[gnome-games] generic: Add uid parameter to constructor



commit 82fa2d88fa61b31606e6b449d355a59c54276276
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Tue Jul 10 18:54:47 2018 +0500

    generic: Add uid parameter to constructor
    
    Also update RetroSimpleGameUriAdapter and plugins.
    
    Use DesktopUid for desktop plugin, SteamUid for steam plugin and
    FingerprintUid for LÖVE plugin, reuse existing uids otherwise.
    
    This will be used in the subsequent commits to add Game.get_uid().

 plugins/desktop/src/desktop-plugin.vala               | 3 ++-
 plugins/dreamcast/src/dreamcast-plugin.vala           | 2 +-
 plugins/game-cube/src/game-cube-plugin.vala           | 2 +-
 plugins/libretro/src/libretro-plugin.vala             | 2 +-
 plugins/love/src/love-plugin.vala                     | 4 +++-
 plugins/mame/src/mame-game-uri-adapter.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               | 2 +-
 plugins/sega-saturn/src/sega-saturn-plugin.vala       | 2 +-
 plugins/steam/src/steam-plugin.vala                   | 3 ++-
 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/generic/generic-game.vala                         | 2 +-
 src/retro/retro-simple-game-uri-adapter.vala          | 2 +-
 16 files changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/plugins/desktop/src/desktop-plugin.vala b/plugins/desktop/src/desktop-plugin.vala
index d2282fc..9331a89 100644
--- a/plugins/desktop/src/desktop-plugin.vala
+++ b/plugins/desktop/src/desktop-plugin.vala
@@ -38,6 +38,7 @@ private class Games.DesktopPlugin : Object, Plugin {
                var path = file.get_path ();
 
                var app_info = new DesktopAppInfo.from_filename (path);
+               var uid = new DesktopUid (app_info);
                var title = new DesktopTitle (app_info);
                var icon = new DesktopIcon (app_info);
                var cover = new DummyCover ();
@@ -48,7 +49,7 @@ private class Games.DesktopPlugin : Object, Plugin {
                        throw new CommandError.INVALID_COMMAND (_("Invalid command “%s”."), command);
                var runner = new CommandRunner (args, true);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, title, icon, cover, runner);
        }
 
        private static void check_uri (Uri uri) throws Error {
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index f4beb81..0ef1a10 100644
--- a/plugins/dreamcast/src/dreamcast-plugin.vala
+++ b/plugins/dreamcast/src/dreamcast-plugin.vala
@@ -31,7 +31,7 @@ private class Games.DreamcastPlugin : Object, Plugin {
                var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, 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 1751bd9..428daa4 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -31,7 +31,7 @@ private class Games.GameCubePlugin : Object, Plugin {
                var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, title, icon, cover, runner);
        }
 }
 
diff --git a/plugins/libretro/src/libretro-plugin.vala b/plugins/libretro/src/libretro-plugin.vala
index 5f45708..6a30cb7 100644
--- a/plugins/libretro/src/libretro-plugin.vala
+++ b/plugins/libretro/src/libretro-plugin.vala
@@ -34,7 +34,7 @@ private class Games.LibretroPlugin : Object, Plugin {
                var cover = new DummyCover ();
                var runner = new RetroRunner.for_core_descriptor (core_descriptor, uid, title);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, title, icon, cover, runner);
        }
 }
 
diff --git a/plugins/love/src/love-plugin.vala b/plugins/love/src/love-plugin.vala
index 206c4b9..8a6620e 100644
--- a/plugins/love/src/love-plugin.vala
+++ b/plugins/love/src/love-plugin.vala
@@ -1,6 +1,7 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 private class Games.LovePlugin : Object, Plugin {
+       private const string FINGERPRINT_PREFIX = "love";
        private const string MIME_TYPE = "application/x-love-game";
 
        public string[] get_mime_types () {
@@ -16,6 +17,7 @@ private class Games.LovePlugin : Object, Plugin {
        }
 
        private static Game game_for_uri (Uri uri) throws Error {
+               var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var package = new LovePackage (uri);
                var title = new LoveTitle (package);
                var icon = new LoveIcon (package);
@@ -23,7 +25,7 @@ private class Games.LovePlugin : Object, Plugin {
                string[] args = { "love", uri.to_string () };
                var runner = new CommandRunner (args, true);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, 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 135c568..7c82534 100644
--- a/plugins/mame/src/mame-game-uri-adapter.vala
+++ b/plugins/mame/src/mame-game-uri-adapter.vala
@@ -32,6 +32,6 @@ private class Games.MameGameUriAdapter : GameUriAdapter, Object {
                Idle.add (this.game_for_uri.callback);
                yield;
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, 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 ebd86ca..922b1e9 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -28,7 +28,7 @@ private class Games.NintendoDsPlugin : Object, Plugin {
                var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, title, icon, cover, runner);
        }
 }
 
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index b420588..1a222c3 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -147,7 +147,7 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                var core_source = new RetroCoreSource (PLATFORM, { CUE_MIME_TYPE, PHONY_MIME_TYPE });
                var runner = new RetroRunner.for_media_set_and_input_capabilities (core_source, media_set, 
uid, input_capabilities, title);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, title, icon, cover, runner);
        }
 
        private static GameinfoDoc get_gameinfo () throws Error {
diff --git a/plugins/sega-cd/src/sega-cd-plugin.vala b/plugins/sega-cd/src/sega-cd-plugin.vala
index d7dcc6e..aae7d15 100644
--- a/plugins/sega-cd/src/sega-cd-plugin.vala
+++ b/plugins/sega-cd/src/sega-cd-plugin.vala
@@ -70,7 +70,7 @@ private class Games.SegaCDPlugin : Object, Plugin {
                var core_source = new RetroCoreSource (platform, mime_types);
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, title, icon, cover, runner);
        }
 
        private static File get_binary_file (CueSheet cue) throws Error {
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index 771f125..6f11bf9 100644
--- a/plugins/sega-saturn/src/sega-saturn-plugin.vala
+++ b/plugins/sega-saturn/src/sega-saturn-plugin.vala
@@ -54,7 +54,7 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
                var core_source = new RetroCoreSource (PLATFORM, { CUE_MIME_TYPE, SEGA_SATURN_MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, title, icon, cover, runner);
        }
 
        private static File get_binary_file (CueSheet cue) throws Error {
diff --git a/plugins/steam/src/steam-plugin.vala b/plugins/steam/src/steam-plugin.vala
index 8043877..6ca34ea 100644
--- a/plugins/steam/src/steam-plugin.vala
+++ b/plugins/steam/src/steam-plugin.vala
@@ -50,13 +50,14 @@ private class Games.SteamPlugin : Object, Plugin {
                        return game;
                }
 
+               var uid = new SteamUid (game_id);
                var title = new SteamTitle (registry);
                var icon = new SteamIcon (game_id);
                var cover = new SteamCover (game_id);
                string[] args = { "steam", @"steam://rungameid/" + game_id };
                var runner = new CommandRunner (args, false);
 
-               var game = new GenericGame (title, icon, cover, runner);
+               var game = new GenericGame (uid, title, icon, cover, runner);
                game_for_id[game_id] = game;
 
                return game;
diff --git a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala 
b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
index 3055132..aea3a74 100644
--- a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
+++ b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
@@ -33,7 +33,7 @@ private class Games.TurboGrafxCDPlugin : Object, Plugin {
                var core_source = new RetroCoreSource (CD_PLATFORM, { CUE_MIME_TYPE, PHONY_MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, title, icon, cover, runner);
        }
 
        private static bool is_valid_disc (Uri uri) throws Error {
diff --git a/plugins/virtual-boy/src/virtual-boy-plugin.vala b/plugins/virtual-boy/src/virtual-boy-plugin.vala
index 16e8f34..0254b9d 100644
--- a/plugins/virtual-boy/src/virtual-boy-plugin.vala
+++ b/plugins/virtual-boy/src/virtual-boy-plugin.vala
@@ -33,7 +33,7 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
                var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, title, icon, cover, runner);
        }
 }
 
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index 9ee9311..9cdb50e 100644
--- a/plugins/wii/src/wii-plugin.vala
+++ b/plugins/wii/src/wii-plugin.vala
@@ -31,7 +31,7 @@ private class Games.WiiPlugin : Object, Plugin {
                var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, title, icon, cover, runner);
        }
 }
 
diff --git a/src/generic/generic-game.vala b/src/generic/generic-game.vala
index bc44d3b..1c0944b 100644
--- a/src/generic/generic-game.vala
+++ b/src/generic/generic-game.vala
@@ -23,7 +23,7 @@ public class Games.GenericGame : Object, Game {
        private Cover game_cover;
        private Runner game_runner;
 
-       public GenericGame (Title title, Icon icon, Cover cover, Runner runner) {
+       public GenericGame (Uid uid, Title title, Icon icon, Cover cover, Runner runner) {
                game_title = title;
                game_icon = icon;
                game_cover = cover;
diff --git a/src/retro/retro-simple-game-uri-adapter.vala b/src/retro/retro-simple-game-uri-adapter.vala
index c5eb3ae..e508a7a 100644
--- a/src/retro/retro-simple-game-uri-adapter.vala
+++ b/src/retro/retro-simple-game-uri-adapter.vala
@@ -21,6 +21,6 @@ private class Games.RetroSimpleGameUriAdapter : GameUriAdapter, Object {
                var core_source = new RetroCoreSource (simple_type.platform, { simple_type.mime_type });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               return new GenericGame (title, icon, cover, runner);
+               return new GenericGame (uid, title, icon, cover, runner);
        }
 }


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