-fpermissive to allow GCC to compile old C++
[oweals/cde.git] / cde / programs / dtmail / dtmail / RoamMenuWindow.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /*
24  *+SNOTICE
25  *
26  *      $TOG: RoamMenuWindow.h /main/29 1999/02/03 18:01:26 mgreess $
27  *
28  *      RESTRICTED CONFIDENTIAL INFORMATION:
29  *      
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
36  *      Sun's request.
37  *
38  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
39  *
40  *+ENOTICE
41  */
42
43 #ifndef ROAMMENUWINDOW_H
44 #define ROAMMENUWINDOW_H
45
46 //-----------------------------------------------------------------------------
47     // Roam window for viewing messages
48 //-----------------------------------------------------------------------------
49
50 #include <DtMail/DtMail.hh>
51
52 #include "MenuWindow.h"
53 #include "MenuBar.h"
54 #include "DtMailGenDialog.hh"
55 #include "NoOpCmd.h"
56 #include "QuitCmd.h"
57 #include "UndoCmd.h"
58 #include "IconifyCmd.h"
59 #include "CmdList.h"
60 #include "RoamCmds.h"
61 #include "Sort.hh"
62 #include "ViewMsgDialog.h"
63 #include <DtMail/DtMailError.hh>
64 #include "MsgScrollingList.hh"
65 #include "AttachArea.h"
66 #include "FindDialog.h"
67 #include "Editor.hh"
68
69 //#include "CDEM_CoeEd.hh"
70
71 #include "DtMailEditor.hh"
72
73 #include "Undelete.hh"
74
75 /*  ROMENU_*       msgid 400 - 499
76  */
77 #define ROMENU_NOINIT    400
78 #define ROMENU_NEWM      401
79 #define ROMENU_STAT      402
80 #define ROMENU_SUM       403
81 #define ROMENU_SEL       404
82 #define ROMENU_NOOPEN    405
83 #define ROMENU_NOCREAT   406
84 #define ROMENU_NOCRT     407
85 #define ROMENU_CREAT     408
86 #define ROMENU_LOAD      409
87 #define ROMENU_INFO      410
88 #define ROMENU_EMPTYC    411
89 #define ROMENU_NEXT      412
90 #define ROMENU_PREV      413
91 #define ROMENU_PRT       414
92 #define ROMENU_MVCP      415
93 #define ROMENU_SENDER    416
94 #define ROMENU_SUB       417
95 #define ROMENU_DATE      418
96 #define ROMENU_SIZE      419
97 #define ROMENU_OPENBOX   420
98 #define ROMENU_NEW       421
99 #define ROMENU_OPEN      422
100 #define ROMENU_EMPTY     423
101 #define ROMENU_SAVEAS    424
102 #define ROMENU_CLOSE     425
103 #define ROMENU_OPMSG     426
104 #define ROMENU_SAVEMSG   427
105 #define ROMENU_PRINT     428
106 #define ROMENU_DEL       429
107 #define ROMENU_LAST      430
108 #define ROMENU_LIST      431
109 #define ROMENU_UNDEL     432
110 #define ROMENU_MSG       433
111 #define ROMENU_UNDMSG    434
112 #define ROMENU_CPTO      435
113 #define ROMENU_COPY      436
114 #define ROMENU_SELALL    437
115 #define ROMENU_PROP      438
116 #define ROMENU_EDIT      439
117 #define ROMENU_FDMSG     440
118 #define ROMENU_FULL      441
119 #define ROMENU_ABB       442
120 #define ROMENU_BYDATE    443
121 #define ROMENU_BYSEND    444
122 #define ROMENU_BYSUB     445
123 #define ROMENU_BYSIZE    446
124 #define ROMENU_BYSTAT    447
125 #define ROMENU_VIEW      448
126 #define ROMENU_HDR       449
127 #define ROMENU_NEWMSG    450
128 #define ROMENU_NEWINCL   451
129 #define ROMENU_FORWARD   452
130 #define ROMENU_REPLY     453
131 #define ROMENU_RPYALL    454
132 #define ROMENU_RPYINCL   455
133 #define ROMENU_RPYAINCL  456
134 #define ROMENU_COMP      457
135 #define ROMENU_VAC       458
136 #define ROMENU_ONITEM    459
137 #define ROMENU_ONAPP     460
138 #define ROMENU_ONVER     461
139 #define ROMENU_HELP      462
140 #define ROMENU_LOADING   463
141 #define ROMENU_CON       464
142 #define ROMENU_DELMSG    465
143 #define ROMENU_NOEMPTY   466
144 #define ROMENU_EMPTY_CONT     467
145 #define ROMENU_EMPTY_NOFILE   468
146 #define ROMENU_MOVE     469
147 #define ROMENU_RELNOTES 470
148     
149 class RoamMenuWindow : public MenuWindow, public AbstractEditorParent
150 {
151   public:       
152                 RoamMenuWindow(char*);
153     virtual     ~RoamMenuWindow();  
154     virtual void initialize();
155     virtual void manage();
156
157     void        Full(Boolean);
158     Widget      GetMainWin() { return _main; }
159                 // Popup Menu Event Handler
160     static void MenuButtonHandler(Widget, XtPointer, XEvent*, Boolean*);
161     static void ShowErrMsg(char*, Boolean, void*);
162
163     void        attachmentFeedback(Boolean);
164     void        checkForMail(DtMailEnv &error)
165                   { _we_called_newmail = TRUE; _mailbox->checkForMail(error); }
166     virtual const char *const
167                 className() { return "RoamMenuWindow"; }
168     void        create_new_container(char*);
169     Widget      getDragIcon(Widget widget);
170     void        load_mailbox(DtMailEnv &mail_error);
171     static XtActionProc
172                 msgListDragStart(Widget, XEvent*, String*, Cardinal*);
173                 // DND: Drop Site
174     static void msgListConvertCallback( Widget, XtPointer, XtPointer);
175     void        msgListDropRegister();
176     void        msgListDropEnable();
177     void        msgListDropDisable();
178     static void msgListDragFinishCallback(Widget, XtPointer, XtPointer);
179     void        msgListDragSetup();
180     static Bool msgListLookForButton(Display*, XEvent*, XPointer);
181     static void msgListProcessPress(Widget, XEvent*, String*, Cardinal*);
182     static void msgListTransferCallback(Widget, XtPointer, XtPointer);
183     void        open(DtMailEnv &, DtMailBoolean, DtMailBoolean);
184     void        open_and_load(DtMailEnv &, DtMailBoolean, DtMailBoolean);
185     virtual void panicQuit();
186     void        postErrorDialog(DtMailEnv&);
187     void        propsChanged(void);
188     virtual void quit(Boolean delete_win = FALSE);
189     void        quit_silently();
190     void        reopen_mail_file();
191     void        removeVacationTitle(void);
192     void        setVacationTitle(void);
193     void        setTitle(char *suffix);
194     void        startAutoSave();
195     void        stopAutoSave();
196     void        sync_work_area_size();
197     Boolean     vacation();
198     void        view_mail_file(char*, DtMailBoolean create = DTM_FALSE);
199
200         
201 //-------------------------------------------------------------------------
202 //              Accessors
203 //-------------------------------------------------------------------------
204
205     DtMailEditor        *get_editor() { return(_my_editor); }
206     ViewMsgDialog       *msgView()
207                         {
208                           if ( _numDialogs==0 )
209                             return 0;
210                           else
211                             return _dialogs[_numDialogs-1];
212                         }
213     FindDialog          *get_find_dialog();
214     DtMail::MailBox     *mailbox()      { return _mailbox; }
215     MenuBar             *menuBar()      { return _menuBar; }
216     MsgScrollingList    *list()         { return _list; }
217     DtMailGenDialog     *genDialog()    { return _genDialog; }
218     Widget              workArea()      { return _workArea;} 
219     Boolean             fullHeader()    { return _full_header_resource; }
220     char                *mailboxName()  { return _mailbox_name; }  
221     unsigned int        x()             { return _x; }
222     unsigned int        y()             { return _y; }
223     unsigned int        width()         { return _width; }
224     unsigned int        height()        { return _height; }
225     char                *mailbox_fullpath() { return _mailbox_fullpath; }
226         
227 //-----------------------------------------------------------------------
228             // Mutators
229 //-----------------------------------------------------------------------
230             
231     void        addToRowOfButtons();
232     void        addToRowOfLabels(MsgScrollingList *msglist);
233     void        addToRowOfMessageStatus();
234
235     void        clearStatus(void);
236     void        forwardFilename(char*);
237     char        *forwardFilename();
238     void        fullHeader(Boolean flag);
239     ViewMsgDialog *ifViewExists(DtMailMessageHandle msg_num);
240     Boolean     inbox();
241     SortBy      last_sorted_by(void) { return _last_sorted_by; }
242     void        last_sorted_by(SortBy type);
243     void        message( char * );
244     void        message_summary();
245     void        message_summary(int msgn, int nmsgs, int nnew, int ndeleted);
246     void        message_selected(int msgn, int nmsgs, int nnew, int ndeleted);
247     void        mailboxName( char *name)
248                 {
249                   if (NULL != _mailbox_name) free((void*)_mailbox_name);
250                   _mailbox_name=strdup( name );
251                 }
252     void        mailboxFullpath( char *path)
253                 {
254                   if (NULL != _mailbox_fullpath) free((void*)_mailbox_fullpath);
255                   _mailbox_fullpath=strdup( path );
256                 }
257     void        registerDialog(ViewMsgDialog*);
258     void        setStatus(const char *);
259     void        set_find_dialog(FindDialog *dialog) { _findDialog = dialog; }
260     void        showMessageFullHeaders(Boolean);
261     void        unregisterDialog(ViewMsgDialog*);  
262     
263     void        construct_file_menu();
264     void        construct_message_menu();
265     void        construct_edit_menu();
266     void        construct_view_menu();
267     void        construct_compose_menu();
268     void        construct_move_menu();
269     void        construct_attachment_menu();
270     void        construct_attachment_popup(void);
271     void        construct_text_popup(void);
272     void        construct_message_popup();
273     void        construct_help_menu();
274
275     UndelFromListDialog
276                 *get_undel_dialog() {return _msg_undelete_from_list->dialog();}
277     DtMail::MailRc
278                 *get_mail_rc();
279     void        clear_message();
280     int         inList(char *filename, DtVirtArray<ContainerMenuCmd *> *);
281     void        addToCachedContainerList(char *filename);
282     void        syncCachedContainerList();
283     void        newMailIndicators(void);
284     void        expunge(void);
285     int         queryExpunge(void);
286     Boolean     requiredConversion()    {return _required_conversion;}
287     
288     virtual void text_selected();
289     virtual void text_unselected();
290
291     void        attachment_selected();
292     void        all_attachments_deselected();
293     void        all_attachments_selected();
294     void        selectAllAttachments();
295     void        add_att(char *) { ; }
296     void        add_att(char *, DtMailBuffer)   { ; }
297     void        add_att(DtMailBuffer)           { ; }
298     void        activate_default_attach_menu();
299     void        deactivate_default_attach_menu();
300     void        activate_default_message_menu();
301     void        deactivate_default_message_menu();      
302     void        showAttachArea();
303     void        hideAttachArea();
304     void        addAttachmentActions(char **, int);
305     void        removeAttachmentActions();
306     void        invokeAttachmentAction(int);
307     void        save_selected_attachment(char *);
308     int         showConversionStatus(int, int);
309     void        conversionFinished();
310     void        convert(char *, char *);
311     void        resetCacheList(int new_size);
312
313     // syncViewAndStore() does the sync-ing of the view of a mail
314     // container and the storage of that container.
315     // E.g., this callback and therefore the method gets invoked every 
316     // time a message gets expunged by the back end based on "timed delete".
317     // 
318     // The method needs to then remove the expunged message from the
319     // deleted messages list, thereby syncing the view to be always
320     // current with the storage.
321     // Similarly, the method also gets invoked when the container store
322     // has received new mail.  The view then needs to be updated....
323
324     DtMailBoolean syncViewAndStore(DtMailCallbackOp, const char*, va_list);
325
326     // Static public methods now.
327     static DtMailBoolean syncViewAndStoreCallback(
328                             DtMailCallbackOp op,
329                             const char * path,
330                             const char * prompt_hint,
331                             void * client_data,
332                             ...);
333     static int          ConvertStatusCB(int current, int total, void *);
334     virtual void        postMsgsPopup(XEvent *event);
335     inline Boolean      IsLoaded ()     { return _is_loaded; }
336
337     // XSMP support
338     static RoamMenuWindow
339                         *restoreSession(char*);
340     virtual int         smpSaveSessionGlobal(void);
341     virtual void        smpSaveSessionLocal(void);
342
343  protected:
344         
345     Boolean              _checkformail_when_mapped;
346     Boolean              _delete_on_quit;
347     char                *_forward_filename;
348     Boolean              _full_header_resource;
349     SortBy               _last_sorted_by;
350     char                *_mail_files_resource;
351     char                *_mailbox_fullpath;
352     char                *_mailbox_name;
353     char                *_mailbox_name_resource;
354     Boolean              _required_conversion;
355     Boolean              _we_called_newmail;
356     
357     ViewMsgDialog       **_dialogs;
358     int                  _numDialogs;
359     FindDialog          *_findDialog;
360     
361     //
362     // ContainerList
363     //
364     int                  _display_cached_list;
365     char                *_filemenu2;
366     int                  _first_cached_item;
367     int                  _max_cached_list_size;
368     DtVirtArray<ContainerMenuCmd *>     *_user_containerlist;
369     DtVirtArray<ContainerMenuCmd *>     *_cached_containerlist;
370
371     //
372     // File Menu
373     //
374     CmdList             *_file_cmdlist;
375     Cmd                 *_file_separator;
376     CheckForNewMailCmd  *_file_check_new_mail;
377     Cmd                 *_file_open_inbox;
378     UnifiedSelectMailboxCmd *_file_new_container;
379     UnifiedSelectMailboxCmd *_file_open;
380     Cmd                 *_file_destroy_deleted_msgs;
381     Cmd                 *_file_quit;
382     Widget               _file_cascade;
383     
384     //
385     // Open Cascade Menu
386     //
387     CmdList             *_open_container_cmdlist;
388     Cmd                 *_open_container_separator;
389     Cmd                 *_open_container_inbox;
390     UnifiedSelectMailboxCmd
391                         *_open_container_other;
392
393     DtVirtArray<ContainerMenuCmd *> *_open_container_containerlist;
394     DtVirtArray<ContainerMenuCmd *> *_open_container_containerlist_cached;
395     Widget              _opencontainerMenu;
396     
397     //
398     // Message Menu
399     //
400     CmdList             *_msg_cmdlist;
401     Cmd                 *_msg_separator;
402     Cmd                 *_msg_open;
403     Cmd                 *_msg_save_as;
404     Cmd                 *_msg_print;
405     Cmd                 *_msg_find;
406     Cmd                 *_msg_select_all;
407     Cmd                 *_msg_delete;
408     Cmd                 *_msg_undelete_last;
409     UndeleteCmd         *_msg_undelete_from_list;
410     
411     //
412     // CopyTo Cascade Menu
413     //
414     CmdList             *_copyto_cmdlist;
415     Cmd                 *_copyto_separator;
416     CopyToInboxCmd      *_copyto_inbox;
417     Cmd                 *_copyto_other;
418
419     DtVirtArray<ContainerMenuCmd *> *_copyto_containerlist;
420     DtVirtArray<ContainerMenuCmd *> *_copyto_containerlist_cached;
421     Widget              _copytoMenu;
422     Widget              _message_cascade;
423     
424     //
425     // Edit Menu
426     //
427     CmdList             *_edit_cmdlist;
428     Cmd                 *_edit_copy;
429     Cmd                 *_edit_select_all;
430     
431     //
432     // Attachments Menu  
433     //
434     CmdList             *_att_cmdlist;
435     Cmd                 *_att_save;
436     Cmd                 *_att_select_all;
437     
438     //
439     // View Menu  
440     //
441     CmdList             *_view_cmdlist;
442     Cmd                 *_view_separator;
443     Cmd                 *_view_next;
444     Cmd                 *_view_previous;
445     Cmd                 *_view_abbrev_headers;
446     Cmd                 *_view_sortTD;
447     Cmd                 *_view_sortSender;      
448     Cmd                 *_view_sortSubject;     
449     Cmd                 *_view_sortSize;        
450     Cmd                 *_view_sortStatus;
451     
452     //
453     // Compose Menu
454     //
455     CmdList             *_comp_cmdlist;
456     Cmd                 *_comp_separator;
457     Cmd                 *_comp_new;
458     Cmd                 *_comp_new_include;
459     Cmd                 *_comp_forward;
460     Cmd                 *_comp_replySender;
461     Cmd                 *_comp_replyAll;
462     Cmd                 *_comp_replySinclude;
463     Cmd                 *_comp_replyAinclude;
464     
465     //
466     // Move Menu
467     //
468     CmdList             *_move_cmdlist;
469     Cmd                 *_move_separator;
470     MoveToInboxCmd      *_move_inbox;
471     Cmd                 *_move_other;
472
473     DtVirtArray<ContainerMenuCmd *> *_move_containerlist;
474     DtVirtArray<ContainerMenuCmd *> *_move_containerlist_cached;
475     Widget              _moveMenu;
476     Widget              _move_cascade;
477
478     //
479     // Help Menu
480     //
481     CmdList             *_help_cmdlist;
482     Cmd                 *_help_separator;
483     Cmd                 *_help_overview;
484     Cmd                 *_help_tasks;
485     Cmd                 *_help_reference;
486     Cmd                 *_help_on_item;
487     Cmd                 *_help_using_help;
488     Cmd                 *_help_about_mailer;
489     
490     //
491     // Message Popup
492     //
493     CmdList             *_msgsPopup_cmdlist;
494     Cmd                 *_msgsPopup_separator;
495
496     MenuBar             *_menuPopupMsgs;
497     Widget              _msgsPopupMenu;
498     Widget              _msgsPopupMoveMenu;
499
500     //
501     // Text Popup
502     //
503     CmdList             *_textPopup_cmdlist;
504     Cmd                 *_textPopup_separator;
505
506     //
507     // Attachments Popup
508     //
509     CmdList             *_attPopup_cmdlist;
510     Cmd                 *_attPopup_separator;
511     CmdList             *_attActions_cmdlist;
512
513     Widget              _attachmentMenu;
514
515     //
516     // Message filing interface
517     //
518     ConvertContainerCmd *_convertContainerCmd;
519     OpenContainerCmd    *_openContainerCmd;
520     
521     //
522     // This is the set of buttons below the scrolling list
523     // They get used in the addToRowOfButtons() method
524     //
525     DeleteCmd           *_delete_button;
526     Cmd                 *_next_button;
527     Cmd                 *_previous_button;
528     Cmd                 *_replySender_button;
529     Cmd                 *_print_button;
530     Cmd                 *_move_copy_button;
531
532     
533     DtMail::MailBox     *_mailbox;
534     Boolean             _inbox;
535     MsgScrollingList    *_list;
536     DtMailGenDialog     *_genDialog;
537     
538     Widget      createWorkArea ( Widget );
539     void        createMenuPanes();
540     void        createContainerList();
541     void        createOpenContainerList(CmdList *);
542     void        createCopyList(CmdList *);
543     void        configurenotify(
544                     unsigned int,
545                     unsigned int,
546                     unsigned int, 
547                     unsigned int,
548                     unsigned int);
549     void        mapnotify();
550
551     
552   private:
553     
554     static XtResource   _resources[];
555     static char         *_supported[];
556
557     Pixmap              _mbox_image;
558     Pixmap              _mbox_mask;
559
560     unsigned int        _x;
561     unsigned int        _y;
562     unsigned int        _width;
563     unsigned int        _height;
564     unsigned int        _border_width;
565     Dimension           _workarea_width;
566     Dimension           _workarea_height;
567     
568     DtMailEditor        *_my_editor;
569     Widget              _message;
570     Widget              _message_summary;
571     Widget              _rowOfLabels;
572     Widget              _rowOfButtons;
573     Widget              _rowOfMessageStatus;
574     XtWorkProcId        _quitWorkprocID;
575     Boolean             _clear_message_p;
576     Boolean             _create_mailbox_file;
577     Boolean             _is_loaded;
578     Boolean             _open_create_flag;
579     Boolean             _open_lock_flag;
580
581     //
582     // Message header list column labels
583     //
584     Widget              _sender_lbl;
585     Widget              _subject_lbl;
586     Widget              _date_lbl;
587     Widget              _size_lbl;
588
589     XmString            _sender_xms;
590     XmString            _subject_xms;
591     XmString            _date_xms;
592     XmString            _size_xms;
593
594     XmString            _sender_key_xms;
595     XmString            _subject_key_xms;
596     XmString            _date_key_xms;
597     XmString            _size_key_xms;
598
599     static void ownselectionCallback(Widget, XtPointer, XtPointer );
600     static void structurenotify(Widget, XtPointer, XEvent *, Boolean *);
601     static void file_selection_callback(void *, char * );
602     static void create_container_callback(void *, char * );
603     static void move_callback(void *, char *);
604     static void copy_callback(void *, char *);
605     static void save_attachment_callback(void *, char *);    
606     static void delete_attachment_callback(void *, char *);    
607     static void conversionFinishedCallback(
608                         RoamInterruptibleCmd *,
609                         Boolean,
610                         void *);
611     static void map_menu( Widget, XtPointer, XtPointer );
612     static Boolean quitWorkproc(XtPointer);
613 };
614
615 #endif