libfreerdp-rail: refactor and update RAIL code

This commit is contained in:
Marc-André Moreau 2013-10-11 17:09:36 -04:00
parent 3fe3cdf876
commit 11109b00e9
7 changed files with 333 additions and 36 deletions

View File

@ -38,10 +38,10 @@
#include "rail_orders.h"
#include "rail_main.h"
void rail_send_channel_data(void* rail_object, void* data, size_t length)
void rail_send_channel_data(void* railObject, void* data, size_t length)
{
wStream* s = NULL;
railPlugin* plugin = (railPlugin*) rail_object;
railPlugin* plugin = (railPlugin*) railObject;
s = Stream_New(NULL, length);
Stream_Write(s, data, length);
@ -56,13 +56,13 @@ static void on_free_rail_channel_event(wMessage* event)
void rail_send_channel_event(void* rail_object, UINT16 event_type, void* param)
{
void * payload = NULL;
void* payload = NULL;
wMessage* out_event = NULL;
railPlugin* plugin = (railPlugin*) rail_object;
payload = rail_clone_order(event_type, param);
if (payload != NULL)
if (payload)
{
out_event = freerdp_event_new(RailChannel_Class, event_type,
on_free_rail_channel_event, payload);
@ -246,12 +246,123 @@ static void rail_process_event(rdpSvcPlugin* plugin, wMessage* event)
freerdp_event_free(event);
}
/**
* Callback Interface
*/
int rail_client_execute(RailClientContext* context, RAIL_EXEC_ORDER* exec)
{
return 0;
}
int rail_client_activate(RailClientContext* context, RAIL_ACTIVATE_ORDER* activate)
{
return 0;
}
int rail_get_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
{
return 0;
}
int rail_client_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
{
return 0;
}
int rail_server_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
{
return 0;
}
int rail_client_system_command(RailClientContext* context, RAIL_SYSCOMMAND_ORDER* syscommand)
{
return 0;
}
int rail_client_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
{
return 0;
}
int rail_server_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
{
return 0;
}
int rail_client_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
{
return 0;
}
int rail_server_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
{
return 0;
}
int rail_client_notify_event(RailClientContext* context, RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
{
return 0;
}
int rail_client_window_move(RailClientContext* context, RAIL_WINDOW_MOVE_ORDER* windowMove)
{
return 0;
}
int rail_server_local_move_size(RailClientContext* context, RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
{
return 0;
}
int rail_server_min_max_info(RailClientContext* context, RAIL_MINMAXINFO_ORDER* minMaxInfo)
{
return 0;
}
int rail_client_information(RailClientContext* context, RAIL_CLIENT_STATUS_ORDER* clientStatus)
{
return 0;
}
int rail_client_system_menu(RailClientContext* context, RAIL_SYSMENU_ORDER* sysmenu)
{
return 0;
}
int rail_client_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
return 0;
}
int rail_server_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
return 0;
}
int rail_server_execute_result(RailClientContext* context, RAIL_EXEC_RESULT_ORDER* execResult)
{
return 0;
}
int rail_client_get_appid_request(RailClientContext* context, RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
{
return 0;
}
int rail_server_get_appid_response(RailClientContext* context, RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
{
return 0;
}
/* rail is always built-in */
#define VirtualChannelEntry rail_VirtualChannelEntry
int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
{
railPlugin* _p;
RailClientContext* context;
CHANNEL_ENTRY_POINTS_EX* pEntryPointsEx;
_p = (railPlugin*) malloc(sizeof(railPlugin));
ZeroMemory(_p, sizeof(railPlugin));
@ -269,6 +380,35 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
_p->plugin.event_callback = rail_process_event;
_p->plugin.terminate_callback = rail_process_terminate;
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_EX*) pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_EX)) &&
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
{
context = (RailClientContext*) malloc(sizeof(RailClientContext));
context->ClientExecute = rail_client_execute;
context->ClientActivate = rail_client_activate;
context->GetSystemParam = rail_get_system_param;
context->ServerSystemParam = rail_server_system_param;
context->ClientSystemCommand = rail_client_system_command;
context->ClientHandshake = rail_client_handshake;
context->ServerHandshake = rail_server_handshake;
context->ClientNotifyEvent = rail_client_notify_event;
context->ClientWindowMove = rail_client_window_move;
context->ServerLocalMoveSize = rail_server_local_move_size;
context->ServerMinMaxInfo = rail_server_min_max_info;
context->ClientInformation = rail_client_information;
context->ClientSystemMenu = rail_client_system_menu;
context->ClientLanguageBarInfo = rail_client_language_bar_info;
context->ServerLanguageBarInfo = rail_server_language_bar_info;
context->ServerExecuteResult = rail_server_execute_result;
context->ClientGetAppIdRequest = rail_client_get_appid_request;
context->ServerGetAppIdResponse = rail_server_get_appid_response;
*(pEntryPointsEx->ppInterface) = (void*) context;
}
svc_plugin_init((rdpSvcPlugin*) _p, pEntryPoints);
return 1;

View File

@ -27,6 +27,9 @@
#include <freerdp/utils/debug.h>
#include <freerdp/utils/svc_plugin.h>
#include <freerdp/client/rail.h>
#include <winpr/crt.h>
#include <winpr/stream.h>
#include "../rail_common.h"
@ -41,6 +44,4 @@ typedef struct rail_plugin railPlugin;
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);
#endif /* FREERDP_CHANNEL_CLIENT_RAIL_MAIN_H */

View File

@ -32,7 +32,6 @@
extern const char* const RAIL_ORDER_TYPE_STRINGS[];
#define RAIL_PDU_HEADER_LENGTH 4
/* Fixed length of PDUs, excluding variable lengths */

View File

@ -0,0 +1,29 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Remote Applications Integrated Locally (RAIL)
*
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifndef FREERDP_CHANNEL_RAIL_H
#define FREERDP_CHANNEL_RAIL_H
#include <freerdp/api.h>
#include <freerdp/types.h>
#endif /* FREERDP_CHANNEL_RAIL_H */

View File

@ -0,0 +1,87 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Remote Applications Integrated Locally (RAIL)
*
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifndef FREERDP_CHANNEL_CLIENT_RAIL_H
#define FREERDP_CHANNEL_CLIENT_RAIL_H
#include <freerdp/api.h>
#include <freerdp/types.h>
#include <freerdp/rail.h>
#include <freerdp/message.h>
#include <freerdp/channels/rail.h>
/**
* Client Interface
*/
#define RAIL_SVC_CHANNEL_NAME "RAIL"
typedef struct _rail_client_context RailClientContext;
typedef int (*pcRailClientExecute)(RailClientContext* context, RAIL_EXEC_ORDER* exec);
typedef int (*pcRailClientActivate)(RailClientContext* context, RAIL_ACTIVATE_ORDER* activate);
typedef int (*pcRailGetSystemParam)(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam);
typedef int (*pcRailClientSystemParam)(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam);
typedef int (*pcRailServerSystemParam)(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam);
typedef int (*pcRailClientSystemCommand)(RailClientContext* context, RAIL_SYSCOMMAND_ORDER* syscommand);
typedef int (*pcRailClientHandshake)(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake);
typedef int (*pcRailServerHandshake)(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake);
typedef int (*pcRailClientHandshakeEx)(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
typedef int (*pcRailServerHandshakeEx)(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
typedef int (*pcRailClientNotifyEvent)(RailClientContext* context, RAIL_NOTIFY_EVENT_ORDER* notifyEvent);
typedef int (*pcRailClientWindowMove)(RailClientContext* context, RAIL_WINDOW_MOVE_ORDER* windowMove);
typedef int (*pcRailServerLocalMoveSize)(RailClientContext* context, RAIL_LOCALMOVESIZE_ORDER* localMoveSize);
typedef int (*pcRailServerMinMaxInfo)(RailClientContext* context, RAIL_MINMAXINFO_ORDER* minMaxInfo);
typedef int (*pcRailClientInformation)(RailClientContext* context, RAIL_CLIENT_STATUS_ORDER* clientStatus);
typedef int (*pcRailClientSystemMenu)(RailClientContext* context, RAIL_SYSMENU_ORDER* sysmenu);
typedef int (*pcRailClientLanguageBarInfo)(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo);
typedef int (*pcRailServerLanguageBarInfo)(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo);
typedef int (*pcRailServerExecuteResult)(RailClientContext* context, RAIL_EXEC_RESULT_ORDER* execResult);
typedef int (*pcRailClientGetAppIdRequest)(RailClientContext* context, RAIL_GET_APPID_REQ_ORDER* getAppIdReq);
typedef int (*pcRailServerGetAppIdResponse)(RailClientContext* context, RAIL_GET_APPID_RESP_ORDER* getAppIdResp);
struct _rail_client_context
{
void* handle;
void* custom;
pcRailClientExecute ClientExecute;
pcRailClientActivate ClientActivate;
pcRailGetSystemParam GetSystemParam;
pcRailClientSystemParam ClientSystemParam;
pcRailServerSystemParam ServerSystemParam;
pcRailClientSystemCommand ClientSystemCommand;
pcRailClientHandshake ClientHandshake;
pcRailServerHandshake ServerHandshake;
pcRailClientNotifyEvent ClientNotifyEvent;
pcRailClientWindowMove ClientWindowMove;
pcRailServerLocalMoveSize ServerLocalMoveSize;
pcRailServerMinMaxInfo ServerMinMaxInfo;
pcRailClientInformation ClientInformation;
pcRailClientSystemMenu ClientSystemMenu;
pcRailClientLanguageBarInfo ClientLanguageBarInfo;
pcRailServerLanguageBarInfo ServerLanguageBarInfo;
pcRailServerExecuteResult ServerExecuteResult;
pcRailClientGetAppIdRequest ClientGetAppIdRequest;
pcRailServerGetAppIdResponse ServerGetAppIdResponse;
};
#endif /* FREERDP_CHANNEL_CLIENT_RAIL_H */

View File

@ -303,6 +303,8 @@
#define RailChannel_ServerExecuteResult 17
#define RailChannel_ClientGetAppIdRequest 18
#define RailChannel_ServerGetAppIdResponse 19
#define RailChannel_ClientHandshakeEx 20
#define RailChannel_ServerHandshakeEx 21
#define FREERDP_RAIL_CHANNEL_CLIENT_EXECUTE MakeMessageId(RailChannel, ClientExecute)
#define FREERDP_RAIL_CHANNEL_CLIENT_ACTIVATE MakeMessageId(RailChannel, ClientActivate)
@ -323,6 +325,8 @@
#define FREERDP_RAIL_CHANNEL_SERVER_EXECUTE_RESULT MakeMessageId(RailChannel, ServerExecuteResult)
#define FREERDP_RAIL_CHANNEL_CLIENT_GET_APP_ID_REQUEST MakeMessageId(RailChannel, ClientGetAppIdRequest)
#define FREERDP_RAIL_CHANNEL_SERVER_GET_APP_ID_RESPONSE MakeMessageId(RailChannel, ServerGetAppIdResponse)
#define FREERDP_RAIL_CHANNEL_CLIENT_HANDSHAKE_EX MakeMessageId(RailChannel, ClientHandshakeEx)
#define FREERDP_RAIL_CHANNEL_SERVER_HANDSHAKE_EX MakeMessageId(RailChannel, ServerHandshakeEx)
/**
* MultiTouch Input Channel Extension (MS-RDPEDI)

View File

@ -69,19 +69,18 @@
/*Bit mask values for SPI_ parameters*/
enum SPI_MASK
{
SPI_MASK_SET_DRAG_FULL_WINDOWS = 0x00000001,
SPI_MASK_SET_KEYBOARD_CUES = 0x00000002,
SPI_MASK_SET_KEYBOARD_PREF = 0x00000004,
SPI_MASK_SET_MOUSE_BUTTON_SWAP = 0x00000008,
SPI_MASK_SET_WORK_AREA = 0x00000010,
SPI_MASK_DISPLAY_CHANGE = 0x00000020,
SPI_MASK_TASKBAR_POS = 0x00000040,
SPI_MASK_SET_HIGH_CONTRAST = 0x00000080,
SPI_MASK_SET_SCREEN_SAVE_ACTIVE = 0x00000100,
SPI_MASK_SET_SET_SCREEN_SAVE_SECURE = 0x00000200
SPI_MASK_SET_DRAG_FULL_WINDOWS = 0x00000001,
SPI_MASK_SET_KEYBOARD_CUES = 0x00000002,
SPI_MASK_SET_KEYBOARD_PREF = 0x00000004,
SPI_MASK_SET_MOUSE_BUTTON_SWAP = 0x00000008,
SPI_MASK_SET_WORK_AREA = 0x00000010,
SPI_MASK_DISPLAY_CHANGE = 0x00000020,
SPI_MASK_TASKBAR_POS = 0x00000040,
SPI_MASK_SET_HIGH_CONTRAST = 0x00000080,
SPI_MASK_SET_SCREEN_SAVE_ACTIVE = 0x00000100,
SPI_MASK_SET_SET_SCREEN_SAVE_SECURE = 0x00000200
};
/* Client System Command PDU */
#define SC_SIZE 0xF000
#define SC_MOVE 0xF010
@ -150,6 +149,38 @@ enum SPI_MASK
#define TF_SFT_NOEXTRAICONSONMINIMIZED 0x00000400
#define TF_SFT_DESKBAND 0x00000800
/* Extended Handshake Flags */
#define RAIL_ORDER_HANDSHAKEEX_FLAGS_HIDEF 0x00000001
/* Language Profile Information Flags */
#define TF_PROFILETYPE_INPUTPROCESSOR 0x00000001
#define TF_PROFILETYPE_KEYBOARDLAYOUT 0x00000002
#define IME_STATE_CLOSED 0x00000000
#define IME_STATE_OPEN 0x00000001
#define IME_CMODE_NATIVE 0x00000001
#define IME_CMODE_KATAKANA 0x00000002
#define IME_CMODE_FULLSHAPE 0x00000008
#define IME_CMODE_ROMAN 0x00000010
#define IME_CMODE_CHARCODE 0x00000020
#define IME_CMODE_HANJACONVERT 0x00000040
#define IME_CMODE_SOFTKBD 0x00000080
#define IME_CMODE_NOCONVERSION 0x00000100
#define IME_CMODE_EUDC 0x00000200
#define IME_CMODE_SYMBOL 0x00000400
#define IME_CMODE_FIXED 0x00000800
#define IME_SMODE_NONE 0x00000000
#define IME_SMODE_PLURALCASE 0x00000001
#define IME_SMODE_SINGLECONVERT 0x00000002
#define IME_SMODE_AUTOMATIC 0x00000004
#define IME_SMODE_PHRASEPREDICT 0x00000008
#define IME_SMODE_CONVERSATION 0x00000010
#define KANA_MODE_OFF 0x00000000
#define KANA_MODE_ON 0x00000001
struct _RAIL_UNICODE_STRING
{
UINT16 length;
@ -173,6 +204,13 @@ struct _RAIL_HANDSHAKE_ORDER
};
typedef struct _RAIL_HANDSHAKE_ORDER RAIL_HANDSHAKE_ORDER;
struct _RAIL_HANDSHAKE_EX_ORDER
{
UINT32 buildNumber;
UINT32 railHandshakeFlags;
};
typedef struct _RAIL_HANDSHAKE_EX_ORDER RAIL_HANDSHAKE_EX_ORDER;
struct _RAIL_CLIENT_STATUS_ORDER
{
UINT32 flags;
@ -300,23 +338,22 @@ typedef struct _RAIL_LANGBARINFO_ORDER RAIL_LANGBAR_INFO_ORDER;
/* RAIL Constants */
enum RDP_RAIL_PDU_TYPE
{
RDP_RAIL_ORDER_EXEC = 0x0001,
RDP_RAIL_ORDER_ACTIVATE = 0x0002,
RDP_RAIL_ORDER_SYSPARAM = 0x0003,
RDP_RAIL_ORDER_SYSCOMMAND = 0x0004,
RDP_RAIL_ORDER_HANDSHAKE = 0x0005,
RDP_RAIL_ORDER_NOTIFY_EVENT = 0x0006,
RDP_RAIL_ORDER_WINDOWMOVE = 0x0008,
RDP_RAIL_ORDER_LOCALMOVESIZE = 0x0009,
RDP_RAIL_ORDER_MINMAXINFO = 0x000A,
RDP_RAIL_ORDER_CLIENTSTATUS = 0x000B,
RDP_RAIL_ORDER_SYSMENU = 0x000C,
RDP_RAIL_ORDER_LANGBARINFO = 0x000D,
RDP_RAIL_ORDER_EXEC_RESULT = 0x0080,
RDP_RAIL_ORDER_GET_APPID_REQ = 0x000E,
RDP_RAIL_ORDER_GET_APPID_RESP = 0x000F
};
#define RDP_RAIL_ORDER_EXEC 0x0001
#define RDP_RAIL_ORDER_ACTIVATE 0x0002
#define RDP_RAIL_ORDER_SYSPARAM 0x0003
#define RDP_RAIL_ORDER_SYSCOMMAND 0x0004
#define RDP_RAIL_ORDER_HANDSHAKE 0x0005
#define RDP_RAIL_ORDER_NOTIFY_EVENT 0x0006
#define RDP_RAIL_ORDER_WINDOWMOVE 0x0008
#define RDP_RAIL_ORDER_LOCALMOVESIZE 0x0009
#define RDP_RAIL_ORDER_MINMAXINFO 0x000A
#define RDP_RAIL_ORDER_CLIENTSTATUS 0x000B
#define RDP_RAIL_ORDER_SYSMENU 0x000C
#define RDP_RAIL_ORDER_LANGBARINFO 0x000D
#define RDP_RAIL_ORDER_EXEC_RESULT 0x0080
#define RDP_RAIL_ORDER_GET_APPID_REQ 0x000E
#define RDP_RAIL_ORDER_GET_APPID_RESP 0x000F
#define RDP_RAIL_ORDER_LANGUAGEIMEINFO 0x0011
#define RDP_RAIL_ORDER_HANDSHAKE_EX 0x0013
#endif /* FREERDP_RAIL_GLOBAL_H */