[evolution-ews] Bug #674599 - Crash on contact view open
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug #674599 - Crash on contact view open
- Date: Wed, 6 Jun 2012 11:08:50 +0000 (UTC)
commit c1089c07c73215afe51d3df300ef6538b060cc4d
Author: Milan Crha <mcrha redhat com>
Date: Wed Jun 6 13:08:11 2012 +0200
Bug #674599 - Crash on contact view open
src/addressbook/e-book-backend-ews.c | 41 +++++++++++++++++++++++++++++++--
1 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index 679db3d..759dcad 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -925,6 +925,8 @@ ews_create_contact_cb (GObject *object,
/* get a list of ids from server (single item) */
e_ews_connection_create_items_finish (cnc, res, &items, &error);
+ g_return_if_fail (ebews->priv->ebsdb != NULL);
+
if (error == NULL) {
EEwsItem *item = (EEwsItem *) items->data;
@@ -1050,6 +1052,8 @@ ews_book_remove_contact_cb (GObject *object,
simple = G_SIMPLE_ASYNC_RESULT (res);
+ g_return_if_fail (priv->ebsdb != NULL);
+
if (!g_simple_async_result_propagate_error (simple, &error))
deleted = ews_book_backend_sqlitedb_remove_contacts (priv->ebsdb, priv->folder_id, remove_contact->sl_ids, &error);
@@ -1150,6 +1154,8 @@ ews_modify_contact_cb (GObject *object,
e_ews_connection_update_items_finish (cnc, res, &items, &error);
+ g_return_if_fail (priv->ebsdb != NULL);
+
if (error == NULL) {
EEwsItem *item = (EEwsItem *) items->data;
@@ -1276,6 +1282,8 @@ e_book_backend_ews_modify_contacts (EBookBackend *backend,
return;
}
+ g_return_if_fail (priv->ebsdb != NULL);
+
contact = e_contact_new_from_vcard (vcards->data);
id = g_new0 (EwsId, 1);
@@ -1355,7 +1363,7 @@ e_book_backend_ews_get_contact_list (EBookBackend *backend,
priv = ebews->priv;
if (!e_backend_get_online (E_BACKEND (backend))) {
- if (ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
+ if (priv->ebsdb && ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
list = ews_book_backend_sqlitedb_search (priv->ebsdb, priv->folder_id, query, NULL, NULL, NULL, &error);
l = list;
while (l) {
@@ -1382,7 +1390,7 @@ e_book_backend_ews_get_contact_list (EBookBackend *backend,
return;
}
- if (ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
+ if (priv->ebsdb && ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
list = ews_book_backend_sqlitedb_search (priv->ebsdb, priv->folder_id, query, NULL, NULL, NULL, &error);
l = list;
while (l) {
@@ -1646,6 +1654,9 @@ ews_gal_needs_update (EBookBackendEws *cbews,
gboolean ret = FALSE;
gchar *tmp;
+ if (!priv->ebsdb)
+ return FALSE;
+
tmp = ews_book_backend_sqlitedb_get_key_value (priv->ebsdb, priv->folder_id, "seq", error);
if (error)
goto exit;
@@ -1712,12 +1723,16 @@ ews_remove_old_gal_file (EBookBackendEws *cbews,
EBookBackendEwsPrivate *priv = cbews->priv;
gchar *filename;
+ if (!priv->ebsdb)
+ return FALSE;
+
filename = ews_book_backend_sqlitedb_get_key_value (priv->ebsdb, priv->folder_id, "oab-filename", error);
if (*error)
return FALSE;
if (filename)
g_unlink (filename);
+ g_free (filename);
return TRUE;
}
@@ -1738,6 +1753,8 @@ ews_gal_store_contact (EContact *contact,
struct _db_data *data = (struct _db_data *) user_data;
EBookBackendEwsPrivate *priv = data->cbews->priv;
+ g_return_if_fail (priv->ebsdb != NULL);
+
data->contact_collector = g_slist_prepend (data->contact_collector, g_object_ref (contact));
data->collected_length += 1;
@@ -1778,6 +1795,8 @@ ews_replace_gal_in_db (EBookBackendEws *cbews,
gboolean ret = TRUE;
struct _db_data data;
+ g_return_val_if_fail (priv->ebsdb != NULL, FALSE);
+
/* remove the old address-book and create a new one in db */
if (ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
ret = ews_book_backend_sqlitedb_delete_addressbook (priv->ebsdb, priv->folder_id, error);
@@ -1833,6 +1852,10 @@ ebews_start_gal_sync (gpointer data)
goto exit;
}
+ g_warn_if_fail (priv->ebsdb != NULL);
+ if (!priv->ebsdb)
+ goto exit;
+
full = (EwsOALDetails *) full_l->data;
/* TODO fetch differential updates if available instead of downloading the whole GAL */
if (!ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL) || ews_gal_needs_update (cbews, full, &error)) {
@@ -1910,6 +1933,8 @@ ebews_sync_deleted_items (EBookBackendEws *ebews,
priv = ebews->priv;
+ g_return_if_fail (priv->ebsdb != NULL);
+
for (l = deleted_ids; l != NULL; l = g_slist_next (l)) {
gchar *id = (gchar *) l->data;
gboolean partial_content;
@@ -1934,6 +1959,8 @@ ebews_store_contact_items (EBookBackendEws *ebews,
priv = ebews->priv;
+ g_return_if_fail (priv->ebsdb != NULL);
+
for (l = new_items; l != NULL; l = g_slist_next (l)) {
EContact *contact;
gint i, element_type;
@@ -2038,6 +2065,8 @@ ebews_store_distribution_list_items (EBookBackendEws *ebews,
GSList *l;
EContact *contact;
+ g_return_if_fail (ebews->priv->ebsdb != NULL);
+
contact = e_contact_new ();
e_contact_set (contact, E_CONTACT_UID, id->id);
e_contact_set (contact, E_CONTACT_REV, id->change_key);
@@ -2252,6 +2281,8 @@ ebews_start_sync (gpointer data)
ebews = (EBookBackendEws *) data;
priv = ebews->priv;
+ g_return_val_if_fail (priv->ebsdb != NULL, FALSE);
+
status_message = g_strdup (_("Syncing contacts..."));
e_book_backend_foreach_view (E_BOOK_BACKEND (ebews), book_view_notify_status, status_message);
g_free (status_message);
@@ -2408,6 +2439,8 @@ fetch_from_offline (EBookBackendEws *ews,
return;
}
+ g_return_if_fail (priv->ebsdb != NULL);
+
contacts = ews_book_backend_sqlitedb_search (priv->ebsdb, priv->folder_id, query, NULL, NULL, NULL, &error);
for (l = contacts; l != NULL; l = g_slist_next (l)) {
EwsSdbSearchData *s_data = (EwsSdbSearchData *) l->data;
@@ -2637,6 +2670,9 @@ e_book_backend_ews_load_source (EBookBackend *backend,
if (priv->ebsdb == NULL)
return;
+ priv->marked_for_offline = FALSE;
+ priv->is_writable = FALSE;
+
if (!priv->is_gal) {
extension_name = E_SOURCE_EXTENSION_OFFLINE;
extension = e_source_get_extension (source, extension_name);
@@ -2657,7 +2693,6 @@ e_book_backend_ews_load_source (EBookBackend *backend,
g_mkdir_with_parents (priv->attachment_dir, 0777);
priv->marked_for_offline = TRUE;
- priv->is_writable = FALSE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]