[gnome-games/wip/exalm/psx-cleanup: 10/10] playstation: Use Game.set_media_set() instead of a separate cache



commit 6864d7a861bf5751b4efb03bcecf4ed71b753cf5
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Feb 10 15:56:15 2020 +0500

    playstation: Use Game.set_media_set() instead of a separate cache
    
    Remove PlaystationGameinfoCache.

 plugins/playstation/src/meson.build                     |  1 -
 plugins/playstation/src/playstation-game-factory.vala   |  7 ++-----
 plugins/playstation/src/playstation-gameinfo-cache.vala | 17 -----------------
 plugins/playstation/src/playstation-plugin.vala         | 10 ++--------
 4 files changed, 4 insertions(+), 31 deletions(-)
---
diff --git a/plugins/playstation/src/meson.build b/plugins/playstation/src/meson.build
index 8f60a5f5..1871682c 100644
--- a/plugins/playstation/src/meson.build
+++ b/plugins/playstation/src/meson.build
@@ -2,7 +2,6 @@ vala_sources = [
   'playstation-error.vala',
   'playstation-game-factory.vala',
   'playstation-header.vala',
-  'playstation-gameinfo-cache.vala',
   'playstation-plugin.vala',
   'playstation-uid.vala',
 ]
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index f57abd92..9958edb2 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -7,7 +7,6 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
        private const string GAMEINFO = 
"resource:///org/gnome/Games/plugin/playstation/playstation.gameinfo.xml";
 
        private static GameinfoDoc gameinfo;
-       private PlaystationGameinfoCache gameinfo_cache;
 
        private HashTable<string, Media> media_for_disc_id;
        private HashTable<Uri, Game> game_for_uri;
@@ -16,13 +15,12 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
        private RetroPlatform platform;
        private unowned GameCallback game_added_callback;
 
-       public PlayStationGameFactory (RetroPlatform platform, PlaystationGameinfoCache gameinfo_cache) {
+       public PlayStationGameFactory (RetroPlatform platform) {
                media_for_disc_id = new HashTable<string, Media> (str_hash, str_equal);
                game_for_uri = new HashTable<Uri, Game> (Uri.hash, Uri.equal);
                game_for_disc_set_id = new HashTable<string, Game> (GLib.str_hash, GLib.str_equal);
                games = new GenericSet<Game> (direct_hash, direct_equal);
                this.platform = platform;
-               this.gameinfo_cache = gameinfo_cache;
        }
 
        public string[] get_mime_types () {
@@ -126,8 +124,6 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                games.add (game);
                if (game_added_callback != null)
                        game_added_callback (game);
-
-               gameinfo_cache.store_info (uri, media_set);
        }
 
        public void foreach_game (GameCallback game_callback) {
@@ -148,6 +144,7 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
 
                var game = new GenericGame (uid, uri, title, platform);
                game.set_cover (cover);
+               game.set_media_set (media_set);
 
                return game;
        }
diff --git a/plugins/playstation/src/playstation-plugin.vala b/plugins/playstation/src/playstation-plugin.vala
index ebd34a4e..c6b9e84f 100644
--- a/plugins/playstation/src/playstation-plugin.vala
+++ b/plugins/playstation/src/playstation-plugin.vala
@@ -8,13 +8,10 @@ private class Games.PlayStation : Object, Plugin {
        private const string PLATFORM_UID_PREFIX = "playstation";
 
        private static RetroPlatform platform;
-       private static PlaystationGameinfoCache gameinfo_cache;
 
        static construct {
                string[] mime_types = { CUE_MIME_TYPE, PHONY_MIME_TYPE };
                platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types, PLATFORM_UID_PREFIX);
-
-               gameinfo_cache = new PlaystationGameinfoCache ();
        }
 
        public Platform[] get_platforms () {
@@ -26,7 +23,7 @@ private class Games.PlayStation : Object, Plugin {
        }
 
        public UriGameFactory[] get_uri_game_factories () {
-               var factory = new PlayStationGameFactory (platform, gameinfo_cache);
+               var factory = new PlayStationGameFactory (platform);
 
                return { factory };
        }
@@ -39,14 +36,11 @@ private class Games.PlayStation : Object, Plugin {
        }
 
        public static Runner? create_runner (Game game) throws Error {
-               var uri = game.get_uri ();
-               var media_set = gameinfo_cache.get_media_set (uri);
-
                var core_source = new RetroCoreSource (platform);
 
                var builder = new RetroRunnerBuilder ();
                builder.core_source = core_source;
-               builder.media_set = media_set;
+               builder.media_set = game.get_media_set ();
                builder.uid = game.get_uid ();
                builder.title = game.name;
 


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