FreeRDP/channels/rail/rail_main.c

122 lines
3.5 KiB
C
Raw Normal View History

/**
* FreeRDP: A Remote Desktop Protocol Client
* RAIL Virtual Channel Plugin
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com>
* Copyright 2011 Vic Lee
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <freerdp/constants.h>
#include <freerdp/types.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/svc_plugin.h>
#include <freerdp/rail.h>
2011-08-12 00:27:16 +04:00
#include "rail_orders.h"
#include "rail_main.h"
2011-08-12 12:26:57 +04:00
static void rail_send_vchannel_data(void* rail_object, void* data, size_t length)
{
STREAM* s = NULL;
2011-08-12 12:26:57 +04:00
railPlugin* plugin = (railPlugin*) rail_object;
2011-08-12 12:26:57 +04:00
DEBUG_RAIL("rail_send_vchannel_data\n");
2011-08-12 00:27:16 +04:00
s = stream_new(length);
stream_write(s, data, length);
svc_plugin_send((rdpSvcPlugin*) plugin, s);
}
static void on_free_rail_vchannel_event(FRDP_EVENT* event)
{
}
2011-08-12 12:26:57 +04:00
static void rail_send_vchannel_event(void* rail_object, RAIL_VCHANNEL_EVENT* event)
{
2011-08-12 12:26:57 +04:00
railPlugin* plugin = (railPlugin*) rail_object;
RAIL_VCHANNEL_EVENT* payload = NULL;
FRDP_EVENT* out_event = NULL;
2011-08-12 12:26:57 +04:00
DEBUG_RAIL("rail_send_vchannel_event\n");
2011-08-12 00:27:16 +04:00
payload = xnew(RAIL_VCHANNEL_EVENT);
memset(payload, 0, sizeof(RAIL_VCHANNEL_EVENT));
memcpy(payload, event, sizeof(RAIL_VCHANNEL_EVENT));
2011-08-11 07:07:03 +04:00
out_event = freerdp_event_new(FRDP_EVENT_CLASS_RAIL, FRDP_EVENT_TYPE_RAIL_VCHANNEL_2_UI, on_free_rail_vchannel_event, payload);
svc_plugin_send_event((rdpSvcPlugin*) plugin, out_event);
}
2011-08-12 12:26:57 +04:00
static void rail_process_connect(rdpSvcPlugin* plugin)
{
2011-08-12 12:26:57 +04:00
railPlugin* rail = (railPlugin*) plugin;
2011-08-12 12:26:57 +04:00
DEBUG_RAIL("rail_process_connect() called.");
2011-08-12 12:26:57 +04:00
rail->rail_event_sender.event_sender_object = rail;
rail->rail_event_sender.send_rail_vchannel_event = rail_send_vchannel_event;
2011-08-12 12:26:57 +04:00
rail->rail_data_sender.data_sender_object = rail;
rail->rail_data_sender.send_rail_vchannel_data = rail_send_vchannel_data;
2011-08-12 12:26:57 +04:00
rail->rail_order = rail_order_new();
rail->rail_order->plugin_data = (FRDP_PLUGIN_DATA*)plugin->channel_entry_points.pExtendedData;
2011-08-12 12:26:57 +04:00
rail->rail_order->data_sender = &(rail->rail_data_sender);
rail->rail_order->event_sender = &(rail->rail_event_sender);
}
2011-08-12 12:26:57 +04:00
static void rail_process_terminate(rdpSvcPlugin* plugin)
{
2011-08-12 12:26:57 +04:00
DEBUG_RAIL("rail_process_terminate\n");
}
2011-08-12 12:26:57 +04:00
static void rail_process_receive(rdpSvcPlugin* plugin, STREAM* s)
{
railPlugin* rail = (railPlugin*) plugin;
2011-08-12 12:26:57 +04:00
DEBUG_RAIL("rail_process_receive\n");
2011-08-12 12:26:57 +04:00
rail_order_recv(rail->rail_order, s);
stream_free(s);
}
2011-08-12 12:26:57 +04:00
static void rail_process_event(rdpSvcPlugin* plugin, FRDP_EVENT* event)
{
RAIL_UI_EVENT* rail_ui_event = NULL;
railPlugin* rail = NULL;
2011-08-12 12:26:57 +04:00
DEBUG_RAIL("rail_process_event: event_type=%d\n", event->event_type);
2011-08-12 12:26:57 +04:00
rail = (railPlugin*)plugin;
rail_ui_event = (RAIL_UI_EVENT*)event->user_data;
2011-08-12 12:26:57 +04:00
//if (event->event_type == FRDP_EVENT_TYPE_RAIL_UI_2_VCHANNEL)
//rail_core_handle_ui_event(rail->session, rail_ui_event);
2011-08-12 12:26:57 +04:00
freerdp_event_free(event);
}
2011-08-12 12:26:57 +04:00
DEFINE_SVC_PLUGIN(rail, "rail",
CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL)