2 * @file sipe-appshare-remmina.c
6 * Copyright (C) 2014-2016 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <glib/gstdio.h>
30 #include "sipe-appshare-client.h"
31 #include "sipe-backend.h"
32 #include "sipe-buddy.h"
33 #include "sipe-common.h"
34 #include "sipe-media.h"
40 static GSocketAddress
*
41 remmina_get_listen_address(SIPE_UNUSED_PARAMETER
struct sipe_rdp_client
*client
)
43 GInetAddress
*loopback
;
44 GSocketAddress
*address
;
46 loopback
= g_inet_address_new_loopback(G_SOCKET_FAMILY_IPV4
);
47 address
= g_inet_socket_address_new(loopback
, 0);
48 g_object_unref(loopback
);
54 remmina_launch(struct sipe_rdp_client
*client
, GSocketAddress
*listen_address
,
55 struct sipe_media_stream
*stream
)
57 struct remmina_data
*client_data
= client
->client_data
;
58 struct sipe_core_private
*sipe_private
;
59 GInetAddress
*address
;
60 gchar
*address_string
;
67 sipe_private
= sipe_media_get_sipe_core_private(stream
->call
);
69 address
= g_inet_socket_address_get_address(G_INET_SOCKET_ADDRESS(listen_address
));
70 address_string
= g_inet_address_to_string(address
);
72 port
= g_inet_socket_address_get_port(G_INET_SOCKET_ADDRESS(listen_address
));
74 alias
= sipe_buddy_get_alias(sipe_private
, stream
->call
->with
);
76 config_file
= g_strdup_printf("[remmina]\n"
77 "name=%s (Sipe desktop)\n"
84 "disableautoreconnect=1\n",
85 alias
? alias
: stream
->call
->with
,
90 g_free(address_string
);
92 client_data
->config_file
=
93 g_strdup_printf("%s/sipe-appshare-%u-%p.remmina",
94 g_get_user_runtime_dir(), getpid(),
97 g_file_set_contents(client_data
->config_file
, config_file
,
98 strlen(config_file
), &error
);
101 SIPE_DEBUG_ERROR("Couldn't write remmina config file: %s",
107 cmdline
= g_strdup_printf("%s -c %s",
109 client_data
->config_file
);
111 g_spawn_command_line_async(cmdline
, &error
);
114 SIPE_DEBUG_ERROR("Couldn't launch remmina: %s", error
->message
);
123 remmina_free(struct sipe_rdp_client
*client
)
125 struct remmina_data
*client_data
= client
->client_data
;
127 if (client_data
->config_file
) {
128 g_unlink(client_data
->config_file
);
129 g_free(client_data
->config_file
);
136 sipe_appshare_remmina_init(struct sipe_rdp_client
*client
)
138 client
->client_data
= g_new0(struct remmina_data
, 1);
140 client
->get_listen_address_cb
= remmina_get_listen_address
;
141 client
->launch_cb
= remmina_launch
;
142 client
->free_cb
= remmina_free
;