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