xref: /haiku/src/apps/mail/MailWindow.h (revision 1c09002cbee8e797a0f8bbfc5678dfadd39ee1a7)
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			MarkMessageRead(entry_ref* message,
112 									read_flags flag);
113 				void			SetTrackerSelectionToCurrent();
114 				TMailWindow*	FrontmostWindow();
115 				void			UpdateViews();
116 				void			UpdatePreferences();
117 
118 	protected:
119 				void			SetTitleForMessage();
120 				void			AddEnclosure(BMessage* msg);
121 				void			BuildButtonBar();
122 				status_t		TrainMessageAs(const char* commandWord);
123 
124 	private:
125 				void			_UpdateSizeLimits();
126 
127 				status_t		_GetQueryPath(BPath* path) const;
128 				void			_RebuildQueryMenu(bool firstTime = false);
129 				char*			_BuildQueryString(BEntry* entry) const;
130 
131  				void			_AddReadButton();
132 				void			_UpdateReadButton();
133 
134 				void			_SetDownloading(bool downloading);
135 
136 				TMailApp*		fApp;
137 
138 				BEmailMessage*	fMail;
139 				entry_ref*		fRef;
140 					// Reference to currently displayed file
141 				int32			fFieldState;
142 				BFilePanel*		fPanel;
143 				BMenuBar*		fMenuBar;
144 				BMenuItem*		fAdd;
145 				BMenuItem*		fCut;
146 				BMenuItem*		fCopy;
147 				BMenuItem*		fHeader;
148 				BMenuItem*		fPaste;
149 				BMenuItem*		fPrint;
150 				BMenuItem*		fPrintSetup;
151 				BMenuItem*		fQuote;
152 				BMenuItem*		fRaw;
153 				BMenuItem*		fRemove;
154 				BMenuItem*		fRemoveQuote;
155 				BMenuItem*		fSendNow;
156 				BMenuItem*		fSendLater;
157 				BMenuItem*		fUndo;
158 				BMenuItem*		fRedo;
159 				BMenuItem*		fNextMsg;
160 				BMenuItem*		fPrevMsg;
161 				BMenuItem*		fDeleteNext;
162 				BMenuItem*		fSpelling;
163 				BMenu*			fSaveAddrMenu;
164 
165 				BMenu*			fQueryMenu;
166 
167 				ButtonBar*		fButtonBar;
168 				BmapButton*		fSendButton;
169 				BmapButton*		fSaveButton;
170 				BmapButton*		fPrintButton;
171 				BmapButton*		fSigButton;
172 
173 				BRect			fZoom;
174 				TContentView*	fContentView;
175 				THeaderView*	fHeaderView;
176 				TEnclosuresView* fEnclosuresView;
177 				TMenu*			fSignature;
178 
179 				BMessenger		fTrackerMessenger;
180 					// Talks to tracker window that this was launched from.
181 				BMessenger		fMessengerToSpamServer;
182 
183 				entry_ref		fPrevRef;
184 				entry_ref		fNextRef;
185 				bool			fPrevTrackerPositionSaved : 1;
186 				bool			fNextTrackerPositionSaved : 1;
187 
188 				entry_ref		fOpenFolder;
189 
190 				bool			fSigAdded : 1;
191 				bool			fIncoming : 1;
192 				bool			fReplying : 1;
193 				bool			fResending : 1;
194 				bool			fSent : 1;
195 				bool			fDraft : 1;
196 				bool			fChanged : 1;
197 
198 				static BList	sWindowList;
199 				static BLocker	sWindowListLock;
200 
201 				char*			fStartingText;
202 				entry_ref		fRepliedMail;
203 				BMessenger*		fOriginatingWindow;
204 
205 				bool			fAutoMarkRead : 1;
206 				BmapButton*		fReadButton;
207 				BmapButton*		fNextButton;
208 
209 				bool			fKeepStatusOnQuit;
210 
211 				bool			fDownloading;
212 };
213 
214 #endif // _MAIL_WINDOW_H
215 
216