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_account_constructed (GObject *object) { EmpathyAccount *account = EMPATHY_ACCOUNT (object); EmpathyAccountPriv *priv = GET_PRIV (account); priv->account = tp_account_new (priv->dbus, priv->unique_name, NULL); g_signal_connect (priv->account, "invalidated", G_CALLBACK (account_invalidated_cb), object); empathy_account_parse_unique_name (priv->unique_name, &(priv->proto_name), &(priv->cm_name)); priv->icon_name = empathy_protocol_icon_name (priv->proto_name); tp_cli_account_connect_to_account_property_changed (priv->account, empathy_account_properties_changed, NULL, NULL, object, NULL); tp_cli_account_connect_to_removed (priv->account, empathy_account_removed_cb, NULL, NULL, object, NULL); empathy_account_refresh_properties (account); }
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 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 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); }