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



commit e616d202c9cc64513768f6f353e1cca0d2958aa4
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/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 +-
 12 files changed, 23 insertions(+), 26 deletions(-)
---
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index 55caba10..f74e8b98 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 runner = new RetroRunner (core_source, uri, uid, title);
 
                var game = new GenericGame (uid, title, platform, runner);
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index 71e3bd6f..8c303730 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 runner = new RetroRunner (core_source, uri, uid, title);
 
                var game = new GenericGame (uid, title, platform, runner);
diff --git a/plugins/mame/src/mame-game-uri-adapter.vala b/plugins/mame/src/mame-game-uri-adapter.vala
index 18232c0d..a3c47022 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 runner = new RetroRunner (core_source, uri, uid, title);
 
                Idle.add (this.game_for_uri.callback);
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index 5183d7f6..0dc58a2e 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 runner = new RetroRunner (core_source, uri, uid, title);
 
                var game = new GenericGame (uid, title, platform, runner);
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index c977feba..cc5750d9 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 runner = new RetroRunner.for_media_set_and_input_capabilities (core_source, media_set, 
uid, input_capabilities, title);
 
                var game = new GenericGame (uid, title, platform, runner);
diff --git a/plugins/sega-cd/src/sega-cd-plugin.vala b/plugins/sega-cd/src/sega-cd-plugin.vala
index b25a5567..646bef77 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 runner = new RetroRunner (core_source, uri, uid, title);
 
                var game = new GenericGame (uid, title, platform, runner);
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index 4f1217b7..d19dcd21 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 runner = new RetroRunner (core_source, uri, uid, title);
 
                var game = new GenericGame (uid, title, platform, runner);
diff --git a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala 
b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
index c571cb54..ee329934 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 runner = new RetroRunner (core_source, uri, uid, title);
 
                var game = new GenericGame (uid, title, platform, runner);
diff --git a/plugins/virtual-boy/src/virtual-boy-plugin.vala b/plugins/virtual-boy/src/virtual-boy-plugin.vala
index e614e0f0..2f91d37c 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 runner = new RetroRunner (core_source, uri, uid, title);
 
                var game = new GenericGame (uid, title, platform, runner);
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index 96f94f37..77aec31f 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 runner = new RetroRunner (core_source, uri, uid, title);
 
                var game = new GenericGame (uid, title, platform, runner);
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 1ac8a890..590e7bc0 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 runner = new RetroRunner (core_source, uri, uid, title);
 
                var game = new GenericGame (uid, title, platform, runner);


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