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