src/include/common/spds/EmailData.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 
00019 
00020 #ifndef INCL_MAIL
00021 #define INCL_MAIL
00022 
00024 #include "base/util/ArrayElement.h"
00025 #include "base/util/StringBuffer.h"
00026 #include "spds/MailMessage.h"
00027 #include "spds/EmailData.h"
00028 
00029 class EmailData : public ArrayElement {
00030     
00031     // ------------------------------------------------------- Private data
00032     private:
00033         bool read;
00034         bool forwarded;
00035         bool replied;
00036         StringBuffer received;
00037         StringBuffer created;
00038         StringBuffer modified;
00039         bool deleted;
00040         bool flagged;
00041 
00042         MailMessage emailItem;
00043         
00044         // these are fields added for the inclusive filters
00045         class ExtMailData : public ArrayElement {  
00046             public:
00047                 ExtMailData() {
00048                     attachName = 0;
00049                     attachSize = 0;
00050                 }  
00051                 ~ExtMailData() {
00052                     if (attachName) {
00053                         delete [] attachName; attachName = NULL;
00054                     }
00055                 }
00056                 char*       attachName;
00057                 long        attachSize;  
00058                 ArrayElement* clone() {
00059                     ExtMailData* ret = new ExtMailData();
00060                     ret->attachName = stringdup(attachName);
00061                     ret->attachSize = attachSize;
00062                     return ret;
00063                 }
00064 
00065         } *extMailData;
00066 
00067 
00068         unsigned long remainingBodySize;
00069         unsigned long remainingAttachNumber;
00070         unsigned long totalEmailSize;
00071         bool isMailPartial;
00072         ArrayList* remainingAttachments;        
00073 
00074     public:
00075     // ------------------------------------------------------- Constructors
00076         EmailData();
00077         ~EmailData();
00078 
00079     // ---------------------------------------------------------- Accessors  
00080         bool getRead() { return read; }
00081         void setRead(bool v) { read=v; }
00082 
00083         bool getForwarded() { return forwarded; }
00084         void setForwarded(bool v) { forwarded=v; }
00085 
00086         bool getReplied() { return replied; }
00087         void setReplied(bool r) { replied=r; }
00088         
00089         const char * getReceived() { return received; }
00090         void setReceived(const char * v) { received=v; }
00091 
00092         const char * getCreated() { return created; }
00093         void setCreated(const char * v) { created=v; }
00094 
00095         const char * getModified() { return modified; }
00096         void setModified(const char * v) { modified=v; }
00097 
00098         bool getDeleted() { return deleted; }
00099         void setDeleted(bool v) { deleted=v; }
00100 
00101         bool getFlagged() { return flagged; }
00102         void setFlagged(bool v) { flagged=v; }
00103 
00104         MailMessage& getEmailItem() { return emailItem; }
00105         void setEmailItem(const MailMessage& v) { emailItem = v; }
00106 
00107     // ----------------------------------------------------- Public Methods
00108         int parse(const char *syncmlData, size_t len = StringBuffer::npos) ;
00109         char *format() ;
00110 
00111         ArrayElement* clone() { return new EmailData(*this); }
00112 
00113         unsigned long getRemainingBodySize() { return remainingBodySize; }
00114         void setRemainingBodySize(unsigned long v) { remainingBodySize = v; }
00115 
00116         unsigned long getRemainingAttachNumber() { return remainingAttachNumber; }
00117         void setRemainingAttachNumber(unsigned long v) { remainingAttachNumber = v; }
00118 
00119         unsigned long getTotalEmailSize() { return totalEmailSize; }
00120         void setTotalEmailSize(unsigned long v) { totalEmailSize = v; }
00121 
00122         bool getIsMailPartial() { return isMailPartial; }
00123         
00124         const char* getAttachmentName(unsigned int index) {
00125             if (remainingAttachments)
00126                 return ((ExtMailData*)remainingAttachments->get(index))->attachName;
00127             else
00128                 return NULL;
00129         }
00130         unsigned long getAttachmentSize(unsigned int index) {
00131             if (remainingAttachments)
00132                 return ((ExtMailData*)remainingAttachments->get(index))->attachSize;
00133             else
00134                 return NULL;
00135         }
00136                 
00137    
00138 };
00139 
00141 #endif
00142 

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