[gnome-games/wip/exalm/uid: 2/18] database: Remove DatabaseGame



commit 1208d766082d4fc44c1f4ff84ab514396b4c89a1
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Feb 21 15:34:41 2020 +0500

    database: Remove DatabaseGame
    
    Use GenericGame instead, their only noticeable difference is constructor.

 src/database/database-game.vala | 50 -----------------------------------------
 src/database/database.vala      | 21 +++++++++++++++--
 src/meson.build                 |  1 -
 3 files changed, 19 insertions(+), 53 deletions(-)
---
diff --git a/src/database/database.vala b/src/database/database.vala
index 1d434a10..939a5773 100644
--- a/src/database/database.vala
+++ b/src/database/database.vala
@@ -291,7 +291,7 @@ private class Games.Database : Object {
                        var platform = get_cached_game_query.column_text (2);
                        var media_set = get_cached_game_query.column_text (3);
 
-                       return new DatabaseGame (uid, uri, title, platform, media_set);
+                       return create_game (uid, uri, title, platform, media_set);
                }
 
                throw new DatabaseError.EXECUTION_FAILED ("Couldn't get game for uid (%s)", uid);
@@ -307,8 +307,25 @@ private class Games.Database : Object {
                        var platform = list_cached_games_query.column_text (3);
                        var media_set = list_cached_games_query.column_text (4);
 
-                       var game = new DatabaseGame (uid, uri, title, platform, media_set);
+                       var game = create_game (uid, uri, title, platform, media_set);
                        game_callback (game);
                }
        }
+
+       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);
+
+               if (game_platform == null)
+                       game_platform = new DummyPlatform ();
+
+               var game = new GenericGame (game_uid, game_uri, game_title, game_platform);
+
+               if (media_set != null)
+                       game.set_media_set (new MediaSet.parse (new Variant.parsed (media_set)));
+
+               return game;
+       }
 }
diff --git a/src/meson.build b/src/meson.build
index a5e6b550..aa8a9fe1 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -46,7 +46,6 @@ vala_sources = [
 
   'database/database.vala',
   'database/database-error.vala',
-  'database/database-game.vala',
   'database/database-uri-iterator.vala',
   'database/database-uri-source.vala',
 


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