[evolution-mapi] Adapt to CamelFolderSummary API changes
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Adapt to CamelFolderSummary API changes
- Date: Thu, 6 Oct 2011 15:02:55 +0000 (UTC)
commit 68c62e71ff16c4c70dd805315f522d98c416822d
Author: Milan Crha <mcrha redhat com>
Date: Thu Oct 6 17:02:16 2011 +0200
Adapt to CamelFolderSummary API changes
src/camel/camel-mapi-folder.c | 66 +++++++++++++++++++++++++---------------
src/camel/camel-mapi-summary.c | 60 ++++++++++++++++++------------------
2 files changed, 71 insertions(+), 55 deletions(-)
---
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index d5bd1d9..db64991 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -114,7 +114,7 @@ update_store_summary (CamelFolder *folder, GError **error)
CamelStoreSummary *store_summary;
CamelStoreInfo *si;
const gchar *full_name;
- gint retval;
+ gboolean retval;
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
@@ -125,7 +125,7 @@ update_store_summary (CamelFolder *folder, GError **error)
if (si) {
guint32 unread, total;
- unread = folder->summary->unread_count;
+ unread = camel_folder_summary_get_unread_count (folder->summary);
total = camel_folder_summary_count (folder->summary);
if (si->total != total || si->unread != unread) {
@@ -139,7 +139,7 @@ update_store_summary (CamelFolder *folder, GError **error)
retval = camel_folder_summary_save_to_db (folder->summary, error);
camel_store_summary_save (store_summary);
- return (retval == 0);
+ return retval;
}
static gboolean
@@ -360,7 +360,7 @@ mapi_update_cache (CamelFolder *folder, GSList *list, CamelFolderChangeInfo **ch
mi = NULL;
pmi = NULL;
msg_uid = exchange_mapi_util_mapi_ids_to_uid (item->fid, item->mid);
- pmi = camel_folder_summary_uid (folder->summary, msg_uid);
+ pmi = camel_folder_summary_get (folder->summary, msg_uid);
if (pmi) {
exists = TRUE;
@@ -553,8 +553,8 @@ mapi_sync_deleted (CamelSession *session,
CamelStore *parent_store;
CamelServiceConnectionStatus status;
CamelService *service;
-
- guint32 index, count, options = 0;
+ GPtrArray *known_uids = NULL;
+ guint32 index, options = 0;
GHashTable *server_messages = NULL;
const gchar *uid = NULL;
gboolean flags_changed = FALSE;
@@ -603,18 +603,18 @@ mapi_sync_deleted (CamelSession *session,
changes = camel_folder_change_info_new ();
- count = camel_folder_summary_count (data->folder->summary);
camel_operation_push_message (
cancellable,
_("Removing deleted messages from cache in %s"),
camel_folder_get_display_name (data->folder));
- /* Iterate over cache and check if the UID is in server*/
- for (index = 0; index < count; index++) {
+ /* Iterate over cache and check if the UID is in server */
+ known_uids = camel_folder_summary_get_array (data->folder->summary);
+ for (index = 0; known_uids && index < known_uids->len; index++) {
guint32 msg_flags;
/* Iterate in a reverse order, thus removal will not hurt */
- info = camel_folder_summary_index (data->folder->summary, count - index - 1);
+ info = camel_folder_summary_get (data->folder->summary, g_ptr_array_index (known_uids, index));
if (!info) continue; /*This is bad. *Should* not happen*/
uid = camel_message_info_uid (info);
@@ -647,7 +647,7 @@ mapi_sync_deleted (CamelSession *session,
camel_message_info_free (info);
/* Progress update */
- camel_operation_progress (cancellable, (index * 100)/count); /* ;-) */
+ camel_operation_progress (cancellable, (index * 100) / known_uids->len);
/* Check if we have to stop */
if (g_cancellable_is_cancelled (cancellable) || camel_application_is_exiting) {
@@ -672,7 +672,9 @@ mapi_sync_deleted (CamelSession *session,
g_hash_table_destroy (server_messages);
-exit:
+ exit:
+ camel_folder_summary_free_array (known_uids);
+
if (data->need_refresh) {
CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY (data->folder->summary);
if (mapi_summary) {
@@ -1001,7 +1003,7 @@ mapi_set_message_flags (CamelFolder *folder,
g_return_val_if_fail (folder->summary != NULL, FALSE);
- info = camel_folder_summary_uid (folder->summary, uid);
+ info = camel_folder_summary_get (folder->summary, uid);
if (info == NULL)
return FALSE;
@@ -1014,6 +1016,7 @@ mapi_set_message_flags (CamelFolder *folder,
static void
mapi_folder_dispose (GObject *object)
{
+ CamelStore *parent_store;
CamelMapiFolder *mapi_folder = CAMEL_MAPI_FOLDER (object);
if (mapi_folder->cache != NULL) {
@@ -1021,6 +1024,13 @@ mapi_folder_dispose (GObject *object)
mapi_folder->cache = NULL;
}
+ parent_store = camel_folder_get_parent_store (CAMEL_FOLDER (mapi_folder));
+ if (parent_store) {
+ camel_store_summary_disconnect_folder_summary (
+ (CamelStoreSummary *) ((CamelMapiStore *) parent_store)->summary,
+ CAMEL_FOLDER (mapi_folder)->summary);
+ }
+
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (camel_mapi_folder_parent_class)->dispose (object);
}
@@ -1164,10 +1174,9 @@ mapi_folder_expunge_sync (CamelFolder *folder,
CamelMessageInfo *info;
CamelFolderChangeInfo *changes;
CamelStore *parent_store;
-
mapi_id_t fid;
-
- gint i, count;
+ GPtrArray *known_uids;
+ gint i;
gboolean delete = FALSE, status = FALSE;
gchar *folder_id;
GSList *deleted_items, *deleted_head;
@@ -1233,11 +1242,11 @@ mapi_folder_expunge_sync (CamelFolder *folder,
}
changes = camel_folder_change_info_new ();
- count = camel_folder_summary_count (folder->summary);
+ known_uids = camel_folder_summary_get_array (folder->summary);
/*Collect UIDs of deleted messages.*/
- for (i = 0; i < count; i++) {
- info = camel_folder_summary_index (folder->summary, i);
+ for (i = 0; known_uids && i < known_uids->len; i++) {
+ info = camel_folder_summary_get (folder->summary, g_ptr_array_index (known_uids, i));
minfo = (CamelMapiMessageInfo *) info;
if (minfo && (minfo->info.flags & CAMEL_MESSAGE_DELETED)) {
const gchar *uid = camel_message_info_uid (info);
@@ -1258,6 +1267,8 @@ mapi_folder_expunge_sync (CamelFolder *folder,
camel_message_info_free (info);
}
+ camel_folder_summary_free_array (known_uids);
+
deleted_items_uid_head = deleted_items_uid;
if (deleted_items) {
@@ -1319,7 +1330,7 @@ mapi_folder_get_message_sync (CamelFolder *folder,
/* see if it is there in cache */
- mi = (CamelMapiMessageInfo *) camel_folder_summary_uid (folder->summary, uid);
+ mi = (CamelMapiMessageInfo *) camel_folder_summary_get (folder->summary, uid);
if (mi == NULL) {
/* Translators: The first %s is replaced with a message ID,
the second %s is replaced with a detailed error string */
@@ -1485,13 +1496,13 @@ mapi_folder_synchronize_sync (CamelFolder *folder,
CamelFolderChangeInfo *changes = NULL;
CamelServiceConnectionStatus status;
CamelService *service;
-
+ GPtrArray *known_uids;
GSList *read_items = NULL, *unread_items = NULL, *to_free = NULL, *junk_items = NULL, *deleted_items = NULL, *l;
flags_diff_t diff, unset_flags;
const gchar *folder_id;
const gchar *full_name;
mapi_id_t fid, deleted_items_fid;
- gint count, i;
+ gint i;
guint32 options =0;
gboolean is_junk_folder;
gboolean success;
@@ -1528,9 +1539,9 @@ mapi_folder_synchronize_sync (CamelFolder *folder,
camel_folder_summary_lock (folder->summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
- count = camel_folder_summary_count (folder->summary);
- for (i=0; i < count; i++) {
- info = camel_folder_summary_index (folder->summary, i);
+ known_uids = camel_folder_summary_get_array (folder->summary);
+ for (i = 0; known_uids && i < known_uids->len; i++) {
+ info = camel_folder_summary_get (folder->summary, g_ptr_array_index (known_uids, i));
mapi_info = (CamelMapiMessageInfo *) info;
if (mapi_info && (mapi_info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) {
@@ -1587,6 +1598,7 @@ mapi_folder_synchronize_sync (CamelFolder *folder,
camel_message_info_free (info);
}
+ camel_folder_summary_free_array (known_uids);
camel_folder_summary_unlock (folder->summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
/*
@@ -1947,5 +1959,9 @@ camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar
g_warning ("%s: cannot find '%s' in known folders", G_STRFUNC, folder_name);
}
+ camel_store_summary_connect_folder_summary (
+ (CamelStoreSummary *) ((CamelMapiStore *) store)->summary,
+ folder_name, folder->summary);
+
return folder;
}
diff --git a/src/camel/camel-mapi-summary.c b/src/camel/camel-mapi-summary.c
index a506659..5e73aed 100644
--- a/src/camel/camel-mapi-summary.c
+++ b/src/camel/camel-mapi-summary.c
@@ -39,13 +39,13 @@
/*Prototypes*/
static CamelFIRecord* mapi_summary_header_to_db (CamelFolderSummary *, GError **error);
-static gint mapi_summary_header_from_db (CamelFolderSummary *, CamelFIRecord *fir);
+static gboolean mapi_summary_header_from_db (CamelFolderSummary *, CamelFIRecord *fir);
static CamelMessageInfo *mapi_message_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir);
static CamelMIRecord *mapi_message_info_to_db (CamelFolderSummary *s, CamelMessageInfo *info);
static CamelMessageContentInfo * mapi_content_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir);
-static gint mapi_content_info_to_db (CamelFolderSummary *s, CamelMessageContentInfo *info, CamelMIRecord *mir);
+static gboolean mapi_content_info_to_db (CamelFolderSummary *s, CamelMessageContentInfo *info, CamelMIRecord *mir);
/*End of Prototypes*/
@@ -105,10 +105,6 @@ camel_mapi_summary_class_init (CamelMapiSummaryClass *class)
static void
camel_mapi_summary_init (CamelMapiSummary *mapi_summary)
{
- CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (mapi_summary);
-
- /* Meta-summary - Overriding UID len */
- summary->meta_summary->uid_len = 2048;
}
/**
@@ -126,19 +122,18 @@ camel_mapi_summary_new (CamelFolder *folder, const gchar *filename)
CamelFolderSummary *summary;
GError *local_error = NULL;
- summary = g_object_new (CAMEL_TYPE_MAPI_SUMMARY, NULL);
+ summary = g_object_new (CAMEL_TYPE_MAPI_SUMMARY, "folder", folder, NULL);
- summary->folder = folder;
camel_folder_summary_set_build_content (summary, TRUE);
camel_folder_summary_set_filename (summary, filename);
- if (camel_folder_summary_load_from_db (summary, &local_error) == -1) {
+ if (!camel_folder_summary_load_from_db (summary, &local_error)) {
/* FIXME: Isn't this dangerous ? We clear the summary
if it cannot be loaded, for some random reason.
We need to pass the ex and find out why it is not loaded etc. ? */
- camel_folder_summary_clear_db (summary);
- g_warning ("Unable to load summary %s\n", local_error->message);
- g_error_free (local_error);
+ camel_folder_summary_clear (summary, NULL);
+ g_warning ("Unable to load summary %s\n", local_error ? local_error->message : "Unknown error");
+ g_clear_error (&local_error);
}
return summary;
@@ -154,21 +149,24 @@ camel_mapi_summary_update_store_info_counts (CamelMapiSummary *mapi_summary)
summary = CAMEL_FOLDER_SUMMARY (mapi_summary);
g_return_if_fail (summary != NULL);
- if (summary->folder) {
+ if (camel_folder_summary_get_folder (summary)) {
CamelMapiStore *mapi_store;
- mapi_store = CAMEL_MAPI_STORE (camel_folder_get_parent_store (summary->folder));
+ mapi_store = CAMEL_MAPI_STORE (camel_folder_get_parent_store (camel_folder_summary_get_folder (summary)));
if (mapi_store && mapi_store->summary) {
CamelStoreInfo *si;
CamelStoreSummary *store_summary = CAMEL_STORE_SUMMARY (mapi_store->summary);
+ CamelFolder*folder;
g_return_if_fail (store_summary != NULL);
- si = camel_store_summary_path (store_summary, camel_folder_get_full_name (summary->folder));
+ folder = camel_folder_summary_get_folder (summary);
+ si = camel_store_summary_path (store_summary, camel_folder_get_full_name (folder));
if (si) {
- if (si->unread != summary->unread_count || si->total != summary->saved_count) {
- si->unread = summary->unread_count;
- si->total = summary->saved_count;
+ if (si->unread != camel_folder_summary_get_unread_count (summary) ||
+ si->total != camel_folder_summary_get_saved_count (summary)) {
+ si->unread = camel_folder_summary_get_unread_count (summary);
+ si->total = camel_folder_summary_get_saved_count (summary);
camel_store_summary_touch (store_summary);
}
@@ -179,7 +177,7 @@ camel_mapi_summary_update_store_info_counts (CamelMapiSummary *mapi_summary)
}
}
-static gint
+static gboolean
mapi_summary_header_from_db (CamelFolderSummary *summary, CamelFIRecord *fir)
{
CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY (summary);
@@ -189,8 +187,8 @@ mapi_summary_header_from_db (CamelFolderSummary *summary, CamelFIRecord *fir)
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
camel_mapi_summary_parent_class);
- if (folder_summary_class->summary_header_from_db (summary, fir) == -1)
- return -1;
+ if (!folder_summary_class->summary_header_from_db (summary, fir))
+ return FALSE;
part = fir->bdata;
@@ -202,7 +200,7 @@ mapi_summary_header_from_db (CamelFolderSummary *summary, CamelFIRecord *fir)
mapi_summary->sync_time_stamp = g_strdup (part);
}
- return 0;
+ return TRUE;
}
static CamelFIRecord *
@@ -288,7 +286,7 @@ mapi_content_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir)
return camel_folder_summary_content_info_new (s);
}
-static gint
+static gboolean
mapi_content_info_to_db (CamelFolderSummary *s, CamelMessageContentInfo *info, CamelMIRecord *mir)
{
CamelFolderSummaryClass *folder_summary_class;
@@ -301,7 +299,7 @@ mapi_content_info_to_db (CamelFolderSummary *s, CamelMessageContentInfo *info, C
return folder_summary_class->content_info_to_db (s, info, mir);
} else {
mir->cinfo = g_strdup ("0");
- return 0;
+ return TRUE;
}
}
@@ -310,13 +308,14 @@ mapi_summary_clear (CamelFolderSummary *summary, gboolean uncache)
{
CamelFolderChangeInfo *changes;
CamelMessageInfo *info;
- gint i, count;
+ gint i;
const gchar *uid;
+ GPtrArray *known_uids;
changes = camel_folder_change_info_new ();
- count = camel_folder_summary_count (summary);
- for (i = 0; i < count; i++) {
- if (!(info = camel_folder_summary_index (summary, i)))
+ known_uids = camel_folder_summary_get_array (summary);
+ for (i = 0; known_uids && i < known_uids->len; i++) {
+ if (!(info = camel_folder_summary_get (summary, g_ptr_array_index (known_uids, i))))
continue;
uid = camel_message_info_uid (info);
@@ -325,9 +324,10 @@ mapi_summary_clear (CamelFolderSummary *summary, gboolean uncache)
camel_message_info_free(info);
}
- camel_folder_summary_clear_db (summary);
+ camel_folder_summary_free_array (known_uids);
+ camel_folder_summary_clear (summary, NULL);
if (camel_folder_change_info_changed (changes))
- camel_folder_changed (summary->folder, changes);
+ camel_folder_changed (camel_folder_summary_get_folder (summary), changes);
camel_folder_change_info_free (changes);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]