Source: kprotocolmanager.h
|
|
|
|
/* This file is part of the KDE libraries
Copyright (C) 1999 Torben Weis <weis@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 version 2 as published by the Free Software Foundation.
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __kprotocolmanager_h__
#define __kprotocolmanager_h__
#include <qstring.h>
#include <qstringlist.h>
#include <qmap.h>
class KProtocolManagerPrivate;
/**
* Information about I/O (Internet, etc.) protocols supported by KDE.
*
* This class is useful if you want to know which protocols
* KDE supports. In addition you can find out lots of information
* about a certain protocol. KProtocolManager scans the *.desktop
* files of all installed kioslaves to get this information.
*
* In addition, KProtocolManager has a heap of static functions that
* allow you to read and write IO related KDE settings. These include
* proxies, resuming, timeouts.
*
* However, please note that these settings apply to all applications.
* This means that the proxy, timeouts etc. are saved in the users config
* file and @bf not in the config file of the application.
*
* @author Torben Weis <weis@kde.org>
*/
class KProtocolManager
{
public:
enum Type { T_STREAM, T_FILESYSTEM, T_NONE, T_ERROR };
/**
* @return the library to open for the protocol *p _protocol
* Example : "kio_ftp.la"
*/
QString library( const QString& _protocol ) const;
Type inputType( const QString& _protocol ) const;
Type outputType( const QString& _protocol ) const;
QStringList listing( const QString& _protocol ) const;
bool isSourceProtocol( const QString& _protocol ) const;
bool isFilterProtocol( const QString& _protocol ) const;
bool isKnownProtocol( const QString& _protocol ) const;
bool supportsListing( const QString& _protocol ) const;
bool supportsReading( const QString& _protocol ) const;
bool supportsWriting( const QString& _protocol ) const;
bool supportsMakeDir( const QString& _protocol ) const;
bool supportsDeleting( const QString& _protocol ) const;
bool supportsLinking( const QString& _protocol ) const;
bool supportsMoving( const QString& _protocol ) const;
QStringList protocols() const;
static int readTimeout();
static bool markPartial();
static int minimumKeepSize();
static bool autoResume();
static bool persistentConnections();
static QString remoteFileProtocol();
static bool useProxy();
static QString ftpProxy();
static QString httpProxy();
static QString noProxyFor();
static bool useCache();
static int maxCacheAge(); // Maximum cache age in seconds.
static int maxCacheSize(); // Maximum cache size in Kb.
/**
* Sets timeout for read operations.
* This applies to FTP and HTTP connections.
* If after a time @p timeout, the read operation doesn't finish
* reading a packet, the read operation is
* stopped with alarm command and the operation is restarted.
* This value is used if the remote server supports resuming.
* For the opposite case see @ref setReadTimeoutNoResume()
*/
static void setReadTimeout( int _time );
/**
* Set this flag if you want slaves to add the extension .PART
* to all files during transfer.
* This extension will be removed when file is fully transferred.
*
* This is a better way to discern finished transfers in case
* of transfer errors.
* @param _mode Default value is @p false: Don't add the extension .PART.
*
*/
static void setMarkPartial( bool _mode );
/**
* Set the minimum size for keeping an interrupted transfer.
*
* A downloaded file whose transfer was interrupted will only be kept if
* its size is bigger than @ _size, otherwise it will be deleted.
*
* Default value is 5000 bytes
*
*/
static void setMinimumKeepSize( int _size );
/**
* Set this flag if you want slaves to automatically resume
* downloading files without asking the user in the "rename" dialog.
*
* @param _mode Default value is @p false: Don't resume automatically.
*
*/
static void setAutoResume( bool _mode );
/**
* Set this flag if you want slaves to have persistent connections (FTP).
*
* @param _mode Default value is true: Keep persistent connections.
*
*/
static void setPersistentConnections( bool _mode );
/**
* Set a protocol which should be used for remote @p file URLs.
*
* Default value is empty: Pass hostname as part of path.
*
* Example:
* With setRemoteFileProtocol("smb"), the URL
* "file://atlas/dfaure"
* will be converted to
* "smb://atlas/dfaure"
*
* File URLs without a hostname are not affected.
*
*/
static void setRemoteFileProtocol( const QString &remoteFileProtocol );
/**
* Set this flag if you want use proxies.
*
* @param Default value is false: Don't use proxies.
*
*/
static void setUseProxy( bool _mode );
/**
* Set the proxy for FTP transfer.
*
*/
static void setFtpProxy( const QString& _proxy );
/**
* Set the proxy for HTTP transfer
*
*/
static void setHttpProxy( const QString& _proxy );
/**
* Set the URLs for which we should not use the proxy.
*
*/
static void setNoProxyFor( const QString& _noproxy );
static KProtocolManager& self() {
if ( ! s_pManager )
s_pManager = new KProtocolManager;
return *s_pManager;
}
protected:
KProtocolManager();
private:
void scanConfig( const QString& _dir );
struct Protocol
{
QString library;
Type inputType;
Type outputType;
QStringList listing;
bool isSourceProtocol;
bool supportsListing;
bool supportsReading;
bool supportsWriting;
bool supportsMakeDir;
bool supportsDeleting;
bool supportsLinking;
bool supportsMoving;
};
typedef QMap<QString,Protocol> Map;
typedef QMap<QString,Protocol>::Iterator Iterator;
typedef QMap<QString,Protocol>::ConstIterator ConstIterator;
Map m_protocols;
static KProtocolManager *s_pManager;
KProtocolManagerPrivate *d;
};
#endif
Generated by: dfaure@faure on Sun Mar 26 14:24:15 2000, using kdoc 2.0a35. |