[gnome-boxes/wip/rishi/rhel: 9/16] wizard: Allow a custom filename when sanity-checking downloadable URIs



commit ae5dae584db586b591f191d6f314c83cd9c55428
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Aug 31 20:33:18 2017 +0200

    wizard: Allow a custom filename when sanity-checking downloadable URIs
    
    https://bugzilla.gnome.org/show_bug.cgi?id=786679

 src/wizard.vala |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/wizard.vala b/src/wizard.vala
index 40ce8a9..dccaca6 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -305,14 +305,20 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
         prepare_for_uri (file.get_uri ());
     }
 
-    private void prepare_for_uri (string uri_as_text) throws Boxes.Error {
+    private void prepare_for_uri (string uri_as_text, string? filename = null) throws Boxes.Error {
         var uri = Xml.URI.parse (uri_as_text);
         if (uri == null || uri.scheme == null)
             throw new Boxes.Error.INVALID (_("Invalid URL"));
 
         if (wizard_source.download_required) {
-            var file = File.new_for_uri (uri_as_text);
-            var basename = file.get_basename ();
+            string? basename = null;
+
+            if (filename == null) {
+                var file = File.new_for_uri (uri_as_text);
+                basename = file.get_basename ();
+            } else {
+                basename = filename;
+            }
 
             if (basename == null || basename == "" || basename == "/")
                 throw new Boxes.Error.INVALID (_("Invalid URL"));


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