File indexing completed on 2025-01-19 03:55:39
0001 #ifndef O2TIMEDREPLYLIST_H 0002 #define O2TIMEDREPLYLIST_H 0003 0004 #include <QList> 0005 #include <QTimer> 0006 #include <QNetworkRequest> 0007 #include <QNetworkReply> 0008 #include <QNetworkAccessManager> 0009 #include <QByteArray> 0010 0011 #include "o0export.h" 0012 0013 /// A network request/reply pair that can time out. 0014 class O0_EXPORT O2Reply: public QTimer { 0015 Q_OBJECT 0016 0017 public: 0018 O2Reply(QNetworkReply *reply, int timeOut = 60 * 1000, QObject *parent = 0); 0019 0020 Q_SIGNALS: 0021 void error(QNetworkReply::NetworkError); 0022 0023 public Q_SLOTS: 0024 /// When time out occurs, the QNetworkReply's error() signal is triggered. 0025 void onTimeOut(); 0026 0027 public: 0028 QNetworkReply *reply; 0029 }; 0030 0031 /// List of O2Replies. 0032 class O0_EXPORT O2ReplyList { 0033 public: 0034 O2ReplyList() { ignoreSslErrors_ = false; } 0035 0036 /// Destructor. 0037 /// Deletes all O2Reply instances in the list. 0038 virtual ~O2ReplyList(); 0039 0040 /// Create a new O2Reply from a QNetworkReply, and add it to this list. 0041 void add(QNetworkReply *reply); 0042 0043 /// Add an O2Reply to the list, while taking ownership of it. 0044 void add(O2Reply *reply); 0045 0046 /// Remove item from the list that corresponds to a QNetworkReply. 0047 void remove(QNetworkReply *reply); 0048 0049 /// Find an O2Reply in the list, corresponding to a QNetworkReply. 0050 /// @return Matching O2Reply or NULL. 0051 O2Reply *find(QNetworkReply *reply); 0052 0053 bool ignoreSslErrors(); 0054 void setIgnoreSslErrors(bool ignoreSslErrors); 0055 0056 protected: 0057 QList<O2Reply *> replies_; 0058 bool ignoreSslErrors_; 0059 }; 0060 0061 #endif // O2TIMEDREPLYLIST_H