Sayonara Player
WebClient.h
1/* WebClient.h */
2
3/* Copyright (C) 2011-2022 Michael Lugmair (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#ifndef SAYONARA_PLAYER_WEBCLIENT_H
22#define SAYONARA_PLAYER_WEBCLIENT_H
23
24#include <QByteArray>
25#include <QObject>
26#include <QString>
27
28class WebClient :
29 public QObject
30{
31 Q_OBJECT
32
33 signals:
34 void sigFinished();
35 void sigStopped();
36
37 public:
38 static constexpr const auto Timeout = 4000;
39
40 enum class Mode :
41 uint8_t
42 {
43 AsBrowser = 0,
44 AsSayonara,
45 Random,
46 None
47 };
48
49 enum class Status :
50 uint8_t
51 {
52 NoError = 0,
53 GotData,
54 AudioStream,
55 NoData,
56 NoHttp,
57 NotFound,
58 Timeout,
59 Error
60 };
61
62 explicit WebClient(QObject* parent);
63 virtual ~WebClient();
64
65 [[nodiscard]] virtual QByteArray data() const = 0;
66 [[nodiscard]] virtual bool hasData() const = 0;
67
68 [[nodiscard]] virtual QString url() const = 0;
69
70 [[nodiscard]] virtual Status status() const = 0;
71 [[nodiscard]] virtual bool hasError() const = 0;
72
73 virtual void setMode(Mode mode) = 0;
74 virtual void setRawHeader(const QMap<QByteArray, QByteArray>& header) = 0;
75
76 virtual void run(const QString& url, int timeout = Timeout) = 0; // NOLINT(google-default-arguments)
77 virtual void runPost(const QString& url, const QByteArray& postData,
78 int timeout = Timeout) = 0; // NOLINT(google-default-arguments)
79
80 public slots: // NOLINT(readability-redundant-access-specifiers)
81 virtual void stop() = 0;
82};
83
84#endif // ABSTRACTWEBACCESS_H
85
Definition: org_mpris_media_player2_adaptor.h:21
Definition: WebClient.h:30