From d04a1b6e0b58d4b4e97836c936a38c1a9c8039e0 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Wed, 10 Oct 2007 02:15:17 +0000 Subject: [PATCH] 2007-10-09 Jim Evins * src/merge-evolution.c: Create address book if it does not exist. Also, be more robust about handling error conditions -- don't just assume GError has been set. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@677 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 6 ++++++ glabels2/src/merge-evolution.c | 39 +++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index e0dac140..8f80daac 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,9 @@ +2007-10-09 Jim Evins + + * src/merge-evolution.c: + Create address book if it does not exist. Also, be more robust about handling + error conditions -- don't just assume GError has been set. + 2007-10-08 Jim Evins * libglabels/template.c: diff --git a/glabels2/src/merge-evolution.c b/glabels2/src/merge-evolution.c index 78c66fc5..cf5d283e 100644 --- a/glabels2/src/merge-evolution.c +++ b/glabels2/src/merge-evolution.c @@ -267,7 +267,7 @@ gl_merge_evolution_open (glMerge *merge) gboolean status; GList *fields, *iter; EContactField *field_id; - GError *error; + GError *error = NULL; gl_debug (DEBUG_MERGE, "BEGIN"); @@ -281,15 +281,23 @@ gl_merge_evolution_open (glMerge *merge) merge_evolution->priv->book = e_book_new_system_addressbook(&error); if (!merge_evolution->priv->book) { - g_warning (_("Couldn't open addressbook: %s"), error->message); + g_warning (_("Couldn't open addressbook.")); + if (error) + { + g_warning ("e_book_new_system_addressbook: %s", error->message); + g_error_free (error); + } e_book_query_unref(query); - g_error_free (error); return; } - if (!e_book_open(merge_evolution->priv->book, TRUE, &error)) { - g_warning (_("Couldn't open addressbook: %s"), error->message); - g_error_free (error); + if (!e_book_open(merge_evolution->priv->book, FALSE, &error)) { + g_warning (_("Couldn't open addressbook.")); + if (error) + { + g_warning ("e_book_open: %s", error->message); + g_error_free (error); + } e_book_query_unref(query); g_object_unref(merge_evolution->priv->book); merge_evolution->priv->book = NULL; @@ -297,11 +305,14 @@ gl_merge_evolution_open (glMerge *merge) } /* fetch the list of fields supported by this address book */ - status = e_book_get_supported_fields(merge_evolution->priv->book, - &fields, &error); + status = e_book_get_supported_fields(merge_evolution->priv->book, &fields, &error); if (status == FALSE) { - g_warning (_("Couldn't list available fields: %s"), error->message); - g_error_free (error); + g_warning (_("Couldn't list available fields.")); + if (error) + { + g_warning ("e_book_get_supported_fields: %s", error->message); + g_error_free (error); + } e_book_query_unref(query); g_object_unref(merge_evolution->priv->book); merge_evolution->priv->book = NULL; @@ -332,8 +343,12 @@ gl_merge_evolution_open (glMerge *merge) &merge_evolution->priv->contacts, &error); if (status == FALSE) { - g_warning (_("Couldn't get contacts: %s"), error->message); - g_error_free (error); + g_warning (_("Couldn't get contacts.")); + if (error) + { + g_warning ("e_book_get_contacts: %s", error->message); + g_error_free (error); + } e_book_query_unref(query); free_field_list(merge_evolution->priv->fields); g_object_unref(merge_evolution->priv->book); -- 2.39.5