File indexing completed on 2025-01-19 03:55:39
0001 #ifndef O1REQUESTOR_H 0002 #define O1REQUESTOR_H 0003 0004 #include <QObject> 0005 #include <QNetworkRequest> 0006 #include <QByteArray> 0007 0008 #include "o0export.h" 0009 #include "o1.h" 0010 0011 class QNetworkAccessManager; 0012 class QNetworkReply; 0013 class O1; 0014 0015 /// Makes authenticated requests using OAuth 1.0. 0016 class O0_EXPORT O1Requestor: public QObject { 0017 Q_OBJECT 0018 0019 public: 0020 explicit O1Requestor(QNetworkAccessManager *manager, O1 *authenticator, QObject *parent = 0); 0021 0022 public Q_SLOTS: 0023 /// Make a GET request. 0024 /// @param req Network request. 0025 /// @param signingParameters Extra (non-OAuth) parameters participating in signing. 0026 /// @return Reply. 0027 QNetworkReply *get(const QNetworkRequest &req, const QList<O0RequestParameter> &signingParameters); 0028 0029 /// Make a POST request. 0030 /// @param req Network request. 0031 /// @param signingParameters Extra (non-OAuth) parameters participating in signing. 0032 /// @param data Request payload. 0033 /// @return Reply. 0034 QNetworkReply *post(const QNetworkRequest &req, const QList<O0RequestParameter> &signingParameters, const QByteArray &data); 0035 0036 /// Make a POST request. 0037 /// @param req Network request. 0038 /// @param signingParameters Extra (non-OAuth) parameters participating in signing. 0039 /// @param multiPart HTTPMultiPart. 0040 /// @return Reply. 0041 QNetworkReply *post(const QNetworkRequest &req, const QList<O0RequestParameter> &signingParameters, QHttpMultiPart *multiPart); 0042 0043 /// Make a PUT request. 0044 /// @param req Network request. 0045 /// @param signingParameters Extra (non-OAuth) parameters participating in signing. 0046 /// @param data Request payload. 0047 /// @return Reply. 0048 QNetworkReply *put(const QNetworkRequest &req, const QList<O0RequestParameter> &signingParameters, const QByteArray &data); 0049 0050 protected: 0051 /// Return new request based on the original, with the "Authentication:" header added. 0052 QNetworkRequest setup(const QNetworkRequest &request, const QList<O0RequestParameter> &signingParameters, QNetworkAccessManager::Operation operation); 0053 0054 /// Augment reply with a timer. 0055 QNetworkReply *addTimer(QNetworkReply *reply); 0056 0057 QNetworkAccessManager *manager_; 0058 O1 *authenticator_; 0059 }; 0060 0061 0062 #endif // O1REQUESTOR_H