summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-08-15 10:48:34 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-08-15 10:48:34 +0000
commit7ad7dc2a281fbe2442bf3e8efe594e4ffdd0c5de (patch)
treef00ceb65e062806bf20a7db84e628ffa8d0b85d6
parent5a91616243eb2dba33ac92849cb2702091641306 (diff)
- folder's path isn't updated upon change in Options;
- plugin's own directory should be skipped during scan; - minor code optimization git-svn-id: http://svn.miranda-ng.org/main/trunk@1464 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/PluginUpdater/src/Common.h39
-rw-r--r--plugins/PluginUpdater/src/Events.cpp13
-rw-r--r--plugins/PluginUpdater/src/Notifications.cpp4
-rw-r--r--plugins/PluginUpdater/src/PluginUpdater.cpp2
-rw-r--r--plugins/PluginUpdater/src/Scanner.cpp9
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp20
6 files changed, 53 insertions, 34 deletions
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h
index b2c8173b46..de9797425e 100644
--- a/plugins/PluginUpdater/src/Common.h
+++ b/plugins/PluginUpdater/src/Common.h
@@ -73,7 +73,7 @@ struct FILEINFO
FILEURL File;
BOOL enabled;
BYTE FileType;
- INT FileNum;
+ int FileNum;
BYTE Force;
};
@@ -91,7 +91,7 @@ struct PlugOptions
BOOL bSilent, bDlgDld;
BYTE bPeriodMeasure;
- INT Period;
+ int Period;
};
#define DEFAULT_UPDATEICONS 0
@@ -117,31 +117,36 @@ extern HINSTANCE hInst;
extern TCHAR tszRoot[MAX_PATH], tszDialogMsg[2048];
extern FILEINFO* pFileInfo;
-extern HANDLE CheckThread;
+extern HANDLE CheckThread, hPluginUpdaterFolder;
extern PlugOptions opts;
extern POPUP_OPTIONS PopupOptions;
extern aPopups PopupsList[POPUPS];
extern HANDLE Timer;
extern HWND hwndDialog;
-VOID InitPopupList();
-VOID LoadOptions();
+void InitPopupList();
+void LoadOptions();
BOOL NetlibInit();
-VOID IcoLibInit();
-VOID NetlibUnInit();
-INT ModulesLoaded(WPARAM wParam, LPARAM lParam);
-INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam);
-INT_PTR EmptyFolder(WPARAM wParam,LPARAM lParam);
-INT OnPreShutdown(WPARAM wParam, LPARAM lParam);
-INT OptInit(WPARAM wParam, LPARAM lParam);
-VOID DoCheck(INT iFlag);
+void IcoLibInit();
+void NetlibUnInit();
+int ModulesLoaded(WPARAM wParam, LPARAM lParam);
+
+int OnFoldersChanged(WPARAM, LPARAM);
+int OnPreShutdown(WPARAM, LPARAM);
+int OptInit(WPARAM, LPARAM);
+
+void DoCheck(int iFlag);
BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal);
-VOID ShowPopup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, INT Number, INT ActType);
-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 ShowPopup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, int Number, int ActType);
void __stdcall ExitMe(void*);
void __stdcall RestartMe(void*);
BOOL AllowUpdateOnStartup();
-VOID InitTimer();
+void InitTimer();
+
+INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam);
+INT_PTR EmptyFolder(WPARAM wParam,LPARAM lParam);
+
+INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
bool unzip(const TCHAR* ptszZipFile, TCHAR* ptszDestPath, TCHAR* ptszBackPath);
diff --git a/plugins/PluginUpdater/src/Events.cpp b/plugins/PluginUpdater/src/Events.cpp
index 23d6fb26ca..4e2eb89ca1 100644
--- a/plugins/PluginUpdater/src/Events.cpp
+++ b/plugins/PluginUpdater/src/Events.cpp
@@ -21,8 +21,19 @@ Boston, MA 02111-1307, USA.
HANDLE Timer;
+int OnFoldersChanged(WPARAM, LPARAM)
+{
+ FoldersGetCustomPathT(hPluginUpdaterFolder, tszRoot, MAX_PATH, _T(""));
+ size_t len = _tcslen(tszRoot);
+ if (tszRoot[len-1] == '\\' || tszRoot[len-1] == '/')
+ tszRoot[len-1] = 0;
+ return 0;
+}
+
int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
+ HookEvent(ME_FOLDERS_PATH_CHANGED, OnFoldersChanged);
+
opts.bSilent = true;
int iRestartCount = DBGetContactSettingByte(NULL, MODNAME, "RestartCount", 2);
@@ -65,7 +76,7 @@ INT_PTR EmptyFolder(WPARAM wParam,LPARAM lParam)
return 0;
}
-INT OnPreShutdown(WPARAM wParam, LPARAM lParam)
+int OnPreShutdown(WPARAM wParam, LPARAM lParam)
{
CancelWaitableTimer(Timer);
CloseHandle(Timer);
diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp
index 2b7a4ca923..c3a83f802f 100644
--- a/plugins/PluginUpdater/src/Notifications.cpp
+++ b/plugins/PluginUpdater/src/Notifications.cpp
@@ -95,7 +95,7 @@ static INT_PTR CALLBACK PopupDlgProc2(HWND hDlg, UINT uMsg, WPARAM wParam, LPARA
return DefWindowProc(hDlg, uMsg, wParam, lParam);
}
-static VOID MakePopupAction(POPUPACTION &pa, INT id)
+static void MakePopupAction(POPUPACTION &pa, int id)
{
pa.cbSize = sizeof(POPUPACTION);
pa.flags = PAF_ENABLED;
@@ -260,7 +260,7 @@ static void ApplyUpdates(void* param)
return;
}
- INT rc = -1;
+ int rc = -1;
PopupDataText temp;
temp.Title = TranslateT("Plugin Updater");
temp.Text = tszBuff;
diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp
index e481252b29..d42c0901e7 100644
--- a/plugins/PluginUpdater/src/PluginUpdater.cpp
+++ b/plugins/PluginUpdater/src/PluginUpdater.cpp
@@ -58,7 +58,7 @@ extern "C" __declspec(dllexport) int Load(void)
hPluginUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, "Plugin Updater", MIRANDA_USERDATAT _T("\\")DEFAULT_UPDATES_FOLDER);
if (hPluginUpdaterFolder)
- FoldersGetCustomPathT(hPluginUpdaterFolder, tszRoot, MAX_PATH, _T(""));
+ OnFoldersChanged(0, 0);
else {
mir_ptr<TCHAR> tszFolder( Utils_ReplaceVarsT(_T("%miranda_userdata%\\"DEFAULT_UPDATES_FOLDER)));
lstrcpyn(tszRoot, tszFolder, SIZEOF(tszRoot));
diff --git a/plugins/PluginUpdater/src/Scanner.cpp b/plugins/PluginUpdater/src/Scanner.cpp
index 83ab6a5396..0c267602c8 100644
--- a/plugins/PluginUpdater/src/Scanner.cpp
+++ b/plugins/PluginUpdater/src/Scanner.cpp
@@ -52,8 +52,11 @@ typedef OBJLIST<ServListEntry> SERVLIST;
static void ScanFolder(const TCHAR* tszFolder, const TCHAR* tszBaseUrl, SERVLIST& hashes, OBJLIST<FILEINFO>* UpdateFiles)
{
- TCHAR tszMask[MAX_PATH], tszFileTemp[MAX_PATH];
- mir_sntprintf(tszFileTemp, SIZEOF(tszFileTemp), _T("%s\\Temp"), tszRoot);
+ // skip updater's own folder
+ if ( !_tcsicmp(tszFolder, tszRoot))
+ return;
+
+ TCHAR tszMask[MAX_PATH];
mir_sntprintf(tszMask, SIZEOF(tszMask), _T("%s\\*"), tszFolder);
WIN32_FIND_DATA ffd;
@@ -107,7 +110,7 @@ static void ScanFolder(const TCHAR* tszFolder, const TCHAR* tszBaseUrl, SERVLIST
_tcscpy(FileInfo->tszDescr, ffd.cFileName);
*pExt = 0;
- mir_sntprintf(FileInfo->File.tszDiskPath, SIZEOF(FileInfo->File.tszDiskPath), _T("%s\\%s.zip"), tszFileTemp, ffd.cFileName);
+ mir_sntprintf(FileInfo->File.tszDiskPath, SIZEOF(FileInfo->File.tszDiskPath), _T("%s\\Temp\\%s.zip"), tszRoot, ffd.cFileName);
mir_sntprintf(FileInfo->File.tszDownloadURL, SIZEOF(FileInfo->File.tszDownloadURL), _T("%s/%s"), tszBaseUrl, item->m_name);
if ((pExt = _tcsrchr(FileInfo->File.tszDownloadURL, '.')) != NULL)
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp
index a4ad93525b..1886d02c01 100644
--- a/plugins/PluginUpdater/src/Utils.cpp
+++ b/plugins/PluginUpdater/src/Utils.cpp
@@ -21,7 +21,7 @@ Boston, MA 02111-1307, USA.
//vector<FILEINFO> Files;
BOOL DlgDld;
-INT /*CurrentFile = 0,*/ Number = 0;
+int Number = 0;
TCHAR tszDialogMsg[2048] = {0};
FILEINFO* pFileInfo = NULL;
//FILEURL* pFileUrl = NULL;
@@ -42,7 +42,7 @@ static iconList[] =
{ "btn_cancel", LPGEN("'No' Button"), IDI_CANCEL }
};
-VOID IcoLibInit()
+void IcoLibInit()
{
TCHAR destfile[MAX_PATH];
GetModuleFileName(hInst, destfile, MAX_PATH);
@@ -74,13 +74,13 @@ BOOL NetlibInit()
return hNetlibUser != NULL;
}
-VOID NetlibUnInit()
+void NetlibUnInit()
{
Netlib_CloseHandle(hNetlibUser);
hNetlibUser = NULL;
}
-VOID InitPopupList()
+void InitPopupList()
{
int index = 0;
PopupsList[index].ID = index;
@@ -107,7 +107,7 @@ VOID InitPopupList()
PopupsList[index].colorText = DBGetContactSettingDword(NULL, MODNAME, "Popups3Tx", COLOR_TX_DEFAULT);
}
-VOID LoadOptions()
+void LoadOptions()
{
PopupOptions.DefColors = DBGetContactSettingByte(NULL, MODNAME, "DefColors", DEFAULT_COLORS);
PopupOptions.LeftClickAction= DBGetContactSettingByte(NULL, MODNAME, "LeftClickAction", DEFAULT_POPUP_LCLICK);
@@ -164,12 +164,12 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
return ret;
}
-VOID __stdcall ExitMe(void*)
+void __stdcall ExitMe(void*)
{
CallService("CloseAction", 0, 0);
}
-VOID __stdcall RestartMe(void*)
+void __stdcall RestartMe(void*)
{
CallService(MS_SYSTEM_RESTART, 0, 0);
}
@@ -188,7 +188,7 @@ BOOL AllowUpdateOnStartup()
return TRUE;
}
-LONG PeriodToMilliseconds(const INT period, BYTE& periodMeasure)
+LONG PeriodToMilliseconds(const int period, BYTE& periodMeasure)
{
LONG result = period * 1000;
switch(periodMeasure) {
@@ -207,12 +207,12 @@ LONG PeriodToMilliseconds(const INT period, BYTE& periodMeasure)
return result;
}
-VOID CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHighValue)
+void CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHighValue)
{
DoCheck(1);
}
-VOID InitTimer()
+void InitTimer()
{
CancelWaitableTimer(Timer);
if (opts.bUpdateOnPeriod) {