4 * $TOG: RoamMenuWindow.h /main/29 1999/02/03 18:01:26 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 Sun Microsystems, Inc. All rights reserved.
21 #ifndef ROAMMENUWINDOW_H
22 #define ROAMMENUWINDOW_H
24 //-----------------------------------------------------------------------------
25 // Roam window for viewing messages
26 //-----------------------------------------------------------------------------
28 #include <DtMail/DtMail.hh>
30 #include "MenuWindow.h"
32 #include "DtMailGenDialog.hh"
36 #include "IconifyCmd.h"
40 #include "ViewMsgDialog.h"
41 #include <DtMail/DtMailError.hh>
42 #include "MsgScrollingList.hh"
43 #include "AttachArea.h"
44 #include "FindDialog.h"
47 //#include "CDEM_CoeEd.hh"
49 #include "DtMailEditor.hh"
51 #include "Undelete.hh"
53 /* ROMENU_* msgid 400 - 499
55 #define ROMENU_NOINIT 400
56 #define ROMENU_NEWM 401
57 #define ROMENU_STAT 402
58 #define ROMENU_SUM 403
59 #define ROMENU_SEL 404
60 #define ROMENU_NOOPEN 405
61 #define ROMENU_NOCREAT 406
62 #define ROMENU_NOCRT 407
63 #define ROMENU_CREAT 408
64 #define ROMENU_LOAD 409
65 #define ROMENU_INFO 410
66 #define ROMENU_EMPTYC 411
67 #define ROMENU_NEXT 412
68 #define ROMENU_PREV 413
69 #define ROMENU_PRT 414
70 #define ROMENU_MVCP 415
71 #define ROMENU_SENDER 416
72 #define ROMENU_SUB 417
73 #define ROMENU_DATE 418
74 #define ROMENU_SIZE 419
75 #define ROMENU_OPENBOX 420
76 #define ROMENU_NEW 421
77 #define ROMENU_OPEN 422
78 #define ROMENU_EMPTY 423
79 #define ROMENU_SAVEAS 424
80 #define ROMENU_CLOSE 425
81 #define ROMENU_OPMSG 426
82 #define ROMENU_SAVEMSG 427
83 #define ROMENU_PRINT 428
84 #define ROMENU_DEL 429
85 #define ROMENU_LAST 430
86 #define ROMENU_LIST 431
87 #define ROMENU_UNDEL 432
88 #define ROMENU_MSG 433
89 #define ROMENU_UNDMSG 434
90 #define ROMENU_CPTO 435
91 #define ROMENU_COPY 436
92 #define ROMENU_SELALL 437
93 #define ROMENU_PROP 438
94 #define ROMENU_EDIT 439
95 #define ROMENU_FDMSG 440
96 #define ROMENU_FULL 441
97 #define ROMENU_ABB 442
98 #define ROMENU_BYDATE 443
99 #define ROMENU_BYSEND 444
100 #define ROMENU_BYSUB 445
101 #define ROMENU_BYSIZE 446
102 #define ROMENU_BYSTAT 447
103 #define ROMENU_VIEW 448
104 #define ROMENU_HDR 449
105 #define ROMENU_NEWMSG 450
106 #define ROMENU_NEWINCL 451
107 #define ROMENU_FORWARD 452
108 #define ROMENU_REPLY 453
109 #define ROMENU_RPYALL 454
110 #define ROMENU_RPYINCL 455
111 #define ROMENU_RPYAINCL 456
112 #define ROMENU_COMP 457
113 #define ROMENU_VAC 458
114 #define ROMENU_ONITEM 459
115 #define ROMENU_ONAPP 460
116 #define ROMENU_ONVER 461
117 #define ROMENU_HELP 462
118 #define ROMENU_LOADING 463
119 #define ROMENU_CON 464
120 #define ROMENU_DELMSG 465
121 #define ROMENU_NOEMPTY 466
122 #define ROMENU_EMPTY_CONT 467
123 #define ROMENU_EMPTY_NOFILE 468
124 #define ROMENU_MOVE 469
125 #define ROMENU_RELNOTES 470
127 class RoamMenuWindow : public MenuWindow, public AbstractEditorParent
130 RoamMenuWindow(char*);
131 virtual ~RoamMenuWindow();
132 virtual void initialize();
133 virtual void manage();
136 Widget GetMainWin() { return _main; }
137 // Popup Menu Event Handler
138 static void MenuButtonHandler(Widget, XtPointer, XEvent*, Boolean*);
139 static void ShowErrMsg(char*, Boolean, void*);
141 void attachmentFeedback(Boolean);
142 void checkForMail(DtMailEnv &error)
143 { _we_called_newmail = TRUE; _mailbox->checkForMail(error); }
144 virtual const char *const
145 className() { return "RoamMenuWindow"; }
146 void create_new_container(char*);
147 Widget getDragIcon(Widget widget);
148 void load_mailbox(DtMailEnv &mail_error);
150 msgListDragStart(Widget, XEvent*, String*, Cardinal*);
152 static void msgListConvertCallback( Widget, XtPointer, XtPointer);
153 void msgListDropRegister();
154 void msgListDropEnable();
155 void msgListDropDisable();
156 static void msgListDragFinishCallback(Widget, XtPointer, XtPointer);
157 void msgListDragSetup();
158 static Bool msgListLookForButton(Display*, XEvent*, XPointer);
159 static void msgListProcessPress(Widget, XEvent*, String*, Cardinal*);
160 static void msgListTransferCallback(Widget, XtPointer, XtPointer);
161 void open(DtMailEnv &, DtMailBoolean, DtMailBoolean);
162 void open_and_load(DtMailEnv &, DtMailBoolean, DtMailBoolean);
163 virtual void panicQuit();
164 void postErrorDialog(DtMailEnv&);
165 void propsChanged(void);
166 virtual void quit(Boolean delete_win = FALSE);
167 void quit_silently();
168 void reopen_mail_file();
169 void removeVacationTitle(void);
170 void setVacationTitle(void);
171 void setTitle(char *suffix);
172 void startAutoSave();
174 void sync_work_area_size();
176 void view_mail_file(char*, DtMailBoolean create = DTM_FALSE);
179 //-------------------------------------------------------------------------
181 //-------------------------------------------------------------------------
183 DtMailEditor *get_editor() { return(_my_editor); }
184 ViewMsgDialog *msgView()
186 if ( _numDialogs==0 )
189 return _dialogs[_numDialogs-1];
191 FindDialog *get_find_dialog();
192 DtMail::MailBox *mailbox() { return _mailbox; }
193 MenuBar *menuBar() { return _menuBar; }
194 MsgScrollingList *list() { return _list; }
195 DtMailGenDialog *genDialog() { return _genDialog; }
196 Widget workArea() { return _workArea;}
197 Boolean fullHeader() { return _full_header_resource; }
198 char *mailboxName() { return _mailbox_name; }
199 unsigned int x() { return _x; }
200 unsigned int y() { return _y; }
201 unsigned int width() { return _width; }
202 unsigned int height() { return _height; }
203 char *mailbox_fullpath() { return _mailbox_fullpath; }
205 //-----------------------------------------------------------------------
207 //-----------------------------------------------------------------------
209 void addToRowOfButtons();
210 void addToRowOfLabels(MsgScrollingList *msglist);
211 void addToRowOfMessageStatus();
213 void clearStatus(void);
214 void forwardFilename(char*);
215 char *forwardFilename();
216 void fullHeader(Boolean flag);
217 ViewMsgDialog *ifViewExists(DtMailMessageHandle msg_num);
219 SortBy last_sorted_by(void) { return _last_sorted_by; }
220 void last_sorted_by(SortBy type);
221 void message( char * );
222 void message_summary();
223 void message_summary(int msgn, int nmsgs, int nnew, int ndeleted);
224 void message_selected(int msgn, int nmsgs, int nnew, int ndeleted);
225 void mailboxName( char *name)
227 if (NULL != _mailbox_name) free((void*)_mailbox_name);
228 _mailbox_name=strdup( name );
230 void mailboxFullpath( char *path)
232 if (NULL != _mailbox_fullpath) free((void*)_mailbox_fullpath);
233 _mailbox_fullpath=strdup( path );
235 void registerDialog(ViewMsgDialog*);
236 void setStatus(const char *);
237 void set_find_dialog(FindDialog *dialog) { _findDialog = dialog; }
238 void showMessageFullHeaders(Boolean);
239 void unregisterDialog(ViewMsgDialog*);
241 void construct_file_menu();
242 void construct_message_menu();
243 void construct_edit_menu();
244 void construct_view_menu();
245 void construct_compose_menu();
246 void construct_move_menu();
247 void construct_attachment_menu();
248 void construct_attachment_popup(void);
249 void construct_text_popup(void);
250 void construct_message_popup();
251 void construct_help_menu();
254 *get_undel_dialog() {return _msg_undelete_from_list->dialog();}
257 void clear_message();
258 int inList(char *filename, DtVirtArray<ContainerMenuCmd *> *);
259 void addToCachedContainerList(char *filename);
260 void syncCachedContainerList();
261 void newMailIndicators(void);
263 int queryExpunge(void);
264 Boolean requiredConversion() {return _required_conversion;}
266 virtual void text_selected();
267 virtual void text_unselected();
269 void attachment_selected();
270 void all_attachments_deselected();
271 void all_attachments_selected();
272 void selectAllAttachments();
273 void add_att(char *) { ; }
274 void add_att(char *, DtMailBuffer) { ; }
275 void add_att(DtMailBuffer) { ; }
276 void activate_default_attach_menu();
277 void deactivate_default_attach_menu();
278 void activate_default_message_menu();
279 void deactivate_default_message_menu();
280 void showAttachArea();
281 void hideAttachArea();
282 void addAttachmentActions(char **, int);
283 void removeAttachmentActions();
284 void invokeAttachmentAction(int);
285 void save_selected_attachment(char *);
286 int showConversionStatus(int, int);
287 void conversionFinished();
288 void convert(char *, char *);
289 void resetCacheList(int new_size);
291 // syncViewAndStore() does the sync-ing of the view of a mail
292 // container and the storage of that container.
293 // E.g., this callback and therefore the method gets invoked every
294 // time a message gets expunged by the back end based on "timed delete".
296 // The method needs to then remove the expunged message from the
297 // deleted messages list, thereby syncing the view to be always
298 // current with the storage.
299 // Similarly, the method also gets invoked when the container store
300 // has received new mail. The view then needs to be updated....
302 DtMailBoolean syncViewAndStore(DtMailCallbackOp, const char*, va_list);
304 // Static public methods now.
305 static DtMailBoolean syncViewAndStoreCallback(
308 const char * prompt_hint,
311 static int ConvertStatusCB(int current, int total, void *);
312 virtual void postMsgsPopup(XEvent *event);
313 inline Boolean IsLoaded () { return _is_loaded; }
316 static RoamMenuWindow
317 *restoreSession(char*);
318 virtual int smpSaveSessionGlobal(void);
319 virtual void smpSaveSessionLocal(void);
323 Boolean _checkformail_when_mapped;
324 Boolean _delete_on_quit;
325 char *_forward_filename;
326 Boolean _full_header_resource;
327 SortBy _last_sorted_by;
328 char *_mail_files_resource;
329 char *_mailbox_fullpath;
331 char *_mailbox_name_resource;
332 Boolean _required_conversion;
333 Boolean _we_called_newmail;
335 ViewMsgDialog **_dialogs;
337 FindDialog *_findDialog;
342 int _display_cached_list;
344 int _first_cached_item;
345 int _max_cached_list_size;
346 DtVirtArray<ContainerMenuCmd *> *_user_containerlist;
347 DtVirtArray<ContainerMenuCmd *> *_cached_containerlist;
352 CmdList *_file_cmdlist;
353 Cmd *_file_separator;
354 CheckForNewMailCmd *_file_check_new_mail;
355 Cmd *_file_open_inbox;
356 UnifiedSelectMailboxCmd *_file_new_container;
357 UnifiedSelectMailboxCmd *_file_open;
358 Cmd *_file_destroy_deleted_msgs;
360 Widget _file_cascade;
365 CmdList *_open_container_cmdlist;
366 Cmd *_open_container_separator;
367 Cmd *_open_container_inbox;
368 UnifiedSelectMailboxCmd
369 *_open_container_other;
371 DtVirtArray<ContainerMenuCmd *> *_open_container_containerlist;
372 DtVirtArray<ContainerMenuCmd *> *_open_container_containerlist_cached;
373 Widget _opencontainerMenu;
378 CmdList *_msg_cmdlist;
384 Cmd *_msg_select_all;
386 Cmd *_msg_undelete_last;
387 UndeleteCmd *_msg_undelete_from_list;
390 // CopyTo Cascade Menu
392 CmdList *_copyto_cmdlist;
393 Cmd *_copyto_separator;
394 CopyToInboxCmd *_copyto_inbox;
397 DtVirtArray<ContainerMenuCmd *> *_copyto_containerlist;
398 DtVirtArray<ContainerMenuCmd *> *_copyto_containerlist_cached;
400 Widget _message_cascade;
405 CmdList *_edit_cmdlist;
407 Cmd *_edit_select_all;
412 CmdList *_att_cmdlist;
414 Cmd *_att_select_all;
419 CmdList *_view_cmdlist;
420 Cmd *_view_separator;
423 Cmd *_view_abbrev_headers;
425 Cmd *_view_sortSender;
426 Cmd *_view_sortSubject;
428 Cmd *_view_sortStatus;
433 CmdList *_comp_cmdlist;
434 Cmd *_comp_separator;
436 Cmd *_comp_new_include;
438 Cmd *_comp_replySender;
440 Cmd *_comp_replySinclude;
441 Cmd *_comp_replyAinclude;
446 CmdList *_move_cmdlist;
447 Cmd *_move_separator;
448 MoveToInboxCmd *_move_inbox;
451 DtVirtArray<ContainerMenuCmd *> *_move_containerlist;
452 DtVirtArray<ContainerMenuCmd *> *_move_containerlist_cached;
454 Widget _move_cascade;
459 CmdList *_help_cmdlist;
460 Cmd *_help_separator;
463 Cmd *_help_reference;
465 Cmd *_help_using_help;
466 Cmd *_help_about_mailer;
471 CmdList *_msgsPopup_cmdlist;
472 Cmd *_msgsPopup_separator;
474 MenuBar *_menuPopupMsgs;
475 Widget _msgsPopupMenu;
476 Widget _msgsPopupMoveMenu;
481 CmdList *_textPopup_cmdlist;
482 Cmd *_textPopup_separator;
487 CmdList *_attPopup_cmdlist;
488 Cmd *_attPopup_separator;
489 CmdList *_attActions_cmdlist;
491 Widget _attachmentMenu;
494 // Message filing interface
496 ConvertContainerCmd *_convertContainerCmd;
497 OpenContainerCmd *_openContainerCmd;
500 // This is the set of buttons below the scrolling list
501 // They get used in the addToRowOfButtons() method
503 DeleteCmd *_delete_button;
505 Cmd *_previous_button;
506 Cmd *_replySender_button;
508 Cmd *_move_copy_button;
511 DtMail::MailBox *_mailbox;
513 MsgScrollingList *_list;
514 DtMailGenDialog *_genDialog;
516 Widget createWorkArea ( Widget );
517 void createMenuPanes();
518 void createContainerList();
519 void createOpenContainerList(CmdList *);
520 void createCopyList(CmdList *);
521 void configurenotify(
532 static XtResource _resources[];
533 static char *_supported[];
541 unsigned int _height;
542 unsigned int _border_width;
543 Dimension _workarea_width;
544 Dimension _workarea_height;
546 DtMailEditor *_my_editor;
548 Widget _message_summary;
550 Widget _rowOfButtons;
551 Widget _rowOfMessageStatus;
552 XtWorkProcId _quitWorkprocID;
553 Boolean _clear_message_p;
554 Boolean _create_mailbox_file;
556 Boolean _open_create_flag;
557 Boolean _open_lock_flag;
560 // Message header list column labels
567 XmString _sender_xms;
568 XmString _subject_xms;
572 XmString _sender_key_xms;
573 XmString _subject_key_xms;
574 XmString _date_key_xms;
575 XmString _size_key_xms;
577 static void ownselectionCallback(Widget, XtPointer, XtPointer );
578 static void structurenotify(Widget, XtPointer, XEvent *, Boolean *);
579 static void file_selection_callback(void *, char * );
580 static void create_container_callback(void *, char * );
581 static void move_callback(void *, char *);
582 static void copy_callback(void *, char *);
583 static void save_attachment_callback(void *, char *);
584 static void delete_attachment_callback(void *, char *);
585 static void conversionFinishedCallback(
586 RoamInterruptibleCmd *,
589 static void map_menu( Widget, XtPointer, XtPointer );
590 static Boolean quitWorkproc(XtPointer);