[gnome-boxes] Split prepare_for_uri ()
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Split prepare_for_uri ()
- Date: Sat, 29 Oct 2011 00:24:42 +0000 (UTC)
commit 06c561de22d004f25bdb9234b0dc73ab34aa14e2
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Sat Oct 29 02:22:42 2011 +0200
Split prepare_for_uri ()
src/wizard.vala | 62 +++++++++++++++++++++++++++++++------------------------
1 files changed, 35 insertions(+), 27 deletions(-)
---
diff --git a/src/wizard.vala b/src/wizard.vala
index 46fe667..183ce06 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -82,40 +82,48 @@ private class Boxes.Wizard: Boxes.UI {
return true;
}
- private void prepare_with_uri (string text) throws Boxes.Error {
+ private void prepare_for_location (string location) throws Boxes.Error {
bool uncertain;
- var mimetype = ContentType.guess (text, null, out uncertain);
- var uri = Xml.URI.parse (text);
+ var mimetype = ContentType.guess (location, null, out uncertain);
- if (uncertain) {
- if (uri.server == null)
- throw new Boxes.Error.INVALID ("the URI is invalid");
+ if (uncertain)
+ prepare_for_uri (location);
+ else
+ debug ("FIXME: %s".printf (mimetype));
+ }
- if (uri.scheme == "spice" || uri.scheme == "vnc") {
- source = new CollectionSource (uri.server, uri.scheme, text);
- summary.add_property (_("Type"), uri.scheme.up ());
- summary.add_property (_("Host"), uri.server.down ());
+ private void prepare_for_uri (string uri_as_text) throws Boxes.Error {
+ var uri = Xml.URI.parse (uri_as_text);
- if (uri.scheme == "spice") {
- if (uri.query_raw == null && uri.query == null)
- throw new Boxes.Error.INVALID ("the Spice URI is incomplete");
+ if (uri.server == null)
+ throw new Boxes.Error.INVALID ("the URI is invalid");
- var query = new Query (uri.query_raw ?? uri.query);
+ source = new CollectionSource (uri.server, uri.scheme, uri_as_text);
+ summary.add_property (_("Type"), uri.scheme.up ());
+ summary.add_property (_("Host"), uri.server.down ());
- if (uri.port > 0)
- throw new Boxes.Error.INVALID ("the Spice URI is invalid");
+ switch (uri.scheme) {
+ case "spice":
+ if (uri.query_raw == null && uri.query == null)
+ throw new Boxes.Error.INVALID ("the Spice URI is incomplete");
- summary.add_property (_("Port"), query.get ("port"));
- summary.add_property (_("TLS Port"), query.get ("tls-port"));
- } else {
- if (uri.port > 0)
- summary.add_property (_("Port"), uri.port.to_string ());
- }
- } else
- throw new Boxes.Error.INVALID ("Unsupported protocol");
- } else {
- debug ("FIXME: %s".printf (mimetype));
+ var query = new Query (uri.query_raw ?? uri.query);
+
+ if (uri.port > 0)
+ throw new Boxes.Error.INVALID ("the Spice URI is invalid");
+
+ summary.add_property (_("Port"), query.get ("port"));
+ summary.add_property (_("TLS Port"), query.get ("tls-port"));
+ break;
+
+ case "vnc":
+ if (uri.port > 0)
+ summary.add_property (_("Port"), uri.port.to_string ());
+ break;
+
+ default:
+ throw new Boxes.Error.INVALID ("Unsupported protocol %s".printf (uri.scheme));
}
}
@@ -124,7 +132,7 @@ private class Boxes.Wizard: Boxes.UI {
if (this.wizard_source.page == Boxes.SourcePage.URL ||
this.wizard_source.page == Boxes.SourcePage.FILE) {
- prepare_with_uri (this.wizard_source.uri);
+ prepare_for_location (this.wizard_source.uri);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]