[evolution-data-server/account-mgmt: 8/33] Adapt libebook to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/account-mgmt: 8/33] Adapt libebook to the new ESource API.
- Date: Wed, 7 Sep 2011 16:07:46 +0000 (UTC)
commit ad12ae6f320a6b5f9d966df583e4e28eef6b72e9
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Nov 12 15:46:18 2010 -0500
Adapt libebook to the new ESource API.
addressbook/libebook/e-book-client.c | 244 +-----------
addressbook/libebook/e-book-client.h | 9 -
addressbook/libebook/e-book.c | 431 ++------------------
addressbook/libebook/e-book.h | 4 -
addressbook/libebook/e-destination.c | 4 +-
.../addressbook/libebook/libebook-sections.txt | 12 -
.../addressbook/libebook/tmpl/e-book-client.sgml | 58 ---
.../addressbook/libebook/tmpl/e-book.sgml | 51 ---
.../addressbook/libebook/tmpl/libebook-unused.sgml | 98 +++++
tests/libebook/client/client-test-utils.c | 77 ++---
tests/libebook/client/test-client-async.c | 4 +
tests/libebook/client/test-client-examine.c | 23 +-
.../test-client-stress-factory--single-book.c | 4 +
tests/libebook/client/test-client-stress-views.c | 4 +
tests/libebook/ebook-test-utils.c | 222 +++++------
tests/libebook/ebook-test-utils.h | 7 -
tests/libebook/test-changes.c | 1 -
tests/libebook/test-ebook-add-contact.c | 3 -
tests/libebook/test-ebook-commit-contact.c | 3 -
tests/libebook/test-ebook-get-book-view.c | 6 +-
tests/libebook/test-ebook-get-contact.c | 2 -
tests/libebook/test-ebook-get-required-fields.c | 2 -
.../libebook/test-ebook-get-static-capabilities.c | 2 -
.../test-ebook-get-supported-auth-methods.c | 2 -
tests/libebook/test-ebook-get-supported-fields.c | 2 -
tests/libebook/test-ebook-remove-contact-by-id.c | 1 -
tests/libebook/test-ebook-remove-contact.c | 4 +-
tests/libebook/test-ebook-remove-contacts.c | 10 +-
tests/libebook/test-ebook-remove.c | 1 -
tests/libebook/test-ebook-stress-factory--fifo.c | 4 -
tests/libebook/test-ebook-stress-factory--serial.c | 1 -
.../test-ebook-stress-factory--single-book.c | 3 -
tests/libebook/test-nonexistent-id.c | 1 +
33 files changed, 294 insertions(+), 1006 deletions(-)
---
diff --git a/addressbook/libebook/e-book-client.c b/addressbook/libebook/e-book-client.c
index af19914..7f2ce26 100644
--- a/addressbook/libebook/e-book-client.c
+++ b/addressbook/libebook/e-book-client.c
@@ -26,8 +26,11 @@
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
+#include <gconf/gconf-client.h>
+
#include "libedataserver/e-data-server-util.h"
#include "libedataserver/e-client-private.h"
+#include "libedataserver/e-source-registry.h"
#include "e-book-client.h"
#include "e-contact.h"
@@ -473,7 +476,7 @@ e_book_client_new (ESource *source,
EBookClient *client;
GError *err = NULL;
GDBusConnection *connection;
- gchar *xml, *gdbus_xml = NULL;
+ const gchar *uid;
gchar *path = NULL;
g_return_val_if_fail (source != NULL, NULL);
@@ -494,21 +497,13 @@ e_book_client_new (ESource *source,
return NULL;
}
- xml = e_source_to_standalone_xml (source);
- if (!xml || !*xml) {
- UNLOCK_FACTORY ();
- g_free (xml);
- g_set_error_literal (error, E_CLIENT_ERROR, E_CLIENT_ERROR_INVALID_ARG, _("Invalid source"));
- return NULL;
- }
+ uid = e_source_get_uid (source);
client = g_object_new (E_TYPE_BOOK_CLIENT, "source", source, NULL);
UNLOCK_FACTORY ();
- if (!e_gdbus_book_factory_call_get_book_sync (G_DBUS_PROXY (book_factory_proxy), e_util_ensure_gdbus_string (xml, &gdbus_xml), &path, NULL, &err)) {
+ if (!e_gdbus_book_factory_call_get_book_sync (G_DBUS_PROXY (book_factory_proxy), uid, &path, NULL, &err)) {
unwrap_dbus_error (err, &err);
- g_free (xml);
- g_free (gdbus_xml);
g_warning ("%s: Cannot get book from factory: %s", G_STRFUNC, err ? err->message : "[no error]");
if (err)
g_propagate_error (error, err);
@@ -517,9 +512,6 @@ e_book_client_new (ESource *source,
return NULL;
}
- g_free (xml);
- g_free (gdbus_xml);
-
client->priv->gdbus_book = G_DBUS_PROXY (e_gdbus_book_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (book_factory_proxy)),
G_DBUS_PROXY_FLAGS_NONE,
ADDRESS_BOOK_DBUS_SERVICE_NAME,
@@ -563,224 +555,6 @@ e_book_client_new (ESource *source,
return client;
}
-/**
- * e_book_client_new_from_uri:
- * @uri: the URI to load
- * @error: A #GError pointer
- *
- * Creates a new #EBookClient corresponding to the given uri. See the
- * documentation for e_book_client_new() for further information.
- *
- * Returns: a new but unopened #EBookClient.
- *
- * Since: 3.2
- **/
-EBookClient *
-e_book_client_new_from_uri (const gchar *uri,
- GError **error)
-{
- ESourceList *source_list = NULL;
- ESource *source;
- EBookClient *client;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- if (!e_book_client_get_sources (&source_list, error))
- return NULL;
-
- source = e_client_util_get_source_for_uri (source_list, uri);
- if (!source && g_str_has_prefix (uri, "file://")) {
- gchar *local_uri;
-
- local_uri = g_strconcat ("local://", uri + 7, NULL);
- source = e_client_util_get_source_for_uri (source_list, uri);
-
- g_free (local_uri);
- }
-
- if (!source) {
- g_object_unref (source_list);
- g_set_error (error, E_CLIENT_ERROR, E_CLIENT_ERROR_INVALID_ARG, _("Incorrect uri '%s'"), uri);
-
- return NULL;
- }
-
- client = e_book_client_new (source, error);
-
- g_object_unref (source);
- g_object_unref (source_list);
-
- return client;
-}
-
-/**
- * e_book_client_new_system:
- * @error: A #GError pointer
- *
- * Creates a new #EBookClient corresponding to the user's system
- * addressbook. See the documentation for e_book_client_new() for further
- * information.
- *
- * Returns: a new but unopened #EBookClient.
- *
- * Since: 3.2
- **/
-EBookClient *
-e_book_client_new_system (GError **error)
-{
- ESourceList *source_list = NULL;
- ESource *source;
- EBookClient *client;
-
- if (!e_book_client_get_sources (&source_list, error))
- return NULL;
-
- source = e_client_util_get_system_source (source_list);
- if (!source) {
- g_object_unref (source_list);
- g_set_error_literal (error, E_BOOK_CLIENT_ERROR, E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE, _("Failed to find system book"));
-
- return NULL;
- }
-
- client = e_book_client_new (source, error);
-
- g_object_unref (source);
- g_object_unref (source_list);
-
- return client;
-}
-
-/**
- * e_book_client_new_default:
- * @error: return location for a #GError, or %NULL
- *
- * Creates a new #EBookClient corresponding to the user's default
- * address book. See the documentation for e_book_client_new() for
- * further information.
- *
- * Returns: a new but unopened #EBookClient
- *
- * Since: 3.2
- **/
-EBookClient *
-e_book_client_new_default (GError **error)
-{
- ESourceList *source_list = NULL;
- ESource *source;
- EBookClient *client;
-
- if (!e_book_client_get_sources (&source_list, error))
- return NULL;
-
- source = e_source_list_peek_default_source (source_list);
- if (!source) {
- g_set_error_literal (error, E_BOOK_CLIENT_ERROR, E_BOOK_CLIENT_ERROR_NO_SUCH_BOOK, _("Address book does not exist"));
- g_object_unref (source_list);
-
- return NULL;
- }
-
- client = e_book_client_new (source, error);
-
- g_object_unref (source_list);
-
- return client;
-}
-
-/**
- * e_book_client_set_default:
- * @client: An #EBookClient pointer
- * @error: A #GError pointer
- *
- * Sets the #ESource of the #EBookClient as the "default" addressbook. This is the source
- * that will be loaded in the e_book_client_get_default_addressbook() call.
- *
- * Returns: %TRUE if the setting was stored in libebook's ESourceList, otherwise %FALSE.
- *
- * Since: 3.2
- **/
-gboolean
-e_book_client_set_default (EBookClient *client,
- GError **error)
-{
- ESource *source;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK_CLIENT (client), FALSE);
- g_return_val_if_fail (client->priv != NULL, FALSE);
-
- source = e_client_get_source (E_CLIENT (client));
- g_return_val_if_fail (source != NULL, FALSE);
-
- return e_book_client_set_default_source (source, error);
-}
-
-/**
- * e_book_client_set_default_source:
- * @source: An #ESource pointer
- * @error: A #GError pointer
- *
- * Sets @source as the "default" addressbook. This is the source that
- * will be loaded in the e_book_client_get_default_addressbook() call.
- *
- * Returns: %TRUE if the setting was stored in libebook's ESourceList, otherwise %FALSE.
- *
- * Since: 3.2
- **/
-gboolean
-e_book_client_set_default_source (ESource *source,
- GError **error)
-{
- ESourceList *source_list = NULL;
- gboolean res = FALSE;
-
- g_return_val_if_fail (source != NULL, FALSE);
- g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
-
- if (!e_book_client_get_sources (&source_list, error))
- return FALSE;
-
- res = e_client_util_set_default (source_list, source);
-
- if (res)
- res = e_source_list_sync (source_list, error);
- else
- g_set_error (error, E_CLIENT_ERROR, E_CLIENT_ERROR_INVALID_ARG,
- _("There was no source for UID '%s' stored in a source list."), e_source_peek_uid (source));
-
- g_object_unref (source_list);
-
- return res;
-}
-
-/**
- * e_book_client_get_sources:
- * @sources: (out): A pointer to an #ESourceList to set
- * @error: A pointer to a GError to set on error
- *
- * Populate @*sources with the list of all sources which have been
- * added to Evolution.
- *
- * Returns: %TRUE if @sources was set, otherwise %FALSE.
- *
- * Since: 3.2
- **/
-gboolean
-e_book_client_get_sources (ESourceList **sources,
- GError **error)
-{
- GConfClient *gconf;
-
- g_return_val_if_fail (sources != NULL, FALSE);
-
- gconf = gconf_client_get_default ();
- *sources = e_source_list_new_for_gconf (gconf, "/apps/evolution/addressbook/sources");
- g_object_unref (gconf);
-
- return TRUE;
-}
-
#define SELF_UID_KEY "/apps/evolution/addressbook/self/self_uid"
static EContact *
@@ -838,6 +612,8 @@ e_book_client_get_self (EContact **contact,
EBookClient **client,
GError **error)
{
+ ESourceRegistry *registry;
+ ESource *source;
GError *local_error = NULL;
GConfClient *gconf;
gchar *uid;
@@ -845,7 +621,9 @@ e_book_client_get_self (EContact **contact,
g_return_val_if_fail (contact != NULL, FALSE);
g_return_val_if_fail (client != NULL, FALSE);
- *client = e_book_client_new_system (&local_error);
+ registry = e_source_registry_get_default ();
+ source = e_source_registry_lookup_by_uid (registry, "system");
+ *client = e_book_client_new (source, &local_error);
if (!*client) {
g_propagate_error (error, local_error);
return FALSE;
diff --git a/addressbook/libebook/e-book-client.h b/addressbook/libebook/e-book-client.h
index 1435ce8..00ce486 100644
--- a/addressbook/libebook/e-book-client.h
+++ b/addressbook/libebook/e-book-client.h
@@ -25,7 +25,6 @@
#include <gio/gio.h>
#include <libedataserver/e-client.h>
-#include <libedataserver/e-source-list.h>
#include <libebook/e-book-client-view.h>
#include <libebook/e-contact.h>
@@ -121,14 +120,6 @@ GType e_book_client_get_type (void);
/* Creating a new addressbook */
EBookClient * e_book_client_new (ESource *source, GError **error);
-EBookClient * e_book_client_new_from_uri (const gchar *uri, GError **error);
-EBookClient * e_book_client_new_system (GError **error);
-EBookClient * e_book_client_new_default (GError **error);
-
-/* Addressbook discovery */
-gboolean e_book_client_set_default (EBookClient *client, GError **error);
-gboolean e_book_client_set_default_source (ESource *source, GError **error);
-gboolean e_book_client_get_sources (ESourceList **sources, GError **error);
/* Identity */
gboolean e_book_client_get_self (EContact **contact, EBookClient **client, GError **error);
diff --git a/addressbook/libebook/e-book.c b/addressbook/libebook/e-book.c
index 18271af..0ec300f 100644
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@ -39,6 +39,7 @@
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
+#include <libedataserver/e-source-registry.h>
#include <libedataserver/e-data-server-util.h>
#include "e-book.h"
#include "e-error.h"
@@ -79,7 +80,6 @@ struct _EBookPrivate {
guint gone_signal_id;
ESource *source;
- gchar *uri;
gboolean loaded;
gboolean writable;
gboolean connected;
@@ -199,9 +199,6 @@ e_book_finalize (GObject *object)
{
EBook *book = E_BOOK (object);
- if (book->priv->uri)
- g_free (book->priv->uri);
-
if (book->priv->cap)
g_free (book->priv->cap);
@@ -277,7 +274,6 @@ e_book_init (EBook *book)
book->priv->gdbus_book = NULL;
book->priv->source = NULL;
- book->priv->uri = NULL;
book->priv->loaded = FALSE;
book->priv->writable = FALSE;
book->priv->connected = FALSE;
@@ -1180,14 +1176,13 @@ e_book_get_supported_auth_methods_async (EBook *book,
/**
* e_book_authenticate_user:
* @book: an #EBook
- * @user: a string
+ * @user: a string (no longer used)
* @passwd: a string
- * @auth_method: a string
+ * @auth_method: a string (no longer used)
* @error: a #GError to set on failure
*
- * Authenticates @user with @passwd, using the auth method
- * @auth_method. @auth_method must be one of the authentication
- * methods returned using e_book_get_supported_auth_methods.
+ * Authenticates @book with @passwd. The @user and @auth_method arguments
+ * are no longer used -- you can safely pass %NULL for these.
*
* Returns: %TRUE if successful, %FALSE otherwise
*
@@ -1210,9 +1205,7 @@ e_book_authenticate_user (EBook *book,
book->priv->gdbus_book, E_BOOK_ERROR_REPOSITORY_OFFLINE);
credentials = e_credentials_new_args (
- E_CREDENTIALS_KEY_USERNAME, user,
E_CREDENTIALS_KEY_PASSWORD, passwd,
- E_CREDENTIALS_KEY_AUTH_METHOD, auth_method,
NULL);
credentials_strv = e_credentials_to_strv (credentials);
@@ -1254,15 +1247,15 @@ authenticate_user_reply (GObject *gdbus_book,
/**
* e_book_async_authenticate_user:
* @book: an #EBook
- * @user: user name
+ * @user: user name (no longer used)
* @passwd: password
- * @auth_method: string indicating authentication method
+ * @auth_method: string indicating authentication method (no longer used)
* @cb: (scope async): function to call when the operation finishes
* @closure: data to pass to callback function
*
- * Authenticate @user with @passwd, using the auth method
- * @auth_method. @auth_method must be one of the authentication
- * methods returned using e_book_get_supported_auth_methods.
+ * Authenticate @book with @passwd. The @user and @auth_method arguments
+ * are no longer used -- you can safely pass %NULL for these.
+ *
* This function does not block.
*
* Returns: %FALSE if successful, %TRUE otherwise.
@@ -1295,9 +1288,7 @@ e_book_async_authenticate_user (EBook *book,
data->closure = closure;
credentials = e_credentials_new_args (
- E_CREDENTIALS_KEY_USERNAME, user,
E_CREDENTIALS_KEY_PASSWORD, passwd,
- E_CREDENTIALS_KEY_AUTH_METHOD, auth_method,
NULL);
credentials_strv = e_credentials_to_strv (credentials);
@@ -1313,15 +1304,15 @@ e_book_async_authenticate_user (EBook *book,
/**
* e_book_authenticate_user_async:
* @book: an #EBook
- * @user: user name
+ * @user: user name (no longer used)
* @passwd: password
- * @auth_method: string indicating authentication method
+ * @auth_method: string indicating authentication method (no longer used)
* @cb: (scope async): function to call when the operation finishes
* @closure: data to pass to callback function
*
- * Authenticate @user with @passwd, using the auth method
- * @auth_method. @auth_method must be one of the authentication
- * methods returned using e_book_get_supported_auth_methods.
+ * Authenticate @book with @passwd. The @user and @auth_method arguments
+ * are no longer used -- you can safely pass %NULL for these.
+ *
* This function does not block.
*
* Returns: %FALSE if successful, %TRUE otherwise.
@@ -1356,9 +1347,7 @@ e_book_authenticate_user_async (EBook *book,
data->closure = closure;
credentials = e_credentials_new_args (
- E_CREDENTIALS_KEY_USERNAME, user,
E_CREDENTIALS_KEY_PASSWORD, passwd,
- E_CREDENTIALS_KEY_AUTH_METHOD, auth_method,
NULL);
credentials_strv = e_credentials_to_strv (credentials);
@@ -2827,24 +2816,6 @@ e_book_remove_async (EBook *book,
}
/**
- * e_book_get_uri:
- * @book: an #EBook
- *
- * Get the URI that this book has loaded. This string should not be freed.
- *
- * Returns: The URI.
- *
- * Deprecated: 3.2: Use e_client_get_uri() on an #EBookClient object instead.
- */
-const gchar *
-e_book_get_uri (EBook *book)
-{
- g_return_val_if_fail (E_IS_BOOK (book), NULL);
-
- return book->priv->uri;
-}
-
-/**
* e_book_get_source:
* @book: an #EBook
*
@@ -3186,10 +3157,12 @@ e_book_set_default_addressbook (EBook *book,
* @source: an #ESource
* @error: return location for a #GError, or %NULL
*
- * Sets @source as the default address book. This is the source that
- * will be loaded in the e_book_get_default_addressbook call.
+ * Sets @source as the default address book.
*
- * Returns: %TRUE if the setting was stored in libebook's ESourceList, otherwise %FALSE.
+ * The @error parameter is only for backward-compatibility.
+ * This function never fails, so you can safely pass %NULL.
+ *
+ * Returns: %TRUE always
*
* Deprecated: 3.2: Use e_book_client_set_default_source() instead.
*/
@@ -3197,81 +3170,12 @@ gboolean
e_book_set_default_source (ESource *source,
GError **error)
{
- ESourceList *sources;
- const gchar *uid;
- GError *err = NULL;
- GSList *g;
+ ESourceRegistry *registry;
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
- uid = e_source_peek_uid (source);
-
- if (!e_book_get_addressbooks (&sources, &err)) {
- if (error)
- g_propagate_error (error, err);
- return FALSE;
- }
-
- /* make sure the source is actually in the ESourceList. if
- * it's not we don't bother adding it, just return an error */
- source = e_source_list_peek_source_by_uid (sources, uid);
- if (!source) {
- g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_NO_SUCH_SOURCE,
- _("%s: there was no source for UID '%s' stored in GConf."), "e_book_set_default_source", uid);
- g_object_unref (sources);
- return FALSE;
- }
-
- /* loop over all the sources clearing out any "default"
- * properties we find */
- for (g = e_source_list_peek_groups (sources); g; g = g->next) {
- GSList *s;
- for (s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data));
- s; s = s->next) {
- e_source_set_property (E_SOURCE (s->data), "default", NULL);
- }
- }
-
- /* set the "default" property on the source */
- e_source_set_property (source, "default", "true");
-
- if (!e_source_list_sync (sources, &err)) {
- if (error)
- g_propagate_error (error, err);
-
- g_object_unref (sources);
-
- return FALSE;
- }
-
- g_object_unref (sources);
-
- return TRUE;
-}
-
-/**
- * e_book_get_addressbooks:
- * @addressbook_sources: (out): A pointer to a #ESourceList to set
- * @error: A pointer to a GError to set on error
- *
- * Populate *addressbook_sources with the list of all sources which have been
- * added to Evolution.
- *
- * Returns: %TRUE if @addressbook_sources was set, otherwise %FALSE.
- *
- * Deprecated: 3.2: Use e_book_client_get_sources() instead.
- */
-gboolean
-e_book_get_addressbooks (ESourceList **addressbook_sources,
- GError **error)
-{
- GConfClient *gconf;
-
- g_return_val_if_fail (addressbook_sources != NULL, FALSE);
-
- gconf = gconf_client_get_default ();
- *addressbook_sources = e_source_list_new_for_gconf (gconf, "/apps/evolution/addressbook/sources");
- g_object_unref (gconf);
+ registry = e_source_registry_get_default ();
+ e_source_registry_set_default_address_book (registry, source);
return TRUE;
}
@@ -3296,7 +3200,7 @@ e_book_new (ESource *source,
GError *err = NULL;
EBook *book;
gchar *path = NULL;
- gchar *xml, *gdbus_xml = NULL;
+ const gchar *uid;
GDBusConnection *connection;
g_return_val_if_fail (E_IS_SOURCE (source), NULL);
@@ -3312,14 +3216,11 @@ e_book_new (ESource *source,
book = g_object_new (E_TYPE_BOOK, NULL);
book->priv->source = g_object_ref (source);
- book->priv->uri = e_source_get_uri (source);
- xml = e_source_to_standalone_xml (source);
+ uid = e_source_get_uid (source);
- if (!e_gdbus_book_factory_call_get_book_sync (G_DBUS_PROXY (book_factory_proxy), e_util_ensure_gdbus_string (xml, &gdbus_xml), &path, NULL, &err)) {
+ if (!e_gdbus_book_factory_call_get_book_sync (G_DBUS_PROXY (book_factory_proxy), uid, &path, NULL, &err)) {
unwrap_gerror (err, &err);
- g_free (xml);
- g_free (gdbus_xml);
g_warning (G_STRLOC ": cannot get book from factory: %s", err ? err->message : "[no error]");
if (err)
g_propagate_error (error, err);
@@ -3327,8 +3228,6 @@ e_book_new (ESource *source,
return NULL;
}
- g_free (xml);
- g_free (gdbus_xml);
book->priv->gdbus_book = G_DBUS_PROXY (e_gdbus_book_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (book_factory_proxy)),
G_DBUS_PROXY_FLAGS_NONE,
@@ -3367,220 +3266,6 @@ e_book_new (ESource *source,
return book;
}
-/* for each known source calls check_func, which should return TRUE if the required
- * source have been found. Function returns NULL or the source on which was returned
- * TRUE by the check_func. Non-NULL pointer should be unreffed by g_object_unref. */
-static ESource *
-search_known_sources (gboolean (*check_func)(ESource *source,
- gpointer user_data),
- gpointer user_data,
- ESourceList **sources,
- GError **error)
-{
- ESource *res = NULL;
- GSList *g;
- GError *err = NULL;
-
- g_return_val_if_fail (check_func != NULL, NULL);
- g_return_val_if_fail (sources != NULL, NULL);
-
- if (!e_book_get_addressbooks (sources, &err)) {
- g_propagate_error (error, err);
- return NULL;
- }
-
- for (g = e_source_list_peek_groups (*sources); g; g = g->next) {
- ESourceGroup *group = E_SOURCE_GROUP (g->data);
- GSList *s;
-
- for (s = e_source_group_peek_sources (group); s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
-
- if (check_func (source, user_data)) {
- res = g_object_ref (source);
- break;
- }
- }
-
- if (res)
- break;
- }
-
- return res;
-}
-
-static gboolean
-check_uri (ESource *source,
- gpointer uri)
-{
- const gchar *suri;
-
- g_return_val_if_fail (source != NULL, FALSE);
- g_return_val_if_fail (uri != NULL, FALSE);
-
- suri = e_source_peek_absolute_uri (source);
-
- if (suri && g_ascii_strcasecmp (suri, uri) == 0)
- return TRUE;
-
- if (!suri && e_source_peek_group (source)) {
- gboolean res = FALSE;
- gchar *my_uri = g_strconcat (
- e_source_group_peek_base_uri (e_source_peek_group (source)),
- e_source_peek_relative_uri (source),
- NULL);
-
- res = my_uri && g_ascii_strcasecmp (my_uri, uri) == 0;
-
- g_free (my_uri);
-
- return res;
- } else {
- gboolean ret;
- gchar *suri2;
-
- suri2 = e_source_get_uri (source);
- ret = !g_ascii_strcasecmp (suri2, uri);
- g_free (suri2);
-
- return ret;
- }
-}
-
-/**
- * e_book_new_from_uri:
- * @uri: the URI to load
- * @error: A #GError pointer
- *
- * Creates a new #EBook corresponding to the given uri. See the
- * documentation for e_book_new for further information.
- *
- * Returns: a new but unopened #EBook.
- *
- * Deprecated: 3.2: Use e_book_client_new_from_uri() instead.
- */
-EBook *
-e_book_new_from_uri (const gchar *uri,
- GError **error)
-{
- ESourceList *sources = NULL;
- ESource *source;
- EBook *book;
- GError *err = NULL;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- source = search_known_sources (check_uri, (gpointer) uri, &sources, &err);
- if (err) {
- g_propagate_error (error, err);
- if (sources)
- g_object_unref (sources);
- return NULL;
- }
-
- if (!source)
- source = e_source_new_with_absolute_uri ("", uri);
-
- book = e_book_new (source, &err);
- if (err)
- g_propagate_error (error, err);
-
- g_object_unref (source);
- if (sources)
- g_object_unref (sources);
-
- return book;
-}
-
-struct check_system_data
-{
- const gchar *uri;
- ESource *uri_source;
-};
-
-static gboolean
-check_system (ESource *source,
- gpointer data)
-{
- struct check_system_data *csd = data;
-
- g_return_val_if_fail (source != NULL, FALSE);
- g_return_val_if_fail (data != NULL, FALSE);
-
- if (e_source_get_property (source, "system")) {
- return TRUE;
- }
-
- if (check_uri (source, (gpointer) csd->uri)) {
- if (csd->uri_source)
- g_object_unref (csd->uri_source);
- csd->uri_source = g_object_ref (source);
- }
-
- return FALSE;
-}
-
-static EBook *
-get_local_source (GError **error)
-{
- ESourceGroup *on_this_computer;
- ESourceList *sources;
- GSList *local_sources, *iter;
- ESource *personal = NULL;
- const gchar *name;
- gchar *source_uri = NULL;
- EBook *book;
-
- if (e_book_get_addressbooks (&sources, error)) {
- on_this_computer = e_source_list_ensure_group (
- sources, _("On This Computer"), "local:", TRUE);
-
- if (on_this_computer) {
- local_sources = e_source_group_peek_sources (on_this_computer);
-
- /* Make sure this group includes a "Personal" source. */
- for (iter = local_sources; iter != NULL; iter = iter->next) {
- ESource *source = iter->data;
- const gchar *relative_uri;
-
- relative_uri = e_source_peek_relative_uri (source);
- if (g_strcmp0 (relative_uri, "system") == 0) {
- personal = source;
- break;
- }
- }
-
- name = _("Personal");
-
- if (personal == NULL) {
- ESource *source;
-
- /* Create the default Personal address book. */
- source = e_source_new (name, "system");
- e_source_group_add_source (on_this_computer, source, -1);
- e_source_set_property (source, "completion", "true");
-
- source_uri = e_source_get_uri (source);
- g_object_unref (source);
- } else {
- /* Force the source name to the current locale. */
- e_source_set_name (personal, name);
-
- source_uri = e_source_get_uri (personal);
- }
-
- g_object_unref (on_this_computer);
- }
-
- g_object_unref (sources);
- }
-
- book = e_book_new_from_uri (source_uri?:"local:system", error);
- g_free (source_uri);
-
- return book;
-}
-
/**
* e_book_new_system_addressbook:
* @error: A #GError pointer
@@ -3595,44 +3280,21 @@ get_local_source (GError **error)
EBook *
e_book_new_system_addressbook (GError **error)
{
- GError *err = NULL;
- ESourceList *sources = NULL;
- ESource *system_source = NULL;
- EBook *book;
- struct check_system_data csd;
+ ESourceRegistry *registry;
+ ESource *source;
- csd.uri = "local:system";
- csd.uri_source = NULL;
+ registry = e_source_registry_get_default ();
+ source = e_source_registry_lookup_by_uid (registry, "system");
- system_source = search_known_sources (check_system, &csd, &sources, &err);
- if (err) {
- g_propagate_error (error, err);
- if (sources)
- g_object_unref (sources);
+ if (!E_IS_SOURCE (source)) {
+ g_set_error_literal (
+ error, E_BOOK_ERROR,
+ E_BOOK_ERROR_NO_SUCH_BOOK,
+ _("No system source found"));
return NULL;
}
- if (!system_source) {
- system_source = csd.uri_source;
- csd.uri_source = NULL;
- }
-
- if (system_source) {
- book = e_book_new (system_source, &err);
- g_object_unref (system_source);
- } else {
- book = get_local_source (&err);
- }
-
- if (csd.uri_source)
- g_object_unref (csd.uri_source);
- if (sources)
- g_object_unref (sources);
-
- if (err)
- g_propagate_error (error, err);
-
- return book;
+ return e_book_new (source, error);
}
/**
@@ -3649,26 +3311,13 @@ e_book_new_system_addressbook (GError **error)
EBook *
e_book_new_default_addressbook (GError **error)
{
- ESourceList *source_list;
+ ESourceRegistry *registry;
ESource *source;
- EBook *book;
- if (!e_book_get_addressbooks (&source_list, error))
- return NULL;
+ registry = e_source_registry_get_default ();
+ source = e_source_registry_get_default_address_book (registry);
- source = e_source_list_peek_default_source (source_list);
- if (!source) {
- g_set_error_literal (error, E_BOOK_ERROR, E_BOOK_ERROR_NO_SUCH_BOOK,
- _("Address book does not exist"));
- g_object_unref (source_list);
- return NULL;
- }
-
- book = e_book_new (source, error);
-
- g_object_unref (source_list);
-
- return book;
+ return e_book_new (source, error);
}
/**
diff --git a/addressbook/libebook/e-book.h b/addressbook/libebook/e-book.h
index f632d2b..e7bcdff 100644
--- a/addressbook/libebook/e-book.h
+++ b/addressbook/libebook/e-book.h
@@ -16,7 +16,6 @@
#include "libedataserver/e-list.h"
#include "libedataserver/e-source.h"
-#include "libedataserver/e-source-list.h"
#include <libebook/e-contact.h>
#include <libebook/e-book-query.h>
#include <libebook/e-book-view.h>
@@ -125,7 +124,6 @@ struct _EBookClass {
/* Creating a new addressbook. */
EBook *e_book_new (ESource *source, GError **error);
-EBook *e_book_new_from_uri (const gchar *uri, GError **error);
EBook *e_book_new_system_addressbook (GError **error);
EBook *e_book_new_default_addressbook (GError **error);
@@ -378,7 +376,6 @@ gboolean e_book_get_changes_async (EBook *book,
void e_book_free_change_list (GList *change_list);
-const gchar *e_book_get_uri (EBook *book);
ESource *e_book_get_source (EBook *book);
const gchar *e_book_get_static_capabilities (EBook *book,
@@ -405,7 +402,6 @@ gboolean e_book_is_self (EContact *contact);
/* Addressbook Discovery */
gboolean e_book_set_default_addressbook (EBook *book, GError **error);
gboolean e_book_set_default_source (ESource *source, GError **error);
-gboolean e_book_get_addressbooks (ESourceList ** addressbook_sources, GError **error);
GType e_book_get_type (void);
diff --git a/addressbook/libebook/e-destination.c b/addressbook/libebook/e-destination.c
index 9d0253e..09ce334 100644
--- a/addressbook/libebook/e-destination.c
+++ b/addressbook/libebook/e-destination.c
@@ -566,7 +566,7 @@ e_destination_set_book (EDestination *dest,
g_return_if_fail (book && E_IS_BOOK (book));
source = e_book_get_source (book);
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
g_return_if_fail (uid != NULL);
if (!dest->priv->source_uid || strcmp (uid, dest->priv->source_uid)) {
@@ -598,7 +598,7 @@ e_destination_set_client (EDestination *dest,
g_return_if_fail (client && E_IS_BOOK_CLIENT (client));
source = e_client_get_source (E_CLIENT (client));
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
g_return_if_fail (uid != NULL);
if (!dest->priv->source_uid || strcmp (uid, dest->priv->source_uid)) {
diff --git a/docs/reference/addressbook/libebook/libebook-sections.txt b/docs/reference/addressbook/libebook/libebook-sections.txt
index 8658b1f..8a54f79 100644
--- a/docs/reference/addressbook/libebook/libebook-sections.txt
+++ b/docs/reference/addressbook/libebook/libebook-sections.txt
@@ -24,11 +24,9 @@ EBookViewPrivate
EBook
e_book_new
e_book_new_default_addressbook
-e_book_new_from_uri
e_book_new_system_addressbook
e_book_set_default_addressbook
e_book_set_default_source
-e_book_remove
e_book_open
e_book_get_supported_fields
e_book_get_supported_auth_methods
@@ -46,7 +44,6 @@ e_book_get_book_view
e_book_get_contacts
e_book_get_changes
e_book_free_change_list
-e_book_get_uri
e_book_get_static_capabilities
e_book_check_static_capability
e_book_is_writable
@@ -55,7 +52,6 @@ e_book_cancel_async_op
e_book_get_self
e_book_set_self
e_book_is_self
-e_book_get_addressbooks
e_return_error_if_fail
e_return_async_error_if_fail
e_return_async_error_val_if_fail
@@ -76,7 +72,6 @@ EBookListCallback
EBookContactCallback
EBookBookViewCallback
e_book_open_async
-e_book_remove_async
e_book_get_supported_fields_async
e_book_get_supported_auth_methods_async
e_book_authenticate_user_async
@@ -91,7 +86,6 @@ e_book_get_book_view_async
e_book_get_changes_async
e_book_get_required_fields_async
e_book_async_open
-e_book_async_remove
e_book_async_get_supported_fields
e_book_async_get_supported_auth_methods
e_book_async_authenticate_user
@@ -130,12 +124,6 @@ e_book_client_error_to_string
e_book_client_error_create
EBookClient
e_book_client_new
-e_book_client_new_from_uri
-e_book_client_new_system
-e_book_client_new_default
-e_book_client_set_default
-e_book_client_set_default_source
-e_book_client_get_sources
e_book_client_get_self
e_book_client_set_self
e_book_client_is_self
diff --git a/docs/reference/addressbook/libebook/tmpl/e-book-client.sgml b/docs/reference/addressbook/libebook/tmpl/e-book-client.sgml
index 5ba515c..3592018 100644
--- a/docs/reference/addressbook/libebook/tmpl/e-book-client.sgml
+++ b/docs/reference/addressbook/libebook/tmpl/e-book-client.sgml
@@ -94,64 +94,6 @@ EBookClient
@Returns:
-<!-- ##### FUNCTION e_book_client_new_from_uri ##### -->
-<para>
-
-</para>
-
- uri:
- error:
- Returns:
-
-
-<!-- ##### FUNCTION e_book_client_new_system ##### -->
-<para>
-
-</para>
-
- error:
- Returns:
-
-
-<!-- ##### FUNCTION e_book_client_new_default ##### -->
-<para>
-
-</para>
-
- error:
- Returns:
-
-
-<!-- ##### FUNCTION e_book_client_set_default ##### -->
-<para>
-
-</para>
-
- client:
- error:
- Returns:
-
-
-<!-- ##### FUNCTION e_book_client_set_default_source ##### -->
-<para>
-
-</para>
-
- source:
- error:
- Returns:
-
-
-<!-- ##### FUNCTION e_book_client_get_sources ##### -->
-<para>
-
-</para>
-
- sources:
- error:
- Returns:
-
-
<!-- ##### FUNCTION e_book_client_get_self ##### -->
<para>
diff --git a/docs/reference/addressbook/libebook/tmpl/e-book.sgml b/docs/reference/addressbook/libebook/tmpl/e-book.sgml
index e6f4b0b..8cbe623 100644
--- a/docs/reference/addressbook/libebook/tmpl/e-book.sgml
+++ b/docs/reference/addressbook/libebook/tmpl/e-book.sgml
@@ -77,16 +77,6 @@ The writable status for this book is being reported.
@Returns:
-<!-- ##### FUNCTION e_book_new_from_uri ##### -->
-<para>
-
-</para>
-
- uri:
- error:
- Returns:
-
-
<!-- ##### FUNCTION e_book_new_system_addressbook ##### -->
<para>
@@ -116,16 +106,6 @@ The writable status for this book is being reported.
@Returns:
-<!-- ##### FUNCTION e_book_remove ##### -->
-<para>
-
-</para>
-
- book:
- error:
- Returns:
-
-
<!-- ##### FUNCTION e_book_open ##### -->
<para>
@@ -312,15 +292,6 @@ The writable status for this book is being reported.
@change_list:
-<!-- ##### FUNCTION e_book_get_uri ##### -->
-<para>
-
-</para>
-
- book:
- Returns:
-
-
<!-- ##### FUNCTION e_book_get_static_capabilities ##### -->
<para>
@@ -610,17 +581,6 @@ The writable status for this book is being reported.
@Returns:
-<!-- ##### FUNCTION e_book_remove_async ##### -->
-<para>
-
-</para>
-
- book:
- cb:
- closure:
- Returns:
-
-
<!-- ##### FUNCTION e_book_get_supported_fields_async ##### -->
<para>
@@ -790,17 +750,6 @@ The writable status for this book is being reported.
@Returns:
-<!-- ##### FUNCTION e_book_async_remove ##### -->
-<para>
-
-</para>
-
- book:
- cb:
- closure:
- Returns:
-
-
<!-- ##### FUNCTION e_book_async_get_supported_fields ##### -->
<para>
diff --git a/docs/reference/addressbook/libebook/tmpl/libebook-unused.sgml b/docs/reference/addressbook/libebook/tmpl/libebook-unused.sgml
index e8fe0b8..3302a3d 100644
--- a/docs/reference/addressbook/libebook/tmpl/libebook-unused.sgml
+++ b/docs/reference/addressbook/libebook/tmpl/libebook-unused.sgml
@@ -443,6 +443,16 @@ Data sent back to the e-book object.
@closure:
@Returns:
+<!-- ##### FUNCTION e_book_async_remove ##### -->
+<para>
+
+</para>
+
+ book:
+ cb:
+ closure:
+ Returns:
+
<!-- ##### FUNCTION e_book_async_remove_contact_by_id_ex ##### -->
<para>
@@ -493,6 +503,58 @@ Data sent back to the e-book object.
@book:
+<!-- ##### FUNCTION e_book_client_get_sources ##### -->
+<para>
+
+</para>
+
+ sources:
+ error:
+ Returns:
+
+<!-- ##### FUNCTION e_book_client_new_default ##### -->
+<para>
+
+</para>
+
+ error:
+ Returns:
+
+<!-- ##### FUNCTION e_book_client_new_from_uri ##### -->
+<para>
+
+</para>
+
+ uri:
+ error:
+ Returns:
+
+<!-- ##### FUNCTION e_book_client_new_system ##### -->
+<para>
+
+</para>
+
+ error:
+ Returns:
+
+<!-- ##### FUNCTION e_book_client_set_default ##### -->
+<para>
+
+</para>
+
+ client:
+ error:
+ Returns:
+
+<!-- ##### FUNCTION e_book_client_set_default_source ##### -->
+<para>
+
+</para>
+
+ source:
+ error:
+ Returns:
+
<!-- ##### FUNCTION e_book_get_addressbooks ##### -->
<para>
@@ -511,6 +573,14 @@ Data sent back to the e-book object.
@error:
@Returns:
+<!-- ##### FUNCTION e_book_get_uri ##### -->
+<para>
+
+</para>
+
+ book:
+ Returns:
+
<!-- ##### FUNCTION e_book_listener_new ##### -->
<para>
@@ -616,6 +686,34 @@ Data sent back to the e-book object.
</para>
+<!-- ##### FUNCTION e_book_new_from_uri ##### -->
+<para>
+
+</para>
+
+ uri:
+ error:
+ Returns:
+
+<!-- ##### FUNCTION e_book_remove ##### -->
+<para>
+
+</para>
+
+ book:
+ error:
+ Returns:
+
+<!-- ##### FUNCTION e_book_remove_async ##### -->
+<para>
+
+</para>
+
+ book:
+ cb:
+ closure:
+ Returns:
+
<!-- ##### FUNCTION e_book_unload_uri ##### -->
<para>
diff --git a/tests/libebook/client/client-test-utils.c b/tests/libebook/client/client-test-utils.c
index 710ba25..2350633 100644
--- a/tests/libebook/client/client-test-utils.c
+++ b/tests/libebook/client/client-test-utils.c
@@ -1,6 +1,9 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#include <stdio.h>
+#include <stdlib.h>
+#include <libedataserver/e-source-registry.h>
+#include <libebook/e-source-address-book.h>
#include "client-test-utils.h"
@@ -38,12 +41,17 @@ print_email (EContact *contact)
EBookClient *
open_system_book (gboolean only_if_exists)
{
+ ESourceRegistry *registry;
+ ESource *source;
EBookClient *book_client;
GError *error = NULL;
main_initialize ();
- book_client = e_book_client_new_system (&error);
+ registry = e_source_registry_get_default ();
+ source = e_source_registry_lookup_by_uid (registry, "system");
+
+ book_client = e_book_client_new (source, &error);
if (error) {
report_error ("create system addressbook", &error);
return NULL;
@@ -224,52 +232,31 @@ foreach_configured_source (void (*func) (ESource *source))
} while (foreach_configured_source_async_next (&foreach_async_data, &source));
}
-struct ForeachConfiguredData
-{
- ESourceList *source_list;
- GSList *current_group;
- GSList *current_source;
+struct ForeachConfiguredData {
+ GList *list;
};
gpointer
foreach_configured_source_async_start (ESource **source)
{
struct ForeachConfiguredData *async_data;
- ESourceList *source_list = NULL;
- GError *error = NULL;
+ ESourceRegistry *registry;
+ const gchar *extension_name;
+ GList *list;
g_return_val_if_fail (source != NULL, NULL);
main_initialize ();
- if (!e_book_client_get_sources (&source_list, &error)) {
- report_error ("get addressbooks", &error);
- return NULL;
- }
+ registry = e_source_registry_get_default ();
- g_return_val_if_fail (source_list != NULL, NULL);
+ extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+ list = e_source_registry_list_sources (registry, extension_name);
async_data = g_new0 (struct ForeachConfiguredData, 1);
- async_data->source_list = source_list;
- async_data->current_group = e_source_list_peek_groups (source_list);
- if (!async_data->current_group) {
- gpointer ad = async_data;
-
- foreach_configured_source_async_next (&ad, source);
- return ad;
- }
-
- async_data->current_source = e_source_group_peek_sources (async_data->current_group->data);
- if (!async_data->current_source) {
- gpointer ad = async_data;
+ async_data->list = list;
- if (foreach_configured_source_async_next (&ad, source))
- return ad;
-
- return NULL;
- }
-
- *source = async_data->current_source->data;
+ *source = async_data->list->data;
return async_data;
}
@@ -285,28 +272,14 @@ foreach_configured_source_async_next (gpointer *foreach_async_data,
async_data = *foreach_async_data;
g_return_val_if_fail (async_data != NULL, FALSE);
- g_return_val_if_fail (async_data->source_list != NULL, FALSE);
- g_return_val_if_fail (async_data->current_group != NULL, FALSE);
-
- if (async_data->current_source)
- async_data->current_source = async_data->current_source->next;
- if (async_data->current_source) {
- *source = async_data->current_source->data;
- return TRUE;
- }
- do {
- async_data->current_group = async_data->current_group->next;
- if (async_data->current_group)
- async_data->current_source = e_source_group_peek_sources (async_data->current_group->data);
- } while (async_data->current_group && !async_data->current_source);
-
- if (async_data->current_source) {
- *source = async_data->current_source->data;
+ if (async_data->list)
+ async_data->list = async_data->list->next;
+ if (async_data->list) {
+ *source = async_data->list->data;
return TRUE;
}
- g_object_unref (async_data->source_list);
g_free (async_data);
*foreach_async_data = NULL;
@@ -317,6 +290,7 @@ foreach_configured_source_async_next (gpointer *foreach_async_data,
EBookClient *
new_temp_client (gchar **uri)
{
+#if 0 /* ACCOUNT_MGMT */
EBookClient *book_client;
ESource *source;
gchar *abs_uri, *filename;
@@ -349,6 +323,9 @@ new_temp_client (gchar **uri)
report_error ("new temp client", &error);
return book_client;
+#endif /* ACCOUNT_MGMT */
+
+ return NULL;
}
gchar *
diff --git a/tests/libebook/client/test-client-async.c b/tests/libebook/client/test-client-async.c
index d6b730f..d4833e3 100644
--- a/tests/libebook/client/test-client-async.c
+++ b/tests/libebook/client/test-client-async.c
@@ -143,6 +143,7 @@ gint
main (gint argc,
gchar **argv)
{
+#if 0 /* ACCOUNT_MGMT */
EBookClient *book_client;
GError *error = NULL;
@@ -163,4 +164,7 @@ main (gint argc,
g_object_unref (book_client);
return get_main_loop_stop_result ();
+#endif /* ACCOUNT_MGMT */
+
+ return 0;
}
diff --git a/tests/libebook/client/test-client-examine.c b/tests/libebook/client/test-client-examine.c
index 1124d50..91cc425 100644
--- a/tests/libebook/client/test-client-examine.c
+++ b/tests/libebook/client/test-client-examine.c
@@ -3,7 +3,6 @@
#include <stdlib.h>
#include <string.h>
#include <libebook/e-book-client.h>
-#include <libedataserver/e-source-group.h>
#include "client-test-utils.h"
@@ -118,28 +117,14 @@ print_values (const ExtraValues *evals,
static void
identify_source (ESource *source)
{
- const gchar *name, *uri;
- gchar *abs_uri = NULL;
+ const gchar *name, *uid;
g_return_if_fail (source != NULL);
- name = e_source_peek_name (source);
- if (!name)
- name = "Unknown name";
+ uid = e_source_get_uid (source);
+ name = e_source_get_display_name (source);
- uri = e_source_peek_absolute_uri (source);
- if (!uri) {
- abs_uri = e_source_build_absolute_uri (source);
- uri = abs_uri;
- }
- if (!uri)
- uri = e_source_peek_relative_uri (source);
- if (!uri)
- uri = "Unknown uri";
-
- g_print ("\n Checking source '%s' (%s)\n", name, uri);
-
- g_free (abs_uri);
+ g_print ("\n Checking source '%s' (%s)\n", name, uid);
}
static void
diff --git a/tests/libebook/client/test-client-stress-factory--single-book.c b/tests/libebook/client/test-client-stress-factory--single-book.c
index 561190f..3a8e3f5 100644
--- a/tests/libebook/client/test-client-stress-factory--single-book.c
+++ b/tests/libebook/client/test-client-stress-factory--single-book.c
@@ -11,6 +11,7 @@ gint
main (gint argc,
gchar **argv)
{
+#if 0 /* ACCOUNT_MGMT */
gchar *uri = NULL;
EBookClient *book_client;
GError *error = NULL;
@@ -60,4 +61,7 @@ main (gint argc,
g_object_unref (book_client);
return ii == NUM_OPENS ? 0 : 1;
+#endif /* ACCOUNT_MGMT */
+
+ return 0;
}
diff --git a/tests/libebook/client/test-client-stress-views.c b/tests/libebook/client/test-client-stress-views.c
index f919f19..fd24b68 100644
--- a/tests/libebook/client/test-client-stress-views.c
+++ b/tests/libebook/client/test-client-stress-views.c
@@ -102,6 +102,7 @@ gint
main (gint argc,
gchar **argv)
{
+#if 0 /* ACCOUNT_MGMT */
EBookClient *book_client;
GError *error = NULL;
@@ -130,4 +131,7 @@ main (gint argc,
g_object_unref (book_client);
return get_main_loop_stop_result ();
+#endif /* ACCOUNT_MGMT */
+
+ return 0;
}
diff --git a/tests/libebook/ebook-test-utils.c b/tests/libebook/ebook-test-utils.c
index 7b9c074..9cb3473 100644
--- a/tests/libebook/ebook-test-utils.c
+++ b/tests/libebook/ebook-test-utils.c
@@ -116,14 +116,16 @@ ebook_test_utils_book_add_contact (EBook *book,
{
GError *error = NULL;
- if (!e_book_add_contact (book, contact, &error)) {
- const gchar *uri;
+ if (!e_book_add_contact (book, contact, &error)) {
+ ESource *source;
+ const gchar *name;
- uri = e_book_get_uri (book);
+ source = e_book_get_source (book);
+ name = e_source_get_display_name (source);
g_warning ("failed to add contact to addressbook: `%s': %s",
- uri, error->message);
- exit (1);
- }
+ name, error->message);
+ exit (1);
+ }
return e_contact_get_const (contact, E_CONTACT_UID);
}
@@ -172,16 +174,19 @@ ebook_test_utils_book_commit_contact (EBook *book,
{
GError *error = NULL;
- if (!e_book_commit_contact (book, contact, &error)) {
- const gchar *uid;
- const gchar *uri;
+ if (!e_book_commit_contact (book, contact, &error)) {
+ ESource *source;
+ const gchar *name;
+ const gchar *uid;
+
+ uid = (const gchar *) e_contact_get_const (contact, E_CONTACT_UID);
- uid = (const gchar *) e_contact_get_const (contact, E_CONTACT_UID);
- uri = e_book_get_uri (book);
+ source = e_book_get_source (book);
+ name = e_source_get_display_name (source);
g_warning ("failed to commit changes to contact '%s' to addressbook: `%s': %s",
- uid, uri, error->message);
- exit (1);
- }
+ uid, name, error->message);
+ exit (1);
+ }
}
static void
@@ -228,14 +233,16 @@ ebook_test_utils_book_get_contact (EBook *book,
EContact *contact = NULL;
GError *error = NULL;
- if (!e_book_get_contact (book, uid, &contact, &error)) {
- const gchar *uri;
+ if (!e_book_get_contact (book, uid, &contact, &error)) {
+ ESource *source;
+ const gchar *name;
- uri = e_book_get_uri (book);
+ source = e_book_get_source (book);
+ name = e_source_get_display_name (source);
g_warning ("failed to get contact '%s' in addressbook: `%s': "
- "%s", uid, uri, error->message);
- exit (1);
- }
+ "%s", uid, name, error->message);
+ exit (1);
+ }
return contact;
}
@@ -289,14 +296,16 @@ ebook_test_utils_book_get_required_fields (EBook *book)
GList *fields = NULL;
GError *error = NULL;
- if (!e_book_get_required_fields (book, &fields, &error)) {
- const gchar *uri;
+ if (!e_book_get_required_fields (book, &fields, &error)) {
+ ESource *source;
+ const gchar *name;
- uri = e_book_get_uri (book);
+ source = e_book_get_source (book);
+ name = e_source_get_display_name (source);
g_warning ("failed to get required fields for addressbook "
- "`%s': %s", uri, error->message);
- exit (1);
- }
+ "`%s': %s", name, error->message);
+ exit (1);
+ }
return fields;
}
@@ -347,14 +356,16 @@ ebook_test_utils_book_get_static_capabilities (EBook *book)
GError *error = NULL;
const gchar *caps;
- if (!(caps = e_book_get_static_capabilities (book, &error))) {
- const gchar *uri;
+ if (!(caps = e_book_get_static_capabilities (book, &error))) {
+ ESource *source;
+ const gchar *name;
- uri = e_book_get_uri (book);
+ source = e_book_get_source (book);
+ name = e_source_get_display_name (source);
g_warning ("failed to get capabilities for addressbook: `%s': "
- "%s", uri, error->message);
- exit (1);
- }
+ "%s", name, error->message);
+ exit (1);
+ }
return caps;
}
@@ -365,14 +376,16 @@ ebook_test_utils_book_get_supported_auth_methods (EBook *book)
GList *fields = NULL;
GError *error = NULL;
- if (!e_book_get_supported_auth_methods (book, &fields, &error)) {
- const gchar *uri;
+ if (!e_book_get_supported_auth_methods (book, &fields, &error)) {
+ ESource *source;
+ const gchar *name;
- uri = e_book_get_uri (book);
+ source = e_book_get_source (book);
+ name = e_source_get_display_name (source);
g_warning ("failed to get supported auth methods for "
- "addressbook `%s': %s", uri, error->message);
- exit (1);
- }
+ "addressbook `%s': %s", name, error->message);
+ exit (1);
+ }
return fields;
}
@@ -424,14 +437,16 @@ ebook_test_utils_book_get_supported_fields (EBook *book)
GList *fields = NULL;
GError *error = NULL;
- if (!e_book_get_supported_fields (book, &fields, &error)) {
- const gchar *uri;
+ if (!e_book_get_supported_fields (book, &fields, &error)) {
+ ESource *source;
+ const gchar *name;
- uri = e_book_get_uri (book);
+ source = e_book_get_source (book);
+ name = e_source_get_display_name (source);
g_warning ("failed to get supported fields for addressbook "
- "`%s': %s", uri, error->message);
- exit (1);
- }
+ "`%s': %s", name, error->message);
+ exit (1);
+ }
return fields;
}
@@ -482,14 +497,16 @@ ebook_test_utils_book_remove_contact (EBook *book,
{
GError *error = NULL;
- if (!e_book_remove_contact (book, uid, &error)) {
- const gchar *uri;
+ if (!e_book_remove_contact (book, uid, &error)) {
+ ESource *source;
+ const gchar *name;
- uri = e_book_get_uri (book);
+ source = e_book_get_source (book);
+ name = e_source_get_display_name (source);
g_warning ("failed to remove contact '%s' from addressbook: `%s': %s",
- uid, uri, error->message);
- exit (1);
- }
+ uid, name, error->message);
+ exit (1);
+ }
}
static void
@@ -574,14 +591,16 @@ ebook_test_utils_book_remove_contacts (EBook *book,
{
GError *error = NULL;
- if (!e_book_remove_contacts (book, ids, &error)) {
- const gchar *uri;
+ if (!e_book_remove_contacts (book, ids, &error)) {
+ ESource *source;
+ const gchar *name;
- uri = e_book_get_uri (book);
+ source = e_book_get_source (book);
+ name = e_source_get_display_name (source);
g_warning ("failed to remove contacts from addressbook: `%s': %s",
- uri, error->message);
- exit (1);
- }
+ name, error->message);
+ exit (1);
+ }
}
static void
@@ -623,22 +642,6 @@ ebook_test_utils_book_async_remove_contacts (EBook *book,
}
EBook *
-ebook_test_utils_book_new_from_uri (const gchar *uri)
-{
- EBook *book;
- GError *error = NULL;
-
- test_print ("loading addressbook\n");
- book = e_book_new_from_uri (uri, &error);
- if (!book) {
- g_error ("failed to create addressbook: `%s': %s", uri,
- error->message);
- }
-
- return book;
-}
-
-EBook *
ebook_test_utils_book_new_temp (gchar **uri)
{
EBook *book;
@@ -656,7 +659,9 @@ ebook_test_utils_book_new_temp (gchar **uri)
}
g_free (file_template);
- book = ebook_test_utils_book_new_from_uri (uri_result);
+ /* FIXME We don't build EBooks from URIs anymore. */
+ /* book = ebook_test_utils_book_new_from_uri (uri_result); */
+ book = NULL;
if (uri)
*uri = g_strdup (uri_result);
@@ -673,79 +678,36 @@ ebook_test_utils_book_open (EBook *book,
GError *error = NULL;
if (!e_book_open (book, only_if_exists, &error)) {
- const gchar *uri;
+ ESource *source;
+ const gchar *name;
- uri = e_book_get_uri (book);
+ source = e_book_get_source (book);
+ name = e_source_get_display_name (source);
- g_warning ("failed to open addressbook: `%s': %s", uri,
+ g_warning ("failed to open addressbook: `%s': %s", name,
error->message);
exit (1);
}
}
void
-ebook_test_utils_book_remove (EBook *book)
-{
- GError *error = NULL;
-
- if (!e_book_remove (book, &error)) {
- g_warning ("failed to remove book; %s\n", error->message);
- exit (1);
- }
- test_print ("successfully removed the temporary addressbook\n");
-
- g_object_unref (book);
-}
-
-static void
-remove_cb (EBook *book,
- const GError *error,
- EBookTestClosure *closure)
-{
- if (error) {
- g_warning ("failed to asynchronously remove the book: "
- "status %d (%s)", error->code, error->message);
- exit (1);
- }
-
- test_print ("successfully asynchronously removed the temporary "
- "addressbook\n");
- if (closure)
- (*closure->cb) (closure);
-}
-
-void
-ebook_test_utils_book_async_remove (EBook *book,
- GSourceFunc callback,
- gpointer user_data)
-{
- EBookTestClosure *closure;
-
- closure = g_new0 (EBookTestClosure, 1);
- closure->cb = callback;
- closure->user_data = user_data;
- if (!e_book_remove_async (book, (EBookAsyncCallback) remove_cb, closure)) {
- g_warning ("failed to set up book removal");
- exit (1);
- }
-}
-
-void
ebook_test_utils_book_get_book_view (EBook *book,
EBookQuery *query,
EBookView **view)
{
GError *error = NULL;
- if (!e_book_get_book_view (book, query, NULL, -1, view, &error)) {
- const gchar *uri;
+ if (!e_book_get_book_view (book, query, NULL, -1, view, &error)) {
+ ESource *source;
+ const gchar *name;
- uri = e_book_get_uri (book);
+ source = e_book_get_source (book);
+ name = e_source_get_display_name (source);
- g_warning ("failed to get view for addressbook: `%s': %s", uri,
- error->message);
- exit (1);
- }
+ g_warning ("failed to get view for addressbook: `%s': %s",
+ name, error->message);
+ exit (1);
+ }
}
static void
diff --git a/tests/libebook/ebook-test-utils.h b/tests/libebook/ebook-test-utils.h
index 78c2256..ad1be19 100644
--- a/tests/libebook/ebook-test-utils.h
+++ b/tests/libebook/ebook-test-utils.h
@@ -138,13 +138,6 @@ ebook_test_utils_book_open (EBook *book,
gboolean only_if_exists);
void
-ebook_test_utils_book_remove (EBook *book);
-void
-ebook_test_utils_book_async_remove (EBook *book,
- GSourceFunc callback,
- gpointer user_data);
-
-void
ebook_test_utils_book_get_book_view (EBook *book,
EBookQuery *query,
EBookView **view);
diff --git a/tests/libebook/test-changes.c b/tests/libebook/test-changes.c
index 49a8aac..424c5bf 100644
--- a/tests/libebook/test-changes.c
+++ b/tests/libebook/test-changes.c
@@ -61,7 +61,6 @@ main (gint argc,
e_book_free_change_list (changes);
g_object_unref (contact);
- ebook_test_utils_book_remove (book);
return 0;
}
diff --git a/tests/libebook/test-ebook-add-contact.c b/tests/libebook/test-ebook-add-contact.c
index 1cc86a5..d79719c 100644
--- a/tests/libebook/test-ebook-add-contact.c
+++ b/tests/libebook/test-ebook-add-contact.c
@@ -32,8 +32,6 @@ main (gint argc,
test_print ("successfully added and retrieved contact '%s'\n", uid);
g_object_unref (contact_final);
- ebook_test_utils_book_remove (book);
-
/*
* Async version
*/
@@ -49,7 +47,6 @@ main (gint argc,
g_free (uid);
g_main_loop_run (loop);
- ebook_test_utils_book_remove (book);
g_free (vcard);
return 0;
diff --git a/tests/libebook/test-ebook-commit-contact.c b/tests/libebook/test-ebook-commit-contact.c
index a04e37a..0fcf16c 100644
--- a/tests/libebook/test-ebook-commit-contact.c
+++ b/tests/libebook/test-ebook-commit-contact.c
@@ -74,8 +74,6 @@ main (gint argc,
g_object_unref (contact);
g_free (uid);
- ebook_test_utils_book_remove (book);
-
/*
* Async version
*/
@@ -92,7 +90,6 @@ main (gint argc,
g_main_loop_run (loop);
g_free (uid);
- ebook_test_utils_book_remove (book);
return 0;
}
diff --git a/tests/libebook/test-ebook-get-book-view.c b/tests/libebook/test-ebook-get-book-view.c
index 9dec7e4..3c78074 100644
--- a/tests/libebook/test-ebook-get-book-view.c
+++ b/tests/libebook/test-ebook-get-book-view.c
@@ -114,8 +114,7 @@ main (gint argc,
loop = g_main_loop_new (NULL, TRUE);
g_main_loop_run (loop);
- e_book_query_unref (query);
- ebook_test_utils_book_remove (book);
+ e_book_query_unref (query);
/*
* Async version
@@ -129,8 +128,7 @@ main (gint argc,
g_main_loop_run (loop);
- e_book_query_unref (query);
- ebook_test_utils_book_remove (book);
+ e_book_query_unref (query);
return 0;
}
diff --git a/tests/libebook/test-ebook-get-contact.c b/tests/libebook/test-ebook-get-contact.c
index d476022..0bb2005 100644
--- a/tests/libebook/test-ebook-get-contact.c
+++ b/tests/libebook/test-ebook-get-contact.c
@@ -39,7 +39,5 @@ main (gint argc,
g_main_loop_run (loop);
- ebook_test_utils_book_remove (book);
-
return 0;
}
diff --git a/tests/libebook/test-ebook-get-required-fields.c b/tests/libebook/test-ebook-get-required-fields.c
index f66ac55..6c3cea3 100644
--- a/tests/libebook/test-ebook-get-required-fields.c
+++ b/tests/libebook/test-ebook-get-required-fields.c
@@ -71,7 +71,5 @@ main (gint argc,
g_main_loop_run (loop);
- ebook_test_utils_book_remove (book);
-
return 0;
}
diff --git a/tests/libebook/test-ebook-get-static-capabilities.c b/tests/libebook/test-ebook-get-static-capabilities.c
index fe553eb..f9a8500 100644
--- a/tests/libebook/test-ebook-get-static-capabilities.c
+++ b/tests/libebook/test-ebook-get-static-capabilities.c
@@ -27,7 +27,5 @@ main (gint argc,
test_print ("successfully retrieved static capabilities: '%s'\n", caps);
- ebook_test_utils_book_remove (book);
-
return 0;
}
diff --git a/tests/libebook/test-ebook-get-supported-auth-methods.c b/tests/libebook/test-ebook-get-supported-auth-methods.c
index 49f05f1..9248478 100644
--- a/tests/libebook/test-ebook-get-supported-auth-methods.c
+++ b/tests/libebook/test-ebook-get-supported-auth-methods.c
@@ -71,7 +71,5 @@ main (gint argc,
g_main_loop_run (loop);
- ebook_test_utils_book_remove (book);
-
return 0;
}
diff --git a/tests/libebook/test-ebook-get-supported-fields.c b/tests/libebook/test-ebook-get-supported-fields.c
index 7213235..d2b576d 100644
--- a/tests/libebook/test-ebook-get-supported-fields.c
+++ b/tests/libebook/test-ebook-get-supported-fields.c
@@ -71,7 +71,5 @@ main (gint argc,
g_main_loop_run (loop);
- ebook_test_utils_book_remove (book);
-
return 0;
}
diff --git a/tests/libebook/test-ebook-remove-contact-by-id.c b/tests/libebook/test-ebook-remove-contact-by-id.c
index 35bc3ac..faa76c9 100644
--- a/tests/libebook/test-ebook-remove-contact-by-id.c
+++ b/tests/libebook/test-ebook-remove-contact-by-id.c
@@ -28,7 +28,6 @@ main (gint argc,
g_main_loop_run (loop);
- ebook_test_utils_book_remove (book);
g_free (uid);
return 0;
diff --git a/tests/libebook/test-ebook-remove-contact.c b/tests/libebook/test-ebook-remove-contact.c
index 4c0f9a0..69d09a2 100644
--- a/tests/libebook/test-ebook-remove-contact.c
+++ b/tests/libebook/test-ebook-remove-contact.c
@@ -32,8 +32,7 @@ main (gint argc,
g_assert (contact_final == NULL);
test_print ("successfully added and removed contact '%s'\n", uid);
- ebook_test_utils_book_remove (book);
- g_free (uid);
+ g_free (uid);
/*
* Async version
@@ -52,7 +51,6 @@ main (gint argc,
g_main_loop_run (loop);
- ebook_test_utils_book_remove (book);
g_object_unref (contact_final);
g_free (uid);
diff --git a/tests/libebook/test-ebook-remove-contacts.c b/tests/libebook/test-ebook-remove-contacts.c
index 1e26917..c4d0e27 100644
--- a/tests/libebook/test-ebook-remove-contacts.c
+++ b/tests/libebook/test-ebook-remove-contacts.c
@@ -40,9 +40,8 @@ main (gint argc,
test_print ("successfully added and removed contacts\n");
- ebook_test_utils_book_remove (book);
- g_free (uid_1);
- g_free (uid_2);
+ g_free (uid_1);
+ g_free (uid_2);
g_list_free (uids);
/*
@@ -63,9 +62,8 @@ main (gint argc,
g_main_loop_run (loop);
- ebook_test_utils_book_remove (book);
- g_free (uid_1);
- g_free (uid_2);
+ g_free (uid_1);
+ g_free (uid_2);
g_list_free (uids);
return 0;
diff --git a/tests/libebook/test-ebook-remove.c b/tests/libebook/test-ebook-remove.c
index 978df54..876e62a 100644
--- a/tests/libebook/test-ebook-remove.c
+++ b/tests/libebook/test-ebook-remove.c
@@ -18,7 +18,6 @@ main (gint argc,
/* Sync version */
book = ebook_test_utils_book_new_temp (&uri);
ebook_test_utils_book_open (book, FALSE);
- ebook_test_utils_book_remove (book);
/* Async version */
book = ebook_test_utils_book_new_temp (&uri);
diff --git a/tests/libebook/test-ebook-stress-factory--fifo.c b/tests/libebook/test-ebook-stress-factory--fifo.c
index f020dba..5b45955 100644
--- a/tests/libebook/test-ebook-stress-factory--fifo.c
+++ b/tests/libebook/test-ebook-stress-factory--fifo.c
@@ -26,9 +26,5 @@ main (gint argc,
g_free (uri);
}
- for (i = 0; i < NUM_BOOKS; i++) {
- ebook_test_utils_book_remove (books[i]);
- }
-
return 0;
}
diff --git a/tests/libebook/test-ebook-stress-factory--serial.c b/tests/libebook/test-ebook-stress-factory--serial.c
index afbddf6..4086bd6 100644
--- a/tests/libebook/test-ebook-stress-factory--serial.c
+++ b/tests/libebook/test-ebook-stress-factory--serial.c
@@ -21,7 +21,6 @@ main (gint argc,
book = ebook_test_utils_book_new_temp (&uri);
ebook_test_utils_book_open (book, FALSE);
- ebook_test_utils_book_remove (book);
g_free (uri);
}
diff --git a/tests/libebook/test-ebook-stress-factory--single-book.c b/tests/libebook/test-ebook-stress-factory--single-book.c
index 136113f..6d54f83 100644
--- a/tests/libebook/test-ebook-stress-factory--single-book.c
+++ b/tests/libebook/test-ebook-stress-factory--single-book.c
@@ -27,9 +27,6 @@ main (gint argc,
g_object_unref (book);
}
- book = ebook_test_utils_book_new_from_uri (uri);
- ebook_test_utils_book_remove (book);
-
g_free (uri);
return 0;
diff --git a/tests/libebook/test-nonexistent-id.c b/tests/libebook/test-nonexistent-id.c
index 821fb5c..24fbab4 100644
--- a/tests/libebook/test-nonexistent-id.c
+++ b/tests/libebook/test-nonexistent-id.c
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include <libebook/e-book.h>
gint main (gint argc, gchar **argv)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]