~ubuntu-branches/ubuntu/wily/kid3/wily-proposed

« back to all changes in this revision

Viewing changes to src/core/import/httpclient.h

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2012-05-14 18:27:44 UTC
  • mfrom: (1.1.14) (2.1.16 sid)
  • Revision ID: package-import@ubuntu.com-20120514182744-4tul4661q4rao8vm
Tags: 2.1-2
Remove patch 01-gcc4.7-ftbfs, it was merged with 2.1 to another location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
#include <QObject>
31
31
#include <QString>
 
32
#include <QNetworkReply>
 
33
#include <QPointer>
32
34
 
33
35
class QByteArray;
34
 
class QHttp;
35
 
class QHttpResponseHeader;
 
36
class QNetworkAccessManager;
36
37
 
37
38
/**
38
39
 * Client to connect to HTTP server.
39
40
 */
40
 
class HttpClient : public QObject
41
 
{
 
41
class HttpClient : public QObject {
42
42
Q_OBJECT
43
43
 
44
44
public:
45
 
  /** Connection progress steps. */
46
 
  enum ConnectionSteps {
47
 
    CS_RequestConnection = 0, /**< Send Request */
48
 
    CS_Connecting        = 1, /**< Connecting */
49
 
    CS_HostFound         = 2, /**< Host Found */
50
 
    CS_RequestSent       = 3, /**< Request Sent */
51
 
    CS_EstimatedBytes = 75000 /**< Estimated total number of bytes */
52
 
  };
53
 
 
54
45
  /**
55
46
   * Constructor.
56
47
   *
57
 
   * @param parent  parent object
 
48
   * @param netMgr  network access manager
58
49
   */
59
 
  explicit HttpClient(QObject* parent = 0);
 
50
  explicit HttpClient(QNetworkAccessManager* netMgr);
60
51
 
61
52
  /**
62
53
   * Destructor.
68
59
   *
69
60
   * @param server host name
70
61
   * @param path   path of the URL
71
 
   * @param setUserAgent true to set user agent to Mozilla
72
62
   */
73
 
  void sendRequest(const QString& server, const QString& path,
74
 
                   bool setUserAgent = false);
 
63
  void sendRequest(const QString& server, const QString& path);
75
64
 
76
65
  /**
77
66
   * Abort request.
115
104
 
116
105
private slots:
117
106
  /**
118
 
   * Called when the connection state changes.
119
 
   *
120
 
   * @param state HTTP connection state
 
107
   * Called when the request is finished.
121
108
   */
122
 
  void slotStateChanged(int state);
 
109
  void networkReplyFinished();
123
110
 
124
111
  /**
125
112
   * Called to report connection progress.
126
113
   *
127
 
   * @param done  bytes received
128
 
   * @param total total bytes, 0 if unknown
129
 
   */
130
 
  void slotDataReadProgress(int done, int total);
131
 
 
132
 
  /**
133
 
   * Called when the request is finished.
134
 
   *
135
 
   * @param error true if error occurred
136
 
   */
137
 
  void slotDone(bool error);
138
 
 
139
 
  /**
140
 
   * Called when the response header is available.
141
 
   *
142
 
   * @param resp HTTP response header
143
 
   */
144
 
  void slotResponseHeaderReceived(const QHttpResponseHeader& resp);
 
114
   * @param received bytes received
 
115
   * @param total total bytes
 
116
   */
 
117
  void networkReplyProgress(qint64 received, qint64 total);
 
118
 
 
119
  /**
 
120
   * Called when an error occurred.
 
121
   *
 
122
   * @param code error code
 
123
   */
 
124
  void networkReplyError(QNetworkReply::NetworkError);
145
125
 
146
126
private:
147
127
  /**
175
155
   */
176
156
  static QString getProxyOrDest(const QString& dst);
177
157
 
178
 
  /** client socket */
179
 
  QHttp* m_http;
 
158
  /** network access manager */
 
159
  QNetworkAccessManager* m_netMgr;
 
160
  /** network reply if available, else 0 */
 
161
  QPointer<QNetworkReply> m_reply;
180
162
  /** content length of entitiy-body, 0 if not available */
181
163
  unsigned long m_rcvBodyLen;
182
164
  /** content type */