38 #include <telepathy-glib/account.h> 39 #include <telepathy-glib/channel.h> 40 #include <telepathy-glib/contact.h> 41 #include <telepathy-glib/dbus.h> 42 #include <telepathy-glib/defs.h> 43 #include <telepathy-glib/handle.h> 44 #include <telepathy-glib/interfaces.h> 45 #include <telepathy-glib/svc-client.h> 46 #include <telepathy-glib/util.h> 82 g_object_unref(chandler->
bus);
85 g_object_unref(chandler->
account);
91 g_object_unref(chandler->
channel);
93 if (chandler->
alias) {
94 g_free(chandler->
alias);
97 g_free(chandler->
host);
107 TRACE_CALL(__func__);
116 TRACE_CALL(__func__);
120 tp_cli_channel_call_close(chandler->
channel, -1, NULL, NULL, NULL, NULL);
125 TRACE_CALL(__func__);
129 remminafile = remmina_plugin_telepathy_service->
file_new();
132 s = g_strdup_printf(
"[%s]:%i", chandler->
host, chandler->
port);
133 remmina_plugin_telepathy_service->
file_set_string(remminafile,
"server", s);
135 remmina_plugin_telepathy_service->
file_set_int(remminafile,
"colordepth", 8);
137 g_free(chandler->
alias);
138 chandler->
alias = NULL;
147 gpointer user_data, GObject *weak_object)
149 TRACE_CALL(__func__);
154 g_print(
"%s: %s", __func__, error->message);
158 svc = g_value_get_string(service);
159 g_print(
"%s: %s %s:%u\n", __func__, svc, chandler->
host, chandler->
port);
161 if (g_strcmp0(svc,
"rfb") == 0) {
162 chandler->
protocol = g_strdup(
"VNC");
164 chandler->
protocol = g_ascii_strup(svc, -1);
170 gpointer user_data, GObject *weak_object)
172 TRACE_CALL(__func__);
176 g_print(
"%s: %s", __func__, error->message);
181 dbus_g_type_struct_get(address, 0, &chandler->
host, 1, &chandler->
port, G_MAXUINT);
183 tp_cli_dbus_properties_call_get(channel, -1, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE,
"Service",
189 TRACE_CALL(__func__);
194 if (response_id == GTK_RESPONSE_YES) {
195 g_value_init(&noop, G_TYPE_INT);
196 tp_cli_channel_type_stream_tube_call_accept(chandler->
channel, -1, TP_SOCKET_ADDRESS_TYPE_IPV4,
199 g_value_unset(&noop);
200 tp_svc_client_handler_return_from_handle_channels(chandler->
context);
202 error = g_error_new(TP_ERROR, TP_ERROR_NOT_AVAILABLE,
"Channel rejected by user.");
203 dbus_g_method_return_error(chandler->
context, error);
210 guint n_failed,
const TpHandle *failed,
const GError *error, gpointer user_data, GObject *weak_object)
212 TRACE_CALL(__func__);
224 g_print(
"%s: %s", __func__, error->message);
228 if (n_contacts <= 0) {
229 g_print(
"%s: no contacts\n", __func__);
233 contact = contacts[0];
234 chandler->
alias = g_strdup(tp_contact_get_alias(contact));
236 dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
237 _(
"%s wants to share their desktop.\nDo you accept?"), chandler->
alias);
239 g_signal_connect(G_OBJECT(dialog),
"response", G_CALLBACK(gtk_widget_destroy), NULL);
240 gtk_window_set_title(GTK_WINDOW(dialog), _(
"Desktop sharing invitation"));
241 remmina_plugin_telepathy_service->
ui_register(dialog);
242 gtk_widget_show(dialog);
244 token = (gchar*)tp_contact_get_avatar_token(contact);
248 protocol = tp_connection_get_protocol_name(chandler->
connection);
249 cm = tp_connection_get_cm_name(chandler->
connection);
250 if (!protocol || !cm) {
253 token = tp_escape_as_identifier(token);
254 filename = g_build_filename(g_get_user_cache_dir(),
"telepathy",
"avatars", cm, protocol, token, NULL);
256 if (g_file_test(filename, G_FILE_TEST_EXISTS)) {
257 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
259 image = gtk_image_new_from_pixbuf(pixbuf);
260 gtk_widget_show(image);
261 g_object_unref(pixbuf);
262 gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog), image);
270 TRACE_CALL(__func__);
273 GError *error = NULL;
274 TpContactFeature features[] =
275 { TP_CONTACT_FEATURE_ALIAS, TP_CONTACT_FEATURE_AVATAR_TOKEN };
277 if (channel_error != NULL) {
278 g_print(
"%s: %s\n", __func__, channel_error->message);
285 g_print(
"tp_cli_channel_connect_to_closed: %s\n", channel_error->message);
291 handle = tp_channel_get_handle(channel, NULL);
292 tp_connection_get_contacts_by_handle(chandler->
connection, 1, &handle, G_N_ELEMENTS(features), features,
299 TRACE_CALL(__func__);
301 GError *error = NULL;
303 if (connection_error != NULL) {
304 g_print(
"%s: %s\n", __func__, connection_error->message);
311 if (chandler->
channel == NULL) {
312 g_print(
"tp_channel_new_from_properties: %s\n", error->message);
321 TRACE_CALL(__func__);
323 GError *error = NULL;
325 if (!tp_account_prepare_finish(TP_ACCOUNT(account), res, &error)) {
326 g_print(
"tp_account_prepare_finish: %s\n", error->message);
333 g_print(
"tp_connection_new: %s\n", error->message);
343 TRACE_CALL(__func__);
346 GError *error = NULL;
349 bus = tp_dbus_daemon_dup(&error);
351 g_print(
"tp_dbus_daemon_dup: %s", error->message);
354 account = tp_account_new(bus, account_path, &error);
355 if (account == NULL) {
357 g_print(
"tp_account_new: %s", error->message);
367 tp_g_hash_table_update(chandler->
channel_properties, channel_properties, (GBoxedCopyFunc)g_strdup,
368 (GBoxedCopyFunc)tp_g_value_slice_dup);
void(* file_set_int)(RemminaFile *remminafile, const gchar *setting, gint value)
typedefG_BEGIN_DECLS struct _RemminaFile RemminaFile
RemminaPluginService * remmina_plugin_telepathy_service
static void remmina_tp_channel_handler_account_ready(GObject *account, GAsyncResult *res, gpointer user_data)
static void remmina_tp_channel_handler_connection_ready(TpConnection *connection, const GError *connection_error, gpointer user_data)
static void remmina_tp_channel_handler_get_contacts(TpConnection *connection, guint n_contacts, TpContact *const *contacts, guint n_failed, const TpHandle *failed, const GError *error, gpointer user_data, GObject *weak_object)
static void remmina_tp_channel_handler_free(RemminaTpChannelHandler *chandler)
static void remmina_tp_channel_handler_channel_ready(TpChannel *channel, const GError *channel_error, gpointer user_data)
static void remmina_tp_channel_handler_on_response(GtkDialog *dialog, gint response_id, RemminaTpChannelHandler *chandler)
static void remmina_tp_channel_handler_accept(TpChannel *channel, const GValue *address, const GError *error, gpointer user_data, GObject *weak_object)
static void remmina_tp_channel_handler_connect(RemminaTpChannelHandler *chandler)
void remmina_tp_channel_handler_new(const gchar *account_path, const gchar *connection_path, const gchar *channel_path, GHashTable *channel_properties, DBusGMethodInvocation *context)
void(* ui_register)(GtkWidget *widget)
void(* file_set_string)(RemminaFile *remminafile, const gchar *setting, const gchar *value)
static void remmina_tp_channel_handler_get_service(TpProxy *channel, const GValue *service, const GError *error, gpointer user_data, GObject *weak_object)
TpConnection * connection
static void remmina_tp_channel_handler_channel_closed(TpChannel *channel, gpointer user_data, GObject *self)
GtkWidget *(* open_connection)(RemminaFile *remminafile, GCallback disconnect_cb, gpointer data, guint *handler)
struct _RemminaTpChannelHandler RemminaTpChannelHandler
GHashTable * channel_properties
DBusGMethodInvocation * context
RemminaFile *(* file_new)(void)
static void remmina_tp_channel_handler_on_disconnect(GtkWidget *widget, RemminaTpChannelHandler *chandler)