Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgshttptransaction.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgshttptransaction.h - Tracks a HTTP request with its response,
3  with particular attention to tracking
4  HTTP redirect responses
5  -------------------
6  begin : 17 Mar, 2005
7  copyright : (C) 2005 by Brendan Morley
8  email : morb at ozemail dot com dot au
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
20 /* $Id: qgshttptransaction.h 5697 2006-08-15 10:29:46Z morb_au $ */
21 
22 #ifndef QGSHTTPTRANSACTION_H
23 #define QGSHTTPTRANSACTION_H
24 
25 #include <QHttp>
26 #include <QNetworkProxy>
27 #include <QString>
28 
29 class QTimer;
30 
37 class CORE_EXPORT QgsHttpTransaction : public QObject
38 {
39 
40  Q_OBJECT
41 
42  public:
47  QgsHttpTransaction( QString uri,
48  QString proxyHost = QString(),
49  int proxyPort = 80,
50  QString proxyUser = QString(),
51  QString proxyPass = QString(),
52  QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy,
53  QString userName = QString(),
54  QString password = QString() );
55 
57  virtual ~QgsHttpTransaction();
58 
59  void getAsynchronously();
60 
63 
76  bool getSynchronously( QByteArray &respondedContent, int redirections = 0, const QByteArray* postData = 0 );
77 
78  QString responseContentType();
79 
86  QString errorString();
87 
90  static bool applyProxySettings( QHttp& http, const QString& url );
91 
97  void setCredentials( const QString& username, const QString &password );
98 
100  int networkTimeout() const { return mNetworkTimeoutMsec;}
102  void setNetworkTimeout( int msec ) { mNetworkTimeoutMsec = msec;}
103 
104 
105  public slots:
106 
107  void dataStarted( int id );
108 
109  void dataHeaderReceived( const QHttpResponseHeader& resp );
110 
111  void dataReceived( const QHttpResponseHeader& resp );
112 
113  void dataProgress( int done, int total );
114 
115  void dataFinished( int id, bool error );
116 
117  void transactionFinished( bool error );
118 
119  void dataStateChanged( int state );
120 
121  void networkTimedOut();
122 
124  void abort();
125 
126  signals:
127 
129  void setProgress( int done, int total );
130 
132  void dataReadProgress( int theProgress );
134  void totalSteps( int theTotalSteps );
135 
137  void statusChanged( QString theStatusQString );
138 
139 
140  private:
141 
144 
152  QHttp* http;
153 
157  int httpid;
158 
163 
164  /*
165  * Indicates the response from the QHttp
166  */
167  QByteArray httpresponse;
168 
169  /*
170  * Indicates the content type of the response from the QHttp
171  */
173 
177  QString httpurl;
178 
182  QString httphost;
183 
189 
198 
202  QTimer * mWatchdogTimer;
203 
207  QString mError;
208 
212  QString mUserName;
213 
217  QString mPassword;
218 
221 };
222 
223 #endif
224 
225 // ENDS