Hello,

After the various comments, I have modified the patch.

What do you think ?

Thank You

Loïc

---
 dlls/winspool.drv/info.c |   97 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 95 insertions(+), 2 deletions(-)

diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index e4a464a..37eafee 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -5962,8 +5962,101 @@ DWORD WINAPI EnumPrinterDataExA(HANDLE hPrinter, LPCSTR 
pKeyName,
  */
 BOOL WINAPI AbortPrinter( HANDLE hPrinter )
 {
-    FIXME("(%p), stub!\n", hPrinter);
-    return TRUE;
+       PRINTER_INFO_2W *pi2 = NULL;
+       BOOL ret = FALSE;
+       opened_printer_t *printer;
+       struct list *cursor, *cursor2;
+       job_t *job;
+       DWORD jobDocId;
+       DWORD needed;
+       LPWSTR portname;
+       
+       EnterCriticalSection(&printer_handles_cs);
+       
+       printer = get_opened_printer(hPrinter);
+       
+       if(!printer) {
+               ERR("The handle for the printer is invalid.\n");
+               SetLastError(ERROR_INVALID_HANDLE);
+               goto end;
+       }
+       
+       TRACE("(%s, %s, %p, %d, %d)\n",debugstr_w(printer->name)
+                 ,debugstr_w(printer->printername)
+                 ,printer->backend_printer
+                 ,printer->queue->ref
+                 ,list_count(&printer->queue->jobs));
+       
+       if(printer->doc) {
+               TRACE("Document inside for job id : %d\n", 
printer->doc->job_id);
+               jobDocId = printer->doc->job_id;
+       }
+       else {
+               ERR("No document.\n");
+               SetLastError(ERROR_SPL_NO_STARTDOC);
+               goto end;
+       }
+       
+       /* For each jobs, see if we have a job document in the double linked 
list */
+       LIST_FOR_EACH_SAFE(cursor, cursor2, &printer->queue->jobs)
+       {
+               /* Take a job. */
+               job = LIST_ENTRY(cursor, job_t, entry);
+               
+               TRACE("(job id : %d, filename : %s, portname : %s, document 
title : %s, printer name %s)\n"
+                         ,job->job_id
+                         ,debugstr_w(job->filename)
+                         ,debugstr_w(job->portname)
+                         ,debugstr_w(job->document_title)
+                         ,debugstr_w(job->printer_name));
+               
+               if(jobDocId == job->job_id) {
+                       TRACE("(hf : %p, job id : %d)\n",printer->doc->hf
+                                 ,printer->doc->job_id);
+                       
+                       /* Get portname. */
+                       if (!job->portname) {
+                               GetPrinterW(hPrinter, 2, NULL, 0, &needed);
+                               pi2 = HeapAlloc(GetProcessHeap(), 0, needed);
+                               GetPrinterW(hPrinter, 2, (LPBYTE)pi2, needed, 
&needed);
+                               portname = pi2->pPortName;
+                       }
+                       
+                       TRACE("portname : %s\n", debugstr_w(portname));
+                       
+                       /* Cups Port */
+                       if(!strncmpW(portname, CUPS_Port, strlenW(CUPS_Port))) {
+                               TRACE("Remove job from the list.\n");
+                               list_remove(cursor);
+                               CloseHandle(printer->doc->hf);
+                               DeleteFileW(job->filename);
+                               HeapFree(GetProcessHeap(), 0, 
job->document_title);
+                               HeapFree(GetProcessHeap(), 0, 
job->printer_name);
+                               HeapFree(GetProcessHeap(), 0, job->portname);
+                               HeapFree(GetProcessHeap(), 0, job->filename);
+                               HeapFree(GetProcessHeap(), 0, job->devmode);
+                               HeapFree(GetProcessHeap(), 0, job);
+                               
+                               /* The document for the printer is not useful 
anymore. */
+                               TRACE("Remove document for the printer : 
%s.\n", debugstr_w(printer->printername));
+                               HeapFree(GetProcessHeap(), 0, printer->doc);
+                               printer->doc = 0;
+                               
+                               ret = TRUE;
+                       }
+                       else
+                               FIXME("AbortPrinter() manage only CUPS for 
now.\n");
+               }
+       }       
+       
+end: 
+       if(pi2)
+               HeapFree(GetProcessHeap(), 0, pi2);
+       
+       LeaveCriticalSection(&printer_handles_cs);
+       
+       TRACE("return %d\n", ret);
+       return ret;
 }
 
 /******************************************************************************
-- 
1.7.3.2



Reply via email to