summaryrefslogtreecommitdiff
path: root/protocols/Tox/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r--protocols/Tox/src/stdafx.h2
-rw-r--r--protocols/Tox/src/tox_events.cpp6
-rw-r--r--protocols/Tox/src/tox_proto.h2
-rw-r--r--protocols/Tox/src/tox_utils.cpp36
4 files changed, 45 insertions, 1 deletions
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 <m_clist.h>
#include <m_clistint.h>
#include <m_gui.h>
-
#include <m_folders.h>
+#include <m_assocmgr.h>
#include <tox.h>
#include <toxav.h>
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<INT_PTR(__cdecl CToxProto::*Service)(WPARAM, LPARAM)>
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