Blame gdata/gdata-entry.c

Packit 4b6dd7
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
Packit 4b6dd7
/*
Packit 4b6dd7
 * GData Client
Packit 4b6dd7
 * Copyright (C) Philip Withnall 2008–2010 <philip@tecnocode.co.uk>
Packit 4b6dd7
 *
Packit 4b6dd7
 * GData Client is free software; you can redistribute it and/or
Packit 4b6dd7
 * modify it under the terms of the GNU Lesser General Public
Packit 4b6dd7
 * License as published by the Free Software Foundation; either
Packit 4b6dd7
 * version 2.1 of the License, or (at your option) any later version.
Packit 4b6dd7
 *
Packit 4b6dd7
 * GData Client is distributed in the hope that it will be useful,
Packit 4b6dd7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 4b6dd7
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 4b6dd7
 * Lesser General Public License for more details.
Packit 4b6dd7
 *
Packit 4b6dd7
 * You should have received a copy of the GNU Lesser General Public
Packit 4b6dd7
 * License along with GData Client.  If not, see <http://www.gnu.org/licenses/>.
Packit 4b6dd7
 */
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * SECTION:gdata-entry
Packit 4b6dd7
 * @short_description: GData entry object
Packit 4b6dd7
 * @stability: Stable
Packit 4b6dd7
 * @include: gdata/gdata-entry.h
Packit 4b6dd7
 *
Packit 4b6dd7
 * #GDataEntry represents a single object on the online service, such as a playlist, video or calendar event. It is a snapshot of the
Packit 4b6dd7
 * state of that object at the time of querying the service, so modifications made to a #GDataEntry will not be automatically or
Packit 4b6dd7
 * magically propagated to the server.
Packit 4b6dd7
 */
Packit 4b6dd7
Packit 4b6dd7
#include <config.h>
Packit 4b6dd7
#include <glib.h>
Packit 4b6dd7
#include <glib/gi18n-lib.h>
Packit 4b6dd7
#include <libxml/parser.h>
Packit 4b6dd7
#include <string.h>
Packit 4b6dd7
#include <json-glib/json-glib.h>
Packit 4b6dd7
Packit 4b6dd7
#include "gdata-entry.h"
Packit 4b6dd7
#include "gdata-types.h"
Packit 4b6dd7
#include "gdata-service.h"
Packit 4b6dd7
#include "gdata-private.h"
Packit 4b6dd7
#include "gdata-comparable.h"
Packit 4b6dd7
#include "atom/gdata-category.h"
Packit 4b6dd7
#include "atom/gdata-link.h"
Packit 4b6dd7
#include "atom/gdata-author.h"
Packit 4b6dd7
Packit 4b6dd7
static void gdata_entry_constructed (GObject *object);
Packit 4b6dd7
static void gdata_entry_dispose (GObject *object);
Packit 4b6dd7
static void gdata_entry_finalize (GObject *object);
Packit 4b6dd7
static void gdata_entry_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static void gdata_entry_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
Packit 4b6dd7
static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
Packit 4b6dd7
static gboolean post_parse_xml (GDataParsable *parsable, gpointer user_data, GError **error);
Packit 4b6dd7
static void pre_get_xml (GDataParsable *parsable, GString *xml_string);
Packit 4b6dd7
static void get_xml (GDataParsable *parsable, GString *xml_string);
Packit 4b6dd7
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
Packit 4b6dd7
static gchar *get_entry_uri (const gchar *id) G_GNUC_WARN_UNUSED_RESULT;
Packit 4b6dd7
static gboolean parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error);
Packit 4b6dd7
static void get_json (GDataParsable *parsable, JsonBuilder *builder);
Packit 4b6dd7
Packit 4b6dd7
struct _GDataEntryPrivate {
Packit 4b6dd7
	gchar *title;
Packit 4b6dd7
	gchar *summary;
Packit 4b6dd7
	gchar *id;
Packit 4b6dd7
	gchar *etag;
Packit 4b6dd7
	gint64 updated;
Packit 4b6dd7
	gint64 published;
Packit 4b6dd7
	GList *categories; /* GDataCategory */
Packit 4b6dd7
	gchar *content;
Packit 4b6dd7
	gboolean content_is_uri;
Packit 4b6dd7
	GList *links; /* GDataLink */
Packit 4b6dd7
	GList *authors; /* GDataAuthor */
Packit 4b6dd7
	gchar *rights;
Packit 4b6dd7
Packit 4b6dd7
	/* Batch processing data */
Packit 4b6dd7
	GDataBatchOperationType batch_operation_type;
Packit 4b6dd7
	guint batch_id;
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
enum {
Packit 4b6dd7
	PROP_TITLE = 1,
Packit 4b6dd7
	PROP_SUMMARY,
Packit 4b6dd7
	PROP_ETAG,
Packit 4b6dd7
	PROP_ID,
Packit 4b6dd7
	PROP_UPDATED,
Packit 4b6dd7
	PROP_PUBLISHED,
Packit 4b6dd7
	PROP_CONTENT,
Packit 4b6dd7
	PROP_IS_INSERTED,
Packit 4b6dd7
	PROP_RIGHTS,
Packit 4b6dd7
	PROP_CONTENT_URI
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
G_DEFINE_TYPE (GDataEntry, gdata_entry, GDATA_TYPE_PARSABLE)
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_entry_class_init (GDataEntryClass *klass)
Packit 4b6dd7
{
Packit 4b6dd7
	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
Packit 4b6dd7
	GDataParsableClass *parsable_class = GDATA_PARSABLE_CLASS (klass);
Packit 4b6dd7
Packit 4b6dd7
	g_type_class_add_private (klass, sizeof (GDataEntryPrivate));
Packit 4b6dd7
Packit 4b6dd7
	gobject_class->constructed = gdata_entry_constructed;
Packit 4b6dd7
	gobject_class->get_property = gdata_entry_get_property;
Packit 4b6dd7
	gobject_class->set_property = gdata_entry_set_property;
Packit 4b6dd7
	gobject_class->dispose = gdata_entry_dispose;
Packit 4b6dd7
	gobject_class->finalize = gdata_entry_finalize;
Packit 4b6dd7
Packit 4b6dd7
	parsable_class->pre_parse_xml = pre_parse_xml;
Packit 4b6dd7
	parsable_class->parse_xml = parse_xml;
Packit 4b6dd7
	parsable_class->post_parse_xml = post_parse_xml;
Packit 4b6dd7
	parsable_class->pre_get_xml = pre_get_xml;
Packit 4b6dd7
	parsable_class->get_xml = get_xml;
Packit 4b6dd7
	parsable_class->get_namespaces = get_namespaces;
Packit 4b6dd7
	parsable_class->element_name = "entry";
Packit 4b6dd7
Packit 4b6dd7
	parsable_class->parse_json = parse_json;
Packit 4b6dd7
	parsable_class->get_json = get_json;
Packit 4b6dd7
Packit 4b6dd7
	klass->get_entry_uri = get_entry_uri;
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataEntry:title:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A human-readable title for the entry.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the 
Packit 4b6dd7
	 * url="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.title">Atom specification</ulink>.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_TITLE,
Packit 4b6dd7
	                                 g_param_spec_string ("title",
Packit 4b6dd7
	                                                      "Title", "A human-readable title for the entry.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataEntry:summary:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A short summary, abstract, or excerpt of the entry.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the 
Packit 4b6dd7
	 * url="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.summary">Atom specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.4.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_SUMMARY,
Packit 4b6dd7
	                                 g_param_spec_string ("summary",
Packit 4b6dd7
	                                                      "Summary", "A short summary, abstract, or excerpt of the entry.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataEntry:id:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A permanent, universally unique identifier for the entry, in IRI form. This is %NULL for new entries (i.e. ones which haven't yet been
Packit 4b6dd7
	 * inserted on the server, created with gdata_entry_new()), and a non-empty IRI string for all other entries.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the <ulink type="http" url="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.id">
Packit 4b6dd7
	 * Atom specification</ulink>.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_ID,
Packit 4b6dd7
	                                 g_param_spec_string ("id",
Packit 4b6dd7
	                                                      "ID", "A permanent, universally unique identifier for the entry, in IRI form.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataEntry:etag:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * An identifier for a particular version of the entry. This changes every time the entry on the server changes, and can be used
Packit 4b6dd7
	 * for conditional retrieval and locking.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/reference.html#ResourceVersioning">
Packit 4b6dd7
	 * GData specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.2.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_ETAG,
Packit 4b6dd7
	                                 g_param_spec_string ("etag",
Packit 4b6dd7
	                                                      "ETag", "An identifier for a particular version of the entry.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataEntry:updated:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The date and time when the entry was most recently updated significantly.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the 
Packit 4b6dd7
	 * url="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.updated">Atom specification</ulink>.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_UPDATED,
Packit 4b6dd7
	                                 g_param_spec_int64 ("updated",
Packit 4b6dd7
	                                                     "Updated", "The date and time when the entry was most recently updated significantly.",
Packit 4b6dd7
	                                                     -1, G_MAXINT64, -1,
Packit 4b6dd7
	                                                     G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataEntry:published:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The date and time the entry was first published or made available.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the 
Packit 4b6dd7
	 * url="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.published">Atom specification</ulink>.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_PUBLISHED,
Packit 4b6dd7
	                                 g_param_spec_int64 ("published",
Packit 4b6dd7
	                                                     "Published", "The date and time the entry was first published or made available.",
Packit 4b6dd7
	                                                     -1, G_MAXINT64, -1,
Packit 4b6dd7
	                                                     G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataEntry:content:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The content of the entry. This is mutually exclusive with #GDataEntry:content.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the 
Packit 4b6dd7
	 * url="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.content">Atom specification</ulink>.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_CONTENT,
Packit 4b6dd7
	                                 g_param_spec_string ("content",
Packit 4b6dd7
	                                                      "Content", "The content of the entry.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataEntry:content-uri:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A URI pointing to the location of the content of the entry. This is mutually exclusive with #GDataEntry:content.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the
Packit 4b6dd7
	 * <ulink type="http" url="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.content">Atom specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_CONTENT_URI,
Packit 4b6dd7
	                                 g_param_spec_string ("content-uri",
Packit 4b6dd7
	                                                      "Content URI", "A URI pointing to the location of the content of the entry.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataEntry:is-inserted:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Whether the entry has been inserted on the server. This is %FALSE for entries which have just been created using gdata_entry_new() and
Packit 4b6dd7
	 * %TRUE for entries returned from the server by queries. It is set to %TRUE when an entry is inserted using gdata_service_insert_entry().
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_IS_INSERTED,
Packit 4b6dd7
	                                 g_param_spec_boolean ("is-inserted",
Packit 4b6dd7
	                                                       "Inserted?", "Whether the entry has been inserted on the server.",
Packit 4b6dd7
	                                                       FALSE,
Packit 4b6dd7
	                                                       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataEntry:rights:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The ownership rights pertaining to the entry.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the 
Packit 4b6dd7
	 * url="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.rights">Atom specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.5.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_RIGHTS,
Packit 4b6dd7
	                                 g_param_spec_string ("rights",
Packit 4b6dd7
	                                                      "Rights", "The ownership rights pertaining to the entry.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_entry_init (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_ENTRY, GDataEntryPrivate);
Packit 4b6dd7
	self->priv->updated = -1;
Packit 4b6dd7
	self->priv->published = -1;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_entry_constructed (GObject *object)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataEntryClass *klass = GDATA_ENTRY_GET_CLASS (object);
Packit 4b6dd7
	GObjectClass *parent_class = G_OBJECT_CLASS (gdata_entry_parent_class);
Packit 4b6dd7
Packit 4b6dd7
	/* This can't be done in *_init() because the class properties haven't been properly set then */
Packit 4b6dd7
	if (klass->kind_term != NULL) {
Packit 4b6dd7
		/* Ensure we have the correct category/kind */
Packit 4b6dd7
		GDataCategory *category = gdata_category_new (klass->kind_term, "http://schemas.google.com/g/2005#kind", NULL);
Packit 4b6dd7
		gdata_entry_add_category (GDATA_ENTRY (object), category);
Packit 4b6dd7
		g_object_unref (category);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	if (parent_class->constructed != NULL)
Packit 4b6dd7
		parent_class->constructed (object);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_entry_dispose (GObject *object)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataEntryPrivate *priv = GDATA_ENTRY (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	if (priv->categories != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->categories, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->categories);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->categories = NULL;
Packit 4b6dd7
Packit 4b6dd7
	if (priv->links != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->links, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->links);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->links = NULL;
Packit 4b6dd7
Packit 4b6dd7
	if (priv->authors != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->authors, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->authors);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->authors = NULL;
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	G_OBJECT_CLASS (gdata_entry_parent_class)->dispose (object);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_entry_finalize (GObject *object)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataEntryPrivate *priv = GDATA_ENTRY (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_free (priv->title);
Packit 4b6dd7
	g_free (priv->summary);
Packit 4b6dd7
	g_free (priv->id);
Packit 4b6dd7
	g_free (priv->etag);
Packit 4b6dd7
	g_free (priv->rights);
Packit 4b6dd7
	g_free (priv->content);
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	G_OBJECT_CLASS (gdata_entry_parent_class)->finalize (object);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_entry_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataEntryPrivate *priv = GDATA_ENTRY (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_TITLE:
Packit 4b6dd7
			g_value_set_string (value, priv->title);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SUMMARY:
Packit 4b6dd7
			g_value_set_string (value, priv->summary);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_ID:
Packit 4b6dd7
			g_value_set_string (value, priv->id);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_ETAG:
Packit 4b6dd7
			g_value_set_string (value, priv->etag);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_UPDATED:
Packit 4b6dd7
			g_value_set_int64 (value, priv->updated);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_PUBLISHED:
Packit 4b6dd7
			g_value_set_int64 (value, priv->published);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_CONTENT:
Packit 4b6dd7
			g_value_set_string (value, (priv->content_is_uri == FALSE) ? priv->content : NULL);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_CONTENT_URI:
Packit 4b6dd7
			g_value_set_string (value, (priv->content_is_uri == TRUE) ? priv->content : NULL);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_IS_INSERTED:
Packit 4b6dd7
			g_value_set_boolean (value, gdata_entry_is_inserted (GDATA_ENTRY (object)));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RIGHTS:
Packit 4b6dd7
			g_value_set_string (value, priv->rights);
Packit 4b6dd7
			break;
Packit 4b6dd7
		default:
Packit 4b6dd7
			/* We don't have any other property... */
Packit 4b6dd7
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
Packit 4b6dd7
			break;
Packit 4b6dd7
	}
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_entry_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataEntry *self = GDATA_ENTRY (object);
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_ID:
Packit 4b6dd7
			/* Construct only */
Packit 4b6dd7
			self->priv->id = g_value_dup_string (value);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_ETAG:
Packit 4b6dd7
			/* Construct only */
Packit 4b6dd7
			self->priv->etag = g_value_dup_string (value);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_TITLE:
Packit 4b6dd7
			gdata_entry_set_title (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SUMMARY:
Packit 4b6dd7
			gdata_entry_set_summary (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_CONTENT:
Packit 4b6dd7
			gdata_entry_set_content (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_CONTENT_URI:
Packit 4b6dd7
			gdata_entry_set_content_uri (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RIGHTS:
Packit 4b6dd7
			gdata_entry_set_rights (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		default:
Packit 4b6dd7
			/* We don't have any other property... */
Packit 4b6dd7
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
Packit 4b6dd7
			break;
Packit 4b6dd7
	}
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static gboolean
Packit 4b6dd7
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
Packit 4b6dd7
{
Packit 4b6dd7
	/* Extract the ETag */
Packit 4b6dd7
	GDATA_ENTRY (parsable)->priv->etag = (gchar*) xmlGetProp (root_node, (xmlChar*) "etag");
Packit 4b6dd7
Packit 4b6dd7
	return TRUE;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static gboolean
Packit 4b6dd7
parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
Packit 4b6dd7
{
Packit 4b6dd7
	gboolean success;
Packit 4b6dd7
	GDataEntryPrivate *priv = GDATA_ENTRY (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	if (gdata_parser_is_namespace (node, "http://www.w3.org/2005/Atom") == TRUE) {
Packit 4b6dd7
		if (gdata_parser_string_from_element (node, "title", P_DEFAULT | P_NO_DUPES, &(priv->title), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "id", P_REQUIRED | P_NON_EMPTY | P_NO_DUPES, &(priv->id), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "summary", P_NONE, &(priv->summary), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "rights", P_NONE, &(priv->rights), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_int64_time_from_element (node, "updated", P_REQUIRED | P_NO_DUPES, &(priv->updated), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_int64_time_from_element (node, "published", P_REQUIRED | P_NO_DUPES, &(priv->published), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "category", P_REQUIRED, GDATA_TYPE_CATEGORY,
Packit 4b6dd7
		                                             gdata_entry_add_category, parsable, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "link", P_REQUIRED, GDATA_TYPE_LINK,
Packit 4b6dd7
		                                             gdata_entry_add_link, parsable, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "author", P_REQUIRED, GDATA_TYPE_AUTHOR,
Packit 4b6dd7
		                                             gdata_entry_add_author, parsable, &success, error) == TRUE) {
Packit 4b6dd7
			return success;
Packit 4b6dd7
		} else if (xmlStrcmp (node->name, (xmlChar*) "content") == 0) {
Packit 4b6dd7
			/* atom:content */
Packit 4b6dd7
			priv->content = (gchar*) xmlGetProp (node, (xmlChar*) "src");
Packit 4b6dd7
			priv->content_is_uri = TRUE;
Packit 4b6dd7
Packit 4b6dd7
			if (priv->content == NULL) {
Packit 4b6dd7
				priv->content = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
Packit 4b6dd7
				priv->content_is_uri = FALSE;
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			return TRUE;
Packit 4b6dd7
		}
Packit 4b6dd7
	} else if (gdata_parser_is_namespace (node, "http://schemas.google.com/gdata/batch") == TRUE) {
Packit 4b6dd7
		if (xmlStrcmp (node->name, (xmlChar*) "id") == 0 ||
Packit 4b6dd7
		    xmlStrcmp (node->name, (xmlChar*) "status") == 0 ||
Packit 4b6dd7
		    xmlStrcmp (node->name, (xmlChar*) "operation") == 0) {
Packit 4b6dd7
			/* Ignore batch operation elements; they're handled in GDataBatchFeed */
Packit 4b6dd7
			return TRUE;
Packit 4b6dd7
		}
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return GDATA_PARSABLE_CLASS (gdata_entry_parent_class)->parse_xml (parsable, doc, node, user_data, error);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static gboolean
Packit 4b6dd7
post_parse_xml (GDataParsable *parsable, gpointer user_data, GError **error)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataEntryPrivate *priv = GDATA_ENTRY (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	/* Check for missing required elements */
Packit 4b6dd7
	/* Can't uncomment it, as things like access rules break the Atom standard */
Packit 4b6dd7
	/*if (priv->title == NULL)
Packit 4b6dd7
		return gdata_parser_error_required_element_missing ("title", "entry", error);
Packit 4b6dd7
	if (priv->id == NULL)
Packit 4b6dd7
		return gdata_parser_error_required_element_missing ("id", "entry", error);
Packit 4b6dd7
	if (priv->updated.tv_sec == 0 && priv->updated.tv_usec == 0)
Packit 4b6dd7
		return gdata_parser_error_required_element_missing ("updated", "entry", error);*/
Packit 4b6dd7
Packit 4b6dd7
	/* Reverse our lists of stuff */
Packit 4b6dd7
	priv->categories = g_list_reverse (priv->categories);
Packit 4b6dd7
	priv->links = g_list_reverse (priv->links);
Packit 4b6dd7
	priv->authors = g_list_reverse (priv->authors);
Packit 4b6dd7
Packit 4b6dd7
	return TRUE;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
pre_get_xml (GDataParsable *parsable, GString *xml_string)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataEntryPrivate *priv = GDATA_ENTRY (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	/* Add the entry's ETag, if available */
Packit 4b6dd7
	if (gdata_entry_get_etag (GDATA_ENTRY (parsable)) != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, " gd:etag='", priv->etag, "'");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_xml (GDataParsable *parsable, GString *xml_string)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataEntryPrivate *priv = GDATA_ENTRY (parsable)->priv;
Packit 4b6dd7
	GList *categories, *links, *authors;
Packit 4b6dd7
Packit 4b6dd7
	gdata_parser_string_append_escaped (xml_string, "<title type='text'>", priv->title, "</title>");
Packit 4b6dd7
Packit 4b6dd7
	if (priv->id != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<id>", priv->id, "</id>");
Packit 4b6dd7
Packit 4b6dd7
	if (priv->updated != -1) {
Packit 4b6dd7
		gchar *updated = gdata_parser_int64_to_iso8601 (priv->updated);
Packit 4b6dd7
		g_string_append_printf (xml_string, "<updated>%s</updated>", updated);
Packit 4b6dd7
		g_free (updated);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	if (priv->published != -1) {
Packit 4b6dd7
		gchar *published = gdata_parser_int64_to_iso8601 (priv->published);
Packit 4b6dd7
		g_string_append_printf (xml_string, "<published>%s</published>", published);
Packit 4b6dd7
		g_free (published);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	if (priv->summary != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<summary type='text'>", priv->summary, "</summary>");
Packit 4b6dd7
Packit 4b6dd7
	if (priv->rights != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<rights>", priv->rights, "</rights>");
Packit 4b6dd7
Packit 4b6dd7
	if (priv->content != NULL) {
Packit 4b6dd7
		if (priv->content_is_uri == TRUE)
Packit 4b6dd7
			gdata_parser_string_append_escaped (xml_string, "<content type='text/plain' src='", priv->content, "'/>");
Packit 4b6dd7
		else
Packit 4b6dd7
			gdata_parser_string_append_escaped (xml_string, "<content type='text'>", priv->content, "</content>");
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	for (categories = priv->categories; categories != NULL; categories = categories->next)
Packit 4b6dd7
		_gdata_parsable_get_xml (GDATA_PARSABLE (categories->data), xml_string, FALSE);
Packit 4b6dd7
Packit 4b6dd7
	for (links = priv->links; links != NULL; links = links->next)
Packit 4b6dd7
		_gdata_parsable_get_xml (GDATA_PARSABLE (links->data), xml_string, FALSE);
Packit 4b6dd7
Packit 4b6dd7
	for (authors = priv->authors; authors != NULL; authors = authors->next)
Packit 4b6dd7
		_gdata_parsable_get_xml (GDATA_PARSABLE (authors->data), xml_string, FALSE);
Packit 4b6dd7
Packit 4b6dd7
	/* Batch operation data */
Packit 4b6dd7
	if (priv->batch_id != 0) {
Packit 4b6dd7
		const gchar *batch_op;
Packit 4b6dd7
Packit 4b6dd7
		switch (priv->batch_operation_type) {
Packit 4b6dd7
			case GDATA_BATCH_OPERATION_QUERY:
Packit 4b6dd7
				batch_op = "query";
Packit 4b6dd7
				break;
Packit 4b6dd7
			case GDATA_BATCH_OPERATION_INSERTION:
Packit 4b6dd7
				batch_op = "insert";
Packit 4b6dd7
				break;
Packit 4b6dd7
			case GDATA_BATCH_OPERATION_UPDATE:
Packit 4b6dd7
				batch_op = "update";
Packit 4b6dd7
				break;
Packit 4b6dd7
			case GDATA_BATCH_OPERATION_DELETION:
Packit 4b6dd7
				batch_op = "delete";
Packit 4b6dd7
				break;
Packit 4b6dd7
			default:
Packit 4b6dd7
				g_assert_not_reached ();
Packit 4b6dd7
				break;
Packit 4b6dd7
		}
Packit 4b6dd7
Packit 4b6dd7
		g_string_append_printf (xml_string, "<batch:id>%u</batch:id><batch:operation type='%s'/>", priv->batch_id, batch_op);
Packit 4b6dd7
	}
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
Packit 4b6dd7
{
Packit 4b6dd7
	g_hash_table_insert (namespaces, (gchar*) "gd", (gchar*) "http://schemas.google.com/g/2005");
Packit 4b6dd7
Packit 4b6dd7
	if (GDATA_ENTRY (parsable)->priv->batch_id != 0)
Packit 4b6dd7
		g_hash_table_insert (namespaces, (gchar*) "batch", (gchar*) "http://schemas.google.com/gdata/batch");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static gchar *
Packit 4b6dd7
get_entry_uri (const gchar *id)
Packit 4b6dd7
{
Packit 4b6dd7
	/* We assume the entry ID is also its entry URI; subclasses can override this
Packit 4b6dd7
	 * if the service they implement has a convoluted API */
Packit 4b6dd7
	return g_strdup (id);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static gboolean
Packit 4b6dd7
parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error)
Packit 4b6dd7
{
Packit 4b6dd7
	gboolean success;
Packit 4b6dd7
	GDataEntryPrivate *priv = GDATA_ENTRY (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	if (gdata_parser_string_from_json_member (reader, "title", P_DEFAULT | P_NO_DUPES, &(priv->title), &success, error) == TRUE ||
Packit 4b6dd7
	    gdata_parser_string_from_json_member (reader, "id", P_NON_EMPTY | P_NO_DUPES, &(priv->id), &success, error) == TRUE ||
Packit 4b6dd7
	    gdata_parser_string_from_json_member (reader, "description", P_NONE, &(priv->summary), &success, error) == TRUE ||
Packit 4b6dd7
	    gdata_parser_int64_time_from_json_member (reader, "updated", P_REQUIRED | P_NO_DUPES, &(priv->updated), &success, error) == TRUE ||
Packit 4b6dd7
	    gdata_parser_string_from_json_member (reader, "etag", P_NON_EMPTY | P_NO_DUPES, &(priv->etag), &success, error) == TRUE) {
Packit 4b6dd7
		return success;
Packit 4b6dd7
	} else if (g_strcmp0 (json_reader_get_member_name (reader), "selfLink") == 0) {
Packit 4b6dd7
		GDataLink *_link;
Packit 4b6dd7
		const gchar *uri;
Packit 4b6dd7
Packit 4b6dd7
		/* Empty URI? */
Packit 4b6dd7
		uri = json_reader_get_string_value (reader);
Packit 4b6dd7
		if (uri == NULL || *uri == '\0') {
Packit 4b6dd7
			return gdata_parser_error_required_json_content_missing (reader, error);
Packit 4b6dd7
		}
Packit 4b6dd7
Packit 4b6dd7
		_link = gdata_link_new (uri, GDATA_LINK_SELF);
Packit 4b6dd7
		gdata_entry_add_link (GDATA_ENTRY (parsable), _link);
Packit 4b6dd7
		g_object_unref (_link);
Packit 4b6dd7
Packit 4b6dd7
		return TRUE;
Packit 4b6dd7
	} else if (g_strcmp0 (json_reader_get_member_name (reader), "kind") == 0) {
Packit 4b6dd7
		GDataCategory *category;
Packit 4b6dd7
		const gchar *kind;
Packit 4b6dd7
Packit 4b6dd7
		/* Empty kind? */
Packit 4b6dd7
		kind = json_reader_get_string_value (reader);
Packit 4b6dd7
		if (kind == NULL || *kind == '\0') {
Packit 4b6dd7
			return gdata_parser_error_required_json_content_missing (reader, error);
Packit 4b6dd7
		}
Packit 4b6dd7
Packit 4b6dd7
		category = gdata_category_new (kind, "http://schemas.google.com/g/2005#kind", NULL);
Packit 4b6dd7
		gdata_entry_add_category (GDATA_ENTRY (parsable), category);
Packit 4b6dd7
		g_object_unref (category);
Packit 4b6dd7
Packit 4b6dd7
		return TRUE;
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return GDATA_PARSABLE_CLASS (gdata_entry_parent_class)->parse_json (parsable, reader, user_data, error);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_json (GDataParsable *parsable, JsonBuilder *builder)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataEntryPrivate *priv = GDATA_ENTRY (parsable)->priv;
Packit 4b6dd7
	GList *i;
Packit 4b6dd7
	GDataLink *_link;
Packit 4b6dd7
Packit 4b6dd7
	json_builder_set_member_name (builder, "title");
Packit 4b6dd7
	json_builder_add_string_value (builder, priv->title);
Packit 4b6dd7
Packit 4b6dd7
	if (priv->id != NULL) {
Packit 4b6dd7
		json_builder_set_member_name (builder, "id");
Packit 4b6dd7
		json_builder_add_string_value (builder, priv->id);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	if (priv->summary != NULL) {
Packit 4b6dd7
		json_builder_set_member_name (builder, "description");
Packit 4b6dd7
		json_builder_add_string_value (builder, priv->summary);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	if (priv->updated != -1) {
Packit 4b6dd7
		gchar *updated = gdata_parser_int64_to_iso8601 (priv->updated);
Packit 4b6dd7
		json_builder_set_member_name (builder, "updated");
Packit 4b6dd7
		json_builder_add_string_value (builder, updated);
Packit 4b6dd7
		g_free (updated);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* If we have a "kind" category, add that. */
Packit 4b6dd7
	for (i = priv->categories; i != NULL; i = i->next) {
Packit 4b6dd7
		GDataCategory *category = GDATA_CATEGORY (i->data);
Packit 4b6dd7
Packit 4b6dd7
		if (g_strcmp0 (gdata_category_get_scheme (category), "http://schemas.google.com/g/2005#kind") == 0) {
Packit 4b6dd7
			json_builder_set_member_name (builder, "kind");
Packit 4b6dd7
			json_builder_add_string_value (builder, gdata_category_get_term (category));
Packit 4b6dd7
		}
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* Add the ETag, if available. */
Packit 4b6dd7
	if (gdata_entry_get_etag (GDATA_ENTRY (parsable)) != NULL) {
Packit 4b6dd7
		json_builder_set_member_name (builder, "etag");
Packit 4b6dd7
		json_builder_add_string_value (builder, priv->etag);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* Add the self-link. */
Packit 4b6dd7
	_link = gdata_entry_look_up_link (GDATA_ENTRY (parsable), GDATA_LINK_SELF);
Packit 4b6dd7
	if (_link != NULL) {
Packit 4b6dd7
		json_builder_set_member_name (builder, "selfLink");
Packit 4b6dd7
		json_builder_add_string_value (builder, gdata_link_get_uri (_link));
Packit 4b6dd7
	}
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_new:
Packit 4b6dd7
 * @id: (allow-none): the entry's ID, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Creates a new #GDataEntry with the given ID and default properties.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a new #GDataEntry; unref with g_object_unref()
Packit 4b6dd7
 */
Packit 4b6dd7
GDataEntry *
Packit 4b6dd7
gdata_entry_new (const gchar *id)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataEntry *entry = GDATA_ENTRY (g_object_new (GDATA_TYPE_ENTRY, "id", id, NULL));
Packit 4b6dd7
Packit 4b6dd7
	/* Set this here, as it interferes with P_NO_DUPES when parsing */
Packit 4b6dd7
	entry->priv->title = g_strdup (""); /* title can't be NULL */
Packit 4b6dd7
Packit 4b6dd7
	return entry;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_get_title:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns the title of the entry. This will never be %NULL, but may be an empty string.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the entry's title
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_entry_get_title (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
Packit 4b6dd7
	return self->priv->title;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_set_title:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @title: (allow-none): the new entry title, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the title of the entry.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_entry_set_title (GDataEntry *self, const gchar *title)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->title);
Packit 4b6dd7
	self->priv->title = g_strdup (title);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "title");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_get_summary:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns the summary of the entry.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the entry's summary, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_entry_get_summary (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
Packit 4b6dd7
	return self->priv->summary;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_set_summary:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @summary: (allow-none): the new entry summary, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the summary of the entry.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_entry_set_summary (GDataEntry *self, const gchar *summary)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->summary);
Packit 4b6dd7
	self->priv->summary = g_strdup (summary);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "summary");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_get_id:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns the URN ID of the entry; a unique and permanent identifier for the object the entry represents.
Packit 4b6dd7
 *
Packit 4b6dd7
 * The ID may be %NULL if and only if the #GDataEntry has been newly created, and hasn't yet been inserted on the server.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (nullable): the entry's ID, or %NULL
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_entry_get_id (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	gchar *id;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
Packit 4b6dd7
Packit 4b6dd7
	/* We have to get the actual property since GDataDocumentsEntry overrides it. We then store it in our own ID field so that we can
Packit 4b6dd7
	 * free it later on. */
Packit 4b6dd7
	g_object_get (G_OBJECT (self), "id", &id, NULL);
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->id);
Packit 4b6dd7
	self->priv->id = id;
Packit 4b6dd7
Packit 4b6dd7
	return id;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_get_etag:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns the ETag of the entry; a unique identifier for each version of the entry. For more information, see the
Packit 4b6dd7
 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/reference.html#ResourceVersioning">online documentation</ulink>.
Packit 4b6dd7
 *
Packit 4b6dd7
 * The ETag will never be empty; it's either %NULL or a valid ETag.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (nullable): the entry's ETag, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_entry_get_etag (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	gchar *etag;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
Packit 4b6dd7
Packit 4b6dd7
	/* We have to check if the property's set since GDataAccessRule overrides it and sets it to always be NULL (since ACL entries don't support
Packit 4b6dd7
	 * ETags, for some reason). */
Packit 4b6dd7
	g_object_get (G_OBJECT (self), "etag", &etag, NULL);
Packit 4b6dd7
	if (etag != NULL) {
Packit 4b6dd7
		g_free (etag);
Packit 4b6dd7
		return self->priv->etag;
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/*
Packit 4b6dd7
 * _gdata_entry_set_etag:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @etag: the new ETag value
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the value of the #GDataEntry:etag property to @etag.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.17.2
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
_gdata_entry_set_etag (GDataEntry *self, const gchar *etag)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->etag);
Packit 4b6dd7
	self->priv->etag = g_strdup (etag);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_get_updated:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the time the entry was last updated.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the UNIX timestamp for the last update of the entry
Packit 4b6dd7
 */
Packit 4b6dd7
gint64
Packit 4b6dd7
gdata_entry_get_updated (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), -1);
Packit 4b6dd7
	return self->priv->updated;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/*
Packit 4b6dd7
 * _gdata_entry_set_updated:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @updated: the new updated value
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the value of the #GDataEntry:updated property to @updated.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.6.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
_gdata_entry_set_updated (GDataEntry *self, gint64 updated)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
	self->priv->updated = updated;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/*
Packit 4b6dd7
 * _gdata_entry_set_published:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @updated: the new published value
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the value of the #GDataEntry:published property to @published.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.17.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
_gdata_entry_set_published (GDataEntry *self, gint64 published)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
	self->priv->published = published;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/*
Packit 4b6dd7
 * _gdata_entry_set_id:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @id: (nullable): the new ID
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the value of the #GDataEntry:id property to @id.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.17.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
_gdata_entry_set_id (GDataEntry *self, const gchar *id)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->id);
Packit 4b6dd7
	self->priv->id = g_strdup (id);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_get_published:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the time the entry was originally published.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the UNIX timestamp for the original publish time of the entry
Packit 4b6dd7
 */
Packit 4b6dd7
gint64
Packit 4b6dd7
gdata_entry_get_published (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), -1);
Packit 4b6dd7
	return self->priv->published;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_add_category:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @category: a #GDataCategory to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds @category to the list of categories in the given #GDataEntry, and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate categories will not be added to the list.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_entry_add_category (GDataEntry *self, GDataCategory *category)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CATEGORY (category));
Packit 4b6dd7
Packit 4b6dd7
	/* Check to see if it's a kind category and if it matches the entry's predetermined kind */
Packit 4b6dd7
	if (g_strcmp0 (gdata_category_get_scheme (category), "http://schemas.google.com/g/2005#kind") == 0) {
Packit 4b6dd7
		GDataEntryClass *klass = GDATA_ENTRY_GET_CLASS (self);
Packit 4b6dd7
		GList *element;
Packit 4b6dd7
Packit 4b6dd7
		if (klass->kind_term != NULL && g_strcmp0 (gdata_category_get_term (category), klass->kind_term) != 0) {
Packit 4b6dd7
			/* This used to make sense as a warning, but the new
Packit 4b6dd7
			 * JSON APIs use a lot of different kinds for very
Packit 4b6dd7
			 * highly related JSON schemas, which libgdata uses a
Packit 4b6dd7
			 * single class for…so it makes less sense now. */
Packit 4b6dd7
			g_debug ("Adding a kind category term, '%s', to an entry of kind '%s'.",
Packit 4b6dd7
			         gdata_category_get_term (category), klass->kind_term);
Packit 4b6dd7
		}
Packit 4b6dd7
Packit 4b6dd7
		/* If it is a kind category, remove the entry’s existing kind category to allow the new one
Packit 4b6dd7
		 * to be added. This is necessary because the existing category was set in
Packit 4b6dd7
		 * gdata_entry_constructed() and might not contain all the attributes of the actual XML
Packit 4b6dd7
		 * category.
Packit 4b6dd7
		 *
Packit 4b6dd7
		 * See: https://bugzilla.gnome.org/show_bug.cgi?id=707477 */
Packit 4b6dd7
		element = g_list_find_custom (self->priv->categories, category, (GCompareFunc) gdata_comparable_compare);
Packit 4b6dd7
		if (element != NULL) {
Packit 4b6dd7
			g_assert (GDATA_IS_CATEGORY (element->data));
Packit 4b6dd7
			g_object_unref (element->data);
Packit 4b6dd7
			self->priv->categories = g_list_delete_link (self->priv->categories, element);
Packit 4b6dd7
		}
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* Add the category if we don't already have it */
Packit 4b6dd7
	if (g_list_find_custom (self->priv->categories, category, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->categories = g_list_prepend (self->priv->categories, g_object_ref (category));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_get_categories:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the #GDataCategorys containing this entry.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.Category) (transfer none): a #GList of #GDataCategorys
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_entry_get_categories (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
Packit 4b6dd7
	return self->priv->categories;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_get_authors:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the #GDataAuthors for this entry.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.Author) (transfer none): a #GList of #GDataAuthors
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_entry_get_authors (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
Packit 4b6dd7
	return self->priv->authors;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_get_content:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns the textual content in this entry. If the content in this entry is pointed to by a URI, %NULL will be returned; the content URI will be
Packit 4b6dd7
 * returned by gdata_entry_get_content_uri().
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the entry's content, or %NULL
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_entry_get_content (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
Packit 4b6dd7
	return (self->priv->content_is_uri == FALSE) ? self->priv->content : NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_set_content:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @content: (allow-none): the new content for the entry, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the entry's content to @content. This unsets #GDataEntry:content-uri.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_entry_set_content (GDataEntry *self, const gchar *content)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->content);
Packit 4b6dd7
	self->priv->content = g_strdup (content);
Packit 4b6dd7
	self->priv->content_is_uri = FALSE;
Packit 4b6dd7
Packit 4b6dd7
	g_object_freeze_notify (G_OBJECT (self));
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "content");
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "content-uri");
Packit 4b6dd7
	g_object_thaw_notify (G_OBJECT (self));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_get_content_uri:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns a URI pointing to the content of this entry. If the content in this entry is stored directly, %NULL will be returned; the content will be
Packit 4b6dd7
 * returned by gdata_entry_get_content().
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a URI pointing to the entry's content, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_entry_get_content_uri (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
Packit 4b6dd7
	return (self->priv->content_is_uri == TRUE) ? self->priv->content : NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_set_content_uri:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @content_uri: (allow-none): the new URI pointing to the content for the entry, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the URI pointing to the entry's content to @content. This unsets #GDataEntry:content.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_entry_set_content_uri (GDataEntry *self, const gchar *content_uri)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->content);
Packit 4b6dd7
	self->priv->content = g_strdup (content_uri);
Packit 4b6dd7
	self->priv->content_is_uri = TRUE;
Packit 4b6dd7
Packit 4b6dd7
	g_object_freeze_notify (G_OBJECT (self));
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "content");
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "content-uri");
Packit 4b6dd7
	g_object_thaw_notify (G_OBJECT (self));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_add_link:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @_link: a #GDataLink to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds @_link to the list of links in the given #GDataEntry and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate links will not be added to the list.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_entry_add_link (GDataEntry *self, GDataLink *_link)
Packit 4b6dd7
{
Packit 4b6dd7
	/* TODO: More link API */
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_LINK (_link));
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->links, _link, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->links = g_list_prepend (self->priv->links, g_object_ref (_link));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_remove_link:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @_link: a #GDataLink to remove
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes @_link from the list of links in the given #GDataEntry and decrements its reference count (since the #GDataEntry held a reference to it
Packit 4b6dd7
 * while it was in the list).
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: %TRUE if @_link was found in the #GDataEntry and removed, %FALSE if it was not found
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.10.0
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_entry_remove_link (GDataEntry *self, GDataLink *_link)
Packit 4b6dd7
{
Packit 4b6dd7
	GList *i;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), FALSE);
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_LINK (_link), FALSE);
Packit 4b6dd7
Packit 4b6dd7
	i = g_list_find_custom (self->priv->links, _link, (GCompareFunc) gdata_comparable_compare);
Packit 4b6dd7
Packit 4b6dd7
	if (i == NULL) {
Packit 4b6dd7
		return FALSE;
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	self->priv->links = g_list_delete_link (self->priv->links, i);
Packit 4b6dd7
	g_object_unref (_link);
Packit 4b6dd7
Packit 4b6dd7
	return TRUE;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static gint
Packit 4b6dd7
link_compare_cb (const GDataLink *_link, const gchar *rel)
Packit 4b6dd7
{
Packit 4b6dd7
	return strcmp (gdata_link_get_relation_type ((GDataLink*) _link), rel);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_look_up_link:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @rel: the value of the <structfield>rel</structfield> attribute of the desired link
Packit 4b6dd7
 *
Packit 4b6dd7
 * Looks up a link by relation type from the list of links in the entry. If the link has one of the standard Atom relation types,
Packit 4b6dd7
 * use one of the defined @rel values, instead of a static string. e.g. %GDATA_LINK_EDIT or %GDATA_LINK_SELF.
Packit 4b6dd7
 *
Packit 4b6dd7
 * In the rare event of requiring a list of links with the same @rel value, use gdata_entry_look_up_links().
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer none): a #GDataLink, or %NULL if one was not found
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.1.1
Packit 4b6dd7
 */
Packit 4b6dd7
GDataLink *
Packit 4b6dd7
gdata_entry_look_up_link (GDataEntry *self, const gchar *rel)
Packit 4b6dd7
{
Packit 4b6dd7
	GList *element;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
Packit 4b6dd7
	g_return_val_if_fail (rel != NULL, NULL);
Packit 4b6dd7
Packit 4b6dd7
	element = g_list_find_custom (self->priv->links, rel, (GCompareFunc) link_compare_cb);
Packit 4b6dd7
	if (element == NULL)
Packit 4b6dd7
		return NULL;
Packit 4b6dd7
	return GDATA_LINK (element->data);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_look_up_links:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @rel: the value of the <structfield>rel</structfield> attribute of the desired links
Packit 4b6dd7
 *
Packit 4b6dd7
 * Looks up a list of links by relation type from the list of links in the entry. If the links have one of the standard Atom
Packit 4b6dd7
 * relation types, use one of the defined @rel values, instead of a static string. e.g. %GDATA_LINK_EDIT or %GDATA_LINK_SELF.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If you will only use the first link found, consider calling gdata_entry_look_up_link() instead.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.Link) (transfer container): a #GList of #GDataLinks, or %NULL if none were found; free the list with
Packit 4b6dd7
 * g_list_free()
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_entry_look_up_links (GDataEntry *self, const gchar *rel)
Packit 4b6dd7
{
Packit 4b6dd7
	GList *i, *results = NULL;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
Packit 4b6dd7
	g_return_val_if_fail (rel != NULL, NULL);
Packit 4b6dd7
Packit 4b6dd7
	for (i = self->priv->links; i != NULL; i = i->next) {
Packit 4b6dd7
		const gchar *relation_type = gdata_link_get_relation_type (((GDataLink*) i->data));
Packit 4b6dd7
		if (strcmp (relation_type, rel) == 0)
Packit 4b6dd7
			results = g_list_prepend (results, i->data);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return g_list_reverse (results);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_add_author:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @author: a #GDataAuthor to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds @author to the list of authors in the given #GDataEntry and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate authors will not be added to the list.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_entry_add_author (GDataEntry *self, GDataAuthor *author)
Packit 4b6dd7
{
Packit 4b6dd7
	/* TODO: More author API */
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_AUTHOR (author));
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->authors, author, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->authors = g_list_prepend (self->priv->authors, g_object_ref (author));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_is_inserted:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns whether the entry is marked as having been inserted on (uploaded to) the server already.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: %TRUE if the entry has been inserted already, %FALSE otherwise
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_entry_is_inserted (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), FALSE);
Packit 4b6dd7
Packit 4b6dd7
	if (self->priv->id != NULL || self->priv->updated != -1)
Packit 4b6dd7
		return TRUE;
Packit 4b6dd7
	return FALSE;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_get_rights:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns the rights pertaining to the entry, or %NULL if not set.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the entry's rights information
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.5.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_entry_get_rights (GDataEntry *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
Packit 4b6dd7
	return self->priv->rights;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_entry_set_rights:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @rights: (allow-none): the new rights, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the rights for this entry.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.5.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_entry_set_rights (GDataEntry *self, const gchar *rights)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->rights);
Packit 4b6dd7
	self->priv->rights = g_strdup (rights);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "rights");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/*
Packit 4b6dd7
 * _gdata_entry_set_batch_data:
Packit 4b6dd7
 * @self: a #GDataEntry
Packit 4b6dd7
 * @id: the batch operation ID
Packit 4b6dd7
 * @type: the type of batch operation being performed on the #GDataEntry
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the batch operation data needed when outputting the XML for a #GDataEntry to be put into a batch operation feed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.6.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
_gdata_entry_set_batch_data (GDataEntry *self, guint id, GDataBatchOperationType type)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_ENTRY (self));
Packit 4b6dd7
Packit 4b6dd7
	self->priv->batch_id = id;
Packit 4b6dd7
	self->priv->batch_operation_type = type;
Packit 4b6dd7
}