-fpermissive to allow GCC to compile old C++
[oweals/cde.git] / cde / programs / dtmail / dtmail / MailSession.hh
1 /*
2  *+SNOTICE
3  *
4  *      $TOG: MailSession.hh /main/8 1999/03/26 16:52:44 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 _MAILSESSION_HH
22 #define _MAILSESSION_HH
23
24 #include <sys/stat.h>
25 #include <sys/types.h>
26
27 #include <DtMail/DtMail.hh>
28 #include "RoamMenuWindow.h"
29
30 class MailSession
31 {
32   public:
33     MailSession(DtMailEnv &, XtAppContext);
34     ~MailSession(void);
35
36     // raises ME_NotBento, ME_AlreadyLocked, ME_OtherAssumedRole, ME_NoSuchFile
37     DtMail::MailBox     *open(DtMailEnv&, const char*, DtMailCallback, void*,
38                               DtMailBoolean auto_create = DTM_TRUE,
39                               DtMailBoolean request_lock = DTM_TRUE,
40                               DtMailBoolean auto_parse = DTM_TRUE);
41
42     void                 close(DtMailEnv&, const DtMail::MailBox*);
43
44     // raises ME_UnknownFormat
45     void                 convert(DtMailEnv&, const char*, const char*,
46                                  DtMailStatusCallback cb_func = NULL,
47                                  void *client_data = NULL);
48
49     // raises ME_NotBento, ME_RequestDenied
50     void                 copy(DtMailEnv&, DtMail::Message&, const char*);
51
52     int                  isActiveRMW(RoamMenuWindow*);
53     void                 activateRMW(RoamMenuWindow*);
54     void                 deactivateRMW(RoamMenuWindow*);
55     RoamMenuWindow      *getRMW(DtMail::MailBox* mbox);
56     RoamMenuWindow      *getRMW(const char* path);
57     Boolean              isMboxOpen(const char* path);
58     int                  numDeactivatedRMW() { return _num_deactivated; }
59     DtMail::Session     *session(void) { return _app_session; }
60
61   private:
62     struct MailBoxItem
63     {
64         DtMail::MailBox         *handle;
65         int                      stated;
66         struct stat              statbuf;
67         int                      is_active;
68         int                      open_ref_count;
69         char                    *path;
70         RoamMenuWindow          *rmw;
71     };
72     DtVirtArray<MailBoxItem *>   _open_mailboxes;
73     static DtMail::Session      *_app_session;
74     static int                   _num_deactivated;
75
76     void        addToList(DtMail::MailBox*, const char*, RoamMenuWindow*);
77     int         locate(const char * path);
78     int         locate(const DtMail::MailBox *);
79     int         locate(const RoamMenuWindow *);
80     static Tt_status
81                 lockCB(Tt_message, Tttk_op, const char*, uid_t, int, void*);
82 };
83
84 #endif