From 6a889421589f6ecfc9b21d8fc45891292c7f577b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 23 Mar 2020 15:04:29 +0300 Subject: Jabber: fix for offline file transfer initialization --- protocols/JabberG/src/jabber_ft.cpp | 27 +++++++++++++++++++++------ protocols/JabberG/src/jabber_proto.cpp | 4 +--- 2 files changed, 22 insertions(+), 9 deletions(-) (limited to 'protocols/JabberG/src') diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index cea0891736..774ee23d0b 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -86,12 +86,15 @@ static void __cdecl FakeAckThread(void *param) void CJabberProto::FtInitiate(const char* jid, filetransfer *ft) { - char *rs = ListGetBestClientResourceNamePtr(jid); - if (ft == nullptr || !m_bJabberOnline || rs == nullptr) { - if (ft) { - ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft); - delete ft; - } + if (ft == nullptr) + return; + + if (!m_bJabberOnline) { + debugLogA("Protocol is offline, file transfer failed"); + +LBL_Error: + ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft); + delete ft; return; } @@ -139,6 +142,18 @@ void CJabberProto::FtInitiate(const char* jid, filetransfer *ft) } } + // offline methods are over, the following code assumes that a contact is online + if (getWord(ft->std.hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) { + debugLogA("%S is offline, file transfer failed", Clist_GetContactDisplayName(ft->std.hContact)); + goto LBL_Error; + } + + char *rs = ListGetBestClientResourceNamePtr(jid); + if (rs == nullptr) { + debugLogA("%S has no current resource available, file transfer failed", Clist_GetContactDisplayName(ft->std.hContact)); + goto LBL_Error; + } + // no cloud services enabled, try to initiate a p2p file transfer ft->type = FT_SI; char sid[9]; diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index f65afa894a..4bdacb12ea 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -827,9 +827,7 @@ int CJabberProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONTACT * HANDLE CJabberProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t** ppszFiles) { - if (!m_bJabberOnline) return nullptr; - - if (getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) + if (!m_bJabberOnline) return nullptr; ptrA jid(getUStringA(hContact, "jid")); -- cgit v1.2.3