src/include/common/spds/MailMessage.h

00001 /*
00002  * Funambol is a mobile platform developed by Funambol, Inc. 
00003  * Copyright (C) 2003 - 2007 Funambol, Inc.
00004  * 
00005  * This program is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Affero General Public License version 3 as published by
00007  * the Free Software Foundation with the addition of the following permission 
00008  * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
00009  * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE 
00010  * WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00015  * details.
00016  * 
00017  * You should have received a copy of the GNU Affero General Public License 
00018  * along with this program; if not, see http://www.gnu.org/licenses or write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00020  * MA 02110-1301 USA.
00021  * 
00022  * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite 
00023  * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
00024  * 
00025  * The interactive user interfaces in modified source and object code versions
00026  * of this program must display Appropriate Legal Notices, as required under
00027  * Section 5 of the GNU Affero General Public License version 3.
00028  * 
00029  * In accordance with Section 7(b) of the GNU Affero General Public License
00030  * version 3, these Appropriate Legal Notices must retain the display of the
00031  * "Powered by Funambol" logo. If the display of the logo is not reasonably 
00032  * feasible for technical reasons, the Appropriate Legal Notices must display
00033  * the words "Powered by Funambol".
00034  */
00035 #ifndef INCL_MAIL_MESSAGE
00036     #define INCL_MAIL_MESSAGE
00037 
00039 #include "base/util/ArrayList.h"
00040 #include "base/util/StringBuffer.h"
00041 #include "base/util/BasicTime.h"
00042 #include "spds/BodyPart.h"
00043 #include "base/globalsdef.h"
00044 
00045 BEGIN_NAMESPACE
00046 
00056 class MailMessage : public ArrayElement {
00057 
00058     private:
00059         // Used to store the newline format used in the incoming message
00060         StringBuffer newline;
00061 
00062         //---------------------------------------- Message Headers
00063         StringBuffer to;
00064         StringBuffer from;
00065         StringBuffer cc;
00066         StringBuffer bcc;
00067 
00068         StringBuffer subject;
00069 
00070         BasicTime date;
00071         BasicTime received;
00072 
00073         StringBuffer contentType;
00074         StringBuffer boundary;
00075         StringBuffer mimeVersion;
00076         StringBuffer messageId;
00077 
00078         ArrayList headers;
00079 
00080         // can be used by the client to store an internal msg id
00081         StringBuffer entryId;
00082         //
00083         //time_t lastModificationTime;
00084 
00085         // it is the priority of the mail message. 
00086         StringBuffer importance;
00087 
00088         BodyPart body;
00089         //BodyPart *alternate;
00090         ArrayList attachments;
00091 
00092         int parseHeaders(StringBuffer &rfcHeaders);
00093         int parseBodyParts(StringBuffer &rfcBody);
00094 
00095     public:
00096 
00097         // Headers
00098         const char *getTo() const;
00099         void setTo(const char *to);
00100 
00101         const char *getFrom() const;
00102         void setFrom(const char *from);
00103 
00104         const char *getCc() const;
00105         void setCc(const char *cc);
00106 
00107         const char *getBcc() const ;
00108         void setBcc(const char *bcc);
00109 
00110         const char *getSubject() const ;
00111         void setSubject(const char *subj);
00112 
00113         const BasicTime& getDate() const ;
00114         void setDate(const BasicTime& d);
00115 
00116         const BasicTime& getReceived() const ;
00117 
00118         const char * getContentType() const ;
00119         void setContentType(const char *val);
00120 
00121         const char * getBoundary() const ;
00122         void setBoundary(const char *val);
00123 
00124         const char * getMimeVersion() const ;
00125         void setMimeVersion(const char *val);
00126 
00127         const char * getMessageId() const ;
00128         void setMessageId(const char *val);
00129 
00130         const char*  getEntryID();
00131         void setEntryID(const char*  id);
00132 
00133         void setHeaders(const char*  extraHeaders);
00134         const char* getHeaders();
00135 
00136         void setImportance(const char*  importance);
00137         const char* getImportance();
00138 
00139         // Body
00140         BodyPart & getBody();
00141         void setBody(BodyPart &body);
00142         //BodyPart * getAlternate();
00143         //void setAlternate(BodyPart &alt);
00144 
00145         // Attachment
00146         BodyPart * getFirstAttachment() ;
00147         BodyPart * getNextAttachment() ;
00148         int addAttachment(BodyPart &att);
00149         int attachmentCount();
00150 
00151         // Conversion methods
00152         char *format();
00153         int parse(const char *rfc2822, size_t len = StringBuffer::npos);
00154 
00155         /*
00156          * Return true if the message is empty
00157          */
00158         bool empty();
00159 
00160         ArrayElement* clone();
00161 
00162         bool operator==(MailMessage& that);
00163 
00164         static StringBuffer decodeHeader(StringBuffer line);
00165 
00166 };
00167 
00168 
00169 END_NAMESPACE
00170 
00172 #endif

Generated on Fri Jul 25 15:04:15 2008 for Funambol C++ Client Library by  doxygen 1.5.1