Commit 7c3a522d authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

wineps: Store the unicode version of the printer name and call the unicode version of OpenPrinter.

parent a1526669
...@@ -291,6 +291,18 @@ static void (WINAPI *pInitCommonControls) (void); ...@@ -291,6 +291,18 @@ static void (WINAPI *pInitCommonControls) (void);
static HPROPSHEETPAGE (WINAPI *pCreatePropertySheetPage) (LPCPROPSHEETPAGEW); static HPROPSHEETPAGE (WINAPI *pCreatePropertySheetPage) (LPCPROPSHEETPAGEW);
static int (WINAPI *pPropertySheet) (LPCPROPSHEETHEADERW); static int (WINAPI *pPropertySheet) (LPCPROPSHEETHEADERW);
static PRINTERINFO *PSDRV_FindPrinterInfoA(LPCSTR name)
{
int len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
WCHAR *nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
PRINTERINFO *pi;
MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, len );
pi = PSDRV_FindPrinterInfo( nameW );
HeapFree( GetProcessHeap(), 0, nameW );
return pi;
}
/****************************************************************** /******************************************************************
* PSDRV_ExtDeviceMode * PSDRV_ExtDeviceMode
...@@ -326,7 +338,7 @@ INT PSDRV_ExtDeviceMode(LPSTR lpszDriver, HWND hwnd, LPDEVMODEA lpdmOutput, ...@@ -326,7 +338,7 @@ INT PSDRV_ExtDeviceMode(LPSTR lpszDriver, HWND hwnd, LPDEVMODEA lpdmOutput,
LPSTR lpszDevice, LPSTR lpszPort, LPDEVMODEA lpdmInput, LPSTR lpszDevice, LPSTR lpszPort, LPDEVMODEA lpdmInput,
LPSTR lpszProfile, DWORD dwMode) LPSTR lpszProfile, DWORD dwMode)
{ {
PRINTERINFO *pi = PSDRV_FindPrinterInfo(lpszDevice); PRINTERINFO *pi = PSDRV_FindPrinterInfoA(lpszDevice);
if(!pi) return -1; if(!pi) return -1;
TRACE("(Driver=%s, hwnd=%p, devOut=%p, Device='%s', Port='%s', devIn=%p, Profile='%s', Mode=%04x)\n", TRACE("(Driver=%s, hwnd=%p, devOut=%p, Device='%s', Port='%s', devIn=%p, Profile='%s', Mode=%04x)\n",
...@@ -419,7 +431,7 @@ DWORD PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszP ...@@ -419,7 +431,7 @@ DWORD PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszP
PRINTERINFO *pi; PRINTERINFO *pi;
DEVMODEA *lpdm; DEVMODEA *lpdm;
DWORD ret; DWORD ret;
pi = PSDRV_FindPrinterInfo(lpszDevice); pi = PSDRV_FindPrinterInfoA(lpszDevice);
TRACE("%s %s %s, %u, %p, %p\n", debugstr_a(lpszDriver), debugstr_a(lpszDevice), TRACE("%s %s %s, %u, %p, %p\n", debugstr_a(lpszDriver), debugstr_a(lpszDevice),
debugstr_a(lpszPort), fwCapability, lpszOutput, lpDevMode); debugstr_a(lpszPort), fwCapability, lpszOutput, lpDevMode);
......
...@@ -425,9 +425,9 @@ INT PSDRV_StartDoc( PHYSDEV dev, const DOCINFOW *doc ) ...@@ -425,9 +425,9 @@ INT PSDRV_StartDoc( PHYSDEV dev, const DOCINFOW *doc )
} }
/* FIXME: use PRINTER_DEFAULTS here */ /* FIXME: use PRINTER_DEFAULTS here */
if(!OpenPrinterA(physDev->pi->FriendlyName, &physDev->job.hprinter, NULL)) { if(!OpenPrinterW( physDev->pi->friendly_name, &physDev->job.hprinter, NULL )) {
WARN("OpenPrinter(%s, ...) failed: %d\n", WARN("OpenPrinter(%s, ...) failed: %d\n",
debugstr_a(physDev->pi->FriendlyName), GetLastError()); debugstr_w(physDev->pi->friendly_name), GetLastError());
return 0; return 0;
} }
......
...@@ -327,18 +327,12 @@ static BOOL PSDRV_CreateDC( PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device, ...@@ -327,18 +327,12 @@ static BOOL PSDRV_CreateDC( PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device,
{ {
PSDRV_PDEVICE *physDev; PSDRV_PDEVICE *physDev;
PRINTERINFO *pi; PRINTERINFO *pi;
DWORD len;
char *deviceA;
TRACE("(%s %s %s %p)\n", debugstr_w(driver), debugstr_w(device), TRACE("(%s %s %s %p)\n", debugstr_w(driver), debugstr_w(device),
debugstr_w(output), initData); debugstr_w(output), initData);
if (!device) return FALSE; if (!device) return FALSE;
len = WideCharToMultiByte(CP_ACP, 0, device, -1, NULL, 0, NULL, NULL); pi = PSDRV_FindPrinterInfo( device );
deviceA = HeapAlloc(GetProcessHeap(), 0, len);
WideCharToMultiByte(CP_ACP, 0, device, -1, deviceA, len, NULL, NULL);
pi = PSDRV_FindPrinterInfo(deviceA);
HeapFree(GetProcessHeap(), 0, deviceA);
if(!pi) return FALSE; if(!pi) return FALSE;
if(!pi->Fonts) { if(!pi->Fonts) {
...@@ -376,7 +370,7 @@ static BOOL PSDRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev ) ...@@ -376,7 +370,7 @@ static BOOL PSDRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
{ {
HDC hdc = (*pdev)->hdc; HDC hdc = (*pdev)->hdc;
PSDRV_PDEVICE *physDev, *orig_dev = get_psdrv_dev( orig ); PSDRV_PDEVICE *physDev, *orig_dev = get_psdrv_dev( orig );
PRINTERINFO *pi = PSDRV_FindPrinterInfo( orig_dev->pi->FriendlyName ); PRINTERINFO *pi = PSDRV_FindPrinterInfo( orig_dev->pi->friendly_name );
if (!pi) return FALSE; if (!pi) return FALSE;
if (!(physDev = create_psdrv_physdev( pi ))) return FALSE; if (!(physDev = create_psdrv_physdev( pi ))) return FALSE;
...@@ -540,7 +534,7 @@ static INT PSDRV_GetDeviceCaps( PHYSDEV dev, INT cap ) ...@@ -540,7 +534,7 @@ static INT PSDRV_GetDeviceCaps( PHYSDEV dev, INT cap )
/********************************************************************** /**********************************************************************
* PSDRV_FindPrinterInfo * PSDRV_FindPrinterInfo
*/ */
PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name)
{ {
static PRINTERINFO *PSDRV_PrinterList; static PRINTERINFO *PSDRV_PrinterList;
DWORD type = REG_BINARY, needed, res, dwPaperSize; DWORD type = REG_BINARY, needed, res, dwPaperSize;
...@@ -550,32 +544,37 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) ...@@ -550,32 +544,37 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
HANDLE hPrinter = 0; HANDLE hPrinter = 0;
const char *ppd = NULL; const char *ppd = NULL;
DWORD ppdType; DWORD ppdType;
char* ppdFileName = NULL; char *ppdFileName = NULL, *nameA = NULL;
HKEY hkey; HKEY hkey;
BOOL using_default_devmode = FALSE; BOOL using_default_devmode = FALSE;
int len;
TRACE("'%s'\n", name); TRACE("'%s'\n", debugstr_w(name));
/* /*
* If this loop completes, last will point to the 'next' element of the * If this loop completes, last will point to the 'next' element of the
* final PRINTERINFO in the list * final PRINTERINFO in the list
*/ */
for( ; pi; last = &pi->next, pi = pi->next) for( ; pi; last = &pi->next, pi = pi->next)
if(!strcmp(pi->FriendlyName, name)) if(!strcmpW(pi->friendly_name, name))
return pi; return pi;
pi = *last = HeapAlloc( PSDRV_Heap, HEAP_ZERO_MEMORY, sizeof(*pi) ); pi = *last = HeapAlloc( PSDRV_Heap, HEAP_ZERO_MEMORY, sizeof(*pi) );
if (pi == NULL) if (pi == NULL)
return NULL; return NULL;
if (!(pi->FriendlyName = HeapAlloc( PSDRV_Heap, 0, strlen(name)+1 ))) goto fail; if (!(pi->friendly_name = HeapAlloc( PSDRV_Heap, 0, (strlenW(name)+1)*sizeof(WCHAR) ))) goto fail;
strcpy( pi->FriendlyName, name ); strcpyW( pi->friendly_name, name );
if (OpenPrinterA (pi->FriendlyName, &hPrinter, NULL) == 0) { if (OpenPrinterW( pi->friendly_name, &hPrinter, NULL ) == 0) {
ERR ("OpenPrinterA failed with code %i\n", GetLastError ()); ERR ("OpenPrinter failed with code %i\n", GetLastError ());
goto cleanup; goto cleanup;
} }
len = WideCharToMultiByte( CP_ACP, 0, name, -1, NULL, 0, NULL, NULL );
nameA = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, name, -1, nameA, len, NULL, NULL );
needed = 0; needed = 0;
res = GetPrinterDataExA(hPrinter, NULL, default_devmodeA, &type, NULL, 0, &needed); res = GetPrinterDataExA(hPrinter, NULL, default_devmodeA, &type, NULL, 0, &needed);
...@@ -585,7 +584,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) ...@@ -585,7 +584,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
goto closeprinter; goto closeprinter;
*pi->Devmode = DefaultDevmode; *pi->Devmode = DefaultDevmode;
lstrcpynA((LPSTR)pi->Devmode->dmPublic.dmDeviceName,name,CCHDEVICENAME); lstrcpynA((LPSTR)pi->Devmode->dmPublic.dmDeviceName, nameA, CCHDEVICENAME);
using_default_devmode = TRUE; using_default_devmode = TRUE;
} }
else { else {
...@@ -604,7 +603,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) ...@@ -604,7 +603,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
pcupsGetPPD = wine_dlsym(cupshandle, "cupsGetPPD", NULL, 0); pcupsGetPPD = wine_dlsym(cupshandle, "cupsGetPPD", NULL, 0);
if (pcupsGetPPD) { if (pcupsGetPPD) {
ppd = pcupsGetPPD(name); ppd = pcupsGetPPD( nameA );
if (ppd) { if (ppd) {
needed=strlen(ppd)+1; needed=strlen(ppd)+1;
...@@ -615,7 +614,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) ...@@ -615,7 +614,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
/* we should unlink() that file later */ /* we should unlink() that file later */
} else { } else {
res = ERROR_FILE_NOT_FOUND; res = ERROR_FILE_NOT_FOUND;
WARN("Did not find ppd for %s\n",name); WARN("Did not find ppd for %s\n", debugstr_w(name));
} }
} }
} }
...@@ -636,8 +635,8 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) ...@@ -636,8 +635,8 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
{ {
const char* value_name; const char* value_name;
if (RegQueryValueExA(hkey, name, 0, NULL, NULL, &needed) == ERROR_SUCCESS) { if (RegQueryValueExA(hkey, nameA, 0, NULL, NULL, &needed) == ERROR_SUCCESS) {
value_name=name; value_name=nameA;
} else if (RegQueryValueExA(hkey, "generic", 0, NULL, NULL, &needed) == ERROR_SUCCESS) { } else if (RegQueryValueExA(hkey, "generic", 0, NULL, NULL, &needed) == ERROR_SUCCESS) {
value_name="generic"; value_name="generic";
} else { } else {
...@@ -660,7 +659,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) ...@@ -660,7 +659,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
else else
{ {
res = ERROR_FILE_NOT_FOUND; res = ERROR_FILE_NOT_FOUND;
ERR ("Error %i getting PPD file name for printer '%s'\n", res, name); ERR ("Error %i getting PPD file name for printer '%s'\n", res, debugstr_w(name));
goto closeprinter; goto closeprinter;
} }
ppdFileName = HeapAlloc( PSDRV_Heap, 0, strlen(data_dir) + strlen(filename) + 1 ); ppdFileName = HeapAlloc( PSDRV_Heap, 0, strlen(data_dir) + strlen(filename) + 1 );
...@@ -726,7 +725,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) ...@@ -726,7 +725,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
if (res == ERROR_SUCCESS) if (res == ERROR_SUCCESS)
pi->Devmode->dmPublic.u1.s1.dmPaperSize = (SHORT) dwPaperSize; pi->Devmode->dmPublic.u1.s1.dmPaperSize = (SHORT) dwPaperSize;
else if (res == ERROR_FILE_NOT_FOUND) else if (res == ERROR_FILE_NOT_FOUND)
TRACE ("No 'Paper Size' for printer '%s'\n", name); TRACE ("No 'Paper Size' for printer '%s'\n", debugstr_w(name));
else { else {
ERR ("GetPrinterDataA returned %i\n", res); ERR ("GetPrinterDataA returned %i\n", res);
goto closeprinter; goto closeprinter;
...@@ -749,7 +748,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) ...@@ -749,7 +748,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
res = EnumPrinterDataExA (hPrinter, "PrinterDriverData\\FontSubTable", NULL, res = EnumPrinterDataExA (hPrinter, "PrinterDriverData\\FontSubTable", NULL,
0, &needed, &pi->FontSubTableSize); 0, &needed, &pi->FontSubTableSize);
if (res == ERROR_SUCCESS || res == ERROR_FILE_NOT_FOUND) { if (res == ERROR_SUCCESS || res == ERROR_FILE_NOT_FOUND) {
TRACE ("No 'FontSubTable' for printer '%s'\n", name); TRACE ("No 'FontSubTable' for printer '%s'\n", debugstr_w(name));
} }
else if (res == ERROR_MORE_DATA) { else if (res == ERROR_MORE_DATA) {
pi->FontSubTable = HeapAlloc (PSDRV_Heap, 0, needed); pi->FontSubTable = HeapAlloc (PSDRV_Heap, 0, needed);
...@@ -794,6 +793,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) ...@@ -794,6 +793,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
} }
} }
HeapFree( GetProcessHeap(), 0, nameA );
if (ppd) unlink(ppd); if (ppd) unlink(ppd);
return pi; return pi;
...@@ -802,10 +802,11 @@ closeprinter: ...@@ -802,10 +802,11 @@ closeprinter:
cleanup: cleanup:
HeapFree(PSDRV_Heap, 0, ppdFileName); HeapFree(PSDRV_Heap, 0, ppdFileName);
HeapFree(PSDRV_Heap, 0, pi->FontSubTable); HeapFree(PSDRV_Heap, 0, pi->FontSubTable);
HeapFree(PSDRV_Heap, 0, pi->FriendlyName); HeapFree(PSDRV_Heap, 0, pi->friendly_name);
HeapFree(PSDRV_Heap, 0, pi->Devmode); HeapFree(PSDRV_Heap, 0, pi->Devmode);
fail: fail:
HeapFree(PSDRV_Heap, 0, pi); HeapFree(PSDRV_Heap, 0, pi);
HeapFree( GetProcessHeap(), 0, nameA );
if (ppd) unlink(ppd); if (ppd) unlink(ppd);
*last = NULL; *last = NULL;
return NULL; return NULL;
......
...@@ -242,7 +242,7 @@ numInstalledOptions of OPTIONs ...@@ -242,7 +242,7 @@ numInstalledOptions of OPTIONs
} PSDRV_DEVMODEA; } PSDRV_DEVMODEA;
typedef struct _tagPI { typedef struct _tagPI {
char *FriendlyName; WCHAR *friendly_name;
PPD *ppd; PPD *ppd;
PSDRV_DEVMODEA *Devmode; PSDRV_DEVMODEA *Devmode;
FONTFAMILY *Fonts; FONTFAMILY *Fonts;
...@@ -471,7 +471,7 @@ extern void PSDRV_MergeDevmodes(PSDRV_DEVMODEA *dm1, PSDRV_DEVMODEA *dm2, ...@@ -471,7 +471,7 @@ extern void PSDRV_MergeDevmodes(PSDRV_DEVMODEA *dm1, PSDRV_DEVMODEA *dm2,
PRINTERINFO *pi) DECLSPEC_HIDDEN; PRINTERINFO *pi) DECLSPEC_HIDDEN;
extern BOOL PSDRV_GetFontMetrics(void) DECLSPEC_HIDDEN; extern BOOL PSDRV_GetFontMetrics(void) DECLSPEC_HIDDEN;
extern PPD *PSDRV_ParsePPD(char *fname) DECLSPEC_HIDDEN; extern PPD *PSDRV_ParsePPD(char *fname) DECLSPEC_HIDDEN;
extern PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) DECLSPEC_HIDDEN; extern PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name) DECLSPEC_HIDDEN;
extern const AFM *PSDRV_FindAFMinList(FONTFAMILY *head, LPCSTR name) DECLSPEC_HIDDEN; extern const AFM *PSDRV_FindAFMinList(FONTFAMILY *head, LPCSTR name) DECLSPEC_HIDDEN;
extern BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, const AFM *afm, extern BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, const AFM *afm,
BOOL *p_added) DECLSPEC_HIDDEN; BOOL *p_added) DECLSPEC_HIDDEN;
......
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