Debian Codegraph @

src/librssguard/miscellaneous/systemfactory.h

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #ifndef SYSTEMFACTORY_H
4 #define SYSTEMFACTORY_H
5
6 #include "network-web/downloader.h"
7
8 #include <QHash>
9 #include <QMetaType>
10 #include <QNetworkReply>
11 #include <QObject>
12 #include <QPair>
13 #include <QRegularExpression>
14
15 class RSSGUARD_DLLSPEC UpdateUrl {
16 public:
17 QString m_fileUrl;
18 QString m_name;
19 QString m_size;
20 };
21
22 class RSSGUARD_DLLSPEC UpdateInfo {
23 public:
24 QString m_availableVersion;
25 QString m_changes;
26 QDateTime m_date;
27 QList<UpdateUrl> m_urls;
28 };
29
30 Q_DECLARE_METATYPE(UpdateInfo)
31
32 class RSSGUARD_DLLSPEC SystemFactory : public QObject {
33 Q_OBJECT
34
35 public:
36 // Specifies possible states of auto-start functionality.
37 enum class AutoStartStatus {
38 Enabled,
39 Disabled,
40 Unavailable
41 };
42
43 explicit SystemFactory(QObject* parent = nullptr);
44 virtual ~SystemFactory();
45
46 // Returns current status of auto-start function.
47 SystemFactory::AutoStartStatus autoStartStatus() const;
48
49 // Sets new status for auto-start function.
50 // Function returns false if setting of
51 // new status failed.
52 bool setAutoStartStatus(AutoStartStatus new_status);
53
54 #if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
55 // Returns standard location where auto-start .desktop files
56 // should be placed.
57 QString autostartDesktopFileLocation() const;
58 #endif
59
60 // Retrieves username of currently logged-in user.
61 QString loggedInUser() const;
62
63 // Tries to download list with new updates.
64 void checkForUpdates() const;
65
66 public slots:
67 void checkForUpdatesOnStartup();
68
69 static QRegularExpression supportedUpdateFiles();
70
71 // Checks if update is newer than current application version.
72 static bool isVersionNewer(const QString& new_version, const QString& base_version);
73 static bool isVersionEqualOrNewer(const QString& new_version, const QString& base_version);
74 static bool openFolderFile(const QString& file_path);
75
76 signals:
77 void updatesChecked(QPair<QList<UpdateInfo>, QNetworkReply::NetworkError> updates) const;
78
79 private:
80 // Performs parsing of downloaded file with list of updates.
81 QList<UpdateInfo> parseUpdatesFile(const QByteArray& updates_file) const;
82 };
83
84 #endif // SYSTEMFACTORY_H