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
26 * $TOG: AUTOServer.C /main/6 1998/11/10 17:07:17 mgreess $
28 * RESTRICTED CONFIDENTIAL INFORMATION:
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
38 * Copyright 1993, 1995, 1995 Sun Microsystems, Inc. All rights reserved.
43 * Common Desktop Environment
45 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
46 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
47 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
48 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
49 * (c) Copyright 1995 Digital Equipment Corp.
50 * (c) Copyright 1995 Fujitsu Limited
51 * (c) Copyright 1995 Hitachi, Ltd.
54 * RESTRICTED RIGHTS LEGEND
56 *Use, duplication, or disclosure by the U.S. Government is subject to
57 *restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
58 *Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
59 *for non-DOD U.S. Government Departments and Agencies are as set forth in
60 *FAR 52.227-19(c)(1,2).
62 *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
63 *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
64 *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
65 *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
66 *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
67 *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
68 *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
76 #include <DtMail/DtMailServer.hh>
78 AUTOServer::AUTOServer(
80 DtMail::Session *session,
81 DtMail::MailBox *mailbox,
82 DtMailAppendCallback append_mailbox_cb,
83 void *append_mailbox_cb_data)
84 : DtMailServer(folder, session, mailbox,
85 append_mailbox_cb, append_mailbox_cb_data)
90 AUTOServer::~AUTOServer()
96 // Set delete flag for given message.
99 AUTOServer::ptrans_delete(int number)
101 static char *pname = "AUTOServer::ptrans_delete";
103 if (_server) return _server->ptrans_delete(number);
105 _logger.logError(DTM_FALSE, "%s: NULL server\n", pname);
106 return DTME_MailServerAccess_Error;
110 // Apply for connection authorization
113 AUTOServer::ptrans_authorize(char *buf)
115 static char *pname = "AUTOServer::ptrans_authorize";
117 if (_server) return _server->ptrans_authorize(buf);
119 _logger.logError(DTM_FALSE, "%s: NULL server\n", pname);
120 return DTME_MailServerAccess_Error;
124 // Expunge deleted messages
127 AUTOServer::ptrans_fldstate_expunge()
129 static char *pname = "AUTOServer::ptrans_fldstate_expunge";
131 if (_server) return _server->ptrans_fldstate_expunge();
133 _logger.logError(DTM_FALSE, "%s: NULL server\n", pname);
134 return DTME_MailServerAccess_Error;
138 // Get range of messages to be fetched
141 AUTOServer::ptrans_fldstate_read(int *countp, int *newp)
143 static char *pname = "AUTOServer::ptrans_fldstate_read";
145 if (_server) return _server->ptrans_fldstate_read(countp, newp);
147 _logger.logError(DTM_FALSE, "%s: NULL server\n", pname);
148 return DTME_MailServerAccess_Error;
152 // Capture the sizes of all messages.
155 AUTOServer::ptrans_msgsizes(int count, int *sizes)
157 static char *pname = "AUTOServer::ptrans_msgsizes";
159 if (_server) return _server->ptrans_msgsizes(count, sizes);
161 _logger.logError(DTM_FALSE, "%s: NULL server\n", pname);
162 return DTME_MailServerAccess_Error;
166 // Is the given message old?
169 AUTOServer::ptrans_msgisold(int num)
171 static char *pname = "AUTOServer::ptrans_msgisold";
173 if (_server) return _server->ptrans_msgisold(num);
182 AUTOServer::ptrans_quit()
184 static char *pname = "AUTOServer::ptrans_quit";
186 if (_server) return _server->ptrans_quit();
188 _logger.logError(DTM_FALSE, "%s: NULL server\n", pname);
189 return DTME_MailServerAccess_Error;
193 // request nth message
196 AUTOServer::ptrans_retrieve_start(int number, int *lenp)
198 static char *pname = "AUTOServer::ptrans_retrieve_start";
200 if (_server) return _server->ptrans_retrieve_start(number, lenp);
202 _logger.logError(DTM_FALSE, "%s: NULL server\n", pname);
203 return DTME_MailServerAccess_Error;
207 // Parse command response
210 AUTOServer::ptrans_parse_response(char *argbuf)
212 static char *pname = "AUTOServer::ptrans_parse_response";
214 if (_server) return _server->ptrans_parse_response(argbuf);
216 _logger.logError(DTM_FALSE, "%s: NULL server\n", pname);
217 return DTME_MailServerAccess_Error;
221 // Retrieve messages using IMAP Version 2bis or Version 4.
224 AUTOServer::retrieve_messages(DtMailEnv &error)
228 _server->retrieve_messages(error);
233 // First time through
235 for (int i=0; i<AUTO_NPROTOCOLS; i++)
243 _server = new POP3Server(
248 _append_mailbox_cb_data);
251 _server = new APOPServer(
256 _append_mailbox_cb_data);
259 _server = new IMAPServer(
264 _append_mailbox_cb_data);
267 _server = new POP2Server(
272 _append_mailbox_cb_data);
278 if (NULL != _password)
279 _server->set_password(_password);
281 _server->retrieve_messages(error);
282 if (DTME_MailServerAccess_MissingPassword == (DTMailError_t) error)
288 else if (error.isNotSet())
295 // Discard tail of FETCH response after reading message text.
298 AUTOServer::ptrans_retrieve_end(int number)
300 static char *pname = "AUTOServer::ptrans_retrieve_end";
303 return _server->ptrans_retrieve_end(number);
305 _logger.logError(DTM_FALSE, "%s: NULL server\n", pname);
306 return DTME_MailServerAccess_Error;