diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2012-06-14 19:02:53 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2012-06-14 19:02:53 +0000 |
commit | 37f6d368b6214799b74dbc6050db106cb9df68af (patch) | |
tree | d3fead3b41a428b864a0731cfed8903a4bfe82dc /plugins/PackUpdater/Src | |
parent | e1cfabdac8f9fba8d4e31e76a076bca5b067d667 (diff) |
PackUpdater sync:
added checking schedule (Unsane patch)
git-svn-id: http://svn.miranda-ng.org/main/trunk@417 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/PackUpdater/Src')
-rw-r--r-- | plugins/PackUpdater/Src/Common.h | 30 | ||||
-rw-r--r-- | plugins/PackUpdater/Src/Events.cpp | 11 | ||||
-rw-r--r-- | plugins/PackUpdater/Src/Notifications.cpp | 72 | ||||
-rw-r--r-- | plugins/PackUpdater/Src/Options.cpp | 129 | ||||
-rw-r--r-- | plugins/PackUpdater/Src/PackUpdater.cpp | 7 | ||||
-rw-r--r-- | plugins/PackUpdater/Src/Utils.cpp | 80 |
6 files changed, 237 insertions, 92 deletions
diff --git a/plugins/PackUpdater/Src/Common.h b/plugins/PackUpdater/Src/Common.h index 93771cd138..fa180a6e78 100644 --- a/plugins/PackUpdater/Src/Common.h +++ b/plugins/PackUpdater/Src/Common.h @@ -20,19 +20,15 @@ Boston, MA 02111-1307, USA. #define MIRANDA_VER 0x0A00
// Windows Header Files:
+#include <time.h>
#include <stdio.h>
#include <windows.h>
-#include <deque>
-#include "Wininet.h"
-#include "Urlmon.h"
-#include <prsht.h>
-#include <string>
-#include <commctrl.h>
-#include "win2k.h"
+#include <Windowsx.h>
#include "vector" // stl vector header
#include <Shlobj.h>
// Miranda header files
+#include "win2k.h"
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_skin.h>
@@ -41,13 +37,14 @@ Boston, MA 02111-1307, USA. #include <m_database.h>
#include <m_utils.h>
#include <m_system.h>
-#include <m_folders.h>
#include <m_popup.h>
#include <m_hotkeys.h>
-#include "m_popup2.h"
#include <m_netlib.h>
#include <m_icolib.h>
+#include <m_folders.h>
+#include "m_popup2.h"
+
#include "..\version.h"
#include "..\resource.h"
#include "Notifications.h"
@@ -95,7 +92,11 @@ struct PackUpdaterIconList };
#define DEFAULT_REMINDER 1
-#define DEFAULT_AUTOUPDATE 1
+#define DEFAULT_UPDATEONSTARTUP 1
+#define DEFAULT_ONLYONCEADAY 0
+#define DEFAULT_UPDATEONPERIOD 0
+#define DEFAULT_PERIOD 1
+#define DEFAULT_PERIODMEASURE 1
#define DEFAULT_FILECOUNT 0
#define DEFAULT_FILETYPE 0 //0 - not defined, 1 - pack, 2 - plugin, 3 - icon, 4 - files in miranda root (e.g. langpack, dbtool), 5 - same as 4 without restart
@@ -107,9 +108,9 @@ using std::wstring; using namespace std;
extern HINSTANCE hInst;
-extern INT FileCount, CurrentFile, Number, UpdatesCount;
+extern INT FileCount, CurrentFile, Number, UpdatesCount, Period;
extern BOOL Silent, DlgDld;
-extern BYTE Reminder, AutoUpdate;
+extern BYTE Reminder, UpdateOnStartup, UpdateOnPeriod, OnlyOnceADay, PeriodMeasure;
extern TCHAR tszRoot[MAX_PATH], tszDialogMsg[2048];
extern FILEINFO* pFileInfo;
extern FILEURL* pFileUrl;
@@ -117,6 +118,7 @@ extern HANDLE CheckThread, hOnPreShutdown, hOptHook, hLoadHook; extern MYOPTIONS MyOptions;
extern aPopups PopupsList[POPUPS];
extern LPCTSTR Title, Text;
+extern HANDLE Timer;
VOID InitPopupList();
VOID LoadOptions();
@@ -135,4 +137,6 @@ VOID DlgDownloadProc(); 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*);
-void __stdcall RestartMe(void*);
\ No newline at end of file +void __stdcall RestartMe(void*);
+BOOL AllowUpdateOnStartup();
+VOID InitTimer();
\ No newline at end of file diff --git a/plugins/PackUpdater/Src/Events.cpp b/plugins/PackUpdater/Src/Events.cpp index 1967b0727d..f0f5ea8d69 100644 --- a/plugins/PackUpdater/Src/Events.cpp +++ b/plugins/PackUpdater/Src/Events.cpp @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. #include "common.h"
+HANDLE Timer;
BOOL Silent;
int ModulesLoaded(WPARAM wParam, LPARAM lParam)
@@ -36,7 +37,12 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) hkd.lParam = FALSE;
CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd);
- DoCheck(AutoUpdate, (int)CheckThread);
+ if (AllowUpdateOnStartup())
+ DoCheck(UpdateOnStartup, (int)CheckThread);
+
+ Timer = CreateWaitableTimer(NULL, FALSE, NULL);
+ InitTimer();
+
return 0;
}
@@ -67,6 +73,9 @@ INT_PTR EmptyFolder(WPARAM wParam,LPARAM lParam) INT OnPreShutdown(WPARAM wParam, LPARAM lParam)
{
+ CancelWaitableTimer(Timer);
+ CloseHandle(Timer);
+
UnhookEvent(hOptHook);
UnhookEvent(hOnPreShutdown);
return 0;
diff --git a/plugins/PackUpdater/Src/Notifications.cpp b/plugins/PackUpdater/Src/Notifications.cpp index edf69e2b09..5c336358a4 100644 --- a/plugins/PackUpdater/Src/Notifications.cpp +++ b/plugins/PackUpdater/Src/Notifications.cpp @@ -8,13 +8,13 @@ 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
+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
+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.
+Boston, MA 02111-1307, USA.
*/
#include "common.h"
@@ -26,7 +26,7 @@ void PopupAction(HWND hWnd, BYTE action) {
switch (action)
{
- case PCA_CLOSEPOPUP:
+ case PCA_CLOSEPOPUP:
break;
case PCA_DONOTHING:
return;
@@ -87,12 +87,12 @@ static INT_PTR CALLBACK PopupDlgProc2(HWND hDlg, UINT uMsg, WPARAM wParam, LPARA {
switch (uMsg)
{
- case WM_COMMAND:
+ case WM_COMMAND:
{
PopupAction(hDlg, MyOptions.LeftClickAction);
- break;
+ break;
}
- case WM_CONTEXTMENU:
+ case WM_CONTEXTMENU:
{
PopupAction(hDlg, MyOptions.RightClickAction);
break;
@@ -131,7 +131,7 @@ static VOID MakePopupAction(POPUPACTION &pa, INT id) break;
}
}
-
+
VOID show_popup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, int Number, int ActType)
{
POPUPDATAT_V2 pd;
@@ -216,7 +216,7 @@ INT_PTR CALLBACK DlgDownloadPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar static void __stdcall CreateDownloadDialog(void*)
{
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL,MODNAME, "Popups3", DEFAULT_POPUP_ENABLED))
+ if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL,MODNAME, "Popups3", DEFAULT_POPUP_ENABLED))
hDlgDld = CreateDialog(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), NULL, DlgDownloadPop);
else if (DBGetContactSettingByte(NULL,MODNAME, "Popups3M", DEFAULT_MESSAGE_ENABLED))
{
@@ -237,7 +237,7 @@ void DlgDownloadProc() {
Title = TranslateT("Pack Updater");
Text = TranslateT("An error occured while downloading the update.");
- if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED))
+ if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED))
{
Number = 1;
show_popup(0, Title, Text, Number, 0);
@@ -260,26 +260,26 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
- LVCOLUMN lvc = {0};
+ LVCOLUMN lvc = {0};
// Initialize the LVCOLUMN structure.
// The mask specifies that the format, width, text, and
- // subitem members of the structure are valid.
- lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ // subitem members of the structure are valid.
+ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.fmt = LVCFMT_LEFT;
-
+
lvc.iSubItem = 0;
- lvc.pszText = TranslateT("Component Name");
- lvc.cx = 145; // width of column in pixels
+ lvc.pszText = TranslateT("Component Name");
+ lvc.cx = 145; // width of column in pixels
ListView_InsertColumn(hwndList, 0, &lvc);
lvc.iSubItem = 1;
- lvc.pszText = TranslateT("Current Version");
- lvc.cx = 95; // width of column in pixels
+ lvc.pszText = TranslateT("Current Version");
+ lvc.cx = 95; // width of column in pixels
ListView_InsertColumn(hwndList, 1, &lvc);
lvc.iSubItem = 2;
- lvc.pszText = TranslateT("New Version");
- lvc.cx = 82; // width of column in pixels
+ lvc.pszText = TranslateT("New Version");
+ lvc.cx = 82; // width of column in pixels
ListView_InsertColumn(hwndList, 2, &lvc);
//enumerate plugins, fill in list
@@ -290,20 +290,20 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam // Some code to create the list-view control.
// Initialize LVITEM members that are common to all
- // items.
- lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_NORECOMPUTE;// | LVIF_IMAGE;
+ // items.
+ 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.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_IMAGE;
lvI.iSubItem = 0;
lvI.lParam = (LPARAM)&todo[i];
lvI.pszText = todo[i].tszDescr;
lvI.iItem = i;
ListView_InsertItem(hwndList, &lvI);
- lvI.mask = LVIF_TEXT;// | LVIF_IMAGE;
+ lvI.mask = LVIF_TEXT;// | LVIF_IMAGE;
lvI.iSubItem = 1;
lvI.pszText = todo[i].tszCurVer;
@@ -322,7 +322,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam bool check = todo[i].enabled;
if (!DBGetContactSettingTString(0, MODNAME, stored_setting, &dbv))
{
- if(dbv.ptszVal && lstrcmp(dbv.ptszVal, todo[i].tszNewVer) == 0)
+ if (dbv.ptszVal && lstrcmp(dbv.ptszVal, todo[i].tszNewVer) == 0)
check = false;
else
DBDeleteContactSetting(0, MODNAME, stored_setting);
@@ -349,12 +349,12 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam {
case LVN_ITEMCHANGED:
{
- if(GetWindowLongPtr(hDlg, GWLP_USERDATA))
+ if (GetWindowLongPtr(hDlg, GWLP_USERDATA))
{
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
LVITEM lvI = {0};
-
+
lvI.iItem = nmlv->iItem;
lvI.iSubItem = 0;
lvI.mask = LVIF_PARAM;
@@ -387,7 +387,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam HWND hwOk = GetDlgItem(hDlg, IDOK);
EnableWindow(hwOk, enableOk ? TRUE : FALSE);
}
- if(nmlv->uNewState & LVIS_SELECTED)
+ if (nmlv->uNewState & LVIS_SELECTED)
{
if (lstrcmp(todo[lvI.iItem].tszInfoURL, _T("")))
EnableWindow(GetDlgItem(hDlg, IDC_INFO), TRUE);
@@ -445,13 +445,13 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam /*DBWriteContactSettingByte(NULL, "Updater", "DefaultConfAll", IsDlgButtonChecked(hwndDlg, IDC_CHK_CONFALL) ? 1 : 0);
DBWriteContactSettingByte(NULL, "Updater", "NoInstall", IsDlgButtonChecked(hwndDlg, IDC_CHK_NOINSTALL) ? 1 : 0);
- if(IsDlgButtonChecked(hDlg, IDC_CHK_CONFALL))
+ if (IsDlgButtonChecked(hDlg, IDC_CHK_CONFALL))
EndDialog(hDlg, CD_CONFALL);
- else if(IsDlgButtonChecked(hDlg, IDC_CHK_NOINSTALL))
+ else if (IsDlgButtonChecked(hDlg, IDC_CHK_NOINSTALL))
EndDialog(hDlg, CD_NOINSTALL);
else
*/
-
+
arFileType.clear();
arFilePath.clear();
arFileName.clear();
@@ -529,7 +529,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam i = (int)todo.size();
}
}
-
+
if (UpdatesCount > 1 && lstrcmp(arExt[0].c_str(), _T(".html")) != 0)
lstrcpyn(tszBuff, TranslateT("Downloads complete. Start updating? All your data will be saved and Miranda IM will be closed."), SIZEOF(tszBuff));
else if (UpdatesCount == 1 && lstrcmp(arExt[0].c_str(), _T(".html")) != 0)
@@ -539,7 +539,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_ADDPOPUPEX) && ServiceExists(MS_POPUP_REGISTERACTIONS) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL,MODNAME, "Popups0", DEFAULT_POPUP_ENABLED) && (DBGetContactSettingDword(NULL, "PopUp", "Actions", 0) & 1))
+ if (ServiceExists(MS_POPUP_ADDPOPUPEX) && ServiceExists(MS_POPUP_REGISTERACTIONS) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL,MODNAME, "Popups0", DEFAULT_POPUP_ENABLED) && (DBGetContactSettingDword(NULL, "PopUp", "Actions", 0) & 1))
rc = DialogBox(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), NULL, DlgMsgPop);
else
rc = MessageBox(NULL, tszBuff, Title, MB_YESNO | MB_ICONQUESTION);
@@ -550,7 +550,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam TCHAR* tszUtilRootPlug = NULL;
TCHAR* tszUtilRootIco = NULL;
TCHAR* tszUtilRoot = NULL;
-
+
switch (arFileType[i])
{
case 0:
@@ -625,7 +625,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_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED))
+ if (ServiceExists(MS_POPUP_ADDPOPUPEX) && DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1) && DBGetContactSettingByte(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED))
{
Number = 2;
show_popup(0, Title, Text, Number, 0);
diff --git a/plugins/PackUpdater/Src/Options.cpp b/plugins/PackUpdater/Src/Options.cpp index 645a2ca718..04045a3293 100644 --- a/plugins/PackUpdater/Src/Options.cpp +++ b/plugins/PackUpdater/Src/Options.cpp @@ -19,6 +19,19 @@ Boston, MA 02111-1307, USA. #include "common.h"
+WNDPROC g_pOldProc;
+
+LRESULT CALLBACK MyEditProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_KEYDOWN:
+ SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0);
+ break;
+ }
+ return CallWindowProc (g_pOldProc, hwnd, message, wParam, lParam);
+}
+
INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
WORD i = 0;
@@ -26,34 +39,72 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA switch (msg)
{
case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- CheckDlgButton(hwndDlg, IDC_ENABLEUPDATES, (int)AutoUpdate);
- 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 (i = 1; i < POPUPS; i++)
+ 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);
+
+ SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETRANGE, 0, MAKELONG(99, 1));
+ SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETPOS, 0, (LPARAM)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))
{
- mir_snprintf(str, SIZEOF(str), "Popups%dM", i);
- CheckDlgButton(hwndDlg, (i+1029), (DBGetContactSettingByte(NULL, MODNAME, str, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED: BST_UNCHECKED);
+ 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 (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);
+ }
}
+ return TRUE;
}
- return TRUE;
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
- case IDC_ENABLEUPDATES:
+ case IDC_UPDATEONSTARTUP:
+ {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP));
+ }
+ break;
+ case IDC_ONLYONCEADAY:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
+ case IDC_UPDATEONPERIOD:
+ {
+ BOOL value = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PERIOD), value);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODSPIN), value);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), value);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ break;
+ case IDC_PERIODMEASURE:
+ if (HIWORD(wParam) == CBN_SELCHANGE)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
case IDC_REMINDER:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -79,10 +130,30 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case WM_NOTIFY:
{
NMHDR *hdr = (NMHDR *)lParam;
+ if(hdr && hdr->code == UDN_DELTAPOS)
+ {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
if (hdr && hdr->code == PSN_APPLY)
{
- AutoUpdate = IsDlgButtonChecked(hwndDlg, IDC_ENABLEUPDATES);
- DBWriteContactSettingByte(NULL, MODNAME, "AutoUpdate", AutoUpdate);
+ UpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP);
+ OnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY);
+
+ UpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);
+
+ char buffer[3] = {0};
+ Edit_GetText(GetDlgItem(hwndDlg, IDC_PERIOD), (LPWSTR)&buffer, 2);
+ Period = atoi(buffer);
+
+ PeriodMeasure = 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))
@@ -387,18 +458,18 @@ return FALSE; int OptInit(WPARAM wParam, LPARAM lParam)
{
- OPTIONSDIALOGPAGE odp = {0};
+ OPTIONSDIALOGPAGE odp = {0};
ZeroMemory(&odp, sizeof(odp));
odp.cbSize = sizeof(odp);
- odp.position = 100000000;
- odp.hInstance = hInst;
- odp.flags = ODPF_TCHAR | ODPF_BOLDGROUPS;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_UPDATENOTIFY);
- odp.ptszGroup = _T("Events");
- odp.ptszTitle = _T("Pack Updater");
- odp.pfnDlgProc = UpdateNotifyOptsProc;
- CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp);
+ odp.position = 100000000;
+ odp.hInstance = hInst;
+ odp.flags = ODPF_TCHAR | ODPF_BOLDGROUPS;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_UPDATENOTIFY);
+ odp.ptszGroup = _T("Events");
+ odp.ptszTitle = _T("Pack Updater");
+ odp.pfnDlgProc = UpdateNotifyOptsProc;
+ CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp);
if (ServiceExists(MS_POPUP_ADDPOPUP))
{
odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP);
@@ -407,5 +478,5 @@ int OptInit(WPARAM wParam, LPARAM lParam) odp.pfnDlgProc = DlgPopUpOpts;
CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
}
- return 0;
+ return 0;
}
\ No newline at end of file diff --git a/plugins/PackUpdater/Src/PackUpdater.cpp b/plugins/PackUpdater/Src/PackUpdater.cpp index 49cf9dab11..d50b045e37 100644 --- a/plugins/PackUpdater/Src/PackUpdater.cpp +++ b/plugins/PackUpdater/Src/PackUpdater.cpp @@ -21,13 +21,13 @@ Boston, MA 02111-1307, USA. HINSTANCE hInst = NULL;
PLUGINLINK *pluginLink;
-HANDLE hOptHook = NULL, hLoadHook = NULL, hPackUpdaterFolder = NULL, hCheckUpdates = NULL, hEmptyFolder = NULL, hOnPreShutdown = NULL;
+HANDLE hOptHook = NULL, hLoadHook = NULL, hPackUpdaterFolder = NULL, hCheckUpdates = NULL, hEmptyFolder = NULL, hOnPreShutdown = NULL;
TCHAR tszRoot[MAX_PATH] = {0};
int hLangpack;
struct MM_INTERFACE mmi;
PLUGININFOEX pluginInfoEx = {
- sizeof(PLUGININFOEX),
+ sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESCRIPTION,
@@ -37,7 +37,7 @@ PLUGININFOEX pluginInfoEx = { __AUTHORWEB,
UNICODE_AWARE,
0,
- //{29517BE5-779A-48e5-8950-CB4DE1D43172}
+ //{29517BE5-779A-48e5-8950-CB4DE1D43172}
{0x29517be5, 0x779a, 0x48e5, {0x89, 0x50, 0xcb, 0x4d, 0xe1, 0xd4, 0x31, 0x72}}
};
@@ -88,7 +88,6 @@ extern "C" __declspec(dllexport) int Load(PLUGINLINK *link) mi.ptszName = _T("Check for pack updates");
mi.pszService = MODNAME"/CheckUpdates";
Menu_AddMainMenuItem(&mi);
-
// Add empty updates folder menu item
hEmptyFolder = CreateServiceFunction(MODNAME"/EmptyFolder", EmptyFolder);
ZeroMemory(&mi, sizeof(mi));
diff --git a/plugins/PackUpdater/Src/Utils.cpp b/plugins/PackUpdater/Src/Utils.cpp index 735e347f2e..533d1472eb 100644 --- a/plugins/PackUpdater/Src/Utils.cpp +++ b/plugins/PackUpdater/Src/Utils.cpp @@ -23,6 +23,8 @@ vector<FILEINFO> Files; BOOL DlgDld;
INT FileCount = 0, CurrentFile = 0, Number = 0;
BYTE Reminder, AutoUpdate;
+BYTE UpdateOnStartup, UpdateOnPeriod, OnlyOnceADay, PeriodMeasure;
+INT Period;
TCHAR tszDialogMsg[2048] = {0};
FILEINFO* pFileInfo = NULL;
FILEURL* pFileUrl = NULL;
@@ -112,7 +114,11 @@ VOID LoadOptions() 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);
- AutoUpdate = DBGetContactSettingByte(NULL, MODNAME, "AutoUpdate", DEFAULT_AUTOUPDATE);
+ 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);
FileCount = DBGetContactSettingDword(NULL, MODNAME, "FileCount", DEFAULT_FILECOUNT);
}
@@ -143,7 +149,7 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal) NETLIBHTTPREQUEST* pReply = NULL;
pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser,(LPARAM)&nlhr);
- if(pReply)
+ if (pReply)
{
if ((200 == pReply->resultCode) && (pReply->dataLength > 0))
{
@@ -175,13 +181,13 @@ VOID __stdcall RestartMe(void*) }
BOOL Exists(LPCTSTR strName)
-{
- return GetFileAttributes(strName) != INVALID_FILE_ATTRIBUTES;
+{
+ return GetFileAttributes(strName) != INVALID_FILE_ATTRIBUTES;
}
BOOL IsPluginDisabled(TCHAR* filename)
{
- char* fname = mir_t2a(filename);
+ char* fname = mir_t2a(filename);
int res = DBGetContactSettingByte(NULL, "PluginDisable", fname, 0);
mir_free(fname);
return res;
@@ -203,11 +209,11 @@ static void CheckUpdates(void *) vector<FILEINFO> UpdateFiles;
if (!Exists(tszRoot))
- CreateDirectory(tszRoot, NULL);
+ CreateDirectory(tszRoot, NULL);
Files.clear();
Reminder = DBGetContactSettingByte(NULL, MODNAME, "Reminder", DEFAULT_REMINDER);
FileCount = DBGetContactSettingDword(NULL, MODNAME, "FileCount", DEFAULT_FILECOUNT);
-
+
// Load files info
DBGetContactSettingTString(NULL, MODNAME, "File_VersionURL", &dbVar);
if (lstrcmp(dbVar.ptszVal, NULL) == 0)// URL is not set
@@ -275,7 +281,7 @@ static void CheckUpdates(void *) GetPrivateProfileString(tszFileInfo, _T("AdvFolder"), _T(""), Files[CurrentFile].tszAdvFolder, SIZEOF(Files[CurrentFile].tszAdvFolder), tszTmpIni);
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
{
Title = TranslateT("Pack Updater");
@@ -326,7 +332,7 @@ static void CheckUpdates(void *) TCHAR* tszUtilRootPlug = NULL;
TCHAR* tszUtilRootIco = NULL;
TCHAR* tszUtilRoot = NULL;
-
+
switch (Files[CurrentFile].FileType)
{
case 0:
@@ -424,5 +430,61 @@ void DoCheck(int iFlag, int iFlag2) else if (iFlag)
{
CheckThread = mir_forkthread(CheckUpdates, 0);
+ DBWriteContactSettingDword(NULL, MODNAME, "LastUpdate", time(NULL));
+ }
+}
+
+BOOL AllowUpdateOnStartup()
+{
+ if(OnlyOnceADay)
+ {
+ time_t now = time(NULL);
+ time_t was = DBGetContactSettingDword(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)
+ {
+ case 1:
+ // day
+ result *= 60 * 60 * 24;
+ break;
+
+ default:
+ // hour
+ if(periodMeasure != 0)
+ periodMeasure = 0;
+ result *= 60 * 60;
+ break;
+ }
+ return result;
+}
+
+VOID CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHighValue)
+{
+ DoCheck(1, (int)CheckThread);
+}
+
+VOID InitTimer()
+{
+ CancelWaitableTimer(Timer);
+ if(UpdateOnPeriod)
+ {
+ LONG interval = PeriodToMilliseconds(Period, PeriodMeasure);
+
+ _int64 qwDueTime = -10000i64 * interval;
+
+ LARGE_INTEGER li = {0};
+ li.LowPart = (DWORD) ( qwDueTime & 0xFFFFFFFF );
+ li.HighPart = (LONG) ( qwDueTime >> 32 );
+
+ SetWaitableTimer(Timer, &li, interval, TimerAPCProc, NULL, 0);
}
}
\ No newline at end of file |