l10n: sync translations with transifex.com (es, pt_BR)
[siplcs.git] / src / core / sipe-appshare-xfreerdp.c
blobc837f7c23e006ac52ba6125f62849f8aa542f98d
1 /**
2 * @file sipe-appshare-xfreerdp.c
4 * pidgin-sipe
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
23 #include <glib.h>
24 #include <glib/gstdio.h>
26 #include <gio/gio.h>
28 #include <sys/socket.h>
29 #include <sys/un.h>
31 #include "sipe-appshare-client.h"
32 #include "sipe-backend.h"
33 #include "sipe-common.h"
35 struct xfreerdp_data {
36 gchar *socket_path;
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(),
47 client);
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));
58 static gboolean
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;
64 gchar *cmdline;
65 GError *error = NULL;
67 /* This assumes FreeRDP 2.x.x */
68 cmdline = g_strdup_printf("%s /v:%s /sec:rdp",
69 client->cmdline,
70 client_data->socket_path);
72 g_spawn_command_line_async(cmdline, &error);
73 g_free(cmdline);
74 if (error) {
75 SIPE_DEBUG_ERROR("Can't launch xfreerdp: %s", error->message);
76 g_error_free(error);
77 return FALSE;
80 return TRUE;
83 static void
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);
93 g_free(client_data);
96 void
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;
107 Local Variables:
108 mode: c
109 c-file-style: "bsd"
110 indent-tabs-mode: t
111 tab-width: 8
112 End: