channels/rail: remove dependency on deprecated eventing system

This commit is contained in:
Marc-André Moreau 2014-11-12 09:46:04 -05:00
parent 1225c6b5ce
commit 68c9e68400
5 changed files with 16 additions and 316 deletions

View File

@ -28,7 +28,6 @@
#include <freerdp/types.h> #include <freerdp/types.h>
#include <freerdp/constants.h> #include <freerdp/constants.h>
#include <freerdp/utils/rail.h> #include <freerdp/utils/rail.h>
#include <freerdp/rail.h>
#include "rail_orders.h" #include "rail_orders.h"
#include "rail_main.h" #include "rail_main.h"
@ -52,36 +51,10 @@ void rail_send_channel_data(void* railObject, void* data, size_t length)
svc_plugin_send((rdpSvcPlugin*) plugin, s); svc_plugin_send((rdpSvcPlugin*) plugin, s);
} }
static void on_free_rail_channel_event(wMessage* event)
{
rail_free_cloned_order(GetMessageType(event->id), event->wParam);
}
void rail_send_channel_event(void* railObject, UINT16 eventType, void* param)
{
void* payload = NULL;
wMessage* out_event = NULL;
railPlugin* plugin = (railPlugin*) railObject;
payload = rail_clone_order(eventType, param);
if (payload)
{
out_event = freerdp_event_new(RailChannel_Class, eventType,
on_free_rail_channel_event, payload);
svc_plugin_send_event((rdpSvcPlugin*) plugin, out_event);
}
}
static void rail_process_connect(rdpSvcPlugin* plugin) static void rail_process_connect(rdpSvcPlugin* plugin)
{ {
railPlugin* rail = (railPlugin*) plugin; railPlugin* rail = (railPlugin*) plugin;
rail->rail_order = rail_order_new();
rail->rail_order->settings = (rdpSettings*) plugin->channel_entry_points.pExtendedData;
rail->rail_order->plugin = rail;
WLog_Print(rail->log, WLOG_DEBUG, "Connect"); WLog_Print(rail->log, WLOG_DEBUG, "Connect");
} }
@ -90,7 +63,7 @@ static void rail_process_terminate(rdpSvcPlugin* plugin)
railPlugin* rail = (railPlugin*) plugin; railPlugin* rail = (railPlugin*) plugin;
WLog_Print(rail->log, WLOG_DEBUG, "Terminate"); WLog_Print(rail->log, WLOG_DEBUG, "Terminate");
svc_plugin_terminate(plugin); svc_plugin_terminate(plugin);
} }
static void rail_process_receive(rdpSvcPlugin* plugin, wStream* s) static void rail_process_receive(rdpSvcPlugin* plugin, wStream* s)
@ -99,168 +72,14 @@ static void rail_process_receive(rdpSvcPlugin* plugin, wStream* s)
rail_order_recv(rail, s); rail_order_recv(rail, s);
} }
static void rail_process_addin_args(rdpRailOrder* railOrder, rdpSettings* settings)
{
char* exeOrFile;
exeOrFile = settings->RemoteApplicationProgram;
if (strlen(exeOrFile) >= 2)
{
if (strncmp(exeOrFile, "||", 2) != 0)
railOrder->exec.flags |= RAIL_EXEC_FLAG_FILE;
}
rail_string_to_unicode_string(settings->RemoteApplicationProgram, &railOrder->exec.exeOrFile);
rail_string_to_unicode_string(settings->ShellWorkingDirectory, &railOrder->exec.workingDir);
rail_string_to_unicode_string(settings->RemoteApplicationCmdLine, &railOrder->exec.arguments);
rail_send_client_exec_order((railPlugin*) railOrder->plugin, &railOrder->exec);
}
static void rail_recv_set_sysparams_event(rdpRailOrder* railOrder, wMessage* event)
{
RAIL_SYSPARAM_ORDER* sysparam;
/* Send System Parameters */
sysparam = (RAIL_SYSPARAM_ORDER*) event->wParam;
memmove(&railOrder->sysparam, sysparam, sizeof(RAIL_SYSPARAM_ORDER));
rail_send_client_sysparams_order((railPlugin*) railOrder->plugin, &railOrder->sysparam);
/* execute */
railOrder->exec.flags = RAIL_EXEC_FLAG_EXPAND_ARGUMENTS;
rail_process_addin_args(railOrder, railOrder->settings);
}
static void rail_recv_exec_remote_app_event(rdpRailOrder* railOrder, wMessage* event)
{
/**
* TODO: replace event system by an API to allow the execution
* of multiple remote apps over the same connection. RAIL is
* always built-in, so clients can safely link to it.
*/
//rail_process_addin_args((railPlugin*) railOrder->plugin, data);
}
static void rail_recv_activate_event(rdpRailOrder* railOrder, wMessage* event)
{
RAIL_ACTIVATE_ORDER* activate = (RAIL_ACTIVATE_ORDER*) event->wParam;
CopyMemory(&railOrder->activate, activate, sizeof(RAIL_ACTIVATE_ORDER));
rail_send_client_activate_order((railPlugin*) railOrder->plugin, &railOrder->activate);
}
static void rail_recv_sysmenu_event(rdpRailOrder* railOrder, wMessage* event)
{
RAIL_SYSMENU_ORDER* sysmenu = (RAIL_SYSMENU_ORDER*) event->wParam;
CopyMemory(&railOrder->sysmenu, sysmenu, sizeof(RAIL_SYSMENU_ORDER));
rail_send_client_sysmenu_order((railPlugin*) railOrder->plugin, &railOrder->sysmenu);
}
static void rail_recv_syscommand_event(rdpRailOrder* railOrder, wMessage* event)
{
RAIL_SYSCOMMAND_ORDER* syscommand = (RAIL_SYSCOMMAND_ORDER*) event->wParam;
CopyMemory(&railOrder->syscommand, syscommand, sizeof(RAIL_SYSCOMMAND_ORDER));
rail_send_client_syscommand_order((railPlugin*) railOrder->plugin, &railOrder->syscommand);
}
static void rail_recv_notify_event(rdpRailOrder* railOrder, wMessage* event)
{
RAIL_NOTIFY_EVENT_ORDER* notify = (RAIL_NOTIFY_EVENT_ORDER*) event->wParam;
CopyMemory(&railOrder->notify_event, notify, sizeof(RAIL_NOTIFY_EVENT_ORDER));
rail_send_client_notify_event_order((railPlugin*) railOrder->plugin, &railOrder->notify_event);
}
static void rail_recv_window_move_event(rdpRailOrder* railOrder, wMessage* event)
{
RAIL_WINDOW_MOVE_ORDER* window_move = (RAIL_WINDOW_MOVE_ORDER*) event->wParam;
CopyMemory(&railOrder->window_move, window_move, sizeof(RAIL_WINDOW_MOVE_ORDER));
rail_send_client_window_move_order((railPlugin*) railOrder->plugin, &railOrder->window_move);
}
static void rail_recv_app_req_event(rdpRailOrder* railOrder, wMessage* event)
{
RAIL_GET_APPID_REQ_ORDER* get_appid_req = (RAIL_GET_APPID_REQ_ORDER*) event->wParam;
CopyMemory(&railOrder->get_appid_req, get_appid_req, sizeof(RAIL_GET_APPID_REQ_ORDER));
rail_send_client_get_appid_req_order((railPlugin*) railOrder->plugin, &railOrder->get_appid_req);
}
static void rail_recv_langbarinfo_event(rdpRailOrder* railOrder, wMessage* event)
{
RAIL_LANGBAR_INFO_ORDER* langbar_info = (RAIL_LANGBAR_INFO_ORDER*) event->wParam;
CopyMemory(&railOrder->langbar_info, langbar_info, sizeof(RAIL_LANGBAR_INFO_ORDER));
rail_send_client_langbar_info_order((railPlugin*) railOrder->plugin, &railOrder->langbar_info);
}
static void rail_process_event(rdpSvcPlugin* plugin, wMessage* event)
{
railPlugin* rail = NULL;
rail = (railPlugin*) plugin;
switch (GetMessageType(event->id))
{
case RailChannel_ClientSystemParam:
rail_recv_set_sysparams_event(rail->rail_order, event);
break;
case RailChannel_ClientExecute:
rail_recv_exec_remote_app_event(rail->rail_order, event);
break;
case RailChannel_ClientActivate:
rail_recv_activate_event(rail->rail_order, event);
break;
case RailChannel_ClientSystemMenu:
rail_recv_sysmenu_event(rail->rail_order, event);
break;
case RailChannel_ClientSystemCommand:
rail_recv_syscommand_event(rail->rail_order, event);
break;
case RailChannel_ClientNotifyEvent:
rail_recv_notify_event(rail->rail_order, event);
break;
case RailChannel_ClientWindowMove:
rail_recv_window_move_event(rail->rail_order, event);
break;
case RailChannel_ClientGetAppIdRequest:
rail_recv_app_req_event(rail->rail_order, event);
break;
case RailChannel_ClientLanguageBarInfo:
rail_recv_langbarinfo_event(rail->rail_order, event);
break;
default:
break;
}
freerdp_event_free(event);
}
/** /**
* Callback Interface * Callback Interface
*/ */
int rail_client_execute(RailClientContext* context, RAIL_EXEC_ORDER* exec) int rail_client_execute(RailClientContext* context, RAIL_EXEC_ORDER* exec)
{ {
railPlugin* rail = (railPlugin*) context->handle;
char* exeOrFile; char* exeOrFile;
railPlugin* rail = (railPlugin*) context->handle;
exeOrFile = exec->RemoteApplicationProgram; exeOrFile = exec->RemoteApplicationProgram;
@ -514,7 +333,6 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
rail->plugin.connect_callback = rail_process_connect; rail->plugin.connect_callback = rail_process_connect;
rail->plugin.receive_callback = rail_process_receive; rail->plugin.receive_callback = rail_process_receive;
rail->plugin.event_callback = rail_process_event;
rail->plugin.terminate_callback = rail_process_terminate; rail->plugin.terminate_callback = rail_process_terminate;
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP*) pEntryPoints; pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP*) pEntryPoints;

View File

@ -24,9 +24,8 @@
#include <freerdp/rail.h> #include <freerdp/rail.h>
#include <freerdp/settings.h> #include <freerdp/settings.h>
#include <freerdp/utils/svc_plugin.h>
#include <freerdp/client/rail.h> #include <freerdp/client/rail.h>
#include <freerdp/utils/svc_plugin.h>
#include <winpr/crt.h> #include <winpr/crt.h>
#include <winpr/wlog.h> #include <winpr/wlog.h>
@ -39,13 +38,11 @@ struct rail_plugin
rdpSvcPlugin plugin; rdpSvcPlugin plugin;
wLog* log; wLog* log;
rdpRailOrder* rail_order;
}; };
typedef struct rail_plugin railPlugin; typedef struct rail_plugin railPlugin;
RailClientContext* rail_get_client_interface(void* railObject); RailClientContext* rail_get_client_interface(void* railObject);
void rail_send_channel_event(void* rail_object, UINT16 event_type, void* param);
void rail_send_channel_data(void* rail_object, void* data, size_t length); void rail_send_channel_data(void* rail_object, void* data, size_t length);
#endif /* FREERDP_CHANNEL_CLIENT_RAIL_MAIN_H */ #endif /* FREERDP_CHANNEL_CLIENT_RAIL_MAIN_H */

View File

@ -22,9 +22,6 @@
#include "config.h" #include "config.h"
#endif #endif
#include <stdio.h>
#include <stdlib.h>
#include <winpr/crt.h> #include <winpr/crt.h>
#include <freerdp/utils/rail.h> #include <freerdp/utils/rail.h>
@ -276,8 +273,6 @@ void rail_write_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbarI
BOOL rail_recv_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake, wStream* s) BOOL rail_recv_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake, wStream* s)
{ {
RAIL_SYSPARAM_ORDER sysparam;
RAIL_CLIENT_STATUS_ORDER clientStatus;
RailClientContext* context = rail_get_client_interface(rail); RailClientContext* context = rail_get_client_interface(rail);
if (!rail_read_handshake_order(s, handshake)) if (!rail_read_handshake_order(s, handshake))
@ -289,44 +284,6 @@ BOOL rail_recv_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake
return TRUE; return TRUE;
} }
handshake->buildNumber = 0x00001DB0;
rail_send_handshake_order(rail, handshake);
ZeroMemory(&clientStatus, sizeof(RAIL_CLIENT_STATUS_ORDER));
clientStatus.flags = RAIL_CLIENTSTATUS_ALLOWLOCALMOVESIZE;
rail_send_client_status_order(rail, &clientStatus);
/* sysparam update */
ZeroMemory(&sysparam, sizeof(RAIL_SYSPARAM_ORDER));
sysparam.params = 0;
sysparam.params |= SPI_MASK_SET_HIGH_CONTRAST;
sysparam.highContrast.colorScheme.string = NULL;
sysparam.highContrast.colorScheme.length = 0;
sysparam.highContrast.flags = 0x7E;
sysparam.params |= SPI_MASK_SET_MOUSE_BUTTON_SWAP;
sysparam.mouseButtonSwap = FALSE;
sysparam.params |= SPI_MASK_SET_KEYBOARD_PREF;
sysparam.keyboardPref = FALSE;
sysparam.params |= SPI_MASK_SET_DRAG_FULL_WINDOWS;
sysparam.dragFullWindows = FALSE;
sysparam.params |= SPI_MASK_SET_KEYBOARD_CUES;
sysparam.keyboardCues = FALSE;
sysparam.params |= SPI_MASK_SET_WORK_AREA;
sysparam.workArea.left = 0;
sysparam.workArea.top = 0;
sysparam.workArea.right = 1024;
sysparam.workArea.bottom = 768;
rail_send_channel_event(rail, RailChannel_GetSystemParam, &sysparam);
return TRUE; return TRUE;
} }
@ -358,10 +315,6 @@ BOOL rail_recv_exec_result_order(railPlugin* rail, RAIL_EXEC_RESULT_ORDER* execR
{ {
IFCALL(context->ServerExecuteResult, context, execResult); IFCALL(context->ServerExecuteResult, context, execResult);
} }
else
{
rail_send_channel_event(rail, RailChannel_ServerExecuteResult, execResult);
}
return TRUE; return TRUE;
} }
@ -377,10 +330,6 @@ BOOL rail_recv_server_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysp
{ {
IFCALL(context->ServerSystemParam, context, sysparam); IFCALL(context->ServerSystemParam, context, sysparam);
} }
else
{
rail_send_channel_event(rail, RailChannel_ServerSystemParam, sysparam);
}
return TRUE; return TRUE;
} }
@ -396,10 +345,6 @@ BOOL rail_recv_server_minmaxinfo_order(railPlugin* rail, RAIL_MINMAXINFO_ORDER*
{ {
IFCALL(context->ServerMinMaxInfo, context, minMaxInfo); IFCALL(context->ServerMinMaxInfo, context, minMaxInfo);
} }
else
{
rail_send_channel_event(rail, RailChannel_ServerMinMaxInfo, minMaxInfo);
}
return TRUE; return TRUE;
} }
@ -415,10 +360,6 @@ BOOL rail_recv_server_localmovesize_order(railPlugin* rail, RAIL_LOCALMOVESIZE_O
{ {
IFCALL(context->ServerLocalMoveSize, context, localMoveSize); IFCALL(context->ServerLocalMoveSize, context, localMoveSize);
} }
else
{
rail_send_channel_event(rail, RailChannel_ServerLocalMoveSize, localMoveSize);
}
return TRUE; return TRUE;
} }
@ -434,10 +375,6 @@ BOOL rail_recv_server_get_appid_resp_order(railPlugin* rail, RAIL_GET_APPID_RESP
{ {
IFCALL(context->ServerGetAppIdResponse, context, getAppIdResp); IFCALL(context->ServerGetAppIdResponse, context, getAppIdResp);
} }
else
{
rail_send_channel_event(rail, RailChannel_ServerGetAppIdResponse, getAppIdResp);
}
return TRUE; return TRUE;
} }
@ -453,10 +390,6 @@ BOOL rail_recv_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* lan
{ {
IFCALL(context->ServerLanguageBarInfo, context, langBarInfo); IFCALL(context->ServerLanguageBarInfo, context, langBarInfo);
} }
else
{
rail_send_channel_event(rail, RailChannel_ServerLanguageBarInfo, langBarInfo);
}
return TRUE; return TRUE;
} }
@ -713,25 +646,3 @@ void rail_send_client_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORD
rail_send_pdu(rail, s, RDP_RAIL_ORDER_LANGBARINFO); rail_send_pdu(rail, s, RDP_RAIL_ORDER_LANGBARINFO);
Stream_Free(s, TRUE); Stream_Free(s, TRUE);
} }
rdpRailOrder* rail_order_new()
{
rdpRailOrder* railOrder;
railOrder = (rdpRailOrder*) malloc(sizeof(rdpRailOrder));
if (railOrder)
{
ZeroMemory(railOrder, sizeof(rdpRailOrder));
}
return railOrder;
}
void rail_order_free(rdpRailOrder* railOrder)
{
if (railOrder)
{
free(railOrder);
}
}

View File

@ -22,6 +22,7 @@
#define __RAIL_ORDERS_H #define __RAIL_ORDERS_H
#include <freerdp/channels/log.h> #include <freerdp/channels/log.h>
#include "rail_main.h" #include "rail_main.h"
#define TAG CHANNELS_TAG("rail.client") #define TAG CHANNELS_TAG("rail.client")
@ -45,7 +46,6 @@ void rail_write_client_get_appid_req_order(wStream* s, RAIL_GET_APPID_REQ_ORDER*
void rail_write_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbar_info); void rail_write_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbar_info);
BOOL rail_order_recv(railPlugin* rail, wStream* s); BOOL rail_order_recv(railPlugin* rail, wStream* s);
void rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType); void rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType);
void rail_send_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake); void rail_send_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake);
@ -62,7 +62,4 @@ void rail_send_client_window_move_order(railPlugin* rail, RAIL_WINDOW_MOVE_ORDER
void rail_send_client_get_appid_req_order(railPlugin* rail, RAIL_GET_APPID_REQ_ORDER* getAppIdReq); void rail_send_client_get_appid_req_order(railPlugin* rail, RAIL_GET_APPID_REQ_ORDER* getAppIdReq);
void rail_send_client_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo); void rail_send_client_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo);
rdpRailOrder* rail_order_new(void);
void rail_order_free(rdpRailOrder* railOrder);
#endif /* __RAIL_ORDERS_H */ #endif /* __RAIL_ORDERS_H */

View File

@ -29,41 +29,18 @@ extern const char* const RAIL_ORDER_TYPE_STRINGS[];
#define RAIL_PDU_HEADER_LENGTH 4 #define RAIL_PDU_HEADER_LENGTH 4
/* Fixed length of PDUs, excluding variable lengths */ /* Fixed length of PDUs, excluding variable lengths */
#define RAIL_HANDSHAKE_ORDER_LENGTH 4 /* fixed */ #define RAIL_HANDSHAKE_ORDER_LENGTH 4 /* fixed */
#define RAIL_HANDSHAKE_EX_ORDER_LENGTH 8 /* fixed */ #define RAIL_HANDSHAKE_EX_ORDER_LENGTH 8 /* fixed */
#define RAIL_CLIENT_STATUS_ORDER_LENGTH 4 /* fixed */ #define RAIL_CLIENT_STATUS_ORDER_LENGTH 4 /* fixed */
#define RAIL_EXEC_ORDER_LENGTH 8 /* variable */ #define RAIL_EXEC_ORDER_LENGTH 8 /* variable */
#define RAIL_SYSPARAM_ORDER_LENGTH 4 /* variable */ #define RAIL_SYSPARAM_ORDER_LENGTH 4 /* variable */
#define RAIL_ACTIVATE_ORDER_LENGTH 5 /* fixed */ #define RAIL_ACTIVATE_ORDER_LENGTH 5 /* fixed */
#define RAIL_SYSMENU_ORDER_LENGTH 8 /* fixed */ #define RAIL_SYSMENU_ORDER_LENGTH 8 /* fixed */
#define RAIL_SYSCOMMAND_ORDER_LENGTH 6 /* fixed */ #define RAIL_SYSCOMMAND_ORDER_LENGTH 6 /* fixed */
#define RAIL_NOTIFY_EVENT_ORDER_LENGTH 12 /* fixed */ #define RAIL_NOTIFY_EVENT_ORDER_LENGTH 12 /* fixed */
#define RAIL_WINDOW_MOVE_ORDER_LENGTH 12 /* fixed */ #define RAIL_WINDOW_MOVE_ORDER_LENGTH 12 /* fixed */
#define RAIL_GET_APPID_REQ_ORDER_LENGTH 4 /* fixed */ #define RAIL_GET_APPID_REQ_ORDER_LENGTH 4 /* fixed */
#define RAIL_LANGBAR_INFO_ORDER_LENGTH 4 /* fixed */ #define RAIL_LANGBAR_INFO_ORDER_LENGTH 4 /* fixed */
struct rdp_rail_order
{
rdpSettings* settings;
void* plugin;
RAIL_HANDSHAKE_ORDER handshake;
RAIL_CLIENT_STATUS_ORDER client_status;
RAIL_EXEC_ORDER exec;
RAIL_EXEC_RESULT_ORDER exec_result;
RAIL_SYSPARAM_ORDER sysparam;
RAIL_ACTIVATE_ORDER activate;
RAIL_SYSMENU_ORDER sysmenu;
RAIL_SYSCOMMAND_ORDER syscommand;
RAIL_NOTIFY_EVENT_ORDER notify_event;
RAIL_MINMAXINFO_ORDER minmaxinfo;
RAIL_LOCALMOVESIZE_ORDER localmovesize;
RAIL_WINDOW_MOVE_ORDER window_move;
RAIL_LANGBAR_INFO_ORDER langbar_info;
RAIL_GET_APPID_REQ_ORDER get_appid_req;
RAIL_GET_APPID_RESP_ORDER get_appid_resp;
};
typedef struct rdp_rail_order rdpRailOrder;
void rail_string_to_unicode_string(char* string, RAIL_UNICODE_STRING* unicode_string); void rail_string_to_unicode_string(char* string, RAIL_UNICODE_STRING* unicode_string);
BOOL rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake); BOOL rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake);