diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2014-09-18 19:32:43 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2014-09-18 19:32:43 +0000 |
commit | c72e3f9fe11a3d6b72a04af599b04fde82091dd5 (patch) | |
tree | 51a38dabcf65b28b8e2e6893b7e947b443583fef | |
parent | 850eb8d3890ebd911fb8278114b7b93eba407cb0 (diff) |
PluginUpdater:
- Show a notification when the update URL isn't available
- small redesign of new components window
- minor memory leaks fixecd
git-svn-id: http://svn.miranda-ng.org/main/trunk@10509 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/PluginUpdater/res/Resource.rc | 72 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Common.h | 6 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgListNew.cpp | 45 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgUpdate.cpp | 24 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Events.cpp | 43 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Notifications.cpp | 75 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Notifications.h | 4 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Options.cpp | 108 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 94 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/resource.h | 1 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/unzipfile.cpp | 8 |
11 files changed, 211 insertions, 269 deletions
diff --git a/plugins/PluginUpdater/res/Resource.rc b/plugins/PluginUpdater/res/Resource.rc index b682acbc93..2048ecaf87 100644 --- a/plugins/PluginUpdater/res/Resource.rc +++ b/plugins/PluginUpdater/res/Resource.rc @@ -52,12 +52,6 @@ BEGIN PUSHBUTTON "Select &none",IDC_SELNONE,175,218,60,14,NOT WS_TABSTOP
END
-IDD_POPUPDUMMI DIALOGEX 65526, 65526, 1, 1
-STYLE DS_ABSALIGN | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
-END
-
IDD_OPT_UPDATENOTIFY DIALOGEX 0, 0, 273, 219
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
@@ -84,45 +78,41 @@ BEGIN CTEXT "Some component(s) was updated.\nYou need to restart your Miranda to apply installed updates.",IDC_NEEDRESTARTLABEL,11,193,247,15,NOT WS_VISIBLE
END
-IDD_POPUP DIALOGEX 0, 0, 316, 187
+IDD_POPUP DIALOGEX 0, 0, 316, 174
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
-GROUPBOX "Notifications", IDC_NOTIFY, 1, 0, 172, 63
-CONTROL "Restart", IDC_MSG_BOXES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 7, 19, 79, 10
-CONTROL "Errors", IDC_ERRORS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 7, 32, 79, 10
-CONTROL "Info messages", IDC_INFO_MESSAGES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 7, 45, 79, 10
-CTEXT "Back", IDC_STATIC, 90, 8, 24, 8
-CTEXT "Text", IDC_STATIC, 116, 8, 24, 8
-CONTROL "", IDC_MSG_BOXES_BG, "ColourPicker", WS_TABSTOP, 90, 17, 24, 12
-CONTROL "", IDC_MSG_BOXES_TX, "ColourPicker", WS_TABSTOP, 116, 17, 24, 12
-CONTROL "", IDC_MSG_BOXES_MSG, "Button", BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP, 153, 19, 8, 10
-CONTROL "", IDC_ERR_BG, "ColourPicker", WS_TABSTOP, 90, 31, 24, 12
-CONTROL "", IDC_ERR_TX, "ColourPicker", WS_TABSTOP, 116, 31, 24, 12
-CONTROL "", IDC_ERRORS_MSG, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 153, 32, 8, 10
-CONTROL "", IDC_INFO_MESSAGES_BG, "ColourPicker", WS_TABSTOP, 90, 44, 24, 12
-CONTROL "", IDC_INFO_MESSAGES_TX, "ColourPicker", WS_TABSTOP, 116, 44, 24, 12
-CONTROL "", IDC_INFO_MESSAGES_MSG, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 153, 45, 8, 10
-GROUPBOX "Colors", IDC_COLORS, 178, 0, 133, 63, WS_GROUP
-CONTROL "Use cus&tom colors", IDC_USEOWNCOLORS, "Button", BS_AUTORADIOBUTTON | BS_MULTILINE | BS_NOTIFY, 186, 15, 122, 13
-CONTROL "Use &Windows colors", IDC_USEWINCOLORS, "Button", BS_AUTORADIOBUTTON | BS_MULTILINE | BS_NOTIFY, 186, 37, 121, 13
-CONTROL "Use Pop&up colors", IDC_USEPOPUPCOLORS, "Button", BS_AUTORADIOBUTTON | BS_MULTILINE | BS_NOTIFY, 186, 26, 102, 13
-PUSHBUTTON "Preview", IDC_PREVIEW, 107, 153, 102, 12
-GROUPBOX "Click action", IDC_STATIC, 1, 110, 310, 37, WS_GROUP
-LTEXT "On left click", IDC_STATIC, 8, 122, 145, 8
-COMBOBOX IDC_LC, 6, 130, 147, 30, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
-LTEXT "On right click", IDC_STATIC, 161, 120, 145, 8
-COMBOBOX IDC_RC, 159, 130, 147, 30, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
-GROUPBOX "Timeout", IDC_STATIC, 1, 64, 310, 45
-EDITTEXT IDC_TIMEOUT_VALUE, 7, 76, 32, 12, ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
-CONTROL "", IDC_TIMEOUT_VALUE_SPIN, "msctls_updown32", UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS, 28, 76, 11, 12
-CTEXT "0 = Default", IDC_STATIC_DEFAULT, 74, 78, 99, 8
-CTEXT "-1 = Infinite", IDC_STATIC_INFINITE, 186, 78, 117, 8
-LTEXT "Sec", IDC_STATIC_SEC, 43, 78, 17, 8
-LTEXT "For ""Restart"" popup setting is always infinity", IDC_STATIC, 7, 94, 297, 8
-CTEXT "Boxes", IDC_STATIC, 146, 8, 23, 8
-CTEXT "Popups", IDC_STATIC, 7, 9, 79, 8
+ GROUPBOX "Notifications",IDC_NOTIFY,1,0,172,63
+ CONTROL "Restart",IDC_MSG_BOXES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,19,79,10
+ CONTROL "Errors",IDC_ERRORS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,32,79,10
+ CONTROL "Info messages",IDC_INFO_MESSAGES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,45,79,10
+ CTEXT "Back",IDC_STATIC,90,8,24,8
+ CTEXT "Text",IDC_STATIC,116,8,24,8
+ CONTROL "",IDC_MSG_BOXES_BG,"ColourPicker",WS_TABSTOP,90,17,24,12
+ CONTROL "",IDC_MSG_BOXES_TX,"ColourPicker",WS_TABSTOP,116,17,24,12
+ CONTROL "",IDC_ERR_BG,"ColourPicker",WS_TABSTOP,90,31,24,12
+ CONTROL "",IDC_ERR_TX,"ColourPicker",WS_TABSTOP,116,31,24,12
+ CONTROL "",IDC_INFO_MESSAGES_BG,"ColourPicker",WS_TABSTOP,90,44,24,12
+ CONTROL "",IDC_INFO_MESSAGES_TX,"ColourPicker",WS_TABSTOP,116,44,24,12
+ GROUPBOX "Colors",IDC_COLORS,178,0,133,63,WS_GROUP
+ CONTROL "Use cus&tom colors",IDC_USEOWNCOLORS,"Button",BS_AUTORADIOBUTTON | BS_MULTILINE | BS_NOTIFY,186,15,122,13
+ CONTROL "Use &Windows colors",IDC_USEWINCOLORS,"Button",BS_AUTORADIOBUTTON | BS_MULTILINE | BS_NOTIFY,186,37,121,13
+ CONTROL "Use Pop&up colors",IDC_USEPOPUPCOLORS,"Button",BS_AUTORADIOBUTTON | BS_MULTILINE | BS_NOTIFY,186,26,102,13
+ PUSHBUTTON "Preview",IDC_PREVIEW,107,153,102,12
+ GROUPBOX "Click action",IDC_STATIC,1,110,310,37,WS_GROUP
+ LTEXT "On left click",IDC_STATIC,8,122,145,8
+ COMBOBOX IDC_LC,6,130,147,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "On right click",IDC_STATIC,161,120,145,8
+ COMBOBOX IDC_RC,159,130,147,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Timeout",IDC_STATIC,1,64,310,45
+ EDITTEXT IDC_TIMEOUT_VALUE,7,76,32,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_TIMEOUT_VALUE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,28,76,11,12
+ CTEXT "0 = Default",IDC_STATIC_DEFAULT,74,78,99,8
+ CTEXT "-1 = Infinite",IDC_STATIC_INFINITE,186,78,117,8
+ LTEXT "Sec",IDC_STATIC_SEC,43,78,17,8
+ LTEXT "For ""Restart"" popup setting is always infinity",IDC_STATIC,7,94,297,8
+ CTEXT "Popups",IDC_STATIC,7,9,79,8
END
IDD_LIST DIALOGEX 0, 0, 240, 236
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h index 0daf395231..e45e885fdd 100644 --- a/plugins/PluginUpdater/src/Common.h +++ b/plugins/PluginUpdater/src/Common.h @@ -121,10 +121,6 @@ struct PlugOptions #define UPDATE_MODE_TRUNK_SYMBOLS 3
#define UPDATE_MODE_MAX_VALUE 3 // when adding new mode, increment this number
-#define POPUP_TYPE_MSG 0
-#define POPUP_TYPE_ERROR 1
-#define POPUP_TYPE_INFO 2
-#define POPUP_TYPE_PROGRESS 2
#define MAX_RETRIES 3
@@ -143,7 +139,7 @@ extern POPUP_OPTIONS PopupOptions; extern aPopups PopupsList[POPUPS];
extern HANDLE Timer, hPipe, hNetlibUser;
-void DoCheck();
+void DoCheck(bool bSilent);
void UninitCheck(void);
void UninitListNew(void);
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp index d860edb694..7cc8a900a4 100644 --- a/plugins/PluginUpdater/src/DlgListNew.cpp +++ b/plugins/PluginUpdater/src/DlgListNew.cpp @@ -28,8 +28,7 @@ static void SelectAll(HWND hDlg, bool bEnable) HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES);
for (int i=0; i < todo.getCount(); i++) {
- ListView_SetCheckState(hwndList, i, bEnable);
- todo[i].bEnabled = bEnable;
+ ListView_SetCheckState(hwndList, i, todo[i].bEnabled = bEnable);
}
}
@@ -59,25 +58,25 @@ static void ApplyDownloads(void *param) mir_sntprintf(tszFileTemp, SIZEOF(tszFileTemp), _T("%s\\Temp"), tszRoot);
SafeCreateDirectory(tszFileTemp);
- TCHAR *tszMirandaPath = Utils_ReplaceVarsT(_T("%miranda_path%"));
+ VARST tszMirandaPath(_T("%miranda_path%"));
HANDLE nlc = NULL;
for (int i=0; i < todo.getCount(); ++i) {
ListView_EnsureVisible(hwndList, i, FALSE);
if (todo[i].bEnabled) {
// download update
- ListView_SetItemText(hwndList, i, 2, TranslateT("Downloading..."));
+ ListView_SetItemText(hwndList, i, 1, TranslateT("Downloading..."));
if (DownloadFile(&todo[i].File, nlc)) {
- ListView_SetItemText(hwndList, i, 2, TranslateT("Succeeded."));
+ ListView_SetItemText(hwndList, i, 1, TranslateT("Succeeded."));
if (unzip(todo[i].File.tszDiskPath, tszMirandaPath, tszFileBack,false))
SafeDeleteFile(todo[i].File.tszDiskPath); // remove .zip after successful update
}
else
- ListView_SetItemText(hwndList, i, 2, TranslateT("Failed!"));
+ ListView_SetItemText(hwndList, i, 1, TranslateT("Failed!"));
}
else
- ListView_SetItemText(hwndList, i, 2, TranslateT("Skipped."));
+ ListView_SetItemText(hwndList, i, 1, TranslateT("Skipped."));
}
Netlib_CloseHandle(nlc);
@@ -100,7 +99,7 @@ static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LP LVHITTESTINFO hi;
hi.pt.x = LOWORD(lParam); hi.pt.y = HIWORD(lParam);
ListView_SubItemHitTest(hwnd, &hi);
- if (hi.iSubItem == 1) {
+ if ((hi.iSubItem == 0) && (hi.flags & LVHT_ONITEMICON)) {
LVITEM lvi = {0};
lvi.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_GROUPID;
lvi.stateMask = -1;
@@ -180,13 +179,9 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) lvc.cx = 220; // width of column in pixels
ListView_InsertColumn(hwndList, 0, &lvc);
- lvc.pszText = L"";
- lvc.cx = 32 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels
- ListView_InsertColumn(hwndList, 1, &lvc);
-
lvc.pszText = TranslateT("State");
- lvc.cx = 100 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels
- ListView_InsertColumn(hwndList, 2, &lvc);
+ lvc.cx = 100; // width of column in pixels
+ ListView_InsertColumn(hwndList, 1, &lvc);
///
LVGROUP lvg;
@@ -228,19 +223,9 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) lvi.iItem = i;
lvi.lParam = (LPARAM)&todo[i];
lvi.iGroupId = groupId;
- lvi.iImage = -1;
+ lvi.iImage = ((groupId ==1) ? 0 : -1);
lvi.pszText = todo[i].tszOldName;
- int iRow = ListView_InsertItem(hwndList, &lvi);
-
- if (iRow != -1) {
- lvi.iItem = iRow;
- if (groupId == 1) {
- lvi.mask = LVIF_IMAGE;
- lvi.iSubItem = 1;
- lvi.iImage = 0;
- ListView_SetItem(hwndList, &lvi);
- }
- }
+ ListView_InsertItem(hwndList, &lvi);
}
}
@@ -366,7 +351,7 @@ static void GetList(void *) }
FILELIST *UpdateFiles = new FILELIST(20);
- TCHAR *dirname = Utils_ReplaceVarsT(_T("%miranda_path%"));
+ VARST dirname(_T("%miranda_path%"));
for (int i=0; i < hashes.getCount(); i++) {
ServListEntry &hash = hashes[i];
@@ -402,12 +387,9 @@ static void GetList(void *) }
}
- mir_free(dirname);
-
// Show dialog
if (UpdateFiles->getCount() == 0) {
- if (!opts.bSilent)
- ShowPopup(TranslateT("Plugin Updater"), TranslateT("List is empty."), POPUP_TYPE_INFO);
+ ShowPopup(TranslateT("Plugin Updater"), TranslateT("List is empty."), POPUP_TYPE_INFO);
delete UpdateFiles;
}
else CallFunctionAsync(LaunchListDialog, UpdateFiles);
@@ -436,7 +418,6 @@ void UninitListNew() INT_PTR ShowListCommand(WPARAM,LPARAM)
{
- opts.bSilent = false;
DoGetList();
return 0;
}
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 8edb1431e8..7b46083131 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -95,7 +95,7 @@ static void ApplyUpdates(void *param) Netlib_CloseHandle(nlc);
// 3) Unpack all zips
- TCHAR *tszMirandaPath = Utils_ReplaceVarsT(_T("%miranda_path%"));
+ VARST tszMirandaPath(_T("%miranda_path%"));
for (int i = 0; i < todo.getCount(); i++) {
FILEINFO& p = todo[i];
if (p.bEnabled) {
@@ -340,13 +340,12 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM Skin_ReleaseIcon((HICON)SendMessage(hDlg, WM_SETICON, ICON_SMALL, 0));
Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ConfirmWindow");
hwndDialog = NULL;
- opts.bSilent = true;
delete (OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
#if MIRANDA_VER >= 0x0A00
db_set_dw(NULL, MODNAME, "LastUpdate", time(NULL));
#endif
- mir_forkthread(InitTimer, (void*)0);
+ mir_forkthread(InitTimer, 0);
break;
}
@@ -404,7 +403,7 @@ static void DlgUpdateSilent(void *lParam) }
// 3) Unpack all zips
- TCHAR *tszMirandaPath = Utils_ReplaceVarsT(_T("%miranda_path%"));
+ VARST tszMirandaPath(_T("%miranda_path%"));
for (int i = 0; i < UpdateFiles.getCount(); i++) {
FILEINFO& p = UpdateFiles[i];
if (p.bEnabled) {
@@ -618,8 +617,9 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const int MyCRC = 0;
mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\%s"), tszFolder, ffd.cFileName);
+ BOOL bDeleteOnly = (tszNewName[0] == 0);
// this file is not marked for deletion
- if (tszNewName[0]) {
+ if (!bDeleteOnly) {
TCHAR *pName = tszNewName;
ServListEntry *item = hashes.find((ServListEntry*)&pName);
if (item == NULL) {
@@ -663,7 +663,7 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const FILEINFO *FileInfo = new FILEINFO;
// copy the relative old name
_tcsncpy(FileInfo->tszOldName, tszBuf+cbBaseLen, SIZEOF(FileInfo->tszOldName));
- FileInfo->bDeleteOnly = (tszNewName[0] == 0);
+ FileInfo->bDeleteOnly = bDeleteOnly;
if (FileInfo->bDeleteOnly) {
// save the full old name for deletion
_tcsncpy(FileInfo->tszNewName, tszBuf, SIZEOF(FileInfo->tszNewName));
@@ -723,19 +723,17 @@ static void CheckUpdates(void *) if (!opts.bSilent)
ShowPopup(TranslateT("Plugin Updater"), TranslateT("No updates found."), POPUP_TYPE_INFO);
delete UpdateFiles;
- opts.bSilent = true;
}
else CallFunctionAsync(LaunchDialog, UpdateFiles);
}
- else opts.bSilent = true;
- mir_forkthread(InitTimer, (void*)(success ? 0 : 2));
+ mir_forkthread(InitTimer, (success ? 0 :(void*) 2));
hashes.destroy();
hCheckThread = NULL;
}
-void DoCheck()
+void DoCheck(bool bSilent)
{
if (hCheckThread)
ShowPopup(TranslateT("Plugin Updater"), TranslateT("Update checking already started!"), POPUP_TYPE_INFO);
@@ -744,6 +742,7 @@ void DoCheck() SetForegroundWindow(hwndDialog);
SetFocus(hwndDialog);
} else {
+ opts.bSilent = bSilent;
#if MIRANDA_VER >= 0x0A00
db_set_dw(NULL, MODNAME, "LastUpdate", time(NULL));
#endif
@@ -760,8 +759,7 @@ void UninitCheck() INT_PTR MenuCommand(WPARAM,LPARAM)
{
Netlib_LogfT(hNetlibUser,_T("Update started manually!"));
- opts.bSilent = false;
- DoCheck();
+ DoCheck(false);
return 0;
}
@@ -789,6 +787,6 @@ void CheckUpdateOnStartup() return;
}
Netlib_LogfT(hNetlibUser,_T("Update on startup started!"));
- DoCheck();
+ DoCheck(true);
}
}
\ No newline at end of file diff --git a/plugins/PluginUpdater/src/Events.cpp b/plugins/PluginUpdater/src/Events.cpp index 90ad62e3fb..6afabbe2a7 100644 --- a/plugins/PluginUpdater/src/Events.cpp +++ b/plugins/PluginUpdater/src/Events.cpp @@ -30,23 +30,34 @@ int OnFoldersChanged(WPARAM, LPARAM) return 0;
}
-int ModulesLoaded(WPARAM, LPARAM)
+void EmptyFolder()
{
- HookEvent(ME_FOLDERS_PATH_CHANGED, OnFoldersChanged);
+ SHFILEOPSTRUCT file_op = {
+ NULL,
+ FO_DELETE,
+ tszRoot,
+ _T(""),
+ FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION,
+ false,
+ 0,
+ _T("") };
+ SHFileOperation(&file_op);
+}
- hPluginUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, LPGEN("Plugin Updater"), MIRANDA_PATHT _T("\\")DEFAULT_UPDATES_FOLDER);
- if (hPluginUpdaterFolder)
+int ModulesLoaded(WPARAM, LPARAM)
+{
+ if (hPluginUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, LPGEN("Plugin Updater"), MIRANDA_PATHT _T("\\")DEFAULT_UPDATES_FOLDER)) {
+ HookEvent(ME_FOLDERS_PATH_CHANGED, OnFoldersChanged);
OnFoldersChanged(0, 0);
+ }
else
lstrcpyn(tszRoot, VARST( _T("%miranda_path%\\"DEFAULT_UPDATES_FOLDER)), SIZEOF(tszRoot));
- opts.bSilent = true;
-
int iRestartCount = db_get_b(NULL, MODNAME, "RestartCount", 2);
if (iRestartCount > 0)
db_set_b(NULL, MODNAME, "RestartCount", iRestartCount-1);
else
- EmptyFolder(0, TRUE); // silently
+ EmptyFolder(); // silently
CheckUpdateOnStartup();
@@ -56,24 +67,6 @@ int ModulesLoaded(WPARAM, LPARAM) return 0;
}
-INT_PTR EmptyFolder(WPARAM,LPARAM lParam)
-{
- SHFILEOPSTRUCT file_op = {
- NULL,
- FO_DELETE,
- tszRoot,
- _T(""),
- FOF_NOERRORUI |
- FOF_SILENT,
- false,
- 0,
- _T("") };
- if (lParam)
- file_op.fFlags |= FOF_NOCONFIRMATION;
- SHFileOperation(&file_op);
- return 0;
-}
-
int OnPreShutdown(WPARAM, LPARAM)
{
CancelWaitableTimer(Timer);
diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp index 634ad80dae..489baf750d 100644 --- a/plugins/PluginUpdater/src/Notifications.cpp +++ b/plugins/PluginUpdater/src/Notifications.cpp @@ -94,51 +94,44 @@ static LRESULT CALLBACK PopupDlgProcRestart(HWND hPopup, UINT uMsg, WPARAM wPara void ShowPopup(LPCTSTR ptszTitle, LPCTSTR ptszText, int Number)
{
- if(Number != POPUP_TYPE_MSG) {
+ if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1)) {
char setting[100];
mir_snprintf(setting, SIZEOF(setting), "Popups%d", Number);
- if(!db_get_b(NULL, MODNAME, setting, DEFAULT_POPUP_ENABLED))
+ if(db_get_b(NULL, MODNAME, setting, DEFAULT_POPUP_ENABLED)) {
+ POPUPDATAT pd = { 0 };
+ pd.lchContact = NULL;
+ pd.lchIcon = Skin_GetIcon("check_update");
+ if(Number == POPUP_TYPE_MSG) {
+ pd.PluginWindowProc = PopupDlgProcRestart;
+ pd.iSeconds = -1;
+ }
+ else {
+ pd.PluginWindowProc = PopupDlgProc;
+ pd.iSeconds = PopupOptions.Timeout;
+ }
+
+ lstrcpyn(pd.lptzText, ptszText, MAX_SECONDLINE);
+ lstrcpyn(pd.lptzContactName, ptszTitle, MAX_CONTACTNAME);
+
+ switch (PopupOptions.DefColors) {
+ case byCOLOR_WINDOWS:
+ pd.colorBack = GetSysColor(COLOR_BTNFACE);
+ pd.colorText = GetSysColor(COLOR_WINDOWTEXT);
+ break;
+ case byCOLOR_OWN:
+ pd.colorBack = PopupsList[Number].colorBack;
+ pd.colorText = PopupsList[Number].colorText;
+ break;
+ case byCOLOR_POPUP:
+ pd.colorBack = pd.colorText = 0;
+ break;
+ }
+ PUAddPopupT(&pd);
return;
- }
-
- if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1)) {
- POPUPDATAT pd = { 0 };
- pd.lchContact = NULL;
- pd.lchIcon = Skin_GetIcon("check_update");
- if(Number == POPUP_TYPE_MSG) {
- pd.PluginWindowProc = PopupDlgProcRestart;
- pd.iSeconds = -1;
- }
- else {
- pd.PluginWindowProc = PopupDlgProc;
- pd.iSeconds = PopupOptions.Timeout;
- }
-
- lstrcpyn(pd.lptzText, ptszText, MAX_SECONDLINE);
- lstrcpyn(pd.lptzContactName, ptszTitle, MAX_CONTACTNAME);
-
- switch (PopupOptions.DefColors) {
- case byCOLOR_WINDOWS:
- pd.colorBack = GetSysColor(COLOR_BTNFACE);
- pd.colorText = GetSysColor(COLOR_WINDOWTEXT);
- break;
- case byCOLOR_OWN:
- pd.colorBack = PopupsList[Number].colorBack;
- pd.colorText = PopupsList[Number].colorText;
- break;
- case byCOLOR_POPUP:
- pd.colorBack = pd.colorText = 0;
- break;
- }
-
- PUAddPopupT(&pd);
- } else {
- if(Number != POPUP_TYPE_MSG) {
- char setting[100];
- mir_snprintf(setting, SIZEOF(setting), "Popups%dM", Number);
- if (!db_get_b(NULL, MODNAME, setting, DEFAULT_MESSAGE_ENABLED))
- return;
}
+ }
+
+ if(Number == POPUP_TYPE_ERROR) {
int iMsgType;
switch( Number ) {
case POPUP_TYPE_MSG: iMsgType = MB_ICONSTOP; break;
diff --git a/plugins/PluginUpdater/src/Notifications.h b/plugins/PluginUpdater/src/Notifications.h index 91c57a6c67..f21581221a 100644 --- a/plugins/PluginUpdater/src/Notifications.h +++ b/plugins/PluginUpdater/src/Notifications.h @@ -43,6 +43,10 @@ typedef struct #define byCOLOR_POPUP 0x3
#define DEFAULT_COLORS byCOLOR_POPUP
+#define POPUP_TYPE_MSG 0
+#define POPUP_TYPE_ERROR 1
+#define POPUP_TYPE_INFO 2
+
// Actions on popup click
#define PCA_CLOSEPOPUP 0 // close popup
#define PCA_DONOTHING 1 // do nothing
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index cd199df741..3a51c9ac90 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -45,25 +45,25 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 1, TranslateT("days"));
ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), opts.bPeriodMeasure);
- int UpdateMode = GetUpdateMode();
- if (UpdateMode == UPDATE_MODE_STABLE) {
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL));
- CheckDlgButton(hwndDlg, IDC_STABLE, TRUE);
- }
- else if (UpdateMode == UPDATE_MODE_TRUNK) {
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL_TRUNK));
- CheckDlgButton(hwndDlg, IDC_TRUNK, TRUE);
- }
- else if (UpdateMode == UPDATE_MODE_TRUNK_SYMBOLS) {
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS));
- CheckDlgButton(hwndDlg, IDC_TRUNK_SYMBOLS, TRUE);
- }
- else {
- CheckDlgButton(hwndDlg, IDC_CUSTOM, TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
+ switch(GetUpdateMode()) {
+ case UPDATE_MODE_STABLE:
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL));
+ CheckDlgButton(hwndDlg, IDC_STABLE, TRUE);
+ break;
+ case UPDATE_MODE_TRUNK:
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL_TRUNK));
+ CheckDlgButton(hwndDlg, IDC_TRUNK, TRUE);
+ break;
+ case UPDATE_MODE_TRUNK_SYMBOLS:
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS));
+ CheckDlgButton(hwndDlg, IDC_TRUNK_SYMBOLS, TRUE);
+ break;
+ default:
+ CheckDlgButton(hwndDlg, IDC_CUSTOM, TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
- ptrT url(db_get_tsa(NULL, MODNAME, "UpdateURL"));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, (url == NULL) ? ptrT(GetDefaultUrl()) : url);
+ ptrT url(db_get_tsa(NULL, MODNAME, "UpdateURL"));
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, (url == NULL) ? ptrT(GetDefaultUrl()) : url);
}
}
return TRUE;
@@ -142,48 +142,42 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
if (hdr && hdr->code == PSN_APPLY) {
- opts.bUpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP);
- opts.bOnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY);
-
- opts.bUpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);
- opts.bSilentMode = IsDlgButtonChecked(hwndDlg, IDC_SILENTMODE);
-
+ db_set_b(NULL, MODNAME, "UpdateOnStartup", opts.bUpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP));
+ db_set_b(NULL, MODNAME, "OnlyOnceADay", opts.bOnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY));
+ db_set_b(NULL, MODNAME, "UpdateOnPeriod", opts.bUpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD));
+ db_set_b(NULL, MODNAME, "PeriodMeasure", opts.bPeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE)));
+ db_set_b(NULL, MODNAME, "SilentMode", opts.bSilentMode = IsDlgButtonChecked(hwndDlg, IDC_SILENTMODE));
TCHAR buffer[3] = {0};
Edit_GetText(GetDlgItem(hwndDlg, IDC_PERIOD), buffer, SIZEOF(buffer));
- opts.Period = _ttoi(buffer);
-
- opts.bPeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE));
-
- db_set_b(NULL, MODNAME, "UpdateOnStartup", opts.bUpdateOnStartup);
- db_set_b(NULL, MODNAME, "OnlyOnceADay", opts.bOnlyOnceADay);
- db_set_b(NULL, MODNAME, "UpdateOnPeriod", opts.bUpdateOnPeriod);
- db_set_b(NULL, MODNAME, "PeriodMeasure", opts.bPeriodMeasure);
- db_set_b(NULL, MODNAME, "SilentMode", opts.bSilentMode);
- db_set_dw(NULL, MODNAME, "Period", opts.Period);
+ db_set_dw(NULL, MODNAME, "Period", opts.Period = _ttoi(buffer));
mir_forkthread(InitTimer, (void*)1);
- if (!IsDlgButtonChecked(hwndDlg, IDC_TRUNK_SYMBOLS)) {
- opts.bForceRedownload = false;
+ if ( IsDlgButtonChecked(hwndDlg, IDC_STABLE)) {
+ db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_STABLE);
+ opts.bForceRedownload = 0;
db_unset(NULL, MODNAME, "ForceRedownload");
}
- if ( IsDlgButtonChecked(hwndDlg, IDC_STABLE))
- db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_STABLE);
- else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK))
+ else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK)) {
db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_TRUNK);
+ opts.bForceRedownload = 0;
+ db_unset(NULL, MODNAME, "ForceRedownload");
+ }
else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK_SYMBOLS)) {
- int oldMode = GetUpdateMode();
- if(oldMode != UPDATE_MODE_TRUNK_SYMBOLS) {
- opts.bForceRedownload = true;
- db_set_b(NULL, MODNAME, "ForceRedownload", 1);
+ // Only set ForceRedownload if the previous UpdateMode was different
+ // to redownload all plugin with pdb files
+ if(db_get_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_STABLE) != UPDATE_MODE_TRUNK_SYMBOLS) {
+ db_set_b(NULL, MODNAME, "ForceRedownload", opts.bForceRedownload = 1);
+ db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_TRUNK_SYMBOLS);
}
-
- db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_TRUNK_SYMBOLS);
- } else {
+ }
+ else {
char szUrl[100];
GetDlgItemTextA(hwndDlg, IDC_CUSTOMURL, szUrl, SIZEOF(szUrl));
db_set_s(NULL, MODNAME, "UpdateURL", szUrl);
db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_CUSTOM);
+ opts.bForceRedownload = 0;
+ db_unset(NULL, MODNAME, "ForceRedownload");
}
}
break;
@@ -226,17 +220,11 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) SendDlgItemMessage(hdlg, IDC_LC, CB_SETCURSEL, PopupOptions.LeftClickAction, 0);
SendDlgItemMessage(hdlg, IDC_RC, CB_SETCURSEL, PopupOptions.RightClickAction, 0);
- //Popups nitified
+ //Popups notified
for (int i = 0; i < POPUPS; i++) {
- char str[20] = {0}, str2[20] = {0};
+ char str[20] = {0};
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);
- CheckDlgButton(hdlg, (i+1024), (db_get_b(NULL, MODNAME, str2, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED: BST_UNCHECKED);
- if (IsDlgButtonChecked(hdlg, (i+40071)))
- EnableWindow(GetDlgItem(hdlg, (i+1024)), FALSE);
- else if (i > 0)
- EnableWindow(GetDlgItem(hdlg, (i+1024)), TRUE);
}
return TRUE;
@@ -256,8 +244,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) return TRUE;
}
}
-
- if (wNotifyCode == CBN_SELCHANGE) {
+ else if (wNotifyCode == CBN_SELCHANGE) {
if (idCtrl == IDC_LC)
PopupOptions.LeftClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_LC, CB_GETCURSEL, 0, 0);
else if (idCtrl == IDC_RC)
@@ -311,9 +298,8 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) LPCTSTR Title = TranslateT("Plugin Updater");
LPCTSTR Text = TranslateT("Test");
for (int i = 0; i < POPUPS; i++) {
- if ((!IsDlgButtonChecked(hdlg, (i+40071))) || (!IsWindowEnabled(GetDlgItem(hdlg, (i+40071)))))
- continue;
- ShowPopup(Title, Text, i);
+ if (IsDlgButtonChecked(hdlg, i+40071))
+ ShowPopup(Title, Text, i);
}
}
break;
@@ -383,11 +369,9 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) db_set_b(NULL, MODNAME, "RightClickAction", PopupOptions.RightClickAction);
//Notified popups
for (int i = 0; i < POPUPS; i++) {
- char str[20] = {0}, str2[20] = {0};
+ char str[20] = {0};
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);
- db_set_b(NULL, MODNAME, str2, (BYTE)(IsDlgButtonChecked(hdlg, (i+1024))));
}
return TRUE;
} //case PSN_APPLY
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index f17e9500aa..4154420bc5 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -189,7 +189,7 @@ int CompareHashes(const ServListEntry *p1, const ServListEntry *p2) return _tcsicmp(p1->m_name, p2->m_name);
}
-bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes)
+bool ParseHashes(const TCHAR *ptszUrl, ptrT &baseUrl, SERVLIST &arHashes)
{
REPLACEVARSARRAY vars[2];
vars[0].lptzKey = _T("platform");
@@ -219,41 +219,49 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes) Netlib_CloseHandle(nlc);
if (!ret) {
- if(!opts.bSilent)
- ShowPopup(TranslateT("Plugin Updater"), TranslateT("An error occurred while checking new updates."), POPUP_TYPE_ERROR);
+ Netlib_LogfT(hNetlibUser,_T("Downloading list of available updates from %s failed"),baseUrl);
+ ShowPopup(TranslateT("Plugin Updater"), TranslateT("An error occurred while checking new updates."), POPUP_TYPE_ERROR);
+ SkinPlaySound("updatefailed");
return false;
}
- if(!unzip(pFileUrl.tszDiskPath, tszTempPath, NULL,true))
+ if(!unzip(pFileUrl.tszDiskPath, tszTempPath, NULL,true)) {
+ Netlib_LogfT(hNetlibUser,_T("Unzipping list of available updates from %s failed"),baseUrl);
+ ShowPopup(TranslateT("Plugin Updater"), TranslateT("An error occurred while checking new updates."), POPUP_TYPE_ERROR);
+ SkinPlaySound("updatefailed");
return false;
+ }
DeleteFile(pFileUrl.tszDiskPath);
TCHAR tszTmpIni[MAX_PATH] = {0};
mir_sntprintf(tszTmpIni, SIZEOF(tszTmpIni), _T("%s\\hashes.txt"), tszTempPath);
FILE *fp = _tfopen(tszTmpIni, _T("r"));
- if (!fp)
+ if (!fp) {
+ Netlib_LogfT(hNetlibUser,_T("Opening %s failed"), tszTempPath);
+ ShowPopup(TranslateT("Plugin Updater"), TranslateT("An error occurred while checking new updates."), POPUP_TYPE_ERROR);
return false;
+ }
char str[200];
while(fgets(str, SIZEOF(str), fp) != NULL) {
rtrim(str);
+ Netlib_Logf(hNetlibUser,"Update: %s", str);
char *p = strchr(str, ' ');
- if (p == NULL)
- continue;
-
- *p++ = 0;
- _strlwr(p);
-
- int dwCrc32;
- char *p1 = strchr(p, ' ');
- if (p1 == NULL)
- dwCrc32 = 0;
- else {
- *p1++ = 0;
- sscanf(p1, "%08x", &dwCrc32);
+ if (p != NULL) {
+ *p++ = 0;
+ _strlwr(p);
+
+ int dwCrc32;
+ char *p1 = strchr(p, ' ');
+ if (p1 == NULL)
+ dwCrc32 = 0;
+ else {
+ *p1++ = 0;
+ sscanf(p1, "%08x", &dwCrc32);
+ }
+ arHashes.insert(new ServListEntry(str, p, dwCrc32));
}
- arHashes.insert(new ServListEntry(str, p, dwCrc32));
}
fclose(fp);
DeleteFile(tszTmpIni);
@@ -263,8 +271,6 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes) bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc)
{
- DWORD dwBytes;
-
NETLIBHTTPREQUEST nlhr = {0};
#if MIRANDA_VER < 0x0A00
nlhr.cbSize = NETLIBHTTPREQUEST_V1_SIZE;
@@ -296,21 +302,24 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc) if (pReply) {
nlc = pReply->nlc;
if ((200 == pReply->resultCode) && (pReply->dataLength > 0)) {
+ // Check CRC sum
+ if (pFileURL->CRCsum) {
+ InitCrcTable();
+ int crc = Get_CRC((unsigned char*)pReply->pData, pReply->dataLength);
+ if (crc != pFileURL->CRCsum) {
+ // crc check failed, try again
+ Netlib_LogfT(hNetlibUser,_T("crc check failed for file %s"),pFileURL->tszDiskPath);
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pReply);
+ continue;
+ }
+ }
+
HANDLE hFile = CreateFile(pFileURL->tszDiskPath, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
+ DWORD dwBytes;
// write the downloaded file directly
WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
CloseHandle(hFile);
- if (pFileURL->CRCsum) {
- InitCrcTable();
- int crc = Get_CRC((unsigned char*)pReply->pData, (long)dwBytes);
- if (crc == pFileURL->CRCsum)
- ret = true;
- else
- Netlib_LogfT(hNetlibUser,_T("crc check failed for %s"),pFileURL->tszDownloadURL);
- }
- else
- ret = true;
}
else {
// try to write it via PU stub
@@ -318,27 +327,20 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc) mir_sntprintf(tszTempFile, SIZEOF(tszTempFile), _T("%s\\pulocal.tmp"), tszTempPath);
hFile = CreateFile(tszTempFile, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
+ DWORD dwBytes;
WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
CloseHandle(hFile);
SafeMoveFile(tszTempFile, pFileURL->tszDiskPath);
- if (pFileURL->CRCsum) {
- InitCrcTable();
- int crc = Get_CRC((unsigned char*)pReply->pData, (long)dwBytes);
- if (crc == pFileURL->CRCsum)
- ret = true;
- else
- Netlib_LogfT(hNetlibUser,_T("crc check failed for %s"),pFileURL->tszDownloadURL);
- }
- else
- ret = true;
}
}
+ 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 {
+ Netlib_LogfT(hNetlibUser,_T("Downloading file %s failed, host is propably temporary down."),pFileURL->tszDownloadURL);
nlc = NULL;
}
}
@@ -353,7 +355,7 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc) /////////////////////////////////////////////////////////////////////////////////////////
-LONG PeriodToMilliseconds(const int period, BYTE periodMeasure)
+LONG PeriodToMilliseconds(const int period, BYTE &periodMeasure)
{
LONG result = period * 1000;
switch(periodMeasure) {
@@ -374,7 +376,7 @@ LONG PeriodToMilliseconds(const int period, BYTE periodMeasure) void CALLBACK TimerAPCProc(void *, DWORD, DWORD)
{
- DoCheck();
+ DoCheck(true);
}
void InitTimer(void *type)
@@ -723,6 +725,12 @@ int SafeCreateFilePath(TCHAR *pFolder) return TransactPipe(5, pFolder, NULL);
}
+void BackupFile(TCHAR *ptszSrcFileName, TCHAR *ptszBackFileName)
+{
+ SafeCreateFilePath(ptszBackFileName);
+ SafeMoveFile(ptszSrcFileName, ptszBackFileName);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
char *StrToLower(char *str)
diff --git a/plugins/PluginUpdater/src/resource.h b/plugins/PluginUpdater/src/resource.h index 283c963197..6a8dbd2979 100644 --- a/plugins/PluginUpdater/src/resource.h +++ b/plugins/PluginUpdater/src/resource.h @@ -5,7 +5,6 @@ #define IDD_UPDATE 101
#define IDD_OPT_UPDATENOTIFY 102
#define IDD_POPUP 103
-#define IDD_POPUPDUMMI 104
#define IDD_LIST 105
#define IDI_MENU 201
#define IDI_OK 202
diff --git a/plugins/PluginUpdater/src/unzipfile.cpp b/plugins/PluginUpdater/src/unzipfile.cpp index c0d0592e07..2b4ed8bf2f 100644 --- a/plugins/PluginUpdater/src/unzipfile.cpp +++ b/plugins/PluginUpdater/src/unzipfile.cpp @@ -39,12 +39,6 @@ static void PrepareFileName(TCHAR *dest, size_t destSize, const TCHAR *ptszPath, *p = '\\';
}
-void BackupFile(TCHAR *ptszSrcFileName, TCHAR *ptszBackFileName)
-{
- SafeCreateFilePath(ptszBackFileName);
- SafeMoveFile(ptszSrcFileName, ptszBackFileName);
-}
-
bool extractCurrentFile(unzFile uf, TCHAR *ptszDestPath, TCHAR *ptszBackPath, bool ch)
{
unz_file_info64 file_info;
@@ -57,6 +51,8 @@ bool extractCurrentFile(unzFile uf, TCHAR *ptszDestPath, TCHAR *ptszBackPath, bo for (char *p = strchr(filename, '/'); p; p = strchr(p+1, '/'))
*p = '\\';
+ // This is because there may be more then one file in a single zip
+ // So we need to check each file
if (ch && !db_get_b(NULL, MODNAME "Files", StrToLower(ptrA(mir_strdup(filename))), 1))
return true;
|