rssguard/src/miscellaneous/systemfactory.h
Martin Rotter cad2fffa87 Save work.
2017-08-21 06:53:16 +02:00

100 lines
2.7 KiB
C++
Executable file

// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
// RSS Guard is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// RSS Guard is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#ifndef SYSTEMFACTORY_H
#define SYSTEMFACTORY_H
#include <QObject>
#include "network-web/downloader.h"
#include <QMetaType>
#include <QHash>
#include <QPair>
#include <QNetworkReply>
class UpdateUrl {
public:
QString m_fileUrl;
QString m_name;
QString m_size;
};
class UpdateInfo {
public:
QString m_availableVersion;
QString m_changes;
QList<UpdateUrl> m_urls;
QDateTime m_date;
};
Q_DECLARE_METATYPE(UpdateInfo)
class SystemFactory : public QObject {
Q_OBJECT
public:
// Specifies possible states of auto-start functionality.
enum class AutoStartStatus {
Enabled,
Disabled,
Unavailable
};
explicit SystemFactory(QObject* parent = nullptr);
virtual ~SystemFactory();
// Returns current status of auto-start function.
SystemFactory::AutoStartStatus autoStartStatus() const;
// Sets new status for auto-start function.
// Function returns false if setting of
// new status failed.
bool setAutoStartStatus(AutoStartStatus new_status);
#if defined(Q_OS_WIN)
bool removeTrolltechJunkRegistryKeys();
#endif
#if defined(Q_OS_LINUX)
// Returns standard location where auto-start .desktop files
// should be placed.
QString autostartDesktopFileLocation() const;
#endif
// Retrieves username of currently logged-in user.
QString loggedInUser() const;
// Tries to download list with new updates.
void checkForUpdates() const;
// Checks if update is newer than current application version.
static bool isVersionNewer(const QString& new_version, const QString& base_version);
static bool isVersionEqualOrNewer(const QString& new_version, const QString& base_version);
static bool openFolderFile(const QString& file_path);
signals:
void updatesChecked(QPair<QList<UpdateInfo>, QNetworkReply::NetworkError> updates) const;
private:
// Performs parsing of downloaded file with list of updates.
QList<UpdateInfo> parseUpdatesFile(const QByteArray& updates_file) const;
};
#endif // SYSTEMFACTORY_H