[gnome-games/wip/aplazas/run-uri-simpler: 2/2] Simplify
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/aplazas/run-uri-simpler: 2/2] Simplify
- Date: Thu, 13 Apr 2017 05:42:10 +0000 (UTC)
commit 421c1df279f085dc54bf57e43534316f5b25a352
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed Apr 12 22:21:47 2017 +0200
Simplify
plugins/amiga/src/amiga-plugin.vala | 3 +-
plugins/atari-2600/src/atari-2600-plugin.vala | 3 +-
plugins/atari-7800/src/atari-7800-plugin.vala | 3 +-
plugins/desktop/src/desktop-tracker-query.vala | 2 +-
plugins/doom/src/doom-plugin.vala | 3 +-
plugins/dreamcast/src/dreamcast-plugin.vala | 3 +-
.../src/game-boy-advance-plugin.vala | 3 +-
plugins/game-boy/src/game-boy-plugin.vala | 6 +--
plugins/game-cube/src/game-cube-plugin.vala | 3 +-
plugins/love/src/love-plugin.vala | 3 +-
plugins/mame/src/mame-plugin.vala | 3 +-
.../master-system/src/master-system-plugin.vala | 9 ++----
plugins/mega-drive/src/mega-drive-plugin.vala | 10 ++----
.../neo-geo-pocket/src/neo-geo-pocket-plugin.vala | 3 +-
plugins/nes/src/nes-plugin.vala | 6 +--
plugins/nintendo-64/src/nintendo-64-plugin.vala | 3 +-
plugins/nintendo-ds/src/nintendo-ds-plugin.vala | 3 +-
plugins/pc-engine/src/pc-engine-plugin.vala | 7 +---
.../playstation/src/playstation-game-factory.vala | 2 +-
plugins/sega-saturn/src/sega-saturn-plugin.vala | 3 +-
plugins/snes/src/snes-plugin.vala | 3 +-
plugins/wii-ware/src/wii-ware-plugin.vala | 3 +-
plugins/wii/src/wii-plugin.vala | 3 +-
src/Makefile.am | 2 -
src/core/uri-game-factory.vala | 1 -
src/core/uri-test.vala | 5 ---
src/generic/generic-mime-type-uri-test.vala | 26 ----------------
src/generic/generic-uri-game-factory.vala | 12 ++------
src/tracker/mime-type-tracker-query.vala | 31 +++++++++++++------
29 files changed, 54 insertions(+), 113 deletions(-)
---
diff --git a/plugins/amiga/src/amiga-plugin.vala b/plugins/amiga/src/amiga-plugin.vala
index f9e1020..2b59a9b 100644
--- a/plugins/amiga/src/amiga-plugin.vala
+++ b/plugins/amiga/src/amiga-plugin.vala
@@ -7,8 +7,7 @@ private class Games.AmigaPlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/atari-2600/src/atari-2600-plugin.vala b/plugins/atari-2600/src/atari-2600-plugin.vala
index b7c3273..a9f5cca 100644
--- a/plugins/atari-2600/src/atari-2600-plugin.vala
+++ b/plugins/atari-2600/src/atari-2600-plugin.vala
@@ -7,8 +7,7 @@ private class Games.Atari2600 : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/atari-7800/src/atari-7800-plugin.vala b/plugins/atari-7800/src/atari-7800-plugin.vala
index 6a05f3c..900fed3 100644
--- a/plugins/atari-7800/src/atari-7800-plugin.vala
+++ b/plugins/atari-7800/src/atari-7800-plugin.vala
@@ -7,8 +7,7 @@ private class Games.Atari7800 : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/desktop/src/desktop-tracker-query.vala b/plugins/desktop/src/desktop-tracker-query.vala
index 3cfa918..f613283 100644
--- a/plugins/desktop/src/desktop-tracker-query.vala
+++ b/plugins/desktop/src/desktop-tracker-query.vala
@@ -19,7 +19,7 @@ private class Games.DesktopTrackerQuery : Object, TrackerQuery {
return is_uri_valid (uri);
}
- public bool is_uri_valid (string uri) {
+ private bool is_uri_valid (string uri) {
try {
check_uri (uri);
} catch (Error e) {
diff --git a/plugins/doom/src/doom-plugin.vala b/plugins/doom/src/doom-plugin.vala
index 73527b0..268c92f 100644
--- a/plugins/doom/src/doom-plugin.vala
+++ b/plugins/doom/src/doom-plugin.vala
@@ -7,8 +7,7 @@ private class Games.DoomPlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index 1143192..5601097 100644
--- a/plugins/dreamcast/src/dreamcast-plugin.vala
+++ b/plugins/dreamcast/src/dreamcast-plugin.vala
@@ -6,8 +6,7 @@ private class Games.DreamcastPlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/game-boy-advance/src/game-boy-advance-plugin.vala
b/plugins/game-boy-advance/src/game-boy-advance-plugin.vala
index 9052ec3..98f2f5b 100644
--- a/plugins/game-boy-advance/src/game-boy-advance-plugin.vala
+++ b/plugins/game-boy-advance/src/game-boy-advance-plugin.vala
@@ -7,8 +7,7 @@ private class Games.GameBoyAdvancePlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/game-boy/src/game-boy-plugin.vala b/plugins/game-boy/src/game-boy-plugin.vala
index fa4c9e9..fcdb217 100644
--- a/plugins/game-boy/src/game-boy-plugin.vala
+++ b/plugins/game-boy/src/game-boy-plugin.vala
@@ -12,10 +12,8 @@ private class Games.GameBoyPlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var game_boy_uri_test = new GenericMimeTypeUriTest (GAME_BOY_MIME_TYPE);
- var game_boy_factory = new GenericUriGameFactory (game_uri_adapter, game_boy_uri_test);
- var game_boy_color_uri_test = new GenericMimeTypeUriTest (GAME_BOY_COLOR_MIME_TYPE);
- var game_boy_color_factory = new GenericUriGameFactory (game_uri_adapter,
game_boy_color_uri_test);
+ var game_boy_factory = new GenericUriGameFactory (game_uri_adapter);
+ var game_boy_color_factory = new GenericUriGameFactory (game_uri_adapter);
var game_boy_query = new MimeTypeTrackerQuery (GAME_BOY_MIME_TYPE, game_boy_factory);
var game_boy_color_query = new MimeTypeTrackerQuery (GAME_BOY_COLOR_MIME_TYPE,
game_boy_color_factory);
var connection = Tracker.Sparql.Connection.@get ();
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index ae70fe4..bdbe8a5 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -6,8 +6,7 @@ private class Games.GameCubePlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/love/src/love-plugin.vala b/plugins/love/src/love-plugin.vala
index 65c8945..c412f41 100644
--- a/plugins/love/src/love-plugin.vala
+++ b/plugins/love/src/love-plugin.vala
@@ -5,8 +5,7 @@ private class Games.LovePlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/mame/src/mame-plugin.vala b/plugins/mame/src/mame-plugin.vala
index 549d4ec..28ede81 100644
--- a/plugins/mame/src/mame-plugin.vala
+++ b/plugins/mame/src/mame-plugin.vala
@@ -6,8 +6,7 @@ private class Games.MamePlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new MameGameUriAdapter ();
// FIXME .zip is too generic, we test further.
- var uri_test = new GenericMimeTypeUriTest (SEARCHED_MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (SEARCHED_MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/master-system/src/master-system-plugin.vala
b/plugins/master-system/src/master-system-plugin.vala
index 6687959..6490362 100644
--- a/plugins/master-system/src/master-system-plugin.vala
+++ b/plugins/master-system/src/master-system-plugin.vala
@@ -18,12 +18,9 @@ private class Games.MasterSystemPlugin : Object, Plugin {
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_uri_test = new GenericMimeTypeUriTest (MASTER_SYSTEM_MIME_TYPE);
- var game_gear_uri_test = new GenericMimeTypeUriTest (GAME_GEAR_MIME_TYPE);
- var sg_1000_uri_test = new GenericMimeTypeUriTest (SG_1000_MIME_TYPE);
- var master_system_factory = new GenericUriGameFactory (game_uri_adapter,
master_system_uri_test);
- var game_gear_factory = new GenericUriGameFactory (game_uri_adapter, game_gear_uri_test);
- var sg_1000_factory = new GenericUriGameFactory (sg_1000_game_uri_adapter, sg_1000_uri_test);
+ 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);
diff --git a/plugins/mega-drive/src/mega-drive-plugin.vala b/plugins/mega-drive/src/mega-drive-plugin.vala
index 3446b62..9c2539c 100644
--- a/plugins/mega-drive/src/mega-drive-plugin.vala
+++ b/plugins/mega-drive/src/mega-drive-plugin.vala
@@ -24,14 +24,10 @@ private class Games.MegaDrivePlugin : Object, Plugin {
var cd_game_uri_adapter = new GenericSyncGameUriAdapter (cd_game_for_uri);
// FIXME We should be able to use one factory for Mega Drive and
// 32X.
- var mega_drive_uri_test = new GenericMimeTypeUriTest (MEGA_DRIVE_MIME_TYPE);
- var 32x_uri_test = new GenericMimeTypeUriTest (32X_MIME_TYPE);
- // FIXME .cue is too generic, we should test further.
- var mega_cd_uri_test = new GenericMimeTypeUriTest (CUE_MIME_TYPE);
// FIXME What about PICO_MIME_TYPE?
- var mega_drive_factory = new GenericUriGameFactory (game_uri_adapter, mega_drive_uri_test);
- var 32x_factory = new GenericUriGameFactory (game_uri_adapter, 32x_uri_test);
- var mega_cd_factory = new GenericUriGameFactory (cd_game_uri_adapter, mega_cd_uri_test);
+ var mega_drive_factory = new GenericUriGameFactory (game_uri_adapter);
+ var 32x_factory = new GenericUriGameFactory (game_uri_adapter);
+ var mega_cd_factory = new GenericUriGameFactory (cd_game_uri_adapter);
var mega_drive_query = new MimeTypeTrackerQuery (MEGA_DRIVE_MIME_TYPE, mega_drive_factory);
var 32x_query = new MimeTypeTrackerQuery (32X_MIME_TYPE, 32x_factory);
var mega_cd_query = new MimeTypeTrackerQuery (CUE_MIME_TYPE, mega_cd_factory);
diff --git a/plugins/neo-geo-pocket/src/neo-geo-pocket-plugin.vala
b/plugins/neo-geo-pocket/src/neo-geo-pocket-plugin.vala
index 8e74864..3d90052 100644
--- a/plugins/neo-geo-pocket/src/neo-geo-pocket-plugin.vala
+++ b/plugins/neo-geo-pocket/src/neo-geo-pocket-plugin.vala
@@ -7,8 +7,7 @@ private class Games.NeoGeoPocketPlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/nes/src/nes-plugin.vala b/plugins/nes/src/nes-plugin.vala
index 9c8fdde..8fe52c7 100644
--- a/plugins/nes/src/nes-plugin.vala
+++ b/plugins/nes/src/nes-plugin.vala
@@ -15,10 +15,8 @@ private class Games.NesPlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var nes_game_uri_adapter = new GenericSyncGameUriAdapter (nes_game_for_uri);
var fds_game_uri_adapter = new GenericSyncGameUriAdapter (fds_game_for_uri);
- var nes_uri_test = new GenericMimeTypeUriTest (NES_MIME_TYPE);
- var fds_uri_test = new GenericMimeTypeUriTest (FDS_MIME_TYPE);
- var nes_factory = new GenericUriGameFactory (nes_game_uri_adapter, nes_uri_test);
- var fds_factory = new GenericUriGameFactory (fds_game_uri_adapter, fds_uri_test);
+ var nes_factory = new GenericUriGameFactory (nes_game_uri_adapter);
+ 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 ();
diff --git a/plugins/nintendo-64/src/nintendo-64-plugin.vala b/plugins/nintendo-64/src/nintendo-64-plugin.vala
index 52d6e08..df68204 100644
--- a/plugins/nintendo-64/src/nintendo-64-plugin.vala
+++ b/plugins/nintendo-64/src/nintendo-64-plugin.vala
@@ -7,8 +7,7 @@ private class Games.Nintendo64Plugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index d349659..23529a9 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -7,8 +7,7 @@ private class Games.NintendoDsPlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/pc-engine/src/pc-engine-plugin.vala b/plugins/pc-engine/src/pc-engine-plugin.vala
index f2dcc86..4639c3d 100644
--- a/plugins/pc-engine/src/pc-engine-plugin.vala
+++ b/plugins/pc-engine/src/pc-engine-plugin.vala
@@ -13,11 +13,8 @@ private class Games.PcEnginePlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
var cd_game_uri_adapter = new GenericSyncGameUriAdapter (cd_game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- // FIXME .cue is too generic, we should test further.
- var cd_uri_test = new GenericMimeTypeUriTest (CUE_MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
- var cd_factory = new GenericUriGameFactory (cd_game_uri_adapter, cd_uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
+ 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 ();
diff --git a/plugins/playstation/src/playstation-game-factory.vala
b/plugins/playstation/src/playstation-game-factory.vala
index 863fc7c..c08b013 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -26,7 +26,7 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
return is_uri_valid (uri);
}
- public bool is_uri_valid (string uri) {
+ private bool is_uri_valid (string uri) {
File file = File.new_for_uri(uri);
return file.query_exists ();
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index 64c2323..0a7fa3c 100644
--- a/plugins/sega-saturn/src/sega-saturn-plugin.vala
+++ b/plugins/sega-saturn/src/sega-saturn-plugin.vala
@@ -8,8 +8,7 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
// FIXME .cue is too generic, we should test further.
- var uri_test = new GenericMimeTypeUriTest (SEARCHED_MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (SEARCHED_MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/snes/src/snes-plugin.vala b/plugins/snes/src/snes-plugin.vala
index 583b6a9..1217d1a 100644
--- a/plugins/snes/src/snes-plugin.vala
+++ b/plugins/snes/src/snes-plugin.vala
@@ -7,8 +7,7 @@ private class Games.SnesPlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/wii-ware/src/wii-ware-plugin.vala b/plugins/wii-ware/src/wii-ware-plugin.vala
index 91604b3..c689570 100644
--- a/plugins/wii-ware/src/wii-ware-plugin.vala
+++ b/plugins/wii-ware/src/wii-ware-plugin.vala
@@ -7,8 +7,7 @@ private class Games.WiiWarePlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index a070a38..188de46 100644
--- a/plugins/wii/src/wii-plugin.vala
+++ b/plugins/wii/src/wii-plugin.vala
@@ -6,8 +6,7 @@ private class Games.WiiPlugin : Object, Plugin {
public GameSource get_game_source () throws Error {
var game_uri_adapter = new GenericSyncGameUriAdapter (game_for_uri);
- var uri_test = new GenericMimeTypeUriTest (MIME_TYPE);
- var factory = new GenericUriGameFactory (game_uri_adapter, uri_test);
+ var factory = new GenericUriGameFactory (game_uri_adapter);
var query = new MimeTypeTrackerQuery (MIME_TYPE, factory);
var connection = Tracker.Sparql.Connection.@get ();
var source = new TrackerGameSource (connection);
diff --git a/src/Makefile.am b/src/Makefile.am
index 99345b9..69126be 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -53,7 +53,6 @@ gnome_games_SOURCES = \
core/title.vala \
core/uid.vala \
core/uri-game-factory.vala \
- core/uri-test.vala \
\
dummy/dummy-cover.vala \
dummy/dummy-game.vala \
@@ -82,7 +81,6 @@ gnome_games_SOURCES = \
gamepad/standard-gamepad-button.vala \
\
generic/generic-game.vala \
- generic/generic-mime-type-uri-test.vala \
generic/generic-sync-game-uri-adapter.vala \
generic/generic-title.vala \
generic/generic-uid.vala \
diff --git a/src/core/uri-game-factory.vala b/src/core/uri-game-factory.vala
index e3f5896..87a0b59 100644
--- a/src/core/uri-game-factory.vala
+++ b/src/core/uri-game-factory.vala
@@ -1,5 +1,4 @@
public interface Games.UriGameFactory : Object {
- public abstract bool is_uri_valid (string uri);
public abstract void add_uri (string uri);
public abstract Game game_for_uri (string uri) throws Error;
public abstract async void foreach_game (Games.GameCallback game_callback);
diff --git a/src/generic/generic-uri-game-factory.vala b/src/generic/generic-uri-game-factory.vala
index 28b47e2..002b599 100644
--- a/src/generic/generic-uri-game-factory.vala
+++ b/src/generic/generic-uri-game-factory.vala
@@ -4,26 +4,20 @@ public class Games.GenericUriGameFactory : Object, UriGameFactory {
private const uint HANDLED_URIS_PER_CYCLE = 5;
private GameUriAdapter game_uri_adapter;
- private UriTest uri_validity_test;
private string[] uris;
- public GenericUriGameFactory (GameUriAdapter game_uri_adapter, UriTest uri_validity_test) {
+ public GenericUriGameFactory (GameUriAdapter game_uri_adapter) {
this.game_uri_adapter = game_uri_adapter;
- this.uri_validity_test = uri_validity_test;
this.uris = {};
}
- public bool is_uri_valid (string uri) {
- return uri_validity_test.is_uri_valid (uri);
- }
-
public void add_uri (string uri) {
uris += uri;
}
public Game game_for_uri (string uri) throws Error {
- if (!is_uri_valid (uri))
- throw new GenericUriGameFactoryError.INVALID_URI ("Invalid URI: %s.", uri);
+// if (!is_uri_valid (uri))
+// throw new GenericUriGameFactoryError.INVALID_URI ("Invalid URI: %s.", uri);
return game_uri_adapter.game_for_uri (uri);
}
diff --git a/src/tracker/mime-type-tracker-query.vala b/src/tracker/mime-type-tracker-query.vala
index 429c088..dc47efe 100644
--- a/src/tracker/mime-type-tracker-query.vala
+++ b/src/tracker/mime-type-tracker-query.vala
@@ -16,7 +16,25 @@ public class Games.MimeTypeTrackerQuery : Object, TrackerQuery {
public bool is_cursor_valid (Tracker.Sparql.Cursor cursor) {
var uri = cursor.get_string (0);
- return uri_game_factory.is_uri_valid (uri);
+ return is_uri_valid (uri);
+ }
+
+ public bool is_uri_valid (string uri) {
+ var file = File.new_for_uri (uri);
+ if (!file.query_exists ())
+ return false;
+
+ try {
+ var info = file.query_info ("standard::content-type", FileQueryInfoFlags.NONE);
+ var actual_type = info.get_content_type ();
+
+ return ContentType.is_a (actual_type, mime_type);
+ }
+ catch (Error e) {
+ debug (e.message);
+
+ return false;
+ }
}
public void process_cursor (Tracker.Sparql.Cursor cursor) {
@@ -25,15 +43,8 @@ public class Games.MimeTypeTrackerQuery : Object, TrackerQuery {
}
public Game game_for_uri (string uri) throws Error {
- // FIXME
-// if (!uri.has_prefix ("file:") || !uri.has_suffix (".libretro"))
-// throw new LibretroError.NOT_A_LIBRETRO_DESCRIPTOR ("This isn’t a Libretro core
descriptor: %s", uri);
-
-// var file = File.new_for_uri (uri);
-// if (!file.query_exists ())
-// throw new LibretroError.NOT_A_LIBRETRO_DESCRIPTOR ("This isn’t a Libretro core
descriptor: %s", uri);
-
-// var path = file.get_path ();
+ if (!is_uri_valid (uri))
+ throw new GenericUriGameFactoryError.INVALID_URI ("Invalid URI: %s.", uri);
return uri_game_factory.game_for_uri (uri);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]