You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
261 lines
6.5 KiB
261 lines
6.5 KiB
15 years ago
|
/*
|
||
|
Copyright (C) 2001 Dawit Alemayehu <adawit@kde.org>
|
||
|
|
||
|
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>
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
15 years ago
|
#include <klocale.h>
|
||
|
#include <kmessagebox.h>
|
||
|
#include <kstaticdeleter.h>
|
||
12 years ago
|
#include <tdeio/ioslave_defaults.h>
|
||
15 years ago
|
|
||
|
#include "ksaveioconfig.h"
|
||
|
|
||
|
class KSaveIOConfigPrivate
|
||
|
{
|
||
|
public:
|
||
|
KSaveIOConfigPrivate ();
|
||
|
~KSaveIOConfigPrivate ();
|
||
|
|
||
12 years ago
|
TDEConfig* config;
|
||
|
TDEConfig* http_config;
|
||
15 years ago
|
};
|
||
|
|
||
|
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;
|
||
|
|
||
12 years ago
|
TDEConfig* KSaveIOConfig::config()
|
||
15 years ago
|
{
|
||
|
if (!d)
|
||
|
d = new KSaveIOConfigPrivate;
|
||
|
|
||
|
if (!d->config)
|
||
12 years ago
|
d->config = new TDEConfig("tdeioslaverc", false, false);
|
||
15 years ago
|
|
||
|
return d->config;
|
||
|
}
|
||
|
|
||
12 years ago
|
TDEConfig* KSaveIOConfig::http_config()
|
||
15 years ago
|
{
|
||
|
if (!d)
|
||
|
d = new KSaveIOConfigPrivate;
|
||
|
|
||
|
if (!d->http_config)
|
||
12 years ago
|
d->http_config = new TDEConfig("tdeio_httprc", false, false);
|
||
15 years ago
|
|
||
|
return d->http_config;
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::reparseConfiguration ()
|
||
|
{
|
||
|
delete d->config;
|
||
|
d->config = 0;
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setReadTimeout( int _timeout )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
14 years ago
|
cfg->setGroup( TQString() );
|
||
15 years ago
|
cfg->writeEntry("ReadTimeout", QMAX(MIN_TIMEOUT_VALUE,_timeout));
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setConnectTimeout( int _timeout )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
14 years ago
|
cfg->setGroup( TQString() );
|
||
15 years ago
|
cfg->writeEntry("ConnectTimeout", QMAX(MIN_TIMEOUT_VALUE,_timeout));
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setProxyConnectTimeout( int _timeout )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
14 years ago
|
cfg->setGroup( TQString() );
|
||
15 years ago
|
cfg->writeEntry("ProxyConnectTimeout", QMAX(MIN_TIMEOUT_VALUE,_timeout));
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setResponseTimeout( int _timeout )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
14 years ago
|
cfg->setGroup( TQString() );
|
||
15 years ago
|
cfg->writeEntry("ResponseTimeout", QMAX(MIN_TIMEOUT_VALUE,_timeout));
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
|
||
|
void KSaveIOConfig::setMarkPartial( bool _mode )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
14 years ago
|
cfg->setGroup( TQString() );
|
||
15 years ago
|
cfg->writeEntry( "MarkPartial", _mode );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setMinimumKeepSize( int _size )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
14 years ago
|
cfg->setGroup( TQString() );
|
||
15 years ago
|
cfg->writeEntry( "MinimumKeepSize", _size );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setAutoResume( bool _mode )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
14 years ago
|
cfg->setGroup( TQString() );
|
||
15 years ago
|
cfg->writeEntry( "AutoResume", _mode );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setUseCache( bool _mode )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = http_config ();
|
||
15 years ago
|
cfg->writeEntry( "UseCache", _mode );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setMaxCacheSize( int cache_size )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = http_config ();
|
||
15 years ago
|
cfg->writeEntry( "MaxCacheSize", cache_size );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
12 years ago
|
void KSaveIOConfig::setCacheControl(TDEIO::CacheControl policy)
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfig* cfg = http_config ();
|
||
|
TQString tmp = TDEIO::getCacheControlString(policy);
|
||
15 years ago
|
cfg->writeEntry("cache", tmp);
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setMaxCacheAge( int cache_age )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = http_config ();
|
||
15 years ago
|
cfg->writeEntry( "MaxCacheAge", cache_age );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setUseReverseProxy( bool mode )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
15 years ago
|
cfg->setGroup( "Proxy Settings" );
|
||
|
cfg->writeEntry("ReversedException", mode);
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setProxyType(KProtocolManager::ProxyType type)
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
15 years ago
|
cfg->setGroup( "Proxy Settings" );
|
||
|
cfg->writeEntry( "ProxyType", static_cast<int>(type) );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setProxyAuthMode(KProtocolManager::ProxyAuthMode mode)
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
15 years ago
|
cfg->setGroup( "Proxy Settings" );
|
||
|
cfg->writeEntry( "AuthMode", static_cast<int>(mode) );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
15 years ago
|
void KSaveIOConfig::setNoProxyFor( const TQString& _noproxy )
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
15 years ago
|
cfg->setGroup( "Proxy Settings" );
|
||
|
cfg->writeEntry( "NoProxyFor", _noproxy );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
15 years ago
|
void KSaveIOConfig::setProxyFor( const TQString& protocol,
|
||
|
const TQString& _proxy )
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
15 years ago
|
cfg->setGroup( "Proxy Settings" );
|
||
|
cfg->writeEntry( protocol.lower() + "Proxy", _proxy );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
15 years ago
|
void KSaveIOConfig::setProxyConfigScript( const TQString& _url )
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
15 years ago
|
cfg->setGroup( "Proxy Settings" );
|
||
|
cfg->writeEntry( "Proxy Config Script", _url );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setPersistentProxyConnection( bool enable )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
14 years ago
|
cfg->setGroup( TQString() );
|
||
15 years ago
|
cfg->writeEntry( "PersistentProxyConnection", enable );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
|
void KSaveIOConfig::setPersistentConnections( bool enable )
|
||
|
{
|
||
12 years ago
|
TDEConfig* cfg = config ();
|
||
14 years ago
|
cfg->setGroup( TQString() );
|
||
15 years ago
|
cfg->writeEntry( "PersistentConnections", enable );
|
||
|
cfg->sync();
|
||
|
}
|
||
|
|
||
15 years ago
|
void KSaveIOConfig::updateRunningIOSlaves (TQWidget *parent)
|
||
15 years ago
|
{
|
||
|
// Inform all running io-slaves about the changes...
|
||
|
// if we cannot update, ioslaves inform the end user...
|
||
12 years ago
|
if (!DCOPRef("*", "TDEIO::Scheduler").send("reparseSlaveConfiguration", TQString()))
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString caption = i18n("Update Failed");
|
||
|
TQString message = i18n("You have to restart the running applications "
|
||
15 years ago
|
"for these changes to take effect.");
|
||
|
KMessageBox::information (parent, message, caption);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void KSaveIOConfig::updateProxyScout( TQWidget * parent )
|
||
15 years ago
|
{
|
||
|
// Inform the proxyscout kded module about changes
|
||
|
// if we cannot update, ioslaves inform the end user...
|
||
|
if (!DCOPRef("kded", "proxyscout").send("reset"))
|
||
|
{
|
||
15 years ago
|
TQString caption = i18n("Update Failed");
|
||
13 years ago
|
TQString message = i18n("You have to restart TDE "
|
||
15 years ago
|
"for these changes to take effect.");
|
||
|
KMessageBox::information (parent, message, caption);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|