summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-02-01 19:30:39 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-02-02 14:05:47 +0000
commit1d8fdd8e39ed535a8d8136c90c592c94b2ce09be (patch)
tree2277fff7304a7d2d2196593c524935cef6acd48f
parent5a621073aa3454e5f93fdb964c76f94f98fb6f04 (diff)
Complete results of TpProxy D-Bus calls in an idle
GAsyncResult guarantees to call your callback from the main loop. For historical reasons (basically "5 years ago I didn't know any better"), TpProxy does not: if the interface is missing or the proxy has been invalidated, the callback is called re-entrantly. I'm going to fix that in Telepathy 1.0, but for now, let's give GAsyncResult the correct semantics.
-rw-r--r--telepathy-glib/account-channel-request.c2
-rw-r--r--telepathy-glib/account-manager.c4
-rw-r--r--telepathy-glib/account.c33
-rw-r--r--telepathy-glib/base-client.c2
-rw-r--r--telepathy-glib/channel-dispatch-operation.c14
-rw-r--r--telepathy-glib/channel-dispatcher.c2
-rw-r--r--telepathy-glib/channel.c8
-rw-r--r--telepathy-glib/connection-aliasing.c2
-rw-r--r--telepathy-glib/connection-avatars.c2
-rw-r--r--telepathy-glib/connection-contact-info.c2
-rw-r--r--telepathy-glib/connection-contact-list.c10
-rw-r--r--telepathy-glib/connection.c4
-rw-r--r--telepathy-glib/contact.c2
-rw-r--r--telepathy-glib/file-transfer-channel.c6
-rw-r--r--telepathy-glib/stream-tube-channel.c4
-rw-r--r--telepathy-glib/text-channel.c18
16 files changed, 50 insertions, 65 deletions
diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c
index 4c221d156..bf7e30ed4 100644
--- a/telepathy-glib/account-channel-request.c
+++ b/telepathy-glib/account-channel-request.c
@@ -534,7 +534,7 @@ complete_result (TpAccountChannelRequest *self)
request_disconnect (self);
- g_simple_async_result_complete (self->priv->result);
+ g_simple_async_result_complete_in_idle (self->priv->result);
tp_clear_object (&self->priv->result);
}
diff --git a/telepathy-glib/account-manager.c b/telepathy-glib/account-manager.c
index e695f6b08..96483cf9e 100644
--- a/telepathy-glib/account-manager.c
+++ b/telepathy-glib/account-manager.c
@@ -1238,7 +1238,7 @@ _tp_account_manager_created_cb (TpAccountManager *proxy,
if (error != NULL)
{
g_simple_async_result_set_from_error (my_res, error);
- g_simple_async_result_complete (my_res);
+ g_simple_async_result_complete_in_idle (my_res);
return;
}
@@ -1247,7 +1247,7 @@ _tp_account_manager_created_cb (TpAccountManager *proxy,
if (account == NULL)
{
g_simple_async_result_take_error (my_res, e);
- g_simple_async_result_complete (my_res);
+ g_simple_async_result_complete_in_idle (my_res);
return;
}
diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index 355d23102..5b2fc88a2 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -562,7 +562,7 @@ _tp_account_got_all_storage_cb (TpProxy *proxy,
if (self->priv->storage_provider == NULL)
self->priv->storage_provider = g_strdup ("");
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
static void
@@ -2276,7 +2276,7 @@ _tp_account_property_set_cb (TpProxy *proxy,
g_simple_async_result_set_from_error (result, error);
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -2338,7 +2338,7 @@ tp_account_set_enabled_async (TpAccount *account,
}
static void
-_tp_account_reconnected_cb (TpAccount *proxy,
+_tp_account_void_cb (TpAccount *proxy,
const GError *error,
gpointer user_data,
GObject *weak_object)
@@ -2348,7 +2348,7 @@ _tp_account_reconnected_cb (TpAccount *proxy,
if (error != NULL)
g_simple_async_result_set_from_error (result, error);
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -2396,7 +2396,7 @@ tp_account_reconnect_async (TpAccount *account,
result = g_simple_async_result_new (G_OBJECT (account),
callback, user_data, tp_account_reconnect_finish);
- tp_cli_account_call_reconnect (account, -1, _tp_account_reconnected_cb,
+ tp_cli_account_call_reconnect (account, -1, _tp_account_void_cb,
result, NULL, G_OBJECT (account));
}
@@ -2550,7 +2550,7 @@ _tp_account_updated_cb (TpAccount *proxy,
g_simple_async_result_set_op_res_gpointer (result,
g_strdupv ((GStrv) reconnect_required), (GDestroyNotify) g_strfreev);
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (G_OBJECT (result));
}
@@ -2802,21 +2802,6 @@ tp_account_set_icon_name_finish (TpAccount *account,
_tp_implement_finish_void (account, tp_account_set_icon_name_finish);
}
-static void
-_tp_account_void_cb (TpAccount *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
-
- if (error != NULL)
- g_simple_async_result_set_from_error (result, error);
-
- g_simple_async_result_complete (result);
- g_object_unref (G_OBJECT (result));
-}
-
/**
* tp_account_remove_async:
* @account: a #TpAccount
@@ -3177,7 +3162,7 @@ _tp_account_got_avatar_cb (TpProxy *proxy,
(GDestroyNotify) g_array_unref);
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -3627,7 +3612,7 @@ _tp_account_get_storage_specific_information_cb (TpProxy *self,
(GDestroyNotify) g_hash_table_unref);
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -3712,7 +3697,7 @@ _tp_account_got_all_addressing_cb (TpProxy *proxy,
if (self->priv->uri_schemes == NULL)
self->priv->uri_schemes = g_new0 (gchar *, 1);
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
static void
diff --git a/telepathy-glib/base-client.c b/telepathy-glib/base-client.c
index 557feefcd..b42b5bd0a 100644
--- a/telepathy-glib/base-client.c
+++ b/telepathy-glib/base-client.c
@@ -3182,7 +3182,7 @@ delegate_channels_cb (TpChannelDispatcher *cd,
}
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
/**
diff --git a/telepathy-glib/channel-dispatch-operation.c b/telepathy-glib/channel-dispatch-operation.c
index c9ae5e4d7..6a4e3a97a 100644
--- a/telepathy-glib/channel-dispatch-operation.c
+++ b/telepathy-glib/channel-dispatch-operation.c
@@ -648,7 +648,7 @@ out:
if (e != NULL)
g_simple_async_result_set_from_error (result, e);
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
if (!prepared)
{
@@ -1079,7 +1079,7 @@ handle_with_cb (TpChannelDispatchOperation *self,
g_simple_async_result_set_from_error (result, error);
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -1167,7 +1167,7 @@ claim_cb (TpChannelDispatchOperation *self,
g_simple_async_result_set_from_error (result, error);
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -1339,7 +1339,7 @@ claim_with_cb (TpChannelDispatchOperation *self,
_tp_base_client_now_handling_channels (client, self->priv->channels);
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -1450,7 +1450,7 @@ claim_close_channels_cb (TpChannelDispatchOperation *self,
tp_channel_close_async (channel, channel_close_cb, NULL);
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -1580,7 +1580,7 @@ claim_leave_channels_cb (TpChannelDispatchOperation *self,
channel_leave_cb, NULL);
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -1691,7 +1691,7 @@ claim_destroy_channels_cb (TpChannelDispatchOperation *self,
tp_channel_destroy_async (channel, channel_destroy_cb, NULL);
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
diff --git a/telepathy-glib/channel-dispatcher.c b/telepathy-glib/channel-dispatcher.c
index 312304733..88d809a00 100644
--- a/telepathy-glib/channel-dispatcher.c
+++ b/telepathy-glib/channel-dispatcher.c
@@ -181,7 +181,7 @@ present_channel_cb (TpChannelDispatcher *cd,
g_simple_async_result_set_from_error (result, error);
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
/**
diff --git a/telepathy-glib/channel.c b/telepathy-glib/channel.c
index 73bf696b3..c6c3d09dd 100644
--- a/telepathy-glib/channel.c
+++ b/telepathy-glib/channel.c
@@ -741,7 +741,7 @@ tp_channel_get_initial_chat_states_cb (TpProxy *proxy,
/* else just ignore it and assume everyone was initially in the default
* Inactive state, unless we already saw a signal for them */
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
static void
@@ -1424,7 +1424,7 @@ got_password_flags_cb (TpChannel *self,
}
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
static void
@@ -2750,7 +2750,7 @@ channel_destroy_cb (TpChannel *channel,
return;
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -2875,7 +2875,7 @@ provide_password_cb (TpChannel *self,
TP_ERROR_AUTHENTICATION_FAILED, "Password was not correct");
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
/**
diff --git a/telepathy-glib/connection-aliasing.c b/telepathy-glib/connection-aliasing.c
index 9581f3653..785320a49 100644
--- a/telepathy-glib/connection-aliasing.c
+++ b/telepathy-glib/connection-aliasing.c
@@ -88,7 +88,7 @@ get_alias_flag_cb (TpConnection *self,
self->priv->alias_flags = flags;
finally:
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
void
diff --git a/telepathy-glib/connection-avatars.c b/telepathy-glib/connection-avatars.c
index d75e39188..ccb548dac 100644
--- a/telepathy-glib/connection-avatars.c
+++ b/telepathy-glib/connection-avatars.c
@@ -83,7 +83,7 @@ tp_connection_get_avatar_requirements_cb (TpProxy *proxy,
tp_asv_get_uint32 (properties, "MaximumAvatarBytes", NULL));
finally:
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
void
diff --git a/telepathy-glib/connection-contact-info.c b/telepathy-glib/connection-contact-info.c
index da9f78d45..9f4204d2f 100644
--- a/telepathy-glib/connection-contact-info.c
+++ b/telepathy-glib/connection-contact-info.c
@@ -473,7 +473,7 @@ tp_connection_get_contact_info_cb (TpProxy *proxy,
}
finally:
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
void
diff --git a/telepathy-glib/connection-contact-list.c b/telepathy-glib/connection-contact-list.c
index 862c04e89..ef42f16bc 100644
--- a/telepathy-glib/connection-contact-list.c
+++ b/telepathy-glib/connection-contact-list.c
@@ -287,7 +287,7 @@ got_contact_list_attributes_cb (TpConnection *self,
OUT:
if (result != NULL)
{
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
}
@@ -402,7 +402,7 @@ prepare_contact_list_props_cb (TpProxy *proxy,
self->priv->contact_list_state);
OUT:
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
void _tp_connection_prepare_contact_list_async (TpProxy *proxy,
@@ -612,7 +612,7 @@ prepare_contact_groups_cb (TpProxy *proxy,
g_ptr_array_add (self->priv->contact_groups, NULL);
OUT:
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
void
@@ -1645,7 +1645,7 @@ blocked_changed_head_ready (TpConnection *self)
_tp_connection_set_contact_blocked (self, contact);
}
- g_simple_async_result_complete (item->result);
+ g_simple_async_result_complete_in_idle (item->result);
}
blocked_changed_item_free (item);
@@ -1819,7 +1819,7 @@ request_blocked_contacts_cb (TpConnection *self,
{
DEBUG ("Error calling RequestBlockedContacts: %s", error->message);
g_simple_async_result_set_from_error (result, error);
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
return;
}
diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c
index a8e677f69..0b34bbee2 100644
--- a/telepathy-glib/connection.c
+++ b/telepathy-glib/connection.c
@@ -466,7 +466,7 @@ tp_connection_get_balance_cb (TpProxy *proxy,
g_object_thaw_notify ((GObject *) self);
finally:
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
static void
@@ -541,7 +541,7 @@ tp_connection_get_rcc_cb (TpProxy *proxy,
finally:
while ((result = g_queue_pop_head (&self->priv->capabilities_queue)) != NULL)
{
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c
index 7e51a5037..29c2884fc 100644
--- a/telepathy-glib/contact.c
+++ b/telepathy-glib/contact.c
@@ -697,7 +697,7 @@ set_contact_groups_cb (TpConnection *connection,
g_simple_async_result_set_from_error (result, error);
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
diff --git a/telepathy-glib/file-transfer-channel.c b/telepathy-glib/file-transfer-channel.c
index e306f79b7..08d8e4c31 100644
--- a/telepathy-glib/file-transfer-channel.c
+++ b/telepathy-glib/file-transfer-channel.c
@@ -185,7 +185,7 @@ operation_failed (TpFileTransferChannel *self,
GError *error)
{
g_simple_async_result_take_error (self->priv->result, error);
- g_simple_async_result_complete (self->priv->result);
+ g_simple_async_result_complete_in_idle (self->priv->result);
tp_clear_object (&self->priv->result);
}
@@ -442,7 +442,7 @@ tp_file_transfer_channel_prepare_core_cb (TpProxy *proxy,
self->priv->file = g_file_new_for_uri (uri);
out:
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
static void
@@ -1169,7 +1169,7 @@ accept_or_provide_file_cb (TpChannel *proxy,
start_transfer (self);
}
- g_simple_async_result_complete (self->priv->result);
+ g_simple_async_result_complete_in_idle (self->priv->result);
}
static gboolean
diff --git a/telepathy-glib/stream-tube-channel.c b/telepathy-glib/stream-tube-channel.c
index 45a778a80..e8018ebc6 100644
--- a/telepathy-glib/stream-tube-channel.c
+++ b/telepathy-glib/stream-tube-channel.c
@@ -533,7 +533,7 @@ operation_failed (TpStreamTubeChannel *self,
{
g_simple_async_result_set_from_error (self->priv->result, error);
- g_simple_async_result_complete (self->priv->result);
+ g_simple_async_result_complete_in_idle (self->priv->result);
tp_clear_object (&self->priv->result);
}
@@ -1203,7 +1203,7 @@ _channel_offered (TpChannel *channel,
DEBUG ("Stream Tube offered");
- g_simple_async_result_complete (self->priv->result);
+ g_simple_async_result_complete_in_idle (self->priv->result);
tp_clear_object (&self->priv->result);
}
diff --git a/telepathy-glib/text-channel.c b/telepathy-glib/text-channel.c
index 3ef0c56fb..8588de890 100644
--- a/telepathy-glib/text-channel.c
+++ b/telepathy-glib/text-channel.c
@@ -641,7 +641,7 @@ get_pending_messages_cb (TpProxy *proxy,
error->domain, error->code,
"Failed to get PendingMessages property: %s", error->message);
- g_simple_async_result_complete (self->priv->pending_messages_result);
+ g_simple_async_result_complete_in_idle (self->priv->pending_messages_result);
g_clear_object (&self->priv->pending_messages_result);
return;
}
@@ -654,7 +654,7 @@ get_pending_messages_cb (TpProxy *proxy,
TP_ERRORS, TP_ERROR_CONFUSED,
"PendingMessages property is of the wrong type");
- g_simple_async_result_complete (self->priv->pending_messages_result);
+ g_simple_async_result_complete_in_idle (self->priv->pending_messages_result);
g_clear_object (&self->priv->pending_messages_result);
return;
}
@@ -663,7 +663,7 @@ get_pending_messages_cb (TpProxy *proxy,
if (messages->len == 0)
{
- g_simple_async_result_complete (self->priv->pending_messages_result);
+ g_simple_async_result_complete_in_idle (self->priv->pending_messages_result);
g_clear_object (&self->priv->pending_messages_result);
return;
}
@@ -755,7 +755,7 @@ get_sms_channel_cb (TpProxy *proxy,
g_object_notify (G_OBJECT (self), "is-sms-channel");
out:
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -1218,7 +1218,7 @@ send_message_cb (TpChannel *proxy,
g_simple_async_result_set_op_res_gpointer (result,
tp_str_empty (token) ? NULL : g_strdup (token), g_free);
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -1295,7 +1295,7 @@ acknowledge_pending_messages_ready_cb (GObject *object,
_tp_channel_contacts_queue_prepare_finish (channel, res, NULL, NULL);
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -1312,7 +1312,7 @@ acknowledge_pending_messages_cb (TpChannel *channel,
DEBUG ("Failed to ack messages: %s", error->message);
g_simple_async_result_set_from_error (result, error);
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
return;
}
@@ -1513,7 +1513,7 @@ set_chat_state_cb (TpChannel *proxy,
g_simple_async_result_set_from_error (result, error);
}
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
@@ -1725,7 +1725,7 @@ get_sms_length_cb (TpChannel *proxy,
(GDestroyNotify) get_sms_length_return_free);
out:
- g_simple_async_result_complete (result);
+ g_simple_async_result_complete_in_idle (result);
}
/**