2 * Copyright (C) 2005-2007 Imendio AB
3 * Copyright (C) 2007-2011 Collabora Ltd.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301 USA
20 * Authors: Martyn Russell <martyn@imendio.com>
21 * Xavier Claessens <xclaesse@gmail.com>
28 #include <glib/gi18n-lib.h>
31 #include <telepathy-glib/account-manager.h>
32 #include <telepathy-glib/util.h>
34 #include <libempathy/empathy-utils.h>
36 #include "empathy-ui-utils.h"
37 #include "empathy-account-chooser.h"
39 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
40 #include <libempathy/empathy-debug.h>
43 * SECTION:empathy-account-chooser
44 * @title:EmpathyAccountChooser
45 * @short_description: A widget used to choose from a list of accounts
46 * @include: libempathy-gtk/empathy-account-chooser.h
48 * #EmpathyAccountChooser is a widget which extends #GtkComboBox to provide
49 * a chooser of available accounts.
53 * EmpathyAccountChooser:
54 * @parent: parent object
56 * Widget which extends #GtkComboBox to provide a chooser of available accounts.
59 struct _EmpathyAccountChooserPriv
61 TpAccountManager *manager;
62 gboolean set_active_item;
63 gboolean account_manually_set;
64 gboolean has_all_option;
65 EmpathyAccountChooserFilterFunc filter;
72 EmpathyAccountChooser *self;
79 EmpathyAccountChooser *self;
82 } FilterResultCallbackData;
84 static FilterResultCallbackData *
85 filter_result_callback_data_new (EmpathyAccountChooser *self,
89 FilterResultCallbackData *data;
91 data = g_slice_new0 (FilterResultCallbackData);
92 data->self = g_object_ref (self);
93 data->account = g_object_ref (account);
94 data->iter = gtk_tree_iter_copy (iter);
100 filter_result_callback_data_free (FilterResultCallbackData *data)
102 g_object_unref (data->self);
103 g_object_unref (data->account);
104 gtk_tree_iter_free (data->iter);
105 g_slice_free (FilterResultCallbackData, data);
108 /* Distinguishes between store entries which are actually accounts, and special
109 * items like the "All" entry and the separator below it, so they can be sorted
110 * correctly. Higher-numbered entries will sort earlier.
121 COL_ACCOUNT_ENABLED, /* Usually tied to connected state */
122 COL_ACCOUNT_ROW_TYPE,
127 static void account_chooser_account_validity_changed_cb (
128 TpAccountManager *manager,
131 EmpathyAccountChooser *self);
132 static void account_chooser_account_add_foreach (TpAccount *account,
133 EmpathyAccountChooser *self);
134 static void account_chooser_account_removed_cb (TpAccountManager *manager,
136 EmpathyAccountChooser *self);
137 static void account_chooser_account_remove_foreach (TpAccount *account,
138 EmpathyAccountChooser*self);
139 static void account_chooser_update_iter (EmpathyAccountChooser *self,
141 static void account_chooser_status_changed_cb (TpAccount *account,
145 gchar *dbus_error_name,
148 static gboolean account_chooser_separator_func (GtkTreeModel *model,
150 EmpathyAccountChooser *self);
151 static gboolean account_chooser_set_account_foreach (GtkTreeModel *model,
154 SetAccountData *data);
166 static guint signals[LAST_SIGNAL] = { 0 };
168 G_DEFINE_TYPE (EmpathyAccountChooser, empathy_account_chooser,
172 empathy_account_chooser_init (EmpathyAccountChooser *self)
174 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
175 EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooserPriv);
177 self->priv->set_active_item = FALSE;
178 self->priv->account_manually_set = FALSE;
179 self->priv->filter = NULL;
180 self->priv->filter_data = NULL;
182 self->priv->manager = tp_account_manager_dup ();
184 tp_g_signal_connect_object (self->priv->manager, "account-validity-changed",
185 G_CALLBACK (account_chooser_account_validity_changed_cb), self, 0);
187 tp_g_signal_connect_object (self->priv->manager, "account-removed",
188 G_CALLBACK (account_chooser_account_removed_cb), self, 0);
192 account_cmp (GtkTreeModel *model,
197 RowType a_type, b_type;
198 gboolean a_enabled, b_enabled;
199 gchar *a_text, *b_text;
202 gtk_tree_model_get (model, a,
203 COL_ACCOUNT_ENABLED, &a_enabled,
204 COL_ACCOUNT_ROW_TYPE, &a_type,
206 gtk_tree_model_get (model, b,
207 COL_ACCOUNT_ENABLED, &b_enabled,
208 COL_ACCOUNT_ROW_TYPE, &b_type,
211 /* This assumes that we have at most one of each special row type. */
212 if (a_type != b_type)
213 /* Display higher-numbered special row types first. */
214 return (b_type - a_type);
216 /* Enabled accounts are displayed first */
217 if (a_enabled != b_enabled)
218 return a_enabled ? -1: 1;
220 gtk_tree_model_get (model, a, COL_ACCOUNT_TEXT, &a_text, -1);
221 gtk_tree_model_get (model, b, COL_ACCOUNT_TEXT, &b_text, -1);
223 if (a_text == b_text)
225 else if (a_text == NULL)
227 else if (b_text == NULL)
230 result = g_ascii_strcasecmp (a_text, b_text);
239 account_manager_prepared_cb (GObject *source_object,
240 GAsyncResult *result,
244 TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
245 EmpathyAccountChooser *self = user_data;
246 GError *error = NULL;
248 if (!tp_proxy_prepare_finish (manager, result, &error))
250 DEBUG ("Failed to prepare account manager: %s", error->message);
251 g_error_free (error);
255 accounts = tp_account_manager_get_valid_accounts (manager);
257 for (l = accounts; l != NULL; l = l->next)
259 TpAccount *account = l->data;
261 account_chooser_account_add_foreach (account, self);
263 tp_g_signal_connect_object (account, "status-changed",
264 G_CALLBACK (account_chooser_status_changed_cb),
268 g_list_free (accounts);
270 self->priv->ready = TRUE;
271 g_signal_emit (self, signals[READY], 0);
275 account_chooser_constructed (GObject *object)
277 EmpathyAccountChooser *self = (EmpathyAccountChooser *) object;
279 GtkCellRenderer *renderer;
280 GtkComboBox *combobox;
282 /* Set up combo box with new store */
283 combobox = GTK_COMBO_BOX (self);
285 gtk_cell_layout_clear (GTK_CELL_LAYOUT (combobox));
287 store = gtk_list_store_new (COL_ACCOUNT_COUNT,
288 GDK_TYPE_PIXBUF, /* Image */
289 G_TYPE_STRING, /* Name */
290 G_TYPE_BOOLEAN, /* Enabled */
291 G_TYPE_UINT, /* Row type */
294 gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store),
295 account_cmp, self, NULL);
296 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
297 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
299 gtk_combo_box_set_model (combobox, GTK_TREE_MODEL (store));
301 renderer = gtk_cell_renderer_pixbuf_new ();
302 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, FALSE);
303 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
304 "pixbuf", COL_ACCOUNT_IMAGE,
305 "sensitive", COL_ACCOUNT_ENABLED,
308 renderer = gtk_cell_renderer_text_new ();
309 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
310 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
311 "text", COL_ACCOUNT_TEXT,
312 "sensitive", COL_ACCOUNT_ENABLED,
315 /* Populate accounts */
316 tp_proxy_prepare_async (self->priv->manager, NULL,
317 account_manager_prepared_cb, self);
319 g_object_unref (store);
324 account_chooser_dispose (GObject *object)
326 EmpathyAccountChooser *self = EMPATHY_ACCOUNT_CHOOSER (object);
328 g_clear_object (&self->priv->manager);
330 G_OBJECT_CLASS (empathy_account_chooser_parent_class)->dispose (object);
334 account_chooser_get_property (GObject *object,
339 EmpathyAccountChooser *self = (EmpathyAccountChooser *) object;
343 case PROP_HAS_ALL_OPTION:
344 g_value_set_boolean (value, self->priv->has_all_option);
347 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
353 account_chooser_set_property (GObject *object,
360 case PROP_HAS_ALL_OPTION:
361 empathy_account_chooser_set_has_all_option (
362 EMPATHY_ACCOUNT_CHOOSER (object), g_value_get_boolean (value));
365 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
371 empathy_account_chooser_class_init (EmpathyAccountChooserClass *klass)
373 GObjectClass *object_class = G_OBJECT_CLASS (klass);
375 object_class->constructed = account_chooser_constructed;
376 object_class->dispose = account_chooser_dispose;
377 object_class->get_property = account_chooser_get_property;
378 object_class->set_property = account_chooser_set_property;
381 * EmpathyAccountChooser:has-all-option:
383 * Have an additional option in the list to mean all accounts.
385 g_object_class_install_property (object_class,
387 g_param_spec_boolean ("has-all-option",
389 "Have a separate option in the list to mean ALL accounts",
394 g_signal_new ("ready",
395 G_OBJECT_CLASS_TYPE (object_class),
399 g_cclosure_marshal_generic,
403 g_type_class_add_private (object_class, sizeof (EmpathyAccountChooserPriv));
407 * empathy_account_chooser_new:
409 * Creates a new #EmpathyAccountChooser.
411 * Return value: A new #EmpathyAccountChooser
414 empathy_account_chooser_new (void)
418 self = g_object_new (EMPATHY_TYPE_ACCOUNT_CHOOSER, NULL);
424 empathy_account_chooser_has_all_selected (EmpathyAccountChooser *self)
430 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self), FALSE);
432 g_return_val_if_fail (self->priv->has_all_option == TRUE, FALSE);
434 model = gtk_combo_box_get_model (GTK_COMBO_BOX (self));
435 if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self), &iter))
438 gtk_tree_model_get (model, &iter, COL_ACCOUNT_ROW_TYPE, &type, -1);
440 return type == ROW_ALL;
444 * empathy_account_chooser_dup_account:
445 * @self: an #EmpathyAccountChooser
447 * Returns the account which is currently selected in the chooser or %NULL
448 * if there is no account selected. The #TpAccount returned should be
449 * unrefed with g_object_unref() when finished with.
451 * Return value: a new ref to the #TpAccount currently selected, or %NULL.
454 empathy_account_chooser_dup_account (EmpathyAccountChooser *self)
460 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self), NULL);
462 model = gtk_combo_box_get_model (GTK_COMBO_BOX (self));
463 if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self), &iter))
466 gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1);
472 * empathy_account_chooser_get_connection:
473 * @self: an #EmpathyAccountChooser
475 * Returns a borrowed reference to the #TpConnection associated with the
476 * account currently selected. The caller must reference the returned object
477 * with g_object_ref() if it will be kept
479 * Return value: a borrowed reference to the #TpConnection associated with the
480 * account curently selected.
483 empathy_account_chooser_get_connection (EmpathyAccountChooser *self)
486 TpConnection *connection;
488 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self), NULL);
490 account = empathy_account_chooser_dup_account (self);
492 /* if the returned account is NULL, then the account manager probably
493 * hasn't been prepared yet. It should be safe to return NULL here
498 connection = tp_account_get_connection (account);
499 g_object_unref (account);
505 * empathy_account_chooser_set_account:
506 * @self: an #EmpathyAccountChooser
507 * @account: a #TpAccount
509 * Sets the currently selected account to @account, if it exists in the list.
511 * Return value: whether the chooser was set to @account.
514 empathy_account_chooser_set_account (EmpathyAccountChooser *self,
517 GtkComboBox *combobox;
522 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self), FALSE);
524 combobox = GTK_COMBO_BOX (self);
525 model = gtk_combo_box_get_model (combobox);
526 gtk_combo_box_get_active_iter (combobox, &iter);
529 data.account = account;
532 gtk_tree_model_foreach (model,
533 (GtkTreeModelForeachFunc) account_chooser_set_account_foreach,
536 self->priv->account_manually_set = data.set;
542 empathy_account_chooser_set_all (EmpathyAccountChooser *self)
544 GtkComboBox *combobox;
548 g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self));
550 g_return_if_fail (self->priv->has_all_option);
552 combobox = GTK_COMBO_BOX (self);
553 model = gtk_combo_box_get_model (combobox);
555 if (gtk_tree_model_get_iter_first (model, &iter))
557 /* 'All accounts' is the first row */
558 gtk_combo_box_set_active_iter (combobox, &iter);
559 self->priv->account_manually_set = TRUE;
564 * empathy_account_chooser_get_has_all_option:
565 * @self: an #EmpathyAccountChooser
567 * Returns whether @self has the #EmpathyAccountChooser:has-all-option
568 * property set to true.
570 * Return value: whether @self has the #EmpathyAccountChooser:has-all-option
574 empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *self)
576 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self), FALSE);
578 return self->priv->has_all_option;
582 * empathy_account_chooser_set_has_all_option:
583 * @self: an #EmpathyAccountChooser
584 * @has_all_option: a new value for the #EmpathyAccountChooser:has-all-option
587 * Sets the #EmpathyAccountChooser:has-all-option property.
590 empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *self,
591 gboolean has_all_option)
593 GtkComboBox *combobox;
598 g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self));
600 if (self->priv->has_all_option == has_all_option)
603 combobox = GTK_COMBO_BOX (self);
604 model = gtk_combo_box_get_model (combobox);
605 store = GTK_LIST_STORE (model);
607 self->priv->has_all_option = has_all_option;
610 * The first 2 options are the ALL and separator
615 gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self),
616 (GtkTreeViewRowSeparatorFunc)
617 account_chooser_separator_func,
621 gtk_list_store_prepend (store, &iter);
622 gtk_list_store_set (store, &iter,
623 COL_ACCOUNT_TEXT, NULL,
624 COL_ACCOUNT_ENABLED, TRUE,
625 COL_ACCOUNT_POINTER, NULL,
626 COL_ACCOUNT_ROW_TYPE, ROW_SEPARATOR,
629 gtk_list_store_prepend (store, &iter);
630 gtk_list_store_set (store, &iter,
631 COL_ACCOUNT_TEXT, _("All accounts"),
632 COL_ACCOUNT_ENABLED, TRUE,
633 COL_ACCOUNT_POINTER, NULL,
634 COL_ACCOUNT_ROW_TYPE, ROW_ALL,
639 if (gtk_tree_model_get_iter_first (model, &iter))
641 if (gtk_list_store_remove (GTK_LIST_STORE (model), &iter))
642 gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
645 gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self),
646 (GtkTreeViewRowSeparatorFunc)
652 g_object_notify (G_OBJECT (self), "has-all-option");
656 account_chooser_account_validity_changed_cb (TpAccountManager *manager,
659 EmpathyAccountChooser *self)
662 account_chooser_account_add_foreach (account, self);
664 account_chooser_account_remove_foreach (account, self);
668 account_chooser_account_add_foreach (TpAccount *account,
669 EmpathyAccountChooser *self)
672 GtkComboBox *combobox;
676 combobox = GTK_COMBO_BOX (self);
677 store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox));
679 position = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL);
680 gtk_list_store_insert_with_values (store, &iter, position,
681 COL_ACCOUNT_POINTER, account,
684 account_chooser_update_iter (self, &iter);
688 account_chooser_account_removed_cb (TpAccountManager *manager,
690 EmpathyAccountChooser *self)
692 account_chooser_account_remove_foreach (account, self);
703 account_chooser_find_account_foreach (GtkTreeModel *model,
708 FindAccountData *data = user_data;
712 gtk_tree_model_get (model, iter,
713 COL_ACCOUNT_POINTER, &account,
714 COL_ACCOUNT_ROW_TYPE, &type,
717 if (type != ROW_ACCOUNT)
720 if (account == data->account)
723 *(data->iter) = *iter;
724 g_object_unref (account);
729 g_object_unref (account);
735 account_chooser_find_account (EmpathyAccountChooser *self,
740 GtkComboBox *combobox;
741 FindAccountData data;
743 combobox = GTK_COMBO_BOX (self);
744 store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox));
746 data.account = account;
748 gtk_tree_model_foreach (GTK_TREE_MODEL (store),
749 account_chooser_find_account_foreach,
756 account_chooser_account_remove_foreach (TpAccount *account,
757 EmpathyAccountChooser *self)
760 GtkComboBox *combobox;
763 combobox = GTK_COMBO_BOX (self);
764 store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox));
766 if (account_chooser_find_account (self, account, &iter))
767 gtk_list_store_remove (store, &iter);
771 account_chooser_filter_ready_cb (gboolean is_enabled,
774 FilterResultCallbackData *fr_data = data;
775 EmpathyAccountChooser *self;
779 GtkComboBox *combobox;
780 const gchar *icon_name;
783 self = fr_data->self;
784 account = fr_data->account;
785 iter = fr_data->iter;
786 combobox = GTK_COMBO_BOX (self);
787 store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox));
789 icon_name = tp_account_get_icon_name (account);
790 pixbuf = empathy_pixbuf_from_icon_name (icon_name,
791 GTK_ICON_SIZE_BUTTON);
793 gtk_list_store_set (store, iter,
794 COL_ACCOUNT_IMAGE, pixbuf,
795 COL_ACCOUNT_TEXT, tp_account_get_display_name (account),
796 COL_ACCOUNT_ENABLED, is_enabled,
800 g_object_unref (pixbuf);
802 /* set first connected account as active account */
803 if (self->priv->account_manually_set == FALSE &&
804 self->priv->set_active_item == FALSE && is_enabled)
806 self->priv->set_active_item = TRUE;
807 gtk_combo_box_set_active_iter (combobox, iter);
810 filter_result_callback_data_free (fr_data);
814 account_chooser_update_iter (EmpathyAccountChooser *self,
818 GtkComboBox *combobox;
820 FilterResultCallbackData *data;
822 combobox = GTK_COMBO_BOX (self);
823 store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox));
825 gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
826 COL_ACCOUNT_POINTER, &account,
829 /* Skip rows without account associated */
833 data = filter_result_callback_data_new (self, account, iter);
835 if (self->priv->filter)
836 self->priv->filter (account, account_chooser_filter_ready_cb,
837 (gpointer) data, self->priv->filter_data);
839 account_chooser_filter_ready_cb (TRUE, (gpointer) data);
841 g_object_unref (account);
845 account_chooser_status_changed_cb (TpAccount *account,
849 gchar *dbus_error_name,
853 EmpathyAccountChooser *self = user_data;
856 if (account_chooser_find_account (self, account, &iter))
857 account_chooser_update_iter (self, &iter);
861 account_chooser_separator_func (GtkTreeModel *model,
863 EmpathyAccountChooser *self)
867 gtk_tree_model_get (model, iter, COL_ACCOUNT_ROW_TYPE, &row_type, -1);
868 return (row_type == ROW_SEPARATOR);
872 account_chooser_set_account_foreach (GtkTreeModel *model,
875 SetAccountData *data)
880 gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1);
882 equal = (data->account == account);
885 g_object_unref (account);
889 GtkComboBox *combobox;
891 combobox = GTK_COMBO_BOX (data->self);
892 gtk_combo_box_set_active_iter (combobox, iter);
901 account_chooser_filter_foreach (GtkTreeModel *model,
906 account_chooser_update_iter (self, iter);
911 * empathy_account_chooser_set_filter:
912 * @self: an #EmpathyAccountChooser
914 * @user_data: data to pass to @filter, or %NULL
916 * Sets a filter on the @self so only accounts that are %TRUE in the eyes
917 * of the filter are visible in the @self.
920 empathy_account_chooser_set_filter (EmpathyAccountChooser *self,
921 EmpathyAccountChooserFilterFunc filter,
926 g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self));
928 self->priv->filter = filter;
929 self->priv->filter_data = user_data;
931 /* Refilter existing data */
932 self->priv->set_active_item = FALSE;
933 model = gtk_combo_box_get_model (GTK_COMBO_BOX (self));
934 gtk_tree_model_foreach (model, account_chooser_filter_foreach, self);
938 * EmpathyAccountChooserFilterFunc:
939 * @account: a #TpAccount
940 * @user_data: user data, or %NULL
942 * A function which decides whether the account indicated by @account
945 * Return value: whether the account indicated by @account is visible.
949 empathy_account_chooser_is_ready (EmpathyAccountChooser *self)
951 return self->priv->ready;
955 empathy_account_chooser_get_account (EmpathyAccountChooser *self)
959 account = empathy_account_chooser_dup_account (self);
963 g_object_unref (account);
969 empathy_account_chooser_get_account_manager (EmpathyAccountChooser *self)
971 return self->priv->manager;
974 /* Pre-defined filters */
977 * empathy_account_chooser_filter_is_connected:
978 * @account: a #TpAccount
979 * @callback: an #EmpathyAccountChooserFilterResultCallback accepting the result
980 * @callback_data: data passed to the @callback
981 * @user_data: user data or %NULL
983 * A useful #EmpathyAccountChooserFilterFunc that one could pass into
984 * empathy_account_chooser_set_filter() and only show connected accounts.
986 * Returns (via the callback) TRUE is @account is connected
989 empathy_account_chooser_filter_is_connected (TpAccount *account,
990 EmpathyAccountChooserFilterResultCallback callback,
991 gpointer callback_data,
994 gboolean is_connected =
995 tp_account_get_connection_status (account, NULL)
996 == TP_CONNECTION_STATUS_CONNECTED;
998 callback (is_connected, callback_data);
1002 * empathy_account_chooser_filter_supports_multichat:
1003 * @account: a #TpAccount
1004 * @callback: an #EmpathyAccountChooserFilterResultCallback accepting the result
1005 * @callback_data: data passed to the @callback
1006 * @user_data: user data or %NULL
1008 * An #EmpathyAccountChooserFilterFunc that returns accounts that both
1009 * support multiuser text chat and are connected.
1011 * Returns (via the callback) TRUE if @account both supports muc and
1015 empathy_account_chooser_filter_supports_chatrooms (TpAccount *account,
1016 EmpathyAccountChooserFilterResultCallback callback,
1017 gpointer callback_data,
1020 TpConnection *connection;
1021 gboolean supported = FALSE;
1022 TpCapabilities *caps;
1024 /* check if CM supports multiuser text chat */
1025 connection = tp_account_get_connection (account);
1026 if (connection == NULL)
1029 caps = tp_connection_get_capabilities (connection);
1033 supported = tp_capabilities_supports_text_chatrooms (caps);
1036 callback (supported, callback_data);