FlightGear next
UpdateChecker.hxx
Go to the documentation of this file.
1// Written by James Turner, started October 2020
2//
3// Copyright (C) 2020 James Turner <james@flightgear.org>
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License as
7// published by the Free Software Foundation; either version 2 of the
8// License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful, but
11// WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19#pragma once
20
21#include <string>
22
23#include <QObject>
24#include <QByteArray>
25#include <QUrl>
26
27#include <simgear/io/HTTPRequest.hxx>
28
29class UpdateChecker : public QObject
30{
31 Q_OBJECT
32
33 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
34 Q_PROPERTY(QUrl updateUri READ updateUri NOTIFY statusChanged)
35 Q_PROPERTY(QString updateVersion READ updateVersion NOTIFY statusChanged)
36public:
37 explicit UpdateChecker(QObject *parent = nullptr);
39
45
46 Q_ENUMS(Status)
47
48
49 Status status() const
50 {
51 return m_status;
52 }
53
54 QUrl updateUri() const
55 {
56 return m_updateUri;
57 }
58
59 QString updateVersion() const
60 {
61 return _currentUpdateVersion;
62 }
63
64signals:
65
67
68public slots:
69 void ignoreUpdate();
70
71private slots:
72 void receivedUpdateXML(QByteArray body);
73
74private:
75 std::string _majorMinorVersion;
76
77 QString _currentUpdateVersion;
78
79 Status m_status = NoUpdate;
80 QUrl m_updateUri;
81
82 simgear::HTTP::Request_ptr m_request;
83};
84
QString updateVersion
UpdateChecker(QObject *parent=nullptr)
QUrl updateUri() const
void statusChanged(Status status)
QString updateVersion() const