mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-07 22:02:12 +08:00
transfer: fix lastEvent detection to avoid multiple finished
And some clean Change-Id: I0e7a607b1749e608f0911f37065a0695df2d45b5
This commit is contained in:
@ -664,11 +664,11 @@
|
||||
<signal name="profileReceived" tp:name-for-bindings="profileReceived">
|
||||
<tp:added version="9.2.0"/>
|
||||
<tp:docstring>
|
||||
Notify clients that a vcard has been received
|
||||
Notify clients that a vCard has been received
|
||||
</tp:docstring>
|
||||
<arg type="s" name="accountID"/>
|
||||
<arg type="s" name="from"/>
|
||||
<arg type="s" name="vcard"/>
|
||||
<arg type="s" name="path"/>
|
||||
</signal>
|
||||
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
virtual void volatileAccountDetailsChanged(const std::string& account_id, const std::map<std::string, std::string>& details){}
|
||||
virtual void incomingAccountMessage(const std::string& /*account_id*/, const std::string& /*message_id*/, const std::string& /*from*/, const std::map<std::string, std::string>& /*payload*/){}
|
||||
virtual void accountMessageStatusChanged(const std::string& /*account_id*/, uint64_t /*message_id*/, const std::string& /*to*/, int /*state*/){}
|
||||
virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*vCard*/){}
|
||||
virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*path*/){}
|
||||
virtual void composingStatusChanged(const std::string& /*account_id*/, const std::string& /*from*/, int /*state*/){}
|
||||
virtual void knownDevicesChanged(const std::string& /*account_id*/, const std::map<std::string, std::string>& /*devices*/){}
|
||||
virtual void exportOnRingEnded(const std::string& /*account_id*/, int /*state*/, const std::string& /*pin*/){}
|
||||
@ -244,7 +244,7 @@ public:
|
||||
virtual void historyChanged(void){}
|
||||
virtual void stunStatusFailure(const std::string& account_id){}
|
||||
virtual void accountDetailsChanged(const std::string& account_id, const std::map<std::string, std::string>& details){}
|
||||
virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*vCard*/) {}
|
||||
virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*path*/) {}
|
||||
virtual void registrationStateChanged(const std::string& account_id, const std::string& state, int code, const std::string& detail_str){}
|
||||
virtual void volatileAccountDetailsChanged(const std::string& account_id, const std::map<std::string, std::string>& details){}
|
||||
virtual void incomingAccountMessage(const std::string& /*account_id*/, const std::string& /*message_id*/, const std::string& /*from*/, const std::map<std::string, std::string>& /*payload*/){}
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
virtual void volatileAccountDetailsChanged(const std::string& account_id, const std::map<std::string, std::string>& details){}
|
||||
virtual void incomingAccountMessage(const std::string& /*account_id*/, const std::string& /*from*/, const std::map<std::string, std::string>& /*payload*/){}
|
||||
virtual void accountMessageStatusChanged(const std::string& /*account_id*/, uint64_t /*message_id*/, const std::string& /*to*/, int /*state*/){}
|
||||
virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*vCard*/){}
|
||||
virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*path*/){}
|
||||
virtual void knownDevicesChanged(const std::string& /*account_id*/, const std::map<std::string, std::string>& /*devices*/){}
|
||||
virtual void exportOnRingEnded(const std::string& /*account_id*/, int /*state*/, const std::string& /*pin*/){}
|
||||
|
||||
@ -234,7 +234,7 @@ public:
|
||||
virtual void volatileAccountDetailsChanged(const std::string& account_id, const std::map<std::string, std::string>& details){}
|
||||
virtual void incomingAccountMessage(const std::string& /*account_id*/, const std::string& /*from*/, const std::map<std::string, std::string>& /*payload*/){}
|
||||
virtual void accountMessageStatusChanged(const std::string& /*account_id*/, uint64_t /*message_id*/, const std::string& /*to*/, int /*state*/){}
|
||||
virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*vCard*/){}
|
||||
virtual void profileReceived(const std::string& /*account_id*/, const std::string& /*from*/, const std::string& /*path*/){}
|
||||
virtual void knownDevicesChanged(const std::string& /*account_id*/, const std::map<std::string, std::string>& /*devices*/){}
|
||||
virtual void exportOnRingEnded(const std::string& /*account_id*/, int /*state*/, const std::string& /*pin*/){}
|
||||
|
||||
|
@ -122,12 +122,12 @@ protected:
|
||||
void
|
||||
DataTransfer::emit(DRing::DataTransferEventCode code) const
|
||||
{
|
||||
if (internalCompletionCb_)
|
||||
return; // VCard transfer is just for the daemon
|
||||
{
|
||||
std::lock_guard<std::mutex> lk {infoMutex_};
|
||||
info_.lastEvent = code;
|
||||
}
|
||||
if (internalCompletionCb_)
|
||||
return; // VCard transfer is just for the daemon
|
||||
emitSignal<DRing::DataTransferSignal::DataTransferEvent>(id, uint32_t(code));
|
||||
}
|
||||
|
||||
@ -643,11 +643,9 @@ IncomingFileTransfer::close() noexcept
|
||||
JAMI_DBG() << "[FTP] file closed, rx " << info_.bytesProgress
|
||||
<< " on " << info_.totalSize;
|
||||
if (info_.bytesProgress >= info_.totalSize) {
|
||||
if (internalCompletionCb_) {
|
||||
if (internalCompletionCb_)
|
||||
internalCompletionCb_(info_.path);
|
||||
} else {
|
||||
emit(DRing::DataTransferEventCode::finished);
|
||||
}
|
||||
emit(DRing::DataTransferEventCode::finished);
|
||||
}
|
||||
else
|
||||
emit(DRing::DataTransferEventCode::closed_by_host);
|
||||
|
@ -2055,12 +2055,12 @@ JamiAccount::doRegister_()
|
||||
uint64_t tid;
|
||||
std::istringstream iss(tid_str);
|
||||
iss >> tid;
|
||||
dhtPeerConnector_->onIncomingConnection(peerId, tid, std::move(channel),
|
||||
[peerId, accountId=getAccountID()](const std::string& path) {
|
||||
auto vCard = fileutils::loadTextFile(path);
|
||||
emitSignal<DRing::ConfigurationSignal::ProfileReceived>(accountId, peerId, vCard);
|
||||
fileutils::remove(path, true);
|
||||
});
|
||||
std::function<void(const std::string&)> cb;
|
||||
if (isVCard)
|
||||
cb = [peerId, accountId=getAccountID()](const std::string& path) {
|
||||
emitSignal<DRing::ConfigurationSignal::ProfileReceived>(accountId, peerId, path);
|
||||
};
|
||||
dhtPeerConnector_->onIncomingConnection(peerId, tid, std::move(channel), std::move(cb));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -3338,7 +3338,7 @@ JamiAccount::sendSIPMessage(SipConnection& conn, const std::string& to, void* ct
|
||||
}
|
||||
|
||||
void
|
||||
JamiAccount::sendProfile(const std::string& peerId, const std::string& deviceId)
|
||||
JamiAccount::sendProfile(const std::string& deviceId)
|
||||
{
|
||||
try {
|
||||
if (not needToSendProfile(deviceId)) {
|
||||
@ -3405,7 +3405,7 @@ JamiAccount::cacheSIPConnection(std::shared_ptr<ChannelSocket>&& socket, const s
|
||||
JAMI_WARN("New SIP channel opened with %s", deviceId.c_str());
|
||||
lk.unlock();
|
||||
|
||||
sendProfile(peerId, deviceId);
|
||||
sendProfile(deviceId);
|
||||
|
||||
// Retry messages
|
||||
messageEngine_.onPeerOnline(peerId);
|
||||
|
@ -747,10 +747,9 @@ private:
|
||||
bool needToSendProfile(const std::string& deviceId);
|
||||
/**
|
||||
* Send Profile via cached SIP connection
|
||||
* @param peerId Peer related
|
||||
* @param deviceId Device that will receive the profile
|
||||
*/
|
||||
void sendProfile(const std::string& peerId, const std::string& deviceId);
|
||||
void sendProfile(const std::string& deviceId);
|
||||
};
|
||||
|
||||
static inline std::ostream& operator<< (std::ostream& os, const JamiAccount& acc)
|
||||
|
Reference in New Issue
Block a user