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 --- plugins/AvatarHistory/src/AvatarDlg.cpp | 24 +++++++++--------- plugins/AvatarHistory/src/AvatarHistory.cpp | 38 +++++++++++++++++------------ plugins/AvatarHistory/src/options.cpp | 16 ++++++------ plugins/AvatarHistory/src/popup.cpp | 6 ++--- plugins/AvatarHistory/src/stdafx.h | 6 ++--- plugins/AvatarHistory/src/utils.cpp | 4 +-- 6 files changed, 49 insertions(+), 45 deletions(-) (limited to 'plugins/AvatarHistory/src') diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp index 262d0f60e3..1fee474f87 100644 --- a/plugins/AvatarHistory/src/AvatarDlg.cpp +++ b/plugins/AvatarHistory/src/AvatarDlg.cpp @@ -116,7 +116,7 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA AvatarDialogData *data = (struct AvatarDialogData*) lParam; SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)createDefaultOverlayedIcon(TRUE)); SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)createDefaultOverlayedIcon(FALSE)); - if (db_get_b(NULL, MODULE_NAME, "LogToHistory", AVH_DEF_LOGTOHISTORY)) + if (db_get_b(NULL, MODULENAME, "LogToHistory", AVH_DEF_LOGTOHISTORY)) FillAvatarListFromDB(hwndList, data->hContact); else if (opts.log_store_as_hash) FillAvatarListFromFolder(hwndList, data->hContact); @@ -132,11 +132,11 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data->hContact); UpdateAvatarPic(hwnd); - CheckDlgButton(hwnd, IDC_LOGUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "LogToDisk", BST_INDETERMINATE)); - CheckDlgButton(hwnd, IDC_POPUPUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "AvatarPopups", BST_INDETERMINATE)); - CheckDlgButton(hwnd, IDC_HISTORYUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "LogToHistory", BST_INDETERMINATE)); + CheckDlgButton(hwnd, IDC_LOGUSER, (UINT)db_get_b(data->hContact, MODULENAME, "LogToDisk", BST_INDETERMINATE)); + CheckDlgButton(hwnd, IDC_POPUPUSER, (UINT)db_get_b(data->hContact, MODULENAME, "AvatarPopups", BST_INDETERMINATE)); + CheckDlgButton(hwnd, IDC_HISTORYUSER, (UINT)db_get_b(data->hContact, MODULENAME, "LogToHistory", BST_INDETERMINATE)); ShowWindow(GetDlgItem(hwnd, IDC_OPENFOLDER), opts.log_per_contact_folders ? SW_SHOW : SW_HIDE); - Utils_RestoreWindowPositionNoSize(hwnd, NULL, MODULE_NAME, "AvatarHistoryDialog"); + Utils_RestoreWindowPositionNoSize(hwnd, NULL, MODULENAME, "AvatarHistoryDialog"); WindowList_Add(hAvatarWindowsList, hwnd, data->hContact); TranslateDialogDefault(hwnd); EnableDisableControls(hwnd); @@ -151,7 +151,7 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA return TRUE; case WM_DESTROY: - Utils_SaveWindowPosition(hwnd, NULL, MODULE_NAME, "AvatarHistoryDialog"); + Utils_SaveWindowPosition(hwnd, NULL, MODULENAME, "AvatarHistoryDialog"); WindowList_Remove(hAvatarWindowsList, hwnd); DestroyIcon((HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0)); DestroyIcon((HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0)); @@ -287,9 +287,9 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA case IDOK: if (HIWORD(wParam) == BN_CLICKED) { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); - db_set_b(hContact, MODULE_NAME, "AvatarPopups", (BYTE)IsDlgButtonChecked(hwnd, IDC_POPUPUSER)); - db_set_b(hContact, MODULE_NAME, "LogToDisk", (BYTE)IsDlgButtonChecked(hwnd, IDC_LOGUSER)); - db_set_b(hContact, MODULE_NAME, "LogToHistory", (BYTE)IsDlgButtonChecked(hwnd, IDC_HISTORYUSER)); + db_set_b(hContact, MODULENAME, "AvatarPopups", (BYTE)IsDlgButtonChecked(hwnd, IDC_POPUPUSER)); + db_set_b(hContact, MODULENAME, "LogToDisk", (BYTE)IsDlgButtonChecked(hwnd, IDC_LOGUSER)); + db_set_b(hContact, MODULENAME, "LogToHistory", (BYTE)IsDlgButtonChecked(hwnd, IDC_HISTORYUSER)); CleanupAvatarPic(hwnd); EndDialog(hwnd, 0); @@ -310,7 +310,7 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA wchar_t avfolder[MAX_PATH]; MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); GetContactFolder(avfolder, hContact); - ShellExecute(nullptr, db_get_b(NULL, MODULE_NAME, "OpenFolderMethod", 0) ? L"explore" : L"open", avfolder, nullptr, nullptr, SW_SHOWNORMAL); + ShellExecute(nullptr, db_get_b(NULL, MODULENAME, "OpenFolderMethod", 0) ? L"explore" : L"open", avfolder, nullptr, nullptr, SW_SHOWNORMAL); return TRUE; } break; @@ -541,7 +541,7 @@ int ShowSaveDialog(HWND hwnd, wchar_t* fn, MCONTACT hContact) ofn.lpstrDefExt = wcsrchr(fn, '.') + 1; DBVARIANT dbvInitDir = { 0 }; - if (!db_get_ws(hContact, MODULE_NAME, "SavedAvatarFolder", &dbvInitDir)) { + if (!db_get_ws(hContact, MODULENAME, "SavedAvatarFolder", &dbvInitDir)) { ofn.lpstrInitialDir = dbvInitDir.ptszVal; db_free(&dbvInitDir); } @@ -549,7 +549,7 @@ int ShowSaveDialog(HWND hwnd, wchar_t* fn, MCONTACT hContact) if (GetSaveFileName(&ofn)) { CopyFile(fn, file, FALSE); - db_set_ws(hContact, MODULE_NAME, "SavedAvatarFolder", file); + db_set_ws(hContact, MODULENAME, "SavedAvatarFolder", file); } return 0; } diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp index 6c2cd9ff99..6d743ff9e2 100644 --- a/plugins/AvatarHistory/src/AvatarHistory.cpp +++ b/plugins/AvatarHistory/src/AvatarHistory.cpp @@ -41,7 +41,9 @@ wchar_t* GetOldStyleAvatarName(wchar_t *fn, MCONTACT hContact); void InitMenuItem(); -PLUGININFOEX pluginInfo = { +///////////////////////////////////////////////////////////////////////////////////////// + +PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), __PLUGIN_NAME, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), @@ -54,9 +56,13 @@ PLUGININFOEX pluginInfo = { {0xdbe8c990, 0x7aa0, 0x458d, {0xba, 0xb7, 0x33, 0xeb, 0x7, 0x23, 0x8e, 0x71}} }; +CMPlugin::CMPlugin() : + PLUGIN(MODULENAME, pluginInfoEx) +{} + extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { - return &pluginInfo; + return &pluginInfoEx; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -105,7 +111,7 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam) return 0; DBVARIANT dbvOldHash = { 0 }; - bool ret = (db_get_ws(hContact, MODULE_NAME, "AvatarHash", &dbvOldHash) == 0); + bool ret = (db_get_ws(hContact, MODULENAME, "AvatarHash", &dbvOldHash) == 0); CONTACTAVATARCHANGEDNOTIFICATION* avatar = (CONTACTAVATARCHANGEDNOTIFICATION*)lParam; if (avatar == nullptr) { @@ -119,7 +125,7 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam) Skin_PlaySound("avatar_removed"); // Is a flash avatar or avs could not load it - db_set_ws(hContact, MODULE_NAME, "AvatarHash", L"-"); + db_set_ws(hContact, MODULENAME, "AvatarHash", L"-"); if (ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_removed) ShowPopup(hContact, nullptr, opts.popup_removed); @@ -280,12 +286,12 @@ static INT_PTR CALLBACK FirstRunDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA extern "C" __declspec(dllexport) int Load(void) { - mir_getLP(&pluginInfo); + mir_getLP(&pluginInfoEx); CoInitialize(nullptr); // Is first run? - if (db_get_b(NULL, MODULE_NAME, "FirstRun", 1)) { + if (db_get_b(NULL, MODULENAME, "FirstRun", 1)) { // Show dialog int ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FIRST_RUN), nullptr, FirstRunDlgProc, 0); if (ret == 0) @@ -293,29 +299,29 @@ extern "C" __declspec(dllexport) int Load(void) // Write settings - db_set_b(NULL, MODULE_NAME, "LogToDisk", 1); + db_set_b(NULL, MODULENAME, "LogToDisk", 1); if (ret == IDC_MIR_SAME) - db_set_b(NULL, MODULE_NAME, "LogKeepSameFolder", 1); + db_set_b(NULL, MODULENAME, "LogKeepSameFolder", 1); else - db_set_b(NULL, MODULE_NAME, "LogKeepSameFolder", 0); + db_set_b(NULL, MODULENAME, "LogKeepSameFolder", 0); if (ret == IDC_MIR_SHORT || ret == IDC_SHORT || ret == IDC_DUP) - db_set_b(NULL, MODULE_NAME, "LogPerContactFolders", 1); + db_set_b(NULL, MODULENAME, "LogPerContactFolders", 1); else - db_set_b(NULL, MODULE_NAME, "LogPerContactFolders", 0); + db_set_b(NULL, MODULENAME, "LogPerContactFolders", 0); if (ret == IDC_DUP) - db_set_b(NULL, MODULE_NAME, "StoreAsHash", 0); + db_set_b(NULL, MODULENAME, "StoreAsHash", 0); else - db_set_b(NULL, MODULE_NAME, "StoreAsHash", 1); + db_set_b(NULL, MODULENAME, "StoreAsHash", 1); if (ret == IDC_MIR_SAME || ret == IDC_MIR_PROTO || ret == IDC_MIR_SHORT) - db_set_b(NULL, MODULE_NAME, "LogToHistory", 1); + db_set_b(NULL, MODULENAME, "LogToHistory", 1); else - db_set_b(NULL, MODULE_NAME, "LogToHistory", 0); + db_set_b(NULL, MODULENAME, "LogToHistory", 0); - db_set_b(NULL, MODULE_NAME, "FirstRun", 0); + db_set_b(NULL, MODULENAME, "FirstRun", 0); } LoadOptions(); diff --git a/plugins/AvatarHistory/src/options.cpp b/plugins/AvatarHistory/src/options.cpp index b0272797b6..79caebdbf1 100644 --- a/plugins/AvatarHistory/src/options.cpp +++ b/plugins/AvatarHistory/src/options.cpp @@ -50,7 +50,7 @@ static OptPageControl popupsControls[] = { static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - return SaveOptsDlgProc(optionsControls, _countof(optionsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam); + return SaveOptsDlgProc(optionsControls, _countof(optionsControls), MODULENAME, hwndDlg, msg, wParam, lParam); } // Popup options dialog procedure ///////////////////////////////////////////////////////////////// @@ -100,7 +100,7 @@ static INT_PTR CALLBACK PopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Show contact history")); // Needs to be called here in this case - SaveOptsDlgProc(popupsControls, _countof(popupsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam); + SaveOptsDlgProc(popupsControls, _countof(popupsControls), MODULENAME, hwndDlg, msg, wParam, lParam); PopupsEnableDisableCtrls(hwndDlg); return TRUE; @@ -139,7 +139,7 @@ static INT_PTR CALLBACK PopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA } } - return SaveOptsDlgProc(popupsControls, _countof(popupsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam); + return SaveOptsDlgProc(popupsControls, _countof(popupsControls), MODULENAME, hwndDlg, msg, wParam, lParam); } // Functions ////////////////////////////////////////////////////////////////////////////////////// @@ -168,10 +168,10 @@ int OptInit(WPARAM wParam, LPARAM) void LoadOptions() { - LoadOpts(optionsControls, _countof(optionsControls), MODULE_NAME); - LoadOpts(popupsControls, _countof(popupsControls), MODULE_NAME); + LoadOpts(optionsControls, _countof(optionsControls), MODULENAME); + LoadOpts(popupsControls, _countof(popupsControls), MODULENAME); - opts.log_per_contact_folders = db_get_b(NULL, MODULE_NAME, "LogPerContactFolders", 0); - opts.log_keep_same_folder = db_get_b(NULL, MODULE_NAME, "LogKeepSameFolder", 0); - opts.log_store_as_hash = db_get_b(NULL, MODULE_NAME, "StoreAsHash", 1); + opts.log_per_contact_folders = db_get_b(NULL, MODULENAME, "LogPerContactFolders", 0); + opts.log_keep_same_folder = db_get_b(NULL, MODULENAME, "LogKeepSameFolder", 0); + opts.log_store_as_hash = db_get_b(NULL, MODULENAME, "StoreAsHash", 1); } diff --git a/plugins/AvatarHistory/src/popup.cpp b/plugins/AvatarHistory/src/popup.cpp index 16e52cb53b..ead52b114d 100644 --- a/plugins/AvatarHistory/src/popup.cpp +++ b/plugins/AvatarHistory/src/popup.cpp @@ -41,7 +41,7 @@ static LRESULT CALLBACK DumbPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, void InitPopups() { // window needed for popup commands - hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW, L"static", _A2W(MODULE_NAME) L"_PopupWindow", + hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW, L"static", _A2W(MODULENAME) L"_PopupWindow", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, g_plugin.getInst(), nullptr); SetWindowLongPtr(hPopupWindow, GWLP_WNDPROC, (LONG_PTR)PopupWndProc); @@ -56,7 +56,7 @@ void DeInitPopups() // Show an error popup void ShowErrPopup(const wchar_t *description, const wchar_t *title) { - ShowPopupEx(NULL, title == nullptr ? _A2W(MODULE_NAME) L" Error" : title, description, + ShowPopupEx(NULL, title == nullptr ? _A2W(MODULENAME) L" Error" : title, description, nullptr, POPUP_TYPE_ERROR, nullptr); } @@ -74,7 +74,7 @@ void ShowPopup(MCONTACT hContact, const wchar_t *title, const wchar_t *descripti void ShowDebugPopup(MCONTACT hContact, const wchar_t *title, const wchar_t *description) { - if (db_get_b(NULL, MODULE_NAME, "Debug", 0)) { + if (db_get_b(NULL, MODULENAME, "Debug", 0)) { ShowPopup(hContact, title, description); } } diff --git a/plugins/AvatarHistory/src/stdafx.h b/plugins/AvatarHistory/src/stdafx.h index d865398e6e..cdf31741b7 100644 --- a/plugins/AvatarHistory/src/stdafx.h +++ b/plugins/AvatarHistory/src/stdafx.h @@ -40,13 +40,11 @@ extern Options opts; extern HANDLE hFolder; extern wchar_t basedir[]; -#define MODULE_NAME "AvatarHistory" +#define MODULENAME "AvatarHistory" struct CMPlugin : public PLUGIN { - CMPlugin() : - PLUGIN(MODULE_NAME) - {} + CMPlugin(); }; #define AVH_DEF_POPUPFG 0 diff --git a/plugins/AvatarHistory/src/utils.cpp b/plugins/AvatarHistory/src/utils.cpp index f390b3463f..9b70f7f762 100644 --- a/plugins/AvatarHistory/src/utils.cpp +++ b/plugins/AvatarHistory/src/utils.cpp @@ -38,8 +38,8 @@ bool ContactEnabled(MCONTACT hContact, char *setting, int def) if (!ProtocolEnabled(proto)) return false; - BYTE globpref = db_get_b(NULL, MODULE_NAME, setting, def); - BYTE userpref = db_get_b(hContact, MODULE_NAME, setting, BST_INDETERMINATE); + BYTE globpref = db_get_b(NULL, MODULENAME, setting, def); + BYTE userpref = db_get_b(hContact, MODULENAME, setting, BST_INDETERMINATE); return (globpref && userpref == BST_INDETERMINATE) || userpref == BST_CHECKED; } -- cgit v1.2.3