summaryrefslogtreecommitdiff
path: root/plugins/CrashDumper/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CrashDumper/src')
-rw-r--r--plugins/CrashDumper/src/crshdmp.cpp60
-rw-r--r--plugins/CrashDumper/src/resource.h5
-rw-r--r--plugins/CrashDumper/src/stdafx.h7
-rw-r--r--plugins/CrashDumper/src/ui.cpp47
-rw-r--r--plugins/CrashDumper/src/upload.cpp247
-rw-r--r--plugins/CrashDumper/src/version.h4
6 files changed, 11 insertions, 359 deletions
diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp
index e5372288a5..d1cfab0dbc 100644
--- a/plugins/CrashDumper/src/crshdmp.cpp
+++ b/plugins/CrashDumper/src/crshdmp.cpp
@@ -52,8 +52,7 @@ CMPlugin::CMPlugin() :
bCatchCrashes(MODULENAME, "CatchCrashes", 1),
bClassicDates(MODULENAME, "ClassicDates", 1),
bUseSubFolder(MODULENAME, "SubFolders", 1),
- bSuccessPopups(MODULENAME, "SuccessPopups", 1),
- bUploadChanged(MODULENAME, "UploadChanged", 0)
+ bSuccessPopups(MODULENAME, "SuccessPopups", 1)
{
}
@@ -98,20 +97,6 @@ INT_PTR StoreVersionInfoToClipboard(WPARAM, LPARAM lParam)
return 0;
}
-INT_PTR UploadVersionInfo(WPARAM, LPARAM lParam)
-{
- CMStringW buffer;
- PrintVersionInfo(buffer);
-
- VerTrnsfr *trn = (VerTrnsfr*)mir_alloc(sizeof(VerTrnsfr));
- trn->buf = mir_utf8encodeW(buffer.c_str());
- trn->autot = lParam == 0xa1;
-
- mir_forkthread(VersionInfoUploadThread, trn);
-
- return 0;
-}
-
INT_PTR GetVersionInfo(WPARAM wParam, LPARAM lParam)
{
int result = 1; //failure
@@ -128,15 +113,7 @@ INT_PTR GetVersionInfo(WPARAM wParam, LPARAM lParam)
INT_PTR OpenUrl(WPARAM wParam, LPARAM)
{
- switch (wParam) {
- case 0:
- ShellExecute(nullptr, L"explore", CrashLogFolder, nullptr, nullptr, SW_SHOW);
- break;
-
- case 1:
- OpenAuthUrl("https://vi.miranda-ng.org/detail/%s");
- break;
- }
+ ShellExecute(nullptr, L"explore", CrashLogFolder, nullptr, nullptr, SW_SHOW);
return 0;
}
@@ -194,11 +171,6 @@ static int ToolbarModulesLoaded(WPARAM, LPARAM)
ttb.name = ttb.pszTooltipUp = LPGEN("Show Version Information");
ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_VISHOW);
g_plugin.addTTB(&ttb);
-
- ttb.pszService = MS_CRASHDUMPER_UPLOAD;
- ttb.name = ttb.pszTooltipUp = LPGEN("Upload Version Information");
- ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_VIUPLOAD);
- g_plugin.addTTB(&ttb);
return 0;
}
@@ -251,13 +223,6 @@ static int ModulesLoaded(WPARAM, LPARAM)
mi.pszService = MS_CRASHDUMPER_VIEWINFO;
Menu_ConfigureItem(Menu_AddMainMenuItem(&mi), MCI_OPT_EXECPARAM, 1);
- SET_UID(mi, 0xc6e3b558, 0xe1e8, 0x4cce, 0x96, 0x8, 0xc6, 0x89, 0x1b, 0x79, 0xf3, 0x7e);
- mi.position = 2000089999;
- mi.name.a = LPGEN("Upload");
- mi.hIcolibItem = g_plugin.getIconHandle(IDI_VIUPLOAD);
- mi.pszService = MS_CRASHDUMPER_UPLOAD;
- Menu_AddMainMenuItem(&mi);
-
SET_UID(mi, 0xa23da95a, 0x7624, 0x4343, 0x8c, 0xc0, 0xa6, 0x16, 0xbc, 0x30, 0x13, 0x8c);
mi.position = 2000089999;
mi.name.a = LPGEN("Copy link to clipboard");
@@ -274,13 +239,6 @@ static int ModulesLoaded(WPARAM, LPARAM)
Menu_AddMainMenuItem(&mi);
}
- SET_UID(mi, 0x6b19be3, 0xfb7d, 0x457d, 0x85, 0xde, 0xe0, 0x26, 0x4c, 0x87, 0x35, 0xf4);
- mi.position = 2000099991;
- mi.name.a = LPGEN("Open online Version Info");
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_EVENT_URL);
- mi.pszService = MS_CRASHDUMPER_URL;
- Menu_ConfigureItem(Menu_AddMainMenuItem(&mi), MCI_OPT_EXECPARAM, 1);
-
HOTKEYDESC hk = {};
hk.szSection.a = MODULENAME;
@@ -294,8 +252,6 @@ static int ModulesLoaded(WPARAM, LPARAM)
hk.pszService = MS_CRASHDUMPER_VIEWINFO;
g_plugin.addHotkey(&hk);
- UploadInit();
-
if (g_plugin.bCatchCrashes && !g_plugin.bNeedRestart)
SetExceptionHandler();
@@ -303,18 +259,10 @@ static int ModulesLoaded(WPARAM, LPARAM)
if (g_plugin.bServiceMode)
ViewVersionInfo(0, 0);
- else if (g_plugin.bUploadChanged && !ProcessVIHash(false))
- UploadVersionInfo(0, 0xa1);
return 0;
}
-static int PreShutdown(WPARAM, LPARAM)
-{
- UploadClose();
- return 0;
-}
-
int CMPlugin::Load()
{
hMsftedit = LoadLibrary(L"Msftedit.dll");
@@ -329,8 +277,7 @@ int CMPlugin::Load()
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
HookEvent(ME_OPT_INITIALISE, OptionsInit);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
-
+
packlcid = (LCID)Langpack_GetDefaultLocale();
InitIcons();
@@ -342,7 +289,6 @@ int CMPlugin::Load()
CreateServiceFunction(MS_CRASHDUMPER_STORETOCLIP, StoreVersionInfoToClipboard);
CreateServiceFunction(MS_CRASHDUMPER_VIEWINFO, ViewVersionInfo);
CreateServiceFunction(MS_CRASHDUMPER_GETINFO, GetVersionInfo);
- CreateServiceFunction(MS_CRASHDUMPER_UPLOAD, UploadVersionInfo);
CreateServiceFunction(MS_CRASHDUMPER_URL, OpenUrl);
CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceModeLaunch);
CreateServiceFunction(MS_CRASHDUMPER_URLTOCLIP, CopyLinkToClipboard);
diff --git a/plugins/CrashDumper/src/resource.h b/plugins/CrashDumper/src/resource.h
index 8a09ec32d6..234d7eca7f 100644
--- a/plugins/CrashDumper/src/resource.h
+++ b/plugins/CrashDumper/src/resource.h
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by crshdmp.rc
+// Used by W:\miranda-ng\plugins\CrashDumper\res\crshdmp.rc
//
#define IDD_VIEWVERSION 101
#define IDR_CONTEXT 102
@@ -14,9 +14,6 @@
#define IDC_VIEWVERSIONINFO 1001
#define IDC_FILEVER 1003
#define IDC_CLIPVER 1004
-#define IDC_USERNAME 1006
-#define IDC_PASSWORD 1007
-#define IDC_UPLOADCHN 1008
#define IDC_CLASSICDATES 1009
#define IDC_DATESUBFOLDER 1010
#define IDC_CATCHCRASHES 1011
diff --git a/plugins/CrashDumper/src/stdafx.h b/plugins/CrashDumper/src/stdafx.h
index 06a23e75d3..78db36af2a 100644
--- a/plugins/CrashDumper/src/stdafx.h
+++ b/plugins/CrashDumper/src/stdafx.h
@@ -72,7 +72,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MS_CRASHDUMPER_STORETOCLIP "CrashDmp/StoreVerInfoToClip"
#define MS_CRASHDUMPER_GETINFO "CrashDmp/GetInfo"
#define MS_CRASHDUMPER_VIEWINFO "CrashDmp/ViewInfo"
-#define MS_CRASHDUMPER_UPLOAD "CrashDmp/UploadInfo"
#define MS_CRASHDUMPER_URL "CrashDmp/StartUrl"
#define MS_CRASHDUMPER_URLTOCLIP "CrashDmp/CopyToClip"
@@ -80,7 +79,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct CMPlugin : public PLUGIN<CMPlugin>
{
- CMOption<uint8_t> bCatchCrashes, bClassicDates, bUploadChanged, bUseSubFolder, bSuccessPopups;
+ CMOption<uint8_t> bCatchCrashes, bClassicDates, bUseSubFolder, bSuccessPopups;
bool bNeedRestart = false, bServiceMode = false;
@@ -137,7 +136,6 @@ const PLUGININFOEX* GetMirInfo(HMODULE hModule);
void CreateMiniDump(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr);
void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wchar_t* msg);
void PrintVersionInfo(CMStringW& buffer, unsigned flags = VI_FLAG_PRNVAR);
-bool ProcessVIHash(bool store);
void InitExceptionHandler(void);
void DestroyExceptionHandler(void);
@@ -146,10 +144,7 @@ void RemoveExceptionHandler(void);
extern CDlgBase *pViewDialog;
-void UploadInit(void);
-void UploadClose(void);
void OpenAuthUrl(const char* url);
-void __cdecl VersionInfoUploadThread(void* arg);
void InitIcons(void);
diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp
index 3fa9ce6046..0959d9d8d6 100644
--- a/plugins/CrashDumper/src/ui.cpp
+++ b/plugins/CrashDumper/src/ui.cpp
@@ -162,8 +162,7 @@ INT_PTR ViewVersionInfo(WPARAM wParam, LPARAM)
class COptDialog : public CDlgBase
{
- CCtrlEdit m_edtUserName, m_edtPass;
- CCtrlCheck m_chkAutoUpload, m_chkClassicDates, m_chkRepSubfolder, m_chkCatchCrashes, m_chkSuccessPopups;
+ CCtrlCheck m_chkClassicDates, m_chkRepSubfolder, m_chkCatchCrashes, m_chkSuccessPopups;
CCtrlLabel m_lblRestart;
void COptDialog::OnCatchCrashesChange(CCtrlCheck*)
@@ -179,16 +178,12 @@ class COptDialog : public CDlgBase
public:
COptDialog() :
CDlgBase(g_plugin, IDD_OPTIONS),
- m_edtUserName(this, IDC_USERNAME),
- m_edtPass(this, IDC_PASSWORD),
- m_chkAutoUpload(this, IDC_UPLOADCHN),
m_chkCatchCrashes(this, IDC_CATCHCRASHES),
m_chkClassicDates(this, IDC_CLASSICDATES),
m_chkRepSubfolder(this, IDC_DATESUBFOLDER),
m_chkSuccessPopups(this, IDC_SUCCESSPOPUPS),
m_lblRestart(this, IDC_RESTARTNOTE)
{
- CreateLink(m_chkAutoUpload, g_plugin.bUploadChanged);
CreateLink(m_chkCatchCrashes, g_plugin.bCatchCrashes);
CreateLink(m_chkClassicDates, g_plugin.bClassicDates);
CreateLink(m_chkRepSubfolder, g_plugin.bUseSubFolder);
@@ -201,33 +196,12 @@ public:
{
CDlgBase::OnInitDialog();
- DBVARIANT dbv;
- if (g_plugin.getString("Username", &dbv) == 0) {
- m_edtUserName.SetTextA(dbv.pszVal);
- db_free(&dbv);
- }
- if (g_plugin.getString("Password", &dbv) == 0) {
- m_edtPass.SetTextA(dbv.pszVal);
- db_free(&dbv);
- }
-
if (!g_plugin.bCatchCrashes)
m_chkRepSubfolder.Disable();
if (g_plugin.bNeedRestart)
m_lblRestart.Show();
return true;
}
-
- bool COptDialog::OnApply()
- {
- char szSetting[100];
- m_edtUserName.GetTextA(szSetting, _countof(szSetting));
- g_plugin.setString("Username", szSetting);
-
- m_edtPass.GetTextA(szSetting, _countof(szSetting));
- g_plugin.setString("Password", szSetting);
- return true;
- }
};
int OptionsInit(WPARAM wParam, LPARAM)
@@ -252,22 +226,9 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
case WM_COMMAND:
- switch ((INT_PTR)PUGetPluginData(hWnd)) {
- case 0:
- OpenAuthUrl("https://vi.miranda-ng.org/detail/%s");
- break;
-
- case 1:
- OpenAuthUrl("https://vi.miranda-ng.org/global/%s");
- break;
-
- case 3:
- wchar_t path[MAX_PATH];
- mir_snwprintf(path, L"%s\\VersionInfo.txt", VersionInfoFolder);
- ShellExecute(nullptr, L"open", path, nullptr, nullptr, SW_SHOW);
- break;
-
- }
+ wchar_t path[MAX_PATH];
+ mir_snwprintf(path, L"%s\\VersionInfo.txt", VersionInfoFolder);
+ ShellExecute(nullptr, L"open", path, nullptr, nullptr, SW_SHOW);
PUDeletePopup(hWnd);
break;
diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp
deleted file mode 100644
index 075c448336..0000000000
--- a/plugins/CrashDumper/src/upload.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
-Miranda Crash Dumper Plugin
-Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation version 2
-of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "stdafx.h"
-
-HNETLIBUSER hNetlibUser;
-
-static void arrayToHex(uint8_t* data, size_t datasz, char* res)
-{
- char* resptr = res;
- for (unsigned i = 0; i < datasz; i++) {
- const uint8_t ch = data[i];
-
- const char ch0 = (char)(ch >> 4);
- *resptr++ = (char)((ch0 <= 9) ? ('0' + ch0) : (('a' - 10) + ch0));
-
- const char ch1 = (char)(ch & 0xF);
- *resptr++ = (char)((ch1 <= 9) ? ('0' + ch1) : (('a' - 10) + ch1));
- }
- *resptr = '\0';
-}
-
-void GetLoginStr(char* user, size_t szuser, char* pass)
-{
- DBVARIANT dbv;
-
- if (g_plugin.getString("Username", &dbv) == 0) {
- strncpy_s(user, szuser, dbv.pszVal, _TRUNCATE);
- db_free(&dbv);
- }
- else
- user[0] = 0;
-
- if (g_plugin.getString("Password", &dbv) == 0) {
- uint8_t hash[16];
- mir_md5_state_t context;
-
- mir_md5_init(&context);
- mir_md5_append(&context, (uint8_t*)dbv.pszVal, (int)mir_strlen(dbv.pszVal));
- mir_md5_finish(&context, hash);
-
- arrayToHex(hash, sizeof(hash), pass);
-
- db_free(&dbv);
- }
- else
- pass[0] = 0;
-}
-
-void OpenAuthUrl(const char* url)
-{
- char user[64], pass[40];
- GetLoginStr(user, sizeof(user), pass);
-
- if (user[0] && pass[0]) {
- char str[256];
- mir_snprintf(str, url, user); // XXX: fix me
- mir_snprintf(str, "https://vi.miranda-ng.org/detail/%s", user);
- Utils_OpenUrl(str);
- }
- else Utils_OpenUrl("https://vi.miranda-ng.org/");
-}
-
-void CreateAuthString(char* auth)
-{
- char user[64], pass[40];
- GetLoginStr(user, sizeof(user), pass);
-
- char str[110];
- int len = mir_snprintf(str, "%s:%s", user, pass);
- mir_snprintf(auth, 250, "Basic %s", ptrA(mir_base64_encode(str, len)));
-}
-
-
-bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq)
-{
- int result = 0xBADBAD;
- char* szRedirUrl = nullptr;
- NETLIBHTTPREQUEST nlhr = {};
-
- // initialize the netlib request
- nlhr.cbSize = sizeof(nlhr);
- nlhr.requestType = REQUEST_POST;
- nlhr.flags = NLHRF_HTTP11 | NLHRF_NODUMP;
- nlhr.szUrl = (char*)szUrl;
-
- nlhr.headersCount = 6;
- nlhr.headers = (NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
- nlhr.headers[0].szName = "Connection";
- nlhr.headers[0].szValue = "close";
- nlhr.headers[1].szName = "Cache-Control";
- nlhr.headers[1].szValue = "no-cache";
- nlhr.headers[2].szName = "Pragma";
- nlhr.headers[2].szValue = "no-cache";
- nlhr.headers[3].szName = "Content-Type";
- nlhr.headers[3].szValue = "text/plain; charset=utf-8";
- nlhr.headers[4].szName = "AutoUpload";
- nlhr.headers[4].szValue = (char*)(szReq->autot ? "1" : "0");
- nlhr.headers[5].szName = "Authorization";
-
- char auth[256];
- CreateAuthString(auth);
- nlhr.headers[5].szValue = auth;
-
- nlhr.pData = szReq->buf;
- nlhr.dataLength = (int)mir_strlen(szReq->buf);
-
- while (result == 0xBADBAD) {
- // download the page
- NLHR_PTR nlhrReply(Netlib_HttpTransaction(hNetlibUser, &nlhr));
- if (nlhrReply) {
- // if the recieved code is 200 OK
- switch (nlhrReply->resultCode) {
- case 200:
- if (g_plugin.bUploadChanged)
- ProcessVIHash(true);
-
- ShowMessage(1, TranslateT("Version Info upload successful."));
- result = 0;
- break;
-
- case 401:
- ShowMessage(0, TranslateT("Cannot upload Version Info. Incorrect username or password"));
- result = 1;
- break;
-
- case 510:
- ShowMessage(0, TranslateT("Cannot upload Version Info. User is banned"));
- result = 1;
- break;
-
- case 511:
- ShowMessage(0, TranslateT("Cannot upload Version Info. Daily upload limit exceeded"));
- result = 1;
- break;
-
- case 301:
- case 302:
- case 307:
- // get the url for the new location and save it to szInfo
- // look for the reply header "Location"
- if (auto *pszUrl = Netlib_GetHeader(nlhrReply, "Location")) {
- size_t rlen = 0;
- if (pszUrl[0] == '/') {
- const char* szPath;
- const char* szPref = strstr(szUrl, "://");
- szPref = szPref ? szPref + 3 : szUrl;
- szPath = strchr(szPref, '/');
- rlen = szPath != nullptr ? szPath - szUrl : mir_strlen(szUrl);
- }
-
- szRedirUrl = (char*)mir_realloc(szRedirUrl,
- rlen + mir_strlen(pszUrl) * 3 + 1);
-
- strncpy(szRedirUrl, szUrl, rlen);
- mir_strcpy(szRedirUrl + rlen, pszUrl);
-
- nlhr.szUrl = szRedirUrl;
- }
- break;
-
- default:
- result = 1;
- ShowMessage(0, TranslateT("Cannot upload Version Info. Unknown error"));
- }
- }
- else {
- result = 1;
- ShowMessage(0, TranslateT("Cannot upload Version Info. Host unreachable."));
- }
- }
-
- mir_free(szRedirUrl);
- mir_free(nlhr.headers);
-
- return result == 0;
-}
-
-void __cdecl VersionInfoUploadThread(void* arg)
-{
- VerTrnsfr* trn = (VerTrnsfr*)arg;
-
- char user[64], pass[40];
- GetLoginStr(user, sizeof(user), pass);
- char str[256];
- mir_snprintf(str, "https://vi.miranda-ng.org/en/upload?login=%s&pass=%s", user, pass);
-
- InternetDownloadFile(str, trn);
- mir_free(trn->buf);
- mir_free(trn);
-}
-
-void UploadInit(void)
-{
- NETLIBUSER nlu = {};
- nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE;
- nlu.szSettingsModule = (char*)MODULENAME;
- nlu.szDescriptiveName.w = TranslateT("Crash Dumper HTTP connections");
- hNetlibUser = Netlib_RegisterUser(&nlu);
-}
-
-void UploadClose(void)
-{
- Netlib_CloseHandle(hNetlibUser);
-}
-
-bool ProcessVIHash(bool store)
-{
- CMStringW buffer;
- PrintVersionInfo(buffer, 0);
-
- uint8_t hash[16];
- mir_md5_state_t context;
-
- mir_md5_init(&context);
- mir_md5_append(&context, (uint8_t*)buffer.c_str(), buffer.GetLength()*sizeof(wchar_t));
- mir_md5_finish(&context, hash);
-
- char hashstr[40];
- arrayToHex(hash, sizeof(hash), hashstr);
-
- if (store) {
- g_plugin.setString("VIHash", hashstr);
- return true;
- }
-
- ptrA VIHash(g_plugin.getStringA("VIHash"));
- if (VIHash == NULL)
- return false;
-
- return mir_strcmp(hashstr, VIHash) == 0;
-}
diff --git a/plugins/CrashDumper/src/version.h b/plugins/CrashDumper/src/version.h
index 46429497dc..3a9c750dfc 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 __MINOR_VERSION 2
#define __RELEASE_NUM 0
-#define __BUILD_NUM 4
+#define __BUILD_NUM 1
#include <stdver.h>