Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgshttptransaction.h - Tracks a HTTP request with its response, 00003 with particular attention to tracking 00004 HTTP redirect responses 00005 ------------------- 00006 begin : 17 Mar, 2005 00007 copyright : (C) 2005 by Brendan Morley 00008 email : morb at ozemail dot com dot au 00009 ***************************************************************************/ 00010 00011 /*************************************************************************** 00012 * * 00013 * This program is free software; you can redistribute it and/or modify * 00014 * it under the terms of the GNU General Public License as published by * 00015 * the Free Software Foundation; either version 2 of the License, or * 00016 * (at your option) any later version. * 00017 * * 00018 ***************************************************************************/ 00019 00020 00021 #ifndef QGSHTTPTRANSACTION_H 00022 #define QGSHTTPTRANSACTION_H 00023 00024 #include <QHttp> 00025 #include <QNetworkProxy> 00026 #include <QString> 00027 00028 class QTimer; 00029 00036 class CORE_EXPORT QgsHttpTransaction : public QObject 00037 { 00038 00039 Q_OBJECT 00040 00041 public: 00046 QgsHttpTransaction( QString uri, 00047 QString proxyHost = QString(), 00048 int proxyPort = 80, 00049 QString proxyUser = QString(), 00050 QString proxyPass = QString(), 00051 QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy, 00052 QString userName = QString(), 00053 QString password = QString() ); 00054 00056 virtual ~QgsHttpTransaction(); 00057 00058 void getAsynchronously(); 00059 00062 00075 bool getSynchronously( QByteArray &respondedContent, int redirections = 0, const QByteArray* postData = 0 ); 00076 00077 QString responseContentType(); 00078 00085 QString errorString(); 00086 00089 static bool applyProxySettings( QHttp& http, const QString& url ); 00090 00096 void setCredentials( const QString& username, const QString &password ); 00097 00099 int networkTimeout() const { return mNetworkTimeoutMsec;} 00101 void setNetworkTimeout( int msec ) { mNetworkTimeoutMsec = msec;} 00102 00103 00104 public slots: 00105 00106 void dataStarted( int id ); 00107 00108 void dataHeaderReceived( const QHttpResponseHeader& resp ); 00109 00110 void dataReceived( const QHttpResponseHeader& resp ); 00111 00112 void dataProgress( int done, int total ); 00113 00114 void dataFinished( int id, bool error ); 00115 00116 void transactionFinished( bool error ); 00117 00118 void dataStateChanged( int state ); 00119 00120 void networkTimedOut(); 00121 00123 void abort(); 00124 00125 signals: 00126 00128 void setProgress( int done, int total ); 00129 00131 void dataReadProgress( int theProgress ); 00133 void totalSteps( int theTotalSteps ); 00134 00136 void statusChanged( QString theStatusQString ); 00137 00138 00139 private: 00140 00142 QgsHttpTransaction(); 00143 00151 QHttp* http; 00152 00156 int httpid; 00157 00161 bool httpactive; 00162 00163 /* 00164 * Indicates the response from the QHttp 00165 */ 00166 QByteArray httpresponse; 00167 00168 /* 00169 * Indicates the content type of the response from the QHttp 00170 */ 00171 QString httpresponsecontenttype; 00172 00176 QString httpurl; 00177 00181 QString httphost; 00182 00187 QString httpredirecturl; 00188 00196 int httpredirections; 00197 00201 QTimer * mWatchdogTimer; 00202 00206 QString mError; 00207 00211 QString mUserName; 00212 00216 QString mPassword; 00217 00219 int mNetworkTimeoutMsec; 00220 }; 00221 00222 #endif 00223 00224 // ENDS