summaryrefslogtreecommitdiffstats
path: root/plugins/rdp/rdp_channels.c
blob: fabb25f564e15a6b920e7e01707a53f666c623ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * Remmina - The GTK+ Remote Desktop Client
 * Copyright (C) 2012-2012 Jean-Louis Dupond
 * Copyright (C) 2016-2023 Antenore Gatta, Giovanni Panozzo
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 *  In addition, as a special exception, the copyright holders give
 *  permission to link the code of portions of this program with the
 *  OpenSSL library under certain conditions as described in each
 *  individual source file, and distribute linked combinations
 *  including the two.
 *  You must obey the GNU General Public License in all respects
 *  for all of the code used other than OpenSSL. *  If you modify
 *  file(s) with this exception, you may extend this exception to your
 *  version of the file(s), but you are not obligated to do so. *  If you
 *  do not wish to do so, delete this exception statement from your
 *  version. *  If you delete this exception statement from all source
 *  files in the program, then also delete it here.
 *
 */

#include "rdp_plugin.h"
#include "rdp_cliprdr.h"
#include "rdp_channels.h"
#include "rdp_event.h"

#include <freerdp/freerdp.h>
#include <freerdp/channels/channels.h>
#include <freerdp/client/cliprdr.h>
#include <freerdp/gdi/gfx.h>

void remmina_rdp_OnChannelConnectedEventHandler(void *context, CONST_ARG ChannelConnectedEventArgs *e)
{
	TRACE_CALL(__func__);

	rfContext* rfi = (rfContext*)context;

	if (g_strcmp0(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) {
		g_print("Unimplemented: channel %s connected but we can’t use it\n", e->name);
		// xfc->rdpei = (RdpeiClientContext*) e->pInterface;
	}else if (g_strcmp0(e->name, TSMF_DVC_CHANNEL_NAME) == 0) {
		g_print("Unimplemented: channel %s connected but we can’t use it\n", e->name);
		// xf_tsmf_init(xfc, (TsmfClientContext*) e->pInterface);
	}else if (g_strcmp0(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) {
		if (freerdp_settings_get_bool(rfi->clientContext.context.settings, FreeRDP_SoftwareGdi)) {
			rfi->rdpgfxchan = TRUE;
			gdi_graphics_pipeline_init(rfi->clientContext.context.gdi, (RdpgfxClientContext*) e->pInterface);
	   }
	   else
			g_print("Unimplemented: channel %s connected but libfreerdp is in HardwareGdi mode\n", e->name);
	}else if (g_strcmp0(e->name, RAIL_SVC_CHANNEL_NAME) == 0) {
		g_print("Unimplemented: channel %s connected but we can’t use it\n", e->name);
		// xf_rail_init(xfc, (RailClientContext*) e->pInterface);
	}else if (g_strcmp0(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) {
		remmina_rdp_cliprdr_init( rfi, (CliprdrClientContext*)e->pInterface);
	}else if (g_strcmp0(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) {
		g_print("Unimplemented: channel %s connected but we can’t use it\n", e->name);
		// xf_encomsp_init(xfc, (EncomspClientContext*) e->pInterface);
	}else if (g_strcmp0(e->name, DISP_DVC_CHANNEL_NAME) == 0) {
		// "disp" channel connected, save its context pointer
		rfi->dispcontext = (DispClientContext*)e->pInterface;
		// Notify rcw to unlock dynres capability
		remmina_plugin_service->protocol_plugin_unlock_dynres(rfi->protocol_widget);
		// Send monitor layout message here to ask for resize of remote desktop now
		if (rfi->scale == REMMINA_PROTOCOL_WIDGET_SCALE_MODE_DYNRES) {
			remmina_rdp_event_send_delayed_monitor_layout(rfi->protocol_widget);
		}
	}
	REMMINA_PLUGIN_DEBUG("Channel %s has been opened", e->name);
}

void remmina_rdp_OnChannelDisconnectedEventHandler(void *context, CONST_ARG ChannelDisconnectedEventArgs *e) {
	TRACE_CALL(__func__);
	rfContext* rfi = (rfContext*)context;

	if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) {
		if (freerdp_settings_get_bool(rfi->clientContext.context.settings, FreeRDP_SoftwareGdi))
			gdi_graphics_pipeline_uninit(rfi->clientContext.context.gdi, (RdpgfxClientContext*) e->pInterface);
	}
	REMMINA_PLUGIN_DEBUG("Channel %s has been closed", e->name);

}