add more spacing
[personal-kdebase.git] / apps / konqueror / settings / kio / ksaveioconfig.cpp
blob435a054590d758fa33454d08d6681421614afc03
1 /*
2 Copyright (C) 2001 Dawit Alemayehu <adawit@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 // Own
21 #include "ksaveioconfig.h"
23 // Qt
24 #include <QtDBus/QtDBus>
26 // KDE
27 #include <kconfig.h>
28 #include <klocale.h>
29 #include <kmessagebox.h>
30 #include <k3staticdeleter.h>
31 #include <kio/ioslave_defaults.h>
32 #include <kconfiggroup.h>
34 class KSaveIOConfigPrivate
36 public:
37 KSaveIOConfigPrivate ();
38 ~KSaveIOConfigPrivate ();
40 KConfig* config;
41 KConfig* http_config;
44 static KSaveIOConfigPrivate *ksiocpref = 0;
45 static K3StaticDeleter<KSaveIOConfigPrivate> ksiocp;
47 KSaveIOConfigPrivate::KSaveIOConfigPrivate (): config(0), http_config(0)
49 ksiocp.setObject (ksiocpref, this);
52 KSaveIOConfigPrivate::~KSaveIOConfigPrivate ()
54 delete config;
57 KSaveIOConfigPrivate* KSaveIOConfig::d = 0;
59 KConfig* KSaveIOConfig::config()
61 if (!d)
62 d = new KSaveIOConfigPrivate;
64 if (!d->config)
65 d->config = new KConfig("kioslaverc", KConfig::NoGlobals);
67 return d->config;
70 KConfig* KSaveIOConfig::http_config()
72 if (!d)
73 d = new KSaveIOConfigPrivate;
75 if (!d->http_config)
76 d->http_config = new KConfig("kio_httprc", KConfig::NoGlobals);
78 return d->http_config;
81 void KSaveIOConfig::reparseConfiguration ()
83 delete d->config;
84 d->config = 0;
87 void KSaveIOConfig::setReadTimeout( int _timeout )
89 KConfig* cfg = config ();
90 cfg->group("").writeEntry("ReadTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
91 cfg->sync();
94 void KSaveIOConfig::setConnectTimeout( int _timeout )
96 KConfig* cfg = config ();
97 cfg->group("").writeEntry("ConnectTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
98 cfg->sync();
101 void KSaveIOConfig::setProxyConnectTimeout( int _timeout )
103 KConfig* cfg = config ();
104 cfg->group("").writeEntry("ProxyConnectTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
105 cfg->sync();
108 void KSaveIOConfig::setResponseTimeout( int _timeout )
110 KConfig* cfg = config ();
111 cfg->group("").writeEntry("ResponseTimeout", qMax(MIN_TIMEOUT_VALUE,_timeout));
112 cfg->sync();
116 void KSaveIOConfig::setMarkPartial( bool _mode )
118 KConfig* cfg = config ();
119 cfg->group("").writeEntry( "MarkPartial", _mode );
120 cfg->sync();
123 void KSaveIOConfig::setMinimumKeepSize( int _size )
125 KConfig* cfg = config ();
126 cfg->group("").writeEntry( "MinimumKeepSize", _size );
127 cfg->sync();
130 void KSaveIOConfig::setAutoResume( bool _mode )
132 KConfig* cfg = config ();
133 cfg->group("").writeEntry( "AutoResume", _mode );
134 cfg->sync();
137 void KSaveIOConfig::setUseCache( bool _mode )
139 KConfig* cfg = http_config ();
140 cfg->group("").writeEntry( "UseCache", _mode );
141 cfg->sync();
144 void KSaveIOConfig::setMaxCacheSize( int cache_size )
146 KConfig* cfg = http_config ();
147 cfg->group("").writeEntry( "MaxCacheSize", cache_size );
148 cfg->sync();
151 void KSaveIOConfig::setCacheControl(KIO::CacheControl policy)
153 KConfig* cfg = http_config ();
154 QString tmp = KIO::getCacheControlString(policy);
155 cfg->group("").writeEntry("cache", tmp);
156 cfg->sync();
159 void KSaveIOConfig::setMaxCacheAge( int cache_age )
161 KConfig* cfg = http_config ();
162 cfg->group("").writeEntry( "MaxCacheAge", cache_age );
163 cfg->sync();
166 void KSaveIOConfig::setUseReverseProxy( bool mode )
168 KConfig* cfg = config ();
169 cfg->group("Proxy Settings").writeEntry("ReversedException", mode);
170 cfg->sync();
173 void KSaveIOConfig::setProxyType(KProtocolManager::ProxyType type)
175 KConfig* cfg = config ();
176 cfg->group("Proxy Settings").writeEntry( "ProxyType", static_cast<int>(type) );
177 cfg->sync();
180 void KSaveIOConfig::setProxyAuthMode(KProtocolManager::ProxyAuthMode mode)
182 KConfig* cfg = config ();
183 cfg->group("Proxy Settings").writeEntry( "AuthMode", static_cast<int>(mode) );
184 cfg->sync();
187 void KSaveIOConfig::setNoProxyFor( const QString& _noproxy )
189 KConfig* cfg = config ();
190 cfg->group("Proxy Settings").writeEntry( "NoProxyFor", _noproxy );
191 cfg->sync();
194 void KSaveIOConfig::setProxyFor( const QString& protocol,
195 const QString& _proxy )
197 KConfig* cfg = config ();
198 cfg->group("Proxy Settings").writeEntry( protocol.toLower() + "Proxy", _proxy );
199 cfg->sync();
202 void KSaveIOConfig::setProxyConfigScript( const QString& _url )
204 KConfig* cfg = config ();
205 cfg->group("Proxy Settings").writeEntry( "Proxy Config Script", _url );
206 cfg->sync();
209 void KSaveIOConfig::setPersistentProxyConnection( bool enable )
211 KConfig* cfg = config ();
212 cfg->group("").writeEntry( "PersistentProxyConnection", enable );
213 cfg->sync();
216 void KSaveIOConfig::setPersistentConnections( bool enable )
218 KConfig* cfg = config ();
219 cfg->group("").writeEntry( "PersistentConnections", enable );
220 cfg->sync();
223 void KSaveIOConfig::updateRunningIOSlaves (QWidget *parent)
225 // Inform all running io-slaves about the changes...
226 // if we cannot update, ioslaves inform the end user...
227 QDBusMessage message =
228 QDBusMessage::createSignal("/KIO/Scheduler", "org.kde.KIO.Scheduler", "reparseSlaveConfiguration");
229 message << QString();
230 if (!QDBusConnection::sessionBus().send(message))
232 QString caption = i18n("Update Failed");
233 QString message = i18n("You have to restart the running applications "
234 "for these changes to take effect.");
235 KMessageBox::information (parent, message, caption);
236 return;
240 void KSaveIOConfig::updateProxyScout( QWidget * parent )
242 // Inform the proxyscout kded module about changes
243 // if we cannot update, ioslaves inform the end user...
244 QDBusInterface kded("org.kde.kded", "/modules/proxyscout", "org.kde.kded.ProxyScout");
245 QDBusReply<void> reply = kded.call( "reset" );
246 if (!reply.isValid())
248 QString caption = i18n("Update Failed");
249 QString message = i18n("You have to restart KDE "
250 "for these changes to take effect.");
251 KMessageBox::information (parent, message, caption);
252 return;