summaryrefslogtreecommitdiff
path: root/plugins/SimpleStatusMsg
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SimpleStatusMsg')
-rw-r--r--plugins/SimpleStatusMsg/src/awaymsg.cpp4
-rw-r--r--plugins/SimpleStatusMsg/src/main.cpp6
-rw-r--r--plugins/SimpleStatusMsg/src/msgbox.cpp42
-rw-r--r--plugins/SimpleStatusMsg/src/simplestatusmsg.h5
-rw-r--r--plugins/SimpleStatusMsg/src/utils.cpp31
5 files changed, 36 insertions, 52 deletions
diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp
index d5ce014c16..0e0b646b29 100644
--- a/plugins/SimpleStatusMsg/src/awaymsg.cpp
+++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp
@@ -353,7 +353,7 @@ int LoadAwayMsgModule(void)
SET_UID(mi, 0x311124e9, 0xb477, 0x42ef, 0x84, 0xd2, 0xc, 0x6c, 0x50, 0x3f, 0x4a, 0x84);
CreateServiceFunction(MS_SIMPLESTATUSMSG_COPYMSG, CopyAwayMsgCommand);
mi.position = -2000006000;
- mi.hIcolibItem = GetIconHandle(IDI_COPY);
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_COPY);
mi.name.w = LPGENW("Copy Away message");
mi.pszService = MS_SIMPLESTATUSMSG_COPYMSG;
hCopyMsgMenuItem = Menu_AddContactMenuItem(&mi);
@@ -361,7 +361,7 @@ int LoadAwayMsgModule(void)
SET_UID(mi, 0xe2c75070, 0x455d, 0x455f, 0xbf, 0x53, 0x86, 0x64, 0xbc, 0x14, 0xa1, 0xbe);
CreateServiceFunction(MS_SIMPLESTATUSMSG_GOTOURLMSG, GoToURLMsgCommand);
mi.position = -2000007000;
- mi.hIcolibItem = GetIconHandle(IDI_GOTOURL);
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_GOTOURL);
mi.name.w = LPGENW("&Go to URL in Away message");
mi.pszService = MS_SIMPLESTATUSMSG_GOTOURLMSG;
hGoToURLMenuItem = Menu_AddContactMenuItem(&mi);
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp
index a72084c738..ff3b8dde0e 100644
--- a/plugins/SimpleStatusMsg/src/main.cpp
+++ b/plugins/SimpleStatusMsg/src/main.cpp
@@ -1221,13 +1221,13 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD)
static int AddTopToolbarButton(WPARAM, LPARAM)
{
TTBButton tbb = {};
- tbb.hIconHandleUp = tbb.hIconHandleDn = GetIconHandle(IDI_CSMSG);
+ tbb.hIconHandleUp = tbb.hIconHandleDn = g_plugin.getIconHandle(IDI_CSMSG);
tbb.pszService = MS_SIMPLESTATUSMSG_SHOWDIALOGINT;
tbb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
tbb.name = tbb.pszTooltipUp = LPGEN("Change status message");
hTTBButton = g_plugin.addTTB(&tbb);
- ReleaseIconEx("csmsg");
+ g_plugin.releaseIcon(IDI_CSMSG);
return 0;
}
@@ -1270,7 +1270,7 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM)
mi.flags = CMIF_UNICODE;
if (!g_plugin.getByte("ShowStatusMenuItem", 1))
mi.flags |= CMIF_HIDDEN;
- mi.hIcolibItem = GetIconHandle(IDI_CSMSG);
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_CSMSG);
mi.pszService = MS_SIMPLESTATUSMSG_SHOWDIALOGINT;
mi.name.w = LPGENW("Status message...");
mi.position = 2000200000;
diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp
index 4ae688bf8c..248c97eeb8 100644
--- a/plugins/SimpleStatusMsg/src/msgbox.cpp
+++ b/plugins/SimpleStatusMsg/src/msgbox.cpp
@@ -943,11 +943,11 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
copy_init_data->m_bOnStartup = init_data->m_bOnStartup;
//Load Icons
- copy_init_data->icon[I_ICON_DEL] = LoadIconEx("cross");
- copy_init_data->icon[I_ICON_HIST] = LoadIconEx("recent");
- copy_init_data->icon[I_ICON_MSG] = LoadIconEx("predef");
- copy_init_data->icon[I_ICON_ADD] = LoadIconEx("add");
- copy_init_data->icon[I_ICON_CLEAR] = LoadIconEx("clear");
+ copy_init_data->icon[I_ICON_DEL] = g_plugin.getIcon(IDI_CROSS);
+ copy_init_data->icon[I_ICON_HIST] = g_plugin.getIcon(IDI_HISTORY);
+ copy_init_data->icon[I_ICON_MSG] = g_plugin.getIcon(IDI_MESSAGE);
+ copy_init_data->icon[I_ICON_ADD] = g_plugin.getIcon(IDI_PLUS);
+ copy_init_data->icon[I_ICON_CLEAR] = g_plugin.getIcon(IDI_CHIST);
if (copy_init_data->m_iDlgFlags & DLG_SHOW_STATUS_ICONS)
copy_init_data->status_icons = AddStatusIconsToImageList(init_data->m_szProto, copy_init_data->m_iStatusModes);
if (copy_init_data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)
@@ -1542,16 +1542,18 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
break;
case DM_SIMPAWAY_CHANGEICONS:
- ReleaseIconEx("cross");
- ReleaseIconEx("recent");
- ReleaseIconEx("predef");
- ReleaseIconEx("add");
- ReleaseIconEx("clear");
- msgbox_data->icon[I_ICON_DEL] = LoadIconEx("cross");
- msgbox_data->icon[I_ICON_HIST] = LoadIconEx("recent");
- msgbox_data->icon[I_ICON_MSG] = LoadIconEx("predef");
- msgbox_data->icon[I_ICON_ADD] = LoadIconEx("add");
- msgbox_data->icon[I_ICON_CLEAR] = LoadIconEx("clear");
+ g_plugin.releaseIcon(IDI_CROSS);
+ g_plugin.releaseIcon(IDI_HISTORY);
+ g_plugin.releaseIcon(IDI_MESSAGE);
+ g_plugin.releaseIcon(IDI_PLUS);
+ g_plugin.releaseIcon(IDI_CHIST);
+
+ msgbox_data->icon[I_ICON_DEL] = g_plugin.getIcon(IDI_CROSS);
+ msgbox_data->icon[I_ICON_HIST] = g_plugin.getIcon(IDI_HISTORY);
+ msgbox_data->icon[I_ICON_MSG] = g_plugin.getIcon(IDI_MESSAGE);
+ msgbox_data->icon[I_ICON_ADD] = g_plugin.getIcon(IDI_PLUS);
+ msgbox_data->icon[I_ICON_CLEAR] = g_plugin.getIcon(IDI_CHIST);
+
if (msgbox_data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)
for (int i = 0; i < 5; ++i)
ImageList_ReplaceIcon(msgbox_data->other_icons, i, msgbox_data->icon[i]);
@@ -1602,11 +1604,11 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
ImageList_Destroy(msgbox_data->status_icons);
ImageList_Destroy(msgbox_data->other_icons);
- ReleaseIconEx("cross");
- ReleaseIconEx("recent");
- ReleaseIconEx("predef");
- ReleaseIconEx("add");
- ReleaseIconEx("clear");
+ g_plugin.releaseIcon(IDI_CROSS);
+ g_plugin.releaseIcon(IDI_HISTORY);
+ g_plugin.releaseIcon(IDI_MESSAGE);
+ g_plugin.releaseIcon(IDI_PLUS);
+ g_plugin.releaseIcon(IDI_CHIST);
Window_FreeIcon_IcoLib(hwndDlg);
hwndSAMsgDialog = nullptr;
diff --git a/plugins/SimpleStatusMsg/src/simplestatusmsg.h b/plugins/SimpleStatusMsg/src/simplestatusmsg.h
index 08b03f1d15..a18012a5fe 100644
--- a/plugins/SimpleStatusMsg/src/simplestatusmsg.h
+++ b/plugins/SimpleStatusMsg/src/simplestatusmsg.h
@@ -89,11 +89,10 @@ int InitOptions(WPARAM wParam, LPARAM lParam);
/* utils.cpp */
void IconsInit(void);
-HICON LoadIconEx(const char* name);
-HANDLE GetIconHandle(int iconId);
-void ReleaseIconEx(const char* name);
+
HANDLE HookProtoEvent(const char *szModule, const char *szEvent, MIRANDAHOOKPARAM hookProc);
void UnhookProtoEvents(void);
+
int GetRandom(int from, int to);
const wchar_t *GetDefaultMessage(int status);
const char *StatusModeToDbSetting(int status, const char *suffix);
diff --git a/plugins/SimpleStatusMsg/src/utils.cpp b/plugins/SimpleStatusMsg/src/utils.cpp
index 00e507f834..a3ba96c977 100644
--- a/plugins/SimpleStatusMsg/src/utils.cpp
+++ b/plugins/SimpleStatusMsg/src/utils.cpp
@@ -20,8 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "stdafx.h"
-static LIST<void> arProtoHooks(5);
-
static IconItem iconList[] =
{
{ LPGEN("Delete selected"), "cross", IDI_CROSS },
@@ -30,7 +28,7 @@ static IconItem iconList[] =
{ LPGEN("Add to predefined"), "add", IDI_PLUS },
{ LPGEN("Clear history"), "clear", IDI_CHIST },
{ LPGEN("Copy Away message"), "copy", IDI_COPY },
- { LPGEN("Change status message"), "csmsg", IDI_CSMSG, },
+ { LPGEN("Change status message"), "csmsg", IDI_CSMSG },
{ LPGEN("Go to URL in Away message"), "gotourl", IDI_GOTOURL }
};
@@ -39,28 +37,9 @@ void IconsInit(void)
g_plugin.registerIcon(LPGEN("Simple Status Message"), iconList, MODULENAME);
}
-HICON LoadIconEx(const char *name)
-{
- char szSettingName[100];
- mir_snprintf(szSettingName, "SimpleStatusMsg_%s", name);
- return IcoLib_GetIcon(szSettingName);
-}
-
-HANDLE GetIconHandle(int iconId)
-{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iconId)
- return iconList[i].hIcolib;
-
- return nullptr;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
-void ReleaseIconEx(const char *name)
-{
- char szSettingName[100];
- mir_snprintf(szSettingName, "SimpleStatusMsg_%s", name);
- IcoLib_Release(szSettingName);
-}
+static LIST<void> arProtoHooks(5);
HANDLE HookProtoEvent(const char *szModule, const char *szEvent, MIRANDAHOOKPARAM hookProc)
{
@@ -78,7 +57,9 @@ void UnhookProtoEvents(void)
arProtoHooks.destroy();
}
+/////////////////////////////////////////////////////////////////////////////////////////
// Generate random number in a specified range
+
int GetRandom(int from, int to)
{
if ((to - from) < 1)
@@ -88,7 +69,9 @@ int GetRandom(int from, int to)
return ((randnum % (to - from + 1)) + from);
}
+/////////////////////////////////////////////////////////////////////////////////////////
// From SRAway module
+
const wchar_t *GetDefaultMessage(int status)
{
switch (status) {