summaryrefslogtreecommitdiff
path: root/spamfilter/m_spamfilter.h
blob: a8b48db038ecb54f559ce67896c6eb39136d3ab5 (plain)
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
/*

"Spam Filter"-Plugin for
Miranda IM: the free IM client for Microsoft* Windows*

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 M_SPAMFILTER_H__
#define M_SPAMFILTER_H__ 1

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


// Spam Filter Version: 2.5.2.3
// See "spamcheck.c" out of the source code for an example on how to use the spam checking services.

// The functionality and the API of Spam Filter is quite complex
// and not easy to describe or explain.
// If you have any question or extension whishes please send me an e-mail:
// hrathh at users.sourceforge.net

// Notes: 
// * All services are fully thread-safe, you can call everything from any thread
//   (If there are problems with it it is a bug :-) )
// * Unicode parameters can also be passed to the ANSI version of the plugin
//   and the other way round. The strings get converted as they are needed
//   using automatic two-way translation.
//   Unicode support was added in v2.5.0.0


// -------------------------------------------
// -- Getting handles ------------------------
// -------------------------------------------

#define MS_SPAMFILTER_GETHANDLE	"SpamFilter/GetHandle"

// Description:
// -------------
// Gets a specified icon/window handle.

// Parameters:
// -------------
// wParam = (UINT)uHandleType (see below)
// lParam = 0

// Possible values for wParam:
#define SFHT_HWND_PLUGIN_OPTIONS			2	// HWND of the "Spam Filter" options dialog (if it is loaded; else NULL)
#define SFHT_HICON_SPAM						3	// HICON of the spam icon (small): The returned HICON must be DestroyIcon()ed.

// Added in v2.0.2.0: 
#define SFHT_HICON_SPAM_LARGE				4	// HICON of the spam icon (large): The returned HICON must be DestroyIcon()ed.
#define SFHT_HICON_SPAM_LAYER				5	// HICON of the spam layer icon (small): The returned HICON must be DestroyIcon()ed.

// Added in v2.1.0.0: 
#define SFHT_HWND_ADVERTISMENT_FILTER		6	// HWND of the "Advertisment Filter" settings dialog (if it is opened; else NULL)
#define SFHT_HWND_ROBOT_FILTER				7	// HWND of the "Robot Filter" settings dialog (if it is opened; else NULL)
#define SFHT_HWND_DISLIKEDMESSAGES_FILTER	8	// HWND of the "Disliked Messages Filter" settings dialog (if it is opened; else NULL)

// Added in v2.5.0.0:
#define SFHT_HWND_SPAMDEFINITIONS_INFO		9	// HWND of the "Spam Definitions" info dialog (if it is opened; else NULL)
#define SFHT_HWND_SPAMMERS_INFO				10	// HWND of the Spammers info dialog (if it is opened; else NULL)

#define SFHT_BOOL_IS_UNICODE				0 // No handle, returns TRUE if Spam Filter is installed as Unicode version, FALSE otherwise
												// (You probably never need to call this since Spam Filter performs automatic two-way translation
												// when a service is called)


// Note: Icons are taken directly from resources, they are not skinned by user

// Return Values:
// --------------
// Returns the specified handle value: HMODULE, HWND, ICON 
//
// Note:
// If a handle is not available (or if it was removed) the function will
// return NULL.
// When you are using this service you need to check always for the
// NULL return value.



// -------------------------------------------
// -- Activating/Deactivating the filters ----
// -------------------------------------------

#define MS_SPAMFILTER_CHANGEFILTERACTIVATION "SpamFilter/ChangeFilterActivation"

// Description:
// -------------
// Provides the possibility to enable or disable the spam filters.
// Also updates the checkboxes in the spam filter options if the option dialog is opened. 

// Parameters:
// -------------
// wParam = (UINT)uFilterType (For possible values see below)
// lParam = (BOOL)bNewState (new activation state of filter)

// Possible filter type values (dwFilterType):
#define SFT_ADVERTISMENT_FILTER			1
#define SFT_DISLIKEDMESSAGES_FILTER		2
#define SFT_ROBOT_FILTER				3


// Return Values:
// --------------
// Returns 0 on success, nonzero on error.


// -------------------------------------------
// -- Showing configure dialogs --------------
// -------------------------------------------

#define MS_SPAMFILTER_SHOWFILTERDIALOG		"SpamFilter/ShowFilterDialog"

// Description:
// -------------
// Shows the configure dialog of the specified filter.

// Parameters:
// -------------
// wParam = (HWND)hwndParent (Can be NULL)
// lParam = (UINT)uFilterType (For possible values see above, SFT_*)
//          -> since 2.0.2.0: If this is zero then the options dialog will be opened pointing to the Spam Filter options.
// Note:
// If hwndParent is not NULL the function will not return
// until the configure dialog is closed.

// Since 2.0.2.0:
#define SFTEX_OPTIONS_PAGE	0

// Since 2.5.0.0:
// Combine the following flag with the lParam/uFilterType parameter
// to show the corresponding Spam Definitions info dialog instead
// of the settings dialog:
#define SFTEXF_SPAMDEFINITIONS_INFO 0x2000
// Note: SFTEXF_SPAMDEFINITIONS_INFO can't be combined with SFT_ROBOT_FILTER

// Combine the following flag with the lParam/uFilterType of 0 parameter
// to show the Spammers dialog instead of the settings dialog:
#define SFTEXF_SPAMMERS_INFO 0x4000
// Note: SFTEXF_SPAMMERS_INFO can't be combined with SFT_*


// Return Values:
// --------------
// Returns 0 on success, nonzero on error.

// Since v2.1.0.0:
// If the specified settings window is already opened it will be
// brought to front (reactivated) instead (returns success though).
// This might be changed however in the future.

// Changed behaviour since v2.1.0.0:
// If hwndParent was not set then the function returned the handle to the new window.
// Now the function returns 0 to indicate success instead.


// -------------------------------------------
// -- Adding message types -------------------
// -------------------------------------------

#define MS_SPAMFILTER_REGISTERMESSAGETYPE	"SpamFilter/MessageTypes/Register"

// Description:
// -------------
// Adds a new message type which can be checked for spam.
// Associated event: ME_SPAMFILTER_PREREGISTERMESSAGETYPE

// Parameters:
// -------------
// wParam = 0
// lParam = (MESSAGETYPEDESC*)mtd (see below)

// Return Values:
// --------------
// Returns 0 on success, nonzero on error.


// Already registered message types are:
// (With pszSection set to the installed network protocol names, e.g. "ICQ")
#define SFMT_AUTHREQUEST	"Auth"
#define SFMT_ADDED			"Added" // since v2.1.0.0
#define SFMT_MESSAGE		"Msg"
#define SFMT_URL			"URL"
#define SFMT_FILE			"File"
#define SFMT_CONTACTS		"Contacts"

// MESSAGETYPEDESC structure:
typedef struct {
	int cbSize;							// Set to sizeof(MESSAGETYPEDESC), in bytes
	char* pszSection;					// Section of message name for database e.g. protocol name (Can not be NULL)
										// -> should be short, no-spaces, english and untranslated
	union {
		char* pszSectionDescription;	// Readable name of section e.g. protocol name (can be NULL)
		WCHAR* ptszSectionDescription;	// Ignored if section existed previously
		WCHAR* pwszSectionDescription;
	};

	HICON hSectionIcon;					// Icon to show for section e.g. protocol icon (can be NULL)
										// -> Can be destroyed after service returns 
										// Ignored if section existed previously
	char* pszName;						// Name to refer to message type when spam checking and in db (Can not be NULL)
										// -> should be short, no-spaces, english and untranslated
	
	union {
		char* pszDescription;			// Description for options dialog (can be NULL)
		WCHAR* ptszDescription;
		WCHAR* pwszDescription;
	};
	
	HICON hIcon;						// EITHER: icon handle representing the message type OR: one of mirandas skin constants with a negative sign, e.g (HICON)-SKINICON_EVENT_MESSAGE, same as for LoadSkinnedIcon() -> can be NULL and can also be a normal icon handle (HICON) 
										// -> Can be destroyed after service returns 
	DWORD dwFlags;						// Flags for the message type (for possible flags see below)

	// Added in v2.5.0.0:
	int iSectionPosition;				// Approx position number for the section in the options list, lower numbers are nearer to the top (Can be 0 to be sorted alphabetically)
										// Ignored if section existed previously (or if pszSection is NULL)
	int iPosition;						// Approx position number for the item in the options list, lower numbers are nearer to the top (Can be 0 to be sorted alphabetically)
} MESSAGETYPEDESC;


// Possible MESSAGETYPEDESC flags:
#define MTDF_DEFAULTDISABLED	0x00000001	// Is disabled by default
#define MTDF_HIDDEN				0x00000002	// Does not get shown on the options page

// Since v2.5.0.0
#define MTDF_UNICODE			0x00000004	// pszSectionDescription and pszDescription are Unicode strings


// MESSAGETYPEDESC struct was enhanced in v2.5.0.0:
#define MESSAGETYPEDESC_V2000_SIZE	(((int)((LPBYTE)(&((MESSAGETYPEDESC*)0)->dwFlags) - ((LPBYTE)((MESSAGETYPEDESC*)0)))) + sizeof(((MESSAGETYPEDESC*)0)->dwFlags))


#ifndef SPAMFILTER_NOHELPER
static int __inline SFRegisterMessageType(const char* section, const WCHAR* sectionDesc, HICON sectionIcon, const char* name, const WCHAR* desc, HICON icon, int pos, DWORD flags)
{
	MESSAGETYPEDESC mtd;
	mtd.cbSize = sizeof(MESSAGETYPEDESC);
	mtd.dwFlags = flags|MTDF_UNICODE;
	mtd.pszSection = (char*)section;
	mtd.ptszSectionDescription = (WCHAR*)sectionDesc;
	mtd.hSectionIcon = sectionIcon;
	mtd.iSectionPosition = 0; // not really needed
	mtd.pszName = (char*)name;
	mtd.ptszDescription = (WCHAR*)desc;
	mtd.hIcon = icon;
	mtd.iPosition = pos;
	return CallService(MS_SPAMFILTER_REGISTERMESSAGETYPE, 0, (LPARAM)&mtd);
}
#endif

// -------------------------------------------
// -- Modify new added message type (Event) --
// -------------------------------------------

#define ME_SPAMFILTER_PREREGISTERMESSAGETYPE	"SpamFilter/MessageTypes/PreRegister"

// Description:
// -------------
// Gets fired before a new message type is added.
//
// This is meant for asking other plugins if the specified default data is ok.
// Other plugins (especially protocols) can disable a message type if either sending spam
// is not possible for those protocols or if spam checking would cause unwanted side-effects.

// Note: Works as it does now since v2.1.1.0

// Warning: Most elements of the MESSAGETYPEDESC structure can also be NULL.
// However, the structure was checked for errors before this events gets called.

// Parameters:
// -----------------
// wParam = 0 (same wParam as used for MS_SPAMFILTER_REGISTERMESSAGETYPE)
// lParam = (MESSAGETYPEDESC*)mtd (see above, contents can be modified)

// Return Values:
// -----------------
// Returning 0 on this event will accept the message type to be added.
// Returning 1 will prevent the the message type to be added.


// -------------------------------------------
// -- Uninstalling a message type ------------
// -------------------------------------------

#define MS_SPAMFILTER_REMOVEMESSAGETYPE	"SpamFilter/MessageTypes/Remove"

// Description:
// -------------
// Uninstalls a specifed message type. It removes the database setting related to the given message type.
// Should only be used for uninstalling purposes (e.g in uninstall function of PluginUninstaller)

// Parameters:
// -------------
// wParam = (char*)pszMsgTypeName (Message type name; You need to use MS_SPAMFILTER_REGISTERMESSAGETYPE before)
// lParam = (char*)pszMsgTypeSection (The section of the message type string; You need to use MS_SPAMFILTER_REGISTERMESSAGETYPE before)

// Return Values:
// --------------
// Returns 0 on success, nonzero on error.


// -------------------------------------------
// -- Message type activation ----------------
// -------------------------------------------

#define MS_SPAMFILTER_ISMESSAGETYPEACTIVATED	"SpamFilter/MessageTypes/IsActivated"

// Description:
// -------------
// Returns if a specified message type is activated or not.

// Parameters:
// -------------
// wParam = (char*)pszMsgTypeName (Message type name; You need to use MS_SPAMFILTER_REGISTERMESSAGETYPE before)
// lParam = (char*)pszMsgTypeSection (The section of the message type string; You need to use MS_SPAMFILTER_REGISTERMESSAGETYPE before)

// Return Values:
// --------------
// Returns TRUE if the message type is activated and FALSE otherwise.


// -------------------------------------------
// -- Reset Auto-ignore counters -------------
// -------------------------------------------

#define MS_SPAMFILTER_RESETAUTOIGNORE	"SpamFilter/AutoIgnore/Reset"

// Description:
// -------------
// Resets the list in which the total number of spam sent by 
// each user is kept.
// The list is necessary to determine when a particular user reached the
// allowed spam messages limit.

// Parameters:
// -------------
// wParam = (BOOL)bOnlyCount (if TRUE the service will only return the user count without doing reset)
// lParam = 0

// Return Values:
// --------------
// Returns 0 on success, nonzero on error.


// -----------------------------------------
// -- Spam Checking ------------------------
// -----------------------------------------

#define MS_SPAMFILTER_ADVERTISMENTCHECK		"SpamFilter/AdvertismentCheck"
#define MS_SPAMFILTER_DISLIKEDMESSAGESCHECK	"SpamFilter/DislikedMessagesCheck"
#define MS_SPAMFILTER_ROBOTCHECK			"SpamFilter/RobotCheck"

// Description:
// -------------
// These services provide the possibility to check a specified text for contained spam.
// The function checks for everything that is activated in the plugin's options.

// Note: These functions work as they do now since v2.1.0.0

// Parameters:
// -------------
// wParam = (SPAMCHECKDATA*)scd
// lParam = 0

// SPAMCHECKDATA structure:
typedef struct {
	int cbSize;				 // Set to sizeof(SPAMCHECKDATA)

	char* pszMsgTypeSection; // The section of the message type string: You need to use MS_SPAMFILTER_REGISTERMESSAGETYPE before
	char* pszMsgTypeName;	 // Description of the message: You need to use MS_SPAMFILTER_REGISTERMESSAGETYPE before
	
	// Pointer to the text of a message which is checked for spam. Can not be NULL.
	// (To use Unicode, you need to set the flag SCDF_UNICODE)
	union {
		char* pszMsgText;	 // ANSI
		WCHAR* ptszMsgText;  // Unicode or ANSI
		WCHAR* pwszMsgText;	 // Unicode
	};

	DWORD dwFlags;			 // Flags for the spam checking. (For more details see below.)
	
	union {
		HANDLE hContact;	 // Handle to the sending contact (use pszUserName instead if no hContact is available)
		char* pszUserName;	 // Name of the user, e.g. nick (set SCDF_NO_CONTACT in the flags to use this parameter)
		WCHAR* ptszUserName; // -"- (Unicode or ANSI)
		WCHAR* pwszUserName; // -"- (Unicode)
							 // -> UserName should be as unique as possible (To use Unicode you need to specify SCDF_UNICODE)
	};
} SPAMCHECKDATA;


// Possible flags in the SPAMCHECKDATA structure:
#define SCDF_NO_NOTIFY		0x00000001	// Don't show a popup, play sound or log to file if the message is spam.
#define SCDF_NO_CANCEL		0x00000002	// Do check even if user pressed control key to avoid the spam check manually
#define SCDF_NO_AUTOIGNORE	0x00000004	// Do not use the AutoIgnore feature for this check

#define SCDF_NO_CONTACT		0x00000008	// Use pszUserName instead of hContact of union

// Since v2.5.0.0:
#define SCDF_UNICODE		0x00000010	// Specify this flag if associated message text and/or user name is Unicode


// Return Values:
// --------------
// Possible return flags:
#define SFF_MARKREAD				0x00000010 // Flag
#define SFF_DELETE					0x00000020 // Flag
#define SFF_IGNORE					0x00000040 // Flag
#define SFF_SENDMSG_NOTIFY			0x00000100 // Flag, Only MS_SPAMFILTER_DISLIKEDMESSAGESCHECK
#define SFF_SENDMSG_INSTRUCTION		0x00000200 // Flag, Only MS_SPAMFILTER_ROBOTCHECK
#define SFF_SENDMSG_CONFIRMATION	0x00000400 // Flag, Only MS_SPAMFILTER_ROBOTCHECK
#define SFF_TESTPASSED				0x00000080 // Flag, Only MS_SPAMFILTER_ROBOTCHECK
#define SFF_ISSPAM					0x00000002 // Flag
#define SFF_ISNORMAL				0x00000001 // Flag

// Since 2.5.2.0:
#define SFF_HIDE					0x00001000 // Flag, Only MS_SPAMFILTER_ROBOTCHECK


// -------------------------------------------
// -- Getting additional Check Info ----------
// -------------------------------------------

#define MS_SPAMFILTER_GETSPAMCHECKINFO	"SpamFilter/GetSpamCheckInfo"

// Description:
// -------------
// Gets data needed for the processing of spam messages.

// Parameters:
// -------------
// wParam = (UINT)uDataType (For possible values see below)
// lParam = depends on wParam (see below)

// Possible values for lParam:

// TRUE/FALSE: if the specified filter is enabled
#define SFSCI_ACTIVATION_FILTER		 1 // lParam = uFilterType (For possible values see above)

// Strings: Get the message texts specified by the user
// ANSI
#define SFSCI_MSGTEXT_NOTIFYA		 2 // lParam = (SPAMCHECKDATA*)scd, scd->hContact (or scd->pszUserName) and scd->pszMsgText (and scd->cbSize) should be filled in.
#define SFSCI_MSGTEXT_INSTRUCTIONA	 3 // lParam: see SFSCI_MSGTEXT_NOTIFYA
#define SFSCI_MSGTEXT_CONFIRMATIONA	 4 // lParam: see SFSCI_MSGTEXT_NOTIFYA

// Unicode (since v2.5.0.0)
#define SFSCI_MSGTEXT_NOTIFYW		 6 // lParam = (SPAMCHECKDATA*)scd, scd->hContact (or scd->pwszUserName) and scd->pwszMsgText (and scd->cbSize) should be filled in.
#define SFSCI_MSGTEXT_INSTRUCTIONW	 7 // lParam: see SFSCI_MSGTEXT_NOTIFYW
#define SFSCI_MSGTEXT_CONFIRMATIONW	 8 // lParam: see SFSCI_MSGTEXT_NOTIFYW

// ANSI/Unicode
#if defined(_UNICODE) || defined(UNICODE)
	#define SFSCI_MSGTEXT_NOTIFY		 SFSCI_MSGTEXT_NOTIFYW
	#define SFSCI_MSGTEXT_INSTRUCTION	 SFSCI_MSGTEXT_INSTRUCTIONW
	#define SFSCI_MSGTEXT_CONFIRMATION	 SFSCI_MSGTEXT_CONFIRMATIONW
#else
	#define SFSCI_MSGTEXT_NOTIFY		 SFSCI_MSGTEXT_NOTIFYA
	#define SFSCI_MSGTEXT_INSTRUCTION	 SFSCI_MSGTEXT_INSTRUCTIONA
	#define SFSCI_MSGTEXT_CONFIRMATION	 SFSCI_MSGTEXT_CONFIRMATIONA
#endif

// TRUE/FALSE: if the above message text should be added to history.
#define SFSCI_ADD_TO_HISTORY		 5 // lParam = SFSCI_MSGTEXT_NOTIFY(A/W), SFSCI_MSGTEXT_INSTRUCTION(A/W) or SFSCI_MSGTEXT_CONFIRMATION(A/W)


// Return Values:
// --------------
// SFSCI_ACTIVATION_FILTER		-> (BOOL)TRUE/FALSE
// SFSCI_DELAY_TIME_REPLY		-> (BOOL)TRUE/FALSE

// SFSCI_MSGTEXT_NOTIFYA		-> (char*) free with miranda_sys_free() of "m_system.h", (all %vars% in the text are already resolved)
// SFSCI_MSGTEXT_INSTRUCTIONA	-> see SFSCI_MSGTEXT_NOTIFYA
// SFSCI_MSGTEXT_CONFIRMATIONA	-> see SFSCI_MSGTEXT_NOTIFYA

// SFSCI_MSGTEXT_NOTIFYW		-> (WCHAR*) free with miranda_sys_free() of "m_system.h", (all %vars% in the text are already resolved)
// SFSCI_MSGTEXT_INSTRUCTIONW	-> see SFSCI_MSGTEXT_NOTIFYW
// SFSCI_MSGTEXT_CONFIRMATIONW	-> see SFSCI_MSGTEXT_NOTIFYW

// SFSCI_ADD_TO_HISTORY			-> (BOOL)TRUE/FALSE

// returns NULL on error


// -------------------------------------------
// -- Confirm spam check (Event) -------------
// -------------------------------------------

#define ME_SPAMFILTER_OKTOSPAMCHECK	"SpamFilter/OkToSpamCheck"

// Description:
// -------------
// Gets fired before the spam check for a message starts.

// Parameters:
// -----------------
// wParam = (SPAMCHECKDATA*)scd (Pointer to SPAMCHECKDATA struct)
// lParam = (UINT)uFilterType (For possible values see above)

// Return Values:
// -----------------
// Returning 0 on this event will accept spam checking for the message,
// Returning 1 will prevent the spam check.


// -------------------------------------------
// -- Confirm spam detection (Event) ---------
// -------------------------------------------

#define ME_SPAMFILTER_OKTOSPAMDETECTION	"SpamFilter/OkToSpamDetection"

// Description:
// -------------
// Gets fired after a spam message is detected.

// Parameters:
// -----------------
// wParam = (SPAMCHECKDATA*)scd (Pointer to SPAMCHECKDATA struct)
// lParam = (UINT)uFilterType (For possible values see above)

// Return Values:
// -----------------
// Returning 0 on this event will accept the detection
// Returning 1 cause the message not to be seen as spam.

// Note: If you only would like to get the final result hook 
// ME_SPAMFILTER_SPAMRECEIVED instead


// -------------------------------------------
// -- Spam message received (Event) ----------
// -------------------------------------------

#define ME_SPAMFILTER_SPAMRECEIVED	"SpamFilter/SpamReceived"

// Description:
// -------------
// Gets fired when a message is recognized as spam.

// Parameters:
// -----------------
// wParam = (SPAMCHECKDATA*)scd (Pointer to SPAMCHECKDATA struct)
// lParam = (UINT)uFilterType (For possible values see above)

// Return Values:
// -----------------
// The return value should be 0.



// -------------------------------------------
// -- Spam Filter loaded ---------------------
// -------------------------------------------

#define ME_SPAMFILTER_MODULELOADED	"SpamFilter/ModuleLoaded"

// Description:
// -------------
// Gets fired when a all parts of the "Spam Filter" were loaded and available
// to other plugins.
// Past this event all functionality of the plugin is fully available.
//
// The event works quite similar as ME_SYSTEM_MODULESLOADED.
// You should use ME_SYSTEM_MODULESLOADED in most cases instead. Please do so!
//
// (Service added in v2.0.1.0)
 
// Parameters:
// -----------------
// wParam = 0
// lParam = 0

// Return Values:
// -----------------
// The return value should be 0.



// -------------------------------------------
// -- Helper: Duplicate SPAMCHECKDATA --------
// -------------------------------------------

#define MS_SPAMFILTER_COPYSPAMCHECKDATA	"SpamFilter/SpamCheckData/Copy"

// Description:
// -------------
// Copys all contents of a SPAMCHECKDATA struct (especially strings) to another one
// using Miranda's Memory Manager Interface (see m_system.h).
// Use MS_SPAMFILTER_FREESPAMCHECKDATA to free the result when no longer needed.

// Available since 2.5.2.0.

// An entire copy of the SPAMCHECKDATA structure is made at pscd->cbSize.
// All strings are duplicated.
// The pscdTo->cbSize member is set to the current size of SPAMCHECKDATA
// that SpamFilter uses.
  
// Warning:
// If you pass a structure that is bigger than the current sizeof(SPAMCHECKDATA)
// then do not use pointers not contained in the current area because
// they will not be duplicated (However, you could duplicate them by yourself).

// Parameters:
// -------------
// wParam = (SPAMCHECKDATA*)pscdTo
// lParam = (SPAMCHECKDATA*)pscdFrom

// Return Values:
// --------------
// Returns 0 on success, nonzero on error.



// -------------------------------------------
// -- Helper: Free SPAMCHECKDATA -------------
// -------------------------------------------

#define MS_SPAMFILTER_FREESPAMCHECKDATA	"SpamFilter/SpamCheckData/Free"

// Description:
// -------------
// Frees the memory allocated by MS_SPAMFILTER_COPYSPAMCHECKDATA.
// using Miranda's Memory Manager Interface (see m_system.h).

// Available since 2.5.2.0.

// Parameters:
// -------------
// wParam = (SPAMCHECKDATA*)pscd
// lParam = 0

// Return Values:
// --------------
// Returns 0 on success, nonzero on failure.



// -------------------------------------------
// -- Showing error messages -----------------
// -------------------------------------------

#define MS_SPAMFILTER_SHOWERROR	"SpamFilter/ShowError"

// Description:
// -------------
// Shows a Miranda try balloon tip, popup or message box
// with the specified error message.

// Parameters:
// -------------
// wParam = (UINT)uErrorType (For possible values see below)
// lParam = 0

// Possible values for wParam:
#define SFSE_CRITICAL_ERROR	 1 // Unspecified critical error occured related to the spam check.
							   // Only use this for situations that may never ever occur.
							   // Please do avoid this if possible.

#define SFSE_SEND_FAILED	 2 // Show this error when a sending of SFSCI_MSGTEXT_NOTIFY,
							   // SFSCI_MSGTEXT_INSTRUCTION, SFSCI_MSGTEXT_CONFIRMATION or
 							   // SFSCI_MSGTEXT_NOTIFY failed (SFSCI_MSGTEXT_*)

// Return Values:
// --------------
// Returns 0 on success, nonzero on error.



// -------------------------------------------
// -- Set contact as spammer (Contact) -------
// -------------------------------------------

#define MS_SPAMFILTER_CONTACT_SETASSPAMMER "SpamFilter/Contact/SetAsSpammer"

// Description:
// -------------
// This service adds a specified user to the spammer list (fully ignored).

// Associated event: ME_SPAMFILTER_CONTACT_SPAMMERSTATECHANGED

// Note: works same as MS_SPAMFILTER_CONTACT_SHOWSETASSPAMMERDIALOG
// but does not prompt the user.

// Available since v2.5.0.0

// Parameters:
// -------------
// wParam = (HANDLE)hContact (Handle to a contact in database. Can't be NULL.)
// lParam = (DWORD)dwFlags (flags about what should be done, see below)

// Available Flags:
#define SCASF_NO_NOTIFY				0x00000001 // Prevents logging and playing of sounds 
#define SCASF_USE_ROBOT_SOUND		0x00000002 // play robot sound instead of advertisment sound (only if SCASF_NO_NOTIFY is not set)
#define SCASF_NO_REMOVE_HISTORY		0x00000004 // history is marked read instead of fully removed
#define SCASF_NO_DENY_AUTHREQUESTS	0x00000008 // do not deny pending auth requests

// Return Values:
// --------------
// Returns 0 on success, nonzero on error.


// -------------------------------------------
// -- Show mark spammer dialog (Contact) -----
// -------------------------------------------

#define MS_SPAMFILTER_CONTACT_SHOWSETASSPAMMERDIALOG "SpamFilter/Contact/ShowSetAsSpammerDlg"

// Description:
// -------------
// This service adds a specified user to the spammer list.
// Before it shows a dialog to let the user confirm the action.
// For use for example as action for a button on the message dialog.

// Note: This service performs the same tasks as MS_SPAMFILTER_SETCONTACTASSPAMMER
// to execute the action the user chooses.

// Associated event: ME_SPAMFILTER_CONTACT_SPAMMERSTATECHANGED

// Available since v2.5.0.0

// Parameters:
// -------------
// wParam = (HANDLE)hContact (Handle to a contact in database. Can't be NULL.)
// lParam = (HWND)hwndParent (Handle to the parent window. Can be NULL.)

// Return Values:
// --------------
// Returns FALSE if user clicked cancel on the dialog.
// TRUE if the contact was handled as spammer.


// Deprecated in v2.5.0.0:
// The service MS_SPAMFILTER_SETSPAMMANUALLY has been deprecated.
// New plugins should use MS_SPAMFILTER_CONTACT_SETASSPAMMERDLG instead.
#define MS_SPAMFILTER_SETSPAMMANUALLY	"SpamFilter/SetSpamManually"


// Return Values:
// --------------
// Returns 0 on success, nozero otherwise.


// -------------------------------------------
// -- Test if contact is spammer (Contact) ---
// -------------------------------------------

#define MS_SPAMFILTER_CONTACT_ISSPAMMER "SpamFilter/Contact/IsSpammer"

// Description:
// -------------
// This service tests if a specified contact is on the spammer list (fully ignored).

// Available since v2.5.0.0

// Parameters:
// -------------
// wParam = (HANDLE)hContact (Handle to a contact in database. Can't be NULL.)
// lParam = 0

// Return Values:
// --------------
// Returns TRUE when the contact is on the spammer list, FALSE otherwise.


// -------------------------------------------
// -- Unmarks a contact as spammer (Contact) -
// -------------------------------------------

#define MS_SPAMFILTER_CONTACT_UNSETSPAMMER "SpamFilter/Contact/UnSetSpammer"

// Description:
// -------------
// This service restores a spammer to be again a normal contact (unignored).

// Associated event: ME_SPAMFILTER_CONTACT_SPAMMERSTATECHANGED

// Available since v2.5.0.0

// Parameters:
// -------------
// wParam = (HANDLE)hContact (Handle to a contact in database. Can't be NULL.)
// lParam = 0

// Return Values:
// --------------
// Returns 0 on success, nonzero on error.


// -------------------------------------------
// -- Spammer state changed (Event) ----------
// -------------------------------------------

#define ME_SPAMFILTER_CONTACT_SPAMMERSTATECHANGED	"SpamFilter/Contact/SpammerStateChanged"

// Description:
// -------------
// Gets fired when a a contact gets marked as spammer or unmarked.

// Parameters:
// -----------------
// wParam = (HANDLE)hContact
// lParam = (BOOL)bIsSpammer (new state)

// Return Values:
// -----------------
// The return value should be 0.


#endif // M_SPAMFILTER_H