Make UEFI boot-platform build again
[haiku.git] / src / servers / print / Printer.h
blobc15b67683790ed8ac2b44399e479990212b1d7ce
1 /*
2 * Copyright 2001-2010, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Ithamar R. Adema
7 * Michael Pfeiffer
8 */
9 #ifndef PRINTER_H
10 #define PRINTER_H
12 class Printer;
14 #include "BeUtils.h"
15 #include "ResourceManager.h"
16 #include "Jobs.h"
18 // BeOS API
19 #include <Directory.h>
20 #include <Handler.h>
21 #include <image.h>
22 #include <Locker.h>
23 #include <PrintJob.h>
24 #include <String.h>
26 // OpenTracker shared sources
27 #include "ObjectList.h"
30 class SpoolFolder : public Folder {
31 protected:
32 void Notify(Job* job, int kind);
34 public:
35 SpoolFolder(BLocker* locker, BLooper* looper, const BDirectory& spoolDir);
39 /*****************************************************************************/
40 // Printer
42 // This class represents one printer definition. It is manages all actions &
43 // data related to that printer.
44 /*****************************************************************************/
45 class Printer : public BHandler, public Object
47 typedef BHandler Inherited;
48 public:
49 Printer(const BDirectory* node, Resource* res);
50 virtual ~Printer();
52 virtual void MessageReceived(BMessage* message);
53 virtual status_t GetSupportedSuites(BMessage* msg);
54 virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index,
55 BMessage* spec, int32 form, const char* prop);
57 // Static helper functions
58 static Printer* Find(const BString& name);
59 static Printer* Find(node_ref* node);
60 static Printer* At(int32 idx);
61 static void Remove(Printer* printer);
62 static int32 CountPrinters();
64 status_t Remove();
65 static status_t FindPathToDriver(const char* driver,
66 BPath* path);
67 static status_t ConfigurePrinter(const char* driverName,
68 const char* printerName);
69 status_t ConfigureJob(BMessage& ioSettings);
70 status_t ConfigurePage(BMessage& ioSettings);
71 status_t GetDefaultSettings(BMessage& configuration);
73 // Try to start processing of next spooled job
74 void HandleSpooledJob();
76 // Abort print_thread without processing spooled job
77 void AbortPrintThread();
79 // Scripting support, see Printer.Scripting.cpp
80 void HandleScriptingCommand(BMessage* msg);
82 void GetName(BString& name);
83 Resource* GetResource() { return fResource; }
85 private:
86 status_t GetDriverName(BString* name);
87 void AddCurrentPrinter(BMessage& message);
89 BDirectory* SpoolDir() { return fPrinter.GetSpoolDir(); }
91 void ResetJobStatus();
92 bool HasCurrentPrinter(BString& name);
93 bool MoveJob(const BString& name);
95 // Get next spooled job if any
96 bool FindSpooledJob();
97 status_t PrintSpooledJob(const char* spoolFile);
98 void PrintThread(Job* job);
100 static status_t print_thread(void* data);
101 void StartPrintThread();
103 private:
104 // the printer spooling directory
105 SpoolFolder fPrinter;
106 // the resource required for processing a print job
107 Resource* fResource;
108 // is printer add-on allowed to process multiple print job at once
109 bool fSinglePrintThread;
110 // the next job to process
111 Job* fJob;
112 // the current nmber of processing threads
113 int32 fProcessing;
114 // stop processing
115 bool fAbort;
116 static BObjectList<Printer> sPrinters;
119 #endif