Sayonara Player
LFMWebAccess.h
1 /* LFMWebAccess.h */
2 
3 /* Copyright (C) 2011-2016 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 /*
23  * LFMWebAccess.h
24  *
25  * Created on: Oct 22, 2011
26  * Author: Lucio Carreras
27  */
28 
29 #ifndef LFMWEBACCESS_H_
30 #define LFMWEBACCESS_H_
31 
32 #include "LFMGlobals.h"
33 #include <QObject>
34 #include <QDomDocument>
35 #include <QMap>
36 #include <QByteArray>
37 
38 class UrlParams : public QMap<QByteArray, QByteArray> {
39 
40 public:
41  UrlParams();
42  void append_signature();
43 };
44 
45 
46 class LFMWebAccess : public QObject {
47 
48  Q_OBJECT
49 
50 signals:
51 
52  void sig_response(const QByteArray& response);
53  void sig_error(const QString& error);
54 
55 public:
56  void call_url(const QString& url);
57 
58  void call_post_url(const QString& url, const QByteArray& post_data);
59  void call_post_url_https(const QString& url, const QByteArray& post_data);
60 
61 private slots:
62  void awa_finished(bool success);
63 
64 
65 private:
66  QString parse_error_message(const QString& response);
67  bool check_error(const QByteArray& data, bool success);
68 
69 public:
70  static QString parse_session_answer(const QString& content);
71  static QString parse_token_answer(const QString& content);
72 
73  static QString create_std_url(const QString& base_url, const UrlParams& data);
74  static QString create_std_url_post(const QString& base_url, const UrlParams& data, QByteArray& post_data);
75 };
76 
77 
78 #endif /* LFMWEBACCESS_H_ */
Definition: LFMWebAccess.h:46
Definition: LFMWebAccess.h:38
Definition: org_mpris_media_player2_adaptor.h:21