static const gchar * _get_manager_for_protocol (EmpathyConnectionManagers *managers, const gchar *protocol) { GList *cms = empathy_connection_managers_get_cms (managers); GList *l; TpConnectionManager *haze = NULL; TpConnectionManager *cm = NULL; for (l = cms; l; l = l->next) { TpConnectionManager *tp_cm = l->data; /* Only use haze if no other cm provides this protocol */ if (!tp_strdiff (tp_connection_manager_get_name (tp_cm), "haze")) { haze = tp_cm; continue; } if (tp_connection_manager_has_protocol (tp_cm, protocol)) { cm = tp_cm; goto out; } } if (haze != NULL && tp_connection_manager_has_protocol (haze, protocol)) return tp_connection_manager_get_name (haze); out: return cm != NULL ? tp_connection_manager_get_name (cm) : NULL; }
static void account_manager_prepared_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object); EmpathyImportWidget *self = user_data; GtkTreeModel *model; GtkTreeIter iter; GList *l; EmpathyImportWidgetPriv *priv = GET_PRIV (self); GError *error = NULL; if (!tp_proxy_prepare_finish (manager, result, &error)) { DEBUG ("Failed to prepare account manager: %s", error->message); g_error_free (error); return; } model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); for (l = priv->accounts; l; l = l->next) { GValue *value; EmpathyImportAccountData *data = l->data; gboolean import; GList *accounts; TpConnectionManager *cm = NULL; if (!empathy_import_protocol_is_supported (data->protocol, &cm)) continue; data->connection_manager = g_strdup ( tp_connection_manager_get_name (cm)); value = g_hash_table_lookup (data->settings, "account"); accounts = tp_account_manager_get_valid_accounts (manager); /* Only set the "Import" cell to be active if there isn't already an * account set up with the same account id. */ import = !import_widget_account_id_in_list (accounts, g_value_get_string (value)); g_list_free (accounts); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_IMPORT, import, COL_PROTOCOL, data->protocol, COL_NAME, g_value_get_string (value), COL_SOURCE, data->source, COL_ACCOUNT_DATA, data, -1); } }
static void import_widget_add_accounts_to_model (EmpathyImportWidget *self) { TpAccountManager *manager; GtkTreeModel *model; GList *l; EmpathyImportWidgetPriv *priv = GET_PRIV (self); gint min, natural; manager = tp_account_manager_dup (); model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); for (l = priv->accounts; l; l = l->next) { GValue *value; EmpathyImportAccountData *data = l->data; gboolean import; GList *accounts; TpConnectionManager *cm = NULL; if (!empathy_import_protocol_is_supported (data->protocol, &cm)) continue; data->connection_manager = g_strdup ( tp_connection_manager_get_name (cm)); value = g_hash_table_lookup (data->settings, "account"); accounts = tp_account_manager_dup_valid_accounts (manager); /* Only set the "Import" cell to be active if there isn't already an * account set up with the same account id. */ import = !import_widget_account_id_in_list (accounts, g_value_get_string (value)); g_list_free_full (accounts, g_object_unref); gtk_list_store_insert_with_values (GTK_LIST_STORE (model), NULL, -1, COL_IMPORT, import, COL_PROTOCOL, data->protocol, COL_NAME, g_value_get_string (value), COL_SOURCE, data->source, COL_ACCOUNT_DATA, data, -1); } /* Display as much rows as possible */ gtk_widget_get_preferred_height (priv->treeview, &min, &natural); gtk_widget_set_size_request (priv->scrolledwindow, -1, MIN (natural, MAX_TREEVIEW_HEIGHT)); g_object_unref (manager); }