GUACAMOLE-200: Maintain print jobs at top level. Do not rely on proper free of RDPDR plugin.

This commit is contained in:
Michael Jumper 2017-02-14 00:02:17 -08:00
parent 1537e475af
commit 5a68f932d6
3 changed files with 29 additions and 16 deletions

View File

@ -23,6 +23,8 @@
#include "client.h"
#include "rdp.h"
#include "rdp_disp.h"
#include "rdp_fs.h"
#include "rdp_print_job.h"
#include "user.h"
#ifdef ENABLE_COMMON_SSH
@ -105,6 +107,12 @@ int guac_rdp_client_free_handler(guac_client* client) {
if (rdp_client->filesystem != NULL)
guac_rdp_fs_free(rdp_client->filesystem);
/* Clean up print job, if active */
if (rdp_client->active_job != NULL) {
guac_rdp_print_job_kill(rdp_client->active_job);
guac_rdp_print_job_free(rdp_client->active_job);
}
#ifdef ENABLE_COMMON_SSH
/* Free SFTP filesystem, if loaded */
if (rdp_client->sftp_filesystem)

View File

@ -22,6 +22,7 @@
#include "rdpdr_messages.h"
#include "rdpdr_printer.h"
#include "rdpdr_service.h"
#include "rdp.h"
#include "rdp_print_job.h"
#include "rdp_status.h"
@ -48,11 +49,14 @@
void guac_rdpdr_process_print_job_create(guac_rdpdr_device* device,
wStream* input_stream, int completion_id) {
guac_client* client = device->rdpdr->client;
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
/* Log creation of print job */
guac_client_log(device->rdpdr->client, GUAC_LOG_INFO, "Print job created");
guac_client_log(client, GUAC_LOG_INFO, "Print job created");
/* Create print job */
device->data = guac_client_for_owner(device->rdpdr->client,
rdp_client->active_job = guac_client_for_owner(client,
guac_rdp_print_job_alloc, NULL);
/* Respond with success */
@ -67,7 +71,9 @@ void guac_rdpdr_process_print_job_create(guac_rdpdr_device* device,
void guac_rdpdr_process_print_job_write(guac_rdpdr_device* device,
wStream* input_stream, int completion_id) {
guac_rdp_print_job* job = (guac_rdp_print_job*) device->data;
guac_client* client = device->rdpdr->client;
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
guac_rdp_print_job* job = (guac_rdp_print_job*) rdp_client->active_job;
unsigned char* buffer;
int length;
@ -104,8 +110,11 @@ void guac_rdpdr_process_print_job_write(guac_rdpdr_device* device,
void guac_rdpdr_process_print_job_close(guac_rdpdr_device* device,
wStream* input_stream, int completion_id) {
guac_client* client = device->rdpdr->client;
guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
guac_rdp_print_job* job = (guac_rdp_print_job*) rdp_client->active_job;
/* End print job */
guac_rdp_print_job* job = (guac_rdp_print_job*) device->data;
if (job != NULL) {
guac_rdp_print_job_free(job);
device->data = NULL;
@ -118,7 +127,7 @@ void guac_rdpdr_process_print_job_close(guac_rdpdr_device* device,
svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream);
/* Log end of print job */
guac_client_log(device->rdpdr->client, GUAC_LOG_INFO, "Print job closed");
guac_client_log(client, GUAC_LOG_INFO, "Print job closed");
}
@ -178,14 +187,7 @@ static void guac_rdpdr_device_printer_iorequest_handler(guac_rdpdr_device* devic
}
static void guac_rdpdr_device_printer_free_handler(guac_rdpdr_device* device) {
/* Terminate and free print job if open */
guac_rdp_print_job* job = (guac_rdp_print_job*) device->data;
if (job != NULL) {
guac_rdp_print_job_kill(job);
guac_rdp_print_job_free(job);
}
/* Do nothing */
}
void guac_rdpdr_register_printer(guac_rdpdrPlugin* rdpdr) {
@ -205,8 +207,5 @@ void guac_rdpdr_register_printer(guac_rdpdrPlugin* rdpdr) {
device->iorequest_handler = guac_rdpdr_device_printer_iorequest_handler;
device->free_handler = guac_rdpdr_device_printer_free_handler;
/* No active print job yet */
device->data = NULL;
}

View File

@ -30,6 +30,7 @@
#include "keyboard.h"
#include "rdp_disp.h"
#include "rdp_fs.h"
#include "rdp_print_job.h"
#include "rdp_settings.h"
#include <freerdp/freerdp.h>
@ -120,6 +121,11 @@ typedef struct guac_rdp_client {
*/
guac_rdp_fs* filesystem;
/**
* The currently-active print job, or NULL if no print job is active.
*/
guac_rdp_print_job* active_job;
#ifdef ENABLE_COMMON_SSH
/**
* The user and credentials used to authenticate for SFTP.