4 * $TOG: SendMsgDialog.h /main/17 1999/03/25 13:43:01 mgreess $
6 * RESTRICTED CONFIDENTIAL INFORMATION:
8 * The information in this document is subject to special
9 * restrictions in a confidential disclosure agreement between
10 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
11 * document outside HP, IBM, Sun, USL, SCO, or Univel without
12 * Sun's specific written approval. This document and all copies
13 * and derivative works thereof must be returned or destroyed at
16 * Copyright 1993, 1994, 1995 Sun Microsystems, Inc. All rights reserved.
21 #ifndef SENDMSGDIALOG_H
22 #define SENDMSGDIALOG_H
24 //#include "Editor.hh"
25 //#include "CDEM_CoeEd.hh"
26 //#include "XmTextEditor.h"
28 #include "DtMailEditor.hh"
29 #include "MenuWindow.h"
30 #include "NoUndoCmd.h"
33 #include "RoamMenuWindow.h"
34 #include "DtMailGenDialog.hh"
35 #include "DtVirtArray.hh"
40 // This is the Compose window.
41 class SendMsgDialog : public MenuWindow, public AbstractEditorParent {
59 HeaderList(const HeaderList &);
63 Widget GetMainWin() { return _main_form; }
64 void setTitle(char *title);
69 DtMailEditor *_my_editor;
70 DtMailGenDialog *_genDialog;
74 Boolean _already_sending; // Flag to make sure we don't send more than once.
75 Boolean _show_attach_area;
77 int _confirm_attachment_threshold;
78 int confirm_add_attachment(char*, int);
79 int get_confirm_attachment_threshold(void);
88 UnifiedSelectFileCmd *_file_include;
89 SaveAsTextCmd *_file_save_as;
92 Cmd *_file_sendAs[10]; // Assume 10 transports.
101 Cmd *_edit_paste_special[2];
104 Cmd *_edit_select_all;
108 DtVirtArray <PropStringPair *> *_aliasList;
109 CmdList *_bccPopupCmdlist;
110 Widget _bccPopupMenu;
111 MenuBar *_bccPopupMenuBar;
112 CmdList *_ccPopupCmdlist;
114 MenuBar *_ccPopupMenuBar;
115 CmdList *_toPopupCmdlist;
117 MenuBar *_toPopupMenuBar;
121 // Found in Editor.hh
123 //MenuBar *_menuPopupText;
124 //Widget _textPopupMenu;
126 CmdList *_textPopupMenuList;
129 Widget _attachmentMenu;
130 CmdList *_attachmentMenuList;
131 CmdList *_attachmentPopupMenuList;
132 CmdList *_attachmentActionsList;
134 SaveAttachCmd *_att_save;
135 UnifiedSelectFileCmd *_att_add;
139 Cmd *_att_select_all;
142 void construct_attachment_popup(void);
143 void construct_text_popup(void);
147 Cmd *_format_word_wrap;
148 Cmd *_format_settings;
149 Cmd *_format_find_change;
151 Cmd *_format_bcc; // Depends on Properties setting.
152 Cmd *_format_separator;
154 CmdList *_format_cmds;
156 Widget _format_cascade;
161 int _num_sendAs; // Number of Transports available through Back End.
162 int _template_count; // Number of templates loaded.
163 char *_templateList; // names of templates
166 // The header list keeps track of the current headers on the Format
167 // menu, as well as their current state in the compose header region.
168 DtVirtArray<HeaderList *> _header_list;
169 DtMailBoolean _headers_changed;
171 char *_additionalfields;
181 // This is the internal data structure used for submission.
182 // As user adds/deletes attachment, this data structure is update immediately.
183 // This data structure is also updated at periodic checkpoints to store the
184 // latest Compose window data.
185 // Before sending, this is also updated.
186 DtMail::Message *_msgHandle;
188 // Pointer to the message that is being included as an attachment.
189 // When updateMsgHndAtt() is called, data in this handle is copied to _msgHandle.
190 DtMail::Message *_inclMsgHandle;
192 // Pointer to the last Attachment BodyPart so that newBodyPart(error, _lastAttBP)
193 // returns a message body part after the last body part. This is so that
194 // attachments will be ordered properly.
195 DtMail::BodyPart *_lastAttBP;
197 // When makeMessage() is called, it creates a message handle with its
198 // first body part empty. If set to TRUE, then this boolean variable
199 // indicates that the first body part of _msgHandle has already been used
200 // (probably for text). Otherwise, the first body part can be used for attachment.
201 Boolean _firstBPHandled;
203 // updateMsgHndAtt() uses this Boolean variable to determine whether the
204 // current message handle to be copied contains a text body part or not.
205 Boolean _inclMsgHasText;
207 // The auto save interval id is used to stop the interval timer for auto
210 XtIntervalId _auto_save_interval;
211 char * _auto_save_path;
212 char * _auto_save_file;
214 char * _dead_letter_buf;
216 DtMailBoolean _log_msg;
218 void mkAutoSavePath();
219 static void autoSaveCallback(XtPointer, XtIntervalId *id);
220 void doAutoSave(void);
221 void doAutoSave(char *);
222 int getAutoSaveInterval(void);
224 void addTemplates(CmdList*); // Create the initial template menu.
225 Widget getHeaderWidget(const char *);
226 static void aliasMenuButtonHandler(
228 XtPointer client_data,
231 void createAliasList(DtVirtArray<PropStringPair*> *aliases);
232 void destroyAliasList(DtVirtArray<PropStringPair*> *aliases);
233 Widget createAliasPopupMenu(
237 DtVirtArray<PropStringPair*> *aliases);
238 void destroyAliasPopupMenu(
243 void createAliasPopupMenus();
244 void destroyAliasPopupMenus();
245 void createFormatMenu();
246 void createMenuPanes();
247 Widget createWorkArea(Widget);
248 void createHeaders(Widget header);
249 void doDynamicHeaderMenus(void);
250 Boolean reservedHeader(const char *label);
252 void valueToAddrText(Widget, DtMailValueSeq &);
254 // File selection Box callbacks
255 static void include_file_cb( void *, char * );
256 static void add_att_cb( void *, char * );
257 static void save_att_cb( void *, char * );
259 // Return a message handle -- internal data structure of a mail message.
260 DtMail::Message * makeMessage(void);
261 // Clear Compose window text fields to prepare for re-use.
264 // Find a header in the list by name.
266 int lookupHeader(const char * name);
267 static void headerValueChanged(Widget, XtPointer, XtPointer);
268 void reattachHeaders(void);
269 void justifyHeaders(void);
270 void forceFormResize(Widget);
272 // Called when the sendmail child process completes
273 static void sendmailErrorProc (int pid, int status, void *data);
274 void popupMemoryError(DtMailEnv &error);
278 virtual ~SendMsgDialog();
279 virtual const char *const className () { return "SendMsgDialog"; }
281 void send_message( const char *, int );
283 void include_file(char *);
284 void add_att(char *);
285 void add_att(char *, DtMailBuffer);
286 void add_att(DtMailBuffer);
287 void setMsgHnd(); // initialize _msgHandle.
288 void startAutoSave(void);
289 void stopAutoSave(void);
290 void setLogState(DtMailBoolean state) { _log_msg = state; }
291 void propsChanged(void);
292 Boolean isMsgValid(void); // checks to see whether _msgHandle is NULL
295 void setLastAttBP(DtMail::BodyPart *);
296 void setFirstBPHandled(Boolean);
298 void attachmentFeedback(Boolean);
300 // The set/get Header methods manage the dynamic header structures.
302 void setHeader(const char * name, const char * value);
303 void setHeader(const char * name, DtMailValueSeq & value);
304 void getHeader(const char * name, char ** value);
305 void resetHeaders(void);
306 void setInputFocus(const int mode);
308 // This method returns true if the user has edited the headers.
310 DtMailBoolean headersChanged(void) { return _headers_changed; }
312 // The load/store Headers methods will reload the pane from a message,
313 // or store the header pane values to the message. Specifying NULL will
314 // load the header pane from the current value for _msgHandle.
315 // If load_all is true, then all headers are loaded, and fields are
316 // added as necessary to the header pane. Otherwise, the list of shown
317 // headers are loaded and all others are ignored.
319 // storeHeaders transfers the currently stored headers to the specified
320 // message object, or the internal message if none is specified.
322 void loadHeaders(DtMail::Message * msg = NULL,
323 DtMailBoolean load_all = DTM_FALSE);
324 void storeHeaders(DtMail::Message * msg = NULL);
326 // Check if a message has addressees. If a message is Sent and
327 // it has no addressees, we need to barf.
329 Boolean hasAddressee();
331 // The changeHeaderState method toggles the dynamic headers between
332 // shown an hidden. It will also update the menu label accordingly.
334 void changeHeaderState(const char * name);
336 // unfilled_headers returns TRUE if no header has a value.
337 // FaLSE if any header has a value
339 Boolean unfilled_headers();
341 // The set/clear Status methods will set and clear the status line.
343 void setStatus(const char * str);
344 void clearStatus(void);
347 static void restoreSession(char*);
348 virtual int smpSaveSessionGlobal();
349 virtual void smpSaveSessionLocal();
351 // These are public so that the check point routine can call
352 // updateMsgHnd, and include/forward routines can call updateMsgHndAtt.
354 void updateMsgHndAtt();
358 DtMailEditor* get_editor() {return _my_editor; }
362 void setInclMsgHnd(DtMail::Message *, Boolean);
363 void text( const char * );
364 void append( const char * );
365 void quit(Boolean delete_win = FALSE);
368 // Method to check if self has content in it.
369 Boolean checkDirty();
370 Boolean handleQuitDialog();
371 void goAway(Boolean);
373 // Add the specified file (first parameter) as attachment.
374 void inclAsAttmt( char *, char *);
375 // Add the content of the buffer as attachment.
376 void inclAsAttmt( unsigned char *, int, char *);
377 // Parse the buffer and fill the Compose window with data.
378 void parseNplace( char *, int );
379 // Parse the file and fill the Compose window with data.
380 void parseNplace(const char * path);
382 // Load the dead letter file.
383 void loadDeadLetter(const char * path);
385 // SR - Text-selection callbacks.
387 virtual void text_selected();
388 virtual void text_unselected();
389 void attachment_selected();
390 void all_attachments_deselected();
391 void all_attachments_selected();
392 void selectAllAttachments();
395 DtMailGenDialog *genDialog() { return _genDialog; }
397 void showAttachArea();
398 void hideAttachArea();
400 void activate_default_attach_menu();
401 void deactivate_default_attach_menu();
403 // Activate and deactivate paste stuff
404 void activate_edit_paste() { _edit_paste->activate(); }
405 void activate_edit_paste_indented() {_edit_paste_special[0]->activate();}
406 void activate_edit_paste_bracketed() {_edit_paste_special[1]->activate();}
408 void delete_selected_attachments();
410 void undelete_last_deleted_attachment();
412 void save_selected_attachment(char *);
413 void save_selected_msg_text(char *);
415 Boolean renameAttachmentOK();
417 void addAttachmentActions(char **, int);
418 void removeAttachmentActions();
419 void invokeAttachmentAction(int);
421 virtual void manage();
422 virtual void unmanage();
427 // Manager of all compose windows.
433 virtual const char *const className () { return "Compose"; }
435 SendMsgDialog *getWin();
436 SendMsgDialog *getUnusedWin();
437 XtIntervalId getTimeOutId() { return _timeout_id; }
438 int numCreatedWindows() { return _num_created; }
439 int numUnusedWindows() { return _not_in_use; }
440 void putWin(SendMsgDialog*, Boolean);
441 void putTimeOutId(XtIntervalId id) { _timeout_id = id; }
442 void Self_destruct(XtPointer, XtIntervalId*);
449 struct Compose_Win *next;
453 Compose_Win *_compose_head; // List of compose windows.
454 int _not_in_use; // Number of unused compose windows.
455 int _num_created; // Total number of compose windows created.
456 XtIntervalId _timeout_id; // Self destruct id.
459 extern Compose theCompose;
461 #ifdef DTMAIL_TOOLTALK
462 extern int started_by_tt;