[evolution-data-server] 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-data-server] Bug #623204 - Be able to report detailed errors from backends
- Date: Fri, 9 Jul 2010 11:19:34 +0000 (UTC)
commit 0dbb2c242ceca7de4055a75d8d592922190d56fa
Author: Milan Crha <mcrha redhat com>
Date: Fri Jul 9 13:18:42 2010 +0200
Bug #623204 - Be able to report detailed errors from backends
addressbook/backends/file/e-book-backend-file.c | 225 +++--
.../backends/google/e-book-backend-google.c | 248 +++---
.../backends/groupwise/e-book-backend-groupwise.c | 228 +++---
addressbook/backends/ldap/e-book-backend-ldap.c | 383 ++++-----
addressbook/backends/vcf/e-book-backend-vcf.c | 103 ++-
.../backends/webdav/e-book-backend-webdav.c | 180 ++--
addressbook/libebook/e-book-marshal.list | 1 +
addressbook/libebook/e-book-types.h | 9 +-
addressbook/libebook/e-book-view.c | 54 +-
addressbook/libebook/e-book-view.h | 3 +
addressbook/libebook/e-book.c | 987 ++++++++++++++++++--
addressbook/libebook/e-book.h | 113 +++
addressbook/libebook/e-error.h | 30 +
addressbook/libedata-book/Makefile.am | 8 +-
addressbook/libedata-book/e-book-backend-sync.c | 253 +++---
addressbook/libedata-book/e-book-backend-sync.h | 68 +-
addressbook/libedata-book/e-book-backend.c | 64 +-
addressbook/libedata-book/e-book-backend.h | 25 +-
addressbook/libedata-book/e-data-book-types.h | 39 +-
addressbook/libedata-book/e-data-book-view.c | 11 +-
addressbook/libedata-book/e-data-book-view.h | 2 +-
addressbook/libedata-book/e-data-book-view.xml | 1 +
addressbook/libedata-book/e-data-book.c | 212 ++++-
addressbook/libedata-book/e-data-book.h | 61 +-
addressbook/tests/ebook/ebook-test-utils.c | 108 ++--
addressbook/tests/ebook/test-ebook-async.c | 24 +-
addressbook/tests/ebook/test-ebook-get-book-view.c | 4 +-
addressbook/tests/ebook/test-stress-bookviews.c | 6 +-
calendar/backends/caldav/e-cal-backend-caldav.c | 586 ++++++------
.../backends/contacts/e-cal-backend-contacts.c | 187 ++--
calendar/backends/file/e-cal-backend-file.c | 371 ++++----
calendar/backends/file/e-cal-backend-file.h | 2 +-
.../backends/groupwise/e-cal-backend-groupwise.c | 510 ++++++-----
calendar/backends/http/e-cal-backend-http.c | 227 ++---
calendar/backends/weather/e-cal-backend-weather.c | 174 ++--
calendar/libecal/e-cal-marshal.list | 1 +
calendar/libecal/e-cal-types.h | 10 +-
calendar/libecal/e-cal-util.h | 6 +-
calendar/libecal/e-cal-view.c | 75 ++-
calendar/libecal/e-cal-view.h | 4 +
calendar/libecal/e-cal.c | 187 +++-
calendar/libecal/e-cal.h | 3 +
calendar/libedata-cal/e-cal-backend-sync.c | 575 +++++-------
calendar/libedata-cal/e-cal-backend-sync.h | 264 +++---
calendar/libedata-cal/e-cal-backend-util.c | 63 --
calendar/libedata-cal/e-cal-backend-util.h | 2 -
calendar/libedata-cal/e-cal-backend.c | 40 +-
calendar/libedata-cal/e-cal-backend.h | 10 +-
calendar/libedata-cal/e-data-cal-factory.c | 2 +-
calendar/libedata-cal/e-data-cal-marshal.list | 1 +
calendar/libedata-cal/e-data-cal-types.h | 49 +-
calendar/libedata-cal/e-data-cal-view.c | 79 +-
calendar/libedata-cal/e-data-cal-view.h | 4 +-
calendar/libedata-cal/e-data-cal-view.xml | 5 +
calendar/libedata-cal/e-data-cal.c | 367 +++++---
calendar/libedata-cal/e-data-cal.h | 85 ++-
calendar/tests/ecal/ecal-test-utils.c | 14 +-
calendar/tests/ecal/test-ecal-get-query.c | 8 +-
calendar/tests/ecal/test-ecal.c | 8 +-
configure.ac | 12 +-
libedataserverui/e-book-auth-util.c | 85 ++-
libedataserverui/e-book-auth-util.h | 4 +
libedataserverui/e-contact-store.c | 6 +-
libedataserverui/e-name-selector-dialog.c | 21 +-
libedataserverui/e-name-selector-entry.c | 2 +-
libedataserverui/e-name-selector.c | 2 +-
66 files changed, 4408 insertions(+), 3093 deletions(-)
---
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index 7757c15..c558b97 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -65,6 +65,9 @@
#define PAS_ID_PREFIX "pas-id-"
#define SUMMARY_FLUSH_TIMEOUT 5000
+#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)
+
G_DEFINE_TYPE (EBookBackendFile, e_book_backend_file, E_TYPE_BOOK_BACKEND_SYNC)
struct _EBookBackendFilePrivate {
@@ -87,18 +90,24 @@ static struct {
DB_ENV *env;
} global_env;
-static EBookBackendSyncStatus
-db_error_to_status (const gint db_error)
+static void
+db_error_to_gerror (const gint db_error, GError **perror)
{
+ if (db_error && perror && *perror)
+ g_clear_error (perror);
+
switch (db_error) {
case 0:
- return GNOME_Evolution_Addressbook_Success;
+ return;
case DB_NOTFOUND:
- return GNOME_Evolution_Addressbook_ContactNotFound;
+ g_propagate_error (perror, EDB_ERROR (CONTACT_NOT_FOUND));
+ return;
case EACCES:
- return GNOME_Evolution_Addressbook_PermissionDenied;
+ g_propagate_error (perror, EDB_ERROR (PERMISSION_DENIED));
+ return;
default:
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "db error 0x%x (%s)", db_error, db_strerror (db_error) ? db_strerror (db_error) : "Unknown error"));
+ return;
}
}
@@ -184,10 +193,11 @@ set_revision (EContact *contact)
}
-static EBookBackendSyncStatus
+static gboolean
do_create(EBookBackendFile *bf,
const gchar *vcard_req,
- EContact **contact)
+ EContact **contact,
+ GError **perror)
{
DB *db = bf->priv->file_db;
DBT id_dbt, vcard_dbt;
@@ -230,32 +240,33 @@ do_create(EBookBackendFile *bf,
}
g_free (id);
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
+
+ return db_error == 0;
}
-static EBookBackendSyncStatus
+static void
e_book_backend_file_create_contact (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *vcard,
- EContact **contact)
+ EContact **contact,
+ GError **perror)
{
- EBookBackendSyncStatus status;
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
- status = do_create (bf, vcard, contact);
- if (status == GNOME_Evolution_Addressbook_Success) {
+ if (do_create (bf, vcard, contact, perror)) {
e_book_backend_summary_add_contact (bf->priv->summary, *contact);
}
- return status;
}
-static EBookBackendSyncStatus
+static void
e_book_backend_file_remove_contacts (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
GList *id_list,
- GList **ids)
+ GList **ids,
+ GError **perror)
{
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
DB *db = bf->priv->file_db;
@@ -264,7 +275,6 @@ e_book_backend_file_remove_contacts (EBookBackendSync *backend,
gchar *id;
GList *l;
GList *removed_cards = NULL;
- GNOME_Evolution_Addressbook_CallStatus rv = GNOME_Evolution_Addressbook_Success;
for (l = id_list; l; l = l->next) {
id = l->data;
@@ -274,7 +284,7 @@ e_book_backend_file_remove_contacts (EBookBackendSync *backend,
db_error = db->del (db, NULL, &id_dbt, 0);
if (0 != db_error) {
g_warning (G_STRLOC ": db->del failed with %s", db_strerror (db_error));
- rv = db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
continue;
}
@@ -294,16 +304,15 @@ e_book_backend_file_remove_contacts (EBookBackendSync *backend,
gchar *id = l->data;
e_book_backend_summary_remove_contact (bf->priv->summary, id);
}
-
- return rv;
}
-static EBookBackendSyncStatus
+static void
e_book_backend_file_modify_contact (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *vcard,
- EContact **contact)
+ EContact **contact,
+ GError **perror)
{
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
DB *db = bf->priv->file_db;
@@ -315,8 +324,10 @@ e_book_backend_file_modify_contact (EBookBackendSync *backend,
*contact = e_contact_new_from_vcard (vcard);
id = e_contact_get_const (*contact, E_CONTACT_UID);
- if (id == NULL)
- return GNOME_Evolution_Addressbook_OtherError;
+ if (id == NULL) {
+ g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "No UID in the contact"));
+ return;
+ }
/* update the revision (modified time of contact) */
set_revision (*contact);
@@ -351,18 +362,16 @@ e_book_backend_file_modify_contact (EBookBackendSync *backend,
}
g_free (vcard_with_rev);
- if (0 == db_error)
- return GNOME_Evolution_Addressbook_Success;
- else
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
}
-static EBookBackendSyncStatus
+static void
e_book_backend_file_get_contact (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *id,
- gchar **vcard)
+ gchar **vcard,
+ GError **perror)
{
EBookBackendFile *bf;
DB *db;
@@ -380,20 +389,21 @@ e_book_backend_file_get_contact (EBookBackendSync *backend,
if (db_error == 0) {
*vcard = vcard_dbt.data;
- return GNOME_Evolution_Addressbook_Success;
} else {
g_warning (G_STRLOC ": db->get failed with %s", db_strerror (db_error));
*vcard = g_strdup ("");
- return GNOME_Evolution_Addressbook_ContactNotFound;
+
+ g_propagate_error (perror, EDB_ERROR (CONTACT_NOT_FOUND));
}
}
-static EBookBackendSyncStatus
+static void
e_book_backend_file_get_contact_list (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *query,
- GList **contacts)
+ GList **contacts,
+ GError **perror)
{
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
DB *db = bf->priv->file_db;
@@ -404,18 +414,18 @@ e_book_backend_file_get_contact_list (EBookBackendSync *backend,
gboolean search_needed;
const gchar *search = query;
GList *contact_list = NULL;
- EBookBackendSyncStatus status;
d(printf ("e_book_backend_file_get_contact_list (%s)\n", search));
- status = GNOME_Evolution_Addressbook_Success;
if (e_book_backend_summary_is_summary_query (bf->priv->summary, search)) {
/* do a summary query */
GPtrArray *ids = e_book_backend_summary_search (bf->priv->summary, search);
gint i;
- if (!ids)
- return GNOME_Evolution_Addressbook_ContactNotFound;
+ if (!ids) {
+ g_propagate_error (perror, EDB_ERROR (CONTACT_NOT_FOUND));
+ return;
+ }
for (i = 0; i < ids->len; i ++) {
gchar *id = g_ptr_array_index (ids, i);
@@ -428,7 +438,7 @@ e_book_backend_file_get_contact_list (EBookBackendSync *backend,
contact_list = g_list_prepend (contact_list, vcard_dbt.data);
} else {
g_warning (G_STRLOC ": db->get failed with %s", db_strerror (db_error));
- status = db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
break;
}
}
@@ -440,8 +450,8 @@ e_book_backend_file_get_contact_list (EBookBackendSync *backend,
card_sexp = e_book_backend_sexp_new (search);
if (!card_sexp) {
- /* XXX this needs to be an invalid query error of some sort*/
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, EDB_ERROR (INVALID_QUERY));
+ return;
}
db_error = db->cursor (db, NULL, &dbc, 0);
@@ -449,7 +459,8 @@ e_book_backend_file_get_contact_list (EBookBackendSync *backend,
if (db_error != 0) {
g_warning (G_STRLOC ": db->cursor failed with %s", db_strerror (db_error));
/* XXX this needs to be some CouldNotOpen error */
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
+ return;
}
memset (&vcard_dbt, 0, sizeof (vcard_dbt));
@@ -474,10 +485,10 @@ e_book_backend_file_get_contact_list (EBookBackendSync *backend,
g_object_unref (card_sexp);
if (db_error == DB_NOTFOUND) {
- status = GNOME_Evolution_Addressbook_Success;
+ /* Success */
} else {
g_warning (G_STRLOC ": dbc->c_get failed with %s", db_strerror (db_error));
- status = db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
}
db_error = dbc->c_close(dbc);
@@ -487,7 +498,6 @@ e_book_backend_file_get_contact_list (EBookBackendSync *backend,
}
*contacts = contact_list;
- return status;
}
typedef struct {
@@ -641,7 +651,7 @@ book_view_thread (gpointer data)
}
done:
if (e_flag_is_set (closure->running))
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
/* unref the */
printf("book_view file uref \n");
@@ -731,12 +741,13 @@ e_book_backend_file_changes_foreach_key (const gchar *key, gpointer user_data)
}
}
-static EBookBackendSyncStatus
+static void
e_book_backend_file_get_changes (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *change_id,
- GList **changes_out)
+ GList **changes_out,
+ GError **perror)
{
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
gint db_error = 0;
@@ -748,7 +759,6 @@ e_book_backend_file_get_changes (EBookBackendSync *backend,
DBC *dbc;
GList *changes = NULL;
EBookBackendFileChangeContext ctx;
- EBookBackendSyncStatus result;
memset (&id_dbt, 0, sizeof (id_dbt));
memset (&vcard_dbt, 0, sizeof (vcard_dbt));
@@ -817,7 +827,7 @@ e_book_backend_file_get_changes (EBookBackendSync *backend,
if (db_error != DB_NOTFOUND) {
g_warning ("e_book_backend_file_changes: error building list\n");
*changes_out = NULL;
- result = db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
}
else {
/* Update the hash and build our changes list */
@@ -857,13 +867,10 @@ e_book_backend_file_get_changes (EBookBackendSync *backend,
e_dbhash_write (ehash);
- result = GNOME_Evolution_Addressbook_Success;
*changes_out = changes;
}
e_dbhash_destroy (ehash);
-
- return GNOME_Evolution_Addressbook_Success;
}
static gchar *
@@ -874,45 +881,47 @@ e_book_backend_file_extract_path_from_uri (const gchar *uri)
return g_filename_from_uri (uri, NULL, NULL);
}
-static EBookBackendSyncStatus
+static void
e_book_backend_file_authenticate_user (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *user,
const gchar *passwd,
- const gchar *auth_method)
+ const gchar *auth_method,
+ GError **perror)
{
- return GNOME_Evolution_Addressbook_Success;
+ /* Success */
}
-static EBookBackendSyncStatus
+static void
e_book_backend_file_get_required_fields (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
- GList **fields_out)
+ GList **fields_out,
+ GError **perror)
{
GList *fields = NULL;
fields = g_list_append (fields , g_strdup(e_contact_field_name (E_CONTACT_FILE_AS)));
*fields_out = fields;
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
+static void
e_book_backend_file_get_supported_auth_methods (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
- GList **methods_out)
+ GList **methods_out,
+ GError **perror)
{
*methods_out = NULL;
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
+static void
e_book_backend_file_get_supported_fields (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
- GList **fields_out)
+ GList **fields_out,
+ GError **perror)
{
GList *fields = NULL;
gint i;
@@ -923,7 +932,6 @@ e_book_backend_file_get_supported_fields (EBookBackendSync *backend,
fields = g_list_append (fields, g_strdup (e_contact_field_name (i)));
*fields_out = fields;
- return GNOME_Evolution_Addressbook_Success;
}
/*
@@ -1069,10 +1077,11 @@ file_errcall (const gchar *buf1, gchar *buf2)
g_warning ("libdb error: %s", buf2);
}
-static GNOME_Evolution_Addressbook_CallStatus
+static void
e_book_backend_file_load_source (EBookBackend *backend,
ESource *source,
- gboolean only_if_exists)
+ gboolean only_if_exists,
+ GError **perror)
{
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
gchar *dirname, *filename;
@@ -1095,7 +1104,8 @@ e_book_backend_file_load_source (EBookBackend *backend,
g_warning ("db recovery failed with %s", db_strerror (db_error));
g_free (dirname);
g_free (filename);
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
+ return;
}
G_LOCK (global_env);
@@ -1109,7 +1119,8 @@ e_book_backend_file_load_source (EBookBackend *backend,
G_UNLOCK (global_env);
g_free (dirname);
g_free (filename);
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
+ return;
}
env->set_errcall (env, file_errcall);
@@ -1126,7 +1137,8 @@ e_book_backend_file_load_source (EBookBackend *backend,
G_UNLOCK (global_env);
g_free (dirname);
g_free (filename);
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
+ return;
}
global_env.env = env;
@@ -1141,7 +1153,8 @@ e_book_backend_file_load_source (EBookBackend *backend,
g_warning ("db_create failed with %s", db_strerror (db_error));
g_free (dirname);
g_free (filename);
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
+ return;
}
db_error = (*db->open) (db, NULL, filename, NULL, DB_HASH, DB_THREAD, 0666);
@@ -1153,7 +1166,8 @@ e_book_backend_file_load_source (EBookBackend *backend,
g_warning ("db format upgrade failed with %s", db_strerror (db_error));
g_free (dirname);
g_free (filename);
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
+ return;
}
db->close (db, 0);
@@ -1162,7 +1176,8 @@ e_book_backend_file_load_source (EBookBackend *backend,
g_warning ("db_create failed with %s", db_strerror (db_error));
g_free (dirname);
g_free (filename);
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
+ return;
}
db_error = (*db->open) (db, NULL, filename, NULL, DB_HASH, DB_THREAD, 0666);
@@ -1177,7 +1192,8 @@ e_book_backend_file_load_source (EBookBackend *backend,
g_warning ("db_create failed with %s", db_strerror (db_error));
g_free (dirname);
g_free (filename);
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
+ return;
}
db_error = (*db->open) (db, NULL, filename, NULL, DB_HASH, DB_RDONLY | DB_THREAD, 0666);
@@ -1191,12 +1207,13 @@ e_book_backend_file_load_source (EBookBackend *backend,
rv = g_mkdir_with_parents (dirname, 0700);
if (rv == -1 && errno != EEXIST) {
g_warning ("failed to make directory %s: %s", dirname, g_strerror (errno));
- g_free (dirname);
- g_free (filename);
if (errno == EACCES || errno == EPERM)
- return GNOME_Evolution_Addressbook_PermissionDenied;
+ g_propagate_error (perror, EDB_ERROR (PERMISSION_DENIED));
else
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "Failed to make directory %s: %s", dirname, g_strerror (errno)));
+ g_free (dirname);
+ g_free (filename);
+ return;
}
db_error = db_create (&db, env, 0);
@@ -1204,7 +1221,8 @@ e_book_backend_file_load_source (EBookBackend *backend,
g_warning ("db_create failed with %s", db_strerror (db_error));
g_free (dirname);
g_free (filename);
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
+ return;
}
db_error = (*db->open) (db, NULL, filename, NULL, DB_HASH, DB_CREATE | DB_THREAD, 0666);
@@ -1215,11 +1233,9 @@ e_book_backend_file_load_source (EBookBackend *backend,
else {
#ifdef CREATE_DEFAULT_VCARD
EContact *contact = NULL;
- EBookBackendSyncStatus status;
- status = do_create (bf, XIMIAN_VCARD, &contact);
- if (status != GNOME_Evolution_Addressbook_Success)
- g_warning ("Cannot create default contact: %d", status);
+ if (!do_create (bf, XIMIAN_VCARD, &contact, NULL))
+ g_warning ("Cannot create default contact");
if (contact)
g_object_unref (contact);
#endif
@@ -1235,16 +1251,17 @@ e_book_backend_file_load_source (EBookBackend *backend,
bf->priv->file_db = NULL;
g_free (dirname);
g_free (filename);
- return db_error_to_status (db_error);
+ db_error_to_gerror (db_error, perror);
+ return;
}
if (!e_book_backend_file_maybe_upgrade_db (bf)) {
db->close (db, 0);
bf->priv->file_db = NULL;
- g_warning ("e_book_backend_file_maybe_upgrade_db failed");
g_free (dirname);
g_free (filename);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "e_book_backend_file_maybe_upgrade_db failed"));
+ return;
}
g_free (bf->priv->dirname);
@@ -1255,8 +1272,8 @@ e_book_backend_file_load_source (EBookBackend *backend,
if (g_stat (bf->priv->filename, &sb) == -1) {
db->close (db, 0);
bf->priv->file_db = NULL;
- g_warning ("stat(%s) failed", bf->priv->filename);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "stat(%s) failed", bf->priv->filename));
+ return;
}
db_mtime = sb.st_mtime;
@@ -1267,14 +1284,13 @@ e_book_backend_file_load_source (EBookBackend *backend,
if (e_book_backend_summary_is_up_to_date (bf->priv->summary, db_mtime) == FALSE
|| e_book_backend_summary_load (bf->priv->summary) == FALSE ) {
if (!bf->priv->summary || !build_summary (bf->priv)) {
- g_warning ("Failed to build summary for an address book %s", bf->priv->filename);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "Failed to build summary for an address book %s", bf->priv->filename));
+ return;
}
}
e_book_backend_set_is_loaded (backend, TRUE);
e_book_backend_set_is_writable (backend, writable);
- return GNOME_Evolution_Addressbook_Success;
}
static gboolean
@@ -1295,19 +1311,22 @@ select_changes (const gchar *name)
return TRUE;
}
-static EBookBackendSyncStatus
+static void
e_book_backend_file_remove (EBookBackendSync *backend,
EDataBook *book,
- guint32 opid)
+ guint32 opid,
+ GError **perror)
{
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
GDir *dir;
if (-1 == g_unlink (bf->priv->filename)) {
- if (errno == EACCES || errno == EPERM)
- return GNOME_Evolution_Addressbook_PermissionDenied;
- else
- return GNOME_Evolution_Addressbook_OtherError;
+ if (errno == EACCES || errno == EPERM) {
+ g_propagate_error (perror, EDB_ERROR (PERMISSION_DENIED));
+ } else {
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "Failed to remove file '%s': %s", bf->priv->filename, g_strerror (errno)));
+ }
+ return;
}
/* unref the summary before we remove the file so it's not written out again */
@@ -1341,7 +1360,6 @@ e_book_backend_file_remove (EBookBackendSync *backend,
it here.. the only time we should return failure is if we
failed to remove the actual data. a failure should mean
that the addressbook is still valid */
- return GNOME_Evolution_Addressbook_Success;
}
static gchar *
@@ -1350,13 +1368,14 @@ e_book_backend_file_get_static_capabilities (EBookBackend *backend)
return g_strdup("local,do-initial-query,bulk-removes,contact-lists");
}
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_file_cancel_operation (EBookBackend *backend, EDataBook *book)
+static void
+e_book_backend_file_cancel_operation (EBookBackend *backend, EDataBook *book, GError **perror)
{
- return GNOME_Evolution_Addressbook_CouldNotCancel;
+ g_propagate_error (perror, EDB_ERROR (COULD_NOT_CANCEL));
}
+
static void
-e_book_backend_file_set_mode (EBookBackend *backend, GNOME_Evolution_Addressbook_BookMode mode)
+e_book_backend_file_set_mode (EBookBackend *backend, EDataBookMode mode)
{
if (e_book_backend_is_loaded (backend)) {
e_book_backend_notify_writable (backend, TRUE);
diff --git a/addressbook/backends/google/e-book-backend-google.c b/addressbook/backends/google/e-book-backend-google.c
index 0eb853c..111ea0c 100644
--- a/addressbook/backends/google/e-book-backend-google.c
+++ b/addressbook/backends/google/e-book-backend-google.c
@@ -40,6 +40,9 @@
#define URI_GET_CONTACTS "://www.google.com/m8/feeds/contacts/default/full"
+#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)
+
G_DEFINE_TYPE (EBookBackendGoogle, e_book_backend_google, E_TYPE_BOOK_BACKEND_SYNC)
typedef enum {
@@ -49,7 +52,7 @@ typedef enum {
} CacheType;
struct _EBookBackendGooglePrivate {
- GNOME_Evolution_Addressbook_BookMode mode;
+ EDataBookMode mode;
GList *bookviews;
gchar *username;
@@ -80,7 +83,7 @@ struct _EBookBackendGooglePrivate {
gboolean __e_book_backend_google_debug__;
-static EBookBackendSyncStatus e_book_backend_status_from_gdata_error (GError *error);
+static void data_book_error_from_gdata_error (GError **dest_err, GError *error);
static void
cache_init (EBookBackend *backend, gboolean on_disk)
@@ -416,20 +419,25 @@ static void
on_sequence_complete (EBookBackend *backend, GError *error)
{
EBookBackendGooglePrivate *priv = E_BOOK_BACKEND_GOOGLE (backend)->priv;
- EBookBackendSyncStatus status = GNOME_Evolution_Addressbook_Success;
GList *iter;
+ GError *err = NULL;
if (!priv->live_mode)
return;
if (error) {
- status = e_book_backend_status_from_gdata_error (error);
+
+ data_book_error_from_gdata_error (&err, error);
+
__debug__ ("Book-view query failed: %s", error->message);
g_clear_error (&error);
}
for (iter = priv->bookviews; iter; iter = iter->next)
- e_data_book_view_notify_complete (E_DATA_BOOK_VIEW (iter->data), GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (E_DATA_BOOK_VIEW (iter->data), err);
+
+ if (err)
+ g_error_free (err);
}
static void
@@ -610,11 +618,10 @@ cache_destroy (EBookBackend *backend)
priv->cache_type = NO_CACHE;
}
-static EBookBackendSyncStatus
-e_book_backend_google_create_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *vcard_str, EContact **out_contact)
+static void
+e_book_backend_google_create_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *vcard_str, EContact **out_contact, GError **perror)
{
EBookBackendGooglePrivate *priv = E_BOOK_BACKEND_GOOGLE (backend)->priv;
- EBookBackendSyncStatus status = GNOME_Evolution_Addressbook_OtherError;
EContact *contact;
GError *error = NULL;
GDataEntry *entry, *new_entry;
@@ -625,10 +632,12 @@ e_book_backend_google_create_contact (EBookBackendSync *backend, EDataBook *book
__debug__ ("Creating: %s", vcard_str);
*out_contact = NULL;
- if (priv->mode != GNOME_Evolution_Addressbook_MODE_REMOTE)
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
+ if (priv->mode != E_DATA_BOOK_MODE_REMOTE) {
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
+ }
- g_return_val_if_fail (priv->service, status);
+ g_return_if_fail (priv->service);
/* Build the GDataEntry from the vCard */
contact = e_contact_new_from_vcard (vcard_str);
@@ -649,35 +658,34 @@ e_book_backend_google_create_contact (EBookBackendSync *backend, EDataBook *book
g_object_unref (entry);
if (!new_entry) {
- status = e_book_backend_status_from_gdata_error (error);
+ data_book_error_from_gdata_error (perror, error);
__debug__ ("Creating contact failed: %s", error->message);
g_error_free (error);
- return status;
+ return;
}
/* Add the new contact to the cache */
*out_contact = cache_add_contact (E_BOOK_BACKEND (backend), new_entry);
g_object_unref (new_entry);
-
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
-e_book_backend_google_remove_contacts (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList *id_list, GList **ids)
+static void
+e_book_backend_google_remove_contacts (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList *id_list, GList **ids, GError **perror)
{
EBookBackendGooglePrivate *priv = E_BOOK_BACKEND_GOOGLE (backend)->priv;
- EBookBackendSyncStatus status = GNOME_Evolution_Addressbook_OtherError;
GList *id_iter;
__debug__ (G_STRFUNC);
*ids = NULL;
- if (priv->mode != GNOME_Evolution_Addressbook_MODE_REMOTE)
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
+ if (priv->mode != E_DATA_BOOK_MODE_REMOTE) {
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
+ }
- g_return_val_if_fail (priv->service, status);
+ g_return_if_fail (priv->service);
for (id_iter = id_list; id_iter; id_iter = id_iter->next) {
GError *error = NULL;
@@ -691,7 +699,9 @@ e_book_backend_google_remove_contacts (EBookBackendSync *backend, EDataBook *boo
if (!cached_contact) {
/* Only the last error will be reported */
- status = GNOME_Evolution_Addressbook_ContactNotFound;
+ g_clear_error (perror);
+ if (perror)
+ *perror = EDB_ERROR (CONTACT_NOT_FOUND);
__debug__ ("Deleting contact %s failed: Contact not found in cache.", uid);
continue;
@@ -705,7 +715,7 @@ e_book_backend_google_remove_contacts (EBookBackendSync *backend, EDataBook *boo
/* Delete the contact from the server */
if (!gdata_service_delete_entry (GDATA_SERVICE (priv->service), entry, NULL, &error)) {
/* Only last error will be reported */
- status = e_book_backend_status_from_gdata_error (error);
+ data_book_error_from_gdata_error (perror, error);
__debug__ ("Deleting contact %s failed: %s", uid, error->message);
g_error_free (error);
} else {
@@ -716,18 +726,17 @@ e_book_backend_google_remove_contacts (EBookBackendSync *backend, EDataBook *boo
g_object_unref (entry);
}
- /* On error, return the status of the last error */
- if (!*ids)
- return status;
-
- return GNOME_Evolution_Addressbook_Success;
+ /* On error, return the last one */
+ if (!*ids) {
+ if (perror && !*perror)
+ *perror = EDB_ERROR (OTHER_ERROR);
+ }
}
-static EBookBackendSyncStatus
-e_book_backend_google_modify_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *vcard_str, EContact **out_contact)
+static void
+e_book_backend_google_modify_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *vcard_str, EContact **out_contact, GError **perror)
{
EBookBackendGooglePrivate *priv = E_BOOK_BACKEND_GOOGLE (backend)->priv;
- EBookBackendSyncStatus status = GNOME_Evolution_Addressbook_OtherError;
EContact *contact, *cached_contact;
GError *error = NULL;
GDataEntry *entry = NULL, *new_entry;
@@ -739,10 +748,12 @@ e_book_backend_google_modify_contact (EBookBackendSync *backend, EDataBook *book
__debug__ ("Updating: %s", vcard_str);
*out_contact = NULL;
- if (priv->mode != GNOME_Evolution_Addressbook_MODE_REMOTE)
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
+ if (priv->mode != E_DATA_BOOK_MODE_REMOTE) {
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
+ }
- g_return_val_if_fail (priv->service, status);
+ g_return_if_fail (priv->service);
/* Get the new contact and its UID */
contact = e_contact_new_from_vcard (vcard_str);
@@ -755,7 +766,8 @@ e_book_backend_google_modify_contact (EBookBackendSync *backend, EDataBook *book
__debug__ ("Modifying contact failed: Contact with uid %s not found in cache.", uid);
g_object_unref (contact);
- return GNOME_Evolution_Addressbook_ContactNotFound;
+ g_propagate_error (perror, EDB_ERROR (CONTACT_NOT_FOUND));
+ return;
}
g_object_unref (cached_contact);
@@ -778,11 +790,11 @@ e_book_backend_google_modify_contact (EBookBackendSync *backend, EDataBook *book
g_object_unref (entry);
if (!new_entry) {
- status = e_book_backend_status_from_gdata_error (error);
+ data_book_error_from_gdata_error (perror, error);
__debug__ ("Modifying contact failed: %s", error->message);
g_error_free (error);
- return status;
+ return;
}
/* Output debug XML */
@@ -795,14 +807,11 @@ e_book_backend_google_modify_contact (EBookBackendSync *backend, EDataBook *book
/* Add the new entry to the cache */
*out_contact = cache_add_contact (E_BOOK_BACKEND (backend), new_entry);
g_object_unref (new_entry);
-
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
-e_book_backend_google_get_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *uid, gchar **vcard_str)
+static void
+e_book_backend_google_get_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *uid, gchar **vcard_str, GError **perror)
{
- EBookBackendSyncStatus status = GNOME_Evolution_Addressbook_OtherError;
EContact *contact;
GError *error = NULL;
@@ -812,11 +821,11 @@ e_book_backend_google_get_contact (EBookBackendSync *backend, EDataBook *book, g
cache_refresh_if_needed (E_BOOK_BACKEND (backend), &error);
if (error) {
- status = e_book_backend_status_from_gdata_error (error);
+ data_book_error_from_gdata_error (perror, error);
__debug__ ("Getting contact with uid %s failed: %s", uid, error->message);
g_error_free (error);
- return status;
+ return;
}
/* Get the contact */
@@ -824,20 +833,19 @@ e_book_backend_google_get_contact (EBookBackendSync *backend, EDataBook *book, g
if (!contact) {
__debug__ ("Getting contact with uid %s failed: Contact not found in cache.", uid);
- return GNOME_Evolution_Addressbook_ContactNotFound;
+
+ g_propagate_error (perror, EDB_ERROR (CONTACT_NOT_FOUND));
+ return;
}
/* Success! Build and return a vCard of the contacts */
*vcard_str = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
g_object_unref (contact);
-
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
-e_book_backend_google_get_contact_list (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *query, GList **contacts)
+static void
+e_book_backend_google_get_contact_list (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *query, GList **contacts, GError **perror)
{
- EBookBackendSyncStatus status = GNOME_Evolution_Addressbook_OtherError;
EBookBackendSExp *sexp;
GError *error = NULL;
GList *all_contacts;
@@ -850,11 +858,11 @@ e_book_backend_google_get_contact_list (EBookBackendSync *backend, EDataBook *bo
cache_refresh_if_needed (E_BOOK_BACKEND (backend), &error);
if (error) {
- status = e_book_backend_status_from_gdata_error (error);
+ data_book_error_from_gdata_error (perror, error);
__debug__ ("Getting all contacts failed: %s", error->message);
g_clear_error (&error);
- return status;
+ return;
}
/* Get all contacts */
@@ -874,8 +882,6 @@ e_book_backend_google_get_contact_list (EBookBackendSync *backend, EDataBook *bo
}
g_object_unref (sexp);
-
- return GNOME_Evolution_Addressbook_Success;
}
static gboolean
@@ -947,7 +953,7 @@ e_book_backend_google_start_book_view (EBookBackend *backend, EDataBookView *boo
g_object_unref (contact);
}
- e_data_book_view_notify_complete (bookview, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (bookview, NULL /* Success */);
}
static void
@@ -987,33 +993,35 @@ proxy_settings_changed (EProxy *proxy, EBookBackend *backend)
g_free (uri);
}
-static EBookBackendSyncStatus
+static void
e_book_backend_google_authenticate_user (EBookBackendSync *backend, EDataBook *book, guint32 opid,
- const gchar *username, const gchar *password, const gchar *auth_method)
+ const gchar *username, const gchar *password, const gchar *auth_method, GError **perror)
{
EBookBackendGooglePrivate *priv = E_BOOK_BACKEND_GOOGLE (backend)->priv;
- EBookBackendSyncStatus status = GNOME_Evolution_Addressbook_Success;
GError *error = NULL;
gboolean match;
__debug__ (G_STRFUNC);
- if (priv->mode != GNOME_Evolution_Addressbook_MODE_REMOTE)
- return GNOME_Evolution_Addressbook_Success;
+ if (priv->mode != E_DATA_BOOK_MODE_REMOTE)
+ return;
if (priv->service) {
g_warning ("Connection to Google already established.");
e_book_backend_notify_writable (E_BOOK_BACKEND (backend), TRUE);
- return GNOME_Evolution_Addressbook_Success;
+ return;
}
- if (!username || username[0] == 0 || !password || password[0] == 0)
- return GNOME_Evolution_Addressbook_AuthenticationFailed;
+ if (!username || username[0] == 0 || !password || password[0] == 0) {
+ g_propagate_error (perror, EDB_ERROR (AUTHENTICATION_FAILED));
+ return;
+ }
match = (strcmp (username, priv->username) == 0);
if (!match) {
g_warning ("Username given when loading source and on authentication did not match!");
- return GNOME_Evolution_Addressbook_AuthenticationRequired;
+ g_propagate_error (perror, EDB_ERROR (AUTHENTICATION_REQUIRED));
+ return;
}
/* Set up the service and proxy */
@@ -1032,49 +1040,45 @@ e_book_backend_google_authenticate_user (EBookBackendSync *backend, EDataBook *b
g_object_unref (priv->proxy);
priv->proxy = NULL;
- status = e_book_backend_status_from_gdata_error (error);
+ data_book_error_from_gdata_error (perror, error);
__debug__ ("Authentication failed: %s", error->message);
g_error_free (error);
- return status;
+ return;
}
/* Update the cache if neccessary */
cache_refresh_if_needed (E_BOOK_BACKEND (backend), &error);
if (error) {
- status = e_book_backend_status_from_gdata_error (error);
+ data_book_error_from_gdata_error (perror, error);
__debug__ ("Authentication failed: %s", error->message);
g_error_free (error);
- return status;
+ return;
}
e_book_backend_notify_writable (E_BOOK_BACKEND (backend), TRUE);
-
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
-e_book_backend_google_get_supported_auth_methods (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **methods)
+static void
+e_book_backend_google_get_supported_auth_methods (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **methods, GError **perror)
{
__debug__ (G_STRFUNC);
*methods = g_list_prepend (NULL, g_strdup ("plain/password"));
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
-e_book_backend_google_get_required_fields (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **fields_out)
+static void
+e_book_backend_google_get_required_fields (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **fields_out, GError **perror)
{
__debug__ (G_STRFUNC);
*fields_out = NULL;
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
-e_book_backend_google_get_supported_fields (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **fields_out)
+static void
+e_book_backend_google_get_supported_fields (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **fields_out, GError **perror)
{
GList *fields = NULL;
guint i;
@@ -1188,21 +1192,19 @@ e_book_backend_google_get_supported_fields (EBookBackendSync *backend, EDataBook
}
*fields_out = fields;
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
-e_book_backend_google_get_changes (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *change_id, GList **changes_out)
+static void
+e_book_backend_google_get_changes (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *change_id, GList **changes_out, GError **perror)
{
__debug__ (G_STRFUNC);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, EDB_ERROR (OTHER_ERROR));
}
-static EBookBackendSyncStatus
-e_book_backend_google_remove (EBookBackendSync *backend, EDataBook *book, guint32 opid)
+static void
+e_book_backend_google_remove (EBookBackendSync *backend, EDataBook *book, guint32 opid, GError **perror)
{
__debug__ (G_STRFUNC);
- return GNOME_Evolution_Addressbook_Success;
}
static void
@@ -1230,8 +1232,8 @@ set_offline_mode (EBookBackend *backend, gboolean offline)
}
}
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_google_load_source (EBookBackend *backend, ESource *source, gboolean only_if_exists)
+static void
+e_book_backend_google_load_source (EBookBackend *backend, ESource *source, gboolean only_if_exists, GError **perror)
{
EBookBackendGooglePrivate *priv = E_BOOK_BACKEND_GOOGLE (backend)->priv;
const gchar *refresh_interval_str, *use_ssl_str, *use_cache_str;
@@ -1242,16 +1244,16 @@ e_book_backend_google_load_source (EBookBackend *backend, ESource *source, gbool
__debug__ (G_STRFUNC);
if (priv->username) {
- g_warning ("Source already loaded!");
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "Source already loaded!"));
+ return;
}
/* Parse the username property */
username = e_source_get_property (source, "username");
if (!username || username[0] == '\0') {
- g_warning ("No or empty username!");
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "No or empty username!"));
+ return;
}
/* Parse various other properties */
@@ -1289,9 +1291,7 @@ e_book_backend_google_load_source (EBookBackend *backend, ESource *source, gbool
e_book_backend_set_is_loaded (backend, TRUE);
e_book_backend_notify_connection_status (backend, TRUE);
e_book_backend_set_is_writable (backend, FALSE);
- set_offline_mode (backend, (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL));
-
- return GNOME_Evolution_Addressbook_Success;
+ set_offline_mode (backend, (priv->mode == E_DATA_BOOK_MODE_LOCAL));
}
static gchar *
@@ -1301,18 +1301,18 @@ e_book_backend_google_get_static_capabilities (EBookBackend *backend)
return g_strdup ("net,do-initial-query,contact-lists");
}
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_google_cancel_operation (EBookBackend *backend, EDataBook *book)
+static void
+e_book_backend_google_cancel_operation (EBookBackend *backend, EDataBook *book, GError **perror)
{
__debug__ (G_STRFUNC);
- return GNOME_Evolution_Addressbook_CouldNotCancel;
+ g_propagate_error (perror, EDB_ERROR (COULD_NOT_CANCEL));
}
static void
-e_book_backend_google_set_mode (EBookBackend *backend, GNOME_Evolution_Addressbook_BookMode mode)
+e_book_backend_google_set_mode (EBookBackend *backend, EDataBookMode mode)
{
EBookBackendGooglePrivate *priv = E_BOOK_BACKEND_GOOGLE (backend)->priv;
- gboolean online = (mode == GNOME_Evolution_Addressbook_MODE_REMOTE);
+ gboolean online = (mode == E_DATA_BOOK_MODE_REMOTE);
__debug__ (G_STRFUNC);
@@ -1426,52 +1426,66 @@ e_book_backend_google_new (void)
return E_BOOK_BACKEND (backend);
}
-static EBookBackendSyncStatus
-e_book_backend_status_from_gdata_error (GError *error)
+static void
+data_book_error_from_gdata_error (GError **dest_err, GError *error)
{
- if (!error)
- return GNOME_Evolution_Addressbook_Success;
+ if (!error || !dest_err)
+ return;
+
+ /* only last error is used */
+ g_clear_error (dest_err);
if (error->domain == GDATA_AUTHENTICATION_ERROR) {
/* Authentication errors */
switch (error->code) {
case GDATA_AUTHENTICATION_ERROR_BAD_AUTHENTICATION:
- return GNOME_Evolution_Addressbook_AuthenticationFailed;
+ g_propagate_error (dest_err, EDB_ERROR (AUTHENTICATION_FAILED));
+ return;
case GDATA_AUTHENTICATION_ERROR_NOT_VERIFIED:
case GDATA_AUTHENTICATION_ERROR_TERMS_NOT_AGREED:
case GDATA_AUTHENTICATION_ERROR_CAPTCHA_REQUIRED:
case GDATA_AUTHENTICATION_ERROR_ACCOUNT_DELETED:
case GDATA_AUTHENTICATION_ERROR_ACCOUNT_DISABLED:
- return GNOME_Evolution_Addressbook_PermissionDenied;
+ g_propagate_error (dest_err, EDB_ERROR (PERMISSION_DENIED));
+ return;
case GDATA_AUTHENTICATION_ERROR_SERVICE_DISABLED:
- return GNOME_Evolution_Addressbook_RepositoryOffline;
+ g_propagate_error (dest_err, EDB_ERROR (REPOSITORY_OFFLINE));
+ return;
default:
- return GNOME_Evolution_Addressbook_OtherError;
+ break;
}
} else if (error->domain == GDATA_SERVICE_ERROR) {
/* General service errors */
switch (error->code) {
case GDATA_SERVICE_ERROR_UNAVAILABLE:
- return GNOME_Evolution_Addressbook_RepositoryOffline;
+ g_propagate_error (dest_err, EDB_ERROR (REPOSITORY_OFFLINE));
+ return;
case GDATA_SERVICE_ERROR_PROTOCOL_ERROR:
- return GNOME_Evolution_Addressbook_InvalidQuery;
+ g_propagate_error (dest_err, EDB_ERROR (INVALID_QUERY));
+ return;
case GDATA_SERVICE_ERROR_ENTRY_ALREADY_INSERTED:
- return GNOME_Evolution_Addressbook_ContactIdAlreadyExists;
+ g_propagate_error (dest_err, EDB_ERROR (CONTACTID_ALREADY_EXISTS));
+ return;
case GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED:
- return GNOME_Evolution_Addressbook_AuthenticationRequired;
+ g_propagate_error (dest_err, EDB_ERROR (AUTHENTICATION_REQUIRED));
+ return;
case GDATA_SERVICE_ERROR_NOT_FOUND:
- return GNOME_Evolution_Addressbook_ContactNotFound;
+ g_propagate_error (dest_err, EDB_ERROR (CONTACT_NOT_FOUND));
+ return;
case GDATA_SERVICE_ERROR_CONFLICT:
- return GNOME_Evolution_Addressbook_ContactIdAlreadyExists;
+ g_propagate_error (dest_err, EDB_ERROR (CONTACTID_ALREADY_EXISTS));
+ return;
case GDATA_SERVICE_ERROR_FORBIDDEN:
- return GNOME_Evolution_Addressbook_QueryRefused;
+ g_propagate_error (dest_err, EDB_ERROR (QUERY_REFUSED));
+ return;
case GDATA_SERVICE_ERROR_BAD_QUERY_PARAMETER:
- return GNOME_Evolution_Addressbook_InvalidQuery;
+ g_propagate_error (dest_err, EDB_ERROR (INVALID_QUERY));
+ return;
default:
- return GNOME_Evolution_Addressbook_OtherError;
+ break;
}
}
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (dest_err, e_data_book_create_error (E_DATA_BOOK_STATUS_OTHER_ERROR, error->message));
}
diff --git a/addressbook/backends/groupwise/e-book-backend-groupwise.c b/addressbook/backends/groupwise/e-book-backend-groupwise.c
index 8e66a84..e1dc824 100644
--- a/addressbook/backends/groupwise/e-book-backend-groupwise.c
+++ b/addressbook/backends/groupwise/e-book-backend-groupwise.c
@@ -56,6 +56,10 @@
#include "e-gw-item.h"
#include "e-gw-filter.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)
+#define EDB_ERROR_FAILED_STATUS(_code, _status) e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_ ## _code, "Failed with status 0x%x", _status)
+
G_DEFINE_TYPE (EBookBackendGroupwise, e_book_backend_groupwise, E_TYPE_BOOK_BACKEND)
typedef struct {
@@ -1202,18 +1206,18 @@ e_book_backend_groupwise_create_contact (EBookBackend *backend,
switch (egwb->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
- e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ case E_DATA_BOOK_MODE_LOCAL :
+ e_data_book_respond_create (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case E_DATA_BOOK_MODE_REMOTE :
if (egwb->priv->cnc == NULL) {
- e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_AuthenticationRequired, NULL);
+ e_data_book_respond_create (book, opid, EDB_ERROR (AUTHENTICATION_REQUIRED), NULL);
return;
}
if (!egwb->priv->is_writable) {
- e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_PermissionDenied, NULL);
+ e_data_book_respond_create (book, opid, EDB_ERROR (PERMISSION_DENIED), NULL);
return;
}
contact = e_contact_new_from_vcard(vcard);
@@ -1252,11 +1256,11 @@ e_book_backend_groupwise_create_contact (EBookBackend *backend,
e_book_backend_db_cache_add_contact (egwb->priv->file_db, contact);
egwb->priv->file_db->sync(egwb->priv->file_db, 0);
e_book_backend_summary_add_contact (egwb->priv->summary, contact);
- e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_Success, contact);
+ e_data_book_respond_create (book, opid, EDB_ERROR (SUCCESS), contact);
}
else {
- e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_create (book, opid, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status), NULL);
}
g_object_unref (item);
return;
@@ -1282,18 +1286,18 @@ e_book_backend_groupwise_remove_contacts (EBookBackend *backend,
switch (ebgw->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
- e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ case E_DATA_BOOK_MODE_LOCAL :
+ e_data_book_respond_remove_contacts (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case E_DATA_BOOK_MODE_REMOTE :
if (ebgw->priv->cnc == NULL) {
- e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_AuthenticationRequired, NULL);
+ e_data_book_respond_remove_contacts (book, opid, EDB_ERROR (AUTHENTICATION_REQUIRED), NULL);
return;
}
if (!ebgw->priv->is_writable) {
- e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_PermissionDenied, NULL);
+ e_data_book_respond_remove_contacts (book, opid, EDB_ERROR (PERMISSION_DENIED), NULL);
return;
}
@@ -1305,8 +1309,7 @@ e_book_backend_groupwise_remove_contacts (EBookBackend *backend,
e_book_backend_summary_remove_contact (ebgw->priv->summary, id);
}
ebgw->priv->file_db->sync(ebgw->priv->file_db, 0);
- e_data_book_respond_remove_contacts (book, opid,
- GNOME_Evolution_Addressbook_Success, deleted_ids);
+ e_data_book_respond_remove_contacts (book, opid, EDB_ERROR (SUCCESS), deleted_ids);
return;
default :
break;
@@ -1372,17 +1375,17 @@ e_book_backend_groupwise_modify_contact (EBookBackend *backend,
switch (egwb->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
- e_data_book_respond_modify(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ case E_DATA_BOOK_MODE_LOCAL :
+ e_data_book_respond_modify (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case E_DATA_BOOK_MODE_REMOTE :
if (egwb->priv->cnc == NULL) {
- e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_AuthenticationRequired, NULL);
+ e_data_book_respond_modify (book, opid, EDB_ERROR (AUTHENTICATION_REQUIRED), NULL);
return;
}
if (!egwb->priv->is_writable) {
- e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_PermissionDenied, NULL);
+ e_data_book_respond_modify (book, opid, EDB_ERROR (PERMISSION_DENIED), NULL);
return;
}
contact = e_contact_new_from_vcard(vcard);
@@ -1411,12 +1414,12 @@ e_book_backend_groupwise_modify_contact (EBookBackend *backend,
status = e_gw_connection_get_item (egwb->priv->cnc, egwb->priv->container_id, id, NULL, &old_item);
if (old_item == NULL) {
- e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_ContactNotFound, NULL);
+ e_data_book_respond_modify (book, opid, EDB_ERROR (CONTACT_NOT_FOUND), NULL);
return;
}
if (status != E_GW_CONNECTION_STATUS_OK) {
- e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_modify (book, opid, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status), NULL);
return;
}
@@ -1428,7 +1431,7 @@ e_book_backend_groupwise_modify_contact (EBookBackend *backend,
e_gw_item_set_item_type (new_item, e_gw_item_get_item_type (old_item));
status = e_gw_connection_modify_item (egwb->priv->cnc, id, new_item);
if (status == E_GW_CONNECTION_STATUS_OK) {
- e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_Success, contact);
+ e_data_book_respond_modify (book, opid, EDB_ERROR (SUCCESS), contact);
e_book_backend_db_cache_remove_contact (egwb->priv->file_db, id);
e_book_backend_summary_remove_contact (egwb->priv->summary, id);
e_book_backend_db_cache_add_contact (egwb->priv->file_db, contact);
@@ -1436,7 +1439,7 @@ e_book_backend_groupwise_modify_contact (EBookBackend *backend,
e_book_backend_summary_add_contact (egwb->priv->summary, contact);
}
else
- e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_modify (book, opid, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status), NULL);
g_object_unref (new_item);
g_object_ref (old_item);
g_object_unref (contact);
@@ -1465,22 +1468,22 @@ e_book_backend_groupwise_get_contact (EBookBackend *backend,
switch (gwb->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
+ case E_DATA_BOOK_MODE_LOCAL :
contact = e_book_backend_db_cache_get_contact (gwb->priv->file_db, id);
vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
if (contact) {
- e_data_book_respond_get_contact(book, opid, GNOME_Evolution_Addressbook_Success, vcard);
+ e_data_book_respond_get_contact (book, opid, EDB_ERROR (SUCCESS), vcard);
g_free (vcard);
g_object_unref (contact);
}
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 (gwb->priv->cnc == NULL) {
- e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_get_contact (book, opid, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "Not connected"), NULL);
return;
}
status = e_gw_connection_get_item (gwb->priv->cnc, gwb->priv->container_id, id,
@@ -1491,14 +1494,14 @@ e_book_backend_groupwise_get_contact (EBookBackend *backend,
fill_contact_from_gw_item (contact, item, gwb->priv->categories_by_id);
e_contact_set (contact, E_CONTACT_BOOK_URI, gwb->priv->original_uri);
vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
- e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_Success, vcard);
+ e_data_book_respond_get_contact (book, opid, EDB_ERROR (SUCCESS), vcard);
g_free (vcard);
g_object_unref (contact);
g_object_unref (item);
return;
}
}
- 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;
default :
break;
@@ -1913,10 +1916,10 @@ e_book_backend_groupwise_get_contact_list (EBookBackend *backend,
switch (egwb->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
+ case E_DATA_BOOK_MODE_LOCAL :
if (!egwb->priv->file_db) {
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
}
@@ -1946,24 +1949,22 @@ e_book_backend_groupwise_get_contact_list (EBookBackend *backend,
EVC_FORMAT_VCARD_30));
g_object_unref (contacts->data);
}
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_Success,
- vcard_list);
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (SUCCESS), vcard_list);
if (temp)
g_list_free (temp);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE:
+ case E_DATA_BOOK_MODE_REMOTE:
if (egwb->priv->cnc == NULL) {
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_AuthenticationRequired, NULL);
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (AUTHENTICATION_REQUIRED), NULL);
return;
}
match_needed = TRUE;
card_sexp = e_book_backend_sexp_new (query);
if (!card_sexp) {
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_InvalidQuery,
- vcard_list);
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (INVALID_QUERY), vcard_list);
}
status = E_GW_CONNECTION_STATUS_OK;
@@ -2024,8 +2025,7 @@ e_book_backend_groupwise_get_contact_list (EBookBackend *backend,
}
if (status != E_GW_CONNECTION_STATUS_OK) {
- 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_FAILED_STATUS (OTHER_ERROR, status), NULL);
return;
}
for (; gw_items != NULL; gw_items = g_list_next(gw_items)) {
@@ -2045,8 +2045,7 @@ e_book_backend_groupwise_get_contact_list (EBookBackend *backend,
}
if (gw_items)
g_list_free (gw_items);
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_Success,
- vcard_list);
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (SUCCESS), vcard_list);
if (filter)
g_object_unref (filter);
return;
@@ -2116,8 +2115,7 @@ get_contacts_from_cache (EBookBackendGroupwise *ebgw,
}
}
if (e_flag_is_set (closure->running))
- e_data_book_view_notify_complete (book_view,
- GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
}
static gpointer
@@ -2151,9 +2149,9 @@ book_view_thread (gpointer data)
printf ("get view for query %s \n", query);
switch (gwb->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
+ case E_DATA_BOOK_MODE_LOCAL :
if (!gwb->priv->file_db) {
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
return NULL;
}
@@ -2186,18 +2184,20 @@ book_view_thread (gpointer data)
g_object_unref (contacts->data);
}
if (e_flag_is_set (closure->running))
- 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);
e_data_book_view_unref (book_view);
return NULL;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case E_DATA_BOOK_MODE_REMOTE :
if (gwb->priv->cnc == NULL) {
- e_data_book_view_notify_complete (book_view,
- GNOME_Evolution_Addressbook_AuthenticationRequired);
+ GError *edb_err = EDB_ERROR (AUTHENTICATION_REQUIRED);
+
+ e_data_book_view_notify_complete (book_view, edb_err);
e_data_book_view_unref (book_view);
+ g_error_free (edb_err);
return NULL;
}
@@ -2225,7 +2225,7 @@ book_view_thread (gpointer data)
if (!gwb->priv->is_writable && !filter && (g_getenv ("GW_HIDE_SYSBOOK") || (!gwb->priv->is_cache_ready))) {
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
e_data_book_view_unref (book_view);
if (filter)
g_object_unref (filter);
@@ -2306,7 +2306,7 @@ book_view_thread (gpointer data)
g_object_unref (contacts->data);
}
if (e_flag_is_set (closure->running))
- 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);
e_data_book_view_unref (book_view);
@@ -2342,8 +2342,10 @@ book_view_thread (gpointer data)
g_ptr_array_free (ids, TRUE);
if (status != E_GW_CONNECTION_STATUS_OK) {
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_OtherError);
+ GError *edb_err = EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status);
+ e_data_book_view_notify_complete (book_view, edb_err);
e_data_book_view_unref (book_view);
+ g_error_free (edb_err);
if (filter)
g_object_unref (filter);
return NULL;
@@ -2374,7 +2376,7 @@ book_view_thread (gpointer data)
if (temp_list)
g_list_free (temp_list);
if (e_flag_is_set (closure->running))
- e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
if (filter)
g_object_unref (filter);
e_data_book_view_unref (book_view);
@@ -2718,8 +2720,7 @@ build_cache (EBookBackendGroupwise *ebgw)
ebgw->priv->file_db->sync(ebgw->priv->file_db, 0);
if (book_view) {
- e_data_book_view_notify_complete (book_view,
- GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
e_data_book_view_unref (book_view);
}
@@ -2866,8 +2867,7 @@ update_cache (EBookBackendGroupwise *ebgw)
ebgw->priv->file_db->sync(ebgw->priv->file_db, 0);
if (book_view) {
- e_data_book_view_notify_complete (book_view,
- GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
e_data_book_view_unref (book_view);
}
g_object_unref (filter);
@@ -3111,8 +3111,7 @@ update_address_book_deltas (EBookBackendGroupwise *ebgw)
ebgw->priv->file_db->sync(ebgw->priv->file_db, 0);
if (book_view) {
- e_data_book_view_notify_complete (book_view,
- GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
e_data_book_view_unref (book_view);
}
@@ -3220,7 +3219,7 @@ e_book_backend_groupwise_authenticate_user (EBookBackend *backend,
}
switch (ebgw->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL:
+ case E_DATA_BOOK_MODE_LOCAL:
/* load summary file for offline use */
g_mkdir_with_parents (g_path_get_dirname (priv->summary_file_name), 0700);
priv->summary = e_book_backend_summary_new (priv->summary_file_name,
@@ -3229,14 +3228,14 @@ e_book_backend_groupwise_authenticate_user (EBookBackend *backend,
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, EDB_ERROR (SUCCESS));
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE:
+ case E_DATA_BOOK_MODE_REMOTE:
if (priv->cnc) { /*we have already authenticated to server */
printf("already authenticated\n");
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR (SUCCESS));
return;
}
@@ -3250,9 +3249,9 @@ e_book_backend_groupwise_authenticate_user (EBookBackend *backend,
if (!E_IS_GW_CONNECTION(priv->cnc)) {
if (error.status == E_GW_CONNECTION_STATUS_INVALID_PASSWORD)
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_AuthenticationFailed);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR (AUTHENTICATION_FAILED));
else
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_OtherError);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, error.status));
return;
}
@@ -3266,7 +3265,7 @@ e_book_backend_groupwise_authenticate_user (EBookBackend *backend,
status = e_gw_connection_create_book (priv->cnc, priv->book_name, &id);
is_writable = TRUE;
if (status != E_GW_CONNECTION_STATUS_OK ) {
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_OtherError);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status));
return;
}
}
@@ -3280,12 +3279,12 @@ e_book_backend_groupwise_authenticate_user (EBookBackend *backend,
priv->is_writable = is_writable;
e_gw_connection_get_categories (priv->cnc, &priv->categories_by_id, &priv->categories_by_name);
if (!e_gw_connection_get_version(priv->cnc))
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_InvalidServerVersion);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR (INVALID_SERVER_VERSION));
else
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR (SUCCESS));
} else {
e_book_backend_set_is_loaded (backend, FALSE);
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_NoSuchBook);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR (NO_SUCH_BOOK));
}
/* initialize summary file */
@@ -3296,7 +3295,7 @@ e_book_backend_groupwise_authenticate_user (EBookBackend *backend,
SUMMARY_FLUSH_TIMEOUT);
if (!ebgw->priv->file_db) {
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_OtherError);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR (OTHER_ERROR));
return;
}
if (e_book_backend_db_cache_is_populated (ebgw->priv->file_db)) {
@@ -3387,7 +3386,7 @@ e_book_backend_groupwise_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,
+ EDB_ERROR (SUCCESS),
fields);
g_list_free (fields);
@@ -3417,17 +3416,17 @@ e_book_backend_groupwise_get_supported_fields (EBookBackend *backend,
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_GROUPWISE)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_WORK)));
e_data_book_respond_get_supported_fields (book, opid,
- GNOME_Evolution_Addressbook_Success,
+ EDB_ERROR (SUCCESS),
fields);
g_list_free (fields);
}
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_groupwise_cancel_operation (EBookBackend *backend, EDataBook *book)
+static void
+e_book_backend_groupwise_cancel_operation (EBookBackend *backend, EDataBook *book, GError **perror)
{
if (enable_debug)
printf ("\ne_book_backend_groupwise_cancel_operation...\n");
- return GNOME_Evolution_Addressbook_CouldNotCancel;
+ g_propagate_error (perror, EDB_ERROR (COULD_NOT_CANCEL));
}
static void
@@ -3440,10 +3439,11 @@ file_errcall (const gchar *buf1, gchar *buf2)
g_warning ("libdb error: %s", buf2);
}
-static GNOME_Evolution_Addressbook_CallStatus
+static void
e_book_backend_groupwise_load_source (EBookBackend *backend,
ESource *source,
- gboolean only_if_exists)
+ gboolean only_if_exists,
+ GError **perror)
{
EBookBackendGroupwise *ebgw;
EBookBackendGroupwisePrivate *priv;
@@ -3472,16 +3472,20 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
uri = e_source_get_uri (source);
priv->original_uri = g_strdup (uri);
- if (uri == NULL)
- return GNOME_Evolution_Addressbook_OtherError;
+ if (uri == NULL) {
+ g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "No URI given"));
+ return;
+ }
tokens = g_strsplit (uri, ";", 2);
g_free (uri);
if (tokens[0])
uri = g_strdup(tokens[0]);
book_name = g_strdup (tokens[1]);
- if (book_name == NULL)
- return GNOME_Evolution_Addressbook_OtherError;
+ if (book_name == NULL) {
+ g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "No book name recognized for a URI"));
+ return;
+ }
g_strfreev (tokens);
parsed_uri = e_uri_new (uri);
port = e_source_get_property (source, "port");
@@ -3520,7 +3524,8 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
g_warning ("db recovery failed with %d", db_error);
g_free (dirname);
g_free (filename);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "DB recovery failed with code 0x%x", db_error));
+ return;
}
g_static_mutex_lock(&global_env_lock);
@@ -3535,7 +3540,8 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
g_static_mutex_unlock (&global_env_lock);
g_free (dirname);
g_free (filename);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "db_env_create failed with code 0x%x", db_error));
+ return;
}
db_error = env->open (env, NULL, DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_THREAD, 0);
@@ -3545,7 +3551,8 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
g_static_mutex_unlock(&global_env_lock);
g_free(dirname);
g_free(filename);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "db_env_open failed with code 0x%x", db_error));
+ return;
}
env->set_errcall (env, file_errcall);
@@ -3562,7 +3569,8 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
g_warning ("db_create failed with %d", db_error);
g_free(dirname);
g_free(filename);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "db_create failed with code 0x%x", db_error));
+ return;
}
db_error = db->open (db, NULL, filename, NULL, DB_HASH, DB_THREAD, 0666);
@@ -3574,7 +3582,8 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
g_warning ("db format upgrade failed with %d", db_error);
g_free(filename);
g_free(dirname);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "db format upgrade failed with code 0x%x", db_error));
+ return;
}
db_error = db->open (db, NULL, filename, NULL, DB_HASH, DB_THREAD, 0666);
@@ -3589,13 +3598,13 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
directory then the .db */
rv = g_mkdir_with_parents (dirname, 0700);
if (rv == -1 && errno != EEXIST) {
- g_warning ("failed to make directory %s: %s", dirname, g_strerror (errno));
- g_free (dirname);
- g_free (filename);
if (errno == EACCES || errno == EPERM)
- return GNOME_Evolution_Addressbook_PermissionDenied;
+ g_propagate_error (perror, EDB_ERROR (PERMISSION_DENIED));
else
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "Failed to make directory %s: %s", dirname, g_strerror (errno)));
+ g_free (dirname);
+ g_free (filename);
+ return;
}
db_error = db->open (db, NULL, filename, NULL, DB_HASH, DB_CREATE | DB_THREAD, 0666);
@@ -3611,11 +3620,13 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
ebgw->priv->file_db = NULL;
g_free(filename);
g_free(dirname);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, EDB_ERROR (OTHER_ERROR));
+ return;
}
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL && !priv->marked_for_offline ) {
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL && !priv->marked_for_offline ) {
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
}
priv->use_ssl = g_strdup (use_ssl);
@@ -3623,7 +3634,7 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
e_book_backend_set_is_loaded (E_BOOK_BACKEND (backend), TRUE);
e_book_backend_set_is_writable (E_BOOK_BACKEND(backend), FALSE);
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL) {
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_notify_connection_status (backend, FALSE);
}
@@ -3631,12 +3642,13 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
e_book_backend_notify_connection_status (backend, TRUE);
}
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL)
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL)
if (!e_book_backend_db_cache_exists (priv->original_uri)) {
g_free (uri);
e_uri_free (parsed_uri);
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
- }
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
+ }
e_book_backend_db_cache_set_filename (ebgw->priv->file_db, filename);
if (priv->marked_for_offline)
@@ -3650,8 +3662,6 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
printf ("summary file name = %s\ncache file name = %s \n",
priv->summary_file_name, e_file_cache_get_filename (E_FILE_CACHE(priv->cache)));
}*/
-
- return GNOME_Evolution_Addressbook_Success;
}
static void
@@ -3666,18 +3676,18 @@ e_book_backend_groupwise_remove (EBookBackend *backend,
printf ("\ne_book_backend_groupwise_remove...\n");
ebgw = E_BOOK_BACKEND_GROUPWISE (backend);
if (ebgw->priv->cnc == NULL) {
- e_data_book_respond_remove (book, opid, GNOME_Evolution_Addressbook_AuthenticationRequired);
+ e_data_book_respond_remove (book, opid, EDB_ERROR (AUTHENTICATION_REQUIRED));
return;
}
if (!ebgw->priv->is_writable) {
- e_data_book_respond_remove (book, opid, GNOME_Evolution_Addressbook_PermissionDenied);
+ e_data_book_respond_remove (book, opid, EDB_ERROR (PERMISSION_DENIED));
return;
}
status = e_gw_connection_remove_item (ebgw->priv->cnc, NULL, ebgw->priv->container_id);
if (status == E_GW_CONNECTION_STATUS_OK)
- e_data_book_respond_remove (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_remove (book, opid, EDB_ERROR (SUCCESS));
else
- e_data_book_respond_remove (book, opid, GNOME_Evolution_Addressbook_OtherError);
+ e_data_book_respond_remove (book, opid, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status));
g_unlink (e_book_backend_db_cache_get_filename(ebgw->priv->file_db));
}
@@ -3710,7 +3720,7 @@ e_book_backend_groupwise_get_supported_auth_methods (EBookBackend *backend, EDat
auth_methods = g_list_append (auth_methods, auth_method);
e_data_book_respond_get_supported_auth_methods (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ EDB_ERROR (SUCCESS),
auth_methods);
g_free (auth_method);
g_list_free (auth_methods);
@@ -3718,7 +3728,7 @@ e_book_backend_groupwise_get_supported_auth_methods (EBookBackend *backend, EDat
static void
e_book_backend_groupwise_set_mode (EBookBackend *backend,
- GNOME_Evolution_Addressbook_BookMode mode)
+ EDataBookMode mode)
{
EBookBackendGroupwise *bg;
@@ -3727,7 +3737,7 @@ e_book_backend_groupwise_set_mode (EBookBackend *backend,
bg = E_BOOK_BACKEND_GROUPWISE (backend);
bg->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);
if (bg->priv->cnc) {
@@ -3735,7 +3745,7 @@ e_book_backend_groupwise_set_mode (EBookBackend *backend,
bg->priv->cnc=NULL;
}
}
- else if (mode == GNOME_Evolution_Addressbook_MODE_REMOTE) {
+ else if (mode == E_DATA_BOOK_MODE_REMOTE) {
if (bg->priv->is_writable)
e_book_backend_notify_writable (backend, TRUE);
else
diff --git a/addressbook/backends/ldap/e-book-backend-ldap.c b/addressbook/backends/ldap/e-book-backend-ldap.c
index b804e87..2cf6c85 100644
--- a/addressbook/backends/ldap/e-book-backend-ldap.c
+++ b/addressbook/backends/ldap/e-book-backend-ldap.c
@@ -167,6 +167,11 @@ static gchar *e_book_backend_ldap_build_query (EBookBackendLDAP *bl, const gchar
typedef struct LDAPOp LDAPOp;
+#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)
+#define EDB_ERROR_NOT_CONNECTED() e_data_book_create_error (E_DATA_BOOK_STATUS_OTHER_ERROR, _("Not connected"))
+#define EDB_ERROR_MSG_TYPE(_msg_type) e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_INVALID_ARG, "Incorrect msg type %d passed to %s", _msg_type, G_STRFUNC)
+
G_DEFINE_TYPE (EBookBackendLDAP, e_book_backend_ldap, E_TYPE_BOOK_BACKEND)
struct _EBookBackendLDAPPrivate {
@@ -429,76 +434,6 @@ static struct prop_info {
#undef GROUP_PROP
};
-#if 0
-static void
-remove_view (gint msgid, LDAPOp *op, EDataBookView *view)
-{
- if (op->view == view)
- op->view = NULL;
-}
-
-static void
-view_destroy(gpointer data, GObject *where_object_was)
-{
- EDataBook *book = (EDataBook *)data;
- EBookBackendLDAP *bl;
- EIterator *iter;
-
- d(printf ("view_destroy (%p)\n", where_object_was));
-
- bl = E_BOOK_BACKEND_LDAP(e_data_book_get_backend(book));
-
- iter = e_list_get_iterator (bl->priv->book_views);
-
- while (e_iterator_is_valid (iter)) {
- EBookBackendLDAPBookView *view = (EBookBackendLDAPBookView*)e_iterator_get (iter);
-
- if (view->book_view == (EDataBookView*)where_object_was) {
- GNOME_Evolution_Addressbook_Book corba_book;
- CORBA_Environment ev;
-
- /* if we have an active search, interrupt it */
- if (view->search_op) {
- ldap_op_finished (view->search_op);
- }
- /* and remove us as the view for any other
- operations that might be using us to spew
- status messages to the gui */
- g_static_rec_mutex_lock (&bl->priv->op_hash_mutex);
- g_hash_table_foreach (bl->priv->id_to_op, (GHFunc)remove_view, view->book_view);
- g_static_rec_mutex_unlock (&bl->priv->op_hash_mutex);
-
- /* free up the view structure */
- g_free (view->search);
- g_free (view);
-
- /* and remove it from our list */
- e_iterator_delete (iter);
-
- /* unref the book now */
- corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book));
-
- CORBA_exception_init(&ev);
-
- GNOME_Evolution_Addressbook_Book_unref(corba_book, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning("view_destroy: Exception unreffing "
- "corba book.\n");
- }
-
- CORBA_exception_free(&ev);
- break;
- }
-
- e_iterator_next (iter);
- }
-
- g_object_unref (iter);
-
-}
-#endif
-
static gboolean
can_browse (EBookBackend *backend)
{
@@ -853,7 +788,7 @@ query_ldap_root_dse (EBookBackendLDAP *bl)
return LDAP_SUCCESS;
}
-static GNOME_Evolution_Addressbook_CallStatus
+static GError *
e_book_backend_ldap_connect (EBookBackendLDAP *bl)
{
EBookBackendLDAPPrivate *blpriv = bl->priv;
@@ -908,7 +843,7 @@ e_book_backend_ldap_connect (EBookBackendLDAP *bl)
ldap_unbind (blpriv->ldap);
blpriv->ldap = NULL;
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- return GNOME_Evolution_Addressbook_TLSNotAvailable;
+ return EDB_ERROR (TLS_NOT_AVAILABLE);
}
if (bl->priv->ldap_port == LDAPS_PORT && bl->priv->use_tls == E_BOOK_BACKEND_LDAP_TLS_ALWAYS) {
@@ -966,7 +901,7 @@ e_book_backend_ldap_connect (EBookBackendLDAP *bl)
ldap_unbind (blpriv->ldap);
blpriv->ldap = NULL;
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- return GNOME_Evolution_Addressbook_TLSNotAvailable;
+ return EDB_ERROR (TLS_NOT_AVAILABLE);
}
else {
g_message ("TLS not available (ldap_error 0x%02x)", ldap_error);
@@ -997,17 +932,17 @@ e_book_backend_ldap_connect (EBookBackendLDAP *bl)
if (ldap_error == LDAP_PROTOCOL_ERROR) {
g_warning ("failed to bind using either v3 or v2 binds.");
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- return GNOME_Evolution_Addressbook_OtherError;
+ return e_data_book_create_error (E_DATA_BOOK_STATUS_OTHER_ERROR, "Failed to bind using either v3 or v2 binds");
}
else if (ldap_error == LDAP_SERVER_DOWN) {
/* we only want this to be fatal if the server is down. */
g_warning ("failed to bind anonymously while connecting (ldap_error 0x%02x)", ldap_error);
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- return GNOME_Evolution_Addressbook_RepositoryOffline;
+ return EDB_ERROR (REPOSITORY_OFFLINE);
} else if (ldap_error == LDAP_INVALID_CREDENTIALS) {
g_warning ("Invalid credentials while connecting (ldap_error 0x%02x)", ldap_error);
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- return (GNOME_Evolution_Addressbook_AuthenticationFailed);
+ return EDB_ERROR (AUTHENTICATION_FAILED);
}
if (ldap_error == LDAP_INSUFFICIENT_ACCESS)
@@ -1045,11 +980,11 @@ e_book_backend_ldap_connect (EBookBackendLDAP *bl)
printf("e_book_backend_ldap_connect took %ld.%03ld seconds\n",
diff/1000,diff%1000);
}
- return GNOME_Evolution_Addressbook_Success;
+ return EDB_ERROR (SUCCESS);
} else if (ldap_error == LDAP_UNWILLING_TO_PERFORM) {
e_book_backend_notify_auth_required (E_BOOK_BACKEND (bl));
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- return GNOME_Evolution_Addressbook_AuthenticationRequired;
+ return EDB_ERROR (AUTHENTICATION_REQUIRED);
} else {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
g_warning ("Failed to perform root dse query anonymously, (ldap_error 0x%02x)", ldap_error);
@@ -1065,7 +1000,7 @@ e_book_backend_ldap_connect (EBookBackendLDAP *bl)
blpriv->ldap_port,
blpriv->ldap_rootdn ? blpriv->ldap_rootdn : "");
blpriv->connected = FALSE;
- return GNOME_Evolution_Addressbook_RepositoryOffline;
+ return EDB_ERROR (REPOSITORY_OFFLINE);
}
static gboolean
@@ -1090,17 +1025,18 @@ e_book_backend_ldap_reconnect (EBookBackendLDAP *bl, EDataBookView *book_view, g
/* we need to reconnect if we were previously connected */
if (bl->priv->connected && ldap_status == LDAP_SERVER_DOWN) {
- GNOME_Evolution_Addressbook_CallStatus status;
+ GError *error;
gint ldap_error = LDAP_SUCCESS;
book_view_notify_status (bl, book_view, _("Reconnecting to LDAP server..."));
- status = e_book_backend_ldap_connect (bl);
+ error = e_book_backend_ldap_connect (bl);
- if (status != GNOME_Evolution_Addressbook_Success) {
+ if (error) {
book_view_notify_status (bl, book_view, "");
if (enable_debug)
printf ("e_book_backend_ldap_reconnect ... failed (server down?)\n");
+ g_error_free (error);
return FALSE;
}
@@ -1211,27 +1147,29 @@ ldap_op_change_id (LDAPOp *op, gint msg_id)
g_static_rec_mutex_unlock (&bl->priv->op_hash_mutex);
}
-static gint
+static GError *
ldap_error_to_response (gint ldap_error)
{
if (ldap_error == LDAP_SUCCESS)
- return GNOME_Evolution_Addressbook_Success;
+ return EDB_ERROR (SUCCESS);
else if (ldap_error == LDAP_INVALID_DN_SYNTAX)
- return GNOME_Evolution_Addressbook_OtherError;
+ return e_data_book_create_error (E_DATA_BOOK_STATUS_OTHER_ERROR, _("Invalid DN syntax"));
else if (LDAP_NAME_ERROR (ldap_error))
- return GNOME_Evolution_Addressbook_ContactNotFound;
+ return EDB_ERROR (CONTACT_NOT_FOUND);
else if (ldap_error == LDAP_INSUFFICIENT_ACCESS)
- return GNOME_Evolution_Addressbook_PermissionDenied;
+ return EDB_ERROR (PERMISSION_DENIED);
else if (ldap_error == LDAP_STRONG_AUTH_REQUIRED)
- return GNOME_Evolution_Addressbook_AuthenticationRequired;
+ return EDB_ERROR (AUTHENTICATION_REQUIRED);
else if (ldap_error == LDAP_SERVER_DOWN)
- return GNOME_Evolution_Addressbook_RepositoryOffline;
+ return EDB_ERROR (REPOSITORY_OFFLINE);
else if (ldap_error == LDAP_ALREADY_EXISTS)
- return GNOME_Evolution_Addressbook_ContactIdAlreadyExists;
+ return EDB_ERROR (CONTACTID_ALREADY_EXISTS);
else if (ldap_error == LDAP_TYPE_OR_VALUE_EXISTS )
- return GNOME_Evolution_Addressbook_ContactIdAlreadyExists;
+ return EDB_ERROR (CONTACTID_ALREADY_EXISTS);
else
- return GNOME_Evolution_Addressbook_OtherError;
+ return e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR,
+ "LDAP error 0x%x (%s)", ldap_error,
+ ldap_err2string (ldap_error) ? ldap_err2string (ldap_error) : "Unknown error");
}
static const gchar *
@@ -1565,14 +1503,13 @@ create_contact_handler (LDAPOp *op, LDAPMessage *res)
EBookBackendLDAP *bl = E_BOOK_BACKEND_LDAP (op->backend);
gchar *ldap_error_msg;
gint ldap_error;
- gint response;
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_create (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ EDB_ERROR_NOT_CONNECTED (),
NULL);
ldap_op_finished (op);
return;
@@ -1580,10 +1517,9 @@ create_contact_handler (LDAPOp *op, LDAPMessage *res)
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (LDAP_RES_ADD != ldap_msgtype (res)) {
- g_warning ("incorrect msg type %d passed to create_contact_handler", ldap_msgtype (res));
e_data_book_respond_create (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ EDB_ERROR_MSG_TYPE (ldap_msgtype (res)),
NULL);
ldap_op_finished (op);
return;
@@ -1604,10 +1540,9 @@ create_contact_handler (LDAPOp *op, LDAPMessage *res)
ldap_memfree (ldap_error_msg);
/* and lastly respond */
- response = ldap_error_to_response (ldap_error);
e_data_book_respond_create (op->book,
op->opid,
- response,
+ ldap_error_to_response (ldap_error),
create_op->new_contact);
ldap_op_finished (op);
@@ -1633,7 +1568,6 @@ e_book_backend_ldap_create_contact (EBookBackend *backend,
EBookBackendLDAP *bl = E_BOOK_BACKEND_LDAP (backend);
EDataBookView *book_view;
gint create_contact_msgid;
- gint response;
gint err;
GPtrArray *mod_array;
LDAPMod **ldap_mods;
@@ -1641,15 +1575,15 @@ e_book_backend_ldap_create_contact (EBookBackend *backend,
switch (bl->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
- e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ case E_DATA_BOOK_MODE_LOCAL :
+ e_data_book_respond_create (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case E_DATA_BOOK_MODE_REMOTE :
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- e_data_book_respond_create (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_create (book, opid, EDB_ERROR_NOT_CONNECTED (), NULL);
return;
}
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
@@ -1674,7 +1608,7 @@ e_book_backend_ldap_create_contact (EBookBackend *backend,
/* there's an illegal field in there. report
UnsupportedAttribute back */
e_data_book_respond_create (book,
- GNOME_Evolution_Addressbook_BookListener_UnsupportedField,
+ EDB_ERROR (UNSUPPORTED_FIELD),
NULL);
g_free (create_op->dn);
@@ -1747,10 +1681,9 @@ e_book_backend_ldap_create_contact (EBookBackend *backend,
free_mods (mod_array);
if (LDAP_SUCCESS != err) {
- response = ldap_error_to_response (err);
e_data_book_respond_create (create_op->op.book,
opid,
- response,
+ ldap_error_to_response (err),
NULL);
create_contact_dtor ((LDAPOp*)create_op);
return;
@@ -1781,17 +1714,16 @@ remove_contact_handler (LDAPOp *op, LDAPMessage *res)
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- e_data_book_respond_remove_contacts (op->book, op->opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_remove_contacts (op->book, op->opid, EDB_ERROR_NOT_CONNECTED (), NULL);
ldap_op_finished (op);
return;
}
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (LDAP_RES_DELETE != ldap_msgtype (res)) {
- g_warning ("incorrect msg type %d passed to remove_contact_handler", ldap_msgtype (res));
e_data_book_respond_remove_contacts (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ EDB_ERROR_MSG_TYPE (ldap_msgtype (res)),
NULL);
ldap_op_finished (op);
return;
@@ -1845,15 +1777,15 @@ e_book_backend_ldap_remove_contacts (EBookBackend *backend,
switch (bl->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
- e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ case E_DATA_BOOK_MODE_LOCAL :
+ e_data_book_respond_remove_contacts (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
g_free (remove_op);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case E_DATA_BOOK_MODE_REMOTE :
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_remove_contacts (book, opid, EDB_ERROR_NOT_CONNECTED (), NULL);
g_free (remove_op);
return;
}
@@ -1933,7 +1865,7 @@ modify_contact_modify_handler (LDAPOp *op, LDAPMessage *res)
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_modify (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ EDB_ERROR_NOT_CONNECTED (),
NULL);
ldap_op_finished (op);
return;
@@ -1941,10 +1873,9 @@ modify_contact_modify_handler (LDAPOp *op, LDAPMessage *res)
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (LDAP_RES_MODIFY != ldap_msgtype (res)) {
- g_warning ("incorrect msg type %d passed to modify_contact_modify_handler", ldap_msgtype (res));
e_data_book_respond_modify (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ EDB_ERROR_MSG_TYPE (ldap_msgtype (res)),
NULL);
ldap_op_finished (op);
return;
@@ -1986,7 +1917,7 @@ modify_contact_search_handler (LDAPOp *op, LDAPMessage *res)
if (!bl->priv->ldap) {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_modify (op->book, op->opid,
- GNOME_Evolution_Addressbook_OtherError, NULL);
+ EDB_ERROR_NOT_CONNECTED (), NULL);
ldap_op_finished (op);
return;
}
@@ -2005,10 +1936,9 @@ modify_contact_search_handler (LDAPOp *op, LDAPMessage *res)
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (!e) {
- g_warning ("uh, this shouldn't happen");
e_data_book_respond_modify (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "%s: NULL returned from ldap_first_entry", G_STRFUNC),
NULL);
ldap_op_finished (op);
return;
@@ -2129,7 +2059,7 @@ modify_contact_rename_handler (LDAPOp *op, LDAPMessage *res)
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_modify (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ EDB_ERROR_NOT_CONNECTED (),
NULL);
ldap_op_finished (op);
return;
@@ -2139,10 +2069,9 @@ modify_contact_rename_handler (LDAPOp *op, LDAPMessage *res)
/* was a rename necessary? */
if (modify_op->new_id) {
if (LDAP_RES_RENAME != ldap_msgtype (res)) {
- g_warning ("incorrect msg type %d passed to modify_contact_rename_handler", ldap_msgtype (res));
e_data_book_respond_modify (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ EDB_ERROR_MSG_TYPE (ldap_msgtype (res)),
NULL);
ldap_op_finished (op);
return;
@@ -2246,10 +2175,10 @@ modify_contact_rename_handler (LDAPOp *op, LDAPMessage *res)
return;
}
} else {
- g_warning ("unhandled result type %d returned", ldap_msgtype (res));
e_data_book_respond_modify (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR,
+ "%s: Unhandled result type %d returned", G_STRFUNC, ldap_msgtype (res)),
NULL);
ldap_op_finished (op);
}
@@ -2286,14 +2215,14 @@ e_book_backend_ldap_modify_contact (EBookBackend *backend,
switch (bl->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
- e_data_book_respond_modify(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ case E_DATA_BOOK_MODE_LOCAL :
+ e_data_book_respond_modify (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case E_DATA_BOOK_MODE_REMOTE :
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_modify (book, opid, EDB_ERROR_NOT_CONNECTED (), NULL);
g_free (modify_op);
return;
}
@@ -2325,10 +2254,9 @@ e_book_backend_ldap_modify_contact (EBookBackend *backend,
modify_contact_search_handler, modify_contact_dtor);
}
else {
- g_warning ("ldap_search_ext returned %d\n", ldap_error);
e_data_book_respond_modify (book,
opid,
- GNOME_Evolution_Addressbook_OtherError,
+ ldap_error_to_response (ldap_error),
NULL);
modify_contact_dtor ((LDAPOp*)modify_op);
}
@@ -2355,7 +2283,7 @@ get_contact_handler (LDAPOp *op, LDAPMessage *res)
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- e_data_book_respond_get_contact (op->book, op->opid, GNOME_Evolution_Addressbook_OtherError, "");
+ e_data_book_respond_get_contact (op->book, op->opid, EDB_ERROR_NOT_CONNECTED (), "");
ldap_op_finished (op);
if (enable_debug)
printf ("get_contact_handler... ldap handler is NULL \n");
@@ -2377,10 +2305,9 @@ get_contact_handler (LDAPOp *op, LDAPMessage *res)
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (!e) {
- g_warning ("uh, this shouldn't happen");
e_data_book_respond_get_contact (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "%s: NULL returned from ldap_first_entry", G_STRFUNC),
"");
ldap_op_finished (op);
return;
@@ -2391,7 +2318,7 @@ get_contact_handler (LDAPOp *op, LDAPMessage *res)
vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
e_data_book_respond_get_contact (op->book,
op->opid,
- GNOME_Evolution_Addressbook_Success,
+ EDB_ERROR (SUCCESS),
vcard);
g_free (vcard);
g_object_unref (contact);
@@ -2427,10 +2354,10 @@ get_contact_handler (LDAPOp *op, LDAPMessage *res)
ldap_op_finished (op);
}
else {
- g_warning ("unhandled result type %d returned", msg_type);
e_data_book_respond_get_contact (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR,
+ "%s: Unhandled result type %d returned", G_STRFUNC, msg_type),
"");
ldap_op_finished (op);
}
@@ -2461,13 +2388,13 @@ e_book_backend_ldap_get_contact (EBookBackend *backend,
switch (bl->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
+ case E_DATA_BOOK_MODE_LOCAL :
if (bl->priv->marked_for_offline && bl->priv->cache) {
EContact *contact = e_book_backend_cache_get_contact (bl->priv->cache, id);
gchar *vcard_str;
if (!contact) {
- e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_OtherError, "");
+ e_data_book_respond_get_contact (book, opid, EDB_ERROR (CONTACT_NOT_FOUND), "");
return;
}
@@ -2475,17 +2402,17 @@ e_book_backend_ldap_get_contact (EBookBackend *backend,
e_data_book_respond_get_contact (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ EDB_ERROR (SUCCESS),
vcard_str);
g_free (vcard_str);
g_object_unref (contact);
return;
}
- e_data_book_respond_get_contact(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, "");
+ e_data_book_respond_get_contact(book, opid, EDB_ERROR (REPOSITORY_OFFLINE), "");
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case E_DATA_BOOK_MODE_REMOTE :
if (enable_debug) {
printf("e_book_backend_ldap_get_contact ... \n");
@@ -2495,7 +2422,7 @@ e_book_backend_ldap_get_contact (EBookBackend *backend,
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_OtherError, "");
+ e_data_book_respond_get_contact (book, opid, EDB_ERROR_NOT_CONNECTED (), "");
if (enable_debug)
printf("e_book_backend_ldap_get_contact ... ldap handler is NULL\n");
return;
@@ -2563,7 +2490,7 @@ contact_list_handler (LDAPOp *op, LDAPMessage *res)
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- e_data_book_respond_get_contact_list (op->book, op->opid, GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_get_contact_list (op->book, op->opid, EDB_ERROR_NOT_CONNECTED (), NULL);
ldap_op_finished (op);
if (enable_debug)
printf ("contact_list_handler ... ldap handler is NULL \n");
@@ -2617,22 +2544,22 @@ contact_list_handler (LDAPOp *op, LDAPMessage *res)
if (ldap_error == LDAP_TIMELIMIT_EXCEEDED)
e_data_book_respond_get_contact_list (op->book,
op->opid,
- GNOME_Evolution_Addressbook_SearchTimeLimitExceeded,
+ EDB_ERROR (SEARCH_TIME_LIMIT_EXCEEDED),
contact_list_op->contacts);
else if (ldap_error == LDAP_SIZELIMIT_EXCEEDED)
e_data_book_respond_get_contact_list (op->book,
op->opid,
- GNOME_Evolution_Addressbook_SearchSizeLimitExceeded,
+ EDB_ERROR (SEARCH_SIZE_LIMIT_EXCEEDED),
contact_list_op->contacts);
else if (ldap_error == LDAP_SUCCESS)
e_data_book_respond_get_contact_list (op->book,
op->opid,
- GNOME_Evolution_Addressbook_Success,
+ EDB_ERROR (SUCCESS),
contact_list_op->contacts);
else
e_data_book_respond_get_contact_list (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ ldap_error_to_response (ldap_error),
contact_list_op->contacts);
ldap_op_finished (op);
@@ -2648,7 +2575,8 @@ contact_list_handler (LDAPOp *op, LDAPMessage *res)
g_warning ("unhandled search result type %d returned", msg_type);
e_data_book_respond_get_contact_list (op->book,
op->opid,
- GNOME_Evolution_Addressbook_OtherError,
+ e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR,
+ "%s: Unhandled search result type %d returned", G_STRFUNC, msg_type),
NULL);
ldap_op_finished (op);
}
@@ -2684,7 +2612,7 @@ e_book_backend_ldap_get_contact_list (EBookBackend *backend,
switch (bl->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
+ case E_DATA_BOOK_MODE_LOCAL :
if (bl->priv->marked_for_offline && bl->priv->cache) {
GList *contacts;
GList *vcard_strings = NULL;
@@ -2700,19 +2628,18 @@ e_book_backend_ldap_get_contact_list (EBookBackend *backend,
}
g_list_free (contacts);
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_Success, vcard_strings);
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (SUCCESS), vcard_strings);
return;
}
- e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline,
- NULL);
+ 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:
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- 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_NOT_CONNECTED (), NULL);
if (enable_debug)
printf ("e_book_backend_ldap_get_contact_list... ldap handler is NULL\n");
return;
@@ -4398,11 +4325,13 @@ ldap_search_handler (LDAPOp *op, LDAPMessage *res)
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
+ GError *edb_err = EDB_ERROR_NOT_CONNECTED ();
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_OtherError);
+ e_data_book_view_notify_complete (view, edb_err);
ldap_op_finished (op);
if (enable_debug)
printf ("ldap_search_handler... ldap handler is NULL \n");
+ g_error_free (edb_err);
return;
}
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
@@ -4430,6 +4359,7 @@ ldap_search_handler (LDAPOp *op, LDAPMessage *res)
}
}
else if (msg_type == LDAP_RES_SEARCH_RESULT) {
+ GError *edb_err = NULL;
gchar *ldap_error_msg;
gint ldap_error;
@@ -4446,15 +4376,22 @@ ldap_search_handler (LDAPOp *op, LDAPMessage *res)
if ((ldap_error == LDAP_TIMELIMIT_EXCEEDED || ldap_error == LDAP_SIZELIMIT_EXCEEDED) && can_browse ((EBookBackend *)bl))
/* do not complain when search limit exceeded for browseable LDAPs */
- e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_Success);
+ edb_err = EDB_ERROR (SUCCESS);
else if (ldap_error == LDAP_TIMELIMIT_EXCEEDED)
- e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_SearchTimeLimitExceeded);
+ edb_err = EDB_ERROR (SEARCH_TIME_LIMIT_EXCEEDED);
else if (ldap_error == LDAP_SIZELIMIT_EXCEEDED)
- e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_SearchSizeLimitExceeded);
+ edb_err = EDB_ERROR (SEARCH_SIZE_LIMIT_EXCEEDED);
else if (ldap_error == LDAP_SUCCESS)
- e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_Success);
+ edb_err = EDB_ERROR (SUCCESS);
else
- e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_OtherError);
+ edb_err = e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR,
+ "LDAP error 0x%x (%s)", ldap_error,
+ ldap_err2string (ldap_error) ? ldap_err2string (ldap_error) : "Unknown error");
+
+
+ e_data_book_view_notify_complete (view, edb_err);
+ if (edb_err)
+ g_error_free (edb_err);
ldap_op_finished (op);
if (enable_debug) {
@@ -4466,9 +4403,11 @@ ldap_search_handler (LDAPOp *op, LDAPMessage *res)
}
}
else {
+ GError *edb_err = EDB_ERROR (INVALID_QUERY);
g_warning ("unhandled search result type %d returned", msg_type);
- e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_InvalidQuery);
+ e_data_book_view_notify_complete (view, edb_err);
ldap_op_finished (op);
+ g_error_free (edb_err);
}
}
@@ -4505,9 +4444,11 @@ e_book_backend_ldap_search (EBookBackendLDAP *bl,
}
switch (bl->priv->mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL :
+ case E_DATA_BOOK_MODE_LOCAL :
if (!(bl->priv->marked_for_offline && bl->priv->cache)) {
- e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_RepositoryOffline);
+ GError *edb_err = EDB_ERROR (REPOSITORY_OFFLINE);
+ e_data_book_view_notify_complete (view, edb_err);
+ g_error_free (edb_err);
return;
}
@@ -4522,10 +4463,10 @@ e_book_backend_ldap_search (EBookBackendLDAP *bl,
g_list_free (contacts);
- e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (view, NULL /* Success */);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case E_DATA_BOOK_MODE_REMOTE :
ldap_query = e_book_backend_ldap_build_query (bl, e_data_book_view_get_card_query (view));
/* search for nonempty full names */
@@ -4600,13 +4541,8 @@ e_book_backend_ldap_search (EBookBackendLDAP *bl,
}
else {
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- /*
- e_data_book_view_notify_complete (view,
- GNOME_Evolution_Addressbook_InvalidQuery);
- */
/* Ignore NULL query */
- e_data_book_view_notify_complete (view,
- GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (view, NULL /* Success */);
return;
}
}
@@ -4722,8 +4658,7 @@ generate_cache_handler (LDAPOp *op, LDAPMessage *res)
e_book_backend_cache_set_populated (bl->priv->cache);
e_file_cache_thaw_changes (E_FILE_CACHE (bl->priv->cache));
if (book_view)
- e_data_book_view_notify_complete (book_view,
- GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
ldap_op_finished (op);
if (enable_debug) {
g_get_current_time (&end);
@@ -4820,26 +4755,25 @@ e_book_backend_ldap_authenticate_user (EBookBackend *backend,
{
EBookBackendLDAP *bl = E_BOOK_BACKEND_LDAP (backend);
gint ldap_error;
- gint status;
gchar *dn = NULL;
if (enable_debug)
printf ("e_book_backend_ldap_authenticate_user ... \n");
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
- if (bl->priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
+ if (bl->priv->mode == 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);
+ EDB_ERROR (SUCCESS));
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
return;
}
if (bl->priv->connected) {
/* other client connected meanwhile, report success and return */
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR (SUCCESS));
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
return;
}
@@ -4871,7 +4805,7 @@ e_book_backend_ldap_authenticate_user (EBookBackend *backend,
ldap_msgfree (res);
e_data_book_respond_authenticate_user (book,
opid,
- GNOME_Evolution_Addressbook_AuthenticationFailed);
+ EDB_ERROR (AUTHENTICATION_FAILED));
return;
}
@@ -4887,7 +4821,7 @@ e_book_backend_ldap_authenticate_user (EBookBackend *backend,
else {
e_data_book_respond_authenticate_user (book,
opid,
- GNOME_Evolution_Addressbook_PermissionDenied);
+ EDB_ERROR (PERMISSION_DENIED));
return;
}
}
@@ -4905,12 +4839,13 @@ e_book_backend_ldap_authenticate_user (EBookBackend *backend,
printf ("simple auth as %s\n", dn);
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->connected || !bl->priv->ldap) {
+ GError *error;
+
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- status = e_book_backend_ldap_connect (bl);
- if (status != GNOME_Evolution_Addressbook_Success) {
- e_data_book_respond_authenticate_user (book,
- opid, status);
+ error = e_book_backend_ldap_connect (bl);
+ if (error) {
+ e_data_book_respond_authenticate_user (book, opid, error);
return;
}
}
@@ -4941,12 +4876,13 @@ e_book_backend_ldap_authenticate_user (EBookBackend *backend,
g_print ("sasl bind (mech = %s) as %s", auth_method + strlen (SASL_PREFIX), user);
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->connected || !bl->priv->ldap) {
+ GError *error;
+
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- status = e_book_backend_ldap_connect (bl);
- if (status != GNOME_Evolution_Addressbook_Success) {
- e_data_book_respond_authenticate_user (book,
- opid, status);
+ error = e_book_backend_ldap_connect (bl);
+ if (error) {
+ e_data_book_respond_authenticate_user (book, opid, error);
return;
}
}
@@ -4962,7 +4898,7 @@ e_book_backend_ldap_authenticate_user (EBookBackend *backend,
if (ldap_error == LDAP_NOT_SUPPORTED)
e_data_book_respond_authenticate_user (book,
opid,
- GNOME_Evolution_Addressbook_UnsupportedAuthenticationMethod);
+ EDB_ERROR (UNSUPPORTED_AUTHENTICATION_METHOD));
else
e_data_book_respond_authenticate_user (book,
opid,
@@ -4972,7 +4908,7 @@ e_book_backend_ldap_authenticate_user (EBookBackend *backend,
else {
e_data_book_respond_authenticate_user (book,
opid,
- GNOME_Evolution_Addressbook_UnsupportedAuthenticationMethod);
+ EDB_ERROR (UNSUPPORTED_AUTHENTICATION_METHOD));
return;
}
@@ -5018,7 +4954,7 @@ e_book_backend_ldap_get_required_fields (EBookBackend *backend,
e_data_book_respond_get_required_fields (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ EDB_ERROR (SUCCESS),
fields);
g_list_free (fields);
}
@@ -5033,7 +4969,7 @@ e_book_backend_ldap_get_supported_fields (EBookBackend *backend,
e_data_book_respond_get_supported_fields (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ EDB_ERROR (SUCCESS),
bl->priv->supported_fields);
}
@@ -5047,7 +4983,7 @@ e_book_backend_ldap_get_supported_auth_methods (EBookBackend *backend,
e_data_book_respond_get_supported_auth_methods (book,
opid,
- GNOME_Evolution_Addressbook_Success,
+ EDB_ERROR (SUCCESS),
bl->priv->supported_auth_methods);
}
@@ -5064,22 +5000,21 @@ ldap_cancel_op(gpointer key, gpointer value, gpointer data)
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
}
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_ldap_cancel_operation (EBookBackend *backend, EDataBook *book)
+static void
+e_book_backend_ldap_cancel_operation (EBookBackend *backend, EDataBook *book, GError **perror)
{
EBookBackendLDAP *bl = E_BOOK_BACKEND_LDAP (backend);
g_static_rec_mutex_lock (&bl->priv->op_hash_mutex);
g_hash_table_foreach (bl->priv->id_to_op, ldap_cancel_op, bl);
g_static_rec_mutex_unlock (&bl->priv->op_hash_mutex);
-
- return GNOME_Evolution_Addressbook_Success;
}
-static GNOME_Evolution_Addressbook_CallStatus
+static void
e_book_backend_ldap_load_source (EBookBackend *backend,
ESource *source,
- gboolean only_if_exists)
+ gboolean only_if_exists,
+ GError **perror)
{
EBookBackendLDAP *bl = E_BOOK_BACKEND_LDAP (backend);
LDAPURLDesc *lud;
@@ -5089,7 +5024,7 @@ e_book_backend_ldap_load_source (EBookBackend *backend,
gchar *uri;
const gchar *str;
const gchar *offline;
- gint result;
+ GError *err;
gboolean auth_required;
g_assert (bl->priv->connected == FALSE);
@@ -5143,7 +5078,8 @@ e_book_backend_ldap_load_source (EBookBackend *backend,
if (enable_debug)
printf ("e_book_backend_ldap_load_source ... failed to parse the ldap URI %s\n", uri);
g_free (uri);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "Failed to parse LDAP URI"));
+ return;
}
if (bl->priv->cache) {
@@ -5154,7 +5090,7 @@ e_book_backend_ldap_load_source (EBookBackend *backend,
bl->priv->cache = e_book_backend_cache_new (uri);
g_free (uri);
- if (bl->priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
+ if (bl->priv->mode == E_DATA_BOOK_MODE_LOCAL) {
/* Offline */
e_book_backend_set_is_loaded (backend, TRUE);
@@ -5162,15 +5098,19 @@ e_book_backend_ldap_load_source (EBookBackend *backend,
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_notify_connection_status (backend, FALSE);
- if (!bl->priv->marked_for_offline)
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
+ if (!bl->priv->marked_for_offline) {
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
+ }
#if 0
- if (!e_book_backend_cache_is_populated (bl->priv->cache))
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
+ if (!e_book_backend_cache_is_populated (bl->priv->cache)) {
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
+ }
#endif
- return GNOME_Evolution_Addressbook_Success;
+ return;
} else {
e_book_backend_set_is_writable (backend, TRUE);
e_book_backend_notify_writable (backend, TRUE);
@@ -5188,26 +5128,25 @@ e_book_backend_ldap_load_source (EBookBackend *backend,
if (!e_book_backend_is_loaded (backend))
e_book_backend_notify_auth_required (backend);
e_book_backend_set_is_loaded (backend, TRUE);
- return GNOME_Evolution_Addressbook_Success;
+ return;
}
/* Online */
- result = e_book_backend_ldap_connect (bl);
- if (result != GNOME_Evolution_Addressbook_Success) {
+ err = e_book_backend_ldap_connect (bl);
+ if (err) {
if (enable_debug)
printf ("e_book_backend_ldap_load_source ... failed to connect to server \n");
- return result;
+ g_propagate_error (perror, err);
+ return;
}
if (auth_required && !e_book_backend_is_loaded (backend)) {
e_book_backend_notify_auth_required (E_BOOK_BACKEND (bl));
- return result;
+ return;
}
if (bl->priv->marked_for_offline)
generate_cache (bl);
-
- return result;
}
static void
@@ -5216,7 +5155,7 @@ e_book_backend_ldap_remove (EBookBackend *backend, EDataBook *book, guint32 opid
/* if we ever add caching, we'll remove it here, but for now,
just report back Success */
- e_data_book_respond_remove (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_remove (book, opid, EDB_ERROR (SUCCESS));
}
static gchar *
@@ -5270,7 +5209,7 @@ start_views (EBookBackend *backend)
static void
e_book_backend_ldap_set_mode (EBookBackend *backend,
- GNOME_Evolution_Addressbook_BookMode mode)
+ EDataBookMode mode)
{
EBookBackendLDAP *bl = E_BOOK_BACKEND_LDAP (backend);
@@ -5283,9 +5222,9 @@ e_book_backend_ldap_set_mode (EBookBackend *backend,
#endif
/* Cancel all running operations */
- e_book_backend_ldap_cancel_operation (backend, NULL);
+ e_book_backend_ldap_cancel_operation (backend, NULL, NULL);
- if (mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
+ if (mode == E_DATA_BOOK_MODE_LOCAL) {
/* Go offline */
e_book_backend_set_is_writable (backend, FALSE);
@@ -5308,7 +5247,7 @@ e_book_backend_ldap_set_mode (EBookBackend *backend,
start_views (backend);
#endif
}
- else if (mode == GNOME_Evolution_Addressbook_MODE_REMOTE) {
+ else if (mode == E_DATA_BOOK_MODE_REMOTE) {
/* Go online */
e_book_backend_set_is_writable (backend, TRUE);
@@ -5316,9 +5255,13 @@ e_book_backend_ldap_set_mode (EBookBackend *backend,
e_book_backend_notify_connection_status (backend, TRUE);
if (e_book_backend_is_loaded (backend)) {
- e_book_backend_ldap_connect (bl);
+ GError *error;
+
+ error = e_book_backend_ldap_connect (bl);
e_book_backend_notify_auth_required (backend);
+ if (error)
+ g_error_free (error);
#if 0
start_views (backend);
#endif
@@ -5478,7 +5421,7 @@ e_book_backend_ldap_init (EBookBackendLDAP *backend)
priv->id_to_op = g_hash_table_new (g_int_hash, g_int_equal);
priv->poll_timeout = -1;
priv->marked_for_offline = FALSE;
- priv->mode = GNOME_Evolution_Addressbook_MODE_REMOTE;
+ priv->mode = E_DATA_BOOK_MODE_REMOTE;
priv->is_summary_ready = FALSE;
priv->reserved1 = NULL;
priv->reserved2 = NULL;
diff --git a/addressbook/backends/vcf/e-book-backend-vcf.c b/addressbook/backends/vcf/e-book-backend-vcf.c
index 467dd49..c07de85 100644
--- a/addressbook/backends/vcf/e-book-backend-vcf.c
+++ b/addressbook/backends/vcf/e-book-backend-vcf.c
@@ -56,6 +56,8 @@
#define d(x)
+#define EDB_ERROR(_code) e_data_book_create_error (E_DATA_BOOK_STATUS_ ## _code, NULL)
+
G_DEFINE_TYPE (EBookBackendVCF, e_book_backend_vcf, E_TYPE_BOOK_BACKEND_SYNC)
typedef struct _EBookBackendVCFBookView EBookBackendVCFBookView;
@@ -268,32 +270,31 @@ do_create(EBookBackendVCF *bvcf,
return contact;
}
-static EBookBackendSyncStatus
+static void
e_book_backend_vcf_create_contact (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *vcard,
- EContact **contact)
+ EContact **contact,
+ GError **perror)
{
EBookBackendVCF *bvcf = E_BOOK_BACKEND_VCF (backend);
*contact = do_create(bvcf, vcard, TRUE);
- if (*contact) {
- return GNOME_Evolution_Addressbook_Success;
- }
- else {
+ if (!*contact) {
/* XXX need a different call status for this case, i
think */
- return GNOME_Evolution_Addressbook_ContactNotFound;
+ g_propagate_error (perror, EDB_ERROR (CONTACT_NOT_FOUND));
}
}
-static EBookBackendSyncStatus
+static void
e_book_backend_vcf_remove_contacts (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
GList *id_list,
- GList **ids)
+ GList **ids,
+ GError **perror)
{
/* FIXME: make this handle bulk deletes like the file backend does */
EBookBackendVCF *bvcf = E_BOOK_BACKEND_VCF (backend);
@@ -304,12 +305,14 @@ e_book_backend_vcf_remove_contacts (EBookBackendSync *backend,
elem = g_hash_table_lookup (bvcf->priv->contacts, id);
if (!elem) {
g_mutex_unlock (bvcf->priv->mutex);
- return GNOME_Evolution_Addressbook_ContactNotFound;
+ g_propagate_error (perror, EDB_ERROR (CONTACT_NOT_FOUND));
+ return;
}
if (!g_hash_table_remove (bvcf->priv->contacts, id)) {
g_mutex_unlock (bvcf->priv->mutex);
- return GNOME_Evolution_Addressbook_ContactNotFound;
+ g_propagate_error (perror, EDB_ERROR (CONTACT_NOT_FOUND));
+ return;
}
g_free (elem->data);
@@ -322,16 +325,15 @@ e_book_backend_vcf_remove_contacts (EBookBackendSync *backend,
g_mutex_unlock (bvcf->priv->mutex);
*ids = g_list_append (*ids, id);
-
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
+static void
e_book_backend_vcf_modify_contact (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *vcard,
- EContact **contact)
+ EContact **contact,
+ GError **perror)
{
EBookBackendVCF *bvcf = E_BOOK_BACKEND_VCF (backend);
GList *elem;
@@ -345,7 +347,8 @@ e_book_backend_vcf_modify_contact (EBookBackendSync *backend,
elem = g_hash_table_lookup (bvcf->priv->contacts, id);
if (!elem) {
g_mutex_unlock (bvcf->priv->mutex);
- return GNOME_Evolution_Addressbook_ContactNotFound;
+ g_propagate_error (perror, EDB_ERROR (CONTACT_NOT_FOUND));
+ return;
}
g_free (elem->data);
@@ -355,16 +358,15 @@ e_book_backend_vcf_modify_contact (EBookBackendSync *backend,
bvcf->priv->flush_timeout_tag = g_timeout_add (FILE_FLUSH_TIMEOUT,
vcf_flush_file, bvcf);
g_mutex_unlock (bvcf->priv->mutex);
-
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
+static void
e_book_backend_vcf_get_contact (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *id,
- gchar **vcard)
+ gchar **vcard,
+ GError **perror)
{
EBookBackendVCF *bvcf = E_BOOK_BACKEND_VCF (backend);
GList *elem;
@@ -373,10 +375,9 @@ e_book_backend_vcf_get_contact (EBookBackendSync *backend,
if (elem) {
*vcard = g_strdup (elem->data);
- return GNOME_Evolution_Addressbook_Success;
} else {
*vcard = g_strdup ("");
- return GNOME_Evolution_Addressbook_ContactNotFound;
+ g_propagate_error (perror, EDB_ERROR (CONTACT_NOT_FOUND));
}
}
@@ -395,12 +396,13 @@ foreach_get_contact_compare (gchar *vcard_string, GetContactListClosure *closure
}
}
-static EBookBackendSyncStatus
+static void
e_book_backend_vcf_get_contact_list (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *query,
- GList **contacts)
+ GList **contacts,
+ GError **perror)
{
EBookBackendVCF *bvcf = E_BOOK_BACKEND_VCF (backend);
const gchar *search = query;
@@ -416,7 +418,6 @@ e_book_backend_vcf_get_contact_list (EBookBackendSync *backend,
g_object_unref (closure.card_sexp);
*contacts = closure.list;
- return GNOME_Evolution_Addressbook_Success;
}
typedef struct {
@@ -489,7 +490,7 @@ book_view_thread (gpointer data)
}
if (e_flag_is_set (closure->running))
- e_data_book_view_notify_complete (closure->view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (closure->view, NULL /* Success */);
/* unref the book view */
e_data_book_view_unref (book_view);
@@ -538,35 +539,37 @@ e_book_backend_vcf_extract_path_from_uri (const gchar *uri)
return g_strdup (uri + 6);
}
-static EBookBackendSyncStatus
+static void
e_book_backend_vcf_authenticate_user (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *user,
const gchar *passwd,
- const gchar *auth_method)
+ const gchar *auth_method,
+ GError **perror)
{
- return GNOME_Evolution_Addressbook_Success;
+ /* Success */
}
-static EBookBackendSyncStatus
+static void
e_book_backend_vcf_get_required_fields (EBookBackendSync *backend,
- EDataBook *book,
- guint32 opid,
- GList **fields_out)
+ EDataBook *book,
+ guint32 opid,
+ GList **fields_out,
+ GError **perror)
{
GList *fields = NULL;
fields = g_list_append (fields , g_strdup(e_contact_field_name (E_CONTACT_FILE_AS)));
*fields_out = fields;
- return GNOME_Evolution_Addressbook_Success;
}
-static EBookBackendSyncStatus
+static void
e_book_backend_vcf_get_supported_fields (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
- GList **fields_out)
+ GList **fields_out,
+ GError **perror)
{
GList *fields = NULL;
gint i;
@@ -577,17 +580,17 @@ e_book_backend_vcf_get_supported_fields (EBookBackendSync *backend,
fields = g_list_append (fields, (gchar *)e_contact_field_name (i));
*fields_out = fields;
- return GNOME_Evolution_Addressbook_Success;
}
#ifdef CREATE_DEFAULT_VCARD
# include <libedata-book/ximian-vcard.h>
#endif
-static GNOME_Evolution_Addressbook_CallStatus
+static void
e_book_backend_vcf_load_source (EBookBackend *backend,
ESource *source,
- gboolean only_if_exists)
+ gboolean only_if_exists,
+ GError **perror)
{
EBookBackendVCF *bvcf = E_BOOK_BACKEND_VCF (backend);
gchar *dirname;
@@ -620,10 +623,12 @@ e_book_backend_vcf_load_source (EBookBackend *backend,
rv = g_mkdir_with_parents (dirname, 0700);
if (rv == -1 && errno != EEXIST) {
g_warning ("failed to make directory %s: %s", dirname, g_strerror (errno));
- if (errno == EACCES || errno == EPERM)
- return GNOME_Evolution_Addressbook_PermissionDenied;
- else
- return GNOME_Evolution_Addressbook_OtherError;
+ if (errno == EACCES || errno == EPERM) {
+ g_propagate_error (perror, EDB_ERROR (PERMISSION_DENIED));
+ } else {
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "Failed to make directory %s: %s", dirname, g_strerror (errno)));
+ }
+ return;
}
fd = g_open (bvcf->priv->filename, O_CREAT | O_BINARY, 0666);
@@ -647,8 +652,9 @@ e_book_backend_vcf_load_source (EBookBackend *backend,
if (fd == -1) {
g_warning ("Failed to open addressbook at uri `%s'", uri);
g_warning ("error == %s", g_strerror(errno));
+ g_propagate_error (perror, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "Failed to open addressbook at uri '%s': %s", uri, g_strerror (errno)));
g_free (uri);
- return GNOME_Evolution_Addressbook_OtherError;
+ return;
}
load_file (bvcf, fd);
@@ -657,7 +663,6 @@ e_book_backend_vcf_load_source (EBookBackend *backend,
e_book_backend_set_is_writable (backend, writable);
g_free (uri);
- return GNOME_Evolution_Addressbook_Success;
}
static gchar *
@@ -666,15 +671,15 @@ e_book_backend_vcf_get_static_capabilities (EBookBackend *backend)
return g_strdup("local,do-initial-query,contact-lists");
}
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_vcf_cancel_operation (EBookBackend *backend, EDataBook *book)
+static void
+e_book_backend_vcf_cancel_operation (EBookBackend *backend, EDataBook *book, GError **perror)
{
- return GNOME_Evolution_Addressbook_CouldNotCancel;
+ g_propagate_error (perror, EDB_ERROR (COULD_NOT_CANCEL));
}
static void
e_book_backend_vcf_set_mode (EBookBackend *backend,
- GNOME_Evolution_Addressbook_BookMode mode)
+ EDataBookMode mode)
{
if (e_book_backend_is_loaded (backend)) {
e_book_backend_notify_writable (backend, TRUE);
diff --git a/addressbook/backends/webdav/e-book-backend-webdav.c b/addressbook/backends/webdav/e-book-backend-webdav.c
index d0d374b..92667af 100644
--- a/addressbook/backends/webdav/e-book-backend-webdav.c
+++ b/addressbook/backends/webdav/e-book-backend-webdav.c
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <glib.h>
+#include <glib/gi18n-lib.h>
#include <libedataserver/e-url.h>
#include <libedataserver/e-flag.h>
@@ -52,6 +53,9 @@
#include <libxml/xpath.h>
#include <libxml/xpathInternals.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)
+
#define USERAGENT "Evolution/" VERSION
#define WEBDAV_CLOSURE_NAME "EBookBackendWebdav.BookView::closure"
#define WEBDAV_CTAG_KEY "WEBDAV_CTAG"
@@ -271,8 +275,8 @@ upload_contact(EBookBackendWebdav *webdav, EContact *contact)
return status;
}
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_handle_auth_request(EBookBackendWebdav *webdav)
+static GError *
+webdav_handle_auth_request(EBookBackendWebdav *webdav)
{
EBookBackendWebdavPrivate *priv = webdav->priv;
@@ -282,9 +286,9 @@ e_book_backend_handle_auth_request(EBookBackendWebdav *webdav)
g_free(priv->password);
priv->password = NULL;
- return GNOME_Evolution_Addressbook_AuthenticationFailed;
+ return EDB_ERROR (AUTHENTICATION_FAILED);
} else {
- return GNOME_Evolution_Addressbook_AuthenticationRequired;
+ return EDB_ERROR (AUTHENTICATION_REQUIRED);
}
}
@@ -298,9 +302,8 @@ e_book_backend_webdav_create_contact(EBookBackend *backend,
gchar *uid;
guint status;
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
- e_data_book_respond_create(book, opid,
- GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL) {
+ e_data_book_respond_create (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
}
@@ -319,14 +322,12 @@ e_book_backend_webdav_create_contact(EBookBackend *backend,
if (status != 201 && status != 204) {
g_object_unref(contact);
if (status == 401 || status == 407) {
- GNOME_Evolution_Addressbook_CallStatus res
- = e_book_backend_handle_auth_request(webdav);
- e_data_book_respond_create(book, opid, res, NULL);
+ e_data_book_respond_create (book, opid, webdav_handle_auth_request (webdav), NULL);
} else {
- g_warning("create resource '%s' failed with http status: %d",
- uid, status);
- e_data_book_respond_create(book, opid,
- GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_create (book, opid,
+ e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR,
+ _("Create resource '%s' failed with http status: %d"), uid, status),
+ NULL);
}
g_free(uid);
return;
@@ -342,8 +343,8 @@ e_book_backend_webdav_create_contact(EBookBackend *backend,
g_object_unref(contact);
if (new_contact == NULL) {
- e_data_book_respond_create(book, opid,
- GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_create (book, opid,
+ EDB_ERROR (OTHER_ERROR), NULL);
g_free(uid);
return;
}
@@ -351,8 +352,7 @@ e_book_backend_webdav_create_contact(EBookBackend *backend,
}
e_book_backend_cache_add_contact(priv->cache, contact);
- e_data_book_respond_create(book, opid,
- GNOME_Evolution_Addressbook_Success, contact);
+ e_data_book_respond_create (book, opid, EDB_ERROR (SUCCESS), contact);
if (contact)
g_object_unref(contact);
@@ -384,9 +384,9 @@ e_book_backend_webdav_remove_contacts(EBookBackend *backend,
GList *deleted_ids = NULL;
GList *list;
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
- e_data_book_respond_create(book, opid,
- GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL) {
+ e_data_book_respond_remove_contacts (book, opid,
+ EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
}
@@ -397,9 +397,7 @@ e_book_backend_webdav_remove_contacts(EBookBackend *backend,
status = delete_contact(webdav, uid);
if (status != 204) {
if (status == 401 || status == 407) {
- GNOME_Evolution_Addressbook_CallStatus res
- = e_book_backend_handle_auth_request(webdav);
- e_data_book_respond_remove_contacts(book, opid, res,
+ e_data_book_respond_remove_contacts (book, opid, webdav_handle_auth_request (webdav),
deleted_ids);
} else {
g_warning("DELETE failed with http status %d", status);
@@ -411,7 +409,7 @@ e_book_backend_webdav_remove_contacts(EBookBackend *backend,
}
e_data_book_respond_remove_contacts (book, opid,
- GNOME_Evolution_Addressbook_Success, deleted_ids);
+ EDB_ERROR (SUCCESS), deleted_ids);
}
static void
@@ -425,9 +423,9 @@ e_book_backend_webdav_modify_contact(EBookBackend *backend,
const gchar *etag;
guint status;
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL) {
e_data_book_respond_create(book, opid,
- GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
+ EDB_ERROR (REPOSITORY_OFFLINE), NULL);
g_object_unref(contact);
return;
}
@@ -437,23 +435,23 @@ e_book_backend_webdav_modify_contact(EBookBackend *backend,
if (status != 201 && status != 204) {
g_object_unref(contact);
if (status == 401 || status == 407) {
- GNOME_Evolution_Addressbook_CallStatus res
- = e_book_backend_handle_auth_request(webdav);
- e_data_book_respond_remove_contacts(book, opid, res, NULL);
+ e_data_book_respond_remove_contacts (book, opid, webdav_handle_auth_request (webdav), NULL);
return;
}
/* data changed on server while we were editing */
if (status == 412) {
- g_warning("contact on server changed -> not modifying");
/* too bad no special error code in evolution for this... */
- e_data_book_respond_modify(book, opid,
- GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_modify (book, opid,
+ e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR,
+ "Contact on server changed -> not modifying"),
+ NULL);
return;
}
- g_warning("modify contact failed with http status: %d", status);
- e_data_book_respond_modify(book, opid,
- GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_modify (book, opid,
+ e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR,
+ "Modify contact failed with http status: %d", status),
+ NULL);
return;
}
@@ -474,8 +472,7 @@ e_book_backend_webdav_modify_contact(EBookBackend *backend,
}
e_book_backend_cache_add_contact(priv->cache, contact);
- e_data_book_respond_modify(book, opid,
- GNOME_Evolution_Addressbook_Success, contact);
+ e_data_book_respond_modify (book, opid, EDB_ERROR (SUCCESS), contact);
g_object_unref(contact);
}
@@ -489,7 +486,7 @@ e_book_backend_webdav_get_contact(EBookBackend *backend, EDataBook *book,
EContact *contact;
gchar *vcard;
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL) {
contact = e_book_backend_cache_get_contact(priv->cache, uid);
} else {
contact = download_contact(webdav, uid);
@@ -501,14 +498,12 @@ e_book_backend_webdav_get_contact(EBookBackend *backend, EDataBook *book,
}
if (contact == NULL) {
- e_data_book_respond_get_contact(book, opid,
- GNOME_Evolution_Addressbook_OtherError, NULL);
+ e_data_book_respond_get_contact (book, opid, EDB_ERROR (CONTACT_NOT_FOUND), NULL);
return;
}
vcard = e_vcard_to_string(E_VCARD(contact), EVC_FORMAT_VCARD_30);
- e_data_book_respond_get_contact(book, opid,
- GNOME_Evolution_Addressbook_Success, vcard);
+ e_data_book_respond_get_contact (book, opid, EDB_ERROR (SUCCESS), vcard);
g_free(vcard);
g_object_unref(contact);
}
@@ -814,7 +809,7 @@ check_addressbook_changed (EBookBackendWebdav *webdav, gchar **new_ctag)
return res;
}
-static GNOME_Evolution_Addressbook_CallStatus
+static GError *
download_contacts(EBookBackendWebdav *webdav, EFlag *running,
EDataBookView *book_view)
{
@@ -844,7 +839,7 @@ download_contacts(EBookBackendWebdav *webdav, EFlag *running,
g_list_free (contact_list);
}
g_free (new_ctag);
- return GNOME_Evolution_Addressbook_Success;
+ return EDB_ERROR (SUCCESS);
}
if (book_view != NULL) {
@@ -856,29 +851,26 @@ download_contacts(EBookBackendWebdav *webdav, EFlag *running,
status = message->status_code;
if (status == 401 || status == 407) {
- GNOME_Evolution_Addressbook_CallStatus res
- = e_book_backend_handle_auth_request(webdav);
g_object_unref(message);
g_free (new_ctag);
if (book_view)
e_data_book_view_unref(book_view);
- return res;
+ return webdav_handle_auth_request (webdav);
}
if (status != 207) {
- g_warning("PROPFIND on webdav failed with http status %d", status);
g_object_unref(message);
g_free (new_ctag);
if (book_view)
e_data_book_view_unref(book_view);
- return GNOME_Evolution_Addressbook_OtherError;
+ return e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "PROPFIND on webdav failed with http status %d", status);
}
if (message->response_body == NULL) {
- g_warning("No response body in webdav PROPEFIND result");
+ g_warning("No response body in webdav PROPFIND result");
g_object_unref(message);
g_free (new_ctag);
if (book_view)
e_data_book_view_unref(book_view);
- return GNOME_Evolution_Addressbook_OtherError;
+ return e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "No response body in webdav PROPFIND result");
}
/* parse response */
@@ -967,7 +959,7 @@ download_contacts(EBookBackendWebdav *webdav, EFlag *running,
}
g_free (new_ctag);
- return GNOME_Evolution_Addressbook_Success;
+ return EDB_ERROR (SUCCESS);
}
static gpointer
@@ -976,7 +968,7 @@ book_view_thread(gpointer data)
EDataBookView *book_view = data;
WebdavBackendSearchClosure *closure = get_closure(book_view);
EBookBackendWebdav *webdav = closure->webdav;
- GNOME_Evolution_Addressbook_CallStatus status;
+ GError *error;
e_flag_set(closure->running);
@@ -984,12 +976,15 @@ book_view_thread(gpointer data)
* it's stopped */
e_data_book_view_ref(book_view);
- status = download_contacts(webdav, closure->running, book_view);
+ error = download_contacts (webdav, closure->running, book_view);
e_data_book_view_unref(book_view);
/* report back status if query wasn't aborted */
- e_data_book_view_notify_complete(book_view, status);
+ e_data_book_view_notify_complete (book_view, error);
+
+ if (error)
+ g_error_free (error);
return NULL;
}
@@ -1000,7 +995,7 @@ e_book_backend_webdav_start_book_view(EBookBackend *backend,
EBookBackendWebdav *webdav = E_BOOK_BACKEND_WEBDAV(backend);
EBookBackendWebdavPrivate *priv = webdav->priv;
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_REMOTE) {
+ if (priv->mode == E_DATA_BOOK_MODE_REMOTE) {
WebdavBackendSearchClosure *closure
= init_closure(book_view, E_BOOK_BACKEND_WEBDAV(backend));
@@ -1019,8 +1014,7 @@ e_book_backend_webdav_start_book_view(EBookBackend *backend,
g_object_unref(contact);
}
g_list_free(contacts);
- e_data_book_view_notify_complete(book_view,
- GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
}
}
@@ -1032,7 +1026,7 @@ e_book_backend_webdav_stop_book_view(EBookBackend *backend,
WebdavBackendSearchClosure *closure;
gboolean need_join;
- if (webdav->priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL)
+ if (webdav->priv->mode == E_DATA_BOOK_MODE_LOCAL)
return;
closure = get_closure(book_view);
@@ -1057,13 +1051,12 @@ e_book_backend_webdav_get_contact_list(EBookBackend *backend, EDataBook *book,
GList *vcard_list;
GList *c;
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_REMOTE) {
+ if (priv->mode == E_DATA_BOOK_MODE_REMOTE) {
/* make sure the cache is up to date */
- GNOME_Evolution_Addressbook_CallStatus status =
- download_contacts(webdav, NULL, NULL);
+ GError *error = download_contacts (webdav, NULL, NULL);
- if (status != GNOME_Evolution_Addressbook_Success) {
- e_data_book_respond_get_contact_list(book, opid, status, NULL);
+ if (error) {
+ e_data_book_respond_get_contact_list (book, opid, error, NULL);
return;
}
}
@@ -1080,8 +1073,7 @@ e_book_backend_webdav_get_contact_list(EBookBackend *backend, EDataBook *book,
}
g_list_free(contact_list);
- e_data_book_respond_get_contact_list(book, opid,
- GNOME_Evolution_Addressbook_Success, vcard_list);
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (SUCCESS), vcard_list);
}
static void
@@ -1109,11 +1101,9 @@ e_book_backend_webdav_authenticate_user(EBookBackend *backend, EDataBook *book,
g_free(priv->password);
priv->password = NULL;
- e_data_book_respond_authenticate_user(book, opid,
- GNOME_Evolution_Addressbook_AuthenticationFailed);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR (AUTHENTICATION_FAILED));
} else {
- e_data_book_respond_authenticate_user(book, opid,
- GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_authenticate_user (book, opid, EDB_ERROR (SUCCESS));
}
}
@@ -1129,8 +1119,7 @@ e_book_backend_webdav_get_supported_fields(EBookBackend *backend,
fields = g_list_append(fields, g_strdup(e_contact_field_name(i)));
}
- e_data_book_respond_get_supported_fields(book, opid,
- GNOME_Evolution_Addressbook_Success, fields);
+ e_data_book_respond_get_supported_fields (book, opid, EDB_ERROR (SUCCESS), fields);
g_list_foreach(fields, (GFunc) g_free, NULL);
g_list_free(fields);
}
@@ -1143,8 +1132,7 @@ e_book_backend_webdav_get_supported_auth_methods(EBookBackend *backend,
auth_methods = g_list_append(auth_methods, g_strdup("plain/password"));
- e_data_book_respond_get_supported_auth_methods(book, opid,
- GNOME_Evolution_Addressbook_Success, auth_methods);
+ e_data_book_respond_get_supported_auth_methods (book, opid, EDB_ERROR (SUCCESS), auth_methods);
g_list_foreach(auth_methods, (GFunc) g_free, NULL);
g_list_free(auth_methods);
@@ -1160,8 +1148,7 @@ e_book_backend_webdav_get_required_fields(EBookBackend *backend,
field_name = e_contact_field_name(E_CONTACT_FILE_AS);
fields = g_list_append(fields , g_strdup(field_name));
- e_data_book_respond_get_supported_fields(book, opid,
- GNOME_Evolution_Addressbook_Success, fields);
+ e_data_book_respond_get_supported_fields (book, opid, EDB_ERROR (SUCCESS), fields);
g_list_free (fields);
}
@@ -1198,9 +1185,9 @@ proxy_settings_changed (EProxy *proxy, gpointer user_data)
g_object_set (priv->session, SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
}
-static GNOME_Evolution_Addressbook_CallStatus
+static void
e_book_backend_webdav_load_source(EBookBackend *backend,
- ESource *source, gboolean only_if_exists)
+ ESource *source, gboolean only_if_exists, GError **perror)
{
EBookBackendWebdav *webdav = E_BOOK_BACKEND_WEBDAV(backend);
EBookBackendWebdavPrivate *priv = webdav->priv;
@@ -1215,32 +1202,34 @@ e_book_backend_webdav_load_source(EBookBackend *backend,
uri = e_source_get_uri(source);
if (uri == NULL) {
- g_warning("no uri given for addressbook");
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "No uri given for addressbook"));
+ return;
}
suri = soup_uri_new (uri);
g_free (uri);
if (!suri) {
- g_warning ("invalid uri given for addressbook");
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "Invalid uri given for addressbook"));
+ return;
}
offline = e_source_get_property(source, "offline_sync");
if (offline && g_str_equal(offline, "1"))
priv->marked_for_offline = TRUE;
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL
+ if (priv->mode == E_DATA_BOOK_MODE_LOCAL
&& !priv->marked_for_offline ) {
soup_uri_free (suri);
- return GNOME_Evolution_Addressbook_OfflineUnavailable;
+ g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ return;
}
if (!suri->scheme || !g_str_equal (suri->scheme, "webdav")) {
/* the book is not for us */
soup_uri_free (suri);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "Not a webdav uri"));
+ return;
}
use_ssl = e_source_get_property (source, "use_ssl");
@@ -1276,7 +1265,8 @@ e_book_backend_webdav_load_source(EBookBackend *backend,
priv->uri = soup_uri_to_string (suri, FALSE);
if (!priv->uri) {
soup_uri_free (suri);
- return GNOME_Evolution_Addressbook_OtherError;
+ g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "Cannot transform SoupURI to string"));
+ return;
}
priv->cache = e_book_backend_cache_new(priv->uri);
@@ -1299,20 +1289,18 @@ e_book_backend_webdav_load_source(EBookBackend *backend,
e_book_backend_notify_writable(backend, TRUE);
soup_uri_free (suri);
-
- return GNOME_Evolution_Addressbook_Success;
}
static void
e_book_backend_webdav_remove(EBookBackend *backend, EDataBook *book,
guint32 opid)
{
- e_data_book_respond_remove(book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_remove (book, opid, EDB_ERROR (SUCCESS));
}
static void
e_book_backend_webdav_set_mode(EBookBackend *backend,
- GNOME_Evolution_Addressbook_BookMode mode)
+ EDataBookMode mode)
{
EBookBackendWebdav *webdav = E_BOOK_BACKEND_WEBDAV(backend);
@@ -1322,11 +1310,11 @@ e_book_backend_webdav_set_mode(EBookBackend *backend,
if (!e_book_backend_is_loaded(backend))
return;
- if (mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
+ if (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);
- } else if (mode == GNOME_Evolution_Addressbook_MODE_REMOTE) {
+ } else if (mode == E_DATA_BOOK_MODE_REMOTE) {
e_book_backend_set_is_writable(backend, TRUE);
e_book_backend_notify_writable(backend, TRUE);
e_book_backend_notify_connection_status(backend, TRUE);
@@ -1339,10 +1327,10 @@ e_book_backend_webdav_get_static_capabilities(EBookBackend *backend)
return g_strdup("net,do-initial-query,contact-lists");
}
-static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_webdav_cancel_operation(EBookBackend *backend, EDataBook *book)
+static void
+e_book_backend_webdav_cancel_operation (EBookBackend *backend, EDataBook *book, GError **perror)
{
- return GNOME_Evolution_Addressbook_CouldNotCancel;
+ g_propagate_error (perror, EDB_ERROR (COULD_NOT_CANCEL));
}
EBookBackend *
diff --git a/addressbook/libebook/e-book-marshal.list b/addressbook/libebook/e-book-marshal.list
index 680ea03..4f34146 100644
--- a/addressbook/libebook/e-book-marshal.list
+++ b/addressbook/libebook/e-book-marshal.list
@@ -3,3 +3,4 @@ NONE:BOOL
NONE:POINTER
NONE:STRING
NONE:INT
+NONE:UINT,STRING
diff --git a/addressbook/libebook/e-book-types.h b/addressbook/libebook/e-book-types.h
index a927079..72564dd 100644
--- a/addressbook/libebook/e-book-types.h
+++ b/addressbook/libebook/e-book-types.h
@@ -39,15 +39,20 @@ typedef enum {
E_BOOK_ERROR_AUTHENTICATION_FAILED,
E_BOOK_ERROR_AUTHENTICATION_REQUIRED,
E_BOOK_ERROR_TLS_NOT_AVAILABLE,
- E_BOOK_ERROR_CORBA_EXCEPTION,
+ E_BOOK_ERROR_DBUS_EXCEPTION,
E_BOOK_ERROR_NO_SUCH_SOURCE,
E_BOOK_ERROR_OFFLINE_UNAVAILABLE,
E_BOOK_ERROR_OTHER_ERROR,
E_BOOK_ERROR_INVALID_SERVER_VERSION,
E_BOOK_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD,
- E_BOOK_ERROR_NO_SPACE
+ E_BOOK_ERROR_NO_SPACE,
+ E_BOOK_ERROR_NOT_SUPPORTED
} EBookStatus;
+#ifndef E_BOOK_DISABLE_DEPRECATED
+#define E_BOOK_ERROR_CORBA_EXCEPTION E_BOOK_ERROR_DBUS_EXCEPTION
+#endif
+
typedef enum {
E_BOOK_VIEW_STATUS_OK,
E_BOOK_VIEW_STATUS_TIME_LIMIT_EXCEEDED,
diff --git a/addressbook/libebook/e-book-view.c b/addressbook/libebook/e-book-view.c
index 54093a2..c628c55 100644
--- a/addressbook/libebook/e-book-view.c
+++ b/addressbook/libebook/e-book-view.c
@@ -27,6 +27,7 @@
#include "e-book-view-private.h"
#include "e-data-book-view-bindings.h"
#include "e-book-marshal.h"
+#include "libedata-book/e-data-book-types.h"
G_DEFINE_TYPE(EBookView, e_book_view, G_TYPE_OBJECT);
@@ -44,7 +45,10 @@ enum {
CONTACTS_CHANGED,
CONTACTS_REMOVED,
CONTACTS_ADDED,
+ #ifndef E_BOOK_DISABLE_DEPRECATED
SEQUENCE_COMPLETE,
+ #endif
+ VIEW_COMPLETE,
STATUS_MESSAGE,
LAST_SIGNAL
};
@@ -121,12 +125,37 @@ contacts_removed_cb (DBusGProxy *proxy, const gchar **ids, EBookView *book_view)
}
static void
-complete_cb (DBusGProxy *proxy, guint status, EBookView *book_view)
+complete_cb (DBusGProxy *proxy, EDataBookStatus status, const gchar *message, EBookView *book_view)
{
+ EBookViewStatus bv_status = E_BOOK_VIEW_ERROR_OTHER_ERROR;
+
if (!book_view->priv->running)
return;
- g_signal_emit (book_view, signals[SEQUENCE_COMPLETE], 0, status);
+ switch (status) {
+ case E_DATA_BOOK_STATUS_SUCCESS:
+ bv_status = E_BOOK_VIEW_STATUS_OK;
+ break;
+ case E_DATA_BOOK_STATUS_SEARCH_TIME_LIMIT_EXCEEDED:
+ bv_status = E_BOOK_VIEW_STATUS_TIME_LIMIT_EXCEEDED;
+ break;
+ case E_DATA_BOOK_STATUS_SEARCH_SIZE_LIMIT_EXCEEDED:
+ bv_status = E_BOOK_VIEW_STATUS_SIZE_LIMIT_EXCEEDED;
+ break;
+ case E_DATA_BOOK_STATUS_INVALID_QUERY:
+ bv_status = E_BOOK_VIEW_ERROR_INVALID_QUERY;
+ break;
+ case E_DATA_BOOK_STATUS_QUERY_REFUSED:
+ bv_status = E_BOOK_VIEW_ERROR_QUERY_REFUSED;
+ break;
+ default:
+ break;
+ }
+
+ #ifndef E_BOOK_DISABLE_DEPRECATED
+ g_signal_emit (book_view, signals[SEQUENCE_COMPLETE], 0, bv_status);
+ #endif
+ g_signal_emit (book_view, signals[VIEW_COMPLETE], 0, bv_status, message);
}
#define LOCK_CONN() g_static_rec_mutex_lock (book_view->priv->view_proxy_lock)
@@ -159,6 +188,8 @@ _e_book_view_new (EBook *book, DBusGProxy *view_proxy, GStaticRecMutex *view_pro
priv->view_proxy_lock = view_proxy_lock;
g_object_add_weak_pointer (G_OBJECT (view_proxy), (gpointer)&priv->view_proxy);
+ dbus_g_object_register_marshaller (e_book_marshal_VOID__UINT_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
+
dbus_g_proxy_add_signal (view_proxy, "StatusMessage", G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (view_proxy, "StatusMessage", G_CALLBACK (status_message_cb), view, NULL);
dbus_g_proxy_add_signal (view_proxy, "ContactsAdded", G_TYPE_STRV, G_TYPE_INVALID);
@@ -167,7 +198,7 @@ _e_book_view_new (EBook *book, DBusGProxy *view_proxy, GStaticRecMutex *view_pro
dbus_g_proxy_connect_signal (view_proxy, "ContactsChanged", G_CALLBACK (contacts_changed_cb), view, NULL);
dbus_g_proxy_add_signal (view_proxy, "ContactsRemoved", G_TYPE_STRV, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (view_proxy, "ContactsRemoved", G_CALLBACK (contacts_removed_cb), view, NULL);
- dbus_g_proxy_add_signal (view_proxy, "Complete", G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (view_proxy, "Complete", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (view_proxy, "Complete", G_CALLBACK (complete_cb), view, NULL);
return view;
@@ -215,8 +246,10 @@ e_book_view_start (EBookView *book_view)
/* Fake a sequence-complete so that the application knows this failed */
/* TODO: use get_status_from_error */
- g_signal_emit (book_view, signals[SEQUENCE_COMPLETE], 0,
- E_BOOK_ERROR_CORBA_EXCEPTION);
+ #ifndef E_BOOK_DISABLE_DEPRECATED
+ g_signal_emit (book_view, signals[SEQUENCE_COMPLETE], 0, E_BOOK_VIEW_ERROR_OTHER_ERROR);
+ #endif
+ g_signal_emit (book_view, signals[VIEW_COMPLETE], 0, E_BOOK_VIEW_ERROR_OTHER_ERROR, error->message);
g_error_free (error);
}
@@ -309,13 +342,22 @@ e_book_view_class_init (EBookViewClass *klass)
NULL, NULL,
e_book_marshal_NONE__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
+ #ifndef E_BOOK_DISABLE_DEPRECATED
signals [SEQUENCE_COMPLETE] = g_signal_new ("sequence_complete",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EBookViewClass, sequence_complete),
NULL, NULL,
e_book_marshal_NONE__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ G_TYPE_NONE, 1, G_TYPE_UINT);
+ #endif
+ signals [VIEW_COMPLETE] = g_signal_new ("view_complete",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EBookViewClass, view_complete),
+ NULL, NULL,
+ e_book_marshal_NONE__UINT_STRING,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
signals [STATUS_MESSAGE] = g_signal_new ("status_message",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
diff --git a/addressbook/libebook/e-book-view.h b/addressbook/libebook/e-book-view.h
index e240c99..2148f74 100644
--- a/addressbook/libebook/e-book-view.h
+++ b/addressbook/libebook/e-book-view.h
@@ -45,7 +45,10 @@ struct _EBookViewClass {
void (* contacts_changed) (EBookView *book_view, const GList *contacts);
void (* contacts_removed) (EBookView *book_view, const GList *ids);
void (* contacts_added) (EBookView *book_view, const GList *contacts);
+ #ifndef E_BOOK_DISABLE_DEPRECATED
void (* sequence_complete) (EBookView *book_view, EBookViewStatus status);
+ #endif
+ void (* view_complete) (EBookView *book_view, EBookViewStatus status, const gchar *error_msg);
void (* status_message) (EBookView *book_view, const gchar *message);
/* Padding for future expansion */
diff --git a/addressbook/libebook/e-book.c b/addressbook/libebook/e-book.c
index c2a13e2..296fc65 100644
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@ -43,7 +43,6 @@
static gchar ** flatten_stringlist(GList *list);
static GList *array_to_stringlist (gchar **list);
static gboolean unwrap_gerror(GError *error, GError **client_error);
-static EBookStatus get_status_from_error (GError *error);
G_DEFINE_TYPE(EBook, e_book, G_TYPE_OBJECT)
#define E_BOOK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), E_TYPE_BOOK, EBookPrivate))
@@ -79,7 +78,10 @@ static GStaticRecMutex connection_lock = G_STATIC_REC_MUTEX_INIT;
typedef struct {
EBook *book;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
gpointer callback; /* TODO union */
+ #endif
+ gpointer excallback;
gpointer closure;
gpointer data;
} AsyncData;
@@ -358,16 +360,29 @@ e_book_add_contact (EBook *book,
static void
add_contact_reply (DBusGProxy *proxy, gchar *uid, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookIdExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookIdCallback cb = data->callback;
+ #endif
+
+ unwrap_gerror (error, &err);
/* If there is an error returned the GLib bindings currently return garbage
for the OUT values. This is bad. */
if (error)
uid = NULL;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), uid, data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, uid, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, uid, data->closure);
+
+ if (err)
+ g_error_free (err);
if (uid)
g_free (uid);
@@ -376,6 +391,7 @@ add_contact_reply (DBusGProxy *proxy, gchar *uid, GError *error, gpointer user_d
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_add_contact:
* @book: an #EBook
@@ -386,6 +402,8 @@ add_contact_reply (DBusGProxy *proxy, gchar *uid, GError *error, gpointer user_d
* Adds @contact to @book without blocking.
*
* Returns: %TRUE if the operation was started, %FALSE otherwise.
+ *
+ * Deprecated: 3.0: Use e_book_async_add_contact_ex() instead.
**/
gboolean
e_book_async_add_contact (EBook *book,
@@ -413,6 +431,47 @@ e_book_async_add_contact (EBook *book,
g_free (vcard);
return 0;
}
+#endif
+
+/**
+ * e_book_async_add_contact_ex:
+ * @book: an #EBook
+ * @contact: an #EContact
+ * @cb: function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Adds @contact to @book without blocking.
+ *
+ * Returns: %TRUE if the operation was started, %FALSE otherwise.
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_add_contact_ex (EBook *book,
+ EContact *contact,
+ EBookIdExCallback cb,
+ gpointer closure)
+{
+ gchar *vcard;
+ AsyncData *data;
+
+ e_return_ex_async_error_val_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_val_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+ e_return_ex_async_error_val_if_fail (E_IS_CONTACT (contact), E_BOOK_ERROR_INVALID_ARG);
+
+ vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_add_contact_async (book->priv->proxy, vcard, add_contact_reply, data);
+ UNLOCK_CONN ();
+ g_free (vcard);
+
+ return TRUE;
+}
/**
* e_book_commit_contact:
@@ -448,16 +507,30 @@ e_book_commit_contact (EBook *book,
static void
modify_contact_reply (DBusGProxy *proxy, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookCallback cb = data->callback;
+ #endif
+
+ unwrap_gerror (error, &err);
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (data->book);
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_commit_contact:
* @book: an #EBook
@@ -469,6 +542,8 @@ modify_contact_reply (DBusGProxy *proxy, GError *error, gpointer user_data)
* @book without blocking.
*
* Returns: %TRUE if the operation was started, %FALSE otherwise.
+ *
+ * Deprecated: 3.0: Use e_book_async_commit_contact_ex() instead.
**/
guint
e_book_async_commit_contact (EBook *book,
@@ -496,6 +571,48 @@ e_book_async_commit_contact (EBook *book,
g_free (vcard);
return 0;
}
+#endif
+
+/**
+ * e_book_async_commit_contact_ex:
+ * @book: an #EBook
+ * @contact: an #EContact
+ * @cb: function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Applies the changes made to @contact to the stored version in
+ * @book without blocking.
+ *
+ * Returns: %TRUE if the operation was started, %FALSE otherwise.
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_commit_contact_ex (EBook *book,
+ EContact *contact,
+ EBookExCallback cb,
+ gpointer closure)
+{
+ gchar *vcard;
+ AsyncData *data;
+
+ e_return_ex_async_error_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+ e_return_ex_async_error_if_fail (E_IS_CONTACT (contact), E_BOOK_ERROR_INVALID_ARG);
+
+ vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_modify_contact_async (book->priv->proxy, vcard, modify_contact_reply, data);
+ UNLOCK_CONN ();
+ g_free (vcard);
+
+ return TRUE;
+}
/**
* e_book_get_required_fields:
@@ -535,8 +652,12 @@ e_book_get_required_fields (EBook *book,
static void
get_required_fields_reply(DBusGProxy *proxy, gchar **fields, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookEListExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookEListCallback cb = data->callback;
+ #endif
gchar **i = fields;
EList *efields = e_list_new (NULL,
(EListFreeFunc) g_free,
@@ -546,8 +667,17 @@ get_required_fields_reply(DBusGProxy *proxy, gchar **fields, GError *error, gpoi
e_list_append (efields, (*i++));
}
+ unwrap_gerror (error, &err);
+
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), efields, data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, efields, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, efields, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (efields);
g_free (fields);
@@ -555,6 +685,7 @@ get_required_fields_reply(DBusGProxy *proxy, gchar **fields, GError *error, gpoi
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_get_required_fields:
* @book: an #EBook
@@ -565,6 +696,8 @@ get_required_fields_reply(DBusGProxy *proxy, gchar **fields, GError *error, gpoi
* all contacts in this @book. This function does not block.
*
* Returns: %TRUE if the operation was started, %FALSE otherwise.
+ *
+ * Deprecated: 3.0: Use e_book_async_get_required_fields_ex() instead.
**/
guint
e_book_async_get_required_fields (EBook *book,
@@ -586,6 +719,41 @@ e_book_async_get_required_fields (EBook *book,
UNLOCK_CONN ();
return 0;
}
+#endif
+
+/**
+ * e_book_async_get_required_fields_ex:
+ * @book: an #EBook
+ * @cb: function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Gets a list of fields that are required to be filled in for
+ * all contacts in this @book. This function does not block.
+ *
+ * Returns: %TRUE if the operation was started, %FALSE otherwise.
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_get_required_fields_ex (EBook *book,
+ EBookEListExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+
+ e_return_ex_async_error_val_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_val_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_get_required_fields_async (book->priv->proxy, get_required_fields_reply, data);
+ UNLOCK_CONN ();
+
+ return TRUE;
+}
/**
* e_book_get_supported_fields:
@@ -625,8 +793,12 @@ e_book_get_supported_fields (EBook *book,
static void
get_supported_fields_reply(DBusGProxy *proxy, gchar **fields, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookEListExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookEListCallback cb = data->callback;
+ #endif
gchar **i = fields;
EList *efields = e_list_new (NULL, (EListFreeFunc) g_free, NULL);
@@ -634,8 +806,17 @@ get_supported_fields_reply(DBusGProxy *proxy, gchar **fields, GError *error, gpo
e_list_append (efields, (*i++));
}
+ unwrap_gerror (error, &err);
+
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), efields, data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, efields, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, efields, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (efields);
g_free (fields);
@@ -644,6 +825,7 @@ get_supported_fields_reply(DBusGProxy *proxy, gchar **fields, GError *error, gpo
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_get_supported_fields:
* @book: an #EBook
@@ -655,6 +837,8 @@ get_supported_fields_reply(DBusGProxy *proxy, gchar **fields, GError *error, gpo
* function does not block.
*
* Returns: %TRUE if successful, %FALSE otherwise.
+ *
+ * Deprecated: 3.0: Use e_book_async_get_supported_fields_ex() instead.
**/
guint
e_book_async_get_supported_fields (EBook *book,
@@ -677,6 +861,42 @@ e_book_async_get_supported_fields (EBook *book,
return 0;
}
+#endif
+
+/**
+ * e_book_async_get_supported_fields_ex:
+ * @book: an #EBook
+ * @cb: function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Gets a list of fields that can be stored for contacts
+ * in this @book. Other fields may be discarded. This
+ * function does not block.
+ *
+ * Returns: %TRUE if successful, %FALSE otherwise.
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_get_supported_fields_ex (EBook *book,
+ EBookEListExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+
+ e_return_ex_async_error_val_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_val_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_get_supported_fields_async (book->priv->proxy, get_supported_fields_reply, data);
+ UNLOCK_CONN ();
+
+ return TRUE;
+}
/**
* e_book_get_supported_auth_methods:
@@ -715,8 +935,12 @@ e_book_get_supported_auth_methods (EBook *book,
static void
get_supported_auth_methods_reply(DBusGProxy *proxy, gchar **methods, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookEListExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookEListCallback cb = data->callback;
+ #endif
gchar **i = methods;
EList *emethods = e_list_new (NULL,
(EListFreeFunc) g_free,
@@ -726,8 +950,17 @@ get_supported_auth_methods_reply(DBusGProxy *proxy, gchar **methods, GError *err
e_list_append (emethods, (*i++));
}
+ unwrap_gerror (error, &err);
+
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), emethods, data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, emethods, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, emethods, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (emethods);
g_free (methods);
@@ -736,6 +969,7 @@ get_supported_auth_methods_reply(DBusGProxy *proxy, gchar **methods, GError *err
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_get_supported_auth_methods:
* @book: an #EBook
@@ -746,7 +980,9 @@ get_supported_auth_methods_reply(DBusGProxy *proxy, gchar **methods, GError *err
* This function does not block.
*
* Returns: %TRUE if successful, %FALSE otherwise.
-**/
+ *
+ * Deprecated: 3.0: Use e_book_async_get_supported_auth_methods_ex() instead.
+ **/
guint
e_book_async_get_supported_auth_methods (EBook *book,
EBookEListCallback cb,
@@ -767,7 +1003,42 @@ e_book_async_get_supported_auth_methods (EBook *book,
UNLOCK_CONN ();
return 0;
- }
+}
+#endif
+
+/**
+ * e_book_async_get_supported_auth_methods_ex:
+ * @book: an #EBook
+ * @cb: function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Queries @book for the list of authentication methods it supports.
+ * This function does not block.
+ *
+ * Returns: %TRUE if successful, %FALSE otherwise.
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_get_supported_auth_methods_ex (EBook *book,
+ EBookEListExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+
+ e_return_ex_async_error_val_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_val_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_get_supported_auth_methods_async (book->priv->proxy, get_supported_auth_methods_reply, data);
+ UNLOCK_CONN ();
+
+ return TRUE;
+}
/**
* e_book_authenticate_user:
@@ -805,16 +1076,30 @@ e_book_authenticate_user (EBook *book,
static void
authenticate_user_reply(DBusGProxy *proxy, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookCallback cb = data->callback;
+ #endif
+
+ unwrap_gerror (error, &err);
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (data->book);
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_authenticate_user:
* @book: an #EBook
@@ -830,6 +1115,8 @@ authenticate_user_reply(DBusGProxy *proxy, GError *error, gpointer user_data)
* This function does not block.
*
* Returns: %FALSE if successful, %TRUE otherwise.
+ *
+ * Deprecated: 3.0: Use e_book_async_authenticate_user_ex() instead.
**/
guint
e_book_async_authenticate_user (EBook *book,
@@ -858,6 +1145,52 @@ e_book_async_authenticate_user (EBook *book,
return 0;
}
+#endif
+
+/**
+ * e_book_async_authenticate_user_ex:
+ * @book: an #EBook
+ * @user: user name
+ * @passwd: password
+ * @auth_method: string indicating authentication method
+ * @cb: function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Authenticate @user with @passwd, using the auth method
+ * @auth_method. @auth_method must be one of the authentication
+ * methods returned using e_book_get_supported_auth_methods.
+ * This function does not block.
+ *
+ * Returns: %FALSE if successful, %TRUE otherwise.
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_authenticate_user_ex (EBook *book,
+ const gchar *user,
+ const gchar *passwd,
+ const gchar *auth_method,
+ EBookExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+
+ e_return_ex_async_error_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+ e_return_ex_async_error_if_fail (user, E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_if_fail (passwd, E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_if_fail (auth_method, E_BOOK_ERROR_INVALID_ARG);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_authenticate_user_async (book->priv->proxy, user, passwd, auth_method, authenticate_user_reply, data);
+ UNLOCK_CONN ();
+
+ return TRUE;
+}
/**
* e_book_get_contact:
@@ -897,31 +1230,34 @@ e_book_get_contact (EBook *book,
static void
get_contact_reply(DBusGProxy *proxy, gchar *vcard, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookContactExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookContactCallback cb = data->callback;
- EBookStatus status = get_status_from_error (error);
+ #endif
+
+ unwrap_gerror (error, &err);
/* Protect against garbage return values on error */
if (error)
vcard = NULL;
- if (cb) {
- if (error == NULL) {
- cb (data->book, status, e_contact_new_from_vcard (vcard), data->closure);
- } else {
- cb (data->book, status, NULL, data->closure);
- }
- } else {
- g_warning (G_STRLOC ": cannot get contact: %s", error->message);
- }
+ #ifndef E_BOOK_DISABLE_DEPRECATED
+ if (cb)
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, err ? NULL : e_contact_new_from_vcard (vcard), data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, err ? NULL : e_contact_new_from_vcard (vcard), data->closure);
- if (error)
- g_error_free (error);
+ if (err)
+ g_error_free (err);
g_free (vcard);
g_object_unref (data->book);
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_get_contact:
* @book: an #EBook
@@ -932,6 +1268,8 @@ get_contact_reply(DBusGProxy *proxy, gchar *vcard, GError *error, gpointer user_
* Retrieves a contact specified by @id from @book.
*
* Returns: %FALSE if successful, %TRUE otherwise
+ *
+ * Deprecated: 3.0: Use e_book_async_get_contact_ex() instead.
**/
guint
e_book_async_get_contact (EBook *book,
@@ -956,6 +1294,43 @@ e_book_async_get_contact (EBook *book,
return 0;
}
+#endif
+
+/**
+ * e_book_async_get_contact_ex:
+ * @book: an #EBook
+ * @id: a unique string ID specifying the contact
+ * @cb: function to call when operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Retrieves a contact specified by @id from @book.
+ *
+ * Returns: %FALSE if successful, %TRUE otherwise
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_get_contact_ex (EBook *book,
+ const gchar *id,
+ EBookContactExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+
+ e_return_ex_async_error_val_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_val_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+ e_return_ex_async_error_val_if_fail (id, E_BOOK_ERROR_INVALID_ARG);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_get_contact_async (book->priv->proxy, id, get_contact_reply, data);
+ UNLOCK_CONN ();
+
+ return TRUE;
+}
/**
* e_book_remove_contact:
@@ -992,11 +1367,24 @@ e_book_remove_contact (EBook *book,
static void
remove_contact_reply (DBusGProxy *proxy, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookCallback cb = data->callback;
+ #endif
+
+ unwrap_gerror (error, &err);
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (data->book);
g_slice_free (AsyncData, data);
@@ -1038,6 +1426,7 @@ e_book_remove_contacts (EBook *book,
return unwrap_gerror (err, error);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_remove_contact:
* @book: an #EBook
@@ -1048,6 +1437,8 @@ e_book_remove_contacts (EBook *book,
* Removes @contact from @book.
*
* Returns: %TRUE if successful, %FALSE otherwise
+ *
+ * Deprecated: 3.0: Use e_book_async_remove_contact_ex() instead.
**/
guint
e_book_async_remove_contact (EBook *book,
@@ -1075,21 +1466,76 @@ e_book_async_remove_contact (EBook *book,
UNLOCK_CONN ();
return 0;
- }
+}
+#endif
+
+/**
+ * e_book_async_remove_contact_ex:
+ * @book: an #EBook
+ * @contact: an #EContact
+ * @cb: a function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Removes @contact from @book.
+ *
+ * Returns: %TRUE if successful, %FALSE otherwise
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_remove_contact_ex (EBook *book,
+ EContact *contact,
+ EBookExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+ const gchar *l[2];
+
+ e_return_ex_async_error_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+ e_return_ex_async_error_if_fail (E_IS_CONTACT (contact), E_BOOK_ERROR_INVALID_ARG);
+
+ l[0] = e_contact_get_const (contact, E_CONTACT_UID);
+ l[1] = NULL;
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_remove_contacts_async (book->priv->proxy, l, remove_contact_reply, data);
+ UNLOCK_CONN ();
+
+ return TRUE;
+}
static void
remove_contact_by_id_reply (DBusGProxy *proxy, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookCallback cb = data->callback;
+ #endif
+
+ unwrap_gerror (error, &err);
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (data->book);
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_remove_contact_by_id:
* @book: an #EBook
@@ -1100,6 +1546,8 @@ remove_contact_by_id_reply (DBusGProxy *proxy, GError *error, gpointer user_data
* Removes the contact with id @id from @book.
*
* Returns: %TRUE if successful, %FALSE otherwise
+ *
+ * Deprecated: 3.0: Use e_book_async_remove_contact_by_id_ex() instead.
**/
guint
e_book_async_remove_contact_by_id (EBook *book,
@@ -1128,20 +1576,75 @@ e_book_async_remove_contact_by_id (EBook *book,
return 0;
}
+#endif
+
+/**
+ * e_book_async_remove_contact_by_id_ex:
+ * @book: an #EBook
+ * @id: a unique ID string specifying the contact
+ * @cb: a function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Removes the contact with id @id from @book.
+ *
+ * Returns: %TRUE if successful, %FALSE otherwise
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_remove_contact_by_id_ex (EBook *book,
+ const gchar *id,
+ EBookExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+ const gchar *l[2];
+
+ e_return_ex_async_error_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+ e_return_ex_async_error_if_fail (id, E_BOOK_ERROR_INVALID_ARG);
+
+ l[0] = id;
+ l[1] = NULL;
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_remove_contacts_async (book->priv->proxy, l, remove_contact_by_id_reply, data);
+ UNLOCK_CONN ();
+
+ return TRUE;
+}
static void
remove_contacts_reply (DBusGProxy *proxy, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookCallback cb = data->callback;
+ #endif
+
+ unwrap_gerror (error, &err);
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (data->book);
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_remove_contacts:
* @book: an #EBook
@@ -1155,6 +1658,8 @@ remove_contacts_reply (DBusGProxy *proxy, GError *error, gpointer user_data)
* as a batch request.
*
* Returns: %TRUE if successful, %FALSE otherwise
+ *
+ * Deprecated: 3.0: Use e_book_async_remove_contacts_ex() instead.
**/
guint
e_book_async_remove_contacts (EBook *book,
@@ -1189,6 +1694,56 @@ e_book_async_remove_contacts (EBook *book,
return 0;
}
+#endif
+
+/**
+ * e_book_async_remove_contacts_ex:
+ * @book: an #EBook
+ * @ids: a #GList of const gchar *id's
+ * @cb: a function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Removes the contacts with ids from the list @ids from @book. This is
+ * always more efficient than calling e_book_remove_contact() if you
+ * have more than one id to remove, as some backends can implement it
+ * as a batch request.
+ *
+ * Returns: %TRUE if successful, %FALSE otherwise
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_remove_contacts_ex (EBook *book,
+ GList *ids,
+ EBookExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+ gchar **l;
+
+ e_return_ex_async_error_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+
+ if (ids == NULL) {
+ if (cb)
+ cb (book, E_BOOK_ERROR_OK, closure);
+ return 0;
+ }
+
+ l = flatten_stringlist (ids);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_remove_contacts_async (book->priv->proxy, (const gchar **) l, remove_contacts_reply, data);
+ UNLOCK_CONN ();
+
+ g_free (l);
+
+ return TRUE;
+}
/**
* e_book_get_book_view:
@@ -1239,7 +1794,7 @@ e_book_get_book_view (EBook *book,
*book_view = _e_book_view_new (book, view_proxy, &connection_lock);
} else {
*book_view = NULL;
- g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION,
+ g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_DBUS_EXCEPTION,
"Cannot get connection to view");
ret = FALSE;
}
@@ -1256,34 +1811,43 @@ get_book_view_reply (DBusGProxy *proxy, gchar *view_path, GError *error, gpointe
AsyncData *data = user_data;
GError *err = NULL;
EBookView *view = NULL;
+ EBookBookViewExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookBookViewCallback cb = data->callback;
+ #endif
DBusGProxy *view_proxy;
- EBookStatus status;
if (view_path) {
+ GError *dbus_error = NULL;
+
LOCK_CONN ();
view_proxy = dbus_g_proxy_new_for_name_owner (connection, E_DATA_BOOK_FACTORY_SERVICE_NAME, view_path,
- "org.gnome.evolution.dataserver.addressbook.BookView", &err);
+ "org.gnome.evolution.dataserver.addressbook.BookView", &dbus_error);
UNLOCK_CONN ();
if (view_proxy) {
view = _e_book_view_new (data->book, view_proxy, &connection_lock);
- status = E_BOOK_ERROR_OK;
} else {
- g_warning (G_STRLOC ": cannot get connection to view: %s", err->message);
- g_error_free (err);
- status = E_BOOK_ERROR_CORBA_EXCEPTION;
+ unwrap_gerror (dbus_error, &err);
+ g_error_free (dbus_error);
}
} else {
- status = get_status_from_error (error);
+ unwrap_gerror (error, &err);
}
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, status, view, data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, view, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, view, data->closure);
+ if (err)
+ g_error_free (err);
g_object_unref (data->book);
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_get_book_view:
* @book: an #EBook
@@ -1297,6 +1861,8 @@ get_book_view_reply (DBusGProxy *proxy, gchar *view_path, GError *error, gpointe
* specified by @requested_fields and limited at @max_results records.
*
* Returns: %FALSE if successful, %TRUE otherwise
+ *
+ * Deprecated: 3.0: Use e_book_async_get_book_view_ex() instead.
**/
guint
e_book_async_get_book_view (EBook *book,
@@ -1327,6 +1893,53 @@ e_book_async_get_book_view (EBook *book,
g_free (sexp);
return 0;
}
+#endif
+
+/**
+ * e_book_async_get_book_view_ex:
+ * @book: an #EBook
+ * @query: an #EBookQuery
+ * @requested_fields: a #GList containing the names of fields to return, or NULL for all
+ * @max_results: the maximum number of contacts to show (or 0 for all)
+ * @cb: a function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Query @book with @query, creating a #EBookView with the fields
+ * specified by @requested_fields and limited at @max_results records.
+ *
+ * Returns: %FALSE if successful, %TRUE otherwise
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_get_book_view_ex (EBook *book,
+ EBookQuery *query,
+ GList *requested_fields,
+ gint max_results,
+ EBookBookViewExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+ gchar *sexp;
+
+ e_return_ex_async_error_val_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_val_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+ e_return_ex_async_error_val_if_fail (query, E_BOOK_ERROR_INVALID_ARG);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ sexp = e_book_query_to_string (query);
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_get_book_view_async (book->priv->proxy, sexp, max_results, get_book_view_reply, data);
+ UNLOCK_CONN ();
+
+ g_free (sexp);
+ return TRUE;
+}
+
/**
* e_book_get_contacts:
* @book: an #EBook
@@ -1374,9 +1987,15 @@ e_book_get_contacts (EBook *book,
static void
get_contacts_reply(DBusGProxy *proxy, gchar **vcards, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
GList *list = NULL;
+ EBookListExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookListCallback cb = data->callback;
+ #endif
+
+ unwrap_gerror (error, &err);
if (!error && vcards) {
gchar **i = vcards;
@@ -1390,13 +2009,22 @@ get_contacts_reply(DBusGProxy *proxy, gchar **vcards, GError *error, gpointer us
list = g_list_reverse (list);
}
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), list, data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, list, data->closure);
+ #endif
+
+ if (excb)
+ excb (data->book, err, list, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (data->book);
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_get_contacts:
* @book: an #EBook
@@ -1407,6 +2035,8 @@ get_contacts_reply(DBusGProxy *proxy, gchar **vcards, GError *error, gpointer us
* Query @book with @query.
*
* Returns: %FALSE on success, %TRUE otherwise
+ *
+ * Deprecated: 3.0: Use e_book_async_get_contacts_ex() instead.
**/
guint
e_book_async_get_contacts (EBook *book,
@@ -1434,6 +2064,47 @@ e_book_async_get_contacts (EBook *book,
g_free (sexp);
return 0;
}
+#endif
+
+/**
+ * e_book_async_get_contacts_ex:
+ * @book: an #EBook
+ * @query: an #EBookQuery
+ * @cb: a function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Query @book with @query.
+ *
+ * Returns: %FALSE on success, %TRUE otherwise
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_get_contacts_ex (EBook *book,
+ EBookQuery *query,
+ EBookListExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+ gchar *sexp;
+
+ e_return_ex_async_error_val_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_val_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+ e_return_ex_async_error_val_if_fail (query, E_BOOK_ERROR_INVALID_ARG);
+
+ sexp = e_book_query_to_string (query);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_get_contact_list_async (book->priv->proxy, sexp, get_contacts_reply, data);
+ UNLOCK_CONN ();
+ g_free (sexp);
+
+ return TRUE;
+}
static GList *
parse_changes_array (GPtrArray *array)
@@ -1502,20 +2173,35 @@ e_book_get_changes (EBook *book,
static void
get_changes_reply (DBusGProxy *proxy, GPtrArray *changes, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookListExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookListCallback cb = data->callback;
+ #endif
GList *list = NULL;
+ unwrap_gerror (error, &err);
+
if (changes)
list = parse_changes_array (changes);
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), list, data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, list, data->closure);
+ #endif
+
+ if (excb)
+ excb (data->book, err, list, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (data->book);
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_get_changes:
* @book: an #EBook
@@ -1527,6 +2213,8 @@ get_changes_reply (DBusGProxy *proxy, GPtrArray *changes, GError *error, gpointe
* for a given change ID.
*
* Returns: TRUE on success, FALSE otherwise
+ *
+ * Deprecated: 3.0: Use e_book_async_get_changes_ex() instead.
*/
guint
e_book_async_get_changes (EBook *book,
@@ -1550,6 +2238,43 @@ e_book_async_get_changes (EBook *book,
return 0;
}
+#endif
+
+/**
+ * e_book_async_get_changes_ex:
+ * @book: an #EBook
+ * @changeid: the change ID
+ * @cb: function to call when operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Get the set of changes since the previous call to #e_book_async_get_changes
+ * for a given change ID.
+ *
+ * Returns: TRUE on success, FALSE otherwise
+ * Since: 3.0
+ */
+gboolean
+e_book_async_get_changes_ex (EBook *book,
+ const gchar *changeid,
+ EBookListExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+
+ e_return_ex_async_error_val_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_val_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_get_changes_async (book->priv->proxy, changeid, get_changes_reply, data);
+ UNLOCK_CONN ();
+
+ return TRUE;
+}
/**
* e_book_free_change_list:
@@ -1643,7 +2368,6 @@ e_book_open (EBook *book,
GError **error)
{
GError *err = NULL;
- EBookStatus status;
e_return_error_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
e_return_error_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
@@ -1651,40 +2375,48 @@ e_book_open (EBook *book,
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_addressbook_Book_open (book->priv->proxy, only_if_exists, &err)) {
UNLOCK_CONN ();
- g_propagate_error (error, err);
+
+ unwrap_gerror (err, error);
+
return FALSE;
}
UNLOCK_CONN ();
- status = get_status_from_error (err);
-
- if (status == E_BOOK_ERROR_OK) {
+ if (!err)
book->priv->loaded = TRUE;
- return TRUE;
- } else {
- g_propagate_error (error, err);
- return FALSE;
- }
+
+ return unwrap_gerror (err, error);
}
static void
open_reply(DBusGProxy *proxy, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookCallback cb = data->callback;
- EDataBookStatus status;
+ #endif
- status = get_status_from_error (error);
+ unwrap_gerror (error, &err);
- data->book->priv->loaded = (status == E_BOOK_ERROR_OK);
+ data->book->priv->loaded = !error;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, status, data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (data->book);
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_open:
* @book: an #EBook
@@ -1696,6 +2428,8 @@ open_reply(DBusGProxy *proxy, GError *error, gpointer user_data)
* This function does not block.
*
* Returns: %FALSE if successful, %TRUE otherwise.
+ *
+ * Deprecated: 3.0: Use e_book_async_open_ex() instead.
**/
guint
e_book_async_open (EBook *book,
@@ -1719,6 +2453,43 @@ e_book_async_open (EBook *book,
return 0;
}
+#endif
+
+/**
+ * e_book_async_open_ex:
+ * @book: an #EBook
+ * @only_if_exists: if %TRUE, fail if this book doesn't already exist, otherwise create it first
+ * @open_response: a function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Opens the addressbook, making it ready for queries and other operations.
+ * This function does not block.
+ *
+ * Returns: %FALSE if successful, %TRUE otherwise.
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_open_ex (EBook *book,
+ gboolean only_if_exists,
+ EBookExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+
+ e_return_ex_async_error_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_open_async (book->priv->proxy, only_if_exists, open_reply, data);
+ UNLOCK_CONN ();
+
+ return TRUE;
+}
/**
* e_book_remove:
@@ -1749,15 +2520,30 @@ e_book_remove (EBook *book,
static void
remove_reply(DBusGProxy *proxy, GError *error, gpointer user_data)
{
+ GError *err = NULL;
AsyncData *data = user_data;
+ EBookExCallback excb = data->excallback;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookCallback cb = data->callback;
+ #endif
+
+ unwrap_gerror (error, &err);
+
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (cb)
- cb (data->book, get_status_from_error (error), data->closure);
+ cb (data->book, err ? err->code : E_BOOK_ERROR_OK, data->closure);
+ #endif
+ if (excb)
+ excb (data->book, err, data->closure);
+
+ if (err)
+ g_error_free (err);
g_object_unref (data->book);
g_slice_free (AsyncData, data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_book_async_remove:
* @book: an #EBook
@@ -1768,6 +2554,8 @@ remove_reply(DBusGProxy *proxy, GError *error, gpointer user_data)
* deletes the database file. You cannot get it back!
*
* Returns: %FALSE if successful, %TRUE otherwise.
+ *
+ * Deprecated: 3.0: Use e_book_async_remove_ex() instead.
**/
guint
e_book_async_remove (EBook *book,
@@ -1790,6 +2578,41 @@ e_book_async_remove (EBook *book,
return 0;
}
+#endif
+
+/**
+ * e_book_async_remove_ex:
+ * @book: an #EBook
+ * @cb: a function to call when the operation finishes
+ * @closure: data to pass to callback function
+ *
+ * Remove the backing data for this #EBook. For example, with the file backend this
+ * deletes the database file. You cannot get it back!
+ *
+ * Returns: %FALSE if successful, %TRUE otherwise.
+ * Since: 3.0
+ **/
+gboolean
+e_book_async_remove_ex (EBook *book,
+ EBookExCallback cb,
+ gpointer closure)
+{
+ AsyncData *data;
+
+ e_return_ex_async_error_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+ e_return_ex_async_error_if_fail (book->priv->proxy, E_BOOK_ERROR_REPOSITORY_OFFLINE);
+
+ data = g_slice_new0 (AsyncData);
+ data->book = g_object_ref (book);
+ data->excallback = cb;
+ data->closure = closure;
+
+ LOCK_CONN ();
+ org_gnome_evolution_dataserver_addressbook_Book_remove_async (book->priv->proxy, remove_reply, data);
+ UNLOCK_CONN ();
+
+ return TRUE;
+}
/**
* e_book_get_uri:
@@ -2498,33 +3321,6 @@ e_book_new_default_addressbook (GError **error)
return book;
}
-/**
- * If the specified GError is a remote error, then create a new error
- * representing the remote error. If the error is anything else, then leave it
- * alone.
- */
-static gboolean
-unwrap_gerror (GError *error, GError **client_error)
-{
- if (error == NULL)
- return TRUE;
-
- if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
- GError *new;
- gint code;
- if (client_error) {
- code = get_status_from_error (error);
- new = g_error_new_literal (E_BOOK_ERROR, code, error->message);
- *client_error = new;
- }
- g_error_free (error);
- } else {
- if (client_error)
- *client_error = error;
- }
- return FALSE;
-}
-
static gboolean
strcaseequal_no_underscore (const gchar *str1, const gchar *str2)
{
@@ -2548,7 +3344,7 @@ strcaseequal_no_underscore (const gchar *str1, const gchar *str2)
/**
* If the GError is a remote error, extract the EBookStatus embedded inside.
- * Otherwise return CORBA_EXCEPTION (I know this is DBus...).
+ * Otherwise return DBUS_EXCEPTION (I know this is DBus...).
*/
static EBookStatus
get_status_from_error (GError *error)
@@ -2578,7 +3374,9 @@ get_status_from_error (GError *error)
{ err ("E_DATA_BOOK_STATUS_COULD_NOT_CANCEL", E_BOOK_ERROR_COULD_NOT_CANCEL) },
{ err ("E_DATA_BOOK_STATUS_OTHER_ERROR", E_BOOK_ERROR_OTHER_ERROR) },
{ err ("E_DATA_BOOK_STATUS_INVALID_SERVER_VERSION", E_BOOK_ERROR_INVALID_SERVER_VERSION) },
- { err ("E_DATA_BOOK_STATUS_NO_SPACE", E_BOOK_ERROR_NO_SPACE) }
+ { err ("E_DATA_BOOK_STATUS_NO_SPACE", E_BOOK_ERROR_NO_SPACE) },
+ { err ("E_DATA_BOOK_STATUS_INVALID_ARG", E_BOOK_ERROR_INVALID_ARG) },
+ { err ("E_DATA_BOOK_STATUS_NOT_SUPPORTED", E_BOOK_ERROR_NOT_SUPPORTED) }
};
#undef err
@@ -2603,11 +3401,38 @@ get_status_from_error (GError *error)
/* In this case the error was caused by DBus. Dump the message to the
console as otherwise we have no idea what the problem is. */
g_warning ("DBus error: %s", error->message);
- return E_BOOK_ERROR_CORBA_EXCEPTION;
+ return E_BOOK_ERROR_DBUS_EXCEPTION;
}
}
/**
+ * If the specified GError is a remote error, then create a new error
+ * representing the remote error. If the error is anything else, then leave it
+ * alone.
+ */
+static gboolean
+unwrap_gerror (GError *error, GError **client_error)
+{
+ if (error == NULL)
+ return TRUE;
+
+ if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
+ GError *new;
+ gint code;
+ if (client_error) {
+ code = get_status_from_error (error);
+ new = g_error_new_literal (E_BOOK_ERROR, code, error->message);
+ *client_error = new;
+ }
+ g_error_free (error);
+ } else {
+ if (client_error)
+ *client_error = error;
+ }
+ return FALSE;
+}
+
+/**
* Turn a GList of strings into an array of strings.
*/
static gchar **
diff --git a/addressbook/libebook/e-book.h b/addressbook/libebook/e-book.h
index 3a73c31..64dcf5e 100644
--- a/addressbook/libebook/e-book.h
+++ b/addressbook/libebook/e-book.h
@@ -35,16 +35,26 @@ typedef struct _EBook EBook;
typedef struct _EBookClass EBookClass;
typedef struct _EBookPrivate EBookPrivate;
+#ifndef E_BOOK_DISABLE_DEPRECATED
typedef void (*EBookCallback) (EBook *book, EBookStatus status, gpointer closure);
+#endif
+typedef void (*EBookExCallback) (EBook *book, const GError *error, gpointer closure);
typedef void (*EBookOpenProgressCallback) (EBook *book,
const gchar *status_message,
short percent,
gpointer closure);
+#ifndef E_BOOK_DISABLE_DEPRECATED
typedef void (*EBookIdCallback) (EBook *book, EBookStatus status, const gchar *id, gpointer closure);
typedef void (*EBookContactCallback) (EBook *book, EBookStatus status, EContact *contact, gpointer closure);
typedef void (*EBookListCallback) (EBook *book, EBookStatus status, GList *list, gpointer closure);
typedef void (*EBookBookViewCallback) (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure);
typedef void (*EBookEListCallback) (EBook *book, EBookStatus status, EList *list, gpointer closure);
+#endif
+typedef void (*EBookIdExCallback) (EBook *book, const GError *error, const gchar *id, gpointer closure);
+typedef void (*EBookContactExCallback) (EBook *book, const GError *error, EContact *contact, gpointer closure);
+typedef void (*EBookListExCallback) (EBook *book, const GError *error, GList *list, gpointer closure);
+typedef void (*EBookBookViewExCallback) (EBook *book, const GError *error, EBookView *book_view, gpointer closure);
+typedef void (*EBookEListExCallback) (EBook *book, const GError *error, EList *list, gpointer closure);
struct _EBook {
GObject parent;
@@ -82,39 +92,71 @@ gboolean e_book_open (EBook *book,
gboolean only_if_exists,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_open (EBook *book,
gboolean only_if_exists,
EBookCallback open_response,
gpointer closure);
+#endif
+
+gboolean e_book_async_open_ex (EBook *book,
+ gboolean only_if_exists,
+ EBookExCallback open_response,
+ gpointer closure);
gboolean e_book_remove (EBook *book,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_remove (EBook *book,
EBookCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_remove_ex (EBook *book,
+ EBookExCallback cb,
+ gpointer closure);
+
gboolean e_book_get_required_fields (EBook *book,
GList **fields,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_get_required_fields (EBook *book,
EBookEListCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_get_required_fields_ex (EBook *book,
+ EBookEListExCallback cb,
+ gpointer closure);
gboolean e_book_get_supported_fields (EBook *book,
GList **fields,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_get_supported_fields (EBook *book,
EBookEListCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_get_supported_fields_ex (EBook *book,
+ EBookEListExCallback cb,
+ gpointer closure);
gboolean e_book_get_supported_auth_methods (EBook *book,
GList **auth_methods,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_get_supported_auth_methods (EBook *book,
EBookEListCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_get_supported_auth_methods_ex (EBook *book,
+ EBookEListExCallback cb,
+ gpointer closure);
/* User authentication. */
gboolean e_book_authenticate_user (EBook *book,
@@ -123,12 +165,21 @@ gboolean e_book_authenticate_user (EBook *book,
const gchar *auth_method,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_authenticate_user (EBook *book,
const gchar *user,
const gchar *passwd,
const gchar *auth_method,
EBookCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_authenticate_user_ex (EBook *book,
+ const gchar *user,
+ const gchar *passwd,
+ const gchar *auth_method,
+ EBookExCallback cb,
+ gpointer closure);
/* Fetching contacts. */
gboolean e_book_get_contact (EBook *book,
@@ -136,16 +187,24 @@ gboolean e_book_get_contact (EBook *book,
EContact **contact,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_get_contact (EBook *book,
const gchar *id,
EBookContactCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_get_contact_ex (EBook *book,
+ const gchar *id,
+ EBookContactExCallback cb,
+ gpointer closure);
/* Deleting contacts. */
gboolean e_book_remove_contact (EBook *book,
const gchar *id,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_remove_contact (EBook *book,
EContact *contact,
EBookCallback cb,
@@ -154,35 +213,66 @@ guint e_book_async_remove_contact_by_id (EBook *book,
const gchar *id,
EBookCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_remove_contact_ex (EBook *book,
+ EContact *contact,
+ EBookExCallback cb,
+ gpointer closure);
+gboolean e_book_async_remove_contact_by_id_ex (EBook *book,
+ const gchar *id,
+ EBookExCallback cb,
+ gpointer closure);
gboolean e_book_remove_contacts (EBook *book,
GList *ids,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_remove_contacts (EBook *book,
GList *ids,
EBookCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_remove_contacts_ex (EBook *book,
+ GList *ids,
+ EBookExCallback cb,
+ gpointer closure);
/* Adding contacts. */
gboolean e_book_add_contact (EBook *book,
EContact *contact,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
gboolean e_book_async_add_contact (EBook *book,
EContact *contact,
EBookIdCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_add_contact_ex (EBook *book,
+ EContact *contact,
+ EBookIdExCallback cb,
+ gpointer closure);
/* Modifying contacts. */
gboolean e_book_commit_contact (EBook *book,
EContact *contact,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_commit_contact (EBook *book,
EContact *contact,
EBookCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_commit_contact_ex (EBook *book,
+ EContact *contact,
+ EBookExCallback cb,
+ gpointer closure);
/* Returns a live view of a query. */
gboolean e_book_get_book_view (EBook *book,
@@ -192,12 +282,21 @@ gboolean e_book_get_book_view (EBook *book,
EBookView **book_view,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_get_book_view (EBook *book,
EBookQuery *query,
GList *requested_fields,
gint max_results,
EBookBookViewCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_get_book_view_ex (EBook *book,
+ EBookQuery *query,
+ GList *requested_fields,
+ gint max_results,
+ EBookBookViewExCallback cb,
+ gpointer closure);
/* Returns a static snapshot of a query. */
gboolean e_book_get_contacts (EBook *book,
@@ -205,10 +304,17 @@ gboolean e_book_get_contacts (EBook *book,
GList **contacts,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_get_contacts (EBook *book,
EBookQuery *query,
EBookListCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_get_contacts_ex (EBook *book,
+ EBookQuery *query,
+ EBookListExCallback cb,
+ gpointer closure);
/* Needed for syncing */
gboolean e_book_get_changes (EBook *book,
@@ -216,10 +322,17 @@ gboolean e_book_get_changes (EBook *book,
GList **changes,
GError **error);
+#ifndef E_BOOK_DISABLE_DEPRECATED
guint e_book_async_get_changes (EBook *book,
const gchar *changeid,
EBookListCallback cb,
gpointer closure);
+#endif
+
+gboolean e_book_async_get_changes_ex (EBook *book,
+ const gchar *changeid,
+ EBookListExCallback cb,
+ gpointer closure);
void e_book_free_change_list (GList *change_list);
diff --git a/addressbook/libebook/e-error.h b/addressbook/libebook/e-error.h
index c0b4f8b..dae4bd4 100644
--- a/addressbook/libebook/e-error.h
+++ b/addressbook/libebook/e-error.h
@@ -44,3 +44,33 @@
} \
} G_STMT_END \
+
+#define e_return_ex_async_error_if_fail(expr, error) G_STMT_START { \
+ if G_LIKELY (expr) {} else { \
+ GError *err; \
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
+ "file %s: line %d (%s): assertion `%s' failed", \
+ __FILE__, __LINE__, G_STRFUNC, #expr); \
+ err = g_error_new (E_BOOK_ERROR, (error), \
+ "file %s: line %d (%s): assertion `%s' failed", \
+ __FILE__, __LINE__, G_STRFUNC, #expr); \
+ cb (book, err, closure); \
+ g_error_free (err); \
+ return FALSE; \
+ } \
+ } G_STMT_END
+
+#define e_return_ex_async_error_val_if_fail(expr, error) G_STMT_START { \
+ if G_LIKELY (expr) {} else { \
+ GError *err; \
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
+ "file %s: line %d (%s): assertion `%s' failed", \
+ __FILE__, __LINE__, G_STRFUNC, #expr); \
+ err = g_error_new (E_BOOK_ERROR, (error), \
+ "file %s: line %d (%s): assertion `%s' failed", \
+ __FILE__, __LINE__, G_STRFUNC, #expr); \
+ cb (book, err, NULL, closure); \
+ g_error_free (err); \
+ return 0; \
+ } \
+ } G_STMT_END
diff --git a/addressbook/libedata-book/Makefile.am b/addressbook/libedata-book/Makefile.am
index e11a15e..cab814c 100644
--- a/addressbook/libedata-book/Makefile.am
+++ b/addressbook/libedata-book/Makefile.am
@@ -1,3 +1,7 @@
+# The marshallers
+MARSHAL_GENERATED = e-data-book-marshal.c e-data-book-marshal.h
+ EVO_MARSHAL_RULE@
+
DBUS_GENERATED_H = e-data-book-glue.h e-data-book-factory-glue.h e-data-book-view-glue.h
%-glue.h: %.xml
@DBUS_BINDING_TOOL@ --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $^
@@ -24,6 +28,7 @@ libedata_book_1_2_la_CPPFLAGS = \
$(EVOLUTION_ADDRESSBOOK_CFLAGS)
libedata_book_1_2_la_SOURCES = \
+ $(MARSHAL_GENERATED) \
$(DBUS_GENERATED_H) \
e-book-backend-factory.c \
e-book-backend-sexp.c \
@@ -94,11 +99,12 @@ servicedir = $(datadir)/dbus-1/services
service_DATA = $(service_in_files:.service.in=.service)
@EVO_SUBST_SERVICE_RULE@
-BUILT_SOURCES = $(DBUS_GENERATED_H) $(ENUM_GENERATED)
+BUILT_SOURCES = $(DBUS_GENERATED_H) $(MARSHAL_GENERATED) $(ENUM_GENERATED)
CLEANFILES = $(BUILT_SOURCES) $(service_DATA)
DISTCLEANFILES = $(pkgconfig_DATA)
EXTRA_DIST = \
+ e-data-book-marshal.list \
e-data-book-factory.xml \
e-data-book-view.xml \
e-data-book.xml \
diff --git a/addressbook/libedata-book/e-book-backend-sync.c b/addressbook/libedata-book/e-book-backend-sync.c
index 524b63c..4492441 100644
--- a/addressbook/libedata-book/e-book-backend-sync.c
+++ b/addressbook/libedata-book/e-book-backend-sync.c
@@ -41,26 +41,26 @@ e_book_backend_sync_construct (EBookBackendSync *backend)
* @opid: the unique ID of the operation
* @vcard: a VCard representation of a contact
* @contact: a pointer to a location to store the resulting #EContact
+ * @error: #GError to set, when something fails
*
* Creates a new contact with the contents of @vcard in @backend.
- *
- * Returns: An #EBookBackendSyncStatus indicating the outcome of the operation.
**/
-EBookBackendSyncStatus
+void
e_book_backend_sync_create_contact (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *vcard,
- EContact **contact)
+ EContact **contact,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (vcard, GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (contact, GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (vcard, E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (contact, E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->create_contact_sync);
- return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->create_contact_sync) (backend, book, opid, vcard, contact);
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->create_contact_sync) (backend, book, opid, vcard, contact, error);
}
/**
@@ -68,23 +68,23 @@ e_book_backend_sync_create_contact (EBookBackendSync *backend,
* @backend: an #EBookBackendSync
* @book: an #EDataBook
* @opid: the unique ID of the operation
+ * @error: #GError to set, when something fails
*
* Remove @book's database and storage overhead from the storage
* medium. This will delete all contacts in @book.
- *
- * Returns: An #EBookBackendSyncStatus indicating the outcome of the operation.
**/
-EBookBackendSyncStatus
+void
e_book_backend_sync_remove (EBookBackendSync *backend,
EDataBook *book,
- guint32 opid)
+ guint32 opid,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->remove_sync);
- return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->remove_sync) (backend, book, opid);
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->remove_sync) (backend, book, opid, error);
}
/**
@@ -94,28 +94,28 @@ e_book_backend_sync_remove (EBookBackendSync *backend,
* @opid: the unique ID of the operation
* @id_list: a #GList of pointers to unique contact ID strings
* @removed_ids: a pointer to a location to store a list of the contacts actually removed
+ * @error: #GError to set, when something fails
*
* Removes the contacts specified by @id_list from @backend. The returned list
* of removed contacts is in the same format as the passed-in list, and must be
* freed by the caller.
- *
- * Returns: An #EBookBackendSyncStatus indicating the outcome of the operation.
**/
-EBookBackendSyncStatus
+void
e_book_backend_sync_remove_contacts (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
GList *id_list,
- GList **removed_ids)
+ GList **removed_ids,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (id_list, GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (removed_ids, GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (id_list, E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (removed_ids, E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->remove_contacts_sync);
- return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->remove_contacts_sync) (backend, book, opid, id_list, removed_ids);
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->remove_contacts_sync) (backend, book, opid, id_list, removed_ids, error);
}
/**
@@ -125,27 +125,27 @@ e_book_backend_sync_remove_contacts (EBookBackendSync *backend,
* @opid: the unique ID of the operation
* @vcard: the string representation of a contact
* @contact: a pointer to a location to store the resulting #EContact
+ * @error: #GError to set, when something fails
*
* Modifies the contact specified by the ID embedded in @vcard, to
* reflect the full contents of @vcard.
- *
- * Returns: An #EBookBackendSyncStatus indicating the outcome of the operation.
**/
-EBookBackendSyncStatus
+void
e_book_backend_sync_modify_contact (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *vcard,
- EContact **contact)
+ EContact **contact,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (vcard, GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (contact, GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (vcard, E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (contact, E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->modify_contact_sync);
- return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->modify_contact_sync) (backend, book, opid, vcard, contact);
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->modify_contact_sync) (backend, book, opid, vcard, contact, error);
}
/**
@@ -157,24 +157,23 @@ e_book_backend_sync_modify_contact (EBookBackendSync *backend,
* @vcard: a pointer to a location to store the resulting VCard string
*
* Gets a contact from @book.
- *
- * Returns: An #EBookBackendSyncStatus indicating the outcome of the operation.
**/
-EBookBackendSyncStatus
+void
e_book_backend_sync_get_contact (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *id,
- gchar **vcard)
+ gchar **vcard,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (id, GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (vcard, GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (id, E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (vcard, E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_contact_sync);
- return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_contact_sync) (backend, book, opid, id, vcard);
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_contact_sync) (backend, book, opid, id, vcard, error);
}
/**
@@ -184,27 +183,27 @@ e_book_backend_sync_get_contact (EBookBackendSync *backend,
* @opid: the unique ID of the operation
* @query: an s-expression of the query to perform
* @contacts: a pointer to a location to store the resulting list of VCard strings
+ * @error: #GError to set, when something fails
*
* Gets a list of contacts from @book. The list and its elements must be freed
* by the caller.
- *
- * Returns: An #EBookBackendSyncStatus indicating the outcome of the operation.
**/
-EBookBackendSyncStatus
+void
e_book_backend_sync_get_contact_list (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *query,
- GList **contacts)
+ GList **contacts,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (query, GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (contacts, GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (query, E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (contacts, E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_contact_list_sync);
- return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_contact_list_sync) (backend, book, opid, query, contacts);
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_contact_list_sync) (backend, book, opid, query, contacts, error);
}
/**
@@ -214,28 +213,28 @@ e_book_backend_sync_get_contact_list (EBookBackendSync *backend,
* @opid: the unique ID of the operation
* @change_id: a unique changes ID
* @changes: a pointer to a location to store the resulting list of changes
+ * @error: #GError to set, when something fails
*
* Gets the changes made to @book since the last call to this function.
* The returned list will contain items of CORBA type
- * #GNOME_Evolution_Addressbook_BookChangeItem.
- *
- * Returns: An #EBookBackendSyncStatus indicating the outcome of the operation.
+ * #EDataBookChange.
**/
-EBookBackendSyncStatus
+void
e_book_backend_sync_get_changes (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *change_id,
- GList **changes)
+ GList **changes,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (change_id, GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (changes, GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (change_id, E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (changes, E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_changes_sync);
- return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_changes_sync) (backend, book, opid, change_id, changes);
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_changes_sync) (backend, book, opid, change_id, changes, error);
}
/**
@@ -246,26 +245,26 @@ e_book_backend_sync_get_changes (EBookBackendSync *backend,
* @user: the user's name
* @passwd: the user's password
* @auth_method: the authentication method desired
+ * @error: #GError to set, when something fails
*
* Authenticates @user against @book.
- *
- * Returns: An #EBookBackendSyncStatus indicating the outcome of the operation.
**/
-EBookBackendSyncStatus
+void
e_book_backend_sync_authenticate_user (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
const gchar *user,
const gchar *passwd,
- const gchar *auth_method)
+ const gchar *auth_method,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (user && passwd && auth_method, GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (user && passwd && auth_method, E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->authenticate_user_sync);
- return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->authenticate_user_sync) (backend, book, opid, user, passwd, auth_method);
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->authenticate_user_sync) (backend, book, opid, user, passwd, auth_method, error);
}
/**
@@ -274,26 +273,26 @@ e_book_backend_sync_authenticate_user (EBookBackendSync *backend,
* @book: an #EDataBook
* @opid: the unique ID of the operation
* @fields: a pointer to a location to store the fields
+ * @error: #GError to set, when something fails
*
* Gets a list of the fields required for all contacts in @book. The
* fields are represented by strings from #e_contact_field_name. The list
* and its contents must be freed by the caller.
- *
- * Returns: An #EBookBackendSyncStatus indicating the outcome of the operation.
**/
-EBookBackendSyncStatus
+void
e_book_backend_sync_get_required_fields (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
- GList **fields)
+ GList **fields,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (fields, GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (fields, E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_required_fields_sync);
- return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_required_fields_sync) (backend, book, opid, fields);
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_required_fields_sync) (backend, book, opid, fields, error);
}
/**
@@ -302,26 +301,26 @@ e_book_backend_sync_get_required_fields (EBookBackendSync *backend,
* @book: an #EDataBook
* @opid: the unique ID of the operation
* @fields: a pointer to a location to store the fields
+ * @error: #GError to set, when something fails
*
* Gets a list of the fields supported for contacts in @book. Other fields
* may not be stored. The fields are represented by strings from #e_contact_field_name.
* The list and its contents must be freed by the caller.
- *
- * Returns: An #EBookBackendSyncStatus indicating the outcome of the operation.
**/
-EBookBackendSyncStatus
+void
e_book_backend_sync_get_supported_fields (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
- GList **fields)
+ GList **fields,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (fields, GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (fields, E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_supported_fields_sync);
- return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_supported_fields_sync) (backend, book, opid, fields);
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_supported_fields_sync) (backend, book, opid, fields, error);
}
/**
@@ -330,26 +329,26 @@ e_book_backend_sync_get_supported_fields (EBookBackendSync *backend,
* @book: an #EDataBook
* @opid: the unique ID of the operation
* @methods: a pointer to a location to store the methods
+ * @error: #GError to set, when something fails
*
* Gets a list of the authentication methods supported by @book. The
* methods are represented by strings. The list and its contents must
* be freed by the caller.
- *
- * Returns: An #EBookBackendSyncStatus indicating the outcome of the operation.
**/
-EBookBackendSyncStatus
+void
e_book_backend_sync_get_supported_auth_methods (EBookBackendSync *backend,
EDataBook *book,
guint32 opid,
- GList **methods)
+ GList **methods,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (methods, GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (methods, E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_supported_auth_methods_sync);
- return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_supported_auth_methods_sync) (backend, book, opid, methods);
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_supported_auth_methods_sync) (backend, book, opid, methods, error);
}
static void
@@ -357,11 +356,11 @@ _e_book_backend_remove (EBookBackend *backend,
EDataBook *book,
guint32 opid)
{
- EBookBackendSyncStatus status;
+ GError *error = NULL;;
- status = e_book_backend_sync_remove (E_BOOK_BACKEND_SYNC (backend), book, opid);
+ e_book_backend_sync_remove (E_BOOK_BACKEND_SYNC (backend), book, opid, &error);
- e_data_book_respond_remove (book, opid, status);
+ e_data_book_respond_remove (book, opid, error);
}
static void
@@ -370,12 +369,12 @@ _e_book_backend_create_contact (EBookBackend *backend,
guint32 opid,
const gchar *vcard)
{
- EBookBackendSyncStatus status;
+ GError *error = NULL;
EContact *contact = NULL;
- status = e_book_backend_sync_create_contact (E_BOOK_BACKEND_SYNC (backend), book, opid, vcard, &contact);
+ e_book_backend_sync_create_contact (E_BOOK_BACKEND_SYNC (backend), book, opid, vcard, &contact, &error);
- e_data_book_respond_create (book, opid, status, contact);
+ e_data_book_respond_create (book, opid, error, contact);
if (contact)
g_object_unref (contact);
@@ -387,12 +386,12 @@ _e_book_backend_remove_contacts (EBookBackend *backend,
guint32 opid,
GList *id_list)
{
- EBookBackendSyncStatus status;
+ GError *error = NULL;
GList *ids = NULL;
- status = e_book_backend_sync_remove_contacts (E_BOOK_BACKEND_SYNC (backend), book, opid, id_list, &ids);
+ e_book_backend_sync_remove_contacts (E_BOOK_BACKEND_SYNC (backend), book, opid, id_list, &ids, &error);
- e_data_book_respond_remove_contacts (book, opid, status, ids);
+ e_data_book_respond_remove_contacts (book, opid, error, ids);
if (ids)
g_list_free (ids);
@@ -404,12 +403,12 @@ _e_book_backend_modify_contact (EBookBackend *backend,
guint32 opid,
const gchar *vcard)
{
- EBookBackendSyncStatus status;
+ GError *error = NULL;
EContact *contact = NULL;
- status = e_book_backend_sync_modify_contact (E_BOOK_BACKEND_SYNC (backend), book, opid, vcard, &contact);
+ e_book_backend_sync_modify_contact (E_BOOK_BACKEND_SYNC (backend), book, opid, vcard, &contact, &error);
- e_data_book_respond_modify (book, opid, status, contact);
+ e_data_book_respond_modify (book, opid, error, contact);
if (contact)
g_object_unref (contact);
@@ -421,12 +420,12 @@ _e_book_backend_get_contact (EBookBackend *backend,
guint32 opid,
const gchar *id)
{
- EBookBackendSyncStatus status;
+ GError *error = NULL;
gchar *vcard = NULL;
- status = e_book_backend_sync_get_contact (E_BOOK_BACKEND_SYNC (backend), book, opid, id, &vcard);
+ e_book_backend_sync_get_contact (E_BOOK_BACKEND_SYNC (backend), book, opid, id, &vcard, &error);
- e_data_book_respond_get_contact (book, opid, status, vcard);
+ e_data_book_respond_get_contact (book, opid, error, vcard);
if (vcard)
g_free (vcard);
@@ -438,12 +437,12 @@ _e_book_backend_get_contact_list (EBookBackend *backend,
guint32 opid,
const gchar *query)
{
- EBookBackendSyncStatus status;
+ GError *error = NULL;
GList *cards = NULL;
- status = e_book_backend_sync_get_contact_list (E_BOOK_BACKEND_SYNC (backend), book, opid, query, &cards);
+ e_book_backend_sync_get_contact_list (E_BOOK_BACKEND_SYNC (backend), book, opid, query, &cards, &error);
- e_data_book_respond_get_contact_list (book, opid, status, cards);
+ e_data_book_respond_get_contact_list (book, opid, error, cards);
}
static void
@@ -452,12 +451,12 @@ _e_book_backend_get_changes (EBookBackend *backend,
guint32 opid,
const gchar *change_id)
{
- EBookBackendSyncStatus status;
+ GError *error = NULL;
GList *changes = NULL;
- status = e_book_backend_sync_get_changes (E_BOOK_BACKEND_SYNC (backend), book, opid, change_id, &changes);
+ e_book_backend_sync_get_changes (E_BOOK_BACKEND_SYNC (backend), book, opid, change_id, &changes, &error);
- e_data_book_respond_get_changes (book, opid, status, changes);
+ e_data_book_respond_get_changes (book, opid, error, changes);
}
static void
@@ -468,11 +467,11 @@ _e_book_backend_authenticate_user (EBookBackend *backend,
const gchar *passwd,
const gchar *auth_method)
{
- EBookBackendSyncStatus status;
+ GError *error = NULL;
- status = e_book_backend_sync_authenticate_user (E_BOOK_BACKEND_SYNC (backend), book, opid, user, passwd, auth_method);
+ e_book_backend_sync_authenticate_user (E_BOOK_BACKEND_SYNC (backend), book, opid, user, passwd, auth_method, &error);
- e_data_book_respond_authenticate_user (book, opid, status);
+ e_data_book_respond_authenticate_user (book, opid, error);
}
static void
@@ -480,12 +479,12 @@ _e_book_backend_get_required_fields (EBookBackend *backend,
EDataBook *book,
guint32 opid)
{
- EBookBackendSyncStatus status;
+ GError *error = NULL;
GList *fields = NULL;
- status = e_book_backend_sync_get_required_fields (E_BOOK_BACKEND_SYNC (backend), book, opid, &fields);
+ e_book_backend_sync_get_required_fields (E_BOOK_BACKEND_SYNC (backend), book, opid, &fields, &error);
- e_data_book_respond_get_required_fields (book, opid, status, fields);
+ e_data_book_respond_get_required_fields (book, opid, error, fields);
if (fields) {
g_list_foreach (fields, (GFunc)g_free, NULL);
@@ -498,12 +497,12 @@ _e_book_backend_get_supported_fields (EBookBackend *backend,
EDataBook *book,
guint32 opid)
{
- EBookBackendSyncStatus status;
+ GError *error = NULL;
GList *fields = NULL;
- status = e_book_backend_sync_get_supported_fields (E_BOOK_BACKEND_SYNC (backend), book, opid, &fields);
+ e_book_backend_sync_get_supported_fields (E_BOOK_BACKEND_SYNC (backend), book, opid, &fields, &error);
- e_data_book_respond_get_supported_fields (book, opid, status, fields);
+ e_data_book_respond_get_supported_fields (book, opid, error, fields);
if (fields) {
g_list_foreach (fields, (GFunc)g_free, NULL);
@@ -516,12 +515,12 @@ _e_book_backend_get_supported_auth_methods (EBookBackend *backend,
EDataBook *book,
guint32 opid)
{
- EBookBackendSyncStatus status;
+ GError *error = NULL;
GList *methods = NULL;
- status = e_book_backend_sync_get_supported_auth_methods (E_BOOK_BACKEND_SYNC (backend), book, opid, &methods);
+ e_book_backend_sync_get_supported_auth_methods (E_BOOK_BACKEND_SYNC (backend), book, opid, &methods, &error);
- e_data_book_respond_get_supported_auth_methods (book, opid, status, methods);
+ e_data_book_respond_get_supported_auth_methods (book, opid, error, methods);
if (methods) {
g_list_foreach (methods, (GFunc)g_free, NULL);
diff --git a/addressbook/libedata-book/e-book-backend-sync.h b/addressbook/libedata-book/e-book-backend-sync.h
index b233dc0..16fb4fb 100644
--- a/addressbook/libedata-book/e-book-backend-sync.h
+++ b/addressbook/libedata-book/e-book-backend-sync.h
@@ -20,8 +20,6 @@ G_BEGIN_DECLS
typedef struct _EBookBackendSyncPrivate EBookBackendSyncPrivate;
-typedef GNOME_Evolution_Addressbook_CallStatus EBookBackendSyncStatus;
-
struct _EBookBackendSync {
EBookBackend parent_object;
EBookBackendSyncPrivate *priv;
@@ -31,41 +29,41 @@ struct _EBookBackendSyncClass {
EBookBackendClass parent_class;
/* Virtual methods */
- EBookBackendSyncStatus (*remove_sync) (EBookBackendSync *backend, EDataBook *book, guint32 opid);
- EBookBackendSyncStatus (*create_contact_sync) (EBookBackendSync *backend, EDataBook *book,
+ void (*remove_sync) (EBookBackendSync *backend, EDataBook *book, guint32 opid, GError **perror);
+ void (*create_contact_sync) (EBookBackendSync *backend, EDataBook *book,
guint32 opid,
- const gchar *vcard, EContact **contact);
- EBookBackendSyncStatus (*remove_contacts_sync) (EBookBackendSync *backend, EDataBook *book,
+ const gchar *vcard, EContact **contact, GError **perror);
+ void (*remove_contacts_sync) (EBookBackendSync *backend, EDataBook *book,
guint32 opid,
- GList *id_list, GList **removed_ids);
- EBookBackendSyncStatus (*modify_contact_sync) (EBookBackendSync *backend, EDataBook *book,
+ GList *id_list, GList **removed_ids, GError **perror);
+ void (*modify_contact_sync) (EBookBackendSync *backend, EDataBook *book,
guint32 opid,
- const gchar *vcard, EContact **contact);
- EBookBackendSyncStatus (*get_contact_sync) (EBookBackendSync *backend, EDataBook *book,
+ const gchar *vcard, EContact **contact, GError **perror);
+ void (*get_contact_sync) (EBookBackendSync *backend, EDataBook *book,
guint32 opid,
- const gchar *id, gchar **vcard);
- EBookBackendSyncStatus (*get_contact_list_sync) (EBookBackendSync *backend, EDataBook *book,
+ const gchar *id, gchar **vcard, GError **perror);
+ void (*get_contact_list_sync) (EBookBackendSync *backend, EDataBook *book,
guint32 opid,
- const gchar *query, GList **contacts);
- EBookBackendSyncStatus (*get_changes_sync) (EBookBackendSync *backend, EDataBook *book,
+ const gchar *query, GList **contacts, GError **perror);
+ void (*get_changes_sync) (EBookBackendSync *backend, EDataBook *book,
guint32 opid,
- const gchar *change_id, GList **changes);
- EBookBackendSyncStatus (*authenticate_user_sync) (EBookBackendSync *backend, EDataBook *book,
+ const gchar *change_id, GList **changes, GError **perror);
+ void (*authenticate_user_sync) (EBookBackendSync *backend, EDataBook *book,
guint32 opid,
const gchar *user,
const gchar *passwd,
- const gchar *auth_method);
+ const gchar *auth_method, GError **perror);
- EBookBackendSyncStatus (*get_required_fields_sync) (EBookBackendSync *backend, EDataBook *book,
+ void (*get_required_fields_sync) (EBookBackendSync *backend, EDataBook *book,
guint32 opid,
- GList **fields);
+ GList **fields, GError **perror);
- EBookBackendSyncStatus (*get_supported_fields_sync) (EBookBackendSync *backend, EDataBook *book,
+ void (*get_supported_fields_sync) (EBookBackendSync *backend, EDataBook *book,
guint32 opid,
- GList **fields);
- EBookBackendSyncStatus (*get_supported_auth_methods_sync) (EBookBackendSync *backend, EDataBook *book,
+ GList **fields, GError **perror);
+ void (*get_supported_auth_methods_sync) (EBookBackendSync *backend, EDataBook *book,
guint32 opid,
- GList **methods);
+ GList **methods, GError **perror);
/* Padding for future expansion */
void (*_pas_reserved0) (void);
@@ -80,18 +78,18 @@ gboolean e_book_backend_sync_construct (EBookBackendSync
GType e_book_backend_sync_get_type (void);
-EBookBackendSyncStatus e_book_backend_sync_remove (EBookBackendSync *backend, EDataBook *book, guint32 opid);
-EBookBackendSyncStatus e_book_backend_sync_create_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *vcard, EContact **contact);
-EBookBackendSyncStatus e_book_backend_sync_remove_contacts (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList *id_list, GList **removed_ids);
-EBookBackendSyncStatus e_book_backend_sync_modify_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *vcard, EContact **contact);
-EBookBackendSyncStatus e_book_backend_sync_get_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *id, gchar **vcard);
-EBookBackendSyncStatus e_book_backend_sync_get_contact_list (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *query, GList **contacts);
-EBookBackendSyncStatus e_book_backend_sync_get_changes (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *change_id, GList **changes);
-EBookBackendSyncStatus e_book_backend_sync_authenticate_user (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *user, const gchar *passwd, const gchar *auth_method);
-
-EBookBackendSyncStatus e_book_backend_sync_get_required_fields (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **fields);
-EBookBackendSyncStatus e_book_backend_sync_get_supported_fields (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **fields);
-EBookBackendSyncStatus e_book_backend_sync_get_supported_auth_methods (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **methods);
+void e_book_backend_sync_remove (EBookBackendSync *backend, EDataBook *book, guint32 opid, GError **perror);
+void e_book_backend_sync_create_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *vcard, EContact **contact, GError **perror);
+void e_book_backend_sync_remove_contacts (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList *id_list, GList **removed_ids, GError **perror);
+void e_book_backend_sync_modify_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *vcard, EContact **contact, GError **perror);
+void e_book_backend_sync_get_contact (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *id, gchar **vcard, GError **perror);
+void e_book_backend_sync_get_contact_list (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *query, GList **contacts, GError **perror);
+void e_book_backend_sync_get_changes (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *change_id, GList **changes, GError **perror);
+void e_book_backend_sync_authenticate_user (EBookBackendSync *backend, EDataBook *book, guint32 opid, const gchar *user, const gchar *passwd, const gchar *auth_method, GError **perror);
+
+void e_book_backend_sync_get_required_fields (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **fields, GError **perror);
+void e_book_backend_sync_get_supported_fields (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **fields, GError **perror);
+void e_book_backend_sync_get_supported_auth_methods (EBookBackendSync *backend, EDataBook *book, guint32 opid, GList **methods, GError **perror);
G_END_DECLS
diff --git a/addressbook/libedata-book/e-book-backend.c b/addressbook/libedata-book/e-book-backend.c
index d3ebab8..de3c327 100644
--- a/addressbook/libedata-book/e-book-backend.c
+++ b/addressbook/libedata-book/e-book-backend.c
@@ -56,32 +56,35 @@ e_book_backend_construct (EBookBackend *backend)
* @backend: an #EBookBackend
* @source: an #ESource to load
* @only_if_exists: %TRUE to prevent the creation of a new book
+ * @error: #GError to set, when something fails
*
* Loads @source into @backend.
- *
- * Returns: A #GNOME_Evolution_Addressbook_CallStatus indicating the outcome.
**/
-GNOME_Evolution_Addressbook_CallStatus
+void
e_book_backend_load_source (EBookBackend *backend,
ESource *source,
- gboolean only_if_exists)
+ gboolean only_if_exists,
+ GError **error)
{
- GNOME_Evolution_Addressbook_CallStatus status;
+ GError *err = NULL;
- g_return_val_if_fail (E_IS_BOOK_BACKEND (backend), FALSE);
- g_return_val_if_fail (source, FALSE);
- g_return_val_if_fail (backend->priv->loaded == FALSE, FALSE);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (source, E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (backend->priv->loaded == FALSE, E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_GET_CLASS (backend)->load_source);
- status = (* E_BOOK_BACKEND_GET_CLASS (backend)->load_source) (backend, source, only_if_exists);
+ (* E_BOOK_BACKEND_GET_CLASS (backend)->load_source) (backend, source, only_if_exists, &err);
- if (status == GNOME_Evolution_Addressbook_Success || status == GNOME_Evolution_Addressbook_InvalidServerVersion) {
+ if (err == NULL || g_error_matches (err, E_DATA_BOOK_ERROR, E_DATA_BOOK_STATUS_INVALID_SERVER_VERSION)) {
g_object_ref (source);
backend->priv->source = source;
- }
- return status;
+ if (err)
+ g_error_free (err);
+ } else {
+ g_propagate_error (error, err);
+ }
}
/**
@@ -125,17 +128,18 @@ e_book_backend_open (EBookBackend *backend,
e_data_book_report_writable (book, backend->priv->writable);
e_data_book_report_connection_status (book, backend->priv->online);
- e_data_book_respond_open (
- book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_open (book, opid, NULL);
} else {
- GNOME_Evolution_Addressbook_CallStatus status =
- e_book_backend_load_source (backend, e_data_book_get_source (book), only_if_exists);
+ GError *error = NULL;
- if (status == GNOME_Evolution_Addressbook_Success || status == GNOME_Evolution_Addressbook_InvalidServerVersion)
+ e_book_backend_load_source (backend, e_data_book_get_source (book), only_if_exists, &error);
+
+ if (!error || g_error_matches (error, E_DATA_BOOK_ERROR, E_DATA_BOOK_STATUS_INVALID_SERVER_VERSION)) {
e_data_book_report_writable (book, backend->priv->writable);
e_data_book_report_connection_status (book, backend->priv->online);
+ }
- e_data_book_respond_open (book, opid, status);
+ e_data_book_respond_open (book, opid, error);
}
g_mutex_unlock (backend->priv->open_mutex);
@@ -454,21 +458,21 @@ e_book_backend_get_supported_auth_methods (EBookBackend *backend,
* e_book_backend_cancel_operation:
* @backend: an #EBookBackend
* @book: an #EDataBook whose operation should be cancelled
+ * @error: #GError to set, when something fails
*
* Cancel @book's running operation on @backend.
- *
- * Returns: A GNOME_Evolution_Addressbook_CallStatus indicating the outcome.
**/
-GNOME_Evolution_Addressbook_CallStatus
+void
e_book_backend_cancel_operation (EBookBackend *backend,
- EDataBook *book)
+ EDataBook *book,
+ GError **error)
{
- g_return_val_if_fail (E_IS_BOOK_BACKEND (backend), GNOME_Evolution_Addressbook_OtherError);
- g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
g_assert (E_BOOK_BACKEND_GET_CLASS (backend)->cancel_operation);
- return (* E_BOOK_BACKEND_GET_CLASS (backend)->cancel_operation) (backend, book);
+ (* E_BOOK_BACKEND_GET_CLASS (backend)->cancel_operation) (backend, book, error);
}
static void
@@ -729,7 +733,7 @@ e_book_backend_set_is_removed (EBookBackend *backend, gboolean is_removed)
**/
void
e_book_backend_set_mode (EBookBackend *backend,
- GNOME_Evolution_Addressbook_BookMode mode)
+ EDataBookMode mode)
{
g_return_if_fail (E_IS_BOOK_BACKEND (backend));
@@ -765,7 +769,7 @@ e_book_backend_sync (EBookBackend *backend)
* Creates a new change item indicating @vcard was added.
* Meant to be used by backend implementations.
*
- * Returns: A new #GNOME_Evolution_Addressbook_BookChangeItem.
+ * Returns: A new #EDataBookChange.
**/
EDataBookChange *
e_book_backend_change_add_new (const gchar *vcard)
@@ -785,7 +789,7 @@ e_book_backend_change_add_new (const gchar *vcard)
* Creates a new change item indicating @vcard was modified.
* Meant to be used by backend implementations.
*
- * Returns: A new #GNOME_Evolution_Addressbook_BookChangeItem.
+ * Returns: A new #EDataBookChange.
**/
EDataBookChange *
e_book_backend_change_modify_new (const gchar *vcard)
@@ -805,7 +809,7 @@ e_book_backend_change_modify_new (const gchar *vcard)
* Creates a new change item indicating @vcard was deleted.
* Meant to be used by backend implementations.
*
- * Returns: A new #GNOME_Evolution_Addressbook_BookChangeItem.
+ * Returns: A new #EDataBookChange.
**/
EDataBookChange *
e_book_backend_change_delete_new (const gchar *vcard)
@@ -897,7 +901,7 @@ e_book_backend_notify_remove (EBookBackend *backend, const gchar *id)
static void
view_notify_complete (EDataBookView *view, gpointer unused)
{
- e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_Success);
+ e_data_book_view_notify_complete (view, NULL /* SUCCESS */);
}
/**
diff --git a/addressbook/libedata-book/e-book-backend.h b/addressbook/libedata-book/e-book-backend.h
index f35f67a..002a43d 100644
--- a/addressbook/libedata-book/e-book-backend.h
+++ b/addressbook/libedata-book/e-book-backend.h
@@ -50,7 +50,7 @@ struct _EBookBackendClass {
GObjectClass parent_class;
/* Virtual methods */
- GNOME_Evolution_Addressbook_CallStatus (*load_source) (EBookBackend *backend, ESource *source, gboolean only_if_exists);
+ void (*load_source) (EBookBackend *backend, ESource *source, gboolean only_if_exists, GError **error);
void (*remove) (EBookBackend *backend, EDataBook *book, guint32 opid);
gchar *(*get_static_capabilities) (EBookBackend *backend);
@@ -66,8 +66,8 @@ struct _EBookBackendClass {
void (*get_required_fields) (EBookBackend *backend, EDataBook *bokk, guint32 opid);
void (*get_supported_fields) (EBookBackend *backend, EDataBook *book, guint32 opid);
void (*get_supported_auth_methods) (EBookBackend *backend, EDataBook *book, guint32 opid);
- GNOME_Evolution_Addressbook_CallStatus (*cancel_operation) (EBookBackend *backend, EDataBook *book);
- void (*set_mode) (EBookBackend *backend, GNOME_Evolution_Addressbook_BookMode mode);
+ void (*cancel_operation) (EBookBackend *backend, EDataBook *book, GError **error);
+ void (*set_mode) (EBookBackend *backend, EDataBookMode mode);
/* Notification signals */
void (* last_client_gone) (EBookBackend *backend);
@@ -83,10 +83,10 @@ struct _EBookBackendClass {
gboolean e_book_backend_construct (EBookBackend *backend);
-GNOME_Evolution_Addressbook_CallStatus
- e_book_backend_load_source (EBookBackend *backend,
+void e_book_backend_load_source (EBookBackend *backend,
ESource *source,
- gboolean only_if_exists);
+ gboolean only_if_exists,
+ GError **error);
ESource *e_book_backend_get_source (EBookBackend *backend);
gboolean e_book_backend_add_client (EBookBackend *backend,
@@ -150,10 +150,11 @@ void e_book_backend_get_required_fields (EBookBackend *b
void e_book_backend_get_supported_auth_methods (EBookBackend *backend,
EDataBook *book,
guint32 opid);
-GNOME_Evolution_Addressbook_CallStatus e_book_backend_cancel_operation (EBookBackend *backend,
- EDataBook *book);
+void e_book_backend_cancel_operation (EBookBackend *backend,
+ EDataBook *book,
+ GError **error);
void e_book_backend_set_mode (EBookBackend *backend,
- GNOME_Evolution_Addressbook_BookMode mode);
+ EDataBookMode mode);
void e_book_backend_start_book_view (EBookBackend *backend,
EDataBookView *view);
@@ -189,9 +190,9 @@ void e_book_backend_set_is_removed (EBookBackend *b
gboolean is_removed);
/* useful for implementing _get_changes in backends */
-GNOME_Evolution_Addressbook_BookChangeItem* e_book_backend_change_add_new (const gchar *vcard);
-GNOME_Evolution_Addressbook_BookChangeItem* e_book_backend_change_modify_new (const gchar *vcard);
-GNOME_Evolution_Addressbook_BookChangeItem* e_book_backend_change_delete_new (const gchar *id);
+EDataBookChange* e_book_backend_change_add_new (const gchar *vcard);
+EDataBookChange* e_book_backend_change_modify_new (const gchar *vcard);
+EDataBookChange* e_book_backend_change_delete_new (const gchar *id);
G_END_DECLS
diff --git a/addressbook/libedata-book/e-data-book-types.h b/addressbook/libedata-book/e-data-book-types.h
index 7ac83e4..c6cdfaa 100644
--- a/addressbook/libedata-book/e-data-book-types.h
+++ b/addressbook/libedata-book/e-data-book-types.h
@@ -66,44 +66,16 @@ typedef enum {
E_DATA_BOOK_STATUS_OTHER_ERROR,
E_DATA_BOOK_STATUS_INVALID_SERVER_VERSION,
E_DATA_BOOK_STATUS_NO_SPACE,
+ E_DATA_BOOK_STATUS_INVALID_ARG,
+ E_DATA_BOOK_STATUS_NOT_SUPPORTED
} EDataBookStatus;
-/* Some hacks so the backends compile without change */
-#define GNOME_Evolution_Addressbook_CallStatus EDataBookStatus
-#define GNOME_Evolution_Addressbook_BookMode EDataBookMode
-
-#define GNOME_Evolution_Addressbook_Success E_DATA_BOOK_STATUS_SUCCESS
-#define GNOME_Evolution_Addressbook_RepositoryOffline E_DATA_BOOK_STATUS_REPOSITORY_OFFLINE
-#define GNOME_Evolution_Addressbook_PermissionDenied E_DATA_BOOK_STATUS_PERMISSION_DENIED
-#define GNOME_Evolution_Addressbook_ContactNotFound E_DATA_BOOK_STATUS_CONTACT_NOT_FOUND
-#define GNOME_Evolution_Addressbook_ContactIdAlreadyExists E_DATA_BOOK_STATUS_CONTACTID_ALREADY_EXISTS
-#define GNOME_Evolution_Addressbook_AuthenticationFailed E_DATA_BOOK_STATUS_AUTHENTICATION_FAILED
-#define GNOME_Evolution_Addressbook_AuthenticationRequired E_DATA_BOOK_STATUS_AUTHENTICATION_REQUIRED
-#define GNOME_Evolution_Addressbook_UnsupportedField E_DATA_BOOK_STATUS_UNSUPPORTED_FIELD
-#define GNOME_Evolution_Addressbook_UnsupportedAuthenticationMethod E_DATA_BOOK_STATUS_UNSUPPORTED_AUTHENTICATION_METHOD
-#define GNOME_Evolution_Addressbook_TLSNotAvailable E_DATA_BOOK_STATUS_TLS_NOT_AVAILABLE
-#define GNOME_Evolution_Addressbook_NoSuchBook E_DATA_BOOK_STATUS_NO_SUCH_BOOK
-#define GNOME_Evolution_Addressbook_BookRemoved E_DATA_BOOK_STATUS_BOOK_REMOVED
-#define GNOME_Evolution_Addressbook_OfflineUnavailable E_DATA_BOOK_STATUS_BOOK_REMOVED
-#define GNOME_Evolution_Addressbook_SearchSizeLimitExceeded E_DATA_BOOK_STATUS_SEARCH_SIZE_LIMIT_EXCEEDED
-#define GNOME_Evolution_Addressbook_SearchTimeLimitExceeded E_DATA_BOOK_STATUS_SEARCH_TIME_LIMIT_EXCEEDED
-#define GNOME_Evolution_Addressbook_InvalidQuery E_DATA_BOOK_STATUS_INVALID_QUERY
-#define GNOME_Evolution_Addressbook_QueryRefused E_DATA_BOOK_STATUS_QUERY_REFUSED
-#define GNOME_Evolution_Addressbook_CouldNotCancel E_DATA_BOOK_STATUS_COULD_NOT_CANCEL
-#define GNOME_Evolution_Addressbook_OtherError E_DATA_BOOK_STATUS_OTHER_ERROR
-#define GNOME_Evolution_Addressbook_InvalidServerVersion E_DATA_BOOK_STATUS_INVALID_SERVER_VERSION
-#define GNOME_Evolution_Addressbook_NoSpace E_DATA_BOOK_STATUS_NO_SPACE
-
typedef enum {
E_DATA_BOOK_MODE_LOCAL,
E_DATA_BOOK_MODE_REMOTE,
E_DATA_BOOK_MODE_ANY,
} EDataBookMode;
-#define GNOME_Evolution_Addressbook_MODE_LOCAL E_DATA_BOOK_MODE_LOCAL
-#define GNOME_Evolution_Addressbook_MODE_REMOTE E_DATA_BOOK_MODE_REMOTE
-#define GNOME_Evolution_Addressbook_MODE_ANY E_DATA_BOOK_MODE_ANY
-
typedef enum {
E_DATA_BOOK_BACKEND_CHANGE_ADDED,
E_DATA_BOOK_BACKEND_CHANGE_DELETED,
@@ -115,13 +87,6 @@ typedef struct {
gchar *vcard;
} EDataBookChange;
-/* Transition typedef */
-typedef EDataBookChange GNOME_Evolution_Addressbook_BookChangeItem;
-
-#define GNOME_Evolution_Addressbook_ContactAdded E_DATA_BOOK_BACKEND_CHANGE_ADDED
-#define GNOME_Evolution_Addressbook_ContactDeleted E_DATA_BOOK_BACKEND_CHANGE_DELETED
-#define GNOME_Evolution_Addressbook_ContactModified E_DATA_BOOK_BACKEND_CHANGE_MODIFIED
-
G_END_DECLS
#endif /* __E_DATA_BOOK_TYPES_H__ */
diff --git a/addressbook/libedata-book/e-data-book-view.c b/addressbook/libedata-book/e-data-book-view.c
index 252e3ec..055bcc8 100644
--- a/addressbook/libedata-book/e-data-book-view.c
+++ b/addressbook/libedata-book/e-data-book-view.c
@@ -28,6 +28,7 @@
#include <dbus/dbus.h>
#include <libebook/e-contact.h>
#include "e-data-book-view.h"
+#include "e-data-book-marshal.h"
extern DBusGConnection *connection;
@@ -122,8 +123,8 @@ e_data_book_view_class_init (EDataBookViewClass *klass)
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
- g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1, G_TYPE_UINT);
+ e_data_book_marshal_NONE__UINT_STRING,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (EDataBookViewPrivate));
@@ -434,14 +435,14 @@ e_data_book_view_notify_remove (EDataBookView *book_view, const gchar *id)
/**
* e_data_book_view_notify_complete:
* @book_view: an #EDataBookView
- * @status: the status of the query
+ * @error: the error of the query, if any
*
* Notifies listeners that all pending updates on @book_view
* have been sent. The listener's information should now be
* in sync with the backend's.
**/
void
-e_data_book_view_notify_complete (EDataBookView *book_view, EDataBookStatus status)
+e_data_book_view_notify_complete (EDataBookView *book_view, const GError *error)
{
EDataBookViewPrivate *priv = book_view->priv;
@@ -459,7 +460,7 @@ e_data_book_view_notify_complete (EDataBookView *book_view, EDataBookStatus stat
/* We're done now, so tell the backend to stop? TODO: this is a bit different to
how the CORBA backend works... */
- g_signal_emit (book_view, signals[COMPLETE], 0, status);
+ g_signal_emit (book_view, signals[COMPLETE], 0, error ? error->code : 0, error ? error->message : NULL);
}
/**
diff --git a/addressbook/libedata-book/e-data-book-view.h b/addressbook/libedata-book/e-data-book-view.h
index b8f7b23..eacc142 100644
--- a/addressbook/libedata-book/e-data-book-view.h
+++ b/addressbook/libedata-book/e-data-book-view.h
@@ -77,7 +77,7 @@ void e_data_book_view_notify_update_prefiltered_vcard (EDataBookView
void e_data_book_view_notify_remove (EDataBookView *book_view,
const gchar *id);
void e_data_book_view_notify_complete (EDataBookView *book_view,
- EDataBookStatus status);
+ const GError *error);
void e_data_book_view_notify_status_message (EDataBookView *book_view,
const gchar *message);
void e_data_book_view_ref (EDataBookView *book_view);
diff --git a/addressbook/libedata-book/e-data-book-view.xml b/addressbook/libedata-book/e-data-book-view.xml
index 29cfa6f..0ef2447 100644
--- a/addressbook/libedata-book/e-data-book-view.xml
+++ b/addressbook/libedata-book/e-data-book-view.xml
@@ -37,6 +37,7 @@
</signal>
<signal name="Complete">
<arg name="status" type="u"/>
+ <arg name="message" type="s"/>
</signal>
</interface>
diff --git a/addressbook/libedata-book/e-data-book.c b/addressbook/libedata-book/e-data-book.c
index 7794e8b..9364a0f 100644
--- a/addressbook/libedata-book/e-data-book.c
+++ b/addressbook/libedata-book/e-data-book.c
@@ -55,8 +55,8 @@ static gboolean impl_AddressBook_Book_cancelOperation(EDataBook *book, GError **
static void impl_AddressBook_Book_close(EDataBook *book, DBusGMethodInvocation *context);
#include "e-data-book-glue.h"
-static void return_status_and_list (guint32 opid, EDataBookStatus status, GList *list, gboolean free_data);
-static void data_book_return_error (DBusGMethodInvocation *context, gint code, const gchar *error_str);
+static void return_error_and_list (guint32 opid, GError *error, const gchar *error_fmt, GList *list, gboolean free_data);
+static void data_book_return_error (DBusGMethodInvocation *context, const GError *error, const gchar *error_fmt);
enum {
WRITABLE,
@@ -174,6 +174,48 @@ op_new (OperationID op, EDataBook *book, DBusGMethodInvocation *context)
return data;
}
+const gchar *
+e_data_book_status_to_string (EDataBookStatus status)
+{
+ gint i;
+ static struct _statuses {
+ EDataBookStatus status;
+ const gchar *msg;
+ } statuses[] = {
+ { E_DATA_BOOK_STATUS_SUCCESS, N_("Success") },
+ { E_DATA_BOOK_STATUS_REPOSITORY_OFFLINE, N_("Repository offline") },
+ { E_DATA_BOOK_STATUS_PERMISSION_DENIED, N_("Permission denied") },
+ { E_DATA_BOOK_STATUS_CONTACT_NOT_FOUND, N_("Contact not found") },
+ { E_DATA_BOOK_STATUS_CONTACTID_ALREADY_EXISTS, N_("Contact ID already exists") },
+ { E_DATA_BOOK_STATUS_AUTHENTICATION_FAILED, N_("Authentication Failed") },
+ { E_DATA_BOOK_STATUS_AUTHENTICATION_REQUIRED, N_("Authentication Required") },
+ { E_DATA_BOOK_STATUS_UNSUPPORTED_FIELD, N_("Unsupported field") },
+ { E_DATA_BOOK_STATUS_UNSUPPORTED_AUTHENTICATION_METHOD, N_("Unsupported authentication method") },
+ { E_DATA_BOOK_STATUS_TLS_NOT_AVAILABLE, N_("TLS not available") },
+ { E_DATA_BOOK_STATUS_NO_SUCH_BOOK, N_("Address Book does not exist") },
+ { E_DATA_BOOK_STATUS_BOOK_REMOVED, N_("Book removed") },
+ { E_DATA_BOOK_STATUS_OFFLINE_UNAVAILABLE, N_("Not available in offline mode") },
+ { E_DATA_BOOK_STATUS_SEARCH_SIZE_LIMIT_EXCEEDED, N_("Search size limit exceeded") },
+ { E_DATA_BOOK_STATUS_SEARCH_TIME_LIMIT_EXCEEDED, N_("Search time limit exceeded") },
+ { E_DATA_BOOK_STATUS_INVALID_QUERY, N_("Invalid query") },
+ { E_DATA_BOOK_STATUS_QUERY_REFUSED, N_("Query refused") },
+ { E_DATA_BOOK_STATUS_COULD_NOT_CANCEL, N_("Could not cancel") },
+ /* { E_DATA_BOOK_STATUS_OTHER_ERROR, N_("Other error") }, */
+ { E_DATA_BOOK_STATUS_INVALID_SERVER_VERSION, N_("Invalid server version") },
+ { E_DATA_BOOK_STATUS_NO_SPACE, N_("No space") },
+ { E_DATA_BOOK_STATUS_INVALID_ARG, N_("Invalid argument") },
+ { E_DATA_BOOK_STATUS_NOT_SUPPORTED, N_("Not supported") }
+
+ };
+
+ for (i = 0; i < G_N_ELEMENTS (statuses); i++) {
+ if (statuses[i].status == status)
+ return _(statuses[i].msg);
+ }
+
+ return _("Other error");
+}
+
/* Create the EDataBook error quark */
GQuark
e_data_book_error_quark (void)
@@ -184,6 +226,36 @@ e_data_book_error_quark (void)
return quark;
}
+GError *
+e_data_book_create_error (EDataBookStatus status, const gchar *custom_msg)
+{
+ if (status == E_DATA_BOOK_STATUS_SUCCESS)
+ return NULL;
+
+ return g_error_new_literal (E_DATA_BOOK_ERROR, status, custom_msg ? custom_msg : e_data_book_status_to_string (status));
+}
+
+GError *
+e_data_book_create_error_fmt (EDataBookStatus status, const gchar *custom_msg_fmt, ...)
+{
+ GError *error;
+ gchar *custom_msg;
+ va_list ap;
+
+ if (!custom_msg_fmt)
+ return e_data_book_create_error (status, NULL);
+
+ va_start (ap, custom_msg_fmt);
+ custom_msg = g_strdup_vprintf (custom_msg_fmt, ap);
+ va_end (ap);
+
+ error = e_data_book_create_error (status, custom_msg);
+
+ g_free (custom_msg);
+
+ return error;
+}
+
/* Generate the GObject boilerplate */
G_DEFINE_TYPE(EDataBook, e_data_book, G_TYPE_OBJECT)
@@ -293,12 +365,14 @@ impl_AddressBook_Book_open(EDataBook *book, gboolean only_if_exists, DBusGMethod
}
void
-e_data_book_respond_open (EDataBook *book, guint opid, EDataBookStatus status)
+e_data_book_respond_open (EDataBook *book, guint opid, GError *error)
{
DBusGMethodInvocation *context = opid_fetch (opid);
- if (status != E_DATA_BOOK_STATUS_SUCCESS) {
- data_book_return_error (context, status, _("Cannot open book"));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Cannot open book: %s"));
+ g_error_free (error);
} else {
dbus_g_method_return (context);
}
@@ -311,12 +385,14 @@ impl_AddressBook_Book_remove(EDataBook *book, DBusGMethodInvocation *context)
}
void
-e_data_book_respond_remove (EDataBook *book, guint opid, EDataBookStatus status)
+e_data_book_respond_remove (EDataBook *book, guint opid, GError *error)
{
DBusGMethodInvocation *context = opid_fetch (opid);
- if (status != E_DATA_BOOK_STATUS_SUCCESS) {
- data_book_return_error (context, status, _("Cannot remove book"));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Cannot remove book: %s"));
+ g_error_free (error);
} else {
dbus_g_method_return (context);
}
@@ -328,7 +404,12 @@ impl_AddressBook_Book_getContact (EDataBook *book, const gchar *IN_uid, DBusGMet
OperationData *op;
if (IN_uid == NULL) {
- data_book_return_error (context, E_DATA_BOOK_STATUS_CONTACT_NOT_FOUND, _("Cannot get contact"));
+ GError *error;
+
+ error = e_data_book_create_error (E_DATA_BOOK_STATUS_CONTACT_NOT_FOUND, NULL);
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Cannot get contact: %s"));
+ g_error_free (error);
return;
}
@@ -338,12 +419,14 @@ impl_AddressBook_Book_getContact (EDataBook *book, const gchar *IN_uid, DBusGMet
}
void
-e_data_book_respond_get_contact (EDataBook *book, guint32 opid, EDataBookStatus status, const gchar *vcard)
+e_data_book_respond_get_contact (EDataBook *book, guint32 opid, GError *error, const gchar *vcard)
{
DBusGMethodInvocation *context = opid_fetch (opid);
- if (status != E_DATA_BOOK_STATUS_SUCCESS) {
- data_book_return_error (context, status, _("Cannot get contact"));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Cannot get contact: %s"));
+ g_error_free (error);
} else {
dbus_g_method_return (context, vcard);
}
@@ -355,7 +438,10 @@ impl_AddressBook_Book_getContactList (EDataBook *book, const gchar *query, DBusG
OperationData *op;
if (query == NULL || query[0] == '\0') {
- data_book_return_error (context, E_DATA_BOOK_STATUS_INVALID_QUERY, _("Empty query"));
+ GError *error = e_data_book_create_error (E_DATA_BOOK_STATUS_INVALID_QUERY, NULL);
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Empty query: %s"));
+ g_error_free (error);
return;
}
@@ -365,9 +451,10 @@ impl_AddressBook_Book_getContactList (EDataBook *book, const gchar *query, DBusG
}
void
-e_data_book_respond_get_contact_list (EDataBook *book, guint32 opid, EDataBookStatus status, GList *cards)
+e_data_book_respond_get_contact_list (EDataBook *book, guint32 opid, GError *error, GList *cards)
{
- return_status_and_list (opid, status, cards, TRUE);
+ /* Translators: The '%s' is replaced with a detailed error message */
+ return_error_and_list (opid, error, _("Cannot get contact list: %s"), cards, TRUE);
}
static void
@@ -383,23 +470,27 @@ impl_AddressBook_Book_authenticateUser(EDataBook *book, const gchar *IN_user, co
}
static void
-data_book_return_error (DBusGMethodInvocation *context, gint code, const gchar *error_str)
+data_book_return_error (DBusGMethodInvocation *context, const GError *perror, const gchar *error_fmt)
{
GError *error;
- error = g_error_new (E_DATA_BOOK_ERROR, code, "%s", error_str);
+ g_return_if_fail (perror != NULL);
+
+ error = g_error_new (E_DATA_BOOK_ERROR, perror->code, error_fmt, perror->message);
dbus_g_method_return_error (context, error);
g_error_free (error);
}
void
-e_data_book_respond_authenticate_user (EDataBook *book, guint32 opid, EDataBookStatus status)
+e_data_book_respond_authenticate_user (EDataBook *book, guint32 opid, GError *error)
{
DBusGMethodInvocation *context = opid_fetch (opid);
- if (status != E_DATA_BOOK_STATUS_SUCCESS) {
- data_book_return_error (context, status, _("Cannot authenticate user"));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Cannot authenticate user: %s"));
+ g_error_free (error);
} else {
dbus_g_method_return (context);
}
@@ -411,7 +502,10 @@ impl_AddressBook_Book_addContact (EDataBook *book, const gchar *IN_vcard, DBusGM
OperationData *op;
if (IN_vcard == NULL || IN_vcard[0] == '\0') {
- data_book_return_error (context, E_DATA_BOOK_STATUS_INVALID_QUERY, _("Cannot add contact"));
+ GError *error = e_data_book_create_error (E_DATA_BOOK_STATUS_INVALID_QUERY, NULL);
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Cannot add contact: %s"));
+ g_error_free (error);
return;
}
@@ -421,12 +515,14 @@ impl_AddressBook_Book_addContact (EDataBook *book, const gchar *IN_vcard, DBusGM
}
void
-e_data_book_respond_create (EDataBook *book, guint32 opid, EDataBookStatus status, EContact *contact)
+e_data_book_respond_create (EDataBook *book, guint32 opid, GError *error, EContact *contact)
{
DBusGMethodInvocation *context = opid_fetch (opid);
- if (status != E_DATA_BOOK_STATUS_SUCCESS) {
- data_book_return_error (context, status, _("Cannot add contact"));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Cannot add contact: %s"));
+ g_error_free (error);
} else {
e_book_backend_notify_update (e_data_book_get_backend (book), contact);
e_book_backend_notify_complete (e_data_book_get_backend (book));
@@ -441,7 +537,10 @@ impl_AddressBook_Book_modifyContact (EDataBook *book, const gchar *IN_vcard, DBu
OperationData *op;
if (IN_vcard == NULL) {
- data_book_return_error (context, E_DATA_BOOK_STATUS_INVALID_QUERY, _("Cannot modify contact"));
+ GError *error = e_data_book_create_error (E_DATA_BOOK_STATUS_INVALID_QUERY, NULL);
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Cannot modify contact: %s"));
+ g_error_free (error);
return;
}
@@ -451,12 +550,14 @@ impl_AddressBook_Book_modifyContact (EDataBook *book, const gchar *IN_vcard, DBu
}
void
-e_data_book_respond_modify (EDataBook *book, guint32 opid, EDataBookStatus status, EContact *contact)
+e_data_book_respond_modify (EDataBook *book, guint32 opid, GError *error, EContact *contact)
{
DBusGMethodInvocation *context = opid_fetch (opid);
- if (status != E_DATA_BOOK_STATUS_SUCCESS) {
- data_book_return_error (context, status, _("Cannot modify contact"));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Cannot modify contact: %s"));
+ g_error_free (error);
} else {
e_book_backend_notify_update (e_data_book_get_backend (book), contact);
e_book_backend_notify_complete (e_data_book_get_backend (book));
@@ -486,12 +587,14 @@ impl_AddressBook_Book_removeContacts(EDataBook *book, const gchar **IN_uids, DBu
}
void
-e_data_book_respond_remove_contacts (EDataBook *book, guint32 opid, EDataBookStatus status, GList *ids)
+e_data_book_respond_remove_contacts (EDataBook *book, guint32 opid, GError *error, GList *ids)
{
DBusGMethodInvocation *context = opid_fetch (opid);
- if (status != E_DATA_BOOK_STATUS_SUCCESS) {
- data_book_return_error (context, status, _("Cannot remove contacts"));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Cannot remove contacts: %s"));
+ g_error_free (error);
} else {
GList *i;
@@ -517,9 +620,10 @@ impl_AddressBook_Book_getSupportedFields(EDataBook *book, DBusGMethodInvocation
}
void
-e_data_book_respond_get_supported_fields (EDataBook *book, guint32 opid, EDataBookStatus status, GList *fields)
+e_data_book_respond_get_supported_fields (EDataBook *book, guint32 opid, GError *error, GList *fields)
{
- return_status_and_list (opid, status, fields, FALSE);
+ /* Translators: The '%s' is replaced with a detailed error message */
+ return_error_and_list (opid, error, _("Cannot get supported fields: %s"), fields, FALSE);
}
static void
@@ -529,9 +633,10 @@ impl_AddressBook_Book_getRequiredFields(EDataBook *book, DBusGMethodInvocation *
}
void
-e_data_book_respond_get_required_fields (EDataBook *book, guint32 opid, EDataBookStatus status, GList *fields)
+e_data_book_respond_get_required_fields (EDataBook *book, guint32 opid, GError *error, GList *fields)
{
- return_status_and_list (opid, status, fields, FALSE);
+ /* Translators: The '%s' is replaced with a detailed error message */
+ return_error_and_list (opid, error, _("Cannot get required fields: %s"), fields, FALSE);
}
static void
@@ -541,9 +646,10 @@ impl_AddressBook_Book_getSupportedAuthMethods(EDataBook *book, DBusGMethodInvoca
}
void
-e_data_book_respond_get_supported_auth_methods (EDataBook *book, guint32 opid, EDataBookStatus status, GList *auth_methods)
+e_data_book_respond_get_supported_auth_methods (EDataBook *book, guint32 opid, GError *error, GList *auth_methods)
{
- return_status_and_list (opid, status, auth_methods, FALSE);
+ /* Translators: The '%s' is replaced with a detailed error message */
+ return_error_and_list (opid, error, _("Cannot get supported auth methods: %s"), auth_methods, FALSE);
}
static gchar *
@@ -566,7 +672,10 @@ impl_AddressBook_Book_getBookView (EDataBook *book, const gchar *search, const g
card_sexp = e_book_backend_sexp_new (search);
if (!card_sexp) {
- data_book_return_error (context, E_DATA_BOOK_STATUS_INVALID_QUERY, _("Invalid query"));
+ GError *error = e_data_book_create_error (E_DATA_BOOK_STATUS_INVALID_QUERY, NULL);
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Invalid query: %s"));
+ g_error_free (error);
return;
}
@@ -590,12 +699,14 @@ impl_AddressBook_Book_getChanges(EDataBook *book, const gchar *IN_change_id, DBu
}
void
-e_data_book_respond_get_changes (EDataBook *book, guint32 opid, EDataBookStatus status, GList *changes)
+e_data_book_respond_get_changes (EDataBook *book, guint32 opid, GError *error, GList *changes)
{
DBusGMethodInvocation *context = opid_fetch (opid);
- if (status != E_DATA_BOOK_STATUS_SUCCESS) {
- data_book_return_error (context, status, _("Cannot get changes"));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_book_return_error (context, error, _("Cannot get changes: %s"));
+ g_error_free (error);
} else {
/* The DBus interface to this is a(us), an array of structs of unsigned ints
and strings. In dbus-glib this is a GPtrArray of GValueArray of unsigned
@@ -632,8 +743,12 @@ e_data_book_respond_get_changes (EDataBook *book, guint32 opid, EDataBookStatus
static gboolean
impl_AddressBook_Book_cancelOperation(EDataBook *book, GError **error)
{
- if (e_book_backend_cancel_operation (e_data_book_get_backend (book), book) != GNOME_Evolution_Addressbook_Success) {
- g_set_error (error, E_DATA_BOOK_ERROR, E_DATA_BOOK_STATUS_COULD_NOT_CANCEL, "Failed to cancel operation");
+ GError *err = NULL;
+
+ e_book_backend_cancel_operation (e_data_book_get_backend (book), book, &err);
+
+ if (err) {
+ g_propagate_error (error, err);
return FALSE;
}
@@ -674,11 +789,16 @@ e_data_book_report_auth_required (EDataBook *book)
}
static void
-return_status_and_list (guint32 opid, EDataBookStatus status, GList *list, gboolean free_data)
+return_error_and_list (guint32 opid, GError *error, const gchar *error_fmt, GList *list, gboolean free_data)
{
DBusGMethodInvocation *context = opid_fetch (opid);
- if (status == E_DATA_BOOK_STATUS_SUCCESS) {
+ g_return_if_fail (error_fmt != NULL);
+
+ if (error) {
+ data_book_return_error (context, error, error_fmt);
+ g_error_free (error);
+ } else {
gchar **array;
GList *l;
gint i = 0;
@@ -695,7 +815,5 @@ return_status_and_list (guint32 opid, EDataBookStatus status, GList *list, gbool
} else {
g_free (array);
}
- } else {
- data_book_return_error (context, status, _("Cannot complete operation"));
}
}
diff --git a/addressbook/libedata-book/e-data-book.h b/addressbook/libedata-book/e-data-book.h
index 51b3d98..c879e1f 100644
--- a/addressbook/libedata-book/e-data-book.h
+++ b/addressbook/libedata-book/e-data-book.h
@@ -57,55 +57,92 @@ GQuark e_data_book_error_quark (void);
**/
#define E_DATA_BOOK_ERROR e_data_book_error_quark ()
+/**
+ * e_data_book_create_error:
+ * @status: #EDataBookStatus code
+ * @custom_msg: Custom message to use for the error. When NULL,
+ * then uses a default message based on the @status code.
+ *
+ * Returns: NULL, when the @status is E_DATA_BOOK_STATUS_SUCCESS,
+ * or a newly allocated GError, which should be freed
+ * with g_error_free() call.
+ **/
+GError *e_data_book_create_error (EDataBookStatus status, const gchar *custom_msg);
+
+/**
+ * e_data_book_create_error_fmt:
+ *
+ * Similar as e_data_book_create_error(), only here, instead of custom_msg,
+ * is used a printf() format to create a custom_msg for the error.
+ **/
+GError *e_data_book_create_error_fmt (EDataBookStatus status, const gchar *custom_msg_fmt, ...) G_GNUC_PRINTF (2, 3);
+
+const gchar *e_data_book_status_to_string (EDataBookStatus status);
+
+#define e_return_data_book_error_if_fail(expr, _code) \
+ G_STMT_START { \
+ if (G_LIKELY(expr)) { \
+ } else { \
+ g_log (G_LOG_DOMAIN, \
+ G_LOG_LEVEL_CRITICAL, \
+ "file %s: line %d (%s): assertion `%s' failed", \
+ __FILE__, __LINE__, G_STRFUNC, #expr); \
+ g_set_error (error, E_DATA_BOOK_ERROR, (_code), \
+ "file %s: line %d (%s): assertion `%s' failed", \
+ __FILE__, __LINE__, G_STRFUNC, #expr); \
+ return; \
+ } \
+ } G_STMT_END
+
EDataBook *e_data_book_new (EBookBackend *backend, ESource *source);
EBookBackend *e_data_book_get_backend (EDataBook *book);
ESource *e_data_book_get_source (EDataBook *book);
void e_data_book_respond_open (EDataBook *book,
guint32 opid,
- EDataBookStatus status);
+ GError *error);
void e_data_book_respond_remove (EDataBook *book,
guint32 opid,
- EDataBookStatus status);
+ GError *error);
void e_data_book_respond_create (EDataBook *book,
guint32 opid,
- EDataBookStatus status,
+ GError *error,
EContact *contact);
void e_data_book_respond_remove_contacts (EDataBook *book,
guint32 opid,
- EDataBookStatus status,
+ GError *error,
GList *ids);
void e_data_book_respond_modify (EDataBook *book,
guint32 opid,
- EDataBookStatus status,
+ GError *error,
EContact *contact);
void e_data_book_respond_authenticate_user (EDataBook *book,
guint32 opid,
- EDataBookStatus status);
+ GError *error);
void e_data_book_respond_get_supported_fields (EDataBook *book,
guint32 opid,
- EDataBookStatus status,
+ GError *error,
GList *fields);
void e_data_book_respond_get_required_fields (EDataBook *book,
guint32 opid,
- EDataBookStatus status,
+ GError *error,
GList *fields);
void e_data_book_respond_get_supported_auth_methods (EDataBook *book,
guint32 opid,
- EDataBookStatus status,
+ GError *error,
GList *fields);
void e_data_book_respond_get_contact (EDataBook *book,
guint32 opid,
- EDataBookStatus status,
+ GError *error,
const gchar *vcard);
void e_data_book_respond_get_contact_list (EDataBook *book,
guint32 opid,
- EDataBookStatus status,
+ GError *error,
GList *cards);
void e_data_book_respond_get_changes (EDataBook *book,
guint32 opid,
- EDataBookStatus status,
+ GError *error,
GList *changes);
void e_data_book_report_writable (EDataBook *book,
diff --git a/addressbook/tests/ebook/ebook-test-utils.c b/addressbook/tests/ebook/ebook-test-utils.c
index eee6d78..3b94eaf 100644
--- a/addressbook/tests/ebook/ebook-test-utils.c
+++ b/addressbook/tests/ebook/ebook-test-utils.c
@@ -131,13 +131,13 @@ ebook_test_utils_book_add_contact (EBook *book,
static void
add_contact_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
const gchar *uid,
EBookTestClosure *closure)
{
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
g_warning ("failed to asynchronously add the contact '%s': "
- "status %d", uid, status);
+ "status %d (%s)", uid, error->code, error->message);
exit (1);
}
@@ -160,8 +160,8 @@ ebook_test_utils_book_async_add_contact (EBook *book,
closure = g_new0 (EBookTestClosure, 1);
closure->cb = callback;
closure->user_data = user_data;
- if (e_book_async_add_contact (book, contact,
- (EBookIdCallback) add_contact_cb, closure)) {
+ if (!e_book_async_add_contact_ex (book, contact,
+ (EBookIdExCallback) add_contact_cb, closure)) {
g_warning ("failed to set up contact add");
exit(1);
}
@@ -187,12 +187,12 @@ ebook_test_utils_book_commit_contact (EBook *book,
static void
commit_contact_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
EBookTestClosure *closure)
{
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
g_warning ("failed to asynchronously commit the contact: "
- "status %d", status);
+ "status %d (%s)", error->code, error->message);
exit (1);
}
@@ -215,8 +215,8 @@ ebook_test_utils_book_async_commit_contact (EBook *book,
closure = g_new0 (EBookTestClosure, 1);
closure->cb = callback;
closure->user_data = user_data;
- if (e_book_async_commit_contact (book, contact,
- (EBookCallback) commit_contact_cb, closure)) {
+ if (!e_book_async_commit_contact_ex (book, contact,
+ (EBookExCallback) commit_contact_cb, closure)) {
g_warning ("failed to set up contact commit");
exit(1);
}
@@ -243,15 +243,15 @@ ebook_test_utils_book_get_contact (EBook *book,
static void
get_contact_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
EContact *contact,
EBookTestClosure *closure)
{
const gchar *uid;
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
g_warning ("failed to asynchronously get the contact: "
- "status %d", status);
+ "status %d (%s)", error->code, error->message);
exit (1);
}
@@ -276,8 +276,8 @@ ebook_test_utils_book_async_get_contact (EBook *book,
closure = g_new0 (EBookTestClosure, 1);
closure->cb = callback;
closure->user_data = user_data;
- if (e_book_async_get_contact (book, uid,
- (EBookContactCallback) get_contact_cb,
+ if (!e_book_async_get_contact_ex (book, uid,
+ (EBookContactExCallback) get_contact_cb,
closure)) {
g_warning ("failed to set up async getContact");
exit(1);
@@ -304,13 +304,13 @@ ebook_test_utils_book_get_required_fields (EBook *book)
static void
get_required_fields_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
EList *fields,
EBookTestClosure *closure)
{
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
g_warning ("failed to asynchronously get the required fields: "
- "status %d", status);
+ "status %d (%s)", error->code, error->message);
exit (1);
}
@@ -334,8 +334,8 @@ ebook_test_utils_book_async_get_required_fields (EBook *book,
closure = g_new0 (EBookTestClosure, 1);
closure->cb = callback;
closure->user_data = user_data;
- if (e_book_async_get_required_fields (book,
- (EBookEListCallback) get_required_fields_cb,
+ if (!e_book_async_get_required_fields_ex (book,
+ (EBookEListExCallback) get_required_fields_cb,
closure)) {
g_warning ("failed to set up async getRequiredFields");
exit(1);
@@ -380,13 +380,13 @@ ebook_test_utils_book_get_supported_auth_methods (EBook *book)
static void
get_supported_auth_methods_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
EList *methods,
EBookTestClosure *closure)
{
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
g_warning ("failed to asynchronously get the supported auth "
- "methods: status %d", status);
+ "methods: status %d (%s)", error->code, error->message);
exit (1);
}
@@ -411,8 +411,8 @@ ebook_test_utils_book_async_get_supported_auth_methods (EBook *book,
closure = g_new0 (EBookTestClosure, 1);
closure->cb = callback;
closure->user_data = user_data;
- if (e_book_async_get_supported_auth_methods (book,
- (EBookEListCallback) get_supported_auth_methods_cb,
+ if (!e_book_async_get_supported_auth_methods_ex (book,
+ (EBookEListExCallback) get_supported_auth_methods_cb,
closure)) {
g_warning ("failed to set up async getSupportedAuthMethods");
exit(1);
@@ -438,14 +438,14 @@ ebook_test_utils_book_get_supported_fields (EBook *book)
}
static void
-get_supported_fields_cb (EBook *book,
- EBookStatus status,
+get_supported_fields_cb (EBook *book,
+ const GError *error,
EList *fields,
EBookTestClosure *closure)
{
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
g_warning ("failed to asynchronously get the supported fields: "
- "status %d", status);
+ "status %d (%s)", error->code, error->message);
exit (1);
}
@@ -469,8 +469,8 @@ ebook_test_utils_book_async_get_supported_fields (EBook *book,
closure = g_new0 (EBookTestClosure, 1);
closure->cb = callback;
closure->user_data = user_data;
- if (e_book_async_get_supported_fields (book,
- (EBookEListCallback) get_supported_fields_cb,
+ if (!e_book_async_get_supported_fields_ex (book,
+ (EBookEListExCallback) get_supported_fields_cb,
closure)) {
g_warning ("failed to set up async getSupportedFields");
exit(1);
@@ -495,12 +495,12 @@ ebook_test_utils_book_remove_contact (EBook *book,
static void
remove_contact_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
EBookTestClosure *closure)
{
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
g_warning ("failed to asynchronously remove the contact: "
- "status %d", status);
+ "status %d (%s)", error->code, error->message);
exit (1);
}
@@ -523,8 +523,8 @@ ebook_test_utils_book_async_remove_contact (EBook *book,
closure = g_new0 (EBookTestClosure, 1);
closure->cb = callback;
closure->user_data = user_data;
- if (e_book_async_remove_contact (book, contact,
- (EBookCallback) remove_contact_cb,
+ if (!e_book_async_remove_contact_ex (book, contact,
+ (EBookExCallback) remove_contact_cb,
closure)) {
g_warning ("failed to set up async removeContacts (for a single contact)");
exit(1);
@@ -533,12 +533,12 @@ ebook_test_utils_book_async_remove_contact (EBook *book,
static void
remove_contact_by_id_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
EBookTestClosure *closure)
{
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
g_warning ("failed to asynchronously remove the contact by id: "
- "status %d", status);
+ "status %d (%s)", error->code, error->message);
exit (1);
}
@@ -561,8 +561,8 @@ ebook_test_utils_book_async_remove_contact_by_id (EBook *book,
closure = g_new0 (EBookTestClosure, 1);
closure->cb = callback;
closure->user_data = user_data;
- if (e_book_async_remove_contact_by_id (book, uid,
- (EBookCallback) remove_contact_by_id_cb,
+ if (!e_book_async_remove_contact_by_id_ex (book, uid,
+ (EBookExCallback) remove_contact_by_id_cb,
closure)) {
g_warning ("failed to set up async removeContacts (by id)");
exit(1);
@@ -587,12 +587,12 @@ ebook_test_utils_book_remove_contacts (EBook *book,
static void
remove_contacts_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
EBookTestClosure *closure)
{
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
g_warning ("failed to asynchronously remove the contacts: "
- "status %d", status);
+ "status %d (%s)", error->code, error->message);
exit (1);
}
@@ -615,8 +615,8 @@ ebook_test_utils_book_async_remove_contacts (EBook *book,
closure = g_new0 (EBookTestClosure, 1);
closure->cb = callback;
closure->user_data = user_data;
- if (e_book_async_remove_contacts (book, uids,
- (EBookCallback) remove_contacts_cb,
+ if (!e_book_async_remove_contacts_ex (book, uids,
+ (EBookExCallback) remove_contacts_cb,
closure)) {
g_warning ("failed to set up async removeContacts");
exit(1);
@@ -701,11 +701,11 @@ ebook_test_utils_book_remove (EBook *book)
}
static void
-remove_cb (EBook *book, EBookStatus status, EBookTestClosure *closure)
+remove_cb (EBook *book, const GError *error, EBookTestClosure *closure)
{
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
g_warning ("failed to asynchronously remove the book: "
- "status %d", status);
+ "status %d (%s)", error->code, error->message);
exit (1);
}
@@ -725,7 +725,7 @@ ebook_test_utils_book_async_remove (EBook *book,
closure = g_new0 (EBookTestClosure, 1);
closure->cb = callback;
closure->user_data = user_data;
- if (e_book_async_remove (book, (EBookCallback) remove_cb, closure)) {
+ if (!e_book_async_remove_ex (book, (EBookExCallback) remove_cb, closure)) {
g_warning ("failed to set up book removal");
exit(1);
}
@@ -751,13 +751,13 @@ ebook_test_utils_book_get_book_view (EBook *book,
static void
get_book_view_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
EBookView *view,
EBookTestClosure *closure)
{
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
g_warning ("failed to asynchronously get book view for the "
- "book: status %d", status);
+ "book: status %d (%s)", error->code, error->message);
exit (1);
}
@@ -779,7 +779,7 @@ ebook_test_utils_book_async_get_book_view (EBook *book,
closure = g_new0 (EBookTestClosure, 1);
closure->cb = callback;
closure->user_data = user_data;
- if (e_book_async_get_book_view (book, query, NULL, -1, (EBookBookViewCallback) get_book_view_cb, closure)) {
+ if (!e_book_async_get_book_view_ex (book, query, NULL, -1, (EBookBookViewExCallback) get_book_view_cb, closure)) {
g_warning ("failed to set up book view retrieval");
exit(1);
}
diff --git a/addressbook/tests/ebook/test-ebook-async.c b/addressbook/tests/ebook/test-ebook-async.c
index 4df8c5f..813d008 100644
--- a/addressbook/tests/ebook/test-ebook-async.c
+++ b/addressbook/tests/ebook/test-ebook-async.c
@@ -26,16 +26,18 @@ print_email (EContact *contact)
}
static void
-print_all_emails_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure)
+print_all_emails_cb (EBook *book, const GError *error, GList *contacts, gpointer closure)
{
GList *c;
- if (status == E_BOOK_ERROR_OK) {
+ if (!error) {
for (c = contacts; c; c = c->next) {
EContact *contact = E_CONTACT (c->data);
print_email (contact);
}
+ } else {
+ g_warning ("%s: Got error %d (%s)", G_STRFUNC, error->code, error->message);
}
g_main_loop_quit (loop);
@@ -48,16 +50,18 @@ print_all_emails (EBook *book)
query = e_book_query_field_exists (E_CONTACT_FULL_NAME);
- e_book_async_get_contacts (book, query, print_all_emails_cb, NULL);
+ e_book_async_get_contacts_ex (book, query, print_all_emails_cb, NULL);
e_book_query_unref (query);
}
static void
-print_email_cb (EBook *book, EBookStatus status, EContact *contact, gpointer closure)
+print_email_cb (EBook *book, const GError *error, EContact *contact, gpointer closure)
{
- if (status == E_BOOK_ERROR_OK)
+ if (!error)
print_email (contact);
+ else
+ g_warning ("%s: Got error %d (%s)", G_STRFUNC, error->code, error->message);
printf ("printing all contacts\n");
print_all_emails (book);
@@ -66,14 +70,16 @@ print_email_cb (EBook *book, EBookStatus status, EContact *contact, gpointer clo
static void
print_one_email (EBook *book)
{
- e_book_async_get_contact (book, "pas-id-0002023", print_email_cb, NULL);
+ e_book_async_get_contact_ex (book, "pas-id-0002023", print_email_cb, NULL);
}
static void
-book_loaded_cb (EBook *book, EBookStatus status, gpointer data)
+book_loaded_cb (EBook *book, const GError *error, gpointer data)
{
- if (status != E_BOOK_ERROR_OK)
+ if (error) {
+ g_warning ("%s: Got error %d (%s)", G_STRFUNC, error->code, error->message);
return;
+ }
printf ("printing one contact\n");
print_one_email (book);
@@ -94,7 +100,7 @@ main (gint argc, gchar **argv)
book = e_book_new_system_addressbook (NULL);
printf ("loading addressbook\n");
- e_book_async_open (book, FALSE, book_loaded_cb, book);
+ e_book_async_open_ex (book, FALSE, book_loaded_cb, book);
g_main_loop_run (loop);
diff --git a/addressbook/tests/ebook/test-ebook-get-book-view.c b/addressbook/tests/ebook/test-ebook-get-book-view.c
index c238168..e4a3277 100644
--- a/addressbook/tests/ebook/test-ebook-get-book-view.c
+++ b/addressbook/tests/ebook/test-ebook-get-book-view.c
@@ -47,7 +47,7 @@ contacts_removed (EBookView *book_view, const GList *ids)
}
static void
-sequence_complete (EBookView *book_view, EBookViewStatus status)
+view_complete (EBookView *book_view, EBookViewStatus status, const gchar *error_msg)
{
e_book_view_stop (book_view);
g_object_unref (book_view);
@@ -59,7 +59,7 @@ setup_and_start_view (EBookView *view)
{
g_signal_connect (view, "contacts_added", G_CALLBACK (contacts_added), NULL);
g_signal_connect (view, "contacts_removed", G_CALLBACK (contacts_removed), NULL);
- g_signal_connect (view, "sequence_complete", G_CALLBACK (sequence_complete), NULL);
+ g_signal_connect (view, "view_complete", G_CALLBACK (view_complete), NULL);
e_book_view_start (view);
}
diff --git a/addressbook/tests/ebook/test-stress-bookviews.c b/addressbook/tests/ebook/test-stress-bookviews.c
index 4aa0eb1..ffad969 100644
--- a/addressbook/tests/ebook/test-stress-bookviews.c
+++ b/addressbook/tests/ebook/test-stress-bookviews.c
@@ -43,9 +43,9 @@ contacts_removed (EBookView *book_view, const GList *ids)
}
static void
-sequence_complete (EBookView *book_view, EBookViewStatus status)
+view_complete (EBookView *book_view, EBookViewStatus status, const gchar *error_msg)
{
- printf ("sequence_complete (status == %d)\n", status);
+ printf ("view_complete (status == %d, error_msg == %s%s%s)\n", status, error_msg ? "'" : "", error_msg ? error_msg : "NULL", error_msg ? "'" : "");
}
gint
@@ -84,7 +84,7 @@ main (gint argc, gchar **argv)
g_signal_connect (new_view, "contacts_added", G_CALLBACK (contacts_added), NULL);
g_signal_connect (new_view, "contacts_removed", G_CALLBACK (contacts_removed), NULL);
- g_signal_connect (new_view, "sequence_complete", G_CALLBACK (sequence_complete), NULL);
+ g_signal_connect (new_view, "view_complete", G_CALLBACK (view_complete), NULL);
e_book_view_start (new_view);
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 9830c39..4d112b9 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -59,6 +59,9 @@
/* in seconds */
#define DEFAULT_REFRESH_TIME 60
+#define EDC_ERROR(_code) e_data_cal_create_error (_code, NULL)
+#define EDC_ERROR_EX(_code, _msg) e_data_cal_create_error (_code, _msg)
+
typedef enum {
SLAVE_SHOULD_SLEEP,
@@ -469,43 +472,41 @@ quote_etag (const gchar *etag)
/* ************************************************************************* */
-static ECalBackendSyncStatus
-status_code_to_result (guint status_code, ECalBackendCalDAVPrivate *priv)
+static gboolean
+status_code_to_result (guint status_code, ECalBackendCalDAVPrivate *priv, GError **perror)
{
- ECalBackendSyncStatus result;
-
if (SOUP_STATUS_IS_SUCCESSFUL (status_code)) {
- return GNOME_Evolution_Calendar_Success;
+ return TRUE;
}
switch (status_code) {
case 404:
- result = GNOME_Evolution_Calendar_NoSuchCal;
+ g_propagate_error (perror, EDC_ERROR (NoSuchCal));
break;
case 403:
- result = GNOME_Evolution_Calendar_AuthenticationFailed;
+ g_propagate_error (perror, EDC_ERROR (AuthenticationFailed));
break;
case 401:
if (priv && priv->need_auth)
- result = GNOME_Evolution_Calendar_AuthenticationFailed;
+ g_propagate_error (perror, EDC_ERROR (AuthenticationFailed));
else
- result = GNOME_Evolution_Calendar_AuthenticationRequired;
+ g_propagate_error (perror, EDC_ERROR (AuthenticationRequired));
break;
default:
d(g_debug ("CalDAV:%s: Unhandled status code %d\n", G_STRFUNC, status_code));
- result = GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, e_data_cal_create_error_fmt (OtherError, _("Unexpected HTTP status code %d returned"), status_code));
}
- return result;
+ return FALSE;
}
/* !TS, call with lock held */
-static ECalBackendSyncStatus
-check_state (ECalBackendCalDAV *cbdav, gboolean *online)
+static gboolean
+check_state (ECalBackendCalDAV *cbdav, gboolean *online, GError **perror)
{
ECalBackendCalDAVPrivate *priv;
@@ -514,20 +515,22 @@ check_state (ECalBackendCalDAV *cbdav, gboolean *online)
*online = FALSE;
if (!priv->loaded) {
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, "Not loaded"));
+ return FALSE;
}
if (priv->mode == CAL_MODE_LOCAL) {
if (!priv->do_offline) {
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
+ return FALSE;
}
} else {
*online = TRUE;
}
- return GNOME_Evolution_Calendar_Success;
+ return TRUE;
}
/* ************************************************************************* */
@@ -928,8 +931,8 @@ caldav_generate_uri (ECalBackendCalDAV *cbdav, const gchar *target)
return uri;
}
-static ECalBackendSyncStatus
-caldav_server_open_calendar (ECalBackendCalDAV *cbdav)
+static gboolean
+caldav_server_open_calendar (ECalBackendCalDAV *cbdav, GError **perror)
{
ECalBackendCalDAVPrivate *priv;
SoupMessage *message;
@@ -943,19 +946,19 @@ caldav_server_open_calendar (ECalBackendCalDAV *cbdav)
/* FIXME: setup text_uri */
message = soup_message_new (SOUP_METHOD_OPTIONS, priv->uri);
- if (message == NULL)
- return GNOME_Evolution_Calendar_NoSuchCal;
+ if (message == NULL) {
+ g_propagate_error (perror, EDC_ERROR (NoSuchCal));
+ return FALSE;
+ }
soup_message_headers_append (message->request_headers,
"User-Agent", "Evolution/" VERSION);
send_and_handle_redirection (priv->session, message, NULL);
if (!SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
- guint status_code = message->status_code;
-
+ status_code_to_result (message->status_code, priv, perror);
g_object_unref (message);
-
- return status_code_to_result (status_code, priv);
+ return FALSE;
}
/* parse the dav header, we are intreseted in the
@@ -982,10 +985,11 @@ caldav_server_open_calendar (ECalBackendCalDAV *cbdav)
if (calendar_access) {
priv->read_only = !(put_allowed && delete_allowed);
- return GNOME_Evolution_Calendar_Success;
+ return TRUE;
}
- return GNOME_Evolution_Calendar_NoSuchCal;
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
+ return FALSE;
}
/* Returns whether calendar changed on the server. This works only when server
@@ -1203,17 +1207,15 @@ caldav_server_list_objects (ECalBackendCalDAV *cbdav, CalDAVObject **objs, gint
return result;
}
-static ECalBackendSyncStatus
-caldav_server_get_object (ECalBackendCalDAV *cbdav, CalDAVObject *object)
+static gboolean
+caldav_server_get_object (ECalBackendCalDAV *cbdav, CalDAVObject *object, GError **perror)
{
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus result;
SoupMessage *message;
const gchar *hdr;
gchar *uri;
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
- result = GNOME_Evolution_Calendar_Success;
g_assert (object != NULL && object->href != NULL);
@@ -1221,7 +1223,8 @@ caldav_server_get_object (ECalBackendCalDAV *cbdav, CalDAVObject *object)
message = soup_message_new (SOUP_METHOD_GET, uri);
if (message == NULL) {
g_free (uri);
- return GNOME_Evolution_Calendar_NoSuchCal;
+ g_propagate_error (perror, EDC_ERROR (NoSuchCal));
+ return FALSE;
}
soup_message_headers_append (message->request_headers,
@@ -1230,22 +1233,22 @@ caldav_server_get_object (ECalBackendCalDAV *cbdav, CalDAVObject *object)
send_and_handle_redirection (priv->session, message, NULL);
if (!SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
- guint status_code = message->status_code;
- g_object_unref (message);
+ status_code_to_result (message->status_code, priv, perror);
- g_warning ("Could not fetch object '%s' from server, status:%d (%s)", uri, status_code, soup_status_get_phrase (status_code) ? soup_status_get_phrase (status_code) : "Unknown code");
+ g_warning ("Could not fetch object '%s' from server, status:%d (%s)", uri, message->status_code, soup_status_get_phrase (message->status_code) ? soup_status_get_phrase (message->status_code) : "Unknown code");
+ g_object_unref (message);
g_free (uri);
- return status_code_to_result (status_code, priv);
+ return FALSE;
}
hdr = soup_message_headers_get (message->response_headers, "Content-Type");
if (hdr == NULL || g_ascii_strncasecmp (hdr, "text/calendar", 13)) {
- result = GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (perror, EDC_ERROR (InvalidObject));
g_object_unref (message);
g_warning ("Object to fetch '%s' not of type text/calendar", uri);
g_free (uri);
- return result;
+ return FALSE;
}
hdr = soup_message_headers_get (message->response_headers, "ETag");
@@ -1263,25 +1266,26 @@ caldav_server_get_object (ECalBackendCalDAV *cbdav, CalDAVObject *object)
g_object_unref (message);
- return result;
+ return TRUE;
}
-static ECalBackendSyncStatus
-caldav_post_freebusy (ECalBackendCalDAV *cbdav, const gchar *url, gchar **post_fb)
+static void
+caldav_post_freebusy (ECalBackendCalDAV *cbdav, const gchar *url, gchar **post_fb, GError **error)
{
ECalBackendCalDAVPrivate *priv;
SoupMessage *message;
- g_return_val_if_fail (cbdav != NULL, GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (url != NULL, GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (post_fb != NULL, GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (*post_fb != NULL, GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (cbdav != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (url != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (post_fb != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (*post_fb != NULL, InvalidArg);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
message = soup_message_new (SOUP_METHOD_POST, url);
if (message == NULL) {
- return GNOME_Evolution_Calendar_NoSuchCal;
+ g_propagate_error (error, EDC_ERROR (NoSuchCal));
+ return;
}
soup_message_headers_append (message->request_headers, "User-Agent", "Evolution/" VERSION);
@@ -1293,32 +1297,28 @@ caldav_post_freebusy (ECalBackendCalDAV *cbdav, const gchar *url, gchar **post_f
send_and_handle_redirection (priv->session, message, NULL);
if (!SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
- guint status_code = message->status_code;
+ status_code_to_result (message->status_code, priv, error);
+ g_warning ("Could not post free/busy request to '%s', status:%d (%s)", url, message->status_code, soup_status_get_phrase (message->status_code) ? soup_status_get_phrase (message->status_code) : "Unknown code");
g_object_unref (message);
- g_warning ("Could not post free/busy request to '%s', status:%d (%s)", url, status_code, soup_status_get_phrase (status_code) ? soup_status_get_phrase (status_code) : "Unknown code");
- return status_code_to_result (status_code, priv);
+ return;
}
g_free (*post_fb);
*post_fb = g_strdup (message->response_body->data);
g_object_unref (message);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-caldav_server_put_object (ECalBackendCalDAV *cbdav, CalDAVObject *object, icalcomponent *icalcomp)
+static gboolean
+caldav_server_put_object (ECalBackendCalDAV *cbdav, CalDAVObject *object, icalcomponent *icalcomp, GError **perror)
{
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus result;
SoupMessage *message;
const gchar *hdr;
gchar *uri;
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
- result = GNOME_Evolution_Calendar_Success;
hdr = NULL;
g_assert (object != NULL && object->cdata != NULL);
@@ -1326,8 +1326,10 @@ caldav_server_put_object (ECalBackendCalDAV *cbdav, CalDAVObject *object, icalco
uri = caldav_generate_uri (cbdav, object->href);
message = soup_message_new (SOUP_METHOD_PUT, uri);
g_free (uri);
- if (message == NULL)
- return GNOME_Evolution_Calendar_NoSuchCal;
+ if (message == NULL) {
+ g_propagate_error (perror, EDC_ERROR (NoSuchCal));
+ return FALSE;
+ }
soup_message_headers_append (message->request_headers,
"User-Agent", "Evolution/" VERSION);
@@ -1370,9 +1372,7 @@ caldav_server_put_object (ECalBackendCalDAV *cbdav, CalDAVObject *object, icalco
g_free (uri);
}
- result = status_code_to_result (message->status_code, priv);
-
- if (result == GNOME_Evolution_Calendar_Success) {
+ if (status_code_to_result (message->status_code, priv, perror)) {
gboolean was_get = FALSE;
hdr = soup_message_headers_get (message->response_headers, "ETag");
@@ -1399,10 +1399,9 @@ caldav_server_put_object (ECalBackendCalDAV *cbdav, CalDAVObject *object, icalco
}
}
- result = caldav_server_get_object (cbdav, object);
was_get = TRUE;
- if (result == GNOME_Evolution_Calendar_Success) {
+ if (caldav_server_get_object (cbdav, object, perror)) {
icalcomponent *use_comp = NULL;
if (object->cdata && was_get) {
@@ -1421,27 +1420,28 @@ caldav_server_put_object (ECalBackendCalDAV *cbdav, CalDAVObject *object, icalco
}
g_object_unref (message);
- return result;
+
+ return TRUE;
}
-static ECalBackendSyncStatus
-caldav_server_delete_object (ECalBackendCalDAV *cbdav, CalDAVObject *object)
+static void
+caldav_server_delete_object (ECalBackendCalDAV *cbdav, CalDAVObject *object, GError **perror)
{
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus result;
SoupMessage *message;
gchar *uri;
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
- result = GNOME_Evolution_Calendar_Success;
g_assert (object != NULL && object->href != NULL);
uri = caldav_generate_uri (cbdav, object->href);
message = soup_message_new (SOUP_METHOD_DELETE, uri);
g_free (uri);
- if (message == NULL)
- return GNOME_Evolution_Calendar_NoSuchCal;
+ if (message == NULL) {
+ g_propagate_error (perror, EDC_ERROR (NoSuchCal));
+ return;
+ }
soup_message_headers_append (message->request_headers,
"User-Agent", "Evolution/" VERSION);
@@ -1453,11 +1453,9 @@ caldav_server_delete_object (ECalBackendCalDAV *cbdav, CalDAVObject *object)
send_and_handle_redirection (priv->session, message, NULL);
- result = status_code_to_result (message->status_code, priv);
+ status_code_to_result (message->status_code, priv, perror);
g_object_unref (message);
-
- return result;
}
static gboolean
@@ -2028,10 +2026,11 @@ get_users_email (const gchar *username, const gchar *may_append)
/* ************************************************************************* */
/* ********** ECalBackendSync virtual function implementation ************* */
-static ECalBackendSyncStatus
+static void
caldav_is_read_only (ECalBackendSync *backend,
EDataCal *cal,
- gboolean *read_only)
+ gboolean *read_only,
+ GError **perror)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
@@ -2045,14 +2044,13 @@ caldav_is_read_only (ECalBackendSync *backend,
} else {
*read_only = priv->read_only;
}
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
caldav_get_cal_address (ECalBackendSync *backend,
EDataCal *cal,
- gchar **address)
+ gchar **address,
+ GError **perror)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
@@ -2065,14 +2063,13 @@ caldav_get_cal_address (ECalBackendSync *backend,
if (priv && priv->is_google && priv->username) {
*address = get_users_email (priv->username, "@gmail.com");
}
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
caldav_get_alarm_email_address (ECalBackendSync *backend,
EDataCal *cal,
- gchar **address)
+ gchar **address,
+ GError **perror)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
@@ -2085,23 +2082,22 @@ caldav_get_alarm_email_address (ECalBackendSync *backend,
if (priv && priv->is_google && priv->username) {
*address = get_users_email (priv->username, "@gmail.com");
}
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
caldav_get_ldap_attribute (ECalBackendSync *backend,
EDataCal *cal,
- gchar **attribute)
+ gchar **attribute,
+ GError **perror)
{
*attribute = NULL;
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
caldav_get_static_capabilities (ECalBackendSync *backend,
EDataCal *cal,
- gchar **capabilities)
+ gchar **capabilities,
+ GError **perror)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
@@ -2118,14 +2114,11 @@ caldav_get_static_capabilities (ECalBackendSync *backend,
CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-initialize_backend (ECalBackendCalDAV *cbdav)
+static gboolean
+initialize_backend (ECalBackendCalDAV *cbdav, GError **perror)
{
- ECalBackendSyncStatus result;
ECalBackendCalDAVPrivate *priv;
ECalSourceType source_type;
ESource *source;
@@ -2140,7 +2133,6 @@ initialize_backend (ECalBackendCalDAV *cbdav)
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
- result = GNOME_Evolution_Calendar_Success;
source = e_cal_backend_get_source (E_CAL_BACKEND (cbdav));
if (!g_signal_handler_find (G_OBJECT (source), G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, caldav_source_changed_cb, cbdav))
@@ -2247,8 +2239,8 @@ initialize_backend (ECalBackendCalDAV *cbdav)
priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (priv->uri, source_type);
if (priv->store == NULL) {
- result = GNOME_Evolution_Calendar_OtherError;
- goto out;
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, "Cannot create local store"));
+ return FALSE;
}
e_cal_backend_store_load (priv->store);
@@ -2263,8 +2255,8 @@ initialize_backend (ECalBackendCalDAV *cbdav)
g_free (priv->local_attachments_store);
priv->local_attachments_store = filename;
if (g_mkdir_with_parents (filename, 0700) < 0) {
- result = GNOME_Evolution_Calendar_OtherError;
- goto out;
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, "mkdir failed"));
+ return FALSE;
}
refresh = e_source_get_property (source, "refresh");
@@ -2277,14 +2269,13 @@ initialize_backend (ECalBackendCalDAV *cbdav)
slave = g_thread_create (caldav_synch_slave_loop, cbdav, FALSE, NULL);
if (slave == NULL) {
- g_warning ("Could not create synch slave");
- result = GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, "Could not create synch slave"));
}
priv->synch_slave = slave;
}
-out:
- return result;
+
+ return TRUE;
}
static void
@@ -2322,40 +2313,35 @@ is_google_uri (const gchar *uri)
return res;
}
-static ECalBackendSyncStatus
+static void
caldav_do_open (ECalBackendSync *backend,
EDataCal *cal,
gboolean only_if_exists,
const gchar *username,
- const gchar *password)
+ const gchar *password,
+ GError **perror)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus status;
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
- status = GNOME_Evolution_Calendar_Success;
-
g_mutex_lock (priv->busy_lock);
/* let it decide the 'getctag' extension availability again */
priv->ctag_supported = TRUE;
- if (!priv->loaded) {
- status = initialize_backend (cbdav);
- }
-
- if (status != GNOME_Evolution_Calendar_Success) {
+ if (!priv->loaded && !initialize_backend (cbdav, perror)) {
g_mutex_unlock (priv->busy_lock);
- return status;
+ return;
}
if (priv->need_auth) {
if ((username == NULL || password == NULL)) {
g_mutex_unlock (priv->busy_lock);
- return GNOME_Evolution_Calendar_AuthenticationRequired;
+ g_propagate_error (perror, EDC_ERROR (AuthenticationRequired));
+ return;
}
g_free (priv->username);
@@ -2366,7 +2352,8 @@ caldav_do_open (ECalBackendSync *backend,
if (!priv->do_offline && priv->mode == CAL_MODE_LOCAL) {
g_mutex_unlock (priv->busy_lock);
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
+ return;
}
priv->loaded = TRUE;
@@ -2376,9 +2363,7 @@ caldav_do_open (ECalBackendSync *backend,
/* set forward proxy */
proxy_settings_changed (priv->proxy, priv);
- status = caldav_server_open_calendar (cbdav);
-
- if (status == GNOME_Evolution_Calendar_Success) {
+ if (caldav_server_open_calendar (cbdav, perror)) {
priv->slave_cmd = SLAVE_SHOULD_WORK;
g_cond_signal (priv->cond);
@@ -2389,12 +2374,10 @@ caldav_do_open (ECalBackendSync *backend,
}
g_mutex_unlock (priv->busy_lock);
-
- return status;
}
-static ECalBackendSyncStatus
-caldav_refresh (ECalBackendSync *backend, EDataCal *cal)
+static void
+caldav_refresh (ECalBackendSync *backend, EDataCal *cal, GError **perror)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
@@ -2407,10 +2390,10 @@ caldav_refresh (ECalBackendSync *backend, EDataCal *cal)
if (!priv->loaded
|| priv->slave_cmd != SLAVE_SHOULD_SLEEP
- || check_state (cbdav, &online) != GNOME_Evolution_Calendar_Success
+ || !check_state (cbdav, &online, NULL)
|| !online) {
g_mutex_unlock (priv->busy_lock);
- return GNOME_Evolution_Calendar_Success;
+ return;
}
priv->slave_cmd = SLAVE_SHOULD_WORK;
@@ -2418,17 +2401,15 @@ caldav_refresh (ECalBackendSync *backend, EDataCal *cal)
/* wake it up */
g_cond_signal (priv->cond);
g_mutex_unlock (priv->busy_lock);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
caldav_remove (ECalBackendSync *backend,
- EDataCal *cal)
+ EDataCal *cal,
+ GError **perror)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus status;
gboolean online;
cbdav = E_CAL_BACKEND_CALDAV (backend);
@@ -2441,14 +2422,13 @@ caldav_remove (ECalBackendSync *backend,
if (!priv->loaded) {
g_mutex_unlock (priv->busy_lock);
- return GNOME_Evolution_Calendar_Success;
+ return;
}
- status = check_state (cbdav, &online);
-
- /* lie here a bit, but otherwise the calendar will not be removed, even it should */
- if (status != GNOME_Evolution_Calendar_Success)
- g_print (G_STRLOC ": %s", e_cal_backend_status_to_string (status));
+ if (!check_state (cbdav, &online, NULL)) {
+ /* lie here a bit, but otherwise the calendar will not be removed, even it should */
+ g_print (G_STRLOC ": Failed to check state");
+ }
e_cal_backend_store_remove (priv->store);
priv->store = NULL;
@@ -2462,8 +2442,6 @@ caldav_remove (ECalBackendSync *backend,
}
g_mutex_unlock (priv->busy_lock);
-
- return GNOME_Evolution_Calendar_Success;
}
static void
@@ -3204,35 +3182,33 @@ replace_master (ECalBackendCalDAV *cbdav, icalcomponent *old_comp, icalcomponent
}
/* a busy_lock is supposed to be locked already, when calling this function */
-static ECalBackendSyncStatus
-do_create_object (ECalBackendCalDAV *cbdav, gchar **calobj, gchar **uid)
+static void
+do_create_object (ECalBackendCalDAV *cbdav, gchar **calobj, gchar **uid, GError **perror)
{
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus status;
ECalComponent *comp;
- gboolean online;
+ gboolean online, did_put = FALSE;
struct icaltimetype current;
icalcomponent *icalcomp;
const gchar *comp_uid;
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
- status = check_state (cbdav, &online);
-
- if (status != GNOME_Evolution_Calendar_Success) {
- return status;
- }
+ if (!check_state (cbdav, &online, perror))
+ return;
comp = e_cal_component_new_from_string (*calobj);
if (comp == NULL) {
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (perror, EDC_ERROR (InvalidObject));
+ return;
}
icalcomp = e_cal_component_get_icalcomponent (comp);
if (icalcomp == NULL) {
g_object_unref (comp);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (perror, EDC_ERROR (InvalidObject));
+ return;
}
comp_uid = icalcomponent_get_uid (icalcomp);
@@ -3242,7 +3218,8 @@ do_create_object (ECalBackendCalDAV *cbdav, gchar **calobj, gchar **uid)
new_uid = e_cal_component_gen_uid ();
if (!new_uid) {
g_object_unref (comp);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (perror, EDC_ERROR (InvalidObject));
+ return;
}
icalcomponent_set_uid (icalcomp, new_uid);
@@ -3254,7 +3231,8 @@ do_create_object (ECalBackendCalDAV *cbdav, gchar **calobj, gchar **uid)
/* check the object is not in our cache */
if (cache_contains (cbdav, comp_uid, NULL)) {
g_object_unref (comp);
- return GNOME_Evolution_Calendar_ObjectIdAlreadyExists;
+ g_propagate_error (perror, EDC_ERROR (ObjectIdAlreadyExists));
+ return;
}
/* Set the created and last modified times on the component */
@@ -3272,7 +3250,7 @@ do_create_object (ECalBackendCalDAV *cbdav, gchar **calobj, gchar **uid)
object.etag = NULL;
object.cdata = pack_cobj (cbdav, icalcomp);
- status = caldav_server_put_object (cbdav, &object, icalcomp);
+ did_put = caldav_server_put_object (cbdav, &object, icalcomp, perror);
caldav_object_free (&object, FALSE);
} else {
@@ -3280,7 +3258,7 @@ do_create_object (ECalBackendCalDAV *cbdav, gchar **calobj, gchar **uid)
/*ecalcomp_set_synch_state (comp, ECALCOMP_LOCALLY_CREATED); */
}
- if (status == GNOME_Evolution_Calendar_Success) {
+ if (did_put) {
if (uid)
*uid = g_strdup (comp_uid);
@@ -3301,19 +3279,16 @@ do_create_object (ECalBackendCalDAV *cbdav, gchar **calobj, gchar **uid)
}
g_object_unref (comp);
-
- return status;
}
/* a busy_lock is supposed to be locked already, when calling this function */
-static ECalBackendSyncStatus
-do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object)
+static void
+do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object, GError **error)
{
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus status;
ECalComponent *comp;
icalcomponent *cache_comp;
- gboolean online;
+ gboolean online, did_put = FALSE;
ECalComponentId *id;
struct icaltimetype current;
gchar *href = NULL, *etag = NULL;
@@ -3323,21 +3298,21 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
if (new_object)
*new_object = NULL;
- status = check_state (cbdav, &online);
- if (status != GNOME_Evolution_Calendar_Success) {
- return status;
- }
+ if (!check_state (cbdav, &online, error))
+ return;
comp = e_cal_component_new_from_string (calobj);
if (comp == NULL) {
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
}
if (!e_cal_component_get_icalcomponent (comp) ||
icalcomponent_isa (e_cal_component_get_icalcomponent (comp)) != e_cal_backend_get_kind (E_CAL_BACKEND (cbdav))) {
g_object_unref (comp);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
}
/* Set the last modified time on the component */
@@ -3348,7 +3323,7 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
sanitize_component ((ECalBackend *)cbdav, comp);
id = e_cal_component_get_id (comp);
- g_return_val_if_fail (id != NULL, GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (id != NULL, InvalidObject);
/* fetch full component from cache, it will be pushed to the server */
cache_comp = get_comp_from_cache (cbdav, id->uid, NULL, &href, &etag);
@@ -3358,7 +3333,8 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
g_object_unref (comp);
g_free (href);
g_free (etag);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
}
if (!online) {
@@ -3439,7 +3415,7 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
object.etag = etag;
object.cdata = pack_cobj (cbdav, cache_comp);
- status = caldav_server_put_object (cbdav, &object, cache_comp);
+ did_put = caldav_server_put_object (cbdav, &object, cache_comp, error);
caldav_object_free (&object, FALSE);
href = NULL;
@@ -3449,7 +3425,7 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
/*ecalcomp_set_synch_state (comp, ECALCOMP_LOCALLY_MODIFIED);*/
}
- if (status == GNOME_Evolution_Calendar_Success) {
+ if (did_put) {
if (new_object && !*new_object) {
/* read the comp from cache again, as some servers can modify it on put */
icalcomponent *newcomp = get_comp_from_cache (cbdav, id->uid, NULL, NULL, NULL), *master;
@@ -3472,16 +3448,13 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
g_object_unref (comp);
g_free (href);
g_free (etag);
-
- return status;
}
/* a busy_lock is supposed to be locked already, when calling this function */
-static ECalBackendSyncStatus
-do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid, CalObjModType mod, gchar **old_object, gchar **object)
+static void
+do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid, CalObjModType mod, gchar **old_object, gchar **object, GError **perror)
{
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus status;
icalcomponent *cache_comp;
gboolean online;
gchar *href = NULL, *etag = NULL;
@@ -3491,15 +3464,14 @@ do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid,
if (object)
*object = NULL;
- status = check_state (cbdav, &online);
- if (status != GNOME_Evolution_Calendar_Success) {
- return status;
- }
+ if (!check_state (cbdav, &online, perror))
+ return;
cache_comp = get_comp_from_cache (cbdav, uid, NULL, &href, &etag);
if (cache_comp == NULL) {
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
+ return;
}
if (old_object) {
@@ -3555,9 +3527,9 @@ do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid,
if (mod == CALOBJ_MOD_THIS && rid && *rid) {
caldav_object.cdata = pack_cobj (cbdav, cache_comp);
- status = caldav_server_put_object (cbdav, &caldav_object, cache_comp);
+ caldav_server_put_object (cbdav, &caldav_object, cache_comp, perror);
} else
- status = caldav_server_delete_object (cbdav, &caldav_object);
+ caldav_server_delete_object (cbdav, &caldav_object, perror);
caldav_object_free (&caldav_object, FALSE);
href = NULL;
@@ -3574,30 +3546,30 @@ do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid,
icalcomponent_free (cache_comp);
g_free (href);
g_free (etag);
-
- return status;
}
-static ECalBackendSyncStatus
+static void
extract_objects (icalcomponent *icomp,
icalcomponent_kind ekind,
- GList **objects)
+ GList **objects,
+ GError **error)
{
icalcomponent *scomp;
icalcomponent_kind kind;
- g_return_val_if_fail (icomp, GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (objects, GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (icomp, InvalidArg);
+ e_return_data_cal_error_if_fail (objects, InvalidArg);
kind = icalcomponent_isa (icomp);
if (kind == ekind) {
*objects = g_list_prepend (NULL, icomp);
- return GNOME_Evolution_Calendar_Success;
+ return;
}
if (kind != ICAL_VCALENDAR_COMPONENT) {
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
}
*objects = NULL;
@@ -3611,8 +3583,6 @@ extract_objects (icalcomponent *icomp,
scomp = icalcomponent_get_next_component (icomp, ekind);
}
-
- return GNOME_Evolution_Calendar_Success;
}
static gboolean
@@ -3621,11 +3591,14 @@ extract_timezones (ECalBackendCalDAV *cbdav, icalcomponent *icomp)
ECalBackendCalDAVPrivate *priv;
GList *timezones = NULL, *iter;
icaltimezone *zone;
+ GError *err = NULL;
g_return_val_if_fail (cbdav != NULL, FALSE);
g_return_val_if_fail (icomp != NULL, FALSE);
- if (extract_objects (icomp, ICAL_VTIMEZONE_COMPONENT, &timezones) != GNOME_Evolution_Calendar_Success) {
+ extract_objects (icomp, ICAL_VTIMEZONE_COMPONENT, &timezones, &err);
+ if (err) {
+ g_error_free (err);
return FALSE;
}
@@ -3646,25 +3619,26 @@ extract_timezones (ECalBackendCalDAV *cbdav, icalcomponent *icomp)
return TRUE;
}
-static ECalBackendSyncStatus
+static void
process_object (ECalBackendCalDAV *cbdav,
ECalComponent *ecomp,
gboolean online,
- icalproperty_method method)
+ icalproperty_method method,
+ GError **error)
{
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus status;
ECalBackend *backend;
struct icaltimetype now;
gchar *new_obj_str;
gboolean is_declined, is_in_cache;
CalObjModType mod;
ECalComponentId *id = e_cal_component_get_id (ecomp);
+ GError *err = NULL;
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
backend = E_CAL_BACKEND (cbdav);
- g_return_val_if_fail (id != NULL, GNOME_Evolution_Calendar_InvalidObject);
+ e_return_data_cal_error_if_fail (id != NULL, InvalidObject);
/* ctime, mtime */
now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
@@ -3676,7 +3650,6 @@ process_object (ECalBackendCalDAV *cbdav,
new_obj_str = e_cal_component_get_as_string (ecomp);
mod = e_cal_component_is_instance (ecomp) ? CALOBJ_MOD_THIS : CALOBJ_MOD_ALL;
- status = GNOME_Evolution_Calendar_Success;
switch (method) {
case ICAL_METHOD_PUBLISH:
@@ -3687,8 +3660,8 @@ process_object (ECalBackendCalDAV *cbdav,
if (!is_declined) {
gchar *new_object = NULL, *old_object = NULL;
- status = do_modify_object (cbdav, new_obj_str, mod, &old_object, &new_object);
- if (status == GNOME_Evolution_Calendar_Success) {
+ do_modify_object (cbdav, new_obj_str, mod, &old_object, &new_object, &err);
+ if (!err) {
if (!old_object)
e_cal_backend_notify_object_created (backend, new_object);
else
@@ -3700,8 +3673,8 @@ process_object (ECalBackendCalDAV *cbdav,
} else {
gchar *new_object = NULL, *old_object = NULL;
- status = do_remove_object (cbdav, id->uid, id->rid, mod, &old_object, &new_object);
- if (status == GNOME_Evolution_Calendar_Success) {
+ do_remove_object (cbdav, id->uid, id->rid, mod, &old_object, &new_object, &err);
+ if (!err) {
if (new_object) {
e_cal_backend_notify_object_modified (backend, old_object, new_object);
} else {
@@ -3715,8 +3688,8 @@ process_object (ECalBackendCalDAV *cbdav,
} else if (!is_declined) {
gchar *new_object = new_obj_str;
- status = do_create_object (cbdav, &new_object, NULL);
- if (status == GNOME_Evolution_Calendar_Success) {
+ do_create_object (cbdav, &new_object, NULL, &err);
+ if (!err) {
e_cal_backend_notify_object_created (backend, new_object);
}
@@ -3728,8 +3701,8 @@ process_object (ECalBackendCalDAV *cbdav,
if (is_in_cache) {
gchar *old_object = NULL, *new_object = NULL;
- status = do_remove_object (cbdav, id->uid, id->rid, CALOBJ_MOD_THIS, &old_object, &new_object);
- if (status == GNOME_Evolution_Calendar_Success) {
+ do_remove_object (cbdav, id->uid, id->rid, CALOBJ_MOD_THIS, &old_object, &new_object, &err);
+ if (!err) {
if (new_object) {
e_cal_backend_notify_object_modified (backend, old_object, new_object);
} else {
@@ -3740,55 +3713,56 @@ process_object (ECalBackendCalDAV *cbdav,
g_free (old_object);
g_free (new_object);
} else {
- status = GNOME_Evolution_Calendar_ObjectNotFound;
+ err = EDC_ERROR (ObjectNotFound);
}
break;
default:
- status = GNOME_Evolution_Calendar_UnsupportedMethod;
+ err = EDC_ERROR (UnsupportedMethod);
break;
}
e_cal_component_free_id (id);
g_free (new_obj_str);
- return status;
+ if (err)
+ g_propagate_error (error, err);
}
-static ECalBackendSyncStatus
-do_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj)
+static void
+do_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GError **perror)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus status;
icalcomponent *icomp;
icalcomponent_kind kind;
icalproperty_method tmethod;
gboolean online;
GList *objects;
GList *iter;
+ GError *err = NULL;
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
- status = check_state (cbdav, &online);
- if (status != GNOME_Evolution_Calendar_Success) {
- return status;
- }
+ if (!check_state (cbdav, &online, perror))
+ return;
icomp = icalparser_parse_string (calobj);
/* Try to parse cal object string */
if (icomp == NULL) {
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (perror, EDC_ERROR (InvalidObject));
+ return;
}
kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
- status = extract_objects (icomp, kind, &objects);
+ extract_objects (icomp, kind, &objects, &err);
- if (status != GNOME_Evolution_Calendar_Success) {
+ if (err) {
icalcomponent_free (icomp);
- return status;
+ g_propagate_error (perror, err);
+ return;
}
/* Extract optional timezone compnents */
@@ -3796,7 +3770,7 @@ do_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj
tmethod = icalcomponent_get_method (icomp);
- for (iter = objects; iter && status == GNOME_Evolution_Calendar_Success; iter = iter->next) {
+ for (iter = objects; iter && !err; iter = iter->next) {
icalcomponent *scomp;
ECalComponent *ecomp;
icalproperty_method method;
@@ -3812,7 +3786,7 @@ do_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj
method = tmethod;
}
- status = process_object (cbdav, ecomp, online, method);
+ process_object (cbdav, ecomp, online, method, &err);
g_object_unref (ecomp);
}
@@ -3821,16 +3795,16 @@ do_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj
icalcomponent_free (icomp);
- return status;
+ if (err)
+ g_propagate_error (perror, err);
}
#define caldav_busy_stub(_func_name, _params, _call_func, _call_params) \
-static ECalBackendSyncStatus \
+static void \
_func_name _params \
{ \
ECalBackendCalDAV *cbdav; \
ECalBackendCalDAVPrivate *priv; \
- ECalBackendSyncStatus status; \
SlaveCommand old_slave_cmd; \
gboolean was_slave_busy; \
\
@@ -3846,7 +3820,7 @@ _func_name _params \
} \
\
g_mutex_lock (priv->busy_lock); \
- status = _call_func _call_params; \
+ _call_func _call_params; \
\
/* this is done before unlocking */ \
if (was_slave_busy) { \
@@ -3855,52 +3829,38 @@ _func_name _params \
} \
\
g_mutex_unlock (priv->busy_lock); \
- \
- return status; \
}
caldav_busy_stub (
- caldav_create_object, (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid),
- do_create_object, (cbdav, calobj, uid))
+ caldav_create_object, (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid, GError **perror),
+ do_create_object, (cbdav, calobj, uid, perror))
caldav_busy_stub (
- caldav_modify_object, (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object),
- do_modify_object, (cbdav, calobj, mod, old_object, new_object))
+ caldav_modify_object, (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object, GError **perror),
+ do_modify_object, (cbdav, calobj, mod, old_object, new_object, perror))
caldav_busy_stub (
- caldav_remove_object, (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, CalObjModType mod, gchar **old_object, gchar **object),
- do_remove_object, (cbdav, uid, rid, mod, old_object, object))
+ caldav_remove_object, (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, CalObjModType mod, gchar **old_object, gchar **object, GError **perror),
+ do_remove_object, (cbdav, uid, rid, mod, old_object, object, perror))
caldav_busy_stub (
- caldav_receive_objects, (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj),
- do_receive_objects, (backend, cal, calobj))
-
-static ECalBackendSyncStatus
-caldav_discard_alarm (ECalBackendSync *backend,
- EDataCal *cal,
- const gchar *uid,
- const gchar *auid)
+ caldav_receive_objects, (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GError **perror),
+ do_receive_objects, (backend, cal, calobj, perror))
+
+static void
+caldav_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid, GError **perror)
{
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-caldav_send_objects (ECalBackendSync *backend,
- EDataCal *cal,
- const gchar *calobj,
- GList **users,
- gchar **modified_calobj)
+static void
+caldav_send_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GList **users, gchar **modified_calobj, GError **perror)
{
*users = NULL;
*modified_calobj = g_strdup (calobj);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-caldav_get_default_object (ECalBackendSync *backend,
- EDataCal *cal,
- gchar **object)
+static void
+caldav_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object, GError **perror)
{
ECalComponent *comp;
@@ -3918,21 +3878,16 @@ caldav_get_default_object (ECalBackendSync *backend,
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
-caldav_get_object (ECalBackendSync *backend,
- EDataCal *cal,
- const gchar *uid,
- const gchar *rid,
- gchar **object)
+static void
+caldav_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object, GError **perror)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
@@ -3945,19 +3900,19 @@ caldav_get_object (ECalBackendSync *backend,
icalcomp = get_comp_from_cache (cbdav, uid, rid, NULL, NULL);
if (!icalcomp) {
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
+ return;
}
*object = icalcomponent_as_ical_string_r (icalcomp);
icalcomponent_free (icalcomp);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
caldav_add_timezone (ECalBackendSync *backend,
EDataCal *cal,
- const gchar *tzobj)
+ const gchar *tzobj,
+ GError **error)
{
icalcomponent *tz_comp;
ECalBackendCalDAV *cbdav;
@@ -3965,14 +3920,16 @@ caldav_add_timezone (ECalBackendSync *backend,
cbdav = E_CAL_BACKEND_CALDAV (backend);
- g_return_val_if_fail (E_IS_CAL_BACKEND_CALDAV (cbdav), 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_CALDAV (cbdav), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
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;
@@ -3986,29 +3943,30 @@ caldav_add_timezone (ECalBackendSync *backend,
} else {
icalcomponent_free (tz_comp);
}
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
caldav_set_default_zone (ECalBackendSync *backend,
EDataCal *cal,
- const gchar *tzobj)
+ const gchar *tzobj,
+ GError **error)
{
icalcomponent *tz_comp;
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
icaltimezone *zone;
- g_return_val_if_fail (E_IS_CAL_BACKEND_CALDAV (backend), 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_CALDAV (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
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);
@@ -4018,15 +3976,14 @@ caldav_set_default_zone (ECalBackendSync *backend,
/* Set the default timezone to it. */
priv->default_zone = zone;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
caldav_get_object_list (ECalBackendSync *backend,
EDataCal *cal,
const gchar *sexp_string,
- GList **objects)
+ GList **objects,
+ GError **perror)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
@@ -4041,7 +3998,8 @@ caldav_get_object_list (ECalBackendSync *backend,
sexp = e_cal_backend_sexp_new (sexp_string);
if (sexp == NULL) {
- return GNOME_Evolution_Calendar_InvalidQuery;
+ g_propagate_error (perror, EDC_ERROR (InvalidQuery));
+ return;
}
if (g_str_equal (sexp_string, "#t")) {
@@ -4069,8 +4027,6 @@ caldav_get_object_list (ECalBackendSync *backend,
g_object_unref (sexp);
g_slist_free (list);
-
- return GNOME_Evolution_Calendar_Success;
}
static void
@@ -4119,20 +4075,20 @@ caldav_start_query (ECalBackend *backend,
g_object_unref (sexp);
g_slist_free (list);
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_Success);
+ e_data_cal_view_notify_done (query, NULL /* Success */);
}
-static ECalBackendSyncStatus
+static void
caldav_get_free_busy (ECalBackendSync *backend,
EDataCal *cal,
GList *users,
time_t start,
time_t end,
- GList **freebusy)
+ GList **freebusy,
+ GError **error)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
- ECalBackendSyncStatus status;
icalcomponent *icalcomp;
ECalComponent *comp;
ECalComponentDateTime dt;
@@ -4141,24 +4097,27 @@ caldav_get_free_busy (ECalBackendSync *backend,
gchar *str;
GList *u;
GSList *attendees = NULL, *to_free = NULL;
+ GError *err = NULL;
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
- g_return_val_if_fail (priv != NULL, GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (users != NULL, GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (freebusy != NULL, GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (start < end, GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (priv != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (users != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (freebusy != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (start < end, InvalidArg);
if (!priv->calendar_schedule) {
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (error, EDC_ERROR_EX (OtherError, _("Calendar doesn't support Free/Busy")));
+ return;
}
if (!priv->schedule_outbox_url) {
caldav_receive_schedule_outbox_url (cbdav);
if (!priv->schedule_outbox_url) {
priv->calendar_schedule = FALSE;
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (error, EDC_ERROR_EX (OtherError, "Schedule outbox url not found"));
+ return;
}
}
@@ -4224,11 +4183,11 @@ caldav_get_free_busy (ECalBackendSync *backend,
icalcomponent_free (icalcomp);
g_object_unref (comp);
- g_return_val_if_fail (str != NULL, GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (str != NULL, OtherError);
- status = caldav_post_freebusy (cbdav, priv->schedule_outbox_url, &str);
+ caldav_post_freebusy (cbdav, priv->schedule_outbox_url, &str, &err);
- if (status == GNOME_Evolution_Calendar_Success) {
+ if (!err) {
/* parse returned xml */
xmlDocPtr doc;
@@ -4244,7 +4203,7 @@ caldav_get_free_busy (ECalBackendSync *backend,
result = xpath_eval (xpctx, "/C:schedule-response/C:response");
if (result == NULL || result->type != XPATH_NODESET) {
- status = GNOME_Evolution_Calendar_OtherError;
+ err = EDC_ERROR_EX (OtherError, "Unexpected result in schedule-response");
} else {
gint i, n;
@@ -4257,7 +4216,9 @@ caldav_get_free_busy (ECalBackendSync *backend,
GList *objects = NULL, *o;
icalcomp = icalparser_parse_string (tmp);
- if (icalcomp && extract_objects (icalcomp, ICAL_VFREEBUSY_COMPONENT, &objects) == GNOME_Evolution_Calendar_Success) {
+ if (icalcomp)
+ extract_objects (icalcomp, ICAL_VFREEBUSY_COMPONENT, &objects, &err);
+ if (icalcomp && !err) {
for (o = objects; o; o = o->next) {
gchar *obj_str = icalcomponent_as_ical_string_r (o->data);
@@ -4273,10 +4234,12 @@ caldav_get_free_busy (ECalBackendSync *backend,
if (icalcomp)
icalcomponent_free (icalcomp);
+ if (err)
+ g_error_free (err);
+ err = NULL;
}
g_free (tmp);
-
}
}
@@ -4289,20 +4252,21 @@ caldav_get_free_busy (ECalBackendSync *backend,
g_free (str);
- return status;
+ if (err)
+ g_propagate_error (error, err);
}
-static ECalBackendSyncStatus
+static void
caldav_get_changes (ECalBackendSync *backend,
EDataCal *cal,
const gchar *change_id,
GList **adds,
GList **modifies,
- GList **deletes)
+ GList **deletes,
+ GError **perror)
{
/* FIXME: implement me! */
- g_warning ("function not implemented %s", G_STRFUNC);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR (NotSupported));
}
static gboolean
@@ -4344,7 +4308,7 @@ caldav_set_mode (ECalBackend *backend, CalMode mode)
if (mode != CAL_MODE_REMOTE &&
mode != CAL_MODE_LOCAL) {
e_cal_backend_notify_mode (backend,
- GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
+ ModeNotSupported,
cal_mode_to_corba (mode));
/*g_mutex_unlock (priv->busy_lock);*/
return;
@@ -4353,7 +4317,7 @@ caldav_set_mode (ECalBackend *backend, CalMode mode)
if (priv->mode == mode || !priv->loaded) {
priv->mode = mode;
e_cal_backend_notify_mode (backend,
- GNOME_Evolution_Calendar_CalListener_MODE_SET,
+ ModeSet,
cal_mode_to_corba (mode));
/*g_mutex_unlock (priv->busy_lock);*/
return;
@@ -4371,7 +4335,7 @@ caldav_set_mode (ECalBackend *backend, CalMode mode)
}
e_cal_backend_notify_mode (backend,
- GNOME_Evolution_Calendar_CalListener_MODE_SET,
+ ModeSet,
cal_mode_to_corba (mode));
/*g_mutex_unlock (priv->busy_lock);*/
@@ -4434,7 +4398,7 @@ caldav_source_changed_cb (ESource *source, ECalBackendCalDAV *cbdav)
g_mutex_lock (priv->busy_lock);
}
- initialize_backend (cbdav);
+ initialize_backend (cbdav, NULL);
/* always wakeup thread, even when it was sleeping */
g_cond_signal (priv->cond);
diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c b/calendar/backends/contacts/e-cal-backend-contacts.c
index 49c09a5..6866497 100644
--- a/calendar/backends/contacts/e-cal-backend-contacts.c
+++ b/calendar/backends/contacts/e-cal-backend-contacts.c
@@ -43,6 +43,8 @@
#include "libedataserver/e-source-list.h"
+#define EDC_ERROR(_code) e_data_cal_create_error (_code, NULL)
+
G_DEFINE_TYPE (ECalBackendContacts, e_cal_backend_contacts, E_TYPE_CAL_BACKEND_SYNC)
static ECalBackendSyncClass *parent_class;
@@ -104,7 +106,7 @@ static ECalComponent * create_anniversary (ECalBackendContacts *cbc, EContact *c
static void contacts_changed_cb (EBookView *book_view, const GList *contacts, gpointer user_data);
static void contacts_added_cb (EBookView *book_view, const GList *contacts, gpointer user_data);
static void contacts_removed_cb (EBookView *book_view, const GList *contact_ids, gpointer user_data);
-static ECalBackendSyncStatus e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj);
+static void e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **perror);
static void setup_alarm (ECalBackendContacts *cbc, ECalComponent *comp);
/* BookRecord methods */
@@ -783,110 +785,107 @@ create_anniversary (ECalBackendContacts *cbc, EContact *contact)
/* First the empty stubs */
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_get_cal_address (ECalBackendSync *backend, EDataCal *cal,
- gchar **address)
+ gchar **address, GError **perror)
{
/* A contact backend has no particular email address associated
* with it (although that would be a useful feature some day).
*/
*address = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal,
- gchar **attribute)
+ gchar **attribute, GError **perror)
{
*attribute = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal,
- gchar **address)
+ gchar **address, GError **perror)
{
/* A contact backend has no particular email address associated
* with it (although that would be a useful feature some day).
*/
*address = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal,
- gchar **capabilities)
+ gchar **capabilities, GError **perror)
{
*capabilities = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_contacts_remove (ECalBackendSync *backend, EDataCal *cal)
+static void
+e_cal_backend_contacts_remove (ECalBackendSync *backend, EDataCal *cal, GError **perror)
{
/* WRITE ME */
- return GNOME_Evolution_Calendar_PermissionDenied;
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_get_default_object (ECalBackendSync *backend, EDataCal *cal,
- gchar **object)
+ gchar **object, GError **perror)
{
- return GNOME_Evolution_Calendar_UnsupportedMethod;
+ g_propagate_error (perror, EDC_ERROR (UnsupportedMethod));
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_get_object (ECalBackendSync *backend, EDataCal *cal,
const gchar *uid, const gchar *rid,
- gchar **object)
+ gchar **object, GError **perror)
{
ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (backend);
ECalBackendContactsPrivate *priv = cbc->priv;
ContactRecord *record;
gchar *real_uid;
- if (!uid)
- return GNOME_Evolution_Calendar_ObjectNotFound;
- else if (g_str_has_suffix (uid, ANNIVERSARY_UID_EXT))
+ if (!uid) {
+ g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
+ return;
+ } else if (g_str_has_suffix (uid, ANNIVERSARY_UID_EXT))
real_uid = g_strndup (uid, strlen (uid) - strlen (ANNIVERSARY_UID_EXT));
else if (g_str_has_suffix (uid, BIRTHDAY_UID_EXT))
real_uid = g_strndup (uid, strlen (uid) - strlen (BIRTHDAY_UID_EXT));
- else
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ else {
+ g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
+ return;
+ }
record = g_hash_table_lookup (priv->tracked_contacts, real_uid);
g_free (real_uid);
- if (!record)
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ if (!record) {
+ g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
+ return;
+ }
if (record->comp_birthday && g_str_has_suffix (uid, BIRTHDAY_UID_EXT)) {
*object = e_cal_component_get_as_string (record->comp_birthday);
d(g_message ("Return birthday: %s", *object));
- return GNOME_Evolution_Calendar_Success;
+ return;
}
if (record->comp_anniversary && g_str_has_suffix (uid, ANNIVERSARY_UID_EXT)) {
*object = e_cal_component_get_as_string (record->comp_anniversary);
d(g_message ("Return anniversary: %s", *object));
- return GNOME_Evolution_Calendar_Success;
+ return;
}
d(g_message ("Returning nothing for uid: %s", uid));
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_get_free_busy (ECalBackendSync *backend, EDataCal *cal,
GList *users, time_t start, time_t end,
- GList **freebusy)
+ GList **freebusy, GError **perror)
{
/* Birthdays/anniversaries don't count as busy time */
@@ -915,41 +914,39 @@ e_cal_backend_contacts_get_free_busy (ECalBackendSync *backend, EDataCal *cal,
icalcomponent_free (vfb);
/* WRITE ME */
- return GNOME_Evolution_Calendar_Success;
+ /* Success */
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_get_changes (ECalBackendSync *backend, EDataCal *cal,
const gchar *change_id,
- GList **adds, GList **modifies, GList **deletes)
+ GList **adds, GList **modifies, GList **deletes, GError **perror)
{
/* WRITE ME */
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_discard_alarm (ECalBackendSync *backend, EDataCal *cal,
- const gchar *uid, const gchar *auid)
+ const gchar *uid, const gchar *auid, GError **perror)
{
/* WRITE ME */
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_receive_objects (ECalBackendSync *backend, EDataCal *cal,
- const gchar *calobj)
+ const gchar *calobj, GError **perror)
{
- return GNOME_Evolution_Calendar_PermissionDenied;
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_send_objects (ECalBackendSync *backend, EDataCal *cal,
- const gchar *calobj, GList **users, gchar **modified_calobj)
+ const gchar *calobj, GList **users, gchar **modified_calobj, GError **perror)
{
*users = NULL;
*modified_calobj = NULL;
/* TODO: Investigate this */
- return GNOME_Evolution_Calendar_PermissionDenied;
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
/* Then the real implementations */
@@ -963,19 +960,14 @@ e_cal_backend_contacts_get_mode (ECalBackend *backend)
static void
e_cal_backend_contacts_set_mode (ECalBackend *backend, CalMode mode)
{
- e_cal_backend_notify_mode (backend,
- GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
- GNOME_Evolution_Calendar_MODE_LOCAL);
-
+ e_cal_backend_notify_mode (backend, ModeNotSupported, Local);
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_is_read_only (ECalBackendSync *backend, EDataCal *cal,
- gboolean *read_only)
+ gboolean *read_only, GError **perror)
{
*read_only = TRUE;
-
- return GNOME_Evolution_Calendar_Success;
}
static gpointer
@@ -1005,17 +997,17 @@ init_sources_cb (ECalBackendContacts *cbc)
return NULL;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_open (ECalBackendSync *backend, EDataCal *cal,
gboolean only_if_exists,
- const gchar *username, const gchar *password)
+ const gchar *username, const gchar *password, GError **perror)
{
ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (backend);
ECalBackendContactsPrivate *priv = cbc->priv;
GError *error = NULL;
if (priv->addressbook_loaded)
- return GNOME_Evolution_Calendar_Success;
+ return;
if (priv->default_zone && priv->default_zone != icaltimezone_get_utc_timezone ()) {
icalcomponent *icalcomp = icaltimezone_get_component (priv->default_zone);
@@ -1033,12 +1025,11 @@ e_cal_backend_contacts_open (ECalBackendSync *backend, EDataCal *cal,
if (error)
g_error_free (error);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR (OtherError));
+ return;
}
priv->addressbook_loaded = TRUE;
-
- return GNOME_Evolution_Calendar_Success;
}
static gboolean
@@ -1051,8 +1042,8 @@ e_cal_backend_contacts_is_loaded (ECalBackend *backend)
}
/* Add_timezone handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
ECalBackendContacts *cbcontacts;
ECalBackendContactsPrivate *priv;
@@ -1062,17 +1053,21 @@ e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, EDataCal *cal, co
cbcontacts = (ECalBackendContacts *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_CONTACTS (cbcontacts), 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_CONTACTS (cbcontacts), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbcontacts->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)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (icalcomponent_isa (tz_comp) != ICAL_VTIMEZONE_COMPONENT) {
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
+ }
zone = icaltimezone_new ();
icaltimezone_set_component (zone, tz_comp);
@@ -1080,17 +1075,13 @@ e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, EDataCal *cal, co
if (g_hash_table_lookup (priv->zones, tzid)) {
icaltimezone_free (zone, TRUE);
-
- return GNOME_Evolution_Calendar_Success;
+ } else {
+ g_hash_table_insert (priv->zones, g_strdup (tzid), zone);
}
-
- g_hash_table_insert (priv->zones, g_strdup (tzid), zone);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_contacts_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_contacts_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
icalcomponent *tz_comp;
ECalBackendContacts *cbcontacts;
@@ -1099,14 +1090,16 @@ e_cal_backend_contacts_set_default_zone (ECalBackendSync *backend, EDataCal *cal
cbcontacts = (ECalBackendContacts *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_CONTACTS (cbcontacts), 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_CONTACTS (cbcontacts), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbcontacts->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);
@@ -1116,21 +1109,21 @@ e_cal_backend_contacts_set_default_zone (ECalBackendSync *backend, EDataCal *cal
/* Set the default timezone to it. */
priv->default_zone = zone;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_contacts_get_object_list (ECalBackendSync *backend, EDataCal *cal,
- const gchar *sexp_string, GList **objects)
+ const gchar *sexp_string, GList **objects, GError **perror)
{
ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (backend);
ECalBackendContactsPrivate *priv = cbc->priv;
ECalBackendSExp *sexp = e_cal_backend_sexp_new (sexp_string);
ContactRecordCB *cb_data;
- if (!sexp)
- return GNOME_Evolution_Calendar_InvalidQuery;
+ if (!sexp) {
+ g_propagate_error (perror, EDC_ERROR (InvalidQuery));
+ return;
+ }
cb_data = contact_record_cb_new (cbc, sexp);
g_hash_table_foreach (priv->tracked_contacts, contact_record_cb, cb_data);
@@ -1139,8 +1132,6 @@ e_cal_backend_contacts_get_object_list (ECalBackendSync *backend, EDataCal *cal,
/* Don't call cb_data_free as that would destroy the results
* in *objects */
g_free (cb_data);
-
- return GNOME_Evolution_Calendar_Success;
}
static void
@@ -1153,7 +1144,9 @@ e_cal_backend_contacts_start_query (ECalBackend *backend, EDataCalView *query)
sexp = e_data_cal_view_get_object_sexp (query);
if (!sexp) {
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_InvalidQuery);
+ GError *error = EDC_ERROR (InvalidQuery);
+ e_data_cal_view_notify_done (query, error);
+ g_error_free (error);
return;
}
@@ -1164,7 +1157,7 @@ e_cal_backend_contacts_start_query (ECalBackend *backend, EDataCalView *query)
contact_record_cb_free (cb_data);
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_Success);
+ e_data_cal_view_notify_done (query, NULL /* Success */);
}
static icaltimezone *
@@ -1273,8 +1266,8 @@ e_cal_backend_contacts_init (ECalBackendContacts *cbc)
e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbc), TRUE);
}
-static ECalBackendSyncStatus
-e_cal_backend_contacts_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid)
+static void
+e_cal_backend_contacts_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid, GError **perror)
{
ECalBackendContacts *cbcontacts;
ECalBackendContactsPrivate *priv;
@@ -1282,7 +1275,7 @@ e_cal_backend_contacts_create_object (ECalBackendSync *backend, EDataCal *cal, g
cbcontacts = E_CAL_BACKEND_CONTACTS (backend);
priv = cbcontacts->priv;
- return GNOME_Evolution_Calendar_PermissionDenied;
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
/* Class initialization function for the contacts backend */
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index f40d0d2..b5e0035 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -45,6 +45,9 @@
#define O_BINARY 0
#endif
+#define EDC_ERROR(_code) e_data_cal_create_error (_code, NULL)
+#define EDC_ERROR_NO_URI() e_data_cal_create_error (OtherError, "Cannot get URI")
+
G_DEFINE_TYPE (ECalBackendFile, e_cal_backend_file, E_TYPE_CAL_BACKEND_SYNC)
/* Placeholder for each component and its recurrences */
@@ -118,8 +121,8 @@ static void e_cal_backend_file_finalize (GObject *object);
static ECalBackendSyncClass *parent_class;
-static ECalBackendSyncStatus
-e_cal_backend_file_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj);
+static void
+e_cal_backend_file_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **perror);
static void free_refresh_data (ECalBackendFile *cbfile);
@@ -389,56 +392,46 @@ lookup_component (ECalBackendFile *cbfile, const gchar *uid)
/* Calendar backend methods */
/* Is_read_only handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_file_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
+static void
+e_cal_backend_file_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only, GError **perror)
{
ECalBackendFile *cbfile = (ECalBackendFile *) backend;
*read_only = cbfile->priv->read_only;
-
- return GNOME_Evolution_Calendar_Success;
}
/* Get_email_address handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_file_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+static void
+e_cal_backend_file_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
{
/* A file backend has no particular email address associated
* with it (although that would be a useful feature some day).
*/
*address = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_file_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute)
+static void
+e_cal_backend_file_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute, GError **perror)
{
*attribute = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_file_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+static void
+e_cal_backend_file_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
{
/* A file backend has no particular email address associated
* with it (although that would be a useful feature some day).
*/
*address = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_file_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities)
+static void
+e_cal_backend_file_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities, GError **perror)
{
*capabilities = g_strdup (CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS ","
CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
CAL_STATIC_CAPABILITY_DELEGATE_SUPPORTED ","
CAL_STATIC_CAPABILITY_NO_THISANDPRIOR);
-
- return GNOME_Evolution_Calendar_Success;
}
/* function to resolve timezones */
@@ -784,7 +777,7 @@ refresh_thread_func (gpointer data)
if (modified != last_modified) {
last_modified = modified;
- e_cal_backend_file_reload (cbfile);
+ e_cal_backend_file_reload (cbfile, NULL);
}
}
@@ -904,8 +897,8 @@ free_refresh_data (ECalBackendFile *cbfile)
}
/* Parses an open iCalendar file and loads it into the backend */
-static ECalBackendSyncStatus
-open_cal (ECalBackendFile *cbfile, const gchar *uristr)
+static void
+open_cal (ECalBackendFile *cbfile, const gchar *uristr, GError **perror)
{
ECalBackendFilePrivate *priv;
icalcomponent *icalcomp;
@@ -915,8 +908,10 @@ open_cal (ECalBackendFile *cbfile, const gchar *uristr)
free_refresh_data (cbfile);
icalcomp = e_cal_util_parse_ics_file (uristr);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_OtherError;
+ if (!icalcomp) {
+ g_propagate_error (perror, e_data_cal_create_error_fmt (OtherError, "Cannot parse ISC file '%s'", uristr));
+ return;
+ }
/* FIXME: should we try to demangle XROOT components and
* individual components as well?
@@ -925,7 +920,8 @@ open_cal (ECalBackendFile *cbfile, const gchar *uristr)
if (icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) {
icalcomponent_free (icalcomp);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, e_data_cal_create_error_fmt (OtherError, "File '%s' is not v VCALENDAR component", uristr));
+ return;
}
priv->icalcomp = icalcomp;
@@ -937,8 +933,6 @@ open_cal (ECalBackendFile *cbfile, const gchar *uristr)
scan_vcalendar (cbfile);
prepare_refresh_data (cbfile);
-
- return GNOME_Evolution_Calendar_Success;
}
typedef struct
@@ -1042,8 +1036,8 @@ notify_changes (ECalBackendFile *cbfile, GHashTable *old_uid_hash, GHashTable *n
g_hash_table_foreach (new_uid_hash, (GHFunc) notify_adds_modifies_cb, &context);
}
-static ECalBackendSyncStatus
-reload_cal (ECalBackendFile *cbfile, const gchar *uristr)
+static void
+reload_cal (ECalBackendFile *cbfile, const gchar *uristr, GError **perror)
{
ECalBackendFilePrivate *priv;
icalcomponent *icalcomp, *icalcomp_old;
@@ -1052,8 +1046,10 @@ reload_cal (ECalBackendFile *cbfile, const gchar *uristr)
priv = cbfile->priv;
icalcomp = e_cal_util_parse_ics_file (uristr);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_OtherError;
+ if (!icalcomp) {
+ g_propagate_error (perror, e_data_cal_create_error_fmt (OtherError, "Cannot parse ISC file '%s'", uristr));
+ return;
+ }
/* FIXME: should we try to demangle XROOT components and
* individual components as well?
@@ -1062,7 +1058,8 @@ reload_cal (ECalBackendFile *cbfile, const gchar *uristr)
if (icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) {
icalcomponent_free (icalcomp);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, e_data_cal_create_error_fmt (OtherError, "File '%s' is not v VCALENDAR component", uristr));
+ return;
}
/* Keep old data for comparison - free later */
@@ -1091,11 +1088,10 @@ reload_cal (ECalBackendFile *cbfile, const gchar *uristr)
/* Free old data */
free_calendar_components (comp_uid_hash_old, icalcomp_old);
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-create_cal (ECalBackendFile *cbfile, const gchar *uristr)
+static void
+create_cal (ECalBackendFile *cbfile, const gchar *uristr, GError **perror)
{
gchar *dirname;
ECalBackendFilePrivate *priv;
@@ -1108,7 +1104,8 @@ create_cal (ECalBackendFile *cbfile, const gchar *uristr)
dirname = g_path_get_dirname (uristr);
if (g_mkdir_with_parents (dirname, 0700) != 0) {
g_free (dirname);
- return GNOME_Evolution_Calendar_NoSuchCal;
+ g_propagate_error (perror, EDC_ERROR (NoSuchCal));
+ return;
}
g_free (dirname);
@@ -1126,8 +1123,6 @@ create_cal (ECalBackendFile *cbfile, const gchar *uristr)
g_free (priv->custom_file);
priv->custom_file = g_strdup (uristr);
prepare_refresh_data (cbfile);
-
- return GNOME_Evolution_Calendar_Success;
}
static gchar *
@@ -1278,14 +1273,14 @@ source_changed_cb (ESource *source, ECalBackend *backend)
}
/* Open handler for the file backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_file_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
- const gchar *username, const gchar *password)
+ const gchar *username, const gchar *password, GError **perror)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
gchar *str_uri;
- ECalBackendSyncStatus status;
+ GError *err = NULL;
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
@@ -1293,29 +1288,29 @@ e_cal_backend_file_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
/* Claim a succesful open if we are already open */
if (priv->path && priv->comp_uid_hash) {
- status = GNOME_Evolution_Calendar_Success;
+ /* Success */
goto done;
}
str_uri = get_uri_string (E_CAL_BACKEND (backend));
if (!str_uri) {
- status = GNOME_Evolution_Calendar_OtherError;
+ err = EDC_ERROR_NO_URI ();
goto done;
}
priv->read_only = FALSE;
if (g_access (str_uri, R_OK) == 0) {
- status = open_cal (cbfile, str_uri);
+ open_cal (cbfile, str_uri, &err);
if (g_access (str_uri, W_OK) != 0)
priv->read_only = TRUE;
} else {
if (only_if_exists)
- status = GNOME_Evolution_Calendar_NoSuchCal;
+ err = EDC_ERROR (NoSuchCal);
else
- status = create_cal (cbfile, str_uri);
+ create_cal (cbfile, str_uri, &err);
}
- if (status == GNOME_Evolution_Calendar_Success) {
+ if (!err) {
if (!priv->read_only) {
ESource *source = e_cal_backend_get_source (E_CAL_BACKEND (backend));
@@ -1336,11 +1331,13 @@ e_cal_backend_file_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
done:
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return status;
+
+ if (err)
+ g_propagate_error (perror, err);
}
-static ECalBackendSyncStatus
-e_cal_backend_file_remove (ECalBackendSync *backend, EDataCal *cal)
+static void
+e_cal_backend_file_remove (ECalBackendSync *backend, EDataCal *cal, GError **perror)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
@@ -1348,8 +1345,7 @@ e_cal_backend_file_remove (ECalBackendSync *backend, EDataCal *cal)
gchar *full_path = NULL;
const gchar *fname;
GDir *dir = NULL;
- GError *error = NULL;
- ECalBackendSyncStatus status = GNOME_Evolution_Calendar_Success;
+ GError *error = NULL, *err = NULL;
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
@@ -1357,12 +1353,12 @@ e_cal_backend_file_remove (ECalBackendSync *backend, EDataCal *cal)
str_uri = get_uri_string (E_CAL_BACKEND (backend));
if (!str_uri) {
- status = GNOME_Evolution_Calendar_OtherError;
+ err = EDC_ERROR_NO_URI ();
goto done;
}
if (g_access (str_uri, W_OK) != 0) {
- status = GNOME_Evolution_Calendar_PermissionDenied;
+ err = EDC_ERROR (PermissionDenied);
goto done;
}
@@ -1370,14 +1366,14 @@ e_cal_backend_file_remove (ECalBackendSync *backend, EDataCal *cal)
dirname = g_path_get_dirname (str_uri);
dir = g_dir_open (dirname, 0, &error);
if (!dir) {
- status = GNOME_Evolution_Calendar_PermissionDenied;
+ err = e_data_cal_create_error (PermissionDenied, error ? error->message : NULL);
goto done;
}
while ((fname = g_dir_read_name (dir))) {
full_path = g_build_filename (dirname, fname, NULL);
if (g_unlink (full_path) != 0) {
- status = GNOME_Evolution_Calendar_OtherError;
+ err = EDC_ERROR (OtherError);
goto done;
}
@@ -1387,7 +1383,7 @@ e_cal_backend_file_remove (ECalBackendSync *backend, EDataCal *cal)
/* remove the directory itself */
if (g_rmdir (dirname) != 0) {
- status = GNOME_Evolution_Calendar_OtherError;
+ err = EDC_ERROR (OtherError);
}
done:
@@ -1401,10 +1397,13 @@ e_cal_backend_file_remove (ECalBackendSync *backend, EDataCal *cal)
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
/* lie here a bit, but otherwise the calendar will not be removed, even it should */
- if (status != GNOME_Evolution_Calendar_Success)
- g_print (G_STRLOC ": %s", e_cal_backend_status_to_string (status));
+ if (err) {
+ g_print (G_STRLOC ": %s", err->message);
+ g_error_free (err);
+ }
- return GNOME_Evolution_Calendar_Success;
+ if (error)
+ g_error_free (error);
}
/* is_loaded handler for the file backend */
@@ -1437,14 +1436,12 @@ e_cal_backend_file_get_mode (ECalBackend *backend)
static void
e_cal_backend_file_set_mode (ECalBackend *backend, CalMode mode)
{
- e_cal_backend_notify_mode (backend,
- GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
- GNOME_Evolution_Calendar_MODE_LOCAL);
+ e_cal_backend_notify_mode (backend, ModeNotSupported, Local);
}
-static ECalBackendSyncStatus
-e_cal_backend_file_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object)
+static void
+e_cal_backend_file_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object, GError **perror)
{
ECalComponent *comp;
@@ -1462,13 +1459,12 @@ e_cal_backend_file_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 void
@@ -1483,8 +1479,8 @@ add_detached_recur_to_vcalendar (gpointer key, gpointer value, gpointer user_dat
}
/* Get_object_component handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_file_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object)
+static void
+e_cal_backend_file_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object, GError **error)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
@@ -1493,8 +1489,8 @@ e_cal_backend_file_get_object (ECalBackendSync *backend, EDataCal *cal, const gc
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
- g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_InvalidObject);
- g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
+ e_return_data_cal_error_if_fail (priv->icalcomp != NULL, InvalidObject);
+ e_return_data_cal_error_if_fail (uid != NULL, ObjectNotFound);
g_assert (priv->comp_uid_hash != NULL);
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
@@ -1502,7 +1498,8 @@ e_cal_backend_file_get_object (ECalBackendSync *backend, EDataCal *cal, const gc
obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid);
if (!obj_data) {
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
}
if (rid && *rid) {
@@ -1517,7 +1514,8 @@ e_cal_backend_file_get_object (ECalBackendSync *backend, EDataCal *cal, const gc
if (!obj_data->full_object) {
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
}
itt = icaltime_from_string (rid);
@@ -1526,7 +1524,8 @@ e_cal_backend_file_get_object (ECalBackendSync *backend, EDataCal *cal, const gc
itt);
if (!icalcomp) {
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
}
*object = icalcomponent_as_ical_string_r (icalcomp);
@@ -1557,12 +1556,11 @@ e_cal_backend_file_get_object (ECalBackendSync *backend, EDataCal *cal, const gc
}
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_Success;
}
/* Add_timezone handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_file_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_file_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
icalcomponent *tz_comp;
ECalBackendFile *cbfile;
@@ -1570,14 +1568,16 @@ e_cal_backend_file_add_timezone (ECalBackendSync *backend, EDataCal *cal, const
cbfile = (ECalBackendFile *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_FILE (cbfile), 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_FILE (cbfile), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbfile->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;
@@ -1595,12 +1595,10 @@ e_cal_backend_file_add_timezone (ECalBackendSync *backend, EDataCal *cal, const
icaltimezone_free (zone, 1);
}
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_file_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_file_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
icalcomponent *tz_comp;
ECalBackendFile *cbfile;
@@ -1609,14 +1607,16 @@ e_cal_backend_file_set_default_zone (ECalBackendSync *backend, EDataCal *cal, co
cbfile = (ECalBackendFile *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_FILE (cbfile), 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_FILE (cbfile), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbfile->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);
@@ -1628,8 +1628,6 @@ e_cal_backend_file_set_default_zone (ECalBackendSync *backend, EDataCal *cal, co
/* Set the default timezone to it. */
priv->default_zone = zone;
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
-
- return GNOME_Evolution_Calendar_Success;
}
typedef struct {
@@ -1675,8 +1673,8 @@ match_object_sexp (gpointer key, gpointer value, gpointer data)
}
/* Get_objects_in_range handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_file_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects)
+static void
+e_cal_backend_file_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects, GError **perror)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
@@ -1697,8 +1695,10 @@ e_cal_backend_file_get_object_list (ECalBackendSync *backend, EDataCal *cal, con
match_data.search_needed = FALSE;
match_data.obj_sexp = e_cal_backend_sexp_new (sexp);
- if (!match_data.obj_sexp)
- return GNOME_Evolution_Calendar_InvalidQuery;
+ if (!match_data.obj_sexp) {
+ g_propagate_error (perror, EDC_ERROR (InvalidQuery));
+ return;
+ }
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
g_hash_table_foreach (priv->comp_uid_hash, (GHFunc) match_object_sexp, &match_data);
@@ -1707,17 +1707,14 @@ e_cal_backend_file_get_object_list (ECalBackendSync *backend, EDataCal *cal, con
*objects = match_data.obj_list;
g_object_unref (match_data.obj_sexp);
-
- return GNOME_Evolution_Calendar_Success;
}
/* Gets the list of attachments */
-static ECalBackendSyncStatus
-e_cal_backend_file_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, GSList **list)
+static void
+e_cal_backend_file_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;
}
/* get_query handler for the file backend */
@@ -1745,7 +1742,9 @@ e_cal_backend_file_start_query (ECalBackend *backend, EDataCalView *query)
match_data.obj_sexp = e_data_cal_view_get_object_sexp (query);
if (!match_data.obj_sexp) {
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_InvalidQuery);
+ GError *error = EDC_ERROR (InvalidQuery);
+ e_data_cal_view_notify_done (query, error);
+ g_error_free (error);
return;
}
@@ -1763,7 +1762,7 @@ e_cal_backend_file_start_query (ECalBackend *backend, EDataCalView *query)
}
g_object_unref (match_data.obj_sexp);
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_Success);
+ e_data_cal_view_notify_done (query, NULL /* Success */);
}
static gboolean
@@ -1876,9 +1875,9 @@ create_user_free_busy (ECalBackendFile *cbfile, const gchar *address, const gcha
}
/* Get_free_busy handler for the file backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_file_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users,
- time_t start, time_t end, GList **freebusy)
+ time_t start, time_t end, GList **freebusy, GError **error)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
@@ -1890,9 +1889,9 @@ e_cal_backend_file_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
- g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal);
- g_return_val_if_fail (start != -1 && end != -1, GNOME_Evolution_Calendar_InvalidRange);
- g_return_val_if_fail (start <= end, GNOME_Evolution_Calendar_InvalidRange);
+ e_return_data_cal_error_if_fail (priv->icalcomp != NULL, NoSuchCal);
+ e_return_data_cal_error_if_fail (start != -1 && end != -1, InvalidRange);
+ e_return_data_cal_error_if_fail (start <= end, InvalidRange);
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
@@ -1921,8 +1920,6 @@ e_cal_backend_file_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList
}
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
-
- return GNOME_Evolution_Calendar_Success;
}
typedef struct
@@ -1956,9 +1953,9 @@ e_cal_backend_file_compute_changes_foreach_key (const gchar *key, gpointer value
return FALSE;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_file_compute_changes (ECalBackendFile *cbfile, const gchar *change_id,
- GList **adds, GList **modifies, GList **deletes)
+ GList **adds, GList **modifies, GList **deletes, GError **perror)
{
ECalBackendFilePrivate *priv;
gchar *filename;
@@ -1975,7 +1972,8 @@ e_cal_backend_file_compute_changes (ECalBackendFile *cbfile, const gchar *change
g_free (unescaped_uri);
if (!(ehash = e_xmlhash_new (filename))) {
g_free (filename);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR (OtherError));
+ return;
}
g_free (filename);
@@ -2023,13 +2021,12 @@ e_cal_backend_file_compute_changes (ECalBackendFile *cbfile, const gchar *change
e_xmlhash_destroy (ehash);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_Success;
}
/* Get_changes handler for the file backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_file_get_changes (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id,
- GList **adds, GList **modifies, GList **deletes)
+ GList **adds, GList **modifies, GList **deletes, GError **error)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
@@ -2037,18 +2034,17 @@ e_cal_backend_file_get_changes (ECalBackendSync *backend, EDataCal *cal, const g
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
- g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal);
- g_return_val_if_fail (change_id != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
+ e_return_data_cal_error_if_fail (priv->icalcomp != NULL, NoSuchCal);
+ e_return_data_cal_error_if_fail (change_id != NULL, ObjectNotFound);
- return e_cal_backend_file_compute_changes (cbfile, change_id, adds, modifies, deletes);
+ e_cal_backend_file_compute_changes (cbfile, change_id, adds, modifies, deletes, error);
}
/* Discard_alarm handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_file_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid)
+static void
+e_cal_backend_file_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid, GError **perror)
{
/* we just do nothing with the alarm */
- return GNOME_Evolution_Calendar_Success;
}
static icaltimezone *
@@ -2140,8 +2136,8 @@ sanitize_component (ECalBackendFile *cbfile, ECalComponent *comp)
}
-static ECalBackendSyncStatus
-e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid)
+static void
+e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid, GError **error)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
@@ -2153,18 +2149,21 @@ e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, gchar
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
- g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal);
- g_return_val_if_fail (*calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
+ e_return_data_cal_error_if_fail (priv->icalcomp != NULL, NoSuchCal);
+ e_return_data_cal_error_if_fail (*calobj != NULL, ObjectNotFound);
/* Parse the icalendar text */
icalcomp = icalparser_parse_string (*calobj);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (!icalcomp) {
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
+ }
/* Check kind with the parent */
if (icalcomponent_isa (icalcomp) != e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
icalcomponent_free (icalcomp);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
}
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
@@ -2178,7 +2177,8 @@ e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, gchar
if (!new_uid) {
icalcomponent_free (icalcomp);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
}
icalcomponent_set_uid (icalcomp, new_uid);
@@ -2191,7 +2191,8 @@ e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, gchar
if (lookup_component (cbfile, comp_uid)) {
icalcomponent_free (icalcomp);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_ObjectIdAlreadyExists;
+ g_propagate_error (error, EDC_ERROR (ObjectIdAlreadyExists));
+ return;
}
/* Create the cal component */
@@ -2218,7 +2219,6 @@ e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, gchar
*calobj = e_cal_component_get_as_string (comp);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_Success;
}
typedef struct {
@@ -2255,9 +2255,9 @@ remove_object_instance_cb (gpointer key, gpointer value, gpointer user_data)
return FALSE;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_file_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)
{
RemoveRecurrenceData rrdata;
ECalBackendFile *cbfile;
@@ -2274,18 +2274,21 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, const
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
- g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal);
- g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
+ e_return_data_cal_error_if_fail (priv->icalcomp != NULL, NoSuchCal);
+ e_return_data_cal_error_if_fail (calobj != NULL, ObjectNotFound);
/* Parse the icalendar text */
icalcomp = icalparser_parse_string ((gchar *) calobj);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (!icalcomp) {
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
+ }
/* Check kind with the parent */
if (icalcomponent_isa (icalcomp) != e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
icalcomponent_free (icalcomp);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
}
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
@@ -2297,7 +2300,8 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, const
if (!(obj_data = g_hash_table_lookup (priv->comp_uid_hash, comp_uid))) {
icalcomponent_free (icalcomp);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
}
/* Create the cal component */
@@ -2342,7 +2346,7 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, const
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
g_free (rid);
- return GNOME_Evolution_Calendar_Success;
+ return;
}
if (g_hash_table_lookup_extended (obj_data->recurrences, rid, (gpointer *)&real_rid, (gpointer *)&recurrence)) {
@@ -2479,7 +2483,6 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, const
*new_object = e_cal_component_get_as_string (comp);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_Success;
}
static void
@@ -2550,11 +2553,11 @@ get_object_string_from_fileobject (ECalBackendFileObject *obj_data, const gchar
}
/* Remove_object handler for the file backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal,
const gchar *uid, const gchar *rid,
CalObjModType mod, gchar **old_object,
- gchar **object)
+ gchar **object, GError **error)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
@@ -2566,8 +2569,8 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal,
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
- g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal);
- g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
+ e_return_data_cal_error_if_fail (priv->icalcomp != NULL, NoSuchCal);
+ e_return_data_cal_error_if_fail (uid != NULL, ObjectNotFound);
*old_object = *object = NULL;
@@ -2576,7 +2579,8 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal,
obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid);
if (!obj_data) {
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
}
if (rid && *rid)
@@ -2608,7 +2612,8 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal,
case CALOBJ_MOD_THISANDFUTURE :
if (!recur_id || !*recur_id) {
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
}
if (comp) {
@@ -2644,7 +2649,6 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal,
save (cbfile);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return GNOME_Evolution_Calendar_Success;
}
static gboolean
@@ -2772,8 +2776,8 @@ fetch_attachments (ECalBackendSync *backend, ECalComponent *comp)
}
/* Update_objects handler for the file backend. */
-static ECalBackendSyncStatus
-e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj)
+static void
+e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GError **error)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
@@ -2785,18 +2789,20 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
ECalComponent *comp;
struct icaltimetype current;
ECalBackendFileTzidData tzdata;
- ECalBackendSyncStatus status = GNOME_Evolution_Calendar_Success;
+ GError *err = NULL;
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
- g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_InvalidObject);
- g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_InvalidObject);
+ e_return_data_cal_error_if_fail (priv->icalcomp != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (calobj != NULL, InvalidObject);
/* Pull the component from the string and ensure that it is sane */
toplevel_comp = icalparser_parse_string ((gchar *) calobj);
- if (!toplevel_comp)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (!toplevel_comp) {
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
+ }
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
@@ -2852,7 +2858,7 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
icalcomponent_foreach_tzid (subcomp, check_tzids, &tzdata);
if (!tzdata.found) {
- status = GNOME_Evolution_Calendar_InvalidObject;
+ err = EDC_ERROR (InvalidObject);
goto error;
}
@@ -2865,7 +2871,7 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
icalcomponent_set_uid (subcomp, new_uid);
g_free (new_uid);
} else {
- status = GNOME_Evolution_Calendar_InvalidObject;
+ err = EDC_ERROR (InvalidObject);
goto error;
}
@@ -2949,17 +2955,17 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
break;
case ICAL_METHOD_ADD:
/* FIXME This should be doable once all the recurid stuff is done */
- status = GNOME_Evolution_Calendar_UnsupportedMethod;
+ err = EDC_ERROR (UnsupportedMethod);
g_free (rid);
goto error;
break;
case ICAL_METHOD_COUNTER:
- status = GNOME_Evolution_Calendar_UnsupportedMethod;
+ err = EDC_ERROR (UnsupportedMethod);
g_free (rid);
goto error;
break;
case ICAL_METHOD_DECLINECOUNTER:
- status = GNOME_Evolution_Calendar_UnsupportedMethod;
+ err = EDC_ERROR (UnsupportedMethod);
g_free (rid);
goto error;
break;
@@ -2984,7 +2990,7 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
g_free (rid);
break;
default:
- status = GNOME_Evolution_Calendar_UnsupportedMethod;
+ err = EDC_ERROR (UnsupportedMethod);
g_free (rid);
goto error;
}
@@ -3003,13 +3009,12 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
g_list_free (del_comps);
/* check and patch timezones */
- {
- GError *error = NULL;
+ if (!err) {
if (!e_cal_check_timezones(toplevel_comp,
NULL,
e_cal_tzlookup_icomp,
priv->icalcomp,
- &error)) {
+ &err)) {
/*
* This makes assumptions about what kind of
* errors can occur inside e_cal_check_timezones().
@@ -3017,8 +3022,6 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
* is the code really identical with the calendar
* status?
*/
- status = error->code;
- g_clear_error(&error);
goto error;
}
}
@@ -3032,17 +3035,17 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
error:
g_hash_table_destroy (tzdata.zones);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return status;
+
+ if (err)
+ g_propagate_error (error, err);
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_file_send_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GList **users,
- gchar **modified_calobj)
+ gchar **modified_calobj, GError **perror)
{
*users = NULL;
*modified_calobj = g_strdup (calobj);
-
- return GNOME_Evolution_Calendar_Success;
}
/* Object initialization function for the file backend */
@@ -3157,33 +3160,33 @@ e_cal_backend_file_get_file_name (ECalBackendFile *cbfile)
return priv->file_name;
}
-ECalBackendSyncStatus
-e_cal_backend_file_reload (ECalBackendFile *cbfile)
+void
+e_cal_backend_file_reload (ECalBackendFile *cbfile, GError **perror)
{
ECalBackendFilePrivate *priv;
gchar *str_uri;
- ECalBackendSyncStatus status;
+ GError *err = NULL;
priv = cbfile->priv;
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
str_uri = get_uri_string (E_CAL_BACKEND (cbfile));
if (!str_uri) {
- status = GNOME_Evolution_Calendar_OtherError;
+ err = EDC_ERROR_NO_URI ();
goto done;
}
if (g_access (str_uri, R_OK) == 0) {
- status = reload_cal (cbfile, str_uri);
+ reload_cal (cbfile, str_uri, &err);
if (g_access (str_uri, W_OK) != 0)
priv->read_only = TRUE;
} else {
- status = GNOME_Evolution_Calendar_NoSuchCal;
+ err = EDC_ERROR (NoSuchCal);
}
g_free (str_uri);
- if (status == GNOME_Evolution_Calendar_Success && !priv->read_only) {
+ if (!err && !priv->read_only) {
ESource *source = e_cal_backend_get_source (E_CAL_BACKEND (cbfile));
if (source && e_source_get_property (source, "custom-file-readonly") && g_str_equal (e_source_get_property (source, "custom-file-readonly"), "1"))
@@ -3191,5 +3194,7 @@ e_cal_backend_file_reload (ECalBackendFile *cbfile)
}
done:
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- return status;
+
+ if (err)
+ g_propagate_error (perror, err);
}
diff --git a/calendar/backends/file/e-cal-backend-file.h b/calendar/backends/file/e-cal-backend-file.h
index ded7f12..68a7773 100644
--- a/calendar/backends/file/e-cal-backend-file.h
+++ b/calendar/backends/file/e-cal-backend-file.h
@@ -57,7 +57,7 @@ void e_cal_backend_file_set_file_name (ECalBackendFile *cbfile
const gchar *file_name);
const gchar *e_cal_backend_file_get_file_name (ECalBackendFile *cbfile);
-ECalBackendSyncStatus e_cal_backend_file_reload (ECalBackendFile *cbfile);
+void e_cal_backend_file_reload (ECalBackendFile *cbfile, GError **error);
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise.c b/calendar/backends/groupwise/e-cal-backend-groupwise.c
index 9350a33..a6959f3 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise.c
@@ -61,6 +61,10 @@
#define SERVER_UTC_TIME "server_utc_time"
#define CACHE_MARKER "populated"
+#define EDC_ERROR(_code) e_data_cal_create_error (_code, NULL)
+#define EDC_ERROR_EX(_code, _msg) e_data_cal_create_error (_code, _msg)
+#define EDC_ERROR_FAILED_STATUS(_code, _status) e_data_cal_create_error_fmt (_code, "Failed with status 0x%x", _status)
+
G_DEFINE_TYPE (ECalBackendGroupwise, e_cal_backend_groupwise, E_TYPE_CAL_BACKEND_SYNC)
typedef struct {
@@ -106,8 +110,7 @@ struct _ECalBackendGroupwisePrivate {
static void e_cal_backend_groupwise_dispose (GObject *object);
static void e_cal_backend_groupwise_finalize (GObject *object);
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj);
+static void e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **perror);
static const gchar * get_gw_item_id (icalcomponent *icalcomp);
static void get_retract_data (ECalComponent *comp, const gchar **retract_comment, gboolean *all_instances);
static const gchar * get_element_type (icalcomponent_kind kind);
@@ -906,14 +909,13 @@ cache_init (ECalBackendGroupwise *cbgw)
return NULL;
}
-static ECalBackendSyncStatus
-set_container_id_with_count (ECalBackendGroupwise *cbgw)
+static gboolean
+set_container_id_with_count (ECalBackendGroupwise *cbgw, GError **perror)
{
ECalBackendGroupwisePrivate *priv;
GList *container_list = NULL, *l;
EGwConnectionStatus status;
icalcomponent_kind kind;
- ECalBackendSyncStatus res;
priv = cbgw->priv;
@@ -927,7 +929,8 @@ set_container_id_with_count (ECalBackendGroupwise *cbgw)
break;
default:
priv->container_id = NULL;
- return GNOME_Evolution_Calendar_UnsupportedMethod;
+ g_propagate_error (perror, EDC_ERROR (UnsupportedMethod));
+ return FALSE;
}
status = e_gw_connection_get_container_list (priv->cnc, "folders", &container_list);
@@ -935,10 +938,11 @@ set_container_id_with_count (ECalBackendGroupwise *cbgw)
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_get_container_list (priv->cnc, "folders", &container_list);
- if (status != E_GW_CONNECTION_STATUS_OK)
- return GNOME_Evolution_Calendar_OtherError;
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ g_propagate_error (perror, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ return FALSE;
+ }
- res = GNOME_Evolution_Calendar_ObjectNotFound;
for (l = container_list; l != NULL; l = l->next) {
EGwContainer *container = E_GW_CONTAINER (l->data);
@@ -947,18 +951,22 @@ set_container_id_with_count (ECalBackendGroupwise *cbgw)
priv->container_id = g_strdup (e_gw_container_get_id (container));
priv->total_count = e_gw_container_get_total_count (container);
- res = GNOME_Evolution_Calendar_Success;
break;
}
}
+ if (l == NULL) {
+ g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
+ return FALSE;
+ }
+
e_gw_connection_free_container_list (container_list);
- return res;
+ return TRUE;
}
-static ECalBackendSyncStatus
-connect_to_server (ECalBackendGroupwise *cbgw)
+static void
+connect_to_server (ECalBackendGroupwise *cbgw, GError **perror)
{
gchar *real_uri;
ECalBackendGroupwisePrivate *priv;
@@ -981,8 +989,8 @@ connect_to_server (ECalBackendGroupwise *cbgw)
use_ssl = e_source_get_property (source, "use_ssl");
if (!real_uri) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Invalid server URI"));
- return GNOME_Evolution_Calendar_NoSuchCal;
+ g_propagate_error (perror, EDC_ERROR_EX (NoSuchCal, _("Invalid server URI")));
+ return;
}
kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
@@ -1000,8 +1008,8 @@ connect_to_server (ECalBackendGroupwise *cbgw)
}
if (!cnc) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
- return GNOME_Evolution_Calendar_AuthenticationFailed;
+ g_propagate_error (perror, EDC_ERROR (AuthenticationFailed));
+ return;
}
priv->cnc = e_gw_connection_get_proxy_connection (cnc, parent_user, priv->password, priv->username, &permissions);
@@ -1009,8 +1017,8 @@ connect_to_server (ECalBackendGroupwise *cbgw)
g_object_unref(cnc);
if (!priv->cnc) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
- return GNOME_Evolution_Calendar_AuthenticationFailed;
+ g_propagate_error (perror, EDC_ERROR (AuthenticationFailed));
+ return;
}
cbgw->priv->read_only = TRUE;
@@ -1043,14 +1051,16 @@ connect_to_server (ECalBackendGroupwise *cbgw)
fetch_deltas (cbgw);
}
- return GNOME_Evolution_Calendar_Success;
+ return;
}
} else {
- if (errors.status == E_GW_CONNECTION_STATUS_INVALID_PASSWORD)
- return GNOME_Evolution_Calendar_AuthenticationFailed;
+ if (errors.status == E_GW_CONNECTION_STATUS_INVALID_PASSWORD) {
+ g_propagate_error (perror, EDC_ERROR (AuthenticationFailed));
+ return;
+ }
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _(errors.description));
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, _(errors.description)));
+ return;
}
priv->mode_changed = FALSE;
@@ -1070,22 +1080,21 @@ connect_to_server (ECalBackendGroupwise *cbgw)
}
if (E_IS_GW_CONNECTION (priv->cnc)) {
- ECalBackendSyncStatus status;
const gchar *uri = e_cal_backend_get_uri (E_CAL_BACKEND (cbgw));
/* get the ID for the container */
if (priv->container_id)
g_free (priv->container_id);
- if ((status = set_container_id_with_count (cbgw)) != GNOME_Evolution_Calendar_Success) {
- return status;
+ if (!set_container_id_with_count (cbgw, perror)) {
+ return;
}
e_cal_backend_cache_remove (uri, source_type);
priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, source_type);
if (!priv->store) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("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_store_load (priv->store);
@@ -1097,19 +1106,18 @@ connect_to_server (ECalBackendGroupwise *cbgw)
g_warning (G_STRLOC ": %s", error->message);
g_error_free (error);
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("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;
}
} else {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
- return GNOME_Evolution_Calendar_AuthenticationFailed;
+ g_propagate_error (perror, EDC_ERROR (AuthenticationFailed));
+ return;
}
- if (!e_gw_connection_get_version (priv->cnc))
- return GNOME_Evolution_Calendar_InvalidServerVersion;
-
- return GNOME_Evolution_Calendar_Success;
+ if (!e_gw_connection_get_version (priv->cnc)) {
+ g_propagate_error (perror, EDC_ERROR (InvalidServerVersion));
+ }
}
/* Dispose handler for the file backend */
@@ -1219,20 +1227,18 @@ e_cal_backend_groupwise_finalize (GObject *object)
/* Calendar backend methods */
/* Is_read_only handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
+static void
+e_cal_backend_groupwise_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only, GError **perror)
{
ECalBackendGroupwise *cbgw;
cbgw = E_CAL_BACKEND_GROUPWISE(backend);
*read_only = cbgw->priv->read_only;
-
- return GNOME_Evolution_Calendar_Success;
}
/* return email address of the person who opened the calendar */
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+static void
+e_cal_backend_groupwise_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -1248,33 +1254,27 @@ e_cal_backend_groupwise_get_cal_address (ECalBackendSync *backend, EDataCal *cal
}
*address = g_strdup (priv->user_email);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute)
+static void
+e_cal_backend_groupwise_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute, GError **perror)
{
/* ldap attribute is specific to Sun ONE connector to get free busy information*/
/* retun NULL here as group wise backend know how to get free busy information */
*attribute = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+static void
+e_cal_backend_groupwise_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
{
/*group wise does not support email based alarms */
*address = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities)
+static void
+e_cal_backend_groupwise_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities, GError **perror)
{
*capabilities = g_strdup (CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS ","
CAL_STATIC_CAPABILITY_ONE_ALARM_ONLY ","
@@ -1292,8 +1292,6 @@ e_cal_backend_groupwise_get_static_capabilities (ECalBackendSync *backend, EData
CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER ","
CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING ","
CAL_STATIC_CAPABILITY_SAVE_SCHEDULES);
-
- return GNOME_Evolution_Calendar_Success;
}
static void
@@ -1324,13 +1322,12 @@ in_offline (ECalBackendGroupwise *cbgw) {
}
/* Open handler for the file backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
- const gchar *username, const gchar *password)
+ const gchar *username, const gchar *password, GError **perror)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
- ECalBackendSyncStatus status;
ECalSourceType source_type;
const gchar *source = NULL;
const gchar *user_cache_dir;
@@ -1371,7 +1368,8 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
if (!display_contents || !g_str_equal (display_contents, "1")) {
PRIV_UNLOCK (priv);
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
+ return;
}
if (!priv->store) {
@@ -1382,16 +1380,15 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, source_type);
if (!priv->store) {
PRIV_UNLOCK (priv);
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("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_store_set_default_timezone (priv->store, priv->default_zone);
PRIV_UNLOCK (priv);
- return GNOME_Evolution_Calendar_Success;
+ return;
}
priv->username = g_strdup (username);
@@ -1414,14 +1411,13 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
g_free (filename);
/* FIXME: no need to set it online here when we implement the online/offline stuff correctly */
- status = connect_to_server (cbgw);
+ connect_to_server (cbgw, perror);
PRIV_UNLOCK (priv);
- return status;
}
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_remove (ECalBackendSync *backend, EDataCal *cal)
+static void
+e_cal_backend_groupwise_remove (ECalBackendSync *backend, EDataCal *cal, GError **perror)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -1436,8 +1432,6 @@ e_cal_backend_groupwise_remove (ECalBackendSync *backend, EDataCal *cal)
e_cal_backend_store_remove (priv->store);
PRIV_UNLOCK (priv);
-
- return GNOME_Evolution_Calendar_Success;
}
/* is_loaded handler for the file backend */
@@ -1477,7 +1471,7 @@ e_cal_backend_groupwise_set_mode (ECalBackend *backend, CalMode mode)
priv = cbgw->priv;
if (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;
}
@@ -1489,8 +1483,7 @@ e_cal_backend_groupwise_set_mode (ECalBackend *backend, CalMode mode)
case CAL_MODE_REMOTE :/* go online */
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);
e_cal_backend_notify_readonly (backend, priv->read_only);
if (e_cal_backend_groupwise_is_loaded (backend))
e_cal_backend_notify_auth_required(backend);
@@ -1501,20 +1494,19 @@ e_cal_backend_groupwise_set_mode (ECalBackend *backend, CalMode mode)
priv->mode = CAL_MODE_LOCAL;
in_offline (cbgw);
e_cal_backend_notify_readonly (backend, priv->read_only);
- e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_SET,
- GNOME_Evolution_Calendar_MODE_LOCAL);
+ e_cal_backend_notify_mode (backend, ModeSet, Local);
break;
default :
- e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
+ e_cal_backend_notify_mode (backend, ModeNotSupported,
cal_mode_to_corba (mode));
}
PRIV_UNLOCK (priv);
}
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object)
+static void
+e_cal_backend_groupwise_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object, GError **perror)
{
ECalComponent *comp;
@@ -1530,24 +1522,23 @@ e_cal_backend_groupwise_get_default_object (ECalBackendSync *backend, EDataCal *
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;
}
/* Get_object_component handler for the groupwise backend */
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object)
+static void
+e_cal_backend_groupwise_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object, GError **error)
{
ECalComponent *comp;
ECalBackendGroupwisePrivate *priv;
ECalBackendGroupwise *cbgw = (ECalBackendGroupwise *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), InvalidArg);
priv = cbgw->priv;
@@ -1565,18 +1556,20 @@ e_cal_backend_groupwise_get_object (ECalBackendSync *backend, EDataCal *cal, con
g_object_unref (comp);
- return *object ? GNOME_Evolution_Calendar_Success : GNOME_Evolution_Calendar_ObjectNotFound;
+ if (!*object)
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
}
PRIV_UNLOCK (priv);
/* callers will never have a uuid that is in server but not in cache */
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
}
/* Add_timezone handler for the groupwise backend */
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
icalcomponent *tz_comp;
ECalBackendGroupwise *cbgw;
@@ -1584,14 +1577,16 @@ e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, c
cbgw = (ECalBackendGroupwise *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), 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_GROUPWISE (cbgw), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbgw->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;
@@ -1600,15 +1595,15 @@ e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, c
icaltimezone_set_component (zone, tz_comp);
if (e_cal_backend_store_put_timezone (priv->store, zone) == FALSE) {
icaltimezone_free (zone, 1);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (error, EDC_ERROR_EX (OtherError, "Put timezone failed"));
+ return;
}
icaltimezone_free (zone, 1);
}
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_groupwise_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
icalcomponent *tz_comp;
ECalBackendGroupwise *cbgw;
@@ -1617,14 +1612,16 @@ e_cal_backend_groupwise_set_default_zone (ECalBackendSync *backend, EDataCal *ca
cbgw = (ECalBackendGroupwise *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), 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_GROUPWISE (cbgw), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbgw->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);
@@ -1638,21 +1635,18 @@ e_cal_backend_groupwise_set_default_zone (ECalBackendSync *backend, EDataCal *ca
priv->default_zone = zone;
PRIV_UNLOCK (priv);
-
- return GNOME_Evolution_Calendar_Success;
}
/* Gets the list of attachments */
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, GSList **list)
+static void
+e_cal_backend_groupwise_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;
}
/* Get_objects_in_range handler for the groupwise backend */
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects)
+static void
+e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects, GError **perror)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -1673,7 +1667,8 @@ e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal
cbsexp = e_cal_backend_sexp_new (sexp);
if (!cbsexp) {
PRIV_UNLOCK (priv);
- return GNOME_Evolution_Calendar_InvalidQuery;
+ g_propagate_error (perror, EDC_ERROR (InvalidQuery));
+ return;
}
*objects = NULL;
@@ -1698,28 +1693,27 @@ e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal
g_slist_free (components);
PRIV_UNLOCK (priv);
-
- return GNOME_Evolution_Calendar_Success;
}
/* get_query handler for the groupwise backend */
static void
e_cal_backend_groupwise_start_query (ECalBackend *backend, EDataCalView *query)
{
- ECalBackendSyncStatus status;
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
GList *objects = NULL;
+ GError *err = NULL;
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
g_message (G_STRLOC ": Starting query (%s)", e_data_cal_view_get_text (query));
- status = e_cal_backend_groupwise_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_groupwise_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;
}
@@ -1732,13 +1726,13 @@ e_cal_backend_groupwise_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);
}
/* Get_free_busy handler for the file backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_groupwise_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users,
- time_t start, time_t end, GList **freebusy)
+ time_t start, time_t end, GList **freebusy, GError **perror)
{
EGwConnectionStatus status;
ECalBackendGroupwise *cbgw;
@@ -1747,19 +1741,19 @@ e_cal_backend_groupwise_get_free_busy (ECalBackendSync *backend, EDataCal *cal,
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
cnc = cbgw->priv->cnc;
- if (cbgw->priv->mode == CAL_MODE_LOCAL) {
- in_offline (cbgw);
- return GNOME_Evolution_Calendar_RepositoryOffline;
- }
+ if (cbgw->priv->mode == CAL_MODE_LOCAL) {
+ in_offline (cbgw);
+ g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
+ return;
+ }
- status = e_gw_connection_get_freebusy_info (cbgw, users, start, end, freebusy);
+ status = e_gw_connection_get_freebusy_info (cbgw, users, start, end, freebusy);
- if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_get_freebusy_info (cbgw, users, start, end, freebusy);
+ if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+ status = e_gw_connection_get_freebusy_info (cbgw, users, start, end, freebusy);
- if (status != E_GW_CONNECTION_STATUS_OK)
- return GNOME_Evolution_Calendar_OtherError;
- return GNOME_Evolution_Calendar_Success;
+ if (status != E_GW_CONNECTION_STATUS_OK)
+ g_propagate_error (perror, EDC_ERROR_FAILED_STATUS (OtherError, status));
}
typedef struct {
@@ -1791,16 +1785,16 @@ e_cal_backend_groupwise_compute_changes_foreach_key (const gchar *key, const gch
}
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_groupwise_compute_changes (ECalBackendGroupwise *cbgw, const gchar *change_id,
- GList **adds, GList **modifies, GList **deletes)
+ GList **adds, GList **modifies, GList **deletes, GError **perror)
{
- ECalBackendSyncStatus status;
gchar *filename;
EXmlHash *ehash;
ECalBackendGroupwiseComputeChangesData be_data;
GList *i, *list = NULL;
gchar *unescaped_uri;
+ GError *err = NULL;
/* FIXME Will this always work? */
unescaped_uri = g_uri_unescape_string (cbgw->priv->uri, "");
@@ -1809,9 +1803,11 @@ e_cal_backend_groupwise_compute_changes (ECalBackendGroupwise *cbgw, const gchar
g_free (filename);
g_free (unescaped_uri);
- status = e_cal_backend_groupwise_get_object_list (E_CAL_BACKEND_SYNC (cbgw), NULL, "#t", &list);
- if (status != GNOME_Evolution_Calendar_Success)
- return status;
+ e_cal_backend_groupwise_get_object_list (E_CAL_BACKEND_SYNC (cbgw), 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)) {
@@ -1855,30 +1851,27 @@ e_cal_backend_groupwise_compute_changes (ECalBackendGroupwise *cbgw, const gchar
e_xmlhash_write (ehash);
e_xmlhash_destroy (ehash);
-
- return GNOME_Evolution_Calendar_Success;
}
/* Get_changes handler for the groupwise backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_groupwise_get_changes (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id,
- GList **adds, GList **modifies, GList **deletes)
+ GList **adds, GList **modifies, GList **deletes, GError **error)
{
ECalBackendGroupwise *cbgw;
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
- g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), GNOME_Evolution_Calendar_InvalidObject);
- g_return_val_if_fail (change_id != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-
- return e_cal_backend_groupwise_compute_changes (cbgw, change_id, adds, modifies, deletes);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), InvalidArg);
+ e_return_data_cal_error_if_fail (change_id != NULL, InvalidArg);
+ e_cal_backend_groupwise_compute_changes (cbgw, change_id, adds, modifies, deletes, error);
}
/* Discard_alarm handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid)
+static void
+e_cal_backend_groupwise_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid, GError **perror)
{
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR (NotSupported));
}
static icaltimezone *
@@ -1934,7 +1927,7 @@ update_from_server (ECalBackendGroupwise *cbgw, GSList *uid_list, gchar **calobj
if (stat != E_GW_CONNECTION_STATUS_OK || (list == NULL) || (g_list_length (list) == 0)) {
g_ptr_array_free (uid_array, TRUE);
- return GNOME_Evolution_Calendar_OtherError;
+ return stat;
}
comp = g_object_ref ( (ECalComponent *) list->data );
@@ -1966,8 +1959,8 @@ update_from_server (ECalBackendGroupwise *cbgw, GSList *uid_list, gchar **calobj
return E_GW_CONNECTION_STATUS_OK;
}
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid)
+static void
+e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid, GError **error)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -1979,22 +1972,26 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal,
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
- g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), 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_GROUPWISE (cbgw), InvalidArg);
+ e_return_data_cal_error_if_fail (calobj != NULL && *calobj != NULL, InvalidArg);
if (priv->mode == CAL_MODE_LOCAL) {
in_offline(cbgw);
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ 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 (e_cal_backend_get_kind (E_CAL_BACKEND (backend)) != icalcomponent_isa (icalcomp)) {
icalcomponent_free (icalcomp);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
}
comp = e_cal_component_new ();
@@ -2013,25 +2010,31 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal,
if (status != E_GW_CONNECTION_STATUS_OK) {
g_object_unref (comp);
- if (status == E_GW_CONNECTION_STATUS_UNKNOWN_USER)
- return GNOME_Evolution_Calendar_UnknownUser;
- else if (status == E_GW_CONNECTION_STATUS_OVER_QUOTA)
- return GNOME_Evolution_Calendar_PermissionDenied;
- else
- return GNOME_Evolution_Calendar_OtherError;
+ if (status == E_GW_CONNECTION_STATUS_UNKNOWN_USER) {
+ g_propagate_error (error, EDC_ERROR (UnknownUser));
+ return;
+ } else if (status == E_GW_CONNECTION_STATUS_OVER_QUOTA) {
+ g_propagate_error (error, EDC_ERROR (PermissionDenied));
+ return;
+ } else {
+ g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ return;
+ }
}
/* If delay deliver has been set, server will not send the uid */
if (!uid_list || ((e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_JOURNAL) && e_cal_component_has_organizer (comp))) {
*calobj = NULL;
g_object_unref (comp);
- return GNOME_Evolution_Calendar_Success;
+ return;
}
/* Get the item back from server to update the last-modified time */
status = update_from_server (cbgw, uid_list, calobj, comp);
- if (status != E_GW_CONNECTION_STATUS_OK)
- return GNOME_Evolution_Calendar_OtherError;
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ return;
+ }
break;
default :
@@ -2039,8 +2042,6 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal,
}
g_object_unref (comp);
-
- return GNOME_Evolution_Calendar_Success;
}
static void
@@ -2081,9 +2082,9 @@ get_retract_data (ECalComponent *comp, const gchar **retract_comment, gboolean *
}
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_groupwise_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)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -2098,18 +2099,21 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
- g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), 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_GROUPWISE (cbgw), InvalidArg);
+ e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
if (priv->mode == CAL_MODE_LOCAL) {
in_offline (cbgw);
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ 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;
+ }
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomp);
e_cal_component_get_uid (comp, &uid);
@@ -2124,7 +2128,8 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
if (!cache_comp) {
g_message ("CRITICAL : Could not find the object in cache");
g_free (rid);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
}
if (e_cal_component_has_attendees (comp) &&
@@ -2146,7 +2151,8 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
g_object_unref (comp);
g_object_unref (cache_comp);
g_free (rid);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ return;
}
e_cal_backend_store_put_component (priv->store, comp);
@@ -2173,10 +2179,13 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
g_object_unref (cache_comp);
g_free (rid);
- if (status == E_GW_CONNECTION_STATUS_OVER_QUOTA)
- return GNOME_Evolution_Calendar_PermissionDenied;
+ if (status == E_GW_CONNECTION_STATUS_OVER_QUOTA) {
+ g_propagate_error (error, EDC_ERROR (PermissionDenied));
+ return;
+ }
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ return;
}
e_cal_backend_store_put_component (priv->store, comp);
break;
@@ -2195,7 +2204,8 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
g_object_unref (comp);
g_object_unref (cache_comp);
g_free (rid);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ return;
}
/* if successful, update the cache */
@@ -2211,7 +2221,6 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
g_object_unref (cache_comp);
g_object_unref (comp);
g_free (rid);
- return GNOME_Evolution_Calendar_Success;
}
static const gchar *
@@ -2236,15 +2245,17 @@ get_gw_item_id (icalcomponent *icalcomp)
}
/* Remove_object handler for the file backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
const gchar *uid, const gchar *rid,
CalObjModType mod, gchar **old_object,
- gchar **object)
+ gchar **object, GError **perror)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
+ EGwConnectionStatus status;
gchar *calobj = NULL;
+ GError *err = NULL;
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
@@ -2253,18 +2264,20 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
/* if online, remove the item from the server */
if (priv->mode == CAL_MODE_REMOTE) {
- ECalBackendSyncStatus status;
const gchar *id_to_remove = NULL;
icalcomponent *icalcomp;
- status = e_cal_backend_groupwise_get_object (backend, cal, uid, rid, &calobj);
- if (status != GNOME_Evolution_Calendar_Success)
- return status;
+ e_cal_backend_groupwise_get_object (backend, cal, uid, rid, &calobj, &err);
+ if (err) {
+ g_propagate_error (perror, err);
+ return;
+ }
icalcomp = icalparser_parse_string (calobj);
if (!icalcomp) {
g_free (calobj);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (perror, EDC_ERROR (InvalidObject));
+ return;
}
if (mod == CALOBJ_MOD_THIS) {
@@ -2285,20 +2298,24 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
/* remove the component from the cache */
if (!e_cal_backend_store_remove_component (priv->store, uid, rid)) {
g_free (calobj);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
+ return;
}
*object = NULL;
*old_object = strdup (calobj);
g_free (calobj);
- return GNOME_Evolution_Calendar_Success;
+ return;
} else {
g_free (calobj);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ return;
}
} else if (mod == CALOBJ_MOD_ALL) {
GSList *l, *comp_list = e_cal_backend_store_get_components_by_uid (priv->store, uid);
if (e_cal_component_has_attendees (E_CAL_COMPONENT (comp_list->data))) {
+ EGwConnectionStatus status;
+
/* get recurrence key and send it to
* e_gw_connection_remove_recurrence_item */
@@ -2345,19 +2362,24 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
*old_object = strdup (calobj);
*object = NULL;
g_free (calobj);
- return GNOME_Evolution_Calendar_Success;
+ return;
} else {
g_free (calobj);
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ return;
}
- } else
- return GNOME_Evolution_Calendar_UnsupportedMethod;
+ } else {
+ g_propagate_error (perror, EDC_ERROR (UnsupportedMethod));
+ return;
+ }
} else if (priv->mode == CAL_MODE_LOCAL) {
in_offline (cbgw);
- return GNOME_Evolution_Calendar_RepositoryOffline;
- } else
- return GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED;
-
+ g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
+ return;
+ } else {
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, "Incorrect online mode set"));
+ return;
+ }
}
/* This function is largely duplicated in
@@ -2474,8 +2496,8 @@ change_status (ECalComponent *comp, icalparameter_partstat status, const gchar *
}
}
-static ECalBackendSyncStatus
-receive_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp)
+static void
+receive_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp, GError **perror)
{
ECalComponent *comp, *modif_comp = NULL;
ECalBackendGroupwisePrivate *priv;
@@ -2590,40 +2612,41 @@ receive_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalco
g_slist_free (comps);
g_object_unref (comp);
g_object_unref (modif_comp);
- return GNOME_Evolution_Calendar_Success;
-
}
g_object_unref (comp);
- if (status == E_GW_CONNECTION_STATUS_INVALID_OBJECT) {
- return GNOME_Evolution_Calendar_InvalidObject;
- } else if (status == E_GW_CONNECTION_STATUS_OVER_QUOTA)
- return GNOME_Evolution_Calendar_PermissionDenied;
-
- return GNOME_Evolution_Calendar_OtherError;
+ if (status == E_GW_CONNECTION_STATUS_INVALID_OBJECT)
+ g_propagate_error (perror, EDC_ERROR (InvalidObject));
+ else if (status == E_GW_CONNECTION_STATUS_OVER_QUOTA)
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
+ else
+ g_propagate_error (perror, EDC_ERROR_FAILED_STATUS (OtherError, status));
}
/* Update_objects handler for the file backend. */
-static ECalBackendSyncStatus
-e_cal_backend_groupwise_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj)
+static void
+e_cal_backend_groupwise_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GError **perror)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
icalcomponent *icalcomp, *subcomp;
icalcomponent_kind kind;
- ECalBackendSyncStatus status = GNOME_Evolution_Calendar_Success;
+ GError *err = NULL;
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
if (priv->mode == CAL_MODE_LOCAL) {
in_offline (cbgw);
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
+ return;
}
icalcomp = icalparser_parse_string (calobj);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (!icalcomp) {
+ g_propagate_error (perror, EDC_ERROR (InvalidObject));
+ return;
+ }
kind = icalcomponent_isa (icalcomp);
if (kind == ICAL_VCALENDAR_COMPONENT) {
@@ -2631,28 +2654,28 @@ e_cal_backend_groupwise_receive_objects (ECalBackendSync *backend, EDataCal *cal
e_cal_backend_get_kind (E_CAL_BACKEND (backend)));
while (subcomp) {
icalcomponent_set_method (subcomp, icalcomponent_get_method (icalcomp));
- status = receive_object (cbgw, cal, subcomp);
- if (status != GNOME_Evolution_Calendar_Success)
+ receive_object (cbgw, cal, subcomp, &err);
+ if (err)
break;
subcomp = icalcomponent_get_next_component (icalcomp,
e_cal_backend_get_kind (E_CAL_BACKEND (backend)));
}
} else if (kind == e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
- status = receive_object (cbgw, cal, icalcomp);
+ receive_object (cbgw, cal, icalcomp, &err);
} else
- status = GNOME_Evolution_Calendar_InvalidObject;
+ err = EDC_ERROR (InvalidObject);
icalcomponent_free (icalcomp);
- return status;
+ if (err)
+ g_propagate_error (perror, err);
}
-static ECalBackendSyncStatus
-send_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp, icalproperty_method method)
+static void
+send_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp, icalproperty_method method, GError **perror)
{
ECalComponent *comp, *found_comp = NULL;
ECalBackendGroupwisePrivate *priv;
- ECalBackendSyncStatus status = GNOME_Evolution_Calendar_OtherError;
const gchar *uid = NULL;
gchar *rid = NULL;
@@ -2669,7 +2692,8 @@ send_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp,
if (!found_comp) {
g_object_unref (comp);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
+ return;
}
switch (priv->mode) {
@@ -2679,6 +2703,7 @@ send_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp,
const gchar *retract_comment = NULL;
gboolean all_instances = FALSE;
const gchar *id = NULL;
+ EGwConnectionStatus status;
get_retract_data (comp, &retract_comment, &all_instances);
id = get_gw_item_id (icalcomp);
@@ -2688,32 +2713,34 @@ send_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp,
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_retract_request (priv->cnc, id, retract_comment,
all_instances, FALSE);
+
+ if (status != E_GW_CONNECTION_STATUS_OK)
+ g_propagate_error (perror, EDC_ERROR_FAILED_STATUS (OtherError, status));
}
break;
case CAL_MODE_LOCAL :
/* in offline mode, we just update the cache */
- status = GNOME_Evolution_Calendar_RepositoryOffline;
+ g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
break;
default:
+ g_propagate_error (perror, EDC_ERROR (OtherError));
break;
}
g_object_unref (comp);
g_object_unref (found_comp);
-
- return status;
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_groupwise_send_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GList **users,
- gchar **modified_calobj)
+ gchar **modified_calobj, GError **perror)
{
- ECalBackendSyncStatus status = GNOME_Evolution_Calendar_OtherError;
icalcomponent *icalcomp, *subcomp;
icalcomponent_kind kind;
icalproperty_method method;
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
+ GError *err = NULL;
*users = NULL;
*modified_calobj = NULL;
@@ -2723,12 +2750,15 @@ e_cal_backend_groupwise_send_objects (ECalBackendSync *backend, EDataCal *cal, c
if (priv->mode == CAL_MODE_LOCAL) {
in_offline (cbgw);
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
+ return;
}
icalcomp = icalparser_parse_string (calobj);
- if (!icalcomp)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (!icalcomp) {
+ g_propagate_error (perror, EDC_ERROR (InvalidObject));
+ return;
+ }
method = icalcomponent_get_method (icalcomp);
kind = icalcomponent_isa (icalcomp);
@@ -2737,18 +2767,19 @@ e_cal_backend_groupwise_send_objects (ECalBackendSync *backend, EDataCal *cal, c
e_cal_backend_get_kind (E_CAL_BACKEND (backend)));
while (subcomp) {
- status = send_object (cbgw, cal, subcomp, method);
- if (status != GNOME_Evolution_Calendar_Success)
+ send_object (cbgw, cal, subcomp, method, &err);
+ if (err)
break;
subcomp = icalcomponent_get_next_component (icalcomp,
e_cal_backend_get_kind (E_CAL_BACKEND (backend)));
}
} else if (kind == e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
- status = send_object (cbgw, cal, icalcomp, method);
- } else
- status = GNOME_Evolution_Calendar_InvalidObject;
+ send_object (cbgw, cal, icalcomp, method, &err);
+ } else {
+ err = EDC_ERROR (InvalidObject);
+ }
- if (status == GNOME_Evolution_Calendar_Success) {
+ if (!err) {
ECalComponent *comp;
comp = e_cal_component_new ();
@@ -2770,7 +2801,8 @@ e_cal_backend_groupwise_send_objects (ECalBackendSync *backend, EDataCal *cal, c
}
icalcomponent_free (icalcomp);
- return status;
+ if (err)
+ g_propagate_error (perror, err);
}
/* Object initialization function for the file backend */
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index 644eb79..02c654c 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -39,6 +39,9 @@
#include <libsoup/soup.h>
#include "e-cal-backend-http.h"
+#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 (ECalBackendHttp, e_cal_backend_http, E_TYPE_CAL_BACKEND_SYNC)
@@ -84,8 +87,7 @@ struct _ECalBackendHttpPrivate {
static void e_cal_backend_http_dispose (GObject *object);
static void e_cal_backend_http_finalize (GObject *object);
static gboolean begin_retrieval_cb (ECalBackendHttp *cbhttp);
-static ECalBackendSyncStatus
-e_cal_backend_http_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj);
+static void e_cal_backend_http_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **perror);
static ECalBackendSyncClass *parent_class;
@@ -168,54 +170,44 @@ e_cal_backend_http_finalize (GObject *object)
/* Calendar backend methods */
/* Is_read_only handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_http_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
+static void
+e_cal_backend_http_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only, GError **perror)
{
*read_only = TRUE;
-
- return GNOME_Evolution_Calendar_Success;
}
/* Get_email_address handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_http_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+static void
+e_cal_backend_http_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
{
/* A HTTP backend has no particular email address associated
* with it (although that would be a useful feature some day).
*/
*address = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_http_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute)
+static void
+e_cal_backend_http_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute, GError **perror)
{
*attribute = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_http_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+static void
+e_cal_backend_http_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
{
/* A HTTP backend has no particular email address associated
* with it (although that would be a useful feature some day).
*/
*address = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_http_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities)
+static void
+e_cal_backend_http_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities, GError **perror)
{
*capabilities = g_strdup (
CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS ","
CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED
);
-
- return GNOME_Evolution_Calendar_Success;
}
static gchar *
@@ -621,9 +613,9 @@ source_changed_cb (ESource *source, ECalBackendHttp *cbhttp)
}
/* Open handler for the file backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
- const gchar *username, const gchar *password)
+ const gchar *username, const gchar *password, GError **perror)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -645,7 +637,8 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
if (e_source_get_property (source, "auth") != NULL) {
if ((username == NULL || password == NULL)) {
- return GNOME_Evolution_Calendar_AuthenticationRequired;
+ g_propagate_error (perror, EDC_ERROR (AuthenticationRequired));
+ return;
}
priv->username = g_strdup (username);
@@ -675,8 +668,8 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
e_cal_backend_store_load (priv->store);
if (!priv->store) {
- e_cal_backend_notify_error (E_CAL_BACKEND(cbhttp), _("Could not create cache file"));
- return GNOME_Evolution_Calendar_OtherError;
+ g_propagate_error (perror, EDC_ERROR_EX (OtherError, _("Could not create cache file")));
+ return;
}
if (priv->default_zone) {
@@ -684,16 +677,12 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
}
}
- if (priv->mode == CAL_MODE_LOCAL)
- return GNOME_Evolution_Calendar_Success;
-
- g_idle_add ((GSourceFunc) begin_retrieval_cb, cbhttp);
-
- return GNOME_Evolution_Calendar_Success;
+ if (priv->mode != CAL_MODE_LOCAL)
+ g_idle_add ((GSourceFunc) begin_retrieval_cb, cbhttp);
}
-static ECalBackendSyncStatus
-e_cal_backend_http_refresh (ECalBackendSync *backend, EDataCal *cal)
+static void
+e_cal_backend_http_refresh (ECalBackendSync *backend, EDataCal *cal, GError **perror)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -703,7 +692,7 @@ e_cal_backend_http_refresh (ECalBackendSync *backend, EDataCal *cal)
if (!priv->opened ||
priv->is_loading)
- return GNOME_Evolution_Calendar_Success;
+ return;
if (priv->reload_timeout_id)
g_source_remove (priv->reload_timeout_id);
@@ -711,12 +700,10 @@ e_cal_backend_http_refresh (ECalBackendSync *backend, EDataCal *cal)
/* wait a second, then start reloading */
priv->reload_timeout_id = g_timeout_add (1000, (GSourceFunc) reload_cb, cbhttp);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_http_remove (ECalBackendSync *backend, EDataCal *cal)
+static void
+e_cal_backend_http_remove (ECalBackendSync *backend, EDataCal *cal, GError **perror)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -725,10 +712,9 @@ e_cal_backend_http_remove (ECalBackendSync *backend, EDataCal *cal)
priv = cbhttp->priv;
if (!priv->store)
- return GNOME_Evolution_Calendar_Success;
+ return;
e_cal_backend_store_remove (priv->store);
- return GNOME_Evolution_Calendar_Success;
}
/* is_loaded handler for the file backend */
@@ -766,7 +752,7 @@ e_cal_backend_http_set_mode (ECalBackend *backend, CalMode mode)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
- GNOME_Evolution_Calendar_CalMode set_mode;
+ EDataCalMode set_mode;
gboolean loaded;
cbhttp = E_CAL_BACKEND_HTTP (backend);
@@ -793,10 +779,10 @@ e_cal_backend_http_set_mode (ECalBackend *backend, CalMode mode)
break;
priv->mode = CAL_MODE_REMOTE;
- set_mode = GNOME_Evolution_Calendar_MODE_REMOTE;
+ set_mode = Remote;
break;
default:
- set_mode = GNOME_Evolution_Calendar_MODE_ANY;
+ set_mode = AnyMode;
break;
}
} else {
@@ -805,19 +791,19 @@ e_cal_backend_http_set_mode (ECalBackend *backend, CalMode mode)
if (loaded) {
- if (set_mode == GNOME_Evolution_Calendar_MODE_ANY)
+ if (set_mode == AnyMode)
e_cal_backend_notify_mode (backend,
- GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
+ ModeNotSupported,
cal_mode_to_corba (priv->mode));
else
e_cal_backend_notify_mode (backend,
- GNOME_Evolution_Calendar_CalListener_MODE_SET,
+ ModeSet,
set_mode);
}
}
-static ECalBackendSyncStatus
-e_cal_backend_http_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object)
+static void
+e_cal_backend_http_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object, GError **perror)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -831,13 +817,11 @@ e_cal_backend_http_get_default_object (ECalBackendSync *backend, EDataCal *cal,
icalcomp = e_cal_util_new_component (kind);
*object = icalcomponent_as_ical_string_r (icalcomp);
icalcomponent_free (icalcomp);
-
- return GNOME_Evolution_Calendar_Success;
}
/* Get_object_component handler for the http backend */
-static ECalBackendSyncStatus
-e_cal_backend_http_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object)
+static void
+e_cal_backend_http_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object, GError **error)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -846,24 +830,26 @@ e_cal_backend_http_get_object (ECalBackendSync *backend, EDataCal *cal, const gc
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
- g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
+ e_return_data_cal_error_if_fail (uid != NULL, ObjectNotFound);
- if (!priv->store)
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ if (!priv->store) {
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
+ }
comp = e_cal_backend_store_get_component (priv->store, uid, rid);
- if (!comp)
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ if (!comp) {
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
+ }
*object = e_cal_component_get_as_string (comp);
g_object_unref (comp);
-
- return GNOME_Evolution_Calendar_Success;
}
/* Add_timezone handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_http_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_http_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -872,29 +858,30 @@ e_cal_backend_http_add_timezone (ECalBackendSync *backend, EDataCal *cal, const
cbhttp = (ECalBackendHttp *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_HTTP (cbhttp), 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_HTTP (cbhttp), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbhttp->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) {
icalcomponent_free (tz_comp);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
}
zone = icaltimezone_new ();
icaltimezone_set_component (zone, tz_comp);
e_cal_backend_store_put_timezone (priv->store, zone);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_http_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_http_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
icalcomponent *tz_comp;
ECalBackendHttp *cbhttp;
@@ -903,14 +890,16 @@ e_cal_backend_http_set_default_zone (ECalBackendSync *backend, EDataCal *cal, co
cbhttp = (ECalBackendHttp *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_HTTP (cbhttp), 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_HTTP (cbhttp), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbhttp->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);
@@ -920,13 +909,11 @@ e_cal_backend_http_set_default_zone (ECalBackendSync *backend, EDataCal *cal, co
/* Set the default timezone to it. */
priv->default_zone = zone;
-
- return GNOME_Evolution_Calendar_Success;
}
/* Get_objects_in_range handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_http_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects)
+static void
+e_cal_backend_http_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects, GError **perror)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -936,8 +923,10 @@ e_cal_backend_http_get_object_list (ECalBackendSync *backend, EDataCal *cal, con
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
- if (!priv->store)
- return GNOME_Evolution_Calendar_NoSuchCal;
+ if (!priv->store) {
+ g_propagate_error (perror, EDC_ERROR (NoSuchCal));
+ return;
+ }
/* process all components in the cache */
cbsexp = e_cal_backend_sexp_new (sexp);
@@ -953,8 +942,6 @@ e_cal_backend_http_get_object_list (ECalBackendSync *backend, EDataCal *cal, con
g_slist_foreach (components, (GFunc) g_object_unref, NULL);
g_slist_free (components);
g_object_unref (cbsexp);
-
- return GNOME_Evolution_Calendar_Success;
}
/* get_query handler for the file backend */
@@ -973,7 +960,9 @@ e_cal_backend_http_start_query (ECalBackend *backend, EDataCalView *query)
d(g_message (G_STRLOC ": Starting query (%s)", e_data_cal_view_get_text (query)));
if (!priv->store) {
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_NoSuchCal);
+ GError *error = EDC_ERROR (NoSuchCal);
+ e_data_cal_view_notify_done (query, error);
+ g_error_free (error);
return;
}
@@ -996,7 +985,7 @@ e_cal_backend_http_start_query (ECalBackend *backend, EDataCalView *query)
g_list_free (objects);
g_object_unref (cbsexp);
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_Success);
+ e_data_cal_view_notify_done (query, NULL /* Success */);
}
static icaltimezone *
@@ -1130,9 +1119,9 @@ create_user_free_busy (ECalBackendHttp *cbhttp, const gchar *address, const gcha
}
/* Get_free_busy handler for the file backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_http_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users,
- time_t start, time_t end, GList **freebusy)
+ time_t start, time_t end, GList **freebusy, GError **error)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -1143,11 +1132,13 @@ e_cal_backend_http_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
- g_return_val_if_fail (start != -1 && end != -1, GNOME_Evolution_Calendar_InvalidRange);
- g_return_val_if_fail (start <= end, GNOME_Evolution_Calendar_InvalidRange);
+ e_return_data_cal_error_if_fail (start != -1 && end != -1, InvalidRange);
+ e_return_data_cal_error_if_fail (start <= end, InvalidRange);
- if (!priv->store)
- return GNOME_Evolution_Calendar_NoSuchCal;
+ if (!priv->store) {
+ g_propagate_error (error, EDC_ERROR (NoSuchCal));
+ return;
+ }
if (users == NULL) {
if (e_cal_backend_mail_account_get_default (&address, &name)) {
@@ -1171,14 +1162,12 @@ e_cal_backend_http_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList
}
}
}
-
- return GNOME_Evolution_Calendar_Success;
}
/* Get_changes handler for the file backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_http_get_changes (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id,
- GList **adds, GList **modifies, GList **deletes)
+ GList **adds, GList **modifies, GList **deletes, GError **perror)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -1186,15 +1175,12 @@ e_cal_backend_http_get_changes (ECalBackendSync *backend, EDataCal *cal, const g
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
- g_return_val_if_fail (change_id != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-
- /* FIXME */
- return GNOME_Evolution_Calendar_Success;
+ g_propagate_error (perror, EDC_ERROR (NotSupported));
}
/* Discard_alarm handler for the file backend */
-static ECalBackendSyncStatus
-e_cal_backend_http_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid)
+static void
+e_cal_backend_http_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid, GError **perror)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -1203,11 +1189,10 @@ e_cal_backend_http_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const
priv = cbhttp->priv;
/* FIXME */
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_http_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid)
+static void
+e_cal_backend_http_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid, GError **perror)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -1215,12 +1200,12 @@ e_cal_backend_http_create_object (ECalBackendSync *backend, EDataCal *cal, gchar
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
- return GNOME_Evolution_Calendar_PermissionDenied;
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_http_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 **perror)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -1228,17 +1213,15 @@ e_cal_backend_http_modify_object (ECalBackendSync *backend, EDataCal *cal, const
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
- g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-
- return GNOME_Evolution_Calendar_PermissionDenied;
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
/* Remove_object handler for the file backend */
-static ECalBackendSyncStatus
+static void
e_cal_backend_http_remove_object (ECalBackendSync *backend, EDataCal *cal,
const gchar *uid, const gchar *rid,
CalObjModType mod, gchar **old_object,
- gchar **object)
+ gchar **object, GError **perror)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -1246,29 +1229,25 @@ e_cal_backend_http_remove_object (ECalBackendSync *backend, EDataCal *cal,
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
- g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
-
*old_object = *object = NULL;
- return GNOME_Evolution_Calendar_PermissionDenied;
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
/* Update_objects handler for the file backend. */
-static ECalBackendSyncStatus
-e_cal_backend_http_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj)
+static void
+e_cal_backend_http_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GError **perror)
{
ECalBackendHttp *cbhttp;
cbhttp = E_CAL_BACKEND_HTTP (backend);
- g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_InvalidObject);
-
- return GNOME_Evolution_Calendar_PermissionDenied;
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
-static ECalBackendSyncStatus
+static void
e_cal_backend_http_send_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GList **users,
- gchar **modified_calobj)
+ gchar **modified_calobj, GError **perror)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
@@ -1279,7 +1258,7 @@ e_cal_backend_http_send_objects (ECalBackendSync *backend, EDataCal *cal, const
*users = NULL;
*modified_calobj = NULL;
- return GNOME_Evolution_Calendar_PermissionDenied;
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
static icaltimezone *
diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c
index 4ac358e..d6f5288 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -34,13 +34,15 @@
#define WEATHER_UID_EXT "-weather"
+#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 (ECalBackendWeather, e_cal_backend_weather, E_TYPE_CAL_BACKEND_SYNC)
static gboolean reload_cb (ECalBackendWeather *cbw);
static gboolean begin_retrieval_cb (ECalBackendWeather *cbw);
static ECalComponent* create_weather (ECalBackendWeather *cbw, WeatherInfo *report, gboolean is_forecast);
-static ECalBackendSyncStatus
-e_cal_backend_weather_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj);
+static void e_cal_backend_weather_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **perror);
/* Private part of the ECalBackendWeather structure */
struct _ECalBackendWeatherPrivate {
@@ -420,42 +422,34 @@ create_weather (ECalBackendWeather *cbw, WeatherInfo *report, gboolean is_foreca
return cal_comp;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
+static void
+e_cal_backend_weather_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only, GError **perror)
{
*read_only = TRUE;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+static void
+e_cal_backend_weather_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
{
/* Weather has no particular email addresses associated with it */
*address = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+static void
+e_cal_backend_weather_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
{
/* Weather has no particular email addresses associated with it */
*address = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute)
+static void
+e_cal_backend_weather_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute, GError **perror)
{
*attribute = NULL;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities)
+static void
+e_cal_backend_weather_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities, GError **perror)
{
*capabilities = g_strdup (CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT ","
CAL_STATIC_CAPABILITY_NO_AUDIO_ALARMS ","
@@ -465,12 +459,10 @@ e_cal_backend_weather_get_static_capabilities (ECalBackendSync *backend, EDataCa
CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists, const gchar *username, const gchar *password)
+static void
+e_cal_backend_weather_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists, const gchar *username, const gchar *password, GError **perror)
{
ECalBackendWeather *cbw;
ECalBackendWeatherPrivate *priv;
@@ -489,8 +481,8 @@ e_cal_backend_weather_open (ECalBackendSync *backend, EDataCal *cal, gboolean on
priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, E_CAL_SOURCE_TYPE_EVENT);
if (!priv->store) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbw), _("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_store_load (priv->store);
@@ -504,17 +496,15 @@ e_cal_backend_weather_open (ECalBackendSync *backend, EDataCal *cal, gboolean on
}
if (priv->mode == CAL_MODE_LOCAL)
- return GNOME_Evolution_Calendar_Success;
+ return;
if (!priv->begin_retrival_id)
priv->begin_retrival_id = g_idle_add ((GSourceFunc) begin_retrieval_cb, cbw);
}
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_refresh (ECalBackendSync *backend, EDataCal *cal)
+static void
+e_cal_backend_weather_refresh (ECalBackendSync *backend, EDataCal *cal, GError **perror)
{
ECalBackendWeather *cbw;
ECalBackendWeatherPrivate *priv;
@@ -524,7 +514,7 @@ e_cal_backend_weather_refresh (ECalBackendSync *backend, EDataCal *cal)
if (!priv->opened ||
priv->is_loading)
- return GNOME_Evolution_Calendar_Success;
+ return;
if (priv->reload_timeout_id)
g_source_remove (priv->reload_timeout_id);
@@ -532,12 +522,10 @@ e_cal_backend_weather_refresh (ECalBackendSync *backend, EDataCal *cal)
/* wait a second, then start reloading */
priv->reload_timeout_id = g_timeout_add (1000, (GSourceFunc) reload_cb, cbw);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_remove (ECalBackendSync *backend, EDataCal *cal)
+static void
+e_cal_backend_weather_remove (ECalBackendSync *backend, EDataCal *cal, GError **perror)
{
ECalBackendWeather *cbw;
ECalBackendWeatherPrivate *priv;
@@ -548,60 +536,58 @@ e_cal_backend_weather_remove (ECalBackendSync *backend, EDataCal *cal)
if (!priv->store) {
/* lie here a bit, but otherwise the calendar will not be removed, even it should */
g_print (G_STRLOC ": Doesn't have a cache?!?");
- return GNOME_Evolution_Calendar_Success;
+ return;
}
e_cal_backend_store_remove (priv->store);
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid)
+static void
+e_cal_backend_weather_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid, GError **perror)
{
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj)
+static void
+e_cal_backend_weather_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GError **perror)
{
- return GNOME_Evolution_Calendar_PermissionDenied;
+ g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object)
+static void
+e_cal_backend_weather_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object, GError **perror)
{
- return GNOME_Evolution_Calendar_UnsupportedMethod;
+ g_propagate_error (perror, EDC_ERROR (UnsupportedMethod));
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object)
+static void
+e_cal_backend_weather_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object, GError **error)
{
ECalBackendWeather *cbw = E_CAL_BACKEND_WEATHER (backend);
ECalBackendWeatherPrivate *priv = cbw->priv;
ECalComponent *comp;
- g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
- g_return_val_if_fail (priv->store != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
+ e_return_data_cal_error_if_fail (uid != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (priv->store != NULL, InvalidArg);
comp = e_cal_backend_store_get_component (priv->store, uid, rid);
- g_return_val_if_fail (comp != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
+ e_return_data_cal_error_if_fail (comp != NULL, ObjectNotFound);
*object = e_cal_component_get_as_string (comp);
g_object_unref (comp);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp_string, GList **objects)
+static void
+e_cal_backend_weather_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp_string, GList **objects, GError **perror)
{
ECalBackendWeather *cbw = E_CAL_BACKEND_WEATHER (backend);
ECalBackendWeatherPrivate *priv = cbw->priv;
ECalBackendSExp *sexp = e_cal_backend_sexp_new (sexp_string);
GSList *components, *l;
- if (!sexp)
- return GNOME_Evolution_Calendar_InvalidQuery;
+ if (!sexp) {
+ g_propagate_error (perror, EDC_ERROR (InvalidQuery));
+ return;
+ }
*objects = NULL;
components = e_cal_backend_store_get_components (priv->store);
@@ -613,12 +599,10 @@ e_cal_backend_weather_get_object_list (ECalBackendSync *backend, EDataCal *cal,
g_slist_foreach (components, (GFunc) g_object_unref, NULL);
g_slist_free (components);
g_object_unref (sexp);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_weather_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
ECalBackendWeather *cbw;
ECalBackendWeatherPrivate *priv;
@@ -628,16 +612,18 @@ e_cal_backend_weather_add_timezone (ECalBackendSync *backend, EDataCal *cal, con
cbw = (ECalBackendWeather*) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_WEATHER (cbw), 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_WEATHER (cbw), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbw->priv;
tz_comp = icalparser_parse_string (tzobj);
- g_return_val_if_fail (tz_comp != NULL, GNOME_Evolution_Calendar_InvalidObject);
+ e_return_data_cal_error_if_fail (tz_comp != NULL, InvalidObject);
- if (icalcomponent_isa (tz_comp) != ICAL_VTIMEZONE_COMPONENT)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (icalcomponent_isa (tz_comp) != ICAL_VTIMEZONE_COMPONENT) {
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
+ return;
+ }
zone = icaltimezone_new ();
icaltimezone_set_component (zone, tz_comp);
@@ -645,15 +631,13 @@ e_cal_backend_weather_add_timezone (ECalBackendSync *backend, EDataCal *cal, con
if (g_hash_table_lookup (priv->zones, tzid)) {
icaltimezone_free (zone, TRUE);
- return GNOME_Evolution_Calendar_Success;
+ } else {
+ g_hash_table_insert (priv->zones, g_strdup (tzid), zone);
}
-
- g_hash_table_insert (priv->zones, g_strdup (tzid), zone);
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+static void
+e_cal_backend_weather_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
icalcomponent *tz_comp;
ECalBackendWeather *cbw;
@@ -662,14 +646,16 @@ e_cal_backend_weather_set_default_zone (ECalBackendSync *backend, EDataCal *cal,
cbw = (ECalBackendWeather *) backend;
- g_return_val_if_fail (E_IS_CAL_BACKEND_WEATHER (cbw), 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_WEATHER (cbw), InvalidArg);
+ e_return_data_cal_error_if_fail (tzobj != NULL, InvalidArg);
priv = cbw->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);
@@ -679,12 +665,10 @@ e_cal_backend_weather_set_default_zone (ECalBackendSync *backend, EDataCal *cal,
/* Set the default timezone to it. */
priv->default_zone = zone;
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users, time_t start, time_t end, GList **freebusy)
+static void
+e_cal_backend_weather_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users, time_t start, time_t end, GList **freebusy, GError **perror)
{
/* Weather doesn't count as busy time */
icalcomponent *vfb = icalcomponent_new_vfreebusy ();
@@ -697,14 +681,11 @@ e_cal_backend_weather_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GL
calobj = icalcomponent_as_ical_string_r (vfb);
*freebusy = g_list_append (NULL, calobj);
icalcomponent_free (vfb);
-
- return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
-e_cal_backend_weather_get_changes (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id, GList **adds, GList **modifies, GList **deletes)
+static void
+e_cal_backend_weather_get_changes (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id, GList **adds, GList **modifies, GList **deletes, GError **perror)
{
- return GNOME_Evolution_Calendar_Success;
}
static gboolean
@@ -729,18 +710,23 @@ static void e_cal_backend_weather_start_query (ECalBackend *backend, EDataCalVie
ECalBackendSExp *sexp;
GSList *components, *l;
GList *objects;
+ GError *error;
cbw = E_CAL_BACKEND_WEATHER (backend);
priv = cbw->priv;
if (!priv->store) {
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_NoSuchCal);
+ error = EDC_ERROR (NoSuchCal);
+ e_data_cal_view_notify_done (query, error);
+ g_error_free (error);
return;
}
sexp = e_data_cal_view_get_object_sexp (query);
if (!sexp) {
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_InvalidQuery);
+ error = EDC_ERROR (InvalidQuery);
+ e_data_cal_view_notify_done (query, error);
+ g_error_free (error);
return;
}
@@ -760,7 +746,7 @@ static void e_cal_backend_weather_start_query (ECalBackend *backend, EDataCalVie
g_list_free (objects);
g_object_unref (sexp);
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_Success);
+ e_data_cal_view_notify_done (query, NULL /* Success */);
}
static CalMode
@@ -780,7 +766,7 @@ e_cal_backend_weather_set_mode (ECalBackend *backend, CalMode mode)
{
ECalBackendWeather *cbw;
ECalBackendWeatherPrivate *priv;
- GNOME_Evolution_Calendar_CalMode set_mode;
+ EDataCalMode set_mode;
gboolean loaded;
cbw = E_CAL_BACKEND_WEATHER (backend);
@@ -806,7 +792,7 @@ e_cal_backend_weather_set_mode (ECalBackend *backend, CalMode mode)
priv->begin_retrival_id = g_idle_add ((GSourceFunc) begin_retrieval_cb, backend);
break;
default:
- set_mode = GNOME_Evolution_Calendar_MODE_ANY;
+ set_mode = AnyMode;
break;
}
} else {
@@ -814,13 +800,13 @@ e_cal_backend_weather_set_mode (ECalBackend *backend, CalMode mode)
}
if (loaded) {
- if (set_mode == GNOME_Evolution_Calendar_MODE_ANY)
+ if (set_mode == AnyMode)
e_cal_backend_notify_mode (backend,
- GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
+ ModeNotSupported,
cal_mode_to_corba (priv->mode));
else
e_cal_backend_notify_mode (backend,
- GNOME_Evolution_Calendar_CalListener_MODE_SET,
+ ModeSet,
set_mode);
}
}
diff --git a/calendar/libecal/e-cal-marshal.list b/calendar/libecal/e-cal-marshal.list
index 26fbf89..6371be8 100644
--- a/calendar/libecal/e-cal-marshal.list
+++ b/calendar/libecal/e-cal-marshal.list
@@ -1,2 +1,3 @@
NONE:ENUM,ENUM
NONE:STRING,UINT
+NONE:UINT,STRING
diff --git a/calendar/libecal/e-cal-types.h b/calendar/libecal/e-cal-types.h
index 6fab8c4..a9dca51 100644
--- a/calendar/libecal/e-cal-types.h
+++ b/calendar/libecal/e-cal-types.h
@@ -62,12 +62,16 @@ typedef enum {
E_CALENDAR_STATUS_COULD_NOT_CANCEL,
E_CALENDAR_STATUS_AUTHENTICATION_FAILED,
E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED,
- E_CALENDAR_STATUS_CORBA_EXCEPTION,
+ E_CALENDAR_STATUS_DBUS_EXCEPTION,
E_CALENDAR_STATUS_OTHER_ERROR,
- E_CALENDAR_STATUS_INVALID_SERVER_VERSION
-
+ E_CALENDAR_STATUS_INVALID_SERVER_VERSION,
+ E_CALENDAR_STATUS_NOT_SUPPORTED
} ECalendarStatus;
+#ifndef E_CAL_DISABLE_DEPRECATED
+#define E_CALENDAR_STATUS_CORBA_EXCEPTION E_CALENDAR_STATUS_DBUS_EXCEPTION
+#endif
+
G_END_DECLS
#endif
diff --git a/calendar/libecal/e-cal-util.h b/calendar/libecal/e-cal-util.h
index c89abdd..c63e76b 100644
--- a/calendar/libecal/e-cal-util.h
+++ b/calendar/libecal/e-cal-util.h
@@ -59,9 +59,9 @@ typedef enum {
} CalMode;
#define cal_mode_to_corba(mode) \
- (mode == CAL_MODE_LOCAL ? GNOME_Evolution_Calendar_MODE_LOCAL : \
- mode == CAL_MODE_REMOTE ? GNOME_Evolution_Calendar_MODE_REMOTE : \
- GNOME_Evolution_Calendar_MODE_ANY)
+ (mode == CAL_MODE_LOCAL ? Local : \
+ mode == CAL_MODE_REMOTE ? Remote : \
+ AnyMode)
void cal_obj_uid_list_free (GList *list);
diff --git a/calendar/libecal/e-cal-view.c b/calendar/libecal/e-cal-view.c
index d5fe206..5ac66b2 100644
--- a/calendar/libecal/e-cal-view.c
+++ b/calendar/libecal/e-cal-view.c
@@ -59,7 +59,10 @@ enum {
OBJECTS_MODIFIED,
OBJECTS_REMOVED,
VIEW_PROGRESS,
+ #ifndef E_CAL_DISABLE_DEPRECATED
VIEW_DONE,
+ #endif
+ VIEW_COMPLETE,
LAST_SIGNAL
};
@@ -178,13 +181,17 @@ progress_cb (DBusGProxy *proxy, const gchar *message, gint percent, gpointer dat
}
static void
-done_cb (DBusGProxy *proxy, ECalendarStatus status, gpointer data)
+done_cb (DBusGProxy *proxy, ECalendarStatus status, const gchar *message, gpointer data)
{
ECalView *view;
view = E_CAL_VIEW (data);
+ #ifndef E_CAL_DISABLE_DEPRECATED
g_signal_emit (G_OBJECT (view), signals[VIEW_DONE], 0, status);
+ #endif
+
+ g_signal_emit (G_OBJECT (view), signals[VIEW_COMPLETE], 0, status, message);
}
/* Object initialization function for the calendar view */
@@ -223,7 +230,8 @@ e_cal_view_set_property (GObject *object, guint property_id, const GValue *value
dbus_g_proxy_add_signal (priv->view_proxy, "Progress", G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->view_proxy, "Progress", G_CALLBACK (progress_cb), view, NULL);
- dbus_g_proxy_add_signal (priv->view_proxy, "Done", G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (e_cal_marshal_VOID__UINT_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (priv->view_proxy, "Done", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->view_proxy, "Done", G_CALLBACK (done_cb), view, NULL);
break;
@@ -346,6 +354,8 @@ e_cal_view_class_init (ECalViewClass *klass)
NULL, NULL,
e_cal_marshal_VOID__STRING_UINT,
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_UINT);
+
+ #ifndef E_CAL_DISABLE_DEPRECATED
signals[VIEW_DONE] =
g_signal_new ("view_done",
G_TYPE_FROM_CLASS (klass),
@@ -354,6 +364,16 @@ e_cal_view_class_init (ECalViewClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
+ #endif
+
+ signals[VIEW_COMPLETE] =
+ g_signal_new ("view_complete",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (ECalViewClass, view_complete),
+ NULL, NULL,
+ e_cal_marshal_VOID__UINT_STRING,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
}
/**
@@ -409,21 +429,60 @@ e_cal_view_get_client (ECalView *view)
void
e_cal_view_start (ECalView *view)
{
+ GError *error = NULL;
ECalViewPrivate *priv;
+
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (E_IS_CAL_VIEW (view));
+
+ priv = E_CAL_VIEW_GET_PRIVATE(view);
+
+ if (priv->view_proxy) {
+ LOCK_VIEW ();
+ org_gnome_evolution_dataserver_calendar_CalView_start (priv->view_proxy, &error);
+ UNLOCK_VIEW ();
+ }
+
+ if (error) {
+ g_warning ("Cannot start cal view: %s\n", error->message);
+
+ /* Fake a sequence-complete so that the application knows this failed */
+ #ifndef E_CAL_DISABLE_DEPRECATED
+ g_signal_emit (view, signals[VIEW_DONE], 0, E_CALENDAR_STATUS_DBUS_EXCEPTION);
+ #endif
+ g_signal_emit (view, signals[VIEW_COMPLETE], 0, E_CALENDAR_STATUS_DBUS_EXCEPTION, error->message);
+
+ g_error_free (error);
+ }
+}
+
+/**
+ * e_cal_view_stop:
+ * @view: A #ECalView object.
+ *
+ * Stops a live query to the calendar/tasks backend.
+ *
+ * Since: 3.0
+ */
+void
+e_cal_view_stop (ECalView *view)
+{
GError *error = NULL;
+ ECalViewPrivate *priv;
g_return_if_fail (view != NULL);
g_return_if_fail (E_IS_CAL_VIEW (view));
priv = E_CAL_VIEW_GET_PRIVATE(view);
- LOCK_VIEW ();
- if (!org_gnome_evolution_dataserver_calendar_CalView_start (priv->view_proxy, &error)) {
+ if (priv->view_proxy) {
+ LOCK_VIEW ();
+ org_gnome_evolution_dataserver_calendar_CalView_stop (priv->view_proxy, &error);
UNLOCK_VIEW ();
- g_printerr("%s: %s\n", G_STRFUNC, error->message);
+ }
+
+ if (error) {
+ g_warning ("Failed to stop view: %s", error->message);
g_error_free (error);
- g_warning (G_STRLOC ": Unable to start view");
- return;
}
- UNLOCK_VIEW ();
}
diff --git a/calendar/libecal/e-cal-view.h b/calendar/libecal/e-cal-view.h
index 4077401..0a3a5a0 100644
--- a/calendar/libecal/e-cal-view.h
+++ b/calendar/libecal/e-cal-view.h
@@ -52,13 +52,17 @@ struct _ECalViewClass {
void (* objects_modified) (ECalView *view, GList *objects);
void (* objects_removed) (ECalView *view, GList *uids);
void (* view_progress) (ECalView *view, gchar *message, gint percent);
+ #ifndef E_CAL_DISABLE_DEPRECATED
void (* view_done) (ECalView *view, ECalendarStatus status);
+ #endif
+ void (* view_complete) (ECalView *view, ECalendarStatus status, const gchar *error_msg);
};
GType e_cal_view_get_type (void);
struct _ECal *e_cal_view_get_client (ECalView *view);
void e_cal_view_start (ECalView *view);
+void e_cal_view_stop (ECalView *view);
G_END_DECLS
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 16f9599..a419e60 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -59,7 +59,11 @@ static GStaticRecMutex connection_lock = G_STATIC_REC_MUTEX_INIT;
G_DEFINE_TYPE(ECal, e_cal, G_TYPE_OBJECT)
#define E_CAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), E_TYPE_CAL, ECalPrivate))
-static gboolean open_calendar (ECal *ecal, gboolean only_if_exists, GError **error, ECalendarStatus *status, gboolean needs_auth, gboolean async);
+static gboolean open_calendar (ECal *ecal, gboolean only_if_exists, GError **error,
+ #ifndef E_CAL_DISABLE_DEPRECATED
+ ECalendarStatus *status,
+ #endif
+ gboolean needs_auth, gboolean async);
static void e_cal_dispose (GObject *object);
static void e_cal_finalize (GObject *object);
@@ -108,7 +112,10 @@ struct _ECalPrivate {
/* Signal IDs */
enum {
+ #ifndef E_CAL_DISABLE_DEPRECATED
CAL_OPENED,
+ #endif
+ CAL_OPENED_EX,
CAL_SET_MODE,
BACKEND_ERROR,
BACKEND_DIED,
@@ -218,7 +225,9 @@ get_status_from_error (GError *error)
{ err ("QueryRefused", E_CALENDAR_STATUS_OTHER_ERROR) },
{ err ("CouldNotCancel", E_CALENDAR_STATUS_COULD_NOT_CANCEL) },
{ err ("OtherError", E_CALENDAR_STATUS_OTHER_ERROR) },
- { err ("InvalidServerVersion", E_CALENDAR_STATUS_INVALID_SERVER_VERSION) }
+ { err ("InvalidServerVersion", E_CALENDAR_STATUS_INVALID_SERVER_VERSION) },
+ { err ("InvalidArg", E_CALENDAR_STATUS_INVALID_ARG) },
+ { err ("NotSupported", E_CALENDAR_STATUS_NOT_SUPPORTED) }
};
#undef err
@@ -241,7 +250,7 @@ get_status_from_error (GError *error)
return error->code;
} else {
/* In this case the error was caused by DBus */
- return E_CALENDAR_STATUS_CORBA_EXCEPTION;
+ return E_CALENDAR_STATUS_DBUS_EXCEPTION;
}
}
@@ -514,6 +523,7 @@ e_cal_class_init (ECalClass *klass)
parent_class = g_type_class_peek_parent (klass);
+ #ifndef E_CAL_DISABLE_DEPRECATED
e_cal_signals[CAL_OPENED] =
g_signal_new ("cal_opened",
G_TYPE_FROM_CLASS (klass),
@@ -522,6 +532,17 @@ e_cal_class_init (ECalClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
+ #endif
+
+ e_cal_signals[CAL_OPENED_EX] =
+ g_signal_new ("cal_opened_ex",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (ECalClass, cal_opened_ex),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
e_cal_signals[CAL_SET_MODE] =
g_signal_new ("cal_set_mode",
G_TYPE_FROM_CLASS (klass),
@@ -550,7 +571,10 @@ e_cal_class_init (ECalClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ #ifndef E_CAL_DISABLE_DEPRECATED
klass->cal_opened = NULL;
+ #endif
+ klass->cal_opened_ex = NULL;
klass->backend_died = NULL;
object_class->dispose = e_cal_dispose;
@@ -639,9 +663,20 @@ e_cal_activate(GError **error)
static gboolean
reopen_with_auth (gpointer data)
{
+ #ifndef E_CAL_DISABLE_DEPRECATED
ECalendarStatus status;
+ #endif
+ GError *error = NULL;
+
+ open_calendar (E_CAL (data), TRUE, &error,
+ #ifndef E_CAL_DISABLE_DEPRECATED
+ &status,
+ #endif
+ TRUE, FALSE);
+
+ if (error)
+ g_error_free (error);
- open_calendar (E_CAL (data), TRUE, NULL, &status, TRUE, FALSE);
return FALSE;
}
@@ -1116,30 +1151,44 @@ static void
async_signal_idle_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
{
ECal *ecal;
+ #ifndef E_CAL_DISABLE_DEPRECATED
ECalendarStatus status;
+ #endif
ecal = E_CAL (user_data);
g_return_if_fail (ecal && E_IS_CAL (ecal));
if (error) {
+ #ifndef E_CAL_DISABLE_DEPRECATED
status = get_status_from_error (error);
+
} else {
status = E_CALENDAR_STATUS_OK;
+ #endif
LOCK_CONN ();
org_gnome_evolution_dataserver_calendar_Cal_is_read_only (ecal->priv->proxy, NULL);
UNLOCK_CONN ();
}
+ #ifndef E_CAL_DISABLE_DEPRECATED
g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED], 0, status);
+ #endif
+ g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED_EX], 0, error);
}
static gboolean
-open_calendar (ECal *ecal, gboolean only_if_exists, GError **error, ECalendarStatus *status, gboolean needs_auth, gboolean async)
+open_calendar (ECal *ecal, gboolean only_if_exists, GError **error,
+ #ifndef E_CAL_DISABLE_DEPRECATED
+ ECalendarStatus *status,
+ #endif
+ gboolean needs_auth, gboolean async)
{
ECalPrivate *priv;
gchar *username = NULL, *auth_type = NULL, *password = NULL;
+ g_return_val_if_fail (error != NULL, FALSE);
+
e_return_error_if_fail (ecal != NULL, E_CALENDAR_STATUS_INVALID_ARG);
e_return_error_if_fail (E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
priv = ecal->priv;
@@ -1158,14 +1207,18 @@ open_calendar (ECal *ecal, gboolean only_if_exists, GError **error, ECalendarSta
if (priv->auth_func == NULL) {
priv->load_state = E_CAL_LOAD_NOT_LOADED;
+ #ifndef E_CAL_DISABLE_DEPRECATED
*status = E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED;
+ #endif
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED, error);
}
username = e_source_get_duped_property (priv->source, "username");
if (!username) {
priv->load_state = E_CAL_LOAD_NOT_LOADED;
+ #ifndef E_CAL_DISABLE_DEPRECATED
*status = E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED;
+ #endif
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED, error);
}
@@ -1192,7 +1245,9 @@ open_calendar (ECal *ecal, gboolean only_if_exists, GError **error, ECalendarSta
if (!key) {
priv->load_state = E_CAL_LOAD_NOT_LOADED;
+ #ifndef E_CAL_DISABLE_DEPRECATED
*status = E_CALENDAR_STATUS_URI_NOT_LOADED;
+ #endif
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED, error);
}
@@ -1200,7 +1255,9 @@ open_calendar (ECal *ecal, gboolean only_if_exists, GError **error, ECalendarSta
if (!password) {
priv->load_state = E_CAL_LOAD_NOT_LOADED;
+ #ifndef E_CAL_DISABLE_DEPRECATED
*status = E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED;
+ #endif
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED, error);
}
@@ -1210,36 +1267,48 @@ open_calendar (ECal *ecal, gboolean only_if_exists, GError **error, ECalendarSta
priv->load_state = E_CAL_LOAD_LOADING;
+ #ifndef E_CAL_DISABLE_DEPRECATED
*status = E_CALENDAR_STATUS_OK;
+ #endif
if (!async) {
LOCK_CONN ();
- if (!org_gnome_evolution_dataserver_calendar_Cal_open (priv->proxy, only_if_exists, username ? username : "", password ? password : "", error))
- *status = E_CALENDAR_STATUS_CORBA_EXCEPTION;
+ if (!org_gnome_evolution_dataserver_calendar_Cal_open (priv->proxy, only_if_exists, username ? username : "", password ? password : "", error)) {
+ #ifndef E_CAL_DISABLE_DEPRECATED
+ *status = E_CALENDAR_STATUS_DBUS_EXCEPTION;
+ #endif
+ }
UNLOCK_CONN ();
} else {
LOCK_CONN ();
- if (!org_gnome_evolution_dataserver_calendar_Cal_open_async (priv->proxy, only_if_exists, username ? username : "", password ? password : "", async_signal_idle_cb, ecal))
- *status = E_CALENDAR_STATUS_CORBA_EXCEPTION;
+ if (!org_gnome_evolution_dataserver_calendar_Cal_open_async (priv->proxy, only_if_exists, username ? username : "", password ? password : "", async_signal_idle_cb, ecal)) {
+ #ifndef E_CAL_DISABLE_DEPRECATED
+ *status = E_CALENDAR_STATUS_DBUS_EXCEPTION;
+ #endif
+ }
UNLOCK_CONN ();
}
g_free (password);
g_free (username);
- if (*status == E_CALENDAR_STATUS_OK) {
- GError *error = NULL;
+ if (!*error) {
priv->load_state = E_CAL_LOAD_LOADED;
if (!async) {
+ GError *err = NULL;
+
LOCK_CONN ();
- org_gnome_evolution_dataserver_calendar_Cal_is_read_only (priv->proxy, &error);
+ org_gnome_evolution_dataserver_calendar_Cal_is_read_only (priv->proxy, &err);
UNLOCK_CONN ();
+
+ if (err)
+ g_error_free (err);
}
} else {
priv->load_state = E_CAL_LOAD_NOT_LOADED;
}
- E_CALENDAR_CHECK_STATUS (*status, error);
+ return *error == NULL;
}
/**
@@ -1253,18 +1322,33 @@ open_calendar (ECal *ecal, gboolean only_if_exists, GError **error, ECalendarSta
*
* Makes a calendar client initiate a request to open a calendar. The calendar
* client will emit the "cal_opened" signal when the response from the server is
- * received.
+ * received. Since 3.0 is emitted also "cal_opened_ex" signal, which contains
+ * a GError pointer from the open operation (NULL when no error occurred).
+ * New signal deprecates the old "cal_opened" signal.
*
* Returns: TRUE on success, FALSE on failure to issue the open request.
**/
gboolean
e_cal_open (ECal *ecal, gboolean only_if_exists, GError **error)
{
+ #ifndef E_CAL_DISABLE_DEPRECATED
ECalendarStatus status;
+ #endif
+ GError *err = NULL;
gboolean result;
- result = open_calendar (ecal, only_if_exists, error, &status, FALSE, FALSE);
+ result = open_calendar (ecal, only_if_exists, &err,
+ #ifndef E_CAL_DISABLE_DEPRECATED
+ &status,
+ #endif
+ FALSE, FALSE);
+ #ifndef E_CAL_DISABLE_DEPRECATED
g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED], 0, status);
+ #endif
+ g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED_EX], 0, err);
+
+ if (err)
+ g_propagate_error (error, err);
return result;
}
@@ -1302,6 +1386,9 @@ idle_async_error_reply_cb (gpointer user_data)
*
* Open the calendar asynchronously. The calendar will emit the
* "cal_opened" signal when the operation has completed.
+ * Since 3.0 is emitted also "cal_opened_ex" signal, which contains
+ * a GError pointer from the open operation (NULL when no error occurred).
+ * New signal deprecates the old "cal_opened" signal.
*
* Because this operation runs in another thread, any authentication
* callback set on the calendar will be called from this other thread.
@@ -1312,7 +1399,9 @@ e_cal_open_async (ECal *ecal, gboolean only_if_exists)
{
ECalPrivate *priv;
GError *error = NULL;
+ #ifndef E_CAL_DISABLE_DEPRECATED
ECalendarStatus status;
+ #endif
g_return_if_fail (ecal != NULL);
g_return_if_fail (E_IS_CAL (ecal));
@@ -1322,17 +1411,31 @@ e_cal_open_async (ECal *ecal, gboolean only_if_exists)
switch (priv->load_state) {
case E_CAL_LOAD_AUTHENTICATING :
case E_CAL_LOAD_LOADING :
+ #ifndef E_CAL_DISABLE_DEPRECATED
g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED], 0, E_CALENDAR_STATUS_BUSY);
+ #endif
+
+ error = g_error_new_literal (E_CALENDAR_ERROR, E_CALENDAR_STATUS_BUSY, e_cal_get_error_message (E_CALENDAR_STATUS_BUSY));
+ g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED_EX], 0, error);
+ g_error_free (error);
return;
case E_CAL_LOAD_LOADED :
+ #ifndef E_CAL_DISABLE_DEPRECATED
g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED], 0, E_CALENDAR_STATUS_OK);
+ #endif
+
+ g_signal_emit (G_OBJECT (ecal), e_cal_signals[CAL_OPENED_EX], 0, NULL);
return;
default:
/* ignore everything else */
break;
}
- open_calendar (ecal, only_if_exists, &error, &status, FALSE, TRUE);
+ open_calendar (ecal, only_if_exists, &error,
+ #ifndef E_CAL_DISABLE_DEPRECATED
+ &status,
+ #endif
+ FALSE, TRUE);
if (error) {
struct idle_async_error_reply_data *data;
@@ -1366,7 +1469,7 @@ e_cal_refresh (ECal *ecal, GError **error)
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_refresh (priv->proxy, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -1394,7 +1497,7 @@ e_cal_remove (ECal *ecal, GError **error)
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_remove (priv->proxy, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -1635,7 +1738,7 @@ e_cal_get_cal_address (ECal *ecal, gchar **cal_address, GError **error)
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_cal_address (priv->proxy, cal_address, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
} else {
@@ -1674,7 +1777,7 @@ e_cal_get_alarm_email_address (ECal *ecal, gchar **alarm_address, GError **error
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_alarm_email_address (priv->proxy, alarm_address, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -1710,7 +1813,7 @@ e_cal_get_ldap_attribute (ECal *ecal, gchar **ldap_attribute, GError **error)
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_ldap_attribute (priv->proxy, ldap_attribute, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -1735,7 +1838,7 @@ load_static_capabilities (ECal *ecal, GError **error)
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_scheduling_information (priv->proxy, &priv->capabilities, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -1960,7 +2063,7 @@ e_cal_get_default_object (ECal *ecal, icalcomponent **icalcomp, GError **error)
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_default_object (priv->proxy, &object, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -2014,7 +2117,7 @@ e_cal_get_attachments_for_comp (ECal *ecal, const gchar *uid, const gchar *rid,
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_attachment_list (priv->proxy, uid, rid ? rid: "", &list_array, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -2067,7 +2170,7 @@ e_cal_get_object (ECal *ecal, const gchar *uid, const gchar *rid, icalcomponent
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_object (priv->proxy, uid, rid ? rid : "", &object, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -2147,7 +2250,7 @@ e_cal_get_objects_for_uid (ECal *ecal, const gchar *uid, GList **objects, GError
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_object (priv->proxy, uid, "", &object, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -2265,7 +2368,7 @@ e_cal_get_changes (ECal *ecal, const gchar *change_id, GList **changes, GError *
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_changes (priv->proxy, change_id, &additions, &modifications, &removals, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -2375,7 +2478,7 @@ e_cal_get_object_list (ECal *ecal, const gchar *query, GList **objects, GError *
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_object_list (priv->proxy, query, &object_array, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -2527,7 +2630,7 @@ e_cal_get_free_busy (ECal *ecal, GList *users, time_t start, time_t end,
if (!org_gnome_evolution_dataserver_calendar_Cal_get_free_busy (priv->proxy, (const gchar **)users_list, start, end, &freebusy_array, error)) {
UNLOCK_CONN ();
g_strfreev (users_list);
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
g_strfreev (users_list);
@@ -3262,7 +3365,7 @@ e_cal_discard_alarm (ECal *ecal, ECalComponent *comp, const gchar *auid, GError
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_discard_alarm (priv->proxy, uid, auid, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -3469,7 +3572,7 @@ e_cal_create_object (ECal *ecal, icalcomponent *icalcomp, gchar **uid, GError **
if (!org_gnome_evolution_dataserver_calendar_Cal_create_object (priv->proxy, obj, &muid, error)) {
UNLOCK_CONN ();
g_free (obj);
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -3528,7 +3631,7 @@ e_cal_modify_object (ECal *ecal, icalcomponent *icalcomp, CalObjModType mod, GEr
if (!org_gnome_evolution_dataserver_calendar_Cal_modify_object (priv->proxy, obj, mod, error)) {
UNLOCK_CONN ();
g_free (obj);
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -3574,7 +3677,7 @@ e_cal_remove_object_with_mod (ECal *ecal, const gchar *uid,
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_remove_object (priv->proxy, uid, rid ? rid : "", mod, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -3632,7 +3735,7 @@ e_cal_receive_objects (ECal *ecal, icalcomponent *icalcomp, GError **error)
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_receive_objects (priv->proxy, icalcomponent_as_ical_string (icalcomp), error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -3678,7 +3781,7 @@ e_cal_send_objects (ECal *ecal, icalcomponent *icalcomp, GList **users, icalcomp
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_send_objects (priv->proxy, icalcomponent_as_ical_string (icalcomp), &users_array, &object, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -3759,7 +3862,7 @@ e_cal_get_timezone (ECal *ecal, const gchar *tzid, icaltimezone **zone, GError *
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_timezone (priv->proxy, tzid, &object, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -3858,7 +3961,7 @@ e_cal_add_timezone (ECal *ecal, icaltimezone *izone, GError **error)
if (!org_gnome_evolution_dataserver_calendar_Cal_add_timezone (priv->proxy, tzobj, error)) {
UNLOCK_CONN ();
g_free (tzobj);
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -3900,7 +4003,7 @@ e_cal_get_query (ECal *ecal, const gchar *sexp, ECalView **query, GError **error
LOCK_CONN ();
if (!org_gnome_evolution_dataserver_calendar_Cal_get_query (priv->proxy, sexp, &query_path, error)) {
UNLOCK_CONN ();
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -3965,7 +4068,7 @@ e_cal_set_default_timezone (ECal *ecal, icaltimezone *zone, GError **error)
if (!org_gnome_evolution_dataserver_calendar_Cal_set_default_timezone (priv->proxy, tzobj, error)) {
UNLOCK_CONN ();
g_free (tzobj);
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_DBUS_EXCEPTION, error);
}
UNLOCK_CONN ();
@@ -4019,12 +4122,14 @@ e_cal_get_error_message (ECalendarStatus status)
return _("Authentication failed");
case E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED :
return _("Authentication required");
- case E_CALENDAR_STATUS_CORBA_EXCEPTION :
- return _("A CORBA exception has occurred");
+ case E_CALENDAR_STATUS_DBUS_EXCEPTION :
+ return _("A DBUS exception has occurred");
case E_CALENDAR_STATUS_OTHER_ERROR :
return _("Unknown error");
case E_CALENDAR_STATUS_OK :
return _("No error");
+ case E_CALENDAR_STATUS_NOT_SUPPORTED :
+ return _("Not supported");
default:
/* ignore everything else */
break;
diff --git a/calendar/libecal/e-cal.h b/calendar/libecal/e-cal.h
index e088899..ead68c6 100644
--- a/calendar/libecal/e-cal.h
+++ b/calendar/libecal/e-cal.h
@@ -81,7 +81,10 @@ struct _ECalClass {
/* Notification signals */
+ #ifndef E_CAL_DISABLE_DEPRECATED
void (* cal_opened) (ECal *ecal, ECalendarStatus status);
+ #endif
+ void (* cal_opened_ex) (ECal *ecal, const GError *error);
void (* cal_set_mode) (ECal *ecal, ECalSetModeStatus status, CalMode mode);
void (* backend_error) (ECal *ecal, const gchar *message);
diff --git a/calendar/libedata-cal/e-cal-backend-sync.c b/calendar/libedata-cal/e-cal-backend-sync.c
index 2bc6741..a598b17 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.c
+++ b/calendar/libedata-cal/e-cal-backend-sync.c
@@ -25,10 +25,9 @@ struct _ECalBackendSyncPrivate {
g_assert (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->func); \
if (backend->priv->mutex_lock) \
g_mutex_lock (backend->priv->sync_mutex); \
- status = (* E_CAL_BACKEND_SYNC_GET_CLASS (backend)->func) args; \
+ (* E_CAL_BACKEND_SYNC_GET_CLASS (backend)->func) args; \
if (backend->priv->mutex_lock) \
g_mutex_unlock (backend->priv->sync_mutex); \
- return status;
static GObjectClass *parent_class;
@@ -55,22 +54,17 @@ e_cal_backend_sync_set_lock (ECalBackendSync *backend, gboolean lock)
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
* @read_only: Return value for read-only status.
+ * @error: Out parameter for a #GError.
*
* Calls the is_read_only method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
+void
+e_cal_backend_sync_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (read_only, GNOME_Evolution_Calendar_OtherError);
-
- LOCK_WRAPPER (is_read_only_sync, (backend, cal, read_only));
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (read_only, InvalidArg);
- return status;
+ LOCK_WRAPPER (is_read_only_sync, (backend, cal, read_only, error));
}
/**
@@ -78,22 +72,17 @@ e_cal_backend_sync_is_read_only (ECalBackendSync *backend, EDataCal *cal, gbool
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
* @address: Return value for the address.
+ * @error: Out parameter for a #GError.
*
* Calls the get_cal_address method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+void
+e_cal_backend_sync_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (address, GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (address, InvalidArg);
- LOCK_WRAPPER (get_cal_address_sync, (backend, cal, address));
-
- return status;
+ LOCK_WRAPPER (get_cal_address_sync, (backend, cal, address, error));
}
/**
@@ -101,22 +90,17 @@ e_cal_backend_sync_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gc
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
* @address: Return value for the address.
+ * @error: Out parameter for a #GError.
*
* Calls the get_alarm_email_address method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
+void
+e_cal_backend_sync_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **error)
{
- ECalBackendSyncStatus status;
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (address, InvalidArg);
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (address, GNOME_Evolution_Calendar_OtherError);
-
- LOCK_WRAPPER (get_alarm_email_address_sync, (backend, cal, address));
-
- return status;
+ LOCK_WRAPPER (get_alarm_email_address_sync, (backend, cal, address, error));
}
/**
@@ -124,22 +108,17 @@ e_cal_backend_sync_get_alarm_email_address (ECalBackendSync *backend, EDataCal
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
* @attribute: Return value for LDAP attribute.
+ * @error: Out parameter for a #GError.
*
* Calls the get_ldap_attribute method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute)
+void
+e_cal_backend_sync_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (attribute, GNOME_Evolution_Calendar_OtherError);
-
- LOCK_WRAPPER (get_ldap_attribute_sync, (backend, cal, attribute));
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (attribute, InvalidArg);
- return status;
+ LOCK_WRAPPER (get_ldap_attribute_sync, (backend, cal, attribute, error));
}
/**
@@ -147,22 +126,17 @@ e_cal_backend_sync_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal,
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
* @capabilities: Return value for capabilities.
+ * @error: Out parameter for a #GError.
*
* Calls the get_capabilities method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities)
+void
+e_cal_backend_sync_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (capabilities, GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (capabilities, InvalidArg);
- LOCK_WRAPPER (get_static_capabilities_sync, (backend, cal, capabilities));
-
- return status;
+ LOCK_WRAPPER (get_static_capabilities_sync, (backend, cal, capabilities, error));
}
/**
@@ -173,68 +147,52 @@ e_cal_backend_sync_get_static_capabilities (ECalBackendSync *backend, EDataCal
* or just create it when it does not exist.
* @username: User name to use for authentication.
* @password: Password to use for authentication.
+ * @error: Out parameter for a #GError.
*
* Calls the open method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
+void
e_cal_backend_sync_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
- const gchar *username, const gchar *password)
+ const gchar *username, const gchar *password, GError **error)
{
- ECalBackendSyncStatus status;
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
-
- LOCK_WRAPPER (open_sync, (backend, cal, only_if_exists, username, password));
-
- return status;
+ LOCK_WRAPPER (open_sync, (backend, cal, only_if_exists, username, password, error));
}
/**
* e_cal_backend_sync_remove:
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
+ * @error: Out parameter for a #GError.
*
* Calls the remove method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_remove (ECalBackendSync *backend, EDataCal *cal)
+void
+e_cal_backend_sync_remove (ECalBackendSync *backend, EDataCal *cal, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
- LOCK_WRAPPER (remove_sync, (backend, cal));
-
- return status;
+ LOCK_WRAPPER (remove_sync, (backend, cal, error));
}
/**
* e_cal_backend_sync_refresh:
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
+ * @error: Out parameter for a #GError.
*
* Calls the refresh method on the given backend.
*
- * Returns: Status code.
- *
* Since: 2.30
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_refresh (ECalBackendSync *backend, EDataCal *cal)
+void
+e_cal_backend_sync_refresh (ECalBackendSync *backend, EDataCal *cal, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->refresh_sync != NULL,
- GNOME_Evolution_Calendar_UnsupportedMethod);
-
- LOCK_WRAPPER (refresh_sync, (backend, cal));
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->refresh_sync != NULL, UnsupportedMethod);
- return status;
+ LOCK_WRAPPER (refresh_sync, (backend, cal, error));
}
/**
@@ -243,23 +201,17 @@ e_cal_backend_sync_refresh (ECalBackendSync *backend, EDataCal *cal)
* @cal: An EDataCal object.
* @calobj: The object to be added.
* @uid: Placeholder for server-generated UID.
+ * @error: Out parameter for a #GError.
*
* Calls the create_object method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid)
+void
+e_cal_backend_sync_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->create_object_sync != NULL,
- GNOME_Evolution_Calendar_UnsupportedMethod);
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->create_object_sync != NULL, UnsupportedMethod);
- LOCK_WRAPPER (create_object_sync, (backend, cal, calobj, uid));
-
- return status;
+ LOCK_WRAPPER (create_object_sync, (backend, cal, calobj, uid, error));
}
/**
@@ -272,24 +224,18 @@ e_cal_backend_sync_create_object (ECalBackendSync *backend, EDataCal *cal, gchar
* backend.
* @new_object: Placeholder for returning the new object as it has been stored
* on the backend.
+ * @error: Out parameter for a #GError.
*
* Calls the modify_object method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
+void
e_cal_backend_sync_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)
{
- ECalBackendSyncStatus status;
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->modify_object_sync != NULL, UnsupportedMethod);
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->modify_object_sync != NULL,
- GNOME_Evolution_Calendar_UnsupportedMethod);
-
- LOCK_WRAPPER (modify_object_sync, (backend, cal, calobj, mod, old_object, new_object));
-
- return status;
+ LOCK_WRAPPER (modify_object_sync, (backend, cal, calobj, mod, old_object, new_object, error));
}
/**
@@ -305,24 +251,18 @@ e_cal_backend_sync_modify_object (ECalBackendSync *backend, EDataCal *cal, const
* @object: Placeholder for returning the object after it has been modified (when
* removing individual instances). If removing the whole object, this will be
* NULL.
+ * @error: Out parameter for a #GError.
*
* Calls the remove_object method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
+void
e_cal_backend_sync_remove_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid,
- CalObjModType mod, gchar **old_object, gchar **object)
+ CalObjModType mod, gchar **old_object, gchar **object, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_object_sync != NULL,
- GNOME_Evolution_Calendar_UnsupportedMethod);
-
- LOCK_WRAPPER (remove_object_sync, (backend, cal, uid, rid, mod, old_object, object));
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_object_sync != NULL, UnsupportedMethod);
- return status;
+ LOCK_WRAPPER (remove_object_sync, (backend, cal, uid, rid, mod, old_object, object, error));
}
/**
@@ -331,23 +271,17 @@ e_cal_backend_sync_remove_object (ECalBackendSync *backend, EDataCal *cal, const
* @cal: An EDataCal object.
* @uid: UID of the object to discard the alarm from.
* @auid: UID of the alarm to be discarded.
+ * @error: Out parameter for a #GError.
*
* Calls the discard_alarm method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid)
+void
+e_cal_backend_sync_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->discard_alarm_sync != NULL,
- GNOME_Evolution_Calendar_UnsupportedMethod);
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->discard_alarm_sync != NULL, UnsupportedMethod);
- LOCK_WRAPPER (discard_alarm_sync, (backend, cal, uid, auid));
-
- return status;
+ LOCK_WRAPPER (discard_alarm_sync, (backend, cal, uid, auid, error));
}
/**
@@ -355,23 +289,17 @@ e_cal_backend_sync_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
* @calobj: iCalendar object to receive.
+ * @error: Out parameter for a #GError.
*
* Calls the receive_objects method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj)
+void
+e_cal_backend_sync_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GError **error)
{
- ECalBackendSyncStatus status;
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->receive_objects_sync != NULL, UnsupportedMethod);
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->receive_objects_sync != NULL,
- GNOME_Evolution_Calendar_UnsupportedMethod);
-
- LOCK_WRAPPER (receive_objects_sync, (backend, cal, calobj));
-
- return status;
+ LOCK_WRAPPER (receive_objects_sync, (backend, cal, calobj, error));
}
/**
@@ -381,24 +309,18 @@ e_cal_backend_sync_receive_objects (ECalBackendSync *backend, EDataCal *cal, con
* @calobj: The iCalendar object to send.
* @users: List of users to send notifications to.
* @modified_calobj: Placeholder for the iCalendar object after being modified.
+ * @error: Out parameter for a #GError.
*
* Calls the send_objects method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
+void
e_cal_backend_sync_send_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GList **users,
- gchar **modified_calobj)
+ gchar **modified_calobj, GError **error)
{
- ECalBackendSyncStatus status;
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->send_objects_sync != NULL, UnsupportedMethod);
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->send_objects_sync != NULL,
- GNOME_Evolution_Calendar_UnsupportedMethod);
-
- LOCK_WRAPPER (send_objects_sync, (backend, cal, calobj, users, modified_calobj));
-
- return status;
+ LOCK_WRAPPER (send_objects_sync, (backend, cal, calobj, users, modified_calobj, error));
}
/**
@@ -406,22 +328,17 @@ e_cal_backend_sync_send_objects (ECalBackendSync *backend, EDataCal *cal, const
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
* @object: Placeholder for returned object.
+ * @error: Out parameter for a #GError.
*
* Calls the get_default_object method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object)
+void
+e_cal_backend_sync_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (object, GNOME_Evolution_Calendar_OtherError);
-
- LOCK_WRAPPER (get_default_object_sync, (backend, cal, object));
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (object, InvalidArg);
- return status;
+ LOCK_WRAPPER (get_default_object_sync, (backend, cal, object, error));
}
/**
@@ -432,22 +349,17 @@ e_cal_backend_sync_get_default_object (ECalBackendSync *backend, EDataCal *cal,
* @rid: Recurrence ID of the specific instance to get, or NULL if getting the
* master object.
* @object: Placeholder for returned object.
+ * @error: Out parameter for a #GError.
*
* Calls the get_object method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object)
+void
+e_cal_backend_sync_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (object, GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (object, InvalidArg);
- LOCK_WRAPPER (get_object_sync, (backend, cal, uid, rid, object));
-
- return status;
+ LOCK_WRAPPER (get_object_sync, (backend, cal, uid, rid, object, error));
}
/**
@@ -456,22 +368,17 @@ e_cal_backend_sync_get_object (ECalBackendSync *backend, EDataCal *cal, const gc
* @cal: An EDataCal object.
* @sexp: Search query.
* @objects: Placeholder for list of returned objects.
+ * @error: Out parameter for a #GError.
*
* Calls the get_object_list method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects)
+void
+e_cal_backend_sync_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects, GError **error)
{
- ECalBackendSyncStatus status;
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (objects, InvalidArg);
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (objects, GNOME_Evolution_Calendar_OtherError);
-
- LOCK_WRAPPER (get_object_list_sync, (backend, cal, sexp, objects));
-
- return status;
+ LOCK_WRAPPER (get_object_list_sync, (backend, cal, sexp, objects, error));
}
/**
@@ -481,22 +388,17 @@ e_cal_backend_sync_get_object_list (ECalBackendSync *backend, EDataCal *cal, con
* @uid: Unique id of the calendar object.
* @rid: Recurrence id of the calendar object.
* @attachments: Placeholder for list of returned attachment uris.
+ * @error: Out parameter for a #GError.
*
* Calls the get_attachment_list method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, GSList **attachments)
+void
+e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, GSList **attachments, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
- g_return_val_if_fail (attachments, GNOME_Evolution_Calendar_OtherError);
-
- LOCK_WRAPPER (get_attachment_list_sync, (backend, cal, uid, rid, attachments));
+ e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (attachments, InvalidArg);
- return status;
+ LOCK_WRAPPER (get_attachment_list_sync, (backend, cal, uid, rid, attachments, error));
}
/**
@@ -505,6 +407,7 @@ e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend, EDataCal *cal,
* @cal: An EDataCal object.
* @tzid: ID of the timezone to retrieve.
* @object: Placeholder for the returned timezone.
+ * @error: Out parameter for a #GError.
*
* Calls the get_timezone_sync method on the given backend.
* This method is not mandatory on the backend, because here
@@ -513,18 +416,14 @@ e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend, EDataCal *cal,
* any object deriving from ECalBackendSync can implement only
* internal_get_timezone and can skip implementation of
* get_timezone_sync completely.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object)
+void
+e_cal_backend_sync_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object, GError **error)
{
- ECalBackendSyncStatus status = GNOME_Evolution_Calendar_ObjectNotFound;
-
- g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
if (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->get_timezone_sync) {
- LOCK_WRAPPER (get_timezone_sync, (backend, cal, tzid, object));
+ LOCK_WRAPPER (get_timezone_sync, (backend, cal, tzid, object, error));
}
if (object && !*object) {
@@ -537,22 +436,20 @@ e_cal_backend_sync_get_timezone (ECalBackendSync *backend, EDataCal *cal, const
g_mutex_unlock (backend->priv->sync_mutex);
if (!zone) {
- status = GNOME_Evolution_Calendar_ObjectNotFound;
+ g_propagate_error (error, e_data_cal_create_error (ObjectNotFound, NULL));
} else {
icalcomponent *icalcomp;
icalcomp = icaltimezone_get_component (zone);
if (!icalcomp) {
- status = GNOME_Evolution_Calendar_InvalidObject;
+ g_propagate_error (error, e_data_cal_create_error (InvalidObject, NULL));
} else {
*object = icalcomponent_as_ical_string_r (icalcomp);
- status = GNOME_Evolution_Calendar_Success;
+ g_propagate_error (error, e_data_cal_create_error (Success, NULL));
}
}
}
-
- return status;
}
/**
@@ -560,21 +457,16 @@ e_cal_backend_sync_get_timezone (ECalBackendSync *backend, EDataCal *cal, const
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
* @tzobj: VTIMEZONE object to be added.
+ * @error: Out parameter for a #GError.
*
* Calls the add_timezone method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
+void
+e_cal_backend_sync_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
{
- ECalBackendSyncStatus status;
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
- g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
-
- LOCK_WRAPPER (add_timezone_sync, (backend, cal, tzobj));
-
- return status;
+ LOCK_WRAPPER (add_timezone_sync, (backend, cal, tzobj, error));
}
/**
@@ -582,17 +474,14 @@ e_cal_backend_sync_add_timezone (ECalBackendSync *backend, EDataCal *cal, const
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
* @tz: Timezone object as string.
+ * @error: Out parameter for a #GError.
*
* Calls the set_default_timezone method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tz)
+void
+e_cal_backend_sync_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tz, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
/* Old backends might be using the set_default_timezone */
if (!E_CAL_BACKEND_SYNC_GET_CLASS (backend)->set_default_zone_sync) {
@@ -605,16 +494,12 @@ e_cal_backend_sync_set_default_zone (ECalBackendSync *backend, EDataCal *cal, co
tzid = icaltimezone_get_tzid (zone);
}
- LOCK_WRAPPER (set_default_timezone_sync, (backend, cal, tzid));
+ LOCK_WRAPPER (set_default_timezone_sync, (backend, cal, tzid, error));
icaltimezone_free (zone, 1);
-
- return status;
+ } else {
+ LOCK_WRAPPER (set_default_zone_sync, (backend, cal, tz, error));
}
-
- LOCK_WRAPPER (set_default_zone_sync, (backend, cal, tz));
-
- return status;
}
/**
@@ -626,21 +511,16 @@ e_cal_backend_sync_set_default_zone (ECalBackendSync *backend, EDataCal *cal, co
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
* @tzid: ID of the timezone to be set as default.
+ * @error: Out parameter for a #GError.
*
* Calls the set_default_timezone method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
-e_cal_backend_sync_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid)
+void
+e_cal_backend_sync_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
-
- LOCK_WRAPPER (set_default_timezone_sync, (backend, cal, tzid));
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
- return status;
+ LOCK_WRAPPER (set_default_timezone_sync, (backend, cal, tzid, error));
}
/**
@@ -651,22 +531,17 @@ e_cal_backend_sync_set_default_timezone (ECalBackendSync *backend, EDataCal *cal
* @adds: Placeholder for list of additions.
* @modifies: Placeholder for list of modifications.
* @deletes: Placeholder for list of deletions.
+ * @error: Out parameter for a #GError.
*
* Calls the get_changes method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
+void
e_cal_backend_sync_get_changes (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id,
- GList **adds, GList **modifies, GList **deletes)
+ GList **adds, GList **modifies, GList **deletes, GError **error)
{
- ECalBackendSyncStatus status;
-
- g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
- LOCK_WRAPPER (get_changes_sync, (backend, cal, change_id, adds, modifies, deletes));
-
- return status;
+ LOCK_WRAPPER (get_changes_sync, (backend, cal, change_id, adds, modifies, deletes, error));
}
/**
@@ -677,44 +552,39 @@ e_cal_backend_sync_get_changes (ECalBackendSync *backend, EDataCal *cal, const g
* @start: Time range start.
* @end: Time range end.
* @freebusy: Placeholder for F/B information.
+ * @error: Out parameter for a #GError.
*
* Calls the get_free_busy method on the given backend.
- *
- * Returns: Status code.
*/
-ECalBackendSyncStatus
+void
e_cal_backend_sync_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users,
- time_t start, time_t end, GList **freebusy)
+ time_t start, time_t end, GList **freebusy, GError **error)
{
- ECalBackendSyncStatus status;
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
- g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
-
- LOCK_WRAPPER (get_freebusy_sync, (backend, cal, users, start, end, freebusy));
-
- return status;
+ LOCK_WRAPPER (get_freebusy_sync, (backend, cal, users, start, end, freebusy, error));
}
static void
_e_cal_backend_is_read_only (ECalBackend *backend, EDataCal *cal)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
gboolean read_only = TRUE;
- status = e_cal_backend_sync_is_read_only (E_CAL_BACKEND_SYNC (backend), cal, &read_only);
+ e_cal_backend_sync_is_read_only (E_CAL_BACKEND_SYNC (backend), cal, &read_only, &error);
- e_data_cal_notify_read_only (cal, status, read_only);
+ e_data_cal_notify_read_only (cal, error, read_only);
}
static void
_e_cal_backend_get_cal_address (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
gchar *address = NULL;
- status = e_cal_backend_sync_get_cal_address (E_CAL_BACKEND_SYNC (backend), cal, &address);
+ e_cal_backend_sync_get_cal_address (E_CAL_BACKEND_SYNC (backend), cal, &address, &error);
- e_data_cal_notify_cal_address (cal, context, status, address);
+ e_data_cal_notify_cal_address (cal, context, error, address);
g_free (address);
}
@@ -722,12 +592,12 @@ _e_cal_backend_get_cal_address (ECalBackend *backend, EDataCal *cal, EServerMeth
static void
_e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
gchar *address = NULL;
- status = e_cal_backend_sync_get_alarm_email_address (E_CAL_BACKEND_SYNC (backend), cal, &address);
+ e_cal_backend_sync_get_alarm_email_address (E_CAL_BACKEND_SYNC (backend), cal, &address, &error);
- e_data_cal_notify_alarm_email_address (cal, context, status, address);
+ e_data_cal_notify_alarm_email_address (cal, context, error, address);
g_free (address);
}
@@ -735,12 +605,12 @@ _e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal, ESe
static void
_e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
gchar *attribute = NULL;
- status = e_cal_backend_sync_get_ldap_attribute (E_CAL_BACKEND_SYNC (backend), cal, &attribute);
+ e_cal_backend_sync_get_ldap_attribute (E_CAL_BACKEND_SYNC (backend), cal, &attribute, &error);
- e_data_cal_notify_ldap_attribute (cal, context, status, attribute);
+ e_data_cal_notify_ldap_attribute (cal, context, error, attribute);
g_free (attribute);
}
@@ -748,12 +618,12 @@ _e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal, EServerM
static void
_e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
gchar *capabilities = NULL;
- status = e_cal_backend_sync_get_static_capabilities (E_CAL_BACKEND_SYNC (backend), cal, &capabilities);
+ e_cal_backend_sync_get_static_capabilities (E_CAL_BACKEND_SYNC (backend), cal, &capabilities, &error);
- e_data_cal_notify_static_capabilities (cal, context, status, capabilities);
+ e_data_cal_notify_static_capabilities (cal, context, error, capabilities);
g_free (capabilities);
}
@@ -762,42 +632,42 @@ static void
_e_cal_backend_open (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, gboolean only_if_exists,
const gchar *username, const gchar *password)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
- status = e_cal_backend_sync_open (E_CAL_BACKEND_SYNC (backend), cal, only_if_exists, username, password);
+ e_cal_backend_sync_open (E_CAL_BACKEND_SYNC (backend), cal, only_if_exists, username, password, &error);
- e_data_cal_notify_open (cal, context, status);
+ e_data_cal_notify_open (cal, context, error);
}
static void
_e_cal_backend_refresh (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
- status = e_cal_backend_sync_refresh (E_CAL_BACKEND_SYNC (backend), cal);
+ e_cal_backend_sync_refresh (E_CAL_BACKEND_SYNC (backend), cal, &error);
- e_data_cal_notify_refresh (cal, context, status);
+ e_data_cal_notify_refresh (cal, context, error);
}
static void
_e_cal_backend_remove (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
- status = e_cal_backend_sync_remove (E_CAL_BACKEND_SYNC (backend), cal);
+ e_cal_backend_sync_remove (E_CAL_BACKEND_SYNC (backend), cal, &error);
- e_data_cal_notify_remove (cal, context, status);
+ e_data_cal_notify_remove (cal, context, error);
}
static void
_e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
gchar *uid = NULL, *modified_calobj = (gchar *) calobj;
- status = e_cal_backend_sync_create_object (E_CAL_BACKEND_SYNC (backend), cal, &modified_calobj, &uid);
+ e_cal_backend_sync_create_object (E_CAL_BACKEND_SYNC (backend), cal, &modified_calobj, &uid, &error);
- e_data_cal_notify_object_created (cal, context, status, uid, modified_calobj);
+ e_data_cal_notify_object_created (cal, context, error, uid, modified_calobj);
/* free memory */
if (uid)
@@ -810,17 +680,17 @@ _e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, EServerMethod
static void
_e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj, CalObjModType mod)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
gchar *old_object = NULL;
gchar *new_object = NULL;
- status = e_cal_backend_sync_modify_object (E_CAL_BACKEND_SYNC (backend), cal,
- calobj, mod, &old_object, &new_object);
+ e_cal_backend_sync_modify_object (E_CAL_BACKEND_SYNC (backend), cal,
+ calobj, mod, &old_object, &new_object, &error);
if (new_object)
- e_data_cal_notify_object_modified (cal, context, status, old_object, new_object);
+ e_data_cal_notify_object_modified (cal, context, error, old_object, new_object);
else
- e_data_cal_notify_object_modified (cal, context, status, old_object, calobj);
+ e_data_cal_notify_object_modified (cal, context, error, old_object, calobj);
g_free (old_object);
g_free (new_object);
@@ -829,13 +699,12 @@ _e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, EServerMethod
static void
_e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid, CalObjModType mod)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
gchar *object = NULL, *old_object = NULL;
- status = e_cal_backend_sync_remove_object (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, mod, &old_object, &object);
-
- if (status == GNOME_Evolution_Calendar_Success) {
+ e_cal_backend_sync_remove_object (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, mod, &old_object, &object, &error);
+ if (!error) {
ECalComponentId *id = g_new0 (ECalComponentId, 1);
id->uid = g_strdup (uid);
@@ -843,13 +712,13 @@ _e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, EServerMethod
id->rid = g_strdup (rid);
if (!object)
- e_data_cal_notify_object_removed (cal, context, status, id, old_object, object);
+ e_data_cal_notify_object_removed (cal, context, error, id, old_object, object);
else
- e_data_cal_notify_object_modified (cal, context, status, old_object, object);
+ e_data_cal_notify_object_modified (cal, context, error, old_object, object);
e_cal_component_free_id (id);
} else
- e_data_cal_notify_object_removed (cal, context, status, NULL, old_object, object);
+ e_data_cal_notify_object_removed (cal, context, error, NULL, old_object, object);
g_free (old_object);
g_free (object);
@@ -858,32 +727,32 @@ _e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, EServerMethod
static void
_e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *auid)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
- status = e_cal_backend_sync_discard_alarm (E_CAL_BACKEND_SYNC (backend), cal, uid, auid);
+ e_cal_backend_sync_discard_alarm (E_CAL_BACKEND_SYNC (backend), cal, uid, auid, &error);
- e_data_cal_notify_alarm_discarded (cal, context, status);
+ e_data_cal_notify_alarm_discarded (cal, context, error);
}
static void
_e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
- status = e_cal_backend_sync_receive_objects (E_CAL_BACKEND_SYNC (backend), cal, calobj);
+ e_cal_backend_sync_receive_objects (E_CAL_BACKEND_SYNC (backend), cal, calobj, &error);
- e_data_cal_notify_objects_received (cal, context, status);
+ e_data_cal_notify_objects_received (cal, context, error);
}
static void
_e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
GList *users = NULL;
gchar *modified_calobj = NULL;
- status = e_cal_backend_sync_send_objects (E_CAL_BACKEND_SYNC (backend), cal, calobj, &users, &modified_calobj);
- e_data_cal_notify_objects_sent (cal, context, status, users, modified_calobj);
+ e_cal_backend_sync_send_objects (E_CAL_BACKEND_SYNC (backend), cal, calobj, &users, &modified_calobj, &error);
+ e_data_cal_notify_objects_sent (cal, context, error, users, modified_calobj);
g_list_foreach (users, (GFunc) g_free, NULL);
g_list_free (users);
@@ -893,12 +762,12 @@ _e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, EServerMethodC
static void
_e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
gchar *object = NULL;
- status = e_cal_backend_sync_get_default_object (E_CAL_BACKEND_SYNC (backend), cal, &object);
+ e_cal_backend_sync_get_default_object (E_CAL_BACKEND_SYNC (backend), cal, &object, &error);
- e_data_cal_notify_default_object (cal, context, status, object);
+ e_data_cal_notify_default_object (cal, context, error, object);
g_free (object);
}
@@ -906,12 +775,12 @@ _e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal, EServerM
static void
_e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
gchar *object = NULL;
- status = e_cal_backend_sync_get_object (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, &object);
+ e_cal_backend_sync_get_object (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, &object, &error);
- e_data_cal_notify_object (cal, context, status, object);
+ e_data_cal_notify_object (cal, context, error, object);
g_free (object);
}
@@ -919,12 +788,12 @@ _e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, EServerMethodCon
static void
_e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
GSList *list = NULL;
- status = e_cal_backend_sync_get_attachment_list (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, &list);
+ e_cal_backend_sync_get_attachment_list (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, &list, &error);
- e_data_cal_notify_attachment_list (cal, context, status, list);
+ e_data_cal_notify_attachment_list (cal, context, error, list);
g_slist_foreach (list, (GFunc) g_free, NULL);
g_free (list);
@@ -933,12 +802,12 @@ _e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, EServer
static void
_e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *sexp)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
GList *objects = NULL, *l;
- status = e_cal_backend_sync_get_object_list (E_CAL_BACKEND_SYNC (backend), cal, sexp, &objects);
+ e_cal_backend_sync_get_object_list (E_CAL_BACKEND_SYNC (backend), cal, sexp, &objects, &error);
- e_data_cal_notify_object_list (cal, context, status, objects);
+ e_data_cal_notify_object_list (cal, context, error, objects);
for (l = objects; l; l = l->next)
g_free (l->data);
@@ -948,10 +817,10 @@ _e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, EServerMeth
static void
_e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
gchar *object = NULL;
- status = e_cal_backend_sync_get_timezone (E_CAL_BACKEND_SYNC (backend), cal, tzid, &object);
+ e_cal_backend_sync_get_timezone (E_CAL_BACKEND_SYNC (backend), cal, tzid, &object, &error);
if (!object && tzid) {
/* fallback if tzid contains only the location of timezone */
@@ -985,7 +854,7 @@ _e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodC
icalproperty_set_tzid (prop, tzid);
object = icalcomponent_as_ical_string_r (clone);
- status = GNOME_Evolution_Calendar_Success;
+ g_clear_error (&error);
}
icalcomponent_free (clone);
}
@@ -996,10 +865,10 @@ _e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodC
/* also cache this timezone to backend */
if (object)
- e_cal_backend_sync_add_timezone (E_CAL_BACKEND_SYNC (backend), cal, object);
+ e_cal_backend_sync_add_timezone (E_CAL_BACKEND_SYNC (backend), cal, object, NULL);
}
- e_data_cal_notify_timezone_requested (cal, context, status, object);
+ e_data_cal_notify_timezone_requested (cal, context, error, object);
g_free (object);
}
@@ -1007,11 +876,11 @@ _e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodC
static void
_e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzobj)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
- status = e_cal_backend_sync_add_timezone (E_CAL_BACKEND_SYNC (backend), cal, tzobj);
+ e_cal_backend_sync_add_timezone (E_CAL_BACKEND_SYNC (backend), cal, tzobj, &error);
- e_data_cal_notify_timezone_added (cal, context, status, tzobj);
+ e_data_cal_notify_timezone_added (cal, context, error, tzobj);
}
/* The default implementation is looking for timezone in the ical's builtin timezones,
@@ -1057,33 +926,33 @@ _e_cal_backend_internal_get_timezone (ECalBackend *backend, const gchar *tzid)
static void
_e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tz)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
- status = e_cal_backend_sync_set_default_zone (E_CAL_BACKEND_SYNC (backend), cal, tz);
+ e_cal_backend_sync_set_default_zone (E_CAL_BACKEND_SYNC (backend), cal, tz, &error);
- e_data_cal_notify_default_timezone_set (cal, context, status);
+ e_data_cal_notify_default_timezone_set (cal, context, error);
}
static void
_e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
- status = e_cal_backend_sync_set_default_timezone (E_CAL_BACKEND_SYNC (backend), cal, tzid);
+ e_cal_backend_sync_set_default_timezone (E_CAL_BACKEND_SYNC (backend), cal, tzid, &error);
- e_data_cal_notify_default_timezone_set (cal, context, status);
+ e_data_cal_notify_default_timezone_set (cal, context, error);
}
static void
_e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *change_id)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
GList *adds = NULL, *modifies = NULL, *deletes = NULL, *l;
- status = e_cal_backend_sync_get_changes (E_CAL_BACKEND_SYNC (backend), cal, change_id,
- &adds, &modifies, &deletes);
+ e_cal_backend_sync_get_changes (E_CAL_BACKEND_SYNC (backend), cal, change_id,
+ &adds, &modifies, &deletes, &error);
- e_data_cal_notify_changes (cal, context, status, adds, modifies, deletes);
+ e_data_cal_notify_changes (cal, context, error, adds, modifies, deletes);
for (l = adds; l; l = l->next)
g_free (l->data);
@@ -1101,12 +970,12 @@ _e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, EServerMethodCo
static void
_e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, GList *users, time_t start, time_t end)
{
- ECalBackendSyncStatus status;
+ GError *error = NULL;
GList *freebusy = NULL, *l;
- status = e_cal_backend_sync_get_free_busy (E_CAL_BACKEND_SYNC (backend), cal, users, start, end, &freebusy);
+ e_cal_backend_sync_get_free_busy (E_CAL_BACKEND_SYNC (backend), cal, users, start, end, &freebusy, &error);
- e_data_cal_notify_free_busy (cal, context, status, freebusy);
+ e_data_cal_notify_free_busy (cal, context, error, freebusy);
for (l = freebusy; l; l = l->next)
g_free (l->data);
diff --git a/calendar/libedata-cal/e-cal-backend-sync.h b/calendar/libedata-cal/e-cal-backend-sync.h
index d157f6b..416324f 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.h
+++ b/calendar/libedata-cal/e-cal-backend-sync.h
@@ -20,8 +20,6 @@ typedef struct _ECalBackendSync ECalBackendSync;
typedef struct _ECalBackendSyncClass ECalBackendSyncClass;
typedef struct _ECalBackendSyncPrivate ECalBackendSyncPrivate;
-typedef GNOME_Evolution_Calendar_CallStatus ECalBackendSyncStatus;
-
struct _ECalBackendSync {
ECalBackend parent_object;
@@ -32,39 +30,39 @@ struct _ECalBackendSyncClass {
ECalBackendClass parent_class;
/* Virtual methods */
- ECalBackendSyncStatus (*is_read_only_sync) (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only);
- ECalBackendSyncStatus (*get_cal_address_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **address);
- ECalBackendSyncStatus (*get_alarm_email_address_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **address);
- ECalBackendSyncStatus (*get_ldap_attribute_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **attribute);
- ECalBackendSyncStatus (*get_static_capabilities_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities);
+ void (*is_read_only_sync) (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only, GError **perror);
+ void (*get_cal_address_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror);
+ void (*get_alarm_email_address_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror);
+ void (*get_ldap_attribute_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **attribute, GError **perror);
+ void (*get_static_capabilities_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities, GError **perror);
- ECalBackendSyncStatus (*open_sync) (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists, const gchar *username, const gchar *password);
- ECalBackendSyncStatus (*refresh_sync) (ECalBackendSync *backend, EDataCal *cal);
- ECalBackendSyncStatus (*remove_sync) (ECalBackendSync *backend, EDataCal *cal);
+ void (*open_sync) (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists, const gchar *username, const gchar *password, GError **perror);
+ void (*refresh_sync) (ECalBackendSync *backend, EDataCal *cal, GError **perror);
+ void (*remove_sync) (ECalBackendSync *backend, EDataCal *cal, GError **perror);
- ECalBackendSyncStatus (*create_object_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid);
- ECalBackendSyncStatus (*modify_object_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object);
- ECalBackendSyncStatus (*remove_object_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, CalObjModType mod, gchar **old_object, gchar **object);
+ void (*create_object_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid, GError **perror);
+ void (*modify_object_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object, GError **perror);
+ void (*remove_object_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, CalObjModType mod, gchar **old_object, gchar **object, GError **perror);
- ECalBackendSyncStatus (*discard_alarm_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid);
+ void (*discard_alarm_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid, GError **perror);
- ECalBackendSyncStatus (*receive_objects_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj);
- ECalBackendSyncStatus (*send_objects_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GList **users,
- gchar **modified_calobj);
+ void (*receive_objects_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GError **perror);
+ void (*send_objects_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GList **users,
+ gchar **modified_calobj, GError **perror);
- ECalBackendSyncStatus (*get_default_object_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **object);
- ECalBackendSyncStatus (*get_object_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object);
- ECalBackendSyncStatus (*get_object_list_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects);
+ void (*get_default_object_sync) (ECalBackendSync *backend, EDataCal *cal, gchar **object, GError **perror);
+ void (*get_object_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object, GError **perror);
+ void (*get_object_list_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects, GError **perror);
- ECalBackendSyncStatus (*get_attachment_list_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, GSList **attachments);
+ void (*get_attachment_list_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, GSList **attachments, GError **perror);
- ECalBackendSyncStatus (*get_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object);
- ECalBackendSyncStatus (*add_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj);
- ECalBackendSyncStatus (*set_default_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid);
- ECalBackendSyncStatus (*set_default_zone_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *tz);
+ void (*get_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object, GError **perror);
+ void (*add_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **perror);
+ void (*set_default_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, GError **perror);
+ void (*set_default_zone_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *tz, GError **perror);
- ECalBackendSyncStatus (*get_changes_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id, GList **adds, GList **modifies, GList **deletes);
- ECalBackendSyncStatus (*get_freebusy_sync) (ECalBackendSync *backend, EDataCal *cal, GList *users, time_t start, time_t end, GList **freebusy);
+ void (*get_changes_sync) (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id, GList **adds, GList **modifies, GList **deletes, GError **perror);
+ void (*get_freebusy_sync) (ECalBackendSync *backend, EDataCal *cal, GList *users, time_t start, time_t end, GList **freebusy, GError **perror);
/* Padding for future expansion */
void (*_cal_reserved0) (void);
@@ -77,87 +75,137 @@ struct _ECalBackendSyncClass {
typedef ECalBackendSync * (*ECalBackendSyncFactoryFn) (void);
GType e_cal_backend_sync_get_type (void);
-void e_cal_backend_sync_set_lock (ECalBackendSync *backend, gboolean lock);
-
-ECalBackendSyncStatus e_cal_backend_sync_is_read_only (ECalBackendSync *backend,
- EDataCal *cal,
- gboolean *read_only);
-ECalBackendSyncStatus e_cal_backend_sync_get_cal_address (ECalBackendSync *backend,
- EDataCal *cal,
- gchar **address);
-ECalBackendSyncStatus e_cal_backend_sync_get_alarm_email_address (ECalBackendSync *backend,
- EDataCal *cal,
- gchar **address);
-ECalBackendSyncStatus e_cal_backend_sync_get_ldap_attribute (ECalBackendSync *backend,
- EDataCal *cal,
- gchar **attribute);
-ECalBackendSyncStatus e_cal_backend_sync_get_static_capabilities (ECalBackendSync *backend,
- EDataCal *cal,
- gchar **capabiliites);
-ECalBackendSyncStatus e_cal_backend_sync_open (ECalBackendSync *backend,
- EDataCal *cal,
- gboolean only_if_exists,
- const gchar *username,
- const gchar *password);
-ECalBackendSyncStatus e_cal_backend_sync_refresh (ECalBackendSync *backend,
- EDataCal *cal);
-ECalBackendSyncStatus e_cal_backend_sync_remove (ECalBackendSync *backend,
- EDataCal *cal);
-ECalBackendSyncStatus e_cal_backend_sync_create_object (ECalBackendSync *backend,
- EDataCal *cal,
- gchar **calobj,
- gchar **uid);
-ECalBackendSyncStatus e_cal_backend_sync_modify_object (ECalBackendSync *backend,
- EDataCal *cal,
- const gchar *calobj,
- CalObjModType mod,
- gchar **old_object,
- gchar **new_object);
-ECalBackendSyncStatus e_cal_backend_sync_remove_object (ECalBackendSync *backend,
- EDataCal *cal,
- const gchar *uid,
- const gchar *rid,
- CalObjModType mod,
- gchar **old_object,
- gchar **object);
-ECalBackendSyncStatus e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend,
- EDataCal *cal,
- const gchar *uid,
- const gchar *rid,
- GSList **attachments);
-
-ECalBackendSyncStatus e_cal_backend_sync_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid);
-
-ECalBackendSyncStatus e_cal_backend_sync_receive_objects (ECalBackendSync *backend,
- EDataCal *cal,
- const gchar *calobj);
-ECalBackendSyncStatus e_cal_backend_sync_send_objects (ECalBackendSync *backend,
- EDataCal *cal,
- const gchar *calobj,
- GList **users,
- gchar **modified_calobj);
-ECalBackendSyncStatus e_cal_backend_sync_get_default_object (ECalBackendSync *backend,
- EDataCal *cal,
- gchar **object);
-
-ECalBackendSyncStatus e_cal_backend_sync_get_object (ECalBackendSync *backend,
- EDataCal *cal,
- const gchar *uid,
- const gchar *rid,
- gchar **object);
-
-ECalBackendSyncStatus e_cal_backend_sync_get_object_list (ECalBackendSync *backend,
- EDataCal *cal,
- const gchar *sexp,
- GList **objects);
-
-ECalBackendSyncStatus e_cal_backend_sync_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object);
-ECalBackendSyncStatus e_cal_backend_sync_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj);
-ECalBackendSyncStatus e_cal_backend_sync_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid);
-ECalBackendSyncStatus e_cal_backend_sync_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj);
-
-ECalBackendSyncStatus e_cal_backend_sync_get_changes (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id, GList **adds, GList **modifies, GList **deletes);
-ECalBackendSyncStatus e_cal_backend_sync_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users, time_t start, time_t end, GList **freebusy);
+
+void e_cal_backend_sync_set_lock (ECalBackendSync *backend,
+ gboolean lock);
+
+void e_cal_backend_sync_is_read_only (ECalBackendSync *backend,
+ EDataCal *cal,
+ gboolean *read_only,
+ GError **error);
+void e_cal_backend_sync_get_cal_address (ECalBackendSync *backend,
+ EDataCal *cal,
+ gchar **address,
+ GError **error);
+void e_cal_backend_sync_get_alarm_email_address
+ (ECalBackendSync *backend,
+ EDataCal *cal,
+ gchar **address,
+ GError **error);
+void e_cal_backend_sync_get_ldap_attribute (ECalBackendSync *backend,
+ EDataCal *cal,
+ gchar **attribute,
+ GError **error);
+void e_cal_backend_sync_get_static_capabilities
+ (ECalBackendSync *backend,
+ EDataCal *cal,
+ gchar **capabiliites,
+ GError **error);
+void e_cal_backend_sync_open (ECalBackendSync *backend,
+ EDataCal *cal,
+ gboolean only_if_exists,
+ const gchar *username,
+ const gchar *password,
+ GError **error);
+void e_cal_backend_sync_refresh (ECalBackendSync *backend,
+ EDataCal *cal,
+ GError **error);
+void e_cal_backend_sync_remove (ECalBackendSync *backend,
+ EDataCal *cal,
+ GError **error);
+void e_cal_backend_sync_create_object (ECalBackendSync *backend,
+ EDataCal *cal,
+ gchar **calobj,
+ gchar **uid,
+ GError **error);
+void e_cal_backend_sync_modify_object (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *calobj,
+ CalObjModType mod,
+ gchar **old_object,
+ gchar **new_object,
+ GError **error);
+void e_cal_backend_sync_remove_object (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *uid,
+ const gchar *rid,
+ CalObjModType mod,
+ gchar **old_object,
+ gchar **object,
+ GError **error);
+void e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *uid,
+ const gchar *rid,
+ GSList **attachments,
+ GError **error);
+
+void e_cal_backend_sync_discard_alarm (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *uid,
+ const gchar *auid,
+ GError **error);
+
+void e_cal_backend_sync_receive_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *calobj,
+ GError **error);
+void e_cal_backend_sync_send_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *calobj,
+ GList **users,
+ gchar **modified_calobj,
+ GError **error);
+void e_cal_backend_sync_get_default_object (ECalBackendSync *backend,
+ EDataCal *cal,
+ gchar **object,
+ GError **error);
+
+void e_cal_backend_sync_get_object (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *uid,
+ const gchar *rid,
+ gchar **object,
+ GError **error);
+
+void e_cal_backend_sync_get_object_list (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *sexp,
+ GList **objects,
+ GError **error);
+
+void e_cal_backend_sync_get_timezone (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *tzid,
+ gchar **object,
+ GError **error);
+void e_cal_backend_sync_add_timezone (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *tzobj,
+ GError **error);
+void e_cal_backend_sync_set_default_timezone (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *tzid,
+ GError **error);
+void e_cal_backend_sync_set_default_zone (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *tzobj,
+ GError **error);
+
+void e_cal_backend_sync_get_changes (ECalBackendSync *backend,
+ EDataCal *cal,
+ const gchar *change_id,
+ GList **adds,
+ GList **modifies,
+ GList **deletes,
+ GError **error);
+void e_cal_backend_sync_get_free_busy (ECalBackendSync *backend,
+ EDataCal *cal,
+ GList *users,
+ time_t start,
+ time_t end,
+ GList **freebusy,
+ GError **error);
G_END_DECLS
diff --git a/calendar/libedata-cal/e-cal-backend-util.c b/calendar/libedata-cal/e-cal-backend-util.c
index 5774355..49d5a2b 100644
--- a/calendar/libedata-cal/e-cal-backend-util.c
+++ b/calendar/libedata-cal/e-cal-backend-util.c
@@ -91,69 +91,6 @@ e_cal_backend_mail_account_is_valid (gchar *user, gchar **name)
}
/**
- * e_cal_backend_status_to_string:
- *
- * Converts status code to string.
- *
- * Since: 2.24
- **/
-const gchar *
-e_cal_backend_status_to_string (GNOME_Evolution_Calendar_CallStatus status)
-{
- switch (status) {
- case GNOME_Evolution_Calendar_Success:
- return _("No error");
- case GNOME_Evolution_Calendar_RepositoryOffline:
- return _("Repository is offline");
- case GNOME_Evolution_Calendar_PermissionDenied:
- return _("Permission denied");
- case GNOME_Evolution_Calendar_InvalidRange:
- return _("Invalid range");
- case GNOME_Evolution_Calendar_ObjectNotFound:
- return _("Object not found");
- case GNOME_Evolution_Calendar_InvalidObject:
- return _("Invalid object");
- case GNOME_Evolution_Calendar_ObjectIdAlreadyExists:
- return _("Object ID already exists");
- case GNOME_Evolution_Calendar_AuthenticationFailed:
- return _("Authentication failed");
- case GNOME_Evolution_Calendar_AuthenticationRequired:
- return _("Authentication required");
- case GNOME_Evolution_Calendar_UnsupportedField:
- return _("Unsupported field");
- case GNOME_Evolution_Calendar_UnsupportedMethod:
- return _("Unsupported method");
- case GNOME_Evolution_Calendar_UnsupportedAuthenticationMethod:
- return _("Unsupported authentication method");
- case GNOME_Evolution_Calendar_TLSNotAvailable:
- return _("TLS not available");
- case GNOME_Evolution_Calendar_NoSuchCal:
- return _("No such calendar");
- case GNOME_Evolution_Calendar_UnknownUser:
- return _("Unknown User");
- case GNOME_Evolution_Calendar_OfflineUnavailable:
- return _("Offline mode unavailable");
- case GNOME_Evolution_Calendar_SearchSizeLimitExceeded:
- return _("Search size limit exceeded");
- case GNOME_Evolution_Calendar_SearchTimeLimitExceeded:
- return _("Search time limit exceeded");
- case GNOME_Evolution_Calendar_InvalidQuery:
- return _("Invalid query");
- case GNOME_Evolution_Calendar_QueryRefused:
- return _("Query refused");
- case GNOME_Evolution_Calendar_CouldNotCancel:
- return _("Could not cancel operation");
- default:
- case GNOME_Evolution_Calendar_OtherError:
- return _("Unknown error");
- case GNOME_Evolution_Calendar_InvalidServerVersion:
- return _("Invalid server version");
- }
-
- return NULL;
-}
-
-/**
* is_attendee_declined:
* @icalcomp: Component where to check the attendee list.
* @email: Attendee's email to look for.
diff --git a/calendar/libedata-cal/e-cal-backend-util.h b/calendar/libedata-cal/e-cal-backend-util.h
index d0d16a2..55cc712 100644
--- a/calendar/libedata-cal/e-cal-backend-util.h
+++ b/calendar/libedata-cal/e-cal-backend-util.h
@@ -33,8 +33,6 @@ G_BEGIN_DECLS
gboolean e_cal_backend_mail_account_get_default (gchar **address, gchar **name);
gboolean e_cal_backend_mail_account_is_valid (gchar *user, gchar **name);
-const gchar *e_cal_backend_status_to_string (GNOME_Evolution_Calendar_CallStatus status);
-
gboolean e_cal_backend_user_declined (icalcomponent *icalcomp);
G_END_DECLS
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index a45ccaf..419c953 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -31,6 +31,8 @@
+#define EDC_ERROR(_code) e_data_cal_create_error (_code, NULL)
+
G_DEFINE_TYPE (ECalBackend, e_cal_backend, G_TYPE_OBJECT);
/* Private part of the CalBackend structure */
@@ -78,8 +80,6 @@ enum props {
/* Signal IDs */
enum {
LAST_CLIENT_GONE,
- OPENED,
- REMOVED,
LAST_SIGNAL
};
static guint e_cal_backend_signals[LAST_SIGNAL];
@@ -225,28 +225,8 @@ e_cal_backend_class_init (ECalBackendClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- e_cal_backend_signals[OPENED] =
- g_signal_new ("opened",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (ECalBackendClass, opened),
- NULL, NULL,
- g_cclosure_marshal_VOID__ENUM,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
- e_cal_backend_signals[REMOVED] =
- g_signal_new ("removed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (ECalBackendClass, removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__ENUM,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
class->last_client_gone = NULL;
- class->opened = NULL;
- class->obj_updated = NULL;
class->get_cal_address = NULL;
class->get_alarm_email_address = NULL;
@@ -551,7 +531,7 @@ e_cal_backend_notify_readonly (ECalBackend *backend, gboolean read_only)
return;
}
for (l = priv->clients; l; l = l->next)
- e_data_cal_notify_read_only (l->data, GNOME_Evolution_Calendar_Success, read_only);
+ e_data_cal_notify_read_only (l->data, NULL /* Success */, read_only);
}
void
@@ -563,7 +543,7 @@ e_cal_backend_notify_cal_address (ECalBackend *backend, EServerMethodContext con
priv = backend->priv;
for (l = priv->clients; l; l = l->next)
- e_data_cal_notify_cal_address (l->data, context, GNOME_Evolution_Calendar_Success, address);
+ e_data_cal_notify_cal_address (l->data, context, NULL /* Success */, address);
}
/**
@@ -933,7 +913,7 @@ e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, EServerMethodC
if (CLASS (backend)->create_object)
(* CLASS (backend)->create_object) (backend, cal, context, calobj);
else
- e_data_cal_notify_object_created (cal, context, PermissionDenied, NULL, NULL);
+ e_data_cal_notify_object_created (cal, context, EDC_ERROR (UnsupportedMethod), NULL, NULL);
}
/**
@@ -955,7 +935,7 @@ e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, EServerMethodC
if (CLASS (backend)->modify_object)
(* CLASS (backend)->modify_object) (backend, cal, context, calobj, mod);
else
- e_data_cal_notify_object_removed (cal, context, PermissionDenied, NULL, NULL, NULL);
+ e_data_cal_notify_object_removed (cal, context, EDC_ERROR (UnsupportedMethod), NULL, NULL, NULL);
}
/**
@@ -1288,12 +1268,12 @@ e_cal_backend_notify_view_progress (ECalBackend *backend, const gchar *message,
/**
* e_cal_backend_notify_view_done:
* @backend: A calendar backend.
- * @status: returns the status once the view is fully populated.
+ * @error: returns the error, if any, once the view is fully populated.
*
* Notifies each of the backend's listeners about the view_done in downloading the items.
**/
void
-e_cal_backend_notify_view_done (ECalBackend *backend, GNOME_Evolution_Calendar_CallStatus status)
+e_cal_backend_notify_view_done (ECalBackend *backend, const GError *error)
{
ECalBackendPrivate *priv;
EList *queries;
@@ -1303,7 +1283,7 @@ e_cal_backend_notify_view_done (ECalBackend *backend, GNOME_Evolution_Calendar_C
priv = backend->priv;
if (priv->notification_proxy) {
- e_cal_backend_notify_view_done (priv->notification_proxy, status);
+ e_cal_backend_notify_view_done (priv->notification_proxy, error);
return;
}
@@ -1315,7 +1295,7 @@ e_cal_backend_notify_view_done (ECalBackend *backend, GNOME_Evolution_Calendar_C
g_object_ref (query);
- e_data_cal_view_notify_done (query, status);
+ e_data_cal_view_notify_done (query, error);
g_object_unref (query);
diff --git a/calendar/libedata-cal/e-cal-backend.h b/calendar/libedata-cal/e-cal-backend.h
index a10077e..95abfa3 100644
--- a/calendar/libedata-cal/e-cal-backend.h
+++ b/calendar/libedata-cal/e-cal-backend.h
@@ -61,14 +61,8 @@ struct _ECalBackendClass {
void (* last_client_gone) (ECalBackend *backend);
void (* cal_added) (ECalBackend *backend, EDataCal *cal);
- gboolean (* is_loaded) (ECalBackend *backend);
-
- /* FIXME What to pass back here */
- void (* opened) (ECalBackend *backend, gint status);
- void (* removed) (ECalBackend *backend, gint status);
- void (* obj_updated) (ECalBackend *backend, const gchar *uid);
-
/* Virtual methods */
+ gboolean (* is_loaded) (ECalBackend *backend);
void (* is_read_only) (ECalBackend *backend, EDataCal *cal);
void (* get_cal_address) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
void (* get_alarm_email_address) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
@@ -181,7 +175,7 @@ void e_cal_backend_notify_mode (ECalBackend *backend,
void e_cal_backend_notify_auth_required (ECalBackend *backend);
void e_cal_backend_notify_error (ECalBackend *backend, const gchar *message);
-void e_cal_backend_notify_view_done (ECalBackend *backend, EDataCalCallStatus status);
+void e_cal_backend_notify_view_done (ECalBackend *backend, const GError *error);
void e_cal_backend_notify_view_progress_start (ECalBackend *backend);
void e_cal_backend_notify_view_progress (ECalBackend *backend, const gchar *message, gint percent);
void e_cal_backend_notify_readonly (ECalBackend *backend, gboolean read_only);
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index a26d84f..d24b43d 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -694,7 +694,7 @@ offline_state_changed_cb (EOfflineListener *eol, EDataCalFactory *factory)
g_return_if_fail (state == EOL_STATE_ONLINE || state == EOL_STATE_OFFLINE);
- e_data_cal_factory_set_backend_mode (factory, state == EOL_STATE_ONLINE ? GNOME_Evolution_Calendar_MODE_REMOTE : GNOME_Evolution_Calendar_MODE_LOCAL);
+ e_data_cal_factory_set_backend_mode (factory, state == EOL_STATE_ONLINE ? Remote : Local);
}
#define E_DATA_CAL_FACTORY_SERVICE_NAME "org.gnome.evolution.dataserver.Calendar"
diff --git a/calendar/libedata-cal/e-data-cal-marshal.list b/calendar/libedata-cal/e-data-cal-marshal.list
index 17c4a78..b341ece 100644
--- a/calendar/libedata-cal/e-data-cal-marshal.list
+++ b/calendar/libedata-cal/e-data-cal-marshal.list
@@ -1 +1,2 @@
NONE:STRING,UINT
+NONE:UINT,STRING
diff --git a/calendar/libedata-cal/e-data-cal-types.h b/calendar/libedata-cal/e-data-cal-types.h
index 83be605..fce65cc 100644
--- a/calendar/libedata-cal/e-data-cal-types.h
+++ b/calendar/libedata-cal/e-data-cal-types.h
@@ -33,47 +33,17 @@ typedef enum {
CouldNotCancel,
OtherError,
- InvalidServerVersion
-
+ InvalidServerVersion,
+ InvalidArg,
+ NotSupported
} EDataCalCallStatus;
-/* Some hacks so the backends compile without change */
-/* TODO: Find out how many of these are necessary */
-#define GNOME_Evolution_Calendar_CallStatus EDataCalCallStatus
-#define GNOME_Evolution_Calendar_Success Success
-#define GNOME_Evolution_Calendar_RepositoryOffline RepositoryOffline
-#define GNOME_Evolution_Calendar_PermissionDenied PermissionDenied
-#define GNOME_Evolution_Calendar_InvalidRange InvalidRange
-#define GNOME_Evolution_Calendar_ObjectNotFound ObjectNotFound
-#define GNOME_Evolution_Calendar_InvalidObject InvalidObject
-#define GNOME_Evolution_Calendar_ObjectIdAlreadyExists ObjectIdAlreadyExists
-#define GNOME_Evolution_Calendar_AuthenticationFailed AuthenticationFailed
-#define GNOME_Evolution_Calendar_AuthenticationRequired AuthenticationRequired
-#define GNOME_Evolution_Calendar_UnsupportedField UnsupportedField
-#define GNOME_Evolution_Calendar_UnsupportedMethod UnsupportedMethod
-#define GNOME_Evolution_Calendar_UnsupportedAuthenticationMethod UnsupportedAuthenticationMethod
-#define GNOME_Evolution_Calendar_TLSNotAvailable TLSNotAvailable
-#define GNOME_Evolution_Calendar_NoSuchCal NoSuchCal
-#define GNOME_Evolution_Calendar_UnknownUser UnknownUser
-#define GNOME_Evolution_Calendar_OfflineUnavailable OfflineUnavailable
-#define GNOME_Evolution_Calendar_SearchSizeLimitExceeded SearchSizeLimitExceeded
-#define GNOME_Evolution_Calendar_SearchTimeLimitExceeded SearchTimeLimitExceeded
-#define GNOME_Evolution_Calendar_InvalidQuery InvalidQuery
-#define GNOME_Evolution_Calendar_QueryRefused QueryRefused
-#define GNOME_Evolution_Calendar_CouldNotCancel CouldNotCancel
-#define GNOME_Evolution_Calendar_OtherError OtherError
-#define GNOME_Evolution_Calendar_InvalidServerVersion InvalidServerVersion
-
typedef enum {
- Set, /* All OK */
- NotSet, /* Generic error */
- NotSupported /* Mode not supported */
+ ModeSet, /* All OK */
+ ModeNotSet, /* Generic error */
+ ModeNotSupported /* Mode not supported */
} EDataCalViewListenerSetModeStatus;
-#define GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED NotSupported
-#define GNOME_Evolution_Calendar_CalListener_MODE_NOT_SET NotSet
-#define GNOME_Evolution_Calendar_CalListener_MODE_SET Set
-
typedef enum {
Event = 1 << 0,
Todo = 1 << 1,
@@ -81,8 +51,6 @@ typedef enum {
AnyType = 0x07
} EDataCalObjType;
-#define GNOME_Evolution_Calendar_CalObjType EDataCalObjType
-
typedef enum {
This = 1 << 0,
ThisAndPrior = 1 << 1,
@@ -96,11 +64,6 @@ typedef enum {
AnyMode = 0x07
} EDataCalMode;
-#define GNOME_Evolution_Calendar_CalMode EDataCalMode
-#define GNOME_Evolution_Calendar_MODE_LOCAL Local
-#define GNOME_Evolution_Calendar_MODE_REMOTE Remote
-#define GNOME_Evolution_Calendar_MODE_ANY AnyMode
-
G_END_DECLS
#endif /* __E_DATA_CAL_TYPES_H__ */
diff --git a/calendar/libedata-cal/e-data-cal-view.c b/calendar/libedata-cal/e-data-cal-view.c
index 6a0c113..8beaa15 100644
--- a/calendar/libedata-cal/e-data-cal-view.c
+++ b/calendar/libedata-cal/e-data-cal-view.c
@@ -39,6 +39,7 @@
extern DBusGConnection *connection;
static gboolean impl_EDataCalView_start (EDataCalView *query, GError **error);
+static gboolean impl_EDataCalView_stop (EDataCalView *query, GError **error);
#include "e-data-cal-view-glue.h"
#define THRESHOLD 32
@@ -48,8 +49,8 @@ struct _EDataCalViewPrivate {
ECalBackend *backend;
gboolean started;
+ gboolean stopped;
gboolean done;
- EDataCalCallStatus done_status;
/* Sexp that defines the query */
ECalBackendSExp *sexp;
@@ -148,8 +149,8 @@ e_data_cal_view_class_init (EDataCalViewClass *klass)
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
- g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1, G_TYPE_UINT);
+ e_data_cal_marshal_NONE__UINT_STRING,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), &dbus_glib_e_data_cal_view_object_info);
}
@@ -178,9 +179,8 @@ e_data_cal_view_init (EDataCalView *view)
priv->backend = NULL;
priv->started = FALSE;
+ priv->stopped = FALSE;
priv->done = FALSE;
- priv->done_status = Success;
- priv->started = FALSE;
priv->sexp = NULL;
priv->adds = g_array_sized_new (TRUE, TRUE, sizeof (gchar *), THRESHOLD);
@@ -324,15 +324,13 @@ notify_remove (EDataCalView *view, ECalComponentId *id)
}
static void
-notify_done (EDataCalView *view)
+notify_done (EDataCalView *view, const GError *error)
{
- EDataCalViewPrivate *priv = view->priv;
-
send_pending_adds (view);
send_pending_changes (view);
send_pending_removes (view);
- g_signal_emit (view, signals[DONE], 0, priv->done_status);
+ g_signal_emit (view, signals[DONE], 0, error ? error->code : 0, error ? error->message : NULL);
}
static gboolean
@@ -350,6 +348,18 @@ impl_EDataCalView_start (EDataCalView *query, GError **error)
return TRUE;
}
+static gboolean
+impl_EDataCalView_stop (EDataCalView *query, GError **error)
+{
+ EDataCalViewPrivate *priv;
+
+ priv = query->priv;
+
+ priv->stopped = TRUE;
+
+ return TRUE;
+}
+
static void
e_data_cal_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
@@ -527,39 +537,36 @@ e_data_cal_view_is_started (EDataCalView *view)
}
/**
- * e_data_cal_view_is_done:
+ * e_data_cal_view_is_stopped:
* @query: A query object.
*
- * Checks whether the given query is already done. Being done means the initial
- * matching of objects have been finished, not that no more notifications about
- * changes will be sent. In fact, even after done, notifications will still be sent
- * if there are changes in the objects matching the query search expression.
+ * Checks whether the given query has been stopped.
*
- * Returns: TRUE if the query is done, FALSE if still in progress.
+ * Returns: TRUE if the query has been stopped, FALSE otherwise.
+ *
+ * Since: 3.0
*/
gboolean
-e_data_cal_view_is_done (EDataCalView *query)
+e_data_cal_view_is_stopped (EDataCalView *view)
{
- EDataCalViewPrivate *priv;
-
- g_return_val_if_fail (IS_QUERY (query), FALSE);
-
- priv = query->priv;
+ g_return_val_if_fail (E_IS_DATA_CAL_VIEW (view), FALSE);
- return priv->done;
+ return view->priv->stopped;
}
/**
- * e_data_cal_view_get_done_status:
+ * e_data_cal_view_is_done:
* @query: A query object.
*
- * Gets the status code obtained when the initial matching of objects was done
- * for the given query.
+ * Checks whether the given query is already done. Being done means the initial
+ * matching of objects have been finished, not that no more notifications about
+ * changes will be sent. In fact, even after done, notifications will still be sent
+ * if there are changes in the objects matching the query search expression.
*
- * Returns: The query status.
+ * Returns: TRUE if the query is done, FALSE if still in progress.
*/
-EDataCalCallStatus
-e_data_cal_view_get_done_status (EDataCalView *query)
+gboolean
+e_data_cal_view_is_done (EDataCalView *query)
{
EDataCalViewPrivate *priv;
@@ -567,10 +574,7 @@ e_data_cal_view_get_done_status (EDataCalView *query)
priv = query->priv;
- if (priv->done)
- return priv->done_status;
-
- return Success;
+ return priv->done;
}
/**
@@ -727,7 +731,7 @@ e_data_cal_view_notify_progress (EDataCalView *view, const gchar *message, gint
g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
priv = view->priv;
- if (!priv->started)
+ if (!priv->started || priv->stopped)
return;
g_signal_emit (view, signals[PROGRESS], 0, message, percent);
@@ -736,24 +740,23 @@ e_data_cal_view_notify_progress (EDataCalView *view, const gchar *message, gint
/**
* e_data_cal_view_notify_done:
* @query: A query object.
- * @status: Query completion status code.
+ * @error: Query completion error, if any.
*
* Notifies all query listeners of the completion of the query, including a
* status code.
*/
void
-e_data_cal_view_notify_done (EDataCalView *view, GNOME_Evolution_Calendar_CallStatus status)
+e_data_cal_view_notify_done (EDataCalView *view, const GError *error)
{
EDataCalViewPrivate *priv;
g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
priv = view->priv;
- if (!priv->started)
+ if (!priv->started || priv->stopped)
return;
priv->done = TRUE;
- priv->done_status = status;
- notify_done (view);
+ notify_done (view, error);
}
diff --git a/calendar/libedata-cal/e-data-cal-view.h b/calendar/libedata-cal/e-data-cal-view.h
index 911b4f0..c988482 100644
--- a/calendar/libedata-cal/e-data-cal-view.h
+++ b/calendar/libedata-cal/e-data-cal-view.h
@@ -63,7 +63,7 @@ gboolean e_data_cal_view_object_matches (EDataCalView *query, const
GList *e_data_cal_view_get_matched_objects (EDataCalView *query);
gboolean e_data_cal_view_is_started (EDataCalView *query);
gboolean e_data_cal_view_is_done (EDataCalView *query);
-EDataCalCallStatus e_data_cal_view_get_done_status (EDataCalView *query);
+gboolean e_data_cal_view_is_stopped (EDataCalView *query);
void e_data_cal_view_notify_objects_added (EDataCalView *query,
const GList *objects);
@@ -81,7 +81,7 @@ void e_data_cal_view_notify_progress (EDataCalView *query,
const gchar *message,
gint percent);
void e_data_cal_view_notify_done (EDataCalView *query,
- EDataCalCallStatus status);
+ const GError *error);
G_END_DECLS
diff --git a/calendar/libedata-cal/e-data-cal-view.xml b/calendar/libedata-cal/e-data-cal-view.xml
index f61bc5d..44ed68a 100644
--- a/calendar/libedata-cal/e-data-cal-view.xml
+++ b/calendar/libedata-cal/e-data-cal-view.xml
@@ -7,6 +7,10 @@
<method name="start">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_EDataCalView_start"/>
</method>
+
+ <method name="stop">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_EDataCalView_stop"/>
+ </method>
<signal name="ObjectsAdded">
<arg name="objects" type="as"/>
@@ -27,6 +31,7 @@
<signal name="Done">
<arg name="status" type="u"/>
+ <arg name="message" type="s"/>
</signal>
</interface>
</node>
diff --git a/calendar/libedata-cal/e-data-cal.c b/calendar/libedata-cal/e-data-cal.c
index da2c4b9..b3633ea 100644
--- a/calendar/libedata-cal/e-data-cal.c
+++ b/calendar/libedata-cal/e-data-cal.c
@@ -84,6 +84,8 @@ G_DEFINE_TYPE (EDataCal, e_data_cal, G_TYPE_OBJECT);
#define E_DATA_CAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), E_TYPE_DATA_CAL, EDataCalPrivate))
+#define EDC_ERROR(_code) e_data_cal_create_error (_code, NULL)
+
struct _EDataCalPrivate {
ECalBackend *backend;
ESource *source;
@@ -100,6 +102,92 @@ e_data_cal_error_quark (void)
return quark;
}
+const gchar *
+e_data_cal_status_to_string (EDataCalCallStatus status)
+{
+ gint i;
+ static struct _statuses {
+ EDataCalCallStatus status;
+ const gchar *msg;
+ } statuses[] = {
+ { Success, N_("Success") },
+ { RepositoryOffline, N_("Repository offline") },
+ { PermissionDenied, N_("Permission denied") },
+ { InvalidRange, N_("Invalid range") },
+ { ObjectNotFound, N_("Object not found") },
+ { InvalidObject, N_("Invalid object") },
+ { ObjectIdAlreadyExists, N_("Object ID already exists") },
+ { AuthenticationFailed, N_("Authentication Failed") },
+ { AuthenticationRequired, N_("Authentication Required") },
+ { UnsupportedField, N_("Unsupported field") },
+ { UnsupportedMethod, N_("Unsupported method") },
+ { UnsupportedAuthenticationMethod, N_("Unsupported authentication method") },
+ { TLSNotAvailable, N_("TLS not available") },
+ { NoSuchCal, N_("Calendar does not exist") },
+ { UnknownUser, N_("UnknownUser") },
+ { OfflineUnavailable, N_("Not available in offline mode") },
+ { SearchSizeLimitExceeded, N_("Search size limit exceeded") },
+ { SearchTimeLimitExceeded, N_("Search time limit exceeded") },
+ { InvalidQuery, N_("Invalid query") },
+ { QueryRefused, N_("Query refused") },
+ { CouldNotCancel, N_("Could not cancel") },
+ /* { OtherError, N_("Other error") }, */
+ { InvalidServerVersion, N_("Invalid server version") },
+ { InvalidArg, N_("Invalid argument") },
+ { NotSupported, N_("Not supported") }
+ };
+
+ for (i = 0; i < G_N_ELEMENTS (statuses); i++) {
+ if (statuses[i].status == status)
+ return _(statuses[i].msg);
+ }
+
+ return _("Other error");
+}
+
+GError *
+e_data_cal_create_error (EDataCalCallStatus status, const gchar *custom_msg)
+{
+ if (status == Success)
+ return NULL;
+
+ return g_error_new_literal (E_DATA_CAL_ERROR, status, custom_msg ? custom_msg : e_data_cal_status_to_string (status));
+}
+
+GError *
+e_data_cal_create_error_fmt (EDataCalCallStatus status, const gchar *custom_msg_fmt, ...)
+{
+ GError *error;
+ gchar *custom_msg;
+ va_list ap;
+
+ if (!custom_msg_fmt)
+ return e_data_cal_create_error (status, NULL);
+
+ va_start (ap, custom_msg_fmt);
+ custom_msg = g_strdup_vprintf (custom_msg_fmt, ap);
+ va_end (ap);
+
+ error = e_data_cal_create_error (status, custom_msg);
+
+ g_free (custom_msg);
+
+ return error;
+}
+
+static void
+data_cal_return_error (DBusGMethodInvocation *context, const GError *perror, const gchar *error_fmt)
+{
+ GError *error;
+
+ g_return_if_fail (perror != NULL);
+
+ error = g_error_new (E_DATA_CAL_ERROR, perror->code, error_fmt, perror->message);
+ dbus_g_method_return_error (context, error);
+
+ g_error_free (error);
+}
+
/* Class init */
static void
e_data_cal_class_init (EDataCalClass *e_data_cal_class)
@@ -422,7 +510,7 @@ impl_Cal_getQuery (EDataCal *cal,
obj_sexp = e_cal_backend_sexp_new (sexp);
if (!obj_sexp) {
- e_data_cal_notify_query (cal, context, InvalidQuery, NULL);
+ e_data_cal_notify_query (cal, context, EDC_ERROR (InvalidQuery), NULL);
return;
}
@@ -430,13 +518,13 @@ impl_Cal_getQuery (EDataCal *cal,
query = e_data_cal_view_new (cal->priv->backend, path, obj_sexp);
if (!query) {
g_object_unref (obj_sexp);
- e_data_cal_notify_query (cal, context, OtherError, NULL);
+ e_data_cal_notify_query (cal, context, EDC_ERROR (OtherError), NULL);
return;
}
e_cal_backend_add_query (cal->priv->backend, query);
- e_data_cal_notify_query (cal, context, Success, path);
+ e_data_cal_notify_query (cal, context, EDC_ERROR (Success), path);
g_free (path);
}
@@ -471,160 +559,181 @@ impl_Cal_setDefaultTimezone (EDataCal *cal,
/**
* e_data_cal_notify_read_only:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @read_only: Read only value.
*
* Notifies listeners of the completion of the is_read_only method call.
*/
void
-e_data_cal_notify_read_only (EDataCal *cal, EDataCalCallStatus status, gboolean read_only)
+e_data_cal_notify_read_only (EDataCal *cal, GError *error, gboolean read_only)
{
g_return_if_fail (cal != NULL);
g_return_if_fail (E_IS_DATA_CAL (cal));
- g_signal_emit (cal, signals[READ_ONLY], 0, read_only);
+ if (error) {
+ e_data_cal_notify_error (cal, error->message);
+ g_error_free (error);
+ } else {
+ g_signal_emit (cal, signals[READ_ONLY], 0, read_only);
+ }
}
/**
* e_data_cal_notify_cal_address:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @address: Calendar address.
*
* Notifies listeners of the completion of the get_cal_address method call.
*/
void
-e_data_cal_notify_cal_address (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *address)
+e_data_cal_notify_cal_address (EDataCal *cal, EServerMethodContext context, GError *error, const gchar *address)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar address")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot retrieve calendar address: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method, address ? address : "");
}
/**
* e_data_cal_notify_alarm_email_address:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @address: Alarm email address.
*
* Notifies listeners of the completion of the get_alarm_email_address method call.
*/
void
-e_data_cal_notify_alarm_email_address (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *address)
+e_data_cal_notify_alarm_email_address (EDataCal *cal, EServerMethodContext context, GError *error, const gchar *address)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar alarm e-mail address")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot retrieve calendar alarm e-mail address: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method, address ? address : "");
}
/**
* e_data_cal_notify_ldap_attribute:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @attibute: LDAP attribute.
*
* Notifies listeners of the completion of the get_ldap_attribute method call.
*/
void
-e_data_cal_notify_ldap_attribute (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *attribute)
+e_data_cal_notify_ldap_attribute (EDataCal *cal, EServerMethodContext context, GError *error, const gchar *attribute)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar's ldap attribute")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot retrieve calendar's ldap attribute: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method, attribute ? attribute : "");
}
/**
* e_data_cal_notify_static_capabilities:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @capabilities: Static capabilities from the backend.
*
* Notifies listeners of the completion of the get_static_capabilities method call.
*/
void
-e_data_cal_notify_static_capabilities (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *capabilities)
+e_data_cal_notify_static_capabilities (EDataCal *cal, EServerMethodContext context, GError *error, const gchar *capabilities)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar scheduling information")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot retrieve calendar scheduling information: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method, capabilities ? capabilities : "");
}
/**
* e_data_cal_notify_open:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
*
* Notifies listeners of the completion of the open method call.
*/
void
-e_data_cal_notify_open (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
+e_data_cal_notify_open (EDataCal *cal, EServerMethodContext context, GError *error)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot open calendar")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot open calendar: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method);
}
/**
* e_data_cal_notify_refresh:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
*
* Notifies listeners of the completion of the refresh method call.
*
* Since: 2.30
*/
void
-e_data_cal_notify_refresh (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
+e_data_cal_notify_refresh (EDataCal *cal, EServerMethodContext context, GError *error)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot refresh calendar")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot refresh calendar: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method);
}
/**
* e_data_cal_notify_remove:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
*
* Notifies listeners of the completion of the remove method call.
*/
void
-e_data_cal_notify_remove (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
+e_data_cal_notify_remove (EDataCal *cal, EServerMethodContext context, GError *error)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot remove calendar")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot remove calendar: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method);
}
/**
* e_data_cal_notify_object_created:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @uid: UID of the object created.
* @object: The object created as an iCalendar string.
*
* Notifies listeners of the completion of the create_object method call.
*/void
-e_data_cal_notify_object_created (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+e_data_cal_notify_object_created (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *uid, const gchar *object)
{
DBusGMethodInvocation *method = context;
- if (status != Success) {
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot create calendar object")));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot create calendar object: %s"));
+ g_error_free (error);
} else {
e_cal_backend_notify_object_created (cal->priv->backend, object);
dbus_g_method_return (method, uid ? uid : "");
@@ -634,19 +743,21 @@ e_data_cal_notify_object_created (EDataCal *cal, EServerMethodContext context, E
/**
* e_data_cal_notify_object_modified:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @old_object: The old object as an iCalendar string.
* @object: The modified object as an iCalendar string.
*
* Notifies listeners of the completion of the modify_object method call.
*/
void
-e_data_cal_notify_object_modified (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+e_data_cal_notify_object_modified (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *old_object, const gchar *object)
{
DBusGMethodInvocation *method = context;
- if (status != Success) {
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot modify calendar object")));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot modify calendar object: %s"));
+ g_error_free (error);
} else {
e_cal_backend_notify_object_modified (cal->priv->backend, old_object, object);
dbus_g_method_return (method);
@@ -656,7 +767,7 @@ e_data_cal_notify_object_modified (EDataCal *cal, EServerMethodContext context,
/**
* e_data_cal_notify_object_removed:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @uid: UID of the removed object.
* @old_object: The old object as an iCalendar string.
* @object: The new object as an iCalendar string. This will not be NULL only
@@ -665,12 +776,14 @@ e_data_cal_notify_object_modified (EDataCal *cal, EServerMethodContext context,
* Notifies listeners of the completion of the remove_object method call.
*/
void
-e_data_cal_notify_object_removed (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+e_data_cal_notify_object_removed (EDataCal *cal, EServerMethodContext context, GError *error,
const ECalComponentId *id, const gchar *old_object, const gchar *object)
{
DBusGMethodInvocation *method = context;
- if (status != Success) {
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot remove calendar object")));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot remove calendar object: %s"));
+ g_error_free (error);
} else {
e_cal_backend_notify_object_removed (cal->priv->backend, id, old_object, object);
dbus_g_method_return (method);
@@ -680,52 +793,58 @@ e_data_cal_notify_object_removed (EDataCal *cal, EServerMethodContext context, E
/**
* e_data_cal_notify_objects_received:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
*
* Notifies listeners of the completion of the receive_objects method call.
*/
void
-e_data_cal_notify_objects_received (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
+e_data_cal_notify_objects_received (EDataCal *cal, EServerMethodContext context, GError *error)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot receive calendar objects")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot receive calendar objects: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method);
}
/**
* e_data_cal_notify_alarm_discarded:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
*
* Notifies listeners of the completion of the discard_alarm method call.
*/
void
-e_data_cal_notify_alarm_discarded (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
+e_data_cal_notify_alarm_discarded (EDataCal *cal, EServerMethodContext context, GError *error)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot discard calendar alarm")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot discard calendar alarm: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method);
}
/**
* e_data_cal_notify_objects_sent:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @users: List of users.
* @calobj: An iCalendar string representing the object sent.
*
* Notifies listeners of the completion of the send_objects method call.
*/
void
-e_data_cal_notify_objects_sent (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GList *users, const gchar *calobj)
+e_data_cal_notify_objects_sent (EDataCal *cal, EServerMethodContext context, GError *error, GList *users, const gchar *calobj)
{
DBusGMethodInvocation *method = context;
- if (status != Success) {
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot send calendar objects")));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot send calendar objects: %s"));
+ g_error_free (error);
} else {
gchar **users_array = NULL;
@@ -750,53 +869,59 @@ e_data_cal_notify_objects_sent (EDataCal *cal, EServerMethodContext context, EDa
/**
* e_data_cal_notify_default_object:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @object: The default object as an iCalendar string.
*
* Notifies listeners of the completion of the get_default_object method call.
*/
void
-e_data_cal_notify_default_object (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *object)
+e_data_cal_notify_default_object (EDataCal *cal, EServerMethodContext context, GError *error, const gchar *object)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve default calendar object path")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot retrieve default calendar object path: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method, object ? object : "");
}
/**
* e_data_cal_notify_object:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @object: The object retrieved as an iCalendar string.
*
* Notifies listeners of the completion of the get_object method call.
*/
void
-e_data_cal_notify_object (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *object)
+e_data_cal_notify_object (EDataCal *cal, EServerMethodContext context, GError *error, const gchar *object)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar object path")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot retrieve calendar object path: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method, object ? object : "");
}
/**
* e_data_cal_notify_object_list:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @objects: List of retrieved objects.
*
* Notifies listeners of the completion of the get_object_list method call.
*/
void
-e_data_cal_notify_object_list (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GList *objects)
+e_data_cal_notify_object_list (EDataCal *cal, EServerMethodContext context, GError *error, GList *objects)
{
DBusGMethodInvocation *method = context;
- if (status != Success) {
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar object list")));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot retrieve calendar object list: %s"));
+ g_error_free (error);
} else {
gchar **seq = NULL;
GList *l;
@@ -816,12 +941,12 @@ e_data_cal_notify_object_list (EDataCal *cal, EServerMethodContext context, EDat
/**
* e_data_cal_notify_attachment_list:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @attachments: List of retrieved attachment uri's.
*
* Notifies listeners of the completion of the get_attachment_list method call.+ */
void
-e_data_cal_notify_attachment_list (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GSList *attachments)
+e_data_cal_notify_attachment_list (EDataCal *cal, EServerMethodContext context, GError *error, GSList *attachments)
{
DBusGMethodInvocation *method = context;
gchar **seq;
@@ -833,91 +958,101 @@ e_data_cal_notify_attachment_list (EDataCal *cal, EServerMethodContext context,
seq[i] = g_strdup (l->data);
}
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Could not retrieve attachment list")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Could not retrieve attachment list: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method, seq);
}
/**
* e_data_cal_notify_query:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @query: The new live query.
*
* Notifies listeners of the completion of the get_query method call.
*/
void
-e_data_cal_notify_query (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *query)
+e_data_cal_notify_query (EDataCal *cal, EServerMethodContext context, GError *error, const gchar *query)
{
/*
* Only have a seperate notify function to follow suit with the rest of this
* file - it'd be much easier to just do the return in the above function
*/
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Could not complete calendar query")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Could not complete calendar query: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method, query);
}
/**
* e_data_cal_notify_timezone_requested:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @object: The requested timezone as an iCalendar string.
*
* Notifies listeners of the completion of the get_timezone method call.
*/
void
-e_data_cal_notify_timezone_requested (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *object)
+e_data_cal_notify_timezone_requested (EDataCal *cal, EServerMethodContext context, GError *error, const gchar *object)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Could not retrieve calendar time zone")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Could not retrieve calendar time zone: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method, object ? object : "");
}
/**
* e_data_cal_notify_timezone_added:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @tzid: ID of the added timezone.
*
* Notifies listeners of the completion of the add_timezone method call.
*/
void
-e_data_cal_notify_timezone_added (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *tzid)
+e_data_cal_notify_timezone_added (EDataCal *cal, EServerMethodContext context, GError *error, const gchar *tzid)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Could not add calendar time zone")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Could not add calendar time zone: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method, tzid ? tzid : "");
}
/**
* e_data_cal_notify_default_timezone_set:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
*
* Notifies listeners of the completion of the set_default_timezone method call.
*/
void
-e_data_cal_notify_default_timezone_set (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
+e_data_cal_notify_default_timezone_set (EDataCal *cal, EServerMethodContext context, GError *error)
{
DBusGMethodInvocation *method = context;
- if (status != Success)
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Could not set default calendar time zone")));
- else
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Could not set default calendar time zone: %s"));
+ g_error_free (error);
+ } else
dbus_g_method_return (method);
}
/**
* e_data_cal_notify_changes:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @adds: List of additions.
* @modifies: List of modifications.
* @deletes: List of removals.
@@ -925,12 +1060,14 @@ e_data_cal_notify_default_timezone_set (EDataCal *cal, EServerMethodContext cont
* Notifies listeners of the completion of the get_changes method call.
*/
void
-e_data_cal_notify_changes (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+e_data_cal_notify_changes (EDataCal *cal, EServerMethodContext context, GError *error,
GList *adds, GList *modifies, GList *deletes)
{
DBusGMethodInvocation *method = context;
- if (status != Success) {
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar changes")));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot retrieve calendar changes: %s"));
+ g_error_free (error);
} else {
gchar **additions, **modifications, **removals;
GList *l;
@@ -970,17 +1107,19 @@ e_data_cal_notify_changes (EDataCal *cal, EServerMethodContext context, EDataCal
/**
* e_data_cal_notify_free_busy:
* @cal: A calendar client interface.
- * @status: Status code.
+ * @error: Operation error, if any, automatically freed if passed it.
* @freebusy: List of free/busy objects.
*
* Notifies listeners of the completion of the get_free_busy method call.
*/
void
-e_data_cal_notify_free_busy (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GList *freebusy)
+e_data_cal_notify_free_busy (EDataCal *cal, EServerMethodContext context, GError *error, GList *freebusy)
{
DBusGMethodInvocation *method = context;
- if (status != Success) {
- dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar free/busy list")));
+ if (error) {
+ /* Translators: The '%s' is replaced with a detailed error message */
+ data_cal_return_error (method, error, _("Cannot retrieve calendar free/busy list: %s"));
+ g_error_free (error);
} else {
gchar **seq;
GList *l;
diff --git a/calendar/libedata-cal/e-data-cal.h b/calendar/libedata-cal/e-data-cal.h
index 94585ac..81b9940 100644
--- a/calendar/libedata-cal/e-data-cal.h
+++ b/calendar/libedata-cal/e-data-cal.h
@@ -48,6 +48,43 @@ GQuark e_data_cal_error_quark (void);
**/
#define E_DATA_CAL_ERROR e_data_cal_error_quark ()
+/**
+ * e_data_cal_create_error:
+ * @status: #EDataCalStatus code
+ * @custom_msg: Custom message to use for the error. When NULL,
+ * then uses a default message based on the @status code.
+ *
+ * Returns: NULL, when the @status is Success,
+ * or a newly allocated GError, which should be freed
+ * with g_error_free() call.
+ **/
+GError *e_data_cal_create_error (EDataCalCallStatus status, const gchar *custom_msg);
+
+/**
+ * e_data_cal_create_error_fmt:
+ *
+ * Similar as e_data_cal_create_error(), only here, instead of custom_msg,
+ * is used a printf() format to create a custom_msg for the error.
+ **/
+GError *e_data_cal_create_error_fmt (EDataCalCallStatus status, const gchar *custom_msg_fmt, ...) G_GNUC_PRINTF (2, 3);
+
+const gchar *e_data_cal_status_to_string (EDataCalCallStatus status);
+
+#define e_return_data_cal_error_if_fail(expr, _code) \
+ G_STMT_START { \
+ if (G_LIKELY(expr)) { \
+ } else { \
+ g_log (G_LOG_DOMAIN, \
+ G_LOG_LEVEL_CRITICAL, \
+ "file %s: line %d (%s): assertion `%s' failed", \
+ __FILE__, __LINE__, G_STRFUNC, #expr); \
+ g_set_error (error, E_DATA_CAL_ERROR, (_code), \
+ "file %s: line %d (%s): assertion `%s' failed", \
+ __FILE__, __LINE__, G_STRFUNC, #expr); \
+ return; \
+ } \
+ } G_STMT_END
+
typedef struct _EDataCalPrivate EDataCalPrivate;
struct _EDataCal {
@@ -66,52 +103,52 @@ EDataCal *e_data_cal_new (ECalBackend *backend, ESource *source);
ECalBackend *e_data_cal_get_backend (EDataCal *cal);
ESource* e_data_cal_get_source (EDataCal *cal);
-void e_data_cal_notify_read_only (EDataCal *cal, EDataCalCallStatus status,
+void e_data_cal_notify_read_only (EDataCal *cal, GError *error,
gboolean read_only);
-void e_data_cal_notify_cal_address (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_cal_address (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *address);
-void e_data_cal_notify_alarm_email_address (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_alarm_email_address (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *address);
-void e_data_cal_notify_ldap_attribute (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_ldap_attribute (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *attribute);
-void e_data_cal_notify_static_capabilities (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_static_capabilities (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *capabilities);
-void e_data_cal_notify_open (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
-void e_data_cal_notify_refresh(EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
-void e_data_cal_notify_remove (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
+void e_data_cal_notify_open (EDataCal *cal, EServerMethodContext context, GError *error);
+void e_data_cal_notify_refresh(EDataCal *cal, EServerMethodContext context, GError *error);
+void e_data_cal_notify_remove (EDataCal *cal, EServerMethodContext context, GError *error);
-void e_data_cal_notify_object_created (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_object_created (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *uid, const gchar *object);
-void e_data_cal_notify_object_modified (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_object_modified (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *old_object, const gchar *object);
-void e_data_cal_notify_object_removed (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_object_removed (EDataCal *cal, EServerMethodContext context, GError *error,
const ECalComponentId *id, const gchar *old_object, const gchar *object);
-void e_data_cal_notify_alarm_discarded (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
+void e_data_cal_notify_alarm_discarded (EDataCal *cal, EServerMethodContext context, GError *error);
-void e_data_cal_notify_objects_received (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
-void e_data_cal_notify_objects_sent (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GList *users,
+void e_data_cal_notify_objects_received (EDataCal *cal, EServerMethodContext context, GError *error);
+void e_data_cal_notify_objects_sent (EDataCal *cal, EServerMethodContext context, GError *error, GList *users,
const gchar *calobj);
-void e_data_cal_notify_default_object (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_default_object (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *object);
-void e_data_cal_notify_object (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_object (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *object);
-void e_data_cal_notify_object_list (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_object_list (EDataCal *cal, EServerMethodContext context, GError *error,
GList *objects);
-void e_data_cal_notify_query (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_query (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *query_path);
-void e_data_cal_notify_timezone_requested (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_timezone_requested (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *object);
-void e_data_cal_notify_timezone_added (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_timezone_added (EDataCal *cal, EServerMethodContext context, GError *error,
const gchar *tzid);
-void e_data_cal_notify_default_timezone_set (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
+void e_data_cal_notify_default_timezone_set (EDataCal *cal, EServerMethodContext context, GError *error);
-void e_data_cal_notify_changes (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_changes (EDataCal *cal, EServerMethodContext context, GError *error,
GList *adds, GList *modifies, GList *deletes);
-void e_data_cal_notify_free_busy (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+void e_data_cal_notify_free_busy (EDataCal *cal, EServerMethodContext context, GError *error,
GList *freebusy);
void e_data_cal_notify_mode (EDataCal *cal,
@@ -122,7 +159,7 @@ void e_data_cal_notify_auth_required (EDataCal *cal);
void e_data_cal_notify_error (EDataCal *cal, const gchar *message);
-void e_data_cal_notify_attachment_list (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GSList *objects);
+void e_data_cal_notify_attachment_list (EDataCal *cal, EServerMethodContext context, GError *error, GSList *objects);
G_END_DECLS
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 7aead7c..b40c128 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -112,17 +112,17 @@ ecal_test_utils_cal_open (ECal *cal,
}
static void
-open_cb (ECal *cal,
- ECalendarStatus status,
+open_ex_cb (ECal *cal,
+ const GError *error,
ECalTestClosure *closure)
{
if (FALSE) {
- } else if (status == E_CALENDAR_STATUS_BUSY) {
+ } else if (error && error->code == E_CALENDAR_STATUS_BUSY) {
test_print ("calendar server is busy; waiting...");
return;
- } else if (status != E_CALENDAR_STATUS_OK) {
+ } else if (error) {
g_warning ("failed to asynchronously remove the calendar: "
- "status %d", status);
+ "status %d (%s)", error->code, error->message);
exit (1);
}
@@ -133,7 +133,7 @@ open_cb (ECal *cal,
if (closure)
(*closure->cb) (closure);
- g_signal_handlers_disconnect_by_func (cal, open_cb, closure);
+ g_signal_handlers_disconnect_by_func (cal, open_ex_cb, closure);
g_free (closure);
}
@@ -149,7 +149,7 @@ ecal_test_utils_cal_async_open (ECal *cal,
closure->cb = callback;
closure->user_data = user_data;
- g_signal_connect (G_OBJECT (cal), "cal_opened", G_CALLBACK (open_cb), closure);
+ g_signal_connect (G_OBJECT (cal), "cal_opened_ex", G_CALLBACK (open_ex_cb), closure);
e_cal_open_async (cal, only_if_exists);
}
diff --git a/calendar/tests/ecal/test-ecal-get-query.c b/calendar/tests/ecal/test-ecal-get-query.c
index b1f54ec..3783060 100644
--- a/calendar/tests/ecal/test-ecal-get-query.c
+++ b/calendar/tests/ecal/test-ecal-get-query.c
@@ -79,9 +79,9 @@ objects_removed_cb (GObject *object, GList *objects, gpointer data)
}
static void
-view_done_cb (GObject *object, ECalendarStatus status, gpointer data)
+view_complete_cb (GObject *object, ECalendarStatus status, const gchar *error_msg, gpointer data)
{
- test_print ("View done\n");
+ test_print ("View complete (status: %d, error_msg:%s\n", status, error_msg ? error_msg : "NULL");
g_source_remove (complete_timeout_id);
@@ -166,8 +166,8 @@ main (gint argc, gchar **argv)
G_CALLBACK (objects_modified_cb), cal);
g_signal_connect (G_OBJECT (view), "objects_removed",
G_CALLBACK (objects_removed_cb), cal);
- g_signal_connect (G_OBJECT (view), "view_done",
- G_CALLBACK (view_done_cb), cal);
+ g_signal_connect (G_OBJECT (view), "view_complete",
+ G_CALLBACK (view_complete_cb), cal);
e_cal_view_start (view);
diff --git a/calendar/tests/ecal/test-ecal.c b/calendar/tests/ecal/test-ecal.c
index 1baecab..f71f026 100644
--- a/calendar/tests/ecal/test-ecal.c
+++ b/calendar/tests/ecal/test-ecal.c
@@ -86,9 +86,9 @@ objects_removed_cb (GObject *object, GList *objects, gpointer data)
}
static void
-view_done_cb (GObject *object, ECalendarStatus status, gpointer data)
+view_complete_cb (GObject *object, ECalendarStatus status, const gchar *error_msg, gpointer data)
{
- cl_printf (data, "View done\n");
+ cl_printf (data, "View complete (status:%d, error_msg:%s)\n", status, error_msg ? error_msg : "NULL");
}
static gboolean
@@ -707,8 +707,8 @@ create_client (ECal **client, const gchar *uri, ECalSourceType type, gboolean on
G_CALLBACK (objects_modified_cb), client);
g_signal_connect (G_OBJECT (query), "objects_removed",
G_CALLBACK (objects_removed_cb), client);
- g_signal_connect (G_OBJECT (query), "view_done",
- G_CALLBACK (view_done_cb), client);
+ g_signal_connect (G_OBJECT (query), "view_complete",
+ G_CALLBACK (view_complete_cb), client);
e_cal_view_start (query);
diff --git a/configure.ac b/configure.ac
index ba808dc..ba7b175 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,19 +94,19 @@ LIBEDATASERVERUI_GTK3_CURRENT=0
LIBEDATASERVERUI_GTK3_REVISION=0
LIBEDATASERVERUI_GTK3_AGE=0
-LIBECAL_CURRENT=9
+LIBECAL_CURRENT=10
LIBECAL_REVISION=2
LIBECAL_AGE=2
-LIBEDATACAL_CURRENT=7
+LIBEDATACAL_CURRENT=8
LIBEDATACAL_REVISION=0
LIBEDATACAL_AGE=0
-LIBEDATABOOK_CURRENT=6
+LIBEDATABOOK_CURRENT=7
LIBEDATABOOK_REVISION=1
LIBEDATABOOK_AGE=4
-LIBEBOOK_CURRENT=12
+LIBEBOOK_CURRENT=13
LIBEBOOK_REVISION=1
LIBEBOOK_AGE=3
@@ -185,6 +185,10 @@ AS_COMPILER_FLAGS(WARNING_FLAGS,
-Wredundant-decls -Wundef -Wwrite-strings")
AC_SUBST(WARNING_FLAGS)
+dnl More depracation from EBook/ECal:
+dnl -DE_BOOK_DISABLE_DEPRECATED
+dnl -DE_CAL_DISABLE_DEPRECATED
+dnl
dnl Other useful compiler warnings for test builds only.
dnl These may produce warnings we have no control over,
dnl or false positives we don't always want to see.
diff --git a/libedataserverui/e-book-auth-util.c b/libedataserverui/e-book-auth-util.c
index e8e6166..485de2a 100644
--- a/libedataserverui/e-book-auth-util.c
+++ b/libedataserverui/e-book-auth-util.c
@@ -33,13 +33,16 @@
#include "e-book-auth-util.h"
static void addressbook_authenticate (EBook *book, gboolean previous_failure,
- ESource *source, EBookCallback cb, gpointer closure);
+ ESource *source, EBookExCallback cb, gpointer closure);
static void auth_required_cb (EBook *book, gpointer data);
typedef struct {
ESource *source;
EBook *book;
+ #ifndef E_BOOK_DISABLE_DEPRECATED
EBookCallback open_func;
+ #endif
+ EBookExCallback open_func_ex;
gpointer open_func_data;
} LoadSourceData;
@@ -68,11 +71,11 @@ remove_parameters_from_uri (const gchar *uri)
}
static void
-load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure)
+load_source_auth_cb (EBook *book, const GError *error, gpointer closure)
{
LoadSourceData *data = closure;
- switch (status) {
+ switch (error ? error->code : E_BOOK_ERROR_OK) {
/* the user clicked cancel in the password dialog */
case E_BOOK_ERROR_CANCELLED:
@@ -94,7 +97,8 @@ load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure)
break;
case E_BOOK_ERROR_INVALID_SERVER_VERSION:
- status = E_BOOK_ERROR_OK;
+ /* aka E_BOOK_ERROR_OK */
+ error = NULL;
break;
case E_BOOK_ERROR_AUTHENTICATION_FAILED:
@@ -107,7 +111,7 @@ load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure)
component_name = auth_domain ? auth_domain : "Addressbook";
- if (status == E_BOOK_ERROR_AUTHENTICATION_FAILED)
+ if (error->code == E_BOOK_ERROR_AUTHENTICATION_FAILED)
e_passwords_forget_password (component_name, stripped_uri);
addressbook_authenticate (book, TRUE, data->source, load_source_auth_cb, closure);
@@ -121,8 +125,12 @@ load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure)
break;
}
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (data->open_func)
- data->open_func (book, status, data->open_func_data);
+ data->open_func (book, error ? error->code : E_BOOK_ERROR_OK, data->open_func_data);
+ #endif
+ if (data->open_func_ex)
+ data->open_func_ex (book, error, data->open_func_data);
free_load_source_data (data);
}
@@ -148,7 +156,7 @@ set_remember_password (ESource *source, gboolean value)
static void
addressbook_authenticate (EBook *book, gboolean previous_failure, ESource *source,
- EBookCallback cb, gpointer closure)
+ EBookExCallback cb, gpointer closure)
{
const gchar *auth;
const gchar *user;
@@ -212,14 +220,18 @@ addressbook_authenticate (EBook *book, gboolean previous_failure, ESource *sourc
}
if (password) {
- e_book_async_authenticate_user (book, user, password,
+ e_book_async_authenticate_user_ex (book, user, password,
e_source_get_property (source, "auth"),
cb, closure);
g_free (password);
}
else {
+ GError *error = g_error_new (E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED, _("Cancelled"));
+
/* they hit cancel */
- cb (book, E_BOOK_ERROR_CANCELLED, closure);
+ cb (book, error, closure);
+
+ g_error_free (error);
}
g_free (stripped_uri);
@@ -237,11 +249,11 @@ auth_required_cb (EBook *book, gpointer data)
}
static void
-load_source_cb (EBook *book, EBookStatus status, gpointer closure)
+load_source_cb (EBook *book, const GError *error, gpointer closure)
{
LoadSourceData *load_source_data = closure;
- if (status == E_BOOK_ERROR_OK && book != NULL) {
+ if (!error && book != NULL) {
const gchar *auth;
auth = e_source_get_property (load_source_data->source, "auth");
@@ -256,12 +268,17 @@ load_source_cb (EBook *book, EBookStatus status, gpointer closure)
}
}
+ #ifndef E_BOOK_DISABLE_DEPRECATED
if (load_source_data->open_func)
- load_source_data->open_func (book, status, load_source_data->open_func_data);
+ load_source_data->open_func (book, error ? error->code : E_BOOK_ERROR_OK, load_source_data->open_func_data);
+ #endif
+ if (load_source_data->open_func_ex)
+ load_source_data->open_func_ex (book, error, load_source_data->open_func_data);
free_load_source_data (load_source_data);
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_load_book_source:
* @source: an #ESource
@@ -277,6 +294,8 @@ load_source_cb (EBook *book, EBookStatus status, gpointer closure)
* @open_func, and no action will be taken on completion.
*
* Returns: A new #EBook that is being opened.
+ *
+ * Deprecated: 3.0: Use e_load_book_source_ex() instead.
**/
EBook *
e_load_book_source (ESource *source, EBookCallback open_func, gpointer user_data)
@@ -294,6 +313,46 @@ e_load_book_source (ESource *source, EBookCallback open_func, gpointer user_data
load_source_data->book = book;
g_object_ref (book);
- e_book_async_open (book, FALSE, load_source_cb, load_source_data);
+ e_book_async_open_ex (book, FALSE, load_source_cb, load_source_data);
+ return book;
+}
+#endif
+
+/**
+ * e_load_book_source_ex:
+ * @source: an #ESource
+ * @open_func_ex: a function to call when the operation finishes, or %NULL
+ * @user_data: data to pass to callback function
+ *
+ * Creates a new #EBook specified by @source, and starts a non-blocking
+ * open operation on it. If the book requires authorization, presents
+ * a window asking the user for such.
+ *
+ * When the operation finishes, calls the callback function indicating
+ * if it succeeded or not. If you don't care, you can pass %NULL for
+ * @open_func_ex, and no action will be taken on completion.
+ *
+ * Returns: A new #EBook that is being opened.
+ *
+ * Since: 3.0
+ **/
+EBook *
+e_load_book_source_ex (ESource *source, EBookExCallback open_func_ex, gpointer user_data)
+{
+ EBook *book;
+ LoadSourceData *load_source_data = g_new0 (LoadSourceData, 1);
+
+ load_source_data->source = g_object_ref (source);
+ load_source_data->open_func_ex = open_func_ex;
+ load_source_data->open_func_data = user_data;
+
+ book = e_book_new (source, NULL);
+ if (!book)
+ return NULL;
+
+ load_source_data->book = book;
+ g_object_ref (book);
+ e_book_async_open_ex (book, FALSE, load_source_cb, load_source_data);
+
return book;
}
diff --git a/libedataserverui/e-book-auth-util.h b/libedataserverui/e-book-auth-util.h
index 5bcb893..4401cf7 100644
--- a/libedataserverui/e-book-auth-util.h
+++ b/libedataserverui/e-book-auth-util.h
@@ -28,6 +28,10 @@
#include <libebook/e-book.h>
+#ifndef E_BOOK_DISABLE_DEPRECATED
EBook *e_load_book_source (ESource *source, EBookCallback open_func, gpointer user_data);
+#endif
+
+EBook *e_load_book_source_ex (ESource *source, EBookExCallback open_func, gpointer user_data);
#endif
diff --git a/libedataserverui/e-contact-store.c b/libedataserverui/e-contact-store.c
index b5095bc..21fd677 100644
--- a/libedataserverui/e-contact-store.c
+++ b/libedataserverui/e-contact-store.c
@@ -607,7 +607,7 @@ view_contacts_changed (EContactStore *contact_store, const GList *contacts, EBoo
}
static void
-view_sequence_complete (EContactStore *contact_store, EBookViewStatus status, EBookView *book_view)
+view_complete (EContactStore *contact_store, EBookViewStatus status, const gchar *error_msg, EBookView *book_view)
{
ContactSource *source;
gint offset;
@@ -688,8 +688,8 @@ start_view (EContactStore *contact_store, EBookView *view)
G_CALLBACK (view_contacts_removed), contact_store);
g_signal_connect_swapped (view, "contacts_changed",
G_CALLBACK (view_contacts_changed), contact_store);
- g_signal_connect_swapped (view, "sequence_complete",
- G_CALLBACK (view_sequence_complete), contact_store);
+ g_signal_connect_swapped (view, "view_complete",
+ G_CALLBACK (view_complete), contact_store);
e_book_view_start (view);
}
diff --git a/libedataserverui/e-name-selector-dialog.c b/libedataserverui/e-name-selector-dialog.c
index 2ca361a..402bd24 100644
--- a/libedataserverui/e-name-selector-dialog.c
+++ b/libedataserverui/e-name-selector-dialog.c
@@ -771,24 +771,29 @@ status_message(EBookView *view, const gchar *message, ENameSelectorDialog *dialo
}
static void
-sequence_complete(EBookView *view, EBookViewStatus status, ENameSelectorDialog *dialog)
+view_complete(EBookView *view, EBookViewStatus status, const gchar *error_msg, ENameSelectorDialog *dialog)
{
status_message(view, NULL, dialog);
}
static void
-book_opened (EBook *book, EBookStatus status, gpointer data)
+book_opened (EBook *book, const GError *error, gpointer data)
{
ENameSelectorDialog *name_selector_dialog = E_NAME_SELECTOR_DIALOG (data);
EContactStore *contact_store;
EBookView *view;
- if (status != E_BOOK_ERROR_OK) {
- /* TODO: Handle errors gracefully */
+ if (error) {
+ gchar *msg;
+
+ msg = g_strdup_printf ("Error loading addressbook, code:%d (%s)", error->code, error->message);
+
gtk_label_set_text(
name_selector_dialog->priv->status_label,
- "Error loading addressbook");
- g_warning ("ENameSelectorDialog failed to open book!");
+ msg);
+
+ g_warning ("ENameSelectorDialog failed to open book! (%d - %s)", error->code, error->message);
+
return;
}
@@ -797,7 +802,7 @@ book_opened (EBook *book, EBookStatus status, gpointer data)
e_contact_store_add_book (contact_store, book);
view = find_contact_source_by_book_return_view(contact_store, book);
g_signal_connect(view, "status_message", G_CALLBACK(status_message), name_selector_dialog);
- g_signal_connect(view, "sequence_complete", G_CALLBACK(sequence_complete), name_selector_dialog);
+ g_signal_connect(view, "view_complete", G_CALLBACK(view_complete), name_selector_dialog);
g_object_unref (book);
name_selector_dialog->priv->pending_book = NULL;
@@ -815,7 +820,7 @@ source_changed (ENameSelectorDialog *name_selector_dialog,
remove_books (name_selector_dialog);
/* Start loading selected book */
- name_selector_dialog->priv->pending_book = e_load_book_source (
+ name_selector_dialog->priv->pending_book = e_load_book_source_ex (
source, book_opened, name_selector_dialog);
}
diff --git a/libedataserverui/e-name-selector-entry.c b/libedataserverui/e-name-selector-entry.c
index bfe053a..093d52d 100644
--- a/libedataserverui/e-name-selector-entry.c
+++ b/libedataserverui/e-name-selector-entry.c
@@ -1948,7 +1948,7 @@ setup_default_contact_store (ENameSelectorEntry *name_selector_entry)
if (!completion || g_ascii_strcasecmp (completion, "true"))
continue;
- book = e_load_book_source (source, NULL, NULL);
+ book = e_load_book_source_ex (source, NULL, NULL);
if (!book)
continue;
diff --git a/libedataserverui/e-name-selector.c b/libedataserverui/e-name-selector.c
index 4726e23..ccf58c2 100644
--- a/libedataserverui/e-name-selector.c
+++ b/libedataserverui/e-name-selector.c
@@ -101,7 +101,7 @@ load_books_thread (gpointer user_data)
if (!completion || g_ascii_strcasecmp (completion, "true"))
continue;
- source_book.book = e_load_book_source (source, NULL, NULL);
+ source_book.book = e_load_book_source_ex (source, NULL, NULL);
if (!source_book.book)
continue;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]