49 const std::string& name)
51 auto acc = account_.lock();
54 auto cm = acc->convModule(
true);
57 auto uri =
cert->issuer->getId().toString();
63 if (
idstr ==
"profile.vcf") {
65 return uri == acc->getUsername();
69 auto conversationId = std::string(
idstr.substr(0,
sep));
72 if (
fileHost == acc->currentDeviceId())
76 if (fileId == fmt::format(
"{}.vcf", acc->getUsername()) || fileId ==
"profile.vcf") {
78 auto members =
cm->getConversationMembers(conversationId);
79 return std::find_if(members.begin(), members.end(), [&](
auto m) { return m[
"uri"] == uri; })
83 return uri == acc->getUsername();
86 return cm->onFileChannelRequest(conversationId, uri, std::string(fileId), acc->sha3SumVerify());
91 const std::string& name,
92 std::shared_ptr<dhtnet::ChannelSocket> channel)
94 auto acc = account_.lock();
103 if (
sep != std::string::npos) {
108 auto start = 0
u, end = 0
u;
114 if (
keyVal[0] ==
"start") {
116 }
else if (
keyVal[0] ==
"end") {
118 }
else if (
keyVal[0] ==
"sha3") {
120 }
else if (
keyVal[0] ==
"modified") {
123 }
catch (
const std::exception&
e) {
124 JAMI_WARNING(
"TransferChannel: Unable to parse modified date: {}: {}",
133 if (
idstr ==
"profile.vcf") {
135 if (auto acc = wacc.lock()) {
136 if (!channel->isInitiator()) {
138 if (lastModified == 0
139 || lastModified > fileutils::lastWriteTimeInSeconds(acc->profilePath()))
140 acc->dataTransfer()->onIncomingProfile(channel, sha3Sum);
145 acc->dataTransfer()->transferFile(channel, idstr,
"", path.string());
154 JAMI_ERROR(
"Unsupported ID detected {}", name);
164 if (channel->isInitiator())
168 dht::ThreadPool::io().run([
wacc = acc->weak(), profilePath = idPath_ /
"profile.vcf", channel, conversationId, fileId,
isContactProfile,
idstr, start, end,
sha3Sum] {
169 if (auto acc = wacc.lock()) {
170 if (fileId == fmt::format(
"{}.vcf", acc->getUsername())) {
171 acc->dataTransfer()->transferFile(channel, fileId,
"", profilePath.string());
173 } else if (isContactProfile && fileId.find(
".vcf") != std::string::npos) {
174 auto path = acc->dataTransfer()->profilePath(fileId.substr(0, fileId.size() - 4));
175 acc->dataTransfer()->transferFile(channel, fileId,
"", path.string());
177 } else if (fileId ==
"profile.vcf") {
178 acc->dataTransfer()->onIncomingProfile(channel, sha3Sum);
182 auto dt = acc->dataTransfer(conversationId);
183 auto sep = fileId.find(
'_');
184 if (!dt or sep == std::string::npos) {
188 auto interactionId = fileId.substr(0, sep);
189 auto path = dt->path(fileId);
190 dt->transferFile(channel, fileId, interactionId, path.string(), start, end);
void connect(const DeviceId &deviceId, const std::string &channelName, ConnectCb &&cb, const std::string &connectionType="", bool forceNewConnection=false) override
Ask for a new channel This replaces the connectDevice() in jamiaccount.