author | harlekin <harlekin> | 2003-12-08 13:37:32 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-08 13:37:32 (UTC) |
commit | 3b37149813d940535b12ba3b1edd938c41804a1b (patch) (unidiff) | |
tree | 0e35a3b28fb147514f22a6a6cb5aaf246e4c5670 /noncore/net/mail/libmailwrapper/mailwrapper.h | |
parent | 3d49fc2f7bba9c9e8856e5f4f7ec6c15ef84c252 (diff) | |
download | opie-3b37149813d940535b12ba3b1edd938c41804a1b.zip opie-3b37149813d940535b12ba3b1edd938c41804a1b.tar.gz opie-3b37149813d940535b12ba3b1edd938c41804a1b.tar.bz2 |
beginning of the new mailer
Diffstat (limited to 'noncore/net/mail/libmailwrapper/mailwrapper.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.h | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h new file mode 100644 index 0000000..3de28a0 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h | |||
@@ -0,0 +1,183 @@ | |||
1 | #ifndef MAILWRAPPER_H | ||
2 | #define MAILWRAPPER_H | ||
3 | |||
4 | #include <qpe/applnk.h> | ||
5 | |||
6 | #include <mailmime.h> | ||
7 | #include <mailimf.h> | ||
8 | #include <mailsmtp.h> | ||
9 | #include <mailimap.h> | ||
10 | #include <mailstorage.h> | ||
11 | #include <maildriver.h> | ||
12 | #include <qbitarray.h> | ||
13 | #include <qdatetime.h> | ||
14 | |||
15 | #include "settings.h" | ||
16 | |||
17 | class Attachment | ||
18 | { | ||
19 | public: | ||
20 | Attachment( DocLnk lnk ); | ||
21 | virtual ~Attachment(){} | ||
22 | const QString getFileName()const{ return doc.file(); } | ||
23 | const QString getName()const{ return doc.name(); } | ||
24 | const QString getMimeType()const{ return doc.type(); } | ||
25 | const QPixmap getPixmap()const{ return doc.pixmap(); } | ||
26 | const int getSize()const { return size; } | ||
27 | DocLnk getDocLnk() { return doc; } | ||
28 | |||
29 | protected: | ||
30 | DocLnk doc; | ||
31 | int size; | ||
32 | |||
33 | }; | ||
34 | |||
35 | #define FLAG_ANSWERED 0 | ||
36 | #define FLAG_FLAGGED 1 | ||
37 | #define FLAG_DELETED 2 | ||
38 | #define FLAG_SEEN 3 | ||
39 | #define FLAG_DRAFT 4 | ||
40 | #define FLAG_RECENT 5 | ||
41 | |||
42 | /* a class to describe mails in a mailbox */ | ||
43 | class RecMail | ||
44 | { | ||
45 | public: | ||
46 | RecMail(); | ||
47 | virtual ~RecMail(){} | ||
48 | |||
49 | const int getNumber()const{return msg_number;} | ||
50 | void setNumber(int number){msg_number=number;} | ||
51 | const QString&getDate()const{ return date; } | ||
52 | void setDate( const QString&a ) { date = a; } | ||
53 | const QString&getFrom()const{ return from; } | ||
54 | void setFrom( const QString&a ) { from = a; } | ||
55 | const QString&getSubject()const { return subject; } | ||
56 | void setSubject( const QString&s ) { subject = s; } | ||
57 | void setFlags(const QBitArray&flags){msg_flags = flags;} | ||
58 | const QBitArray&getFlags()const{return msg_flags;} | ||
59 | |||
60 | #if 0 | ||
61 | void setDate(const QString&dstring); | ||
62 | void setDate(const QDateTime&date){mDate = date;} | ||
63 | QString getDate()const{return mDate.toString();} | ||
64 | #endif | ||
65 | protected: | ||
66 | QString subject,date,from; | ||
67 | int msg_number; | ||
68 | QBitArray msg_flags; | ||
69 | #if 0 | ||
70 | QDateTime mDate; | ||
71 | #endif | ||
72 | }; | ||
73 | |||
74 | typedef QList<RecMail> Maillist; | ||
75 | |||
76 | class Mail | ||
77 | { | ||
78 | public: | ||
79 | Mail(); | ||
80 | /* Possible that this destructor must not be declared virtual | ||
81 | * 'cause it seems that it will never have some child classes. | ||
82 | * in this case this object will not get a virtual table -> memory and | ||
83 | * speed will be a little bit better? | ||
84 | */ | ||
85 | virtual ~Mail(){} | ||
86 | void addAttachment( Attachment *att ) { attList.append( att ); } | ||
87 | const QList<Attachment>& getAttachments()const { return attList; } | ||
88 | void removeAttachment( Attachment *att ) { attList.remove( att ); } | ||
89 | const QString&getName()const { return name; } | ||
90 | void setName( QString s ) { name = s; } | ||
91 | const QString&getMail()const{ return mail; } | ||
92 | void setMail( const QString&s ) { mail = s; } | ||
93 | const QString&getTo()const{ return to; } | ||
94 | void setTo( const QString&s ) { to = s; } | ||
95 | const QString&getCC()const{ return cc; } | ||
96 | void setCC( const QString&s ) { cc = s; } | ||
97 | const QString&getBCC()const { return bcc; } | ||
98 | void setBCC( const QString&s ) { bcc = s; } | ||
99 | const QString&getMessage()const { return message; } | ||
100 | void setMessage( const QString&s ) { message = s; } | ||
101 | const QString&getSubject()const { return subject; } | ||
102 | void setSubject( const QString&s ) { subject = s; } | ||
103 | const QString&getReply()const{ return reply; } | ||
104 | void setReply( const QString&a ) { reply = a; } | ||
105 | |||
106 | private: | ||
107 | QList<Attachment> attList; | ||
108 | QString name, mail, to, cc, bcc, reply, subject, message; | ||
109 | }; | ||
110 | |||
111 | class Folder : public QObject | ||
112 | { | ||
113 | Q_OBJECT | ||
114 | |||
115 | public: | ||
116 | Folder( const QString&init_name ); | ||
117 | const QString&getDisplayName()const { return nameDisplay; } | ||
118 | const QString&getName()const { return name; } | ||
119 | virtual bool may_select()const{return true;}; | ||
120 | |||
121 | private: | ||
122 | QString nameDisplay, name; | ||
123 | |||
124 | }; | ||
125 | |||
126 | class IMAPFolder : public Folder | ||
127 | { | ||
128 | public: | ||
129 | IMAPFolder( QString name,bool select=true ) : Folder( name ),m_MaySelect(select) {} | ||
130 | virtual bool may_select()const{return m_MaySelect;} | ||
131 | private: | ||
132 | bool m_MaySelect; | ||
133 | }; | ||
134 | |||
135 | class MailWrapper : public QObject | ||
136 | { | ||
137 | Q_OBJECT | ||
138 | |||
139 | public: | ||
140 | MailWrapper( Settings *s ); | ||
141 | void sendMail( Mail mail ); | ||
142 | |||
143 | private: | ||
144 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); | ||
145 | mailimf_address_list *parseAddresses(const QString&addr ); | ||
146 | mailimf_fields *createImfFields( Mail *mail ); | ||
147 | mailmime *buildTxtPart( QString str ); | ||
148 | mailmime *buildFilePart( QString filename, QString mimetype ); | ||
149 | void addFileParts( mailmime *message, QList<Attachment> files ); | ||
150 | mailmime *createMimeMail( Mail *mail ); | ||
151 | void smtpSend( mailmime *mail ); | ||
152 | mailimf_field *getField( mailimf_fields *fields, int type ); | ||
153 | clist *createRcptList( mailimf_fields *fields ); | ||
154 | char *getFrom( mailmime *mail ); | ||
155 | SMTPaccount *getAccount( QString from ); | ||
156 | void writeToFile( QString file, mailmime *mail ); | ||
157 | void readFromFile( QString file, char **data, size_t *size ); | ||
158 | static QString mailsmtpError( int err ); | ||
159 | static QString getTmpFile(); | ||
160 | |||
161 | Settings *settings; | ||
162 | |||
163 | }; | ||
164 | |||
165 | class IMAPwrapper : public QObject | ||
166 | { | ||
167 | Q_OBJECT | ||
168 | |||
169 | public: | ||
170 | IMAPwrapper( IMAPaccount *a ); | ||
171 | QList<IMAPFolder>* listFolders(); | ||
172 | void listMessages(const QString & mailbox,Maillist&target ); | ||
173 | QString fetchBody(const QString & mailbox,const RecMail&mail); | ||
174 | |||
175 | protected: | ||
176 | RecMail*parse_list_result(mailimap_msg_att*); | ||
177 | |||
178 | private: | ||
179 | IMAPaccount *account; | ||
180 | |||
181 | }; | ||
182 | |||
183 | #endif | ||