[gnome-boxes] wizard-source, downloader: Unify supported uri schemes



commit 7627d336cc6d692cab871ae63c0c5728de88c17a
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Nov 21 13:52:33 2017 +0100

    wizard-source, downloader: Unify supported uri schemes
    
    Lets define the supported URI schemes in the Downloader singleton,
    making it easy to introduce support for new protocols in  the
    future, updating a single store.

 src/downloader.vala    |    7 ++++++-
 src/wizard-source.vala |    3 +--
 2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/downloader.vala b/src/downloader.vala
index ae870bd..53397cc 100644
--- a/src/downloader.vala
+++ b/src/downloader.vala
@@ -23,6 +23,11 @@ private class Boxes.Downloader : GLib.Object {
     public signal void downloaded (Download download);
     public signal void download_failed (Download download, GLib.Error error);
 
+    public static string[] supported_schemes = {
+        "http",
+        "https",
+    };
+
     public static Downloader get_instance () {
         if (downloader == null)
             downloader = new Downloader ();
@@ -94,7 +99,7 @@ private class Boxes.Downloader : GLib.Object {
         downloads.set (uri, download);
 
         try {
-            if (remote_file.has_uri_scheme ("http") || remote_file.has_uri_scheme ("https"))
+            if (remote_file.get_uri_scheme () in supported_schemes)
                 yield download_from_http (download, cancellable);
             else
                 yield download_from_filesystem (download, cancellable);
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 8f4b608..96136f7 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -319,10 +319,9 @@ private class Boxes.WizardSource: Gtk.Stack {
 
     public bool download_required {
         get {
-            const string[] supported_schemes = { "http", "https" };
             string scheme = Uri.parse_scheme (uri);
 
-            return (scheme != null && scheme in supported_schemes);
+            return (scheme != null && scheme in Downloader.supported_schemes);
         }
     }
 


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