diff options
Diffstat (limited to 'plugins/PluginUpdater/src')
-rw-r--r-- | plugins/PluginUpdater/src/Common.h | 31 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Compat/compat.cpp | 21 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Compat/compat.h | 18 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgListNew.cpp | 14 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgUpdate.cpp | 120 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Events.cpp | 8 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Notifications.cpp | 20 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Notifications.h | 8 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Options.cpp | 11 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/PluginUpdater.cpp | 16 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 99 |
11 files changed, 197 insertions, 169 deletions
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;
|