[gupnp-av] all: Port classes to new GObject type macros
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp-av] all: Port classes to new GObject type macros
- Date: Sat, 3 Jul 2021 21:43:13 +0000 (UTC)
commit 8f24dda0f85426c960a83b6cef5f70ed2a2d5af0
Author: Jens Georg <mail jensge org>
Date: Sat Jul 3 23:37:33 2021 +0200
all: Port classes to new GObject type macros
Bump ABI version, since I cannot guarantee that this didn't change ABI
libgupnp-av/gupnp-cds-last-change-parser.c | 2 -
libgupnp-av/gupnp-cds-last-change-parser.h | 44 +---
libgupnp-av/gupnp-didl-lite-container.c | 2 +-
libgupnp-av/gupnp-didl-lite-container.h | 35 +--
libgupnp-av/gupnp-didl-lite-contributor.c | 50 ++--
libgupnp-av/gupnp-didl-lite-contributor.h | 37 +--
libgupnp-av/gupnp-didl-lite-createclass.c | 68 +++--
libgupnp-av/gupnp-didl-lite-createclass.h | 47 +---
libgupnp-av/gupnp-didl-lite-descriptor.c | 60 +++--
libgupnp-av/gupnp-didl-lite-descriptor.h | 48 +---
libgupnp-av/gupnp-didl-lite-item.c | 2 +-
libgupnp-av/gupnp-didl-lite-item.h | 39 +--
libgupnp-av/gupnp-didl-lite-object.c | 401 ++++++++++++++++++-----------
libgupnp-av/gupnp-didl-lite-object.h | 35 +--
libgupnp-av/gupnp-didl-lite-parser.c | 2 +-
libgupnp-av/gupnp-didl-lite-parser.h | 35 +--
libgupnp-av/gupnp-didl-lite-resource.c | 401 ++++++++++++++++-------------
libgupnp-av/gupnp-didl-lite-resource.h | 45 +---
libgupnp-av/gupnp-didl-lite-writer.c | 108 ++++----
libgupnp-av/gupnp-didl-lite-writer.h | 42 +--
libgupnp-av/gupnp-dlna.h | 6 +-
libgupnp-av/gupnp-feature-list-parser.c | 29 +--
libgupnp-av/gupnp-feature-list-parser.h | 33 +--
libgupnp-av/gupnp-feature.c | 33 ++-
libgupnp-av/gupnp-feature.h | 46 +---
libgupnp-av/gupnp-last-change-parser.c | 4 +-
libgupnp-av/gupnp-last-change-parser.h | 40 +--
libgupnp-av/gupnp-media-collection.c | 203 +++++++--------
libgupnp-av/gupnp-media-collection.h | 46 +---
libgupnp-av/gupnp-protocol-info.c | 191 +++++++-------
libgupnp-av/gupnp-protocol-info.h | 50 +---
libgupnp-av/gupnp-search-criteria-parser.c | 135 +++++-----
libgupnp-av/gupnp-search-criteria-parser.h | 53 ++--
libgupnp-av/gvalue-util.c | 7 +-
libgupnp-av/gvalue-util.h | 7 +-
libgupnp-av/meson.build | 2 +-
libgupnp-av/time-utils.h | 4 +-
libgupnp-av/xml-util.c | 46 +++-
libgupnp-av/xml-util.h | 13 +-
libgupnp-av/xsd-data.c | 7 +-
libgupnp-av/xsd-data.h | 4 +-
meson.build | 3 +-
tests/check-feature-list-parser.c | 4 -
tests/test-search-criteria-parser.c | 4 -
44 files changed, 1190 insertions(+), 1283 deletions(-)
---
diff --git a/libgupnp-av/gupnp-cds-last-change-parser.c b/libgupnp-av/gupnp-cds-last-change-parser.c
index 2e4595a..63ae361 100644
--- a/libgupnp-av/gupnp-cds-last-change-parser.c
+++ b/libgupnp-av/gupnp-cds-last-change-parser.c
@@ -50,8 +50,6 @@ G_DEFINE_TYPE (GUPnPCDSLastChangeParser,
gupnp_cds_last_change_parser,
G_TYPE_OBJECT)
-#define GUPNP_TYPE_CDS_LAST_CHANGE_PARSER (gupnp_cds_last_change_entry_get_type())
-
G_DEFINE_BOXED_TYPE (GUPnPCDSLastChangeEntry,
gupnp_cds_last_change_entry,
gupnp_cds_last_change_entry_ref,
diff --git a/libgupnp-av/gupnp-cds-last-change-parser.h b/libgupnp-av/gupnp-cds-last-change-parser.h
index 8e7483b..af989f0 100644
--- a/libgupnp-av/gupnp-cds-last-change-parser.h
+++ b/libgupnp-av/gupnp-cds-last-change-parser.h
@@ -26,47 +26,23 @@
G_BEGIN_DECLS
-GType
-gupnp_cds_last_change_parser_get_type (void) G_GNUC_CONST;
GType
gupnp_cds_last_change_entry_get_type (void) G_GNUC_CONST;
-#define GUPNP_TYPE_CDS_LAST_CHANGE_PARSER \
- (gupnp_cds_last_change_parser_get_type ())
-#define GUPNP_CDS_LAST_CHANGE_PARSER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_CDS_LAST_CHANGE_PARSER, \
- GUPnPCDSLastChangeParser))
-#define GUPNP_CDS_LAST_CHANGE_PARSER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_CDS_LAST_CHANGE_PARSER, \
- GUPnPCDSLastChangeParserClass))
-#define GUPNP_IS_CDS_LAST_CHANGE_PARSER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_CDS_LAST_CHANGE_PARSER))
-#define GUPNP_IS_CDS_LAST_CHANGE_PARSER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- GUPNP_TYPE_CDS_LAST_CHANGE_PARSER))
-#define GUPNP_CDS_LAST_CHANGE_PARSER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_CDS_LAST_CHANGE_PARSER, \
- GUPnPCDSLastChangeParserClass))
-
-typedef struct _GUPnPCDSLastChangeParser GUPnPCDSLastChangeParser;
-typedef struct _GUPnPCDSLastChangeParserClass GUPnPCDSLastChangeParserClass;
-typedef struct _GUPnPCDSLastChangeParserPrivate GUPnPCDSLastChangeParserPrivate;
-typedef struct _GUPnPCDSLastChangeEntry GUPnPCDSLastChangeEntry;
-
-struct _GUPnPCDSLastChangeParser {
- GObject parent;
+G_DECLARE_DERIVABLE_TYPE(GUPnPCDSLastChangeParser,
+ gupnp_cds_last_change_parser,
+ GUPNP,
+ CDS_LAST_CHANGE_PARSER,
+ GObject)
+#define GUPNP_TYPE_CDS_LAST_CHANGE_PARSER gupnp_cds_last_change_parser_get_type()
- GUPnPCDSLastChangeParserPrivate *priv;
+struct _GUPnPCDSLastChangeParserClass
+{
+ GObjectClass parent_class;
};
-struct _GUPnPCDSLastChangeParserClass {
- GObjectClass parent_class;
-};
+typedef struct _GUPnPCDSLastChangeEntry GUPnPCDSLastChangeEntry;
/**
* GUPnPCDSLastChangeEvent:
diff --git a/libgupnp-av/gupnp-didl-lite-container.c b/libgupnp-av/gupnp-didl-lite-container.c
index cf6164d..1cab480 100644
--- a/libgupnp-av/gupnp-didl-lite-container.c
+++ b/libgupnp-av/gupnp-didl-lite-container.c
@@ -41,7 +41,7 @@
G_DEFINE_TYPE (GUPnPDIDLLiteContainer,
gupnp_didl_lite_container,
- GUPNP_TYPE_DIDL_LITE_OBJECT);
+ GUPNP_TYPE_DIDL_LITE_OBJECT)
enum {
PROP_0,
diff --git a/libgupnp-av/gupnp-didl-lite-container.h b/libgupnp-av/gupnp-didl-lite-container.h
index 7c4ced7..365f8d7 100644
--- a/libgupnp-av/gupnp-didl-lite-container.h
+++ b/libgupnp-av/gupnp-didl-lite-container.h
@@ -31,35 +31,16 @@
G_BEGIN_DECLS
-GType
-gupnp_didl_lite_container_get_type (void) G_GNUC_CONST;
+G_DECLARE_DERIVABLE_TYPE(GUPnPDIDLLiteContainer,
+ gupnp_didl_lite_container,
+ GUPNP,
+ DIDL_LITE_CONTAINER,
+ GUPnPDIDLLiteObject)
#define GUPNP_TYPE_DIDL_LITE_CONTAINER \
(gupnp_didl_lite_container_get_type ())
-#define GUPNP_DIDL_LITE_CONTAINER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_CONTAINER, \
- GUPnPDIDLLiteContainer))
-#define GUPNP_DIDL_LITE_CONTAINER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_CONTAINER, \
- GUPnPDIDLLiteContainerClass))
-#define GUPNP_IS_DIDL_LITE_CONTAINER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_CONTAINER))
-#define GUPNP_IS_DIDL_LITE_CONTAINER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_CONTAINER))
-#define GUPNP_DIDL_LITE_CONTAINER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_DIDL_LITE_CONTAINER, \
- GUPnPDIDLLiteContainerClass))
-
-typedef struct {
- GUPnPDIDLLiteObject parent;
-} GUPnPDIDLLiteContainer;
-
-typedef struct {
+
+struct _GUPnPDIDLLiteContainerClass {
GUPnPDIDLLiteObjectClass parent_class;
/* future padding */
@@ -67,7 +48,7 @@ typedef struct {
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
-} GUPnPDIDLLiteContainerClass;
+};
gboolean
gupnp_didl_lite_container_get_searchable
diff --git a/libgupnp-av/gupnp-didl-lite-contributor.c b/libgupnp-av/gupnp-didl-lite-contributor.c
index 3e0ddbe..6359718 100644
--- a/libgupnp-av/gupnp-didl-lite-contributor.c
+++ b/libgupnp-av/gupnp-didl-lite-contributor.c
@@ -32,14 +32,14 @@
#include "gupnp-didl-lite-contributor-private.h"
#include "xml-util.h"
-struct _GUPnPDIDLLiteContributorPrivate {
+typedef struct _GUPnPDIDLLiteContributorPrivate {
xmlNode *xml_node;
GUPnPAVXMLDoc *xml_doc;
-};
+} GUPnPDIDLLiteContributorPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GUPnPDIDLLiteContributor,
gupnp_didl_lite_contributor,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
enum {
PROP_0,
@@ -52,8 +52,6 @@ enum {
static void
gupnp_didl_lite_contributor_init (GUPnPDIDLLiteContributor *contributor)
{
- contributor->priv =
- gupnp_didl_lite_contributor_get_instance_private (contributor);
}
static void
@@ -96,16 +94,17 @@ gupnp_didl_lite_contributor_set_property (GObject *object,
GParamSpec *pspec)
{
- GUPnPDIDLLiteContributor *contributor;
-
- contributor = GUPNP_DIDL_LITE_CONTRIBUTOR (object);
+ GUPnPDIDLLiteContributor *contributor =
+ GUPNP_DIDL_LITE_CONTRIBUTOR (object);
+ GUPnPDIDLLiteContributorPrivate *priv =
+ gupnp_didl_lite_contributor_get_instance_private (contributor);
switch (property_id) {
case PROP_XML_NODE:
- contributor->priv->xml_node = g_value_get_pointer (value);
+ priv->xml_node = g_value_get_pointer (value);
break;
case PROP_XML_DOC:
- contributor->priv->xml_doc = g_value_dup_boxed (value);
+ priv->xml_doc = g_value_dup_boxed (value);
break;
case PROP_ROLE:
gupnp_didl_lite_contributor_set_role
@@ -127,9 +126,11 @@ static void
gupnp_didl_lite_contributor_dispose (GObject *object)
{
GObjectClass *object_class;
- GUPnPDIDLLiteContributorPrivate *priv;
- priv = GUPNP_DIDL_LITE_CONTRIBUTOR (object)->priv;
+ GUPnPDIDLLiteContributor *contributor =
+ GUPNP_DIDL_LITE_CONTRIBUTOR (object);
+ GUPnPDIDLLiteContributorPrivate *priv =
+ gupnp_didl_lite_contributor_get_instance_private (contributor);
g_clear_pointer (&priv->xml_doc, av_xml_doc_unref);
@@ -239,9 +240,10 @@ gupnp_didl_lite_contributor_get_role (GUPnPDIDLLiteContributor *contributor)
g_return_val_if_fail (contributor != NULL, NULL);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CONTRIBUTOR (contributor),
NULL);
+ GUPnPDIDLLiteContributorPrivate *priv =
+ gupnp_didl_lite_contributor_get_instance_private (contributor);
- return av_xml_util_get_attribute_content (contributor->priv->xml_node,
- "role");
+ return av_xml_util_get_attribute_content (priv->xml_node, "role");
}
/**
@@ -257,8 +259,10 @@ gupnp_didl_lite_contributor_get_name (GUPnPDIDLLiteContributor *contributor)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CONTRIBUTOR (contributor),
NULL);
+ GUPnPDIDLLiteContributorPrivate *priv =
+ gupnp_didl_lite_contributor_get_instance_private (contributor);
- return (const char *) contributor->priv->xml_node->children->content;
+ return (const char *) priv->xml_node->children->content;
}
/**
@@ -275,7 +279,10 @@ gupnp_didl_lite_contributor_set_role (GUPnPDIDLLiteContributor *contributor,
g_return_if_fail (contributor != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_CONTRIBUTOR (contributor));
- xmlSetProp (contributor->priv->xml_node,
+ GUPnPDIDLLiteContributorPrivate *priv =
+ gupnp_didl_lite_contributor_get_instance_private (contributor);
+
+ xmlSetProp (priv->xml_node,
(unsigned char *) "role",
(unsigned char *) role);
@@ -298,9 +305,12 @@ gupnp_didl_lite_contributor_set_name (GUPnPDIDLLiteContributor *contributor,
g_return_if_fail (GUPNP_IS_DIDL_LITE_CONTRIBUTOR (contributor));
g_return_if_fail (name != NULL);
- escaped = xmlEncodeSpecialChars (contributor->priv->xml_doc->doc,
+ GUPnPDIDLLiteContributorPrivate *priv =
+ gupnp_didl_lite_contributor_get_instance_private (contributor);
+
+ escaped = xmlEncodeSpecialChars (priv->xml_doc->doc,
(const unsigned char *) name);
- xmlNodeSetContent (contributor->priv->xml_node, escaped);
+ xmlNodeSetContent (priv->xml_node, escaped);
xmlFree (escaped);
g_object_notify (G_OBJECT (contributor), "name");
@@ -338,6 +348,8 @@ gupnp_didl_lite_contributor_get_xml_node (GUPnPDIDLLiteContributor *contributor)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CONTRIBUTOR (contributor),
NULL);
+ GUPnPDIDLLiteContributorPrivate *priv =
+ gupnp_didl_lite_contributor_get_instance_private (contributor);
- return contributor->priv->xml_node;
+ return priv->xml_node;
}
diff --git a/libgupnp-av/gupnp-didl-lite-contributor.h b/libgupnp-av/gupnp-didl-lite-contributor.h
index dbedae7..60028c3 100644
--- a/libgupnp-av/gupnp-didl-lite-contributor.h
+++ b/libgupnp-av/gupnp-didl-lite-contributor.h
@@ -28,39 +28,16 @@
G_BEGIN_DECLS
-GType
-gupnp_didl_lite_contributor_get_type (void) G_GNUC_CONST;
+G_DECLARE_DERIVABLE_TYPE(GUPnPDIDLLiteContributor,
+ gupnp_didl_lite_contributor,
+ GUPNP,
+ DIDL_LITE_CONTRIBUTOR,
+ GObject)
#define GUPNP_TYPE_DIDL_LITE_CONTRIBUTOR \
(gupnp_didl_lite_contributor_get_type ())
-#define GUPNP_DIDL_LITE_CONTRIBUTOR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_CONTRIBUTOR, \
- GUPnPDIDLLiteContributor))
-#define GUPNP_DIDL_LITE_CONTRIBUTOR_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_CONTRIBUTOR, \
- GUPnPDIDLLiteContributorClass))
-#define GUPNP_IS_DIDL_LITE_CONTRIBUTOR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_CONTRIBUTOR))
-#define GUPNP_IS_DIDL_LITE_CONTRIBUTOR_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_CONTRIBUTOR))
-#define GUPNP_DIDL_LITE_CONTRIBUTOR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_DIDL_LITE_CONTRIBUTOR, \
- GUPnPDIDLLiteContributorClass))
-typedef struct _GUPnPDIDLLiteContributorPrivate GUPnPDIDLLiteContributorPrivate;
-
-typedef struct {
- GObject parent;
-
- GUPnPDIDLLiteContributorPrivate *priv;
-} GUPnPDIDLLiteContributor;
-
-typedef struct {
+struct _GUPnPDIDLLiteContributorClass{
GObjectClass parent_class;
/* future padding */
@@ -68,7 +45,7 @@ typedef struct {
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
-} GUPnPDIDLLiteContributorClass;
+};
const char *
gupnp_didl_lite_contributor_get_role (GUPnPDIDLLiteContributor *contributor);
diff --git a/libgupnp-av/gupnp-didl-lite-createclass.c b/libgupnp-av/gupnp-didl-lite-createclass.c
index f0e86a9..ffcd53f 100644
--- a/libgupnp-av/gupnp-didl-lite-createclass.c
+++ b/libgupnp-av/gupnp-didl-lite-createclass.c
@@ -40,9 +40,11 @@ struct _GUPnPDIDLLiteCreateClassPrivate {
GUPnPAVXMLDoc *xml_doc;
};
+typedef struct _GUPnPDIDLLiteCreateClassPrivate GUPnPDIDLLiteCreateClassPrivate;
+
G_DEFINE_TYPE_WITH_PRIVATE (GUPnPDIDLLiteCreateClass,
gupnp_didl_lite_create_class,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
enum {
PROP_0,
@@ -56,8 +58,6 @@ enum {
static void
gupnp_didl_lite_create_class_init (GUPnPDIDLLiteCreateClass *create_class)
{
- create_class->priv = gupnp_didl_lite_create_class_get_instance_private (
- create_class);
}
static void
@@ -110,13 +110,16 @@ gupnp_didl_lite_create_class_set_property (GObject *object,
GUPnPDIDLLiteCreateClass *create_class;
create_class = GUPNP_DIDL_LITE_CREATE_CLASS (object);
+ GUPnPDIDLLiteCreateClassPrivate *priv =
+ gupnp_didl_lite_create_class_get_instance_private (
+ create_class);
switch (property_id) {
case PROP_XML_NODE:
- create_class->priv->xml_node = g_value_get_pointer (value);
+ priv->xml_node = g_value_get_pointer (value);
break;
case PROP_XML_DOC:
- create_class->priv->xml_doc = g_value_dup_boxed (value);
+ priv->xml_doc = g_value_dup_boxed (value);
break;
case PROP_CONTENT:
gupnp_didl_lite_create_class_set_content
@@ -143,9 +146,9 @@ static void
gupnp_didl_lite_create_class_dispose (GObject *object)
{
GObjectClass *object_class;
- GUPnPDIDLLiteCreateClassPrivate *priv;
-
- priv = GUPNP_DIDL_LITE_CREATE_CLASS (object)->priv;
+ GUPnPDIDLLiteCreateClassPrivate *priv =
+ gupnp_didl_lite_create_class_get_instance_private (
+ GUPNP_DIDL_LITE_CREATE_CLASS (object));
g_clear_pointer (&priv->xml_doc, av_xml_doc_unref);
@@ -277,11 +280,14 @@ gupnp_didl_lite_create_class_get_content
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class),
NULL);
+ GUPnPDIDLLiteCreateClassPrivate *priv =
+ gupnp_didl_lite_create_class_get_instance_private (
+ create_class);
- if (G_UNLIKELY (create_class->priv->xml_node->children == NULL))
+ if (G_UNLIKELY (priv->xml_node->children == NULL))
return NULL;
- return (const char *) create_class->priv->xml_node->children->content;
+ return (const char *) priv->xml_node->children->content;
}
/**
@@ -296,14 +302,16 @@ gupnp_didl_lite_create_class_set_content
(GUPnPDIDLLiteCreateClass *create_class,
const char *content)
{
- xmlChar *escaped;
-
g_return_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class));
g_return_if_fail (create_class != NULL);
- escaped = xmlEncodeSpecialChars (create_class->priv->xml_doc->doc,
- (const unsigned char *) content);
- xmlNodeSetContent (create_class->priv->xml_node, escaped);
+ GUPnPDIDLLiteCreateClassPrivate *priv =
+ gupnp_didl_lite_create_class_get_instance_private (
+ create_class);
+ xmlChar *escaped =
+ xmlEncodeSpecialChars (priv->xml_doc->doc,
+ (const unsigned char *) content);
+ xmlNodeSetContent (priv->xml_node, escaped);
xmlFree (escaped);
g_object_notify (G_OBJECT (create_class), "content");
@@ -323,8 +331,11 @@ gupnp_didl_lite_create_class_get_include_derived
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class),
FALSE);
+ GUPnPDIDLLiteCreateClassPrivate *priv =
+ gupnp_didl_lite_create_class_get_instance_private (
+ create_class);
- return av_xml_util_get_boolean_attribute (create_class->priv->xml_node,
+ return av_xml_util_get_boolean_attribute (priv->xml_node,
"includeDerived");
}
@@ -345,11 +356,16 @@ gupnp_didl_lite_create_class_set_include_derived
g_return_if_fail (create_class != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class));
+ GUPnPDIDLLiteCreateClassPrivate *priv =
+ gupnp_didl_lite_create_class_get_instance_private (
+ create_class);
+
if (include_derived)
str = "1";
else
str = "0";
- xmlSetProp (create_class->priv->xml_node,
+
+ xmlSetProp (priv->xml_node,
(unsigned char *) "includeDerived",
(unsigned char *) str);
@@ -370,8 +386,11 @@ gupnp_didl_lite_create_class_get_friendly_name
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class),
NULL);
- return av_xml_util_get_attribute_content (create_class->priv->xml_node,
- "name");
+ GUPnPDIDLLiteCreateClassPrivate *priv =
+ gupnp_didl_lite_create_class_get_instance_private (
+ create_class);
+
+ return av_xml_util_get_attribute_content (priv->xml_node, "name");
}
/**
@@ -389,7 +408,11 @@ gupnp_didl_lite_create_class_set_friendly_name
g_return_if_fail (create_class != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class));
- xmlSetProp (create_class->priv->xml_node,
+ GUPnPDIDLLiteCreateClassPrivate *priv =
+ gupnp_didl_lite_create_class_get_instance_private (
+ create_class);
+
+ xmlSetProp (priv->xml_node,
(unsigned char *) "name",
(const unsigned char *) friendly_name);
@@ -429,6 +452,9 @@ gupnp_didl_lite_create_class_get_xml_node
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class),
NULL);
+ GUPnPDIDLLiteCreateClassPrivate *priv =
+ gupnp_didl_lite_create_class_get_instance_private (
+ create_class);
- return create_class->priv->xml_node;
+ return priv->xml_node;
}
diff --git a/libgupnp-av/gupnp-didl-lite-createclass.h b/libgupnp-av/gupnp-didl-lite-createclass.h
index fd94093..f754670 100644
--- a/libgupnp-av/gupnp-didl-lite-createclass.h
+++ b/libgupnp-av/gupnp-didl-lite-createclass.h
@@ -22,8 +22,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GUPNP_DIDL_LITE_CREATE_CLASS_H__
-#define __GUPNP_DIDL_LITE_CREATE_CLASS_H__
+#ifndef GUPNP_DIDL_LITE_CREATE_CLASS_H
+#define GUPNP_DIDL_LITE_CREATE_CLASS_H
#include <glib-object.h>
#include <libxml/tree.h>
@@ -31,43 +31,16 @@
G_BEGIN_DECLS
-GType
-gupnp_didl_lite_create_class_get_type (void) G_GNUC_CONST;
+G_DECLARE_DERIVABLE_TYPE(GUPnPDIDLLiteCreateClass,
+ gupnp_didl_lite_create_class,
+ GUPNP,
+ DIDL_LITE_CREATE_CLASS,
+ GObject)
#define GUPNP_TYPE_DIDL_LITE_CREATE_CLASS \
(gupnp_didl_lite_create_class_get_type ())
-#define GUPNP_DIDL_LITE_CREATE_CLASS(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_CREATE_CLASS, \
- GUPnPDIDLLiteCreateClass))
-#define GUPNP_DIDL_LITE_CREATE_CLASS_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_CREATE_CLASS, \
- GUPnPDIDLLiteCreateClassClass))
-#define GUPNP_IS_DIDL_LITE_CREATE_CLASS(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_CREATE_CLASS))
-#define GUPNP_IS_DIDL_LITE_CREATE_CLASS_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_CREATE_CLASS))
-#define GUPNP_DIDL_LITE_CREATE_CLASS_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_DIDL_LITE_CREATE_CLASS, \
- GUPnPDIDLLiteCreateClassClass))
-
-typedef struct _GUPnPDIDLLiteCreateClassPrivate GUPnPDIDLLiteCreateClassPrivate;
-
-/**
- * GUPnPDIDLLiteCreateClass:
- **/
-typedef struct {
- GObject parent;
-
- /*< private >*/
- GUPnPDIDLLiteCreateClassPrivate *priv;
-} GUPnPDIDLLiteCreateClass;
-
-typedef struct {
+
+struct _GUPnPDIDLLiteCreateClassClass {
GObjectClass parent_class;
/* future padding */
@@ -75,7 +48,7 @@ typedef struct {
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
-} GUPnPDIDLLiteCreateClassClass;
+};
const char *
gupnp_didl_lite_create_class_get_content
diff --git a/libgupnp-av/gupnp-didl-lite-descriptor.c b/libgupnp-av/gupnp-didl-lite-descriptor.c
index ab68ec0..3a568a5 100644
--- a/libgupnp-av/gupnp-didl-lite-descriptor.c
+++ b/libgupnp-av/gupnp-didl-lite-descriptor.c
@@ -37,10 +37,12 @@ struct _GUPnPDIDLLiteDescriptorPrivate {
xmlNode *xml_node;
GUPnPAVXMLDoc *xml_doc;
};
+typedef struct _GUPnPDIDLLiteDescriptorPrivate GUPnPDIDLLiteDescriptorPrivate;
+
G_DEFINE_TYPE_WITH_PRIVATE (GUPnPDIDLLiteDescriptor,
gupnp_didl_lite_descriptor,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
enum {
PROP_0,
@@ -56,8 +58,6 @@ enum {
static void
gupnp_didl_lite_descriptor_init (GUPnPDIDLLiteDescriptor *descriptor)
{
- descriptor->priv =
- gupnp_didl_lite_descriptor_get_instance_private (descriptor);
}
static void
@@ -69,13 +69,15 @@ gupnp_didl_lite_descriptor_set_property (GObject *object,
GUPnPDIDLLiteDescriptor *descriptor;
descriptor = GUPNP_DIDL_LITE_DESCRIPTOR (object);
+ GUPnPDIDLLiteDescriptorPrivate *priv =
+ gupnp_didl_lite_descriptor_get_instance_private (descriptor);
switch (property_id) {
case PROP_XML_NODE:
- descriptor->priv->xml_node = g_value_get_pointer (value);
+ priv->xml_node = g_value_get_pointer (value);
break;
case PROP_XML_DOC:
- descriptor->priv->xml_doc = g_value_dup_boxed (value);
+ priv->xml_doc = g_value_dup_boxed (value);
break;
case PROP_ID:
gupnp_didl_lite_descriptor_set_id
@@ -151,9 +153,9 @@ static void
gupnp_didl_lite_descriptor_dispose (GObject *object)
{
GObjectClass *object_class;
- GUPnPDIDLLiteDescriptorPrivate *priv;
-
- priv = GUPNP_DIDL_LITE_DESCRIPTOR (object)->priv;
+ GUPnPDIDLLiteDescriptorPrivate *priv =
+ gupnp_didl_lite_descriptor_get_instance_private (
+ GUPNP_DIDL_LITE_DESCRIPTOR (object));
g_clear_pointer (&priv->xml_doc, av_xml_doc_unref);
@@ -326,8 +328,10 @@ xmlNode *
gupnp_didl_lite_descriptor_get_xml_node (GUPnPDIDLLiteDescriptor *descriptor)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_DESCRIPTOR (descriptor), NULL);
+ GUPnPDIDLLiteDescriptorPrivate *priv =
+ gupnp_didl_lite_descriptor_get_instance_private (descriptor);
- return descriptor->priv->xml_node;
+ return priv->xml_node;
}
/**
@@ -342,8 +346,10 @@ const char *
gupnp_didl_lite_descriptor_get_content (GUPnPDIDLLiteDescriptor *descriptor)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_DESCRIPTOR (descriptor), NULL);
+ GUPnPDIDLLiteDescriptorPrivate *priv =
+ gupnp_didl_lite_descriptor_get_instance_private (descriptor);
- return (const char *) descriptor->priv->xml_node->children;
+ return (const char *) priv->xml_node->children;
}
/**
@@ -358,9 +364,10 @@ const char *
gupnp_didl_lite_descriptor_get_id (GUPnPDIDLLiteDescriptor *descriptor)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_DESCRIPTOR (descriptor), NULL);
+ GUPnPDIDLLiteDescriptorPrivate *priv =
+ gupnp_didl_lite_descriptor_get_instance_private (descriptor);
- return av_xml_util_get_attribute_content (descriptor->priv->xml_node,
- "id");
+ return av_xml_util_get_attribute_content (priv->xml_node, "id");
}
/**
@@ -376,9 +383,10 @@ gupnp_didl_lite_descriptor_get_metadata_type
(GUPnPDIDLLiteDescriptor *descriptor)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_DESCRIPTOR (descriptor), NULL);
+ GUPnPDIDLLiteDescriptorPrivate *priv =
+ gupnp_didl_lite_descriptor_get_instance_private (descriptor);
- return av_xml_util_get_attribute_content (descriptor->priv->xml_node,
- "type");
+ return av_xml_util_get_attribute_content (priv->xml_node, "type");
}
/**
@@ -393,9 +401,10 @@ const char *
gupnp_didl_lite_descriptor_get_name_space (GUPnPDIDLLiteDescriptor *descriptor)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_DESCRIPTOR (descriptor), NULL);
+ GUPnPDIDLLiteDescriptorPrivate *priv =
+ gupnp_didl_lite_descriptor_get_instance_private (descriptor);
- return av_xml_util_get_attribute_content (descriptor->priv->xml_node,
- "nameSpace");
+ return av_xml_util_get_attribute_content (priv->xml_node, "nameSpace");
}
/**
@@ -413,10 +422,12 @@ gupnp_didl_lite_descriptor_set_content (GUPnPDIDLLiteDescriptor *descriptor,
g_return_if_fail (GUPNP_IS_DIDL_LITE_DESCRIPTOR (descriptor));
g_return_if_fail (content != NULL);
+ GUPnPDIDLLiteDescriptorPrivate *priv =
+ gupnp_didl_lite_descriptor_get_instance_private (descriptor);
- escaped = xmlEncodeSpecialChars (descriptor->priv->xml_doc->doc,
+ escaped = xmlEncodeSpecialChars (priv->xml_doc->doc,
(const unsigned char *) content);
- xmlNodeSetContent (descriptor->priv->xml_node, escaped);
+ xmlNodeSetContent (priv->xml_node, escaped);
xmlFree (escaped);
g_object_notify (G_OBJECT (descriptor), "content");
@@ -435,8 +446,10 @@ gupnp_didl_lite_descriptor_set_id (GUPnPDIDLLiteDescriptor *descriptor,
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_DESCRIPTOR (descriptor));
g_return_if_fail (id != NULL);
+ GUPnPDIDLLiteDescriptorPrivate *priv =
+ gupnp_didl_lite_descriptor_get_instance_private (descriptor);
- xmlSetProp (descriptor->priv->xml_node,
+ xmlSetProp (priv->xml_node,
(unsigned char *) "id",
(const unsigned char *) id);
@@ -457,8 +470,10 @@ gupnp_didl_lite_descriptor_set_metadata_type
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_DESCRIPTOR (descriptor));
g_return_if_fail (type != NULL);
+ GUPnPDIDLLiteDescriptorPrivate *priv =
+ gupnp_didl_lite_descriptor_get_instance_private (descriptor);
- xmlSetProp (descriptor->priv->xml_node,
+ xmlSetProp (priv->xml_node,
(unsigned char *) "type",
(const unsigned char *) type);
@@ -479,7 +494,10 @@ gupnp_didl_lite_descriptor_set_name_space (GUPnPDIDLLiteDescriptor *descriptor,
g_return_if_fail (GUPNP_IS_DIDL_LITE_DESCRIPTOR (descriptor));
g_return_if_fail (name_space != NULL);
- xmlSetProp (descriptor->priv->xml_node,
+ GUPnPDIDLLiteDescriptorPrivate *priv =
+ gupnp_didl_lite_descriptor_get_instance_private (descriptor);
+
+ xmlSetProp (priv->xml_node,
(unsigned char *) "nameSpace",
(const unsigned char *) name_space);
diff --git a/libgupnp-av/gupnp-didl-lite-descriptor.h b/libgupnp-av/gupnp-didl-lite-descriptor.h
index 5f7e304..9648ca3 100644
--- a/libgupnp-av/gupnp-didl-lite-descriptor.h
+++ b/libgupnp-av/gupnp-didl-lite-descriptor.h
@@ -20,8 +20,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GUPNP_DIDL_LITE_DESCRIPTOR_H__
-#define __GUPNP_DIDL_LITE_DESCRIPTOR_H__
+#ifndef GUPNP_DIDL_LITE_DESCRIPTOR_H
+#define GUPNP_DIDL_LITE_DESCRIPTOR_H
#include <stdarg.h>
#include <glib-object.h>
@@ -29,39 +29,15 @@
G_BEGIN_DECLS
-GType
-gupnp_didl_lite_descriptor_get_type (void) G_GNUC_CONST;
-
-#define GUPNP_TYPE_DIDL_LITE_DESCRIPTOR \
- (gupnp_didl_lite_descriptor_get_type ())
-#define GUPNP_DIDL_LITE_DESCRIPTOR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_DESCRIPTOR, \
- GUPnPDIDLLiteDescriptor))
-#define GUPNP_DIDL_LITE_DESCRIPTOR_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_DESCRIPTOR, \
- GUPnPDIDLLiteDescriptorClass))
-#define GUPNP_IS_DIDL_LITE_DESCRIPTOR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_DESCRIPTOR))
-#define GUPNP_IS_DIDL_LITE_DESCRIPTOR_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_DESCRIPTOR))
-#define GUPNP_DIDL_LITE_DESCRIPTOR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_DIDL_LITE_DESCRIPTOR, \
- GUPnPDIDLLiteDescriptorClass))
-
-typedef struct _GUPnPDIDLLiteDescriptorPrivate GUPnPDIDLLiteDescriptorPrivate;
-
-typedef struct {
- GObject parent;
-
- GUPnPDIDLLiteDescriptorPrivate *priv;
-} GUPnPDIDLLiteDescriptor;
-
-typedef struct {
+#define GUPNP_TYPE_DIDL_LITE_DESCRIPTOR gupnp_didl_lite_descriptor_get_type ()
+
+G_DECLARE_DERIVABLE_TYPE (GUPnPDIDLLiteDescriptor,
+ gupnp_didl_lite_descriptor,
+ GUPNP,
+ DIDL_LITE_DESCRIPTOR,
+ GObject)
+
+struct _GUPnPDIDLLiteDescriptorClass {
GObjectClass parent_class;
/* future padding */
@@ -69,7 +45,7 @@ typedef struct {
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
-} GUPnPDIDLLiteDescriptorClass;
+};
GUPnPDIDLLiteDescriptor *
gupnp_didl_lite_descriptor_new (void);
diff --git a/libgupnp-av/gupnp-didl-lite-item.c b/libgupnp-av/gupnp-didl-lite-item.c
index 03bbfc1..f6e73d8 100644
--- a/libgupnp-av/gupnp-didl-lite-item.c
+++ b/libgupnp-av/gupnp-didl-lite-item.c
@@ -35,7 +35,7 @@
G_DEFINE_TYPE (GUPnPDIDLLiteItem,
gupnp_didl_lite_item,
- GUPNP_TYPE_DIDL_LITE_OBJECT);
+ GUPNP_TYPE_DIDL_LITE_OBJECT)
enum {
PROP_0,
diff --git a/libgupnp-av/gupnp-didl-lite-item.h b/libgupnp-av/gupnp-didl-lite-item.h
index e55c271..9fa5431 100644
--- a/libgupnp-av/gupnp-didl-lite-item.h
+++ b/libgupnp-av/gupnp-didl-lite-item.h
@@ -22,43 +22,24 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GUPNP_DIDL_LITE_ITEM_H__
-#define __GUPNP_DIDL_LITE_ITEM_H__
+#ifndef GUPNP_DIDL_LITE_ITEM_H
+#define GUPNP_DIDL_LITE_ITEM_H
#include <glib-object.h>
#include "gupnp-didl-lite-object.h"
G_BEGIN_DECLS
-GType
-gupnp_didl_lite_item_get_type (void) G_GNUC_CONST;
+G_DECLARE_DERIVABLE_TYPE(GUPnPDIDLLiteItem,
+ gupnp_didl_lite_item,
+ GUPNP,
+ DIDL_LITE_ITEM,
+ GUPnPDIDLLiteObject)
#define GUPNP_TYPE_DIDL_LITE_ITEM \
(gupnp_didl_lite_item_get_type ())
-#define GUPNP_DIDL_LITE_ITEM(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_ITEM, \
- GUPnPDIDLLiteItem))
-#define GUPNP_DIDL_LITE_ITEM_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_ITEM, \
- GUPnPDIDLLiteItemClass))
-#define GUPNP_IS_DIDL_LITE_ITEM(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_ITEM))
-#define GUPNP_IS_DIDL_LITE_ITEM_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_ITEM))
-#define GUPNP_DIDL_LITE_ITEM_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_DIDL_LITE_ITEM, \
- GUPnPDIDLLiteItemClass))
-typedef struct {
- GUPnPDIDLLiteObject parent;
-} GUPnPDIDLLiteItem;
-
-typedef struct {
+struct _GUPnPDIDLLiteItemClass {
GUPnPDIDLLiteObjectClass parent_class;
/* future padding */
@@ -66,7 +47,7 @@ typedef struct {
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
-} GUPnPDIDLLiteItemClass;
+};
const char *
gupnp_didl_lite_item_get_ref_id (GUPnPDIDLLiteItem *item);
@@ -84,4 +65,4 @@ gupnp_didl_lite_item_get_lifetime (GUPnPDIDLLiteItem *item);
G_END_DECLS
-#endif /* __GUPNP_DIDL_LITE_ITEM_H__ */
+#endif /* GUPNP_DIDL_LITE_ITEM_H */
diff --git a/libgupnp-av/gupnp-didl-lite-object.c b/libgupnp-av/gupnp-didl-lite-object.c
index b8de85a..1687d45 100644
--- a/libgupnp-av/gupnp-didl-lite-object.c
+++ b/libgupnp-av/gupnp-didl-lite-object.c
@@ -54,7 +54,7 @@ struct _GUPnPDIDLLiteObjectPrivate {
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GUPnPDIDLLiteObject,
gupnp_didl_lite_object,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
static XSDData *didl_lite_xsd;
@@ -101,7 +101,6 @@ is_non_transcoded_resource (GUPnPDIDLLiteResource *resource, gpointer data)
static void
gupnp_didl_lite_object_init (GUPnPDIDLLiteObject *object)
{
- object->priv = gupnp_didl_lite_object_get_instance_private (object);
}
static void
@@ -112,27 +111,29 @@ gupnp_didl_lite_object_set_property (GObject *object,
{
GUPnPDIDLLiteObject *didl_object;
+ GUPnPDIDLLiteObjectPrivate *priv;
- didl_object = GUPNP_DIDL_LITE_OBJECT (object);
+ didl_object = GUPNP_DIDL_LITE_OBJECT(object);
+ priv = gupnp_didl_lite_object_get_instance_private(didl_object);
switch (property_id) {
case PROP_XML_NODE:
- didl_object->priv->xml_node = g_value_get_pointer (value);
+ priv->xml_node = g_value_get_pointer (value);
break;
case PROP_XML_DOC:
- didl_object->priv->xml_doc = g_value_dup_boxed (value);
+ priv->xml_doc = g_value_dup_boxed (value);
break;
case PROP_UPNP_NAMESPACE:
- didl_object->priv->upnp_ns = g_value_get_pointer (value);
+ priv->upnp_ns = g_value_get_pointer (value);
break;
case PROP_DC_NAMESPACE:
- didl_object->priv->dc_ns = g_value_get_pointer (value);
+ priv->dc_ns = g_value_get_pointer (value);
break;
case PROP_DLNA_NAMESPACE:
- didl_object->priv->dlna_ns = g_value_get_pointer (value);
+ priv->dlna_ns = g_value_get_pointer (value);
break;
case PROP_PV_NAMESPACE:
- didl_object->priv->pv_ns = g_value_get_pointer (value);
+ priv->pv_ns = g_value_get_pointer (value);
break;
case PROP_ID:
gupnp_didl_lite_object_set_id (didl_object,
@@ -360,8 +361,9 @@ gupnp_didl_lite_object_dispose (GObject *object)
{
GObjectClass *object_class;
GUPnPDIDLLiteObjectPrivate *priv;
+ GUPnPDIDLLiteObject *self = GUPNP_DIDL_LITE_OBJECT (object);
- priv = GUPNP_DIDL_LITE_OBJECT (object)->priv;
+ priv = gupnp_didl_lite_object_get_instance_private (self);
g_clear_pointer (&priv->xml_doc, av_xml_doc_unref);
@@ -844,6 +846,8 @@ get_contributor_list_by_name (GUPnPDIDLLiteObject *object,
GList *contributors = NULL;
GList *ret = NULL;
GList *l;
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
contributors = gupnp_didl_lite_object_get_properties (object, name);
@@ -857,7 +861,7 @@ get_contributor_list_by_name (GUPnPDIDLLiteObject *object,
contributor = gupnp_didl_lite_contributor_new_from_xml
(contributor_node,
- object->priv->xml_doc);
+ priv->xml_doc);
ret = g_list_append (ret, contributor);
}
@@ -875,6 +879,8 @@ get_contributors_xml_string_by_name (GUPnPDIDLLiteObject *object,
char *ret = NULL;
GList *l;
xmlBuffer *buffer;
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
contributors = gupnp_didl_lite_object_get_properties (object, name);
if (contributors == NULL)
@@ -890,7 +896,7 @@ get_contributors_xml_string_by_name (GUPnPDIDLLiteObject *object,
continue;
xmlNodeDump (buffer,
- object->priv->xml_doc->doc,
+ priv->xml_doc->doc,
node,
0,
0);
@@ -990,8 +996,10 @@ GUPnPAVXMLDoc *
gupnp_didl_lite_object_get_gupnp_xml_doc (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return object->priv->xml_doc;
+ return priv->xml_doc;
}
/**
@@ -1006,8 +1014,10 @@ xmlNode *
gupnp_didl_lite_object_get_xml_node (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return object->priv->xml_node;
+ return priv->xml_node;
}
/**
@@ -1022,10 +1032,12 @@ xmlNsPtr
gupnp_didl_lite_object_get_upnp_namespace (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_ns (object->priv->xml_doc->doc,
+ return av_xml_util_get_ns (priv->xml_doc->doc,
GUPNP_XML_NAMESPACE_UPNP,
- &(object->priv->upnp_ns));
+ &(priv->upnp_ns));
}
/**
@@ -1041,10 +1053,12 @@ xmlNsPtr
gupnp_didl_lite_object_get_dc_namespace (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_ns (object->priv->xml_doc->doc,
+ return av_xml_util_get_ns (priv->xml_doc->doc,
GUPNP_XML_NAMESPACE_DC,
- &(object->priv->dc_ns));
+ &(priv->dc_ns));
}
/**
@@ -1059,8 +1073,10 @@ const char *
gupnp_didl_lite_object_get_upnp_class (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_element_content (object->priv->xml_node,
+ return av_xml_util_get_child_element_content (priv->xml_node,
"class");
}
@@ -1077,10 +1093,12 @@ xmlNsPtr
gupnp_didl_lite_object_get_dlna_namespace (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_ns (object->priv->xml_doc->doc,
+ return av_xml_util_get_ns (priv->xml_doc->doc,
GUPNP_XML_NAMESPACE_DLNA,
- &(object->priv->dlna_ns));
+ &(priv->dlna_ns));
}
/**
@@ -1096,10 +1114,12 @@ xmlNsPtr
gupnp_didl_lite_object_get_pv_namespace (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_ns (object->priv->xml_doc->doc,
+ return av_xml_util_get_ns (priv->xml_doc->doc,
GUPNP_XML_NAMESPACE_PV,
- &(object->priv->pv_ns));
+ &(priv->pv_ns));
}
@@ -1115,9 +1135,10 @@ const char *
gupnp_didl_lite_object_get_id (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_attribute_content (object->priv->xml_node,
- "id");
+ return av_xml_util_get_attribute_content (priv->xml_node, "id");
}
/**
@@ -1132,9 +1153,10 @@ const char *
gupnp_didl_lite_object_get_parent_id (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_attribute_content (object->priv->xml_node,
- "parentID");
+ return av_xml_util_get_attribute_content (priv->xml_node, "parentID");
}
/**
@@ -1154,9 +1176,10 @@ gupnp_didl_lite_object_get_properties (GUPnPDIDLLiteObject *object,
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
g_return_val_if_fail (name != NULL, NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_elements_by_name (object->priv->xml_node,
- name);
+ return av_xml_util_get_child_elements_by_name (priv->xml_node, name);
}
/**
@@ -1172,8 +1195,10 @@ gupnp_didl_lite_object_is_restricted_set (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (object != NULL, FALSE);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), FALSE);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_attribute_content (object->priv->xml_node,
+ return av_xml_util_get_attribute_content (priv->xml_node,
"restricted") != NULL;
}
@@ -1189,9 +1214,10 @@ gboolean
gupnp_didl_lite_object_get_restricted (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), FALSE);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_boolean_attribute (object->priv->xml_node,
- "restricted");
+ return av_xml_util_get_boolean_attribute (priv->xml_node, "restricted");
}
/**
@@ -1206,9 +1232,10 @@ const char *
gupnp_didl_lite_object_get_title (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_element_content (object->priv->xml_node,
- "title");
+ return av_xml_util_get_child_element_content (priv->xml_node, "title");
}
/**
@@ -1223,8 +1250,10 @@ const char *
gupnp_didl_lite_object_get_creator (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_element_content (object->priv->xml_node,
+ return av_xml_util_get_child_element_content (priv->xml_node,
"creator");
}
@@ -1261,9 +1290,10 @@ const char *
gupnp_didl_lite_object_get_artist (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_element_content (object->priv->xml_node,
- "artist");
+ return av_xml_util_get_child_element_content (priv->xml_node, "artist");
}
/**
@@ -1298,9 +1328,10 @@ const char *
gupnp_didl_lite_object_get_author (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_element_content (object->priv->xml_node,
- "author");
+ return av_xml_util_get_child_element_content (priv->xml_node, "author");
}
/**
@@ -1337,6 +1368,8 @@ gupnp_didl_lite_object_get_descriptors (GUPnPDIDLLiteObject *object)
GList *descriptors = NULL;
GList *ret = NULL;
GList *l;
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
@@ -1348,9 +1381,9 @@ gupnp_didl_lite_object_get_descriptors (GUPnPDIDLLiteObject *object)
descriptor_node = (xmlNode *) l->data;
- descriptor = gupnp_didl_lite_descriptor_new_from_xml
- (descriptor_node,
- object->priv->xml_doc);
+ descriptor = gupnp_didl_lite_descriptor_new_from_xml (
+ descriptor_node,
+ priv->xml_doc);
ret = g_list_append (ret, descriptor);
}
@@ -1372,9 +1405,10 @@ const char *
gupnp_didl_lite_object_get_genre (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_element_content (object->priv->xml_node,
- "genre");
+ return av_xml_util_get_child_element_content (priv->xml_node, "genre");
}
/**
@@ -1389,8 +1423,10 @@ const char *
gupnp_didl_lite_object_get_write_status (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_element_content (object->priv->xml_node,
+ return av_xml_util_get_child_element_content (priv->xml_node,
"writeStatus");
}
@@ -1406,9 +1442,10 @@ const char *
gupnp_didl_lite_object_get_album (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_element_content (object->priv->xml_node,
- "album");
+ return av_xml_util_get_child_element_content (priv->xml_node, "album");
}
/**
@@ -1423,8 +1460,10 @@ const char *
gupnp_didl_lite_object_get_album_art (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_element_content (object->priv->xml_node,
+ return av_xml_util_get_child_element_content (priv->xml_node,
"albumArtURI");
}
@@ -1440,8 +1479,10 @@ const char *
gupnp_didl_lite_object_get_description (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_element_content (object->priv->xml_node,
+ return av_xml_util_get_child_element_content (priv->xml_node,
"description");
}
@@ -1457,9 +1498,10 @@ const char *
gupnp_didl_lite_object_get_date (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_element_content (object->priv->xml_node,
- "date");
+ return av_xml_util_get_child_element_content (priv->xml_node, "date");
}
/**
@@ -1476,8 +1518,10 @@ gupnp_didl_lite_object_get_track_number (GUPnPDIDLLiteObject *object)
const char *str;
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), -1);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- str = av_xml_util_get_child_element_content (object->priv->xml_node,
+ str = av_xml_util_get_child_element_content (priv->xml_node,
"originalTrackNumber");
if (str == NULL)
return -1;
@@ -1502,8 +1546,10 @@ gupnp_didl_lite_object_get_dlna_managed (GUPnPDIDLLiteObject *object)
g_return_val_if_fail (object != NULL, GUPNP_OCM_FLAGS_NONE);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object),
GUPNP_OCM_FLAGS_NONE);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- str = av_xml_util_get_attribute_content (object->priv->xml_node,
+ str = av_xml_util_get_attribute_content (priv->xml_node,
"dlnaManaged");
if (str == NULL)
return GUPNP_OCM_FLAGS_NONE;
@@ -1526,8 +1572,10 @@ gupnp_didl_lite_object_get_update_id (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (object != NULL, 0);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), 0);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_uint_child_element (object->priv->xml_node,
+ return av_xml_util_get_uint_child_element (priv->xml_node,
"objectUpdateID",
0);
}
@@ -1547,8 +1595,10 @@ gupnp_didl_lite_object_update_id_is_set (GUPnPDIDLLiteObject *object)
g_return_val_if_fail (object != NULL, FALSE);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), FALSE);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- content = av_xml_util_get_child_element_content (object->priv->xml_node,
+ content = av_xml_util_get_child_element_content (priv->xml_node,
"objectUpdateID");
return content != NULL;
}
@@ -1571,6 +1621,8 @@ gupnp_didl_lite_object_get_resources (GUPnPDIDLLiteObject *object)
GList *ret = NULL;
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
resources = gupnp_didl_lite_object_get_properties (object, "res");
@@ -1581,11 +1633,10 @@ gupnp_didl_lite_object_get_resources (GUPnPDIDLLiteObject *object)
res_node = (xmlNode *) res->data;
/* Create a resource struct out of DIDLLite XML */
- resource = gupnp_didl_lite_resource_new_from_xml
- (res_node,
- object->priv->xml_doc,
- object->priv->dlna_ns,
- object->priv->pv_ns);
+ resource = gupnp_didl_lite_resource_new_from_xml (res_node,
+ priv->xml_doc,
+ priv->dlna_ns,
+ priv->pv_ns);
ret = g_list_append (ret, resource);
}
@@ -1689,11 +1740,13 @@ gupnp_didl_lite_object_set_upnp_class (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_UPNP,
- &(object->priv->upnp_ns),
- object->priv->xml_doc->doc,
+ &(priv->upnp_ns),
+ priv->xml_doc->doc,
"class",
upnp_class);
@@ -1713,8 +1766,10 @@ gupnp_didl_lite_object_set_id (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- xmlSetProp (object->priv->xml_node,
+ xmlSetProp (priv->xml_node,
(unsigned char *) "id",
(unsigned char *) id);
@@ -1734,8 +1789,10 @@ gupnp_didl_lite_object_set_parent_id (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- xmlSetProp (object->priv->xml_node,
+ xmlSetProp (priv->xml_node,
(unsigned char *) "parentID",
(unsigned char *) parent_id);
@@ -1757,12 +1814,14 @@ gupnp_didl_lite_object_set_restricted (GUPnPDIDLLiteObject *object,
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
if (restricted)
str = "1";
else
str = "0";
- xmlSetProp (object->priv->xml_node,
+ xmlSetProp (priv->xml_node,
(unsigned char *) "restricted",
(unsigned char *) str);
@@ -1782,11 +1841,13 @@ gupnp_didl_lite_object_set_title (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_DC,
- &(object->priv->dc_ns),
- object->priv->xml_doc->doc,
+ &(priv->dc_ns),
+ priv->xml_doc->doc,
"title",
title);
@@ -1806,11 +1867,13 @@ gupnp_didl_lite_object_set_creator (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_DC,
- &(object->priv->dc_ns),
- object->priv->xml_doc->doc,
+ &(priv->dc_ns),
+ priv->xml_doc->doc,
"creator",
creator);
@@ -1833,14 +1896,16 @@ gupnp_didl_lite_object_add_creator (GUPnPDIDLLiteObject *object)
g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- res_node = xmlNewChild (object->priv->xml_node,
- object->priv->dc_ns,
+ res_node = xmlNewChild (priv->xml_node,
+ priv->dc_ns,
(unsigned char *) "creator",
NULL);
return gupnp_didl_lite_contributor_new_from_xml (res_node,
- object->priv->xml_doc);
+ priv->xml_doc);
}
@@ -1859,11 +1924,13 @@ gupnp_didl_lite_object_set_artist (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_UPNP,
- &(object->priv->upnp_ns),
- object->priv->xml_doc->doc,
+ &(priv->upnp_ns),
+ priv->xml_doc->doc,
"artist",
artist);
@@ -1886,14 +1953,16 @@ gupnp_didl_lite_object_add_artist (GUPnPDIDLLiteObject *object)
g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- res_node = xmlNewChild (object->priv->xml_node,
- object->priv->upnp_ns,
+ res_node = xmlNewChild (priv->xml_node,
+ priv->upnp_ns,
(unsigned char *) "artist",
NULL);
return gupnp_didl_lite_contributor_new_from_xml (res_node,
- object->priv->xml_doc);
+ priv->xml_doc);
}
/**
@@ -1911,11 +1980,13 @@ gupnp_didl_lite_object_set_author (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_DC,
- &(object->priv->upnp_ns),
- object->priv->xml_doc->doc,
+ &(priv->upnp_ns),
+ priv->xml_doc->doc,
"author",
author);
@@ -1938,14 +2009,16 @@ gupnp_didl_lite_object_add_author (GUPnPDIDLLiteObject *object)
g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- res_node = xmlNewChild (object->priv->xml_node,
- object->priv->upnp_ns,
+ res_node = xmlNewChild (priv->xml_node,
+ priv->upnp_ns,
(unsigned char *) "author",
NULL);
return gupnp_didl_lite_contributor_new_from_xml (res_node,
- object->priv->xml_doc);
+ priv->xml_doc);
}
/**
@@ -1961,11 +2034,13 @@ gupnp_didl_lite_object_set_genre (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_UPNP,
- &(object->priv->upnp_ns),
- object->priv->xml_doc->doc,
+ &(priv->upnp_ns),
+ priv->xml_doc->doc,
"genre",
genre);
@@ -1985,11 +2060,13 @@ gupnp_didl_lite_object_set_write_status (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_DC,
- &(object->priv->dc_ns),
- object->priv->xml_doc->doc,
+ &(priv->dc_ns),
+ priv->xml_doc->doc,
"writeStatus",
write_status);
@@ -2009,11 +2086,13 @@ gupnp_didl_lite_object_set_album (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_UPNP,
- &(object->priv->upnp_ns),
- object->priv->xml_doc->doc,
+ &(priv->upnp_ns),
+ priv->xml_doc->doc,
"album",
album);
@@ -2035,20 +2114,22 @@ gupnp_didl_lite_object_set_album_art (GUPnPDIDLLiteObject *object,
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- node = av_xml_util_set_child (object->priv->xml_node,
+ node = av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_UPNP,
- &(object->priv->upnp_ns),
- object->priv->xml_doc->doc,
+ &(priv->upnp_ns),
+ priv->xml_doc->doc,
"albumArtURI",
album_art);
- av_xml_util_get_ns (object->priv->xml_doc->doc,
+ av_xml_util_get_ns (priv->xml_doc->doc,
GUPNP_XML_NAMESPACE_DLNA,
- &(object->priv->dlna_ns));
+ &(priv->dlna_ns));
xmlSetNsProp (node,
- object->priv->dlna_ns,
+ priv->dlna_ns,
(const unsigned char *) "profileID",
(const unsigned char *) "JPEG_TN");
@@ -2068,11 +2149,13 @@ gupnp_didl_lite_object_set_description (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_DC,
- &(object->priv->dc_ns),
- object->priv->xml_doc->doc,
+ &(priv->dc_ns),
+ priv->xml_doc->doc,
"description",
description);
@@ -2092,11 +2175,13 @@ gupnp_didl_lite_object_set_date (GUPnPDIDLLiteObject *object,
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_DC,
- &(object->priv->dc_ns),
- object->priv->xml_doc->doc,
+ &(priv->dc_ns),
+ priv->xml_doc->doc,
"date",
date);
@@ -2118,12 +2203,14 @@ gupnp_didl_lite_object_set_track_number (GUPnPDIDLLiteObject *object,
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
str = g_strdup_printf ("%d", track_number);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_UPNP,
- &(object->priv->upnp_ns),
- object->priv->xml_doc->doc,
+ &(priv->upnp_ns),
+ priv->xml_doc->doc,
"originalTrackNumber",
str);
g_free (str);
@@ -2146,16 +2233,18 @@ gupnp_didl_lite_object_set_dlna_managed (GUPnPDIDLLiteObject *object,
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_get_ns (object->priv->xml_doc->doc,
+ av_xml_util_get_ns (priv->xml_doc->doc,
GUPNP_XML_NAMESPACE_DLNA,
- &(object->priv->dlna_ns));
+ &(priv->dlna_ns));
str = g_strdup_printf ("%08x", dlna_managed);
- xmlSetNsProp (object->priv->xml_node,
- object->priv->dlna_ns,
- (const unsigned char *) "dlnaManaged",
- (const unsigned char *) str);
+ xmlSetNsProp (priv->xml_node,
+ priv->dlna_ns,
+ (xmlChar *) "dlnaManaged",
+ (xmlChar *) str);
g_free (str);
g_object_notify (G_OBJECT (object), "dlna-managed");
@@ -2176,12 +2265,14 @@ gupnp_didl_lite_object_set_update_id (GUPnPDIDLLiteObject *object,
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
str = g_strdup_printf ("%u", update_id);
- av_xml_util_set_child (object->priv->xml_node,
+ av_xml_util_set_child (priv->xml_node,
GUPNP_XML_NAMESPACE_UPNP,
- &(object->priv->upnp_ns),
- object->priv->xml_doc->doc,
+ &(priv->upnp_ns),
+ priv->xml_doc->doc,
"objectUpdateID",
str);
g_free (str);
@@ -2200,8 +2291,10 @@ gupnp_didl_lite_object_unset_update_id (GUPnPDIDLLiteObject *object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object));
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- av_xml_util_unset_child (object->priv->xml_node,
+ av_xml_util_unset_child (priv->xml_node,
"objectUpdateID");
g_object_notify (G_OBJECT (object), "update-id");
@@ -2221,16 +2314,18 @@ gupnp_didl_lite_object_add_resource (GUPnPDIDLLiteObject *object)
xmlNode *res_node;
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- res_node = xmlNewChild (object->priv->xml_node,
+ res_node = xmlNewChild (priv->xml_node,
NULL,
(unsigned char *) "res",
NULL);
return gupnp_didl_lite_resource_new_from_xml (res_node,
- object->priv->xml_doc,
- object->priv->dlna_ns,
- object->priv->pv_ns);
+ priv->xml_doc,
+ priv->dlna_ns,
+ priv->pv_ns);
}
/**
@@ -2247,14 +2342,14 @@ gupnp_didl_lite_object_add_descriptor (GUPnPDIDLLiteObject *object)
xmlNode *desc_node;
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- desc_node = xmlNewChild (object->priv->xml_node,
- NULL,
- (unsigned char *) "desc",
- NULL);
+ desc_node =
+ xmlNewChild (priv->xml_node, NULL, (xmlChar *) "desc", NULL);
return gupnp_didl_lite_descriptor_new_from_xml (desc_node,
- object->priv->xml_doc);
+ priv->xml_doc);
}
/**
@@ -2270,9 +2365,11 @@ char *
gupnp_didl_lite_object_get_title_xml_string (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_string (object->priv->xml_node,
- object->priv->xml_doc->doc,
+ return av_xml_util_get_child_string (priv->xml_node,
+ priv->xml_doc->doc,
"title");
}
@@ -2289,9 +2386,11 @@ char *
gupnp_didl_lite_object_get_date_xml_string (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_string (object->priv->xml_node,
- object->priv->xml_doc->doc,
+ return av_xml_util_get_child_string (priv->xml_node,
+ priv->xml_doc->doc,
"date");
}
@@ -2308,9 +2407,11 @@ char *
gupnp_didl_lite_object_get_upnp_class_xml_string (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_string (object->priv->xml_node,
- object->priv->xml_doc->doc,
+ return av_xml_util_get_child_string (priv->xml_node,
+ priv->xml_doc->doc,
"class");
}
@@ -2327,9 +2428,11 @@ char *
gupnp_didl_lite_object_get_album_xml_string (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_string (object->priv->xml_node,
- object->priv->xml_doc->doc,
+ return av_xml_util_get_child_string (priv->xml_node,
+ priv->xml_doc->doc,
"album");
}
@@ -2346,9 +2449,11 @@ char *
gupnp_didl_lite_object_get_track_number_xml_string (GUPnPDIDLLiteObject *object)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- return av_xml_util_get_child_string (object->priv->xml_node,
- object->priv->xml_doc->doc,
+ return av_xml_util_get_child_string (priv->xml_node,
+ priv->xml_doc->doc,
"originalTrackNumber");
}
@@ -2481,9 +2586,11 @@ gupnp_didl_lite_object_apply_fragments (GUPnPDIDLLiteObject *object,
goto out;
}
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
- original.doc = object->priv->xml_doc->doc;
- original.node = object->priv->xml_node;
+ original.doc = priv->xml_doc->doc;
+ original.node = priv->xml_node;
modified.doc = xmlCopyDoc (original.doc, 1);
if (modified.doc == NULL) {
@@ -2515,7 +2622,7 @@ gupnp_didl_lite_object_apply_fragments (GUPnPDIDLLiteObject *object,
goto out;
}
- if (!fragment_util_apply_modification (&object->priv->xml_node,
+ if (!fragment_util_apply_modification (&priv->xml_node,
&modified))
result = GUPNP_DIDL_LITE_FRAGMENT_RESULT_UNKNOWN_ERROR;
out:
@@ -2536,13 +2643,11 @@ gupnp_didl_lite_object_get_xml_string (GUPnPDIDLLiteObject *object)
{
xmlBuffer *buffer = NULL;
char *ret = NULL;
+ GUPnPDIDLLiteObjectPrivate *priv;
+ priv = gupnp_didl_lite_object_get_instance_private (object);
buffer = xmlBufferCreate ();
- xmlNodeDump (buffer,
- object->priv->xml_doc->doc,
- object->priv->xml_node,
- 0,
- 0);
+ xmlNodeDump (buffer, priv->xml_doc->doc, priv->xml_node, 0, 0);
ret = g_strndup ((char *) xmlBufferContent (buffer),
xmlBufferLength (buffer));
diff --git a/libgupnp-av/gupnp-didl-lite-object.h b/libgupnp-av/gupnp-didl-lite-object.h
index 61c525a..cf5afa1 100644
--- a/libgupnp-av/gupnp-didl-lite-object.h
+++ b/libgupnp-av/gupnp-didl-lite-object.h
@@ -38,39 +38,18 @@
G_BEGIN_DECLS
-GType
-gupnp_didl_lite_object_get_type (void) G_GNUC_CONST;
+G_DECLARE_DERIVABLE_TYPE(GUPnPDIDLLiteObject,
+ gupnp_didl_lite_object,
+ GUPNP,
+ DIDL_LITE_OBJECT,
+ GObject)
#define GUPNP_TYPE_DIDL_LITE_OBJECT \
(gupnp_didl_lite_object_get_type ())
-#define GUPNP_DIDL_LITE_OBJECT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_OBJECT, \
- GUPnPDIDLLiteObject))
-#define GUPNP_DIDL_LITE_OBJECT_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_OBJECT, \
- GUPnPDIDLLiteObjectClass))
-#define GUPNP_IS_DIDL_LITE_OBJECT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_OBJECT))
-#define GUPNP_IS_DIDL_LITE_OBJECT_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_OBJECT))
-#define GUPNP_DIDL_LITE_OBJECT_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_DIDL_LITE_OBJECT, \
- GUPnPDIDLLiteObjectClass))
typedef struct _GUPnPDIDLLiteObjectPrivate GUPnPDIDLLiteObjectPrivate;
-typedef struct {
- GObject parent;
-
- GUPnPDIDLLiteObjectPrivate *priv;
-} GUPnPDIDLLiteObject;
-
-typedef struct {
+struct _GUPnPDIDLLiteObjectClass {
GObjectClass parent_class;
/* future padding */
@@ -78,7 +57,7 @@ typedef struct {
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
-} GUPnPDIDLLiteObjectClass;
+};
xmlNode *
gupnp_didl_lite_object_get_xml_node (GUPnPDIDLLiteObject *object);
diff --git a/libgupnp-av/gupnp-didl-lite-parser.c b/libgupnp-av/gupnp-didl-lite-parser.c
index 1ea06d2..ad8e779 100644
--- a/libgupnp-av/gupnp-didl-lite-parser.c
+++ b/libgupnp-av/gupnp-didl-lite-parser.c
@@ -36,7 +36,7 @@
G_DEFINE_TYPE (GUPnPDIDLLiteParser,
gupnp_didl_lite_parser,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
enum {
OBJECT_AVAILABLE,
diff --git a/libgupnp-av/gupnp-didl-lite-parser.h b/libgupnp-av/gupnp-didl-lite-parser.h
index 764dc1e..6c37db9 100644
--- a/libgupnp-av/gupnp-didl-lite-parser.h
+++ b/libgupnp-av/gupnp-didl-lite-parser.h
@@ -27,37 +27,16 @@
G_BEGIN_DECLS
-GType
-gupnp_didl_lite_parser_get_type (void) G_GNUC_CONST;
+G_DECLARE_DERIVABLE_TYPE(GUPnPDIDLLiteParser,
+ gupnp_didl_lite_parser,
+ GUPNP,
+ DIDL_LITE_PARSER,
+ GObject)
#define GUPNP_TYPE_DIDL_LITE_PARSER \
(gupnp_didl_lite_parser_get_type ())
-#define GUPNP_DIDL_LITE_PARSER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_PARSER, \
- GUPnPDIDLLiteParser))
-#define GUPNP_DIDL_LITE_PARSER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_PARSER, \
- GUPnPDIDLLiteParserClass))
-#define GUPNP_IS_DIDL_LITE_PARSER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_PARSER))
-#define GUPNP_IS_DIDL_LITE_PARSER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_PARSER))
-#define GUPNP_DIDL_LITE_PARSER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_DIDL_LITE_PARSER, \
- GUPnPDIDLLiteParserClass))
-typedef struct {
- GObject parent;
-
- gpointer gupnp_reserved;
-} GUPnPDIDLLiteParser;
-
-typedef struct {
+struct _GUPnPDIDLLiteParserClass {
GObjectClass parent_class;
/* signals */
@@ -74,7 +53,7 @@ typedef struct {
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
void (* _gupnp_reserved5) (void);
-} GUPnPDIDLLiteParserClass;
+};
GUPnPDIDLLiteParser *
gupnp_didl_lite_parser_new (void);
diff --git a/libgupnp-av/gupnp-didl-lite-resource.c b/libgupnp-av/gupnp-didl-lite-resource.c
index a977ebd..03e9591 100644
--- a/libgupnp-av/gupnp-didl-lite-resource.c
+++ b/libgupnp-av/gupnp-didl-lite-resource.c
@@ -47,10 +47,11 @@ struct _GUPnPDIDLLiteResourcePrivate {
GUPnPProtocolInfo *protocol_info;
};
+typedef struct _GUPnPDIDLLiteResourcePrivate GUPnPDIDLLiteResourcePrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GUPnPDIDLLiteResource,
gupnp_didl_lite_resource,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
enum {
PROP_0,
@@ -86,32 +87,31 @@ enum {
};
static void
-get_resolution_info (GUPnPDIDLLiteResource *resource,
- int *width,
- int *height)
+get_resolution_info (xmlNodePtr xml_node, int *width, int *height)
{
const char *resolution;
char **tokens;
- resolution = av_xml_util_get_attribute_content
- (resource->priv->xml_node,
- "resolution");
+ if (width)
+ *width = 0;
+ if (height)
+ *height = 0;
+
+ resolution = av_xml_util_get_attribute_content (xml_node, "resolution");
if (resolution == NULL)
return;
tokens = g_strsplit (resolution, "x", -1);
if (tokens == NULL || tokens[0] == NULL || tokens[1] == NULL) {
g_warning ("Failed to resolution string '%s'\n", resolution);
+ } else {
- goto return_point;
+ if (width)
+ *width = atoi (tokens[0]);
+ if (height)
+ *height = atoi (tokens[1]);
}
- if (width)
- *width = atoi (tokens[0]);
- if (height)
- *height = atoi (tokens[1]);
-
-return_point:
g_strfreev (tokens);
}
@@ -128,8 +128,6 @@ on_protocol_info_changed (GUPnPProtocolInfo *info,
static void
gupnp_didl_lite_resource_init (GUPnPDIDLLiteResource *resource)
{
- resource->priv =
- gupnp_didl_lite_resource_get_instance_private (resource);
}
static void
@@ -138,16 +136,16 @@ gupnp_didl_lite_resource_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GUPnPDIDLLiteResource *resource;
-
- resource = GUPNP_DIDL_LITE_RESOURCE (object);
+ GUPnPDIDLLiteResource *resource = GUPNP_DIDL_LITE_RESOURCE (object);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
switch (property_id) {
case PROP_XML_NODE:
- resource->priv->xml_node = g_value_get_pointer (value);
+ priv->xml_node = g_value_get_pointer (value);
break;
case PROP_XML_DOC:
- resource->priv->xml_doc = g_value_dup_boxed (value);
+ priv->xml_doc = g_value_dup_boxed (value);
break;
case PROP_URI:
gupnp_didl_lite_resource_set_uri (resource,
@@ -172,10 +170,10 @@ gupnp_didl_lite_resource_set_property (GObject *object,
g_value_get_int64 (value));
break;
case PROP_DLNA_NAMESPACE:
- resource->priv->dlna_ns = g_value_get_pointer (value);
+ priv->dlna_ns = g_value_get_pointer (value);
break;
case PROP_PV_NAMESPACE:
- resource->priv->pv_ns = g_value_get_pointer (value);
+ priv->pv_ns = g_value_get_pointer (value);
break;
case PROP_CLEAR_TEXT_SIZE:
gupnp_didl_lite_resource_set_cleartext_size (resource,
@@ -381,16 +379,12 @@ static void
gupnp_didl_lite_resource_dispose (GObject *object)
{
GObjectClass *object_class;
- GUPnPDIDLLiteResourcePrivate *priv;
-
- priv = GUPNP_DIDL_LITE_RESOURCE (object)->priv;
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (
+ GUPNP_DIDL_LITE_RESOURCE (object));
g_clear_pointer (&priv->xml_doc, av_xml_doc_unref);
-
- if (priv->protocol_info != NULL) {
- g_object_unref (priv->protocol_info);
- priv->protocol_info = NULL;
- }
+ g_clear_object (&priv->protocol_info);
object_class = G_OBJECT_CLASS (gupnp_didl_lite_resource_parent_class);
object_class->dispose (object);
@@ -873,8 +867,10 @@ xmlNode *
gupnp_didl_lite_resource_get_xml_node (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return resource->priv->xml_node;
+ return priv->xml_node;
}
/**
@@ -890,8 +886,10 @@ xmlNsPtr
gupnp_didl_lite_resource_get_dlna_namespace (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return resource->priv->dlna_ns;
+ return priv->dlna_ns;
}
/**
@@ -907,8 +905,10 @@ xmlNsPtr
gupnp_didl_lite_resource_get_pv_namespace (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return resource->priv->pv_ns;
+ return priv->pv_ns;
}
@@ -918,17 +918,19 @@ gupnp_didl_lite_resource_get_pv_namespace (GUPnPDIDLLiteResource *resource)
*
* Get the URI associated with the @resource.
*
- * Return value: The of URI the @resource or %NULL.
+ * Return value:(transfer none)(nullable): The of URI the @resource or %NULL.
**/
const char *
gupnp_didl_lite_resource_get_uri (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- if (G_UNLIKELY (resource->priv->xml_node->children == NULL))
+ if (G_UNLIKELY (priv->xml_node->children == NULL))
return NULL;
- return (const char *) resource->priv->xml_node->children->content;
+ return (const char *) priv->xml_node->children->content;
}
/**
@@ -943,9 +945,10 @@ const char *
gupnp_didl_lite_resource_get_import_uri (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_attribute_content (resource->priv->xml_node,
- "importUri");
+ return av_xml_util_get_attribute_content (priv->xml_node, "importUri");
}
/**
@@ -954,8 +957,8 @@ gupnp_didl_lite_resource_get_import_uri (GUPnPDIDLLiteResource *resource)
*
* Get the protocol info associated with the @resource.
*
- * Returns: (transfer none): The protocol info associated with the @resource or %NULL. The
- * returned object must not be unrefed.
+ * Returns: (transfer none)(nullable): The protocol info associated with the
+ * @resource or %NULL. The returned object must not be unrefed.
**/
GUPnPProtocolInfo *
gupnp_didl_lite_resource_get_protocol_info (GUPnPDIDLLiteResource *resource)
@@ -965,13 +968,14 @@ gupnp_didl_lite_resource_get_protocol_info (GUPnPDIDLLiteResource *resource)
GError *error;
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- if (resource->priv->protocol_info != NULL)
- return resource->priv->protocol_info;
+ if (priv->protocol_info != NULL)
+ return priv->protocol_info;
- protocol_info = av_xml_util_get_attribute_content
- (resource->priv->xml_node,
- "protocolInfo");
+ protocol_info = av_xml_util_get_attribute_content (priv->xml_node,
+ "protocolInfo");
if (protocol_info == NULL)
return NULL;
@@ -985,7 +989,7 @@ gupnp_didl_lite_resource_get_protocol_info (GUPnPDIDLLiteResource *resource)
g_error_free (error);
}
- resource->priv->protocol_info = info;
+ priv->protocol_info = info;
return info;
}
@@ -1016,10 +1020,10 @@ gint64
gupnp_didl_lite_resource_get_size64 (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_int64_attribute (resource->priv->xml_node,
- "size",
- -1);
+ return av_xml_util_get_int64_attribute (priv->xml_node, "size", -1);
}
/**
@@ -1034,8 +1038,10 @@ gint64
gupnp_didl_lite_resource_get_cleartext_size (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_int64_attribute (resource->priv->xml_node,
+ return av_xml_util_get_int64_attribute (priv->xml_node,
"cleartextSize",
-1);
}
@@ -1055,10 +1061,11 @@ gupnp_didl_lite_resource_get_duration (GUPnPDIDLLiteResource *resource)
long duration;
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- duration_str = av_xml_util_get_attribute_content
- (resource->priv->xml_node,
- "duration");
+ duration_str =
+ av_xml_util_get_attribute_content (priv->xml_node, "duration");
duration = seconds_from_time (duration_str);
return duration;
@@ -1076,10 +1083,10 @@ int
gupnp_didl_lite_resource_get_bitrate (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_long_attribute (resource->priv->xml_node,
- "bitrate",
- -1);
+ return av_xml_util_get_long_attribute (priv->xml_node, "bitrate", -1);
}
/**
@@ -1094,8 +1101,10 @@ int
gupnp_didl_lite_resource_get_sample_freq (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_long_attribute (resource->priv->xml_node,
+ return av_xml_util_get_long_attribute (priv->xml_node,
"sampleFrequency",
-1);
}
@@ -1112,8 +1121,10 @@ int
gupnp_didl_lite_resource_get_bits_per_sample (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_long_attribute (resource->priv->xml_node,
+ return av_xml_util_get_long_attribute (priv->xml_node,
"bitsPerSample",
-1);
}
@@ -1130,9 +1141,10 @@ const char *
gupnp_didl_lite_resource_get_protection (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_attribute_content (resource->priv->xml_node,
- "protection");
+ return av_xml_util_get_attribute_content (priv->xml_node, "protection");
}
/**
@@ -1147,8 +1159,10 @@ int
gupnp_didl_lite_resource_get_audio_channels (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_long_attribute (resource->priv->xml_node,
+ return av_xml_util_get_long_attribute (priv->xml_node,
"nrAudioChannels",
-1);
}
@@ -1167,8 +1181,10 @@ gupnp_didl_lite_resource_get_width (GUPnPDIDLLiteResource *resource)
int width = -1;
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- get_resolution_info (resource, &width, NULL);
+ get_resolution_info (priv->xml_node, &width, NULL);
return width;
}
@@ -1187,8 +1203,10 @@ gupnp_didl_lite_resource_get_height (GUPnPDIDLLiteResource *resource)
int height = -1;
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- get_resolution_info (resource, NULL, &height);
+ get_resolution_info (priv->xml_node, NULL, &height);
return height;
}
@@ -1205,8 +1223,10 @@ int
gupnp_didl_lite_resource_get_color_depth (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_long_attribute (resource->priv->xml_node,
+ return av_xml_util_get_long_attribute (priv->xml_node,
"colorDepth",
-1);
}
@@ -1223,8 +1243,10 @@ guint
gupnp_didl_lite_resource_get_update_count (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), 0);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_uint_attribute (resource->priv->xml_node,
+ return av_xml_util_get_uint_attribute (priv->xml_node,
"updateCount",
-1);
}
@@ -1241,8 +1263,10 @@ guint
gupnp_didl_lite_resource_get_track_total (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), 0);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_uint_attribute (resource->priv->xml_node,
+ return av_xml_util_get_uint_attribute (priv->xml_node,
"trackTotal",
-1);
}
@@ -1258,13 +1282,12 @@ gupnp_didl_lite_resource_get_track_total (GUPnPDIDLLiteResource *resource)
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);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- content = av_xml_util_get_attribute_content (resource->priv->xml_node,
- "updateCount");
- return content != NULL;
+ return av_xml_util_get_attribute_content (priv->xml_node,
+ "updateCount") != NULL;
}
/**
@@ -1278,13 +1301,12 @@ gupnp_didl_lite_resource_update_count_is_set (GUPnPDIDLLiteResource *resource)
gboolean
gupnp_didl_lite_resource_track_total_is_set (GUPnPDIDLLiteResource *resource)
{
- const char *content;
-
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), FALSE);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- content = av_xml_util_get_attribute_content (resource->priv->xml_node,
- "trackTotal");
- return content != NULL;
+ return av_xml_util_get_attribute_content (priv->xml_node,
+ "trackTotal") != NULL;
}
@@ -1303,10 +1325,12 @@ gupnp_didl_lite_resource_set_uri (GUPnPDIDLLiteResource *resource,
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
g_return_if_fail (uri != NULL);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- escaped = xmlEncodeSpecialChars (resource->priv->xml_doc->doc,
+ escaped = xmlEncodeSpecialChars (priv->xml_doc->doc,
(const unsigned char *) uri);
- xmlNodeSetContent (resource->priv->xml_node, escaped);
+ xmlNodeSetContent (priv->xml_node, escaped);
xmlFree (escaped);
g_object_notify (G_OBJECT (resource), "uri");
@@ -1324,8 +1348,11 @@ gupnp_didl_lite_resource_set_import_uri (GUPnPDIDLLiteResource *resource,
const char *import_uri)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- xmlSetProp (resource->priv->xml_node,
+ // FIXME: Why is this URI not escaped?
+ xmlSetProp (priv->xml_node,
(unsigned char *) "importUri",
(unsigned char *) import_uri);
@@ -1347,24 +1374,25 @@ gupnp_didl_lite_resource_set_protocol_info (GUPnPDIDLLiteResource *resource,
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
str = gupnp_protocol_info_to_string (info);
- xmlSetProp (resource->priv->xml_node,
+ xmlSetProp (priv->xml_node,
(unsigned char *) "protocolInfo",
(unsigned char *) str);
g_free (str);
/* Get a ref first in case it's the same object that we already have */
g_object_ref (info);
- if (resource->priv->protocol_info != NULL)
- g_object_unref (resource->priv->protocol_info);
- resource->priv->protocol_info = info;
+ g_clear_object (&priv->protocol_info);
+ priv->protocol_info = info;
/* We need to listen to changes to properties so we update the
* corresponding xml property.
*/
g_signal_handlers_disconnect_by_func (info,
- on_protocol_info_changed,
+ (gpointer) on_protocol_info_changed,
resource);
g_signal_connect (info,
"notify",
@@ -1402,15 +1430,16 @@ gupnp_didl_lite_resource_set_size64 (GUPnPDIDLLiteResource *resource,
gint64 size)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
if (size < 0)
- xmlUnsetProp (resource->priv->xml_node,
- (unsigned char *) "size");
+ xmlUnsetProp (priv->xml_node, (unsigned char *) "size");
else {
char *str;
str = g_strdup_printf ("%" G_GINT64_FORMAT, size);
- xmlSetProp (resource->priv->xml_node,
+ xmlSetProp (priv->xml_node,
(unsigned char *) "size",
(unsigned char *) str);
g_free (str);
@@ -1434,20 +1463,22 @@ gupnp_didl_lite_resource_set_cleartext_size
gint64 cleartext_size)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
if (cleartext_size < 0)
- xmlUnsetNsProp (resource->priv->xml_node,
- resource->priv->dlna_ns,
+ xmlUnsetNsProp (priv->xml_node,
+ priv->dlna_ns,
(unsigned char *) "cleartextSize");
else {
char *str;
str = g_strdup_printf ("%" G_GINT64_FORMAT, cleartext_size);
- av_xml_util_get_ns (resource->priv->xml_doc->doc,
+ av_xml_util_get_ns (priv->xml_doc->doc,
GUPNP_XML_NAMESPACE_DLNA,
- &(resource->priv->dlna_ns));
+ &(priv->dlna_ns));
- xmlSetNsProp (resource->priv->xml_node,
- resource->priv->dlna_ns,
+ xmlSetNsProp (priv->xml_node,
+ priv->dlna_ns,
(unsigned char *) "cleartextSize",
(unsigned char *) str);
@@ -1470,15 +1501,16 @@ gupnp_didl_lite_resource_set_duration (GUPnPDIDLLiteResource *resource,
glong duration)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
if (duration < 0)
- xmlUnsetProp (resource->priv->xml_node,
- (unsigned char *) "duration");
+ xmlUnsetProp (priv->xml_node, (unsigned char *) "duration");
else {
char *str;
str = seconds_to_time (duration);
- xmlSetProp (resource->priv->xml_node,
+ xmlSetProp (priv->xml_node,
(unsigned char *) "duration",
(unsigned char *) str);
g_free (str);
@@ -1500,15 +1532,16 @@ gupnp_didl_lite_resource_set_bitrate (GUPnPDIDLLiteResource *resource,
int bitrate)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
if (bitrate < 0)
- xmlUnsetProp (resource->priv->xml_node,
- (unsigned char *) "bitrate");
+ xmlUnsetProp (priv->xml_node, (unsigned char *) "bitrate");
else {
char *str;
str = g_strdup_printf ("%d", bitrate);
- xmlSetProp (resource->priv->xml_node,
+ xmlSetProp (priv->xml_node,
(unsigned char *) "bitrate",
(unsigned char *) str);
g_free (str);
@@ -1530,15 +1563,17 @@ gupnp_didl_lite_resource_set_sample_freq (GUPnPDIDLLiteResource *resource,
int sample_freq)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
if (sample_freq < 0)
- xmlUnsetProp (resource->priv->xml_node,
+ xmlUnsetProp (priv->xml_node,
(unsigned char *) "sampleFrequency");
else {
char *str;
str = g_strdup_printf ("%d", sample_freq);
- xmlSetProp (resource->priv->xml_node,
+ xmlSetProp (priv->xml_node,
(unsigned char *) "sampleFrequency",
(unsigned char *) str);
g_free (str);
@@ -1561,18 +1596,17 @@ gupnp_didl_lite_resource_set_bits_per_sample
int sample_size)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
if (sample_size < 0)
- xmlUnsetProp (resource->priv->xml_node,
+ xmlUnsetProp (priv->xml_node,
(unsigned char *) "bitsPerSample");
else {
- char *str;
-
- str = g_strdup_printf ("%d", sample_size);
- xmlSetProp (resource->priv->xml_node,
- (unsigned char *) "bitsPerSample",
- (unsigned char *) str);
- g_free (str);
+ av_xml_util_set_prop (priv->xml_node,
+ "bitsPerSample",
+ "%d",
+ sample_size);
}
g_object_notify (G_OBJECT (resource), "bits-per-sample");
@@ -1591,8 +1625,10 @@ gupnp_didl_lite_resource_set_protection (GUPnPDIDLLiteResource *resource,
const char *protection)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- xmlSetProp (resource->priv->xml_node,
+ xmlSetProp (priv->xml_node,
(unsigned char *) "protection",
(unsigned char *) protection);
@@ -1612,18 +1648,16 @@ gupnp_didl_lite_resource_set_audio_channels (GUPnPDIDLLiteResource *resource,
int n_channels)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
if (n_channels < 0)
- xmlUnsetProp (resource->priv->xml_node,
+ xmlUnsetProp (priv->xml_node,
(unsigned char *) "nrAudioChannels");
else {
- char *str;
-
- str = g_strdup_printf ("%d", n_channels);
- xmlSetProp (resource->priv->xml_node,
- (unsigned char *) "nrAudioChannels",
- (unsigned char *) str);
- g_free (str);
+ av_xml_util_set_int_prop (priv->xml_node,
+ "nrAudioChannels",
+ n_channels);
}
g_object_notify (G_OBJECT (resource), "audio-channels");
@@ -1641,22 +1675,19 @@ void
gupnp_didl_lite_resource_set_width (GUPnPDIDLLiteResource *resource,
int width)
{
- char *resolution;
int height = -1;
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- get_resolution_info (resource, NULL, &height);
+ get_resolution_info (priv->xml_node, NULL, &height);
if (width < 0 && height < 0)
- xmlUnsetProp (resource->priv->xml_node,
+ xmlUnsetProp (priv->xml_node,
(unsigned char *) "resolution");
else {
- resolution = g_strdup_printf ("%dx%d", width, height);
- xmlSetProp (resource->priv->xml_node,
- (unsigned char *) "resolution",
- (unsigned char *) resolution);
- g_free (resolution);
+ av_xml_util_set_prop (priv->xml_node, "resolution", "%dx%d", width, height);
}
g_object_notify (G_OBJECT (resource), "width");
@@ -1677,20 +1708,16 @@ gupnp_didl_lite_resource_set_height (GUPnPDIDLLiteResource *resource,
int width = -1;
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- get_resolution_info (resource, &width, NULL);
+ get_resolution_info (priv->xml_node, &width, NULL);
if (width < 0 && height < 0)
- xmlUnsetProp (resource->priv->xml_node,
+ xmlUnsetProp (priv->xml_node,
(unsigned char *) "resolution");
else {
- char *resolution;
-
- resolution = g_strdup_printf ("%dx%d", width, height);
- xmlSetProp (resource->priv->xml_node,
- (unsigned char *) "resolution",
- (unsigned char *) resolution);
- g_free (resolution);
+ av_xml_util_set_prop (priv->xml_node, "resolution", "%dx%d", width, height);
}
g_object_notify (G_OBJECT (resource), "height");
@@ -1709,18 +1736,16 @@ gupnp_didl_lite_resource_set_color_depth (GUPnPDIDLLiteResource *resource,
int color_depth)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
if (color_depth < 0)
- xmlUnsetProp (resource->priv->xml_node,
- (unsigned char *) "colorDepth");
+ xmlUnsetProp (priv->xml_node, (unsigned char *) "colorDepth");
else {
- char *str;
-
- str = g_strdup_printf ("%d", color_depth);
- xmlSetProp (resource->priv->xml_node,
- (unsigned char *) "colorDepth",
- (unsigned char *) str);
- g_free (str);
+ av_xml_util_set_prop (priv->xml_node,
+ "colorDepth",
+ "%d",
+ color_depth);
}
g_object_notify (G_OBJECT (resource), "color-depth");
@@ -1737,15 +1762,13 @@ 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);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
+ av_xml_util_set_prop (priv->xml_node,
+ "updateCount",
+ "%u",
+ update_count);
g_object_notify (G_OBJECT (resource), "update-count");
}
@@ -1761,21 +1784,18 @@ void
gupnp_didl_lite_resource_set_track_total (GUPnPDIDLLiteResource *resource,
guint track_total)
{
- char *str;
-
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- av_xml_util_get_ns (resource->priv->xml_doc->doc,
+ av_xml_util_get_ns (priv->xml_doc->doc,
GUPNP_XML_NAMESPACE_DLNA,
- &(resource->priv->dlna_ns));
-
- str = g_strdup_printf ("%u", track_total);
- xmlSetNsProp (resource->priv->xml_node,
- resource->priv->dlna_ns,
- (unsigned char *) "trackTotal",
- (unsigned char *) str);
- g_free (str);
-
+ &(priv->dlna_ns));
+ av_xml_util_set_ns_prop (priv->xml_node,
+ priv->dlna_ns,
+ "trackTotal",
+ "%u",
+ track_total);
g_object_notify (G_OBJECT (resource), "track-total");
}
@@ -1790,9 +1810,10 @@ void
gupnp_didl_lite_resource_unset_update_count (GUPnPDIDLLiteResource *resource)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- xmlUnsetProp (resource->priv->xml_node,
- (unsigned char *) "updateCount");
+ xmlUnsetProp (priv->xml_node, (unsigned char *) "updateCount");
g_object_notify (G_OBJECT (resource), "update-count");
}
@@ -1807,9 +1828,15 @@ void
gupnp_didl_lite_resource_unset_track_total (GUPnPDIDLLiteResource *resource)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
+
+ av_xml_util_get_ns (priv->xml_doc->doc,
+ GUPNP_XML_NAMESPACE_DLNA,
+ &(priv->dlna_ns));
- xmlUnsetNsProp (resource->priv->xml_node,
- resource->priv->dlna_ns,
+ xmlUnsetNsProp (priv->xml_node,
+ priv->dlna_ns,
(unsigned char *) "trackTotal");
g_object_notify (G_OBJECT (resource), "track-total");
@@ -1828,8 +1855,10 @@ gupnp_didl_lite_resource_get_subtitle_file_uri
(GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_attribute_content (resource->priv->xml_node,
+ return av_xml_util_get_attribute_content (priv->xml_node,
"subtitleFileUri");
}
@@ -1846,8 +1875,10 @@ gupnp_didl_lite_resource_get_subtitle_file_type
(GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
- return av_xml_util_get_attribute_content (resource->priv->xml_node,
+ return av_xml_util_get_attribute_content (priv->xml_node,
"subtitleFileType");
}
@@ -1867,17 +1898,19 @@ gupnp_didl_lite_resource_set_subtitle_file_uri
const char *uri)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
if (uri == NULL)
- xmlUnsetNsProp (resource->priv->xml_node,
- resource->priv->pv_ns,
+ xmlUnsetNsProp (priv->xml_node,
+ priv->pv_ns,
(unsigned char *) "subtitleFileUri");
else {
- av_xml_util_get_ns (resource->priv->xml_doc->doc,
+ av_xml_util_get_ns (priv->xml_doc->doc,
GUPNP_XML_NAMESPACE_PV,
- &(resource->priv->pv_ns));
- xmlSetNsProp (resource->priv->xml_node,
- resource->priv->pv_ns,
+ &(priv->pv_ns));
+ xmlSetNsProp (priv->xml_node,
+ priv->pv_ns,
(unsigned char *) "subtitleFileUri",
(xmlChar *) uri);
}
@@ -1903,18 +1936,20 @@ gupnp_didl_lite_resource_set_subtitle_file_type
const char *type)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+ GUPnPDIDLLiteResourcePrivate *priv =
+ gupnp_didl_lite_resource_get_instance_private (resource);
if (type == NULL)
- xmlUnsetNsProp (resource->priv->xml_node,
- resource->priv->pv_ns,
+ xmlUnsetNsProp (priv->xml_node,
+ priv->pv_ns,
(unsigned char *) "subtitleFileUri");
else {
- av_xml_util_get_ns (resource->priv->xml_doc->doc,
+ av_xml_util_get_ns (priv->xml_doc->doc,
GUPNP_XML_NAMESPACE_PV,
- &(resource->priv->pv_ns));
+ &(priv->pv_ns));
- xmlSetNsProp (resource->priv->xml_node,
- resource->priv->pv_ns,
+ xmlSetNsProp (priv->xml_node,
+ priv->pv_ns,
(unsigned char *) "subtitleFileType",
(xmlChar *) type);
}
diff --git a/libgupnp-av/gupnp-didl-lite-resource.h b/libgupnp-av/gupnp-didl-lite-resource.h
index bd3bb8d..7b458e0 100644
--- a/libgupnp-av/gupnp-didl-lite-resource.h
+++ b/libgupnp-av/gupnp-didl-lite-resource.h
@@ -24,8 +24,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GUPNP_DIDL_LITE_RESOURCE_H__
-#define __GUPNP_DIDL_LITE_RESOURCE_H__
+#ifndef GUPNP_DIDL_LITE_RESOURCE_H
+#define GUPNP_DIDL_LITE_RESOURCE_H
#include <stdarg.h>
#include <glib-object.h>
@@ -37,39 +37,18 @@
G_BEGIN_DECLS
-GType
-gupnp_didl_lite_resource_get_type (void) G_GNUC_CONST;
+
+G_DECLARE_DERIVABLE_TYPE(GUPnPDIDLLiteResource,
+ gupnp_didl_lite_resource,
+ GUPNP,
+ DIDL_LITE_RESOURCE,
+ GObject)
#define GUPNP_TYPE_DIDL_LITE_RESOURCE \
(gupnp_didl_lite_resource_get_type ())
-#define GUPNP_DIDL_LITE_RESOURCE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_RESOURCE, \
- GUPnPDIDLLiteResource))
-#define GUPNP_DIDL_LITE_RESOURCE_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_RESOURCE, \
- GUPnPDIDLLiteResourceClass))
-#define GUPNP_IS_DIDL_LITE_RESOURCE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_RESOURCE))
-#define GUPNP_IS_DIDL_LITE_RESOURCE_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_RESOURCE))
-#define GUPNP_DIDL_LITE_RESOURCE_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_DIDL_LITE_RESOURCE, \
- GUPnPDIDLLiteResourceClass))
-
-typedef struct _GUPnPDIDLLiteResourcePrivate GUPnPDIDLLiteResourcePrivate;
-
-typedef struct {
- GObject parent;
-
- GUPnPDIDLLiteResourcePrivate *priv;
-} GUPnPDIDLLiteResource;
-
-typedef struct {
+
+
+struct _GUPnPDIDLLiteResourceClass {
GObjectClass parent_class;
/* future padding */
@@ -77,7 +56,7 @@ typedef struct {
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
-} GUPnPDIDLLiteResourceClass;
+};
void
gupnp_didl_lite_resource_set_uri (GUPnPDIDLLiteResource *resource,
diff --git a/libgupnp-av/gupnp-didl-lite-writer.c b/libgupnp-av/gupnp-didl-lite-writer.c
index 6eaf416..a8b92f2 100644
--- a/libgupnp-av/gupnp-didl-lite-writer.c
+++ b/libgupnp-av/gupnp-didl-lite-writer.c
@@ -49,10 +49,11 @@ struct _GUPnPDIDLLiteWriterPrivate {
char *language;
};
+typedef struct _GUPnPDIDLLiteWriterPrivate GUPnPDIDLLiteWriterPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GUPnPDIDLLiteWriter,
gupnp_didl_lite_writer,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
enum {
PROP_0,
@@ -210,7 +211,6 @@ filter_attributes (xmlNode *node,
static void
filter_node (xmlNode *node,
GList *allowed,
- GUPnPDIDLLiteWriter *writer,
gboolean tags_only)
{
xmlNode *child;
@@ -264,7 +264,7 @@ filter_node (xmlNode *node,
/* Recurse */
for (child = node->children; child != NULL; child = child->next)
if (!xmlNodeIsText (child))
- filter_node (child, allowed, writer, tags_only);
+ filter_node (child, allowed, tags_only);
}
static void
@@ -280,6 +280,9 @@ apply_filter (GUPnPDIDLLiteWriter *writer,
g_return_if_fail (GUPNP_IS_DIDL_LITE_WRITER (writer));
g_return_if_fail (filter != NULL);
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (writer);
+
if (filter[0] == '*')
return; /* Wildcard */
@@ -289,10 +292,8 @@ apply_filter (GUPnPDIDLLiteWriter *writer,
for (i = 0; tokens[i] != NULL; i++)
allowed = g_list_append (allowed, tokens[i]);
- for (node = writer->priv->xml_node->children;
- node != NULL;
- node = node->next)
- filter_node (node, allowed, writer, tags_only);
+ for (node = priv->xml_node->children; node != NULL; node = node->next)
+ filter_node (node, allowed, tags_only);
g_list_free (allowed);
g_strfreev (tokens);
@@ -302,7 +303,6 @@ apply_filter (GUPnPDIDLLiteWriter *writer,
static void
gupnp_didl_lite_writer_init (GUPnPDIDLLiteWriter *writer)
{
- writer->priv = gupnp_didl_lite_writer_get_instance_private (writer);
}
static void
@@ -315,10 +315,12 @@ gupnp_didl_lite_writer_set_property (GObject *object,
GUPnPDIDLLiteWriter *writer;
writer = GUPNP_DIDL_LITE_WRITER (object);
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (writer);
switch (property_id) {
case PROP_LANGUAGE:
- writer->priv->language = g_value_dup_string (value);
+ priv->language = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -355,10 +357,11 @@ static void
gupnp_didl_lite_writer_constructed (GObject *object)
{
GObjectClass *object_class;
- GUPnPDIDLLiteWriterPrivate *priv;
xmlDoc *doc;
- priv = GUPNP_DIDL_LITE_WRITER (object)->priv;
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (
+ GUPNP_DIDL_LITE_WRITER (object));
doc = xmlNewDoc ((unsigned char *) "1.0");
priv->xml_doc = av_xml_doc_new (doc);
@@ -386,9 +389,9 @@ static void
gupnp_didl_lite_writer_dispose (GObject *object)
{
GObjectClass *object_class;
- GUPnPDIDLLiteWriterPrivate *priv;
-
- priv = GUPNP_DIDL_LITE_WRITER (object)->priv;
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (
+ GUPNP_DIDL_LITE_WRITER (object));
g_clear_pointer (&priv->xml_doc, av_xml_doc_unref);
@@ -400,12 +403,11 @@ static void
gupnp_didl_lite_writer_finalize (GObject *object)
{
GObjectClass *object_class;
- GUPnPDIDLLiteWriterPrivate *priv;
-
- priv = GUPNP_DIDL_LITE_WRITER (object)->priv;
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (
+ GUPNP_DIDL_LITE_WRITER (object));
- if (priv->language)
- g_free (priv->language);
+ g_free (priv->language);
object_class = G_OBJECT_CLASS (gupnp_didl_lite_writer_parent_class);
object_class->finalize (object);
@@ -492,20 +494,22 @@ gupnp_didl_lite_writer_add_item (GUPnPDIDLLiteWriter *writer)
{
xmlNode *item_node;
GUPnPDIDLLiteObject *object;
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (writer);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_WRITER (writer), NULL);
- item_node = xmlNewChild (writer->priv->xml_node,
- NULL,
- (unsigned char *) "item",
- NULL);
+ item_node = xmlNewChild (priv->xml_node,
+ NULL,
+ (unsigned char *) "item",
+ NULL);
object = gupnp_didl_lite_object_new_from_xml (item_node,
- writer->priv->xml_doc,
- writer->priv->upnp_ns,
- writer->priv->dc_ns,
- writer->priv->dlna_ns,
- writer->priv->pv_ns);
+ priv->xml_doc,
+ priv->upnp_ns,
+ priv->dc_ns,
+ priv->dlna_ns,
+ priv->pv_ns);
return GUPNP_DIDL_LITE_ITEM (object);
}
@@ -527,6 +531,8 @@ gupnp_didl_lite_writer_add_container_child_item
{
xmlNode *item_node, *container_node;
GUPnPDIDLLiteObject *object;
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (writer);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CONTAINER (container), NULL);
@@ -539,11 +545,11 @@ gupnp_didl_lite_writer_add_container_child_item
NULL);
object = gupnp_didl_lite_object_new_from_xml (item_node,
- writer->priv->xml_doc,
- writer->priv->upnp_ns,
- writer->priv->dc_ns,
- writer->priv->dlna_ns,
- writer->priv->pv_ns);
+ priv->xml_doc,
+ priv->upnp_ns,
+ priv->dc_ns,
+ priv->dlna_ns,
+ priv->pv_ns);
return GUPNP_DIDL_LITE_ITEM (object);
}
@@ -560,20 +566,22 @@ gupnp_didl_lite_writer_add_container (GUPnPDIDLLiteWriter *writer)
{
xmlNode *container_node;
GUPnPDIDLLiteObject *object;
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (writer);
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_WRITER (writer), NULL);
- container_node = xmlNewChild (writer->priv->xml_node,
+ container_node = xmlNewChild (priv->xml_node,
NULL,
(unsigned char *) "container",
NULL);
object = gupnp_didl_lite_object_new_from_xml (container_node,
- writer->priv->xml_doc,
- writer->priv->upnp_ns,
- writer->priv->dc_ns,
- writer->priv->dlna_ns,
- writer->priv->pv_ns);
+ priv->xml_doc,
+ priv->upnp_ns,
+ priv->dc_ns,
+ priv->dlna_ns,
+ priv->pv_ns);
return GUPNP_DIDL_LITE_CONTAINER (object);
}
@@ -591,14 +599,16 @@ gupnp_didl_lite_writer_add_descriptor (GUPnPDIDLLiteWriter *writer)
xmlNode *desc_node;
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_WRITER (writer), NULL);
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (writer);
- desc_node = xmlNewChild (writer->priv->xml_node,
+ desc_node = xmlNewChild (priv->xml_node,
NULL,
(unsigned char *) "desc",
NULL);
return gupnp_didl_lite_descriptor_new_from_xml (desc_node,
- writer->priv->xml_doc);
+ priv->xml_doc);
}
/**
@@ -616,13 +626,11 @@ gupnp_didl_lite_writer_get_string (GUPnPDIDLLiteWriter *writer)
char *ret;
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_WRITER (writer), NULL);
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (writer);
buffer = xmlBufferCreate ();
- xmlNodeDump (buffer,
- writer->priv->xml_doc->doc,
- writer->priv->xml_node,
- 0,
- 0);
+ xmlNodeDump (buffer, priv->xml_doc->doc, priv->xml_node, 0, 0);
ret = g_strndup ((char *) xmlBufferContent (buffer),
xmlBufferLength (buffer));
xmlBufferFree (buffer);
@@ -642,8 +650,10 @@ xmlNode *
gupnp_didl_lite_writer_get_xml_node (GUPnPDIDLLiteWriter *writer)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_WRITER (writer), NULL);
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (writer);
- return writer->priv->xml_node;
+ return priv->xml_node;
}
/**
@@ -658,8 +668,10 @@ const char *
gupnp_didl_lite_writer_get_language (GUPnPDIDLLiteWriter *writer)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_WRITER (writer), NULL);
+ GUPnPDIDLLiteWriterPrivate *priv =
+ gupnp_didl_lite_writer_get_instance_private (writer);
- return writer->priv->language;
+ return priv->language;
}
/**
diff --git a/libgupnp-av/gupnp-didl-lite-writer.h b/libgupnp-av/gupnp-didl-lite-writer.h
index 1546751..9ed160f 100644
--- a/libgupnp-av/gupnp-didl-lite-writer.h
+++ b/libgupnp-av/gupnp-didl-lite-writer.h
@@ -33,39 +33,17 @@
G_BEGIN_DECLS
-GType
-gupnp_didl_lite_writer_get_type (void) G_GNUC_CONST;
+
+G_DECLARE_DERIVABLE_TYPE(GUPnPDIDLLiteWriter,
+ gupnp_didl_lite_writer,
+ GUPNP,
+ DIDL_LITE_WRITER,
+ GObject)
#define GUPNP_TYPE_DIDL_LITE_WRITER \
(gupnp_didl_lite_writer_get_type ())
-#define GUPNP_DIDL_LITE_WRITER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_WRITER, \
- GUPnPDIDLLiteWriter))
-#define GUPNP_DIDL_LITE_WRITER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_DIDL_LITE_WRITER, \
- GUPnPDIDLLiteWriterClass))
-#define GUPNP_IS_DIDL_LITE_WRITER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_WRITER))
-#define GUPNP_IS_DIDL_LITE_WRITER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_DIDL_LITE_WRITER))
-#define GUPNP_DIDL_LITE_WRITER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_DIDL_LITE_WRITER, \
- GUPnPDIDLLiteWriterClass))
-
-typedef struct _GUPnPDIDLLiteWriterPrivate GUPnPDIDLLiteWriterPrivate;
-
-typedef struct {
- GObject parent;
-
- GUPnPDIDLLiteWriterPrivate *priv;
-} GUPnPDIDLLiteWriter;
-
-typedef struct {
+
+struct _GUPnPDIDLLiteWriterClass {
GObjectClass parent_class;
/* future padding */
@@ -73,7 +51,7 @@ typedef struct {
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
-} GUPnPDIDLLiteWriterClass;
+};
#define GUPNP_DIDL_LITE_WRITER_NAMESPACE_DC "dc"
#define GUPNP_DIDL_LITE_WRITER_NAMESPACE_UPNP "upnp"
@@ -107,4 +85,4 @@ gupnp_didl_lite_writer_filter (GUPnPDIDLLiteWriter *writer,
G_END_DECLS
-#endif /* __GUPNP_DIDL_LITE_WRITER_H__ */
+#endif /* GUPNP_DIDL_LITE_WRITER_H */
diff --git a/libgupnp-av/gupnp-dlna.h b/libgupnp-av/gupnp-dlna.h
index 3ce0562..afee8d3 100644
--- a/libgupnp-av/gupnp-dlna.h
+++ b/libgupnp-av/gupnp-dlna.h
@@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GUPNP_DLNA_H__
-#define __GUPNP_DLNA_H__
+#ifndef GUPNP_DLNA_H
+#define GUPNP_DLNA_H
#include <glib-object.h>
@@ -152,4 +152,4 @@ gupnp_ocm_flags_get_type (void) G_GNUC_CONST;
G_END_DECLS
-#endif /* __GUPNP_DLNA_H__ */
+#endif /* GUPNP_DLNA_H */
diff --git a/libgupnp-av/gupnp-feature-list-parser.c b/libgupnp-av/gupnp-feature-list-parser.c
index 2f179b1..c4ce5a4 100644
--- a/libgupnp-av/gupnp-feature-list-parser.c
+++ b/libgupnp-av/gupnp-feature-list-parser.c
@@ -36,7 +36,7 @@
/* GUPnPFeatureListParser */
G_DEFINE_TYPE (GUPnPFeatureListParser,
gupnp_feature_list_parser,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
static void
gupnp_feature_list_parser_init (G_GNUC_UNUSED GUPnPFeatureListParser *parser)
@@ -78,31 +78,24 @@ static char *
get_feature_object_ids (xmlNode *feature)
{
xmlNode *element;
- char *object_ids = NULL;
const char *content;
-
- object_ids = (char *) g_malloc0(1);
+ GString *object_ids = g_string_new ("");
for (element = feature->children; element; element = element->next) {
- gsize new_size;
-
- if (g_ascii_strcasecmp ((char *) element->name,
- "objectIDs") == 0) {
+ const char *name = (const char *) element->name;
+ if (g_ascii_strcasecmp (name, "objectIDs") == 0) {
content = (const char *) xmlNodeGetContent (element);
+ if (strlen (content) == 0)
+ continue;
- new_size = strlen (object_ids) + strlen (content) + 1;
- if (*object_ids)
- new_size++;
-
- object_ids = g_realloc (object_ids, new_size);
+ if (object_ids->len > 0)
+ g_string_append_c (object_ids, ',');
- if (*object_ids)
- strcat (object_ids, ",");
- strcat (object_ids, content);
+ g_string_append (object_ids, content);
}
}
- return object_ids;
+ return g_string_free (object_ids, FALSE);
}
/**
@@ -114,7 +107,7 @@ get_feature_object_ids (xmlNode *feature)
* Parses @text and returns the list of available features.
* If an error occured @error will be set.
*
- * Return value: (transfer full) (element-type GUPnPFeature): The list of
+ * Return value: (transfer full) (element-type GUPnPFeature)(nullable): The list of
* features or %NULL if an error occured.
**/
GList *
diff --git a/libgupnp-av/gupnp-feature-list-parser.h b/libgupnp-av/gupnp-feature-list-parser.h
index aa7cc68..075d7b9 100644
--- a/libgupnp-av/gupnp-feature-list-parser.h
+++ b/libgupnp-av/gupnp-feature-list-parser.h
@@ -27,37 +27,18 @@
G_BEGIN_DECLS
-GType
-gupnp_feature_list_parser_get_type (void) G_GNUC_CONST;
+G_DECLARE_DERIVABLE_TYPE(GUPnPFeatureListParser,
+ gupnp_feature_list_parser,
+ GUPNP,
+ FEATURE_LIST_PARSER,
+ GObject)
#define GUPNP_TYPE_FEATURE_LIST_PARSER \
(gupnp_feature_list_parser_get_type ())
-#define GUPNP_FEATURE_LIST_PARSER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_FEATURE_LIST_PARSER, \
- GUPnPFeatureListParser))
-#define GUPNP_FEATURE_LIST_PARSER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_FEATURE_LIST_PARSER, \
- GUPnPFeatureListParserClass))
-#define GUPNP_IS_FEATURE_LIST_PARSER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_FEATURE_LIST_PARSER))
-#define GUPNP_IS_FEATURE_LIST_PARSER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_FEATURE_LIST_PARSER))
-#define GUPNP_FEATURE_LIST_PARSER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_FEATURE_LIST_PARSER, \
- GUPnPFeatureListParserClass))
-typedef struct {
- GObject parent;
-} GUPnPFeatureListParser;
-
-typedef struct {
+struct _GUPnPFeatureListParserClass{
GObjectClass parent_class;
-} GUPnPFeatureListParserClass;
+};
GUPnPFeatureListParser *
gupnp_feature_list_parser_new (void);
diff --git a/libgupnp-av/gupnp-feature.c b/libgupnp-av/gupnp-feature.c
index 580bf29..be363a0 100644
--- a/libgupnp-av/gupnp-feature.c
+++ b/libgupnp-av/gupnp-feature.c
@@ -33,10 +33,11 @@ struct _GUPnPFeaturePrivate {
char *version;
char *object_ids;
};
+typedef struct _GUPnPFeaturePrivate GUPnPFeaturePrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GUPnPFeature,
gupnp_feature,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
enum {
PROP_0,
@@ -48,7 +49,6 @@ enum {
static void
gupnp_feature_init (GUPnPFeature *object)
{
- object->priv = gupnp_feature_get_instance_private (object);
}
static void
@@ -57,7 +57,8 @@ gupnp_feature_finalize (GObject *object)
GObjectClass *object_class;
GUPnPFeaturePrivate *priv;
- priv = GUPNP_FEATURE (object)->priv;
+ priv = gupnp_feature_get_instance_private (GUPNP_FEATURE (object));
+
g_free (priv->name);
g_free (priv->version);
g_free (priv->object_ids);
@@ -99,19 +100,18 @@ gupnp_feature_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GUPnPFeature *feature;
-
- feature = GUPNP_FEATURE (object);
+ GUPnPFeaturePrivate *priv =
+ gupnp_feature_get_instance_private (GUPNP_FEATURE (object));
switch (property_id) {
case PROP_NAME:
- feature->priv->name = g_value_dup_string (value);
+ priv->name = g_value_dup_string (value);
break;
case PROP_VERSION:
- feature->priv->version = g_value_dup_string (value);
+ priv->version = g_value_dup_string (value);
break;
case PROP_OBJECT_IDS:
- feature->priv->object_ids = g_value_dup_string (value);
+ priv->object_ids = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -196,7 +196,10 @@ gupnp_feature_class_init (GUPnPFeatureClass *klass)
const char *
gupnp_feature_get_name (GUPnPFeature *feature)
{
- return feature->priv->name;
+ GUPnPFeaturePrivate *priv =
+ gupnp_feature_get_instance_private (GUPNP_FEATURE (feature));
+
+ return priv->name;
}
/**
@@ -210,7 +213,10 @@ gupnp_feature_get_name (GUPnPFeature *feature)
const char *
gupnp_feature_get_version (GUPnPFeature *feature)
{
- return feature->priv->version;
+ GUPnPFeaturePrivate *priv =
+ gupnp_feature_get_instance_private (GUPNP_FEATURE (feature));
+
+ return priv->version;
}
/**
@@ -224,5 +230,8 @@ gupnp_feature_get_version (GUPnPFeature *feature)
const char *
gupnp_feature_get_object_ids (GUPnPFeature *feature)
{
- return feature->priv->object_ids;
+ GUPnPFeaturePrivate *priv =
+ gupnp_feature_get_instance_private (GUPNP_FEATURE (feature));
+
+ return priv->object_ids;
}
diff --git a/libgupnp-av/gupnp-feature.h b/libgupnp-av/gupnp-feature.h
index cc3e259..872f816 100644
--- a/libgupnp-av/gupnp-feature.h
+++ b/libgupnp-av/gupnp-feature.h
@@ -19,48 +19,24 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GUPNP_FEATURE_H_
-#define __GUPNP_FEATURE_H_
+#ifndef GUPNP_FEATURE_H
+#define GUPNP_FEATURE_H
#include <glib-object.h>
G_BEGIN_DECLS
-GType
-gupnp_feature_get_type (void) G_GNUC_CONST;
+G_DECLARE_DERIVABLE_TYPE(GUPnPFeature,
+ gupnp_feature,
+ GUPNP,
+ FEATURE,
+ GObject)
-#define GUPNP_TYPE_FEATURE \
- (gupnp_feature_get_type ())
-#define GUPNP_FEATURE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_FEATURE, \
- GUPnPFeature))
-#define GUPNP_FEATURE_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_FEATURE, \
- GUPnPFeatureClass))
-#define GUPNP_IS_FEATURE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_FEATURE))
-#define GUPNP_IS_FEATURE_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_FEATURE))
-#define GUPNP_FEATURE_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_FEATURE, \
- GUPnPFeatureClass))
+#define GUPNP_TYPE_FEATURE (gupnp_feature_get_type ())
-typedef struct _GUPnPFeaturePrivate GUPnPFeaturePrivate;
-
-typedef struct {
- GObject parent;
-
- GUPnPFeaturePrivate *priv;
-} GUPnPFeature;
-
-typedef struct {
+struct _GUPnPFeatureClass {
GObjectClass parent_class;
-} GUPnPFeatureClass;
+};
const char *
gupnp_feature_get_name (GUPnPFeature *feature);
@@ -73,4 +49,4 @@ gupnp_feature_get_object_ids (GUPnPFeature *feature);
G_END_DECLS
-#endif /* __GUPNP_FEATURE_H_ */
+#endif /* GUPNP_FEATURE_H */
diff --git a/libgupnp-av/gupnp-last-change-parser.c b/libgupnp-av/gupnp-last-change-parser.c
index 5c969a3..afbc8e7 100644
--- a/libgupnp-av/gupnp-last-change-parser.c
+++ b/libgupnp-av/gupnp-last-change-parser.c
@@ -39,7 +39,7 @@
G_DEFINE_TYPE (GUPnPLastChangeParser,
gupnp_last_change_parser,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
static void
gupnp_last_change_parser_init (G_GNUC_UNUSED GUPnPLastChangeParser *parser)
@@ -90,7 +90,7 @@ read_state_variable (const char *variable_name,
return FALSE;
}
- gvalue_util_set_value_from_string (value, val_str);
+ av_gvalue_util_set_value_from_string (value, val_str);
return TRUE;
}
diff --git a/libgupnp-av/gupnp-last-change-parser.h b/libgupnp-av/gupnp-last-change-parser.h
index cd14ac6..fd533db 100644
--- a/libgupnp-av/gupnp-last-change-parser.h
+++ b/libgupnp-av/gupnp-last-change-parser.h
@@ -21,42 +21,22 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GUPNP_LAST_CHANGE_PARSER_H__
-#define __GUPNP_LAST_CHANGE_PARSER_H__
+#ifndef GUPNP_LAST_CHANGE_PARSER_H
+#define GUPNP_LAST_CHANGE_PARSER_H
#include <glib-object.h>
G_BEGIN_DECLS
-GType
-gupnp_last_change_parser_get_type (void) G_GNUC_CONST;
+G_DECLARE_DERIVABLE_TYPE (GUPnPLastChangeParser,
+ gupnp_last_change_parser,
+ GUPNP,
+ LAST_CHANGE_PARSER,
+ GObject)
-#define GUPNP_TYPE_LAST_CHANGE_PARSER \
- (gupnp_last_change_parser_get_type ())
-#define GUPNP_LAST_CHANGE_PARSER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_LAST_CHANGE_PARSER, \
- GUPnPLastChangeParser))
-#define GUPNP_LAST_CHANGE_PARSER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_LAST_CHANGE_PARSER, \
- GUPnPLastChangeParserClass))
-#define GUPNP_IS_LAST_CHANGE_PARSER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_LAST_CHANGE_PARSER))
-#define GUPNP_IS_LAST_CHANGE_PARSER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_LAST_CHANGE_PARSER))
-#define GUPNP_LAST_CHANGE_PARSER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_LAST_CHANGE_PARSER, \
- GUPnPLastChangeParserClass))
+#define GUPNP_TYPE_LAST_CHANGE_PARSER (gupnp_last_change_parser_get_type ())
-typedef struct {
- GObject parent;
-} GUPnPLastChangeParser;
-
-typedef struct {
+struct _GUPnPLastChangeParserClass {
GObjectClass parent_class;
/* future padding */
@@ -64,7 +44,7 @@ typedef struct {
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
-} GUPnPLastChangeParserClass;
+};
GUPnPLastChangeParser *
gupnp_last_change_parser_new (void);
diff --git a/libgupnp-av/gupnp-media-collection.c b/libgupnp-av/gupnp-media-collection.c
index 11d30b3..6417799 100644
--- a/libgupnp-av/gupnp-media-collection.c
+++ b/libgupnp-av/gupnp-media-collection.c
@@ -43,10 +43,11 @@ struct _GUPnPMediaCollectionPrivate {
gboolean mutable;
char *data;
};
+typedef struct _GUPnPMediaCollectionPrivate GUPnPMediaCollectionPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GUPnPMediaCollection,
gupnp_media_collection,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
enum {
PROP_0,
@@ -61,17 +62,18 @@ reparent_children (GUPnPMediaCollection *collection)
{
GList *it;
xmlNode *container_node;
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
- container_node = gupnp_didl_lite_object_get_xml_node
- (collection->priv->container);
+ container_node = gupnp_didl_lite_object_get_xml_node (priv->container);
/* Reverse iterate the list to get the correct order in XML */
- it = g_list_last (collection->priv->items);
+ it = g_list_last (priv->items);
while (it) {
xmlNode *node;
- node = gupnp_didl_lite_object_get_xml_node
- (GUPNP_DIDL_LITE_OBJECT (it->data));
+ node = gupnp_didl_lite_object_get_xml_node (
+ GUPNP_DIDL_LITE_OBJECT (it->data));
xmlUnlinkNode (node);
xmlAddChild (container_node, node);
@@ -84,12 +86,14 @@ on_container_available (GUPnPMediaCollection *self,
GUPnPDIDLLiteContainer *container,
G_GNUC_UNUSED gpointer user_data)
{
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (self);
+
/* According to media format spec, there's only one container allowed;
* We allow any number of containers, but only the last one wins. */
- if (self->priv->container != NULL)
- g_object_unref (self->priv->container);
+ g_clear_object (&priv->container);
- self->priv->container = GUPNP_DIDL_LITE_OBJECT (g_object_ref (container));
+ priv->container = GUPNP_DIDL_LITE_OBJECT (g_object_ref (container));
}
static void
@@ -97,8 +101,10 @@ on_item_available (GUPnPMediaCollection *self,
GUPnPDIDLLiteItem *item,
G_GNUC_UNUSED gpointer user_data)
{
- self->priv->items = g_list_prepend (self->priv->items,
- g_object_ref (item));
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (self);
+
+ priv->items = g_list_prepend (priv->items, g_object_ref (item));
}
static void
@@ -123,14 +129,13 @@ parse_data (GUPnPMediaCollection *collection, const char *data)
TRUE,
&error);
if (!result) {
- GUPnPMediaCollectionPrivate *priv = collection->priv;
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
g_warning ("Failed to parse DIDL-Lite: %s", error->message);
g_error_free (error);
- if (priv->container) {
- g_object_unref (priv->container);
- priv->container = NULL;
- }
+ g_clear_object (&priv->container);
+
if (priv->items) {
g_list_free_full (priv->items, g_object_unref);
priv->items = NULL;
@@ -141,11 +146,12 @@ parse_data (GUPnPMediaCollection *collection, const char *data)
static void
gupnp_media_collection_init (GUPnPMediaCollection *collection)
{
- collection->priv =
+ GUPnPMediaCollectionPrivate *priv =
gupnp_media_collection_get_instance_private (collection);
+
/* Initialize as mutable and decide later on in constructed() if we
* really are. */
- collection->priv->mutable = TRUE;
+ priv->mutable = TRUE;
}
static void
@@ -154,9 +160,9 @@ gupnp_media_collection_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GUPnPMediaCollection *collection;
-
- collection = GUPNP_MEDIA_COLLECTION (object);
+ GUPnPMediaCollection *collection = GUPNP_MEDIA_COLLECTION (object);
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
switch (property_id) {
case PROP_AUTHOR:
@@ -168,7 +174,7 @@ gupnp_media_collection_set_property (GObject *object,
g_value_get_string (value));
break;
case PROP_DATA:
- collection->priv->data = g_value_dup_string (value);
+ priv->data = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -212,26 +218,20 @@ gupnp_media_collection_constructed (GObject *object)
GObjectClass *object_class;
collection = GUPNP_MEDIA_COLLECTION (object);
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
/* Check if we have some data. If there's data, we assume that the
* user meant to parse a playlist. We ignore title and author then. */
- if (collection->priv->data != NULL) {
- if (collection->priv->container != NULL) {
- g_object_unref (collection->priv->container);
- collection->priv->container = NULL;
- }
-
- if (collection->priv->writer != NULL) {
- g_object_unref (collection->priv->writer);
- collection->priv->writer = NULL;
- }
-
- parse_data (collection, collection->priv->data);
- collection->priv->mutable = FALSE;
- } else if (collection->priv->writer == NULL) {
- collection->priv->writer =
- gupnp_didl_lite_writer_new (NULL);
- collection->priv->mutable = TRUE;
+ if (priv->data != NULL) {
+ g_clear_object (&priv->container);
+ g_clear_object (&priv->writer);
+
+ parse_data (collection, priv->data);
+ priv->mutable = FALSE;
+ } else if (priv->writer == NULL) {
+ priv->writer = gupnp_didl_lite_writer_new (NULL);
+ priv->mutable = TRUE;
}
/* Chain up */
@@ -247,24 +247,18 @@ gupnp_media_collection_dispose (GObject *object)
GObjectClass *object_class;
collection = GUPNP_MEDIA_COLLECTION (object);
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
- if (collection->priv->writer) {
- g_object_unref (collection->priv->writer);
- collection->priv->writer = NULL;
- }
-
- if (collection->priv->items) {
- g_list_free_full (collection->priv->items, g_object_unref);
- collection->priv->items = NULL;
- }
+ g_clear_object (&priv->writer);
- if (collection->priv->container) {
- g_object_unref (collection->priv->container);
- collection->priv->container = NULL;
+ if (priv->items) {
+ g_list_free_full (priv->items, g_object_unref);
+ priv->items = NULL;
}
+ g_clear_object (&priv->container);
- g_free (collection->priv->data);
- collection->priv->data = NULL;
+ g_clear_pointer (&priv->data, g_free);
object_class = G_OBJECT_CLASS (gupnp_media_collection_parent_class);
object_class->dispose (object);
@@ -389,48 +383,49 @@ gupnp_media_collection_set_title (GUPnPMediaCollection *collection,
const char *title)
{
GUPnPDIDLLiteContainer *container;
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
g_return_if_fail (GUPNP_IS_MEDIA_COLLECTION (collection));
- g_return_if_fail (collection->priv->mutable);
+ g_return_if_fail (priv->mutable);
if (title == NULL)
return;
- if (collection->priv->container != NULL) {
- gupnp_didl_lite_object_set_title (collection->priv->container,
- title);
+ if (priv->container != NULL) {
+ gupnp_didl_lite_object_set_title (priv->container, title);
return;
}
- if (collection->priv->writer == NULL)
- collection->priv->writer = gupnp_didl_lite_writer_new (NULL);
+ if (priv->writer == NULL)
+ priv->writer = gupnp_didl_lite_writer_new (NULL);
- container = gupnp_didl_lite_writer_add_container
- (collection->priv->writer);
- collection->priv->container = GUPNP_DIDL_LITE_OBJECT (container);
+ container = gupnp_didl_lite_writer_add_container (priv->writer);
+ priv->container = GUPNP_DIDL_LITE_OBJECT (container);
reparent_children (collection);
- gupnp_didl_lite_object_set_title (collection->priv->container,
- title);
+ gupnp_didl_lite_object_set_title (priv->container, title);
}
/**
* gupnp_media_collection_get_title:
* @collection: #GUPnPMediaCollection
*
- * Returns: The title of this media collection or %NULL if not set.
+ * Returns: (nullable)(transfer none): The title of this media collection or %NULL if not set.
**/
const char *
gupnp_media_collection_get_title (GUPnPMediaCollection *collection)
{
g_return_val_if_fail (GUPNP_IS_MEDIA_COLLECTION (collection), NULL);
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
- if (collection->priv->container == NULL)
+ if (priv->container == NULL)
return NULL;
- return gupnp_didl_lite_object_get_title (collection->priv->container);
+ return gupnp_didl_lite_object_get_title (priv->container);
}
/**
@@ -445,31 +440,30 @@ gupnp_media_collection_set_author (GUPnPMediaCollection *collection,
const char *author)
{
GUPnPDIDLLiteContainer *container;
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
g_return_if_fail (GUPNP_IS_MEDIA_COLLECTION (collection));
- g_return_if_fail (collection->priv->mutable);
+ g_return_if_fail (priv->mutable);
if (author == NULL)
return;
- if (collection->priv->container != NULL) {
- gupnp_didl_lite_object_set_creator (collection->priv->container,
- author);
+ if (priv->container != NULL) {
+ gupnp_didl_lite_object_set_creator (priv->container, author);
return;
}
- if (collection->priv->writer == NULL)
- collection->priv->writer = gupnp_didl_lite_writer_new (NULL);
+ if (priv->writer == NULL)
+ priv->writer = gupnp_didl_lite_writer_new (NULL);
- container = gupnp_didl_lite_writer_add_container
- (collection->priv->writer);
- collection->priv->container = GUPNP_DIDL_LITE_OBJECT (container);
+ container = gupnp_didl_lite_writer_add_container (priv->writer);
+ priv->container = GUPNP_DIDL_LITE_OBJECT (container);
reparent_children (collection);
- gupnp_didl_lite_object_set_creator (collection->priv->container,
- author);
+ gupnp_didl_lite_object_set_creator (priv->container, author);
}
/**
@@ -482,11 +476,13 @@ const char *
gupnp_media_collection_get_author (GUPnPMediaCollection *collection)
{
g_return_val_if_fail (GUPNP_IS_MEDIA_COLLECTION (collection), NULL);
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
- if (collection->priv->container == NULL)
+ if (priv->container == NULL)
return NULL;
- return gupnp_didl_lite_object_get_creator (collection->priv->container);
+ return gupnp_didl_lite_object_get_creator (priv->container);
}
/**
@@ -501,22 +497,22 @@ gupnp_media_collection_add_item (GUPnPMediaCollection *collection)
{
GUPnPDIDLLiteItem *item = NULL;
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
+
g_return_val_if_fail (collection != NULL, NULL);
g_return_val_if_fail (GUPNP_IS_MEDIA_COLLECTION (collection), NULL);
- g_return_val_if_fail (collection->priv->mutable, NULL);
+ g_return_val_if_fail (priv->mutable, NULL);
- if (collection->priv->container != NULL)
- item = gupnp_didl_lite_writer_add_container_child_item
- (collection->priv->writer,
- GUPNP_DIDL_LITE_CONTAINER
- (collection->priv->container));
+ if (priv->container != NULL)
+ item = gupnp_didl_lite_writer_add_container_child_item (
+ priv->writer,
+ GUPNP_DIDL_LITE_CONTAINER (priv->container));
else
- item = gupnp_didl_lite_writer_add_item
- (collection->priv->writer);
+ item = gupnp_didl_lite_writer_add_item (priv->writer);
/* Keep a reference of the object in case we need to do reparenting */
- collection->priv->items = g_list_prepend (collection->priv->items,
- g_object_ref (item));
+ priv->items = g_list_prepend (priv->items, g_object_ref (item));
/* Mandatory in DLNA for object. Not specified if mandatory for
* DIDL_S, but to avoid problems with clients reusing their normal
@@ -541,14 +537,15 @@ gupnp_media_collection_get_string (GUPnPMediaCollection *collection)
{
g_return_val_if_fail (collection != NULL, NULL);
g_return_val_if_fail (GUPNP_IS_MEDIA_COLLECTION (collection), NULL);
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
- if (collection->priv->data)
- return g_strdup (collection->priv->data);
+ if (priv->data)
+ return g_strdup (priv->data);
- gupnp_didl_lite_writer_filter_tags (collection->priv->writer,
- DIDL_S_FILTER);
+ gupnp_didl_lite_writer_filter_tags (priv->writer, DIDL_S_FILTER);
- return gupnp_didl_lite_writer_get_string (collection->priv->writer);
+ return gupnp_didl_lite_writer_get_string (priv->writer);
}
/**
@@ -562,16 +559,13 @@ gupnp_media_collection_get_string (GUPnPMediaCollection *collection)
GList *
gupnp_media_collection_get_items (GUPnPMediaCollection *collection)
{
- GList *tmp = NULL, *iter;
-
g_return_val_if_fail (collection != NULL, NULL);
g_return_val_if_fail (GUPNP_IS_MEDIA_COLLECTION (collection), NULL);
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
- for (iter = collection->priv->items; iter != NULL; iter = iter->next) {
- tmp = g_list_prepend (tmp, g_object_ref (iter->data));
- }
-
- return tmp;
+ return g_list_reverse (
+ g_list_copy_deep (priv->items, (GCopyFunc) g_object_ref, NULL));
}
/**
@@ -586,5 +580,8 @@ gupnp_media_collection_get_mutable (GUPnPMediaCollection *collection)
g_return_val_if_fail (collection != NULL, FALSE);
g_return_val_if_fail (GUPNP_IS_MEDIA_COLLECTION (collection), FALSE);
- return collection->priv->mutable;
+ GUPnPMediaCollectionPrivate *priv =
+ gupnp_media_collection_get_instance_private (collection);
+
+ return priv->mutable;
}
diff --git a/libgupnp-av/gupnp-media-collection.h b/libgupnp-av/gupnp-media-collection.h
index 9c5a755..26f7982 100644
--- a/libgupnp-av/gupnp-media-collection.h
+++ b/libgupnp-av/gupnp-media-collection.h
@@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GUPNP_DIDL_LITE_MEDIA_COLLECTION_H__
-#define __GUPNP_DIDL_LITE_MEDIA_COLLECTION_H__
+#ifndef GUPNP_DIDL_LITE_MEDIA_COLLECTION_H
+#define GUPNP_DIDL_LITE_MEDIA_COLLECTION_H
#include <glib-object.h>
@@ -28,39 +28,13 @@
G_BEGIN_DECLS
-GType
-gupnp_media_collection_get_type (void) G_GNUC_CONST;
-
-#define GUPNP_TYPE_MEDIA_COLLECTION \
- (gupnp_media_collection_get_type ())
-#define GUPNP_MEDIA_COLLECTION(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_MEDIA_COLLECTION, \
- GUPnPMediaCollection))
-#define GUPNP_MEDIA_COLLECTION_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_MEDIA_COLLECTION, \
- GUPnPMediaCollectionClass))
-#define GUPNP_IS_MEDIA_COLLECTION(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_MEDIA_COLLECTION))
-#define GUPNP_IS_MEDIA_COLLECTION_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_MEDIA_COLLECTION))
-#define GUPNP_MEDIA_COLLECTION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_MEDIA_COLLECTION, \
- GUPnPMediaCollectionClass))
-
-typedef struct _GUPnPMediaCollectionPrivate GUPnPMediaCollectionPrivate;
-typedef struct _GUPnPMediaCollection GUPnPMediaCollection;
-typedef struct _GUPnPMediaCollectionClass GUPnPMediaCollectionClass;
-
-struct _GUPnPMediaCollection {
- GObject parent;
-
- GUPnPMediaCollectionPrivate *priv;
-};
+G_DECLARE_DERIVABLE_TYPE (GUPnPMediaCollection,
+ gupnp_media_collection,
+ GUPNP,
+ MEDIA_COLLECTION,
+ GObject)
+
+#define GUPNP_TYPE_MEDIA_COLLECTION (gupnp_media_collection_get_type ())
struct _GUPnPMediaCollectionClass {
GObjectClass parent_class;
@@ -106,4 +80,4 @@ gupnp_media_collection_get_mutable (GUPnPMediaCollection *collection);
G_END_DECLS
-#endif /* __GUPNP_DIDL_LITE_MEDIA_COLLECTION_H__ */
+#endif /* GUPNP_DIDL_LITE_MEDIA_COLLECTION_H */
diff --git a/libgupnp-av/gupnp-protocol-info.c b/libgupnp-av/gupnp-protocol-info.c
index 2c3c5db..bc7d480 100644
--- a/libgupnp-av/gupnp-protocol-info.c
+++ b/libgupnp-av/gupnp-protocol-info.c
@@ -46,10 +46,11 @@ struct _GUPnPProtocolInfoPrivate {
GUPnPDLNAOperation dlna_operation;
GUPnPDLNAFlags dlna_flags;
};
+typedef struct _GUPnPProtocolInfoPrivate GUPnPProtocolInfoPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GUPnPProtocolInfo,
gupnp_protocol_info,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
enum {
PROP_0,
@@ -300,11 +301,6 @@ add_dlna_info (GString *str,
static void
gupnp_protocol_info_init (GUPnPProtocolInfo *info)
{
- info->priv = gupnp_protocol_info_get_instance_private (info);
-
- info->priv->dlna_conversion = GUPNP_DLNA_CONVERSION_NONE;
- info->priv->dlna_operation = GUPNP_DLNA_OPERATION_NONE;
- info->priv->dlna_flags = GUPNP_DLNA_FLAGS_NONE;
}
static void
@@ -417,20 +413,15 @@ static void
gupnp_protocol_info_finalize (GObject *object)
{
GObjectClass *object_class;
- GUPnPProtocolInfoPrivate *priv;
-
- priv = GUPNP_PROTOCOL_INFO (object)->priv;
-
- if (priv->protocol)
- g_free (priv->protocol);
- if (priv->network)
- g_free (priv->network);
- if (priv->mime_type)
- g_free (priv->mime_type);
- if (priv->dlna_profile)
- g_free (priv->dlna_profile);
- if (priv->play_speeds)
- g_strfreev (priv->play_speeds);
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (
+ GUPNP_PROTOCOL_INFO (object));
+
+ g_free (priv->protocol);
+ g_free (priv->network);
+ g_free (priv->mime_type);
+ g_free (priv->dlna_profile);
+ g_clear_pointer(&priv->play_speeds,g_strfreev);
object_class = G_OBJECT_CLASS (gupnp_protocol_info_parent_class);
object_class->finalize (object);
@@ -541,54 +532,48 @@ gupnp_protocol_info_class_init (GUPnPProtocolInfoClass *klass)
*
* The DLNA conversion flags.
**/
- g_object_class_install_property
- (object_class,
- PROP_DLNA_CONVERSION,
- g_param_spec_flags ("dlna-conversion",
- "DLNAConversion",
- "The DLNA conversion flags.",
- GUPNP_TYPE_DLNA_CONVERSION,
- GUPNP_DLNA_CONVERSION_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (
+ object_class,
+ PROP_DLNA_CONVERSION,
+ g_param_spec_flags ("dlna-conversion",
+ "DLNAConversion",
+ "The DLNA conversion flags.",
+ GUPNP_TYPE_DLNA_CONVERSION,
+ GUPNP_DLNA_CONVERSION_NONE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
/**
* GUPnPProtocolInfo:dlna-operation:
*
* The DLNA operation flags.
**/
- g_object_class_install_property
- (object_class,
- PROP_DLNA_OPERATION,
- g_param_spec_flags ("dlna-operation",
- "DLNAOperation",
- "The DLNA operation flags.",
- GUPNP_TYPE_DLNA_OPERATION,
- GUPNP_DLNA_OPERATION_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (
+ object_class,
+ PROP_DLNA_OPERATION,
+ g_param_spec_flags ("dlna-operation",
+ "DLNAOperation",
+ "The DLNA operation flags.",
+ GUPNP_TYPE_DLNA_OPERATION,
+ GUPNP_DLNA_OPERATION_NONE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
/**
* GUPnPProtocolInfo:dlna-flags:
*
* Various generic DLNA flags.
**/
- g_object_class_install_property
- (object_class,
- PROP_DLNA_FLAGS,
- g_param_spec_flags ("dlna-flags",
- "DLNAFlags",
- "Various generic DLNA flags.",
- GUPNP_TYPE_DLNA_FLAGS,
- GUPNP_DLNA_FLAGS_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (
+ object_class,
+ PROP_DLNA_FLAGS,
+ g_param_spec_flags ("dlna-flags",
+ "DLNAFlags",
+ "Various generic DLNA flags.",
+ GUPNP_TYPE_DLNA_FLAGS,
+ GUPNP_DLNA_FLAGS_NONE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
}
/**
@@ -617,6 +602,7 @@ GUPnPProtocolInfo *
gupnp_protocol_info_new_from_string (const char *protocol_info,
GError **error)
{
+ // FIXME: make a property...
GUPnPProtocolInfo *info;
char **tokens;
@@ -657,7 +643,8 @@ gupnp_protocol_info_new_from_string (const char *protocol_info,
*
* Provides the string representation of @info.
*
- * Return value: String representation of @info. #g_free after usage.
+ * Return value:(transfer full)(nullable): String representation of @info.
+ * #g_free after usage.
**/
char *
gupnp_protocol_info_to_string (GUPnPProtocolInfo *info)
@@ -698,15 +685,17 @@ gupnp_protocol_info_to_string (GUPnPProtocolInfo *info)
*
* Get the protocol of this info.
*
- * Return value: The protocol of this info or %NULL. This string should not
+ * Return value:(transfer none)(nullable): The protocol of this info or %NULL. This string should not
* be freed.
**/
const char *
gupnp_protocol_info_get_protocol (GUPnPProtocolInfo *info)
{
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info), NULL);
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- return info->priv->protocol;
+ return priv->protocol;
}
/**
@@ -715,14 +704,16 @@ gupnp_protocol_info_get_protocol (GUPnPProtocolInfo *info)
*
* Get the network this info is associated with.
*
- * Return value: The network string or %NULL. This string should not be freed.
+ * Return value:(transfer none)(nullable): The network string or %NULL. This string should not be freed.
**/
const char *
gupnp_protocol_info_get_network (GUPnPProtocolInfo *info)
{
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info), NULL);
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- return info->priv->network;
+ return priv->network;
}
/**
@@ -731,15 +722,17 @@ gupnp_protocol_info_get_network (GUPnPProtocolInfo *info)
*
* Get the MIME-type of this info.
*
- * Return value: The MIME-type of this info or %NULL. This string should not
+ * Return value:(transfer none)(nullable): The MIME-type of this info or %NULL. This string should not
* be freed.
**/
const char *
gupnp_protocol_info_get_mime_type (GUPnPProtocolInfo *info)
{
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info), NULL);
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- return info->priv->mime_type;
+ return priv->mime_type;
}
/**
@@ -748,15 +741,17 @@ gupnp_protocol_info_get_mime_type (GUPnPProtocolInfo *info)
*
* Get the DLNA profile of this info.
*
- * Return value: The DLNA profile of this info or %NULL. This string should
+ * Return value:(transfer none)(nullable): The DLNA profile of this info or %NULL. This string should
* not be freed.
**/
const char *
gupnp_protocol_info_get_dlna_profile (GUPnPProtocolInfo *info)
{
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info), NULL);
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- return info->priv->dlna_profile;
+ return priv->dlna_profile;
}
/**
@@ -765,15 +760,17 @@ gupnp_protocol_info_get_dlna_profile (GUPnPProtocolInfo *info)
*
* Get the allowed play speeds on this info in the form of array of strings.
*
- * Returns: (transfer none): The allowed play speeds as array of strings or %NULL. This
+ * Returns: (transfer none)(nullable): The allowed play speeds as array of strings or %NULL. This
* return array and it's content must not be modified or freed.
**/
const char **
gupnp_protocol_info_get_play_speeds (GUPnPProtocolInfo *info)
{
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info), NULL);
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- return (const char **) info->priv->play_speeds;
+ return (const char **) priv->play_speeds;
}
/**
@@ -789,8 +786,10 @@ gupnp_protocol_info_get_dlna_conversion (GUPnPProtocolInfo *info)
{
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info),
GUPNP_DLNA_CONVERSION_NONE);
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- return info->priv->dlna_conversion;
+ return priv->dlna_conversion;
}
/**
@@ -806,8 +805,10 @@ gupnp_protocol_info_get_dlna_operation (GUPnPProtocolInfo *info)
{
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info),
GUPNP_DLNA_OPERATION_NONE);
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- return info->priv->dlna_operation;
+ return priv->dlna_operation;
}
/**
@@ -823,8 +824,10 @@ gupnp_protocol_info_get_dlna_flags (GUPnPProtocolInfo *info)
{
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info),
GUPNP_DLNA_FLAGS_NONE);
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- return info->priv->dlna_flags;
+ return priv->dlna_flags;
}
/**
@@ -839,10 +842,11 @@ gupnp_protocol_info_set_protocol (GUPnPProtocolInfo *info,
const char *protocol)
{
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- if (info->priv->protocol)
- g_free (info->priv->protocol);
- info->priv->protocol = g_strdup (protocol);
+ g_free (priv->protocol);
+ priv->protocol = g_strdup (protocol);
g_object_notify (G_OBJECT (info), "protocol");
}
@@ -859,10 +863,11 @@ gupnp_protocol_info_set_network (GUPnPProtocolInfo *info,
const char *network)
{
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- if (info->priv->network)
- g_free (info->priv->network);
- info->priv->network = g_strdup (network);
+ g_free (priv->network);
+ priv->network = g_strdup (network);
g_object_notify (G_OBJECT (info), "network");
}
@@ -879,10 +884,11 @@ gupnp_protocol_info_set_mime_type (GUPnPProtocolInfo *info,
const char *mime_type)
{
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- if (info->priv->mime_type)
- g_free (info->priv->mime_type);
- info->priv->mime_type = g_strdup (mime_type);
+ g_free (priv->mime_type);
+ priv->mime_type = g_strdup (mime_type);
g_object_notify (G_OBJECT (info), "mime-type");
}
@@ -899,10 +905,11 @@ gupnp_protocol_info_set_dlna_profile (GUPnPProtocolInfo *info,
const char *profile)
{
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- if (info->priv->dlna_profile)
- g_free (info->priv->dlna_profile);
- info->priv->dlna_profile = g_strdup (profile);
+ g_free (priv->dlna_profile);
+ priv->dlna_profile = g_strdup (profile);
g_object_notify (G_OBJECT (info), "dlna-profile");
}
@@ -919,10 +926,12 @@ gupnp_protocol_info_set_play_speeds (GUPnPProtocolInfo *info,
const char **speeds)
{
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- if (info->priv->play_speeds)
- g_strfreev (info->priv->play_speeds);
- info->priv->play_speeds = (char **) g_boxed_copy (G_TYPE_STRV, speeds);
+ if (priv->play_speeds)
+ g_strfreev (priv->play_speeds);
+ priv->play_speeds = (char **) g_boxed_copy (G_TYPE_STRV, speeds);
g_object_notify (G_OBJECT (info), "play-speeds");
}
@@ -939,8 +948,10 @@ gupnp_protocol_info_set_dlna_conversion (GUPnPProtocolInfo *info,
GUPnPDLNAConversion conversion)
{
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- info->priv->dlna_conversion = conversion;
+ priv->dlna_conversion = conversion;
g_object_notify (G_OBJECT (info), "dlna-conversion");
}
@@ -957,8 +968,10 @@ gupnp_protocol_info_set_dlna_operation (GUPnPProtocolInfo *info,
GUPnPDLNAOperation operation)
{
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- info->priv->dlna_operation = operation;
+ priv->dlna_operation = operation;
g_object_notify (G_OBJECT (info), "dlna-operation");
}
@@ -975,8 +988,10 @@ gupnp_protocol_info_set_dlna_flags (GUPnPProtocolInfo *info,
GUPnPDLNAFlags flags)
{
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
+ GUPnPProtocolInfoPrivate *priv =
+ gupnp_protocol_info_get_instance_private (info);
- info->priv->dlna_flags = flags;
+ priv->dlna_flags = flags;
g_object_notify (G_OBJECT (info), "dlna-flags");
}
diff --git a/libgupnp-av/gupnp-protocol-info.h b/libgupnp-av/gupnp-protocol-info.h
index 078ad4e..74dbed3 100644
--- a/libgupnp-av/gupnp-protocol-info.h
+++ b/libgupnp-av/gupnp-protocol-info.h
@@ -22,8 +22,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GUPNP_PROTOCOL_INFO_H__
-#define __GUPNP_PROTOCOL_INFO_H__
+#ifndef GUPNP_PROTOCOL_INFO_H
+#define GUPNP_PROTOCOL_INFO_H
#include <stdarg.h>
#include <glib-object.h>
@@ -32,39 +32,15 @@
G_BEGIN_DECLS
-GType
-gupnp_protocol_info_get_type (void) G_GNUC_CONST;
-
-#define GUPNP_TYPE_PROTOCOL_INFO \
- (gupnp_protocol_info_get_type ())
-#define GUPNP_PROTOCOL_INFO(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_PROTOCOL_INFO, \
- GUPnPProtocolInfo))
-#define GUPNP_PROTOCOL_INFO_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_PROTOCOL_INFO, \
- GUPnPProtocolInfoClass))
-#define GUPNP_IS_PROTOCOL_INFO(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_PROTOCOL_INFO))
-#define GUPNP_IS_PROTOCOL_INFO_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_PROTOCOL_INFO))
-#define GUPNP_PROTOCOL_INFO_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_PROTOCOL_INFO, \
- GUPnPProtocolInfoClass))
-
-typedef struct _GUPnPProtocolInfoPrivate GUPnPProtocolInfoPrivate;
-
-typedef struct {
- GObject parent;
-
- GUPnPProtocolInfoPrivate *priv;
-} GUPnPProtocolInfo;
-
-typedef struct {
+G_DECLARE_DERIVABLE_TYPE (GUPnPProtocolInfo,
+ gupnp_protocol_info,
+ GUPNP,
+ PROTOCOL_INFO,
+ GObject)
+
+#define GUPNP_TYPE_PROTOCOL_INFO (gupnp_protocol_info_get_type ())
+
+struct _GUPnPProtocolInfoClass {
GObjectClass parent_class;
/* future padding */
@@ -72,7 +48,7 @@ typedef struct {
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
-} GUPnPProtocolInfoClass;
+};
GUPnPProtocolInfo *
gupnp_protocol_info_new (void);
@@ -146,4 +122,4 @@ gupnp_protocol_info_get_dlna_flags (GUPnPProtocolInfo *info);
G_END_DECLS
-#endif /* __GUPNP_PROTOCOL_INFO_H__ */
+#endif /* GUPNP_PROTOCOL_INFO_H */
diff --git a/libgupnp-av/gupnp-search-criteria-parser.c b/libgupnp-av/gupnp-search-criteria-parser.c
index 1fcac5b..b8ed6f7 100644
--- a/libgupnp-av/gupnp-search-criteria-parser.c
+++ b/libgupnp-av/gupnp-search-criteria-parser.c
@@ -98,10 +98,13 @@ struct _GUPnPSearchCriteriaParserPrivate {
GScanner *scanner;
};
+typedef struct _GUPnPSearchCriteriaParserPrivate
+ GUPnPSearchCriteriaParserPrivate;
+
/* GUPnPSearchCriteriaParser */
G_DEFINE_TYPE_WITH_PRIVATE (GUPnPSearchCriteriaParser,
gupnp_search_criteria_parser,
- G_TYPE_OBJECT);
+ G_TYPE_OBJECT)
enum {
BEGIN_PARENS,
@@ -169,30 +172,28 @@ struct {
static void
gupnp_search_criteria_parser_init (GUPnPSearchCriteriaParser *parser)
{
- int i;
-
- parser->priv =
+ GUPnPSearchCriteriaParserPrivate *priv =
gupnp_search_criteria_parser_get_instance_private (parser);
/* Set up GScanner */
- parser->priv->scanner = g_scanner_new (NULL);
+ priv->scanner = g_scanner_new (NULL);
- parser->priv->scanner->config->cset_skip_characters = (char *)" \t\n\r\012"
+ priv->scanner->config->cset_skip_characters = (char *)" \t\n\r\012"
"\013\014\015";
- parser->priv->scanner->config->scan_identifier_1char = TRUE;
- parser->priv->scanner->config->cset_identifier_first = (char *) G_CSET_a_2_z
+ priv->scanner->config->scan_identifier_1char = TRUE;
+ priv->scanner->config->cset_identifier_first = (char *) G_CSET_a_2_z
"_*<>=!@"
G_CSET_A_2_Z;
- parser->priv->scanner->config->cset_identifier_nth = (char *)G_CSET_a_2_z
+ priv->scanner->config->cset_identifier_nth = (char *)G_CSET_a_2_z
"_0123456789=:@"
G_CSET_A_2_Z
G_CSET_LATINS
G_CSET_LATINC;
- parser->priv->scanner->config->symbol_2_token = TRUE;
+ priv->scanner->config->symbol_2_token = TRUE;
/* Add symbols */
- for (i = 0; i < NUM_SYMBOLS; i++) {
- g_scanner_scope_add_symbol (parser->priv->scanner,
+ for (int i = 0; i < NUM_SYMBOLS; i++) {
+ g_scanner_scope_add_symbol (priv->scanner,
0,
symbols[i].name,
GINT_TO_POINTER (symbols[i].token));
@@ -206,9 +207,11 @@ gupnp_search_criteria_parser_finalize (GObject *object)
GUPnPSearchCriteriaParser *parser;
parser = GUPNP_SEARCH_CRITERIA_PARSER (object);
+ GUPnPSearchCriteriaParserPrivate *priv =
+ gupnp_search_criteria_parser_get_instance_private (parser);
/* Destroy GScanner */
- g_scanner_destroy (parser->priv->scanner);
+ g_scanner_destroy (priv->scanner);
gobject_class =
G_OBJECT_CLASS (gupnp_search_criteria_parser_parent_class);
@@ -350,14 +353,16 @@ scan_rel_exp (GUPnPSearchCriteriaParser *parser,
guint token;
GUPnPSearchCriteriaOp op;
char *arg1;
+ GUPnPSearchCriteriaParserPrivate *priv =
+ gupnp_search_criteria_parser_get_instance_private (parser);
- token = g_scanner_get_next_token (parser->priv->scanner);
+ token = g_scanner_get_next_token (priv->scanner);
g_assert (token == G_TOKEN_IDENTIFIER); /* Already checked */
- value = g_scanner_cur_value (parser->priv->scanner);
+ value = g_scanner_cur_value (priv->scanner);
arg1 = g_strdup (value.v_string);
- token = g_scanner_get_next_token (parser->priv->scanner);
+ token = g_scanner_get_next_token (priv->scanner);
switch (token) {
case GUPNP_SEARCH_CRITERIA_OP_EQ:
case GUPNP_SEARCH_CRITERIA_OP_NEQ:
@@ -370,32 +375,36 @@ scan_rel_exp (GUPnPSearchCriteriaParser *parser,
case GUPNP_SEARCH_CRITERIA_OP_DERIVED_FROM:
op = token;
- token = g_scanner_get_next_token (parser->priv->scanner);
+ token = g_scanner_get_next_token (priv->scanner);
if (token != G_TOKEN_STRING) {
- g_set_error
- (error,
- GUPNP_SEARCH_CRITERIA_PARSER_ERROR,
- GUPNP_SEARCH_CRITERIA_PARSER_ERROR_FAILED,
- "Expected quoted string at position %u",
- g_scanner_cur_position
- (parser->priv->scanner));
+ g_set_error (error,
+ GUPNP_SEARCH_CRITERIA_PARSER_ERROR,
+ GUPNP_SEARCH_CRITERIA_PARSER_ERROR_FAILED,
+ "Expected quoted string at position %u",
+ g_scanner_cur_position (priv->scanner));
ret = FALSE;
break;
}
- value = g_scanner_cur_value (parser->priv->scanner);
+ value = g_scanner_cur_value (priv->scanner);
- g_signal_emit (parser, signals[EXPRESSION], 0,
- arg1, op, value.v_string, error, &ret);
+ g_signal_emit (parser,
+ signals[EXPRESSION],
+ 0,
+ arg1,
+ op,
+ value.v_string,
+ error,
+ &ret);
break;
case GUPNP_SEARCH_CRITERIA_OP_EXISTS:
op = token;
- token = g_scanner_get_next_token (parser->priv->scanner);
+ token = g_scanner_get_next_token (priv->scanner);
switch (token) {
case SYMBOL_TRUE:
g_signal_emit (parser, signals[EXPRESSION], 0,
@@ -408,13 +417,11 @@ scan_rel_exp (GUPnPSearchCriteriaParser *parser,
break;
default:
- g_set_error
- (error,
- GUPNP_SEARCH_CRITERIA_PARSER_ERROR,
- GUPNP_SEARCH_CRITERIA_PARSER_ERROR_FAILED,
- "Expected boolean value at position %u",
- g_scanner_cur_position
- (parser->priv->scanner));
+ g_set_error (error,
+ GUPNP_SEARCH_CRITERIA_PARSER_ERROR,
+ GUPNP_SEARCH_CRITERIA_PARSER_ERROR_FAILED,
+ "Expected boolean value at position %u",
+ g_scanner_cur_position (priv->scanner));
ret = FALSE;
@@ -428,8 +435,7 @@ scan_rel_exp (GUPnPSearchCriteriaParser *parser,
GUPNP_SEARCH_CRITERIA_PARSER_ERROR,
GUPNP_SEARCH_CRITERIA_PARSER_ERROR_FAILED,
"Expected operator at position %u",
- g_scanner_cur_position
- (parser->priv->scanner));
+ g_scanner_cur_position (priv->scanner));
ret = FALSE;
}
@@ -450,12 +456,14 @@ scan_logical_op (GUPnPSearchCriteriaParser *parser,
{
gboolean ret;
guint token;
+ GUPnPSearchCriteriaParserPrivate *priv =
+ gupnp_search_criteria_parser_get_instance_private (parser);
- token = g_scanner_peek_next_token (parser->priv->scanner);
+ token = g_scanner_peek_next_token (priv->scanner);
switch (token) {
case SYMBOL_AND:
- g_scanner_get_next_token (parser->priv->scanner);
+ g_scanner_get_next_token (priv->scanner);
g_signal_emit (parser, signals[CONJUNCTION], 0);
@@ -464,7 +472,7 @@ scan_logical_op (GUPnPSearchCriteriaParser *parser,
break;
case SYMBOL_OR:
- g_scanner_get_next_token (parser->priv->scanner);
+ g_scanner_get_next_token (priv->scanner);
g_signal_emit (parser, signals[DISJUNCTION], 0);
@@ -490,11 +498,13 @@ scan_search_exp (GUPnPSearchCriteriaParser *parser,
{
gboolean ret;
guint token;
+ GUPnPSearchCriteriaParserPrivate *priv =
+ gupnp_search_criteria_parser_get_instance_private (parser);
- token = g_scanner_peek_next_token (parser->priv->scanner);
+ token = g_scanner_peek_next_token (priv->scanner);
switch (token) {
case G_TOKEN_LEFT_PAREN:
- g_scanner_get_next_token (parser->priv->scanner);
+ g_scanner_get_next_token (priv->scanner);
g_signal_emit (parser, signals[BEGIN_PARENS], 0);
@@ -502,15 +512,14 @@ scan_search_exp (GUPnPSearchCriteriaParser *parser,
if (ret == FALSE)
break;
- token = g_scanner_get_next_token (parser->priv->scanner);
+ token = g_scanner_get_next_token (priv->scanner);
if (token != G_TOKEN_RIGHT_PAREN) {
- g_set_error
- (error,
- GUPNP_SEARCH_CRITERIA_PARSER_ERROR,
- GUPNP_SEARCH_CRITERIA_PARSER_ERROR_FAILED,
- "Expected right parenthesis at position %u",
- g_scanner_cur_position
- (parser->priv->scanner));
+ g_set_error (
+ error,
+ GUPNP_SEARCH_CRITERIA_PARSER_ERROR,
+ GUPNP_SEARCH_CRITERIA_PARSER_ERROR_FAILED,
+ "Expected right parenthesis at position %u",
+ g_scanner_cur_position (priv->scanner));
ret = FALSE;
@@ -533,14 +542,14 @@ scan_search_exp (GUPnPSearchCriteriaParser *parser,
break;
default:
- g_scanner_get_next_token (parser->priv->scanner);
+ g_scanner_get_next_token (priv->scanner);
g_set_error (error,
GUPNP_SEARCH_CRITERIA_PARSER_ERROR,
GUPNP_SEARCH_CRITERIA_PARSER_ERROR_FAILED,
"Expected property name or left parenthesis at "
"position %u",
- g_scanner_cur_position (parser->priv->scanner));
+ g_scanner_cur_position (priv->scanner));
ret = FALSE;
}
@@ -570,13 +579,15 @@ gupnp_search_criteria_parser_parse_text (GUPnPSearchCriteriaParser *parser,
g_return_val_if_fail (GUPNP_IS_SEARCH_CRITERIA_PARSER (parser),
FALSE);
g_return_val_if_fail (text != NULL, FALSE);
+ GUPnPSearchCriteriaParserPrivate *priv =
+ gupnp_search_criteria_parser_get_instance_private (parser);
/* Feed into scanner */
- g_scanner_input_text (parser->priv->scanner, text, strlen (text));
+ g_scanner_input_text (priv->scanner, text, strlen (text));
- token = g_scanner_peek_next_token (parser->priv->scanner);
+ token = g_scanner_peek_next_token (priv->scanner);
if (token == SYMBOL_ASTERISK) {
- g_scanner_get_next_token (parser->priv->scanner);
+ g_scanner_get_next_token (priv->scanner);
/* Do nothing. */
@@ -586,15 +597,13 @@ gupnp_search_criteria_parser_parse_text (GUPnPSearchCriteriaParser *parser,
if (ret == TRUE) {
/* Confirm that we have EOF now */
- token = g_scanner_get_next_token (parser->priv->scanner);
+ token = g_scanner_get_next_token (priv->scanner);
if (token != G_TOKEN_EOF) {
- g_set_error
- (error,
- GUPNP_SEARCH_CRITERIA_PARSER_ERROR,
- GUPNP_SEARCH_CRITERIA_PARSER_ERROR_FAILED,
- "Expected EOF at position %u",
- g_scanner_cur_position
- (parser->priv->scanner));
+ g_set_error (error,
+ GUPNP_SEARCH_CRITERIA_PARSER_ERROR,
+ GUPNP_SEARCH_CRITERIA_PARSER_ERROR_FAILED,
+ "Expected EOF at position %u",
+ g_scanner_cur_position (priv->scanner));
}
}
diff --git a/libgupnp-av/gupnp-search-criteria-parser.h b/libgupnp-av/gupnp-search-criteria-parser.h
index 832a17a..7a0878c 100644
--- a/libgupnp-av/gupnp-search-criteria-parser.h
+++ b/libgupnp-av/gupnp-search-criteria-parser.h
@@ -19,36 +19,21 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GUPNP_SEARCH_CRITERIA_PARSER_H__
-#define __GUPNP_SEARCH_CRITERIA_PARSER_H__
+#ifndef GUPNP_SEARCH_CRITERIA_PARSER_H
+#define GUPNP_SEARCH_CRITERIA_PARSER_H
#include <glib-object.h>
G_BEGIN_DECLS
-GType
-gupnp_search_criteria_parser_get_type (void) G_GNUC_CONST;
-
-#define GUPNP_TYPE_SEARCH_CRITERIA_PARSER \
- (gupnp_search_criteria_parser_get_type ())
-#define GUPNP_SEARCH_CRITERIA_PARSER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- GUPNP_TYPE_SEARCH_CRITERIA_PARSER, \
- GUPnPSearchCriteriaParser))
-#define GUPNP_SEARCH_CRITERIA_PARSER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_CAST ((obj), \
- GUPNP_TYPE_SEARCH_CRITERIA_PARSER, \
- GUPnPSearchCriteriaParserClass))
-#define GUPNP_IS_SEARCH_CRITERIA_PARSER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- GUPNP_TYPE_SEARCH_CRITERIA_PARSER))
-#define GUPNP_IS_SEARCH_CRITERIA_PARSER_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE ((obj), \
- GUPNP_TYPE_SEARCH_CRITERIA_PARSER))
-#define GUPNP_SEARCH_CRITERIA_PARSER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- GUPNP_TYPE_SEARCH_CRITERIA_PARSER, \
- GUPnPSearchCriteriaParserClass))
+G_DECLARE_DERIVABLE_TYPE(GUPnPSearchCriteriaParser,
+ gupnp_search_criteria_parser,
+ GUPNP,
+ SEARCH_CRITERIA_PARSER,
+ GObject)
+
+#define GUPNP_TYPE_SEARCH_CRITERIA_PARSER \
+ (gupnp_search_criteria_parser_get_type ())
/**
* GUPnPSearchCriteriaOp:
@@ -87,8 +72,8 @@ gupnp_search_criteria_op_get_type (void) G_GNUC_CONST;
#define GUPNP_TYPE_SEARCH_CRITERIA_OP (gupnp_search_criteria_op_get_type ())
-#define GUPNP_SEARCH_CRITERIA_PARSER_ERROR \
- (gupnp_search_criteria_parser_error_quark ())
+#define GUPNP_SEARCH_CRITERIA_PARSER_ERROR \
+ (gupnp_search_criteria_parser_error_quark ())
GQuark
gupnp_search_criteria_parser_error_quark (void);
@@ -102,16 +87,8 @@ typedef enum {
GUPNP_SEARCH_CRITERIA_PARSER_ERROR_FAILED
} GUPnPSearchCriteriaParserError;
-typedef struct _GUPnPSearchCriteriaParserPrivate
- GUPnPSearchCriteriaParserPrivate;
-
-typedef struct {
- GObject parent;
-
- GUPnPSearchCriteriaParserPrivate *priv;
-} GUPnPSearchCriteriaParser;
-typedef struct {
+struct _GUPnPSearchCriteriaParserClass {
GObjectClass parent_class;
/* signals */
@@ -130,7 +107,7 @@ typedef struct {
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
-} GUPnPSearchCriteriaParserClass;
+};
GUPnPSearchCriteriaParser *
gupnp_search_criteria_parser_new (void);
@@ -142,4 +119,4 @@ gupnp_search_criteria_parser_parse_text (GUPnPSearchCriteriaParser *parser,
G_END_DECLS
-#endif /* __GUPNP_SEARCH_CRITERIA_PARSER_H__ */
+#endif /* GUPNP_SEARCH_CRITERIA_PARSER_H */
diff --git a/libgupnp-av/gvalue-util.c b/libgupnp-av/gvalue-util.c
index daece3b..abfee66 100644
--- a/libgupnp-av/gvalue-util.c
+++ b/libgupnp-av/gvalue-util.c
@@ -25,8 +25,7 @@
#include "gvalue-util.h"
gboolean
-gvalue_util_set_value_from_string (GValue *value,
- const char *str)
+av_gvalue_util_set_value_from_string (GValue *value, const char *str)
{
GValue tmp_value = {0, };
int i;
@@ -42,11 +41,7 @@ gvalue_util_set_value_from_string (GValue *value,
break;
case G_TYPE_CHAR:
-#if GLIB_CHECK_VERSION(2,32,0)
g_value_set_schar (value, *str);
-#else
- g_value_set_char (value, *str);
-#endif
break;
diff --git a/libgupnp-av/gvalue-util.h b/libgupnp-av/gvalue-util.h
index c3b883a..1af32fd 100644
--- a/libgupnp-av/gvalue-util.h
+++ b/libgupnp-av/gvalue-util.h
@@ -19,14 +19,13 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GVALUE_UTIL_H__
-#define __GVALUE_UTIL_H__
+#ifndef GVALUE_UTIL_H
+#define GVALUE_UTIL_H
#include <glib-object.h>
G_GNUC_INTERNAL gboolean
-gvalue_util_set_value_from_string (GValue *value,
- const char *str);
+av_gvalue_util_set_value_from_string (GValue *value, const char *str);
#endif /* __GVALUE_UTIL_H__ */
diff --git a/libgupnp-av/meson.build b/libgupnp-av/meson.build
index deb14e3..2dc1bb9 100644
--- a/libgupnp-av/meson.build
+++ b/libgupnp-av/meson.build
@@ -22,7 +22,7 @@ introspection_sources = [
]
v = meson.project_version().split('.')
-soversion = 2
+soversion = 3
library_minor = v[0].to_int() * 100 + v[1].to_int()
library_micro = v[2].to_int()
diff --git a/libgupnp-av/time-utils.h b/libgupnp-av/time-utils.h
index d15c598..d5a8ad2 100644
--- a/libgupnp-av/time-utils.h
+++ b/libgupnp-av/time-utils.h
@@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __TIME_UTILS_H__
-#define __TIME_UTILS_H__
+#ifndef TIME_UTILS_H
+#define TIME_UTILS_H
G_BEGIN_DECLS
diff --git a/libgupnp-av/xml-util.c b/libgupnp-av/xml-util.c
index ba3b1d1..bb1c2b4 100644
--- a/libgupnp-av/xml-util.c
+++ b/libgupnp-av/xml-util.c
@@ -24,6 +24,7 @@
*/
#include <string.h>
+#include <glib/gprintf.h>
#include "xml-util.h"
@@ -41,7 +42,7 @@ static GUPnPXMLNamespaceDescription gupnp_xml_namespaces[] =
{ "urn:schemas-dlna-org:metadata-1-0/", "dlna" },
{ "http://www.pv.com/pvns/", "pv" },
{ "urn:schemas-upnp-org:metadata-1-0/upnp/", "upnp" },
- { NULL }
+ { NULL, NULL }
};
GUPnPAVXMLDoc *
@@ -558,4 +559,47 @@ av_xml_util_get_ns (xmlDocPtr doc, GUPnPXMLNamespace ns, xmlNsPtr *ns_out)
return tmp_ns;
}
+void
+av_xml_util_set_int_prop (xmlNodePtr node, const char *name, int value)
+{
+ char *str;
+
+ str = g_strdup_printf ("%d", value);
+ xmlSetProp (node, (unsigned char *) name, (unsigned char *) str);
+ g_free (str);
+}
+
+void
+av_xml_util_set_prop (xmlNodePtr node,
+ const char *name,
+ const char *format,
+ ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ char *str = NULL;
+ g_vasprintf (&str, format, args);
+ xmlSetProp (node, (xmlChar *) name, (xmlChar *) str);
+ g_free (str);
+ va_end (args);
+}
+
+void
+av_xml_util_set_ns_prop (xmlNodePtr node,
+ xmlNsPtr ns,
+ const char *name,
+ const char *format,
+ ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ char *str = NULL;
+ g_vasprintf(&str, format, args);
+ xmlSetNsProp (node, ns, (xmlChar *) name, (xmlChar *) str);
+ g_free (str);
+ va_end (args);
+}
+
G_DEFINE_BOXED_TYPE (GUPnPAVXMLDoc, av_xml_doc, g_rc_box_acquire, av_xml_doc_unref)
diff --git a/libgupnp-av/xml-util.h b/libgupnp-av/xml-util.h
index 0010837..9c52d5f 100644
--- a/libgupnp-av/xml-util.h
+++ b/libgupnp-av/xml-util.h
@@ -23,8 +23,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __XML_UTIL_H__
-#define __XML_UTIL_H__
+#ifndef XML_UTIL_H
+#define XML_UTIL_H
#include <glib.h>
#include <libxml/tree.h>
@@ -45,7 +45,6 @@ G_BEGIN_DECLS
typedef struct _GPnPAVXMLDoc
{
- volatile int refcount;
xmlDoc *doc;
} GUPnPAVXMLDoc;
@@ -159,6 +158,14 @@ G_GNUC_INTERNAL xmlNsPtr
av_xml_util_get_ns (xmlDocPtr doc,
GUPnPXMLNamespace ns,
xmlNsPtr *ns_out);
+G_GNUC_INTERNAL void
+av_xml_util_set_int_prop (xmlNodePtr node, const char *name, int value);
+
+G_GNUC_INTERNAL void
+av_xml_util_set_prop (xmlNodePtr node, const char *name, const char *format, ...) G_GNUC_PRINTF(3, 4);
+
+G_GNUC_INTERNAL void
+av_xml_util_set_ns_prop (xmlNodePtr node, xmlNsPtr ns, const char *name, const char *format, ...)
G_GNUC_PRINTF(4, 5);
G_END_DECLS
diff --git a/libgupnp-av/xsd-data.c b/libgupnp-av/xsd-data.c
index 3f985a4..276a973 100644
--- a/libgupnp-av/xsd-data.c
+++ b/libgupnp-av/xsd-data.c
@@ -64,10 +64,9 @@ xsd_data_free (XSDData *xsd_data)
{
if (xsd_data == NULL)
return;
- if (xsd_data->valid_context != NULL)
- xmlSchemaFreeValidCtxt (xsd_data->valid_context);
- if (xsd_data->schema != NULL)
- xmlSchemaFree (xsd_data->schema);
+ g_clear_pointer (&xsd_data->valid_context, xmlSchemaFreeValidCtxt);
+ g_clear_pointer (&xsd_data->schema, xmlSchemaFree);
+
g_slice_free (XSDData, xsd_data);
}
diff --git a/libgupnp-av/xsd-data.h b/libgupnp-av/xsd-data.h
index b89dcd6..55d86f2 100644
--- a/libgupnp-av/xsd-data.h
+++ b/libgupnp-av/xsd-data.h
@@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __XSD_DATA_H__
-#define __XSD_DATA_H__
+#ifndef XSD_DATA_H
+#define XSD_DATA_H
#include <glib.h>
#include <libxml/tree.h>
diff --git a/meson.build b/meson.build
index 816a535..7bbee82 100644
--- a/meson.build
+++ b/meson.build
@@ -1,4 +1,4 @@
-project('gupnp-av', 'c', version : '0.12.12')
+project('gupnp-av', 'c', version : '0.12.12', default_options: ['c_std=c11'])
gnome = import('gnome')
@@ -40,7 +40,6 @@ elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
'-Wnested-externs',
'-Wbad-function-cast',
'-Wold-style-definition',
- '-Wdeclaration-after-statement',
'-Wunused',
'-Wuninitialized',
'-Wshadow',
diff --git a/tests/check-feature-list-parser.c b/tests/check-feature-list-parser.c
index 06014ab..c805ba0 100644
--- a/tests/check-feature-list-parser.c
+++ b/tests/check-feature-list-parser.c
@@ -83,10 +83,6 @@ main (G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
GList *item;
gboolean success = TRUE;
-#if !GLIB_CHECK_VERSION (2, 35, 0)
- g_type_init ();
-#endif
-
parser = gupnp_feature_list_parser_new ();
error = NULL;
diff --git a/tests/test-search-criteria-parser.c b/tests/test-search-criteria-parser.c
index 101b4bd..ebceefb 100644
--- a/tests/test-search-criteria-parser.c
+++ b/tests/test-search-criteria-parser.c
@@ -71,10 +71,6 @@ main (int argc, char **argv)
g_assert (argc == 2);
-#if !GLIB_CHECK_VERSION (2, 35, 0)
- g_type_init ();
-#endif
-
parser = gupnp_search_criteria_parser_new ();
g_signal_connect (parser,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]