From e79b2d652e8a868b2605a24b1f3796b32e6ea0c9 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Mon, 20 Apr 2015 15:03:07 +0000 Subject: SkypeWeb: AssocMgr support part 1. git-svn-id: http://svn.miranda-ng.org/main/trunk@12978 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/common.h | 3 +++ protocols/SkypeWeb/src/main.cpp | 15 +++++++++++-- protocols/SkypeWeb/src/skype_login.cpp | 2 -- protocols/SkypeWeb/src/skype_proto.h | 2 ++ protocols/SkypeWeb/src/skype_utils.cpp | 41 ++++++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 4 deletions(-) (limited to 'protocols') diff --git a/protocols/SkypeWeb/src/common.h b/protocols/SkypeWeb/src/common.h index 5ccd0640c7..85191fd8da 100644 --- a/protocols/SkypeWeb/src/common.h +++ b/protocols/SkypeWeb/src/common.h @@ -56,6 +56,7 @@ along with this program. If not, see . #include #include #include +#include struct CSkypeProto; @@ -99,6 +100,8 @@ enum SKYPE_LOGIN_ERROR #define SKYPE_SETTINGS_PASSWORD "Password" #define SKYPE_SETTINGS_GROUP "DefaultGroup" +#define SKYPE_PARSEURI "SKYPE/ParseUri" + #define SKYPE_DB_EVENT_TYPE_ACTION 10001 #endif //_COMMON_H_ \ No newline at end of file diff --git a/protocols/SkypeWeb/src/main.cpp b/protocols/SkypeWeb/src/main.cpp index 0891e11bc9..6aedb66382 100644 --- a/protocols/SkypeWeb/src/main.cpp +++ b/protocols/SkypeWeb/src/main.cpp @@ -56,6 +56,8 @@ extern "C" int __declspec(dllexport) Load(void) { mir_getTMI(&tmi); mir_getLP(&pluginInfo); + mir_getXI(&xi); + mir_getCLI(); PROTOCOLDESCRIPTOR pd = { sizeof(pd) }; pd.szName = MODULE; @@ -70,8 +72,6 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_SYSTEM_MODULESLOADED, &CSkypeProto::OnModulesLoaded); - mir_getXI(&xi); - mir_getCLI(); return 0; } @@ -82,4 +82,15 @@ extern "C" int __declspec(dllexport) Unload(void) CSkypeProto::UninitMenus(); return 0; +} + + +int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM) +{ + if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) + { + CreateServiceFunction(SKYPE_PARSEURI, ParseSkypeURI); + AssocMgr_AddNewUrlTypeT("skype:", TranslateT("Skype Link Protocol"), g_hInstance, IDI_SKYPE, SKYPE_PARSEURI, 0); + } + return 0; } \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp index 00a065cbd5..c1657f1cc6 100644 --- a/protocols/SkypeWeb/src/skype_login.cpp +++ b/protocols/SkypeWeb/src/skype_login.cpp @@ -17,8 +17,6 @@ along with this program. If not, see . #include "common.h" -int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM) { return 0; } - void CSkypeProto::OnLoginFirst(const NETLIBHTTPREQUEST *response) { if (response == NULL) diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 9fc42a035b..3e50d204a3 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -277,6 +277,8 @@ private: char *SelfUrlToName(const char *url); char *GetServerFromUrl(const char *url); + static INT_PTR __cdecl CSkypeProto::ParseSkypeURI(WPARAM, LPARAM lParam); + template static INT_PTR __cdecl GlobalService(WPARAM wParam, LPARAM lParam) { diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index ca2fb11989..165a48cdf0 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -515,4 +515,45 @@ char *CSkypeProto::ChatUrlToName(const char *url) char *CSkypeProto::GetServerFromUrl(const char *url) { return ParseUrl(url, "://"); +} + +INT_PTR __cdecl CSkypeProto::ParseSkypeURI(WPARAM w, LPARAM lParam) +{ + TCHAR *arg = (TCHAR *)lParam; + if (arg == NULL) + return 1; + + // skip leading prefix + TCHAR szUri[ 1024 ]; + _tcsncpy_s(szUri, arg, _TRUNCATE); + TCHAR *szJid = _tcschr(szUri, _T(':')); + if (szJid == NULL) + return 1; + + // skip // + for (++szJid; *szJid == _T('/'); ++szJid); + + // empty jid? + if (!*szJid) + return 1; + + // command code + TCHAR *szCommand = szJid; + szCommand = _tcschr(szCommand, _T('?')); + if (szCommand) + *(szCommand++) = 0; + + // parameters + TCHAR *szSecondParam = szCommand ? _tcschr(szCommand, _T(';')) : NULL; + if (szSecondParam) + *(szSecondParam++) = 0; + + // no command or message command + if (!szCommand || (szCommand && !_tcsicmp(szCommand, _T("chat")))) + { + //CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, NULL); + return 0; + } + + return 1; /* parse failed */ } \ No newline at end of file -- cgit v1.2.3