src/include/common/spds/MailMessage.h

00001 /*
00002  * Copyright (C) 2003-2007 Funambol
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 #ifndef INCL_MAIL_MESSAGE
00019     #define INCL_MAIL_MESSAGE
00020 
00022 #include "base/util/ArrayList.h"
00023 #include "base/util/StringBuffer.h"
00024 #include "base/util/BasicTime.h"
00025 #include "spds/BodyPart.h"
00026 
00036 class MailMessage : public ArrayElement {
00037 
00038     private:
00039         // Used to store the newline format used in the incoming message 
00040         StringBuffer newline;
00041 
00042         //---------------------------------------- Message Headers
00043         StringBuffer to;
00044         StringBuffer from;
00045         StringBuffer cc;
00046         StringBuffer bcc;
00047 
00048         StringBuffer subject;
00049 
00050         BasicTime date;
00051         BasicTime received;
00052 
00053         StringBuffer contentType;
00054         StringBuffer boundary;
00055         StringBuffer mimeVersion;
00056         StringBuffer messageId;
00057 
00058         ArrayList headers;
00059         
00060                 // can be used by the client to store an internal msg id
00061                 StringBuffer entryId;
00062         //
00063                 //time_t lastModificationTime;
00064 
00065         BodyPart body;
00066         //BodyPart *alternate;
00067         ArrayList attachments;
00068 
00069         int parseHeaders(StringBuffer &rfcHeaders);
00070         int parseBodyParts(StringBuffer &rfcBody);
00071 
00072     public:
00073 
00074         // Headers
00075         const char *getTo() const;
00076         void setTo(const char *to);
00077 
00078         const char *getFrom() const;
00079         void setFrom(const char *from);
00080 
00081         const char *getCc() const;
00082         void setCc(const char *cc);
00083 
00084         const char *getBcc() const ;
00085         void setBcc(const char *bcc);
00086 
00087         const char *getSubject() const ;
00088         void setSubject(const char *subj);
00089                 
00090         const BasicTime& getDate() const ;
00091         void setDate(const BasicTime& d);
00092                 
00093         const BasicTime& getReceived() const ;
00094 
00095         const char * getContentType() const ;
00096         void setContentType(const char *val);
00097 
00098         const char * getBoundary() const ;
00099         void setBoundary(const char *val);
00100 
00101         const char * getMimeVersion() const ;
00102         void setMimeVersion(const char *val);
00103         
00104         const char * getMessageId() const ;
00105         void setMessageId(const char *val);
00106         
00107                 const char*  getEntryID();
00108                 void setEntryID(const char*  id);
00109 
00110         void setHeaders(const char*  extraHeaders); 
00111         const char* getHeaders();
00112 
00113         // Body
00114                 BodyPart & getBody();
00115                 void setBody(BodyPart &body);
00116         //BodyPart * getAlternate();
00117         //void setAlternate(BodyPart &alt);
00118                 
00119         // Attachment
00120         BodyPart * getFirstAttachment() ;
00121         BodyPart * getNextAttachment() ;
00122         int addAttachment(BodyPart &att);
00123         int attachmentCount();
00124 
00125         // Conversion methods
00126         char *format();
00127         int parse(const char *rfc2822, size_t len = StringBuffer::npos);
00128 
00129         /*
00130          * Return true if the message is empty
00131          */
00132         bool empty();
00133 
00134         ArrayElement* clone();
00135 
00136         bool operator==(MailMessage& that);
00137 
00138 };
00139 
00141 #endif

Generated on Fri Apr 27 12:29:18 2007 for Funambol C++ Client Library by  doxygen 1.5.2