public static bool CanUpdate(bool showWarnings) { if (RuntimeInformation.OSArchitecture != Architecture.X64) { if (showWarnings) { GtkDialog.CreateWarningDialog("You are not running a supported system architecture!", "(Only x64 systems are supported!)"); } return(false); } if (!NetworkInterface.GetIsNetworkAvailable()) { if (showWarnings) { GtkDialog.CreateWarningDialog("You are not connected to the Internet!", "Please verify that you have a working Internet connection!"); } return(false); } if (Program.Version.Contains("dirty")) { if (showWarnings) { GtkDialog.CreateWarningDialog("You Cannot update a Dirty build of Ryujinx!", "Please download Ryujinx at https://ryujinx.org/ if you are looking for a supported version."); } return(false); } return(true); }
static void Main(string[] args) { Console.Title = "Ryujinx Console"; string systemPath = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine); Environment.SetEnvironmentVariable("Path", $"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin")};{systemPath}"); GLib.ExceptionManager.UnhandledException += Glib_UnhandledException; // Initialize the configuration ConfigurationState.Initialize(); // Initialize the logger system LoggerModule.Initialize(); // Initialize Discord integration DiscordIntegrationModule.Initialize(); string configurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"); // Now load the configuration as the other subsystems are now registered if (File.Exists(configurationPath)) { ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(configurationPath); ConfigurationState.Instance.Load(configurationFileFormat); } else { // No configuration, we load the default values and save it on disk ConfigurationState.Instance.LoadDefault(); ConfigurationState.Instance.ToFileFormat().SaveConfig(configurationPath); } Profile.Initialize(); Application.Init(); string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx", "system", "prod.keys"); string userProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch", "prod.keys"); if (!File.Exists(appDataPath) && !File.Exists(userProfilePath) && !Migration.IsMigrationNeeded()) { GtkDialog.CreateWarningDialog("Key file was not found", "Please refer to `KEYS.md` for more info"); } MainWindow mainWindow = new MainWindow(); mainWindow.Show(); if (args.Length == 1) { mainWindow.LoadApplication(args[0]); } Application.Run(); }
public static bool CanUpdate(bool showWarnings) { #if !DISABLE_UPDATER if (RuntimeInformation.OSArchitecture != Architecture.X64) { if (showWarnings) { GtkDialog.CreateWarningDialog("You are not running a supported system architecture!", "(Only x64 systems are supported!)"); } return(false); } if (!NetworkInterface.GetIsNetworkAvailable()) { if (showWarnings) { GtkDialog.CreateWarningDialog("You are not connected to the Internet!", "Please verify that you have a working Internet connection!"); } return(false); } if (AppDataManager.Mode == AppDataManager.LaunchMode.Portable) { if (showWarnings) { GtkDialog.CreateWarningDialog("You cannot update a portable version of Ryujinx!", "Please use a non-portable configuration to enable updates."); } return(false); } if (Program.Version.Contains("dirty")) { if (showWarnings) { GtkDialog.CreateWarningDialog("You cannot update a Dirty build of Ryujinx!", "Please download Ryujinx at https://ryujinx.org/ if you are looking for a supported version."); } return(false); } return(true); #else if (showWarnings) { GtkDialog.CreateWarningDialog("Updater Disabled!", "Please download Ryujinx at https://ryujinx.org/ if you are looking for a supported version."); } return(false); #endif }
public static bool CanUpdate(bool showWarnings) { #if !DISABLE_UPDATER if (RuntimeInformation.OSArchitecture != Architecture.X64) { if (showWarnings) { GtkDialog.CreateWarningDialog("You are not running a supported system architecture!", "(Only x64 systems are supported!)"); } return(false); } if (!NetworkInterface.GetIsNetworkAvailable()) { if (showWarnings) { GtkDialog.CreateWarningDialog("You are not connected to the Internet!", "Please verify that you have a working Internet connection!"); } return(false); } if (Program.Version.Contains("dirty") || !ReleaseInformations.IsValid()) { if (showWarnings) { GtkDialog.CreateWarningDialog("You cannot update a Dirty build of Ryujinx!", "Please download Ryujinx at https://ryujinx.org/ if you are looking for a supported version."); } return(false); } return(true); #else if (showWarnings) { if (ReleaseInformations.IsFlatHubBuild()) { GtkDialog.CreateWarningDialog("Updater Disabled!", "Please update Ryujinx via FlatHub."); } else { GtkDialog.CreateWarningDialog("Updater Disabled!", "Please download Ryujinx at https://ryujinx.org/ if you are looking for a supported version."); } } return(false); #endif }
public static async Task BeginParse(MainWindow mainWindow, bool showVersionUpToDate) { if (Running) { return; } Running = true; mainWindow.UpdateMenuItem.Sensitive = false; int artifactIndex = -1; // Detect current platform if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { _platformExt = "osx_x64.zip"; artifactIndex = 1; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _platformExt = "win_x64.zip"; artifactIndex = 2; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { _platformExt = "linux_x64.tar.gz"; artifactIndex = 0; } if (artifactIndex == -1) { GtkDialog.CreateErrorDialog("Your platform is not supported!"); return; } Version newVersion; Version currentVersion; try { currentVersion = Version.Parse(Program.Version); } catch { GtkDialog.CreateWarningDialog("Failed to convert the current Ryujinx version.", "Cancelling Update!"); Logger.Error?.Print(LogClass.Application, "Failed to convert the current Ryujinx version!"); return; } // Get latest version number from Appveyor try { using (WebClient jsonClient = new WebClient()) { // Fetch latest build information string fetchedJson = await jsonClient.DownloadStringTaskAsync($"{AppveyorApiUrl}/projects/gdkchan/ryujinx/branch/master"); JObject jsonRoot = JObject.Parse(fetchedJson); JToken buildToken = jsonRoot["build"]; _jobId = (string)buildToken["jobs"][0]["jobId"]; _buildVer = (string)buildToken["version"]; _buildUrl = $"{AppveyorApiUrl}/buildjobs/{_jobId}/artifacts/ryujinx-{_buildVer}-{_platformExt}"; // If build not done, assume no new update are availaible. if ((string)buildToken["jobs"][0]["status"] != "success") { if (showVersionUpToDate) { GtkDialog.CreateUpdaterInfoDialog("You are already using the latest version of Ryujinx!", ""); } return; } } } catch (Exception exception) { Logger.Error?.Print(LogClass.Application, exception.Message); GtkDialog.CreateErrorDialog("An error has occurred when trying to get release information from AppVeyor."); return; } try { newVersion = Version.Parse(_buildVer); } catch { GtkDialog.CreateWarningDialog("Failed to convert the received Ryujinx version from AppVeyor.", "Cancelling Update!"); Logger.Error?.Print(LogClass.Application, "Failed to convert the received Ryujinx version from AppVeyor!"); return; } if (newVersion <= currentVersion) { if (showVersionUpToDate) { GtkDialog.CreateUpdaterInfoDialog("You are already using the latest version of Ryujinx!", ""); } Running = false; mainWindow.UpdateMenuItem.Sensitive = true; return; } // Fetch build size information to learn chunk sizes. using (WebClient buildSizeClient = new WebClient()) { try { buildSizeClient.Headers.Add("Range", "bytes=0-0"); await buildSizeClient.DownloadDataTaskAsync(new Uri(_buildUrl)); string contentRange = buildSizeClient.ResponseHeaders["Content-Range"]; _buildSize = long.Parse(contentRange.Substring(contentRange.IndexOf('/') + 1)); } catch (Exception ex) { Logger.Warning?.Print(LogClass.Application, ex.Message); Logger.Warning?.Print(LogClass.Application, "Couldn't determine build size for update, will use single-threaded updater"); _buildSize = -1; } } // Show a message asking the user if they want to update UpdateDialog updateDialog = new UpdateDialog(mainWindow, newVersion, _buildUrl); updateDialog.Show(); }
static void Main(string[] args) { Toolkit.Init(new ToolkitOptions { Backend = PlatformBackend.PreferNative, EnableHighResolution = true }); Version = Assembly.GetEntryAssembly().GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion; Console.Title = $"Ryujinx Console {Version}"; string systemPath = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine); Environment.SetEnvironmentVariable("Path", $"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin")};{systemPath}"); GLib.ExceptionManager.UnhandledException += Glib_UnhandledException; // Initialize the configuration ConfigurationState.Initialize(); // Initialize the logger system LoggerModule.Initialize(); // Initialize Discord integration DiscordIntegrationModule.Initialize(); string localConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"); string globalBasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx"); string globalConfigurationPath = Path.Combine(globalBasePath, "Config.json"); // Now load the configuration as the other subsystems are now registered if (File.Exists(localConfigurationPath)) { ConfigurationPath = localConfigurationPath; ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(localConfigurationPath); ConfigurationState.Instance.Load(configurationFileFormat, ConfigurationPath); } else if (File.Exists(globalConfigurationPath)) { ConfigurationPath = globalConfigurationPath; ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(globalConfigurationPath); ConfigurationState.Instance.Load(configurationFileFormat, ConfigurationPath); } else { // No configuration, we load the default values and save it on disk ConfigurationPath = globalConfigurationPath; // Make sure to create the Ryujinx directory if needed. Directory.CreateDirectory(globalBasePath); ConfigurationState.Instance.LoadDefault(); ConfigurationState.Instance.ToFileFormat().SaveConfig(globalConfigurationPath); } Logger.PrintInfo(LogClass.Application, $"Ryujinx Version: {Version}"); Logger.PrintInfo(LogClass.Application, $"Operating System: {SystemInfo.Instance.OsDescription}"); Logger.PrintInfo(LogClass.Application, $"CPU: {SystemInfo.Instance.CpuName}"); Logger.PrintInfo(LogClass.Application, $"Total RAM: {SystemInfo.Instance.RamSizeInMB}"); Profile.Initialize(); Application.Init(); string globalProdKeysPath = Path.Combine(globalBasePath, "system", "prod.keys"); string userProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch", "prod.keys"); if (!File.Exists(globalProdKeysPath) && !File.Exists(userProfilePath) && !Migration.IsMigrationNeeded()) { GtkDialog.CreateWarningDialog("Key file was not found", "Please refer to `KEYS.md` for more info"); } MainWindow mainWindow = new MainWindow(); mainWindow.Show(); if (args.Length == 1) { mainWindow.LoadApplication(args[0]); } Application.Run(); }
public static async Task BeginParse(MainWindow mainWindow, bool showVersionUpToDate) { if (Running) { return; } Running = true; mainWindow.UpdateMenuItem.Sensitive = false; // Detect current platform if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { _platformExt = "osx_x64.zip"; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _platformExt = "win_x64.zip"; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { _platformExt = "linux_x64.tar.gz"; } Version newVersion; Version currentVersion; try { currentVersion = Version.Parse(Program.Version); } catch { GtkDialog.CreateWarningDialog("Failed to convert the current Ryujinx version.", "Cancelling Update!"); Logger.Error?.Print(LogClass.Application, "Failed to convert the current Ryujinx version!"); return; } // Get latest version number from Appveyor try { using (WebClient jsonClient = new WebClient()) { string fetchedJson = await jsonClient.DownloadStringTaskAsync($"{AppveyorApiUrl}/projects/gdkchan/ryujinx/branch/master"); JObject jsonRoot = JObject.Parse(fetchedJson); JToken buildToken = jsonRoot["build"]; _jobId = (string)buildToken["jobs"][0]["jobId"]; _buildVer = (string)buildToken["version"]; _buildUrl = $"{AppveyorApiUrl}/buildjobs/{_jobId}/artifacts/ryujinx-{_buildVer}-{_platformExt}"; // If build not done, assume no new update are availaible. if ((string)buildToken["jobs"][0]["status"] != "success") { if (showVersionUpToDate) { GtkDialog.CreateInfoDialog("Ryujinx - Updater", "You are already using the most updated version of Ryujinx!", ""); } return; } } } catch (Exception exception) { Logger.Error?.Print(LogClass.Application, exception.Message); GtkDialog.CreateErrorDialog("An error has occurred when trying to get release information from AppVeyor."); return; } try { newVersion = Version.Parse(_buildVer); } catch { GtkDialog.CreateWarningDialog("Failed to convert the received Ryujinx version from AppVeyor.", "Cancelling Update!"); Logger.Error?.Print(LogClass.Application, "Failed to convert the received Ryujinx version from AppVeyor!"); return; } if (newVersion <= currentVersion) { if (showVersionUpToDate) { GtkDialog.CreateInfoDialog("Ryujinx - Updater", "You are already using the most updated version of Ryujinx!", ""); } Running = false; mainWindow.UpdateMenuItem.Sensitive = true; return; } // Show a message asking the user if they want to update UpdateDialog updateDialog = new UpdateDialog(mainWindow, newVersion, _buildUrl); updateDialog.Show(); }
public static async Task BeginParse(MainWindow mainWindow, bool showVersionUpToDate) { if (Running) { return; } Running = true; mainWindow.UpdateMenuItem.Sensitive = false; int artifactIndex = -1; // Detect current platform if (OperatingSystem.IsMacOS()) { _platformExt = "osx_x64.zip"; artifactIndex = 1; } else if (OperatingSystem.IsWindows()) { _platformExt = "win_x64.zip"; artifactIndex = 2; } else if (OperatingSystem.IsLinux()) { _platformExt = "linux_x64.tar.gz"; artifactIndex = 0; } if (artifactIndex == -1) { GtkDialog.CreateErrorDialog("Your platform is not supported!"); return; } Version newVersion; Version currentVersion; try { currentVersion = Version.Parse(Program.Version); } catch { GtkDialog.CreateWarningDialog("Failed to convert the current Ryujinx version.", "Cancelling Update!"); Logger.Error?.Print(LogClass.Application, "Failed to convert the current Ryujinx version!"); return; } // Get latest version number from Appveyor try { using (HttpClient jsonClient = new HttpClient()) { // Fetch latest build information string fetchedJson = await jsonClient.GetStringAsync($"{AppveyorApiUrl}/projects/gdkchan/ryujinx/branch/master"); JObject jsonRoot = JObject.Parse(fetchedJson); JToken buildToken = jsonRoot["build"]; _jobId = (string)buildToken["jobs"][0]["jobId"]; _buildVer = (string)buildToken["version"]; _buildUrl = $"{AppveyorApiUrl}/buildjobs/{_jobId}/artifacts/ryujinx-{_buildVer}-{_platformExt}"; // If build not done, assume no new update are availaible. if ((string)buildToken["jobs"][0]["status"] != "success") { if (showVersionUpToDate) { GtkDialog.CreateUpdaterInfoDialog("You are already using the latest version of Ryujinx!", ""); } return; } } } catch (Exception exception) { Logger.Error?.Print(LogClass.Application, exception.Message); GtkDialog.CreateErrorDialog("An error occurred when trying to get release information from AppVeyor. This can be caused if a new release is being compiled by AppVeyor. Try again in a few minutes."); return; } try { newVersion = Version.Parse(_buildVer); } catch { GtkDialog.CreateWarningDialog("Failed to convert the received Ryujinx version from AppVeyor.", "Cancelling Update!"); Logger.Error?.Print(LogClass.Application, "Failed to convert the received Ryujinx version from AppVeyor!"); return; } if (newVersion <= currentVersion) { if (showVersionUpToDate) { GtkDialog.CreateUpdaterInfoDialog("You are already using the latest version of Ryujinx!", ""); } Running = false; mainWindow.UpdateMenuItem.Sensitive = true; return; } // Fetch build size information to learn chunk sizes. using (HttpClient buildSizeClient = new HttpClient()) { try { buildSizeClient.DefaultRequestHeaders.Add("Range", "bytes=0-0"); HttpResponseMessage message = await buildSizeClient.GetAsync(new Uri(_buildUrl), HttpCompletionOption.ResponseHeadersRead); _buildSize = message.Content.Headers.ContentRange.Length.Value; } catch (Exception ex) { Logger.Warning?.Print(LogClass.Application, ex.Message); Logger.Warning?.Print(LogClass.Application, "Couldn't determine build size for update, using single-threaded updater"); _buildSize = -1; } } // Show a message asking the user if they want to update UpdateDialog updateDialog = new UpdateDialog(mainWindow, newVersion, _buildUrl); updateDialog.Show(); }
public static async Task BeginParse(MainWindow mainWindow, bool showVersionUpToDate) { if (Running) { return; } Running = true; mainWindow.UpdateMenuItem.Sensitive = false; int artifactIndex = -1; // Detect current platform if (OperatingSystem.IsMacOS()) { _platformExt = "osx_x64.zip"; artifactIndex = 1; } else if (OperatingSystem.IsWindows()) { _platformExt = "win_x64.zip"; artifactIndex = 2; } else if (OperatingSystem.IsLinux()) { _platformExt = "linux_x64.tar.gz"; artifactIndex = 0; } if (artifactIndex == -1) { GtkDialog.CreateErrorDialog("Your platform is not supported!"); return; } Version newVersion; Version currentVersion; try { currentVersion = Version.Parse(Program.Version); } catch { GtkDialog.CreateWarningDialog("Failed to convert the current Ryujinx version.", "Cancelling Update!"); Logger.Error?.Print(LogClass.Application, "Failed to convert the current Ryujinx version!"); return; } // Get latest version number from GitHub API try { using (HttpClient jsonClient = ConstructHttpClient()) { string buildInfoURL = $"{GitHubApiURL}/repos/{ReleaseInformations.ReleaseChannelOwner}/{ReleaseInformations.ReleaseChannelRepo}/releases/latest"; // Fetch latest build information string fetchedJson = await jsonClient.GetStringAsync(buildInfoURL); JObject jsonRoot = JObject.Parse(fetchedJson); JToken assets = jsonRoot["assets"]; _buildVer = (string)jsonRoot["name"]; foreach (JToken asset in assets) { string assetName = (string)asset["name"]; string assetState = (string)asset["state"]; string downloadURL = (string)asset["browser_download_url"]; if (!assetName.StartsWith("ryujinx-headless-sdl2") && assetName.EndsWith(_platformExt)) { _buildUrl = downloadURL; if (assetState != "uploaded") { if (showVersionUpToDate) { GtkDialog.CreateUpdaterInfoDialog("You are already using the latest version of Ryujinx!", ""); } return; } break; } } if (_buildUrl == null) { if (showVersionUpToDate) { GtkDialog.CreateUpdaterInfoDialog("You are already using the latest version of Ryujinx!", ""); } return; } } } catch (Exception exception) { Logger.Error?.Print(LogClass.Application, exception.Message); GtkDialog.CreateErrorDialog("An error occurred when trying to get release information from GitHub Release. This can be caused if a new release is being compiled by GitHub Actions. Try again in a few minutes."); return; } try { newVersion = Version.Parse(_buildVer); } catch { GtkDialog.CreateWarningDialog("Failed to convert the received Ryujinx version from GitHub Release.", "Cancelling Update!"); Logger.Error?.Print(LogClass.Application, "Failed to convert the received Ryujinx version from GitHub Release!"); return; } if (newVersion <= currentVersion) { if (showVersionUpToDate) { GtkDialog.CreateUpdaterInfoDialog("You are already using the latest version of Ryujinx!", ""); } Running = false; mainWindow.UpdateMenuItem.Sensitive = true; return; } // Fetch build size information to learn chunk sizes. using (HttpClient buildSizeClient = ConstructHttpClient()) { try { buildSizeClient.DefaultRequestHeaders.Add("Range", "bytes=0-0"); HttpResponseMessage message = await buildSizeClient.GetAsync(new Uri(_buildUrl), HttpCompletionOption.ResponseHeadersRead); _buildSize = message.Content.Headers.ContentRange.Length.Value; } catch (Exception ex) { Logger.Warning?.Print(LogClass.Application, ex.Message); Logger.Warning?.Print(LogClass.Application, "Couldn't determine build size for update, using single-threaded updater"); _buildSize = -1; } } // Show a message asking the user if they want to update UpdateDialog updateDialog = new UpdateDialog(mainWindow, newVersion, _buildUrl); updateDialog.Show(); }