vfs: check userland buffers before reading them.
[haiku.git] / src / servers / print / Settings.h
blob2ba6752aece4901e01e68548ec2ab6038687f460
1 /*
2 * Copyright 2002-2006, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Michael Pfeiffer
7 */
8 #ifndef _SETTINGS_H
9 #define _SETTINGS_H
11 #include "BeUtils.h"
12 #include "ObjectList.h"
14 #include <String.h>
16 class AppSettings {
17 private:
18 BString fMimeType; // application signature
19 BString fPrinter; // printer used by application (default == empty string)
21 public:
22 AppSettings(const char* mimeType, const char* printer = NULL);
24 const char* GetMimeType() const { return fMimeType.String(); }
25 bool UsesDefaultPrinter() const { return fMimeType.Length() == 0; }
26 const char* GetPrinter() const { return fPrinter.String(); }
27 void SetPrinter(const char* printer) { fPrinter = printer; }
28 void SetDefaultPrinter() { fPrinter = ""; }
32 class PrinterSettings {
33 private:
34 BString fPrinter;
35 BMessage fPageSettings; // default page settings
36 BMessage fJobSettings; // default job settings
38 public:
39 PrinterSettings(const char* printer, BMessage* pageSettings = NULL, BMessage* jobSettings = NULL);
41 const char* GetPrinter() const { return fPrinter.String(); }
42 BMessage* GetPageSettings() { return &fPageSettings; }
43 BMessage* GetJobSettings() { return &fJobSettings; }
45 void SetPrinter(const char* p) { fPrinter = p; }
46 void SetPageSettings(BMessage* s) { fPageSettings = *s; }
47 void SetJobSettings(BMessage* s) { fJobSettings = *s; }
50 class Settings {
51 private:
52 BObjectList<AppSettings> fApps;
53 BObjectList<PrinterSettings> fPrinters;
54 bool fUseConfigWindow;
55 BRect fConfigWindowFrame;
56 BString fDefaultPrinter;
58 static Settings* sSingleton;
59 Settings();
61 public:
62 static Settings* GetSettings();
63 ~Settings();
65 int AppSettingsCount() const { return fApps.CountItems(); }
66 AppSettings* AppSettingsAt(int i) { return fApps.ItemAt(i); }
67 void AddAppSettings(AppSettings* s) { fApps.AddItem(s); }
68 void RemoveAppSettings(int i);
69 AppSettings* FindAppSettings(const char* mimeType);
71 int PrinterSettingsCount() const { return fPrinters.CountItems(); }
72 PrinterSettings* PrinterSettingsAt(int i) { return fPrinters.ItemAt(i); }
73 void AddPrinterSettings(PrinterSettings* s) { fPrinters.AddItem(s); }
74 void RemovePrinterSettings(int i);
75 PrinterSettings* FindPrinterSettings(const char* printer);
77 bool UseConfigWindow() const { return fUseConfigWindow; }
78 void SetUseConfigWindow(bool b) { fUseConfigWindow = b; }
79 BRect ConfigWindowFrame() const { return fConfigWindowFrame; }
80 void SetConfigWindowFrame(BRect r) { fConfigWindowFrame = r; }
81 const char* DefaultPrinter() const { return fDefaultPrinter.String(); }
82 void SetDefaultPrinter(const char* n) { fDefaultPrinter = n; }
84 void Save(BFile* settings_file);
85 void Load(BFile* settings_file);
88 #endif