File indexing completed on 2025-01-19 03:55:39

0001 #ifndef O2POLLSERVER_H
0002 #define O2POLLSERVER_H
0003 
0004 #include <QByteArray>
0005 #include <QMap>
0006 #include <QNetworkRequest>
0007 #include <QObject>
0008 #include <QString>
0009 #include <QTimer>
0010 
0011 #include "o0export.h"
0012 
0013 class QNetworkAccessManager;
0014 
0015 /// Poll an authorization server for token
0016 class O0_EXPORT O2PollServer : public QObject
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     explicit O2PollServer(QNetworkAccessManager * manager, const QNetworkRequest &request, const QByteArray & payload, int expiresIn, QObject *parent = 0);
0022 
0023     /// Seconds to wait between polling requests
0024     Q_PROPERTY(int interval READ interval WRITE setInterval)
0025     int interval() const;
0026     void setInterval(int interval);
0027 
0028 Q_SIGNALS:
0029     void verificationReceived(QMap<QString, QString>);
0030     void serverClosed(bool); // whether it has found parameters
0031 
0032 public Q_SLOTS:
0033     void startPolling();
0034 
0035 protected Q_SLOTS:
0036     void onPollTimeout();
0037     void onExpiration();
0038     void onReplyFinished();
0039 
0040 protected:
0041     QNetworkAccessManager *manager_;
0042     const QNetworkRequest request_;
0043     const QByteArray payload_;
0044     const int expiresIn_;
0045     QTimer expirationTimer;
0046     QTimer pollTimer;
0047 };
0048 
0049 #endif // O2POLLSERVER_H