-fpermissive to allow GCC to compile old C++
[oweals/cde.git] / cde / programs / dtmail / dtmail / RoamInterruptibleCmd.hh
1 /*
2  *+SNOTICE
3  *
4  *      $XConsortium: RoamInterruptibleCmd.hh /main/3 1995/11/06 16:12:42 rswiston $
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
22 //////////////////////////////////////////////////////////////
23 // RoamInterruptibleCmd.h: Abstract class that supports lengthy,
24 //                     user-interruptible activities
25 //////////////////////////////////////////////////////////////
26 #ifndef ROAMINTERRUPTIBLECMD_H
27 #define ROAMINTERRUPTIBLECMD_H
28
29 #include <Xm/Xm.h>
30 #include "NoUndoCmd.h"
31
32 // Influenced by the InterruptibleCmd class from MotifApp.
33 // Different because it does not call the derived class's
34 // doit() repeatedly.  Instead, it repeatedly calls check_if_done().
35
36 // Define a type for the callback invoked when the task is finished
37
38 class RoamInterruptibleCmd;
39
40 typedef void (*RoamTaskDoneCallback) (
41                 RoamInterruptibleCmd *, 
42                 Boolean, 
43                 void * );
44
45 class RoamInterruptibleCmd : public NoUndoCmd {
46     
47   private:
48     
49     XtWorkProcId     _wpId;         // The ID of the workproc
50     RoamTaskDoneCallback _callback;     // Application-defined callback
51     void            *_clientData;
52     
53   protected:
54     
55     Boolean      _done;         // TRUE if the task has been completed
56     Boolean _interrupted;       // TRUE if the task was interrupted
57
58     virtual void cleanup();     // Called when task ends
59     virtual void updateMessage ( char * );
60
61     virtual void post_dialog() = 0;
62     virtual void unpost_dialog() = 0;
63     virtual void check_if_done() = 0;
64
65     Boolean workProc ();
66     static Boolean  workProcCallback ( XtPointer );
67     static void     interruptCallback ( void * );
68     void interrupt(); 
69
70     
71     // Derived classes implement doit(), declared by Cmd
72     
73   public:
74     
75     RoamInterruptibleCmd ( char * , char *, int );
76     virtual ~RoamInterruptibleCmd();
77     
78     virtual void execute();  // Overrides base class member function
79     virtual void execute ( RoamTaskDoneCallback, void * );
80
81     // Enable others to check if the command was interrupted...
82     virtual Boolean  interrupted();
83     
84     // Force update (and flushing of events in queue).
85     virtual void update();
86
87 };
88 #endif
89
90
91
92