From 8a74e7495ce5ad39de4f5c25121a84d35df90c36 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 20 May 2018 15:08:48 +0300 Subject: CMPlugin to receive a reference to PLUGININFOEX --- .../ClientChangeNotify/src/ClientChangeNotify.cpp | 46 +++++++++++++--------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'plugins/ClientChangeNotify/src/ClientChangeNotify.cpp') 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(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); -- cgit v1.2.3