=?utf-8?q?=5Blibgdata=5D_Bug_588714_=E2=80=94_=3Cgd=3AquotaBytesUsed=3E_h?= =?utf-8?q?andling_in_GDataDocumentsEntry?=



commit 3ee77832b4dcfdb83a5e653760eeece34d68c045
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Apr 14 11:00:35 2012 +0100

    Bug 588714 â <gd:quotaBytesUsed> handling in GDataDocumentsEntry
    
    Add support for <gd:quotaBytesUsed> to GDataDocumentsEntry.
    
    API additions:
     â GDataDocumentsEntry:quota-used and gdata_documents_entry_get_quota_used()
    
    Closes: https://bugzilla.gnome.org/show_bug.cgi?id=588714

 docs/reference/gdata-sections.txt                |    1 +
 gdata/gdata.symbols                              |    1 +
 gdata/services/documents/gdata-documents-entry.c |   45 +++++++++++++++++++++-
 gdata/services/documents/gdata-documents-entry.h |    2 +
 4 files changed, 48 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index 0c49d6c..ea3f4ff 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -1563,6 +1563,7 @@ gdata_documents_entry_get_document_id
 gdata_documents_entry_get_edited
 gdata_documents_entry_get_last_modified_by
 gdata_documents_entry_get_last_viewed
+gdata_documents_entry_get_quota_used
 gdata_documents_entry_writers_can_invite
 gdata_documents_entry_set_writers_can_invite
 gdata_documents_entry_is_deleted
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index dceb4ad..f7f7b83 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -949,3 +949,4 @@ gdata_documents_upload_query_set_folder
 gdata_documents_document_new
 gdata_documents_upload_query_get_convert
 gdata_documents_upload_query_set_convert
+gdata_documents_entry_get_quota_used
diff --git a/gdata/services/documents/gdata-documents-entry.c b/gdata/services/documents/gdata-documents-entry.c
index 69f1178..bf0bc12 100644
--- a/gdata/services/documents/gdata-documents-entry.c
+++ b/gdata/services/documents/gdata-documents-entry.c
@@ -131,6 +131,7 @@ struct _GDataDocumentsEntryPrivate {
 	gboolean writers_can_invite;
 	gboolean is_deleted;
 	GDataAuthor *last_modified_by;
+	goffset quota_used; /* bytes */
 };
 
 enum {
@@ -142,6 +143,7 @@ enum {
 	PROP_WRITERS_CAN_INVITE,
 	PROP_ID,
 	PROP_RESOURCE_ID,
+	PROP_QUOTA_USED,
 };
 
 G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GDataDocumentsEntry, gdata_documents_entry, GDATA_TYPE_ENTRY,
@@ -276,6 +278,22 @@ gdata_documents_entry_class_init (GDataDocumentsEntryClass *klass)
 	                                                      GDATA_TYPE_AUTHOR,
 	                                                      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
+	/**
+	 * GDataDocumentsEntry:quota-used:
+	 *
+	 * The amount of user quota the document is occupying. Currently, only arbitrary files consume file space quota (whereas standard document
+	 * formats, such as #GDataDocumentsText, #GDataDocumentsSpreadsheet and #GDataDocumentsFolder don't). Measured in bytes.
+	 *
+	 * This property will be <code class="literal">0</code> for documents which aren't consuming any quota.
+	 *
+	 * Since: 0.13.0
+	 */
+	g_object_class_install_property (gobject_class, PROP_QUOTA_USED,
+	                                 g_param_spec_int64 ("quota-used",
+	                                                     "Quota used", "The amount of user quota the document is occupying.",
+	                                                     0, G_MAXINT64, 0,
+	                                                     G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
 	/* Override the ID property since the server returns two different forms of ID depending on how you form a query on an entry. These two forms
 	 * of ID are (for version 3 of the API):
 	 *  - Document ID: /feeds/id/[resource_id]
@@ -389,6 +407,9 @@ gdata_documents_entry_get_property (GObject *object, guint property_id, GValue *
 		case PROP_LAST_MODIFIED_BY:
 			g_value_set_object (value, priv->last_modified_by);
 			break;
+		case PROP_QUOTA_USED:
+			g_value_set_int64 (value, priv->quota_used);
+			break;
 		case PROP_ID: {
 			gchar *uri;
 
@@ -423,6 +444,8 @@ gdata_documents_entry_set_property (GObject *object, guint property_id, const GV
 		case PROP_ID:
 			/* Never set an ID (note that this doesn't stop it being set in GDataEntry due to XML parsing) */
 			break;
+		case PROP_QUOTA_USED:
+			/* Read only. */
 		default:
 			/* We don't have any other property... */
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -447,7 +470,9 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 		    gdata_parser_object_from_element (node, "lastModifiedBy", P_REQUIRED, GDATA_TYPE_AUTHOR,
 		                                      &(self->priv->last_modified_by), &success, error) == TRUE ||
 		    gdata_parser_string_from_element (node, "resourceId", P_REQUIRED | P_NON_EMPTY | P_NO_DUPES, &(self->priv->resource_id),
-		                                      &success, error) == TRUE) {
+		                                      &success, error) == TRUE ||
+		    gdata_parser_int64_from_element (node, "quotaBytesUsed", P_REQUIRED | P_NO_DUPES,
+		                                     &(self->priv->quota_used), 0, &success, error) == TRUE) {
 			return success;
 		} else if (xmlStrcmp (node->name, (xmlChar*) "deleted") ==  0) {
 			/* <gd:deleted> */
@@ -724,6 +749,24 @@ gdata_documents_entry_get_last_modified_by (GDataDocumentsEntry *self)
 }
 
 /**
+ * gdata_documents_entry_get_quota_used:
+ * @self: a #GDataDocumentsEntry
+ *
+ * Gets the #GDataDocumentsEntry:quota-used property.
+ *
+ * Return value: the number of quota bytes used by the document
+ *
+ * Since: 0.13.0
+ */
+goffset
+gdata_documents_entry_get_quota_used (GDataDocumentsEntry *self)
+{
+	g_return_val_if_fail (GDATA_IS_DOCUMENTS_ENTRY (self), 0);
+
+	return self->priv->quota_used;
+}
+
+/**
  * gdata_documents_entry_is_deleted:
  * @self: a #GDataDocumentsEntry
  *
diff --git a/gdata/services/documents/gdata-documents-entry.h b/gdata/services/documents/gdata-documents-entry.h
index 097df9d..e71dfb6 100644
--- a/gdata/services/documents/gdata-documents-entry.h
+++ b/gdata/services/documents/gdata-documents-entry.h
@@ -108,6 +108,8 @@ gboolean gdata_documents_entry_writers_can_invite (GDataDocumentsEntry *self) G_
 
 GDataAuthor *gdata_documents_entry_get_last_modified_by (GDataDocumentsEntry *self) G_GNUC_PURE;
 
+goffset gdata_documents_entry_get_quota_used (GDataDocumentsEntry *self) G_GNUC_PURE;
+
 gboolean gdata_documents_entry_is_deleted (GDataDocumentsEntry *self) G_GNUC_PURE;
 
 G_END_DECLS



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