diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-20 15:08:48 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-20 15:08:48 +0300 |
commit | 8a74e7495ce5ad39de4f5c25121a84d35df90c36 (patch) | |
tree | 03e5b4870f09a3163306740c2eebee47bc15b042 /plugins/ClientChangeNotify/src | |
parent | c5bf7d6123dd1c3b82ccb8fdb1b068077e9d56d4 (diff) |
CMPlugin to receive a reference to PLUGININFOEX
Diffstat (limited to 'plugins/ClientChangeNotify/src')
-rw-r--r-- | plugins/ClientChangeNotify/src/ClientChangeNotify.cpp | 46 | ||||
-rw-r--r-- | plugins/ClientChangeNotify/src/OptDlg.cpp | 4 | ||||
-rw-r--r-- | plugins/ClientChangeNotify/src/stdafx.h | 10 |
3 files changed, 33 insertions, 27 deletions
diff --git a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp index 5c11b907fb..a1b4f4ad20 100644 --- a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp +++ b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp @@ -28,7 +28,9 @@ int &hLangpack(g_plugin.m_hLang); COptPage *g_PreviewOptPage; // we need to show popup even for the NULL contact if g_PreviewOptPage is not NULL (used for popup preview)
BOOL bPopupExists = FALSE, bFingerprintExists = FALSE, bVariablesExists = FALSE;
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -41,11 +43,17 @@ PLUGININFOEX pluginInfo = { {0xb68a8906, 0x748b, 0x435d, {0x93, 0xe, 0x21, 0xcc, 0x6e, 0x8f, 0x3b, 0x3f}}
};
+CMPlugin::CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
+{}
+
extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD)
{
- return &pluginInfo;
+ return &pluginInfoEx;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static int CALLBACK MenuWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
@@ -58,12 +66,11 @@ static int CALLBACK MenuWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
-
static VOID NTAPI ShowContactMenu(ULONG_PTR wParam)
// wParam = hContact
{
POINT pt;
- HWND hMenuWnd = CreateWindowEx(WS_EX_TOOLWINDOW, L"static", _A2W(MOD_NAME) L"_MenuWindow", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, g_plugin.getInst(), nullptr);
+ HWND hMenuWnd = CreateWindowEx(WS_EX_TOOLWINDOW, L"static", _A2W(MODULENAME) L"_MenuWindow", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, g_plugin.getInst(), nullptr);
SetWindowLongPtr(hMenuWnd, GWLP_WNDPROC, (LONG_PTR)MenuWndProc);
HMENU hMenu = Menu_BuildContactMenu(wParam);
GetCursorPos(&pt);
@@ -74,7 +81,6 @@ static VOID NTAPI ShowContactMenu(ULONG_PTR wParam) DestroyWindow(hMenuWnd);
}
-
void Popup_DoAction(HWND hWnd, BYTE Action, PLUGIN_DATA*)
{
MCONTACT hContact = (MCONTACT)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0);
@@ -108,7 +114,6 @@ void Popup_DoAction(HWND hWnd, BYTE Action, PLUGIN_DATA*) }
}
-
static LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PLUGIN_DATA *pdata = (PLUGIN_DATA*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0);
@@ -137,7 +142,6 @@ static LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA return DefWindowProc(hWnd, message, wParam, lParam);
}
-
void ShowPopup(SHOWPOPUP_DATA *sd)
{
TCString PopupText;
@@ -195,8 +199,8 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) if (sd.MirVer.IsEmpty())
return 0;
}
- sd.OldMirVer = db_get_s(hContact, MOD_NAME, DB_OLDMIRVER, L"");
- db_set_ws(hContact, MOD_NAME, DB_OLDMIRVER, sd.MirVer); // we have to write it here, because we modify sd.OldMirVer and sd.MirVer to conform our settings later
+ sd.OldMirVer = db_get_s(hContact, MODULENAME, DB_OLDMIRVER, L"");
+ db_set_ws(hContact, MODULENAME, DB_OLDMIRVER, sd.MirVer); // we have to write it here, because we modify sd.OldMirVer and sd.MirVer to conform our settings later
if (sd.OldMirVer.IsEmpty()) // looks like it's the right way to do
return 0;
@@ -215,9 +219,9 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) if (hContact && db_get_b(hContactOrMeta, "CList", "Hidden", 0))
return 0;
- int PerContactSetting = hContact ? db_get_b(hContact, MOD_NAME, DB_CCN_NOTIFY, NOTIFY_USEGLOBAL) : NOTIFY_ALWAYS; // NOTIFY_ALWAYS for preview
+ int PerContactSetting = hContact ? db_get_b(hContact, MODULENAME, DB_CCN_NOTIFY, NOTIFY_USEGLOBAL) : NOTIFY_ALWAYS; // NOTIFY_ALWAYS for preview
if (PerContactSetting == NOTIFY_USEGLOBAL && hContactOrMeta != hContact) // subcontact setting has a priority over a metacontact setting
- PerContactSetting = db_get_b(hContactOrMeta, MOD_NAME, DB_CCN_NOTIFY, NOTIFY_USEGLOBAL);
+ PerContactSetting = db_get_b(hContactOrMeta, MODULENAME, DB_CCN_NOTIFY, NOTIFY_USEGLOBAL);
if (PerContactSetting && (PerContactSetting == NOTIFY_ALMOST_ALWAYS || PerContactSetting == NOTIFY_ALWAYS || !PopupOptPage.GetValue(IDC_POPUPOPTDLG_USESTATUSNOTIFYFLAG) || !(db_get_dw(hContactOrMeta, "Ignore", "Mask1", 0) & 0x8))) { // check if we need to notify at all
sd.hContact = hContact;
@@ -291,12 +295,14 @@ INT_PTR CALLBACK CCNErrorDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) case WM_DESTROY:
if (IsDlgButtonChecked(hwndDlg, IDC_DONTREMIND))
- db_set_b(NULL, MOD_NAME, DB_NO_FINGERPRINT_ERROR, 1);
+ db_set_b(NULL, MODULENAME, DB_NO_FINGERPRINT_ERROR, 1);
break;
}
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static int ModuleLoad(WPARAM, LPARAM)
{
bPopupExists = ServiceExists(MS_POPUP_ADDPOPUPT);
@@ -305,7 +311,7 @@ static int ModuleLoad(WPARAM, LPARAM) return 0;
}
-int MirandaLoaded(WPARAM, LPARAM)
+static int MirandaLoaded(WPARAM, LPARAM)
{
ModuleLoad(0, 0);
COptPage PopupOptPage(g_PopupOptPage);
@@ -336,7 +342,7 @@ int MirandaLoaded(WPARAM, LPARAM) }
// seems that Fingerprint is not installed
- if (!bFingerprintExists && !db_get_b(NULL, MOD_NAME, DB_NO_FINGERPRINT_ERROR, 0))
+ if (!bFingerprintExists && !db_get_b(NULL, MODULENAME, DB_NO_FINGERPRINT_ERROR, 0))
CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CCN_ERROR), nullptr, CCNErrorDlgProc);
return 0;
@@ -344,23 +350,25 @@ int MirandaLoaded(WPARAM, LPARAM) extern "C" int __declspec(dllexport) Load(void)
{
- mir_getLP(&pluginInfo);
+ mir_getLP(&pluginInfoEx);
HookEvent(ME_SYSTEM_MODULESLOADED, MirandaLoaded);
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &g_hMainThread, THREAD_SET_CONTEXT, false, 0);
InitOptions();
- if (db_get_b(NULL, MOD_NAME, DB_SETTINGSVER, 0) < 1) {
+ if (db_get_b(NULL, MODULENAME, DB_SETTINGSVER, 0) < 1) {
TCString Str;
- Str = db_get_s(NULL, MOD_NAME, DB_IGNORESUBSTRINGS, L"");
+ Str = db_get_s(NULL, MODULENAME, DB_IGNORESUBSTRINGS, L"");
if (Str.GetLen()) // fix incorrect regexp from v0.1.1.0
- db_set_ws(NULL, MOD_NAME, DB_IGNORESUBSTRINGS, Str.Replace(L"/Miranda[0-9A-F]{8}/", L"/[0-9A-F]{8}(\\W|$)/"));
+ db_set_ws(NULL, MODULENAME, DB_IGNORESUBSTRINGS, Str.Replace(L"/Miranda[0-9A-F]{8}/", L"/[0-9A-F]{8}(\\W|$)/"));
- db_set_b(NULL, MOD_NAME, DB_SETTINGSVER, 1);
+ db_set_b(NULL, MODULENAME, DB_SETTINGSVER, 1);
}
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload()
{
CloseHandle(g_hMainThread);
diff --git a/plugins/ClientChangeNotify/src/OptDlg.cpp b/plugins/ClientChangeNotify/src/OptDlg.cpp index 55ce10cbd2..57653c71aa 100644 --- a/plugins/ClientChangeNotify/src/OptDlg.cpp +++ b/plugins/ClientChangeNotify/src/OptDlg.cpp @@ -21,7 +21,7 @@ // ================================================ Popup options ================================================
-COptPage g_PopupOptPage(MOD_NAME, nullptr);
+COptPage g_PopupOptPage(MODULENAME, nullptr);
void EnablePopupOptDlgControls()
{
@@ -128,7 +128,7 @@ INT_PTR CALLBACK PopupOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara DBCONTACTWRITESETTING cws = {};
cws.szModule = "ICQ";
cws.szSetting = DB_MIRVER;
- db_set_s(NULL, MOD_NAME, DB_OLDMIRVER, "ICQ Lite v5");
+ db_set_s(NULL, MODULENAME, DB_OLDMIRVER, "ICQ Lite v5");
ContactSettingChanged(NULL, (LPARAM)&cws); // simulate a version change
delete g_PreviewOptPage;
g_PreviewOptPage = nullptr;
diff --git a/plugins/ClientChangeNotify/src/stdafx.h b/plugins/ClientChangeNotify/src/stdafx.h index 2b9c9168d1..497ee6ac1d 100644 --- a/plugins/ClientChangeNotify/src/stdafx.h +++ b/plugins/ClientChangeNotify/src/stdafx.h @@ -82,17 +82,15 @@ #define NOTIFYTIMER_INTERVAL 3500
-#define MOD_NAME "ClientChangeNotify"
+#define MODULENAME "ClientChangeNotify"
struct CMPlugin : public PLUGIN<CMPlugin>
{
- CMPlugin() :
- PLUGIN<CMPlugin>(MOD_NAME)
- {}
+ CMPlugin();
};
-#define LOG_ID MOD_NAME
-#define LOG_PREFIX MOD_NAME ": " // for netlib.log
+#define LOG_ID MODULENAME
+#define LOG_PREFIX MODULENAME ": " // for netlib.log
#define MS_NETLIB_LOG "Netlib/Log"
|