[Printing] Update and Add Functions
[reactos.git] / win32ss / printing / providers / localspl / printers.c
index a278372..e63af1a 100644 (file)
@@ -346,6 +346,24 @@ Cleanup:
     return (dwErrorCode == ERROR_SUCCESS);
 }
 
+VOID
+BroadcastChange(PLOCAL_HANDLE pHandle)
+{
+    PLOCAL_PRINTER pPrinter;
+    PSKIPLIST_NODE pNode;
+    DWORD cchMachineName = 0;
+    WCHAR wszMachineName[MAX_PATH] = {0}; // if not local, use Machine Name then Printer Name... pPrinter->pJob->pwszMachineName?
+
+    for (pNode = PrinterList.Head.Next[0]; pNode; pNode = pNode->Next[0])
+    {
+        pPrinter = (PLOCAL_PRINTER)pNode->Element;
+
+        StringCchCopyW( &wszMachineName[cchMachineName], sizeof(wszMachineName), pPrinter->pwszPrinterName );
+
+        PostMessageW( HWND_BROADCAST, WM_DEVMODECHANGE, 0, (LPARAM)&wszMachineName );
+    }
+}
+
 /**
  * @name _LocalEnumPrintersCheckName
  *
@@ -607,7 +625,7 @@ _LocalGetPrinterLevel2(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_2W* ppPrinterInfo,
     size_t cbParameters;
     PWSTR p, Allocation;
     PCWSTR pwszStrings[10];
-
+    FIXME("LocalGetPrinterLevel2\n");
     // Calculate the string lengths.
     cbDevMode = pPrinter->pDefaultDevMode->dmSize + pPrinter->pDefaultDevMode->dmDriverExtra;
     cbPrinterName = (cchComputerName + wcslen(pPrinter->pwszPrinterName) + 1) * sizeof(WCHAR);
@@ -626,6 +644,7 @@ _LocalGetPrinterLevel2(PLOCAL_PRINTER pPrinter, PPRINTER_INFO_2W* ppPrinterInfo,
         cbParameters = sizeof(wszEmpty);
 
         *pcbNeeded += sizeof(PRINTER_INFO_2W) + cbDevMode + cbPrinterName + cbShareName + cbPortName + cbDriverName + cbComment + cbLocation + cbSepFile + cbPrintProcessor + cbDatatype + cbParameters;
+        FIXME("LocalGetPrinterLevel2 Needed %d\n",*pcbNeeded);
         return;
     }
 
@@ -871,7 +890,7 @@ LocalEnumPrinters(DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DW
     WCHAR wszComputerName[2 + MAX_COMPUTERNAME_LENGTH + 1 + 1] = { 0 };
     PLOCAL_PRINTER pPrinter;
 
-    TRACE("LocalEnumPrinters(%lu, %S, %lu, %p, %lu, %p, %p)\n", Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
+    FIXME("LocalEnumPrinters(%lu, %S, %lu, %p, %lu, %p, %p)\n", Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
 
     // Do no sanity checks or assertions for pcbNeeded and pcReturned here.
     // This is verified and required by localspl_apitest!
@@ -1283,6 +1302,7 @@ _LocalOpenXcvHandle(PWSTR pwszParameter, PHANDLE phPrinter)
         {
             // The caller supplied a non-existing Monitor name.
             dwErrorCode = ERROR_INVALID_NAME;
+            ERR("OpenXcvHandle failed on Monitor name! %lu\n", dwErrorCode);
             goto Failure;
         }
     }
@@ -1297,6 +1317,7 @@ _LocalOpenXcvHandle(PWSTR pwszParameter, PHANDLE phPrinter)
         {
             // The supplied port is unknown to all our Print Monitors.
             dwErrorCode = ERROR_INVALID_NAME;
+            ERR("OpenXcvHandle failed on Port name! %lu\n", dwErrorCode);
             goto Failure;
         }
 
@@ -1305,6 +1326,7 @@ _LocalOpenXcvHandle(PWSTR pwszParameter, PHANDLE phPrinter)
     else
     {
         dwErrorCode = ERROR_INVALID_NAME;
+        ERR("OpenXcvHandle failed on bad name! %lu\n", dwErrorCode);
         goto Failure;
     }
 
@@ -1318,6 +1340,7 @@ _LocalOpenXcvHandle(PWSTR pwszParameter, PHANDLE phPrinter)
     {
         // The XcvOpenPort function failed. Return its last error.
         dwErrorCode = GetLastError();
+        ERR("XcvOpenPort function failed! %lu\n", dwErrorCode);
         goto Failure;
     }
 
@@ -1348,6 +1371,7 @@ _LocalOpenXcvHandle(PWSTR pwszParameter, PHANDLE phPrinter)
 
     // Return it.
     *phPrinter = (HANDLE)pHandle;
+    ERR("OpenXcvHandle Success! %p\n", pXcvHandle);
     return ERROR_SUCCESS;
 
 Failure:
@@ -1360,6 +1384,16 @@ Failure:
     return dwErrorCode;
 }
 
+//
+// Dead API
+//
+DWORD WINAPI
+LocalPrinterMessageBox(HANDLE hPrinter, DWORD Error, HWND hWnd, LPWSTR pText, LPWSTR pCaption, DWORD dwType)
+{
+    SetLastError(ERROR_INVALID_HANDLE); // Yes....
+    return 0;
+}
+
 BOOL WINAPI
 LocalOpenPrinter(PWSTR lpPrinterName, HANDLE* phPrinter, PPRINTER_DEFAULTSW pDefault)
 {
@@ -1475,6 +1509,7 @@ LocalOpenPrinter(PWSTR lpPrinterName, HANDLE* phPrinter, PPRINTER_DEFAULTSW pDef
         //    "\\COMPUTERNAME\, XcvMonitor Local Port"
         //    ", XcvPort LPT1:"
         //    "\\COMPUTERNAME\, XcvPort LPT1:"
+        FIXME("OpenXcvHandle : %S\n",pwszSecondParameter);
         dwErrorCode = _LocalOpenXcvHandle(pwszSecondParameter, phPrinter);
     }
     else
@@ -1890,6 +1925,7 @@ Cleanup:
 static void
 _LocalClosePortHandle(PLOCAL_PORT_HANDLE pPortHandle)
 {
+    FIXME("LocalClosePortHandle\n");
     // Call the monitor's ClosePort function.
     if (pPortHandle->pPort->pPrintMonitor->bIsLevel2)
         ((PMONITOR2)pPortHandle->pPort->pPrintMonitor->pMonitor)->pfnClosePort(pPortHandle->hPort);
@@ -1900,6 +1936,7 @@ _LocalClosePortHandle(PLOCAL_PORT_HANDLE pPortHandle)
 static void
 _LocalClosePrinterHandle(PLOCAL_PRINTER_HANDLE pPrinterHandle)
 {
+    FIXME("LocalClosePrinterHandle\n");
     // Terminate any started job.
     if (pPrinterHandle->pJob)
         FreeJob(pPrinterHandle->pJob);
@@ -1924,7 +1961,7 @@ LocalClosePrinter(HANDLE hPrinter)
 {
     PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
 
-    TRACE("LocalClosePrinter(%p)\n", hPrinter);
+    FIXME("LocalClosePrinter(%p)\n", hPrinter);
 
     if (!pHandle)
     {
@@ -1948,12 +1985,12 @@ LocalClosePrinter(HANDLE hPrinter)
     {
         _LocalCloseXcvHandle(pHandle->pSpecificHandle);
     }
-
+    FIXME("LocalClosePrinter 1\n");
     // Free memory for the handle and the specific handle (if any).
     if (pHandle->pSpecificHandle)
         DllFreeSplMem(pHandle->pSpecificHandle);
-
+    FIXME("LocalClosePrinter 2\n");
     DllFreeSplMem(pHandle);
-
+    FIXME("LocalClosePrinter 3\n");
     return TRUE;
 }