author | zautrix <zautrix> | 2004-09-11 15:41:30 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-11 15:41:30 (UTC) |
commit | 32f9963a39236d08718a36d5adad2a0c5c4e2602 (patch) (unidiff) | |
tree | 8856a90d505df8dc3afa0d72541f27cb68913a0d | |
parent | d7a273f40838f56205c1377ed0bcc5457bd46ea3 (diff) | |
download | kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.zip kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.gz kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.bz2 |
Mail enhancements
-rw-r--r-- | kmicromail/accountitem.cpp | 22 | ||||
-rw-r--r-- | kmicromail/accountview.cpp | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 67 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.h | 7 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 64 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.h | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 18 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.cpp | 23 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.h | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mboxwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/nntpwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.h | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/smtpwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/mailistviewitem.cpp | 9 |
17 files changed, 208 insertions, 22 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index 1698b40..7b9b881 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp | |||
@@ -1,764 +1,784 @@ | |||
1 | 1 | ||
2 | #include "accountitem.h" | 2 | #include "accountitem.h" |
3 | #include "accountview.h" | 3 | #include "accountview.h" |
4 | #include "newmaildir.h" | 4 | #include "newmaildir.h" |
5 | #include "nntpgroupsdlg.h" | 5 | #include "nntpgroupsdlg.h" |
6 | #include "defines.h" | 6 | #include "defines.h" |
7 | 7 | ||
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | #include <libmailwrapper/mailwrapper.h> | 10 | #include <libmailwrapper/mailwrapper.h> |
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | //#include <qpe/qpeapplication.h> | 12 | //#include <qpe/qpeapplication.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <kiconloader.h> | 17 | #include <kiconloader.h> |
18 | 18 | ||
19 | using namespace Opie::Core; | 19 | using namespace Opie::Core; |
20 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 20 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
21 | /** | 21 | /** |
22 | * POP3 Account stuff | 22 | * POP3 Account stuff |
23 | */ | 23 | */ |
24 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 24 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
25 | : AccountViewItem( parent ) | 25 | : AccountViewItem( parent ) |
26 | { | 26 | { |
27 | account = a; | 27 | account = a; |
28 | wrapper = AbstractMail::getWrapper( account ); | 28 | wrapper = AbstractMail::getWrapper( account ); |
29 | SETPIX(PIXMAP_POP3FOLDER); | 29 | SETPIX(PIXMAP_POP3FOLDER); |
30 | #if 0 | 30 | #if 0 |
31 | if (!account->getOffline()) | 31 | if (!account->getOffline()) |
32 | { | 32 | { |
33 | setPixmap( 0, ); | 33 | setPixmap( 0, ); |
34 | } | 34 | } |
35 | else | 35 | else |
36 | { | 36 | { |
37 | setPixmap( 0, PIXMAP_OFFLINE ); | 37 | setPixmap( 0, PIXMAP_OFFLINE ); |
38 | } | 38 | } |
39 | #endif | 39 | #endif |
40 | setText( 0, account->getAccountName() ); | 40 | setText( 0, account->getAccountName() ); |
41 | setOpen( true ); | 41 | setOpen( true ); |
42 | } | 42 | } |
43 | 43 | ||
44 | POP3viewItem::~POP3viewItem() | 44 | POP3viewItem::~POP3viewItem() |
45 | { | 45 | { |
46 | delete wrapper; | 46 | delete wrapper; |
47 | } | 47 | } |
48 | 48 | ||
49 | AbstractMail *POP3viewItem::getWrapper() | 49 | AbstractMail *POP3viewItem::getWrapper() |
50 | { | 50 | { |
51 | return wrapper; | 51 | return wrapper; |
52 | } | 52 | } |
53 | 53 | ||
54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
55 | { | 55 | { |
56 | refresh(); | 56 | refresh(); |
57 | } | 57 | } |
58 | 58 | ||
59 | void POP3viewItem::refresh() | 59 | void POP3viewItem::refresh() |
60 | { | 60 | { |
61 | if (account->getOffline()) return; | 61 | if (account->getOffline()) return; |
62 | QValueList<FolderP> *folders = wrapper->listFolders(); | 62 | QValueList<FolderP> *folders = wrapper->listFolders(); |
63 | QListViewItem *child = firstChild(); | 63 | QListViewItem *child = firstChild(); |
64 | while ( child ) | 64 | while ( child ) |
65 | { | 65 | { |
66 | QListViewItem *tmp = child; | 66 | QListViewItem *tmp = child; |
67 | child = child->nextSibling(); | 67 | child = child->nextSibling(); |
68 | delete tmp; | 68 | delete tmp; |
69 | } | 69 | } |
70 | QValueList<FolderP>::ConstIterator it; | 70 | QValueList<FolderP>::ConstIterator it; |
71 | QListViewItem*item = 0; | 71 | QListViewItem*item = 0; |
72 | for ( it = folders->begin(); it!=folders->end(); ++it) | 72 | for ( it = folders->begin(); it!=folders->end(); ++it) |
73 | { | 73 | { |
74 | item = new POP3folderItem( (*it), this , item ); | 74 | item = new POP3folderItem( (*it), this , item ); |
75 | item->setSelectable( (*it)->may_select()); | 75 | item->setSelectable( (*it)->may_select()); |
76 | } | 76 | } |
77 | delete folders; | 77 | delete folders; |
78 | } | 78 | } |
79 | 79 | ||
80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | 80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
81 | { | 81 | { |
82 | 82 | ||
83 | return wrapper->fetchBody( mail ); | 83 | return wrapper->fetchBody( mail ); |
84 | } | 84 | } |
85 | 85 | ||
86 | QPopupMenu * POP3viewItem::getContextMenu() | 86 | QPopupMenu * POP3viewItem::getContextMenu() |
87 | { | 87 | { |
88 | QPopupMenu *m = new QPopupMenu(0); | 88 | QPopupMenu *m = new QPopupMenu(0); |
89 | if (m) | 89 | if (m) |
90 | { | 90 | { |
91 | if (!account->getOffline()) | 91 | if (!account->getOffline()) |
92 | { | 92 | { |
93 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 93 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
94 | m->insertItem(QObject::tr("Set offline",contextName),1); | 94 | m->insertItem(QObject::tr("Set offline",contextName),1); |
95 | m->insertItem(QObject::tr("Download messages",contextName),2); | 95 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); |
96 | } | 96 | } |
97 | else | 97 | else |
98 | { | 98 | { |
99 | m->insertItem(QObject::tr("Set online",contextName),1); | 99 | m->insertItem(QObject::tr("Set online",contextName),1); |
100 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); | ||
100 | } | 101 | } |
101 | } | 102 | } |
102 | return m; | 103 | return m; |
103 | } | 104 | } |
104 | 105 | ||
105 | void POP3viewItem::disconnect() | 106 | void POP3viewItem::disconnect() |
106 | { | 107 | { |
107 | QListViewItem *child = firstChild(); | 108 | QListViewItem *child = firstChild(); |
108 | while ( child ) | 109 | while ( child ) |
109 | { | 110 | { |
110 | QListViewItem *tmp = child; | 111 | QListViewItem *tmp = child; |
111 | child = child->nextSibling(); | 112 | child = child->nextSibling(); |
112 | delete tmp; | 113 | delete tmp; |
113 | } | 114 | } |
114 | wrapper->logout(); | 115 | wrapper->logout(); |
115 | } | 116 | } |
116 | 117 | ||
117 | void POP3viewItem::setOnOffline() | 118 | void POP3viewItem::setOnOffline() |
118 | { | 119 | { |
119 | if (!account->getOffline()) | 120 | if (!account->getOffline()) |
120 | { | 121 | { |
121 | disconnect(); | 122 | disconnect(); |
122 | } | 123 | } |
123 | account->setOffline(!account->getOffline()); | 124 | account->setOffline(!account->getOffline()); |
124 | account->save(); | 125 | account->save(); |
125 | SETPIX(PIXMAP_POP3FOLDER); | 126 | SETPIX(PIXMAP_POP3FOLDER); |
126 | refresh(); | 127 | refresh(); |
127 | } | 128 | } |
128 | 129 | ||
129 | void POP3viewItem::contextMenuSelected(int which) | 130 | void POP3viewItem::contextMenuSelected(int which) |
130 | { | 131 | { |
131 | switch (which) | 132 | switch (which) |
132 | { | 133 | { |
133 | case 0: | 134 | case 0: |
134 | disconnect(); | 135 | disconnect(); |
135 | break; | 136 | break; |
136 | case 1: | 137 | case 1: |
137 | setOnOffline(); | 138 | setOnOffline(); |
138 | break; | 139 | break; |
139 | case 2: // daunlood | 140 | case 2: // daunlood |
141 | if (account->getOffline()) | ||
142 | setOnOffline(); | ||
140 | AccountView*bl = accountView(); | 143 | AccountView*bl = accountView(); |
141 | if (!bl) return; | 144 | if (!bl) return; |
142 | AccountViewItem* in = findSubItem( "inbox" , 0); | 145 | AccountViewItem* in = findSubItem( "inbox" , 0); |
143 | if ( ! in ) | 146 | if ( ! in ) |
144 | return; | 147 | return; |
145 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); | 148 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); |
146 | setOnOffline(); | 149 | setOnOffline(); |
147 | break; | 150 | break; |
148 | } | 151 | } |
149 | } | 152 | } |
150 | 153 | ||
151 | POP3folderItem::~POP3folderItem() | 154 | POP3folderItem::~POP3folderItem() |
152 | {} | 155 | {} |
153 | 156 | ||
154 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 157 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
155 | : AccountViewItem(folderInit,parent,after ) | 158 | : AccountViewItem(folderInit,parent,after ) |
156 | { | 159 | { |
157 | pop3 = parent; | 160 | pop3 = parent; |
158 | if (folder->getDisplayName().lower()!="inbox") | 161 | if (folder->getDisplayName().lower()!="inbox") |
159 | { | 162 | { |
160 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 163 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
161 | } | 164 | } |
162 | else | 165 | else |
163 | { | 166 | { |
164 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 167 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
165 | } | 168 | } |
166 | setText( 0, folder->getDisplayName() ); | 169 | setText( 0, folder->getDisplayName() ); |
167 | } | 170 | } |
168 | 171 | ||
169 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 172 | void POP3folderItem::refresh(QValueList<RecMailP>&target) |
170 | { | 173 | { |
171 | if (folder->may_select()) | 174 | if (folder->may_select()) |
172 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 175 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
173 | } | 176 | } |
174 | 177 | ||
175 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 178 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
176 | { | 179 | { |
177 | return pop3->getWrapper()->fetchBody(aMail); | 180 | return pop3->getWrapper()->fetchBody(aMail); |
178 | } | 181 | } |
179 | 182 | ||
180 | QPopupMenu * POP3folderItem::getContextMenu() | 183 | QPopupMenu * POP3folderItem::getContextMenu() |
181 | { | 184 | { |
182 | QPopupMenu *m = new QPopupMenu(0); | 185 | QPopupMenu *m = new QPopupMenu(0); |
183 | if (m) | 186 | if (m) |
184 | { | 187 | { |
185 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 188 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
186 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 189 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
187 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 190 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
188 | } | 191 | } |
189 | return m; | 192 | return m; |
190 | } | 193 | } |
191 | 194 | ||
192 | void POP3folderItem::downloadMails() | 195 | void POP3folderItem::downloadMails() |
193 | { | 196 | { |
194 | AccountView*bl = pop3->accountView(); | 197 | AccountView*bl = pop3->accountView(); |
195 | if (!bl) return; | 198 | if (!bl) return; |
196 | bl->downloadMails(folder,pop3->getWrapper()); | 199 | bl->downloadMails(folder,pop3->getWrapper()); |
197 | } | 200 | } |
198 | 201 | ||
199 | void POP3folderItem::contextMenuSelected(int which) | 202 | void POP3folderItem::contextMenuSelected(int which) |
200 | { | 203 | { |
201 | AccountView * view = (AccountView*)listView(); | 204 | AccountView * view = (AccountView*)listView(); |
202 | switch (which) | 205 | switch (which) |
203 | { | 206 | { |
204 | case 0: | 207 | case 0: |
205 | /* must be 'cause pop3 lists are cached */ | 208 | /* must be 'cause pop3 lists are cached */ |
206 | pop3->getWrapper()->logout(); | 209 | pop3->getWrapper()->logout(); |
207 | view->refreshCurrent(); | 210 | view->refreshCurrent(); |
208 | break; | 211 | break; |
209 | case 1: | 212 | case 1: |
210 | deleteAllMail(pop3->getWrapper(),folder); | 213 | deleteAllMail(pop3->getWrapper(),folder); |
211 | break; | 214 | break; |
212 | case 2: | 215 | case 2: |
213 | downloadMails(); | 216 | downloadMails(); |
214 | break; | 217 | break; |
215 | default: | 218 | default: |
216 | break; | 219 | break; |
217 | } | 220 | } |
218 | } | 221 | } |
219 | 222 | ||
220 | /** | 223 | /** |
221 | * NNTP Account stuff | 224 | * NNTP Account stuff |
222 | */ | 225 | */ |
223 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 226 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
224 | : AccountViewItem( parent ) | 227 | : AccountViewItem( parent ) |
225 | { | 228 | { |
226 | account = a; | 229 | account = a; |
227 | wrapper = AbstractMail::getWrapper( account ); | 230 | wrapper = AbstractMail::getWrapper( account ); |
228 | //FIXME | 231 | //FIXME |
229 | SETPIX(PIXMAP_POP3FOLDER); | 232 | SETPIX(PIXMAP_POP3FOLDER); |
230 | #if 0 | 233 | #if 0 |
231 | if (!account->getOffline()) | 234 | if (!account->getOffline()) |
232 | { | 235 | { |
233 | setPixmap( 0, ); | 236 | setPixmap( 0, ); |
234 | } | 237 | } |
235 | else | 238 | else |
236 | { | 239 | { |
237 | setPixmap( 0, PIXMAP_OFFLINE ); | 240 | setPixmap( 0, PIXMAP_OFFLINE ); |
238 | } | 241 | } |
239 | #endif | 242 | #endif |
240 | setText( 0, account->getAccountName() ); | 243 | setText( 0, account->getAccountName() ); |
241 | setOpen( true ); | 244 | setOpen( true ); |
242 | } | 245 | } |
243 | 246 | ||
244 | NNTPviewItem::~NNTPviewItem() | 247 | NNTPviewItem::~NNTPviewItem() |
245 | { | 248 | { |
246 | delete wrapper; | 249 | delete wrapper; |
247 | } | 250 | } |
248 | 251 | ||
249 | AbstractMail *NNTPviewItem::getWrapper() | 252 | AbstractMail *NNTPviewItem::getWrapper() |
250 | { | 253 | { |
251 | return wrapper; | 254 | return wrapper; |
252 | } | 255 | } |
253 | 256 | ||
254 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) | 257 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) |
255 | { | 258 | { |
256 | refresh(); | 259 | refresh(); |
257 | } | 260 | } |
258 | 261 | ||
259 | void NNTPviewItem::refresh() | 262 | void NNTPviewItem::refresh() |
260 | { | 263 | { |
261 | if (account->getOffline()) return; | 264 | if (account->getOffline()) return; |
262 | QValueList<FolderP> *folders = wrapper->listFolders(); | 265 | QValueList<FolderP> *folders = wrapper->listFolders(); |
263 | 266 | ||
264 | QListViewItem *child = firstChild(); | 267 | QListViewItem *child = firstChild(); |
265 | while ( child ) | 268 | while ( child ) |
266 | { | 269 | { |
267 | QListViewItem *tmp = child; | 270 | QListViewItem *tmp = child; |
268 | child = child->nextSibling(); | 271 | child = child->nextSibling(); |
269 | delete tmp; | 272 | delete tmp; |
270 | } | 273 | } |
271 | QValueList<FolderP>::ConstIterator it; | 274 | QValueList<FolderP>::ConstIterator it; |
272 | QListViewItem*item = 0; | 275 | QListViewItem*item = 0; |
273 | for ( it = folders->begin(); it!=folders->end(); ++it) | 276 | for ( it = folders->begin(); it!=folders->end(); ++it) |
274 | { | 277 | { |
275 | item = new NNTPfolderItem( (*it), this , item ); | 278 | item = new NNTPfolderItem( (*it), this , item ); |
276 | item->setSelectable( (*it)->may_select()); | 279 | item->setSelectable( (*it)->may_select()); |
277 | } | 280 | } |
278 | delete folders; | 281 | delete folders; |
279 | } | 282 | } |
280 | 283 | ||
281 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) | 284 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) |
282 | { | 285 | { |
283 | 286 | ||
284 | return wrapper->fetchBody( mail ); | 287 | return wrapper->fetchBody( mail ); |
285 | } | 288 | } |
286 | 289 | ||
287 | QPopupMenu * NNTPviewItem::getContextMenu() | 290 | QPopupMenu * NNTPviewItem::getContextMenu() |
288 | { | 291 | { |
289 | QPopupMenu *m = new QPopupMenu(0); | 292 | QPopupMenu *m = new QPopupMenu(0); |
290 | if (m) | 293 | if (m) |
291 | { | 294 | { |
292 | if (!account->getOffline()) | 295 | if (!account->getOffline()) |
293 | { | 296 | { |
294 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 297 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
295 | m->insertItem(QObject::tr("Set offline",contextName),1); | 298 | m->insertItem(QObject::tr("Set offline",contextName),1); |
296 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); | 299 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); |
297 | } | 300 | } |
298 | else | 301 | else |
299 | { | 302 | { |
300 | m->insertItem(QObject::tr("Set online",contextName),1); | 303 | m->insertItem(QObject::tr("Set online",contextName),1); |
301 | } | 304 | } |
302 | } | 305 | } |
303 | return m; | 306 | return m; |
304 | } | 307 | } |
305 | 308 | ||
306 | void NNTPviewItem::subscribeGroups() | 309 | void NNTPviewItem::subscribeGroups() |
307 | { | 310 | { |
308 | NNTPGroupsDlg dlg(account); | 311 | NNTPGroupsDlg dlg(account); |
309 | dlg.showMaximized(); | 312 | dlg.showMaximized(); |
310 | if ( dlg.exec()== QDialog::Accepted ){ | 313 | if ( dlg.exec()== QDialog::Accepted ){ |
311 | refresh(); | 314 | refresh(); |
312 | } | 315 | } |
313 | } | 316 | } |
314 | 317 | ||
315 | void NNTPviewItem::disconnect() | 318 | void NNTPviewItem::disconnect() |
316 | { | 319 | { |
317 | QListViewItem *child = firstChild(); | 320 | QListViewItem *child = firstChild(); |
318 | while ( child ) | 321 | while ( child ) |
319 | { | 322 | { |
320 | QListViewItem *tmp = child; | 323 | QListViewItem *tmp = child; |
321 | child = child->nextSibling(); | 324 | child = child->nextSibling(); |
322 | delete tmp; | 325 | delete tmp; |
323 | } | 326 | } |
324 | wrapper->logout(); | 327 | wrapper->logout(); |
325 | } | 328 | } |
326 | 329 | ||
327 | void NNTPviewItem::setOnOffline() | 330 | void NNTPviewItem::setOnOffline() |
328 | { | 331 | { |
329 | if (!account->getOffline()) | 332 | if (!account->getOffline()) |
330 | { | 333 | { |
331 | disconnect(); | 334 | disconnect(); |
332 | } | 335 | } |
333 | account->setOffline(!account->getOffline()); | 336 | account->setOffline(!account->getOffline()); |
334 | account->save(); | 337 | account->save(); |
335 | //FIXME | 338 | //FIXME |
336 | SETPIX(PIXMAP_POP3FOLDER); | 339 | SETPIX(PIXMAP_POP3FOLDER); |
337 | refresh(); | 340 | refresh(); |
338 | } | 341 | } |
339 | 342 | ||
340 | void NNTPviewItem::contextMenuSelected(int which) | 343 | void NNTPviewItem::contextMenuSelected(int which) |
341 | { | 344 | { |
342 | switch (which) | 345 | switch (which) |
343 | { | 346 | { |
344 | case 0: | 347 | case 0: |
345 | disconnect(); | 348 | disconnect(); |
346 | break; | 349 | break; |
347 | case 1: | 350 | case 1: |
348 | setOnOffline(); | 351 | setOnOffline(); |
349 | break; | 352 | break; |
350 | case 2: | 353 | case 2: |
351 | subscribeGroups(); | 354 | subscribeGroups(); |
352 | break; | 355 | break; |
353 | } | 356 | } |
354 | } | 357 | } |
355 | 358 | ||
356 | NNTPfolderItem::~NNTPfolderItem() | 359 | NNTPfolderItem::~NNTPfolderItem() |
357 | {} | 360 | {} |
358 | 361 | ||
359 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) | 362 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) |
360 | : AccountViewItem( folderInit, parent,after ) | 363 | : AccountViewItem( folderInit, parent,after ) |
361 | { | 364 | { |
362 | nntp = parent; | 365 | nntp = parent; |
363 | if (folder->getDisplayName().lower()!="inbox") | 366 | if (folder->getDisplayName().lower()!="inbox") |
364 | { | 367 | { |
365 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 368 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
366 | } | 369 | } |
367 | else | 370 | else |
368 | { | 371 | { |
369 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 372 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
370 | } | 373 | } |
371 | setText( 0, folder->getDisplayName() ); | 374 | setText( 0, folder->getDisplayName() ); |
372 | } | 375 | } |
373 | 376 | ||
374 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) | 377 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) |
375 | { | 378 | { |
376 | if (folder->may_select()) | 379 | if (folder->may_select()) |
377 | nntp->getWrapper()->listMessages( folder->getName(),target ); | 380 | nntp->getWrapper()->listMessages( folder->getName(),target ); |
378 | } | 381 | } |
379 | 382 | ||
380 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) | 383 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) |
381 | { | 384 | { |
382 | return nntp->getWrapper()->fetchBody(aMail); | 385 | return nntp->getWrapper()->fetchBody(aMail); |
383 | } | 386 | } |
384 | 387 | ||
385 | QPopupMenu * NNTPfolderItem::getContextMenu() | 388 | QPopupMenu * NNTPfolderItem::getContextMenu() |
386 | { | 389 | { |
387 | QPopupMenu *m = new QPopupMenu(0); | 390 | QPopupMenu *m = new QPopupMenu(0); |
388 | if (m) | 391 | if (m) |
389 | { | 392 | { |
390 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 393 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
391 | m->insertItem(QObject::tr("Copy all postings",contextName),1); | 394 | m->insertItem(QObject::tr("Copy all postings",contextName),1); |
392 | } | 395 | } |
393 | return m; | 396 | return m; |
394 | } | 397 | } |
395 | 398 | ||
396 | void NNTPfolderItem::downloadMails() | 399 | void NNTPfolderItem::downloadMails() |
397 | { | 400 | { |
398 | AccountView*bl = nntp->accountView(); | 401 | AccountView*bl = nntp->accountView(); |
399 | if (!bl) return; | 402 | if (!bl) return; |
400 | bl->downloadMails(folder,nntp->getWrapper()); | 403 | bl->downloadMails(folder,nntp->getWrapper()); |
401 | } | 404 | } |
402 | 405 | ||
403 | void NNTPfolderItem::contextMenuSelected(int which) | 406 | void NNTPfolderItem::contextMenuSelected(int which) |
404 | { | 407 | { |
405 | AccountView * view = (AccountView*)listView(); | 408 | AccountView * view = (AccountView*)listView(); |
406 | switch (which) | 409 | switch (which) |
407 | { | 410 | { |
408 | case 0: | 411 | case 0: |
409 | /* must be 'cause pop3 lists are cached */ | 412 | /* must be 'cause pop3 lists are cached */ |
410 | nntp->getWrapper()->logout(); | 413 | nntp->getWrapper()->logout(); |
411 | view->refreshCurrent(); | 414 | view->refreshCurrent(); |
412 | break; | 415 | break; |
413 | case 1: | 416 | case 1: |
414 | downloadMails(); | 417 | downloadMails(); |
415 | break; | 418 | break; |
416 | default: | 419 | default: |
417 | break; | 420 | break; |
418 | } | 421 | } |
419 | } | 422 | } |
420 | 423 | ||
421 | /** | 424 | /** |
422 | * IMAP Account stuff | 425 | * IMAP Account stuff |
423 | */ | 426 | */ |
424 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 427 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
425 | : AccountViewItem( parent ) | 428 | : AccountViewItem( parent ) |
426 | { | 429 | { |
427 | account = a; | 430 | account = a; |
428 | wrapper = AbstractMail::getWrapper( account ); | 431 | wrapper = AbstractMail::getWrapper( account ); |
429 | SETPIX(PIXMAP_IMAPFOLDER); | 432 | SETPIX(PIXMAP_IMAPFOLDER); |
430 | setText( 0, account->getAccountName() ); | 433 | setText( 0, account->getAccountName() ); |
431 | setOpen( true ); | 434 | setOpen( true ); |
432 | } | 435 | } |
433 | 436 | ||
434 | IMAPviewItem::~IMAPviewItem() | 437 | IMAPviewItem::~IMAPviewItem() |
435 | { | 438 | { |
436 | delete wrapper; | 439 | delete wrapper; |
437 | } | 440 | } |
438 | 441 | ||
439 | AbstractMail *IMAPviewItem::getWrapper() | 442 | AbstractMail *IMAPviewItem::getWrapper() |
440 | { | 443 | { |
441 | return wrapper; | 444 | return wrapper; |
442 | } | 445 | } |
443 | 446 | ||
444 | void IMAPviewItem::refresh(QValueList<RecMailP>&) | 447 | void IMAPviewItem::refresh(QValueList<RecMailP>&) |
445 | { | 448 | { |
446 | refreshFolders(false); | 449 | refreshFolders(false); |
447 | } | 450 | } |
448 | 451 | ||
449 | const QStringList&IMAPviewItem::subFolders() | 452 | const QStringList&IMAPviewItem::subFolders() |
450 | { | 453 | { |
451 | return currentFolders; | 454 | return currentFolders; |
452 | } | 455 | } |
453 | 456 | ||
454 | void IMAPviewItem::refreshFolders(bool force) | 457 | void IMAPviewItem::refreshFolders(bool force) |
455 | { | 458 | { |
456 | if (childCount()>0 && force==false) return; | 459 | if (childCount()>0 && force==false) return; |
457 | if (account->getOffline()) return; | 460 | if (account->getOffline()) return; |
458 | 461 | ||
459 | removeChilds(); | 462 | removeChilds(); |
460 | currentFolders.clear(); | 463 | currentFolders.clear(); |
461 | QValueList<FolderP> * folders = wrapper->listFolders(); | 464 | QValueList<FolderP> * folders = wrapper->listFolders(); |
462 | 465 | ||
463 | QValueList<FolderP>::Iterator it; | 466 | QValueList<FolderP>::Iterator it; |
464 | QListViewItem*item = 0; | 467 | QListViewItem*item = 0; |
465 | QListViewItem*titem = 0; | 468 | QListViewItem*titem = 0; |
466 | QString fname,del,search; | 469 | QString fname,del,search; |
467 | int pos; | 470 | int pos; |
468 | 471 | ||
469 | for ( it = folders->begin(); it!=folders->end(); ++it) | 472 | for ( it = folders->begin(); it!=folders->end(); ++it) |
470 | { | 473 | { |
471 | if ((*it)->getDisplayName().lower()=="inbox") | 474 | if ((*it)->getDisplayName().lower()=="inbox") |
472 | { | 475 | { |
473 | item = new IMAPfolderItem( (*it), this , item ); | 476 | item = new IMAPfolderItem( (*it), this , item ); |
474 | folders->remove(it); | 477 | folders->remove(it); |
475 | break; | 478 | break; |
476 | } | 479 | } |
477 | } | 480 | } |
478 | for ( it = folders->begin(); it!=folders->end(); ++it) | 481 | for ( it = folders->begin(); it!=folders->end(); ++it) |
479 | { | 482 | { |
480 | fname = (*it)->getDisplayName(); | 483 | fname = (*it)->getDisplayName(); |
481 | currentFolders.append((*it)->getName()); | 484 | currentFolders.append((*it)->getName()); |
482 | pos = fname.findRev((*it)->Separator()); | 485 | pos = fname.findRev((*it)->Separator()); |
483 | if (pos != -1) | 486 | if (pos != -1) |
484 | { | 487 | { |
485 | fname = fname.left(pos); | 488 | fname = fname.left(pos); |
486 | } | 489 | } |
487 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 490 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
488 | if (pitem) | 491 | if (pitem) |
489 | { | 492 | { |
490 | titem = item; | 493 | titem = item; |
491 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 494 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
492 | /* setup the short name */ | 495 | /* setup the short name */ |
493 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); | 496 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); |
494 | item = titem; | 497 | item = titem; |
495 | } | 498 | } |
496 | else | 499 | else |
497 | { | 500 | { |
498 | item = new IMAPfolderItem( (*it), this , item ); | 501 | item = new IMAPfolderItem( (*it), this , item ); |
499 | } | 502 | } |
500 | } | 503 | } |
501 | delete folders; | 504 | delete folders; |
502 | } | 505 | } |
503 | 506 | ||
504 | QPopupMenu * IMAPviewItem::getContextMenu() | 507 | QPopupMenu * IMAPviewItem::getContextMenu() |
505 | { | 508 | { |
506 | QPopupMenu *m = new QPopupMenu(0); | 509 | QPopupMenu *m = new QPopupMenu(0); |
507 | if (m) | 510 | if (m) |
508 | { | 511 | { |
509 | if (!account->getOffline()) | 512 | if (!account->getOffline()) |
510 | { | 513 | { |
511 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 514 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
512 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 515 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
513 | m->insertSeparator(); | 516 | m->insertSeparator(); |
514 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 517 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
515 | m->insertItem(QObject::tr("Set offline",contextName),3); | 518 | m->insertItem(QObject::tr("Set offline",contextName),3); |
519 | m->insertSeparator(); | ||
520 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); | ||
516 | } | 521 | } |
517 | else | 522 | else |
518 | { | 523 | { |
519 | m->insertItem(QObject::tr("Set online",contextName),3); | 524 | m->insertItem(QObject::tr("Set online",contextName),3); |
525 | m->insertSeparator(); | ||
526 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); | ||
520 | } | 527 | } |
521 | } | 528 | } |
522 | return m; | 529 | return m; |
523 | } | 530 | } |
524 | 531 | ||
525 | void IMAPviewItem::createNewFolder() | 532 | void IMAPviewItem::createNewFolder() |
526 | { | 533 | { |
527 | Newmdirdlg ndirdlg; | 534 | Newmdirdlg ndirdlg; |
528 | 535 | ||
529 | ndirdlg.showMaximized(); | 536 | ndirdlg.showMaximized(); |
530 | if ( ndirdlg.exec() ) | 537 | if ( ndirdlg.exec() ) |
531 | { | 538 | { |
532 | QString ndir = ndirdlg.Newdir(); | 539 | QString ndir = ndirdlg.Newdir(); |
533 | bool makesubs = ndirdlg.subpossible(); | 540 | bool makesubs = ndirdlg.subpossible(); |
534 | QString delemiter = "/"; | 541 | QString delemiter = "/"; |
535 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 542 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
536 | if (item) | 543 | if (item) |
537 | { | 544 | { |
538 | delemiter = item->Delemiter(); | 545 | delemiter = item->Delemiter(); |
539 | } | 546 | } |
540 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 547 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
541 | { | 548 | { |
542 | refreshFolders(true); | 549 | refreshFolders(true); |
543 | } | 550 | } |
544 | } | 551 | } |
545 | } | 552 | } |
546 | 553 | ||
547 | void IMAPviewItem::contextMenuSelected(int id) | 554 | void IMAPviewItem::contextMenuSelected(int id) |
548 | { | 555 | { |
549 | 556 | ||
550 | switch (id) | 557 | switch (id) |
551 | { | 558 | { |
552 | case 0: | 559 | case 0: |
553 | refreshFolders(true); | 560 | refreshFolders(true); |
554 | break; | 561 | break; |
555 | case 1: | 562 | case 1: |
556 | createNewFolder(); | 563 | createNewFolder(); |
557 | break; | 564 | break; |
558 | case 2: | 565 | case 2: |
559 | removeChilds(); | 566 | removeChilds(); |
560 | wrapper->logout(); | 567 | wrapper->logout(); |
561 | break; | 568 | break; |
562 | case 3: | 569 | case 3: |
563 | if (account->getOffline()==false) | 570 | if (account->getOffline()==false) |
564 | { | 571 | { |
565 | removeChilds(); | 572 | removeChilds(); |
566 | wrapper->logout(); | 573 | wrapper->logout(); |
567 | } | 574 | } |
568 | account->setOffline(!account->getOffline()); | 575 | account->setOffline(!account->getOffline()); |
569 | account->save(); | 576 | account->save(); |
570 | SETPIX(PIXMAP_IMAPFOLDER); | 577 | SETPIX(PIXMAP_IMAPFOLDER); |
571 | refreshFolders(false); | 578 | refreshFolders(false); |
572 | break; | 579 | break; |
580 | case 4: // daunlood | ||
581 | { | ||
582 | if (account->getOffline()) { | ||
583 | contextMenuSelected( 3 ); | ||
584 | } | ||
585 | AccountView*bl = accountView(); | ||
586 | if (!bl) return; | ||
587 | AccountViewItem* in = findSubItem( "inbox" , 0); | ||
588 | if ( ! in ) | ||
589 | return; | ||
590 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); | ||
591 | } | ||
592 | break; | ||
573 | default: | 593 | default: |
574 | break; | 594 | break; |
575 | } | 595 | } |
576 | } | 596 | } |
577 | 597 | ||
578 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) | 598 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
579 | { | 599 | { |
580 | return new RecBody(); | 600 | return new RecBody(); |
581 | } | 601 | } |
582 | 602 | ||
583 | bool IMAPviewItem::offline() | 603 | bool IMAPviewItem::offline() |
584 | { | 604 | { |
585 | return account->getOffline(); | 605 | return account->getOffline(); |
586 | } | 606 | } |
587 | 607 | ||
588 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 608 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
589 | : AccountViewItem( folderInit, parent , after ) | 609 | : AccountViewItem( folderInit, parent , after ) |
590 | { | 610 | { |
591 | imap = parent; | 611 | imap = parent; |
592 | if (folder->getDisplayName().lower()!="inbox") | 612 | if (folder->getDisplayName().lower()!="inbox") |
593 | { | 613 | { |
594 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 614 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
595 | } | 615 | } |
596 | else | 616 | else |
597 | { | 617 | { |
598 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 618 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
599 | } | 619 | } |
600 | setText( 0, folder->getDisplayName() ); | 620 | setText( 0, folder->getDisplayName() ); |
601 | } | 621 | } |
602 | 622 | ||
603 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 623 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
604 | : AccountViewItem(folderInit, parent,after ) | 624 | : AccountViewItem(folderInit, parent,after ) |
605 | { | 625 | { |
606 | imap = master; | 626 | imap = master; |
607 | if (folder->getDisplayName().lower()!="inbox") | 627 | if (folder->getDisplayName().lower()!="inbox") |
608 | { | 628 | { |
609 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 629 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
610 | } | 630 | } |
611 | else | 631 | else |
612 | { | 632 | { |
613 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 633 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
614 | } | 634 | } |
615 | setText( 0, folder->getDisplayName() ); | 635 | setText( 0, folder->getDisplayName() ); |
616 | } | 636 | } |
617 | 637 | ||
618 | IMAPfolderItem::~IMAPfolderItem() | 638 | IMAPfolderItem::~IMAPfolderItem() |
619 | {} | 639 | {} |
620 | 640 | ||
621 | const QString& IMAPfolderItem::Delemiter()const | 641 | const QString& IMAPfolderItem::Delemiter()const |
622 | { | 642 | { |
623 | return folder->Separator(); | 643 | return folder->Separator(); |
624 | } | 644 | } |
625 | 645 | ||
626 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | 646 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) |
627 | { | 647 | { |
628 | if (folder->may_select()) | 648 | if (folder->may_select()) |
629 | { | 649 | { |
630 | imap->getWrapper()->listMessages( folder->getName(),target ); | 650 | imap->getWrapper()->listMessages( folder->getName(),target ); |
631 | } | 651 | } |
632 | else | 652 | else |
633 | { | 653 | { |
634 | target.clear(); | 654 | target.clear(); |
635 | } | 655 | } |
636 | } | 656 | } |
637 | 657 | ||
638 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) | 658 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
639 | { | 659 | { |
640 | return imap->getWrapper()->fetchBody(aMail); | 660 | return imap->getWrapper()->fetchBody(aMail); |
641 | } | 661 | } |
642 | 662 | ||
643 | QPopupMenu * IMAPfolderItem::getContextMenu() | 663 | QPopupMenu * IMAPfolderItem::getContextMenu() |
644 | { | 664 | { |
645 | QPopupMenu *m = new QPopupMenu(0); | 665 | QPopupMenu *m = new QPopupMenu(0); |
646 | if (m) | 666 | if (m) |
647 | { | 667 | { |
648 | if (folder->may_select()) | 668 | if (folder->may_select()) |
649 | { | 669 | { |
650 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 670 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
651 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | 671 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); |
652 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 672 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
653 | } | 673 | } |
654 | if (folder->no_inferior()==false) | 674 | if (folder->no_inferior()==false) |
655 | { | 675 | { |
656 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 676 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
657 | } | 677 | } |
658 | if (folder->getDisplayName().lower()!="inbox") | 678 | if (folder->getDisplayName().lower()!="inbox") |
659 | { | 679 | { |
660 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 680 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
661 | } | 681 | } |
662 | } | 682 | } |
663 | return m; | 683 | return m; |
664 | } | 684 | } |
665 | 685 | ||
666 | void IMAPfolderItem::createNewFolder() | 686 | void IMAPfolderItem::createNewFolder() |
667 | { | 687 | { |
668 | Newmdirdlg ndirdlg; | 688 | Newmdirdlg ndirdlg; |
669 | ndirdlg.showMaximized(); | 689 | ndirdlg.showMaximized(); |
670 | if ( ndirdlg.exec() ) | 690 | if ( ndirdlg.exec() ) |
671 | { | 691 | { |
672 | QString ndir = ndirdlg.Newdir(); | 692 | QString ndir = ndirdlg.Newdir(); |
673 | bool makesubs = ndirdlg.subpossible(); | 693 | bool makesubs = ndirdlg.subpossible(); |
674 | QString delemiter = Delemiter(); | 694 | QString delemiter = Delemiter(); |
675 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 695 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
676 | { | 696 | { |
677 | imap->refreshFolders(true); | 697 | imap->refreshFolders(true); |
678 | } | 698 | } |
679 | } | 699 | } |
680 | } | 700 | } |
681 | 701 | ||
682 | void IMAPfolderItem::deleteFolder() | 702 | void IMAPfolderItem::deleteFolder() |
683 | { | 703 | { |
684 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 704 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
685 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 705 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
686 | QObject::tr("Yes",contextName), | 706 | QObject::tr("Yes",contextName), |
687 | QObject::tr("No",contextName),QString::null,1,1); | 707 | QObject::tr("No",contextName),QString::null,1,1); |
688 | 708 | ||
689 | if (yesno == 0) | 709 | if (yesno == 0) |
690 | { | 710 | { |
691 | if (imap->getWrapper()->deleteMbox(folder)) | 711 | if (imap->getWrapper()->deleteMbox(folder)) |
692 | { | 712 | { |
693 | QListView*v=listView(); | 713 | QListView*v=listView(); |
694 | IMAPviewItem * box = imap; | 714 | IMAPviewItem * box = imap; |
695 | /* be carefull - after that this object is destroyd so don't use | 715 | /* be carefull - after that this object is destroyd so don't use |
696 | * any member of it after that call!!*/ | 716 | * any member of it after that call!!*/ |
697 | imap->refreshFolders(true); | 717 | imap->refreshFolders(true); |
698 | if (v) | 718 | if (v) |
699 | { | 719 | { |
700 | v->setSelected(box,true); | 720 | v->setSelected(box,true); |
701 | } | 721 | } |
702 | } | 722 | } |
703 | } | 723 | } |
704 | } | 724 | } |
705 | 725 | ||
706 | void IMAPfolderItem::downloadMails() | 726 | void IMAPfolderItem::downloadMails() |
707 | { | 727 | { |
708 | AccountView*bl = imap->accountView(); | 728 | AccountView*bl = imap->accountView(); |
709 | if (!bl) return; | 729 | if (!bl) return; |
710 | bl->downloadMails(folder,imap->getWrapper()); | 730 | bl->downloadMails(folder,imap->getWrapper()); |
711 | } | 731 | } |
712 | 732 | ||
713 | void IMAPfolderItem::contextMenuSelected(int id) | 733 | void IMAPfolderItem::contextMenuSelected(int id) |
714 | { | 734 | { |
715 | 735 | ||
716 | AccountView * view = (AccountView*)listView(); | 736 | AccountView * view = (AccountView*)listView(); |
717 | switch(id) | 737 | switch(id) |
718 | { | 738 | { |
719 | case 0: | 739 | case 0: |
720 | view->refreshCurrent(); | 740 | view->refreshCurrent(); |
721 | break; | 741 | break; |
722 | case 1: | 742 | case 1: |
723 | deleteAllMail(imap->getWrapper(),folder); | 743 | deleteAllMail(imap->getWrapper(),folder); |
724 | break; | 744 | break; |
725 | case 2: | 745 | case 2: |
726 | createNewFolder(); | 746 | createNewFolder(); |
727 | break; | 747 | break; |
728 | case 3: | 748 | case 3: |
729 | deleteFolder(); | 749 | deleteFolder(); |
730 | break; | 750 | break; |
731 | case 4: | 751 | case 4: |
732 | downloadMails(); | 752 | downloadMails(); |
733 | break; | 753 | break; |
734 | default: | 754 | default: |
735 | break; | 755 | break; |
736 | } | 756 | } |
737 | } | 757 | } |
738 | 758 | ||
739 | /** | 759 | /** |
740 | * MH Account stuff | 760 | * MH Account stuff |
741 | */ | 761 | */ |
742 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 762 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
743 | POP3 and MBOX */ | 763 | POP3 and MBOX */ |
744 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 764 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
745 | : AccountViewItem( parent ) | 765 | : AccountViewItem( parent ) |
746 | { | 766 | { |
747 | m_Path = aPath; | 767 | m_Path = aPath; |
748 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 768 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
749 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 769 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |
750 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 770 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
751 | setText( 0, " Local Folders" ); | 771 | setText( 0, " Local Folders" ); |
752 | setOpen( true ); | 772 | setOpen( true ); |
753 | folder = 0; | 773 | folder = 0; |
754 | } | 774 | } |
755 | 775 | ||
756 | MHviewItem::~MHviewItem() | 776 | MHviewItem::~MHviewItem() |
757 | { | 777 | { |
758 | delete wrapper; | 778 | delete wrapper; |
759 | } | 779 | } |
760 | 780 | ||
761 | AbstractMail *MHviewItem::getWrapper() | 781 | AbstractMail *MHviewItem::getWrapper() |
762 | { | 782 | { |
763 | return wrapper; | 783 | return wrapper; |
764 | } | 784 | } |
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp index 85523b1..de8c5bb 100644 --- a/kmicromail/accountview.cpp +++ b/kmicromail/accountview.cpp | |||
@@ -1,203 +1,206 @@ | |||
1 | 1 | ||
2 | #include "accountview.h" | 2 | #include "accountview.h" |
3 | #include "accountitem.h" | 3 | #include "accountitem.h" |
4 | #include "selectstore.h" | 4 | #include "selectstore.h" |
5 | 5 | ||
6 | #include <libmailwrapper/settings.h> | 6 | #include <libmailwrapper/settings.h> |
7 | #include <libmailwrapper/mailwrapper.h> | 7 | #include <libmailwrapper/mailwrapper.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | 10 | ||
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qpopupmenu.h> | 16 | #include <qpopupmenu.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qspinbox.h> | 18 | #include <qspinbox.h> |
19 | 19 | ||
20 | using namespace Opie::Core; | 20 | using namespace Opie::Core; |
21 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 21 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
22 | : QListView( parent, name, flags ) | 22 | : QListView( parent, name, flags ) |
23 | { | 23 | { |
24 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 24 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
25 | SLOT( refresh(QListViewItem*) ) ); | 25 | SLOT( refresh(QListViewItem*) ) ); |
26 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 26 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
27 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 27 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); |
28 | setSorting(0); | 28 | setSorting(0); |
29 | } | 29 | } |
30 | 30 | ||
31 | AccountView::~AccountView() | 31 | AccountView::~AccountView() |
32 | { | 32 | { |
33 | imapAccounts.clear(); | 33 | imapAccounts.clear(); |
34 | mhAccounts.clear(); | 34 | mhAccounts.clear(); |
35 | } | 35 | } |
36 | 36 | ||
37 | void AccountView::slotContextMenu(int id) | 37 | void AccountView::slotContextMenu(int id) |
38 | { | 38 | { |
39 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 39 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
40 | if (!view) return; | 40 | if (!view) return; |
41 | view->contextMenuSelected(id); | 41 | view->contextMenuSelected(id); |
42 | } | 42 | } |
43 | 43 | ||
44 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 44 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
45 | { | 45 | { |
46 | if (button==1) {return;} | 46 | if (button==1) {return;} |
47 | if (!item) return; | 47 | if (!item) return; |
48 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 48 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
49 | QPopupMenu*m = view->getContextMenu(); | 49 | QPopupMenu*m = view->getContextMenu(); |
50 | if (!m) return; | 50 | if (!m) return; |
51 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 51 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
52 | m->setFocus(); | 52 | m->setFocus(); |
53 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 53 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
54 | delete m; | 54 | delete m; |
55 | } | 55 | } |
56 | 56 | ||
57 | void AccountView::populate( QList<Account> list ) | 57 | void AccountView::populate( QList<Account> list ) |
58 | { | 58 | { |
59 | clear(); | 59 | clear(); |
60 | 60 | ||
61 | imapAccounts.clear(); | 61 | imapAccounts.clear(); |
62 | mhAccounts.clear(); | 62 | mhAccounts.clear(); |
63 | 63 | ||
64 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); | 64 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); |
65 | 65 | ||
66 | Account *it; | 66 | Account *it; |
67 | for ( it = list.first(); it; it = list.next() ) | 67 | for ( it = list.first(); it; it = list.next() ) |
68 | { | 68 | { |
69 | if ( it->getType() == MAILLIB::A_IMAP ) | 69 | if ( it->getType() == MAILLIB::A_IMAP ) |
70 | { | 70 | { |
71 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 71 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
72 | imapAccounts.append(new IMAPviewItem( imap, this )); | 72 | imapAccounts.append(new IMAPviewItem( imap, this )); |
73 | } | 73 | } |
74 | else if ( it->getType() == MAILLIB::A_POP3 ) | 74 | else if ( it->getType() == MAILLIB::A_POP3 ) |
75 | { | 75 | { |
76 | POP3account *pop3 = static_cast<POP3account *>(it); | 76 | POP3account *pop3 = static_cast<POP3account *>(it); |
77 | /* must not be hold 'cause it isn't required */ | 77 | /* must not be hold 'cause it isn't required */ |
78 | (void) new POP3viewItem( pop3, this ); | 78 | (void) new POP3viewItem( pop3, this ); |
79 | } | 79 | } |
80 | else if ( it->getType() == MAILLIB::A_NNTP ) | 80 | else if ( it->getType() == MAILLIB::A_NNTP ) |
81 | { | 81 | { |
82 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | 82 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); |
83 | /* must not be hold 'cause it isn't required */ | 83 | /* must not be hold 'cause it isn't required */ |
84 | (void) new NNTPviewItem( nntp, this ); | 84 | (void) new NNTPviewItem( nntp, this ); |
85 | } | 85 | } |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | void AccountView::refresh(QListViewItem *item) | 89 | void AccountView::refresh(QListViewItem *item) |
90 | { | 90 | { |
91 | if ( item ) | 91 | if ( item ) |
92 | { | 92 | { |
93 | m_currentItem = item; | 93 | m_currentItem = item; |
94 | QValueList<RecMailP> headerlist; | 94 | QValueList<RecMailP> headerlist; |
95 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 95 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
96 | view->refresh(headerlist); | 96 | view->refresh(headerlist); |
97 | emit refreshMailview(headerlist); | 97 | emit refreshMailview(headerlist); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | void AccountView::refreshCurrent() | 101 | void AccountView::refreshCurrent() |
102 | { | 102 | { |
103 | m_currentItem = currentItem(); | 103 | m_currentItem = currentItem(); |
104 | if ( !m_currentItem ) return; | 104 | if ( !m_currentItem ) return; |
105 | QValueList<RecMailP> headerlist; | 105 | QValueList<RecMailP> headerlist; |
106 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 106 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
107 | view->refresh(headerlist); | 107 | view->refresh(headerlist); |
108 | emit refreshMailview(headerlist); | 108 | emit refreshMailview(headerlist); |
109 | } | 109 | } |
110 | 110 | ||
111 | void AccountView::refreshAll() | 111 | void AccountView::refreshAll() |
112 | { | 112 | { |
113 | } | 113 | } |
114 | 114 | ||
115 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) | 115 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) |
116 | { | 116 | { |
117 | QListViewItem*item = selectedItem (); | 117 | QListViewItem*item = selectedItem (); |
118 | if (!item) return new RecBody(); | 118 | if (!item) return new RecBody(); |
119 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 119 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
120 | return view->fetchBody(aMail); | 120 | return view->fetchBody(aMail); |
121 | } | 121 | } |
122 | 122 | ||
123 | void AccountView::setupFolderselect(Selectstore*sels) | 123 | void AccountView::setupFolderselect(Selectstore*sels) |
124 | { | 124 | { |
125 | sels->showMaximized(); | 125 | sels->showMaximized(); |
126 | QStringList sFolders; | 126 | QStringList sFolders; |
127 | unsigned int i = 0; | 127 | unsigned int i = 0; |
128 | for (i=0; i < mhAccounts.count();++i) | 128 | for (i=0; i < mhAccounts.count();++i) |
129 | { | 129 | { |
130 | mhAccounts[i]->refresh(false); | 130 | mhAccounts[i]->refresh(false); |
131 | sFolders = mhAccounts[i]->subFolders(); | 131 | sFolders = mhAccounts[i]->subFolders(); |
132 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 132 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
133 | } | 133 | } |
134 | for (i=0; i < imapAccounts.count();++i) | 134 | for (i=0; i < imapAccounts.count();++i) |
135 | { | 135 | { |
136 | if (imapAccounts[i]->offline()) | 136 | if (imapAccounts[i]->offline()) |
137 | continue; | 137 | continue; |
138 | imapAccounts[i]->refreshFolders(false); | 138 | imapAccounts[i]->refreshFolders(false); |
139 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 139 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) | 142 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) |
143 | { | 143 | { |
144 | #if 0 | ||
144 | AbstractMail*targetMail = 0; | 145 | AbstractMail*targetMail = 0; |
145 | QString targetFolder = ""; | 146 | QString targetFolder = ""; |
146 | Selectstore sels; | 147 | Selectstore sels; |
147 | setupFolderselect(&sels); | 148 | setupFolderselect(&sels); |
148 | if (!sels.exec()) return; | 149 | if (!sels.exec()) return; |
149 | targetMail = sels.currentMail(); | 150 | targetMail = sels.currentMail(); |
150 | targetFolder = sels.currentFolder(); | 151 | targetFolder = sels.currentFolder(); |
151 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 152 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
152 | targetFolder.isEmpty()) | 153 | targetFolder.isEmpty()) |
153 | { | 154 | { |
154 | return; | 155 | return; |
155 | } | 156 | } |
156 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 157 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
157 | { | 158 | { |
158 | QMessageBox::critical(0,tr("Error creating new Folder"), | 159 | QMessageBox::critical(0,tr("Error creating new Folder"), |
159 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 160 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
160 | return; | 161 | return; |
161 | } | 162 | } |
162 | int maxsize = 0; | 163 | int maxsize = 0; |
163 | if ( sels.useSize->isChecked()) | 164 | if ( sels.useSize->isChecked()) |
164 | maxsize = sels.sizeSpinBox->value(); | 165 | maxsize = sels.sizeSpinBox->value(); |
165 | |||
166 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 166 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
167 | #endif | ||
168 | fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); | ||
167 | refreshCurrent(); | 169 | refreshCurrent(); |
170 | |||
168 | } | 171 | } |
169 | 172 | ||
170 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 173 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
171 | { | 174 | { |
172 | AbstractMail*targetMail = 0; | 175 | AbstractMail*targetMail = 0; |
173 | QString targetFolder = ""; | 176 | QString targetFolder = ""; |
174 | Selectstore sels; | 177 | Selectstore sels; |
175 | setupFolderselect(&sels); | 178 | setupFolderselect(&sels); |
176 | if (!sels.exec()) return; | 179 | if (!sels.exec()) return; |
177 | targetMail = sels.currentMail(); | 180 | targetMail = sels.currentMail(); |
178 | targetFolder = sels.currentFolder(); | 181 | targetFolder = sels.currentFolder(); |
179 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 182 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
180 | targetFolder.isEmpty()) | 183 | targetFolder.isEmpty()) |
181 | { | 184 | { |
182 | return; | 185 | return; |
183 | } | 186 | } |
184 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 187 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
185 | { | 188 | { |
186 | QMessageBox::critical(0,tr("Error creating new Folder"), | 189 | QMessageBox::critical(0,tr("Error creating new Folder"), |
187 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 190 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
188 | return; | 191 | return; |
189 | } | 192 | } |
190 | int maxsize = 0; | 193 | int maxsize = 0; |
191 | if ( sels.useSize->isChecked()) | 194 | if ( sels.useSize->isChecked()) |
192 | maxsize = sels.sizeSpinBox->value(); | 195 | maxsize = sels.sizeSpinBox->value(); |
193 | 196 | ||
194 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 197 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
195 | refreshCurrent(); | 198 | refreshCurrent(); |
196 | } | 199 | } |
197 | 200 | ||
198 | bool AccountView::currentisDraft() | 201 | bool AccountView::currentisDraft() |
199 | { | 202 | { |
200 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 203 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
201 | if (!view) return false; | 204 | if (!view) return false; |
202 | return view->isDraftfolder(); | 205 | return view->isDraftfolder(); |
203 | } | 206 | } |
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index f876235..374d606 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -1,210 +1,277 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "abstractmail.h" | 2 | #include "abstractmail.h" |
3 | #include "imapwrapper.h" | 3 | #include "imapwrapper.h" |
4 | #include "pop3wrapper.h" | 4 | #include "pop3wrapper.h" |
5 | #include "nntpwrapper.h" | 5 | #include "nntpwrapper.h" |
6 | #include "mhwrapper.h" | 6 | #include "mhwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | 9 | ||
10 | 10 | ||
11 | #include <qprogressbar.h> | 11 | #include <qprogressbar.h> |
12 | #include <qapplication.h> | 12 | #include <qapplication.h> |
13 | #include <qmessagebox.h> | ||
13 | 14 | ||
14 | #include <kdecore/kstandarddirs.h> | 15 | #include <kdecore/kstandarddirs.h> |
15 | #include <qfile.h> | 16 | #include <qfile.h> |
16 | #include <qtextstream.h> | 17 | #include <qtextstream.h> |
17 | #include <stdlib.h> | 18 | #include <stdlib.h> |
18 | #include <libetpan/mailmime_content.h> | 19 | #include <libetpan/mailmime_content.h> |
19 | #include <libetpan/mailmime.h> | 20 | #include <libetpan/mailmime.h> |
20 | 21 | ||
21 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
22 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 23 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
23 | { | 24 | { |
24 | return new IMAPwrapper(a); | 25 | return new IMAPwrapper(a); |
25 | } | 26 | } |
26 | 27 | ||
27 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 28 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
28 | { | 29 | { |
29 | return new POP3wrapper(a); | 30 | return new POP3wrapper(a); |
30 | } | 31 | } |
31 | 32 | ||
32 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 33 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
33 | { | 34 | { |
34 | return new NNTPwrapper(a); | 35 | return new NNTPwrapper(a); |
35 | } | 36 | } |
36 | 37 | ||
37 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 38 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
38 | { | 39 | { |
39 | return new MHwrapper(a,name); | 40 | return new MHwrapper(a,name); |
40 | } | 41 | } |
41 | 42 | ||
42 | AbstractMail* AbstractMail::getWrapper(Account*a) | 43 | AbstractMail* AbstractMail::getWrapper(Account*a) |
43 | { | 44 | { |
44 | if (!a) return 0; | 45 | if (!a) return 0; |
45 | switch (a->getType()) { | 46 | switch (a->getType()) { |
46 | case MAILLIB::A_IMAP: | 47 | case MAILLIB::A_IMAP: |
47 | return new IMAPwrapper((IMAPaccount*)a); | 48 | return new IMAPwrapper((IMAPaccount*)a); |
48 | break; | 49 | break; |
49 | case MAILLIB::A_POP3: | 50 | case MAILLIB::A_POP3: |
50 | return new POP3wrapper((POP3account*)a); | 51 | return new POP3wrapper((POP3account*)a); |
51 | break; | 52 | break; |
52 | case MAILLIB::A_NNTP: | 53 | case MAILLIB::A_NNTP: |
53 | return new NNTPwrapper((NNTPaccount*)a); | 54 | return new NNTPwrapper((NNTPaccount*)a); |
54 | break; | 55 | break; |
55 | default: | 56 | default: |
56 | return 0; | 57 | return 0; |
57 | } | 58 | } |
58 | } | 59 | } |
59 | 60 | ||
60 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 61 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
61 | { | 62 | { |
62 | // odebug << "Decode string start" << oendl; | 63 | // odebug << "Decode string start" << oendl; |
63 | char*result_text; | 64 | char*result_text; |
64 | size_t index = 0; | 65 | size_t index = 0; |
65 | /* reset for recursive use! */ | 66 | /* reset for recursive use! */ |
66 | size_t target_length = 0; | 67 | size_t target_length = 0; |
67 | result_text = 0; | 68 | result_text = 0; |
68 | int mimetype = MAILMIME_MECHANISM_7BIT; | 69 | int mimetype = MAILMIME_MECHANISM_7BIT; |
69 | if (enc.lower()=="quoted-printable") { | 70 | if (enc.lower()=="quoted-printable") { |
70 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 71 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
71 | } else if (enc.lower()=="base64") { | 72 | } else if (enc.lower()=="base64") { |
72 | mimetype = MAILMIME_MECHANISM_BASE64; | 73 | mimetype = MAILMIME_MECHANISM_BASE64; |
73 | } else if (enc.lower()=="8bit") { | 74 | } else if (enc.lower()=="8bit") { |
74 | mimetype = MAILMIME_MECHANISM_8BIT; | 75 | mimetype = MAILMIME_MECHANISM_8BIT; |
75 | } else if (enc.lower()=="binary") { | 76 | } else if (enc.lower()=="binary") { |
76 | mimetype = MAILMIME_MECHANISM_BINARY; | 77 | mimetype = MAILMIME_MECHANISM_BINARY; |
77 | } | 78 | } |
78 | 79 | ||
79 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 80 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
80 | &result_text,&target_length); | 81 | &result_text,&target_length); |
81 | 82 | ||
82 | encodedString* result = new encodedString(); | 83 | encodedString* result = new encodedString(); |
83 | if (err == MAILIMF_NO_ERROR) { | 84 | if (err == MAILIMF_NO_ERROR) { |
84 | result->setContent(result_text,target_length); | 85 | result->setContent(result_text,target_length); |
85 | } | 86 | } |
86 | //odebug << "Decode string finished" << oendl; | 87 | //odebug << "Decode string finished" << oendl; |
87 | return result; | 88 | return result; |
88 | } | 89 | } |
89 | 90 | ||
90 | QString AbstractMail::convert_String(const char*text) | 91 | QString AbstractMail::convert_String(const char*text) |
91 | { | 92 | { |
92 | //size_t index = 0; | 93 | //size_t index = 0; |
93 | char*res = 0; | 94 | char*res = 0; |
94 | int err = MAILIMF_NO_ERROR; | 95 | int err = MAILIMF_NO_ERROR; |
95 | 96 | ||
96 | QString result(text); | 97 | QString result(text); |
97 | 98 | ||
98 | /* due a bug in libetpan it isn't usable this moment */ | 99 | /* due a bug in libetpan it isn't usable this moment */ |
99 | /* int err = mailmime_encoded_phrase_parse("iso-8859-1", | 100 | /* int err = mailmime_encoded_phrase_parse("iso-8859-1", |
100 | text, strlen(text),&index, "iso-8859-1",&res);*/ | 101 | text, strlen(text),&index, "iso-8859-1",&res);*/ |
101 | //odebug << "Input: " << text << "" << oendl; | 102 | //odebug << "Input: " << text << "" << oendl; |
102 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 103 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
103 | // result = QString(res); | 104 | // result = QString(res); |
104 | // odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl; | 105 | // odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl; |
105 | } | 106 | } |
106 | if (res) free(res); | 107 | if (res) free(res); |
107 | return result; | 108 | return result; |
108 | } | 109 | } |
109 | 110 | ||
110 | /* cp & paste from launcher */ | 111 | /* cp & paste from launcher */ |
111 | QString AbstractMail::gen_attachment_id() | 112 | QString AbstractMail::gen_attachment_id() |
112 | { | 113 | { |
113 | QFile file( "/proc/sys/kernel/random/uuid" ); | 114 | QFile file( "/proc/sys/kernel/random/uuid" ); |
114 | if (!file.open(IO_ReadOnly ) ) | 115 | if (!file.open(IO_ReadOnly ) ) |
115 | return QString::null; | 116 | return QString::null; |
116 | 117 | ||
117 | QTextStream stream(&file); | 118 | QTextStream stream(&file); |
118 | 119 | ||
119 | return "{" + stream.read().stripWhiteSpace() + "}"; | 120 | return "{" + stream.read().stripWhiteSpace() + "}"; |
120 | } | 121 | } |
121 | 122 | ||
122 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) | 123 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) |
123 | { | 124 | { |
124 | return 0; | 125 | return 0; |
125 | } | 126 | } |
126 | 127 | ||
127 | QString AbstractMail::defaultLocalfolder() | 128 | QString AbstractMail::defaultLocalfolder() |
128 | { | 129 | { |
129 | // QString f = getenv( "HOME" ); | 130 | // QString f = getenv( "HOME" ); |
130 | QString f = locateLocal( "data", "kopiemail/localmail"); | 131 | QString f = locateLocal( "data", "kopiemail/localmail"); |
131 | // f += "/Applications/opiemail/localmail"; | 132 | // f += "/Applications/opiemail/localmail"; |
132 | return f; | 133 | return f; |
133 | } | 134 | } |
134 | 135 | ||
135 | QString AbstractMail::draftFolder() | 136 | QString AbstractMail::draftFolder() |
136 | { | 137 | { |
137 | return QString("Drafts"); | 138 | return QString("Drafts"); |
138 | } | 139 | } |
139 | 140 | ||
140 | /* temporary - will be removed when implemented in all classes */ | 141 | /* temporary - will be removed when implemented in all classes */ |
141 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 142 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
142 | { | 143 | { |
143 | } | 144 | } |
144 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | 145 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) |
145 | { | 146 | { |
146 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | 147 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); |
147 | // this is currently re-implemented in pop3wrapper and imapwrapper | 148 | // this is currently re-implemented in pop3wrapper and imapwrapper |
148 | int iii = 0; | 149 | int iii = 0; |
149 | int count = target.count(); | 150 | int count = target.count(); |
150 | QWidget wid; | 151 | QWidget wid; |
151 | wid.show(); | 152 | wid.show(); |
152 | while (iii < count ) { | 153 | while (iii < count ) { |
153 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 154 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
154 | wid.raise(); | 155 | wid.raise(); |
155 | qApp->processEvents(); | 156 | qApp->processEvents(); |
156 | RecMailP mail = (*target.at( iii )); | 157 | RecMailP mail = (*target.at( iii )); |
157 | deleteMail(mail); | 158 | deleteMail(mail); |
158 | ++iii; | 159 | ++iii; |
159 | } | 160 | } |
160 | } | 161 | } |
162 | |||
163 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) | ||
164 | { | ||
165 | qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); | ||
166 | // get local folder | ||
167 | Account * acc = getAccount(); | ||
168 | if ( !acc ) return; | ||
169 | QString lfName = acc->getLocalFolder(); | ||
170 | if ( lfName.isEmpty() ) | ||
171 | lfName = acc->getAccountName(); | ||
172 | // create local folder | ||
173 | if ( !targetMail->createMbox(lfName)) | ||
174 | { | ||
175 | QMessageBox::critical(0,tr("Error creating new Folder"), | ||
176 | tr("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); | ||
177 | return; | ||
178 | } | ||
179 | QValueList<RecMailP> t; | ||
180 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); | ||
181 | if ( t.count() == 0 ) { | ||
182 | Global::statusMessage(tr("There are no new messages")); | ||
183 | return; | ||
184 | } | ||
185 | QValueList<RecMailP> e; | ||
186 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); | ||
187 | qDebug("target has mails %d ", e.count()); | ||
188 | QValueList<RecMailP> n; | ||
189 | int iii = 0; | ||
190 | int count = t.count(); | ||
191 | while (iii < count ) { | ||
192 | RecMailP r = (*t.at( iii )); | ||
193 | bool found = false; | ||
194 | int jjj = 0; | ||
195 | int countE = e.count(); | ||
196 | while (jjj < countE ) { | ||
197 | RecMailP re = (*e.at( jjj )); | ||
198 | if ( re->isEqual(r) ) { | ||
199 | found = true; | ||
200 | break; | ||
201 | } | ||
202 | ++jjj; | ||
203 | } | ||
204 | if ( found ) | ||
205 | qDebug("found "); | ||
206 | else | ||
207 | qDebug("NOT found "); | ||
208 | |||
209 | if ( !found ) { | ||
210 | n.append( r ); | ||
211 | } | ||
212 | ++iii; | ||
213 | } | ||
214 | if ( n.count() == 0 ) { | ||
215 | Global::statusMessage(tr("There are no new messages")); | ||
216 | return; | ||
217 | } | ||
218 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); | ||
219 | |||
220 | |||
221 | #if 0 | ||
222 | QValueList<RecMailP> t; | ||
223 | listMessages(fromFolder->getName(),t, maxSizeInKb); | ||
224 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | ||
225 | #endif | ||
226 | |||
227 | } | ||
161 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 228 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
162 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 229 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
163 | { | 230 | { |
164 | QValueList<RecMailP> t; | 231 | QValueList<RecMailP> t; |
165 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 232 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
166 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 233 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
167 | 234 | ||
168 | } | 235 | } |
169 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, | 236 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, |
170 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 237 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
171 | { | 238 | { |
172 | encodedString*st = 0; | 239 | encodedString*st = 0; |
173 | int iii = 0; | 240 | int iii = 0; |
174 | int count = t.count(); | 241 | int count = t.count(); |
175 | if ( count == 0 ) | 242 | if ( count == 0 ) |
176 | return; | 243 | return; |
177 | // wel, processevents is qite strange, we need a widget for getting | 244 | // wel, processevents is qite strange, we need a widget for getting |
178 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displayed | 245 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displayed |
179 | QWidget wid; | 246 | QWidget wid; |
180 | wid.show(); | 247 | wid.show(); |
181 | while (iii < count ) { | 248 | while (iii < count ) { |
182 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); | 249 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); |
183 | wid.raise(); | 250 | wid.raise(); |
184 | qApp->processEvents(); | 251 | qApp->processEvents(); |
185 | RecMailP r = (*t.at( iii )); | 252 | RecMailP r = (*t.at( iii )); |
186 | st = fetchRawBody(r); | 253 | st = fetchRawBody(r); |
187 | if (st) { | 254 | if (st) { |
188 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 255 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
189 | delete st; | 256 | delete st; |
190 | } | 257 | } |
191 | ++iii; | 258 | ++iii; |
192 | } | 259 | } |
193 | if (moveit) { | 260 | if (moveit) { |
194 | deleteMailList( t ); | 261 | deleteMailList( t ); |
195 | //deleteAllMail(fromFolder); | 262 | //deleteAllMail(fromFolder); |
196 | } | 263 | } |
197 | } | 264 | } |
198 | 265 | ||
199 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 266 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
200 | { | 267 | { |
201 | encodedString*st = 0; | 268 | encodedString*st = 0; |
202 | st = fetchRawBody(mail); | 269 | st = fetchRawBody(mail); |
203 | if (st) { | 270 | if (st) { |
204 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 271 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
205 | delete st; | 272 | delete st; |
206 | } | 273 | } |
207 | if (moveit) { | 274 | if (moveit) { |
208 | deleteMail(mail); | 275 | deleteMail(mail); |
209 | } | 276 | } |
210 | } | 277 | } |
diff --git a/kmicromail/libmailwrapper/abstractmail.h b/kmicromail/libmailwrapper/abstractmail.h index cae83f4..2069ca1 100644 --- a/kmicromail/libmailwrapper/abstractmail.h +++ b/kmicromail/libmailwrapper/abstractmail.h | |||
@@ -1,76 +1,81 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __abstract_mail_ | 2 | #ifndef __abstract_mail_ |
3 | #define __abstract_mail_ | 3 | #define __abstract_mail_ |
4 | 4 | ||
5 | #include "maildefines.h" | 5 | #include "maildefines.h" |
6 | 6 | ||
7 | #include "settings.h" | 7 | #include "settings.h" |
8 | 8 | ||
9 | #include <qobject.h> | 9 | #include <qobject.h> |
10 | #include <opie2/osmartpointer.h> | 10 | #include <opie2/osmartpointer.h> |
11 | #include "mailtypes.h" | 11 | #include "mailtypes.h" |
12 | 12 | ||
13 | |||
14 | #include "mailwrapper.h" | ||
15 | |||
13 | class IMAPwrapper; | 16 | class IMAPwrapper; |
14 | class POP3wrapper; | 17 | class POP3wrapper; |
15 | class Folder; | 18 | class Folder; |
16 | class encodedString; | 19 | class encodedString; |
17 | struct folderStat; | 20 | struct folderStat; |
18 | 21 | ||
19 | class AbstractMail:public QObject | 22 | class AbstractMail:public QObject |
20 | { | 23 | { |
21 | Q_OBJECT | 24 | Q_OBJECT |
22 | public: | 25 | public: |
23 | AbstractMail(){}; | 26 | AbstractMail(){}; |
24 | virtual ~AbstractMail(){} | 27 | virtual ~AbstractMail(){} |
25 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0; | 28 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0; |
26 | virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target, int sizeInKb = 0 )=0; | 29 | virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target, int sizeInKb = 0 )=0; |
27 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 30 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
28 | virtual RecBodyP fetchBody(const RecMailP&mail)=0; | 31 | virtual RecBodyP fetchBody(const RecMailP&mail)=0; |
29 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0; | 32 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0; |
30 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0; | 33 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0; |
31 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0; | 34 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0; |
32 | virtual encodedString* fetchRawBody(const RecMailP&mail)=0; | 35 | virtual encodedString* fetchRawBody(const RecMailP&mail)=0; |
33 | 36 | ||
34 | virtual void deleteMail(const RecMailP&mail)=0; | 37 | virtual void deleteMail(const RecMailP&mail)=0; |
35 | virtual void deleteMailList(const QValueList<RecMailP>&target); | 38 | virtual void deleteMailList(const QValueList<RecMailP>&target); |
36 | virtual void answeredMail(const RecMailP&mail)=0; | 39 | virtual void answeredMail(const RecMailP&mail)=0; |
37 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0; | 40 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0; |
38 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target); | 41 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target); |
39 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; | 42 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; |
40 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 43 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
41 | 44 | void downloadNewMails(const FolderP&fromFolder,AbstractMail*targetWrapper ); | |
42 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 45 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
43 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int sizeInKb = 0); | 46 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int sizeInKb = 0); |
44 | virtual void mvcpMailList(const QValueList<RecMailP>& t, | 47 | virtual void mvcpMailList(const QValueList<RecMailP>& t, |
45 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 48 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
46 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 49 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
47 | 50 | ||
48 | virtual void cleanMimeCache(){}; | 51 | virtual void cleanMimeCache(){}; |
49 | /* mail box methods */ | 52 | /* mail box methods */ |
50 | /* parameter is the box to create. | 53 | /* parameter is the box to create. |
51 | * if the implementing subclass has prefixes, | 54 | * if the implementing subclass has prefixes, |
52 | * them has to be appended automatic. | 55 | * them has to be appended automatic. |
53 | */ | 56 | */ |
54 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, | 57 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, |
55 | const QString& delemiter="/",bool getsubfolder=false); | 58 | const QString& delemiter="/",bool getsubfolder=false); |
56 | virtual void logout()=0; | 59 | virtual void logout()=0; |
57 | 60 | ||
61 | virtual Account* getAccount() = 0; | ||
62 | |||
58 | static AbstractMail* getWrapper(IMAPaccount *a); | 63 | static AbstractMail* getWrapper(IMAPaccount *a); |
59 | static AbstractMail* getWrapper(POP3account *a); | 64 | static AbstractMail* getWrapper(POP3account *a); |
60 | static AbstractMail* getWrapper(NNTPaccount *a); | 65 | static AbstractMail* getWrapper(NNTPaccount *a); |
61 | /* mbox only! */ | 66 | /* mbox only! */ |
62 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); | 67 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
63 | static AbstractMail* getWrapper(Account*a); | 68 | static AbstractMail* getWrapper(Account*a); |
64 | 69 | ||
65 | static QString defaultLocalfolder(); | 70 | static QString defaultLocalfolder(); |
66 | static QString draftFolder(); | 71 | static QString draftFolder(); |
67 | 72 | ||
68 | virtual MAILLIB::ATYPE getType()const=0; | 73 | virtual MAILLIB::ATYPE getType()const=0; |
69 | virtual const QString&getName()const=0; | 74 | virtual const QString&getName()const=0; |
70 | 75 | ||
71 | protected: | 76 | protected: |
72 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 77 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
73 | static QString convert_String(const char*text); | 78 | static QString convert_String(const char*text); |
74 | static QString gen_attachment_id(); | 79 | static QString gen_attachment_id(); |
75 | }; | 80 | }; |
76 | #endif | 81 | #endif |
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index 9614d53..2b04847 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,481 +1,521 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "genericwrapper.h" | 2 | #include "genericwrapper.h" |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <kconfig.h> | ||
7 | #include <kglobal.h> | ||
8 | #include <kstandarddirs.h> | ||
6 | 9 | ||
7 | 10 | ||
8 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
9 | Genericwrapper::Genericwrapper() | 12 | Genericwrapper::Genericwrapper() |
10 | : AbstractMail() | 13 | : AbstractMail() |
11 | { | 14 | { |
12 | bodyCache.clear(); | 15 | bodyCache.clear(); |
13 | m_storage = 0; | 16 | m_storage = 0; |
14 | m_folder = 0; | 17 | m_folder = 0; |
15 | } | 18 | } |
16 | 19 | ||
17 | Genericwrapper::~Genericwrapper() | 20 | Genericwrapper::~Genericwrapper() |
18 | { | 21 | { |
19 | if (m_folder) { | 22 | if (m_folder) { |
20 | mailfolder_free(m_folder); | 23 | mailfolder_free(m_folder); |
21 | } | 24 | } |
22 | if (m_storage) { | 25 | if (m_storage) { |
23 | mailstorage_free(m_storage); | 26 | mailstorage_free(m_storage); |
24 | } | 27 | } |
25 | cleanMimeCache(); | 28 | cleanMimeCache(); |
26 | } | 29 | } |
30 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | ||
31 | { | ||
32 | static bool init = false ; | ||
33 | if ( ! init ) { | ||
34 | KConfig kon ( locateLocal( "config", "korganizerrc" ) ); | ||
35 | kon.setGroup("Locale"); | ||
36 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); | ||
37 | QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); | ||
38 | KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); | ||
39 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | ||
40 | kon.setGroup("Time & Date"); | ||
41 | KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), | ||
42 | kon.readNumEntry( "DaylightsavingStart", 90), | ||
43 | kon.readNumEntry( "DaylightsavingEnd",304) ); | ||
44 | KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); | ||
45 | |||
46 | init = true; | ||
47 | |||
48 | } | ||
49 | QDateTime dt (QDate(date->dt_year,date->dt_month, date->dt_day ),QTime(date->dt_hour, date->dt_min, date->dt_sec ) ); | ||
50 | int off = KGlobal::locale()->localTimeOffset( dt ); | ||
51 | dt = dt.addSecs( off*60 ); | ||
52 | QString ret = KGlobal::locale()->formatDateTime( dt,true,true); | ||
53 | if ( off < 0 ) | ||
54 | ret += " -"; | ||
55 | else | ||
56 | ret += " +"; | ||
57 | ret += QString::number( off / 60 ); | ||
58 | ret += "h"; | ||
59 | #if 0 | ||
60 | char tmp[23]; | ||
61 | |||
62 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | ||
63 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
64 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | ||
65 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
66 | |||
67 | |||
68 | return QString( tmp ); | ||
69 | #endif | ||
70 | return ret; | ||
71 | } | ||
27 | 72 | ||
28 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 73 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
29 | { | 74 | { |
30 | if (!mime) { | 75 | if (!mime) { |
31 | return; | 76 | return; |
32 | } | 77 | } |
33 | mailmime_field*field = 0; | 78 | mailmime_field*field = 0; |
34 | mailmime_single_fields fields; | 79 | mailmime_single_fields fields; |
35 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 80 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
36 | if (mime->mm_mime_fields != NULL) { | 81 | if (mime->mm_mime_fields != NULL) { |
37 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 82 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
38 | mime->mm_content_type); | 83 | mime->mm_content_type); |
39 | } | 84 | } |
40 | 85 | ||
41 | mailmime_content*type = fields.fld_content; | 86 | mailmime_content*type = fields.fld_content; |
42 | clistcell*current; | 87 | clistcell*current; |
43 | if (!type) { | 88 | if (!type) { |
44 | target->setType("text"); | 89 | target->setType("text"); |
45 | target->setSubtype("plain"); | 90 | target->setSubtype("plain"); |
46 | } else { | 91 | } else { |
47 | target->setSubtype(type->ct_subtype); | 92 | target->setSubtype(type->ct_subtype); |
48 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 93 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
49 | case MAILMIME_DISCRETE_TYPE_TEXT: | 94 | case MAILMIME_DISCRETE_TYPE_TEXT: |
50 | target->setType("text"); | 95 | target->setType("text"); |
51 | break; | 96 | break; |
52 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 97 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
53 | target->setType("image"); | 98 | target->setType("image"); |
54 | break; | 99 | break; |
55 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 100 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
56 | target->setType("audio"); | 101 | target->setType("audio"); |
57 | break; | 102 | break; |
58 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 103 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
59 | target->setType("video"); | 104 | target->setType("video"); |
60 | break; | 105 | break; |
61 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 106 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
62 | target->setType("application"); | 107 | target->setType("application"); |
63 | break; | 108 | break; |
64 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 109 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
65 | default: | 110 | default: |
66 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 111 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
67 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 112 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
68 | } | 113 | } |
69 | break; | 114 | break; |
70 | } | 115 | } |
71 | if (type->ct_parameters) { | 116 | if (type->ct_parameters) { |
72 | fillParameters(target,type->ct_parameters); | 117 | fillParameters(target,type->ct_parameters); |
73 | } | 118 | } |
74 | } | 119 | } |
75 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { | 120 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { |
76 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { | 121 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { |
77 | field = (mailmime_field*)current->data; | 122 | field = (mailmime_field*)current->data; |
78 | switch(field->fld_type) { | 123 | switch(field->fld_type) { |
79 | case MAILMIME_FIELD_TRANSFER_ENCODING: | 124 | case MAILMIME_FIELD_TRANSFER_ENCODING: |
80 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); | 125 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); |
81 | break; | 126 | break; |
82 | case MAILMIME_FIELD_ID: | 127 | case MAILMIME_FIELD_ID: |
83 | target->setIdentifier(field->fld_data.fld_id); | 128 | target->setIdentifier(field->fld_data.fld_id); |
84 | break; | 129 | break; |
85 | case MAILMIME_FIELD_DESCRIPTION: | 130 | case MAILMIME_FIELD_DESCRIPTION: |
86 | target->setDescription(field->fld_data.fld_description); | 131 | target->setDescription(field->fld_data.fld_description); |
87 | break; | 132 | break; |
88 | default: | 133 | default: |
89 | break; | 134 | break; |
90 | } | 135 | } |
91 | } | 136 | } |
92 | } | 137 | } |
93 | } | 138 | } |
94 | 139 | ||
95 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) | 140 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) |
96 | { | 141 | { |
97 | if (!parameters) {return;} | 142 | if (!parameters) {return;} |
98 | clistcell*current=0; | 143 | clistcell*current=0; |
99 | mailmime_parameter*param; | 144 | mailmime_parameter*param; |
100 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { | 145 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { |
101 | param = (mailmime_parameter*)current->data; | 146 | param = (mailmime_parameter*)current->data; |
102 | if (param) { | 147 | if (param) { |
103 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 148 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
104 | } | 149 | } |
105 | } | 150 | } |
106 | } | 151 | } |
107 | 152 | ||
108 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | 153 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) |
109 | { | 154 | { |
110 | QString enc="7bit"; | 155 | QString enc="7bit"; |
111 | if (!aEnc) return enc; | 156 | if (!aEnc) return enc; |
112 | switch(aEnc->enc_type) { | 157 | switch(aEnc->enc_type) { |
113 | case MAILMIME_MECHANISM_7BIT: | 158 | case MAILMIME_MECHANISM_7BIT: |
114 | enc = "7bit"; | 159 | enc = "7bit"; |
115 | break; | 160 | break; |
116 | case MAILMIME_MECHANISM_8BIT: | 161 | case MAILMIME_MECHANISM_8BIT: |
117 | enc = "8bit"; | 162 | enc = "8bit"; |
118 | break; | 163 | break; |
119 | case MAILMIME_MECHANISM_BINARY: | 164 | case MAILMIME_MECHANISM_BINARY: |
120 | enc = "binary"; | 165 | enc = "binary"; |
121 | break; | 166 | break; |
122 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 167 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
123 | enc = "quoted-printable"; | 168 | enc = "quoted-printable"; |
124 | break; | 169 | break; |
125 | case MAILMIME_MECHANISM_BASE64: | 170 | case MAILMIME_MECHANISM_BASE64: |
126 | enc = "base64"; | 171 | enc = "base64"; |
127 | break; | 172 | break; |
128 | case MAILMIME_MECHANISM_TOKEN: | 173 | case MAILMIME_MECHANISM_TOKEN: |
129 | default: | 174 | default: |
130 | if (aEnc->enc_token) { | 175 | if (aEnc->enc_token) { |
131 | enc = QString(aEnc->enc_token); | 176 | enc = QString(aEnc->enc_token); |
132 | } | 177 | } |
133 | break; | 178 | break; |
134 | } | 179 | } |
135 | return enc; | 180 | return enc; |
136 | } | 181 | } |
137 | 182 | ||
138 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 183 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
139 | { | 184 | { |
140 | if (current_rec >= 10) { | 185 | if (current_rec >= 10) { |
141 | ; // odebug << "too deep recursion!" << oendl; | 186 | ; // odebug << "too deep recursion!" << oendl; |
142 | } | 187 | } |
143 | if (!message || !mime) { | 188 | if (!message || !mime) { |
144 | return; | 189 | return; |
145 | } | 190 | } |
146 | int r; | 191 | int r; |
147 | char*data = 0; | 192 | char*data = 0; |
148 | size_t len; | 193 | size_t len; |
149 | clistiter * cur = 0; | 194 | clistiter * cur = 0; |
150 | QString b; | 195 | QString b; |
151 | RecPartP part = new RecPart(); | 196 | RecPartP part = new RecPart(); |
152 | 197 | ||
153 | switch (mime->mm_type) { | 198 | switch (mime->mm_type) { |
154 | case MAILMIME_SINGLE: | 199 | case MAILMIME_SINGLE: |
155 | { | 200 | { |
156 | QValueList<int>countlist = recList; | 201 | QValueList<int>countlist = recList; |
157 | countlist.append(current_count); | 202 | countlist.append(current_count); |
158 | r = mailmessage_fetch_section(message,mime,&data,&len); | 203 | r = mailmessage_fetch_section(message,mime,&data,&len); |
159 | part->setSize(len); | 204 | part->setSize(len); |
160 | part->setPositionlist(countlist); | 205 | part->setPositionlist(countlist); |
161 | b = gen_attachment_id(); | 206 | b = gen_attachment_id(); |
162 | part->setIdentifier(b); | 207 | part->setIdentifier(b); |
163 | fillSingleBody(part,message,mime); | 208 | fillSingleBody(part,message,mime); |
164 | if (part->Type()=="text" && target->Bodytext().isNull()) { | 209 | if (part->Type()=="text" && target->Bodytext().isNull()) { |
165 | encodedString*rs = new encodedString(); | 210 | encodedString*rs = new encodedString(); |
166 | rs->setContent(data,len); | 211 | rs->setContent(data,len); |
167 | encodedString*res = decode_String(rs,part->Encoding()); | 212 | encodedString*res = decode_String(rs,part->Encoding()); |
168 | if (countlist.count()>2) { | 213 | if (countlist.count()>2) { |
169 | bodyCache[b]=rs; | 214 | bodyCache[b]=rs; |
170 | target->addPart(part); | 215 | target->addPart(part); |
171 | } else { | 216 | } else { |
172 | delete rs; | 217 | delete rs; |
173 | } | 218 | } |
174 | b = QString(res->Content()); | 219 | b = QString(res->Content()); |
175 | delete res; | 220 | delete res; |
176 | target->setBodytext(b); | 221 | target->setBodytext(b); |
177 | target->setDescription(part); | 222 | target->setDescription(part); |
178 | } else { | 223 | } else { |
179 | bodyCache[b]=new encodedString(data,len); | 224 | bodyCache[b]=new encodedString(data,len); |
180 | target->addPart(part); | 225 | target->addPart(part); |
181 | } | 226 | } |
182 | } | 227 | } |
183 | break; | 228 | break; |
184 | case MAILMIME_MULTIPLE: | 229 | case MAILMIME_MULTIPLE: |
185 | { | 230 | { |
186 | unsigned int ccount = 1; | 231 | unsigned int ccount = 1; |
187 | mailmime*cbody=0; | 232 | mailmime*cbody=0; |
188 | QValueList<int>countlist = recList; | 233 | QValueList<int>countlist = recList; |
189 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 234 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
190 | cbody = (mailmime*)clist_content(cur); | 235 | cbody = (mailmime*)clist_content(cur); |
191 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 236 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
192 | RecPartP targetPart = new RecPart(); | 237 | RecPartP targetPart = new RecPart(); |
193 | targetPart->setType("multipart"); | 238 | targetPart->setType("multipart"); |
194 | countlist.append(current_count); | 239 | countlist.append(current_count); |
195 | targetPart->setPositionlist(countlist); | 240 | targetPart->setPositionlist(countlist); |
196 | target->addPart(targetPart); | 241 | target->addPart(targetPart); |
197 | } | 242 | } |
198 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 243 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
199 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 244 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
200 | countlist = recList; | 245 | countlist = recList; |
201 | } | 246 | } |
202 | ++ccount; | 247 | ++ccount; |
203 | } | 248 | } |
204 | } | 249 | } |
205 | break; | 250 | break; |
206 | case MAILMIME_MESSAGE: | 251 | case MAILMIME_MESSAGE: |
207 | { | 252 | { |
208 | QValueList<int>countlist = recList; | 253 | QValueList<int>countlist = recList; |
209 | countlist.append(current_count); | 254 | countlist.append(current_count); |
210 | /* the own header is always at recursion 0 - we don't need that */ | 255 | /* the own header is always at recursion 0 - we don't need that */ |
211 | if (current_rec > 0) { | 256 | if (current_rec > 0) { |
212 | part->setPositionlist(countlist); | 257 | part->setPositionlist(countlist); |
213 | r = mailmessage_fetch_section(message,mime,&data,&len); | 258 | r = mailmessage_fetch_section(message,mime,&data,&len); |
214 | part->setSize(len); | 259 | part->setSize(len); |
215 | part->setPositionlist(countlist); | 260 | part->setPositionlist(countlist); |
216 | b = gen_attachment_id(); | 261 | b = gen_attachment_id(); |
217 | part->setIdentifier(b); | 262 | part->setIdentifier(b); |
218 | part->setType("message"); | 263 | part->setType("message"); |
219 | part->setSubtype("rfc822"); | 264 | part->setSubtype("rfc822"); |
220 | bodyCache[b]=new encodedString(data,len); | 265 | bodyCache[b]=new encodedString(data,len); |
221 | target->addPart(part); | 266 | target->addPart(part); |
222 | } | 267 | } |
223 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 268 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
224 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 269 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
225 | } | 270 | } |
226 | } | 271 | } |
227 | break; | 272 | break; |
228 | } | 273 | } |
229 | } | 274 | } |
230 | 275 | ||
231 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) | 276 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) |
232 | { | 277 | { |
233 | int err = MAILIMF_NO_ERROR; | 278 | int err = MAILIMF_NO_ERROR; |
234 | mailmime_single_fields fields; | 279 | mailmime_single_fields fields; |
235 | /* is bound to msg and will be freed there */ | 280 | /* is bound to msg and will be freed there */ |
236 | mailmime * mime=0; | 281 | mailmime * mime=0; |
237 | RecBodyP body = new RecBody(); | 282 | RecBodyP body = new RecBody(); |
238 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 283 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
239 | err = mailmessage_get_bodystructure(msg,&mime); | 284 | err = mailmessage_get_bodystructure(msg,&mime); |
240 | QValueList<int>recList; | 285 | QValueList<int>recList; |
241 | traverseBody(body,msg,mime,recList); | 286 | traverseBody(body,msg,mime,recList); |
242 | return body; | 287 | return body; |
243 | } | 288 | } |
244 | 289 | ||
245 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | ||
246 | { | ||
247 | char tmp[23]; | ||
248 | |||
249 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | ||
250 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
251 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | ||
252 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
253 | |||
254 | return QString( tmp ); | ||
255 | } | ||
256 | 290 | ||
257 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 291 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
258 | { | 292 | { |
259 | QString result( "" ); | 293 | QString result( "" ); |
260 | 294 | ||
261 | bool first = true; | 295 | bool first = true; |
262 | if (list == 0) return result; | 296 | if (list == 0) return result; |
263 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 297 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
264 | mailimf_address *addr = (mailimf_address *) current->data; | 298 | mailimf_address *addr = (mailimf_address *) current->data; |
265 | 299 | ||
266 | if ( !first ) { | 300 | if ( !first ) { |
267 | result.append( "," ); | 301 | result.append( "," ); |
268 | } else { | 302 | } else { |
269 | first = false; | 303 | first = false; |
270 | } | 304 | } |
271 | 305 | ||
272 | switch ( addr->ad_type ) { | 306 | switch ( addr->ad_type ) { |
273 | case MAILIMF_ADDRESS_MAILBOX: | 307 | case MAILIMF_ADDRESS_MAILBOX: |
274 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 308 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
275 | break; | 309 | break; |
276 | case MAILIMF_ADDRESS_GROUP: | 310 | case MAILIMF_ADDRESS_GROUP: |
277 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 311 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
278 | break; | 312 | break; |
279 | default: | 313 | default: |
280 | ; // odebug << "Generic: unkown mailimf address type" << oendl; | 314 | ; // odebug << "Generic: unkown mailimf address type" << oendl; |
281 | break; | 315 | break; |
282 | } | 316 | } |
283 | } | 317 | } |
284 | 318 | ||
285 | return result; | 319 | return result; |
286 | } | 320 | } |
287 | 321 | ||
288 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 322 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
289 | { | 323 | { |
290 | QString result( "" ); | 324 | QString result( "" ); |
291 | 325 | ||
292 | result.append( group->grp_display_name ); | 326 | result.append( group->grp_display_name ); |
293 | result.append( ": " ); | 327 | result.append( ": " ); |
294 | 328 | ||
295 | if ( group->grp_mb_list != NULL ) { | 329 | if ( group->grp_mb_list != NULL ) { |
296 | result.append( parseMailboxList( group->grp_mb_list ) ); | 330 | result.append( parseMailboxList( group->grp_mb_list ) ); |
297 | } | 331 | } |
298 | 332 | ||
299 | result.append( ";" ); | 333 | result.append( ";" ); |
300 | 334 | ||
301 | return result; | 335 | return result; |
302 | } | 336 | } |
303 | 337 | ||
304 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 338 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) |
305 | { | 339 | { |
306 | QString result( "" ); | 340 | QString result( "" ); |
307 | 341 | ||
308 | if ( box->mb_display_name == NULL ) { | 342 | if ( box->mb_display_name == NULL ) { |
309 | result.append( box->mb_addr_spec ); | 343 | result.append( box->mb_addr_spec ); |
310 | } else { | 344 | } else { |
311 | result.append( convert_String(box->mb_display_name).latin1() ); | 345 | result.append( convert_String(box->mb_display_name).latin1() ); |
312 | result.append( " <" ); | 346 | result.append( " <" ); |
313 | result.append( box->mb_addr_spec ); | 347 | result.append( box->mb_addr_spec ); |
314 | result.append( ">" ); | 348 | result.append( ">" ); |
315 | } | 349 | } |
316 | 350 | ||
317 | return result; | 351 | return result; |
318 | } | 352 | } |
319 | 353 | ||
320 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | 354 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) |
321 | { | 355 | { |
322 | QString result( "" ); | 356 | QString result( "" ); |
323 | 357 | ||
324 | bool first = true; | 358 | bool first = true; |
325 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { | 359 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { |
326 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; | 360 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; |
327 | 361 | ||
328 | if ( !first ) { | 362 | if ( !first ) { |
329 | result.append( "," ); | 363 | result.append( "," ); |
330 | } else { | 364 | } else { |
331 | first = false; | 365 | first = false; |
332 | } | 366 | } |
333 | 367 | ||
334 | result.append( parseMailbox( box ) ); | 368 | result.append( parseMailbox( box ) ); |
335 | } | 369 | } |
336 | 370 | ||
337 | return result; | 371 | return result; |
338 | } | 372 | } |
339 | 373 | ||
340 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) | 374 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) |
341 | { | 375 | { |
342 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 376 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
343 | if (it==bodyCache.end()) return new encodedString(); | 377 | if (it==bodyCache.end()) return new encodedString(); |
344 | encodedString*t = decode_String(it.data(),part->Encoding()); | 378 | encodedString*t = decode_String(it.data(),part->Encoding()); |
345 | return t; | 379 | return t; |
346 | } | 380 | } |
347 | 381 | ||
348 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) | 382 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) |
349 | { | 383 | { |
350 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 384 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
351 | if (it==bodyCache.end()) return new encodedString(); | 385 | if (it==bodyCache.end()) return new encodedString(); |
352 | encodedString*t = it.data(); | 386 | encodedString*t = it.data(); |
353 | return t; | 387 | return t; |
354 | } | 388 | } |
355 | 389 | ||
356 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 390 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
357 | { | 391 | { |
358 | encodedString*t = fetchDecodedPart(mail,part); | 392 | encodedString*t = fetchDecodedPart(mail,part); |
359 | QString text=t->Content(); | 393 | QString text=t->Content(); |
360 | delete t; | 394 | delete t; |
361 | return text; | 395 | return text; |
362 | } | 396 | } |
363 | 397 | ||
364 | void Genericwrapper::cleanMimeCache() | 398 | void Genericwrapper::cleanMimeCache() |
365 | { | 399 | { |
366 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); | 400 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); |
367 | for (;it!=bodyCache.end();++it) { | 401 | for (;it!=bodyCache.end();++it) { |
368 | encodedString*t = it.data(); | 402 | encodedString*t = it.data(); |
369 | //it.setValue(0); | 403 | //it.setValue(0); |
370 | if (t) delete t; | 404 | if (t) delete t; |
371 | } | 405 | } |
372 | bodyCache.clear(); | 406 | bodyCache.clear(); |
373 | ; // odebug << "Genericwrapper: cache cleaned" << oendl; | 407 | ; // odebug << "Genericwrapper: cache cleaned" << oendl; |
374 | } | 408 | } |
375 | 409 | ||
376 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | 410 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) |
377 | { | 411 | { |
378 | QStringList res; | 412 | QStringList res; |
379 | if (!in_replies || !in_replies->mid_list) return res; | 413 | if (!in_replies || !in_replies->mid_list) return res; |
380 | clistiter * current = 0; | 414 | clistiter * current = 0; |
381 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { | 415 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { |
382 | QString h((char*)current->data); | 416 | QString h((char*)current->data); |
383 | while (h.length()>0 && h[0]=='<') { | 417 | while (h.length()>0 && h[0]=='<') { |
384 | h.remove(0,1); | 418 | h.remove(0,1); |
385 | } | 419 | } |
386 | while (h.length()>0 && h[h.length()-1]=='>') { | 420 | while (h.length()>0 && h[h.length()-1]=='>') { |
387 | h.remove(h.length()-1,1); | 421 | h.remove(h.length()-1,1); |
388 | } | 422 | } |
389 | if (h.length()>0) { | 423 | if (h.length()>0) { |
390 | res.append(h); | 424 | res.append(h); |
391 | } | 425 | } |
392 | } | 426 | } |
393 | return res; | 427 | return res; |
394 | } | 428 | } |
395 | 429 | ||
396 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) | 430 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) |
397 | { | 431 | { |
398 | int r; | 432 | int r; |
399 | mailmessage_list * env_list = 0; | 433 | mailmessage_list * env_list = 0; |
400 | r = mailsession_get_messages_list(session,&env_list); | 434 | r = mailsession_get_messages_list(session,&env_list); |
401 | if (r != MAIL_NO_ERROR) { | 435 | if (r != MAIL_NO_ERROR) { |
402 | ; // odebug << "Error message list" << oendl; | 436 | ; // odebug << "Error message list" << oendl; |
403 | return; | 437 | return; |
404 | } | 438 | } |
405 | r = mailsession_get_envelopes_list(session, env_list); | 439 | r = mailsession_get_envelopes_list(session, env_list); |
406 | if (r != MAIL_NO_ERROR) { | 440 | if (r != MAIL_NO_ERROR) { |
407 | ; // odebug << "Error filling message list" << oendl; | 441 | ; // odebug << "Error filling message list" << oendl; |
408 | if (env_list) { | 442 | if (env_list) { |
409 | mailmessage_list_free(env_list); | 443 | mailmessage_list_free(env_list); |
410 | } | 444 | } |
411 | return; | 445 | return; |
412 | } | 446 | } |
413 | mailimf_references * refs = 0; | 447 | mailimf_references * refs = 0; |
414 | mailimf_in_reply_to * in_replies = 0; | 448 | mailimf_in_reply_to * in_replies = 0; |
415 | uint32_t i = 0; | 449 | uint32_t i = 0; |
416 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 450 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
417 | mailmessage * msg; | 451 | mailmessage * msg; |
418 | QBitArray mFlags(7); | 452 | QBitArray mFlags(7); |
419 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 453 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
420 | if (msg->msg_fields == NULL) { | 454 | if (msg->msg_fields == NULL) { |
421 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; | 455 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; |
422 | continue; | 456 | continue; |
423 | } | 457 | } |
424 | RecMailP mail = new RecMail(); | 458 | RecMailP mail = new RecMail(); |
425 | mail->setWrapper(this); | 459 | mail->setWrapper(this); |
426 | mail_flags * flag_result = 0; | 460 | mail_flags * flag_result = 0; |
427 | r = mailmessage_get_flags(msg,&flag_result); | 461 | r = mailmessage_get_flags(msg,&flag_result); |
428 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 462 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
429 | mFlags.setBit(FLAG_SEEN); | 463 | mFlags.setBit(FLAG_SEEN); |
430 | } | 464 | } |
431 | mailimf_single_fields single_fields; | 465 | mailimf_single_fields single_fields; |
432 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 466 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
433 | mail->setMsgsize(msg->msg_size); | 467 | mail->setMsgsize(msg->msg_size); |
434 | mail->setFlags(mFlags); | 468 | mail->setFlags(mFlags); |
435 | mail->setMbox(mailbox); | 469 | mail->setMbox(mailbox); |
436 | mail->setNumber(msg->msg_index); | 470 | mail->setNumber(msg->msg_index); |
437 | if (single_fields.fld_subject) | 471 | if (single_fields.fld_subject) |
438 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 472 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
439 | if (single_fields.fld_from) | 473 | if (single_fields.fld_from) |
440 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 474 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
441 | if (!mbox_as_to) { | 475 | if (!mbox_as_to) { |
442 | if (single_fields.fld_to) | 476 | if (single_fields.fld_to) |
443 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 477 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
444 | } else { | 478 | } else { |
445 | mail->setTo(mailbox); | 479 | mail->setTo(mailbox); |
446 | } | 480 | } |
447 | if (single_fields.fld_cc) | 481 | if (single_fields.fld_cc) |
448 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 482 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
449 | if (single_fields.fld_bcc) | 483 | if (single_fields.fld_bcc) |
450 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 484 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
451 | if (single_fields.fld_orig_date) | 485 | if (single_fields.fld_orig_date) { |
452 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 486 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); |
487 | char tmp[23]; | ||
488 | struct mailimf_date_time* date = single_fields.fld_orig_date->dt_date_time; | ||
489 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | ||
490 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
491 | mail->setIsoDate( QString( tmp ) ); | ||
492 | } | ||
453 | // crashes when accessing pop3 account? | 493 | // crashes when accessing pop3 account? |
454 | if (single_fields.fld_message_id) { | 494 | if (single_fields.fld_message_id) { |
455 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 495 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
456 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; | 496 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; |
457 | } | 497 | } |
458 | if (single_fields.fld_reply_to) { | 498 | if (single_fields.fld_reply_to) { |
459 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | 499 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); |
460 | if (t.count()>0) { | 500 | if (t.count()>0) { |
461 | mail->setReplyto(t[0]); | 501 | mail->setReplyto(t[0]); |
462 | } | 502 | } |
463 | } | 503 | } |
464 | #if 0 | 504 | #if 0 |
465 | refs = single_fields.fld_references; | 505 | refs = single_fields.fld_references; |
466 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 506 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
467 | char * text = (char*)refs->mid_list->first->data; | 507 | char * text = (char*)refs->mid_list->first->data; |
468 | mail->setReplyto(QString(text)); | 508 | mail->setReplyto(QString(text)); |
469 | } | 509 | } |
470 | #endif | 510 | #endif |
471 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && | 511 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && |
472 | clist_count(single_fields.fld_in_reply_to->mid_list)) { | 512 | clist_count(single_fields.fld_in_reply_to->mid_list)) { |
473 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); | 513 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); |
474 | } | 514 | } |
475 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) | 515 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) |
476 | target.append(mail); | 516 | target.append(mail); |
477 | } | 517 | } |
478 | if (env_list) { | 518 | if (env_list) { |
479 | mailmessage_list_free(env_list); | 519 | mailmessage_list_free(env_list); |
480 | } | 520 | } |
481 | } | 521 | } |
diff --git a/kmicromail/libmailwrapper/genericwrapper.h b/kmicromail/libmailwrapper/genericwrapper.h index 235e116..244212f 100644 --- a/kmicromail/libmailwrapper/genericwrapper.h +++ b/kmicromail/libmailwrapper/genericwrapper.h | |||
@@ -1,68 +1,68 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __GENERIC_WRAPPER_H | 2 | #ifndef __GENERIC_WRAPPER_H |
3 | #define __GENERIC_WRAPPER_H | 3 | #define __GENERIC_WRAPPER_H |
4 | 4 | ||
5 | #include "abstractmail.h" | 5 | #include "abstractmail.h" |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
9 | 9 | ||
10 | class RecMail; | 10 | class RecMail; |
11 | class RecBody; | 11 | class RecBody; |
12 | class encodedString; | 12 | class encodedString; |
13 | struct mailpop3; | 13 | struct mailpop3; |
14 | struct mailmessage; | 14 | struct mailmessage; |
15 | struct mailmime; | 15 | struct mailmime; |
16 | struct mailmime_mechanism; | 16 | struct mailmime_mechanism; |
17 | struct mailimf_mailbox_list; | 17 | struct mailimf_mailbox_list; |
18 | struct mailimf_mailbox; | 18 | struct mailimf_mailbox; |
19 | struct mailimf_date_time; | 19 | struct mailimf_date_time; |
20 | struct mailimf_group; | 20 | struct mailimf_group; |
21 | struct mailimf_address_list; | 21 | struct mailimf_address_list; |
22 | struct mailsession; | 22 | struct mailsession; |
23 | struct mailstorage; | 23 | struct mailstorage; |
24 | struct mailfolder; | 24 | struct mailfolder; |
25 | struct mailimf_in_reply_to; | 25 | struct mailimf_in_reply_to; |
26 | 26 | ||
27 | /* this class hold just the funs shared between | 27 | /* this class hold just the funs shared between |
28 | * mbox and pop3 (later mh, too) mail access. | 28 | * mbox and pop3 (later mh, too) mail access. |
29 | * it is not desigend to make a instance of it! | 29 | * it is not desigend to make a instance of it! |
30 | */ | 30 | */ |
31 | class Genericwrapper : public AbstractMail | 31 | class Genericwrapper : public AbstractMail |
32 | { | 32 | { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | public: | 34 | public: |
35 | Genericwrapper(); | 35 | Genericwrapper(); |
36 | virtual ~Genericwrapper(); | 36 | virtual ~Genericwrapper(); |
37 | 37 | ||
38 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); | 38 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); |
39 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); | 39 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); |
40 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); | 40 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); |
41 | virtual void cleanMimeCache(); | 41 | virtual void cleanMimeCache(); |
42 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} | 42 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} |
43 | virtual void logout(){}; | 43 | virtual void logout(){}; |
44 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; | 44 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; |
45 | static QString parseDateTime( mailimf_date_time *date ); | ||
45 | 46 | ||
46 | protected: | 47 | protected: |
47 | RecBodyP parseMail( mailmessage * msg ); | 48 | RecBodyP parseMail( mailmessage * msg ); |
48 | QString parseMailboxList( mailimf_mailbox_list *list ); | 49 | QString parseMailboxList( mailimf_mailbox_list *list ); |
49 | QString parseMailbox( mailimf_mailbox *box ); | 50 | QString parseMailbox( mailimf_mailbox *box ); |
50 | QString parseGroup( mailimf_group *group ); | 51 | QString parseGroup( mailimf_group *group ); |
51 | QString parseAddressList( mailimf_address_list *list ); | 52 | QString parseAddressList( mailimf_address_list *list ); |
52 | QString parseDateTime( mailimf_date_time *date ); | ||
53 | 53 | ||
54 | void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); | 54 | void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); |
55 | static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); | 55 | static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); |
56 | static void fillParameters(RecPartP&target,clist*parameters); | 56 | static void fillParameters(RecPartP&target,clist*parameters); |
57 | static QString getencoding(mailmime_mechanism*aEnc); | 57 | static QString getencoding(mailmime_mechanism*aEnc); |
58 | virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false, int maxSizeInKb = 0); | 58 | virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false, int maxSizeInKb = 0); |
59 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); | 59 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); |
60 | 60 | ||
61 | QString msgTempName; | 61 | QString msgTempName; |
62 | unsigned int last_msg_id; | 62 | unsigned int last_msg_id; |
63 | QMap<QString,encodedString*> bodyCache; | 63 | QMap<QString,encodedString*> bodyCache; |
64 | mailstorage * m_storage; | 64 | mailstorage * m_storage; |
65 | mailfolder*m_folder; | 65 | mailfolder*m_folder; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | #endif | 68 | #endif |
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 6faa524..5441a9b 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,201 +1,202 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | #include "genericwrapper.h" | ||
10 | 11 | ||
11 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
12 | int IMAPwrapper::mMax = 0; | 13 | int IMAPwrapper::mMax = 0; |
13 | int IMAPwrapper::mCurrent = 0; | 14 | int IMAPwrapper::mCurrent = 0; |
14 | 15 | ||
15 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 16 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
16 | : AbstractMail() | 17 | : AbstractMail() |
17 | { | 18 | { |
18 | account = a; | 19 | account = a; |
19 | m_imap = 0; | 20 | m_imap = 0; |
20 | m_Lastmbox = ""; | 21 | m_Lastmbox = ""; |
21 | mCurrent = 0; | 22 | mCurrent = 0; |
22 | mMax = 0; | 23 | mMax = 0; |
23 | } | 24 | } |
24 | 25 | ||
25 | IMAPwrapper::~IMAPwrapper() | 26 | IMAPwrapper::~IMAPwrapper() |
26 | { | 27 | { |
27 | logout(); | 28 | logout(); |
28 | } | 29 | } |
29 | 30 | ||
30 | /* to avoid to often select statements in loops etc. | 31 | /* to avoid to often select statements in loops etc. |
31 | we trust that we are logged in and connection is established!*/ | 32 | we trust that we are logged in and connection is established!*/ |
32 | int IMAPwrapper::selectMbox(const QString&mbox) | 33 | int IMAPwrapper::selectMbox(const QString&mbox) |
33 | { | 34 | { |
34 | if (mbox == m_Lastmbox) { | 35 | if (mbox == m_Lastmbox) { |
35 | return MAILIMAP_NO_ERROR; | 36 | return MAILIMAP_NO_ERROR; |
36 | } | 37 | } |
37 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 38 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
38 | if ( err != MAILIMAP_NO_ERROR ) { | 39 | if ( err != MAILIMAP_NO_ERROR ) { |
39 | m_Lastmbox = ""; | 40 | m_Lastmbox = ""; |
40 | return err; | 41 | return err; |
41 | } | 42 | } |
42 | m_Lastmbox = mbox; | 43 | m_Lastmbox = mbox; |
43 | return err; | 44 | return err; |
44 | } | 45 | } |
45 | 46 | ||
46 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 47 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
47 | { | 48 | { |
48 | //qDebug("imap progress %d of %d ",current,maximum ); | 49 | //qDebug("imap progress %d of %d ",current,maximum ); |
49 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); | 50 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); |
50 | //qApp->processEvents() | 51 | //qApp->processEvents() |
51 | static int last = 0; | 52 | static int last = 0; |
52 | if ( last != current ) | 53 | if ( last != current ) |
53 | IMAPwrapper::progress(); | 54 | IMAPwrapper::progress(); |
54 | last = current; | 55 | last = current; |
55 | } | 56 | } |
56 | void IMAPwrapper::progress( QString m ) | 57 | void IMAPwrapper::progress( QString m ) |
57 | { | 58 | { |
58 | 59 | ||
59 | static QString mProgrMess; | 60 | static QString mProgrMess; |
60 | if ( m != QString::null ) { | 61 | if ( m != QString::null ) { |
61 | mProgrMess = m; | 62 | mProgrMess = m; |
62 | mCurrent = 0; | 63 | mCurrent = 0; |
63 | return; | 64 | return; |
64 | } | 65 | } |
65 | QString mess; | 66 | QString mess; |
66 | //qDebug("progress "); | 67 | //qDebug("progress "); |
67 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); | 68 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); |
68 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); | 69 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); |
69 | Global::statusMessage(mess); | 70 | Global::statusMessage(mess); |
70 | qApp->processEvents(); | 71 | qApp->processEvents(); |
71 | } | 72 | } |
72 | bool IMAPwrapper::start_tls(bool force_tls) | 73 | bool IMAPwrapper::start_tls(bool force_tls) |
73 | { | 74 | { |
74 | int err; | 75 | int err; |
75 | bool try_tls; | 76 | bool try_tls; |
76 | mailimap_capability_data * cap_data = 0; | 77 | mailimap_capability_data * cap_data = 0; |
77 | 78 | ||
78 | err = mailimap_capability(m_imap,&cap_data); | 79 | err = mailimap_capability(m_imap,&cap_data); |
79 | if (err != MAILIMAP_NO_ERROR) { | 80 | if (err != MAILIMAP_NO_ERROR) { |
80 | Global::statusMessage("error getting capabilities!"); | 81 | Global::statusMessage("error getting capabilities!"); |
81 | return false; | 82 | return false; |
82 | } | 83 | } |
83 | clistiter * cur; | 84 | clistiter * cur; |
84 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 85 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
85 | struct mailimap_capability * cap; | 86 | struct mailimap_capability * cap; |
86 | cap = (struct mailimap_capability *)clist_content(cur); | 87 | cap = (struct mailimap_capability *)clist_content(cur); |
87 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 88 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
88 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 89 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
89 | try_tls = true; | 90 | try_tls = true; |
90 | break; | 91 | break; |
91 | } | 92 | } |
92 | } | 93 | } |
93 | } | 94 | } |
94 | if (cap_data) { | 95 | if (cap_data) { |
95 | mailimap_capability_data_free(cap_data); | 96 | mailimap_capability_data_free(cap_data); |
96 | } | 97 | } |
97 | if (try_tls) { | 98 | if (try_tls) { |
98 | err = mailimap_starttls(m_imap); | 99 | err = mailimap_starttls(m_imap); |
99 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 100 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
100 | Global::statusMessage(tr("Server has no TLS support!")); | 101 | Global::statusMessage(tr("Server has no TLS support!")); |
101 | try_tls = false; | 102 | try_tls = false; |
102 | } else { | 103 | } else { |
103 | mailstream_low * low; | 104 | mailstream_low * low; |
104 | mailstream_low * new_low; | 105 | mailstream_low * new_low; |
105 | low = mailstream_get_low(m_imap->imap_stream); | 106 | low = mailstream_get_low(m_imap->imap_stream); |
106 | if (!low) { | 107 | if (!low) { |
107 | try_tls = false; | 108 | try_tls = false; |
108 | } else { | 109 | } else { |
109 | int fd = mailstream_low_get_fd(low); | 110 | int fd = mailstream_low_get_fd(low); |
110 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 111 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
111 | mailstream_low_free(low); | 112 | mailstream_low_free(low); |
112 | mailstream_set_low(m_imap->imap_stream, new_low); | 113 | mailstream_set_low(m_imap->imap_stream, new_low); |
113 | } else { | 114 | } else { |
114 | try_tls = false; | 115 | try_tls = false; |
115 | } | 116 | } |
116 | } | 117 | } |
117 | } | 118 | } |
118 | } | 119 | } |
119 | return try_tls; | 120 | return try_tls; |
120 | } | 121 | } |
121 | 122 | ||
122 | void IMAPwrapper::login() | 123 | void IMAPwrapper::login() |
123 | { | 124 | { |
124 | QString server, user, pass; | 125 | QString server, user, pass; |
125 | uint16_t port; | 126 | uint16_t port; |
126 | int err = MAILIMAP_NO_ERROR; | 127 | int err = MAILIMAP_NO_ERROR; |
127 | 128 | ||
128 | if (account->getOffline()) return; | 129 | if (account->getOffline()) return; |
129 | /* we are connected this moment */ | 130 | /* we are connected this moment */ |
130 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 131 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
131 | if (m_imap) { | 132 | if (m_imap) { |
132 | err = mailimap_noop(m_imap); | 133 | err = mailimap_noop(m_imap); |
133 | if (err!=MAILIMAP_NO_ERROR) { | 134 | if (err!=MAILIMAP_NO_ERROR) { |
134 | logout(); | 135 | logout(); |
135 | } else { | 136 | } else { |
136 | mailstream_flush(m_imap->imap_stream); | 137 | mailstream_flush(m_imap->imap_stream); |
137 | return; | 138 | return; |
138 | } | 139 | } |
139 | } | 140 | } |
140 | server = account->getServer(); | 141 | server = account->getServer(); |
141 | port = account->getPort().toUInt(); | 142 | port = account->getPort().toUInt(); |
142 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 143 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
143 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 144 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
144 | login.show(); | 145 | login.show(); |
145 | if ( QDialog::Accepted == login.exec() ) { | 146 | if ( QDialog::Accepted == login.exec() ) { |
146 | // ok | 147 | // ok |
147 | user = login.getUser(); | 148 | user = login.getUser(); |
148 | pass = login.getPassword(); | 149 | pass = login.getPassword(); |
149 | } else { | 150 | } else { |
150 | // cancel | 151 | // cancel |
151 | return; | 152 | return; |
152 | } | 153 | } |
153 | } else { | 154 | } else { |
154 | user = account->getUser(); | 155 | user = account->getUser(); |
155 | pass = account->getPassword(); | 156 | pass = account->getPassword(); |
156 | } | 157 | } |
157 | 158 | ||
158 | m_imap = mailimap_new( 20, &imap_progress ); | 159 | m_imap = mailimap_new( 20, &imap_progress ); |
159 | 160 | ||
160 | /* connect */ | 161 | /* connect */ |
161 | bool ssl = false; | 162 | bool ssl = false; |
162 | bool try_tls = false; | 163 | bool try_tls = false; |
163 | bool force_tls = false; | 164 | bool force_tls = false; |
164 | 165 | ||
165 | if ( account->ConnectionType() == 2 ) { | 166 | if ( account->ConnectionType() == 2 ) { |
166 | ssl = true; | 167 | ssl = true; |
167 | } | 168 | } |
168 | if (account->ConnectionType()==1) { | 169 | if (account->ConnectionType()==1) { |
169 | force_tls = true; | 170 | force_tls = true; |
170 | } | 171 | } |
171 | 172 | ||
172 | if ( ssl ) { | 173 | if ( ssl ) { |
173 | qDebug("using ssl "); | 174 | qDebug("using ssl "); |
174 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); | 175 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); |
175 | } else { | 176 | } else { |
176 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); | 177 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); |
177 | } | 178 | } |
178 | 179 | ||
179 | if ( err != MAILIMAP_NO_ERROR && | 180 | if ( err != MAILIMAP_NO_ERROR && |
180 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 181 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
181 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 182 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
182 | QString failure = ""; | 183 | QString failure = ""; |
183 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 184 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
184 | failure="Connection refused"; | 185 | failure="Connection refused"; |
185 | } else { | 186 | } else { |
186 | failure="Unknown failure"; | 187 | failure="Unknown failure"; |
187 | } | 188 | } |
188 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); | 189 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); |
189 | mailimap_free( m_imap ); | 190 | mailimap_free( m_imap ); |
190 | m_imap = 0; | 191 | m_imap = 0; |
191 | return; | 192 | return; |
192 | } | 193 | } |
193 | 194 | ||
194 | if (!ssl) { | 195 | if (!ssl) { |
195 | try_tls = start_tls(force_tls); | 196 | try_tls = start_tls(force_tls); |
196 | } | 197 | } |
197 | 198 | ||
198 | bool ok = true; | 199 | bool ok = true; |
199 | if (force_tls && !try_tls) { | 200 | if (force_tls && !try_tls) { |
200 | Global::statusMessage(tr("Server has no TLS support!")); | 201 | Global::statusMessage(tr("Server has no TLS support!")); |
201 | ok = false; | 202 | ok = false; |
@@ -267,386 +268,401 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma | |||
267 | 268 | ||
268 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 269 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
269 | mailimap_set_free( set ); | 270 | mailimap_set_free( set ); |
270 | mailimap_fetch_type_free( fetchType ); | 271 | mailimap_fetch_type_free( fetchType ); |
271 | 272 | ||
272 | QString date,subject,from; | 273 | QString date,subject,from; |
273 | 274 | ||
274 | if ( err == MAILIMAP_NO_ERROR ) { | 275 | if ( err == MAILIMAP_NO_ERROR ) { |
275 | mailimap_msg_att * msg_att; | 276 | mailimap_msg_att * msg_att; |
276 | int i = 0; | 277 | int i = 0; |
277 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 278 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
278 | ++i; | 279 | ++i; |
279 | msg_att = (mailimap_msg_att*)current->data; | 280 | msg_att = (mailimap_msg_att*)current->data; |
280 | RecMail*m = parse_list_result(msg_att); | 281 | RecMail*m = parse_list_result(msg_att); |
281 | if (m) { | 282 | if (m) { |
282 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { | 283 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { |
283 | m->setNumber(i); | 284 | m->setNumber(i); |
284 | m->setMbox(mailbox); | 285 | m->setMbox(mailbox); |
285 | m->setWrapper(this); | 286 | m->setWrapper(this); |
286 | target.append(m); | 287 | target.append(m); |
287 | } | 288 | } |
288 | } | 289 | } |
289 | } | 290 | } |
290 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 291 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); |
291 | } else { | 292 | } else { |
292 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 293 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
293 | } | 294 | } |
294 | if (result) mailimap_fetch_list_free(result); | 295 | if (result) mailimap_fetch_list_free(result); |
295 | } | 296 | } |
296 | 297 | ||
297 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 298 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
298 | { | 299 | { |
299 | const char *path, *mask; | 300 | const char *path, *mask; |
300 | int err = MAILIMAP_NO_ERROR; | 301 | int err = MAILIMAP_NO_ERROR; |
301 | clist *result = 0; | 302 | clist *result = 0; |
302 | clistcell *current = 0; | 303 | clistcell *current = 0; |
303 | clistcell*cur_flag = 0; | 304 | clistcell*cur_flag = 0; |
304 | mailimap_mbx_list_flags*bflags = 0; | 305 | mailimap_mbx_list_flags*bflags = 0; |
305 | 306 | ||
306 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 307 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
307 | login(); | 308 | login(); |
308 | if (!m_imap) { | 309 | if (!m_imap) { |
309 | return folders; | 310 | return folders; |
310 | } | 311 | } |
311 | 312 | ||
312 | /* | 313 | /* |
313 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 314 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
314 | * We must not forget to filter them out in next loop! | 315 | * We must not forget to filter them out in next loop! |
315 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 316 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
316 | */ | 317 | */ |
317 | Global::statusMessage(tr("Fetching folder list")); | 318 | Global::statusMessage(tr("Fetching folder list")); |
318 | qApp->processEvents(); | 319 | qApp->processEvents(); |
319 | QString temp; | 320 | QString temp; |
320 | mask = "INBOX" ; | 321 | mask = "INBOX" ; |
321 | mailimap_mailbox_list *list; | 322 | mailimap_mailbox_list *list; |
322 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 323 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
323 | QString del; | 324 | QString del; |
324 | bool selectable = true; | 325 | bool selectable = true; |
325 | bool no_inferiors = false; | 326 | bool no_inferiors = false; |
326 | if ( err == MAILIMAP_NO_ERROR ) { | 327 | if ( err == MAILIMAP_NO_ERROR ) { |
327 | current = result->first; | 328 | current = result->first; |
328 | for ( int i = result->count; i > 0; i-- ) { | 329 | for ( int i = result->count; i > 0; i-- ) { |
329 | list = (mailimap_mailbox_list *) current->data; | 330 | list = (mailimap_mailbox_list *) current->data; |
330 | // it is better use the deep copy mechanism of qt itself | 331 | // it is better use the deep copy mechanism of qt itself |
331 | // instead of using strdup! | 332 | // instead of using strdup! |
332 | temp = list->mb_name; | 333 | temp = list->mb_name; |
333 | del = list->mb_delimiter; | 334 | del = list->mb_delimiter; |
334 | current = current->next; | 335 | current = current->next; |
335 | if ( (bflags = list->mb_flag) ) { | 336 | if ( (bflags = list->mb_flag) ) { |
336 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 337 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
337 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 338 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
338 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 339 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
339 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 340 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
340 | no_inferiors = true; | 341 | no_inferiors = true; |
341 | } | 342 | } |
342 | } | 343 | } |
343 | } | 344 | } |
344 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 345 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
345 | } | 346 | } |
346 | } else { | 347 | } else { |
347 | qDebug("error fetching folders: "); | 348 | qDebug("error fetching folders: "); |
348 | 349 | ||
349 | } | 350 | } |
350 | mailimap_list_result_free( result ); | 351 | mailimap_list_result_free( result ); |
351 | 352 | ||
352 | /* | 353 | /* |
353 | * second stage - get the other then inbox folders | 354 | * second stage - get the other then inbox folders |
354 | */ | 355 | */ |
355 | mask = "*" ; | 356 | mask = "*" ; |
356 | path = account->getPrefix().latin1(); | 357 | path = account->getPrefix().latin1(); |
357 | if (!path) path = ""; | 358 | if (!path) path = ""; |
358 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 359 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
359 | if ( err == MAILIMAP_NO_ERROR ) { | 360 | if ( err == MAILIMAP_NO_ERROR ) { |
360 | current = result->first; | 361 | current = result->first; |
361 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 362 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
362 | no_inferiors = false; | 363 | no_inferiors = false; |
363 | list = (mailimap_mailbox_list *) current->data; | 364 | list = (mailimap_mailbox_list *) current->data; |
364 | // it is better use the deep copy mechanism of qt itself | 365 | // it is better use the deep copy mechanism of qt itself |
365 | // instead of using strdup! | 366 | // instead of using strdup! |
366 | temp = list->mb_name; | 367 | temp = list->mb_name; |
367 | if (temp.lower()=="inbox") | 368 | if (temp.lower()=="inbox") |
368 | continue; | 369 | continue; |
369 | if (temp.lower()==account->getPrefix().lower()) | 370 | if (temp.lower()==account->getPrefix().lower()) |
370 | continue; | 371 | continue; |
371 | if ( (bflags = list->mb_flag) ) { | 372 | if ( (bflags = list->mb_flag) ) { |
372 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 373 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
373 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 374 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
374 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 375 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
375 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 376 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
376 | no_inferiors = true; | 377 | no_inferiors = true; |
377 | } | 378 | } |
378 | } | 379 | } |
379 | } | 380 | } |
380 | del = list->mb_delimiter; | 381 | del = list->mb_delimiter; |
381 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 382 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
382 | } | 383 | } |
383 | } else { | 384 | } else { |
384 | qDebug("error fetching folders "); | 385 | qDebug("error fetching folders "); |
385 | 386 | ||
386 | } | 387 | } |
387 | if (result) mailimap_list_result_free( result ); | 388 | if (result) mailimap_list_result_free( result ); |
388 | return folders; | 389 | return folders; |
389 | } | 390 | } |
390 | 391 | ||
391 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 392 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
392 | { | 393 | { |
393 | RecMail * m = 0; | 394 | RecMail * m = 0; |
394 | mailimap_msg_att_item *item=0; | 395 | mailimap_msg_att_item *item=0; |
395 | clistcell *current,*c,*cf; | 396 | clistcell *current,*c,*cf; |
396 | mailimap_msg_att_dynamic*flist; | 397 | mailimap_msg_att_dynamic*flist; |
397 | mailimap_flag_fetch*cflag; | 398 | mailimap_flag_fetch*cflag; |
398 | int size; | 399 | int size; |
399 | QBitArray mFlags(7); | 400 | QBitArray mFlags(7); |
400 | QStringList addresslist; | 401 | QStringList addresslist; |
401 | 402 | ||
402 | if (!m_att) { | 403 | if (!m_att) { |
403 | return m; | 404 | return m; |
404 | } | 405 | } |
405 | m = new RecMail(); | 406 | m = new RecMail(); |
406 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 407 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
407 | current = c; | 408 | current = c; |
408 | size = 0; | 409 | size = 0; |
409 | item = (mailimap_msg_att_item*)current->data; | 410 | item = (mailimap_msg_att_item*)current->data; |
410 | if ( !item ) | 411 | if ( !item ) |
411 | continue; | 412 | continue; |
412 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 413 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
413 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 414 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
414 | if (!flist || !flist->att_list) { | 415 | if (!flist || !flist->att_list) { |
415 | continue; | 416 | continue; |
416 | } | 417 | } |
417 | cf = flist->att_list->first; | 418 | cf = flist->att_list->first; |
418 | if( ! cf ) | 419 | if( ! cf ) |
419 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 420 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
420 | cflag = (mailimap_flag_fetch*)cf->data; | 421 | cflag = (mailimap_flag_fetch*)cf->data; |
421 | if( ! cflag ) | 422 | if( ! cflag ) |
422 | qDebug("imap:not cflag "); | 423 | qDebug("imap:not cflag "); |
423 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 424 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
424 | switch (cflag->fl_flag->fl_type) { | 425 | switch (cflag->fl_flag->fl_type) { |
425 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 426 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
426 | mFlags.setBit(FLAG_ANSWERED); | 427 | mFlags.setBit(FLAG_ANSWERED); |
427 | break; | 428 | break; |
428 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 429 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
429 | mFlags.setBit(FLAG_FLAGGED); | 430 | mFlags.setBit(FLAG_FLAGGED); |
430 | break; | 431 | break; |
431 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 432 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
432 | mFlags.setBit(FLAG_DELETED); | 433 | mFlags.setBit(FLAG_DELETED); |
433 | break; | 434 | break; |
434 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 435 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
435 | mFlags.setBit(FLAG_SEEN); | 436 | mFlags.setBit(FLAG_SEEN); |
436 | break; | 437 | break; |
437 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 438 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
438 | mFlags.setBit(FLAG_DRAFT); | 439 | mFlags.setBit(FLAG_DRAFT); |
439 | break; | 440 | break; |
440 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 441 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
441 | break; | 442 | break; |
442 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 443 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
443 | break; | 444 | break; |
444 | default: | 445 | default: |
445 | break; | 446 | break; |
446 | } | 447 | } |
447 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 448 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
448 | mFlags.setBit(FLAG_RECENT); | 449 | mFlags.setBit(FLAG_RECENT); |
449 | } | 450 | } |
450 | } | 451 | } |
451 | continue; | 452 | continue; |
452 | } | 453 | } |
453 | if ( item->att_data.att_static == NULL ) | 454 | if ( item->att_data.att_static == NULL ) |
454 | continue; | 455 | continue; |
455 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 456 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
456 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 457 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
457 | if ( head == NULL ) | 458 | if ( head == NULL ) |
458 | continue; | 459 | continue; |
459 | if ( head->env_date != NULL ) | 460 | if ( head->env_date != NULL ) { |
460 | m->setDate(head->env_date); | 461 | m->setDate(head->env_date); |
462 | struct mailimf_date_time result; | ||
463 | struct mailimf_date_time* date = &result; | ||
464 | struct mailimf_date_time **re = &date; | ||
465 | size_t length = m->getDate().length(); | ||
466 | size_t index = 0; | ||
467 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | ||
468 | m->setDate( Genericwrapper::parseDateTime( date ) ); | ||
469 | char tmp[23]; | ||
470 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | ||
471 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
472 | m->setIsoDate( QString( tmp ) ); | ||
473 | } else { | ||
474 | m->setIsoDate(head->env_date); | ||
475 | } | ||
476 | } | ||
461 | if ( head->env_subject != NULL ) | 477 | if ( head->env_subject != NULL ) |
462 | m->setSubject(convert_String((const char*)head->env_subject)); | 478 | m->setSubject(convert_String((const char*)head->env_subject)); |
463 | //m->setSubject(head->env_subject); | 479 | //m->setSubject(head->env_subject); |
464 | if (head->env_from!=NULL) { | 480 | if (head->env_from!=NULL) { |
465 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 481 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
466 | if (addresslist.count()) { | 482 | if (addresslist.count()) { |
467 | m->setFrom(addresslist.first()); | 483 | m->setFrom(addresslist.first()); |
468 | } | 484 | } |
469 | } | 485 | } |
470 | if (head->env_to!=NULL) { | 486 | if (head->env_to!=NULL) { |
471 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 487 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
472 | m->setTo(addresslist); | 488 | m->setTo(addresslist); |
473 | } | 489 | } |
474 | if (head->env_cc!=NULL) { | 490 | if (head->env_cc!=NULL) { |
475 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 491 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
476 | m->setCC(addresslist); | 492 | m->setCC(addresslist); |
477 | } | 493 | } |
478 | if (head->env_bcc!=NULL) { | 494 | if (head->env_bcc!=NULL) { |
479 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 495 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
480 | m->setBcc(addresslist); | 496 | m->setBcc(addresslist); |
481 | } | 497 | } |
482 | /* reply to address, eg. email. */ | 498 | /* reply to address, eg. email. */ |
483 | if (head->env_reply_to!=NULL) { | 499 | if (head->env_reply_to!=NULL) { |
484 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 500 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
485 | if (addresslist.count()) { | 501 | if (addresslist.count()) { |
486 | m->setReplyto(addresslist.first()); | 502 | m->setReplyto(addresslist.first()); |
487 | } | 503 | } |
488 | } | 504 | } |
489 | if (head->env_in_reply_to!=NULL) { | 505 | if (head->env_in_reply_to!=NULL) { |
490 | QString h(head->env_in_reply_to); | 506 | QString h(head->env_in_reply_to); |
491 | while (h.length()>0 && h[0]=='<') { | 507 | while (h.length()>0 && h[0]=='<') { |
492 | h.remove(0,1); | 508 | h.remove(0,1); |
493 | } | 509 | } |
494 | while (h.length()>0 && h[h.length()-1]=='>') { | 510 | while (h.length()>0 && h[h.length()-1]=='>') { |
495 | h.remove(h.length()-1,1); | 511 | h.remove(h.length()-1,1); |
496 | } | 512 | } |
497 | if (h.length()>0) { | 513 | if (h.length()>0) { |
498 | m->setInreply(QStringList(h)); | 514 | m->setInreply(QStringList(h)); |
499 | } | 515 | } |
500 | } | 516 | } |
501 | if (head->env_message_id != NULL) { | 517 | if (head->env_message_id != NULL) { |
502 | m->setMsgid(QString(head->env_message_id)); | 518 | m->setMsgid(QString(head->env_message_id)); |
503 | } | 519 | } |
504 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 520 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
505 | #if 0 | 521 | #if 0 |
506 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 522 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
507 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 523 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
508 | qDebug("time %s ",da.toString().latin1() ); | 524 | qDebug("time %s ",da.toString().latin1() ); |
509 | #endif | 525 | #endif |
510 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 526 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
511 | size = item->att_data.att_static->att_data.att_rfc822_size; | 527 | size = item->att_data.att_static->att_data.att_rfc822_size; |
512 | } | 528 | } |
513 | } | 529 | } |
514 | /* msg is already deleted */ | 530 | /* msg is already deleted */ |
515 | if (mFlags.testBit(FLAG_DELETED) && m) { | 531 | if (mFlags.testBit(FLAG_DELETED) && m) { |
516 | delete m; | 532 | delete m; |
517 | m = 0; | 533 | m = 0; |
518 | } | 534 | } |
519 | if (m) { | 535 | if (m) { |
520 | m->setFlags(mFlags); | 536 | m->setFlags(mFlags); |
521 | m->setMsgsize(size); | 537 | m->setMsgsize(size); |
522 | } | 538 | } |
523 | return m; | 539 | return m; |
524 | } | 540 | } |
525 | 541 | ||
526 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 542 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
527 | { | 543 | { |
528 | RecBodyP body = new RecBody(); | 544 | RecBodyP body = new RecBody(); |
529 | const char *mb; | 545 | const char *mb; |
530 | int err = MAILIMAP_NO_ERROR; | 546 | int err = MAILIMAP_NO_ERROR; |
531 | clist *result = 0; | 547 | clist *result = 0; |
532 | clistcell *current; | 548 | clistcell *current; |
533 | mailimap_fetch_att *fetchAtt = 0; | 549 | mailimap_fetch_att *fetchAtt = 0; |
534 | mailimap_fetch_type *fetchType = 0; | 550 | mailimap_fetch_type *fetchType = 0; |
535 | mailimap_set *set = 0; | 551 | mailimap_set *set = 0; |
536 | mailimap_body*body_desc = 0; | 552 | mailimap_body*body_desc = 0; |
537 | 553 | ||
538 | mb = mail->getMbox().latin1(); | 554 | mb = mail->getMbox().latin1(); |
539 | 555 | ||
540 | login(); | 556 | login(); |
541 | if (!m_imap) { | 557 | if (!m_imap) { |
542 | return body; | 558 | return body; |
543 | } | 559 | } |
544 | err = selectMbox(mail->getMbox()); | 560 | err = selectMbox(mail->getMbox()); |
545 | if ( err != MAILIMAP_NO_ERROR ) { | 561 | if ( err != MAILIMAP_NO_ERROR ) { |
546 | return body; | 562 | return body; |
547 | } | 563 | } |
548 | 564 | ||
549 | /* the range has to start at 1!!! not with 0!!!! */ | 565 | /* the range has to start at 1!!! not with 0!!!! */ |
550 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 566 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
551 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 567 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
552 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 568 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
553 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 569 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
554 | mailimap_set_free( set ); | 570 | mailimap_set_free( set ); |
555 | mailimap_fetch_type_free( fetchType ); | 571 | mailimap_fetch_type_free( fetchType ); |
556 | 572 | ||
557 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 573 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
558 | mailimap_msg_att * msg_att; | 574 | mailimap_msg_att * msg_att; |
559 | msg_att = (mailimap_msg_att*)current->data; | 575 | msg_att = (mailimap_msg_att*)current->data; |
560 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 576 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
561 | QValueList<int> path; | 577 | QValueList<int> path; |
562 | body_desc = item->att_data.att_static->att_data.att_body; | 578 | body_desc = item->att_data.att_static->att_data.att_body; |
563 | traverseBody(mail,body_desc,body,0,path); | 579 | traverseBody(mail,body_desc,body,0,path); |
564 | } else { | 580 | } else { |
565 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 581 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; |
566 | } | 582 | } |
567 | if (result) mailimap_fetch_list_free(result); | 583 | if (result) mailimap_fetch_list_free(result); |
568 | return body; | 584 | return body; |
569 | } | 585 | } |
570 | 586 | ||
571 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 587 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
572 | { | 588 | { |
573 | QStringList l; | 589 | QStringList l; |
574 | QString from; | 590 | QString from; |
575 | bool named_from; | 591 | bool named_from; |
576 | clistcell *current = NULL; | 592 | clistcell *current = NULL; |
577 | mailimap_address * current_address=NULL; | 593 | mailimap_address * current_address=NULL; |
578 | if (!list) { | 594 | if (!list) { |
579 | return l; | 595 | return l; |
580 | } | 596 | } |
581 | unsigned int count = 0; | 597 | unsigned int count = 0; |
582 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 598 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
583 | from = ""; | 599 | from = ""; |
584 | named_from = false; | 600 | named_from = false; |
585 | current_address=(mailimap_address*)current->data; | 601 | current_address=(mailimap_address*)current->data; |
586 | if (current_address->ad_personal_name){ | 602 | if (current_address->ad_personal_name){ |
587 | from+=convert_String((const char*)current_address->ad_personal_name); | 603 | from+=convert_String((const char*)current_address->ad_personal_name); |
588 | from+=" "; | 604 | from+=" "; |
589 | named_from = true; | 605 | named_from = true; |
590 | } | 606 | } |
591 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 607 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
592 | from+="<"; | 608 | from+="<"; |
593 | } | 609 | } |
594 | if (current_address->ad_mailbox_name) { | 610 | if (current_address->ad_mailbox_name) { |
595 | from+=QString(current_address->ad_mailbox_name); | 611 | from+=QString(current_address->ad_mailbox_name); |
596 | from+="@"; | 612 | from+="@"; |
597 | } | 613 | } |
598 | if (current_address->ad_host_name) { | 614 | if (current_address->ad_host_name) { |
599 | from+=QString(current_address->ad_host_name); | 615 | from+=QString(current_address->ad_host_name); |
600 | } | 616 | } |
601 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 617 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
602 | from+=">"; | 618 | from+=">"; |
603 | } | 619 | } |
604 | l.append(QString(from)); | 620 | l.append(QString(from)); |
605 | if (++count > 99) { | 621 | if (++count > 99) { |
606 | break; | 622 | break; |
607 | } | 623 | } |
608 | } | 624 | } |
609 | return l; | 625 | return l; |
610 | } | 626 | } |
611 | 627 | ||
612 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) | 628 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
613 | { | 629 | { |
614 | encodedString*res=new encodedString; | 630 | encodedString*res=new encodedString; |
615 | int err; | 631 | int err; |
616 | mailimap_fetch_type *fetchType; | 632 | mailimap_fetch_type *fetchType; |
617 | mailimap_set *set; | 633 | mailimap_set *set; |
618 | clistcell*current,*cur; | 634 | clistcell*current,*cur; |
619 | mailimap_section_part * section_part = 0; | 635 | mailimap_section_part * section_part = 0; |
620 | mailimap_section_spec * section_spec = 0; | 636 | mailimap_section_spec * section_spec = 0; |
621 | mailimap_section * section = 0; | 637 | mailimap_section * section = 0; |
622 | mailimap_fetch_att * fetch_att = 0; | 638 | mailimap_fetch_att * fetch_att = 0; |
623 | 639 | ||
624 | login(); | 640 | login(); |
625 | if (!m_imap) { | 641 | if (!m_imap) { |
626 | return res; | 642 | return res; |
627 | } | 643 | } |
628 | if (!internal_call) { | 644 | if (!internal_call) { |
629 | err = selectMbox(mail->getMbox()); | 645 | err = selectMbox(mail->getMbox()); |
630 | if ( err != MAILIMAP_NO_ERROR ) { | 646 | if ( err != MAILIMAP_NO_ERROR ) { |
631 | return res; | 647 | return res; |
632 | } | 648 | } |
633 | } | 649 | } |
634 | set = mailimap_set_new_single(mail->getNumber()); | 650 | set = mailimap_set_new_single(mail->getNumber()); |
635 | 651 | ||
636 | clist*id_list = 0; | 652 | clist*id_list = 0; |
637 | 653 | ||
638 | /* if path == empty then its a request for the whole rfc822 mail and generates | 654 | /* if path == empty then its a request for the whole rfc822 mail and generates |
639 | a "fetch <id> (body[])" statement on imap server */ | 655 | a "fetch <id> (body[])" statement on imap server */ |
640 | if (path.count()>0 ) { | 656 | if (path.count()>0 ) { |
641 | id_list = clist_new(); | 657 | id_list = clist_new(); |
642 | for (unsigned j=0; j < path.count();++j) { | 658 | for (unsigned j=0; j < path.count();++j) { |
643 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 659 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
644 | *p_id = path[j]; | 660 | *p_id = path[j]; |
645 | clist_append(id_list,p_id); | 661 | clist_append(id_list,p_id); |
646 | } | 662 | } |
647 | section_part = mailimap_section_part_new(id_list); | 663 | section_part = mailimap_section_part_new(id_list); |
648 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 664 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
649 | } | 665 | } |
650 | 666 | ||
651 | section = mailimap_section_new(section_spec); | 667 | section = mailimap_section_new(section_spec); |
652 | fetch_att = mailimap_fetch_att_new_body_section(section); | 668 | fetch_att = mailimap_fetch_att_new_body_section(section); |
diff --git a/kmicromail/libmailwrapper/imapwrapper.h b/kmicromail/libmailwrapper/imapwrapper.h index db8ab5b..5535d8d 100644 --- a/kmicromail/libmailwrapper/imapwrapper.h +++ b/kmicromail/libmailwrapper/imapwrapper.h | |||
@@ -1,84 +1,85 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __IMAPWRAPPER | 2 | #ifndef __IMAPWRAPPER |
3 | #define __IMAPWRAPPER | 3 | #define __IMAPWRAPPER |
4 | 4 | ||
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include "mailwrapper.h" | 6 | #include "mailwrapper.h" |
7 | #include "abstractmail.h" | 7 | #include "abstractmail.h" |
8 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
9 | 9 | ||
10 | struct mailimap; | 10 | struct mailimap; |
11 | struct mailimap_body; | 11 | struct mailimap_body; |
12 | struct mailimap_body_type_1part; | 12 | struct mailimap_body_type_1part; |
13 | struct mailimap_body_type_text; | 13 | struct mailimap_body_type_text; |
14 | struct mailimap_body_type_basic; | 14 | struct mailimap_body_type_basic; |
15 | struct mailimap_body_type_msg; | 15 | struct mailimap_body_type_msg; |
16 | struct mailimap_body_type_mpart; | 16 | struct mailimap_body_type_mpart; |
17 | struct mailimap_body_fields; | 17 | struct mailimap_body_fields; |
18 | struct mailimap_msg_att; | 18 | struct mailimap_msg_att; |
19 | class encodedString; | 19 | class encodedString; |
20 | 20 | ||
21 | class IMAPwrapper : public AbstractMail | 21 | class IMAPwrapper : public AbstractMail |
22 | { | 22 | { |
23 | Q_OBJECT | 23 | Q_OBJECT |
24 | public: | 24 | public: |
25 | IMAPwrapper( IMAPaccount *a ); | 25 | IMAPwrapper( IMAPaccount *a ); |
26 | virtual ~IMAPwrapper(); | 26 | virtual ~IMAPwrapper(); |
27 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 27 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
28 | virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target , int sizeInKb = 0); | 28 | virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target , int sizeInKb = 0); |
29 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 29 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
30 | 30 | ||
31 | virtual void deleteMail(const RecMailP&mail); | 31 | virtual void deleteMail(const RecMailP&mail); |
32 | void deleteMailList(const QValueList<RecMailP>&target); | 32 | void deleteMailList(const QValueList<RecMailP>&target); |
33 | virtual void answeredMail(const RecMailP&mail); | 33 | virtual void answeredMail(const RecMailP&mail); |
34 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); | 34 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); |
35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
36 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 36 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
37 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit,int sizeInKb = 0); | 37 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit,int sizeInKb = 0); |
38 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 38 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
39 | 39 | ||
40 | virtual RecBodyP fetchBody(const RecMailP&mail); | 40 | virtual RecBodyP fetchBody(const RecMailP&mail); |
41 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); | 41 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); |
42 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); | 42 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); |
43 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); | 43 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); |
44 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 44 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
45 | 45 | ||
46 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, | 46 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, |
47 | const QString& delemiter="/",bool getsubfolder=false); | 47 | const QString& delemiter="/",bool getsubfolder=false); |
48 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder); | 48 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder); |
49 | 49 | ||
50 | static void imap_progress( size_t current, size_t maximum ); | 50 | static void imap_progress( size_t current, size_t maximum ); |
51 | 51 | ||
52 | virtual void logout(); | 52 | virtual void logout(); |
53 | virtual MAILLIB::ATYPE getType()const; | 53 | virtual MAILLIB::ATYPE getType()const; |
54 | virtual const QString&getName()const; | 54 | virtual const QString&getName()const; |
55 | virtual Account* getAccount() { return account; }; | ||
55 | 56 | ||
56 | protected: | 57 | protected: |
57 | RecMail*parse_list_result(mailimap_msg_att*); | 58 | RecMail*parse_list_result(mailimap_msg_att*); |
58 | void login(); | 59 | void login(); |
59 | bool start_tls(bool force=true); | 60 | bool start_tls(bool force=true); |
60 | 61 | ||
61 | virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 62 | virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
62 | virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); | 63 | virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); |
63 | int selectMbox(const QString&mbox); | 64 | int selectMbox(const QString&mbox); |
64 | 65 | ||
65 | void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description); | 66 | void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description); |
66 | void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which); | 67 | void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which); |
67 | void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which); | 68 | void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which); |
68 | void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which); | 69 | void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which); |
69 | void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which); | 70 | void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which); |
70 | void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 71 | void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
71 | 72 | ||
72 | /* just helpers */ | 73 | /* just helpers */ |
73 | static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); | 74 | static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); |
74 | static QStringList address_list_to_stringlist(clist*list); | 75 | static QStringList address_list_to_stringlist(clist*list); |
75 | 76 | ||
76 | static void progress(QString mess = QString::null); | 77 | static void progress(QString mess = QString::null); |
77 | static int mCurrent; | 78 | static int mCurrent; |
78 | static int mMax; | 79 | static int mMax; |
79 | IMAPaccount *account; | 80 | IMAPaccount *account; |
80 | mailimap *m_imap; | 81 | mailimap *m_imap; |
81 | QString m_Lastmbox; | 82 | QString m_Lastmbox; |
82 | }; | 83 | }; |
83 | 84 | ||
84 | #endif | 85 | #endif |
diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp index d43bdc6..1a4ffd1 100644 --- a/kmicromail/libmailwrapper/mailtypes.cpp +++ b/kmicromail/libmailwrapper/mailtypes.cpp | |||
@@ -1,218 +1,241 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | //#include <opie2/odebug.h> | 3 | //#include <opie2/odebug.h> |
4 | 4 | ||
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
6 | 6 | ||
7 | using namespace Opie::Core; | 7 | using namespace Opie::Core; |
8 | RecMail::RecMail() | 8 | RecMail::RecMail() |
9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
10 | { | 10 | { |
11 | init(); | 11 | init(); |
12 | } | 12 | } |
13 | 13 | ||
14 | RecMail::RecMail(const RecMail&old) | 14 | RecMail::RecMail(const RecMail&old) |
15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
16 | { | 16 | { |
17 | init(); | 17 | init(); |
18 | copy_old(old); | 18 | copy_old(old); |
19 | // odebug << "Copy constructor RecMail" << oendl; | 19 | // odebug << "Copy constructor RecMail" << oendl; |
20 | } | 20 | } |
21 | 21 | ||
22 | RecMail::~RecMail() | 22 | RecMail::~RecMail() |
23 | { | 23 | { |
24 | wrapper = 0; | 24 | wrapper = 0; |
25 | } | 25 | } |
26 | static bool stringCompareRec( const QString& s1, const QString& s2 ) | ||
27 | { | ||
28 | if ( s1.isEmpty() && s2.isEmpty() ) | ||
29 | return true; | ||
30 | return s1 == s2; | ||
31 | } | ||
26 | 32 | ||
33 | bool RecMail::isEqual( RecMail* r1 ) | ||
34 | { | ||
35 | if ( !stringCompareRec( isodate, r1->isodate ) ) { | ||
36 | // qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); | ||
37 | return false; | ||
38 | } | ||
39 | if ( !stringCompareRec( from, r1->from ) ) { | ||
40 | //qDebug("from *%s* *%s* ", from.latin1(), r1->from.latin1()); | ||
41 | return false; | ||
42 | } | ||
43 | if ( !stringCompareRec( subject, r1->subject ) ) { | ||
44 | //qDebug("sub "); | ||
45 | return false; | ||
46 | } | ||
47 | |||
48 | return true; | ||
49 | } | ||
27 | void RecMail::copy_old(const RecMail&old) | 50 | void RecMail::copy_old(const RecMail&old) |
28 | { | 51 | { |
29 | subject = old.subject; | 52 | subject = old.subject; |
30 | date = old.date; | 53 | date = old.date; |
31 | mbox = old.mbox; | 54 | mbox = old.mbox; |
32 | msg_id = old.msg_id; | 55 | msg_id = old.msg_id; |
33 | msg_size = old.msg_size; | 56 | msg_size = old.msg_size; |
34 | msg_number = old.msg_number; | 57 | msg_number = old.msg_number; |
35 | from = old.from; | 58 | from = old.from; |
36 | msg_flags = old.msg_flags; | 59 | msg_flags = old.msg_flags; |
37 | to = old.to; | 60 | to = old.to; |
38 | cc = old.cc; | 61 | cc = old.cc; |
39 | bcc = old.bcc; | 62 | bcc = old.bcc; |
40 | wrapper = old.wrapper; | 63 | wrapper = old.wrapper; |
41 | in_reply_to = old.in_reply_to; | 64 | in_reply_to = old.in_reply_to; |
42 | references = old.references; | 65 | references = old.references; |
43 | replyto = old.replyto; | 66 | replyto = old.replyto; |
44 | } | 67 | } |
45 | 68 | ||
46 | void RecMail::init() | 69 | void RecMail::init() |
47 | { | 70 | { |
48 | to.clear(); | 71 | to.clear(); |
49 | cc.clear(); | 72 | cc.clear(); |
50 | bcc.clear(); | 73 | bcc.clear(); |
51 | in_reply_to.clear(); | 74 | in_reply_to.clear(); |
52 | references.clear(); | 75 | references.clear(); |
53 | wrapper = 0; | 76 | wrapper = 0; |
54 | } | 77 | } |
55 | 78 | ||
56 | void RecMail::setWrapper(AbstractMail*awrapper) | 79 | void RecMail::setWrapper(AbstractMail*awrapper) |
57 | { | 80 | { |
58 | wrapper = awrapper; | 81 | wrapper = awrapper; |
59 | } | 82 | } |
60 | 83 | ||
61 | AbstractMail* RecMail::Wrapper() | 84 | AbstractMail* RecMail::Wrapper() |
62 | { | 85 | { |
63 | return wrapper; | 86 | return wrapper; |
64 | } | 87 | } |
65 | 88 | ||
66 | void RecMail::setTo(const QStringList&list) | 89 | void RecMail::setTo(const QStringList&list) |
67 | { | 90 | { |
68 | to = list; | 91 | to = list; |
69 | } | 92 | } |
70 | 93 | ||
71 | const QStringList&RecMail::To()const | 94 | const QStringList&RecMail::To()const |
72 | { | 95 | { |
73 | return to; | 96 | return to; |
74 | } | 97 | } |
75 | 98 | ||
76 | void RecMail::setCC(const QStringList&list) | 99 | void RecMail::setCC(const QStringList&list) |
77 | { | 100 | { |
78 | cc = list; | 101 | cc = list; |
79 | } | 102 | } |
80 | 103 | ||
81 | const QStringList&RecMail::CC()const | 104 | const QStringList&RecMail::CC()const |
82 | { | 105 | { |
83 | return cc; | 106 | return cc; |
84 | } | 107 | } |
85 | 108 | ||
86 | void RecMail::setBcc(const QStringList&list) | 109 | void RecMail::setBcc(const QStringList&list) |
87 | { | 110 | { |
88 | bcc = list; | 111 | bcc = list; |
89 | } | 112 | } |
90 | 113 | ||
91 | const QStringList& RecMail::Bcc()const | 114 | const QStringList& RecMail::Bcc()const |
92 | { | 115 | { |
93 | return bcc; | 116 | return bcc; |
94 | } | 117 | } |
95 | 118 | ||
96 | void RecMail::setInreply(const QStringList&list) | 119 | void RecMail::setInreply(const QStringList&list) |
97 | { | 120 | { |
98 | in_reply_to = list; | 121 | in_reply_to = list; |
99 | } | 122 | } |
100 | 123 | ||
101 | const QStringList& RecMail::Inreply()const | 124 | const QStringList& RecMail::Inreply()const |
102 | { | 125 | { |
103 | return in_reply_to; | 126 | return in_reply_to; |
104 | } | 127 | } |
105 | 128 | ||
106 | void RecMail::setReferences(const QStringList&list) | 129 | void RecMail::setReferences(const QStringList&list) |
107 | { | 130 | { |
108 | references = list; | 131 | references = list; |
109 | } | 132 | } |
110 | 133 | ||
111 | const QStringList& RecMail::References()const | 134 | const QStringList& RecMail::References()const |
112 | { | 135 | { |
113 | return references; | 136 | return references; |
114 | } | 137 | } |
115 | 138 | ||
116 | RecPart::RecPart() | 139 | RecPart::RecPart() |
117 | : Opie::Core::ORefCount(), | 140 | : Opie::Core::ORefCount(), |
118 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | 141 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) |
119 | { | 142 | { |
120 | m_Parameters.clear(); | 143 | m_Parameters.clear(); |
121 | m_poslist.clear(); | 144 | m_poslist.clear(); |
122 | } | 145 | } |
123 | 146 | ||
124 | RecPart::RecPart(const RecPart&old) | 147 | RecPart::RecPart(const RecPart&old) |
125 | : Opie::Core::ORefCount(), | 148 | : Opie::Core::ORefCount(), |
126 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | 149 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) |
127 | { | 150 | { |
128 | m_type = old.m_type; | 151 | m_type = old.m_type; |
129 | m_subtype = old.m_subtype; | 152 | m_subtype = old.m_subtype; |
130 | m_identifier = old.m_identifier; | 153 | m_identifier = old.m_identifier; |
131 | m_encoding = old.m_encoding; | 154 | m_encoding = old.m_encoding; |
132 | m_description = old.m_description; | 155 | m_description = old.m_description; |
133 | m_lines = old.m_lines; | 156 | m_lines = old.m_lines; |
134 | m_size = old.m_size; | 157 | m_size = old.m_size; |
135 | m_Parameters = old.m_Parameters; | 158 | m_Parameters = old.m_Parameters; |
136 | m_poslist = old.m_poslist; | 159 | m_poslist = old.m_poslist; |
137 | // odebug << "RecPart copy constructor" << oendl; | 160 | // odebug << "RecPart copy constructor" << oendl; |
138 | } | 161 | } |
139 | 162 | ||
140 | RecPart::~RecPart() | 163 | RecPart::~RecPart() |
141 | { | 164 | { |
142 | } | 165 | } |
143 | 166 | ||
144 | void RecPart::setSize(unsigned int size) | 167 | void RecPart::setSize(unsigned int size) |
145 | { | 168 | { |
146 | m_size = size; | 169 | m_size = size; |
147 | } | 170 | } |
148 | 171 | ||
149 | const unsigned int RecPart::Size()const | 172 | const unsigned int RecPart::Size()const |
150 | { | 173 | { |
151 | return m_size; | 174 | return m_size; |
152 | } | 175 | } |
153 | 176 | ||
154 | void RecPart::setLines(unsigned int lines) | 177 | void RecPart::setLines(unsigned int lines) |
155 | { | 178 | { |
156 | m_lines = lines; | 179 | m_lines = lines; |
157 | } | 180 | } |
158 | 181 | ||
159 | const unsigned int RecPart::Lines()const | 182 | const unsigned int RecPart::Lines()const |
160 | { | 183 | { |
161 | return m_lines; | 184 | return m_lines; |
162 | } | 185 | } |
163 | 186 | ||
164 | const QString& RecPart::Type()const | 187 | const QString& RecPart::Type()const |
165 | { | 188 | { |
166 | return m_type; | 189 | return m_type; |
167 | } | 190 | } |
168 | 191 | ||
169 | void RecPart::setType(const QString&type) | 192 | void RecPart::setType(const QString&type) |
170 | { | 193 | { |
171 | m_type = type; | 194 | m_type = type; |
172 | } | 195 | } |
173 | 196 | ||
174 | const QString& RecPart::Subtype()const | 197 | const QString& RecPart::Subtype()const |
175 | { | 198 | { |
176 | return m_subtype; | 199 | return m_subtype; |
177 | } | 200 | } |
178 | 201 | ||
179 | void RecPart::setSubtype(const QString&subtype) | 202 | void RecPart::setSubtype(const QString&subtype) |
180 | { | 203 | { |
181 | m_subtype = subtype; | 204 | m_subtype = subtype; |
182 | } | 205 | } |
183 | 206 | ||
184 | const QString& RecPart::Identifier()const | 207 | const QString& RecPart::Identifier()const |
185 | { | 208 | { |
186 | return m_identifier; | 209 | return m_identifier; |
187 | } | 210 | } |
188 | 211 | ||
189 | void RecPart::setIdentifier(const QString&identifier) | 212 | void RecPart::setIdentifier(const QString&identifier) |
190 | { | 213 | { |
191 | m_identifier = identifier; | 214 | m_identifier = identifier; |
192 | } | 215 | } |
193 | 216 | ||
194 | const QString& RecPart::Encoding()const | 217 | const QString& RecPart::Encoding()const |
195 | { | 218 | { |
196 | return m_encoding; | 219 | return m_encoding; |
197 | } | 220 | } |
198 | 221 | ||
199 | void RecPart::setEncoding(const QString&encoding) | 222 | void RecPart::setEncoding(const QString&encoding) |
200 | { | 223 | { |
201 | m_encoding = encoding; | 224 | m_encoding = encoding; |
202 | } | 225 | } |
203 | 226 | ||
204 | const QString& RecPart::Description()const | 227 | const QString& RecPart::Description()const |
205 | { | 228 | { |
206 | return m_description; | 229 | return m_description; |
207 | } | 230 | } |
208 | 231 | ||
209 | void RecPart::setDescription(const QString&desc) | 232 | void RecPart::setDescription(const QString&desc) |
210 | { | 233 | { |
211 | m_description = desc; | 234 | m_description = desc; |
212 | } | 235 | } |
213 | 236 | ||
214 | void RecPart::setParameters(const part_plist_t&list) | 237 | void RecPart::setParameters(const part_plist_t&list) |
215 | { | 238 | { |
216 | m_Parameters = list; | 239 | m_Parameters = list; |
217 | } | 240 | } |
218 | 241 | ||
diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h index c317880..020278d 100644 --- a/kmicromail/libmailwrapper/mailtypes.h +++ b/kmicromail/libmailwrapper/mailtypes.h | |||
@@ -1,206 +1,209 @@ | |||
1 | #ifndef __MAIL_TYPES_H | 1 | #ifndef __MAIL_TYPES_H |
2 | #define __MAIL_TYPES_H | 2 | #define __MAIL_TYPES_H |
3 | 3 | ||
4 | #define FLAG_ANSWERED 0 | 4 | #define FLAG_ANSWERED 0 |
5 | #define FLAG_FLAGGED 1 | 5 | #define FLAG_FLAGGED 1 |
6 | #define FLAG_DELETED 2 | 6 | #define FLAG_DELETED 2 |
7 | #define FLAG_SEEN 3 | 7 | #define FLAG_SEEN 3 |
8 | #define FLAG_DRAFT 4 | 8 | #define FLAG_DRAFT 4 |
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <opie2/osmartpointer.h> | 11 | #include <opie2/osmartpointer.h> |
12 | 12 | ||
13 | #include <qbitarray.h> | 13 | #include <qbitarray.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qstringlist.h> | 15 | #include <qstringlist.h> |
16 | #include <qmap.h> | 16 | #include <qmap.h> |
17 | #include <qvaluelist.h> | 17 | #include <qvaluelist.h> |
18 | 18 | ||
19 | class AbstractMail; | 19 | class AbstractMail; |
20 | /* a class to describe mails in a mailbox */ | 20 | /* a class to describe mails in a mailbox */ |
21 | /* Attention! | 21 | /* Attention! |
22 | From programmers point of view it would make sense to | 22 | From programmers point of view it would make sense to |
23 | store the mail body into this class, too. | 23 | store the mail body into this class, too. |
24 | But: not from the point of view of the device. | 24 | But: not from the point of view of the device. |
25 | Mailbodies can be real large. So we request them when | 25 | Mailbodies can be real large. So we request them when |
26 | needed from the mail-wrapper class direct from the server itself | 26 | needed from the mail-wrapper class direct from the server itself |
27 | (imap) or from a file-based cache (pop3?) | 27 | (imap) or from a file-based cache (pop3?) |
28 | So there is no interface "const QString&body()" but you should | 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 | 29 | make a request to the mailwrapper with this class as parameter to |
30 | get the body. Same words for the attachments. | 30 | get the body. Same words for the attachments. |
31 | */ | 31 | */ |
32 | class RecMail:public Opie::Core::ORefCount | 32 | class RecMail:public Opie::Core::ORefCount |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | RecMail(); | 35 | RecMail(); |
36 | RecMail(const RecMail&old); | 36 | RecMail(const RecMail&old); |
37 | virtual ~RecMail(); | 37 | virtual ~RecMail(); |
38 | bool isEqual( RecMail* r1 ); | ||
38 | 39 | ||
39 | const unsigned int getNumber()const{return msg_number;} | 40 | const unsigned int getNumber()const{return msg_number;} |
40 | void setNumber(unsigned int number){msg_number=number;} | 41 | void setNumber(unsigned int number){msg_number=number;} |
41 | const QString&getDate()const{ return date; } | 42 | const QString&getDate()const{ return date; } |
42 | void setDate( const QString&a ) { date = a; } | 43 | void setDate( const QString&a ) { date = a; } |
44 | const QString&getIsoDate()const{ return isodate; } | ||
45 | void setIsoDate( const QString&a ) { isodate = a; } | ||
43 | const QString&getFrom()const{ return from; } | 46 | const QString&getFrom()const{ return from; } |
44 | void setFrom( const QString&a ) { from = a; } | 47 | void setFrom( const QString&a ) { from = a; } |
45 | const QString&getSubject()const { return subject; } | 48 | const QString&getSubject()const { return subject; } |
46 | void setSubject( const QString&s ) { subject = s; } | 49 | void setSubject( const QString&s ) { subject = s; } |
47 | const QString&getMbox()const{return mbox;} | 50 | const QString&getMbox()const{return mbox;} |
48 | void setMbox(const QString&box){mbox = box;} | 51 | void setMbox(const QString&box){mbox = box;} |
49 | void setMsgid(const QString&id){msg_id=id;} | 52 | void setMsgid(const QString&id){msg_id=id;} |
50 | const QString&Msgid()const{return msg_id;} | 53 | const QString&Msgid()const{return msg_id;} |
51 | void setReplyto(const QString&reply){replyto=reply;} | 54 | void setReplyto(const QString&reply){replyto=reply;} |
52 | const QString&Replyto()const{return replyto;} | 55 | const QString&Replyto()const{return replyto;} |
53 | void setMsgsize(unsigned int size){msg_size = size;} | 56 | void setMsgsize(unsigned int size){msg_size = size;} |
54 | const unsigned int Msgsize()const{return msg_size;} | 57 | const unsigned int Msgsize()const{return msg_size;} |
55 | 58 | ||
56 | 59 | ||
57 | void setTo(const QStringList&list); | 60 | void setTo(const QStringList&list); |
58 | const QStringList&To()const; | 61 | const QStringList&To()const; |
59 | void setCC(const QStringList&list); | 62 | void setCC(const QStringList&list); |
60 | const QStringList&CC()const; | 63 | const QStringList&CC()const; |
61 | void setBcc(const QStringList&list); | 64 | void setBcc(const QStringList&list); |
62 | const QStringList&Bcc()const; | 65 | const QStringList&Bcc()const; |
63 | void setInreply(const QStringList&list); | 66 | void setInreply(const QStringList&list); |
64 | const QStringList&Inreply()const; | 67 | const QStringList&Inreply()const; |
65 | void setReferences(const QStringList&list); | 68 | void setReferences(const QStringList&list); |
66 | const QStringList&References()const; | 69 | const QStringList&References()const; |
67 | 70 | ||
68 | const QBitArray&getFlags()const{return msg_flags;} | 71 | const QBitArray&getFlags()const{return msg_flags;} |
69 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 72 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
70 | 73 | ||
71 | void setWrapper(AbstractMail*wrapper); | 74 | void setWrapper(AbstractMail*wrapper); |
72 | AbstractMail* Wrapper(); | 75 | AbstractMail* Wrapper(); |
73 | 76 | ||
74 | protected: | 77 | protected: |
75 | QString subject,date,from,mbox,msg_id,replyto; | 78 | QString subject,date,isodate,from,mbox,msg_id,replyto; |
76 | unsigned int msg_number,msg_size; | 79 | unsigned int msg_number,msg_size; |
77 | QBitArray msg_flags; | 80 | QBitArray msg_flags; |
78 | QStringList to,cc,bcc,in_reply_to,references; | 81 | QStringList to,cc,bcc,in_reply_to,references; |
79 | AbstractMail*wrapper; | 82 | AbstractMail*wrapper; |
80 | void init(); | 83 | void init(); |
81 | void copy_old(const RecMail&old); | 84 | void copy_old(const RecMail&old); |
82 | }; | 85 | }; |
83 | 86 | ||
84 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; | 87 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; |
85 | typedef QMap<QString,QString> part_plist_t; | 88 | typedef QMap<QString,QString> part_plist_t; |
86 | 89 | ||
87 | class RecPart:public Opie::Core::ORefCount | 90 | class RecPart:public Opie::Core::ORefCount |
88 | { | 91 | { |
89 | protected: | 92 | protected: |
90 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 93 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
91 | unsigned int m_lines,m_size; | 94 | unsigned int m_lines,m_size; |
92 | part_plist_t m_Parameters; | 95 | part_plist_t m_Parameters; |
93 | /* describes the position in the mail */ | 96 | /* describes the position in the mail */ |
94 | QValueList<int> m_poslist; | 97 | QValueList<int> m_poslist; |
95 | 98 | ||
96 | public: | 99 | public: |
97 | RecPart(); | 100 | RecPart(); |
98 | RecPart(const RecPart&); | 101 | RecPart(const RecPart&); |
99 | virtual ~RecPart(); | 102 | virtual ~RecPart(); |
100 | 103 | ||
101 | const QString&Type()const; | 104 | const QString&Type()const; |
102 | void setType(const QString&type); | 105 | void setType(const QString&type); |
103 | const QString&Subtype()const; | 106 | const QString&Subtype()const; |
104 | void setSubtype(const QString&subtype); | 107 | void setSubtype(const QString&subtype); |
105 | const QString&Identifier()const; | 108 | const QString&Identifier()const; |
106 | void setIdentifier(const QString&identifier); | 109 | void setIdentifier(const QString&identifier); |
107 | const QString&Encoding()const; | 110 | const QString&Encoding()const; |
108 | void setEncoding(const QString&encoding); | 111 | void setEncoding(const QString&encoding); |
109 | const QString&Description()const; | 112 | const QString&Description()const; |
110 | void setDescription(const QString&desc); | 113 | void setDescription(const QString&desc); |
111 | void setLines(unsigned int lines); | 114 | void setLines(unsigned int lines); |
112 | const unsigned int Lines()const; | 115 | const unsigned int Lines()const; |
113 | void setSize(unsigned int size); | 116 | void setSize(unsigned int size); |
114 | const unsigned int Size()const; | 117 | const unsigned int Size()const; |
115 | 118 | ||
116 | 119 | ||
117 | void setParameters(const part_plist_t&list); | 120 | void setParameters(const part_plist_t&list); |
118 | const part_plist_t&Parameters()const; | 121 | const part_plist_t&Parameters()const; |
119 | void addParameter(const QString&key,const QString&value); | 122 | void addParameter(const QString&key,const QString&value); |
120 | const QString searchParamter(const QString&key)const; | 123 | const QString searchParamter(const QString&key)const; |
121 | void setPositionlist(const QValueList<int>&poslist); | 124 | void setPositionlist(const QValueList<int>&poslist); |
122 | const QValueList<int>& Positionlist()const; | 125 | const QValueList<int>& Positionlist()const; |
123 | }; | 126 | }; |
124 | 127 | ||
125 | typedef Opie::Core::OSmartPointer<RecPart> RecPartP; | 128 | typedef Opie::Core::OSmartPointer<RecPart> RecPartP; |
126 | 129 | ||
127 | class RecBody:public Opie::Core::ORefCount | 130 | class RecBody:public Opie::Core::ORefCount |
128 | { | 131 | { |
129 | protected: | 132 | protected: |
130 | QString m_BodyText; | 133 | QString m_BodyText; |
131 | QValueList<RecPartP> m_PartsList; | 134 | QValueList<RecPartP> m_PartsList; |
132 | RecPartP m_description; | 135 | RecPartP m_description; |
133 | 136 | ||
134 | public: | 137 | public: |
135 | RecBody(); | 138 | RecBody(); |
136 | RecBody(const RecBody&old); | 139 | RecBody(const RecBody&old); |
137 | virtual ~RecBody(); | 140 | virtual ~RecBody(); |
138 | void setBodytext(const QString&); | 141 | void setBodytext(const QString&); |
139 | const QString& Bodytext()const; | 142 | const QString& Bodytext()const; |
140 | 143 | ||
141 | void setDescription(const RecPartP&des); | 144 | void setDescription(const RecPartP&des); |
142 | const RecPartP& Description()const; | 145 | const RecPartP& Description()const; |
143 | 146 | ||
144 | void setParts(const QValueList<RecPartP>&parts); | 147 | void setParts(const QValueList<RecPartP>&parts); |
145 | const QValueList<RecPartP>& Parts()const; | 148 | const QValueList<RecPartP>& Parts()const; |
146 | void addPart(const RecPartP&part); | 149 | void addPart(const RecPartP&part); |
147 | }; | 150 | }; |
148 | 151 | ||
149 | typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; | 152 | typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; |
150 | 153 | ||
151 | class encodedString | 154 | class encodedString |
152 | { | 155 | { |
153 | public: | 156 | public: |
154 | encodedString(); | 157 | encodedString(); |
155 | /* | 158 | /* |
156 | creates an new content string. | 159 | creates an new content string. |
157 | it makes a deep copy of it! | 160 | it makes a deep copy of it! |
158 | */ | 161 | */ |
159 | encodedString(const char*nContent,unsigned int length); | 162 | encodedString(const char*nContent,unsigned int length); |
160 | /* | 163 | /* |
161 | Take over the nContent. Means: it will just copy the pointer, not the content. | 164 | 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 | 165 | so make sure: No one else frees the string, the string has allocated with |
163 | malloc for compatibility with c-based libs | 166 | malloc for compatibility with c-based libs |
164 | */ | 167 | */ |
165 | encodedString(char*nContent,unsigned int nSize); | 168 | encodedString(char*nContent,unsigned int nSize); |
166 | /* copy construkor - makes ALWAYS a deep copy!!!! */ | 169 | /* copy construkor - makes ALWAYS a deep copy!!!! */ |
167 | encodedString(const encodedString&old); | 170 | encodedString(const encodedString&old); |
168 | /* assign operator - makes ALWAYS a deep copy!!!! */ | 171 | /* assign operator - makes ALWAYS a deep copy!!!! */ |
169 | encodedString& operator=(const encodedString&old); | 172 | encodedString& operator=(const encodedString&old); |
170 | /* destructor - cleans the content */ | 173 | /* destructor - cleans the content */ |
171 | virtual ~encodedString(); | 174 | virtual ~encodedString(); |
172 | 175 | ||
173 | /* returns a pointer to the content - do not delete yoursel! */ | 176 | /* returns a pointer to the content - do not delete yoursel! */ |
174 | const char*Content()const; | 177 | const char*Content()const; |
175 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ | 178 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ |
176 | const int Length()const; | 179 | const int Length()const; |
177 | 180 | ||
178 | /* | 181 | /* |
179 | makes a deep copy of nContent! | 182 | makes a deep copy of nContent! |
180 | */ | 183 | */ |
181 | void setContent(const char*nContent,int nSize); | 184 | void setContent(const char*nContent,int nSize); |
182 | /* | 185 | /* |
183 | Take over the nContent. Means: it will just copy the pointer, not the content. | 186 | 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 | 187 | so make sure: No one else frees the string, the string has allocated with |
185 | malloc for compatibility with c-based libs | 188 | malloc for compatibility with c-based libs |
186 | */ | 189 | */ |
187 | void setContent(char*nContent,int nSize); | 190 | void setContent(char*nContent,int nSize); |
188 | 191 | ||
189 | protected: | 192 | protected: |
190 | char * content; | 193 | char * content; |
191 | unsigned int size; | 194 | unsigned int size; |
192 | 195 | ||
193 | void init(); | 196 | void init(); |
194 | void copy_old(const encodedString&old); | 197 | void copy_old(const encodedString&old); |
195 | void clean(); | 198 | void clean(); |
196 | }; | 199 | }; |
197 | 200 | ||
198 | struct folderStat | 201 | struct folderStat |
199 | { | 202 | { |
200 | unsigned int message_count; | 203 | unsigned int message_count; |
201 | unsigned int message_unseen; | 204 | unsigned int message_unseen; |
202 | unsigned int message_recent; | 205 | unsigned int message_recent; |
203 | folderStat&operator=(const folderStat&old); | 206 | folderStat&operator=(const folderStat&old); |
204 | }; | 207 | }; |
205 | 208 | ||
206 | #endif | 209 | #endif |
diff --git a/kmicromail/libmailwrapper/mboxwrapper.h b/kmicromail/libmailwrapper/mboxwrapper.h index 9731b85..d03940f 100644 --- a/kmicromail/libmailwrapper/mboxwrapper.h +++ b/kmicromail/libmailwrapper/mboxwrapper.h | |||
@@ -1,46 +1,47 @@ | |||
1 | #ifndef __MBOX_WRAPPER_H | 1 | #ifndef __MBOX_WRAPPER_H |
2 | #define __MBOX_WRAPPER_H | 2 | #define __MBOX_WRAPPER_H |
3 | 3 | ||
4 | #include "genericwrapper.h" | 4 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | class encodedString; | 7 | class encodedString; |
8 | struct mailmbox_folder; | 8 | struct mailmbox_folder; |
9 | 9 | ||
10 | class MBOXwrapper : public Genericwrapper | 10 | class MBOXwrapper : public Genericwrapper |
11 | { | 11 | { |
12 | Q_OBJECT | 12 | Q_OBJECT |
13 | 13 | ||
14 | public: | 14 | public: |
15 | MBOXwrapper(const QString & dir,const QString&name); | 15 | MBOXwrapper(const QString & dir,const QString&name); |
16 | virtual ~MBOXwrapper(); | 16 | virtual ~MBOXwrapper(); |
17 | 17 | ||
18 | virtual void listMessages(const QString & mailbox, QValueList<RecMailP>&target ); | 18 | virtual void listMessages(const QString & mailbox, QValueList<RecMailP>&target ); |
19 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 19 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
21 | 21 | ||
22 | virtual void deleteMail(const RecMailP&mail); | 22 | virtual void deleteMail(const RecMailP&mail); |
23 | virtual void answeredMail(const RecMailP&mail); | 23 | virtual void answeredMail(const RecMailP&mail); |
24 | 24 | ||
25 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, | 25 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, |
26 | const QString&d="",bool s=false); | 26 | const QString&d="",bool s=false); |
27 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); | 27 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); |
28 | 28 | ||
29 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 29 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
30 | 30 | ||
31 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 31 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
32 | static void mbox_progress( size_t current, size_t maximum ); | 32 | static void mbox_progress( size_t current, size_t maximum ); |
33 | 33 | ||
34 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 34 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
35 | virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target); | 35 | virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target); |
36 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 36 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
37 | virtual MAILLIB::ATYPE getType()const; | 37 | virtual MAILLIB::ATYPE getType()const; |
38 | virtual const QString&getName()const; | 38 | virtual const QString&getName()const; |
39 | virtual Account* getAccount() { return 0; }; | ||
39 | 40 | ||
40 | protected: | 41 | protected: |
41 | static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target); | 42 | static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target); |
42 | QString MBOXPath; | 43 | QString MBOXPath; |
43 | QString MBOXName; | 44 | QString MBOXName; |
44 | }; | 45 | }; |
45 | 46 | ||
46 | #endif | 47 | #endif |
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp index cbc52d9..962dac0 100644 --- a/kmicromail/libmailwrapper/mhwrapper.cpp +++ b/kmicromail/libmailwrapper/mhwrapper.cpp | |||
@@ -1,259 +1,260 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "mhwrapper.h" | 2 | #include "mhwrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qpe/global.h> | 9 | #include <qpe/global.h> |
10 | #include <oprocess.h> | 10 | #include <oprocess.h> |
11 | //#include <opie2/odebug.h> | 11 | //#include <opie2/odebug.h> |
12 | 12 | ||
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 14 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
15 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 15 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
16 | { | 16 | { |
17 | if (MHPath.length()>0) { | 17 | if (MHPath.length()>0) { |
18 | if (MHPath[MHPath.length()-1]=='/') { | 18 | if (MHPath[MHPath.length()-1]=='/') { |
19 | MHPath=MHPath.left(MHPath.length()-1); | 19 | MHPath=MHPath.left(MHPath.length()-1); |
20 | } | 20 | } |
21 | //odebug << MHPath << oendl; | 21 | //odebug << MHPath << oendl; |
22 | QDir dir(MHPath); | 22 | QDir dir(MHPath); |
23 | if (!dir.exists()) { | 23 | if (!dir.exists()) { |
24 | dir.mkdir(MHPath); | 24 | dir.mkdir(MHPath); |
25 | } | 25 | } |
26 | init_storage(); | 26 | init_storage(); |
27 | } | 27 | } |
28 | } | 28 | } |
29 | 29 | ||
30 | void MHwrapper::init_storage() | 30 | void MHwrapper::init_storage() |
31 | { | 31 | { |
32 | int r; | 32 | int r; |
33 | QString pre = MHPath; | 33 | QString pre = MHPath; |
34 | if (!m_storage) { | 34 | if (!m_storage) { |
35 | m_storage = mailstorage_new(NULL); | 35 | m_storage = mailstorage_new(NULL); |
36 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 36 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
37 | if (r != MAIL_NO_ERROR) { | 37 | if (r != MAIL_NO_ERROR) { |
38 | qDebug(" error init storage "); | 38 | qDebug(" error init storage "); |
39 | mailstorage_free(m_storage); | 39 | mailstorage_free(m_storage); |
40 | m_storage = 0; | 40 | m_storage = 0; |
41 | return; | 41 | return; |
42 | } | 42 | } |
43 | } | 43 | } |
44 | r = mailstorage_connect(m_storage); | 44 | r = mailstorage_connect(m_storage); |
45 | if (r!=MAIL_NO_ERROR) { | 45 | if (r!=MAIL_NO_ERROR) { |
46 | qDebug("error connecting storage "); | 46 | qDebug("error connecting storage "); |
47 | mailstorage_free(m_storage); | 47 | mailstorage_free(m_storage); |
48 | m_storage = 0; | 48 | m_storage = 0; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void MHwrapper::clean_storage() | 52 | void MHwrapper::clean_storage() |
53 | { | 53 | { |
54 | if (m_storage) { | 54 | if (m_storage) { |
55 | mailstorage_disconnect(m_storage); | 55 | mailstorage_disconnect(m_storage); |
56 | mailstorage_free(m_storage); | 56 | mailstorage_free(m_storage); |
57 | m_storage = 0; | 57 | m_storage = 0; |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | MHwrapper::~MHwrapper() | 61 | MHwrapper::~MHwrapper() |
62 | { | 62 | { |
63 | clean_storage(); | 63 | clean_storage(); |
64 | } | 64 | } |
65 | 65 | ||
66 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) | 66 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) |
67 | { | 67 | { |
68 | qDebug("MHwrapper::listMessages "); | ||
68 | init_storage(); | 69 | init_storage(); |
69 | if (!m_storage) { | 70 | if (!m_storage) { |
70 | return; | 71 | return; |
71 | } | 72 | } |
72 | QString f = buildPath(mailbox); | 73 | QString f = buildPath(mailbox); |
73 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 74 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
74 | if (r!=MAIL_NO_ERROR) { | 75 | if (r!=MAIL_NO_ERROR) { |
75 | qDebug("listMessages: error selecting folder! "); | 76 | qDebug("listMessages: error selecting folder! "); |
76 | return; | 77 | return; |
77 | } | 78 | } |
78 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); | 79 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); |
79 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 80 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
80 | } | 81 | } |
81 | 82 | ||
82 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 83 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
83 | { | 84 | { |
84 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 85 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
85 | /* this is needed! */ | 86 | /* this is needed! */ |
86 | if (m_storage) mailstorage_disconnect(m_storage); | 87 | if (m_storage) mailstorage_disconnect(m_storage); |
87 | init_storage(); | 88 | init_storage(); |
88 | if (!m_storage) { | 89 | if (!m_storage) { |
89 | return folders; | 90 | return folders; |
90 | } | 91 | } |
91 | mail_list*flist = 0; | 92 | mail_list*flist = 0; |
92 | clistcell*current=0; | 93 | clistcell*current=0; |
93 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 94 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
94 | if (r != MAIL_NO_ERROR || !flist) { | 95 | if (r != MAIL_NO_ERROR || !flist) { |
95 | qDebug("error getting folder list "); | 96 | qDebug("error getting folder list "); |
96 | return folders; | 97 | return folders; |
97 | } | 98 | } |
98 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 99 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
99 | QString t = (char*)current->data; | 100 | QString t = (char*)current->data; |
100 | t.replace(0,MHPath.length(),""); | 101 | t.replace(0,MHPath.length(),""); |
101 | folders->append(new MHFolder(t,MHPath)); | 102 | folders->append(new MHFolder(t,MHPath)); |
102 | } | 103 | } |
103 | mail_list_free(flist); | 104 | mail_list_free(flist); |
104 | return folders; | 105 | return folders; |
105 | } | 106 | } |
106 | 107 | ||
107 | void MHwrapper::deleteMail(const RecMailP&mail) | 108 | void MHwrapper::deleteMail(const RecMailP&mail) |
108 | { | 109 | { |
109 | init_storage(); | 110 | init_storage(); |
110 | if (!m_storage) { | 111 | if (!m_storage) { |
111 | return; | 112 | return; |
112 | } | 113 | } |
113 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 114 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
114 | if (r!=MAIL_NO_ERROR) { | 115 | if (r!=MAIL_NO_ERROR) { |
115 | qDebug("error selecting folder! "); | 116 | qDebug("error selecting folder! "); |
116 | return; | 117 | return; |
117 | } | 118 | } |
118 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); | 119 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); |
119 | if (r != MAIL_NO_ERROR) { | 120 | if (r != MAIL_NO_ERROR) { |
120 | qDebug("error deleting mail "); | 121 | qDebug("error deleting mail "); |
121 | } | 122 | } |
122 | } | 123 | } |
123 | 124 | ||
124 | void MHwrapper::answeredMail(const RecMailP&) | 125 | void MHwrapper::answeredMail(const RecMailP&) |
125 | { | 126 | { |
126 | } | 127 | } |
127 | 128 | ||
128 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) | 129 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) |
129 | { | 130 | { |
130 | RecBodyP body = new RecBody(); | 131 | RecBodyP body = new RecBody(); |
131 | init_storage(); | 132 | init_storage(); |
132 | if (!m_storage) { | 133 | if (!m_storage) { |
133 | return body; | 134 | return body; |
134 | } | 135 | } |
135 | mailmessage * msg; | 136 | mailmessage * msg; |
136 | char*data=0; | 137 | char*data=0; |
137 | 138 | ||
138 | /* mail should hold the complete path! */ | 139 | /* mail should hold the complete path! */ |
139 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 140 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
140 | if (r != MAIL_NO_ERROR) { | 141 | if (r != MAIL_NO_ERROR) { |
141 | return body; | 142 | return body; |
142 | } | 143 | } |
143 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 144 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
144 | if (r != MAIL_NO_ERROR) { | 145 | if (r != MAIL_NO_ERROR) { |
145 | qDebug("Error fetching mail "); | 146 | qDebug("Error fetching mail "); |
146 | 147 | ||
147 | return body; | 148 | return body; |
148 | } | 149 | } |
149 | body = parseMail(msg); | 150 | body = parseMail(msg); |
150 | mailmessage_fetch_result_free(msg,data); | 151 | mailmessage_fetch_result_free(msg,data); |
151 | return body; | 152 | return body; |
152 | } | 153 | } |
153 | 154 | ||
154 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 155 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
155 | { | 156 | { |
156 | qDebug("MBox Progress %d of %d",current,maximum ); | 157 | qDebug("MBox Progress %d of %d",current,maximum ); |
157 | //odebug << "MH " << current << " von " << maximum << "" << oendl; | 158 | //odebug << "MH " << current << " von " << maximum << "" << oendl; |
158 | } | 159 | } |
159 | 160 | ||
160 | QString MHwrapper::buildPath(const QString&p) | 161 | QString MHwrapper::buildPath(const QString&p) |
161 | { | 162 | { |
162 | QString f=""; | 163 | QString f=""; |
163 | if (p.length()==0||p=="/") | 164 | if (p.length()==0||p=="/") |
164 | return MHPath; | 165 | return MHPath; |
165 | if (!p.startsWith(MHPath)) { | 166 | if (!p.startsWith(MHPath)) { |
166 | f+=MHPath; | 167 | f+=MHPath; |
167 | } | 168 | } |
168 | if (!p.startsWith("/")) { | 169 | if (!p.startsWith("/")) { |
169 | f+="/"; | 170 | f+="/"; |
170 | } | 171 | } |
171 | f+=p; | 172 | f+=p; |
172 | return f; | 173 | return f; |
173 | } | 174 | } |
174 | 175 | ||
175 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) | 176 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) |
176 | { | 177 | { |
177 | init_storage(); | 178 | init_storage(); |
178 | if (!m_storage) { | 179 | if (!m_storage) { |
179 | return 0; | 180 | return 0; |
180 | } | 181 | } |
181 | QString f; | 182 | QString f; |
182 | if (!pfolder) { | 183 | if (!pfolder) { |
183 | // toplevel folder | 184 | // toplevel folder |
184 | f = buildPath(folder); | 185 | f = buildPath(folder); |
185 | } else { | 186 | } else { |
186 | f = pfolder->getName(); | 187 | f = pfolder->getName(); |
187 | f+="/"; | 188 | f+="/"; |
188 | f+=folder; | 189 | f+=folder; |
189 | } | 190 | } |
190 | 191 | ||
191 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); | 192 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); |
192 | if (r != MAIL_NO_ERROR) { | 193 | if (r != MAIL_NO_ERROR) { |
193 | qDebug("error creating folder "); | 194 | qDebug("error creating folder "); |
194 | return 0; | 195 | return 0; |
195 | } | 196 | } |
196 | qDebug("Folder created "); | 197 | qDebug("Folder created "); |
197 | return 1; | 198 | return 1; |
198 | } | 199 | } |
199 | 200 | ||
200 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) | 201 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) |
201 | { | 202 | { |
202 | init_storage(); | 203 | init_storage(); |
203 | if (!m_storage) { | 204 | if (!m_storage) { |
204 | return; | 205 | return; |
205 | } | 206 | } |
206 | QString f = buildPath(Folder); | 207 | QString f = buildPath(Folder); |
207 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 208 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
208 | if (r!=MAIL_NO_ERROR) { | 209 | if (r!=MAIL_NO_ERROR) { |
209 | qDebug("error selecting folder! "); | 210 | qDebug("error selecting folder! "); |
210 | return; | 211 | return; |
211 | } | 212 | } |
212 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); | 213 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); |
213 | if (r!=MAIL_NO_ERROR) { | 214 | if (r!=MAIL_NO_ERROR) { |
214 | qDebug("error storing mail "); | 215 | qDebug("error storing mail "); |
215 | } | 216 | } |
216 | return; | 217 | return; |
217 | } | 218 | } |
218 | 219 | ||
219 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) | 220 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) |
220 | { | 221 | { |
221 | encodedString*result = 0; | 222 | encodedString*result = 0; |
222 | init_storage(); | 223 | init_storage(); |
223 | if (!m_storage) { | 224 | if (!m_storage) { |
224 | return result; | 225 | return result; |
225 | } | 226 | } |
226 | mailmessage * msg = 0; | 227 | mailmessage * msg = 0; |
227 | char*data=0; | 228 | char*data=0; |
228 | size_t size; | 229 | size_t size; |
229 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 230 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
230 | if (r!=MAIL_NO_ERROR) { | 231 | if (r!=MAIL_NO_ERROR) { |
231 | qDebug("error selecting folder! "); | 232 | qDebug("error selecting folder! "); |
232 | return result; | 233 | return result; |
233 | } | 234 | } |
234 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 235 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
235 | if (r != MAIL_NO_ERROR) { | 236 | if (r != MAIL_NO_ERROR) { |
236 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 237 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
237 | return 0; | 238 | return 0; |
238 | } | 239 | } |
239 | r = mailmessage_fetch(msg,&data,&size); | 240 | r = mailmessage_fetch(msg,&data,&size); |
240 | if (r != MAIL_NO_ERROR) { | 241 | if (r != MAIL_NO_ERROR) { |
241 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 242 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
242 | if (msg) mailmessage_free(msg); | 243 | if (msg) mailmessage_free(msg); |
243 | return 0; | 244 | return 0; |
244 | } | 245 | } |
245 | result = new encodedString(data,size); | 246 | result = new encodedString(data,size); |
246 | if (msg) mailmessage_free(msg); | 247 | if (msg) mailmessage_free(msg); |
247 | return result; | 248 | return result; |
248 | } | 249 | } |
249 | 250 | ||
250 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 251 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) |
251 | { | 252 | { |
252 | QString f = buildPath(mailbox); | 253 | QString f = buildPath(mailbox); |
253 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 254 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
254 | if (r!=MAIL_NO_ERROR) { | 255 | if (r!=MAIL_NO_ERROR) { |
255 | qDebug("deleteMails: error selecting folder! "); | 256 | qDebug("deleteMails: error selecting folder! "); |
256 | return; | 257 | return; |
257 | } | 258 | } |
258 | QValueList<RecMailP>::ConstIterator it; | 259 | QValueList<RecMailP>::ConstIterator it; |
259 | for (it=target.begin(); it!=target.end();++it) { | 260 | for (it=target.begin(); it!=target.end();++it) { |
diff --git a/kmicromail/libmailwrapper/mhwrapper.h b/kmicromail/libmailwrapper/mhwrapper.h index 550824d..d1b7d1f 100644 --- a/kmicromail/libmailwrapper/mhwrapper.h +++ b/kmicromail/libmailwrapper/mhwrapper.h | |||
@@ -1,61 +1,62 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __MH_WRAPPER_H | 2 | #ifndef __MH_WRAPPER_H |
3 | #define __MH_WRAPPER_H | 3 | #define __MH_WRAPPER_H |
4 | 4 | ||
5 | #include "maildefines.h" | 5 | #include "maildefines.h" |
6 | 6 | ||
7 | #include "genericwrapper.h" | 7 | #include "genericwrapper.h" |
8 | #include <qstring.h> | 8 | #include <qstring.h> |
9 | 9 | ||
10 | class encodedString; | 10 | class encodedString; |
11 | struct mailmbox_folder; | 11 | struct mailmbox_folder; |
12 | namespace Opie {namespace Core {class OProcess;}} | 12 | namespace Opie {namespace Core {class OProcess;}} |
13 | 13 | ||
14 | class MHwrapper : public Genericwrapper | 14 | class MHwrapper : public Genericwrapper |
15 | { | 15 | { |
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | public: | 17 | public: |
18 | MHwrapper(const QString & dir,const QString&name); | 18 | MHwrapper(const QString & dir,const QString&name); |
19 | virtual ~MHwrapper(); | 19 | virtual ~MHwrapper(); |
20 | 20 | ||
21 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); | 21 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); |
22 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 22 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
24 | 24 | ||
25 | virtual void deleteMail(const RecMailP&mail); | 25 | virtual void deleteMail(const RecMailP&mail); |
26 | virtual void answeredMail(const RecMailP&mail); | 26 | virtual void answeredMail(const RecMailP&mail); |
27 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 27 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
28 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 28 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
29 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 29 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
30 | 30 | ||
31 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, | 31 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, |
32 | const QString&d="",bool s=false); | 32 | const QString&d="",bool s=false); |
33 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); | 33 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); |
34 | 34 | ||
35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
36 | 36 | ||
37 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 37 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
38 | static void mbox_progress( size_t current, size_t maximum ); | 38 | static void mbox_progress( size_t current, size_t maximum ); |
39 | 39 | ||
40 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 40 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
41 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); | 41 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); |
42 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 42 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
43 | virtual MAILLIB::ATYPE getType()const; | 43 | virtual MAILLIB::ATYPE getType()const; |
44 | virtual const QString&getName()const; | 44 | virtual const QString&getName()const; |
45 | virtual Account* getAccount() { return 0; }; | ||
45 | 46 | ||
46 | public slots: | 47 | public slots: |
47 | /* for deleting maildirs we are using a system call */ | 48 | /* for deleting maildirs we are using a system call */ |
48 | virtual void oprocessStderr(Opie::Core::OProcess*, char *buffer, int ); | 49 | virtual void oprocessStderr(Opie::Core::OProcess*, char *buffer, int ); |
49 | virtual void processEnded(Opie::Core::OProcess *); | 50 | virtual void processEnded(Opie::Core::OProcess *); |
50 | protected: | 51 | protected: |
51 | QString buildPath(const QString&p); | 52 | QString buildPath(const QString&p); |
52 | QString MHPath; | 53 | QString MHPath; |
53 | QString MHName; | 54 | QString MHName; |
54 | 55 | ||
55 | void init_storage(); | 56 | void init_storage(); |
56 | void clean_storage(); | 57 | void clean_storage(); |
57 | 58 | ||
58 | bool removeMboxfailed; | 59 | bool removeMboxfailed; |
59 | }; | 60 | }; |
60 | 61 | ||
61 | #endif | 62 | #endif |
diff --git a/kmicromail/libmailwrapper/nntpwrapper.h b/kmicromail/libmailwrapper/nntpwrapper.h index 5d4e5ce..8c54f12 100644 --- a/kmicromail/libmailwrapper/nntpwrapper.h +++ b/kmicromail/libmailwrapper/nntpwrapper.h | |||
@@ -1,49 +1,50 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __NNTPWRAPPER | 2 | #ifndef __NNTPWRAPPER |
3 | #define __NNTPWRAPPER | 3 | #define __NNTPWRAPPER |
4 | 4 | ||
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | #include "genericwrapper.h" | 6 | #include "genericwrapper.h" |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
9 | 9 | ||
10 | class encodedString; | 10 | class encodedString; |
11 | struct mailstorage; | 11 | struct mailstorage; |
12 | struct mailfolder; | 12 | struct mailfolder; |
13 | 13 | ||
14 | class NNTPwrapper : public Genericwrapper | 14 | class NNTPwrapper : public Genericwrapper |
15 | { | 15 | { |
16 | 16 | ||
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | 18 | ||
19 | public: | 19 | public: |
20 | NNTPwrapper( NNTPaccount *a ); | 20 | NNTPwrapper( NNTPaccount *a ); |
21 | virtual ~NNTPwrapper(); | 21 | virtual ~NNTPwrapper(); |
22 | 22 | ||
23 | /* mailbox will be ignored */ | 23 | /* mailbox will be ignored */ |
24 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); | 24 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); |
25 | /* should only get the subscribed one */ | 25 | /* should only get the subscribed one */ |
26 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 26 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
27 | /* mailbox will be ignored */ | 27 | /* mailbox will be ignored */ |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
29 | QStringList listAllNewsgroups(const QString&mask = QString::null); | 29 | QStringList listAllNewsgroups(const QString&mask = QString::null); |
30 | virtual void deleteMail(const RecMailP&mail); | 30 | virtual void deleteMail(const RecMailP&mail); |
31 | virtual void answeredMail(const RecMailP&mail); | 31 | virtual void answeredMail(const RecMailP&mail); |
32 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 32 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
33 | 33 | ||
34 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 34 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
35 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 35 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
36 | virtual void logout(); | 36 | virtual void logout(); |
37 | virtual MAILLIB::ATYPE getType()const; | 37 | virtual MAILLIB::ATYPE getType()const; |
38 | virtual const QString&getName()const; | 38 | virtual const QString&getName()const; |
39 | static void nntp_progress( size_t current, size_t maximum ); | 39 | static void nntp_progress( size_t current, size_t maximum ); |
40 | virtual Account* getAccount() { return account; }; | ||
40 | 41 | ||
41 | protected: | 42 | protected: |
42 | void login(); | 43 | void login(); |
43 | NNTPaccount *account; | 44 | NNTPaccount *account; |
44 | mailstorage* m_nntp; | 45 | mailstorage* m_nntp; |
45 | 46 | ||
46 | 47 | ||
47 | }; | 48 | }; |
48 | 49 | ||
49 | #endif | 50 | #endif |
diff --git a/kmicromail/libmailwrapper/pop3wrapper.h b/kmicromail/libmailwrapper/pop3wrapper.h index 7c70942..ebc2fc7 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.h +++ b/kmicromail/libmailwrapper/pop3wrapper.h | |||
@@ -1,44 +1,44 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __POP3WRAPPER | 2 | #ifndef __POP3WRAPPER |
3 | #define __POP3WRAPPER | 3 | #define __POP3WRAPPER |
4 | 4 | ||
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | #include "genericwrapper.h" | 6 | #include "genericwrapper.h" |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | 8 | ||
9 | class encodedString; | 9 | class encodedString; |
10 | struct mailstorage; | 10 | struct mailstorage; |
11 | struct mailfolder; | 11 | struct mailfolder; |
12 | 12 | ||
13 | class POP3wrapper : public Genericwrapper | 13 | class POP3wrapper : public Genericwrapper |
14 | { | 14 | { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | 16 | ||
17 | public: | 17 | public: |
18 | POP3wrapper( POP3account *a ); | 18 | POP3wrapper( POP3account *a ); |
19 | virtual ~POP3wrapper(); | 19 | virtual ~POP3wrapper(); |
20 | /* mailbox will be ignored */ | 20 | /* mailbox will be ignored */ |
21 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); | 21 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); |
22 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 22 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
23 | /* mailbox will be ignored */ | 23 | /* mailbox will be ignored */ |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
25 | 25 | ||
26 | virtual void deleteMail(const RecMailP&mail); | 26 | virtual void deleteMail(const RecMailP&mail); |
27 | virtual void deleteMailList(const QValueList<RecMailP>&target); | 27 | virtual void deleteMailList(const QValueList<RecMailP>&target); |
28 | virtual void answeredMail(const RecMailP&mail); | 28 | virtual void answeredMail(const RecMailP&mail); |
29 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 29 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
30 | 30 | ||
31 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 31 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
32 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 32 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
33 | virtual void logout(); | 33 | virtual void logout(); |
34 | virtual MAILLIB::ATYPE getType()const; | 34 | virtual MAILLIB::ATYPE getType()const; |
35 | virtual const QString&getName()const; | 35 | virtual const QString&getName()const; |
36 | static void pop3_progress( size_t current, size_t maximum ); | 36 | static void pop3_progress( size_t current, size_t maximum ); |
37 | 37 | virtual Account* getAccount() { return account; }; | |
38 | protected: | 38 | protected: |
39 | void login(); | 39 | void login(); |
40 | POP3account *account; | 40 | POP3account *account; |
41 | mailstorage*m_pop3; | 41 | mailstorage*m_pop3; |
42 | }; | 42 | }; |
43 | 43 | ||
44 | #endif | 44 | #endif |
diff --git a/kmicromail/libmailwrapper/smtpwrapper.h b/kmicromail/libmailwrapper/smtpwrapper.h index 105cbf5..ec42b56 100644 --- a/kmicromail/libmailwrapper/smtpwrapper.h +++ b/kmicromail/libmailwrapper/smtpwrapper.h | |||
@@ -1,63 +1,64 @@ | |||
1 | // -*- Mode: C++; -*- | 1 | // -*- Mode: C++; -*- |
2 | #ifndef SMTPwrapper_H | 2 | #ifndef SMTPwrapper_H |
3 | #define SMTPwrapper_H | 3 | #define SMTPwrapper_H |
4 | 4 | ||
5 | #include <qpe/applnk.h> | 5 | #include <qpe/applnk.h> |
6 | 6 | ||
7 | #include <qbitarray.h> | 7 | #include <qbitarray.h> |
8 | #include <qdatetime.h> | 8 | #include <qdatetime.h> |
9 | #include <libetpan/clist.h> | 9 | #include <libetpan/clist.h> |
10 | 10 | ||
11 | #include "settings.h" | 11 | #include "settings.h" |
12 | #include "generatemail.h" | 12 | #include "generatemail.h" |
13 | 13 | ||
14 | #include <opie2/osmartpointer.h> | 14 | #include <opie2/osmartpointer.h> |
15 | 15 | ||
16 | class SMTPaccount; | 16 | class SMTPaccount; |
17 | class AbstractMail; | 17 | class AbstractMail; |
18 | 18 | ||
19 | class SMTPwrapper : public Generatemail | 19 | class SMTPwrapper : public Generatemail |
20 | { | 20 | { |
21 | Q_OBJECT | 21 | Q_OBJECT |
22 | 22 | ||
23 | public: | 23 | public: |
24 | SMTPwrapper(SMTPaccount * aSmtp); | 24 | SMTPwrapper(SMTPaccount * aSmtp); |
25 | virtual ~SMTPwrapper(); | 25 | virtual ~SMTPwrapper(); |
26 | bool sendMail(const Opie::Core::OSmartPointer<Mail>& mail,bool later=false ); | 26 | bool sendMail(const Opie::Core::OSmartPointer<Mail>& mail,bool later=false ); |
27 | bool flushOutbox(); | 27 | bool flushOutbox(); |
28 | 28 | ||
29 | static progressMailSend*sendProgress; | 29 | static progressMailSend*sendProgress; |
30 | virtual Account* getAccount() { return m_SmtpAccount; }; | ||
30 | 31 | ||
31 | signals: | 32 | signals: |
32 | void queuedMails( int ); | 33 | void queuedMails( int ); |
33 | 34 | ||
34 | protected: | 35 | protected: |
35 | mailsmtp *m_smtp; | 36 | mailsmtp *m_smtp; |
36 | SMTPaccount * m_SmtpAccount; | 37 | SMTPaccount * m_SmtpAccount; |
37 | 38 | ||
38 | void connect_server(); | 39 | void connect_server(); |
39 | void disc_server(); | 40 | void disc_server(); |
40 | int start_smtp_tls(); | 41 | int start_smtp_tls(); |
41 | 42 | ||
42 | 43 | ||
43 | bool smtpSend( mailmime *mail,bool later); | 44 | bool smtpSend( mailmime *mail,bool later); |
44 | 45 | ||
45 | static void storeMail(const char*mail, size_t length, const QString&box); | 46 | static void storeMail(const char*mail, size_t length, const QString&box); |
46 | static QString mailsmtpError( int err ); | 47 | static QString mailsmtpError( int err ); |
47 | static void progress( size_t current, size_t maximum ); | 48 | static void progress( size_t current, size_t maximum ); |
48 | 49 | ||
49 | int smtpSend(char*from,clist*rcpts,const char*data,size_t size); | 50 | int smtpSend(char*from,clist*rcpts,const char*data,size_t size); |
50 | 51 | ||
51 | void storeMail(mailmime*mail, const QString&box); | 52 | void storeMail(mailmime*mail, const QString&box); |
52 | 53 | ||
53 | int sendQueuedMail(AbstractMail*wrap,const Opie::Core::OSmartPointer<RecMail>&which); | 54 | int sendQueuedMail(AbstractMail*wrap,const Opie::Core::OSmartPointer<RecMail>&which); |
54 | void storeFailedMail(const char*data,unsigned int size, const char*failuremessage); | 55 | void storeFailedMail(const char*data,unsigned int size, const char*failuremessage); |
55 | 56 | ||
56 | int m_queuedMail; | 57 | int m_queuedMail; |
57 | 58 | ||
58 | protected slots: | 59 | protected slots: |
59 | void emitQCop( int queued ); | 60 | void emitQCop( int queued ); |
60 | 61 | ||
61 | }; | 62 | }; |
62 | 63 | ||
63 | #endif | 64 | #endif |
diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp index b92b0cf..484a635 100644 --- a/kmicromail/mailistviewitem.cpp +++ b/kmicromail/mailistviewitem.cpp | |||
@@ -1,143 +1,146 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #include "mailistviewitem.h" | 2 | #include "mailistviewitem.h" |
3 | #include <libmailwrapper/abstractmail.h> | 3 | #include <libmailwrapper/abstractmail.h> |
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | #include <kiconloader.h> | 5 | #include <kiconloader.h> |
6 | //#include <qpe/resource.h> | 6 | //#include <qpe/resource.h> |
7 | 7 | ||
8 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 8 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
9 | :QListViewItem(parent,item),mail_data() | 9 | :QListViewItem(parent,item),mail_data() |
10 | { | 10 | { |
11 | } | 11 | } |
12 | 12 | ||
13 | void MailListViewItem::showEntry() | 13 | void MailListViewItem::showEntry() |
14 | { | 14 | { |
15 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { | 15 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { |
16 | setPixmap( 0, SmallIcon ( "kmmsgreplied") ); | 16 | setPixmap( 0, SmallIcon ( "kmmsgreplied") ); |
17 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { | 17 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { |
18 | /* I think it looks nicer if there are not such a log of icons but only on mails | 18 | /* I think it looks nicer if there are not such a log of icons but only on mails |
19 | replied or new - Alwin*/ | 19 | replied or new - Alwin*/ |
20 | //setPixmap( 0,SmallIcon ("kmmsgunseen") ); | 20 | //setPixmap( 0,SmallIcon ("kmmsgunseen") ); |
21 | } else { | 21 | } else { |
22 | setPixmap( 0,SmallIcon ( "kmmsgnew") ); | 22 | setPixmap( 0,SmallIcon ( "kmmsgnew") ); |
23 | } | 23 | } |
24 | double s = mail_data->Msgsize(); | 24 | double s = mail_data->Msgsize(); |
25 | int w = 0; | 25 | int w = 0; |
26 | s/=1024; | 26 | s/=1024; |
27 | if (s>999.0) { | 27 | if (s>999.0) { |
28 | s/=1024.0; | 28 | s/=1024.0; |
29 | ++w; | 29 | ++w; |
30 | } | 30 | } |
31 | QString fsort; | 31 | QString fsort; |
32 | fsort.sprintf( "%.2f", s ); | 32 | fsort.sprintf( "%.2f", s ); |
33 | QString fsize = QString::number( s, 'f', 2 ); | 33 | QString fsize = QString::number( s, 'f', 2 ); |
34 | // 1.23 | 34 | // 1.23 |
35 | // 11.23 | 35 | // 11.23 |
36 | // 111.23 | 36 | // 111.23 |
37 | // 999.23 maxlen | 37 | // 999.23 maxlen |
38 | switch(fsize.length() ) { | 38 | switch(fsize.length() ) { |
39 | case 4: | 39 | case 4: |
40 | fsort = "00" + fsize ; | 40 | fsort = "00" + fsize ; |
41 | break; | 41 | break; |
42 | case 5: | 42 | case 5: |
43 | fsort = "0" + fsize ; | 43 | fsort = "0" + fsize ; |
44 | break; | 44 | break; |
45 | default: | 45 | default: |
46 | fsort = fsize ; | 46 | fsort = fsize ; |
47 | break; | 47 | break; |
48 | 48 | ||
49 | } | 49 | } |
50 | if ( w == 0 ) { | 50 | if ( w == 0 ) { |
51 | setText(3, fsize + "kB" ); | 51 | setText(3, fsize + "kB" ); |
52 | mKeyMap.insert(3, "k" + fsort); | 52 | mKeyMap.insert(3, "k" + fsort); |
53 | //setText(3, "kB" + fsort ); // test only | 53 | //setText(3, "kB" + fsort ); // test only |
54 | } else { | 54 | } else { |
55 | //setText(3, fsize + "MB"); | 55 | //setText(3, fsize + "MB"); |
56 | mKeyMap.insert(4, "M" +fsort ); | 56 | mKeyMap.insert(3, "M" +fsort ); |
57 | } | 57 | } |
58 | setText(1,mail_data->getSubject()); | 58 | setText(1,mail_data->getSubject()); |
59 | setText(2,mail_data->getFrom()); | 59 | setText(2,mail_data->getFrom()); |
60 | 60 | #if 0 | |
61 | QString date = mail_data->getDate(); | 61 | QString date = mail_data->getDate(); |
62 | 62 | ||
63 | int kom = date.find( ",")+2; | 63 | int kom = date.find( ",")+2; |
64 | if ( kom == 1 ) | 64 | if ( kom == 1 ) |
65 | kom = 0; | 65 | kom = 0; |
66 | if ( date.mid(kom,1) == " ") | 66 | if ( date.mid(kom,1) == " ") |
67 | ++kom; | 67 | ++kom; |
68 | if ( date.mid(kom+1,1) == " " ) | 68 | if ( date.mid(kom+1,1) == " " ) |
69 | date = "0" + date.mid( kom ); | 69 | date = "0" + date.mid( kom ); |
70 | else if ( kom ) | 70 | else if ( kom ) |
71 | date = date.mid( kom ); | 71 | date = date.mid( kom ); |
72 | if ( kom || date.mid(2,1 ) == " ") { | 72 | if ( kom || date.mid(2,1 ) == " ") { |
73 | QString mon = date.mid(3,3); | 73 | QString mon = date.mid(3,3); |
74 | QString so = 00; | 74 | QString so = 00; |
75 | if ( mon == "Jan" ) | 75 | if ( mon == "Jan" ) |
76 | so = "01"; | 76 | so = "01"; |
77 | else if ( mon == "Feb" ) | 77 | else if ( mon == "Feb" ) |
78 | so = "02"; | 78 | so = "02"; |
79 | else if ( mon == "Mar" ) | 79 | else if ( mon == "Mar" ) |
80 | so = "03"; | 80 | so = "03"; |
81 | else if ( mon == "Apr" ) | 81 | else if ( mon == "Apr" ) |
82 | so = "04"; | 82 | so = "04"; |
83 | else if ( mon == "May" ) | 83 | else if ( mon == "May" ) |
84 | so = "05"; | 84 | so = "05"; |
85 | else if ( mon == "Jun" ) | 85 | else if ( mon == "Jun" ) |
86 | so = "06"; | 86 | so = "06"; |
87 | else if ( mon == "Jul" ) | 87 | else if ( mon == "Jul" ) |
88 | so = "07"; | 88 | so = "07"; |
89 | else if ( mon == "Aug" ) | 89 | else if ( mon == "Aug" ) |
90 | so = "08"; | 90 | so = "08"; |
91 | else if ( mon == "Sep" ) | 91 | else if ( mon == "Sep" ) |
92 | so = "09"; | 92 | so = "09"; |
93 | else if ( mon == "Oct" ) | 93 | else if ( mon == "Oct" ) |
94 | so = "10"; | 94 | so = "10"; |
95 | else if ( mon == "Nov" ) | 95 | else if ( mon == "Nov" ) |
96 | so = "11"; | 96 | so = "11"; |
97 | else if ( mon == "Dec" ) | 97 | else if ( mon == "Dec" ) |
98 | so = "12"; | 98 | so = "12"; |
99 | date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); | 99 | date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); |
100 | } | 100 | } |
101 | //qDebug("insert Date %s ", date.latin1()); | ||
101 | // if ( date.left(1) != "1" || date.left(1) != "2" ) | 102 | // if ( date.left(1) != "1" || date.left(1) != "2" ) |
102 | // date = date.mid(5); | 103 | // date = date.mid(5); |
103 | mKeyMap.insert(4,date); | 104 | mKeyMap.insert(4,date); |
105 | #endif | ||
106 | mKeyMap.insert(4,mail_data->getIsoDate()); | ||
104 | setText(4,mail_data->getDate()); | 107 | setText(4,mail_data->getDate()); |
105 | } | 108 | } |
106 | 109 | ||
107 | void MailListViewItem::storeData(const RecMailP&data) | 110 | void MailListViewItem::storeData(const RecMailP&data) |
108 | { | 111 | { |
109 | mail_data = data; | 112 | mail_data = data; |
110 | } | 113 | } |
111 | void MailListViewItem::setSortKey(int column,const QString &key) | 114 | void MailListViewItem::setSortKey(int column,const QString &key) |
112 | { | 115 | { |
113 | mKeyMap.insert(column,key); | 116 | mKeyMap.insert(column,key); |
114 | } | 117 | } |
115 | QString MailListViewItem::key(int column, bool) const | 118 | QString MailListViewItem::key(int column, bool) const |
116 | { | 119 | { |
117 | // to make is fast, we use here special cases | 120 | // to make is fast, we use here special cases |
118 | if ( column == 3 || column == 4 ) { | 121 | if ( column == 3 || column == 4 ) { |
119 | return *mKeyMap.find(column); | 122 | return *mKeyMap.find(column); |
120 | } | 123 | } |
121 | if ( column == 1 ) { | 124 | if ( column == 1 ) { |
122 | if ( text(1).left(4).lower() == "re: " ) | 125 | if ( text(1).left(4).lower() == "re: " ) |
123 | return text(1).mid(4); | 126 | return text(1).mid(4); |
124 | 127 | ||
125 | } | 128 | } |
126 | return text(column); | 129 | return text(column); |
127 | /* | 130 | /* |
128 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | 131 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); |
129 | if (it == mKeyMap.end()) return text(column); | 132 | if (it == mKeyMap.end()) return text(column); |
130 | else return *it; | 133 | else return *it; |
131 | */ | 134 | */ |
132 | } | 135 | } |
133 | 136 | ||
134 | const RecMailP& MailListViewItem::data()const | 137 | const RecMailP& MailListViewItem::data()const |
135 | { | 138 | { |
136 | return mail_data; | 139 | return mail_data; |
137 | } | 140 | } |
138 | 141 | ||
139 | MAILLIB::ATYPE MailListViewItem::wrapperType() | 142 | MAILLIB::ATYPE MailListViewItem::wrapperType() |
140 | { | 143 | { |
141 | if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; | 144 | if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; |
142 | return mail_data->Wrapper()->getType(); | 145 | return mail_data->Wrapper()->getType(); |
143 | } | 146 | } |