[gupnp-av] Add updateCount to GUPnPDIDLLiteResource.



commit dc9f3c87fcd64c6e0ffafe2e5e5211e1b5a507e2
Author: Krzesimir Nowak <krnowak openismus com>
Date:   Thu Sep 6 15:05:16 2012 +0200

    Add updateCount to GUPnPDIDLLiteResource.
    
    Will be needed for Tracking Changes Option of ContentDirectory.

 libgupnp-av/gupnp-didl-lite-resource.c |  117 +++++++++++++++++++++++++++++++-
 libgupnp-av/gupnp-didl-lite-resource.h |   19 +++++
 2 files changed, 135 insertions(+), 1 deletions(-)
---
diff --git a/libgupnp-av/gupnp-didl-lite-resource.c b/libgupnp-av/gupnp-didl-lite-resource.c
index 240b070..8b4e064 100644
--- a/libgupnp-av/gupnp-didl-lite-resource.c
+++ b/libgupnp-av/gupnp-didl-lite-resource.c
@@ -1,10 +1,12 @@
 /*
  * Copyright (C) 2009 Nokia Corporation.
  * Copyright (C) 2007, 2008 OpenedHand Ltd.
+ * Copyright (C) 2012 Intel Corporation
  *
  * Authors: Zeeshan Ali (Khattak) <zeeshan ali nokia com>
  *                                <zeeshanak gnome org>
  *          Jorn Baayen <jorn openedhand com>
+ *          Krzesimir Nowak <krnowak openismus com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -70,7 +72,9 @@ enum {
 
         PROP_WIDTH,
         PROP_HEIGHT,
-        PROP_COLOR_DEPTH
+        PROP_COLOR_DEPTH,
+
+        PROP_UPDATE_COUNT
 };
 
 static void
@@ -227,6 +231,11 @@ gupnp_didl_lite_resource_set_property (GObject      *object,
                                 (resource,
                                  g_value_get_int (value));
                 break;
+        case PROP_UPDATE_COUNT:
+                gupnp_didl_lite_resource_set_update_count
+                                        (resource,
+                                         g_value_get_uint (value));
+                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                 break;
@@ -318,6 +327,11 @@ gupnp_didl_lite_resource_get_property (GObject    *object,
                         (value,
                          gupnp_didl_lite_resource_get_color_depth (resource));
                 break;
+        case PROP_UPDATE_COUNT:
+                g_value_set_uint
+                         (value,
+                          gupnp_didl_lite_resource_get_update_count (resource));
+                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                 break;
@@ -663,6 +677,25 @@ gupnp_didl_lite_resource_class_init (GUPnPDIDLLiteResourceClass *klass)
                                    G_PARAM_STATIC_NAME |
                                    G_PARAM_STATIC_NICK |
                                    G_PARAM_STATIC_BLURB));
+
+        /**
+         * GUPnPDIDLLiteResource:update_count:
+         *
+         * The update count of this resource.
+         **/
+        g_object_class_install_property
+                       (object_class,
+                        PROP_UPDATE_COUNT,
+                        g_param_spec_uint ("update-count",
+                                           "UpdateCount",
+                                           "The update count of this resource.",
+                                           0,
+                                           G_MAXUINT,
+                                           0,
+                                           G_PARAM_READWRITE |
+                                           G_PARAM_STATIC_NAME |
+                                           G_PARAM_STATIC_NICK |
+                                           G_PARAM_STATIC_BLURB));
 }
 
 /**
@@ -985,6 +1018,44 @@ gupnp_didl_lite_resource_get_color_depth (GUPnPDIDLLiteResource *resource)
 }
 
 /**
+ * gupnp_didl_lite_resource_get_update_count:
+ * @resource: A #GUPnPDIDLLiteResource
+ *
+ * Get the update count of this resource.
+ *
+ * Return value: The update count of the @resource.
+ **/
+guint
+gupnp_didl_lite_resource_get_update_count (GUPnPDIDLLiteResource *resource)
+{
+        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), 0);
+
+        return xml_util_get_uint_attribute (resource->priv->xml_node,
+                                            "updateCount",
+                                            -1);
+}
+
+/**
+ * gupnp_didl_lite_resource_update_count_is_set:
+ * @resource: A #GUPnPDIDLLiteResource
+ *
+ * Check whether the update count property of this resource is set.
+ *
+ * Return value: %TRUE if set, otherwise %FALSE.
+ **/
+gboolean
+gupnp_didl_lite_resource_update_count_is_set (GUPnPDIDLLiteResource *resource)
+{
+        const char *content;
+
+        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), FALSE);
+
+        content = xml_util_get_attribute_content (resource->priv->xml_node,
+                                                  "updateCount");
+        return content != NULL;
+}
+
+/**
  * gupnp_didl_lite_resource_set_uri:
  * @resource: A #GUPnPDIDLLiteResource
  * @uri: The URI as string
@@ -1417,3 +1488,47 @@ gupnp_didl_lite_resource_set_color_depth (GUPnPDIDLLiteResource *resource,
         g_object_notify (G_OBJECT (resource), "color-depth");
 }
 
+/**
+ * gupnp_didl_lite_resource_set_update_count:
+ * @resource: A #GUPnPDIDLLiteResource
+ * @update_count: The update_count
+ *
+ * Set the update count of this resource.
+ *
+ * Return value: None.
+ **/
+void
+gupnp_didl_lite_resource_set_update_count (GUPnPDIDLLiteResource *resource,
+                                          guint                  update_count)
+{
+        char *str;
+
+        g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+
+        str = g_strdup_printf ("%u", update_count);
+        xmlSetProp (resource->priv->xml_node,
+                    (unsigned char *) "updateCount",
+                    (unsigned char *) str);
+        g_free (str);
+
+        g_object_notify (G_OBJECT (resource), "update-count");
+}
+
+/**
+ * gupnp_didl_lite_resource_unset_update_count:
+ * @resource: A #GUPnPDIDLLiteResource
+ *
+ * Unset the update count of this resource.
+ *
+ * Return value: None.
+ **/
+void
+gupnp_didl_lite_resource_unset_update_count (GUPnPDIDLLiteResource *resource)
+{
+        g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+
+        xmlUnsetProp (resource->priv->xml_node,
+                      (unsigned char *) "updateCount");
+
+        g_object_notify (G_OBJECT (resource), "update-count");
+}
diff --git a/libgupnp-av/gupnp-didl-lite-resource.h b/libgupnp-av/gupnp-didl-lite-resource.h
index 1f3b8f3..cba2e71 100644
--- a/libgupnp-av/gupnp-didl-lite-resource.h
+++ b/libgupnp-av/gupnp-didl-lite-resource.h
@@ -1,10 +1,12 @@
 /*
  * Copyright (C) 2009 Nokia Corporation.
  * Copyright (C) 2007, 2008 OpenedHand Ltd.
+ * Copyright (C) 2012 Intel Corporation
  *
  * Authors: Zeeshan Ali (Khattak) <zeeshan ali nokia com>
  *                                <zeeshanak gnome org>
  *          Jorn Baayen <jorn openedhand com>
+ *          Krzesimir Nowak <krnowak openismus com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -139,6 +141,15 @@ gupnp_didl_lite_resource_set_color_depth
                                         (GUPnPDIDLLiteResource *resource,
                                          int                    color_depth);
 
+void
+gupnp_didl_lite_resource_set_update_count
+                                        (GUPnPDIDLLiteResource *resource,
+                                         guint                  update_count);
+
+void
+gupnp_didl_lite_resource_unset_update_count
+                                        (GUPnPDIDLLiteResource *resource);
+
 xmlNode *
 gupnp_didl_lite_resource_get_xml_node   (GUPnPDIDLLiteResource *resource);
 
@@ -189,6 +200,14 @@ int
 gupnp_didl_lite_resource_get_color_depth
                                         (GUPnPDIDLLiteResource *resource);
 
+guint
+gupnp_didl_lite_resource_get_update_count
+                                        (GUPnPDIDLLiteResource *resource);
+
+gboolean
+gupnp_didl_lite_resource_update_count_is_set
+                                        (GUPnPDIDLLiteResource *resource);
+
 G_END_DECLS
 
 #endif /* __GUPNP_DIDL_LITE_RESOURCE_H__ */



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