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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
/*
"Spam Filter"-Plugin for Miranda IM
Copyright 2003-2006 Heiko Herkenrath
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 ("SpamFilter-License.txt"); if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef SF_COMMON_H__
#define SF_COMMON_H__ 1
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// -- Includes: CRT (C Runtime Library)
//#include <tchar.h> // generic Ansi/Unicode functions
#include <wchar.h> // unicode functions
#include <stdio.h> // for mir_snprintf() etc.
#include <process.h> // for forkthread()
#include <time.h> // for time()
// -- Includes: WinAPI
#define _WIN32_WINNT 0x0501
//#define WINVER 0x0502
#define _WIN32_IE 0x0500 // for SHFileOperation
#include <windows.h>
#include <commctrl.h>
#include <shlwapi.h>
#include <shlobj.h>
// -- Include: MirandaAPI
//#define NOWIN2K
#include <win2k.h>
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_clui.h>
#include <m_database.h>
#include <m_langpack.h>
#include <m_options.h>
#include <m_skin.h>
#include <m_button.h>
#include <m_protosvc.h>
#include <m_protocols.h>
#include <m_protomod.h>
#include <m_plugins.h>
#include <m_ignore.h>
#include <m_contacts.h>
#include <m_utils.h>
#include <m_url.h>
#include <m_file.h>
#include <m_message.h>
#include <m_popup.h>
//#define VARIABLES_NOHELPER
#include <m_variables.h>
#include <m_icolib.h>
#include <m_clc.h>
#include <m_fontservice.h>
#include <m_netlib.h>
#include <m_updater.h>
#include <m_folders.h>
#include "m_trigger.h"
#include <m_icq.h>
#include <m_cluiframes.h>
// -- Includes: Header
#include "m_spamfilter.h"
#include "forkthread.h"
#include "path.h"
#include "stringlist.h"
#include "string.h"
#include "regexp.h"
#include "utilities.h"
#include "spamdefinitions.h"
#include "spamcheckdata.h"
#include "popup.h"
#include "logfile.h"
#include "contact.h"
#include "dlg.h"
#include "options.h"
#include "services.h"
#include "spamcheck.h"
#include "variables.h"
#include "folders.h"
#include "trigger.h"
#include "extraimg.h"
#include "menuitems.h"
#include "version.h"
#include "resource.h"
#include <m_system.h>
struct MM_INTERFACE memoryManagerInterface;
struct UTF8_INTERFACE utfi;
// -- Includes: Utilities
#if defined(_DEBUG)
// Memory leak and invalid access detection
//#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
//#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
// Check database setting type (m_database.h)
//#define DBCHECKSETTINGS
#else
// Prevent C Runtime Library (CRT)
/*
#pragma comment(linker,"/ENTRY:DllMain")
#pragma comment(linker,"/NODEFAULTLIB")
*/
#endif
// Debug Functions
#include "Utilities/DebugHelper.h"
// -- Variables: Plugin
HINSTANCE hInstance;
PLUGINLINK* pluginLink;
// -- Variables: Window Handles
HWND hwndSpamFilterOpt;
HWND hwndAdvertismentFilter;
HWND hwndRobotFilter;
HWND hwndDislikedMessagesFilter;
HWND hwndSpamDefinitionsInfo;
HWND hwndSpammersInfo;
// -- Variables: Message Types List
CRITICAL_SECTION csMsgTypes;
unsigned int uMsgTypesCount; // protected by csMsgTypes
MESSAGETYPEDESC* pamtdMsgTypes; // protected by csMsgTypes
// -- Defines: General
#define DEFAULT_LOGFILE TranslateT("Spam.xml")
#define DEFAULT_ADVERTISMENT_SOUNDFILE _T("filtered1.wav") // Sound files must not be translated and must be lower case
#define DEFAULT_DISLIKEDMESSAGE_SOUNDFILE _T("filtered2.wav")
#define DEFAULT_ROBOT_SOUNDFILE _T("filtered3.wav")
#define SOUNDS_SUBDIRECTORY _T("Sounds") // Dirs must have no backslash at the end!
#define DOCS_SUBDIRECTORY _T("Docs")
#define LOGS_SUBDIRECTORY _T("Logs")
#define DATA_SUBDIRECTORY _T("Spam Filter")
#define RANDOM_ANSWER_LENGTH 8
#define MAX_INT_LENGTH 15 // or just 10
#define MS_CONTACTS_SEND "ContactsTransfer/SendContacts"
#define MS_CONTACTS_RECEIVE "ContactsTransfer/ReceiveContacts"
// -- Defines: Default Settings
#define DEFAULT_SETTING_BEHAVIOUR 1 // 1 = Mark message read or 2 = Delete message
#define DEFAULT_SETTING_POPUP FALSE
#define DEFAULT_SETTING_LOGGING FALSE
#define DEFAULT_SETTING_AUTOADDSPAMMERS TRUE
#define DEFAULT_SETTING_ALLOWEDSPAMMESSAGES 3 // 0 to x
#define DEFAULT_SETTING_HIDEFROMCLIST TRUE
#define DEFAULT_SETTING_MOVETOGROUP FALSE
#define DEFAULT_SETTING_MOVETOGROUPNAME TranslateT("Spammers")
#define DEFAULT_SETTING_SETSPAMMERFLAGS 0 // flags can be SCASF_NO_REMOVE_HISTORY, SCASF_NO_DENY_AUTHREQUESTS, SCASF_NO_NOTIFY
#define DEFAULT_SETTING_ADVERTISMENTFILTER TRUE
#define DEFAULT_SETTING_ADVERTISMENT_DEFAULTBADWORDS TRUE
#define DEFAULT_SETTING_ADVERTISMENT_FORMATING TRUE
#define DEFAULT_SETTING_ADVERTISMENT_URL FALSE
#define DEFAULT_SETTING_ADVERTISMENT_PHONENUMBERS FALSE
#define DEFAULT_SETTING_ADVERTISMENT_CAPITALIZED FALSE
#define DEFAULT_SETTING_ADVERTISMENT_EMPTY TRUE
#define DEFAULT_SETTING_ADVERTISMENT_DEFAULTSPAMMERS TRUE
#define DEFAULT_SETTING_ADVERTISMENT_MULTIPLEMESSAGES TRUE
#define DEFAULT_SETTING_ADVERTISMENT_TEASERMESSAGES TRUE
#define DEFAULT_SETTING_ADVERTISMENT_ALLOWEDBADWORDS 3 // 0 to x
#define DEFAULT_SETTING_ADVERTISMENT_ALLOWEDGOODWORDS 0 // 0 to x
#define DEFAULT_SETTING_ADVERTISMENT_ALLOWEDFORMATEDWORDS 1 // 0 to x
#define DEFAULT_SETTING_DISLIKEDMESSAGEFILTER FALSE
#define DEFAULT_SETTING_DISLIKEDMESSAGE_HOAXTEXTS TRUE
#define DEFAULT_SETTING_DISLIKEDMESSAGE_MULTIPLEMESSAGES TRUE
#define DEFAULT_SETTING_DISLIKEDMESSAGE_NOTIFYSENDER FALSE
#define DEFAULT_SETTING_DISLIKEDMESSAGE_ADDTOHISTORY TRUE
#define DEFAULT_SETTING_DISLIKEDMESSAGE_RETURNMESSAGE TranslateT("Hello %sender%,\r\nI don't like such messages. Please don't send them to me anymore.\r\nThanks.\r\n\r\n(Automated message)")
#define DEFAULT_SETTING_ROBOTFILTER FALSE
#define DEFAULT_SETTING_ROBOT_INSTRUCTION TranslateT("Hello %sender%,\r\nPlease reply \"%securitycode%\" if you want to contact me. If you don't reply correctly your messages will be ignored. Sorry for the inconvenience.\r\nThis spam check guarantees that you are a real person.\r\nYou have %triesleft% tries left.\r\nThanks in advance!\r\n\r\n(Automated message)")
#define DEFAULT_SETTING_ROBOT_CONFIRMATION TranslateT("Thank you for your help!\r\nAll your previous messages were delivered. New messages do now reach me directly without an additional spam check.\r\n\r\n(Automated message)")
#define DEFAULT_SETTING_ROBOT_ADDTOHISTORY TRUE
#define DEFAULT_SETTING_ROBOT_HIDEUSERS TRUE
// -- Defines: Database
#define DB_MODULE_NAME "SpamFilter"
#define DB_MODULE_NAME_PRESPAMMERS "SpamFilterAutoIgnore"
#define DB_MODULE_NAME_MSGTYPES "SpamFilterMsgTypes"
#define DB_SETTING_FIRSTRUNDONE "FirstRunDone"
#define DB_SETTING_POPUP "PopupActivated"
#define DB_SETTING_BEHAVIOUR "FilterBehaviour"
#define DB_SETTING_AUTOADDSPAMMERS "AutoIgnoreSpammers"
#define DB_SETTING_ALLOWEDSPAMMESSAGES "AllowedSpamMsgs"
#define DB_SETTING_MOVETOGROUP "MoveToGroup"
#define DB_SETTING_HIDEFROMCLIST "HideFromCList"
#define DB_SETTING_MOVETOGROUPNAME "MoveToGroupName"
#define DB_SETTING_LOGGING "LoggingActivated"
#define DB_SETTING_LOGFILE "LogFile"
#define DB_SETTING_ADVERTISMENTFILTER "AFActivated"
#define DB_SETTING_ADVERTISMENT_DEFAULTBADWORDS "AFDefaultBadWordsCheck"
#define DB_SETTING_ADVERTISMENT_CUSTOMIZEDBADWORDS "AFCustomizedBadWordsCheck"
#define DB_SETTING_ADVERTISMENT_CUSTOMIZEDGOODWORDS "AFGoodWordsCheck"
#define DB_SETTING_ADVERTISMENT_FORMATING "AFDifferentFormatingCheck"
#define DB_SETTING_ADVERTISMENT_URL "AFMsgContainsUrlCheck"
#define DB_SETTING_ADVERTISMENT_PHONENUMBERS "AFMsgContainsPhoneNumbersCheck"
#define DB_SETTING_ADVERTISMENT_CAPITALIZED "AFCapitalizedMsgsCheck"
#define DB_SETTING_ADVERTISMENT_EMPTY "AFEmptyMsgsCheck"
#define DB_SETTING_ADVERTISMENT_DEFAULTSPAMMERS "AFDefaultSpammersCheck"
#define DB_SETTING_ADVERTISMENT_MULTIPLEMESSAGES "AFMultipleMsgsCheck"
#define DB_SETTING_ADVERTISMENT_LASTMESSAGE "AFLastFilteredMsg"
#define DB_SETTING_ADVERTISMENT_TEASERMESSAGES "AFTeaserMsgCheck"
#define DB_SETTING_ADVERTISMENT_ALLOWEDBADWORDS "AFAllowedBadWords"
#define DB_SETTING_ADVERTISMENT_ALLOWEDGOODWORDS "AFAllowedGoodWords"
#define DB_SETTING_ADVERTISMENT_ALLOWEDFORMATEDWORDS "AFAllowedFormatedWords"
#define DB_SETTING_ADVERTISMENT_DIALOGPOSITION "AFConfigureDialog_"
#define DB_SETTING_DISLIKEDMESSAGEFILTER "DFActivated"
#define DB_SETTING_DISLIKEDMESSAGE_CUSTOMIZEDWORDS "DFIndicatingWordsCheck"
#define DB_SETTING_DISLIKEDMESSAGE_HOAXTEXTS "DFHoaxTextsCheck"
#define DB_SETTING_DISLIKEDMESSAGE_MULTIPLEMESSAGES "DFMultipleMsgsCheck"
#define DB_SETTING_DISLIKEDMESSAGE_LASTMESSAGE "DFLastFilteredMsg"
#define DB_SETTING_DISLIKEDMESSAGE_LASTSENDER "DFLastFilteredSender"
#define DB_SETTING_DISLIKEDMESSAGE_NOTIFYSENDER "DFNotifySender"
#define DB_SETTING_DISLIKEDMESSAGE_RETURNMESSAGE "DFNotifySenderMsg"
#define DB_SETTING_DISLIKEDMESSAGE_ADDTOHISTORY "DFAddReplyToHistory"
#define DB_SETTING_DISLIKEDMESSAGE_DIALOGPOSITION "DFConfigureDialog_"
#define DB_SETTING_ROBOTFILTER "RFActivated"
#define DB_SETTING_ROBOT_INSTRUCTION "RFInstructionMsg"
#define DB_SETTING_ROBOT_CONFIRMATION "RFConfirmationMsg"
#define DB_SETTING_ROBOT_ADDTOHISTORY "RFAddMsgsToHistory"
#define DB_SETTING_ROBOT_DIALOGPOSITION "RFConfigureDialog_"
#define DB_SETTING_ROBOT_ANSWER "RFCorrectAnswer"
#define DB_SETTING_ROBOT_HIDEUSERS "RFHideUntilConfirmed"
#define DB_SETTING_SPAMDEF_DIALOGPOSITION "SpamDefinitionsDlg_"
#define DB_SETTING_SPAMMERS_DIALOGPOSITION "SpammersDlg_"
// Per contact settings
#define DB_SETTING_ROBOT_TESTPASSED "RFTestPassed"
#define DB_SETTING_ISSPAMMER "IsSpammer"
// Sounds
#define DB_SOUND_ADVERTISMENT_SETTING DB_MODULE_NAME"_AdvertismentFiltered"
#define DB_SOUND_DISLIKEDMESSAGE_SETTING DB_MODULE_NAME"_DislikedMessageFiltered"
#define DB_SOUND_ROBOT_SETTING DB_MODULE_NAME"_RobotFiltered"
// Icons
#define DB_ICON_SPAMLAYER_SETTING DB_MODULE_NAME"_SpamLayer"
#define DB_ICON_SPAMMANUALLY_SETTING DB_MODULE_NAME"_SpamManually"
#define DB_ICON_ISSPAMMER_SETTING DB_MODULE_NAME"_IsSpammer"
// Colors
#define DB_COLOR_POPUPBACKGROUND_SETTING DB_MODULE_NAME"_PopupBackground"
#define DB_COLOR_POPUPTEXT_SETTING DB_MODULE_NAME"_PopupText"
#endif // SF_COMMON_H__
|