diff options
Diffstat (limited to 'plugins/ClientChangeNotify')
-rw-r--r-- | plugins/ClientChangeNotify/src/ClientChangeNotify.cpp | 47 | ||||
-rw-r--r-- | plugins/ClientChangeNotify/src/OptDlg.cpp | 2 | ||||
-rw-r--r-- | plugins/ClientChangeNotify/src/stdafx.h | 8 |
3 files changed, 14 insertions, 43 deletions
diff --git a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp index c489ddd1d9..95068d4ce1 100644 --- a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp +++ b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp @@ -19,8 +19,6 @@ #include "stdafx.h"
-HGENMENU g_hTogglePopupsMenuItem;
-
CMPlugin g_plugin;
COptPage *g_PreviewOptPage; // we need to show popup even for the NULL contact if g_PreviewOptPage is not NULL (used for popup preview)
@@ -42,8 +40,10 @@ PLUGININFOEX pluginInfoEx = { };
CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
-{}
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
+ bPopups(MODULENAME, "PopupNotify", true)
+{
+}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -241,7 +241,7 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) _ASSERT(hContact);
return 0;
}
- if (PerContactSetting == NOTIFY_ALWAYS || (PopupOptPage.GetValue(IDC_POPUPOPTDLG_POPUPNOTIFY) && (g_PreviewOptPage || PerContactSetting == NOTIFY_ALMOST_ALWAYS || -1 == PcreCheck(sd.MirVer)))) {
+ if (PerContactSetting == NOTIFY_ALWAYS || (g_plugin.bPopups && (g_PreviewOptPage || PerContactSetting == NOTIFY_ALMOST_ALWAYS || -1 == PcreCheck(sd.MirVer)))) {
ShowPopup(&sd);
Skin_PlaySound(CLIENTCHANGED_SOUND);
}
@@ -259,22 +259,6 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) return 0;
}
-static INT_PTR srvTogglePopups(WPARAM, LPARAM)
-{
- g_PopupOptPage.SetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY, !g_PopupOptPage.GetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY));
- return 0;
-}
-
-static int PrebuildMainMenu(WPARAM, LPARAM)
-{
- // we have to use ME_CLIST_PREBUILDMAINMENU instead of updating menu items only on settings change, because "popup_enabled" and "popup_disabled" icons are not always available yet in ModulesLoaded
- if (g_PopupOptPage.GetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY))
- Menu_ModifyItem(g_hTogglePopupsMenuItem, LPGENW("Disable c&lient change notification"), IcoLib_GetIconHandle("popup_enabled"));
- else
- Menu_ModifyItem(g_hTogglePopupsMenuItem, LPGENW("Enable c&lient change notification"), IcoLib_GetIconHandle("popup_disabled"));
- return 0;
-}
-
INT_PTR CALLBACK CCNErrorDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM)
{
switch (uMsg) {
@@ -311,23 +295,6 @@ static int MirandaLoaded(WPARAM, LPARAM) PopupOptPage.DBToMem();
RecompileRegexps(*(TCString*)PopupOptPage.GetValue(IDC_POPUPOPTDLG_IGNORESTRINGS));
- g_plugin.addSound(CLIENTCHANGED_SOUND, nullptr, LPGENW("ClientChangeNotify: Client changed"));
-
- CreateServiceFunction(MS_CCN_TOGGLEPOPUPS, srvTogglePopups);
- HookEvent(ME_CLIST_PREBUILDMAINMENU, PrebuildMainMenu);
-
- CMenuItem mi(&g_plugin);
- SET_UID(mi, 0xfabb9181, 0xdb92, 0x43f4, 0x86, 0x40, 0xca, 0xb6, 0x4c, 0x93, 0x34, 0x27);
- mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0);
- mi.flags = CMIF_UNICODE;
- if (g_PopupOptPage.GetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY))
- mi.name.w = LPGENW("Disable c&lient change notification");
- else
- mi.name.w = LPGENW("Enable c&lient change notification");
-
- mi.pszService = MS_CCN_TOGGLEPOPUPS;
- g_hTogglePopupsMenuItem = Menu_AddMainMenuItem(&mi);
-
// seems that Fingerprint is not installed
if (!bFingerprintExists && !g_plugin.getByte(DB_NO_FINGERPRINT_ERROR, 0))
CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CCN_ERROR), nullptr, CCNErrorDlgProc);
@@ -343,6 +310,10 @@ int CMPlugin::Load() HookEvent(ME_SYSTEM_MODULEUNLOAD, ModuleLoad);
HookEvent(ME_SYSTEM_MODULESLOADED, MirandaLoaded);
+ addPopupOption(LPGEN("Client change notifications"), bPopups);
+
+ addSound(CLIENTCHANGED_SOUND, nullptr, LPGENW("ClientChangeNotify: Client changed"));
+
InitOptions();
if (g_plugin.getByte(DB_SETTINGSVER, 0) < 1) {
diff --git a/plugins/ClientChangeNotify/src/OptDlg.cpp b/plugins/ClientChangeNotify/src/OptDlg.cpp index 536334e4a4..15e7879c32 100644 --- a/plugins/ClientChangeNotify/src/OptDlg.cpp +++ b/plugins/ClientChangeNotify/src/OptDlg.cpp @@ -27,7 +27,7 @@ void EnablePopupOptDlgControls() {
int I;
g_PopupOptPage.PageToMem();
- bool UsePopups = g_PopupOptPage.GetValue(IDC_POPUPOPTDLG_POPUPNOTIFY) != 0;
+ bool UsePopups = g_plugin.bPopups;
for (I = 0; I < g_PopupOptPage.Items.GetSize(); I++) {
switch (g_PopupOptPage.Items[I]->GetParam()) {
case IDC_POPUPOPTDLG_POPUPNOTIFY:
diff --git a/plugins/ClientChangeNotify/src/stdafx.h b/plugins/ClientChangeNotify/src/stdafx.h index 4775140184..7053a56ed4 100644 --- a/plugins/ClientChangeNotify/src/stdafx.h +++ b/plugins/ClientChangeNotify/src/stdafx.h @@ -49,8 +49,10 @@ #include "m_genmenu.h"
#include "m_metacontacts.h"
#include "m_netlib.h"
+#include "m_gui.h"
#include "m_fingerprint.h"
+#include "m_variables.h"
#include <pcre.h>
@@ -58,6 +60,8 @@ struct CMPlugin : public PLUGIN<CMPlugin> {
CMPlugin();
+ CMOption<bool> bPopups;
+
int Load() override;
};
@@ -116,10 +120,6 @@ extern BOOL bFingerprintExists; extern COptPage g_PopupOptPage;
extern COptPage *g_PreviewOptPage;
-#define MS_VARS_FORMATSTRING "Vars/FormatString"
-#define MS_CCN_TOGGLEPOPUPS "ClientChangeNotify/TogglePopups"
-
-
static __inline CString LogMessage(const char *Format, ...)
{
va_list va;
|