summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_ft.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/JabberG/src/jabber_ft.cpp')
-rw-r--r--protocols/JabberG/src/jabber_ft.cpp27
1 files changed, 21 insertions, 6 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];