void remmina_tp_channel_handler_new(const gchar *account_path, const gchar *connection_path, const gchar *channel_path, GHashTable *channel_properties, DBusGMethodInvocation *context) { TpDBusDaemon *bus; TpAccount *account; GError *error = NULL; RemminaTpChannelHandler *chandler; bus = tp_dbus_daemon_dup(&error); if (bus == NULL) { g_print("tp_dbus_daemon_dup: %s", error->message); return; } account = tp_account_new(bus, account_path, &error); if (account == NULL) { g_object_unref(bus); g_print("tp_account_new: %s", error->message); return; } chandler = g_new0(RemminaTpChannelHandler, 1); chandler->bus = bus; chandler->account = account; chandler->connection_path = g_strdup(connection_path); chandler->channel_path = g_strdup(channel_path); chandler->channel_properties = tp_asv_new(NULL, NULL); tp_g_hash_table_update(chandler->channel_properties, channel_properties, (GBoxedCopyFunc) g_strdup, (GBoxedCopyFunc) tp_g_value_slice_dup); chandler->context = context; tp_account_prepare_async(account, NULL, remmina_tp_channel_handler_account_ready, chandler); }
static void empathy_ft_factory_init (EmpathyFTFactory *self) { EmpathyFTFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_FT_FACTORY, EmpathyFTFactoryPriv); TpDBusDaemon *dbus; GError *error = NULL; self->priv = priv; dbus = tp_dbus_daemon_dup (&error); if (dbus == NULL) { g_warning ("Failed to get TpDBusDaemon: %s", error->message); g_error_free (error); return; } priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE, EMPATHY_FT_BUS_NAME_SUFFIX, FALSE, handle_channels_cb, self, NULL); tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, /* Only handle *incoming* channels as outgoing FT channels has to be * handled by the requester. */ TP_PROP_CHANNEL_REQUESTED, G_TYPE_BOOLEAN, FALSE, NULL)); g_object_unref (dbus); }
/** * tp_yts_client_new: * @service_name: The Ytstenut service name for this client. * @account: The Ytstenut account for this client. * * Create a new #TpYtsClient object for the given Ytstenut name and * account. After getting the new client object, you should add * localized names, capabilities and interests with * tp_yts_client_add_names(), tp_yts_client_add_capabilities() and * tp_yts_client_add_interests() respectively. * After setting these values, You should call * tp_yts_client_register() to register the client. g_object_unref() * should be used to free the object. * * Returns: A newly allocated client object. */ TpYtsClient * tp_yts_client_new (const gchar *service_name, TpAccount *account) { TpYtsClient *out = NULL; TpDBusDaemon *bus; gchar *name, *tmp; g_return_val_if_fail (tp_dbus_check_valid_interface_name (service_name, NULL), NULL); name = g_strdup_printf ("Ytsenut.Client.%s", service_name); bus = tp_dbus_daemon_dup (NULL); out = g_object_new (TP_TYPE_YTS_CLIENT, "dbus-daemon", bus, "name", name, "service-name", service_name, "uniquify-name", TRUE, "account", account, NULL); g_object_unref (bus); g_free (name); /* add uid handler capability token */ tmp = g_strdup_printf (TP_YTS_IFACE_CHANNEL "/uid/%s", service_name); tp_base_client_add_handler_capability (TP_BASE_CLIENT (out), tmp); g_free (tmp); return out; }
static void debug_dialog_fill_cm_chooser (EmpathyDebugDialog *debug_dialog) { EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog); GError *error = NULL; GtkTreeIter iter; priv->dbus = tp_dbus_daemon_dup (&error); if (error != NULL) { DEBUG ("Failed to dup dbus daemon: %s", error->message); g_error_free (error); return; } /* Add empathy */ gtk_list_store_append (priv->cms, &iter); gtk_list_store_set (priv->cms, &iter, COL_CM_NAME, "empathy", COL_CM_UNIQUE_NAME, "org.gnome.Empathy", -1); gtk_combo_box_set_active (GTK_COMBO_BOX (priv->cm_chooser), 0); /* Add CMs to list */ tp_list_connection_names (priv->dbus, debug_dialog_list_connection_names_cb, debug_dialog, NULL, NULL); priv->name_owner_changed_signal = tp_cli_dbus_daemon_connect_to_name_owner_changed (priv->dbus, debug_dialog_name_owner_changed_cb, debug_dialog, NULL, NULL, NULL); }
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); } } }
void TelepathyAccountHandler::getBuddiesAsync() { UT_DEBUGMSG(("TelepathyAccountHandler::getBuddiesAsync()\n")); // ask telepathy for the connection names TpDBusDaemon* dbus = tp_dbus_daemon_dup(NULL); UT_return_if_fail(dbus); tp_list_connection_names(dbus, list_connection_names_cb, this, NULL, NULL); g_object_unref(dbus); }
static void account_manager_ready_for_accounts_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object); GError *error = NULL; if (!tp_proxy_prepare_finish (manager, result, &error)) { DEBUG ("Failed to prepare account manager: %s", error->message); g_clear_error (&error); return; } account_manager_prepared = TRUE; if (selected_account_name != 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 */ if (g_str_has_prefix (selected_account_name, TP_ACCOUNT_OBJECT_PATH_BASE)) account_path = g_strdup (selected_account_name); else account_path = g_strdup_printf ("%s%s", TP_ACCOUNT_OBJECT_PATH_BASE, selected_account_name); bus = tp_dbus_daemon_dup (NULL); if ((account = tp_account_new (bus, account_path, &error))) { tp_proxy_prepare_async (account, NULL, account_prepare_cb, manager); g_object_unref (bus); return; } else { DEBUG ("Failed to find account with path %s: %s", account_path, error->message); g_clear_error (&error); maybe_show_accounts_ui (manager); } g_object_unref (bus); g_free (account_path); } else { maybe_show_accounts_ui (manager); } }
static void empathy_contact_manager_init (EmpathyContactManager *manager) { EmpathyContactManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, EMPATHY_TYPE_CONTACT_MANAGER, EmpathyContactManagerPriv); TpDBusDaemon *bus; GError *error = NULL; manager->priv = priv; priv->lists = g_hash_table_new_full (empathy_proxy_hash, empathy_proxy_equal, (GDestroyNotify) g_object_unref, (GDestroyNotify) g_object_unref); priv->favourites = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_hash_table_unref); priv->account_manager = tp_account_manager_dup (); priv->contact_monitor = NULL; tp_account_manager_prepare_async (priv->account_manager, NULL, account_manager_prepared_cb, manager); bus = tp_dbus_daemon_dup (&error); if (error == NULL) { priv->logger = g_object_new (TP_TYPE_PROXY, "bus-name", "org.freedesktop.Telepathy.Logger", "object-path", "/org/freedesktop/Telepathy/Logger", "dbus-daemon", bus, NULL); g_object_unref (bus); tp_proxy_add_interface_by_id (priv->logger, EMP_IFACE_QUARK_LOGGER); logger_favourite_contacts_setup (manager); priv->favourite_contacts_changed_signal = emp_cli_logger_connect_to_favourite_contacts_changed ( priv->logger, logger_favourite_contacts_changed_cb, NULL, NULL, G_OBJECT (manager), NULL); } else { DEBUG ("Failed to get telepathy-logger proxy: %s", error->message); g_clear_error (&error); } }
int main (int argc, char **argv) { TpConnectionManager *cm = NULL; GError *error = NULL; TpDBusDaemon *dbus = NULL; tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); example_cli_init (); dbus = tp_dbus_daemon_dup (&error); if (dbus == NULL) { g_warning ("%s", error->message); g_error_free (error); goto out; } mainloop = g_main_loop_new (NULL, FALSE); cm = tp_connection_manager_new (dbus, "example_extended", NULL, &error); if (cm == NULL) { g_warning ("%s", error->message); goto out; } g_signal_connect (cm, "got-info", G_CALLBACK (connection_manager_got_info), NULL); timer = g_timeout_add (5000, time_out, NULL); g_main_loop_run (mainloop); out: if (cm != NULL) g_object_unref (cm); if (dbus != NULL) g_object_unref (dbus); if (mainloop != NULL) g_main_loop_unref (mainloop); return main_ret; }
static gboolean tp_base_connection_manager_ensure_dbus (TpBaseConnectionManager *self, GError **error) { if (self->priv->dbus_daemon == NULL) { self->priv->dbus_daemon = tp_dbus_daemon_dup (error); if (self->priv->dbus_daemon == NULL) return FALSE; } return TRUE; }
static void empathy_presence_manager_init (EmpathyPresenceManager *self) { TpDBusDaemon *dbus; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_PRESENCE_MANAGER, EmpathyPresenceManagerPrivate); self->priv->is_idle = FALSE; self->priv->manager = tp_account_manager_dup (); tp_account_manager_prepare_async (self->priv->manager, NULL, account_manager_ready_cb, self); tp_g_signal_connect_object (self->priv->manager, "most-available-presence-changed", G_CALLBACK (most_available_presence_changed), self, 0); dbus = tp_dbus_daemon_dup (NULL); self->priv->gs_proxy = dbus_g_proxy_new_for_name ( tp_proxy_get_dbus_connection (dbus), "org.gnome.SessionManager", "/org/gnome/SessionManager/Presence", "org.gnome.SessionManager.Presence"); if (self->priv->gs_proxy) { dbus_g_proxy_add_signal (self->priv->gs_proxy, "StatusChanged", G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal (self->priv->gs_proxy, "StatusChanged", G_CALLBACK (session_status_changed_cb), self, NULL); } else { DEBUG ("Failed to get gs proxy"); } g_object_unref (dbus); self->priv->connectivity = empathy_connectivity_dup_singleton (); tp_g_signal_connect_object (self->priv->connectivity, "state-change", G_CALLBACK (state_change_cb), self, 0); self->priv->connect_times = g_hash_table_new (g_direct_hash, g_direct_equal); }
static void empathy_chat_manager_constructed (GObject *obj) { TpDBusDaemon *dbus_daemon; dbus_daemon = tp_dbus_daemon_dup (NULL); if (dbus_daemon != NULL) { tp_dbus_daemon_register_object (dbus_daemon, "/org/gnome/Empathy/ChatManager", obj); g_object_unref (dbus_daemon); } }
TpDBusDaemon * tp_tests_dbus_daemon_dup_or_die (void) { TpDBusDaemon *d = tp_dbus_daemon_dup (NULL); /* In a shared library, this would be very bad (see fd.o #18832), but in a * regression test that's going to be run under a temporary session bus, * it's just what we want. */ if (d == NULL) { g_error ("Unable to connect to session bus"); } return d; }
static void empathy_connection_managers_init (EmpathyConnectionManagers *obj) { EmpathyConnectionManagersPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ EMPATHY_TYPE_CONNECTION_MANAGERS, EmpathyConnectionManagersPriv); obj->priv = priv; priv->dbus = tp_dbus_daemon_dup (NULL); g_assert (priv->dbus != NULL); empathy_connection_managers_update (obj); /* allocate any data required by the object here */ }
static void vino_tube_servers_manager_init (VinoTubeServersManager *self) { TpDBusDaemon *dbus; GError *error = NULL; TpSimpleClientFactory *factory; self->priv = VINO_TUBE_SERVERS_MANAGER_GET_PRIVATE (self); self->priv->vino_tube_servers = NULL; self->priv->alternative_port = 26570; dbus = tp_dbus_daemon_dup (NULL); factory = TP_SIMPLE_CLIENT_FACTORY (tp_automatic_client_factory_new (dbus)); g_object_unref (dbus); tp_simple_client_factory_add_contact_features_varargs (factory, TP_CONTACT_FEATURE_ALIAS, TP_CONTACT_FEATURE_AVATAR_DATA, TP_CONTACT_FEATURE_INVALID); tp_simple_client_factory_add_channel_features_varargs (factory, TP_CHANNEL_FEATURE_CONTACTS, 0); self->priv->handler = tp_simple_handler_new_with_factory (factory, FALSE, FALSE, "Vino", FALSE, handle_channels_cb, self, NULL); g_object_unref (factory); tp_base_client_take_handler_filter (self->priv->handler, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_PROP_CHANNEL_REQUESTED, G_TYPE_BOOLEAN, TRUE, TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING, "rfb", NULL)); if (!tp_base_client_register (self->priv->handler, &error)) { dprintf (TUBE, "Failed to register Handler: %s\n", error->message); g_error_free (error); } }
static void list_connection_names_cb (const gchar * const *bus_names, gsize n, const gchar * const * cms, const gchar * const * protocols, const GError *error, gpointer user_data, GObject * /*unused*/) { UT_DEBUGMSG(("list_connection_names_cb()\n")); TelepathyAccountHandler* pHandler = reinterpret_cast<TelepathyAccountHandler*>(user_data); UT_return_if_fail(pHandler); if (error != NULL) { UT_DEBUGMSG(("List connectiones failed: %s", error->message)); UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); return; } TpDBusDaemon* dbus = tp_dbus_daemon_dup(NULL); UT_return_if_fail(dbus); UT_DEBUGMSG(("Got %d connections:\n", (int)n)); for (UT_uint32 i = 0; i < n; i++) { UT_DEBUGMSG(("%d: Bus name %s, connection manager %s, protocol %s\n", i+1, bus_names[i], cms[i], protocols[i])); TpConnection* connection = tp_connection_new (dbus, bus_names[i], NULL, NULL); UT_continue_if_fail(connection); TpCapabilities* caps = tp_connection_get_capabilities(connection); if (!caps) { GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 }; tp_proxy_prepare_async(connection, features, prepare_connection_cb, pHandler); } else { validate_connection(connection, pHandler); } } g_object_unref(dbus); }
ConnectResult TelepathyAccountHandler::connect() { UT_DEBUGMSG(("TelepathyAccountHandler::connect()\n")); AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); UT_return_val_if_fail(pManager, CONNECT_FAILED); UT_return_val_if_fail(m_pTpClient == NULL, CONNECT_INTERNAL_ERROR); // inform telepathy that we can handle incoming AbiCollab tubes GError *error = NULL; TpDBusDaemon* dbus = tp_dbus_daemon_dup (&error); UT_return_val_if_fail(dbus, CONNECT_FAILED); m_pTpClient = tp_simple_handler_new(dbus, TRUE, FALSE, "AbiCollab", FALSE, handle_dbus_channel, this, NULL); tp_base_client_take_handler_filter(m_pTpClient, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_DBUS_TUBE, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_ROOM, TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME, G_TYPE_STRING, INTERFACE, NULL ) ); if (!tp_base_client_register(m_pTpClient, &error)) { UT_DEBUGMSG(("Error registering tube handler: %s", error->message)); UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); } UT_DEBUGMSG(("Tube handler setup, listening for incoming tubes...\n")); // we are connected now, time to start sending out messages (such as events) pManager->registerEventListener(this); // signal all listeners we are logged in AccountOnlineEvent event; pManager->signal(event); return CONNECT_SUCCESS; }
static void empathy_idle_init (EmpathyIdle *idle) { EmpathyIdlePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (idle, EMPATHY_TYPE_IDLE, EmpathyIdlePriv); TpDBusDaemon *dbus; idle->priv = priv; priv->is_idle = FALSE; priv->manager = tp_account_manager_dup (); tp_account_manager_prepare_async (priv->manager, NULL, account_manager_ready_cb, idle); priv->idle_presence_changed_id = g_signal_connect (priv->manager, "most-available-presence-changed", G_CALLBACK (idle_presence_changed_cb), idle); dbus = tp_dbus_daemon_dup (NULL); priv->gs_proxy = dbus_g_proxy_new_for_name ( tp_proxy_get_dbus_connection (dbus), "org.gnome.SessionManager", "/org/gnome/SessionManager/Presence", "org.gnome.SessionManager.Presence"); if (priv->gs_proxy) { dbus_g_proxy_add_signal (priv->gs_proxy, "StatusChanged", G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->gs_proxy, "StatusChanged", G_CALLBACK (idle_session_status_changed_cb), idle, NULL); } else { DEBUG ("Failed to get gs proxy"); } g_object_unref (dbus); priv->connectivity = empathy_connectivity_dup_singleton (); priv->state_change_signal_id = g_signal_connect (priv->connectivity, "state-change", G_CALLBACK (idle_state_change_cb), idle); priv->connect_times = g_hash_table_new (g_direct_hash, g_direct_equal); }
static void debug_dialog_list_connection_names_cb (const gchar * const *names, gsize n, const gchar * const *cms, const gchar * const *protocols, const GError *error, gpointer user_data, GObject *weak_object) { EmpathyDebugDialog *debug_dialog = (EmpathyDebugDialog *) user_data; guint i; TpDBusDaemon *dbus; GError *error2 = NULL; if (error != NULL) { DEBUG ("list_connection_names failed: %s", error->message); return; } dbus = tp_dbus_daemon_dup (&error2); if (error2 != NULL) { DEBUG ("Failed to dup TpDBusDaemon."); g_error_free (error2); return; } for (i = 0; cms[i] != NULL; i++) { FillCmChooserData *data; data = g_slice_new0 (FillCmChooserData); data->debug_dialog = debug_dialog; data->cm_name = g_strdup (cms[i]); tp_cli_dbus_daemon_call_get_name_owner (dbus, -1, names[i], debug_dialog_get_name_owner_cb, data, NULL, NULL); } g_object_unref (dbus); }
int main (int argc, char **argv) { GError *error = NULL; g_type_init (); if (argc != 4) { g_error ("Must provide first name, last name and filename"); } /* create a main loop */ loop = g_main_loop_new (NULL, FALSE); /* acquire a connection to the D-Bus daemon */ bus_daemon = tp_dbus_daemon_dup (&error); if (bus_daemon == NULL) { g_error ("%s", error->message); } /* we want to request the salut CM */ TpConnectionManager *cm = tp_connection_manager_new (bus_daemon, "salut", NULL, &error); if (error) g_error ("%s", error->message); tp_connection_manager_call_when_ready (cm, cm_ready, argv, NULL, NULL); /* set up a signal handler */ struct sigaction sa = { 0 }; sa.sa_handler = interrupt_cb; sigaction (SIGINT, &sa, NULL); g_main_loop_run (loop); g_object_unref (bus_daemon); return 0; }
static void debug_dialog_fill_cm_chooser (EmpathyDebugDialog *debug_dialog) { EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog); GError *error = NULL; priv->dbus = tp_dbus_daemon_dup (&error); if (error != NULL) { DEBUG ("Failed to dup dbus daemon: %s", error->message); g_error_free (error); return; } tp_list_connection_names (priv->dbus, debug_dialog_list_connection_names_cb, debug_dialog, NULL, NULL); priv->name_owner_changed_signal = tp_cli_dbus_daemon_connect_to_name_owner_changed (priv->dbus, debug_dialog_name_owner_changed_cb, debug_dialog, NULL, NULL, NULL); }
static gchar * create_channel_request (TpTestsSimpleChannelDispatcher *self, const gchar *account, GHashTable *request, gint64 user_action_time, const gchar *preferred_handler) { TpTestsSimpleChannelRequest *chan_request; GPtrArray *requests; static guint count = 0; gchar *path; TpDBusDaemon *dbus; requests = g_ptr_array_sized_new (1); g_ptr_array_add (requests, request); path = g_strdup_printf ("/Request%u", count++); chan_request = tp_tests_simple_channel_request_new (path, self->priv->conn, account, user_action_time, preferred_handler, requests); self->priv->requests = g_slist_append (self->priv->requests, chan_request); g_ptr_array_free (requests, TRUE); dbus = tp_dbus_daemon_dup (NULL); g_assert (dbus != NULL); tp_dbus_daemon_register_object (dbus, path, chan_request); g_object_unref (dbus); g_signal_emit (self, signals[CHANNEL_REQUEST_CREATED], 0, chan_request); return path; }
void empathy_chat_manager_call_undo_closed_chat (void) { TpDBusDaemon *dbus_daemon = tp_dbus_daemon_dup (NULL); TpProxy *proxy; if (dbus_daemon == NULL) return; proxy = g_object_new (TP_TYPE_PROXY, "dbus-daemon", dbus_daemon, "dbus-connection", tp_proxy_get_dbus_connection (TP_PROXY (dbus_daemon)), "bus-name", EMPATHY_CHAT_BUS_NAME, "object-path", "/org/gnome/Empathy/ChatManager", NULL); tp_proxy_add_interface_by_id (proxy, EMP_IFACE_QUARK_CHAT_MANAGER); emp_cli_chat_manager_call_undo_closed_chat (proxy, -1, empathy_get_current_action_time (), NULL, NULL, NULL, NULL); g_object_unref (proxy); g_object_unref (dbus_daemon); }
int main (int argc, char *argv[]) { #if HAVE_GEOCLUE EmpathyLocationManager *location_manager = NULL; #endif EmpathyStatusIcon *icon; EmpathyDispatcher *dispatcher; TpAccountManager *account_manager; EmpathyLogManager *log_manager; EmpathyChatroomManager *chatroom_manager; EmpathyCallFactory *call_factory; EmpathyFTFactory *ft_factory; GtkWidget *window; EmpathyIdle *idle; EmpathyConnectivity *connectivity; GError *error = NULL; TpDBusDaemon *dbus_daemon; UniqueApp *unique_app; gboolean chatroom_manager_ready; GOptionContext *optcontext; GOptionEntry options[] = { { "no-connect", 'n', 0, G_OPTION_ARG_NONE, &no_connect, N_("Don't connect on startup"), NULL }, { "start-hidden", 'h', 0, G_OPTION_ARG_NONE, &start_hidden, N_("Don't display the contact list or any other dialogs on startup"), NULL }, { "accounts", 'a', 0, G_OPTION_ARG_NONE, &account_dialog_only, N_("Show the accounts dialog"), NULL }, { "version", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version_cb, NULL, NULL }, { NULL } }; /* Init */ g_thread_init (NULL); empathy_init (); optcontext = g_option_context_new (N_("- Empathy IM Client")); g_option_context_add_group (optcontext, gst_init_get_option_group ()); g_option_context_add_group (optcontext, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE); if (!g_option_context_parse (optcontext, &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 init: %s", error->message); return EXIT_FAILURE; } g_option_context_free (optcontext); empathy_gtk_init (); g_set_application_name (_(PACKAGE_NAME)); g_setenv ("PULSE_PROP_media.role", "phone", TRUE); #if HAVE_LIBCHAMPLAIN gtk_clutter_init (&argc, &argv); #endif gtk_window_set_default_icon_name ("empathy"); textdomain (GETTEXT_PACKAGE); #ifdef ENABLE_DEBUG /* Set up debugger */ g_log_set_default_handler (default_log_handler, NULL); #endif unique_app = unique_app_new_with_commands ("org.gnome.Empathy", NULL, "accounts_dialog", COMMAND_ACCOUNTS_DIALOG, NULL); if (unique_app_is_running (unique_app)) { unique_app_send_message (unique_app, account_dialog_only ? COMMAND_ACCOUNTS_DIALOG : UNIQUE_ACTIVATE, NULL); g_object_unref (unique_app); return EXIT_SUCCESS; } /* Take well-known name */ dbus_daemon = tp_dbus_daemon_dup (&error); if (error == NULL) { if (!tp_dbus_daemon_request_name (dbus_daemon, "org.gnome.Empathy", TRUE, &error)) { DEBUG ("Failed to request well-known name: %s", error ? error->message : "no message"); g_clear_error (&error); } g_object_unref (dbus_daemon); } else { DEBUG ("Failed to dup dbus daemon: %s", error ? error->message : "no message"); g_clear_error (&error); } if (account_dialog_only) { account_manager = tp_account_manager_dup (); show_accounts_ui (NULL, TRUE); gtk_main (); g_object_unref (account_manager); return 0; } notify_init (_(PACKAGE_NAME)); /* Setting up Idle */ idle = empathy_idle_dup_singleton (); empathy_idle_set_auto_away (idle, TRUE); /* Setting up Connectivity */ connectivity = empathy_connectivity_dup_singleton (); use_conn_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_CONN, connectivity); empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_CONN, use_conn_notify_cb, connectivity); /* account management */ account_manager = tp_account_manager_dup (); tp_account_manager_prepare_async (account_manager, NULL, account_manager_ready_cb, NULL); /* Handle channels */ dispatcher = setup_dispatcher (); g_signal_connect (dispatcher, "dispatch", G_CALLBACK (dispatch_cb), NULL); migrate_config_to_xdg_dir (); /* Setting up UI */ window = empathy_main_window_show (); icon = empathy_status_icon_new (GTK_WINDOW (window), start_hidden); g_signal_connect (unique_app, "message-received", G_CALLBACK (unique_app_message_cb), window); /* Logging */ log_manager = empathy_log_manager_dup_singleton (); empathy_log_manager_observe (log_manager, dispatcher); chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL); empathy_chatroom_manager_observe (chatroom_manager, dispatcher); g_object_get (chatroom_manager, "ready", &chatroom_manager_ready, NULL); if (!chatroom_manager_ready) { g_signal_connect (G_OBJECT (chatroom_manager), "notify::ready", G_CALLBACK (chatroom_manager_ready_cb), account_manager); } else { chatroom_manager_ready_cb (chatroom_manager, NULL, account_manager); } /* Create the call factory */ call_factory = empathy_call_factory_initialise (); g_signal_connect (G_OBJECT (call_factory), "new-call-handler", G_CALLBACK (new_call_handler_cb), NULL); /* Create the FT factory */ ft_factory = empathy_ft_factory_dup_singleton (); g_signal_connect (ft_factory, "new-ft-handler", G_CALLBACK (new_ft_handler_cb), NULL); g_signal_connect (ft_factory, "new-incoming-transfer", G_CALLBACK (new_incoming_transfer_cb), NULL); /* Location mananger */ #if HAVE_GEOCLUE location_manager = empathy_location_manager_dup_singleton (); #endif gtk_main (); empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE); g_object_unref (idle); g_object_unref (connectivity); g_object_unref (icon); g_object_unref (account_manager); g_object_unref (log_manager); g_object_unref (dispatcher); g_object_unref (chatroom_manager); #if HAVE_GEOCLUE g_object_unref (location_manager); #endif g_object_unref (ft_factory); g_object_unref (unique_app); notify_uninit (); return EXIT_SUCCESS; }
static void preferences_preview_theme_changed_cb (EmpathyThemeManager *manager, EmpathyPreferences *preferences) { EmpathyPreferencesPriv *priv = GET_PRIV (preferences); TpDBusDaemon *dbus; TpAccount *account; EmpathyContact *juliet; EmpathyContact *romeo; DEBUG ("Theme changed, update preview widget"); if (priv->chat_theme_preview != NULL) { gtk_widget_destroy (GTK_WIDGET (priv->chat_theme_preview)); } priv->chat_theme_preview = empathy_theme_manager_create_view (manager); gtk_container_add (GTK_CONTAINER (priv->sw_chat_theme_preview), GTK_WIDGET (priv->chat_theme_preview)); gtk_widget_show (GTK_WIDGET (priv->chat_theme_preview)); /* FIXME: It is ugly to add a fake conversation like that. * Would be cool if we could request a TplLogManager for a fake * conversation */ dbus = tp_dbus_daemon_dup (NULL); account = tp_account_new (dbus, TP_ACCOUNT_OBJECT_PATH_BASE "cm/jabber/account", NULL); juliet = g_object_new (EMPATHY_TYPE_CONTACT, "account", account, "id", "juliet", /* translators: Contact name for the chat theme preview */ "alias", _("Juliet"), "is-user", FALSE, NULL); romeo = g_object_new (EMPATHY_TYPE_CONTACT, "account", account, "id", "romeo", /* translators: Contact name for the chat theme preview */ "alias", _("Romeo"), "is-user", TRUE, NULL); preferences_preview_theme_append_message (priv->chat_theme_preview, /* translators: Quote from Romeo & Julier, for chat theme preview */ juliet, romeo, _("O Romeo, Romeo, wherefore art thou Romeo?"), TRUE /* this message mentions Romeo */); preferences_preview_theme_append_message (priv->chat_theme_preview, /* translators: Quote from Romeo & Julier, for chat theme preview */ juliet, romeo, _("Deny thy father and refuse thy name;"), FALSE); preferences_preview_theme_append_message (priv->chat_theme_preview, /* translators: Quote from Romeo & Julier, for chat theme preview */ juliet, romeo, _("Or if thou wilt not, be but sworn my love"), FALSE); preferences_preview_theme_append_message (priv->chat_theme_preview, /* translators: Quote from Romeo & Julier, for chat theme preview */ juliet, romeo, _("And I'll no longer be a Capulet."), FALSE); preferences_preview_theme_append_message (priv->chat_theme_preview, /* translators: Quote from Romeo & Julier, for chat theme preview */ romeo, juliet, _("Shall I hear more, or shall I speak at this?"), FALSE); /* translators: Quote from Romeo & Julier, for chat theme preview */ empathy_chat_view_append_event (priv->chat_theme_preview, _("Juliet has disconnected")); g_object_unref (juliet); g_object_unref (romeo); g_object_unref (account); g_object_unref (dbus); }
void _client_create_tube_async (const gchar *account_path, const gchar *contact_id, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *simple; CreateTubeData *data; GHashTable *request; TpDBusDaemon *dbus; TpAccount *account = NULL; TpAccountChannelRequest *acr; GError *error = NULL; if (g_cancellable_is_cancelled (cancellable)) { g_simple_async_report_error_in_idle (NULL, callback, user_data, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Operation has been cancelled"); return; } dbus = tp_dbus_daemon_dup (&error); if (dbus != NULL) account = tp_account_new (dbus, account_path, &error); if (account == NULL) { g_simple_async_report_gerror_in_idle (NULL, callback, user_data, error); g_clear_error (&error); tp_clear_object (&dbus); return; } simple = g_simple_async_result_new (NULL, callback, user_data, _client_create_tube_finish); data = g_slice_new0 (CreateTubeData); data->op_cancellable = g_cancellable_new (); if (cancellable != NULL) { data->global_cancellable = g_object_ref (cancellable); data->cancelled_id = g_cancellable_connect (data->global_cancellable, G_CALLBACK (create_tube_cancelled_cb), simple, NULL); } g_simple_async_result_set_op_res_gpointer (simple, data, (GDestroyNotify) create_tube_data_free); request = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, contact_id, TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING, TUBE_SERVICE, NULL); acr = tp_account_channel_request_new (account, request, G_MAXINT64); tp_account_channel_request_create_and_handle_channel_async (acr, data->op_cancellable, create_channel_cb, simple); g_hash_table_unref (request); g_object_unref (dbus); g_object_unref (account); g_object_unref (acr); }
int main (int argc, char **argv) { GError *error = NULL; GDBusConnection *gdbus = NULL; GDBusConnection *gdbus_system = NULL; DBusConnection *connection = NULL; int ret = 1; GMainLoop *teardown_loop; guint linger_time = 5; g_type_init (); g_set_application_name ("Mission Control regression tests"); mcd_debug_init (); tp_debug_set_flags (g_getenv ("MC_TP_DEBUG")); /* Not all warnings are fatal due to MC spamming warnings (fd.o #23486), * but GLib and GObject warnings are pretty serious */ g_log_set_fatal_mask ("GLib", G_LOG_FATAL_MASK | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); g_log_set_fatal_mask ("GLib-GObject", G_LOG_FATAL_MASK | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); gdbus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); g_assert_no_error (error); g_assert (gdbus != NULL); g_dbus_connection_set_exit_on_close (gdbus, FALSE); gdbus_system = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); g_assert_no_error (error); g_assert (gdbus_system != NULL); g_dbus_connection_set_exit_on_close (gdbus_system, FALSE); bus_daemon = tp_dbus_daemon_dup (&error); g_assert_no_error (error); g_assert (bus_daemon != NULL); /* It appears that dbus-glib registers a filter that wrongly returns * DBUS_HANDLER_RESULT_HANDLED for signals, so for *our* filter to have any * effect, we need to install it as soon as possible */ connection = dbus_g_connection_get_connection ( tp_proxy_get_dbus_connection (bus_daemon)); dbus_connection_add_filter (connection, dbus_filter_function, NULL, NULL); mcd = mcd_service_new (); /* Listen for suicide notification */ g_signal_connect_after (mcd, "abort", G_CALLBACK (on_abort), NULL); /* connect */ mcd_mission_connect (MCD_MISSION (mcd)); dbus_connection_set_exit_on_disconnect (connection, FALSE); mcd_service_run (MCD_OBJECT (mcd)); ret = 0; teardown_loop = g_main_loop_new (NULL, FALSE); if (g_getenv ("MC_LINGER_TIME") != NULL) { linger_time = g_ascii_strtoull (g_getenv ("MC_LINGER_TIME"), NULL, 10); } /* Keep running in the background until it's all over. This means valgrind * and refdbg can get complete information. */ g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, linger_time, the_end, teardown_loop, (GDestroyNotify) g_main_loop_unref); g_main_loop_run (teardown_loop); if (connection != NULL) { dbus_connection_flush (connection); } tp_clear_object (&gdbus); tp_clear_object (&gdbus_system); tp_clear_object (&bus_daemon); dbus_shutdown (); g_message ("Exiting with %d", ret); return ret; }
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; }
static void debug_dialog_cm_chooser_changed_cb (GtkComboBox *cm_chooser, EmpathyDebugDialog *debug_dialog) { EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog); MissionControl *mc; TpDBusDaemon *dbus; GError *error = NULL; gchar *bus_name; TpProxy *proxy; GtkTreeIter iter; if (!gtk_combo_box_get_active_iter (cm_chooser, &iter)) { DEBUG ("No CM is selected"); if (gtk_tree_model_iter_n_children ( GTK_TREE_MODEL (priv->cms), NULL) > 0) { gtk_combo_box_set_active (cm_chooser, 0); } return; } mc = empathy_mission_control_dup_singleton (); dbus = tp_dbus_daemon_dup (&error); if (error != NULL) { DEBUG ("Failed at duping the dbus daemon: %s", error->message); g_object_unref (mc); } gtk_tree_model_get (GTK_TREE_MODEL (priv->cms), &iter, COL_CM_UNIQUE_NAME, &bus_name, -1); proxy = g_object_new (TP_TYPE_PROXY, "bus-name", bus_name, "dbus-daemon", dbus, "object-path", DEBUG_OBJECT_PATH, NULL); g_free (bus_name); gtk_list_store_clear (priv->store); /* Disable debug signalling */ if (priv->proxy != NULL) debug_dialog_set_enabled (debug_dialog, FALSE); /* Disconnect from previous NewDebugMessage signal */ if (priv->new_debug_message_signal != NULL) { tp_proxy_signal_connection_disconnect (priv->new_debug_message_signal); priv->new_debug_message_signal = NULL; } if (priv->proxy != NULL) g_object_unref (priv->proxy); priv->proxy = proxy; tp_proxy_add_interface_by_id (priv->proxy, emp_iface_quark_debug ()); emp_cli_debug_call_get_messages (priv->proxy, -1, debug_dialog_get_messages_cb, debug_dialog, NULL, NULL); g_object_unref (dbus); g_object_unref (mc); }