From ad6ff6ce99619bb320cc7517768bca603f11a75c Mon Sep 17 00:00:00 2001
From: TSRBerry <20988865+TSRBerry@users.noreply.github.com>
Date: Sun, 22 Jan 2023 18:39:00 +0100
Subject: GUI: Add option to register file types (#4250)

* Add FileAssociationHelper.cs

* Add register file types option to gtk

* Add register file types option to avalonia

* Add Windows support to FileAssociationHelper.cs

* linux: Add uninstall support for file types

* Ignore .glade~ backup files

* Rename Register/Unregister methods

* gtk: Add manage file types submenu

* ava: Add manage file types submenu

* windows: Add uninstall support for file types

* Don't invert uninstall condition (formatting change)

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Add IsTypesRegisteredWindows & Fix Windows install function

* Add AreMimeTypesRegisteredLinux()

* Fix wrong indention

Co-authored-by: AcK77 <acoustik666@gmail.com>
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
---
 Ryujinx.Ava/Program.cs | 50 --------------------------------------------------
 1 file changed, 50 deletions(-)

(limited to 'Ryujinx.Ava/Program.cs')

diff --git a/Ryujinx.Ava/Program.cs b/Ryujinx.Ava/Program.cs
index e64b6921..7f35c62a 100644
--- a/Ryujinx.Ava/Program.cs
+++ b/Ryujinx.Ava/Program.cs
@@ -14,10 +14,8 @@ using Ryujinx.Ui.Common;
 using Ryujinx.Ui.Common.Configuration;
 using Ryujinx.Ui.Common.Helper;
 using System;
-using System.Diagnostics;
 using System.IO;
 using System.Runtime.InteropServices;
-using System.Runtime.Versioning;
 using System.Threading.Tasks;
 
 namespace Ryujinx.Ava
@@ -35,48 +33,6 @@ namespace Ryujinx.Ava
 
         private const uint MB_ICONWARNING = 0x30;
 
-        [SupportedOSPlatform("linux")]
-        static void RegisterMimeTypes()
-        {
-            if (ReleaseInformation.IsFlatHubBuild())
-            {
-                return;
-            }
-
-            string mimeDbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share", "mime");
-
-            if (!File.Exists(Path.Combine(mimeDbPath, "packages", "Ryujinx.xml")))
-            {
-                string mimeTypesFile = Path.Combine(ReleaseInformation.GetBaseApplicationDirectory(), "mime", "Ryujinx.xml");
-                using Process mimeProcess = new();
-
-                mimeProcess.StartInfo.FileName = "xdg-mime";
-                mimeProcess.StartInfo.Arguments = $"install --novendor --mode user {mimeTypesFile}";
-
-                mimeProcess.Start();
-                mimeProcess.WaitForExit();
-
-                if (mimeProcess.ExitCode != 0)
-                {
-                    Logger.Error?.PrintMsg(LogClass.Application, $"Unable to install mime types. Make sure xdg-utils is installed. Process exited with code: {mimeProcess.ExitCode}");
-                    return;
-                }
-
-                using Process updateMimeProcess = new();
-
-                updateMimeProcess.StartInfo.FileName = "update-mime-database";
-                updateMimeProcess.StartInfo.Arguments = mimeDbPath;
-
-                updateMimeProcess.Start();
-                updateMimeProcess.WaitForExit();
-
-                if (updateMimeProcess.ExitCode != 0)
-                {
-                    Logger.Error?.PrintMsg(LogClass.Application, $"Could not update local mime database. Process exited with code: {updateMimeProcess.ExitCode}");
-                }
-            }
-        }
-
         public static void Main(string[] args)
         {
             Version = ReleaseInformation.GetVersion();
@@ -139,12 +95,6 @@ namespace Ryujinx.Ava
             // Initialize the logger system.
             LoggerModule.Initialize();
 
-            // Register mime types on linux.
-            if (OperatingSystem.IsLinux())
-            {
-                RegisterMimeTypes();
-            }
-
             // Initialize Discord integration.
             DiscordIntegrationModule.Initialize();
 
-- 
cgit v1.2.3-70-g09d2