[PrintUI|NTPrint] Printing Application Utility Support

PrintUI : Move to printing base directory.
NTPrint : Import from wine.

NTPrint does have a API test program from wine, not imported at this
time.

These will be Sync/Ported to full forked.
This commit is contained in:
James Tabor 2020-05-12 20:26:02 -05:00
parent 666fe66fe9
commit 98bfe2fc89
12 changed files with 242 additions and 1 deletions

View file

@ -1,4 +1,6 @@
#add_subdirectory(printui)
add_subdirectory(ntprint)
add_subdirectory(printui)
add_subdirectory(spoolss)
add_subdirectory(spoolsv)
add_subdirectory(winspool)

View file

@ -0,0 +1,15 @@
add_definitions(-D__WINESRC__)
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
spec2def(ntprint.dll ntprint.spec)
list(APPEND SOURCE
ntprint.c
${CMAKE_CURRENT_BINARY_DIR}/ntprint_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/ntprint.def)
add_library(ntprint MODULE ${SOURCE} ntprint.rc)
set_module_type(ntprint win32dll)
target_link_libraries(ntprint wine)
add_importlibs(ntprint winspool msvcrt kernel32 ntdll)
add_cd_file(TARGET ntprint DESTINATION reactos/system32 FOR all)

View file

@ -0,0 +1,156 @@
/*
* Implementation of the Spooler Setup API (Printing)
*
* Copyright 2007 Detlef Riekenberg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "winnls.h"
#include "winver.h"
#include "winspool.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ntprint);
typedef struct {
LPMONITOR_INFO_2W mi2; /* Buffer for installed Monitors */
DWORD installed; /* Number of installed Monitors */
} monitorinfo_t;
/*****************************************************
* DllMain
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("(%p, %d, %p)\n",hinstDLL, fdwReason, lpvReserved);
switch(fdwReason)
{
case DLL_WINE_PREATTACH:
return FALSE; /* prefer native version */
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls( hinstDLL );
break;
}
return TRUE;
}
/*****************************************************
* PSetupCreateMonitorInfo [NTPRINT.@]
*
*
*/
HANDLE WINAPI PSetupCreateMonitorInfo(DWORD unknown1, WCHAR *server)
{
monitorinfo_t * mi=NULL;
DWORD needed;
DWORD res;
TRACE("(%d, %s)\n", unknown1, debugstr_w(server));
mi = HeapAlloc(GetProcessHeap(), 0, sizeof(monitorinfo_t));
if (!mi) {
/* FIXME: SetLastError() needed? */
return NULL;
}
/* Get the needed size for all Monitors */
res = EnumMonitorsW(server, 2, NULL, 0, &needed, &mi->installed);
if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
mi->mi2 = HeapAlloc(GetProcessHeap(), 0, needed);
res = EnumMonitorsW(server, 2, (LPBYTE) mi->mi2, needed, &needed, &mi->installed);
}
if (!res) {
HeapFree(GetProcessHeap(), 0, mi);
return NULL;
}
TRACE("=> %p (%u monitors installed)\n", mi, mi->installed);
return mi;
}
/*****************************************************
* PSetupDestroyMonitorInfo [NTPRINT.@]
*
*/
VOID WINAPI PSetupDestroyMonitorInfo(HANDLE monitorinfo)
{
monitorinfo_t * mi = monitorinfo;
TRACE("(%p)\n", mi);
if (mi) {
if (mi->installed) HeapFree(GetProcessHeap(), 0, mi->mi2);
HeapFree(GetProcessHeap(), 0, mi);
}
}
/*****************************************************
* PSetupEnumMonitor [NTPRINT.@]
*
* Copy the selected Monitorname to a buffer
*
* PARAMS
* monitorinfo [I] HANDLE from PSetupCreateMonitorInfo
* index [I] Nr. of the Monitorname to copy
* buffer [I] Target, that receive the Monitorname
* psize [IO] PTR to a DWORD that hold the size of the buffer and receive
* the needed size, when the buffer is too small
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*
* NOTES
* size is in Bytes on w2k and WCHAR on XP
*
*/
BOOL WINAPI PSetupEnumMonitor(HANDLE monitorinfo, DWORD index, LPWSTR buffer, LPDWORD psize)
{
monitorinfo_t * mi = monitorinfo;
LPWSTR nameW;
DWORD len;
TRACE("(%p, %u, %p, %p) => %d\n", mi, index, buffer, psize, psize ? *psize : 0);
if (index < mi->installed) {
nameW = mi->mi2[index].pName;
len = lstrlenW(nameW) + 1;
if (len <= *psize) {
memcpy(buffer, nameW, len * sizeof(WCHAR));
TRACE("#%u: %s\n", index, debugstr_w(buffer));
return TRUE;
}
*psize = len;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
SetLastError(ERROR_NO_MORE_ITEMS);
return FALSE;
}

View file

@ -0,0 +1,34 @@
/*
* Top level resource file for ntprint.dll
*
* Copyright 2007 Detlef Riekenberg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#include "winver.h"
#define WINE_FILENAME_STR "ntprint.dll"
#define WINE_FILEDESCRIPTION_STR "Spooler Setup API (Printing)"
/* Same Version as WinXP_sp2 */
#define WINE_FILEVERSION 5,1,2600,2180
#define WINE_FILEVERSION_STR "5.1.2600.2180"
#define WINE_PRODUCTVERSION 5,1,2600,2180
#define WINE_PRODUCTVERSION_STR "5.1.2600.2180"
#include "wine/wine_common_ver.rc"

View file

@ -0,0 +1,35 @@
@ stub ClassInstall32
@ stub PSetupAssociateICMProfiles
@ stub PSetupBuildDriversFromPath
@ stub PSetupCreateDrvSetupPage
@ stdcall PSetupCreateMonitorInfo(long wstr)
@ stub PSetupCreatePrinterDeviceInfoList
@ stub PSetupDestroyDriverInfo3
@ stdcall PSetupDestroyMonitorInfo(long)
@ stub PSetupDestroyPrinterDeviceInfoList
@ stub PSetupDestroySelectedDriverInfo
@ stub PSetupDriverInfoFromName
@ stdcall PSetupEnumMonitor(long long ptr ptr)
@ stub PSetupFreeDrvField
@ stub PSetupGetDriverInfForPrinter
@ stub PSetupGetDriverInfo3
@ stub PSetupGetLocalDataField
@ stub PSetupGetPathToSearch
@ stub PSetupGetSelectedDriverInfo
@ stub PSetupInstallICMProfiles
@ stub PSetupInstallMonitor
@ stub PSetupInstallPrinterDriver
@ stub PSetupInstallPrinterDriverFromTheWeb
@ stub PSetupIsCompatibleDriver
@ stub PSetupIsDriverInstalled
@ stub PSetupIsMonitorInstalled
@ stub PSetupIsOemDriver
@ stub PSetupIsTheDriverFoundInInfInstalled
@ stub PSetupKillBadUserConnections
@ stub PSetupPreSelectDriver
@ stub PSetupProcessPrinterAdded
@ stub PSetupRefreshDriverList
@ stub PSetupSelectDeviceButtons
@ stub PSetupSelectDriver
@ stub PSetupSetSelectDevTitleAndInstructions
@ stub PSetupThisPlatform

View file

@ -0,0 +1,15 @@
add_definitions(-D__WINESRC__)
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
spec2def(printui.dll printui.spec)
list(APPEND SOURCE
printui.c
${CMAKE_CURRENT_BINARY_DIR}/printui_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/printui.def)
add_library(printui MODULE ${SOURCE} printui.rc)
set_module_type(printui win32dll)
target_link_libraries(printui wine)
add_importlibs(printui shell32 msvcrt kernel32 ntdll)
add_cd_file(TARGET printui DESTINATION reactos/system32 FOR all)

View file

@ -0,0 +1,278 @@
/*
* Implementation of the Printer User Interface Dialogs
*
* Copyright 2006-2007 Detlef Riekenberg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winreg.h"
#include "winver.h"
#include "winnls.h"
#include "shellapi.h"
#include "wine/debug.h"
#include "printui_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(printui);
/* ################################# */
/* Must be in order with OPT_* */
static const WCHAR optionsW[OPT_MAX+1]={'a','b','c','f','h','j','l','m','n','t','r','v',0};
/* Must be in order with FLAG_* */
static const WCHAR flagsW[FLAG_MAX+1]={'q','w','y','z','Z',0};
/* ################################
* get_next_wstr() [Internal]
*
* Get the next WSTR, when available
*
*/
static LPWSTR get_next_wstr(context_t * cx)
{
LPWSTR ptr;
ptr = cx->pNextCharW;
if (ptr && ptr[0]) {
cx->pNextCharW = NULL;
return ptr;
}
/* Get the next Parameter, when available */
if (cx->next_arg < cx->argc) {
ptr = cx->argv[cx->next_arg];
cx->next_arg++;
cx->pNextCharW = NULL;
return ptr;
}
return NULL;
}
/* ################################
* get_next_wchar() [Internal]
*
* Get the next WCHAR from the Commandline or from the File (@ Filename)
*
* ToDo: Support Parameter from a File ( "@Filename" )
*
*/
static WCHAR get_next_wchar(context_t * cx, BOOL use_next_parameter)
{
WCHAR c;
/* Try the next WCHAR in the actual Parameter */
if (cx->pNextCharW) {
c = *cx->pNextCharW;
if (c) {
cx->pNextCharW++;
return c;
}
/* We reached the end of the Parameter */
cx->pNextCharW = NULL;
}
/* Get the next Parameter, when available and allowed */
if ((cx->pNextCharW == NULL) && (cx->next_arg < cx->argc) && (use_next_parameter)) {
cx->pNextCharW = cx->argv[cx->next_arg];
cx->next_arg++;
}
if (cx->pNextCharW) {
c = *cx->pNextCharW;
if (c) {
cx->pNextCharW++;
}
else
{
/* We reached the end of the Parameter */
cx->pNextCharW = NULL;
}
return c;
}
return '\0';
}
/* ################################ */
static BOOL parse_rundll(context_t * cx)
{
LPWSTR ptr;
DWORD index;
WCHAR txtW[2];
WCHAR c;
c = get_next_wchar(cx, TRUE);
txtW[1] = '\0';
while (c)
{
while ( (c == ' ') || (c == '\t'))
{
c = get_next_wchar(cx, TRUE);
}
txtW[0] = c;
if (c == '@') {
/* read commands from a File */
ptr = get_next_wstr(cx);
FIXME("redir not supported: %s\n", debugstr_w(ptr));
return FALSE;
}
else if (c == '/') {
c = get_next_wchar(cx, FALSE);
while ( c )
{
txtW[0] = c;
ptr = wcschr(optionsW, c);
if (ptr) {
index = ptr - optionsW;
cx->options[index] = get_next_wstr(cx);
TRACE(" opt: %s %s\n", debugstr_w(txtW), debugstr_w(cx->options[index]));
c = 0;
}
else
{
ptr = wcschr(flagsW, c);
if (ptr) {
index = ptr - flagsW;
cx->flags[index] = TRUE;
TRACE("flag: %s\n", debugstr_w(txtW));
}
else
{
cx->command = c;
cx->subcommand = '\0';
TRACE(" cmd: %s\n", debugstr_w(txtW));
}
/* help has priority over all commands */
if (c == '?') {
return TRUE;
}
c = get_next_wchar(cx, FALSE);
/* Some commands use two wchar */
if ((cx->command == 'd') || (cx->command == 'g') || (cx->command == 'i') ||
(cx->command == 'S') || (cx->command == 'X') ){
cx->subcommand = c;
txtW[0] = c;
TRACE(" sub: %s\n", debugstr_w(txtW));
c = get_next_wchar(cx, FALSE);
}
}
}
c = get_next_wchar(cx, TRUE);
}
else
{
/* The commands 'S' and 'X' have additional Parameter */
if ((cx->command == 'S') || (cx->command == 'X')) {
/* the actual WCHAR is the start from the extra Parameter */
cx->pNextCharW--;
TRACE("%d extra Parameter, starting with %s\n", 1 + (cx->argc - cx->next_arg), debugstr_w(cx->pNextCharW));
return TRUE;
}
FIXME("0x%x: %s is unknown\n", c, debugstr_wn(&c, 1));
return FALSE;
}
}
return TRUE;
}
/*****************************************************
* DllMain
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("(%p, %d, %p)\n",hinstDLL, fdwReason, lpvReserved);
switch(fdwReason)
{
case DLL_WINE_PREATTACH:
return FALSE; /* prefer native version */
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls( hinstDLL );
break;
}
return TRUE;
}
/*****************************************************
* PrintUIEntryW [printui.@]
* Commandline-Interface for using printui.dll with rundll32.exe
*
*/
void WINAPI PrintUIEntryW(HWND hWnd, HINSTANCE hInst, LPCWSTR pCommand, DWORD nCmdShow)
{
context_t cx;
BOOL res = FALSE;
TRACE("(%p, %p, %s, 0x%x)\n", hWnd, hInst, debugstr_w(pCommand), nCmdShow);
memset(&cx, 0, sizeof(context_t));
cx.hWnd = hWnd;
cx.nCmdShow = nCmdShow;
if ((pCommand) && (pCommand[0])) {
/* result is allocated with GlobalAlloc() */
cx.argv = CommandLineToArgvW(pCommand, &cx.argc);
TRACE("got %d args at %p\n", cx.argc, cx.argv);
res = parse_rundll(&cx);
}
if (res && cx.command) {
switch (cx.command)
{
default:
{
WCHAR txtW[3];
txtW[0] = cx.command;
txtW[1] = cx.subcommand;
txtW[2] = '\0';
FIXME("command not implemented: %s\n", debugstr_w(txtW));
}
}
}
if ((res == FALSE) || (cx.command == '\0')) {
FIXME("dialog: Printer / The operation was not successful\n");
}
GlobalFree(cx.argv);
}

View file

@ -0,0 +1,34 @@
/*
* Top level resource file for printui.dll
*
* Copyright 2007 Detlef Riekenberg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#include "winver.h"
#define WINE_FILENAME_STR "printui.dll"
#define WINE_FILEDESCRIPTION_STR "User Interface for Printing"
/* Same Version as WinXP_sp2 */
#define WINE_FILEVERSION 5,1,2600,2180
#define WINE_FILEVERSION_STR "5.1.2600.2180"
#define WINE_PRODUCTVERSION 5,1,2600,2180
#define WINE_PRODUCTVERSION_STR "5.1.2600.2180"
#include "wine/wine_common_ver.rc"

View file

@ -0,0 +1,23 @@
@ stub ConnectToPrinterDlg
@ stub ConnectToPrinterPropertyPage
@ stub ConstructPrinterFriendlyName
@ stub -private DllCanUnloadNow
@ stub -private DllGetClassObject
@ stub DocumentPropertiesWrap
@ stub PnPInterface
@ stub PrintNotifyTray_Exit
@ stub PrintNotifyTray_Init
@ stdcall PrintUIEntryW(ptr ptr wstr long)
@ stub PrinterPropPageProvider
@ stub RegisterPrintNotify
@ stub ShowErrorMessageHR
@ stub ShowErrorMessageSC
@ stub UnregisterPrintNotify
@ stub bFolderEnumPrinters
@ stub bFolderGetPrinter
@ stub bFolderRefresh
@ stdcall -stub bPrinterSetup(ptr long long ptr ptr ptr)
@ stub vDocumentDefaults
@ stub vPrinterPropPages
@ stub vQueueCreate
@ stub vServerPropPages

View file

@ -0,0 +1,66 @@
/*
* Implementation of the Printer User Interface Dialogs: private Header
*
* Copyright 2007 Detlef Riekenberg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_PRINTUI_PRIVATE__
#define __WINE_PRINTUI_PRIVATE__
/* Index for Options with an argument */
/* Must be in order with optionsW */
typedef enum _OPT_INDEX {
OPT_A = 0,
OPT_B,
OPT_C,
OPT_F,
OPT_H,
OPT_J,
OPT_L,
OPT_M,
OPT_N,
OPT_R,
OPT_T,
OPT_V,
OPT_MAX
} OPT_INDEX;
/* Index for Flags without an argument */
/* Must be in order with flagsW */
typedef enum _FLAG_INDEX {
FLAG_Q = 0,
FLAG_W,
FLAG_Y,
FLAG_Z,
FLAG_ZZ,
FLAG_MAX
} FLAG_INDEX;
typedef struct tag_context {
HWND hWnd;
DWORD nCmdShow;
LPWSTR * argv;
LPWSTR pNextCharW;
int argc;
int next_arg;
WCHAR command;
WCHAR subcommand;
LPWSTR options[OPT_MAX];
BOOL flags[FLAG_MAX];
} context_t;
#endif