2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $XConsortium: mailbox.C /main/4 1996/04/21 19:44:02 drk $ */
30 * RESTRICTED CONFIDENTIAL INFORMATION:
32 * The information in this document is subject to special
33 * restrictions in a confidential disclosure agreement between
34 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
35 * document outside HP, IBM, Sun, USL, SCO, or Univel without
36 * Sun's specific written approval. This document and all copies
37 * and derivative works thereof must be returned or destroyed at
40 * Copyright 1994 Sun Microsystems, Inc. All rights reserved.
49 DmxMailbox::DmxMailbox (void)
59 DmxMailbox::loadMessages (void)
62 boolean_t moreMessages = B_TRUE;
66 mbox->open (env, /* DtMailEnv */
67 DTM_FALSE, /* auto_create */
68 O_RDONLY, /* open(2) flag */
69 (mode_t) 0, /* create(2) mode */
70 DTM_FALSE, /* lock_flag */
71 DTM_TRUE /* auto_parse */
74 if (handleError (env, "open mailbox") == B_TRUE)
77 // get the first message handle
78 DtMailMessageHandle first = NULL, next = NULL, prev = NULL;
79 DtMailHeaderRequest request;
80 DtMailHeaderLine hdrline;
82 DtMail::Message *m = NULL; // temporary
84 createHeaderRequest (request);
86 first = mbox->getFirstMessageSummary (env, request, hdrline);
88 if (handleError (env, "get first msg summary") == B_TRUE)
94 "loadMessages: error w/1st message...exiting.\n");
98 // this makes hash of the caching strategy, but oh well....
99 m = mbox->getMessage (env, first);
100 if (handleError (env, "get first msg") == B_TRUE)
102 msg [i].setMessage (m);
106 msg [i].setHandle (first);
107 msg [i].setHeader (hdrline);
109 while (moreMessages == B_TRUE)
111 next = mbox->getNextMessageSummary (env, prev,
116 moreMessages = B_FALSE;
117 if (handleError (env, "msgLoop") == B_TRUE)
119 break; // break out if error
122 msg [i].setHandle (next);
123 msg [i].setHeader (hdrline);
132 // fill in the remaining message structures .. temporary, honest!
133 for (int j = 1; j <= messageCount; j++)
135 m = mbox->getMessage (env, msg [j].msgHandle);
136 if (handleError (env, "getMessage loop") == B_TRUE)
138 printf ("fatal error...bailing...\n");
141 msg [j].setMessage (m);
144 sprintf (tmp, "%d", j); // ick
145 msg [j].setInfo (tmp);
148 if (msg[j].isNew == B_TRUE)
159 // no new messages -- start with first message in mailbox
163 // free header request structure
165 // this assumes that you have allocated all of the possible headers
166 // in the enum DmxHeaders -- a bad assumption, but currently true
167 for (k = 0; k < DMXNUMHDRS; k++)
169 free (request.header_name [k]);
171 delete request.header_name;
177 DmxMailbox::createHeaderRequest (DtMailHeaderRequest &request)
179 // set up default headers
180 request.number_of_names = DMXNUMHDRS;
181 request.header_name = new (char* [DMXNUMHDRS]);
182 request.header_name[DMXFROM] = strdup(DtMailMessageSender);
183 request.header_name[DMXSUBJ] = strdup(DtMailMessageSubject);
184 request.header_name[DMXDATE] = strdup(DtMailMessageReceivedTime);
185 request.header_name[DMXCLENGTH] = strdup(DtMailMessageContentLength);
186 request.header_name[DMXSTATUS] = strdup(DtMailMessageStatus);
187 request.header_name[DMXTO] = strdup(DtMailMessageTo);
188 request.header_name[DMXV3CHARSET] = strdup(DtMailMessageV3charset);
189 request.header_name[DMXCONTENTTYPE] = strdup(DtMailMessageContentType);
195 DmxMailbox::printMailboxInfo (void)
199 printf ("\"%s\": %d messages %d new\n",
200 name, messageCount, newMessages);
202 printf ("\"%s\": %d messages\n",