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: RoamMenuWindow.h /main/29 1999/02/03 18:01:26 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 Sun Microsystems, Inc. All rights reserved.
43 #ifndef ROAMMENUWINDOW_H
44 #define ROAMMENUWINDOW_H
46 //-----------------------------------------------------------------------------
47 // Roam window for viewing messages
48 //-----------------------------------------------------------------------------
50 #include <DtMail/DtMail.hh>
52 #include "MenuWindow.h"
54 #include "DtMailGenDialog.hh"
58 #include "IconifyCmd.h"
62 #include "ViewMsgDialog.h"
63 #include <DtMail/DtMailError.hh>
64 #include "MsgScrollingList.hh"
65 #include "AttachArea.h"
66 #include "FindDialog.h"
69 //#include "CDEM_CoeEd.hh"
71 #include "DtMailEditor.hh"
73 #include "Undelete.hh"
75 /* ROMENU_* msgid 400 - 499
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
149 class RoamMenuWindow : public MenuWindow, public AbstractEditorParent
152 RoamMenuWindow(char*);
153 virtual ~RoamMenuWindow();
154 virtual void initialize();
155 virtual void manage();
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*);
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);
172 msgListDragStart(Widget, XEvent*, String*, Cardinal*);
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();
196 void sync_work_area_size();
198 void view_mail_file(char*, DtMailBoolean create = DTM_FALSE);
201 //-------------------------------------------------------------------------
203 //-------------------------------------------------------------------------
205 DtMailEditor *get_editor() { return(_my_editor); }
206 ViewMsgDialog *msgView()
208 if ( _numDialogs==0 )
211 return _dialogs[_numDialogs-1];
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; }
227 //-----------------------------------------------------------------------
229 //-----------------------------------------------------------------------
231 void addToRowOfButtons();
232 void addToRowOfLabels(MsgScrollingList *msglist);
233 void addToRowOfMessageStatus();
235 void clearStatus(void);
236 void forwardFilename(char*);
237 char *forwardFilename();
238 void fullHeader(Boolean flag);
239 ViewMsgDialog *ifViewExists(DtMailMessageHandle msg_num);
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)
249 if (NULL != _mailbox_name) free((void*)_mailbox_name);
250 _mailbox_name=strdup( name );
252 void mailboxFullpath( char *path)
254 if (NULL != _mailbox_fullpath) free((void*)_mailbox_fullpath);
255 _mailbox_fullpath=strdup( path );
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*);
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();
276 *get_undel_dialog() {return _msg_undelete_from_list->dialog();}
279 void clear_message();
280 int inList(char *filename, DtVirtArray<ContainerMenuCmd *> *);
281 void addToCachedContainerList(char *filename);
282 void syncCachedContainerList();
283 void newMailIndicators(void);
285 int queryExpunge(void);
286 Boolean requiredConversion() {return _required_conversion;}
288 virtual void text_selected();
289 virtual void text_unselected();
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);
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".
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....
324 DtMailBoolean syncViewAndStore(DtMailCallbackOp, const char*, va_list);
326 // Static public methods now.
327 static DtMailBoolean syncViewAndStoreCallback(
330 const char * prompt_hint,
333 static int ConvertStatusCB(int current, int total, void *);
334 virtual void postMsgsPopup(XEvent *event);
335 inline Boolean IsLoaded () { return _is_loaded; }
338 static RoamMenuWindow
339 *restoreSession(char*);
340 virtual int smpSaveSessionGlobal(void);
341 virtual void smpSaveSessionLocal(void);
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;
353 char *_mailbox_name_resource;
354 Boolean _required_conversion;
355 Boolean _we_called_newmail;
357 ViewMsgDialog **_dialogs;
359 FindDialog *_findDialog;
364 int _display_cached_list;
366 int _first_cached_item;
367 int _max_cached_list_size;
368 DtVirtArray<ContainerMenuCmd *> *_user_containerlist;
369 DtVirtArray<ContainerMenuCmd *> *_cached_containerlist;
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;
382 Widget _file_cascade;
387 CmdList *_open_container_cmdlist;
388 Cmd *_open_container_separator;
389 Cmd *_open_container_inbox;
390 UnifiedSelectMailboxCmd
391 *_open_container_other;
393 DtVirtArray<ContainerMenuCmd *> *_open_container_containerlist;
394 DtVirtArray<ContainerMenuCmd *> *_open_container_containerlist_cached;
395 Widget _opencontainerMenu;
400 CmdList *_msg_cmdlist;
406 Cmd *_msg_select_all;
408 Cmd *_msg_undelete_last;
409 UndeleteCmd *_msg_undelete_from_list;
412 // CopyTo Cascade Menu
414 CmdList *_copyto_cmdlist;
415 Cmd *_copyto_separator;
416 CopyToInboxCmd *_copyto_inbox;
419 DtVirtArray<ContainerMenuCmd *> *_copyto_containerlist;
420 DtVirtArray<ContainerMenuCmd *> *_copyto_containerlist_cached;
422 Widget _message_cascade;
427 CmdList *_edit_cmdlist;
429 Cmd *_edit_select_all;
434 CmdList *_att_cmdlist;
436 Cmd *_att_select_all;
441 CmdList *_view_cmdlist;
442 Cmd *_view_separator;
445 Cmd *_view_abbrev_headers;
447 Cmd *_view_sortSender;
448 Cmd *_view_sortSubject;
450 Cmd *_view_sortStatus;
455 CmdList *_comp_cmdlist;
456 Cmd *_comp_separator;
458 Cmd *_comp_new_include;
460 Cmd *_comp_replySender;
462 Cmd *_comp_replySinclude;
463 Cmd *_comp_replyAinclude;
468 CmdList *_move_cmdlist;
469 Cmd *_move_separator;
470 MoveToInboxCmd *_move_inbox;
473 DtVirtArray<ContainerMenuCmd *> *_move_containerlist;
474 DtVirtArray<ContainerMenuCmd *> *_move_containerlist_cached;
476 Widget _move_cascade;
481 CmdList *_help_cmdlist;
482 Cmd *_help_separator;
485 Cmd *_help_reference;
487 Cmd *_help_using_help;
488 Cmd *_help_about_mailer;
493 CmdList *_msgsPopup_cmdlist;
494 Cmd *_msgsPopup_separator;
496 MenuBar *_menuPopupMsgs;
497 Widget _msgsPopupMenu;
498 Widget _msgsPopupMoveMenu;
503 CmdList *_textPopup_cmdlist;
504 Cmd *_textPopup_separator;
509 CmdList *_attPopup_cmdlist;
510 Cmd *_attPopup_separator;
511 CmdList *_attActions_cmdlist;
513 Widget _attachmentMenu;
516 // Message filing interface
518 ConvertContainerCmd *_convertContainerCmd;
519 OpenContainerCmd *_openContainerCmd;
522 // This is the set of buttons below the scrolling list
523 // They get used in the addToRowOfButtons() method
525 DeleteCmd *_delete_button;
527 Cmd *_previous_button;
528 Cmd *_replySender_button;
530 Cmd *_move_copy_button;
533 DtMail::MailBox *_mailbox;
535 MsgScrollingList *_list;
536 DtMailGenDialog *_genDialog;
538 Widget createWorkArea ( Widget );
539 void createMenuPanes();
540 void createContainerList();
541 void createOpenContainerList(CmdList *);
542 void createCopyList(CmdList *);
543 void configurenotify(
554 static XtResource _resources[];
555 static char *_supported[];
563 unsigned int _height;
564 unsigned int _border_width;
565 Dimension _workarea_width;
566 Dimension _workarea_height;
568 DtMailEditor *_my_editor;
570 Widget _message_summary;
572 Widget _rowOfButtons;
573 Widget _rowOfMessageStatus;
574 XtWorkProcId _quitWorkprocID;
575 Boolean _clear_message_p;
576 Boolean _create_mailbox_file;
578 Boolean _open_create_flag;
579 Boolean _open_lock_flag;
582 // Message header list column labels
589 XmString _sender_xms;
590 XmString _subject_xms;
594 XmString _sender_key_xms;
595 XmString _subject_key_xms;
596 XmString _date_key_xms;
597 XmString _size_key_xms;
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 *,
611 static void map_menu( Widget, XtPointer, XtPointer );
612 static Boolean quitWorkproc(XtPointer);