summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/mailtypes.h
authorzautrix <zautrix>2004-07-03 16:33:12 (UTC)
committer zautrix <zautrix>2004-07-03 16:33:12 (UTC)
commite3b89230f065c48c84b48c88edb6eb088374c487 (patch) (unidiff)
tree162ea2ef909a6f82ccfcedf45d80d6c821174912 /kmicromail/libmailwrapper/mailtypes.h
parent2dd6ac0b2d24c91d35ce674a6c26351352df2b15 (diff)
downloadkdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.zip
kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.gz
kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.bz2
Initial revision
Diffstat (limited to 'kmicromail/libmailwrapper/mailtypes.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/mailtypes.h206
1 files changed, 206 insertions, 0 deletions
diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h
new file mode 100644
index 0000000..c317880
--- a/dev/null
+++ b/kmicromail/libmailwrapper/mailtypes.h
@@ -0,0 +1,206 @@
1#ifndef __MAIL_TYPES_H
2#define __MAIL_TYPES_H
3
4#define FLAG_ANSWERED 0
5#define FLAG_FLAGGED 1
6#define FLAG_DELETED 2
7#define FLAG_SEEN 3
8#define FLAG_DRAFT 4
9#define FLAG_RECENT 5
10
11#include <opie2/osmartpointer.h>
12
13#include <qbitarray.h>
14#include <qstring.h>
15#include <qstringlist.h>
16#include <qmap.h>
17#include <qvaluelist.h>
18
19class AbstractMail;
20/* a class to describe mails in a mailbox */
21/* Attention!
22 From programmers point of view it would make sense to
23 store the mail body into this class, too.
24 But: not from the point of view of the device.
25 Mailbodies can be real large. So we request them when
26 needed from the mail-wrapper class direct from the server itself
27 (imap) or from a file-based cache (pop3?)
28 So there is no interface "const QString&body()" but you should
29 make a request to the mailwrapper with this class as parameter to
30 get the body. Same words for the attachments.
31*/
32class RecMail:public Opie::Core::ORefCount
33{
34public:
35 RecMail();
36 RecMail(const RecMail&old);
37 virtual ~RecMail();
38
39 const unsigned int getNumber()const{return msg_number;}
40 void setNumber(unsigned int number){msg_number=number;}
41 const QString&getDate()const{ return date; }
42 void setDate( const QString&a ) { date = a; }
43 const QString&getFrom()const{ return from; }
44 void setFrom( const QString&a ) { from = a; }
45 const QString&getSubject()const { return subject; }
46 void setSubject( const QString&s ) { subject = s; }
47 const QString&getMbox()const{return mbox;}
48 void setMbox(const QString&box){mbox = box;}
49 void setMsgid(const QString&id){msg_id=id;}
50 const QString&Msgid()const{return msg_id;}
51 void setReplyto(const QString&reply){replyto=reply;}
52 const QString&Replyto()const{return replyto;}
53 void setMsgsize(unsigned int size){msg_size = size;}
54 const unsigned int Msgsize()const{return msg_size;}
55
56
57 void setTo(const QStringList&list);
58 const QStringList&To()const;
59 void setCC(const QStringList&list);
60 const QStringList&CC()const;
61 void setBcc(const QStringList&list);
62 const QStringList&Bcc()const;
63 void setInreply(const QStringList&list);
64 const QStringList&Inreply()const;
65 void setReferences(const QStringList&list);
66 const QStringList&References()const;
67
68 const QBitArray&getFlags()const{return msg_flags;}
69 void setFlags(const QBitArray&flags){msg_flags = flags;}
70
71 void setWrapper(AbstractMail*wrapper);
72 AbstractMail* Wrapper();
73
74protected:
75 QString subject,date,from,mbox,msg_id,replyto;
76 unsigned int msg_number,msg_size;
77 QBitArray msg_flags;
78 QStringList to,cc,bcc,in_reply_to,references;
79 AbstractMail*wrapper;
80 void init();
81 void copy_old(const RecMail&old);
82};
83
84typedef Opie::Core::OSmartPointer<RecMail> RecMailP;
85typedef QMap<QString,QString> part_plist_t;
86
87class RecPart:public Opie::Core::ORefCount
88{
89protected:
90 QString m_type,m_subtype,m_identifier,m_encoding,m_description;
91 unsigned int m_lines,m_size;
92 part_plist_t m_Parameters;
93 /* describes the position in the mail */
94 QValueList<int> m_poslist;
95
96public:
97 RecPart();
98 RecPart(const RecPart&);
99 virtual ~RecPart();
100
101 const QString&Type()const;
102 void setType(const QString&type);
103 const QString&Subtype()const;
104 void setSubtype(const QString&subtype);
105 const QString&Identifier()const;
106 void setIdentifier(const QString&identifier);
107 const QString&Encoding()const;
108 void setEncoding(const QString&encoding);
109 const QString&Description()const;
110 void setDescription(const QString&desc);
111 void setLines(unsigned int lines);
112 const unsigned int Lines()const;
113 void setSize(unsigned int size);
114 const unsigned int Size()const;
115
116
117 void setParameters(const part_plist_t&list);
118 const part_plist_t&Parameters()const;
119 void addParameter(const QString&key,const QString&value);
120 const QString searchParamter(const QString&key)const;
121 void setPositionlist(const QValueList<int>&poslist);
122 const QValueList<int>& Positionlist()const;
123};
124
125typedef Opie::Core::OSmartPointer<RecPart> RecPartP;
126
127class RecBody:public Opie::Core::ORefCount
128{
129protected:
130 QString m_BodyText;
131 QValueList<RecPartP> m_PartsList;
132 RecPartP m_description;
133
134public:
135 RecBody();
136 RecBody(const RecBody&old);
137 virtual ~RecBody();
138 void setBodytext(const QString&);
139 const QString& Bodytext()const;
140
141 void setDescription(const RecPartP&des);
142 const RecPartP& Description()const;
143
144 void setParts(const QValueList<RecPartP>&parts);
145 const QValueList<RecPartP>& Parts()const;
146 void addPart(const RecPartP&part);
147};
148
149typedef Opie::Core::OSmartPointer<RecBody> RecBodyP;
150
151class encodedString
152{
153public:
154 encodedString();
155 /*
156 creates an new content string.
157 it makes a deep copy of it!
158 */
159 encodedString(const char*nContent,unsigned int length);
160 /*
161 Take over the nContent. Means: it will just copy the pointer, not the content.
162 so make sure: No one else frees the string, the string has allocated with
163 malloc for compatibility with c-based libs
164 */
165 encodedString(char*nContent,unsigned int nSize);
166 /* copy construkor - makes ALWAYS a deep copy!!!! */
167 encodedString(const encodedString&old);
168 /* assign operator - makes ALWAYS a deep copy!!!! */
169 encodedString& operator=(const encodedString&old);
170 /* destructor - cleans the content */
171 virtual ~encodedString();
172
173 /* returns a pointer to the content - do not delete yoursel! */
174 const char*Content()const;
175 /* returns the lengths of the content 'cause it must not be a null-terminated string! */
176 const int Length()const;
177
178 /*
179 makes a deep copy of nContent!
180 */
181 void setContent(const char*nContent,int nSize);
182 /*
183 Take over the nContent. Means: it will just copy the pointer, not the content.
184 so make sure: No one else frees the string, the string has allocated with
185 malloc for compatibility with c-based libs
186 */
187 void setContent(char*nContent,int nSize);
188
189protected:
190 char * content;
191 unsigned int size;
192
193 void init();
194 void copy_old(const encodedString&old);
195 void clean();
196};
197
198struct folderStat
199{
200 unsigned int message_count;
201 unsigned int message_unseen;
202 unsigned int message_recent;
203 folderStat&operator=(const folderStat&old);
204};
205
206#endif