summaryrefslogtreecommitdiff
path: root/plugins/PluginUpdater
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/PluginUpdater')
-rw-r--r--plugins/PluginUpdater/res/Resource.rc37
-rw-r--r--plugins/PluginUpdater/src/Common.h33
-rw-r--r--plugins/PluginUpdater/src/Events.cpp19
-rw-r--r--plugins/PluginUpdater/src/Notifications.cpp17
-rw-r--r--plugins/PluginUpdater/src/Notifications.h2
-rw-r--r--plugins/PluginUpdater/src/Options.cpp124
-rw-r--r--plugins/PluginUpdater/src/PluginUpdater.cpp12
-rw-r--r--plugins/PluginUpdater/src/Scanner.cpp24
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp33
-rw-r--r--plugins/PluginUpdater/src/resource.h8
-rw-r--r--plugins/PluginUpdater/src/unzipfile.cpp24
11 files changed, 131 insertions, 202 deletions
diff --git a/plugins/PluginUpdater/res/Resource.rc b/plugins/PluginUpdater/res/Resource.rc
index 9817f29590..626070c3e0 100644
--- a/plugins/PluginUpdater/res/Resource.rc
+++ b/plugins/PluginUpdater/res/Resource.rc
@@ -49,14 +49,6 @@ BEGIN
PUSHBUTTON "Select &none",IDC_SELNONE,124,187,50,14,NOT WS_TABSTOP
END
-IDD_DOWNLOAD DIALOGEX 0, 0, 172, 39
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_SYSMENU
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "",IDC_PB,"msctls_progress32",WS_BORDER,7,23,158,9
- CTEXT "Downloading...",IDC_LABEL,7,7,158,12
-END
-
IDD_POPUPDUMMI DIALOGEX 65526, 65526, 1, 1
STYLE DS_ABSALIGN | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
@@ -68,23 +60,21 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Plugin updates options",IDC_STATIC,1,27,253,60
- CONTROL "On startup",IDC_UPDATEONSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,44,52,10
- CONTROL "Remind about not installed plugin updates",IDC_REMINDER,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,72,198,10
GROUPBOX "Hotkey",IDC_STATIC,2,0,253,26
CONTROL "Go to Customize -> Hotkeys to change the hotkey",IDC_LINK_HOTKEY,
"Hyperlink",WS_TABSTOP,9,11,199,10
- CONTROL "Message boxes",IDC_MSG_BOXES2,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,8,101,79,10
- CONTROL "Errors",IDC_ERRORS2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,114,57,10
- CONTROL "Info messages",IDC_INFO_MESSAGES2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,127,80,10
- CONTROL "Progress dialogs",IDC_PROGR_DLG2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,140,80,10
+
+ GROUPBOX "Plugin updates options",IDC_STATIC,1,27,253,74
+ CONTROL "On startup",IDC_UPDATEONSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,44,52,10
+ CONTROL "(but only once a day)",IDC_ONLYONCEADAY,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,92,44,161,10
+
CONTROL "Every",IDC_UPDATEONPERIOD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,58,52,10
EDITTEXT IDC_PERIOD,65,56,28,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
CONTROL "",IDC_PERIODSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,92,56,10,15
COMBOBOX IDC_PERIODMEASURE,114,56,58,30,CBS_DROPDOWNLIST | CBS_SORT | WS_DISABLED | WS_VSCROLL | WS_TABSTOP
- CONTROL "(but only once a day)",IDC_ONLYONCEADAY,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,92,44,161,10
- GROUPBOX "Notifications",IDC_NOTIFY2,3,90,253,67
+
+ CONTROL "Remind about not installed plugin updates",IDC_REMINDER, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,72,198,10
+ CONTROL "Update icons",IDC_UPDATEICONS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,86,198,10
END
IDD_POPUP DIALOGEX 0, 0, 316, 182
@@ -140,18 +130,18 @@ END
// TEXTINCLUDE
//
-1 TEXTINCLUDE
+1 TEXTINCLUDE
BEGIN
"..\\src\\resource.h\0"
END
-2 TEXTINCLUDE
+2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
-3 TEXTINCLUDE
+3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
@@ -173,10 +163,6 @@ BEGIN
BOTTOMMARGIN, 201
END
- IDD_DOWNLOAD, DIALOG
- BEGIN
- END
-
IDD_POPUPDUMMI, DIALOG
BEGIN
END
@@ -205,4 +191,3 @@ END
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
-
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h
index 7539b14847..ecf0dd1295 100644
--- a/plugins/PluginUpdater/src/Common.h
+++ b/plugins/PluginUpdater/src/Common.h
@@ -32,7 +32,6 @@ Boston, MA 02111-1307, USA.
#include <Shlobj.h>
// Miranda header files
-#include "win2k.h"
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_skin.h>
@@ -46,19 +45,19 @@ Boston, MA 02111-1307, USA.
#include <m_hotkeys.h>
#include <m_netlib.h>
#include <m_icolib.h>
+#include <win2k.h>
#include <m_folders.h>
-#include "m_popup2.h"
+#include <m_popup2.h>
#include "version.h"
#include "resource.h"
#include "Notifications.h"
-#define MODNAME "PluginUpdater"
-#define MODULEA "Plugin Updater"
-#define MODULEW L"Plugin Updater"
-#define DEFAULT_UPDATES_FOLDER L"Plugin Updates"
-typedef std::wstring tString;
+#define MODNAME "PluginUpdater"
+#define MODULEA "Plugin Updater"
+#define MODULEW L"Plugin Updater"
+#define DEFAULT_UPDATES_FOLDER L"Plugin Updates"
#define MODULE MODULEW
struct FILEURL
@@ -85,7 +84,17 @@ struct PopupDataText
TCHAR* Text;
};
+struct PlugOptions
+{
+ BYTE bReminder, bUpdateOnStartup, bUpdateOnPeriod, bOnlyOnceADay, bUpdateIcons;
+ BOOL bSilent, bDlgDld;
+
+ BYTE bPeriodMeasure;
+ INT Period;
+};
+
#define DEFAULT_REMINDER 1
+#define DEFAULT_UPDATEICONS 0
#define DEFAULT_UPDATEONSTARTUP 1
#define DEFAULT_ONLYONCEADAY 0
#define DEFAULT_UPDATEONPERIOD 0
@@ -102,18 +111,15 @@ struct PopupDataText
#define IDDOWNLOAD 4
#define IDDOWNLOADALL 5
-using std::wstring;
using namespace std;
extern HINSTANCE hInst;
-extern INT Period;
-extern BOOL Silent, DlgDld;
-extern BYTE Reminder, UpdateOnStartup, UpdateOnPeriod, OnlyOnceADay, PeriodMeasure;
+
extern TCHAR tszRoot[MAX_PATH], tszDialogMsg[2048];
extern FILEINFO* pFileInfo;
-//extern FILEURL* pFileUrl;
extern HANDLE CheckThread;
-extern MYOPTIONS MyOptions;
+extern PlugOptions opts;
+extern POPUP_OPTIONS PopupOptions;
extern aPopups PopupsList[POPUPS];
extern HANDLE Timer;
extern HWND hwndDialog;
@@ -131,7 +137,6 @@ INT OptInit(WPARAM wParam, LPARAM lParam);
VOID DoCheck(INT iFlag);
BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal);
VOID ShowPopup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, INT Number, INT ActType);
-VOID DlgDownloadProc(FILEURL *pFileUrl, PopupDataText temp);
INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void __stdcall ExitMe(void*);
diff --git a/plugins/PluginUpdater/src/Events.cpp b/plugins/PluginUpdater/src/Events.cpp
index d2055474d5..5ac9d19561 100644
--- a/plugins/PluginUpdater/src/Events.cpp
+++ b/plugins/PluginUpdater/src/Events.cpp
@@ -20,24 +20,13 @@ Boston, MA 02111-1307, USA.
#include "common.h"
HANDLE Timer;
-BOOL Silent;
int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
- Silent = true;
- HOTKEYDESC hkd = {0};
- hkd.cbSize = sizeof(hkd);
- hkd.dwFlags = HKD_TCHAR;
- hkd.pszName = "Check for plugin updates";
- hkd.ptszDescription = _T("Check for plugin updates");
- hkd.ptszSection = _T("Plugin Updater");
- hkd.pszService = MODNAME"/CheckUpdates";
- hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F10) | HKF_MIRANDA_LOCAL;
- hkd.lParam = FALSE;
- Hotkey_Register(&hkd);
+ opts.bSilent = true;
if (AllowUpdateOnStartup())
- DoCheck(UpdateOnStartup);
+ DoCheck(opts.bUpdateOnStartup);
Timer = CreateWaitableTimer(NULL, FALSE, NULL);
InitTimer();
@@ -47,7 +36,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam)
INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam)
{
- Silent = false;
+ opts.bSilent = false;
DoCheck(1);
return 0;
}
@@ -75,4 +64,4 @@ INT OnPreShutdown(WPARAM wParam, LPARAM lParam)
CancelWaitableTimer(Timer);
CloseHandle(Timer);
return 0;
-} \ No newline at end of file
+}
diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp
index a85b0fa02e..bedbb36723 100644
--- a/plugins/PluginUpdater/src/Notifications.cpp
+++ b/plugins/PluginUpdater/src/Notifications.cpp
@@ -76,11 +76,11 @@ static INT_PTR CALLBACK PopupDlgProc2(HWND hDlg, UINT uMsg, WPARAM wParam, LPARA
{
switch (uMsg) {
case WM_COMMAND:
- PopupAction(hDlg, MyOptions.LeftClickAction);
+ PopupAction(hDlg, PopupOptions.LeftClickAction);
break;
case WM_CONTEXTMENU:
- PopupAction(hDlg, MyOptions.RightClickAction);
+ PopupAction(hDlg, PopupOptions.RightClickAction);
break;
case UM_FREEPLUGINDATA:
@@ -142,7 +142,7 @@ void ShowPopup(HWND hDlg, LPCTSTR ptszTitle, LPCTSTR ptszText, int Number, int A
pd.lchIcon = LoadSkinnedIcon(PopupsList[Number].Icon);
lstrcpyn(pd.lptzText, TranslateTS(ptszText), SIZEOF(pd.lptzText));
lstrcpyn(pd.lptzContactName, TranslateTS(ptszTitle), SIZEOF(pd.lptzContactName));
- switch (MyOptions.DefColors) {
+ switch (PopupOptions.DefColors) {
case byCOLOR_WINDOWS:
pd.colorBack = GetSysColor(COLOR_BTNFACE);
pd.colorText = GetSysColor(COLOR_WINDOWTEXT);
@@ -163,7 +163,7 @@ void ShowPopup(HWND hDlg, LPCTSTR ptszTitle, LPCTSTR ptszText, int Number, int A
if (Number == 0)
pd.iSeconds = -1;
else
- pd.iSeconds = MyOptions.Timeout;
+ pd.iSeconds = PopupOptions.Timeout;
pd.hNotification = NULL;
pd.lpActions = pmpd->pa;
@@ -206,13 +206,6 @@ INT_PTR CALLBACK DlgDownloadPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
void DlgDownloadProc(FILEURL *pFileUrl, PopupDataText temp)
{
- lstrcpyn(tszDialogMsg, temp.Text, SIZEOF(tszDialogMsg));
- HWND hDlgDld = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DOWNLOAD), NULL, DlgDownload);
-
- if (!DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath))
- ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("An error occured while downloading the update."), 1, 0);
-
- DestroyWindow(hDlgDld);
}
void SelectAll(HWND hDlg, bool bEnable)
@@ -323,7 +316,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
lvc.iSubItem = 1;
lvc.pszText = TranslateT("State");
- lvc.cx = 120; // width of column in pixels
+ lvc.cx = 120 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels
ListView_InsertColumn(hwndList, 1, &lvc);
//enumerate plugins, fill in list
diff --git a/plugins/PluginUpdater/src/Notifications.h b/plugins/PluginUpdater/src/Notifications.h
index 09bc77a810..b131a7e4a3 100644
--- a/plugins/PluginUpdater/src/Notifications.h
+++ b/plugins/PluginUpdater/src/Notifications.h
@@ -61,7 +61,7 @@ typedef struct tagMYOPTIONS {
BYTE LeftClickAction;
BYTE RightClickAction;
int Timeout;
-} MYOPTIONS;
+} POPUP_OPTIONS;
static struct {
TCHAR *Text;
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp
index 009c5b70e3..f26a351977 100644
--- a/plugins/PluginUpdater/src/Options.cpp
+++ b/plugins/PluginUpdater/src/Options.cpp
@@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA.
#include "common.h"
+PlugOptions opts;
WNDPROC g_pOldProc;
LRESULT CALLBACK MyEditProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -33,43 +34,29 @@ LRESULT CALLBACK MyEditProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- char str[20];
-
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- CheckDlgButton(hwndDlg, IDC_UPDATEONSTARTUP, (int)UpdateOnStartup);
- CheckDlgButton(hwndDlg, IDC_ONLYONCEADAY, (int)OnlyOnceADay);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), UpdateOnStartup);
- CheckDlgButton(hwndDlg, IDC_UPDATEONPERIOD, (int)UpdateOnPeriod);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PERIOD), UpdateOnPeriod);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODSPIN), UpdateOnPeriod);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), UpdateOnPeriod);
+ CheckDlgButton(hwndDlg, IDC_UPDATEONSTARTUP, opts.bUpdateOnStartup);
+ CheckDlgButton(hwndDlg, IDC_ONLYONCEADAY, opts.bOnlyOnceADay);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), opts.bUpdateOnStartup);
+ CheckDlgButton(hwndDlg, IDC_UPDATEONPERIOD, opts.bUpdateOnPeriod);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PERIOD), opts.bUpdateOnPeriod);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODSPIN), opts.bUpdateOnPeriod);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), opts.bUpdateOnPeriod);
SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETRANGE, 0, MAKELONG(99, 1));
- SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETPOS, 0, (LPARAM)Period);
+ SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETPOS, 0, (LPARAM)opts.Period);
Edit_LimitText(GetDlgItem(hwndDlg, IDC_PERIOD), 2);
g_pOldProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_PERIOD), GWLP_WNDPROC, (LONG)MyEditProc);
ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 0, TranslateT("hours"));
ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 1, TranslateT("days"));
- ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), PeriodMeasure);
-
- CheckDlgButton(hwndDlg, IDC_REMINDER, (int)Reminder);
- if (ServiceExists(MS_POPUP_ADDPOPUP)) {
- ShowWindow(GetDlgItem(hwndDlg, IDC_NOTIFY2), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_MSG_BOXES2), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_ERRORS2), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_INFO_MESSAGES2), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PROGR_DLG2), SW_HIDE);
- }
- else {
- for (int i = 1; i < POPUPS; i++) {
- mir_snprintf(str, SIZEOF(str), "Popups%dM", i);
- CheckDlgButton(hwndDlg, (i+1029), (DBGetContactSettingByte(NULL, MODNAME, str, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED: BST_UNCHECKED);
- }
- }
+ ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), opts.bPeriodMeasure);
+
+ CheckDlgButton(hwndDlg, IDC_REMINDER, opts.bReminder);
+ CheckDlgButton(hwndDlg, IDC_UPDATEICONS, opts.bUpdateIcons);
return TRUE;
case WM_COMMAND:
@@ -98,6 +85,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
+ case IDC_UPDATEICONS:
case IDC_REMINDER:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -111,14 +99,6 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
Options_Open(&ood);
}
return true;
-
- case IDC_MSG_BOXES2:
- case IDC_ERRORS2:
- case IDC_INFO_MESSAGES2:
- case IDC_PROGR_DLG2:
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
}
break;
@@ -129,32 +109,28 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
if (hdr && hdr->code == PSN_APPLY) {
- UpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP);
- OnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY);
+ opts.bUpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP);
+ opts.bOnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY);
- UpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);
+ opts.bUpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);
char buffer[3] = {0};
Edit_GetText(GetDlgItem(hwndDlg, IDC_PERIOD), (LPWSTR)&buffer, 2);
- Period = atoi(buffer);
+ opts.Period = atoi(buffer);
- PeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE));
+ opts.bPeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE));
InitTimer();
- DBWriteContactSettingByte(NULL, MODNAME, "UpdateOnStartup", UpdateOnStartup);
- DBWriteContactSettingByte(NULL, MODNAME, "OnlyOnceADay", OnlyOnceADay);
- DBWriteContactSettingByte(NULL, MODNAME, "UpdateOnPeriod", UpdateOnPeriod);
- DBWriteContactSettingDword(NULL, MODNAME, "Period", Period);
- DBWriteContactSettingByte(NULL, MODNAME, "PeriodMeasure", PeriodMeasure);
- Reminder = IsDlgButtonChecked(hwndDlg, IDC_REMINDER);
- DBWriteContactSettingByte(NULL, MODNAME, "Reminder", Reminder);
- if (!ServiceExists(MS_POPUP_ADDPOPUP)) {
- for (int i = 1; i < POPUPS; i++) {
- mir_snprintf(str, SIZEOF(str), "Popups%dM", i);
- DBWriteContactSettingByte(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hwndDlg, (i+1029))));
- }
- }
+ DBWriteContactSettingByte(NULL, MODNAME, "UpdateOnStartup", opts.bUpdateOnStartup);
+ DBWriteContactSettingByte(NULL, MODNAME, "OnlyOnceADay", opts.bOnlyOnceADay);
+ DBWriteContactSettingByte(NULL, MODNAME, "UpdateOnPeriod", opts.bUpdateOnPeriod);
+ DBWriteContactSettingByte(NULL, MODNAME, "PeriodMeasure", opts.bPeriodMeasure);
+ DBWriteContactSettingDword(NULL, MODNAME, "Period", opts.Period);
+ opts.bReminder = IsDlgButtonChecked(hwndDlg, IDC_REMINDER);
+ DBWriteContactSettingByte(NULL, MODNAME, "Reminder", opts.bReminder);
+ opts.bUpdateIcons = IsDlgButtonChecked(hwndDlg, IDC_UPDATEICONS);
+ DBWriteContactSettingByte(NULL, MODNAME, "UpdateIcons", opts.bUpdateIcons);
}
break;
}
@@ -172,17 +148,17 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
TranslateDialogDefault(hdlg);
//Colors
- if (MyOptions.DefColors == byCOLOR_OWN) {
+ if (PopupOptions.DefColors == byCOLOR_OWN) {
CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_CHECKED);
CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED);
}
- if (MyOptions.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);
}
- if (MyOptions.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);
@@ -192,20 +168,20 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
for (i = 1; i < POPUPS; i++) {
SendDlgItemMessage(hdlg, (i+42071), CPM_SETCOLOUR, 0, PopupsList[i].colorBack);
SendDlgItemMessage(hdlg, (i+41071), CPM_SETCOLOUR, 0, PopupsList[i].colorText);
- EnableWindow(GetDlgItem(hdlg, (i+42071)), (MyOptions.DefColors == byCOLOR_OWN));
- EnableWindow(GetDlgItem(hdlg, (i+41071)), (MyOptions.DefColors == byCOLOR_OWN));
+ EnableWindow(GetDlgItem(hdlg, (i+42071)), (PopupOptions.DefColors == byCOLOR_OWN));
+ EnableWindow(GetDlgItem(hdlg, (i+41071)), (PopupOptions.DefColors == byCOLOR_OWN));
}
//Timeout
SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE, EM_LIMITTEXT, 4, 0);
SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, -1, 9999);
- SetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, MyOptions.Timeout, TRUE);
+ SetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, PopupOptions.Timeout, TRUE);
//Mouse actions
for (i = 0; i < SIZEOF(PopupActions); i++) {
SendMessage(GetDlgItem(hdlg, IDC_LC), CB_SETITEMDATA, SendMessage(GetDlgItem(hdlg, IDC_LC), CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action);
SendMessage(GetDlgItem(hdlg, IDC_RC), CB_SETITEMDATA, SendMessage(GetDlgItem(hdlg, IDC_RC), CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action);
}
- SendDlgItemMessage(hdlg, IDC_LC, CB_SETCURSEL, MyOptions.LeftClickAction, 0);
- SendDlgItemMessage(hdlg, IDC_RC, CB_SETCURSEL, MyOptions.RightClickAction, 0);
+ SendDlgItemMessage(hdlg, IDC_LC, CB_SETCURSEL, PopupOptions.LeftClickAction, 0);
+ SendDlgItemMessage(hdlg, IDC_RC, CB_SETCURSEL, PopupOptions.RightClickAction, 0);
//Popups nitified
for (i = 0; i < POPUPS; i++) {
@@ -226,8 +202,8 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
}
else {
EnableWindow(GetDlgItem(hdlg, (40071)), TRUE);
- EnableWindow(GetDlgItem(hdlg, (41071)), (MyOptions.DefColors == byCOLOR_OWN));
- EnableWindow(GetDlgItem(hdlg, (42071)), (MyOptions.DefColors == byCOLOR_OWN));
+ EnableWindow(GetDlgItem(hdlg, (41071)), (PopupOptions.DefColors == byCOLOR_OWN));
+ EnableWindow(GetDlgItem(hdlg, (42071)), (PopupOptions.DefColors == byCOLOR_OWN));
}
return TRUE;
@@ -239,8 +215,8 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
}
else {
EnableWindow(GetDlgItem(hdlg, (40071)), TRUE);
- EnableWindow(GetDlgItem(hdlg, (41071)), (MyOptions.DefColors == byCOLOR_OWN));
- EnableWindow(GetDlgItem(hdlg, (42071)), (MyOptions.DefColors == byCOLOR_OWN));
+ EnableWindow(GetDlgItem(hdlg, (41071)), (PopupOptions.DefColors == byCOLOR_OWN));
+ EnableWindow(GetDlgItem(hdlg, (42071)), (PopupOptions.DefColors == byCOLOR_OWN));
}
return TRUE;
@@ -263,9 +239,9 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
if (wNotifyCode == CBN_SELCHANGE) {
if (idCtrl == IDC_LC)
- MyOptions.LeftClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_LC, CB_GETCURSEL, 0, 0);
+ PopupOptions.LeftClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_LC, CB_GETCURSEL, 0, 0);
else if(idCtrl == IDC_RC)
- MyOptions.RightClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_RC, CB_GETCURSEL, 0, 0);
+ PopupOptions.RightClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_RC, CB_GETCURSEL, 0, 0);
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
return TRUE;
@@ -275,7 +251,7 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
if (wNotifyCode != BN_CLICKED)
break;
- MyOptions.DefColors = byCOLOR_OWN;
+ PopupOptions.DefColors = byCOLOR_OWN;
if ( !(DBGetContactSettingDword(NULL, "PopUp", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS)) {
EnableWindow(GetDlgItem(hdlg, (41071)), FALSE);
@@ -297,7 +273,7 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
break;
//Use Windows colors
- MyOptions.DefColors = byCOLOR_WINDOWS;
+ PopupOptions.DefColors = byCOLOR_WINDOWS;
for (i = 0; i < POPUPS; i++) {
EnableWindow(GetDlgItem(hdlg, (i+42071)), FALSE); //Background
EnableWindow(GetDlgItem(hdlg, (i+41071)), FALSE); //Text
@@ -310,7 +286,7 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
break;
//Use Popup colors
- MyOptions.DefColors = byCOLOR_POPUP;
+ PopupOptions.DefColors = byCOLOR_POPUP;
for (i = 0; i < POPUPS; i++) {
EnableWindow(GetDlgItem(hdlg, (i+42071)), FALSE); //Background
EnableWindow(GetDlgItem(hdlg, (i+41071)), FALSE); //Text
@@ -385,14 +361,14 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
DBWriteContactSettingDword(NULL, MODNAME, szSetting, ctlColor);
}
//Colors
- DBWriteContactSettingByte(NULL, MODNAME, "DefColors", MyOptions.DefColors);
+ DBWriteContactSettingByte(NULL, MODNAME, "DefColors", PopupOptions.DefColors);
//Timeout
- MyOptions.Timeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, 0, TRUE);
- DBWriteContactSettingDword(NULL, MODNAME, "Timeout", MyOptions.Timeout);
+ PopupOptions.Timeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, 0, TRUE);
+ DBWriteContactSettingDword(NULL, MODNAME, "Timeout", PopupOptions.Timeout);
//Left mouse click
- DBWriteContactSettingByte(NULL, MODNAME, "LeftClickAction", MyOptions.LeftClickAction);
+ DBWriteContactSettingByte(NULL, MODNAME, "LeftClickAction", PopupOptions.LeftClickAction);
//Right mouse click
- DBWriteContactSettingByte(NULL, MODNAME, "RightClickAction", MyOptions.RightClickAction);
+ DBWriteContactSettingByte(NULL, MODNAME, "RightClickAction", PopupOptions.RightClickAction);
//Notified popups
for (i = 0; i < POPUPS; i++) {
mir_snprintf(str, SIZEOF(str), "Popups%d", i);
diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp
index 73bcee1e13..19cf80e0e7 100644
--- a/plugins/PluginUpdater/src/PluginUpdater.cpp
+++ b/plugins/PluginUpdater/src/PluginUpdater.cpp
@@ -87,6 +87,18 @@ extern "C" __declspec(dllexport) int Load(void)
mi.pszService = MODNAME"/EmptyFolder";
Menu_AddMainMenuItem(&mi);
+ // Add hotkey
+ HOTKEYDESC hkd = {0};
+ hkd.cbSize = sizeof(hkd);
+ hkd.dwFlags = HKD_TCHAR;
+ hkd.pszName = "Check for plugin updates";
+ hkd.ptszDescription = _T("Check for plugin updates");
+ hkd.ptszSection = _T("Plugin Updater");
+ hkd.pszService = MODNAME"/CheckUpdates";
+ hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F10) | HKF_MIRANDA_LOCAL;
+ hkd.lParam = FALSE;
+ Hotkey_Register(&hkd);
+
// Add options hook
HookEvent(ME_OPT_INITIALISE, OptInit);
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
diff --git a/plugins/PluginUpdater/src/Scanner.cpp b/plugins/PluginUpdater/src/Scanner.cpp
index 9edd0b69d5..929999c80b 100644
--- a/plugins/PluginUpdater/src/Scanner.cpp
+++ b/plugins/PluginUpdater/src/Scanner.cpp
@@ -103,7 +103,7 @@ static void ScanFolder(const TCHAR* tszFolder, const TCHAR* tszBaseUrl, hashMap&
static void __stdcall LaunchDialog(void* param)
{
- DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE), GetDesktopWindow(), DlgUpdate, (LPARAM)param);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_UPDATE), GetDesktopWindow(), DlgUpdate, (LPARAM)param);
}
static void CheckUpdates(void *)
@@ -115,9 +115,6 @@ static void CheckUpdates(void *)
if (!Exists(tszRoot))
CreateDirectoryTreeT(tszRoot);
- //Files.clear();
- Reminder = DBGetContactSettingByte(NULL, MODNAME, "Reminder", DEFAULT_REMINDER);
-
// Load files info
if (DBGetContactSettingTString(NULL, MODNAME, "UpdateURL", &dbVar)) { // URL is not set
DBWriteContactSettingTString(NULL, MODNAME, "UpdateURL", _T(DEFAULT_UPDATE_URL));
@@ -127,17 +124,16 @@ static void CheckUpdates(void *)
DBFreeVariant(&dbVar);
// Download version info
- FILEURL *pFileUrl = (FILEURL *)mir_alloc(sizeof(*pFileUrl));
- mir_sntprintf(pFileUrl->tszDownloadURL, SIZEOF(pFileUrl->tszDownloadURL), _T("%s/hashes.txt"), tszBaseUrl);
+ FILEURL pFileUrl;
+ mir_sntprintf(pFileUrl.tszDownloadURL, SIZEOF(pFileUrl.tszDownloadURL), _T("%s/hashes.txt"), tszBaseUrl);
mir_sntprintf(tszBuff, SIZEOF(tszBuff), _T("%s\\tmp.ini"), tszRoot);
- lstrcpyn(pFileUrl->tszDiskPath, tszBuff, SIZEOF(pFileUrl->tszDiskPath));
+ lstrcpyn(pFileUrl.tszDiskPath, tszBuff, SIZEOF(pFileUrl.tszDiskPath));
lstrcpyn(tszTmpIni, tszBuff, SIZEOF(tszTmpIni));
- PopupDataText temp;
- temp.Title = TranslateT("Plugin Updater");
- temp.Text = TranslateT("Downloading version info...");
- DlgDownloadProc(pFileUrl, temp);
- mir_free(pFileUrl);
- if (!DlgDld) {
+
+ ShowPopup(NULL, TranslateT("Plugin Updater"), TranslateT("Downloading version info..."), 3, 0);
+
+ if (!DownloadFile(pFileUrl.tszDownloadURL, pFileUrl.tszDiskPath)) {
+ ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("An error occured while downloading the update."), 1, 0);
CheckThread = NULL;
return;
}
@@ -169,7 +165,7 @@ static void CheckUpdates(void *)
// Show dialog
if (UpdateFiles->size() == 0) {
- if ( !Silent)
+ if ( !opts.bSilent)
ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("No updates found."), 2, 0);
}
else CallFunctionAsync(LaunchDialog, UpdateFiles);
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp
index bbce5de63d..2f1e0b17b5 100644
--- a/plugins/PluginUpdater/src/Utils.cpp
+++ b/plugins/PluginUpdater/src/Utils.cpp
@@ -22,14 +22,11 @@ Boston, MA 02111-1307, USA.
//vector<FILEINFO> Files;
BOOL DlgDld;
INT /*CurrentFile = 0,*/ Number = 0;
-BYTE Reminder, AutoUpdate;
-BYTE UpdateOnStartup, UpdateOnPeriod, OnlyOnceADay, PeriodMeasure;
-INT Period;
TCHAR tszDialogMsg[2048] = {0};
FILEINFO* pFileInfo = NULL;
//FILEURL* pFileUrl = NULL;
HANDLE CheckThread = NULL, hNetlibUser = NULL;
-MYOPTIONS MyOptions = {0};
+POPUP_OPTIONS PopupOptions = {0};
aPopups PopupsList[POPUPS];
struct
@@ -113,16 +110,18 @@ VOID InitPopupList()
VOID LoadOptions()
{
- MyOptions.DefColors = DBGetContactSettingByte(NULL, MODNAME, "DefColors", DEFAULT_COLORS);
- MyOptions.LeftClickAction= DBGetContactSettingByte(NULL, MODNAME, "LeftClickAction", DEFAULT_POPUP_LCLICK);
- MyOptions.RightClickAction = DBGetContactSettingByte(NULL, MODNAME, "RightClickAction", DEFAULT_POPUP_RCLICK);
- MyOptions.Timeout = DBGetContactSettingDword(NULL, MODNAME, "Timeout", DEFAULT_TIMEOUT_VALUE);
- UpdateOnStartup = DBGetContactSettingByte(NULL, MODNAME, "UpdateOnStartup", DEFAULT_UPDATEONSTARTUP);
- OnlyOnceADay = DBGetContactSettingByte(NULL, MODNAME, "OnlyOnceADay", DEFAULT_ONLYONCEADAY);
- UpdateOnPeriod = DBGetContactSettingByte(NULL, MODNAME, "UpdateOnPeriod", DEFAULT_UPDATEONPERIOD);
- Period = DBGetContactSettingDword(NULL, MODNAME, "Period", DEFAULT_PERIOD);
- PeriodMeasure = DBGetContactSettingByte(NULL, MODNAME, "PeriodMeasure", DEFAULT_PERIODMEASURE);
- Reminder = DBGetContactSettingByte(NULL, MODNAME, "Reminder", DEFAULT_REMINDER);
+ PopupOptions.DefColors = DBGetContactSettingByte(NULL, MODNAME, "DefColors", DEFAULT_COLORS);
+ PopupOptions.LeftClickAction= DBGetContactSettingByte(NULL, MODNAME, "LeftClickAction", DEFAULT_POPUP_LCLICK);
+ PopupOptions.RightClickAction = DBGetContactSettingByte(NULL, MODNAME, "RightClickAction", DEFAULT_POPUP_RCLICK);
+ PopupOptions.Timeout = DBGetContactSettingDword(NULL, MODNAME, "Timeout", DEFAULT_TIMEOUT_VALUE);
+
+ opts.bUpdateOnStartup = DBGetContactSettingByte(NULL, MODNAME, "UpdateOnStartup", DEFAULT_UPDATEONSTARTUP);
+ opts.bOnlyOnceADay = DBGetContactSettingByte(NULL, MODNAME, "OnlyOnceADay", DEFAULT_ONLYONCEADAY);
+ opts.bUpdateOnPeriod = DBGetContactSettingByte(NULL, MODNAME, "UpdateOnPeriod", DEFAULT_UPDATEONPERIOD);
+ opts.Period = DBGetContactSettingDword(NULL, MODNAME, "Period", DEFAULT_PERIOD);
+ opts.bPeriodMeasure = DBGetContactSettingByte(NULL, MODNAME, "PeriodMeasure", DEFAULT_PERIODMEASURE);
+ opts.bReminder = DBGetContactSettingByte(NULL, MODNAME, "Reminder", DEFAULT_REMINDER);
+ opts.bUpdateIcons = DBGetContactSettingByte(NULL, MODNAME, "UpdateIcons", DEFAULT_UPDATEICONS);
}
BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
@@ -181,7 +180,7 @@ VOID __stdcall RestartMe(void*)
BOOL AllowUpdateOnStartup()
{
- if (OnlyOnceADay) {
+ if (opts.bOnlyOnceADay) {
time_t now = time(NULL);
time_t was = DBGetContactSettingDword(NULL, MODNAME, "LastUpdate", 0);
@@ -218,8 +217,8 @@ VOID CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHig
VOID InitTimer()
{
CancelWaitableTimer(Timer);
- if (UpdateOnPeriod) {
- LONG interval = PeriodToMilliseconds(Period, PeriodMeasure);
+ if (opts.bUpdateOnPeriod) {
+ LONG interval = PeriodToMilliseconds(opts.Period, opts.bPeriodMeasure);
_int64 qwDueTime = -10000i64 * interval;
diff --git a/plugins/PluginUpdater/src/resource.h b/plugins/PluginUpdater/src/resource.h
index 7e71315760..46d86396f2 100644
--- a/plugins/PluginUpdater/src/resource.h
+++ b/plugins/PluginUpdater/src/resource.h
@@ -4,7 +4,6 @@
//
#define IDI_MENU 101
#define IDD_UPDATE 102
-#define IDD_DOWNLOAD 103
#define IDD_OPT_UPDATENOTIFY 104
#define IDD_POPUP 105
#define IDD_POPUPDUMMI 106
@@ -40,13 +39,8 @@
#define IDC_ERRORS_MSG 1025
#define IDC_INFO_MESSAGES_MSG 1026
#define IDC_PROGR_DLG_MSG 1027
-#define IDC_SYSLINK1 1028
#define IDC_LINK_HOTKEY 1028
-#define IDC_MSG_BOXES2 1029
-#define IDC_ERRORS2 1030
-#define IDC_INFO_MESSAGES2 1031
-#define IDC_PROGR_DLG2 1032
-#define IDC_NOTIFY2 1033
+#define IDC_UPDATEICONS 1029
#define IDC_NOTIFY 1034
#define IDC_UPDATEONSTARTUP 1035
#define IDC_ONLYONCEADAY 1036
diff --git a/plugins/PluginUpdater/src/unzipfile.cpp b/plugins/PluginUpdater/src/unzipfile.cpp
index 2cbfdca5d7..fcafc5b17c 100644
--- a/plugins/PluginUpdater/src/unzipfile.cpp
+++ b/plugins/PluginUpdater/src/unzipfile.cpp
@@ -37,28 +37,8 @@ bool extractCurrentFile(unzFile uf, TCHAR* ptszDestPath, TCHAR* ptszBackPath)
if (err != UNZ_OK)
return false;
- // Get Unicode file name for InfoZip style archives, otherwise assume PKZip/WinZip style
- if (file_info.size_file_extra)
- {
- char *p = buf;
- unsigned long size = min(file_info.size_file_extra, sizeof(buf));
- while (size > 0)
- {
- unsigned short id = *(unsigned short*)p;
- unsigned len = *(unsigned short*)(p + 2);
-
- if (size < (len + 4)) break;
-
- if (id == 0x7075 && len > 5 && (len - 5) < sizeof(filename) && *(p + 4) == 1)
- {
- memcpy(filename, p + 9, len - 5);
- filename[len - 5] = 0;
- break;
- }
- size -= len + 4;
- p += len + 4;
- }
- }
+ if (!opts.bUpdateIcons && !_strnicmp(filename, "Icons/", 6))
+ return true;
TCHAR tszDestFile[MAX_PATH], tszBackFile[MAX_PATH];
TCHAR* p = mir_utf8decodeT(filename);