choke uploadProgress signals
[profile/ivi/qtbase.git] / src / network / access / qftp_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtNetwork module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 //
43 //  W A R N I N G
44 //  -------------
45 //
46 // This file is not part of the Qt API.  It exists for the convenience
47 // of the Network Access API.  This header file may change from
48 // version to version without notice, or even be removed.
49 //
50 // We mean it.
51 //
52
53 #ifndef QFTP_H
54 #define QFTP_H
55
56 #include <QtCore/qstring.h>
57 #include <QtNetwork/qurlinfo.h>
58 #include <QtCore/qobject.h>
59
60 QT_BEGIN_HEADER
61
62 QT_BEGIN_NAMESPACE
63
64
65 #ifndef QT_NO_FTP
66
67 class QFtpPrivate;
68
69 class Q_AUTOTEST_EXPORT QFtp : public QObject
70 {
71     Q_OBJECT
72
73 public:
74     explicit QFtp(QObject *parent = 0);
75     virtual ~QFtp();
76
77     enum State {
78         Unconnected,
79         HostLookup,
80         Connecting,
81         Connected,
82         LoggedIn,
83         Closing
84     };
85     enum Error {
86         NoError,
87         UnknownError,
88         HostNotFound,
89         ConnectionRefused,
90         NotConnected
91     };
92     enum Command {
93         None,
94         SetTransferMode,
95         SetProxy,
96         ConnectToHost,
97         Login,
98         Close,
99         List,
100         Cd,
101         Get,
102         Put,
103         Remove,
104         Mkdir,
105         Rmdir,
106         Rename,
107         RawCommand
108     };
109     enum TransferMode {
110         Active,
111         Passive
112     };
113     enum TransferType {
114         Binary,
115         Ascii
116     };
117
118     int setProxy(const QString &host, quint16 port);
119     int connectToHost(const QString &host, quint16 port=21);
120     int login(const QString &user = QString(), const QString &password = QString());
121     int close();
122     int setTransferMode(TransferMode mode);
123     int list(const QString &dir = QString());
124     int cd(const QString &dir);
125     int get(const QString &file, QIODevice *dev=0, TransferType type = Binary);
126     int put(const QByteArray &data, const QString &file, TransferType type = Binary);
127     int put(QIODevice *dev, const QString &file, TransferType type = Binary);
128     int remove(const QString &file);
129     int mkdir(const QString &dir);
130     int rmdir(const QString &dir);
131     int rename(const QString &oldname, const QString &newname);
132
133     int rawCommand(const QString &command);
134
135     qint64 bytesAvailable() const;
136     qint64 read(char *data, qint64 maxlen);
137     QByteArray readAll();
138
139     int currentId() const;
140     QIODevice* currentDevice() const;
141     Command currentCommand() const;
142     bool hasPendingCommands() const;
143     void clearPendingCommands();
144
145     State state() const;
146
147     Error error() const;
148     QString errorString() const;
149
150 public Q_SLOTS:
151     void abort();
152
153 Q_SIGNALS:
154     void stateChanged(int);
155     void listInfo(const QUrlInfo&);
156     void readyRead();
157     void dataTransferProgress(qint64, qint64);
158     void rawCommandReply(int, const QString&);
159
160     void commandStarted(int);
161     void commandFinished(int, bool);
162     void done(bool);
163
164 private:
165     Q_DISABLE_COPY(QFtp)
166     Q_DECLARE_PRIVATE(QFtp)
167
168     Q_PRIVATE_SLOT(d_func(), void _q_startNextCommand())
169     Q_PRIVATE_SLOT(d_func(), void _q_piFinished(const QString&))
170     Q_PRIVATE_SLOT(d_func(), void _q_piError(int, const QString&))
171     Q_PRIVATE_SLOT(d_func(), void _q_piConnectState(int))
172     Q_PRIVATE_SLOT(d_func(), void _q_piFtpReply(int, const QString&))
173 };
174
175 #endif // QT_NO_FTP
176
177 QT_END_NAMESPACE
178
179 QT_END_HEADER
180
181 #endif // QFTP_H