Logo Search packages:      
Sourcecode: kbear version File versions  Download package

connection.h

/***************************************************************************
                          connection.h  -  description
                             -------------------
    begin                : sön jan 6 2002
    copyright            : (C) 2002 by Bjrn Sahlstrm
    email                : kbjorn@users.sourceforge.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 option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef CONNECTION_H
#define CONNECTION_H

//////////////////////////////////////////////////////
// Qt specific includes
#include <qstring.h>
#include <qmap.h>
//////////////////////////////////////////////////////
// KDE specific includes
#include <kdatastream.h>
#include <kio/global.h>

class KURL;
/**
  *@author Björn Sahlström
  */

00035 class Connection {
public: 
      /** */
      Connection();
      /** */
      Connection( const KURL& url );
      ~Connection();
      /** @returns whether the connection is for local file system*/
00043       bool isLocal() const { return m_host==QString::null;}
      /** @returns connection settings as @ref KIO::MetaData */
      KIO::MetaData metaData() const;
      /** Set meta data information */
      void setMetaData( const KIO::MetaData&);
      /** @returns Label for the site */
00049       QString label() const { return m_label;}
      /** @returns Name of the server to connect to, like ftp.kde.org */
00051       QString protocol() const { return m_protocol;}
      /** @returns Name of the server to connect to, like ftp.kde.org */
00053       QString host() const { return m_host;}
      /** @returns port number to connect to*/
00055       int port() const { return m_port;}
      /** @returns whether to use anonymous login or not*/
00057       bool anonym() const { return m_anonym;}
      /** @returns whether to use passivemode (PASV)or not*/
00059       bool passiveMode() const { return m_passiveMode;}
      /** @returns whether to use passivemode (EPSV)or not*/
00061       bool extendedPassiveMode() const { return m_extendedPassiveMode;}
      /** @returns whether to use binary/ASCII mode ( binary=true, ASCII=false)*/
00063       bool binaryMode() const { return m_binaryMode;}
      /** @returns whether to use log or not*/
00065       bool enableLog() const { return m_enableLog;}
      /** @returns whether to use *.part extensions or not*/
00067       bool markPartial() const { return m_markPartial;}
      /** @returns whether to use 'list -a' or not*/
00069       bool listA() const { return m_listA;}
      /** @returns users login name for the remote host */
00071       QString user() const { return m_user;}
      /** @returns users password for the remote host */
00073       QString pass() const { return m_pass;}
      /** @returns Initial path for the remote host */
00075       QString remotePath() const { return (m_remotePath==""?QString("/"):m_remotePath);}
      /** @returns Initial path for the localhost */
00077       QString localPath() const { return (m_localPath==""?QString("/"):m_localPath);}
      /** @returns if auto reconnect is tuned on or off */
00079       bool autoReconnect() const { return m_autoReconnect; }
      /** @returns if transfers should be queued */
00081       bool queue() const { return m_queue; }
      /** @returns if a single connection is to be used for filesys operations */
00083       bool singleConnection() const { return m_singleConnection; }
      /** @returns number of seconds before trying to reconnect */
00085       int reconnectTime() const { return m_reconnectTime; }
      /** @returns number of times to try to reconnect */
00087       int numOfRetries() const { return m_numOfRetries; }
      /** Set label for the site */
00089       void setLabel( const QString& label ) { m_label = label; }
      /** Set name of the server to connect to, like ftp.kde.org */
00091       void setProtocol( const QString& protocol ) { m_protocol = protocol; }
      /** Set name of the server to connect to, like ftp.kde.org */
00093       void setHost( const QString& host ) { m_host = host; }
      /** Set port number to connect to*/
00095       void setPort( const int& port ) { m_port = port; }
      /** Set whether to use anonymous login or not*/
00097       void setAnonym( bool anonym ) { m_anonym = anonym; }
      /** Set whether to use passivemode (PASV) or not*/
00099       void setPassiveMode( bool passive ) { m_passiveMode = passive; }
      /** Set whether to use passivemode (EPSV) or not*/
00101       void setExtendedPassiveMode( bool e_passive ) { m_extendedPassiveMode = e_passive; }
      /** Set whether to use passivemode or not*/
00103       void setBinaryMode( bool binary ) { m_binaryMode = binary; }
      /** Set whether to enable log or not*/
00105       void setEnableLog( bool log ) { m_enableLog = log; }
      /** Set whether to use *.part extensions or not*/
00107       void setMarkPartial( bool part ) { m_markPartial = part; }
      /** Set whether to use *.part extensions or not*/
00109       void setListA( bool a ) { m_listA = a; }
      /** Set users login name for the remote host */
00111       void setUser( const QString& user ) { m_user = user; }
      /** Set users password for the remote host */
00113       void setPass( const QString& pass ) { m_pass = pass; }
      /** Set initial path for the remote host */
00115       void setRemotePath( const QString& remotePath ) { m_remotePath = (remotePath==""?QString("/"):remotePath); }
      /** Set initial path for the localhost */
00117       void setLocalPath( const QString& localPath ) { m_localPath = (localPath==""?QString("/"):localPath); }
      /** Set if autmatic reconnect on failure */
00119       void setAutoReconnect( bool r ) { m_autoReconnect = r; }
      /** Set number of seconds before tying to reconnect */
00121       void setReconnectTime( int t ) { m_reconnectTime = t; }
      /** Set number of times to try to reconnect */
00123       void setNumOfRetries( int n ) { m_numOfRetries = n; }
      /** Set if transfers should be queued or not, default is not queue */
00125       void setQueue( bool q ) { m_queue = q; }
      /** Set if a single connection is to be used for filesys operations, default is false */
00127       void setSingleConnection( bool s ) { m_singleConnection = s; }
      /** Set if a single connection is to be used for filesys operations, default is false */
00129       void setFileSysEncoding(  const QString& e ) { m_fileSysEncoding = e; }
      QString fileSysEncoding() const { return m_fileSysEncoding; }

      void setFireWallType( unsigned int t ) { m_firewallType = t; }
      void setFireWallHost( const QString& h ) { m_firewallHost = h; }
      void setFireWallPort( unsigned int p ) { m_firewallPort = p; }
      void setFireWallUser( const QString& u ) { m_firewallUser = u; }
      void setFireWallPass( const QString& p ) { m_firewallPass = p; }
      void setFireWallAccount( const QString& a ) { m_firewallAccount = a; }
      void setFireWallMacro( const QString& m ) { m_firewallMacro = m; }
      unsigned int fireWallType() const { return m_firewallType; }
      QString fireWallHost() const { return m_firewallHost; }
      unsigned int fireWallPort() const { return m_firewallPort; }
      QString fireWallUser() const { return m_firewallUser; }
      QString fireWallPass() const { return m_firewallPass; }
      QString fireWallAccount() const { return m_firewallAccount; }
      QString fireWallMacro() const { return m_firewallMacro; }
      /** @returns an URL representing the contents of the connection */
      KURL url() const;
      /** */
      void insert( QDataStream& out ) const;
      /** */
      void extract( QDataStream& in );
protected:
      QString m_label;
      QString m_protocol;
      QString m_host;
      int m_port;
      bool m_anonym;
      bool m_passiveMode;
      bool m_extendedPassiveMode;
      bool m_binaryMode;
      bool m_enableLog;
      bool m_markPartial;
      bool m_listA;
      bool m_queue;
      bool m_singleConnection;
      bool m_autoReconnect;
      int m_reconnectTime;
      int m_numOfRetries;
      QString m_user;
      QString m_pass;
      QString m_remotePath;
      QString m_localPath;
      unsigned int m_firewallType;
      QString m_firewallHost;
      unsigned int m_firewallPort;
      QString m_firewallUser;
      QString m_firewallPass;
      QString m_firewallAccount;
      QString m_firewallMacro;
      QString m_fileSysEncoding;
};
///////////////////////////////////////////////////////
inline QDataStream& operator << ( QDataStream& s, const Connection& con ) {
      con.insert( s );
      return s;
}
///////////////////////////////////////////////////////
inline QDataStream& operator >> ( QDataStream& s, Connection& con ) {
      con.extract( s );
      return s;
}
///////////////////////////////////////////////////////
#endif

Generated by  Doxygen 1.6.0   Back to index