summaryrefslogtreecommitdiff
path: root/plugins/Sessions
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/Sessions
parent7639f72273189df60566755c0d5f1e4ab7201b67 (diff)
OpenFolder, PackUpdater, PasteIt, Ping, QuickMessages, QuickReplies, Sessions, TranslitSwitcher => CMPlugin
Diffstat (limited to 'plugins/Sessions')
-rw-r--r--plugins/Sessions/Src/Main.cpp68
-rw-r--r--plugins/Sessions/Src/Options.cpp4
-rw-r--r--plugins/Sessions/Src/stdafx.h9
3 files changed, 44 insertions, 37 deletions
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;