static void account_manager_ready_for_accounts_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object); const gchar *account_id = (const gchar*) user_data; GError *error = NULL; if (!tp_account_manager_prepare_finish (manager, result, &error)) { DEBUG ("Failed to prepare account manager: %s", error->message); g_clear_error (&error); return; } if (account_id != NULL) { gchar *account_path; TpAccount *account = NULL; TpDBusDaemon *bus; /* create and prep the corresponding TpAccount so it's fully ready by the * time we try to select it in the accounts dialog */ account_path = g_strdup_printf ("%s%s", TP_ACCOUNT_OBJECT_PATH_BASE, account_id); bus = tp_dbus_daemon_dup (NULL); if ((account = tp_account_new (bus, account_path, &error))) { tp_account_prepare_async (account, NULL, account_prepare_cb, manager); return; } else { DEBUG ("Failed to find account with path %s: %s", account_path, error->message); g_clear_error (&error); } g_object_unref (bus); g_free (account_path); } else { if (empathy_import_mc4_has_imported ()) { maybe_show_accounts_ui (manager); } else { EmpathyConnectionManagers *cm_mgr = empathy_connection_managers_dup_singleton (); empathy_connection_managers_prepare_async ( cm_mgr, cm_manager_prepared_cb, manager); } } }
static void empathy_import_widget_init (EmpathyImportWidget *self) { EmpathyImportWidgetPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_IMPORT_WIDGET, EmpathyImportWidgetPriv); self->priv = priv; priv->cms = empathy_connection_managers_dup_singleton (); }
static void account_manager_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object); GError *error = NULL; EmpathyIdle *idle; EmpathyConnectivity *connectivity; gboolean autoconnect = TRUE; if (!tp_account_manager_prepare_finish (manager, result, &error)) { DEBUG ("Failed to prepare account manager: %s", error->message); g_error_free (error); return; } /* Autoconnect */ idle = empathy_idle_dup_singleton (); connectivity = empathy_connectivity_dup_singleton (); empathy_conf_get_bool (empathy_conf_get (), EMPATHY_PREFS_AUTOCONNECT, &autoconnect); if (autoconnect && !no_connect && tp_connection_presence_type_cmp_availability (empathy_idle_get_state (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) /* if current state is Offline, then put it online */ empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE); if (should_create_salut_account (manager) || !empathy_import_mc4_has_imported ()) { EmpathyConnectionManagers *managers; managers = empathy_connection_managers_dup_singleton (); if (!check_connection_managers_ready (managers)) { g_signal_connect (managers, "notify::ready", G_CALLBACK (connection_managers_ready_cb), NULL); } } else if (!start_hidden) { maybe_show_account_assistant (); } g_object_unref (idle); g_object_unref (connectivity); }
static void empathy_protocol_chooser_init (EmpathyProtocolChooser *protocol_chooser) { EmpathyProtocolChooserPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (protocol_chooser, EMPATHY_TYPE_PROTOCOL_CHOOSER, EmpathyProtocolChooserPriv); priv->dispose_run = FALSE; priv->cms = empathy_connection_managers_dup_singleton (); priv->protocols = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); protocol_chooser->priv = priv; }
gboolean empathy_import_protocol_is_supported (const gchar *protocol, TpConnectionManager **cm) { EmpathyConnectionManagers *manager; GList *cms; GList *l; gboolean proto_is_supported = FALSE; manager = empathy_connection_managers_dup_singleton (); cms = empathy_connection_managers_get_cms (manager); for (l = cms; l; l = l->next) { TpConnectionManager *tp_cm = l->data; if (tp_connection_manager_has_protocol (tp_cm, (const gchar*) protocol)) { if (!tp_strdiff (protocol, "irc") && !tp_strdiff (tp_cm->name, "haze")) continue; if (!proto_is_supported) { *cm = tp_cm; proto_is_supported = TRUE; continue; } /* we have more than one CM for this protocol, * select the one which is not haze. */ if (!tp_strdiff ((*cm)->name, "haze")) { *cm = tp_cm; break; } } } g_object_unref (manager); return proto_is_supported; }