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: RoamCmds.h /main/14 1999/07/13 08:42:16 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.
46 #include <Dt/Action.h>
48 #include <DtMail/DtMail.hh>
49 #include <DtMail/DtVirtArray.hh>
52 #include "NoUndoCmd.h"
53 #include "InterruptibleCmd.h"
54 #include "RoamInterruptibleCmd.hh"
55 #include "SelectFileCmd.h"
56 #include "DtMailWDM.hh"
58 #include "DtMailGenDialog.hh"
59 #include "MotifCmds.h"
63 /* ROCMD_* msgid 300 - 399
65 #define ROCMD_EMPTY 300
73 class UndelFromListDialog;
75 //class VacationPopup;
77 class RoamCmd : public NoUndoCmd {
80 RoamMenuWindow *_menuwindow;
83 // virtual void doit();
84 RoamCmd( char *, char *, int, RoamMenuWindow * );
85 // virtual const char *const className () { return "SaveCmd"; }
88 class OpenMsgCmd : public RoamCmd {
91 OpenMsgCmd(char *, char *, int, RoamMenuWindow *);
92 virtual const char *const className() { return "OpenMsgCmd"; }
96 class SaveCmd : public RoamCmd {
99 SaveCmd( char *, char *, int, RoamMenuWindow * );
100 virtual const char *const className () { return "SaveCmd"; }
102 #endif /* DEAD_WOOD */
105 class UnifiedSelectFileCmd : public SelectFileCmd {
107 static void unifiedFileSelectedCB(void *client_data, char *selection);
108 static void unifiedFileCanceledCB(void *client_data, char *selection);
109 void unifiedFileSelected(char *selection);
111 static char *_unified_file;
112 static char *_unified_directory;
113 static int _unified_hidden;
114 static int _unify_selection;
115 static int _is_initialized;
117 FileCallback _select_file_callback;
118 void *_select_file_client_data;
121 DtMailGenDialog *_genDialog;
122 void updateUnifiedData();
125 UnifiedSelectFileCmd(
126 char *name, char *label,
127 char *title, char *ok_label, int active,
128 FileCallback select_callback, void *client_data,
130 ~UnifiedSelectFileCmd();
132 virtual const char *const
133 className() { return "UnifiedSelectFileCmd"; }
138 class UnifiedSelectMailboxCmd : public SelectFileCmd {
140 static void unifiedMailboxSearchProc(Widget w, XtPointer sd);
141 static void unifiedMailboxSelectedCB(void *client_data, char *selection);
142 static void unifiedMailboxCanceledCB(void *client_data, char *selection);
144 static char *_unified_file;
145 static char *_unified_directory;
146 static int _unified_hidden;
147 static int _unify_selection;
148 static int _is_initialized;
150 DtMailBoolean _only_show_mailboxes;
151 FileCallback _select_file_callback;
152 void *_select_file_client_data;
155 DtMailGenDialog *_genDialog;
157 void updateUnifiedData();
158 void unifiedMailboxSelected(
165 UnifiedSelectMailboxCmd(
166 char *name, char *label,
167 char *title, char *ok_label, int active,
168 FileCallback select_callback, void *client_data,
170 DtMailBoolean only_show_mailboxes = DTM_FALSE);
171 ~UnifiedSelectMailboxCmd();
173 virtual const char *const
174 className() { return "UnifiedSelectMailboxCmd"; }
179 class MoveCopyCmd : public UnifiedSelectMailboxCmd {
182 static void fileSelectedCallback2 ( Widget, XtPointer, XtPointer );
183 static void setDefaultButtonCB ( Widget, XtPointer, XtPointer );
187 FileCallback _copy_callback;
188 RoamMenuWindow * _menuwindow;
193 Widget _default_button;
208 Widget getCopyButton() { return _copy_button; }
209 Widget getMoveButton() { return _move_button; }
210 void setDefault( Widget );
212 virtual const char *const className () { return "MoveCopyCmd"; }
217 class CopyCmd : public RoamCmd {
219 MoveCopyCmd *_move_copy_cmd;
222 CopyCmd( char *, char *, int, RoamMenuWindow *, MoveCopyCmd * );
224 virtual const char *const className () { return "CopyCmd"; }
228 class MoveCmd : public RoamCmd {
230 MoveCopyCmd *_move_copy_cmd;
233 MoveCmd( char *, char *, int, RoamMenuWindow *, MoveCopyCmd * );
235 virtual const char *const className () { return "MoveCmd"; }
239 class NextCmd : public RoamCmd {
242 NextCmd( char *, char *, int, RoamMenuWindow * );
243 virtual const char *const className () { return "NextCmd"; }
247 class PrevCmd : public RoamCmd {
250 PrevCmd( char *, char *, int, RoamMenuWindow * );
251 virtual const char *const className () { return "PrevCmd"; }
256 class MessagesCmd : public RoamCmd {
259 MessagesCmd( char *, char *, int, RoamMenuWindow * );
260 virtual const char *const className () { return "MessagesCmd"; }
262 #endif /* DEAD_WOOD */
266 class ChooseCmd : public NoUndoCmd {
269 class RoamMenuWindow *_menuwindow;
270 DtMailMessageHandle _msgno;
275 ChooseCmd( char *, char *, int, RoamMenuWindow * );
276 virtual const char *const className () { return "ChooseCmd"; }
277 DtMailMessageHandle msgno() { return _msgno; }
278 void msgno( DtMailMessageHandle msgno) { _msgno=msgno; }
282 class ClearCmd : public NoUndoCmd {
285 class RoamMenuWindow *parent;
288 ClearCmd( char *, char *, int, RoamMenuWindow * );
289 virtual const char *const className () { return "ClearCmd"; }
293 class SearchCmd : public InterruptibleCmd {
297 RoamMenuWindow *_menuwindow;
302 virtual void undoit();
305 SearchCmd ( char *, char *, int, RoamMenuWindow * );
306 virtual void execute();
307 virtual void execute ( TaskDoneCallback, void * );
308 void set_criteria( char *criteria ) { _criteria=criteria; };
309 virtual void updateMessage ( char * );
310 virtual const char *const className () { return "SearchCmd"; }
312 #endif /* DEAD_WOOD */
315 class CheckForNewMailCmd : public NoUndoCmd {
318 class RoamMenuWindow *_menuwindow;
322 CheckForNewMailCmd( char *, char *, int, RoamMenuWindow * );
323 virtual const char *const className () { return "CheckForNewMailCmd"; }
327 // Used for opening a container.
329 class OpenContainerCmd : public RoamInterruptibleCmd {
332 RoamMenuWindow *_menuWindow;
335 virtual void undoit();
336 virtual void post_dialog();
337 virtual void unpost_dialog();
338 virtual void check_if_done();
342 // Need this to be public coz RMW's callback function needs it.
343 // Its a boolean_t because that's what the back-end uses and
344 // passes. The back-end doesn't want to know anything about
345 // Boolean which is a Motif/Xt concept. Instead of casting to
346 // to and from Boolean<->boolean_t, might as well set it to be
347 // boolean_t and avoid the casting mess. No?
349 DtMailBoolean _open_create_flag;
350 DtMailBoolean _open_lock_flag;
352 OpenContainerCmd(char *, char *, int, RoamMenuWindow *);
353 virtual void execute();
354 virtual void execute(RoamTaskDoneCallback, void *);
355 void set_create_lock_flags(DtMailBoolean, DtMailBoolean);
356 virtual void updateMessage ( char * );
357 virtual const char *const className () { return "ShowStatusCmd"; }
360 class OpenInboxCmd : public Cmd {
363 RoamMenuWindow *_menuWindow;
367 virtual void undoit();
370 OpenInboxCmd(char*, char *, int, RoamMenuWindow *);
374 // Used for converting containers from rfc<->???.
376 typedef int (*ConversionStatusCB) (int, int, void *);
378 class ConvertContainerCmd : public RoamInterruptibleCmd {
382 RoamMenuWindow *_menuWindow;
385 ConversionStatusCB _conv_cb;
389 int _num_to_be_converted;
392 virtual void undoit();
393 virtual void post_dialog();
394 virtual void unpost_dialog();
395 virtual void check_if_done();
398 ConvertContainerCmd ( char *, char *, int, RoamMenuWindow *);
399 virtual void execute();
400 virtual void execute(RoamTaskDoneCallback, void *);
402 virtual void updateDialog ( char * );
403 virtual void updateAnimation();
404 virtual const char *const className () { return "ConvertContainerCmd"; }
406 void set_data(char *, char *, ConversionStatusCB);
407 void set_convert_data(int, int);
408 int get_num_converted();
409 char * get_destination_name();
415 class SelectAllCmd : public Cmd {
418 class RoamMenuWindow *_menuwindow;
422 virtual void undoit();
424 SelectAllCmd(char *, char *, int, RoamMenuWindow * );
425 virtual const char *const className() { return "SelectAllCmd"; }
428 class DeleteCmd : public Cmd {
431 class RoamMenuWindow *_menuwindow;
432 DtMailMessageHandle _msgno;
437 virtual void undoit();
438 DeleteCmd( char *, char *, int, RoamMenuWindow * );
439 virtual const char *const className () { return "DeleteCmd"; }
440 DtMailMessageHandle msgno() { return _msgno; }
441 void msgno( DtMailMessageHandle msgno) { _msgno=msgno; }
444 class DestroyCmd : public Cmd {
445 RoamMenuWindow *_menuwindow;
449 virtual void undoit();
451 DestroyCmd(char *, char *, int active, RoamMenuWindow *);
452 virtual const char *const className() { return "DestroyCmd"; }
455 typedef enum { DTM_NONE, DTM_MOVE, DTM_COPY, DTM_OPEN } ContainerOp;
457 class ContainerMenuCmd : public RoamCmd {
459 char *_container_name;
460 ContainerOp _operation;
464 ContainerMenuCmd( char *, char *, int, RoamMenuWindow *, ContainerOp);
465 virtual ~ContainerMenuCmd();
466 char *containerName(void) { return(_container_name); }
467 void changeContainer( char * container_name )
468 { _container_name = container_name; }
469 virtual const char *const className() { return "ContainerMenuCmd"; }
472 class MoveToInboxCmd : public RoamCmd {
475 MoveToInboxCmd( char *, char *, int, RoamMenuWindow * );
476 virtual ~MoveToInboxCmd();
477 virtual const char *const className () { return "MoveToInboxCmd"; }
480 class CopyToInboxCmd : public RoamCmd {
483 CopyToInboxCmd( char *, char *, int, RoamMenuWindow * );
484 virtual ~CopyToInboxCmd();
485 virtual const char *const className () { return "CopyToInboxCmd"; }
489 class DoUndeleteCmd : public Cmd {
491 class UndelFromListDialog *_undelDialog;
494 virtual void undoit();
495 DoUndeleteCmd(char *, char *, int, UndelFromListDialog * );
496 virtual ~DoUndeleteCmd();
497 virtual const char *const className () { return "DoUndeleteCmd";}
500 class CloseUndelCmd : public Cmd {
502 class UndelFromListDialog *_undelDialog;
505 virtual void undoit();
506 CloseUndelCmd(char *, char *, int, UndelFromListDialog *);
507 virtual ~CloseUndelCmd();
508 virtual const char *const className () { return "CloseUndelCmd";}
512 class UndeleteCmd : public ChooseCmd {
516 UndeleteCmd( char *, char *, int, RoamMenuWindow *, Boolean );
518 UndelFromListDialog *dialog() { return _undelFromList; }
519 virtual const char *const className () { return "UndeleteCmd"; }
521 void *_clientData; // Data provided by caller
522 UndelFromListDialog *_undelFromList;
524 int _num_deleted; // number of deleted messages
529 class PrintCmd : public ChooseCmd {
532 PrintCmd( char *, char *, int, int silent, RoamMenuWindow * );
533 virtual const char *const className () { return "PrintCmd"; }
536 RoamMenuWindow *_parent;
540 DtActionInvocationID id;
542 DtVirtArray<struct tmp_file *> _tmp_files;
545 int _register_tmp_file(const char *, DtActionInvocationID);
546 void _unregister_tmp_file(DtActionInvocationID);
547 static void actioncb(DtActionInvocationID,XtPointer,DtActionArg *,int,int);
548 static void printjobcb(Widget,XtPointer,XtPointer);
552 class PopupCmd : public NoUndoCmd {
554 RoamMenuWindow *parent;
555 PopupWindow *(RoamMenuWindow::* pmpopup) ( void );
558 PopupCmd( char *, char *, int, PopupWindow * (RoamMenuWindow::*) (void), RoamMenuWindow * );
559 virtual const char *const className () { return "PopupCmd"; }
561 #endif /* DEAD_WOOD */
563 class OnItemCmd : public NoUndoCmd {
565 UIComponent *_parent;
568 OnItemCmd( char *, char *, int, UIComponent * );
569 virtual const char *const className () { return "OnItemCmd"; }
572 class OnAppCmd : public NoUndoCmd {
574 UIComponent *_parent;
577 OnAppCmd( char *, char *, int, UIComponent * );
578 virtual const char *const className () { return "OnAppCmd"; }
581 class TasksCmd : public NoUndoCmd {
583 UIComponent *_parent;
586 TasksCmd( char *, char *, int, UIComponent * );
587 virtual const char *const className () { return "TasksCmd"; }
590 class ReferenceCmd : public NoUndoCmd {
592 UIComponent *_parent;
595 ReferenceCmd( char *, char *, int, UIComponent * );
596 virtual const char *const className () { return "ReferenceCmd"; }
599 class UsingHelpCmd : public NoUndoCmd {
601 UIComponent *_parent;
604 UsingHelpCmd( char *, char *, int, UIComponent * );
605 virtual const char *const className () { return "UsingHelpCmd"; }
608 class RelNoteCmd : public NoUndoCmd {
610 DtMailGenDialog *_genDialog;
611 UIComponent *_parent;
615 RelNoteCmd( char *, char *, int, UIComponent * );
616 virtual const char *const className () { return "RelNoteCmd"; }
620 class FindCmd : public RoamCmd {
623 FindCmd( char *, char *, int, RoamMenuWindow * );
624 virtual const char *const className () { return "FindCmd"; }
629 class StartCmd : public Cmd {
631 // VacationPopup *parent;
635 virtual void undoit();
636 // StartCmd( char *, char *, int, VacationPopup * );
637 StartCmd( char *, char *, int );
638 virtual const char *const className () { return "StartCmd"; }
641 class ChangeCmd : public Cmd {
644 virtual void undoit();
645 ChangeCmd( char *, char *, int );
646 virtual const char *const className () { return "ChangeCmd"; }
649 class StopCmd : public Cmd {
651 RoamMenuWindow *parent;
654 virtual void undoit();
655 StopCmd( char *, char *, int, RoamMenuWindow * );
656 virtual const char *const className () { return "StopCmd"; }
658 #endif /* DEAD_WOOD */
660 class SendCmd : public NoUndoCmd {
662 SendMsgDialog *_parent;
666 SendCmd( char *, char *, int, SendMsgDialog *, int );
667 virtual const char *const className () { return "SendCmd"; }
670 class SaveAsTextCmd : public UnifiedSelectFileCmd {
672 RoamMenuWindow *_roam_menu_window;
673 Editor *_text_editor;
675 static void fileCB(void * client_data, char * selection);
676 void saveText(const char * filename);
677 void writeTextFromScrolledList(int fd);
678 static void writeText(XtPointer, char*);
683 char *, char *, char * title, int, Editor *,
684 RoamMenuWindow *, Widget);
686 char *, char *, char * title, int, Editor *,
688 virtual const char *const className() { return "SaveAsTextCmd"; }
691 class SaveAttachCmd : public UnifiedSelectFileCmd {
693 AbstractEditorParent *_parent;
695 static void updateCallback( Widget, XtPointer, XtPointer);
699 SaveAttachCmd(char *, char *, char *, int, FileCallback, RoamMenuWindow *, Widget);
700 SaveAttachCmd(char *, char *, char *, int, FileCallback, ViewMsgDialog *, Widget);
701 SaveAttachCmd(char *, char *, char *, int, FileCallback, SendMsgDialog *, Widget);
703 virtual const char *const className () { return "SaveAttachCmd"; }
706 class DeleteAttachCmd : public Cmd {
708 SendMsgDialog *_parent;
713 virtual void undoit();
717 DeleteAttachCmd ( char *, char *, int, SendMsgDialog *);
718 virtual const char *const className () { return "AttachDeleteCmd"; }
721 class UndeleteAttachCmd : public Cmd {
723 SendMsgDialog *_parent;
728 virtual void undoit();
732 UndeleteAttachCmd ( char *, char *, int, SendMsgDialog *);
734 virtual const char *const className () { return "AttachUndeleteCmd"; }
737 class RenameAttachCmd : public Cmd {
741 SendMsgDialog *_parent;
742 void cancel( XtPointer ); // Called when the Cancel button is pressed
743 static void cancelCallback( Widget, XtPointer, XtPointer );
744 void ok( XtPointer ); // Called when the OK button is pressed
745 static void okCallback( Widget, XtPointer, XtPointer );
750 virtual void undoit();
754 RenameAttachCmd ( char *, char *, int, SendMsgDialog * );
756 virtual const char *const className () { return "RenameAttachCmd"; }
759 class AttachmentActionCmd : public Cmd {
762 AbstractEditorParent *_parent;
768 virtual void undoit();
772 AttachmentActionCmd( char *, char *, RoamMenuWindow *, int);
773 AttachmentActionCmd( char *, char *, ViewMsgDialog *, int);
774 AttachmentActionCmd( char *, char *, SendMsgDialog *, int);
776 virtual const char *const className () { return "AttachmentActionCmd"; }
780 class SelectAllAttachsCmd : public Cmd {
783 AbstractEditorParent *_parent;
788 virtual void undoit();
792 SelectAllAttachsCmd ( char *, char *, RoamMenuWindow *);
793 SelectAllAttachsCmd ( char *, char *, ViewMsgDialog *);
794 SelectAllAttachsCmd ( char *, char *, SendMsgDialog *);
796 virtual const char *const className () { return "SelectAllAttachsCmd"; }
800 // Its critical that children of ToggleButtonCmd not have a
801 // const className() method.
804 class ShowAttachPaneCmd : public ToggleButtonCmd {
807 AbstractEditorParent *_parent;
812 virtual void undoit();
816 ShowAttachPaneCmd (char *, char *, AbstractEditorParent *);
820 class AbbrevHeadersCmd : public ToggleButtonCmd {
823 RoamMenuWindow *_parent;
828 virtual void undoit();
832 AbbrevHeadersCmd (char *, char *, RoamMenuWindow *);
835 // Close button applies only to SMD
837 class CloseCmd : public NoUndoCmd {
839 SendMsgDialog *_compose_dialog;
844 CloseCmd( char *, char *, int, Widget, SendMsgDialog * );
845 virtual const char *const className () { return "CloseCmd"; }
848 class EditUndoCmd : public NoUndoCmd {
853 EditUndoCmd( char *, char *, int, AbstractEditorParent * );
854 virtual const char *const className () { return "EditUndoCmd"; }
857 // CDEM_DtWidgetEditor *editor;
858 // XmTextEditor *editor;
860 class EditCutCmd : public NoUndoCmd {
863 SendMsgDialog *_compose_dialog;
866 EditCutCmd( char *, char *, int, AbstractEditorParent * );
867 virtual const char *const className () { return "EditCutCmd"; }
870 // CDEM_DtWidgetEditor *editor;
871 // XmTextEditor *editor;
873 class EditCopyCmd : public NoUndoCmd {
876 SendMsgDialog *_compose_dialog;
879 EditCopyCmd( char *, char *, int, AbstractEditorParent * );
880 virtual const char *const className () { return "EditCopyCmd"; }
883 // CDEM_DtWidgetEditor *editor;
884 // XmTextEditor *editor;
886 class EditPasteCmd : public NoUndoCmd {
891 EditPasteCmd( char *, char *, int, AbstractEditorParent * );
892 virtual const char *const className () { return "EditPasteCmd"; }
895 // CDEM_DtWidgetEditor *editor;
896 // XmTextEditor *editor;
898 class EditPasteSpecialCmd : public NoUndoCmd {
901 Editor::InsertFormat insert_format;
904 EditPasteSpecialCmd( char *, char *, int, AbstractEditorParent *, Editor::InsertFormat );
905 virtual const char *const className () { return "EditPasteSpecialCmd"; }
909 // CDEM_DtWidgetEditor *editor;
910 // XmTextEditor *editor;
912 class EditClearCmd : public NoUndoCmd {
917 EditClearCmd( char *, char *, int, AbstractEditorParent * );
918 virtual const char *const className () { return "EditClearCmd"; }
921 // CDEM_DtWidgetEditor *editor;
922 // XmTextEditor *editor;
924 class EditDeleteCmd : public NoUndoCmd {
929 EditDeleteCmd( char *, char *, int, AbstractEditorParent * );
930 virtual const char *const className () { return "EditDeleteCmd"; }
933 // XmTextEditor *editor;
935 class EditSelectAllCmd : public NoUndoCmd {
940 EditSelectAllCmd( char *, char *, int, AbstractEditorParent * );
941 virtual const char *const className () { return "EditSelectAllCmd"; }
944 // CDEM_DtWidgetEditor *editor;
945 // XmTextEditor *editor;
947 class WordWrapCmd : public ToggleButtonCmd {
953 virtual void undoit() {};
954 WordWrapCmd( char *, char *, int, AbstractEditorParent * );
958 // CDEM_DtWidgetEditor *editor;
959 // XmTextEditor *editor;
961 class FindChangeCmd : public NoUndoCmd {
966 FindChangeCmd( char *, char *, int, AbstractEditorParent * );
967 virtual const char *const className () { return "FindChangeCmd"; }
970 class SpellCmd : public NoUndoCmd {
975 SpellCmd( char *, char *, int, AbstractEditorParent * );
976 virtual const char *const className () { return "SpellCmd"; }
979 class AliasCmd : public NoUndoCmd {
985 AliasCmd(char *, char *, int, Widget);
987 virtual const char *const className () { return "AliasCmd"; }
990 class OtherAliasesCmd : public NoUndoCmd {
995 OtherAliasesCmd(char *, char *, int);
996 virtual ~OtherAliasesCmd();
997 virtual const char *const className () { return "OtherAliasesCmd"; }
1000 class FormatCmd : public NoUndoCmd {
1004 virtual void doit();
1005 FormatCmd( char *, char *, int, AbstractEditorParent * );
1006 virtual const char *const className () { return "FormatCmd"; }
1009 // Applicable only to SMD
1011 class LogMsgCmd : public ToggleButtonCmd {
1013 SendMsgDialog * _send;
1016 virtual void doit();
1017 virtual void undoit() {};
1018 LogMsgCmd( char *, char *, int, SendMsgDialog *);
1019 int LogMsg(void) { return ((ToggleButtonCmd *)this)->getButtonState(); }
1022 class VacationCmd : public Cmd {
1025 char *_backupSuffix;
1028 DtMail::Message *_msg;
1029 Boolean _priorVacationRunning;
1030 DtMailGenDialog *_dialog;
1035 VacationCmd(char *, char *);
1038 virtual void doit();
1039 virtual void undoit() {};
1041 int startVacation(char *, char*);
1042 void stopVacation();
1044 int handleMessageFile(char *, char *);
1045 int handleForwardFile();
1046 Boolean priorVacationRunning();
1048 int backupFile(char *);
1049 int recoverForwardFile(char *);
1054 void parseVacationMessage();
1055 void setGenDialog(DtMailGenDialog *dialog) { _dialog = dialog; }