From b44646093db8f41de952c9b740529cb849c73122 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 31 Jan 2017 13:33:41 +0100 Subject: core: Add a public wrapper for GDataParsable:get_content_type https://bugzilla.gnome.org/show_bug.cgi?id=777980 --- docs/reference/gdata-sections.txt | 1 + gdata/gdata-core.symbols | 1 + gdata/gdata-parsable.c | 23 +++++++++++++++++++++++ gdata/gdata-parsable.h | 2 ++ 4 files changed, 27 insertions(+) diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt index 231c2b5f..441d67db 100644 --- a/docs/reference/gdata-sections.txt +++ b/docs/reference/gdata-sections.txt @@ -706,6 +706,7 @@ GDataAccessRulePrivate GDataParsable GDataParsable GDataParsableClass +gdata_parsable_get_content_type gdata_parsable_new_from_xml gdata_parsable_get_xml gdata_parsable_new_from_json diff --git a/gdata/gdata-core.symbols b/gdata/gdata-core.symbols index c04188d8..7f5da8a5 100644 --- a/gdata/gdata-core.symbols +++ b/gdata/gdata-core.symbols @@ -311,6 +311,7 @@ gdata_access_rule_set_scope gdata_access_rule_get_edited gdata_access_rule_get_key gdata_parsable_get_type +gdata_parsable_get_content_type gdata_parsable_new_from_xml gdata_parsable_get_xml gdata_parsable_new_from_json diff --git a/gdata/gdata-parsable.c b/gdata/gdata-parsable.c index 64fa1bfe..06ea6221 100644 --- a/gdata/gdata-parsable.c +++ b/gdata/gdata-parsable.c @@ -547,6 +547,29 @@ _gdata_parsable_new_from_json_node (GType parsable_type, JsonReader *reader, gpo return parsable; } +/** + * gdata_parsable_get_content_type: + * @self: a #GDataParsable + * + * Returns the content type upon which the #GDataParsable is built. For example, `application/atom+xml` or `application/json`. + * + * Return value: the parsable's content type + * + * Since: UNRELEASED + */ +const gchar * +gdata_parsable_get_content_type (GDataParsable *self) +{ + GDataParsableClass *klass; + + g_return_val_if_fail (GDATA_IS_PARSABLE (self), NULL); + + klass = GDATA_PARSABLE_GET_CLASS (self); + g_assert (klass->get_content_type != NULL); + + return klass->get_content_type (); +} + static void build_namespaces_cb (gchar *prefix, gchar *href, GString *output) { diff --git a/gdata/gdata-parsable.h b/gdata/gdata-parsable.h index 2f16a8e7..f4a090f2 100644 --- a/gdata/gdata-parsable.h +++ b/gdata/gdata-parsable.h @@ -120,6 +120,8 @@ typedef struct { GType gdata_parsable_get_type (void) G_GNUC_CONST; +const gchar *gdata_parsable_get_content_type (GDataParsable *self); + GDataParsable *gdata_parsable_new_from_xml (GType parsable_type, const gchar *xml, gint length, GError **error) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC; gchar *gdata_parsable_get_xml (GDataParsable *self) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC; -- cgit v1.2.1