~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/qt3support/network/q3networkprotocol.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the Qt 3 compatibility classes of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef Q3NETWORKPROTOCOL_H
 
30
#define Q3NETWORKPROTOCOL_H
 
31
 
 
32
#ifndef QT_H
 
33
#include "QtNetwork/qurlinfo.h"
 
34
#include "QtCore/qstring.h"
 
35
#include "Qt3Support/q3dict.h"
 
36
#include "QtCore/qobject.h"
 
37
#include "Qt3Support/q3valuelist.h"
 
38
#endif // QT_H
 
39
 
 
40
#ifndef QT_NO_NETWORKPROTOCOL
 
41
 
 
42
class Q3NetworkProtocol;
 
43
class Q3NetworkOperation;
 
44
class QTimer;
 
45
class Q3UrlOperator;
 
46
class Q3NetworkProtocolPrivate;
 
47
template <class T> class Q3ValueList;
 
48
 
 
49
class Q_COMPAT_EXPORT Q3NetworkProtocolFactoryBase
 
50
{
 
51
public:
 
52
    virtual ~Q3NetworkProtocolFactoryBase() {}
 
53
    virtual Q3NetworkProtocol *createObject() = 0;
 
54
};
 
55
 
 
56
template< class Protocol >
 
57
class Q3NetworkProtocolFactory : public Q3NetworkProtocolFactoryBase
 
58
{
 
59
public:
 
60
    Q3NetworkProtocol *createObject() {
 
61
        return new Protocol;
 
62
    }
 
63
 
 
64
};
 
65
 
 
66
typedef Q3Dict< Q3NetworkProtocolFactoryBase > Q3NetworkProtocolDict;
 
67
 
 
68
class Q_COMPAT_EXPORT Q3NetworkProtocol : public QObject
 
69
{
 
70
    Q_OBJECT
 
71
 
 
72
public:
 
73
    enum State {
 
74
        StWaiting = 0,
 
75
        StInProgress,
 
76
        StDone,
 
77
        StFailed,
 
78
        StStopped
 
79
    };
 
80
 
 
81
    enum Operation {
 
82
        OpListChildren = 1,
 
83
        OpMkDir = 2,
 
84
        OpMkdir = OpMkDir, // ### remove in 4.0
 
85
        OpRemove = 4,
 
86
        OpRename = 8,
 
87
        OpGet = 32,
 
88
        OpPut = 64
 
89
    };
 
90
 
 
91
    enum ConnectionState {
 
92
        ConHostFound,
 
93
        ConConnected,
 
94
        ConClosed
 
95
    };
 
96
 
 
97
    enum Error {
 
98
        // no error
 
99
        NoError = 0,
 
100
        // general errors
 
101
        ErrValid,
 
102
        ErrUnknownProtocol,
 
103
        ErrUnsupported,
 
104
        ErrParse,
 
105
        // errors on connect
 
106
        ErrLoginIncorrect,
 
107
        ErrHostNotFound,
 
108
        // protocol errors
 
109
        ErrListChildren,
 
110
        ErrListChlidren = ErrListChildren, // ### remove in 4.0
 
111
        ErrMkDir,
 
112
        ErrMkdir = ErrMkDir, // ### remove in 4.0
 
113
        ErrRemove,
 
114
        ErrRename,
 
115
        ErrGet,
 
116
        ErrPut,
 
117
        ErrFileNotExisting,
 
118
        ErrPermissionDenied
 
119
    };
 
120
 
 
121
    Q3NetworkProtocol();
 
122
    virtual ~Q3NetworkProtocol();
 
123
 
 
124
    virtual void setUrl( Q3UrlOperator *u );
 
125
 
 
126
    virtual void setAutoDelete( bool b, int i = 10000 );
 
127
    bool autoDelete() const;
 
128
 
 
129
    static void registerNetworkProtocol( const QString &protocol,
 
130
                                         Q3NetworkProtocolFactoryBase *protocolFactory );
 
131
    static Q3NetworkProtocol *getNetworkProtocol( const QString &protocol );
 
132
    static bool hasOnlyLocalFileSystem();
 
133
 
 
134
    virtual int supportedOperations() const;
 
135
    virtual void addOperation( Q3NetworkOperation *op );
 
136
 
 
137
    Q3UrlOperator *url() const;
 
138
    Q3NetworkOperation *operationInProgress() const;
 
139
    virtual void clearOperationQueue();
 
140
    virtual void stop();
 
141
 
 
142
signals:
 
143
    void data( const QByteArray &, Q3NetworkOperation *res );
 
144
    void connectionStateChanged( int state, const QString &data );
 
145
    void finished( Q3NetworkOperation *res );
 
146
    void start( Q3NetworkOperation *res );
 
147
    void newChildren( const Q3ValueList<QUrlInfo> &, Q3NetworkOperation *res );
 
148
    void newChild( const QUrlInfo &, Q3NetworkOperation *res );
 
149
    void createdDirectory( const QUrlInfo &, Q3NetworkOperation *res );
 
150
    void removed( Q3NetworkOperation *res );
 
151
    void itemChanged( Q3NetworkOperation *res );
 
152
    void dataTransferProgress( int bytesDone, int bytesTotal, Q3NetworkOperation *res );
 
153
 
 
154
protected:
 
155
    virtual void processOperation( Q3NetworkOperation *op );
 
156
    virtual void operationListChildren( Q3NetworkOperation *op );
 
157
    virtual void operationMkDir( Q3NetworkOperation *op );
 
158
    virtual void operationRemove( Q3NetworkOperation *op );
 
159
    virtual void operationRename( Q3NetworkOperation *op );
 
160
    virtual void operationGet( Q3NetworkOperation *op );
 
161
    virtual void operationPut( Q3NetworkOperation *op );
 
162
    virtual void operationPutChunk( Q3NetworkOperation *op );
 
163
    virtual bool checkConnection( Q3NetworkOperation *op );
 
164
 
 
165
private:
 
166
    Q3NetworkProtocolPrivate *d;
 
167
 
 
168
private slots:
 
169
    void processNextOperation( Q3NetworkOperation *old );
 
170
    void startOps();
 
171
    void emitNewChildren( const QUrlInfo &i, Q3NetworkOperation *op );
 
172
 
 
173
    void removeMe();
 
174
 
 
175
private:        // Disabled copy constructor and operator=
 
176
#if defined(Q_DISABLE_COPY)
 
177
    Q3NetworkProtocol( const Q3NetworkProtocol & );
 
178
    Q3NetworkProtocol &operator=( const Q3NetworkProtocol & );
 
179
#endif
 
180
};
 
181
 
 
182
class Q3NetworkOperationPrivate;
 
183
 
 
184
class Q_COMPAT_EXPORT Q3NetworkOperation : public QObject
 
185
{
 
186
    Q_OBJECT
 
187
    friend class Q3UrlOperator;
 
188
 
 
189
public:
 
190
    Q3NetworkOperation( Q3NetworkProtocol::Operation operation,
 
191
                    const QString &arg0, const QString &arg1,
 
192
                    const QString &arg2 );
 
193
    Q3NetworkOperation( Q3NetworkProtocol::Operation operation,
 
194
                    const QByteArray &arg0, const QByteArray &arg1,
 
195
                    const QByteArray &arg2 );
 
196
    ~Q3NetworkOperation();
 
197
 
 
198
    void setState( Q3NetworkProtocol::State state );
 
199
    void setProtocolDetail( const QString &detail );
 
200
    void setErrorCode( int ec );
 
201
    void setArg( int num, const QString &arg );
 
202
    void setRawArg( int num, const QByteArray &arg );
 
203
 
 
204
    Q3NetworkProtocol::Operation operation() const;
 
205
    Q3NetworkProtocol::State state() const;
 
206
    QString arg( int num ) const;
 
207
    QByteArray rawArg( int num ) const;
 
208
    QString protocolDetail() const;
 
209
    int errorCode() const;
 
210
 
 
211
    void free();
 
212
 
 
213
private slots:
 
214
    void deleteMe();
 
215
 
 
216
private:
 
217
    QByteArray &raw( int num ) const;
 
218
    Q3NetworkOperationPrivate *d;
 
219
 
 
220
private:        // Disabled copy constructor and operator=
 
221
#if defined(Q_DISABLE_COPY)
 
222
    Q3NetworkOperation( const Q3NetworkOperation & );
 
223
    Q3NetworkOperation &operator=( const Q3NetworkOperation & );
 
224
#endif
 
225
};
 
226
 
 
227
#endif // QT_NO_NETWORKPROTOCOL
 
228
 
 
229
#endif // Q3NETWORKPROTOCOL_H