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

134 lines
3.8 KiB
C
Raw Normal View History

2011-03-26 04:58:46 +00:00
/* ***** 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 ***** */
2011-03-26 05:49:48 +00:00
#include <stdlib.h>
#include <string.h>
#include <freerdp/freerdp.h>
#include <freerdp/chanman.h>
2011-03-26 04:58:46 +00:00
#include <guacamole/log.h>
#include <guacamole/guacio.h>
#include <guacamole/protocol.h>
#include <guacamole/client.h>
2011-03-26 05:49:48 +00:00
#define RDP_DEFAULT_PORT 3389
2011-03-26 04:58:46 +00:00
/* Client plugin arguments */
const char* GUAC_CLIENT_ARGS[] = {
"hostname",
"port",
NULL
};
int guac_client_init(guac_client* client, int argc, char** argv) {
2011-03-26 05:49:48 +00:00
rdpInst* rdp_inst;
rdpChanMan* chanman;
rdpSet* settings;
char* hostname;
int port = RDP_DEFAULT_PORT;
if (argc < 2) {
guac_send_error(client->io, "Wrong argument count received.");
guac_flush(client->io);
return 1;
}
/* If port specified, use it */
if (argv[1][0] != '\0')
port = atoi(argv[1]);
hostname = argv[0];
/* Get channel manager */
chanman = freerdp_chanman_new();
/* INIT SETTINGS */
settings = malloc(sizeof(rdpSet));
memset(settings, 0, sizeof(rdpSet));
/* Set hostname */
strncpy(settings->hostname, hostname, sizeof(settings->hostname) - 1);
/* Default size */
settings->width = 1024;
settings->height = 768;
strncpy(settings->server, hostname, sizeof(settings->server));
strcpy(settings->username, "guest");
settings->tcp_port_rdp = port;
settings->encryption = 1;
settings->server_depth = 16;
settings->bitmap_cache = 1;
settings->bitmap_compression = 1;
settings->desktop_save = 0;
settings->rdp5_performanceflags =
RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS;
settings->off_screen_bitmaps = 1;
settings->triblt = 0;
settings->new_cursors = 1;
settings->rdp_version = 5;
/* Init chanman here? */
/* Init client */
rdp_inst = freerdp_new(settings);
if (rdp_inst == NULL) {
guac_send_error(client->io, "Error initializing RDP client");
guac_flush(client->io);
return 1;
}
/* freerdp_chanman_pre_connect ? */
/* rdp_inst->rdp_connect(rdp_inst) */
/* rdp_inst->rdp_disconnect(rdp_inst) */
/* freerdp_chanman_post_connect ? */
freerdp_free(rdp_inst);
freerdp_chanman_free(chanman);
free(settings);
2011-03-26 04:58:46 +00:00
/* STUB */
guac_send_error(client->io, "STUB");
2011-03-26 05:49:48 +00:00
return 1;
2011-03-26 04:58:46 +00:00
}