[evolution-exchange] Adapt to CamelFolderSummary API changes
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-exchange] Adapt to CamelFolderSummary API changes
- Date: Thu, 6 Oct 2011 15:01:08 +0000 (UTC)
commit 55f6971ce8c49abd25ce92c86849ba53692d57f6
Author: Milan Crha <mcrha redhat com>
Date: Thu Oct 6 17:00:24 2011 +0200
Adapt to CamelFolderSummary API changes
camel/camel-exchange-folder.c | 63 ++++++++++++++++------------------------
camel/camel-exchange-journal.c | 10 ++++--
camel/camel-exchange-search.c | 2 +-
camel/camel-exchange-summary.c | 23 +++++++-------
camel/camel-exchange-utils.c | 4 +-
5 files changed, 45 insertions(+), 57 deletions(-)
---
diff --git a/camel/camel-exchange-folder.c b/camel/camel-exchange-folder.c
index d9db9e4..793a259 100644
--- a/camel/camel-exchange-folder.c
+++ b/camel/camel-exchange-folder.c
@@ -253,7 +253,7 @@ exchange_folder_transfer_messages_the_hard_way (CamelFolder *source,
*transferred_uids = g_ptr_array_new ();
for (i = 0; i < uids->len; i++) {
- info = camel_folder_summary_uid (source->summary, uids->pdata[i]);
+ info = camel_folder_summary_get (source->summary, uids->pdata[i]);
if (!info)
continue;
@@ -645,8 +645,9 @@ exchange_folder_refresh_info_sync (CamelFolder *folder,
success = success && (!error || !*error);
if (success) {
- folder->summary->unread_count = unread_count;
- folder->summary->visible_count = visible_count;
+ /* do nothing, the summary should be in sync on its own */
+ /* folder->summary->unread_count = unread_count;
+ folder->summary->visible_count = visible_count; */
} else if (error && !*error) {
g_set_error (error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, "%s", _("Could not get new messages"));
}
@@ -663,7 +664,7 @@ exchange_folder_synchronize_sync (CamelFolder *folder,
if (expunge)
exchange_folder_expunge_sync (folder, cancellable, NULL);
- return camel_folder_summary_save_to_db (folder->summary, error) == 0;
+ return camel_folder_summary_save_to_db (folder->summary, error);
}
static gboolean
@@ -708,7 +709,7 @@ exchange_folder_transfer_messages_to_sync (CamelFolder *source,
journal = (CamelExchangeJournal *) exch_dest->journal;
for (i = 0; i < uids->len && success; i++) {
- info = camel_folder_summary_uid (
+ info = camel_folder_summary_get (
source->summary, uids->pdata[i]);
if (!info)
continue;
@@ -861,7 +862,7 @@ camel_exchange_folder_add_message (CamelExchangeFolder *exch,
CamelStream *stream;
CamelMimeMessage *msg;
- info = camel_folder_summary_uid (folder->summary, uid);
+ info = camel_folder_summary_get (folder->summary, uid);
if (info) {
camel_message_info_free (info);
return;
@@ -900,11 +901,6 @@ camel_exchange_folder_add_message (CamelExchangeFolder *exch,
camel_folder_summary_add (folder->summary, info);
- if (!(flags & CAMEL_MESSAGE_SEEN)) {
- folder->summary->unread_count++;
- folder->summary->visible_count++;
- }
-
changes = camel_folder_change_info_new ();
camel_folder_change_info_add_uid (changes, uid);
camel_folder_change_info_recent_uid (changes, uid);
@@ -929,7 +925,7 @@ camel_exchange_folder_remove_message (CamelExchangeFolder *exch,
CamelMessageInfo *info;
CamelExchangeMessageInfo *einfo;
- info = camel_folder_summary_uid (summary, uid);
+ info = camel_folder_summary_get (summary, uid);
if (!info)
return;
@@ -985,24 +981,18 @@ camel_exchange_folder_update_message_flags (CamelExchangeFolder *exch,
{
CamelFolder *folder = CAMEL_FOLDER (exch);
CamelMessageInfoBase *info;
- CamelFolderChangeInfo *changes;
- info = (CamelMessageInfoBase *) camel_folder_summary_uid (folder->summary, uid);
+ info = (CamelMessageInfoBase *) camel_folder_summary_get (folder->summary, uid);
if (!info)
return;
flags |= (info->flags & ~CAMEL_EXCHANGE_SERVER_FLAGS);
if (info->flags != flags) {
- info->flags = flags;
- info->dirty = 1;
- camel_folder_summary_touch (folder->summary);
-
- changes = camel_folder_change_info_new ();
- camel_folder_change_info_change_uid (changes, uid);
- camel_folder_changed (CAMEL_FOLDER (exch), changes);
- camel_folder_change_info_free (changes);
+ camel_message_info_set_flags ((CamelMessageInfo *) info, ~0, flags);
}
+
+ camel_message_info_free ((CamelMessageInfo *) info);
}
/**
@@ -1023,28 +1013,22 @@ camel_exchange_folder_update_message_flags_ex (CamelExchangeFolder *exch,
{
CamelFolder *folder = CAMEL_FOLDER (exch);
CamelMessageInfoBase *info;
- CamelFolderChangeInfo *changes;
- info = (CamelMessageInfoBase *) camel_folder_summary_uid (folder->summary, uid);
+ info = (CamelMessageInfoBase *) camel_folder_summary_get (folder->summary, uid);
if (!info)
return;
mask &= CAMEL_EXCHANGE_SERVER_FLAGS;
if (!mask) {
+ camel_message_info_free ((CamelMessageInfo *) info);
return;
}
if ((info->flags & mask) != (flags & mask)) {
- info->flags &= ~mask;
- info->flags |= (flags & mask);
- info->dirty = 1;
- camel_folder_summary_touch (folder->summary);
-
- changes = camel_folder_change_info_new ();
- camel_folder_change_info_change_uid (changes, uid);
- camel_folder_changed (CAMEL_FOLDER (exch), changes);
- camel_folder_change_info_free (changes);
+ camel_message_info_set_flags ((CamelMessageInfo *) info, mask, flags);
}
+
+ camel_message_info_free ((CamelMessageInfo *) info);
}
/**
@@ -1067,7 +1051,7 @@ camel_exchange_folder_update_message_tag (CamelExchangeFolder *exch,
CamelMessageInfoBase *info;
CamelFolderChangeInfo *changes;
- info = (CamelMessageInfoBase *) camel_folder_summary_uid (folder->summary, uid);
+ info = (CamelMessageInfoBase *) camel_folder_summary_get (folder->summary, uid);
if (!info)
return;
@@ -1112,6 +1096,7 @@ camel_exchange_folder_construct (CamelFolder *folder,
CamelStore *parent_store;
const gchar *full_name;
gint i, len = 0;
+ GPtrArray *known_uids;
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
@@ -1161,9 +1146,9 @@ camel_exchange_folder_construct (CamelFolder *folder,
exch->thread_index_to_message_id =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- len = camel_folder_summary_count (folder->summary);
- for (i = 0; i < len; 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));
einfo = (CamelExchangeMessageInfo *) info;
if (einfo->thread_index && einfo->info.message_id.id.id) {
@@ -1175,6 +1160,8 @@ camel_exchange_folder_construct (CamelFolder *folder,
camel_message_info_free (info);
}
+ camel_folder_summary_free_array (known_uids);
+
if (parent_store != NULL) {
gboolean ok, create = camel_flags & CAMEL_STORE_FOLDER_CREATE, readonly = FALSE;
@@ -1190,7 +1177,7 @@ camel_exchange_folder_construct (CamelFolder *folder,
for (i = 0; i < summary->len; i++) {
uids->pdata[i] = summary->pdata[i];
- info = camel_folder_summary_uid (folder->summary, uids->pdata[i]);
+ info = camel_folder_summary_get (folder->summary, uids->pdata[i]);
flags->data[i] = ((CamelMessageInfoBase *) info)->flags & CAMEL_EXCHANGE_SERVER_FLAGS;
hrefs->pdata[i] = ((CamelExchangeMessageInfo *) info)->href;
//camel_tag_list_free (&((CamelMessageInfoBase *) info)->user_tags);
diff --git a/camel/camel-exchange-journal.c b/camel/camel-exchange-journal.c
index 06e0196..4738b0e 100644
--- a/camel/camel-exchange-journal.c
+++ b/camel/camel-exchange-journal.c
@@ -81,7 +81,7 @@ exchange_entry_play_append (CamelOfflineJournal *journal,
g_object_unref (stream);
- if (!(info = camel_folder_summary_uid (folder->summary, entry->uid))) {
+ if (!(info = camel_folder_summary_get (folder->summary, entry->uid))) {
/* Should have never happened, but create a new info to avoid further crashes */
info = camel_message_info_new (NULL);
}
@@ -138,7 +138,7 @@ exchange_entry_play_transfer (CamelOfflineJournal *journal,
g_object_unref (stream);
- if (!(info = camel_folder_summary_uid (folder->summary, entry->uid))) {
+ if (!(info = camel_folder_summary_get (folder->summary, entry->uid))) {
/* Note: this should never happen, but rather than crash lets make a new info */
info = camel_message_info_new (NULL);
}
@@ -434,7 +434,8 @@ update_cache (CamelExchangeJournal *exchange_journal,
cache = camel_data_cache_add (
exchange_folder->cache, "cache", uid, error);
if (cache == NULL) {
- folder->summary->nextuid--;
+ /* this will not change it anyway */
+ camel_folder_summary_set_next_uid (folder->summary, nextuid - 1);
g_free (uid);
return FALSE;
}
@@ -446,7 +447,8 @@ update_cache (CamelExchangeJournal *exchange_journal,
error, _("Cannot append message in offline mode: "));
camel_data_cache_remove (
exchange_folder->cache, "cache", uid, NULL);
- folder->summary->nextuid--;
+ /* this will not change it anyway */
+ camel_folder_summary_set_next_uid (folder->summary, nextuid - 1);
g_object_unref (cache);
g_free (uid);
return FALSE;
diff --git a/camel/camel-exchange-search.c b/camel/camel-exchange-search.c
index d6cf4df..0809ff9 100644
--- a/camel/camel-exchange-search.c
+++ b/camel/camel-exchange-search.c
@@ -111,7 +111,7 @@ exchange_search_body_contains (struct _ESExp *f,
uid_hash = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < s->summary->len; i++) {
- info = camel_folder_summary_uid (s->folder->summary, s->summary->pdata[i]);
+ info = camel_folder_summary_get (s->folder->summary, s->summary->pdata[i]);
g_hash_table_insert (uid_hash, s->summary->pdata[i], info);
}
}
diff --git a/camel/camel-exchange-summary.c b/camel/camel-exchange-summary.c
index 4005546..2608696 100644
--- a/camel/camel-exchange-summary.c
+++ b/camel/camel-exchange-summary.c
@@ -255,7 +255,7 @@ exchange_summary_summary_header_to_db (CamelFolderSummary *s,
return fir;
}
-static gint
+static gboolean
exchange_summary_summary_header_from_db (CamelFolderSummary *s,
CamelFIRecord *mir)
{
@@ -266,8 +266,8 @@ exchange_summary_summary_header_from_db (CamelFolderSummary *s,
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
camel_exchange_summary_parent_class);
- if (folder_summary_class->summary_header_from_db (s, mir) == -1)
- return -1;
+ if (!folder_summary_class->summary_header_from_db (s, mir))
+ return FALSE;
part = mir->bdata;
@@ -275,7 +275,7 @@ exchange_summary_summary_header_from_db (CamelFolderSummary *s,
exchange->readonly = bdata_extract_digit (&part);
exchange->high_article_num = bdata_extract_digit (&part);
- return 0;
+ return TRUE;
}
static CamelMIRecord *
@@ -332,7 +332,7 @@ exchange_summary_info_set_flags (CamelMessageInfo *info,
if (CAMEL_EXCHANGE_SUMMARY (info->summary)->readonly)
return FALSE;
- folder = info->summary->folder;
+ folder = camel_folder_summary_get_folder (info->summary);
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
@@ -385,12 +385,12 @@ exchange_summary_info_set_user_tag (CamelMessageInfo *info,
camel_exchange_summary_parent_class);
res = folder_summary_class->info_set_user_tag (info, name, value);
- if (res && info->summary->folder && info->uid) {
- CamelFolder *folder = info->summary->folder;
+ if (res && camel_folder_summary_get_folder (info->summary) && info->uid) {
+ CamelFolder *folder;
CamelStore *parent_store;
const gchar *full_name;
- folder = info->summary->folder;
+ folder = camel_folder_summary_get_folder (info->summary);
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
@@ -443,15 +443,14 @@ camel_exchange_summary_new (struct _CamelFolder *folder,
CamelFolderSummary *summary;
GError *local_error = NULL;
- summary = g_object_new (CAMEL_TYPE_EXCHANGE_SUMMARY, NULL);
- summary->folder = folder;
+ summary = g_object_new (CAMEL_TYPE_EXCHANGE_SUMMARY, "folder", folder, NULL);
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)) {
g_warning (
"Unable to load Exchage summary for folder %s: %s\n",
camel_folder_get_full_name (folder),
local_error->message);
- camel_folder_summary_clear_db (summary);
+ camel_folder_summary_clear (summary, NULL);
camel_folder_summary_touch (summary);
g_error_free (local_error);
}
diff --git a/camel/camel-exchange-utils.c b/camel/camel-exchange-utils.c
index 079b999..fa7fb4f 100644
--- a/camel/camel-exchange-utils.c
+++ b/camel/camel-exchange-utils.c
@@ -375,7 +375,7 @@ message_remove_at_index (ExchangeFolder *mfld,
g_datalist_clear (&mmsg->tag_updates);
}
- if (folder && (info = camel_folder_summary_uid (folder->summary, mmsg->uid))) {
+ if (folder && (info = camel_folder_summary_get (folder->summary, mmsg->uid))) {
camel_message_info_free (info);
camel_exchange_folder_remove_message (CAMEL_EXCHANGE_FOLDER (folder), mmsg->uid);
}
@@ -2826,7 +2826,7 @@ camel_exchange_utils_get_message (CamelService *service,
mmsg = find_message (mfld, uid);
if (!mmsg) {
- if (folder && (info = camel_folder_summary_uid (folder->summary, uid))) {
+ if (folder && (info = camel_folder_summary_get (folder->summary, uid))) {
camel_message_info_free (info);
camel_exchange_folder_remove_message (CAMEL_EXCHANGE_FOLDER (folder), uid);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]