[gnome-games/wip/exalm/platform-preferences: 48/65] retro-core-source: Drop 'mime_types' parameter



commit 757c15e66a88e7f698f50786d3b5fe24bac92b3f
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Wed Sep 26 22:53:19 2018 +0500

    retro-core-source: Drop 'mime_types' parameter
    
    Since RetroPlatform now provides MIME types, RetroCoreSource can use them
    instead of providing its own types.

 plugins/dreamcast/src/dreamcast-plugin.vala           |  2 +-
 plugins/game-cube/src/game-cube-plugin.vala           |  2 +-
 plugins/mame/src/mame-game-uri-adapter.vala           |  5 +----
 plugins/ms-dos/src/ms-dos-plugin.vala                 |  2 +-
 plugins/nintendo-ds/src/nintendo-ds-plugin.vala       |  2 +-
 plugins/playstation/src/playstation-game-factory.vala |  2 +-
 plugins/sega-cd/src/sega-cd-plugin.vala               | 11 +++--------
 plugins/sega-saturn/src/sega-saturn-plugin.vala       |  2 +-
 plugins/turbografx-cd/src/turbografx-cd-plugin.vala   |  2 +-
 plugins/virtual-boy/src/virtual-boy-plugin.vala       |  2 +-
 plugins/wii/src/wii-plugin.vala                       |  2 +-
 src/retro/retro-core-source.vala                      | 15 ++++++++++-----
 src/retro/retro-simple-game-uri-adapter.vala          |  2 +-
 13 files changed, 24 insertions(+), 27 deletions(-)
---
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index ad84d3f4..bcf4c2fe 100644
--- a/plugins/dreamcast/src/dreamcast-plugin.vala
+++ b/plugins/dreamcast/src/dreamcast-plugin.vala
@@ -46,7 +46,7 @@ private class Games.DreamcastPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
-               var core_source = new RetroCoreSource (platform, { MIME_TYPE });
+               var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index 62fbe0a4..eea79684 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -46,7 +46,7 @@ private class Games.GameCubePlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
-               var core_source = new RetroCoreSource (platform, { MIME_TYPE });
+               var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;
diff --git a/plugins/mame/src/mame-game-uri-adapter.vala b/plugins/mame/src/mame-game-uri-adapter.vala
index d1bab433..c831e98e 100644
--- a/plugins/mame/src/mame-game-uri-adapter.vala
+++ b/plugins/mame/src/mame-game-uri-adapter.vala
@@ -1,9 +1,6 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 private class Games.MameGameUriAdapter : GameUriAdapter, Object {
-       private const string SEARCHED_MIME_TYPE = "application/zip";
-       private const string SPECIFIC_MIME_TYPE = "application/x-mame-rom";
-
        private RetroPlatform platform;
 
        public MameGameUriAdapter (RetroPlatform platform) {
@@ -31,7 +28,7 @@ private class Games.MameGameUriAdapter : GameUriAdapter, Object {
 
                var cover = new LocalCover (uri);
                var developer = new GenericDeveloper (info.company);
-               var core_source = new RetroCoreSource (platform, { SEARCHED_MIME_TYPE, SPECIFIC_MIME_TYPE });
+               var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;
diff --git a/plugins/ms-dos/src/ms-dos-plugin.vala b/plugins/ms-dos/src/ms-dos-plugin.vala
index 71bcab8d..10fdd1a3 100644
--- a/plugins/ms-dos/src/ms-dos-plugin.vala
+++ b/plugins/ms-dos/src/ms-dos-plugin.vala
@@ -40,7 +40,7 @@ private class Games.MsDosPlugin : Object, Plugin {
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
 
-               var core_source = new RetroCoreSource (platform, { MIME_TYPE });
+               var core_source = new RetroCoreSource (platform);
                var input_capabilities = new MsDosInputCapabilities ();
 
                var builder = new RetroRunnerBuilder ();
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index 16af6169..2e534d68 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -44,7 +44,7 @@ private class Games.NintendoDsPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var core_source = new RetroCoreSource (platform, { MIME_TYPE });
+               var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index 49fc7df5..cda5f7ba 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -151,7 +151,7 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
                var input_capabilities = new GameinfoDiscIdInputCapabilities (gameinfo, disc_set_id);
-               var core_source = new RetroCoreSource (platform, { CUE_MIME_TYPE, PHONY_MIME_TYPE });
+               var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;
diff --git a/plugins/sega-cd/src/sega-cd-plugin.vala b/plugins/sega-cd/src/sega-cd-plugin.vala
index 497e1429..ae376ff8 100644
--- a/plugins/sega-cd/src/sega-cd-plugin.vala
+++ b/plugins/sega-cd/src/sega-cd-plugin.vala
@@ -63,16 +63,11 @@ private class Games.SegaCDPlugin : Object, Plugin {
                var header = new SegaCDHeader (bin_file);
                header.check_validity ();
 
-               string[] mime_types;
                RetroPlatform platform;
-               if (header.is_sega_cd ()) {
-                       mime_types = { CUE_MIME_TYPE, SEGA_CD_MIME_TYPE };
+               if (header.is_sega_cd ())
                        platform = platform_sega_cd;
-               }
-               else if (header.is_sega_cd_32x ()) {
-                       mime_types = { CUE_MIME_TYPE, SEGA_CD_MIME_TYPE, 32X_MIME_TYPE };
+               else if (header.is_sega_cd_32x ())
                        platform = platform_sega_cd_32x;
-               }
                else
                        assert_not_reached ();
 
@@ -92,7 +87,7 @@ private class Games.SegaCDPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
-               var core_source = new RetroCoreSource (platform, mime_types);
+               var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index f5c705d9..4637d2d2 100644
--- a/plugins/sega-saturn/src/sega-saturn-plugin.vala
+++ b/plugins/sega-saturn/src/sega-saturn-plugin.vala
@@ -70,7 +70,7 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
-               var core_source = new RetroCoreSource (platform, { CUE_MIME_TYPE, SEGA_SATURN_MIME_TYPE });
+               var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;
diff --git a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala 
b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
index 1f81173a..1abe0cc0 100644
--- a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
+++ b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
@@ -50,7 +50,7 @@ private class Games.TurboGrafxCDPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
-               var core_source = new RetroCoreSource (platform, { CUE_MIME_TYPE, PHONY_MIME_TYPE });
+               var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;
diff --git a/plugins/virtual-boy/src/virtual-boy-plugin.vala b/plugins/virtual-boy/src/virtual-boy-plugin.vala
index 55f26cd7..c6ce11c2 100644
--- a/plugins/virtual-boy/src/virtual-boy-plugin.vala
+++ b/plugins/virtual-boy/src/virtual-boy-plugin.vala
@@ -48,7 +48,7 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
-               var core_source = new RetroCoreSource (platform, { MIME_TYPE });
+               var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index 034a5882..3b3b9e6a 100644
--- a/plugins/wii/src/wii-plugin.vala
+++ b/plugins/wii/src/wii-plugin.vala
@@ -46,7 +46,7 @@ private class Games.WiiPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
-               var core_source = new RetroCoreSource (platform, { MIME_TYPE });
+               var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;
diff --git a/src/retro/retro-core-source.vala b/src/retro/retro-core-source.vala
index 2ba9aabe..21d10d2b 100644
--- a/src/retro/retro-core-source.vala
+++ b/src/retro/retro-core-source.vala
@@ -2,14 +2,12 @@
 
 public class Games.RetroCoreSource : Object {
        private RetroPlatform platform;
-       private string[] mime_types;
 
        private Retro.CoreDescriptor core_descriptor;
        private bool searched;
 
-       public RetroCoreSource (RetroPlatform platform, string[] mime_types) {
+       public RetroCoreSource (RetroPlatform platform) {
                this.platform = platform;
-               this.mime_types = mime_types;
                searched = false;
        }
 
@@ -21,8 +19,11 @@ public class Games.RetroCoreSource : Object {
                ensure_module_is_found ();
 
                var module_file = core_descriptor.get_module_file ();
-               if (module_file == null)
+               if (module_file == null) {
+                       var mime_types = platform.get_mime_types ();
+
                        throw new RetroError.MODULE_NOT_FOUND (_("No module found for platform “%s” and MIME 
types [ “%s” ]."), platform.get_id (), string.joinv (_("”, “"), mime_types));
+               }
 
                return module_file.get_path ();
        }
@@ -35,8 +36,11 @@ public class Games.RetroCoreSource : Object {
 
                var platform_id = platform.get_id ();
 
-               if (core_descriptor == null)
+               if (core_descriptor == null) {
+                       var mime_types = platform.get_mime_types ();
+
                        throw new RetroError.MODULE_NOT_FOUND (_("No module found for platform “%s” and MIME 
types [ “%s” ]."), platform_id, string.joinv (_("”, “"), mime_types));
+               }
 
                if (core_descriptor.has_firmwares (platform_id))
                        foreach (var firmware in core_descriptor_get_firmwares (core_descriptor, platform_id))
@@ -48,6 +52,7 @@ public class Games.RetroCoreSource : Object {
                foreach (var core_descriptor in modules) {
                        try {
                                var platform_id = platform.get_id ();
+                               var mime_types = platform.get_mime_types ();
 
                                if (!core_descriptor.get_is_emulator ())
                                        continue;
diff --git a/src/retro/retro-simple-game-uri-adapter.vala b/src/retro/retro-simple-game-uri-adapter.vala
index 1c80d561..2626c84a 100644
--- a/src/retro/retro-simple-game-uri-adapter.vala
+++ b/src/retro/retro-simple-game-uri-adapter.vala
@@ -27,7 +27,7 @@ private class Games.RetroSimpleGameUriAdapter : GameUriAdapter, Object {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
-               var core_source = new RetroCoreSource (platform, { simple_type.mime_type });
+               var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]