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/CrashDumper/src/crshdmp.cpp | 33 ++++++++++++++++++++----------- plugins/CrashDumper/src/crshdmp_icons.cpp | 2 +- plugins/CrashDumper/src/dumper.cpp | 10 +++------- plugins/CrashDumper/src/stdafx.h | 7 ++----- plugins/CrashDumper/src/ui.cpp | 32 +++++++++++++++--------------- plugins/CrashDumper/src/upload.cpp | 12 +++++------ 6 files changed, 49 insertions(+), 47 deletions(-) (limited to 'plugins/CrashDumper/src') diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index bddadf4f8c..693cdab46f 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -37,8 +37,9 @@ bool servicemode, clsdates, dtsubfldr, catchcrashes, needrestart = 0; extern HWND hViewWnd; -static const PLUGININFOEX pluginInfoEx = -{ +///////////////////////////////////////////////////////////////////////////////////////// + +PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), __PLUGIN_NAME, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), @@ -51,7 +52,9 @@ static const PLUGININFOEX pluginInfoEx = { 0xf62c1d7a, 0xffa4, 0x4065, { 0xa2, 0x51, 0x4c, 0x9d, 0xd9, 0x10, 0x1c, 0xc8 } } }; -const PLUGININFOEX* GetPluginInfoEx(void) { return &pluginInfoEx; } +CMPlugin::CMPlugin() : + PLUGIN(MODULENAME, pluginInfoEx) +{} extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirVersion) { @@ -59,9 +62,13 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirVers return (PLUGININFOEX*)&pluginInfoEx; } +///////////////////////////////////////////////////////////////////////////////////////// // MirandaInterfaces - returns the protocol interface to the core + extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SERVICEMODE, MIID_LAST }; +///////////////////////////////////////////////////////////////////////////////////////// + INT_PTR StoreVersionInfoToFile(WPARAM, LPARAM lParam) { CreateDirectoryTreeW(VersionInfoFolder); @@ -155,7 +162,7 @@ INT_PTR OpenUrl(WPARAM wParam, LPARAM) INT_PTR CopyLinkToClipboard(WPARAM, LPARAM) { - ptrW tmp(db_get_wsa(NULL, PluginName, "Username")); + ptrW tmp(db_get_wsa(NULL, MODULENAME, "Username")); if (tmp != NULL) { wchar_t buffer[MAX_PATH]; mir_snwprintf(buffer, L"https://vi.miranda-ng.org/detail/%s", tmp); @@ -202,7 +209,7 @@ int OptionsInit(WPARAM wParam, LPARAM) odp.position = -790000000; odp.hInstance = g_plugin.getInst(); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); - odp.szTitle.a = PluginName; + odp.szTitle.a = MODULENAME; odp.szGroup.a = LPGEN("Services"); odp.flags = ODPF_BOLDGROUPS; odp.pfnDlgProc = DlgProcOptions; @@ -247,8 +254,8 @@ static int ModulesLoaded(WPARAM, LPARAM) replaceStrW(profpath, L"%miranda_userdata%"); // Removed because it isn't available on Load() - // hCrashLogFolder = FoldersRegisterCustomPathT(PluginName, LPGEN("Crash Reports"), CrashLogFolder); - hVerInfoFolder = FoldersRegisterCustomPathT(PluginName, LPGEN("Version Information"), VersionInfoFolder); + // hCrashLogFolder = FoldersRegisterCustomPathT(MODULENAME, LPGEN("Crash Reports"), CrashLogFolder); + hVerInfoFolder = FoldersRegisterCustomPathT(MODULENAME, LPGEN("Version Information"), VersionInfoFolder); HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersPathChanged); FoldersPathChanged(0, 0); @@ -317,7 +324,7 @@ static int ModulesLoaded(WPARAM, LPARAM) Menu_ConfigureItem(Menu_AddMainMenuItem(&mi), MCI_OPT_EXECPARAM, 1); HOTKEYDESC hk = {}; - hk.szSection.a = PluginName; + hk.szSection.a = MODULENAME; hk.szDescription.a = LPGEN("Copy Version Info to clipboard"); hk.pszName = "CopyVerInfo"; @@ -338,7 +345,7 @@ static int ModulesLoaded(WPARAM, LPARAM) if (servicemode) ViewVersionInfo(0, 0); - else if (db_get_b(NULL, PluginName, "UploadChanged", 0) && !ProcessVIHash(false)) + else if (db_get_b(NULL, MODULENAME, "UploadChanged", 0) && !ProcessVIHash(false)) UploadVersionInfo(0, 0xa1); return 0; @@ -357,9 +364,9 @@ extern "C" int __declspec(dllexport) Load(void) if (hMsftedit == nullptr) return 1; - clsdates = db_get_b(NULL, PluginName, "ClassicDates", 1) != 0; - dtsubfldr = db_get_b(NULL, PluginName, "SubFolders", 1) != 0; - catchcrashes = db_get_b(NULL, PluginName, "CatchCrashes", 1) != 0; + clsdates = db_get_b(NULL, MODULENAME, "ClassicDates", 1) != 0; + dtsubfldr = db_get_b(NULL, MODULENAME, "SubFolders", 1) != 0; + catchcrashes = db_get_b(NULL, MODULENAME, "CatchCrashes", 1) != 0; mir_getLP(&pluginInfoEx); @@ -391,6 +398,8 @@ extern "C" int __declspec(dllexport) Load(void) return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" int __declspec(dllexport) Unload(void) { DestroyAllWindows(); diff --git a/plugins/CrashDumper/src/crshdmp_icons.cpp b/plugins/CrashDumper/src/crshdmp_icons.cpp index ae97c49528..e1dcd040ca 100644 --- a/plugins/CrashDumper/src/crshdmp_icons.cpp +++ b/plugins/CrashDumper/src/crshdmp_icons.cpp @@ -30,7 +30,7 @@ static IconItem iconList[] = void InitIcons(void) { - g_plugin.registerIcon(LPGEN("Crash Dumper"), iconList, PluginName); + g_plugin.registerIcon(LPGEN("Crash Dumper"), iconList, MODULENAME); } HICON LoadIconEx(int iconId, bool big) diff --git a/plugins/CrashDumper/src/dumper.cpp b/plugins/CrashDumper/src/dumper.cpp index 4e2123733a..41af5b4721 100644 --- a/plugins/CrashDumper/src/dumper.cpp +++ b/plugins/CrashDumper/src/dumper.cpp @@ -529,16 +529,12 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha frame.AddrFrame.Mode = AddrModeFlat; frame.AddrStack.Mode = AddrModeFlat; - const PLUGININFOEX *pluginInfoEx = GetPluginInfoEx(); - wchar_t curtime[30]; GetISO8061Time(nullptr, curtime, 30); CMStringW buffer; - buffer.AppendFormat(L"Miranda Crash Report from %s. Crash Dumper v.%d.%d.%d.%d\r\n", - curtime, - HIBYTE(HIWORD(pluginInfoEx->version)), LOBYTE(HIWORD(pluginInfoEx->version)), - HIBYTE(LOWORD(pluginInfoEx->version)), LOBYTE(LOWORD(pluginInfoEx->version))); + buffer.AppendFormat(L"Miranda Crash Report from %s. Crash Dumper v.%d.%d.%d.%d\r\n", + curtime, __MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM); int crashpos = buffer.GetLength(); @@ -635,6 +631,6 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha if (len > 8192) free(dst); - if (db_get_b(0, PluginName, "ShowCrashMessageBox", 1) && msg && IDYES == MessageBox(nullptr, msg, L"Miranda Crash Dumper", MB_YESNO | MB_ICONERROR | MB_TASKMODAL | MB_DEFBUTTON2 | MB_TOPMOST)) + if (db_get_b(0, MODULENAME, "ShowCrashMessageBox", 1) && msg && IDYES == MessageBox(nullptr, msg, L"Miranda Crash Dumper", MB_YESNO | MB_ICONERROR | MB_TASKMODAL | MB_DEFBUTTON2 | MB_TOPMOST)) StoreStringToClip(buffer); } diff --git a/plugins/CrashDumper/src/stdafx.h b/plugins/CrashDumper/src/stdafx.h index ac343409e7..5abffe7fb9 100644 --- a/plugins/CrashDumper/src/stdafx.h +++ b/plugins/CrashDumper/src/stdafx.h @@ -76,13 +76,11 @@ along with this program. If not, see . #define MS_CRASHDUMPER_URL "CrashDmp/StartUrl" #define MS_CRASHDUMPER_URLTOCLIP "CrashDmp/CopyToClip" -#define PluginName "Crash Dumper" +#define MODULENAME "Crash Dumper" struct CMPlugin : public PLUGIN { - CMPlugin() : - PLUGIN(PluginName) - {} + CMPlugin(); }; #define VI_FLAG_FORMAT 1 @@ -131,7 +129,6 @@ void ShowMessage(int type, const wchar_t* format, ...); bool IsPluginEnabled(wchar_t* filename); PLUGININFOEX* GetMirInfo(HMODULE hModule); -const PLUGININFOEX* GetPluginInfoEx(void); void CreateMiniDump(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr); void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wchar_t* msg); diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp index d270b7438b..c9b642af73 100644 --- a/plugins/CrashDumper/src/ui.cpp +++ b/plugins/CrashDumper/src/ui.cpp @@ -80,7 +80,7 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara if (lParam & VI_FLAG_PRNDLL) SetWindowText(hwndDlg, TranslateT("View Version Information (with DLLs)")); - Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, PluginName, "ViewInfo_"); + Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, MODULENAME, "ViewInfo_"); ShowWindow(hwndDlg, SW_SHOW); break; @@ -163,7 +163,7 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara case WM_DESTROY: hViewWnd = nullptr; Window_FreeIcon_IcoLib(hwndDlg); - Utils_SaveWindowPosition(hwndDlg, NULL, PluginName, "ViewInfo_"); + Utils_SaveWindowPosition(hwndDlg, NULL, MODULENAME, "ViewInfo_"); if (servicemode) PostQuitMessage(0); break; @@ -187,15 +187,15 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP TranslateDialogDefault(hwndDlg); { DBVARIANT dbv; - if (db_get_s(NULL, PluginName, "Username", &dbv) == 0) { + if (db_get_s(NULL, MODULENAME, "Username", &dbv) == 0) { SetDlgItemTextA(hwndDlg, IDC_USERNAME, dbv.pszVal); db_free(&dbv); } - if (db_get_s(NULL, PluginName, "Password", &dbv) == 0) { + if (db_get_s(NULL, MODULENAME, "Password", &dbv) == 0) { SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal); db_free(&dbv); } - CheckDlgButton(hwndDlg, IDC_UPLOADCHN, db_get_b(NULL, PluginName, "UploadChanged", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_UPLOADCHN, db_get_b(NULL, MODULENAME, "UploadChanged", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CLASSICDATES, clsdates ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_DATESUBFOLDER, dtsubfldr ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CATCHCRASHES, catchcrashes ? BST_CHECKED : BST_UNCHECKED); @@ -230,28 +230,28 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) { char szSetting[100]; GetDlgItemTextA(hwndDlg, IDC_USERNAME, szSetting, _countof(szSetting)); - db_set_s(NULL, PluginName, "Username", szSetting); + db_set_s(NULL, MODULENAME, "Username", szSetting); GetDlgItemTextA(hwndDlg, IDC_PASSWORD, szSetting, _countof(szSetting)); - db_set_s(NULL, PluginName, "Password", szSetting); + db_set_s(NULL, MODULENAME, "Password", szSetting); - db_set_b(NULL, PluginName, "UploadChanged", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UPLOADCHN)); + db_set_b(NULL, MODULENAME, "UploadChanged", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UPLOADCHN)); clsdates = IsDlgButtonChecked(hwndDlg, IDC_CLASSICDATES) == BST_CHECKED; if (clsdates) - db_set_b(NULL, PluginName, "ClassicDates", 1); + db_set_b(NULL, MODULENAME, "ClassicDates", 1); else - db_set_b(NULL, PluginName, "ClassicDates", 0); + db_set_b(NULL, MODULENAME, "ClassicDates", 0); dtsubfldr = IsDlgButtonChecked(hwndDlg, IDC_DATESUBFOLDER) == BST_CHECKED; if (dtsubfldr) - db_set_b(NULL, PluginName, "SubFolders", 1); + db_set_b(NULL, MODULENAME, "SubFolders", 1); else - db_set_b(NULL, PluginName, "SubFolders", 0); + db_set_b(NULL, MODULENAME, "SubFolders", 0); catchcrashes = IsDlgButtonChecked(hwndDlg, IDC_CATCHCRASHES) == BST_CHECKED; if (catchcrashes) - db_set_b(NULL, PluginName, "CatchCrashes", 1); + db_set_b(NULL, MODULENAME, "CatchCrashes", 1); else - db_set_b(NULL, PluginName, "CatchCrashes", 0); + db_set_b(NULL, MODULENAME, "CatchCrashes", 0); } break; } @@ -305,12 +305,12 @@ void ShowMessage(int type, const wchar_t* format, ...) va_end(va); if (ServiceExists(MS_POPUP_ADDPOPUPT)) { - mir_wstrcpy(pi.lptzContactName, _A2W(PluginName)); + mir_wstrcpy(pi.lptzContactName, _A2W(MODULENAME)); pi.lchIcon = LoadIconEx(IDI_VI); pi.PluginWindowProc = DlgProcPopup; pi.PluginData = (void*)type; PUAddPopupT(&pi); } - else MessageBox(nullptr, pi.lptzText, _A2W(PluginName), MB_OK | MB_ICONINFORMATION); + else MessageBox(nullptr, pi.lptzText, _A2W(MODULENAME), MB_OK | MB_ICONINFORMATION); } diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp index 338cbccfa2..adfe5b0aa0 100644 --- a/plugins/CrashDumper/src/upload.cpp +++ b/plugins/CrashDumper/src/upload.cpp @@ -39,14 +39,14 @@ void GetLoginStr(char* user, size_t szuser, char* pass) { DBVARIANT dbv; - if (db_get_s(NULL, PluginName, "Username", &dbv) == 0) { + if (db_get_s(NULL, MODULENAME, "Username", &dbv) == 0) { strncpy_s(user, szuser, dbv.pszVal, _TRUNCATE); db_free(&dbv); } else user[0] = 0; - if (db_get_s(NULL, PluginName, "Password", &dbv) == 0) { + if (db_get_s(NULL, MODULENAME, "Password", &dbv) == 0) { BYTE hash[16]; mir_md5_state_t context; @@ -129,7 +129,7 @@ bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq) // if the recieved code is 200 OK switch (nlhrReply->resultCode) { case 200: - if (db_get_b(NULL, PluginName, "UploadChanged", 0)) + if (db_get_b(NULL, MODULENAME, "UploadChanged", 0)) ProcessVIHash(true); ShowMessage(1, TranslateT("Version Info upload successful.")); @@ -216,7 +216,7 @@ void UploadInit(void) { NETLIBUSER nlu = {}; nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE; - nlu.szSettingsModule = (char*)PluginName; + nlu.szSettingsModule = (char*)MODULENAME; nlu.szDescriptiveName.w = TranslateT("Crash Dumper HTTP connections"); hNetlibUser = Netlib_RegisterUser(&nlu); } @@ -242,11 +242,11 @@ bool ProcessVIHash(bool store) arrayToHex(hash, sizeof(hash), hashstr); if (store) { - db_set_s(NULL, PluginName, "VIHash", hashstr); + db_set_s(NULL, MODULENAME, "VIHash", hashstr); return true; } - ptrA VIHash(db_get_sa(NULL, PluginName, "VIHash")); + ptrA VIHash(db_get_sa(NULL, MODULENAME, "VIHash")); if (VIHash == NULL) return false; -- cgit v1.2.3