2013-06-14 18:00:19 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* X11 Client Interface
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "mfreerdp.h"
|
2013-06-15 00:19:03 +04:00
|
|
|
#include <freerdp/constants.h>
|
2013-06-14 18:00:19 +04:00
|
|
|
#include <freerdp/utils/signal.h>
|
|
|
|
#include <freerdp/client/cmdline.h>
|
2013-06-26 21:45:12 +04:00
|
|
|
#import "MRDPView.h"
|
2013-06-14 18:00:19 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Client Interface
|
|
|
|
*/
|
|
|
|
|
2013-06-15 00:19:03 +04:00
|
|
|
void mfreerdp_client_global_init()
|
2013-06-14 18:00:19 +04:00
|
|
|
{
|
|
|
|
freerdp_handle_signals();
|
|
|
|
freerdp_channels_global_init();
|
|
|
|
}
|
|
|
|
|
2013-06-15 00:19:03 +04:00
|
|
|
void mfreerdp_client_global_uninit()
|
2013-06-14 18:00:19 +04:00
|
|
|
{
|
|
|
|
freerdp_channels_global_uninit();
|
|
|
|
}
|
|
|
|
|
2013-06-15 00:19:03 +04:00
|
|
|
int mfreerdp_client_start(rdpContext* context)
|
2013-06-14 18:00:19 +04:00
|
|
|
{
|
2013-06-23 06:55:51 +04:00
|
|
|
MRDPView* view;
|
|
|
|
mfContext* mfc = (mfContext*) context;
|
2013-06-23 04:27:23 +04:00
|
|
|
|
2013-06-26 21:45:12 +04:00
|
|
|
if (mfc->view == NULL)
|
|
|
|
{
|
|
|
|
// view not specified beforehand. Create view dynamically
|
2013-06-27 19:22:15 +04:00
|
|
|
mfc->view = [[MRDPView alloc] initWithFrame : NSMakeRect(0, 0, context->settings->DesktopWidth, context->settings->DesktopHeight)];
|
2013-06-26 21:45:12 +04:00
|
|
|
mfc->view_ownership = TRUE;
|
|
|
|
}
|
|
|
|
|
2013-06-23 06:55:51 +04:00
|
|
|
view = (MRDPView*) mfc->view;
|
|
|
|
[view rdpStart:context];
|
2013-06-23 04:27:23 +04:00
|
|
|
|
|
|
|
return 0;
|
2013-06-14 18:00:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-15 00:19:03 +04:00
|
|
|
int mfreerdp_client_stop(rdpContext* context)
|
2013-06-14 18:00:19 +04:00
|
|
|
{
|
2013-06-23 04:27:23 +04:00
|
|
|
mfContext* mfc = (mfContext*) context;
|
|
|
|
|
|
|
|
if (context->settings->AsyncUpdate)
|
|
|
|
{
|
|
|
|
wMessageQueue* queue;
|
|
|
|
queue = freerdp_get_message_queue(context->instance, FREERDP_UPDATE_MESSAGE_QUEUE);
|
2013-06-27 19:22:15 +04:00
|
|
|
if (queue)
|
|
|
|
{
|
|
|
|
MessageQueue_PostQuit(queue, 0);
|
|
|
|
}
|
2013-06-23 04:27:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (context->settings->AsyncInput)
|
|
|
|
{
|
|
|
|
wMessageQueue* queue;
|
|
|
|
queue = freerdp_get_message_queue(context->instance, FREERDP_INPUT_MESSAGE_QUEUE);
|
2013-06-27 19:22:15 +04:00
|
|
|
if (queue)
|
|
|
|
{
|
|
|
|
MessageQueue_PostQuit(queue, 0);
|
|
|
|
}
|
|
|
|
}
|
2013-06-23 04:27:23 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
mfc->disconnect = TRUE;
|
|
|
|
}
|
|
|
|
|
2013-06-26 21:45:12 +04:00
|
|
|
if (mfc->view_ownership)
|
|
|
|
{
|
2013-06-27 19:22:15 +04:00
|
|
|
MRDPView* view = (MRDPView*) mfc->view;
|
2013-06-26 21:45:12 +04:00
|
|
|
[view releaseResources];
|
|
|
|
[view release];
|
2013-06-27 19:22:15 +04:00
|
|
|
mfc->view = nil;
|
2013-06-26 21:45:12 +04:00
|
|
|
}
|
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
return 0;
|
2013-06-14 18:00:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-15 00:19:03 +04:00
|
|
|
int mfreerdp_client_new(freerdp* instance, rdpContext* context)
|
2013-06-14 18:00:19 +04:00
|
|
|
{
|
2013-06-23 04:27:23 +04:00
|
|
|
mfContext* mfc;
|
|
|
|
rdpSettings* settings;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
mfc = (mfContext*) instance->context;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-07-04 22:42:40 +04:00
|
|
|
context->instance->PreConnect = mac_pre_connect;
|
|
|
|
context->instance->PostConnect = mac_post_connect;
|
|
|
|
context->instance->ReceiveChannelData = mac_receive_channel_data;
|
|
|
|
context->instance->Authenticate = mac_authenticate;
|
|
|
|
|
|
|
|
context->channels = freerdp_channels_new();
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
settings = instance->settings;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
settings->AsyncUpdate = TRUE;
|
|
|
|
// TODO settings->AsyncInput = TRUE;
|
|
|
|
settings->AsyncChannels = TRUE;
|
|
|
|
settings->AsyncTransport = TRUE;
|
|
|
|
settings->RedirectClipboard = TRUE;
|
2013-06-20 18:03:20 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
settings->OsMajorType = OSMAJORTYPE_MACINTOSH;
|
|
|
|
settings->OsMinorType = OSMINORTYPE_MACINTOSH;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
|
|
|
settings->OrderSupport[NEG_DSTBLT_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_PATBLT_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_DRAWNINEGRID_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_LINETO_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_POLYLINE_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_MEMBLT_INDEX] = settings->BitmapCacheEnabled;
|
|
|
|
|
|
|
|
settings->OrderSupport[NEG_MEM3BLT_INDEX] = (settings->SoftwareGdi) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = settings->BitmapCacheEnabled;
|
|
|
|
settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_FAST_INDEX_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = TRUE;
|
|
|
|
|
|
|
|
settings->OrderSupport[NEG_POLYGON_SC_INDEX] = (settings->SoftwareGdi) ? FALSE : TRUE;
|
|
|
|
settings->OrderSupport[NEG_POLYGON_CB_INDEX] = (settings->SoftwareGdi) ? FALSE : TRUE;
|
|
|
|
|
|
|
|
settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE;
|
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
return 0;
|
2013-06-14 18:00:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-15 00:19:03 +04:00
|
|
|
void mfreerdp_client_free(freerdp* instance, rdpContext* context)
|
2013-06-14 18:00:19 +04:00
|
|
|
{
|
2013-06-23 06:55:51 +04:00
|
|
|
|
2013-06-14 18:00:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-18 05:21:42 +04:00
|
|
|
void freerdp_client_mouse_event(rdpContext* cfc, DWORD flags, int x, int y)
|
|
|
|
{
|
2013-06-23 04:27:23 +04:00
|
|
|
int width, height;
|
|
|
|
rdpInput* input = cfc->instance->input;
|
|
|
|
rdpSettings* settings = cfc->instance->settings;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
width = settings->DesktopWidth;
|
|
|
|
height = settings->DesktopHeight;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
x = width - 1;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
if (y < 0)
|
|
|
|
y = 0;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
if (y >= height)
|
|
|
|
y = height - 1;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
input->MouseEvent(input, flags, x, y);
|
2013-06-18 05:21:42 +04:00
|
|
|
}
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-15 00:19:03 +04:00
|
|
|
int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
|
2013-06-14 18:00:19 +04:00
|
|
|
{
|
2013-06-23 04:27:23 +04:00
|
|
|
pEntryPoints->Version = 1;
|
|
|
|
pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
pEntryPoints->GlobalInit = mfreerdp_client_global_init;
|
|
|
|
pEntryPoints->GlobalUninit = mfreerdp_client_global_uninit;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
pEntryPoints->ContextSize = sizeof(mfContext);
|
|
|
|
pEntryPoints->ClientNew = mfreerdp_client_new;
|
|
|
|
pEntryPoints->ClientFree = mfreerdp_client_free;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
pEntryPoints->ClientStart = mfreerdp_client_start;
|
|
|
|
pEntryPoints->ClientStop = mfreerdp_client_stop;
|
2013-06-14 18:00:19 +04:00
|
|
|
|
2013-06-23 04:27:23 +04:00
|
|
|
return 0;
|
2013-06-14 18:00:19 +04:00
|
|
|
}
|