summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-03-23 15:04:29 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-03-23 15:04:29 +0300
commit6a889421589f6ecfc9b21d8fc45891292c7f577b (patch)
treecfda5de4ee108d6873fcb17f064fd6f031285635 /protocols
parent35f813b6877408ebc5f37e09da81fd4e8edb769f (diff)
Jabber: fix for offline file transfer initialization
Diffstat (limited to 'protocols')
-rw-r--r--protocols/JabberG/src/jabber_ft.cpp27
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.cpp4
2 files changed, 22 insertions, 9 deletions
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"));