[gnome-games/wip/aplazas/781334-refactor-game-source: 23/35] master-system: Provide MIME types and URI game factories
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/aplazas/781334-refactor-game-source: 23/35] master-system: Provide MIME types and URI game factories
- Date: Thu, 4 May 2017 16:14:41 +0000 (UTC)
commit 671e05ffdef3f79f56cc747404ebc53d4b3063c5
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.
.../master-system/src/master-system-plugin.vala | 31 ++++++++++---------
1 files changed, 16 insertions(+), 15 deletions(-)
---
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]