diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/PluginUpdater/src/Common.h | 24 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgListNew.cpp | 19 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgUpdate.cpp | 19 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Events.cpp | 38 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Options.cpp | 5 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/PluginUpdater.cpp | 34 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Services.cpp | 2 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 10 |
8 files changed, 88 insertions, 63 deletions
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h index 1c9282481e..52e2732467 100644 --- a/plugins/PluginUpdater/src/Common.h +++ b/plugins/PluginUpdater/src/Common.h @@ -130,14 +130,12 @@ extern HINSTANCE hInst; extern TCHAR tszRoot[MAX_PATH], tszDialogMsg[2048], tszTempPath[MAX_PATH];
extern FILEINFO *pFileInfo;
-extern HANDLE hCheckThread, hListThread, hPluginUpdaterFolder;
extern PlugOptions opts;
extern POPUP_OPTIONS PopupOptions;
extern aPopups PopupsList[POPUPS];
extern HANDLE Timer, hPipe;
void DoCheck(int iFlag);
-void DoGetList(int iFlag);
void UninitCheck(void);
void UninitListNew(void);
@@ -184,15 +182,17 @@ typedef OBJLIST<ServListEntry> SERVLIST; void InitPopupList();
void LoadOptions();
-BOOL NetlibInit();
-void IcoLibInit();
-void ServiceInit();
-void NetlibUnInit();
-int ModulesLoaded(WPARAM wParam, LPARAM lParam);
-
-int OnFoldersChanged(WPARAM, LPARAM);
-int OnPreShutdown(WPARAM, LPARAM);
-int OptInit(WPARAM, LPARAM);
+void InitNetlib();
+void InitIcoLib();
+void InitServices();
+void InitEvents();
+void InitOptions();
+void InitListNew();
+void InitCheck();
+
+void UnloadCheck();
+void UnloadListNew();
+void UnloadNetlib();
void BackupFile(TCHAR *ptszSrcFileName, TCHAR *ptszBackFileName);
@@ -208,8 +208,6 @@ void __stdcall OpenPluginOptions(void*); BOOL AllowUpdateOnStartup();
void InitTimer(int type = 0);
-INT_PTR MenuCommand(WPARAM,LPARAM);
-INT_PTR ShowListCommand(WPARAM,LPARAM);
INT_PTR EmptyFolder(WPARAM,LPARAM);
INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp index 0f3811ce92..4ef7d445b2 100644 --- a/plugins/PluginUpdater/src/DlgListNew.cpp +++ b/plugins/PluginUpdater/src/DlgListNew.cpp @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. #include "common.h"
static HWND hwndDialog;
+HANDLE hListThread;
static void SelectAll(HWND hDlg, bool bEnable)
{
@@ -468,3 +469,21 @@ void UninitListNew() if (hwndDialog != NULL)
DestroyWindow(hwndDialog);
}
+
+INT_PTR ShowListCommand(WPARAM,LPARAM)
+{
+ opts.bSilent = false;
+ DoGetList(true);
+ return 0;
+}
+
+void InitListNew()
+{
+ CreateServiceFunction(MODNAME"/ShowList", ShowListCommand);
+}
+
+void UnloadListNew()
+{
+ if (hListThread)
+ hListThread = NULL;
+}
\ No newline at end of file diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 18fbe96960..ec16cd7f2f 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -23,6 +23,7 @@ Boston, MA 02111-1307, USA. static bool bShowDetails;
static HWND hwndDialog;
+HANDLE hCheckThread;
static void SelectAll(HWND hDlg, bool bEnable)
{
@@ -734,3 +735,21 @@ void UninitCheck() if (hwndDialog != NULL)
DestroyWindow(hwndDialog);
}
+
+INT_PTR MenuCommand(WPARAM,LPARAM)
+{
+ opts.bSilent = false;
+ DoCheck(true);
+ return 0;
+}
+
+void InitCheck()
+{
+ CreateServiceFunction(MODNAME"/CheckUpdates", MenuCommand);
+}
+
+void UnloadCheck()
+{
+ if (hCheckThread)
+ hCheckThread = NULL;
+}
\ No newline at end of file diff --git a/plugins/PluginUpdater/src/Events.cpp b/plugins/PluginUpdater/src/Events.cpp index e05aba0ff2..e892092094 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;
+HANDLE Timer, hPluginUpdaterFolder;
int OnFoldersChanged(WPARAM, LPARAM)
{
@@ -30,10 +30,16 @@ int OnFoldersChanged(WPARAM, LPARAM) return 0;
}
-int ModulesLoaded(WPARAM wParam, LPARAM lParam)
+int ModulesLoaded(WPARAM, LPARAM)
{
HookEvent(ME_FOLDERS_PATH_CHANGED, OnFoldersChanged);
+ hPluginUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, LPGEN("Plugin Updater"), MIRANDA_PATHT _T("\\")DEFAULT_UPDATES_FOLDER);
+ if (hPluginUpdaterFolder)
+ OnFoldersChanged(0, 0);
+ else
+ lstrcpyn(tszRoot, VARST( _T("%miranda_path%\\"DEFAULT_UPDATES_FOLDER)), SIZEOF(tszRoot));
+
opts.bSilent = true;
int iRestartCount = db_get_b(NULL, MODNAME, "RestartCount", 2);
@@ -51,22 +57,6 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) return 0;
}
-INT_PTR MenuCommand(WPARAM,LPARAM)
-{
- opts.bSilent = false;
- DoCheck(true);
- return 0;
-}
-
-#if MIRANDA_VER >= 0x0A00
-INT_PTR ShowListCommand(WPARAM,LPARAM)
-{
- opts.bSilent = false;
- DoGetList(true);
- return 0;
-}
-#endif
-
INT_PTR EmptyFolder(WPARAM,LPARAM lParam)
{
SHFILEOPSTRUCT file_op = {
@@ -92,8 +82,14 @@ int OnPreShutdown(WPARAM, LPARAM) UninitCheck();
- #if MIRANDA_VER >= 0x0A00
- UninitListNew();
- #endif
+#if MIRANDA_VER >= 0x0A00
+ UninitListNew();
+#endif
return 0;
}
+
+void InitEvents()
+{
+ HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown);
+}
\ No newline at end of file diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index a0375bef2d..f212a396db 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -407,3 +407,8 @@ int OptInit(WPARAM wParam, LPARAM) }
return 0;
}
+
+void InitOptions()
+{
+ HookEvent(ME_OPT_INITIALISE, OptInit);
+}
\ No newline at end of file diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp index ef4d048d93..5e14fddd70 100644 --- a/plugins/PluginUpdater/src/PluginUpdater.cpp +++ b/plugins/PluginUpdater/src/PluginUpdater.cpp @@ -31,7 +31,6 @@ PlugOptions opts; UTF8_INTERFACE utfi;
#endif
-HANDLE hPluginUpdaterFolder = NULL, hEmptyFolder = NULL;
HINSTANCE hInst = NULL;
TCHAR tszRoot[MAX_PATH] = {0}, tszTempPath[MAX_PATH];
int hLangpack;
@@ -89,28 +88,22 @@ extern "C" __declspec(dllexport) int Load(void) {
mir_getLP(&pluginInfoEx);
- ServiceInit();
+ InitServices();
#endif
db_set_b(NULL, MODNAME, "NeedRestart", 0);
- hPluginUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, LPGEN("Plugin Updater"), MIRANDA_PATHT _T("\\")DEFAULT_UPDATES_FOLDER);
- if (hPluginUpdaterFolder)
- OnFoldersChanged(0, 0);
- else
- lstrcpyn(tszRoot, VARST( _T("%miranda_path%\\"DEFAULT_UPDATES_FOLDER)), SIZEOF(tszRoot));
-
DWORD dwLen = GetTempPath( SIZEOF(tszTempPath), tszTempPath);
if (tszTempPath[dwLen-1] == '\\')
tszTempPath[dwLen-1] = 0;
LoadOptions();
InitPopupList();
- NetlibInit();
- IcoLibInit();
+ InitNetlib();
+ InitIcoLib();
// Add cheking update menu item
- CreateServiceFunction(MODNAME"/CheckUpdates", MenuCommand);
+ InitCheck();
CLISTMENUITEM mi = { sizeof(mi) };
mi.position = 400010000;
mi.icolibItem = Skin_GetIconHandle("check_update");
@@ -119,7 +112,7 @@ extern "C" __declspec(dllexport) int Load(void) Menu_AddMainMenuItem(&mi);
#if MIRANDA_VER >= 0x0A00
- CreateServiceFunction(MODNAME"/ShowList", ShowListCommand);
+ InitListNew();
mi.position++;
mi.icolibItem = Skin_GetIconHandle("plg_list");
@@ -127,7 +120,7 @@ extern "C" __declspec(dllexport) int Load(void) mi.pszService = MODNAME"/ShowList";
Menu_AddMainMenuItem(&mi);
- HookEvent(ME_OPT_INITIALISE, OptInit);
+ InitOptions();
#endif
// Add hotkey
@@ -140,8 +133,7 @@ extern "C" __declspec(dllexport) int Load(void) hkd.lParam = FALSE;
Hotkey_Register(&hkd);
- HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown);
+ InitEvents();
//add sounds
SkinAddNewSoundEx("updatecompleted",LPGEN("Plugin Updater"),LPGEN("Update completed"));
@@ -151,12 +143,10 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void)
{
- if (hCheckThread)
- hCheckThread = NULL;
-
- if (hListThread)
- hListThread = NULL;
-
- NetlibUnInit();
+ UnloadCheck();
+#if MIRANDA_VER >= 0x0A00
+ UnloadListNew();
+#endif
+ UnloadNetlib();
return 0;
}
diff --git a/plugins/PluginUpdater/src/Services.cpp b/plugins/PluginUpdater/src/Services.cpp index 282163c88d..9b44f0038d 100644 --- a/plugins/PluginUpdater/src/Services.cpp +++ b/plugins/PluginUpdater/src/Services.cpp @@ -57,7 +57,7 @@ static INT_PTR srvGetNthHash(WPARAM wParam, LPARAM lParam) return (pList == NULL) ? 0 : INT_PTR(&(*pList)[wParam]);
}
-void ServiceInit()
+void InitServices()
{
CreateServiceFunction(MS_PU_PARSEHASHES, srvParseHashes);
CreateServiceFunction(MS_PU_FREEHASHES, srvFreeHashes);
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 06e0407c2f..cf3de1c7ec 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -23,7 +23,7 @@ BOOL DlgDld; int Number = 0;
TCHAR tszDialogMsg[2048] = {0};
FILEINFO *pFileInfo = NULL;
-HANDLE hCheckThread = NULL, hListThread = NULL, hNetlibUser = NULL;
+HANDLE hNetlibUser = NULL;
POPUP_OPTIONS PopupOptions = {0};
aPopups PopupsList[POPUPS];
extern DWORD g_mirandaVersion;
@@ -46,7 +46,7 @@ static iconList[] = { "plg_list", LPGEN("Plugin list"), IDI_PLGLIST },
};
-void IcoLibInit()
+void InitIcoLib()
{
TCHAR destfile[MAX_PATH];
GetModuleFileName(hInst, destfile, MAX_PATH);
@@ -64,7 +64,7 @@ void IcoLibInit() }
}
-BOOL NetlibInit()
+void InitNetlib()
{
NETLIBUSER nlu = {0};
nlu.cbSize = sizeof(nlu);
@@ -72,11 +72,9 @@ BOOL NetlibInit() nlu.ptszDescriptiveName = TranslateT("Plugin Updater HTTP connection");
nlu.szSettingsModule = MODNAME;
hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
-
- return hNetlibUser != NULL;
}
-void NetlibUnInit()
+void UnloadNetlib()
{
Netlib_CloseHandle(hNetlibUser);
hNetlibUser = NULL;
|