- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qftp.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtNetwork module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    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