connection: pass connection type as a parameter.

This allows the iOS Notification extension to handle
connection requests appropriately.

Change-Id: Iea92cf7015dee1750c85c4495a4fdb3b72cb8331
This commit is contained in:
Kateryna Kostiuk
2024-11-19 15:09:57 -05:00
parent a1bba4d761
commit d2e12fc12c
12 changed files with 181 additions and 97 deletions

View File

@ -37,8 +37,14 @@ public:
* @param deviceId The device to connect
* @param name The name of the channel
* @param cb The callback to call when connected (can be immediate if already connected)
* @param connectionType The connection type used by iOS notifications (not used)
* @param forceNewConnection If we want a new SIP connection (not used)
*/
virtual void connect(const DeviceId& deviceId, const std::string& name, ConnectCb&& cb)
virtual void connect(const DeviceId& deviceId,
const std::string& name,
ConnectCb&& cb,
const std::string& connectionType = "",
bool forceNewConnection = false)
= 0;
/**
@ -47,7 +53,9 @@ public:
* @param name The name of the channel
* @return if we accept or not
*/
virtual bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer, const std::string& name) = 0;
virtual bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer,
const std::string& name)
= 0;
/**
* Called when ConnectionManager has a new channel ready
@ -61,4 +69,4 @@ public:
= 0;
};
} // namespace jami
} // namespace jami

View File

@ -30,7 +30,9 @@ ConversationChannelHandler::~ConversationChannelHandler() {}
void
ConversationChannelHandler::connect(const DeviceId& deviceId,
const std::string& channelName,
ConnectCb&& cb)
ConnectCb&& cb,
const std::string& connectionType,
bool forceNewConnection)
{
connectionManager_.connectDevice(deviceId,
"git://" + deviceId.toString() + "/" + channelName,
@ -65,4 +67,4 @@ ConversationChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certifica
std::shared_ptr<dhtnet::ChannelSocket>)
{}
} // namespace jami
} // namespace jami

View File

@ -28,7 +28,8 @@ namespace jami {
class ConversationChannelHandler : public ChannelHandlerInterface
{
public:
ConversationChannelHandler(const std::shared_ptr<JamiAccount>& acc, dhtnet::ConnectionManager& cm);
ConversationChannelHandler(const std::shared_ptr<JamiAccount>& acc,
dhtnet::ConnectionManager& cm);
~ConversationChannelHandler();
/**
@ -36,8 +37,14 @@ public:
* @param deviceId The device to connect
* @param name The name of the channel
* @param cb The callback to call when connected (can be immediate if already connected)
* @param connectionType The connection type used by iOS notifications (not used)
* @param forceNewConnection If we want a new SIP connection (not used)
*/
void connect(const DeviceId& deviceId, const std::string& name, ConnectCb&& cb) override;
void connect(const DeviceId& deviceId,
const std::string& name,
ConnectCb&& cb,
const std::string& connectionType = "",
bool forceNewConnection = false) override;
/**
* Determine if we accept or not the git request
@ -45,7 +52,8 @@ public:
* @param name name asked
* @return if the channel is for a valid conversation and device not banned
*/
bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer, const std::string& name) override;
bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer,
const std::string& name) override;
/**
* TODO, this needs to extract gitservers from JamiAccount
@ -59,4 +67,4 @@ private:
dhtnet::ConnectionManager& connectionManager_;
};
} // namespace jami
} // namespace jami

View File

@ -648,7 +648,7 @@ JamiAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::
}
JAMI_WARNING("[call {}] No channeled socket with this peer. Send request",
call->getCallId());
call->getCallId());
// Else, ask for a channel (for future calls/text messages)
auto type = call->hasVideo() ? "videoCall" : "audioCall";
requestSIPConnection(toUri, deviceId, type, true, dev_call);
@ -674,8 +674,7 @@ JamiAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::
channels.emplace_back(sipConn.channel);
JAMI_WARNING("[call {}] A channeled socket is detected with this peer.",
call->getCallId());
JAMI_WARNING("[call {}] A channeled socket is detected with this peer.", call->getCallId());
auto dev_call = createSubCall(call);
dev_call->setPeerNumber(call->getPeerNumber());
@ -790,7 +789,8 @@ JamiAccount::onConnectedOutgoingCall(const std::shared_ptr<SIPCall>& call,
}
if (not sdp.createOffer(mediaAttrList)) {
JAMI_ERROR("[call:{}] Unable to send outgoing INVITE request for new call", call->getCallId());
JAMI_ERROR("[call:{}] Unable to send outgoing INVITE request for new call",
call->getCallId());
return;
}
@ -806,7 +806,8 @@ JamiAccount::onConnectedOutgoingCall(const std::shared_ptr<SIPCall>& call,
return;
if (not account->SIPStartCall(*call, target)) {
JAMI_ERROR("[call:{}] Unable to send outgoing INVITE request for new call", call->getCallId());
JAMI_ERROR("[call:{}] Unable to send outgoing INVITE request for new call",
call->getCallId());
}
});
}
@ -835,7 +836,11 @@ JamiAccount::SIPStartCall(SIPCall& call, const dhtnet::IpAddr& target)
auto pjContact = sip_utils::CONST_PJ_STR(contact);
JAMI_LOG("[call:{}] contact header: {} / {} -> {} / {}",
call.getCallId(), contact, from, toUri, targetStr);
call.getCallId(),
contact,
from,
toUri,
targetStr);
auto local_sdp = call.getSDP().getLocalSdpSession();
pjsip_dialog* dialog {nullptr};
@ -861,7 +866,8 @@ JamiAccount::SIPStartCall(SIPCall& call, const dhtnet::IpAddr& target)
}
tp_sel.u.transport = call.getTransport()->get();
if (pjsip_dlg_set_transport(dialog, &tp_sel) != PJ_SUCCESS) {
JAMI_ERROR("[call:{}] Unable to associate transport for invite session dialog", call.getCallId());
JAMI_ERROR("[call:{}] Unable to associate transport for invite session dialog",
call.getCallId());
return false;
}
@ -954,8 +960,7 @@ JamiAccount::changeArchivePassword(const std::string& password_old, const std::s
config.archiveHasPassword = not password_new.empty();
});
} catch (const std::exception& ex) {
JAMI_ERROR("[Account {}] Unable to change archive password: {}",
getAccountID(), ex.what());
JAMI_ERROR("[Account {}] Unable to change archive password: {}", getAccountID(), ex.what());
if (password_old.empty()) {
editConfig([&](JamiAccountConfig& config) { config.archiveHasPassword = true; });
emitSignal<libjami::ConfigurationSignal::AccountDetailsChanged>(getAccountID(),
@ -1252,12 +1257,12 @@ JamiAccount::loadAccount(const std::string& archive_password_scheme,
if (info->identity.first->getPublicKey().getLongId() != oldIdentity) {
JAMI_WARNING("[Account {:s}] identity changed", getAccountID());
{
std::lock_guard lk(moduleMtx_);
convModule_.reset();
std::lock_guard lk(moduleMtx_);
convModule_.reset();
}
convModule(); // convModule must absolutely be initialized in
convModule(); // convModule must absolutely be initialized in
// both branches of the if statement here in order
// for it to exist for subsequent use.
// for it to exist for subsequent use.
} else {
convModule()->setAccountManager(accountManager_);
}
@ -2012,7 +2017,10 @@ JamiAccount::doRegister_()
});
connectionManager_->onChannelRequest(
[this](const std::shared_ptr<dht::crypto::Certificate>& cert, const std::string& name) {
JAMI_WARNING("[Account {}] New channel asked with name {} from {}", getAccountID(), name, cert->issuer->getId());
JAMI_WARNING("[Account {}] New channel asked with name {} from {}",
getAccountID(),
name,
cert->issuer->getId());
if (this->config().turnEnabled && turnCache_) {
auto addr = turnCache_->getResolvedTurn();
@ -2595,7 +2603,8 @@ JamiAccount::loadCachedUrl(const std::string& url,
JAMI_WARNING("Failed to download url, using cached data");
std::string data;
{
std::lock_guard lk(dhtnet::fileutils::getFileLock(cachePath));
std::lock_guard lk(
dhtnet::fileutils::getFileLock(cachePath));
data = fileutils::loadTextFile(cachePath);
}
dht::http::Response ret;
@ -3023,7 +3032,9 @@ JamiAccount::sendMessage(const std::string& to,
try {
toUri = parseJamiUri(to);
} catch (...) {
JAMI_ERROR("[Account {}] Failed to send a text message due to an invalid URI {}", getAccountID(), to);
JAMI_ERROR("[Account {}] Failed to send a text message due to an invalid URI {}",
getAccountID(),
to);
if (!onlyConnected)
messageEngine_.onMessageSent(to, token, false, deviceId);
return;
@ -3039,7 +3050,8 @@ JamiAccount::sendMessage(const std::string& to,
// Use the Message channel if available
std::unique_lock clk(connManagerMtx_);
auto* handler =static_cast<MessageChannelHandler*>(channelHandlers_[Uri::Scheme::MESSAGE].get());
auto* handler = static_cast<MessageChannelHandler*>(
channelHandlers_[Uri::Scheme::MESSAGE].get());
if (!handler) {
clk.unlock();
if (!onlyConnected)
@ -3055,7 +3067,7 @@ JamiAccount::sendMessage(const std::string& to,
bool sent = false;
auto conns = handler->getChannels(toUri);
clk.unlock();
for (const auto &conn: conns) {
for (const auto& conn : conns) {
if (MessageChannelHandler::sendMessage(conn, msg)) {
devices->emplace(conn->deviceId());
sent = true;
@ -3084,7 +3096,7 @@ JamiAccount::sendMessage(const std::string& to,
clk.unlock();
std::unique_lock lk(sipConnsMtx_);
for (auto& [key, value]: sipConns_) {
for (auto& [key, value] : sipConns_) {
if (key.first != to or value.empty())
continue;
if (!deviceId.empty() && key.second != device)
@ -3113,7 +3125,7 @@ JamiAccount::sendMessage(const std::string& to,
payloads,
[](void* token, pjsip_event* event) {
std::shared_ptr<TextMessageCtx> c {
(TextMessageCtx*) token};
(TextMessageCtx*) token};
auto code = event->body.tsx_state.tsx->status_code;
runOnMainThread([c = std::move(c), code]() {
if (c) {
@ -3181,8 +3193,12 @@ JamiAccount::sendMessage(const std::string& to,
auto toH = dht::InfoHash(toUri);
// Find listening devices for this account
accountManager_->forEachDevice(toH,
[this, to, devices, payload_type, currentDevice = DeviceId(currentDeviceId())](
const std::shared_ptr<dht::crypto::PublicKey>& dev) {
[this,
to,
devices,
payload_type,
currentDevice = DeviceId(currentDeviceId())](
const std::shared_ptr<dht::crypto::PublicKey>& dev) {
// Test if already sent
auto deviceId = dev->getLongId();
if (!devices->emplace(deviceId).second
@ -3656,10 +3672,12 @@ JamiAccount::callConnectionClosed(const DeviceId& deviceId, bool eraseDummy)
void
JamiAccount::requestMessageConnection(const std::string& peerId,
const DeviceId& deviceId,
const std::string& connectionType,
bool forceNewConnection) {
auto* handler = static_cast<MessageChannelHandler*>(channelHandlers_[Uri::Scheme::MESSAGE].get());
const DeviceId& deviceId,
const std::string& connectionType,
bool forceNewConnection)
{
auto* handler = static_cast<MessageChannelHandler*>(
channelHandlers_[Uri::Scheme::MESSAGE].get());
if (deviceId) {
if (auto connected = handler->getChannel(peerId, deviceId)) {
return;
@ -3670,17 +3688,21 @@ JamiAccount::requestMessageConnection(const std::string& peerId,
return;
}
}
handler->connect(deviceId, "", [w = weak(), peerId](
std::shared_ptr<dhtnet::ChannelSocket> socket, const DeviceId& deviceId) {
if (socket)
if (auto acc = w.lock()) {
acc->messageEngine_.onPeerOnline(peerId);
acc->messageEngine_.onPeerOnline(peerId, deviceId.toString(), true);
}
});
handler->connect(
deviceId,
"",
[w = weak(), peerId](std::shared_ptr<dhtnet::ChannelSocket> socket,
const DeviceId& deviceId) {
if (socket)
if (auto acc = w.lock()) {
acc->messageEngine_.onPeerOnline(peerId);
acc->messageEngine_.onPeerOnline(peerId, deviceId.toString(), true);
}
},
connectionType,
forceNewConnection);
}
void
JamiAccount::requestSIPConnection(const std::string& peerId,
const DeviceId& deviceId,
@ -3692,21 +3714,23 @@ JamiAccount::requestSIPConnection(const std::string& peerId,
if (peerId == getUsername()) {
if (!syncModule()->isConnected(deviceId))
channelHandlers_[Uri::Scheme::SYNC]
->connect(deviceId,
"",
[](std::shared_ptr<dhtnet::ChannelSocket> socket, const DeviceId& deviceId) {});
->connect(deviceId,
"",
[](std::shared_ptr<dhtnet::ChannelSocket> socket,
const DeviceId& deviceId) {});
}
JAMI_LOG("[Account {}] Request SIP connection to peer {} on device {}",
getAccountID(), peerId, deviceId);
getAccountID(),
peerId,
deviceId);
// If a connection already exists or is in progress, no need to do this
std::lock_guard lk(sipConnsMtx_);
auto id = std::make_pair(peerId, deviceId);
if (sipConns_.find(id) != sipConns_.end()) {
JAMI_LOG("[Account {}] A SIP connection with {} already exists",
getAccountID(), deviceId);
JAMI_LOG("[Account {}] A SIP connection with {} already exists", getAccountID(), deviceId);
return;
}
// If not present, create it

View File

@ -22,7 +22,7 @@ namespace jami {
using Key = std::pair<std::string, DeviceId>;
struct MessageChannelHandler::Impl: public std::enable_shared_from_this<Impl>
struct MessageChannelHandler::Impl : public std::enable_shared_from_this<Impl>
{
std::weak_ptr<JamiAccount> account_;
dhtnet::ConnectionManager& connectionManager_;
@ -34,11 +34,13 @@ struct MessageChannelHandler::Impl: public std::enable_shared_from_this<Impl>
, connectionManager_(cm)
{}
void onChannelShutdown(const std::shared_ptr<dhtnet::ChannelSocket>& socket, const std::string& peerId, const DeviceId& device);
void onChannelShutdown(const std::shared_ptr<dhtnet::ChannelSocket>& socket,
const std::string& peerId,
const DeviceId& device);
};
MessageChannelHandler::MessageChannelHandler(const std::shared_ptr<JamiAccount>& acc,
dhtnet::ConnectionManager& cm)
dhtnet::ConnectionManager& cm)
: ChannelHandlerInterface()
, pimpl_(std::make_shared<Impl>(acc, cm))
{}
@ -46,7 +48,11 @@ MessageChannelHandler::MessageChannelHandler(const std::shared_ptr<JamiAccount>&
MessageChannelHandler::~MessageChannelHandler() {}
void
MessageChannelHandler::connect(const DeviceId& deviceId, const std::string&, ConnectCb&& cb)
MessageChannelHandler::connect(const DeviceId& deviceId,
const std::string&,
ConnectCb&& cb,
const std::string& connectionType,
bool forceNewConnection)
{
auto channelName = MESSAGE_SCHEME + deviceId.toString();
if (pimpl_->connectionManager_.isConnecting(deviceId, channelName)) {
@ -57,12 +63,14 @@ MessageChannelHandler::connect(const DeviceId& deviceId, const std::string&, Con
channelName,
std::move(cb),
false,
false,
MIME_TYPE_GIT);
forceNewConnection,
connectionType);
}
void
MessageChannelHandler::Impl::onChannelShutdown(const std::shared_ptr<dhtnet::ChannelSocket>& socket, const std::string& peerId, const DeviceId& device)
MessageChannelHandler::Impl::onChannelShutdown(const std::shared_ptr<dhtnet::ChannelSocket>& socket,
const std::string& peerId,
const DeviceId& device)
{
std::lock_guard lk(connectionsMtx_);
auto connectionsIt = connections_.find({peerId, device});
@ -101,19 +109,19 @@ MessageChannelHandler::getChannels(const std::string& peer) const
bool
MessageChannelHandler::onRequest(const std::shared_ptr<dht::crypto::Certificate>& cert,
const std::string& /* name */)
const std::string& /* name */)
{
auto acc = pimpl_->account_.lock();
if (!cert || !cert->issuer || !acc)
return false;
return true;
//return cert->issuer->getId().toString() == acc->getUsername();
// return cert->issuer->getId().toString() == acc->getUsername();
}
void
MessageChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>& cert,
const std::string&,
std::shared_ptr<dhtnet::ChannelSocket> socket)
const std::string&,
std::shared_ptr<dhtnet::ChannelSocket> socket)
{
auto acc = pimpl_->account_.lock();
if (!cert || !cert->issuer || !acc)
@ -123,7 +131,7 @@ MessageChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
std::lock_guard lk(pimpl_->connectionsMtx_);
pimpl_->connections_[{peerId, device}].emplace_back(socket);
socket->onShutdown([w = pimpl_->weak_from_this(), peerId, device, s=std::weak_ptr(socket)]() {
socket->onShutdown([w = pimpl_->weak_from_this(), peerId, device, s = std::weak_ptr(socket)]() {
if (auto shared = w.lock())
shared->onChannelShutdown(s.lock(), peerId, device);
});
@ -135,9 +143,9 @@ MessageChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
1500};
};
socket->setOnRecv([acc = pimpl_->account_.lock(), peerId,
ctx = std::make_shared<DecodingContext>()
](const uint8_t* buf, size_t len) {
socket->setOnRecv([acc = pimpl_->account_.lock(),
peerId,
ctx = std::make_shared<DecodingContext>()](const uint8_t* buf, size_t len) {
if (!buf || !acc)
return len;
@ -161,7 +169,8 @@ MessageChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
}
bool
MessageChannelHandler::sendMessage(const std::shared_ptr<dhtnet::ChannelSocket>& socket, const Message& message)
MessageChannelHandler::sendMessage(const std::shared_ptr<dhtnet::ChannelSocket>& socket,
const Message& message)
{
if (!socket)
return false;

View File

@ -36,10 +36,17 @@ public:
* @param deviceId The device to connect
* @param name (Unused, generated from deviceId)
* @param cb The callback to call when connected (can be immediate if already connected)
* @param connectionType for iOS notifications
* @param forceNewConnection If we want a new SIP connection
*/
void connect(const DeviceId& deviceId, const std::string&, ConnectCb&& cb) override;
void connect(const DeviceId& deviceId,
const std::string&,
ConnectCb&& cb,
const std::string& connectionType,
bool forceNewConnection = false) override;
std::shared_ptr<dhtnet::ChannelSocket> getChannel(const std::string& peer, const DeviceId& deviceId) const;
std::shared_ptr<dhtnet::ChannelSocket> getChannel(const std::string& peer,
const DeviceId& deviceId) const;
std::vector<std::shared_ptr<dhtnet::ChannelSocket>> getChannels(const std::string& peer) const;
/**
@ -48,7 +55,8 @@ public:
* @param name Name asked
* @return if the channel is for a valid conversation and device not banned
*/
bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer, const std::string& name) override;
bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer,
const std::string& name) override;
/**
* Launch message process
@ -60,10 +68,11 @@ public:
const std::string& name,
std::shared_ptr<dhtnet::ChannelSocket> channel) override;
struct Message {
std::string t; /* Message type */
std::string c; /* Message content */
std::unique_ptr<ConversationRequest> req; /* Conversation request */
struct Message
{
std::string t; /* Message type */
std::string c; /* Message content */
std::unique_ptr<ConversationRequest> req; /* Conversation request */
MSGPACK_DEFINE_MAP(t, c, req)
};
@ -74,4 +83,4 @@ private:
std::shared_ptr<Impl> pimpl_;
};
} // namespace jami
} // namespace jami

View File

@ -31,7 +31,9 @@ SwarmChannelHandler::~SwarmChannelHandler() {}
void
SwarmChannelHandler::connect(const DeviceId& deviceId,
const std::string& conversationId,
ConnectCb&& cb)
ConnectCb&& cb,
const std::string& connectionType,
bool forceNewConnection)
{
#ifdef LIBJAMI_TESTABLE
if (disableSwarmManager)
@ -76,4 +78,4 @@ SwarmChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&,
}
}
}
} // namespace jami
} // namespace jami

View File

@ -46,8 +46,14 @@ public:
* @param nodeId The node to connect
* @param name The name of the channel
* @param cb The callback to call when connected (can be immediate if already connected)
* @param connectionType The connection type used by iOS notifications (not used)
* @param forceNewConnection If we want a new SIP connection (not used)
*/
void connect(const NodeId& nodeId, const std::string& name, ConnectCb&& cb) override;
void connect(const NodeId& nodeId,
const std::string& name,
ConnectCb&& cb,
const std::string& connectionType = "",
bool forceNewConnection = false) override;
/**
* Determine if we accept or not the git request
@ -70,4 +76,4 @@ private:
dhtnet::ConnectionManager& connectionManager_;
};
} // namespace jami
} // namespace jami

View File

@ -31,16 +31,18 @@ SyncChannelHandler::SyncChannelHandler(const std::shared_ptr<JamiAccount>& acc,
SyncChannelHandler::~SyncChannelHandler() {}
void
SyncChannelHandler::connect(const DeviceId& deviceId, const std::string&, ConnectCb&& cb)
SyncChannelHandler::connect(const DeviceId& deviceId,
const std::string&,
ConnectCb&& cb,
const std::string& connectionType,
bool forceNewConnection)
{
auto channelName = SYNC_SCHEME + deviceId.toString();
if (connectionManager_.isConnecting(deviceId, channelName)) {
JAMI_LOG("Already connecting to {}", deviceId);
return;
}
connectionManager_.connectDevice(deviceId,
channelName,
std::move(cb));
connectionManager_.connectDevice(deviceId, channelName, std::move(cb));
}
bool
@ -65,10 +67,10 @@ SyncChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>& cer
sm->cacheSyncConnection(std::move(channel),
cert->issuer->getId().toString(),
cert->getLongId());
dht::ThreadPool::io().run([account=account_, channel]() {
dht::ThreadPool::io().run([account = account_, channel]() {
if (auto acc = account.lock())
acc->sendProfile("", acc->getUsername(), channel->deviceId().toString());
});
}
} // namespace jami
} // namespace jami

View File

@ -36,8 +36,14 @@ public:
* @param deviceId The device to connect
* @param name (Unused, generated from deviceId)
* @param cb The callback to call when connected (can be immediate if already connected)
* @param connectionType The connection type used by iOS notifications (not used)
* @param forceNewConnection If we want a new SIP connection (not used)
*/
void connect(const DeviceId& deviceId, const std::string&, ConnectCb&& cb) override;
void connect(const DeviceId& deviceId,
const std::string&,
ConnectCb&& cb,
const std::string& connectionType = "",
bool forceNewConnection = false) override;
/**
* Determine if we accept or not the sync request
@ -45,7 +51,8 @@ public:
* @param name Name asked
* @return if the channel is for a valid conversation and device not banned
*/
bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer, const std::string& name) override;
bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer,
const std::string& name) override;
/**
* Launch sync process
@ -62,4 +69,4 @@ private:
dhtnet::ConnectionManager& connectionManager_;
};
} // namespace jami
} // namespace jami

View File

@ -38,7 +38,9 @@ TransferChannelHandler::~TransferChannelHandler() {}
void
TransferChannelHandler::connect(const DeviceId& deviceId,
const std::string& channelName,
ConnectCb&& cb)
ConnectCb&& cb,
const std::string& connectionType,
bool forceNewConnection)
{}
bool
@ -80,10 +82,7 @@ TransferChannelHandler::onRequest(const std::shared_ptr<dht::crypto::Certificate
return uri == acc->getUsername();
}
return cm->onFileChannelRequest(conversationId,
uri,
std::string(fileId),
acc->sha3SumVerify());
return cm->onFileChannelRequest(conversationId, uri, std::string(fileId), acc->sha3SumVerify());
}
void
@ -122,7 +121,8 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
lastModified = jami::to_int<uint64_t>(keyVal[1]);
} catch (const std::exception& e) {
JAMI_WARNING("TransferChannel: Unable to parse modified date: {}: {}",
keyVal[1], e.what());
keyVal[1],
e.what());
}
}
}
@ -185,4 +185,4 @@ TransferChannelHandler::onReady(const std::shared_ptr<dht::crypto::Certificate>&
dt->transferFile(channel, fileId, interactionId, path.string(), start, end);
}
} // namespace jami
} // namespace jami

View File

@ -37,8 +37,14 @@ public:
* @param deviceId The device to connect
* @param channelName The name of the channel
* @param cb The callback to call when connected (can be immediate if already connected)
* @param connectionType The connection type used by iOS notifications (not used)
* @param forceNewConnection If we want a new SIP connection (not used)
*/
void connect(const DeviceId& deviceId, const std::string& channelName, ConnectCb&& cb) override;
void connect(const DeviceId& deviceId,
const std::string& channelName,
ConnectCb&& cb,
const std::string& connectionType = "",
bool forceNewConnection = false) override;
/**
* Determine if we accept or not the request
@ -46,7 +52,8 @@ public:
* @param name name asked
* @return if we accept or not
*/
bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer, const std::string& name) override;
bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer,
const std::string& name) override;
/**
* Handle socket ready
@ -65,4 +72,4 @@ private:
std::filesystem::path idPath_;
};
} // namespace jami
} // namespace jami