source: SMSSender/lib/libdatatypes/src/shttphelper.h @ 71:415b45c71663

3.0
Last change on this file since 71:415b45c71663 was 71:415b45c71663, checked in by Sämy Zehnder <saemy.zehnder@…>, 13 years ago
  • Reorganized all the libraries. libinterfaces and libgateways are removed now and libdatatypes contains now all these files.
File size: 2.1 KB
Line 
1/*
2 * AbstractAccount.h
3 *
4 *  Created on: Jul 9, 2009
5 *      Author: saemy
6 */
7
8#ifndef SHTTPHELPER_H_
9#define SHTTPHELPER_H_
10
11#include <QBuffer>
12#include <QEventLoop>
13#include <QMap>
14#include <QHttp>
15#include <QHttpResponseHeader>
16
17#include <iaccount.h>
18
19#include "shttpcookiemanager.h"
20
21
22class SHttpRequest: public QObject {
23    Q_OBJECT
24
25public:
26    int     httpRequestId;
27
28    QString method;
29    QString posts;
30
31    QBuffer buffer;
32
33    bool    finished;
34};
35
36class SHttpHelper: public QObject {
37    Q_OBJECT
38
39public:
40    SHttpHelper();
41    ~SHttpHelper();
42
43    virtual QHttp*             http() const;
44    virtual SHttpCookieManager* cookieManager() const;
45
46    virtual QString            get(const QString& destination, const QMap<QString, QString>& requests = (QMap<QString, QString>()));
47    virtual QString            post(const QString& destination, const QMap<QString, QString>& requests = (QMap<QString, QString>()), const QMap<QString, QString>& posts = (QMap<QString, QString>()));
48
49protected:
50    virtual QHttpRequestHeader defaultHeader(const QUrl& url) const;
51
52    virtual void               startRequest(const QString& method, const QString& destination, const QMap<QString, QString>& requests = (QMap<QString, QString>()), const QMap<QString, QString>& posts = (QMap<QString, QString>()));
53    virtual int                doRequest(const QString& destination);
54    //virtual bool               isRequestFinished() const;
55    virtual void               waitForRequest(bool createIfNotExisting = true);
56    virtual QString            getRequestResult() const;
57
58private:
59    QHttp*              http_;
60    QHttpRequestHeader* defaultHeader_;
61
62    SHttpCookieManager*  cookieManager_;
63
64    SHttpRequest         request_;
65    QString             requestResult_;
66    QEventLoop          requestLoop_;
67
68    QString getParamStr(const QMap<QString, QString>& params);
69
70private slots:
71    void responseHeaderReceived(const QHttpResponseHeader& responseHeader);
72    void httpRequestFinished(int httpRequestId, bool error);
73    void sslErrors(const QList<QSslError>& errors);
74};
75
76#endif /* HTTPHELPER_H_ */
Note: See TracBrowser for help on using the repository browser.