diff options
author | George Hazan <george.hazan@gmail.com> | 2024-08-01 20:51:22 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-08-01 20:51:22 +0300 |
commit | 7942ead292c9f159ddde7b16c7eb25fa2c751924 (patch) | |
tree | 52ff48d05506e25f7ffd17ac19240c3c83500c45 /protocols/SkypeWeb | |
parent | 749751e81dbd135946b66cb44ebd69ffef7a9a1e (diff) |
SkypeWeb: added code to receive offline files (doesn't work for now)
Diffstat (limited to 'protocols/SkypeWeb')
-rw-r--r-- | protocols/SkypeWeb/src/main.cpp | 4 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_events.cpp | 4 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_files.cpp | 65 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_proto.cpp | 2 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_proto.h | 15 |
5 files changed, 81 insertions, 9 deletions
diff --git a/protocols/SkypeWeb/src/main.cpp b/protocols/SkypeWeb/src/main.cpp index e37ab796e7..cd3cd257da 100644 --- a/protocols/SkypeWeb/src/main.cpp +++ b/protocols/SkypeWeb/src/main.cpp @@ -68,8 +68,8 @@ int CMPlugin::Load() CSkypeProto::InitMenus();
CSkypeProto::InitLanguages();
- CreateServiceFunction(MODULE "/GetEventIcon", &CSkypeProto::EventGetIcon);
- CreateServiceFunction(MODULE "/GetEventText", &CSkypeProto::GetEventText);
+ CreateServiceFunction(MODULE "/GetEventIcon", &CSkypeProto::SvcEventGetIcon);
+ CreateServiceFunction(MODULE "/GetEventText", &CSkypeProto::SvcGetEventText);
g_hCallEvent = CreateHookableEvent(MODULE "/IncomingCall");
diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp index 44d662f4e5..acd5208277 100644 --- a/protocols/SkypeWeb/src/skype_events.cpp +++ b/protocols/SkypeWeb/src/skype_events.cpp @@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
-INT_PTR CSkypeProto::GetEventText(WPARAM pEvent, LPARAM datatype)
+INT_PTR CSkypeProto::SvcGetEventText(WPARAM pEvent, LPARAM datatype)
{
DBEVENTINFO *dbei = (DBEVENTINFO*)pEvent;
@@ -111,7 +111,7 @@ INT_PTR CSkypeProto::GetEventText(WPARAM pEvent, LPARAM datatype) return (datatype == DBVT_WCHAR) ? (INT_PTR)mir_a2u(szText) : (INT_PTR)szText.Detach();
}
-INT_PTR CSkypeProto::EventGetIcon(WPARAM flags, LPARAM pEvent)
+INT_PTR CSkypeProto::SvcEventGetIcon(WPARAM flags, LPARAM pEvent)
{
DBEVENTINFO *dbei = (DBEVENTINFO*)pEvent;
HICON icon = nullptr;
diff --git a/protocols/SkypeWeb/src/skype_files.cpp b/protocols/SkypeWeb/src/skype_files.cpp index a8045419be..24875a5590 100644 --- a/protocols/SkypeWeb/src/skype_files.cpp +++ b/protocols/SkypeWeb/src/skype_files.cpp @@ -1,5 +1,70 @@ #include "stdafx.h"
+////////////////////////////////////////////////////////////////////////////////////////
+// File receiving
+
+static void __cdecl DownloadCallack(size_t iProgress, void *pParam)
+{
+ auto *ofd = (OFDTHREAD *)pParam;
+
+ DBVARIANT dbv = { DBVT_DWORD };
+ dbv.dVal = unsigned(iProgress);
+ db_event_setJson(ofd->hDbEvent, "ft", &dbv);
+}
+
+void CSkypeProto::ReceiveFileThread(void *param)
+{
+ auto *ofd = (OFDTHREAD *)param;
+
+ DB::EventInfo dbei(ofd->hDbEvent);
+ if (IsOnline() && dbei && !strcmp(dbei.szModule, m_szModuleName) && dbei.eventType == EVENTTYPE_FILE) {
+ DB::FILE_BLOB blob(dbei);
+
+ if (ofd->bCopy) {
+ ofd->wszPath = Utf2T(blob.getUrl()).get();
+ ofd->pCallback->Invoke(*ofd);
+ }
+ else {
+ CMStringA szCookie;
+ szCookie.AppendFormat("skypetoken_asm=%s", m_szApiToken.get());
+
+ MHttpRequest nlhr(REQUEST_GET);
+ nlhr.m_szUrl = blob.getUrl();
+ nlhr.AddHeader("Sec-Fetch-User", "?1");
+ nlhr.AddHeader("Sec-Fetch-Site", "same-site");
+ nlhr.AddHeader("Sec-Fetch-Mode", "navigate");
+ nlhr.AddHeader("Sec-Fetch-Dest", "empty");
+ nlhr.AddHeader("Accept", "*/*");
+ nlhr.AddHeader("Accept-Encoding", "gzip");
+ nlhr.AddHeader("Cookie", szCookie);
+ nlhr.AddHeader("Referer", "https://web.skype.com/");
+
+ NLHR_PTR reply(Netlib_DownloadFile(m_hNetlibUser, &nlhr, ofd->wszPath, DownloadCallack, ofd));
+ if (reply && reply->resultCode == 200) {
+ struct _stat st;
+ _wstat(ofd->wszPath, &st);
+
+ DBVARIANT dbv = { DBVT_DWORD };
+ dbv.dVal = st.st_size;
+ db_event_setJson(ofd->hDbEvent, "ft", &dbv);
+
+ ofd->Finish();
+ }
+ }
+ }
+
+ delete ofd;
+}
+
+INT_PTR CSkypeProto::SvcOfflineFile(WPARAM param, LPARAM)
+{
+ ForkThread(&CSkypeProto::ReceiveFileThread, (void *)param);
+ return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+// File sending
+
#define FILETRANSFER_FAILED(fup) { ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)fup); delete fup; fup = nullptr;}
HANDLE CSkypeProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles)
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index e57ed0c346..a75ef8751f 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -42,6 +42,8 @@ CSkypeProto::CSkypeProto(const char* protoName, const wchar_t* userName) : CreateProtoService(PS_GETMYAVATAR, &CSkypeProto::SvcGetMyAvatar);
CreateProtoService(PS_SETMYAVATAR, &CSkypeProto::SvcSetMyAvatar);
+ CreateProtoService(PS_OFFLINEFILE, &CSkypeProto::SvcOfflineFile);
+
CreateProtoService(PS_MENU_REQAUTH, &CSkypeProto::OnRequestAuth);
CreateProtoService(PS_MENU_GRANTAUTH, &CSkypeProto::OnGrantAuth);
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index bd71a99658..7a4da4ff38 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -95,13 +95,13 @@ public: static void InitLanguages();
// search
- void __cdecl SearchBasicThread(void* id);
+ void __cdecl SearchBasicThread(void *param);
//////////////////////////////////////////////////////////////////////////////////////
// services
- static INT_PTR EventGetIcon(WPARAM wParam, LPARAM lParam);
- static INT_PTR GetEventText(WPARAM, LPARAM lParam);
+ static INT_PTR __cdecl SvcEventGetIcon(WPARAM, LPARAM);
+ static INT_PTR __cdecl SvcGetEventText(WPARAM, LPARAM);
//////////////////////////////////////////////////////////////////////////////////////
// settings
@@ -251,6 +251,11 @@ private: MCONTACT GetContactFromAuthEvent(MEVENT hEvent);
+ // files
+ void __cdecl ReceiveFileThread(void *param);
+
+ INT_PTR __cdecl SvcOfflineFile(WPARAM, LPARAM);
+
// messages
std::map<ULONGLONG, HANDLE> m_mpOutMessagesIds;
@@ -326,10 +331,10 @@ private: CMStringW ChangeTopicForm();
- //events
+ // events
void InitDBEvents();
- //services
+ // services
INT_PTR __cdecl BlockContact(WPARAM hContact, LPARAM);
INT_PTR __cdecl UnblockContact(WPARAM hContact, LPARAM);
INT_PTR __cdecl OnRequestAuth(WPARAM hContact, LPARAM lParam);
|