Sayonara Player
WebClientImpl.h
1/* WebClientImpl.h */
2/*
3 * Copyright (C) 2011-2022 Michael Lugmair
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#ifndef SAYONARA_PLAYER_WEBCLIENTIMPL_H
21#define SAYONARA_PLAYER_WEBCLIENTIMPL_H
22
23#include "WebClient.h"
24#include "Utils/Pimpl.h"
25
27 public QObject
28{
29 Q_OBJECT
31
32 signals:
33 void sigFinished();
34 void sigTimeout();
35 void sigStopped();
36
37 public:
38 explicit AbstractWebClientStopper(QObject* parent);
39 ~AbstractWebClientStopper() noexcept override;
40
41 void startTimer(int timeout);
42 void stopTimer();
43 void stop();
44
45 private slots: // NOLINT(readability-redundant-access-specifiers)
46 void timeout();
47};
48
50 public WebClient
51{
52 Q_OBJECT
53 PIMPL(WebClientImpl)
54
55 public:
56 explicit WebClientImpl(QObject* parent);
57 ~WebClientImpl() override;
58
59 void run(const QString& url, int timeout=WebClient::Timeout) override;
60 void runPost(const QString& url, const QByteArray& postData, int timeout) override;
61
62 void setMode(WebClientImpl::Mode mode) override;
63 void setRawHeader(const QMap<QByteArray, QByteArray>& header) override;
64
65 [[nodiscard]] bool hasData() const override;
66 [[nodiscard]] QByteArray data() const override;
67 [[nodiscard]] QString url() const override;
68 [[nodiscard]] WebClientImpl::Status status() const override;
69 [[nodiscard]] bool hasError() const override;
70
71 public slots: // NOLINT(readability-redundant-access-specifiers)
72 void stop() override;
73
74 private slots:
75 void dataAvailable();
76 void finished();
77 void timeout();
78
79 private:
80 void reset();
81};
82
83#endif //SAYONARA_PLAYER_WEBCLIENTIMPL_H
Definition: WebClientImpl.h:28
Definition: org_mpris_media_player2_adaptor.h:21
Definition: WebClientImpl.h:51
Definition: WebClient.h:30