vfs: check userland buffers before reading them.
[haiku.git] / headers / os / interface / PrintJob.h
blob324f101dfa026c8771215b0a17f89b949224ef04
1 /*
2 * Copyright 2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _PRINTSESSION_H
6 #define _PRINTSESSION_H
9 #include <Picture.h>
12 class BFile;
13 class BView;
15 struct print_file_header {
16 int32 version;
17 int32 page_count;
18 off_t first_page;
20 int32 _reserved[3];
21 } _PACKED;
23 struct _page_header_;
26 class BPrintJob {
27 public:
28 // Values returned by PrinterType()
29 enum {
30 B_BW_PRINTER = 0,
31 B_COLOR_PRINTER
35 BPrintJob(const char* name);
36 virtual ~BPrintJob();
38 void BeginJob();
39 void CommitJob();
40 status_t ConfigJob();
41 void CancelJob();
43 status_t ConfigPage();
44 void SpoolPage();
46 bool CanContinue();
48 virtual void DrawView(BView* view, BRect rect,
49 BPoint where);
51 BMessage* Settings(); // TODO: const
52 void SetSettings(BMessage* archive);
53 bool IsSettingsMessageValid(
54 BMessage* archive) const;
56 BRect PaperRect();
57 BRect PrintableRect();
58 void GetResolution(int32* xDPI, int32* yDPI);
60 int32 FirstPage(); // TODO: const
61 int32 LastPage(); // TODO: const
62 int32 PrinterType(void* type = NULL) const;
65 private:
66 // FBC padding and forbidden methods
67 virtual void _ReservedPrintJob1();
68 virtual void _ReservedPrintJob2();
69 virtual void _ReservedPrintJob3();
70 virtual void _ReservedPrintJob4();
72 BPrintJob(const BPrintJob& other);
73 BPrintJob& operator=(const BPrintJob& other);
75 private:
76 void _RecurseView(BView* view, BPoint origin,
77 BPicture* picture, BRect rect);
78 void _GetMangledName(char* buffer,
79 size_t bufferSize) const;
80 void _HandlePageSetup(BMessage* setup);
81 bool _HandlePrintSetup(BMessage* setup);
83 void _NewPage();
84 void _EndLastPage();
86 void _AddSetupSpec();
87 void _AddPicture(BPicture& picture, BRect& rect,
88 BPoint& where);
90 char* _GetCurrentPrinterName() const;
91 void _LoadDefaultSettings();
93 private:
94 char* fPrintJobName;
96 int32 _unused;
98 BFile* fSpoolFile;
99 print_file_header fSpoolFileHeader;
100 BRect fPaperSize;
101 BRect fUsableSize;
102 status_t fError;
103 char fSpoolFileName[256];
104 BMessage* fSetupMessage;
105 BMessage* fDefaultSetupMessage;
106 char fAbort;
107 int32 fFirstPage;
108 int32 fLastPage;
109 short fXResolution;
110 short fYResolution;
111 _page_header_* fCurrentPageHeader;
112 off_t fCurrentPageHeaderOffset;
114 uint32 _reserved[2];
117 #endif // _PRINTSESSION_H