/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebevent.h

http://github.com/tomahawk-player/tomahawk · C Header · 153 lines · 95 code · 24 blank · 34 comment · 0 complexity · 7a9d588fb50467ca4bc9d105a5a4dbde MD5 · raw file

  1. /****************************************************************************
  2. **
  3. ** Copyright (C) Qxt Foundation. Some rights reserved.
  4. **
  5. ** This file is part of the QxtWeb module of the Qxt library.
  6. **
  7. ** This library is free software; you can redistribute it and/or modify it
  8. ** under the terms of the Common Public License, version 1.0, as published
  9. ** by IBM, and/or under the terms of the GNU Lesser General Public License,
  10. ** version 2.1, as published by the Free Software Foundation.
  11. **
  12. ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
  13. ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
  14. ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
  15. ** FITNESS FOR A PARTICULAR PURPOSE.
  16. **
  17. ** You should have received a copy of the CPL and the LGPL along with this
  18. ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files
  19. ** included with the source distribution for more information.
  20. ** If you did not receive a copy of the licenses, contact the Qxt Foundation.
  21. **
  22. ** <http://libqxt.org> <foundation@libqxt.org>
  23. **
  24. ****************************************************************************/
  25. #ifndef QXTWEBEVENT_H
  26. #define QXTWEBEVENT_H
  27. #include <qxtglobal.h>
  28. #include <QString>
  29. #include <QByteArray>
  30. #include <QStringList>
  31. #include <QPointer>
  32. #include <QUrl>
  33. #include <QMultiHash>
  34. #include <QDateTime>
  35. QT_FORWARD_DECLARE_CLASS(QIODevice)
  36. class QxtWebContent;
  37. class QXT_WEB_EXPORT QxtWebEvent
  38. {
  39. public:
  40. enum EventType
  41. {
  42. None = 0,
  43. Request,
  44. FileUpload,
  45. Page,
  46. StoreCookie,
  47. RemoveCookie,
  48. Redirect
  49. };
  50. QxtWebEvent(EventType type, int sessionID);
  51. virtual ~QxtWebEvent();
  52. inline EventType type() const
  53. {
  54. return m_type;
  55. }
  56. const int sessionID;
  57. private:
  58. EventType m_type;
  59. };
  60. class QXT_WEB_EXPORT QxtWebRequestEvent : public QxtWebEvent
  61. {
  62. public:
  63. QxtWebRequestEvent(int sessionID, int requestID, const QUrl& url);
  64. ~QxtWebRequestEvent();
  65. const int requestID;
  66. QUrl url;
  67. const QUrl originalUrl;
  68. QString contentType;
  69. QPointer<QxtWebContent> content;
  70. QString method;
  71. QString remoteAddress;
  72. QMultiHash<QString, QString> cookies;
  73. QMultiHash<QString, QString> headers;
  74. };
  75. /* TODO: refactor and implement
  76. class QXT_WEB_EXPORT QxtWebFileUploadEvent : public QxtWebEvent {
  77. public:
  78. QxtWebFileUploadEvent(int sessionID);
  79. QString filename;
  80. int contentLength;
  81. QIODevice* content;
  82. };
  83. */
  84. class QxtWebRedirectEvent;
  85. class QXT_WEB_EXPORT QxtWebPageEvent : public QxtWebEvent
  86. {
  87. public:
  88. QxtWebPageEvent(int sessionID, int requestID, QSharedPointer<QIODevice> source);
  89. QxtWebPageEvent(int sessionID, int requestID, QByteArray source); // creates a QBuffer
  90. virtual ~QxtWebPageEvent();
  91. QSharedPointer<QIODevice> dataSource; // data is read from this device and written to the client
  92. bool chunked;
  93. bool streaming;
  94. const int requestID;
  95. int status;
  96. QByteArray statusMessage;
  97. QByteArray contentType;
  98. QMultiHash<QString, QString> headers;
  99. private:
  100. friend class QxtWebRedirectEvent;
  101. QxtWebPageEvent(QxtWebEvent::EventType typeOverride, int sessionID, int requestID, QByteArray source);
  102. };
  103. class QXT_WEB_EXPORT QxtWebErrorEvent : public QxtWebPageEvent
  104. {
  105. public:
  106. QxtWebErrorEvent(int sessionID, int requestID, int status, QByteArray statusMessage);
  107. };
  108. class QXT_WEB_EXPORT QxtWebStoreCookieEvent : public QxtWebEvent
  109. {
  110. public:
  111. QxtWebStoreCookieEvent(int sessionID, QString name, QString data, QDateTime expiration = QDateTime());
  112. QString name;
  113. QString data;
  114. QDateTime expiration;
  115. };
  116. class QXT_WEB_EXPORT QxtWebRemoveCookieEvent : public QxtWebEvent
  117. {
  118. public:
  119. QxtWebRemoveCookieEvent(int sessionID, QString name);
  120. QString name;
  121. };
  122. class QXT_WEB_EXPORT QxtWebRedirectEvent : public QxtWebPageEvent
  123. {
  124. public:
  125. QxtWebRedirectEvent(int sessionID, int requestID, const QString& destination, int statusCode = 302);
  126. QString destination;
  127. };
  128. #endif // QXTWEBEVENT_H