1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*
A small Miranda plugin, by bidyut, updated by Maat.
Original plugin idea (NoSound) by Anders Nilsson.
Miranda can be found here:
https://miranda-ng.org/
*/
#include "stdafx.h"
CMPlugin g_plugin;
HGENMENU noSoundMenu;
int OptionsInitialize(WPARAM, LPARAM);
/////////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESCRIPTION,
__AUTHOR,
__COPYRIGHT,
__AUTHORWEB,
UNICODE_AWARE,
// {47D489D3-310D-4EF6-BD05-699FFFD5A4AA}
{ 0x47d489d3, 0x310d, 0x4ef6, { 0xbd, 0x5, 0x69, 0x9f, 0xff, 0xd5, 0xa4, 0xaa } }
};
CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
{}
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
}
/////////////////////////////////////////////////////////////////////////////////////////
// Update the name on the menu
static void UpdateMenuItem()
{
Menu_ModifyItem(noSoundMenu, db_get_b(NULL, "Skin", "UseSound", 1) ? DISABLE_SOUND : ENABLE_SOUND);
}
// Called when the sound setting in the database is changed
static int SoundSettingChanged(WPARAM, LPARAM lParam)
{
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
if (!strcmp(cws->szModule, "Skin") && !strcmp(cws->szSetting, "UseSound"))
UpdateMenuItem();
return 0;
}
int SetNotify(const long status)
{
db_set_b(NULL, "Skin", "UseSound", (BYTE)!(db_get_dw(NULL, MODULENAME, "NoSound", DEFAULT_NOSOUND) & status));
db_set_b(NULL, "CList", "DisableTrayFlash", (BYTE)(db_get_dw(NULL, MODULENAME, "NoBlink", DEFAULT_NOBLINK) & status));
db_set_b(NULL, "CList", "NoIconBlink", (BYTE)(db_get_dw(NULL, MODULENAME, "NoCLCBlink", DEFAULT_NOCLCBLINK) & status));
UpdateMenuItem();
return 0;
}
// Called whenever a change in status is detected
static int ProtoAck(WPARAM, LPARAM lParam)
{
// quit if not status event
ACKDATA *ack = (ACKDATA*)lParam;
if (ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS) {
long status = 0;
for (auto &pa : Accounts())
status = status | Proto_Status2Flag(Proto_GetStatus(pa->szModuleName));
SetNotify(status);
}
return 0;
}
static INT_PTR NoSoundMenuCommand(WPARAM, LPARAM)
{
bool useSound = db_get_b(0, "Skin", "UseSound", true);
db_set_b(0, "Skin", "UseSound", !useSound);
return 0;
}
extern "C" __declspec(dllexport) int Load(void)
{
if (!db_get_b(NULL, MODULENAME, "HideMenu", 1)) {
CreateServiceFunction(MODULENAME "/MenuCommand", NoSoundMenuCommand);
CMenuItem mi(g_plugin);
SET_UID(mi, 0x6bd635eb, 0xc4bb, 0x413b, 0xb9, 0x3, 0x81, 0x6d, 0x8f, 0xf1, 0x9b, 0xb0);
mi.position = -0x7FFFFFFF;
mi.flags = CMIF_UNICODE;
mi.pszService = MODULENAME "/MenuCommand";
noSoundMenu = Menu_AddMainMenuItem(&mi);
UpdateMenuItem();
}
HookEvent(ME_PROTO_ACK, ProtoAck);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SoundSettingChanged);
HookEvent(ME_OPT_INITIALISE, OptionsInitialize);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) int Unload(void)
{
return 0;
}
|