1 /* 2 * Copyright 2001-2008, Haiku. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Philippe Houdoin 7 * Simon Gauvin 8 * Michael Pfeiffer 9 */ 10 11 #include <stdio.h> 12 #include <string.h> 13 14 15 #include <StorageKit.h> 16 #include <String.h> 17 18 19 #include "Driver.h" 20 #include "PrinterDriver.h" 21 22 23 BMessage* 24 take_job(BFile *spoolFile, BNode *spoolDir, BMessage *msg) 25 { 26 PrinterDriver *driver = instanciate_driver(spoolDir); 27 status_t status = driver->PrintJob(spoolFile, msg); 28 delete driver; 29 30 msg = new BMessage('okok'); 31 if (status != B_OK) 32 msg->what = 'baad'; 33 34 return msg; 35 } 36 37 38 BMessage* 39 config_page(BNode *spoolDir, BMessage *msg) 40 { 41 BString printerName; 42 spoolDir->ReadAttrString("Printer Name", &printerName); 43 44 BMessage *pagesetupMsg = new BMessage(*msg); 45 pagesetupMsg->what = 'okok'; 46 47 PrinterDriver *driver = instanciate_driver(spoolDir); 48 if (driver->PageSetup(pagesetupMsg, printerName.String()) != B_OK) { 49 delete pagesetupMsg; 50 pagesetupMsg = NULL; 51 } 52 delete driver; 53 return pagesetupMsg; 54 } 55 56 57 BMessage* 58 config_job(BNode *spoolDir, BMessage *msg) 59 { 60 BString printerName; 61 spoolDir->ReadAttrString("Printer Name", &printerName); 62 63 BMessage *jobsetupMsg = new BMessage(*msg); 64 jobsetupMsg->what = 'okok'; 65 66 PrinterDriver *driver = instanciate_driver(spoolDir); 67 if (driver->JobSetup(jobsetupMsg, printerName.String()) != B_OK) { 68 delete jobsetupMsg; 69 jobsetupMsg = NULL; 70 } 71 delete driver; 72 return jobsetupMsg; 73 } 74 75 76 char* 77 add_printer(char *printerName) 78 { 79 return printerName; 80 } 81 82 83 BMessage* 84 default_settings(BNode* spoolDir) 85 { 86 PrinterDriver *driver = instanciate_driver(spoolDir); 87 BMessage *settings = driver->GetDefaultSettings(); 88 delete driver; 89 return settings; 90 } 91