ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

win32-updates.cpp

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 // Disable symbol overrides so that we can use system headers.
00024 #define FORBIDDEN_SYMBOL_ALLOW_ALL
00025 
00026 #include "common/system.h"
00027 #include "backends/updates/win32/win32-updates.h"
00028 
00029 #ifdef USE_SPARKLE
00030 #include "common/translation.h"
00031 #include "common/config-manager.h"
00032 
00033 #include <time.h>
00034 #include <winsparkle.h>
00035 
00053 Win32UpdateManager::Win32UpdateManager() {
00054     const char *appcastUrl = "https://www.residualvm.org/appcasts/macosx/release.xml";
00055 
00056     win_sparkle_set_appcast_url(appcastUrl);
00057     win_sparkle_init();
00058 
00059     if (!ConfMan.hasKey("updates_check")
00060       || ConfMan.getInt("updates_check") == Common::UpdateManager::kUpdateIntervalNotSupported) {
00061         setAutomaticallyChecksForUpdates(kUpdateStateDisabled);
00062     } else {
00063         setAutomaticallyChecksForUpdates(kUpdateStateEnabled);
00064         setUpdateCheckInterval(normalizeInterval(ConfMan.getInt("updates_check")));
00065     }
00066 }
00067 
00068 Win32UpdateManager::~Win32UpdateManager() {
00069     win_sparkle_cleanup();
00070 }
00071 
00072 void Win32UpdateManager::checkForUpdates() {
00073     win_sparkle_check_update_with_ui();
00074 }
00075 
00076 void Win32UpdateManager::setAutomaticallyChecksForUpdates(UpdateManager::UpdateState state) {
00077     if (state == kUpdateStateNotSupported)
00078         return;
00079 
00080     win_sparkle_set_automatic_check_for_updates(state == kUpdateStateEnabled ? 1 : 0);
00081 }
00082 
00083 Common::UpdateManager::UpdateState Win32UpdateManager::getAutomaticallyChecksForUpdates() {
00084     if (win_sparkle_get_automatic_check_for_updates() == 1)
00085         return kUpdateStateEnabled;
00086     else
00087         return kUpdateStateDisabled;
00088 }
00089 
00090 void Win32UpdateManager::setUpdateCheckInterval(int interval) {
00091     if (interval == kUpdateIntervalNotSupported)
00092         return;
00093 
00094     interval = normalizeInterval(interval);
00095 
00096     win_sparkle_set_update_check_interval(interval);
00097 }
00098 
00099 int Win32UpdateManager::getUpdateCheckInterval() {
00100     // This is kind of a hack but necessary, as the value stored by Sparkle
00101     // might have been changed outside of ScummVM (in which case we return the
00102     // default interval of one day)
00103 
00104     int updateInterval = win_sparkle_get_update_check_interval();
00105     switch (updateInterval) {
00106     case kUpdateIntervalOneDay:
00107     case kUpdateIntervalOneWeek:
00108     case kUpdateIntervalOneMonth:
00109         return updateInterval;
00110 
00111     default:
00112         // Return the default value (one day)
00113         return kUpdateIntervalOneDay;
00114     }
00115 }
00116 
00117 bool Win32UpdateManager::getLastUpdateCheckTimeAndDate(TimeDate &t) {
00118     time_t updateTime = win_sparkle_get_last_check_time();
00119     tm *ut = localtime(&updateTime);
00120 
00121     t.tm_wday = ut->tm_wday;
00122     t.tm_year = ut->tm_year;
00123     t.tm_mon  = ut->tm_mon;
00124     t.tm_mday = ut->tm_mday;
00125     t.tm_hour = ut->tm_hour;
00126     t.tm_min  = ut->tm_min;
00127     t.tm_sec  = ut->tm_sec;
00128 
00129     return true;
00130 }
00131 
00132 #endif


Generated on Sat Jun 15 2019 05:01:06 for ResidualVM by doxygen 1.7.1
curved edge   curved edge