diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-18 20:51:18 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-18 20:51:18 +0300 |
commit | 9cf1444eb7888f2d942d220f938aa893396a8a1b (patch) | |
tree | ea87e4cb78e9c26a651af00b2d423324ce4a85a6 /plugins/Non-IM Contact/src | |
parent | 3936ebbc665c9653d9f62527c1e136944d52e2ca (diff) |
g_hInstance incapulated into PLUGIN<>, no need in the separate variable
Diffstat (limited to 'plugins/Non-IM Contact/src')
-rw-r--r-- | plugins/Non-IM Contact/src/dialog.cpp | 16 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/main.cpp | 75 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/stdafx.h | 18 |
3 files changed, 52 insertions, 57 deletions
diff --git a/plugins/Non-IM Contact/src/dialog.cpp b/plugins/Non-IM Contact/src/dialog.cpp index 5923e9794f..fe21a066f3 100644 --- a/plugins/Non-IM Contact/src/dialog.cpp +++ b/plugins/Non-IM Contact/src/dialog.cpp @@ -123,7 +123,7 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_HELPMSG:
- CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_HELP), nullptr, HelpWindowDlgProc);
+ CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_HELP), nullptr, HelpWindowDlgProc);
break;
case IDCANCEL:
@@ -205,13 +205,13 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) INT_PTR testStringReplacer(WPARAM, LPARAM)
{
- CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_TEST_LINE), nullptr, TestWindowDlgProc);
+ CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_TEST_LINE), nullptr, TestWindowDlgProc);
return 0;
}
INT_PTR LoadFilesDlg(WPARAM, LPARAM)
{
- CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_ADD_FILE), nullptr, DlgProcFiles);
+ CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ADD_FILE), nullptr, DlgProcFiles);
return 0;
}
@@ -241,7 +241,7 @@ void DoPropertySheet(MCONTACT hContact) /* contact info */
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[0].hInstance = g_hInstance;
+ psp[0].hInstance = g_plugin.getInst();
psp[0].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_INFO);
psp[0].pszIcon = nullptr;
psp[0].pfnDlgProc = DlgProcContactInfo;
@@ -252,7 +252,7 @@ void DoPropertySheet(MCONTACT hContact) /* other settings */
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[1].hInstance = g_hInstance;
+ psp[1].hInstance = g_plugin.getInst();
psp[1].pszTemplate = MAKEINTRESOURCEA(IDD_OTHER_STUFF);
psp[1].pszIcon = nullptr;
psp[1].pfnDlgProc = DlgProcOtherStuff;
@@ -263,7 +263,7 @@ void DoPropertySheet(MCONTACT hContact) /* copy contact */
psp[2].dwSize = sizeof(PROPSHEETPAGE);
psp[2].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[2].hInstance = g_hInstance;
+ psp[2].hInstance = g_plugin.getInst();
psp[2].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COPYEXPORT);
psp[2].pszIcon = nullptr;
psp[2].pfnDlgProc = DlgProcCopy;
@@ -274,7 +274,7 @@ void DoPropertySheet(MCONTACT hContact) /* files */
psp[3].dwSize = sizeof(PROPSHEETPAGE);
psp[3].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[3].hInstance = g_hInstance;
+ psp[3].hInstance = g_plugin.getInst();
psp[3].pszTemplate = MAKEINTRESOURCEA(IDD_ADD_FILE);
psp[3].pszIcon = nullptr;
psp[3].pfnDlgProc = DlgProcFiles;
@@ -285,7 +285,7 @@ void DoPropertySheet(MCONTACT hContact) /* propery sheet header.. dont touch !!!! */
PROPSHEETHEADERA psh = { sizeof(psh) };
psh.dwFlags = PSH_USEICONID | PSH_PROPSHEETPAGE | PSH_USECALLBACK;
- psh.hInstance = g_hInstance;
+ psh.hInstance = g_plugin.getInst();
psh.pszIcon = MAKEINTRESOURCEA(IDI_MAIN);
if (!db_get_static(hContact, MODNAME, "Nick", nick, _countof(nick))) {
char title[256];
diff --git a/plugins/Non-IM Contact/src/main.cpp b/plugins/Non-IM Contact/src/main.cpp index 36e2d33361..1a10038b7c 100644 --- a/plugins/Non-IM Contact/src/main.cpp +++ b/plugins/Non-IM Contact/src/main.cpp @@ -7,22 +7,8 @@ #include "Version.h"
CLIST_INTERFACE *pcli;
-HINSTANCE g_hInstance;
int hLangpack;
-PLUGININFOEX pluginInfoEx = {
- sizeof(pluginInfoEx),
- __PLUGIN_NAME,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
- __DESCRIPTION,
- __AUTHOR,
- __COPYRIGHT,
- __AUTHORWEB,
- UNICODE_AWARE,
- //2e0d2ae3-e123-4607-8539-d4448d675ddb
- { 0x2e0d2ae3, 0xe123, 0x4607, {0x85, 0x39, 0xd4, 0x44, 0x8d, 0x67, 0x5d, 0xdb} }
-};
-
INT_PTR doubleClick(WPARAM wParam, LPARAM)
{
char program[MAX_PATH], params[MAX_PATH];
@@ -63,7 +49,7 @@ int LCStatus = ID_STATUS_OFFLINE; int NimcOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.szGroup.a = LPGEN("Plugins");
odp.szTitle.a = LPGEN("Non-IM Contacts");
@@ -77,12 +63,33 @@ int NimcOptInit(WPARAM wParam, LPARAM) // Returns :
// Description : Sets plugin info
//=====================================================
-//
+
+PLUGININFOEX pluginInfoEx = {
+ sizeof(pluginInfoEx),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ //2e0d2ae3-e123-4607-8539-d4448d675ddb
+ { 0x2e0d2ae3, 0xe123, 0x4607, {0x85, 0x39, 0xd4, 0x44, 0x8d, 0x67, 0x5d, 0xdb} }
+};
+
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
//=====================================================
@@ -91,12 +98,6 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC // Returns : BOOL
// Description :
//=====================================================
-//
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID)
-{
- g_hInstance = hinst;
- return TRUE;
-}
int ModulesLoaded(WPARAM, LPARAM)
{
@@ -104,24 +105,24 @@ int ModulesLoaded(WPARAM, LPARAM) return 0;
}
-IconItem icoList[] =
-{
- { LPGEN("Main Icon"), MODNAME, IDI_MAIN },
-};
-
//=====================================================
// Name : Load
// Parameters: PLUGINLINK *link
// Returns : int
// Description : Called when plugin is loaded into Miranda
//=====================================================
-//
+
+IconItem icoList[] =
+{
+ { LPGEN("Main Icon"), MODNAME, IDI_MAIN },
+};
+
extern "C" __declspec(dllexport) int Load()
{
mir_getLP(&pluginInfoEx);
pcli = Clist_GetInterface();
- Icon_Register(g_hInstance, LPGEN("Non-IM Contact"), icoList, _countof(icoList));
+ Icon_Register(g_plugin.getInst(), LPGEN("Non-IM Contact"), icoList, _countof(icoList));
HookEvent(ME_CLIST_DOUBLECLICKED, (MIRANDAHOOK)doubleClick);
HookEvent(ME_OPT_INITIALISE, NimcOptInit);
@@ -195,23 +196,9 @@ extern "C" __declspec(dllexport) int Load() // Returns :
// Description : Unloads plugin
//=====================================================
-//
+
extern "C" __declspec(dllexport) int Unload(void)
{
killTimer();
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-struct CMPlugin : public PLUGIN<CMPlugin>
-{
- CMPlugin() :
- PLUGIN<CMPlugin>(MODNAME)
- {
- RegisterProtocol(PROTOTYPE_VIRTUAL);
- }
-}
- g_plugin;
-
-extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
diff --git a/plugins/Non-IM Contact/src/stdafx.h b/plugins/Non-IM Contact/src/stdafx.h index 857bb66680..c8f6738916 100644 --- a/plugins/Non-IM Contact/src/stdafx.h +++ b/plugins/Non-IM Contact/src/stdafx.h @@ -68,12 +68,12 @@ struct DLGTEMPLATEEX //=======================================================
// Defines
//=======================================================
-//General
-extern HINSTANCE g_hInstance;
+// General
+
extern int LCStatus;
extern IconItem icoList[];
-//Services.c
+// Services.c
INT_PTR GetLCCaps(WPARAM wParam,LPARAM lParam);
INT_PTR GetLCName(WPARAM wParam,LPARAM lParam);
INT_PTR LoadLCIcon(WPARAM wParam,LPARAM lParam);
@@ -108,17 +108,25 @@ void replaceAllStrings(MCONTACT hContact); void WriteSetting(MCONTACT hContact, char* module1, char* setting1 , char* module12, char* setting2);
//timer.c
-void CALLBACK timerProc();
int startTimer(int interval);
int killTimer();
// http.c
void NetlibInit();
-int InternetDownloadFile (CHAR *szUrl);
+int InternetDownloadFile (char *szUrl);
extern char *szInfo;
extern char *szData;
extern HNETLIBUSER hNetlibUser;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODNAME)
+ {
+ RegisterProtocol(PROTOTYPE_VIRTUAL);
+ }
+};
+
#endif
#pragma comment(lib,"comctl32.lib")
|