diff options
author | aunsane <aunsane@gmail.com> | 2017-02-23 16:39:28 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-02-23 16:40:23 +0300 |
commit | 34e423793fe14fe60a1e463e724523bc1f471cd3 (patch) | |
tree | 43b19928c01cc652c46b9d7d9f34312552f9a1a9 /protocols | |
parent | bbb4ba8b737a4c3aaf165392f1d4919c0147b834 (diff) |
Tox:
- added compatibility check
- version bump
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Tox/src/api_main.cpp | 5 | ||||
-rw-r--r-- | protocols/Tox/src/main.cpp (renamed from protocols/Tox/src/tox.cpp) | 141 | ||||
-rw-r--r-- | protocols/Tox/src/stdafx.h | 5 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 5 | ||||
-rw-r--r-- | protocols/Tox/src/version.h | 2 |
5 files changed, 90 insertions, 68 deletions
diff --git a/protocols/Tox/src/api_main.cpp b/protocols/Tox/src/api_main.cpp index a63bc729b8..3d46576925 100644 --- a/protocols/Tox/src/api_main.cpp +++ b/protocols/Tox/src/api_main.cpp @@ -2,6 +2,11 @@ /* MAIN FUNCTIONS */
+bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch)
+{
+ return CreateFunction<bool(*)(uint32_t, uint32_t, uint32_t)>(__FUNCTION__)(major, minor, patch);
+}
+
struct Tox_Options *tox_options_new(TOX_ERR_OPTIONS_NEW *error)
{
return CreateFunction<struct Tox_Options*(*)(TOX_ERR_OPTIONS_NEW*)>(__FUNCTION__)(error);
diff --git a/protocols/Tox/src/tox.cpp b/protocols/Tox/src/main.cpp index 0ee2774aa4..d315f7605f 100644 --- a/protocols/Tox/src/tox.cpp +++ b/protocols/Tox/src/main.cpp @@ -1,67 +1,76 @@ -#include "stdafx.h"
-
-int hLangpack;
-CHAT_MANAGER *pci;
-CLIST_INTERFACE *pcli;
-HINSTANCE g_hInstance;
-HMODULE g_hToxLibrary = NULL;
-
-PLUGININFOEX pluginInfo =
-{
- sizeof(PLUGININFOEX),
- __PLUGIN_NAME,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
- __DESCRIPTION,
- __AUTHOR,
- __AUTHOREMAIL,
- __COPYRIGHT,
- __AUTHORWEB,
- UNICODE_AWARE,
- // {00272A3E-F5FA-4090-8B67-3E62AC1EE0B4}
- {0x272a3e, 0xf5fa, 0x4090, {0x8b, 0x67, 0x3e, 0x62, 0xac, 0x1e, 0xe0, 0xb4}}
-};
-
-DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
-{
- g_hInstance = hInstance;
-
- return TRUE;
-}
-
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfo;
-}
-
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
-
-extern "C" int __declspec(dllexport) Load(void)
-{
- g_hToxLibrary = LoadLibrary(L"libtox.dll");
- if (g_hToxLibrary == NULL)
- return 0;
-
- pci = Chat_GetInterface();
- pcli = Clist_GetInterface();
- mir_getLP(&pluginInfo);
-
- PROTOCOLDESCRIPTOR pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.szName = "TOX";
- pd.type = PROTOTYPE_PROTOCOL;
- pd.fnInit = (pfnInitProto)CToxProto::InitAccount;
- pd.fnUninit = (pfnUninitProto)CToxProto::UninitAccount;
- Proto_RegisterModule(&pd);
-
- HookEvent(ME_SYSTEM_MODULESLOADED, &CToxProto::OnModulesLoaded);
-
- return 0;
-}
-
-extern "C" int __declspec(dllexport) Unload(void)
-{
- if (g_hToxLibrary)
- FreeLibrary(g_hToxLibrary);
-
- return 0;
+#include "stdafx.h" + +int hLangpack; +CHAT_MANAGER *pci; +CLIST_INTERFACE *pcli; +HINSTANCE g_hInstance; +HMODULE g_hToxLibrary = NULL; + +PLUGININFOEX pluginInfo = +{ + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {00272A3E-F5FA-4090-8B67-3E62AC1EE0B4} + {0x272a3e, 0xf5fa, 0x4090, {0x8b, 0x67, 0x3e, 0x62, 0xac, 0x1e, 0xe0, 0xb4}} +}; + +DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID) +{ + g_hInstance = hInstance; + + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; + +extern "C" int __declspec(dllexport) Load(void) +{ + g_hToxLibrary = LoadLibrary(TOX_LIBRARY); + if (g_hToxLibrary == NULL) + return 1; + + if (!TOX_VERSION_IS_ABI_COMPATIBLE()) + { + wchar_t message[100]; + mir_snwprintf(message, TranslateT("Current version of plugin is support tox api version %i.%i.%i which is incompatible with %s"), TOX_VERSION_MAJOR, TOX_VERSION_MINOR, TOX_VERSION_PATCH, TOX_LIBRARY); + CToxProto::ShowNotification(message, MB_ICONERROR); + FreeLibrary(g_hToxLibrary); + return 2; + } + + pci = Chat_GetInterface(); + pcli = Clist_GetInterface(); + mir_getLP(&pluginInfo); + + PROTOCOLDESCRIPTOR pd = { 0 }; + pd.cbSize = sizeof(pd); + pd.szName = "TOX"; + pd.type = PROTOTYPE_PROTOCOL; + pd.fnInit = (pfnInitProto)CToxProto::InitAccount; + pd.fnUninit = (pfnUninitProto)CToxProto::UninitAccount; + Proto_RegisterModule(&pd); + + HookEvent(ME_SYSTEM_MODULESLOADED, &CToxProto::OnModulesLoaded); + + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + if (g_hToxLibrary) + FreeLibrary(g_hToxLibrary); + + return 0; }
\ No newline at end of file diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h index 6b2c083543..dee3d7f817 100644 --- a/protocols/Tox/src/stdafx.h +++ b/protocols/Tox/src/stdafx.h @@ -70,6 +70,10 @@ extern HINSTANCE g_hInstance; #define MODULE "Tox"
+#define TOX_API_VER_MAJOR 0
+#define TOX_API_VER_MINOR 1
+#define TOX_API_VER_PATCH 5
+
#define TOX_ERROR -1
#define TOX_MAX_CONNECT_RETRIES 300
@@ -103,6 +107,7 @@ enum TOX_DB_EVENT #define TOX_MAX_AVATAR_SIZE 1 << 16 // 2 ^ 16 bytes
+#define TOX_LIBRARY L"libtox.dll"
extern HMODULE g_hToxLibrary;
template<typename T>
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 65ab3c2c15..953452d01b 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -65,6 +65,9 @@ public: static int OnModulesLoaded(WPARAM, LPARAM);
+ // utils
+ static void ShowNotification(const wchar_t *message, int flags = 0, MCONTACT hContact = NULL);
+
private:
CToxThread *toxThread;
mir_cs profileLock;
@@ -287,7 +290,7 @@ private: static wchar_t* ToxErrorToString(TOX_ERR_NEW error);
static wchar_t* ToxErrorToString(TOX_ERR_FRIEND_SEND_MESSAGE error);
- static void ShowNotification(const wchar_t *message, int flags = 0, MCONTACT hContact = NULL);
+
static void ShowNotification(const wchar_t *caption, const wchar_t *message, int flags = 0, MCONTACT hContact = NULL);
static bool IsFileExists(const wchar_t* path);
diff --git a/protocols/Tox/src/version.h b/protocols/Tox/src/version.h index 95e8e40b34..3fd62a1c86 100644 --- a/protocols/Tox/src/version.h +++ b/protocols/Tox/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 1
-#define __BUILD_NUM 21
+#define __BUILD_NUM 22
#include <stdver.h>
|