summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-28 12:30:50 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-28 12:30:50 +0300
commit9ee90b86b0be67b64b650bfd349a13829a48efb5 (patch)
treec4b10adb83e3d5a8e28d5a462939d63c20a6e991
parent798128b9ab4c6de67321af80f1d338ed206e7064 (diff)
PLUGIN<> to receive the basic class located inside mir_app
-rw-r--r--include/m_plugin.h121
-rw-r--r--libs/win32/mir_app.libbin132008 -> 141746 bytes
-rw-r--r--libs/win64/mir_app.libbin127542 -> 137694 bytes
-rw-r--r--plugins/MirLua/src/mlua.h2
-rwxr-xr-xprotocols/JabberG/src/stdafx.h1
-rw-r--r--src/mir_app/src/CMPluginBase.cpp67
-rw-r--r--src/mir_app/src/mir_app.def34
-rw-r--r--src/mir_app/src/mir_app64.def34
-rw-r--r--src/mir_app/src/stdafx.h1
9 files changed, 193 insertions, 67 deletions
diff --git a/include/m_plugin.h b/include/m_plugin.h
index 1ac420b5ab..5588f7c865 100644
--- a/include/m_plugin.h
+++ b/include/m_plugin.h
@@ -3,176 +3,165 @@
#include <m_core.h>
#include <m_database.h>
-/////////////////////////////////////////////////////////////////////////////////////////
-// Basic class for plugins (not protocols) written in C++
-
-template<class T> class PLUGIN
+class MIR_APP_EXPORT CMPlugin
{
+ void tryOpenLog();
+
protected:
- const char *m_moduleName;
+ const char *m_szModuleName;
HANDLE m_hLogger = nullptr;
- PLUGIN(const char *moduleName)
- : m_moduleName(moduleName)
- {
- wchar_t path[MAX_PATH];
- mir_snwprintf(path, L"%s\\%s.txt", VARSW(L"%miranda_logpath%"), moduleName);
- m_hLogger = mir_createLog(moduleName, nullptr, path, 0);
- }
+ CMPlugin(const char *moduleName);
+ ~CMPlugin();
- ~PLUGIN()
- {
- if (m_hLogger) {
- mir_closeLog(m_hLogger);
- m_hLogger = nullptr;
- }
- }
-
- __inline void debugLogA(LPCSTR szFormat, ...)
- {
- va_list args;
- va_start(args, szFormat);
- mir_writeLogVA(m_hLogger, szFormat, args);
- va_end(args);
- }
-
- __inline void debugLogW(LPCWSTR wszFormat, ...)
- {
- va_list args;
- va_start(args, wszFormat);
- mir_writeLogVW(m_hLogger, wszFormat, args);
- va_end(args);
- }
+public:
+ void debugLogA(LPCSTR szFormat, ...);
+ void debugLogW(LPCWSTR wszFormat, ...);
__forceinline INT_PTR delSetting(const char *name)
{
- return db_unset(0, m_moduleName, name);
+ return db_unset(0, m_szModuleName, name);
}
__forceinline INT_PTR delSetting(MCONTACT hContact, const char *name)
{
- return db_unset(hContact, m_moduleName, name);
+ return db_unset(hContact, m_szModuleName, name);
}
__forceinline bool getBool(const char *name, bool defaultValue = false)
{
- return db_get_b(0, m_moduleName, name, defaultValue) != 0;
+ return db_get_b(0, m_szModuleName, name, defaultValue) != 0;
}
__forceinline bool getBool(MCONTACT hContact, const char *name, bool defaultValue = false)
{
- return db_get_b(hContact, m_moduleName, name, defaultValue) != 0;
+ return db_get_b(hContact, m_szModuleName, name, defaultValue) != 0;
}
__forceinline int getByte(const char *name, BYTE defaultValue = 0)
{
- return db_get_b(0, m_moduleName, name, defaultValue);
+ return db_get_b(0, m_szModuleName, name, defaultValue);
}
__forceinline int getByte(MCONTACT hContact, const char *name, BYTE defaultValue = 0)
{
- return db_get_b(hContact, m_moduleName, name, defaultValue);
+ return db_get_b(hContact, m_szModuleName, name, defaultValue);
}
__forceinline int getWord(const char *name, WORD defaultValue = 0)
{
- return db_get_w(0, m_moduleName, name, defaultValue);
+ return db_get_w(0, m_szModuleName, name, defaultValue);
}
__forceinline int getWord(MCONTACT hContact, const char *name, WORD defaultValue = 0)
{
- return db_get_w(hContact, m_moduleName, name, defaultValue);
+ return db_get_w(hContact, m_szModuleName, name, defaultValue);
}
__forceinline DWORD getDword(const char *name, DWORD defaultValue = 0)
{
- return db_get_dw(0, m_moduleName, name, defaultValue);
+ return db_get_dw(0, m_szModuleName, name, defaultValue);
}
__forceinline DWORD getDword(MCONTACT hContact, const char *name, DWORD defaultValue = 0)
{
- return db_get_dw(hContact, m_moduleName, name, defaultValue);
+ return db_get_dw(hContact, m_szModuleName, name, defaultValue);
}
__forceinline INT_PTR getString(const char *name, DBVARIANT *result)
{
- return db_get_s(0, m_moduleName, name, result);
+ return db_get_s(0, m_szModuleName, name, result);
}
__forceinline INT_PTR getString(MCONTACT hContact, const char *name, DBVARIANT *result)
{
- return db_get_s(hContact, m_moduleName, name, result);
+ return db_get_s(hContact, m_szModuleName, name, result);
}
__forceinline INT_PTR getWString(const char *name, DBVARIANT *result)
{
- return db_get_ws(0, m_moduleName, name, result);
+ return db_get_ws(0, m_szModuleName, name, result);
}
__forceinline INT_PTR getWString(MCONTACT hContact, const char *name, DBVARIANT *result)
{
- return db_get_ws(hContact, m_moduleName, name, result);
+ return db_get_ws(hContact, m_szModuleName, name, result);
}
__forceinline char* getStringA(const char *name)
{
- return db_get_sa(0, m_moduleName, name);
+ return db_get_sa(0, m_szModuleName, name);
}
__forceinline char* getStringA(MCONTACT hContact, const char *name)
{
- return db_get_sa(hContact, m_moduleName, name);
+ return db_get_sa(hContact, m_szModuleName, name);
}
__forceinline wchar_t* getWStringA(const char *name)
{
- return db_get_wsa(0, m_moduleName, name);
+ return db_get_wsa(0, m_szModuleName, name);
}
__forceinline wchar_t* getWStringA(MCONTACT hContact, const char *name)
{
- return db_get_wsa(hContact, m_moduleName, name);
+ return db_get_wsa(hContact, m_szModuleName, name);
}
__forceinline void setByte(const char *name, BYTE value)
{
- db_set_b(0, m_moduleName, name, value);
+ db_set_b(0, m_szModuleName, name, value);
}
__forceinline void setByte(MCONTACT hContact, const char *name, BYTE value)
{
- db_set_b(hContact, m_moduleName, name, value);
+ db_set_b(hContact, m_szModuleName, name, value);
}
__forceinline void setWord(const char *name, WORD value)
{
- db_set_w(0, m_moduleName, name, value);
+ db_set_w(0, m_szModuleName, name, value);
}
__forceinline void setWord(MCONTACT hContact, const char *name, WORD value)
{
- db_set_w(hContact, m_moduleName, name, value);
+ db_set_w(hContact, m_szModuleName, name, value);
}
__forceinline void setDword(const char *name, DWORD value)
{
- db_set_dw(0, m_moduleName, name, value);
+ db_set_dw(0, m_szModuleName, name, value);
}
__forceinline void setDword(MCONTACT hContact, const char *name, DWORD value)
{
- db_set_dw(hContact, m_moduleName, name, value);
+ db_set_dw(hContact, m_szModuleName, name, value);
}
__forceinline void setString(const char *name, const char* value)
{
- db_set_s(0, m_moduleName, name, value);
+ db_set_s(0, m_szModuleName, name, value);
}
__forceinline void setString(MCONTACT hContact, const char *name, const char* value)
{
- db_set_s(hContact, m_moduleName, name, value);
+ db_set_s(hContact, m_szModuleName, name, value);
}
__forceinline void setWString(const char *name, const wchar_t* value)
{
- db_set_ws(0, m_moduleName, name, value);
+ db_set_ws(0, m_szModuleName, name, value);
}
__forceinline void setWString(MCONTACT hContact, const char *name, const wchar_t* value)
{
- db_set_ws(hContact, m_moduleName, name, value);
+ db_set_ws(hContact, m_szModuleName, name, value);
}
+};
+
+extern CMPlugin g_plugin;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Basic class for plugins (not protocols) written in C++
+
+template<class T> class PLUGIN : public CMPlugin
+{
+ typedef CMPlugin CSuper;
+
+protected:
+ PLUGIN(const char *moduleName)
+ : CSuper(moduleName)
+ {}
__forceinline HANDLE CreatePluginEvent(const char *name)
{
- CMStringA str(FORMAT, "%s\\%s", m_moduleName, name);
+ CMStringA str(FORMAT, "%s\\%s", m_szModuleName, name);
return CreateHookableEvent(str);
}
@@ -185,14 +174,14 @@ protected:
typedef INT_PTR(__cdecl T::*MyServiceFunc)(WPARAM, LPARAM);
__forceinline void CreatePluginService(const char *name, MyServiceFunc pFunc)
{
- CMStringA str(FORMAT, "%s\\%s", m_moduleName, name);
+ CMStringA str(FORMAT, "%s\\%s", m_szModuleName, name);
CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&pFunc, this);
}
typedef INT_PTR(__cdecl T::*MyServiceFuncParam)(WPARAM, LPARAM, LPARAM);
__forceinline void CreatePluginServiceParam(const char *name, MyServiceFuncParam pFunc, LPARAM param)
{
- CMStringA str(FORMAT, "%s\\%s", m_moduleName, name);
+ CMStringA str(FORMAT, "%s\\%s", m_szModuleName, name);
CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&pFunc, this, param);
}
};
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index e64350bca5..24fa479955 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 83ae0fbf5c..8b301eaec8 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/MirLua/src/mlua.h b/plugins/MirLua/src/mlua.h
index 6f5bdca432..d3f9cc3acd 100644
--- a/plugins/MirLua/src/mlua.h
+++ b/plugins/MirLua/src/mlua.h
@@ -1,7 +1,7 @@
#ifndef _LUA_CORE_H_
#define _LUA_CORE_H_
-class CMLua : private PLUGIN<CMLua>
+class CMLua : public PLUGIN<CMLua>
{
friend class CMLuaOptions;
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h
index 41e02d9b85..6edf05c6aa 100755
--- a/protocols/JabberG/src/stdafx.h
+++ b/protocols/JabberG/src/stdafx.h
@@ -87,6 +87,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <win2k.h>
#include <m_imgsrvc.h>
#include <m_clc.h>
+#include <m_plugin.h>
#include <m_folders.h>
#include <m_fingerprint.h>
diff --git a/src/mir_app/src/CMPluginBase.cpp b/src/mir_app/src/CMPluginBase.cpp
new file mode 100644
index 0000000000..a6dad00e44
--- /dev/null
+++ b/src/mir_app/src/CMPluginBase.cpp
@@ -0,0 +1,67 @@
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright (c) 2012-18 Miranda NG team (https://miranda-ng.org),
+Copyright (c) 2000-12 Miranda IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+CMPlugin::CMPlugin(const char *moduleName) :
+ m_szModuleName(moduleName)
+{
+}
+
+CMPlugin::~CMPlugin()
+{
+ if (m_hLogger) {
+ mir_closeLog(m_hLogger);
+ m_hLogger = nullptr;
+ }
+}
+
+void CMPlugin::tryOpenLog()
+{
+ wchar_t path[MAX_PATH];
+ mir_snwprintf(path, L"%s\\%s.txt", VARSW(L"%miranda_logpath%"), m_szModuleName);
+ m_hLogger = mir_createLog(m_szModuleName, nullptr, path, 0);
+}
+
+void CMPlugin::debugLogA(LPCSTR szFormat, ...)
+{
+ if (m_hLogger == nullptr)
+ tryOpenLog();
+
+ va_list args;
+ va_start(args, szFormat);
+ mir_writeLogVA(m_hLogger, szFormat, args);
+ va_end(args);
+}
+
+void CMPlugin::debugLogW(LPCWSTR wszFormat, ...)
+{
+ if (m_hLogger == nullptr)
+ tryOpenLog();
+
+ va_list args;
+ va_start(args, wszFormat);
+ mir_writeLogVW(m_hLogger, wszFormat, args);
+ va_end(args);
+}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 38942137a0..da203dd583 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -492,3 +492,37 @@ GetDatabasePlugin @508
SetServiceModePlugin @510
Proto_CreateAccount @511
Proto_ActivateAccount @512
+??0CMPlugin@@IAE@PBD@Z @513 NONAME
+??1CMPlugin@@IAE@XZ @514 NONAME
+??4CMPlugin@@QAEAAV0@ABV0@@Z @515 NONAME
+?debugLogA@CMPlugin@@QAAXPBDZZ @516 NONAME
+?debugLogW@CMPlugin@@QAAXPB_WZZ @517 NONAME
+?delSetting@CMPlugin@@QAEHIPBD@Z @518 NONAME
+?delSetting@CMPlugin@@QAEHPBD@Z @519 NONAME
+?getBool@CMPlugin@@QAE_NIPBD_N@Z @520 NONAME
+?getBool@CMPlugin@@QAE_NPBD_N@Z @521 NONAME
+?getByte@CMPlugin@@QAEHIPBDE@Z @522 NONAME
+?getByte@CMPlugin@@QAEHPBDE@Z @523 NONAME
+?getDword@CMPlugin@@QAEKIPBDK@Z @524 NONAME
+?getDword@CMPlugin@@QAEKPBDK@Z @525 NONAME
+?getString@CMPlugin@@QAEHIPBDPAUDBVARIANT@@@Z @526 NONAME
+?getString@CMPlugin@@QAEHPBDPAUDBVARIANT@@@Z @527 NONAME
+?getStringA@CMPlugin@@QAEPADIPBD@Z @528 NONAME
+?getStringA@CMPlugin@@QAEPADPBD@Z @529 NONAME
+?getWString@CMPlugin@@QAEHIPBDPAUDBVARIANT@@@Z @530 NONAME
+?getWString@CMPlugin@@QAEHPBDPAUDBVARIANT@@@Z @531 NONAME
+?getWStringA@CMPlugin@@QAEPA_WIPBD@Z @532 NONAME
+?getWStringA@CMPlugin@@QAEPA_WPBD@Z @533 NONAME
+?getWord@CMPlugin@@QAEHIPBDG@Z @534 NONAME
+?getWord@CMPlugin@@QAEHPBDG@Z @535 NONAME
+?setByte@CMPlugin@@QAEXIPBDE@Z @536 NONAME
+?setByte@CMPlugin@@QAEXPBDE@Z @537 NONAME
+?setDword@CMPlugin@@QAEXIPBDK@Z @538 NONAME
+?setDword@CMPlugin@@QAEXPBDK@Z @539 NONAME
+?setString@CMPlugin@@QAEXIPBD0@Z @540 NONAME
+?setString@CMPlugin@@QAEXPBD0@Z @541 NONAME
+?setWString@CMPlugin@@QAEXIPBDPB_W@Z @542 NONAME
+?setWString@CMPlugin@@QAEXPBDPB_W@Z @543 NONAME
+?setWord@CMPlugin@@QAEXIPBDG@Z @544 NONAME
+?setWord@CMPlugin@@QAEXPBDG@Z @545 NONAME
+?tryOpenLog@CMPlugin@@AAEXXZ @546 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index da18a51b62..012dd53097 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -492,3 +492,37 @@ GetDatabasePlugin @508
SetServiceModePlugin @510
Proto_CreateAccount @511
Proto_ActivateAccount @512
+??0CMPlugin@@IEAA@PEBD@Z @513 NONAME
+??1CMPlugin@@IEAA@XZ @514 NONAME
+??4CMPlugin@@QEAAAEAV0@AEBV0@@Z @515 NONAME
+?debugLogA@CMPlugin@@QEAAXPEBDZZ @516 NONAME
+?debugLogW@CMPlugin@@QEAAXPEB_WZZ @517 NONAME
+?delSetting@CMPlugin@@QEAA_JIPEBD@Z @518 NONAME
+?delSetting@CMPlugin@@QEAA_JPEBD@Z @519 NONAME
+?getBool@CMPlugin@@QEAA_NIPEBD_N@Z @520 NONAME
+?getBool@CMPlugin@@QEAA_NPEBD_N@Z @521 NONAME
+?getByte@CMPlugin@@QEAAHIPEBDE@Z @522 NONAME
+?getByte@CMPlugin@@QEAAHPEBDE@Z @523 NONAME
+?getDword@CMPlugin@@QEAAKIPEBDK@Z @524 NONAME
+?getDword@CMPlugin@@QEAAKPEBDK@Z @525 NONAME
+?getString@CMPlugin@@QEAA_JIPEBDPEAUDBVARIANT@@@Z @526 NONAME
+?getString@CMPlugin@@QEAA_JPEBDPEAUDBVARIANT@@@Z @527 NONAME
+?getStringA@CMPlugin@@QEAAPEADIPEBD@Z @528 NONAME
+?getStringA@CMPlugin@@QEAAPEADPEBD@Z @529 NONAME
+?getWString@CMPlugin@@QEAA_JIPEBDPEAUDBVARIANT@@@Z @530 NONAME
+?getWString@CMPlugin@@QEAA_JPEBDPEAUDBVARIANT@@@Z @531 NONAME
+?getWStringA@CMPlugin@@QEAAPEA_WIPEBD@Z @532 NONAME
+?getWStringA@CMPlugin@@QEAAPEA_WPEBD@Z @533 NONAME
+?getWord@CMPlugin@@QEAAHIPEBDG@Z @534 NONAME
+?getWord@CMPlugin@@QEAAHPEBDG@Z @535 NONAME
+?setByte@CMPlugin@@QEAAXIPEBDE@Z @536 NONAME
+?setByte@CMPlugin@@QEAAXPEBDE@Z @537 NONAME
+?setDword@CMPlugin@@QEAAXIPEBDK@Z @538 NONAME
+?setDword@CMPlugin@@QEAAXPEBDK@Z @539 NONAME
+?setString@CMPlugin@@QEAAXIPEBD0@Z @540 NONAME
+?setString@CMPlugin@@QEAAXPEBD0@Z @541 NONAME
+?setWString@CMPlugin@@QEAAXIPEBDPEB_W@Z @542 NONAME
+?setWString@CMPlugin@@QEAAXPEBDPEB_W@Z @543 NONAME
+?setWord@CMPlugin@@QEAAXIPEBDG@Z @544 NONAME
+?setWord@CMPlugin@@QEAAXPEBDG@Z @545 NONAME
+?tryOpenLog@CMPlugin@@AEAAXXZ @546 NONAME
diff --git a/src/mir_app/src/stdafx.h b/src/mir_app/src/stdafx.h
index d68b11ed91..7f8ff36975 100644
--- a/src/mir_app/src/stdafx.h
+++ b/src/mir_app/src/stdafx.h
@@ -92,6 +92,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_gui.h>
#include <m_srmm_int.h>
#include <m_imgsrvc.h>
+#include <m_plugin.h>
#include "miranda.h"