summaryrefslogtreecommitdiff
path: root/plugins/StopSpamPlus/src/options.cpp
blob: 063bf1d2bdd132cb4d216f7513ad4f5483d59896 (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
#include "headers.h"

TCHAR * pluginDescription = TranslateT("No more spam! Robots can't go! Only human beings invited!\r\n\r\nThis plugin works pretty simple:\r\nWhile messages from users on your contact list go as there is no any anti-spam software, messages from unknown users are not delivered to you. But also they are not ignored, this plugin replies with a simple question, and if user gives the right answer, plugin adds him to your contact list so that he can contact you.");
TCHAR const * infTalkProtPrefix = TranslateT("StopSpam automatic message:\r\n");
char const * answeredSetting = "Answered";
char const * questCountSetting = "QuestionCount";

INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{

	switch(msg)
	{
	case WM_INITDIALOG:
		{
			SetDlgItemText(hwnd, ID_DESCRIPTION, pluginDescription);
			TranslateDialogDefault(hwnd);
			SetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, plSets->MaxQuestCount.Get(), FALSE);
			CheckDlgButton(hwnd, ID_INFTALKPROT, plSets->InfTalkProtection.Get() ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwnd, ID_ADDPERMANENT, plSets->AddPermanent.Get() ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwnd, ID_HANDLEAUTHREQ, plSets->HandleAuthReq.Get() ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwnd, ID_NOTCASESENS, plSets->AnswNotCaseSens.Get() ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwnd, ID_REMOVE_TMP_ALL, plSets->RemTmpAll.Get() ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwnd, ID_HISTORY_LOG, plSets->HistLog.Get() ? BST_CHECKED : BST_UNCHECKED);
		}
		return TRUE;
	case WM_COMMAND:{
		switch (LOWORD(wParam))
		{
		case ID_MAXQUESTCOUNT:
			{
				if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
					return FALSE;
				break;
			}
		case ID_DESCRIPTION: 
			{
				return FALSE;
			}
		}
		SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
					}
		break;
	case WM_NOTIFY:
		{
			NMHDR* nmhdr = (NMHDR*)lParam;
			switch (nmhdr->code)
			{
			case PSN_APPLY:
				{
					plSets->MaxQuestCount=GetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, NULL, FALSE);
					plSets->InfTalkProtection=(BST_CHECKED == IsDlgButtonChecked(hwnd, ID_INFTALKPROT));
					plSets->AddPermanent=(BST_CHECKED == IsDlgButtonChecked(hwnd, ID_ADDPERMANENT));
					plSets->HandleAuthReq=(BST_CHECKED == IsDlgButtonChecked(hwnd, ID_HANDLEAUTHREQ));
					plSets->AnswNotCaseSens=(BST_CHECKED == IsDlgButtonChecked(hwnd, ID_NOTCASESENS));
					plSets->RemTmpAll=(BST_CHECKED == IsDlgButtonChecked(hwnd, ID_REMOVE_TMP_ALL));
					plSets->HistLog=(BST_CHECKED == IsDlgButtonChecked(hwnd, ID_HISTORY_LOG));
				}
				return TRUE;
			}
		}
		break;			
	}
	return FALSE;
}

INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{

	switch(msg)
	{
	case WM_INITDIALOG:
		{
			TranslateDialogDefault(hwnd);
			SetDlgItemString(hwnd, ID_QUESTION, plSets->Question.Get());
			SetDlgItemString(hwnd, ID_ANSWER, plSets->Answer.Get());
			SetDlgItemString(hwnd, ID_CONGRATULATION, plSets->Congratulation.Get());
			SetDlgItemString(hwnd, ID_AUTHREPL, plSets->AuthRepl.Get());
			SetDlgItemString(hwnd, ID_DIVIDER, plSets->AnswSplitString.Get());
			variables_skin_helpbutton(hwnd, IDC_VARS);
			ServiceExists(MS_VARS_FORMATSTRING)?EnableWindow(GetDlgItem(hwnd, IDC_VARS),1):EnableWindow(GetDlgItem(hwnd, IDC_VARS),0);
		}
		return TRUE;
	case WM_COMMAND:
		{
			switch(LOWORD(wParam))
			{
			case ID_QUESTION:
			case ID_ANSWER:
			case ID_AUTHREPL:
			case ID_CONGRATULATION:
			case ID_DIVIDER:
				{
					if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
						return FALSE;
					break;
				}
			case ID_RESTOREDEFAULTS:
				SetDlgItemString(hwnd, ID_QUESTION, plSets->Question.GetDefault());
				SetDlgItemString(hwnd, ID_ANSWER, plSets->Answer.GetDefault());
				SetDlgItemString(hwnd, ID_CONGRATULATION, plSets->Congratulation.GetDefault());
				SetDlgItemString(hwnd, ID_AUTHREPL, plSets->AuthRepl.GetDefault());
				SetDlgItemString(hwnd, ID_DIVIDER, plSets->AnswSplitString.GetDefault());
				SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
				return TRUE;
			case IDC_VARS:
				variables_showhelp(hwnd, msg, VHF_FULLDLG|VHF_SETLASTSUBJECT, NULL, NULL);
				return TRUE; 
			}
			SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
		}
		break;
	case WM_NOTIFY:
		{
			NMHDR* nmhdr = (NMHDR*)lParam;
			switch (nmhdr->code)
			{
			case PSN_APPLY:
				{
					plSets->Question=GetDlgItemString(hwnd, ID_QUESTION);
					plSets->Answer=GetDlgItemString(hwnd, ID_ANSWER);
					plSets->AuthRepl=GetDlgItemString(hwnd, ID_AUTHREPL);
					plSets->Congratulation=GetDlgItemString(hwnd, ID_CONGRATULATION);
					plSets->AnswSplitString=GetDlgItemString(hwnd, ID_DIVIDER);
				}
				return TRUE;
			}
		}
		break;			
	}
	return FALSE;
}