Debian Codegraph @

src/GUI/UpdateChecker.hxx

raw symbols SCIP
1 // Written by James Turner, started October 2020
2 //
3 // Copyright (C) 2020 James Turner <[email protected]>
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
29 class 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)
36 public:
37 explicit UpdateChecker(QObject *parent = nullptr);
38 ~UpdateChecker();
39
40 enum Status {
41 NoUpdate,
42 PointUpdate,
43 MajorUpdate
44 };
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
64 signals:
65
66 void statusChanged(Status status);
67
68 public slots:
69 void ignoreUpdate();
70
71 private slots:
72 void receivedUpdateXML(QByteArray body);
73
74 private:
75 std::string _majorMinorVersion; ///< version without patch level
76
77 QString _currentUpdateVersion;
78
79 Status m_status = NoUpdate;
80 QUrl m_updateUri;
81
82 simgear::HTTP::Request_ptr m_request;
83 };
84