summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/JabberG/src/jabber_file.cpp41
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp17
-rw-r--r--protocols/JabberG/src/jabber_proto.h7
-rw-r--r--protocols/Sametime/src/sametime_proto.cpp2
-rw-r--r--protocols/Sametime/src/sametime_proto.h2
5 files changed, 66 insertions, 3 deletions
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp
index e76e81b123..24ea2c6296 100644
--- a/protocols/JabberG/src/jabber_file.cpp
+++ b/protocols/JabberG/src/jabber_file.cpp
@@ -25,6 +25,47 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "jabber_caps.h"
+INT_PTR __cdecl CJabberProto::OnOfflineFile(WPARAM param, LPARAM)
+{
+ ForkThread((MyThreadFunc)&CJabberProto::OfflineFileThread, (void*)param);
+ return 0;
+}
+
+void __cdecl CJabberProto::OfflineFileThread(OFDTHREAD *param)
+{
+ DB::EventInfo dbei(param->hDbEvent);
+ if (dbei && !strcmp(dbei.szModule, m_szModuleName) && dbei.eventType == EVENTTYPE_FILE) {
+ DB::FILE_BLOB blob(dbei);
+ if (blob.isOffline()) {
+ // initialize the netlib request
+ NETLIBHTTPREQUEST nlhr = {};
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_HTTP11 | NLHRF_DUMPASTEXT | NLHRF_REDIRECT;
+ nlhr.szUrl = (char*)blob.getUrl();
+
+ // download the page
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
+ if (nlhrReply) {
+ if (nlhrReply->resultCode == 200) {
+ FILE *f = _wfopen(param->wszPath, L"wb");
+ fwrite(nlhrReply->pData, 1, nlhrReply->dataLength, f);
+ fclose(f);
+
+ blob.setSize(nlhrReply->dataLength);
+ blob.write(dbei);
+ db_event_edit(param->hDbEvent, &dbei);
+
+ if (param->bOpen)
+ ShellExecute(nullptr, L"open", param->wszPath, nullptr, nullptr, SW_SHOWDEFAULT);
+ }
+ }
+ }
+ }
+
+ delete param;
+}
+
#define JABBER_NETWORK_BUFFER_SIZE 2048
void __cdecl CJabberProto::FileReceiveHttpThread(filetransfer *ft)
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 9891bfd60f..acc141e114 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -188,6 +188,9 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) :
// XEP-0224 support (Attention/Nudge)
CreateProtoService(PS_SEND_NUDGE, &CJabberProto::JabberSendNudge);
+ // Offline file transfer
+ CreateProtoService(PS_OFFLINEFILE, &CJabberProto::OnOfflineFile);
+
// service to get from protocol chat buddy info
CreateProtoService(MS_GC_PROTO_GETTOOLTIPTEXT, &CJabberProto::JabberGCGetToolTipText);
@@ -809,6 +812,20 @@ HANDLE CJabberProto::SearchByName(const wchar_t *nick, const wchar_t *firstName,
return (HANDLE)pInfo->GetIqId();
}
+MEVENT CJabberProto::RecvFile(MCONTACT hContact, PROTORECVFILE *pre)
+{
+ MEVENT hEvent = CSuper::RecvFile(hContact, pre);
+ if (hEvent) {
+ auto *ft = (filetransfer *)pre->lParam;
+ if (ft && ft->type == FT_HTTP && ft->httpPath) {
+ DBVARIANT dbv = { DBVT_UTF8 };
+ dbv.pszVal = ft->httpPath;
+ db_event_setJson(hEvent, "u", &dbv);
+ }
+ }
+ return hEvent;
+}
+
////////////////////////////////////////////////////////////////////////////////////////
// SendContacts
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index f940f3349d..019ea10d35 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -135,6 +135,8 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
HANDLE SearchAdvanced(HWND owner) override;
HWND CreateExtendedSearchUI(HWND owner) override;
+ MEVENT RecvFile(MCONTACT hContact, PROTORECVFILE *pre) override;
+
int SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList) override;
HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles) override;
int SendMsg(MCONTACT hContact, int flags, const char *msg) override;
@@ -506,7 +508,10 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void __cdecl FileReceiveThread(filetransfer *ft);
void __cdecl FileServerThread(filetransfer *ft);
void __cdecl FileReceiveHttpThread(filetransfer *ft);
-
+
+ INT_PTR __cdecl OnOfflineFile(WPARAM dbevent, LPARAM lParam);
+ void __cdecl OfflineFileThread(OFDTHREAD *param);
+
void FtCancel(filetransfer *ft);
void FtInitiate(filetransfer *ft);
void FtHandleSiRequest(const TiXmlElement *iqNode);
diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp
index 1ca043c75a..179f01999d 100644
--- a/protocols/Sametime/src/sametime_proto.cpp
+++ b/protocols/Sametime/src/sametime_proto.cpp
@@ -162,7 +162,7 @@ HWND CSametimeProto::CreateExtendedSearchUI(HWND owner)
}
-int CSametimeProto::RecvFile(MCONTACT hContact, PROTORECVFILE* pre)
+MEVENT CSametimeProto::RecvFile(MCONTACT hContact, PROTORECVFILE* pre)
{
debugLogW(L"CSametimeProto::RecvFile() hContact=[%x]", hContact);
diff --git a/protocols/Sametime/src/sametime_proto.h b/protocols/Sametime/src/sametime_proto.h
index 036ca4d2c0..fb022ae3c2 100644
--- a/protocols/Sametime/src/sametime_proto.h
+++ b/protocols/Sametime/src/sametime_proto.h
@@ -24,7 +24,7 @@ struct CSametimeProto : public PROTO<CSametimeProto>
HANDLE SearchAdvanced(HWND owner) override;
HWND CreateExtendedSearchUI(HWND owner) override;
- int RecvFile(MCONTACT hContact, PROTORECVFILE*) override;
+ MEVENT RecvFile(MCONTACT hContact, PROTORECVFILE*) override;
MEVENT RecvMsg(MCONTACT hContact, PROTORECVEVENT*) override;
HANDLE SendFile(MCONTACT hContact, const wchar_t* szDescription, wchar_t** ppszFiles) override;