summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-05-22 20:15:32 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-05-22 20:15:32 +0000
commitba020540c064ebd48bf6b77e5bd5e11255766f23 (patch)
treead87b13d4dbc6cc43a489aa1022b28b48d0e2dd5
parentc09aa99a7e9915c503064d6eb5e9dd1bdd2a673f (diff)
-PluginUpdater:
-code cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@13765 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_pluginupdater.h4
-rw-r--r--plugins/PluginUpdater/res/Resource.rc35
-rw-r--r--plugins/PluginUpdater/src/Common.h31
-rw-r--r--plugins/PluginUpdater/src/Compat/compat.cpp21
-rw-r--r--plugins/PluginUpdater/src/Compat/compat.h18
-rw-r--r--plugins/PluginUpdater/src/DlgListNew.cpp14
-rw-r--r--plugins/PluginUpdater/src/DlgUpdate.cpp120
-rw-r--r--plugins/PluginUpdater/src/Events.cpp8
-rw-r--r--plugins/PluginUpdater/src/Notifications.cpp20
-rw-r--r--plugins/PluginUpdater/src/Notifications.h8
-rw-r--r--plugins/PluginUpdater/src/Options.cpp11
-rw-r--r--plugins/PluginUpdater/src/PluginUpdater.cpp16
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp99
13 files changed, 218 insertions, 187 deletions
diff --git a/include/m_pluginupdater.h b/include/m_pluginupdater.h
index 41cf58f56c..78e1dfd6f6 100644
--- a/include/m_pluginupdater.h
+++ b/include/m_pluginupdater.h
@@ -65,4 +65,8 @@ typedef struct {
#define MS_PU_GETNTHHASH "PluginUpdater/GetNthCount"
+
+#define MS_PU_RESTART "PluginUpdater/RestartMe"
+#define MS_PU_SHOWLIST "PluginUpdater/ShowList"
+#define MS_PU_CHECKUPDATES "PluginUpdater/CheckUpdates"
#endif // M_PLUGINUPDATER_H__
diff --git a/plugins/PluginUpdater/res/Resource.rc b/plugins/PluginUpdater/res/Resource.rc
index dd80f9c8cc..3e80e28af9 100644
--- a/plugins/PluginUpdater/res/Resource.rc
+++ b/plugins/PluginUpdater/res/Resource.rc
@@ -52,31 +52,30 @@ BEGIN
PUSHBUTTON "Select &none",IDC_SELNONE,175,218,60,14,NOT WS_TABSTOP
END
-IDD_OPT_UPDATENOTIFY DIALOGEX 0, 0, 273, 238
+IDD_OPT_UPDATENOTIFY DIALOGEX 0, 0, 301, 222
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Hotkey",IDC_STATIC,2,0,262,26
+ GROUPBOX "Hotkey",IDC_STATIC,2,0,284,26
CONTROL "Go to Customize -> Hotkeys to change the hotkey",IDC_LINK_HOTKEY,
- "Hyperlink",WS_TABSTOP,9,11,249,10
- GROUPBOX "Plugin updates options",IDC_STATIC,1,29,263,60
+ "Hyperlink",WS_TABSTOP,29,11,249,10
+ GROUPBOX "Plugin updates options",IDC_STATIC,1,29,285,60
CONTROL "On startup",IDC_UPDATEONSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,44,73,10
- CONTROL "(but only once a day)",IDC_ONLYONCEADAY,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,92,44,161,10
+ CONTROL "(but only once a day)",IDC_ONLYONCEADAY,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,92,44,186,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 "Silent mode",IDC_SILENTMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,72,247,10
- GROUPBOX "Files source",IDC_STATIC,1,92,263,96
- CONTROL "Stable version",IDC_STABLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,105,247,10
- CONTROL "Development version (less stable)",IDC_TRUNK,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,120,247,10
+ CONTROL "Silent mode",IDC_SILENTMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,72,267,10
+ GROUPBOX "Files source",IDC_STATIC,1,92,285,96
+ CONTROL "Stable version",IDC_STABLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,105,267,10
+ CONTROL "Development version (less stable)",IDC_TRUNK,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,120,267,10
CONTROL "Development version with debug symbols",IDC_TRUNK_SYMBOLS,
- "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,135,247,10
- CONTROL "Custom version",IDC_CUSTOM,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,150,247,10
- EDITTEXT IDC_CUSTOMURL,11,164,234,16,ES_AUTOHSCROLL | WS_DISABLED
- CTEXT "Some component(s) was updated.\nYou need to restart your Miranda to apply installed updates.",IDC_NEEDRESTARTLABEL,11,193,247,15,NOT WS_VISIBLE
- LTEXT "Switch to Stable version is now impossible due to incompatibility with currrent Dev version!",IDC_DONTSWITCHTOSTABLE,11,214,247,19,NOT WS_VISIBLE
+ "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,135,267,10
+ CONTROL "Custom version",IDC_CUSTOM,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,150,267,10
+ EDITTEXT IDC_CUSTOMURL,11,164,267,16,ES_AUTOHSCROLL | WS_DISABLED
+ CTEXT "Some component(s) was updated.\nYou need to restart your Miranda to apply installed updates.",IDC_NEEDRESTARTLABEL,11,194,267,15,NOT WS_VISIBLE
END
IDD_POPUP DIALOGEX 0, 0, 316, 174
@@ -172,12 +171,12 @@ BEGIN
IDD_OPT_UPDATENOTIFY, DIALOG
BEGIN
LEFTMARGIN, 1
- RIGHTMARGIN, 261
+ RIGHTMARGIN, 294
VERTGUIDE, 2
VERTGUIDE, 11
- VERTGUIDE, 258
- VERTGUIDE, 264
- BOTTOMMARGIN, 233
+ VERTGUIDE, 278
+ VERTGUIDE, 286
+ BOTTOMMARGIN, 214
END
IDD_POPUP, DIALOG
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h
index 6f62cd98e9..363b084848 100644
--- a/plugins/PluginUpdater/src/Common.h
+++ b/plugins/PluginUpdater/src/Common.h
@@ -33,7 +33,6 @@ Boston, MA 02111-1307, USA.
#include <m_skin.h>
#include <m_langpack.h>
#include <m_options.h>
-#include <m_database.h>
#include <m_system_cpp.h>
#include <m_popup.h>
#include <m_hotkeys.h>
@@ -48,7 +47,7 @@ Boston, MA 02111-1307, USA.
#include "resource.h"
#if MIRANDA_VER < 0x0A00
-#include "compat.h"
+#include "Compat\compat.h"
#endif
#include "Notifications.h"
@@ -85,20 +84,14 @@ struct FILEINFO
typedef OBJLIST<FILEINFO> FILELIST;
-struct PopupDataText
-{
- TCHAR *Title;
- TCHAR *Text;
-};
-
-struct PlugOptions
+extern struct PlugOptions
{
BYTE bUpdateOnStartup, bUpdateOnPeriod, bOnlyOnceADay, bForceRedownload, bSilentMode;
BOOL bSilent, bDlgDld;
BYTE bPeriodMeasure;
int Period;
-};
+} opts;
#define DEFAULT_UPDATEONSTARTUP 1
#define DEFAULT_UPDATEONPERIOD 0
@@ -141,13 +134,9 @@ using namespace std;
extern HINSTANCE hInst;
extern TCHAR tszRoot[MAX_PATH], tszTempPath[MAX_PATH];
-extern FILEINFO *pFileInfo;
-extern PlugOptions opts;
-extern POPUP_OPTIONS PopupOptions;
extern aPopups PopupsList[POPUPS];
-extern HANDLE Timer, hPipe, hNetlibUser;
-
-void DoCheck(bool bSilent);
+extern HANDLE hPipe, hNetlibUser;
+extern IconItemT iconList[];
void UninitCheck(void);
void UninitListNew(void);
@@ -176,7 +165,7 @@ struct ServListEntry
m_name( mir_a2t(_name)),
m_crc(_crc)
{
- strncpy(m_szHash, _hash, sizeof(m_szHash));
+ strncpy(m_szHash, _hash, sizeof(m_szHash)-1);
}
~ServListEntry()
@@ -187,7 +176,6 @@ struct ServListEntry
TCHAR *m_name;
DWORD m_crc;
char m_szHash[32+1];
- BYTE m_selected;
};
typedef OBJLIST<ServListEntry> SERVLIST;
@@ -203,6 +191,7 @@ void InitEvents();
void InitOptions();
void InitListNew();
void InitCheck();
+void CreateTimer();
void UnloadCheck();
void UnloadListNew();
@@ -223,11 +212,7 @@ void __stdcall OpenPluginOptions(void*);
void CheckUpdateOnStartup();
void InitTimer(void *type);
-INT_PTR EmptyFolder(WPARAM,LPARAM);
-
-INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
-int ImageList_AddIconFromIconLib(HIMAGELIST hIml, const char *name);
+int ImageList_AddIconFromIconLib(HIMAGELIST hIml, int i);
bool unzip(const TCHAR *ptszZipFile, TCHAR *ptszDestPath, TCHAR *ptszBackPath,bool ch);
void strdel(TCHAR *parBuffer, int len);
diff --git a/plugins/PluginUpdater/src/Compat/compat.cpp b/plugins/PluginUpdater/src/Compat/compat.cpp
index 260ff99039..e6b67265bd 100644
--- a/plugins/PluginUpdater/src/Compat/compat.cpp
+++ b/plugins/PluginUpdater/src/Compat/compat.cpp
@@ -114,3 +114,24 @@ void __stdcall RestartMe(void*)
STARTUPINFO si = { sizeof(si) };
CreateProcess(mirandaPath, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
}
+
+/////////////////////////////////////////////////////////////////////////////////////
+// we don't use Icon_Register here because it should work under Miranda IM too
+
+void InitIcoLib()
+{
+ TCHAR destfile[MAX_PATH];
+ GetModuleFileName(hInst, destfile, MAX_PATH);
+
+ SKINICONDESC sid = { sizeof(sid) };
+ sid.flags = SIDF_PATH_TCHAR;
+ sid.ptszDefaultFile = destfile;
+ sid.pszSection = MODULEA;
+
+ for (int i = 0; i < SIZEOF(iconList); i++) {
+ sid.pszName = iconList[i].szIconName;
+ sid.pszDescription = iconList[i].szDescr;
+ sid.iDefaultIndex = -iconList[i].IconID;
+ Skin_AddIcon(&sid);
+ }
+}
diff --git a/plugins/PluginUpdater/src/Compat/compat.h b/plugins/PluginUpdater/src/Compat/compat.h
index d6dca84836..01f6536b71 100644
--- a/plugins/PluginUpdater/src/Compat/compat.h
+++ b/plugins/PluginUpdater/src/Compat/compat.h
@@ -1,5 +1,8 @@
#define MIID_UPDATER {0x4a47b19b, 0xde5a, 0x4436, { 0xab, 0x4b, 0xe1, 0xf3, 0xa0, 0x22, 0x5d, 0xe7}}
+#include <m_database.h>
+#include "..\..\..\..\include\m_pluginupdater.h"
+
#define db_free(A) DBFreeVariant(A)
#define db_get_b(A,B,C,D) DBGetContactSettingByte(A,B,C,D)
@@ -73,6 +76,20 @@ public:
}
};
+struct
+{
+ char *szIconName;
+ char *szDescr;
+ int IconID;
+}
+static iconList[] =
+{
+ { "check_update", LPGEN("Check for updates"), IDI_MENU },
+ { "info", LPGEN("Plugin info"), IDI_INFO },
+ { "plg_list", LPGEN("Component list"), IDI_PLGLIST },
+ { "plg_restart", LPGEN("Restart"), IDI_RESTART },
+};
+
__forceinline INT_PTR Options_Open(OPENOPTIONSDIALOG *ood)
{
return CallService("Opt/OpenOptions", 0, (LPARAM)ood);
@@ -87,6 +104,7 @@ char *bin2hex(const void *pData, size_t len, char *dest);
char *rtrim(char *str);
void CreatePathToFileT(TCHAR *ptszPath);
int wildcmpit(const WCHAR *name, const WCHAR *mask);
+void InitIcoLib()
#define NEWTSTR_ALLOCA(A) (A == NULL)?NULL:_tcscpy((TCHAR*)alloca((_tcslen(A)+1) *sizeof(TCHAR)), A)
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp
index b77f5a71d7..a51d146b9a 100644
--- a/plugins/PluginUpdater/src/DlgListNew.cpp
+++ b/plugins/PluginUpdater/src/DlgListNew.cpp
@@ -20,7 +20,7 @@ Boston, MA 02111-1307, USA.
#include "common.h"
static HWND hwndDialog;
-HANDLE hListThread;
+static HANDLE hListThread;
static void SelectAll(HWND hDlg, bool bEnable)
{
@@ -143,12 +143,12 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
case WM_INITDIALOG:
TranslateDialogDefault( hDlg );
oldWndProc = (WNDPROC)SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)PluginListWndProc);
-
- SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon("plg_list", 1));
- SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon("plg_list"));
+
+ SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(iconList[2].hIcolib, 1));
+ SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle(iconList[2].hIcolib));
{
HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0);
- ImageList_AddIconFromIconLib(hIml, "info");
+ ImageList_AddIconFromIconLib(hIml, 1);
ListView_SetImageList(hwndList, hIml, LVSIL_SMALL);
OSVERSIONINFO osver = { sizeof(osver) };
@@ -396,7 +396,7 @@ static void GetList(void *)
hListThread = NULL;
}
-void DoGetList()
+static void DoGetList()
{
if (hListThread)
ShowPopup(TranslateT("Plugin Updater"), TranslateT("List loading already started!"), POPUP_TYPE_INFO);
@@ -423,7 +423,7 @@ INT_PTR ShowListCommand(WPARAM,LPARAM)
void InitListNew()
{
- CreateServiceFunction(MODNAME"/ShowList", ShowListCommand);
+ CreateServiceFunction(MS_PU_SHOWLIST, ShowListCommand);
}
void UnloadListNew()
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index 00c86cd706..3dd823458f 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -23,7 +23,7 @@ Boston, MA 02111-1307, USA.
static bool bShowDetails;
static HWND hwndDialog;
-HANDLE hCheckThread;
+static HANDLE hCheckThread, hTimer;
static void SelectAll(HWND hDlg, bool bEnable)
{
@@ -160,8 +160,8 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM
case WM_INITDIALOG:
TranslateDialogDefault(hDlg);
SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
- SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon("check_update"));
- SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon("check_update", 1));
+ SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle(iconList[0].hIcolib));
+ SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(iconList[0].hIcolib, 1));
{
OSVERSIONINFO osver = { sizeof(osver) };
if (GetVersionEx(&osver) && osver.dwMajorVersion >= 6)
@@ -301,9 +301,14 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM
return TRUE;
case IDC_DETAILS:
- bShowDetails = !bShowDetails;
- ResizeVert(hDlg, bShowDetails ? 242 : 60);
- SetDlgItemText(hDlg, IDC_DETAILS, (bShowDetails ? TranslateT("<< Details") : TranslateT("Details >>")));
+ if (bShowDetails = !bShowDetails) {
+ ResizeVert(hDlg, 242);
+ SetDlgItemText(hDlg, IDC_DETAILS, TranslateT("<< Details"));
+ }
+ else {
+ ResizeVert(hDlg, 60);
+ SetDlgItemText(hDlg, IDC_DETAILS, TranslateT("Details >>"));
+ }
break;
case IDC_SELALL:
@@ -615,7 +620,7 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
}
TCHAR *ptszUrl;
- int MyCRC = 0;
+ int MyCRC;
mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\%s"), tszFolder, ffd.cFileName);
bool bDeleteOnly = (tszNewName[0] == 0);
@@ -626,19 +631,22 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
// Not in list? Check for trailing 'W' or 'w'
if (item == NULL) {
TCHAR *p = _tcsrchr(tszNewName, '.');
- if (p[-1] != 'w' && p[-1] != 'W')
+ if (p[-1] != 'w' && p[-1] != 'W') {
+ Netlib_LogfT(hNetlibUser, _T("File %s not found on server"), ffd.cFileName);
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)
+ if ((item = hashes.find((ServListEntry*)&pName)) == NULL) {
+ Netlib_LogfT(hNetlibUser, _T("File %s not found on server"), ffd.cFileName);
continue;
+ }
strdel(tszNewName + iPos, 1);
}
- ptszUrl = item->m_name;
// No need to hash a file if we are forcing a redownload anyway
if (!opts.bForceRedownload) {
// try to hash the file
@@ -646,8 +654,10 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
__try {
CalculateModuleHash(tszBuf, szMyHash);
// hashes are the same, skipping
- if (strcmp(szMyHash, item->m_szHash) == 0)
+ if (strcmp(szMyHash, item->m_szHash) == 0) {
+ Netlib_LogfT(hNetlibUser, _T("File %s is already up-to-date"), ffd.cFileName);
continue;
+ }
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
@@ -655,13 +665,18 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
}
}
+ ptszUrl = item->m_name;
MyCRC = item->m_crc;
+ Netlib_LogfT(hNetlibUser, _T("Found update for %s"), ffd.cFileName);
}
- else // file was marked for deletion, add it to the list anyway
+ else {
+ // file was marked for deletion, add it to the list anyway
+ Netlib_LogfT(hNetlibUser, _T("File %s marked for deletion"), ffd.cFileName);
ptszUrl = _T("");
+ MyCRC = 0;
+ }
// Yeah, we've got new version.
- Netlib_LogfT(hNetlibUser, _T("Found update for %s"), tszBuf);
FILEINFO *FileInfo = new FILEINFO;
// copy the relative old name
_tcsncpy(FileInfo->tszOldName, tszBuf + cbBaseLen, SIZEOF(FileInfo->tszOldName));
@@ -736,7 +751,7 @@ static void CheckUpdates(void *)
hCheckThread = NULL;
}
-void DoCheck(bool bSilent)
+static void DoCheck(bool bSilent)
{
if (hCheckThread)
ShowPopup(TranslateT("Plugin Updater"), TranslateT("Update checking already started!"), POPUP_TYPE_INFO);
@@ -756,12 +771,14 @@ void DoCheck(bool bSilent)
void UninitCheck()
{
+ CancelWaitableTimer(hTimer);
+ CloseHandle(hTimer);
if (hwndDialog != NULL)
DestroyWindow(hwndDialog);
}
// menu item command
-INT_PTR MenuCommand(WPARAM, LPARAM)
+static INT_PTR MenuCommand(WPARAM, LPARAM)
{
Netlib_LogfT(hNetlibUser, _T("Update started manually!"));
DoCheck(false);
@@ -770,7 +787,7 @@ INT_PTR MenuCommand(WPARAM, LPARAM)
void InitCheck()
{
- CreateServiceFunction(MODNAME"/CheckUpdates", MenuCommand);
+ CreateServiceFunction(MS_PU_CHECKUPDATES, MenuCommand);
}
void UnloadCheck()
@@ -793,3 +810,74 @@ void CheckUpdateOnStartup()
DoCheck(true);
}
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static void CALLBACK TimerAPCProc(void *, DWORD, DWORD)
+{
+ DoCheck(true);
+}
+
+static LONGLONG PeriodToMilliseconds(const int period, BYTE &periodMeasure)
+{
+ LONGLONG result = period * 1000LL;
+ switch(periodMeasure) {
+ case 1:
+ // day
+ result *= 60 * 60 * 24;
+ break;
+
+ default:
+ // hour
+ if (periodMeasure != 0)
+ periodMeasure = 0;
+ result *= 60 * 60;
+ }
+ return result;
+}
+
+void InitTimer(void *type)
+{
+ if (!opts.bUpdateOnPeriod)
+ return;
+
+ LONGLONG interval;
+
+ switch ((int)type) {
+ case 0: // default, plan next check relative to last check
+ {
+ time_t now = time(NULL);
+ time_t was = db_get_dw(NULL, MODNAME, DB_SETTING_LAST_UPDATE, 0);
+
+ interval = PeriodToMilliseconds(opts.Period, opts.bPeriodMeasure);
+ interval -= (now - was) * 1000;
+ if (interval <= 0)
+ interval = 1000; // no last update or too far in the past -> do it now
+ }
+ break;
+
+ case 2: // failed last check, check again in two hours
+ interval = 1000 * 60 * 60 * 2;
+ break;
+
+ default: // options changed, use set interval from now
+ interval = PeriodToMilliseconds(opts.Period, opts.bPeriodMeasure);
+ }
+
+ FILETIME ft;
+ GetSystemTimeAsFileTime(&ft);
+
+ LARGE_INTEGER li;
+ li.LowPart = ft.dwLowDateTime;
+ li.HighPart = ft.dwHighDateTime;
+ li.QuadPart += interval * 10000LL;
+ SetWaitableTimer(hTimer, &li, 0, TimerAPCProc, NULL, 0);
+
+ // Wait in an alertable state for the timer to go off.
+ SleepEx(INFINITE, TRUE);
+}
+
+void CreateTimer() {
+ hTimer = CreateWaitableTimer(NULL, FALSE, NULL);
+ mir_forkthread(InitTimer, 0);
+} \ No newline at end of file
diff --git a/plugins/PluginUpdater/src/Events.cpp b/plugins/PluginUpdater/src/Events.cpp
index ed2d5e7811..9987cf1179 100644
--- a/plugins/PluginUpdater/src/Events.cpp
+++ b/plugins/PluginUpdater/src/Events.cpp
@@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA.
#include "common.h"
-HANDLE Timer, hPluginUpdaterFolder;
+HANDLE hPluginUpdaterFolder;
int OnFoldersChanged(WPARAM, LPARAM)
{
@@ -61,17 +61,13 @@ int ModulesLoaded(WPARAM, LPARAM)
CheckUpdateOnStartup();
- Timer = CreateWaitableTimer(NULL, FALSE, NULL);
- mir_forkthread(InitTimer, 0);
+ CreateTimer();
return 0;
}
int OnPreShutdown(WPARAM, LPARAM)
{
- CancelWaitableTimer(Timer);
- CloseHandle(Timer);
-
UninitCheck();
#if MIRANDA_VER >= 0x0A00
diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp
index ac5ba40acd..9edd5348be 100644
--- a/plugins/PluginUpdater/src/Notifications.cpp
+++ b/plugins/PluginUpdater/src/Notifications.cpp
@@ -101,7 +101,11 @@ void ShowPopup(LPCTSTR ptszTitle, LPCTSTR ptszText, int Number)
if (db_get_b(NULL, MODNAME, setting, DEFAULT_POPUP_ENABLED)) {
POPUPDATAT pd = { 0 };
pd.lchContact = NULL;
+#if MIRANDA_VER >= 0x0A00
+ pd.lchIcon = Skin_GetIconByHandle(iconList[0].hIcolib);
+#else
pd.lchIcon = Skin_GetIcon("check_update");
+#endif
if (Number == POPUP_TYPE_MSG) {
pd.PluginWindowProc = PopupDlgProcRestart;
pd.iSeconds = -1;
@@ -132,21 +136,13 @@ void ShowPopup(LPCTSTR ptszTitle, LPCTSTR ptszText, int Number)
}
}
- if (Number == POPUP_TYPE_ERROR) {
- int iMsgType;
- switch (Number) {
- case POPUP_TYPE_MSG: iMsgType = MB_ICONSTOP; break;
- case POPUP_TYPE_ERROR: iMsgType = MB_ICONINFORMATION; break;
- case POPUP_TYPE_INFO: iMsgType = MB_ICONQUESTION; break;
- default: iMsgType = 0;
- }
- MessageBox(0, ptszText, ptszTitle, iMsgType);
- }
+ if (Number == POPUP_TYPE_ERROR)
+ MessageBox(0, ptszText, ptszTitle, MB_ICONINFORMATION);
}
-int ImageList_AddIconFromIconLib(HIMAGELIST hIml, const char *name)
+int ImageList_AddIconFromIconLib(HIMAGELIST hIml, int i)
{
- HICON icon = Skin_GetIconByHandle(Skin_GetIconHandle(name));
+ HICON icon = Skin_GetIconByHandle(iconList[i].hIcolib);
int res = ImageList_AddIcon(hIml, icon);
Skin_ReleaseIcon(icon);
return res;
diff --git a/plugins/PluginUpdater/src/Notifications.h b/plugins/PluginUpdater/src/Notifications.h
index f21581221a..1d8544ba63 100644
--- a/plugins/PluginUpdater/src/Notifications.h
+++ b/plugins/PluginUpdater/src/Notifications.h
@@ -21,12 +21,12 @@ Boston, MA 02111-1307, USA.
//=== Objects =====
//This one is used to easily tie status id, icon, text...
-typedef struct
+struct aPopups
{
int ID;
COLORREF colorBack;
COLORREF colorText;
-} aPopups;
+};
#define DEFAULT_POPUP_LCLICK 1
#define DEFAULT_POPUP_RCLICK 0
@@ -52,12 +52,12 @@ typedef struct
#define PCA_DONOTHING 1 // do nothing
//===== Options flags
-typedef struct tagMYOPTIONS {
+extern struct POPUP_OPTIONS {
BYTE DefColors;
BYTE LeftClickAction;
BYTE RightClickAction;
int Timeout;
-} POPUP_OPTIONS;
+} PopupOptions;
static struct {
TCHAR *Text;
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp
index ee191b7977..df04c64977 100644
--- a/plugins/PluginUpdater/src/Options.cpp
+++ b/plugins/PluginUpdater/src/Options.cpp
@@ -51,7 +51,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
int UpdateMode = db_get_b(NULL, MODNAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE);
if (UpdateMode == UPDATE_MODE_STABLE)
db_set_b(NULL, MODNAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK);
- ShowWindow(GetDlgItem(hwndDlg, IDC_DONTSWITCHTOSTABLE), SW_SHOW);
+ SetDlgItemText(hwndDlg,IDC_STABLE,TranslateT("Stable version (incompatible with current development version)"));
}
switch (GetUpdateMode()) {
@@ -72,7 +72,9 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
ptrT url(db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, (url == NULL) ? ptrT(GetDefaultUrl()) : url);
+ if (url == NULL)
+ url = GetDefaultUrl();
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url);
}
}
return TRUE;
@@ -116,7 +118,9 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
{
ptrT url(db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, (url == NULL) ? ptrT(GetDefaultUrl()) : url);
+ if (url == NULL)
+ url = GetDefaultUrl();
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url);
}
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -189,7 +193,6 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
db_unset(NULL, MODNAME, DB_SETTING_REDOWNLOAD);
}
}
- break;
}
}
return FALSE;
diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp
index b77d93d3a8..900c9bd34e 100644
--- a/plugins/PluginUpdater/src/PluginUpdater.cpp
+++ b/plugins/PluginUpdater/src/PluginUpdater.cpp
@@ -88,18 +88,22 @@ extern "C" __declspec(dllexport) int Load(void)
InitCheck();
CLISTMENUITEM mi = { sizeof(mi) };
mi.position = 400010000;
+#if MIRANDA_VER >= 0x0A00
+ mi.icolibItem = iconList[0].hIcolib;
+#else
mi.icolibItem = Skin_GetIconHandle("check_update");
+#endif
mi.pszName = LPGEN("Check for updates");
- mi.pszService = MODNAME"/CheckUpdates";
+ mi.pszService = MS_PU_CHECKUPDATES;
Menu_AddMainMenuItem(&mi);
#if MIRANDA_VER >= 0x0A00
InitListNew();
mi.position++;
- mi.icolibItem = Skin_GetIconHandle("plg_list");
+ mi.icolibItem = iconList[2].hIcolib;
mi.pszName = LPGEN("Available components list");
- mi.pszService = MODNAME"/ShowList";
+ mi.pszService = MS_PU_SHOWLIST;
Menu_AddMainMenuItem(&mi);
InitOptions();
@@ -110,7 +114,7 @@ extern "C" __declspec(dllexport) int Load(void)
hkd.pszName = "Check for updates";
hkd.pszDescription = "Check for updates";
hkd.pszSection = "Plugin Updater";
- hkd.pszService = MODNAME"/CheckUpdates";
+ hkd.pszService = MS_PU_CHECKUPDATES;
hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F10) | HKF_MIRANDA_LOCAL;
hkd.lParam = FALSE;
Hotkey_Register(&hkd);
@@ -120,7 +124,8 @@ extern "C" __declspec(dllexport) int Load(void)
// add sounds
SkinAddNewSoundEx("updatecompleted", LPGEN("Plugin Updater"), LPGEN("Update completed"));
SkinAddNewSoundEx("updatefailed", LPGEN("Plugin Updater"), LPGEN("Update failed"));
-
+
+#if MIRANDA_VER >= 0x0A00
// Upgrade old settings
if (-1 == db_get_b(0, MODNAME, DB_SETTING_UPDATE_MODE, -1)) {
ptrT dbvUpdateURL(db_get_tsa(0, MODNAME, DB_SETTING_UPDATE_URL));
@@ -140,6 +145,7 @@ extern "C" __declspec(dllexport) int Load(void)
else db_set_b(0, MODNAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_CUSTOM);
}
}
+#endif
return 0;
}
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp
index e8c555df4f..4f0c806ce9 100644
--- a/plugins/PluginUpdater/src/Utils.cpp
+++ b/plugins/PluginUpdater/src/Utils.cpp
@@ -24,38 +24,19 @@ POPUP_OPTIONS PopupOptions = {0};
extern DWORD g_mirandaVersion;
/////////////////////////////////////////////////////////////////////////////////////
-// we don't use Icon_Register here because it should work under Miranda IM too
-
-struct
-{
- char *szIconName;
- char *szDescr;
- int IconID;
-}
-static iconList[] =
+#if MIRANDA_VER >= 0x0A00
+IconItemT iconList[] =
{
- { "check_update", LPGEN("Check for updates"), IDI_MENU },
- { "info", LPGEN("Plugin info"), IDI_INFO },
- { "plg_list", LPGEN("Component list"), IDI_PLGLIST },
+ { LPGENT("Check for updates"),"check_update", IDI_MENU },
+ { LPGENT("Plugin info"), "info", IDI_INFO },
+ { LPGENT("Component list"),"plg_list", IDI_PLGLIST }
};
void InitIcoLib()
{
- TCHAR destfile[MAX_PATH];
- GetModuleFileName(hInst, destfile, MAX_PATH);
-
- SKINICONDESC sid = { sizeof(sid) };
- sid.flags = SIDF_PATH_TCHAR;
- sid.ptszDefaultFile = destfile;
- sid.pszSection = MODULEA;
-
- for (int i = 0; i < SIZEOF(iconList); i++) {
- sid.pszName = iconList[i].szIconName;
- sid.pszDescription = iconList[i].szDescr;
- sid.iDefaultIndex = -iconList[i].IconID;
- Skin_AddIcon(&sid);
- }
+ Icon_RegisterT(hInst,MODULE,iconList, SIZEOF(iconList));
}
+#endif
void InitNetlib()
{
@@ -368,72 +349,6 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc)
return ret;
}
-/////////////////////////////////////////////////////////////////////////////////////////
-
-LONGLONG PeriodToMilliseconds(const int period, BYTE &periodMeasure)
-{
- LONGLONG result = period * 1000LL;
- 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(void *, DWORD, DWORD)
-{
- DoCheck(true);
-}
-
-void InitTimer(void *type)
-{
- if (!opts.bUpdateOnPeriod)
- return;
-
- LONGLONG interval = PeriodToMilliseconds(opts.Period, opts.bPeriodMeasure);
-
- switch ((int)type) {
- case 0: // default, plan next check relative to last check
- {
- time_t now = time(NULL);
- time_t was = db_get_dw(NULL, MODNAME, DB_SETTING_LAST_UPDATE, 0);
-
- interval -= (now - was) * 1000;
- if (interval <= 0)
- interval = 1000; // no last update or too far in the past -> do it now
- }
- break;
-
- case 1: // options changed, use set interval from now
- break;
-
- case 2: // failed last check, check again in two hours
- interval = 1000 * 60 * 60 * 2;
- break;
- }
-
- FILETIME ft;
- GetSystemTimeAsFileTime(&ft);
-
- LARGE_INTEGER li;
- li.LowPart = ft.dwLowDateTime;
- li.HighPart = ft.dwHighDateTime;
- li.QuadPart += interval * 10000LL;
- SetWaitableTimer(Timer, &li, 0, TimerAPCProc, NULL, 0);
-
- // Wait in an alertable state for the timer to go off.
- SleepEx(INFINITE, TRUE);
-}
-
void strdel(TCHAR *parBuffer, int len)
{
TCHAR* p;