Eneboo - Documentación para desarrolladores
src/qt/src/network/qftp.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qftp.h   3.3.8   edited Jan 11 14:46 $
00003 **
00004 ** Definition of QFtp class.
00005 **
00006 ** Created : 970521
00007 **
00008 ** Copyright (C) 1997-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the network module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition licenses may use this
00022 ** file in accordance with the Qt Commercial License Agreement provided
00023 ** with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QFTP_H
00039 #define QFTP_H
00040 
00041 #ifndef QT_H
00042 #include "qstring.h" // char*->QString conversion
00043 #include "qurlinfo.h"
00044 #include "qnetworkprotocol.h"
00045 #endif // QT_H
00046 
00047 #if !defined( QT_MODULE_NETWORK ) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_NETWORK )
00048 #define QM_EXPORT_FTP
00049 #else
00050 #define QM_EXPORT_FTP Q_EXPORT
00051 #endif
00052 
00053 #ifndef QT_NO_NETWORKPROTOCOL_FTP
00054 
00055 
00056 class QSocket;
00057 class QFtpCommand;
00058 
00059 class QM_EXPORT_FTP QFtp : public QNetworkProtocol
00060 {
00061     Q_OBJECT
00062 
00063 public:
00064     QFtp(); // ### Qt 4.0: get rid of this overload
00065     QFtp( QObject *parent, const char *name=0 );
00066     virtual ~QFtp();
00067 
00068     int supportedOperations() const;
00069 
00070     // non-QNetworkProtocol functions:
00071     enum State {
00072         Unconnected,
00073         HostLookup,
00074         Connecting,
00075         Connected,
00076         LoggedIn,
00077         Closing
00078     };
00079     enum Error {
00080         NoError,
00081         UnknownError,
00082         HostNotFound,
00083         ConnectionRefused,
00084         NotConnected
00085     };
00086     enum Command {
00087         None,
00088         ConnectToHost,
00089         Login,
00090         Close,
00091         List,
00092         Cd,
00093         Get,
00094         Put,
00095         Remove,
00096         Mkdir,
00097         Rmdir,
00098         Rename,
00099         RawCommand
00100     };
00101 
00102     int connectToHost( const QString &host, Q_UINT16 port=21 );
00103     int login( const QString &user=QString::null, const QString &password=QString::null );
00104     int close();
00105     int list( const QString &dir=QString::null );
00106     int cd( const QString &dir );
00107     int get( const QString &file, QIODevice *dev=0 );
00108     int put( const QByteArray &data, const QString &file );
00109     int put( QIODevice *dev, const QString &file );
00110     int remove( const QString &file );
00111     int mkdir( const QString &dir );
00112     int rmdir( const QString &dir );
00113     int rename( const QString &oldname, const QString &newname );
00114 
00115     int rawCommand( const QString &command );
00116 
00117     Q_ULONG bytesAvailable() const;
00118     Q_LONG readBlock( char *data, Q_ULONG maxlen );
00119     QByteArray readAll();
00120 
00121     int currentId() const;
00122     QIODevice* currentDevice() const;
00123     Command currentCommand() const;
00124     bool hasPendingCommands() const;
00125     void clearPendingCommands();
00126 
00127     State state() const;
00128 
00129     Error error() const;
00130     QString errorString() const;
00131 
00132 public slots:
00133     void abort();
00134 
00135 signals:
00136     void stateChanged( int );
00137     void listInfo( const QUrlInfo& );
00138     void readyRead();
00139     void dataTransferProgress( int, int );
00140     void rawCommandReply( int, const QString& );
00141 
00142     void commandStarted( int );
00143     void commandFinished( int, bool );
00144     void done( bool );
00145 
00146 protected:
00147     void parseDir( const QString &buffer, QUrlInfo &info ); // ### Qt 4.0: delete this? (not public API)
00148     void operationListChildren( QNetworkOperation *op );
00149     void operationMkDir( QNetworkOperation *op );
00150     void operationRemove( QNetworkOperation *op );
00151     void operationRename( QNetworkOperation *op );
00152     void operationGet( QNetworkOperation *op );
00153     void operationPut( QNetworkOperation *op );
00154 
00155     // ### Qt 4.0: delete these
00156     // unused variables:
00157     QSocket *commandSocket, *dataSocket;
00158     bool connectionReady, passiveMode;
00159     int getTotalSize, getDoneSize;
00160     bool startGetOnFail;
00161     int putToWrite, putWritten;
00162     bool errorInListChildren;
00163 
00164 private:
00165     void init();
00166     int addCommand( QFtpCommand * );
00167 
00168     bool checkConnection( QNetworkOperation *op );
00169 
00170 private slots:
00171     void startNextCommand();
00172     void piFinished( const QString& );
00173     void piError( int, const QString& );
00174     void piConnectState( int );
00175     void piFtpReply( int, const QString& );
00176 
00177 private slots:
00178     void npListInfo( const QUrlInfo & );
00179     void npDone( bool );
00180     void npStateChanged( int );
00181     void npDataTransferProgress( int, int );
00182     void npReadyRead();
00183 
00184 protected slots:
00185     // ### Qt 4.0: delete these
00186     void hostFound();
00187     void connected();
00188     void closed();
00189     void dataHostFound();
00190     void dataConnected();
00191     void dataClosed();
00192     void dataReadyRead();
00193     void dataBytesWritten( int nbytes );
00194     void error( int );
00195 };
00196 
00197 #endif // QT_NO_NETWORKPROTOCOL_FTP
00198 
00199 #endif // QFTP_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'