[gnome-games] pc-engine: Provide MIME types and URI game factories
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] pc-engine: Provide MIME types and URI game factories
- Date: Thu, 4 May 2017 19:21:15 +0000 (UTC)
commit a77bc4d1c97fb3f3a1fe6f94179948c7c1155eba
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu May 4 15:39:33 2017 +0200
pc-engine: 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.
https://bugzilla.gnome.org/show_bug.cgi?id=781334
plugins/pc-engine/configure.ac | 1 -
plugins/pc-engine/src/pc-engine-plugin.vala | 51 ++++++++++++++++++---------
2 files changed, 34 insertions(+), 18 deletions(-)
---
diff --git a/plugins/pc-engine/configure.ac b/plugins/pc-engine/configure.ac
index 6c49395..2a8c96e 100644
--- a/plugins/pc-engine/configure.ac
+++ b/plugins/pc-engine/configure.ac
@@ -3,7 +3,6 @@ PKG_CHECK_MODULES(PC_ENGINE_PLUGIN, [
glib-2.0 >= $GLIB_MIN_VERSION
gtk+-3.0
retro-gtk-0.10
- tracker-sparql-1.0
], [enable_pc_engine_plugin=yes], [enable_pc_engine_plugin=no])
AM_CONDITIONAL(ENABLE_PC_ENGINE_PLUGIN, test x$enable_pc_engine_plugin != xno)
diff --git a/plugins/pc-engine/src/pc-engine-plugin.vala b/plugins/pc-engine/src/pc-engine-plugin.vala
index a3c2e50..c94e8a0 100644
--- a/plugins/pc-engine/src/pc-engine-plugin.vala
+++ b/plugins/pc-engine/src/pc-engine-plugin.vala
@@ -10,19 +10,23 @@ private class Games.PcEnginePlugin : Object, Plugin {
private const string CD_MAGIC_VALUE = "PC Engine CD-ROM SYSTEM";
private const string CD_PLATFORM = "TurboGrafxCD";
- public GameSource? get_game_source () throws Error {
+ public string[] get_mime_types () {
+ return {
+ MIME_TYPE,
+ CUE_MIME_TYPE,
+ };
+ }
+
+ public UriGameFactory[] get_uri_game_factories () {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var cd_game_uri_adapter = new GenericSyncGameUriAdapter (cd_game_for_uri);
var factory = new GenericUriGameFactory (game_uri_adapter);
+ factory.add_mime_type (MIME_TYPE);
+
+ var cd_game_uri_adapter = new GenericSyncGameUriAdapter (cd_game_for_uri);
var cd_factory = new GenericUriGameFactory (cd_game_uri_adapter);
- var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
- var cd_query = new MimeTypeTrackerQuery (CUE_MIME_TYPE, cd_factory);
- var connection = Tracker.Sparql.Connection.@get ();
- var source = new TrackerGameSource (connection);
- source.add_query (query);
- source.add_query (cd_query);
-
- return source;
+ cd_factory.add_mime_type (CUE_MIME_TYPE);
+
+ return { factory, cd_factory };
}
private static Game game_for_uri (string uri) throws Error {
@@ -57,16 +61,29 @@ private class Games.PcEnginePlugin : Object, Plugin {
}
private static bool is_valid_disc (string uri) throws Error {
- var cue_file = File.new_for_uri (uri);
- var cue_sheet = new CueSheet (cue_file);
- if (cue_sheet.tracks_number < 2)
- return false;
+ var file = File.new_for_uri (uri);
+ var file_info = file.query_info (FileAttribute.STANDARD_CONTENT_TYPE,
FileQueryInfoFlags.NONE);
+ var mime_type = file_info.get_content_type ();
+
+ File bin_file;
+ switch (mime_type) {
+ case CUE_MIME_TYPE:
+ var cue = new CueSheet (file);
+ if (cue.tracks_number < 2)
+ return false;
+
+ var track = cue.get_track (1);
+ if (!track.track_mode.is_mode1 ())
+ return false;
+
+ bin_file = track.file.file;
- var track = cue_sheet.get_track (1);
- if (!track.track_mode.is_mode1 ())
+ break;
+ // TODO Add support for binary files.
+ default:
return false;
+ }
- var bin_file = track.file.file;
var path = bin_file.get_path ();
var offsets = Grep.get_offsets (path, CD_MAGIC_VALUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]