1337
1341
((GObjectClass *) tp_channel_parent_class)->finalize (object);
1345
got_password_flags_cb (TpChannel *self,
1346
guint password_flags,
1347
const GError *error,
1349
GObject *weak_object)
1351
GSimpleAsyncResult *result = user_data;
1355
DEBUG ("Failed to get password flags: %s", error->message);
1359
self->priv->password_flags = password_flags;
1361
if (tp_channel_password_needed (self))
1363
/* password-needed is FALSE by default */
1364
g_object_notify (G_OBJECT (self), "password-needed");
1368
g_simple_async_result_complete (result);
1372
password_flags_changed_cb (TpChannel *self,
1376
GObject *weak_object)
1378
gboolean was_needed, needed;
1380
was_needed = tp_channel_password_needed (self);
1382
self->priv->password_flags |= added;
1383
self->priv->password_flags ^= removed;
1385
needed = tp_channel_password_needed (self);
1387
if (was_needed != needed)
1388
g_object_notify (G_OBJECT (self), "password-needed");
1392
tp_channel_prepare_password_async (TpProxy *proxy,
1393
const TpProxyFeature *feature,
1394
GAsyncReadyCallback callback,
1397
TpChannel *self = (TpChannel *) proxy;
1398
GSimpleAsyncResult *result;
1400
result = g_simple_async_result_new ((GObject *) proxy, callback, user_data,
1401
tp_channel_prepare_password_async);
1403
tp_cli_channel_interface_password_connect_to_password_flags_changed (self,
1404
password_flags_changed_cb, self, NULL, G_OBJECT (self), NULL);
1406
tp_cli_channel_interface_password_call_get_password_flags (self, -1,
1407
got_password_flags_cb, result, g_object_unref, G_OBJECT (self));
1343
1414
FEAT_CHAT_STATES,
2383
2474
_tp_implement_finish_void (self, tp_channel_close_async)
2478
channel_destroy_cb (TpChannel *channel,
2479
const GError *error,
2481
GObject *weak_object)
2483
GSimpleAsyncResult *result = user_data;
2485
if (tp_proxy_get_invalidated (channel) == NULL &&
2488
DEBUG ("Destroy() failed; call Close(): %s", error->message);
2490
tp_cli_channel_call_close (channel, -1, channel_close_cb, result,
2495
g_simple_async_result_complete (result);
2496
g_object_unref (result);
2500
* tp_channel_destroy_async:
2501
* @self: a #TpChannel
2502
* @callback: a callback to call when we left the channel
2503
* @user_data: data to pass to @callback
2505
* Destroy channel @self.
2506
* If @self doesn't implement #TP_IFACE_QUARK_CHANNEL_INTERFACE_DESTROYABLE
2507
* or if for any reason we can't destroy the channel, we close it.
2509
* When the channel has been destroyed or closed, @callback will be called.
2510
* You can then call tp_channel_destroy_finish() to get the result of
2516
tp_channel_destroy_async (TpChannel *self,
2517
GAsyncReadyCallback callback,
2520
GSimpleAsyncResult *result;
2522
g_return_if_fail (TP_IS_CHANNEL (self));
2524
result = g_simple_async_result_new (G_OBJECT (self), callback,
2525
user_data, tp_channel_destroy_async);
2527
if (tp_proxy_is_prepared (self, TP_CHANNEL_FEATURE_CORE) &&
2528
!tp_proxy_has_interface_by_id (self,
2529
TP_IFACE_QUARK_CHANNEL_INTERFACE_DESTROYABLE))
2531
DEBUG ("Channel doesn't implement Destroy; fallback to Close()");
2533
tp_cli_channel_call_close (self, -1, channel_close_cb, result,
2538
tp_cli_channel_interface_destroyable_call_destroy (self, -1,
2539
channel_destroy_cb, result, NULL, NULL);
2543
* tp_channel_destroy_finish:
2544
* @self: a #TpChannel
2545
* @result: a #GAsyncResult
2546
* @error: a #GError to fill
2548
* Finishes to leave a channel.
2550
* Returns: %TRUE if the channel has been destroyed or closed; %FALSE otherwise
2555
tp_channel_destroy_finish (TpChannel *self,
2556
GAsyncResult *result,
2559
_tp_implement_finish_void (self, tp_channel_destroy_async)
2563
* TP_CHANNEL_FEATURE_PASSWORD:
2565
* Expands to a call to a function that returns a quark representing the
2566
* password feature on a #TpChannel.
2568
* When this feature is prepared, tp_channel_password_needed() and the
2569
* #TpChannel:password-needed property become useful.
2571
* One can ask for a feature to be prepared using the
2572
* tp_proxy_prepare_async() function, and waiting for it to callback.
2578
tp_channel_get_feature_quark_password (void)
2580
return g_quark_from_static_string ("tp-channel-feature-password");
2584
* tp_channel_password_needed:
2585
* @self: a #TpChannel
2587
* Return the #TpChannel:password-needed property
2589
* Returns: the value of #TpChannel:password-needed
2594
tp_channel_password_needed (TpChannel *self)
2596
return self->priv->password_flags & TP_CHANNEL_PASSWORD_FLAG_PROVIDE;
2600
provide_password_cb (TpChannel *self,
2602
const GError *error,
2604
GObject *weak_object)
2606
GSimpleAsyncResult *result = user_data;
2610
g_simple_async_result_set_from_error (result, error);
2614
DEBUG ("Wrong password provided for %s", tp_proxy_get_object_path (self));
2616
g_simple_async_result_set_error (result, TP_ERRORS,
2617
TP_ERROR_AUTHENTICATION_FAILED, "Password was not correct");
2620
g_simple_async_result_complete (result);
2624
* tp_channel_provide_password_async:
2625
* @self: a #TpChannel
2626
* @password: the password
2627
* @callback: a callback to call when @password has been provided
2628
* @user_data: data to pass to @callback
2630
* Provide @password so that @self can be joined.
2631
* This function must be called with the correct password in order for
2632
* channel joining to proceed if the TpChannel:password-needed property
2635
* Once the password has been provided, @callback will be
2636
* called. You can then call tp_channel_provide_password_finish()
2637
* to get the result of the operation.
2642
tp_channel_provide_password_async (TpChannel *self,
2643
const gchar *password,
2644
GAsyncReadyCallback callback,
2647
GSimpleAsyncResult *result;
2649
g_return_if_fail (TP_IS_CHANNEL (self));
2651
result = g_simple_async_result_new (G_OBJECT (self), callback,
2652
user_data, tp_channel_provide_password_async);
2654
tp_cli_channel_interface_password_call_provide_password (self, -1, password,
2655
provide_password_cb, result, g_object_unref, G_OBJECT (self));
2659
* tp_channel_provide_password_finish:
2660
* @self: a #TpChannel
2661
* @result: a #GAsyncResult
2662
* @error: a #GError to fill
2664
* Finishes to provide a password. If the password was rejected, the operation
2665
* fails with #TP_ERROR_AUTHENTICATION_FAILED.
2667
* Returns: %TRUE if the password has been provided and accepted,
2673
tp_channel_provide_password_finish (TpChannel *self,
2674
GAsyncResult *result,
2677
_tp_implement_finish_void (self, tp_channel_provide_password_async);