aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2003-02-07 15:14:34 +0800
committerChris Toshok <toshok@src.gnome.org>2003-02-07 15:14:34 +0800
commitaeec7106f7a3d6d1e4479c2ec596a506c4c281fa (patch)
tree1e84b323a01d8a2e88ca09d841d187643a564a85 /addressbook/backend
parentfe77d02dd0637587aa417a329914feb37508a1ef (diff)
downloadgsoc2013-evolution-aeec7106f7a3d6d1e4479c2ec596a506c4c281fa.tar
gsoc2013-evolution-aeec7106f7a3d6d1e4479c2ec596a506c4c281fa.tar.gz
gsoc2013-evolution-aeec7106f7a3d6d1e4479c2ec596a506c4c281fa.tar.bz2
gsoc2013-evolution-aeec7106f7a3d6d1e4479c2ec596a506c4c281fa.tar.lz
gsoc2013-evolution-aeec7106f7a3d6d1e4479c2ec596a506c4c281fa.tar.xz
gsoc2013-evolution-aeec7106f7a3d6d1e4479c2ec596a506c4c281fa.tar.zst
gsoc2013-evolution-aeec7106f7a3d6d1e4479c2ec596a506c4c281fa.zip
check the status, not the book, and unref the book here.
2003-02-06 Chris Toshok <toshok@ximian.com> * gui/component/e-address-popup.c (email_table_save_card_cb): check the status, not the book, and unref the book here. (contact_editor_cb): same. (start_query): unref the book in the failure case. (add_card_idle_cb): addressbook_load_default_book returns void now. (edit_contact_info_cb): same. (e_address_popup_query): same. * gui/component/addressbook.c (control_activate_cb): track change to addressbook_load_uri return type. (set_prop): same. (addressbook_load_uri): return type is void now. (addressbook_load_default_book): same. * gui/component/addressbook.h: addressbook_load_uri/addressbook_load_default_book return void now. * conduit/address-conduit.c (start_addressbook_server): e_book_load_default_book returns void now. * backend/ebook/e-book-util.h: track changes to return types. * backend/ebook/e-book-util.c (e_book_load_address_book_by_uri): fallout from change to e_book_load_uri. return type for this function is void now too. (e_book_use_address_book_by_uri): same. (e_book_use_default_book): same. (e_book_load_default_book): same. (got_uri_book_cb): if unsuccessful and book is non-NULL, unref it here. (got_default_book_cb): same. * backend/ebook/e-book.c (e_book_load_uri): no longer return a gboolean. any error is communicated to the callback. * backend/ebook/e-book.h: e_book_load_uri no longer returns a gboolean (it's void.) * backend/ebook/evolution-ldif-importer.c (ebook_create): track change to the e_book_load_uri family of functions. * backend/ebook/test-client-list.c (ebook_create): same. * backend/ebook/test-client.c (ebook_create): same. * backend/ebook/load-pine-addressbook.c (ebook_create): same. * backend/ebook/evolution-vcard-importer.c (ebook_create): same. svn path=/trunk/; revision=19839
Diffstat (limited to 'addressbook/backend')
-rw-r--r--addressbook/backend/ebook/e-book-util.c50
-rw-r--r--addressbook/backend/ebook/e-book-util.h4
-rw-r--r--addressbook/backend/ebook/e-book.c23
-rw-r--r--addressbook/backend/ebook/e-book.h2
-rw-r--r--addressbook/backend/ebook/evolution-ldif-importer.c8
-rw-r--r--addressbook/backend/ebook/evolution-vcard-importer.c8
-rw-r--r--addressbook/backend/ebook/load-gnomecard-addressbook.c4
-rw-r--r--addressbook/backend/ebook/load-pine-addressbook.c4
-rw-r--r--addressbook/backend/ebook/test-client-list.c5
-rw-r--r--addressbook/backend/ebook/test-client.c5
10 files changed, 38 insertions, 75 deletions
diff --git a/addressbook/backend/ebook/e-book-util.c b/addressbook/backend/ebook/e-book-util.c
index aaba56f8dc..40ec0fb446 100644
--- a/addressbook/backend/ebook/e-book-util.c
+++ b/addressbook/backend/ebook/e-book-util.c
@@ -73,32 +73,27 @@ got_uri_book_cb (EBook *book, EBookStatus status, gpointer closure)
if (status == E_BOOK_STATUS_SUCCESS) {
info->cb (book, info->closure);
} else {
+ if (book)
+ g_object_unref (book);
info->cb (NULL, info->closure);
}
g_free (info);
}
-gboolean
+void
e_book_load_address_book_by_uri (EBook *book, const char *uri, EBookCallback open_response, gpointer closure)
{
- gboolean rv;
char *real_uri;
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (open_response != NULL, FALSE);
+ g_return_if_fail (book != NULL);
+ g_return_if_fail (E_IS_BOOK (book));
+ g_return_if_fail (open_response != NULL);
real_uri = e_book_expand_uri (uri);
- rv = e_book_load_uri (book, real_uri, open_response, closure);
-
- if (!rv) {
- g_warning ("Couldn't load addressbook %s", real_uri);
- }
+ e_book_load_uri (book, real_uri, open_response, closure);
g_free (real_uri);
-
- return rv;
}
void
@@ -114,10 +109,7 @@ e_book_use_address_book_by_uri (const char *uri, EBookCommonCallback cb, gpointe
info->closure = closure;
book = e_book_new ();
- if (! e_book_load_address_book_by_uri (book, uri, got_uri_book_cb, info)) {
- g_object_unref (book);
- g_free (info);
- }
+ e_book_load_address_book_by_uri (book, uri, got_uri_book_cb, info);
}
EConfigListener *
@@ -155,7 +147,8 @@ got_default_book_cb (EBook *book, EBookStatus status, gpointer closure)
}
} else {
-
+ if (book)
+ g_object_unref (book);
info->cb (NULL, info->closure);
}
@@ -180,10 +173,7 @@ e_book_use_default_book (EBookCommonCallback cb, gpointer closure)
info->closure = closure;
book = e_book_new ();
- if (! e_book_load_default_book (book, got_default_book_cb, info)) {
- g_object_unref (book);
- g_free (info);
- }
+ e_book_load_default_book (book, got_default_book_cb, info);
}
static char *default_book_uri;
@@ -272,16 +262,15 @@ e_book_default_book_open (EBook *book, EBookStatus status, gpointer closure)
}
}
-gboolean
+void
e_book_load_default_book (EBook *book, EBookCallback open_response, gpointer closure)
{
char *uri;
- gboolean rv;
DefaultBookClosure *default_book_closure;
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (open_response != NULL, FALSE);
+ g_return_if_fail (book != NULL);
+ g_return_if_fail (E_IS_BOOK (book));
+ g_return_if_fail (open_response != NULL);
uri = e_book_get_default_book_uri ();
@@ -290,14 +279,9 @@ e_book_load_default_book (EBook *book, EBookCallback open_response, gpointer clo
default_book_closure->closure = closure;
default_book_closure->open_response = open_response;
- rv = e_book_load_uri (book, uri,
- e_book_default_book_open, default_book_closure);
-
- if (!rv) {
- g_warning ("Couldn't load default addressbook");
- }
+ e_book_load_uri (book, uri,
+ e_book_default_book_open, default_book_closure);
- return rv;
}
char*
diff --git a/addressbook/backend/ebook/e-book-util.h b/addressbook/backend/ebook/e-book-util.h
index 3ebea41ef0..3ea59df8aa 100644
--- a/addressbook/backend/ebook/e-book-util.h
+++ b/addressbook/backend/ebook/e-book-util.h
@@ -42,7 +42,7 @@ typedef void (*EBookHaveAddressCallback) (EBook *book, const gchar *addr, ECard
/* expand file:///foo/foo/ to file:///foo/foo/addressbook.db */
char *e_book_expand_uri (const char *uri);
-gboolean e_book_load_address_book_by_uri (EBook *book,
+void e_book_load_address_book_by_uri (EBook *book,
const char *uri,
EBookCallback open_response,
gpointer closure);
@@ -52,7 +52,7 @@ void e_book_use_address_book_by_uri (const char
void e_book_use_default_book (EBookCommonCallback cb,
gpointer closure);
-gboolean e_book_load_default_book (EBook *book,
+void e_book_load_default_book (EBook *book,
EBookCallback open_response,
gpointer closure);
char *e_book_get_default_book_uri (void);
diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c
index 195418d29b..fff07bcfb9 100644
--- a/addressbook/backend/ebook/e-book.c
+++ b/addressbook/backend/ebook/e-book.c
@@ -729,7 +729,7 @@ activate_factories_for_uri (EBook *book, const char *uri)
return retval;
}
-gboolean
+void
e_book_load_uri (EBook *book,
const char *uri,
EBookCallback open_response,
@@ -738,21 +738,21 @@ e_book_load_uri (EBook *book,
EBookLoadURIData *load_uri_data;
GNOME_Evolution_Addressbook_BookFactory factory;
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (uri != NULL, FALSE);
- g_return_val_if_fail (open_response != NULL, FALSE);
+ g_return_if_fail (book != NULL);
+ g_return_if_fail (E_IS_BOOK (book));
+ g_return_if_fail (uri != NULL);
+ g_return_if_fail (open_response != NULL);
if (book->priv->load_state != URINotLoaded) {
g_warning ("e_book_load_uri: Attempted to load a URI "
"on a book which already has a URI loaded!\n");
- return FALSE;
+ open_response (book, E_BOOK_STATUS_OTHER_ERROR, closure); /* XXX need a new status code here */
+ return;
}
/* try to find a list of factories that can handle the protocol */
if (!activate_factories_for_uri (book, uri)) {
- open_response (NULL, E_BOOK_STATUS_PROTOCOL_NOT_SUPPORTED, closure);
- return FALSE;
+ open_response (book, E_BOOK_STATUS_PROTOCOL_NOT_SUPPORTED, closure);
}
g_free (book->priv->uri);
@@ -764,7 +764,8 @@ e_book_load_uri (EBook *book,
book->priv->listener = e_book_listener_new ();
if (book->priv->listener == NULL) {
g_warning ("e_book_load_uri: Could not create EBookListener!\n");
- return FALSE;
+ open_response (NULL, E_BOOK_STATUS_OTHER_ERROR, closure); /* XXX need a new status code here */
+ return;
}
g_signal_connect (book->priv->listener, "responses_queued",
@@ -782,10 +783,6 @@ e_book_load_uri (EBook *book,
e_book_load_uri_from_factory (book, factory, load_uri_data);
book->priv->load_state = URILoading;
-
- /* Now we play the waiting game. */
-
- return TRUE;
}
/**
diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h
index bbc49b711c..bee3a24907 100644
--- a/addressbook/backend/ebook/e-book.h
+++ b/addressbook/backend/ebook/e-book.h
@@ -65,7 +65,7 @@ typedef void (*EBookAuthMethodsCallback) (EBook *book, EBookStatus status, EList
/* Creating a new addressbook. */
EBook *e_book_new (void);
-gboolean e_book_load_uri (EBook *book,
+void e_book_load_uri (EBook *book,
const char *uri,
EBookCallback open_response,
gpointer closure);
diff --git a/addressbook/backend/ebook/evolution-ldif-importer.c b/addressbook/backend/ebook/evolution-ldif-importer.c
index d64a9a0c40..0ab8e872af 100644
--- a/addressbook/backend/ebook/evolution-ldif-importer.c
+++ b/addressbook/backend/ebook/evolution-ldif-importer.c
@@ -470,15 +470,11 @@ ebook_create (LDIFImporter *gci)
uri = g_strdup_printf ("file://%s", path);
g_free (path);
- if (! e_book_load_uri (gci->book, uri, book_open_cb, gci)) {
- printf ("error calling load_uri!\n");
- }
+ e_book_load_uri (gci->book, uri, book_open_cb, gci);
g_free(uri);
#endif
- if (! e_book_load_default_book (gci->book, book_open_cb, gci)) {
- g_warning ("Error calling load_default_book");
- }
+ e_book_load_default_book (gci->book, book_open_cb, gci);
}
/* EvolutionImporter methods */
diff --git a/addressbook/backend/ebook/evolution-vcard-importer.c b/addressbook/backend/ebook/evolution-vcard-importer.c
index c16fab4019..51f29f1278 100644
--- a/addressbook/backend/ebook/evolution-vcard-importer.c
+++ b/addressbook/backend/ebook/evolution-vcard-importer.c
@@ -70,15 +70,11 @@ ebook_create (VCardImporter *gci)
uri = g_strdup_printf ("%s/addressbook.db", epath);
g_free (epath);
- if (! e_book_load_uri (gci->book, uri, book_open_cb, gci)) {
- printf ("error calling load_uri!\n");
- }
+ e_book_load_uri (gci->book, uri, book_open_cb, gci);
g_free(uri);
#endif
- if (! e_book_load_default_book (gci->book, book_open_cb, gci)) {
- g_warning ("Error calling load_default_book");
- }
+ e_book_load_default_book (gci->book, book_open_cb, gci);
}
/* EvolutionImporter methods */
diff --git a/addressbook/backend/ebook/load-gnomecard-addressbook.c b/addressbook/backend/ebook/load-gnomecard-addressbook.c
index 30f4f5a5f2..b0478f3c9b 100644
--- a/addressbook/backend/ebook/load-gnomecard-addressbook.c
+++ b/addressbook/backend/ebook/load-gnomecard-addressbook.c
@@ -53,9 +53,7 @@ ebook_create (gpointer data)
uri = g_strdup_printf ("file://%s", path);
g_free (path);
- if (! e_book_load_uri (book, uri, book_open_cb, NULL)) {
- printf ("error calling load_uri!\n");
- }
+ e_book_load_uri (book, uri, book_open_cb, NULL);
g_free(uri);
diff --git a/addressbook/backend/ebook/load-pine-addressbook.c b/addressbook/backend/ebook/load-pine-addressbook.c
index 9dc495badf..7203c8160d 100644
--- a/addressbook/backend/ebook/load-pine-addressbook.c
+++ b/addressbook/backend/ebook/load-pine-addressbook.c
@@ -110,9 +110,7 @@ ebook_create (gpointer data)
uri = g_strdup_printf ("file://%s", path);
g_free (path);
- if (! e_book_load_uri (book, uri, book_open_cb, NULL)) {
- printf ("error calling load_uri!\n");
- }
+ e_book_load_uri (book, uri, book_open_cb, NULL);
g_free(uri);
diff --git a/addressbook/backend/ebook/test-client-list.c b/addressbook/backend/ebook/test-client-list.c
index 271d9fc3bf..6fa3d6b094 100644
--- a/addressbook/backend/ebook/test-client-list.c
+++ b/addressbook/backend/ebook/test-client-list.c
@@ -45,10 +45,7 @@ ebook_create (gpointer data)
book = e_book_new ();
- if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) {
- printf ("error calling load_uri!\n");
- }
-
+ e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL);
return FALSE;
}
diff --git a/addressbook/backend/ebook/test-client.c b/addressbook/backend/ebook/test-client.c
index bd11d93691..59419c3d36 100644
--- a/addressbook/backend/ebook/test-client.c
+++ b/addressbook/backend/ebook/test-client.c
@@ -137,10 +137,7 @@ ebook_create (gpointer data)
}
- if (! e_book_load_default_book (book, book_open_cb, NULL)) {
- printf ("error calling load_uri!\n");
- }
-
+ e_book_load_default_book (book, book_open_cb, NULL);
return FALSE;
}