summaryrefslogtreecommitdiff
path: root/src/core/stdaway
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/stdaway')
-rw-r--r--src/core/stdaway/src/awaymsg.cpp6
-rw-r--r--src/core/stdaway/src/main.cpp8
-rw-r--r--src/core/stdaway/src/sendmsg.cpp24
-rw-r--r--src/core/stdaway/src/stdafx.h11
4 files changed, 24 insertions, 25 deletions
diff --git a/src/core/stdaway/src/awaymsg.cpp b/src/core/stdaway/src/awaymsg.cpp
index d5cc58afae..0a8014e618 100644
--- a/src/core/stdaway/src/awaymsg.cpp
+++ b/src/core/stdaway/src/awaymsg.cpp
@@ -78,7 +78,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP
ack.result = ACKRESULT_SUCCESS;
SendMessage(hwndDlg, HM_AWAYMSG, 0, (LPARAM)&ack);
}
- Utils_RestoreWindowPosition(hwndDlg, lParam, "SRAway", "AwayMsgDlg");
+ Utils_RestoreWindowPosition(hwndDlg, lParam, MODULENAME, "AwayMsgDlg");
return TRUE;
case HM_AWAYMSG:
@@ -111,7 +111,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP
case WM_DESTROY:
if (dat->hAwayMsgEvent) UnhookEvent(dat->hAwayMsgEvent);
- Utils_SaveWindowPosition(hwndDlg, dat->hContact, "SRAway", "AwayMsgDlg");
+ Utils_SaveWindowPosition(hwndDlg, dat->hContact, MODULENAME, "AwayMsgDlg");
WindowList_Remove(hWindowList, hwndDlg);
Window_FreeIcon_IcoLib(hwndDlg);
mir_free(dat);
@@ -126,7 +126,7 @@ static INT_PTR GetMessageCommand(WPARAM wParam, LPARAM)
SetForegroundWindow(hwnd);
SetFocus(hwnd);
}
- else CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_READAWAYMSG), NULL, ReadAwayMsgDlgProc, wParam);
+ else CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_READAWAYMSG), NULL, ReadAwayMsgDlgProc, wParam);
return 0;
}
diff --git a/src/core/stdaway/src/main.cpp b/src/core/stdaway/src/main.cpp
index f9b1b2e174..4ea617bc4e 100644
--- a/src/core/stdaway/src/main.cpp
+++ b/src/core/stdaway/src/main.cpp
@@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
int LoadAwayMsgModule(void);
-HINSTANCE hInst;
+CMPlugin g_plugin;
int hLangpack;
PLUGININFOEX pluginInfo = {
@@ -39,12 +39,6 @@ PLUGININFOEX pluginInfo = {
{ 0xe58558e3, 0x83e7, 0x44ef, {0x8e, 0x39, 0xd9, 0xe0, 0x54, 0x19, 0x56, 0xdf}}
};
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
diff --git a/src/core/stdaway/src/sendmsg.cpp b/src/core/stdaway/src/sendmsg.cpp
index 1ec83b0b38..532ad9d1ec 100644
--- a/src/core/stdaway/src/sendmsg.cpp
+++ b/src/core/stdaway/src/sendmsg.cpp
@@ -70,12 +70,12 @@ static const char* StatusModeToDbSetting(int status, const char *suffix)
static bool GetStatusModeByte(int status, const char *suffix, bool bDefault = false)
{
- return db_get_b(NULL, "SRAway", StatusModeToDbSetting(status, suffix), bDefault) != 0;
+ return db_get_b(NULL, MODULENAME, StatusModeToDbSetting(status, suffix), bDefault) != 0;
}
static void SetStatusModeByte(int status, const char *suffix, BYTE value)
{
- db_set_b(NULL, "SRAway", StatusModeToDbSetting(status, suffix), value);
+ db_set_b(NULL, MODULENAME, StatusModeToDbSetting(status, suffix), value);
}
static wchar_t* GetAwayMessage(int statusMode, char *szProto)
@@ -88,11 +88,11 @@ static wchar_t* GetAwayMessage(int statusMode, char *szProto)
DBVARIANT dbv;
if (GetStatusModeByte(statusMode, "UsePrev")) {
- if (db_get_ws(NULL, "SRAway", StatusModeToDbSetting(statusMode, "Msg"), &dbv))
+ if (db_get_ws(NULL, MODULENAME, StatusModeToDbSetting(statusMode, "Msg"), &dbv))
dbv.ptszVal = mir_wstrdup(GetDefaultMessage(statusMode));
}
else {
- if (db_get_ws(NULL, "SRAway", StatusModeToDbSetting(statusMode, "Default"), &dbv))
+ if (db_get_ws(NULL, MODULENAME, StatusModeToDbSetting(statusMode, "Default"), &dbv))
dbv.ptszVal = mir_wstrdup(GetDefaultMessage(statusMode));
for (int i = 0; dbv.ptszVal[i]; i++) {
@@ -231,7 +231,7 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
dat->countdown = 6;
SendMessage(hwndDlg, WM_TIMER, 0, 0);
Window_SetProtoIcon_IcoLib(hwndDlg, dat->szProto, dat->statusMode);
- Utils_RestoreWindowPosition(hwndDlg, NULL, "SRAway", "AwayMsgDlg");
+ Utils_RestoreWindowPosition(hwndDlg, NULL, MODULENAME, "AwayMsgDlg");
SetTimer(hwndDlg, 1, 1000, nullptr);
dat->hPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, DM_SRAWAY_SHUTDOWN);
}
@@ -265,7 +265,7 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
wchar_t str[1024];
GetDlgItemText(hwndDlg, IDC_MSG, str, _countof(str));
ChangeAllProtoMessages(dat->szProto, dat->statusMode, str);
- db_set_ws(NULL, "SRAway", StatusModeToDbSetting(dat->statusMode, "Msg"), str);
+ db_set_ws(NULL, MODULENAME, StatusModeToDbSetting(dat->statusMode, "Msg"), str);
DestroyWindow(hwndDlg);
}
else PostMessage(hwndDlg, WM_CLOSE, 0, 0);
@@ -286,7 +286,7 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
break;
case WM_DESTROY:
- Utils_SaveWindowPosition(hwndDlg, NULL, "SRAway", "AwayMsgDlg");
+ Utils_SaveWindowPosition(hwndDlg, NULL, MODULENAME, "AwayMsgDlg");
KillTimer(hwndDlg, 1);
UnhookEvent(dat->hPreshutdown);
Window_FreeIcon_IcoLib(hwndDlg);
@@ -332,7 +332,7 @@ static int StatusModeChange(WPARAM wParam, LPARAM lParam)
newdat->statusMode = statusMode;
if (hwndStatusMsg)
DestroyWindow(hwndStatusMsg);
- hwndStatusMsg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETAWAYMSG), NULL, SetAwayMsgDlgProc, (LPARAM)newdat);
+ hwndStatusMsg = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SETAWAYMSG), NULL, SetAwayMsgDlgProc, (LPARAM)newdat);
}
return 0;
}
@@ -388,8 +388,8 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam
dat->info[j].usePrevious = GetStatusModeByte(it, "UsePrev");
DBVARIANT dbv;
- if (db_get_ws(NULL, "SRAway", StatusModeToDbSetting(it, "Default"), &dbv))
- if (db_get_ws(NULL, "SRAway", StatusModeToDbSetting(it, "Msg"), &dbv))
+ if (db_get_ws(NULL, MODULENAME, StatusModeToDbSetting(it, "Default"), &dbv))
+ if (db_get_ws(NULL, MODULENAME, StatusModeToDbSetting(it, "Msg"), &dbv))
dbv.ptszVal = mir_wstrdup(GetDefaultMessage(it));
mir_wstrcpy(dat->info[j].msg, dbv.ptszVal);
mir_free(dbv.ptszVal);
@@ -494,7 +494,7 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam
SetStatusModeByte(status, "Ignore", (BYTE)dat->info[i].ignore);
SetStatusModeByte(status, "NoDlg", (BYTE)dat->info[i].noDialog);
SetStatusModeByte(status, "UsePrev", (BYTE)dat->info[i].usePrevious);
- db_set_ws(NULL, "SRAway", StatusModeToDbSetting(status, "Default"), dat->info[i].msg);
+ db_set_ws(NULL, MODULENAME, StatusModeToDbSetting(status, "Default"), dat->info[i].msg);
}
return TRUE;
}
@@ -517,7 +517,7 @@ static int AwayMsgOptInitialise(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 870000000;
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_AWAYMSG);
odp.szTitle.a = LPGEN("Status messages");
odp.szGroup.a = LPGEN("Status");
diff --git a/src/core/stdaway/src/stdafx.h b/src/core/stdaway/src/stdafx.h
index 44a47b363a..6ae1a5bd6a 100644
--- a/src/core/stdaway/src/stdafx.h
+++ b/src/core/stdaway/src/stdafx.h
@@ -40,9 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <direct.h>
#include <malloc.h>
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
-
#include <m_system.h>
#include <newpluginapi.h>
#include <m_utils.h>
@@ -68,4 +66,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../mir_app/src/resource.h"
-extern HINSTANCE hInst;
+#define MODULENAME "SRAway"
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};