From 620f852c78e3c4dbb537c0bee32afc8d814d1d1a Mon Sep 17 00:00:00 2001 From: Michael Pfeiffer Date: Sun, 29 Jul 2007 09:03:25 +0000 Subject: [PATCH] Search printer spool folder by name stored in attribute 'Printer Name'. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21738 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/print/Printer.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/servers/print/Printer.cpp b/src/servers/print/Printer.cpp index 6591e91a1a..dc9736724e 100644 --- a/src/servers/print/Printer.cpp +++ b/src/servers/print/Printer.cpp @@ -463,20 +463,33 @@ bool Printer::HasCurrentPrinter(BString& name) { // Try to move job to another printer folder. // // Parameters: -// name - the printer folder name. +// name - the printer name. // // Returns: // true if successful. // --------------------------------------------------------------- bool Printer::MoveJob(const BString& name) { - BPath file(&fJob->EntryRef()); BPath path; - file.GetParent(&path); - path.Append(".."); path.Append(name.String()); - BDirectory dir(path.Path()); - BEntry entry(&fJob->EntryRef()); - // try to move job file to proper directory - return entry.MoveTo(&dir) == B_OK; + if (::find_directory(B_USER_PRINTERS_DIRECTORY, &path) != B_OK) + return false; + + // search printer folder with given name + BDirectory printersFolder(path.Path()); + BEntry printerEntry; + while (printersFolder.GetNextEntry(&printerEntry) == B_OK) { + BNode printerNode(&printerEntry); + BString printerName; + if (printerNode.ReadAttrString(PSRV_PRINTER_ATTR_PRT_NAME, &printerName) != B_OK) + continue; + if (name != printerName) + continue; + + BEntry jobEntry(&fJob->EntryRef()); + BDirectory printerDirectory(&printerEntry); + return jobEntry.MoveTo(&printerDirectory) == B_OK; + // try to move job file to proper directory + } + return false; } // ---------------------------------------------------------------