[gnome-games] Use the new Uri type



commit 1b85607c5f89f4f6838b9e2727b79312427c8d1f
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sat May 6 09:01:56 2017 +0200

    Use the new Uri type
    
    Replace usage of string in favor of the new Uri type to represent URIs
    wherever possible.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781334

 plugins/amiga/src/amiga-plugin.vala                |    2 +-
 plugins/atari-2600/src/atari-2600-plugin.vala      |    2 +-
 plugins/atari-7800/src/atari-7800-plugin.vala      |    2 +-
 plugins/desktop/src/desktop-plugin.vala            |   10 ++++----
 plugins/doom/src/doom-plugin.vala                  |    2 +-
 plugins/dreamcast/src/dreamcast-plugin.vala        |    4 +-
 .../src/game-boy-advance-plugin.vala               |    2 +-
 plugins/game-boy/src/game-boy-plugin.vala          |    4 +-
 plugins/game-cube/src/game-cube-plugin.vala        |    4 +-
 plugins/love/src/love-package.vala                 |   16 ++++++------
 plugins/love/src/love-plugin.vala                  |    4 +-
 plugins/love/src/love-title.vala                   |    2 +-
 plugins/mame/src/mame-game-uri-adapter.vala        |    6 ++--
 .../master-system/src/master-system-plugin.vala    |    6 ++--
 plugins/mega-drive/src/mega-drive-plugin.vala      |   12 +++++-----
 .../neo-geo-pocket/src/neo-geo-pocket-plugin.vala  |    2 +-
 plugins/nes/src/nes-plugin.vala                    |    4 +-
 plugins/nintendo-64/src/nintendo-64-plugin.vala    |    2 +-
 plugins/nintendo-ds/src/nintendo-ds-icon.vala      |    6 ++--
 plugins/nintendo-ds/src/nintendo-ds-plugin.vala    |    2 +-
 plugins/pc-engine/src/pc-engine-plugin.vala        |   10 ++++----
 .../playstation/src/playstation-game-factory.vala  |   14 +++++-----
 plugins/sega-saturn/src/sega-saturn-plugin.vala    |    6 ++--
 plugins/snes/src/snes-plugin.vala                  |    2 +-
 plugins/wii-ware/src/wii-ware-plugin.vala          |    2 +-
 plugins/wii/src/wii-plugin.vala                    |    4 +-
 src/core/game-uri-adapter.vala                     |    2 +-
 src/core/media.vala                                |    6 ++--
 src/core/uri-game-factory.vala                     |    4 +-
 src/core/uri-iterator.vala                         |    2 +-
 src/dummy/dummy-game.vala                          |    4 +-
 src/generic/generic-game-uri-adapter.vala          |    4 +-
 src/generic/generic-uri-game-factory.vala          |   10 +++-----
 src/generic/generic-uri-game-source.vala           |   24 ++++++++++++++-----
 src/retro/retro-runner.vala                        |    8 +++---
 src/tracker/tracker-uri-iterator.vala              |    6 ++--
 src/ui/application.vala                            |    6 ++--
 src/utils/filename-title.vala                      |    6 ++--
 src/utils/fingerprint.vala                         |   10 ++++----
 src/utils/local-cover.vala                         |    8 +++---
 40 files changed, 120 insertions(+), 112 deletions(-)
---
diff --git a/plugins/amiga/src/amiga-plugin.vala b/plugins/amiga/src/amiga-plugin.vala
index 71faeba..1d1b500 100644
--- a/plugins/amiga/src/amiga-plugin.vala
+++ b/plugins/amiga/src/amiga-plugin.vala
@@ -17,7 +17,7 @@ private class Games.AmigaPlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
diff --git a/plugins/atari-2600/src/atari-2600-plugin.vala b/plugins/atari-2600/src/atari-2600-plugin.vala
index ea8673a..384bf83 100644
--- a/plugins/atari-2600/src/atari-2600-plugin.vala
+++ b/plugins/atari-2600/src/atari-2600-plugin.vala
@@ -17,7 +17,7 @@ private class Games.Atari2600 : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
diff --git a/plugins/atari-7800/src/atari-7800-plugin.vala b/plugins/atari-7800/src/atari-7800-plugin.vala
index a2f2cff..8088ebe 100644
--- a/plugins/atari-7800/src/atari-7800-plugin.vala
+++ b/plugins/atari-7800/src/atari-7800-plugin.vala
@@ -17,7 +17,7 @@ private class Games.Atari7800 : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
diff --git a/plugins/desktop/src/desktop-plugin.vala b/plugins/desktop/src/desktop-plugin.vala
index e4bd19d..8760095 100644
--- a/plugins/desktop/src/desktop-plugin.vala
+++ b/plugins/desktop/src/desktop-plugin.vala
@@ -24,10 +24,10 @@ private class Games.DesktopPlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                check_uri (uri);
 
-               var file = File.new_for_uri (uri);
+               var file = uri.to_file ();
                var path = file.get_path ();
 
                var app_info = new DesktopAppInfo.from_filename (path);
@@ -44,11 +44,11 @@ private class Games.DesktopPlugin : Object, Plugin {
                return new GenericGame (title, icon, cover, runner);
        }
 
-       private static void check_uri (string uri) throws Error {
-               var file = File.new_for_uri (uri);
+       private static void check_uri (Uri uri) throws Error {
+               var file = uri.to_file ();
 
                if (!file.query_exists ())
-                       throw new IOError.NOT_FOUND (_("Tracker listed file not found: “%s”."), uri);
+                       throw new IOError.NOT_FOUND (_("Tracker listed file not found: “%s”."), uri.to_string 
());
 
                var path = file.get_path ();
                var app_info = new DesktopAppInfo.from_filename (path);
diff --git a/plugins/doom/src/doom-plugin.vala b/plugins/doom/src/doom-plugin.vala
index 952d9a1..6427032 100644
--- a/plugins/doom/src/doom-plugin.vala
+++ b/plugins/doom/src/doom-plugin.vala
@@ -17,7 +17,7 @@ private class Games.DoomPlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index 6241ad5..f4beb81 100644
--- a/plugins/dreamcast/src/dreamcast-plugin.vala
+++ b/plugins/dreamcast/src/dreamcast-plugin.vala
@@ -16,8 +16,8 @@ private class Games.DreamcastPlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
-               var file = File.new_for_uri (uri);
+       private static Game game_for_uri (Uri uri) throws Error {
+               var file = uri.to_file ();
                var header = new DreamcastHeader (file);
                header.check_validity ();
 
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 208d6e6..e845062 100644
--- a/plugins/game-boy-advance/src/game-boy-advance-plugin.vala
+++ b/plugins/game-boy-advance/src/game-boy-advance-plugin.vala
@@ -17,7 +17,7 @@ private class Games.GameBoyAdvancePlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
diff --git a/plugins/game-boy/src/game-boy-plugin.vala b/plugins/game-boy/src/game-boy-plugin.vala
index 142eaf0..63f4588 100644
--- a/plugins/game-boy/src/game-boy-plugin.vala
+++ b/plugins/game-boy/src/game-boy-plugin.vala
@@ -26,8 +26,8 @@ private class Games.GameBoyPlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
-               var file = File.new_for_uri (uri);
+       private static Game game_for_uri (Uri uri) throws Error {
+               var file = uri.to_file ();
                var header = new GameBoyHeader (file);
 
                string prefix;
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index b945052..1751bd9 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -16,8 +16,8 @@ private class Games.GameCubePlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
-               var file = File.new_for_uri (uri);
+       private static Game game_for_uri (Uri uri) throws Error {
+               var file = uri.to_file ();
                var header = new GameCubeHeader (file);
                header.check_validity ();
 
diff --git a/plugins/love/src/love-package.vala b/plugins/love/src/love-package.vala
index 3eed261..44c8308 100644
--- a/plugins/love/src/love-package.vala
+++ b/plugins/love/src/love-package.vala
@@ -3,18 +3,18 @@
 private class Games.LovePackage : Object {
        private const size_t BLOCK_SIZE = 4096;
 
-       private string uri;
+       private Uri uri;
        private HashTable<string, string> config;
 
-       public LovePackage (string uri) throws Error {
+       public LovePackage (Uri uri) throws Error {
                this.uri = uri;
 
                if (!contains_file ("main.lua"))
-                       throw new LoveError.INVALID_PACKAGE (_("This doesn’t represent a valid LÖVE package: 
“%s”."), uri);
+                       throw new LoveError.INVALID_PACKAGE (_("This doesn’t represent a valid LÖVE package: 
“%s”."), uri.to_string ());
 
                var config_file = get_file_string ("conf.lua");
                if (config_file == null)
-                       throw new LoveError.INVALID_PACKAGE (_("This doesn’t represent a valid LÖVE package: 
“%s”."), uri);
+                       throw new LoveError.INVALID_PACKAGE (_("This doesn’t represent a valid LÖVE package: 
“%s”."), uri.to_string ());
 
                var regex = /^\s*[^\s]+\.([^\s\.]+)\s*=\s*(.+?)\s*$/;
 
@@ -30,7 +30,7 @@ private class Games.LovePackage : Object {
                        }
        }
 
-       public string get_uri () {
+       public Uri get_uri () {
                return uri;
        }
 
@@ -42,7 +42,7 @@ private class Games.LovePackage : Object {
        }
 
        public bool contains_file (string path_in_archive) {
-               var file = File.new_for_uri (uri);
+               var file = uri.to_file ();
                var path = file.get_path ();
 
                Archive.Read archive = new Archive.Read ();
@@ -67,7 +67,7 @@ private class Games.LovePackage : Object {
        }
 
        public InputStream? get_file_input_stream (string path_in_archive) {
-               var file = File.new_for_uri (uri);
+               var file = uri.to_file ();
                var path = file.get_path ();
 
                Archive.Read archive = new Archive.Read ();
@@ -94,7 +94,7 @@ private class Games.LovePackage : Object {
        }
 
        public string? get_file_string (string path_in_archive) {
-               var file = File.new_for_uri (uri);
+               var file = uri.to_file ();
                var path = file.get_path ();
 
                Archive.Read archive = new Archive.Read ();
diff --git a/plugins/love/src/love-plugin.vala b/plugins/love/src/love-plugin.vala
index ca94af4..206c4b9 100644
--- a/plugins/love/src/love-plugin.vala
+++ b/plugins/love/src/love-plugin.vala
@@ -15,12 +15,12 @@ private class Games.LovePlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var package = new LovePackage (uri);
                var title = new LoveTitle (package);
                var icon = new LoveIcon (package);
                var cover = new LocalCover (uri);
-               string[] args = { "love", uri };
+               string[] args = { "love", uri.to_string () };
                var runner = new CommandRunner (args, true);
 
                return new GenericGame (title, icon, cover, runner);
diff --git a/plugins/love/src/love-title.vala b/plugins/love/src/love-title.vala
index 45e46e1..6164629 100644
--- a/plugins/love/src/love-title.vala
+++ b/plugins/love/src/love-title.vala
@@ -21,7 +21,7 @@ private class Games.LoveTitle : Object, Title {
                        return title;
 
                var uri = package.get_uri ();
-               var file = File.new_for_uri (uri);
+               var file = uri.to_file ();
                title = file.get_basename ();
                title = title.split (".")[0];
                title = title.split ("(")[0];
diff --git a/plugins/mame/src/mame-game-uri-adapter.vala b/plugins/mame/src/mame-game-uri-adapter.vala
index ee18949..135c568 100644
--- a/plugins/mame/src/mame-game-uri-adapter.vala
+++ b/plugins/mame/src/mame-game-uri-adapter.vala
@@ -5,15 +5,15 @@ private class Games.MameGameUriAdapter : GameUriAdapter, Object {
        private const string SPECIFIC_MIME_TYPE = "application/x-mame-rom";
        private const string PLATFORM = "MAME";
 
-       public async Game game_for_uri (string uri) throws Error {
+       public async Game game_for_uri (Uri uri) throws Error {
                var supported_games = yield MameGameInfo.get_supported_games ();
 
-               var file = File.new_for_uri (uri);
+               var file = uri.to_file ();
                var game_id = file.get_basename ();
                game_id = /\.zip$/.replace (game_id, game_id.length, 0, "");
 
                if (!supported_games.contains (game_id))
-                       throw new MameError.INVALID_GAME_ID (_("Invalid MAME game id “%s” for “%s”."), 
game_id, uri);
+                       throw new MameError.INVALID_GAME_ID (_("Invalid MAME game id “%s” for “%s”."), 
game_id, uri.to_string ());
 
                var uid_string = @"mame-$game_id".down ();
                var uid = new GenericUid (uid_string);
diff --git a/plugins/master-system/src/master-system-plugin.vala 
b/plugins/master-system/src/master-system-plugin.vala
index 6145a14..080cf20 100644
--- a/plugins/master-system/src/master-system-plugin.vala
+++ b/plugins/master-system/src/master-system-plugin.vala
@@ -34,8 +34,8 @@ private class Games.MasterSystemPlugin : Object, Plugin {
                return { factory, sg_1000_factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
-               var file = File.new_for_uri (uri);
+       private static Game game_for_uri (Uri uri) throws Error {
+               var file = uri.to_file ();
                var header = new MasterSystemHeader (file);
                header.check_validity ();
 
@@ -68,7 +68,7 @@ private class Games.MasterSystemPlugin : Object, Plugin {
                return new GenericGame (title, icon, cover, runner);
        }
 
-       private static Game sg_1000_game_for_uri (string uri) throws Error {
+       private static Game sg_1000_game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, SG_1000_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
diff --git a/plugins/mega-drive/src/mega-drive-plugin.vala b/plugins/mega-drive/src/mega-drive-plugin.vala
index df18d0a..69d104d 100644
--- a/plugins/mega-drive/src/mega-drive-plugin.vala
+++ b/plugins/mega-drive/src/mega-drive-plugin.vala
@@ -44,8 +44,8 @@ private class Games.MegaDrivePlugin : Object, Plugin {
                return { factory, mega_cd_factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
-               var file = File.new_for_uri (uri);
+       private static Game game_for_uri (Uri uri) throws Error {
+               var file = uri.to_file ();
                var header = new MegaDriveHeader (file);
                header.check_validity ();
 
@@ -83,8 +83,8 @@ private class Games.MegaDrivePlugin : Object, Plugin {
                return new GenericGame (title, icon, cover, runner);
        }
 
-       private static Game cd_game_for_uri (string uri) throws Error {
-               var file = File.new_for_uri (uri);
+       private static Game cd_game_for_uri (Uri uri) throws Error {
+               var file = uri.to_file ();
                var file_info = file.query_info (FileAttribute.STANDARD_CONTENT_TYPE, 
FileQueryInfoFlags.NONE);
                var mime_type = file_info.get_content_type ();
 
@@ -100,7 +100,7 @@ private class Games.MegaDrivePlugin : Object, Plugin {
 
                        break;
                default:
-                       throw new MegaDriveError.INVALID_FILE_TYPE ("Invalid file type: expected %s or %s but 
got %s for file %s.", CUE_MIME_TYPE, MEGA_CD_MIME_TYPE, mime_type, uri);
+                       throw new MegaDriveError.INVALID_FILE_TYPE ("Invalid file type: expected %s or %s but 
got %s for file %s.", CUE_MIME_TYPE, MEGA_CD_MIME_TYPE, mime_type, uri.to_string ());
                }
 
                var header = new MegaDriveHeader (bin_file);
@@ -119,7 +119,7 @@ private class Games.MegaDrivePlugin : Object, Plugin {
                else
                        assert_not_reached ();
 
-               var bin_uri = bin_file.get_uri ();
+               var bin_uri = new Uri (bin_file.get_uri ());
                var header_offset = header.get_offset ();
                var uid = new FingerprintUid.for_chunk (bin_uri, MEGA_CD_PREFIX, header_offset, 
MegaDriveHeader.HEADER_LENGTH);
                var title = new FilenameTitle (uri);
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 94a995e..0ce2928 100644
--- a/plugins/neo-geo-pocket/src/neo-geo-pocket-plugin.vala
+++ b/plugins/neo-geo-pocket/src/neo-geo-pocket-plugin.vala
@@ -17,7 +17,7 @@ private class Games.NeoGeoPocketPlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
diff --git a/plugins/nes/src/nes-plugin.vala b/plugins/nes/src/nes-plugin.vala
index a00565c..2484dc6 100644
--- a/plugins/nes/src/nes-plugin.vala
+++ b/plugins/nes/src/nes-plugin.vala
@@ -31,7 +31,7 @@ private class Games.NesPlugin : Object, Plugin {
                return { nes_factory, fds_factory };
        }
 
-       private static Game nes_game_for_uri (string uri) throws Error {
+       private static Game nes_game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, NES_FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
@@ -45,7 +45,7 @@ private class Games.NesPlugin : Object, Plugin {
                return new GenericGame (title, icon, cover, runner);
        }
 
-       private static Game fds_game_for_uri (string uri) throws Error {
+       private static Game fds_game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FDS_FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
diff --git a/plugins/nintendo-64/src/nintendo-64-plugin.vala b/plugins/nintendo-64/src/nintendo-64-plugin.vala
index f1e96ce..ef7d1db 100644
--- a/plugins/nintendo-64/src/nintendo-64-plugin.vala
+++ b/plugins/nintendo-64/src/nintendo-64-plugin.vala
@@ -17,7 +17,7 @@ private class Games.Nintendo64Plugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
diff --git a/plugins/nintendo-ds/src/nintendo-ds-icon.vala b/plugins/nintendo-ds/src/nintendo-ds-icon.vala
index fb1eb11..3a5d0a5 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-icon.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-icon.vala
@@ -1,16 +1,16 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 public class Games.NintendoDsIcon : Object, Icon {
-       private string uri;
+       private Uri uri;
        private bool extracted;
        private Gdk.Pixbuf pixbuf;
 
-       public NintendoDsIcon (string uri) {
+       public NintendoDsIcon (Uri uri) {
                this.uri = uri;
                extracted = false;
        }
 
-       private static extern Gdk.Pixbuf extract (string uri) throws Error;
+       private static extern Gdk.Pixbuf extract (Uri uri) throws Error;
 
        public GLib.Icon? get_icon () {
                if (extracted)
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index 24e6034..ebd86ca 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -17,7 +17,7 @@ private class Games.NintendoDsPlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new NintendoDsIcon (uri);
diff --git a/plugins/pc-engine/src/pc-engine-plugin.vala b/plugins/pc-engine/src/pc-engine-plugin.vala
index 0489eab..a6370de 100644
--- a/plugins/pc-engine/src/pc-engine-plugin.vala
+++ b/plugins/pc-engine/src/pc-engine-plugin.vala
@@ -29,7 +29,7 @@ private class Games.PcEnginePlugin : Object, Plugin {
                return { factory, cd_factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
@@ -43,9 +43,9 @@ private class Games.PcEnginePlugin : Object, Plugin {
                return new GenericGame (title, icon, cover, runner);
        }
 
-       private static Game cd_game_for_uri (string uri) throws Error {
+       private static Game cd_game_for_uri (Uri uri) throws Error {
                if (!is_valid_disc (uri))
-                       throw new PcEngineError.INVALID_DISC ("“%s” isn’t a valid PC-Engine CD-ROM² disc.", 
uri);
+                       throw new PcEngineError.INVALID_DISC ("“%s” isn’t a valid PC-Engine CD-ROM² disc.", 
uri.to_string ());
 
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
@@ -60,8 +60,8 @@ private class Games.PcEnginePlugin : Object, Plugin {
                return new GenericGame (title, icon, cover, runner);
        }
 
-       private static bool is_valid_disc (string uri) throws Error {
-               var file = File.new_for_uri (uri);
+       private static bool is_valid_disc (Uri uri) throws Error {
+               var file = uri.to_file ();
                var file_info = file.query_info (FileAttribute.STANDARD_CONTENT_TYPE, 
FileQueryInfoFlags.NONE);
                var mime_type = file_info.get_content_type ();
 
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index 26e3f87..06a45a5 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -10,14 +10,14 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
        private static GameinfoDoc gameinfo;
 
        private HashTable<string, Media> media_for_disc_id;
-       private HashTable<string, Game> game_for_uri;
+       private HashTable<Uri, Game> game_for_uri;
        private HashTable<string, Game> game_for_disc_set_id;
        private GenericSet<Game> games;
 
 
        public PlayStationGameFactory () {
                media_for_disc_id = new HashTable<string, Media> (str_hash, str_equal);
-               game_for_uri = new HashTable<string, Game> (GLib.str_hash, GLib.str_equal);
+               game_for_uri = new HashTable<Uri, Game> (Uri.hash, Uri.equal);
                game_for_disc_set_id = new HashTable<string, Game> (GLib.str_hash, GLib.str_equal);
                games = new GenericSet<Game> (direct_hash, direct_equal);
        }
@@ -26,7 +26,7 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                return { CUE_MIME_TYPE };
        }
 
-       public async Game? query_game_for_uri (string uri) {
+       public async Game? query_game_for_uri (Uri uri) {
                Idle.add (this.query_game_for_uri.callback);
                yield;
 
@@ -36,7 +36,7 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                return null;
        }
 
-       public async void add_uri (string uri) {
+       public async void add_uri (Uri uri) {
                try {
                        add_uri_with_error (uri);
                }
@@ -46,11 +46,11 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
        }
 
        // TODO support unknown games (not in DB)
-       private void add_uri_with_error (string uri) throws Error {
+       private void add_uri_with_error (Uri uri) throws Error {
                if (game_for_uri.contains (uri))
                        return;
 
-               var file = File.new_for_uri (uri);
+               var file = uri.to_file ();
                var file_info = file.query_info (FileAttribute.STANDARD_CONTENT_TYPE, 
FileQueryInfoFlags.NONE);
                var mime_type = file_info.get_content_type ();
 
@@ -128,7 +128,7 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                games.foreach ((game) => game_callback (game));
        }
 
-       private Game create_game (MediaSet media_set, string disc_set_id, string uri) throws Error {
+       private Game create_game (MediaSet media_set, string disc_set_id, Uri uri) throws Error {
                var gameinfo = get_gameinfo ();
                var uid = new PlayStationUid (disc_set_id);
                var title = new CompositeTitle ({
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index a4c670a..771f125 100644
--- a/plugins/sega-saturn/src/sega-saturn-plugin.vala
+++ b/plugins/sega-saturn/src/sega-saturn-plugin.vala
@@ -21,8 +21,8 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
-               var file = File.new_for_uri (uri);
+       private static Game game_for_uri (Uri uri) throws Error {
+               var file = uri.to_file ();
                var file_info = file.query_info (FileAttribute.STANDARD_CONTENT_TYPE, 
FileQueryInfoFlags.NONE);
                var mime_type = file_info.get_content_type ();
 
@@ -38,7 +38,7 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
 
                        break;
                default:
-                       throw new SegaSaturnError.INVALID_FILE_TYPE ("Invalid file type: expected %s or %s 
but got %s for file %s.", CUE_MIME_TYPE, SEGA_SATURN_MIME_TYPE, mime_type, uri);
+                       throw new SegaSaturnError.INVALID_FILE_TYPE ("Invalid file type: expected %s or %s 
but got %s for file %s.", CUE_MIME_TYPE, SEGA_SATURN_MIME_TYPE, mime_type, uri.to_string ());
                }
 
                var header = new SegaSaturnHeader (bin_file);
diff --git a/plugins/snes/src/snes-plugin.vala b/plugins/snes/src/snes-plugin.vala
index 45b4ed9..6637ce0 100644
--- a/plugins/snes/src/snes-plugin.vala
+++ b/plugins/snes/src/snes-plugin.vala
@@ -17,7 +17,7 @@ private class Games.SnesPlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
diff --git a/plugins/wii-ware/src/wii-ware-plugin.vala b/plugins/wii-ware/src/wii-ware-plugin.vala
index c568b25..5a27767 100644
--- a/plugins/wii-ware/src/wii-ware-plugin.vala
+++ b/plugins/wii-ware/src/wii-ware-plugin.vala
@@ -17,7 +17,7 @@ private class Games.WiiWarePlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
+       private static Game game_for_uri (Uri uri) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index a851aa1..9ee9311 100644
--- a/plugins/wii/src/wii-plugin.vala
+++ b/plugins/wii/src/wii-plugin.vala
@@ -16,8 +16,8 @@ private class Games.WiiPlugin : Object, Plugin {
                return { factory };
        }
 
-       private static Game game_for_uri (string uri) throws Error {
-               var file = File.new_for_uri (uri);
+       private static Game game_for_uri (Uri uri) throws Error {
+               var file = uri.to_file ();
                var header = new WiiHeader (file);
                header.check_validity ();
 
diff --git a/src/core/game-uri-adapter.vala b/src/core/game-uri-adapter.vala
index 65ae670..8e97086 100644
--- a/src/core/game-uri-adapter.vala
+++ b/src/core/game-uri-adapter.vala
@@ -1,5 +1,5 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 public interface Games.GameUriAdapter : Object {
-       public abstract async Game game_for_uri (string uri) throws Error;
+       public abstract async Game game_for_uri (Uri uri) throws Error;
 }
diff --git a/src/core/media.vala b/src/core/media.vala
index d9d8f17..292bf5f 100644
--- a/src/core/media.vala
+++ b/src/core/media.vala
@@ -3,18 +3,18 @@
 public class Games.Media : Object {
        public Title? title { get; private set; }
 
-       private string[] uris;
+       private Uri[] uris;
 
        public Media (Title? title = null) {
                this.title = title;
                this.uris = {};
        }
 
-       public string[] get_uris () {
+       public Uri[] get_uris () {
                return uris;
        }
 
-       public void add_uri (string uri) {
+       public void add_uri (Uri uri) {
                uris += uri;
        }
 }
diff --git a/src/core/uri-game-factory.vala b/src/core/uri-game-factory.vala
index e5ada50..152af39 100644
--- a/src/core/uri-game-factory.vala
+++ b/src/core/uri-game-factory.vala
@@ -2,7 +2,7 @@ public interface Games.UriGameFactory : Object {
        public signal void game_added (Game game);
 
        public abstract string[] get_mime_types ();
-       public abstract async void add_uri (string uri);
-       public abstract async Game? query_game_for_uri (string uri);
+       public abstract async void add_uri (Uri uri);
+       public abstract async Game? query_game_for_uri (Uri uri);
        public abstract async void foreach_game (Games.GameCallback game_callback);
 }
diff --git a/src/core/uri-iterator.vala b/src/core/uri-iterator.vala
index 964a22c..f548883 100644
--- a/src/core/uri-iterator.vala
+++ b/src/core/uri-iterator.vala
@@ -1,6 +1,6 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 public interface Games.UriIterator : Object {
-       public abstract new string? get ();
+       public abstract new Uri? get ();
        public abstract bool next ();
 }
diff --git a/src/dummy/dummy-game.vala b/src/dummy/dummy-game.vala
index 69c3251..980abff 100644
--- a/src/dummy/dummy-game.vala
+++ b/src/dummy/dummy-game.vala
@@ -10,8 +10,8 @@ private class Games.DummyGame : Object, Game {
                _name = name;
        }
 
-       public DummyGame.for_uri (string uri) {
-               var file = File.new_for_uri (uri);
+       public DummyGame.for_uri (Uri uri) {
+               var file = uri.to_file ();
                var name = file.get_basename ();
                name = name.split (".")[0];
                name = name.split ("(")[0];
diff --git a/src/generic/generic-game-uri-adapter.vala b/src/generic/generic-game-uri-adapter.vala
index c55501c..e3b957b 100644
--- a/src/generic/generic-game-uri-adapter.vala
+++ b/src/generic/generic-game-uri-adapter.vala
@@ -1,7 +1,7 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 public class Games.GenericGameUriAdapter : GameUriAdapter, Object {
-       public delegate Game GameForUri (string uri) throws Error;
+       public delegate Game GameForUri (Uri uri) throws Error;
 
        private GameForUri callback;
 
@@ -9,7 +9,7 @@ public class Games.GenericGameUriAdapter : GameUriAdapter, Object {
                this.callback = (owned) callback;
        }
 
-       public async Game game_for_uri (string uri) throws Error {
+       public async Game game_for_uri (Uri uri) throws Error {
                Idle.add (this.game_for_uri.callback);
                yield;
 
diff --git a/src/generic/generic-uri-game-factory.vala b/src/generic/generic-uri-game-factory.vala
index c1015ee..31077b5 100644
--- a/src/generic/generic-uri-game-factory.vala
+++ b/src/generic/generic-uri-game-factory.vala
@@ -4,14 +4,12 @@ public class Games.GenericUriGameFactory : Object, UriGameFactory {
        private const uint GAMES_PER_CYCLE = 4;
 
        private GameUriAdapter game_uri_adapter;
-       private HashTable<string, Game> game_for_uri;
-       private string[] uris;
+       private HashTable<Uri, Game> game_for_uri;
        private string[] mime_types;
 
        public GenericUriGameFactory (GameUriAdapter game_uri_adapter) {
                this.game_uri_adapter = game_uri_adapter;
-               game_for_uri = new HashTable<string, Game> (str_hash, str_equal);
-               uris = {};
+               game_for_uri = new HashTable<Uri, Game> (Uri.hash, Uri.equal);
                mime_types = {};
        }
 
@@ -23,7 +21,7 @@ public class Games.GenericUriGameFactory : Object, UriGameFactory {
                mime_types += mime_type;
        }
 
-       public async void add_uri (string uri) {
+       public async void add_uri (Uri uri) {
                Idle.add (this.add_uri.callback);
                yield;
 
@@ -41,7 +39,7 @@ public class Games.GenericUriGameFactory : Object, UriGameFactory {
                }
        }
 
-       public async Game? query_game_for_uri (string uri) {
+       public async Game? query_game_for_uri (Uri uri) {
                Idle.add (this.query_game_for_uri.callback);
                yield;
 
diff --git a/src/generic/generic-uri-game-source.vala b/src/generic/generic-uri-game-source.vala
index c877e70..653923f 100644
--- a/src/generic/generic-uri-game-source.vala
+++ b/src/generic/generic-uri-game-source.vala
@@ -28,12 +28,12 @@ public class Games.GenericUriGameSource : Object, GameSource {
                factory.game_added.connect ((game) => game_added (game));
        }
 
-       public async void add_uri (string uri) {
+       public async void add_uri (Uri uri) {
                foreach (var factory in yield get_factories_for_uri (uri))
                        yield factory.add_uri (uri);
        }
 
-       public async Game? query_game_for_uri (string uri) {
+       public async Game? query_game_for_uri (Uri uri) {
                Game[] games = {};
                foreach (var factory in yield get_factories_for_uri (uri)) {
                        var game = yield factory.query_game_for_uri (uri);
@@ -56,15 +56,26 @@ public class Games.GenericUriGameSource : Object, GameSource {
                        yield factory.foreach_game (callback);
        }
 
-       private async UriGameFactory[] get_factories_for_uri (string uri) {
+       private async UriGameFactory[] get_factories_for_uri (Uri uri) {
                Idle.add (get_factories_for_uri.callback);
                yield;
 
                UriGameFactory[] factories = {};
 
-               if (uri.has_prefix ("file:")) {
+               string scheme;
+               try {
+                       scheme = uri.get_scheme ();
+               }
+               catch (Error e) {
+                       debug (e.message);
+
+                       return factories;
+               }
+
+               if (scheme == "file") {
                        try {
-                               foreach (var factory in yield get_factories_for_file (uri))
+                               var file = uri.to_file ();
+                               foreach (var factory in yield get_factories_for_file (file))
                                        factories += factory;
                        }
                        catch (Error e) {
@@ -76,8 +87,7 @@ public class Games.GenericUriGameSource : Object, GameSource {
                return factories;
        }
 
-       private async UriGameFactory[] get_factories_for_file (string uri) throws Error {
-               var file = File.new_for_uri (uri);
+       private async UriGameFactory[] get_factories_for_file (File file) throws Error {
                if (!file.query_exists ())
                        return {};
 
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index d3fd25e..0be9d0b 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -70,7 +70,7 @@ public class Games.RetroRunner : Object, Runner {
        private bool is_ready;
        private bool should_save;
 
-       public RetroRunner (RetroCoreSource core_source, string uri, Uid uid, Title game_title) {
+       public RetroRunner (RetroCoreSource core_source, Uri uri, Uid uid, Title game_title) {
                is_initialized = false;
                is_ready = false;
                should_save = false;
@@ -219,7 +219,7 @@ public class Games.RetroRunner : Object, Runner {
 
                        var uri = uris[0];
                        if (!try_load_game (core, uri))
-                               throw new RetroError.INVALID_GAME_FILE (_("Invalid game file: “%s”."), uri);
+                               throw new RetroError.INVALID_GAME_FILE (_("Invalid game file: “%s”."), 
uri.to_string ());
                }
 
                core.shutdown.connect (on_shutdown);
@@ -287,8 +287,8 @@ public class Games.RetroRunner : Object, Runner {
                core.init ();
        }
 
-       private bool try_load_game (Retro.Core core, string uri) {
-               var file = File.new_for_uri (uri);
+       private bool try_load_game (Retro.Core core, Uri uri) {
+               var file = uri.to_file ();
                var path = file.get_path ();
 
                try {
diff --git a/src/tracker/tracker-uri-iterator.vala b/src/tracker/tracker-uri-iterator.vala
index db3381a..f04130d 100644
--- a/src/tracker/tracker-uri-iterator.vala
+++ b/src/tracker/tracker-uri-iterator.vala
@@ -4,7 +4,7 @@ private class Games.TrackerUriIterator : Object, UriIterator {
        private Tracker.Sparql.Connection connection;
        private TrackerUriQuery[] queries;
        private int query_index;
-       private string? uri;
+       private Uri? uri;
        private Tracker.Sparql.Cursor cursor;
 
        internal TrackerUriIterator (Tracker.Sparql.Connection connection, TrackerUriQuery[] queries) {
@@ -15,7 +15,7 @@ private class Games.TrackerUriIterator : Object, UriIterator {
                cursor = null;
        }
 
-       public new string? get () {
+       public new Uri? get () {
                return uri;
        }
 
@@ -54,7 +54,7 @@ private class Games.TrackerUriIterator : Object, UriIterator {
                if (!cursor.next ())
                        return false;
 
-               uri = cursor.get_string (0);
+               uri = new Uri (cursor.get_string (0));
 
                return true;
        }
diff --git a/src/ui/application.vala b/src/ui/application.vala
index d4e9263..8bb16e5 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -121,9 +121,9 @@ public class Games.Application : Gtk.Application {
                if (files.length == 0)
                        return;
 
-               string[] uris = {};
+               Uri[] uris = {};
                foreach (var file in files)
-                       uris += file.get_uri ();
+                       uris += new Uri.from_file (file);
 
                var game = yield game_for_uris (uris);
 
@@ -212,7 +212,7 @@ public class Games.Application : Gtk.Application {
                }
        }
 
-       private async Game? game_for_uris (string[] uris) {
+       private async Game? game_for_uris (Uri[] uris) {
                init_game_sources ();
 
                Game? game = null;
diff --git a/src/utils/filename-title.vala b/src/utils/filename-title.vala
index eed88ce..975e86e 100644
--- a/src/utils/filename-title.vala
+++ b/src/utils/filename-title.vala
@@ -3,18 +3,18 @@
 public class Games.FilenameTitle : Object, Title {
        private static Regex filename_ext_regex;
 
-       private string uri;
+       private Uri uri;
 
        static construct {
                filename_ext_regex = /\.\w+$/;
        }
 
-       public FilenameTitle (string uri) {
+       public FilenameTitle (Uri uri) {
                this.uri = uri;
        }
 
        public string get_title () throws Error {
-               var file = File.new_for_uri (uri);
+               var file = uri.to_file ();
                var name = file.get_basename ();
                name = filename_ext_regex.replace (name, name.length, 0, "");
                name = name.split ("(")[0];
diff --git a/src/utils/fingerprint.vala b/src/utils/fingerprint.vala
index 3ae2fc6..d1f5fc3 100644
--- a/src/utils/fingerprint.vala
+++ b/src/utils/fingerprint.vala
@@ -1,8 +1,8 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 namespace Games.Fingerprint {
-       private string get_for_file_uri (string uri, size_t start, size_t? length) throws Error {
-               var file = File.new_for_uri (uri);
+       private string get_for_file_uri (Uri uri, size_t start, size_t? length) throws Error {
+               var file = uri.to_file ();
                var istream = file.read ();
 
                return get_for_file_input_stream (istream, start, length);
@@ -25,20 +25,20 @@ namespace Games.Fingerprint {
 }
 
 public class Games.FingerprintUid: Object, Uid {
-       private string uri;
+       private Uri uri;
        private string prefix;
        private size_t start;
        private size_t? length;
        private string uid;
 
-       public FingerprintUid (string uri, string prefix) {
+       public FingerprintUid (Uri uri, string prefix) {
                this.uri = uri;
                this.prefix = prefix;
                start = 0;
                length = null;
        }
 
-       public FingerprintUid.for_chunk (string uri, string prefix, size_t start, size_t length) {
+       public FingerprintUid.for_chunk (Uri uri, string prefix, size_t start, size_t length) {
                this.uri = uri;
                this.prefix = prefix;
                this.start = start;
diff --git a/src/utils/local-cover.vala b/src/utils/local-cover.vala
index 4ad02a9..4172758 100644
--- a/src/utils/local-cover.vala
+++ b/src/utils/local-cover.vala
@@ -1,11 +1,11 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 public class Games.LocalCover : Object, Cover {
-       private string uri;
+       private Uri uri;
        private bool resolved;
        private GLib.Icon? icon;
 
-       public LocalCover (string uri) {
+       public LocalCover (Uri uri) {
                this.uri = uri;
        }
 
@@ -47,7 +47,7 @@ public class Games.LocalCover : Object, Cover {
        }
 
        private string? get_sibbling_cover_path () throws Error {
-               var file = File.new_for_uri (uri);
+               var file = uri.to_file ();
                var parent = file.get_parent ();
                if (parent == null)
                        return null;
@@ -80,7 +80,7 @@ public class Games.LocalCover : Object, Cover {
        }
 
        private string? get_directory_cover_path () throws Error {
-               var file = File.new_for_uri (uri);
+               var file = uri.to_file ();
                var parent = file.get_parent ();
                if (parent == null)
                        return null;



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