summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-17 20:53:02 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-17 20:53:02 +0300
commit067a48827e8bae1bc595f3268e18996314843396 (patch)
treed51ae1287c40f08f291f5578b2dccf69f902cc97 /plugins
parent7639f72273189df60566755c0d5f1e4ab7201b67 (diff)
OpenFolder, PackUpdater, PasteIt, Ping, QuickMessages, QuickReplies, Sessions, TranslitSwitcher => CMPlugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/OpenFolder/src/openFolder.cpp29
-rw-r--r--plugins/OpenFolder/src/stdafx.h1
-rw-r--r--plugins/PackUpdater/Src/Notifications.cpp6
-rw-r--r--plugins/PackUpdater/Src/Options.cpp2
-rw-r--r--plugins/PackUpdater/Src/PackUpdater.cpp19
-rw-r--r--plugins/PackUpdater/Src/Utils.cpp4
-rw-r--r--plugins/PackUpdater/Src/stdafx.h9
-rw-r--r--plugins/PasteIt/src/Options.cpp6
-rw-r--r--plugins/PasteIt/src/PasteIt.cpp150
-rw-r--r--plugins/PasteIt/src/PasteToWeb.cpp4
-rw-r--r--plugins/PasteIt/src/stdafx.h11
-rw-r--r--plugins/Ping/src/options.cpp6
-rw-r--r--plugins/Ping/src/ping.cpp39
-rw-r--r--plugins/Ping/src/pinggraph.cpp8
-rw-r--r--plugins/Ping/src/pingthread.cpp10
-rw-r--r--plugins/Ping/src/stdafx.h10
-rw-r--r--plugins/Ping/src/utils.cpp2
-rw-r--r--plugins/QuickMessages/src/Utils.cpp2
-rw-r--r--plugins/QuickMessages/src/main.cpp55
-rw-r--r--plugins/QuickMessages/src/options.cpp4
-rw-r--r--plugins/QuickMessages/src/stdafx.h9
-rw-r--r--plugins/QuickReplies/src/events.cpp2
-rw-r--r--plugins/QuickReplies/src/options.cpp2
-rw-r--r--plugins/QuickReplies/src/quickreplies.cpp17
-rw-r--r--plugins/QuickReplies/src/stdafx.h9
-rw-r--r--plugins/Sessions/Src/Main.cpp68
-rw-r--r--plugins/Sessions/Src/Options.cpp4
-rw-r--r--plugins/Sessions/Src/stdafx.h9
-rw-r--r--plugins/TranslitSwitcher/src/TranslitSwitcher.cpp36
-rw-r--r--plugins/TranslitSwitcher/src/stdafx.h1
30 files changed, 270 insertions, 264 deletions
diff --git a/plugins/OpenFolder/src/openFolder.cpp b/plugins/OpenFolder/src/openFolder.cpp
index 695aa6ac73..c2898261d1 100644
--- a/plugins/OpenFolder/src/openFolder.cpp
+++ b/plugins/OpenFolder/src/openFolder.cpp
@@ -1,9 +1,18 @@
#include "stdafx.h"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(nullptr)
+ {}
+}
+g_plugin;
+
int hLangpack = 0;
-HINSTANCE hInst;
HANDLE hButtonTopToolbar;
+/////////////////////////////////////////////////////////////////////////////////////////
+
PLUGININFOEX pluginInfoEx =
{
sizeof(PLUGININFOEX),
@@ -18,14 +27,15 @@ PLUGININFOEX pluginInfoEx =
{0x10896143, 0x7249, 0x4b36, {0xa4, 0x8, 0x65, 0x1, 0xa6, 0xb6, 0x3, 0x5a}}
};
-static IconItem icon = { LPGEN("Open Folder"), "open", IDI_FOLDER };
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
- hInst = hinstDLL;
- return TRUE;
+ return &pluginInfoEx;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static IconItem icon = { LPGEN("Open Folder"), "open", IDI_FOLDER };
+
static INT_PTR MenuCommand_OpenFolder(WPARAM, LPARAM)
{
wchar_t szMirandaPath[MAX_PATH];
@@ -67,11 +77,6 @@ HICON LoadIconExEx(const char* IcoLibName, int)
return IcoLib_GetIcon(szSettingName);
}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" int __declspec(dllexport) Load()
@@ -83,7 +88,7 @@ extern "C" int __declspec(dllexport) Load()
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
// icolib (0.7+)
- Icon_Register(hInst, LPGEN("Open Folder"), &icon, 1, OPENFOLDER_MODULE_NAME);
+ Icon_Register(g_plugin.getInst(), LPGEN("Open Folder"), &icon, 1, OPENFOLDER_MODULE_NAME);
// hotkeys service (0.8+)
HOTKEYDESC hotkey = {};
diff --git a/plugins/OpenFolder/src/stdafx.h b/plugins/OpenFolder/src/stdafx.h
index ea39d7d6da..2020c78b28 100644
--- a/plugins/OpenFolder/src/stdafx.h
+++ b/plugins/OpenFolder/src/stdafx.h
@@ -3,7 +3,6 @@
#include <windows.h>
#include <commctrl.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_icolib.h>
diff --git a/plugins/PackUpdater/Src/Notifications.cpp b/plugins/PackUpdater/Src/Notifications.cpp
index 3e15b6ed56..e2e3d9793c 100644
--- a/plugins/PackUpdater/Src/Notifications.cpp
+++ b/plugins/PackUpdater/Src/Notifications.cpp
@@ -177,10 +177,10 @@ INT_PTR CALLBACK DlgDownloadPop(HWND hDlg, UINT uMsg, WPARAM, LPARAM)
static void __stdcall CreateDownloadDialog(void*)
{
if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups3", DEFAULT_POPUP_ENABLED))
- hDlgDld = CreateDialog(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), nullptr, DlgDownloadPop);
+ hDlgDld = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_POPUPDUMMI), nullptr, DlgDownloadPop);
else if (db_get_b(NULL, MODNAME, "Popups3M", DEFAULT_MESSAGE_ENABLED)) {
mir_wstrncpy(tszDialogMsg, Text, _countof(tszDialogMsg));
- hDlgDld = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DOWNLOAD), nullptr, DlgDownload);
+ hDlgDld = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DOWNLOAD), nullptr, DlgDownload);
}
}
@@ -421,7 +421,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
Title = TranslateT("Pack Updater");
Text = tszBuff;
if (ServiceExists(MS_POPUP_ADDPOPUPT) && ServiceExists(MS_POPUP_REGISTERACTIONS) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups0", DEFAULT_POPUP_ENABLED) && (db_get_dw(NULL, "Popup", "Actions", 0) & 1))
- rc = DialogBox(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), nullptr, DlgMsgPop);
+ rc = DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_POPUPDUMMI), nullptr, DlgMsgPop);
else
rc = MessageBox(nullptr, tszBuff, Title, MB_YESNO | MB_ICONQUESTION);
if (rc == IDYES) {
diff --git a/plugins/PackUpdater/Src/Options.cpp b/plugins/PackUpdater/Src/Options.cpp
index a93d6de456..f7701cb158 100644
--- a/plugins/PackUpdater/Src/Options.cpp
+++ b/plugins/PackUpdater/Src/Options.cpp
@@ -382,7 +382,7 @@ int OptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_UPDATENOTIFY);
odp.szGroup.w = LPGENW("Services");
diff --git a/plugins/PackUpdater/Src/PackUpdater.cpp b/plugins/PackUpdater/Src/PackUpdater.cpp
index 81da988409..4a47392e0a 100644
--- a/plugins/PackUpdater/Src/PackUpdater.cpp
+++ b/plugins/PackUpdater/Src/PackUpdater.cpp
@@ -19,13 +19,16 @@ Boston, MA 02111-1307, USA.
#include "stdafx.h"
-HINSTANCE hInst = nullptr;
-
HANDLE hPackUpdaterFolder = nullptr;
wchar_t tszRoot[MAX_PATH] = { 0 };
+
int hLangpack;
+CMPlugin g_plugin;
+
+/////////////////////////////////////////////////////////////////////////////////////////
-PLUGININFOEX pluginInfoEx = {
+PLUGININFOEX pluginInfoEx =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -38,17 +41,13 @@ PLUGININFOEX pluginInfoEx = {
{ 0x29517be5, 0x779a, 0x48e5, { 0x89, 0x50, 0xcb, 0x4d, 0xe1, 0xd4, 0x31, 0x72 } }
};
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfoEx);
@@ -97,6 +96,8 @@ extern "C" __declspec(dllexport) int Load(void)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
if (hCheckThread)
diff --git a/plugins/PackUpdater/Src/Utils.cpp b/plugins/PackUpdater/Src/Utils.cpp
index 9554653ffd..36e04c722f 100644
--- a/plugins/PackUpdater/Src/Utils.cpp
+++ b/plugins/PackUpdater/Src/Utils.cpp
@@ -44,7 +44,7 @@ IconItem iconList[] =
void IcoLibInit()
{
- Icon_Register(hInst, MODULEA, iconList, _countof(iconList));
+ Icon_Register(g_plugin.getInst(), MODULEA, iconList, _countof(iconList));
}
BOOL NetlibInit()
@@ -330,7 +330,7 @@ static void CheckUpdates(void *)
// Show dialog
INT upd_ret = 0;
if (UpdateFiles.size() > 0)
- upd_ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE), GetDesktopWindow(), DlgUpdate, (LPARAM)&UpdateFiles);
+ upd_ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UPDATE), GetDesktopWindow(), DlgUpdate, (LPARAM)&UpdateFiles);
DeleteFile(tszTmpIni);
if (upd_ret == IDCANCEL) {
hCheckThread = nullptr;
diff --git a/plugins/PackUpdater/Src/stdafx.h b/plugins/PackUpdater/Src/stdafx.h
index 3b86f1ee69..5df3de5503 100644
--- a/plugins/PackUpdater/Src/stdafx.h
+++ b/plugins/PackUpdater/Src/stdafx.h
@@ -27,7 +27,6 @@ Boston, MA 02111-1307, USA.
#include <Shlobj.h>
// Miranda header files
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
#include <newpluginapi.h>
#include <m_clist.h>
@@ -52,6 +51,13 @@ Boston, MA 02111-1307, USA.
#define DEFAULT_UPDATES_FOLDER L"Pack Updates"
typedef std::wstring tString;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODNAME)
+ {}
+};
+
struct FILEURL
{
wchar_t tszDownloadURL[2048];
@@ -90,7 +96,6 @@ struct FILEINFO
using std::wstring;
using namespace std;
-extern HINSTANCE hInst;
extern INT FileCount, CurrentFile, Number, UpdatesCount, Period;
extern BOOL Silent, DlgDld;
extern BYTE Reminder, UpdateOnStartup, UpdateOnPeriod, OnlyOnceADay, PeriodMeasure;
diff --git a/plugins/PasteIt/src/Options.cpp b/plugins/PasteIt/src/Options.cpp
index 97d93e3d98..8a23ecc154 100644
--- a/plugins/PasteIt/src/Options.cpp
+++ b/plugins/PasteIt/src/Options.cpp
@@ -298,7 +298,7 @@ INT_PTR CALLBACK Options::DlgProcOptsPages(HWND hwndDlg, UINT msg, WPARAM wParam
d.page = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE));
WebOptions* wo = optsPagesData->webOptions[d.page];
d.tempFormats = wo->formats;
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_CONFIGURE), hwndDlg, DlgProcOptsConfigure, (LPARAM)&d) == IDOK) {
+ if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DLG_CONFIGURE), hwndDlg, DlgProcOptsConfigure, (LPARAM)&d) == IDOK) {
wo->formats = d.tempFormats;
ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), wo);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
@@ -306,7 +306,7 @@ INT_PTR CALLBACK Options::DlgProcOptsPages(HWND hwndDlg, UINT msg, WPARAM wParam
}
else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_PASTEBIN_LOGIN) {
OptsLoginData d;
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_PASTEBIN_LOGIN), hwndDlg, DlgProcOptsLogin, (LPARAM)&d) == IDOK) {
+ if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DLG_PASTEBIN_LOGIN), hwndDlg, DlgProcOptsLogin, (LPARAM)&d) == IDOK) {
PasteToWeb1 *web = (PasteToWeb1*)pasteToWebs[optsPagesData->lastPage];
Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), web->GetUserKey(d.user, d.password).c_str());
}
@@ -679,7 +679,7 @@ int Options::InitOptions(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.szTitle.w = LPGENW("Paste It");
odp.szGroup.w = LPGENW("Services");
diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp
index d5b3b77d88..9cd94f3c4e 100644
--- a/plugins/PasteIt/src/PasteIt.cpp
+++ b/plugins/PasteIt/src/PasteIt.cpp
@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
PasteToWeb* pasteToWebs[PasteToWeb::pages];
std::map<MCONTACT, HWND>* contactWindows;
-DWORD gMirandaVersion;
HNETLIBUSER g_hNetlibUser;
HANDLE hModulesLoaded, hTabsrmmButtonPressed;
@@ -29,14 +28,22 @@ HGENMENU hContactMenu;
HGENMENU hWebPageMenus[PasteToWeb::pages];
HANDLE hOptionsInit;
HANDLE hWindowEvent = nullptr;
-HINSTANCE hInst;
+
+static IconItem icon = { LPGEN("Paste It"), "PasteIt_main", IDI_MENU };
+
+CMPlugin g_plugin;
+int hLangpack = 0;
+CHAT_MANAGER *pci;
#define FROM_CLIPBOARD 10
#define FROM_FILE 11
#define DEF_PAGES_START 20
#define MS_PASTEIT_CONTACTMENU "PasteIt/ContactMenu"
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -49,23 +56,12 @@ PLUGININFOEX pluginInfo = {
{ 0x1aac15e8, 0xdcec, 0x4050, { 0xb6, 0x6f, 0x2a, 0xa0, 0xe6, 0x12, 0xc, 0x22 } }
};
-static IconItem icon = { LPGEN("Paste It"), "PasteIt_main", IDI_MENU };
-
-int hLangpack = 0;
-CHAT_MANAGER *pci;
-
-BOOL APIENTRY DllMain(HMODULE hModule, DWORD, LPVOID)
-{
- hInst = hModule;
- return TRUE;
-}
-
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
- gMirandaVersion = mirandaVersion;
return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
std::wstring GetFile()
{
@@ -84,46 +80,37 @@ std::wstring GetFile()
ofn.lpstrTitle = TranslateT("Paste It - Select file");
ofn.nMaxFile = _countof(stzFilePath);
ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR;
- if (GetOpenFileName(&ofn))
- {
+ if (GetOpenFileName(&ofn)) {
return stzFilePath;
}
return L"";
}
-void PasteIt(MCONTACT hContact, int mode)
+static void PasteIt(MCONTACT hContact, int mode)
{
PasteToWeb* pasteToWeb = pasteToWebs[Options::instance->defWeb];
- if (mode == FROM_CLIPBOARD)
- {
+ if (mode == FROM_CLIPBOARD) {
pasteToWeb->FromClipboard();
}
- else if (mode == FROM_FILE)
- {
+ else if (mode == FROM_FILE) {
std::wstring file = GetFile();
- if (file.length() > 0)
- {
+ if (file.length() > 0) {
pasteToWeb->FromFile(file);
}
else return;
}
else return;
- if (pasteToWeb->szFileLink[0] == 0 && pasteToWeb->error != nullptr)
- {
+ if (pasteToWeb->szFileLink[0] == 0 && pasteToWeb->error != nullptr) {
MessageBox(nullptr, pasteToWeb->error, TranslateT("Error"), MB_OK | MB_ICONERROR);
}
- else if (hContact != NULL && pasteToWeb->szFileLink[0] != 0)
- {
+ else if (hContact != NULL && pasteToWeb->szFileLink[0] != 0) {
char *szProto = GetContactProto(hContact);
- if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND)
- {
+ if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND) {
BOOL isChat = db_get_b(hContact, szProto, "ChatRoom", 0);
- if (Options::instance->autoSend)
- {
- if (!isChat)
- {
+ if (Options::instance->autoSend) {
+ if (!isChat) {
DBEVENTINFO dbei = {};
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_SENT;
@@ -134,23 +121,20 @@ void PasteIt(MCONTACT hContact, int mode)
db_event_add(hContact, &dbei);
ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)pasteToWeb->szFileLink);
}
- else
- {
+ else {
// PSS_MESSAGE is not compatible with chat rooms
// there are no simple method to send text to all users
// in chat room.
// Next step is to get all protocol sessions and find
// one with correct hContact
int cnt = pci->SM_GetCount(szProto);
- for (int i = 0; i < cnt; i++)
- {
+ for (int i = 0; i < cnt; i++) {
GC_INFO gci = {};
gci.iItem = i;
gci.pszModule = szProto;
gci.Flags = GCF_BYINDEX | GCF_HCONTACT | GCF_ID;
Chat_GetInfo(&gci);
- if (gci.hContact == hContact)
- {
+ if (gci.hContact == hContact) {
// In this place session was finded, gci.pszID contains
// session ID, but it is in unicode or ascii format,
// depends on protocol wersion
@@ -163,10 +147,8 @@ void PasteIt(MCONTACT hContact, int mode)
// Send message to focus window
CallServiceSync(MS_MSG_SENDMESSAGE, hContact, 0);
}
- else
- {
- if (isChat)
- {
+ else {
+ if (isChat) {
// MS_MSG_SENDMESSAGE in incompatible with chat rooms,
// because it sends text to IDC_MESSAGE window,
// but in chat rooms is only IDC_CHAT_MESSAGE window.
@@ -174,8 +156,7 @@ void PasteIt(MCONTACT hContact, int mode)
// with assaigned to them chat windows.
// This map is prepared in ME_MSG_WINDOWEVENT event.
std::map<MCONTACT, HWND>::iterator it = contactWindows->find(hContact);
- if (it != contactWindows->end())
- {
+ if (it != contactWindows->end()) {
// it->second is imput window, so now I can send to them
// new text. Afterr all is sended MS_MSG_SENDMESSAGE
// to focus window.
@@ -183,14 +164,12 @@ void PasteIt(MCONTACT hContact, int mode)
SendMessageA(it->second, EM_REPLACESEL, FALSE, (LPARAM)pasteToWeb->szFileLink);
CallServiceSync(MS_MSG_SENDMESSAGE, hContact, NULL);
}
- else
- {
+ else {
// If window do not exist, maybe it is not chat
CallServiceSync(MS_MSG_SENDMESSAGE, hContact, (LPARAM)pasteToWeb->szFileLink);
}
}
- else
- {
+ else {
CallServiceSync(MS_MSG_SENDMESSAGE, hContact, (LPARAM)pasteToWeb->szFileLink);
}
}
@@ -198,22 +177,18 @@ void PasteIt(MCONTACT hContact, int mode)
}
}
-int TabsrmmButtonPressed(WPARAM hContact, LPARAM lParam)
+static int TabsrmmButtonPressed(WPARAM hContact, LPARAM lParam)
{
CustomButtonClickData *cbc = (CustomButtonClickData *)lParam;
- if (!mir_strcmp(cbc->pszModule, MODULE) && cbc->dwButtonId == 1 && hContact)
- {
- if (cbc->flags == BBCF_ARROWCLICKED)
- {
+ if (!mir_strcmp(cbc->pszModule, MODULE) && cbc->dwButtonId == 1 && hContact) {
+ if (cbc->flags == BBCF_ARROWCLICKED) {
HMENU hMenu = CreatePopupMenu();
- if (hMenu)
- {
+ if (hMenu) {
AppendMenu(hMenu, MF_STRING, FROM_CLIPBOARD, TranslateT("Paste from clipboard"));
AppendMenu(hMenu, MF_STRING, FROM_FILE, TranslateT("Paste from file"));
HMENU hDefMenu = CreatePopupMenu();
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
UINT flags = MF_STRING;
if (Options::instance->defWeb == i)
flags |= MF_CHECKED;
@@ -226,20 +201,16 @@ int TabsrmmButtonPressed(WPARAM hContact, LPARAM lParam)
POINT pt;
GetCursorPos(&pt);
HWND hwndBtn = WindowFromPoint(pt);
- if (hwndBtn)
- {
+ if (hwndBtn) {
RECT rc;
GetWindowRect(hwndBtn, &rc);
SetForegroundWindow(cbc->hwndFrom);
int selected = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, cbc->hwndFrom, nullptr);
- if (selected != 0)
- {
- if (selected >= DEF_PAGES_START)
- {
+ if (selected != 0) {
+ if (selected >= DEF_PAGES_START) {
Options::instance->SetDefWeb(selected - DEF_PAGES_START);
}
- else
- {
+ else {
PasteIt(hContact, selected);
}
}
@@ -249,8 +220,7 @@ int TabsrmmButtonPressed(WPARAM hContact, LPARAM lParam)
DestroyMenu(hMenu);
}
}
- else
- {
+ else {
PasteIt(hContact, FROM_CLIPBOARD);
}
}
@@ -258,7 +228,7 @@ int TabsrmmButtonPressed(WPARAM hContact, LPARAM lParam)
return 0;
}
-int PrebuildContactMenu(WPARAM wParam, LPARAM)
+static int PrebuildContactMenu(WPARAM wParam, LPARAM)
{
bool bIsContact = false;
@@ -270,7 +240,7 @@ int PrebuildContactMenu(WPARAM wParam, LPARAM)
return 0;
}
-INT_PTR ContactMenuService(WPARAM hContact, LPARAM lParam)
+static INT_PTR ContactMenuService(WPARAM hContact, LPARAM lParam)
{
if (lParam >= DEF_PAGES_START)
Options::instance->SetDefWeb(lParam - DEF_PAGES_START);
@@ -279,10 +249,10 @@ INT_PTR ContactMenuService(WPARAM hContact, LPARAM lParam)
return 0;
}
-void InitMenuItems()
+static void InitMenuItems()
{
CMenuItem mi;
-
+
SET_UID(mi, 0x33ecc112, 0x6, 0x487d, 0xbb, 0x8b, 0x76, 0xb4, 0x17, 0x9b, 0xdb, 0xc5);
mi.flags = CMIF_UNICODE;
mi.hIcolibItem = icon.hIcolib;
@@ -292,7 +262,7 @@ void InitMenuItems()
memset(&mi, 0, sizeof(mi));
SET_UID(mi, 0xedc0456d, 0x5aa8, 0x4a61, 0xbe, 0xfd, 0xed, 0x34, 0xb2, 0xcc, 0x6, 0x54);
- mi.flags = CMIF_UNICODE;
+ mi.flags = CMIF_UNICODE;
mi.pszService = MS_PASTEIT_CONTACTMENU;
mi.root = hContactMenu;
mi.name.w = LPGENW("Paste from clipboard");
@@ -310,9 +280,8 @@ void InitMenuItems()
CMenuItem mi2;
mi2.pszService = MS_PASTEIT_CONTACTMENU;
mi2.root = hDefWebMenu;
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
- mi2.flags = CMIF_UNICODE | CMIF_UNMOVABLE;
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
+ mi2.flags = CMIF_UNICODE | CMIF_UNMOVABLE;
if (Options::instance->defWeb == i)
mi2.flags |= CMIF_CHECKED;
mi2.name.w = pasteToWebs[i]->GetName();
@@ -331,7 +300,7 @@ void DefWebPageChanged()
}
}
-void InitTabsrmmButton()
+static void InitTabsrmmButton()
{
BBButton btn = {};
btn.dwButtonID = 1;
@@ -348,24 +317,19 @@ void InitTabsrmmButton()
hTabsrmmButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed);
}
-int WindowEvent(WPARAM, MessageWindowEventData* lParam)
+static int WindowEvent(WPARAM, MessageWindowEventData* lParam)
{
- if (lParam->uType == MSG_WINDOW_EVT_OPEN)
- {
+ if (lParam->uType == MSG_WINDOW_EVT_OPEN) {
char *szProto = GetContactProto(lParam->hContact);
- if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND)
- {
- if (db_get_b(lParam->hContact, szProto, "ChatRoom", 0))
- {
+ if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND) {
+ if (db_get_b(lParam->hContact, szProto, "ChatRoom", 0)) {
(*contactWindows)[lParam->hContact] = lParam->hwndInput;
}
}
}
- else if (lParam->uType == MSG_WINDOW_EVT_CLOSE)
- {
+ else if (lParam->uType == MSG_WINDOW_EVT_CLOSE) {
std::map<MCONTACT, HWND>::iterator it = contactWindows->find(lParam->hContact);
- if (it != contactWindows->end())
- {
+ if (it != contactWindows->end()) {
contactWindows->erase(it);
}
}
@@ -373,7 +337,7 @@ int WindowEvent(WPARAM, MessageWindowEventData* lParam)
return 0;
}
-int ModulesLoaded(WPARAM, LPARAM)
+static int ModulesLoaded(WPARAM, LPARAM)
{
InitMenuItems();
InitTabsrmmButton();
@@ -387,7 +351,7 @@ extern "C" int __declspec(dllexport) Load(void)
mir_getLP(&pluginInfo);
pci = Chat_GetInterface();
- Icon_Register(hInst, LPGEN("Paste It"), &icon, 1);
+ Icon_Register(g_plugin.getInst(), LPGEN("Paste It"), &icon, 1);
NETLIBUSER nlu = {};
nlu.flags = NUF_UNICODE | NUF_OUTGOING | NUF_HTTPCONNS;
@@ -411,6 +375,8 @@ extern "C" int __declspec(dllexport) Load(void)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload(void)
{
UnhookEvent(hModulesLoaded);
diff --git a/plugins/PasteIt/src/PasteToWeb.cpp b/plugins/PasteIt/src/PasteToWeb.cpp
index 09786c738a..358564bdb6 100644
--- a/plugins/PasteIt/src/PasteToWeb.cpp
+++ b/plugins/PasteIt/src/PasteToWeb.cpp
@@ -356,7 +356,7 @@ void PasteToWeb::FromClipboard()
FromClipboardData data;
data.content = str;
data.page = pageIndex;
- if (Options::instance->confDlg && DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_FROM_CLIPBOARD), nullptr, DlgProcFromClipboard, (LPARAM)&data) != IDC_BTN_OK)
+ if (Options::instance->confDlg && DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DLG_FROM_CLIPBOARD), nullptr, DlgProcFromClipboard, (LPARAM)&data) != IDC_BTN_OK)
return;
SendToServer(str, L"", data.format);
@@ -473,7 +473,7 @@ void PasteToWeb::FromFile(std::wstring file)
fromFileData.contentW[cbLen] = 0;
fromFileData.page = pageIndex;
- if (!Options::instance->confDlg || DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_FROM_FILE), nullptr, DlgProcFromFile, (LPARAM)&fromFileData) == IDC_BTN_OK)
+ if (!Options::instance->confDlg || DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DLG_FROM_FILE), nullptr, DlgProcFromFile, (LPARAM)&fromFileData) == IDC_BTN_OK)
{
std::wstring fileName;
std::wstring::size_type pos1 = file.find_last_of(L'\\');
diff --git a/plugins/PasteIt/src/stdafx.h b/plugins/PasteIt/src/stdafx.h
index 6b2d795b3a..139b7ed2dc 100644
--- a/plugins/PasteIt/src/stdafx.h
+++ b/plugins/PasteIt/src/stdafx.h
@@ -18,7 +18,6 @@
#include <map>
#include <list>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_langpack.h>
@@ -37,7 +36,13 @@
#include "resource.h"
#include "Options.h"
-extern HINSTANCE hInst;
extern PasteToWeb* pasteToWebs[PasteToWeb::pages];
-#define MODULE "PasteIt"
+#define MODULE "PasteIt"
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE)
+ {}
+};
diff --git a/plugins/Ping/src/options.cpp b/plugins/Ping/src/options.cpp
index 3909b2ce6c..e1c880cd87 100644
--- a/plugins/Ping/src/options.cpp
+++ b/plugins/Ping/src/options.cpp
@@ -276,7 +276,7 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
bool Edit(HWND hwnd, PINGADDRESS &addr)
{
add_edit_addr = addr;
- if (DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwnd, DlgProcDestEdit) == IDOK)
+ if (DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG3), hwnd, DlgProcDestEdit) == IDOK)
{
addr = add_edit_addr;
return true;
@@ -360,7 +360,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
add_edit_addr.item_id = 0;
add_edit_addr.index = (int)temp_list.size();
- if (DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndDlg, DlgProcDestEdit) == IDOK)
+ if (DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG3), hwndDlg, DlgProcDestEdit) == IDOK)
{
temp_list.push_back(add_edit_addr);
@@ -497,7 +497,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
int PingOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.szGroup.w = LPGENW("Network");
odp.szTitle.w = LPGENW("Ping");
diff --git a/plugins/Ping/src/ping.cpp b/plugins/Ping/src/ping.cpp
index 42112e98bc..1e9a7de001 100644
--- a/plugins/Ping/src/ping.cpp
+++ b/plugins/Ping/src/ping.cpp
@@ -1,7 +1,7 @@
#include "stdafx.h"
CLIST_INTERFACE *pcli;
-HINSTANCE hInst;
+CMPlugin g_plugin;
int hLangpack = 0;
HNETLIBUSER hNetlibUser = nullptr;
@@ -9,8 +9,10 @@ HANDLE hFillListEvent = nullptr;
bool use_raw_ping = true;
-// plugin stuff
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -23,18 +25,14 @@ PLUGININFOEX pluginInfo = {
{ 0x760ea901, 0xc0c2, 0x446c, { 0x80, 0x29, 0x94, 0xc3, 0xbc, 0x47, 0xc4, 0x5e } }
};
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
-void CreatePluginServices()
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static void CreatePluginServices()
{
// general
CreateServiceFunction(PLUG "/Ping", PluginPing);
@@ -65,7 +63,8 @@ void CreatePluginServices()
}
-int OnShutdown(WPARAM, LPARAM) {
+static int OnShutdown(WPARAM, LPARAM)
+{
graphs_cleanup();
UnhookEvent(hFillListEvent);
@@ -80,17 +79,15 @@ int OnShutdown(WPARAM, LPARAM) {
return 0;
}
-int OnModulesLoaded(WPARAM, LPARAM)
+static int OnModulesLoaded(WPARAM, LPARAM)
{
NETLIBUSER nl_user = {};
nl_user.szSettingsModule = PLUG;
nl_user.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE;
nl_user.szDescriptiveName.w = TranslateT("Ping Plugin");
-
hNetlibUser = Netlib_RegisterUser(&nl_user);
InitUtils();
-
InitMenus();
hFillListEvent = HookEvent(PLUG "/ListReload", FillList);
@@ -108,7 +105,8 @@ int OnModulesLoaded(WPARAM, LPARAM)
graphs_init();
- if (options.logging) CallService(PLUG "/Log", (WPARAM)L"start", 0);
+ if (options.logging)
+ CallService(PLUG "/Log", (WPARAM)L"start", 0);
return 0;
}
@@ -141,25 +139,24 @@ extern "C" __declspec(dllexport) int Load(void)
Skin_AddSound("PingReply", LPGENW("Ping"), LPGENW("Reply"));
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
-
HookEvent(ME_OPT_INITIALISE, PingOptInit);
-
HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
-
- Icon_Register(hInst, LPGEN("Ping"), iconList, _countof(iconList));
-
HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
+ Icon_Register(g_plugin.getInst(), LPGEN("Ping"), iconList, _countof(iconList));
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
SavePingList(0, 0);
CloseHandle(mainThread);
- if (options.logging) CallService(PLUG "/Log", (WPARAM)L"stop", 0);
+ if (options.logging)
+ CallService(PLUG "/Log", (WPARAM)L"stop", 0);
return 0;
}
diff --git a/plugins/Ping/src/pinggraph.cpp b/plugins/Ping/src/pinggraph.cpp
index 554c740c61..b9efbc01e8 100644
--- a/plugins/Ping/src/pinggraph.cpp
+++ b/plugins/Ping/src/pinggraph.cpp
@@ -45,11 +45,11 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
WindowData *wd = (WindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (wd->hwnd_chk_grid == nullptr) {
- wd->hwnd_chk_grid = CreateWindow(L"BUTTON", TranslateT("Show grid lines"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 0, 0, 0, 0, hwnd, nullptr, hInst, nullptr);
+ wd->hwnd_chk_grid = CreateWindow(L"BUTTON", TranslateT("Show grid lines"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 0, 0, 0, 0, hwnd, nullptr, g_plugin.getInst(), nullptr);
SendMessage(wd->hwnd_chk_grid, BM_SETCHECK, wd->show_grid ? BST_CHECKED : BST_UNCHECKED, 0);
}
if (wd->hwnd_chk_stat == nullptr) {
- wd->hwnd_chk_stat = CreateWindow(L"BUTTON", TranslateT("Show stats"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 0, 0, 0, 0, hwnd, nullptr, hInst, nullptr);
+ wd->hwnd_chk_stat = CreateWindow(L"BUTTON", TranslateT("Show stats"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 0, 0, 0, 0, hwnd, nullptr, g_plugin.getInst(), nullptr);
SendMessage(wd->hwnd_chk_stat, BM_SETCHECK, wd->show_stat ? BST_CHECKED : BST_UNCHECKED, 0);
}
KillTimer(hwnd, ID_REPAINT_TIMER);
@@ -267,7 +267,7 @@ INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) {
wndclass.lpfnWndProc = GraphWindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInst;
+ wndclass.hInstance = g_plugin.getInst();
wndclass.hIcon = hIconResponding;
wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
@@ -285,7 +285,7 @@ INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) {
HWND parent = nullptr;
hGraphWnd = CreateWindowEx(0, _A2W(PLUG) L"GraphWindow", title,
(WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN) & ~CS_VREDRAW & ~CS_HREDRAW,
- 0, 0, 800, 600, parent, nullptr, hInst, nullptr);
+ 0, 0, 800, 600, parent, nullptr, g_plugin.getInst(), nullptr);
WindowData *wd = new WindowData;
wd->item_id = (DWORD)wParam; // wParam is destination id
diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp
index 6bac84f199..077dfa855b 100644
--- a/plugins/Ping/src/pingthread.cpp
+++ b/plugins/Ping/src/pingthread.cpp
@@ -418,7 +418,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
context_point = lParam;
context_point_valid = true;
InvalidateRect(list_hwnd, nullptr, FALSE);
- HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)),
+ HMENU menu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MENU1)),
submenu = GetSubMenu(menu, 0);
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
@@ -474,7 +474,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
list_hwnd = CreateWindow(L"LISTBOX", L"",
//(WS_VISIBLE | WS_CHILD | LBS_NOINTEGRALHEIGHT| LBS_STANDARD | WS_CLIPCHILDREN | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY)
(WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_NOTIFY)
- & ~WS_BORDER, 0, 0, 0, 0, hwnd, nullptr, hInst, nullptr);
+ & ~WS_BORDER, 0, 0, 0, 0, hwnd, nullptr, g_plugin.getInst(), nullptr);
if (db_get_b(NULL, "CList", "Transparent", 0)) {
if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
@@ -850,7 +850,7 @@ void InitList()
wndclass.lpfnWndProc = FrameWindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInst;
+ wndclass.hInstance = g_plugin.getInst();
wndclass.hIcon = hIconResponding;
wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
@@ -859,7 +859,7 @@ void InitList()
RegisterClass(&wndclass);
if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
- hpwnd = CreateWindow(_A2W(PLUG) L"WindowClass", L"Ping", (WS_BORDER | WS_CHILD | WS_CLIPCHILDREN), 0, 0, 0, 0, hwnd_clist, nullptr, hInst, nullptr);
+ hpwnd = CreateWindow(_A2W(PLUG) L"WindowClass", L"Ping", (WS_BORDER | WS_CHILD | WS_CLIPCHILDREN), 0, 0, 0, 0, hwnd_clist, nullptr, g_plugin.getInst(), nullptr);
CLISTFrame frame = { 0 };
frame.name = PLUG;
@@ -875,7 +875,7 @@ void InitList()
else {
hpwnd = CreateWindowEx(WS_EX_TOOLWINDOW, _A2W(PLUG) L"WindowClass", L"Ping",
(WS_POPUPWINDOW | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN),
- 0, 0, 400, 300, hwnd_clist, nullptr, hInst, nullptr);
+ 0, 0, 400, 300, hwnd_clist, nullptr, g_plugin.getInst(), nullptr);
Utils_RestoreWindowPosition(hpwnd, 0, PLUG, "main_window");
diff --git a/plugins/Ping/src/stdafx.h b/plugins/Ping/src/stdafx.h
index 14049e295f..3e1c99c68f 100644
--- a/plugins/Ping/src/stdafx.h
+++ b/plugins/Ping/src/stdafx.h
@@ -12,7 +12,6 @@
#include <Icmpapi.h>
#include <list>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_options.h>
#include <m_langpack.h>
@@ -55,6 +54,12 @@
#define MAX_PINGADDRESS_STRING_LENGTH 256
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(PLUG)
+ {}
+};
typedef struct {
int ping_period, ping_timeout;
@@ -105,13 +110,12 @@ struct PINGADDRESS {
};
#include "options.h"
+
typedef Map<DWORD, HistoryList> HistoryMap;
typedef std::list<PINGADDRESS> PINGLIST;
typedef std::list<PINGADDRESS>::iterator pinglist_it;
-
extern HNETLIBUSER hNetlibUser;
-extern HINSTANCE hInst;
extern bool use_raw_ping;
diff --git a/plugins/Ping/src/utils.cpp b/plugins/Ping/src/utils.cpp
index cf900a3ffa..59e0c6b5fd 100644
--- a/plugins/Ping/src/utils.cpp
+++ b/plugins/Ping/src/utils.cpp
@@ -189,7 +189,7 @@ INT_PTR EditContact(WPARAM wParam, LPARAM)
add_edit_addr = *i;
- if (DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndList, DlgProcDestEdit) == IDOK) {
+ if (DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG3), hwndList, DlgProcDestEdit) == IDOK) {
*i = add_edit_addr;
CallService(PLUG "/SetAndSavePingList", (WPARAM)&pl, 0);
diff --git a/plugins/QuickMessages/src/Utils.cpp b/plugins/QuickMessages/src/Utils.cpp
index 77a2cea691..1fa555b4c6 100644
--- a/plugins/QuickMessages/src/Utils.cpp
+++ b/plugins/QuickMessages/src/Utils.cpp
@@ -225,7 +225,7 @@ BYTE getEntryByte(int buttonnum, int entrynum, BOOL mode)
static HANDLE AddIcon(char* szIcoName)
{
wchar_t tszPath[MAX_PATH];
- GetModuleFileName(hinstance, tszPath, _countof(tszPath));
+ GetModuleFileName(g_plugin.getInst(), tszPath, _countof(tszPath));
SKINICONDESC sid = {};
sid.flags = SIDF_PATH_UNICODE;
diff --git a/plugins/QuickMessages/src/main.cpp b/plugins/QuickMessages/src/main.cpp
index cd9da5c4bc..8d6060fade 100644
--- a/plugins/QuickMessages/src/main.cpp
+++ b/plugins/QuickMessages/src/main.cpp
@@ -19,18 +19,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-HINSTANCE hinstance;
int hLangpack;
+CMPlugin g_plugin;
WNDPROC mainProc;
-int g_iButtonsCount=0;
-int g_bStartup=0;
-BOOL g_bRClickAuto=0;
-BOOL g_bLClickAuto=0;
-BOOL g_bQuickMenu=0;
+int g_iButtonsCount = 0;
+int g_bStartup = 0;
+BOOL g_bRClickAuto = 0;
+BOOL g_bLClickAuto = 0;
+BOOL g_bQuickMenu = 0;
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -43,6 +46,13 @@ PLUGININFOEX pluginInfo = {
{ 0x37ed754b, 0x6cf9, 0x40ed, { 0x9e, 0xb6, 0xf, 0xef, 0x8e, 0x82, 0x24, 0x75 } }
};
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
int PreShutdown(WPARAM, LPARAM)
{
DestructButtonsList();
@@ -101,7 +111,7 @@ static int InputMenuPopup(WPARAM, LPARAM lParam)
textlenght = cr.cpMax - cr.cpMin;
if (textlenght) {
- pszText = (wchar_t *)mir_alloc((textlenght + 10)*sizeof(wchar_t));
+ pszText = (wchar_t *)mir_alloc((textlenght + 10) * sizeof(wchar_t));
memset(pszText, 0, ((textlenght + 10) * sizeof(wchar_t)));
SendMessage(mwpd->hwnd, EM_GETSELTEXT, 0, (LPARAM)pszText);
}
@@ -160,7 +170,7 @@ static int CustomButtonPressed(WPARAM, LPARAM lParam)
UINT textlenght = cr.cpMax - cr.cpMin;
if (textlenght) {
- pszText = (wchar_t *)mir_alloc((textlenght + 10)*sizeof(wchar_t));
+ pszText = (wchar_t *)mir_alloc((textlenght + 10) * sizeof(wchar_t));
memset(pszText, 0, ((textlenght + 10) * sizeof(wchar_t)));
SendMessage(hEdit, EM_GETSELTEXT, 0, (LPARAM)pszText);
}
@@ -195,7 +205,7 @@ static int CustomButtonPressed(WPARAM, LPARAM lParam)
case 3:
if (!g_iButtonsCount)
break;
-
+
HMENU hMenu = CreatePopupMenu(), hSubMenu = nullptr;
for (int menunum = 0; menunum < sl->realCount; menunum++) {
@@ -216,8 +226,8 @@ static int CustomButtonPressed(WPARAM, LPARAM lParam)
AppendMenu((HMENU)((hSubMenu && !bSetPopupMark) ? hSubMenu : hMenu), MF_SEPARATOR, 0, nullptr);
else
AppendMenu((HMENU)((hSubMenu && !bSetPopupMark) ? hSubMenu : hMenu),
- MF_STRING | (bSetPopupMark ? MF_POPUP : 0),
- (bSetPopupMark ? (UINT_PTR)hSubMenu : (menunum + 1)), bd->pszName);
+ MF_STRING | (bSetPopupMark ? MF_POPUP : 0),
+ (bSetPopupMark ? (UINT_PTR)hSubMenu : (menunum + 1)), bd->pszName);
}
int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, nullptr);
@@ -267,27 +277,18 @@ static int PluginInit(WPARAM, LPARAM)
return 0;
}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+extern "C" __declspec(dllexport) int Load(void)
{
- return &pluginInfo;
-}
+ mir_getLP(&pluginInfo);
-extern "C" __declspec(dllexport) int Unload(void)
-{
+ HookEvent(ME_SYSTEM_MODULESLOADED, PluginInit);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
return 0;
}
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID)
-{
- hinstance = hinst;
- return 1;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
-extern "C" __declspec(dllexport) int Load(void)
+extern "C" __declspec(dllexport) int Unload(void)
{
- mir_getLP(&pluginInfo);
-
- HookEvent(ME_SYSTEM_MODULESLOADED, PluginInit);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
return 0;
}
diff --git a/plugins/QuickMessages/src/options.cpp b/plugins/QuickMessages/src/options.cpp
index a9799aa64d..22da0bf26b 100644
--- a/plugins/QuickMessages/src/options.cpp
+++ b/plugins/QuickMessages/src/options.cpp
@@ -920,7 +920,7 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
switch (LOWORD(wparam)) {
case IDC_VARHELP:
if (!g_varhelpDlg)
- g_varhelpDlg = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_HELPDIALOG), nullptr, HelpDlgProc);
+ g_varhelpDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_HELPDIALOG), nullptr, HelpDlgProc);
else
//ShowWindow(g_varhelpDlg,SW_SHOWDEFAULT);
SetWindowPos(g_varhelpDlg, nullptr, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
@@ -1085,7 +1085,7 @@ int OptionsInit(WPARAM wparam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 940000000;
- odp.hInstance = hinstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.szTitle.a = LPGEN("Quick Messages");
odp.pfnDlgProc = OptionsProc;
diff --git a/plugins/QuickMessages/src/stdafx.h b/plugins/QuickMessages/src/stdafx.h
index 4672bdb74c..f41f46e448 100644
--- a/plugins/QuickMessages/src/stdafx.h
+++ b/plugins/QuickMessages/src/stdafx.h
@@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <commctrl.h>
#include <Richedit.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_options.h>
@@ -44,7 +43,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PLGNAME "QuickMessages"
-extern HINSTANCE hinstance;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(PLGNAME)
+ {}
+};
+
extern HANDLE hIcolib;
extern ListData *ButtonsList[100];
extern SortedList *QuickList;
diff --git a/plugins/QuickReplies/src/events.cpp b/plugins/QuickReplies/src/events.cpp
index 23ec25f537..3e5a663eaf 100644
--- a/plugins/QuickReplies/src/events.cpp
+++ b/plugins/QuickReplies/src/events.cpp
@@ -30,7 +30,7 @@ int OnModulesLoaded(WPARAM, LPARAM)
HookEvent(ME_OPT_INITIALISE, OnOptInitialized);
HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed);
- Icon_Register(hInstance, "TabSRMM/Quick Replies", &icon, 1);
+ Icon_Register(g_plugin.getInst(), "TabSRMM/Quick Replies", &icon, 1);
char buttonNameTranslated[32], buttonName[32];
mir_snprintf(buttonNameTranslated, "%s %x", Translate("Button"), iNumber + 1);
diff --git a/plugins/QuickReplies/src/options.cpp b/plugins/QuickReplies/src/options.cpp
index 29477c53a7..46abcd6ba6 100644
--- a/plugins/QuickReplies/src/options.cpp
+++ b/plugins/QuickReplies/src/options.cpp
@@ -169,7 +169,7 @@ int OnOptInitialized(WPARAM wParam, LPARAM)
odp.szTitle.a = LPGEN("Quick Replies");
odp.szTab.a = tabName;
odp.position = iNumber;
- odp.hInstance = hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_PAGE);
odp.pfnDlgProc = DlgProcOptionsPage;
Options_AddPage(wParam, &odp);
diff --git a/plugins/QuickReplies/src/quickreplies.cpp b/plugins/QuickReplies/src/quickreplies.cpp
index 428b0ec6b2..a4718893d7 100644
--- a/plugins/QuickReplies/src/quickreplies.cpp
+++ b/plugins/QuickReplies/src/quickreplies.cpp
@@ -19,10 +19,13 @@ Boston, MA 02111-1307, USA.
#include "stdafx.h"
-HINSTANCE hInstance = nullptr;
int hLangpack;
+CMPlugin g_plugin;
-PLUGININFOEX pluginInfoEx = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfoEx =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -35,17 +38,13 @@ PLUGININFOEX pluginInfoEx = {
{0xa6a031b6, 0xd32f, 0x4842, {0x98, 0xc6, 0xec, 0x71, 0x6c, 0x57, 0x6b, 0x77}}
};
-BOOL WINAPI DllMain(HINSTANCE hInstanceDLL, DWORD, LPVOID)
-{
- hInstance = hInstanceDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfoEx);
@@ -54,6 +53,8 @@ extern "C" __declspec(dllexport) int Load(void)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
return 0;
diff --git a/plugins/QuickReplies/src/stdafx.h b/plugins/QuickReplies/src/stdafx.h
index d4aadc189d..f56d5845d1 100644
--- a/plugins/QuickReplies/src/stdafx.h
+++ b/plugins/QuickReplies/src/stdafx.h
@@ -23,7 +23,6 @@ Boston, MA 02111-1307, USA.
#include <windows.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_utils.h>
#include <m_string.h>
@@ -38,9 +37,15 @@ Boston, MA 02111-1307, USA.
#define MODULE "QuickReplies"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE)
+ {}
+};
+
#define MS_QUICKREPLIES_SERVICE MODULE"/Service"
-extern HINSTANCE hInstance;
extern int iNumber;
int OnModulesLoaded(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp
index 5667ffe7e4..6894cbf16e 100644
--- a/plugins/Sessions/Src/Main.cpp
+++ b/plugins/Sessions/Src/Main.cpp
@@ -19,8 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-HINSTANCE g_hInst = nullptr;
-
HGENMENU hmSaveCurrentSession;
HANDLE hmTBButton[2], hiTBbutton[2], iTBbutton[2];
@@ -46,11 +44,25 @@ MCONTACT session_list[255] = { 0 };
MCONTACT user_session_list[255] = { 0 };
MCONTACT session_list_recovered[255];
+CMPlugin g_plugin;
int hLangpack;
int OptionsInit(WPARAM, LPARAM);
-PLUGININFOEX pluginInfo = {
+IconItem iconList[] =
+{
+ { LPGEN("Sessions"), "Sessions", IDD_SESSION_CHECKED },
+ { LPGEN("Favorite Session"), "SessionMarked", IDD_SESSION_CHECKED },
+ { LPGEN("Not favorite Session"), "SessionUnMarked", IDD_SESSION_UNCHECKED },
+ { LPGEN("Load Session"), "SessionsLoad", IDI_SESSIONS_LOAD },
+ { LPGEN("Save Session"), "SessionsSave", IDD_SESSIONS_SAVE },
+ { LPGEN("Load last Session"), "SessionsLoadLast", IDD_SESSIONS_LOADLAST }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -63,15 +75,12 @@ PLUGININFOEX pluginInfo = {
{ 0x60558872, 0x2aab, 0x45aa, { 0x88, 0x8d, 0x9, 0x76, 0x91, 0xc9, 0xb6, 0x83 } }
};
-IconItem iconList[] =
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
- { LPGEN("Sessions"), "Sessions", IDD_SESSION_CHECKED },
- { LPGEN("Favorite Session"), "SessionMarked", IDD_SESSION_CHECKED },
- { LPGEN("Not favorite Session"), "SessionUnMarked", IDD_SESSION_UNCHECKED },
- { LPGEN("Load Session"), "SessionsLoad", IDI_SESSIONS_LOAD },
- { LPGEN("Save Session"), "SessionsSave", IDD_SESSIONS_SAVE },
- { LPGEN("Load last Session"), "SessionsLoadLast", IDD_SESSIONS_LOADLAST }
-};
+ return &pluginInfo;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
INT_PTR CALLBACK ExitDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM)
{
@@ -161,7 +170,7 @@ INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l
dd = 5;
hClistControl = CreateWindowEx(WS_EX_CLIENTEDGE, CLISTCONTROL_CLASSW, L"",
WS_TABSTOP | WS_VISIBLE | WS_CHILD,
- x, y, dx, dy, hdlg, (HMENU)IDC_CLIST, g_hInst, nullptr);
+ x, y, dx, dy, hdlg, (HMENU)IDC_CLIST, g_plugin.getInst(), nullptr);
SetWindowLongPtr(hClistControl, GWL_STYLE,
GetWindowLongPtr(hClistControl, GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES);
@@ -431,7 +440,7 @@ INT_PTR SaveUserSessionHandles(WPARAM, LPARAM)
return 1;
}
- g_hSDlg = CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_SAVEDIALOG), nullptr, SaveSessionDlgProc);
+ g_hSDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SAVEDIALOG), nullptr, SaveSessionDlgProc);
return 0;
}
@@ -446,7 +455,7 @@ INT_PTR OpenSessionsManagerWindow(WPARAM, LPARAM)
tszSession(db_get_wsa(NULL, MODNAME, "SessionDate_0")),
tszUserSession(db_get_wsa(NULL, MODNAME, "UserSessionDsc_0"));
if (g_bIncompletedSave || tszSession || tszUserSession) {
- g_hDlg = CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
+ g_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
return 0;
}
if (g_bOtherWarnings)
@@ -658,7 +667,7 @@ int OkToExit(WPARAM, LPARAM)
db_set_b(NULL, MODNAME, "lastempty", 0);
}
else if (exitmode == 1 && session_list[0] != 0) {
- DialogBox(g_hInst, MAKEINTRESOURCE(IDD_EXDIALOG), nullptr, ExitDlgProc);
+ DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EXDIALOG), nullptr, ExitDlgProc);
}
else db_set_b(NULL, MODNAME, "lastempty", 1);
return 0;
@@ -727,11 +736,11 @@ static void CALLBACK LaunchSessions()
int startup = db_get_b(NULL, MODNAME, "StartupMode", 3);
if (startup == 1 || (startup == 3 && isLastTRUE == TRUE)) {
StartUp = TRUE;
- g_hDlg = CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
+ g_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
}
else if (startup == 2 && isLastTRUE == TRUE) {
g_hghostw = TRUE;
- g_hDlg = CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
+ g_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
}
}
@@ -797,21 +806,7 @@ static int PluginInit(WPARAM, LPARAM)
return 0;
}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfo;
-}
-
-extern "C" __declspec(dllexport) int Unload(void)
-{
- return 0;
-}
-
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID)
-{
- g_hInst = hinst;
- return 1;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) int Load(void)
{
@@ -857,6 +852,13 @@ extern "C" __declspec(dllexport) int Load(void)
HookEvent(ME_SYSTEM_PRESHUTDOWN, SessionPreShutdown);
// Icons
- Icon_Register(g_hInst, MODNAME, iconList, _countof(iconList));
+ Icon_Register(g_plugin.getInst(), MODNAME, iconList, _countof(iconList));
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+extern "C" __declspec(dllexport) int Unload(void)
+{
return 0;
}
diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp
index 7bfbbcf1c8..b577147bbe 100644
--- a/plugins/Sessions/Src/Options.cpp
+++ b/plugins/Sessions/Src/Options.cpp
@@ -336,7 +336,7 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l
SetDlgItemText(hdlg, IDC_EDIT, TranslateT("View"));
hOpClistControl = CreateWindowEx(WS_EX_STATICEDGE, CLISTCONTROL_CLASSW, L"",
WS_TABSTOP | WS_VISIBLE | WS_CHILD,
- 14, 198, 161, 163, hdlg, (HMENU)IDC_EMCLIST, g_hInst, nullptr);
+ 14, 198, 161, 163, hdlg, (HMENU)IDC_EMCLIST, g_plugin.getInst(), nullptr);
SetWindowLongPtr(hOpClistControl, GWL_STYLE,
GetWindowLongPtr(hOpClistControl, GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES);
@@ -491,7 +491,7 @@ int OptionsInit(WPARAM wparam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 955000000;
- odp.hInstance = g_hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.szTitle.a = MODNAME;
odp.pfnDlgProc = OptionsProc;
diff --git a/plugins/Sessions/Src/stdafx.h b/plugins/Sessions/Src/stdafx.h
index 1cd5cfcf87..642ae6bc52 100644
--- a/plugins/Sessions/Src/stdafx.h
+++ b/plugins/Sessions/Src/stdafx.h
@@ -26,7 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <malloc.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_options.h>
#include <m_clc.h>
@@ -48,6 +47,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MODNAME "Sessions"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODNAME)
+ {}
+};
+
extern IconItem iconList[];
#define MIIM_STRING 0x00000040
@@ -61,7 +67,6 @@ int SaveUserSessionName(wchar_t*);
INT_PTR CloseCurrentSession(WPARAM, LPARAM);
int SaveSessionDate();
-extern HINSTANCE g_hInst;
extern MCONTACT session_list_recovered[255];
extern MCONTACT session_list[255];
extern int g_ses_limit;
diff --git a/plugins/TranslitSwitcher/src/TranslitSwitcher.cpp b/plugins/TranslitSwitcher/src/TranslitSwitcher.cpp
index 7cba65cf85..223bb849e6 100644
--- a/plugins/TranslitSwitcher/src/TranslitSwitcher.cpp
+++ b/plugins/TranslitSwitcher/src/TranslitSwitcher.cpp
@@ -19,10 +19,18 @@ Boston, MA 02111-1307, USA.
#include "stdafx.h"
-HINSTANCE hInst = nullptr;
-
int hLangpack;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(nullptr)
+ {}
+}
+g_plugin;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -36,6 +44,13 @@ PLUGININFOEX pluginInfoEx = {
{ 0x286947d, 0x3140, 0x4222, { 0xb5, 0xad, 0x2c, 0x92, 0x31, 0x5e, 0x1c, 0x1e } }
};
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfoEx;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static IconItem iconList[] =
{
{ LPGEN("Switch Layout and Send"), "Switch Layout and Send", IDI_SWITCHSEND },
@@ -43,17 +58,6 @@ static IconItem iconList[] =
{ LPGEN("Invert Case and Send"), "Invert Case and Send", IDI_INVERTSEND },
};
-bool WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return true;
-}
-
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
//-------------------------------------------------------------------------------------------------------
#define MS_TS_SWITCHLAYOUT "TranslitSwitcher/SwitchLayout"
INT_PTR ServiceSwitch(WPARAM, LPARAM lParam)
@@ -80,7 +84,7 @@ int OnModulesLoaded(WPARAM, LPARAM)
{
HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed);
- Icon_Register(hInst, "TabSRMM/TranslitSwitcher", iconList, _countof(iconList));
+ Icon_Register(g_plugin.getInst(), "TabSRMM/TranslitSwitcher", iconList, _countof(iconList));
BBButton bbd = {};
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON;
@@ -107,7 +111,7 @@ int OnModulesLoaded(WPARAM, LPARAM)
return 0;
}
-//-------------------------------------------------------------------------------------------------------
+/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) int Load(void)
{
@@ -162,6 +166,8 @@ extern "C" __declspec(dllexport) int Load(void)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
return 0;
diff --git a/plugins/TranslitSwitcher/src/stdafx.h b/plugins/TranslitSwitcher/src/stdafx.h
index 6939fee8c6..fd6e7cd3c7 100644
--- a/plugins/TranslitSwitcher/src/stdafx.h
+++ b/plugins/TranslitSwitcher/src/stdafx.h
@@ -23,7 +23,6 @@ Boston, MA 02111-1307, USA.
#include <windows.h>
#include <commctrl.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_langpack.h>
#include <m_utils.h>