summaryrefslogtreecommitdiff
path: root/plugins/PluginUpdater/src
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2014-07-26 22:51:26 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2014-07-26 22:51:26 +0000
commite54b4cd7f0c6fd272437e410f17238a6c94b1547 (patch)
tree77eb81e4a1fc1acc27b95561614fff6a0405d313 /plugins/PluginUpdater/src
parentcfeeb89bc233916e4a173f005e71862bfa595b50 (diff)
PluginUpdater:
-Now the custom URL is remembered when changing the update mode in Options -Cleaned up popup Options -Fixed Restart MessageBox after silent update -code reordering git-svn-id: http://svn.miranda-ng.org/main/trunk@9958 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/PluginUpdater/src')
-rw-r--r--plugins/PluginUpdater/src/Common.h24
-rw-r--r--plugins/PluginUpdater/src/Compat/compat.cpp101
-rw-r--r--plugins/PluginUpdater/src/Compat/compat.h22
-rw-r--r--plugins/PluginUpdater/src/DlgListNew.cpp154
-rw-r--r--plugins/PluginUpdater/src/DlgUpdate.cpp266
-rw-r--r--plugins/PluginUpdater/src/Events.cpp5
-rw-r--r--plugins/PluginUpdater/src/Notifications.cpp264
-rw-r--r--plugins/PluginUpdater/src/Notifications.h16
-rw-r--r--plugins/PluginUpdater/src/Options.cpp90
-rw-r--r--plugins/PluginUpdater/src/PluginUpdater.cpp25
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp221
-rw-r--r--plugins/PluginUpdater/src/unzipfile.cpp9
12 files changed, 569 insertions, 628 deletions
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h
index c5c192d63f..a56212c9e9 100644
--- a/plugins/PluginUpdater/src/Common.h
+++ b/plugins/PluginUpdater/src/Common.h
@@ -48,7 +48,6 @@ Boston, MA 02111-1307, USA.
#include "resource.h"
#if MIRANDA_VER < 0x0A00
-#include <m_popup2.h>
#include "compat.h"
#endif
@@ -107,16 +106,24 @@ struct PlugOptions
#define DEFAULT_PERIODMEASURE 1
#if MIRANDA_VER < 0x0A00
- #define DEFAULT_UPDATEICONS 1
#define DEFAULT_ONLYONCEADAY 0
#else
- #define DEFAULT_UPDATEICONS 0
#define DEFAULT_ONLYONCEADAY 1
#endif
#define DEFAULT_UPDATE_URL "http://miranda-ng.org/distr/stable/x%platform%"
#define DEFAULT_UPDATE_URL_TRUNK "http://miranda-ng.org/distr/x%platform%"
-#define DEFAULT_UPDATE_URL_TRUNK_SYMBOLS "http://miranda-ng.now.im/pdb_x%platform%/"
+#define DEFAULT_UPDATE_URL_TRUNK_SYMBOLS "http://miranda-ng.now.im/pdb_x%platform%"
+
+#define UPDATE_MODE_CUSTOM 0
+#define UPDATE_MODE_STABLE 1
+#define UPDATE_MODE_TRUNK 2
+#define UPDATE_MODE_TRUNK_SYMBOLS 3
+
+#define POPUP_TYPE_MSG 0
+#define POPUP_TYPE_ERROR 1
+#define POPUP_TYPE_INFO 2
+#define POPUP_TYPE_PROGRESS 2
#define MAX_RETRIES 3
@@ -133,7 +140,7 @@ extern FILEINFO *pFileInfo;
extern PlugOptions opts;
extern POPUP_OPTIONS PopupOptions;
extern aPopups PopupsList[POPUPS];
-extern HANDLE Timer, hPipe;
+extern HANDLE Timer, hPipe, hNetlibUser;
void DoCheck();
@@ -202,10 +209,10 @@ int CompareHashes(const ServListEntry *p1, const ServListEntry *p2);
TCHAR* GetDefaultUrl();
bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc);
-void ShowPopup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, int Number, int ActType, bool NoMessageBox = false);
+void ShowPopup(LPCTSTR Title, LPCTSTR Text, int Number);
void __stdcall RestartMe(void*);
void __stdcall OpenPluginOptions(void*);
-BOOL AllowUpdateOnStartup();
+void CheckUpdateOnStartup();
void InitTimer(void *type);
INT_PTR EmptyFolder(WPARAM,LPARAM);
@@ -214,14 +221,13 @@ INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
int ImageList_AddIconFromIconLib(HIMAGELIST hIml, const char *name);
-bool unzip(const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath,bool ch);
+bool unzip(const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath);
void strdel(TCHAR *parBuffer, int len);
///////////////////////////////////////////////////////////////////////////////
int CalculateModuleHash(const TCHAR *tszFileName, char *dest);
-BOOL IsRunAsAdmin();
BOOL IsProcessElevated();
bool PrepareEscalation();
diff --git a/plugins/PluginUpdater/src/Compat/compat.cpp b/plugins/PluginUpdater/src/Compat/compat.cpp
new file mode 100644
index 0000000000..25fdcf27e0
--- /dev/null
+++ b/plugins/PluginUpdater/src/Compat/compat.cpp
@@ -0,0 +1,101 @@
+/*
+Copyright (C) 2010 Mataes
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+
+ This file contains some compatibility functions for Miranda IM
+*/
+
+static char szHexTable[] = "0123456789abcdef";
+
+char *bin2hex(const void *pData, size_t len, char *dest)
+{
+ const BYTE *p = (const BYTE*)pData;
+ char *d = dest;
+
+ for (size_t i=0; i < len; i++, p++) {
+ *d++ = szHexTable[*p >> 4];
+ *d++ = szHexTable[*p & 0x0F];
+ }
+ *d = 0;
+
+ return dest;
+}
+
+char *rtrim(char *str)
+{
+ if (str == NULL)
+ return NULL;
+
+ char *p = strchr(str, 0);
+ while (--p >= str) {
+ switch (*p) {
+ case ' ': case '\t': case '\n': case '\r':
+ *p = 0; break;
+ default:
+ return str;
+ }
+ }
+ return str;
+}
+
+void CreatePathToFileT(TCHAR *tszFilePath)
+{
+ TCHAR *pszLastBackslash = _tcsrchr(tszFilePath, '\\');
+ if (pszLastBackslash != NULL){
+ *pszLastBackslash = '\0';
+ CreateDirectoryTreeT(tszFilePath);
+ *pszLastBackslash = '\\';
+ }
+}
+
+int wildcmpit(const WCHAR *name, const WCHAR *mask)
+{
+ if (name == NULL || mask == NULL)
+ return false;
+
+ const WCHAR* last = NULL;
+ for (;; mask++, name++) {
+ if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) break;
+ if (*name == '\0') return ((BOOL)!*mask);
+ }
+ if (*mask != '*') return FALSE;
+ for (;; mask++, name++) {
+ while(*mask == '*') {
+ last = mask++;
+ if (*mask == '\0') return ((BOOL)!*mask); /* true */
+ }
+ if (*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */
+ if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) name -= (size_t)(mask - last) - 1, mask = last;
+ }
+}
+
+
+void __stdcall RestartMe(void*)
+{
+ TCHAR mirandaPath[MAX_PATH], cmdLine[MAX_PATH];
+ GetModuleFileName(NULL, mirandaPath, SIZEOF(mirandaPath));
+
+ TCHAR *profilename = Utils_ReplaceVarsT(_T("%miranda_profilename%"));
+ mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("\"%s\" /restart:%d /profile=%s"), mirandaPath, GetCurrentProcessId(), profilename);
+ mir_free(profilename);
+
+ CallService("CloseAction", 0, 0);
+
+ PROCESS_INFORMATION pi;
+ STARTUPINFO si = { sizeof(si) };
+ CreateProcess(mirandaPath, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
+}
diff --git a/plugins/PluginUpdater/src/Compat/compat.h b/plugins/PluginUpdater/src/Compat/compat.h
index 6afc901e17..26e807f478 100644
--- a/plugins/PluginUpdater/src/Compat/compat.h
+++ b/plugins/PluginUpdater/src/Compat/compat.h
@@ -76,9 +76,10 @@ __forceinline INT_PTR Options_AddPage(WPARAM wParam, OPTIONSDIALOGPAGE *odp)
return CallService("Opt/AddPage", wParam, (LPARAM)odp);
}
-char* bin2hex(const void *pData, size_t len, char *dest);
+char *bin2hex(const void *pData, size_t len, char *dest);
char *rtrim(char *str);
int CreatePathToFileT(const TCHAR *ptszPath);
+int wildcmpit(const WCHAR *name, const WCHAR *mask);
#define NEWTSTR_ALLOCA(A) (A == NULL)?NULL:_tcscpy((TCHAR*)alloca((_tcslen(A)+1) *sizeof(TCHAR)), A)
@@ -124,23 +125,4 @@ int __forceinline PUDeletePopup(HWND hWndPopup)
#define _qtoupper(_c) (((_c) >= 'a' && (_c) <= 'z')?((_c)-('a'+'A')):(_c))
-int __forceinline wildcmpit(const WCHAR *name, const WCHAR *mask)
-{
- if (name == NULL || mask == NULL)
- return false;
- const WCHAR* last = NULL;
- for (;; mask++, name++) {
- if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) break;
- if (*name == '\0') return ((BOOL)!*mask);
- }
- if (*mask != '*') return FALSE;
- for (;; mask++, name++) {
- while(*mask == '*') {
- last = mask++;
- if (*mask == '\0') return ((BOOL)!*mask); /* true */
- }
- if (*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */
- if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) name -= (size_t)(mask - last) - 1, mask = last;
- }
-}
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp
index 45cd3ddb64..5f181cbce4 100644
--- a/plugins/PluginUpdater/src/DlgListNew.cpp
+++ b/plugins/PluginUpdater/src/DlgListNew.cpp
@@ -51,7 +51,7 @@ static void ApplyDownloads(void *param)
AutoHandle pipe(hPipe);
HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES);
OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
- TCHAR tszBuff[2048], tszFileTemp[MAX_PATH], tszFileBack[MAX_PATH];
+ TCHAR tszFileTemp[MAX_PATH], tszFileBack[MAX_PATH];
mir_sntprintf(tszFileBack, SIZEOF(tszFileBack), _T("%s\\Backups"), tszRoot);
SafeCreateDirectory(tszFileBack);
@@ -59,68 +59,35 @@ static void ApplyDownloads(void *param)
mir_sntprintf(tszFileTemp, SIZEOF(tszFileTemp), _T("%s\\Temp"), tszRoot);
SafeCreateDirectory(tszFileTemp);
+ TCHAR *tszMirandaPath = Utils_ReplaceVarsT(_T("%miranda_path%"));
+
HANDLE nlc = NULL;
for (int i=0; i < todo.getCount(); ++i) {
ListView_EnsureVisible(hwndList, i, FALSE);
- if (!todo[i].bEnabled) {
- ListView_SetItemText(hwndList, i, 2, TranslateT("Skipped."));
- continue;
- }
-
- // download update
- ListView_SetItemText(hwndList, i, 2, TranslateT("Downloading..."));
-
- FILEURL *pFileUrl = &todo[i].File;
- if (!DownloadFile(pFileUrl, nlc)) {
- ListView_SetItemText(hwndList, i, 2, TranslateT("Failed!"));
+ if (todo[i].bEnabled) {
+ // download update
+ ListView_SetItemText(hwndList, i, 2, TranslateT("Downloading..."));
+
+ if (DownloadFile(&todo[i].File, nlc)) {
+ ListView_SetItemText(hwndList, i, 2, TranslateT("Succeeded."));
+ if (unzip(todo[i].File.tszDiskPath, tszMirandaPath, tszFileBack))
+ SafeDeleteFile(todo[i].File.tszDiskPath); // remove .zip after successful update
+ }
+ else
+ ListView_SetItemText(hwndList, i, 2, TranslateT("Failed!"));
}
else
- ListView_SetItemText(hwndList, i, 2, TranslateT("Succeeded."));
+ ListView_SetItemText(hwndList, i, 2, TranslateT("Skipped."));
}
Netlib_CloseHandle(nlc);
- if (todo.getCount() > 0) {
- ShowPopup(0, LPGENT("Plugin Updater"), TranslateT("Download complete"), 2, 0);
-
- TCHAR *tszMirandaPath = Utils_ReplaceVarsT(_T("%miranda_path%"));
-
- for (int i = 0; i < todo.getCount(); i++) {
- if (!todo[i].bEnabled)
- continue;
-
- TCHAR tszBackFile[MAX_PATH];
- FILEINFO& p = todo[i];
- if (p.bDeleteOnly) { // we need only to backup the old file
- TCHAR *ptszRelPath = p.tszNewName + _tcslen(tszMirandaPath) + 1;
- mir_sntprintf(tszBackFile, SIZEOF(tszBackFile), _T("%s\\%s"), tszFileBack, ptszRelPath);
- BackupFile(p.tszNewName, tszBackFile);
- continue;
- }
-
- // if file name differs, we also need to backup the old file here
- // otherwise it would be replaced by unzip
- if ( _tcsicmp(p.tszOldName, p.tszNewName)) {
- TCHAR tszSrcPath[MAX_PATH];
- mir_sntprintf(tszSrcPath, SIZEOF(tszSrcPath), _T("%s\\%s"), tszMirandaPath, p.tszOldName);
- mir_sntprintf(tszBackFile, SIZEOF(tszBackFile), _T("%s\\%s"), tszFileBack, p.tszOldName);
- BackupFile(tszSrcPath, tszBackFile);
- }
-
- if ( unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack,false))
- SafeDeleteFile(p.File.tszDiskPath); // remove .zip after successful update
- }
- }
+ ShowPopup(TranslateT("Plugin Updater"), TranslateT("Download complete"), POPUP_TYPE_INFO);
- PopupDataText temp;
- temp.Title = TranslateT("Plugin Updater");
- temp.Text = tszBuff;
- lstrcpyn(tszBuff, TranslateT("Download complete. Do you want to go to plugins option page?"), SIZEOF(tszBuff));
- int rc = MessageBox(hDlg, temp.Text, temp.Title, MB_YESNO | MB_ICONQUESTION);
+ int rc = MessageBox(hDlg, TranslateT("Download complete. Do you want to go to plugins option page?"), TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION);
if (rc == IDYES)
CallFunctionAsync(OpenPluginOptions, 0);
PostMessage(hDlg, WM_CLOSE, 0, 0);
- return;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -174,7 +141,6 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
switch (message) {
case WM_INITDIALOG:
- hwndDialog = hDlg;
TranslateDialogDefault( hDlg );
oldWndProc = (WNDPROC)SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)PluginListWndProc);
@@ -275,10 +241,7 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
ListView_SetItem(hwndList, &lvi);
}
}
- todo[i].bEnabled = false;
}
- HWND hwOk = GetDlgItem(hDlg, IDOK);
- EnableWindow(hwOk, false);
}
// do this after filling list - enables 'ITEMCHANGED' below
@@ -292,16 +255,16 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
case LVN_ITEMCHANGED:
if (GetWindowLongPtr(hDlg, GWLP_USERDATA)) {
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
-
- LVITEM lvI = {0};
- lvI.iItem = nmlv->iItem;
- lvI.iSubItem = 0;
- lvI.mask = LVIF_PARAM;
- ListView_GetItem(hwndList, &lvI);
-
- OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) {
- todo[lvI.iItem].bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem);
+ LVITEM lvI = {0};
+ lvI.iItem = nmlv->iItem;
+ lvI.iSubItem = 0;
+ lvI.mask = LVIF_PARAM;
+ ListView_GetItem(hwndList, &lvI);
+
+ OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
+ FILEINFO *p = (FILEINFO*)lvI.lParam;
+ p->bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem);
bool enableOk = false;
for (int i=0; i < todo.getCount(); ++i) {
@@ -310,8 +273,7 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
break;
}
}
- HWND hwOk = GetDlgItem(hDlg, IDOK);
- EnableWindow(hwOk, enableOk ? TRUE : FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDOK), enableOk ? TRUE : FALSE);
}
}
break;
@@ -381,7 +343,7 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
static void __stdcall LaunchListDialog(void *param)
{
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_LIST), GetDesktopWindow(), DlgList, (LPARAM)param);
+ hwndDialog = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_LIST), GetDesktopWindow(), DlgList, (LPARAM)param);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -412,30 +374,32 @@ static void GetList(void *)
TCHAR tszPath[MAX_PATH];
mir_sntprintf(tszPath, SIZEOF(tszPath), _T("%s\\%s"), dirname, hash.m_name);
- if (GetFileAttributes(tszPath) != DWORD(-1))
- continue;
-
- FILEINFO *FileInfo = new FILEINFO;
- FileInfo->bDeleteOnly = FALSE;
- _tcscpy(FileInfo->tszOldName, hash.m_name); // copy the relative old name
- _tcscpy(FileInfo->tszNewName, hash.m_name);
-
- TCHAR tszFileName[MAX_PATH];
- _tcscpy(tszFileName, _tcsrchr(tszPath, L'\\') + 1);
- TCHAR *tp = _tcschr(tszFileName, L'.'); *tp = 0;
-
- TCHAR tszRelFileName[MAX_PATH];
- _tcscpy(tszRelFileName, hash.m_name);
- tp = _tcsrchr(tszRelFileName, L'.'); if (tp) *tp = 0;
- tp = _tcschr(tszRelFileName, L'\\'); if (tp) tp++; else tp = tszRelFileName;
- _tcslwr(tp);
-
- mir_sntprintf(FileInfo->File.tszDiskPath, SIZEOF(FileInfo->File.tszDiskPath), _T("%s\\Temp\\%s.zip"), tszRoot, tszFileName);
- mir_sntprintf(FileInfo->File.tszDownloadURL, SIZEOF(FileInfo->File.tszDownloadURL), _T("%s/%s.zip"), baseUrl, tszRelFileName);
- for (tp = _tcschr(FileInfo->File.tszDownloadURL, '\\'); tp != 0; tp = _tcschr(tp, '\\'))
- *tp++ = '/';
- FileInfo->File.CRCsum = hash.m_crc;
- UpdateFiles->insert(FileInfo);
+ if (GetFileAttributes(tszPath) == INVALID_FILE_ATTRIBUTES) {
+ FILEINFO *FileInfo = new FILEINFO;
+ FileInfo->bDeleteOnly = FALSE;
+ // copy the relative old name
+ _tcsncpy(FileInfo->tszOldName, hash.m_name, SIZEOF(FileInfo->tszOldName));
+ _tcsncpy(FileInfo->tszNewName, hash.m_name, SIZEOF(FileInfo->tszNewName));
+
+ TCHAR tszFileName[MAX_PATH];
+ _tcsncpy(tszFileName, _tcsrchr(tszPath, L'\\') + 1, SIZEOF(tszFileName));
+ TCHAR *tp = _tcschr(tszFileName, L'.'); *tp = 0;
+
+ TCHAR tszRelFileName[MAX_PATH];
+ _tcsncpy(tszRelFileName, hash.m_name, MAX_PATH);
+ tp = _tcsrchr(tszRelFileName, L'.'); if (tp) *tp = 0;
+ tp = _tcschr(tszRelFileName, L'\\'); if (tp) tp++; else tp = tszRelFileName;
+ _tcslwr(tp);
+
+ mir_sntprintf(FileInfo->File.tszDiskPath, SIZEOF(FileInfo->File.tszDiskPath), _T("%s\\Temp\\%s.zip"), tszRoot, tszFileName);
+ mir_sntprintf(FileInfo->File.tszDownloadURL, SIZEOF(FileInfo->File.tszDownloadURL), _T("%s/%s.zip"), baseUrl, tszRelFileName);
+ for (tp = _tcschr(FileInfo->File.tszDownloadURL, '\\'); tp != 0; tp = _tcschr(tp, '\\'))
+ *tp++ = '/';
+ FileInfo->File.CRCsum = hash.m_crc;
+ // Deselect all plugins by default
+ FileInfo->bEnabled = false;
+ UpdateFiles->insert(FileInfo);
+ }
}
mir_free(dirname);
@@ -443,7 +407,7 @@ static void GetList(void *)
// Show dialog
if (UpdateFiles->getCount() == 0) {
if (!opts.bSilent)
- ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("List is empty."), 2, 0);
+ ShowPopup(TranslateT("Plugin Updater"), TranslateT("List is empty."), POPUP_TYPE_INFO);
delete UpdateFiles;
}
else CallFunctionAsync(LaunchListDialog, UpdateFiles);
@@ -451,16 +415,16 @@ static void GetList(void *)
hListThread = NULL;
}
-void DoGetList(int iFlag)
+void DoGetList()
{
if (hListThread)
- ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("List loading already started!"), 2, 0);
+ ShowPopup(TranslateT("Plugin Updater"), TranslateT("List loading already started!"), POPUP_TYPE_INFO);
else if (hwndDialog) {
ShowWindow(hwndDialog, SW_SHOW);
SetForegroundWindow(hwndDialog);
SetFocus(hwndDialog);
}
- else if (iFlag)
+ else
hListThread = mir_forkthread(GetList, 0);
}
@@ -473,7 +437,7 @@ void UninitListNew()
INT_PTR ShowListCommand(WPARAM,LPARAM)
{
opts.bSilent = false;
- DoGetList(true);
+ DoGetList();
return 0;
}
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index 56de9eef47..879f9c0343 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -97,12 +97,11 @@ static void ApplyUpdates(void *param)
// 3) Unpack all zips
TCHAR *tszMirandaPath = Utils_ReplaceVarsT(_T("%miranda_path%"));
for (int i = 0; i < todo.getCount(); i++) {
- if (todo[i].bEnabled) {
- TCHAR tszBackFile[MAX_PATH];
- FILEINFO& p = todo[i];
+ FILEINFO& p = todo[i];
+ if (p.bEnabled) {
if (p.bDeleteOnly) {
// we need only to backup the old file
- TCHAR *ptszRelPath = p.tszNewName + _tcslen(tszMirandaPath) + 1;
+ TCHAR *ptszRelPath = p.tszNewName + _tcslen(tszMirandaPath) + 1, tszBackFile[MAX_PATH];
mir_sntprintf(tszBackFile, SIZEOF(tszBackFile), _T("%s\\%s"), tszFileBack, ptszRelPath);
BackupFile(p.tszNewName, tszBackFile);
}
@@ -110,13 +109,13 @@ static void ApplyUpdates(void *param)
// if file name differs, we also need to backup the old file here
// otherwise it would be replaced by unzip
if ( _tcsicmp(p.tszOldName, p.tszNewName)) {
- TCHAR tszSrcPath[MAX_PATH];
+ TCHAR tszSrcPath[MAX_PATH], tszBackFile[MAX_PATH];
mir_sntprintf(tszSrcPath, SIZEOF(tszSrcPath), _T("%s\\%s"), tszMirandaPath, p.tszOldName);
mir_sntprintf(tszBackFile, SIZEOF(tszBackFile), _T("%s\\%s"), tszFileBack, p.tszOldName);
BackupFile(tszSrcPath, tszBackFile);
}
- if ( unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack,true))
+ if ( unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack))
SafeDeleteFile(p.File.tszDiskPath); // remove .zip after successful update
}
}
@@ -139,7 +138,11 @@ static void ApplyUpdates(void *param)
int rc = MessageBox(hDlg, TranslateT("Update complete. Press Yes to restart Miranda now or No to postpone a restart until the exit."), TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION);
PostMessage(hDlg, WM_CLOSE, 0, 0);
if (rc == IDYES)
+#if MIRANDA_VER >= 0x0A00
+ CallServiceSync(MS_SYSTEM_RESTART, db_get_b(NULL,MODNAME,"RestartCurrentProfile",1) ? 1 : 0, 0);
+#else
CallFunctionAsync(RestartMe, 0);
+#endif
}
static void ResizeVert(HWND hDlg, int yy)
@@ -180,9 +183,6 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM
DeleteFile(szPath);
}
}
- RECT r;
- GetClientRect(hwndList, &r);
-
LVCOLUMN lvc = {0};
// Initialize the LVCOLUMN structure.
// The mask specifies that the format, width, text, and
@@ -203,30 +203,55 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM
//enumerate plugins, fill in list
//bool one_enabled = false;
ListView_DeleteAllItems(hwndList);
+ ///
+ LVGROUP lvg;
+ lvg.cbSize = sizeof(LVGROUP);
+ lvg.mask = LVGF_HEADER | LVGF_GROUPID;
+
+ lvg.pszHeader = TranslateT("Plugins");
+ lvg.iGroupId = 1;
+ ListView_InsertGroup(hwndList, 0, &lvg);
+
+ lvg.pszHeader = TranslateT("Icons");
+ lvg.iGroupId = 2;
+ ListView_InsertGroup(hwndList, 0, &lvg);
+
+ lvg.pszHeader = TranslateT("Languages");
+ lvg.iGroupId = 3;
+ ListView_InsertGroup(hwndList, 0, &lvg);
+
+ lvg.pszHeader = TranslateT("Core components");
+ lvg.iGroupId = 4;
+ ListView_InsertGroup(hwndList, 0, &lvg);
- // Some code to create the list-view control.
- // Initialize LVITEM members that are common to all items.
- LVITEM lvI = {0};
- lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_NORECOMPUTE;// | LVIF_IMAGE;
+ lvg.pszHeader = TranslateT("Core");
+ lvg.iGroupId = 5;
+ ListView_InsertGroup(hwndList, 0, &lvg);
+
+ ListView_EnableGroupView(hwndList, TRUE);
bool enableOk = false;
OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)lParam;
for (int i = 0; i < todo.getCount(); ++i) {
- lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_IMAGE;
+ LVITEM lvI = {0};
+ lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_GROUPID | LVIF_NORECOMPUTE;
+ lvI.iGroupId = (_tcschr(todo[i].tszOldName, L'\\') == NULL) ? 5 :
+ (_tcsstr(todo[i].tszOldName, _T("Plugins")) != NULL) ? 1 :
+ ((_tcsstr(todo[i].tszOldName, _T("Icons")) != NULL) ? 2 :
+ ((_tcsstr(todo[i].tszOldName, _T("Languages")) != NULL) ? 3 :
+ ((_tcsstr(todo[i].tszOldName, _T("Core")) != NULL) ? 4 : 5)));
lvI.iSubItem = 0;
lvI.lParam = (LPARAM)&todo[i];
lvI.pszText = todo[i].tszOldName;
lvI.iItem = i;
ListView_InsertItem(hwndList, &lvI);
- // remember whether the user has decided not to update this component with this particular new version
- todo[i].bEnabled = db_get_b(NULL, MODNAME "Files", StrToLower(_T2A(todo[i].tszOldName)), true);
ListView_SetCheckState(hwndList, lvI.iItem, todo[i].bEnabled);
if (todo[i].bEnabled)
enableOk = true;
}
- HWND hwOk = GetDlgItem(hDlg, IDOK);
- EnableWindow(hwOk, enableOk);
+ if(enableOk)
+ EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
}
bShowDetails = false;
@@ -243,27 +268,26 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM
case LVN_ITEMCHANGED:
if (GetWindowLongPtr(hDlg, GWLP_USERDATA)) {
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
-
- LVITEM lvI = {0};
- lvI.iItem = nmlv->iItem;
- lvI.iSubItem = 0;
- lvI.mask = LVIF_PARAM;
- ListView_GetItem(hwndList, &lvI);
-
- OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) {
- todo[lvI.iItem].bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem);
- db_set_b(NULL, MODNAME "Files", StrToLower(_T2A(todo[lvI.iItem].tszOldName)), todo[lvI.iItem].bEnabled);
+ LVITEM lvI = {0};
+ lvI.iItem = nmlv->iItem;
+ lvI.iSubItem = 0;
+ lvI.mask = LVIF_PARAM;
+ ListView_GetItem(hwndList, &lvI);
+
+ FILEINFO *p = (FILEINFO*)lvI.lParam;
+ db_set_b(NULL, MODNAME "Files", StrToLower(_T2A(p->tszOldName)), p->bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem));
+ // Toggle the Download button
bool enableOk = false;
+ OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
for (int i=0; i < todo.getCount(); ++i) {
if (todo[i].bEnabled) {
enableOk = true;
break;
}
}
- HWND hwOk = GetDlgItem(hDlg, IDOK);
- EnableWindow(hwOk, enableOk ? TRUE : FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDOK), enableOk ? TRUE : FALSE);
}
}
break;
@@ -319,9 +343,9 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM
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
+#if MIRANDA_VER >= 0x0A00
+ db_set_dw(NULL, MODNAME, "LastUpdate", time(NULL));
+#endif
mir_forkthread(InitTimer, (void*)0);
break;
}
@@ -329,27 +353,6 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM
return FALSE;
}
-static LRESULT CALLBACK PopupDlgProcRestart(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch (uMsg) {
- case WM_COMMAND:
- case WM_CONTEXTMENU:
- PUDeletePopup(hDlg);
-
- if (uMsg == WM_COMMAND) {
- TCHAR tszText[200];
- mir_sntprintf(tszText, SIZEOF(tszText), _T("%s\n\n%s"), TranslateT("You need to restart your Miranda to apply installed updates."), TranslateT("Would you like to restart it now?"));
-
- if (MessageBox(hDlg, tszText, TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION) == IDYES)
- CallFunctionAsync(RestartMe, 0);
- }
-
- return TRUE;
- }
-
- return DefWindowProc(hDlg, uMsg, wParam, lParam);
-}
-
static void DlgUpdateSilent(void *lParam)
{
OBJLIST<FILEINFO> &UpdateFiles = *(OBJLIST<FILEINFO> *)lParam;
@@ -378,7 +381,7 @@ static void DlgUpdateSilent(void *lParam)
// Count all updates that have been enabled
int count = 0;
for (int i = 0; i < UpdateFiles.getCount(); i++) {
- if (db_get_b(NULL, MODNAME "Files", StrToLower(_T2A(UpdateFiles[i].tszOldName)), 1) && !UpdateFiles[i].bDeleteOnly) {
+ if (UpdateFiles[i].bEnabled && !UpdateFiles[i].bDeleteOnly) {
// download update
FILEURL *pFileUrl = &UpdateFiles[i].File;
if (!DownloadFile(pFileUrl, nlc)) {
@@ -394,6 +397,7 @@ static void DlgUpdateSilent(void *lParam)
}
Netlib_CloseHandle(nlc);
+ // All available updates have been disabled
if (count == 0) {
delete &UpdateFiles;
return;
@@ -402,11 +406,11 @@ static void DlgUpdateSilent(void *lParam)
// 3) Unpack all zips
TCHAR *tszMirandaPath = Utils_ReplaceVarsT(_T("%miranda_path%"));
for (int i = 0; i < UpdateFiles.getCount(); i++) {
- if (db_get_b(NULL, MODNAME "Files", StrToLower(_T2A(UpdateFiles[i].tszOldName)), 1)) {
- TCHAR tszBackFile[MAX_PATH];
- FILEINFO& p = UpdateFiles[i];
- if (p.bDeleteOnly) { // we need only to backup the old file
- TCHAR *ptszRelPath = p.tszNewName + _tcslen(tszMirandaPath) + 1;
+ FILEINFO& p = UpdateFiles[i];
+ if (p.bEnabled) {
+ if (p.bDeleteOnly) {
+ // we need only to backup the old file
+ TCHAR *ptszRelPath = p.tszNewName + _tcslen(tszMirandaPath) + 1, tszBackFile[MAX_PATH];
mir_sntprintf(tszBackFile, SIZEOF(tszBackFile), _T("%s\\%s"), tszFileBack, ptszRelPath);
BackupFile(p.tszNewName, tszBackFile);
}
@@ -414,14 +418,15 @@ static void DlgUpdateSilent(void *lParam)
// if file name differs, we also need to backup the old file here
// otherwise it would be replaced by unzip
if (_tcsicmp(p.tszOldName, p.tszNewName)) {
- TCHAR tszSrcPath[MAX_PATH];
+ TCHAR tszSrcPath[MAX_PATH], tszBackFile[MAX_PATH];
mir_sntprintf(tszSrcPath, SIZEOF(tszSrcPath), _T("%s\\%s"), tszMirandaPath, p.tszOldName);
mir_sntprintf(tszBackFile, SIZEOF(tszBackFile), _T("%s\\%s"), tszFileBack, p.tszOldName);
BackupFile(tszSrcPath, tszBackFile);
}
-
- if (unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack, true))
- SafeDeleteFile(p.File.tszDiskPath); // remove .zip after successful update
+
+ // remove .zip after successful update
+ if (unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack))
+ SafeDeleteFile(p.File.tszDiskPath);
}
}
}
@@ -446,18 +451,7 @@ static void DlgUpdateSilent(void *lParam)
mir_sntprintf(tszTitle, SIZEOF(tszTitle), TranslateT("%d component(s) was updated"), count);
if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1)) {
- POPUPDATAT_V2 pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.lchContact = NULL;
- pd.lchIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
- pd.colorBack = pd.colorText = 0;
- pd.iSeconds = -1;
- pd.PluginWindowProc = PopupDlgProcRestart;
-
- lstrcpyn(pd.lptzText, TranslateT("You need to restart your Miranda to apply installed updates."), MAX_SECONDLINE);
- lstrcpyn(pd.lptzContactName, tszTitle, MAX_CONTACTNAME);
-
- CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, APF_NEWDATA);
+ ShowPopup(tszTitle,TranslateT("You need to restart your Miranda to apply installed updates."),POPUP_TYPE_MSG);
} else {
bool notified = false;
@@ -479,7 +473,11 @@ static void DlgUpdateSilent(void *lParam)
mir_sntprintf(tszText, SIZEOF(tszText), _T("%s\n\n%s"), TranslateT("You need to restart your Miranda to apply installed updates."), TranslateT("Would you like to restart it now?"));
if (MessageBox(NULL, tszText, tszTitle, MB_ICONINFORMATION | MB_YESNO) == IDYES)
+#if MIRANDA_VER >= 0x0A00
+ CallServiceSync(MS_SYSTEM_RESTART, db_get_b(NULL,MODNAME,"RestartCurrentProfile",1) ? 1 : 0, 0);
+#else
CallFunctionAsync(RestartMe, 0);
+#endif
}
}
}
@@ -518,12 +516,12 @@ static renameTable[] =
{ _T("rss.dll"), _T("Plugins\\newsaggregator.dll") },
{ _T("dbx_3x.dll"), _T("Plugins\\dbx_mmap.dll") },
- #if MIRANDA_VER >= 0x0A00
- { _T("dbx_mmap_sa.dll"), _T("Plugins\\dbx_mmap.dll") },
- { _T("dbx_tree.dll"), _T("Plugins\\dbx_mmap.dll") },
- { _T("rc4.dll"), NULL },
- { _T("athena.dll"), NULL },
- #endif
+#if MIRANDA_VER >= 0x0A00
+ { _T("dbx_mmap_sa.dll"), _T("Plugins\\dbx_mmap.dll") },
+ { _T("dbx_tree.dll"), _T("Plugins\\dbx_mmap.dll") },
+ { _T("rc4.dll"), NULL },
+ { _T("athena.dll"), NULL },
+#endif
{ _T("proto_newsaggr.dll"), _T("Icons\\proto_newsaggregator.dll") },
{ _T("clienticons_*.dll"), _T("Icons\\fp_icons.dll") },
@@ -543,19 +541,18 @@ static renameTable[] =
static bool CheckFileRename(const TCHAR *ptszOldName, TCHAR *pNewName)
{
for (int i = 0; i < SIZEOF(renameTable); i++) {
- if (!wildcmpit(ptszOldName, renameTable[i].oldName))
- continue;
-
- TCHAR *ptszDest = renameTable[i].newName;
- if (ptszDest == NULL)
- *pNewName = 0;
- else {
- _tcsncpy_s(pNewName, MAX_PATH, ptszDest, _TRUNCATE);
- size_t cbLen = _tcslen(ptszDest) - 1;
- if (pNewName[cbLen] == '*')
- _tcsncpy_s(pNewName + cbLen, MAX_PATH - cbLen, ptszOldName, _TRUNCATE);
+ if (wildcmpit(ptszOldName, renameTable[i].oldName)) {
+ TCHAR *ptszDest = renameTable[i].newName;
+ if (ptszDest == NULL)
+ *pNewName = 0;
+ else {
+ _tcsncpy_s(pNewName, MAX_PATH, ptszDest, _TRUNCATE);
+ size_t cbLen = _tcslen(ptszDest) - 1;
+ if (pNewName[cbLen] == '*')
+ _tcsncpy_s(pNewName + cbLen, MAX_PATH - cbLen, ptszOldName, _TRUNCATE);
+ }
+ return true;
}
- return true;
}
return false;
@@ -572,11 +569,15 @@ static bool isValidExtension(const TCHAR *ptszFileName)
static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const TCHAR *tszBaseUrl, SERVLIST& hashes, OBJLIST<FILEINFO> *UpdateFiles)
{
- int count = 0;
-
// skip updater's own folder
if (!_tcsicmp(tszFolder, tszRoot))
- return count;
+ return 0;
+
+ // skip profile folder
+ TCHAR tszProfilePath[MAX_PATH];
+ CallService(MS_DB_GETPROFILEPATHT, SIZEOF(tszProfilePath), (LPARAM)tszProfilePath);
+ if (!_tcsicmp(tszFolder, tszProfilePath))
+ return 0;
TCHAR tszBuf[MAX_PATH];
mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\*"), tszFolder);
@@ -584,18 +585,17 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile(tszBuf, &ffd);
if (hFind == INVALID_HANDLE_VALUE)
- return count;
+ return 0;
+
+ Netlib_LogfT(hNetlibUser,_T("Scanning folder %s"), tszFolder);
+ int count = 0;
do {
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ // Scan recursively all subfolders
if (_tcscmp(ffd.cFileName, _T(".")) && _tcscmp(ffd.cFileName, _T(".."))) {
- // we need to skip profile folder
- TCHAR tszProfilePath[MAX_PATH];
- CallService(MS_DB_GETPROFILEPATHT, SIZEOF(tszProfilePath), (LPARAM)tszProfilePath);
-
mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\%s"), tszFolder, ffd.cFileName);
- if (0 != _tcsicmp(tszBuf, tszProfilePath))
- count += ScanFolder(tszBuf, cbBaseLen, level+1, tszBaseUrl, hashes, UpdateFiles);
+ count += ScanFolder(tszBuf, cbBaseLen, level+1, tszBaseUrl, hashes, UpdateFiles);
}
}
else if (isValidExtension(ffd.cFileName)) {
@@ -622,6 +622,7 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
if (p[-1] != 'w' && p[-1] != 'W')
continue;
+ // remove trailing w or W and try again
int iPos = int(p - tszNewName)-1;
strdel(p-1, 1);
if ((item = hashes.find((ServListEntry*)&pName)) == NULL)
@@ -651,19 +652,22 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
ptszUrl = _T("");
// Compare versions
- if (bHasNewVersion) { // Yeah, we've got new version.
+ if (bHasNewVersion) {
+ // Yeah, we've got new version.
+ Netlib_LogfT(hNetlibUser,_T("Found update for %s"), tszBuf);
FILEINFO *FileInfo = new FILEINFO;
- _tcscpy(FileInfo->tszOldName, tszBuf+cbBaseLen); // copy the relative old name
- if (tszNewName[0] == 0) {
- FileInfo->bDeleteOnly = TRUE;
- _tcscpy(FileInfo->tszNewName, tszBuf); // save the full old name for deletion
+ // copy the relative old name
+ _tcsncpy(FileInfo->tszOldName, tszBuf+cbBaseLen, SIZEOF(FileInfo->tszOldName));
+ FileInfo->bDeleteOnly = (tszNewName[0] == 0);
+ if (FileInfo->bDeleteOnly) {
+ // save the full old name for deletion
+ _tcsncpy(FileInfo->tszNewName, tszBuf, SIZEOF(FileInfo->tszNewName));
}
else {
- FileInfo->bDeleteOnly = FALSE;
_tcsncpy(FileInfo->tszNewName, ptszUrl, SIZEOF(FileInfo->tszNewName));
}
- _tcscpy(tszBuf, ptszUrl);
+ _tcsncpy(tszBuf, ptszUrl, SIZEOF(tszBuf));
TCHAR *p = _tcsrchr(tszBuf, '.');
if (p) *p = 0;
p = _tcsrchr(tszBuf, '\\');
@@ -675,10 +679,13 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
for (p = _tcschr(FileInfo->File.tszDownloadURL, '\\'); p != 0; p = _tcschr(p, '\\'))
*p++ = '/';
+ // remember whether the user has decided not to update this component with this particular new version
+ FileInfo->bEnabled = db_get_b(NULL, MODNAME "Files", StrToLower(_T2A(FileInfo->tszOldName)), 1);
+
FileInfo->File.CRCsum = MyCRC;
UpdateFiles->insert(FileInfo);
-
- if (!opts.bSilent || db_get_b(NULL, MODNAME "Files", StrToLower(_T2A(FileInfo->tszNewName)), true))
+
+ if (!opts.bSilent || FileInfo->bEnabled)
count++;
} // end compare versions
}
@@ -691,8 +698,7 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
static void CheckUpdates(void *)
{
- char szKey[64] = {0};
-
+ Netlib_LogfT(hNetlibUser,_T("Checking for updates"));
TCHAR tszTempPath[MAX_PATH];
DWORD dwLen = GetTempPath(SIZEOF(tszTempPath), tszTempPath);
if (tszTempPath[dwLen-1] == '\\')
@@ -710,7 +716,7 @@ static void CheckUpdates(void *)
// Show dialog
if (count == 0) {
if (!opts.bSilent)
- ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("No updates found."), 2, 0);
+ ShowPopup(TranslateT("Plugin Updater"), TranslateT("No updates found."), POPUP_TYPE_INFO);
delete UpdateFiles;
opts.bSilent = true;
}
@@ -718,7 +724,7 @@ static void CheckUpdates(void *)
}
else opts.bSilent = true;
- mir_forkthread(InitTimer, (void*)(success ? 0 : 2));
+ mir_forkthread(InitTimer, (void*)(success ? 0 : 2));
hashes.destroy();
hCheckThread = NULL;
@@ -727,15 +733,15 @@ static void CheckUpdates(void *)
void DoCheck()
{
if (hCheckThread)
- ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("Update checking already started!"), 2, 0);
+ ShowPopup(TranslateT("Plugin Updater"), TranslateT("Update checking already started!"), POPUP_TYPE_INFO);
else if (hwndDialog) {
ShowWindow(hwndDialog, SW_SHOW);
SetForegroundWindow(hwndDialog);
SetFocus(hwndDialog);
} else {
- #if MIRANDA_VER >= 0x0A00
- db_set_dw(NULL, MODNAME, "LastUpdate", time(NULL));
- #endif
+#if MIRANDA_VER >= 0x0A00
+ db_set_dw(NULL, MODNAME, "LastUpdate", time(NULL));
+#endif
hCheckThread = mir_forkthread(CheckUpdates, 0);
}
}
@@ -748,6 +754,7 @@ void UninitCheck()
INT_PTR MenuCommand(WPARAM,LPARAM)
{
+ Netlib_LogfT(hNetlibUser,_T("Update started manually!"));
opts.bSilent = false;
DoCheck();
return 0;
@@ -762,4 +769,21 @@ void UnloadCheck()
{
if (hCheckThread)
hCheckThread = NULL;
+}
+
+void CheckUpdateOnStartup()
+{
+ if(opts.bUpdateOnStartup)
+ {
+ if (opts.bOnlyOnceADay)
+ {
+ time_t now = time(NULL),
+ was = db_get_dw(NULL, MODNAME, "LastUpdate", 0);
+
+ if ((now - was) < 86400)
+ return;
+ }
+ Netlib_LogfT(hNetlibUser,_T("Update on startup started!"));
+ DoCheck();
+ }
} \ No newline at end of file
diff --git a/plugins/PluginUpdater/src/Events.cpp b/plugins/PluginUpdater/src/Events.cpp
index 816f92c603..90ad62e3fb 100644
--- a/plugins/PluginUpdater/src/Events.cpp
+++ b/plugins/PluginUpdater/src/Events.cpp
@@ -48,11 +48,10 @@ int ModulesLoaded(WPARAM, LPARAM)
else
EmptyFolder(0, TRUE); // silently
- if (AllowUpdateOnStartup())
- DoCheck();
+ CheckUpdateOnStartup();
Timer = CreateWaitableTimer(NULL, FALSE, NULL);
- mir_forkthread(InitTimer, (void*)0);
+ mir_forkthread(InitTimer, 0);
return 0;
}
diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp
index 4a9108a5e8..9dbbf9a5a9 100644
--- a/plugins/PluginUpdater/src/Notifications.cpp
+++ b/plugins/PluginUpdater/src/Notifications.cpp
@@ -19,9 +19,27 @@ Boston, MA 02111-1307, USA.
#include "common.h"
-HANDLE hPipe = NULL;
+aPopups PopupsList[POPUPS];
-void PopupAction(HWND hWnd, BYTE action)
+void InitPopupList()
+{
+ int index = 0;
+ PopupsList[index].ID = index;
+ PopupsList[index].colorBack = db_get_dw(NULL, MODNAME, "Popups0Bg", COLOR_BG_FIRSTDEFAULT);
+ PopupsList[index].colorText = db_get_dw(NULL, MODNAME, "Popups0Tx", COLOR_TX_DEFAULT);
+
+ index = 1;
+ PopupsList[index].ID = index;
+ PopupsList[index].colorBack = db_get_dw(NULL, MODNAME, "Popups1Bg", COLOR_BG_SECONDDEFAULT);
+ PopupsList[index].colorText = db_get_dw(NULL, MODNAME, "Popups1Tx", COLOR_TX_DEFAULT);
+
+ index = 2;
+ PopupsList[index].ID = index;
+ PopupsList[index].colorBack = db_get_dw(NULL, MODNAME, "Popups2Bg", COLOR_BG_FIRSTDEFAULT);
+ PopupsList[index].colorText = db_get_dw(NULL, MODNAME, "Popups2Tx", COLOR_TX_DEFAULT);
+}
+
+void PopupAction(HWND hPopup, BYTE action)
{
switch (action) {
case PCA_CLOSEPOPUP:
@@ -29,108 +47,75 @@ void PopupAction(HWND hWnd, BYTE action)
case PCA_DONOTHING:
return;
}
- PUDeletePopup(hWnd);
+ PUDeletePopup(hPopup);
}
-static LRESULT CALLBACK PopupDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+static LRESULT CALLBACK PopupDlgProc(HWND hPopup, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
- case UM_POPUPACTION:
- if (HIWORD(wParam) == BN_CLICKED) {
- LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg);
- if (pmpd) {
- switch (LOWORD(wParam)) {
- case IDYES:
- if (IsWindow(pmpd->hDialog))
- PostMessage(pmpd->hDialog, WM_CLOSE, 0, 0);
- PUDeletePopup(hDlg);
- break;
+ case WM_COMMAND:
+ PopupAction(hPopup, PopupOptions.LeftClickAction);
+ break;
- case IDNO:
- if (IsWindow(pmpd->hDialog))
- PostMessage(pmpd->hDialog, WM_CLOSE, 0, 0);
- PUDeletePopup(hDlg);
- break;
- }
- }
- }
+ case WM_CONTEXTMENU:
+ PopupAction(hPopup, PopupOptions.RightClickAction);
break;
case UM_FREEPLUGINDATA:
- {
- LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg);
- if (pmpd > 0)
- mir_free(pmpd);
- return TRUE; //TRUE or FALSE is the same, it gets ignored.
- }
break;
}
- return DefWindowProc(hDlg, uMsg, wParam, lParam);
+ return DefWindowProc(hPopup, uMsg, wParam, lParam);
+}
+
+static void _stdcall RestartPrompt(void *) {
+ TCHAR tszText[200];
+ mir_sntprintf(tszText, SIZEOF(tszText), _T("%s\n\n%s"), TranslateT("You need to restart your Miranda to apply installed updates."), TranslateT("Would you like to restart it now?"));
+
+ if (MessageBox(0, tszText, TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION | MB_TOPMOST) == IDYES)
+ CallService(MS_SYSTEM_RESTART, db_get_b(NULL,MODNAME,"RestartCurrentProfile",1) ? 1 : 0, 0);
}
-static LRESULT CALLBACK PopupDlgProc2(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+static LRESULT CALLBACK PopupDlgProcRestart(HWND hPopup, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
- case WM_COMMAND:
- PopupAction(hDlg, PopupOptions.LeftClickAction);
- break;
-
case WM_CONTEXTMENU:
- PopupAction(hDlg, PopupOptions.RightClickAction);
+ PUDeletePopup(hPopup);
break;
+ case WM_COMMAND:
+ PUDeletePopup(hPopup);
+ CallFunctionAsync(RestartPrompt,0);
- case UM_FREEPLUGINDATA:
- {
- LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg);
- if (pmpd > 0)
- mir_free(pmpd);
- return TRUE; //TRUE or FALSE is the same, it gets ignored.
- }
break;
}
- return DefWindowProc(hDlg, uMsg, wParam, lParam);
+ return DefWindowProc(hPopup, uMsg, wParam, lParam);
}
-static void MakePopupAction(POPUPACTION &pa, int id)
+void ShowPopup(LPCTSTR ptszTitle, LPCTSTR ptszText, int Number)
{
- pa.cbSize = sizeof(POPUPACTION);
- pa.flags = PAF_ENABLED;
- pa.wParam = MAKEWORD(id, BN_CLICKED);
- pa.lParam = 0;
- switch (id) {
- case IDYES:
- pa.lchIcon = Skin_GetIcon("btn_ok");
- strncpy_s(pa.lpzTitle, MODNAME"/Yes", MAX_ACTIONTITLE);
- break;
-
- case IDNO:
- pa.lchIcon = Skin_GetIcon("btn_cancel");
- strncpy_s(pa.lpzTitle, MODNAME"/No", MAX_ACTIONTITLE);
- break;
+ if(Number != POPUP_TYPE_MSG) {
+ char setting[100];
+ mir_snprintf(setting, SIZEOF(setting), "Popups%d", Number);
+ if(!db_get_b(NULL, MODNAME, setting, DEFAULT_MESSAGE_ENABLED))
+ return;
}
-}
-void ShowPopup(HWND hDlg, LPCTSTR ptszTitle, LPCTSTR ptszText, int Number, int ActType, bool NoMessageBox)
-{
if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1)) {
- LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)mir_alloc(sizeof(MSGPOPUPDATA));
- if (!pmpd)
- return;
-
- POPUPDATAT_V2 pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.lchContact = NULL; //(HANDLE)wParam;
- pd.lchIcon = LoadSkinnedIcon(PopupsList[Number].Icon);
- pd.PluginWindowProc = (Number == 0 && ActType != 0) ? PopupDlgProc : PopupDlgProc2;
- pd.PluginData = pmpd;
- pd.iSeconds = (Number == 0) ? -1 : PopupOptions.Timeout;
- pd.hNotification = NULL;
- pd.lpActions = pmpd->pa;
+ 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, TranslateTS(ptszText), MAX_SECONDLINE);
- lstrcpyn(pd.lptzContactName, TranslateTS(ptszTitle), MAX_CONTACTNAME);
+ lstrcpyn(pd.lptzText, ptszText, MAX_SECONDLINE);
+ lstrcpyn(pd.lptzContactName, ptszTitle, MAX_CONTACTNAME);
switch (PopupOptions.DefColors) {
case byCOLOR_WINDOWS:
@@ -146,112 +131,25 @@ void ShowPopup(HWND hDlg, LPCTSTR ptszTitle, LPCTSTR ptszText, int Number, int A
break;
}
- pmpd->hDialog = hDlg;
-
- if (ActType == 1) {
- MakePopupAction(pmpd->pa[pd.actionCount++], IDYES);
- MakePopupAction(pmpd->pa[pd.actionCount++], IDNO);
+ 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;
}
-
- CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, APF_NEWDATA);
- } else if (!NoMessageBox) {
- char setting[100];
- mir_snprintf(setting, SIZEOF(setting), "Popups%dM", Number);
- if (db_get_b(NULL, MODNAME, setting, DEFAULT_MESSAGE_ENABLED)) {
- int iMsgType;
- switch( Number ) {
- case 1: iMsgType = MB_ICONSTOP; break;
- case 2: iMsgType = MB_ICONINFORMATION; break;
- case 3: iMsgType = MB_ICONQUESTION; break;
- case 4: return;
- default: iMsgType = 0;
- }
- MessageBox(hDlg, TranslateTS(ptszText), TranslateTS(ptszTitle), iMsgType);
+ int iMsgType;
+ switch( Number ) {
+ case POPUP_TYPE_MSG: iMsgType = MB_ICONSTOP; break;
+ case POPUP_TYPE_ERROR: iMsgType = MB_ICONINFORMATION; break;
+ case POPUP_TYPE_INFO: iMsgType = MB_ICONQUESTION; break;
+ default: iMsgType = 0;
}
+ MessageBox(0, ptszText, ptszTitle, iMsgType);
}
}
-INT_PTR CALLBACK DlgDownload(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch (message) {
- case WM_INITDIALOG:
- SetWindowText(GetDlgItem(hDlg, IDC_LABEL), tszDialogMsg);
- SetWindowLongPtr(GetDlgItem(hDlg, IDC_PB), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hDlg, IDC_PB), GWL_STYLE) | PBS_MARQUEE);
- SendMessage(GetDlgItem(hDlg, IDC_PB), PBM_SETMARQUEE, 1, 50);
- return TRUE;
- }
- return FALSE;
-}
-
-INT_PTR CALLBACK DlgDownloadPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch (uMsg) {
- case WM_INITDIALOG:
- PopupDataText *temp = (PopupDataText*)lParam;
- ShowPopup(hDlg, temp->Title, temp->Text, 3, 0);
- return TRUE;
- }
- return FALSE;
-}
-
-bool PrepareEscalation()
-{
- // First try to create a file near Miranda32.exe
- TCHAR szPath[MAX_PATH];
- GetModuleFileName(NULL, szPath, SIZEOF(szPath));
- TCHAR *ext = _tcsrchr(szPath, '.');
- if (ext != NULL)
- *ext = '\0';
- _tcscat(szPath, _T(".test"));
- HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hFile != INVALID_HANDLE_VALUE) {
- // we are admins or UAC is disable, cool
- CloseHandle(hFile);
- DeleteFile(szPath);
- return true;
- }
-
- // Check the current process's "run as administrator" status.
- if ( IsRunAsAdmin())
- return true;
-
- // Elevate the process. Create a pipe for a stub first
- TCHAR tszPipeName[MAX_PATH];
- mir_sntprintf(tszPipeName, MAX_PATH, _T("\\\\.\\pipe\\Miranda_Pu_%d"), GetCurrentProcessId());
- hPipe = CreateNamedPipe(tszPipeName, PIPE_ACCESS_DUPLEX, PIPE_READMODE_BYTE | PIPE_WAIT, 1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
- if (hPipe == INVALID_HANDLE_VALUE) {
- hPipe = NULL;
- return false;
- }
-
- TCHAR cmdLine[100], *p;
- GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath));
- if ((p = _tcsrchr(szPath, '\\')) != 0)
- _tcscpy(p+1, _T("pu_stub.exe"));
- mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("%d"), GetCurrentProcessId());
-
- // Launch a stub
- SHELLEXECUTEINFO sei = { sizeof(sei) };
- sei.lpVerb = L"runas";
- sei.lpFile = szPath;
- sei.lpParameters = cmdLine;
- sei.hwnd = NULL;
- sei.nShow = SW_NORMAL;
- if (ShellExecuteEx(&sei)) {
- if (hPipe != NULL)
- ConnectNamedPipe(hPipe, NULL);
- return true;
- }
-
- DWORD dwError = GetLastError();
- if (dwError == ERROR_CANCELLED)
- {
- // The user refused to allow privileges elevation.
- // Do nothing ...
- }
- return false;
-}
-
int ImageList_AddIconFromIconLib(HIMAGELIST hIml, const char *name)
{
HICON icon = Skin_GetIconByHandle(Skin_GetIconHandle(name));
@@ -259,15 +157,3 @@ int ImageList_AddIconFromIconLib(HIMAGELIST hIml, const char *name)
Skin_ReleaseIcon(icon);
return res;
}
-
-INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch (uMsg) {
- case WM_INITDIALOG:
- PopupDataText *temp = (PopupDataText*)lParam;
- ShowPopup(hDlg, temp->Title, temp->Text, 0, 1);
- return TRUE;
- }
- ShowWindow(hDlg, SW_HIDE);
- return FALSE;
-}
diff --git a/plugins/PluginUpdater/src/Notifications.h b/plugins/PluginUpdater/src/Notifications.h
index b131a7e4a3..91c57a6c67 100644
--- a/plugins/PluginUpdater/src/Notifications.h
+++ b/plugins/PluginUpdater/src/Notifications.h
@@ -17,29 +17,21 @@ not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#define POPUPS 4
+#define POPUPS 3
//=== Objects =====
//This one is used to easily tie status id, icon, text...
typedef struct
{
int ID;
- int Icon;
COLORREF colorBack;
COLORREF colorText;
} aPopups;
-typedef struct _MSGPOPUPDATA
-{
- POPUPACTION pa[4];
- HWND hDialog;
-}
-MSGPOPUPDATA, *LPMSGPOPUPDATA;
-
#define DEFAULT_POPUP_LCLICK 1
#define DEFAULT_POPUP_RCLICK 0
#define DEFAULT_POPUP_ENABLED 1
-#define DEFAULT_MESSAGE_ENABLED 1
+#define DEFAULT_MESSAGE_ENABLED 0
#define DEFAULT_TIMEOUT_VALUE 0
#define COLOR_BG_FIRSTDEFAULT RGB(173,206,247)
@@ -67,6 +59,6 @@ static struct {
TCHAR *Text;
int Action;
} PopupActions[] = {
- _T("Close popup"), PCA_CLOSEPOPUP,
- _T("Do nothing"), PCA_DONOTHING
+ LPGENT("Close popup"), PCA_CLOSEPOPUP,
+ LPGENT("Do nothing"), PCA_DONOTHING
};
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp
index 11021ac371..9d7ff1eb32 100644
--- a/plugins/PluginUpdater/src/Options.cpp
+++ b/plugins/PluginUpdater/src/Options.cpp
@@ -44,24 +44,30 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
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);
- DBVARIANT dbv;
- if ( db_get_s(NULL, MODNAME, "UpdateURL", &dbv)) {
+
+ BYTE UpdateMode = db_get_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_STABLE);
+ 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 {
- SetDlgItemTextA(hwndDlg, IDC_CUSTOMURL, dbv.pszVal);
- if (!strcmp(dbv.pszVal, DEFAULT_UPDATE_URL))
- CheckDlgButton(hwndDlg, IDC_STABLE, TRUE);
- else if (!strcmp(dbv.pszVal, DEFAULT_UPDATE_URL_TRUNK))
- CheckDlgButton(hwndDlg, IDC_TRUNK, TRUE);
- else if (!strcmp(dbv.pszVal, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS))
- CheckDlgButton(hwndDlg, IDC_TRUNK_SYMBOLS, TRUE);
- else {
- CheckDlgButton(hwndDlg, IDC_CUSTOM, TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
+ CheckDlgButton(hwndDlg, IDC_CUSTOM, TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
+ DBVARIANT dbv;
+ if (!db_get_s(NULL, MODNAME, "UpdateURL", &dbv)) {
+ SetDlgItemTextA(hwndDlg, IDC_CUSTOMURL, dbv.pszVal);
+ db_free(&dbv);
}
- db_free(&dbv);
+ else
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL));
}
}
return TRUE;
@@ -87,10 +93,31 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
break;
case IDC_TRUNK_SYMBOLS:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE);
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS));
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
case IDC_TRUNK:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE);
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL_TRUNK));
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
case IDC_STABLE:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE);
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL));
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
case IDC_CUSTOM:
- EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), IsDlgButtonChecked(hwndDlg, IDC_CUSTOM));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
+ {
+ DBVARIANT dbv;
+ if (!db_get_ts(NULL, MODNAME, "UpdateURL", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL));
+ }
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -146,21 +173,22 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
mir_forkthread(InitTimer, (void*)1);
if ( IsDlgButtonChecked(hwndDlg, IDC_STABLE))
- db_set_s(NULL, MODNAME, "UpdateURL", DEFAULT_UPDATE_URL);
+ db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_STABLE);
else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK))
- db_set_s(NULL, MODNAME, "UpdateURL", DEFAULT_UPDATE_URL_TRUNK);
+ db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_TRUNK);
else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK_SYMBOLS)) {
- ptrA oldUrl( db_get_sa(NULL, MODNAME, "UpdateURL"));
- if (strcmp(oldUrl, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS)) {
+ BYTE oldMode = db_get_b(NULL, MODNAME, "UpdateMode",0);
+ if(oldMode == UPDATE_MODE_TRUNK_SYMBOLS) {
opts.bForceRedownload = true;
db_set_b(NULL, MODNAME, "ForceRedownload", 1);
}
- db_set_s(NULL, MODNAME, "UpdateURL", DEFAULT_UPDATE_URL_TRUNK_SYMBOLS);
+ db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_TRUNK_SYMBOLS);
} 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);
}
}
break;
@@ -171,8 +199,6 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- char str[20] = {0}, str2[20] = {0};
-
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hdlg);
@@ -180,18 +206,12 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
//Colors
if (PopupOptions.DefColors == byCOLOR_OWN) {
CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_CHECKED);
- CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED);
}
- if (PopupOptions.DefColors == byCOLOR_WINDOWS) {
- CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED);
+ else if (PopupOptions.DefColors == byCOLOR_WINDOWS) {
CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_CHECKED);
}
- if (PopupOptions.DefColors == byCOLOR_POPUP) {
- CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED);
+ else if (PopupOptions.DefColors == byCOLOR_POPUP) {
CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_CHECKED);
- CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED);
}
for (int i = 0; i < POPUPS; i++) {
SendDlgItemMessage(hdlg, (i+42071), CPM_SETCOLOUR, 0, PopupsList[i].colorBack);
@@ -213,6 +233,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
//Popups nitified
for (int i = 0; i < POPUPS; i++) {
+ char str[20] = {0}, str2[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);
@@ -222,12 +243,6 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
else if (i > 0)
EnableWindow(GetDlgItem(hdlg, (i+1024)), TRUE);
}
-
- EnableWindow(GetDlgItem(hdlg, (40071)), FALSE);
- return TRUE;
-
- case WM_SHOWWINDOW:
- EnableWindow(GetDlgItem(hdlg, (40071)), FALSE);
return TRUE;
case WM_COMMAND:
@@ -303,7 +318,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
for (int i = 0; i < POPUPS; i++) {
if ((!IsDlgButtonChecked(hdlg, (i+40071))) || (!IsWindowEnabled(GetDlgItem(hdlg, (i+40071)))))
continue;
- ShowPopup(0, Title, Text, i, 0);
+ ShowPopup(Title, Text, i);
}
}
break;
@@ -352,7 +367,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
//Text color
char szSetting[20] = {0};
DWORD ctlColor = 0;
- for (int i = 0; i <= POPUPS-1; i++) {
+ for (int i = 0; i < POPUPS; i++) {
ctlColor = SendDlgItemMessage(hdlg, (i+42071), CPM_GETCOLOUR, 0, 0);
PopupsList[i].colorBack = ctlColor;
mir_snprintf(szSetting, SIZEOF(szSetting), "Popups%iBg", i);
@@ -373,6 +388,7 @@ 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};
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);
diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp
index 5e14fddd70..4644d6d13e 100644
--- a/plugins/PluginUpdater/src/PluginUpdater.cpp
+++ b/plugins/PluginUpdater/src/PluginUpdater.cpp
@@ -138,6 +138,31 @@ extern "C" __declspec(dllexport) int Load(void)
//add sounds
SkinAddNewSoundEx("updatecompleted",LPGEN("Plugin Updater"),LPGEN("Update completed"));
SkinAddNewSoundEx("updatefailed",LPGEN("Plugin Updater"),LPGEN("Update failed"));
+
+ // Upgrade old settings
+ if(!db_set_b(0,MODNAME,"UpdateMode",UPDATE_MODE_STABLE))
+ {
+ DBVARIANT dbvUpdateURL;
+ if (!db_get_s(0,MODNAME, "UpdateURL",&dbvUpdateURL))
+ {
+ if (!strcmp(dbvUpdateURL.pszVal, DEFAULT_UPDATE_URL))
+ {
+ db_set_b(0,MODNAME,"UpdateMode",UPDATE_MODE_STABLE);
+ db_unset(0,MODNAME, "UpdateURL");
+ }
+ else if (!strcmp(dbvUpdateURL.pszVal, DEFAULT_UPDATE_URL_TRUNK))
+ {
+ db_set_b(0,MODNAME,"UpdateMode",UPDATE_MODE_TRUNK);
+ db_unset(0,MODNAME, "UpdateURL");
+ }
+ else if (!strcmp(dbvUpdateURL.pszVal, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS"/"))
+ {
+ db_set_b(0,MODNAME,"UpdateMode",UPDATE_MODE_TRUNK_SYMBOLS);
+ db_unset(0,MODNAME, "UpdateURL");
+ }
+ db_free(&dbvUpdateURL);
+ }
+ }
return 0;
}
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp
index 07e17b2231..a74c878f35 100644
--- a/plugins/PluginUpdater/src/Utils.cpp
+++ b/plugins/PluginUpdater/src/Utils.cpp
@@ -19,13 +19,8 @@ Boston, MA 02111-1307, USA.
#include "Common.h"
-BOOL DlgDld;
-int Number = 0;
-TCHAR tszDialogMsg[2048] = {0};
-FILEINFO *pFileInfo = NULL;
-HANDLE hNetlibUser = NULL;
+HANDLE hNetlibUser = NULL, hPipe = NULL;
POPUP_OPTIONS PopupOptions = {0};
-aPopups PopupsList[POPUPS];
extern DWORD g_mirandaVersion;
/////////////////////////////////////////////////////////////////////////////////////
@@ -40,8 +35,6 @@ struct
static iconList[] =
{
{ "check_update", LPGEN("Check for updates"), IDI_MENU },
- { "btn_ok", LPGEN("'Yes' Button"), IDI_OK },
- { "btn_cancel", LPGEN("'No' Button"), IDI_CANCEL },
{ "info", LPGEN("Plugin info"), IDI_INFO },
{ "plg_list", LPGEN("Plugin list"), IDI_PLGLIST },
};
@@ -80,33 +73,6 @@ void UnloadNetlib()
hNetlibUser = NULL;
}
-void InitPopupList()
-{
- int index = 0;
- PopupsList[index].ID = index;
- PopupsList[index].Icon = SKINICON_OTHER_MIRANDA;
- PopupsList[index].colorBack = db_get_dw(NULL, MODNAME, "Popups0Bg", COLOR_BG_FIRSTDEFAULT);
- PopupsList[index].colorText = db_get_dw(NULL, MODNAME, "Popups0Tx", COLOR_TX_DEFAULT);
-
- index = 1;
- PopupsList[index].ID = index;
- PopupsList[index].Icon = SKINICON_OTHER_MIRANDA;
- PopupsList[index].colorBack = db_get_dw(NULL, MODNAME, "Popups1Bg", COLOR_BG_SECONDDEFAULT);
- PopupsList[index].colorText = db_get_dw(NULL, MODNAME, "Popups1Tx", COLOR_TX_DEFAULT);
-
- index = 2;
- PopupsList[index].ID = index;
- PopupsList[index].Icon = SKINICON_OTHER_MIRANDA;
- PopupsList[index].colorBack = db_get_dw(NULL, MODNAME, "Popups2Bg", COLOR_BG_FIRSTDEFAULT);
- PopupsList[index].colorText = db_get_dw(NULL, MODNAME, "Popups2Tx", COLOR_TX_DEFAULT);
-
- index = 3;
- PopupsList[index].ID = index;
- PopupsList[index].Icon = SKINICON_OTHER_MIRANDA;
- PopupsList[index].colorBack = db_get_dw(NULL, MODNAME, "Popups3Bg", COLOR_BG_SECONDDEFAULT);
- PopupsList[index].colorText = db_get_dw(NULL, MODNAME, "Popups3Tx", COLOR_TX_DEFAULT);
-}
-
void LoadOptions()
{
PopupOptions.DefColors = db_get_b(NULL, MODNAME, "DefColors", DEFAULT_COLORS);
@@ -178,16 +144,26 @@ int Get_CRC(unsigned char* buffer, ULONG bufsize)
TCHAR* GetDefaultUrl()
{
- #if MIRANDA_VER < 0x0A00
- return mir_tstrdup(_T("http://miranda-ng.org/distr/deprecated/0.94.9/x%platform%"));
- #else
+#if MIRANDA_VER < 0x0A00
+ return mir_tstrdup(_T("http://miranda-ng.org/distr/deprecated/0.94.9/x%platform%"));
+#else
+ // If "UpdateMode" is missing, try to use "UpdateURL" directly
+ BYTE UpdateMode = db_get_b(NULL,MODNAME,"UpdateMode",UPDATE_MODE_CUSTOM);
+ if (UpdateMode==UPDATE_MODE_STABLE)
+ return mir_tstrdup(_T(DEFAULT_UPDATE_URL));
+ else if (UpdateMode==UPDATE_MODE_TRUNK)
+ return mir_tstrdup(_T(DEFAULT_UPDATE_URL_TRUNK));
+ else if (UpdateMode==UPDATE_MODE_TRUNK_SYMBOLS)
+ return mir_tstrdup(_T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS));
+ else {
TCHAR *result = db_get_tsa(NULL, MODNAME, "UpdateURL");
if (result == NULL) { // URL is not set
- db_set_ts(NULL, MODNAME, "UpdateURL", _T(DEFAULT_UPDATE_URL));
+ db_set_b(NULL,MODNAME,"UpdateMode",UPDATE_MODE_STABLE);
result = mir_tstrdup( _T(DEFAULT_UPDATE_URL));
}
return result;
- #endif
+ }
+#endif
}
int CompareHashes(const ServListEntry *p1, const ServListEntry *p2)
@@ -199,11 +175,11 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes)
{
REPLACEVARSARRAY vars[2];
vars[0].lptzKey = _T("platform");
- #ifdef _WIN64
- vars[0].lptzValue = _T("64");
- #else
- vars[0].lptzValue = _T("32");
- #endif
+#ifdef _WIN64
+ vars[0].lptzValue = _T("64");
+#else
+ vars[0].lptzValue = _T("32");
+#endif
vars[1].lptzKey = vars[1].lptzValue = 0;
REPLACEVARSDATA dat = { sizeof(REPLACEVARSDATA) };
@@ -213,7 +189,7 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes)
// Download version info
if (!opts.bSilent)
- ShowPopup(NULL, TranslateT("Plugin Updater"), TranslateT("Checking new updates..."), 2, 0, true);
+ ShowPopup(TranslateT("Plugin Updater"), TranslateT("Checking new updates..."), POPUP_TYPE_INFO);
FILEURL pFileUrl;
mir_sntprintf(pFileUrl.tszDownloadURL, SIZEOF(pFileUrl.tszDownloadURL), _T("%s/hashes.zip"), baseUrl);
@@ -226,11 +202,11 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes)
if (!ret) {
if(!opts.bSilent)
- ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("An error occurred while checking new updates."), 1, 0);
+ ShowPopup(TranslateT("Plugin Updater"), TranslateT("An error occurred while checking new updates."), POPUP_TYPE_ERROR);
return false;
}
- if(!unzip(pFileUrl.tszDiskPath, tszTempPath, NULL,true))
+ if(!unzip(pFileUrl.tszDiskPath, tszTempPath, NULL))
return false;
DeleteFile(pFileUrl.tszDiskPath);
@@ -354,28 +330,12 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc)
mir_free(szUrl);
mir_free(nlhr.headers);
- DlgDld = ret;
return ret;
}
/////////////////////////////////////////////////////////////////////////////////////////
-BOOL AllowUpdateOnStartup()
-{
- if (!opts.bUpdateOnStartup)
- return FALSE;
-
- if (opts.bOnlyOnceADay) {
- time_t now = time(NULL);
- time_t was = db_get_dw(NULL, MODNAME, "LastUpdate", 0);
-
- if ((now - was) < 86400)
- return FALSE;
- }
- return TRUE;
-}
-
-LONG PeriodToMilliseconds(const int period, BYTE& periodMeasure)
+LONG PeriodToMilliseconds(const int period, BYTE periodMeasure)
{
LONG result = period * 1000;
switch(periodMeasure) {
@@ -394,7 +354,7 @@ LONG PeriodToMilliseconds(const int period, BYTE& periodMeasure)
return result;
}
-void CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHighValue)
+void CALLBACK TimerAPCProc(void *, DWORD, DWORD)
{
DoCheck();
}
@@ -445,76 +405,6 @@ void strdel(TCHAR *parBuffer, int len)
p[-len] = '\0';
}
-#if MIRANDA_VER < 0x0A00
-static char szHexTable[] = "0123456789abcdef";
-
-char* bin2hex(const void *pData, size_t len, char *dest)
-{
- const BYTE *p = (const BYTE*)pData;
- char *d = dest;
-
- for (size_t i=0; i < len; i++, p++) {
- *d++ = szHexTable[*p >> 4];
- *d++ = szHexTable[*p & 0x0F];
- }
- *d = 0;
-
- return dest;
-}
-
-char* rtrim(char *str)
-{
- if (str == NULL)
- return NULL;
-
- char *p = strchr(str, 0);
- while (--p >= str) {
- switch (*p) {
- case ' ': case '\t': case '\n': case '\r':
- *p = 0; break;
- default:
- return str;
- }
- }
- return str;
-}
-
-void CreatePathToFileT(TCHAR* tszFilePath)
-{
- TCHAR* pszLastBackslash = _tcsrchr(tszFilePath, '\\');
- if (pszLastBackslash == NULL)
- return;
-
- *pszLastBackslash = '\0';
- CreateDirectoryTreeT(tszFilePath);
- *pszLastBackslash = '\\';
-}
-
-void __stdcall RestartMe(void*)
-{
- TCHAR mirandaPath[MAX_PATH], cmdLine[MAX_PATH];
- GetModuleFileName(NULL, mirandaPath, SIZEOF(mirandaPath));
-
- TCHAR *profilename = Utils_ReplaceVarsT(_T("%miranda_profilename%"));
- mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("\"%s\" /restart:%d /profile=%s"), mirandaPath, GetCurrentProcessId(), profilename);
- mir_free(profilename);
-
- CallService("CloseAction", 0, 0);
-
- PROCESS_INFORMATION pi;
- STARTUPINFO si = { sizeof(si) };
- CreateProcess(mirandaPath, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-}
-
-#else
-
-void __stdcall RestartMe(void*)
-{
- CallService(MS_SYSTEM_RESTART, db_get_b(NULL,MODNAME,"RestartCurrentProfile",1) ? 1 : 0, 0);
-}
-
-#endif
-
void __stdcall OpenPluginOptions(void*)
{
OPENOPTIONSDIALOG ood = {0};
@@ -680,6 +570,65 @@ Cleanup:
return fIsElevated;
}
+bool PrepareEscalation()
+{
+ // First try to create a file near Miranda32.exe
+ TCHAR szPath[MAX_PATH];
+ GetModuleFileName(NULL, szPath, SIZEOF(szPath));
+ TCHAR *ext = _tcsrchr(szPath, '.');
+ if (ext != NULL)
+ *ext = '\0';
+ _tcscat(szPath, _T(".test"));
+ HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hFile != INVALID_HANDLE_VALUE) {
+ // we are admins or UAC is disable, cool
+ CloseHandle(hFile);
+ DeleteFile(szPath);
+ return true;
+ }
+ else if (IsRunAsAdmin()) {
+ // Check the current process's "run as administrator" status.
+ return true;
+ }
+ else {
+ // Elevate the process. Create a pipe for a stub first
+ TCHAR tszPipeName[MAX_PATH];
+ mir_sntprintf(tszPipeName, MAX_PATH, _T("\\\\.\\pipe\\Miranda_Pu_%d"), GetCurrentProcessId());
+ hPipe = CreateNamedPipe(tszPipeName, PIPE_ACCESS_DUPLEX, PIPE_READMODE_BYTE | PIPE_WAIT, 1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
+ if (hPipe == INVALID_HANDLE_VALUE) {
+ hPipe = NULL;
+ }
+ else {
+ TCHAR cmdLine[100], *p;
+ GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath));
+ if ((p = _tcsrchr(szPath, '\\')) != 0)
+ _tcscpy(p+1, _T("pu_stub.exe"));
+ mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("%d"), GetCurrentProcessId());
+
+ // Launch a stub
+ SHELLEXECUTEINFO sei = { sizeof(sei) };
+ sei.lpVerb = L"runas";
+ sei.lpFile = szPath;
+ sei.lpParameters = cmdLine;
+ sei.hwnd = NULL;
+ sei.nShow = SW_NORMAL;
+ if (ShellExecuteEx(&sei)) {
+ if (hPipe != NULL)
+ ConnectNamedPipe(hPipe, NULL);
+ return true;
+ }
+
+ DWORD dwError = GetLastError();
+ if (dwError == ERROR_CANCELLED)
+ {
+ // The user refused to allow privileges elevation.
+ // Do nothing ...
+ }
+ }
+ return false;
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
int TransactPipe(int opcode, const TCHAR *p1, const TCHAR *p2)
diff --git a/plugins/PluginUpdater/src/unzipfile.cpp b/plugins/PluginUpdater/src/unzipfile.cpp
index b29e7e1193..24da1147a4 100644
--- a/plugins/PluginUpdater/src/unzipfile.cpp
+++ b/plugins/PluginUpdater/src/unzipfile.cpp
@@ -45,7 +45,7 @@ void BackupFile(TCHAR *ptszSrcFileName, TCHAR *ptszBackFileName)
SafeMoveFile(ptszSrcFileName, ptszBackFileName);
}
-bool extractCurrentFile(unzFile uf, TCHAR *ptszDestPath, TCHAR *ptszBackPath, bool ch)
+bool extractCurrentFile(unzFile uf, TCHAR *ptszDestPath, TCHAR *ptszBackPath)
{
unz_file_info64 file_info;
char filename[MAX_PATH], buf[8192];
@@ -57,9 +57,6 @@ bool extractCurrentFile(unzFile uf, TCHAR *ptszDestPath, TCHAR *ptszBackPath, bo
for (char *p = strchr(filename, '/'); p; p = strchr(p+1, '/'))
*p = '\\';
- if (ch && !db_get_b(NULL, MODNAME "Files", StrToLower(ptrA(mir_strdup(filename))), 1))
- return true;
-
TCHAR tszDestFile[MAX_PATH], tszBackFile[MAX_PATH];
TCHAR *ptszNewName = mir_utf8decodeT(filename);
if (ptszNewName == NULL)
@@ -121,7 +118,7 @@ bool extractCurrentFile(unzFile uf, TCHAR *ptszDestPath, TCHAR *ptszBackPath, bo
return true;
}
-bool unzip(const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath,bool ch)
+bool unzip(const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath)
{
bool bResult = true;
@@ -131,7 +128,7 @@ bool unzip(const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath,bo
unzFile uf = unzOpen2_64(ptszZipFile, &ffunc);
if (uf) {
do {
- if (!extractCurrentFile(uf, ptszDestPath, ptszBackPath,ch))
+ if (!extractCurrentFile(uf, ptszDestPath, ptszBackPath))
bResult = false;
}
while (unzGoToNextFile(uf) == UNZ_OK);