diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-05-30 21:25:36 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-06-22 15:12:08 +0800 |
commit | a997201320e14d4bdca30391bd3c8d29224d0b26 (patch) | |
tree | 27eb2c5ec090843854882e0501be158d7c010cbd /src/empathy-call-observer.c | |
parent | 9cfab15b0c15b23d59d01e88c9efac0d0cf27433 (diff) | |
download | gsoc2013-empathy-a997201320e14d4bdca30391bd3c8d29224d0b26.tar gsoc2013-empathy-a997201320e14d4bdca30391bd3c8d29224d0b26.tar.gz gsoc2013-empathy-a997201320e14d4bdca30391bd3c8d29224d0b26.tar.bz2 gsoc2013-empathy-a997201320e14d4bdca30391bd3c8d29224d0b26.tar.lz gsoc2013-empathy-a997201320e14d4bdca30391bd3c8d29224d0b26.tar.xz gsoc2013-empathy-a997201320e14d4bdca30391bd3c8d29224d0b26.tar.zst gsoc2013-empathy-a997201320e14d4bdca30391bd3c8d29224d0b26.zip |
call-observer: use tp_channel_dispatch_operation_leave_channels_async() (#651473)
We now return from Observe() right after having called Claim(). That's what
the spec suggests and not doing so would break Claim() which can't return
while Observer didn't return from Observe.
Diffstat (limited to 'src/empathy-call-observer.c')
-rw-r--r-- | src/empathy-call-observer.c | 98 |
1 files changed, 27 insertions, 71 deletions
diff --git a/src/empathy-call-observer.c b/src/empathy-call-observer.c index 308cec22d..c6ba53c95 100644 --- a/src/empathy-call-observer.c +++ b/src/empathy-call-observer.c @@ -168,71 +168,6 @@ display_reject_notification (EmpathyCallObserver *self, g_object_ref (channel), g_object_unref, G_OBJECT (self)); } -static void -on_cdo_claim_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) -{ - AutoRejectCtx *ctx = user_data; - TpChannelDispatchOperation *cdo; - GError *error = NULL; - GPtrArray *channels; - guint i; - - cdo = TP_CHANNEL_DISPATCH_OPERATION (source_object); - - tp_channel_dispatch_operation_claim_with_finish (cdo, result, &error); - if (error != NULL) - { - DEBUG ("Could not claim CDO: %s", error->message); - g_error_free (error); - goto out; - } - - channels = tp_channel_dispatch_operation_borrow_channels (cdo); - for (i = 0; i < channels->len; i++) - { - TpChannel *channel = g_ptr_array_index (channels, i); - - tp_channel_leave_async (channel, - TP_CHANNEL_GROUP_CHANGE_REASON_BUSY, "Already in a call", - NULL, NULL); - } - - display_reject_notification (ctx->self, ctx->main_channel); - -out: - auto_reject_ctx_free (ctx); -} - -static void -cdo_prepare_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) -{ - AutoRejectCtx *ctx = user_data; - GError *error = NULL; - TpChannelDispatchOperation *cdo; - - cdo = TP_CHANNEL_DISPATCH_OPERATION (source_object); - - if (!tp_proxy_prepare_finish (source_object, result, &error)) - { - DEBUG ("Failed to prepare ChannelDispatchOperation: %s", error->message); - - tp_observe_channels_context_fail (ctx->context, error); - - g_error_free (error); - auto_reject_ctx_free (ctx); - return; - } - - tp_channel_dispatch_operation_claim_with_async (cdo, - ctx->self->priv->observer, on_cdo_claim_cb, ctx); - - tp_observe_channels_context_accept (ctx->context); -} - static TpChannel * find_main_channel (GList *channels) { @@ -265,6 +200,29 @@ has_ongoing_calls (EmpathyCallObserver *self) } static void +claim_and_leave_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + AutoRejectCtx *ctx = user_data; + GError *error = NULL; + + if (!tp_channel_dispatch_operation_leave_channels_finish ( + TP_CHANNEL_DISPATCH_OPERATION (source), result, &error)) + { + DEBUG ("Failed to reject call: %s", error->message); + + g_error_free (error); + goto out; + } + + display_reject_notification (ctx->self, ctx->main_channel); + +out: + auto_reject_ctx_free (ctx); +} + +static void observe_channels (TpSimpleObserver *observer, TpAccount *account, TpConnection *connection, @@ -294,17 +252,15 @@ observe_channels (TpSimpleObserver *observer, if (has_ongoing_calls (self)) { AutoRejectCtx *ctx = auto_reject_ctx_new (self, context, channel); - GQuark features[] = { TP_CHANNEL_DISPATCH_OPERATION_FEATURE_CORE, 0 }; DEBUG ("Autorejecting incoming call since there are others in " "progress: %s", tp_proxy_get_object_path (channel)); - /* We have to prepare dispatch_operation so we'll be able to get the - * channels from it. */ - tp_proxy_prepare_async (dispatch_operation, features, - cdo_prepare_cb, ctx); + tp_channel_dispatch_operation_leave_channels_async (dispatch_operation, + TP_CHANNEL_GROUP_CHANGE_REASON_BUSY, "Already in a call", + claim_and_leave_cb, ctx); - tp_observe_channels_context_delay (context); + tp_observe_channels_context_accept (context); return; } |