[evolution-exchange] Adapt to Camel API changes.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-exchange] Adapt to Camel API changes.
- Date: Wed, 28 Apr 2010 12:57:30 +0000 (UTC)
commit c01218d6a7a9ee482cbd66b33f6b437b17670365
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Apr 27 12:52:25 2010 -0400
Adapt to Camel API changes.
camel/camel-exchange-folder.c | 184 +++++++++++++++++++++++++---------------
camel/camel-exchange-folder.h | 2 -
camel/camel-exchange-journal.c | 26 ++++--
camel/camel-exchange-search.c | 14 +++-
camel/camel-exchange-store.c | 26 ++++--
camel/camel-exchange-summary.c | 54 +++++++++---
6 files changed, 206 insertions(+), 100 deletions(-)
---
diff --git a/camel/camel-exchange-folder.c b/camel/camel-exchange-folder.c
index 082c372..26bc442 100644
--- a/camel/camel-exchange-folder.c
+++ b/camel/camel-exchange-folder.c
@@ -61,28 +61,30 @@ exchange_folder_append_message_data (CamelFolder *folder,
{
CamelExchangeFolder *exch = CAMEL_EXCHANGE_FOLDER (folder);
CamelStream *stream_cache;
+ CamelStore *parent_store;
+ const gchar *full_name;
gchar *new_uid;
+ full_name = camel_folder_get_full_name (folder);
+ parent_store = camel_folder_get_parent_store (folder);
+
if (!subject)
subject = camel_message_info_subject (info);;
if (!subject)
subject = _("No Subject");
- if (camel_exchange_utils_append_message (CAMEL_SERVICE (folder->parent_store),
- folder->full_name,
- info ? camel_message_info_flags (info) : 0,
- subject,
- message,
- &new_uid,
- ex)) {
- stream_cache = camel_data_cache_add (exch->cache,
- "cache", new_uid, NULL);
+ if (camel_exchange_utils_append_message (
+ CAMEL_SERVICE (parent_store), full_name,
+ info ? camel_message_info_flags (info) : 0,
+ subject, message, &new_uid, ex)) {
+ stream_cache = camel_data_cache_add (
+ exch->cache, "cache", new_uid, NULL);
if (stream_cache) {
camel_stream_write (stream_cache,
(gchar *) message->data,
message->len);
camel_stream_flush (stream_cache);
- g_object_unref (CAMEL_OBJECT (stream_cache));
+ g_object_unref (stream_cache);
}
if (appended_uid)
*appended_uid = new_uid;
@@ -97,10 +99,18 @@ exchange_folder_get_message_data (CamelFolder *folder,
const gchar *uid,
CamelException *ex)
{
- CamelExchangeFolder *exch = CAMEL_EXCHANGE_FOLDER (folder);
- CamelExchangeStore *store = CAMEL_EXCHANGE_STORE (folder->parent_store);
+ CamelExchangeFolder *exch;
+ CamelExchangeStore *store;
CamelStream *stream, *stream_mem;
+ CamelStore *parent_store;
GByteArray *ba;
+ const gchar *full_name;
+
+ full_name = camel_folder_get_full_name (folder);
+ parent_store = camel_folder_get_parent_store (folder);
+
+ exch = CAMEL_EXCHANGE_FOLDER (folder);
+ store = CAMEL_EXCHANGE_STORE (parent_store);
stream = camel_data_cache_get (exch->cache, "cache", uid, NULL);
if (stream) {
@@ -121,7 +131,8 @@ exchange_folder_get_message_data (CamelFolder *folder,
return NULL;
}
- if (!camel_exchange_utils_get_message (CAMEL_SERVICE (folder->parent_store), folder->full_name, uid, &ba, ex))
+ if (!camel_exchange_utils_get_message (
+ CAMEL_SERVICE (parent_store), full_name, uid, &ba, ex))
return NULL;
stream = camel_data_cache_add (exch->cache, "cache", uid, ex);
@@ -132,7 +143,7 @@ exchange_folder_get_message_data (CamelFolder *folder,
camel_stream_write (stream, (gchar *) ba->data, ba->len);
camel_stream_flush (stream);
- g_object_unref (CAMEL_OBJECT (stream));
+ g_object_unref (stream);
return ba;
}
@@ -187,7 +198,7 @@ fix_broken_multipart_related (CamelMimePart *part)
camel_medium_set_content (CAMEL_MEDIUM (part),
CAMEL_DATA_WRAPPER (new));
- g_object_unref (CAMEL_OBJECT (new));
+ g_object_unref (new);
}
}
@@ -201,10 +212,15 @@ exchange_folder_transfer_messages_the_hard_way (CamelFolder *source,
{
CamelException local_ex;
CamelMessageInfo *info;
+ CamelStore *parent_store;
GByteArray *ba;
+ const gchar *full_name;
gchar *ret_uid;
gint i;
+ full_name = camel_folder_get_full_name (source);
+ parent_store = camel_folder_get_parent_store (source);
+
if (transferred_uids)
*transferred_uids = g_ptr_array_new ();
camel_exception_init (&local_ex);
@@ -240,9 +256,9 @@ exchange_folder_transfer_messages_the_hard_way (CamelFolder *source,
return;
}
- if (delete_originals) {
- camel_exchange_utils_expunge_uids (CAMEL_SERVICE (source->parent_store), source->full_name, uids, ex);
- }
+ if (delete_originals)
+ camel_exchange_utils_expunge_uids (
+ CAMEL_SERVICE (parent_store), full_name, uids, ex);
}
static void
@@ -268,9 +284,9 @@ exchange_folder_cache_xfer (CamelExchangeFolder *folder_source,
dest_uids->pdata[i], NULL);
if (dest) {
camel_stream_write_to_stream (src, dest);
- g_object_unref (CAMEL_OBJECT (dest));
+ g_object_unref (dest);
}
- g_object_unref (CAMEL_OBJECT (src));
+ g_object_unref (src);
if (delete) {
camel_data_cache_remove (folder_source->cache, "cache",
@@ -322,18 +338,29 @@ static gboolean
exchange_folder_refresh_info (CamelFolder *folder,
CamelException *ex)
{
- CamelExchangeFolder *exch = CAMEL_EXCHANGE_FOLDER (folder);
- CamelExchangeStore *store = CAMEL_EXCHANGE_STORE (folder->parent_store);
+ CamelExchangeFolder *exch;
+ CamelExchangeStore *store;
+ CamelStore *parent_store;
guint32 unread_count, visible_count;
+ const gchar *full_name;
+
+ full_name = camel_folder_get_full_name (folder);
+ parent_store = camel_folder_get_parent_store (folder);
+
+ exch = CAMEL_EXCHANGE_FOLDER (folder);
+ store = CAMEL_EXCHANGE_STORE (parent_store);
if (camel_exchange_store_connected (store, ex)) {
camel_offline_journal_replay (exch->journal, NULL);
- camel_exchange_utils_refresh_folder (CAMEL_SERVICE (folder->parent_store), folder->full_name, ex);
+ camel_exchange_utils_refresh_folder (
+ CAMEL_SERVICE (parent_store), full_name, ex);
}
/* sync up the counts now */
- if (!camel_exchange_utils_sync_count (CAMEL_SERVICE (folder->parent_store), folder->full_name, &unread_count, &visible_count, ex)) {
+ if (!camel_exchange_utils_sync_count (
+ CAMEL_SERVICE (parent_store), full_name,
+ &unread_count, &visible_count, ex)) {
g_print("\n Error syncing up the counts");
}
@@ -349,7 +376,12 @@ exchange_folder_expunge (CamelFolder *folder,
{
CamelFolder *trash;
GPtrArray *uids;
- CamelExchangeStore *store = CAMEL_EXCHANGE_STORE (folder->parent_store);
+ CamelExchangeStore *store;
+ CamelStore *parent_store;
+ const gchar *full_name;
+
+ parent_store = camel_folder_get_parent_store (folder);
+ store = CAMEL_EXCHANGE_STORE (parent_store);
if (!camel_exchange_store_connected (store, ex)) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
@@ -357,16 +389,18 @@ exchange_folder_expunge (CamelFolder *folder,
return FALSE;
}
- trash = camel_store_get_trash (folder->parent_store, NULL);
+ trash = camel_store_get_trash (parent_store, NULL);
if (!trash) {
printf ("Expunge failed, could not read trash folder\n");
return TRUE; /* XXX exception not set */
}
uids = camel_folder_get_uids (trash);
- camel_exchange_utils_expunge_uids (CAMEL_SERVICE (trash->parent_store), trash->full_name, uids, ex);
+ full_name = camel_folder_get_full_name (trash);
+ camel_exchange_utils_expunge_uids (
+ CAMEL_SERVICE (parent_store), full_name, uids, ex);
camel_folder_free_uids (trash, uids);
- g_object_unref (CAMEL_OBJECT (trash));
+ g_object_unref (trash);
return TRUE;
}
@@ -392,12 +426,16 @@ exchange_folder_append_message (CamelFolder *folder,
CamelException *ex)
{
CamelStream *stream;
- CamelExchangeStore *store = CAMEL_EXCHANGE_STORE (folder->parent_store);
+ CamelExchangeStore *store;
+ CamelStore *parent_store;
GByteArray *byte_array;
gchar *old_subject = NULL;
GString *new_subject;
gint i, len;
+ parent_store = camel_folder_get_parent_store (folder);
+ store = CAMEL_EXCHANGE_STORE (parent_store);
+
/*
FIXME: We should add a top-level camel API camel_mime_message_prune_invalid_chars
which each of the provider will have to implement to remove things
@@ -465,13 +503,13 @@ exchange_folder_get_message (CamelFolder *folder,
filtered_stream = camel_stream_filter_new (stream);
camel_stream_filter_add (
CAMEL_STREAM_FILTER (filtered_stream), crlffilter);
- g_object_unref (CAMEL_OBJECT (crlffilter));
- g_object_unref (CAMEL_OBJECT (stream));
+ g_object_unref (crlffilter);
+ g_object_unref (stream);
msg = camel_mime_message_new ();
camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg),
CAMEL_STREAM (filtered_stream));
- g_object_unref (CAMEL_OBJECT (filtered_stream));
+ g_object_unref (filtered_stream);
camel_mime_message_set_source (msg, exch->source);
if (camel_medium_get_header (CAMEL_MEDIUM (msg), "Sender")) {
@@ -519,7 +557,7 @@ exchange_folder_search_by_expression (CamelFolder *folder,
camel_folder_search_set_folder (search, folder);
matches = camel_folder_search_search (search, expression, NULL, ex);
- g_object_unref (CAMEL_OBJECT (search));
+ g_object_unref (search);
return matches;
}
@@ -538,7 +576,7 @@ exchange_folder_search_by_uids (CamelFolder *folder,
camel_folder_search_set_summary (search, uids);
matches = camel_folder_search_execute_expression (search, expression, ex);
- g_object_unref (CAMEL_OBJECT (search));
+ g_object_unref (search);
return matches;
}
@@ -553,11 +591,17 @@ exchange_folder_transfer_messages_to (CamelFolder *source,
{
CamelExchangeFolder *exch_source = CAMEL_EXCHANGE_FOLDER (source);
CamelExchangeFolder *exch_dest = CAMEL_EXCHANGE_FOLDER (dest);
- CamelExchangeStore *store = CAMEL_EXCHANGE_STORE (source->parent_store);
+ CamelExchangeStore *store;
+ CamelStore *parent_store;
CamelMessageInfo *info;
GPtrArray *ret_uids = NULL;
+ const gchar *source_full_name;
+ const gchar *dest_full_name;
gint hier_len, i;
+ parent_store = camel_folder_get_parent_store (source);
+ store = CAMEL_EXCHANGE_STORE (parent_store);
+
camel_operation_start (NULL, delete_originals ? _("Moving messages") :
_("Copying messages"));
@@ -587,8 +631,11 @@ exchange_folder_transfer_messages_to (CamelFolder *source,
goto end;
}
- hier_len = strcspn (source->full_name, "/");
- if (strncmp (source->full_name, dest->full_name, hier_len) != 0) {
+ source_full_name = camel_folder_get_full_name (source);
+ dest_full_name = camel_folder_get_full_name (dest);
+
+ hier_len = strcspn (source_full_name, "/");
+ if (strncmp (source_full_name, dest_full_name, hier_len) != 0) {
exchange_folder_transfer_messages_the_hard_way (
source, uids, dest, transferred_uids,
delete_originals, ex);
@@ -596,8 +643,8 @@ exchange_folder_transfer_messages_to (CamelFolder *source,
}
if (camel_exchange_utils_transfer_messages (CAMEL_SERVICE (store),
- source->full_name,
- dest->full_name,
+ source_full_name,
+ dest_full_name,
uids,
delete_originals,
&ret_uids,
@@ -632,7 +679,7 @@ exchange_folder_count_by_expression (CamelFolder *folder,
camel_folder_search_set_folder (search, folder);
matches = camel_folder_search_count (search, expression, ex);
- g_object_unref (CAMEL_OBJECT (search));
+ g_object_unref (search);
return matches;
}
@@ -748,7 +795,7 @@ camel_exchange_folder_add_message (CamelExchangeFolder *exch,
stream = camel_stream_mem_new_with_buffer (headers, strlen (headers));
msg = camel_mime_message_new ();
camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream);
- g_object_unref (CAMEL_OBJECT (stream));
+ g_object_unref (stream);
info = camel_folder_summary_info_new_from_message (folder->summary, msg, NULL);
einfo = (CamelExchangeMessageInfo *)info;
@@ -768,7 +815,7 @@ camel_exchange_folder_add_message (CamelExchangeFolder *exch,
einfo->info.references->size = 1;
}
}
- g_object_unref (CAMEL_OBJECT (msg));
+ g_object_unref (msg);
info->uid = camel_pstring_strdup (uid);
einfo->info.flags = flags;
@@ -973,25 +1020,25 @@ camel_exchange_folder_update_message_tag (CamelExchangeFolder *exch,
* Return value: success or failure.
**/
gboolean
-camel_exchange_folder_construct (CamelFolder *folder, CamelStore *parent,
- const gchar *name, guint32 camel_flags,
- const gchar *folder_dir, gint offline_state,
- CamelException *ex)
+camel_exchange_folder_construct (CamelFolder *folder,
+ guint32 camel_flags,
+ const gchar *folder_dir,
+ gint offline_state,
+ CamelException *ex)
{
CamelExchangeFolder *exch = (CamelExchangeFolder *)folder;
- const gchar *short_name;
gchar *summary_file, *journal_file, *path;
GPtrArray *summary, *uids, *hrefs;
GByteArray *flags;
guint32 folder_flags;
CamelMessageInfo *info;
CamelExchangeMessageInfo *einfo;
+ CamelStore *parent_store;
+ const gchar *full_name;
gint i, len = 0;
- short_name = strrchr (name, '/');
- if (!short_name++)
- short_name = name;
- camel_folder_construct (folder, parent, name, short_name);
+ full_name = camel_folder_get_full_name (folder);
+ parent_store = camel_folder_get_parent_store (folder);
if (g_mkdir_with_parents (folder_dir, S_IRWXU) != 0) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -1004,17 +1051,17 @@ camel_exchange_folder_construct (CamelFolder *folder, CamelStore *parent,
folder->summary = camel_exchange_summary_new (folder, summary_file);
g_free (summary_file);
if (!folder->summary) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not load summary for %s"),
- name);
+ camel_exception_setv (
+ ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Could not load summary for %s"), full_name);
return FALSE;
}
exch->cache = camel_data_cache_new (folder_dir, ex);
if (!exch->cache) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not create cache for %s"),
- name);
+ camel_exception_setv (
+ ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Could not create cache for %s"), full_name);
return FALSE;
}
@@ -1022,16 +1069,16 @@ camel_exchange_folder_construct (CamelFolder *folder, CamelStore *parent,
exch->journal = camel_exchange_journal_new (exch, journal_file);
g_free (journal_file);
if (!exch->journal) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not create journal for %s"),
- name);
+ camel_exception_setv (
+ ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Could not create journal for %s"), full_name);
return FALSE;
}
path = g_build_filename (folder_dir, "cmeta", NULL);
- camel_object_set (folder, NULL, CAMEL_OBJECT_STATE_FILE, path, NULL);
+ camel_object_set_state_filename (CAMEL_OBJECT (folder), path);
g_free (path);
- camel_object_state_read (folder);
+ camel_object_state_read (CAMEL_OBJECT (folder));
exch->thread_index_to_message_id =
g_hash_table_new (g_str_hash, g_str_equal);
@@ -1050,7 +1097,7 @@ camel_exchange_folder_construct (CamelFolder *folder, CamelStore *parent,
camel_message_info_free(info);
}
- if (parent) {
+ if (parent_store != NULL) {
gboolean ok, create = camel_flags & CAMEL_STORE_FOLDER_CREATE, readonly = FALSE;
summary = camel_folder_get_summary (folder);
@@ -1073,9 +1120,11 @@ camel_exchange_folder_construct (CamelFolder *folder, CamelStore *parent,
}
camel_operation_start (NULL, _("Scanning for changed messages"));
- ok = camel_exchange_utils_get_folder (CAMEL_SERVICE (parent),
- name, create, uids, flags, hrefs, CAMEL_EXCHANGE_SUMMARY (folder->summary)->high_article_num,
- &folder_flags, &exch->source, &readonly, ex);
+ ok = camel_exchange_utils_get_folder (
+ CAMEL_SERVICE (parent_store),
+ full_name, create, uids, flags, hrefs,
+ CAMEL_EXCHANGE_SUMMARY (folder->summary)->high_article_num,
+ &folder_flags, &exch->source, &readonly, ex);
camel_operation_end (NULL);
g_ptr_array_free (uids, TRUE);
g_byte_array_free (flags, TRUE);
@@ -1098,7 +1147,8 @@ camel_exchange_folder_construct (CamelFolder *folder, CamelStore *parent,
return TRUE;
camel_operation_start (NULL, _("Fetching summary information for new messages"));
- ok = camel_exchange_utils_refresh_folder (CAMEL_SERVICE (parent), folder->full_name, ex);
+ ok = camel_exchange_utils_refresh_folder (
+ CAMEL_SERVICE (parent_store), full_name, ex);
camel_operation_end (NULL);
if (!ok)
return FALSE;
diff --git a/camel/camel-exchange-folder.h b/camel/camel-exchange-folder.h
index f623af7..8e77485 100644
--- a/camel/camel-exchange-folder.h
+++ b/camel/camel-exchange-folder.h
@@ -49,8 +49,6 @@ struct _CamelExchangeFolderClass {
GType camel_exchange_folder_get_type (void);
gboolean camel_exchange_folder_construct (CamelFolder *folder,
- CamelStore *parent,
- const gchar *name,
guint32 camel_flags,
const gchar *folder_dir,
gint offline_state,
diff --git a/camel/camel-exchange-journal.c b/camel/camel-exchange-journal.c
index 9fe0d9b..15c7b85 100644
--- a/camel/camel-exchange-journal.c
+++ b/camel/camel-exchange-journal.c
@@ -126,6 +126,7 @@ exchange_entry_play_transfer (CamelOfflineJournal *journal,
CamelExchangeStore *store;
CamelStream *stream;
CamelMimeMessage *message;
+ CamelStore *parent_store;
if (!exchange_folder->cache || !(stream = camel_data_cache_get (exchange_folder->cache, "cache", entry->uid, ex)))
goto done;
@@ -149,7 +150,9 @@ exchange_entry_play_transfer (CamelOfflineJournal *journal,
goto exception;
}
- store = (CamelExchangeStore *) folder->parent_store;
+ parent_store = camel_folder_get_parent_store (folder);
+ store = CAMEL_EXCHANGE_STORE (parent_store);
+
g_mutex_lock (store->folders_lock);
src = (CamelFolder *) g_hash_table_lookup (store->folders, entry->folder_name);
g_mutex_unlock (store->folders_lock);
@@ -200,14 +203,18 @@ exchange_entry_play_delete (CamelOfflineJournal *journal,
CamelExchangeJournalEntry *entry,
CamelException *ex)
{
- CamelFolder *folder = (CamelFolder *) journal->folder;
+ CamelFolder *folder;
+ CamelStore *parent_store;
+ const gchar *full_name;
+
+ folder = CAMEL_FOLDER (journal->folder);
+ full_name = camel_folder_get_full_name (folder);
+ parent_store = camel_folder_get_parent_store (folder);
+
+ camel_exchange_utils_set_message_flags (
+ CAMEL_SERVICE (parent_store), full_name,
+ entry->uid, entry->set, entry->flags, ex);
- camel_exchange_utils_set_message_flags (CAMEL_SERVICE (folder->parent_store),
- folder->full_name,
- entry->uid,
- entry->set,
- entry->flags,
- ex);
return 0;
}
@@ -519,7 +526,8 @@ camel_exchange_journal_transfer (CamelExchangeJournal *exchange_journal, CamelEx
return;
real_uid = original_uid;
- real_source_folder = ((CamelFolder *)source_folder)->full_name;
+ real_source_folder = camel_folder_get_full_name (
+ CAMEL_FOLDER (source_folder));
type = find_real_source_for_message (source_folder, &real_source_folder,
&real_uid, delete_original);
diff --git a/camel/camel-exchange-search.c b/camel/camel-exchange-search.c
index b952827..71aeef8 100644
--- a/camel/camel-exchange-search.c
+++ b/camel/camel-exchange-search.c
@@ -42,14 +42,22 @@ exchange_search_body_contains (struct _ESExp *f,
const gchar *uid;
ESExpResult *r;
CamelMessageInfo *info;
+ CamelOfflineStore *offline_store;
+ CamelStore *parent_store;
GHashTable *uid_hash = NULL;
GPtrArray *found_uids;
+ const gchar *full_name;
gint i;
folder_search_class = CAMEL_FOLDER_SEARCH_CLASS (
camel_exchange_search_parent_class);
- if (((CamelOfflineStore *) s->folder->parent_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
+ full_name = camel_folder_get_full_name (s->folder);
+ parent_store = camel_folder_get_parent_store (s->folder);
+
+ offline_store = CAMEL_OFFLINE_STORE (parent_store);
+
+ if (offline_store->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return folder_search_class->body_contains (f, argc, argv, s);
if (s->current) {
@@ -74,7 +82,9 @@ exchange_search_body_contains (struct _ESExp *f,
}
/* FIXME: what if we have multiple string args? */
- if (!camel_exchange_utils_search (CAMEL_SERVICE (s->folder->parent_store), s->folder->full_name, value, &found_uids, NULL))
+ if (!camel_exchange_utils_search (
+ CAMEL_SERVICE (parent_store),
+ full_name, value, &found_uids, NULL))
return r;
if (!found_uids->len) {
diff --git a/camel/camel-exchange-store.c b/camel/camel-exchange-store.c
index 9a8a179..66aaccc 100644
--- a/camel/camel-exchange-store.c
+++ b/camel/camel-exchange-store.c
@@ -423,6 +423,7 @@ exchange_store_get_folder (CamelStore *store,
{
CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (store);
CamelFolder *folder;
+ const gchar *short_name;
gchar *folder_dir;
RETURN_VAL_IF_NOT_CONNECTED (exch, ex, NULL);
@@ -449,18 +450,25 @@ exchange_store_get_folder (CamelStore *store,
* by the store-level cache...
*/
g_mutex_unlock (exch->folders_lock);
- g_object_ref (CAMEL_OBJECT (folder));
+ g_object_ref (folder);
g_free (folder_dir);
return folder;
}
- folder = g_object_new (CAMEL_TYPE_EXCHANGE_FOLDER, NULL);
+ short_name = strrchr (folder_name, '/');
+ if (!short_name++)
+ short_name = folder_name;
+
+ folder = g_object_new (
+ CAMEL_TYPE_EXCHANGE_FOLDER,
+ "name", short_name, "full-name", folder_name,
+ "parent-store", store, NULL);
g_hash_table_insert (exch->folders, g_strdup (folder_name), folder);
g_mutex_unlock (exch->folders_lock);
- if (!camel_exchange_folder_construct (folder, store, folder_name,
- flags, folder_dir, ((CamelOfflineStore *) store)->state,
- ex)) {
+ if (!camel_exchange_folder_construct (
+ folder, flags, folder_dir,
+ ((CamelOfflineStore *) store)->state, ex)) {
gchar *key;
g_mutex_lock (exch->folders_lock);
if (g_hash_table_lookup_extended (exch->folders, folder_name,
@@ -470,7 +478,7 @@ exchange_store_get_folder (CamelStore *store,
}
g_mutex_unlock (exch->folders_lock);
g_free (folder_dir);
- g_object_unref (CAMEL_OBJECT (folder));
+ g_object_unref (folder);
return NULL;
}
g_free (folder_dir);
@@ -479,7 +487,7 @@ exchange_store_get_folder (CamelStore *store,
* may create and then unref the folder. That's a waste. So don't
* let that happen. Probably not the best fix...
*/
- g_object_ref (CAMEL_OBJECT (folder));
+ g_object_ref (folder);
return folder;
}
@@ -657,7 +665,7 @@ exchange_store_rename_folder (CamelStore *store,
folder = g_hash_table_lookup (exch->folders, reninfo.old_base);
if (folder) {
g_hash_table_remove (exch->folders, reninfo.old_base);
- g_object_unref (CAMEL_OBJECT (folder));
+ g_object_unref (folder);
}
g_mutex_unlock (exch->folders_lock);
@@ -839,7 +847,7 @@ camel_exchange_store_folder_deleted (CamelExchangeStore *estore, const gchar *na
folder = g_hash_table_lookup (estore->folders, info->full_name);
if (folder) {
g_hash_table_remove (estore->folders, info->full_name);
- g_object_unref (CAMEL_OBJECT (folder));
+ g_object_unref (folder);
}
g_mutex_unlock (estore->folders_lock);
diff --git a/camel/camel-exchange-summary.c b/camel/camel-exchange-summary.c
index 9899407..a4434af 100644
--- a/camel/camel-exchange-summary.c
+++ b/camel/camel-exchange-summary.c
@@ -46,12 +46,14 @@ G_DEFINE_TYPE (CamelExchangeSummary, camel_exchange_summary, CAMEL_TYPE_FOLDER_S
static gboolean
exchange_summary_check_for_trash (CamelFolder *folder)
{
- CamelStore *store = (CamelStore *) folder->parent_store;
- CamelException lex;
+ CamelStore *parent_store;
CamelFolder *trash;
+ CamelException lex;
camel_exception_init (&lex);
- trash = camel_store_get_trash (store, &lex);
+
+ parent_store = camel_folder_get_parent_store (folder);
+ trash = camel_store_get_trash (parent_store, &lex);
if (camel_exception_is_set (&lex) || !trash)
return FALSE;
@@ -64,15 +66,23 @@ exchange_summary_expunge_mail (CamelFolder *folder,
CamelMessageInfo *info)
{
GPtrArray *uids = g_ptr_array_new ();
+ CamelStore *parent_store;
gchar *uid = g_strdup (info->uid);
CamelException lex;
+ const gchar *full_name;
+
+ camel_exception_init (&lex);
+
+ full_name = camel_folder_get_full_name (folder);
+ parent_store = camel_folder_get_parent_store (folder);
g_ptr_array_add (uids, uid);
- camel_exception_init (&lex);
- camel_exchange_utils_expunge_uids (CAMEL_SERVICE (folder->parent_store), folder->full_name, uids, &lex);
+ camel_exchange_utils_expunge_uids (
+ CAMEL_SERVICE (parent_store), full_name, uids, &lex);
g_ptr_array_free (uids, TRUE);
+
return camel_exception_is_set (&lex);
}
@@ -351,23 +361,33 @@ exchange_summary_info_set_flags (CamelMessageInfo *info,
guint32 flags,
guint32 set)
{
- CamelFolder *folder = (CamelFolder *) info->summary->folder;
- CamelOfflineStore *store = (CamelOfflineStore *) folder->parent_store;
+ CamelFolder *folder;
+ CamelStore *parent_store;
+ CamelOfflineStore *offline_store;
CamelFolderSummaryClass *folder_summary_class;
+ const gchar *full_name;
if (CAMEL_EXCHANGE_SUMMARY (info->summary)->readonly)
return FALSE;
+ folder = info->summary->folder;
+ full_name = camel_folder_get_full_name (folder);
+ parent_store = camel_folder_get_parent_store (folder);
+
+ offline_store = CAMEL_OFFLINE_STORE (parent_store);
+
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
camel_exchange_summary_parent_class);
- if (store->state != CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
+ if (offline_store->state != CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
if (folder && info->uid) {
if ((flags & set & CAMEL_MESSAGE_DELETED) &&
exchange_summary_check_for_trash (folder)) {
return exchange_summary_expunge_mail (folder, info);
} else {
- camel_exchange_utils_set_message_flags (CAMEL_SERVICE (folder->parent_store), folder->full_name, info->uid, set, flags, NULL);
+ camel_exchange_utils_set_message_flags (
+ CAMEL_SERVICE (parent_store),
+ full_name, info->uid, set, flags, NULL);
return folder_summary_class->info_set_flags(info, flags, set);
}
}
@@ -405,7 +425,16 @@ exchange_summary_info_set_user_tag (CamelMessageInfo *info,
res = folder_summary_class->info_set_user_tag(info, name, value);
if (res && info->summary->folder && info->uid) {
CamelFolder *folder = info->summary->folder;
- camel_exchange_utils_set_message_tag (CAMEL_SERVICE (folder->parent_store), folder->full_name, info->uid, name, value, NULL);
+ CamelStore *parent_store;
+ const gchar *full_name;
+
+ folder = info->summary->folder;
+ full_name = camel_folder_get_full_name (folder);
+ parent_store = camel_folder_get_parent_store (folder);
+
+ camel_exchange_utils_set_message_tag (
+ CAMEL_SERVICE (parent_store),
+ full_name, info->uid, name, value, NULL);
}
return res;
@@ -457,7 +486,10 @@ camel_exchange_summary_new (struct _CamelFolder *folder, const gchar *filename)
summary->folder = folder;
camel_folder_summary_set_filename (summary, filename);
if (camel_folder_summary_load_from_db (summary, &lex) == -1) {
- g_warning ("Unable to load Exchage summary for folder %s: %s\n", folder->full_name, camel_exception_get_description(&lex));
+ g_warning (
+ "Unable to load Exchage summary for folder %s: %s\n",
+ camel_folder_get_full_name (folder),
+ camel_exception_get_description(&lex));
camel_folder_summary_clear_db (summary);
camel_folder_summary_touch (summary);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]