Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtmail / dtmail / RoamApp.h
1 /*
2  *+SNOTICE
3  *
4  *      $TOG: RoamApp.h /main/20 1999/07/13 08:41:18 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 ROAMAPP_H
22 #define ROAMAPP_H
23
24 #include <stdio.h>
25
26 #include "Application.h"
27 #include "MailSession.hh"
28 #include <DtMail/DtVirtArray.hh>
29
30 class Cmd;
31 class VacationCmd;
32 class DtMailGenDialog;
33 class RoamMenuWindow;
34
35 class RoamApp : public Application
36 {
37   private:
38     DtVirtArray<Display*> _activePrintDisplays;
39     int                 _busy_count;
40     DtMailGenDialog     *_dialog;
41     Display             *_errorPrintDisplay;
42     Boolean             _firstSaveYourselfArrived;
43     Cmd                 *_options;
44     char                *_optionsHandle;
45     RoamMenuWindow      *_mailview;
46     Boolean             _quitSilently;
47     Boolean             _quitQuickly;
48     static XtResource   _resources[];
49     VacationCmd         *_vacation;
50     FILE                *session_fp;
51     XtWorkProcId        _shutdownWorkprocID;
52
53     void                initSession(void);
54     void                openSessionFile(char *filename);
55     char                *parseSessionArg(int *argc, char **argv);
56     void                restoreSession(void);
57     static Boolean      shutdownWorkproc(XtPointer);
58     static void         smpDieCB(Widget, XtPointer, XtPointer);
59     static void         smpInteractCB(Widget, XtPointer, XtPointer);
60     static void         smpSaveSessionCB(Widget, XtPointer, XtPointer);
61     virtual int         smpSaveSessionGlobal(void);
62     virtual void        smpSaveSessionLocal(void);
63
64     
65   protected:
66     XtIntervalId        _appTimeoutId;
67     char                *_default_mailbox;
68     char                *_glyph_font;   // Font for attchment glyph
69     char                *_glyph_name;   // Font for attchment glyph
70     char                *_mailfiles_folder;
71     MailSession         *_mail_session;
72     DtMail::Transport   *_mail_transport;
73     char                *_print_script;
74     char                *_system_font;  // Variable width font
75     XmFontList          _system_fontlist;
76     int                 _tt_fd;
77     char                *_user_font;    // Fixed width font
78     XmFontList          _user_fontlist;
79     
80     static void         applicationTimeout ( XtPointer, XtIntervalId * );
81     static void         disableGroupPrivileges(void *);
82     static void         enableGroupPrivileges(void *);
83     static long         lastInteractiveEventTime(void *);
84     static void         setBusyState(DtMailEnv &, DtMailBusyState, void *);
85     static void         showBusyState(DtMailEnv &, DtMailBusyState, void *);
86     void                timeout(XtIntervalId *);
87
88   public:
89     RoamApp(char*);
90     virtual ~RoamApp();     
91
92     void                busyAllWindows(const char * msg = NULL);
93     virtual const char *const
94                         className()
95                             { return "RoamApp"; }
96     void                closeAllWindows(void);
97     char                *default_mailbox()
98                             { return _default_mailbox; }
99     DtMail::Transport   *default_transport(void)
100                             { return _mail_transport; }
101     MainWindow          *defaultStatusWindow();
102     int                 (*_default_x_error_handler)(Display*, XErrorEvent*);
103     DtMailGenDialog     *genDialog();
104     Display             *getErrorPrintDisplay(void)
105                             { return _errorPrintDisplay; }
106     void                globalAddToCachedContainerList(char*);
107     void                globalPropChange(void);
108     char                *glyphName(void)
109                             { return _glyph_name; }
110     RoamMenuWindow      *inboxWindow();
111     virtual void        initialize( int *, char ** );  
112     Boolean             isActivePrintDisplay(Display *display)
113                           { return (_activePrintDisplays.indexof(display)>=0); }
114     Cmd                 *mailOptions(void)
115                             { return _options; };
116     char                *mail_folder()
117                             { return _mailfiles_folder; }
118     RoamMenuWindow      *nextRoamMenuWindow(RoamMenuWindow*);
119     void                closeInactiveRoamMenuWindows(void);
120     void                reopenRoamMenuWindows(void);
121     virtual void        open_catalog();  
122     char                *optionsDialog(void)
123                             { return _optionsHandle; }
124     char                *print_script(){ return _print_script; }
125     Boolean             quitSilently(void)
126                             { return _quitSilently; }
127     Boolean             quitQuickly(void)
128                             { return _quitQuickly; }
129     void                registerActivePrintDisplay(Display *display)
130                             { _activePrintDisplays.append(display); }
131     MailSession         *session(void) { return _mail_session; }
132     FILE                *sessionFile(void) { return session_fp;}
133     void                setErrorPrintDisplay(Display *display)
134                             { _errorPrintDisplay = display; }
135     void                setOptionsDialog(char *oHandle)
136                             { _optionsHandle = oHandle; }
137     void                setQuitSilently(void) { _quitSilently = TRUE; }
138     void                setQuitQuickly(void) { _quitQuickly = TRUE; }
139     void                setSession(MailSession *);
140     virtual void        shutdown();
141     void                checkForShutdown();
142     Boolean             startVacation(Widget, Widget);
143     static void         statusCallback(DtMailOperationId, DtMailEnv&, void*);
144     void                stopVacation();
145     void                unbusyAllWindows(void);
146     void                unregisterActivePrintDisplay(Display *display)
147                             { _activePrintDisplays.remove(display); }
148     void                unsetQuitSilently(void) { _quitSilently = FALSE; }
149     void                unsetQuitQuickly(void) { _quitQuickly = FALSE; }
150     VacationCmd* vacation();
151 };
152
153 // This method will parse a colon/space tuples that are used in
154 // the mail properties.
155 //
156 struct PropStringPair {
157     char *      label;
158     char *      value;
159
160     PropStringPair(void);
161     PropStringPair(const PropStringPair &);
162     ~PropStringPair(void);
163 };
164
165 char *formatPropPair(char * key, void * data);
166 void parsePropString(const char * input, DtVirtArray<PropStringPair *> & result);
167 char* getPropStringValue(DtVirtArray<PropStringPair *> &result, const char *value);
168
169 extern RoamApp theRoamApp;
170
171 // This variable indicates whether RoamMenuWindow is mapped or not.
172 // If a RMW is mapped, then Self_destruct will not be called by Compose
173 // if Compose was started by ToolTalk.
174 extern int dtmail_mapped;
175
176 #endif // ROAMAPP_H