[rygel] external: Use Vala's Value conversion capabilities



commit 6d693495750e3f17c4e23974412827c9d47f95a6
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Aug 11 01:32:48 2010 +0300

    external: Use Vala's Value conversion capabilities
    
    Make use of Vala's ability to convert GLib.Value to primite types.

 .../external/rygel-external-album-art-factory.vala |    6 ++--
 src/plugins/external/rygel-external-container.vala |   18 +++++-----
 .../external/rygel-external-icon-factory.vala      |   14 ++++----
 .../external/rygel-external-item-factory.vala      |   36 ++++++++++----------
 .../external/rygel-external-plugin-factory.vala    |    2 +-
 .../external/rygel-external-thumbnail-factory.vala |   14 ++++----
 6 files changed, 45 insertions(+), 45 deletions(-)
---
diff --git a/src/plugins/external/rygel-external-album-art-factory.vala b/src/plugins/external/rygel-external-album-art-factory.vala
index 7844323..105857a 100644
--- a/src/plugins/external/rygel-external-album-art-factory.vala
+++ b/src/plugins/external/rygel-external-album-art-factory.vala
@@ -44,17 +44,17 @@ public class Rygel.External.AlbumArtFactory {
         var thumbnail = new AlbumArt ();
 
         var value = item_props.lookup ("MIMEType");
-        thumbnail.mime_type = value.get_string ();
+        thumbnail.mime_type = (string) value;
 
         value = item_props.lookup ("URLs");
-        weak string[] uris = (string[]) value.get_boxed ();
+        var uris = (string[]) value;
         if (uris != null && uris[0] != null) {
             thumbnail.uri = uris[0].replace ("@ADDRESS@", host_ip);
         }
 
         value = item_props.lookup ("Size");
         if (value != null) {
-            thumbnail.size = value.get_int ();
+            thumbnail.size = (int) value;
         }
 
         return thumbnail;
diff --git a/src/plugins/external/rygel-external-container.vala b/src/plugins/external/rygel-external-container.vala
index 4a5bd4f..7dfff0d 100644
--- a/src/plugins/external/rygel-external-container.vala
+++ b/src/plugins/external/rygel-external-container.vala
@@ -188,14 +188,14 @@ public class Rygel.External.Container : Rygel.MediaContainer {
         var media_objects = new MediaObjects ();
 
         foreach (var props in all_props) {
-            var id = props.lookup ("Path").get_string ();
-            var type = props.lookup ("Type").get_string ();
+            var id = (string) props.lookup ("Path");
+            var type = (string) props.lookup ("Type");
 
             MediaContainer parent_container;
             if (parent != null) {
                 parent_container = parent;
             } else {
-                var parent_id = props.lookup ("Parent").get_string ();
+                var parent_id = (string) props.lookup ("Parent");
 
                 parent_container = new DummyContainer (parent_id,
                                                        "LaLaLa",
@@ -209,10 +209,10 @@ public class Rygel.External.Container : Rygel.MediaContainer {
             }
 
             if (media_object == null) {
-                var title = props.lookup ("DisplayName").get_string ();
+                var title = (string) props.lookup ("DisplayName");
 
                 if (type == "container") {
-                    var child_count = props.lookup ("ChildCount").get_uint ();
+                    var child_count = (uint) props.lookup ("ChildCount");
 
                     media_object = new DummyContainer (id,
                                                        title,
@@ -255,10 +255,10 @@ public class Rygel.External.Container : Rygel.MediaContainer {
         this.containers.clear ();
 
         foreach (var props in children_props) {
-            var path = props.lookup ("Path").get_string ();
-            var title = props.lookup ("DisplayName").get_string ();
-            var child_count = props.lookup ("ChildCount").get_uint ();
-            var searchable = props.lookup ("Searchable").get_boolean ();
+            var path = (string) props.lookup ("Path");
+            var title = (string) props.lookup ("DisplayName");
+            var child_count = (uint) props.lookup ("ChildCount");
+            var searchable = (bool) props.lookup ("Searchable");
 
             var container = new Container (path,
                                            title,
diff --git a/src/plugins/external/rygel-external-icon-factory.vala b/src/plugins/external/rygel-external-icon-factory.vala
index 6beb563..7d54272 100644
--- a/src/plugins/external/rygel-external-icon-factory.vala
+++ b/src/plugins/external/rygel-external-icon-factory.vala
@@ -41,7 +41,7 @@ public class Rygel.External.IconFactory {
             return null;
         }
 
-        var icon_path = value.get_string ();
+        var icon_path = (string) value;
         var props = this.connection.get_object (service_name,
                                                 icon_path)
                                                 as Properties;
@@ -56,33 +56,33 @@ public class Rygel.External.IconFactory {
         }
 
         value = item_props.lookup ("MIMEType");
-        var mime_type = value.get_string ();
+        var mime_type = (string) value;
         var icon = new IconInfo (mime_type, this.get_ext_for_mime (mime_type));
 
         value = item_props.lookup ("URLs");
-        weak string[] uris = (string[]) value.get_boxed ();
+        var uris = (string[]) value;
         if (uris != null && uris[0] != null) {
             icon.uri = uris[0];
         }
 
         value = item_props.lookup ("Size");
         if (value != null) {
-            icon.size = value.get_int ();
+            icon.size = (int) value;
         }
 
         value = item_props.lookup ("Width");
         if (value != null) {
-            icon.width = value.get_int ();
+            icon.width = (int) value;
         }
 
         value = item_props.lookup ("Height");
         if (value != null) {
-            icon.height = value.get_int ();
+            icon.height = (int) value;
         }
 
         value = item_props.lookup ("ColorDepth");
         if (value != null) {
-            icon.depth = value.get_int ();
+            icon.depth = (int) value;
         }
 
         return icon;
diff --git a/src/plugins/external/rygel-external-item-factory.vala b/src/plugins/external/rygel-external-item-factory.vala
index 3d5afd5..bae3624 100644
--- a/src/plugins/external/rygel-external-item-factory.vala
+++ b/src/plugins/external/rygel-external-item-factory.vala
@@ -56,7 +56,7 @@ public class Rygel.External.ItemFactory {
         }
 
         var value = props.lookup ("MIMEType");
-        item.mime_type = value.get_string ();
+        item.mime_type = (string) value;
 
         value = props.lookup ("URLs");
         var uris = (string[]) value;
@@ -71,60 +71,60 @@ public class Rygel.External.ItemFactory {
 
         value = props.lookup ("DLNAProfile");
         if (value != null) {
-            item.dlna_profile = value.get_string ();
+            item.dlna_profile = (string) value;
         }
 
         value = props.lookup ("Size");
         if (value != null) {
-            item.size = value.get_int64 ();
+            item.size = (int64) value;
         }
 
         value = props.lookup ("Artist");
         if (value != null) {
-            item.author = value.get_string ();
+            item.author = (string) value;
         }
 
         value = props.lookup ("Album");
         if (value != null) {
-            item.album = value.get_string ();
+            item.album = (string) value;
         }
 
         value = props.lookup ("Genre");
         if (value != null) {
-            item.genre = value.get_string ();
+            item.genre = (string) value;
         }
 
         value = props.lookup ("Date");
         if (value != null) {
-            item.date = value.get_string ();
+            item.date = (string) value;
         }
 
         // Properties specific to video and audio/music
 
         value = props.lookup ("Duration");
         if (value != null) {
-            item.duration = value.get_int ();
+            item.duration = (int) value;
         }
 
         value = props.lookup ("Bitrate");
         if (value != null) {
-            item.bitrate = value.get_int ();
+            item.bitrate = (int) value;
         }
 
         value = props.lookup ("SampleRate");
         if (value != null) {
-            item.sample_freq = value.get_int ();
+            item.sample_freq = (int) value;
         }
 
         value = props.lookup ("BitsPerSample");
         if (value != null) {
-            item.bits_per_sample = value.get_int ();
+            item.bits_per_sample = (int) value;
         }
 
         value = props.lookup ("AlbumArt");
         if (value != null) {
             var cover_factory = new AlbumArtFactory ();
-            var album_art = yield cover_factory.create (value.get_string (),
+            var album_art = yield cover_factory.create ((string) value,
                                                         service_name,
                                                         host_ip);
             item.thumbnails.add (album_art);
@@ -134,33 +134,33 @@ public class Rygel.External.ItemFactory {
 
         value = props.lookup ("Width");
         if (value != null) {
-            item.width = value.get_int ();
+            item.width = (int) value;
         }
 
         value = props.lookup ("Height");
         if (value != null) {
-            item.height = value.get_int ();
+            item.height = (int) value;
         }
 
         value = props.lookup ("ColorDepth");
         if (value != null) {
-            item.color_depth = value.get_int ();
+            item.color_depth = (int) value;
         }
 
         value = props.lookup ("PixelWidth");
         if (value != null) {
-            item.pixel_width = value.get_int ();
+            item.pixel_width = (int) value;
         }
 
         value = props.lookup ("PixelHeight");
         if (value != null) {
-            item.pixel_height = value.get_int ();
+            item.pixel_height = (int) value;
         }
 
         value = props.lookup ("Thumbnail");
         if (value != null) {
             var factory = new ThumbnailFactory ();
-            var thumbnail = yield factory.create (value.get_string (),
+            var thumbnail = yield factory.create ((string) value,
                                                   service_name,
                                                   host_ip);
             item.thumbnails.add (thumbnail);
diff --git a/src/plugins/external/rygel-external-plugin-factory.vala b/src/plugins/external/rygel-external-plugin-factory.vala
index b827684..170fa37 100644
--- a/src/plugins/external/rygel-external-plugin-factory.vala
+++ b/src/plugins/external/rygel-external-plugin-factory.vala
@@ -143,7 +143,7 @@ public class Rygel.External.PluginFactory {
         string title;
         var value = object_props.lookup ("DisplayName");
         if (value != null) {
-            title = value.get_string ();
+            title = (string) value;
         } else {
             title = service_name;
         }
diff --git a/src/plugins/external/rygel-external-thumbnail-factory.vala b/src/plugins/external/rygel-external-thumbnail-factory.vala
index 46650fe..31b79a2 100644
--- a/src/plugins/external/rygel-external-thumbnail-factory.vala
+++ b/src/plugins/external/rygel-external-thumbnail-factory.vala
@@ -44,37 +44,37 @@ public class Rygel.External.ThumbnailFactory {
         var thumbnail = new Thumbnail ();
 
         var value = item_props.lookup ("MIMEType");
-        thumbnail.mime_type = value.get_string ();
+        thumbnail.mime_type = (string) value;
 
         value = item_props.lookup ("URLs");
-        weak string[] uris = (string[]) value.get_boxed ();
+        var uris = (string[]) value;
         if (uris != null && uris[0] != null) {
             thumbnail.uri = uris[0].replace ("@ADDRESS@", host_ip);
         }
 
         value = item_props.lookup ("DLNAProfile");
         if (value != null) {
-            thumbnail.dlna_profile = value.get_string ();
+            thumbnail.dlna_profile = (string) value;
         }
 
         value = item_props.lookup ("Size");
         if (value != null) {
-            thumbnail.size = value.get_int ();
+            thumbnail.size = (int) value;
         }
 
         value = item_props.lookup ("Width");
         if (value != null) {
-            thumbnail.width = value.get_int ();
+            thumbnail.width = (int) value;
         }
 
         value = item_props.lookup ("Height");
         if (value != null) {
-            thumbnail.height = value.get_int ();
+            thumbnail.height = (int) value;
         }
 
         value = item_props.lookup ("ColorDepth");
         if (value != null) {
-            thumbnail.depth = value.get_int ();
+            thumbnail.depth = (int) value;
         }
 
         return thumbnail;



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