[gnome-games/wip/aplazas/781334-refactor-game-source: 23/37] master-system: Provide MIME types and URI game factories



commit e5164a3ac4c6defe246d1ef02f03535be2d6c164
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu May 4 15:37:48 2017 +0200

    master-system: Provide MIME types and URI game factories
    
    Also stop providing a GameSource.
    
    This helps splitting the conerns of looking for game resources and
    building games from them.

 plugins/master-system/configure.ac                 |    1 -
 .../master-system/src/master-system-plugin.vala    |   31 ++++++++++---------
 2 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/plugins/master-system/configure.ac b/plugins/master-system/configure.ac
index 26a1812..d56ff4b 100644
--- a/plugins/master-system/configure.ac
+++ b/plugins/master-system/configure.ac
@@ -3,7 +3,6 @@ PKG_CHECK_MODULES(MASTER_SYSTEM_PLUGIN, [
        glib-2.0 >= $GLIB_MIN_VERSION
        gtk+-3.0
        retro-gtk-0.10
-       tracker-sparql-1.0
 ], [enable_master_system_plugin=yes], [enable_master_system_plugin=no])
 
 AM_CONDITIONAL(ENABLE_MASTER_SYSTEM_PLUGIN, test x$enable_master_system_plugin != xno)
diff --git a/plugins/master-system/src/master-system-plugin.vala 
b/plugins/master-system/src/master-system-plugin.vala
index 3db80c0..e1a2ea3 100644
--- a/plugins/master-system/src/master-system-plugin.vala
+++ b/plugins/master-system/src/master-system-plugin.vala
@@ -13,24 +13,25 @@ private class Games.MasterSystemPlugin : Object, Plugin {
        private const string SG_1000_MIME_TYPE = "application/x-sg1000-rom";
        private const string SG_1000_PLATFORM = "SG1000";
 
-       public GameSource? get_game_source () throws Error {
+       public string[] get_mime_types () {
+               return {
+                       MASTER_SYSTEM_MIME_TYPE,
+                       GAME_GEAR_MIME_TYPE,
+                       SG_1000_MIME_TYPE,
+               };
+       }
+
+       public UriGameFactory[] get_uri_game_factories () {
                var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
+               var factory = new GenericUriGameFactory (game_uri_adapter);
+               factory.add_mime_type (MASTER_SYSTEM_MIME_TYPE);
+               factory.add_mime_type (GAME_GEAR_MIME_TYPE);
+
                var sg_1000_game_uri_adapter = new GenericSyncGameUriAdapter (sg_1000_game_for_uri);
-               // FIXME We should be able to use one factory for Master System and
-               // Game Gear.
-               var master_system_factory = new GenericUriGameFactory (game_uri_adapter);
-               var game_gear_factory = new GenericUriGameFactory (game_uri_adapter);
                var sg_1000_factory = new GenericUriGameFactory (sg_1000_game_uri_adapter);
-               var master_system_query = new MimeTypeTrackerQuery (MASTER_SYSTEM_MIME_TYPE, 
master_system_factory);
-               var game_gear_query = new MimeTypeTrackerQuery (GAME_GEAR_MIME_TYPE, game_gear_factory);
-               var sg_1000_query = new MimeTypeTrackerQuery (SG_1000_MIME_TYPE, sg_1000_factory);
-               var connection = Tracker.Sparql.Connection.@get ();
-               var source = new TrackerGameSource (connection);
-               source.add_query (master_system_query);
-               source.add_query (game_gear_query);
-               source.add_query (sg_1000_query);
+               sg_1000_factory.add_mime_type (SG_1000_MIME_TYPE);
 
-               return source;
+               return { factory, sg_1000_factory };
        }
 
        private static Game game_for_uri (string uri) throws Error {


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