Blame client/Wayland/wlf_channels.c

Packit 1fb8d4
/**
Packit 1fb8d4
 * FreeRDP: A Remote Desktop Protocol Implementation
Packit 1fb8d4
 * X11 Client Channels
Packit 1fb8d4
 *
Packit 1fb8d4
 * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
Packit 1fb8d4
 *
Packit 1fb8d4
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit 1fb8d4
 * you may not use this file except in compliance with the License.
Packit 1fb8d4
 * You may obtain a copy of the License at
Packit 1fb8d4
 *
Packit 1fb8d4
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 1fb8d4
 *
Packit 1fb8d4
 * Unless required by applicable law or agreed to in writing, software
Packit 1fb8d4
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 1fb8d4
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 1fb8d4
 * See the License for the specific language governing permissions and
Packit 1fb8d4
 * limitations under the License.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#ifdef HAVE_CONFIG_H
Packit 1fb8d4
#include "config.h"
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
#include <freerdp/gdi/gfx.h>
Packit 1fb8d4
Packit 1fb8d4
#include "wlf_channels.h"
Packit Service 5a9772
#include "wlf_cliprdr.h"
Packit Service 5a9772
#include "wlf_disp.h"
Packit 1fb8d4
#include "wlfreerdp.h"
Packit 1fb8d4
Packit Service 5a9772
BOOL encomsp_toggle_control(EncomspClientContext* encomsp, BOOL control)
Packit Service 5a9772
{
Packit Service 5a9772
	ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU pdu;
Packit Service 5a9772
Packit Service 5a9772
	if (!encomsp)
Packit Service 5a9772
		return FALSE;
Packit Service 5a9772
Packit Service 5a9772
	pdu.ParticipantId = 0;
Packit Service 5a9772
	pdu.Flags = ENCOMSP_REQUEST_VIEW;
Packit Service 5a9772
Packit Service 5a9772
	if (control)
Packit Service 5a9772
		pdu.Flags |= ENCOMSP_REQUEST_INTERACT;
Packit Service 5a9772
Packit Service 5a9772
	encomsp->ChangeParticipantControlLevel(encomsp, &pdu);
Packit Service 5a9772
	return TRUE;
Packit Service 5a9772
}
Packit Service 5a9772
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT
Packit Service 5a9772
wlf_encomsp_participant_created(EncomspClientContext* context,
Packit Service 5a9772
                                const ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
Packit 1fb8d4
{
Packit Service 5a9772
	wlfContext* wlf;
Packit Service 5a9772
	rdpSettings* settings;
Packit Service 5a9772
	BOOL request;
Packit Service 5a9772
Packit Service 5a9772
	if (!context || !context->custom || !participantCreated)
Packit Service 5a9772
		return ERROR_INVALID_PARAMETER;
Packit Service 5a9772
Packit Service 5a9772
	wlf = (wlfContext*)context->custom;
Packit Service 5a9772
	settings = wlf->context.settings;
Packit Service 5a9772
Packit Service 5a9772
	if (!settings)
Packit Service 5a9772
		return ERROR_INVALID_PARAMETER;
Packit Service 5a9772
Packit Service 5a9772
	request = freerdp_settings_get_bool(settings, FreeRDP_RemoteAssistanceRequestControl);
Packit Service 5a9772
	if (request && (participantCreated->Flags & ENCOMSP_MAY_VIEW) &&
Packit Service 5a9772
	    !(participantCreated->Flags & ENCOMSP_MAY_INTERACT))
Packit Service 5a9772
	{
Packit Service 5a9772
		if (!encomsp_toggle_control(context, TRUE))
Packit Service 5a9772
			return ERROR_INTERNAL_ERROR;
Packit Service 5a9772
	}
Packit Service 5a9772
Packit 1fb8d4
	return CHANNEL_RC_OK;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static void wlf_encomsp_init(wlfContext* wlf, EncomspClientContext* encomsp)
Packit 1fb8d4
{
Packit 1fb8d4
	wlf->encomsp = encomsp;
Packit Service 5a9772
	encomsp->custom = (void*)wlf;
Packit 1fb8d4
	encomsp->ParticipantCreated = wlf_encomsp_participant_created;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static void wlf_encomsp_uninit(wlfContext* wlf, EncomspClientContext* encomsp)
Packit 1fb8d4
{
Packit 1fb8d4
	if (encomsp)
Packit 1fb8d4
	{
Packit 1fb8d4
		encomsp->custom = NULL;
Packit 1fb8d4
		encomsp->ParticipantCreated = NULL;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	if (wlf)
Packit 1fb8d4
		wlf->encomsp = NULL;
Packit 1fb8d4
}
Packit 1fb8d4
Packit Service 5a9772
void wlf_OnChannelConnectedEventHandler(void* context, ChannelConnectedEventArgs* e)
Packit 1fb8d4
{
Packit Service 5a9772
	wlfContext* wlf = (wlfContext*)context;
Packit 1fb8d4
Packit 1fb8d4
	if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
Packit 1fb8d4
	{
Packit Service 5a9772
		wlf->rdpei = (RdpeiClientContext*)e->pInterface;
Packit 1fb8d4
	}
Packit 1fb8d4
	else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
Packit 1fb8d4
	{
Packit Service 5a9772
		gdi_graphics_pipeline_init(wlf->context.gdi, (RdpgfxClientContext*)e->pInterface);
Packit 1fb8d4
	}
Packit 1fb8d4
	else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
Packit 1fb8d4
	{
Packit 1fb8d4
	}
Packit 1fb8d4
	else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
Packit 1fb8d4
	{
Packit Service 5a9772
		wlf_cliprdr_init(wlf->clipboard, (CliprdrClientContext*)e->pInterface);
Packit 1fb8d4
	}
Packit 1fb8d4
	else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
Packit 1fb8d4
	{
Packit Service 5a9772
		wlf_encomsp_init(wlf, (EncomspClientContext*)e->pInterface);
Packit Service 5a9772
	}
Packit Service 5a9772
	else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
Packit Service 5a9772
	{
Packit Service 5a9772
		wlf_disp_init(wlf->disp, (DispClientContext*)e->pInterface);
Packit 1fb8d4
	}
Packit 1fb8d4
}
Packit 1fb8d4
Packit Service 5a9772
void wlf_OnChannelDisconnectedEventHandler(void* context, ChannelDisconnectedEventArgs* e)
Packit 1fb8d4
{
Packit Service 5a9772
	wlfContext* wlf = (wlfContext*)context;
Packit 1fb8d4
Packit 1fb8d4
	if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
Packit 1fb8d4
	{
Packit 1fb8d4
		wlf->rdpei = NULL;
Packit 1fb8d4
	}
Packit 1fb8d4
	else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
Packit 1fb8d4
	{
Packit Service 5a9772
		gdi_graphics_pipeline_uninit(wlf->context.gdi, (RdpgfxClientContext*)e->pInterface);
Packit 1fb8d4
	}
Packit 1fb8d4
	else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
Packit 1fb8d4
	{
Packit 1fb8d4
	}
Packit 1fb8d4
	else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
Packit 1fb8d4
	{
Packit Service 5a9772
		wlf_cliprdr_uninit(wlf->clipboard, (CliprdrClientContext*)e->pInterface);
Packit 1fb8d4
	}
Packit 1fb8d4
	else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
Packit 1fb8d4
	{
Packit Service 5a9772
		wlf_encomsp_uninit(wlf, (EncomspClientContext*)e->pInterface);
Packit Service 5a9772
	}
Packit Service 5a9772
	else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
Packit Service 5a9772
	{
Packit Service 5a9772
		wlf_disp_uninit(wlf->disp, (DispClientContext*)e->pInterface);
Packit 1fb8d4
	}
Packit 1fb8d4
}