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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
/*
Name: NewEventNotify - Plugin for Miranda IM
File: main.c - Main DLL procedures
Version: 0.2.2.2
Description: Notifies you about some events
Author: jokusoftware, <jokusoftware@miranda-im.org>
Date: 18.07.02 13:59 / Update: 22.10.07 19:56
Copyright: (C) 2002 Starzinger Michael
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "stdafx.h"
//---------------------------
//---Some global variables for the plugin
CMPlugin g_plugin;
/////////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfoEx =
{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESCRIPTION,
__AUTHOR,
__COPYRIGHT,
__AUTHORWEB,
UNICODE_AWARE,
// {3503D584-6234-4BEF-A553-6C1B9CD471F2}
{0x3503D584, 0x6234, 0x4BEF, {0xA5, 0x53, 0x6C, 0x1B, 0x9C, 0xD4, 0x71, 0xF2}}
};
CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
bPopups(MODULENAME, "Popups", true),
bMucPopups(MODULENAME, "MucPopups", true)
{}
/////////////////////////////////////////////////////////////////////////////////////////
// Hooks
//---Called when a new event is added to the database
// wParam: contact-handle
// lParam: dbevent-handle
int HookedNewEvent(WPARAM hContact, LPARAM hDbEvent)
{
//are popups currently enabled?
if (!g_plugin.bPopups || Contact::IsGroupChat(hContact))
return 0;
//get DBEVENTINFO without pBlob
DB::EventInfo dbei(hDbEvent, false);
if (!dbei)
return 0;
//do not show popups for sub-contacts
if (hContact && db_mc_isSub(hContact))
return 0;
//custom database event types
DBEVENTTYPEDESCR *pei = DbEvent_GetType(dbei.szModule, dbei.eventType);
// ignore events according to flags
if (pei && pei->flags & DETF_NONOTIFY)
return 0;
// if event was allready read don't show it
if (g_plugin.bReadCheck && (dbei.flags & DBEF_READ))
return 0;
// is it an event sent by the user? -> don't show
if (dbei.flags & DBEF_SENT) {
// JK, only message event, do not influence others
auto *pdata = PU_GetByContact(hContact, dbei.eventType);
if (g_plugin.bHideSend && pdata)
PopupAct(pdata->hWnd, MASK_DISMISS, pdata); // JK, only dismiss, i.e. do not kill event (e.g. file transfer)
return 0;
}
if (dbei.isSrmm() && (g_plugin.bMsgWindowCheck && hContact && CheckMsgWnd(hContact)))
return 0;
// is another popup for this contact already present? -> merge message popups if enabled
auto *pdata = PU_GetByContact(hContact, dbei.eventType);
if (dbei.isSrmm() && g_plugin.bMergePopup && pdata)
PopupUpdate(*pdata, hDbEvent);
else
PopupShow(hContact, hDbEvent, dbei.eventType);
return 0;
}
//---Called when all the modules are loaded
int HookedInit(WPARAM, LPARAM)
{
HookEvent(ME_DB_EVENT_ADDED, HookedNewEvent);
// Plugin sweeper support
if (ServiceExists("PluginSweeper/Add"))
CallService("PluginSweeper/Add", (WPARAM)MODULENAME, (LPARAM)MODULENAME);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
int CMPlugin::Load()
{
if (getBool(OPT_DISABLE)) {
bPopups = false;
delSetting(OPT_DISABLE);
}
if (getBool(OPT_MUCDISABLE, false)) {
bMucPopups = false;
delSetting(OPT_MUCDISABLE);
}
HookEvent(ME_SYSTEM_MODULESLOADED, HookedInit);
HookEvent(ME_OPT_INITIALISE, OptionsAdd);
addPopupOption(LPGEN("New event notifications"), bPopups);
OptionsRead();
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
// Check Window Message function
int CheckMsgWnd(MCONTACT hContact)
{
MessageWindowData mwd;
if (!Srmm_GetWindowData(hContact, mwd))
if (mwd.hwndWindow != nullptr && (mwd.uState & MSG_WINDOW_STATE_EXISTS))
return 1;
return 0;
}
|