requestqueue.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. *
  3. * requestqueue.h
  4. * © Copyrights 2012 inneractive LTD, Nokia. All rights reserved
  5. *
  6. * This file is part of inneractiveAdQML.
  7. *
  8. * inneractiveAdQML is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * inneractiveAdQML is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with inneractiveAdQML. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef REQUESTQUEUE_H
  22. #define REQUESTQUEUE_H
  23. #include <QObject>
  24. #include <QQueue>
  25. #include <QNetworkSession>
  26. class QNetworkAccessManager;
  27. class QNetworkReply;
  28. class AdInterface;
  29. class QNetworkSession;
  30. class QNetworkConfigurationManager;
  31. class RequestQueue : public QObject
  32. {
  33. Q_OBJECT
  34. public:
  35. explicit RequestQueue(AdInterface *parent = 0);
  36. ~RequestQueue();
  37. void setUserAgent(const QByteArray &ua) { m_userAgent = ua; }
  38. bool isOnline() const;
  39. signals:
  40. public slots:
  41. void addToQueue(QObject *object);
  42. private:
  43. private slots:
  44. void handleRequests();
  45. void adRequestFinished(QNetworkReply *req);
  46. void netSessionStateChanged(QNetworkSession::State state = QNetworkSession::Connected);
  47. signals:
  48. void requestReady();
  49. private:
  50. QQueue<QObject*> m_adItemQueue;
  51. QNetworkAccessManager *m_nam;
  52. QByteArray m_userAgent;
  53. bool m_requestRunning;
  54. QNetworkConfigurationManager *m_confman;
  55. QNetworkSession *m_nsession;
  56. bool m_onlineCheck;
  57. bool m_networkError;
  58. };
  59. #endif // REQUESTQUEUE_H