xref: /haiku/src/servers/print/PrintServerApp.h (revision 3cb015b1ee509d69c643506e8ff573808c86dcfc)
1 /*
2  * Copyright 2001-2006, Haiku. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Ithamar R. Adema
7  *		Michael Pfeiffer
8  */
9 #ifndef PRINTSERVERAPP_H
10 #define PRINTSERVERAPP_H
11 
12 #include "ResourceManager.h"
13 #include "Settings.h"
14 #include "FolderWatcher.h"
15 
16 class PrintServerApp;
17 
18 #include <Application.h>
19 #include <Bitmap.h>
20 #include <OS.h>
21 #include <String.h>
22 
23 // global BLocker for synchronisation
24 extern BLocker* gLock;
25 
26 /*****************************************************************************/
27 // PrintServerApp
28 //
29 // Application class for print_server.
30 /*****************************************************************************/
31 class Printer;
32 class PrintServerApp : public BApplication, public FolderListener
33 {
34 	typedef BApplication Inherited;
35 public:
36 	PrintServerApp(status_t* err);
37 	~PrintServerApp();
38 
39 	void Acquire();
40 	void Release();
41 
42 	bool QuitRequested();
43 	void MessageReceived(BMessage* msg);
44 	void NotifyPrinterDeletion(Printer* printer);
45 
46 		// Scripting support, see PrintServerApp.Scripting.cpp
47 	status_t GetSupportedSuites(BMessage* msg);
48 	void HandleScriptingCommand(BMessage* msg);
49 	Printer* GetPrinterFromSpecifier(BMessage* msg);
50 	BHandler* ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec,
51 								int32 form, const char* prop);
52 private:
53 	bool OpenSettings(BFile& file, const char* name, bool forReading);
54 	void LoadSettings();
55 	void SaveSettings();
56 
57 	status_t SetupPrinterList();
58 
59 	void     HandleSpooledJobs();
60 
61 	status_t SelectPrinter(const char* printerName);
62 	status_t CreatePrinter(	const char* printerName, const char* driverName,
63 							const char* connection, const char* transportName,
64 							const char* transportPath);
65 
66 	void     RegisterPrinter(BDirectory* node);
67 	void     UnregisterPrinter(Printer* printer);
68 	// FolderListener
69 	void     EntryCreated(node_ref* node, entry_ref* entry);
70 	void     EntryRemoved(node_ref* node);
71 	void     AttributeChanged(node_ref* node);
72 
73 	status_t StoreDefaultPrinter();
74 	status_t RetrieveDefaultPrinter();
75 
76 	status_t FindPrinterNode(const char* name, BNode& node);
77 	status_t FindPrinterDriver(const char* name, BPath& outPath);
78 
79 	ResourceManager fResourceManager;
80 	Printer* fDefaultPrinter;
81 	BBitmap* fSelectedIconMini;
82 	BBitmap* fSelectedIconLarge;
83 	vint32   fReferences;
84 	sem_id   fHasReferences;
85 	Settings*fSettings;
86 	bool     fUseConfigWindow;
87 	FolderWatcher* fFolder;
88 
89 		// "Classic" BeOS R5 support, see PrintServerApp.R5.cpp
90 	static status_t async_thread(void* data);
91 	void AsyncHandleMessage(BMessage* msg);
92 	void Handle_BeOSR5_Message(BMessage* msg);
93 
94 };
95 
96 #endif
97