00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef QGSHTTPTRANSACTION_H
00023 #define QGSHTTPTRANSACTION_H
00024
00025 #include <QHttp>
00026 #include <QNetworkProxy>
00027 #include <QString>
00028
00029 class QTimer;
00030
00037 class CORE_EXPORT QgsHttpTransaction : public QObject
00038 {
00039
00040 Q_OBJECT
00041
00042 public:
00047 QgsHttpTransaction( QString uri,
00048 QString proxyHost = QString(),
00049 int proxyPort = 80,
00050 QString proxyUser = QString(),
00051 QString proxyPass = QString(),
00052 QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy,
00053 QString userName = QString(),
00054 QString password = QString() );
00055
00057 virtual ~QgsHttpTransaction();
00058
00059 void getAsynchronously();
00060
00063
00076 bool getSynchronously( QByteArray &respondedContent, int redirections = 0, const QByteArray* postData = 0 );
00077
00078 QString responseContentType();
00079
00086 QString errorString();
00087
00090 static bool applyProxySettings( QHttp& http, const QString& url );
00091
00097 void setCredentials( const QString& username, const QString &password );
00098
00100 int networkTimeout() const { return mNetworkTimeoutMsec;}
00102 void setNetworkTimeout( int msec ) { mNetworkTimeoutMsec = msec;}
00103
00104
00105 public slots:
00106
00107 void dataStarted( int id );
00108
00109 void dataHeaderReceived( const QHttpResponseHeader& resp );
00110
00111 void dataReceived( const QHttpResponseHeader& resp );
00112
00113 void dataProgress( int done, int total );
00114
00115 void dataFinished( int id, bool error );
00116
00117 void transactionFinished( bool error );
00118
00119 void dataStateChanged( int state );
00120
00121 void networkTimedOut();
00122
00124 void abort();
00125
00126 signals:
00127
00129 void setProgress( int done, int total );
00130
00132 void dataReadProgress( int theProgress );
00134 void totalSteps( int theTotalSteps );
00135
00137 void statusChanged( QString theStatusQString );
00138
00139
00140 private:
00141
00143 QgsHttpTransaction();
00144
00152 QHttp* http;
00153
00157 int httpid;
00158
00162 bool httpactive;
00163
00164
00165
00166
00167 QByteArray httpresponse;
00168
00169
00170
00171
00172 QString httpresponsecontenttype;
00173
00177 QString httpurl;
00178
00182 QString httphost;
00183
00188 QString httpredirecturl;
00189
00197 int httpredirections;
00198
00202 QTimer * mWatchdogTimer;
00203
00207 QString mError;
00208
00212 QString mUserName;
00213
00217 QString mPassword;
00218
00220 int mNetworkTimeoutMsec;
00221 };
00222
00223 #endif
00224
00225