build,core,plugins: Port to GDBus and GVariant
[profile/ivi/rygel.git] / src / plugins / external / rygel-external-album-art-factory.vala
index 0608f1c..4d657fe 100644 (file)
@@ -22,7 +22,6 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-using DBus;
 using FreeDesktop;
 
 /**
@@ -31,28 +30,30 @@ using FreeDesktop;
 public class Rygel.External.AlbumArtFactory {
     public async Thumbnail create (string service_name,
                                    string object_path,
-                                   string host_ip)
-                                   throws GLib.Error {
-        DBus.Connection connection = DBus.Bus.get (DBus.BusType.SESSION);
-
-        var props = connection.get_object (service_name,
-                                           object_path)
-                                           as Properties;
+                                   string host_ip) throws IOError {
+        Properties props = Bus.get_proxy_sync (BusType.SESSION,
+                                               service_name,
+                                               object_path);
 
         var item_props = yield props.get_all (MediaItemProxy.IFACE);
 
+        return this.create_from_props (item_props, host_ip);
+    }
+
+    private Thumbnail create_from_props (HashTable<string,Variant> props,
+                                         string                    host_ip) {
         var thumbnail = new AlbumArt ();
 
-        var value = item_props.lookup ("MIMEType");
+        var value = props.lookup ("MIMEType");
         thumbnail.mime_type = (string) value;
 
-        value = item_props.lookup ("URLs");
+        value = props.lookup ("URLs");
         var uris = (string[]) value;
         if (uris != null && uris[0] != null) {
             thumbnail.uri = uris[0].replace ("@ADDRESS@", host_ip);
         }
 
-        value = item_props.lookup ("Size");
+        value = props.lookup ("Size");
         if (value != null) {
             thumbnail.size = (int64) value;
         }