xref: /haiku/src/apps/mail/MailWindow.h (revision cbed190f71b8aff814bf95539c39a1bcfb953ed8)
1 /*
2 Open Tracker License
3 
4 Terms and Conditions
5 
6 Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
7 
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:
14 
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.
17 
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.
24 
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.
28 
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.
33 */
34 #ifndef _MAIL_WINDOW_H
35 #define _MAIL_WINDOW_H
36 
37 
38 #include <Entry.h>
39 #include <Font.h>
40 #include <List.h>
41 #include <Locker.h>
42 #include <Messenger.h>
43 #include <Window.h>
44 
45 #include <E-mail.h>
46 #include <mail_encoding.h>
47 
48 
49 class TContentView;
50 class TEnclosuresView;
51 class THeaderView;
52 class TMailApp;
53 class TMenu;
54 class TPrefsWindow;
55 class TSignatureWindow;
56 
57 class BEmailMessage;
58 class BFile;
59 class BFilePanel;
60 class BMailMessage;
61 class BMenu;
62 class BMenuBar;
63 class BMenuItem;
64 class BmapButton;
65 class ButtonBar;
66 class Words;
67 
68 class TMailWindow : public BWindow {
69 	public:
70 								TMailWindow(BRect frame, const char* title,
71 									TMailApp* app, const entry_ref* ref,
72 									const char* to, const BFont *font,
73 									bool resending,
74 									BMessenger* trackerMessenger);
75 		virtual					~TMailWindow();
76 
77 		virtual	void			FrameResized(float width, float height);
78 		virtual	void			MenusBeginning();
79 		virtual	void			MessageReceived(BMessage*);
80 		virtual	bool			QuitRequested();
81 		virtual	void			Show();
82 		virtual	void			Zoom(BPoint, float, float);
83 		virtual	void			WindowActivated(bool state);
84 
85 				void			SetTo(const char* mailTo, const char* subject,
86 									const char* ccTo = NULL,
87 									const char* bccTo = NULL,
88 									const BString* body = NULL,
89 									BMessage* enclosures = NULL);
90 				void			AddSignature(BMailMessage*);
91 				void			Forward(entry_ref*, TMailWindow*,
92 									bool includeAttachments);
93 				void			Print();
94 				void			PrintSetup();
95 				void			Reply(entry_ref*, TMailWindow*, uint32);
96 				void			CopyMessage(entry_ref* ref, TMailWindow* src);
97 				status_t		Send(bool);
98 				status_t		SaveAsDraft();
99 				status_t		OpenMessage(const entry_ref* ref,
100 									uint32 characterSetForDecoding
101 										= B_MAIL_NULL_CONVERSION);
102 
103 				status_t		GetMailNodeRef(node_ref &nodeRef) const;
104 				BEmailMessage*	Mail() const { return fMail; }
105 
106 				bool			GetTrackerWindowFile(entry_ref*,
107 									bool dir) const;
108 				void			SaveTrackerPosition(entry_ref*);
109 				void			SetOriginatingWindow(BWindow* window);
110 
111 				void			SetCurrentMessageRead(read_flags flag);
112 				void			SetTrackerSelectionToCurrent();
113 				TMailWindow*	FrontmostWindow();
114 				void			UpdateViews();
115 				void			UpdatePreferences();
116 
117 	protected:
118 				void			SetTitleForMessage();
119 				void			AddEnclosure(BMessage* msg);
120 				void			BuildButtonBar();
121 				status_t		TrainMessageAs(const char* commandWord);
122 
123 	private:
124 				void			_UpdateSizeLimits();
125 
126 				status_t		_GetQueryPath(BPath* path) const;
127 				void			_RebuildQueryMenu(bool firstTime = false);
128 				char*			_BuildQueryString(BEntry* entry) const;
129 
130  				void			_AddReadButton();
131 				void			_UpdateReadButton();
132 
133 				void			_SetDownloading(bool downloading);
134 
135 				TMailApp*		fApp;
136 
137 				BEmailMessage*	fMail;
138 				entry_ref*		fRef;
139 					// Reference to currently displayed file
140 				int32			fFieldState;
141 				BFilePanel*		fPanel;
142 				BMenuBar*		fMenuBar;
143 				BMenuItem*		fAdd;
144 				BMenuItem*		fCut;
145 				BMenuItem*		fCopy;
146 				BMenuItem*		fHeader;
147 				BMenuItem*		fPaste;
148 				BMenuItem*		fPrint;
149 				BMenuItem*		fPrintSetup;
150 				BMenuItem*		fQuote;
151 				BMenuItem*		fRaw;
152 				BMenuItem*		fRemove;
153 				BMenuItem*		fRemoveQuote;
154 				BMenuItem*		fSendNow;
155 				BMenuItem*		fSendLater;
156 				BMenuItem*		fUndo;
157 				BMenuItem*		fRedo;
158 				BMenuItem*		fNextMsg;
159 				BMenuItem*		fPrevMsg;
160 				BMenuItem*		fDeleteNext;
161 				BMenuItem*		fSpelling;
162 				BMenu*			fSaveAddrMenu;
163 
164 				BMenu*			fQueryMenu;
165 
166 				ButtonBar*		fButtonBar;
167 				BmapButton*		fSendButton;
168 				BmapButton*		fSaveButton;
169 				BmapButton*		fPrintButton;
170 				BmapButton*		fSigButton;
171 
172 				BRect			fZoom;
173 				TContentView*	fContentView;
174 				THeaderView*	fHeaderView;
175 				TEnclosuresView* fEnclosuresView;
176 				TMenu*			fSignature;
177 
178 				BMessenger		fTrackerMessenger;
179 					// Talks to tracker window that this was launched from.
180 				BMessenger		fMessengerToSpamServer;
181 
182 				entry_ref		fPrevRef;
183 				entry_ref		fNextRef;
184 				bool			fPrevTrackerPositionSaved : 1;
185 				bool			fNextTrackerPositionSaved : 1;
186 
187 				entry_ref		fOpenFolder;
188 
189 				bool			fSigAdded : 1;
190 				bool			fIncoming : 1;
191 				bool			fReplying : 1;
192 				bool			fResending : 1;
193 				bool			fSent : 1;
194 				bool			fDraft : 1;
195 				bool			fChanged : 1;
196 
197 				static BList	sWindowList;
198 				static BLocker	sWindowListLock;
199 
200 				char*			fStartingText;
201 				entry_ref		fRepliedMail;
202 				BMessenger*		fOriginatingWindow;
203 
204 				bool			fAutoMarkRead : 1;
205 				BmapButton*		fReadButton;
206 				BmapButton*		fNextButton;
207 
208 				bool			fKeepStatusOnQuit;
209 
210 				bool			fDownloading;
211 };
212 
213 #endif // _MAIL_WINDOW_H
214 
215