Hello Mr.Timoshkov,

Thank you for your reply.
Loïc Maury<lma...@gmail.com>  wrote:

After the various comments, I have modified the patch.
First of all set your tab size to 8, and ask your editor to not use tabs
at all.
I have modified my editor, but I don't know if it 's correct now ?
+       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));
TRACE() with the API parameters usually is the very first statement in
the API implementation, comma should be placed at the end of the statement,
not before.
Ok, I have remplaced this TRACE().
+                               GetPrinterW(hPrinter, 2, NULL, 0,&needed);
+                               pi2 = HeapAlloc(GetProcessHeap(), 0, needed);
+                               GetPrinterW(hPrinter, 2, (LPBYTE)pi2, 
needed,&needed);
You need to check the return value of GetPrinterW() and handle the errors.
Ok
+       if(pi2)
+               HeapFree(GetProcessHeap(), 0, pi2);
NULL check before HeapFree() is not needed.
Ok, I have removed the NULL check.
+ TRACE("return %d\n", ret);
This trace is redundant.
Ok, I have removed this TRACE().

I have make an other patch.

Thank you

Loïc

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

diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index e4a464a..d4210ad 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -5962,8 +5962,109 @@ 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;
+    BOOL retFromGetPrinter = FALSE;
+    opened_printer_t *printer;
+    struct list *cursor, *cursor2;
+    job_t *job;
+    DWORD jobDocId;
+    DWORD needed;
+    LPWSTR portname;
+    
+    TRACE("(%p)\n", hPrinter);
+    
+    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;
+    }
+    
+    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);
+                
+                if(GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+                    goto end;
+                
+                pi2 = HeapAlloc(GetProcessHeap(), 0, needed);
+                
+                retFromGetPrinter = GetPrinterW(hPrinter, 2, (LPBYTE)pi2, 
needed, &needed);
+                if(!retFromGetPrinter)
+                    goto end;
+                
+                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: 
+    
+    HeapFree(GetProcessHeap(), 0, pi2);
+    
+    LeaveCriticalSection(&printer_handles_cs);
+    
+    return ret;
+    
 }
 
 /******************************************************************************
-- 
1.7.3.2



Reply via email to