1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef COMMON_UPDATES_H 24 #define COMMON_UPDATES_H 25 26 #if defined(USE_UPDATES) 27 28 namespace Common { 29 30 /** 31 * The UpdateManager allows configuring of the automatic update checking 32 * for systems that support it: 33 * - using Sparkle on Mac OS X 34 * - using WinSparkle on Windows 35 * 36 * Most of the update checking is completely automated and this class only 37 * gives access to basic settings. It is mostly used by the GUI to set 38 * widgets state on the update page and for manually checking for updates 39 * 40 */ 41 class UpdateManager { 42 public: 43 enum UpdateState { 44 kUpdateStateDisabled = 0, 45 kUpdateStateEnabled = 1, 46 kUpdateStateNotSupported = 2 47 }; 48 49 enum UpdateInterval { 50 kUpdateIntervalNotSupported = 0, 51 kUpdateIntervalOneDay = 86400, 52 kUpdateIntervalOneWeek = 604800, 53 kUpdateIntervalOneMonth = 2628000 // average seconds per month (60*60*24*365)/12 54 }; 55 UpdateManager()56 UpdateManager() {} ~UpdateManager()57 virtual ~UpdateManager() {} 58 59 /** 60 * Checks manually if an update is available, showing progress UI to the user. 61 * 62 * By default, update checks are done silently on start. 63 * This allows to manually start an update check. 64 */ checkForUpdates()65 virtual void checkForUpdates() {} 66 67 /** 68 * Sets the automatic update checking state 69 * 70 * @param state The state. 71 */ setAutomaticallyChecksForUpdates(UpdateState state)72 virtual void setAutomaticallyChecksForUpdates(UpdateState state) {} 73 74 /** 75 * Gets the automatic update checking state 76 * 77 * @return kUpdateStateDisabled if automatic update checking is disabled, 78 * kUpdateStateEnabled if automatic update checking is enabled, 79 * kUpdateStateNotSupported if automatic update checking is not available 80 */ getAutomaticallyChecksForUpdates()81 virtual UpdateState getAutomaticallyChecksForUpdates() { return kUpdateStateNotSupported; } 82 83 /** 84 * Sets the update checking interval. 85 * 86 * @param interval The interval. 87 */ setUpdateCheckInterval(int interval)88 virtual void setUpdateCheckInterval(int interval) {} 89 90 /** 91 * Gets the update check interval. 92 * 93 * @return the update check interval. 94 */ getUpdateCheckInterval()95 virtual int getUpdateCheckInterval() { return kUpdateIntervalNotSupported; } 96 97 /** 98 * Gets last update check time 99 * 100 * @param t TimeDate struct to fill out 101 * @return flag indicating success 102 */ getLastUpdateCheckTimeAndDate(TimeDate & t)103 virtual bool getLastUpdateCheckTimeAndDate(TimeDate &t) { return false; } 104 105 /** 106 * Returns list of supported uptate intervals. 107 * Ending with '-1' which is not acceptable value. 108 * 109 * @return list of integer values representing update intervals in seconds. 110 */ 111 static const int *getUpdateIntervals(); 112 113 /** 114 * Returns string representation of a given interval. 115 * 116 * @param interval The interval. 117 * @return pointer to localized string of given interval. 118 */ 119 static const char *updateIntervalToString(int interval); 120 121 /** 122 * Rounds up the given interval to acceptable value. 123 * 124 * @param interval The interval. 125 * @return rounded up interval 126 */ 127 static int normalizeInterval(int interval); 128 }; 129 130 } // End of namespace Common 131 132 #endif 133 134 #endif // COMMON_UPDATES_H 135