[rygel/wip/upload-profiles: 1/3] server: Add X_GetDLNAUploadProfiles call



commit 38810883faaa6731d812a0c2748c5081869851dc
Author: Jens Georg <jensg openismus com>
Date:   Fri Aug 9 12:57:43 2013 +0200

    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 deletions(-)
---
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 @@
             </argument>
          </argumentList>
       </action>
-   </actionList>
+
+      <action>
+        <name>X_GetDLNAUploadProfiles</name>
+        <argumentList>
+          <argument>
+            <name>UploadProfiles</name>
+            <direction>in</direction>
+            <relatedStateVariable>X_A_ARG_Type_UploadProfiles</relatedStateVariable>
+          </argument>
+          <argument>
+            <name>SupportedUploadProfiles</name>
+            <direction>out</direction>
+            <relatedStateVariable>X_A_ARG_Type_SupportedUploadProfiles</relatedStateVariable>
+          </argument>
+        </argumentList>
+      </action>
+  </actionList>
 
    <serviceStateTable>
       <stateVariable sendEvents="no">
@@ -419,5 +435,15 @@
          <name>A_ARG_TYPE_TransferTotal</name>
          <dataType>string</dataType>
       </stateVariable>
+
+      <stateVariable sendEvents="no">
+        <name>X_A_ARG_Type_UploadProfiles</name>
+        <dataType>string</dataType>
+      </stateVariable>
+
+      <stateVariable sendEvents="no">
+        <name>X_A_ARG_Type_SupportedUploadProfiles</name>
+        <dataType>string</dataType>
+      </stateVariable>
    </serviceStateTable>
 </scpd>
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 @@
             </argument>
          </argumentList>
       </action>
+
+      <action>
+        <name>X_GetDLNAUploadProfiles</name>
+        <argumentList>
+          <argument>
+            <name>UploadProfiles</name>
+            <direction>in</direction>
+            <relatedStateVariable>X_A_ARG_Type_UploadProfiles</relatedStateVariable>
+          </argument>
+          <argument>
+            <name>SupportedUploadProfiles</name>
+            <direction>out</direction>
+            <relatedStateVariable>X_A_ARG_Type_SupportedUploadProfiles</relatedStateVariable>
+          </argument>
+        </argumentList>
+      </action>
    </actionList>
 
    <serviceStateTable>
@@ -446,5 +462,15 @@
          <name>A_ARG_TYPE_TransferTotal</name>
          <dataType>string</dataType>
       </stateVariable>
+
+      <stateVariable sendEvents="no">
+        <name>X_A_ARG_Type_UploadProfiles</name>
+        <dataType>string</dataType>
+      </stateVariable>
+
+      <stateVariable sendEvents="no">
+        <name>X_A_ARG_Type_SupportedUploadProfiles</name>
+        <dataType>string</dataType>
+      </stateVariable>
    </serviceStateTable>
 </scpd>
diff --git a/src/librygel-server/rygel-content-directory.vala 
b/src/librygel-server/rygel-content-directory.vala
index adf2f24..8619dc6 100644
--- a/src/librygel-server/rygel-content-directory.vala
+++ b/src/librygel-server/rygel-content-directory.vala
@@ -144,6 +144,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 */
@@ -756,4 +759,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<DLNAProfile> 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 ();
+    }
 }


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