#include <guacamole/socket.h>
#include <guacamole/protocol.h>
#include <guacamole/client.h>
+#include <guacamole/error.h>
#include "client.h"
#include "guac_handlers.h"
bitmap->Decompress = guac_rdp_bitmap_decompress;
bitmap->SetSurface = guac_rdp_bitmap_setsurface;
graphics_register_bitmap(context->graphics, bitmap);
+ xfree(bitmap);
/* Set up glyph handling */
glyph = xnew(rdpGlyph);
glyph->BeginDraw = guac_rdp_glyph_begindraw;
glyph->EndDraw = guac_rdp_glyph_enddraw;
graphics_register_glyph(context->graphics, glyph);
+ xfree(glyph);
/* Set up pointer handling */
pointer = xnew(rdpPointer);
pointer->Free = guac_rdp_pointer_free;
pointer->Set = guac_rdp_pointer_set;
graphics_register_pointer(context->graphics, pointer);
+ xfree(pointer);
/* Set up GDI */
instance->update->Palette = guac_rdp_gdi_palette_update;
/* EMPTY */
}
+void __guac_rdp_client_load_keymap(guac_client* client,
+ const guac_rdp_keymap* keymap) {
+
+ rdp_guac_client_data* guac_client_data =
+ (rdp_guac_client_data*) client->data;
+ /* Get mapping */
+ const guac_rdp_keysym_desc* mapping = keymap->mapping;
+
+ /* If parent exists, load parent first */
+ if (keymap->parent != NULL)
+ __guac_rdp_client_load_keymap(client, keymap->parent);
+
+ /* Log load */
+ guac_client_log_info(client, "Loading keymap \"%s\"", keymap->name);
+
+ /* Load mapping into keymap */
+ while (mapping->keysym != 0) {
+
+ /* Copy mapping */
+ GUAC_RDP_KEYSYM_LOOKUP(guac_client_data->keymap, mapping->keysym) =
+ *mapping;
+
+ /* Next keysym */
+ mapping++;
+
+ }
+
+}
+
int guac_client_init(guac_client* client, int argc, char** argv) {
rdp_guac_client_data* guac_client_data;
boolean bitmap_cache;
if (argc < 8) {
- guac_protocol_send_error(client->socket, "Wrong argument count received.");
+
+ guac_protocol_send_error(client->socket,
+ "Wrong argument count received.");
guac_socket_flush(client->socket);
+
+ guac_error = GUAC_STATUS_BAD_ARGUMENT;
+ guac_error_message = "Wrong argument count received";
+
return 1;
}
guac_client_data->mouse_button_mask = 0;
guac_client_data->current_surface = GUAC_DEFAULT_LAYER;
- ((rdp_freerdp_context*) rdp_inst->context)->client = client;
+ /* Clear keysym state mapping and keymap */
+ memset(guac_client_data->keysym_state, 0,
+ sizeof(guac_rdp_keysym_state_map));
+
+ memset(guac_client_data->keymap, 0,
+ sizeof(guac_rdp_static_keymap));
+
client->data = guac_client_data;
+ ((rdp_freerdp_context*) rdp_inst->context)->client = client;
+
+ /* Load keymap into client */
+ __guac_rdp_client_load_keymap(client, &guac_rdp_keymap_en_us);
/* Connect to RDP server */
if (!freerdp_connect(rdp_inst)) {
- guac_protocol_send_error(client->socket, "Error connecting to RDP server");
+
+ guac_protocol_send_error(client->socket,
+ "Error connecting to RDP server");
guac_socket_flush(client->socket);
+
+ guac_error = GUAC_STATUS_BAD_STATE;
+ guac_error_message = "Error connecting to RDP server";
+
return 1;
}