diff options
| author | Tobias Weimer <wishmaster51@googlemail.com> | 2014-05-29 15:34:20 +0000 | 
|---|---|---|
| committer | Tobias Weimer <wishmaster51@googlemail.com> | 2014-05-29 15:34:20 +0000 | 
| commit | d8b7b2b660f81c3d78c64641e894666ac194495d (patch) | |
| tree | 0b036fd9ded5f2b2e6004fc60d29046c19ee623f | |
| parent | dcdc05c1287a9007301ecc7bfd3814f3270cc70b (diff) | |
PluginUpdater:
- Fixed Apply button
- Added Logging
- Minor cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@9351 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
| -rw-r--r-- | plugins/PluginUpdater/res/Resource.rc | 31 | ||||
| -rw-r--r-- | plugins/PluginUpdater/src/Common.h | 2 | ||||
| -rw-r--r-- | plugins/PluginUpdater/src/DlgListNew.cpp | 2 | ||||
| -rw-r--r-- | plugins/PluginUpdater/src/DlgUpdate.cpp | 4 | ||||
| -rw-r--r-- | plugins/PluginUpdater/src/Events.cpp | 8 | ||||
| -rw-r--r-- | plugins/PluginUpdater/src/Options.cpp | 46 | ||||
| -rw-r--r-- | plugins/PluginUpdater/src/PluginUpdater.cpp | 18 | ||||
| -rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 37 | ||||
| -rw-r--r-- | plugins/PluginUpdater/src/resource.h | 2 | 
9 files changed, 78 insertions, 72 deletions
| diff --git a/plugins/PluginUpdater/res/Resource.rc b/plugins/PluginUpdater/res/Resource.rc index d7fda4e6af..2d153aa4eb 100644 --- a/plugins/PluginUpdater/res/Resource.rc +++ b/plugins/PluginUpdater/res/Resource.rc @@ -58,30 +58,30 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1  BEGIN
  END
 -IDD_OPT_UPDATENOTIFY DIALOGEX 0, 0, 261, 207
 +IDD_OPT_UPDATENOTIFY DIALOGEX 0, 0, 273, 219
  STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
  EXSTYLE WS_EX_CONTROLPARENT
  FONT 8, "MS Shell Dlg", 0, 0, 0x1
  BEGIN
 -    GROUPBOX        "Hotkey",IDC_STATIC,2,0,253,26
 +    GROUPBOX        "Hotkey",IDC_STATIC,2,0,262,26
      CONTROL         "Go to Customize -> Hotkeys to change the hotkey",IDC_LINK_HOTKEY,
 -                    "Hyperlink",WS_TABSTOP,9,11,199,10
 -    GROUPBOX        "Plugin updates options",IDC_STATIC,1,29,253,60
 +                    "Hyperlink",WS_TABSTOP,9,11,249,10
 +    GROUPBOX        "Plugin updates options",IDC_STATIC,1,29,263,60
      CONTROL         "On startup",IDC_UPDATEONSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,44,73,10
      CONTROL         "(but only once a day)",IDC_ONLYONCEADAY,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,92,44,161,10
      CONTROL         "Every",IDC_UPDATEONPERIOD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,58,52,10
      EDITTEXT        IDC_PERIOD,65,56,28,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
      CONTROL         "",IDC_PERIODSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,92,56,10,15
      COMBOBOX        IDC_PERIODMEASURE,114,56,58,30,CBS_DROPDOWNLIST | CBS_SORT | WS_DISABLED | WS_VSCROLL | WS_TABSTOP
 -    CONTROL         "Silent mode",IDC_SILENTMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,72,128,10
 -    GROUPBOX        "Files source",IDC_STATIC,1,92,253,96
 -    CONTROL         "Stable version",IDC_STABLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,105,236,10
 -    CONTROL         "Development version (less stable)",IDC_TRUNK,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,120,236,10
 +    CONTROL         "Silent mode",IDC_SILENTMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,72,247,10
 +    GROUPBOX        "Files source",IDC_STATIC,1,92,263,96
 +    CONTROL         "Stable version",IDC_STABLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,105,247,10
 +    CONTROL         "Development version (less stable)",IDC_TRUNK,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,120,247,10
      CONTROL         "Development version with debug symbols",IDC_TRUNK_SYMBOLS,
 -                    "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,135,236,10
 -    CONTROL         "Custom version",IDC_CUSTOM,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,150,236,10
 -    EDITTEXT        IDC_CUSTOMURL,11,164,234,16,ES_AUTOHSCROLL
 -    LTEXT           "You need restart your Miranda to apply installed updates",IDC_NEEDRESTARTLABEL,10,192,222,8,NOT WS_VISIBLE
 +                    "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,135,247,10
 +    CONTROL         "Custom version",IDC_CUSTOM,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,150,247,10
 +    EDITTEXT        IDC_CUSTOMURL,11,164,234,16,ES_AUTOHSCROLL | WS_DISABLED
 +    LTEXT           "You need restart your Miranda to apply installed updates",IDC_NEEDRESTARTLABEL,11,192,253,22,NOT WS_VISIBLE
  END
  IDD_POPUP DIALOGEX 0, 0, 316, 182
 @@ -185,6 +185,13 @@ BEGIN      IDD_OPT_UPDATENOTIFY, DIALOG
      BEGIN
 +        LEFTMARGIN, 1
 +        RIGHTMARGIN, 261
 +        VERTGUIDE, 2
 +        VERTGUIDE, 11
 +        VERTGUIDE, 258
 +        VERTGUIDE, 264
 +        BOTTOMMARGIN, 207
      END
      IDD_LIST, DIALOG
 diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h index add054051c..00094a21f7 100644 --- a/plugins/PluginUpdater/src/Common.h +++ b/plugins/PluginUpdater/src/Common.h @@ -193,7 +193,7 @@ bool  ParseHashes(const TCHAR *ptszUrl, ptrT &baseUrl, SERVLIST &arHashes);  int   CompareHashes(const ServListEntry *p1, const ServListEntry *p2);
  TCHAR* GetDefaultUrl();
 -BOOL   DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum, HANDLE &nlc);
 +BOOL   DownloadFile(FILEURL *pFileURL, HANDLE &nlc);
  void  ShowPopup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, int Number, int ActType, bool NoMessageBox = false);
  void  __stdcall RestartMe(void*);
 diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp index 255066ea01..0f3811ce92 100644 --- a/plugins/PluginUpdater/src/DlgListNew.cpp +++ b/plugins/PluginUpdater/src/DlgListNew.cpp @@ -70,7 +70,7 @@ static void ApplyDownloads(void *param)  		ListView_SetItemText(hwndList, i, 2, TranslateT("Downloading..."));
  		FILEURL *pFileUrl = &todo[i].File;
 -		if (!DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath, pFileUrl->CRCsum, nlc)) {
 +		if (!DownloadFile(pFileUrl, nlc)) {
  			ListView_SetItemText(hwndList, i, 2, TranslateT("Failed!"));
  		}
  		else
 diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 9e8c2338e1..58da5f1263 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -83,7 +83,7 @@ static void ApplyUpdates(void *param)  		SetStringText(hwndList, i, TranslateT("Downloading..."));
  		FILEURL *pFileUrl = &todo[i].File;
 -		if (!DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath, pFileUrl->CRCsum, nlc)) {
 +		if (!DownloadFile(pFileUrl, nlc)) {
  			SetStringText(hwndList, i, TranslateT("Failed!"));
  			// interrupt update as we require all components to be updated
 @@ -369,7 +369,7 @@ static void DlgUpdateSilent(void *lParam)  		// download update
  		FILEURL *pFileUrl = &UpdateFiles[i].File;
 -		if (!DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath, pFileUrl->CRCsum, nlc)) {
 +		if (!DownloadFile(pFileUrl, nlc)) {
  			// interrupt update as we require all components to be updated
  			error = true;
  			break;
 diff --git a/plugins/PluginUpdater/src/Events.cpp b/plugins/PluginUpdater/src/Events.cpp index cf1e72f868..3fa58c9439 100644 --- a/plugins/PluginUpdater/src/Events.cpp +++ b/plugins/PluginUpdater/src/Events.cpp @@ -51,7 +51,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam)  	return 0;
  }
 -INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam)
 +INT_PTR MenuCommand(WPARAM,LPARAM)
  {
  	opts.bSilent = false;
  	DoCheck(true);
 @@ -59,7 +59,7 @@ INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam)  }
  #if MIRANDA_VER >= 0x0A00
 -INT_PTR ShowListCommand(WPARAM wParam,LPARAM lParam)
 +INT_PTR ShowListCommand(WPARAM,LPARAM)
  {
  	opts.bSilent = false;
  	DoGetList(true);
 @@ -67,7 +67,7 @@ INT_PTR ShowListCommand(WPARAM wParam,LPARAM lParam)  }
  #endif
 -INT_PTR EmptyFolder(WPARAM wParam,LPARAM lParam)
 +INT_PTR EmptyFolder(WPARAM,LPARAM lParam)
  {
  	SHFILEOPSTRUCT file_op = {
  		NULL,
 @@ -85,7 +85,7 @@ INT_PTR EmptyFolder(WPARAM wParam,LPARAM lParam)  	return 0;
  }
 -int OnPreShutdown(WPARAM wParam, LPARAM lParam)
 +int OnPreShutdown(WPARAM, LPARAM)
  {
  	CancelWaitableTimer(Timer);
  	CloseHandle(Timer);
 diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index 10624c4ba3..ff86820cf3 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -20,24 +20,12 @@ Boston, MA 02111-1307, USA.  #include "common.h"
  PlugOptions opts;
 -WNDPROC g_pOldProc;
 -
 -LRESULT CALLBACK MyEditProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 -{
 -	switch (message) {
 -	case WM_KEYDOWN:
 -		SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0);
 -		break;
 -	}
 -	return CallWindowProc(g_pOldProc, hwnd, message, wParam, lParam);
 -}
  INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  {
 -	DBVARIANT dbv;
 -
  	switch (msg) {
  	case WM_INITDIALOG:
 +	{
  		TranslateDialogDefault(hwndDlg);
  		CheckDlgButton(hwndDlg, IDC_UPDATEONSTARTUP, opts.bUpdateOnStartup);
  		CheckDlgButton(hwndDlg, IDC_ONLYONCEADAY, opts.bOnlyOnceADay);
 @@ -54,13 +42,11 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA  		SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETPOS, 0, (LPARAM)opts.Period);
  		Edit_LimitText(GetDlgItem(hwndDlg, IDC_PERIOD), 2);
 -		g_pOldProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_PERIOD), GWLP_WNDPROC, (LONG_PTR)MyEditProc);
  		ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 0, TranslateT("hours"));
  		ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 1, TranslateT("days"));
  		ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), opts.bPeriodMeasure);
 -
 -		EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE);
 +		DBVARIANT dbv;
  		if ( db_get_s(NULL, MODNAME, "UpdateURL", &dbv)) {
  			SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL));
  			CheckDlgButton(hwndDlg, IDC_STABLE, TRUE);
 @@ -79,14 +65,13 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA  			}
  			db_free(&dbv);
  		}
 +	}
  		return TRUE;
  	case WM_COMMAND:
  		switch (LOWORD(wParam)) {
  		case IDC_UPDATEONSTARTUP:
 -			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
  			EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP));
 -			break;
  		case IDC_SILENTMODE:
  		case IDC_ONLYONCEADAY:
 @@ -111,6 +96,12 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA  			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
  			break;
 +		case IDC_PERIOD:
 +		case IDC_CUSTOMURL:
 +			if ((HWND)lParam == GetFocus() && (HIWORD(wParam) == EN_CHANGE))
 +				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
 +			break;
 +
  		case IDC_PERIODMEASURE:
  			if (HIWORD(wParam) == CBN_SELCHANGE)
  				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
 @@ -182,7 +173,6 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA  INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
  {
 -	int i;
  	char str[20] = {0}, str2[20] = {0};
  	switch (msg) {
 @@ -205,7 +195,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)  			CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_CHECKED);
  			CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED);
  		}
 -		for (i = 0; i < POPUPS; i++) {
 +		for (int i = 0; i < POPUPS; i++) {
  			SendDlgItemMessage(hdlg, (i+42071), CPM_SETCOLOUR, 0, PopupsList[i].colorBack);
  			SendDlgItemMessage(hdlg, (i+41071), CPM_SETCOLOUR, 0, PopupsList[i].colorText);
  			EnableWindow(GetDlgItem(hdlg, (i+42071)), (PopupOptions.DefColors == byCOLOR_OWN));
 @@ -216,7 +206,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)  		SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, -1, 9999);
  		SetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, PopupOptions.Timeout, TRUE);
  		//Mouse actions
 -		for (i = 0; i < SIZEOF(PopupActions); i++) {
 +		for (int i = 0; i < SIZEOF(PopupActions); i++) {
  			SendMessage(GetDlgItem(hdlg, IDC_LC), CB_SETITEMDATA, SendMessage(GetDlgItem(hdlg, IDC_LC), CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action);
  			SendMessage(GetDlgItem(hdlg, IDC_RC), CB_SETITEMDATA, SendMessage(GetDlgItem(hdlg, IDC_RC), CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action);
  		}
 @@ -224,7 +214,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)  		SendDlgItemMessage(hdlg, IDC_RC, CB_SETCURSEL, PopupOptions.RightClickAction, 0);
  		//Popups nitified
 -		for (i = 0; i < POPUPS; i++) {
 +		for (int i = 0; i < POPUPS; i++) {
  			mir_snprintf(str, SIZEOF(str), "Popups%d", i);
  			mir_snprintf(str2, SIZEOF(str2), "Popups%dM", i);
  			CheckDlgButton(hdlg, (i+40071), (db_get_b(NULL, MODNAME, str, DEFAULT_POPUP_ENABLED)) ? BST_CHECKED: BST_UNCHECKED);
 @@ -275,7 +265,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)  				PopupOptions.DefColors = byCOLOR_OWN;
 -				for (i = 0; i < POPUPS; i++) {
 +				for (int i = 0; i < POPUPS; i++) {
  					EnableWindow(GetDlgItem(hdlg, (i+42071)), TRUE); //Background
  					EnableWindow(GetDlgItem(hdlg, (i+41071)), TRUE); //Text
  				}
 @@ -288,7 +278,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)  				//Use Windows colors
  				PopupOptions.DefColors = byCOLOR_WINDOWS;
 -				for (i = 0; i < POPUPS; i++) {
 +				for (int i = 0; i < POPUPS; i++) {
  					EnableWindow(GetDlgItem(hdlg, (i+42071)), FALSE); //Background
  					EnableWindow(GetDlgItem(hdlg, (i+41071)), FALSE); //Text
  				}
 @@ -301,7 +291,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)  				//Use Popup colors
  				PopupOptions.DefColors = byCOLOR_POPUP;
 -				for (i = 0; i < POPUPS; i++)  {
 +				for (int i = 0; i < POPUPS; i++)  {
  					EnableWindow(GetDlgItem(hdlg, (i+42071)), FALSE); //Background
  					EnableWindow(GetDlgItem(hdlg, (i+41071)), FALSE); //Text
  				}
 @@ -364,7 +354,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)  				//Text color
  				char szSetting[20] = {0};
  				DWORD ctlColor = 0;
 -				for (i = 0; i <= POPUPS-1; i++) {
 +				for (int i = 0; i <= POPUPS-1; i++) {
  					ctlColor = SendDlgItemMessage(hdlg, (i+42071), CPM_GETCOLOUR, 0, 0);
  					PopupsList[i].colorBack = ctlColor;
  					mir_snprintf(szSetting, SIZEOF(szSetting), "Popups%iBg", i);
 @@ -384,7 +374,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)  				//Right mouse click
  				db_set_b(NULL, MODNAME, "RightClickAction", PopupOptions.RightClickAction);
  				//Notified popups
 -				for (i = 0; i < POPUPS; i++) {
 +				for (int i = 0; i < POPUPS; i++) {
  					mir_snprintf(str, SIZEOF(str), "Popups%d", i);
  					db_set_b(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hdlg, (i+40071))));
  					mir_snprintf(str2, SIZEOF(str2), "Popups%dM", i);
 @@ -398,7 +388,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)  	return FALSE;
  }
 -int OptInit(WPARAM wParam, LPARAM lParam)
 +int OptInit(WPARAM wParam, LPARAM)
  {
  	OPTIONSDIALOGPAGE odp = { sizeof(odp) };
  	odp.position = 100000000;
 diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp index 1cfa3f2ab9..90836ea084 100644 --- a/plugins/PluginUpdater/src/PluginUpdater.cpp +++ b/plugins/PluginUpdater/src/PluginUpdater.cpp @@ -116,15 +116,15 @@ extern "C" __declspec(dllexport) int Load(void)  	mi.pszService = MODNAME"/CheckUpdates";
  	Menu_AddMainMenuItem(&mi);
 -	#if MIRANDA_VER >= 0x0A00
 -		CreateServiceFunction(MODNAME"/ShowList", ShowListCommand);
 -
 -		mi.position++;
 -		mi.icolibItem = Skin_GetIconHandle("plg_list");
 -		mi.pszName = LPGEN("Available components list");
 -		mi.pszService = MODNAME"/ShowList";
 -		Menu_AddMainMenuItem(&mi);
 -	#endif
 +#if MIRANDA_VER >= 0x0A00
 +	CreateServiceFunction(MODNAME"/ShowList", ShowListCommand);
 +
 +	mi.position++;
 +	mi.icolibItem = Skin_GetIconHandle("plg_list");
 +	mi.pszName = LPGEN("Available components list");
 +	mi.pszService = MODNAME"/ShowList";
 +	Menu_AddMainMenuItem(&mi);
 +#endif
  	// Add hotkey
  	HOTKEYDESC hkd = { sizeof(hkd) };
 diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index d64f5c51b3..5cf508dbbb 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -217,9 +217,10 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes)  	FILEURL pFileUrl;
  	mir_sntprintf(pFileUrl.tszDownloadURL, SIZEOF(pFileUrl.tszDownloadURL), _T("%s/hashes.zip"), baseUrl);
  	mir_sntprintf(pFileUrl.tszDiskPath, SIZEOF(pFileUrl.tszDiskPath), _T("%s\\hashes.zip"), tszTempPath);
 +	pFileUrl.CRCsum = 0;
  	HANDLE nlc;
 -	BOOL ret = DownloadFile(pFileUrl.tszDownloadURL, pFileUrl.tszDiskPath, 0, nlc);
 +	BOOL ret = DownloadFile(&pFileUrl, nlc);
  	Netlib_CloseHandle(nlc);
  	if (!ret && !opts.bSilent) {
 @@ -262,22 +263,22 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes)  }
 -BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum, HANDLE &nlc)
 +bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc)
  {
  	DWORD dwBytes;
  	NETLIBHTTPREQUEST nlhr = {0};
 -	#if MIRANDA_VER < 0x0A00
 -		nlhr.cbSize = NETLIBHTTPREQUEST_V1_SIZE;
 -	#else
 -		nlhr.cbSize = sizeof(nlhr);
 -	#endif
 +#if MIRANDA_VER < 0x0A00
 +	nlhr.cbSize = NETLIBHTTPREQUEST_V1_SIZE;
 +#else
 +	nlhr.cbSize = sizeof(nlhr);
 +#endif
  	nlhr.requestType = REQUEST_GET;
  	nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11;
  	if (g_mirandaVersion >= PLUGIN_MAKE_VERSION(0, 9, 0, 0))
  		nlhr.flags |= NLHRF_PERSISTENT;
  	nlhr.nlc = nlc;
 -	char *szUrl = mir_t2a(tszURL);
 +	char *szUrl = mir_t2a(pFileURL->tszDownloadURL);
  	nlhr.szUrl = szUrl;
  	nlhr.headersCount = 4;
  	nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
 @@ -292,20 +293,23 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum, HANDLE &nlc)  	bool ret = false;
  	for (int i = 0; !ret && i < MAX_RETRIES; i++) {
 +		Netlib_LogfT(hNetlibUser,_T("Downloading file %s to %s (attempt %d)"),pFileURL->tszDownloadURL,pFileURL->tszDiskPath, i+1);
  		NETLIBHTTPREQUEST *pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
  		if (pReply) {
  			nlc = pReply->nlc;
  			if ((200 == pReply->resultCode) && (pReply->dataLength > 0)) {
 -				HANDLE hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
 +				HANDLE hFile = CreateFile(pFileURL->tszDiskPath, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  				if (hFile != INVALID_HANDLE_VALUE) {
  					// write the downloaded file directly
  					WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
  					CloseHandle(hFile);
 -					if (CRCsum) {
 +					if (pFileURL->CRCsum) {
  						InitCrcTable();
  						int crc = Get_CRC((unsigned char*)pReply->pData, (long)dwBytes);
 -						if (crc == CRCsum)
 +						if (crc == pFileURL->CRCsum)
  							ret = true;
 +						else
 +							Netlib_LogfT(hNetlibUser,_T("crc check failed for %s"),pFileURL->tszDownloadURL);
  					}
  					else
  						ret = true;
 @@ -318,24 +322,29 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum, HANDLE &nlc)  					if (hFile != INVALID_HANDLE_VALUE) {
  						WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
  						CloseHandle(hFile);
 -						SafeMoveFile(tszTempFile, tszLocal);
 -						if (CRCsum) {
 +						SafeMoveFile(tszTempFile, pFileURL->tszDiskPath);
 +						if (pFileURL->CRCsum) {
  							InitCrcTable();
  							int crc = Get_CRC((unsigned char*)pReply->pData, (long)dwBytes);
 -							if (crc == CRCsum)
 +							if (crc == pFileURL->CRCsum)
  								ret = true;
 +							else
 +								Netlib_LogfT(hNetlibUser,_T("crc check failed for %s"),pFileURL->tszDownloadURL);
  						}
  						else
  							ret = true;
  					}
  				}
  			}
 +			else
 +				Netlib_LogfT(hNetlibUser,_T("Downloading file %s failed with error %d"),pFileURL->tszDownloadURL,pReply->resultCode);
  			CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pReply);
  		}
  		else {
  			nlc = NULL;
  		}
  	}
 +	Netlib_LogfT(hNetlibUser,_T("Downloading file %s failed, giving up"),pFileURL->tszDownloadURL);
  	mir_free(szUrl);
  	mir_free(nlhr.headers);
 diff --git a/plugins/PluginUpdater/src/resource.h b/plugins/PluginUpdater/src/resource.h index 92771780d2..283c963197 100644 --- a/plugins/PluginUpdater/src/resource.h +++ b/plugins/PluginUpdater/src/resource.h @@ -1,6 +1,6 @@  //{{NO_DEPENDENCIES}}
  // Microsoft Visual C++ generated include file.
 -// Used by D:\Development\Miranda NG\plugins\PluginUpdater\res\Resource.rc
 +// Used by ..\res\Resource.rc
  //
  #define IDD_UPDATE                      101
  #define IDD_OPT_UPDATENOTIFY            102
 | 
