From 98bfe2fc89b1d3dc5a6e433a320e926f5fef4474 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 12 May 2020 20:26:02 -0500 Subject: [PATCH] [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. --- dll/win32/CMakeLists.txt | 1 - win32ss/printing/base/CMakeLists.txt | 2 + win32ss/printing/base/ntprint/CMakeLists.txt | 15 ++ win32ss/printing/base/ntprint/ntprint.c | 156 ++++++++++++++++++ win32ss/printing/base/ntprint/ntprint.rc | 34 ++++ win32ss/printing/base/ntprint/ntprint.spec | 35 ++++ win32ss/printing/base/printui/.keep | 0 .../printing/base}/printui/CMakeLists.txt | 0 .../printing/base}/printui/printui.c | 0 .../printing/base}/printui/printui.rc | 0 .../printing/base}/printui/printui.spec | 0 .../printing/base}/printui/printui_private.h | 0 12 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 win32ss/printing/base/ntprint/CMakeLists.txt create mode 100644 win32ss/printing/base/ntprint/ntprint.c create mode 100644 win32ss/printing/base/ntprint/ntprint.rc create mode 100644 win32ss/printing/base/ntprint/ntprint.spec delete mode 100644 win32ss/printing/base/printui/.keep rename {dll/win32 => win32ss/printing/base}/printui/CMakeLists.txt (100%) rename {dll/win32 => win32ss/printing/base}/printui/printui.c (100%) rename {dll/win32 => win32ss/printing/base}/printui/printui.rc (100%) rename {dll/win32 => win32ss/printing/base}/printui/printui.spec (100%) rename {dll/win32 => win32ss/printing/base}/printui/printui_private.h (100%) diff --git a/dll/win32/CMakeLists.txt b/dll/win32/CMakeLists.txt index e69b50bc877..476aaec6fcb 100644 --- a/dll/win32/CMakeLists.txt +++ b/dll/win32/CMakeLists.txt @@ -157,7 +157,6 @@ add_subdirectory(olethk32) add_subdirectory(pdh) add_subdirectory(pidgen) add_subdirectory(powrprof) -add_subdirectory(printui) add_subdirectory(profmap) add_subdirectory(propsys) add_subdirectory(psapi) diff --git a/win32ss/printing/base/CMakeLists.txt b/win32ss/printing/base/CMakeLists.txt index 25ae88295bc..3101315cff1 100644 --- a/win32ss/printing/base/CMakeLists.txt +++ b/win32ss/printing/base/CMakeLists.txt @@ -1,4 +1,6 @@ #add_subdirectory(printui) +add_subdirectory(ntprint) +add_subdirectory(printui) add_subdirectory(spoolss) add_subdirectory(spoolsv) add_subdirectory(winspool) diff --git a/win32ss/printing/base/ntprint/CMakeLists.txt b/win32ss/printing/base/ntprint/CMakeLists.txt new file mode 100644 index 00000000000..f468021ff70 --- /dev/null +++ b/win32ss/printing/base/ntprint/CMakeLists.txt @@ -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) diff --git a/win32ss/printing/base/ntprint/ntprint.c b/win32ss/printing/base/ntprint/ntprint.c new file mode 100644 index 00000000000..100385725c8 --- /dev/null +++ b/win32ss/printing/base/ntprint/ntprint.c @@ -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 + +#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; +} diff --git a/win32ss/printing/base/ntprint/ntprint.rc b/win32ss/printing/base/ntprint/ntprint.rc new file mode 100644 index 00000000000..272f15159e6 --- /dev/null +++ b/win32ss/printing/base/ntprint/ntprint.rc @@ -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" diff --git a/win32ss/printing/base/ntprint/ntprint.spec b/win32ss/printing/base/ntprint/ntprint.spec new file mode 100644 index 00000000000..04e85fe72fc --- /dev/null +++ b/win32ss/printing/base/ntprint/ntprint.spec @@ -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 diff --git a/win32ss/printing/base/printui/.keep b/win32ss/printing/base/printui/.keep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/dll/win32/printui/CMakeLists.txt b/win32ss/printing/base/printui/CMakeLists.txt similarity index 100% rename from dll/win32/printui/CMakeLists.txt rename to win32ss/printing/base/printui/CMakeLists.txt diff --git a/dll/win32/printui/printui.c b/win32ss/printing/base/printui/printui.c similarity index 100% rename from dll/win32/printui/printui.c rename to win32ss/printing/base/printui/printui.c diff --git a/dll/win32/printui/printui.rc b/win32ss/printing/base/printui/printui.rc similarity index 100% rename from dll/win32/printui/printui.rc rename to win32ss/printing/base/printui/printui.rc diff --git a/dll/win32/printui/printui.spec b/win32ss/printing/base/printui/printui.spec similarity index 100% rename from dll/win32/printui/printui.spec rename to win32ss/printing/base/printui/printui.spec diff --git a/dll/win32/printui/printui_private.h b/win32ss/printing/base/printui/printui_private.h similarity index 100% rename from dll/win32/printui/printui_private.h rename to win32ss/printing/base/printui/printui_private.h