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