vfs: check userland buffers before reading them.
[haiku.git] / src / apps / mail / MailWindow.h
blobfc3ca0e13a28e68c215eb8a7b2f2f8412980b765
1 /*
2 Open Tracker License
4 Terms and Conditions
6 Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
32 All rights reserved.
34 #ifndef _MAIL_WINDOW_H
35 #define _MAIL_WINDOW_H
38 #include <Entry.h>
39 #include <Font.h>
40 #include <Locker.h>
41 #include <Messenger.h>
42 #include <ObjectList.h>
43 #include <Window.h>
45 #include <ToolBar.h>
47 #include <E-mail.h>
48 #include <mail_encoding.h>
51 class TContentView;
52 class TEnclosuresView;
53 class THeaderView;
54 class TMailApp;
55 class TMenu;
56 class TPrefsWindow;
57 class TSignatureWindow;
59 class BEmailMessage;
60 class BFile;
61 class BFilePanel;
62 class BMailMessage;
63 class BMenu;
64 class BMenuBar;
65 class BMenuItem;
66 class Words;
69 class TMailWindow : public BWindow {
70 public:
71 TMailWindow(BRect frame, const char* title,
72 TMailApp* app, const entry_ref* ref,
73 const char* to, const BFont *font,
74 bool resending,
75 BMessenger* trackerMessenger);
76 virtual ~TMailWindow();
78 virtual void FrameResized(float width, float height);
79 virtual void MenusBeginning();
80 virtual void MessageReceived(BMessage*);
81 virtual bool QuitRequested();
82 virtual void Show();
83 virtual void Zoom(BPoint, float, float);
84 virtual void WindowActivated(bool state);
86 void SetTo(const char* mailTo, const char* subject,
87 const char* ccTo = NULL,
88 const char* bccTo = NULL,
89 const BString* body = NULL,
90 BMessage* enclosures = NULL);
91 void AddSignature(BMailMessage*);
92 void Forward(entry_ref*, TMailWindow*,
93 bool includeAttachments);
94 void Print();
95 void PrintSetup();
96 void Reply(entry_ref*, TMailWindow*, uint32);
97 void CopyMessage(entry_ref* ref, TMailWindow* src);
98 status_t Send(bool now);
99 status_t SaveAsDraft();
100 status_t OpenMessage(const entry_ref* ref,
101 uint32 characterSetForDecoding
102 = B_MAIL_NULL_CONVERSION);
104 status_t GetMailNodeRef(node_ref &nodeRef) const;
105 BEmailMessage* Mail() const { return fMail; }
107 bool GetTrackerWindowFile(entry_ref*,
108 bool dir) const;
109 void SaveTrackerPosition(entry_ref*);
110 void SetOriginatingWindow(BWindow* window);
112 void PreserveReadingPos(bool save);
113 void MarkMessageRead(entry_ref* message,
114 read_flags flag);
115 void SetTrackerSelectionToCurrent();
116 TMailWindow* FrontmostWindow();
117 void UpdateViews();
118 void UpdatePreferences();
120 protected:
121 void SetTitleForMessage();
122 void AddEnclosure(BMessage* msg);
123 void BuildToolBar();
124 status_t TrainMessageAs(const char* commandWord);
126 private:
127 status_t _GetQueryPath(BPath* path) const;
128 void _RebuildQueryMenu(bool firstTime = false);
129 char* _BuildQueryString(BEntry* entry) const;
131 void _AddReadButton();
132 void _UpdateReadButton();
133 void _UpdateLabel(uint32 command, const char* label,
134 bool show);
136 void _SetDownloading(bool downloading);
137 uint32 _CurrentCharacterSet() const;
139 static BBitmap* _RetrieveVectorIcon(int32 id);
141 private:
142 TMailApp* fApp;
144 BEmailMessage* fMail;
145 entry_ref* fRef;
146 // Reference to currently displayed file
147 int32 fFieldState;
148 BFilePanel* fPanel;
149 BMenuBar* fMenuBar;
150 BMenuItem* fAdd;
151 BMenuItem* fCut;
152 BMenuItem* fCopy;
153 BMenuItem* fHeader;
154 BMenuItem* fPaste;
155 BMenuItem* fPrint;
156 BMenuItem* fPrintSetup;
157 BMenuItem* fQuote;
158 BMenuItem* fRaw;
159 BMenuItem* fRemove;
160 BMenuItem* fRemoveQuote;
161 BMenuItem* fSendNow;
162 BMenuItem* fSendLater;
163 BMenuItem* fUndo;
164 BMenuItem* fRedo;
165 BMenuItem* fNextMsg;
166 BMenuItem* fPrevMsg;
167 BMenuItem* fDeleteNext;
168 BMenuItem* fSpelling;
169 BMenu* fSaveAddrMenu;
171 BMenu* fQueryMenu;
172 BMenu* fLeaveStatusMenu;
173 BMenu* fEncodingMenu;
175 struct BitmapItem {
176 BBitmap* bm;
177 int32 id;
179 static BObjectList<BitmapItem> sBitmapCache;
180 static BLocker sBitmapCacheLock;
182 BToolBar* fToolBar;
184 BRect fZoom;
185 TContentView* fContentView;
186 THeaderView* fHeaderView;
187 TEnclosuresView* fEnclosuresView;
188 TMenu* fSignature;
190 BMessenger fTrackerMessenger;
191 // Talks to tracker window that this was launched from.
192 BMessenger fMessengerToSpamServer;
194 entry_ref fPrevRef;
195 entry_ref fNextRef;
196 bool fPrevTrackerPositionSaved : 1;
197 bool fNextTrackerPositionSaved : 1;
199 entry_ref fOpenFolder;
201 bool fSigAdded : 1;
202 bool fIncoming : 1;
203 bool fReplying : 1;
204 bool fResending : 1;
205 bool fSent : 1;
206 bool fDraft : 1;
207 bool fChanged : 1;
209 static BList sWindowList;
210 static BLocker sWindowListLock;
212 entry_ref fRepliedMail;
213 BMessenger* fOriginatingWindow;
215 bool fAutoMarkRead : 1;
216 bool fKeepStatusOnQuit;
218 bool fDownloading;
222 #endif // _MAIL_WINDOW_H