Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtmail / dtmail / RoamMenuWindow.h
1 /*
2  *+SNOTICE
3  *
4  *      $TOG: RoamMenuWindow.h /main/29 1999/02/03 18:01:26 mgreess $
5  *
6  *      RESTRICTED CONFIDENTIAL INFORMATION:
7  *      
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
14  *      Sun's request.
15  *
16  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
17  *
18  *+ENOTICE
19  */
20
21 #ifndef ROAMMENUWINDOW_H
22 #define ROAMMENUWINDOW_H
23
24 //-----------------------------------------------------------------------------
25     // Roam window for viewing messages
26 //-----------------------------------------------------------------------------
27
28 #include <DtMail/DtMail.hh>
29
30 #include "MenuWindow.h"
31 #include "MenuBar.h"
32 #include "DtMailGenDialog.hh"
33 #include "NoOpCmd.h"
34 #include "QuitCmd.h"
35 #include "UndoCmd.h"
36 #include "IconifyCmd.h"
37 #include "CmdList.h"
38 #include "RoamCmds.h"
39 #include "Sort.hh"
40 #include "ViewMsgDialog.h"
41 #include <DtMail/DtMailError.hh>
42 #include "MsgScrollingList.hh"
43 #include "AttachArea.h"
44 #include "FindDialog.h"
45 #include "Editor.hh"
46
47 //#include "CDEM_CoeEd.hh"
48
49 #include "DtMailEditor.hh"
50
51 #include "Undelete.hh"
52
53 /*  ROMENU_*       msgid 400 - 499
54  */
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
126     
127 class RoamMenuWindow : public MenuWindow, public AbstractEditorParent
128 {
129   public:       
130                 RoamMenuWindow(char*);
131     virtual     ~RoamMenuWindow();  
132     virtual void initialize();
133     virtual void manage();
134
135     void        Full(Boolean);
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*);
140
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);
149     static XtActionProc
150                 msgListDragStart(Widget, XEvent*, String*, Cardinal*);
151                 // DND: Drop Site
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();
173     void        stopAutoSave();
174     void        sync_work_area_size();
175     Boolean     vacation();
176     void        view_mail_file(char*, DtMailBoolean create = DTM_FALSE);
177
178         
179 //-------------------------------------------------------------------------
180 //              Accessors
181 //-------------------------------------------------------------------------
182
183     DtMailEditor        *get_editor() { return(_my_editor); }
184     ViewMsgDialog       *msgView()
185                         {
186                           if ( _numDialogs==0 )
187                             return 0;
188                           else
189                             return _dialogs[_numDialogs-1];
190                         }
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; }
204         
205 //-----------------------------------------------------------------------
206             // Mutators
207 //-----------------------------------------------------------------------
208             
209     void        addToRowOfButtons();
210     void        addToRowOfLabels(MsgScrollingList *msglist);
211     void        addToRowOfMessageStatus();
212
213     void        clearStatus(void);
214     void        forwardFilename(char*);
215     char        *forwardFilename();
216     void        fullHeader(Boolean flag);
217     ViewMsgDialog *ifViewExists(DtMailMessageHandle msg_num);
218     Boolean     inbox();
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)
226                 {
227                   if (NULL != _mailbox_name) free((void*)_mailbox_name);
228                   _mailbox_name=strdup( name );
229                 }
230     void        mailboxFullpath( char *path)
231                 {
232                   if (NULL != _mailbox_fullpath) free((void*)_mailbox_fullpath);
233                   _mailbox_fullpath=strdup( path );
234                 }
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*);  
240     
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();
252
253     UndelFromListDialog
254                 *get_undel_dialog() {return _msg_undelete_from_list->dialog();}
255     DtMail::MailRc
256                 *get_mail_rc();
257     void        clear_message();
258     int         inList(char *filename, DtVirtArray<ContainerMenuCmd *> *);
259     void        addToCachedContainerList(char *filename);
260     void        syncCachedContainerList();
261     void        newMailIndicators(void);
262     void        expunge(void);
263     int         queryExpunge(void);
264     Boolean     requiredConversion()    {return _required_conversion;}
265     
266     virtual void text_selected();
267     virtual void text_unselected();
268
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);
290
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".
295     // 
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....
301
302     DtMailBoolean syncViewAndStore(DtMailCallbackOp, const char*, va_list);
303
304     // Static public methods now.
305     static DtMailBoolean syncViewAndStoreCallback(
306                             DtMailCallbackOp op,
307                             const char * path,
308                             const char * prompt_hint,
309                             void * client_data,
310                             ...);
311     static int          ConvertStatusCB(int current, int total, void *);
312     virtual void        postMsgsPopup(XEvent *event);
313     inline Boolean      IsLoaded ()     { return _is_loaded; }
314
315     // XSMP support
316     static RoamMenuWindow
317                         *restoreSession(char*);
318     virtual int         smpSaveSessionGlobal(void);
319     virtual void        smpSaveSessionLocal(void);
320
321  protected:
322         
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;
330     char                *_mailbox_name;
331     char                *_mailbox_name_resource;
332     Boolean              _required_conversion;
333     Boolean              _we_called_newmail;
334     
335     ViewMsgDialog       **_dialogs;
336     int                  _numDialogs;
337     FindDialog          *_findDialog;
338     
339     //
340     // ContainerList
341     //
342     int                  _display_cached_list;
343     char                *_filemenu2;
344     int                  _first_cached_item;
345     int                  _max_cached_list_size;
346     DtVirtArray<ContainerMenuCmd *>     *_user_containerlist;
347     DtVirtArray<ContainerMenuCmd *>     *_cached_containerlist;
348
349     //
350     // File Menu
351     //
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;
359     Cmd                 *_file_quit;
360     Widget               _file_cascade;
361     
362     //
363     // Open Cascade Menu
364     //
365     CmdList             *_open_container_cmdlist;
366     Cmd                 *_open_container_separator;
367     Cmd                 *_open_container_inbox;
368     UnifiedSelectMailboxCmd
369                         *_open_container_other;
370
371     DtVirtArray<ContainerMenuCmd *> *_open_container_containerlist;
372     DtVirtArray<ContainerMenuCmd *> *_open_container_containerlist_cached;
373     Widget              _opencontainerMenu;
374     
375     //
376     // Message Menu
377     //
378     CmdList             *_msg_cmdlist;
379     Cmd                 *_msg_separator;
380     Cmd                 *_msg_open;
381     Cmd                 *_msg_save_as;
382     Cmd                 *_msg_print;
383     Cmd                 *_msg_find;
384     Cmd                 *_msg_select_all;
385     Cmd                 *_msg_delete;
386     Cmd                 *_msg_undelete_last;
387     UndeleteCmd         *_msg_undelete_from_list;
388     
389     //
390     // CopyTo Cascade Menu
391     //
392     CmdList             *_copyto_cmdlist;
393     Cmd                 *_copyto_separator;
394     CopyToInboxCmd      *_copyto_inbox;
395     Cmd                 *_copyto_other;
396
397     DtVirtArray<ContainerMenuCmd *> *_copyto_containerlist;
398     DtVirtArray<ContainerMenuCmd *> *_copyto_containerlist_cached;
399     Widget              _copytoMenu;
400     Widget              _message_cascade;
401     
402     //
403     // Edit Menu
404     //
405     CmdList             *_edit_cmdlist;
406     Cmd                 *_edit_copy;
407     Cmd                 *_edit_select_all;
408     
409     //
410     // Attachments Menu  
411     //
412     CmdList             *_att_cmdlist;
413     Cmd                 *_att_save;
414     Cmd                 *_att_select_all;
415     
416     //
417     // View Menu  
418     //
419     CmdList             *_view_cmdlist;
420     Cmd                 *_view_separator;
421     Cmd                 *_view_next;
422     Cmd                 *_view_previous;
423     Cmd                 *_view_abbrev_headers;
424     Cmd                 *_view_sortTD;
425     Cmd                 *_view_sortSender;      
426     Cmd                 *_view_sortSubject;     
427     Cmd                 *_view_sortSize;        
428     Cmd                 *_view_sortStatus;
429     
430     //
431     // Compose Menu
432     //
433     CmdList             *_comp_cmdlist;
434     Cmd                 *_comp_separator;
435     Cmd                 *_comp_new;
436     Cmd                 *_comp_new_include;
437     Cmd                 *_comp_forward;
438     Cmd                 *_comp_replySender;
439     Cmd                 *_comp_replyAll;
440     Cmd                 *_comp_replySinclude;
441     Cmd                 *_comp_replyAinclude;
442     
443     //
444     // Move Menu
445     //
446     CmdList             *_move_cmdlist;
447     Cmd                 *_move_separator;
448     MoveToInboxCmd      *_move_inbox;
449     Cmd                 *_move_other;
450
451     DtVirtArray<ContainerMenuCmd *> *_move_containerlist;
452     DtVirtArray<ContainerMenuCmd *> *_move_containerlist_cached;
453     Widget              _moveMenu;
454     Widget              _move_cascade;
455
456     //
457     // Help Menu
458     //
459     CmdList             *_help_cmdlist;
460     Cmd                 *_help_separator;
461     Cmd                 *_help_overview;
462     Cmd                 *_help_tasks;
463     Cmd                 *_help_reference;
464     Cmd                 *_help_on_item;
465     Cmd                 *_help_using_help;
466     Cmd                 *_help_about_mailer;
467     
468     //
469     // Message Popup
470     //
471     CmdList             *_msgsPopup_cmdlist;
472     Cmd                 *_msgsPopup_separator;
473
474     MenuBar             *_menuPopupMsgs;
475     Widget              _msgsPopupMenu;
476     Widget              _msgsPopupMoveMenu;
477
478     //
479     // Text Popup
480     //
481     CmdList             *_textPopup_cmdlist;
482     Cmd                 *_textPopup_separator;
483
484     //
485     // Attachments Popup
486     //
487     CmdList             *_attPopup_cmdlist;
488     Cmd                 *_attPopup_separator;
489     CmdList             *_attActions_cmdlist;
490
491     Widget              _attachmentMenu;
492
493     //
494     // Message filing interface
495     //
496     ConvertContainerCmd *_convertContainerCmd;
497     OpenContainerCmd    *_openContainerCmd;
498     
499     //
500     // This is the set of buttons below the scrolling list
501     // They get used in the addToRowOfButtons() method
502     //
503     DeleteCmd           *_delete_button;
504     Cmd                 *_next_button;
505     Cmd                 *_previous_button;
506     Cmd                 *_replySender_button;
507     Cmd                 *_print_button;
508     Cmd                 *_move_copy_button;
509
510     
511     DtMail::MailBox     *_mailbox;
512     Boolean             _inbox;
513     MsgScrollingList    *_list;
514     DtMailGenDialog     *_genDialog;
515     
516     Widget      createWorkArea ( Widget );
517     void        createMenuPanes();
518     void        createContainerList();
519     void        createOpenContainerList(CmdList *);
520     void        createCopyList(CmdList *);
521     void        configurenotify(
522                     unsigned int,
523                     unsigned int,
524                     unsigned int, 
525                     unsigned int,
526                     unsigned int);
527     void        mapnotify();
528
529     
530   private:
531     
532     static XtResource   _resources[];
533     static char         *_supported[];
534
535     Pixmap              _mbox_image;
536     Pixmap              _mbox_mask;
537
538     unsigned int        _x;
539     unsigned int        _y;
540     unsigned int        _width;
541     unsigned int        _height;
542     unsigned int        _border_width;
543     Dimension           _workarea_width;
544     Dimension           _workarea_height;
545     
546     DtMailEditor        *_my_editor;
547     Widget              _message;
548     Widget              _message_summary;
549     Widget              _rowOfLabels;
550     Widget              _rowOfButtons;
551     Widget              _rowOfMessageStatus;
552     XtWorkProcId        _quitWorkprocID;
553     Boolean             _clear_message_p;
554     Boolean             _create_mailbox_file;
555     Boolean             _is_loaded;
556     Boolean             _open_create_flag;
557     Boolean             _open_lock_flag;
558
559     //
560     // Message header list column labels
561     //
562     Widget              _sender_lbl;
563     Widget              _subject_lbl;
564     Widget              _date_lbl;
565     Widget              _size_lbl;
566
567     XmString            _sender_xms;
568     XmString            _subject_xms;
569     XmString            _date_xms;
570     XmString            _size_xms;
571
572     XmString            _sender_key_xms;
573     XmString            _subject_key_xms;
574     XmString            _date_key_xms;
575     XmString            _size_key_xms;
576
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 *,
587                         Boolean,
588                         void *);
589     static void map_menu( Widget, XtPointer, XtPointer );
590     static Boolean quitWorkproc(XtPointer);
591 };
592
593 #endif