[gnome-games] Use RetroCoreSource



commit 6bdd19d6ca1a66ae6e604accacf79bb7b2031904
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun Dec 4 15:38:42 2016 +0100

    Use RetroCoreSource
    
    Use RetroCoreSource in the plugins and in RetroRunner.
    
    This allows to use the Libretro Core Descriptor format for Games instead
    of the previously used core descriptor format.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=778446

 plugins/amiga/src/amiga-plugin.vala                |    6 +-
 plugins/atari-2600/src/atari-2600-plugin.vala      |    6 +-
 plugins/atari-7800/src/atari-7800-plugin.vala      |    6 +-
 plugins/doom/src/doom-plugin.vala                  |    6 +-
 plugins/dreamcast/src/dreamcast-plugin.vala        |    6 +-
 .../src/game-boy-advance-plugin.vala               |    6 +-
 plugins/game-boy/src/game-boy-plugin.vala          |   11 +++--
 plugins/game-cube/src/game-cube-plugin.vala        |    6 +-
 plugins/mame/src/mame-game-uri-adapter.vala        |    6 +-
 .../master-system/src/master-system-plugin.vala    |   15 ++++--
 plugins/mega-drive/src/mega-drive-plugin.vala      |   27 ++++++++---
 .../neo-geo-pocket/src/neo-geo-pocket-plugin.vala  |    6 +-
 plugins/nes/src/nes-plugin.vala                    |    8 +++-
 plugins/nintendo-64/src/nintendo-64-plugin.vala    |    6 +-
 plugins/nintendo-ds/src/nintendo-ds-plugin.vala    |    6 +-
 plugins/pc-engine/src/pc-engine-plugin.vala        |   11 +++--
 .../playstation/src/playstation-game-factory.vala  |    6 +-
 plugins/sega-saturn/src/sega-saturn-plugin.vala    |    6 +-
 plugins/snes/src/snes-plugin.vala                  |    6 +-
 plugins/wii-ware/src/wii-ware-plugin.vala          |    6 +-
 plugins/wii/src/wii-plugin.vala                    |    6 +-
 src/retro/retro-runner.vala                        |   48 +++----------------
 22 files changed, 105 insertions(+), 111 deletions(-)
---
diff --git a/plugins/amiga/src/amiga-plugin.vala b/plugins/amiga/src/amiga-plugin.vala
index 6bd80a1..03a54eb 100644
--- a/plugins/amiga/src/amiga-plugin.vala
+++ b/plugins/amiga/src/amiga-plugin.vala
@@ -3,8 +3,7 @@
 private class Games.AmigaPlugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "amiga";
        private const string MIME_TYPE = "application/x-amiga-disk-format";
-       private const string MODULE_BASENAME = "libretro-amiga.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "Amiga";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -25,7 +24,8 @@ private class Games.AmigaPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/atari-2600/src/atari-2600-plugin.vala b/plugins/atari-2600/src/atari-2600-plugin.vala
index 7760fd5..027fa57 100644
--- a/plugins/atari-2600/src/atari-2600-plugin.vala
+++ b/plugins/atari-2600/src/atari-2600-plugin.vala
@@ -3,8 +3,7 @@
 private class Games.Atari2600 : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "atari-2600";
        private const string MIME_TYPE = "application/x-atari-2600-rom";
-       private const string MODULE_BASENAME = "libretro-atari-2600.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "Atari2600";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -25,7 +24,8 @@ private class Games.Atari2600 : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/atari-7800/src/atari-7800-plugin.vala b/plugins/atari-7800/src/atari-7800-plugin.vala
index afc8581..3a07c41 100644
--- a/plugins/atari-7800/src/atari-7800-plugin.vala
+++ b/plugins/atari-7800/src/atari-7800-plugin.vala
@@ -3,8 +3,7 @@
 private class Games.Atari7800 : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "atari-7800";
        private const string MIME_TYPE = "application/x-atari-7800-rom";
-       private const string MODULE_BASENAME = "libretro-atari-7800.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "Atari7800";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -25,7 +24,8 @@ private class Games.Atari7800 : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/doom/src/doom-plugin.vala b/plugins/doom/src/doom-plugin.vala
index 3c45e66..7dd7c33 100644
--- a/plugins/doom/src/doom-plugin.vala
+++ b/plugins/doom/src/doom-plugin.vala
@@ -3,8 +3,7 @@
 private class Games.DoomPlugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "doom";
        private const string MIME_TYPE = "application/x-doom-wad";
-       private const string MODULE_BASENAME = "libretro-doom.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "DOOM";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -22,7 +21,8 @@ private class Games.DoomPlugin : Object, Plugin {
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
                var cover = new LocalCover (uri);
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index 7b466e3..eae8e5d 100644
--- a/plugins/dreamcast/src/dreamcast-plugin.vala
+++ b/plugins/dreamcast/src/dreamcast-plugin.vala
@@ -2,8 +2,7 @@
 
 private class Games.DreamcastPlugin : Object, Plugin {
        private const string MIME_TYPE = "application/x-dc-rom";
-       private const string MODULE_BASENAME = "libretro-dreamcast.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "Dreamcast";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -28,7 +27,8 @@ private class Games.DreamcastPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/game-boy-advance/src/game-boy-advance-plugin.vala 
b/plugins/game-boy-advance/src/game-boy-advance-plugin.vala
index b64c2a8..9b2e8c2 100644
--- a/plugins/game-boy-advance/src/game-boy-advance-plugin.vala
+++ b/plugins/game-boy-advance/src/game-boy-advance-plugin.vala
@@ -3,8 +3,7 @@
 private class Games.GameBoyAdvancePlugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "game-boy-advance";
        private const string MIME_TYPE = "application/x-gba-rom";
-       private const string MODULE_BASENAME = "libretro-game-boy-advance.so";
-       private const bool SUPPORTS_SNAPSHOTTING = true;
+       private const string PLATFORM = "GameBoyAdvance";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -25,7 +24,8 @@ private class Games.GameBoyAdvancePlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/game-boy/src/game-boy-plugin.vala b/plugins/game-boy/src/game-boy-plugin.vala
index c1262f2..0e23dcb 100644
--- a/plugins/game-boy/src/game-boy-plugin.vala
+++ b/plugins/game-boy/src/game-boy-plugin.vala
@@ -3,13 +3,12 @@
 private class Games.GameBoyPlugin : Object, Plugin {
        private const string GAME_BOY_PREFIX = "game-boy";
        private const string GAME_BOY_MIME_TYPE = "application/x-gameboy-rom";
+       private const string GAME_BOY_PLATFORM = "GameBoy";
 
        // Similar to GAME_BOY_PREFIX for simplicity and backward compatibility.
        private const string GAME_BOY_COLOR_PREFIX = "game-boy";
        private const string GAME_BOY_COLOR_MIME_TYPE = "application/x-gameboy-color-rom";
-
-       private const string MODULE_BASENAME = "libretro-game-boy.so";
-       private const bool SUPPORTS_SNAPSHOTTING = true;
+       private const string GAME_BOY_COLOR_PLATFORM = "GameBoyColor";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -31,12 +30,15 @@ private class Games.GameBoyPlugin : Object, Plugin {
 
                string prefix;
                string mime_type;
+               string platform;
                if (header.is_classic ()) {
                        prefix = GAME_BOY_PREFIX;
+                       platform = GAME_BOY_PLATFORM;
                        mime_type = GAME_BOY_MIME_TYPE;
                }
                else if (header.is_color ()) {
                        prefix = GAME_BOY_COLOR_PREFIX;
+                       platform = GAME_BOY_COLOR_PLATFORM;
                        mime_type = GAME_BOY_COLOR_MIME_TYPE;
                }
                else
@@ -49,7 +51,8 @@ private class Games.GameBoyPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { mime_type }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (platform, { mime_type });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index a945ca7..c5b67ff 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -2,8 +2,7 @@
 
 private class Games.GameCubePlugin : Object, Plugin {
        private const string MIME_TYPE = "application/x-gamecube-rom";
-       private const string MODULE_BASENAME = "libretro-game-cube.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "GameCube";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -28,7 +27,8 @@ private class Games.GameCubePlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/mame/src/mame-game-uri-adapter.vala b/plugins/mame/src/mame-game-uri-adapter.vala
index b4d0484..a43c47a 100644
--- a/plugins/mame/src/mame-game-uri-adapter.vala
+++ b/plugins/mame/src/mame-game-uri-adapter.vala
@@ -3,8 +3,7 @@
 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 const string MODULE_BASENAME = "libretro-mame.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "MAME";
 
        public async Game game_for_uri (string uri) throws Error {
                var supported_games = yield MameGameInfo.get_supported_games ();
@@ -27,7 +26,8 @@ private class Games.MameGameUriAdapter : GameUriAdapter, Object {
 
                var icon = new DummyIcon ();
                var cover = new LocalCover (uri);
-               var runner = new RetroRunner (uri, uid, { SEARCHED_MIME_TYPE, SPECIFIC_MIME_TYPE }, 
MODULE_BASENAME, SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { SEARCHED_MIME_TYPE, SPECIFIC_MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/master-system/src/master-system-plugin.vala 
b/plugins/master-system/src/master-system-plugin.vala
index 55bc154..2057b17 100644
--- a/plugins/master-system/src/master-system-plugin.vala
+++ b/plugins/master-system/src/master-system-plugin.vala
@@ -3,15 +3,15 @@
 private class Games.MasterSystemPlugin : Object, Plugin {
        private const string MASTER_SYSTEM_PREFIX = "master-system";
        private const string MASTER_SYSTEM_MIME_TYPE = "application/x-sms-rom";
+       private const string MASTER_SYSTEM_PLATFORM = "MasterSystem";
 
        private const string GAME_GEAR_PREFIX = "game-gear";
        private const string GAME_GEAR_MIME_TYPE = "application/x-gamegear-rom";
+       private const string GAME_GEAR_PLATFORM = "GameGear";
 
        private const string SG_1000_PREFIX = "sg-1000";
        private const string SG_1000_MIME_TYPE = "application/x-sg1000-rom";
-
-       private const string MODULE_BASENAME = "libretro-master-system.so";
-       private const bool SUPPORTS_SNAPSHOTTING = true;
+       private const string SG_1000_PLATFORM = "SG1000";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -40,13 +40,16 @@ private class Games.MasterSystemPlugin : Object, Plugin {
 
                string prefix;
                string mime_type;
+               string platform;
                if (header.is_master_system ()) {
                        prefix = MASTER_SYSTEM_PREFIX;
                        mime_type = MASTER_SYSTEM_MIME_TYPE;
+                       platform = MASTER_SYSTEM_PLATFORM;
                }
                else if (header.is_game_gear ()) {
                        prefix = GAME_GEAR_PREFIX;
                        mime_type = GAME_GEAR_MIME_TYPE;
+                       platform = GAME_GEAR_PLATFORM;
                }
                else
                        assert_not_reached ();
@@ -58,7 +61,8 @@ private class Games.MasterSystemPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { mime_type }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (platform, { mime_type });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
@@ -71,7 +75,8 @@ private class Games.MasterSystemPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { SG_1000_MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (SG_1000_PLATFORM, { SG_1000_MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/mega-drive/src/mega-drive-plugin.vala b/plugins/mega-drive/src/mega-drive-plugin.vala
index cfa3e6a..8d0a070 100644
--- a/plugins/mega-drive/src/mega-drive-plugin.vala
+++ b/plugins/mega-drive/src/mega-drive-plugin.vala
@@ -3,19 +3,21 @@
 private class Games.MegaDrivePlugin : Object, Plugin {
        private const string MEGA_DRIVE_PREFIX = "mega-drive";
        private const string MEGA_DRIVE_MIME_TYPE = "application/x-genesis-rom";
+       private const string MEGA_DRIVE_PLATFORM = "SegaGenesis";
 
        private const string 32X_PREFIX = "mega-drive-32x";
        private const string 32X_MIME_TYPE = "application/x-genesis-32x-rom";
+       private const string 32X_PLATFORM = "Sega32X";
 
        private const string PICO_PREFIX = "sega-pico";
        private const string PICO_MIME_TYPE = "application/x-sega-pico-rom";
+       private const string PICO_PLATFORM = "SegaPico";
 
        private const string MEGA_CD_PREFIX = "mega-cd";
        private const string CUE_MIME_TYPE = "application/x-cue";
        private const string MEGA_CD_MIME_TYPE = "application/x-sega-cd-rom";
-
-       private const string MODULE_BASENAME = "libretro-mega-drive.so";
-       private const bool SUPPORTS_SNAPSHOTTING = true;
+       private const string MEGA_CD_PLATFORM = "SegaCD";
+       private const string MEGA_CD_32X_PLATFORM = "SegaCD32X";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -44,17 +46,21 @@ private class Games.MegaDrivePlugin : Object, Plugin {
 
                string prefix;
                string mime_type;
+               string platform;
                if (header.is_mega_drive ()) {
                        prefix = MEGA_DRIVE_PREFIX;
                        mime_type = MEGA_DRIVE_MIME_TYPE;
+                       platform = MEGA_DRIVE_PLATFORM;
                }
                else if (header.is_32x ()) {
                        prefix = 32X_PREFIX;
                        mime_type = 32X_MIME_TYPE;
+                       platform = 32X_PLATFORM;
                }
                else if (header.is_pico ()) {
                        prefix = PICO_PREFIX;
                        mime_type = PICO_MIME_TYPE;
+                       platform = PICO_PLATFORM;
                }
                else
                        assert_not_reached ();
@@ -66,7 +72,8 @@ private class Games.MegaDrivePlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { mime_type }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (platform, { mime_type });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
@@ -80,10 +87,15 @@ private class Games.MegaDrivePlugin : Object, Plugin {
                header.check_validity ();
 
                string[] mime_types;
-               if (header.is_mega_drive ())
+               string platform;
+               if (header.is_mega_drive ()) {
                        mime_types = { CUE_MIME_TYPE, MEGA_CD_MIME_TYPE };
-               else if (header.is_32x ())
+                       platform = MEGA_CD_PLATFORM;
+               }
+               else if (header.is_32x ()) {
                        mime_types = { CUE_MIME_TYPE, MEGA_CD_MIME_TYPE, 32X_MIME_TYPE };
+                       platform = MEGA_CD_32X_PLATFORM;
+               }
                else
                        assert_not_reached ();
 
@@ -96,7 +108,8 @@ private class Games.MegaDrivePlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, mime_types, MODULE_BASENAME, SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (platform, mime_types);
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/neo-geo-pocket/src/neo-geo-pocket-plugin.vala 
b/plugins/neo-geo-pocket/src/neo-geo-pocket-plugin.vala
index 0c3a611..94fa9d6 100644
--- a/plugins/neo-geo-pocket/src/neo-geo-pocket-plugin.vala
+++ b/plugins/neo-geo-pocket/src/neo-geo-pocket-plugin.vala
@@ -3,8 +3,7 @@
 private class Games.NeoGeoPocketPlugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "neo-geo-pocket";
        private const string MIME_TYPE = "application/x-neo-geo-pocket-rom";
-       private const string MODULE_BASENAME = "libretro-neo-geo-pocket.so";
-       private const bool SUPPORTS_SNAPSHOTTING = true;
+       private const string PLATFORM = "NeoGeoPocket";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -25,7 +24,8 @@ private class Games.NeoGeoPocketPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/nes/src/nes-plugin.vala b/plugins/nes/src/nes-plugin.vala
index 1e61bab..5d3af42 100644
--- a/plugins/nes/src/nes-plugin.vala
+++ b/plugins/nes/src/nes-plugin.vala
@@ -3,9 +3,11 @@
 private class Games.NesPlugin : Object, Plugin {
        private const string NES_FINGERPRINT_PREFIX = "nes";
        private const string NES_MIME_TYPE = "application/x-nes-rom";
+       private const string NES_PLATFORM = "NintendoEntertainmentSystem";
 
        private const string FDS_FINGERPRINT_PREFIX = "fds";
        private const string FDS_MIME_TYPE = "application/x-fds-disk";
+       private const string FDS_PLATFORM = "FamicomDiskSystem";
 
        private const string MODULE_BASENAME = "libretro-nes.so";
        private const bool SUPPORTS_SNAPSHOTTING = true;
@@ -33,7 +35,8 @@ private class Games.NesPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { NES_MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (NES_PLATFORM, { NES_MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
@@ -46,7 +49,8 @@ private class Games.NesPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { FDS_MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (FDS_PLATFORM, { FDS_MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/nintendo-64/src/nintendo-64-plugin.vala b/plugins/nintendo-64/src/nintendo-64-plugin.vala
index 44e5fba..a92014a 100644
--- a/plugins/nintendo-64/src/nintendo-64-plugin.vala
+++ b/plugins/nintendo-64/src/nintendo-64-plugin.vala
@@ -3,8 +3,7 @@
 private class Games.Nintendo64Plugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "nintendo-64";
        private const string MIME_TYPE = "application/x-n64-rom";
-       private const string MODULE_BASENAME = "libretro-nintendo-64.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "Nintendo64";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -25,7 +24,8 @@ private class Games.Nintendo64Plugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index cf49419..9c6214a 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -3,8 +3,7 @@
 private class Games.NintendoDsPlugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "nintendo-ds";
        private const string MIME_TYPE = "application/x-nintendo-ds-rom";
-       private const string MODULE_BASENAME = "libretro-nintendo-ds.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "NintendoDS";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -25,7 +24,8 @@ private class Games.NintendoDsPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/pc-engine/src/pc-engine-plugin.vala b/plugins/pc-engine/src/pc-engine-plugin.vala
index 2a2a2f0..63b3eef 100644
--- a/plugins/pc-engine/src/pc-engine-plugin.vala
+++ b/plugins/pc-engine/src/pc-engine-plugin.vala
@@ -4,12 +4,11 @@ private class Games.PcEnginePlugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "pc-engine";
 
        private const string MIME_TYPE = "application/x-pc-engine-rom";
+       private const string PLATFORM = "TurboGrafx16";
 
        private const string CUE_MIME_TYPE = "application/x-cue";
        private const string CD_MAGIC_VALUE = "PC Engine CD-ROM SYSTEM";
-
-       private const string MODULE_BASENAME = "libretro-pc-engine.so";
-       private const bool SUPPORTS_SNAPSHOTTING = true;
+       private const string CD_PLATFORM = "TurboCD";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -34,7 +33,8 @@ private class Games.PcEnginePlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
@@ -50,7 +50,8 @@ private class Games.PcEnginePlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { CUE_MIME_TYPE, MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (CD_PLATFORM, { CUE_MIME_TYPE, MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index 724ef29..89f8e94 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -3,9 +3,8 @@
 public class Games.PlayStationGameFactory : Object, UriGameFactory {
        private const string SEARCHED_MIME_TYPE = "application/x-cue";
        private const string SPECIFIC_MIME_TYPE = "application/x-playstation-rom";
-       private const string MODULE_BASENAME = "libretro-playstation.so";
+       private const string PLATFORM = "PlayStation";
        private const string ICON_NAME = "media-optical-symbolic";
-       private const bool SUPPORTS_SNAPSHOTTING = true;
        private const string GAMEINFO = 
"resource:///org/gnome/Games/plugin/playstation/playstation.gameinfo.xml";
 
        private static GameinfoDoc gameinfo;
@@ -155,7 +154,8 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
                var input_capabilities = new GameinfoDiscIdInputCapabilities (gameinfo, header.disc_id);
-               var runner = new RetroRunner.for_media_set_and_input_capabilities (media_set, uid, { 
SEARCHED_MIME_TYPE, SPECIFIC_MIME_TYPE }, MODULE_BASENAME, SUPPORTS_SNAPSHOTTING, input_capabilities);
+               var core_source = new RetroCoreSource (PLATFORM, { SEARCHED_MIME_TYPE, SPECIFIC_MIME_TYPE });
+               var runner = new RetroRunner.for_media_set_and_input_capabilities (core_source, media_set, 
uid, input_capabilities);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index 8dc111f..0d44f71 100644
--- a/plugins/sega-saturn/src/sega-saturn-plugin.vala
+++ b/plugins/sega-saturn/src/sega-saturn-plugin.vala
@@ -3,8 +3,7 @@
 private class Games.SegaSaturnPlugin : Object, Plugin {
        private const string SEARCHED_MIME_TYPE = "application/x-cue";
        private const string SPECIFIC_MIME_TYPE = "application/x-saturn-rom";
-       private const string MODULE_BASENAME = "libretro-saturn.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "SegaSaturn";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -32,7 +31,8 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { SEARCHED_MIME_TYPE, SPECIFIC_MIME_TYPE }, 
MODULE_BASENAME, SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { SEARCHED_MIME_TYPE, SPECIFIC_MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/snes/src/snes-plugin.vala b/plugins/snes/src/snes-plugin.vala
index 7d5eab7..60a6d92 100644
--- a/plugins/snes/src/snes-plugin.vala
+++ b/plugins/snes/src/snes-plugin.vala
@@ -3,8 +3,7 @@
 private class Games.SnesPlugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "snes";
        private const string MIME_TYPE = "application/vnd.nintendo.snes.rom";
-       private const string MODULE_BASENAME = "libretro-snes.so";
-       private const bool SUPPORTS_SNAPSHOTTING = true;
+       private const string PLATFORM = "SuperNintendoEntertainmentSystem";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -25,7 +24,8 @@ private class Games.SnesPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/wii-ware/src/wii-ware-plugin.vala b/plugins/wii-ware/src/wii-ware-plugin.vala
index c402292..389577a 100644
--- a/plugins/wii-ware/src/wii-ware-plugin.vala
+++ b/plugins/wii-ware/src/wii-ware-plugin.vala
@@ -3,8 +3,7 @@
 private class Games.WiiWarePlugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "wii-ware";
        private const string MIME_TYPE = "application/x-wii-wad";
-       private const string MODULE_BASENAME = "libretro-wii.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "Wii";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -25,7 +24,8 @@ private class Games.WiiWarePlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index a568720..47f2d2c 100644
--- a/plugins/wii/src/wii-plugin.vala
+++ b/plugins/wii/src/wii-plugin.vala
@@ -2,8 +2,7 @@
 
 private class Games.WiiPlugin : Object, Plugin {
        private const string MIME_TYPE = "application/x-wii-rom";
-       private const string MODULE_BASENAME = "libretro-wii.so";
-       private const bool SUPPORTS_SNAPSHOTTING = false;
+       private const string PLATFORM = "WiiWare";
 
        public GameSource get_game_source () throws Error {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
@@ -28,7 +27,8 @@ private class Games.WiiPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var runner = new RetroRunner (uri, uid, { MIME_TYPE }, MODULE_BASENAME, 
SUPPORTS_SNAPSHOTTING);
+               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
+               var runner = new RetroRunner (core_source, uri, uid);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 7690d78..c36a7d0 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -46,8 +46,7 @@ public class Games.RetroRunner : Object, Runner {
        private string snapshot_path;
        private string screenshot_path;
 
-       private string module_basename;
-       private string[] mime_types;
+       private RetroCoreSource core_source;
        private Uid uid;
        private InputCapabilities input_capabilities;
 
@@ -68,7 +67,7 @@ public class Games.RetroRunner : Object, Runner {
        private bool is_ready;
        private bool should_save;
 
-       public RetroRunner (string uri, Uid uid, string[] mime_types, string module_basename, bool 
core_supports_snapshotting) {
+       public RetroRunner (RetroCoreSource core_source, string uri, Uid uid) {
                is_initialized = false;
                is_ready = false;
                should_save = false;
@@ -76,20 +75,18 @@ public class Games.RetroRunner : Object, Runner {
                var game_media = new Media (uri);
                _media_set = new MediaSet ({ game_media });
 
-               this.mime_types = mime_types;
-               this.module_basename = module_basename;
                this.uid = uid;
+               this.core_source = core_source;
                this.input_capabilities = null;
        }
 
-       public RetroRunner.for_media_set_and_input_capabilities (MediaSet media_set, Uid uid, string[] 
mime_types, string module_basename, bool core_supports_snapshotting, InputCapabilities input_capabilities) {
+       public RetroRunner.for_media_set_and_input_capabilities (RetroCoreSource core_source, MediaSet 
media_set, Uid uid, InputCapabilities input_capabilities) {
                is_initialized = false;
                is_ready = false;
                should_save = false;
 
+               this.core_source = core_source;
                this._media_set = media_set;
-               this.mime_types = mime_types;
-               this.module_basename = module_basename;
                this.uid = uid;
                this.input_capabilities = input_capabilities;
 
@@ -171,7 +168,7 @@ public class Games.RetroRunner : Object, Runner {
                var media = media_set.get_selected_media (media_number);
                var uri = media.uri;
 
-               prepare_core (module_basename, uri);
+               prepare_core (uri);
                core.shutdown.connect (on_shutdown);
 
                core.run (); // Needed to finish preparing some cores.
@@ -201,8 +198,8 @@ public class Games.RetroRunner : Object, Runner {
                should_save = false;
        }
 
-       private void prepare_core (string module_basename, string uri) throws Error {
-               var module_path = get_module_path ();
+       private void prepare_core (string uri) throws Error {
+               var module_path = core_source.get_module_path ();
                core = new Retro.Core (module_path);
                audio = new RetroGtk.PaPlayer ();
 
@@ -217,35 +214,6 @@ public class Games.RetroRunner : Object, Runner {
                        throw new RetroError.INVALID_GAME_FILE (_("Invalid game file: '%s'."), uri);
        }
 
-       private string get_module_path () throws Error {
-               var module_path = Retro.ModuleQuery.lookup_module_for_basename (module_basename);
-
-               if (FileUtils.test (module_path, FileTest.EXISTS))
-                       return module_path;
-
-               if (mime_types.length == 0)
-                       throw new RetroError.MODULE_NOT_FOUND (_("Couldn't run game: module '%s' not 
found."), module_basename);
-
-               module_path = Retro.ModuleQuery.lookup_module_for_info (check_module_info);
-
-               if (FileUtils.test (module_path, FileTest.EXISTS))
-                       return module_path;
-
-               throw new RetroError.MODULE_NOT_FOUND (_("Couldn't run game: module '%s' not found and no 
module found for MIME types %s."), module_basename, string.joinv (" ", mime_types));
-       }
-
-       private bool check_module_info (HashTable<string, string> module_info) {
-               if (!module_info.contains ("supported_mimetypes"))
-                       return false;
-
-               var supported_mime_types = module_info["supported_mimetypes"];
-               foreach (var mime_type in mime_types)
-                       if (!(mime_type in supported_mime_types))
-                               return false;
-
-               return true;
-       }
-
        private bool try_load_game (Retro.Core core, string uri) {
                var file = File.new_for_uri (uri);
                var path = file.get_path ();


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