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
|
/*
Copyright (C) 2001 Dawit Alemayehu <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <dcopref.h>
#include <tdeconfig.h>
#include <tdelocale.h>
#include <tdemessagebox.h>
#include <kstaticdeleter.h>
#include <tdeio/ioslave_defaults.h>
#include "ksaveioconfig.h"
class KSaveIOConfigPrivate
{
public:
KSaveIOConfigPrivate ();
~KSaveIOConfigPrivate ();
TDEConfig* config;
TDEConfig* http_config;
};
static KSaveIOConfigPrivate *ksiocpref = 0;
static KStaticDeleter<KSaveIOConfigPrivate> ksiocp;
KSaveIOConfigPrivate::KSaveIOConfigPrivate (): config(0), http_config(0)
{
ksiocp.setObject (ksiocpref, this);
}
KSaveIOConfigPrivate::~KSaveIOConfigPrivate ()
{
delete config;
}
KSaveIOConfigPrivate* KSaveIOConfig::d = 0;
TDEConfig* KSaveIOConfig::config()
{
if (!d)
d = new KSaveIOConfigPrivate;
if (!d->config)
d->config = new TDEConfig("tdeioslaverc", false, false);
return d->config;
}
TDEConfig* KSaveIOConfig::http_config()
{
if (!d)
d = new KSaveIOConfigPrivate;
if (!d->http_config)
d->http_config = new TDEConfig("tdeio_httprc", false, false);
return d->http_config;
}
void KSaveIOConfig::reparseConfiguration ()
{
delete d->config;
d->config = 0;
}
void KSaveIOConfig::setReadTimeout( int _timeout )
{
TDEConfig* cfg = config ();
cfg->setGroup( TQString() );
cfg->writeEntry("ReadTimeout", TQMAX(MIN_TIMEOUT_VALUE,_timeout));
cfg->sync();
}
void KSaveIOConfig::setConnectTimeout( int _timeout )
{
TDEConfig* cfg = config ();
cfg->setGroup( TQString() );
cfg->writeEntry("ConnectTimeout", TQMAX(MIN_TIMEOUT_VALUE,_timeout));
cfg->sync();
}
void KSaveIOConfig::setProxyConnectTimeout( int _timeout )
{
TDEConfig* cfg = config ();
cfg->setGroup( TQString() );
cfg->writeEntry("ProxyConnectTimeout", TQMAX(MIN_TIMEOUT_VALUE,_timeout));
cfg->sync();
}
void KSaveIOConfig::setResponseTimeout( int _timeout )
{
TDEConfig* cfg = config ();
cfg->setGroup( TQString() );
cfg->writeEntry("ResponseTimeout", TQMAX(MIN_TIMEOUT_VALUE,_timeout));
cfg->sync();
}
void KSaveIOConfig::setMarkPartial( bool _mode )
{
TDEConfig* cfg = config ();
cfg->setGroup( TQString() );
cfg->writeEntry( "MarkPartial", _mode );
cfg->sync();
}
void KSaveIOConfig::setMinimumKeepSize( int _size )
{
TDEConfig* cfg = config ();
cfg->setGroup( TQString() );
cfg->writeEntry( "MinimumKeepSize", _size );
cfg->sync();
}
void KSaveIOConfig::setAutoResume( bool _mode )
{
TDEConfig* cfg = config ();
cfg->setGroup( TQString() );
cfg->writeEntry( "AutoResume", _mode );
cfg->sync();
}
void KSaveIOConfig::setUseCache( bool _mode )
{
TDEConfig* cfg = http_config ();
cfg->writeEntry( "UseCache", _mode );
cfg->sync();
}
void KSaveIOConfig::setMaxCacheSize( int cache_size )
{
TDEConfig* cfg = http_config ();
cfg->writeEntry( "MaxCacheSize", cache_size );
cfg->sync();
}
void KSaveIOConfig::setCacheControl(TDEIO::CacheControl policy)
{
TDEConfig* cfg = http_config ();
TQString tmp = TDEIO::getCacheControlString(policy);
cfg->writeEntry("cache", tmp);
cfg->sync();
}
void KSaveIOConfig::setMaxCacheAge( int cache_age )
{
TDEConfig* cfg = http_config ();
cfg->writeEntry( "MaxCacheAge", cache_age );
cfg->sync();
}
void KSaveIOConfig::setUseReverseProxy( bool mode )
{
TDEConfig* cfg = config ();
cfg->setGroup( "Proxy Settings" );
cfg->writeEntry("ReversedException", mode);
cfg->sync();
}
void KSaveIOConfig::setProxyType(KProtocolManager::ProxyType type)
{
TDEConfig* cfg = config ();
cfg->setGroup( "Proxy Settings" );
cfg->writeEntry( "ProxyType", static_cast<int>(type) );
cfg->sync();
}
void KSaveIOConfig::setProxyAuthMode(KProtocolManager::ProxyAuthMode mode)
{
TDEConfig* cfg = config ();
cfg->setGroup( "Proxy Settings" );
cfg->writeEntry( "AuthMode", static_cast<int>(mode) );
cfg->sync();
}
void KSaveIOConfig::setNoProxyFor( const TQString& _noproxy )
{
TDEConfig* cfg = config ();
cfg->setGroup( "Proxy Settings" );
cfg->writeEntry( "NoProxyFor", _noproxy );
cfg->sync();
}
void KSaveIOConfig::setProxyFor( const TQString& protocol,
const TQString& _proxy )
{
TDEConfig* cfg = config ();
cfg->setGroup( "Proxy Settings" );
cfg->writeEntry( protocol.lower() + "Proxy", _proxy );
cfg->sync();
}
void KSaveIOConfig::setProxyConfigScript( const TQString& _url )
{
TDEConfig* cfg = config ();
cfg->setGroup( "Proxy Settings" );
cfg->writeEntry( "Proxy Config Script", _url );
cfg->sync();
}
void KSaveIOConfig::setPersistentProxyConnection( bool enable )
{
TDEConfig* cfg = config ();
cfg->setGroup( TQString() );
cfg->writeEntry( "PersistentProxyConnection", enable );
cfg->sync();
}
void KSaveIOConfig::setPersistentConnections( bool enable )
{
TDEConfig* cfg = config ();
cfg->setGroup( TQString() );
cfg->writeEntry( "PersistentConnections", enable );
cfg->sync();
}
void KSaveIOConfig::updateRunningIOSlaves (TQWidget *parent)
{
// Inform all running io-slaves about the changes...
// if we cannot update, ioslaves inform the end user...
if (!DCOPRef("*", "TDEIO::Scheduler").send("reparseSlaveConfiguration", TQString()))
{
TQString caption = i18n("Update Failed");
TQString message = i18n("You have to restart the running applications "
"for these changes to take effect.");
KMessageBox::information (parent, message, caption);
return;
}
}
void KSaveIOConfig::updateProxyScout( TQWidget * parent )
{
// Inform the proxyscout kded module about changes
// if we cannot update, ioslaves inform the end user...
if (!DCOPRef("kded", "proxyscout").send("reset"))
{
TQString caption = i18n("Update Failed");
TQString message = i18n("You have to restart TDE "
"for these changes to take effect.");
KMessageBox::information (parent, message, caption);
return;
}
}
|