2 * @file sipe-appshare-xfreerdp.c
6 * Copyright (C) 2014-2018 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
26 #include <glib/gstdio.h>
30 #include <sys/socket.h>
33 #include "sipe-appshare-client.h"
34 #include "sipe-backend.h"
35 #include "sipe-common.h"
37 struct xfreerdp_data
{
41 static GSocketAddress
*
42 xfreerdp_get_listen_address(struct sipe_rdp_client
*client
)
44 struct xfreerdp_data
*data
= client
->client_data
;
45 struct sockaddr_un address
;
47 data
->socket_path
= g_strdup_printf("%s/sipe-appshare-%u-%p",
48 g_get_user_runtime_dir(), getpid(),
51 g_unlink(data
->socket_path
);
53 address
.sun_family
= AF_LOCAL
;
54 strncpy(address
.sun_path
, data
->socket_path
, sizeof (address
.sun_path
) - 1);
55 address
.sun_path
[sizeof (address
.sun_path
) - 1] = '\0';
57 return g_socket_address_new_from_native(&address
, sizeof (address
));
61 xfreerdp_launch(struct sipe_rdp_client
*client
,
62 SIPE_UNUSED_PARAMETER GSocketAddress
*listen_address
,
63 SIPE_UNUSED_PARAMETER
struct sipe_media_stream
*stream
)
65 struct xfreerdp_data
*client_data
= client
->client_data
;
69 /* This assumes FreeRDP 2.x.x */
70 cmdline
= g_strdup_printf("%s /v:%s /sec:rdp",
72 client_data
->socket_path
);
74 g_spawn_command_line_async(cmdline
, &error
);
77 SIPE_DEBUG_ERROR("Can't launch xfreerdp: %s", error
->message
);
86 xfreerdp_free(struct sipe_rdp_client
*client
)
88 struct xfreerdp_data
*client_data
= client
->client_data
;
90 if (client_data
->socket_path
) {
91 g_unlink(client_data
->socket_path
);
92 g_free(client_data
->socket_path
);
99 sipe_appshare_xfreerdp_init(struct sipe_rdp_client
*client
)
101 client
->client_data
= g_new0(struct xfreerdp_data
, 1);
103 client
->get_listen_address_cb
= xfreerdp_get_listen_address
;
104 client
->launch_cb
= xfreerdp_launch
;
105 client
->free_cb
= xfreerdp_free
;