Eneboo - Documentación para desarrolladores
src/qt/src/kernel/qnetworkprotocol.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qnetworkprotocol.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QNetworkProtocol class
00005 **
00006 ** Created : 950429
00007 **
00008 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the kernel module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QNETWORKPROTOCOL_H
00039 #define QNETWORKPROTOCOL_H
00040 
00041 #ifndef QT_H
00042 #include "qurlinfo.h"
00043 #include "qstring.h"
00044 #include "qdict.h"
00045 #include "qobject.h"
00046 #endif // QT_H
00047 
00048 #ifndef QT_NO_NETWORKPROTOCOL
00049 
00050 #if __GNUC__ - 0 > 3
00051 #pragma GCC system_header
00052 #endif
00053 
00054 class QNetworkProtocol;
00055 class QNetworkOperation;
00056 class QTimer;
00057 class QUrlOperator;
00058 class QNetworkProtocolPrivate;
00059 template <class T> class QValueList;
00060 
00061 class Q_EXPORT QNetworkProtocolFactoryBase
00062 {
00063 public:
00064    virtual QNetworkProtocol *createObject() = 0;
00065 
00066 };
00067 
00068 template< class T >
00069 class QNetworkProtocolFactory : public QNetworkProtocolFactoryBase
00070 {
00071 public:
00072     QNetworkProtocol *createObject() {
00073         return new T;
00074     }
00075 
00076 };
00077 
00078 typedef QDict< QNetworkProtocolFactoryBase > QNetworkProtocolDict;
00079 
00080 class Q_EXPORT QNetworkProtocol : public QObject
00081 {
00082     Q_OBJECT
00083 
00084 public:
00085     enum State {
00086         StWaiting = 0,
00087         StInProgress,
00088         StDone,
00089         StFailed,
00090         StStopped
00091     };
00092 
00093     enum Operation {
00094         OpListChildren = 1,
00095         OpMkDir = 2,
00096         OpMkdir = OpMkDir, // ### remove in 4.0
00097         OpRemove = 4,
00098         OpRename = 8,
00099         OpGet = 32,
00100         OpPut = 64
00101     };
00102 
00103     enum ConnectionState {
00104         ConHostFound,
00105         ConConnected,
00106         ConClosed
00107     };
00108 
00109     enum Error {
00110         // no error
00111         NoError = 0,
00112         // general errors
00113         ErrValid,
00114         ErrUnknownProtocol,
00115         ErrUnsupported,
00116         ErrParse,
00117         // errors on connect
00118         ErrLoginIncorrect,
00119         ErrHostNotFound,
00120         // protocol errors
00121         ErrListChildren,
00122         ErrListChlidren = ErrListChildren, // ### remove in 4.0
00123         ErrMkDir,
00124         ErrMkdir = ErrMkDir, // ### remove in 4.0
00125         ErrRemove,
00126         ErrRename,
00127         ErrGet,
00128         ErrPut,
00129         ErrFileNotExisting,
00130         ErrPermissionDenied
00131     };
00132 
00133     QNetworkProtocol();
00134     virtual ~QNetworkProtocol();
00135 
00136     virtual void setUrl( QUrlOperator *u );
00137 
00138     virtual void setAutoDelete( bool b, int i = 10000 );
00139     bool autoDelete() const;
00140 
00141     static void registerNetworkProtocol( const QString &protocol,
00142                                          QNetworkProtocolFactoryBase *protocolFactory );
00143     static QNetworkProtocol *getNetworkProtocol( const QString &protocol );
00144     static bool hasOnlyLocalFileSystem();
00145 
00146     virtual int supportedOperations() const;
00147     virtual void addOperation( QNetworkOperation *op );
00148 
00149     QUrlOperator *url() const;
00150     QNetworkOperation *operationInProgress() const;
00151     virtual void clearOperationQueue();
00152     virtual void stop();
00153 
00154 signals:
00155     void data( const QByteArray &, QNetworkOperation *res );
00156     void connectionStateChanged( int state, const QString &data );
00157     void finished( QNetworkOperation *res );
00158     void start( QNetworkOperation *res );
00159     void newChildren( const QValueList<QUrlInfo> &, QNetworkOperation *res );
00160     void newChild( const QUrlInfo &, QNetworkOperation *res );
00161     void createdDirectory( const QUrlInfo &, QNetworkOperation *res );
00162     void removed( QNetworkOperation *res );
00163     void itemChanged( QNetworkOperation *res );
00164     void dataTransferProgress( int bytesDone, int bytesTotal, QNetworkOperation *res );
00165 
00166 protected:
00167     virtual void processOperation( QNetworkOperation *op );
00168     virtual void operationListChildren( QNetworkOperation *op );
00169     virtual void operationMkDir( QNetworkOperation *op );
00170     virtual void operationRemove( QNetworkOperation *op );
00171     virtual void operationRename( QNetworkOperation *op );
00172     virtual void operationGet( QNetworkOperation *op );
00173     virtual void operationPut( QNetworkOperation *op );
00174     virtual void operationPutChunk( QNetworkOperation *op );
00175     virtual bool checkConnection( QNetworkOperation *op );
00176 
00177 private:
00178     QNetworkProtocolPrivate *d;
00179 
00180 private slots:
00181     void processNextOperation( QNetworkOperation *old );
00182     void startOps();
00183     void emitNewChildren( const QUrlInfo &i, QNetworkOperation *op );
00184 
00185     void removeMe();
00186 
00187 private:        // Disabled copy constructor and operator=
00188 #if defined(Q_DISABLE_COPY)
00189     QNetworkProtocol( const QNetworkProtocol & );
00190     QNetworkProtocol &operator=( const QNetworkProtocol & );
00191 #endif
00192 };
00193 
00194 class QNetworkOperationPrivate;
00195 
00196 class Q_EXPORT QNetworkOperation : public QObject
00197 {
00198     Q_OBJECT
00199     friend class QUrlOperator;
00200 
00201 public:
00202     QNetworkOperation( QNetworkProtocol::Operation operation,
00203                     const QString &arg0, const QString &arg1,
00204                     const QString &arg2 );
00205     QNetworkOperation( QNetworkProtocol::Operation operation,
00206                     const QByteArray &arg0, const QByteArray &arg1,
00207                     const QByteArray &arg2 );
00208     ~QNetworkOperation();
00209 
00210     void setState( QNetworkProtocol::State state );
00211     void setProtocolDetail( const QString &detail );
00212     void setErrorCode( int ec );
00213     void setArg( int num, const QString &arg );
00214     void setRawArg( int num, const QByteArray &arg );
00215 
00216     QNetworkProtocol::Operation operation() const;
00217     QNetworkProtocol::State state() const;
00218     QString arg( int num ) const;
00219     QByteArray rawArg( int num ) const;
00220     QString protocolDetail() const;
00221     int errorCode() const;
00222 
00223     void free();
00224 
00225 private slots:
00226     void deleteMe();
00227 
00228 private:
00229     QByteArray &raw( int num ) const;
00230     QNetworkOperationPrivate *d;
00231 
00232 private:        // Disabled copy constructor and operator=
00233 #if defined(Q_DISABLE_COPY)
00234     QNetworkOperation( const QNetworkOperation & );
00235     QNetworkOperation &operator=( const QNetworkOperation & );
00236 #endif
00237 };
00238 
00239 #endif // QT_NO_NETWORKPROTOCOL
00240 
00241 #endif // QNETWORKPROTOCOL_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'