52 auto acc = account_.lock();
55 auto cm = acc->convModule(
true);
58 auto uri =
cert->issuer->getId().toString();
64 if (
idstr ==
"profile.vcf") {
66 return uri == acc->getUsername();
70 auto conversationId = std::string(
idstr.substr(0,
sep));
73 if (
fileHost == acc->currentDeviceId())
77 if (fileId == fmt::format(
"{}.vcf", acc->getUsername()) || fileId ==
"profile.vcf") {
79 auto members =
cm->getConversationMembers(conversationId);
80 return std::find_if(members.begin(), members.end(), [&](
auto m) { return m[
"uri"] == uri; }) != members.end();
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: {}: {}",
keyVal[1],
e.what());
131 if (
idstr ==
"profile.vcf") {
132 dht::ThreadPool::io().run(
134 if (auto acc = wacc.lock()) {
135 if (!channel->isInitiator()) {
137 if (lastModified == 0 || lastModified > fileutils::lastWriteTimeInSeconds(acc->profilePath()))
138 acc->dataTransfer()->onIncomingProfile(channel, sha3Sum);
143 acc->dataTransfer()->transferFile(channel, idstr,
"", path.string());
152 JAMI_ERROR(
"Unsupported ID detected {}", name);
162 if (channel->isInitiator())
166 dht::ThreadPool::io().run([
wacc = acc->weak(),
167 profilePath = idPath_ /
"profile.vcf",
176 if (auto acc = wacc.lock()) {
177 if (fileId == fmt::format(
"{}.vcf", acc->getUsername())) {
178 acc->dataTransfer()->transferFile(channel, fileId,
"", profilePath.string());
180 } else if (isContactProfile && fileId.find(
".vcf") != std::string::npos) {
181 auto path = acc->dataTransfer()->profilePath(fileId.substr(0, fileId.size() - 4));
182 acc->dataTransfer()->transferFile(channel, fileId,
"", path.string());
184 } else if (fileId ==
"profile.vcf") {
185 acc->dataTransfer()->onIncomingProfile(channel, sha3Sum);
189 auto dt = acc->dataTransfer(conversationId);
190 auto sep = fileId.find(
'_');
191 if (!dt or sep == std::string::npos) {
195 auto interactionId = fileId.substr(0, sep);
196 auto path = dt->path(fileId);
197 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.