From a323d80c3abb1a2dbf079ffb37116fe7f77af8db Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Fri, 9 Aug 2013 12:57:43 +0200 Subject: [PATCH] server: Add X_GetDLNAUploadProfiles call --- data/xml/ContentDirectory-NoTrack.xml.in | 28 ++++++++++++++- data/xml/ContentDirectory.xml.in | 26 ++++++++++++++ src/librygel-server/rygel-content-directory.vala | 43 ++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/data/xml/ContentDirectory-NoTrack.xml.in b/data/xml/ContentDirectory-NoTrack.xml.in index aabcbd8..cc8d125 100644 --- a/data/xml/ContentDirectory-NoTrack.xml.in +++ b/data/xml/ContentDirectory-NoTrack.xml.in @@ -297,7 +297,23 @@ - + + + X_GetDLNAUploadProfiles + + + UploadProfiles + in + X_A_ARG_Type_UploadProfiles + + + SupportedUploadProfiles + out + X_A_ARG_Type_SupportedUploadProfiles + + + + @@ -419,5 +435,15 @@ A_ARG_TYPE_TransferTotal string + + + X_A_ARG_Type_UploadProfiles + string + + + + X_A_ARG_Type_SupportedUploadProfiles + string + diff --git a/data/xml/ContentDirectory.xml.in b/data/xml/ContentDirectory.xml.in index b46f366..aec67da 100644 --- a/data/xml/ContentDirectory.xml.in +++ b/data/xml/ContentDirectory.xml.in @@ -319,6 +319,22 @@ + + + X_GetDLNAUploadProfiles + + + UploadProfiles + in + X_A_ARG_Type_UploadProfiles + + + SupportedUploadProfiles + out + X_A_ARG_Type_SupportedUploadProfiles + + + @@ -446,5 +462,15 @@ A_ARG_TYPE_TransferTotal string + + + X_A_ARG_Type_UploadProfiles + string + + + + X_A_ARG_Type_SupportedUploadProfiles + string + diff --git a/src/librygel-server/rygel-content-directory.vala b/src/librygel-server/rygel-content-directory.vala index c63d7fa..48ec050 100644 --- a/src/librygel-server/rygel-content-directory.vala +++ b/src/librygel-server/rygel-content-directory.vala @@ -145,6 +145,9 @@ internal class Rygel.ContentDirectory: Service { this.action_invoked["StopTransferResource"].connect ( this.stop_transfer_resource_cb); + this.action_invoked["X_GetDLNAUploadProfiles"].connect + (this.get_dlna_upload_profiles_cb); + this.query_variable["TransferIDs"].connect (this.query_transfer_ids); /* Connect SystemUpdateID related signals */ @@ -757,4 +760,44 @@ internal class Rygel.ContentDirectory: Service { debug ("New service reset token is %s", this.service_reset_token); } catch (Error error) { warning ("Failed to search for objects..."); }; } + + /* X_GetDLNAUploadProfiles action implementation */ + private void get_dlna_upload_profiles_cb (Service content_dir, + ServiceAction action) { + string upload_profiles = null; + + action.get ("UploadProfiles", typeof (string), out upload_profiles); + + if (upload_profiles == null) { + action.return_error (402, _("Invalid argument")); + + return; + } + + unowned GLib.List profiles = MediaEngine.get_default (). + get_dlna_profiles (); + var requested_profiles = upload_profiles.split (","); + var builder = new StringBuilder (); + foreach (var profile in profiles) { + // Skip forbidden profiles + if (profile.name.has_suffix ("_ICO") || + profile.name.has_suffix ("_TN") || + profile.name == "DIDL_S") { + continue; + } + + if (requested_profiles.length == 0 || + profile.name in requested_profiles) { + builder.append (profile.name); + builder.append (","); + } + } + + if (builder.len > 0) { + builder.truncate (builder.len - 1); + } + + action.set ("SupportedUploadProfiles", typeof (string), builder.str); + action.return (); + } } -- 2.7.4