/src/web/api_v1.h

http://github.com/tomahawk-player/tomahawk · C Header · 77 lines · 36 code · 16 blank · 25 comment · 0 complexity · d15f9588037027df014d34e93c7d6b7a MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4. * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
  5. *
  6. * Tomahawk is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Tomahawk is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef TOMAHAWK_WEBAPI_V1
  20. #define TOMAHAWK_WEBAPI_V1
  21. // See: http://doc.libqxt.org/tip/qxtweb.html
  22. #include "QxtHttpServerConnector"
  23. #include "QxtHttpSessionManager"
  24. #include "QxtWebContent"
  25. #include "QxtWebSlotService"
  26. #include "QxtWebPageEvent"
  27. #include <qjson/parser.h>
  28. #include <qjson/serializer.h>
  29. #include <qjson/qobjecthelper.h>
  30. #include <QFile>
  31. #include <QSharedPointer>
  32. #include <QStringList>
  33. class Api_v1 : public QxtWebSlotService
  34. {
  35. Q_OBJECT
  36. public:
  37. Api_v1( QxtAbstractWebSessionManager* sm, QObject* parent = 0 );
  38. public slots:
  39. // authenticating uses /auth_1
  40. // we redirect to /auth_2 for the callback
  41. void auth_1( QxtWebRequestEvent* event, QString unused = QString() );
  42. void auth_2( QxtWebRequestEvent* event, QString unused = QString() );
  43. // all v1 api calls go to /api/
  44. void api( QxtWebRequestEvent* event );
  45. // request for stream: /sid/<id>
  46. void sid( QxtWebRequestEvent* event, QString unused = QString() );
  47. void send404( QxtWebRequestEvent* event );
  48. void stat( QxtWebRequestEvent* event );
  49. void statResult( const QString& clientToken, const QString& name, bool valid );
  50. void resolve( QxtWebRequestEvent* event );
  51. void staticdata( QxtWebRequestEvent* event,const QString& );
  52. void get_results( QxtWebRequestEvent* event );
  53. void sendJSON( const QVariantMap& m, QxtWebRequestEvent* event );
  54. // load an html template from a file, replace args from map
  55. // then serve
  56. void sendWebpageWithArgs( QxtWebRequestEvent* event, const QString& filenameSource, const QHash< QString, QString >& args );
  57. void index( QxtWebRequestEvent* event );
  58. private:
  59. QxtWebRequestEvent* m_storedEvent;
  60. };
  61. #endif