2 * Copyright (C) 2008 Collabora Ltd.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
19 * Sjoerd Simons <sjoerd.simons@collabora.co.uk>
24 #include <telepathy-glib/util.h>
25 #include <telepathy-glib/account-manager.h>
26 #include <telepathy-glib/enums.h>
27 #include <telepathy-glib/defs.h>
28 #include <telepathy-glib/dbus.h>
29 #include <telepathy-glib/interfaces.h>
31 #include "empathy-account-manager.h"
32 #include "empathy-marshal.h"
33 #include "empathy-utils.h"
35 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
36 #include <libempathy/empathy-debug.h>
38 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountManager)
40 #define MC5_BUS_NAME "org.freedesktop.Telepathy.MissionControl5"
43 /* (owned) unique name -> (reffed) EmpathyAccount */
49 TpAccountManager *tp_manager;
53 EmpathyAccount *global_account;
55 TpConnectionPresenceType global_presence;
57 gchar *global_status_message;
59 /* requested global presence, could be different
60 * from the actual global one.
62 TpConnectionPresenceType requested_presence;
63 gchar *requested_status;
64 gchar *requested_status_message;
66 GHashTable *create_results;
67 } EmpathyAccountManagerPriv;
75 ACCOUNT_CONNECTION_CHANGED,
76 GLOBAL_PRESENCE_CHANGED,
85 static guint signals[LAST_SIGNAL];
86 static EmpathyAccountManager *manager_singleton = NULL;
88 G_DEFINE_TYPE (EmpathyAccountManager, empathy_account_manager, G_TYPE_OBJECT);
91 emp_account_connection_cb (EmpathyAccount *account,
95 TpConnection *connection = empathy_account_get_connection (account);
97 DEBUG ("Signalling connection %p of account %s",
98 connection, empathy_account_get_unique_name (account));
100 if (connection != NULL)
101 g_signal_emit (manager, signals[NEW_CONNECTION], 0, connection);
105 emp_account_enabled_cb (EmpathyAccount *account,
109 if (empathy_account_is_enabled (account))
110 g_signal_emit (manager, signals[ACCOUNT_ENABLED], 0, account);
112 g_signal_emit (manager, signals[ACCOUNT_DISABLED], 0, account);
116 emp_account_status_changed_cb (EmpathyAccount *account,
117 TpConnectionStatus old,
118 TpConnectionStatus new,
119 TpConnectionStatusReason reason,
122 EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
123 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
127 case TP_CONNECTION_STATUS_CONNECTING:
130 case TP_CONNECTION_STATUS_CONNECTED:
139 case TP_CONNECTION_STATUS_CONNECTING:
142 case TP_CONNECTION_STATUS_CONNECTED:
149 g_signal_emit (manager, signals[ACCOUNT_CONNECTION_CHANGED], 0,
150 account, reason, new, old);
154 emp_account_manager_update_global_presence (EmpathyAccountManager *manager)
156 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
157 TpConnectionPresenceType presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
158 EmpathyAccount *account = NULL;
162 /* Make the global presence is equal to the presence of the account with the
163 * highest availability */
165 g_hash_table_iter_init (&iter, priv->accounts);
166 while (g_hash_table_iter_next (&iter, NULL, &value))
168 EmpathyAccount *a = EMPATHY_ACCOUNT (value);
169 TpConnectionPresenceType p;
171 g_object_get (a, "presence", &p, NULL);
173 if (tp_connection_presence_type_cmp_availability (p, presence) > 0)
180 priv->global_account = account;
181 g_free (priv->global_status);
182 g_free (priv->global_status_message);
186 priv->global_status = NULL;
187 priv->global_status_message = NULL;
191 g_object_get (account,
192 "presence", &priv->global_presence,
193 "status", &priv->global_status,
194 "status-message", &priv->global_status_message,
197 DEBUG ("Updated global presence to: %s (%d) \"%s\"",
198 priv->global_status, priv->global_presence, priv->global_status_message);
202 emp_account_presence_changed_cb (EmpathyAccount *account,
203 TpConnectionPresenceType presence,
205 const gchar *status_message,
208 EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
209 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
211 if (tp_connection_presence_type_cmp_availability (presence,
212 priv->global_presence) > 0)
214 priv->global_account = account;
216 priv->global_presence = presence;
218 g_free (priv->global_status);
219 priv->global_status = g_strdup (status);
221 g_free (priv->global_status_message);
222 priv->global_status_message = g_strdup (status_message);
226 else if (priv->global_account == account)
228 emp_account_manager_update_global_presence (manager);
234 g_signal_emit (manager, signals[GLOBAL_PRESENCE_CHANGED], 0,
235 priv->global_presence, priv->global_status, priv->global_status_message);
239 emp_account_removed_cb (EmpathyAccount *account, gpointer user_data)
241 EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
242 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
244 g_object_ref (account);
245 g_hash_table_remove (priv->accounts,
246 empathy_account_get_unique_name (account));
248 g_signal_emit (manager, signals[ACCOUNT_DELETED], 0, account);
249 g_object_unref (account);
253 empathy_account_manager_check_ready (EmpathyAccountManager *manager)
255 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
262 g_hash_table_iter_init (&iter, priv->accounts);
263 while (g_hash_table_iter_next (&iter, NULL, &value))
265 EmpathyAccount *account = EMPATHY_ACCOUNT (value);
268 g_object_get (account, "ready", &ready, NULL);
274 /* Rerequest global presence on the initial set of accounts for cases where a
275 * global presence was requested before the manager was ready */
276 if (priv->requested_presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
277 empathy_account_manager_request_global_presence (manager,
278 priv->requested_presence,
279 priv->requested_status,
280 priv->requested_status_message);
283 g_object_notify (G_OBJECT (manager), "ready");
287 account_manager_account_ready_cb (GObject *obj,
291 EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
292 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
293 EmpathyAccount *account = EMPATHY_ACCOUNT (obj);
294 GSimpleAsyncResult *result;
297 g_object_get (account, "ready", &ready, NULL);
302 /* see if there's any pending callbacks for this account */
303 result = g_hash_table_lookup (priv->create_results, account);
306 g_simple_async_result_set_op_res_gpointer (
307 G_SIMPLE_ASYNC_RESULT (result), account, NULL);
309 g_simple_async_result_complete (result);
311 g_hash_table_remove (priv->create_results, account);
312 g_object_unref (result);
315 g_signal_emit (manager, signals[ACCOUNT_CREATED], 0, account);
317 g_signal_connect (account, "notify::connection",
318 G_CALLBACK (emp_account_connection_cb), manager);
320 g_signal_connect (account, "notify::enabled",
321 G_CALLBACK (emp_account_enabled_cb), manager);
323 g_signal_connect (account, "status-changed",
324 G_CALLBACK (emp_account_status_changed_cb), manager);
326 g_signal_connect (account, "presence-changed",
327 G_CALLBACK (emp_account_presence_changed_cb), manager);
329 g_signal_connect (account, "removed",
330 G_CALLBACK (emp_account_removed_cb), manager);
332 empathy_account_manager_check_ready (manager);
336 empathy_account_manager_get_account (EmpathyAccountManager *manager,
339 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
340 EmpathyAccount *account;
342 account = g_hash_table_lookup (priv->accounts, path);
346 account = empathy_account_new (priv->dbus, path);
347 g_hash_table_insert (priv->accounts, g_strdup (path), account);
349 g_signal_connect (account, "notify::ready",
350 G_CALLBACK (account_manager_account_ready_cb), manager);
356 account_manager_got_all_cb (TpProxy *proxy,
357 GHashTable *properties,
360 GObject *weak_object)
362 EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (weak_object);
368 DEBUG ("Failed to get account manager properties: %s", error->message);
372 accounts = tp_asv_get_boxed (properties, "ValidAccounts",
373 EMPATHY_ARRAY_TYPE_OBJECT);
375 for (i = 0; i < accounts->len; i++)
377 gchar *name = g_ptr_array_index (accounts, i);
379 empathy_account_manager_get_account (manager, name);
382 empathy_account_manager_check_ready (manager);
386 account_validity_changed_cb (TpAccountManager *proxy,
390 GObject *weak_object)
392 EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (weak_object);
397 empathy_account_manager_get_account (manager, path);
401 account_manager_name_owner_cb (TpDBusDaemon *proxy,
403 const gchar *new_owner,
406 EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
407 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
409 tp_dbus_daemon_cancel_name_owner_watch (proxy, name,
410 account_manager_name_owner_cb, user_data);
412 priv->tp_manager = tp_account_manager_new (priv->dbus);
414 tp_cli_account_manager_connect_to_account_validity_changed (
416 account_validity_changed_cb,
422 tp_cli_dbus_properties_call_get_all (priv->tp_manager, -1,
423 TP_IFACE_ACCOUNT_MANAGER,
424 account_manager_got_all_cb,
431 empathy_account_manager_init (EmpathyAccountManager *manager)
433 EmpathyAccountManagerPriv *priv;
436 priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
437 EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerPriv);
439 manager->priv = priv;
440 priv->connected = priv->connecting = 0;
441 priv->global_presence = TP_CONNECTION_PRESENCE_TYPE_UNSET;
443 priv->accounts = g_hash_table_new_full (g_str_hash, g_str_equal,
444 g_free, (GDestroyNotify) g_object_unref);
446 priv->create_results = g_hash_table_new (g_direct_hash, g_direct_equal);
448 priv->dbus = tp_dbus_daemon_dup (NULL);
450 tp_dbus_daemon_watch_name_owner (priv->dbus,
451 TP_ACCOUNT_MANAGER_BUS_NAME,
452 account_manager_name_owner_cb,
456 /* trigger MC5 starting */
457 mc5_proxy = g_object_new (TP_TYPE_PROXY,
458 "dbus-daemon", priv->dbus,
459 "dbus-connection", tp_proxy_get_dbus_connection (TP_PROXY (priv->dbus)),
460 "bus-name", MC5_BUS_NAME,
464 tp_cli_dbus_peer_call_ping (mc5_proxy, -1, NULL, NULL, NULL, NULL);
466 g_object_unref (mc5_proxy);
470 do_finalize (GObject *obj)
472 EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (obj);
473 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
475 g_hash_table_destroy (priv->create_results);
476 g_hash_table_destroy (priv->accounts);
478 g_free (priv->global_status);
479 g_free (priv->global_status_message);
481 g_free (priv->requested_status);
482 g_free (priv->requested_status_message);
484 G_OBJECT_CLASS (empathy_account_manager_parent_class)->finalize (obj);
488 do_dispose (GObject *obj)
490 EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (obj);
491 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
493 GSimpleAsyncResult *result;
495 if (priv->dispose_run)
498 priv->dispose_run = TRUE;
500 /* the manager is being destroyed while there are account creation
501 * processes pending; this should not happen, but emit the callbacks
502 * with an error anyway.
504 g_hash_table_iter_init (&iter, priv->create_results);
505 while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &result))
507 g_simple_async_result_set_error (result, G_IO_ERROR,
508 G_IO_ERROR_CANCELLED, "The account manager was disposed while "
509 "creating the account");
510 g_simple_async_result_complete (result);
511 g_object_unref (result);
513 g_hash_table_remove_all (priv->create_results);
515 if (priv->dbus != NULL)
517 tp_dbus_daemon_cancel_name_owner_watch (priv->dbus,
518 TP_ACCOUNT_MANAGER_BUS_NAME, account_manager_name_owner_cb, manager);
520 g_object_unref (priv->dbus);
524 G_OBJECT_CLASS (empathy_account_manager_parent_class)->dispose (obj);
528 do_constructor (GType type,
529 guint n_construct_params,
530 GObjectConstructParam *construct_params)
534 if (!manager_singleton)
536 retval = G_OBJECT_CLASS (empathy_account_manager_parent_class)->constructor (type,
539 manager_singleton = EMPATHY_ACCOUNT_MANAGER (retval);
540 g_object_add_weak_pointer (retval, (gpointer) &manager_singleton);
544 retval = g_object_ref (manager_singleton);
551 do_get_property (GObject *object,
556 EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (object);
557 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
562 g_value_set_boolean (value, priv->ready);
565 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
571 empathy_account_manager_class_init (EmpathyAccountManagerClass *klass)
573 GObjectClass *oclass = G_OBJECT_CLASS (klass);
575 oclass->finalize = do_finalize;
576 oclass->dispose = do_dispose;
577 oclass->constructor = do_constructor;
578 oclass->get_property = do_get_property;
580 g_object_class_install_property (oclass, PROP_READY,
581 g_param_spec_boolean ("ready",
583 "Whether the initial state dump from the account manager is finished",
585 G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
587 signals[ACCOUNT_CREATED] =
588 g_signal_new ("account-created",
589 G_TYPE_FROM_CLASS (klass),
593 g_cclosure_marshal_VOID__OBJECT,
595 1, EMPATHY_TYPE_ACCOUNT);
597 signals[ACCOUNT_DELETED] =
598 g_signal_new ("account-deleted",
599 G_TYPE_FROM_CLASS (klass),
603 g_cclosure_marshal_VOID__OBJECT,
605 1, EMPATHY_TYPE_ACCOUNT);
607 signals[ACCOUNT_ENABLED] =
608 g_signal_new ("account-enabled",
609 G_TYPE_FROM_CLASS (klass),
613 g_cclosure_marshal_VOID__OBJECT,
615 1, EMPATHY_TYPE_ACCOUNT);
617 signals[ACCOUNT_DISABLED] =
618 g_signal_new ("account-disabled",
619 G_TYPE_FROM_CLASS (klass),
623 g_cclosure_marshal_VOID__OBJECT,
625 1, EMPATHY_TYPE_ACCOUNT);
627 signals[ACCOUNT_CHANGED] =
628 g_signal_new ("account-changed",
629 G_TYPE_FROM_CLASS (klass),
633 g_cclosure_marshal_VOID__OBJECT,
635 1, EMPATHY_TYPE_ACCOUNT);
637 signals[ACCOUNT_CONNECTION_CHANGED] =
638 g_signal_new ("account-connection-changed",
639 G_TYPE_FROM_CLASS (klass),
643 _empathy_marshal_VOID__OBJECT_INT_UINT_UINT,
645 4, EMPATHY_TYPE_ACCOUNT,
646 G_TYPE_INT, /* reason */
647 G_TYPE_UINT, /* actual connection */
648 G_TYPE_UINT); /* previous connection */
650 signals[GLOBAL_PRESENCE_CHANGED] =
651 g_signal_new ("global-presence-changed",
652 G_TYPE_FROM_CLASS (klass),
656 _empathy_marshal_VOID__UINT_STRING_STRING,
658 3, G_TYPE_UINT, /* Presence type */
659 G_TYPE_STRING, /* status */
660 G_TYPE_STRING); /* stauts message*/
662 signals[NEW_CONNECTION] =
663 g_signal_new ("new-connection",
664 G_TYPE_FROM_CLASS (klass),
668 g_cclosure_marshal_VOID__OBJECT,
670 1, TP_TYPE_CONNECTION);
672 g_type_class_add_private (oclass, sizeof (EmpathyAccountManagerPriv));
677 EmpathyAccountManager *
678 empathy_account_manager_dup_singleton (void)
680 return g_object_new (EMPATHY_TYPE_ACCOUNT_MANAGER, NULL);
684 empathy_account_manager_is_ready (EmpathyAccountManager *manager)
686 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
692 empathy_account_manager_get_connected_accounts (EmpathyAccountManager *manager)
694 EmpathyAccountManagerPriv *priv;
696 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
698 priv = GET_PRIV (manager);
700 return priv->connected;
704 empathy_account_manager_get_connecting_accounts (EmpathyAccountManager *manager)
706 EmpathyAccountManagerPriv *priv;
708 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
710 priv = GET_PRIV (manager);
712 return priv->connecting;
716 * empathy_account_manager_get_count:
717 * @manager: a #EmpathyAccountManager
719 * Get the number of accounts.
721 * Returns: the number of accounts.
724 empathy_account_manager_get_count (EmpathyAccountManager *manager)
726 EmpathyAccountManagerPriv *priv;
728 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
730 priv = GET_PRIV (manager);
732 return g_hash_table_size (priv->accounts);
736 empathy_account_manager_get_account_for_connection (
737 EmpathyAccountManager *manager,
738 TpConnection *connection)
740 EmpathyAccountManagerPriv *priv;
744 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
746 priv = GET_PRIV (manager);
748 g_hash_table_iter_init (&iter, priv->accounts);
749 while (g_hash_table_iter_next (&iter, NULL, &value))
751 EmpathyAccount *account = EMPATHY_ACCOUNT (value);
753 if (connection == empathy_account_get_connection (account))
761 empathy_account_manager_dup_accounts (EmpathyAccountManager *manager)
763 EmpathyAccountManagerPriv *priv;
766 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), NULL);
768 priv = GET_PRIV (manager);
770 ret = g_hash_table_get_values (priv->accounts);
771 g_list_foreach (ret, (GFunc) g_object_ref, NULL);
777 * empathy_account_manager_dup_connections:
778 * @manager: a #EmpathyAccountManager
780 * Get a #GList of all ready #TpConnection. The list must be freed with
781 * g_list_free, and its elements must be unreffed.
783 * Returns: the list of connections
786 empathy_account_manager_dup_connections (EmpathyAccountManager *manager)
788 EmpathyAccountManagerPriv *priv;
793 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), NULL);
795 priv = GET_PRIV (manager);
797 g_hash_table_iter_init (&iter, priv->accounts);
798 while (g_hash_table_iter_next (&iter, NULL, &value))
800 EmpathyAccount *account = EMPATHY_ACCOUNT (value);
801 TpConnection *connection;
803 connection = empathy_account_get_connection (account);
804 if (connection != NULL)
805 ret = g_list_prepend (ret, g_object_ref (connection));
812 empathy_account_manager_request_global_presence (
813 EmpathyAccountManager *manager,
814 TpConnectionPresenceType type,
816 const gchar *message)
818 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
822 DEBUG ("request global presence, type: %d, status: %s, message: %s",
823 type, status, message);
825 g_hash_table_iter_init (&iter, priv->accounts);
826 while (g_hash_table_iter_next (&iter, NULL, &value))
828 EmpathyAccount *account = EMPATHY_ACCOUNT (value);
831 g_object_get (account, "ready", &ready, NULL);
834 empathy_account_request_presence (account, type, status, message);
837 /* save the requested global presence, to use it in case we create
838 * new accounts or some accounts become ready.
840 priv->requested_presence = type;
842 if (tp_strdiff (priv->requested_status, status))
844 g_free (priv->requested_status);
845 priv->requested_status = g_strdup (status);
848 if (tp_strdiff (priv->requested_status_message, message))
850 g_free (priv->requested_status_message);
851 priv->requested_status_message = g_strdup (message);
855 TpConnectionPresenceType
856 empathy_account_manager_get_requested_global_presence (
857 EmpathyAccountManager *manager,
861 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
864 *status = g_strdup (priv->requested_status);
866 *message = g_strdup (priv->requested_status_message);
868 return priv->requested_presence;
871 TpConnectionPresenceType
872 empathy_account_manager_get_global_presence (
873 EmpathyAccountManager *manager,
877 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
880 *status = g_strdup (priv->global_status);
882 *message = g_strdup (priv->global_status_message);
884 return priv->global_presence;
888 empathy_account_manager_created_cb (TpAccountManager *proxy,
889 const gchar *account_path,
892 GObject *weak_object)
894 EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (weak_object);
895 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
896 GSimpleAsyncResult *my_res = user_data;
897 EmpathyAccount *account;
901 g_simple_async_result_set_from_error (my_res,
903 g_simple_async_result_complete (my_res);
904 g_object_unref (my_res);
909 account = empathy_account_manager_get_account (manager, account_path);
911 g_hash_table_insert (priv->create_results, account, my_res);
915 empathy_account_manager_create_account_async (EmpathyAccountManager *manager,
916 const gchar *connection_manager,
917 const gchar *protocol,
918 const gchar *display_name,
919 GHashTable *parameters,
920 GHashTable *properties,
921 GAsyncReadyCallback callback,
924 EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
925 GSimpleAsyncResult *res;
927 res = g_simple_async_result_new
928 (G_OBJECT (manager), callback, user_data,
929 empathy_account_manager_create_account_finish);
931 tp_cli_account_manager_call_create_account (priv->tp_manager,
938 empathy_account_manager_created_cb,
945 empathy_account_manager_create_account_finish (
946 EmpathyAccountManager *manager, GAsyncResult *result, GError **error)
948 EmpathyAccount *retval;
950 if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
954 g_return_val_if_fail (g_simple_async_result_is_valid (result,
955 G_OBJECT (manager), empathy_account_manager_create_account_finish), NULL);
957 retval = EMPATHY_ACCOUNT (g_simple_async_result_get_op_res_gpointer (
958 G_SIMPLE_ASYNC_RESULT (result)));