GDI stubs, working rect.

This commit is contained in:
Michael Jumper 2012-01-03 19:09:33 -08:00
parent ff51f39436
commit 8fe7443663
6 changed files with 160 additions and 12 deletions

View File

@ -41,7 +41,7 @@ AM_CFLAGS = -Werror -Wall -pedantic -Iinclude
lib_LTLIBRARIES = libguac-client-rdp.la lib_LTLIBRARIES = libguac-client-rdp.la
libguac_client_rdp_la_SOURCES = src/client.c src/rdp_keymap.c src/rdp_bitmap.c src/rdp_glyph.c src/rdp_pointer.c src/guac_handlers.c libguac_client_rdp_la_SOURCES = src/client.c src/rdp_keymap.c src/rdp_bitmap.c src/rdp_glyph.c src/rdp_pointer.c src/rdp_gdi.c src/guac_handlers.c
libguac_client_rdp_la_LDFLAGS = -version-info 0:0:0 libguac_client_rdp_la_LDFLAGS = -version-info 0:0:0

View File

@ -39,6 +39,7 @@
#define _GUAC_RDP_CLIENT_H #define _GUAC_RDP_CLIENT_H
#include <freerdp/freerdp.h> #include <freerdp/freerdp.h>
#include <freerdp/codec/color.h>
#include <guacamole/client.h> #include <guacamole/client.h>
@ -72,5 +73,7 @@ typedef struct rdp_freerdp_context {
} rdp_freerdp_context; } rdp_freerdp_context;
extern CLRCONV guac_rdp_clrconv;
#endif #endif

View File

@ -0,0 +1,49 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is libguac-client-rdp.
*
* The Initial Developer of the Original Code is
* Michael Jumper.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _GUAC_RDP_RDP_GDI_H
#define _GUAC_RDP_RDP_GDI_H
#include <freerdp/freerdp.h>
void guac_rdp_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt);
void guac_rdp_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt);
void guac_rdp_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt);
void guac_rdp_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt);
void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect);
#endif

View File

@ -58,6 +58,7 @@
#include "rdp_bitmap.h" #include "rdp_bitmap.h"
#include "rdp_glyph.h" #include "rdp_glyph.h"
#include "rdp_pointer.h" #include "rdp_pointer.h"
#include "rdp_gdi.h"
/* Client plugin arguments */ /* Client plugin arguments */
const char* GUAC_CLIENT_ARGS[] = { const char* GUAC_CLIENT_ARGS[] = {
@ -66,6 +67,13 @@ const char* GUAC_CLIENT_ARGS[] = {
NULL NULL
}; };
CLRCONV guac_rdp_clrconv = {
.alpha = 1,
.invert = 0,
.rgb555 = 0,
.palette = NULL
};
boolean rdp_freerdp_pre_connect(freerdp* instance) { boolean rdp_freerdp_pre_connect(freerdp* instance) {
rdpContext* context = instance->context; rdpContext* context = instance->context;
@ -74,6 +82,7 @@ boolean rdp_freerdp_pre_connect(freerdp* instance) {
rdpBitmap* bitmap; rdpBitmap* bitmap;
rdpGlyph* glyph; rdpGlyph* glyph;
rdpPointer* pointer; rdpPointer* pointer;
rdpPrimaryUpdate* primary;
/* Set up bitmap handling */ /* Set up bitmap handling */
bitmap = xnew(rdpBitmap); bitmap = xnew(rdpBitmap);
@ -101,6 +110,15 @@ boolean rdp_freerdp_pre_connect(freerdp* instance) {
pointer->Set = guac_rdp_pointer_set; pointer->Set = guac_rdp_pointer_set;
graphics_register_pointer(context->graphics, pointer); graphics_register_pointer(context->graphics, pointer);
/* Set up GDI */
primary = instance->update->primary;
primary->DstBlt = guac_rdp_gdi_dstblt;
primary->PatBlt = guac_rdp_gdi_patblt;
primary->ScrBlt = guac_rdp_gdi_scrblt;
primary->MemBlt = guac_rdp_gdi_memblt;
primary->OpaqueRect = guac_rdp_gdi_opaquerect;
/* Init channels (pre-connect) */ /* Init channels (pre-connect) */
if (freerdp_channels_pre_connect(channels, instance)) { if (freerdp_channels_pre_connect(channels, instance)) {
guac_protocol_send_error(client->socket, "Error initializing RDP client channel manager"); guac_protocol_send_error(client->socket, "Error initializing RDP client channel manager");
@ -131,6 +149,10 @@ boolean rdp_freerdp_post_connect(freerdp* instance) {
client->mouse_handler = rdp_guac_client_mouse_handler; client->mouse_handler = rdp_guac_client_mouse_handler;
client->key_handler = rdp_guac_client_key_handler; client->key_handler = rdp_guac_client_key_handler;
/* FIXME: Actually read REAL screen size from whatever RDP sends us */
guac_protocol_send_size(client->socket, 1024, 768);
guac_socket_flush(client->socket);
return true; return true;
} }
@ -225,9 +247,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
settings->order_support[NEG_MEMBLT_V2_INDEX] = bitmap_cache; settings->order_support[NEG_MEMBLT_V2_INDEX] = bitmap_cache;
settings->order_support[NEG_MEM3BLT_V2_INDEX] = false; settings->order_support[NEG_MEM3BLT_V2_INDEX] = false;
settings->order_support[NEG_SAVEBITMAP_INDEX] = false; settings->order_support[NEG_SAVEBITMAP_INDEX] = false;
settings->order_support[NEG_GLYPH_INDEX_INDEX] = true; settings->order_support[NEG_GLYPH_INDEX_INDEX] = false;
settings->order_support[NEG_FAST_INDEX_INDEX] = true; settings->order_support[NEG_FAST_INDEX_INDEX] = false;
settings->order_support[NEG_FAST_GLYPH_INDEX] = true; settings->order_support[NEG_FAST_GLYPH_INDEX] = false;
settings->order_support[NEG_POLYGON_SC_INDEX] = false; settings->order_support[NEG_POLYGON_SC_INDEX] = false;
settings->order_support[NEG_POLYGON_CB_INDEX] = false; settings->order_support[NEG_POLYGON_CB_INDEX] = false;
settings->order_support[NEG_ELLIPSE_SC_INDEX] = false; settings->order_support[NEG_ELLIPSE_SC_INDEX] = false;

View File

@ -50,13 +50,6 @@
#include "client.h" #include "client.h"
#include "rdp_bitmap.h" #include "rdp_bitmap.h"
static CLRCONV _guac_rdp_clrconv = {
.alpha = 1,
.invert = 0,
.rgb555 = 0,
.palette = NULL
};
void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) { void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) {
/* Allocate buffer */ /* Allocate buffer */
@ -71,7 +64,7 @@ void guac_rdp_bitmap_new(rdpContext* context, rdpBitmap* bitmap) {
unsigned char* image_buffer = freerdp_image_convert(bitmap->data, NULL, unsigned char* image_buffer = freerdp_image_convert(bitmap->data, NULL,
bitmap->width, bitmap->height, bitmap->width, bitmap->height,
context->instance->settings->color_depth, context->instance->settings->color_depth,
32, (HCLRCONV) &_guac_rdp_clrconv); 32, (HCLRCONV) &guac_rdp_clrconv);
/* Create surface from image data */ /* Create surface from image data */
cairo_surface_t* surface = cairo_image_surface_create_for_data( cairo_surface_t* surface = cairo_image_surface_create_for_data(

View File

@ -0,0 +1,81 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is libguac-client-rdp.
*
* The Initial Developer of the Original Code is
* Michael Jumper.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <freerdp/freerdp.h>
#include <guacamole/client.h>
#include "client.h"
void guac_rdp_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt) {
guac_client* client = ((rdp_freerdp_context*) context)->client;
guac_client_log_info(client, "guac_rdp_gdi_dstblt()");
}
void guac_rdp_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) {
guac_client* client = ((rdp_freerdp_context*) context)->client;
guac_client_log_info(client, "guac_rdp_gdi_patblt()");
}
void guac_rdp_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) {
guac_client* client = ((rdp_freerdp_context*) context)->client;
guac_client_log_info(client, "guac_rdp_gdi_scrblt()");
}
void guac_rdp_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt) {
guac_client* client = ((rdp_freerdp_context*) context)->client;
guac_client_log_info(client, "guac_rdp_gdi_memblt()");
}
void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) {
guac_client* client = ((rdp_freerdp_context*) context)->client;
uint32 color = freerdp_color_convert(opaque_rect->color,
context->instance->settings->color_depth, 32, &guac_rdp_clrconv);
guac_protocol_send_rect(client->socket,
GUAC_COMP_OVER, GUAC_DEFAULT_LAYER,
opaque_rect->nLeftRect, opaque_rect->nTopRect,
opaque_rect->nWidth, opaque_rect->nHeight,
(color >> 16) & 0xFF,
(color >> 8 ) & 0xFF,
(color ) & 0xFF,
255);
}