guacamole-spice-protocol/src/protocols/rdp/client.c

111 lines
3.0 KiB
C
Raw Normal View History

/*
2016-03-25 19:59:40 +00:00
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
*
2016-03-25 19:59:40 +00:00
* http://www.apache.org/licenses/LICENSE-2.0
*
2016-03-25 19:59:40 +00:00
* 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.
*/
2014-01-01 22:44:28 +00:00
#include "config.h"
#include "client.h"
#include "rdp.h"
#include "rdp_disp.h"
2014-01-01 22:44:28 +00:00
#include "rdp_keymap.h"
#include "user.h"
2014-01-01 22:44:28 +00:00
#ifdef ENABLE_COMMON_SSH
#include <guac_sftp.h>
#include <guac_ssh.h>
#include <guac_ssh_user.h>
#endif
#include <freerdp/cache/cache.h>
2013-07-19 04:52:40 +00:00
#include <freerdp/channels/channels.h>
2014-01-01 22:44:28 +00:00
#include <freerdp/freerdp.h>
#include <guacamole/client.h>
#include <guacamole/socket.h>
#ifdef HAVE_FREERDP_CLIENT_CLIPRDR_H
#include <freerdp/client/cliprdr.h>
#else
#include "compat/client-cliprdr.h"
#endif
2014-01-01 22:44:28 +00:00
#ifdef HAVE_FREERDP_CLIENT_CHANNELS_H
#include <freerdp/client/channels.h>
#endif
2014-06-11 01:45:14 +00:00
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
int guac_client_init(guac_client* client, int argc, char** argv) {
/* Set client args */
client->args = GUAC_RDP_CLIENT_ARGS;
/* Alloc client data */
guac_rdp_client* rdp_client = calloc(1, sizeof(guac_rdp_client));
client->data = rdp_client;
/* Init clipboard */
rdp_client->clipboard = guac_common_clipboard_alloc(GUAC_RDP_CLIPBOARD_MAX_LENGTH);
/* Init display update module */
rdp_client->disp = guac_rdp_disp_alloc();
2013-08-24 19:37:43 +00:00
/* Recursive attribute for locks */
pthread_mutexattr_init(&(rdp_client->attributes));
pthread_mutexattr_settype(&(rdp_client->attributes),
PTHREAD_MUTEX_RECURSIVE);
2013-08-24 19:37:43 +00:00
/* Init RDP lock */
pthread_mutex_init(&(rdp_client->rdp_lock), &(rdp_client->attributes));
2013-08-24 19:37:43 +00:00
/* Clear keysym state mapping and keymap */
memset(rdp_client->keysym_state, 0, sizeof(guac_rdp_keysym_state_map));
memset(rdp_client->keymap, 0, sizeof(guac_rdp_static_keymap));
/* Set handlers */
client->join_handler = guac_rdp_user_join_handler;
client->free_handler = guac_rdp_client_free_handler;
2013-08-27 04:26:38 +00:00
return 0;
}
int guac_rdp_client_free_handler(guac_client* client) {
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
/* Wait for client thread */
pthread_join(rdp_client->client_thread, NULL);
/* Free parsed settings */
if (rdp_client->settings != NULL)
guac_rdp_settings_free(rdp_client->settings);
/* Free display update module */
guac_rdp_disp_free(rdp_client->disp);
/* Free client data */
guac_common_clipboard_free(rdp_client->clipboard);
free(rdp_client);
return 0;
}