1/*
2Open Tracker License
3
4Terms and Conditions
5
6Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy of
9this software and associated documentation files (the "Software"), to deal in
10the Software without restriction, including without limitation the rights to
11use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12of the Software, and to permit persons to whom the Software is furnished to do
13so, subject to the following conditions:
14
15The above copyright notice and this permission notice applies to all licensees
16and shall be included in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25Except as contained in this notice, the name of Be Incorporated shall not be
26used in advertising or otherwise to promote the sale, use or other dealings in
27this Software without prior written authorization from Be Incorporated.
28
29BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30of Be Incorporated in the United States and other countries. Other brand product
31names are registered trademarks or trademarks of their respective holders.
32All 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 <Locker.h>
41#include <Messenger.h>
42#include <ObjectList.h>
43#include <Window.h>
44
45#include <ToolBar.h>
46
47#include <E-mail.h>
48#include <mail_encoding.h>
49
50
51class TContentView;
52class TEnclosuresView;
53class THeaderView;
54class TMailApp;
55class TMenu;
56class TPrefsWindow;
57class TSignatureWindow;
58
59class BEmailMessage;
60class BFile;
61class BFilePanel;
62class BMailMessage;
63class BMenu;
64class BMenuBar;
65class BMenuItem;
66class Words;
67
68
69class TMailWindow : public BWindow {
70public:
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();
77
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);
85
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);
103
104			status_t			GetMailNodeRef(node_ref &nodeRef) const;
105			BEmailMessage*		Mail() const { return fMail; }
106
107			bool				GetTrackerWindowFile(entry_ref*,
108									bool dir) const;
109			void				SaveTrackerPosition(entry_ref*);
110			void				SetOriginatingWindow(BWindow* window);
111
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();
119
120protected:
121			void				SetTitleForMessage();
122			void				AddEnclosure(BMessage* msg);
123			void				BuildToolBar();
124			status_t			TrainMessageAs(const char* commandWord);
125
126private:
127			status_t			_GetQueryPath(BPath* path) const;
128			void				_RebuildQueryMenu(bool firstTime = false);
129			char*				_BuildQueryString(BEntry* entry) const;
130			void				_LaunchQuery(const char* title,
131									const char* attribute, BString text);
132
133			void				_CreateNewPerson(BString address, BString name);
134			void				_AddReadButton();
135			void				_UpdateReadButton();
136			void				_UpdateLabel(uint32 command, const char* label,
137									bool show);
138
139			void				_SetDownloading(bool downloading);
140			uint32				_CurrentCharacterSet() const;
141
142	static	BBitmap*			_RetrieveVectorIcon(int32 id);
143
144private:
145			TMailApp*			fApp;
146
147			BEmailMessage*		fMail;
148			entry_ref*			fRef;
149				// Reference to currently displayed file
150			int32				fFieldState;
151			BFilePanel*			fPanel;
152			BMenuBar*			fMenuBar;
153			BMenuItem*			fAdd;
154			BMenuItem*			fCut;
155			BMenuItem*			fCopy;
156			BMenuItem*			fHeader;
157			BMenuItem*			fPaste;
158			BMenuItem*			fPrint;
159			BMenuItem*			fPrintSetup;
160			BMenuItem*			fQuote;
161			BMenuItem*			fRaw;
162			BMenuItem*			fRemove;
163			BMenuItem*			fRemoveQuote;
164			BMenuItem*			fSendNow;
165			BMenuItem*			fSendLater;
166			BMenuItem*			fUndo;
167			BMenuItem*			fRedo;
168			BMenuItem*			fNextMsg;
169			BMenuItem*			fPrevMsg;
170			BMenuItem*			fDeleteNext;
171			BMenuItem*			fSpelling;
172			BMenu*				fSaveAddrMenu;
173
174			BMenu*				fQueryMenu;
175			BMenu*				fLeaveStatusMenu;
176			BMenu*				fEncodingMenu;
177
178	struct BitmapItem {
179		BBitmap* bm;
180		int32 id;
181	};
182	static	BObjectList<BitmapItem>	sBitmapCache;
183	static	BLocker				sBitmapCacheLock;
184
185			BToolBar*			fToolBar;
186
187			BRect				fZoom;
188			TContentView*		fContentView;
189			THeaderView*		fHeaderView;
190			TEnclosuresView*	fEnclosuresView;
191			TMenu*				fSignature;
192
193			BMessenger			fTrackerMessenger;
194				// Talks to tracker window that this was launched from.
195			BMessenger			fMessengerToSpamServer;
196
197			entry_ref			fPrevRef;
198			entry_ref			fNextRef;
199			bool				fPrevTrackerPositionSaved : 1;
200			bool				fNextTrackerPositionSaved : 1;
201
202			entry_ref			fOpenFolder;
203
204			bool				fSigAdded : 1;
205			bool				fIncoming : 1;
206			bool				fReplying : 1;
207			bool				fResending : 1;
208			bool				fSent : 1;
209			bool				fDraft : 1;
210			bool				fChanged : 1;
211
212	static	BList				sWindowList;
213	static	BLocker				sWindowListLock;
214
215			entry_ref			fRepliedMail;
216			BMessenger*			fOriginatingWindow;
217
218			bool				fAutoMarkRead : 1;
219			bool				fKeepStatusOnQuit;
220
221			bool				fDownloading;
222};
223
224
225#endif // _MAIL_WINDOW_H
226