summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/PackUpdater/Src/Events.cpp2
-rw-r--r--plugins/PackUpdater/Src/Notifications.cpp18
-rw-r--r--plugins/PackUpdater/Src/Options.cpp281
-rw-r--r--plugins/PackUpdater/Src/Utils.cpp198
-rw-r--r--plugins/PackUpdater/Src/Version.h24
5 files changed, 234 insertions, 289 deletions
diff --git a/plugins/PackUpdater/Src/Events.cpp b/plugins/PackUpdater/Src/Events.cpp
index f1fd530493..8ee03c1e30 100644
--- a/plugins/PackUpdater/Src/Events.cpp
+++ b/plugins/PackUpdater/Src/Events.cpp
@@ -79,4 +79,4 @@ INT OnPreShutdown(WPARAM wParam, LPARAM lParam)
UnhookEvent(hOptHook);
UnhookEvent(hOnPreShutdown);
return 0;
-} \ No newline at end of file
+}
diff --git a/plugins/PackUpdater/Src/Notifications.cpp b/plugins/PackUpdater/Src/Notifications.cpp
index 93c345560e..acbd27badf 100644
--- a/plugins/PackUpdater/Src/Notifications.cpp
+++ b/plugins/PackUpdater/Src/Notifications.cpp
@@ -249,8 +249,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_NORECOMPUTE;// | LVIF_IMAGE;
vector<FILEINFO> &todo = *(vector<FILEINFO> *)lParam;
- for (int i = 0; i < (int)todo.size(); ++i)
- {
+ for (int i = 0; i < (int)todo.size(); ++i) {
lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_IMAGE;
lvI.iSubItem = 0;
lvI.lParam = (LPARAM)&todo[i];
@@ -421,7 +420,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
INT rc = -1;
Title = TranslateT("Pack Updater");
Text = tszBuff;
- if ( ServiceExists(MS_POPUP_ADDPOPUP) && ServiceExists(MS_POPUP_REGISTERACTIONS) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL,MODNAME, "Popups0", DEFAULT_POPUP_ENABLED) && (db_get_dw(NULL, "Popup", "Actions", 0) & 1))
+ if (ServiceExists(MS_POPUP_ADDPOPUP) && ServiceExists(MS_POPUP_REGISTERACTIONS) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL,MODNAME, "Popups0", DEFAULT_POPUP_ENABLED) && (db_get_dw(NULL, "Popup", "Actions", 0) & 1))
rc = DialogBox(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), NULL, DlgMsgPop);
else
rc = MessageBox(NULL, tszBuff, Title, MB_YESNO | MB_ICONQUESTION);
@@ -430,6 +429,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
TCHAR* tszUtilRootPlug = NULL;
TCHAR* tszUtilRootIco = NULL;
TCHAR* tszUtilRoot = NULL;
+ TCHAR tszCurrentDir[MAX_PATH];
switch (arFileType[i]) {
case 0:
@@ -440,7 +440,12 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
memset(&si, 0, sizeof(STARTUPINFO));
memset(&pi, 0, sizeof(PROCESS_INFORMATION));
si.cb = sizeof(STARTUPINFO);
- CreateProcess(arFilePath[i].c_str(), _T(""), NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi);
+ {
+ _tcsncpy_s(tszCurrentDir, SIZEOF(tszCurrentDir), arFilePath[i].c_str(), _TRUNCATE);
+ TCHAR *p = _tcsrchr(tszCurrentDir, '\\');
+ if (p) *p = 0;
+ }
+ CreateProcess(arFilePath[i].c_str(), _T(""), NULL, NULL, FALSE, NULL, NULL, tszCurrentDir, &si, &pi);
i = UpdatesCount;
CallFunctionAsync(ExitMe, 0);
break;
@@ -503,8 +508,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
mir_sntprintf(tszBuff, SIZEOF(tszBuff), TranslateT("You have chosen not to install the pack update immediately.\nYou can install it manually from this location:\n\n%s"), arFilePath[0].c_str());
Title = TranslateT("Pack Updater");
Text = tszBuff;
- if ( ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED))
- {
+ if (ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) {
Number = 2;
show_popup(0, Title, Text, Number, 0);
}
@@ -545,4 +549,4 @@ INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
ShowWindow(hDlg, SW_HIDE);
return FALSE;
-} \ No newline at end of file
+}
diff --git a/plugins/PackUpdater/Src/Options.cpp b/plugins/PackUpdater/Src/Options.cpp
index 8781c25601..0ad1cd2599 100644
--- a/plugins/PackUpdater/Src/Options.cpp
+++ b/plugins/PackUpdater/Src/Options.cpp
@@ -161,35 +161,30 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- WORD i = 0;
+ int i;
+ WORD idCtrl;
char str[20] = {0}, str2[20] = {0};
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
TranslateDialogDefault(hdlg);
//Colors
- if (MyOptions.DefColors == byCOLOR_OWN)
- {
+ if (MyOptions.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 (MyOptions.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 (MyOptions.DefColors == byCOLOR_POPUP) {
CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_CHECKED);
CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED);
}
- for (i = 0; i < POPUPS; i++)
- {
+ for (i = 0; i < POPUPS; i++) {
SendDlgItemMessage(hdlg, (i+42071), CPM_SETCOLOUR, 0, PopupsList[i].colorBack);
SendDlgItemMessage(hdlg, (i+41071), CPM_SETCOLOUR, 0, PopupsList[i].colorText);
EnableWindow(GetDlgItem(hdlg, (i+42071)), (MyOptions.DefColors == byCOLOR_OWN));
@@ -200,16 +195,14 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, -1, 9999);
SetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, MyOptions.Timeout, TRUE);
//Mouse actions
- for (i = 0; i < SIZEOF(PopupActions); i++)
- {
+ 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);
//Popups nitified
- for (i = 0; i < POPUPS; i++)
- {
+ for (i = 0; i < POPUPS; i++) {
mir_snprintf(str, SIZEOF(str), "Popups%d", i);
mir_snprintf(str2, SIZEOF(str2), "Popups%dM", i);
CheckDlgButton(hdlg, (i+40071), (db_get_b(NULL, MODNAME, str, DEFAULT_POPUP_ENABLED)) ? BST_CHECKED: BST_UNCHECKED);
@@ -225,21 +218,18 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
EnableWindow(GetDlgItem(hdlg, (40071)), TRUE);
return TRUE;
- }
+
case WM_SHOWWINDOW:
if (!(db_get_dw(NULL, "Popup", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS))
EnableWindow(GetDlgItem(hdlg, (40071)), FALSE);
else
EnableWindow(GetDlgItem(hdlg, (40071)), TRUE);
-
return TRUE;
+
case WM_COMMAND:
- {
- WORD idCtrl = LOWORD(wParam), wNotifyCode = HIWORD(wParam);
- if (wNotifyCode == CPN_COLOURCHANGED)
- {
- if(idCtrl > 40070)
- {
+ idCtrl = LOWORD(wParam);
+ if (HIWORD(wParam) == CPN_COLOURCHANGED) {
+ if(idCtrl > 40070) {
//It's a color picker change. idCtrl is the control id.
COLORREF color = SendDlgItemMessage(hdlg, idCtrl, CPM_GETCOLOUR, 0, 0);
int ctlID = idCtrl;
@@ -251,171 +241,146 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
return TRUE;
}
}
- if (wNotifyCode == CBN_SELCHANGE)
- {
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
if (idCtrl == IDC_LC)
- {
MyOptions.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);
- }
+
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
return TRUE;
}
- switch(idCtrl)
- {
- case IDC_USEOWNCOLORS:
- {
- BOOL bEnableOthers = FALSE;
- if (wNotifyCode != BN_CLICKED)
- break;
+
+ switch(idCtrl) {
+ case IDC_USEOWNCOLORS:
+ if (HIWORD(wParam) == BN_CLICKED) {
MyOptions.DefColors = byCOLOR_OWN;
- bEnableOthers = TRUE;
- for (i = 0; i < POPUPS; i++)
- {
+ BOOL bEnableOthers = TRUE;
+ for (i = 0; i < POPUPS; i++) {
EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background
EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text
}
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
}
- case IDC_USEWINCOLORS:
- {
- BOOL bEnableOthers = FALSE;
- if (wNotifyCode != BN_CLICKED)
- break;
+ break;
+ case IDC_USEWINCOLORS:
+ if (HIWORD(wParam) == BN_CLICKED) {
//Use Windows colors
MyOptions.DefColors = byCOLOR_WINDOWS;
- bEnableOthers = FALSE;
- for (i = 0; i < POPUPS; i++)
- {
+ BOOL bEnableOthers = FALSE;
+ for (i = 0; i < POPUPS; i++) {
EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background
EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text
}
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
}
- case IDC_USEPOPUPCOLORS:
- {
- BOOL bEnableOthers = FALSE;
- if (wNotifyCode != BN_CLICKED)
- break;
+ break;
+
+ case IDC_USEPOPUPCOLORS:
+ if (HIWORD(wParam) == BN_CLICKED) {
//Use Popup colors
MyOptions.DefColors = byCOLOR_POPUP;
- bEnableOthers = FALSE;
- for (i = 0; i < POPUPS; i++)
- {
+ BOOL bEnableOthers = FALSE;
+ for (i = 0; i < POPUPS; i++) {
EnableWindow(GetDlgItem(hdlg, (i+42071)), bEnableOthers); //Background
EnableWindow(GetDlgItem(hdlg, (i+41071)), bEnableOthers); //Text
}
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
- }
- case IDC_PREVIEW:
- {//Declarations and initializations
- Title = TranslateT("Pack Updater");
- Text = TranslateT("Test");
- for (int i = 0; i < POPUPS; i++)
- {
- if ((!IsDlgButtonChecked(hdlg, (i+40071))) || (!IsWindowEnabled(GetDlgItem(hdlg, (i+40071)))))
- continue;
- show_popup(0, Title, Text, i, 0);
- }
- break;
- }
- case IDC_TIMEOUT_VALUE:
- case IDC_MSG_BOXES:
- case IDC_ERRORS:
- {
- if (!IsDlgButtonChecked(hdlg, IDC_ERRORS))
- EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), TRUE);
- else
- EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), FALSE);
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
- }
- case IDC_INFO_MESSAGES:
- {
- if (!IsDlgButtonChecked(hdlg, IDC_INFO_MESSAGES))
- EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), TRUE);
- else
- EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), FALSE);
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
}
- case IDC_PROGR_DLG:
- {
- if (!IsDlgButtonChecked(hdlg, IDC_PROGR_DLG))
- EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), TRUE);
- else
- EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), FALSE);
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
+ break;
+
+ case IDC_PREVIEW:
+ Title = TranslateT("Pack Updater");
+ Text = TranslateT("Test");
+ for (int i = 0; i < POPUPS; i++) {
+ if ((!IsDlgButtonChecked(hdlg, (i+40071))) || (!IsWindowEnabled(GetDlgItem(hdlg, (i+40071)))))
+ continue;
+ show_popup(0, Title, Text, i, 0);
}
- case IDC_MSG_BOXES_MSG:
- case IDC_ERRORS_MSG:
- case IDC_INFO_MESSAGES_MSG:
- case IDC_PROGR_DLG_MSG:
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
break;
- }//end* switch(idCtrl)
+
+ case IDC_TIMEOUT_VALUE:
+ case IDC_MSG_BOXES:
+ case IDC_ERRORS:
+ if (!IsDlgButtonChecked(hdlg, IDC_ERRORS))
+ EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), TRUE);
+ else
+ EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), FALSE);
+ if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_INFO_MESSAGES:
+ if (!IsDlgButtonChecked(hdlg, IDC_INFO_MESSAGES))
+ EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), TRUE);
+ else
+ EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), FALSE);
+ if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_PROGR_DLG:
+ if (!IsDlgButtonChecked(hdlg, IDC_PROGR_DLG))
+ EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), TRUE);
+ else
+ EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), FALSE);
+ if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_MSG_BOXES_MSG:
+ case IDC_ERRORS_MSG:
+ case IDC_INFO_MESSAGES_MSG:
+ case IDC_PROGR_DLG_MSG:
+ if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+ }
break;
- }//end* case WM_COMMAND:
+
case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_RESET:
- {
- //Restore the options stored in memory.
- LoadOptions();
- InitPopupList();
- return TRUE;
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_RESET:
+ //Restore the options stored in memory.
+ LoadOptions();
+ InitPopupList();
+ return TRUE;
+
+ case PSN_APPLY:
+ //Text color
+ char szSetting[20] = {0};
+ DWORD ctlColor = 0;
+ for (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);
+ db_set_dw(NULL, MODNAME, szSetting, ctlColor);
+ ctlColor = SendDlgItemMessage(hdlg, (i+41071), CPM_GETCOLOUR, 0, 0);
+ PopupsList[i].colorText = ctlColor;
+ mir_snprintf(szSetting, SIZEOF(szSetting), "Popups%iTx", i);
+ db_set_dw(NULL, MODNAME, szSetting, ctlColor);
}
- case PSN_APPLY:
- {
- //Text color
- char szSetting[20] = {0};
- DWORD ctlColor = 0;
- for (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);
- db_set_dw(NULL, MODNAME, szSetting, ctlColor);
- ctlColor = SendDlgItemMessage(hdlg, (i+41071), CPM_GETCOLOUR, 0, 0);
- PopupsList[i].colorText = ctlColor;
- mir_snprintf(szSetting, SIZEOF(szSetting), "Popups%iTx", i);
- db_set_dw(NULL, MODNAME, szSetting, ctlColor);
- }
- //Colors
- db_set_b(NULL, MODNAME, "DefColors", MyOptions.DefColors);
- //Timeout
- MyOptions.Timeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, 0, TRUE);
- db_set_dw(NULL, MODNAME, "Timeout", MyOptions.Timeout);
- //Left mouse click
- db_set_b(NULL, MODNAME, "LeftClickAction", MyOptions.LeftClickAction);
- //Right mouse click
- db_set_b(NULL, MODNAME, "RightClickAction", MyOptions.RightClickAction);
- //Notified popups
- for (i = 0; i < POPUPS; i++)
- {
- mir_snprintf(str, SIZEOF(str), "Popups%d", i);
- db_set_b(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hdlg, (i+40071))));
- mir_snprintf(str2, SIZEOF(str2), "Popups%dM", i);
- db_set_b(NULL, MODNAME, str2, (BYTE)(IsDlgButtonChecked(hdlg, (i+1024))));
- }
- return TRUE;
- } //case PSN_APPLY
- } // switch code
- break; //End WM_NOTIFY
- } //switch message
-return FALSE;
+ //Colors
+ db_set_b(NULL, MODNAME, "DefColors", MyOptions.DefColors);
+ //Timeout
+ MyOptions.Timeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, 0, TRUE);
+ db_set_dw(NULL, MODNAME, "Timeout", MyOptions.Timeout);
+ //Left mouse click
+ db_set_b(NULL, MODNAME, "LeftClickAction", MyOptions.LeftClickAction);
+ //Right mouse click
+ db_set_b(NULL, MODNAME, "RightClickAction", MyOptions.RightClickAction);
+ //Notified popups
+ for (i = 0; i < POPUPS; i++) {
+ mir_snprintf(str, SIZEOF(str), "Popups%d", i);
+ db_set_b(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hdlg, (i+40071))));
+ mir_snprintf(str2, SIZEOF(str2), "Popups%dM", i);
+ db_set_b(NULL, MODNAME, str2, (BYTE)(IsDlgButtonChecked(hdlg, (i+1024))));
+ }
+ return TRUE;
+ }
+ break; //End WM_NOTIFY
+ }
+ return FALSE;
}
int OptInit(WPARAM wParam, LPARAM lParam)
@@ -438,4 +403,4 @@ int OptInit(WPARAM wParam, LPARAM lParam)
Options_AddPage(wParam, &odp);
}
return 0;
-} \ No newline at end of file
+}
diff --git a/plugins/PackUpdater/Src/Utils.cpp b/plugins/PackUpdater/Src/Utils.cpp
index 27d9cac3c1..6c67bab25e 100644
--- a/plugins/PackUpdater/Src/Utils.cpp
+++ b/plugins/PackUpdater/Src/Utils.cpp
@@ -132,10 +132,8 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
NETLIBHTTPREQUEST* pReply = NULL;
pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser,(LPARAM)&nlhr);
- if (pReply)
- {
- if ((200 == pReply->resultCode) && (pReply->dataLength > 0))
- {
+ if (pReply) {
+ if (200 == pReply->resultCode && pReply->dataLength > 0) {
hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
ret = true;
@@ -198,12 +196,10 @@ static void CheckUpdates(void *)
// Load files info
db_get_ts(NULL, MODNAME, "File_VersionURL", &dbVar);
- if (lstrcmp(dbVar.ptszVal, NULL) == 0)// URL is not set
- {
+ if (lstrcmp(dbVar.ptszVal, NULL) == 0) { // URL is not set
Title=TranslateT("Pack Updater");
Text = TranslateT("URL for checking updates not found.");
- if ( ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED))
- {
+ if (ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED)) {
Number = 1;
show_popup(0, Title, Text, Number, 0);
}
@@ -223,36 +219,32 @@ static void CheckUpdates(void *)
Text = TranslateT("Downloading version info...");
DlgDownloadProc();
mir_free(pFileUrl);
- if (!DlgDld)
- {
+ if (!DlgDld) {
hCheckThread = NULL;
return;
}
- for (CurrentFile = 0; CurrentFile < FileCount; CurrentFile++)
- {
+ for (CurrentFile = 0; CurrentFile < FileCount; CurrentFile++) {
FILEINFO FileInfo = {_T(""), _T(""), _T(""), _T(""), _T(""), _T(""), _T(""), {_T(""), _T("")}};
dbVar.ptszVal = NULL;
mir_snprintf(szKey, SIZEOF(szKey), "File_%d_CurrentVersion", CurrentFile + 1);
db_get_ts(NULL, MODNAME, szKey, &dbVar);
- if (lstrcmp(dbVar.ptszVal, NULL) == 0)
- {
+ if (lstrcmp(dbVar.ptszVal, NULL) == 0) {
db_free(&dbVar);
lstrcpyn(FileInfo.tszCurVer, _T(""), SIZEOF(FileInfo.tszCurVer));
}
- else
- lstrcpyn(FileInfo.tszCurVer, dbVar.ptszVal, SIZEOF(FileInfo.tszCurVer));
+ else lstrcpyn(FileInfo.tszCurVer, dbVar.ptszVal, SIZEOF(FileInfo.tszCurVer));
+
dbVar.ptszVal = NULL;
mir_snprintf(szKey, SIZEOF(szKey), "File_%d_LastVersion", CurrentFile + 1);
db_get_ts(NULL, MODNAME, szKey, &dbVar);
- if (lstrcmp(dbVar.ptszVal, NULL) == 0)
- {
+ if (lstrcmp(dbVar.ptszVal, NULL) == 0) {
db_free(&dbVar);
lstrcpyn(FileInfo.tszLastVer, _T(""), SIZEOF(FileInfo.tszLastVer));
}
- else
- lstrcpyn(FileInfo.tszLastVer, dbVar.ptszVal, SIZEOF(FileInfo.tszLastVer));
+ else lstrcpyn(FileInfo.tszLastVer, dbVar.ptszVal, SIZEOF(FileInfo.tszLastVer));
+
Files.push_back(FileInfo);
// Read version info
@@ -264,12 +256,10 @@ static void CheckUpdates(void *)
GetPrivateProfileString(tszFileInfo, _T("Descr"), _T(""), Files[CurrentFile].tszDescr, SIZEOF(Files[CurrentFile].tszDescr), tszTmpIni);
GetPrivateProfileString(tszFileInfo, _T("DiskFileName"), _T(""), tszBuff, MAX_PATH, tszTmpIni);
- if (_tcsstr(tszBuff, _T("\\"))) //check update name
- {
+ if (_tcsstr(tszBuff, _T("\\"))) { //check update name
Title = TranslateT("Pack Updater");
Text = TranslateT("Name of Update's file is not supported.");
- if ( ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED))
- {
+ if ( ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED)) {
Number = 1;
show_popup(0, Title, Text, Number, 0);
}
@@ -283,8 +273,7 @@ static void CheckUpdates(void *)
Files[CurrentFile].Force = GetPrivateProfileInt(tszFileInfo, _T("Force"), 0, tszTmpIni);
Files[CurrentFile].FileNum = CurrentFile+1;
- if (Files[CurrentFile].FileType == 2)
- {
+ if (Files[CurrentFile].FileType == 2) {
TCHAR pluginFolgerName[MAX_PATH];
if (lstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0)
mir_sntprintf(tszBuff, SIZEOF(tszBuff), _T("Plugins\\%s"), Files[CurrentFile].File.tszDiskPath);
@@ -295,65 +284,61 @@ static void CheckUpdates(void *)
continue;
}
// Compare versions
- if (getVer(Files[CurrentFile].tszCurVer) < getVer(Files[CurrentFile].tszNewVer)) // Yeah, we've got new version.
- {
+ if (getVer(Files[CurrentFile].tszCurVer) < getVer(Files[CurrentFile].tszNewVer)) { // Yeah, we've got new version.
TCHAR* tszSysRoot = Utils_ReplaceVarsT(_T("%SystemRoot%"));
TCHAR* tszProgFiles = Utils_ReplaceVarsT(_T("%ProgramFiles%"));
- if (Files[CurrentFile].FileType != 1 && !IsUserAnAdmin() && (_tcsstr(tszRoot, tszSysRoot) || _tcsstr(tszRoot, tszProgFiles)))
- {
+ if (Files[CurrentFile].FileType != 1 && !IsUserAnAdmin() && (_tcsstr(tszRoot, tszSysRoot) || _tcsstr(tszRoot, tszProgFiles))) {
MessageBox(NULL, TranslateT("Update is not possible!\nYou have no Administrator's rights.\nPlease run Miranda NG with Administrator's rights."), Title, MB_ICONINFORMATION);
DeleteFile(tszTmpIni);
hCheckThread = NULL;
return;
} // user have not admin's rights
- else
- {
- //добавить проверку на существование файла
- TCHAR tszFilePathDest[MAX_PATH] = {0};
- TCHAR* tszUtilRootPlug = NULL;
- TCHAR* tszUtilRootIco = NULL;
- TCHAR* tszUtilRoot = NULL;
-
- switch (Files[CurrentFile].FileType)
- {
- case 0:
- case 1:
- break;
- case 2:
- tszUtilRootPlug = Utils_ReplaceVarsT(_T("%miranda_path%\\Plugins"));
- if (lstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0)
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRootPlug, Files[CurrentFile].File.tszDiskPath);
- else
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootPlug, Files[CurrentFile].tszAdvFolder, Files[CurrentFile].File.tszDiskPath);
- mir_free(tszUtilRootPlug);
- break;
- case 3:
- tszUtilRootIco = Utils_ReplaceVarsT(_T("%miranda_path%\\Icons"));
- if (lstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0)
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRootIco, Files[CurrentFile].File.tszDiskPath);
- else
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootIco, Files[CurrentFile].tszAdvFolder, Files[CurrentFile].File.tszDiskPath);
- mir_free(tszUtilRootIco);
- break;
- case 4:
- case 5:
- tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%"));
- if (lstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0)
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRoot, Files[CurrentFile].File.tszDiskPath);
- else
- mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRoot, Files[CurrentFile].tszAdvFolder, Files[CurrentFile].File.tszDiskPath);
- mir_free(tszUtilRoot);
- break;
- }//end* switch (Files[CurrentFile].FileType)
-
- if (Files[CurrentFile].Force || Exists(tszFilePathDest))
- UpdateFiles.push_back(Files[CurrentFile]);
- // Save last version
- lstrcpyn(Files[CurrentFile].tszLastVer, Files[CurrentFile].tszNewVer, SIZEOF(Files[CurrentFile].tszLastVer));
- mir_snprintf(szKey, SIZEOF(szKey), "File_%d_LastVersion", CurrentFile + 1);
- db_set_ts(NULL, MODNAME, szKey, Files[CurrentFile].tszLastVer);
- } // user have admin's rights
+
+ //добавить проверку на существование файла
+ TCHAR tszFilePathDest[MAX_PATH] = {0};
+ TCHAR* tszUtilRootPlug = NULL;
+ TCHAR* tszUtilRootIco = NULL;
+ TCHAR* tszUtilRoot = NULL;
+
+ switch (Files[CurrentFile].FileType) {
+ case 0:
+ case 1:
+ break;
+ case 2:
+ tszUtilRootPlug = Utils_ReplaceVarsT(_T("%miranda_path%\\Plugins"));
+ if (lstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0)
+ mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRootPlug, Files[CurrentFile].File.tszDiskPath);
+ else
+ mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootPlug, Files[CurrentFile].tszAdvFolder, Files[CurrentFile].File.tszDiskPath);
+ mir_free(tszUtilRootPlug);
+ break;
+ case 3:
+ tszUtilRootIco = Utils_ReplaceVarsT(_T("%miranda_path%\\Icons"));
+ if (lstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0)
+ mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRootIco, Files[CurrentFile].File.tszDiskPath);
+ else
+ mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootIco, Files[CurrentFile].tszAdvFolder, Files[CurrentFile].File.tszDiskPath);
+ mir_free(tszUtilRootIco);
+ break;
+ case 4:
+ case 5:
+ tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%"));
+ if (lstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0)
+ mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s"), tszUtilRoot, Files[CurrentFile].File.tszDiskPath);
+ else
+ mir_sntprintf(tszFilePathDest, SIZEOF(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRoot, Files[CurrentFile].tszAdvFolder, Files[CurrentFile].File.tszDiskPath);
+ mir_free(tszUtilRoot);
+ break;
+ }//end* switch (Files[CurrentFile].FileType)
+
+ if (Files[CurrentFile].Force || Exists(tszFilePathDest))
+ UpdateFiles.push_back(Files[CurrentFile]);
+ // Save last version
+ lstrcpyn(Files[CurrentFile].tszLastVer, Files[CurrentFile].tszNewVer, SIZEOF(Files[CurrentFile].tszLastVer));
+ mir_snprintf(szKey, SIZEOF(szKey), "File_%d_LastVersion", CurrentFile + 1);
+ db_set_ts(NULL, MODNAME, szKey, Files[CurrentFile].tszLastVer);
+
mir_free(tszSysRoot);
mir_free(tszProgFiles);
} // end compare versions
@@ -363,29 +348,26 @@ static void CheckUpdates(void *)
if (UpdateFiles.size()>0)
upd_ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE), GetDesktopWindow(), DlgUpdate, (LPARAM)&UpdateFiles);
DeleteFile(tszTmpIni);
- if (upd_ret == IDCANCEL)
- {
+ if (upd_ret == IDCANCEL) {
hCheckThread = NULL;
return;
}
- if (!UpdatesCount && !Silent)
- {
+
+ if (!UpdatesCount && !Silent) {
Title = TranslateT("Pack Updater");
Text = TranslateT("No updates found.");
- if ( ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED))
- {
+ if (ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) {
Number = 2;
show_popup(0, Title, Text, Number, 0);
}
else if (db_get_b(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED))
MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
}
- if (!FileCount)
- {
+
+ if (!FileCount) {
Title = TranslateT("Pack Updater");
Text = TranslateT("No files for update.");
- if ( ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED))
- {
+ if (ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) {
Number = 2;
show_popup(0, Title, Text, Number, 0);
}
@@ -397,20 +379,17 @@ static void CheckUpdates(void *)
void DoCheck(int iFlag)
{
- if (hCheckThread != NULL)
- {
+ if (hCheckThread != NULL) {
Title = TranslateT("Pack Updater");
Text = TranslateT("Update checking already started!");
- if ( ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED))
- {
+ if ( ServiceExists(MS_POPUP_ADDPOPUP) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) {
Number = 2;
show_popup(0, Title, Text, Number, 0);
}
else if (db_get_b(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED))
MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
}
- else if (iFlag)
- {
+ else if (iFlag) {
hCheckThread = mir_forkthread(CheckUpdates, 0);
db_set_dw(NULL, MODNAME, "LastUpdate", time(NULL));
}
@@ -418,8 +397,7 @@ void DoCheck(int iFlag)
BOOL AllowUpdateOnStartup()
{
- if(OnlyOnceADay)
- {
+ if(OnlyOnceADay) {
time_t now = time(NULL);
time_t was = db_get_dw(NULL, MODNAME, "LastUpdate", 0);
@@ -432,19 +410,18 @@ BOOL AllowUpdateOnStartup()
LONG PeriodToMilliseconds(const INT period, BYTE& periodMeasure)
{
LONG result = period * 1000;
- switch(periodMeasure)
- {
- case 1:
- // day
- result *= 60 * 60 * 24;
- break;
-
- default:
- // hour
- if(periodMeasure != 0)
- periodMeasure = 0;
- result *= 60 * 60;
- break;
+ switch(periodMeasure) {
+ case 1:
+ // day
+ result *= 60 * 60 * 24;
+ break;
+
+ default:
+ // hour
+ if(periodMeasure != 0)
+ periodMeasure = 0;
+ result *= 60 * 60;
+ break;
}
return result;
}
@@ -457,8 +434,7 @@ VOID CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHig
VOID InitTimer()
{
CancelWaitableTimer(Timer);
- if(UpdateOnPeriod)
- {
+ if(UpdateOnPeriod) {
LONG interval = PeriodToMilliseconds(Period, PeriodMeasure);
_int64 qwDueTime = -10000i64 * interval;
@@ -469,4 +445,4 @@ VOID InitTimer()
SetWaitableTimer(Timer, &li, interval, TimerAPCProc, NULL, 0);
}
-} \ No newline at end of file
+}
diff --git a/plugins/PackUpdater/Src/Version.h b/plugins/PackUpdater/Src/Version.h
index 8ce2d0b2d4..6f6f9f2cb2 100644
--- a/plugins/PackUpdater/Src/Version.h
+++ b/plugins/PackUpdater/Src/Version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 0
-#define __RELEASE_NUM 1
-#define __BUILD_NUM 1
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 1
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 1
-#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
-#define __PLUGIN_NAME "Pack updater"
-#define __FILENAME "PackUpdater.dll"
-#define __DESCRIPTION "Simple updater for Miranda NG premodified packs."
-#define __AUTHOR "Mataes, ZERO_BiT"
-#define __AUTHOREMAIL "mataes2007@gmail.com, zero-bit@mail.ru"
-#define __AUTHORWEB "http://miranda-ng.org/p/PackUpdater/"
-#define __COPYRIGHT "© 2011 Mataes, 2007 ZERO_BiT"
+#define __PLUGIN_NAME "Pack updater"
+#define __FILENAME "PackUpdater.dll"
+#define __DESCRIPTION "Simple updater for Miranda NG premodified packs."
+#define __AUTHOR "Mataes, ZERO_BiT"
+#define __AUTHOREMAIL "mataes2007@gmail.com, zero-bit@mail.ru"
+#define __AUTHORWEB "http://miranda-ng.org/p/PackUpdater/"
+#define __COPYRIGHT "© 2011 Mataes, 2007 ZERO_BiT"