[evolution-mapi] Migrate from CamelException to GError.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Migrate from CamelException to GError.
- Date: Thu, 8 Jul 2010 18:37:08 +0000 (UTC)
commit 36d3e4dacc31facc11a3a323549559fe00f36298
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Jul 5 10:45:45 2010 -0400
Migrate from CamelException to GError.
src/camel/camel-mapi-folder.c | 195 +++++++++++--------
src/camel/camel-mapi-folder.h | 6 +-
src/camel/camel-mapi-provider.c | 2 +-
src/camel/camel-mapi-store.c | 241 +++++++++++++----------
src/camel/camel-mapi-store.h | 2 +-
src/camel/camel-mapi-summary.c | 16 +-
src/camel/camel-mapi-transport.c | 14 +-
src/camel/camel-mapi-utils.c | 16 +-
src/camel/camel-mapi-utils.h | 2 +-
src/libexchangemapi/exchange-mapi-connection.c | 2 +-
src/libexchangemapi/exchange-mapi-mail-utils.c | 4 +-
11 files changed, 284 insertions(+), 216 deletions(-)
---
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index e987aa2..2361dfd 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -70,26 +70,26 @@ typedef struct {
/*For collecting summary info from server*/
static void mapi_update_cache (CamelFolder *folder, GSList *list, CamelFolderChangeInfo **changeinfo,
- CamelException *ex, gboolean uid_flag);
+ GError **error, gboolean uid_flag);
G_DEFINE_TYPE (CamelMapiFolder, camel_mapi_folder, CAMEL_TYPE_OFFLINE_FOLDER)
static GPtrArray *
-mapi_folder_search_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
+mapi_folder_search_by_expression (CamelFolder *folder, const gchar *expression, GError **error)
{
CamelMapiFolder *mapi_folder = CAMEL_MAPI_FOLDER(folder);
GPtrArray *matches;
CAMEL_MAPI_FOLDER_LOCK(mapi_folder, search_lock);
camel_folder_search_set_folder (mapi_folder->search, folder);
- matches = camel_folder_search_search(mapi_folder->search, expression, NULL, ex);
+ matches = camel_folder_search_search(mapi_folder->search, expression, NULL, error);
CAMEL_MAPI_FOLDER_UNLOCK(mapi_folder, search_lock);
return matches;
}
static GPtrArray *
-mapi_folder_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex)
+mapi_folder_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, GError **error)
{
GPtrArray *matches;
CamelMapiFolder *mapi_folder = CAMEL_MAPI_FOLDER (folder);
@@ -99,19 +99,20 @@ mapi_folder_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrAr
CAMEL_MAPI_FOLDER_LOCK (mapi_folder, search_lock);
camel_folder_search_set_folder (mapi_folder->search, folder);
- matches = camel_folder_search_search (mapi_folder->search, expression, uids, ex);
+ matches = camel_folder_search_search (mapi_folder->search, expression, uids, error);
CAMEL_MAPI_FOLDER_UNLOCK (mapi_folder, search_lock);
return matches;
}
-static void
-update_store_summary (CamelFolder *folder, CamelException *ex)
+static gboolean
+update_store_summary (CamelFolder *folder, GError **error)
{
CamelStore *parent_store;
CamelStoreSummary *store_summary;
CamelStoreInfo *si;
const gchar *full_name;
+ gboolean success;
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
@@ -132,20 +133,20 @@ update_store_summary (CamelFolder *folder, CamelException *ex)
}
camel_store_summary_info_free (store_summary, si);
}
- camel_folder_summary_save_to_db (folder->summary, ex);
+
+ success = camel_folder_summary_save_to_db (folder->summary, error);
camel_store_summary_save (store_summary);
+
+ return success;
}
static gboolean
-mapi_refresh_info (CamelFolder *folder, CamelException *ex)
+mapi_refresh_info (CamelFolder *folder, GError **error)
{
- mapi_refresh_folder (folder, ex);
- if (camel_exception_is_set (ex))
+ if (!mapi_refresh_folder (folder, error))
return FALSE;
- update_store_summary (folder, ex);
-
- return !camel_exception_is_set (ex);
+ return update_store_summary (folder, error);
}
static gboolean
@@ -322,7 +323,7 @@ mapi_set_message_references (CamelMapiMessageInfo *mapi_mi, const gchar *referen
static void
mapi_update_cache (CamelFolder *folder, GSList *list, CamelFolderChangeInfo **changeinfo,
- CamelException *ex, gboolean uid_flag)
+ GError **error, gboolean uid_flag)
{
CamelMapiMessageInfo *mi = NULL;
CamelMessageInfo *pmi = NULL;
@@ -695,18 +696,17 @@ mapi_sync_deleted_free (CamelSession *session, CamelSessionThreadMsg *msg)
if (m->need_refresh) {
CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY (m->folder->summary);
if (mapi_summary) {
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
+ GError *local_error = NULL;
camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
g_free (mapi_summary->sync_time_stamp);
mapi_summary->sync_time_stamp = NULL;
camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- mapi_refresh_folder (m->folder, &ex);
-
- if (camel_exception_is_set (&ex))
- g_warning ("%s: %s", G_STRFUNC, ex.desc);
- camel_exception_clear (&ex);
+ if (!mapi_refresh_folder (m->folder, &local_error)) {
+ g_warning ("%s: %s", G_STRFUNC, local_error->message);
+ g_error_free (local_error);
+ }
}
}
@@ -719,7 +719,7 @@ static CamelSessionThreadOps deleted_items_sync_ops = {
};
static gboolean
-mapi_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+mapi_sync (CamelFolder *folder, gboolean expunge, GError **error)
{
CamelMapiStore *mapi_store;
CamelMapiFolder *mapi_folder;
@@ -735,6 +735,7 @@ mapi_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
gint count, i;
guint32 options =0;
gboolean is_junk_folder;
+ gboolean success;
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
@@ -744,8 +745,7 @@ mapi_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
if (((CamelOfflineStore *) mapi_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
((CamelService *)mapi_store)->status == CAMEL_SERVICE_DISCONNECTED) {
- update_store_summary (folder, ex);
- return !camel_exception_is_set (ex);
+ return update_store_summary (folder, error);
}
if (((CamelMapiFolder *)folder)->type & CAMEL_MAPI_FOLDER_PUBLIC)
@@ -755,9 +755,8 @@ mapi_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
exchange_mapi_util_mapi_id_from_string (folder_id, &fid);
camel_service_lock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_mapi_store_connected (mapi_store, ex)) {
+ if (!camel_mapi_store_connected (mapi_store, NULL)) {
camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- camel_exception_clear (ex);
return TRUE;
}
camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
@@ -890,10 +889,10 @@ mapi_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
}
camel_service_lock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- update_store_summary (folder, ex);
+ success = update_store_summary (folder, error);
camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- return !camel_exception_is_set (ex);
+ return success;
}
static gboolean
@@ -948,8 +947,8 @@ camel_mapi_folder_fetch_summary (CamelStore *store, CamelFolder *folder, const m
return status;
}
-void
-mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
+gboolean
+mapi_refresh_folder(CamelFolder *folder, GError **error)
{
CamelMapiStore *mapi_store;
@@ -961,6 +960,7 @@ mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
gboolean is_proxy;
gboolean is_locked = FALSE;
gboolean status;
+ gboolean success = TRUE;
struct mapi_SRestriction *res = NULL;
struct SSortOrderSet *sort = NULL;
@@ -984,7 +984,7 @@ mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
/* Sync-up the (un)read changes before getting updates,
so that the getFolderList will reflect the most recent changes too */
- mapi_sync (folder, FALSE, ex);
+ mapi_sync (folder, FALSE, NULL);
//creating a copy
folder_id = camel_mapi_store_folder_id_lookup (mapi_store, full_name);
@@ -1000,7 +1000,7 @@ mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
camel_service_lock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
is_locked = TRUE;
- if (!camel_mapi_store_connected (mapi_store, ex))
+ if (!camel_mapi_store_connected (mapi_store, NULL))
goto end1;
/*Get the New Items*/
@@ -1042,10 +1042,13 @@ mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
exchange_mapi_util_mapi_id_from_string (folder_id, &temp_folder_id);
- if (!camel_mapi_store_connected (mapi_store, ex)) {
+ if (!camel_mapi_store_connected (mapi_store, NULL)) {
/*BUG : Fix exception string.*/
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("This message is not available in offline mode."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("This message is not available in offline mode."));
+ success = FALSE;
goto end1;
}
@@ -1058,7 +1061,11 @@ mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
fetch_data, options);
if (!status) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Fetching items failed"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("Fetching items failed"));
+ success = FALSE;
goto end1;
}
@@ -1067,7 +1074,7 @@ mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
mapi_summary->sync_time_stamp = g_time_val_to_iso8601 (&fetch_data->last_modification_time);
camel_folder_summary_touch (folder->summary);
- update_store_summary (folder, ex);
+ update_store_summary (folder, NULL);
camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
is_locked = FALSE;
@@ -1093,10 +1100,12 @@ end1:
g_slist_foreach (fetch_data->items_list, (GFunc) mail_item_free, NULL);
g_slist_free (fetch_data->items_list);
g_free (fetch_data);
+
+ return success;
}
static CamelMimeMessage *
-mapi_folder_get_message( CamelFolder *folder, const gchar *uid, CamelException *ex )
+mapi_folder_get_message( CamelFolder *folder, const gchar *uid, GError **error )
{
CamelMimeMessage *msg = NULL;
CamelMapiFolder *mapi_folder;
@@ -1120,30 +1129,32 @@ mapi_folder_get_message( CamelFolder *folder, const gchar *uid, CamelException *
if (mi == NULL) {
/* Translators: The first %s is replaced with a message ID,
the second %s is replaced with a detailed error string */
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("Cannot get message %s: %s"), uid, _("No such message"));
+ g_set_error (
+ error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID_UID,
+ _("Cannot get message %s: %s"), uid,
+ _("No such message"));
return NULL;
}
- cache_stream = camel_data_cache_get (mapi_folder->cache, "cache", uid, ex);
+ cache_stream = camel_data_cache_get (mapi_folder->cache, "cache", uid, error);
stream = camel_stream_mem_new ();
if (cache_stream) {
+ GError *local_error = NULL;
+
msg = camel_mime_message_new ();
- camel_stream_reset (stream);
- camel_stream_write_to_stream (cache_stream, stream);
- camel_stream_reset (stream);
- if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, stream) == -1) {
- if (errno == EINTR) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Message fetching cancelled by user."));
+ camel_stream_reset (stream, NULL);
+ camel_stream_write_to_stream (cache_stream, stream, NULL);
+ camel_stream_reset (stream, NULL);
+ if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, stream, &local_error) == -1) {
+ if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
g_object_unref (msg);
g_object_unref (cache_stream);
g_object_unref (stream);
camel_message_info_free (&mi->info);
return NULL;
} else {
- /* Translators: The first %s is replaced with a message ID,
- the second %s is replaced with a detailed error string */
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get message %s: %s"),
- uid, g_strerror (errno));
+ /* Translators: The %s is replaced with a message ID */
+ g_prefix_error (error, "Cannot get message %s: ", uid);
g_object_unref (msg);
msg = NULL;
}
@@ -1158,16 +1169,20 @@ mapi_folder_get_message( CamelFolder *folder, const gchar *uid, CamelException *
}
if (((CamelOfflineStore *) mapi_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("This message is not available in offline mode."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("This message is not available in offline mode."));
camel_message_info_free (&mi->info);
return NULL;
}
/* Check if we are really offline */
- if (!camel_mapi_store_connected (mapi_store, ex)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("This message is not available in offline mode."));
+ if (!camel_mapi_store_connected (mapi_store, NULL)) {
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("This message is not available in offline mode."));
camel_message_info_free (&mi->info);
return NULL;
}
@@ -1189,7 +1204,10 @@ mapi_folder_get_message( CamelFolder *folder, const gchar *uid, CamelException *
camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
if (item == NULL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Could not get message"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("Could not get message"));
camel_message_info_free (&mi->info);
return NULL;
}
@@ -1198,7 +1216,10 @@ mapi_folder_get_message( CamelFolder *folder, const gchar *uid, CamelException *
mail_item_free (item);
if (!msg) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Could not get message"));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_INVALID,
+ _("Could not get message"));
camel_message_info_free (&mi->info);
return NULL;
@@ -1207,8 +1228,8 @@ mapi_folder_get_message( CamelFolder *folder, const gchar *uid, CamelException *
/* add to cache */
CAMEL_MAPI_FOLDER_REC_LOCK (folder, cache_lock);
if ((cache_stream = camel_data_cache_add (mapi_folder->cache, "cache", uid, NULL))) {
- if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, cache_stream) == -1
- || camel_stream_flush (cache_stream) == -1) {
+ if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, cache_stream, NULL) == -1
+ || camel_stream_flush (cache_stream, NULL) == -1) {
camel_data_cache_remove (mapi_folder->cache, "cache", uid, NULL);
} else {
CamelMimeMessage *msg2;
@@ -1218,8 +1239,8 @@ mapi_folder_get_message( CamelFolder *folder, const gchar *uid, CamelException *
composing message in memory, but when they are read from the cache
they appear properly in the UI. */
msg2 = camel_mime_message_new ();
- camel_stream_reset (cache_stream);
- if (camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg2), cache_stream) == -1) {
+ camel_stream_reset (cache_stream, NULL);
+ if (camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg2), cache_stream, NULL) == -1) {
g_object_unref (msg2);
} else {
g_object_unref (msg);
@@ -1291,7 +1312,7 @@ mapi_get_message_info(CamelFolder *folder, const gchar *uid)
#endif
static gboolean
-mapi_expunge (CamelFolder *folder, CamelException *ex)
+mapi_expunge (CamelFolder *folder, GError **error)
{
CamelMapiStore *mapi_store;
CamelMapiFolder *mapi_folder;
@@ -1401,7 +1422,7 @@ mapi_expunge (CamelFolder *folder, CamelException *ex)
static gboolean
mapi_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
CamelFolder *destination, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex)
+ gboolean delete_originals, GError **error)
{
mapi_id_t src_fid, dest_fid;
guint32 src_fid_options, dest_fid_options;
@@ -1416,6 +1437,7 @@ mapi_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
const gchar *destination_full_name;
gint i = 0;
GSList *src_msg_ids = NULL;
+ gboolean success = TRUE;
if (!CAMEL_IS_MAPI_FOLDER (source) || !CAMEL_IS_MAPI_FOLDER (destination) ||
(CAMEL_MAPI_FOLDER (source)->type & CAMEL_MAPI_FOLDER_PUBLIC) != 0 ||
@@ -1427,7 +1449,7 @@ mapi_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
folder_class = CAMEL_FOLDER_CLASS (camel_mapi_folder_parent_class);
return folder_class->transfer_messages_to (
source, uids, destination, transferred_uids,
- delete_originals, ex);
+ delete_originals, error);
}
source_full_name = camel_folder_get_full_name (source);
@@ -1464,7 +1486,10 @@ mapi_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
if (retval != MAPI_E_SUCCESS) {
const gchar *err_str = mapi_get_errstr (retval);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, err_str ? err_str : _("Unknown error"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ "%s", err_str ? err_str : _("Unknown error"));
+ success = FALSE;
} else {
changes = camel_folder_change_info_new ();
@@ -1481,14 +1506,17 @@ mapi_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
if (retval != MAPI_E_SUCCESS) {
const gchar *err_str = mapi_get_errstr (retval);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, err_str ? err_str : _("Unknown error"));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ "%s", err_str ? err_str : _("Unknown error"));
+ success = FALSE;
}
}
g_slist_foreach (src_msg_ids, (GFunc) g_free, NULL);
g_slist_free (src_msg_ids);
- return !camel_exception_is_set (ex);
+ return success;
}
static void
@@ -1509,7 +1537,7 @@ mapi_cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2)
static gboolean
mapi_append_message (CamelFolder *folder, CamelMimeMessage *message,
const CamelMessageInfo *info, gchar **appended_uid,
- CamelException *ex)
+ GError **error)
{
CamelMapiStore *mapi_store;
CamelOfflineStore *offline;
@@ -1537,15 +1565,17 @@ mapi_append_message (CamelFolder *folder, CamelMimeMessage *message,
if (((folder_flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_TRASH) ||
((folder_flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_OUTBOX)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message to folder '%s'"),
- full_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot append message to folder '%s'"),
+ full_name);
return FALSE;
}
if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Offline."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Offline."));
return FALSE;
}
@@ -1556,7 +1586,9 @@ mapi_append_message (CamelFolder *folder, CamelMimeMessage *message,
/* Convert MIME to Item */
from = (CamelAddress *) camel_mime_message_get_from (message);
- item = camel_mapi_utils_mime_to_item (message, from, ex);
+ item = camel_mapi_utils_mime_to_item (message, from, error);
+ if (item == NULL)
+ return FALSE;
mid = exchange_mapi_connection_create_item (camel_mapi_store_get_exchange_connection (mapi_store), -1, fid,
camel_mapi_utils_create_item_build_props, item,
@@ -1566,7 +1598,7 @@ mapi_append_message (CamelFolder *folder, CamelMimeMessage *message,
if (appended_uid)
*appended_uid = exchange_mapi_util_mapi_ids_to_uid(fid, mid);
- return !camel_exception_is_set (ex);
+ return TRUE;
}
static gboolean
@@ -1670,7 +1702,7 @@ camel_mapi_folder_init (CamelMapiFolder *mapi_folder)
CamelFolder *
camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar *folder_dir,
- guint32 flags, CamelException *ex)
+ guint32 flags, GError **error)
{
CamelFolder *folder = NULL;
@@ -1701,9 +1733,10 @@ camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar
if (!folder->summary) {
g_object_unref (CAMEL_OBJECT (folder));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not load summary for %s"),
- folder_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Could not load summary for %s"),
+ folder_name);
return NULL;
}
@@ -1714,7 +1747,7 @@ camel_mapi_folder_new (CamelStore *store, const gchar *folder_name, const gchar
camel_object_state_read (CAMEL_OBJECT (folder));
state_file = g_strdup_printf ("%s/%s", folder_dir, folder_name);
- mapi_folder->cache = camel_data_cache_new (state_file, ex);
+ mapi_folder->cache = camel_data_cache_new (state_file, error);
g_free (state_file);
if (!mapi_folder->cache) {
g_object_unref (folder);
diff --git a/src/camel/camel-mapi-folder.h b/src/camel/camel-mapi-folder.h
index 94773be..7f66dca 100644
--- a/src/camel/camel-mapi-folder.h
+++ b/src/camel/camel-mapi-folder.h
@@ -90,10 +90,10 @@ GType camel_mapi_folder_get_type (void);
/* implemented */
CamelFolder *
-camel_mapi_folder_new(CamelStore *store, const gchar *folder_name, const gchar *folder_dir, guint32 flags, CamelException *ex);
+camel_mapi_folder_new(CamelStore *store, const gchar *folder_name, const gchar *folder_dir, guint32 flags, GError **error);
-void mapi_update_summary ( CamelFolder *folder, GList *item_list,CamelException *ex);
-void mapi_refresh_folder(CamelFolder *folder, CamelException *ex);
+void mapi_update_summary ( CamelFolder *folder, GList *item_list,GError **error);
+gboolean mapi_refresh_folder(CamelFolder *folder, GError **error);
gboolean camel_mapi_folder_fetch_summary (CamelStore *store, CamelFolder *folder, const mapi_id_t fid, struct mapi_SRestriction *res,
struct SSortOrderSet *sort, fetch_items_data *fetch_data, guint32 options);
diff --git a/src/camel/camel-mapi-provider.c b/src/camel/camel-mapi-provider.c
index dc26788..c15b436 100644
--- a/src/camel/camel-mapi-provider.c
+++ b/src/camel/camel-mapi-provider.c
@@ -89,7 +89,7 @@ CamelServiceAuthType camel_mapi_password_authtype = {
};
static gint
-mapi_auto_detect_cb(CamelURL *url, GHashTable **auto_detected, CamelException *ex)
+mapi_auto_detect_cb(CamelURL *url, GHashTable **auto_detected, GError **error)
{
*auto_detected = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (*auto_detected, g_strdup ("poa"), g_strdup (url->host));
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index 40f4c32..3d33c37 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -80,28 +80,28 @@ G_DEFINE_TYPE (CamelMapiStore, camel_mapi_store, CAMEL_TYPE_OFFLINE_STORE)
/* service methods */
static gboolean mapi_construct(CamelService *, CamelSession *,
CamelProvider *, CamelURL *,
- CamelException *);
+ GError **);
static gchar *mapi_get_name(CamelService *, gboolean );
-static gboolean mapi_connect(CamelService *, CamelException *);
-static gboolean mapi_disconnect(CamelService *, gboolean , CamelException *);
-static GList *mapi_query_auth_types(CamelService *, CamelException *);
+static gboolean mapi_connect(CamelService *, GError **);
+static gboolean mapi_disconnect(CamelService *, gboolean , GError **);
+static GList *mapi_query_auth_types(CamelService *, GError **);
/* store methods */
-static CamelFolder *mapi_get_folder(CamelStore *, const gchar *, guint32, CamelException *);
-static CamelFolderInfo *mapi_create_folder(CamelStore *, const gchar *, const gchar *, CamelException *);
-static gboolean mapi_delete_folder(CamelStore *, const gchar *, CamelException *);
-static gboolean mapi_rename_folder(CamelStore *, const gchar *, const gchar *, CamelException *);
-static CamelFolderInfo *mapi_get_folder_info(CamelStore *, const gchar *, guint32, CamelException *);
-static gboolean mapi_subscribe_folder(CamelStore *, const gchar *, CamelException *);
+static CamelFolder *mapi_get_folder(CamelStore *, const gchar *, guint32, GError **);
+static CamelFolderInfo *mapi_create_folder(CamelStore *, const gchar *, const gchar *, GError **);
+static gboolean mapi_delete_folder(CamelStore *, const gchar *, GError **);
+static gboolean mapi_rename_folder(CamelStore *, const gchar *, const gchar *, GError **);
+static CamelFolderInfo *mapi_get_folder_info(CamelStore *, const gchar *, guint32, GError **);
+static gboolean mapi_subscribe_folder(CamelStore *, const gchar *, GError **);
static gboolean mapi_folder_is_subscribed (CamelStore *store, const gchar *folder_name);
-static gboolean mapi_unsubscribe_folder(CamelStore *, const gchar *, CamelException *);
-static gboolean mapi_noop(CamelStore *, CamelException *);
+static gboolean mapi_unsubscribe_folder(CamelStore *, const gchar *, GError **);
+static gboolean mapi_noop(CamelStore *, GError **);
static CamelFolderInfo * mapi_build_folder_info(CamelMapiStore *mapi_store, const gchar *parent_name, const gchar *folder_name);
static gboolean mapi_fid_is_system_folder (CamelMapiStore *mapi_store, const gchar *fid);
static void mapi_update_hash_table_type (CamelMapiStore *store, const gchar *full_name, guint *folder_type);
-static CamelFolder *mapi_get_trash (CamelStore *store, CamelException *ex);
-static CamelFolder *mapi_get_junk (CamelStore *store, CamelException *ex);
-static gboolean mapi_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex);
+static CamelFolder *mapi_get_trash (CamelStore *store, GError **error);
+static CamelFolder *mapi_get_junk (CamelStore *store, GError **error);
+static gboolean mapi_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error);
static void mapi_update_folder_hash_tables (CamelMapiStore *store, const gchar *name, const gchar *fid, const gchar *parent_id);
guint mapi_folders_hash_table_type_lookup (CamelMapiStore *store, const gchar *name);
@@ -256,23 +256,18 @@ camel_mapi_store_init (CamelMapiStore *mapi_store)
/* service methods */
static gboolean mapi_construct(CamelService *service, CamelSession *session,
CamelProvider *provider, CamelURL *url,
- CamelException *ex)
+ GError **error)
{
CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (service);
CamelStore *store = CAMEL_STORE (service);
CamelMapiStorePrivate *priv = mapi_store->priv;
gchar *path = NULL;
- if (!CAMEL_SERVICE_CLASS (camel_mapi_store_parent_class)->construct (service, session, provider, url, ex))
+ if (!CAMEL_SERVICE_CLASS (camel_mapi_store_parent_class)->construct (service, session, provider, url, error))
return FALSE;
-/* if (!(url->host || url->user)) { */
-/* camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, */
-/* _("Host or user not available in url")); */
-/* } */
-
/*storage path*/
- priv->storage_path = camel_session_get_storage_path (session, service, ex);
+ priv->storage_path = camel_session_get_storage_path (session, service, error);
if (!priv->storage_path)
return FALSE;
@@ -327,7 +322,7 @@ static char
}
static gboolean
-check_for_connection (CamelService *service, CamelException *ex)
+check_for_connection (CamelService *service, GError **error)
{
CamelMapiStore *store = CAMEL_MAPI_STORE (service);
@@ -335,7 +330,7 @@ check_for_connection (CamelService *service, CamelException *ex)
}
static gboolean
-mapi_auth_loop (CamelService *service, CamelException *ex)
+mapi_auth_loop (CamelService *service, GError **error)
{
CamelMapiStore *store = CAMEL_MAPI_STORE (service);
CamelSession *session = camel_service_get_session (service);
@@ -367,14 +362,16 @@ mapi_auth_loop (CamelService *service, CamelException *ex)
service->url->host);
service->url->passwd =
camel_session_get_password (session, service, E_PASSWORD_COMPONENT,
- prompt, "password", prompt_flags, ex);
+ prompt, "password", prompt_flags, NULL);
g_free (prompt);
g_free (errbuf);
errbuf = NULL;
if (!service->url->passwd) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("You did not enter a password."));
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("You did not enter a password."));
return FALSE;
}
}
@@ -383,7 +380,6 @@ mapi_auth_loop (CamelService *service, CamelException *ex)
if (!store->priv->conn || !exchange_mapi_connection_connected (store->priv->conn)) {
errbuf = g_strdup_printf (_("Unable to authenticate to Exchange MAPI server."));
- camel_exception_clear (ex);
} else
authenticated = TRUE;
@@ -392,7 +388,7 @@ mapi_auth_loop (CamelService *service, CamelException *ex)
}
static gboolean
-mapi_connect(CamelService *service, CamelException *ex)
+mapi_connect(CamelService *service, GError **error)
{
CamelMapiStore *store = CAMEL_MAPI_STORE (service);
CamelMapiStorePrivate *priv = store->priv;
@@ -405,16 +401,17 @@ mapi_connect(CamelService *service, CamelException *ex)
if (!priv) {
store->priv = g_new0 (CamelMapiStorePrivate, 1);
priv = store->priv;
- camel_service_construct (service, service->session, service->provider, service->url, ex);
+ if (!camel_service_construct (service, service->session, service->provider, service->url, error))
+ return FALSE;
}
camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (check_for_connection (service, ex)) {
+ if (check_for_connection (service, NULL)) {
camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
return TRUE;
}
- if (!mapi_auth_loop (service, ex)) {
+ if (!mapi_auth_loop (service, error)) {
camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
@@ -447,7 +444,7 @@ camel_mapi_store_unset_notification_data (CamelMapiStore *mstore)
}
static gboolean
-mapi_disconnect(CamelService *service, gboolean clean, CamelException *ex)
+mapi_disconnect(CamelService *service, gboolean clean, GError **error)
{
CamelMapiStore *store = CAMEL_MAPI_STORE (service);
@@ -471,7 +468,7 @@ mapi_disconnect(CamelService *service, gboolean clean, CamelException *ex)
return TRUE;
}
-static GList *mapi_query_auth_types(CamelService *service, CamelException *ex)
+static GList *mapi_query_auth_types(CamelService *service, GError **error)
{
return NULL;
}
@@ -502,7 +499,7 @@ mapi_system_folder_fid (CamelMapiStore *mapi_store, gint folder_type)
}
static CamelFolder *
-mapi_get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+mapi_get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, GError **error)
{
CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
CamelMapiStorePrivate *priv = mapi_store->priv;
@@ -525,7 +522,7 @@ mapi_get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, Came
parent = tmp;
}
- folder_info = mapi_create_folder (store, parent, name, ex);
+ folder_info = mapi_create_folder (store, parent, name, error);
g_free (tmp);
if (!folder_info)
@@ -538,14 +535,14 @@ mapi_get_folder(CamelStore *store, const gchar *folder_name, guint32 flags, Came
camel_store_summary_info_free ((CamelStoreSummary *)mapi_store->summary, si);
storage_path = g_strdup_printf ("%s/folders", priv->storage_path);
- folder = camel_mapi_folder_new (store, folder_name, storage_path, flags, ex);
+ folder = camel_mapi_folder_new (store, folder_name, storage_path, flags, error);
g_free (storage_path);
return folder;
}
static CamelFolderInfo*
-mapi_create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_name, CamelException *ex)
+mapi_create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_name, GError **error)
{
CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
CamelMapiStorePrivate *priv = mapi_store->priv;
@@ -554,13 +551,17 @@ mapi_create_folder(CamelStore *store, const gchar *parent_name, const gchar *fol
mapi_id_t parent_fid, new_folder_id;
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create MAPI folders in offline mode."));
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot create MAPI folders in offline mode."));
return NULL;
}
if (mapi_fid_is_system_folder (mapi_store, camel_mapi_store_folder_id_lookup (mapi_store, folder_name))) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create new folder '%s'"),
- folder_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot create new folder '%s'"),
+ folder_name);
return NULL;
}
@@ -569,9 +570,12 @@ mapi_create_folder(CamelStore *store, const gchar *parent_name, const gchar *fol
else
parent_id = g_strdup ("");
- if (!mapi_connect (CAMEL_SERVICE(store), ex)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Authentication failed"));
- return NULL;
+ if (!mapi_connect (CAMEL_SERVICE(store), NULL)) {
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Authentication failed"));
+ return NULL;
}
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
@@ -597,8 +601,8 @@ mapi_create_folder(CamelStore *store, const gchar *parent_name, const gchar *fol
}
-static void
-mapi_forget_folder (CamelMapiStore *mapi_store, const gchar *folder_name, CamelException *ex)
+static gboolean
+mapi_forget_folder (CamelMapiStore *mapi_store, const gchar *folder_name, GError **error)
{
CamelMapiStorePrivate *priv = mapi_store->priv;
gchar *state_file;
@@ -616,7 +620,7 @@ mapi_forget_folder (CamelMapiStore *mapi_store, const gchar *folder_name, CamelE
if (g_access(folder_dir, F_OK) != 0) {
g_free(folder_dir);
- return;
+ return TRUE;
}
state_file = g_strdup_printf ("%s/cmeta", folder_dir);
@@ -632,10 +636,12 @@ mapi_forget_folder (CamelMapiStore *mapi_store, const gchar *folder_name, CamelE
fi = mapi_build_folder_info (mapi_store, NULL, folder_name);
camel_store_folder_deleted (CAMEL_STORE (mapi_store), fi);
camel_folder_info_free (fi);
+
+ return TRUE;
}
static gboolean
-mapi_delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
+mapi_delete_folder(CamelStore *store, const gchar *folder_name, GError **error)
{
CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
CamelMapiStorePrivate *priv = mapi_store->priv;
@@ -643,12 +649,20 @@ mapi_delete_folder(CamelStore *store, const gchar *folder_name, CamelException *
const gchar *folder_id;
mapi_id_t folder_fid;
gboolean status = FALSE;
+ gboolean success = TRUE;
+ GError *local_error = NULL;
camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_mapi_store_connected ((CamelMapiStore *)store, ex)) {
+ if (!camel_mapi_store_connected ((CamelMapiStore *)store, &local_error)) {
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- return !camel_exception_is_set (ex);
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
folder_id = g_hash_table_lookup (priv->name_hash, folder_name);
@@ -659,7 +673,7 @@ mapi_delete_folder(CamelStore *store, const gchar *folder_name, CamelException *
/* Fixme ?? */
/* if (mapi_store->current_folder) */
/* g_object_unref (mapi_store->current_folder); */
- mapi_forget_folder(mapi_store,folder_name,ex);
+ success = mapi_forget_folder(mapi_store,folder_name,error);
/* remove from name_cache at the end, because the folder_id is from there */
/*g_hash_table_remove (priv->parent_hash, folder_id);*/
@@ -669,7 +683,7 @@ mapi_delete_folder(CamelStore *store, const gchar *folder_name, CamelException *
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- return !camel_exception_is_set (ex);
+ return success;
}
static void
@@ -722,7 +736,7 @@ mapi_rename_folder_infos (CamelMapiStore *mapi_store, const gchar *old_name, con
}
static gboolean
-mapi_rename_folder(CamelStore *store, const gchar *old_name, const gchar *new_name, CamelException *ex)
+mapi_rename_folder(CamelStore *store, const gchar *old_name, const gchar *new_name, GError **error)
{
CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
CamelMapiStorePrivate *priv = mapi_store->priv;
@@ -731,21 +745,29 @@ mapi_rename_folder(CamelStore *store, const gchar *old_name, const gchar *new_na
gboolean move_cache = TRUE;
const gchar *old_fid_str, *new_parent_fid_str = NULL;
mapi_id_t old_fid;
+ GError *local_error = NULL;
camel_service_lock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- if (!camel_mapi_store_connected ((CamelMapiStore *)store, ex)) {
+ if (!camel_mapi_store_connected ((CamelMapiStore *)store, &local_error)) {
camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- return !camel_exception_is_set (ex);
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
/* Need a full name of a folder */
old_fid_str = camel_mapi_store_folder_id_lookup (mapi_store, old_name);
if (!old_fid_str) {
/*To translators : '%s' is current name of the folder */
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot rename MAPI folder '%s'. Folder does not exist."),
- old_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot rename MAPI folder '%s'. Folder does not exist."),
+ old_name);
camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return FALSE;
}
@@ -754,9 +776,10 @@ mapi_rename_folder(CamelStore *store, const gchar *old_name, const gchar *new_na
if (mapi_fid_is_system_folder (mapi_store, old_fid_str)) {
/*To translators : '%s to %s' is current name of the folder and
new name of the folder.*/
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot rename MAPI default folder '%s' to '%s'."),
- old_name, new_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot rename MAPI default folder '%s' to '%s'."),
+ old_name, new_name);
camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return FALSE;
}
@@ -780,7 +803,10 @@ mapi_rename_folder(CamelStore *store, const gchar *old_name, const gchar *new_na
}
if (!exchange_mapi_util_mapi_id_from_string (old_fid_str, &old_fid)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename MAPI folder '%s' to '%s'"), old_name, new_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot rename MAPI folder '%s' to '%s'"),
+ old_name, new_name);
camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
g_free (old_parent);
g_free (new_parent);
@@ -794,8 +820,10 @@ mapi_rename_folder(CamelStore *store, const gchar *old_name, const gchar *new_na
if (!exchange_mapi_connection_rename_folder (priv->conn, old_fid, 0, tmp ? tmp : new_name)) {
/*To translators : '%s to %s' is current name of the folder and
new name of the folder.*/
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot rename MAPI folder '%s' to '%s'"), old_name, new_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot rename MAPI folder '%s' to '%s'"),
+ old_name, new_name);
camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
g_free (old_parent);
@@ -846,7 +874,10 @@ mapi_rename_folder(CamelStore *store, const gchar *old_name, const gchar *new_na
!exchange_mapi_util_mapi_id_from_string (new_parent_fid_str, &new_parent_fid) ||
!exchange_mapi_connection_move_folder (priv->conn, old_fid, old_parent_fid, 0, new_parent_fid, 0, tmp)) {
camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename MAPI folder '%s' to '%s'"), old_name, new_name);
+ g_set_error (
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot rename MAPI folder '%s' to '%s'"),
+ old_name, new_name);
g_free (old_parent);
g_free (new_parent);
return FALSE;
@@ -1063,7 +1094,7 @@ mapi_build_folder_info(CamelMapiStore *mapi_store, const gchar *parent_name, con
static CamelFolderInfo *
mapi_get_folder_info_offline (CamelStore *store, const gchar *top,
- guint32 flags, CamelException *ex)
+ guint32 flags, GError **error)
{
CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
CamelFolderInfo *fi;
@@ -1165,7 +1196,7 @@ mapi_get_folder_info_offline (CamelStore *store, const gchar *top,
}
static CamelFolderInfo *
-mapi_convert_to_folder_info (CamelMapiStore *store, ExchangeMAPIFolder *folder, const gchar *url, CamelException *ex)
+mapi_convert_to_folder_info (CamelMapiStore *store, ExchangeMAPIFolder *folder, const gchar *url, GError **error)
{
const gchar *name = NULL;
gchar *parent, *id = NULL;
@@ -1248,14 +1279,10 @@ mapi_convert_to_folder_info (CamelMapiStore *store, ExchangeMAPIFolder *folder,
}
gboolean
-camel_mapi_store_connected (CamelMapiStore *store, CamelException *ex)
+camel_mapi_store_connected (CamelMapiStore *store, GError **error)
{
- if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL
- && camel_service_connect ((CamelService *)store, ex))
-
- return TRUE;
-
- return FALSE;
+ return (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL
+ && camel_service_connect ((CamelService *)store, error));
}
static void
@@ -1392,8 +1419,8 @@ remove_path_from_store_summary (const gchar *path, gpointer value, CamelMapiStor
camel_store_summary_remove_path ((CamelStoreSummary *)mstore->summary, path);
}
-static void
-mapi_folders_sync (CamelMapiStore *store, guint32 flags, CamelException *ex)
+static gboolean
+mapi_folders_sync (CamelMapiStore *store, guint32 flags, GError **error)
{
CamelMapiStorePrivate *priv = store->priv;
gboolean status;
@@ -1406,17 +1433,19 @@ mapi_folders_sync (CamelMapiStore *store, guint32 flags, CamelException *ex)
CamelStoreInfo *si = NULL;
GHashTable *old_cache_folders;
- if (!camel_mapi_store_connected (store, ex)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Folder list not available in offline mode."));
- return;
+ if (!camel_mapi_store_connected (store, NULL)) {
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Folder list not available in offline mode."));
+ return FALSE;
}
status = exchange_mapi_connection_get_folders_list (priv->conn, &folder_list);
if (!status) {
g_warning ("Could not get folder list..\n");
- return;
+ return TRUE;
}
/* remember all folders in cache before update */
@@ -1501,7 +1530,7 @@ mapi_folders_sync (CamelMapiStore *store, guint32 flags, CamelException *ex)
continue;
if ( folder->container_class == MAPI_FOLDER_TYPE_MAIL) {
- info = mapi_convert_to_folder_info (store, folder, (const gchar *)url, ex);
+ info = mapi_convert_to_folder_info (store, folder, (const gchar *)url, NULL);
info->flags |= CAMEL_MAPI_FOLDER_MAIL;
mapi_si = (CamelMapiStoreInfo *) camel_store_summary_path ((CamelStoreSummary *)store->summary, info->full_name);
@@ -1535,7 +1564,7 @@ mapi_folders_sync (CamelMapiStore *store, guint32 flags, CamelException *ex)
camel_folder_info_free (info);
} else if (folder->category == MAPI_FAVOURITE_FOLDER) {
gchar *fid, *pfid = NULL;
- info = mapi_convert_to_folder_info (store, folder, (const gchar *)url, ex);
+ info = mapi_convert_to_folder_info (store, folder, (const gchar *)url, NULL);
mapi_si = (CamelMapiStoreInfo *) camel_store_summary_path ((CamelStoreSummary *)store->summary, info->full_name);
fid = g_strdup_printf ("%016" G_GINT64_MODIFIER "X",
exchange_mapi_folder_get_fid((ExchangeMAPIFolder *)(folder_list->data)));
@@ -1578,13 +1607,14 @@ mapi_folders_sync (CamelMapiStore *store, guint32 flags, CamelException *ex)
/* fnevObjectModified | fnevObjectMoved | fnevObjectCopied; */
/* camel_mapi_notfication_listener_start (store, event_mask, MAPI_EVENTS_USE_STORE); */
+
+ return TRUE;
}
static CamelFolderInfo*
-mapi_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+mapi_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, GError **error)
{
CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
- CamelFolderInfo *info = NULL;
/*
* Thanks to Michael, for his cached folders implementation in IMAP
@@ -1596,7 +1626,7 @@ mapi_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelEx
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
if (((CamelService *)store)->status == CAMEL_SERVICE_DISCONNECTED) {
((CamelService *)store)->status = CAMEL_SERVICE_CONNECTING;
- mapi_connect ((CamelService *)store, ex);
+ mapi_connect ((CamelService *)store, NULL);
}
}
@@ -1607,10 +1637,8 @@ mapi_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelEx
(!(flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)) ||
(!mapi_store->priv->folders_synced) ||
(top && *top && !camel_mapi_store_folder_id_lookup (mapi_store, top))) &&
- (check_for_connection ((CamelService *)store, ex) || ((CamelService *)store)->status == CAMEL_SERVICE_CONNECTING)) {
- mapi_folders_sync (mapi_store, flags, ex);
-
- if (camel_exception_is_set (ex)) {
+ (check_for_connection ((CamelService *)store, NULL) || ((CamelService *)store)->status == CAMEL_SERVICE_CONNECTING)) {
+ if (!mapi_folders_sync (mapi_store, flags, error)) {
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
return NULL;
}
@@ -1620,8 +1648,7 @@ mapi_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelEx
camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
- info = mapi_get_folder_info_offline (store, top, flags, ex);
- return info;
+ return mapi_get_folder_info_offline (store, top, flags, error);
}
const gchar *
@@ -1675,7 +1702,7 @@ camel_mapi_store_get_profile_name (CamelMapiStore *mapi_store)
}
static gboolean
-mapi_subscribe_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
+mapi_subscribe_folder(CamelStore *store, const gchar *folder_name, GError **error)
{
CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
guint folder_type = mapi_folders_hash_table_type_lookup(mapi_store, folder_name);
@@ -1753,7 +1780,7 @@ mapi_folder_is_subscribed (CamelStore *store, const gchar *folder_name)
}
static gboolean
-mapi_unsubscribe_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
+mapi_unsubscribe_folder(CamelStore *store, const gchar *folder_name, GError **error)
{
CamelFolderInfo *fi;
CamelStoreInfo *si;
@@ -1796,7 +1823,7 @@ mapi_unsubscribe_folder(CamelStore *store, const gchar *folder_name, CamelExcept
}
static gboolean
-mapi_noop(CamelStore *store, CamelException *ex)
+mapi_noop(CamelStore *store, GError **error)
{
return TRUE;
}
@@ -1812,7 +1839,7 @@ camel_mapi_store_get_exchange_connection (CamelMapiStore *mapi_store)
}
static CamelFolder *
-mapi_get_folder_with_type (CamelStore *store, guint folder_type, CamelException *ex)
+mapi_get_folder_with_type (CamelStore *store, guint folder_type, GError **error)
{
CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
CamelFolderInfo *all_fi, *fi;
@@ -1821,13 +1848,17 @@ mapi_get_folder_with_type (CamelStore *store, guint folder_type, CamelException
g_return_val_if_fail (mapi_store != NULL, NULL);
g_return_val_if_fail (mapi_store->priv != NULL, NULL);
- all_fi = camel_store_get_folder_info (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE, ex);
+ all_fi = camel_store_get_folder_info (
+ store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE, error);
+ if (all_fi == NULL)
+ return NULL;
+
fi = all_fi;
while (fi) {
CamelFolderInfo *next;
if ((fi->flags & CAMEL_FOLDER_TYPE_MASK) == folder_type) {
- folder = camel_store_get_folder (store, fi->full_name, 0, ex);
+ folder = camel_store_get_folder (store, fi->full_name, 0, error);
break;
}
@@ -1857,20 +1888,20 @@ mapi_get_folder_with_type (CamelStore *store, guint folder_type, CamelException
}
static CamelFolder *
-mapi_get_trash (CamelStore *store, CamelException *ex)
+mapi_get_trash (CamelStore *store, GError **error)
{
- return mapi_get_folder_with_type (store, CAMEL_FOLDER_TYPE_TRASH, ex);
+ return mapi_get_folder_with_type (store, CAMEL_FOLDER_TYPE_TRASH, error);
}
static CamelFolder *
-mapi_get_junk (CamelStore *store, CamelException *ex)
+mapi_get_junk (CamelStore *store, GError **error)
{
- return mapi_get_folder_with_type (store, CAMEL_FOLDER_TYPE_JUNK, ex);
+ return mapi_get_folder_with_type (store, CAMEL_FOLDER_TYPE_JUNK, error);
}
static gboolean
-mapi_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+mapi_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error)
{
- return CAMEL_STORE_CLASS(camel_mapi_store_parent_class)->can_refresh_folder (store, info, ex) ||
+ return CAMEL_STORE_CLASS(camel_mapi_store_parent_class)->can_refresh_folder (store, info, error) ||
(camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL);
}
diff --git a/src/camel/camel-mapi-store.h b/src/camel/camel-mapi-store.h
index 7817f98..e95fd2b 100644
--- a/src/camel/camel-mapi-store.h
+++ b/src/camel/camel-mapi-store.h
@@ -92,7 +92,7 @@ struct _CamelMapiStoreClass {
*/
GType camel_mapi_store_get_type(void);
-gboolean camel_mapi_store_connected(CamelMapiStore *, CamelException *);
+gboolean camel_mapi_store_connected(CamelMapiStore *, GError **);
const gchar * camel_mapi_store_folder_id_lookup (CamelMapiStore *mapi_store, const gchar *folder_name);
const gchar * camel_mapi_store_folder_lookup (CamelMapiStore *mapi_store, const gchar *folder_id);
diff --git a/src/camel/camel-mapi-summary.c b/src/camel/camel-mapi-summary.c
index 73011f2..37b18ed 100644
--- a/src/camel/camel-mapi-summary.c
+++ b/src/camel/camel-mapi-summary.c
@@ -41,7 +41,7 @@
#define MS_EXTRACT_FIRST_DIGIT(val) val=strtoul (part, &part, 10);
/*Prototypes*/
-static CamelFIRecord* mapi_summary_header_to_db (CamelFolderSummary *, CamelException *ex);
+static CamelFIRecord* mapi_summary_header_to_db (CamelFolderSummary *, GError **error);
static gint mapi_summary_header_from_db (CamelFolderSummary *, CamelFIRecord *fir);
static CamelMessageInfo *mapi_message_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir);
@@ -127,23 +127,21 @@ CamelFolderSummary *
camel_mapi_summary_new (CamelFolder *folder, const gchar *filename)
{
CamelFolderSummary *summary;
- CamelException ex;
+ GError *local_error = NULL;
summary = g_object_new (CAMEL_TYPE_MAPI_SUMMARY, NULL);
- camel_exception_init (&ex);
-
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, &ex) == -1) {
+ if (camel_folder_summary_load_from_db (summary, &local_error) == -1) {
/* 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", camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
+ g_warning ("Unable to load summary %s\n", local_error->message);
+ g_error_free (local_error);
}
return summary;
@@ -211,7 +209,7 @@ mapi_summary_header_from_db (CamelFolderSummary *summary, CamelFIRecord *fir)
}
static CamelFIRecord *
-mapi_summary_header_to_db (CamelFolderSummary *summary, CamelException *ex)
+mapi_summary_header_to_db (CamelFolderSummary *summary, GError **error)
{
CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY(summary);
CamelFolderSummaryClass *folder_summary_class;
@@ -220,7 +218,7 @@ mapi_summary_header_to_db (CamelFolderSummary *summary, CamelException *ex)
folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
camel_mapi_summary_parent_class);
- fir = folder_summary_class->summary_header_to_db (summary, ex);
+ fir = folder_summary_class->summary_header_to_db (summary, error);
if (!fir)
return NULL;
diff --git a/src/camel/camel-mapi-transport.c b/src/camel/camel-mapi-transport.c
index bf8c1e6..521e83b 100644
--- a/src/camel/camel-mapi-transport.c
+++ b/src/camel/camel-mapi-transport.c
@@ -72,7 +72,7 @@ mapi_message_item_send (ExchangeMapiConnection *conn, MailItem *item)
static gboolean
mapi_send_to (CamelTransport *transport, CamelMimeMessage *message,
- CamelAddress *from, CamelAddress *recipients, CamelException *ex)
+ CamelAddress *from, CamelAddress *recipients, GError **error)
{
ExchangeMapiConnection *conn;
MailItem *item = NULL;
@@ -92,12 +92,15 @@ mapi_send_to (CamelTransport *transport, CamelMimeMessage *message,
conn = exchange_mapi_connection_find (camel_url_get_param (url, "profile"));
if (!conn) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, _("Could not send message."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Could not send message."));
return FALSE;
}
/* Convert MIME to MailItem, attacment lists and recipient list.*/
- item = camel_mapi_utils_mime_to_item (message, from, ex);
+ item = camel_mapi_utils_mime_to_item (message, from, NULL);
/* send */
st = mapi_message_item_send (conn, item);
@@ -106,7 +109,10 @@ mapi_send_to (CamelTransport *transport, CamelMimeMessage *message,
if (st == 0) {
/*Fixme : Set a better error message. Would be helful in troubleshooting. */
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,_("Could not send message."));
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("Could not send message."));
return FALSE;
}
diff --git a/src/camel/camel-mapi-utils.c b/src/camel/camel-mapi-utils.c
index 586f8ed..863f01e 100644
--- a/src/camel/camel-mapi-utils.c
+++ b/src/camel/camel-mapi-utils.c
@@ -125,11 +125,11 @@ mail_item_set_body_stream (MailItem *item, CamelStream *body, MailItemPartType p
ExchangeMAPIStream *stream = g_new0 (ExchangeMAPIStream, 1);
gboolean contains_only_7bit = TRUE, is_null_terminated = FALSE;
- camel_seekable_stream_seek((CamelSeekableStream *)body, 0, CAMEL_STREAM_SET);
+ camel_seekable_stream_seek((CamelSeekableStream *)body, 0, CAMEL_STREAM_SET, NULL);
stream->value = g_byte_array_new ();
- while (read_size = camel_stream_read (body, (gchar *)buf, STREAM_SIZE), read_size > 0) {
+ while (read_size = camel_stream_read (body, (gchar *)buf, STREAM_SIZE, NULL), read_size > 0) {
stream->value = g_byte_array_append (stream->value, buf, read_size);
is_null_terminated = buf [read_size - 1] == 0;
@@ -247,8 +247,8 @@ mail_item_add_attach (MailItem *item, CamelMimePart *part, CamelStream *content_
stream->proptag = PR_ATTACH_DATA_BIN;
stream->value = g_byte_array_new ();
- camel_seekable_stream_seek((CamelSeekableStream *)content_stream, 0, CAMEL_STREAM_SET);
- while (read_size = camel_stream_read(content_stream, (gchar *)buf, STREAM_SIZE), read_size > 0) {
+ camel_seekable_stream_seek((CamelSeekableStream *)content_stream, 0, CAMEL_STREAM_SET, NULL);
+ while (read_size = camel_stream_read(content_stream, (gchar *)buf, STREAM_SIZE, NULL), read_size > 0) {
stream->value = g_byte_array_append (stream->value, buf, read_size);
}
@@ -288,9 +288,9 @@ mapi_do_multipart (CamelMultipart *mp, MailItem *item, gboolean *is_first)
filename = camel_mime_part_get_filename(part);
content_stream = camel_stream_mem_new();
- content_size = camel_data_wrapper_decode_to_stream (dw, (CamelStream *) content_stream);
+ content_size = camel_data_wrapper_decode_to_stream (dw, (CamelStream *) content_stream, NULL);
- camel_seekable_stream_seek((CamelSeekableStream *)content_stream, 0, CAMEL_STREAM_SET);
+ camel_seekable_stream_seek((CamelSeekableStream *)content_stream, 0, CAMEL_STREAM_SET, NULL);
description = camel_mime_part_get_description(part);
content_id = camel_mime_part_get_content_id(part);
@@ -311,7 +311,7 @@ mapi_do_multipart (CamelMultipart *mp, MailItem *item, gboolean *is_first)
}
MailItem *
-camel_mapi_utils_mime_to_item (CamelMimeMessage *message, CamelAddress *from, CamelException *ex)
+camel_mapi_utils_mime_to_item (CamelMimeMessage *message, CamelAddress *from, GError **error)
{
CamelDataWrapper *dw = NULL;
CamelContentType *type;
@@ -380,7 +380,7 @@ camel_mapi_utils_mime_to_item (CamelMimeMessage *message, CamelAddress *from, Ca
content_type = camel_content_type_simple (type);
content_stream = (CamelStream *)camel_stream_mem_new();
- content_size = camel_data_wrapper_decode_to_stream(dw, (CamelStream *)content_stream);
+ content_size = camel_data_wrapper_decode_to_stream(dw, (CamelStream *)content_stream, NULL);
mail_item_set_body_stream (item, content_stream, PART_TYPE_PLAIN_TEXT);
}
diff --git a/src/camel/camel-mapi-utils.h b/src/camel/camel-mapi-utils.h
index 26ec846..6205b72 100644
--- a/src/camel/camel-mapi-utils.h
+++ b/src/camel/camel-mapi-utils.h
@@ -31,7 +31,7 @@ G_BEGIN_DECLS
#include <camel/camel.h>
MailItem *
-camel_mapi_utils_mime_to_item (CamelMimeMessage *message, CamelAddress *from, CamelException *ex);
+camel_mapi_utils_mime_to_item (CamelMimeMessage *message, CamelAddress *from, GError **error);
gboolean
camel_mapi_utils_create_item_build_props (ExchangeMapiConnection *conn, mapi_id_t fid, TALLOC_CTX *mem_ctx, struct SPropValue **values, uint32_t *n_values, gpointer data);
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index 667ffdc..6d55b56 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -857,7 +857,7 @@ obj_message_to_camel_mime (ExchangeMapiConnection *conn, mapi_id_t fid, mapi_obj
mem = camel_stream_mem_new ();
camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (mem), res);
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (msg), mem);
+ camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (msg), mem, NULL);
g_object_unref (mem);
g_object_unref (msg);
diff --git a/src/libexchangemapi/exchange-mapi-mail-utils.c b/src/libexchangemapi/exchange-mapi-mail-utils.c
index ee4fdf1..8ff5b13 100644
--- a/src/libexchangemapi/exchange-mapi-mail-utils.c
+++ b/src/libexchangemapi/exchange-mapi-mail-utils.c
@@ -381,11 +381,11 @@ mapi_mime_set_msg_headers (ExchangeMapiConnection *conn, CamelMimeMessage *msg,
stream = camel_stream_mem_new_with_buffer (item->header.transport_headers, strlen (item->header.transport_headers));
parser = camel_mime_parser_new ();
- camel_mime_parser_init_with_stream (parser, stream);
+ camel_mime_parser_init_with_stream (parser, stream, NULL);
camel_mime_parser_scan_from (parser, FALSE);
g_object_unref (stream);
- if (camel_mime_part_construct_from_parser (part, parser) != -1) {
+ if (camel_mime_part_construct_from_parser (part, parser, NULL) != -1) {
struct _camel_header_raw *h;
for (h = part->headers; h; h = h->next) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]