Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtmail / dtmail / Dmx.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 librararies 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 /* $XConsortium: Dmx.h /main/4 1996/04/21 19:55:42 drk $ */
24
25 #ifndef _DMX_HH
26 #define _DMX_HH
27
28 /*
29  *+SNOTICE
30  *
31  *      $:$
32  *
33  *      RESTRICTED CONFIDENTIAL INFORMATION:
34  *      
35  *      The information in this document is subject to special
36  *      restrictions in a confidential disclosure agreement between
37  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
38  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
39  *      Sun's specific written approval.  This document and all copies
40  *      and derivative works thereof must be returned or destroyed at
41  *      Sun's request.
42  *
43  *      Copyright 1994 Sun Microsystems, Inc.  All rights reserved.
44  *
45  *+ENOTICE
46  */
47 /*
48  *                   Common Desktop Environment
49  *
50  *   (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
51  *   (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
52  *   (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
53  *   (c) Copyright 1993, 1994, 1995 Novell, Inc.
54  *   (c) Copyright 1995 Digital Equipment Corp.
55  *   (c) Copyright 1995 Fujitsu Limited
56  *   (c) Copyright 1995 Hitachi, Ltd.
57  *                                                                   
58  *
59  *                     RESTRICTED RIGHTS LEGEND                              
60  *
61  *Use, duplication, or disclosure by the U.S. Government is subject to
62  *restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
63  *Technical Data and Computer Software clause in DFARS 252.227-7013.  Rights
64  *for non-DOD U.S. Government Departments and Agencies are as set forth in
65  *FAR 52.227-19(c)(1,2).
66
67  *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
68  *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A. 
69  *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
70  *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
71  *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
72  *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
73  *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
74  */
75
76
77 #include <stdio.h>
78 #include <stdlib.h>
79 #include <unistd.h>
80
81 #include <string.h>
82
83 #include <sys/types.h>
84 #include <ctype.h>
85
86 #include <DtMail/DtMail.hh>
87 #include <DtMail/DtMailError.hh>
88 #include <DtMail/DtMailValues.hh>
89 #include <Dt/Dts.h>
90
91 extern const char *const        dmxversion;
92
93 typedef enum {
94     DMX_NONE_STRING,
95     DMX_CC_HEADER_STRING,
96     DMX_DATE_HEADER_STRING,
97     DMX_FROM_HEADER_STRING,
98     DMX_SUBJECT_HEADER_STRING,
99     DMX_TO_HEADER_STRING,
100     DMX_PAGE_NUMBER_STRING,
101     DMX_USER_NAME_STRING,
102     /*
103      * KEEP THIS LAST
104      */
105     DMX_NUM_STRING_TYPE_ENUM
106 } DmxStringTypeEnum;
107
108 typedef enum
109 {
110     DMX_SEPARATOR_NEW_LINE,
111     DMX_SEPARATOR_BLANK_LINE,
112     DMX_SEPARATOR_CHARACTER_LINE,
113     DMX_SEPARATOR_PAGE_BREAK,
114     DMX_SEPARATOR_NEW_JOB,
115     /*
116      * KEEP THIS LAST
117      */
118     DMX_NUM_MSG_SEPARATOR_ENUM
119 } DmxMsgSeparatorEnum;
120
121 typedef enum
122 {
123     DMX_PRINT_HEADERS_NONE,
124     DMX_PRINT_HEADERS_STANDARD,
125     DMX_PRINT_HEADERS_ABBREV,
126     DMX_PRINT_HEADERS_ALL,
127     /*
128      * KEEP THIS LAST
129      */
130     DMX_NUM_PRINT_HEADERS_ENUM
131 } DmxPrintHeadersEnum;
132
133 typedef enum
134 {
135         DMXCC,
136         DMXFROM,
137         DMXSUBJ,
138         DMXCLENGTH,
139         DMXSTATUS,
140         DMXDATE,
141         DMXTO,
142         DMXV3CHARSET,
143         DMXCONTENTTYPE,
144         DMXNUMHDRS
145 } DmxHeaders;
146
147 // utils
148 char            *convertValueToString (DtMailValueSeq *, int);
149 DtMailBoolean   handleError (DtMailEnv &, char *);
150 char            *getStandardHeaders (DtMailHeaderLine &);
151 char            *errorString (DmxHeaders);
152
153 class DmxMsg
154 {
155     public:
156
157     typedef void (*DmxPrintOutputProc)(XtPointer, char*);
158
159         DmxMsg (void);
160
161         void    display (DmxPrintHeadersEnum, DmxPrintOutputProc, XtPointer);
162         void    setHandle (DtMailMessageHandle &);
163         void    setHeader (DtMailHeaderLine &);
164         void    setMessage (DtMail::Message *);
165         void    setInfo (char *);
166         void    parse (void);
167         char    *getPrintedHeaders (DmxPrintHeadersEnum);
168         char    *getHeaders (DtMailBoolean);
169         char    *getMessageHeader (DmxHeaders);
170         
171         
172         DtMailMessageHandle     msgHandle;
173         DtMailHeaderLine        msgHeader;
174         DtMail::Message         *message;
175
176         DtMail::BodyPart        **bodyParts;
177         int     numBPs;
178
179         char            *addlInfo;
180         DtMailBoolean   cachedValues;
181         DtMailBoolean   isNew;
182         // other flags for status (read, unopened, etc.)
183 };
184
185
186 class DmxMailbox
187 {
188 private:
189     void                createHeaderRequest (DtMailHeaderRequest &);
190     void                printMailboxInfo (void);
191
192     static const int    _firstIndex;
193     char                *_fileName;
194     DtMail::MailBox     *_mbox;
195     DmxMsg              _messages[2048];
196     DmxMsg              *_message;
197     int                 _messageCount;
198 public:
199     DmxMailbox (char*);
200     ~DmxMailbox (void);
201
202     void                loadMessages (void);
203     inline DmxMsg       *firstMessage (void)
204                         {
205                             return (_message = &_messages[_firstIndex]);
206                         }
207     inline DmxMsg       *nextMessage (void)
208                         {
209                             _message++;
210                             return ((_message <= &_messages[_messageCount]) ?
211                                     _message :
212                                     (DmxMsg*)NULL);
213                         }
214     inline int          numMessages (void) { return _messageCount; }
215
216 };
217
218
219
220 #endif // _DMX_HH