Fix typo in license headers
[oweals/cde.git] / cde / programs / dtmail / include / DtMail / FileShare.hh
1 /*
2  *+SNOTICE
3  *
4  *
5  *      $TOG: FileShare.hh /main/5 1997/04/29 16:45:06 mgreess $
6  *
7  *      RESTRICTED CONFIDENTIAL INFORMATION:
8  *      
9  *      The information in this document is subject to special
10  *      restrictions in a confidential disclosure agreement bertween
11  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
12  *      document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
13  *      Sun's specific written approval.  This documment and all copies
14  *      and derivative works thereof must be returned or destroyed at
15  *      Sun's request.
16  *
17  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
18  *
19  *+ENOTICE
20  */
21
22 #ifndef _FILESHARE_HH
23 #define _FILESHARE_HH
24
25 #include <DtMail/DtMail.hh>
26 #include <Tt/tt_c.h>
27
28 class FileShare : public DtCPlusPlusAllocator {
29   public:
30     FileShare(DtMailEnv & error,
31               DtMail::Session * session,
32               const char * path,
33               DtMailCallback cb_func,
34               void * clientData);
35     virtual ~FileShare(void);
36     
37     void lockFile(DtMailEnv & error);
38     DtMailBoolean readOnly(DtMailEnv & error);
39     DtMailBoolean readWriteOverride(DtMailEnv & error);
40
41 #ifdef DEAD_WOOD
42     DtMailBoolean locked(void);
43 #endif /* DEAD_WOOD */
44
45   private:
46     struct TTHandle : public DtCPlusPlusAllocator {
47         DtMail::Session         *session;
48         DtMailObjectKey         key;
49         FileShare *             self;
50     };
51
52     DtMailObjectKey     _key;
53     DtMail::Session     *_session;
54     char                *_path;
55     TTHandle            *_tt_handle;
56     Tt_pattern          *_file_pats;
57     DtMailBoolean       _have_write_access;
58     DtMailBoolean       _other_modified;
59     DtMailCallback      _cb_func;
60     void                *_cb_data;
61
62     enum PendingOp {
63         PENDING_LOCK = 1,
64         PENDING_SAVE = 2,
65         PENDING_DESTROY = 3
66     };
67
68     PendingOp           _pending;
69     DtMailBoolean       _outstanding;
70
71     DtMailBoolean       isModified(DtMailEnv & error);
72
73     static Tt_message fileCB(Tt_message msg, Tttk_op op,
74                              char * path, void *clientData, int same_euid,
75                              int same_proc);
76
77     static Tt_callback_action mt_lock_cb(Tt_message m, Tt_pattern p);
78
79     static Tt_message fileRequestCB(Tt_message, Tttk_op,
80                                     char *, void *, int, int);
81
82   /* _mt_pattern is used to handle tlock and rulock messages from mailtool */
83     Tt_pattern  _mt_pattern;
84
85   /* _mt_lock is DTM_TRUE is we use the mailtool locking protocol */
86     int _mt_lock;
87 };
88
89 #endif