[gnome-games/wip/exalm/uid: 73/82] game: Take uid as string argument instead of Uid



commit fc27b1efef1384987793087090c6a4641c443e4e
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Feb 21 17:41:10 2020 +0500

    game: Take uid as string argument instead of Uid
    
    Create GenericUid implicitly from the passed string. Somewhat unrelated,
    make GriloCover accept string uid as well.

 plugins/desktop/src/desktop-plugin.vala               | 2 +-
 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                     | 2 +-
 plugins/mame/src/mame-game-uri-adapter.vala           | 3 +--
 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 | 5 ++---
 plugins/sega-cd/src/sega-cd-plugin.vala               | 4 +++-
 plugins/sega-saturn/src/sega-saturn-plugin.vala       | 2 +-
 plugins/steam/src/steam-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/core/game.vala                                    | 4 ++--
 src/database/database.vala                            | 3 +--
 src/grilo/grilo-cover.vala                            | 7 +++----
 src/retro/retro-simple-game-uri-adapter.vala          | 2 +-
 19 files changed, 25 insertions(+), 27 deletions(-)
---
diff --git a/plugins/desktop/src/desktop-plugin.vala b/plugins/desktop/src/desktop-plugin.vala
index 2f89356b..163b4b9e 100644
--- a/plugins/desktop/src/desktop-plugin.vala
+++ b/plugins/desktop/src/desktop-plugin.vala
@@ -61,7 +61,7 @@ private class Games.DesktopPlugin : Object, Plugin {
                var path = file.get_path ();
 
                var app_info = new DesktopAppInfo.from_filename (path);
-               var uid = new GenericUid (get_uid (app_info));
+               var uid = get_uid (app_info);
                var title = new DesktopTitle (app_info);
                var icon = new DesktopIcon (app_info);
 
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index 526012bf..05bb8f25 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 header = new DreamcastHeader (file);
                header.check_validity ();
 
-               var uid = new GenericUid (get_uid (header));
+               var uid = get_uid (header);
                var title = new FilenameTitle (uri);
                var media = new GriloMedia (title, MIME_TYPE);
                var cover = new CompositeCover ({
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index 51354f6e..d1790dcf 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -45,7 +45,7 @@ private class Games.GameCubePlugin : Object, Plugin {
                var header = new GameCubeHeader (file);
                header.check_validity ();
 
-               var uid = new GenericUid (get_uid (header));
+               var uid = get_uid (header);
                var title = new FilenameTitle (uri);
                var media = new GriloMedia (title, MIME_TYPE);
                var cover = new CompositeCover ({
diff --git a/plugins/libretro/src/libretro-plugin.vala b/plugins/libretro/src/libretro-plugin.vala
index b4a65fec..a24b1e51 100644
--- a/plugins/libretro/src/libretro-plugin.vala
+++ b/plugins/libretro/src/libretro-plugin.vala
@@ -60,7 +60,7 @@ private class Games.LibretroPlugin : Object, Plugin {
        private static Game game_for_uri (Uri uri) throws Error {
                var core_descriptor = get_core_descriptor (uri);
 
-               var uid = new GenericUid (get_uid (core_descriptor));
+               var uid = get_uid (core_descriptor);
                var title = new LibretroTitle (core_descriptor);
                var icon = new LibretroIcon (core_descriptor);
 
diff --git a/plugins/love/src/love-plugin.vala b/plugins/love/src/love-plugin.vala
index 2bdc4cb4..75a98caa 100644
--- a/plugins/love/src/love-plugin.vala
+++ b/plugins/love/src/love-plugin.vala
@@ -36,7 +36,7 @@ private class Games.LovePlugin : Object, Plugin {
        }
 
        private static Game game_for_uri (Uri uri) throws Error {
-               var uid = new GenericUid (Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX));
+               var uid = Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX);
                var package = new LovePackage (uri);
                var title = new LoveTitle (package);
                var icon = new LoveIcon (package);
diff --git a/plugins/mame/src/mame-game-uri-adapter.vala b/plugins/mame/src/mame-game-uri-adapter.vala
index 1bd1e82f..8822bbf2 100644
--- a/plugins/mame/src/mame-game-uri-adapter.vala
+++ b/plugins/mame/src/mame-game-uri-adapter.vala
@@ -17,8 +17,7 @@ private class Games.MameGameUriAdapter : GameUriAdapter, Object {
                if (!supported_games.contains (game_id))
                        throw new MameError.INVALID_GAME_ID (_("Invalid MAME game id “%s” for “%s”."), 
game_id, uri.to_string ());
 
-               var uid_string = @"mame-$game_id".down ();
-               var uid = new GenericUid (uid_string);
+               var uid = @"mame-$game_id".down ();
 
                var title_string = supported_games[game_id];
                title_string = title_string.split ("(")[0];
diff --git a/plugins/ms-dos/src/ms-dos-plugin.vala b/plugins/ms-dos/src/ms-dos-plugin.vala
index b50d6552..7a82a746 100644
--- a/plugins/ms-dos/src/ms-dos-plugin.vala
+++ b/plugins/ms-dos/src/ms-dos-plugin.vala
@@ -32,7 +32,7 @@ private class Games.MsDosPlugin : Object, Plugin {
        }
 
        private static Game game_for_uri (Uri uri) throws Error {
-               var uid = new GenericUid (Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX));
+               var uid = Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX);
                var title = new FilenameTitle (uri);
                var media = new GriloMedia (title, MIME_TYPE);
                var cover = new CompositeCover ({
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index ece7d308..aa259ba3 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -36,7 +36,7 @@ private class Games.NintendoDsPlugin : Object, Plugin {
        }
 
        private static Game game_for_uri (Uri uri) throws Error {
-               var uid = new GenericUid (Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX));
+               var uid = Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new NintendoDsIcon (uri);
                var media = new GriloMedia (title, MIME_TYPE);
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index a22b20e6..dc739300 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -149,10 +149,9 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
        }
 
        private Game create_game (MediaSet media_set, string disc_set_id, Uri uri) throws Error {
-               var uid_string = @"$PLATFORM_UID_PREFIX-$disc_set_id".down ();
-
                var gameinfo = get_gameinfo ();
-               var uid = new GenericUid (uid_string);
+
+               var uid = @"$PLATFORM_UID_PREFIX-$disc_set_id".down ();
                var title = new CompositeTitle ({
                        new GameinfoDiscIdGameTitle (gameinfo, disc_set_id),
                        new FilenameTitle (uri)
diff --git a/plugins/sega-cd/src/sega-cd-plugin.vala b/plugins/sega-cd/src/sega-cd-plugin.vala
index 81eb1a18..9540f8bb 100644
--- a/plugins/sega-cd/src/sega-cd-plugin.vala
+++ b/plugins/sega-cd/src/sega-cd-plugin.vala
@@ -81,7 +81,9 @@ private class Games.SegaCDPlugin : Object, Plugin {
 
                var bin_uri = new Uri (bin_file.get_uri ());
                var header_offset = header.get_offset ();
-               var uid = new GenericUid (Fingerprint.get_uid_for_chunk (bin_uri, SEGA_CD_UID_PREFIX, 
header_offset, SegaCDHeader.HEADER_LENGTH));
+               var uid = Fingerprint.get_uid_for_chunk (bin_uri, SEGA_CD_UID_PREFIX,
+                                                        header_offset,
+                                                        SegaCDHeader.HEADER_LENGTH);
                var title = new FilenameTitle (uri);
                var media = new GriloMedia (title, SEGA_CD_MIME_TYPE);
                var cover = new CompositeCover ({
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index b510ec9c..84cd34e3 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 header = new SegaSaturnHeader (bin_file);
                header.check_validity ();
 
-               var uid = new GenericUid (get_uid (header));
+               var uid = get_uid (header);
                var title = new FilenameTitle (uri);
                var media = new GriloMedia (title, SEGA_SATURN_MIME_TYPE);
                var cover = new CompositeCover ({
diff --git a/plugins/steam/src/steam-plugin.vala b/plugins/steam/src/steam-plugin.vala
index 947ad47e..3069c648 100644
--- a/plugins/steam/src/steam-plugin.vala
+++ b/plugins/steam/src/steam-plugin.vala
@@ -102,7 +102,7 @@ private class Games.SteamPlugin : Object, Plugin {
                        assert_not_reached ();
                }
 
-               var uid = new GenericUid (@"$PLATFORM_UID_PREFIX-$prefix$game_id".down ());
+               var uid = @"$PLATFORM_UID_PREFIX-$prefix$game_id".down ();
                var title = new GenericTitle (game_title);
                var icon = new SteamIcon (app_id, game_id);
                var cover = new SteamCover (game_id);
diff --git a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala 
b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
index 450ac3f0..962357ab 100644
--- a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
+++ b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
@@ -42,7 +42,7 @@ private class Games.TurboGrafxCDPlugin : Object, Plugin {
                if (!is_valid_disc (uri))
                        throw new TurboGrafxCDError.INVALID_DISC ("“%s” isn’t a valid TurboGrafx-CD disc.", 
uri.to_string ());
 
-               var uid = new GenericUid (Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX));
+               var uid = Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX);
                var title = new FilenameTitle (uri);
                var media = new GriloMedia (title, PHONY_MIME_TYPE);
                var cover = new CompositeCover ({
diff --git a/plugins/virtual-boy/src/virtual-boy-plugin.vala b/plugins/virtual-boy/src/virtual-boy-plugin.vala
index a3c5516b..3be85e8d 100644
--- a/plugins/virtual-boy/src/virtual-boy-plugin.vala
+++ b/plugins/virtual-boy/src/virtual-boy-plugin.vala
@@ -40,7 +40,7 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
                var header = new VirtualBoyHeader (file);
                header.check_validity ();
 
-               var uid = new GenericUid (Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX));
+               var uid = Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX);
                var title = new FilenameTitle (uri);
                var media = new GriloMedia (title, MIME_TYPE);
                var cover = new CompositeCover ({
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index 8617b7ac..0e1caa6c 100644
--- a/plugins/wii/src/wii-plugin.vala
+++ b/plugins/wii/src/wii-plugin.vala
@@ -45,7 +45,7 @@ private class Games.WiiPlugin : Object, Plugin {
                var header = new WiiHeader (file);
                header.check_validity ();
 
-               var uid = new GenericUid (get_uid (header));
+               var uid = get_uid (header);
                var title = new FilenameTitle (uri);
                var media = new GriloMedia (title, MIME_TYPE);
                var cover = new CompositeCover ({
diff --git a/src/core/game.vala b/src/core/game.vala
index 722b32be..8cdd4901 100644
--- a/src/core/game.vala
+++ b/src/core/game.vala
@@ -28,8 +28,8 @@ public class Games.Game : Object {
        private Platform game_platform;
        private MediaSet? media_set;
 
-       public Game (Uid uid, Uri uri, Title title, Platform platform) {
-               game_uid = uid;
+       public Game (string uid, Uri uri, Title title, Platform platform) {
+               game_uid = new GenericUid (uid);
                game_uri = uri;
                game_title = title;
                game_platform = platform;
diff --git a/src/database/database.vala b/src/database/database.vala
index df7f8280..665c47bb 100644
--- a/src/database/database.vala
+++ b/src/database/database.vala
@@ -313,7 +313,6 @@ private class Games.Database : Object {
        }
 
        private Game create_game (string uid, string uri, string title, string platform, string? media_set) {
-               var game_uid = new GenericUid (uid);
                var game_uri = new Uri (uri);
                var game_title = new GenericTitle (title);
                var game_platform = PlatformRegister.get_register ().get_platform (platform);
@@ -321,7 +320,7 @@ private class Games.Database : Object {
                if (game_platform == null)
                        game_platform = new DummyPlatform ();
 
-               var game = new Game (game_uid, game_uri, game_title, game_platform);
+               var game = new Game (uid, game_uri, game_title, game_platform);
 
                if (media_set != null)
                        game.set_media_set (new MediaSet.parse (new Variant.parsed (media_set)));
diff --git a/src/grilo/grilo-cover.vala b/src/grilo/grilo-cover.vala
index 53ce7a26..476c10ce 100644
--- a/src/grilo/grilo-cover.vala
+++ b/src/grilo/grilo-cover.vala
@@ -2,12 +2,12 @@
 
 public class Games.GriloCover : Object, Cover {
        private GriloMedia media;
-       private Uid uid;
+       private string uid;
        private File? file;
        private bool resolving;
        private string cover_path;
 
-       public GriloCover (GriloMedia media, Uid uid) {
+       public GriloCover (GriloMedia media, string uid) {
                this.media = media;
                this.uid = uid;
                media.resolved.connect (on_media_resolved);
@@ -51,12 +51,11 @@ public class Games.GriloCover : Object, Cover {
                try_fetch_cover.begin (uri);
        }
 
-       private string get_cover_path () throws Error {
+       private string get_cover_path () {
                if (cover_path != null)
                        return cover_path;
 
                var dir = Application.get_covers_dir ();
-               var uid = uid.get_uid ();
                cover_path = @"$dir/$uid.cover";
 
                return cover_path;
diff --git a/src/retro/retro-simple-game-uri-adapter.vala b/src/retro/retro-simple-game-uri-adapter.vala
index 35eed310..56fc1a8f 100644
--- a/src/retro/retro-simple-game-uri-adapter.vala
+++ b/src/retro/retro-simple-game-uri-adapter.vala
@@ -10,7 +10,7 @@ private class Games.RetroSimpleGameUriAdapter : GameUriAdapter, Object {
        }
 
        public Game game_for_uri (Uri uri) throws Error {
-               var uid = new GenericUid (Fingerprint.get_uid (uri, simple_type.prefix));
+               var uid = Fingerprint.get_uid (uri, simple_type.prefix);
                var title = new FilenameTitle (uri);
                var media = new GriloMedia (title, simple_type.mime_type);
                var cover = new CompositeCover ({


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