void goa_utils_initialize_client_factory (void) { static gsize once_init_value = 0; if (g_once_init_enter (&once_init_value)) { TpSimpleClientFactory *factory; TpAccountManager *account_manager; GQuark account_features[] = {TP_ACCOUNT_FEATURE_STORAGE, TP_ACCOUNT_FEATURE_CONNECTION, 0}; GQuark connection_features[] = {TP_CONNECTION_FEATURE_AVATAR_REQUIREMENTS, TP_CONNECTION_FEATURE_CONTACT_INFO, 0}; /* We make sure that new instances of Telepathy objects will have all * the features we need. */ factory = tp_simple_client_factory_new (NULL); tp_simple_client_factory_add_account_features (factory, account_features); tp_simple_client_factory_add_connection_features (factory, connection_features); account_manager = tp_account_manager_new_with_factory (factory); tp_account_manager_set_default (account_manager); g_object_unref (account_manager); g_object_unref (factory); g_once_init_leave (&once_init_value, 1); } }
static void cm_requested_connection (TpConnectionManager *manager, const gchar *bus_name, const gchar *object_path, const GError *error, gpointer user_data, GObject *weak_object) { TpSimpleClientFactory *factory; GError *e = NULL; TpConnection *conn; if (die_if (error, "RequestConnection()")) return; /* Because we don't have an AccountManager, we have to do more work here. */ factory = tp_simple_client_factory_new (NULL); conn = tp_simple_client_factory_ensure_connection (factory, object_path, NULL, &e); g_object_unref (factory); if (conn == NULL) { g_warning ("tp_connection_new(): %s", error->message); g_main_loop_quit (mainloop); return; } /* the connection hasn't had a chance to become invalid yet, so we can * assume that this signal connection will work */ tp_cli_connection_connect_to_status_changed (conn, conn_status_changed, NULL, NULL, NULL, NULL); tp_proxy_prepare_async (conn, NULL, conn_ready, NULL); tp_cli_connection_call_connect (conn, -1, NULL, NULL, NULL, NULL); }
int main (int argc, char **argv) { GOptionContext *context; GError *error = NULL; EmpathyAuthFactory *factory; TpDebugSender *debug_sender; TpSimpleClientFactory *tp_factory; TpDBusDaemon *dbus; context = g_option_context_new (N_(" — Empathy authentication client")); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print ("%s\nRun '%s --help' to see a full list of available command " "line options.\n", error->message, argv[0]); g_warning ("Error in empathy-auth-client init: %s", error->message); return EXIT_FAILURE; } g_option_context_free (context); empathy_gtk_init (); gnutls_global_init (); g_set_application_name (_("Empathy authentication client")); /* Make empathy and empathy-auth-client appear as the same app in * gnome-shell */ g_set_prgname ("empathy"); gtk_window_set_default_icon_name ("empathy"); textdomain (GETTEXT_PACKAGE); /* There is no 'main' UI window so just use the default GdkScreen */ empathy_set_css_provider (NULL); #ifdef ENABLE_DEBUG /* Set up debug sender */ debug_sender = tp_debug_sender_dup (); g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN); #endif dbus = tp_dbus_daemon_dup (NULL); tp_factory = tp_simple_client_factory_new (dbus); tp_simple_client_factory_add_account_features_varargs (tp_factory, TP_ACCOUNT_FEATURE_STORAGE, 0); factory = empathy_auth_factory_new (tp_factory); g_object_unref (tp_factory); g_object_unref (dbus); g_signal_connect (factory, "new-server-tls-handler", G_CALLBACK (auth_factory_new_tls_handler_cb), NULL); g_signal_connect (factory, "new-server-sasl-handler", G_CALLBACK (auth_factory_new_sasl_handler_cb), NULL); g_signal_connect (factory, "auth-password-failed", G_CALLBACK (auth_factory_auth_passsword_failed), NULL); if (!empathy_auth_factory_register (factory, &error)) { g_critical ("Failed to register the auth factory: %s\n", error->message); g_error_free (error); g_object_unref (factory); return EXIT_FAILURE; } DEBUG ("Empathy auth client started."); if (g_getenv ("EMPATHY_PERSIST") != NULL) { DEBUG ("Timed-exit disabled"); use_timer = FALSE; } /* Wait for the migration code to be done before starting the timer */ empathy_sanity_checking_run_async (sanity_cb, NULL); gtk_main (); g_object_unref (factory); g_object_unref (debug_sender); return EXIT_SUCCESS; }