Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mailtypes.h

Go to the documentation of this file.
00001 #ifndef __MAIL_TYPES_H
00002 #define __MAIL_TYPES_H
00003 
00004 #define FLAG_ANSWERED 0
00005 #define FLAG_FLAGGED  1
00006 #define FLAG_DELETED  2
00007 #define FLAG_SEEN     3
00008 #define FLAG_DRAFT    4
00009 #define FLAG_RECENT   5
00010 
00011 #include <opie2/osmartpointer.h>
00012 
00013 #include <qbitarray.h>
00014 #include <qstring.h>
00015 #include <qstringlist.h>
00016 #include <qmap.h>
00017 #include <qvaluelist.h>
00018 #include <qdatetime.h>
00019 
00020 class AbstractMail;
00021 /* a class to describe mails in a mailbox */
00022 /* Attention!
00023    From programmers point of view it would make sense to
00024    store the mail body into this class, too.
00025    But: not from the point of view of the device.
00026    Mailbodies can be real large. So we request them when
00027    needed from the mail-wrapper class direct from the server itself
00028    (imap) or from a file-based cache (pop3?)
00029    So there is no interface "const QString&body()" but you should
00030    make a request to the mailwrapper with this class as parameter to
00031    get the body. Same words for the attachments.
00032 */
00033 class RecMail:public Opie::Core::ORefCount
00034 {
00035 public:
00036     RecMail();
00037     RecMail(const RecMail&old);
00038     virtual ~RecMail();
00039 
00040     const unsigned int getNumber()const{return msg_number;}
00041     void setNumber(unsigned int number){msg_number=number;}
00042     const QString&getFrom()const{ return from; }
00043     void setFrom( const QString&a ) { from = a; }
00044     const QString&getSubject()const { return subject; }
00045     void setSubject( const QString&s ) { subject = s; }
00046     const QString&getMbox()const{return mbox;}
00047     void setMbox(const QString&box){mbox = box;}
00048     void setMsgid(const QString&id){msg_id=id;}
00049     const QString&Msgid()const{return msg_id;}
00050     void setReplyto(const QString&reply){replyto=reply;}
00051     const QString&Replyto()const{return replyto;}
00052     void setMsgsize(unsigned int size){msg_size = size;}
00053     const unsigned int Msgsize()const{return msg_size;}
00054 
00055 
00056     void setTo(const QStringList&list);
00057     const QStringList&To()const;
00058     void setCC(const QStringList&list);
00059     const QStringList&CC()const;
00060     void setBcc(const QStringList&list);
00061     const QStringList&Bcc()const;
00062     void setInreply(const QStringList&list);
00063     const QStringList&Inreply()const;
00064     void setReferences(const QStringList&list);
00065     const QStringList&References()const;
00066 
00067     const QBitArray&getFlags()const{return msg_flags;}
00068     void setFlags(const QBitArray&flags){msg_flags = flags;}
00069 
00070     void setWrapper(AbstractMail*wrapper);
00071     AbstractMail* Wrapper();
00072 
00073     const QDateTime&getDate()const{ return maildate; }
00074     const QString&getStringDate()const{return date;}
00075     void setDate( const QDateTime&a,int offset=0 );
00076 
00077 protected:
00078     QString subject,from,mbox,msg_id,replyto;
00079     unsigned int msg_number,msg_size;
00080     QBitArray msg_flags;
00081     QStringList to,cc,bcc,in_reply_to,references;
00082     AbstractMail*wrapper;
00083     void init();
00084     void copy_old(const RecMail&old);
00085     QDateTime maildate;
00086     QString date;
00087 };
00088 
00089 typedef Opie::Core::OSmartPointer<RecMail> RecMailP;
00090 typedef QMap<QString,QString> part_plist_t;
00091 
00092 class RecPart:public Opie::Core::ORefCount
00093 {
00094 protected:
00095     QString m_type,m_subtype,m_identifier,m_encoding,m_description;
00096     unsigned int m_lines,m_size;
00097     part_plist_t m_Parameters;
00098     /* describes the position in the mail */
00099     QValueList<int> m_poslist;
00100 
00101 public:
00102     RecPart();
00103     RecPart(const RecPart&);
00104     virtual ~RecPart();
00105 
00106     const QString&Type()const;
00107     void setType(const QString&type);
00108     const QString&Subtype()const;
00109     void setSubtype(const QString&subtype);
00110     const QString&Identifier()const;
00111     void setIdentifier(const QString&identifier);
00112     const QString&Encoding()const;
00113     void setEncoding(const QString&encoding);
00114     const QString&Description()const;
00115     void setDescription(const QString&desc);
00116     void setLines(unsigned int lines);
00117     const unsigned int Lines()const;
00118     void setSize(unsigned int size);
00119     const unsigned int Size()const;
00120 
00121 
00122     void setParameters(const part_plist_t&list);
00123     const part_plist_t&Parameters()const;
00124     void addParameter(const QString&key,const QString&value);
00125     const QString searchParamter(const QString&key)const;
00126     void setPositionlist(const QValueList<int>&poslist);
00127     const QValueList<int>& Positionlist()const;
00128 };
00129 
00130 typedef Opie::Core::OSmartPointer<RecPart> RecPartP;
00131 
00132 class RecBody:public Opie::Core::ORefCount
00133 {
00134 protected:
00135     QString m_BodyText;
00136     QValueList<RecPartP> m_PartsList;
00137     RecPartP m_description;
00138 
00139 public:
00140     RecBody();
00141     RecBody(const RecBody&old);
00142     virtual ~RecBody();
00143     void setBodytext(const QString&);
00144     const QString& Bodytext()const;
00145 
00146     void setDescription(const RecPartP&des);
00147     const RecPartP& Description()const;
00148 
00149     void setParts(const QValueList<RecPartP>&parts);
00150     const QValueList<RecPartP>& Parts()const;
00151     void addPart(const RecPartP&part);
00152 };
00153 
00154 typedef Opie::Core::OSmartPointer<RecBody> RecBodyP;
00155 
00156 class encodedString
00157 {
00158 public:
00159     encodedString();
00160     /*
00161        creates an new content string.
00162        it makes a deep copy of it!
00163      */
00164     encodedString(const char*nContent,unsigned int length);
00165     /*
00166       Take over the nContent. Means: it will just copy the pointer, not the content.
00167        so make sure: No one else frees the string, the string has allocated with
00168        malloc for compatibility with c-based libs
00169     */
00170     encodedString(char*nContent,unsigned int nSize);
00171     /* copy construkor - makes ALWAYS a deep copy!!!! */
00172     encodedString(const encodedString&old);
00173     /* assign operator - makes ALWAYS a deep copy!!!! */
00174     encodedString& operator=(const encodedString&old);
00175     /* destructor - cleans the content */
00176     virtual ~encodedString();
00177 
00178     /* returns a pointer to the content - do not delete yoursel! */
00179     const char*Content()const;
00180     /* returns the lengths of the content 'cause it must not be a null-terminated string! */
00181     const int Length()const;
00182 
00183     /*
00184        makes a deep copy of nContent!
00185      */
00186     void setContent(const char*nContent,int nSize);
00187     /*
00188       Take over the nContent. Means: it will just copy the pointer, not the content.
00189        so make sure: No one else frees the string, the string has allocated with
00190        malloc for compatibility with c-based libs
00191     */
00192     void setContent(char*nContent,int nSize);
00193 
00194 protected:
00195     char * content;
00196     unsigned int size;
00197 
00198     void init();
00199     void copy_old(const encodedString&old);
00200     void clean();
00201 };
00202 
00203 struct folderStat
00204 {
00205     unsigned int message_count;
00206     unsigned int message_unseen;
00207     unsigned int message_recent;
00208     folderStat&operator=(const folderStat&old);
00209 };
00210 
00211 #endif

Generated on Sat Nov 5 16:17:38 2005 for OPIE by  doxygen 1.4.2