summaryrefslogtreecommitdiff
path: root/plugins/PluginUpdater/src
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2014-07-27 08:39:37 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2014-07-27 08:39:37 +0000
commit6071a68cf1829b79f88270d16cb534865529c92c (patch)
tree2db5c27c61fb1f5b88d6516d181c7b6a082b3942 /plugins/PluginUpdater/src
parent7dfa4fde6c5111aa9a761fb6d535fcd904e91805 (diff)
temporary rollback
git-svn-id: http://svn.miranda-ng.org/main/trunk@9964 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.cpp27
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp221
-rw-r--r--plugins/PluginUpdater/src/unzipfile.cpp9
12 files changed, 631 insertions, 568 deletions
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h
index a56212c9e9..c5c192d63f 100644
--- a/plugins/PluginUpdater/src/Common.h
+++ b/plugins/PluginUpdater/src/Common.h
@@ -48,6 +48,7 @@ Boston, MA 02111-1307, USA.
#include "resource.h"
#if MIRANDA_VER < 0x0A00
+#include <m_popup2.h>
#include "compat.h"
#endif
@@ -106,24 +107,16 @@ 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 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 DEFAULT_UPDATE_URL_TRUNK_SYMBOLS "http://miranda-ng.now.im/pdb_x%platform%/"
#define MAX_RETRIES 3
@@ -140,7 +133,7 @@ extern FILEINFO *pFileInfo;
extern PlugOptions opts;
extern POPUP_OPTIONS PopupOptions;
extern aPopups PopupsList[POPUPS];
-extern HANDLE Timer, hPipe, hNetlibUser;
+extern HANDLE Timer, hPipe;
void DoCheck();
@@ -209,10 +202,10 @@ int CompareHashes(const ServListEntry *p1, const ServListEntry *p2);
TCHAR* GetDefaultUrl();
bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc);
-void ShowPopup(LPCTSTR Title, LPCTSTR Text, int Number);
+void ShowPopup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, int Number, int ActType, bool NoMessageBox = false);
void __stdcall RestartMe(void*);
void __stdcall OpenPluginOptions(void*);
-void CheckUpdateOnStartup();
+BOOL AllowUpdateOnStartup();
void InitTimer(void *type);
INT_PTR EmptyFolder(WPARAM,LPARAM);
@@ -221,13 +214,14 @@ 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 unzip(const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath,bool ch);
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
deleted file mode 100644
index 25fdcf27e0..0000000000
--- a/plugins/PluginUpdater/src/Compat/compat.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
-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 26e807f478..6afc901e17 100644
--- a/plugins/PluginUpdater/src/Compat/compat.h
+++ b/plugins/PluginUpdater/src/Compat/compat.h
@@ -76,10 +76,9 @@ __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)
@@ -125,4 +124,23 @@ 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 5f181cbce4..45cd3ddb64 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 tszFileTemp[MAX_PATH], tszFileBack[MAX_PATH];
+ TCHAR tszBuff[2048], tszFileTemp[MAX_PATH], tszFileBack[MAX_PATH];
mir_sntprintf(tszFileBack, SIZEOF(tszFileBack), _T("%s\\Backups"), tszRoot);
SafeCreateDirectory(tszFileBack);
@@ -59,35 +59,68 @@ 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) {
- // 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!"));
+ 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!"));
}
else
- ListView_SetItemText(hwndList, i, 2, TranslateT("Skipped."));
+ ListView_SetItemText(hwndList, i, 2, TranslateT("Succeeded."));
}
Netlib_CloseHandle(nlc);
- ShowPopup(TranslateT("Plugin Updater"), TranslateT("Download complete"), POPUP_TYPE_INFO);
+ 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
+ }
+ }
- int rc = MessageBox(hDlg, TranslateT("Download complete. Do you want to go to plugins option page?"), TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION);
+ 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);
if (rc == IDYES)
CallFunctionAsync(OpenPluginOptions, 0);
PostMessage(hDlg, WM_CLOSE, 0, 0);
+ return;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -141,6 +174,7 @@ 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);
@@ -241,7 +275,10 @@ 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
@@ -255,16 +292,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;
- if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) {
- 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);
+ 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);
bool enableOk = false;
for (int i=0; i < todo.getCount(); ++i) {
@@ -273,7 +310,8 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
break;
}
}
- EnableWindow(GetDlgItem(hDlg, IDOK), enableOk ? TRUE : FALSE);
+ HWND hwOk = GetDlgItem(hDlg, IDOK);
+ EnableWindow(hwOk, enableOk ? TRUE : FALSE);
}
}
break;
@@ -343,7 +381,7 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
static void __stdcall LaunchListDialog(void *param)
{
- hwndDialog = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_LIST), GetDesktopWindow(), DlgList, (LPARAM)param);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_LIST), GetDesktopWindow(), DlgList, (LPARAM)param);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -374,32 +412,30 @@ static void GetList(void *)
TCHAR tszPath[MAX_PATH];
mir_sntprintf(tszPath, SIZEOF(tszPath), _T("%s\\%s"), dirname, hash.m_name);
- 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);
- }
+ 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);
}
mir_free(dirname);
@@ -407,7 +443,7 @@ static void GetList(void *)
// Show dialog
if (UpdateFiles->getCount() == 0) {
if (!opts.bSilent)
- ShowPopup(TranslateT("Plugin Updater"), TranslateT("List is empty."), POPUP_TYPE_INFO);
+ ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("List is empty."), 2, 0);
delete UpdateFiles;
}
else CallFunctionAsync(LaunchListDialog, UpdateFiles);
@@ -415,16 +451,16 @@ static void GetList(void *)
hListThread = NULL;
}
-void DoGetList()
+void DoGetList(int iFlag)
{
if (hListThread)
- ShowPopup(TranslateT("Plugin Updater"), TranslateT("List loading already started!"), POPUP_TYPE_INFO);
+ ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("List loading already started!"), 2, 0);
else if (hwndDialog) {
ShowWindow(hwndDialog, SW_SHOW);
SetForegroundWindow(hwndDialog);
SetFocus(hwndDialog);
}
- else
+ else if (iFlag)
hListThread = mir_forkthread(GetList, 0);
}
@@ -437,7 +473,7 @@ void UninitListNew()
INT_PTR ShowListCommand(WPARAM,LPARAM)
{
opts.bSilent = false;
- DoGetList();
+ DoGetList(true);
return 0;
}
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index 879f9c0343..56de9eef47 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -97,11 +97,12 @@ static void ApplyUpdates(void *param)
// 3) Unpack all zips
TCHAR *tszMirandaPath = Utils_ReplaceVarsT(_T("%miranda_path%"));
for (int i = 0; i < todo.getCount(); i++) {
- FILEINFO& p = todo[i];
- if (p.bEnabled) {
+ if (todo[i].bEnabled) {
+ 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, tszBackFile[MAX_PATH];
+ TCHAR *ptszRelPath = p.tszNewName + _tcslen(tszMirandaPath) + 1;
mir_sntprintf(tszBackFile, SIZEOF(tszBackFile), _T("%s\\%s"), tszFileBack, ptszRelPath);
BackupFile(p.tszNewName, tszBackFile);
}
@@ -109,13 +110,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], tszBackFile[MAX_PATH];
+ 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))
+ if ( unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack,true))
SafeDeleteFile(p.File.tszDiskPath); // remove .zip after successful update
}
}
@@ -138,11 +139,7 @@ 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)
@@ -183,6 +180,9 @@ 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,55 +203,30 @@ 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);
- lvg.pszHeader = TranslateT("Core");
- lvg.iGroupId = 5;
- ListView_InsertGroup(hwndList, 0, &lvg);
-
- ListView_EnableGroupView(hwndList, TRUE);
+ // 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;
bool enableOk = false;
OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)lParam;
for (int i = 0; i < todo.getCount(); ++i) {
- 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.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_IMAGE;
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;
}
- if(enableOk)
- EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
+ HWND hwOk = GetDlgItem(hDlg, IDOK);
+ EnableWindow(hwOk, enableOk);
}
bShowDetails = false;
@@ -268,26 +243,27 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM
case LVN_ITEMCHANGED:
if (GetWindowLongPtr(hDlg, GWLP_USERDATA)) {
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
- if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) {
- 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));
+ 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);
- // 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;
}
}
- EnableWindow(GetDlgItem(hDlg, IDOK), enableOk ? TRUE : FALSE);
+ HWND hwOk = GetDlgItem(hDlg, IDOK);
+ EnableWindow(hwOk, enableOk ? TRUE : FALSE);
}
}
break;
@@ -343,9 +319,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;
}
@@ -353,6 +329,27 @@ 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;
@@ -381,7 +378,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 (UpdateFiles[i].bEnabled && !UpdateFiles[i].bDeleteOnly) {
+ if (db_get_b(NULL, MODNAME "Files", StrToLower(_T2A(UpdateFiles[i].tszOldName)), 1) && !UpdateFiles[i].bDeleteOnly) {
// download update
FILEURL *pFileUrl = &UpdateFiles[i].File;
if (!DownloadFile(pFileUrl, nlc)) {
@@ -397,7 +394,6 @@ static void DlgUpdateSilent(void *lParam)
}
Netlib_CloseHandle(nlc);
- // All available updates have been disabled
if (count == 0) {
delete &UpdateFiles;
return;
@@ -406,11 +402,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++) {
- 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];
+ 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;
mir_sntprintf(tszBackFile, SIZEOF(tszBackFile), _T("%s\\%s"), tszFileBack, ptszRelPath);
BackupFile(p.tszNewName, tszBackFile);
}
@@ -418,15 +414,14 @@ 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], tszBackFile[MAX_PATH];
+ 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);
}
-
- // remove .zip after successful update
- if (unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack))
- SafeDeleteFile(p.File.tszDiskPath);
+
+ if (unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack, true))
+ SafeDeleteFile(p.File.tszDiskPath); // remove .zip after successful update
}
}
}
@@ -451,7 +446,18 @@ 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)) {
- ShowPopup(tszTitle,TranslateT("You need to restart your Miranda to apply installed updates."),POPUP_TYPE_MSG);
+ 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);
} else {
bool notified = false;
@@ -473,11 +479,7 @@ 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
}
}
}
@@ -516,12 +518,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") },
@@ -541,18 +543,19 @@ static renameTable[] =
static bool CheckFileRename(const TCHAR *ptszOldName, TCHAR *pNewName)
{
for (int i = 0; i < SIZEOF(renameTable); i++) {
- 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;
+ 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);
}
+ return true;
}
return false;
@@ -569,15 +572,11 @@ 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 0;
-
- // skip profile folder
- TCHAR tszProfilePath[MAX_PATH];
- CallService(MS_DB_GETPROFILEPATHT, SIZEOF(tszProfilePath), (LPARAM)tszProfilePath);
- if (!_tcsicmp(tszFolder, tszProfilePath))
- return 0;
+ return count;
TCHAR tszBuf[MAX_PATH];
mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\*"), tszFolder);
@@ -585,17 +584,18 @@ 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 0;
-
- Netlib_LogfT(hNetlibUser,_T("Scanning folder %s"), tszFolder);
+ return count;
- 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);
- count += ScanFolder(tszBuf, cbBaseLen, level+1, tszBaseUrl, hashes, UpdateFiles);
+ if (0 != _tcsicmp(tszBuf, tszProfilePath))
+ count += ScanFolder(tszBuf, cbBaseLen, level+1, tszBaseUrl, hashes, UpdateFiles);
}
}
else if (isValidExtension(ffd.cFileName)) {
@@ -622,7 +622,6 @@ 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)
@@ -652,22 +651,19 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
ptszUrl = _T("");
// Compare versions
- if (bHasNewVersion) {
- // Yeah, we've got new version.
- Netlib_LogfT(hNetlibUser,_T("Found update for %s"), tszBuf);
+ if (bHasNewVersion) { // Yeah, we've got new version.
FILEINFO *FileInfo = new FILEINFO;
- // 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));
+ _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
}
else {
+ FileInfo->bDeleteOnly = FALSE;
_tcsncpy(FileInfo->tszNewName, ptszUrl, SIZEOF(FileInfo->tszNewName));
}
- _tcsncpy(tszBuf, ptszUrl, SIZEOF(tszBuf));
+ _tcscpy(tszBuf, ptszUrl);
TCHAR *p = _tcsrchr(tszBuf, '.');
if (p) *p = 0;
p = _tcsrchr(tszBuf, '\\');
@@ -679,13 +675,10 @@ 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 || FileInfo->bEnabled)
+
+ if (!opts.bSilent || db_get_b(NULL, MODNAME "Files", StrToLower(_T2A(FileInfo->tszNewName)), true))
count++;
} // end compare versions
}
@@ -698,7 +691,8 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
static void CheckUpdates(void *)
{
- Netlib_LogfT(hNetlibUser,_T("Checking for updates"));
+ char szKey[64] = {0};
+
TCHAR tszTempPath[MAX_PATH];
DWORD dwLen = GetTempPath(SIZEOF(tszTempPath), tszTempPath);
if (tszTempPath[dwLen-1] == '\\')
@@ -716,7 +710,7 @@ static void CheckUpdates(void *)
// Show dialog
if (count == 0) {
if (!opts.bSilent)
- ShowPopup(TranslateT("Plugin Updater"), TranslateT("No updates found."), POPUP_TYPE_INFO);
+ ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("No updates found."), 2, 0);
delete UpdateFiles;
opts.bSilent = true;
}
@@ -724,7 +718,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;
@@ -733,15 +727,15 @@ static void CheckUpdates(void *)
void DoCheck()
{
if (hCheckThread)
- ShowPopup(TranslateT("Plugin Updater"), TranslateT("Update checking already started!"), POPUP_TYPE_INFO);
+ ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("Update checking already started!"), 2, 0);
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);
}
}
@@ -754,7 +748,6 @@ void UninitCheck()
INT_PTR MenuCommand(WPARAM,LPARAM)
{
- Netlib_LogfT(hNetlibUser,_T("Update started manually!"));
opts.bSilent = false;
DoCheck();
return 0;
@@ -769,21 +762,4 @@ 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 90ad62e3fb..816f92c603 100644
--- a/plugins/PluginUpdater/src/Events.cpp
+++ b/plugins/PluginUpdater/src/Events.cpp
@@ -48,10 +48,11 @@ int ModulesLoaded(WPARAM, LPARAM)
else
EmptyFolder(0, TRUE); // silently
- CheckUpdateOnStartup();
+ if (AllowUpdateOnStartup())
+ DoCheck();
Timer = CreateWaitableTimer(NULL, FALSE, NULL);
- mir_forkthread(InitTimer, 0);
+ mir_forkthread(InitTimer, (void*)0);
return 0;
}
diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp
index 9dbbf9a5a9..4a9108a5e8 100644
--- a/plugins/PluginUpdater/src/Notifications.cpp
+++ b/plugins/PluginUpdater/src/Notifications.cpp
@@ -19,27 +19,9 @@ Boston, MA 02111-1307, USA.
#include "common.h"
-aPopups PopupsList[POPUPS];
+HANDLE hPipe = NULL;
-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)
+void PopupAction(HWND hWnd, BYTE action)
{
switch (action) {
case PCA_CLOSEPOPUP:
@@ -47,75 +29,108 @@ void PopupAction(HWND hPopup, BYTE action)
case PCA_DONOTHING:
return;
}
- PUDeletePopup(hPopup);
+ PUDeletePopup(hWnd);
}
-static LRESULT CALLBACK PopupDlgProc(HWND hPopup, UINT uMsg, WPARAM wParam, LPARAM lParam)
+static LRESULT CALLBACK PopupDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
- case WM_COMMAND:
- PopupAction(hPopup, PopupOptions.LeftClickAction);
- break;
+ 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_CONTEXTMENU:
- PopupAction(hPopup, PopupOptions.RightClickAction);
+ case IDNO:
+ if (IsWindow(pmpd->hDialog))
+ PostMessage(pmpd->hDialog, WM_CLOSE, 0, 0);
+ PUDeletePopup(hDlg);
+ break;
+ }
+ }
+ }
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(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);
+ return DefWindowProc(hDlg, uMsg, wParam, lParam);
}
-static LRESULT CALLBACK PopupDlgProcRestart(HWND hPopup, UINT uMsg, WPARAM wParam, LPARAM lParam)
+static LRESULT CALLBACK PopupDlgProc2(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
+ case WM_COMMAND:
+ PopupAction(hDlg, PopupOptions.LeftClickAction);
+ break;
+
case WM_CONTEXTMENU:
- PUDeletePopup(hPopup);
+ PopupAction(hDlg, PopupOptions.RightClickAction);
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(hPopup, uMsg, wParam, lParam);
+ return DefWindowProc(hDlg, uMsg, wParam, lParam);
}
-void ShowPopup(LPCTSTR ptszTitle, LPCTSTR ptszText, int Number)
+static void MakePopupAction(POPUPACTION &pa, int id)
{
- 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;
+ 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;
}
+}
+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)) {
- 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;
- }
+ 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;
- lstrcpyn(pd.lptzText, ptszText, MAX_SECONDLINE);
- lstrcpyn(pd.lptzContactName, ptszTitle, MAX_CONTACTNAME);
+ lstrcpyn(pd.lptzText, TranslateTS(ptszText), MAX_SECONDLINE);
+ lstrcpyn(pd.lptzContactName, TranslateTS(ptszTitle), MAX_CONTACTNAME);
switch (PopupOptions.DefColors) {
case byCOLOR_WINDOWS:
@@ -131,25 +146,112 @@ void ShowPopup(LPCTSTR ptszTitle, LPCTSTR ptszText, int Number)
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;
+ pmpd->hDialog = hDlg;
+
+ if (ActType == 1) {
+ MakePopupAction(pmpd->pa[pd.actionCount++], IDYES);
+ MakePopupAction(pmpd->pa[pd.actionCount++], IDNO);
}
- 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;
+
+ 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);
}
- 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));
@@ -157,3 +259,15 @@ 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 91c57a6c67..b131a7e4a3 100644
--- a/plugins/PluginUpdater/src/Notifications.h
+++ b/plugins/PluginUpdater/src/Notifications.h
@@ -17,21 +17,29 @@ not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#define POPUPS 3
+#define POPUPS 4
//=== 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 0
+#define DEFAULT_MESSAGE_ENABLED 1
#define DEFAULT_TIMEOUT_VALUE 0
#define COLOR_BG_FIRSTDEFAULT RGB(173,206,247)
@@ -59,6 +67,6 @@ static struct {
TCHAR *Text;
int Action;
} PopupActions[] = {
- LPGENT("Close popup"), PCA_CLOSEPOPUP,
- LPGENT("Do nothing"), PCA_DONOTHING
+ _T("Close popup"), PCA_CLOSEPOPUP,
+ _T("Do nothing"), PCA_DONOTHING
};
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp
index 9d7ff1eb32..11021ac371 100644
--- a/plugins/PluginUpdater/src/Options.cpp
+++ b/plugins/PluginUpdater/src/Options.cpp
@@ -44,30 +44,24 @@ 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);
-
- BYTE UpdateMode = db_get_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_STABLE);
- if (UpdateMode == UPDATE_MODE_STABLE) {
+ DBVARIANT dbv;
+ if ( db_get_s(NULL, MODNAME, "UpdateURL", &dbv)) {
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);
- DBVARIANT dbv;
- if (!db_get_s(NULL, MODNAME, "UpdateURL", &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_CUSTOMURL, dbv.pszVal);
- db_free(&dbv);
+ 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);
}
- else
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL));
+ db_free(&dbv);
}
}
return TRUE;
@@ -93,31 +87,10 @@ 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), 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));
- }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), IsDlgButtonChecked(hwndDlg, IDC_CUSTOM));
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -173,22 +146,21 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
mir_forkthread(InitTimer, (void*)1);
if ( IsDlgButtonChecked(hwndDlg, IDC_STABLE))
- db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_STABLE);
+ db_set_s(NULL, MODNAME, "UpdateURL", DEFAULT_UPDATE_URL);
else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK))
- db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_TRUNK);
+ db_set_s(NULL, MODNAME, "UpdateURL", DEFAULT_UPDATE_URL_TRUNK);
else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK_SYMBOLS)) {
- BYTE oldMode = db_get_b(NULL, MODNAME, "UpdateMode",0);
- if(oldMode == UPDATE_MODE_TRUNK_SYMBOLS) {
+ ptrA oldUrl( db_get_sa(NULL, MODNAME, "UpdateURL"));
+ if (strcmp(oldUrl, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS)) {
opts.bForceRedownload = true;
db_set_b(NULL, MODNAME, "ForceRedownload", 1);
}
- db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_TRUNK_SYMBOLS);
+ db_set_s(NULL, MODNAME, "UpdateURL", DEFAULT_UPDATE_URL_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;
@@ -199,6 +171,8 @@ 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);
@@ -206,12 +180,18 @@ 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);
}
- else if (PopupOptions.DefColors == byCOLOR_WINDOWS) {
+ if (PopupOptions.DefColors == byCOLOR_WINDOWS) {
+ CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_CHECKED);
}
- else if (PopupOptions.DefColors == byCOLOR_POPUP) {
+ if (PopupOptions.DefColors == byCOLOR_POPUP) {
+ CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED);
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);
@@ -233,7 +213,6 @@ 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);
@@ -243,6 +222,12 @@ 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:
@@ -318,7 +303,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(Title, Text, i);
+ ShowPopup(0, Title, Text, i, 0);
}
}
break;
@@ -367,7 +352,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; i++) {
+ for (int i = 0; i <= POPUPS-1; i++) {
ctlColor = SendDlgItemMessage(hdlg, (i+42071), CPM_GETCOLOUR, 0, 0);
PopupsList[i].colorBack = ctlColor;
mir_snprintf(szSetting, SIZEOF(szSetting), "Popups%iBg", i);
@@ -388,7 +373,6 @@ 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 d0678e91e5..5e14fddd70 100644
--- a/plugins/PluginUpdater/src/PluginUpdater.cpp
+++ b/plugins/PluginUpdater/src/PluginUpdater.cpp
@@ -135,30 +135,9 @@ extern "C" __declspec(dllexport) int Load(void)
InitEvents();
- // add sounds
- SkinAddNewSoundEx("updatecompleted", LPGEN("Plugin Updater"), LPGEN("Update completed"));
- SkinAddNewSoundEx("updatefailed", LPGEN("Plugin Updater"), LPGEN("Update failed"));
-
- // Upgrade old settings
- if (-1 == db_get_b(0, MODNAME, "UpdateMode", -1)) {
- ptrA dbvUpdateURL(db_get_sa(0, MODNAME, "UpdateURL"));
- if (dbvUpdateURL) {
- if (!strcmp(dbvUpdateURL, DEFAULT_UPDATE_URL)) {
- db_set_b(0, MODNAME, "UpdateMode", UPDATE_MODE_STABLE);
- db_unset(0, MODNAME, "UpdateURL");
- }
- else if (!strcmp(dbvUpdateURL, DEFAULT_UPDATE_URL_TRUNK)) {
- db_set_b(0, MODNAME, "UpdateMode", UPDATE_MODE_TRUNK);
- db_unset(0, MODNAME, "UpdateURL");
- }
- else if (!strcmp(dbvUpdateURL, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS"/")) {
- db_set_b(0, MODNAME, "UpdateMode", UPDATE_MODE_TRUNK_SYMBOLS);
- db_unset(0, MODNAME, "UpdateURL");
- }
- else db_set_b(0, MODNAME, "UpdateMode", UPDATE_MODE_CUSTOM);
- }
- else db_set_b(0, MODNAME, "UpdateMode", UPDATE_MODE_STABLE);
- }
+ //add sounds
+ SkinAddNewSoundEx("updatecompleted",LPGEN("Plugin Updater"),LPGEN("Update completed"));
+ SkinAddNewSoundEx("updatefailed",LPGEN("Plugin Updater"),LPGEN("Update failed"));
return 0;
}
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp
index a74c878f35..07e17b2231 100644
--- a/plugins/PluginUpdater/src/Utils.cpp
+++ b/plugins/PluginUpdater/src/Utils.cpp
@@ -19,8 +19,13 @@ Boston, MA 02111-1307, USA.
#include "Common.h"
-HANDLE hNetlibUser = NULL, hPipe = NULL;
+BOOL DlgDld;
+int Number = 0;
+TCHAR tszDialogMsg[2048] = {0};
+FILEINFO *pFileInfo = NULL;
+HANDLE hNetlibUser = NULL;
POPUP_OPTIONS PopupOptions = {0};
+aPopups PopupsList[POPUPS];
extern DWORD g_mirandaVersion;
/////////////////////////////////////////////////////////////////////////////////////
@@ -35,6 +40,8 @@ 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 },
};
@@ -73,6 +80,33 @@ 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);
@@ -144,26 +178,16 @@ 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 "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 {
+ #if MIRANDA_VER < 0x0A00
+ return mir_tstrdup(_T("http://miranda-ng.org/distr/deprecated/0.94.9/x%platform%"));
+ #else
TCHAR *result = db_get_tsa(NULL, MODNAME, "UpdateURL");
if (result == NULL) { // URL is not set
- db_set_b(NULL,MODNAME,"UpdateMode",UPDATE_MODE_STABLE);
+ db_set_ts(NULL, MODNAME, "UpdateURL", _T(DEFAULT_UPDATE_URL));
result = mir_tstrdup( _T(DEFAULT_UPDATE_URL));
}
return result;
- }
-#endif
+ #endif
}
int CompareHashes(const ServListEntry *p1, const ServListEntry *p2)
@@ -175,11 +199,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) };
@@ -189,7 +213,7 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes)
// Download version info
if (!opts.bSilent)
- ShowPopup(TranslateT("Plugin Updater"), TranslateT("Checking new updates..."), POPUP_TYPE_INFO);
+ ShowPopup(NULL, TranslateT("Plugin Updater"), TranslateT("Checking new updates..."), 2, 0, true);
FILEURL pFileUrl;
mir_sntprintf(pFileUrl.tszDownloadURL, SIZEOF(pFileUrl.tszDownloadURL), _T("%s/hashes.zip"), baseUrl);
@@ -202,11 +226,11 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes)
if (!ret) {
if(!opts.bSilent)
- ShowPopup(TranslateT("Plugin Updater"), TranslateT("An error occurred while checking new updates."), POPUP_TYPE_ERROR);
+ ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("An error occurred while checking new updates."), 1, 0);
return false;
}
- if(!unzip(pFileUrl.tszDiskPath, tszTempPath, NULL))
+ if(!unzip(pFileUrl.tszDiskPath, tszTempPath, NULL,true))
return false;
DeleteFile(pFileUrl.tszDiskPath);
@@ -330,12 +354,28 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc)
mir_free(szUrl);
mir_free(nlhr.headers);
+ DlgDld = ret;
return ret;
}
/////////////////////////////////////////////////////////////////////////////////////////
-LONG PeriodToMilliseconds(const int period, BYTE periodMeasure)
+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 result = period * 1000;
switch(periodMeasure) {
@@ -354,7 +394,7 @@ LONG PeriodToMilliseconds(const int period, BYTE periodMeasure)
return result;
}
-void CALLBACK TimerAPCProc(void *, DWORD, DWORD)
+void CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHighValue)
{
DoCheck();
}
@@ -405,6 +445,76 @@ 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};
@@ -570,65 +680,6 @@ 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 24da1147a4..b29e7e1193 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 extractCurrentFile(unzFile uf, TCHAR *ptszDestPath, TCHAR *ptszBackPath, bool ch)
{
unz_file_info64 file_info;
char filename[MAX_PATH], buf[8192];
@@ -57,6 +57,9 @@ bool extractCurrentFile(unzFile uf, TCHAR *ptszDestPath, TCHAR *ptszBackPath)
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)
@@ -118,7 +121,7 @@ bool extractCurrentFile(unzFile uf, TCHAR *ptszDestPath, TCHAR *ptszBackPath)
return true;
}
-bool unzip(const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath)
+bool unzip(const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath,bool ch)
{
bool bResult = true;
@@ -128,7 +131,7 @@ bool unzip(const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath)
unzFile uf = unzOpen2_64(ptszZipFile, &ffunc);
if (uf) {
do {
- if (!extractCurrentFile(uf, ptszDestPath, ptszBackPath))
+ if (!extractCurrentFile(uf, ptszDestPath, ptszBackPath,ch))
bResult = false;
}
while (unzGoToNextFile(uf) == UNZ_OK);