[evolution-mapi] Bug #623204 - Be able to report detailed errors from backends
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Bug #623204 - Be able to report detailed errors from backends
- Date: Fri, 9 Jul 2010 12:34:22 +0000 (UTC)
commit 9e8105977f7ad842aa713bd8ab1cec48ef59b374
Author: Milan Crha <mcrha redhat com>
Date: Fri Jul 9 14:34:00 2010 +0200
Bug #623204 - Be able to report detailed errors from backends
configure.ac | 2 +
src/addressbook/e-book-backend-mapi-gal.c | 79 +++---
src/addressbook/e-book-backend-mapi-utils.h | 3 +
src/addressbook/e-book-backend-mapi.c | 178 +++++-----
src/calendar/e-cal-backend-mapi.c | 484 ++++++++++++++-------------
5 files changed, 380 insertions(+), 366 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fbb99b2..62c3362 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,6 +83,8 @@ AS_COMPILER_FLAGS(WARNING_FLAGS,
-DGDK_PIXBUF_DISABLE_DEPRECATED
-DGTK_DISABLE_DEPRECATED
-DGNOME_DISABLE_DEPRECATED
+ -DE_BOOK_DISABLE_DEPRECATED
+ -DE_CAL_DISABLE_DEPRECATED
-DGSEAL_ENABLE
-Wall -Wextra
-Wno-missing-field-initializers
diff --git a/src/addressbook/e-book-backend-mapi-gal.c b/src/addressbook/e-book-backend-mapi-gal.c
index 3da54f0..cdd0c3b 100644
--- a/src/addressbook/e-book-backend-mapi-gal.c
+++ b/src/addressbook/e-book-backend-mapi-gal.c
@@ -207,7 +207,7 @@ build_cache (EBookBackendMAPIGAL *ebmapi)
fetch_gal_cb, &fgd);
if (fgd.book_view) {
- e_data_book_view_notify_complete (fgd.book_view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (fgd.book_view, NULL /* Success */);
e_data_book_view_unref (fgd.book_view);
}
@@ -237,7 +237,7 @@ e_book_backend_mapi_gal_get_supported_fields (EBookBackend *backend,
fields = mapi_book_utils_get_supported_fields ();
e_data_book_respond_get_supported_fields (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ NULL /* Success */,
fields);
g_list_free (fields);
}
@@ -252,7 +252,7 @@ e_book_backend_mapi_gal_get_required_fields (EBookBackend *backend,
fields = g_list_append (fields, (gchar *) e_contact_field_name (E_CONTACT_FILE_AS));
e_data_book_respond_get_required_fields (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ NULL /* Success */,
fields);
g_list_free (fields);
}
@@ -273,14 +273,14 @@ e_book_backend_mapi_gal_authenticate_user (EBookBackend *backend,
}
switch (priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL:
+ case E_DATA_BOOK_MODE_LOCAL:
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_set_is_writable (E_BOOK_BACKEND(backend), FALSE);
e_book_backend_notify_connection_status (backend, FALSE);
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_authenticate_user (book, opid, NULL /* Success */);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE:
+ case E_DATA_BOOK_MODE_REMOTE:
g_static_mutex_lock (&priv->running_mutex);
/* rather reuse already established connection */
@@ -291,7 +291,7 @@ e_book_backend_mapi_gal_authenticate_user (EBookBackend *backend,
priv->conn = exchange_mapi_connection_new (priv->profile, passwd);
if (!priv->conn) {
- e_data_book_respond_authenticate_user (book, opid,GNOME_Evolution_Addressbook_OtherError);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR_EX (OTHER_ERROR, "Cannot connect"));
g_static_mutex_unlock (&priv->running_mutex);
return;
}
@@ -309,7 +309,7 @@ e_book_backend_mapi_gal_authenticate_user (EBookBackend *backend,
}
}
e_book_backend_set_is_writable (backend, FALSE);
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_authenticate_user (book, opid, NULL /* Success */);
g_static_mutex_unlock (&priv->running_mutex);
return;
@@ -351,7 +351,7 @@ e_book_backend_mapi_gal_create_contact (EBookBackend *backend,
const gchar *vcard)
{
e_data_book_respond_create (book, opid,
- GNOME_Evolution_Addressbook_PermissionDenied,
+ EDB_ERROR (PERMISSION_DENIED),
NULL);
}
@@ -362,7 +362,7 @@ e_book_backend_mapi_gal_remove_contacts (EBookBackend *backend,
GList *ids)
{
e_data_book_respond_remove_contacts (book, opid,
- GNOME_Evolution_Addressbook_PermissionDenied,
+ EDB_ERROR (PERMISSION_DENIED),
NULL);
}
@@ -373,14 +373,15 @@ e_book_backend_mapi_gal_modify_contact (EBookBackend *backend,
const gchar *vcard)
{
e_data_book_respond_modify (book, opid,
- GNOME_Evolution_Addressbook_PermissionDenied,
+ EDB_ERROR (PERMISSION_DENIED),
NULL);
}
-static GNOME_Evolution_Addressbook_CallStatus
+static void
e_book_backend_mapi_gal_load_source (EBookBackend *backend,
ESource *source,
- gboolean only_if_exists)
+ gboolean only_if_exists,
+ GError **perror)
{
EBookBackendMAPIGALPrivate *priv = ((EBookBackendMAPIGAL *) backend)->priv;
const gchar *offline, *tmp;
@@ -389,7 +390,7 @@ e_book_backend_mapi_gal_load_source (EBookBackend *backend,
printf("MAPI load source\n");
if (e_book_backend_is_loaded (backend))
- return GNOME_Evolution_Addressbook_Success;
+ return /* Success */;
offline = e_source_get_property (source, "offline_sync");
if (offline && g_str_equal (offline, "1"))
@@ -399,9 +400,10 @@ e_book_backend_mapi_gal_load_source (EBookBackend *backend,
priv->uri = e_source_get_uri (source);
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL &&
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL &&
!priv->marked_for_offline ) {
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
}
g_free (priv->summary_file_name);
@@ -430,13 +432,14 @@ e_book_backend_mapi_gal_load_source (EBookBackend *backend,
e_book_backend_set_is_loaded (E_BOOK_BACKEND (backend), TRUE);
e_book_backend_set_is_writable (backend, FALSE);
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL) {
e_book_backend_set_is_writable (backend, FALSE);
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_notify_connection_status (backend, FALSE);
if (!priv->cache) {
printf("Unfortunately the cache is not yet created\n");
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
}
} else {
e_book_backend_notify_connection_status (backend, TRUE);
@@ -448,8 +451,8 @@ e_book_backend_mapi_gal_load_source (EBookBackend *backend,
tmp = e_source_get_property (source, "folder-id");
/* Once aunthentication in address book works this can be removed */
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
- return GNOME_Evolution_Addressbook_Success;
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL) {
+ return /* Success */;
}
// writable property will be set in authenticate_user callback
@@ -458,12 +461,10 @@ e_book_backend_mapi_gal_load_source (EBookBackend *backend,
if (enable_debug)
printf("For profile %s and folder %s - %016" G_GINT64_MODIFIER "X\n", priv->profile, tmp, priv->fid);
-
- return GNOME_Evolution_Addressbook_Success;
}
static void
-e_book_backend_mapi_gal_set_mode (EBookBackend *backend, GNOME_Evolution_Addressbook_BookMode mode)
+e_book_backend_mapi_gal_set_mode (EBookBackend *backend, EDataBookMode mode)
{
EBookBackendMAPIGALPrivate *priv = ((EBookBackendMAPIGAL *) backend)->priv;
@@ -472,13 +473,13 @@ e_book_backend_mapi_gal_set_mode (EBookBackend *backend, GNOME_Evolution_Address
priv->mode = mode;
if (e_book_backend_is_loaded (backend)) {
- if (mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
+ if (mode == E_DATA_BOOK_MODE_LOCAL) {
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_set_is_writable (backend, FALSE);
e_book_backend_notify_connection_status (backend, FALSE);
/* FIXME: Uninitialize mapi here. may be.*/
}
- else if (mode == GNOME_Evolution_Addressbook_MODE_REMOTE) {
+ else if (mode == E_DATA_BOOK_MODE_REMOTE) {
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_set_is_writable (backend, FALSE);
e_book_backend_notify_connection_status (backend, TRUE);
@@ -625,11 +626,12 @@ book_view_thread (gpointer data)
e_book_backend_add_book_view (E_BOOK_BACKEND (backend), book_view);
switch (priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_REMOTE:
+ case E_DATA_BOOK_MODE_REMOTE:
if (!priv->conn) {
+ GError *err = EDB_ERROR (AUTHENTICATION_REQUIRED);
e_book_backend_notify_auth_required (E_BOOK_BACKEND (backend));
- e_data_book_view_notify_complete (book_view,
- GNOME_Evolution_Addressbook_AuthenticationRequired);
+ e_data_book_view_notify_complete (book_view, err);
+ g_error_free (err);
untrack_book_view (backend, book_view);
destroy_closure (closure);
return;
@@ -689,7 +691,7 @@ book_view_thread (gpointer data)
break;
}
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
untrack_book_view (backend, book_view);
destroy_closure (closure);
}
@@ -703,7 +705,7 @@ e_book_backend_mapi_gal_get_contact (EBookBackend *backend,
if (enable_debug)
printf ("mapi: get contact %s\n", id);
- e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ e_data_book_respond_get_contact (book, opid, EDB_ERROR (NOT_SUPPORTED), NULL);
}
static void
@@ -717,10 +719,7 @@ e_book_backend_mapi_gal_get_contact_list (EBookBackend *backend,
if (enable_debug)
printf("mapi: get contact list %s\n", query);
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline,
- NULL);
-
- return;
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (NOT_SUPPORTED), NULL);
}
static void
@@ -753,7 +752,7 @@ e_book_backend_mapi_gal_get_changes (EBookBackend *backend, EDataBook *book, gui
if (enable_debug)
printf ("mapi: get changes\n");
- e_data_book_respond_get_changes (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ e_data_book_respond_get_changes (book, opid, EDB_ERROR (NOT_SUPPORTED), NULL);
}
static void
@@ -769,24 +768,24 @@ e_book_backend_mapi_gal_get_supported_auth_methods (EBookBackend *backend, EData
auth_methods = g_list_append (auth_methods, auth_method);
e_data_book_respond_get_supported_auth_methods (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ NULL /* Success */,
auth_methods);
g_free (auth_method);
g_list_free (auth_methods);
}
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_mapi_gal_cancel_operation (EBookBackend *backend, EDataBook *book)
+static void
+e_book_backend_mapi_gal_cancel_operation (EBookBackend *backend, EDataBook *book, GError **perror)
{
if (enable_debug)
printf ("mapi cancel_operation...\n");
- return GNOME_Evolution_Addressbook_CouldNotCancel;
+ g_propagate_error (perror, EDB_ERROR (COULD_NOT_CANCEL));
}
static void
e_book_backend_mapi_gal_remove (EBookBackend *backend, EDataBook *book, guint32 opid)
{
- e_data_book_respond_remove (book, opid, GNOME_Evolution_Addressbook_PermissionDenied);
+ e_data_book_respond_remove (book, opid, EDB_ERROR (PERMISSION_DENIED));
}
static void
diff --git a/src/addressbook/e-book-backend-mapi-utils.h b/src/addressbook/e-book-backend-mapi-utils.h
index 52a2ece..eb02462 100644
--- a/src/addressbook/e-book-backend-mapi-utils.h
+++ b/src/addressbook/e-book-backend-mapi-utils.h
@@ -23,6 +23,9 @@
#include "exchange-mapi-connection.h"
+#define EDB_ERROR(_code) e_data_book_create_error (E_DATA_BOOK_STATUS_ ## _code, NULL)
+#define EDB_ERROR_EX(_code, _msg) e_data_book_create_error (E_DATA_BOOK_STATUS_ ## _code, _msg)
+
/* vCard parameter name in contact list */
#define EMA_X_MEMBERID "X-EMA-MEMBER-ID"
#define EMA_X_MEMBERVALUE "X-EMA-MEMBER-VALUE"
diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index 4b242a1..385d7ef 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -247,10 +247,11 @@ get_filename_from_uri (const gchar *uri, const gchar *file)
return filename;
}
-static GNOME_Evolution_Addressbook_CallStatus
+static void
e_book_backend_mapi_load_source (EBookBackend *backend,
ESource *source,
- gboolean only_if_exists)
+ gboolean only_if_exists,
+ GError **perror)
{
EBookBackendMAPIPrivate *priv = ((EBookBackendMAPI *) backend)->priv;
const gchar *offline, *tmp;
@@ -259,7 +260,7 @@ e_book_backend_mapi_load_source (EBookBackend *backend,
printf("MAPI load source\n");
if (e_book_backend_is_loaded (backend))
- return GNOME_Evolution_Addressbook_Success;
+ return /* Success */;
offline = e_source_get_property (source, "offline_sync");
if (offline && g_str_equal (offline, "1"))
@@ -269,9 +270,10 @@ e_book_backend_mapi_load_source (EBookBackend *backend,
priv->uri = e_source_get_uri (source);
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL &&
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL &&
!priv->marked_for_offline ) {
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
}
g_free (priv->summary_file_name);
@@ -297,13 +299,14 @@ e_book_backend_mapi_load_source (EBookBackend *backend,
e_book_backend_set_is_loaded (E_BOOK_BACKEND (backend), TRUE);
e_book_backend_set_is_writable (backend, TRUE);
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL) {
e_book_backend_set_is_writable (backend, FALSE);
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_notify_connection_status (backend, FALSE);
if (!priv->cache) {
printf("Unfortunately the cache is not yet created\n");
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
}
} else {
e_book_backend_notify_connection_status (backend, TRUE);
@@ -316,8 +319,8 @@ e_book_backend_mapi_load_source (EBookBackend *backend,
printf("Folder is %s %016" G_GINT64_MODIFIER "X\n", tmp, priv->fid);
/* Once aunthentication in address book works this can be removed */
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
- return GNOME_Evolution_Addressbook_Success;
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL) {
+ return /* Success */;
}
// writable property will be set in authenticate_user callback
@@ -326,8 +329,6 @@ e_book_backend_mapi_load_source (EBookBackend *backend,
if (enable_debug)
printf("For profile %s and folder %s - %016" G_GINT64_MODIFIER "X\n", priv->profile, tmp, priv->fid);
-
- return GNOME_Evolution_Addressbook_Success;
}
static gchar *
@@ -706,11 +707,11 @@ e_book_backend_mapi_create_contact (EBookBackend *backend,
switch (priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
- e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
- return;
+ case E_DATA_BOOK_MODE_LOCAL:
+ e_data_book_respond_create(book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
+ break;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case E_DATA_BOOK_MODE_REMOTE:
contact = e_contact_new_from_vcard(vcard);
mcd.contact = contact;
mcd.cache = priv->cache;
@@ -718,7 +719,7 @@ e_book_backend_mapi_create_contact (EBookBackend *backend,
mapi_book_write_props, &mcd,
NULL, NULL, NULL, 0);
if (!status) {
- e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_create(book, opid, EDB_ERROR (OTHER_ERROR), NULL);
return;
}
id = exchange_mapi_util_mapi_ids_to_uid (priv->fid, status);
@@ -735,11 +736,9 @@ e_book_backend_mapi_create_contact (EBookBackend *backend,
if (priv->marked_for_offline && priv->is_summary_ready)
e_book_backend_summary_add_contact (priv->summary, contact);
- e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_Success, contact);
- return;
+ e_data_book_respond_create(book, opid, NULL /* Success */, contact);
+ break;
}
-
- return;
}
static void
@@ -758,12 +757,11 @@ e_book_backend_mapi_remove_contacts (EBookBackend *backend,
switch (priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
- e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
- return;
-
- case GNOME_Evolution_Addressbook_MODE_REMOTE:
+ case E_DATA_BOOK_MODE_LOCAL:
+ e_data_book_respond_remove_contacts (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
+ break;
+ case E_DATA_BOOK_MODE_REMOTE:
while (tmp) {
struct id_list *data = g_new (struct id_list, 1);
exchange_mapi_util_mapi_ids_from_uid (tmp->data, &fid, &mid);
@@ -790,9 +788,8 @@ e_book_backend_mapi_remove_contacts (EBookBackend *backend,
}
g_slist_free (list);
- e_data_book_respond_remove_contacts (book, opid,
- GNOME_Evolution_Addressbook_Success, id_list);
- return;
+ e_data_book_respond_remove_contacts (book, opid, NULL /* Success */, id_list);
+ break;
default:
break;
}
@@ -816,10 +813,10 @@ e_book_backend_mapi_modify_contact (EBookBackend *backend,
switch (priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
- e_data_book_respond_modify(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
- return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case E_DATA_BOOK_MODE_LOCAL:
+ e_data_book_respond_modify (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
+ break;
+ case E_DATA_BOOK_MODE_REMOTE:
contact = e_contact_new_from_vcard(vcard);
tmp = e_contact_get (contact, E_CONTACT_UID);
exchange_mapi_util_mapi_ids_from_uid (tmp, &fid, &mid);
@@ -832,8 +829,8 @@ e_book_backend_mapi_modify_contact (EBookBackend *backend,
NULL, NULL, NULL, 0);
printf("getting %d\n", status);
if (!status) {
- e_data_book_respond_modify(book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
- return;
+ e_data_book_respond_modify (book, opid, EDB_ERROR (OTHER_ERROR), NULL);
+ break;
}
e_contact_set (contact, E_CONTACT_BOOK_URI, priv->uri);
@@ -851,7 +848,7 @@ e_book_backend_mapi_modify_contact (EBookBackend *backend,
if (priv->marked_for_offline && priv->is_summary_ready)
e_book_backend_summary_add_contact (priv->summary, contact);
- e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_Success, contact);
+ e_data_book_respond_modify (book, opid, NULL /* Success */, contact);
}
}
@@ -900,7 +897,7 @@ e_book_backend_mapi_get_contact (EBookBackend *backend,
switch (priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL:
+ case E_DATA_BOOK_MODE_LOCAL:
contact = e_book_backend_cache_get_contact (priv->cache,
id);
if (contact) {
@@ -908,18 +905,18 @@ e_book_backend_mapi_get_contact (EBookBackend *backend,
EVC_FORMAT_VCARD_30);
e_data_book_respond_get_contact (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ NULL /* Success */,
vcard);
g_free (vcard);
g_object_unref (contact);
return;
}
else {
- e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_ContactNotFound, "");
+ e_data_book_respond_get_contact (book, opid, EDB_ERROR (CONTACT_NOT_FOUND), "");
return;
}
- case GNOME_Evolution_Addressbook_MODE_REMOTE:
+ case E_DATA_BOOK_MODE_REMOTE:
if (priv->marked_for_offline && e_book_backend_cache_is_populated (priv->cache)) {
contact = e_book_backend_cache_get_contact (priv->cache,
@@ -929,14 +926,14 @@ e_book_backend_mapi_get_contact (EBookBackend *backend,
EVC_FORMAT_VCARD_30);
e_data_book_respond_get_contact (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ NULL /* Success */,
vcard);
g_free (vcard);
g_object_unref (contact);
return;
}
else {
- e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_ContactNotFound, "");
+ e_data_book_respond_get_contact (book, opid, EDB_ERROR (CONTACT_NOT_FOUND), "");
return;
}
@@ -955,14 +952,14 @@ e_book_backend_mapi_get_contact (EBookBackend *backend,
EVC_FORMAT_VCARD_30);
e_data_book_respond_get_contact (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ NULL /* Success */,
vcard);
g_free (vcard);
g_object_unref (contact);
return;
} else {
- e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_ContactNotFound, "");
+ e_data_book_respond_get_contact (book, opid, EDB_ERROR (CONTACT_NOT_FOUND), "");
return;
}
}
@@ -1021,7 +1018,7 @@ e_book_backend_mapi_get_contact_list (EBookBackend *backend,
printf("mapi: get contact list %s\n", query);
switch (priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL:
+ case E_DATA_BOOK_MODE_LOCAL:
if (priv->marked_for_offline && priv->cache) {
GList *contacts;
GList *vcard_strings = NULL;
@@ -1038,14 +1035,14 @@ e_book_backend_mapi_get_contact_list (EBookBackend *backend,
g_list_free (contacts);
printf("get_contact_list in %s returning %d contacts\n", priv->uri, g_list_length (vcard_strings));
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_Success, vcard_strings);
+ e_data_book_respond_get_contact_list (book, opid, NULL /* Success */, vcard_strings);
return;
}
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline,
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (REPOSITORY_OFFLINE),
NULL);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE:
+ case E_DATA_BOOK_MODE_REMOTE:
printf("Mode : Remote\n");
if (priv->marked_for_offline && priv->cache) {
GList *contacts;
@@ -1063,7 +1060,7 @@ e_book_backend_mapi_get_contact_list (EBookBackend *backend,
g_list_free (contacts);
printf("get_contact_list in %s returning %d contacts\n", priv->uri, g_list_length (vcard_strings));
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_Success, vcard_strings);
+ e_data_book_respond_get_contact_list (book, opid, NULL /* Success */, vcard_strings);
return;
}
else {
@@ -1075,7 +1072,7 @@ e_book_backend_mapi_get_contact_list (EBookBackend *backend,
/* Unfortunately MAPI Doesn't support searching well, we do allow only online search for emails rest all are returned as error. */
if (!no_summary_search && !build_restriction_emails_contains (&res, query)) {
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (OTHER_ERROR), NULL);
return;
}
@@ -1083,11 +1080,11 @@ e_book_backend_mapi_get_contact_list (EBookBackend *backend,
is_public ? NULL : mapi_book_utils_get_prop_list, GET_ALL_KNOWN_IDS,
create_contact_list_cb, &vcard_str,
options)) {
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (OTHER_ERROR), NULL);
return;
}
printf("get_contact_list in %s returning %d contacts\n", priv->uri, g_list_length (vcard_str));
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_Success, vcard_str);
+ e_data_book_respond_get_contact_list (book, opid, NULL /* Success */, vcard_str);
return;
}
@@ -1221,7 +1218,8 @@ book_view_thread (gpointer data)
guint res_count = 6;
ESource *source;
guint32 options = MAPI_OPTIONS_FETCH_ALL;
- gboolean is_public = FALSE;
+ gboolean is_public = FALSE;
+ GError *err = NULL;
source = e_book_backend_get_source(E_BOOK_BACKEND(backend));
if (strcmp (e_source_get_property(source, "public"), "yes") == 0 ) {
@@ -1237,18 +1235,18 @@ book_view_thread (gpointer data)
switch (priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL:
+ case E_DATA_BOOK_MODE_LOCAL:
if (!priv->marked_for_offline) {
- e_data_book_view_notify_complete (book_view,
- GNOME_Evolution_Addressbook_OfflineUnavailable);
+ err = EDB_ERROR (OFFLINE_UNAVAILABLE);
+ e_data_book_view_notify_complete (book_view, err);
+ g_error_free (err);
untrack_book_view (backend, book_view);
destroy_closure (closure);
return;
}
if (!priv->cache) {
printf("The cache is not yet built\n");
- e_data_book_view_notify_complete (book_view,
- GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
untrack_book_view (backend, book_view);
destroy_closure (closure);
return;
@@ -1285,19 +1283,20 @@ book_view_thread (gpointer data)
E_CONTACT(contacts->data));
g_object_unref (contacts->data);
}
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
if (temp_list)
g_list_free (temp_list);
untrack_book_view (backend, book_view);
destroy_closure (closure);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE:
+ case E_DATA_BOOK_MODE_REMOTE:
if (!priv->conn || !exchange_mapi_connection_connected (priv->conn)) {
e_book_backend_notify_auth_required (E_BOOK_BACKEND (backend));
- e_data_book_view_notify_complete (book_view,
- GNOME_Evolution_Addressbook_AuthenticationRequired);
+ err = EDB_ERROR (AUTHENTICATION_REQUIRED);
+ e_data_book_view_notify_complete (book_view, err);
+ g_error_free (err);
untrack_book_view (backend, book_view);
destroy_closure (closure);
return;
@@ -1334,7 +1333,7 @@ book_view_thread (gpointer data)
E_CONTACT(contacts->data));
g_object_unref (contacts->data);
}
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
if (temp_list)
g_list_free (temp_list);
untrack_book_view (backend, book_view);
@@ -1349,8 +1348,9 @@ book_view_thread (gpointer data)
or_res = g_new0 (struct mapi_SRestriction_or, res_count);
if (!build_multiple_restriction_emails_contains (priv->conn, priv->fid, &res, or_res, query, &to_free)) {
- e_data_book_view_notify_complete (book_view,
- GNOME_Evolution_Addressbook_OtherError);
+ err = EDB_ERROR_EX (OTHER_ERROR, "Cannot build query based on email");
+ e_data_book_view_notify_complete (book_view, err);
+ g_error_free (err);
g_free (or_res);
g_free (to_free);
untrack_book_view (backend, book_view);
@@ -1363,7 +1363,9 @@ book_view_thread (gpointer data)
is_public ? NULL : mapi_book_utils_get_prop_list, GET_SHORT_SUMMARY,
create_contact_cb, closure,
options)) {
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_OtherError);
+ err = EDB_ERROR (OTHER_ERROR);
+ e_data_book_view_notify_complete (book_view, err);
+ g_error_free (err);
if (or_res)
g_free(or_res);
@@ -1380,14 +1382,16 @@ book_view_thread (gpointer data)
is_public ? NULL : mapi_book_utils_get_prop_list, GET_ALL_KNOWN_IDS,
create_contact_cb, closure,
options)) {
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_OtherError);
+ err = EDB_ERROR (OTHER_ERROR);
+ e_data_book_view_notify_complete (book_view, err);
+ g_error_free (err);
untrack_book_view (backend, book_view);
destroy_closure (closure);
return;
}
}
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
default:
break;
}
@@ -1432,7 +1436,7 @@ e_book_backend_mapi_get_changes (EBookBackend *backend,
if (enable_debug)
printf("mapi: get changes\n");
/* FIXME : provide implmentation */
- e_data_book_respond_get_changes (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ e_data_book_respond_get_changes (book, opid, EDB_ERROR (NOT_SUPPORTED), NULL);
}
static gboolean
@@ -1558,13 +1562,13 @@ e_book_backend_mapi_authenticate_user (EBookBackend *backend,
}
switch (priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL:
+ case E_DATA_BOOK_MODE_LOCAL:
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_notify_connection_status (backend, FALSE);
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_authenticate_user (book, opid, NULL /* Success */);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE:
+ case E_DATA_BOOK_MODE_REMOTE:
g_static_mutex_lock (&priv->running_mutex);
/* rather reuse already established connection */
@@ -1575,7 +1579,7 @@ e_book_backend_mapi_authenticate_user (EBookBackend *backend,
priv->conn = exchange_mapi_connection_new (priv->profile, passwd);
if (!priv->conn) {
- e_data_book_respond_authenticate_user (book, opid,GNOME_Evolution_Addressbook_OtherError);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR_EX (OTHER_ERROR, "Cannot connect"));
g_static_mutex_unlock (&priv->running_mutex);
return;
}
@@ -1590,7 +1594,7 @@ e_book_backend_mapi_authenticate_user (EBookBackend *backend,
g_thread_create ((GThreadFunc) build_cache, backend, FALSE, NULL);
}
e_book_backend_set_is_writable (backend, TRUE);
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_authenticate_user (book, opid, NULL /* Success */);
g_static_mutex_unlock (&priv->running_mutex);
return;
@@ -1611,7 +1615,7 @@ e_book_backend_mapi_get_required_fields (EBookBackend *backend,
fields = g_list_append (fields, (gchar *)e_contact_field_name (E_CONTACT_FILE_AS));
e_data_book_respond_get_supported_fields (book, opid,
- GNOME_Evolution_Addressbook_Success,
+ NULL /* Success */,
fields);
g_list_free (fields);
}
@@ -1628,7 +1632,7 @@ e_book_backend_mapi_get_supported_fields (EBookBackend *backend,
fields = mapi_book_utils_get_supported_fields ();
e_data_book_respond_get_supported_fields (book, opid,
- GNOME_Evolution_Addressbook_Success,
+ NULL /* Success */,
fields);
g_list_free (fields);
@@ -1647,18 +1651,18 @@ e_book_backend_mapi_get_supported_auth_methods (EBookBackend *backend, EDataBook
auth_methods = g_list_append (auth_methods, auth_method);
e_data_book_respond_get_supported_auth_methods (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ NULL /* Success */,
auth_methods);
g_free (auth_method);
g_list_free (auth_methods);
}
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_mapi_cancel_operation (EBookBackend *backend, EDataBook *book)
+static void
+e_book_backend_mapi_cancel_operation (EBookBackend *backend, EDataBook *book, GError **perror)
{
if (enable_debug)
printf ("mapi cancel_operation...\n");
- return GNOME_Evolution_Addressbook_CouldNotCancel;
+ g_propagate_error (perror, EDB_ERROR (COULD_NOT_CANCEL));
}
static void
@@ -1676,17 +1680,17 @@ e_book_backend_mapi_remove (EBookBackend *backend,
switch (priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL:
- e_data_book_respond_remove (book, opid, GNOME_Evolution_Addressbook_OfflineUnavailable);
+ case E_DATA_BOOK_MODE_LOCAL:
+ e_data_book_respond_remove (book, opid, EDB_ERROR (OFFLINE_UNAVAILABLE));
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE:
+ case E_DATA_BOOK_MODE_REMOTE:
if (strcmp (e_source_get_property(source, "public"), "yes") != 0)
status = exchange_mapi_connection_remove_folder (priv->conn, priv->fid, 0);
if (!status) {
- e_data_book_respond_remove (book, opid, GNOME_Evolution_Addressbook_OtherError);
+ e_data_book_respond_remove (book, opid, EDB_ERROR (OTHER_ERROR));
return;
}
@@ -1715,7 +1719,7 @@ e_book_backend_mapi_remove (EBookBackend *backend,
}
g_free (cache_uri);
- e_data_book_respond_remove (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_remove (book, opid, NULL /* Success */);
return;
default:
@@ -1728,7 +1732,7 @@ e_book_backend_mapi_remove (EBookBackend *backend,
}
static void
-e_book_backend_mapi_set_mode (EBookBackend *backend, GNOME_Evolution_Addressbook_BookMode mode)
+e_book_backend_mapi_set_mode (EBookBackend *backend, EDataBookMode mode)
{
EBookBackendMAPIPrivate *priv = ((EBookBackendMAPI *) backend)->priv;
@@ -1737,12 +1741,12 @@ e_book_backend_mapi_set_mode (EBookBackend *backend, GNOME_Evolution_Addressbook
priv->mode = mode;
if (e_book_backend_is_loaded (backend)) {
- if (mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
+ if (mode == E_DATA_BOOK_MODE_LOCAL) {
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_notify_connection_status (backend, FALSE);
/* FIXME: Uninitialize mapi here. may be.*/
}
- else if (mode == GNOME_Evolution_Addressbook_MODE_REMOTE) {
+ else if (mode == E_DATA_BOOK_MODE_REMOTE) {
e_book_backend_notify_writable (backend, TRUE);
e_book_backend_notify_connection_status (backend, TRUE);
e_book_backend_notify_auth_required (backend); //FIXME: WTH is this required.
diff --git a/src/calendar/e-cal-backend-mapi.c b/src/calendar/e-cal-backend-mapi.c
index 323568c..535c9d2 100644
--- a/src/calendar/e-cal-backend-mapi.c
+++ b/src/calendar/e-cal-backend-mapi.c
@@ -49,6 +49,9 @@
#define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
#endif
+#define EDC_ERROR(_code) e_data_cal_create_error (_code, NULL)
+#define EDC_ERROR_EX(_code, _msg) e_data_cal_create_error (_code, _msg)
+
G_DEFINE_TYPE (ECalBackendMAPI, e_cal_backend_mapi, E_TYPE_CAL_BACKEND_SYNC)
typedef struct {
@@ -100,8 +103,8 @@ static ECalBackendClass *parent_class = NULL;
static GStaticMutex auth_mutex = G_STATIC_MUTEX_INIT;
-static ECalBackendSyncStatus
-e_cal_backend_mapi_authenticate (ECalBackend *backend)
+static gboolean
+e_cal_backend_mapi_authenticate (ECalBackend *backend, GError **perror)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
@@ -120,11 +123,13 @@ e_cal_backend_mapi_authenticate (ECalBackend *backend)
priv->conn = exchange_mapi_connection_new (priv->profile, priv->password);
if (priv->conn && exchange_mapi_connection_connected (priv->conn)) {
- return GNOME_Evolution_Calendar_Success;
+ /* Success */;
} else {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbmapi), _("Authentication failed"));
- return GNOME_Evolution_Calendar_AuthenticationFailed;
+ g_propagate_error (perror, EDC_ERROR (AuthenticationFailed));
+ return FALSE;
}
+
+ return TRUE;
}
/***** OBJECT CLASS FUNCTIONS *****/
@@ -248,8 +253,8 @@ e_cal_backend_mapi_finalize (GObject *object)
}
/***** SYNC CLASS FUNCTIONS *****/
-static ECalBackendSyncStatus
-e_cal_backend_mapi_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
+static void
+e_cal_backend_mapi_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only, GError **perror)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
@@ -258,12 +263,10 @@ e_cal_backend_mapi_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboole
priv = cbmapi->priv;
*read_only = priv->read_only;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+static void
+e_cal_backend_mapi_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
@@ -272,31 +275,25 @@ e_cal_backend_mapi_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gch
priv = cbmapi->priv;
*address = g_strdup (priv->user_email);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+static void
+e_cal_backend_mapi_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
{
/* We don't support email alarms. This should not have been called. */
*address = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute)
+static void
+e_cal_backend_mapi_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute, GError **perror)
{
/* This is just a hack for SunONE */
*attribute = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities)
+static void
+e_cal_backend_mapi_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities, GError **perror)
{
/* FIXME: what else ? */
@@ -329,16 +326,13 @@ e_cal_backend_mapi_get_static_capabilities (ECalBackendSync *backend, EDataCal *
// CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY ","
CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING
);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_remove (ECalBackendSync *backend, EDataCal *cal)
+static void
+e_cal_backend_mapi_remove (ECalBackendSync *backend, EDataCal *cal, GError **perror)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
- gboolean status = TRUE;
ESource *source = NULL;
cbmapi = E_CAL_BACKEND_MAPI (backend);
@@ -346,12 +340,16 @@ e_cal_backend_mapi_remove (ECalBackendSync *backend, EDataCal *cal)
source = e_cal_backend_get_source (E_CAL_BACKEND (cbmapi));
- if (priv->mode == CAL_MODE_LOCAL || !priv->conn || !exchange_mapi_connection_connected (priv->conn))
- return GNOME_Evolution_Calendar_RepositoryOffline;
- if (strcmp (e_source_get_property (source, "public"), "yes") != 0)
- status = exchange_mapi_connection_remove_folder (priv->conn, priv->fid, 0);
- if (!status)
- return GNOME_Evolution_Calendar_OtherError;
+ if (priv->mode == CAL_MODE_LOCAL || !priv->conn || !exchange_mapi_connection_connected (priv->conn)) {
+ g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
+ return;
+ }
+ if (strcmp (e_source_get_property (source, "public"), "yes") != 0) {
+ if (!exchange_mapi_connection_remove_folder (priv->conn, priv->fid, 0)) {
+ g_propagate_error (perror, EDC_ERROR (OtherError));
+ return;
+ }
+ }
g_mutex_lock (priv->mutex);
@@ -360,10 +358,6 @@ e_cal_backend_mapi_remove (ECalBackendSync *backend, EDataCal *cal)
e_file_cache_remove (E_FILE_CACHE (priv->cache));
g_mutex_unlock (priv->mutex);
-
- /* anything else ? */
-
- return GNOME_Evolution_Calendar_Success;
}
#if 0
@@ -768,7 +762,7 @@ get_deltas (gpointer handle)
}
// e_file_cache_thaw_changes (E_FILE_CACHE (priv->cache));
- e_cal_backend_notify_view_done (E_CAL_BACKEND (cbmapi), GNOME_Evolution_Calendar_Success);
+ e_cal_backend_notify_view_done (E_CAL_BACKEND (cbmapi), NULL /* Success */);
time_string = g_strdup (t_str);
e_cal_backend_cache_put_server_utc_time (priv->cache, time_string);
@@ -894,8 +888,8 @@ get_deltas (gpointer handle)
return TRUE;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object)
+static void
+e_cal_backend_mapi_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object, GError **perror)
{
ECalComponent *comp;
@@ -913,24 +907,23 @@ e_cal_backend_mapi_get_default_object (ECalBackendSync *backend, EDataCal *cal,
break;
default:
g_object_unref (comp);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
+ return;
}
*object = e_cal_component_get_as_string (comp);
g_object_unref (comp);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object)
+static void
+e_cal_backend_mapi_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object, GError **error)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
ECalComponent *comp;
cbmapi = (ECalBackendMAPI *)(backend);
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
priv = cbmapi->priv;
@@ -949,17 +942,16 @@ e_cal_backend_mapi_get_object (ECalBackendSync *backend, EDataCal *cal, const gc
g_object_unref (comp);
- return *object ? GNOME_Evolution_Calendar_Success : GNOME_Evolution_Calendar_ObjectNotFound;
+ } else {
+ g_mutex_unlock (priv->mutex);
}
- g_mutex_unlock (priv->mutex);
-
- /* callers will never have a uid that is in server but not in cache */
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ if (!object || !*object)
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects)
+static void
+e_cal_backend_mapi_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects, GError **perror)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
@@ -981,7 +973,8 @@ e_cal_backend_mapi_get_object_list (ECalBackendSync *backend, EDataCal *cal, con
if (!cbsexp) {
g_mutex_unlock (priv->mutex);
- return GNOME_Evolution_Calendar_InvalidQuery;
+ g_propagate_error (perror, EDC_ERROR (InvalidQuery));
+ return;
}
*objects = NULL;
@@ -1002,15 +995,13 @@ e_cal_backend_mapi_get_object_list (ECalBackendSync *backend, EDataCal *cal, con
g_list_foreach (components, (GFunc) g_object_unref, NULL);
g_list_free (components);
g_mutex_unlock (priv->mutex);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, GSList **list)
+static void
+e_cal_backend_mapi_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, GSList **list, GError **perror)
{
/* TODO implement the function */
- return GNOME_Evolution_Calendar_Success;
+ g_propagate_error (perror, EDC_ERROR (NotSupported));
}
static guint
@@ -1037,7 +1028,7 @@ delta_thread (gpointer data)
GTimeVal timeout;
cbmapi = (ECalBackendMAPI *)(data);
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GINT_TO_POINTER (GNOME_Evolution_Calendar_OtherError));
+ g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), NULL);
priv = cbmapi->priv;
@@ -1073,7 +1064,7 @@ fetch_deltas (ECalBackendMAPI *cbmapi)
ECalBackendMAPIPrivate *priv;
GError *error = NULL;
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GNOME_Evolution_Calendar_OtherError);
+ g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), FALSE);
priv = cbmapi->priv;
@@ -1104,7 +1095,7 @@ start_fetch_deltas (gpointer data)
ECalBackendMAPIPrivate *priv;
cbmapi = (ECalBackendMAPI *)(data);
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GNOME_Evolution_Calendar_OtherError);
+ g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), FALSE);
priv = cbmapi->priv;
@@ -1176,8 +1167,8 @@ mapi_cal_cache_create_cb (FetchItemsCallbackData *item_data, gpointer data)
return TRUE;
}
-static ECalBackendSyncStatus
-populate_cache (ECalBackendMAPI *cbmapi)
+static gboolean
+populate_cache (ECalBackendMAPI *cbmapi, GError **perror)
{
ECalBackendMAPIPrivate *priv;
ESource *source = NULL;
@@ -1194,7 +1185,7 @@ populate_cache (ECalBackendMAPI *cbmapi)
g_mutex_lock (priv->mutex);
if (priv->populating_cache) {
g_mutex_unlock (priv->mutex);
- return GNOME_Evolution_Calendar_Success;
+ return TRUE; /* Success */
}
priv->populating_cache = TRUE;
g_mutex_unlock (priv->mutex);
@@ -1221,12 +1212,12 @@ populate_cache (ECalBackendMAPI *cbmapi)
is_public ? NULL : mapi_cal_get_known_ids, NULL,
mapi_cal_cache_create_cb, cbmapi,
options)) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbmapi), _("Could not create cache file"));
e_file_cache_thaw_changes (E_FILE_CACHE (priv->cache));
g_mutex_lock (priv->mutex);
priv->populating_cache = FALSE;
g_mutex_unlock (priv->mutex);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, _("Could not create cache file")));
+ return FALSE;
}
} else {
if (strcmp (e_source_get_property(source, "public"), "yes") ==0 ) {
@@ -1238,17 +1229,17 @@ populate_cache (ECalBackendMAPI *cbmapi)
is_public ? NULL : exchange_mapi_cal_utils_get_props_cb, GINT_TO_POINTER (kind),
mapi_cal_cache_create_cb, cbmapi,
options)) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbmapi), _("Could not create cache file"));
e_file_cache_thaw_changes (E_FILE_CACHE (priv->cache));
g_mutex_lock (priv->mutex);
priv->populating_cache = FALSE;
g_mutex_unlock (priv->mutex);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, _("Could not create cache file")));
+ return FALSE;
}
}
// e_file_cache_thaw_changes (E_FILE_CACHE (priv->cache));
- e_cal_backend_notify_view_done (E_CAL_BACKEND (cbmapi), GNOME_Evolution_Calendar_Success);
+ e_cal_backend_notify_view_done (E_CAL_BACKEND (cbmapi), NULL /* Success */);
time_string = g_strdup (t_str);
e_cal_backend_cache_put_server_utc_time (priv->cache, time_string);
@@ -1260,7 +1251,7 @@ populate_cache (ECalBackendMAPI *cbmapi)
priv->populating_cache = FALSE;
g_mutex_unlock (priv->mutex);
- return GNOME_Evolution_Calendar_Success;
+ return TRUE;
}
static gpointer
@@ -1268,7 +1259,6 @@ cache_init (ECalBackendMAPI *cbmapi)
{
ECalBackendMAPIPrivate *priv = cbmapi->priv;
icalcomponent_kind kind;
- ECalBackendSyncStatus status;
kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbmapi));
@@ -1276,11 +1266,10 @@ cache_init (ECalBackendMAPI *cbmapi)
if (!e_cal_backend_cache_get_marker (priv->cache)) {
/* Populate the cache for the first time.*/
- status = populate_cache (cbmapi);
- if (status != GNOME_Evolution_Calendar_Success) {
+ if (!populate_cache (cbmapi, NULL)) {
g_warning (G_STRLOC ": Could not populate the cache");
/*FIXME why dont we do a notify here */
- return GINT_TO_POINTER(GNOME_Evolution_Calendar_PermissionDenied);
+ return NULL;
} else {
/* Set delta fetch timeout */
priv->timeout_id = g_timeout_add (get_cache_refresh_interval (), start_fetch_deltas, (gpointer) cbmapi);
@@ -1296,8 +1285,8 @@ cache_init (ECalBackendMAPI *cbmapi)
return NULL;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_connect (ECalBackendMAPI *cbmapi)
+static void
+e_cal_backend_mapi_connect (ECalBackendMAPI *cbmapi, GError **perror)
{
ECalBackendMAPIPrivate *priv;
ESource *source;
@@ -1307,14 +1296,16 @@ e_cal_backend_mapi_connect (ECalBackendMAPI *cbmapi)
priv = cbmapi->priv;
- if (!priv->fid)
- return GNOME_Evolution_Calendar_OtherError;
+ if (!priv->fid) {
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, "No folder ID set"));
+ return;
+ }
source = e_cal_backend_get_source (E_CAL_BACKEND (cbmapi));
if (!priv->conn || !exchange_mapi_connection_connected (priv->conn)) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbmapi), _("Authentication failed"));
- return GNOME_Evolution_Calendar_AuthenticationFailed;
+ g_propagate_error (perror, EDC_ERROR (AuthenticationFailed));
+ return;
}
/* We have established a connection */
@@ -1326,7 +1317,7 @@ e_cal_backend_mapi_connect (ECalBackendMAPI *cbmapi)
}
/* FIXME: put server UTC time in cache */
- return GNOME_Evolution_Calendar_Success;
+ return /* Success */;
}
priv->mode_changed = FALSE;
@@ -1348,8 +1339,8 @@ e_cal_backend_mapi_connect (ECalBackendMAPI *cbmapi)
priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbmapi)), source_type);
if (!priv->cache) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbmapi), _("Could not create cache file"));
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, _("Could not create cache file")));
+ return;
}
e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
@@ -1359,37 +1350,36 @@ e_cal_backend_mapi_connect (ECalBackendMAPI *cbmapi)
if (!thread) {
g_warning (G_STRLOC ": %s", error->message);
g_error_free (error);
- e_cal_backend_notify_error (E_CAL_BACKEND (cbmapi), _("Could not create thread for populating cache"));
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, _("Could not create thread for populating cache")));
}
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists, const gchar *username, const gchar *password)
+static void
+e_cal_backend_mapi_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists, const gchar *username, const gchar *password, GError **perror)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
- ECalBackendSyncStatus status;
ECalSourceType source_type;
ESource *esource;
const gchar *source = NULL, *fid = NULL;
gchar *filename;
gchar *mangled_uri;
gint i;
+ gboolean res;
uint32_t olFolder = 0;
if (e_cal_backend_is_loaded (E_CAL_BACKEND (backend)))
- return GNOME_Evolution_Calendar_Success;
+ return /* Success */;
cbmapi = E_CAL_BACKEND_MAPI (backend);
priv = cbmapi->priv;
esource = e_cal_backend_get_source (E_CAL_BACKEND (cbmapi));
fid = e_source_get_property (esource, "folder-id");
- if (!(fid && *fid))
- return GNOME_Evolution_Calendar_OtherError;
+ if (!(fid && *fid)) {
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, "No folder ID set"));
+ return;
+ }
g_mutex_lock (priv->mutex);
@@ -1425,7 +1415,8 @@ e_cal_backend_mapi_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
if (!display_contents || !g_str_equal (display_contents, "1")) {
g_mutex_unlock (priv->mutex);
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
+ return;
}
/* Cache created here for the first time */
@@ -1433,13 +1424,13 @@ e_cal_backend_mapi_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbmapi)), source_type);
if (!priv->cache) {
g_mutex_unlock (priv->mutex);
- e_cal_backend_notify_error (E_CAL_BACKEND (cbmapi), _("Could not create cache file"));
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, _("Could not create cache file")));
+ return;
}
}
e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
g_mutex_unlock (priv->mutex);
- return GNOME_Evolution_Calendar_Success;
+ return /* Success */;
}
priv->username = g_strdup (username);
@@ -1479,13 +1470,11 @@ e_cal_backend_mapi_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
g_mutex_unlock (priv->mutex);
g_static_mutex_lock (&auth_mutex);
- status = e_cal_backend_mapi_authenticate (E_CAL_BACKEND (cbmapi));
+ res = e_cal_backend_mapi_authenticate (E_CAL_BACKEND (cbmapi), perror);
g_static_mutex_unlock (&auth_mutex);
- if (status == GNOME_Evolution_Calendar_Success)
- return e_cal_backend_mapi_connect (cbmapi);
- else
- return status;
+ if (res)
+ e_cal_backend_mapi_connect (cbmapi, perror);
}
static gboolean
@@ -1582,8 +1571,8 @@ get_server_data (ECalBackendMAPI *cbmapi, icalcomponent *comp, struct cal_cbdata
static icaltimezone *e_cal_backend_mapi_internal_get_timezone (ECalBackend *backend, const gchar *tzid);
-static ECalBackendSyncStatus
-e_cal_backend_mapi_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid)
+static void
+e_cal_backend_mapi_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid, GError **error)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
@@ -1604,20 +1593,25 @@ e_cal_backend_mapi_create_object (ECalBackendSync *backend, EDataCal *cal, gchar
priv = cbmapi->priv;
kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GNOME_Evolution_Calendar_InvalidObject);
- g_return_val_if_fail (calobj != NULL && *calobj != NULL, GNOME_Evolution_Calendar_InvalidObject);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
+ e_return_data_cal_error_if_fail (calobj != NULL && *calobj != NULL, InvalidArg);
- if (priv->mode == CAL_MODE_LOCAL)
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ if (priv->mode == CAL_MODE_LOCAL) {
+ g_propagate_error (error, EDC_ERROR (RepositoryOffline));
+ return;
+ }
/* check the component for validity */
icalcomp = icalparser_parse_string (*calobj);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (!icalcomp) {
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
+ }
if (kind != icalcomponent_isa (icalcomp)) {
icalcomponent_free (icalcomp);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
}
comp = e_cal_component_new ();
@@ -1683,7 +1677,8 @@ e_cal_backend_mapi_create_object (ECalBackendSync *backend, EDataCal *cal, gchar
exchange_mapi_util_free_recipient_list (&recipients);
exchange_mapi_util_free_stream_list (&streams);
exchange_mapi_util_free_attachment_list (&attachments);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (error, EDC_ERROR (OtherError));
+ return;
}
tmp = exchange_mapi_util_mapi_id_to_string (mid);
@@ -1702,7 +1697,8 @@ e_cal_backend_mapi_create_object (ECalBackendSync *backend, EDataCal *cal, gchar
exchange_mapi_util_free_recipient_list (&recipients);
exchange_mapi_util_free_stream_list (&streams);
exchange_mapi_util_free_attachment_list (&attachments);
- return GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED;
+ g_propagate_error (error, EDC_ERROR (UnsupportedMethod));
+ return;
}
/* blatant HACK /me blames some stupid design in e-d-s */
@@ -1713,8 +1709,6 @@ e_cal_backend_mapi_create_object (ECalBackendSync *backend, EDataCal *cal, gchar
exchange_mapi_util_free_recipient_list (&recipients);
exchange_mapi_util_free_stream_list (&streams);
exchange_mapi_util_free_attachment_list (&attachments);
-
- return GNOME_Evolution_Calendar_Success;
}
static gboolean
@@ -1771,9 +1765,9 @@ find_my_response (ECalBackendMAPI *cbmapi, ECalComponent *comp)
return val;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_mapi_modify_object (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj,
- CalObjModType mod, gchar **old_object, gchar **new_object)
+ CalObjModType mod, gchar **old_object, gchar **new_object, GError **error)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
@@ -1796,21 +1790,25 @@ e_cal_backend_mapi_modify_object (ECalBackendSync *backend, EDataCal *cal, const
priv = cbmapi->priv;
kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GNOME_Evolution_Calendar_InvalidObject);
- g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_InvalidObject);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
+ e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
- if (priv->mode == CAL_MODE_LOCAL)
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ if (priv->mode == CAL_MODE_LOCAL) {
+ g_propagate_error (error, EDC_ERROR (RepositoryOffline));
+ return;
+ }
if (mod != CALOBJ_MOD_ALL) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbmapi), _("Support for modifying single instances of a recurring appointment is not yet implemented. No change was made to the appointment on the server."));
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (error, EDC_ERROR_EX (OtherError, _("Support for modifying single instances of a recurring appointment is not yet implemented. No change was made to the appointment on the server.")));
+ return;
}
/* check the component for validity */
icalcomp = icalparser_parse_string (calobj);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (!icalcomp) {
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
+ }
prop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
while (prop) {
@@ -1869,7 +1867,8 @@ e_cal_backend_mapi_modify_object (ECalBackendSync *backend, EDataCal *cal, const
exchange_mapi_util_free_recipient_list (&recipients);
exchange_mapi_util_free_stream_list (&streams);
exchange_mapi_util_free_attachment_list (&attachments);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
}
exchange_mapi_util_mapi_id_from_string (uid, &mid);
@@ -1904,7 +1903,8 @@ e_cal_backend_mapi_modify_object (ECalBackendSync *backend, EDataCal *cal, const
exchange_mapi_util_free_recipient_list (&recipients);
exchange_mapi_util_free_stream_list (&streams);
exchange_mapi_util_free_attachment_list (&attachments);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (error, EDC_ERROR (OtherError));
+ return;
}
break;
default :
@@ -1913,7 +1913,8 @@ e_cal_backend_mapi_modify_object (ECalBackendSync *backend, EDataCal *cal, const
exchange_mapi_util_free_recipient_list (&recipients);
exchange_mapi_util_free_stream_list (&streams);
exchange_mapi_util_free_attachment_list (&attachments);
- return GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED;
+ g_propagate_error (error, EDC_ERROR (UnsupportedMethod));
+ return;
}
*old_object = e_cal_component_get_as_string (cache_comp);
@@ -1927,45 +1928,48 @@ e_cal_backend_mapi_modify_object (ECalBackendSync *backend, EDataCal *cal, const
exchange_mapi_util_free_recipient_list (&recipients);
exchange_mapi_util_free_stream_list (&streams);
exchange_mapi_util_free_attachment_list (&attachments);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_mapi_remove_object (ECalBackendSync *backend, EDataCal *cal,
const gchar *uid, const gchar *rid, CalObjModType mod,
- gchar **old_object, gchar **object)
+ gchar **old_object, gchar **object, GError **error)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
icalcomponent *icalcomp;
- ECalBackendSyncStatus status;
gchar *calobj = NULL;
mapi_id_t mid;
+ GError *err = NULL;
*old_object = *object = NULL;
cbmapi = E_CAL_BACKEND_MAPI (backend);
priv = cbmapi->priv;
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GNOME_Evolution_Calendar_InvalidObject);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
- if (priv->mode == CAL_MODE_LOCAL)
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ if (priv->mode == CAL_MODE_LOCAL) {
+ g_propagate_error (error, EDC_ERROR (RepositoryOffline));
+ return;
+ }
switch (priv->mode) {
case CAL_MODE_ANY :
case CAL_MODE_REMOTE : /* when online, modify/delete the item from the server */
/* check if the object exists */
/* FIXME: we may have detached instances which need to be removed */
- status = e_cal_backend_mapi_get_object (backend, cal, uid, NULL, &calobj);
- if (status != GNOME_Evolution_Calendar_Success)
- return status;
+ e_cal_backend_mapi_get_object (backend, cal, uid, NULL, &calobj, &err);
+ if (err) {
+ g_propagate_error (error, err);
+ return;
+ }
/* check the component for validity */
icalcomp = icalparser_parse_string (calobj);
if (!icalcomp) {
g_free (calobj);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
}
exchange_mapi_util_mapi_id_from_string (uid, &mid);
@@ -1978,8 +1982,8 @@ e_cal_backend_mapi_remove_object (ECalBackendSync *backend, EDataCal *cal,
time_rid = icaltime_from_string (rid);
e_cal_util_remove_instances (icalcomp, time_rid, mod);
new_calobj = (gchar *) icalcomponent_as_ical_string_r (icalcomp);
- status = e_cal_backend_mapi_modify_object (backend, cal, new_calobj, CALOBJ_MOD_ALL, &obj, &new_object);
- if (status == GNOME_Evolution_Calendar_Success) {
+ e_cal_backend_mapi_modify_object (backend, cal, new_calobj, CALOBJ_MOD_ALL, &obj, &new_object, &err);
+ if (!err) {
*old_object = obj;
*object = new_object;
}
@@ -2008,36 +2012,34 @@ e_cal_backend_mapi_remove_object (ECalBackendSync *backend, EDataCal *cal,
}
*old_object = g_strdup (calobj);
*object = NULL;
- status = GNOME_Evolution_Calendar_Success;
+ err = NULL; /* Success */
} else
- status = GNOME_Evolution_Calendar_OtherError;
+ err = EDC_ERROR_EX (OtherError, "Cannot remove items from a server");
g_slist_free (list);
g_slist_free (comp_list);
}
g_free (calobj);
break;
- default :
- status = GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED;
+ default:
+ err = EDC_ERROR (UnsupportedMethod);
break;
}
- return status;
+ if (err)
+ g_propagate_error (error, err);
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid)
+static void
+e_cal_backend_mapi_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid, GError **perror)
{
-
- return GNOME_Evolution_Calendar_Success;
-
+ g_propagate_error (perror, EDC_ERROR (NotSupported));
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_mapi_send_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj,
- GList **users, gchar **modified_calobj)
+ GList **users, gchar **modified_calobj, GError **error)
{
- ECalBackendSyncStatus status = GNOME_Evolution_Calendar_OtherError;
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
icalcomponent_kind kind;
@@ -2047,16 +2049,20 @@ e_cal_backend_mapi_send_objects (ECalBackendSync *backend, EDataCal *cal, const
priv = cbmapi->priv;
kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GNOME_Evolution_Calendar_InvalidObject);
- g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_InvalidObject);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
+ e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
- if (priv->mode == CAL_MODE_LOCAL)
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ if (priv->mode == CAL_MODE_LOCAL) {
+ g_propagate_error (error, EDC_ERROR (RepositoryOffline));
+ return;
+ }
/* check the component for validity */
icalcomp = icalparser_parse_string (calobj);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (!icalcomp) {
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
+ }
*modified_calobj = NULL;
*users = NULL;
@@ -2146,9 +2152,9 @@ e_cal_backend_mapi_send_objects (ECalBackendSync *backend, EDataCal *cal, const
g_object_unref (comp);
exchange_mapi_util_free_recipient_list (&recipients);
exchange_mapi_util_free_attachment_list (&attachments);
- return GNOME_Evolution_Calendar_OtherError;
- } else
- status = GNOME_Evolution_Calendar_Success;
+ g_propagate_error (error, EDC_ERROR_EX (OtherError, "Cannot create item on a server"));
+ return;
+ }
g_object_unref (comp);
exchange_mapi_util_free_recipient_list (&recipients);
@@ -2159,37 +2165,38 @@ e_cal_backend_mapi_send_objects (ECalBackendSync *backend, EDataCal *cal, const
}
}
- if (status == GNOME_Evolution_Calendar_Success)
- *modified_calobj = g_strdup (calobj);
+ *modified_calobj = g_strdup (calobj);
icalcomponent_free (icalcomp);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj)
+static void
+e_cal_backend_mapi_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GError **error)
{
- ECalBackendSyncStatus status = GNOME_Evolution_Calendar_OtherError;
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
icalcomponent_kind kind;
icalcomponent *icalcomp;
+ GError *err = NULL;
cbmapi = E_CAL_BACKEND_MAPI (backend);
priv = cbmapi->priv;
kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GNOME_Evolution_Calendar_InvalidObject);
- g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_InvalidObject);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
+ e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
- if (priv->mode == CAL_MODE_LOCAL)
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ if (priv->mode == CAL_MODE_LOCAL) {
+ g_propagate_error (error, EDC_ERROR (RepositoryOffline));
+ return;
+ }
/* check the component for validity */
icalcomp = icalparser_parse_string (calobj);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (!icalcomp) {
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
+ }
if (icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT) {
gboolean stop = FALSE;
@@ -2206,7 +2213,8 @@ e_cal_backend_mapi_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
/* FIXME: Add support for recurrences */
if (e_cal_component_has_recurrences (comp)) {
g_object_unref (comp);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (error, EDC_ERROR_EX (OtherError, "No support for recurrences"));
+ return;
}
e_cal_component_get_uid (comp, &uid);
@@ -2215,29 +2223,30 @@ e_cal_backend_mapi_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
switch (method) {
case ICAL_METHOD_REQUEST :
comp_str = NULL;
- status = e_cal_backend_mapi_get_object (backend, cal, uid, NULL, &comp_str);
- if (status != GNOME_Evolution_Calendar_Success) {
+ e_cal_backend_mapi_get_object (backend, cal, uid, NULL, &comp_str, &err);
+ if (err) {
+ g_clear_error (&err);
comp_str = e_cal_component_get_as_string (comp);
new_object = comp_str;
- status = e_cal_backend_mapi_create_object (backend, cal, &new_object, NULL);
+ e_cal_backend_mapi_create_object (backend, cal, &new_object, NULL, &err);
if (new_object == comp_str)
new_object = NULL;
} else {
g_free (comp_str);
comp_str = e_cal_component_get_as_string (comp);
- status = e_cal_backend_mapi_modify_object (backend, cal, comp_str, CALOBJ_MOD_ALL, &old_object, &new_object);
+ e_cal_backend_mapi_modify_object (backend, cal, comp_str, CALOBJ_MOD_ALL, &old_object, &new_object, &err);
}
g_free (comp_str);
g_free (old_object);
g_free (new_object);
- if (status == GNOME_Evolution_Calendar_Success) {
+ if (!err) {
GList *users = NULL, *l;
icalcomponent *resp_comp = e_cal_util_new_top_level ();
icalcomponent_set_method (resp_comp, ICAL_METHOD_RESPONSE);
icalcomponent_add_component (resp_comp,
icalcomponent_new_clone(e_cal_component_get_icalcomponent(comp)));
comp_str = icalcomponent_as_ical_string_r (resp_comp);
- status = e_cal_backend_mapi_send_objects (backend, cal, comp_str, &users, &new_object);
+ e_cal_backend_mapi_send_objects (backend, cal, comp_str, &users, &new_object, &err);
g_free (comp_str);
g_free (new_object);
for (l = users; l; l = l->next)
@@ -2246,19 +2255,19 @@ e_cal_backend_mapi_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
icalcomponent_free (resp_comp);
}
- if (status != GNOME_Evolution_Calendar_Success)
+ if (err)
stop = TRUE;
break;
case ICAL_METHOD_CANCEL :
- status = e_cal_backend_mapi_remove_object (backend, cal, uid, rid, CALOBJ_MOD_THIS, &old_object, &new_object);
- if (status != GNOME_Evolution_Calendar_Success)
+ e_cal_backend_mapi_remove_object (backend, cal, uid, rid, CALOBJ_MOD_THIS, &old_object, &new_object, &err);
+ if (err)
stop = TRUE;
g_free (old_object);
g_free (new_object);
break;
case ICAL_METHOD_REPLY :
/* responses are automatically updated even as they are rendered (just like in Outlook) */
- status = GNOME_Evolution_Calendar_Success;
+ /* FIXME: the above might not be true anymore */
break;
default :
break;
@@ -2272,11 +2281,12 @@ e_cal_backend_mapi_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
}
}
- return status;
+ if (err)
+ g_propagate_error (error, err);
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_mapi_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
@@ -2284,14 +2294,16 @@ e_cal_backend_mapi_add_timezone (ECalBackendSync *backend, EDataCal *cal, const
cbmapi = (ECalBackendMAPI *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbmapi->priv;
tz_comp = icalparser_parse_string (tzobj);
- if (!tz_comp)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (!tz_comp) {
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
+ }
if (icalcomponent_isa (tz_comp) == ICAL_VTIMEZONE_COMPONENT) {
icaltimezone *zone;
@@ -2300,16 +2312,15 @@ e_cal_backend_mapi_add_timezone (ECalBackendSync *backend, EDataCal *cal, const
if (e_cal_backend_cache_put_timezone (priv->cache, zone) == FALSE) {
icaltimezone_free (zone, 1);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (error, EDC_ERROR_EX (OtherError, "Cannot push timezone to cache"));
+ return;
}
icaltimezone_free (zone, 1);
}
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_mapi_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_mapi_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
icalcomponent *tz_comp;
ECalBackendMAPI *cbmapi;
@@ -2318,14 +2329,16 @@ e_cal_backend_mapi_set_default_zone (ECalBackendSync *backend, EDataCal *cal, co
cbmapi = (ECalBackendMAPI *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbmapi->priv;
tz_comp = icalparser_parse_string (tzobj);
- if (!tz_comp)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (!tz_comp) {
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
+ }
zone = icaltimezone_new ();
icaltimezone_set_component (zone, tz_comp);
@@ -2335,13 +2348,11 @@ e_cal_backend_mapi_set_default_zone (ECalBackendSync *backend, EDataCal *cal, co
/* Set the default timezone to it. */
priv->default_zone = zone;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_mapi_get_free_busy (ECalBackendSync *backend, EDataCal *cal,
- GList *users, time_t start, time_t end, GList **freebusy)
+ GList *users, time_t start, time_t end, GList **freebusy, GError **perror)
{
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
@@ -2350,8 +2361,6 @@ e_cal_backend_mapi_get_free_busy (ECalBackendSync *backend, EDataCal *cal,
priv = cbmapi->priv;
exchange_mapi_cal_utils_get_free_busy_data (priv->conn, users, start, end, freebusy);
-
- return GNOME_Evolution_Calendar_Success;
}
typedef struct {
@@ -2383,17 +2392,17 @@ e_cal_backend_mapi_compute_changes_foreach_key (const gchar *key, const gchar *v
}
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_mapi_compute_changes (ECalBackendMAPI *cbmapi, const gchar *change_id,
- GList **adds, GList **modifies, GList **deletes)
+ GList **adds, GList **modifies, GList **deletes, GError **perror)
{
- ECalBackendSyncStatus status;
ECalBackendCache *cache;
gchar *filename;
EXmlHash *ehash;
ECalBackendMAPIComputeChangesData be_data;
GList *i, *list = NULL;
gchar *unescaped_uri;
+ GError *err = NULL;
cache = cbmapi->priv->cache;
@@ -2404,9 +2413,11 @@ e_cal_backend_mapi_compute_changes (ECalBackendMAPI *cbmapi, const gchar *change
g_free (filename);
g_free (unescaped_uri);
- status = e_cal_backend_mapi_get_object_list (E_CAL_BACKEND_SYNC (cbmapi), NULL, "#t", &list);
- if (status != GNOME_Evolution_Calendar_Success)
- return status;
+ e_cal_backend_mapi_get_object_list (E_CAL_BACKEND_SYNC (cbmapi), NULL, "#t", &list, &err);
+ if (err) {
+ g_propagate_error (perror, err);
+ return;
+ }
/* Calculate adds and modifies */
for (i = list; i != NULL; i = g_list_next (i)) {
@@ -2450,23 +2461,20 @@ e_cal_backend_mapi_compute_changes (ECalBackendMAPI *cbmapi, const gchar *change
e_xmlhash_write (ehash);
e_xmlhash_destroy (ehash);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_mapi_get_changes (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id,
- GList **adds, GList **modifies, GList **deletes)
+ GList **adds, GList **modifies, GList **deletes, GError **error)
{
ECalBackendMAPI *cbmapi;
cbmapi = E_CAL_BACKEND_MAPI (backend);
- g_return_val_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), GNOME_Evolution_Calendar_InvalidObject);
- g_return_val_if_fail (change_id != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-
- return e_cal_backend_mapi_compute_changes (cbmapi, change_id, adds, modifies, deletes);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
+ e_return_data_cal_error_if_fail (change_id != NULL, InvalidArg);
+ e_cal_backend_mapi_compute_changes (cbmapi, change_id, adds, modifies, deletes, error);
}
/***** BACKEND CLASS FUNCTIONS *****/
@@ -2485,18 +2493,18 @@ e_cal_backend_mapi_is_loaded (ECalBackend *backend)
static void
e_cal_backend_mapi_start_query (ECalBackend *backend, EDataCalView *query)
{
- ECalBackendSyncStatus status;
ECalBackendMAPI *cbmapi;
ECalBackendMAPIPrivate *priv;
GList *objects = NULL;
+ GError *err = NULL;
cbmapi = E_CAL_BACKEND_MAPI (backend);
priv = cbmapi->priv;
- status = e_cal_backend_mapi_get_object_list (E_CAL_BACKEND_SYNC (backend), NULL,
- e_data_cal_view_get_text (query), &objects);
- if (status != GNOME_Evolution_Calendar_Success) {
- e_data_cal_view_notify_done (query, status);
+ e_cal_backend_mapi_get_object_list (E_CAL_BACKEND_SYNC (backend), NULL, e_data_cal_view_get_text (query), &objects, &err);
+ if (err) {
+ e_data_cal_view_notify_done (query, err);
+ g_error_free (err);
return;
}
@@ -2508,7 +2516,7 @@ e_cal_backend_mapi_start_query (ECalBackend *backend, EDataCalView *query)
g_list_free (objects);
}
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_Success);
+ e_data_cal_view_notify_done (query, NULL /* Success */);
}
static CalMode
@@ -2534,7 +2542,7 @@ e_cal_backend_mapi_set_mode (ECalBackend *backend, CalMode mode)
priv = cbmapi->priv;
if (!priv->mode && priv->mode == mode) {
- e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_SET,
+ e_cal_backend_notify_mode (backend, ModeSet,
cal_mode_to_corba (mode));
return;
}
@@ -2548,8 +2556,7 @@ e_cal_backend_mapi_set_mode (ECalBackend *backend, CalMode mode)
case CAL_MODE_REMOTE:
priv->mode = CAL_MODE_REMOTE;
priv->read_only = FALSE;
- e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_SET,
- GNOME_Evolution_Calendar_MODE_REMOTE);
+ e_cal_backend_notify_mode (backend, ModeSet, Remote);
if (e_cal_backend_mapi_is_loaded (backend) && re_open)
e_cal_backend_notify_auth_required(backend);
break;
@@ -2557,12 +2564,11 @@ e_cal_backend_mapi_set_mode (ECalBackend *backend, CalMode mode)
priv->mode = CAL_MODE_LOCAL;
priv->read_only = TRUE;
/* do we have to close the connection here ? */
- e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_SET,
- GNOME_Evolution_Calendar_MODE_REMOTE);
+ e_cal_backend_notify_mode (backend, ModeSet, Remote);
break;
default:
- e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
- cal_mode_to_corba (mode));
+ e_cal_backend_notify_mode (backend, ModeNotSupported, cal_mode_to_corba (mode));
+ break;
}
g_mutex_unlock (priv->mutex);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]