2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
26 * $TOG: SendMsgDialog.h /main/17 1999/03/25 13:43:01 mgreess $
28 * RESTRICTED CONFIDENTIAL INFORMATION:
30 * The information in this document is subject to special
31 * restrictions in a confidential disclosure agreement between
32 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
33 * document outside HP, IBM, Sun, USL, SCO, or Univel without
34 * Sun's specific written approval. This document and all copies
35 * and derivative works thereof must be returned or destroyed at
38 * Copyright 1993, 1994, 1995 Sun Microsystems, Inc. All rights reserved.
43 #ifndef SENDMSGDIALOG_H
44 #define SENDMSGDIALOG_H
46 //#include "Editor.hh"
47 //#include "CDEM_CoeEd.hh"
48 //#include "XmTextEditor.h"
50 #include "DtMailEditor.hh"
51 #include "MenuWindow.h"
52 #include "NoUndoCmd.h"
55 #include "RoamMenuWindow.h"
56 #include "DtMailGenDialog.hh"
57 #include "DtVirtArray.hh"
62 // This is the Compose window.
63 class SendMsgDialog : public MenuWindow, public AbstractEditorParent {
81 HeaderList(const HeaderList &);
85 Widget GetMainWin() { return _main_form; }
86 void setTitle(char *title);
91 DtMailEditor *_my_editor;
92 DtMailGenDialog *_genDialog;
96 Boolean _already_sending; // Flag to make sure we don't send more than once.
97 Boolean _show_attach_area;
99 int _confirm_attachment_threshold;
100 int confirm_add_attachment(char*, int);
101 int get_confirm_attachment_threshold(void);
110 UnifiedSelectFileCmd *_file_include;
111 SaveAsTextCmd *_file_save_as;
114 Cmd *_file_sendAs[10]; // Assume 10 transports.
123 Cmd *_edit_paste_special[2];
126 Cmd *_edit_select_all;
130 DtVirtArray <PropStringPair *> *_aliasList;
131 CmdList *_bccPopupCmdlist;
132 Widget _bccPopupMenu;
133 MenuBar *_bccPopupMenuBar;
134 CmdList *_ccPopupCmdlist;
136 MenuBar *_ccPopupMenuBar;
137 CmdList *_toPopupCmdlist;
139 MenuBar *_toPopupMenuBar;
143 // Found in Editor.hh
145 //MenuBar *_menuPopupText;
146 //Widget _textPopupMenu;
148 CmdList *_textPopupMenuList;
151 Widget _attachmentMenu;
152 CmdList *_attachmentMenuList;
153 CmdList *_attachmentPopupMenuList;
154 CmdList *_attachmentActionsList;
156 SaveAttachCmd *_att_save;
157 UnifiedSelectFileCmd *_att_add;
161 Cmd *_att_select_all;
164 void construct_attachment_popup(void);
165 void construct_text_popup(void);
169 Cmd *_format_word_wrap;
170 Cmd *_format_settings;
171 Cmd *_format_find_change;
173 Cmd *_format_bcc; // Depends on Properties setting.
174 Cmd *_format_separator;
176 CmdList *_format_cmds;
178 Widget _format_cascade;
183 int _num_sendAs; // Number of Transports available through Back End.
184 int _template_count; // Number of templates loaded.
185 char *_templateList; // names of templates
188 // The header list keeps track of the current headers on the Format
189 // menu, as well as their current state in the compose header region.
190 DtVirtArray<HeaderList *> _header_list;
191 DtMailBoolean _headers_changed;
193 char *_additionalfields;
203 // This is the internal data structure used for submission.
204 // As user adds/deletes attachment, this data structure is update immediately.
205 // This data structure is also updated at periodic checkpoints to store the
206 // latest Compose window data.
207 // Before sending, this is also updated.
208 DtMail::Message *_msgHandle;
210 // Pointer to the message that is being included as an attachment.
211 // When updateMsgHndAtt() is called, data in this handle is copied to _msgHandle.
212 DtMail::Message *_inclMsgHandle;
214 // Pointer to the last Attachment BodyPart so that newBodyPart(error, _lastAttBP)
215 // returns a message body part after the last body part. This is so that
216 // attachments will be ordered properly.
217 DtMail::BodyPart *_lastAttBP;
219 // When makeMessage() is called, it creates a message handle with its
220 // first body part empty. If set to TRUE, then this boolean variable
221 // indicates that the first body part of _msgHandle has already been used
222 // (probably for text). Otherwise, the first body part can be used for attachment.
223 Boolean _firstBPHandled;
225 // updateMsgHndAtt() uses this Boolean variable to determine whether the
226 // current message handle to be copied contains a text body part or not.
227 Boolean _inclMsgHasText;
229 // The auto save interval id is used to stop the interval timer for auto
232 XtIntervalId _auto_save_interval;
233 char * _auto_save_path;
234 char * _auto_save_file;
236 char * _dead_letter_buf;
238 DtMailBoolean _log_msg;
240 void mkAutoSavePath();
241 static void autoSaveCallback(XtPointer, XtIntervalId *id);
242 void doAutoSave(void);
243 void doAutoSave(char *);
244 int getAutoSaveInterval(void);
246 void addTemplates(CmdList*); // Create the initial template menu.
247 Widget getHeaderWidget(const char *);
248 static void aliasMenuButtonHandler(
250 XtPointer client_data,
253 void createAliasList(DtVirtArray<PropStringPair*> *aliases);
254 void destroyAliasList(DtVirtArray<PropStringPair*> *aliases);
255 Widget createAliasPopupMenu(
259 DtVirtArray<PropStringPair*> *aliases);
260 void destroyAliasPopupMenu(
265 void createAliasPopupMenus();
266 void destroyAliasPopupMenus();
267 void createFormatMenu();
268 void createMenuPanes();
269 Widget createWorkArea(Widget);
270 void createHeaders(Widget header);
271 void doDynamicHeaderMenus(void);
272 Boolean reservedHeader(const char *label);
274 void valueToAddrText(Widget, DtMailValueSeq &);
276 // File selection Box callbacks
277 static void include_file_cb( void *, char * );
278 static void add_att_cb( void *, char * );
279 static void save_att_cb( void *, char * );
281 // Return a message handle -- internal data structure of a mail message.
282 DtMail::Message * makeMessage(void);
283 // Clear Compose window text fields to prepare for re-use.
286 // Find a header in the list by name.
288 int lookupHeader(const char * name);
289 static void headerValueChanged(Widget, XtPointer, XtPointer);
290 void reattachHeaders(void);
291 void justifyHeaders(void);
292 void forceFormResize(Widget);
294 // Called when the sendmail child process completes
295 static void sendmailErrorProc (int pid, int status, void *data);
296 void popupMemoryError(DtMailEnv &error);
300 virtual ~SendMsgDialog();
301 virtual const char *const className () { return "SendMsgDialog"; }
303 void send_message( const char *, int );
305 void include_file(char *);
306 void add_att(char *);
307 void add_att(char *, DtMailBuffer);
308 void add_att(DtMailBuffer);
309 void setMsgHnd(); // initialize _msgHandle.
310 void startAutoSave(void);
311 void stopAutoSave(void);
312 void setLogState(DtMailBoolean state) { _log_msg = state; }
313 void propsChanged(void);
314 Boolean isMsgValid(void); // checks to see whether _msgHandle is NULL
317 void setLastAttBP(DtMail::BodyPart *);
318 void setFirstBPHandled(Boolean);
320 void attachmentFeedback(Boolean);
322 // The set/get Header methods manage the dynamic header structures.
324 void setHeader(const char * name, const char * value);
325 void setHeader(const char * name, DtMailValueSeq & value);
326 void getHeader(const char * name, char ** value);
327 void resetHeaders(void);
328 void setInputFocus(const int mode);
330 // This method returns true if the user has edited the headers.
332 DtMailBoolean headersChanged(void) { return _headers_changed; }
334 // The load/store Headers methods will reload the pane from a message,
335 // or store the header pane values to the message. Specifying NULL will
336 // load the header pane from the current value for _msgHandle.
337 // If load_all is true, then all headers are loaded, and fields are
338 // added as necessary to the header pane. Otherwise, the list of shown
339 // headers are loaded and all others are ignored.
341 // storeHeaders transfers the currently stored headers to the specified
342 // message object, or the internal message if none is specified.
344 void loadHeaders(DtMail::Message * msg = NULL,
345 DtMailBoolean load_all = DTM_FALSE);
346 void storeHeaders(DtMail::Message * msg = NULL);
348 // Check if a message has addressees. If a message is Sent and
349 // it has no addressees, we need to barf.
351 Boolean hasAddressee();
353 // The changeHeaderState method toggles the dynamic headers between
354 // shown an hidden. It will also update the menu label accordingly.
356 void changeHeaderState(const char * name);
358 // unfilled_headers returns TRUE if no header has a value.
359 // FaLSE if any header has a value
361 Boolean unfilled_headers();
363 // The set/clear Status methods will set and clear the status line.
365 void setStatus(const char * str);
366 void clearStatus(void);
369 static void restoreSession(char*);
370 virtual int smpSaveSessionGlobal();
371 virtual void smpSaveSessionLocal();
373 // These are public so that the check point routine can call
374 // updateMsgHnd, and include/forward routines can call updateMsgHndAtt.
376 void updateMsgHndAtt();
380 DtMailEditor* get_editor() {return _my_editor; }
384 void setInclMsgHnd(DtMail::Message *, Boolean);
385 void text( const char * );
386 void append( const char * );
387 void quit(Boolean delete_win = FALSE);
390 // Method to check if self has content in it.
391 Boolean checkDirty();
392 Boolean handleQuitDialog();
393 void goAway(Boolean);
395 // Add the specified file (first parameter) as attachment.
396 void inclAsAttmt( char *, char *);
397 // Add the content of the buffer as attachment.
398 void inclAsAttmt( unsigned char *, int, char *);
399 // Parse the buffer and fill the Compose window with data.
400 void parseNplace( char *, int );
401 // Parse the file and fill the Compose window with data.
402 void parseNplace(const char * path);
404 // Load the dead letter file.
405 void loadDeadLetter(const char * path);
407 // SR - Text-selection callbacks.
409 virtual void text_selected();
410 virtual void text_unselected();
411 void attachment_selected();
412 void all_attachments_deselected();
413 void all_attachments_selected();
414 void selectAllAttachments();
417 DtMailGenDialog *genDialog() { return _genDialog; }
419 void showAttachArea();
420 void hideAttachArea();
422 void activate_default_attach_menu();
423 void deactivate_default_attach_menu();
425 // Activate and deactivate paste stuff
426 void activate_edit_paste() { _edit_paste->activate(); }
427 void activate_edit_paste_indented() {_edit_paste_special[0]->activate();}
428 void activate_edit_paste_bracketed() {_edit_paste_special[1]->activate();}
430 void delete_selected_attachments();
432 void undelete_last_deleted_attachment();
434 void save_selected_attachment(char *);
435 void save_selected_msg_text(char *);
437 Boolean renameAttachmentOK();
439 void addAttachmentActions(char **, int);
440 void removeAttachmentActions();
441 void invokeAttachmentAction(int);
443 virtual void manage();
444 virtual void unmanage();
449 // Manager of all compose windows.
455 virtual const char *const className () { return "Compose"; }
457 SendMsgDialog *getWin();
458 SendMsgDialog *getUnusedWin();
459 XtIntervalId getTimeOutId() { return _timeout_id; }
460 int numCreatedWindows() { return _num_created; }
461 int numUnusedWindows() { return _not_in_use; }
462 void putWin(SendMsgDialog*, Boolean);
463 void putTimeOutId(XtIntervalId id) { _timeout_id = id; }
464 void Self_destruct(XtPointer, XtIntervalId*);
471 struct Compose_Win *next;
475 Compose_Win *_compose_head; // List of compose windows.
476 int _not_in_use; // Number of unused compose windows.
477 int _num_created; // Total number of compose windows created.
478 XtIntervalId _timeout_id; // Self destruct id.
481 extern Compose theCompose;
483 #ifdef DTMAIL_TOOLTALK
484 extern int started_by_tt;