[evolution-data-server/eclient] Have 'refresh' method available on books too, thus it can be part of EClient
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/eclient] Have 'refresh' method available on books too, thus it can be part of EClient
- Date: Fri, 20 May 2011 14:42:04 +0000 (UTC)
commit 1ec389d877d0e3f8de2657b49fde761432897cdd
Author: Milan Crha <mcrha redhat com>
Date: Fri May 20 16:41:17 2011 +0200
Have 'refresh' method available on books too, thus it can be part of EClient
addressbook/libebook/e-book-client.c | 36 +++++++
addressbook/libedata-book/e-book-backend-sync.c | 32 ++++++
addressbook/libedata-book/e-book-backend-sync.h | 2 +
addressbook/libedata-book/e-book-backend.c | 30 ++++++
addressbook/libedata-book/e-book-backend.h | 2 +
addressbook/libedata-book/e-data-book.c | 48 +++++++++-
addressbook/libedata-book/e-data-book.h | 1 +
addressbook/libegdbus/e-gdbus-book.c | 29 ++++++
addressbook/libegdbus/e-gdbus-book.h | 9 ++
calendar/libecal/e-cal-client.c | 122 +++++++----------------
calendar/libecal/e-cal-client.h | 1 -
calendar/libecal/e-cal.c | 2 +-
calendar/libedata-cal/e-cal-backend.c | 9 ++-
libedataserver/e-client.c | 106 ++++++++++++++++++++
libedataserver/e-client.h | 9 ++
tests/libebook/client/Makefile.am | 3 +
tests/libebook/client/test-client-refresh.c | 114 +++++++++++++++++++++
tests/libecal/client/test-client-refresh.c | 10 ++-
18 files changed, 470 insertions(+), 95 deletions(-)
---
diff --git a/addressbook/libebook/e-book-client.c b/addressbook/libebook/e-book-client.c
index c8fea3b..be9ceb9 100644
--- a/addressbook/libebook/e-book-client.c
+++ b/addressbook/libebook/e-book-client.c
@@ -1017,6 +1017,39 @@ book_client_remove_sync (EClient *client, GCancellable *cancellable, GError **er
return e_client_proxy_call_sync_void__void (client, cancellable, error, e_gdbus_book_call_remove_sync);
}
+static void
+book_client_refresh (EClient *client, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
+{
+ e_client_proxy_call_void (client, cancellable, callback, user_data, book_client_refresh,
+ e_gdbus_book_call_refresh,
+ e_gdbus_book_call_refresh_finish, NULL, NULL, NULL, NULL);
+}
+
+static gboolean
+book_client_refresh_finish (EClient *client, GAsyncResult *result, GError **error)
+{
+ return e_client_proxy_call_finish_void (client, result, error, book_client_refresh);
+}
+
+static gboolean
+book_client_refresh_sync (EClient *client, GCancellable *cancellable, GError **error)
+{
+ EBookClient *book_client;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (E_IS_BOOK_CLIENT (client), FALSE);
+
+ book_client = E_BOOK_CLIENT (client);
+ g_return_val_if_fail (book_client != NULL, FALSE);
+ g_return_val_if_fail (book_client->priv != NULL, FALSE);
+
+ if (!book_client->priv->gdbus_book) {
+ set_proxy_gone_error (error);
+ return FALSE;
+ }
+
+ return e_client_proxy_call_sync_void__void (client, cancellable, error, e_gdbus_book_call_refresh_sync);
+}
/**
* e_book_client_add_contact:
@@ -2054,4 +2087,7 @@ e_book_client_class_init (EBookClientClass *klass)
client_class->remove = book_client_remove;
client_class->remove_finish = book_client_remove_finish;
client_class->remove_sync = book_client_remove_sync;
+ client_class->refresh = book_client_refresh;
+ client_class->refresh_finish = book_client_refresh_finish;
+ client_class->refresh_sync = book_client_refresh_sync;
}
diff --git a/addressbook/libedata-book/e-book-backend-sync.c b/addressbook/libedata-book/e-book-backend-sync.c
index 340636c..a944554 100644
--- a/addressbook/libedata-book/e-book-backend-sync.c
+++ b/addressbook/libedata-book/e-book-backend-sync.c
@@ -110,6 +110,27 @@ e_book_backend_sync_remove (EBookBackendSync *backend,
}
/**
+ * e_book_backend_sync_refresh:
+ * @backend: An EBookBackendSync object.
+ * @book: An EDataBook object.
+ * @cancellable: a #GCancellable for the operation
+ * @error: Out parameter for a #GError.
+ *
+ * Calls the refresh_sync method on the given backend.
+ *
+ * Since: 3.2
+ */
+void
+e_book_backend_sync_refresh (EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, GError **error)
+{
+ e_return_data_book_error_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_IS_DATA_BOOK (book), E_DATA_BOOK_STATUS_INVALID_ARG);
+ e_return_data_book_error_if_fail (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->refresh_sync, E_DATA_BOOK_STATUS_NOT_SUPPORTED);
+
+ (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->refresh_sync) (backend, book, cancellable, error);
+}
+
+/**
* e_book_backend_sync_get_backend_property:
* @backend: an #EBookBackendSync
* @book: an #EDataBook
@@ -332,6 +353,16 @@ book_backend_remove (EBookBackend *backend,
}
static void
+book_backend_refresh (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable)
+{
+ GError *error = NULL;
+
+ e_book_backend_sync_refresh (E_BOOK_BACKEND_SYNC (backend), book, cancellable, &error);
+
+ e_data_book_respond_refresh (book, opid, error);
+}
+
+static void
book_backend_get_backend_property (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable, const gchar *prop_name)
{
GError *error = NULL;
@@ -514,6 +545,7 @@ e_book_backend_sync_class_init (EBookBackendSyncClass *klass)
backend_class->open = book_backend_open;
backend_class->authenticate_user = book_backend_authenticate_user;
backend_class->remove = book_backend_remove;
+ backend_class->refresh = book_backend_refresh;
backend_class->get_backend_property = book_backend_get_backend_property;
backend_class->set_backend_property = book_backend_set_backend_property;
backend_class->create_contact = book_backend_create_contact;
diff --git a/addressbook/libedata-book/e-book-backend-sync.h b/addressbook/libedata-book/e-book-backend-sync.h
index e944052..7f37d04 100644
--- a/addressbook/libedata-book/e-book-backend-sync.h
+++ b/addressbook/libedata-book/e-book-backend-sync.h
@@ -31,6 +31,7 @@ struct _EBookBackendSyncClass {
/* Virtual methods */
void (*open_sync) (EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, gboolean only_if_exists, GError **error);
void (*remove_sync) (EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, GError **error);
+ void (* refresh_sync) (EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, GError **error);
gboolean (*get_backend_property_sync) (EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, const gchar *prop_name, gchar **prop_value, GError **error);
gboolean (*set_backend_property_sync) (EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, const gchar *prop_name, const gchar *prop_value, GError **error);
void (*create_contact_sync) (EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, const gchar *vcard, EContact **contact, GError **error);
@@ -48,6 +49,7 @@ gboolean e_book_backend_sync_construct (EBookBackendSync *backend);
void e_book_backend_sync_open (EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, gboolean only_if_exists, GError **error);
void e_book_backend_sync_remove (EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, GError **error);
+void e_book_backend_sync_refresh (EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, GError **error);
gboolean e_book_backend_sync_get_backend_property(EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, const gchar *prop_name, gchar **prop_value, GError **error);
gboolean e_book_backend_sync_set_backend_property(EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, const gchar *prop_name, const gchar *prop_value, GError **error);
void e_book_backend_sync_create_contact (EBookBackendSync *backend, EDataBook *book, GCancellable *cancellable, const gchar *vcard, EContact **contact, GError **error);
diff --git a/addressbook/libedata-book/e-book-backend.c b/addressbook/libedata-book/e-book-backend.c
index d261be4..204e53a 100644
--- a/addressbook/libedata-book/e-book-backend.c
+++ b/addressbook/libedata-book/e-book-backend.c
@@ -413,6 +413,36 @@ e_book_backend_remove (EBookBackend *backend,
}
/**
+ * e_book_backend_refresh:
+ * @backend: an #EBookBackend
+ * @book: an #EDataBook
+ * @opid: the ID to use for this operation
+ * @cancellable: a #GCancellable for the operation
+ *
+ * Refreshes the address book being accessed by the given backend.
+ * This might be finished with e_data_book_respond_refresh(),
+ * and it might be called as soon as possible; it doesn't mean
+ * that the refreshing is done after calling that, the backend
+ * is only notifying client whether it started the refresh process
+ * or not.
+ *
+ * Since: 3.2
+ **/
+void
+e_book_backend_refresh (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable)
+{
+ g_return_if_fail (backend != NULL);
+ g_return_if_fail (E_IS_BOOK_BACKEND (backend));
+
+ if (e_book_backend_is_opening (backend))
+ e_data_book_respond_refresh (book, opid, EDB_OPENING_ERROR);
+ else if (!E_BOOK_BACKEND_GET_CLASS (backend)->refresh)
+ e_data_book_respond_refresh (book, opid, e_data_book_create_error (E_DATA_BOOK_STATUS_NOT_SUPPORTED, NULL));
+ else
+ (* E_BOOK_BACKEND_GET_CLASS (backend)->refresh) (backend, book, opid, cancellable);
+}
+
+/**
* e_book_backend_create_contact:
* @backend: an #EBookBackend
* @book: an #EDataBook
diff --git a/addressbook/libedata-book/e-book-backend.h b/addressbook/libedata-book/e-book-backend.h
index 752b381..ad8be78 100644
--- a/addressbook/libedata-book/e-book-backend.h
+++ b/addressbook/libedata-book/e-book-backend.h
@@ -70,6 +70,7 @@ struct _EBookBackendClass {
void (* set_online) (EBookBackend *backend, gboolean is_online);
void (* authenticate_user) (EBookBackend *backend, GCancellable *cancellable, ECredentials *credentials);
+ void (* refresh) (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable);
void (* create_contact) (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable, const gchar *vcard);
void (* remove_contacts) (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable, const GSList *id_list);
void (* modify_contact) (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable, const gchar *vcard);
@@ -107,6 +108,7 @@ void e_book_backend_set_backend_property (EBookBackend *backend, EDataBook *boo
void e_book_backend_open (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable, gboolean only_if_exists);
void e_book_backend_remove (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable);
+void e_book_backend_refresh (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable);
void e_book_backend_create_contact (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable, const gchar *vcard);
void e_book_backend_remove_contacts (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable, const GSList *id_list);
void e_book_backend_modify_contact (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable, const gchar *vcard);
diff --git a/addressbook/libedata-book/e-data-book.c b/addressbook/libedata-book/e-data-book.c
index 29f1a5b..1e1f04b 100644
--- a/addressbook/libedata-book/e-data-book.c
+++ b/addressbook/libedata-book/e-data-book.c
@@ -56,6 +56,7 @@ static EOperationPool *ops_pool = NULL;
typedef enum {
OP_OPEN,
OP_REMOVE,
+ OP_REFRESH,
OP_GET_CONTACT,
OP_GET_CONTACTS,
OP_AUTHENTICATE,
@@ -101,9 +102,10 @@ typedef struct {
gchar *prop_value;
} sbp;
- /* - OP_REMOVE */
- /* - OP_CANCEL_ALL */
- /* - OP_CLOSE */
+ /* OP_REMOVE */
+ /* OP_REFRESH */
+ /* OP_CANCEL_ALL */
+ /* OP_CLOSE */
} d;
} OperationData;
@@ -161,6 +163,9 @@ operation_thread (gpointer data, gpointer user_data)
case OP_REMOVE:
e_book_backend_remove (backend, op->book, op->id, op->cancellable);
break;
+ case OP_REFRESH:
+ e_book_backend_refresh (backend, op->book, op->id, op->cancellable);
+ break;
case OP_GET_BACKEND_PROPERTY:
e_book_backend_get_backend_property (backend, op->book, op->id, op->cancellable, op->d.prop_name);
g_free (op->d.prop_name);
@@ -497,6 +502,19 @@ impl_Book_remove (EGdbusBook *object, GDBusMethodInvocation *invocation, EDataBo
}
static gboolean
+impl_Book_refresh (EGdbusBook *object, GDBusMethodInvocation *invocation, EDataBook *book)
+{
+ OperationData *op;
+
+ op = op_new (OP_REFRESH, book);
+
+ e_gdbus_book_complete_refresh (book->priv->gdbus_object, invocation, op->id);
+ e_operation_pool_push (ops_pool, op);
+
+ return TRUE;
+}
+
+static gboolean
impl_Book_getContact (EGdbusBook *object, GDBusMethodInvocation *invocation, const gchar *in_uid, EDataBook *book)
{
OperationData *op;
@@ -751,6 +769,29 @@ e_data_book_respond_remove (EDataBook *book, guint opid, GError *error)
e_book_backend_set_is_removed (book->priv->backend, TRUE);
}
+/**
+ * e_data_book_respond_refresh:
+ * @book: An addressbook client interface.
+ * @error: Operation error, if any, automatically freed if passed it.
+ *
+ * Notifies listeners of the completion of the refresh method call.
+ *
+ * Since: 3.2
+ */
+void
+e_data_book_respond_refresh (EDataBook *book, guint32 opid, GError *error)
+{
+ op_complete (book, opid);
+
+ /* Translators: This is prefix to a detailed error message */
+ g_prefix_error (&error, "%s", _("Cannot refresh address book: "));
+
+ e_gdbus_book_emit_refresh_done (book->priv->gdbus_object, opid, error);
+
+ if (error)
+ g_error_free (error);
+}
+
void
e_data_book_respond_get_backend_property (EDataBook *book, guint32 opid, GError *error, const gchar *prop_value)
{
@@ -985,6 +1026,7 @@ e_data_book_init (EDataBook *ebook)
gdbus_object = ebook->priv->gdbus_object;
g_signal_connect (gdbus_object, "handle-open", G_CALLBACK (impl_Book_open), ebook);
g_signal_connect (gdbus_object, "handle-remove", G_CALLBACK (impl_Book_remove), ebook);
+ g_signal_connect (gdbus_object, "handle-refresh", G_CALLBACK (impl_Book_refresh), ebook);
g_signal_connect (gdbus_object, "handle-get-contact", G_CALLBACK (impl_Book_getContact), ebook);
g_signal_connect (gdbus_object, "handle-get-contact-list", G_CALLBACK (impl_Book_getContactList), ebook);
g_signal_connect (gdbus_object, "handle-authenticate-user", G_CALLBACK (impl_Book_authenticateUser), ebook);
diff --git a/addressbook/libedata-book/e-data-book.h b/addressbook/libedata-book/e-data-book.h
index 465a2ba..5f5d879 100644
--- a/addressbook/libedata-book/e-data-book.h
+++ b/addressbook/libedata-book/e-data-book.h
@@ -135,6 +135,7 @@ guint e_data_book_register_gdbus_object (EDataBook *cal, GDBusConnection *conn
void e_data_book_respond_open (EDataBook *book, guint32 opid, GError *error);
void e_data_book_respond_remove (EDataBook *book, guint32 opid, GError *error);
+void e_data_book_respond_refresh (EDataBook *book, guint32 opid, GError *error);
void e_data_book_respond_get_backend_property (EDataBook *book, guint32 opid, GError *error, const gchar *prop_value);
void e_data_book_respond_set_backend_property (EDataBook *book, guint32 opid, GError *error);
void e_data_book_respond_create (EDataBook *book, guint32 opid, GError *error, const EContact *contact);
diff --git a/addressbook/libegdbus/e-gdbus-book.c b/addressbook/libegdbus/e-gdbus-book.c
index a3dbcd1..c6d2df5 100644
--- a/addressbook/libegdbus/e-gdbus-book.c
+++ b/addressbook/libegdbus/e-gdbus-book.c
@@ -44,6 +44,8 @@ enum
__OPEN_DONE_SIGNAL,
__REMOVE_METHOD,
__REMOVE_DONE_SIGNAL,
+ __REFRESH_METHOD,
+ __REFRESH_DONE_SIGNAL,
__GET_CONTACT_METHOD,
__GET_CONTACT_DONE_SIGNAL,
__GET_CONTACT_LIST_METHOD,
@@ -117,6 +119,7 @@ E_DECLARE_GDBUS_SIGNAL_EMISSION_HOOK_STRV (GDBUS_BOOK_INTERFACE_NAME, opened)
E_DECLARE_GDBUS_METHOD_DONE_EMISSION_HOOK_ASYNC_VOID (GDBUS_BOOK_INTERFACE_NAME, open)
E_DECLARE_GDBUS_METHOD_DONE_EMISSION_HOOK_ASYNC_VOID (GDBUS_BOOK_INTERFACE_NAME, remove)
+E_DECLARE_GDBUS_METHOD_DONE_EMISSION_HOOK_ASYNC_VOID (GDBUS_BOOK_INTERFACE_NAME, refresh)
E_DECLARE_GDBUS_METHOD_DONE_EMISSION_HOOK_ASYNC_STRING (GDBUS_BOOK_INTERFACE_NAME, get_contact)
E_DECLARE_GDBUS_METHOD_DONE_EMISSION_HOOK_ASYNC_STRV (GDBUS_BOOK_INTERFACE_NAME, get_contact_list)
E_DECLARE_GDBUS_METHOD_DONE_EMISSION_HOOK_ASYNC_STRING (GDBUS_BOOK_INTERFACE_NAME, add_contact)
@@ -145,6 +148,7 @@ e_gdbus_book_default_init (EGdbusBookIface *iface)
/* GObject signals definitions for D-Bus methods: */
E_INIT_GDBUS_METHOD_ASYNC_BOOLEAN__VOID (EGdbusBookIface, "open", open, __OPEN_METHOD, __OPEN_DONE_SIGNAL)
E_INIT_GDBUS_METHOD_ASYNC_VOID__VOID (EGdbusBookIface, "remove", remove, __REMOVE_METHOD, __REMOVE_DONE_SIGNAL)
+ E_INIT_GDBUS_METHOD_ASYNC_VOID__VOID (EGdbusBookIface, "refresh", refresh, __REFRESH_METHOD, __REFRESH_DONE_SIGNAL)
E_INIT_GDBUS_METHOD_ASYNC_STRING__STRING(EGdbusBookIface, "getContact", get_contact, __GET_CONTACT_METHOD, __GET_CONTACT_DONE_SIGNAL)
E_INIT_GDBUS_METHOD_ASYNC_STRING__STRV (EGdbusBookIface, "getContactList", get_contact_list, __GET_CONTACT_LIST_METHOD, __GET_CONTACT_LIST_DONE_SIGNAL)
E_INIT_GDBUS_METHOD_ASYNC_STRING__STRING(EGdbusBookIface, "addContact", add_contact, __ADD_CONTACT_METHOD, __ADD_CONTACT_DONE_SIGNAL)
@@ -200,6 +204,26 @@ e_gdbus_book_call_remove_sync (GDBusProxy *proxy, GCancellable *cancellable, GEr
}
void
+e_gdbus_book_call_refresh (GDBusProxy *proxy, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
+{
+ e_gdbus_proxy_call_void ("refresh", e_gdbus_book_call_refresh, E_GDBUS_ASYNC_OP_KEEPER (proxy), cancellable, callback, user_data);
+}
+
+gboolean
+e_gdbus_book_call_refresh_finish (GDBusProxy *proxy, GAsyncResult *result, GError **error)
+{
+ return e_gdbus_proxy_finish_call_void (E_GDBUS_ASYNC_OP_KEEPER (proxy), result, error, e_gdbus_book_call_refresh);
+}
+
+gboolean
+e_gdbus_book_call_refresh_sync (GDBusProxy *proxy, GCancellable *cancellable, GError **error)
+{
+ return e_gdbus_proxy_call_sync_void__void (proxy, cancellable, error,
+ e_gdbus_book_call_refresh,
+ e_gdbus_book_call_refresh_finish);
+}
+
+void
e_gdbus_book_call_get_contact (GDBusProxy *proxy, const gchar *in_uid, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
{
e_gdbus_proxy_call_string ("getContact", e_gdbus_book_call_get_contact, E_GDBUS_ASYNC_OP_KEEPER (proxy), in_uid, cancellable, callback, user_data);
@@ -478,6 +502,7 @@ e_gdbus_book_emit_ ## _mname ## _done (EGdbusBook *object, guint arg_opid, const
DECLARE_EMIT_DONE_SIGNAL_0 (open, __OPEN_DONE_SIGNAL)
DECLARE_EMIT_DONE_SIGNAL_0 (remove, __REMOVE_DONE_SIGNAL)
+DECLARE_EMIT_DONE_SIGNAL_0 (refresh, __REFRESH_DONE_SIGNAL)
DECLARE_EMIT_DONE_SIGNAL_1 (get_contact, __GET_CONTACT_DONE_SIGNAL, const gchar *)
DECLARE_EMIT_DONE_SIGNAL_1 (get_contact_list, __GET_CONTACT_LIST_DONE_SIGNAL, const gchar * const *)
DECLARE_EMIT_DONE_SIGNAL_1 (add_contact, __ADD_CONTACT_DONE_SIGNAL, const gchar *)
@@ -528,6 +553,7 @@ E_DECLARE_GDBUS_NOTIFY_SIGNAL_1 (book, opened, error, "as")
E_DECLARE_GDBUS_ASYNC_METHOD_1 (book, open, only_if_exists, "b")
E_DECLARE_GDBUS_ASYNC_METHOD_0 (book, remove)
+E_DECLARE_GDBUS_ASYNC_METHOD_0 (book, refresh)
E_DECLARE_GDBUS_ASYNC_METHOD_1_WITH_RETURN (book, getContact, uid, "s", vcard, "s")
E_DECLARE_GDBUS_ASYNC_METHOD_1_WITH_RETURN (book, getContactList, query, "s", vcards, "as")
E_DECLARE_GDBUS_ASYNC_METHOD_1_WITH_RETURN (book, addContact, vcard, "s", uid, "s")
@@ -546,6 +572,7 @@ static const GDBusMethodInfo * const e_gdbus_book_method_info_pointers[] =
{
&E_DECLARED_GDBUS_METHOD_INFO_NAME (book, open),
&E_DECLARED_GDBUS_METHOD_INFO_NAME (book, remove),
+ &E_DECLARED_GDBUS_METHOD_INFO_NAME (book, refresh),
&E_DECLARED_GDBUS_METHOD_INFO_NAME (book, getContact),
&E_DECLARED_GDBUS_METHOD_INFO_NAME (book, getContactList),
&E_DECLARED_GDBUS_METHOD_INFO_NAME (book, addContact),
@@ -571,6 +598,7 @@ static const GDBusSignalInfo * const e_gdbus_book_signal_info_pointers[] =
&E_DECLARED_GDBUS_SIGNAL_INFO_NAME (book, open_done),
&E_DECLARED_GDBUS_SIGNAL_INFO_NAME (book, remove_done),
+ &E_DECLARED_GDBUS_SIGNAL_INFO_NAME (book, refresh_done),
&E_DECLARED_GDBUS_SIGNAL_INFO_NAME (book, getContact_done),
&E_DECLARED_GDBUS_SIGNAL_INFO_NAME (book, getContactList_done),
&E_DECLARED_GDBUS_SIGNAL_INFO_NAME (book, addContact_done),
@@ -775,6 +803,7 @@ e_gdbus_book_proxy_init (EGdbusBookProxy *proxy)
E_GDBUS_CONNECT_METHOD_DONE_SIGNAL_VOID (open);
E_GDBUS_CONNECT_METHOD_DONE_SIGNAL_VOID (remove);
+ E_GDBUS_CONNECT_METHOD_DONE_SIGNAL_VOID (refresh);
E_GDBUS_CONNECT_METHOD_DONE_SIGNAL_STRING (get_contact);
E_GDBUS_CONNECT_METHOD_DONE_SIGNAL_STRV (get_contact_list);
E_GDBUS_CONNECT_METHOD_DONE_SIGNAL_STRING (add_contact);
diff --git a/addressbook/libegdbus/e-gdbus-book.h b/addressbook/libegdbus/e-gdbus-book.h
index 0249539..ae0dd9e 100644
--- a/addressbook/libegdbus/e-gdbus-book.h
+++ b/addressbook/libegdbus/e-gdbus-book.h
@@ -125,6 +125,9 @@ struct _EGdbusBookIface
gboolean (*handle_remove) (EGdbusBook *object, GDBusMethodInvocation *invocation);
void (*remove_done) (EGdbusBook *object, guint arg_opid, const GError *arg_error);
+ gboolean (*handle_refresh) (EGdbusBook *object, GDBusMethodInvocation *invocation);
+ void (*refresh_done) (EGdbusBook *object, guint arg_opid, const GError *arg_error);
+
gboolean (*handle_get_contact) (EGdbusBook *object, GDBusMethodInvocation *invocation, const gchar *in_uid);
void (*get_contact_done) (EGdbusBook *object, guint arg_opid, const GError *arg_error, gchar **out_vcard);
@@ -167,6 +170,10 @@ void e_gdbus_book_call_remove (GDBusProxy *proxy, GCancellable *cancellable, GA
gboolean e_gdbus_book_call_remove_finish (GDBusProxy *proxy, GAsyncResult *result, GError **error);
gboolean e_gdbus_book_call_remove_sync (GDBusProxy *proxy, GCancellable *cancellable, GError **error);
+void e_gdbus_book_call_refresh (GDBusProxy *proxy, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
+gboolean e_gdbus_book_call_refresh_finish (GDBusProxy *proxy, GAsyncResult *result, GError **error);
+gboolean e_gdbus_book_call_refresh_sync (GDBusProxy *proxy, GCancellable *cancellable, GError **error);
+
void e_gdbus_book_call_get_contact (GDBusProxy *proxy, const gchar *in_uid, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
gboolean e_gdbus_book_call_get_contact_finish (GDBusProxy *proxy, GAsyncResult *result, gchar **out_vcard, GError **error);
gboolean e_gdbus_book_call_get_contact_sync (GDBusProxy *proxy, const gchar *in_uid, gchar **out_vcard, GCancellable *cancellable, GError **error);
@@ -220,6 +227,7 @@ gboolean e_gdbus_book_call_close_sync (GDBusProxy *proxy, GCancellable *cancella
/* D-Bus Methods Completion Helpers */
#define e_gdbus_book_complete_open e_gdbus_complete_async_method
#define e_gdbus_book_complete_remove e_gdbus_complete_async_method
+#define e_gdbus_book_complete_refresh e_gdbus_complete_async_method
#define e_gdbus_book_complete_get_contact e_gdbus_complete_async_method
#define e_gdbus_book_complete_get_contact_list e_gdbus_complete_async_method
#define e_gdbus_book_complete_add_contact e_gdbus_complete_async_method
@@ -235,6 +243,7 @@ gboolean e_gdbus_book_call_close_sync (GDBusProxy *proxy, GCancellable *cancella
void e_gdbus_book_emit_open_done (EGdbusBook *object, guint arg_opid, const GError *arg_error);
void e_gdbus_book_emit_remove_done (EGdbusBook *object, guint arg_opid, const GError *arg_error);
+void e_gdbus_book_emit_refresh_done (EGdbusBook *object, guint arg_opid, const GError *arg_error);
void e_gdbus_book_emit_get_contact_done (EGdbusBook *object, guint arg_opid, const GError *arg_error, const gchar *out_vcard);
void e_gdbus_book_emit_get_contact_list_done (EGdbusBook *object, guint arg_opid, const GError *arg_error, const gchar * const *out_vcards);
void e_gdbus_book_emit_add_contact_done (EGdbusBook *object, guint arg_opid, const GError *arg_error, const gchar *out_uid);
diff --git a/calendar/libecal/e-cal-client.c b/calendar/libecal/e-cal-client.c
index 9b5c47a..ad6b4e8 100644
--- a/calendar/libecal/e-cal-client.c
+++ b/calendar/libecal/e-cal-client.c
@@ -973,25 +973,6 @@ e_cal_client_check_save_schedules (ECalClient *client)
}
/**
- * e_cal_client_check_refresh_supported:
- * @client: A calendar client.
- *
- * Checks whether a calendar supports explicit refreshing (see e_cal_client_refresh()).
- *
- * Returns: TRUE if the calendar supports refreshing, FALSE otherwise.
- *
- * Since: 3.2
- **/
-gboolean
-e_cal_client_check_refresh_supported (ECalClient *client)
-{
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
-
- return e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED);
-}
-
-/**
* e_cal_client_check_organizer_must_attend:
* @client: A calendar client.
*
@@ -1894,6 +1875,40 @@ cal_client_remove_sync (EClient *client, GCancellable *cancellable, GError **err
return e_client_proxy_call_sync_void__void (client, cancellable, error, e_gdbus_cal_call_remove_sync);
}
+static void
+cal_client_refresh (EClient *client, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
+{
+ e_client_proxy_call_void (client, cancellable, callback, user_data, cal_client_refresh,
+ e_gdbus_cal_call_refresh,
+ e_gdbus_cal_call_refresh_finish, NULL, NULL, NULL, NULL);
+}
+
+static gboolean
+cal_client_refresh_finish (EClient *client, GAsyncResult *result, GError **error)
+{
+ return e_client_proxy_call_finish_void (client, result, error, cal_client_refresh);
+}
+
+static gboolean
+cal_client_refresh_sync (EClient *client, GCancellable *cancellable, GError **error)
+{
+ ECalClient *cal_client;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
+
+ cal_client = E_CAL_CLIENT (client);
+ g_return_val_if_fail (cal_client != NULL, FALSE);
+ g_return_val_if_fail (cal_client->priv != NULL, FALSE);
+
+ if (!cal_client->priv->gdbus_cal) {
+ set_proxy_gone_error (error);
+ return FALSE;
+ }
+
+ return e_client_proxy_call_sync_void__void (client, cancellable, error, e_gdbus_cal_call_refresh_sync);
+}
+
static gboolean
complete_string_exchange (gboolean res, gchar *out_string, gchar **result, GError **error)
{
@@ -2027,72 +2042,6 @@ e_cal_client_get_default_object_sync (ECalClient *client, icalcomponent **icalco
}
/**
- * e_cal_client_refresh:
- * @client: an #ECalClient
- * @cancellable: a #GCancellable; can be %NULL
- * @callback: callback to call when a result is ready
- * @user_data: user data for the @callback
- *
- * Invokes refresh on a calendar. See @e_cal_client_get_refresh_supported().
- * The call is finished by e_cal_client_refresh_finish() from
- * the @callback.
- *
- * Since: 3.2
- **/
-void
-e_cal_client_refresh (ECalClient *client, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
-{
- e_client_proxy_call_void (E_CLIENT (client), cancellable, callback, user_data, e_cal_client_refresh,
- e_gdbus_cal_call_refresh,
- e_gdbus_cal_call_refresh_finish, NULL, NULL, NULL, NULL);
-}
-
-/**
- * e_cal_client_refresh_finish:
- * @client: an #ECalClient
- * @result: a #GAsyncResult
- * @error: (out): a #GError to set an error, if any
- *
- * Finishes previous call of e_cal_client_refresh().
- *
- * Returns: %TRUE if successful, %FALSE otherwise.
- *
- * Since: 3.2
- **/
-gboolean
-e_cal_client_refresh_finish (ECalClient *client, GAsyncResult *result, GError **error)
-{
- return e_client_proxy_call_finish_void (E_CLIENT (client), result, error, e_cal_client_refresh);
-}
-
-/**
- * e_cal_client_refresh_sync:
- * @client: an #ECalClient
- * @cancellable: a #GCancellable; can be %NULL
- * @error: (out): a #GError to set an error, if any
- *
- * Invokes refresh on a calendar. See @e_cal_client_get_refresh_supported().
- *
- * Returns: %TRUE if successful, %FALSE otherwise.
- *
- * Since: 3.2
- **/
-gboolean
-e_cal_client_refresh_sync (ECalClient *client, GCancellable *cancellable, GError **error)
-{
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
- g_return_val_if_fail (client->priv != NULL, FALSE);
-
- if (!client->priv->gdbus_cal) {
- set_proxy_gone_error (error);
- return FALSE;
- }
-
- return e_client_proxy_call_sync_void__void (E_CLIENT (client), cancellable, error, e_gdbus_cal_call_refresh_sync);
-}
-
-/**
* e_cal_client_get_object:
* @client: an #ECalClient
* @uid: Unique identifier for a calendar component.
@@ -4141,6 +4090,9 @@ e_cal_client_class_init (ECalClientClass *klass)
client_class->remove = cal_client_remove;
client_class->remove_finish = cal_client_remove_finish;
client_class->remove_sync = cal_client_remove_sync;
+ client_class->refresh = cal_client_refresh;
+ client_class->refresh_finish = cal_client_refresh_finish;
+ client_class->refresh_sync = cal_client_refresh_sync;
signals[FREE_BUSY_DATA] = g_signal_new (
"free-busy-data",
diff --git a/calendar/libecal/e-cal-client.h b/calendar/libecal/e-cal-client.h
index 00278cd..8f2f726 100644
--- a/calendar/libecal/e-cal-client.h
+++ b/calendar/libecal/e-cal-client.h
@@ -106,7 +106,6 @@ void e_cal_client_set_default_timezone (ECalClient *client, /* const */ icalti
/* Check predefined capabilities */
gboolean e_cal_client_check_one_alarm_only (ECalClient *client);
gboolean e_cal_client_check_save_schedules (ECalClient *client);
-gboolean e_cal_client_check_refresh_supported (ECalClient *client);
gboolean e_cal_client_check_organizer_must_attend(ECalClient *client);
gboolean e_cal_client_check_organizer_must_accept(ECalClient *client);
gboolean e_cal_client_check_recurrences_no_master(ECalClient *client);
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 7d70e98..9e1f89d 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -2272,7 +2272,7 @@ e_cal_get_organizer_must_accept (ECal *ecal)
*
* Since: 2.30
*
- * Deprecated: 3.2: Use e_cal_client_check_refresh_supported() instead.
+ * Deprecated: 3.2: Use e_client_check_refresh_supported() instead.
*/
gboolean
e_cal_get_refresh_supported (ECal *ecal)
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index 3349770..a65051f 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -988,7 +988,11 @@ e_cal_backend_remove (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancel
* @cancellable: a #GCancellable for the operation
*
* Refreshes the calendar being accessed by the given backend.
- * This might be finished with e_data_cal_respond_refresh().
+ * This might be finished with e_data_cal_respond_refresh(),
+ * and it might be called as soon as possible; it doesn't mean
+ * that the refreshing is done after calling that, the backend
+ * is only notifying client whether it started the refresh process
+ * or not.
*
* Since: 2.30
**/
@@ -997,10 +1001,11 @@ e_cal_backend_refresh (ECalBackend *backend, EDataCal *cal, guint32 opid, GCance
{
g_return_if_fail (backend != NULL);
g_return_if_fail (E_IS_CAL_BACKEND (backend));
- g_return_if_fail (E_CAL_BACKEND_GET_CLASS (backend)->refresh != NULL);
if (e_cal_backend_is_opening (backend))
e_data_cal_respond_refresh (cal, opid, EDC_OPENING_ERROR);
+ else if (!E_CAL_BACKEND_GET_CLASS (backend)->refresh)
+ e_data_cal_respond_refresh (cal, opid, EDC_ERROR (UnsupportedMethod));
else
(* E_CAL_BACKEND_GET_CLASS (backend)->refresh) (backend, cal, opid, cancellable);
}
diff --git a/libedataserver/e-client.c b/libedataserver/e-client.c
index 1479a13..4e56f2d 100644
--- a/libedataserver/e-client.c
+++ b/libedataserver/e-client.c
@@ -555,6 +555,25 @@ e_client_check_capability (EClient *client, const gchar *capability)
return FALSE;
}
+/**
+ * e_client_check_refresh_supported:
+ * @client: A client.
+ *
+ * Checks whether a client supports explicit refreshing (see e_client_refresh()).
+ *
+ * Returns: TRUE if the client supports refreshing, FALSE otherwise.
+ *
+ * Since: 3.2
+ **/
+gboolean
+e_client_check_refresh_supported (EClient *client)
+{
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
+
+ return e_client_check_capability (client, "refresh-supported");
+}
+
/* capabilities - comma-separated list of capabilities; can be NULL to unset */
void
e_client_set_capabilities (EClient *client, const gchar *capabilities)
@@ -1252,6 +1271,93 @@ e_client_remove_sync (EClient *client, GCancellable *cancellable, GError **error
}
/**
+ * e_client_refresh:
+ * @client: an #EClient
+ * @cancellable: a #GCancellable; can be %NULL
+ * @callback: callback to call when a result is ready
+ * @user_data: user data for the @callback
+ *
+ * Initiates refresh on the @client. Finishing the method doesn't mean
+ * that the refresh is done, backend only notifies whether it started
+ * refreshing or not. Use e_client_check_refresh_supported() to check
+ * whether the backend supports this method.
+ * The call is finished by e_client_refresh_finish() from the @callback.
+ *
+ * Since: 3.2
+ **/
+void
+e_client_refresh (EClient *client, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
+{
+ EClientClass *klass;
+
+ g_return_if_fail (client != NULL);
+ g_return_if_fail (E_IS_CLIENT (client));
+ g_return_if_fail (client->priv != NULL);
+ g_return_if_fail (callback != NULL);
+
+ klass = E_CLIENT_GET_CLASS (client);
+ g_return_if_fail (klass != NULL);
+ g_return_if_fail (klass->refresh != NULL);
+
+ klass->refresh (client, cancellable, callback, user_data);
+}
+
+/**
+ * e_client_refresh_finish:
+ * @client: an #EClient
+ * @result: a #GAsyncResult
+ * @error: (out): a #GError to set an error, if any
+ *
+ * Finishes previous call of e_client_refresh().
+ *
+ * Returns: %TRUE if successful, %FALSE otherwise.
+ *
+ * Since: 3.2
+ **/
+gboolean
+e_client_refresh_finish (EClient *client, GAsyncResult *result, GError **error)
+{
+ EClientClass *klass;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
+ g_return_val_if_fail (client->priv != NULL, FALSE);
+
+ klass = E_CLIENT_GET_CLASS (client);
+ g_return_val_if_fail (klass != NULL, FALSE);
+ g_return_val_if_fail (klass->refresh_finish != NULL, FALSE);
+
+ return klass->refresh_finish (client, result, error);
+}
+
+/**
+ * e_client_refresh_sync:
+ * @client: an #EClient
+ * @cancellable: a #GCancellable; can be %NULL
+ * @error: (out): a #GError to set an error, if any
+ *
+ * Initiates refresh on the @client. Finishing the method doesn't mean
+ * that the refresh is done, backend only notifies whether it started
+ * refreshing or not. Use e_client_check_refresh_supported() to check
+ * whether the backend supports this method.
+ *
+ * Returns: %TRUE if successful, %FALSE otherwise.
+ *
+ * Since: 3.2
+ **/
+gboolean
+e_client_refresh_sync (EClient *client, GCancellable *cancellable, GError **error)
+{
+ EClientClass *klass;
+
+ klass = E_CLIENT_GET_CLASS (client);
+ g_return_val_if_fail (klass != NULL, FALSE);
+ g_return_val_if_fail (klass->refresh_sync != NULL, FALSE);
+
+ return klass->refresh_sync (client, cancellable, error);
+}
+
+/**
* e_client_util_slist_to_strv:
* @strings: a #GSList of strings (const gchar *)
*
diff --git a/libedataserver/e-client.h b/libedataserver/e-client.h
index 5db9afb..0d6f793 100644
--- a/libedataserver/e-client.h
+++ b/libedataserver/e-client.h
@@ -99,6 +99,10 @@ struct _EClientClass {
gboolean (* remove_finish) (EClient *client, GAsyncResult *result, GError **error);
gboolean (* remove_sync) (EClient *client, GCancellable *cancellable, GError **error);
+ void (* refresh) (EClient *client, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
+ gboolean (* refresh_finish) (EClient *client, GAsyncResult *result, GError **error);
+ gboolean (* refresh_sync) (EClient *client, GCancellable *cancellable, GError **error);
+
void (* handle_authentication) (EClient *client, const ECredentials *credentials);
gchar * (* retrieve_capabilities) (EClient *client);
@@ -115,6 +119,7 @@ ESource * e_client_get_source (EClient *client);
const gchar * e_client_get_uri (EClient *client);
const GSList * e_client_get_capabilities (EClient *client);
gboolean e_client_check_capability (EClient *client, const gchar *capability);
+gboolean e_client_check_refresh_supported (EClient *client);
gboolean e_client_is_readonly (EClient *client);
gboolean e_client_is_online (EClient *client);
gboolean e_client_is_opened (EClient *client);
@@ -137,6 +142,10 @@ void e_client_remove (EClient *client, GCancellable *cancellable, GAsyncRead
gboolean e_client_remove_finish (EClient *client, GAsyncResult *result, GError **error);
gboolean e_client_remove_sync (EClient *client, GCancellable *cancellable, GError **error);
+void e_client_refresh (EClient *client, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
+gboolean e_client_refresh_finish (EClient *client, GAsyncResult *result, GError **error);
+gboolean e_client_refresh_sync (EClient *client, GCancellable *cancellable, GError **error);
+
/* utility functions */
gchar ** e_client_util_slist_to_strv (const GSList *strings);
GSList * e_client_util_strv_to_slist (const gchar * const *strv);
diff --git a/tests/libebook/client/Makefile.am b/tests/libebook/client/Makefile.am
index 327659b..9f1b832 100644
--- a/tests/libebook/client/Makefile.am
+++ b/tests/libebook/client/Makefile.am
@@ -21,6 +21,7 @@ libclient_test_utils_la_LIBADD = \
TESTS = \
test-client-remove \
test-client-examine \
+ test-client-refresh \
test-client-add-contact \
test-client-get-contact \
test-client-get-view \
@@ -69,6 +70,8 @@ test_client_get_view_LDADD=$(TEST_LIBS)
test_client_get_view_CPPFLAGS=$(TEST_CPPFLAGS)
test_client_modify_contact_LDADD=$(TEST_LIBS)
test_client_modify_contact_CPPFLAGS=$(TEST_CPPFLAGS)
+test_client_refresh_LDADD=$(TEST_LIBS)
+test_client_refresh_CPPFLAGS=$(TEST_CPPFLAGS)
test_client_remove_LDADD=$(TEST_LIBS)
test_client_remove_CPPFLAGS=$(TEST_CPPFLAGS)
test_client_remove_contact_LDADD=$(TEST_LIBS)
diff --git a/tests/libebook/client/test-client-refresh.c b/tests/libebook/client/test-client-refresh.c
new file mode 100644
index 0000000..37db6df
--- /dev/null
+++ b/tests/libebook/client/test-client-refresh.c
@@ -0,0 +1,114 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <string.h>
+#include <libebook/e-book-client.h>
+
+#include "client-test-utils.h"
+
+static gboolean
+test_sync (EBookClient *book_client)
+{
+ GError *error = NULL;
+
+ g_print ("Refresh supported: %s\n", e_client_check_refresh_supported (E_CLIENT (book_client)) ? "yes" : "no");
+
+ if (!e_client_refresh_sync (E_CLIENT (book_client), NULL, &error)) {
+ report_error ("refresh sync", &error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* asynchronous callback with a main-loop running */
+static void
+async_refresh_result_ready (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ EBookClient *book_client;
+ GError *error = NULL;
+
+ book_client = E_BOOK_CLIENT (source_object);
+
+ if (!e_client_refresh_finish (E_CLIENT (book_client), result, &error)) {
+ report_error ("refresh finish", &error);
+ stop_main_loop (1);
+ return;
+ }
+
+ stop_main_loop (0);
+}
+
+/* synchronously in idle with main-loop running */
+static gboolean
+test_sync_in_idle (gpointer user_data)
+{
+ EBookClient *book_client = user_data;
+
+ g_return_val_if_fail (book_client != NULL, FALSE);
+ g_return_val_if_fail (E_IS_BOOK_CLIENT (book_client), FALSE);
+
+ if (!test_sync (book_client)) {
+ stop_main_loop (1);
+ return FALSE;
+ }
+
+ g_print ("Refresh supported: %s\n", e_client_check_refresh_supported (E_CLIENT (book_client)) ? "yes" : "no");
+
+ e_client_refresh (E_CLIENT (book_client), NULL, async_refresh_result_ready, NULL);
+
+ return FALSE;
+}
+
+/* synchronously in a dedicated thread with main-loop running */
+static gpointer
+test_sync_in_thread (gpointer user_data)
+{
+ if (!test_sync (user_data)) {
+ stop_main_loop (1);
+ return NULL;
+ }
+
+ g_idle_add (test_sync_in_idle, user_data);
+
+ return NULL;
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+ EBookClient *book_client;
+ GError *error = NULL;
+
+ main_initialize ();
+
+ book_client = new_temp_client (NULL);
+ g_return_val_if_fail (book_client != NULL, FALSE);
+
+ if (!e_client_open_sync (E_CLIENT (book_client), FALSE, NULL, &error)) {
+ report_error ("client open sync", &error);
+ g_object_unref (book_client);
+ return 1;
+ }
+
+ /* synchronously without main-loop */
+ if (!test_sync (book_client)) {
+ g_object_unref (book_client);
+ return 1;
+ }
+
+ start_in_thread_with_main_loop (test_sync_in_thread, book_client);
+
+ if (!e_client_remove_sync (E_CLIENT (book_client), NULL, &error)) {
+ report_error ("client remove sync", &error);
+ g_object_unref (book_client);
+ return 1;
+ }
+
+ g_object_unref (book_client);
+
+ if (get_main_loop_stop_result () == 0)
+ g_print ("Test finished successfully.\n");
+
+ return get_main_loop_stop_result ();
+}
diff --git a/tests/libecal/client/test-client-refresh.c b/tests/libecal/client/test-client-refresh.c
index dc258df..5ebae91 100644
--- a/tests/libecal/client/test-client-refresh.c
+++ b/tests/libecal/client/test-client-refresh.c
@@ -12,7 +12,9 @@ test_sync (ECalClient *cal_client)
{
GError *error = NULL;
- if (!e_cal_client_refresh_sync (cal_client, NULL, &error)) {
+ g_print ("Refresh supported: %s\n", e_client_check_refresh_supported (E_CLIENT (cal_client)) ? "yes" : "no");
+
+ if (!e_client_refresh_sync (E_CLIENT (cal_client), NULL, &error)) {
report_error ("refresh sync", &error);
return FALSE;
}
@@ -29,7 +31,7 @@ async_refresh_result_ready (GObject *source_object, GAsyncResult *result, gpoint
cal_client = E_CAL_CLIENT (source_object);
- if (!e_cal_client_refresh_finish (cal_client, result, &error)) {
+ if (!e_client_refresh_finish (E_CLIENT (cal_client), result, &error)) {
report_error ("refresh finish", &error);
stop_main_loop (1);
return;
@@ -52,7 +54,9 @@ test_sync_in_idle (gpointer user_data)
return FALSE;
}
- e_cal_client_refresh (cal_client, NULL, async_refresh_result_ready, NULL);
+ g_print ("Refresh supported: %s\n", e_client_check_refresh_supported (E_CLIENT (cal_client)) ? "yes" : "no");
+
+ e_client_refresh (E_CLIENT (cal_client), NULL, async_refresh_result_ready, NULL);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]