Beispiel #1
0
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
    int i;
    char* name;
    char* driver_name;
    rdpPrinter* printer;
    rdpPrinter** printers;
    RDPDR_PRINTER* device;
    rdpPrinterDriver* driver = NULL;

#ifdef WITH_CUPS
    driver = printer_cups_get_driver();
#endif
#ifdef WIN32
    driver = printer_win_get_driver();
#endif

    if (driver == NULL)
    {
        DEBUG_WARN("no driver");
        return 1;
    }

    device = (RDPDR_PRINTER*) pEntryPoints->device;
    name = device->Name;
    driver_name = device->DriverName;

    if (name && name[0])
    {
        printer = driver->GetPrinter(driver, name);

        if (printer == NULL)
        {
            DEBUG_WARN("printer %s not found.", name);
            return 1;
        }

        if (driver_name && driver_name[0])
            printer->driver = driver_name;

        printer_register(pEntryPoints, printer);
    }
    else
    {
        printers = driver->EnumPrinters(driver);

        for (i = 0; printers[i]; i++)
        {
            printer = printers[i];
            printer_register(pEntryPoints, printer);
        }

        free(printers);
    }

    return 0;
}
Beispiel #2
0
int
DeviceServiceEntry(PDEVMAN pDevman, PDEVMAN_ENTRY_POINTS pEntryPoints)
{
	SERVICE * srv = NULL;
	RD_PLUGIN_DATA * data;
	int port = 1;

	data = (RD_PLUGIN_DATA *) pEntryPoints->pExtendedData;
	while (data && data->size > 0)
	{
		if (strcmp((char*)data->data[0], "printer") == 0)
		{
			if (srv == NULL)
				srv = printer_register_service(pDevman, pEntryPoints);

			if (data->data[1] == NULL)
			{
				printer_hw_register_auto(pDevman, pEntryPoints, srv, &port);
				break;
			}
			else
			{
				printer_register(pDevman, pEntryPoints, srv, data->data[1], data->data[2], (port == 1), &port);
			}
		}
		data = (RD_PLUGIN_DATA *) (((void *) data) + data->size);
	}

	return 1;
}
Beispiel #3
0
int
printer_hw_register_auto(PDEVMAN pDevman, PDEVMAN_ENTRY_POINTS pEntryPoints, SERVICE * srv,
	int * port)
{
	cups_dest_t *dests;
	cups_dest_t *dest;
	int num_dests;
	int i;

	num_dests = cupsGetDests(&dests);
	for (i = 0, dest = dests; i < num_dests; i++, dest++)
	{
		if (dest->instance == NULL)
		{
			printer_register(pDevman, pEntryPoints, srv, dest->name, NULL, dest->is_default, port);
		}
	}
	cupsFreeDests(num_dests, dests);
	return 0;
}
Beispiel #4
0
int pdfDeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) {
	urdpPdfPrinter* pdf_printer;

	pdf_printer = xnew(urdpPdfPrinter);

	pdf_printer->printer.id = 1;
	pdf_printer->printer.name = strdup(pEntryPoints->plugin_data->data[1]);
	/* This is the PDF Ulteo driver. On printing, the printer transmits a PDF back to the client. */
	pdf_printer->printer.driver = "Ulteo TS Printer Driver";
	pdf_printer->printer.is_default = true;

	pdf_printer->printer.CreatePrintJob = urdp_pdf_create_printjob;
	pdf_printer->printer.FindPrintJob = urdp_pdf_find_printjob;
	pdf_printer->printer.Free = urdp_pdf_free_printer;

	pdf_printer->jobs = list_new();
	pdf_printer->plugin = pEntryPoints->devman->plugin;

	printer_register(pEntryPoints, (rdpPrinter*) pdf_printer);

	return 0;
}
Beispiel #5
0
/**
 * Function description
 *
 * @return 0 on success, otherwise a Win32 error code
 */
UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
	int i;
	char* name;
	char* driver_name;
	rdpPrinter* printer;
	rdpPrinter** printers;
	RDPDR_PRINTER* device;
	rdpPrinterDriver* driver = NULL;
	UINT error;
#ifdef WITH_CUPS
	driver = printer_cups_get_driver();
#endif
#if defined(_WIN32) && !defined(_UWP)
	driver = printer_win_get_driver();
#endif

	if (!driver)
	{
		WLog_ERR(TAG, "Could not get a printer driver!");
		return CHANNEL_RC_INITIALIZATION_ERROR;
	}

	device = (RDPDR_PRINTER*) pEntryPoints->device;
	name = device->Name;
	driver_name = device->DriverName;

	if (name && name[0])
	{
		printer = driver->GetPrinter(driver, name, driver_name);

		if (!printer)
		{
			WLog_ERR(TAG, "Could not get printer %s!", name);
			return CHANNEL_RC_INITIALIZATION_ERROR;
		}

		if ((error = printer_register(pEntryPoints, printer)))
		{
			WLog_ERR(TAG, "printer_register failed with error %lu!", error);
			return error;
		}
	}
	else
	{
		printers = driver->EnumPrinters(driver);

		for (i = 0; printers[i]; i++)
		{
			printer = printers[i];

			if ((error = printer_register(pEntryPoints, printer)))
			{
				WLog_ERR(TAG, "printer_register failed with error %lu!", error);
				free(printers);
				return error;
			}
		}

		free(printers);
	}

	return CHANNEL_RC_OK;
}