summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/src/options.cpp
blob: ca3b411b79576e772f0e8c0b480b76950a7f1b6d (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
#include "gg.h"

GaduOptions::GaduOptions(PROTO_INTERFACE *proto) :
	autoRecconect(proto, "AReconnect", 0),
	keepConnectionAlive(proto, "KeepAlive", 1),
	showConnectionErrors(proto, "ShowCErrors", 0),
	useDirectConnections(proto, "DirectConns", 1),
	useForwarding(proto, "Forwarding", 0),
	useManualHosts(proto, "ManualHost", 1),
	useMsgDeliveryAcknowledge(proto, "MessageAck", 1),
	useSslConnection(proto, "SSLConnection", 1),
	directConnectionPort(proto, "DirectPort", 1550),
	forwardPort(proto, "ForwardPort", 1550),
	forwardHost(proto, "ForwardHost", L""),
	serverHosts(proto, "ServerHosts", GG_KEYDEF_SERVERHOSTS)
{}

GaduOptionsDlgConference::GaduOptionsDlgConference(GaduProto *proto) :
	GaduDlgBase(proto, IDD_OPT_GG_CONFERENCE),
	cmbPolicyForAllChatParticipants(this, IDC_GC_POLICY_TOTAL),
	edtNumberOfAllChatParticipants(this, IDC_GC_COUNT_TOTAL_SPIN, 250),
	cmbPolicyForUnknownChatParticipants(this, IDC_GC_POLICY_UNKNOWN),
	edtNumberOfUnknownChatParticipants(this, IDC_GC_COUNT_UNKNOWN_SPIN, 250),
	cmbDefaultChatPolicy(this, IDC_GC_POLICY_DEFAULT)
{
	CreateLink(cmbPolicyForAllChatParticipants, GG_KEY_GC_POLICY_TOTAL, DBVT_WORD, GG_KEYDEF_GC_POLICY_TOTAL);
	CreateLink(edtNumberOfAllChatParticipants, GG_KEY_GC_COUNT_TOTAL, DBVT_WORD, GG_KEYDEF_GC_COUNT_TOTAL);

	CreateLink(cmbPolicyForUnknownChatParticipants, GG_KEY_GC_POLICY_UNKNOWN, DBVT_WORD, GG_KEYDEF_GC_POLICY_UNKNOWN);
	CreateLink(edtNumberOfUnknownChatParticipants, GG_KEY_GC_COUNT_UNKNOWN, DBVT_WORD, GG_KEYDEF_GC_COUNT_UNKNOWN);

	CreateLink(cmbDefaultChatPolicy, GG_KEY_GC_POLICY_DEFAULT, DBVT_WORD, GG_KEYDEF_GC_POLICY_DEFAULT);
}

bool GaduOptionsDlgConference::OnInitDialog()
{
	cmbPolicyForAllChatParticipants.AddString(TranslateT("Allow"), 0L);
	cmbPolicyForAllChatParticipants.AddString(TranslateT("Ask"), 1L);
	cmbPolicyForAllChatParticipants.AddString(TranslateT("Ignore"), 2L);
	int listIndex = m_proto->getWord(GG_KEY_GC_POLICY_TOTAL, GG_KEYDEF_GC_POLICY_TOTAL);
	cmbPolicyForAllChatParticipants.SetCurSel(listIndex);

	cmbPolicyForUnknownChatParticipants.AddString(TranslateT("Allow"), 0L);
	cmbPolicyForUnknownChatParticipants.AddString(TranslateT("Ask"), 1L);
	cmbPolicyForUnknownChatParticipants.AddString(TranslateT("Ignore"), 2L);
	listIndex = m_proto->getWord(GG_KEY_GC_POLICY_UNKNOWN, GG_KEYDEF_GC_POLICY_UNKNOWN);
	cmbPolicyForUnknownChatParticipants.SetCurSel(listIndex);

	cmbDefaultChatPolicy.AddString(TranslateT("Allow"), 0L);
	cmbDefaultChatPolicy.AddString(TranslateT("Ask"), 1L);
	cmbDefaultChatPolicy.AddString(TranslateT("Ignore"), 2L);
	listIndex = m_proto->getWord(GG_KEY_GC_POLICY_DEFAULT, GG_KEYDEF_GC_POLICY_DEFAULT);
	cmbDefaultChatPolicy.SetCurSel(listIndex);
	return true;
}

bool GaduOptionsDlgConference::OnApply()
{
	int selectionIndex = cmbPolicyForAllChatParticipants.GetCurSel();
	m_proto->setWord(GG_KEY_GC_POLICY_TOTAL, cmbPolicyForAllChatParticipants.GetItemData(selectionIndex));

	selectionIndex = cmbPolicyForUnknownChatParticipants.GetCurSel();
	m_proto->setWord(GG_KEY_GC_POLICY_UNKNOWN, cmbPolicyForUnknownChatParticipants.GetItemData(selectionIndex));

	selectionIndex = cmbDefaultChatPolicy.GetCurSel();
	m_proto->setWord(GG_KEY_GC_POLICY_DEFAULT, cmbDefaultChatPolicy.GetItemData(selectionIndex));
	return true;
}

/////////////////////////////////////////////////////////////////////////////////////////

GaduOptionsDlgAdvanced::GaduOptionsDlgAdvanced(GaduProto *proto) :
	GaduDlgBase(proto, IDD_OPT_GG_ADVANCED),
	chkAutoReconnect(this, IDC_ARECONNECT),
	chkKeepConnectionAlive(this, IDC_KEEPALIVE),
	chkMsgAcknowledge(this, IDC_MSGACK),
	chkShowConnectionErrors(this, IDC_SHOWCERRORS),
	chkSslConnection(this, IDC_SSLCONN),
	chkManualHosts(this, IDC_MANUALHOST),
	edtServerHosts(this, IDC_HOST),
	txtServerHostsLabel(this, IDC_HOST_LIST_L),
	chkDirectConnections(this, IDC_DIRECTCONNS),
	edtDirectPort(this, IDC_DIRECTPORT),
	txtDirectPortLabel(this, IDC_DIRECTPORT_L),
	chkForwarding(this, IDC_FORWARDING),
	edtForwardHost(this, IDC_FORWARDHOST),
	txtForwardHostLabel(this, IDC_FORWARDHOST_L),
	edtForwardPort(this, IDC_FORWARDPORT),
	txtForwardPortLabel(this, IDC_FORWARDPORT_L),
	txtReconnectRequired(this, IDC_RELOADREQD)
{
	CreateLink(chkAutoReconnect, proto->m_gaduOptions.autoRecconect);
	CreateLink(chkKeepConnectionAlive, proto->m_gaduOptions.keepConnectionAlive);
	CreateLink(chkMsgAcknowledge, proto->m_gaduOptions.useMsgDeliveryAcknowledge);
	CreateLink(chkShowConnectionErrors, proto->m_gaduOptions.showConnectionErrors);
	CreateLink(chkSslConnection, proto->m_gaduOptions.useSslConnection);

	CreateLink(chkManualHosts, proto->m_gaduOptions.useManualHosts);
	CreateLink(edtServerHosts, proto->m_gaduOptions.serverHosts);

	CreateLink(chkDirectConnections, proto->m_gaduOptions.useDirectConnections);
	CreateLink(edtDirectPort, proto->m_gaduOptions.directConnectionPort);

	CreateLink(chkForwarding, proto->m_gaduOptions.useForwarding);
	CreateLink(edtForwardHost, proto->m_gaduOptions.forwardHost);
	CreateLink(edtForwardPort, proto->m_gaduOptions.forwardPort);

	chkManualHosts.OnChange = Callback(this, &GaduOptionsDlgAdvanced::onCheck_ManualHosts);
	chkDirectConnections.OnChange = Callback(this, &GaduOptionsDlgAdvanced::onCheck_DirectConnections);
	edtDirectPort.OnChange = Callback(this, &GaduOptionsDlgAdvanced::showRecconectRequired);
	chkForwarding.OnChange = Callback(this, &GaduOptionsDlgAdvanced::onCheck_Forwarding);
	edtForwardHost.OnChange = Callback(this, &GaduOptionsDlgAdvanced::showRecconectRequired);
	edtForwardPort.OnChange = Callback(this, &GaduOptionsDlgAdvanced::showRecconectRequired);
}

bool GaduOptionsDlgAdvanced::OnInitDialog()
{
	chkKeepConnectionAlive.Disable();
	chkSslConnection.Disable();

	chkManualHosts.Disable();
	bool useManualHosts = chkManualHosts.GetState() && chkManualHosts.Enabled();
	edtServerHosts.Enable(useManualHosts);
	txtServerHostsLabel.Enable(useManualHosts);

	bool useDirectConnection = chkDirectConnections.GetState();
	edtDirectPort.Enable(useDirectConnection);
	txtDirectPortLabel.Enable(useDirectConnection);
	chkForwarding.Enable(useDirectConnection);

	bool useForwarding = useDirectConnection && chkForwarding.GetState();
	edtForwardHost.Enable(useForwarding);
	txtForwardHostLabel.Enable(useForwarding);
	edtForwardPort.Enable(useForwarding);
	txtForwardPortLabel.Enable(useForwarding);

	txtReconnectRequired.Hide();
	return true;
}

void GaduOptionsDlgAdvanced::onCheck_ManualHosts(CCtrlCheck *)
{
	bool useManualHosts = chkManualHosts.GetState();
	edtServerHosts.Enable(useManualHosts);
	txtServerHostsLabel.Enable(useManualHosts);

	showRecconectRequired();
}

void GaduOptionsDlgAdvanced::onCheck_DirectConnections(CCtrlCheck *)
{
	bool useDirectConnection = chkDirectConnections.GetState();
	edtDirectPort.Enable(useDirectConnection);
	txtDirectPortLabel.Enable(useDirectConnection);
	chkForwarding.Enable(useDirectConnection);

	bool useForwarding = useDirectConnection && chkForwarding.GetState();
	edtForwardHost.Enable(useForwarding);
	txtForwardHostLabel.Enable(useForwarding);
	edtForwardPort.Enable(useForwarding);
	txtForwardPortLabel.Enable(useForwarding);

	showRecconectRequired();
}

void GaduOptionsDlgAdvanced::onCheck_Forwarding(CCtrlCheck *)
{
	bool useForwarding = chkForwarding.GetState();
	edtForwardHost.Enable(useForwarding);
	txtForwardHostLabel.Enable(useForwarding);
	edtForwardPort.Enable(useForwarding);
	txtForwardPortLabel.Enable(useForwarding);

	showRecconectRequired();
}

void GaduOptionsDlgAdvanced::showRecconectRequired(CCtrlBase*)
{
	txtReconnectRequired.Show();
}