PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/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
20#ifndef TOMAHAWK_WEBAPI_V1
21#define TOMAHAWK_WEBAPI_V1
22
23// See: http://doc.libqxt.org/tip/qxtweb.html
24
25#include "QxtHttpServerConnector"
26#include "QxtHttpSessionManager"
27#include "QxtWebContent"
28#include "QxtWebSlotService"
29#include "QxtWebPageEvent"
30
31#include <qjson/parser.h>
32#include <qjson/serializer.h>
33#include <qjson/qobjecthelper.h>
34
35#include <QFile>
36#include <QSharedPointer>
37#include <QStringList>
38
39class Api_v1 : public QxtWebSlotService
40{
41Q_OBJECT
42
43public:
44
45    Api_v1( QxtAbstractWebSessionManager* sm, QObject* parent = 0 );
46
47public slots:
48    // authenticating uses /auth_1
49    // we redirect to /auth_2 for the callback
50    void auth_1( QxtWebRequestEvent* event, QString unused = QString() );
51    void auth_2( QxtWebRequestEvent* event, QString unused = QString() );
52
53    // all v1 api calls go to /api/
54    void api( QxtWebRequestEvent* event );
55
56    // request for stream: /sid/<id>
57    void sid( QxtWebRequestEvent* event, QString unused = QString() );
58    void send404( QxtWebRequestEvent* event );
59    void stat( QxtWebRequestEvent* event );
60    void statResult( const QString& clientToken, const QString& name, bool valid );
61    void resolve( QxtWebRequestEvent* event );
62    void staticdata( QxtWebRequestEvent* event,const QString& );
63    void get_results( QxtWebRequestEvent* event );
64    void sendJSON( const QVariantMap& m, QxtWebRequestEvent* event );
65
66    // load an html template from a file, replace args from map
67    // then serve
68    void sendWebpageWithArgs( QxtWebRequestEvent* event, const QString& filenameSource, const QHash< QString, QString >& args );
69
70    void index( QxtWebRequestEvent* event );
71
72private:
73    QxtWebRequestEvent* m_storedEvent;
74};
75
76#endif
77