Send printed document via blobs.

This commit is contained in:
Michael Jumper 2013-06-24 12:34:30 -07:00
parent 9e88ae4f60
commit 8920bc0c76
2 changed files with 28 additions and 2 deletions

View File

@ -2,14 +2,24 @@
#include <freerdp/utils/stream.h>
#include <freerdp/utils/svc_plugin.h>
#include <guacamole/protocol.h>
#include "rdpdr_messages.h"
#include "rdpdr_printer.h"
#include "rdpdr_service.h"
#include "client.h"
void guac_rdpdr_process_print_job_create(guac_rdpdrPlugin* rdpdr, STREAM* input_stream, int completion_id) {
rdp_guac_client_data* client_data = (rdp_guac_client_data*) rdpdr->client->data;
STREAM* output_stream = stream_new(24);
/* Open file */
guac_client_log_info(rdpdr->client, "Print job created");
pthread_mutex_lock(&(client_data->update_lock));
guac_protocol_send_file(rdpdr->client->socket,
GUAC_RDPDR_PRINTER_BLOB, "print.ps", "application/postscript");
pthread_mutex_unlock(&(client_data->update_lock));
/* Write header */
stream_write_uint16(output_stream, RDPDR_CTYP_CORE);
@ -28,15 +38,21 @@ void guac_rdpdr_process_print_job_create(guac_rdpdrPlugin* rdpdr, STREAM* input_
void guac_rdpdr_process_print_job_write(guac_rdpdrPlugin* rdpdr, STREAM* input_stream, int completion_id) {
int length;
unsigned char* buffer;
rdp_guac_client_data* client_data = (rdp_guac_client_data*) rdpdr->client->data;
STREAM* output_stream = stream_new(24);
stream_read_uint32(input_stream, length);
stream_seek(input_stream, 8); /* Offset */
stream_seek(input_stream, 20); /* Padding */
buffer = stream_get_tail(input_stream);
/* TODO: Here, read data */
guac_client_log_info(rdpdr->client, "Data received: %i bytes", length);
/* Send data */
pthread_mutex_lock(&(client_data->update_lock));
guac_protocol_send_blob(rdpdr->client->socket,
GUAC_RDPDR_PRINTER_BLOB, buffer, length);
pthread_mutex_unlock(&(client_data->update_lock));
/* Write header */
stream_write_uint16(output_stream, RDPDR_CTYP_CORE);
@ -55,9 +71,14 @@ void guac_rdpdr_process_print_job_write(guac_rdpdrPlugin* rdpdr, STREAM* input_s
void guac_rdpdr_process_print_job_close(guac_rdpdrPlugin* rdpdr, STREAM* input_stream, int completion_id) {
rdp_guac_client_data* client_data = (rdp_guac_client_data*) rdpdr->client->data;
STREAM* output_stream = stream_new(24);
/* Close file */
guac_client_log_info(rdpdr->client, "Print job closed");
pthread_mutex_lock(&(client_data->update_lock));
guac_protocol_send_end(rdpdr->client->socket, GUAC_RDPDR_PRINTER_BLOB);
pthread_mutex_unlock(&(client_data->update_lock));
/* Write header */
stream_write_uint16(output_stream, RDPDR_CTYP_CORE);

View File

@ -41,6 +41,11 @@
#include <freerdp/utils/stream.h>
#include <freerdp/utils/svc_plugin.h>
/**
* The index of the blob to use when sending printed files.
*/
#define GUAC_RDPDR_PRINTER_BLOB 0
/*
* Message handlers.
*/