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