evolution-data-server r8632 - in trunk/camel: . providers/imap
- From: mcrha svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8632 - in trunk/camel: . providers/imap
- Date: Mon, 14 Apr 2008 15:29:14 +0100 (BST)
Author: mcrha
Date: Mon Apr 14 15:29:14 2008
New Revision: 8632
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8632&view=rev
Log:
2008-04-14 Milan Crha <mcrha redhat com>
** Fix for bug #270406
* camel/camel-folder.h: (CamelFolderClass):
* camel/camel-folder.c: (camel_folder_class_init), (get_quota_info),
(camel_folder_get_quota_info), (camel_folder_quota_info_new),
(camel_folder_quota_info_clone), (camel_folder_quota_info_free):
Add virtual function get_quota_info on a folder. Also add functions
to work with CamelFolderQuotaInfo structure.
* camel/providers/imap/camel-imap-store.h:
* camel/providers/imap/camel-imap-store.c: (struct capabilities[]):
Add new check for IMAP_CAPABILITY_QUOTA.
* camel/providers/imap/camel-imap-folder.c: (camel_imap_folder_class_init),
(imap_get_quota_info): Implement get_quota_info on a folder.
Modified:
trunk/camel/ChangeLog
trunk/camel/camel-folder.c
trunk/camel/camel-folder.h
trunk/camel/providers/imap/ChangeLog
trunk/camel/providers/imap/camel-imap-folder.c
trunk/camel/providers/imap/camel-imap-store.c
trunk/camel/providers/imap/camel-imap-store.h
Modified: trunk/camel/camel-folder.c
==============================================================================
--- trunk/camel/camel-folder.c (original)
+++ trunk/camel/camel-folder.c Mon Apr 14 15:29:14 2008
@@ -115,6 +115,8 @@
static gboolean folder_changed (CamelObject *object,
gpointer event_data);
+static CamelFolderQuotaInfo *get_quota_info (CamelFolder *folder);
+
static void
camel_folder_class_init (CamelFolderClass *camel_folder_class)
{
@@ -155,6 +157,7 @@
camel_folder_class->freeze = freeze;
camel_folder_class->thaw = thaw;
camel_folder_class->is_frozen = is_frozen;
+ camel_folder_class->get_quota_info = get_quota_info;
/* virtual method overload */
camel_object_class->getv = folder_getv;
@@ -1632,6 +1635,95 @@
return CF_CLASS (folder)->is_frozen (folder);
}
+static CamelFolderQuotaInfo *
+get_quota_info (CamelFolder *folder)
+{
+ return NULL;
+}
+
+/**
+ * camel_folder_get_quota_info:
+ * @folder: a #CamelFolder object
+ *
+ * Returns list of known quota(s) for the folder.
+ **/
+CamelFolderQuotaInfo *
+camel_folder_get_quota_info (CamelFolder *folder)
+{
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
+
+ return CF_CLASS (folder)->get_quota_info (folder);
+}
+
+/**
+ * camel_folder_quota_info_new:
+ * @name: Name of the quota.
+ * @used: Current usage of the quota.
+ * @total: Total available size of the quota.
+ *
+ * Returns newly allocated #CamelFolderQuotaInfo structure with initialized values
+ * based on the parameters, with next member set to NULL.
+ **/
+CamelFolderQuotaInfo *
+camel_folder_quota_info_new (const char *name, guint64 used, guint64 total)
+{
+ CamelFolderQuotaInfo *info;
+
+ info = g_malloc0 (sizeof (CamelFolderQuotaInfo));
+ info->name = g_strdup (name);
+ info->used = used;
+ info->total = total;
+ info->next = NULL;
+
+ return info;
+}
+
+/**
+ * camel_folder_quota_info_clone:
+ * @info: a #CamelFolderQuotaInfo object to clone.
+ *
+ * Makes a copy of the given info and all next-s.
+ **/
+CamelFolderQuotaInfo *
+camel_folder_quota_info_clone (const CamelFolderQuotaInfo *info)
+{
+ CamelFolderQuotaInfo *clone = NULL, *last = NULL;
+ const CamelFolderQuotaInfo *iter;
+
+ for (iter = info; iter != NULL; iter = iter->next) {
+ CamelFolderQuotaInfo *n = camel_folder_quota_info_new (iter->name, iter->used, iter->total);
+
+ if (last)
+ last->next = n;
+ else
+ clone = n;
+
+ last = n;
+ }
+
+ return clone;
+}
+
+/**
+ * camel_folder_quota_info_free:
+ * @info: a #CamelFolderQuotaInfo object to free.
+ *
+ * Frees this and all next objects.
+ **/
+void
+camel_folder_quota_info_free (CamelFolderQuotaInfo *info)
+{
+ CamelFolderQuotaInfo *next = info;
+
+ while (next) {
+ info = next;
+ next = next->next;
+
+ g_free (info->name);
+ g_free (info);
+ }
+}
+
struct _folder_filter_msg {
CamelSessionThreadMsg msg;
Modified: trunk/camel/camel-folder.h
==============================================================================
--- trunk/camel/camel-folder.h (original)
+++ trunk/camel/camel-folder.h Mon Apr 14 15:29:14 2008
@@ -84,6 +84,16 @@
struct _CamelFolderChangeInfoPrivate *priv;
};
+typedef struct _CamelFolderQuotaInfo CamelFolderQuotaInfo;
+
+struct _CamelFolderQuotaInfo {
+ char *name;
+ guint64 used;
+ guint64 total;
+
+ struct _CamelFolderQuotaInfo *next;
+};
+
struct _CamelFolder {
CamelObject parent_object;
@@ -193,6 +203,8 @@
void (*freeze) (CamelFolder *folder);
void (*thaw) (CamelFolder *folder);
gboolean (*is_frozen) (CamelFolder *folder);
+
+ CamelFolderQuotaInfo * (*get_quota_info) (CamelFolder *folder);
} CamelFolderClass;
/* Standard Camel function */
@@ -320,6 +332,13 @@
void camel_folder_thaw (CamelFolder *folder);
gboolean camel_folder_is_frozen (CamelFolder *folder);
+/* quota support */
+CamelFolderQuotaInfo *camel_folder_get_quota_info (CamelFolder *folder);
+
+CamelFolderQuotaInfo *camel_folder_quota_info_new (const char *name, guint64 used, guint64 total);
+CamelFolderQuotaInfo *camel_folder_quota_info_clone (const CamelFolderQuotaInfo *info);
+void camel_folder_quota_info_free (CamelFolderQuotaInfo *info);
+
/* For use by subclasses (for free_{uids,summary,subfolder_names}) */
void camel_folder_free_nop (CamelFolder *folder, GPtrArray *array);
void camel_folder_free_shallow (CamelFolder *folder, GPtrArray *array);
Modified: trunk/camel/providers/imap/camel-imap-folder.c
==============================================================================
--- trunk/camel/providers/imap/camel-imap-folder.c (original)
+++ trunk/camel/providers/imap/camel-imap-folder.c Mon Apr 14 15:29:14 2008
@@ -67,6 +67,7 @@
#include "camel-imap-private.h"
#include "camel-imap-search.h"
#include "camel-imap-store.h"
+#include "camel-imap-store-summary.h"
#include "camel-imap-summary.h"
#include "camel-imap-utils.h"
#include "camel-imap-wrapper.h"
@@ -133,6 +134,7 @@
static void imap_search_free (CamelFolder *folder, GPtrArray *uids);
static void imap_thaw (CamelFolder *folder);
+static CamelFolderQuotaInfo *imap_get_quota_info (CamelFolder *folder);
static CamelObjectClass *parent_class;
@@ -164,6 +166,7 @@
camel_folder_class->search_by_uids = imap_search_by_uids;
camel_folder_class->search_free = imap_search_free;
camel_folder_class->thaw = imap_thaw;
+ camel_folder_class->get_quota_info = imap_get_quota_info;
camel_disco_folder_class->refresh_info_online = imap_refresh_info;
camel_disco_folder_class->sync_online = imap_sync_online;
@@ -3379,3 +3382,85 @@
return data;
}
+/* it uses connect_lock, thus be sure it doesn't run in main thread */
+static CamelFolderQuotaInfo *
+imap_get_quota_info (CamelFolder *folder)
+{
+ CamelImapStore *imap_store = CAMEL_IMAP_STORE (folder->parent_store);
+ CamelImapResponse *response;
+ CamelFolderQuotaInfo *res = NULL, *last = NULL;
+
+ if (camel_disco_store_status (CAMEL_DISCO_STORE (imap_store)) == CAMEL_DISCO_STORE_OFFLINE)
+ return NULL;
+
+ CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
+
+ if (!camel_imap_store_connected (imap_store, NULL))
+ goto done;
+
+ if (imap_store->capabilities & IMAP_CAPABILITY_QUOTA) {
+ char *folder_name = camel_imap_store_summary_path_to_full (imap_store->summary, camel_folder_get_full_name (folder), imap_store->dir_sep);
+
+ response = camel_imap_command (imap_store, NULL, NULL, "GETQUOTAROOT \"%s\"", folder_name);
+
+ if (response) {
+ int i;
+
+ for (i = 0; i < response->untagged->len; i++) {
+ const char *resp = response->untagged->pdata[i];
+
+ if (resp && g_str_has_prefix (resp, "* QUOTA ")) {
+ size_t sz;
+ char *astr;
+
+ resp = resp + 8;
+ astr = imap_parse_astring (&resp, &sz);
+ g_free (astr);
+
+ while (resp && *resp && *resp != '(')
+ resp++;
+
+ if (resp && *resp == '(') {
+ char *name;
+ const char *used, *total;
+
+ resp++;
+ name = imap_parse_astring (&resp, &sz);
+
+ used = imap_next_word (resp);
+ total = imap_next_word (used);
+
+ while (resp && *resp && *resp != ')')
+ resp++;
+
+ if (resp && *resp == ')' && used && total) {
+ guint64 u, t;
+
+ u = strtoull (used, NULL, 10);
+ t = strtoull (total, NULL, 10);
+
+ if (u >= 0 && t > 0) {
+ CamelFolderQuotaInfo *info = camel_folder_quota_info_new (name, u, t);
+
+ if (last)
+ last->next = info;
+ else
+ res = info;
+
+ last = info;
+ }
+ }
+
+ g_free (name);
+ }
+ }
+ }
+ camel_imap_response_free (imap_store, response);
+ }
+
+ g_free (folder_name);
+ }
+done:
+ CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
+ return res;
+}
Modified: trunk/camel/providers/imap/camel-imap-store.c
==============================================================================
--- trunk/camel/providers/imap/camel-imap-store.c (original)
+++ trunk/camel/providers/imap/camel-imap-store.c Mon Apr 14 15:29:14 2008
@@ -486,6 +486,7 @@
{ "XGWEXTENSIONS", IMAP_CAPABILITY_XGWEXTENSIONS },
{ "XGWMOVE", IMAP_CAPABILITY_XGWMOVE },
{ "LOGINDISABLED", IMAP_CAPABILITY_LOGINDISABLED },
+ { "QUOTA", IMAP_CAPABILITY_QUOTA },
{ NULL, 0 }
};
Modified: trunk/camel/providers/imap/camel-imap-store.h
==============================================================================
--- trunk/camel/providers/imap/camel-imap-store.h (original)
+++ trunk/camel/providers/imap/camel-imap-store.h Mon Apr 14 15:29:14 2008
@@ -98,6 +98,7 @@
#define IMAP_CAPABILITY_XGWEXTENSIONS (1 << 9)
#define IMAP_CAPABILITY_XGWMOVE (1 << 10)
#define IMAP_CAPABILITY_LOGINDISABLED (1 << 11)
+#define IMAP_CAPABILITY_QUOTA (1 << 12)
#define IMAP_PARAM_OVERRIDE_NAMESPACE (1 << 0)
#define IMAP_PARAM_CHECK_ALL (1 << 1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]