2 * Copyright 2001-2010, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
15 #include "ResourceManager.h"
19 #include <Directory.h>
26 // OpenTracker shared sources
27 #include "ObjectList.h"
30 class SpoolFolder
: public Folder
{
32 void Notify(Job
* job
, int kind
);
35 SpoolFolder(BLocker
* locker
, BLooper
* looper
, const BDirectory
& spoolDir
);
39 /*****************************************************************************/
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
;
49 Printer(const BDirectory
* node
, Resource
* res
);
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();
65 static status_t
FindPathToDriver(const char* driver
,
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
; }
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();
104 // the printer spooling directory
105 SpoolFolder fPrinter
;
106 // the resource required for processing a print job
108 // is printer add-on allowed to process multiple print job at once
109 bool fSinglePrintThread
;
110 // the next job to process
112 // the current nmber of processing threads
116 static BObjectList
<Printer
> sPrinters
;