2 * @file sipe-appshare-xfreerdp.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>
28 #include <sys/socket.h>
31 #include "sipe-appshare-client.h"
32 #include "sipe-backend.h"
33 #include "sipe-common.h"
35 struct xfreerdp_data
{
39 static GSocketAddress
*
40 xfreerdp_get_listen_address(struct sipe_rdp_client
*client
)
42 struct xfreerdp_data
*data
= client
->client_data
;
43 struct sockaddr_un address
;
45 data
->socket_path
= g_strdup_printf("%s/sipe-appshare-%u-%p",
46 g_get_user_runtime_dir(), getpid(),
49 g_unlink(data
->socket_path
);
51 address
.sun_family
= AF_LOCAL
;
52 strncpy(address
.sun_path
, data
->socket_path
, sizeof (address
.sun_path
) - 1);
53 address
.sun_path
[sizeof (address
.sun_path
) - 1] = '\0';
55 return g_socket_address_new_from_native(&address
, sizeof (address
));
59 xfreerdp_launch(struct sipe_rdp_client
*client
,
60 SIPE_UNUSED_PARAMETER GSocketAddress
*listen_address
,
61 SIPE_UNUSED_PARAMETER
struct sipe_media_stream
*stream
)
63 struct xfreerdp_data
*client_data
= client
->client_data
;
67 /* This assumes FreeRDP 2.x.x */
68 cmdline
= g_strdup_printf("%s /v:%s /sec:rdp",
70 client_data
->socket_path
);
72 g_spawn_command_line_async(cmdline
, &error
);
75 SIPE_DEBUG_ERROR("Can't launch xfreerdp: %s", error
->message
);
84 xfreerdp_free(struct sipe_rdp_client
*client
)
86 struct xfreerdp_data
*client_data
= client
->client_data
;
88 if (client_data
->socket_path
) {
89 g_unlink(client_data
->socket_path
);
90 g_free(client_data
->socket_path
);
97 sipe_appshare_xfreerdp_init(struct sipe_rdp_client
*client
)
99 client
->client_data
= g_new0(struct xfreerdp_data
, 1);
101 client
->get_listen_address_cb
= xfreerdp_get_listen_address
;
102 client
->launch_cb
= xfreerdp_launch
;
103 client
->free_cb
= xfreerdp_free
;