GUACAMOLE-445: Pass printer name from settings to RDP session.
This commit is contained in:
parent
b21f00c29d
commit
e68fe81938
@ -273,4 +273,3 @@ void guac_rdpdr_process_prn_cache_data(guac_rdpdrPlugin* rdpdr, wStream* input_s
|
||||
void guac_rdpdr_process_prn_using_xps(guac_rdpdrPlugin* rdpdr, wStream* input_stream) {
|
||||
guac_client_log(rdpdr->client, GUAC_LOG_INFO, "Printer unexpectedly switched to XPS mode");
|
||||
}
|
||||
|
||||
|
@ -76,12 +76,6 @@
|
||||
#define GUAC_PRINTER_DRIVER "M\0S\0 \0P\0u\0b\0l\0i\0s\0h\0e\0r\0 \0I\0m\0a\0g\0e\0s\0e\0t\0t\0e\0r\0\0\0"
|
||||
#define GUAC_PRINTER_DRIVER_LENGTH 50
|
||||
|
||||
/**
|
||||
* Name of the printer itself.
|
||||
*/
|
||||
#define GUAC_PRINTER_NAME "G\0u\0a\0c\0a\0m\0o\0l\0e\0\0\0"
|
||||
#define GUAC_PRINTER_NAME_LENGTH 20
|
||||
|
||||
/**
|
||||
* Name of the filesystem.
|
||||
*/
|
||||
|
@ -25,12 +25,14 @@
|
||||
#include "rdp.h"
|
||||
#include "rdp_print_job.h"
|
||||
#include "rdp_status.h"
|
||||
#include "unicode.h"
|
||||
|
||||
#include <freerdp/utils/svc_plugin.h>
|
||||
#include <guacamole/client.h>
|
||||
#include <guacamole/protocol.h>
|
||||
#include <guacamole/socket.h>
|
||||
#include <guacamole/stream.h>
|
||||
#include <guacamole/unicode.h>
|
||||
#include <guacamole/user.h>
|
||||
|
||||
#ifdef ENABLE_WINPR
|
||||
@ -141,18 +143,25 @@ static void guac_rdpdr_device_printer_announce_handler(guac_rdpdr_device* device
|
||||
Stream_Write(output_stream, "PRN1\0\0\0\0", 8); /* DOS name */
|
||||
|
||||
/* Printer data */
|
||||
Stream_Write_UINT32(output_stream, 24 + GUAC_PRINTER_DRIVER_LENGTH + GUAC_PRINTER_NAME_LENGTH);
|
||||
int settings_length = guac_utf8_strlen(device->device_name);
|
||||
int printer_name_length = (settings_length + 1) * 2;
|
||||
char printer_name[printer_name_length];
|
||||
guac_rdp_utf8_to_utf16((const unsigned char*)device->device_name,
|
||||
settings_length, printer_name, printer_name_length);
|
||||
printer_name[printer_name_length - 2] = '\0';
|
||||
printer_name[printer_name_length - 1] = '\0';
|
||||
Stream_Write_UINT32(output_stream, 24 + GUAC_PRINTER_DRIVER_LENGTH + printer_name_length);
|
||||
Stream_Write_UINT32(output_stream,
|
||||
RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER
|
||||
| RDPDR_PRINTER_ANNOUNCE_FLAG_NETWORKPRINTER);
|
||||
Stream_Write_UINT32(output_stream, 0); /* reserved - must be 0 */
|
||||
Stream_Write_UINT32(output_stream, 0); /* PnPName length (PnPName is ultimately ignored) */
|
||||
Stream_Write_UINT32(output_stream, GUAC_PRINTER_DRIVER_LENGTH); /* DriverName length */
|
||||
Stream_Write_UINT32(output_stream, GUAC_PRINTER_NAME_LENGTH); /* PrinterName length */
|
||||
Stream_Write_UINT32(output_stream, printer_name_length); /* PrinterName length */
|
||||
Stream_Write_UINT32(output_stream, 0); /* CachedFields length */
|
||||
|
||||
Stream_Write(output_stream, GUAC_PRINTER_DRIVER, GUAC_PRINTER_DRIVER_LENGTH);
|
||||
Stream_Write(output_stream, GUAC_PRINTER_NAME, GUAC_PRINTER_NAME_LENGTH);
|
||||
Stream_Write(output_stream, printer_name, printer_name_length);
|
||||
|
||||
}
|
||||
|
||||
@ -190,7 +199,7 @@ static void guac_rdpdr_device_printer_free_handler(guac_rdpdr_device* device) {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
void guac_rdpdr_register_printer(guac_rdpdrPlugin* rdpdr) {
|
||||
void guac_rdpdr_register_printer(guac_rdpdrPlugin* rdpdr, char* printer_name) {
|
||||
|
||||
int id = rdpdr->devices_registered++;
|
||||
|
||||
@ -200,7 +209,7 @@ void guac_rdpdr_register_printer(guac_rdpdrPlugin* rdpdr) {
|
||||
/* Init device */
|
||||
device->rdpdr = rdpdr;
|
||||
device->device_id = id;
|
||||
device->device_name = "Guacamole Printer";
|
||||
device->device_name = printer_name;
|
||||
|
||||
/* Set handlers */
|
||||
device->announce_handler = guac_rdpdr_device_printer_announce_handler;
|
||||
|
@ -35,7 +35,7 @@
|
||||
* Registers a new printer device within the RDPDR plugin. This must be done
|
||||
* before RDPDR connection finishes.
|
||||
*/
|
||||
void guac_rdpdr_register_printer(guac_rdpdrPlugin* rdpdr);
|
||||
void guac_rdpdr_register_printer(guac_rdpdrPlugin* rdpdr, char* printer_name);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -96,7 +96,7 @@ void guac_rdpdr_process_connect(rdpSvcPlugin* plugin) {
|
||||
|
||||
/* Register printer if enabled */
|
||||
if (rdp_client->settings->printing_enabled)
|
||||
guac_rdpdr_register_printer(rdpdr);
|
||||
guac_rdpdr_register_printer(rdpdr, rdp_client->settings->printer_name);
|
||||
|
||||
/* Register drive if enabled */
|
||||
if (rdp_client->settings->drive_enabled)
|
||||
|
@ -990,6 +990,7 @@ void guac_rdp_settings_free(guac_rdp_settings* settings) {
|
||||
free(settings->remote_app_args);
|
||||
free(settings->remote_app_dir);
|
||||
free(settings->username);
|
||||
free(settings->printer_name);
|
||||
|
||||
/* Free channel name array */
|
||||
if (settings->svc_names != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user