aboutsummaryrefslogtreecommitdiff
path: root/launcher/updater/ExternalUpdater.h
blob: daa5b109530971d781a3ca4832e3d877c5de5954 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// SPDX-License-Identifier: GPL-3.0-only
/*
 *  Prism Launcher - Minecraft Launcher
 *  Copyright (C) 2022 Kenneth Chew <kenneth.c0@protonmail.com>
 *
 *  This program 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, version 3.
 *
 *  This program 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 this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef LAUNCHER_EXTERNALUPDATER_H
#define LAUNCHER_EXTERNALUPDATER_H

#include <QObject>

/*!
 * A base class for an updater that uses an external library.
 * This class contains basic functions to control the updater.
 *
 * To implement the updater on a new platform, create a new class that inherits from this class and
 * implement the pure virtual functions.
 *
 * The initializer of the new class should have the side effect of starting the automatic updater. That is,
 * once the class is initialized, the program should automatically check for updates if necessary.
 */
class ExternalUpdater : public QObject {
    Q_OBJECT

   public:
    /*!
     * Check for updates manually, showing the user a progress bar and an alert if no updates are found.
     */
    virtual void checkForUpdates() = 0;

    /*!
     * Indicates whether or not to check for updates automatically.
     */
    virtual bool getAutomaticallyChecksForUpdates() = 0;

    /*!
     * Indicates the current automatic update check interval in seconds.
     */
    virtual double getUpdateCheckInterval() = 0;

    /*!
     * Indicates whether or not beta updates should be checked for in addition to regular releases.
     */
    virtual bool getBetaAllowed() = 0;

    /*!
     * Set whether or not to check for updates automatically.
     */
    virtual void setAutomaticallyChecksForUpdates(bool check) = 0;

    /*!
     * Set the current automatic update check interval in seconds.
     */
    virtual void setUpdateCheckInterval(double seconds) = 0;

    /*!
     * Set whether or not beta updates should be checked for in addition to regular releases.
     */
    virtual void setBetaAllowed(bool allowed) = 0;

   signals:
    /*!
     * Emits whenever the user's ability to check for updates changes.
     *
     * As per Sparkle documentation, "An update check can be made by the user when an update session isn’t in progress,
     * or when an update or its progress is being shown to the user. A user cannot check for updates when data (such
     * as the feed or an update) is still being downloaded automatically in the background.
     *
     * This property is suitable to use for menu item validation for seeing if checkForUpdates can be invoked."
     */
    void canCheckForUpdatesChanged(bool canCheck);
};

#endif  // LAUNCHER_EXTERNALUPDATER_H