Commit a8c40200 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wineps.drv: Export DrvDeviceCapabilities.

Allows wineps.drv to act as printer configuration interface DLL. Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 9d9d44e4
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "wine/debug.h" #include "wine/debug.h"
#include "psdrv.h" #include "psdrv.h"
#include "ddk/winddiui.h"
#include "winuser.h" #include "winuser.h"
#include "wine/wingdi16.h" #include "wine/wingdi16.h"
...@@ -612,40 +613,87 @@ INT CDECL PSDRV_ExtDeviceMode(LPSTR lpszDriver, HWND hwnd, LPDEVMODEA lpdmOutput ...@@ -612,40 +613,87 @@ INT CDECL PSDRV_ExtDeviceMode(LPSTR lpszDriver, HWND hwnd, LPDEVMODEA lpdmOutput
* Returns * Returns
* Result depends on the setting of fwCapability. -1 indicates failure. * Result depends on the setting of fwCapability. -1 indicates failure.
*/ */
DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszPort, DWORD CDECL PSDRV_DeviceCapabilities(char *driver, const char *device, const char *port,
WORD fwCapability, LPSTR lpszOutput, LPDEVMODEA lpDevMode) WORD capability, char *output, DEVMODEA *devmodeA)
{
WCHAR *device_name = NULL;
DEVMODEW *devmode = NULL;
DWORD ret, len;
len = MultiByteToWideChar(CP_ACP, 0, device, -1, NULL, 0);
if (len) {
device_name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, device, -1, device_name, len);
}
if (devmodeA) devmode = GdiConvertToDevmodeW( devmodeA );
if (output && (capability == DC_BINNAMES ||
capability == DC_FILEDEPENDENCIES ||
capability == DC_PAPERNAMES)) {
/* These need A -> W translation */
unsigned int size = 0, i;
WCHAR *outputW;
ret = DrvDeviceCapabilities(NULL, device_name, capability, NULL, devmode);
if (ret == -1) return ret;
switch (capability) {
case DC_BINNAMES:
size = 24;
break;
case DC_PAPERNAMES:
case DC_FILEDEPENDENCIES:
size = 64;
break;
}
outputW = HeapAlloc(GetProcessHeap(), 0, size * ret * sizeof(WCHAR));
ret = DrvDeviceCapabilities(NULL, device_name, capability, outputW, devmode);
for (i = 0; i < ret; i++)
WideCharToMultiByte(CP_ACP, 0, outputW + (i * size), -1,
output + (i * size), size, NULL, NULL);
HeapFree(GetProcessHeap(), 0, outputW);
} else {
ret = DrvDeviceCapabilities(NULL, device_name, capability, output, devmode);
}
HeapFree(GetProcessHeap(), 0, device_name);
HeapFree(GetProcessHeap(), 0, devmode);
return ret;
}
/******************************************************************************
* DrvDeviceCapabilities (wineps.drv.@)
*/
DWORD WINAPI DrvDeviceCapabilities(HANDLE printer, WCHAR *device_name, WORD capability,
void *output, DEVMODEW *devmode)
{ {
PRINTERINFO *pi; PRINTERINFO *pi;
DEVMODEW *lpdm; DEVMODEW *lpdm;
DWORD ret; DWORD ret;
pi = PSDRV_FindPrinterInfoA(lpszDevice);
TRACE("%s %s %s, %u, %p, %p\n", debugstr_a(lpszDriver), debugstr_a(lpszDevice), TRACE("%s %u, %p, %p\n", debugstr_w(device_name), capability, output, devmode);
debugstr_a(lpszPort), fwCapability, lpszOutput, lpDevMode);
if (!pi) { if (!(pi = PSDRV_FindPrinterInfo(device_name))) {
ERR("no printer info for %s %s, return 0!\n", ERR("no printer info for %s, return 0!\n", debugstr_w(device_name));
debugstr_a(lpszDriver), debugstr_a(lpszDevice));
return 0; return 0;
} }
lpdm = &pi->Devmode->dmPublic; lpdm = &pi->Devmode->dmPublic;
if (lpDevMode) lpdm = GdiConvertToDevmodeW( lpDevMode ); if (devmode) lpdm = devmode;
switch(fwCapability) { switch(capability) {
case DC_PAPERS: case DC_PAPERS:
{ {
PAGESIZE *ps; PAGESIZE *ps;
WORD *wp = (WORD *)lpszOutput; WORD *wp = output;
int i = 0; int i = 0;
LIST_FOR_EACH_ENTRY(ps, &pi->ppd->PageSizes, PAGESIZE, entry) LIST_FOR_EACH_ENTRY(ps, &pi->ppd->PageSizes, PAGESIZE, entry)
{ {
TRACE("DC_PAPERS: %u\n", ps->WinPage); TRACE("DC_PAPERS: %u\n", ps->WinPage);
i++; i++;
if(lpszOutput != NULL) if (output != NULL) *wp++ = ps->WinPage;
*wp++ = ps->WinPage;
} }
ret = i; ret = i;
break; break;
...@@ -654,14 +702,14 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR ...@@ -654,14 +702,14 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR
case DC_PAPERSIZE: case DC_PAPERSIZE:
{ {
PAGESIZE *ps; PAGESIZE *ps;
POINT16 *pt = (POINT16 *)lpszOutput; POINT16 *pt = output;
int i = 0; int i = 0;
LIST_FOR_EACH_ENTRY(ps, &pi->ppd->PageSizes, PAGESIZE, entry) LIST_FOR_EACH_ENTRY(ps, &pi->ppd->PageSizes, PAGESIZE, entry)
{ {
TRACE("DC_PAPERSIZE: %f x %f\n", ps->PaperDimension->x, ps->PaperDimension->y); TRACE("DC_PAPERSIZE: %f x %f\n", ps->PaperDimension->x, ps->PaperDimension->y);
i++; i++;
if(lpszOutput != NULL) { if (output != NULL) {
pt->x = paper_size_from_points( ps->PaperDimension->x ); pt->x = paper_size_from_points( ps->PaperDimension->x );
pt->y = paper_size_from_points( ps->PaperDimension->y ); pt->y = paper_size_from_points( ps->PaperDimension->y );
pt++; pt++;
...@@ -674,15 +722,15 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR ...@@ -674,15 +722,15 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR
case DC_PAPERNAMES: case DC_PAPERNAMES:
{ {
PAGESIZE *ps; PAGESIZE *ps;
char *cp = lpszOutput; WCHAR *cp = output;
int i = 0; int i = 0;
LIST_FOR_EACH_ENTRY(ps, &pi->ppd->PageSizes, PAGESIZE, entry) LIST_FOR_EACH_ENTRY(ps, &pi->ppd->PageSizes, PAGESIZE, entry)
{ {
TRACE("DC_PAPERNAMES: %s\n", debugstr_a(ps->FullName)); TRACE("DC_PAPERNAMES: %s\n", debugstr_a(ps->FullName));
i++; i++;
if(lpszOutput != NULL) { if (output != NULL) {
lstrcpynA(cp, ps->FullName, 64); MultiByteToWideChar(CP_ACP, 0, ps->FullName, -1, cp, 64);
cp += 64; cp += 64;
} }
} }
...@@ -697,13 +745,13 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR ...@@ -697,13 +745,13 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR
case DC_BINS: case DC_BINS:
{ {
INPUTSLOT *slot; INPUTSLOT *slot;
WORD *wp = (WORD *)lpszOutput; WORD *wp = output;
int i = 0; int i = 0;
LIST_FOR_EACH_ENTRY( slot, &pi->ppd->InputSlots, INPUTSLOT, entry ) LIST_FOR_EACH_ENTRY( slot, &pi->ppd->InputSlots, INPUTSLOT, entry )
{ {
i++; i++;
if (lpszOutput != NULL) if (output != NULL)
*wp++ = slot->WinBin; *wp++ = slot->WinBin;
} }
ret = i; ret = i;
...@@ -713,15 +761,15 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR ...@@ -713,15 +761,15 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR
case DC_BINNAMES: case DC_BINNAMES:
{ {
INPUTSLOT *slot; INPUTSLOT *slot;
char *cp = lpszOutput; WCHAR *cp = output;
int i = 0; int i = 0;
LIST_FOR_EACH_ENTRY( slot, &pi->ppd->InputSlots, INPUTSLOT, entry ) LIST_FOR_EACH_ENTRY( slot, &pi->ppd->InputSlots, INPUTSLOT, entry )
{ {
i++; i++;
if (lpszOutput != NULL) if (output != NULL)
{ {
lstrcpynA( cp, slot->FullName, 24 ); MultiByteToWideChar(CP_ACP, 0, slot->FullName, -1, cp, 24);
cp += 24; cp += 24;
} }
} }
...@@ -737,13 +785,13 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR ...@@ -737,13 +785,13 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR
case DC_ENUMRESOLUTIONS: case DC_ENUMRESOLUTIONS:
{ {
RESOLUTION *res; RESOLUTION *res;
LONG *lp = (LONG *)lpszOutput; LONG *lp = output;
int i = 0; int i = 0;
LIST_FOR_EACH_ENTRY(res, &pi->ppd->Resolutions, RESOLUTION, entry) LIST_FOR_EACH_ENTRY(res, &pi->ppd->Resolutions, RESOLUTION, entry)
{ {
i++; i++;
if (lpszOutput != NULL) if (output != NULL)
{ {
lp[0] = res->resx; lp[0] = res->resx;
lp[1] = res->resy; lp[1] = res->resy;
...@@ -936,11 +984,10 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR ...@@ -936,11 +984,10 @@ DWORD CDECL PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR
break; break;
default: default:
FIXME("Unsupported capability %d\n", fwCapability); FIXME("Unsupported capability %d\n", capability);
ret = -1; ret = -1;
} }
if (lpDevMode) HeapFree( GetProcessHeap(), 0, lpdm );
return ret; return ret;
} }
......
@ cdecl wine_get_gdi_driver(long) PSDRV_get_gdi_driver @ cdecl wine_get_gdi_driver(long) PSDRV_get_gdi_driver
# Printer driver config exports
@ stdcall DrvDeviceCapabilities(ptr wstr long ptr ptr)
...@@ -40,6 +40,7 @@ extern "C" { ...@@ -40,6 +40,7 @@ extern "C" {
#define PRINTER_EVENT_FLAG_NO_UI 1 #define PRINTER_EVENT_FLAG_NO_UI 1
DWORD WINAPI DrvDeviceCapabilities(HANDLE, WCHAR *, WORD, void *, DEVMODEW *);
BOOL WINAPI DrvDriverEvent(DWORD, DWORD, LPBYTE, LPARAM); BOOL WINAPI DrvDriverEvent(DWORD, DWORD, LPBYTE, LPARAM);
BOOL WINAPI DrvPrinterEvent(LPWSTR, INT, DWORD, LPARAM); BOOL WINAPI DrvPrinterEvent(LPWSTR, INT, DWORD, LPARAM);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment