Add guacsvc plugin.

This commit is contained in:
Michael Jumper 2014-03-01 16:42:39 -08:00
parent d0d34a63b9
commit aa4896da07
3 changed files with 225 additions and 2 deletions

View File

@ -42,6 +42,9 @@ libguac_client_rdp_la_SOURCES = \
rdp_settings.c \
unicode.c
guacsvc_sources = \
guac_svc/svc_service.c
guacsnd_sources = \
guac_rdpsnd/rdpsnd_messages.c \
guac_rdpsnd/rdpsnd_service.c
@ -71,6 +74,7 @@ noinst_HEADERS = \
guac_rdpdr/rdpdr_service.h \
guac_rdpsnd/rdpsnd_messages.h \
guac_rdpsnd/rdpsnd_service.h \
guac_svc/svc_service.h \
client.h \
debug.h \
guac_handlers.h \
@ -89,15 +93,18 @@ noinst_HEADERS = \
# Add compatibility layer for WinPR if not available
if ! ENABLE_WINPR
noinst_HEADERS += compat/winpr-stream.h compat/winpr-wtypes.h
guacsvc_sources += compat/winpr-stream.c
guacsnd_sources += compat/winpr-stream.c
guacdr_sources += compat/winpr-stream.c
endif
libguac_client_rdp_la_LDFLAGS = -version-info 0:0:0 @RDP_LIBS@ @PTHREAD_LIBS@ @CAIRO_LIBS@
guacsvc_ldflags = -module -avoid-version -shared @RDP_LIBS@ @PTHREAD_LIBS@
guacsnd_ldflags = -module -avoid-version -shared @RDP_LIBS@ @PTHREAD_LIBS@
guacdr_ldflags = -module -avoid-version -shared @RDP_LIBS@ @PTHREAD_LIBS@
libguac_client_rdp_la_LIBADD = @LIBGUAC_LTLIB@ @COMMON_LTLIB@
guacsvc_libadd = @LIBGUAC_LTLIB@
guacsnd_libadd = @LIBGUAC_LTLIB@
guacdr_libadd = @LIBGUAC_LTLIB@
@ -118,7 +125,11 @@ _generated_keymaps.c: $(rdp_keymaps)
if LEGACY_FREERDP_EXTENSIONS
# FreeRDP 1.0-style extensions
freerdp_LTLIBRARIES = guacsnd.la guacdr.la
freerdp_LTLIBRARIES = guacsvc.la guacsnd.la guacdr.la
guacsvc_la_SOURCES = ${guacsvc_sources}
guacsvc_la_LDFLAGS = ${guacsvc_ldflags}
guacsvc_la_LIBADD = ${guacsvc_libadd}
guacsnd_la_SOURCES = ${guacsnd_sources}
guacsnd_la_LDFLAGS = ${guacsnd_ldflags}
@ -131,7 +142,11 @@ guacdr_la_LIBADD = ${guacdr_libadd}
else
# FreeRDP 1.1 (and hopefully onward) extensions
freerdp_LTLIBRARIES = guacsnd-client.la guacdr-client.la
freerdp_LTLIBRARIES = guacsvc-client.la guacsnd-client.la guacdr-client.la
guacsvc_client_la_SOURCES = ${guacsvc_sources}
guacsvc_client_la_LDFLAGS = ${guacsvc_ldflags}
guacsvc_client_la_LIBADD = ${guacsvc_libadd}
guacsnd_client_la_SOURCES = ${guacsnd_sources}
guacsnd_client_la_LDFLAGS = ${guacsnd_ldflags}

View File

@ -0,0 +1,112 @@
/*
* Copyright (C) 2013 Glyptodon LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "config.h"
#include "client.h"
#include "debug.h"
#include "svc_service.h"
#include <stdlib.h>
#include <string.h>
#include <freerdp/constants.h>
#include <freerdp/utils/svc_plugin.h>
#include <guacamole/client.h>
#ifdef ENABLE_WINPR
#include <winpr/stream.h>
#include <winpr/wtypes.h>
#else
#include "compat/winpr-stream.h"
#include "compat/winpr-wtypes.h"
#endif
/**
* Entry point for arbitrary SVC.
*/
int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) {
/* Allocate plugin */
guac_svcPlugin* svc =
(guac_svcPlugin*) calloc(1, sizeof(guac_svcPlugin));
/* Init channel def */
strcpy(svc->plugin.channel_def.name, "FIXME");
svc->plugin.channel_def.options =
CHANNEL_OPTION_INITIALIZED
| CHANNEL_OPTION_ENCRYPT_RDP
| CHANNEL_OPTION_COMPRESS_RDP;
/* Set callbacks */
svc->plugin.connect_callback = guac_svc_process_connect;
svc->plugin.receive_callback = guac_svc_process_receive;
svc->plugin.event_callback = guac_svc_process_event;
svc->plugin.terminate_callback = guac_svc_process_terminate;
/* Finish init */
svc_plugin_init((rdpSvcPlugin*) svc, pEntryPoints);
return 1;
}
/*
* Service Handlers
*/
void guac_svc_process_connect(rdpSvcPlugin* plugin) {
/* Get SVC plugin */
guac_svcPlugin* svc = (guac_svcPlugin*) plugin;
/* Get client from plugin parameters */
guac_client* client = (guac_client*)
plugin->channel_entry_points.pExtendedData;
/* NULL out pExtendedData so we don't lose our guac_client due to an
* automatic free() within libfreerdp */
plugin->channel_entry_points.pExtendedData = NULL;
/* Get data from client */
/*rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;*/
/* Init plugin */
svc->client = client;
/* Log that printing, etc. has been loaded */
guac_client_log_info(client, "guacsvc connected.");
}
void guac_svc_process_terminate(rdpSvcPlugin* plugin) {
free(plugin);
}
void guac_rdpdr_process_event(rdpSvcPlugin* plugin, wMessage* event) {
freerdp_event_free(event);
}
void guac_rdpdr_process_receive(rdpSvcPlugin* plugin,
wStream* input_stream) {
/* STUB */
}

View File

@ -0,0 +1,96 @@
/*
* Copyright (C) 2013 Glyptodon LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef __GUAC_SVC_SERVICE_H
#define __GUAC_SVC_SERVICE_H
#include "config.h"
#include <pthread.h>
#include <freerdp/utils/svc_plugin.h>
#include <guacamole/client.h>
#ifdef ENABLE_WINPR
#include <winpr/stream.h>
#else
#include "compat/winpr-stream.h"
#endif
/**
* Structure representing the current state of an arbitrary static virtual
* channel.
*/
typedef struct guac_svcPlugin {
/**
* The FreeRDP parts of this plugin. This absolutely MUST be first.
* FreeRDP depends on accessing this structure as if it were an instance
* of rdpSvcPlugin.
*/
rdpSvcPlugin plugin;
/**
* Reference to the client owning this instance.
*/
guac_client* client;
/**
* The name of the RDP channel in use, and the name to use for each pipe.
*/
char* name;
/**
* The pipe opened by the Guacamole client.
*/
guac_stream* input_pipe;
/**
* The output pipe, opened in response to the open input pipe.
*/
guac_stream* output_pipe;
} guac_svcPlugin;
/**
* Handler called when this plugin is loaded by FreeRDP.
*/
void guac_svc_process_connect(rdpSvcPlugin* plugin);
/**
* Handler called when this plugin receives data along its designated channel.
*/
void guac_svc_process_receive(rdpSvcPlugin* plugin,
wStream* input_stream);
/**
* Handler called when this plugin is being unloaded.
*/
void guac_svc_process_terminate(rdpSvcPlugin* plugin);
/**
* Handler called when this plugin receives an event.
*/
void guac_svc_process_event(rdpSvcPlugin* plugin, wMessage* event);
#endif