From 6967fb68000cdf3431343ede41addcc5db2dfbae Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 31 May 2015 12:00:47 +0000 Subject: Tox: added support of assocmgr git-svn-id: http://svn.miranda-ng.org/main/trunk@13933 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/stdafx.h | 2 +- protocols/Tox/src/tox_events.cpp | 6 ++++++ protocols/Tox/src/tox_proto.h | 2 ++ protocols/Tox/src/tox_utils.cpp | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) (limited to 'protocols/Tox') diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h index c9470524b2..82ef5e31e3 100644 --- a/protocols/Tox/src/stdafx.h +++ b/protocols/Tox/src/stdafx.h @@ -37,8 +37,8 @@ #include #include #include - #include +#include #include #include diff --git a/protocols/Tox/src/tox_events.cpp b/protocols/Tox/src/tox_events.cpp index 67b6ecfbfc..e667bd8bd6 100644 --- a/protocols/Tox/src/tox_events.cpp +++ b/protocols/Tox/src/tox_events.cpp @@ -7,6 +7,12 @@ int CToxProto::OnModulesLoaded(WPARAM, LPARAM) hProfileFolderPath = FoldersRegisterCustomPathT("Tox", Translate("Profiles folder"), MIRANDA_USERDATAT); + if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) + { + CreateServiceFunction(MODULE "/ParseUri", CToxProto::ParseToxUri); + AssocMgr_AddNewUrlTypeT("tox:", TranslateT("Tox URI scheme"), g_hInstance, IDI_TOX, MODULE "/ParseUri", 0); + } + return 0; } diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 1d9d0ed5f7..4d1e08cf6b 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -279,6 +279,8 @@ private: MEVENT AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, PBYTE pBlob, size_t cbBlob); + static INT_PTR ParseToxUri(WPARAM, LPARAM lParam); + template static INT_PTR __cdecl GlobalService(WPARAM wParam, LPARAM lParam) { diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp index 2b22f02849..ed44c09630 100644 --- a/protocols/Tox/src/tox_utils.cpp +++ b/protocols/Tox/src/tox_utils.cpp @@ -75,4 +75,40 @@ MEVENT CToxProto::AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DW dbei.pBlob = pBlob; dbei.flags = flags; return db_event_add(hContact, &dbei); +} + +INT_PTR CToxProto::ParseToxUri(WPARAM, LPARAM lParam) +{ + TCHAR *uri = (TCHAR*)lParam; + if (mir_tstrlen(uri) <= 4) + return 1; + + if (Accounts.getCount() == 0) + return 1; + + CToxProto *proto = NULL; + for (size_t i = 0; i < Accounts.getCount(); i++) + { + if (Accounts[i]->IsOnline()) + { + proto = Accounts[i]; + break; + } + } + if (proto == NULL) + return 1; + + if (_tcschr(uri, _T('@')) != NULL) + return 1; + + PROTOSEARCHRESULT psr = { sizeof(psr) }; + psr.flags = PSR_TCHAR; + psr.id = mir_tstrdup(&uri[4]); + + ADDCONTACTSTRUCT acs = { HANDLE_SEARCHRESULT }; + acs.szProto = proto->m_szModuleName; + acs.psr = &psr; + + CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs); + return 0; } \ No newline at end of file -- cgit v1.2.3