[evolution-groupwise] Adapt to EClient changes in eds master
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-groupwise] Adapt to EClient changes in eds master
- Date: Mon, 23 May 2011 11:03:43 +0000 (UTC)
commit 7291de611f680f8888a13b3a462efe6a66f4fbbd
Author: Milan Crha <mcrha redhat com>
Date: Mon May 23 13:03:13 2011 +0200
Adapt to EClient changes in eds master
configure.ac | 6 +-
src/addressbook/e-book-backend-groupwise.c | 1364 ++++++++++++--------------
src/calendar/e-cal-backend-groupwise-utils.c | 22 +-
src/calendar/e-cal-backend-groupwise-utils.h | 2 +-
src/calendar/e-cal-backend-groupwise.c | 800 ++++++----------
5 files changed, 941 insertions(+), 1253 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 047bf76..4a8a9f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,8 +64,6 @@ AS_COMPILER_FLAGS(WARNING_FLAGS,
-DGDK_DISABLE_DEPRECATED
-DGDK_PIXBUF_DISABLE_DEPRECATED
-DGTK_DISABLE_DEPRECATED
- -DE_BOOK_DISABLE_DEPRECATED
- -DE_CAL_DISABLE_DEPRECATED
-DG_DISABLE_SINGLE_INCLUDES
-DGTK_DISABLE_SINGLE_INCLUDES
-DGSEAL_ENABLE
@@ -81,6 +79,10 @@ AS_COMPILER_FLAGS(WARNING_FLAGS,
-Wredundant-decls -Wundef -Wwrite-strings")
AC_SUBST(WARNING_FLAGS)
+dnl Disable these later
+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/src/addressbook/e-book-backend-groupwise.c b/src/addressbook/e-book-backend-groupwise.c
index 947604f..283b92b 100644
--- a/src/addressbook/e-book-backend-groupwise.c
+++ b/src/addressbook/e-book-backend-groupwise.c
@@ -78,12 +78,12 @@ struct _EBookBackendGroupwisePrivate {
gboolean only_if_exists;
GHashTable *categories_by_id;
GHashTable *categories_by_name;
- gboolean is_writable;
+ gboolean is_readonly;
gboolean is_cache_ready;
gboolean is_summary_ready;
gboolean marked_for_offline;
gchar *use_ssl;
- gint mode;
+ gboolean is_online;
EBookBackendSummary *summary;
GMutex *update_cache_mutex;
GMutex *update_mutex;
@@ -1184,6 +1184,7 @@ static void
e_book_backend_groupwise_create_contact (EBookBackend *backend,
EDataBook *book,
guint32 opid,
+ GCancellable *cancellable,
const gchar *vcard )
{
EContact *contact;
@@ -1200,116 +1201,101 @@ e_book_backend_groupwise_create_contact (EBookBackend *backend,
egwb = E_BOOK_BACKEND_GROUPWISE (backend);
- switch (egwb->priv->mode) {
-
- case E_DATA_BOOK_MODE_LOCAL :
+ if (!egwb->priv->is_online) {
e_data_book_respond_create (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
+ }
- case E_DATA_BOOK_MODE_REMOTE :
-
- if (egwb->priv->cnc == 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, EDB_ERROR (PERMISSION_DENIED), NULL);
- return;
- }
- contact = e_contact_new_from_vcard (vcard);
- item = e_gw_item_new_empty ();
- e_gw_item_set_item_type (item, e_contact_get (contact, E_CONTACT_IS_LIST) ? E_GW_ITEM_TYPE_GROUP :E_GW_ITEM_TYPE_CONTACT);
- e_gw_item_set_container_id (item, g_strdup (egwb->priv->container_id));
+ if (egwb->priv->cnc == NULL) {
+ e_data_book_respond_create (book, opid, EDB_ERROR (AUTHENTICATION_REQUIRED), NULL);
+ return;
+ }
+ if (egwb->priv->is_readonly) {
+ e_data_book_respond_create (book, opid, EDB_ERROR (PERMISSION_DENIED), NULL);
+ return;
+ }
+ contact = e_contact_new_from_vcard (vcard);
+ item = e_gw_item_new_empty ();
+ e_gw_item_set_item_type (item, e_contact_get (contact, E_CONTACT_IS_LIST) ? E_GW_ITEM_TYPE_GROUP :E_GW_ITEM_TYPE_CONTACT);
+ e_gw_item_set_container_id (item, g_strdup (egwb->priv->container_id));
- 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 (contact, mappings[i].field_id);
- if (value != NULL)
- e_gw_item_set_field_value (item, mappings[i].element_name, value);
- } else if (element_type == ELEMENT_TYPE_COMPLEX) {
- if (mappings[i].field_id == E_CONTACT_CATEGORIES) {
- set_categories_in_gw_item (item, contact, egwb);
- }
- else if (mappings[i].field_id == E_CONTACT_EMAIL) {
- if (e_contact_get (contact, E_CONTACT_IS_LIST))
- set_members_in_gw_item (item, contact, egwb);
- }
- else {
- mappings[i].set_value_in_gw_item (item, 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 (contact, mappings[i].field_id);
+ if (value != NULL)
+ e_gw_item_set_field_value (item, mappings[i].element_name, value);
+ } else if (element_type == ELEMENT_TYPE_COMPLEX) {
+ if (mappings[i].field_id == E_CONTACT_CATEGORIES) {
+ set_categories_in_gw_item (item, contact, egwb);
+ } else if (mappings[i].field_id == E_CONTACT_EMAIL) {
+ if (e_contact_get (contact, E_CONTACT_IS_LIST))
+ set_members_in_gw_item (item, contact, egwb);
+ } else {
+ mappings[i].set_value_in_gw_item (item, contact);
}
}
- id = NULL;
+ }
+ id = NULL;
+ status = e_gw_connection_create_item (egwb->priv->cnc, item, &id);
+ if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_create_item (egwb->priv->cnc, item, &id);
- if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_create_item (egwb->priv->cnc, item, &id);
- /* Make sure server has returned an id for the created contact */
- if (status == E_GW_CONNECTION_STATUS_OK && id) {
- e_contact_set (contact, E_CONTACT_UID, id);
- g_free (id);
- 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, EDB_ERROR (SUCCESS), contact);
-
- }
- else {
- e_data_book_respond_create (book, opid, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status), NULL);
- }
- g_object_unref (item);
- return;
- default:
- break;
+ /* Make sure server has returned an id for the created contact */
+ if (status == E_GW_CONNECTION_STATUS_OK && id) {
+ e_contact_set (contact, E_CONTACT_UID, id);
+ g_free (id);
+ 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, EDB_ERROR (SUCCESS), contact);
+ } else {
+ e_data_book_respond_create (book, opid, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status), NULL);
}
+ g_object_unref (item);
}
static void
e_book_backend_groupwise_remove_contacts (EBookBackend *backend,
EDataBook *book,
guint32 opid,
- GList *id_list)
+ GCancellable *cancellable,
+ const GSList *id_list)
{
gchar *id;
EBookBackendGroupwise *ebgw;
- GList *deleted_ids = NULL;
+ GSList *deleted_ids = NULL;
if (enable_debug)
printf ("\ne_book_backend_groupwise_remove_contacts...\n");
ebgw = E_BOOK_BACKEND_GROUPWISE (backend);
- switch (ebgw->priv->mode) {
-
- case E_DATA_BOOK_MODE_LOCAL :
+ if (!ebgw->priv->is_online) {
e_data_book_respond_remove_contacts (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
+ }
- case E_DATA_BOOK_MODE_REMOTE :
- if (ebgw->priv->cnc == 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, EDB_ERROR (PERMISSION_DENIED), NULL);
- return;
- }
+ if (ebgw->priv->cnc == NULL) {
+ e_data_book_respond_remove_contacts (book, opid, EDB_ERROR (AUTHENTICATION_REQUIRED), NULL);
+ return;
+ }
- for (; id_list != NULL; id_list = g_list_next (id_list)) {
- id = (gchar *) id_list->data;
- e_gw_connection_remove_item (ebgw->priv->cnc, ebgw->priv->container_id, id);
- deleted_ids = g_list_append (deleted_ids, id);
- e_book_backend_db_cache_remove_contact (ebgw->priv->file_db, id);
- 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, EDB_ERROR (SUCCESS), deleted_ids);
+ if (ebgw->priv->is_readonly) {
+ e_data_book_respond_remove_contacts (book, opid, EDB_ERROR (PERMISSION_DENIED), NULL);
return;
- default :
- break;
}
+
+ for (; id_list != NULL; id_list = id_list->next) {
+ id = (gchar *) id_list->data;
+ e_gw_connection_remove_item (ebgw->priv->cnc, ebgw->priv->container_id, id);
+ deleted_ids = g_slist_append (deleted_ids, id);
+ e_book_backend_db_cache_remove_contact (ebgw->priv->file_db, id);
+ 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, EDB_ERROR (SUCCESS), deleted_ids);
+ g_slist_free (deleted_ids);
}
static void
@@ -1353,6 +1339,7 @@ static void
e_book_backend_groupwise_modify_contact (EBookBackend *backend,
EDataBook *book,
guint32 opid,
+ GCancellable *cancellable,
const gchar *vcard)
{
EContact *contact;
@@ -1369,86 +1356,79 @@ e_book_backend_groupwise_modify_contact (EBookBackend *backend,
printf ("\ne_book_backend_groupwise_modify_contact...\n");
egwb = E_BOOK_BACKEND_GROUPWISE (backend);
- switch (egwb->priv->mode) {
-
- case E_DATA_BOOK_MODE_LOCAL :
+ if (!egwb->priv->is_online) {
e_data_book_respond_modify (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
- case E_DATA_BOOK_MODE_REMOTE :
+ }
- if (egwb->priv->cnc == 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, EDB_ERROR (PERMISSION_DENIED), NULL);
- return;
- }
- contact = e_contact_new_from_vcard (vcard);
- new_item = e_gw_item_new_empty ();
+ if (egwb->priv->cnc == NULL) {
+ e_data_book_respond_modify (book, opid, EDB_ERROR (AUTHENTICATION_REQUIRED), NULL);
+ return;
+ }
+ if (egwb->priv->is_readonly) {
+ e_data_book_respond_modify (book, opid, EDB_ERROR (PERMISSION_DENIED), NULL);
+ return;
+ }
+ contact = e_contact_new_from_vcard (vcard);
+ new_item = e_gw_item_new_empty ();
- 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 (contact, mappings[i].field_id);
- if (value && *value)
- e_gw_item_set_field_value (new_item, mappings[i].element_name, value);
- } else if (element_type == ELEMENT_TYPE_COMPLEX) {
- if (mappings[i].field_id == E_CONTACT_CATEGORIES)
- set_categories_in_gw_item (new_item, contact, egwb);
- else if (mappings[i].field_id == E_CONTACT_EMAIL) {
- if (e_contact_get (contact, E_CONTACT_IS_LIST))
- set_members_in_gw_item (new_item, contact, egwb);
- }
- else
- mappings[i].set_value_in_gw_item (new_item, 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 (contact, mappings[i].field_id);
+ if (value && *value)
+ e_gw_item_set_field_value (new_item, mappings[i].element_name, value);
+ } else if (element_type == ELEMENT_TYPE_COMPLEX) {
+ if (mappings[i].field_id == E_CONTACT_CATEGORIES)
+ set_categories_in_gw_item (new_item, contact, egwb);
+ else if (mappings[i].field_id == E_CONTACT_EMAIL) {
+ if (e_contact_get (contact, E_CONTACT_IS_LIST))
+ set_members_in_gw_item (new_item, contact, egwb);
+ } else
+ mappings[i].set_value_in_gw_item (new_item, contact);
}
+ }
- id = e_contact_get (contact, E_CONTACT_UID);
- old_item = NULL;
- status = e_gw_connection_get_item (egwb->priv->cnc, egwb->priv->container_id, id, NULL, &old_item);
+ id = e_contact_get (contact, E_CONTACT_UID);
+ old_item = NULL;
+ 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, EDB_ERROR (CONTACT_NOT_FOUND), NULL);
- return;
- }
+ if (old_item == 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, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status), NULL);
- return;
- }
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ e_data_book_respond_modify (book, opid, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status), NULL);
+ return;
+ }
- if (e_contact_get (contact, E_CONTACT_IS_LIST))
- set_member_changes (new_item, old_item, egwb);
+ if (e_contact_get (contact, E_CONTACT_IS_LIST))
+ set_member_changes (new_item, old_item, egwb);
- set_changes_in_gw_item (new_item, old_item);
+ set_changes_in_gw_item (new_item, old_item);
- 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, 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);
- egwb->priv->file_db->sync (egwb->priv->file_db, 0);
- e_book_backend_summary_add_contact (egwb->priv->summary, contact);
- }
- else
- 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);
- return;
- default :
- break;
- }
+ 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, 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);
+ egwb->priv->file_db->sync (egwb->priv->file_db, 0);
+ e_book_backend_summary_add_contact (egwb->priv->summary, contact);
+ } else
+ 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);
}
static void
e_book_backend_groupwise_get_contact (EBookBackend *backend,
EDataBook *book,
guint32 opid,
+ GCancellable *cancellable,
const gchar *id)
{
EBookBackendGroupwise *gwb;
@@ -1462,46 +1442,39 @@ e_book_backend_groupwise_get_contact (EBookBackend *backend,
gwb = E_BOOK_BACKEND_GROUPWISE (backend);
- switch (gwb->priv->mode) {
-
- case E_DATA_BOOK_MODE_LOCAL :
+ if (!gwb->priv->is_online) {
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, EDB_ERROR (SUCCESS), vcard);
g_free (vcard);
g_object_unref (contact);
- }
- else {
+ } else {
e_data_book_respond_get_contact (book, opid, EDB_ERROR (CONTACT_NOT_FOUND), "");
}
return;
+ }
- case E_DATA_BOOK_MODE_REMOTE :
- if (gwb->priv->cnc == 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,
+ if (gwb->priv->cnc == 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,
"name email default members", &item);
- if (status == E_GW_CONNECTION_STATUS_OK) {
- if (item) {
- contact = e_contact_new ();
- 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, EDB_ERROR (SUCCESS), vcard);
- g_free (vcard);
- g_object_unref (contact);
- g_object_unref (item);
- return;
- }
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ if (item) {
+ contact = e_contact_new ();
+ 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, EDB_ERROR (SUCCESS), vcard);
+ g_free (vcard);
+ g_object_unref (contact);
+ g_object_unref (item);
+ return;
}
- e_data_book_respond_get_contact (book, opid, EDB_ERROR (CONTACT_NOT_FOUND), "");
- return;
- default :
- break;
}
+ e_data_book_respond_get_contact (book, opid, EDB_ERROR (CONTACT_NOT_FOUND), "");
}
typedef struct {
@@ -1851,7 +1824,7 @@ e_book_backend_groupwise_build_gw_filter (EBookBackendGroupwise *ebgw, const gch
sexp_data = g_new0 (EBookBackendGroupwiseSExpData, 1);
sexp_data->filter = filter;
sexp_data->is_filter_valid = TRUE;
- sexp_data->is_personal_book = e_book_backend_is_writable ( E_BOOK_BACKEND (ebgw));
+ sexp_data->is_personal_book = !e_book_backend_is_readonly (E_BOOK_BACKEND (ebgw));
sexp_data->auto_completion = 0;
sexp_data->search_string = NULL;
@@ -1890,9 +1863,10 @@ static void
e_book_backend_groupwise_get_contact_list (EBookBackend *backend,
EDataBook *book,
guint32 opid,
+ GCancellable *cancellable,
const gchar *query )
{
- GList *vcard_list;
+ GSList *vcard_list;
gint status;
GList *gw_items, *contacts = NULL, *temp;
EContact *contact;
@@ -1910,10 +1884,7 @@ e_book_backend_groupwise_get_contact_list (EBookBackend *backend,
if (enable_debug)
printf ("\ne_book_backend_groupwise_get_contact_list...\n");
- switch (egwb->priv->mode) {
-
- case E_DATA_BOOK_MODE_LOCAL :
-
+ if (!egwb->priv->is_online) {
if (!egwb->priv->file_db) {
e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
return;
@@ -1940,115 +1911,110 @@ e_book_backend_groupwise_get_contact_list (EBookBackend *backend,
temp = contacts;
for (; contacts != NULL; contacts = g_list_next (contacts)) {
- vcard_list = g_list_append (vcard_list,
- e_vcard_to_string (E_VCARD (contacts->data),
- EVC_FORMAT_VCARD_30));
+ vcard_list = g_slist_append (vcard_list,
+ e_vcard_to_string (E_VCARD (contacts->data), EVC_FORMAT_VCARD_30));
g_object_unref (contacts->data);
}
e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (SUCCESS), vcard_list);
+ g_slist_foreach (vcard_list, (GFunc) g_free, NULL);
+ g_slist_free (vcard_list);
if (temp)
g_list_free (temp);
return;
+ }
- case E_DATA_BOOK_MODE_REMOTE:
-
- if (egwb->priv->cnc == NULL) {
- e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (AUTHENTICATION_REQUIRED), NULL);
- return;
- }
+ if (egwb->priv->cnc == 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, EDB_ERROR (INVALID_QUERY), vcard_list);
- }
+ match_needed = TRUE;
+ card_sexp = e_book_backend_sexp_new (query);
+ if (!card_sexp) {
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (INVALID_QUERY), NULL);
+ return;
+ }
- status = E_GW_CONNECTION_STATUS_OK;
- if (egwb->priv->is_cache_ready ) {
- if (egwb->priv->is_summary_ready &&
- e_book_backend_summary_is_summary_query (egwb->priv->summary, query)) {
- ids = e_book_backend_summary_search (egwb->priv->summary, query);
+ status = E_GW_CONNECTION_STATUS_OK;
+ if (egwb->priv->is_cache_ready ) {
+ if (egwb->priv->is_summary_ready &&
+ e_book_backend_summary_is_summary_query (egwb->priv->summary, query)) {
+ ids = e_book_backend_summary_search (egwb->priv->summary, query);
- if (!egwb->priv->is_writable) {
- gint i;
- for (i = 0; i < ids->len; i++) {
- gchar *uid = g_ptr_array_index (ids, i);
- contact = e_book_backend_db_cache_get_contact (egwb->priv->file_db, uid);
- vcard_list = g_list_append (vcard_list,
- e_vcard_to_string (E_VCARD (contact),
- EVC_FORMAT_VCARD_30));
- g_object_unref (contact);
- }
- g_ptr_array_free (ids, TRUE);
- ids = NULL;
+ if (egwb->priv->is_readonly) {
+ gint i;
+ for (i = 0; i < ids->len; i++) {
+ gchar *uid = g_ptr_array_index (ids, i);
+ contact = e_book_backend_db_cache_get_contact (egwb->priv->file_db, uid);
+ vcard_list = g_slist_append (vcard_list,
+ e_vcard_to_string (E_VCARD (contact),
+ EVC_FORMAT_VCARD_30));
+ g_object_unref (contact);
}
+ g_ptr_array_free (ids, TRUE);
+ ids = NULL;
}
- else {
- ids = e_book_backend_db_cache_search (egwb->priv->file_db, query);
- }
+ } else {
+ ids = e_book_backend_db_cache_search (egwb->priv->file_db, query);
+ }
- if (ids && ids->len > 0) {
- status = e_gw_connection_get_items_from_ids (egwb->priv->cnc,
- egwb->priv->container_id,
- "name email default members",
- ids, &gw_items);
- if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+ if (ids && ids->len > 0) {
+ status = e_gw_connection_get_items_from_ids (egwb->priv->cnc,
+ egwb->priv->container_id,
+ "name email default members",
+ ids, &gw_items);
+ if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_get_items_from_ids (egwb->priv->cnc,
- egwb->priv->container_id,
- "name email default members",
- ids, &gw_items);
- }
- if (ids)
- g_ptr_array_free (ids, TRUE);
+ egwb->priv->container_id,
+ "name email default members",
+ ids, &gw_items);
+ }
+ if (ids)
+ g_ptr_array_free (ids, TRUE);
+ match_needed = FALSE;
+ } else {
+ if (strcmp (query, "(contains \"x-evolution-any-field\" \"\")") != 0)
+ filter = e_book_backend_groupwise_build_gw_filter (egwb,
+ query,
+ &is_auto_completion,
+ NULL);
+ if (filter)
match_needed = FALSE;
- } else {
- if (strcmp (query, "(contains \"x-evolution-any-field\" \"\")") != 0)
- filter = e_book_backend_groupwise_build_gw_filter (egwb,
- query,
- &is_auto_completion,
- NULL);
- if (filter)
- match_needed = FALSE;
+ status = e_gw_connection_get_items (egwb->priv->cnc,
+ egwb->priv->container_id,
+ "name email default members",
+ filter, &gw_items);
+ if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_get_items (egwb->priv->cnc,
egwb->priv->container_id,
"name email default members",
filter, &gw_items);
- if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_get_items (egwb->priv->cnc,
- egwb->priv->container_id,
- "name email default members",
- filter, &gw_items);
- }
+ }
- if (status != E_GW_CONNECTION_STATUS_OK) {
- 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)) {
- contact = e_contact_new ();
- fill_contact_from_gw_item (contact, E_GW_ITEM (gw_items->data), egwb->priv->categories_by_id);
- e_contact_set (contact, E_CONTACT_BOOK_URI, egwb->priv->original_uri);
- if (match_needed && e_book_backend_sexp_match_contact (card_sexp, contact))
- vcard_list = g_list_append (vcard_list,
- e_vcard_to_string (E_VCARD (contact),
- EVC_FORMAT_VCARD_30));
- else
- vcard_list = g_list_append (vcard_list,
- e_vcard_to_string (E_VCARD (contact),
- EVC_FORMAT_VCARD_30));
- g_object_unref (contact);
- g_object_unref (gw_items->data);
- }
- if (gw_items)
- g_list_free (gw_items);
- e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (SUCCESS), vcard_list);
- if (filter)
- g_object_unref (filter);
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status), NULL);
return;
- default :
- break;
-
}
+ for (; gw_items != NULL; gw_items = g_list_next (gw_items)) {
+ contact = e_contact_new ();
+ fill_contact_from_gw_item (contact, E_GW_ITEM (gw_items->data), egwb->priv->categories_by_id);
+ e_contact_set (contact, E_CONTACT_BOOK_URI, egwb->priv->original_uri);
+ if (match_needed && e_book_backend_sexp_match_contact (card_sexp, contact))
+ vcard_list = g_slist_append (vcard_list,
+ e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30));
+ else
+ vcard_list = g_slist_append (vcard_list,
+ e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30));
+ g_object_unref (contact);
+ g_object_unref (gw_items->data);
+ }
+ if (gw_items)
+ g_list_free (gw_items);
+ e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (SUCCESS), vcard_list);
+ if (filter)
+ g_object_unref (filter);
+ g_slist_foreach (vcard_list, (GFunc) g_free, NULL);
+ g_slist_free (vcard_list);
}
typedef struct {
@@ -2143,9 +2109,7 @@ book_view_thread (gpointer data)
query = e_data_book_view_get_card_query (book_view);
if (enable_debug)
printf ("get view for query %s \n", query);
- switch (gwb->priv->mode) {
-
- case E_DATA_BOOK_MODE_LOCAL :
+ if (!gwb->priv->is_online) {
if (!gwb->priv->file_db) {
e_data_book_view_notify_complete (book_view, NULL /* Success */);
return NULL;
@@ -2185,211 +2149,200 @@ book_view_thread (gpointer data)
g_list_free (temp_list);
e_data_book_view_unref (book_view);
return NULL;
+ }
- case E_DATA_BOOK_MODE_REMOTE :
-
- if (gwb->priv->cnc == NULL) {
- 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;
- }
-
- if (enable_debug)
- g_get_current_time (&start);
+ if (gwb->priv->cnc == NULL) {
+ 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;
+ }
- filter = e_book_backend_groupwise_build_gw_filter (gwb, query, &is_auto_completion, &search_string);
- view = "name email default members";
- if (is_auto_completion && !g_getenv ("AUTOCOMPLETE_EXPAND_CL"))
- view = "name email";
+ if (enable_debug)
+ g_get_current_time (&start);
- if (search_string) {
- if (filter)
- g_object_unref (filter);
+ filter = e_book_backend_groupwise_build_gw_filter (gwb, query, &is_auto_completion, &search_string);
+ view = "name email default members";
+ if (is_auto_completion && !g_getenv ("AUTOCOMPLETE_EXPAND_CL"))
+ view = "name email";
- /* groupwise server supports only name, rebuild the filter */
- filter = e_gw_filter_new ();
- e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS,
- "fullName/lastName", search_string);
- e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS,
- "fullName/firstName", search_string);
- e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_OR, 2);
- g_free (search_string);
- }
+ if (search_string) {
+ if (filter)
+ g_object_unref (filter);
- if (!gwb->priv->is_writable && !filter && (g_getenv ("GW_HIDE_SYSBOOK") || (!gwb->priv->is_cache_ready))) {
+ /* groupwise server supports only name, rebuild the filter */
+ filter = e_gw_filter_new ();
+ e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS,
+ "fullName/lastName", search_string);
+ e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS,
+ "fullName/firstName", search_string);
+ e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_OR, 2);
+ g_free (search_string);
+ }
- e_data_book_view_notify_complete (book_view, NULL /* Success */);
- e_data_book_view_unref (book_view);
- if (filter)
- g_object_unref (filter);
- return NULL;
- }
- else
- status = E_GW_CONNECTION_STATUS_OK;
+ if (gwb->priv->is_readonly && !filter && (g_getenv ("GW_HIDE_SYSBOOK") || (!gwb->priv->is_cache_ready))) {
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
+ e_data_book_view_unref (book_view);
+ if (filter)
+ g_object_unref (filter);
+ return NULL;
+ } else
+ status = E_GW_CONNECTION_STATUS_OK;
- /* Check if the data is found on summary */
- if (gwb->priv->is_summary_ready &&
- e_book_backend_summary_is_summary_query (gwb->priv->summary, query)) {
- if (enable_debug)
- printf("reading the uids from summary file\n");
- ids = e_book_backend_summary_search (gwb->priv->summary, query);
- }
+ /* Check if the data is found on summary */
+ if (gwb->priv->is_summary_ready &&
+ e_book_backend_summary_is_summary_query (gwb->priv->summary, query)) {
+ if (enable_debug)
+ printf("reading the uids from summary file\n");
+ ids = e_book_backend_summary_search (gwb->priv->summary, query);
+ }
- /*
- * Search for contact in cache, if not found, read from server
- */
+ /*
+ * Search for contact in cache, if not found, read from server
+ */
- if (ids && ids->len > 0) {
+ if (ids && ids->len > 0) {
+ if (enable_debug)
+ printf ("number of matches found in summary %d\n", ids->len);
+ /* read from summary */
+ if (gwb->priv->is_cache_ready && gwb->priv->is_readonly) {
+ /* read from cache, only for system address book, as we refresh
+ * only system address book, periodically.
+ */
if (enable_debug)
- printf ("number of matches found in summary %d\n", ids->len);
- /* read from summary */
- if (gwb->priv->is_cache_ready && !gwb->priv->is_writable) {
- /* read from cache, only for system address book, as we refresh
- * only system address book, periodically.
- */
- if (enable_debug)
- printf ("reading contacts from cache for the uids in summary \n");
- if (!is_auto_completion)
- e_data_book_view_notify_status_message (book_view,
- _("Searching..."));
- get_contacts_from_cache (gwb, query, ids, book_view, closure);
- g_ptr_array_free (ids, TRUE);
- e_data_book_view_unref (book_view);
- if (enable_debug) {
- g_get_current_time (&end);
- diff = end.tv_sec * 1000 + end.tv_usec/1000;
- diff -= start.tv_sec * 1000 + start.tv_usec/1000;
- printf("reading contacts from cache took %ld.%03ld seconds\n",
- diff/1000,diff%1000);
- }
- if (filter)
- g_object_unref (filter);
- return NULL;
+ printf ("reading contacts from cache for the uids in summary \n");
+ if (!is_auto_completion)
+ e_data_book_view_notify_progress (book_view, -1,
+ _("Searching..."));
+ get_contacts_from_cache (gwb, query, ids, book_view, closure);
+ g_ptr_array_free (ids, TRUE);
+ e_data_book_view_unref (book_view);
+ if (enable_debug) {
+ g_get_current_time (&end);
+ diff = end.tv_sec * 1000 + end.tv_usec/1000;
+ diff -= start.tv_sec * 1000 + start.tv_usec/1000;
+ printf("reading contacts from cache took %ld.%03ld seconds\n",
+ diff/1000,diff%1000);
}
- else {
- /* read from server for the ids */
- /* either autocompletion or search query and cache not ready */
- if (enable_debug)
- printf ("reading contacts from server for the uids in summary \n");
- if (!is_auto_completion)
- e_data_book_view_notify_status_message (book_view,
- _("Searching..."));
+ if (filter)
+ g_object_unref (filter);
+ return NULL;
+ } else {
+ /* read from server for the ids */
+ /* either autocompletion or search query and cache not ready */
+ if (enable_debug)
+ printf ("reading contacts from server for the uids in summary \n");
+ if (!is_auto_completion)
+ e_data_book_view_notify_progress (book_view, -1,
+ _("Searching..."));
+ status = e_gw_connection_get_items_from_ids (gwb->priv->cnc,
+ gwb->priv->container_id,
+ view, ids, &gw_items);
+ if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_get_items_from_ids (gwb->priv->cnc,
gwb->priv->container_id,
view, ids, &gw_items);
- if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_get_items_from_ids (gwb->priv->cnc,
- gwb->priv->container_id,
- view, ids, &gw_items);
- if (enable_debug && status == E_GW_CONNECTION_STATUS_OK)
- printf ("read contacts from server \n");
- }
- }
- else {
- if (gwb->priv->is_cache_ready) {
- contacts = e_book_backend_db_cache_get_contacts (gwb->priv->file_db, query);
- temp_list = contacts;
- for (; contacts != NULL; contacts = g_list_next (contacts)) {
- if (!e_flag_is_set (closure->running)) {
- for (;contacts != NULL; contacts = g_list_next (contacts))
- g_object_unref (contacts->data);
- break;
- }
- e_data_book_view_notify_update (book_view, E_CONTACT (contacts->data));
- g_object_unref (contacts->data);
+ if (enable_debug && status == E_GW_CONNECTION_STATUS_OK)
+ printf ("read contacts from server \n");
+ }
+ } else {
+ if (gwb->priv->is_cache_ready) {
+ contacts = e_book_backend_db_cache_get_contacts (gwb->priv->file_db, query);
+ temp_list = contacts;
+ for (; contacts != NULL; contacts = g_list_next (contacts)) {
+ if (!e_flag_is_set (closure->running)) {
+ for (;contacts != NULL; contacts = g_list_next (contacts))
+ g_object_unref (contacts->data);
+ break;
}
- if (e_flag_is_set (closure->running))
- 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);
-
- if (filter)
- g_object_unref (filter);
-
- if (ids)
- g_ptr_array_free (ids, TRUE);
-
- return NULL;
+ e_data_book_view_notify_update (book_view, E_CONTACT (contacts->data));
+ g_object_unref (contacts->data);
}
-
- /* no summary information found, read from server */
- if (enable_debug)
- printf ("summary not found, reading the contacts from server\n");
- if (!is_auto_completion) {
- if (filter)
- e_data_book_view_notify_status_message (book_view, _("Searching..."));
- else
- e_data_book_view_notify_status_message (book_view, _("Loading..."));
- }
- status = e_gw_connection_get_items (gwb->priv->cnc,
- gwb->priv->container_id,
- view, filter, &gw_items);
- if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_get_items (gwb->priv->cnc,
- gwb->priv->container_id,
- view, filter, &gw_items);
- }
-
- if (ids)
- g_ptr_array_free (ids, TRUE);
-
- if (status != E_GW_CONNECTION_STATUS_OK) {
- GError *edb_err = EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status);
- e_data_book_view_notify_complete (book_view, edb_err);
+ if (e_flag_is_set (closure->running))
+ 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);
- g_error_free (edb_err);
+
if (filter)
g_object_unref (filter);
- return NULL;
- }
- temp_list = gw_items;
- for (; gw_items != NULL; gw_items = g_list_next (gw_items)) {
+ if (ids)
+ g_ptr_array_free (ids, TRUE);
- if (!e_flag_is_set (closure->running)) {
- for (;gw_items != NULL; gw_items = g_list_next (gw_items))
- g_object_unref (gw_items->data);
- break;
- }
+ return NULL;
+ }
- count++;
- contact = e_contact_new ();
- fill_contact_from_gw_item (contact,
- E_GW_ITEM (gw_items->data),
- gwb->priv->categories_by_id);
- e_contact_set (contact, E_CONTACT_BOOK_URI, gwb->priv->original_uri);
- if (e_contact_get_const (contact, E_CONTACT_UID))
- e_data_book_view_notify_update (book_view, contact);
+ /* no summary information found, read from server */
+ if (enable_debug)
+ printf ("summary not found, reading the contacts from server\n");
+ if (!is_auto_completion) {
+ if (filter)
+ e_data_book_view_notify_progress (book_view, -1, _("Searching..."));
else
- g_critical ("Id missing for item %s\n", (gchar *)e_contact_get_const (contact, E_CONTACT_FILE_AS));
- g_object_unref (contact);
- g_object_unref (gw_items->data);
+ e_data_book_view_notify_progress (book_view, -1, _("Loading..."));
}
- if (temp_list)
- g_list_free (temp_list);
- if (e_flag_is_set (closure->running))
- e_data_book_view_notify_complete (book_view, NULL /* Success */);
+ status = e_gw_connection_get_items (gwb->priv->cnc,
+ gwb->priv->container_id,
+ view, filter, &gw_items);
+ if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+ status = e_gw_connection_get_items (gwb->priv->cnc,
+ gwb->priv->container_id,
+ view, filter, &gw_items);
+ }
+
+ if (ids)
+ g_ptr_array_free (ids, TRUE);
+
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ 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);
- e_data_book_view_unref (book_view);
+ return NULL;
+ }
- if (enable_debug) {
- g_get_current_time (&end);
- diff = end.tv_sec * 1000 + end.tv_usec/1000;
- diff -= start.tv_sec * 1000 + start.tv_usec/1000;
- printf("reading %d contacts from server took %ld.%03ld seconds\n",
- count, diff/1000,diff%1000);
+ temp_list = gw_items;
+ for (; gw_items != NULL; gw_items = g_list_next (gw_items)) {
+
+ if (!e_flag_is_set (closure->running)) {
+ for (;gw_items != NULL; gw_items = g_list_next (gw_items))
+ g_object_unref (gw_items->data);
+ break;
}
- return NULL;
- default :
- break;
+ count++;
+ contact = e_contact_new ();
+ fill_contact_from_gw_item (contact,
+ E_GW_ITEM (gw_items->data),
+ gwb->priv->categories_by_id);
+ e_contact_set (contact, E_CONTACT_BOOK_URI, gwb->priv->original_uri);
+ if (e_contact_get_const (contact, E_CONTACT_UID))
+ e_data_book_view_notify_update (book_view, contact);
+ else
+ g_critical ("Id missing for item %s\n", (gchar *)e_contact_get_const (contact, E_CONTACT_FILE_AS));
+ g_object_unref (contact);
+ g_object_unref (gw_items->data);
}
+ if (temp_list)
+ g_list_free (temp_list);
+ if (e_flag_is_set (closure->running))
+ e_data_book_view_notify_complete (book_view, NULL /* Success */);
+ if (filter)
+ g_object_unref (filter);
e_data_book_view_unref (book_view);
+
+ if (enable_debug) {
+ g_get_current_time (&end);
+ diff = end.tv_sec * 1000 + end.tv_usec/1000;
+ diff -= start.tv_sec * 1000 + start.tv_usec/1000;
+ printf("reading %d contacts from server took %ld.%03ld seconds\n",
+ count, diff/1000,diff%1000);
+ }
+
return NULL;
}
@@ -2419,54 +2372,33 @@ e_book_backend_groupwise_stop_book_view (EBookBackend *backend,
}
static void
-e_book_backend_groupwise_get_changes (EBookBackend *backend,
- EDataBook *book,
- guint32 opid,
- const gchar *change_id )
-{
- if (enable_debug)
- printf ("\ne_book_backend_groupwise_get_changes...\n");
-
- /* FIXME : provide implmentation */
-
-}
-
-static void
book_view_notify_status (EDataBookView *view, const gchar *status)
{
if (!view)
return;
- e_data_book_view_notify_status_message (view, status);
+ e_data_book_view_notify_progress (view, -1, status);
}
-static EDataBookView *
-find_book_view (EBookBackendGroupwise *ebgw)
+static gboolean
+pick_view_cb (EDataBookView *view, gpointer user_data)
{
- EList *views = e_book_backend_get_book_views (E_BOOK_BACKEND (ebgw));
- EIterator *iter;
- EDataBookView *rv = NULL;
+ EDataBookView **pick = user_data;
- if (!views)
- return NULL;
-
- iter = e_list_get_iterator (views);
+ g_return_val_if_fail (user_data != NULL, FALSE);
- if (!iter) {
- g_object_unref (views);
- return NULL;
- }
+ /* just always use the first book view */
+ *pick = view;
+ return view == NULL;
+}
- if (e_iterator_is_valid (iter)) {
- /* just always use the first book view */
- EDataBookView *v = (EDataBookView*) e_iterator_get (iter);
- if (v)
- rv = v;
- }
+static EDataBookView *
+find_book_view (EBookBackendGroupwise *ebgw)
+{
+ EDataBookView *pick = NULL;
- g_object_unref (iter);
- g_object_unref (views);
+ e_book_backend_foreach_view (E_BOOK_BACKEND (ebgw), pick_view_cb, &pick);
- return rv;
+ return pick;
}
static void
@@ -3201,11 +3133,8 @@ update_address_book_cache (gpointer data)
static void
e_book_backend_groupwise_authenticate_user (EBookBackend *backend,
- EDataBook *book,
- guint32 opid,
- const gchar *user,
- const gchar *passwd,
- const gchar *auth_method)
+ GCancellable *cancellable,
+ ECredentials *credentials)
{
EBookBackendGroupwise *ebgw;
EBookBackendGroupwisePrivate *priv;
@@ -3226,218 +3155,151 @@ e_book_backend_groupwise_authenticate_user (EBookBackend *backend,
printf("book_name:%s\n", priv->book_name);
}
- switch (ebgw->priv->mode) {
- case E_DATA_BOOK_MODE_LOCAL:
+ if (!ebgw->priv->is_online) {
/* 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,
SUMMARY_FLUSH_TIMEOUT);
e_book_backend_summary_load (priv->summary);
- e_book_backend_notify_writable (backend, FALSE);
- e_book_backend_notify_connection_status (backend, FALSE);
- e_data_book_respond_authenticate_user (book, opid, EDB_ERROR (SUCCESS));
+ e_book_backend_notify_readonly (backend, TRUE);
+ e_book_backend_notify_online (backend, FALSE);
+ e_book_backend_notify_opened (backend, NULL /* Success */);
return;
+ }
- 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, EDB_ERROR (SUCCESS));
- return;
- }
-
- priv->cnc = e_gw_connection_new_with_error_handler (priv->uri, user, passwd, &error);
- if (!E_IS_GW_CONNECTION(priv->cnc) && priv->use_ssl && g_str_equal (priv->use_ssl, "when-possible")) {
- http_uri = g_strconcat ("http://", priv->uri + 8, NULL);
- priv->cnc = e_gw_connection_new (http_uri, user, passwd);
- g_free (http_uri);
- }
+ if (priv->cnc) { /*we have already authenticated to server */
+ printf("already authenticated\n");
+ e_book_backend_notify_opened (backend, NULL /* Success */);
+ return;
+ }
- if (!E_IS_GW_CONNECTION (priv->cnc)) {
+ priv->cnc = e_gw_connection_new_with_error_handler (priv->uri, e_credentials_peek (credentials, E_CREDENTIALS_KEY_USERNAME), e_credentials_peek (credentials, E_CREDENTIALS_KEY_PASSWORD), &error);
+ if (!E_IS_GW_CONNECTION(priv->cnc) && priv->use_ssl && g_str_equal (priv->use_ssl, "when-possible")) {
+ http_uri = g_strconcat ("http://", priv->uri + 8, NULL);
+ priv->cnc = e_gw_connection_new (http_uri, e_credentials_peek (credentials, E_CREDENTIALS_KEY_USERNAME), e_credentials_peek (credentials, E_CREDENTIALS_KEY_PASSWORD));
+ g_free (http_uri);
+ }
- if (error.status == E_GW_CONNECTION_STATUS_INVALID_PASSWORD)
- e_data_book_respond_authenticate_user (book, opid, EDB_ERROR (AUTHENTICATION_FAILED));
- else
- e_data_book_respond_authenticate_user (book, opid, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, error.status));
- return;
- }
+ if (!E_IS_GW_CONNECTION (priv->cnc)) {
+ if (error.status == E_GW_CONNECTION_STATUS_INVALID_PASSWORD)
+ e_book_backend_notify_opened (backend, EDB_ERROR (AUTHENTICATION_FAILED));
+ else
+ e_book_backend_notify_opened (backend, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, error.status));
+ return;
+ }
- id = NULL;
- is_writable = FALSE;
+ id = NULL;
+ is_writable = FALSE;
+ status = e_gw_connection_get_address_book_id (priv->cnc, priv->book_name, &id, &is_writable);
+ if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_get_address_book_id (priv->cnc, priv->book_name, &id, &is_writable);
- if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_get_address_book_id (priv->cnc, priv->book_name, &id, &is_writable);
- if (status == E_GW_CONNECTION_STATUS_OK) {
- if ((id == NULL) && !priv->only_if_exists) {
- 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, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status));
- return;
- }
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ if ((id == NULL) && !priv->only_if_exists) {
+ status = e_gw_connection_create_book (priv->cnc, priv->book_name, &id);
+ is_writable = TRUE;
+ if (status != E_GW_CONNECTION_STATUS_OK ) {
+ e_book_backend_notify_opened (backend, EDB_ERROR_FAILED_STATUS (OTHER_ERROR, status));
+ return;
}
}
- if (id != NULL) {
- priv->container_id = g_strdup (id);
- g_free (id);
- e_book_backend_set_is_writable (backend, is_writable);
- e_book_backend_notify_writable (backend, is_writable);
- e_book_backend_notify_connection_status (backend, TRUE);
- 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, EDB_ERROR (INVALID_SERVER_VERSION));
- else
- 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, EDB_ERROR (NO_SUCH_BOOK));
- }
-
- /* initialize summary file */
- tmpfile = g_path_get_dirname (priv->summary_file_name);
- g_mkdir_with_parents (tmpfile, 0700);
- g_free (tmpfile);
- priv->summary = e_book_backend_summary_new (priv->summary_file_name,
- SUMMARY_FLUSH_TIMEOUT);
+ }
+ if (id != NULL) {
+ priv->container_id = g_strdup (id);
+ g_free (id);
+ e_book_backend_notify_readonly (backend, !is_writable);
+ e_book_backend_notify_online (backend, TRUE);
+ priv->is_readonly = !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_book_backend_notify_opened (backend, EDB_ERROR (INVALID_SERVER_VERSION));
+ else
+ e_book_backend_notify_opened (backend, EDB_ERROR (SUCCESS));
+ } else {
+ e_book_backend_notify_opened (backend, EDB_ERROR (NO_SUCH_BOOK));
+ }
- if (!ebgw->priv->file_db) {
- 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)) {
- if (enable_debug)
- printf("cache is populated\n");
+ /* initialize summary file */
+ tmpfile = g_path_get_dirname (priv->summary_file_name);
+ g_mkdir_with_parents (tmpfile, 0700);
+ g_free (tmpfile);
+ priv->summary = e_book_backend_summary_new (priv->summary_file_name,
+ SUMMARY_FLUSH_TIMEOUT);
- if (!e_book_backend_summary_load (priv->summary))
- build_summary (ebgw);
+ if (!ebgw->priv->file_db) {
+ e_book_backend_notify_opened (backend, EDB_ERROR (OTHER_ERROR));
+ return;
+ }
+ if (e_book_backend_db_cache_is_populated (ebgw->priv->file_db)) {
+ if (enable_debug)
+ printf("cache is populated\n");
- ebgw->priv->is_cache_ready = TRUE;
- ebgw->priv->is_summary_ready = TRUE;
+ if (!e_book_backend_summary_load (priv->summary))
+ build_summary (ebgw);
- if (priv->is_writable) {
- if (enable_debug) {
- printf("is writable\n");
- printf("creating update_cache thread\n");
- }
- g_thread_create ((GThreadFunc) update_cache, ebgw, FALSE, NULL);
- }
- else if (priv->marked_for_offline) {
- GThread *t;
- if (enable_debug)
- printf("marked for offline\n");
- if (enable_debug)
- printf("creating update_address_book_deltas thread\n");
-
- t = g_thread_create ((GThreadFunc) update_address_book_deltas, ebgw, TRUE, NULL);
-
- /* spawn a thread to update the system address book cache
- * at given intervals
- */
- cache_refresh_interval_set = g_getenv ("BOOK_CACHE_REFRESH_INTERVAL");
- if (cache_refresh_interval_set) {
- cache_refresh_interval = g_ascii_strtod (cache_refresh_interval_set,
- NULL); /* use this */
- cache_refresh_interval *= (60*1000);
- }
+ ebgw->priv->is_cache_ready = TRUE;
+ ebgw->priv->is_summary_ready = TRUE;
- /* set the cache refresh time */
- g_thread_join (t);
- if (enable_debug)
- printf ("creating cache refresh thread for GW system book \n");
- priv->cache_timeout = g_timeout_add (cache_refresh_interval,
- (GSourceFunc) update_address_book_cache,
- (gpointer) ebgw);
- }
- }
- else if (priv->is_writable) { /* for personal books we always cache */
- /* Personal address book and frequent contacts */
+ if (priv->is_readonly) {
if (enable_debug) {
- printf("else if is _writable");
- printf("build_cahe thread");
+ printf("is writable\n");
+ printf("creating update_cache thread\n");
}
- g_thread_create ((GThreadFunc) build_cache, ebgw, FALSE, NULL);
- }
- else if (priv->marked_for_offline) {
+ g_thread_create ((GThreadFunc) update_cache, ebgw, FALSE, NULL);
+ } else if (priv->marked_for_offline) {
GThread *t;
if (enable_debug)
- printf("else if marked_for_offline\n");
- /* System address book */
- /* cache is not populated and book is not writable and marked for offline usage */
+ printf("marked for offline\n");
if (enable_debug)
printf("creating update_address_book_deltas thread\n");
+
t = g_thread_create ((GThreadFunc) update_address_book_deltas, ebgw, TRUE, NULL);
- g_thread_join (t);
+
+ /* spawn a thread to update the system address book cache
+ * at given intervals
+ */
+ cache_refresh_interval_set = g_getenv ("BOOK_CACHE_REFRESH_INTERVAL");
+ if (cache_refresh_interval_set) {
+ cache_refresh_interval = g_ascii_strtod (cache_refresh_interval_set,
+ NULL); /* use this */
+ cache_refresh_interval *= (60*1000);
+ }
+
/* set the cache refresh time */
+ g_thread_join (t);
if (enable_debug)
printf ("creating cache refresh thread for GW system book \n");
priv->cache_timeout = g_timeout_add (cache_refresh_interval,
(GSourceFunc) update_address_book_cache,
(gpointer) ebgw);
}
- return;
- default :
- break;
+ } else if (priv->is_readonly) { /* for personal books we always cache */
+ /* Personal address book and frequent contacts */
+ if (enable_debug) {
+ printf("else if is _writable");
+ printf("build_cahe thread");
+ }
+ g_thread_create ((GThreadFunc) build_cache, ebgw, FALSE, NULL);
+ } else if (priv->marked_for_offline) {
+ GThread *t;
+ if (enable_debug)
+ printf("else if marked_for_offline\n");
+ /* System address book */
+ /* cache is not populated and book is not writable and marked for offline usage */
+ if (enable_debug)
+ printf("creating update_address_book_deltas thread\n");
+ t = g_thread_create ((GThreadFunc) update_address_book_deltas, ebgw, TRUE, NULL);
+ g_thread_join (t);
+ /* set the cache refresh time */
+ if (enable_debug)
+ printf ("creating cache refresh thread for GW system book \n");
+ priv->cache_timeout = g_timeout_add (cache_refresh_interval,
+ (GSourceFunc) update_address_book_cache,
+ (gpointer) ebgw);
}
}
static void
-e_book_backend_groupwise_get_required_fields (EBookBackend *backend,
- EDataBook *book,
- guint32 opid)
-{
- GList *fields = NULL;
-
- if (enable_debug)
- printf ("\ne_book_backend_groupwise_get_required_fields...\n");
-
- fields = g_list_append (fields, (gchar *) e_contact_field_name (E_CONTACT_FILE_AS));
- e_data_book_respond_get_supported_fields (book, opid,
- EDB_ERROR (SUCCESS),
- fields);
- g_list_free (fields);
-
-}
-
-static void
-e_book_backend_groupwise_get_supported_fields (EBookBackend *backend,
- EDataBook *book,
- guint32 opid)
-{
- GList *fields = NULL;
- gint i;
-
- if (enable_debug)
- printf ("\ne_book_backend_groupwise_get_supported_fields...\n");
-
- for (i = 0; i < G_N_ELEMENTS (mappings); i++)
- fields = g_list_append (fields, g_strdup (e_contact_field_name (mappings[i].field_id)));
- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_EMAIL_2)));
- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_EMAIL_3)));
- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_ICQ)));
- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_YAHOO)));
- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_GADUGADU)));
- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_MSN)));
- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_SKYPE)));
- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_JABBER)));
- 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,
- EDB_ERROR (SUCCESS),
- fields);
- g_list_free (fields);
-}
-
-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");
- g_propagate_error (perror, EDB_ERROR (COULD_NOT_CANCEL));
-}
-
-static void
#if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3
file_errcall (const DB_ENV *env, const gchar *buf1, const gchar *buf2)
#else
@@ -3448,13 +3310,15 @@ file_errcall (const gchar *buf1, gchar *buf2)
}
static void
-e_book_backend_groupwise_load_source (EBookBackend *backend,
- ESource *source,
- gboolean only_if_exists,
- GError **perror)
+e_book_backend_groupwise_open (EBookBackend *backend,
+ EDataBook *book,
+ guint opid,
+ GCancellable *cancellable,
+ gboolean only_if_exists)
{
EBookBackendGroupwise *ebgw;
EBookBackendGroupwisePrivate *priv;
+ ESource *source;
gchar *dirname, *filename, *tmp;
gchar *book_name;
gchar *uri;
@@ -3469,6 +3333,7 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
const gchar *offline;
cache_dir = e_book_backend_get_cache_dir (backend);
+ source = e_book_backend_get_source (backend);
if (enable_debug)
printf("\ne_book_backend_groupwise_load_source.. \n");
@@ -3483,7 +3348,7 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
uri = e_source_get_uri (source);
priv->original_uri = g_strdup (uri);
if (uri == NULL) {
- g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "No URI given"));
+ e_data_book_respond_open (book, opid, EDB_ERROR_EX (OTHER_ERROR, "No URI given"));
return;
}
@@ -3493,7 +3358,7 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
uri = g_strdup (tokens[0]);
book_name = g_strdup (tokens[1]);
if (book_name == NULL) {
- g_propagate_error (perror, EDB_ERROR_EX (OTHER_ERROR, "No book name recognized for a URI"));
+ e_data_book_respond_open (book, opid, EDB_ERROR_EX (OTHER_ERROR, "No book name recognized for a URI"));
return;
}
g_strfreev (tokens);
@@ -3522,7 +3387,7 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
g_warning ("db recovery failed with %d", db_error);
g_free (dirname);
g_free (filename);
- 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));
+ e_data_book_respond_open (book, opid, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "DB recovery failed with code 0x%x", db_error));
return;
}
@@ -3538,7 +3403,7 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
g_static_mutex_unlock (&global_env_lock);
g_free (dirname);
g_free (filename);
- 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));
+ e_data_book_respond_open (book, opid, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "db_env_create failed with code 0x%x", db_error));
return;
}
@@ -3549,7 +3414,7 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
g_static_mutex_unlock (&global_env_lock);
g_free (dirname);
g_free (filename);
- 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));
+ e_data_book_respond_open (book, opid, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "db_env_open failed with code 0x%x", db_error));
return;
}
@@ -3567,7 +3432,7 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
g_warning ("db_create failed with %d", db_error);
g_free (dirname);
g_free (filename);
- 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));
+ e_data_book_respond_open (book, opid, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "db_create failed with code 0x%x", db_error));
return;
}
@@ -3580,7 +3445,7 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
g_warning ("db format upgrade failed with %d", db_error);
g_free (filename);
g_free (dirname);
- 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));
+ e_data_book_respond_open (book, opid, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR, "db format upgrade failed with code 0x%x", db_error));
return;
}
@@ -3597,9 +3462,9 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
rv = g_mkdir_with_parents (dirname, 0700);
if (rv == -1 && errno != EEXIST) {
if (errno == EACCES || errno == EPERM)
- g_propagate_error (perror, EDB_ERROR (PERMISSION_DENIED));
+ e_data_book_respond_open (book, opid, 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)));
+ e_data_book_respond_open (book, opid, 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;
@@ -3618,33 +3483,26 @@ e_book_backend_groupwise_load_source (EBookBackend *backend,
ebgw->priv->file_db = NULL;
g_free (filename);
g_free (dirname);
- g_propagate_error (perror, EDB_ERROR (OTHER_ERROR));
+ e_data_book_respond_open (book, opid, EDB_ERROR (OTHER_ERROR));
return;
}
- if (priv->mode == E_DATA_BOOK_MODE_LOCAL && !priv->marked_for_offline ) {
- g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ if (!priv->is_online && !priv->marked_for_offline ) {
+ e_data_book_respond_open (book, opid, EDB_ERROR (OFFLINE_UNAVAILABLE));
return;
}
priv->use_ssl = g_strdup (use_ssl);
priv->only_if_exists = only_if_exists;
- 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 == E_DATA_BOOK_MODE_LOCAL) {
- e_book_backend_notify_writable (backend, FALSE);
- e_book_backend_notify_connection_status (backend, FALSE);
- }
- else {
- e_book_backend_notify_connection_status (backend, TRUE);
- }
+ e_book_backend_notify_readonly (backend, TRUE);
+ e_book_backend_notify_online (backend, priv->is_online);
- if (priv->mode == E_DATA_BOOK_MODE_LOCAL)
+ if (!priv->is_online)
if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
g_free (uri);
e_uri_free (parsed_uri);
- g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
+ e_data_book_respond_open (book, opid, EDB_ERROR (OFFLINE_UNAVAILABLE));
return;
}
@@ -3660,12 +3518,17 @@ 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)));
}*/
+
+ e_data_book_respond_open (book, opid, NULL /* Success */);
+ if (!priv->is_online)
+ e_book_backend_notify_opened (backend, NULL /* Success */);
}
static void
e_book_backend_groupwise_remove (EBookBackend *backend,
EDataBook *book,
- guint32 opid)
+ guint32 opid,
+ GCancellable *cancellable)
{
EBookBackendGroupwise *ebgw;
gint status;
@@ -3677,7 +3540,7 @@ e_book_backend_groupwise_remove (EBookBackend *backend,
e_data_book_respond_remove (book, opid, EDB_ERROR (AUTHENTICATION_REQUIRED));
return;
}
- if (!ebgw->priv->is_writable) {
+ if (ebgw->priv->is_readonly) {
e_data_book_respond_remove (book, opid, EDB_ERROR (PERMISSION_DENIED));
return;
}
@@ -3689,63 +3552,76 @@ e_book_backend_groupwise_remove (EBookBackend *backend,
g_unlink (e_book_backend_db_cache_get_filename (ebgw->priv->file_db));
}
-static gchar *
-e_book_backend_groupwise_get_static_capabilities (EBookBackend *backend)
+static void
+e_book_backend_groupwise_get_backend_property (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable, const gchar *prop_name)
{
if (enable_debug)
- printf ("\ne_book_backend_groupwise_get_static_capabilities...\n");
+ printf ("\n%s (prop_name: %s)...\n", G_STRFUNC, prop_name ? prop_name : "NULL");
- /* do-initialy-query is enabled for system address book also, so that we get the
- * book_view, which is needed for displaying cache update progress.
- * and null query is handled for system address book.
- */
- return g_strdup ("net,bulk-removes,do-initial-query,contact-lists");
-}
+ g_return_if_fail (prop_name != NULL);
-static void
-e_book_backend_groupwise_get_supported_auth_methods (EBookBackend *backend, EDataBook *book, guint32 opid)
-{
- GList *auth_methods = NULL;
- gchar *auth_method;
+ if (g_str_equal (prop_name, CLIENT_BACKEND_PROPERTY_CAPABILITIES)) {
+ /* do-initialy-query is enabled for system address book also, so that we get the
+ * book_view, which is needed for displaying cache update progress.
+ * and null query is handled for system address book.
+ */
+ e_data_book_respond_get_backend_property (book, opid, NULL, "net,bulk-removes,do-initial-query,contact-lists");
+ } else if (g_str_equal (prop_name, BOOK_BACKEND_PROPERTY_REQUIRED_FIELDS)) {
+ e_data_book_respond_get_backend_property (book, opid, NULL, e_contact_field_name (E_CONTACT_FILE_AS));
+ } else if (g_str_equal (prop_name, BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS)) {
+ gchar *fields_str;
+ GSList *fields = NULL;
+ gint i;
- if (enable_debug)
- printf ("\ne_book_backend_groupwise_get_supported_auth_methods...\n");
- auth_method = g_strdup_printf ("plain/password");
- auth_methods = g_list_append (auth_methods, auth_method);
- e_data_book_respond_get_supported_auth_methods (book,
- opid,
- EDB_ERROR (SUCCESS),
- auth_methods);
- g_free (auth_method);
- g_list_free (auth_methods);
+ for (i = 0; i < G_N_ELEMENTS (mappings); i++) {
+ fields = g_slist_append (fields, (gpointer) e_contact_field_name (mappings[i].field_id));
+ }
+
+ fields = g_slist_append (fields, (gpointer) e_contact_field_name (E_CONTACT_EMAIL_2));
+ fields = g_slist_append (fields, (gpointer) e_contact_field_name (E_CONTACT_EMAIL_3));
+ fields = g_slist_append (fields, (gpointer) e_contact_field_name (E_CONTACT_IM_ICQ));
+ fields = g_slist_append (fields, (gpointer) e_contact_field_name (E_CONTACT_IM_YAHOO));
+ fields = g_slist_append (fields, (gpointer) e_contact_field_name (E_CONTACT_IM_GADUGADU));
+ fields = g_slist_append (fields, (gpointer) e_contact_field_name (E_CONTACT_IM_MSN));
+ fields = g_slist_append (fields, (gpointer) e_contact_field_name (E_CONTACT_IM_SKYPE));
+ fields = g_slist_append (fields, (gpointer) e_contact_field_name (E_CONTACT_IM_JABBER));
+ fields = g_slist_append (fields, (gpointer) e_contact_field_name (E_CONTACT_IM_GROUPWISE));
+ fields = g_slist_append (fields, (gpointer) e_contact_field_name (E_CONTACT_ADDRESS_WORK));
+
+ fields_str = e_data_book_string_slist_to_comma_string (fields);
+
+ e_data_book_respond_get_backend_property (book, opid, NULL, fields_str);
+
+ g_slist_free (fields);
+ g_free (fields_str);
+ } else if (g_str_equal (prop_name, BOOK_BACKEND_PROPERTY_SUPPORTED_AUTH_METHODS)) {
+ e_data_book_respond_get_backend_property (book, opid, NULL, "plain/password");
+ } else {
+ E_BOOK_BACKEND_CLASS (e_book_backend_groupwise_parent_class)->get_backend_property (backend, book, opid, cancellable, prop_name);
+ }
}
static void
-e_book_backend_groupwise_set_mode (EBookBackend *backend,
- EDataBookMode mode)
+e_book_backend_groupwise_set_online (EBookBackend *backend, gboolean is_online)
{
EBookBackendGroupwise *bg;
if (enable_debug)
printf ("\ne_book_backend_groupwise_set_mode...\n");
bg = E_BOOK_BACKEND_GROUPWISE (backend);
- bg->priv->mode = mode;
- if (e_book_backend_is_loaded (backend)) {
- if (mode == E_DATA_BOOK_MODE_LOCAL) {
- e_book_backend_notify_writable (backend, FALSE);
- e_book_backend_notify_connection_status (backend, FALSE);
+ bg->priv->is_online = is_online;
+ if (e_book_backend_is_opened (backend)) {
+ if (!is_online) {
+ e_book_backend_notify_readonly (backend, TRUE);
+ e_book_backend_notify_online (backend, FALSE);
if (bg->priv->cnc) {
g_object_unref (bg->priv->cnc);
bg->priv->cnc=NULL;
}
- }
- else if (mode == E_DATA_BOOK_MODE_REMOTE) {
- if (bg->priv->is_writable)
- e_book_backend_notify_writable (backend, TRUE);
- else
- e_book_backend_notify_writable (backend, FALSE);
- e_book_backend_notify_connection_status (backend, TRUE);
- e_book_backend_notify_auth_required (backend);
+ } else {
+ e_book_backend_notify_readonly (backend, bg->priv->is_readonly);
+ e_book_backend_notify_online (backend, TRUE);
+ e_book_backend_notify_auth_required (backend, TRUE, NULL);
}
}
}
@@ -3873,25 +3749,21 @@ e_book_backend_groupwise_class_init (EBookBackendGroupwiseClass *klass)
parent_class = E_BOOK_BACKEND_CLASS (klass);
/* Set the virtual methods. */
- parent_class->load_source = e_book_backend_groupwise_load_source;
- parent_class->get_static_capabilities = e_book_backend_groupwise_get_static_capabilities;
-
- parent_class->create_contact = e_book_backend_groupwise_create_contact;
- parent_class->remove_contacts = e_book_backend_groupwise_remove_contacts;
- parent_class->modify_contact = e_book_backend_groupwise_modify_contact;
- parent_class->get_contact = e_book_backend_groupwise_get_contact;
- parent_class->get_contact_list = e_book_backend_groupwise_get_contact_list;
- parent_class->start_book_view = e_book_backend_groupwise_start_book_view;
- parent_class->stop_book_view = e_book_backend_groupwise_stop_book_view;
- parent_class->get_changes = e_book_backend_groupwise_get_changes;
- parent_class->authenticate_user = e_book_backend_groupwise_authenticate_user;
- parent_class->get_required_fields = e_book_backend_groupwise_get_required_fields;
- parent_class->get_supported_fields = e_book_backend_groupwise_get_supported_fields;
- parent_class->get_supported_auth_methods = e_book_backend_groupwise_get_supported_auth_methods;
- parent_class->cancel_operation = e_book_backend_groupwise_cancel_operation;
- parent_class->remove = e_book_backend_groupwise_remove;
- parent_class->set_mode = e_book_backend_groupwise_set_mode;
- object_class->dispose = e_book_backend_groupwise_dispose;
+ parent_class->open = e_book_backend_groupwise_open;
+ parent_class->get_backend_property = e_book_backend_groupwise_get_backend_property;
+
+ parent_class->create_contact = e_book_backend_groupwise_create_contact;
+ parent_class->remove_contacts = e_book_backend_groupwise_remove_contacts;
+ parent_class->modify_contact = e_book_backend_groupwise_modify_contact;
+ parent_class->get_contact = e_book_backend_groupwise_get_contact;
+ parent_class->get_contact_list = e_book_backend_groupwise_get_contact_list;
+ parent_class->start_book_view = e_book_backend_groupwise_start_book_view;
+ parent_class->stop_book_view = e_book_backend_groupwise_stop_book_view;
+ parent_class->authenticate_user = e_book_backend_groupwise_authenticate_user;
+ parent_class->remove = e_book_backend_groupwise_remove;
+ parent_class->set_online = e_book_backend_groupwise_set_online;
+
+ object_class->dispose = e_book_backend_groupwise_dispose;
}
static void
@@ -3900,7 +3772,7 @@ e_book_backend_groupwise_init (EBookBackendGroupwise *backend)
EBookBackendGroupwisePrivate *priv;
priv= g_new0 (EBookBackendGroupwisePrivate, 1);
- priv->is_writable = TRUE;
+ priv->is_readonly = FALSE;
priv->is_cache_ready = FALSE;
priv->is_summary_ready = FALSE;
priv->marked_for_offline = FALSE;
diff --git a/src/calendar/e-cal-backend-groupwise-utils.c b/src/calendar/e-cal-backend-groupwise-utils.c
index 623c3e3..4e804f5 100644
--- a/src/calendar/e-cal-backend-groupwise-utils.c
+++ b/src/calendar/e-cal-backend-groupwise-utils.c
@@ -490,7 +490,7 @@ get_actual_count (ECalComponent *comp, ECalBackendGroupwise *cbgw)
gint count = 0;
icaltimezone *dzone, *utc;
- dzone = e_cal_backend_groupwise_get_default_zone (cbgw);
+ dzone = NULL;
utc = icaltimezone_get_utc_timezone ();
if (dzone)
@@ -565,8 +565,8 @@ set_rrule_from_comp (ECalComponent *comp, EGwItem *item, ECalBackendGroupwise *c
struct icaltimetype itt_utc;
e_cal_component_get_exdate_list (comp, &exdate_list);
- default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
utc = icaltimezone_get_utc_timezone ();
+ default_zone = utc;
for (l = exdate_list; l; l = l->next) {
ECalComponentDateTime *dt = (ECalComponentDateTime *) l->data;
if (dt->value) {
@@ -598,8 +598,8 @@ set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBacke
struct icaltimetype itt_utc;
gboolean dtstart_has_timezone;
- default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
utc = icaltimezone_get_utc_timezone ();
+ default_zone = utc;
/* first set specific properties */
switch (e_cal_component_get_vtype (comp)) {
@@ -845,7 +845,7 @@ e_gw_item_new_for_delegate_from_cal (ECalBackendGroupwise *cbgw, ECalComponent *
const gchar *user_email;
g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL);
- default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
+ default_zone = icaltimezone_get_utc_timezone ();
item = e_gw_item_new_empty ();
e_gw_item_set_id (item, e_cal_component_get_gw_id (comp));
user_email = e_gw_connection_get_user_email (e_cal_backend_groupwise_get_connection (cbgw));
@@ -1087,7 +1087,7 @@ e_gw_item_to_cal_component (EGwItem *item, ECalBackendGroupwise *cbgw)
e_cal_backend_groupwise_priv_lock (cbgw);
- default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
+ default_zone = icaltimezone_get_utc_timezone ();
categories_by_id = e_cal_backend_groupwise_get_categories_by_id (cbgw);
comp = e_cal_component_new ();
@@ -1674,14 +1674,14 @@ e_gw_connection_create_appointment (EGwConnection *cnc, const gchar *container,
}
static EGwConnectionStatus
-start_freebusy_session (EGwConnection *cnc, GList *users,
+start_freebusy_session (EGwConnection *cnc, const GSList *users,
time_t start, time_t end, gchar **session)
{
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status;
SoupSoapParameter *param;
- GList *l;
+ const GSList *l;
icaltimetype icaltime;
icaltimezone *utc;
gchar *start_date, *end_date;
@@ -1697,7 +1697,7 @@ start_freebusy_session (EGwConnection *cnc, GList *users,
* email id apart from the name*/
soup_soap_message_start_element (msg, "users", NULL, NULL);
- for ( l = users; l != NULL; l = g_list_next (l)) {
+ for ( l = users; l != NULL; l = g_slist_next (l)) {
soup_soap_message_start_element (msg, "user", NULL, NULL);
e_gw_message_write_string_parameter (msg, "email", NULL, l->data);
soup_soap_message_end_element (msg);
@@ -1779,7 +1779,7 @@ close_freebusy_session (EGwConnection *cnc, const gchar *session)
}
EGwConnectionStatus
-e_gw_connection_get_freebusy_info (ECalBackendGroupwise *cbgw, GList *users, time_t start, time_t end, GList **freebusy)
+e_gw_connection_get_freebusy_info (ECalBackendGroupwise *cbgw, const GSList *users, time_t start, time_t end, GSList **freebusy)
{
SoupSoapMessage *msg;
SoupSoapResponse *response;
@@ -1792,7 +1792,7 @@ e_gw_connection_get_freebusy_info (ECalBackendGroupwise *cbgw, GList *users, tim
gint request_iteration = 0;
icaltimezone *default_zone;
- default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
+ default_zone = icaltimezone_get_utc_timezone ();
cnc = e_cal_backend_groupwise_get_connection (cbgw);
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_CONNECTION);
@@ -1991,7 +1991,7 @@ e_gw_connection_get_freebusy_info (ECalBackendGroupwise *cbgw, GList *users, tim
}
e_cal_component_commit_sequence (comp);
- *freebusy = g_list_append (*freebusy, e_cal_component_get_as_string (comp));
+ *freebusy = g_slist_append (*freebusy, e_cal_component_get_as_string (comp));
g_object_unref (comp);
e_cal_backend_groupwise_priv_unlock (cbgw);
}
diff --git a/src/calendar/e-cal-backend-groupwise-utils.h b/src/calendar/e-cal-backend-groupwise-utils.h
index 838f846..5905e79 100644
--- a/src/calendar/e-cal-backend-groupwise-utils.h
+++ b/src/calendar/e-cal-backend-groupwise-utils.h
@@ -52,7 +52,7 @@ void e_gw_item_set_changes (EGwItem *item, EGwItem *cached_item);
*/
EGwConnectionStatus e_gw_connection_create_appointment (EGwConnection *cnc, const gchar *container, ECalBackendGroupwise *cbgw, ECalComponent *comp, GSList **id_list);
EGwConnectionStatus e_gw_connection_send_appointment (ECalBackendGroupwise *cbgw, const gchar *container, ECalComponent *comp, icalproperty_method method, gboolean all_instances, ECalComponent **created_comp, icalparameter_partstat *pstatus);
-EGwConnectionStatus e_gw_connection_get_freebusy_info (ECalBackendGroupwise *cbgw, GList *users, time_t start, time_t end, GList **freebusy);
+EGwConnectionStatus e_gw_connection_get_freebusy_info (ECalBackendGroupwise *cbgw, const GSList *users, time_t start, time_t end, GSList **freebusy);
gboolean e_cal_backend_groupwise_store_settings (GwSettings *hold);
gboolean e_cal_backend_groupwise_utils_check_delegate (ECalComponent *comp, const gchar *email);
diff --git a/src/calendar/e-cal-backend-groupwise.c b/src/calendar/e-cal-backend-groupwise.c
index 37d638a..d323048 100644
--- a/src/calendar/e-cal-backend-groupwise.c
+++ b/src/calendar/e-cal-backend-groupwise.c
@@ -80,11 +80,10 @@ struct _ECalBackendGroupwisePrivate {
ECalBackendStore *store;
gboolean read_only;
gchar *uri;
- gchar *username;
- gchar *password;
+ ECredentials *credentials;
gchar *container_id;
- CalMode mode;
- gboolean mode_changed;
+ gboolean is_online;
+ gboolean is_online_changed;
GHashTable *categories_by_id;
GHashTable *categories_by_name;
@@ -101,7 +100,6 @@ struct _ECalBackendGroupwisePrivate {
/* A mutex to control access to the private structure for the following */
GStaticRecMutex rec_mutex;
- icaltimezone *default_zone;
guint timeout_id;
GThread *dthread;
SyncDelta *dlock;
@@ -111,7 +109,7 @@ struct _ECalBackendGroupwisePrivate {
#define PRIV_UNLOCK(p) (g_static_rec_mutex_unlock (&(p)->rec_mutex))
static void e_cal_backend_groupwise_finalize (GObject *object);
-static void e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **perror);
+static void e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, 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);
@@ -150,14 +148,6 @@ e_cal_backend_groupwise_get_categories_by_name (ECalBackendGroupwise *cbgw) {
return cbgw->priv->categories_by_name;
}
-icaltimezone *
-e_cal_backend_groupwise_get_default_zone (ECalBackendGroupwise *cbgw) {
-
- g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), NULL);
-
- return cbgw->priv->default_zone;
-}
-
const gchar *
e_cal_backend_groupwise_get_container_id (ECalBackendGroupwise *cbgw)
{
@@ -219,12 +209,48 @@ put_component_to_store (ECalBackendGroupwise *cbgw,
priv = cbgw->priv;
e_cal_util_get_component_occur_times (comp, &time_start, &time_end,
- resolve_tzid, cbgw, priv->default_zone,
+ resolve_tzid, cbgw, icaltimezone_get_utc_timezone (),
e_cal_backend_get_kind (E_CAL_BACKEND (cbgw)));
e_cal_backend_store_put_component_with_time_range (priv->store, comp, time_start, time_end);
}
+struct progressData
+{
+ gint percent;
+ const gchar *message;
+};
+
+static gboolean
+update_progress_cb (EDataCalView *view, gpointer user_data)
+{
+ struct progressData *pd = user_data;
+
+ g_return_val_if_fail (view != NULL, FALSE);
+ g_return_val_if_fail (user_data != NULL, FALSE);
+
+ if ((!pd->message || !*pd->message) && (pd->percent >= 100 || pd->percent < 0)) {
+ e_data_cal_view_notify_complete (view, NULL);
+ } else {
+ e_data_cal_view_notify_progress (view, pd->percent, pd->message);
+ }
+
+ return TRUE;
+}
+
+static void
+notify_view_progress (ECalBackend *backend, gint percent, const gchar *message)
+{
+ struct progressData pd;
+
+ g_return_if_fail (backend != NULL);
+
+ pd.percent = percent;
+ pd.message = message;
+
+ e_cal_backend_foreach_view (backend, update_progress_cb, &pd);
+}
+
/* Initialy populate the cache from the server */
static EGwConnectionStatus
populate_cache (ECalBackendGroupwise *cbgw)
@@ -299,8 +325,6 @@ populate_cache (ECalBackendGroupwise *cbgw)
forward = FALSE;
}
- e_cal_backend_notify_view_progress_start (E_CAL_BACKEND (cbgw));
-
while (!done) {
status = e_gw_connection_read_cursor (priv->cnc, priv->container_id, cursor, forward, CURSOR_ITEM_LIMIT, position, &list);
@@ -326,13 +350,13 @@ populate_cache (ECalBackendGroupwise *cbgw)
percent = 99;
if (g_str_equal (type, "Appointment"))
- e_cal_backend_notify_view_progress (E_CAL_BACKEND (cbgw), _("Loading Appointment items"), percent);
+ notify_view_progress (E_CAL_BACKEND (cbgw), percent, _("Loading Appointment items"));
else if (g_str_equal (type, "Task"))
- e_cal_backend_notify_view_progress (E_CAL_BACKEND (cbgw), _("Loading Task items"), percent);
+ notify_view_progress (E_CAL_BACKEND (cbgw), percent, _("Loading Task items"));
else if (g_str_equal (type, "Note"))
- e_cal_backend_notify_view_progress (E_CAL_BACKEND (cbgw), _("Loading Note items"), percent);
+ notify_view_progress (E_CAL_BACKEND (cbgw), percent, _("Loading Note items"));
else
- e_cal_backend_notify_view_progress (E_CAL_BACKEND (cbgw), _("Loading items"), percent);
+ notify_view_progress (E_CAL_BACKEND (cbgw), percent, _("Loading items"));
if (E_IS_CAL_COMPONENT (comp)) {
gchar *comp_str;
@@ -355,7 +379,7 @@ populate_cache (ECalBackendGroupwise *cbgw)
e_gw_connection_destroy_cursor (priv->cnc, priv->container_id, cursor);
g_object_unref (filter[i]);
}
- e_cal_backend_notify_view_progress (E_CAL_BACKEND (cbgw), "", 100);
+ notify_view_progress (E_CAL_BACKEND (cbgw), 100, "");
return E_GW_CONNECTION_STATUS_OK;
}
@@ -424,7 +448,7 @@ get_deltas (gpointer handle)
cbgw = (ECalBackendGroupwise *) handle;
priv = cbgw->priv;
- if (priv->mode == CAL_MODE_LOCAL)
+ if (!priv->is_online)
return FALSE;
kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
@@ -824,7 +848,7 @@ e_cal_backend_groupwise_refresh_calendar (ECalBackendGroupwise *cbgw)
ECalBackendGroupwisePrivate *priv = cbgw->priv;
gboolean delta_started = FALSE;
- if (priv->mode == CAL_MODE_LOCAL)
+ if (!priv->is_online)
return;
PRIV_LOCK (priv);
@@ -897,7 +921,7 @@ cache_init (ECalBackendGroupwise *cbgw)
g_warning (G_STRLOC ": Could not get the categories from the server");
}
- priv->mode = CAL_MODE_REMOTE;
+ priv->is_online = TRUE;
/* We poke the cache for a default timezone. Its
* absence indicates that the cache file has not been
@@ -1002,8 +1026,14 @@ connect_to_server (ECalBackendGroupwise *cbgw, GError **perror)
gchar *parent_user = NULL;
icalcomponent_kind kind;
EGwConnectionErrors errors;
+
priv = cbgw->priv;
+ if (!priv->credentials) {
+ g_propagate_error (perror, EDC_ERROR (AuthenticationRequired));
+ return;
+ }
+
source = e_cal_backend_get_source (E_CAL_BACKEND (cbgw));
real_uri = NULL;
if (source)
@@ -1025,10 +1055,10 @@ connect_to_server (ECalBackendGroupwise *cbgw, GError **perror)
if (parent_user) {
EGwConnection *cnc;
/* create connection to server */
- cnc = e_gw_connection_new (real_uri, parent_user, priv->password);
+ cnc = e_gw_connection_new (real_uri, parent_user, e_credentials_peek (priv->credentials, E_CREDENTIALS_KEY_PASSWORD));
if (!E_IS_GW_CONNECTION(cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
http_uri = g_strconcat ("http://", real_uri + 8, NULL);
- cnc = e_gw_connection_new (http_uri, parent_user, priv->password);
+ cnc = e_gw_connection_new (http_uri, parent_user, e_credentials_peek (priv->credentials, E_CREDENTIALS_KEY_PASSWORD));
g_free (http_uri);
}
@@ -1037,7 +1067,7 @@ connect_to_server (ECalBackendGroupwise *cbgw, GError **perror)
return;
}
- priv->cnc = e_gw_connection_get_proxy_connection (cnc, parent_user, priv->password, priv->username, &permissions);
+ priv->cnc = e_gw_connection_get_proxy_connection (cnc, parent_user, e_credentials_peek (priv->credentials, E_CREDENTIALS_KEY_PASSWORD), e_credentials_peek (priv->credentials, E_CREDENTIALS_KEY_USERNAME), &permissions);
g_object_unref (cnc);
@@ -1057,22 +1087,25 @@ connect_to_server (ECalBackendGroupwise *cbgw, GError **perror)
} else {
- priv->cnc = e_gw_connection_new_with_error_handler ( real_uri, priv->username, priv->password, &errors);
+ priv->cnc = e_gw_connection_new_with_error_handler ( real_uri, e_credentials_peek (priv->credentials, E_CREDENTIALS_KEY_USERNAME), e_credentials_peek (priv->credentials, E_CREDENTIALS_KEY_PASSWORD), &errors);
if (!E_IS_GW_CONNECTION(priv->cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
http_uri = g_strconcat ("http://", real_uri + 8, NULL);
- priv->cnc = e_gw_connection_new_with_error_handler (http_uri, priv->username, priv->password, &errors);
+ priv->cnc = e_gw_connection_new_with_error_handler (http_uri, e_credentials_peek (priv->credentials, E_CREDENTIALS_KEY_USERNAME), e_credentials_peek (priv->credentials, E_CREDENTIALS_KEY_PASSWORD), &errors);
g_free (http_uri);
}
cbgw->priv->read_only = FALSE;
}
g_free (real_uri);
+ e_cal_backend_notify_readonly (E_CAL_BACKEND (cbgw), cbgw->priv->read_only);
+ e_cal_backend_notify_online (E_CAL_BACKEND (cbgw), priv->is_online);
+
if (priv->cnc ) {
if (priv->store && priv->container_id) {
- priv->mode = CAL_MODE_REMOTE;
- if (priv->mode_changed && !priv->dthread) {
- priv->mode_changed = FALSE;
+ priv->is_online = TRUE;
+ if (priv->is_online_changed && !priv->dthread) {
+ priv->is_online_changed = FALSE;
fetch_deltas (cbgw);
}
@@ -1092,7 +1125,7 @@ connect_to_server (ECalBackendGroupwise *cbgw, GError **perror)
g_free (errors.description);
return;
}
- priv->mode_changed = FALSE;
+ priv->is_online_changed = FALSE;
if (E_IS_GW_CONNECTION (priv->cnc)) {
ECalBackend *backend;
@@ -1186,15 +1219,8 @@ e_cal_backend_groupwise_finalize (GObject *object)
priv->store = NULL;
}
- if (priv->username) {
- g_free (priv->username);
- priv->username = NULL;
- }
-
- if (priv->password) {
- g_free (priv->password);
- priv->password = NULL;
- }
+ e_credentials_free (priv->credentials);
+ priv->credentials = NULL;
if (priv->container_id) {
g_free (priv->container_id);
@@ -1211,11 +1237,6 @@ e_cal_backend_groupwise_finalize (GObject *object)
priv->sendoptions_sync_timeout = 0;
}
- if (priv->default_zone) {
- icaltimezone_free (priv->default_zone, 1);
- priv->default_zone = NULL;
- }
-
g_free (priv);
cbgw->priv = NULL;
@@ -1225,72 +1246,75 @@ e_cal_backend_groupwise_finalize (GObject *object)
/* Calendar backend methods */
-/* Is_read_only handler for the file backend */
-static void
-e_cal_backend_groupwise_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only, GError **perror)
+static gboolean
+e_cal_backend_groupwise_get_backend_property (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *prop_name, gchar **prop_value, GError **perror)
{
- ECalBackendGroupwise *cbgw;
-
- cbgw = E_CAL_BACKEND_GROUPWISE (backend);
- *read_only = cbgw->priv->read_only;
-}
+ gboolean processed = TRUE;
+
+ g_return_val_if_fail (prop_name != NULL, FALSE);
+ g_return_val_if_fail (prop_value != NULL, FALSE);
+
+ if (g_str_equal (prop_name, CLIENT_BACKEND_PROPERTY_CAPABILITIES)) {
+ *prop_value = g_strdup (CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS ","
+ CAL_STATIC_CAPABILITY_ONE_ALARM_ONLY ","
+ CAL_STATIC_CAPABILITY_REMOVE_ALARMS ","
+ CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
+ CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
+ CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK ","
+ CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR ","
+ CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS ","
+ CAL_STATIC_CAPABILITY_SAVE_SCHEDULES ","
+ CAL_STATIC_CAPABILITY_ORGANIZER_MUST_ACCEPT ","
+ CAL_STATIC_CAPABILITY_DELEGATE_SUPPORTED ","
+ CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY ","
+ CAL_STATIC_CAPABILITY_NO_ORGANIZER ","
+ CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER ","
+ CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING ","
+ CAL_STATIC_CAPABILITY_SAVE_SCHEDULES);
+ } else if (g_str_equal (prop_name, CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS)) {
+ /* return email address of the person who opened the calendar */
+ ECalBackendGroupwise *cbgw;
+ ECalBackendGroupwisePrivate *priv;
+
+ cbgw = E_CAL_BACKEND_GROUPWISE (backend);
+ priv = cbgw->priv;
+
+ if (priv->is_online) {
+ if (priv->user_email)
+ g_free (priv->user_email);
+
+ priv->user_email = g_strdup (e_gw_connection_get_user_email (cbgw->priv->cnc));
+ }
-/* return email address of the person who opened the calendar */
-static void
-e_cal_backend_groupwise_get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
-{
- ECalBackendGroupwise *cbgw;
- ECalBackendGroupwisePrivate *priv;
+ *prop_value = g_strdup (priv->user_email);
+ } else if (g_str_equal (prop_name, CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS)) {
+ /* group wise does not support email based alarms */
+ *prop_value = NULL;
+ } else if (g_str_equal (prop_name, CAL_BACKEND_PROPERTY_DEFAULT_OBJECT)) {
+ ECalComponent *comp;
- cbgw = E_CAL_BACKEND_GROUPWISE (backend);
- priv = cbgw->priv;
+ comp = e_cal_component_new ();
- if (priv->mode == CAL_MODE_REMOTE) {
- if (priv->user_email)
- g_free (priv->user_email);
+ switch (e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
+ case ICAL_VEVENT_COMPONENT:
+ e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
+ break;
+ case ICAL_VTODO_COMPONENT:
+ e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO);
+ break;
+ default:
+ g_object_unref (comp);
+ g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
+ return TRUE;
+ }
- priv->user_email = g_strdup (e_gw_connection_get_user_email (cbgw->priv->cnc));
+ *prop_value = e_cal_component_get_as_string (comp);
+ g_object_unref (comp);
+ } else {
+ processed = FALSE;
}
- *address = g_strdup (priv->user_email);
-}
-
-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;
-}
-
-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;
-}
-
-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 ","
- CAL_STATIC_CAPABILITY_REMOVE_ALARMS ","
- CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
- CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
- CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK ","
- CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR ","
- CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS ","
- CAL_STATIC_CAPABILITY_SAVE_SCHEDULES ","
- CAL_STATIC_CAPABILITY_ORGANIZER_MUST_ACCEPT ","
- CAL_STATIC_CAPABILITY_DELEGATE_SUPPORTED ","
- CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY ","
- CAL_STATIC_CAPABILITY_NO_ORGANIZER ","
- CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER ","
- CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING ","
- CAL_STATIC_CAPABILITY_SAVE_SCHEDULES);
+ return processed;
}
static void
@@ -1298,7 +1322,10 @@ in_offline (ECalBackendGroupwise *cbgw) {
ECalBackendGroupwisePrivate *priv;
priv= cbgw->priv;
- priv->read_only = TRUE;
+ if (!priv->read_only) {
+ priv->read_only = TRUE;
+ e_cal_backend_notify_readonly (E_CAL_BACKEND (cbgw), priv->read_only);
+ }
if (priv->dlock) {
g_mutex_lock (priv->dlock->mutex);
@@ -1317,13 +1344,11 @@ in_offline (ECalBackendGroupwise *cbgw) {
g_object_unref (priv->cnc);
priv->cnc = NULL;
}
-
}
/* Open handler for the file backend */
static void
-e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
- const gchar *username, const gchar *password, GError **perror)
+e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, gboolean only_if_exists, GError **perror)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -1337,18 +1362,22 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
PRIV_LOCK (priv);
cbgw->priv->read_only = FALSE;
+ e_cal_backend_notify_online (E_CAL_BACKEND (backend), priv->is_online);
- if (priv->mode == CAL_MODE_LOCAL) {
+ if (!priv->is_online) {
ESource *esource;
const gchar *display_contents = NULL;
cbgw->priv->read_only = TRUE;
+ e_cal_backend_notify_readonly (E_CAL_BACKEND (cbgw), cbgw->priv->read_only);
+
esource = e_cal_backend_get_source (E_CAL_BACKEND (cbgw));
display_contents = e_source_get_property (esource, "offline_sync");
if (!display_contents || !g_str_equal (display_contents, "1")) {
PRIV_UNLOCK (priv);
g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
+ e_cal_backend_notify_opened (E_CAL_BACKEND (backend), EDC_ERROR (RepositoryOffline));
return;
}
@@ -1359,58 +1388,62 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
if (!priv->store) {
PRIV_UNLOCK (priv);
g_propagate_error (perror, EDC_ERROR_EX (OtherError, _("Could not create cache file")));
+ e_cal_backend_notify_opened (E_CAL_BACKEND (backend), EDC_ERROR_EX (OtherError, _("Could not create cache file")));
return;
}
}
e_cal_backend_store_load (priv->store);
+ e_cal_backend_notify_opened (E_CAL_BACKEND (backend), NULL);
PRIV_UNLOCK (priv);
return;
}
- priv->username = g_strdup (username);
- priv->password = g_strdup (password);
+ if (priv->credentials) {
+ GError *local_error = NULL;
- /* FIXME: no need to set it online here when we implement the online/offline stuff correctly */
- connect_to_server (cbgw, perror);
+ connect_to_server (cbgw, &local_error);
+
+ if (!local_error)
+ e_cal_backend_notify_opened (E_CAL_BACKEND (backend), NULL);
+ else
+ g_propagate_error (perror, local_error);
+ } else {
+ e_cal_backend_notify_auth_required (E_CAL_BACKEND (cbgw), TRUE, priv->credentials);
+ }
PRIV_UNLOCK (priv);
}
static void
-e_cal_backend_groupwise_remove (ECalBackendSync *backend, EDataCal *cal, GError **perror)
+e_cal_backend_groupwise_authenticate_user (ECalBackendSync *backend, GCancellable *cancellable, ECredentials *credentials, GError **error)
{
- ECalBackendGroupwise *cbgw;
+ ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
- priv = cbgw->priv;
+ priv = cbgw->priv;
PRIV_LOCK (priv);
- /* remove the cache */
- if (priv->store)
- e_cal_backend_store_remove (priv->store);
+ e_credentials_free (priv->credentials);
+ priv->credentials = NULL;
- PRIV_UNLOCK (priv);
-}
+ if (!credentials || !e_credentials_has_key (credentials, E_CREDENTIALS_KEY_USERNAME)) {
+ PRIV_UNLOCK (priv);
+ g_propagate_error (error, EDC_ERROR (AuthenticationFailed));
+ return;
+ }
-/* is_loaded handler for the file backend */
-static gboolean
-e_cal_backend_groupwise_is_loaded (ECalBackend *backend)
-{
- ECalBackendGroupwise *cbgw;
- ECalBackendGroupwisePrivate *priv;
+ priv->credentials = e_credentials_new_clone (credentials);
- cbgw = E_CAL_BACKEND_GROUPWISE (backend);
- priv = cbgw->priv;
+ connect_to_server (cbgw, error);
- return priv->store ? TRUE : FALSE;
+ PRIV_UNLOCK (priv);
}
-/* is_remote handler for the file backend */
-static CalMode
-e_cal_backend_groupwise_get_mode (ECalBackend *backend)
+static void
+e_cal_backend_groupwise_remove (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, GError **perror)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -1418,12 +1451,18 @@ e_cal_backend_groupwise_get_mode (ECalBackend *backend)
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
- return priv->mode;
+ PRIV_LOCK (priv);
+
+ /* remove the cache */
+ if (priv->store)
+ e_cal_backend_store_remove (priv->store);
+
+ PRIV_UNLOCK (priv);
}
/* Set_mode handler for the file backend */
static void
-e_cal_backend_groupwise_set_mode (ECalBackend *backend, CalMode mode)
+e_cal_backend_groupwise_set_online (ECalBackend *backend, gboolean is_online)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -1431,69 +1470,34 @@ e_cal_backend_groupwise_set_mode (ECalBackend *backend, CalMode mode)
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
- if (priv->mode == mode) {
- e_cal_backend_notify_mode (backend, ModeSet,
- cal_mode_to_corba (mode));
+ if ((priv->is_online ? 1 : 0) == (is_online ? 1 : 0)) {
+ e_cal_backend_notify_online (backend, priv->is_online);
return;
}
PRIV_LOCK (priv);
- priv->mode_changed = TRUE;
- switch (mode) {
- case CAL_MODE_REMOTE :/* go online */
- priv->mode = CAL_MODE_REMOTE;
+ priv->is_online = is_online;
+ priv->is_online_changed = TRUE;
+ if (is_online) {
priv->read_only = FALSE;
- e_cal_backend_notify_mode (backend, ModeSet, Remote);
+ e_cal_backend_notify_online (backend, priv->is_online);
e_cal_backend_notify_readonly (backend, priv->read_only);
- if (e_cal_backend_groupwise_is_loaded (backend))
- e_cal_backend_notify_auth_required (backend);
- break;
-
- case CAL_MODE_LOCAL : /* go offline */
+ if (e_cal_backend_is_opened (backend))
+ e_cal_backend_notify_auth_required (backend, TRUE, priv->credentials);
+ } else {
/* FIXME: make sure we update the cache before closing the connection */
- priv->mode = CAL_MODE_LOCAL;
in_offline (cbgw);
e_cal_backend_notify_readonly (backend, priv->read_only);
- e_cal_backend_notify_mode (backend, ModeSet, Local);
-
- break;
- default :
- e_cal_backend_notify_mode (backend, ModeNotSupported,
- cal_mode_to_corba (mode));
+ e_cal_backend_notify_online (backend, priv->is_online);
}
PRIV_UNLOCK (priv);
}
-static void
-e_cal_backend_groupwise_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object, GError **perror)
-{
-
- ECalComponent *comp;
-
- comp = e_cal_component_new ();
-
- switch (e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
- case ICAL_VEVENT_COMPONENT:
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
- break;
- case ICAL_VTODO_COMPONENT:
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO);
- break;
- default:
- g_object_unref (comp);
- g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
- return;
- }
-
- *object = e_cal_component_get_as_string (comp);
- g_object_unref (comp);
-}
-
/* Get_object_component handler for the groupwise backend */
static void
-e_cal_backend_groupwise_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object, GError **error)
+e_cal_backend_groupwise_get_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, gchar **object, GError **error)
{
ECalComponent *comp;
ECalBackendGroupwisePrivate *priv;
@@ -1530,7 +1534,7 @@ e_cal_backend_groupwise_get_object (ECalBackendSync *backend, EDataCal *cal, con
/* Add_timezone handler for the groupwise backend */
static void
-e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
+e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *tzobj, GError **error)
{
icalcomponent *tz_comp;
ECalBackendGroupwise *cbgw;
@@ -1563,51 +1567,16 @@ e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, c
}
}
-static void
-e_cal_backend_groupwise_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj, GError **error)
-{
- icalcomponent *tz_comp;
- ECalBackendGroupwise *cbgw;
- ECalBackendGroupwisePrivate *priv;
- icaltimezone *zone;
-
- cbgw = (ECalBackendGroupwise *) backend;
-
- 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) {
- g_propagate_error (error, EDC_ERROR (InvalidObject));
- return;
- }
-
- zone = icaltimezone_new ();
- icaltimezone_set_component (zone, tz_comp);
-
- PRIV_LOCK (priv);
-
- if (priv->default_zone)
- icaltimezone_free (priv->default_zone, 1);
-
- /* Set the default timezone to it. */
- priv->default_zone = zone;
-
- PRIV_UNLOCK (priv);
-}
-
/* Gets the list of attachments */
static void
-e_cal_backend_groupwise_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, GSList **list, GError **perror)
+e_cal_backend_groupwise_get_attachment_uris (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, GSList **list, GError **perror)
{
/* TODO implement the function */
}
/* Get_objects_in_range handler for the groupwise backend */
static void
-e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects, GError **perror)
+e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *sexp, GSList **objects, GError **perror)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -1645,7 +1614,7 @@ e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal
icalcomponent_isa (e_cal_component_get_icalcomponent (comp))) {
if ((!search_needed) ||
(e_cal_backend_sexp_match_comp (cbsexp, comp, E_CAL_BACKEND (backend)))) {
- *objects = g_list_append (*objects, e_cal_component_get_as_string (comp));
+ *objects = g_slist_append (*objects, e_cal_component_get_as_string (comp));
}
}
}
@@ -1657,42 +1626,42 @@ e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal
/* get_query handler for the groupwise backend */
static void
-e_cal_backend_groupwise_start_query (ECalBackend *backend, EDataCalView *query)
+e_cal_backend_groupwise_start_view (ECalBackend *backend, EDataCalView *query)
{
- GList *objects = NULL;
+ GSList *objects = NULL;
GError *err = NULL;
- e_cal_backend_groupwise_get_object_list (E_CAL_BACKEND_SYNC (backend), NULL,
+ e_cal_backend_groupwise_get_object_list (E_CAL_BACKEND_SYNC (backend), NULL, NULL,
e_data_cal_view_get_text (query), &objects, &err);
if (err) {
- e_data_cal_view_notify_done (query, err);
+ e_data_cal_view_notify_complete (query, err);
g_error_free (err);
return;
}
/* notify listeners of all objects */
if (objects) {
- e_data_cal_view_notify_objects_added (query, (const GList *) objects);
+ e_data_cal_view_notify_objects_added (query, objects);
/* free memory */
- g_list_foreach (objects, (GFunc) g_free, NULL);
- g_list_free (objects);
+ g_slist_foreach (objects, (GFunc) g_free, NULL);
+ g_slist_free (objects);
}
- e_data_cal_view_notify_done (query, NULL);
+ e_data_cal_view_notify_complete (query, NULL);
}
/* Get_free_busy handler for the file backend */
static void
-e_cal_backend_groupwise_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users,
- time_t start, time_t end, GList **freebusy, GError **perror)
+e_cal_backend_groupwise_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const GSList *users,
+ time_t start, time_t end, GSList **freebusy, GError **perror)
{
EGwConnectionStatus status;
ECalBackendGroupwise *cbgw;
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
- if (cbgw->priv->mode == CAL_MODE_LOCAL) {
+ if (!cbgw->priv->is_online) {
in_offline (cbgw);
g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
return;
@@ -1707,132 +1676,6 @@ e_cal_backend_groupwise_get_free_busy (ECalBackendSync *backend, EDataCal *cal,
g_propagate_error (perror, EDC_ERROR_FAILED_STATUS (OtherError, status));
}
-typedef struct {
- ECalBackendGroupwise *backend;
- icalcomponent_kind kind;
- GList *deletes;
- EXmlHash *ehash;
-} ECalBackendGroupwiseComputeChangesData;
-
-static void
-e_cal_backend_groupwise_compute_changes_foreach_key (const gchar *key, const gchar *value, gpointer data)
-{
- ECalBackendGroupwiseComputeChangesData *be_data = data;
-
- if (!e_cal_backend_store_get_component (be_data->backend->priv->store, key, NULL)) {
- ECalComponent *comp;
-
- comp = e_cal_component_new ();
- if (be_data->kind == ICAL_VTODO_COMPONENT)
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO);
- else
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
-
- e_cal_component_set_uid (comp, key);
- be_data->deletes = g_list_prepend (be_data->deletes, e_cal_component_get_as_string (comp));
-
- e_xmlhash_remove (be_data->ehash, key);
- g_object_unref (comp);
- }
-}
-
-static void
-e_cal_backend_groupwise_compute_changes (ECalBackendGroupwise *cbgw, const gchar *change_id,
- GList **adds, GList **modifies, GList **deletes, GError **perror)
-{
- 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, "");
- filename = g_strdup_printf ("%s-%s.db", unescaped_uri, change_id);
- ehash = e_xmlhash_new (filename);
- g_free (filename);
- g_free (unescaped_uri);
-
- 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)) {
- const gchar *uid;
- gchar *calobj;
- ECalComponent *comp;
-
- comp = e_cal_component_new_from_string (i->data);
- e_cal_component_get_uid (comp, &uid);
- calobj = i->data;
-
- g_assert (calobj != NULL);
-
- /* check what type of change has occurred, if any */
- switch (e_xmlhash_compare (ehash, uid, calobj)) {
- case E_XMLHASH_STATUS_SAME:
- break;
- case E_XMLHASH_STATUS_NOT_FOUND:
- *adds = g_list_prepend (*adds, g_strdup (calobj));
- e_xmlhash_add (ehash, uid, calobj);
- break;
- case E_XMLHASH_STATUS_DIFFERENT:
- *modifies = g_list_prepend (*modifies, g_strdup (calobj));
- e_xmlhash_add (ehash, uid, calobj);
- break;
- }
-
- g_free (calobj);
- g_object_unref (comp);
- }
- g_list_free (list);
-
- /* Calculate deletions */
- be_data.backend = cbgw;
- be_data.kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
- be_data.deletes = NULL;
- be_data.ehash = ehash;
- e_xmlhash_foreach_key (ehash, (EXmlHashFunc) e_cal_backend_groupwise_compute_changes_foreach_key, &be_data);
-
- *deletes = be_data.deletes;
-
- e_xmlhash_write (ehash);
- e_xmlhash_destroy (ehash);
-}
-
-/* Get_changes handler for the groupwise backend */
-static void
-e_cal_backend_groupwise_get_changes (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id,
- GList **adds, GList **modifies, GList **deletes, GError **error)
-{
- ECalBackendGroupwise *cbgw;
- cbgw = E_CAL_BACKEND_GROUPWISE (backend);
-
- 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 void
-e_cal_backend_groupwise_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid, GError **perror)
-{
- g_propagate_error (perror, EDC_ERROR (NotSupported));
-}
-
-static icaltimezone *
-e_cal_backend_groupwise_internal_get_default_timezone (ECalBackend *backend)
-{
- ECalBackendGroupwise *cbgw = E_CAL_BACKEND_GROUPWISE (backend);
-
- return cbgw->priv->default_zone;
-}
-
static icaltimezone *
e_cal_backend_groupwise_internal_get_timezone (ECalBackend *backend, const gchar *tzid)
{
@@ -1909,7 +1752,7 @@ update_from_server (ECalBackendGroupwise *cbgw, GSList *uid_list, gchar **calobj
}
static void
-e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid, GError **error)
+e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *in_calobj, gchar **uid, gchar **new_calobj, GError **error)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -1922,16 +1765,17 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal,
priv = cbgw->priv;
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);
+ e_return_data_cal_error_if_fail (in_calobj != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (new_calobj != NULL, InvalidArg);
- if (priv->mode == CAL_MODE_LOCAL) {
+ if (!priv->is_online) {
in_offline (cbgw);
g_propagate_error (error, EDC_ERROR (RepositoryOffline));
return;
}
/* check the component for validity */
- icalcomp = icalparser_parse_string (*calobj);
+ icalcomp = icalparser_parse_string (in_calobj);
if (!icalcomp) {
g_propagate_error (error, EDC_ERROR (InvalidObject));
return;
@@ -1947,9 +1791,7 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal,
e_cal_component_set_icalcomponent (comp, icalcomp);
/* check if the object exists */
- switch (priv->mode) {
- case CAL_MODE_ANY :
- case CAL_MODE_REMOTE :
+ if (priv->is_online) {
/* when online, send the item to the server */
status = e_gw_connection_create_appointment (priv->cnc, priv->container_id, cbgw, comp, &uid_list);
@@ -1978,15 +1820,11 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal,
}
/* Get the item back from server to update the last-modified time */
- status = update_from_server (cbgw, uid_list, calobj, comp);
+ status = update_from_server (cbgw, uid_list, new_calobj, comp);
if (status != E_GW_CONNECTION_STATUS_OK) {
g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
return;
}
-
- break;
- default :
- break;
}
g_object_unref (comp);
@@ -2031,7 +1869,7 @@ get_retract_data (ECalComponent *comp, const gchar **retract_comment, gboolean *
}
static void
-e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj,
+e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj,
CalObjModType mod, gchar **old_object, gchar **new_object, GError **error)
{
ECalBackendGroupwise *cbgw;
@@ -2050,7 +1888,7 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
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) {
+ if (!priv->is_online) {
in_offline (cbgw);
g_propagate_error (error, EDC_ERROR (RepositoryOffline));
return;
@@ -2068,101 +1906,98 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
rid = e_cal_component_get_recurid_as_string (comp);
/* check if the object exists */
- switch (priv->mode) {
- case CAL_MODE_ANY :
- case CAL_MODE_REMOTE :
- /* when online, send the item to the server */
- cache_comp = e_cal_backend_store_get_component (priv->store, uid, rid);
- if (!cache_comp) {
- g_critical ("Could not find the object in cache");
- g_free (rid);
- g_propagate_error (error, EDC_ERROR (ObjectNotFound));
- return;
- }
-
- if (e_cal_component_has_attendees (comp) &&
- e_cal_backend_groupwise_utils_check_delegate (comp, e_gw_connection_get_user_email (priv->cnc))) {
- const gchar *id = NULL, *recur_key = NULL;
-
- item = e_gw_item_new_for_delegate_from_cal (cbgw, comp);
-
- if (mod == CALOBJ_MOD_ALL && e_cal_component_is_instance (comp)) {
- recur_key = uid;
- }
- id = e_gw_item_get_id (item);
-
- status = e_gw_connection_delegate_request (priv->cnc, item, id, NULL, NULL, recur_key);
-
- if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_delegate_request (priv->cnc, item, id, NULL, NULL, recur_key);
- if (status != E_GW_CONNECTION_STATUS_OK) {
- g_object_unref (comp);
- g_object_unref (cache_comp);
+ if (priv->is_online) {
+ while (1) {
+ /* when online, send the item to the server */
+ cache_comp = e_cal_backend_store_get_component (priv->store, uid, rid);
+ if (!cache_comp) {
+ g_critical ("Could not find the object in cache");
g_free (rid);
- g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
return;
}
- put_component_to_store (cbgw, comp);
- *new_object = e_cal_component_get_as_string (comp);
- break;
- }
+ if (e_cal_component_has_attendees (comp) &&
+ e_cal_backend_groupwise_utils_check_delegate (comp, e_gw_connection_get_user_email (priv->cnc))) {
+ const gchar *id = NULL, *recur_key = NULL;
- item = e_gw_item_new_from_cal_component (priv->container_id, cbgw, comp);
- cache_item = e_gw_item_new_from_cal_component (priv->container_id, cbgw, cache_comp);
- if ( e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_TASK) {
- gboolean completed, cache_completed;
+ item = e_gw_item_new_for_delegate_from_cal (cbgw, comp);
- completed = e_gw_item_get_completed (item);
- cache_completed = e_gw_item_get_completed (cache_item);
- if (completed && !cache_completed) {
- /*FIXME return values. */
- status = e_gw_connection_complete_request (priv->cnc, e_gw_item_get_id (item));
+ if (mod == CALOBJ_MOD_ALL && e_cal_component_is_instance (comp)) {
+ recur_key = uid;
+ }
+ id = e_gw_item_get_id (item);
- if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_complete_request (priv->cnc, e_gw_item_get_id (item));
+ status = e_gw_connection_delegate_request (priv->cnc, item, id, NULL, NULL, recur_key);
+ if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+ status = e_gw_connection_delegate_request (priv->cnc, item, id, NULL, NULL, recur_key);
if (status != E_GW_CONNECTION_STATUS_OK) {
g_object_unref (comp);
g_object_unref (cache_comp);
g_free (rid);
-
- if (status == E_GW_CONNECTION_STATUS_OVER_QUOTA) {
- g_propagate_error (error, EDC_ERROR (PermissionDenied));
- return;
- }
-
g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
return;
}
+
put_component_to_store (cbgw, comp);
+ *new_object = e_cal_component_get_as_string (comp);
break;
}
- }
- e_gw_item_set_changes (item, cache_item);
+ item = e_gw_item_new_from_cal_component (priv->container_id, cbgw, comp);
+ cache_item = e_gw_item_new_from_cal_component (priv->container_id, cbgw, cache_comp);
+ if ( e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_TASK) {
+ gboolean completed, cache_completed;
- /* the second argument is redundant */
- status = e_gw_connection_modify_item (priv->cnc, e_gw_item_get_id (item), item);
+ completed = e_gw_item_get_completed (item);
+ cache_completed = e_gw_item_get_completed (cache_item);
+ if (completed && !cache_completed) {
+ /*FIXME return values. */
+ status = e_gw_connection_complete_request (priv->cnc, e_gw_item_get_id (item));
- if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+ if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+ status = e_gw_connection_complete_request (priv->cnc, e_gw_item_get_id (item));
+
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ g_object_unref (comp);
+ g_object_unref (cache_comp);
+ g_free (rid);
+
+ if (status == E_GW_CONNECTION_STATUS_OVER_QUOTA) {
+ g_propagate_error (error, EDC_ERROR (PermissionDenied));
+ return;
+ }
+
+ g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ return;
+ }
+ put_component_to_store (cbgw, comp);
+ break;
+ }
+ }
+
+ e_gw_item_set_changes (item, cache_item);
+
+ /* the second argument is redundant */
status = e_gw_connection_modify_item (priv->cnc, e_gw_item_get_id (item), item);
- if (status != E_GW_CONNECTION_STATUS_OK) {
- g_object_unref (comp);
- g_object_unref (cache_comp);
- g_free (rid);
- g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
- return;
+ if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+ status = e_gw_connection_modify_item (priv->cnc, e_gw_item_get_id (item), item);
+
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ g_object_unref (comp);
+ g_object_unref (cache_comp);
+ g_free (rid);
+ g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ return;
+ }
+ break;
}
/* if successful, update the cache */
-
- case CAL_MODE_LOCAL :
+ } else {
/* in offline mode, we just update the cache */
put_component_to_store (cbgw, comp);
- break;
- default :
- break;
}
*old_object = e_cal_component_get_as_string (cache_comp);
@@ -2194,7 +2029,7 @@ get_gw_item_id (icalcomponent *icalcomp)
/* Remove_object handler for the file backend */
static void
-e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
+e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable,
const gchar *uid, const gchar *rid,
CalObjModType mod, gchar **old_object,
gchar **object, GError **perror)
@@ -2211,11 +2046,11 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
*old_object = *object = NULL;
/* if online, remove the item from the server */
- if (priv->mode == CAL_MODE_REMOTE) {
+ if (priv->is_online) {
const gchar *id_to_remove = NULL;
icalcomponent *icalcomp;
- e_cal_backend_groupwise_get_object (backend, cal, uid, rid, &calobj, &err);
+ e_cal_backend_groupwise_get_object (backend, cal, NULL, uid, rid, &calobj, &err);
if (err) {
g_propagate_error (perror, err);
return;
@@ -2318,13 +2153,9 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
g_propagate_error (perror, EDC_ERROR (UnsupportedMethod));
return;
}
- } else if (priv->mode == CAL_MODE_LOCAL) {
+ } else {
in_offline (cbgw);
g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
- return;
- } else {
- g_propagate_error (perror, EDC_ERROR_EX (OtherError, "Incorrect online mode set"));
- return;
}
}
@@ -2566,7 +2397,7 @@ receive_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalco
/* Update_objects handler for the file backend. */
static void
-e_cal_backend_groupwise_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GError **perror)
+e_cal_backend_groupwise_receive_objects (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, GError **perror)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -2577,7 +2408,7 @@ e_cal_backend_groupwise_receive_objects (ECalBackendSync *backend, EDataCal *cal
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
- if (priv->mode == CAL_MODE_LOCAL) {
+ if (!priv->is_online) {
in_offline (cbgw);
g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
return;
@@ -2637,9 +2468,7 @@ send_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp,
return;
}
- switch (priv->mode) {
- case CAL_MODE_ANY :
- case CAL_MODE_REMOTE :
+ if (priv->is_online) {
if (method == ICAL_METHOD_CANCEL) {
const gchar *retract_comment = NULL;
gboolean all_instances = FALSE;
@@ -2658,14 +2487,9 @@ send_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp,
if (status != E_GW_CONNECTION_STATUS_OK)
g_propagate_error (perror, EDC_ERROR_FAILED_STATUS (OtherError, status));
}
- break;
- case CAL_MODE_LOCAL :
+ } else {
/* in offline mode, we just update the cache */
g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
- break;
- default:
- g_propagate_error (perror, EDC_ERROR (OtherError));
- break;
}
g_object_unref (comp);
@@ -2673,7 +2497,7 @@ send_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp,
}
static void
-e_cal_backend_groupwise_send_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GList **users,
+e_cal_backend_groupwise_send_objects (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, GSList **users,
gchar **modified_calobj, GError **perror)
{
icalcomponent *icalcomp, *subcomp;
@@ -2689,7 +2513,7 @@ e_cal_backend_groupwise_send_objects (ECalBackendSync *backend, EDataCal *cal, c
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
- if (priv->mode == CAL_MODE_LOCAL) {
+ if (!priv->is_online) {
in_offline (cbgw);
g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
return;
@@ -2728,7 +2552,7 @@ e_cal_backend_groupwise_send_objects (ECalBackendSync *backend, EDataCal *cal, c
if (e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp))) {
GSList *attendee_list = NULL, *tmp;
e_cal_component_get_attendee_list (comp, &attendee_list);
- /* convert this into GList */
+
for (tmp = attendee_list; tmp; tmp = g_slist_next (tmp)) {
ECalComponentAttendee *attendee = NULL;
const gchar *email_id = NULL;
@@ -2737,7 +2561,7 @@ e_cal_backend_groupwise_send_objects (ECalBackendSync *backend, EDataCal *cal, c
email_id = attendee->value;
if (!g_ascii_strncasecmp (email_id, "mailto:", 7))
email_id += 7;
- *users = g_list_append (*users, g_strdup (email_id));
+ *users = g_slist_append (*users, g_strdup (email_id));
}
}
@@ -2787,34 +2611,24 @@ e_cal_backend_groupwise_class_init (ECalBackendGroupwiseClass *class)
object_class->finalize = e_cal_backend_groupwise_finalize;
- sync_class->is_read_only_sync = e_cal_backend_groupwise_is_read_only;
- sync_class->get_cal_address_sync = e_cal_backend_groupwise_get_cal_address;
- sync_class->get_alarm_email_address_sync = e_cal_backend_groupwise_get_alarm_email_address;
- sync_class->get_ldap_attribute_sync = e_cal_backend_groupwise_get_ldap_attribute;
- sync_class->get_static_capabilities_sync = e_cal_backend_groupwise_get_static_capabilities;
- sync_class->open_sync = e_cal_backend_groupwise_open;
- sync_class->remove_sync = e_cal_backend_groupwise_remove;
- sync_class->create_object_sync = e_cal_backend_groupwise_create_object;
- sync_class->modify_object_sync = e_cal_backend_groupwise_modify_object;
- sync_class->remove_object_sync = e_cal_backend_groupwise_remove_object;
- sync_class->discard_alarm_sync = e_cal_backend_groupwise_discard_alarm;
- sync_class->receive_objects_sync = e_cal_backend_groupwise_receive_objects;
- sync_class->send_objects_sync = e_cal_backend_groupwise_send_objects;
- sync_class->get_default_object_sync = e_cal_backend_groupwise_get_default_object;
- sync_class->get_object_sync = e_cal_backend_groupwise_get_object;
- sync_class->get_object_list_sync = e_cal_backend_groupwise_get_object_list;
- sync_class->get_attachment_list_sync = e_cal_backend_groupwise_get_attachment_list;
- sync_class->add_timezone_sync = e_cal_backend_groupwise_add_timezone;
- sync_class->set_default_zone_sync = e_cal_backend_groupwise_set_default_zone;
- sync_class->get_freebusy_sync = e_cal_backend_groupwise_get_free_busy;
- sync_class->get_changes_sync = e_cal_backend_groupwise_get_changes;
-
- backend_class->is_loaded = e_cal_backend_groupwise_is_loaded;
- backend_class->start_query = e_cal_backend_groupwise_start_query;
- backend_class->get_mode = e_cal_backend_groupwise_get_mode;
- backend_class->set_mode = e_cal_backend_groupwise_set_mode;
- backend_class->internal_get_default_timezone = e_cal_backend_groupwise_internal_get_default_timezone;
- backend_class->internal_get_timezone = e_cal_backend_groupwise_internal_get_timezone;
+ sync_class->get_backend_property_sync = e_cal_backend_groupwise_get_backend_property;
+ sync_class->open_sync = e_cal_backend_groupwise_open;
+ sync_class->authenticate_user_sync = e_cal_backend_groupwise_authenticate_user;
+ sync_class->remove_sync = e_cal_backend_groupwise_remove;
+ sync_class->create_object_sync = e_cal_backend_groupwise_create_object;
+ sync_class->modify_object_sync = e_cal_backend_groupwise_modify_object;
+ sync_class->remove_object_sync = e_cal_backend_groupwise_remove_object;
+ sync_class->receive_objects_sync = e_cal_backend_groupwise_receive_objects;
+ sync_class->send_objects_sync = e_cal_backend_groupwise_send_objects;
+ sync_class->get_object_sync = e_cal_backend_groupwise_get_object;
+ sync_class->get_object_list_sync = e_cal_backend_groupwise_get_object_list;
+ sync_class->get_attachment_uris_sync = e_cal_backend_groupwise_get_attachment_uris;
+ sync_class->add_timezone_sync = e_cal_backend_groupwise_add_timezone;
+ sync_class->get_free_busy_sync = e_cal_backend_groupwise_get_free_busy;
+
+ backend_class->start_view = e_cal_backend_groupwise_start_view;
+ backend_class->set_online = e_cal_backend_groupwise_set_online;
+ backend_class->internal_get_timezone = e_cal_backend_groupwise_internal_get_timezone;
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]