00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QFTP_H
00043 #define QFTP_H
00044
00045 #include <QtCore/qstring.h>
00046 #include <QtNetwork/qurlinfo.h>
00047 #include <QtCore/qobject.h>
00048
00049 QT_BEGIN_HEADER
00050
00051 QT_BEGIN_NAMESPACE
00052
00053 QT_MODULE(Network)
00054
00055 #ifndef QT_NO_FTP
00056
00057 class QFtpPrivate;
00058
00059 class Q_NETWORK_EXPORT QFtp : public QObject
00060 {
00061 Q_OBJECT
00062
00063 public:
00064 explicit QFtp(QObject *parent = 0);
00065 virtual ~QFtp();
00066
00067 enum State {
00068 Unconnected,
00069 HostLookup,
00070 Connecting,
00071 Connected,
00072 LoggedIn,
00073 Closing
00074 };
00075 enum Error {
00076 NoError,
00077 UnknownError,
00078 HostNotFound,
00079 ConnectionRefused,
00080 NotConnected
00081 };
00082 enum Command {
00083 None,
00084 SetTransferMode,
00085 SetProxy,
00086 ConnectToHost,
00087 Login,
00088 Close,
00089 List,
00090 Cd,
00091 Get,
00092 Put,
00093 Remove,
00094 Mkdir,
00095 Rmdir,
00096 Rename,
00097 RawCommand
00098 };
00099 enum TransferMode {
00100 Active,
00101 Passive
00102 };
00103 enum TransferType {
00104 Binary,
00105 Ascii
00106 };
00107
00108 int setProxy(const QString &host, quint16 port);
00109 int connectToHost(const QString &host, quint16 port=21);
00110 int login(const QString &user = QString(), const QString &password = QString());
00111 int close();
00112 int setTransferMode(TransferMode mode);
00113 int list(const QString &dir = QString());
00114 int cd(const QString &dir);
00115 int get(const QString &file, QIODevice *dev=0, TransferType type = Binary);
00116 int put(const QByteArray &data, const QString &file, TransferType type = Binary);
00117 int put(QIODevice *dev, const QString &file, TransferType type = Binary);
00118 int remove(const QString &file);
00119 int mkdir(const QString &dir);
00120 int rmdir(const QString &dir);
00121 int rename(const QString &oldname, const QString &newname);
00122
00123 int rawCommand(const QString &command);
00124
00125 qint64 bytesAvailable() const;
00126 qint64 read(char *data, qint64 maxlen);
00127 #ifdef QT3_SUPPORT
00128 inline QT3_SUPPORT qint64 readBlock(char *data, quint64 maxlen)
00129 { return read(data, qint64(maxlen)); }
00130 #endif
00131 QByteArray readAll();
00132
00133 int currentId() const;
00134 QIODevice* currentDevice() const;
00135 Command currentCommand() const;
00136 bool hasPendingCommands() const;
00137 void clearPendingCommands();
00138
00139 State state() const;
00140
00141 Error error() const;
00142 QString errorString() const;
00143
00144 public Q_SLOTS:
00145 void abort();
00146
00147 Q_SIGNALS:
00148 void stateChanged(int);
00149 void listInfo(const QUrlInfo&);
00150 void readyRead();
00151 void dataTransferProgress(qint64, qint64);
00152 void rawCommandReply(int, const QString&);
00153
00154 void commandStarted(int);
00155 void commandFinished(int, bool);
00156 void done(bool);
00157
00158 #ifdef QT3_SUPPORT
00159 public:
00160 QT3_SUPPORT_CONSTRUCTOR QFtp(QObject *parent, const char *name);
00161 #endif
00162
00163 private:
00164 Q_DISABLE_COPY(QFtp)
00165 Q_DECLARE_PRIVATE(QFtp)
00166
00167 Q_PRIVATE_SLOT(d_func(), void _q_startNextCommand())
00168 Q_PRIVATE_SLOT(d_func(), void _q_piFinished(const QString&))
00169 Q_PRIVATE_SLOT(d_func(), void _q_piError(int, const QString&))
00170 Q_PRIVATE_SLOT(d_func(), void _q_piConnectState(int))
00171 Q_PRIVATE_SLOT(d_func(), void _q_piFtpReply(int, const QString&))
00172 };
00173
00174 #endif // QT_NO_FTP
00175
00176 QT_END_NAMESPACE
00177
00178 QT_END_HEADER
00179
00180 #endif // QFTP_H