[evolution-data-server/openismus-work] Mega-Commit changing the API of fetching the initial addressbook locale.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work] Mega-Commit changing the API of fetching the initial addressbook locale.
- Date: Tue, 28 May 2013 08:13:28 +0000 (UTC)
commit c8187c9831bbcb5f5ba547c5d0eff0ac77b94c29
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Tue May 28 17:10:32 2013 +0900
Mega-Commit changing the API of fetching the initial addressbook locale.
This is a bit of a messy patch to support the same API backported into 3.6,
what we've done is extend the addressboook 'open' D-Bus API to report the
locale of the addressbook initially. Using the previously created get_locale()
D-Bus API was broken as it caused lockups when an addressbook is opened from
a dedicated thread (as test-client-view-operations does).
This patch is just a huge workaround to avoid the lockup in
test-client-view-operations.
addressbook/libebook/e-book-client.c | 40 +++++++++++-------------------
addressbook/libebook/e-book.c | 4 +-
addressbook/libedata-book/e-data-book.c | 8 ++++-
addressbook/libegdbus/e-gdbus-book.c | 31 ++++++++++++++----------
addressbook/libegdbus/e-gdbus-book.h | 8 +++---
libedataserver/e-gdbus-templates.c | 16 ++++++++++++
libedataserver/e-gdbus-templates.h | 5 ++++
7 files changed, 66 insertions(+), 46 deletions(-)
---
diff --git a/addressbook/libebook/e-book-client.c b/addressbook/libebook/e-book-client.c
index 8e2b36f..1132459 100644
--- a/addressbook/libebook/e-book-client.c
+++ b/addressbook/libebook/e-book-client.c
@@ -1048,8 +1048,8 @@ book_client_open (EClient *client,
gpointer user_data)
{
e_client_proxy_call_boolean (client, only_if_exists, cancellable, callback, user_data,
book_client_open,
- e_gdbus_book_call_open,
- e_gdbus_book_call_open_finish, NULL, NULL, NULL, NULL);
+ e_gdbus_book_call_open, NULL, NULL,
+ e_gdbus_book_call_open_finish, NULL, NULL);
}
static gboolean
@@ -1058,14 +1058,13 @@ book_client_open_finish (EClient *client,
GError **error)
{
EBookClient *book_client;
- GError *local_error = NULL;
gchar *locale = NULL;
g_return_val_if_fail (E_IS_BOOK_CLIENT (client), FALSE);
book_client = E_BOOK_CLIENT (client);
- if (!e_client_proxy_call_finish_void (client, result, error, book_client_open))
+ if (!e_client_proxy_call_finish_string (client, result, &locale, error, book_client_open))
return FALSE;
/**
@@ -1082,19 +1081,14 @@ book_client_open_finish (EClient *client,
*/
if (book_client->priv->direct_book &&
!e_data_book_open_sync (book_client->priv->direct_book,
- FALSE /* only_if_exists */, NULL /* cancellable */, error))
- return FALSE;
-
- /* More cheating... quick fix for back port to 3.6 branch */
- if (!e_client_proxy_call_sync_void__string (client, &locale, NULL, &local_error,
- e_gdbus_book_call_get_locale_sync)) {
- g_warning ("Failed to fetch initial locale: %s", local_error->message);
- g_error_free (local_error);
- } else {
- book_client_set_locale (book_client, locale);
+ FALSE /* only_if_exists */, NULL /* cancellable */, error)) {
g_free (locale);
+ return FALSE;
}
+ book_client_set_locale (book_client, locale);
+ g_free (locale);
+
return TRUE;
}
@@ -1106,7 +1100,6 @@ book_client_open_sync (EClient *client,
{
EBookClient *book_client;
gchar *locale = NULL;
- GError *local_error = NULL;
g_return_val_if_fail (E_IS_BOOK_CLIENT (client), FALSE);
@@ -1117,23 +1110,20 @@ book_client_open_sync (EClient *client,
return FALSE;
}
- if (!e_client_proxy_call_sync_boolean__void (client, only_if_exists, cancellable, error,
e_gdbus_book_call_open_sync))
+ if (!e_client_proxy_call_sync_boolean__string (client, only_if_exists, &locale, cancellable, error,
+ e_gdbus_book_call_open_sync))
return FALSE;
if (book_client->priv->direct_book &&
!e_data_book_open_sync (book_client->priv->direct_book,
- only_if_exists, cancellable, error))
- return FALSE;
-
- if (!e_client_proxy_call_sync_void__string (client, &locale, cancellable, &local_error,
- e_gdbus_book_call_get_locale_sync)) {
- g_warning ("Failed to fetch initial locale: %s", local_error->message);
- g_error_free (local_error);
- } else {
- book_client_set_locale (book_client, locale);
+ only_if_exists, cancellable, error)) {
g_free (locale);
+ return FALSE;
}
+ book_client_set_locale (book_client, locale);
+ g_free (locale);
+
return TRUE;
}
diff --git a/addressbook/libebook/e-book.c b/addressbook/libebook/e-book.c
index 9aa6bc7..fda73df 100644
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@ -2343,7 +2343,7 @@ e_book_open (EBook *book,
e_return_error_if_fail (
book->priv->gdbus_book, E_BOOK_ERROR_REPOSITORY_OFFLINE);
- if (!e_gdbus_book_call_open_sync (book->priv->gdbus_book, only_if_exists, NULL, &err)) {
+ if (!e_gdbus_book_call_open_sync (book->priv->gdbus_book, only_if_exists, NULL, NULL, &err)) {
unwrap_gerror (err, error);
@@ -2366,7 +2366,7 @@ open_reply (GObject *gdbus_book,
EBookAsyncCallback excb = data->excallback;
EBookCallback cb = data->callback;
- e_gdbus_book_call_open_finish (G_DBUS_PROXY (gdbus_book), res, &error);
+ e_gdbus_book_call_open_finish (G_DBUS_PROXY (gdbus_book), res, NULL, &error);
unwrap_gerror (error, &err);
diff --git a/addressbook/libedata-book/e-data-book.c b/addressbook/libedata-book/e-data-book.c
index cbcf5b3..7bcf307 100644
--- a/addressbook/libedata-book/e-data-book.c
+++ b/addressbook/libedata-book/e-data-book.c
@@ -1175,8 +1175,12 @@ e_data_book_respond_open (EDataBook *book,
/* Deliver the result to the caller */
direct_operation_complete (data);
- } else
- e_gdbus_book_emit_open_done (book->priv->gdbus_object, opid, error);
+ } else {
+ /* XXX Hack to propagate the initial locale through the 'open' call response */
+ const gchar *locale = e_book_backend_get_locale (book->priv->backend);
+
+ e_gdbus_book_emit_open_done (book->priv->gdbus_object, opid, error, locale);
+ }
if (error)
g_error_free (error);
diff --git a/addressbook/libegdbus/e-gdbus-book.c b/addressbook/libegdbus/e-gdbus-book.c
index fe9fd41..90930b2 100644
--- a/addressbook/libegdbus/e-gdbus-book.c
+++ b/addressbook/libegdbus/e-gdbus-book.c
@@ -129,8 +129,8 @@ E_DECLARE_GDBUS_SIGNAL_EMISSION_HOOK_STRV (GDBUS_BOOK_INTERFACE_NAME,
E_DECLARE_GDBUS_SIGNAL_EMISSION_HOOK_STRING (GDBUS_BOOK_INTERFACE_NAME,
locale_changed)
-E_DECLARE_GDBUS_METHOD_DONE_EMISSION_HOOK_ASYNC_VOID (GDBUS_BOOK_INTERFACE_NAME,
- open)
+E_DECLARE_GDBUS_METHOD_DONE_EMISSION_HOOK_ASYNC_STRING (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,
@@ -198,7 +198,7 @@ e_gdbus_book_default_init (EGdbusBookIface *iface)
__LOCALE_CHANGED_SIGNAL)
/* GObject signals definitions for D-Bus methods: */
- E_INIT_GDBUS_METHOD_ASYNC_BOOLEAN__VOID (
+ E_INIT_GDBUS_METHOD_ASYNC_BOOLEAN__STRING (
EGdbusBookIface,
"open",
open,
@@ -306,19 +306,21 @@ e_gdbus_book_call_open (GDBusProxy *proxy,
gboolean
e_gdbus_book_call_open_finish (GDBusProxy *proxy,
GAsyncResult *result,
+ gchar **out_locale,
GError **error)
{
- return e_gdbus_proxy_finish_call_void (E_GDBUS_ASYNC_OP_KEEPER (proxy), result, error,
e_gdbus_book_call_open);
+ return e_gdbus_proxy_finish_call_string (E_GDBUS_ASYNC_OP_KEEPER (proxy), result, out_locale, error,
e_gdbus_book_call_open);
}
gboolean
e_gdbus_book_call_open_sync (GDBusProxy *proxy,
gboolean in_only_if_exists,
+ gchar **out_locale,
GCancellable *cancellable,
GError **error)
{
- return e_gdbus_proxy_call_sync_boolean__void (
- proxy, in_only_if_exists, cancellable, error,
+ return e_gdbus_proxy_call_sync_boolean__string (
+ proxy, in_only_if_exists, out_locale, cancellable, error,
e_gdbus_book_call_open,
e_gdbus_book_call_open_finish);
}
@@ -799,8 +801,9 @@ e_gdbus_book_emit_ ## _mname ## _done (EGdbusBook *object, guint arg_opid, const
g_signal_emit (object, signals[_sig_id], 0, arg_opid, arg_error, out_par);
\
}
-DECLARE_EMIT_DONE_SIGNAL_0 (open,
- __OPEN_DONE_SIGNAL)
+DECLARE_EMIT_DONE_SIGNAL_1 (open,
+ __OPEN_DONE_SIGNAL,
+ const gchar *)
DECLARE_EMIT_DONE_SIGNAL_0 (remove,
__REMOVE_DONE_SIGNAL)
DECLARE_EMIT_DONE_SIGNAL_0 (refresh,
@@ -903,10 +906,12 @@ E_DECLARE_GDBUS_NOTIFY_SIGNAL_1 (book,
name_value,
"s")
-E_DECLARE_GDBUS_ASYNC_METHOD_1 (book,
- open,
- only_if_exists,
- "b")
+E_DECLARE_GDBUS_ASYNC_METHOD_1_WITH_RETURN (book,
+ open,
+ only_if_exists,
+ "b",
+ locale,
+ "s")
E_DECLARE_GDBUS_ASYNC_METHOD_0 (book,
remove)
E_DECLARE_GDBUS_ASYNC_METHOD_0 (book,
@@ -1229,7 +1234,7 @@ e_gdbus_book_proxy_init (EGdbusBookProxy *proxy)
proxy->priv = E_GDBUS_BOOK_PROXY_GET_PRIVATE (proxy);
proxy->priv->pending_ops = e_gdbus_async_op_keeper_create_pending_ops (E_GDBUS_ASYNC_OP_KEEPER
(proxy));
- E_GDBUS_CONNECT_METHOD_DONE_SIGNAL_VOID (open);
+ E_GDBUS_CONNECT_METHOD_DONE_SIGNAL_STRING (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);
diff --git a/addressbook/libegdbus/e-gdbus-book.h b/addressbook/libegdbus/e-gdbus-book.h
index a946971..54328e3 100644
--- a/addressbook/libegdbus/e-gdbus-book.h
+++ b/addressbook/libegdbus/e-gdbus-book.h
@@ -121,7 +121,7 @@ struct _EGdbusBookIface
/* Signal handlers for handling D-Bus method calls: */
gboolean (*handle_open) (EGdbusBook *object, GDBusMethodInvocation *invocation,
gboolean in_only_if_exists);
- void (*open_done) (EGdbusBook *object, guint arg_opid, const GError *arg_error);
+ void (*open_done) (EGdbusBook *object, guint arg_opid, const GError *arg_error,
gchar **out_locale);
gboolean (*handle_remove) (EGdbusBook *object, GDBusMethodInvocation *invocation);
void (*remove_done) (EGdbusBook *object, guint arg_opid, const GError *arg_error);
@@ -168,8 +168,8 @@ struct _EGdbusBookIface
/* D-Bus Methods */
void e_gdbus_book_call_open (GDBusProxy *proxy, gboolean in_only_if_exists, GCancellable
*cancellable, GAsyncReadyCallback callback, gpointer user_data);
-gboolean e_gdbus_book_call_open_finish (GDBusProxy *proxy, GAsyncResult *result, GError **error);
-gboolean e_gdbus_book_call_open_sync (GDBusProxy *proxy, gboolean in_only_if_exists, GCancellable
*cancellable, GError **error);
+gboolean e_gdbus_book_call_open_finish (GDBusProxy *proxy, GAsyncResult *result, gchar **out_locale,
GError **error);
+gboolean e_gdbus_book_call_open_sync (GDBusProxy *proxy, gboolean in_only_if_exists, gchar
**out_locale, GCancellable *cancellable, GError **error);
void e_gdbus_book_call_remove (GDBusProxy *proxy, GCancellable *cancellable, GAsyncReadyCallback
callback, gpointer user_data);
gboolean e_gdbus_book_call_remove_finish (GDBusProxy *proxy, GAsyncResult *result, GError **error);
@@ -251,7 +251,7 @@ gboolean e_gdbus_book_call_get_locale_sync (GDBusProxy *proxy, gchar **out_local
#define e_gdbus_book_complete_close e_gdbus_complete_sync_method_void
#define e_gdbus_book_complete_get_locale e_gdbus_complete_async_method
-void e_gdbus_book_emit_open_done (EGdbusBook *object, guint arg_opid, const GError
*arg_error);
+void e_gdbus_book_emit_open_done (EGdbusBook *object, guint arg_opid, const GError
*arg_error, const gchar *out_locale);
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);
diff --git a/libedataserver/e-gdbus-templates.c b/libedataserver/e-gdbus-templates.c
index 43743d0..d742439 100644
--- a/libedataserver/e-gdbus-templates.c
+++ b/libedataserver/e-gdbus-templates.c
@@ -1743,6 +1743,22 @@ e_gdbus_proxy_call_sync_boolean__void (GDBusProxy *proxy,
return e_gdbus_proxy_call_sync (proxy, cancellable, error, start_func, finish_func,
E_GDBUS_TYPE_BOOLEAN, &in_boolean, E_GDBUS_TYPE_VOID, NULL);
}
+gboolean
+e_gdbus_proxy_call_sync_boolean__string (GDBusProxy *proxy,
+ gboolean in_boolean,
+ gchar **out_string,
+ GCancellable *cancellable,
+ GError **error,
+ EGdbusCallStartBoolean start_func,
+ EGdbusCallFinishString finish_func)
+{
+ g_return_val_if_fail (proxy != NULL, FALSE);
+ g_return_val_if_fail (start_func != NULL, FALSE);
+ g_return_val_if_fail (finish_func != NULL, FALSE);
+
+ return e_gdbus_proxy_call_sync (proxy, cancellable, error, start_func, finish_func,
E_GDBUS_TYPE_BOOLEAN, &in_boolean, E_GDBUS_TYPE_STRING, out_string);
+}
+
/**
* e_gdbus_proxy_call_sync_string__void:
* @proxy:
diff --git a/libedataserver/e-gdbus-templates.h b/libedataserver/e-gdbus-templates.h
index 0c45d48..3f2995f 100644
--- a/libedataserver/e-gdbus-templates.h
+++ b/libedataserver/e-gdbus-templates.h
@@ -521,6 +521,10 @@ enum {
E_INIT_GDBUS_METHOD_CALL_BOOLEAN (_iface_struct, _dbus_sig_name_str, _sig_name_var, _method_sig_id)
\
E_INIT_GDBUS_METHOD_DONE_VOID (_iface_struct, _sig_name_var, _done_sig_id)
+#define E_INIT_GDBUS_METHOD_ASYNC_BOOLEAN__STRING(_iface_struct, _dbus_sig_name_str, _sig_name_var,
_method_sig_id, _done_sig_id) \
+ E_INIT_GDBUS_METHOD_CALL_BOOLEAN (_iface_struct, _dbus_sig_name_str, _sig_name_var, _method_sig_id)
\
+ E_INIT_GDBUS_METHOD_DONE_STRING (_iface_struct, _sig_name_var, _done_sig_id)
+
#define E_INIT_GDBUS_METHOD_ASYNC_UINT__VOID(_iface_struct, _dbus_sig_name_str, _sig_name_var,
_method_sig_id, _done_sig_id) \
E_INIT_GDBUS_METHOD_CALL_UINT (_iface_struct, _dbus_sig_name_str, _sig_name_var, _method_sig_id)
\
E_INIT_GDBUS_METHOD_DONE_VOID (_iface_struct, _sig_name_var, _done_sig_id)
@@ -719,6 +723,7 @@ gboolean e_gdbus_proxy_call_sync_void__string (GDBusProxy *proxy, gchar **out_st
gboolean e_gdbus_proxy_call_sync_void__strv (GDBusProxy *proxy, gchar ***out_strv, GCancellable
*cancellable, GError **error, EGdbusCallStartVoid start_func, EGdbusCallFinishStrv finish_func);
gboolean e_gdbus_proxy_call_sync_void__uint (GDBusProxy *proxy, guint *out_uint, GCancellable
*cancellable, GError **error, EGdbusCallStartVoid start_func, EGdbusCallFinishUint finish_func);
gboolean e_gdbus_proxy_call_sync_boolean__void (GDBusProxy *proxy, gboolean in_boolean, GCancellable
*cancellable, GError **error, EGdbusCallStartBoolean start_func, EGdbusCallFinishVoid finish_func);
+gboolean e_gdbus_proxy_call_sync_boolean__string(GDBusProxy *proxy, gboolean in_boolean, gchar **out_string,
GCancellable *cancellable, GError **error, EGdbusCallStartBoolean start_func, EGdbusCallFinishString
finish_func);
gboolean e_gdbus_proxy_call_sync_string__void (GDBusProxy *proxy, const gchar *in_string, GCancellable
*cancellable, GError **error, EGdbusCallStartString start_func, EGdbusCallFinishVoid finish_func);
gboolean e_gdbus_proxy_call_sync_strv__void (GDBusProxy *proxy, const gchar * const *in_strv,
GCancellable *cancellable, GError **error, EGdbusCallStartStrv start_func, EGdbusCallFinishVoid finish_func);
gboolean e_gdbus_proxy_call_sync_uint__void (GDBusProxy *proxy, guint in_uint, GCancellable *cancellable,
GError **error, EGdbusCallStartUint start_func, EGdbusCallFinishVoid finish_func);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]