diff options
author | George Hazan <ghazan@miranda.im> | 2019-09-04 19:21:26 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-09-04 19:21:26 +0300 |
commit | e80684d7a2ad3afff40ec1c211fba92bb457ea4f (patch) | |
tree | 4e405124f0b2c0e30bf935de375c3c00f4fa917e /plugins/CrashDumper | |
parent | b82860d36b5c9e09918fc7db671412b81457e8f6 (diff) |
CrashDumper:
- fixes #2043 (CrashDumper: add option to disable VI popup);
- massive cleaning of options-related code;
- version bump
Diffstat (limited to 'plugins/CrashDumper')
-rw-r--r-- | plugins/CrashDumper/res/crshdmp.rc | 59 | ||||
-rw-r--r-- | plugins/CrashDumper/src/crshdmp.cpp | 32 | ||||
-rw-r--r-- | plugins/CrashDumper/src/dumper.cpp | 6 | ||||
-rw-r--r-- | plugins/CrashDumper/src/exhndlr.cpp | 4 | ||||
-rw-r--r-- | plugins/CrashDumper/src/resource.h | 5 | ||||
-rw-r--r-- | plugins/CrashDumper/src/stdafx.h | 5 | ||||
-rw-r--r-- | plugins/CrashDumper/src/ui.cpp | 46 | ||||
-rw-r--r-- | plugins/CrashDumper/src/upload.cpp | 2 | ||||
-rw-r--r-- | plugins/CrashDumper/src/utils.cpp | 2 | ||||
-rw-r--r-- | plugins/CrashDumper/src/version.h | 2 |
10 files changed, 88 insertions, 75 deletions
diff --git a/plugins/CrashDumper/res/crshdmp.rc b/plugins/CrashDumper/res/crshdmp.rc index 310ccfa235..d38fcc97cd 100644 --- a/plugins/CrashDumper/res/crshdmp.rc +++ b/plugins/CrashDumper/res/crshdmp.rc @@ -8,19 +8,16 @@ // Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
-#include "richedit.h"
-
+#include "richedit.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
+// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
-#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
@@ -60,26 +57,28 @@ BEGIN PUSHBUTTON "Close",IDCANCEL,302,215,66,14
PUSHBUTTON "Copy To Clipboard",IDC_CLIPVER,142,215,95,14
PUSHBUTTON "To File",IDC_FILEVER,6,215,66,14
- CONTROL "",IDC_VIEWVERSIONINFO,"RichEdit50W",ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,7,7,361,203,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_VIEWVERSIONINFO,"RichEdit50W",WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP | 0x8c4,7,7,361,203,WS_EX_CLIENTEDGE
END
-IDD_OPTIONS DIALOGEX 0, 0, 209, 195
+IDD_OPTIONS DIALOGEX 0, 0, 267, 173
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Support for vi.miranda-ng.org",IDC_STATIC,7,7,195,94
+ GROUPBOX "Support for vi.miranda-ng.org",IDC_STATIC,7,7,253,62
LTEXT "Username",IDC_STATIC,14,20,107,8
- EDITTEXT IDC_USERNAME,14,33,108,14,ES_AUTOHSCROLL
- LTEXT "Password",IDC_STATIC,14,52,107,8
- EDITTEXT IDC_PASSWORD,14,65,107,14,ES_PASSWORD | ES_AUTOHSCROLL
- CONTROL "Upload automatically when changed",IDC_UPLOADCHN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,84,161,10
- GROUPBOX "Crash reports",IDC_STATIC,7,104,195,54
- CONTROL "Generate crash reports",IDC_CATCHCRASHES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,113,169,10
+ EDITTEXT IDC_USERNAME,152,18,108,14,ES_AUTOHSCROLL
+ LTEXT "Password",IDC_STATIC,14,39,107,8
+ EDITTEXT IDC_PASSWORD,153,35,107,14,ES_PASSWORD | ES_AUTOHSCROLL
+ CONTROL "Upload automatically when changed",IDC_UPLOADCHN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,54,245,10
+ GROUPBOX "Crash reports",IDC_STATIC,7,70,253,52
+ CONTROL "Generate crash reports",IDC_CATCHCRASHES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,83,237,10
CONTROL "Create reports in subfolders naming as current date",IDC_DATESUBFOLDER,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,127,180,10
- CONTROL "Use classic dates",IDC_CLASSICDATES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,141,157,10
- LTEXT "* You need to restart Miranda NG to apply changes",IDC_RESTARTNOTE,9,160,186,22,NOT WS_VISIBLE
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,95,237,10
+ CONTROL "Use classic dates",IDC_CLASSICDATES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,107,237,10
+ LTEXT "* You need to restart Miranda NG to apply changes",IDC_RESTARTNOTE,7,145,251,22,NOT WS_VISIBLE
+ CONTROL "Display popups about successful actions",IDC_SUCCESSPOPUPS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,129,253,10
END
@@ -102,9 +101,9 @@ BEGIN IDD_OPTIONS, DIALOG
BEGIN
LEFTMARGIN, 7
- RIGHTMARGIN, 202
+ RIGHTMARGIN, 260
TOPMARGIN, 7
- BOTTOMMARGIN, 189
+ BOTTOMMARGIN, 167
END
END
#endif // APSTUDIO_INVOKED
@@ -135,12 +134,29 @@ END // Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_VI ICON "Vi.ico"
+
IDI_VISHOW ICON "Vi show.ico"
+
IDI_VITOCLIP ICON "Vi to clipboard.ico"
+
IDI_VITOFILE ICON "Vi to file.ico"
+
IDI_VIUPLOAD ICON "Vi upload.ico"
+
IDI_LINKTOCLIP ICON "Vi link to clipboard.ico"
-#endif // English (U.S.) resources
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_OPTIONS AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
+#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
@@ -150,8 +166,7 @@ IDI_LINKTOCLIP ICON "Vi link to clipboard.ico" //
// Generated from the TEXTINCLUDE 3 resource.
//
-
-
+
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index ebad56ebaf..e5372288a5 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -30,8 +30,6 @@ wchar_t* profpath; wchar_t CrashLogFolder[MAX_PATH], VersionInfoFolder[MAX_PATH];
-bool servicemode, clsdates, dtsubfldr, catchcrashes, needrestart = 0;
-
CDlgBase *pViewDialog = nullptr;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -50,8 +48,14 @@ PLUGININFOEX pluginInfoEx = { };
CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
-{}
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
+ bCatchCrashes(MODULENAME, "CatchCrashes", 1),
+ bClassicDates(MODULENAME, "ClassicDates", 1),
+ bUseSubFolder(MODULENAME, "SubFolders", 1),
+ bSuccessPopups(MODULENAME, "SuccessPopups", 1),
+ bUploadChanged(MODULENAME, "UploadChanged", 0)
+{
+}
/////////////////////////////////////////////////////////////////////////////////////////
// MirandaInterfaces - returns the protocol interface to the core
@@ -160,7 +164,7 @@ INT_PTR CopyLinkToClipboard(WPARAM, LPARAM) INT_PTR ServiceModeLaunch(WPARAM, LPARAM)
{
- servicemode = true;
+ g_plugin.bServiceMode = true;
ViewVersionInfo(1, 0);
return SERVICE_ONLYDB;
}
@@ -261,7 +265,7 @@ static int ModulesLoaded(WPARAM, LPARAM) mi.pszService = MS_CRASHDUMPER_URLTOCLIP;
Menu_AddMainMenuItem(&mi);
- if (catchcrashes && !needrestart) {
+ if (g_plugin.bCatchCrashes && !g_plugin.bNeedRestart) {
SET_UID(mi, 0xecae52f2, 0xd601, 0x4f85, 0x87, 0x9, 0xec, 0x8e, 0x84, 0xfe, 0x1b, 0x3c);
mi.position = 2000099990;
mi.name.a = LPGEN("Open crash report directory");
@@ -292,14 +296,14 @@ static int ModulesLoaded(WPARAM, LPARAM) UploadInit();
- if (catchcrashes && !needrestart)
+ if (g_plugin.bCatchCrashes && !g_plugin.bNeedRestart)
SetExceptionHandler();
HookEvent(ME_TTB_MODULELOADED, ToolbarModulesLoaded);
- if (servicemode)
+ if (g_plugin.bServiceMode)
ViewVersionInfo(0, 0);
- else if (g_plugin.getByte("UploadChanged", 0) && !ProcessVIHash(false))
+ else if (g_plugin.bUploadChanged && !ProcessVIHash(false))
UploadVersionInfo(0, 0xa1);
return 0;
@@ -317,13 +321,9 @@ int CMPlugin::Load() if (hMsftedit == nullptr)
return 1;
- clsdates = g_plugin.getByte("ClassicDates", 1) != 0;
- dtsubfldr = g_plugin.getByte("SubFolders", 1) != 0;
- catchcrashes = g_plugin.getByte("CatchCrashes", 1) != 0;
-
profname = Utils_ReplaceVarsW(L"%miranda_profilename%.dat");
profpath = Utils_ReplaceVarsW(L"%miranda_userdata%");
- if (catchcrashes && !needrestart)
+ if (g_plugin.bCatchCrashes && !g_plugin.bNeedRestart)
mir_snwprintf(CrashLogFolder, L"%s\\CrashLog", profpath);
wcsncpy_s(VersionInfoFolder, profpath, _TRUNCATE);
@@ -335,7 +335,7 @@ int CMPlugin::Load() InitIcons();
- if (catchcrashes && !needrestart)
+ if (g_plugin.bCatchCrashes && !g_plugin.bNeedRestart)
InitExceptionHandler();
CreateServiceFunction(MS_CRASHDUMPER_STORETOFILE, StoreVersionInfoToFile);
@@ -353,7 +353,7 @@ int CMPlugin::Load() int CMPlugin::Unload()
{
- if ((catchcrashes && !needrestart) || (!catchcrashes && needrestart))
+ if ((g_plugin.bCatchCrashes && !g_plugin.bNeedRestart) || (!g_plugin.bCatchCrashes && g_plugin.bNeedRestart))
DestroyExceptionHandler();
mir_free(profpath);
diff --git a/plugins/CrashDumper/src/dumper.cpp b/plugins/CrashDumper/src/dumper.cpp index 8e89470c5b..99f4c801cb 100644 --- a/plugins/CrashDumper/src/dumper.cpp +++ b/plugins/CrashDumper/src/dumper.cpp @@ -140,7 +140,7 @@ static int CompareDlls(const wchar_t *p1, const wchar_t *p2) static void GetPluginsString(CMStringW &buffer, unsigned &flags)
{
- buffer.AppendFormat(L"Service Mode: %s\r\n", servicemode ? L"Yes" : L"No");
+ buffer.AppendFormat(L"Service Mode: %s\r\n", g_plugin.bServiceMode ? L"Yes" : L"No");
wchar_t path[MAX_PATH];
GetModuleFileName(nullptr, path, MAX_PATH);
@@ -163,7 +163,7 @@ static void GetPluginsString(CMStringW &buffer, unsigned &flags) bool loaded = false;
mir_snwprintf(fname, MAX_PATH - (fname - path), L"\\plugins\\%s", FindFileData.cFileName);
HMODULE hModule = GetModuleHandle(path);
- if (hModule == nullptr && servicemode) {
+ if (hModule == nullptr && g_plugin.bServiceMode) {
hModule = LoadLibrary(path);
loaded = true;
}
@@ -449,7 +449,7 @@ void PrintVersionInfo(CMStringW& buffer, unsigned flags) GetWeatherStrings(buffer, flags);
}
- if (flags & VI_FLAG_PRNVAR && !servicemode) {
+ if (flags & VI_FLAG_PRNVAR && !g_plugin.bServiceMode) {
buffer.AppendFormat(L"\r\n%sProtocols and Accounts:%s\r\n-------------------------------------------------------------------------------\r\n",
(flags & VI_FLAG_FORMAT) ? L"[b]" : L"",
(flags & VI_FLAG_FORMAT) ? L"[/b]" : L"");
diff --git a/plugins/CrashDumper/src/exhndlr.cpp b/plugins/CrashDumper/src/exhndlr.cpp index 32b4b224d1..652adcbf9f 100644 --- a/plugins/CrashDumper/src/exhndlr.cpp +++ b/plugins/CrashDumper/src/exhndlr.cpp @@ -54,7 +54,7 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) CreateDirectoryTreeW(CrashLogFolder);
__try {
- if (dtsubfldr) {
+ if (g_plugin.bUseSubFolder) {
mir_snwprintf(path, L"%s\\%02d.%02d.%02d", CrashLogFolder, st.wYear, st.wMonth, st.wDay);
CreateDirectory(path, nullptr);
mir_snwprintf(path, L"%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.mdmp", CrashLogFolder,
@@ -80,7 +80,7 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) DeleteFile(path);
__try {
- if (dtsubfldr) {
+ if (g_plugin.bUseSubFolder) {
mir_snwprintf(path, L"%s\\%02d.%02d.%02d", CrashLogFolder, st.wYear, st.wMonth, st.wDay);
CreateDirectory(path, nullptr);
mir_snwprintf(path, L"%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.txt", CrashLogFolder,
diff --git a/plugins/CrashDumper/src/resource.h b/plugins/CrashDumper/src/resource.h index 8172d99a51..8a09ec32d6 100644 --- a/plugins/CrashDumper/src/resource.h +++ b/plugins/CrashDumper/src/resource.h @@ -21,6 +21,7 @@ #define IDC_DATESUBFOLDER 1010
#define IDC_CATCHCRASHES 1011
#define IDC_RESTARTNOTE 1012
+#define IDC_SUCCESSPOPUPS 1013
#define IDM_COPY 40002
#define IDM_COPYALL 40003
#define IDM_SELECTALL 40004
@@ -29,9 +30,9 @@ //
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 110
+#define _APS_NEXT_RESOURCE_VALUE 111
#define _APS_NEXT_COMMAND_VALUE 40005
-#define _APS_NEXT_CONTROL_VALUE 1013
+#define _APS_NEXT_CONTROL_VALUE 1014
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/plugins/CrashDumper/src/stdafx.h b/plugins/CrashDumper/src/stdafx.h index 588c8ce737..6270d4c932 100644 --- a/plugins/CrashDumper/src/stdafx.h +++ b/plugins/CrashDumper/src/stdafx.h @@ -80,6 +80,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. struct CMPlugin : public PLUGIN<CMPlugin>
{
+ CMOption<BYTE> bCatchCrashes, bClassicDates, bUploadChanged, bUseSubFolder, bSuccessPopups;
+
+ bool bNeedRestart = false, bServiceMode = false;
+
CMPlugin();
int Load() override;
@@ -98,7 +102,6 @@ struct VerTrnsfr };
extern LCID packlcid;
-extern bool servicemode, clsdates, dtsubfldr, catchcrashes, needrestart;
extern wchar_t CrashLogFolder[MAX_PATH];
extern wchar_t VersionInfoFolder[MAX_PATH];
diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp index cde5a7bf2f..52141270fe 100644 --- a/plugins/CrashDumper/src/ui.cpp +++ b/plugins/CrashDumper/src/ui.cpp @@ -73,7 +73,7 @@ public: Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "ViewInfo_");
if (pViewDialog == this)
pViewDialog = nullptr;
- if (servicemode)
+ if (g_plugin.bServiceMode)
PostQuitMessage(0);
return true;
}
@@ -171,14 +171,14 @@ INT_PTR ViewVersionInfo(WPARAM wParam, LPARAM) class COptDialog : public CDlgBase
{
CCtrlEdit m_edtUserName, m_edtPass;
- CCtrlCheck m_chkAutoUpload, m_chkClassicDates, m_chkRepSubfolder, m_chkCatchCrashes;
+ CCtrlCheck m_chkAutoUpload, m_chkClassicDates, m_chkRepSubfolder, m_chkCatchCrashes, m_chkSuccessPopups;
CCtrlLabel m_lblRestart;
void COptDialog::OnCatchCrashesChange(CCtrlCheck*)
{
m_chkRepSubfolder.Enable(m_chkCatchCrashes.GetState());
m_lblRestart.Show();
- needrestart = 1;
+ g_plugin.bNeedRestart = true;
}
public:
@@ -190,15 +190,21 @@ public: m_chkClassicDates(this, IDC_CLASSICDATES),
m_chkRepSubfolder(this, IDC_DATESUBFOLDER),
m_chkCatchCrashes(this, IDC_CATCHCRASHES),
+ m_chkSuccessPopups(this, IDC_SUCCESSPOPUPS),
m_lblRestart(this, IDC_RESTARTNOTE)
{
- CreateLink(m_chkAutoUpload, "UploadChanged", DBVT_BYTE, 0);
+ CreateLink(m_chkAutoUpload, g_plugin.bUploadChanged);
+ CreateLink(m_chkClassicDates, g_plugin.bClassicDates);
+ CreateLink(m_chkRepSubfolder, g_plugin.bUseSubFolder);
+ CreateLink(m_chkSuccessPopups, g_plugin.bSuccessPopups);
+
m_chkCatchCrashes.OnChange = Callback(this, &COptDialog::OnCatchCrashesChange);
}
bool COptDialog::OnInitDialog()
{
CDlgBase::OnInitDialog();
+
DBVARIANT dbv;
if (g_plugin.getString("Username", &dbv) == 0) {
m_edtUserName.SetTextA(dbv.pszVal);
@@ -208,12 +214,10 @@ public: m_edtPass.SetTextA(dbv.pszVal);
db_free(&dbv);
}
- m_chkClassicDates.SetState(clsdates);
- m_chkRepSubfolder.SetState(dtsubfldr);
- m_chkCatchCrashes.SetState(catchcrashes);
- if (!catchcrashes)
+
+ if (!g_plugin.bCatchCrashes)
m_chkRepSubfolder.Disable();
- if (needrestart)
+ if (g_plugin.bNeedRestart)
m_lblRestart.Show();
return true;
}
@@ -226,23 +230,6 @@ public: m_edtPass.GetTextA(szSetting, _countof(szSetting));
g_plugin.setString("Password", szSetting);
-
- clsdates = m_chkClassicDates.GetState();
- if (clsdates)
- g_plugin.setByte("ClassicDates", 1);
- else
- g_plugin.setByte("ClassicDates", 0);
- dtsubfldr = m_chkRepSubfolder.GetState();
- if (dtsubfldr)
- g_plugin.setByte("SubFolders", 1);
- else
- g_plugin.setByte("SubFolders", 0);
- catchcrashes = m_chkCatchCrashes.GetState();
- if (catchcrashes)
- g_plugin.setByte("CatchCrashes", 1);
- else
- g_plugin.setByte("CatchCrashes", 0);
-
return true;
}
};
@@ -298,6 +285,13 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) void ShowMessage(int type, const wchar_t *format, ...)
{
+ switch(type) {
+ case 1:
+ case 3:
+ if (!g_plugin.bSuccessPopups)
+ return;
+ }
+
POPUPDATAW ppd;
va_list va;
diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp index 1e212aa391..09cf4199e0 100644 --- a/plugins/CrashDumper/src/upload.cpp +++ b/plugins/CrashDumper/src/upload.cpp @@ -127,7 +127,7 @@ bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq) // if the recieved code is 200 OK
switch (nlhrReply->resultCode) {
case 200:
- if (g_plugin.getByte("UploadChanged", 0))
+ if (g_plugin.bUploadChanged)
ProcessVIHash(true);
ShowMessage(1, TranslateT("Version Info upload successful."));
diff --git a/plugins/CrashDumper/src/utils.cpp b/plugins/CrashDumper/src/utils.cpp index c2908ff458..8b59693f01 100644 --- a/plugins/CrashDumper/src/utils.cpp +++ b/plugins/CrashDumper/src/utils.cpp @@ -50,7 +50,7 @@ void GetISO8061Time(SYSTEMTIME *stLocal, LPTSTR lpszString, DWORD dwSize) GetLocalTime(stLocal);
}
- if (clsdates) {
+ if (g_plugin.bClassicDates) {
GetDateFormat(LOCALE_INVARIANT, 0, stLocal, L"d MMM yyyy", lpszString, dwSize);
int dlen = (int)mir_wstrlen(lpszString);
GetTimeFormat(LOCALE_INVARIANT, 0, stLocal, L" H:mm:ss", lpszString + dlen, dwSize - dlen);
diff --git a/plugins/CrashDumper/src/version.h b/plugins/CrashDumper/src/version.h index 323a32cc67..213bb305f1 100644 --- a/plugins/CrashDumper/src/version.h +++ b/plugins/CrashDumper/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>
|