[rygel] core: Make use of Uri.parse_scheme()



commit 58b66e5d7546b74ebd4cfb907b4b82f3ec98cbf3
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Oct 2 14:32:08 2009 +0300

    core: Make use of Uri.parse_scheme()

 src/rygel/rygel-http-server.vala |    2 +-
 src/rygel/rygel-media-item.vala  |   20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/src/rygel/rygel-http-server.vala b/src/rygel/rygel-http-server.vala
index 612795a..5e03ff7 100644
--- a/src/rygel/rygel-http-server.vala
+++ b/src/rygel/rygel-http-server.vala
@@ -107,7 +107,7 @@ internal class Rygel.HTTPServer : Rygel.TranscodeManager, Rygel.StateMachine {
     }
 
     private bool is_http_uri (string uri) {
-            return uri.has_prefix ("http:");
+        return Uri.parse_scheme (uri) == "http";
     }
 
     private void on_cancelled (Cancellable cancellable) {
diff --git a/src/rygel/rygel-media-item.vala b/src/rygel/rygel-media-item.vala
index fd402ae..847c8f0 100644
--- a/src/rygel/rygel-media-item.vala
+++ b/src/rygel/rygel-media-item.vala
@@ -206,25 +206,25 @@ public class Rygel.MediaItem : MediaObject {
     }
 
     private string get_protocol_for_uri (string uri) throws Error {
-        if (uri.has_prefix ("http")) {
+        var scheme = Uri.parse_scheme (uri);
+        if (scheme == null) {
+            throw new MediaItemError.BAD_URI ("Bad URI: %s", uri);
+        }
+
+        if (scheme == "http") {
             return "http-get";
-        } else if (uri.has_prefix ("file")) {
+        } else if (scheme == "file") {
             return "internal";
-        } else if (uri.has_prefix ("rtsp")) {
+        } else if (scheme == "rtsp") {
             // FIXME: Assuming that RTSP is always accompanied with RTP over UDP
             return "rtsp-rtp-udp";
         } else {
             // Assume the protocol to be the scheme of the URI
-            var tokens = uri.split (":", 2);
-            if (tokens[0] == null) {
-                throw new MediaItemError.BAD_URI ("Bad URI: %s", uri);
-            }
-
             warning ("Failed to probe protocol for URI %s. Assuming '%s'",
                      uri,
-                     tokens[0]);
+                     scheme);
 
-            return tokens[0];
+            return scheme;
         }
     }
 }



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