src/qt3support/network/q3ftp.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt3Support module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef Q3FTP_H
       
    43 #define Q3FTP_H
       
    44 
       
    45 #include <QtCore/qstring.h> // char*->QString conversion
       
    46 #include <QtNetwork/qurlinfo.h>
       
    47 #include <Qt3Support/q3networkprotocol.h>
       
    48 
       
    49 QT_BEGIN_HEADER
       
    50 
       
    51 QT_BEGIN_NAMESPACE
       
    52 
       
    53 QT_MODULE(Qt3Support)
       
    54 
       
    55 #ifndef QT_NO_NETWORKPROTOCOL_FTP
       
    56 
       
    57 class Q3Socket;
       
    58 class Q3FtpCommand;
       
    59 
       
    60 class Q_COMPAT_EXPORT Q3Ftp : public Q3NetworkProtocol
       
    61 {
       
    62     Q_OBJECT
       
    63 
       
    64 public:
       
    65     Q3Ftp(); // ### Qt 4.0: get rid of this overload
       
    66     Q3Ftp( QObject *parent, const char *name=0 );
       
    67     virtual ~Q3Ftp();
       
    68 
       
    69     int supportedOperations() const;
       
    70 
       
    71     // non-Q3NetworkProtocol functions:
       
    72     enum State {
       
    73 	Unconnected,
       
    74 	HostLookup,
       
    75 	Connecting,
       
    76 	Connected,
       
    77 	LoggedIn,
       
    78 	Closing
       
    79     };
       
    80     enum Error {
       
    81 	NoError,
       
    82 	UnknownError,
       
    83 	HostNotFound,
       
    84 	ConnectionRefused,
       
    85 	NotConnected
       
    86     };
       
    87     enum Command {
       
    88 	None,
       
    89 	ConnectToHost,
       
    90 	Login,
       
    91 	Close,
       
    92 	List,
       
    93 	Cd,
       
    94 	Get,
       
    95 	Put,
       
    96 	Remove,
       
    97 	Mkdir,
       
    98 	Rmdir,
       
    99 	Rename,
       
   100 	RawCommand
       
   101     };
       
   102 
       
   103     int connectToHost( const QString &host, Q_UINT16 port=21 );
       
   104     int login( const QString &user=QString(), const QString &password=QString() );
       
   105     int close();
       
   106     int list( const QString &dir=QString() );
       
   107     int cd( const QString &dir );
       
   108     int get( const QString &file, QIODevice *dev=0 );
       
   109     int put( const QByteArray &data, const QString &file );
       
   110     int put( QIODevice *dev, const QString &file );
       
   111     int remove( const QString &file );
       
   112     int mkdir( const QString &dir );
       
   113     int rmdir( const QString &dir );
       
   114     int rename( const QString &oldname, const QString &newname );
       
   115 
       
   116     int rawCommand( const QString &command );
       
   117 
       
   118     Q_ULONG bytesAvailable() const;
       
   119     Q_LONG readBlock( char *data, Q_ULONG maxlen );
       
   120     QByteArray readAll();
       
   121 
       
   122     int currentId() const;
       
   123     QIODevice* currentDevice() const;
       
   124     Command currentCommand() const;
       
   125     bool hasPendingCommands() const;
       
   126     void clearPendingCommands();
       
   127 
       
   128     State state() const;
       
   129 
       
   130     Error error() const;
       
   131     QString errorString() const;
       
   132 
       
   133 public Q_SLOTS:
       
   134     void abort();
       
   135 
       
   136 Q_SIGNALS:
       
   137     void stateChanged( int );
       
   138     void listInfo( const QUrlInfo& );
       
   139     void readyRead();
       
   140     void dataTransferProgress( int, int );
       
   141     void rawCommandReply( int, const QString& );
       
   142 
       
   143     void commandStarted( int );
       
   144     void commandFinished( int, bool );
       
   145     void done( bool );
       
   146 
       
   147 protected:
       
   148     void parseDir( const QString &buffer, QUrlInfo &info ); // ### Qt 4.0: delete this? (not public API)
       
   149     void operationListChildren( Q3NetworkOperation *op );
       
   150     void operationMkDir( Q3NetworkOperation *op );
       
   151     void operationRemove( Q3NetworkOperation *op );
       
   152     void operationRename( Q3NetworkOperation *op );
       
   153     void operationGet( Q3NetworkOperation *op );
       
   154     void operationPut( Q3NetworkOperation *op );
       
   155 
       
   156     // ### Qt 4.0: delete these
       
   157     // unused variables:
       
   158     Q3Socket *commandSocket, *dataSocket;
       
   159     bool connectionReady, passiveMode;
       
   160     int getTotalSize, getDoneSize;
       
   161     bool startGetOnFail;
       
   162     int putToWrite, putWritten;
       
   163     bool errorInListChildren;
       
   164 
       
   165 private:
       
   166     void init();
       
   167     int addCommand( Q3FtpCommand * );
       
   168 
       
   169     bool checkConnection( Q3NetworkOperation *op );
       
   170 
       
   171 private Q_SLOTS:
       
   172     void startNextCommand();
       
   173     void piFinished( const QString& );
       
   174     void piError( int, const QString& );
       
   175     void piConnectState( int );
       
   176     void piFtpReply( int, const QString& );
       
   177 
       
   178 private Q_SLOTS:
       
   179     void npListInfo( const QUrlInfo & );
       
   180     void npDone( bool );
       
   181     void npStateChanged( int );
       
   182     void npDataTransferProgress( int, int );
       
   183     void npReadyRead();
       
   184 
       
   185 protected Q_SLOTS:
       
   186     // ### Qt 4.0: delete these
       
   187     void hostFound();
       
   188     void connected();
       
   189     void closed();
       
   190     void dataHostFound();
       
   191     void dataConnected();
       
   192     void dataClosed();
       
   193     void dataReadyRead();
       
   194     void dataBytesWritten( int nbytes );
       
   195     void error( int );
       
   196 };
       
   197 
       
   198 #endif // QT_NO_NETWORKPROTOCOL_FTP
       
   199 
       
   200 QT_END_NAMESPACE
       
   201 
       
   202 QT_END_HEADER
       
   203 
       
   204 #endif // Q3FTP_H