summaryrefslogtreecommitdiffstats
path: root/src/modules/options/optw_connection.cpp
blob: 21c1192c087761501c7bf654a23e41e7f13a62f6 (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
//=============================================================================
//
//   File : optw_connection.cpp
//   Creation date : Sat Nov 24 04:25:16 2001 GMT by Szymon Stefanek
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net)
//
//   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 opinion) 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. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================

#include "optw_connection.h"

#include "kvi_settings.h"
#include "kvi_locale.h"
#include "kvi_options.h"
#include "kvi_iconmanager.h"
#include <tqradiobutton.h>


KviConnectionOptionsWidget::KviConnectionOptionsWidget(TQWidget * parent)
: KviOptionsWidget(parent,"connection_options_widget")
{

	createLayout(2,1);
	KviTalGroupBox *gbox = addGroupBox(0,0,0,0,1,Qt::Horizontal,__tr2qs_ctx("On Disconnect","options"));


	KviBoolSelector *b1 = addBoolSelector(gbox,__tr2qs_ctx("Keep channels open","options"),KviOption_boolKeepChannelsOpenOnDisconnect,true);
#ifdef COMPILE_INFO_TIPS
	mergeTip(b1,__tr2qs_ctx("<center>This option will cause KVIrc to keep channels open after disconnect.</center>","options"));
#endif

	b1 = addBoolSelector(gbox,__tr2qs_ctx("Keep queries open","options"),KviOption_boolKeepQueriesOpenOnDisconnect,true);
#ifdef COMPILE_INFO_TIPS
	mergeTip(b1,__tr2qs_ctx("<center>This option will cause KVIrc to keep queries open after disconnect.</center>","options"));
#endif

	 gbox = addGroupBox(0,1,0,1,1,Qt::Horizontal,__tr2qs_ctx("On Unexpected Disconnect","options"));


	b1 = addBoolSelector(gbox,__tr2qs_ctx("Keep channels open","options"),KviOption_boolKeepChannelsOpenOnUnexpectedDisconnect,true);
#ifdef COMPILE_INFO_TIPS
	mergeTip(b1,__tr2qs_ctx("<center>This option will cause KVIrc to keep channels open after an unexpected disconnect.</center>","options"));
#endif

	b1 = addBoolSelector(gbox,__tr2qs_ctx("Keep queries open","options"),KviOption_boolKeepQueriesOpenOnUnexpectedDisconnect,true);
#ifdef COMPILE_INFO_TIPS
	mergeTip(b1,__tr2qs_ctx("<center>This option will cause KVIrc to keep queries open after an unexpected disconnect.</center>","options"));
#endif

	b1 = addBoolSelector(gbox,__tr2qs_ctx("Rejoin channels after reconnect","options"),KviOption_boolRejoinChannelsAfterReconnect,KVI_OPTION_BOOL(KviOption_boolAutoReconnectOnUnexpectedDisconnect));
#ifdef COMPILE_INFO_TIPS
	mergeTip(b1,__tr2qs_ctx("<center>This option will cause KVIrc to rejoin channels after a successful reconnect attempt.</center>","options"));
#endif
	b1 = addBoolSelector(gbox,__tr2qs_ctx("Reopen queries after reconnect","options"),KviOption_boolReopenQueriesAfterReconnect,KVI_OPTION_BOOL(KviOption_boolAutoReconnectOnUnexpectedDisconnect));
#ifdef COMPILE_INFO_TIPS
	mergeTip(b1,__tr2qs_ctx("<center>This option will cause KVIrc to reopen query windows after a successful reconnect attempt.</center>","options"));
#endif

//	gbox = addGroupBox(0,1,0,1,1,Qt::Horizontal,__tr2qs_ctx("On Unexpected Disconnect","options"));
	KviBoolSelector * b = addBoolSelector(gbox,__tr2qs_ctx("Automatically reconnect","options"),KviOption_boolAutoReconnectOnUnexpectedDisconnect);
#ifdef COMPILE_INFO_TIPS
	mergeTip(b,__tr2qs_ctx("<center>This option will enable auto-reconnecting after an unexpected disconnect. " \
						"An unexpected disconnect is the <b>termination</b> of a <b>fully connected IRC session</b> " \
						"that was <b>not requested by the user</b> by the means of the QUIT message." \
						"<p><b>Warning:</b> If you use /RAW to send a QUIT message to the server, " \
						"this option will not behave correctly, since does not detect the outgoing " \
						"QUIT message and will attempt to reconnect after the server has closed the connection. " \
						"For this reason, always use the /QUIT command to close your connections. " \
						"This option may also behave incorrectly with bouncers that support " \
						"detaching, in this case a solution could be to prepare an alias that sends the " \
						"bouncer \"detach\" command immediately before the \"quit\" command.<br>" \
						"<tt>alias(bncdetach){ raw bouncer detach; quit; }</tt></p></center>","options"));
#endif
	KviUIntSelector * u = addUIntSelector(gbox,__tr2qs_ctx("Maximum attempts (0: unlimited):","options"),
			KviOption_uintMaxAutoReconnectAttempts,0,100,5,
			KVI_OPTION_BOOL(KviOption_boolAutoReconnectOnUnexpectedDisconnect));
	connect(b,TQT_SIGNAL(toggled(bool)),u,TQT_SLOT(setEnabled(bool)));

	u = addUIntSelector(gbox,__tr2qs_ctx("Delay between attempts:","options"),
			KviOption_uintAutoReconnectDelay,0,86400,5,
			KVI_OPTION_BOOL(KviOption_boolAutoReconnectOnUnexpectedDisconnect));
	u->setSuffix(__tr2qs_ctx(" sec","options"));
	connect(b,TQT_SIGNAL(toggled(bool)),u,TQT_SLOT(setEnabled(bool)));
#ifdef COMPILE_INFO_TIPS
	mergeTip(u,__tr2qs_ctx("<center>Minimum value: <b>0 sec</b><br>Maximum value: <b>86400 sec</b></center>","options"));
#endif




	addRowSpacer(0,2,4,2);
}


KviConnectionOptionsWidget::~KviConnectionOptionsWidget()
{
}




KviSSLOptionsWidget::KviSSLOptionsWidget(TQWidget * parent)
: KviOptionsWidget(parent,"ssl_options_widget")
{
#ifdef COMPILE_SSL_SUPPORT
	createLayout(3,1);

	KviTalGroupBox * gbox = addGroupBox(0,0,0,0,1,Qt::Horizontal,__tr2qs_ctx("Certificate","options"));

	KviBoolSelector * b = addBoolSelector(gbox,__tr2qs_ctx("Use SSL certificate (PEM format only)","options"),
		&(KVI_OPTION_BOOL(KviOption_boolUseSSLCertificate)),true);
	KviFileSelector * f = addFileSelector(gbox,__tr2qs_ctx("Certificate location:","options"),
		&(KVI_OPTION_STRING(KviOption_stringSSLCertificatePath)),KVI_OPTION_BOOL(KviOption_boolUseSSLCertificate));
	connect(b,TQT_SIGNAL(toggled(bool)),f,TQT_SLOT(setEnabled(bool)));
	KviPasswordSelector * p = new KviPasswordSelector(gbox,__tr2qs_ctx("Certificate password:","options"),
		&(KVI_OPTION_STRING(KviOption_stringSSLCertificatePass)),KVI_OPTION_BOOL(KviOption_boolUseSSLCertificate));
	connect(b,TQT_SIGNAL(toggled(bool)),p,TQT_SLOT(setEnabled(bool)));

	gbox = addGroupBox(0,1,0,1,1,Qt::Horizontal,__tr2qs_ctx("Private Key","options"));
	b = addBoolSelector(gbox,__tr2qs_ctx("Use SSL private key","options"),
		&(KVI_OPTION_BOOL(KviOption_boolUseSSLPrivateKey)),true);
	f = addFileSelector(gbox,__tr2qs_ctx("Private key location:","options"),
		&(KVI_OPTION_STRING(KviOption_stringSSLPrivateKeyPath)),KVI_OPTION_BOOL(KviOption_boolUseSSLPrivateKey));
	connect(b,TQT_SIGNAL(toggled(bool)),f,TQT_SLOT(setEnabled(bool)));
	p = addPasswordSelector(gbox,__tr2qs_ctx("Private key password:","options"),
		&(KVI_OPTION_STRING(KviOption_stringSSLPrivateKeyPass)),KVI_OPTION_BOOL(KviOption_boolUseSSLPrivateKey));
	connect(b,TQT_SIGNAL(toggled(bool)),p,TQT_SLOT(setEnabled(bool)));
	addRowSpacer(0,2,0,2);
#else
	createLayout(1,1);
	addLabel(0,0,0,0,__tr2qs_ctx("This executable has no SSL support.","options"));
#endif
}

KviSSLOptionsWidget::~KviSSLOptionsWidget()
{
}






KviTransportOptionsWidget::KviTransportOptionsWidget(TQWidget * parent)
: KviOptionsWidget(parent,"transport_options_widget")
{
	createLayout(5,1);
	KviUIntSelector * u;
	
	KviTalGroupBox * g = addGroupBox(0,0,0,0,1,Qt::Horizontal,__tr2qs_ctx("Timeout Values","options"),this);
	u = addUIntSelector(g,__tr2qs_ctx("Connect timeout:","options"),KviOption_uintIrcSocketTimeout,5,6000,60);
	u->setSuffix(__tr2qs_ctx(" sec","options"));
	u = addUIntSelector(g,__tr2qs_ctx("Outgoing data queue flush timeout:","options"),KviOption_uintSocketQueueFlushTimeout,100,2000,500);
	u->setSuffix(__tr2qs_ctx(" msec","options"));
	KviBoolSelector * b = addBoolSelector(0,1,0,1,__tr2qs_ctx("Limit outgoing traffic","options"),KviOption_boolLimitOutgoingTraffic);
	u = addUIntSelector(0,2,0,2,__tr2qs_ctx("Limit to 1 message every:","options"),
			KviOption_uintOutgoingTrafficLimitUSeconds,10000,2000000,10000000,KVI_OPTION_BOOL(KviOption_boolLimitOutgoingTraffic));
	u->setSuffix(__tr2qs_ctx(" usec","options"));
#ifdef COMPILE_INFO_TIPS
	mergeTip(u,__tr2qs_ctx("<center>Minimum value: <b>10000 usec</b><br>Maximum value: <b>10000000 usec</b></center>","options"));
#endif
	connect(b,TQT_SIGNAL(toggled(bool)),u,TQT_SLOT(setEnabled(bool)));

	g = addGroupBox(0,3,0,3,2,Qt::Horizontal,__tr2qs_ctx("Network Interfaces","options"));
	
	b = addBoolSelector(g,__tr2qs_ctx("Bind IPv4 connections to:","options"),KviOption_boolBindIrcIpV4ConnectionsToSpecifiedAddress);
	KviStringSelector * s = addStringSelector(g,"",KviOption_stringIpV4ConnectionBindAddress,KVI_OPTION_BOOL(KviOption_boolBindIrcIpV4ConnectionsToSpecifiedAddress));
	connect(b,TQT_SIGNAL(toggled(bool)),s,TQT_SLOT(setEnabled(bool)));
#ifdef COMPILE_IPV6_SUPPORT
	b = addBoolSelector(g,__tr2qs_ctx("Bind IPv6 connections to:","options"),KviOption_boolBindIrcIpV6ConnectionsToSpecifiedAddress);
	s = addStringSelector(g,"",KviOption_stringIpV6ConnectionBindAddress,KVI_OPTION_BOOL(KviOption_boolBindIrcIpV6ConnectionsToSpecifiedAddress));
	connect(b,TQT_SIGNAL(toggled(bool)),s,TQT_SLOT(setEnabled(bool)));
#endif //!COMPILE_IPV6_SUPPORT

	addRowSpacer(0,4,0,4);
}

KviTransportOptionsWidget::~KviTransportOptionsWidget()
{
}









KviIdentOptionsWidget::KviIdentOptionsWidget(TQWidget * parent)
: KviOptionsWidget(parent,"ident_options_widget")
{
	createLayout(6,1);

	m_pEnableIdent = addBoolSelector(0,0,0,0,__tr2qs_ctx("Enable ident service (bad practice on UNIX!)","options"),KviOption_boolUseIdentService);
	connect(m_pEnableIdent,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(enableIpv4InIpv6(bool)));

	KviTalGroupBox * gbox = addGroupBox(0,1,0,1,1,Qt::Horizontal,__tr2qs_ctx("Output verbosity","options"),KVI_OPTION_BOOL(KviOption_boolUseIdentService));
	connect(m_pEnableIdent,TQT_SIGNAL(toggled(bool)),gbox,TQT_SLOT(setEnabled(bool)));

	addLabel(gbox,__tr2qs_ctx("Output identd messages to:","options"));

	m_pActiveRadio = new TQRadioButton(__tr2qs_ctx("Active window","options"),gbox);
	m_pConsoleRadio = new TQRadioButton(__tr2qs_ctx("Console","options"),gbox);
	m_pQuietRadio = new TQRadioButton(__tr2qs_ctx("Do not show any identd messages","options"),gbox);

	switch(KVI_OPTION_UINT(KviOption_uintIdentdOutputMode))
	{
		case KviIdentdOutputMode::Quiet :
			m_pQuietRadio->setChecked(true);
			break;
		case KviIdentdOutputMode::ToConsole :
			m_pConsoleRadio->setChecked(true);
			break;
		case KviIdentdOutputMode::ToActiveWindow :
			m_pActiveRadio->setChecked(true);
			break;
	}

	gbox = addGroupBox(0,2,0,2,1,Qt::Horizontal,__tr2qs_ctx("Configuration","options"),KVI_OPTION_BOOL(KviOption_boolUseIdentService));
	
	KviBoolSelector *b = addBoolSelector(gbox,__tr2qs_ctx("Enable ident service only while connecting to server","options"),KviOption_boolUseIdentServiceOnlyOnConnect);
	connect(m_pEnableIdent,TQT_SIGNAL(toggled(bool)),b,TQT_SLOT(setEnabled(bool)));

	KviStringSelector * s = addStringSelector(gbox,__tr2qs_ctx("Ident username:","options"),
		KviOption_stringIdentdUser,KVI_OPTION_BOOL(KviOption_boolUseIdentService));
	
	KviUIntSelector * u = addUIntSelector(gbox,__tr2qs_ctx("Service port:","options"),
		KviOption_uintIdentdPort,0,65535,113,KVI_OPTION_BOOL(KviOption_boolUseIdentService));
	connect(m_pEnableIdent,TQT_SIGNAL(toggled(bool)),u,TQT_SLOT(setEnabled(bool)));
	connect(m_pEnableIdent,TQT_SIGNAL(toggled(bool)),gbox,TQT_SLOT(setEnabled(bool)));

	gbox = addGroupBox(0,3,0,3,1,Qt::Horizontal,__tr2qs_ctx("IPv6 Settings","options"),KVI_OPTION_BOOL(KviOption_boolUseIdentService));
	m_pEnableIpv6 = addBoolSelector(gbox,__tr2qs_ctx("Enable service for IPv6","options"),
		KviOption_boolIdentdEnableIpV6,
		KVI_OPTION_BOOL(KviOption_boolUseIdentService));
#ifdef COMPILE_IPV6_SUPPORT
	connect(m_pEnableIdent,TQT_SIGNAL(toggled(bool)),m_pEnableIpv6,TQT_SLOT(setEnabled(bool)));
	connect(m_pEnableIpv6,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(enableIpv4InIpv6(bool)));
#else
	m_pEnableIpv6->setEnabled(false);
#endif
	m_pIpv4InIpv6 = addBoolSelector(gbox,__tr2qs_ctx("IP stack treats IPv4 as part of IPv6 namespace","options"),
		KviOption_boolIdentdIpV6ContainsIpV4,
		KVI_OPTION_BOOL(KviOption_boolUseIdentService) && KVI_OPTION_BOOL(KviOption_boolIdentdEnableIpV6));
	connect(m_pEnableIdent,TQT_SIGNAL(toggled(bool)),gbox,TQT_SLOT(setEnabled(bool)));

	addLabel(0,4,0,4,
#ifdef COMPILE_ON_WINDOWS
			__tr2qs_ctx("<p><b>Warning:</b><br>" \
			"This is a <b>non RFC 1413 compliant</b> ident daemon that implements " \
			"only a limited subset of the Identification Protocol specifications. If it is possible, install a " \
			"real ident daemon.</p>","options")
#else
			__tr2qs_ctx("<p><b>Warning:</b><br>" \
			"This is a <b>non RFC 1413 compliant</b> ident daemon that implements " \
			"only a limited subset of the Identification Protocol specifications.<br>" \
			"On UNIX, you may also need root privileges to bind to the auth port (113).<br>" \
			"It is <b>highly recommended</b> that a <b>real</b> system-wide ident daemon be used instead, "\
			"or none at all if ident is not required.</p>","options")
#endif
	);

	addRowSpacer(0,5,0,5);
}

KviIdentOptionsWidget::~KviIdentOptionsWidget()
{
}

void KviIdentOptionsWidget::commit()
{
	KviOptionsWidget::commit();
	if(m_pConsoleRadio->isOn())
		KVI_OPTION_UINT(KviOption_uintIdentdOutputMode)=KviIdentdOutputMode::ToConsole;
	if(m_pActiveRadio->isOn())
		KVI_OPTION_UINT(KviOption_uintIdentdOutputMode)=KviIdentdOutputMode::ToActiveWindow;
	if(m_pQuietRadio->isOn())
		KVI_OPTION_UINT(KviOption_uintIdentdOutputMode)=KviIdentdOutputMode::Quiet;
}

void KviIdentOptionsWidget::enableIpv4InIpv6(bool)
{
#ifdef COMPILE_IPV6_SUPPORT
	m_pIpv4InIpv6->setEnabled(m_pEnableIdent->isChecked() && m_pEnableIpv6->isChecked());
#endif
}







KviConnectionAdvancedOptionsWidget::KviConnectionAdvancedOptionsWidget(TQWidget * parent)
: KviOptionsWidget(parent,"connection_advanced_options_widget")
{

}

KviConnectionAdvancedOptionsWidget::~KviConnectionAdvancedOptionsWidget()
{

}

#include "m_optw_connection.moc"