diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-15 21:45:48 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-15 21:45:48 +0300 |
commit | 2160d0a2343309c3c1e13ceb74061b39f306a063 (patch) | |
tree | 2290b6f06c8acff86a7c188a5ff22be542a65745 /plugins/AVS | |
parent | de594644d5c14142346cbb039b027af79e718904 (diff) |
what has to be done with each plugin:
- remove DllMain;
- replace global variable that carries hInstance with g_plugin.getInst();
- create an instance of CMPlugin template that passes the name of data module into its parent;
- create an instance of CMPlugin class named g_plugin;
- remove __NO_CMPLUGIN_NEEDED from stdafx.h
Diffstat (limited to 'plugins/AVS')
-rw-r--r-- | plugins/AVS/src/main.cpp | 55 | ||||
-rw-r--r-- | plugins/AVS/src/options.cpp | 5 | ||||
-rw-r--r-- | plugins/AVS/src/services.cpp | 6 | ||||
-rw-r--r-- | plugins/AVS/src/stdafx.h | 9 |
4 files changed, 39 insertions, 36 deletions
diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp index 18cbe3ae9d..d8bfc89206 100644 --- a/plugins/AVS/src/main.cpp +++ b/plugins/AVS/src/main.cpp @@ -24,20 +24,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-HINSTANCE g_hInst = nullptr;
-HICON g_hIcon = nullptr;
-bool g_shutDown = false;
+HICON g_hIcon = nullptr;
+bool g_shutDown = false;
-int hLangpack;
+CMPlugin g_plugin;
+int hLangpack;
-wchar_t g_szDataPath[MAX_PATH]; // user datae path (read at startup only)
-BOOL g_AvatarHistoryAvail = FALSE;
-HWND hwndSetMyAvatar = nullptr;
+wchar_t g_szDataPath[MAX_PATH]; // user datae path (read at startup only)
+BOOL g_AvatarHistoryAvail = FALSE;
+HWND hwndSetMyAvatar = nullptr;
-HANDLE hMyAvatarsFolder;
-HANDLE hGlobalAvatarFolder;
-HANDLE hLoaderEvent, hShutdownEvent;
-HANDLE hEventChanged, hEventContactAvatarChanged, hMyAvatarChanged;
+HANDLE hMyAvatarsFolder;
+HANDLE hGlobalAvatarFolder;
+HANDLE hLoaderEvent, hShutdownEvent;
+HANDLE hEventChanged, hEventContactAvatarChanged, hMyAvatarChanged;
void InitServices();
@@ -58,19 +58,6 @@ char *g_szMetaName = nullptr; int OnDetailsInit(WPARAM wParam, LPARAM lParam);
int OptInit(WPARAM wParam, LPARAM lParam);
-PLUGININFOEX pluginInfoEx = {
- sizeof(PLUGININFOEX),
- __PLUGIN_NAME,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
- __DESCRIPTION,
- __AUTHOR,
- __COPYRIGHT,
- __AUTHORWEB,
- UNICODE_AWARE,
- // {E00F1643-263C-4599-B84B-053E5C511D29}
- { 0xe00f1643, 0x263c, 0x4599, { 0xb8, 0x4b, 0x5, 0x3e, 0x5c, 0x51, 0x1d, 0x29 } }
-};
-
static int ProtocolAck(WPARAM, LPARAM lParam)
{
ACKDATA *ack = (ACKDATA*)lParam;
@@ -372,17 +359,29 @@ static int LoadAvatarModule() return 0;
}
-BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD, LPVOID)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfoEx = {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {E00F1643-263C-4599-B84B-053E5C511D29}
{
- g_hInst = hInstDLL;
- return TRUE;
-}
+ 0xe00f1643, 0x263c, 0x4599,{ 0xb8, 0x4b, 0x5, 0x3e, 0x5c, 0x51, 0x1d, 0x29 } }
+};
extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfoEx);
diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index 55de5ed96a..925fa52ee5 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -31,7 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern OBJLIST<protoPicCacheEntry> g_ProtoPictures; extern HANDLE hEventChanged; -extern HINSTANCE g_hInst; extern HICON g_hIcon; extern BOOL ScreenToClient(HWND hWnd, LPRECT lpRect); @@ -708,7 +707,7 @@ INT_PTR CALLBACK DlgProcAvatarOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA int OptInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = g_hInst; + odp.hInstance = g_plugin.getInst(); odp.flags = ODPF_BOLDGROUPS; odp.szGroup.a = LPGEN("Contacts"); odp.szTitle.a = LPGEN("Avatars"); @@ -1100,7 +1099,7 @@ static INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wP int OnDetailsInit(WPARAM wParam, LPARAM lParam) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = g_hInst; + odp.hInstance = g_plugin.getInst(); odp.szTitle.a = LPGEN("Avatar"); MCONTACT hContact = lParam; diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp index cf7f6cafe9..7a4b80faf2 100644 --- a/plugins/AVS/src/services.cpp +++ b/plugins/AVS/src/services.cpp @@ -142,7 +142,7 @@ INT_PTR SetAvatar(WPARAM hContact, LPARAM lParam) ofn.lpstrInitialDir = L".";
*FileName = '\0';
ofn.lpstrDefExt = L"";
- ofn.hInstance = g_hInst;
+ ofn.hInstance = g_plugin.getInst();
ofn.lpTemplateName = MAKEINTRESOURCE(IDD_OPENSUBCLASS);
ofn.lpfnHook = OpenFileSubclass;
locking_request = is_locked;
@@ -648,7 +648,7 @@ INT_PTR SetMyAvatar(WPARAM wParam, LPARAM lParam) *FileName = '\0';
ofn.lpstrDefExt = L"";
- ofn.hInstance = g_hInst;
+ ofn.hInstance = g_plugin.getInst();
wchar_t title[256];
if (protocol == nullptr)
@@ -681,7 +681,7 @@ INT_PTR CALLBACK DlgProcAvatarOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA static INT_PTR ContactOptions(WPARAM wParam, LPARAM)
{
if (wParam)
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_AVATAROPTIONS), nullptr, DlgProcAvatarOptions, (LPARAM)wParam);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_AVATAROPTIONS), nullptr, DlgProcAvatarOptions, (LPARAM)wParam);
return 0;
}
diff --git a/plugins/AVS/src/stdafx.h b/plugins/AVS/src/stdafx.h index 596b29fecd..162b642359 100644 --- a/plugins/AVS/src/stdafx.h +++ b/plugins/AVS/src/stdafx.h @@ -57,6 +57,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SHVIEW_THUMBNAIL 0x702D
#endif
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(AVS_MODULE)
+ {}
+};
+
/* most free()'s are invalid when the code is executed from a dll, so this changes
all the bad free()'s to good ones, however it's still incorrect code. The reasons for not
changing them include:
@@ -122,8 +129,6 @@ extern wchar_t g_szDataPath[]; // user datae path (read at startup only) extern BOOL g_AvatarHistoryAvail;
extern HWND hwndSetMyAvatar;
-extern HINSTANCE g_hInst;
-
extern HANDLE hMyAvatarsFolder;
extern HANDLE hGlobalAvatarFolder;
extern HANDLE hLoaderEvent, hShutdownEvent;
|