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



commit 5ced88ca5d42f998e73e2ef6ec1c0095b1580602
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 c3fcbb7..a724199 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -306,14 +306,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]