[evolution-ews/gnome-2-28: 41/41] Merge branch 'master' into gnome-2-28
- From: Chenthill Palanisamy <pchen src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/gnome-2-28: 41/41] Merge branch 'master' into gnome-2-28
- Date: Mon, 12 Sep 2011 10:27:37 +0000 (UTC)
commit a7233074ae511423ab133f540693686a5dea54a8
Merge: 7f65546 23a5203
Author: Chenthill Palanisamy <pchenthill novell com>
Date: Mon Sep 12 10:22:40 2011 +0530
Merge branch 'master' into gnome-2-28
Conflicts:
src/account-setup-eplugin/exchange-ews-account-listener.c
src/addressbook/e-book-backend-ews-gal.c
src/addressbook/e-book-backend-ews.c
src/calendar/e-cal-backend-ews.c
src/camel/camel-ews-store.c
src/camel/camel-ews-transport.c
src/utils/Makefile.am
src/utils/ews-camel-compat.c
src/utils/ews-camel-compat.h
po/pl.po | 231 +++++++++----------
.../exchange-ews-account-listener.c | 1 +
.../exchange-ews-account-setup.c | 59 +++--
src/addressbook/e-book-backend-ews-gal.c | 2 +-
src/addressbook/e-book-backend-ews.c | 238 +++++++++++++++++++-
src/addressbook/e-book-backend-sqlitedb.c | 33 +++-
src/addressbook/lzx/ews-oal-decompress.c | 18 +-
src/calendar/e-cal-backend-ews-utils.c | 28 ++-
src/calendar/e-cal-backend-ews-utils.h | 3 +-
src/calendar/e-cal-backend-ews.c | 200 +++++++++++------
src/camel/camel-ews-folder.c | 4 +-
src/camel/camel-ews-provider.c | 4 +-
src/camel/camel-ews-store.c | 176 ++++++++-------
src/camel/camel-ews-transport.c | 12 +-
src/camel/camel-ews-utils.c | 14 +-
src/server/e-ews-connection.c | 34 +++
src/server/e-ews-connection.h | 11 +
src/server/e-ews-item-change.c | 30 +++
src/server/e-ews-item-change.h | 4 +
src/server/e-ews-item.c | 3 +-
src/utils/Makefile.am | 2 +-
src/utils/ews-camel-compat.c | 45 ++++-
src/utils/ews-camel-compat.h | 8 +
23 files changed, 833 insertions(+), 327 deletions(-)
---
diff --cc src/addressbook/e-book-backend-ews-gal.c
index e738e43,54b5d90..b9cf10b
--- a/src/addressbook/e-book-backend-ews-gal.c
+++ b/src/addressbook/e-book-backend-ews-gal.c
@@@ -1001,11 -988,10 +1001,11 @@@ e_book_backend_ews_gal_load_source (EB
priv->attachment_dir = g_build_filename (cache_dir, "attachments", NULL);
g_mkdir_with_parents (priv->attachment_dir, 0777);
- priv->ebsdb = e_book_backend_sqlitedb_new (cache_dir, email, priv->oal_id, priv->folder_name, FALSE, &err);
+ priv->ebsdb = e_book_backend_sqlitedb_new (cache_dir, email, priv->oal_id, priv->folder_name, TRUE, &err);
+ g_free (cache_dir);
if (err) {
- g_propagate_error (perror, err);
- return;
+ g_clear_error (&err);
+ return EDB_ERROR (OtherError);
}
priv->marked_for_offline = TRUE;
}
diff --cc src/addressbook/e-book-backend-ews.c
index 5a1d53f,5d7ceeb..2da3478
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@@ -690,6 -776,107 +774,107 @@@ e_book_backend_ews_remove_contacts (EBo
}
}
+ typedef struct {
+ EBookBackendEws *ebews;
+ EDataBook *book;
+ EContact *new_contact;
+ EContact *old_contact;
+ guint32 opid;
+ } EwsModifyContact;
+
+ static void
+ ews_modify_contact_cb (GObject *object, GAsyncResult *res, gpointer user_data)
+ {
+ EEwsConnection *cnc = E_EWS_CONNECTION (object);
+ EwsModifyContact *modify_contact = user_data;
+ EBookBackendEws *ebews = modify_contact->ebews;
+ EBookBackendEwsPrivate *priv = ebews->priv;
+ GError *error = NULL;
+ GSList *items = NULL;
+ gchar *id;
+ const EwsId *item_id;
+
+ g_object_ref (modify_contact->new_contact);
+ g_object_ref (modify_contact->old_contact);
+
+
+ e_ews_connection_update_items_finish(cnc, res, &items, &error);
+
+ if (error == NULL) {
+ EEwsItem *item = (EEwsItem *) items->data;
+
+ /* set item id */
+ item_id = e_ews_item_get_id((EEwsItem *)items->data);
+
+ e_contact_set (modify_contact->new_contact, E_CONTACT_UID, item_id->id);
+ e_contact_set (modify_contact->new_contact, E_CONTACT_REV, item_id->change_key);
+
+ id = e_contact_get (modify_contact->old_contact, E_CONTACT_UID);
+
+ e_book_backend_sqlitedb_remove_contact (priv->ebsdb, priv->folder_id, id, &error);
+ e_book_backend_sqlitedb_add_contact (ebews->priv->ebsdb, ebews->priv->folder_id, modify_contact->new_contact, FALSE, &error);
+
+ if (error == NULL)
- e_data_book_respond_modify (modify_contact->book, modify_contact->opid, EDB_ERROR (SUCCESS), modify_contact->new_contact);
++ e_data_book_respond_modify (modify_contact->book, modify_contact->opid, EDB_ERROR (Success), modify_contact->new_contact);
+
+ g_object_unref (item);
+ g_slist_free (items);
+ }
+
+ if (error) {
+ g_warning("Error while Creating contact: %s", error->message);
- e_data_book_respond_modify (modify_contact->book, modify_contact->opid, EDB_ERROR_EX (OTHER_ERROR, error->message), modify_contact->new_contact);
++ e_data_book_respond_modify (modify_contact->book, modify_contact->opid, EDB_ERROR (OtherError), modify_contact->new_contact);
+ }
+
+ /* free memory allocated for create_contact & unref contained objects */
+ g_object_unref(modify_contact->ebews);
+ g_object_unref(modify_contact->new_contact);
+ g_object_unref(modify_contact->old_contact);
+ g_free(modify_contact);
+ g_clear_error (&error);
+ }
+
+ static void
+ convert_contact_to_updatexml (ESoapMessage *msg, gpointer user_data)
+ {
+ EwsModifyContact *modify_contact = user_data;
+ EwsId *id;
+ EContact *old_contact = modify_contact->old_contact;
+ EContact *new_contact = modify_contact->new_contact;
+ gchar *value = NULL, *old_value = NULL ;
+ gint i, element_type;
+
+ id = g_new0 (EwsId, 1);
+ id->id = e_contact_get (old_contact, E_CONTACT_UID);
+ id->change_key = e_contact_get (old_contact, E_CONTACT_REV);
+
+ e_ews_message_start_item_change (msg, E_EWS_ITEMCHANGE_TYPE_ITEM,
+ id->id, id->change_key, 0);
+
+ /*Iterate for each field in contact*/
+
+ for (i = 0; i < G_N_ELEMENTS (mappings); i++) {
+ element_type = mappings[i].element_type;
+ if (element_type == ELEMENT_TYPE_SIMPLE) {
+ value = e_contact_get (new_contact, mappings[i].field_id);
+ old_value = e_contact_get (old_contact, mappings[i].field_id);
+ if (value)
+ {
+ if(( *value && !old_value) || g_ascii_strcasecmp (value, old_value))
+ convert_contact_property_to_updatexml(msg, mappings[i].element_name, value, "contacts", NULL, NULL);
+ g_free(value);
+ }
+ if(old_value)
+ g_free(old_value);
+ } else if (element_type == ELEMENT_TYPE_COMPLEX) {
+ if(mappings [i].field_id == E_CONTACT_UID)
+ continue;
+ mappings[i].set_changes (msg, new_contact, old_contact);
+ }
+ }
+
+ e_ews_message_end_item_change (msg);
+ }
static void
e_book_backend_ews_modify_contact (EBookBackend *backend,
@@@ -697,33 -884,54 +882,54 @@@
guint32 opid,
const gchar *vcard)
{
- EContact *contact = NULL;
- EBookBackendEws *egwb;
+ EContact *contact = NULL, *old_contact;
+ EwsModifyContact *modify_contact;
+ EBookBackendEws *ebews;
+ EwsId *id;
+ EBookBackendEwsPrivate *priv;
+ GCancellable *cancellable = NULL;
+ GError *error;
- egwb = E_BOOK_BACKEND_EWS (backend);
- switch (egwb->priv->mode) {
+ ebews = E_BOOK_BACKEND_EWS (backend);
+ priv = ebews->priv;
+
+ switch (priv->mode) {
- case E_DATA_BOOK_MODE_LOCAL :
- e_data_book_respond_modify (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
+ case GNOME_Evolution_Addressbook_MODE_LOCAL :
+ e_data_book_respond_modify (book, opid, EDB_ERROR (RepositoryOffline), NULL);
return;
- case E_DATA_BOOK_MODE_REMOTE :
+ case GNOME_Evolution_Addressbook_MODE_REMOTE :
- if (egwb->priv->cnc == NULL) {
- if (priv->cnc == NULL) {
- e_data_book_respond_modify (book, opid, EDB_ERROR (AUTHENTICATION_REQUIRED), NULL);
++ if (ebews->priv->cnc == NULL) {
+ e_data_book_respond_modify (book, opid, EDB_ERROR (AuthenticationRequired), NULL);
return;
}
- if (!egwb->priv->is_writable) {
- if (!priv->is_writable) {
- e_data_book_respond_modify (book, opid, EDB_ERROR (PERMISSION_DENIED), NULL);
++ if (!ebews->priv->is_writable) {
+ e_data_book_respond_modify (book, opid, EDB_ERROR (PermissionDenied), NULL);
return;
}
contact = e_contact_new_from_vcard (vcard);
+ id = g_new0 (EwsId, 1);
+ id->id = e_contact_get (contact, E_CONTACT_UID);
+ id->change_key = e_contact_get (contact, E_CONTACT_REV);
+
+ /*get item id and change key from contact and fetch old contact and assign.*/
+
if (e_contact_get (contact, E_CONTACT_IS_LIST)) {
g_object_unref (contact);
- e_data_book_respond_create (book, opid, EDB_ERROR (OtherError), NULL);
- e_data_book_respond_modify (book, opid, EDB_ERROR (NOT_SUPPORTED), NULL);
++ e_data_book_respond_modify (book, opid, EDB_ERROR (OtherError), NULL);
+ return;
+ }
+
+ old_contact = e_book_backend_sqlitedb_get_contact ( priv->ebsdb, priv->folder_id,
+ id->id, &error);
+ if (!old_contact) {
+ g_object_unref (contact);
- e_data_book_respond_modify (book, opid, EDB_ERROR (NOT_SUPPORTED), NULL);
++ e_data_book_respond_modify (book, opid, EDB_ERROR (OtherError), NULL);
return;
}
diff --cc src/calendar/e-cal-backend-ews.c
index 1288722,4246a2a..379d4c4
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@@ -923,9 -879,13 +939,12 @@@ ews_cal_append_exdate (ECalBackendEws *
typedef struct {
ECalBackendEws *cbews;
EDataCal *cal;
- ECalComponent *comp;
+ ECalComponent *comp, *parent;
- EServerMethodContext context;
EwsId item_id;
guint index;
+ gchar *rid;
+ gboolean modified;
+ CalObjModType mod;
} EwsRemoveData;
static void
@@@ -937,27 -897,17 +956,18 @@@ ews_cal_remove_object_cb (GObject *obje
simple = G_SIMPLE_ASYNC_RESULT (res);
- if (!g_simple_async_result_propagate_error (simple, &error)) {
+ if (!g_simple_async_result_propagate_error (simple, &error) || error->code == EWS_CONNECTION_ERROR_ITEMNOTFOUND) {
/* FIXME: This is horrid. Will bite us when we start to delete
more than one item at a time... */
- if (remove_data->comp)
- ews_cal_delete_comp (remove_data->cbews, remove_data->comp, remove_data->item_id.id);
- } else {
- /*In case where item already removed, we do not want to fail*/
- if (error->code == EWS_CONNECTION_ERROR_ITEMNOTFOUND) {
- g_clear_error (&error);
- /*probably we are not in sync, let's sync with server*/
- ews_start_sync (remove_data->cbews);
- } else
- error->code = EDC_CODE(OtherError);
- }
-
- if (remove_data->cal) {
- if (!error && remove_data->index != 0) ews_start_sync (remove_data->cbews);
- /* FIXME BUG */
- if (remove_data->cal)
- e_data_cal_notify_remove (remove_data->cal, EDC_ER_CODE(error));
- } else if (error) {
+ if (remove_data->comp) ews_cal_delete_comp (remove_data->cbews, remove_data->comp, remove_data->item_id.id);
+ if (remove_data->parent) ews_cal_append_exdate (remove_data->cbews, remove_data->parent, remove_data->rid, remove_data->mod);
+
- } else error->code = OtherError;
++ } else error->code = EDC_CODE(OtherError);
+
- if (remove_data->context)
- e_data_cal_notify_remove (remove_data->cal, remove_data->context, error);
++ /* FIXME BUG */
++ if (remove_data->cal)
++ e_data_cal_notify_remove (remove_data->cal, EDC_ER_CODE (error));
+ else if (error) {
g_warning ("Remove object error : %s\n", error->message);
g_clear_error (&error);
}
@@@ -1008,9 -961,13 +1021,13 @@@ e_cal_backend_ews_remove_object (ECalBa
EwsId item_id;
guint index = 0;
+ /* There are 3 scenarios where this function is called:
+ * 1. An item with no recurrence - rid is NULL. Nothing special here.
+ * 2. A modified occurrence of a recurring event - rid isnt NULL. The store will contain the object which will have to be removed from it.
+ * 3. A non modified occurrence of a recurring event - rid isnt NULL. The store will only have a reference to the master event.
+ * This is actually an update event where an exception date will have to be appended to the master.
+ */
- e_data_cal_error_if_fail (E_IS_CAL_BACKEND_EWS (cbews), InvalidArg);
+ e_data_cal_error_if_fail (E_IS_CAL_BACKEND_EWS (cbews), OtherError);
- /*We have to run sync before some write operations, in some cases we may need a new change key for our items */
- ews_start_sync (cbews);
priv = cbews->priv;
@@@ -1048,8 -1008,9 +1068,9 @@@
remove_data = g_new0 (EwsRemoveData, 1);
remove_data->cbews = g_object_ref(cbews);
remove_data->comp = comp;
+ if (cal)
+ remove_data->cal = g_object_ref(cal);
+ remove_data->parent = parent;
- remove_data->cal = g_object_ref(cal);
- remove_data->context = context;
remove_data->index = index;
remove_data->item_id.id = item_id.id;
remove_data->item_id.change_key = item_id.change_key;
@@@ -1060,11 -1023,16 +1083,17 @@@
remove_data);
return;
+ errorlvl2:
+ if (comp) g_object_unref (comp);
+
+ errorlvl1:
+ if (parent) g_object_unref (parent);
+
exit:
- if (context)
- e_data_cal_notify_remove (cal, context, error);
- else if (error) {
+ /* FIXME BUG */
+ if (cal)
+ e_data_cal_notify_remove (cal, EDC_ER_CODE(error));
+ if (error) {
g_warning ("Remove object error : %s\n", error->message);
g_clear_error (&error);
}
@@@ -1497,10 -1471,14 +1527,12 @@@ ews_create_object_cb(GObject *object, G
e_cal_component_commit_sequence(create_data->comp);
put_component_to_store (create_data->cbews, create_data->comp);
- /* notify the backend and the application that a new object was created */
- e_cal_backend_notify_object_created (E_CAL_BACKEND(create_data->cbews), create_data->context);
-
+ /* notify the backend and the application that a new object was created. FIXME - check if its works fine - backport issue */
e_cal_component_get_uid(create_data->comp, &comp_uid);
- e_data_cal_notify_object_created (create_data->cal, EDC_ER_CODE(error), comp_uid, e_cal_component_get_as_string(create_data->comp));
+ comp_str = e_cal_component_get_as_string(create_data->comp);
- e_data_cal_notify_object_created (create_data->cal, create_data->context, error, comp_uid, comp_str);
++ e_data_cal_notify_object_created (create_data->cal, EDC_ER_CODE(error), comp_uid, comp_str);
+ g_free (comp_str);
/* place new component in our cache */
PRIV_LOCK (priv);
@@@ -1718,15 -1698,14 +1752,15 @@@ ews_cal_modify_object_cb (GObject *obje
comp_str = e_cal_component_get_as_string (modify_data->comp);
comp_str_old = e_cal_component_get_as_string (modify_data->oldcomp);
- if (modify_data->context) {
+ if (modify_data->cal) {
e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbews), comp_str_old, comp_str);
- e_data_cal_notify_object_modified (modify_data->cal, modify_data->context, error, comp_str_old, comp_str);
+ e_data_cal_notify_object_modified (modify_data->cal, EDC_ER_CODE(error), comp_str_old, comp_str);
}
- else if (error) {
+
+ if (error) {
g_warning ("Modify object error : %s\n", error->message);
g_clear_error (&error);
- }
+ } else ews_start_sync (modify_data->cbews);
PRIV_LOCK (priv);
g_hash_table_replace (priv->item_id_hash, g_strdup(modify_data->itemid), g_object_ref (modify_data->comp));
@@@ -3208,16 -3224,19 +3276,16 @@@ ews_cal_sync_items_ready_cb (GObject *o
PRIV_LOCK (priv);
- if (priv->opening_ctx) {
+ if (priv->opening_cal) {
/* Report success/failure for calendar open if pending,
translating an authentication failure into something that
- will be recognised and handled appropriately */
+ will be recognized and handled appropriately */
if (error && error->domain == EWS_CONNECTION_ERROR &&
error->code == EWS_CONNECTION_ERROR_AUTHENTICATION_FAILED) {
- e_data_cal_notify_open(priv->opening_cal, priv->opening_ctx,
- EDC_ERROR(AuthenticationFailed));
+ e_data_cal_notify_open(priv->opening_cal, EDC_CODE(AuthenticationFailed));
} else {
- e_data_cal_notify_open(priv->opening_cal, priv->opening_ctx,
- error?g_error_copy (error):NULL);
+ e_data_cal_notify_open(priv->opening_cal, EDC_ER_CODE(error));
}
- priv->opening_ctx = NULL;
priv->opening_cal = NULL;
if (error) {
priv->cnc = NULL;
diff --cc src/camel/camel-ews-store.c
index 320bddb,3783b56..3ee4790
--- a/src/camel/camel-ews-store.c
+++ b/src/camel/camel-ews-store.c
@@@ -45,8 -45,8 +45,9 @@@
#include "camel-ews-store.h"
#include "camel-ews-summary.h"
#include "camel-ews-utils.h"
+ #include "ews-camel-compat.h"
#include "ews-esource-utils.h"
+#include "ews-camel-compat.h"
#ifdef G_OS_WIN32
#include <winsock2.h>
@@@ -92,9 -90,54 +93,56 @@@ static inline gboolean camel_offline_st
#endif
extern CamelServiceAuthType camel_ews_password_authtype; /*for the query_auth_types function*/
+ static gboolean ews_store_construct (CamelService *service, CamelSession *session,
+ CamelProvider *provider, CamelURL *url,
+ GError **error);
+ #if EDS_CHECK_VERSION(3,1,0)
+ static void camel_ews_store_initable_init (GInitableIface *interface);
+ static GInitableIface *parent_initable_interface;
+
+ G_DEFINE_TYPE_WITH_CODE (
+ CamelEwsStore, camel_ews_store, CAMEL_TYPE_OFFLINE_STORE,
+ G_IMPLEMENT_INTERFACE (
+ G_TYPE_INITABLE, camel_ews_store_initable_init))
+
+ static gboolean
+ ews_store_initable_init (GInitable *initable,
+ GCancellable *cancellable,
+ GError **error)
+ {
+ CamelService *service;
+ CamelSession *session;
+ CamelURL *url;
+ gboolean ret;
+
+ service = CAMEL_SERVICE (initable);
+ url = camel_service_get_camel_url (service);
+ session = camel_service_get_session (service);
+
+ /* Chain up to parent interface's init() method. */
+ if (!parent_initable_interface->init (initable, cancellable, error))
+ return FALSE;
+
+ ret = ews_store_construct (service, session, NULL, url, error);
+
+ /* Add transport here ? */
+
+ return ret;
+ }
+
+ static void
+ camel_ews_store_initable_init (GInitableIface *interface)
+ {
+ parent_initable_interface = g_type_interface_peek_parent (interface);
+
+ interface->init = ews_store_initable_init;
+ }
+ #else
+#if EDS_CHECK_VERSION(2,31,0)
G_DEFINE_TYPE (CamelEwsStore, camel_ews_store, CAMEL_TYPE_OFFLINE_STORE)
++#endif /* 2,31,0 */
+
#endif
static gboolean
@@@ -105,21 -148,18 +153,24 @@@ ews_store_construct (CamelService *serv
CamelEwsStore *ews_store;
CamelEwsStorePrivate *priv;
gchar *summary_file, *session_storage_path;
+ CamelException ex;
- ews_store = (CamelEwsStore *) service;
- priv = ews_store->priv;
+ #if ! EDS_CHECK_VERSION(3,1,0)
+ CamelServiceClass *service_class;
/* Chain up to parent's construct() method. */
- service_class = CAMEL_SERVICE_CLASS (camel_ews_store_parent_class);
- if (!service_class->construct (service, session, provider, url, error))
+ service_class = CAMEL_SERVICE_CLASS (parent_class);
+ camel_exception_init (&ex);
+ service_class->construct (service, session, provider, url, &ex);
+
+ if (camel_exception_is_set (&ex)) {
+ ews_compat_propagate_exception_to_gerror (&ex, error);
return FALSE;
+ }
+ #endif
+
+ ews_store = (CamelEwsStore *) service;
+ priv = ews_store->priv;
/* Disable virtual trash and junk folders. Exchange has real
folders for that */
@@@ -425,42 -453,25 +468,25 @@@ ews_folder_hierarchy_ready_cb (GObject
ews_update_folder_hierarchy (ews_store, sync_state, includes_last_folder,
folders_created, folders_deleted, folders_updated);
- if (!sync_data->sync) {
- g_mutex_lock (priv->get_finfo_lock);
- ews_store->priv->last_refresh_time = time (NULL);
- g_mutex_unlock (priv->get_finfo_lock);
- }
+ g_mutex_lock (priv->get_finfo_lock);
+ ews_store->priv->last_refresh_time = time (NULL);
+ g_mutex_unlock (priv->get_finfo_lock);
exit:
- if (sync_data->sync) {
- e_flag_set (sync_data->sync);
- if (error)
- g_propagate_error (sync_data->error, error);
-
- } else {
- g_free (sync_data);
- g_clear_error (&error);
- }
+ g_object_unref (ews_store);
+ g_clear_error (&error);
}
- struct _ews_refresh_msg {
- CamelSessionThreadMsg msg;
- CamelStore *store;
- };
-
- static void
- ews_refresh_finfo (CamelSession *session, CamelSessionThreadMsg *msg)
+ static gboolean
+ ews_refresh_finfo (CamelEwsStore *ews_store)
{
- struct _ews_refresh_msg *m = (struct _ews_refresh_msg *)msg;
- CamelEwsStore *ews_store = (CamelEwsStore *) m->store;
gchar *sync_state;
- struct _store_sync_data *sync_data;
-
+
if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (ews_store)))
- return;
+ return FALSE;
- if (!EVO3_sync(camel_service_connect) ((CamelService *) ews_store, NULL))
+ if (!camel_service_connect_compat ((CamelService *) ews_store, NULL))
- return;
+ return FALSE;
sync_state = camel_ews_store_summary_get_string_val (ews_store->summary, "sync_state", NULL);
@@@ -1015,14 -906,22 +1022,17 @@@ camel_ews_store_class_init (CamelEwsSto
CamelServiceClass *service_class;
CamelStoreClass *store_class;
- g_type_class_add_private (class, sizeof (CamelEwsStorePrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->dispose = ews_store_dispose;
- object_class->finalize = ews_store_finalize;
+ parent_class = CAMEL_OFFLINE_STORE_CLASS (camel_type_get_global_classfuncs (camel_offline_store_get_type ()));
service_class = CAMEL_SERVICE_CLASS (class);
+
+ #if ! EDS_CHECK_VERSION(3,1,0)
- service_class->construct = ews_store_construct;
+ service_class->construct = ews_store_construct_compat;
+ #endif
- service_class->EVO3_sync(query_auth_types) = ews_store_query_auth_types_sync;
+ service_class->EVO3_sync(query_auth_types) = ews_store_query_auth_types_compat;
service_class->get_name = ews_get_name;
- service_class->EVO3_sync(connect) = ews_connect_sync;
- service_class->EVO3_sync(disconnect) = ews_disconnect_sync;
+ service_class->EVO3_sync(connect) = ews_connect_compat;
+ service_class->EVO3_sync(disconnect) = ews_disconnect_compat;
store_class = CAMEL_STORE_CLASS (class);
store_class->hash_folder_name = ews_hash_folder_name;
diff --cc src/camel/camel-ews-transport.c
index b5d7685,fbc792d..b2d4601
--- a/src/camel/camel-ews-transport.c
+++ b/src/camel/camel-ews-transport.c
@@@ -72,18 -78,18 +74,20 @@@ ews_send_to_sync (CamelTransport *trans
CamelService *service;
EEwsConnection *cnc;
const gchar *host_url;
+ CamelURL *url;
gboolean res;
+ GError *error = NULL;
service = CAMEL_SERVICE (transport);
- host_url = camel_url_get_param (service->url, "hosturl");
+ url = camel_service_get_camel_url (service);
+ host_url = camel_url_get_param (url, "hosturl");
- cnc = e_ews_connection_find (host_url, service->url->user);
+ cnc = e_ews_connection_find (host_url, url->user);
if (!cnc) {
- g_set_error (error, CAMEL_SERVICE_ERROR,
+ g_set_error (&error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_NOT_CONNECTED,
_("Service not connected"));
+ ews_compat_propagate_gerror_to_exception (error, ex);
return FALSE;
}
diff --cc src/camel/camel-ews-utils.c
index 1d381a2,70fd16c..1eb0b75
--- a/src/camel/camel-ews-utils.c
+++ b/src/camel/camel-ews-utils.c
@@@ -33,8 -33,8 +33,9 @@@
#include "camel-ews-utils.h"
#include "ews-esource-utils.h"
#include "e-ews-compat.h"
+ #include "ews-camel-compat.h"
#include "e-ews-message.h"
+#include "ews-camel-compat.h"
#define SUBFOLDER_DIR_NAME "subfolders"
#define SUBFOLDER_DIR_NAME_LEN 10
diff --cc src/utils/ews-camel-compat.c
index 3edb001,07f3877..1d120ce
--- a/src/utils/ews-camel-compat.c
+++ b/src/utils/ews-camel-compat.c
@@@ -20,362 -20,61 +20,405 @@@
#include "ews-camel-compat.h"
+gint
+camel_stream_flush_compat (CamelStream *stream, GCancellable *cancellable, GError **error)
+{
+#if EDS_CHECK_VERSION(2,33,0)
+ return camel_stream_flush (stream, cancellable, error);
+#elif EDS_CHECK_VERSION(2,29,0)
+ return camel_stream_flush (stream, error);
+#else
+ return camel_stream_flush (stream);
+#endif
+}
+
+gint
+camel_stream_close_compat (CamelStream *stream, GCancellable *cancellable, GError **error)
+{
+#if EDS_CHECK_VERSION(2,33,0)
+ return camel_stream_close (stream, cancellable, error);
+#elif EDS_CHECK_VERSION(2,29,0)
+ return camel_stream_close (stream, error);
+#else
+ return camel_stream_close (stream);
+#endif
+}
+
+
gchar *
-camel_session_get_password_compat (CamelSession *session,
- CamelService *service,
- const gchar *domain,
- const gchar *prompt,
- const gchar *item,
- guint32 flags,
- GError **error)
+camel_data_cache_get_filename_compat (CamelDataCache *cdc,
+ const gchar *path,
+ const gchar *key,
+ GError **error)
{
+#if EDS_CHECK_VERSION(2,29,0)
+ return camel_data_cache_get_filename (cdc, path, key, error);
+#else
+ CamelException ex;
+ gchar *ret;
-#if ! EDS_CHECK_VERSION(3,1,0)
- return camel_session_get_password (session, service, domain, prompt, item, flags, error);
+ camel_exception_init (&ex);
+ ret = camel_data_cache_get_filename (cdc, path, key, &ex);
+ ews_compat_propagate_exception_to_gerror (&ex, error);
+
+ return ret;
+#endif
+}
+
+CamelDataCache *
+camel_data_cache_new_compat (const gchar *path,
+ GError **error)
+{
+#if EDS_CHECK_VERSION(2,29,0)
+ return camel_data_cache_new (path, error);
+#else
+ CamelException ex;
+ CamelDataCache *ret;
+
+ camel_exception_init (&ex);
+ ret = camel_data_cache_new (path, 0, &ex);
+ ews_compat_propagate_exception_to_gerror (&ex, error);
+
+ return ret;
+#endif
+}
+
+CamelStream *
+camel_data_cache_get_compat (CamelDataCache *cdc,
+ const gchar *path,
+ const gchar *key,
+ GError **error)
+{
+#if EDS_CHECK_VERSION(2,29,0)
+ return camel_data_cache_get (cdc, path, key, error);
+#else
+ CamelException ex;
+ CamelStream *ret;
+
+ camel_exception_init (&ex);
+ ret = camel_data_cache_get (cdc, path, key, &ex);
+ ews_compat_propagate_exception_to_gerror (&ex, error);
+
+ return ret;
+#endif
+}
+
+GPtrArray *
+camel_folder_search_search_compat (CamelFolderSearch *search,
+ const gchar *expr,
+ GPtrArray *uids,
+ GError **error)
+{
+#if EDS_CHECK_VERSION(2,29,0)
+ return camel_folder_search_search (search, expr, uids, error);
#else
+ CamelException ex;
+ GPtrArray *ret;
+
+ camel_exception_init (&ex);
+ ret = camel_folder_search_search (search, expr, uids, &ex);
+ ews_compat_propagate_exception_to_gerror (&ex, error);
+
+ return ret;
+#endif
+}
+
+guint32
+camel_folder_search_count_compat (CamelFolderSearch *search,
+ const gchar *expr,
+ GError **error)
+{
+#if EDS_CHECK_VERSION(2,29,0)
+ return camel_folder_search_count (search, expr, error);
+#else
+ CamelException ex;
+ guint32 ret;
+
+ camel_exception_init (&ex);
+ ret = camel_folder_search_count (search, expr, &ex);
+ ews_compat_propagate_exception_to_gerror (&ex, error);
+
+ return ret;
+#endif
+}
+
+gchar *
+camel_session_get_storage_path_compat (CamelSession *session,
+ CamelService *service,
+ GError **error)
+
+{
+#if EDS_CHECK_VERSION(2,29,0)
+ return camel_session_get_storage_path (session, service, error);
+#else
+ CamelException ex;
+ gchar *ret;
+
+ camel_exception_init (&ex);
+ ret = camel_session_get_storage_path (session, service, &ex);
+ ews_compat_propagate_exception_to_gerror (&ex, error);
+ return ret;
+#endif
+}
+
+gchar *
+camel_session_get_password_compat (CamelSession *session,
+ CamelService *service,
+ const gchar *domain,
+ const gchar *prompt,
+ const gchar *item,
+ guint32 flags,
+ GError **error)
+{
- #if EDS_CHECK_VERSION(2,29,0)
++
++#if EDS_CHECK_VERSION(3,1,0)
+ return camel_session_get_password (session, service, prompt, item, flags, error);
++#elif EDS_CHECK_VERSION(2,29,0)
+ return camel_session_get_password (session, service, domain, prompt, item, flags, error);
+#else
+ CamelException ex;
+ gchar *ret;
+
+ camel_exception_init (&ex);
+ ret = camel_session_get_password (session, service, domain, prompt, item, flags, &ex);
+ ews_compat_propagate_exception_to_gerror (&ex, error);
+ return ret;
+#endif
+}
+
+gboolean
+camel_service_connect_compat (CamelService *service,
+ GError **error)
+{
+#if EDS_CHECK_VERSION(2,33,0)
+ return camel_service_connect_sync (service, error);
+#elif EDS_CHECK_VERSION(2,29,0)
+ return camel_service_connect (service, error);
+#else
+ CamelException ex;
+ gboolean ret;
+
+ camel_exception_init (&ex);
+ ret = camel_service_connect (service, &ex);
+ ews_compat_propagate_exception_to_gerror (&ex, error);
+ return ret;
+#endif
+}
+
+#if ! EDS_CHECK_VERSION(2,33,0)
+gssize
+camel_data_wrapper_write_to_stream_sync (CamelDataWrapper *data_wrapper,
+ CamelStream *stream,
+ GCancellable *cancellable,
+ GError **error)
+{
+#if EDS_CHECK_VERSION(2,29,0)
+ return camel_data_wrapper_write_to_stream (data_wrapper, stream, error);
+#else
+ return camel_data_wrapper_write_to_stream (data_wrapper, stream);
#endif
}
+gssize
+camel_data_wrapper_decode_to_stream_sync (CamelDataWrapper *data_wrapper,
+ CamelStream *stream,
+ GCancellable *cancellable,
+ GError **error)
+{
+#if EDS_CHECK_VERSION(2,29,0)
+ return camel_data_wrapper_decode_to_stream (data_wrapper, stream, error);
+#else
+ return camel_data_wrapper_decode_to_stream (data_wrapper, stream);
+#endif
+}
+
+gboolean
+camel_data_wrapper_construct_from_stream_sync (CamelDataWrapper *data_wrapper,
+ CamelStream *stream,
+ GCancellable *cancellable,
+ GError **error)
+{
+ /* this returns an int, which is zero for success in earlier versions */
+#if EDS_CHECK_VERSION(2,29,0)
+ return !camel_data_wrapper_construct_from_stream(data_wrapper, stream, error);
+#else
+ return !camel_data_wrapper_construct_from_stream(data_wrapper, stream);
+#endif
+}
+
+gboolean
+camel_mime_part_construct_from_parser_sync (CamelMimePart *mime_part,
+ CamelMimeParser *parser,
+ GCancellable *cancellable,
+ GError **error)
+{
+#if EDS_CHECK_VERSION(2,29,0)
+ return camel_mime_part_construct_from_parser_sync (mime_part, parser, error);
+#else
+ return camel_mime_part_construct_from_parser (mime_part, parser);
+#endif
+}
+
+#endif /* missing apis in version < 3.0 */
+
+/* Missing apis in Evolution 2.28 */
+#if ! EDS_CHECK_VERSION(2,29,0)
+GQuark
+camel_error_quark_compat (void)
+{
+ static GQuark quark = 0;
+
+ if (G_UNLIKELY (quark == 0)) {
+ const gchar *string = "camel-error-quark";
+ quark = g_quark_from_static_string (string);
+ }
+
+ return quark;
+}
+
+GByteArray *
+camel_stream_mem_get_byte_array (CamelStreamMem *mem)
+{
+ return mem->buffer;
+}
+
+CamelDataWrapper *
+camel_medium_get_content (CamelMedium *medium)
+{
+ return medium->content;
+}
+
+const gchar *
+camel_data_cache_get_path (CamelDataCache *cdc)
+{
+ g_return_val_if_fail (CAMEL_IS_DATA_CACHE (cdc), NULL);
+
+ return cdc->path;
+}
+
+void
+camel_object_set_state_filename (CamelObject *object,
+ const gchar *state_filename)
+{
+ camel_object_set(object, NULL, CAMEL_OBJECT_STATE_FILE, state_filename, NULL);
+}
+
+
+void
+camel_folder_changed (CamelFolder *folder,
+ CamelFolderChangeInfo *changes)
+{
+ camel_object_trigger_event (folder, "folder_changed", changes);
+}
+
+void
+camel_service_lock (CamelService *service,
+ CamelServiceLock lock)
+{
+ /* dummy function. As this is present in camel-private.h we cannot implement a backward compatible
+ API from an external backend. I think its not necessary to use a service lock while deleting messages,
+ (ews _delete_messages)but since I have not investigated much on it, not removing it. */
+}
+
+void
+camel_service_unlock (CamelService *service,
+ CamelServiceLock lock)
+{
+ /* dummy function */
+}
+
+void
+camel_folder_summary_lock (CamelFolderSummary *summary,
+ CamelFolderSummaryLock lock)
+{
+ /* dummy function, same as service lock */
+}
+
+void
+camel_folder_summary_unlock (CamelFolderSummary *summary,
+ CamelFolderSummaryLock lock)
+{
+ /* dummy function, same as service lock */
+}
+
+void
+camel_folder_set_description (CamelFolder *folder,
+ const gchar *description)
+{
+ folder->description = g_strdup (description);
+}
+
+/* requires complete patch to be backported. isn't worth to backport it as
+ cancellation is not possible with 2.28 */
+void
+camel_folder_set_lock_async (CamelFolder *folder,
+ gboolean skip_folder_lock)
+{
+ /* dummy function */
+}
+
+CamelStream *
+camel_stream_filter_new (CamelStream *stream)
+{
+ return (CamelStream *) camel_stream_filter_new_with_stream (stream);
+}
+
+void
+ews_compat_propagate_exception_to_gerror (CamelException *ex, GError **error)
+{
+ if (error && camel_exception_is_set (ex)) {
+ g_set_error (error, CAMEL_ERROR, ex->id, "%s", ex->desc);
+ }
+ camel_exception_clear (ex);
+}
+
+void
+ews_compat_propagate_gerror_to_exception (GError *error, CamelException *ex)
+{
+ if (error && ex) {
+ camel_exception_set (ex, error->code, error->message);
+ }
+ g_clear_error (&error);
+}
++#endif /* 2.28 */
+
+ CamelService *
+ camel_session_get_service_compat (CamelSession *session, const gchar *url, CamelProviderType type)
+ {
+ #if ! EDS_CHECK_VERSION(3,1,0)
+ return camel_session_get_service (session, url, type, NULL);
+ #else
+ CamelURL *curl = camel_url_new (url, NULL);
+ CamelService *service;
+
+ service = camel_session_get_service_by_url (session, curl, type);
+ camel_url_free (curl);
+ return service;
+ #endif
+ }
+
+ #if ! EDS_CHECK_VERSION(3,1,0)
+
+ CamelURL *
+ camel_service_get_camel_url (CamelService *service)
+ {
+ g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
+
+ return service->url;
+ }
+
+ CamelServiceConnectionStatus
+ camel_service_get_connection_status (CamelService *service)
+ {
+ return service->status;
+ }
+
+ #else
+
+ gchar *
+ camel_session_get_storage_path (CamelSession *session, CamelService *service, GError **error)
+ {
+ return g_strdup (camel_service_get_user_data_dir (service));
+ }
#endif
diff --cc src/utils/ews-camel-compat.h
index 9024235,0bda345..ee08495
--- a/src/utils/ews-camel-compat.h
+++ b/src/utils/ews-camel-compat.h
@@@ -25,144 -25,22 +25,152 @@@
#include <glib.h>
#include <gio/gio.h>
-gchar *
-camel_session_get_password_compat (CamelSession *session,
- CamelService *service,
- const gchar *domain,
- const gchar *prompt,
- const gchar *item,
- guint32 flags,
- GError **error);
+/* APIs which have the same symbol name across versions but with arguments changed are suffixed with _compat.
+ Rest of the apis are maintained with the latest camel apis in master */
+gint camel_stream_flush_compat (CamelStream *stream,
+ GCancellable *cancellable,
+ GError **error);
+gint camel_stream_close_compat (CamelStream *stream,
+ GCancellable *cancellable,
+ GError **error);
+gchar * camel_data_cache_get_filename_compat
+ (CamelDataCache *cdc,
+ const gchar *path,
+ const gchar *key,
+ GError **error);
+CamelDataCache *camel_data_cache_new_compat (const gchar *path,
+ GError **error);
+CamelStream * camel_data_cache_get_compat (CamelDataCache *cdc,
+ const gchar *path,
+ const gchar *key,
+ GError **error);
+GPtrArray * camel_folder_search_search_compat
+ (CamelFolderSearch *search,
+ const gchar *expr,
+ GPtrArray *uids,
+ GError **error);
+guint32 camel_folder_search_count_compat
+ (CamelFolderSearch *search,
+ const gchar *expr,
+ GError **error);
+gchar * camel_session_get_storage_path_compat
+ (CamelSession *session,
+ CamelService *service,
+ GError **error);
+gchar * camel_session_get_password_compat
+ (CamelSession *session,
+ CamelService *service,
+ const gchar *domain,
+ const gchar *prompt,
+ const gchar *item,
+ guint32 flags,
+ GError **error);
+gboolean camel_service_connect_compat (CamelService *service,
+ GError **error);
+
+
+/* Missing apis or renamed apis beyond 3.0 */
+#if ! EDS_CHECK_VERSION(2,33,0)
+gssize camel_data_wrapper_write_to_stream_sync
+ (CamelDataWrapper *data_wrapper,
+ CamelStream *stream, GCancellable *cancellable,
+ GError **error);
+gssize camel_data_wrapper_decode_to_stream_sync
+ (CamelDataWrapper *data_wrapper,
+ CamelStream *stream,
+ GCancellable *cancellable,
+ GError **error);
+gboolean camel_data_wrapper_construct_from_stream_sync
+ (CamelDataWrapper *data_wrapper,
+ CamelStream *stream,
+ GCancellable *cancellable,
+ GError **error);
+gboolean camel_mime_part_construct_from_parser_sync
+ (CamelMimePart *mime_part,
+ CamelMimeParser *parser,
+ GCancellable *cancellable,
+ GError **error);
+#endif
+
+/* Missing api's and abi's in Evolution 2.28 */
+#if EDS_CHECK_VERSION(2,29,0)
+#else
+GQuark
+camel_error_quark_compat (void);
+
+/* Since 2.32 */
+#define CAMEL_ERROR \
+ (camel_error_quark_compat ())
+#define CAMEL_STORE_ERROR CAMEL_ERROR /* it doesn matter */
+#define CAMEL_SERVICE_ERROR CAMEL_ERROR /* it doesn matter */
+
+typedef enum {
+ CAMEL_ERROR_GENERIC /* lazy fallback error */
+} CamelError;
+
+typedef enum {
+ CAMEL_STORE_ERROR_INVALID,
+ CAMEL_STORE_ERROR_NO_FOLDER
+} CamelStoreError;
+
+
+typedef enum {
+ CAMEL_SERVICE_ERROR_INVALID,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ CAMEL_SERVICE_ERROR_NOT_CONNECTED
+} CamelServiceError;
+
+typedef enum _CamelFolderSummaryLock {
+ CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK,
+ CAMEL_FOLDER_SUMMARY_IO_LOCK,
+ CAMEL_FOLDER_SUMMARY_FILTER_LOCK,
+ CAMEL_FOLDER_SUMMARY_ALLOC_LOCK,
+ CAMEL_FOLDER_SUMMARY_REF_LOCK
+} CamelFolderSummaryLock;
+
+typedef enum {
+ CAMEL_SERVICE_REC_CONNECT_LOCK,
+ CAMEL_SERVICE_CONNECT_OP_LOCK
+} CamelServiceLock;
+
+GByteArray * camel_stream_mem_get_byte_array (CamelStreamMem *mem);
+CamelDataWrapper * camel_medium_get_content (CamelMedium *medium);
+const gchar * camel_data_cache_get_path (CamelDataCache *cdc);
+void camel_object_set_state_filename (CamelObject *object,
+ const gchar *state_filename);
+void camel_folder_changed (CamelFolder *folder,
+ CamelFolderChangeInfo *changes);
+void camel_service_lock (CamelService *service,
+ CamelServiceLock lock);
+void camel_service_unlock (CamelService *service,
+ CamelServiceLock lock);
+void camel_folder_summary_lock (CamelFolderSummary *summary,
+ CamelFolderSummaryLock lock);
+void camel_folder_summary_unlock (CamelFolderSummary *summary,
+ CamelFolderSummaryLock lock);
+void camel_folder_set_description (CamelFolder *folder,
+ const gchar *description);
+void camel_folder_set_lock_async (CamelFolder *folder,
+ gboolean skip_folder_lock);
+CamelStream * camel_stream_filter_new (CamelStream *stream);
+void ews_compat_propagate_exception_to_gerror
+ (CamelException *ex, GError **error);
+void ews_compat_propagate_gerror_to_exception
+ (GError *error,
+ CamelException *ex);
+
+
+#endif /* 2.28 api adds */
+ CamelService * camel_session_get_service_compat (CamelSession *session, const gchar *url, CamelProviderType type);
+ #if ! EDS_CHECK_VERSION(3,1,0)
+ CamelURL * camel_service_get_camel_url (CamelService *service);
+ CamelServiceConnectionStatus camel_service_get_connection_status (CamelService *service);
+
+ #else
+ gchar * camel_session_get_storage_path (CamelSession *session, CamelService *service, GError **error);
+ #endif
#endif /* EWS_CAMEL_COMPAT_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]