[gnome-games/wip/aplazas/781334-refactor-game-source: 26/35] nes: Provide MIME types and URI game factories



commit 5b836a1c9d99b00e133ce23a077b47ad658fec9b
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu May 4 15:38:22 2017 +0200

    nes: 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/nes/src/nes-plugin.vala |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/plugins/nes/src/nes-plugin.vala b/plugins/nes/src/nes-plugin.vala
index a51fd5e..3534731 100644
--- a/plugins/nes/src/nes-plugin.vala
+++ b/plugins/nes/src/nes-plugin.vala
@@ -12,19 +12,23 @@ private class Games.NesPlugin : Object, Plugin {
        private const string MODULE_BASENAME = "libretro-nes.so";
        private const bool SUPPORTS_SNAPSHOTTING = true;
 
-       public GameSource? get_game_source () throws Error {
+       public string[] get_mime_types () {
+               return {
+                       NES_MIME_TYPE,
+                       FDS_MIME_TYPE,
+               };
+       }
+
+       public UriGameFactory[] get_uri_game_factories () {
                var nes_game_uri_adapter = new GenericSyncGameUriAdapter (nes_game_for_uri);
-               var fds_game_uri_adapter = new GenericSyncGameUriAdapter (fds_game_for_uri);
                var nes_factory = new GenericUriGameFactory (nes_game_uri_adapter);
+               nes_factory.add_mime_type (NES_MIME_TYPE);
+
+               var fds_game_uri_adapter = new GenericSyncGameUriAdapter (fds_game_for_uri);
                var fds_factory = new GenericUriGameFactory (fds_game_uri_adapter);
-               var nes_query = new MimeTypeTrackerQuery (NES_MIME_TYPE, nes_factory);
-               var fds_query = new MimeTypeTrackerQuery (FDS_MIME_TYPE, fds_factory);
-               var connection = Tracker.Sparql.Connection.@get ();
-               var source = new TrackerGameSource (connection);
-               source.add_query (nes_query);
-               source.add_query (fds_query);
-
-               return source;
+               fds_factory.add_mime_type (FDS_MIME_TYPE);
+
+               return { nes_factory, fds_factory };
        }
 
        private static Game nes_game_for_uri (string uri) throws Error {


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