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         MailMessage();
00098 
00099         // Headers
00100         const char *getTo() const;
00101         void setTo(const char *to);
00102 
00103         const char *getFrom() const;
00104         void setFrom(const char *from);
00105 
00106         const char *getCc() const;
00107         void setCc(const char *cc);
00108 
00109         const char *getBcc() const ;
00110         void setBcc(const char *bcc);
00111 
00112         const char *getSubject() const ;
00113         void setSubject(const char *subj);
00114 
00115         const BasicTime& getDate() const ;
00116         void setDate(const BasicTime& d);
00117 
00118         const BasicTime& getReceived() const ;
00119 
00120         const char * getContentType() const ;
00121         void setContentType(const char *val);
00122 
00123         const char * getBoundary() const ;
00124         void setBoundary(const char *val);
00125 
00126         const char * getMimeVersion() const ;
00127         void setMimeVersion(const char *val);
00128 
00129         const char * getMessageId() const ;
00130         void setMessageId(const char *val);
00131 
00132         const char*  getEntryID();
00133         void setEntryID(const char*  id);
00134 
00135         void setHeaders(const char*  extraHeaders);
00136         const char* getHeaders();
00137 
00138         void setImportance(const char*  importance);
00139         const char* getImportance();
00140 
00141         // Body
00142         BodyPart & getBody();
00143         void setBody(BodyPart &body);
00144         //BodyPart * getAlternate();
00145         //void setAlternate(BodyPart &alt);
00146 
00147         // Attachment
00148         BodyPart * getFirstAttachment() ;
00149         BodyPart * getNextAttachment() ;
00150         int addAttachment(BodyPart &att);
00151         int attachmentCount();
00152 
00153         // Conversion methods
00154         char *format();
00155         int parse(const char *rfc2822, size_t len = StringBuffer::npos);
00156 
00157         /*
00158          * Return true if the message is empty
00159          */
00160         bool empty();
00161 
00162         ArrayElement* clone();
00163 
00164         bool operator==(MailMessage& that);
00165 
00166         static StringBuffer decodeHeader(StringBuffer line);
00167 
00168 };
00169 
00170 
00171 END_NAMESPACE
00172 
00174 #endif

Generated on Wed Jan 14 17:15:36 2009 for Funambol C++ Client Library by  doxygen 1.5.2