23 files changed, 230 insertions, 196 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index e4bb6c5..54d2da2 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp | |||
@@ -1,464 +1,464 @@ | |||
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 | /* OPIE */ | 8 | /* OPIE */ |
9 | #include <libmailwrapper/mailtypes.h> | 9 | #include <libmailwrapper/mailtypes.h> |
10 | #include <libmailwrapper/abstractmail.h> | 10 | #include <libmailwrapper/abstractmail.h> |
11 | #include <libmailwrapper/mailwrapper.h> | 11 | #include <libmailwrapper/mailwrapper.h> |
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 | 17 | ||
18 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
19 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 19 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
20 | /** | 20 | /** |
21 | * POP3 Account stuff | 21 | * POP3 Account stuff |
22 | */ | 22 | */ |
23 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 23 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
24 | : AccountViewItem( parent ) | 24 | : AccountViewItem( parent ) |
25 | { | 25 | { |
26 | account = a; | 26 | account = a; |
27 | wrapper = AbstractMail::getWrapper( account ); | 27 | wrapper = AbstractMail::getWrapper( account ); |
28 | SETPIX(PIXMAP_POP3FOLDER); | 28 | SETPIX(PIXMAP_POP3FOLDER); |
29 | #if 0 | 29 | #if 0 |
30 | if (!account->getOffline()) | 30 | if (!account->getOffline()) |
31 | { | 31 | { |
32 | setPixmap( 0, ); | 32 | setPixmap( 0, ); |
33 | } | 33 | } |
34 | else | 34 | else |
35 | { | 35 | { |
36 | setPixmap( 0, PIXMAP_OFFLINE ); | 36 | setPixmap( 0, PIXMAP_OFFLINE ); |
37 | } | 37 | } |
38 | #endif | 38 | #endif |
39 | setText( 0, account->getAccountName() ); | 39 | setText( 0, account->getAccountName() ); |
40 | setOpen( true ); | 40 | setOpen( true ); |
41 | } | 41 | } |
42 | 42 | ||
43 | POP3viewItem::~POP3viewItem() | 43 | POP3viewItem::~POP3viewItem() |
44 | { | 44 | { |
45 | delete wrapper; | 45 | delete wrapper; |
46 | } | 46 | } |
47 | 47 | ||
48 | AbstractMail *POP3viewItem::getWrapper() | 48 | AbstractMail *POP3viewItem::getWrapper() |
49 | { | 49 | { |
50 | return wrapper; | 50 | return wrapper; |
51 | } | 51 | } |
52 | 52 | ||
53 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 53 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
54 | { | 54 | { |
55 | refresh(); | 55 | refresh(); |
56 | } | 56 | } |
57 | 57 | ||
58 | void POP3viewItem::refresh() | 58 | void POP3viewItem::refresh() |
59 | { | 59 | { |
60 | if (account->getOffline()) return; | 60 | if (account->getOffline()) return; |
61 | QValueList<FolderP> *folders = wrapper->listFolders(); | 61 | QValueList<FolderP> *folders = wrapper->listFolders(); |
62 | QListViewItem *child = firstChild(); | 62 | QListViewItem *child = firstChild(); |
63 | while ( child ) | 63 | while ( child ) |
64 | { | 64 | { |
65 | QListViewItem *tmp = child; | 65 | QListViewItem *tmp = child; |
66 | child = child->nextSibling(); | 66 | child = child->nextSibling(); |
67 | delete tmp; | 67 | delete tmp; |
68 | } | 68 | } |
69 | QValueList<FolderP>::ConstIterator it; | 69 | QValueList<FolderP>::ConstIterator it; |
70 | QListViewItem*item = 0; | 70 | QListViewItem*item = 0; |
71 | for ( it = folders->begin(); it!=folders->end(); ++it) | 71 | for ( it = folders->begin(); it!=folders->end(); ++it) |
72 | { | 72 | { |
73 | item = new POP3folderItem( (*it), this , item ); | 73 | item = new POP3folderItem( (*it), this , item ); |
74 | item->setSelectable( (*it)->may_select()); | 74 | item->setSelectable( (*it)->may_select()); |
75 | } | 75 | } |
76 | delete folders; | 76 | delete folders; |
77 | } | 77 | } |
78 | 78 | ||
79 | RecBody POP3viewItem::fetchBody( const RecMailP &mail ) | 79 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
80 | { | 80 | { |
81 | qDebug( "POP3 fetchBody" ); | 81 | qDebug( "POP3 fetchBody" ); |
82 | return wrapper->fetchBody( mail ); | 82 | return wrapper->fetchBody( mail ); |
83 | } | 83 | } |
84 | 84 | ||
85 | QPopupMenu * POP3viewItem::getContextMenu() | 85 | QPopupMenu * POP3viewItem::getContextMenu() |
86 | { | 86 | { |
87 | QPopupMenu *m = new QPopupMenu(0); | 87 | QPopupMenu *m = new QPopupMenu(0); |
88 | if (m) | 88 | if (m) |
89 | { | 89 | { |
90 | if (!account->getOffline()) | 90 | if (!account->getOffline()) |
91 | { | 91 | { |
92 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 92 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
93 | m->insertItem(QObject::tr("Set offline",contextName),1); | 93 | m->insertItem(QObject::tr("Set offline",contextName),1); |
94 | } | 94 | } |
95 | else | 95 | else |
96 | { | 96 | { |
97 | m->insertItem(QObject::tr("Set online",contextName),1); | 97 | m->insertItem(QObject::tr("Set online",contextName),1); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | return m; | 100 | return m; |
101 | } | 101 | } |
102 | 102 | ||
103 | void POP3viewItem::disconnect() | 103 | void POP3viewItem::disconnect() |
104 | { | 104 | { |
105 | QListViewItem *child = firstChild(); | 105 | QListViewItem *child = firstChild(); |
106 | while ( child ) | 106 | while ( child ) |
107 | { | 107 | { |
108 | QListViewItem *tmp = child; | 108 | QListViewItem *tmp = child; |
109 | child = child->nextSibling(); | 109 | child = child->nextSibling(); |
110 | delete tmp; | 110 | delete tmp; |
111 | } | 111 | } |
112 | wrapper->logout(); | 112 | wrapper->logout(); |
113 | } | 113 | } |
114 | 114 | ||
115 | void POP3viewItem::setOnOffline() | 115 | void POP3viewItem::setOnOffline() |
116 | { | 116 | { |
117 | if (!account->getOffline()) | 117 | if (!account->getOffline()) |
118 | { | 118 | { |
119 | disconnect(); | 119 | disconnect(); |
120 | } | 120 | } |
121 | account->setOffline(!account->getOffline()); | 121 | account->setOffline(!account->getOffline()); |
122 | account->save(); | 122 | account->save(); |
123 | SETPIX(PIXMAP_POP3FOLDER); | 123 | SETPIX(PIXMAP_POP3FOLDER); |
124 | refresh(); | 124 | refresh(); |
125 | } | 125 | } |
126 | 126 | ||
127 | void POP3viewItem::contextMenuSelected(int which) | 127 | void POP3viewItem::contextMenuSelected(int which) |
128 | { | 128 | { |
129 | switch (which) | 129 | switch (which) |
130 | { | 130 | { |
131 | case 0: | 131 | case 0: |
132 | disconnect(); | 132 | disconnect(); |
133 | break; | 133 | break; |
134 | case 1: | 134 | case 1: |
135 | setOnOffline(); | 135 | setOnOffline(); |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | POP3folderItem::~POP3folderItem() | 140 | POP3folderItem::~POP3folderItem() |
141 | {} | 141 | {} |
142 | 142 | ||
143 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 143 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
144 | : AccountViewItem(folderInit,parent,after ) | 144 | : AccountViewItem(folderInit,parent,after ) |
145 | { | 145 | { |
146 | pop3 = parent; | 146 | pop3 = parent; |
147 | if (folder->getDisplayName().lower()!="inbox") | 147 | if (folder->getDisplayName().lower()!="inbox") |
148 | { | 148 | { |
149 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 149 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
150 | } | 150 | } |
151 | else | 151 | else |
152 | { | 152 | { |
153 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 153 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
154 | } | 154 | } |
155 | setText( 0, folder->getDisplayName() ); | 155 | setText( 0, folder->getDisplayName() ); |
156 | } | 156 | } |
157 | 157 | ||
158 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 158 | void POP3folderItem::refresh(QValueList<RecMailP>&target) |
159 | { | 159 | { |
160 | if (folder->may_select()) | 160 | if (folder->may_select()) |
161 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 161 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
162 | } | 162 | } |
163 | 163 | ||
164 | RecBody POP3folderItem::fetchBody(const RecMailP&aMail) | 164 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
165 | { | 165 | { |
166 | return pop3->getWrapper()->fetchBody(aMail); | 166 | return pop3->getWrapper()->fetchBody(aMail); |
167 | } | 167 | } |
168 | 168 | ||
169 | QPopupMenu * POP3folderItem::getContextMenu() | 169 | QPopupMenu * POP3folderItem::getContextMenu() |
170 | { | 170 | { |
171 | QPopupMenu *m = new QPopupMenu(0); | 171 | QPopupMenu *m = new QPopupMenu(0); |
172 | if (m) | 172 | if (m) |
173 | { | 173 | { |
174 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 174 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
175 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 175 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
176 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 176 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
177 | } | 177 | } |
178 | return m; | 178 | return m; |
179 | } | 179 | } |
180 | 180 | ||
181 | void POP3folderItem::downloadMails() | 181 | void POP3folderItem::downloadMails() |
182 | { | 182 | { |
183 | AccountView*bl = pop3->accountView(); | 183 | AccountView*bl = pop3->accountView(); |
184 | if (!bl) return; | 184 | if (!bl) return; |
185 | bl->downloadMails(folder,pop3->getWrapper()); | 185 | bl->downloadMails(folder,pop3->getWrapper()); |
186 | } | 186 | } |
187 | 187 | ||
188 | void POP3folderItem::contextMenuSelected(int which) | 188 | void POP3folderItem::contextMenuSelected(int which) |
189 | { | 189 | { |
190 | AccountView * view = (AccountView*)listView(); | 190 | AccountView * view = (AccountView*)listView(); |
191 | switch (which) | 191 | switch (which) |
192 | { | 192 | { |
193 | case 0: | 193 | case 0: |
194 | /* must be 'cause pop3 lists are cached */ | 194 | /* must be 'cause pop3 lists are cached */ |
195 | pop3->getWrapper()->logout(); | 195 | pop3->getWrapper()->logout(); |
196 | view->refreshCurrent(); | 196 | view->refreshCurrent(); |
197 | break; | 197 | break; |
198 | case 1: | 198 | case 1: |
199 | deleteAllMail(pop3->getWrapper(),folder); | 199 | deleteAllMail(pop3->getWrapper(),folder); |
200 | break; | 200 | break; |
201 | case 2: | 201 | case 2: |
202 | downloadMails(); | 202 | downloadMails(); |
203 | break; | 203 | break; |
204 | default: | 204 | default: |
205 | break; | 205 | break; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * NNTP Account stuff | 210 | * NNTP Account stuff |
211 | */ | 211 | */ |
212 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 212 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
213 | : AccountViewItem( parent ) | 213 | : AccountViewItem( parent ) |
214 | { | 214 | { |
215 | account = a; | 215 | account = a; |
216 | wrapper = AbstractMail::getWrapper( account ); | 216 | wrapper = AbstractMail::getWrapper( account ); |
217 | //FIXME | 217 | //FIXME |
218 | SETPIX(PIXMAP_POP3FOLDER); | 218 | SETPIX(PIXMAP_POP3FOLDER); |
219 | #if 0 | 219 | #if 0 |
220 | if (!account->getOffline()) | 220 | if (!account->getOffline()) |
221 | { | 221 | { |
222 | setPixmap( 0, ); | 222 | setPixmap( 0, ); |
223 | } | 223 | } |
224 | else | 224 | else |
225 | { | 225 | { |
226 | setPixmap( 0, PIXMAP_OFFLINE ); | 226 | setPixmap( 0, PIXMAP_OFFLINE ); |
227 | } | 227 | } |
228 | #endif | 228 | #endif |
229 | setText( 0, account->getAccountName() ); | 229 | setText( 0, account->getAccountName() ); |
230 | setOpen( true ); | 230 | setOpen( true ); |
231 | } | 231 | } |
232 | 232 | ||
233 | NNTPviewItem::~NNTPviewItem() | 233 | NNTPviewItem::~NNTPviewItem() |
234 | { | 234 | { |
235 | delete wrapper; | 235 | delete wrapper; |
236 | } | 236 | } |
237 | 237 | ||
238 | AbstractMail *NNTPviewItem::getWrapper() | 238 | AbstractMail *NNTPviewItem::getWrapper() |
239 | { | 239 | { |
240 | return wrapper; | 240 | return wrapper; |
241 | } | 241 | } |
242 | 242 | ||
243 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) | 243 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) |
244 | { | 244 | { |
245 | refresh(); | 245 | refresh(); |
246 | } | 246 | } |
247 | 247 | ||
248 | void NNTPviewItem::refresh() | 248 | void NNTPviewItem::refresh() |
249 | { | 249 | { |
250 | if (account->getOffline()) return; | 250 | if (account->getOffline()) return; |
251 | QValueList<FolderP> *folders = wrapper->listFolders(); | 251 | QValueList<FolderP> *folders = wrapper->listFolders(); |
252 | 252 | ||
253 | QListViewItem *child = firstChild(); | 253 | QListViewItem *child = firstChild(); |
254 | while ( child ) | 254 | while ( child ) |
255 | { | 255 | { |
256 | QListViewItem *tmp = child; | 256 | QListViewItem *tmp = child; |
257 | child = child->nextSibling(); | 257 | child = child->nextSibling(); |
258 | delete tmp; | 258 | delete tmp; |
259 | } | 259 | } |
260 | QValueList<FolderP>::ConstIterator it; | 260 | QValueList<FolderP>::ConstIterator it; |
261 | QListViewItem*item = 0; | 261 | QListViewItem*item = 0; |
262 | for ( it = folders->begin(); it!=folders->end(); ++it) | 262 | for ( it = folders->begin(); it!=folders->end(); ++it) |
263 | { | 263 | { |
264 | item = new NNTPfolderItem( (*it), this , item ); | 264 | item = new NNTPfolderItem( (*it), this , item ); |
265 | item->setSelectable( (*it)->may_select()); | 265 | item->setSelectable( (*it)->may_select()); |
266 | } | 266 | } |
267 | delete folders; | 267 | delete folders; |
268 | } | 268 | } |
269 | 269 | ||
270 | RecBody NNTPviewItem::fetchBody( const RecMailP &mail ) | 270 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) |
271 | { | 271 | { |
272 | qDebug( "NNTP fetchBody" ); | 272 | qDebug( "NNTP fetchBody" ); |
273 | return wrapper->fetchBody( mail ); | 273 | return wrapper->fetchBody( mail ); |
274 | } | 274 | } |
275 | 275 | ||
276 | QPopupMenu * NNTPviewItem::getContextMenu() | 276 | QPopupMenu * NNTPviewItem::getContextMenu() |
277 | { | 277 | { |
278 | QPopupMenu *m = new QPopupMenu(0); | 278 | QPopupMenu *m = new QPopupMenu(0); |
279 | if (m) | 279 | if (m) |
280 | { | 280 | { |
281 | if (!account->getOffline()) | 281 | if (!account->getOffline()) |
282 | { | 282 | { |
283 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 283 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
284 | m->insertItem(QObject::tr("Set offline",contextName),1); | 284 | m->insertItem(QObject::tr("Set offline",contextName),1); |
285 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); | 285 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); |
286 | } | 286 | } |
287 | else | 287 | else |
288 | { | 288 | { |
289 | m->insertItem(QObject::tr("Set online",contextName),1); | 289 | m->insertItem(QObject::tr("Set online",contextName),1); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | return m; | 292 | return m; |
293 | } | 293 | } |
294 | 294 | ||
295 | void NNTPviewItem::subscribeGroups() | 295 | void NNTPviewItem::subscribeGroups() |
296 | { | 296 | { |
297 | NNTPGroupsDlg dlg(account); | 297 | NNTPGroupsDlg dlg(account); |
298 | if (QPEApplication::execDialog(&dlg)== QDialog::Accepted ){ | 298 | if (QPEApplication::execDialog(&dlg)== QDialog::Accepted ){ |
299 | refresh(); | 299 | refresh(); |
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | void NNTPviewItem::disconnect() | 303 | void NNTPviewItem::disconnect() |
304 | { | 304 | { |
305 | QListViewItem *child = firstChild(); | 305 | QListViewItem *child = firstChild(); |
306 | while ( child ) | 306 | while ( child ) |
307 | { | 307 | { |
308 | QListViewItem *tmp = child; | 308 | QListViewItem *tmp = child; |
309 | child = child->nextSibling(); | 309 | child = child->nextSibling(); |
310 | delete tmp; | 310 | delete tmp; |
311 | } | 311 | } |
312 | wrapper->logout(); | 312 | wrapper->logout(); |
313 | } | 313 | } |
314 | 314 | ||
315 | void NNTPviewItem::setOnOffline() | 315 | void NNTPviewItem::setOnOffline() |
316 | { | 316 | { |
317 | if (!account->getOffline()) | 317 | if (!account->getOffline()) |
318 | { | 318 | { |
319 | disconnect(); | 319 | disconnect(); |
320 | } | 320 | } |
321 | account->setOffline(!account->getOffline()); | 321 | account->setOffline(!account->getOffline()); |
322 | account->save(); | 322 | account->save(); |
323 | //FIXME | 323 | //FIXME |
324 | SETPIX(PIXMAP_POP3FOLDER); | 324 | SETPIX(PIXMAP_POP3FOLDER); |
325 | refresh(); | 325 | refresh(); |
326 | } | 326 | } |
327 | 327 | ||
328 | void NNTPviewItem::contextMenuSelected(int which) | 328 | void NNTPviewItem::contextMenuSelected(int which) |
329 | { | 329 | { |
330 | switch (which) | 330 | switch (which) |
331 | { | 331 | { |
332 | case 0: | 332 | case 0: |
333 | disconnect(); | 333 | disconnect(); |
334 | break; | 334 | break; |
335 | case 1: | 335 | case 1: |
336 | setOnOffline(); | 336 | setOnOffline(); |
337 | break; | 337 | break; |
338 | case 2: | 338 | case 2: |
339 | subscribeGroups(); | 339 | subscribeGroups(); |
340 | break; | 340 | break; |
341 | } | 341 | } |
342 | } | 342 | } |
343 | 343 | ||
344 | NNTPfolderItem::~NNTPfolderItem() | 344 | NNTPfolderItem::~NNTPfolderItem() |
345 | {} | 345 | {} |
346 | 346 | ||
347 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) | 347 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) |
348 | : AccountViewItem( folderInit, parent,after ) | 348 | : AccountViewItem( folderInit, parent,after ) |
349 | { | 349 | { |
350 | nntp = parent; | 350 | nntp = parent; |
351 | if (folder->getDisplayName().lower()!="inbox") | 351 | if (folder->getDisplayName().lower()!="inbox") |
352 | { | 352 | { |
353 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 353 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
354 | } | 354 | } |
355 | else | 355 | else |
356 | { | 356 | { |
357 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 357 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
358 | } | 358 | } |
359 | setText( 0, folder->getDisplayName() ); | 359 | setText( 0, folder->getDisplayName() ); |
360 | } | 360 | } |
361 | 361 | ||
362 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) | 362 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) |
363 | { | 363 | { |
364 | if (folder->may_select()) | 364 | if (folder->may_select()) |
365 | nntp->getWrapper()->listMessages( folder->getName(),target ); | 365 | nntp->getWrapper()->listMessages( folder->getName(),target ); |
366 | } | 366 | } |
367 | 367 | ||
368 | RecBody NNTPfolderItem::fetchBody(const RecMailP&aMail) | 368 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) |
369 | { | 369 | { |
370 | return nntp->getWrapper()->fetchBody(aMail); | 370 | return nntp->getWrapper()->fetchBody(aMail); |
371 | } | 371 | } |
372 | 372 | ||
373 | QPopupMenu * NNTPfolderItem::getContextMenu() | 373 | QPopupMenu * NNTPfolderItem::getContextMenu() |
374 | { | 374 | { |
375 | QPopupMenu *m = new QPopupMenu(0); | 375 | QPopupMenu *m = new QPopupMenu(0); |
376 | if (m) | 376 | if (m) |
377 | { | 377 | { |
378 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 378 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
379 | m->insertItem(QObject::tr("Copy all postings",contextName),1); | 379 | m->insertItem(QObject::tr("Copy all postings",contextName),1); |
380 | } | 380 | } |
381 | return m; | 381 | return m; |
382 | } | 382 | } |
383 | 383 | ||
384 | void NNTPfolderItem::downloadMails() | 384 | void NNTPfolderItem::downloadMails() |
385 | { | 385 | { |
386 | AccountView*bl = nntp->accountView(); | 386 | AccountView*bl = nntp->accountView(); |
387 | if (!bl) return; | 387 | if (!bl) return; |
388 | bl->downloadMails(folder,nntp->getWrapper()); | 388 | bl->downloadMails(folder,nntp->getWrapper()); |
389 | } | 389 | } |
390 | 390 | ||
391 | void NNTPfolderItem::contextMenuSelected(int which) | 391 | void NNTPfolderItem::contextMenuSelected(int which) |
392 | { | 392 | { |
393 | AccountView * view = (AccountView*)listView(); | 393 | AccountView * view = (AccountView*)listView(); |
394 | switch (which) | 394 | switch (which) |
395 | { | 395 | { |
396 | case 0: | 396 | case 0: |
397 | /* must be 'cause pop3 lists are cached */ | 397 | /* must be 'cause pop3 lists are cached */ |
398 | nntp->getWrapper()->logout(); | 398 | nntp->getWrapper()->logout(); |
399 | view->refreshCurrent(); | 399 | view->refreshCurrent(); |
400 | break; | 400 | break; |
401 | case 1: | 401 | case 1: |
402 | downloadMails(); | 402 | downloadMails(); |
403 | break; | 403 | break; |
404 | default: | 404 | default: |
405 | break; | 405 | break; |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | /** | 409 | /** |
410 | * IMAP Account stuff | 410 | * IMAP Account stuff |
411 | */ | 411 | */ |
412 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 412 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
413 | : AccountViewItem( parent ) | 413 | : AccountViewItem( parent ) |
414 | { | 414 | { |
415 | account = a; | 415 | account = a; |
416 | wrapper = AbstractMail::getWrapper( account ); | 416 | wrapper = AbstractMail::getWrapper( account ); |
417 | SETPIX(PIXMAP_IMAPFOLDER); | 417 | SETPIX(PIXMAP_IMAPFOLDER); |
418 | setText( 0, account->getAccountName() ); | 418 | setText( 0, account->getAccountName() ); |
419 | setOpen( true ); | 419 | setOpen( true ); |
420 | } | 420 | } |
421 | 421 | ||
422 | IMAPviewItem::~IMAPviewItem() | 422 | IMAPviewItem::~IMAPviewItem() |
423 | { | 423 | { |
424 | delete wrapper; | 424 | delete wrapper; |
425 | } | 425 | } |
426 | 426 | ||
427 | AbstractMail *IMAPviewItem::getWrapper() | 427 | AbstractMail *IMAPviewItem::getWrapper() |
428 | { | 428 | { |
429 | return wrapper; | 429 | return wrapper; |
430 | } | 430 | } |
431 | 431 | ||
432 | void IMAPviewItem::refresh(QValueList<RecMailP>&) | 432 | void IMAPviewItem::refresh(QValueList<RecMailP>&) |
433 | { | 433 | { |
434 | refreshFolders(false); | 434 | refreshFolders(false); |
435 | } | 435 | } |
436 | 436 | ||
437 | const QStringList&IMAPviewItem::subFolders() | 437 | const QStringList&IMAPviewItem::subFolders() |
438 | { | 438 | { |
439 | return currentFolders; | 439 | return currentFolders; |
440 | } | 440 | } |
441 | 441 | ||
442 | void IMAPviewItem::refreshFolders(bool force) | 442 | void IMAPviewItem::refreshFolders(bool force) |
443 | { | 443 | { |
444 | if (childCount()>0 && force==false) return; | 444 | if (childCount()>0 && force==false) return; |
445 | if (account->getOffline()) return; | 445 | if (account->getOffline()) return; |
446 | 446 | ||
447 | removeChilds(); | 447 | removeChilds(); |
448 | currentFolders.clear(); | 448 | currentFolders.clear(); |
449 | QValueList<FolderP> * folders = wrapper->listFolders(); | 449 | QValueList<FolderP> * folders = wrapper->listFolders(); |
450 | 450 | ||
451 | QValueList<FolderP>::Iterator it; | 451 | QValueList<FolderP>::Iterator it; |
452 | QListViewItem*item = 0; | 452 | QListViewItem*item = 0; |
453 | QListViewItem*titem = 0; | 453 | QListViewItem*titem = 0; |
454 | QString fname,del,search; | 454 | QString fname,del,search; |
455 | int pos; | 455 | int pos; |
456 | 456 | ||
457 | for ( it = folders->begin(); it!=folders->end(); ++it) | 457 | for ( it = folders->begin(); it!=folders->end(); ++it) |
458 | { | 458 | { |
459 | if ((*it)->getDisplayName().lower()=="inbox") | 459 | if ((*it)->getDisplayName().lower()=="inbox") |
460 | { | 460 | { |
461 | item = new IMAPfolderItem( (*it), this , item ); | 461 | item = new IMAPfolderItem( (*it), this , item ); |
462 | folders->remove(it); | 462 | folders->remove(it); |
463 | qDebug("inbox found"); | 463 | qDebug("inbox found"); |
464 | break; | 464 | break; |
@@ -469,552 +469,552 @@ void IMAPviewItem::refreshFolders(bool force) | |||
469 | fname = (*it)->getDisplayName(); | 469 | fname = (*it)->getDisplayName(); |
470 | currentFolders.append((*it)->getName()); | 470 | currentFolders.append((*it)->getName()); |
471 | pos = fname.findRev((*it)->Separator()); | 471 | pos = fname.findRev((*it)->Separator()); |
472 | if (pos != -1) | 472 | if (pos != -1) |
473 | { | 473 | { |
474 | fname = fname.left(pos); | 474 | fname = fname.left(pos); |
475 | } | 475 | } |
476 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 476 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
477 | if (pitem) | 477 | if (pitem) |
478 | { | 478 | { |
479 | titem = item; | 479 | titem = item; |
480 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 480 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
481 | /* setup the short name */ | 481 | /* setup the short name */ |
482 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); | 482 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); |
483 | item = titem; | 483 | item = titem; |
484 | } | 484 | } |
485 | else | 485 | else |
486 | { | 486 | { |
487 | item = new IMAPfolderItem( (*it), this , item ); | 487 | item = new IMAPfolderItem( (*it), this , item ); |
488 | } | 488 | } |
489 | } | 489 | } |
490 | delete folders; | 490 | delete folders; |
491 | } | 491 | } |
492 | 492 | ||
493 | QPopupMenu * IMAPviewItem::getContextMenu() | 493 | QPopupMenu * IMAPviewItem::getContextMenu() |
494 | { | 494 | { |
495 | QPopupMenu *m = new QPopupMenu(0); | 495 | QPopupMenu *m = new QPopupMenu(0); |
496 | if (m) | 496 | if (m) |
497 | { | 497 | { |
498 | if (!account->getOffline()) | 498 | if (!account->getOffline()) |
499 | { | 499 | { |
500 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 500 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
501 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 501 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
502 | m->insertSeparator(); | 502 | m->insertSeparator(); |
503 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 503 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
504 | m->insertItem(QObject::tr("Set offline",contextName),3); | 504 | m->insertItem(QObject::tr("Set offline",contextName),3); |
505 | } | 505 | } |
506 | else | 506 | else |
507 | { | 507 | { |
508 | m->insertItem(QObject::tr("Set online",contextName),3); | 508 | m->insertItem(QObject::tr("Set online",contextName),3); |
509 | } | 509 | } |
510 | } | 510 | } |
511 | return m; | 511 | return m; |
512 | } | 512 | } |
513 | 513 | ||
514 | void IMAPviewItem::createNewFolder() | 514 | void IMAPviewItem::createNewFolder() |
515 | { | 515 | { |
516 | Newmdirdlg ndirdlg; | 516 | Newmdirdlg ndirdlg; |
517 | if ( QPEApplication::execDialog( &ndirdlg )) | 517 | if ( QPEApplication::execDialog( &ndirdlg )) |
518 | { | 518 | { |
519 | QString ndir = ndirdlg.Newdir(); | 519 | QString ndir = ndirdlg.Newdir(); |
520 | bool makesubs = ndirdlg.subpossible(); | 520 | bool makesubs = ndirdlg.subpossible(); |
521 | QString delemiter = "/"; | 521 | QString delemiter = "/"; |
522 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 522 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
523 | if (item) | 523 | if (item) |
524 | { | 524 | { |
525 | delemiter = item->Delemiter(); | 525 | delemiter = item->Delemiter(); |
526 | } | 526 | } |
527 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 527 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
528 | { | 528 | { |
529 | refreshFolders(true); | 529 | refreshFolders(true); |
530 | } | 530 | } |
531 | } | 531 | } |
532 | } | 532 | } |
533 | 533 | ||
534 | void IMAPviewItem::contextMenuSelected(int id) | 534 | void IMAPviewItem::contextMenuSelected(int id) |
535 | { | 535 | { |
536 | qDebug("Id selected: %i",id); | 536 | qDebug("Id selected: %i",id); |
537 | switch (id) | 537 | switch (id) |
538 | { | 538 | { |
539 | case 0: | 539 | case 0: |
540 | refreshFolders(true); | 540 | refreshFolders(true); |
541 | break; | 541 | break; |
542 | case 1: | 542 | case 1: |
543 | createNewFolder(); | 543 | createNewFolder(); |
544 | break; | 544 | break; |
545 | case 2: | 545 | case 2: |
546 | removeChilds(); | 546 | removeChilds(); |
547 | wrapper->logout(); | 547 | wrapper->logout(); |
548 | break; | 548 | break; |
549 | case 3: | 549 | case 3: |
550 | if (account->getOffline()==false) | 550 | if (account->getOffline()==false) |
551 | { | 551 | { |
552 | removeChilds(); | 552 | removeChilds(); |
553 | wrapper->logout(); | 553 | wrapper->logout(); |
554 | } | 554 | } |
555 | account->setOffline(!account->getOffline()); | 555 | account->setOffline(!account->getOffline()); |
556 | account->save(); | 556 | account->save(); |
557 | SETPIX(PIXMAP_IMAPFOLDER); | 557 | SETPIX(PIXMAP_IMAPFOLDER); |
558 | refreshFolders(false); | 558 | refreshFolders(false); |
559 | break; | 559 | break; |
560 | default: | 560 | default: |
561 | break; | 561 | break; |
562 | } | 562 | } |
563 | } | 563 | } |
564 | 564 | ||
565 | RecBody IMAPviewItem::fetchBody(const RecMailP&) | 565 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
566 | { | 566 | { |
567 | return RecBody(); | 567 | return new RecBody(); |
568 | } | 568 | } |
569 | 569 | ||
570 | bool IMAPviewItem::offline() | 570 | bool IMAPviewItem::offline() |
571 | { | 571 | { |
572 | return account->getOffline(); | 572 | return account->getOffline(); |
573 | } | 573 | } |
574 | 574 | ||
575 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 575 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
576 | : AccountViewItem( folderInit, parent , after ) | 576 | : AccountViewItem( folderInit, parent , after ) |
577 | { | 577 | { |
578 | imap = parent; | 578 | imap = parent; |
579 | if (folder->getDisplayName().lower()!="inbox") | 579 | if (folder->getDisplayName().lower()!="inbox") |
580 | { | 580 | { |
581 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 581 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
582 | } | 582 | } |
583 | else | 583 | else |
584 | { | 584 | { |
585 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 585 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
586 | } | 586 | } |
587 | setText( 0, folder->getDisplayName() ); | 587 | setText( 0, folder->getDisplayName() ); |
588 | } | 588 | } |
589 | 589 | ||
590 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 590 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
591 | : AccountViewItem(folderInit, parent,after ) | 591 | : AccountViewItem(folderInit, parent,after ) |
592 | { | 592 | { |
593 | imap = master; | 593 | imap = master; |
594 | if (folder->getDisplayName().lower()!="inbox") | 594 | if (folder->getDisplayName().lower()!="inbox") |
595 | { | 595 | { |
596 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 596 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
597 | } | 597 | } |
598 | else | 598 | else |
599 | { | 599 | { |
600 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 600 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
601 | } | 601 | } |
602 | setText( 0, folder->getDisplayName() ); | 602 | setText( 0, folder->getDisplayName() ); |
603 | } | 603 | } |
604 | 604 | ||
605 | IMAPfolderItem::~IMAPfolderItem() | 605 | IMAPfolderItem::~IMAPfolderItem() |
606 | {} | 606 | {} |
607 | 607 | ||
608 | const QString& IMAPfolderItem::Delemiter()const | 608 | const QString& IMAPfolderItem::Delemiter()const |
609 | { | 609 | { |
610 | return folder->Separator(); | 610 | return folder->Separator(); |
611 | } | 611 | } |
612 | 612 | ||
613 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | 613 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) |
614 | { | 614 | { |
615 | if (folder->may_select()) | 615 | if (folder->may_select()) |
616 | { | 616 | { |
617 | imap->getWrapper()->listMessages( folder->getName(),target ); | 617 | imap->getWrapper()->listMessages( folder->getName(),target ); |
618 | } | 618 | } |
619 | else | 619 | else |
620 | { | 620 | { |
621 | target.clear(); | 621 | target.clear(); |
622 | } | 622 | } |
623 | } | 623 | } |
624 | 624 | ||
625 | RecBody IMAPfolderItem::fetchBody(const RecMailP&aMail) | 625 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
626 | { | 626 | { |
627 | return imap->getWrapper()->fetchBody(aMail); | 627 | return imap->getWrapper()->fetchBody(aMail); |
628 | } | 628 | } |
629 | 629 | ||
630 | QPopupMenu * IMAPfolderItem::getContextMenu() | 630 | QPopupMenu * IMAPfolderItem::getContextMenu() |
631 | { | 631 | { |
632 | QPopupMenu *m = new QPopupMenu(0); | 632 | QPopupMenu *m = new QPopupMenu(0); |
633 | if (m) | 633 | if (m) |
634 | { | 634 | { |
635 | if (folder->may_select()) | 635 | if (folder->may_select()) |
636 | { | 636 | { |
637 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 637 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
638 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | 638 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); |
639 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 639 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
640 | } | 640 | } |
641 | if (folder->no_inferior()==false) | 641 | if (folder->no_inferior()==false) |
642 | { | 642 | { |
643 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 643 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
644 | } | 644 | } |
645 | if (folder->getDisplayName().lower()!="inbox") | 645 | if (folder->getDisplayName().lower()!="inbox") |
646 | { | 646 | { |
647 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 647 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
648 | } | 648 | } |
649 | } | 649 | } |
650 | return m; | 650 | return m; |
651 | } | 651 | } |
652 | 652 | ||
653 | void IMAPfolderItem::createNewFolder() | 653 | void IMAPfolderItem::createNewFolder() |
654 | { | 654 | { |
655 | Newmdirdlg ndirdlg; | 655 | Newmdirdlg ndirdlg; |
656 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 656 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
657 | { | 657 | { |
658 | QString ndir = ndirdlg.Newdir(); | 658 | QString ndir = ndirdlg.Newdir(); |
659 | bool makesubs = ndirdlg.subpossible(); | 659 | bool makesubs = ndirdlg.subpossible(); |
660 | QString delemiter = Delemiter(); | 660 | QString delemiter = Delemiter(); |
661 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 661 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
662 | { | 662 | { |
663 | imap->refreshFolders(true); | 663 | imap->refreshFolders(true); |
664 | } | 664 | } |
665 | } | 665 | } |
666 | } | 666 | } |
667 | 667 | ||
668 | void IMAPfolderItem::deleteFolder() | 668 | void IMAPfolderItem::deleteFolder() |
669 | { | 669 | { |
670 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 670 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
671 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 671 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
672 | QObject::tr("Yes",contextName), | 672 | QObject::tr("Yes",contextName), |
673 | QObject::tr("No",contextName),QString::null,1,1); | 673 | QObject::tr("No",contextName),QString::null,1,1); |
674 | qDebug("Auswahl: %i",yesno); | 674 | qDebug("Auswahl: %i",yesno); |
675 | if (yesno == 0) | 675 | if (yesno == 0) |
676 | { | 676 | { |
677 | if (imap->getWrapper()->deleteMbox(folder)) | 677 | if (imap->getWrapper()->deleteMbox(folder)) |
678 | { | 678 | { |
679 | QListView*v=listView(); | 679 | QListView*v=listView(); |
680 | IMAPviewItem * box = imap; | 680 | IMAPviewItem * box = imap; |
681 | /* be carefull - after that this object is destroyd so don't use | 681 | /* be carefull - after that this object is destroyd so don't use |
682 | * any member of it after that call!!*/ | 682 | * any member of it after that call!!*/ |
683 | imap->refreshFolders(true); | 683 | imap->refreshFolders(true); |
684 | if (v) | 684 | if (v) |
685 | { | 685 | { |
686 | v->setSelected(box,true); | 686 | v->setSelected(box,true); |
687 | } | 687 | } |
688 | } | 688 | } |
689 | } | 689 | } |
690 | } | 690 | } |
691 | 691 | ||
692 | void IMAPfolderItem::downloadMails() | 692 | void IMAPfolderItem::downloadMails() |
693 | { | 693 | { |
694 | AccountView*bl = imap->accountView(); | 694 | AccountView*bl = imap->accountView(); |
695 | if (!bl) return; | 695 | if (!bl) return; |
696 | bl->downloadMails(folder,imap->getWrapper()); | 696 | bl->downloadMails(folder,imap->getWrapper()); |
697 | } | 697 | } |
698 | 698 | ||
699 | void IMAPfolderItem::contextMenuSelected(int id) | 699 | void IMAPfolderItem::contextMenuSelected(int id) |
700 | { | 700 | { |
701 | qDebug("Selected id: %i",id); | 701 | qDebug("Selected id: %i",id); |
702 | AccountView * view = (AccountView*)listView(); | 702 | AccountView * view = (AccountView*)listView(); |
703 | switch(id) | 703 | switch(id) |
704 | { | 704 | { |
705 | case 0: | 705 | case 0: |
706 | view->refreshCurrent(); | 706 | view->refreshCurrent(); |
707 | break; | 707 | break; |
708 | case 1: | 708 | case 1: |
709 | deleteAllMail(imap->getWrapper(),folder); | 709 | deleteAllMail(imap->getWrapper(),folder); |
710 | break; | 710 | break; |
711 | case 2: | 711 | case 2: |
712 | createNewFolder(); | 712 | createNewFolder(); |
713 | break; | 713 | break; |
714 | case 3: | 714 | case 3: |
715 | deleteFolder(); | 715 | deleteFolder(); |
716 | break; | 716 | break; |
717 | case 4: | 717 | case 4: |
718 | downloadMails(); | 718 | downloadMails(); |
719 | break; | 719 | break; |
720 | default: | 720 | default: |
721 | break; | 721 | break; |
722 | } | 722 | } |
723 | } | 723 | } |
724 | 724 | ||
725 | /** | 725 | /** |
726 | * MH Account stuff | 726 | * MH Account stuff |
727 | */ | 727 | */ |
728 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 728 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
729 | POP3 and MBOX */ | 729 | POP3 and MBOX */ |
730 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 730 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
731 | : AccountViewItem( parent ) | 731 | : AccountViewItem( parent ) |
732 | { | 732 | { |
733 | m_Path = aPath; | 733 | m_Path = aPath; |
734 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 734 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
735 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 735 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |
736 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 736 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
737 | setText( 0, " Local Folders" ); | 737 | setText( 0, " Local Folders" ); |
738 | setOpen( true ); | 738 | setOpen( true ); |
739 | folder = 0; | 739 | folder = 0; |
740 | } | 740 | } |
741 | 741 | ||
742 | MHviewItem::~MHviewItem() | 742 | MHviewItem::~MHviewItem() |
743 | { | 743 | { |
744 | delete wrapper; | 744 | delete wrapper; |
745 | } | 745 | } |
746 | 746 | ||
747 | AbstractMail *MHviewItem::getWrapper() | 747 | AbstractMail *MHviewItem::getWrapper() |
748 | { | 748 | { |
749 | return wrapper; | 749 | return wrapper; |
750 | } | 750 | } |
751 | 751 | ||
752 | void MHviewItem::refresh( QValueList<RecMailP> & target) | 752 | void MHviewItem::refresh( QValueList<RecMailP> & target) |
753 | { | 753 | { |
754 | refresh(false); | 754 | refresh(false); |
755 | getWrapper()->listMessages( "",target ); | 755 | getWrapper()->listMessages( "",target ); |
756 | } | 756 | } |
757 | 757 | ||
758 | void MHviewItem::refresh(bool force) | 758 | void MHviewItem::refresh(bool force) |
759 | { | 759 | { |
760 | if (childCount()>0 && force==false) return; | 760 | if (childCount()>0 && force==false) return; |
761 | removeChilds(); | 761 | removeChilds(); |
762 | currentFolders.clear(); | 762 | currentFolders.clear(); |
763 | QValueList<FolderP> *folders = wrapper->listFolders(); | 763 | QValueList<FolderP> *folders = wrapper->listFolders(); |
764 | QValueList<FolderP>::ConstIterator it; | 764 | QValueList<FolderP>::ConstIterator it; |
765 | MHfolderItem*item = 0; | 765 | MHfolderItem*item = 0; |
766 | MHfolderItem*pmaster = 0; | 766 | MHfolderItem*pmaster = 0; |
767 | QString fname = ""; | 767 | QString fname = ""; |
768 | int pos; | 768 | int pos; |
769 | for ( it = folders->begin(); it!=folders->end(); ++it) | 769 | for ( it = folders->begin(); it!=folders->end(); ++it) |
770 | { | 770 | { |
771 | fname = (*it)->getDisplayName(); | 771 | fname = (*it)->getDisplayName(); |
772 | /* this folder itself */ | 772 | /* this folder itself */ |
773 | if (fname=="/") | 773 | if (fname=="/") |
774 | { | 774 | { |
775 | currentFolders.append(fname); | 775 | currentFolders.append(fname); |
776 | folder = (*it); | 776 | folder = (*it); |
777 | continue; | 777 | continue; |
778 | } | 778 | } |
779 | currentFolders.append(fname); | 779 | currentFolders.append(fname); |
780 | pos = fname.findRev("/"); | 780 | pos = fname.findRev("/"); |
781 | if (pos > 0) | 781 | if (pos > 0) |
782 | { | 782 | { |
783 | fname = fname.left(pos); | 783 | fname = fname.left(pos); |
784 | pmaster = (MHfolderItem*)findSubItem(fname); | 784 | pmaster = (MHfolderItem*)findSubItem(fname); |
785 | } | 785 | } |
786 | else | 786 | else |
787 | { | 787 | { |
788 | pmaster = 0; | 788 | pmaster = 0; |
789 | } | 789 | } |
790 | if (pmaster) | 790 | if (pmaster) |
791 | { | 791 | { |
792 | item = new MHfolderItem( (*it), pmaster, item, this ); | 792 | item = new MHfolderItem( (*it), pmaster, item, this ); |
793 | } | 793 | } |
794 | else | 794 | else |
795 | { | 795 | { |
796 | item = new MHfolderItem( (*it), this , item ); | 796 | item = new MHfolderItem( (*it), this , item ); |
797 | } | 797 | } |
798 | item->setSelectable((*it)->may_select()); | 798 | item->setSelectable((*it)->may_select()); |
799 | } | 799 | } |
800 | delete folders; | 800 | delete folders; |
801 | } | 801 | } |
802 | 802 | ||
803 | RecBody MHviewItem::fetchBody( const RecMailP &mail ) | 803 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) |
804 | { | 804 | { |
805 | qDebug( "MH fetchBody" ); | 805 | qDebug( "MH fetchBody" ); |
806 | return wrapper->fetchBody( mail ); | 806 | return wrapper->fetchBody( mail ); |
807 | } | 807 | } |
808 | 808 | ||
809 | QPopupMenu * MHviewItem::getContextMenu() | 809 | QPopupMenu * MHviewItem::getContextMenu() |
810 | { | 810 | { |
811 | QPopupMenu *m = new QPopupMenu(0); | 811 | QPopupMenu *m = new QPopupMenu(0); |
812 | if (m) | 812 | if (m) |
813 | { | 813 | { |
814 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 814 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
815 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 815 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
816 | m->insertItem(QObject::tr("Delete all mails",contextName),2); | 816 | m->insertItem(QObject::tr("Delete all mails",contextName),2); |
817 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); | 817 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); |
818 | } | 818 | } |
819 | return m; | 819 | return m; |
820 | } | 820 | } |
821 | 821 | ||
822 | void MHviewItem::createFolder() | 822 | void MHviewItem::createFolder() |
823 | { | 823 | { |
824 | Newmdirdlg ndirdlg(0,0,true); | 824 | Newmdirdlg ndirdlg(0,0,true); |
825 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 825 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
826 | { | 826 | { |
827 | QString ndir = ndirdlg.Newdir(); | 827 | QString ndir = ndirdlg.Newdir(); |
828 | if (wrapper->createMbox(ndir)) | 828 | if (wrapper->createMbox(ndir)) |
829 | { | 829 | { |
830 | refresh(true); | 830 | refresh(true); |
831 | } | 831 | } |
832 | } | 832 | } |
833 | } | 833 | } |
834 | 834 | ||
835 | void MHviewItem::downloadMails() | 835 | void MHviewItem::downloadMails() |
836 | { | 836 | { |
837 | AccountView*bl = accountView(); | 837 | AccountView*bl = accountView(); |
838 | if (!bl) return; | 838 | if (!bl) return; |
839 | bl->downloadMails(folder,getWrapper()); | 839 | bl->downloadMails(folder,getWrapper()); |
840 | } | 840 | } |
841 | 841 | ||
842 | QStringList MHviewItem::subFolders() | 842 | QStringList MHviewItem::subFolders() |
843 | { | 843 | { |
844 | return currentFolders; | 844 | return currentFolders; |
845 | } | 845 | } |
846 | 846 | ||
847 | void MHviewItem::contextMenuSelected(int which) | 847 | void MHviewItem::contextMenuSelected(int which) |
848 | { | 848 | { |
849 | switch (which) | 849 | switch (which) |
850 | { | 850 | { |
851 | case 0: | 851 | case 0: |
852 | refresh(true); | 852 | refresh(true); |
853 | break; | 853 | break; |
854 | case 1: | 854 | case 1: |
855 | createFolder(); | 855 | createFolder(); |
856 | break; | 856 | break; |
857 | case 2: | 857 | case 2: |
858 | deleteAllMail(getWrapper(),folder); | 858 | deleteAllMail(getWrapper(),folder); |
859 | break; | 859 | break; |
860 | case 3: | 860 | case 3: |
861 | downloadMails(); | 861 | downloadMails(); |
862 | break; | 862 | break; |
863 | default: | 863 | default: |
864 | break; | 864 | break; |
865 | } | 865 | } |
866 | } | 866 | } |
867 | 867 | ||
868 | MHfolderItem::~MHfolderItem() | 868 | MHfolderItem::~MHfolderItem() |
869 | {} | 869 | {} |
870 | 870 | ||
871 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) | 871 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) |
872 | : AccountViewItem(folderInit, parent,after ) | 872 | : AccountViewItem(folderInit, parent,after ) |
873 | { | 873 | { |
874 | mbox = parent; | 874 | mbox = parent; |
875 | initName(); | 875 | initName(); |
876 | } | 876 | } |
877 | 877 | ||
878 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | 878 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) |
879 | : AccountViewItem(folderInit, parent,after ) | 879 | : AccountViewItem(folderInit, parent,after ) |
880 | { | 880 | { |
881 | folder = folderInit; | 881 | folder = folderInit; |
882 | mbox = master; | 882 | mbox = master; |
883 | initName(); | 883 | initName(); |
884 | } | 884 | } |
885 | 885 | ||
886 | void MHfolderItem::initName() | 886 | void MHfolderItem::initName() |
887 | { | 887 | { |
888 | QString bName = folder->getDisplayName(); | 888 | QString bName = folder->getDisplayName(); |
889 | if (bName.startsWith("/")&&bName.length()>1) | 889 | if (bName.startsWith("/")&&bName.length()>1) |
890 | { | 890 | { |
891 | bName.replace(0,1,""); | 891 | bName.replace(0,1,""); |
892 | } | 892 | } |
893 | int pos = bName.findRev("/"); | 893 | int pos = bName.findRev("/"); |
894 | if (pos > 0) | 894 | if (pos > 0) |
895 | { | 895 | { |
896 | bName.replace(0,pos+1,""); | 896 | bName.replace(0,pos+1,""); |
897 | } | 897 | } |
898 | if (bName.lower() == "outgoing") | 898 | if (bName.lower() == "outgoing") |
899 | { | 899 | { |
900 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 900 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
901 | } | 901 | } |
902 | else if (bName.lower() == "inbox") | 902 | else if (bName.lower() == "inbox") |
903 | { | 903 | { |
904 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 904 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
905 | } else if (bName.lower() == "drafts") { | 905 | } else if (bName.lower() == "drafts") { |
906 | setPixmap(0, Resource::loadPixmap("inline/edit")); | 906 | setPixmap(0, Resource::loadPixmap("inline/edit")); |
907 | } else { | 907 | } else { |
908 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 908 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
909 | } | 909 | } |
910 | setText( 0, bName ); | 910 | setText( 0, bName ); |
911 | } | 911 | } |
912 | 912 | ||
913 | const FolderP&MHfolderItem::getFolder()const | 913 | const FolderP&MHfolderItem::getFolder()const |
914 | { | 914 | { |
915 | return folder; | 915 | return folder; |
916 | } | 916 | } |
917 | 917 | ||
918 | void MHfolderItem::refresh(QValueList<RecMailP>&target) | 918 | void MHfolderItem::refresh(QValueList<RecMailP>&target) |
919 | { | 919 | { |
920 | if (folder->may_select()) | 920 | if (folder->may_select()) |
921 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 921 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
922 | } | 922 | } |
923 | 923 | ||
924 | RecBody MHfolderItem::fetchBody(const RecMailP&aMail) | 924 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) |
925 | { | 925 | { |
926 | return mbox->getWrapper()->fetchBody(aMail); | 926 | return mbox->getWrapper()->fetchBody(aMail); |
927 | } | 927 | } |
928 | 928 | ||
929 | void MHfolderItem::deleteFolder() | 929 | void MHfolderItem::deleteFolder() |
930 | { | 930 | { |
931 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 931 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
932 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 932 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
933 | QObject::tr("Yes",contextName), | 933 | QObject::tr("Yes",contextName), |
934 | QObject::tr("No",contextName),QString::null,1,1); | 934 | QObject::tr("No",contextName),QString::null,1,1); |
935 | qDebug("Auswahl: %i",yesno); | 935 | qDebug("Auswahl: %i",yesno); |
936 | if (yesno == 0) | 936 | if (yesno == 0) |
937 | { | 937 | { |
938 | if (mbox->getWrapper()->deleteMbox(folder)) | 938 | if (mbox->getWrapper()->deleteMbox(folder)) |
939 | { | 939 | { |
940 | QListView*v=listView(); | 940 | QListView*v=listView(); |
941 | MHviewItem * box = mbox; | 941 | MHviewItem * box = mbox; |
942 | /* be carefull - after that this object is destroyd so don't use | 942 | /* be carefull - after that this object is destroyd so don't use |
943 | * any member of it after that call!!*/ | 943 | * any member of it after that call!!*/ |
944 | mbox->refresh(true); | 944 | mbox->refresh(true); |
945 | if (v) | 945 | if (v) |
946 | { | 946 | { |
947 | v->setSelected(box,true); | 947 | v->setSelected(box,true); |
948 | } | 948 | } |
949 | } | 949 | } |
950 | } | 950 | } |
951 | } | 951 | } |
952 | 952 | ||
953 | QPopupMenu * MHfolderItem::getContextMenu() | 953 | QPopupMenu * MHfolderItem::getContextMenu() |
954 | { | 954 | { |
955 | QPopupMenu *m = new QPopupMenu(0); | 955 | QPopupMenu *m = new QPopupMenu(0); |
956 | if (m) | 956 | if (m) |
957 | { | 957 | { |
958 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 958 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
959 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | 959 | m->insertItem(QObject::tr("Delete all mails",contextName),0); |
960 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); | 960 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); |
961 | m->insertItem(QObject::tr("Delete folder",contextName),1); | 961 | m->insertItem(QObject::tr("Delete folder",contextName),1); |
962 | } | 962 | } |
963 | return m; | 963 | return m; |
964 | } | 964 | } |
965 | 965 | ||
966 | void MHfolderItem::downloadMails() | 966 | void MHfolderItem::downloadMails() |
967 | { | 967 | { |
968 | AccountView*bl = mbox->accountView(); | 968 | AccountView*bl = mbox->accountView(); |
969 | if (!bl) return; | 969 | if (!bl) return; |
970 | bl->downloadMails(folder,mbox->getWrapper()); | 970 | bl->downloadMails(folder,mbox->getWrapper()); |
971 | } | 971 | } |
972 | 972 | ||
973 | void MHfolderItem::createFolder() | 973 | void MHfolderItem::createFolder() |
974 | { | 974 | { |
975 | Newmdirdlg ndirdlg(0,0,true); | 975 | Newmdirdlg ndirdlg(0,0,true); |
976 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 976 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
977 | { | 977 | { |
978 | QString ndir = ndirdlg.Newdir(); | 978 | QString ndir = ndirdlg.Newdir(); |
979 | if (mbox->getWrapper()->createMbox(ndir,folder)) | 979 | if (mbox->getWrapper()->createMbox(ndir,folder)) |
980 | { | 980 | { |
981 | QListView*v=listView(); | 981 | QListView*v=listView(); |
982 | MHviewItem * box = mbox; | 982 | MHviewItem * box = mbox; |
983 | /* be carefull - after that this object is destroyd so don't use | 983 | /* be carefull - after that this object is destroyd so don't use |
984 | * any member of it after that call!!*/ | 984 | * any member of it after that call!!*/ |
985 | mbox->refresh(true); | 985 | mbox->refresh(true); |
986 | if (v) | 986 | if (v) |
987 | { | 987 | { |
988 | v->setSelected(box,true); | 988 | v->setSelected(box,true); |
989 | } | 989 | } |
990 | } | 990 | } |
991 | } | 991 | } |
992 | } | 992 | } |
993 | 993 | ||
994 | void MHfolderItem::contextMenuSelected(int which) | 994 | void MHfolderItem::contextMenuSelected(int which) |
995 | { | 995 | { |
996 | switch(which) | 996 | switch(which) |
997 | { | 997 | { |
998 | case 0: | 998 | case 0: |
999 | deleteAllMail(mbox->getWrapper(),folder); | 999 | deleteAllMail(mbox->getWrapper(),folder); |
1000 | break; | 1000 | break; |
1001 | case 1: | 1001 | case 1: |
1002 | deleteFolder(); | 1002 | deleteFolder(); |
1003 | break; | 1003 | break; |
1004 | case 2: | 1004 | case 2: |
1005 | downloadMails(); | 1005 | downloadMails(); |
1006 | break; | 1006 | break; |
1007 | case 3: | 1007 | case 3: |
1008 | createFolder(); | 1008 | createFolder(); |
1009 | break; | 1009 | break; |
1010 | default: | 1010 | default: |
1011 | break; | 1011 | break; |
1012 | } | 1012 | } |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | bool MHfolderItem::isDraftfolder() | 1015 | bool MHfolderItem::isDraftfolder() |
1016 | { | 1016 | { |
1017 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; | 1017 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; |
1018 | return false; | 1018 | return false; |
1019 | } | 1019 | } |
1020 | 1020 | ||
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h index 6cdb260..f125eeb 100644 --- a/noncore/net/mail/accountitem.h +++ b/noncore/net/mail/accountitem.h | |||
@@ -1,210 +1,212 @@ | |||
1 | #ifndef __ACCOUNT_ITEM | 1 | #ifndef __ACCOUNT_ITEM |
2 | #define __ACCOUNT_ITEM | 2 | #define __ACCOUNT_ITEM |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include <opie2/osmartpointer.h> | 6 | #include <opie2/osmartpointer.h> |
7 | 7 | ||
8 | class POP3wrapper; | 8 | class POP3wrapper; |
9 | class RecMail; | 9 | class RecMail; |
10 | class RecBody; | 10 | class RecBody; |
11 | class QPopupMenu; | 11 | class QPopupMenu; |
12 | class Selectstore; | 12 | class Selectstore; |
13 | class AccountView; | 13 | class AccountView; |
14 | class POP3account; | 14 | class POP3account; |
15 | class NNTPaccount; | 15 | class NNTPaccount; |
16 | class IMAPaccount; | 16 | class IMAPaccount; |
17 | class AbstractMail; | 17 | class AbstractMail; |
18 | class Folder; | 18 | class Folder; |
19 | 19 | ||
20 | #define RECBODYP Opie::Core::OSmartPointer<RecBody> | ||
21 | |||
20 | class AccountViewItem : public QListViewItem | 22 | class AccountViewItem : public QListViewItem |
21 | { | 23 | { |
22 | 24 | ||
23 | public: | 25 | public: |
24 | AccountViewItem( AccountView *parent ); | 26 | AccountViewItem( AccountView *parent ); |
25 | AccountViewItem( QListViewItem *parent); | 27 | AccountViewItem( QListViewItem *parent); |
26 | AccountViewItem( QListViewItem *parent , QListViewItem*after ); | 28 | AccountViewItem( QListViewItem *parent , QListViewItem*after ); |
27 | AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ); | 29 | AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ); |
28 | 30 | ||
29 | virtual ~AccountViewItem(); | 31 | virtual ~AccountViewItem(); |
30 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&)=0; | 32 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&)=0; |
31 | virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&)=0; | 33 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&)=0; |
32 | virtual QPopupMenu * getContextMenu(){return 0;}; | 34 | virtual QPopupMenu * getContextMenu(){return 0;}; |
33 | virtual void contextMenuSelected(int){} | 35 | virtual void contextMenuSelected(int){} |
34 | virtual AccountView*accountView(); | 36 | virtual AccountView*accountView(); |
35 | virtual bool matchName(const QString&name)const; | 37 | virtual bool matchName(const QString&name)const; |
36 | virtual bool isDraftfolder(); | 38 | virtual bool isDraftfolder(); |
37 | 39 | ||
38 | protected: | 40 | protected: |
39 | AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); | 41 | AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); |
40 | virtual void init(); | 42 | virtual void init(); |
41 | virtual void removeChilds(); | 43 | virtual void removeChilds(); |
42 | virtual void deleteAllMail(AbstractMail*wrapper,const Opie::Core::OSmartPointer<Folder>&f); | 44 | virtual void deleteAllMail(AbstractMail*wrapper,const Opie::Core::OSmartPointer<Folder>&f); |
43 | static const QString contextName; | 45 | static const QString contextName; |
44 | AccountView*m_Backlink; | 46 | AccountView*m_Backlink; |
45 | Opie::Core::OSmartPointer<Folder> folder; | 47 | Opie::Core::OSmartPointer<Folder> folder; |
46 | }; | 48 | }; |
47 | 49 | ||
48 | class POP3viewItem : public AccountViewItem | 50 | class POP3viewItem : public AccountViewItem |
49 | { | 51 | { |
50 | 52 | ||
51 | public: | 53 | public: |
52 | POP3viewItem( POP3account *a, AccountView *parent ); | 54 | POP3viewItem( POP3account *a, AccountView *parent ); |
53 | virtual ~POP3viewItem(); | 55 | virtual ~POP3viewItem(); |
54 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); | 56 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); |
55 | virtual RecBody fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); | 57 | virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); |
56 | AbstractMail *getWrapper(); | 58 | AbstractMail *getWrapper(); |
57 | virtual QPopupMenu * getContextMenu(); | 59 | virtual QPopupMenu * getContextMenu(); |
58 | virtual void contextMenuSelected(int); | 60 | virtual void contextMenuSelected(int); |
59 | 61 | ||
60 | protected: | 62 | protected: |
61 | POP3account *account; | 63 | POP3account *account; |
62 | virtual void refresh(); | 64 | virtual void refresh(); |
63 | AbstractMail *wrapper; | 65 | AbstractMail *wrapper; |
64 | void disconnect(); | 66 | void disconnect(); |
65 | void setOnOffline(); | 67 | void setOnOffline(); |
66 | }; | 68 | }; |
67 | 69 | ||
68 | class POP3folderItem : public AccountViewItem | 70 | class POP3folderItem : public AccountViewItem |
69 | { | 71 | { |
70 | 72 | ||
71 | public: | 73 | public: |
72 | POP3folderItem( const Opie::Core::OSmartPointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after ); | 74 | POP3folderItem( const Opie::Core::OSmartPointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after ); |
73 | virtual ~POP3folderItem(); | 75 | virtual ~POP3folderItem(); |
74 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); | 76 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); |
75 | virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&); | 77 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); |
76 | virtual QPopupMenu * getContextMenu(); | 78 | virtual QPopupMenu * getContextMenu(); |
77 | virtual void contextMenuSelected(int); | 79 | virtual void contextMenuSelected(int); |
78 | 80 | ||
79 | protected: | 81 | protected: |
80 | void downloadMails(); | 82 | void downloadMails(); |
81 | POP3viewItem *pop3; | 83 | POP3viewItem *pop3; |
82 | }; | 84 | }; |
83 | 85 | ||
84 | 86 | ||
85 | class NNTPviewItem : public AccountViewItem | 87 | class NNTPviewItem : public AccountViewItem |
86 | { | 88 | { |
87 | 89 | ||
88 | public: | 90 | public: |
89 | NNTPviewItem( NNTPaccount *a, AccountView *parent ); | 91 | NNTPviewItem( NNTPaccount *a, AccountView *parent ); |
90 | virtual ~NNTPviewItem(); | 92 | virtual ~NNTPviewItem(); |
91 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); | 93 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); |
92 | virtual RecBody fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); | 94 | virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); |
93 | AbstractMail *getWrapper(); | 95 | AbstractMail *getWrapper(); |
94 | virtual QPopupMenu * getContextMenu(); | 96 | virtual QPopupMenu * getContextMenu(); |
95 | virtual void contextMenuSelected(int); | 97 | virtual void contextMenuSelected(int); |
96 | 98 | ||
97 | protected: | 99 | protected: |
98 | NNTPaccount *account; | 100 | NNTPaccount *account; |
99 | virtual void refresh(); | 101 | virtual void refresh(); |
100 | AbstractMail *wrapper; | 102 | AbstractMail *wrapper; |
101 | void disconnect(); | 103 | void disconnect(); |
102 | void setOnOffline(); | 104 | void setOnOffline(); |
103 | void subscribeGroups(); | 105 | void subscribeGroups(); |
104 | }; | 106 | }; |
105 | 107 | ||
106 | class NNTPfolderItem : public AccountViewItem | 108 | class NNTPfolderItem : public AccountViewItem |
107 | { | 109 | { |
108 | 110 | ||
109 | public: | 111 | public: |
110 | NNTPfolderItem(const Opie::Core::OSmartPointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after ); | 112 | NNTPfolderItem(const Opie::Core::OSmartPointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after ); |
111 | virtual ~NNTPfolderItem(); | 113 | virtual ~NNTPfolderItem(); |
112 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); | 114 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); |
113 | virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&); | 115 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); |
114 | virtual QPopupMenu * getContextMenu(); | 116 | virtual QPopupMenu * getContextMenu(); |
115 | virtual void contextMenuSelected(int); | 117 | virtual void contextMenuSelected(int); |
116 | 118 | ||
117 | protected: | 119 | protected: |
118 | void downloadMails(); | 120 | void downloadMails(); |
119 | NNTPviewItem *nntp; | 121 | NNTPviewItem *nntp; |
120 | }; | 122 | }; |
121 | 123 | ||
122 | 124 | ||
123 | 125 | ||
124 | class IMAPviewItem : public AccountViewItem | 126 | class IMAPviewItem : public AccountViewItem |
125 | { | 127 | { |
126 | friend class IMAPfolderItem; | 128 | friend class IMAPfolderItem; |
127 | public: | 129 | public: |
128 | IMAPviewItem( IMAPaccount *a, AccountView *parent ); | 130 | IMAPviewItem( IMAPaccount *a, AccountView *parent ); |
129 | virtual ~IMAPviewItem(); | 131 | virtual ~IMAPviewItem(); |
130 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); | 132 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); |
131 | virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&); | 133 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); |
132 | AbstractMail *getWrapper(); | 134 | AbstractMail *getWrapper(); |
133 | virtual QPopupMenu * getContextMenu(); | 135 | virtual QPopupMenu * getContextMenu(); |
134 | virtual void contextMenuSelected(int); | 136 | virtual void contextMenuSelected(int); |
135 | const QStringList&subFolders(); | 137 | const QStringList&subFolders(); |
136 | virtual void refreshFolders(bool force=false); | 138 | virtual void refreshFolders(bool force=false); |
137 | bool offline(); | 139 | bool offline(); |
138 | 140 | ||
139 | protected: | 141 | protected: |
140 | virtual void createNewFolder(); | 142 | virtual void createNewFolder(); |
141 | IMAPaccount *account; | 143 | IMAPaccount *account; |
142 | AbstractMail *wrapper; | 144 | AbstractMail *wrapper; |
143 | QStringList currentFolders; | 145 | QStringList currentFolders; |
144 | }; | 146 | }; |
145 | 147 | ||
146 | class IMAPfolderItem : public AccountViewItem | 148 | class IMAPfolderItem : public AccountViewItem |
147 | { | 149 | { |
148 | 150 | ||
149 | public: | 151 | public: |
150 | IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after ); | 152 | IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after ); |
151 | IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); | 153 | IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); |
152 | virtual ~IMAPfolderItem(); | 154 | virtual ~IMAPfolderItem(); |
153 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); | 155 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); |
154 | virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&); | 156 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); |
155 | virtual QPopupMenu * getContextMenu(); | 157 | virtual QPopupMenu * getContextMenu(); |
156 | virtual void contextMenuSelected(int); | 158 | virtual void contextMenuSelected(int); |
157 | virtual const QString& Delemiter()const; | 159 | virtual const QString& Delemiter()const; |
158 | protected: | 160 | protected: |
159 | virtual void createNewFolder(); | 161 | virtual void createNewFolder(); |
160 | virtual void deleteFolder(); | 162 | virtual void deleteFolder(); |
161 | virtual void downloadMails(); | 163 | virtual void downloadMails(); |
162 | IMAPviewItem *imap; | 164 | IMAPviewItem *imap; |
163 | }; | 165 | }; |
164 | 166 | ||
165 | class MHviewItem : public AccountViewItem | 167 | class MHviewItem : public AccountViewItem |
166 | { | 168 | { |
167 | friend class MHfolderItem; | 169 | friend class MHfolderItem; |
168 | 170 | ||
169 | public: | 171 | public: |
170 | MHviewItem( const QString&aMboxPath, AccountView *parent ); | 172 | MHviewItem( const QString&aMboxPath, AccountView *parent ); |
171 | virtual ~MHviewItem(); | 173 | virtual ~MHviewItem(); |
172 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); | 174 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); |
173 | virtual RecBody fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); | 175 | virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); |
174 | AbstractMail *getWrapper(); | 176 | AbstractMail *getWrapper(); |
175 | virtual QPopupMenu * getContextMenu(); | 177 | virtual QPopupMenu * getContextMenu(); |
176 | virtual void contextMenuSelected(int); | 178 | virtual void contextMenuSelected(int); |
177 | QStringList subFolders(); | 179 | QStringList subFolders(); |
178 | virtual void refresh(bool force=false); | 180 | virtual void refresh(bool force=false); |
179 | 181 | ||
180 | protected: | 182 | protected: |
181 | void downloadMails(); | 183 | void downloadMails(); |
182 | virtual void createFolder(); | 184 | virtual void createFolder(); |
183 | QString m_Path; | 185 | QString m_Path; |
184 | AbstractMail *wrapper; | 186 | AbstractMail *wrapper; |
185 | QStringList currentFolders; | 187 | QStringList currentFolders; |
186 | }; | 188 | }; |
187 | 189 | ||
188 | class MHfolderItem : public AccountViewItem | 190 | class MHfolderItem : public AccountViewItem |
189 | { | 191 | { |
190 | 192 | ||
191 | public: | 193 | public: |
192 | MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHviewItem *parent , QListViewItem*after ); | 194 | MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHviewItem *parent , QListViewItem*after ); |
193 | MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); | 195 | MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); |
194 | virtual ~MHfolderItem(); | 196 | virtual ~MHfolderItem(); |
195 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); | 197 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); |
196 | virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&); | 198 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); |
197 | virtual QPopupMenu * getContextMenu(); | 199 | virtual QPopupMenu * getContextMenu(); |
198 | virtual void contextMenuSelected(int); | 200 | virtual void contextMenuSelected(int); |
199 | virtual const Opie::Core::OSmartPointer<Folder>&getFolder()const; | 201 | virtual const Opie::Core::OSmartPointer<Folder>&getFolder()const; |
200 | virtual bool isDraftfolder(); | 202 | virtual bool isDraftfolder(); |
201 | 203 | ||
202 | protected: | 204 | protected: |
203 | void downloadMails(); | 205 | void downloadMails(); |
204 | virtual void createFolder(); | 206 | virtual void createFolder(); |
205 | virtual void deleteFolder(); | 207 | virtual void deleteFolder(); |
206 | void initName(); | 208 | void initName(); |
207 | MHviewItem *mbox; | 209 | MHviewItem *mbox; |
208 | }; | 210 | }; |
209 | 211 | ||
210 | #endif | 212 | #endif |
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 811e57a..f0a163e 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -21,156 +21,156 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | |||
21 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 21 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
22 | SLOT( refresh(QListViewItem*) ) ); | 22 | SLOT( refresh(QListViewItem*) ) ); |
23 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 23 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
24 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 24 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); |
25 | setSorting(0); | 25 | setSorting(0); |
26 | } | 26 | } |
27 | 27 | ||
28 | AccountView::~AccountView() | 28 | AccountView::~AccountView() |
29 | { | 29 | { |
30 | imapAccounts.clear(); | 30 | imapAccounts.clear(); |
31 | mhAccounts.clear(); | 31 | mhAccounts.clear(); |
32 | } | 32 | } |
33 | 33 | ||
34 | void AccountView::slotContextMenu(int id) | 34 | void AccountView::slotContextMenu(int id) |
35 | { | 35 | { |
36 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 36 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
37 | if (!view) return; | 37 | if (!view) return; |
38 | view->contextMenuSelected(id); | 38 | view->contextMenuSelected(id); |
39 | } | 39 | } |
40 | 40 | ||
41 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 41 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
42 | { | 42 | { |
43 | if (button==1) {return;} | 43 | if (button==1) {return;} |
44 | if (!item) return; | 44 | if (!item) return; |
45 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 45 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
46 | QPopupMenu*m = view->getContextMenu(); | 46 | QPopupMenu*m = view->getContextMenu(); |
47 | if (!m) return; | 47 | if (!m) return; |
48 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 48 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
49 | m->setFocus(); | 49 | m->setFocus(); |
50 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 50 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
51 | delete m; | 51 | delete m; |
52 | } | 52 | } |
53 | 53 | ||
54 | void AccountView::populate( QList<Account> list ) | 54 | void AccountView::populate( QList<Account> list ) |
55 | { | 55 | { |
56 | clear(); | 56 | clear(); |
57 | 57 | ||
58 | imapAccounts.clear(); | 58 | imapAccounts.clear(); |
59 | mhAccounts.clear(); | 59 | mhAccounts.clear(); |
60 | 60 | ||
61 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); | 61 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); |
62 | 62 | ||
63 | Account *it; | 63 | Account *it; |
64 | for ( it = list.first(); it; it = list.next() ) | 64 | for ( it = list.first(); it; it = list.next() ) |
65 | { | 65 | { |
66 | if ( it->getType() == MAILLIB::A_IMAP ) | 66 | if ( it->getType() == MAILLIB::A_IMAP ) |
67 | { | 67 | { |
68 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 68 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
69 | qDebug( "added IMAP " + imap->getAccountName() ); | 69 | qDebug( "added IMAP " + imap->getAccountName() ); |
70 | imapAccounts.append(new IMAPviewItem( imap, this )); | 70 | imapAccounts.append(new IMAPviewItem( imap, this )); |
71 | } | 71 | } |
72 | else if ( it->getType() == MAILLIB::A_POP3 ) | 72 | else if ( it->getType() == MAILLIB::A_POP3 ) |
73 | { | 73 | { |
74 | POP3account *pop3 = static_cast<POP3account *>(it); | 74 | POP3account *pop3 = static_cast<POP3account *>(it); |
75 | qDebug( "added POP3 " + pop3->getAccountName() ); | 75 | qDebug( "added POP3 " + pop3->getAccountName() ); |
76 | /* must not be hold 'cause it isn't required */ | 76 | /* must not be hold 'cause it isn't required */ |
77 | (void) new POP3viewItem( pop3, this ); | 77 | (void) new POP3viewItem( pop3, this ); |
78 | } | 78 | } |
79 | else if ( it->getType() == MAILLIB::A_NNTP ) | 79 | else if ( it->getType() == MAILLIB::A_NNTP ) |
80 | { | 80 | { |
81 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | 81 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); |
82 | qDebug( "added NNTP " + nntp->getAccountName() ); | 82 | qDebug( "added NNTP " + nntp->getAccountName() ); |
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 | 91 | ||
92 | qDebug("AccountView refresh..."); | 92 | qDebug("AccountView refresh..."); |
93 | if ( item ) | 93 | if ( item ) |
94 | { | 94 | { |
95 | m_currentItem = item; | 95 | m_currentItem = item; |
96 | QValueList<RecMailP> headerlist; | 96 | QValueList<RecMailP> headerlist; |
97 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 97 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
98 | view->refresh(headerlist); | 98 | view->refresh(headerlist); |
99 | emit refreshMailview(headerlist); | 99 | emit refreshMailview(headerlist); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | void AccountView::refreshCurrent() | 103 | void AccountView::refreshCurrent() |
104 | { | 104 | { |
105 | m_currentItem = currentItem(); | 105 | m_currentItem = currentItem(); |
106 | if ( !m_currentItem ) return; | 106 | if ( !m_currentItem ) return; |
107 | QValueList<RecMailP> headerlist; | 107 | QValueList<RecMailP> headerlist; |
108 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 108 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
109 | view->refresh(headerlist); | 109 | view->refresh(headerlist); |
110 | emit refreshMailview(headerlist); | 110 | emit refreshMailview(headerlist); |
111 | } | 111 | } |
112 | 112 | ||
113 | void AccountView::refreshAll() | 113 | void AccountView::refreshAll() |
114 | { | 114 | { |
115 | } | 115 | } |
116 | 116 | ||
117 | RecBody AccountView::fetchBody(const RecMailP&aMail) | 117 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) |
118 | { | 118 | { |
119 | QListViewItem*item = selectedItem (); | 119 | QListViewItem*item = selectedItem (); |
120 | if (!item) return RecBody(); | 120 | if (!item) return new RecBody(); |
121 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 121 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
122 | return view->fetchBody(aMail); | 122 | return view->fetchBody(aMail); |
123 | } | 123 | } |
124 | 124 | ||
125 | void AccountView::setupFolderselect(Selectstore*sels) | 125 | void AccountView::setupFolderselect(Selectstore*sels) |
126 | { | 126 | { |
127 | QPEApplication::showDialog( sels ); | 127 | QPEApplication::showDialog( sels ); |
128 | QStringList sFolders; | 128 | QStringList sFolders; |
129 | unsigned int i = 0; | 129 | unsigned int i = 0; |
130 | for (i=0; i < mhAccounts.count();++i) | 130 | for (i=0; i < mhAccounts.count();++i) |
131 | { | 131 | { |
132 | mhAccounts[i]->refresh(false); | 132 | mhAccounts[i]->refresh(false); |
133 | sFolders = mhAccounts[i]->subFolders(); | 133 | sFolders = mhAccounts[i]->subFolders(); |
134 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 134 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
135 | } | 135 | } |
136 | for (i=0; i < imapAccounts.count();++i) | 136 | for (i=0; i < imapAccounts.count();++i) |
137 | { | 137 | { |
138 | if (imapAccounts[i]->offline()) | 138 | if (imapAccounts[i]->offline()) |
139 | continue; | 139 | continue; |
140 | imapAccounts[i]->refreshFolders(false); | 140 | imapAccounts[i]->refreshFolders(false); |
141 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 141 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 145 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
146 | { | 146 | { |
147 | AbstractMail*targetMail = 0; | 147 | AbstractMail*targetMail = 0; |
148 | QString targetFolder = ""; | 148 | QString targetFolder = ""; |
149 | Selectstore sels; | 149 | Selectstore sels; |
150 | setupFolderselect(&sels); | 150 | setupFolderselect(&sels); |
151 | if (!sels.exec()) return; | 151 | if (!sels.exec()) return; |
152 | targetMail = sels.currentMail(); | 152 | targetMail = sels.currentMail(); |
153 | targetFolder = sels.currentFolder(); | 153 | targetFolder = sels.currentFolder(); |
154 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 154 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
155 | targetFolder.isEmpty()) | 155 | targetFolder.isEmpty()) |
156 | { | 156 | { |
157 | return; | 157 | return; |
158 | } | 158 | } |
159 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 159 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
160 | { | 160 | { |
161 | QMessageBox::critical(0,tr("Error creating new Folder"), | 161 | QMessageBox::critical(0,tr("Error creating new Folder"), |
162 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 162 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | qDebug("Targetfolder: %s",targetFolder.latin1()); | 165 | qDebug("Targetfolder: %s",targetFolder.latin1()); |
166 | qDebug("Fromfolder: %s",fromFolder->getName().latin1()); | 166 | qDebug("Fromfolder: %s",fromFolder->getName().latin1()); |
167 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); | 167 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); |
168 | refreshCurrent(); | 168 | refreshCurrent(); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool AccountView::currentisDraft() | 171 | bool AccountView::currentisDraft() |
172 | { | 172 | { |
173 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 173 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
174 | if (!view) return false; | 174 | if (!view) return false; |
175 | return view->isDraftfolder(); | 175 | return view->isDraftfolder(); |
176 | } | 176 | } |
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index b082b1f..787b0b0 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -1,45 +1,45 @@ | |||
1 | #ifndef ACCOUNTVIEW_H | 1 | #ifndef ACCOUNTVIEW_H |
2 | #define ACCOUNTVIEW_H | 2 | #define ACCOUNTVIEW_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include <opie2/osmartpointer.h> | 6 | #include <opie2/osmartpointer.h> |
7 | #include <libmailwrapper/mailtypes.h> | 7 | #include <libmailwrapper/mailtypes.h> |
8 | 8 | ||
9 | class Selectstore; | 9 | class Selectstore; |
10 | class Folder; | 10 | class Folder; |
11 | class AbstractMail; | 11 | class AbstractMail; |
12 | class Account; | 12 | class Account; |
13 | class IMAPviewItem; | 13 | class IMAPviewItem; |
14 | class MHviewItem; | 14 | class MHviewItem; |
15 | 15 | ||
16 | class AccountView : public QListView | 16 | class AccountView : public QListView |
17 | { | 17 | { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | 19 | ||
20 | public: | 20 | public: |
21 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 21 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
22 | virtual ~AccountView(); | 22 | virtual ~AccountView(); |
23 | virtual void populate( QList<Account> list ); | 23 | virtual void populate( QList<Account> list ); |
24 | virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail); | 24 | virtual RecBodyP fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail); |
25 | virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper); | 25 | virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper); |
26 | virtual bool currentisDraft(); | 26 | virtual bool currentisDraft(); |
27 | 27 | ||
28 | public slots: | 28 | public slots: |
29 | virtual void refreshAll(); | 29 | virtual void refreshAll(); |
30 | virtual void refresh(QListViewItem *item); | 30 | virtual void refresh(QListViewItem *item); |
31 | virtual void refreshCurrent(); | 31 | virtual void refreshCurrent(); |
32 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); | 32 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); |
33 | virtual void slotContextMenu(int id); | 33 | virtual void slotContextMenu(int id); |
34 | void setupFolderselect(Selectstore*sels); | 34 | void setupFolderselect(Selectstore*sels); |
35 | 35 | ||
36 | signals: | 36 | signals: |
37 | void refreshMailview(const QValueList<RecMailP>& ); | 37 | void refreshMailview(const QValueList<RecMailP>& ); |
38 | 38 | ||
39 | protected: | 39 | protected: |
40 | QListViewItem* m_currentItem; | 40 | QListViewItem* m_currentItem; |
41 | QValueList<IMAPviewItem*> imapAccounts; | 41 | QValueList<IMAPviewItem*> imapAccounts; |
42 | QValueList<MHviewItem*> mhAccounts; | 42 | QValueList<MHviewItem*> mhAccounts; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | #endif | 45 | #endif |
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index 5bc2883..988a1d9 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp | |||
@@ -187,116 +187,116 @@ void ComposeMail::accept() | |||
187 | } | 187 | } |
188 | 188 | ||
189 | #if 0 | 189 | #if 0 |
190 | qDebug( "Sending Mail with " + | 190 | qDebug( "Sending Mail with " + |
191 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); | 191 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); |
192 | #endif | 192 | #endif |
193 | Opie::Core::OSmartPointer<Mail> mail=new Mail; | 193 | Opie::Core::OSmartPointer<Mail> mail=new Mail; |
194 | 194 | ||
195 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 195 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
196 | mail->setMail(fromBox->currentText()); | 196 | mail->setMail(fromBox->currentText()); |
197 | 197 | ||
198 | if ( !toLine->text().isEmpty() ) { | 198 | if ( !toLine->text().isEmpty() ) { |
199 | mail->setTo( toLine->text() ); | 199 | mail->setTo( toLine->text() ); |
200 | } else { | 200 | } else { |
201 | QMessageBox::warning(0,tr("Sending mail"), | 201 | QMessageBox::warning(0,tr("Sending mail"), |
202 | tr("No Receiver spezified" ) ); | 202 | tr("No Receiver spezified" ) ); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | mail->setName(senderNameEdit->text()); | 205 | mail->setName(senderNameEdit->text()); |
206 | mail->setCC( ccLine->text() ); | 206 | mail->setCC( ccLine->text() ); |
207 | mail->setBCC( bccLine->text() ); | 207 | mail->setBCC( bccLine->text() ); |
208 | mail->setReply( replyLine->text() ); | 208 | mail->setReply( replyLine->text() ); |
209 | mail->setSubject( subjectLine->text() ); | 209 | mail->setSubject( subjectLine->text() ); |
210 | if (!m_replyid.isEmpty()) { | 210 | if (!m_replyid.isEmpty()) { |
211 | QStringList ids; | 211 | QStringList ids; |
212 | ids.append(m_replyid); | 212 | ids.append(m_replyid); |
213 | mail->setInreply(ids); | 213 | mail->setInreply(ids); |
214 | } | 214 | } |
215 | QString txt = message->text(); | 215 | QString txt = message->text(); |
216 | if ( !sigMultiLine->text().isEmpty() ) { | 216 | if ( !sigMultiLine->text().isEmpty() ) { |
217 | txt.append( "\n--\n" ); | 217 | txt.append( "\n--\n" ); |
218 | txt.append( sigMultiLine->text() ); | 218 | txt.append( sigMultiLine->text() ); |
219 | } | 219 | } |
220 | mail->setMessage( txt ); | 220 | mail->setMessage( txt ); |
221 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 221 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
222 | while ( it != NULL ) { | 222 | while ( it != NULL ) { |
223 | mail->addAttachment( it->getAttachment() ); | 223 | mail->addAttachment( it->getAttachment() ); |
224 | it = (AttachViewItem *) it->nextSibling(); | 224 | it = (AttachViewItem *) it->nextSibling(); |
225 | } | 225 | } |
226 | 226 | ||
227 | SMTPwrapper wrapper( smtp ); | 227 | SMTPwrapper wrapper( smtp ); |
228 | wrapper.sendMail( mail,checkBoxLater->isChecked() ); | 228 | wrapper.sendMail( mail,checkBoxLater->isChecked() ); |
229 | 229 | ||
230 | QDialog::accept(); | 230 | QDialog::accept(); |
231 | } | 231 | } |
232 | 232 | ||
233 | void ComposeMail::reject() | 233 | void ComposeMail::reject() |
234 | { | 234 | { |
235 | int yesno = QMessageBox::warning(0,tr("Store message"), | 235 | int yesno = QMessageBox::warning(0,tr("Store message"), |
236 | tr("Store message into drafts?"), | 236 | tr("Store message into drafts?"), |
237 | tr("Yes"), | 237 | tr("Yes"), |
238 | tr("No"),QString::null,0,1); | 238 | tr("No"),QString::null,0,1); |
239 | 239 | ||
240 | if (yesno == 0) { | 240 | if (yesno == 0) { |
241 | Opie::Core::OSmartPointer<Mail> mail=new Mail(); | 241 | Opie::Core::OSmartPointer<Mail> mail=new Mail(); |
242 | mail->setMail(fromBox->currentText()); | 242 | mail->setMail(fromBox->currentText()); |
243 | mail->setTo( toLine->text() ); | 243 | mail->setTo( toLine->text() ); |
244 | mail->setName(senderNameEdit->text()); | 244 | mail->setName(senderNameEdit->text()); |
245 | mail->setCC( ccLine->text() ); | 245 | mail->setCC( ccLine->text() ); |
246 | mail->setBCC( bccLine->text() ); | 246 | mail->setBCC( bccLine->text() ); |
247 | mail->setReply( replyLine->text() ); | 247 | mail->setReply( replyLine->text() ); |
248 | mail->setSubject( subjectLine->text() ); | 248 | mail->setSubject( subjectLine->text() ); |
249 | if (!m_replyid.isEmpty()) { | 249 | if (!m_replyid.isEmpty()) { |
250 | QStringList ids; | 250 | QStringList ids; |
251 | ids.append(m_replyid); | 251 | ids.append(m_replyid); |
252 | mail->setInreply(ids); | 252 | mail->setInreply(ids); |
253 | } | 253 | } |
254 | QString txt = message->text(); | 254 | QString txt = message->text(); |
255 | if ( !sigMultiLine->text().isEmpty() ) { | 255 | if ( !sigMultiLine->text().isEmpty() ) { |
256 | txt.append( "\n--\n" ); | 256 | txt.append( "\n--\n" ); |
257 | txt.append( sigMultiLine->text() ); | 257 | txt.append( sigMultiLine->text() ); |
258 | } | 258 | } |
259 | qDebug(txt); | 259 | qDebug(txt); |
260 | mail->setMessage( txt ); | 260 | mail->setMessage( txt ); |
261 | 261 | ||
262 | /* only use the default drafts folder name! */ | 262 | /* only use the default drafts folder name! */ |
263 | Storemail wrapper(AbstractMail::draftFolder()); | 263 | Storemail wrapper(AbstractMail::draftFolder()); |
264 | wrapper.storeMail(mail); | 264 | wrapper.storeMail(mail); |
265 | 265 | ||
266 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 266 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
267 | /* attachments we will ignore! */ | 267 | /* attachments we will ignore! */ |
268 | if ( it != NULL ) { | 268 | if ( it != NULL ) { |
269 | QMessageBox::warning(0,tr("Store message"), | 269 | QMessageBox::warning(0,tr("Store message"), |
270 | tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); | 270 | tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | QDialog::reject(); | 273 | QDialog::reject(); |
274 | } | 274 | } |
275 | 275 | ||
276 | ComposeMail::~ComposeMail() | 276 | ComposeMail::~ComposeMail() |
277 | { | 277 | { |
278 | } | 278 | } |
279 | 279 | ||
280 | void ComposeMail::reEditMail(const RecMailP¤t) | 280 | void ComposeMail::reEditMail(const RecMailP¤t) |
281 | { | 281 | { |
282 | RecMailP data = current; | 282 | RecMailP data = current; |
283 | message->setText(data->Wrapper()->fetchBody(current).Bodytext()); | 283 | message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); |
284 | subjectLine->setText( data->getSubject()); | 284 | subjectLine->setText( data->getSubject()); |
285 | toLine->setText(data->To().join(",")); | 285 | toLine->setText(data->To().join(",")); |
286 | ccLine->setText(data->CC().join(",")); | 286 | ccLine->setText(data->CC().join(",")); |
287 | bccLine->setText(data->Bcc().join(",")); | 287 | bccLine->setText(data->Bcc().join(",")); |
288 | replyLine->setText(data->Replyto()); | 288 | replyLine->setText(data->Replyto()); |
289 | } | 289 | } |
290 | 290 | ||
291 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 291 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
292 | : QListViewItem( parent ) | 292 | : QListViewItem( parent ) |
293 | { | 293 | { |
294 | attachment = att; | 294 | attachment = att; |
295 | qDebug( att->getMimeType() ); | 295 | qDebug( att->getMimeType() ); |
296 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? | 296 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? |
297 | Resource::loadPixmap( "UnknownDocument-14" ) : | 297 | Resource::loadPixmap( "UnknownDocument-14" ) : |
298 | attachment->getDocLnk().pixmap() ); | 298 | attachment->getDocLnk().pixmap() ); |
299 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); | 299 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); |
300 | setText( 1, QString::number( att->getSize() ) ); | 300 | setText( 1, QString::number( att->getSize() ) ); |
301 | } | 301 | } |
302 | 302 | ||
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 2d55c83..e5d64a6 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -1,72 +1,72 @@ | |||
1 | #ifndef __abstract_mail_ | 1 | #ifndef __abstract_mail_ |
2 | #define __abstract_mail_ | 2 | #define __abstract_mail_ |
3 | 3 | ||
4 | #include "maildefines.h" | 4 | #include "maildefines.h" |
5 | 5 | ||
6 | #include "settings.h" | 6 | #include "settings.h" |
7 | 7 | ||
8 | #include <qobject.h> | 8 | #include <qobject.h> |
9 | #include <opie2/osmartpointer.h> | 9 | #include <opie2/osmartpointer.h> |
10 | #include "mailtypes.h" | 10 | #include "mailtypes.h" |
11 | 11 | ||
12 | class IMAPwrapper; | 12 | class IMAPwrapper; |
13 | class POP3wrapper; | 13 | class POP3wrapper; |
14 | class Folder; | 14 | class Folder; |
15 | class encodedString; | 15 | class encodedString; |
16 | struct folderStat; | 16 | struct folderStat; |
17 | 17 | ||
18 | class AbstractMail:public QObject | 18 | class AbstractMail:public QObject |
19 | { | 19 | { |
20 | Q_OBJECT | 20 | Q_OBJECT |
21 | public: | 21 | public: |
22 | AbstractMail(){}; | 22 | AbstractMail(){}; |
23 | virtual ~AbstractMail(){} | 23 | virtual ~AbstractMail(){} |
24 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0; | 24 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0; |
25 | virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0; | 25 | virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0; |
26 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 26 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
27 | virtual RecBody fetchBody(const RecMailP&mail)=0; | 27 | virtual RecBodyP fetchBody(const RecMailP&mail)=0; |
28 | virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part)=0; | 28 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0; |
29 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part)=0; | 29 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0; |
30 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part)=0; | 30 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0; |
31 | virtual encodedString* fetchRawBody(const RecMailP&mail)=0; | 31 | virtual encodedString* fetchRawBody(const RecMailP&mail)=0; |
32 | 32 | ||
33 | virtual void deleteMail(const RecMailP&mail)=0; | 33 | virtual void deleteMail(const RecMailP&mail)=0; |
34 | virtual void answeredMail(const RecMailP&mail)=0; | 34 | virtual void answeredMail(const RecMailP&mail)=0; |
35 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0; | 35 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0; |
36 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target); | 36 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target); |
37 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; | 37 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; |
38 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 38 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
39 | 39 | ||
40 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 40 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
41 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 41 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
42 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 42 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
43 | 43 | ||
44 | virtual void cleanMimeCache(){}; | 44 | virtual void cleanMimeCache(){}; |
45 | /* mail box methods */ | 45 | /* mail box methods */ |
46 | /* parameter is the box to create. | 46 | /* parameter is the box to create. |
47 | * if the implementing subclass has prefixes, | 47 | * if the implementing subclass has prefixes, |
48 | * them has to be appended automatic. | 48 | * them has to be appended automatic. |
49 | */ | 49 | */ |
50 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, | 50 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, |
51 | const QString& delemiter="/",bool getsubfolder=false); | 51 | const QString& delemiter="/",bool getsubfolder=false); |
52 | virtual void logout()=0; | 52 | virtual void logout()=0; |
53 | 53 | ||
54 | static AbstractMail* getWrapper(IMAPaccount *a); | 54 | static AbstractMail* getWrapper(IMAPaccount *a); |
55 | static AbstractMail* getWrapper(POP3account *a); | 55 | static AbstractMail* getWrapper(POP3account *a); |
56 | static AbstractMail* getWrapper(NNTPaccount *a); | 56 | static AbstractMail* getWrapper(NNTPaccount *a); |
57 | /* mbox only! */ | 57 | /* mbox only! */ |
58 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); | 58 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
59 | static AbstractMail* getWrapper(Account*a); | 59 | static AbstractMail* getWrapper(Account*a); |
60 | 60 | ||
61 | static QString defaultLocalfolder(); | 61 | static QString defaultLocalfolder(); |
62 | static QString draftFolder(); | 62 | static QString draftFolder(); |
63 | 63 | ||
64 | virtual MAILLIB::ATYPE getType()const=0; | 64 | virtual MAILLIB::ATYPE getType()const=0; |
65 | virtual const QString&getName()const=0; | 65 | virtual const QString&getName()const=0; |
66 | 66 | ||
67 | protected: | 67 | protected: |
68 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 68 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
69 | static QString convert_String(const char*text); | 69 | static QString convert_String(const char*text); |
70 | static QString gen_attachment_id(); | 70 | static QString gen_attachment_id(); |
71 | }; | 71 | }; |
72 | #endif | 72 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index f428415..0c68280 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,447 +1,447 @@ | |||
1 | #include "genericwrapper.h" | 1 | #include "genericwrapper.h" |
2 | #include <libetpan/libetpan.h> | 2 | #include <libetpan/libetpan.h> |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | 4 | ||
5 | using namespace Opie::Core; | 5 | using namespace Opie::Core; |
6 | Genericwrapper::Genericwrapper() | 6 | Genericwrapper::Genericwrapper() |
7 | : AbstractMail() | 7 | : AbstractMail() |
8 | { | 8 | { |
9 | bodyCache.clear(); | 9 | bodyCache.clear(); |
10 | m_storage = 0; | 10 | m_storage = 0; |
11 | m_folder = 0; | 11 | m_folder = 0; |
12 | } | 12 | } |
13 | 13 | ||
14 | Genericwrapper::~Genericwrapper() | 14 | Genericwrapper::~Genericwrapper() |
15 | { | 15 | { |
16 | if (m_folder) { | 16 | if (m_folder) { |
17 | mailfolder_free(m_folder); | 17 | mailfolder_free(m_folder); |
18 | } | 18 | } |
19 | if (m_storage) { | 19 | if (m_storage) { |
20 | mailstorage_free(m_storage); | 20 | mailstorage_free(m_storage); |
21 | } | 21 | } |
22 | cleanMimeCache(); | 22 | cleanMimeCache(); |
23 | } | 23 | } |
24 | 24 | ||
25 | void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) | 25 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
26 | { | 26 | { |
27 | if (!mime) { | 27 | if (!mime) { |
28 | return; | 28 | return; |
29 | } | 29 | } |
30 | mailmime_field*field = 0; | 30 | mailmime_field*field = 0; |
31 | mailmime_single_fields fields; | 31 | mailmime_single_fields fields; |
32 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 32 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
33 | if (mime->mm_mime_fields != NULL) { | 33 | if (mime->mm_mime_fields != NULL) { |
34 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 34 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
35 | mime->mm_content_type); | 35 | mime->mm_content_type); |
36 | } | 36 | } |
37 | 37 | ||
38 | mailmime_content*type = fields.fld_content; | 38 | mailmime_content*type = fields.fld_content; |
39 | clistcell*current; | 39 | clistcell*current; |
40 | if (!type) { | 40 | if (!type) { |
41 | target.setType("text"); | 41 | target->setType("text"); |
42 | target.setSubtype("plain"); | 42 | target->setSubtype("plain"); |
43 | } else { | 43 | } else { |
44 | target.setSubtype(type->ct_subtype); | 44 | target->setSubtype(type->ct_subtype); |
45 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 45 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
46 | case MAILMIME_DISCRETE_TYPE_TEXT: | 46 | case MAILMIME_DISCRETE_TYPE_TEXT: |
47 | target.setType("text"); | 47 | target->setType("text"); |
48 | break; | 48 | break; |
49 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 49 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
50 | target.setType("image"); | 50 | target->setType("image"); |
51 | break; | 51 | break; |
52 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 52 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
53 | target.setType("audio"); | 53 | target->setType("audio"); |
54 | break; | 54 | break; |
55 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 55 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
56 | target.setType("video"); | 56 | target->setType("video"); |
57 | break; | 57 | break; |
58 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 58 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
59 | target.setType("application"); | 59 | target->setType("application"); |
60 | break; | 60 | break; |
61 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 61 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
62 | default: | 62 | default: |
63 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 63 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
64 | target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 64 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
65 | } | 65 | } |
66 | break; | 66 | break; |
67 | } | 67 | } |
68 | if (type->ct_parameters) { | 68 | if (type->ct_parameters) { |
69 | fillParameters(target,type->ct_parameters); | 69 | fillParameters(target,type->ct_parameters); |
70 | } | 70 | } |
71 | } | 71 | } |
72 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { | 72 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { |
73 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { | 73 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { |
74 | field = (mailmime_field*)current->data; | 74 | field = (mailmime_field*)current->data; |
75 | switch(field->fld_type) { | 75 | switch(field->fld_type) { |
76 | case MAILMIME_FIELD_TRANSFER_ENCODING: | 76 | case MAILMIME_FIELD_TRANSFER_ENCODING: |
77 | target.setEncoding(getencoding(field->fld_data.fld_encoding)); | 77 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); |
78 | break; | 78 | break; |
79 | case MAILMIME_FIELD_ID: | 79 | case MAILMIME_FIELD_ID: |
80 | target.setIdentifier(field->fld_data.fld_id); | 80 | target->setIdentifier(field->fld_data.fld_id); |
81 | break; | 81 | break; |
82 | case MAILMIME_FIELD_DESCRIPTION: | 82 | case MAILMIME_FIELD_DESCRIPTION: |
83 | target.setDescription(field->fld_data.fld_description); | 83 | target->setDescription(field->fld_data.fld_description); |
84 | break; | 84 | break; |
85 | default: | 85 | default: |
86 | break; | 86 | break; |
87 | } | 87 | } |
88 | } | 88 | } |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | void Genericwrapper::fillParameters(RecPart&target,clist*parameters) | 92 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) |
93 | { | 93 | { |
94 | if (!parameters) {return;} | 94 | if (!parameters) {return;} |
95 | clistcell*current=0; | 95 | clistcell*current=0; |
96 | mailmime_parameter*param; | 96 | mailmime_parameter*param; |
97 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { | 97 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { |
98 | param = (mailmime_parameter*)current->data; | 98 | param = (mailmime_parameter*)current->data; |
99 | if (param) { | 99 | if (param) { |
100 | target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 100 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | 105 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) |
106 | { | 106 | { |
107 | QString enc="7bit"; | 107 | QString enc="7bit"; |
108 | if (!aEnc) return enc; | 108 | if (!aEnc) return enc; |
109 | switch(aEnc->enc_type) { | 109 | switch(aEnc->enc_type) { |
110 | case MAILMIME_MECHANISM_7BIT: | 110 | case MAILMIME_MECHANISM_7BIT: |
111 | enc = "7bit"; | 111 | enc = "7bit"; |
112 | break; | 112 | break; |
113 | case MAILMIME_MECHANISM_8BIT: | 113 | case MAILMIME_MECHANISM_8BIT: |
114 | enc = "8bit"; | 114 | enc = "8bit"; |
115 | break; | 115 | break; |
116 | case MAILMIME_MECHANISM_BINARY: | 116 | case MAILMIME_MECHANISM_BINARY: |
117 | enc = "binary"; | 117 | enc = "binary"; |
118 | break; | 118 | break; |
119 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 119 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
120 | enc = "quoted-printable"; | 120 | enc = "quoted-printable"; |
121 | break; | 121 | break; |
122 | case MAILMIME_MECHANISM_BASE64: | 122 | case MAILMIME_MECHANISM_BASE64: |
123 | enc = "base64"; | 123 | enc = "base64"; |
124 | break; | 124 | break; |
125 | case MAILMIME_MECHANISM_TOKEN: | 125 | case MAILMIME_MECHANISM_TOKEN: |
126 | default: | 126 | default: |
127 | if (aEnc->enc_token) { | 127 | if (aEnc->enc_token) { |
128 | enc = QString(aEnc->enc_token); | 128 | enc = QString(aEnc->enc_token); |
129 | } | 129 | } |
130 | break; | 130 | break; |
131 | } | 131 | } |
132 | return enc; | 132 | return enc; |
133 | } | 133 | } |
134 | 134 | ||
135 | void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 135 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
136 | { | 136 | { |
137 | if (current_rec >= 10) { | 137 | if (current_rec >= 10) { |
138 | qDebug("too deep recursion!"); | 138 | qDebug("too deep recursion!"); |
139 | } | 139 | } |
140 | if (!message || !mime) { | 140 | if (!message || !mime) { |
141 | return; | 141 | return; |
142 | } | 142 | } |
143 | int r; | 143 | int r; |
144 | char*data = 0; | 144 | char*data = 0; |
145 | size_t len; | 145 | size_t len; |
146 | clistiter * cur = 0; | 146 | clistiter * cur = 0; |
147 | QString b; | 147 | QString b; |
148 | RecPart part; | 148 | RecPartP part = new RecPart(); |
149 | 149 | ||
150 | switch (mime->mm_type) { | 150 | switch (mime->mm_type) { |
151 | case MAILMIME_SINGLE: | 151 | case MAILMIME_SINGLE: |
152 | { | 152 | { |
153 | QValueList<int>countlist = recList; | 153 | QValueList<int>countlist = recList; |
154 | countlist.append(current_count); | 154 | countlist.append(current_count); |
155 | r = mailmessage_fetch_section(message,mime,&data,&len); | 155 | r = mailmessage_fetch_section(message,mime,&data,&len); |
156 | part.setSize(len); | 156 | part->setSize(len); |
157 | part.setPositionlist(countlist); | 157 | part->setPositionlist(countlist); |
158 | b = gen_attachment_id(); | 158 | b = gen_attachment_id(); |
159 | part.setIdentifier(b); | 159 | part->setIdentifier(b); |
160 | fillSingleBody(part,message,mime); | 160 | fillSingleBody(part,message,mime); |
161 | if (part.Type()=="text" && target.Bodytext().isNull()) { | 161 | if (part->Type()=="text" && target->Bodytext().isNull()) { |
162 | encodedString*rs = new encodedString(); | 162 | encodedString*rs = new encodedString(); |
163 | rs->setContent(data,len); | 163 | rs->setContent(data,len); |
164 | encodedString*res = decode_String(rs,part.Encoding()); | 164 | encodedString*res = decode_String(rs,part->Encoding()); |
165 | if (countlist.count()>2) { | 165 | if (countlist.count()>2) { |
166 | bodyCache[b]=rs; | 166 | bodyCache[b]=rs; |
167 | target.addPart(part); | 167 | target->addPart(part); |
168 | } else { | 168 | } else { |
169 | delete rs; | 169 | delete rs; |
170 | } | 170 | } |
171 | b = QString(res->Content()); | 171 | b = QString(res->Content()); |
172 | delete res; | 172 | delete res; |
173 | target.setBodytext(b); | 173 | target->setBodytext(b); |
174 | target.setDescription(part); | 174 | target->setDescription(part); |
175 | } else { | 175 | } else { |
176 | bodyCache[b]=new encodedString(data,len); | 176 | bodyCache[b]=new encodedString(data,len); |
177 | target.addPart(part); | 177 | target->addPart(part); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | break; | 180 | break; |
181 | case MAILMIME_MULTIPLE: | 181 | case MAILMIME_MULTIPLE: |
182 | { | 182 | { |
183 | unsigned int ccount = 1; | 183 | unsigned int ccount = 1; |
184 | mailmime*cbody=0; | 184 | mailmime*cbody=0; |
185 | QValueList<int>countlist = recList; | 185 | QValueList<int>countlist = recList; |
186 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 186 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
187 | cbody = (mailmime*)clist_content(cur); | 187 | cbody = (mailmime*)clist_content(cur); |
188 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 188 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
189 | RecPart targetPart; | 189 | RecPartP targetPart = new RecPart(); |
190 | targetPart.setType("multipart"); | 190 | targetPart->setType("multipart"); |
191 | countlist.append(current_count); | 191 | countlist.append(current_count); |
192 | targetPart.setPositionlist(countlist); | 192 | targetPart->setPositionlist(countlist); |
193 | target.addPart(targetPart); | 193 | target->addPart(targetPart); |
194 | } | 194 | } |
195 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 195 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
196 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 196 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
197 | countlist = recList; | 197 | countlist = recList; |
198 | } | 198 | } |
199 | ++ccount; | 199 | ++ccount; |
200 | } | 200 | } |
201 | } | 201 | } |
202 | break; | 202 | break; |
203 | case MAILMIME_MESSAGE: | 203 | case MAILMIME_MESSAGE: |
204 | { | 204 | { |
205 | QValueList<int>countlist = recList; | 205 | QValueList<int>countlist = recList; |
206 | countlist.append(current_count); | 206 | countlist.append(current_count); |
207 | /* the own header is always at recursion 0 - we don't need that */ | 207 | /* the own header is always at recursion 0 - we don't need that */ |
208 | if (current_rec > 0) { | 208 | if (current_rec > 0) { |
209 | part.setPositionlist(countlist); | 209 | part->setPositionlist(countlist); |
210 | r = mailmessage_fetch_section(message,mime,&data,&len); | 210 | r = mailmessage_fetch_section(message,mime,&data,&len); |
211 | part.setSize(len); | 211 | part->setSize(len); |
212 | part.setPositionlist(countlist); | 212 | part->setPositionlist(countlist); |
213 | b = gen_attachment_id(); | 213 | b = gen_attachment_id(); |
214 | part.setIdentifier(b); | 214 | part->setIdentifier(b); |
215 | part.setType("message"); | 215 | part->setType("message"); |
216 | part.setSubtype("rfc822"); | 216 | part->setSubtype("rfc822"); |
217 | bodyCache[b]=new encodedString(data,len); | 217 | bodyCache[b]=new encodedString(data,len); |
218 | target.addPart(part); | 218 | target->addPart(part); |
219 | } | 219 | } |
220 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 220 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
221 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 221 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
222 | } | 222 | } |
223 | } | 223 | } |
224 | break; | 224 | break; |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | RecBody Genericwrapper::parseMail( mailmessage * msg ) | 228 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) |
229 | { | 229 | { |
230 | int err = MAILIMF_NO_ERROR; | 230 | int err = MAILIMF_NO_ERROR; |
231 | mailmime_single_fields fields; | 231 | mailmime_single_fields fields; |
232 | /* is bound to msg and will be freed there */ | 232 | /* is bound to msg and will be freed there */ |
233 | mailmime * mime=0; | 233 | mailmime * mime=0; |
234 | RecBody body; | 234 | RecBodyP body = new RecBody(); |
235 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 235 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
236 | err = mailmessage_get_bodystructure(msg,&mime); | 236 | err = mailmessage_get_bodystructure(msg,&mime); |
237 | QValueList<int>recList; | 237 | QValueList<int>recList; |
238 | traverseBody(body,msg,mime,recList); | 238 | traverseBody(body,msg,mime,recList); |
239 | return body; | 239 | return body; |
240 | } | 240 | } |
241 | 241 | ||
242 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | 242 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) |
243 | { | 243 | { |
244 | char tmp[23]; | 244 | char tmp[23]; |
245 | 245 | ||
246 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 246 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
247 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 247 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
248 | 248 | ||
249 | return QString( tmp ); | 249 | return QString( tmp ); |
250 | } | 250 | } |
251 | 251 | ||
252 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 252 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
253 | { | 253 | { |
254 | QString result( "" ); | 254 | QString result( "" ); |
255 | 255 | ||
256 | bool first = true; | 256 | bool first = true; |
257 | if (list == 0) return result; | 257 | if (list == 0) return result; |
258 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 258 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
259 | mailimf_address *addr = (mailimf_address *) current->data; | 259 | mailimf_address *addr = (mailimf_address *) current->data; |
260 | 260 | ||
261 | if ( !first ) { | 261 | if ( !first ) { |
262 | result.append( "," ); | 262 | result.append( "," ); |
263 | } else { | 263 | } else { |
264 | first = false; | 264 | first = false; |
265 | } | 265 | } |
266 | 266 | ||
267 | switch ( addr->ad_type ) { | 267 | switch ( addr->ad_type ) { |
268 | case MAILIMF_ADDRESS_MAILBOX: | 268 | case MAILIMF_ADDRESS_MAILBOX: |
269 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 269 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
270 | break; | 270 | break; |
271 | case MAILIMF_ADDRESS_GROUP: | 271 | case MAILIMF_ADDRESS_GROUP: |
272 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 272 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
273 | break; | 273 | break; |
274 | default: | 274 | default: |
275 | qDebug( "Generic: unkown mailimf address type" ); | 275 | qDebug( "Generic: unkown mailimf address type" ); |
276 | break; | 276 | break; |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | return result; | 280 | return result; |
281 | } | 281 | } |
282 | 282 | ||
283 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 283 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
284 | { | 284 | { |
285 | QString result( "" ); | 285 | QString result( "" ); |
286 | 286 | ||
287 | result.append( group->grp_display_name ); | 287 | result.append( group->grp_display_name ); |
288 | result.append( ": " ); | 288 | result.append( ": " ); |
289 | 289 | ||
290 | if ( group->grp_mb_list != NULL ) { | 290 | if ( group->grp_mb_list != NULL ) { |
291 | result.append( parseMailboxList( group->grp_mb_list ) ); | 291 | result.append( parseMailboxList( group->grp_mb_list ) ); |
292 | } | 292 | } |
293 | 293 | ||
294 | result.append( ";" ); | 294 | result.append( ";" ); |
295 | 295 | ||
296 | return result; | 296 | return result; |
297 | } | 297 | } |
298 | 298 | ||
299 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 299 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) |
300 | { | 300 | { |
301 | QString result( "" ); | 301 | QString result( "" ); |
302 | 302 | ||
303 | if ( box->mb_display_name == NULL ) { | 303 | if ( box->mb_display_name == NULL ) { |
304 | result.append( box->mb_addr_spec ); | 304 | result.append( box->mb_addr_spec ); |
305 | } else { | 305 | } else { |
306 | result.append( convert_String(box->mb_display_name).latin1() ); | 306 | result.append( convert_String(box->mb_display_name).latin1() ); |
307 | result.append( " <" ); | 307 | result.append( " <" ); |
308 | result.append( box->mb_addr_spec ); | 308 | result.append( box->mb_addr_spec ); |
309 | result.append( ">" ); | 309 | result.append( ">" ); |
310 | } | 310 | } |
311 | 311 | ||
312 | return result; | 312 | return result; |
313 | } | 313 | } |
314 | 314 | ||
315 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | 315 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) |
316 | { | 316 | { |
317 | QString result( "" ); | 317 | QString result( "" ); |
318 | 318 | ||
319 | bool first = true; | 319 | bool first = true; |
320 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { | 320 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { |
321 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; | 321 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; |
322 | 322 | ||
323 | if ( !first ) { | 323 | if ( !first ) { |
324 | result.append( "," ); | 324 | result.append( "," ); |
325 | } else { | 325 | } else { |
326 | first = false; | 326 | first = false; |
327 | } | 327 | } |
328 | 328 | ||
329 | result.append( parseMailbox( box ) ); | 329 | result.append( parseMailbox( box ) ); |
330 | } | 330 | } |
331 | 331 | ||
332 | return result; | 332 | return result; |
333 | } | 333 | } |
334 | 334 | ||
335 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPart&part) | 335 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) |
336 | { | 336 | { |
337 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); | 337 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
338 | if (it==bodyCache.end()) return new encodedString(); | 338 | if (it==bodyCache.end()) return new encodedString(); |
339 | encodedString*t = decode_String(it.data(),part.Encoding()); | 339 | encodedString*t = decode_String(it.data(),part->Encoding()); |
340 | return t; | 340 | return t; |
341 | } | 341 | } |
342 | 342 | ||
343 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part) | 343 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) |
344 | { | 344 | { |
345 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); | 345 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
346 | if (it==bodyCache.end()) return new encodedString(); | 346 | if (it==bodyCache.end()) return new encodedString(); |
347 | encodedString*t = it.data(); | 347 | encodedString*t = it.data(); |
348 | return t; | 348 | return t; |
349 | } | 349 | } |
350 | 350 | ||
351 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part) | 351 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
352 | { | 352 | { |
353 | encodedString*t = fetchDecodedPart(mail,part); | 353 | encodedString*t = fetchDecodedPart(mail,part); |
354 | QString text=t->Content(); | 354 | QString text=t->Content(); |
355 | delete t; | 355 | delete t; |
356 | return text; | 356 | return text; |
357 | } | 357 | } |
358 | 358 | ||
359 | void Genericwrapper::cleanMimeCache() | 359 | void Genericwrapper::cleanMimeCache() |
360 | { | 360 | { |
361 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); | 361 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); |
362 | for (;it!=bodyCache.end();++it) { | 362 | for (;it!=bodyCache.end();++it) { |
363 | encodedString*t = it.data(); | 363 | encodedString*t = it.data(); |
364 | //it.setValue(0); | 364 | //it.setValue(0); |
365 | if (t) delete t; | 365 | if (t) delete t; |
366 | } | 366 | } |
367 | bodyCache.clear(); | 367 | bodyCache.clear(); |
368 | qDebug("Genericwrapper: cache cleaned"); | 368 | qDebug("Genericwrapper: cache cleaned"); |
369 | } | 369 | } |
370 | 370 | ||
371 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | 371 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) |
372 | { | 372 | { |
373 | QStringList res; | 373 | QStringList res; |
374 | if (!in_replies || !in_replies->mid_list) return res; | 374 | if (!in_replies || !in_replies->mid_list) return res; |
375 | clistiter * current = 0; | 375 | clistiter * current = 0; |
376 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { | 376 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { |
377 | QString h((char*)current->data); | 377 | QString h((char*)current->data); |
378 | while (h.length()>0 && h[0]=='<') { | 378 | while (h.length()>0 && h[0]=='<') { |
379 | h.remove(0,1); | 379 | h.remove(0,1); |
380 | } | 380 | } |
381 | while (h.length()>0 && h[h.length()-1]=='>') { | 381 | while (h.length()>0 && h[h.length()-1]=='>') { |
382 | h.remove(h.length()-1,1); | 382 | h.remove(h.length()-1,1); |
383 | } | 383 | } |
384 | if (h.length()>0) { | 384 | if (h.length()>0) { |
385 | res.append(h); | 385 | res.append(h); |
386 | } | 386 | } |
387 | } | 387 | } |
388 | return res; | 388 | return res; |
389 | } | 389 | } |
390 | 390 | ||
391 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) | 391 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) |
392 | { | 392 | { |
393 | int r; | 393 | int r; |
394 | mailmessage_list * env_list = 0; | 394 | mailmessage_list * env_list = 0; |
395 | r = mailsession_get_messages_list(session,&env_list); | 395 | r = mailsession_get_messages_list(session,&env_list); |
396 | if (r != MAIL_NO_ERROR) { | 396 | if (r != MAIL_NO_ERROR) { |
397 | qDebug("Error message list"); | 397 | qDebug("Error message list"); |
398 | return; | 398 | return; |
399 | } | 399 | } |
400 | r = mailsession_get_envelopes_list(session, env_list); | 400 | r = mailsession_get_envelopes_list(session, env_list); |
401 | if (r != MAIL_NO_ERROR) { | 401 | if (r != MAIL_NO_ERROR) { |
402 | qDebug("Error filling message list"); | 402 | qDebug("Error filling message list"); |
403 | if (env_list) { | 403 | if (env_list) { |
404 | mailmessage_list_free(env_list); | 404 | mailmessage_list_free(env_list); |
405 | } | 405 | } |
406 | return; | 406 | return; |
407 | } | 407 | } |
408 | mailimf_references * refs = 0; | 408 | mailimf_references * refs = 0; |
409 | mailimf_in_reply_to * in_replies = 0; | 409 | mailimf_in_reply_to * in_replies = 0; |
410 | uint32_t i = 0; | 410 | uint32_t i = 0; |
411 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 411 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
412 | mailmessage * msg; | 412 | mailmessage * msg; |
413 | QBitArray mFlags(7); | 413 | QBitArray mFlags(7); |
414 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 414 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
415 | if (msg->msg_fields == NULL) { | 415 | if (msg->msg_fields == NULL) { |
416 | //qDebug("could not fetch envelope of message %i", i); | 416 | //qDebug("could not fetch envelope of message %i", i); |
417 | continue; | 417 | continue; |
418 | } | 418 | } |
419 | RecMailP mail = new RecMail(); | 419 | RecMailP mail = new RecMail(); |
420 | mail->setWrapper(this); | 420 | mail->setWrapper(this); |
421 | mail_flags * flag_result = 0; | 421 | mail_flags * flag_result = 0; |
422 | r = mailmessage_get_flags(msg,&flag_result); | 422 | r = mailmessage_get_flags(msg,&flag_result); |
423 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 423 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
424 | mFlags.setBit(FLAG_SEEN); | 424 | mFlags.setBit(FLAG_SEEN); |
425 | } | 425 | } |
426 | mailimf_single_fields single_fields; | 426 | mailimf_single_fields single_fields; |
427 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 427 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
428 | mail->setMsgsize(msg->msg_size); | 428 | mail->setMsgsize(msg->msg_size); |
429 | mail->setFlags(mFlags); | 429 | mail->setFlags(mFlags); |
430 | mail->setMbox(mailbox); | 430 | mail->setMbox(mailbox); |
431 | mail->setNumber(msg->msg_index); | 431 | mail->setNumber(msg->msg_index); |
432 | if (single_fields.fld_subject) | 432 | if (single_fields.fld_subject) |
433 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 433 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
434 | if (single_fields.fld_from) | 434 | if (single_fields.fld_from) |
435 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 435 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
436 | if (!mbox_as_to) { | 436 | if (!mbox_as_to) { |
437 | if (single_fields.fld_to) | 437 | if (single_fields.fld_to) |
438 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 438 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
439 | } else { | 439 | } else { |
440 | mail->setTo(mailbox); | 440 | mail->setTo(mailbox); |
441 | } | 441 | } |
442 | if (single_fields.fld_cc) | 442 | if (single_fields.fld_cc) |
443 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 443 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
444 | if (single_fields.fld_bcc) | 444 | if (single_fields.fld_bcc) |
445 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 445 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
446 | if (single_fields.fld_orig_date) | 446 | if (single_fields.fld_orig_date) |
447 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 447 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h index f5b9504..8be9212 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.h +++ b/noncore/net/mail/libmailwrapper/genericwrapper.h | |||
@@ -1,67 +1,67 @@ | |||
1 | #ifndef __GENERIC_WRAPPER_H | 1 | #ifndef __GENERIC_WRAPPER_H |
2 | #define __GENERIC_WRAPPER_H | 2 | #define __GENERIC_WRAPPER_H |
3 | 3 | ||
4 | #include "abstractmail.h" | 4 | #include "abstractmail.h" |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | class RecMail; | 9 | class RecMail; |
10 | class RecBody; | 10 | class RecBody; |
11 | class encodedString; | 11 | class encodedString; |
12 | struct mailpop3; | 12 | struct mailpop3; |
13 | struct mailmessage; | 13 | struct mailmessage; |
14 | struct mailmime; | 14 | struct mailmime; |
15 | struct mailmime_mechanism; | 15 | struct mailmime_mechanism; |
16 | struct mailimf_mailbox_list; | 16 | struct mailimf_mailbox_list; |
17 | struct mailimf_mailbox; | 17 | struct mailimf_mailbox; |
18 | struct mailimf_date_time; | 18 | struct mailimf_date_time; |
19 | struct mailimf_group; | 19 | struct mailimf_group; |
20 | struct mailimf_address_list; | 20 | struct mailimf_address_list; |
21 | struct mailsession; | 21 | struct mailsession; |
22 | struct mailstorage; | 22 | struct mailstorage; |
23 | struct mailfolder; | 23 | struct mailfolder; |
24 | struct mailimf_in_reply_to; | 24 | struct mailimf_in_reply_to; |
25 | 25 | ||
26 | /* this class hold just the funs shared between | 26 | /* this class hold just the funs shared between |
27 | * mbox and pop3 (later mh, too) mail access. | 27 | * mbox and pop3 (later mh, too) mail access. |
28 | * it is not desigend to make a instance of it! | 28 | * it is not desigend to make a instance of it! |
29 | */ | 29 | */ |
30 | class Genericwrapper : public AbstractMail | 30 | class Genericwrapper : public AbstractMail |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | Genericwrapper(); | 34 | Genericwrapper(); |
35 | virtual ~Genericwrapper(); | 35 | virtual ~Genericwrapper(); |
36 | 36 | ||
37 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part); | 37 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); |
38 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part); | 38 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); |
39 | virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part); | 39 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); |
40 | virtual void cleanMimeCache(); | 40 | virtual void cleanMimeCache(); |
41 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} | 41 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} |
42 | virtual void logout(){}; | 42 | virtual void logout(){}; |
43 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; | 43 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; |
44 | 44 | ||
45 | protected: | 45 | protected: |
46 | RecBody parseMail( mailmessage * msg ); | 46 | RecBodyP parseMail( mailmessage * msg ); |
47 | QString parseMailboxList( mailimf_mailbox_list *list ); | 47 | QString parseMailboxList( mailimf_mailbox_list *list ); |
48 | QString parseMailbox( mailimf_mailbox *box ); | 48 | QString parseMailbox( mailimf_mailbox *box ); |
49 | QString parseGroup( mailimf_group *group ); | 49 | QString parseGroup( mailimf_group *group ); |
50 | QString parseAddressList( mailimf_address_list *list ); | 50 | QString parseAddressList( mailimf_address_list *list ); |
51 | QString parseDateTime( mailimf_date_time *date ); | 51 | QString parseDateTime( mailimf_date_time *date ); |
52 | 52 | ||
53 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); | 53 | void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); |
54 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); | 54 | static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); |
55 | static void fillParameters(RecPart&target,clist*parameters); | 55 | static void fillParameters(RecPartP&target,clist*parameters); |
56 | static QString getencoding(mailmime_mechanism*aEnc); | 56 | static QString getencoding(mailmime_mechanism*aEnc); |
57 | virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); | 57 | virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); |
58 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); | 58 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); |
59 | 59 | ||
60 | QString msgTempName; | 60 | QString msgTempName; |
61 | unsigned int last_msg_id; | 61 | unsigned int last_msg_id; |
62 | QMap<QString,encodedString*> bodyCache; | 62 | QMap<QString,encodedString*> bodyCache; |
63 | mailstorage * m_storage; | 63 | mailstorage * m_storage; |
64 | mailfolder*m_folder; | 64 | mailfolder*m_folder; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | #endif | 67 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 56e7df9..230cf53 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -390,673 +390,673 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
390 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 390 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
391 | mFlags.setBit(FLAG_ANSWERED); | 391 | mFlags.setBit(FLAG_ANSWERED); |
392 | break; | 392 | break; |
393 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 393 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
394 | mFlags.setBit(FLAG_FLAGGED); | 394 | mFlags.setBit(FLAG_FLAGGED); |
395 | break; | 395 | break; |
396 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 396 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
397 | mFlags.setBit(FLAG_DELETED); | 397 | mFlags.setBit(FLAG_DELETED); |
398 | break; | 398 | break; |
399 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 399 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
400 | mFlags.setBit(FLAG_SEEN); | 400 | mFlags.setBit(FLAG_SEEN); |
401 | break; | 401 | break; |
402 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 402 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
403 | mFlags.setBit(FLAG_DRAFT); | 403 | mFlags.setBit(FLAG_DRAFT); |
404 | break; | 404 | break; |
405 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 405 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
406 | break; | 406 | break; |
407 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 407 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
408 | break; | 408 | break; |
409 | default: | 409 | default: |
410 | break; | 410 | break; |
411 | } | 411 | } |
412 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 412 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
413 | mFlags.setBit(FLAG_RECENT); | 413 | mFlags.setBit(FLAG_RECENT); |
414 | } | 414 | } |
415 | } | 415 | } |
416 | continue; | 416 | continue; |
417 | } | 417 | } |
418 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 418 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
419 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 419 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
420 | m->setDate(head->env_date); | 420 | m->setDate(head->env_date); |
421 | m->setSubject(convert_String((const char*)head->env_subject)); | 421 | m->setSubject(convert_String((const char*)head->env_subject)); |
422 | //m->setSubject(head->env_subject); | 422 | //m->setSubject(head->env_subject); |
423 | if (head->env_from!=NULL) { | 423 | if (head->env_from!=NULL) { |
424 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 424 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
425 | if (addresslist.count()) { | 425 | if (addresslist.count()) { |
426 | m->setFrom(addresslist.first()); | 426 | m->setFrom(addresslist.first()); |
427 | } | 427 | } |
428 | } | 428 | } |
429 | if (head->env_to!=NULL) { | 429 | if (head->env_to!=NULL) { |
430 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 430 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
431 | m->setTo(addresslist); | 431 | m->setTo(addresslist); |
432 | } | 432 | } |
433 | if (head->env_cc!=NULL) { | 433 | if (head->env_cc!=NULL) { |
434 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 434 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
435 | m->setCC(addresslist); | 435 | m->setCC(addresslist); |
436 | } | 436 | } |
437 | if (head->env_bcc!=NULL) { | 437 | if (head->env_bcc!=NULL) { |
438 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 438 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
439 | m->setBcc(addresslist); | 439 | m->setBcc(addresslist); |
440 | } | 440 | } |
441 | /* reply to address, eg. email. */ | 441 | /* reply to address, eg. email. */ |
442 | if (head->env_reply_to!=NULL) { | 442 | if (head->env_reply_to!=NULL) { |
443 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 443 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
444 | if (addresslist.count()) { | 444 | if (addresslist.count()) { |
445 | m->setReplyto(addresslist.first()); | 445 | m->setReplyto(addresslist.first()); |
446 | } | 446 | } |
447 | } | 447 | } |
448 | if (head->env_in_reply_to!=NULL) { | 448 | if (head->env_in_reply_to!=NULL) { |
449 | QString h(head->env_in_reply_to); | 449 | QString h(head->env_in_reply_to); |
450 | while (h.length()>0 && h[0]=='<') { | 450 | while (h.length()>0 && h[0]=='<') { |
451 | h.remove(0,1); | 451 | h.remove(0,1); |
452 | } | 452 | } |
453 | while (h.length()>0 && h[h.length()-1]=='>') { | 453 | while (h.length()>0 && h[h.length()-1]=='>') { |
454 | h.remove(h.length()-1,1); | 454 | h.remove(h.length()-1,1); |
455 | } | 455 | } |
456 | if (h.length()>0) { | 456 | if (h.length()>0) { |
457 | m->setInreply(QStringList(h)); | 457 | m->setInreply(QStringList(h)); |
458 | } | 458 | } |
459 | } | 459 | } |
460 | if (head->env_message_id) { | 460 | if (head->env_message_id) { |
461 | m->setMsgid(QString(head->env_message_id)); | 461 | m->setMsgid(QString(head->env_message_id)); |
462 | } | 462 | } |
463 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 463 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
464 | #if 0 | 464 | #if 0 |
465 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 465 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
466 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 466 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
467 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); | 467 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
468 | qDebug(da.toString()); | 468 | qDebug(da.toString()); |
469 | #endif | 469 | #endif |
470 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 470 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
471 | size = item->att_data.att_static->att_data.att_rfc822_size; | 471 | size = item->att_data.att_static->att_data.att_rfc822_size; |
472 | } | 472 | } |
473 | } | 473 | } |
474 | /* msg is already deleted */ | 474 | /* msg is already deleted */ |
475 | if (mFlags.testBit(FLAG_DELETED) && m) { | 475 | if (mFlags.testBit(FLAG_DELETED) && m) { |
476 | delete m; | 476 | delete m; |
477 | m = 0; | 477 | m = 0; |
478 | } | 478 | } |
479 | if (m) { | 479 | if (m) { |
480 | m->setFlags(mFlags); | 480 | m->setFlags(mFlags); |
481 | m->setMsgsize(size); | 481 | m->setMsgsize(size); |
482 | } | 482 | } |
483 | return m; | 483 | return m; |
484 | } | 484 | } |
485 | 485 | ||
486 | RecBody IMAPwrapper::fetchBody(const RecMailP&mail) | 486 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
487 | { | 487 | { |
488 | RecBody body; | 488 | RecBodyP body = new RecBody(); |
489 | const char *mb; | 489 | const char *mb; |
490 | int err = MAILIMAP_NO_ERROR; | 490 | int err = MAILIMAP_NO_ERROR; |
491 | clist *result = 0; | 491 | clist *result = 0; |
492 | clistcell *current; | 492 | clistcell *current; |
493 | mailimap_fetch_att *fetchAtt = 0; | 493 | mailimap_fetch_att *fetchAtt = 0; |
494 | mailimap_fetch_type *fetchType = 0; | 494 | mailimap_fetch_type *fetchType = 0; |
495 | mailimap_set *set = 0; | 495 | mailimap_set *set = 0; |
496 | mailimap_body*body_desc = 0; | 496 | mailimap_body*body_desc = 0; |
497 | 497 | ||
498 | mb = mail->getMbox().latin1(); | 498 | mb = mail->getMbox().latin1(); |
499 | 499 | ||
500 | login(); | 500 | login(); |
501 | if (!m_imap) { | 501 | if (!m_imap) { |
502 | return body; | 502 | return body; |
503 | } | 503 | } |
504 | err = selectMbox(mail->getMbox()); | 504 | err = selectMbox(mail->getMbox()); |
505 | if ( err != MAILIMAP_NO_ERROR ) { | 505 | if ( err != MAILIMAP_NO_ERROR ) { |
506 | return body; | 506 | return body; |
507 | } | 507 | } |
508 | 508 | ||
509 | /* the range has to start at 1!!! not with 0!!!! */ | 509 | /* the range has to start at 1!!! not with 0!!!! */ |
510 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 510 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
511 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 511 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
512 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 512 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
513 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 513 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
514 | mailimap_set_free( set ); | 514 | mailimap_set_free( set ); |
515 | mailimap_fetch_type_free( fetchType ); | 515 | mailimap_fetch_type_free( fetchType ); |
516 | 516 | ||
517 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 517 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
518 | mailimap_msg_att * msg_att; | 518 | mailimap_msg_att * msg_att; |
519 | msg_att = (mailimap_msg_att*)current->data; | 519 | msg_att = (mailimap_msg_att*)current->data; |
520 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 520 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
521 | QValueList<int> path; | 521 | QValueList<int> path; |
522 | body_desc = item->att_data.att_static->att_data.att_body; | 522 | body_desc = item->att_data.att_static->att_data.att_body; |
523 | traverseBody(mail,body_desc,body,0,path); | 523 | traverseBody(mail,body_desc,body,0,path); |
524 | } else { | 524 | } else { |
525 | qDebug("error fetching body: %s",m_imap->imap_response); | 525 | qDebug("error fetching body: %s",m_imap->imap_response); |
526 | } | 526 | } |
527 | if (result) mailimap_fetch_list_free(result); | 527 | if (result) mailimap_fetch_list_free(result); |
528 | return body; | 528 | return body; |
529 | } | 529 | } |
530 | 530 | ||
531 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 531 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
532 | { | 532 | { |
533 | QStringList l; | 533 | QStringList l; |
534 | QString from; | 534 | QString from; |
535 | bool named_from; | 535 | bool named_from; |
536 | clistcell *current = NULL; | 536 | clistcell *current = NULL; |
537 | mailimap_address * current_address=NULL; | 537 | mailimap_address * current_address=NULL; |
538 | if (!list) { | 538 | if (!list) { |
539 | return l; | 539 | return l; |
540 | } | 540 | } |
541 | unsigned int count = 0; | 541 | unsigned int count = 0; |
542 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 542 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
543 | from = ""; | 543 | from = ""; |
544 | named_from = false; | 544 | named_from = false; |
545 | current_address=(mailimap_address*)current->data; | 545 | current_address=(mailimap_address*)current->data; |
546 | if (current_address->ad_personal_name){ | 546 | if (current_address->ad_personal_name){ |
547 | from+=convert_String((const char*)current_address->ad_personal_name); | 547 | from+=convert_String((const char*)current_address->ad_personal_name); |
548 | from+=" "; | 548 | from+=" "; |
549 | named_from = true; | 549 | named_from = true; |
550 | } | 550 | } |
551 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 551 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
552 | from+="<"; | 552 | from+="<"; |
553 | } | 553 | } |
554 | if (current_address->ad_mailbox_name) { | 554 | if (current_address->ad_mailbox_name) { |
555 | from+=QString(current_address->ad_mailbox_name); | 555 | from+=QString(current_address->ad_mailbox_name); |
556 | from+="@"; | 556 | from+="@"; |
557 | } | 557 | } |
558 | if (current_address->ad_host_name) { | 558 | if (current_address->ad_host_name) { |
559 | from+=QString(current_address->ad_host_name); | 559 | from+=QString(current_address->ad_host_name); |
560 | } | 560 | } |
561 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 561 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
562 | from+=">"; | 562 | from+=">"; |
563 | } | 563 | } |
564 | l.append(QString(from)); | 564 | l.append(QString(from)); |
565 | if (++count > 99) { | 565 | if (++count > 99) { |
566 | break; | 566 | break; |
567 | } | 567 | } |
568 | } | 568 | } |
569 | return l; | 569 | return l; |
570 | } | 570 | } |
571 | 571 | ||
572 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) | 572 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
573 | { | 573 | { |
574 | encodedString*res=new encodedString; | 574 | encodedString*res=new encodedString; |
575 | int err; | 575 | int err; |
576 | mailimap_fetch_type *fetchType; | 576 | mailimap_fetch_type *fetchType; |
577 | mailimap_set *set; | 577 | mailimap_set *set; |
578 | clistcell*current,*cur; | 578 | clistcell*current,*cur; |
579 | mailimap_section_part * section_part = 0; | 579 | mailimap_section_part * section_part = 0; |
580 | mailimap_section_spec * section_spec = 0; | 580 | mailimap_section_spec * section_spec = 0; |
581 | mailimap_section * section = 0; | 581 | mailimap_section * section = 0; |
582 | mailimap_fetch_att * fetch_att = 0; | 582 | mailimap_fetch_att * fetch_att = 0; |
583 | 583 | ||
584 | login(); | 584 | login(); |
585 | if (!m_imap) { | 585 | if (!m_imap) { |
586 | return res; | 586 | return res; |
587 | } | 587 | } |
588 | if (!internal_call) { | 588 | if (!internal_call) { |
589 | err = selectMbox(mail->getMbox()); | 589 | err = selectMbox(mail->getMbox()); |
590 | if ( err != MAILIMAP_NO_ERROR ) { | 590 | if ( err != MAILIMAP_NO_ERROR ) { |
591 | return res; | 591 | return res; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | set = mailimap_set_new_single(mail->getNumber()); | 594 | set = mailimap_set_new_single(mail->getNumber()); |
595 | 595 | ||
596 | clist*id_list = 0; | 596 | clist*id_list = 0; |
597 | 597 | ||
598 | /* if path == empty then its a request for the whole rfc822 mail and generates | 598 | /* if path == empty then its a request for the whole rfc822 mail and generates |
599 | a "fetch <id> (body[])" statement on imap server */ | 599 | a "fetch <id> (body[])" statement on imap server */ |
600 | if (path.count()>0 ) { | 600 | if (path.count()>0 ) { |
601 | id_list = clist_new(); | 601 | id_list = clist_new(); |
602 | for (unsigned j=0; j < path.count();++j) { | 602 | for (unsigned j=0; j < path.count();++j) { |
603 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 603 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
604 | *p_id = path[j]; | 604 | *p_id = path[j]; |
605 | clist_append(id_list,p_id); | 605 | clist_append(id_list,p_id); |
606 | } | 606 | } |
607 | section_part = mailimap_section_part_new(id_list); | 607 | section_part = mailimap_section_part_new(id_list); |
608 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 608 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
609 | } | 609 | } |
610 | 610 | ||
611 | section = mailimap_section_new(section_spec); | 611 | section = mailimap_section_new(section_spec); |
612 | fetch_att = mailimap_fetch_att_new_body_section(section); | 612 | fetch_att = mailimap_fetch_att_new_body_section(section); |
613 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 613 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
614 | 614 | ||
615 | clist*result = 0; | 615 | clist*result = 0; |
616 | 616 | ||
617 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 617 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
618 | mailimap_set_free( set ); | 618 | mailimap_set_free( set ); |
619 | mailimap_fetch_type_free( fetchType ); | 619 | mailimap_fetch_type_free( fetchType ); |
620 | 620 | ||
621 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 621 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
622 | mailimap_msg_att * msg_att; | 622 | mailimap_msg_att * msg_att; |
623 | msg_att = (mailimap_msg_att*)current->data; | 623 | msg_att = (mailimap_msg_att*)current->data; |
624 | mailimap_msg_att_item*msg_att_item; | 624 | mailimap_msg_att_item*msg_att_item; |
625 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 625 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
626 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 626 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
627 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 627 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
628 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 628 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
629 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 629 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
630 | /* detach - we take over the content */ | 630 | /* detach - we take over the content */ |
631 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 631 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
632 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 632 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
633 | } | 633 | } |
634 | } | 634 | } |
635 | } | 635 | } |
636 | } else { | 636 | } else { |
637 | qDebug("error fetching text: %s",m_imap->imap_response); | 637 | qDebug("error fetching text: %s",m_imap->imap_response); |
638 | } | 638 | } |
639 | if (result) mailimap_fetch_list_free(result); | 639 | if (result) mailimap_fetch_list_free(result); |
640 | return res; | 640 | return res; |
641 | } | 641 | } |
642 | 642 | ||
643 | /* current_recursion is for recursive calls. | 643 | /* current_recursion is for recursive calls. |
644 | current_count means the position inside the internal loop! */ | 644 | current_count means the position inside the internal loop! */ |
645 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body, | 645 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, |
646 | int current_recursion,QValueList<int>recList,int current_count) | 646 | int current_recursion,QValueList<int>recList,int current_count) |
647 | { | 647 | { |
648 | if (!body || current_recursion>=10) { | 648 | if (!body || current_recursion>=10) { |
649 | return; | 649 | return; |
650 | } | 650 | } |
651 | switch (body->bd_type) { | 651 | switch (body->bd_type) { |
652 | case MAILIMAP_BODY_1PART: | 652 | case MAILIMAP_BODY_1PART: |
653 | { | 653 | { |
654 | QValueList<int>countlist = recList; | 654 | QValueList<int>countlist = recList; |
655 | countlist.append(current_count); | 655 | countlist.append(current_count); |
656 | RecPart currentPart; | 656 | RecPartP currentPart = new RecPart(); |
657 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 657 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
658 | QString id(""); | 658 | QString id(""); |
659 | currentPart.setPositionlist(countlist); | 659 | currentPart->setPositionlist(countlist); |
660 | for (unsigned int j = 0; j < countlist.count();++j) { | 660 | for (unsigned int j = 0; j < countlist.count();++j) { |
661 | id+=(j>0?" ":""); | 661 | id+=(j>0?" ":""); |
662 | id+=QString("%1").arg(countlist[j]); | 662 | id+=QString("%1").arg(countlist[j]); |
663 | } | 663 | } |
664 | qDebug("ID = %s",id.latin1()); | 664 | qDebug("ID = %s",id.latin1()); |
665 | currentPart.setIdentifier(id); | 665 | currentPart->setIdentifier(id); |
666 | fillSinglePart(currentPart,part1); | 666 | fillSinglePart(currentPart,part1); |
667 | /* important: Check for is NULL 'cause a body can be empty! | 667 | /* important: Check for is NULL 'cause a body can be empty! |
668 | And we put it only into the mail if it is the FIRST part */ | 668 | And we put it only into the mail if it is the FIRST part */ |
669 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) { | 669 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
670 | QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); | 670 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
671 | target_body.setDescription(currentPart); | 671 | target_body->setDescription(currentPart); |
672 | target_body.setBodytext(body_text); | 672 | target_body->setBodytext(body_text); |
673 | if (countlist.count()>1) { | 673 | if (countlist.count()>1) { |
674 | target_body.addPart(currentPart); | 674 | target_body->addPart(currentPart); |
675 | } | 675 | } |
676 | } else { | 676 | } else { |
677 | target_body.addPart(currentPart); | 677 | target_body->addPart(currentPart); |
678 | } | 678 | } |
679 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 679 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
680 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 680 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
681 | } | 681 | } |
682 | } | 682 | } |
683 | break; | 683 | break; |
684 | case MAILIMAP_BODY_MPART: | 684 | case MAILIMAP_BODY_MPART: |
685 | { | 685 | { |
686 | QValueList<int>countlist = recList; | 686 | QValueList<int>countlist = recList; |
687 | clistcell*current=0; | 687 | clistcell*current=0; |
688 | mailimap_body*current_body=0; | 688 | mailimap_body*current_body=0; |
689 | unsigned int ccount = 1; | 689 | unsigned int ccount = 1; |
690 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 690 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
691 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 691 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
692 | current_body = (mailimap_body*)current->data; | 692 | current_body = (mailimap_body*)current->data; |
693 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 693 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
694 | RecPart targetPart; | 694 | RecPartP targetPart = new RecPart(); |
695 | targetPart.setType("multipart"); | 695 | targetPart->setType("multipart"); |
696 | fillMultiPart(targetPart,mailDescription); | 696 | fillMultiPart(targetPart,mailDescription); |
697 | countlist.append(current_count); | 697 | countlist.append(current_count); |
698 | targetPart.setPositionlist(countlist); | 698 | targetPart->setPositionlist(countlist); |
699 | target_body.addPart(targetPart); | 699 | target_body->addPart(targetPart); |
700 | QString id(""); | 700 | QString id(""); |
701 | for (unsigned int j = 0; j < countlist.count();++j) { | 701 | for (unsigned int j = 0; j < countlist.count();++j) { |
702 | id+=(j>0?" ":""); | 702 | id+=(j>0?" ":""); |
703 | id+=QString("%1").arg(countlist[j]); | 703 | id+=QString("%1").arg(countlist[j]); |
704 | } | 704 | } |
705 | qDebug("ID(mpart) = %s",id.latin1()); | 705 | qDebug("ID(mpart) = %s",id.latin1()); |
706 | } | 706 | } |
707 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 707 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
708 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 708 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
709 | countlist = recList; | 709 | countlist = recList; |
710 | } | 710 | } |
711 | ++ccount; | 711 | ++ccount; |
712 | } | 712 | } |
713 | } | 713 | } |
714 | break; | 714 | break; |
715 | default: | 715 | default: |
716 | break; | 716 | break; |
717 | } | 717 | } |
718 | } | 718 | } |
719 | 719 | ||
720 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) | 720 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) |
721 | { | 721 | { |
722 | if (!Description) { | 722 | if (!Description) { |
723 | return; | 723 | return; |
724 | } | 724 | } |
725 | switch (Description->bd_type) { | 725 | switch (Description->bd_type) { |
726 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 726 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
727 | target_part.setType("text"); | 727 | target_part->setType("text"); |
728 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 728 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
729 | break; | 729 | break; |
730 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 730 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
731 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 731 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
732 | break; | 732 | break; |
733 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 733 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
734 | target_part.setType("message"); | 734 | target_part->setType("message"); |
735 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 735 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
736 | break; | 736 | break; |
737 | default: | 737 | default: |
738 | break; | 738 | break; |
739 | } | 739 | } |
740 | } | 740 | } |
741 | 741 | ||
742 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) | 742 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) |
743 | { | 743 | { |
744 | if (!which) { | 744 | if (!which) { |
745 | return; | 745 | return; |
746 | } | 746 | } |
747 | QString sub; | 747 | QString sub; |
748 | sub = which->bd_media_text; | 748 | sub = which->bd_media_text; |
749 | qDebug("Type= text/%s",which->bd_media_text); | 749 | qDebug("Type= text/%s",which->bd_media_text); |
750 | target_part.setSubtype(sub.lower()); | 750 | target_part->setSubtype(sub.lower()); |
751 | target_part.setLines(which->bd_lines); | 751 | target_part->setLines(which->bd_lines); |
752 | fillBodyFields(target_part,which->bd_fields); | 752 | fillBodyFields(target_part,which->bd_fields); |
753 | } | 753 | } |
754 | 754 | ||
755 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) | 755 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) |
756 | { | 756 | { |
757 | if (!which) { | 757 | if (!which) { |
758 | return; | 758 | return; |
759 | } | 759 | } |
760 | target_part.setSubtype("rfc822"); | 760 | target_part->setSubtype("rfc822"); |
761 | qDebug("Message part"); | 761 | qDebug("Message part"); |
762 | /* we set this type to text/plain */ | 762 | /* we set this type to text/plain */ |
763 | target_part.setLines(which->bd_lines); | 763 | target_part->setLines(which->bd_lines); |
764 | fillBodyFields(target_part,which->bd_fields); | 764 | fillBodyFields(target_part,which->bd_fields); |
765 | } | 765 | } |
766 | 766 | ||
767 | void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) | 767 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) |
768 | { | 768 | { |
769 | if (!which) return; | 769 | if (!which) return; |
770 | QString sub = which->bd_media_subtype; | 770 | QString sub = which->bd_media_subtype; |
771 | target_part.setSubtype(sub.lower()); | 771 | target_part->setSubtype(sub.lower()); |
772 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 772 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
773 | clistcell*cur = 0; | 773 | clistcell*cur = 0; |
774 | mailimap_single_body_fld_param*param=0; | 774 | mailimap_single_body_fld_param*param=0; |
775 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 775 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
776 | param = (mailimap_single_body_fld_param*)cur->data; | 776 | param = (mailimap_single_body_fld_param*)cur->data; |
777 | if (param) { | 777 | if (param) { |
778 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 778 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
779 | } | 779 | } |
780 | } | 780 | } |
781 | } | 781 | } |
782 | } | 782 | } |
783 | 783 | ||
784 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) | 784 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) |
785 | { | 785 | { |
786 | if (!which) { | 786 | if (!which) { |
787 | return; | 787 | return; |
788 | } | 788 | } |
789 | QString type,sub; | 789 | QString type,sub; |
790 | switch (which->bd_media_basic->med_type) { | 790 | switch (which->bd_media_basic->med_type) { |
791 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 791 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
792 | type = "application"; | 792 | type = "application"; |
793 | break; | 793 | break; |
794 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 794 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
795 | type = "audio"; | 795 | type = "audio"; |
796 | break; | 796 | break; |
797 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 797 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
798 | type = "image"; | 798 | type = "image"; |
799 | break; | 799 | break; |
800 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 800 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
801 | type = "message"; | 801 | type = "message"; |
802 | break; | 802 | break; |
803 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 803 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
804 | type = "video"; | 804 | type = "video"; |
805 | break; | 805 | break; |
806 | case MAILIMAP_MEDIA_BASIC_OTHER: | 806 | case MAILIMAP_MEDIA_BASIC_OTHER: |
807 | default: | 807 | default: |
808 | if (which->bd_media_basic->med_basic_type) { | 808 | if (which->bd_media_basic->med_basic_type) { |
809 | type = which->bd_media_basic->med_basic_type; | 809 | type = which->bd_media_basic->med_basic_type; |
810 | } else { | 810 | } else { |
811 | type = ""; | 811 | type = ""; |
812 | } | 812 | } |
813 | break; | 813 | break; |
814 | } | 814 | } |
815 | if (which->bd_media_basic->med_subtype) { | 815 | if (which->bd_media_basic->med_subtype) { |
816 | sub = which->bd_media_basic->med_subtype; | 816 | sub = which->bd_media_basic->med_subtype; |
817 | } else { | 817 | } else { |
818 | sub = ""; | 818 | sub = ""; |
819 | } | 819 | } |
820 | qDebug("Type = %s/%s",type.latin1(),sub.latin1()); | 820 | qDebug("Type = %s/%s",type.latin1(),sub.latin1()); |
821 | target_part.setType(type.lower()); | 821 | target_part->setType(type.lower()); |
822 | target_part.setSubtype(sub.lower()); | 822 | target_part->setSubtype(sub.lower()); |
823 | fillBodyFields(target_part,which->bd_fields); | 823 | fillBodyFields(target_part,which->bd_fields); |
824 | } | 824 | } |
825 | 825 | ||
826 | void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | 826 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
827 | { | 827 | { |
828 | if (!which) return; | 828 | if (!which) return; |
829 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 829 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
830 | clistcell*cur; | 830 | clistcell*cur; |
831 | mailimap_single_body_fld_param*param=0; | 831 | mailimap_single_body_fld_param*param=0; |
832 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 832 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
833 | param = (mailimap_single_body_fld_param*)cur->data; | 833 | param = (mailimap_single_body_fld_param*)cur->data; |
834 | if (param) { | 834 | if (param) { |
835 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 835 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
836 | } | 836 | } |
837 | } | 837 | } |
838 | } | 838 | } |
839 | mailimap_body_fld_enc*enc = which->bd_encoding; | 839 | mailimap_body_fld_enc*enc = which->bd_encoding; |
840 | QString encoding(""); | 840 | QString encoding(""); |
841 | switch (enc->enc_type) { | 841 | switch (enc->enc_type) { |
842 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 842 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
843 | encoding = "7bit"; | 843 | encoding = "7bit"; |
844 | break; | 844 | break; |
845 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 845 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
846 | encoding = "8bit"; | 846 | encoding = "8bit"; |
847 | break; | 847 | break; |
848 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 848 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
849 | encoding="binary"; | 849 | encoding="binary"; |
850 | break; | 850 | break; |
851 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 851 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
852 | encoding="base64"; | 852 | encoding="base64"; |
853 | break; | 853 | break; |
854 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 854 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
855 | encoding="quoted-printable"; | 855 | encoding="quoted-printable"; |
856 | break; | 856 | break; |
857 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 857 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
858 | default: | 858 | default: |
859 | if (enc->enc_value) { | 859 | if (enc->enc_value) { |
860 | char*t=enc->enc_value; | 860 | char*t=enc->enc_value; |
861 | encoding=QString(enc->enc_value); | 861 | encoding=QString(enc->enc_value); |
862 | enc->enc_value=0L; | 862 | enc->enc_value=0L; |
863 | free(t); | 863 | free(t); |
864 | } | 864 | } |
865 | } | 865 | } |
866 | if (which->bd_description) { | 866 | if (which->bd_description) { |
867 | target_part.setDescription(QString(which->bd_description)); | 867 | target_part->setDescription(QString(which->bd_description)); |
868 | } | 868 | } |
869 | target_part.setEncoding(encoding); | 869 | target_part->setEncoding(encoding); |
870 | target_part.setSize(which->bd_size); | 870 | target_part->setSize(which->bd_size); |
871 | } | 871 | } |
872 | 872 | ||
873 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 873 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
874 | { | 874 | { |
875 | mailimap_flag_list*flist; | 875 | mailimap_flag_list*flist; |
876 | mailimap_set *set; | 876 | mailimap_set *set; |
877 | mailimap_store_att_flags * store_flags; | 877 | mailimap_store_att_flags * store_flags; |
878 | int err; | 878 | int err; |
879 | login(); | 879 | login(); |
880 | if (!m_imap) { | 880 | if (!m_imap) { |
881 | return; | 881 | return; |
882 | } | 882 | } |
883 | err = selectMbox(mail->getMbox()); | 883 | err = selectMbox(mail->getMbox()); |
884 | if ( err != MAILIMAP_NO_ERROR ) { | 884 | if ( err != MAILIMAP_NO_ERROR ) { |
885 | return; | 885 | return; |
886 | } | 886 | } |
887 | flist = mailimap_flag_list_new_empty(); | 887 | flist = mailimap_flag_list_new_empty(); |
888 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 888 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
889 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 889 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
890 | set = mailimap_set_new_single(mail->getNumber()); | 890 | set = mailimap_set_new_single(mail->getNumber()); |
891 | err = mailimap_store(m_imap,set,store_flags); | 891 | err = mailimap_store(m_imap,set,store_flags); |
892 | mailimap_set_free( set ); | 892 | mailimap_set_free( set ); |
893 | mailimap_store_att_flags_free(store_flags); | 893 | mailimap_store_att_flags_free(store_flags); |
894 | 894 | ||
895 | if (err != MAILIMAP_NO_ERROR) { | 895 | if (err != MAILIMAP_NO_ERROR) { |
896 | qDebug("error deleting mail: %s",m_imap->imap_response); | 896 | qDebug("error deleting mail: %s",m_imap->imap_response); |
897 | return; | 897 | return; |
898 | } | 898 | } |
899 | qDebug("deleting mail: %s",m_imap->imap_response); | 899 | qDebug("deleting mail: %s",m_imap->imap_response); |
900 | /* should we realy do that at this moment? */ | 900 | /* should we realy do that at this moment? */ |
901 | err = mailimap_expunge(m_imap); | 901 | err = mailimap_expunge(m_imap); |
902 | if (err != MAILIMAP_NO_ERROR) { | 902 | if (err != MAILIMAP_NO_ERROR) { |
903 | qDebug("error deleting mail: %s",m_imap->imap_response); | 903 | qDebug("error deleting mail: %s",m_imap->imap_response); |
904 | } | 904 | } |
905 | qDebug("Delete successfull %s",m_imap->imap_response); | 905 | qDebug("Delete successfull %s",m_imap->imap_response); |
906 | } | 906 | } |
907 | 907 | ||
908 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 908 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
909 | { | 909 | { |
910 | mailimap_flag_list*flist; | 910 | mailimap_flag_list*flist; |
911 | mailimap_set *set; | 911 | mailimap_set *set; |
912 | mailimap_store_att_flags * store_flags; | 912 | mailimap_store_att_flags * store_flags; |
913 | int err; | 913 | int err; |
914 | login(); | 914 | login(); |
915 | if (!m_imap) { | 915 | if (!m_imap) { |
916 | return; | 916 | return; |
917 | } | 917 | } |
918 | err = selectMbox(mail->getMbox()); | 918 | err = selectMbox(mail->getMbox()); |
919 | if ( err != MAILIMAP_NO_ERROR ) { | 919 | if ( err != MAILIMAP_NO_ERROR ) { |
920 | return; | 920 | return; |
921 | } | 921 | } |
922 | flist = mailimap_flag_list_new_empty(); | 922 | flist = mailimap_flag_list_new_empty(); |
923 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 923 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
924 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 924 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
925 | set = mailimap_set_new_single(mail->getNumber()); | 925 | set = mailimap_set_new_single(mail->getNumber()); |
926 | err = mailimap_store(m_imap,set,store_flags); | 926 | err = mailimap_store(m_imap,set,store_flags); |
927 | mailimap_set_free( set ); | 927 | mailimap_set_free( set ); |
928 | mailimap_store_att_flags_free(store_flags); | 928 | mailimap_store_att_flags_free(store_flags); |
929 | 929 | ||
930 | if (err != MAILIMAP_NO_ERROR) { | 930 | if (err != MAILIMAP_NO_ERROR) { |
931 | qDebug("error marking mail: %s",m_imap->imap_response); | 931 | qDebug("error marking mail: %s",m_imap->imap_response); |
932 | return; | 932 | return; |
933 | } | 933 | } |
934 | } | 934 | } |
935 | 935 | ||
936 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 936 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
937 | { | 937 | { |
938 | QString body(""); | 938 | QString body(""); |
939 | encodedString*res = fetchRawPart(mail,path,internal_call); | 939 | encodedString*res = fetchRawPart(mail,path,internal_call); |
940 | encodedString*r = decode_String(res,enc); | 940 | encodedString*r = decode_String(res,enc); |
941 | delete res; | 941 | delete res; |
942 | if (r) { | 942 | if (r) { |
943 | if (r->Length()>0) { | 943 | if (r->Length()>0) { |
944 | body = r->Content(); | 944 | body = r->Content(); |
945 | } | 945 | } |
946 | delete r; | 946 | delete r; |
947 | } | 947 | } |
948 | return body; | 948 | return body; |
949 | } | 949 | } |
950 | 950 | ||
951 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part) | 951 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
952 | { | 952 | { |
953 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); | 953 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); |
954 | } | 954 | } |
955 | 955 | ||
956 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPart&part) | 956 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) |
957 | { | 957 | { |
958 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); | 958 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); |
959 | encodedString*r = decode_String(res,part.Encoding()); | 959 | encodedString*r = decode_String(res,part->Encoding()); |
960 | delete res; | 960 | delete res; |
961 | return r; | 961 | return r; |
962 | } | 962 | } |
963 | 963 | ||
964 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part) | 964 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) |
965 | { | 965 | { |
966 | return fetchRawPart(mail,part.Positionlist(),false); | 966 | return fetchRawPart(mail,part->Positionlist(),false); |
967 | } | 967 | } |
968 | 968 | ||
969 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 969 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
970 | { | 970 | { |
971 | login(); | 971 | login(); |
972 | if (!m_imap) { | 972 | if (!m_imap) { |
973 | return 0; | 973 | return 0; |
974 | } | 974 | } |
975 | mailimap_flag_list*flist; | 975 | mailimap_flag_list*flist; |
976 | mailimap_set *set; | 976 | mailimap_set *set; |
977 | mailimap_store_att_flags * store_flags; | 977 | mailimap_store_att_flags * store_flags; |
978 | int err = selectMbox(folder->getName()); | 978 | int err = selectMbox(folder->getName()); |
979 | if ( err != MAILIMAP_NO_ERROR ) { | 979 | if ( err != MAILIMAP_NO_ERROR ) { |
980 | return 0; | 980 | return 0; |
981 | } | 981 | } |
982 | 982 | ||
983 | int last = m_imap->imap_selection_info->sel_exists; | 983 | int last = m_imap->imap_selection_info->sel_exists; |
984 | if (last == 0) { | 984 | if (last == 0) { |
985 | Global::statusMessage(tr("Mailbox has no mails!")); | 985 | Global::statusMessage(tr("Mailbox has no mails!")); |
986 | return 0; | 986 | return 0; |
987 | } | 987 | } |
988 | flist = mailimap_flag_list_new_empty(); | 988 | flist = mailimap_flag_list_new_empty(); |
989 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 989 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
990 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 990 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
991 | set = mailimap_set_new_interval( 1, last ); | 991 | set = mailimap_set_new_interval( 1, last ); |
992 | err = mailimap_store(m_imap,set,store_flags); | 992 | err = mailimap_store(m_imap,set,store_flags); |
993 | mailimap_set_free( set ); | 993 | mailimap_set_free( set ); |
994 | mailimap_store_att_flags_free(store_flags); | 994 | mailimap_store_att_flags_free(store_flags); |
995 | if (err != MAILIMAP_NO_ERROR) { | 995 | if (err != MAILIMAP_NO_ERROR) { |
996 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 996 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
997 | return 0; | 997 | return 0; |
998 | } | 998 | } |
999 | qDebug("deleting mail: %s",m_imap->imap_response); | 999 | qDebug("deleting mail: %s",m_imap->imap_response); |
1000 | /* should we realy do that at this moment? */ | 1000 | /* should we realy do that at this moment? */ |
1001 | err = mailimap_expunge(m_imap); | 1001 | err = mailimap_expunge(m_imap); |
1002 | if (err != MAILIMAP_NO_ERROR) { | 1002 | if (err != MAILIMAP_NO_ERROR) { |
1003 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1003 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
1004 | return 0; | 1004 | return 0; |
1005 | } | 1005 | } |
1006 | qDebug("Delete successfull %s",m_imap->imap_response); | 1006 | qDebug("Delete successfull %s",m_imap->imap_response); |
1007 | return 1; | 1007 | return 1; |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) | 1010 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) |
1011 | { | 1011 | { |
1012 | if (folder.length()==0) return 0; | 1012 | if (folder.length()==0) return 0; |
1013 | login(); | 1013 | login(); |
1014 | if (!m_imap) {return 0;} | 1014 | if (!m_imap) {return 0;} |
1015 | QString pre = account->getPrefix(); | 1015 | QString pre = account->getPrefix(); |
1016 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 1016 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { |
1017 | pre+=delemiter; | 1017 | pre+=delemiter; |
1018 | } | 1018 | } |
1019 | if (parentfolder) { | 1019 | if (parentfolder) { |
1020 | pre += parentfolder->getDisplayName()+delemiter; | 1020 | pre += parentfolder->getDisplayName()+delemiter; |
1021 | } | 1021 | } |
1022 | pre+=folder; | 1022 | pre+=folder; |
1023 | if (getsubfolder) { | 1023 | if (getsubfolder) { |
1024 | if (delemiter.length()>0) { | 1024 | if (delemiter.length()>0) { |
1025 | pre+=delemiter; | 1025 | pre+=delemiter; |
1026 | } else { | 1026 | } else { |
1027 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); | 1027 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); |
1028 | return 0; | 1028 | return 0; |
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | qDebug("Creating %s",pre.latin1()); | 1031 | qDebug("Creating %s",pre.latin1()); |
1032 | int res = mailimap_create(m_imap,pre.latin1()); | 1032 | int res = mailimap_create(m_imap,pre.latin1()); |
1033 | if (res != MAILIMAP_NO_ERROR) { | 1033 | if (res != MAILIMAP_NO_ERROR) { |
1034 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1034 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1035 | return 0; | 1035 | return 0; |
1036 | } | 1036 | } |
1037 | return 1; | 1037 | return 1; |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | int IMAPwrapper::deleteMbox(const FolderP&folder) | 1040 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1041 | { | 1041 | { |
1042 | if (!folder) return 0; | 1042 | if (!folder) return 0; |
1043 | login(); | 1043 | login(); |
1044 | if (!m_imap) {return 0;} | 1044 | if (!m_imap) {return 0;} |
1045 | int res = mailimap_delete(m_imap,folder->getName()); | 1045 | int res = mailimap_delete(m_imap,folder->getName()); |
1046 | if (res != MAILIMAP_NO_ERROR) { | 1046 | if (res != MAILIMAP_NO_ERROR) { |
1047 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1047 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1048 | return 0; | 1048 | return 0; |
1049 | } | 1049 | } |
1050 | return 1; | 1050 | return 1; |
1051 | } | 1051 | } |
1052 | 1052 | ||
1053 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1053 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1054 | { | 1054 | { |
1055 | mailimap_status_att_list * att_list =0; | 1055 | mailimap_status_att_list * att_list =0; |
1056 | mailimap_mailbox_data_status * status=0; | 1056 | mailimap_mailbox_data_status * status=0; |
1057 | clistiter * cur = 0; | 1057 | clistiter * cur = 0; |
1058 | int r = 0; | 1058 | int r = 0; |
1059 | target_stat.message_count = 0; | 1059 | target_stat.message_count = 0; |
1060 | target_stat.message_unseen = 0; | 1060 | target_stat.message_unseen = 0; |
1061 | target_stat.message_recent = 0; | 1061 | target_stat.message_recent = 0; |
1062 | login(); | 1062 | login(); |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 7448acb..e56605a 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -1,80 +1,80 @@ | |||
1 | #ifndef __IMAPWRAPPER | 1 | #ifndef __IMAPWRAPPER |
2 | #define __IMAPWRAPPER | 2 | #define __IMAPWRAPPER |
3 | 3 | ||
4 | #include <qlist.h> | 4 | #include <qlist.h> |
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | #include "abstractmail.h" | 6 | #include "abstractmail.h" |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | struct mailimap; | 9 | struct mailimap; |
10 | struct mailimap_body; | 10 | struct mailimap_body; |
11 | struct mailimap_body_type_1part; | 11 | struct mailimap_body_type_1part; |
12 | struct mailimap_body_type_text; | 12 | struct mailimap_body_type_text; |
13 | struct mailimap_body_type_basic; | 13 | struct mailimap_body_type_basic; |
14 | struct mailimap_body_type_msg; | 14 | struct mailimap_body_type_msg; |
15 | struct mailimap_body_type_mpart; | 15 | struct mailimap_body_type_mpart; |
16 | struct mailimap_body_fields; | 16 | struct mailimap_body_fields; |
17 | struct mailimap_msg_att; | 17 | struct mailimap_msg_att; |
18 | class encodedString; | 18 | class encodedString; |
19 | 19 | ||
20 | class IMAPwrapper : public AbstractMail | 20 | class IMAPwrapper : public AbstractMail |
21 | { | 21 | { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
24 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
25 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
26 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 26 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
27 | virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); | 27 | virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
29 | 29 | ||
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>&folder); | 32 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); |
33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
34 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 34 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
35 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 35 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
36 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 36 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
37 | 37 | ||
38 | virtual RecBody fetchBody(const RecMailP&mail); | 38 | virtual RecBodyP fetchBody(const RecMailP&mail); |
39 | virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part); | 39 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); |
40 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part); | 40 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); |
41 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part); | 41 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); |
42 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 42 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
43 | 43 | ||
44 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, | 44 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, |
45 | const QString& delemiter="/",bool getsubfolder=false); | 45 | const QString& delemiter="/",bool getsubfolder=false); |
46 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder); | 46 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder); |
47 | 47 | ||
48 | static void imap_progress( size_t current, size_t maximum ); | 48 | static void imap_progress( size_t current, size_t maximum ); |
49 | 49 | ||
50 | virtual void logout(); | 50 | virtual void logout(); |
51 | virtual MAILLIB::ATYPE getType()const; | 51 | virtual MAILLIB::ATYPE getType()const; |
52 | virtual const QString&getName()const; | 52 | virtual const QString&getName()const; |
53 | 53 | ||
54 | protected: | 54 | protected: |
55 | RecMail*parse_list_result(mailimap_msg_att*); | 55 | RecMail*parse_list_result(mailimap_msg_att*); |
56 | void login(); | 56 | void login(); |
57 | bool start_tls(bool force=true); | 57 | bool start_tls(bool force=true); |
58 | 58 | ||
59 | virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 59 | virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
60 | virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); | 60 | virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); |
61 | int selectMbox(const QString&mbox); | 61 | int selectMbox(const QString&mbox); |
62 | 62 | ||
63 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 63 | void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description); |
64 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 64 | void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which); |
65 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 65 | void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which); |
66 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 66 | void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which); |
67 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); | 67 | void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which); |
68 | void traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 68 | void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
69 | 69 | ||
70 | /* just helpers */ | 70 | /* just helpers */ |
71 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 71 | static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); |
72 | static QStringList address_list_to_stringlist(clist*list); | 72 | static QStringList address_list_to_stringlist(clist*list); |
73 | 73 | ||
74 | 74 | ||
75 | IMAPaccount *account; | 75 | IMAPaccount *account; |
76 | mailimap *m_imap; | 76 | mailimap *m_imap; |
77 | QString m_Lastmbox; | 77 | QString m_Lastmbox; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | #endif | 80 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index fd91fe5..90b8865 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -18,349 +18,375 @@ RecMail::RecMail(const RecMail&old) | |||
18 | 18 | ||
19 | RecMail::~RecMail() | 19 | RecMail::~RecMail() |
20 | { | 20 | { |
21 | wrapper = 0; | 21 | wrapper = 0; |
22 | } | 22 | } |
23 | 23 | ||
24 | void RecMail::copy_old(const RecMail&old) | 24 | void RecMail::copy_old(const RecMail&old) |
25 | { | 25 | { |
26 | subject = old.subject; | 26 | subject = old.subject; |
27 | date = old.date; | 27 | date = old.date; |
28 | mbox = old.mbox; | 28 | mbox = old.mbox; |
29 | msg_id = old.msg_id; | 29 | msg_id = old.msg_id; |
30 | msg_size = old.msg_size; | 30 | msg_size = old.msg_size; |
31 | msg_number = old.msg_number; | 31 | msg_number = old.msg_number; |
32 | from = old.from; | 32 | from = old.from; |
33 | msg_flags = old.msg_flags; | 33 | msg_flags = old.msg_flags; |
34 | to = old.to; | 34 | to = old.to; |
35 | cc = old.cc; | 35 | cc = old.cc; |
36 | bcc = old.bcc; | 36 | bcc = old.bcc; |
37 | wrapper = old.wrapper; | 37 | wrapper = old.wrapper; |
38 | in_reply_to = old.in_reply_to; | 38 | in_reply_to = old.in_reply_to; |
39 | references = old.references; | 39 | references = old.references; |
40 | replyto = old.replyto; | 40 | replyto = old.replyto; |
41 | } | 41 | } |
42 | 42 | ||
43 | void RecMail::init() | 43 | void RecMail::init() |
44 | { | 44 | { |
45 | to.clear(); | 45 | to.clear(); |
46 | cc.clear(); | 46 | cc.clear(); |
47 | bcc.clear(); | 47 | bcc.clear(); |
48 | in_reply_to.clear(); | 48 | in_reply_to.clear(); |
49 | references.clear(); | 49 | references.clear(); |
50 | wrapper = 0; | 50 | wrapper = 0; |
51 | } | 51 | } |
52 | 52 | ||
53 | void RecMail::setWrapper(AbstractMail*awrapper) | 53 | void RecMail::setWrapper(AbstractMail*awrapper) |
54 | { | 54 | { |
55 | wrapper = awrapper; | 55 | wrapper = awrapper; |
56 | } | 56 | } |
57 | 57 | ||
58 | AbstractMail* RecMail::Wrapper() | 58 | AbstractMail* RecMail::Wrapper() |
59 | { | 59 | { |
60 | return wrapper; | 60 | return wrapper; |
61 | } | 61 | } |
62 | 62 | ||
63 | void RecMail::setTo(const QStringList&list) | 63 | void RecMail::setTo(const QStringList&list) |
64 | { | 64 | { |
65 | to = list; | 65 | to = list; |
66 | } | 66 | } |
67 | 67 | ||
68 | const QStringList&RecMail::To()const | 68 | const QStringList&RecMail::To()const |
69 | { | 69 | { |
70 | return to; | 70 | return to; |
71 | } | 71 | } |
72 | 72 | ||
73 | void RecMail::setCC(const QStringList&list) | 73 | void RecMail::setCC(const QStringList&list) |
74 | { | 74 | { |
75 | cc = list; | 75 | cc = list; |
76 | } | 76 | } |
77 | 77 | ||
78 | const QStringList&RecMail::CC()const | 78 | const QStringList&RecMail::CC()const |
79 | { | 79 | { |
80 | return cc; | 80 | return cc; |
81 | } | 81 | } |
82 | 82 | ||
83 | void RecMail::setBcc(const QStringList&list) | 83 | void RecMail::setBcc(const QStringList&list) |
84 | { | 84 | { |
85 | bcc = list; | 85 | bcc = list; |
86 | } | 86 | } |
87 | 87 | ||
88 | const QStringList& RecMail::Bcc()const | 88 | const QStringList& RecMail::Bcc()const |
89 | { | 89 | { |
90 | return bcc; | 90 | return bcc; |
91 | } | 91 | } |
92 | 92 | ||
93 | void RecMail::setInreply(const QStringList&list) | 93 | void RecMail::setInreply(const QStringList&list) |
94 | { | 94 | { |
95 | in_reply_to = list; | 95 | in_reply_to = list; |
96 | } | 96 | } |
97 | 97 | ||
98 | const QStringList& RecMail::Inreply()const | 98 | const QStringList& RecMail::Inreply()const |
99 | { | 99 | { |
100 | return in_reply_to; | 100 | return in_reply_to; |
101 | } | 101 | } |
102 | 102 | ||
103 | void RecMail::setReferences(const QStringList&list) | 103 | void RecMail::setReferences(const QStringList&list) |
104 | { | 104 | { |
105 | references = list; | 105 | references = list; |
106 | } | 106 | } |
107 | 107 | ||
108 | const QStringList& RecMail::References()const | 108 | const QStringList& RecMail::References()const |
109 | { | 109 | { |
110 | return references; | 110 | return references; |
111 | } | 111 | } |
112 | 112 | ||
113 | RecPart::RecPart() | 113 | RecPart::RecPart() |
114 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | 114 | : Opie::Core::ORefCount(), |
115 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | ||
115 | { | 116 | { |
116 | m_Parameters.clear(); | 117 | m_Parameters.clear(); |
117 | m_poslist.clear(); | 118 | m_poslist.clear(); |
118 | } | 119 | } |
119 | 120 | ||
121 | RecPart::RecPart(const RecPart&old) | ||
122 | : Opie::Core::ORefCount(), | ||
123 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | ||
124 | { | ||
125 | m_type = old.m_type; | ||
126 | m_subtype = old.m_subtype; | ||
127 | m_identifier = old.m_identifier; | ||
128 | m_encoding = old.m_encoding; | ||
129 | m_description = old.m_description; | ||
130 | m_lines = old.m_lines; | ||
131 | m_size = old.m_size; | ||
132 | m_Parameters = old.m_Parameters; | ||
133 | m_poslist = old.m_poslist; | ||
134 | qDebug("RecPart copy constructor"); | ||
135 | } | ||
136 | |||
120 | RecPart::~RecPart() | 137 | RecPart::~RecPart() |
121 | { | 138 | { |
122 | } | 139 | } |
123 | 140 | ||
124 | void RecPart::setSize(unsigned int size) | 141 | void RecPart::setSize(unsigned int size) |
125 | { | 142 | { |
126 | m_size = size; | 143 | m_size = size; |
127 | } | 144 | } |
128 | 145 | ||
129 | const unsigned int RecPart::Size()const | 146 | const unsigned int RecPart::Size()const |
130 | { | 147 | { |
131 | return m_size; | 148 | return m_size; |
132 | } | 149 | } |
133 | 150 | ||
134 | void RecPart::setLines(unsigned int lines) | 151 | void RecPart::setLines(unsigned int lines) |
135 | { | 152 | { |
136 | m_lines = lines; | 153 | m_lines = lines; |
137 | } | 154 | } |
138 | 155 | ||
139 | const unsigned int RecPart::Lines()const | 156 | const unsigned int RecPart::Lines()const |
140 | { | 157 | { |
141 | return m_lines; | 158 | return m_lines; |
142 | } | 159 | } |
143 | 160 | ||
144 | const QString& RecPart::Type()const | 161 | const QString& RecPart::Type()const |
145 | { | 162 | { |
146 | return m_type; | 163 | return m_type; |
147 | } | 164 | } |
148 | 165 | ||
149 | void RecPart::setType(const QString&type) | 166 | void RecPart::setType(const QString&type) |
150 | { | 167 | { |
151 | m_type = type; | 168 | m_type = type; |
152 | } | 169 | } |
153 | 170 | ||
154 | const QString& RecPart::Subtype()const | 171 | const QString& RecPart::Subtype()const |
155 | { | 172 | { |
156 | return m_subtype; | 173 | return m_subtype; |
157 | } | 174 | } |
158 | 175 | ||
159 | void RecPart::setSubtype(const QString&subtype) | 176 | void RecPart::setSubtype(const QString&subtype) |
160 | { | 177 | { |
161 | m_subtype = subtype; | 178 | m_subtype = subtype; |
162 | } | 179 | } |
163 | 180 | ||
164 | const QString& RecPart::Identifier()const | 181 | const QString& RecPart::Identifier()const |
165 | { | 182 | { |
166 | return m_identifier; | 183 | return m_identifier; |
167 | } | 184 | } |
168 | 185 | ||
169 | void RecPart::setIdentifier(const QString&identifier) | 186 | void RecPart::setIdentifier(const QString&identifier) |
170 | { | 187 | { |
171 | m_identifier = identifier; | 188 | m_identifier = identifier; |
172 | } | 189 | } |
173 | 190 | ||
174 | const QString& RecPart::Encoding()const | 191 | const QString& RecPart::Encoding()const |
175 | { | 192 | { |
176 | return m_encoding; | 193 | return m_encoding; |
177 | } | 194 | } |
178 | 195 | ||
179 | void RecPart::setEncoding(const QString&encoding) | 196 | void RecPart::setEncoding(const QString&encoding) |
180 | { | 197 | { |
181 | m_encoding = encoding; | 198 | m_encoding = encoding; |
182 | } | 199 | } |
183 | 200 | ||
184 | const QString& RecPart::Description()const | 201 | const QString& RecPart::Description()const |
185 | { | 202 | { |
186 | return m_description; | 203 | return m_description; |
187 | } | 204 | } |
188 | 205 | ||
189 | void RecPart::setDescription(const QString&desc) | 206 | void RecPart::setDescription(const QString&desc) |
190 | { | 207 | { |
191 | m_description = desc; | 208 | m_description = desc; |
192 | } | 209 | } |
193 | 210 | ||
194 | void RecPart::setParameters(const part_plist_t&list) | 211 | void RecPart::setParameters(const part_plist_t&list) |
195 | { | 212 | { |
196 | m_Parameters = list; | 213 | m_Parameters = list; |
197 | } | 214 | } |
198 | 215 | ||
199 | const part_plist_t& RecPart::Parameters()const | 216 | const part_plist_t& RecPart::Parameters()const |
200 | { | 217 | { |
201 | return m_Parameters; | 218 | return m_Parameters; |
202 | } | 219 | } |
203 | 220 | ||
204 | void RecPart::addParameter(const QString&key,const QString&value) | 221 | void RecPart::addParameter(const QString&key,const QString&value) |
205 | { | 222 | { |
206 | m_Parameters[key]=value; | 223 | m_Parameters[key]=value; |
207 | } | 224 | } |
208 | 225 | ||
209 | const QString RecPart::searchParamter(const QString&key)const | 226 | const QString RecPart::searchParamter(const QString&key)const |
210 | { | 227 | { |
211 | QString value(""); | 228 | QString value(""); |
212 | part_plist_t::ConstIterator it = m_Parameters.find(key); | 229 | part_plist_t::ConstIterator it = m_Parameters.find(key); |
213 | if (it != m_Parameters.end()) { | 230 | if (it != m_Parameters.end()) { |
214 | value = it.data(); | 231 | value = it.data(); |
215 | } | 232 | } |
216 | return value; | 233 | return value; |
217 | } | 234 | } |
218 | 235 | ||
219 | void RecPart::setPositionlist(const QValueList<int>&poslist) | 236 | void RecPart::setPositionlist(const QValueList<int>&poslist) |
220 | { | 237 | { |
221 | m_poslist = poslist; | 238 | m_poslist = poslist; |
222 | } | 239 | } |
223 | 240 | ||
224 | const QValueList<int>& RecPart::Positionlist()const | 241 | const QValueList<int>& RecPart::Positionlist()const |
225 | { | 242 | { |
226 | return m_poslist; | 243 | return m_poslist; |
227 | } | 244 | } |
228 | 245 | ||
229 | RecBody::RecBody() | 246 | RecBody::RecBody() |
230 | : m_BodyText(),m_PartsList(),m_description() | 247 | : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart()) |
231 | { | 248 | { |
232 | m_PartsList.clear(); | 249 | m_PartsList.clear(); |
233 | } | 250 | } |
234 | 251 | ||
252 | RecBody::RecBody(const RecBody&old) | ||
253 | :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) | ||
254 | { | ||
255 | m_BodyText = old.m_BodyText; | ||
256 | m_PartsList = old.m_PartsList; | ||
257 | m_description = old.m_description; | ||
258 | qDebug("Recbody copy constructor"); | ||
259 | } | ||
260 | |||
235 | RecBody::~RecBody() | 261 | RecBody::~RecBody() |
236 | { | 262 | { |
237 | } | 263 | } |
238 | 264 | ||
239 | void RecBody::setBodytext(const QString&bodyText) | 265 | void RecBody::setBodytext(const QString&bodyText) |
240 | { | 266 | { |
241 | m_BodyText = bodyText; | 267 | m_BodyText = bodyText; |
242 | } | 268 | } |
243 | 269 | ||
244 | const QString& RecBody::Bodytext()const | 270 | const QString& RecBody::Bodytext()const |
245 | { | 271 | { |
246 | return m_BodyText; | 272 | return m_BodyText; |
247 | } | 273 | } |
248 | 274 | ||
249 | void RecBody::setParts(const QValueList<RecPart>&parts) | 275 | void RecBody::setParts(const QValueList<RecPartP>&parts) |
250 | { | 276 | { |
251 | m_PartsList.clear(); | 277 | m_PartsList.clear(); |
252 | m_PartsList = parts; | 278 | m_PartsList = parts; |
253 | } | 279 | } |
254 | 280 | ||
255 | const QValueList<RecPart>& RecBody::Parts()const | 281 | const QValueList<RecPartP>& RecBody::Parts()const |
256 | { | 282 | { |
257 | return m_PartsList; | 283 | return m_PartsList; |
258 | } | 284 | } |
259 | 285 | ||
260 | void RecBody::addPart(const RecPart& part) | 286 | void RecBody::addPart(const RecPartP& part) |
261 | { | 287 | { |
262 | m_PartsList.append(part); | 288 | m_PartsList.append(part); |
263 | } | 289 | } |
264 | 290 | ||
265 | void RecBody::setDescription(const RecPart&des) | 291 | void RecBody::setDescription(const RecPartP&des) |
266 | { | 292 | { |
267 | m_description = des; | 293 | m_description = des; |
268 | } | 294 | } |
269 | 295 | ||
270 | const RecPart& RecBody::Description()const | 296 | const RecPartP& RecBody::Description()const |
271 | { | 297 | { |
272 | return m_description; | 298 | return m_description; |
273 | } | 299 | } |
274 | 300 | ||
275 | /* handling encoded content */ | 301 | /* handling encoded content */ |
276 | encodedString::encodedString() | 302 | encodedString::encodedString() |
277 | { | 303 | { |
278 | init(); | 304 | init(); |
279 | } | 305 | } |
280 | 306 | ||
281 | encodedString::encodedString(const char*nContent,unsigned int nSize) | 307 | encodedString::encodedString(const char*nContent,unsigned int nSize) |
282 | { | 308 | { |
283 | init(); | 309 | init(); |
284 | setContent(nContent,nSize); | 310 | setContent(nContent,nSize); |
285 | } | 311 | } |
286 | 312 | ||
287 | encodedString::encodedString(char*nContent,unsigned int nSize) | 313 | encodedString::encodedString(char*nContent,unsigned int nSize) |
288 | { | 314 | { |
289 | init(); | 315 | init(); |
290 | setContent(nContent,nSize); | 316 | setContent(nContent,nSize); |
291 | } | 317 | } |
292 | 318 | ||
293 | encodedString::encodedString(const encodedString&old) | 319 | encodedString::encodedString(const encodedString&old) |
294 | { | 320 | { |
295 | init(); | 321 | init(); |
296 | copy_old(old); | 322 | copy_old(old); |
297 | qDebug("encodedeString: copy constructor!"); | 323 | qDebug("encodedeString: copy constructor!"); |
298 | } | 324 | } |
299 | 325 | ||
300 | encodedString& encodedString::operator=(const encodedString&old) | 326 | encodedString& encodedString::operator=(const encodedString&old) |
301 | { | 327 | { |
302 | init(); | 328 | init(); |
303 | copy_old(old); | 329 | copy_old(old); |
304 | qDebug("encodedString: assign operator!"); | 330 | qDebug("encodedString: assign operator!"); |
305 | return *this; | 331 | return *this; |
306 | } | 332 | } |
307 | 333 | ||
308 | encodedString::~encodedString() | 334 | encodedString::~encodedString() |
309 | { | 335 | { |
310 | clean(); | 336 | clean(); |
311 | } | 337 | } |
312 | 338 | ||
313 | void encodedString::init() | 339 | void encodedString::init() |
314 | { | 340 | { |
315 | content = 0; | 341 | content = 0; |
316 | size = 0; | 342 | size = 0; |
317 | } | 343 | } |
318 | 344 | ||
319 | void encodedString::clean() | 345 | void encodedString::clean() |
320 | { | 346 | { |
321 | if (content) { | 347 | if (content) { |
322 | free(content); | 348 | free(content); |
323 | } | 349 | } |
324 | content = 0; | 350 | content = 0; |
325 | size = 0; | 351 | size = 0; |
326 | } | 352 | } |
327 | 353 | ||
328 | void encodedString::copy_old(const encodedString&old) | 354 | void encodedString::copy_old(const encodedString&old) |
329 | { | 355 | { |
330 | clean(); | 356 | clean(); |
331 | if (old.size>0 && old.content) { | 357 | if (old.size>0 && old.content) { |
332 | content = (char*)malloc(old.size*sizeof(char)); | 358 | content = (char*)malloc(old.size*sizeof(char)); |
333 | memcpy(content,old.content,size); | 359 | memcpy(content,old.content,size); |
334 | size = old.size; | 360 | size = old.size; |
335 | } | 361 | } |
336 | } | 362 | } |
337 | 363 | ||
338 | const char*encodedString::Content()const | 364 | const char*encodedString::Content()const |
339 | { | 365 | { |
340 | return content; | 366 | return content; |
341 | } | 367 | } |
342 | 368 | ||
343 | const int encodedString::Length()const | 369 | const int encodedString::Length()const |
344 | { | 370 | { |
345 | return size; | 371 | return size; |
346 | } | 372 | } |
347 | 373 | ||
348 | void encodedString::setContent(const char*nContent,int nSize) | 374 | void encodedString::setContent(const char*nContent,int nSize) |
349 | { | 375 | { |
350 | if (nSize>0 && nContent) { | 376 | if (nSize>0 && nContent) { |
351 | content = (char*)malloc(nSize*sizeof(char)); | 377 | content = (char*)malloc(nSize*sizeof(char)); |
352 | memcpy(content,nContent,nSize); | 378 | memcpy(content,nContent,nSize); |
353 | size = nSize; | 379 | size = nSize; |
354 | } | 380 | } |
355 | } | 381 | } |
356 | 382 | ||
357 | void encodedString::setContent(char*nContent,int nSize) | 383 | void encodedString::setContent(char*nContent,int nSize) |
358 | { | 384 | { |
359 | content = nContent; | 385 | content = nContent; |
360 | size = nSize; | 386 | size = nSize; |
361 | } | 387 | } |
362 | 388 | ||
363 | folderStat&folderStat::operator=(const folderStat&old) | 389 | folderStat&folderStat::operator=(const folderStat&old) |
364 | { | 390 | { |
365 | message_count = old.message_count; | 391 | message_count = old.message_count; |
366 | message_unseen = old.message_unseen; | 392 | message_unseen = old.message_unseen; |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index 941556a..c317880 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -1,200 +1,206 @@ | |||
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 | 38 | ||
39 | const unsigned int getNumber()const{return msg_number;} | 39 | const unsigned int getNumber()const{return msg_number;} |
40 | void setNumber(unsigned int number){msg_number=number;} | 40 | void setNumber(unsigned int number){msg_number=number;} |
41 | const QString&getDate()const{ return date; } | 41 | const QString&getDate()const{ return date; } |
42 | void setDate( const QString&a ) { date = a; } | 42 | void setDate( const QString&a ) { date = a; } |
43 | const QString&getFrom()const{ return from; } | 43 | const QString&getFrom()const{ return from; } |
44 | void setFrom( const QString&a ) { from = a; } | 44 | void setFrom( const QString&a ) { from = a; } |
45 | const QString&getSubject()const { return subject; } | 45 | const QString&getSubject()const { return subject; } |
46 | void setSubject( const QString&s ) { subject = s; } | 46 | void setSubject( const QString&s ) { subject = s; } |
47 | const QString&getMbox()const{return mbox;} | 47 | const QString&getMbox()const{return mbox;} |
48 | void setMbox(const QString&box){mbox = box;} | 48 | void setMbox(const QString&box){mbox = box;} |
49 | void setMsgid(const QString&id){msg_id=id;} | 49 | void setMsgid(const QString&id){msg_id=id;} |
50 | const QString&Msgid()const{return msg_id;} | 50 | const QString&Msgid()const{return msg_id;} |
51 | void setReplyto(const QString&reply){replyto=reply;} | 51 | void setReplyto(const QString&reply){replyto=reply;} |
52 | const QString&Replyto()const{return replyto;} | 52 | const QString&Replyto()const{return replyto;} |
53 | void setMsgsize(unsigned int size){msg_size = size;} | 53 | void setMsgsize(unsigned int size){msg_size = size;} |
54 | const unsigned int Msgsize()const{return msg_size;} | 54 | const unsigned int Msgsize()const{return msg_size;} |
55 | 55 | ||
56 | 56 | ||
57 | void setTo(const QStringList&list); | 57 | void setTo(const QStringList&list); |
58 | const QStringList&To()const; | 58 | const QStringList&To()const; |
59 | void setCC(const QStringList&list); | 59 | void setCC(const QStringList&list); |
60 | const QStringList&CC()const; | 60 | const QStringList&CC()const; |
61 | void setBcc(const QStringList&list); | 61 | void setBcc(const QStringList&list); |
62 | const QStringList&Bcc()const; | 62 | const QStringList&Bcc()const; |
63 | void setInreply(const QStringList&list); | 63 | void setInreply(const QStringList&list); |
64 | const QStringList&Inreply()const; | 64 | const QStringList&Inreply()const; |
65 | void setReferences(const QStringList&list); | 65 | void setReferences(const QStringList&list); |
66 | const QStringList&References()const; | 66 | const QStringList&References()const; |
67 | 67 | ||
68 | const QBitArray&getFlags()const{return msg_flags;} | 68 | const QBitArray&getFlags()const{return msg_flags;} |
69 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 69 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
70 | 70 | ||
71 | void setWrapper(AbstractMail*wrapper); | 71 | void setWrapper(AbstractMail*wrapper); |
72 | AbstractMail* Wrapper(); | 72 | AbstractMail* Wrapper(); |
73 | 73 | ||
74 | protected: | 74 | protected: |
75 | QString subject,date,from,mbox,msg_id,replyto; | 75 | QString subject,date,from,mbox,msg_id,replyto; |
76 | unsigned int msg_number,msg_size; | 76 | unsigned int msg_number,msg_size; |
77 | QBitArray msg_flags; | 77 | QBitArray msg_flags; |
78 | QStringList to,cc,bcc,in_reply_to,references; | 78 | QStringList to,cc,bcc,in_reply_to,references; |
79 | AbstractMail*wrapper; | 79 | AbstractMail*wrapper; |
80 | void init(); | 80 | void init(); |
81 | void copy_old(const RecMail&old); | 81 | void copy_old(const RecMail&old); |
82 | }; | 82 | }; |
83 | 83 | ||
84 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; | 84 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; |
85 | typedef QMap<QString,QString> part_plist_t; | 85 | typedef QMap<QString,QString> part_plist_t; |
86 | 86 | ||
87 | class RecPart | 87 | class RecPart:public Opie::Core::ORefCount |
88 | { | 88 | { |
89 | protected: | 89 | protected: |
90 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 90 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
91 | unsigned int m_lines,m_size; | 91 | unsigned int m_lines,m_size; |
92 | part_plist_t m_Parameters; | 92 | part_plist_t m_Parameters; |
93 | /* describes the position in the mail */ | 93 | /* describes the position in the mail */ |
94 | QValueList<int> m_poslist; | 94 | QValueList<int> m_poslist; |
95 | 95 | ||
96 | public: | 96 | public: |
97 | RecPart(); | 97 | RecPart(); |
98 | RecPart(const RecPart&); | ||
98 | virtual ~RecPart(); | 99 | virtual ~RecPart(); |
99 | 100 | ||
100 | const QString&Type()const; | 101 | const QString&Type()const; |
101 | void setType(const QString&type); | 102 | void setType(const QString&type); |
102 | const QString&Subtype()const; | 103 | const QString&Subtype()const; |
103 | void setSubtype(const QString&subtype); | 104 | void setSubtype(const QString&subtype); |
104 | const QString&Identifier()const; | 105 | const QString&Identifier()const; |
105 | void setIdentifier(const QString&identifier); | 106 | void setIdentifier(const QString&identifier); |
106 | const QString&Encoding()const; | 107 | const QString&Encoding()const; |
107 | void setEncoding(const QString&encoding); | 108 | void setEncoding(const QString&encoding); |
108 | const QString&Description()const; | 109 | const QString&Description()const; |
109 | void setDescription(const QString&desc); | 110 | void setDescription(const QString&desc); |
110 | void setLines(unsigned int lines); | 111 | void setLines(unsigned int lines); |
111 | const unsigned int Lines()const; | 112 | const unsigned int Lines()const; |
112 | void setSize(unsigned int size); | 113 | void setSize(unsigned int size); |
113 | const unsigned int Size()const; | 114 | const unsigned int Size()const; |
114 | 115 | ||
115 | 116 | ||
116 | void setParameters(const part_plist_t&list); | 117 | void setParameters(const part_plist_t&list); |
117 | const part_plist_t&Parameters()const; | 118 | const part_plist_t&Parameters()const; |
118 | void addParameter(const QString&key,const QString&value); | 119 | void addParameter(const QString&key,const QString&value); |
119 | const QString searchParamter(const QString&key)const; | 120 | const QString searchParamter(const QString&key)const; |
120 | void setPositionlist(const QValueList<int>&poslist); | 121 | void setPositionlist(const QValueList<int>&poslist); |
121 | const QValueList<int>& Positionlist()const; | 122 | const QValueList<int>& Positionlist()const; |
122 | }; | 123 | }; |
123 | 124 | ||
124 | class RecBody | 125 | typedef Opie::Core::OSmartPointer<RecPart> RecPartP; |
126 | |||
127 | class RecBody:public Opie::Core::ORefCount | ||
125 | { | 128 | { |
126 | protected: | 129 | protected: |
127 | QString m_BodyText; | 130 | QString m_BodyText; |
128 | QValueList<RecPart> m_PartsList; | 131 | QValueList<RecPartP> m_PartsList; |
129 | RecPart m_description; | 132 | RecPartP m_description; |
130 | 133 | ||
131 | public: | 134 | public: |
132 | RecBody(); | 135 | RecBody(); |
136 | RecBody(const RecBody&old); | ||
133 | virtual ~RecBody(); | 137 | virtual ~RecBody(); |
134 | void setBodytext(const QString&); | 138 | void setBodytext(const QString&); |
135 | const QString& Bodytext()const; | 139 | const QString& Bodytext()const; |
136 | 140 | ||
137 | void setDescription(const RecPart&des); | 141 | void setDescription(const RecPartP&des); |
138 | const RecPart& Description()const; | 142 | const RecPartP& Description()const; |
139 | 143 | ||
140 | void setParts(const QValueList<RecPart>&parts); | 144 | void setParts(const QValueList<RecPartP>&parts); |
141 | const QValueList<RecPart>& Parts()const; | 145 | const QValueList<RecPartP>& Parts()const; |
142 | void addPart(const RecPart&part); | 146 | void addPart(const RecPartP&part); |
143 | }; | 147 | }; |
144 | 148 | ||
149 | typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; | ||
150 | |||
145 | class encodedString | 151 | class encodedString |
146 | { | 152 | { |
147 | public: | 153 | public: |
148 | encodedString(); | 154 | encodedString(); |
149 | /* | 155 | /* |
150 | creates an new content string. | 156 | creates an new content string. |
151 | it makes a deep copy of it! | 157 | it makes a deep copy of it! |
152 | */ | 158 | */ |
153 | encodedString(const char*nContent,unsigned int length); | 159 | encodedString(const char*nContent,unsigned int length); |
154 | /* | 160 | /* |
155 | Take over the nContent. Means: it will just copy the pointer, not the content. | 161 | Take over the nContent. Means: it will just copy the pointer, not the content. |
156 | so make sure: No one else frees the string, the string has allocated with | 162 | so make sure: No one else frees the string, the string has allocated with |
157 | malloc for compatibility with c-based libs | 163 | malloc for compatibility with c-based libs |
158 | */ | 164 | */ |
159 | encodedString(char*nContent,unsigned int nSize); | 165 | encodedString(char*nContent,unsigned int nSize); |
160 | /* copy construkor - makes ALWAYS a deep copy!!!! */ | 166 | /* copy construkor - makes ALWAYS a deep copy!!!! */ |
161 | encodedString(const encodedString&old); | 167 | encodedString(const encodedString&old); |
162 | /* assign operator - makes ALWAYS a deep copy!!!! */ | 168 | /* assign operator - makes ALWAYS a deep copy!!!! */ |
163 | encodedString& operator=(const encodedString&old); | 169 | encodedString& operator=(const encodedString&old); |
164 | /* destructor - cleans the content */ | 170 | /* destructor - cleans the content */ |
165 | virtual ~encodedString(); | 171 | virtual ~encodedString(); |
166 | 172 | ||
167 | /* returns a pointer to the content - do not delete yoursel! */ | 173 | /* returns a pointer to the content - do not delete yoursel! */ |
168 | const char*Content()const; | 174 | const char*Content()const; |
169 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ | 175 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ |
170 | const int Length()const; | 176 | const int Length()const; |
171 | 177 | ||
172 | /* | 178 | /* |
173 | makes a deep copy of nContent! | 179 | makes a deep copy of nContent! |
174 | */ | 180 | */ |
175 | void setContent(const char*nContent,int nSize); | 181 | void setContent(const char*nContent,int nSize); |
176 | /* | 182 | /* |
177 | Take over the nContent. Means: it will just copy the pointer, not the content. | 183 | Take over the nContent. Means: it will just copy the pointer, not the content. |
178 | so make sure: No one else frees the string, the string has allocated with | 184 | so make sure: No one else frees the string, the string has allocated with |
179 | malloc for compatibility with c-based libs | 185 | malloc for compatibility with c-based libs |
180 | */ | 186 | */ |
181 | void setContent(char*nContent,int nSize); | 187 | void setContent(char*nContent,int nSize); |
182 | 188 | ||
183 | protected: | 189 | protected: |
184 | char * content; | 190 | char * content; |
185 | unsigned int size; | 191 | unsigned int size; |
186 | 192 | ||
187 | void init(); | 193 | void init(); |
188 | void copy_old(const encodedString&old); | 194 | void copy_old(const encodedString&old); |
189 | void clean(); | 195 | void clean(); |
190 | }; | 196 | }; |
191 | 197 | ||
192 | struct folderStat | 198 | struct folderStat |
193 | { | 199 | { |
194 | unsigned int message_count; | 200 | unsigned int message_count; |
195 | unsigned int message_unseen; | 201 | unsigned int message_unseen; |
196 | unsigned int message_recent; | 202 | unsigned int message_recent; |
197 | folderStat&operator=(const folderStat&old); | 203 | folderStat&operator=(const folderStat&old); |
198 | }; | 204 | }; |
199 | 205 | ||
200 | #endif | 206 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 4aee0be..e3c75f3 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,188 +1,188 @@ | |||
1 | #include "mboxwrapper.h" | 1 | #include "mboxwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
8 | 8 | ||
9 | using namespace Opie::Core; | 9 | using namespace Opie::Core; |
10 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) | 10 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) |
11 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) | 11 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
12 | { | 12 | { |
13 | QDir dir(MBOXPath); | 13 | QDir dir(MBOXPath); |
14 | if (!dir.exists()) { | 14 | if (!dir.exists()) { |
15 | dir.mkdir(MBOXPath); | 15 | dir.mkdir(MBOXPath); |
16 | } | 16 | } |
17 | } | 17 | } |
18 | 18 | ||
19 | MBOXwrapper::~MBOXwrapper() | 19 | MBOXwrapper::~MBOXwrapper() |
20 | { | 20 | { |
21 | } | 21 | } |
22 | 22 | ||
23 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) | 23 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) |
24 | { | 24 | { |
25 | mailstorage*storage = mailstorage_new(NULL); | 25 | mailstorage*storage = mailstorage_new(NULL); |
26 | QString p = MBOXPath+"/"; | 26 | QString p = MBOXPath+"/"; |
27 | p+=mailbox; | 27 | p+=mailbox; |
28 | 28 | ||
29 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 29 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
30 | mailfolder*folder; | 30 | mailfolder*folder; |
31 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 31 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
32 | r = mailfolder_connect(folder); | 32 | r = mailfolder_connect(folder); |
33 | if (r != MAIL_NO_ERROR) { | 33 | if (r != MAIL_NO_ERROR) { |
34 | qDebug("Error initializing mbox"); | 34 | qDebug("Error initializing mbox"); |
35 | mailfolder_free(folder); | 35 | mailfolder_free(folder); |
36 | mailstorage_free(storage); | 36 | mailstorage_free(storage); |
37 | return; | 37 | return; |
38 | } | 38 | } |
39 | 39 | ||
40 | parseList(target,folder->fld_session,mailbox); | 40 | parseList(target,folder->fld_session,mailbox); |
41 | 41 | ||
42 | mailfolder_disconnect(folder); | 42 | mailfolder_disconnect(folder); |
43 | mailfolder_free(folder); | 43 | mailfolder_free(folder); |
44 | mailstorage_free(storage); | 44 | mailstorage_free(storage); |
45 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 45 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
46 | } | 46 | } |
47 | 47 | ||
48 | QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() | 48 | QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() |
49 | { | 49 | { |
50 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 50 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
51 | QDir dir(MBOXPath); | 51 | QDir dir(MBOXPath); |
52 | if (!dir.exists()) return folders; | 52 | if (!dir.exists()) return folders; |
53 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 53 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
54 | QStringList entries = dir.entryList(); | 54 | QStringList entries = dir.entryList(); |
55 | QStringList::ConstIterator it = entries.begin(); | 55 | QStringList::ConstIterator it = entries.begin(); |
56 | for (;it!=entries.end();++it) { | 56 | for (;it!=entries.end();++it) { |
57 | FolderP inb=new Folder(*it,"/"); | 57 | FolderP inb=new Folder(*it,"/"); |
58 | folders->append(inb); | 58 | folders->append(inb); |
59 | } | 59 | } |
60 | return folders; | 60 | return folders; |
61 | } | 61 | } |
62 | 62 | ||
63 | void MBOXwrapper::deleteMail(const RecMailP & mail) | 63 | void MBOXwrapper::deleteMail(const RecMailP & mail) |
64 | { | 64 | { |
65 | mailstorage*storage = mailstorage_new(NULL); | 65 | mailstorage*storage = mailstorage_new(NULL); |
66 | QString p = MBOXPath+"/"; | 66 | QString p = MBOXPath+"/"; |
67 | p+=mail->getMbox(); | 67 | p+=mail->getMbox(); |
68 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 68 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
69 | mailfolder*folder; | 69 | mailfolder*folder; |
70 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 70 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
71 | r = mailfolder_connect(folder); | 71 | r = mailfolder_connect(folder); |
72 | if (r != MAIL_NO_ERROR) { | 72 | if (r != MAIL_NO_ERROR) { |
73 | qDebug("Error initializing mbox"); | 73 | qDebug("Error initializing mbox"); |
74 | mailfolder_free(folder); | 74 | mailfolder_free(folder); |
75 | mailstorage_free(storage); | 75 | mailstorage_free(storage); |
76 | return; | 76 | return; |
77 | } | 77 | } |
78 | r = mailsession_remove_message(folder->fld_session,mail->getNumber()); | 78 | r = mailsession_remove_message(folder->fld_session,mail->getNumber()); |
79 | if (r != MAIL_NO_ERROR) { | 79 | if (r != MAIL_NO_ERROR) { |
80 | qDebug("error deleting mail"); | 80 | qDebug("error deleting mail"); |
81 | } | 81 | } |
82 | mailfolder_free(folder); | 82 | mailfolder_free(folder); |
83 | mailstorage_free(storage); | 83 | mailstorage_free(storage); |
84 | } | 84 | } |
85 | 85 | ||
86 | void MBOXwrapper::answeredMail(const RecMailP&) | 86 | void MBOXwrapper::answeredMail(const RecMailP&) |
87 | { | 87 | { |
88 | } | 88 | } |
89 | 89 | ||
90 | RecBody MBOXwrapper::fetchBody( const RecMailP &mail ) | 90 | RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) |
91 | { | 91 | { |
92 | RecBody body; | 92 | RecBodyP body = new RecBody(); |
93 | mailstorage*storage = mailstorage_new(NULL); | 93 | mailstorage*storage = mailstorage_new(NULL); |
94 | QString p = MBOXPath+"/"; | 94 | QString p = MBOXPath+"/"; |
95 | p+=mail->getMbox(); | 95 | p+=mail->getMbox(); |
96 | mailmessage * msg; | 96 | mailmessage * msg; |
97 | char*data=0; | 97 | char*data=0; |
98 | size_t size; | 98 | size_t size; |
99 | 99 | ||
100 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 100 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
101 | mailfolder*folder; | 101 | mailfolder*folder; |
102 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 102 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
103 | r = mailfolder_connect(folder); | 103 | r = mailfolder_connect(folder); |
104 | if (r != MAIL_NO_ERROR) { | 104 | if (r != MAIL_NO_ERROR) { |
105 | qDebug("Error initializing mbox"); | 105 | qDebug("Error initializing mbox"); |
106 | mailfolder_free(folder); | 106 | mailfolder_free(folder); |
107 | mailstorage_free(storage); | 107 | mailstorage_free(storage); |
108 | return body; | 108 | return body; |
109 | } | 109 | } |
110 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); | 110 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
111 | if (r != MAIL_NO_ERROR) { | 111 | if (r != MAIL_NO_ERROR) { |
112 | qDebug("Error fetching mail %i",mail->getNumber()); | 112 | qDebug("Error fetching mail %i",mail->getNumber()); |
113 | mailfolder_free(folder); | 113 | mailfolder_free(folder); |
114 | mailstorage_free(storage); | 114 | mailstorage_free(storage); |
115 | return body; | 115 | return body; |
116 | } | 116 | } |
117 | r = mailmessage_fetch(msg,&data,&size); | 117 | r = mailmessage_fetch(msg,&data,&size); |
118 | if (r != MAIL_NO_ERROR) { | 118 | if (r != MAIL_NO_ERROR) { |
119 | qDebug("Error fetching mail %i",mail->getNumber()); | 119 | qDebug("Error fetching mail %i",mail->getNumber()); |
120 | mailfolder_free(folder); | 120 | mailfolder_free(folder); |
121 | mailstorage_free(storage); | 121 | mailstorage_free(storage); |
122 | mailmessage_free(msg); | 122 | mailmessage_free(msg); |
123 | return body; | 123 | return body; |
124 | } | 124 | } |
125 | body = parseMail(msg); | 125 | body = parseMail(msg); |
126 | mailmessage_fetch_result_free(msg,data); | 126 | mailmessage_fetch_result_free(msg,data); |
127 | mailfolder_free(folder); | 127 | mailfolder_free(folder); |
128 | mailstorage_free(storage); | 128 | mailstorage_free(storage); |
129 | 129 | ||
130 | return body; | 130 | return body; |
131 | } | 131 | } |
132 | 132 | ||
133 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 133 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
134 | { | 134 | { |
135 | qDebug("MBOX %i von %i",current,maximum); | 135 | qDebug("MBOX %i von %i",current,maximum); |
136 | } | 136 | } |
137 | 137 | ||
138 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) | 138 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) |
139 | { | 139 | { |
140 | QString p = MBOXPath+"/"; | 140 | QString p = MBOXPath+"/"; |
141 | p+=folder; | 141 | p+=folder; |
142 | QFileInfo fi(p); | 142 | QFileInfo fi(p); |
143 | if (fi.exists()) { | 143 | if (fi.exists()) { |
144 | Global::statusMessage(tr("Mailbox exists.")); | 144 | Global::statusMessage(tr("Mailbox exists.")); |
145 | return 0; | 145 | return 0; |
146 | } | 146 | } |
147 | mailmbox_folder*f = 0; | 147 | mailmbox_folder*f = 0; |
148 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | 148 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { |
149 | Global::statusMessage(tr("Error init folder")); | 149 | Global::statusMessage(tr("Error init folder")); |
150 | return 0; | 150 | return 0; |
151 | } | 151 | } |
152 | if (f) mailmbox_done(f); | 152 | if (f) mailmbox_done(f); |
153 | return 1; | 153 | return 1; |
154 | } | 154 | } |
155 | 155 | ||
156 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 156 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
157 | { | 157 | { |
158 | QString p = MBOXPath+"/"; | 158 | QString p = MBOXPath+"/"; |
159 | p+=folder; | 159 | p+=folder; |
160 | mailmbox_folder*f = 0; | 160 | mailmbox_folder*f = 0; |
161 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 161 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
162 | if (r != MAIL_NO_ERROR) { | 162 | if (r != MAIL_NO_ERROR) { |
163 | Global::statusMessage(tr("Error init folder")); | 163 | Global::statusMessage(tr("Error init folder")); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | r = mailmbox_append_message(f,msg,length); | 166 | r = mailmbox_append_message(f,msg,length); |
167 | if (r != MAIL_NO_ERROR) { | 167 | if (r != MAIL_NO_ERROR) { |
168 | Global::statusMessage(tr("Error writing to message folder")); | 168 | Global::statusMessage(tr("Error writing to message folder")); |
169 | } | 169 | } |
170 | mailmbox_done(f); | 170 | mailmbox_done(f); |
171 | } | 171 | } |
172 | 172 | ||
173 | encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) | 173 | encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) |
174 | { | 174 | { |
175 | RecBody body; | 175 | RecBody body; |
176 | mailstorage*storage = mailstorage_new(NULL); | 176 | mailstorage*storage = mailstorage_new(NULL); |
177 | QString p = MBOXPath+"/"; | 177 | QString p = MBOXPath+"/"; |
178 | p+=mail->getMbox(); | 178 | p+=mail->getMbox(); |
179 | mailmessage * msg; | 179 | mailmessage * msg; |
180 | char*data=0; | 180 | char*data=0; |
181 | size_t size; | 181 | size_t size; |
182 | 182 | ||
183 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 183 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
184 | mailfolder*folder; | 184 | mailfolder*folder; |
185 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 185 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
186 | r = mailfolder_connect(folder); | 186 | r = mailfolder_connect(folder); |
187 | if (r != MAIL_NO_ERROR) { | 187 | if (r != MAIL_NO_ERROR) { |
188 | Global::statusMessage(tr("Error initializing mbox")); | 188 | Global::statusMessage(tr("Error initializing mbox")); |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index a2ecfee..9731b85 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -1,46 +1,46 @@ | |||
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 RecBody 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 | 39 | ||
40 | protected: | 40 | protected: |
41 | static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target); | 41 | static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target); |
42 | QString MBOXPath; | 42 | QString MBOXPath; |
43 | QString MBOXName; | 43 | QString MBOXName; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | #endif | 46 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index 5eae31f..12472e9 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -30,195 +30,195 @@ void MHwrapper::init_storage() | |||
30 | int r; | 30 | int r; |
31 | QString pre = MHPath; | 31 | QString pre = MHPath; |
32 | if (!m_storage) { | 32 | if (!m_storage) { |
33 | m_storage = mailstorage_new(NULL); | 33 | m_storage = mailstorage_new(NULL); |
34 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 34 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
35 | if (r != MAIL_NO_ERROR) { | 35 | if (r != MAIL_NO_ERROR) { |
36 | qDebug("error initializing storage"); | 36 | qDebug("error initializing storage"); |
37 | mailstorage_free(m_storage); | 37 | mailstorage_free(m_storage); |
38 | m_storage = 0; | 38 | m_storage = 0; |
39 | return; | 39 | return; |
40 | } | 40 | } |
41 | } | 41 | } |
42 | r = mailstorage_connect(m_storage); | 42 | r = mailstorage_connect(m_storage); |
43 | if (r!=MAIL_NO_ERROR) { | 43 | if (r!=MAIL_NO_ERROR) { |
44 | qDebug("error connecting storage"); | 44 | qDebug("error connecting storage"); |
45 | mailstorage_free(m_storage); | 45 | mailstorage_free(m_storage); |
46 | m_storage = 0; | 46 | m_storage = 0; |
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | void MHwrapper::clean_storage() | 50 | void MHwrapper::clean_storage() |
51 | { | 51 | { |
52 | if (m_storage) { | 52 | if (m_storage) { |
53 | mailstorage_disconnect(m_storage); | 53 | mailstorage_disconnect(m_storage); |
54 | mailstorage_free(m_storage); | 54 | mailstorage_free(m_storage); |
55 | m_storage = 0; | 55 | m_storage = 0; |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | MHwrapper::~MHwrapper() | 59 | MHwrapper::~MHwrapper() |
60 | { | 60 | { |
61 | clean_storage(); | 61 | clean_storage(); |
62 | } | 62 | } |
63 | 63 | ||
64 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 64 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
65 | { | 65 | { |
66 | init_storage(); | 66 | init_storage(); |
67 | if (!m_storage) { | 67 | if (!m_storage) { |
68 | return; | 68 | return; |
69 | } | 69 | } |
70 | QString f = buildPath(mailbox); | 70 | QString f = buildPath(mailbox); |
71 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 71 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
72 | if (r!=MAIL_NO_ERROR) { | 72 | if (r!=MAIL_NO_ERROR) { |
73 | qDebug("listMessages: error selecting folder!"); | 73 | qDebug("listMessages: error selecting folder!"); |
74 | return; | 74 | return; |
75 | } | 75 | } |
76 | parseList(target,m_storage->sto_session,f); | 76 | parseList(target,m_storage->sto_session,f); |
77 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 77 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
78 | } | 78 | } |
79 | 79 | ||
80 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 80 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
81 | { | 81 | { |
82 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 82 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
83 | /* this is needed! */ | 83 | /* this is needed! */ |
84 | if (m_storage) mailstorage_disconnect(m_storage); | 84 | if (m_storage) mailstorage_disconnect(m_storage); |
85 | init_storage(); | 85 | init_storage(); |
86 | if (!m_storage) { | 86 | if (!m_storage) { |
87 | return folders; | 87 | return folders; |
88 | } | 88 | } |
89 | mail_list*flist = 0; | 89 | mail_list*flist = 0; |
90 | clistcell*current=0; | 90 | clistcell*current=0; |
91 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 91 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
92 | if (r != MAIL_NO_ERROR || !flist) { | 92 | if (r != MAIL_NO_ERROR || !flist) { |
93 | qDebug("error getting folder list"); | 93 | qDebug("error getting folder list"); |
94 | return folders; | 94 | return folders; |
95 | } | 95 | } |
96 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 96 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
97 | QString t = (char*)current->data; | 97 | QString t = (char*)current->data; |
98 | t.replace(0,MHPath.length(),""); | 98 | t.replace(0,MHPath.length(),""); |
99 | folders->append(new MHFolder(t,MHPath)); | 99 | folders->append(new MHFolder(t,MHPath)); |
100 | } | 100 | } |
101 | mail_list_free(flist); | 101 | mail_list_free(flist); |
102 | return folders; | 102 | return folders; |
103 | } | 103 | } |
104 | 104 | ||
105 | void MHwrapper::deleteMail(const RecMailP&mail) | 105 | void MHwrapper::deleteMail(const RecMailP&mail) |
106 | { | 106 | { |
107 | init_storage(); | 107 | init_storage(); |
108 | if (!m_storage) { | 108 | if (!m_storage) { |
109 | return; | 109 | return; |
110 | } | 110 | } |
111 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 111 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
112 | if (r!=MAIL_NO_ERROR) { | 112 | if (r!=MAIL_NO_ERROR) { |
113 | qDebug("error selecting folder!"); | 113 | qDebug("error selecting folder!"); |
114 | return; | 114 | return; |
115 | } | 115 | } |
116 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); | 116 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); |
117 | if (r != MAIL_NO_ERROR) { | 117 | if (r != MAIL_NO_ERROR) { |
118 | qDebug("error deleting mail"); | 118 | qDebug("error deleting mail"); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | void MHwrapper::answeredMail(const RecMailP&) | 122 | void MHwrapper::answeredMail(const RecMailP&) |
123 | { | 123 | { |
124 | } | 124 | } |
125 | 125 | ||
126 | RecBody MHwrapper::fetchBody( const RecMailP &mail ) | 126 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) |
127 | { | 127 | { |
128 | RecBody body; | 128 | RecBodyP body = new RecBody(); |
129 | init_storage(); | 129 | init_storage(); |
130 | if (!m_storage) { | 130 | if (!m_storage) { |
131 | return body; | 131 | return body; |
132 | } | 132 | } |
133 | mailmessage * msg; | 133 | mailmessage * msg; |
134 | char*data=0; | 134 | char*data=0; |
135 | 135 | ||
136 | /* mail should hold the complete path! */ | 136 | /* mail should hold the complete path! */ |
137 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 137 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
138 | if (r != MAIL_NO_ERROR) { | 138 | if (r != MAIL_NO_ERROR) { |
139 | return body; | 139 | return body; |
140 | } | 140 | } |
141 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 141 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
142 | if (r != MAIL_NO_ERROR) { | 142 | if (r != MAIL_NO_ERROR) { |
143 | qDebug("Error fetching mail %i",mail->getNumber()); | 143 | qDebug("Error fetching mail %i",mail->getNumber()); |
144 | return body; | 144 | return body; |
145 | } | 145 | } |
146 | body = parseMail(msg); | 146 | body = parseMail(msg); |
147 | mailmessage_fetch_result_free(msg,data); | 147 | mailmessage_fetch_result_free(msg,data); |
148 | return body; | 148 | return body; |
149 | } | 149 | } |
150 | 150 | ||
151 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 151 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
152 | { | 152 | { |
153 | qDebug("MH %i von %i",current,maximum); | 153 | qDebug("MH %i von %i",current,maximum); |
154 | } | 154 | } |
155 | 155 | ||
156 | QString MHwrapper::buildPath(const QString&p) | 156 | QString MHwrapper::buildPath(const QString&p) |
157 | { | 157 | { |
158 | QString f=""; | 158 | QString f=""; |
159 | if (p.length()==0||p=="/") | 159 | if (p.length()==0||p=="/") |
160 | return MHPath; | 160 | return MHPath; |
161 | if (!p.startsWith(MHPath)) { | 161 | if (!p.startsWith(MHPath)) { |
162 | f+=MHPath; | 162 | f+=MHPath; |
163 | } | 163 | } |
164 | if (!p.startsWith("/")) { | 164 | if (!p.startsWith("/")) { |
165 | f+="/"; | 165 | f+="/"; |
166 | } | 166 | } |
167 | f+=p; | 167 | f+=p; |
168 | return f; | 168 | return f; |
169 | } | 169 | } |
170 | 170 | ||
171 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) | 171 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) |
172 | { | 172 | { |
173 | init_storage(); | 173 | init_storage(); |
174 | if (!m_storage) { | 174 | if (!m_storage) { |
175 | return 0; | 175 | return 0; |
176 | } | 176 | } |
177 | QString f; | 177 | QString f; |
178 | if (!pfolder) { | 178 | if (!pfolder) { |
179 | // toplevel folder | 179 | // toplevel folder |
180 | f = buildPath(folder); | 180 | f = buildPath(folder); |
181 | } else { | 181 | } else { |
182 | f = pfolder->getName(); | 182 | f = pfolder->getName(); |
183 | f+="/"; | 183 | f+="/"; |
184 | f+=folder; | 184 | f+=folder; |
185 | } | 185 | } |
186 | qDebug(f); | 186 | qDebug(f); |
187 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); | 187 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); |
188 | if (r != MAIL_NO_ERROR) { | 188 | if (r != MAIL_NO_ERROR) { |
189 | qDebug("error creating folder %i",r); | 189 | qDebug("error creating folder %i",r); |
190 | return 0; | 190 | return 0; |
191 | } | 191 | } |
192 | qDebug("Folder created"); | 192 | qDebug("Folder created"); |
193 | return 1; | 193 | return 1; |
194 | } | 194 | } |
195 | 195 | ||
196 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) | 196 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) |
197 | { | 197 | { |
198 | init_storage(); | 198 | init_storage(); |
199 | if (!m_storage) { | 199 | if (!m_storage) { |
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | QString f = buildPath(Folder); | 202 | QString f = buildPath(Folder); |
203 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 203 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
204 | if (r!=MAIL_NO_ERROR) { | 204 | if (r!=MAIL_NO_ERROR) { |
205 | qDebug("error selecting folder!"); | 205 | qDebug("error selecting folder!"); |
206 | return; | 206 | return; |
207 | } | 207 | } |
208 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); | 208 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); |
209 | if (r!=MAIL_NO_ERROR) { | 209 | if (r!=MAIL_NO_ERROR) { |
210 | qDebug("error storing mail"); | 210 | qDebug("error storing mail"); |
211 | } | 211 | } |
212 | return; | 212 | return; |
213 | } | 213 | } |
214 | 214 | ||
215 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) | 215 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) |
216 | { | 216 | { |
217 | encodedString*result = 0; | 217 | encodedString*result = 0; |
218 | init_storage(); | 218 | init_storage(); |
219 | if (!m_storage) { | 219 | if (!m_storage) { |
220 | return result; | 220 | return result; |
221 | } | 221 | } |
222 | mailmessage * msg = 0; | 222 | mailmessage * msg = 0; |
223 | char*data=0; | 223 | char*data=0; |
224 | size_t size; | 224 | size_t size; |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h index 0846ec3..4310c84 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.h +++ b/noncore/net/mail/libmailwrapper/mhwrapper.h | |||
@@ -1,60 +1,60 @@ | |||
1 | #ifndef __MH_WRAPPER_H | 1 | #ifndef __MH_WRAPPER_H |
2 | #define __MH_WRAPPER_H | 2 | #define __MH_WRAPPER_H |
3 | 3 | ||
4 | #include "maildefines.h" | 4 | #include "maildefines.h" |
5 | 5 | ||
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 mailmbox_folder; | 10 | struct mailmbox_folder; |
11 | namespace Opie {namespace Core {class OProcess;}} | 11 | namespace Opie {namespace Core {class OProcess;}} |
12 | 12 | ||
13 | class MHwrapper : public Genericwrapper | 13 | class MHwrapper : public Genericwrapper |
14 | { | 14 | { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | public: | 16 | public: |
17 | MHwrapper(const QString & dir,const QString&name); | 17 | MHwrapper(const QString & dir,const QString&name); |
18 | virtual ~MHwrapper(); | 18 | virtual ~MHwrapper(); |
19 | 19 | ||
20 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); | 20 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); |
21 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 21 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
23 | 23 | ||
24 | virtual void deleteMail(const RecMailP&mail); | 24 | virtual void deleteMail(const RecMailP&mail); |
25 | virtual void answeredMail(const RecMailP&mail); | 25 | virtual void answeredMail(const RecMailP&mail); |
26 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 26 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
27 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 27 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
28 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 28 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
29 | 29 | ||
30 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, | 30 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, |
31 | const QString&d="",bool s=false); | 31 | const QString&d="",bool s=false); |
32 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); | 32 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); |
33 | 33 | ||
34 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 34 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
35 | 35 | ||
36 | virtual RecBody fetchBody( const RecMailP &mail ); | 36 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
37 | static void mbox_progress( size_t current, size_t maximum ); | 37 | static void mbox_progress( size_t current, size_t maximum ); |
38 | 38 | ||
39 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 39 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
40 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); | 40 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); |
41 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 41 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
42 | virtual MAILLIB::ATYPE getType()const; | 42 | virtual MAILLIB::ATYPE getType()const; |
43 | virtual const QString&getName()const; | 43 | virtual const QString&getName()const; |
44 | 44 | ||
45 | public slots: | 45 | public slots: |
46 | /* for deleting maildirs we are using a system call */ | 46 | /* for deleting maildirs we are using a system call */ |
47 | virtual void oprocessStderr(Opie::Core::OProcess*, char *buffer, int ); | 47 | virtual void oprocessStderr(Opie::Core::OProcess*, char *buffer, int ); |
48 | virtual void processEnded(Opie::Core::OProcess *); | 48 | virtual void processEnded(Opie::Core::OProcess *); |
49 | protected: | 49 | protected: |
50 | QString buildPath(const QString&p); | 50 | QString buildPath(const QString&p); |
51 | QString MHPath; | 51 | QString MHPath; |
52 | QString MHName; | 52 | QString MHName; |
53 | 53 | ||
54 | void init_storage(); | 54 | void init_storage(); |
55 | void clean_storage(); | 55 | void clean_storage(); |
56 | 56 | ||
57 | bool removeMboxfailed; | 57 | bool removeMboxfailed; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | #endif | 60 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index 9de958d..cc36f32 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -1,142 +1,142 @@ | |||
1 | #include "nntpwrapper.h" | 1 | #include "nntpwrapper.h" |
2 | #include "logindialog.h" | 2 | #include "logindialog.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | 4 | ||
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | 6 | ||
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | 8 | ||
9 | #include <libetpan/libetpan.h> | 9 | #include <libetpan/libetpan.h> |
10 | 10 | ||
11 | 11 | ||
12 | #define HARD_MSG_SIZE_LIMIT 5242880 | 12 | #define HARD_MSG_SIZE_LIMIT 5242880 |
13 | 13 | ||
14 | using namespace Opie::Core; | 14 | using namespace Opie::Core; |
15 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) | 15 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) |
16 | : Genericwrapper() { | 16 | : Genericwrapper() { |
17 | account = a; | 17 | account = a; |
18 | m_nntp = NULL; | 18 | m_nntp = NULL; |
19 | msgTempName = a->getFileName()+"_msg_cache"; | 19 | msgTempName = a->getFileName()+"_msg_cache"; |
20 | last_msg_id = 0; | 20 | last_msg_id = 0; |
21 | } | 21 | } |
22 | 22 | ||
23 | NNTPwrapper::~NNTPwrapper() { | 23 | NNTPwrapper::~NNTPwrapper() { |
24 | logout(); | 24 | logout(); |
25 | QFile msg_cache(msgTempName); | 25 | QFile msg_cache(msgTempName); |
26 | if (msg_cache.exists()) { | 26 | if (msg_cache.exists()) { |
27 | msg_cache.remove(); | 27 | msg_cache.remove(); |
28 | } | 28 | } |
29 | } | 29 | } |
30 | 30 | ||
31 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { | 31 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { |
32 | qDebug( "NNTP: %i of %i", current, maximum ); | 32 | qDebug( "NNTP: %i of %i", current, maximum ); |
33 | } | 33 | } |
34 | 34 | ||
35 | 35 | ||
36 | RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) { | 36 | RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { |
37 | int err = NEWSNNTP_NO_ERROR; | 37 | int err = NEWSNNTP_NO_ERROR; |
38 | char *message = 0; | 38 | char *message = 0; |
39 | size_t length = 0; | 39 | size_t length = 0; |
40 | 40 | ||
41 | RecBodyP body = new RecBody(); | ||
41 | login(); | 42 | login(); |
42 | if ( !m_nntp ) { | 43 | if ( !m_nntp ) { |
43 | return RecBody(); | 44 | return body; |
44 | } | 45 | } |
45 | 46 | ||
46 | RecBody body; | ||
47 | mailmessage * mailmsg; | 47 | mailmessage * mailmsg; |
48 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 48 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { |
49 | qDebug("Message to large: %i",mail->Msgsize()); | 49 | qDebug("Message to large: %i",mail->Msgsize()); |
50 | return body; | 50 | return body; |
51 | } | 51 | } |
52 | 52 | ||
53 | QFile msg_cache(msgTempName); | 53 | QFile msg_cache(msgTempName); |
54 | 54 | ||
55 | cleanMimeCache(); | 55 | cleanMimeCache(); |
56 | 56 | ||
57 | if (mail->getNumber()!=last_msg_id) { | 57 | if (mail->getNumber()!=last_msg_id) { |
58 | if (msg_cache.exists()) { | 58 | if (msg_cache.exists()) { |
59 | msg_cache.remove(); | 59 | msg_cache.remove(); |
60 | } | 60 | } |
61 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 61 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
62 | last_msg_id = mail->getNumber(); | 62 | last_msg_id = mail->getNumber(); |
63 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); | 63 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); |
64 | err = mailmessage_fetch(mailmsg,&message,&length); | 64 | err = mailmessage_fetch(mailmsg,&message,&length); |
65 | msg_cache.writeBlock(message,length); | 65 | msg_cache.writeBlock(message,length); |
66 | } else { | 66 | } else { |
67 | QString msg=""; | 67 | QString msg=""; |
68 | msg_cache.open(IO_ReadOnly); | 68 | msg_cache.open(IO_ReadOnly); |
69 | message = new char[4096]; | 69 | message = new char[4096]; |
70 | memset(message,0,4096); | 70 | memset(message,0,4096); |
71 | while (msg_cache.readBlock(message,4095)>0) { | 71 | while (msg_cache.readBlock(message,4095)>0) { |
72 | msg+=message; | 72 | msg+=message; |
73 | memset(message,0,4096); | 73 | memset(message,0,4096); |
74 | } | 74 | } |
75 | delete message; | 75 | delete message; |
76 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 76 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
77 | memset(message,0,msg.length()+1); | 77 | memset(message,0,msg.length()+1); |
78 | memcpy(message,msg.latin1(),msg.length()); | 78 | memcpy(message,msg.latin1(),msg.length()); |
79 | /* transform to libetpan stuff */ | 79 | /* transform to libetpan stuff */ |
80 | mailmsg = mailmessage_new(); | 80 | mailmsg = mailmessage_new(); |
81 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 81 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
82 | generic_message_t * msg_data; | 82 | generic_message_t * msg_data; |
83 | msg_data = (generic_message_t *)mailmsg->msg_data; | 83 | msg_data = (generic_message_t *)mailmsg->msg_data; |
84 | msg_data->msg_fetched = 1; | 84 | msg_data->msg_fetched = 1; |
85 | msg_data->msg_message = message; | 85 | msg_data->msg_message = message; |
86 | msg_data->msg_length = strlen(message); | 86 | msg_data->msg_length = strlen(message); |
87 | } | 87 | } |
88 | body = parseMail(mailmsg); | 88 | body = parseMail(mailmsg); |
89 | 89 | ||
90 | /* clean up */ | 90 | /* clean up */ |
91 | if (mailmsg) | 91 | if (mailmsg) |
92 | mailmessage_free(mailmsg); | 92 | mailmessage_free(mailmsg); |
93 | if (message) | 93 | if (message) |
94 | free(message); | 94 | free(message); |
95 | 95 | ||
96 | return body; | 96 | return body; |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 100 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
101 | { | 101 | { |
102 | login(); | 102 | login(); |
103 | if (!m_nntp) | 103 | if (!m_nntp) |
104 | return; | 104 | return; |
105 | uint32_t res_messages,res_recent,res_unseen; | 105 | uint32_t res_messages,res_recent,res_unseen; |
106 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); | 106 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); |
107 | parseList(target,m_nntp->sto_session,which,true); | 107 | parseList(target,m_nntp->sto_session,which,true); |
108 | } | 108 | } |
109 | 109 | ||
110 | void NNTPwrapper::login() | 110 | void NNTPwrapper::login() |
111 | { | 111 | { |
112 | if (account->getOffline()) | 112 | if (account->getOffline()) |
113 | return; | 113 | return; |
114 | /* we'll hold the line */ | 114 | /* we'll hold the line */ |
115 | if ( m_nntp != NULL ) | 115 | if ( m_nntp != NULL ) |
116 | return; | 116 | return; |
117 | 117 | ||
118 | const char *server, *user, *pass; | 118 | const char *server, *user, *pass; |
119 | QString User,Pass; | 119 | QString User,Pass; |
120 | uint16_t port; | 120 | uint16_t port; |
121 | int err = NEWSNNTP_NO_ERROR; | 121 | int err = NEWSNNTP_NO_ERROR; |
122 | 122 | ||
123 | server = account->getServer().latin1(); | 123 | server = account->getServer().latin1(); |
124 | port = account->getPort().toUInt(); | 124 | port = account->getPort().toUInt(); |
125 | 125 | ||
126 | user = pass = 0; | 126 | user = pass = 0; |
127 | 127 | ||
128 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { | 128 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { |
129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
130 | login.show(); | 130 | login.show(); |
131 | if ( QDialog::Accepted == login.exec() ) { | 131 | if ( QDialog::Accepted == login.exec() ) { |
132 | // ok | 132 | // ok |
133 | User = login.getUser().latin1(); | 133 | User = login.getUser().latin1(); |
134 | Pass = login.getPassword().latin1(); | 134 | Pass = login.getPassword().latin1(); |
135 | } else { | 135 | } else { |
136 | // cancel | 136 | // cancel |
137 | qDebug( "NNTP: Login canceled" ); | 137 | qDebug( "NNTP: Login canceled" ); |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | } else { | 140 | } else { |
141 | User = account->getUser().latin1(); | 141 | User = account->getUser().latin1(); |
142 | Pass = account->getPassword().latin1(); | 142 | Pass = account->getPassword().latin1(); |
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h index a87a8e8..2fb82f2 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.h +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h | |||
@@ -1,48 +1,48 @@ | |||
1 | #ifndef __NNTPWRAPPER | 1 | #ifndef __NNTPWRAPPER |
2 | #define __NNTPWRAPPER | 2 | #define __NNTPWRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.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 NNTPwrapper : public Genericwrapper | 13 | class NNTPwrapper : public Genericwrapper |
14 | { | 14 | { |
15 | 15 | ||
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | 17 | ||
18 | public: | 18 | public: |
19 | NNTPwrapper( NNTPaccount *a ); | 19 | NNTPwrapper( NNTPaccount *a ); |
20 | virtual ~NNTPwrapper(); | 20 | virtual ~NNTPwrapper(); |
21 | 21 | ||
22 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
23 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); | 23 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); |
24 | /* should only get the subscribed one */ | 24 | /* should only get the subscribed one */ |
25 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 25 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
26 | /* mailbox will be ignored */ | 26 | /* mailbox will be ignored */ |
27 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 27 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
28 | QStringList listAllNewsgroups(const QString&mask = QString::null); | 28 | QStringList listAllNewsgroups(const QString&mask = QString::null); |
29 | virtual void deleteMail(const RecMailP&mail); | 29 | virtual void deleteMail(const RecMailP&mail); |
30 | virtual void answeredMail(const RecMailP&mail); | 30 | virtual void answeredMail(const RecMailP&mail); |
31 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 31 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
32 | 32 | ||
33 | virtual RecBody fetchBody( const RecMailP &mail ); | 33 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
34 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 34 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
35 | virtual void logout(); | 35 | virtual void logout(); |
36 | virtual MAILLIB::ATYPE getType()const; | 36 | virtual MAILLIB::ATYPE getType()const; |
37 | virtual const QString&getName()const; | 37 | virtual const QString&getName()const; |
38 | static void nntp_progress( size_t current, size_t maximum ); | 38 | static void nntp_progress( size_t current, size_t maximum ); |
39 | 39 | ||
40 | protected: | 40 | protected: |
41 | void login(); | 41 | void login(); |
42 | NNTPaccount *account; | 42 | NNTPaccount *account; |
43 | mailstorage* m_nntp; | 43 | mailstorage* m_nntp; |
44 | 44 | ||
45 | 45 | ||
46 | }; | 46 | }; |
47 | 47 | ||
48 | #endif | 48 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index f5694fe..1b7a1b4 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,140 +1,141 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | //#include <qstring.h> | 8 | //#include <qstring.h> |
9 | 9 | ||
10 | /* we don't fetch messages larger than 5 MB */ | 10 | /* we don't fetch messages larger than 5 MB */ |
11 | #define HARD_MSG_SIZE_LIMIT 5242880 | 11 | #define HARD_MSG_SIZE_LIMIT 5242880 |
12 | 12 | ||
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | POP3wrapper::POP3wrapper( POP3account *a ) | 14 | POP3wrapper::POP3wrapper( POP3account *a ) |
15 | : Genericwrapper() { | 15 | : Genericwrapper() { |
16 | account = a; | 16 | account = a; |
17 | m_pop3 = NULL; | 17 | m_pop3 = NULL; |
18 | msgTempName = a->getFileName()+"_msg_cache"; | 18 | msgTempName = a->getFileName()+"_msg_cache"; |
19 | last_msg_id = 0; | 19 | last_msg_id = 0; |
20 | } | 20 | } |
21 | 21 | ||
22 | POP3wrapper::~POP3wrapper() { | 22 | POP3wrapper::~POP3wrapper() { |
23 | logout(); | 23 | logout(); |
24 | QFile msg_cache(msgTempName); | 24 | QFile msg_cache(msgTempName); |
25 | if (msg_cache.exists()) { | 25 | if (msg_cache.exists()) { |
26 | msg_cache.remove(); | 26 | msg_cache.remove(); |
27 | } | 27 | } |
28 | } | 28 | } |
29 | 29 | ||
30 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { | 30 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { |
31 | qDebug( "POP3: %i of %i", current, maximum ); | 31 | qDebug( "POP3: %i of %i", current, maximum ); |
32 | } | 32 | } |
33 | 33 | ||
34 | RecBody POP3wrapper::fetchBody( const RecMailP &mail ) { | 34 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { |
35 | int err = MAILPOP3_NO_ERROR; | 35 | int err = MAILPOP3_NO_ERROR; |
36 | char *message = 0; | 36 | char *message = 0; |
37 | size_t length = 0; | 37 | size_t length = 0; |
38 | 38 | ||
39 | RecBodyP body = new RecBody(); | ||
40 | |||
39 | login(); | 41 | login(); |
40 | if ( !m_pop3 ) { | 42 | if ( !m_pop3 ) { |
41 | return RecBody(); | 43 | return body; |
42 | } | 44 | } |
43 | 45 | ||
44 | RecBody body; | ||
45 | mailmessage * mailmsg; | 46 | mailmessage * mailmsg; |
46 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 47 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { |
47 | qDebug("Message to large: %i",mail->Msgsize()); | 48 | qDebug("Message to large: %i",mail->Msgsize()); |
48 | return body; | 49 | return body; |
49 | } | 50 | } |
50 | 51 | ||
51 | QFile msg_cache(msgTempName); | 52 | QFile msg_cache(msgTempName); |
52 | 53 | ||
53 | cleanMimeCache(); | 54 | cleanMimeCache(); |
54 | 55 | ||
55 | if (mail->getNumber()!=last_msg_id) { | 56 | if (mail->getNumber()!=last_msg_id) { |
56 | if (msg_cache.exists()) { | 57 | if (msg_cache.exists()) { |
57 | msg_cache.remove(); | 58 | msg_cache.remove(); |
58 | } | 59 | } |
59 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 60 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
60 | last_msg_id = mail->getNumber(); | 61 | last_msg_id = mail->getNumber(); |
61 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); | 62 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
62 | err = mailmessage_fetch(mailmsg,&message,&length); | 63 | err = mailmessage_fetch(mailmsg,&message,&length); |
63 | msg_cache.writeBlock(message,length); | 64 | msg_cache.writeBlock(message,length); |
64 | } else { | 65 | } else { |
65 | QString msg=""; | 66 | QString msg=""; |
66 | msg_cache.open(IO_ReadOnly); | 67 | msg_cache.open(IO_ReadOnly); |
67 | message = new char[4096]; | 68 | message = new char[4096]; |
68 | memset(message,0,4096); | 69 | memset(message,0,4096); |
69 | while (msg_cache.readBlock(message,4095)>0) { | 70 | while (msg_cache.readBlock(message,4095)>0) { |
70 | msg+=message; | 71 | msg+=message; |
71 | memset(message,0,4096); | 72 | memset(message,0,4096); |
72 | } | 73 | } |
73 | delete message; | 74 | delete message; |
74 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 75 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
75 | memset(message,0,msg.length()+1); | 76 | memset(message,0,msg.length()+1); |
76 | memcpy(message,msg.latin1(),msg.length()); | 77 | memcpy(message,msg.latin1(),msg.length()); |
77 | /* transform to libetpan stuff */ | 78 | /* transform to libetpan stuff */ |
78 | mailmsg = mailmessage_new(); | 79 | mailmsg = mailmessage_new(); |
79 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 80 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
80 | generic_message_t * msg_data; | 81 | generic_message_t * msg_data; |
81 | msg_data = (generic_message_t *)mailmsg->msg_data; | 82 | msg_data = (generic_message_t *)mailmsg->msg_data; |
82 | msg_data->msg_fetched = 1; | 83 | msg_data->msg_fetched = 1; |
83 | msg_data->msg_message = message; | 84 | msg_data->msg_message = message; |
84 | msg_data->msg_length = strlen(message); | 85 | msg_data->msg_length = strlen(message); |
85 | } | 86 | } |
86 | body = parseMail(mailmsg); | 87 | body = parseMail(mailmsg); |
87 | 88 | ||
88 | /* clean up */ | 89 | /* clean up */ |
89 | if (mailmsg) | 90 | if (mailmsg) |
90 | mailmessage_free(mailmsg); | 91 | mailmessage_free(mailmsg); |
91 | if (message) | 92 | if (message) |
92 | free(message); | 93 | free(message); |
93 | 94 | ||
94 | return body; | 95 | return body; |
95 | } | 96 | } |
96 | 97 | ||
97 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 98 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
98 | { | 99 | { |
99 | login(); | 100 | login(); |
100 | if (!m_pop3) | 101 | if (!m_pop3) |
101 | return; | 102 | return; |
102 | uint32_t res_messages,res_recent,res_unseen; | 103 | uint32_t res_messages,res_recent,res_unseen; |
103 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 104 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
104 | parseList(target,m_pop3->sto_session,"INBOX"); | 105 | parseList(target,m_pop3->sto_session,"INBOX"); |
105 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 106 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); |
106 | } | 107 | } |
107 | 108 | ||
108 | void POP3wrapper::login() | 109 | void POP3wrapper::login() |
109 | { | 110 | { |
110 | if (account->getOffline()) | 111 | if (account->getOffline()) |
111 | return; | 112 | return; |
112 | /* we'll hold the line */ | 113 | /* we'll hold the line */ |
113 | if ( m_pop3 != NULL ) | 114 | if ( m_pop3 != NULL ) |
114 | return; | 115 | return; |
115 | 116 | ||
116 | const char *server, *user, *pass; | 117 | const char *server, *user, *pass; |
117 | uint16_t port; | 118 | uint16_t port; |
118 | int err = MAILPOP3_NO_ERROR; | 119 | int err = MAILPOP3_NO_ERROR; |
119 | 120 | ||
120 | server = account->getServer().latin1(); | 121 | server = account->getServer().latin1(); |
121 | port = account->getPort().toUInt(); | 122 | port = account->getPort().toUInt(); |
122 | 123 | ||
123 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 124 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
124 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 125 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
125 | login.show(); | 126 | login.show(); |
126 | if ( QDialog::Accepted == login.exec() ) { | 127 | if ( QDialog::Accepted == login.exec() ) { |
127 | // ok | 128 | // ok |
128 | user = login.getUser().latin1(); | 129 | user = login.getUser().latin1(); |
129 | pass = login.getPassword().latin1(); | 130 | pass = login.getPassword().latin1(); |
130 | } else { | 131 | } else { |
131 | // cancel | 132 | // cancel |
132 | qDebug( "POP3: Login canceled" ); | 133 | qDebug( "POP3: Login canceled" ); |
133 | return; | 134 | return; |
134 | } | 135 | } |
135 | } else { | 136 | } else { |
136 | user = account->getUser().latin1(); | 137 | user = account->getUser().latin1(); |
137 | pass = account->getPassword().latin1(); | 138 | pass = account->getPassword().latin1(); |
138 | } | 139 | } |
139 | 140 | ||
140 | // bool ssl = account->getSSL(); | 141 | // bool ssl = account->getSSL(); |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index c46b941..5101fa5 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -1,42 +1,42 @@ | |||
1 | #ifndef __POP3WRAPPER | 1 | #ifndef __POP3WRAPPER |
2 | #define __POP3WRAPPER | 2 | #define __POP3WRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
8 | class encodedString; | 8 | class encodedString; |
9 | struct mailstorage; | 9 | struct mailstorage; |
10 | struct mailfolder; | 10 | struct mailfolder; |
11 | 11 | ||
12 | class POP3wrapper : public Genericwrapper | 12 | class POP3wrapper : public Genericwrapper |
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | 15 | ||
16 | public: | 16 | public: |
17 | POP3wrapper( POP3account *a ); | 17 | POP3wrapper( POP3account *a ); |
18 | virtual ~POP3wrapper(); | 18 | virtual ~POP3wrapper(); |
19 | /* mailbox will be ignored */ | 19 | /* mailbox will be ignored */ |
20 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); | 20 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); |
21 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 21 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
22 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
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 int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 27 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
28 | 28 | ||
29 | virtual RecBody fetchBody( const RecMailP &mail ); | 29 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
30 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 30 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
31 | virtual void logout(); | 31 | virtual void logout(); |
32 | virtual MAILLIB::ATYPE getType()const; | 32 | virtual MAILLIB::ATYPE getType()const; |
33 | virtual const QString&getName()const; | 33 | virtual const QString&getName()const; |
34 | static void pop3_progress( size_t current, size_t maximum ); | 34 | static void pop3_progress( size_t current, size_t maximum ); |
35 | 35 | ||
36 | protected: | 36 | protected: |
37 | void login(); | 37 | void login(); |
38 | POP3account *account; | 38 | POP3account *account; |
39 | mailstorage*m_pop3; | 39 | mailstorage*m_pop3; |
40 | }; | 40 | }; |
41 | 41 | ||
42 | #endif | 42 | #endif |
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index dd305df..5da2161 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -53,193 +53,193 @@ void OpieMail::slotwriteMail(const QString&name,const QString&email) | |||
53 | if (!email.isEmpty()) | 53 | if (!email.isEmpty()) |
54 | { | 54 | { |
55 | if (!name.isEmpty()) | 55 | if (!name.isEmpty()) |
56 | { | 56 | { |
57 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 57 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
58 | } | 58 | } |
59 | else | 59 | else |
60 | { | 60 | { |
61 | compose.setTo(email); | 61 | compose.setTo(email); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | compose.slotAdjustColumns(); | 64 | compose.slotAdjustColumns(); |
65 | QPEApplication::execDialog( &compose ); | 65 | QPEApplication::execDialog( &compose ); |
66 | } | 66 | } |
67 | 67 | ||
68 | void OpieMail::slotComposeMail() | 68 | void OpieMail::slotComposeMail() |
69 | { | 69 | { |
70 | qDebug( "Compose Mail" ); | 70 | qDebug( "Compose Mail" ); |
71 | slotwriteMail(0l,0l); | 71 | slotwriteMail(0l,0l); |
72 | } | 72 | } |
73 | 73 | ||
74 | void OpieMail::slotSendQueued() | 74 | void OpieMail::slotSendQueued() |
75 | { | 75 | { |
76 | qDebug( "Send Queued" ); | 76 | qDebug( "Send Queued" ); |
77 | SMTPaccount *smtp = 0; | 77 | SMTPaccount *smtp = 0; |
78 | 78 | ||
79 | QList<Account> list = settings->getAccounts(); | 79 | QList<Account> list = settings->getAccounts(); |
80 | QList<SMTPaccount> smtpList; | 80 | QList<SMTPaccount> smtpList; |
81 | smtpList.setAutoDelete(false); | 81 | smtpList.setAutoDelete(false); |
82 | Account *it; | 82 | Account *it; |
83 | for ( it = list.first(); it; it = list.next() ) | 83 | for ( it = list.first(); it; it = list.next() ) |
84 | { | 84 | { |
85 | if ( it->getType() == MAILLIB::A_SMTP ) | 85 | if ( it->getType() == MAILLIB::A_SMTP ) |
86 | { | 86 | { |
87 | smtp = static_cast<SMTPaccount *>(it); | 87 | smtp = static_cast<SMTPaccount *>(it); |
88 | smtpList.append(smtp); | 88 | smtpList.append(smtp); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | if (smtpList.count()==0) | 91 | if (smtpList.count()==0) |
92 | { | 92 | { |
93 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); | 93 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); |
94 | return; | 94 | return; |
95 | } | 95 | } |
96 | if (smtpList.count()==1) | 96 | if (smtpList.count()==1) |
97 | { | 97 | { |
98 | smtp = smtpList.at(0); | 98 | smtp = smtpList.at(0); |
99 | } | 99 | } |
100 | else | 100 | else |
101 | { | 101 | { |
102 | smtp = 0; | 102 | smtp = 0; |
103 | selectsmtp selsmtp; | 103 | selectsmtp selsmtp; |
104 | selsmtp.setSelectionlist(&smtpList); | 104 | selsmtp.setSelectionlist(&smtpList); |
105 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) | 105 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) |
106 | { | 106 | { |
107 | smtp = selsmtp.selected_smtp(); | 107 | smtp = selsmtp.selected_smtp(); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | if (smtp) | 110 | if (smtp) |
111 | { | 111 | { |
112 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 112 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
113 | if ( wrap->flushOutbox() ) | 113 | if ( wrap->flushOutbox() ) |
114 | { | 114 | { |
115 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); | 115 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); |
116 | } | 116 | } |
117 | delete wrap; | 117 | delete wrap; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | void OpieMail::slotSearchMails() | 121 | void OpieMail::slotSearchMails() |
122 | { | 122 | { |
123 | qDebug( "Search Mails" ); | 123 | qDebug( "Search Mails" ); |
124 | } | 124 | } |
125 | 125 | ||
126 | void OpieMail::slotEditSettings() | 126 | void OpieMail::slotEditSettings() |
127 | { | 127 | { |
128 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); | 128 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); |
129 | QPEApplication::execDialog( &settingsDialog ); | 129 | QPEApplication::execDialog( &settingsDialog ); |
130 | } | 130 | } |
131 | 131 | ||
132 | void OpieMail::slotEditAccounts() | 132 | void OpieMail::slotEditAccounts() |
133 | { | 133 | { |
134 | qDebug( "Edit Accounts" ); | 134 | qDebug( "Edit Accounts" ); |
135 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); | 135 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); |
136 | eaDialog.slotAdjustColumns(); | 136 | eaDialog.slotAdjustColumns(); |
137 | QPEApplication::execDialog( &eaDialog ); | 137 | QPEApplication::execDialog( &eaDialog ); |
138 | if ( settings ) delete settings; | 138 | if ( settings ) delete settings; |
139 | settings = new Settings(); | 139 | settings = new Settings(); |
140 | 140 | ||
141 | folderView->populate( settings->getAccounts() ); | 141 | folderView->populate( settings->getAccounts() ); |
142 | } | 142 | } |
143 | 143 | ||
144 | void OpieMail::displayMail() | 144 | void OpieMail::displayMail() |
145 | { | 145 | { |
146 | QListViewItem*item = mailView->currentItem(); | 146 | QListViewItem*item = mailView->currentItem(); |
147 | if (!item) return; | 147 | if (!item) return; |
148 | RecMailP mail = ((MailListViewItem*)item)->data(); | 148 | RecMailP mail = ((MailListViewItem*)item)->data(); |
149 | RecBody body = folderView->fetchBody(mail); | 149 | RecBodyP body = folderView->fetchBody(mail); |
150 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); | 150 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); |
151 | readMail.setBody( body ); | 151 | readMail.setBody( body ); |
152 | readMail.setMail( mail ); | 152 | readMail.setMail( mail ); |
153 | readMail.showMaximized(); | 153 | readMail.showMaximized(); |
154 | readMail.exec(); | 154 | readMail.exec(); |
155 | 155 | ||
156 | if ( readMail.deleted ) | 156 | if ( readMail.deleted ) |
157 | { | 157 | { |
158 | folderView->refreshCurrent(); | 158 | folderView->refreshCurrent(); |
159 | } | 159 | } |
160 | else | 160 | else |
161 | { | 161 | { |
162 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); | 162 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | void OpieMail::slotDeleteMail() | 166 | void OpieMail::slotDeleteMail() |
167 | { | 167 | { |
168 | if (!mailView->currentItem()) return; | 168 | if (!mailView->currentItem()) return; |
169 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 169 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
170 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 170 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
171 | { | 171 | { |
172 | mail->Wrapper()->deleteMail( mail ); | 172 | mail->Wrapper()->deleteMail( mail ); |
173 | folderView->refreshCurrent(); | 173 | folderView->refreshCurrent(); |
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 177 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
178 | { | 178 | { |
179 | if (!mailView->currentItem()) return; | 179 | if (!mailView->currentItem()) return; |
180 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 180 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
181 | /* just the RIGHT button - or hold on pda */ | 181 | /* just the RIGHT button - or hold on pda */ |
182 | if (button!=2) {return;} | 182 | if (button!=2) {return;} |
183 | qDebug("Event right/hold"); | 183 | qDebug("Event right/hold"); |
184 | if (!item) return; | 184 | if (!item) return; |
185 | QPopupMenu *m = new QPopupMenu(0); | 185 | QPopupMenu *m = new QPopupMenu(0); |
186 | if (m) | 186 | if (m) |
187 | { | 187 | { |
188 | if (mailtype==MAILLIB::A_NNTP) { | 188 | if (mailtype==MAILLIB::A_NNTP) { |
189 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); | 189 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); |
190 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 190 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
191 | } else { | 191 | } else { |
192 | if (folderView->currentisDraft()) { | 192 | if (folderView->currentisDraft()) { |
193 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); | 193 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); |
194 | } | 194 | } |
195 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | 195 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); |
196 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | 196 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); |
197 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); | 197 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); |
198 | } | 198 | } |
199 | m->setFocus(); | 199 | m->setFocus(); |
200 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 200 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
201 | delete m; | 201 | delete m; |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | void OpieMail::slotShowFolders( bool show ) | 205 | void OpieMail::slotShowFolders( bool show ) |
206 | { | 206 | { |
207 | qDebug( "Show Folders" ); | 207 | qDebug( "Show Folders" ); |
208 | if ( show && folderView->isHidden() ) | 208 | if ( show && folderView->isHidden() ) |
209 | { | 209 | { |
210 | qDebug( "-> showing" ); | 210 | qDebug( "-> showing" ); |
211 | folderView->show(); | 211 | folderView->show(); |
212 | } | 212 | } |
213 | else if ( !show && !folderView->isHidden() ) | 213 | else if ( !show && !folderView->isHidden() ) |
214 | { | 214 | { |
215 | qDebug( "-> hiding" ); | 215 | qDebug( "-> hiding" ); |
216 | folderView->hide(); | 216 | folderView->hide(); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 220 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
221 | { | 221 | { |
222 | MailListViewItem*item = 0; | 222 | MailListViewItem*item = 0; |
223 | mailView->clear(); | 223 | mailView->clear(); |
224 | 224 | ||
225 | QValueList<RecMailP>::ConstIterator it; | 225 | QValueList<RecMailP>::ConstIterator it; |
226 | for (it = list.begin(); it != list.end();++it) | 226 | for (it = list.begin(); it != list.end();++it) |
227 | { | 227 | { |
228 | item = new MailListViewItem(mailView,item); | 228 | item = new MailListViewItem(mailView,item); |
229 | item->storeData((*it)); | 229 | item->storeData((*it)); |
230 | item->showEntry(); | 230 | item->showEntry(); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | 233 | ||
234 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) | 234 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) |
235 | { | 235 | { |
236 | /* just LEFT button - or tap with stylus on pda */ | 236 | /* just LEFT button - or tap with stylus on pda */ |
237 | if (button!=1) return; | 237 | if (button!=1) return; |
238 | if (!item) return; | 238 | if (!item) return; |
239 | if (folderView->currentisDraft()) { | 239 | if (folderView->currentisDraft()) { |
240 | reEditMail(); | 240 | reEditMail(); |
241 | } else { | 241 | } else { |
242 | displayMail(); | 242 | displayMail(); |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index f00d2cb..156e11d 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,356 +1,356 @@ | |||
1 | #include "composemail.h" | 1 | #include "composemail.h" |
2 | #include "viewmail.h" | 2 | #include "viewmail.h" |
3 | 3 | ||
4 | /* OPIE */ | 4 | /* OPIE */ |
5 | #include <libmailwrapper/settings.h> | 5 | #include <libmailwrapper/settings.h> |
6 | #include <libmailwrapper/abstractmail.h> | 6 | #include <libmailwrapper/abstractmail.h> |
7 | #include <libmailwrapper/mailtypes.h> | 7 | #include <libmailwrapper/mailtypes.h> |
8 | 8 | ||
9 | #include <opie2/ofiledialog.h> | 9 | #include <opie2/ofiledialog.h> |
10 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
11 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
12 | 12 | ||
13 | /* QT */ | 13 | /* QT */ |
14 | #include <qtextbrowser.h> | 14 | #include <qtextbrowser.h> |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qtextstream.h> | 16 | #include <qtextstream.h> |
17 | #include <qaction.h> | 17 | #include <qaction.h> |
18 | #include <qpopupmenu.h> | 18 | #include <qpopupmenu.h> |
19 | #include <qfile.h> | 19 | #include <qfile.h> |
20 | 20 | ||
21 | using namespace Opie::Ui; | 21 | using namespace Opie::Ui; |
22 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 22 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
23 | const QString&fsize,int num,const QValueList<int>&path) | 23 | const QString&fsize,int num,const QValueList<int>&path) |
24 | : QListViewItem(parent,after),_partNum(num) | 24 | : QListViewItem(parent,after),_partNum(num) |
25 | { | 25 | { |
26 | _path=path; | 26 | _path=path; |
27 | setText(0, mime); | 27 | setText(0, mime); |
28 | setText(1, desc); | 28 | setText(1, desc); |
29 | setText(2, file); | 29 | setText(2, file); |
30 | setText(3, fsize); | 30 | setText(3, fsize); |
31 | } | 31 | } |
32 | 32 | ||
33 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 33 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
34 | const QString&fsize,int num,const QValueList<int>&path) | 34 | const QString&fsize,int num,const QValueList<int>&path) |
35 | : QListViewItem(parent,after),_partNum(num) | 35 | : QListViewItem(parent,after),_partNum(num) |
36 | { | 36 | { |
37 | _path=path; | 37 | _path=path; |
38 | setText(0, mime); | 38 | setText(0, mime); |
39 | setText(1, desc); | 39 | setText(1, desc); |
40 | setText(2, file); | 40 | setText(2, file); |
41 | setText(3, fsize); | 41 | setText(3, fsize); |
42 | } | 42 | } |
43 | 43 | ||
44 | bool AttachItem::isParentof(const QValueList<int>&path) | 44 | bool AttachItem::isParentof(const QValueList<int>&path) |
45 | { | 45 | { |
46 | /* if not set, then no parent */ | 46 | /* if not set, then no parent */ |
47 | if (path.count()==0||_path.count()==0) return false; | 47 | if (path.count()==0||_path.count()==0) return false; |
48 | /* the parent must have one digit less then a child */ | 48 | /* the parent must have one digit less then a child */ |
49 | if (path.count()!=_path.count()+1) return false; | 49 | if (path.count()!=_path.count()+1) return false; |
50 | for (unsigned int i=0; i < _path.count();++i) | 50 | for (unsigned int i=0; i < _path.count();++i) |
51 | { | 51 | { |
52 | if (_path[i]!=path[i]) return false; | 52 | if (_path[i]!=path[i]) return false; |
53 | } | 53 | } |
54 | return true; | 54 | return true; |
55 | } | 55 | } |
56 | 56 | ||
57 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 57 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
58 | { | 58 | { |
59 | QListViewItemIterator it( attachments ); | 59 | QListViewItemIterator it( attachments ); |
60 | for ( ; it.current(); ++it ) | 60 | for ( ; it.current(); ++it ) |
61 | { | 61 | { |
62 | AttachItem*ati = (AttachItem*)it.current(); | 62 | AttachItem*ati = (AttachItem*)it.current(); |
63 | if (ati->isParentof(path)) return ati; | 63 | if (ati->isParentof(path)) return ati; |
64 | } | 64 | } |
65 | return 0; | 65 | return 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 68 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
69 | { | 69 | { |
70 | if (!parent) return 0; | 70 | if (!parent) return 0; |
71 | AttachItem* item = (AttachItem*)parent->firstChild(); | 71 | AttachItem* item = (AttachItem*)parent->firstChild(); |
72 | if (!item) return item; | 72 | if (!item) return item; |
73 | AttachItem*temp=0; | 73 | AttachItem*temp=0; |
74 | while( (temp=(AttachItem*)item->nextSibling())) | 74 | while( (temp=(AttachItem*)item->nextSibling())) |
75 | { | 75 | { |
76 | item = temp; | 76 | item = temp; |
77 | } | 77 | } |
78 | return item; | 78 | return item; |
79 | } | 79 | } |
80 | 80 | ||
81 | void ViewMail::setBody( RecBody body ) | 81 | void ViewMail::setBody(const RecBodyP&body ) |
82 | { | 82 | { |
83 | 83 | ||
84 | m_body = body; | 84 | m_body = body; |
85 | m_mail[2] = body.Bodytext(); | 85 | m_mail[2] = body->Bodytext(); |
86 | attachbutton->setEnabled(body.Parts().count()>0); | 86 | attachbutton->setEnabled(body->Parts().count()>0); |
87 | attachments->setEnabled(body.Parts().count()>0); | 87 | attachments->setEnabled(body->Parts().count()>0); |
88 | if (body.Parts().count()==0) | 88 | if (body->Parts().count()==0) |
89 | { | 89 | { |
90 | return; | 90 | return; |
91 | } | 91 | } |
92 | AttachItem * curItem=0; | 92 | AttachItem * curItem=0; |
93 | AttachItem * parentItem = 0; | 93 | AttachItem * parentItem = 0; |
94 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 94 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); |
95 | QString desc,fsize; | 95 | QString desc,fsize; |
96 | double s = body.Description().Size(); | 96 | double s = body->Description()->Size(); |
97 | int w; | 97 | int w; |
98 | w=0; | 98 | w=0; |
99 | 99 | ||
100 | while (s>1024) | 100 | while (s>1024) |
101 | { | 101 | { |
102 | s/=1024; | 102 | s/=1024; |
103 | ++w; | 103 | ++w; |
104 | if (w>=2) break; | 104 | if (w>=2) break; |
105 | } | 105 | } |
106 | 106 | ||
107 | QString q=""; | 107 | QString q=""; |
108 | switch(w) | 108 | switch(w) |
109 | { | 109 | { |
110 | case 1: | 110 | case 1: |
111 | q="k"; | 111 | q="k"; |
112 | break; | 112 | break; |
113 | case 2: | 113 | case 2: |
114 | q="M"; | 114 | q="M"; |
115 | break; | 115 | break; |
116 | default: | 116 | default: |
117 | break; | 117 | break; |
118 | } | 118 | } |
119 | 119 | ||
120 | { | 120 | { |
121 | /* I did not found a method to make a CONTENT reset on a QTextStream | 121 | /* I did not found a method to make a CONTENT reset on a QTextStream |
122 | so I use this construct that the stream will re-constructed in each | 122 | so I use this construct that the stream will re-constructed in each |
123 | loop. To let it work, the textstream is packed into a own area of | 123 | loop. To let it work, the textstream is packed into a own area of |
124 | code is it will be destructed after finishing its small job. | 124 | code is it will be destructed after finishing its small job. |
125 | */ | 125 | */ |
126 | QTextOStream o(&fsize); | 126 | QTextOStream o(&fsize); |
127 | if (w>0) o.precision(2); else o.precision(0); | 127 | if (w>0) o.precision(2); else o.precision(0); |
128 | o.setf(QTextStream::fixed); | 128 | o.setf(QTextStream::fixed); |
129 | o << s << " " << q << "Byte"; | 129 | o << s << " " << q << "Byte"; |
130 | } | 130 | } |
131 | 131 | ||
132 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); | 132 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); |
133 | QString filename = ""; | 133 | QString filename = ""; |
134 | 134 | ||
135 | for (unsigned int i = 0; i < body.Parts().count();++i) | 135 | for (unsigned int i = 0; i < body->Parts().count();++i) |
136 | { | 136 | { |
137 | filename = ""; | 137 | filename = ""; |
138 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 138 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); |
139 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 139 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); |
140 | for (;it!=body.Parts()[i].Parameters().end();++it) | 140 | for (;it!=body->Parts()[i]->Parameters().end();++it) |
141 | { | 141 | { |
142 | qDebug(it.key()); | 142 | qDebug(it.key()); |
143 | if (it.key().lower()=="name") | 143 | if (it.key().lower()=="name") |
144 | { | 144 | { |
145 | filename=it.data(); | 145 | filename=it.data(); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | s = body.Parts()[i].Size(); | 148 | s = body->Parts()[i]->Size(); |
149 | w = 0; | 149 | w = 0; |
150 | while (s>1024) | 150 | while (s>1024) |
151 | { | 151 | { |
152 | s/=1024; | 152 | s/=1024; |
153 | ++w; | 153 | ++w; |
154 | if (w>=2) break; | 154 | if (w>=2) break; |
155 | } | 155 | } |
156 | switch(w) | 156 | switch(w) |
157 | { | 157 | { |
158 | case 1: | 158 | case 1: |
159 | q="k"; | 159 | q="k"; |
160 | break; | 160 | break; |
161 | case 2: | 161 | case 2: |
162 | q="M"; | 162 | q="M"; |
163 | break; | 163 | break; |
164 | default: | 164 | default: |
165 | q=""; | 165 | q=""; |
166 | break; | 166 | break; |
167 | } | 167 | } |
168 | QTextOStream o(&fsize); | 168 | QTextOStream o(&fsize); |
169 | if (w>0) o.precision(2); else o.precision(0); | 169 | if (w>0) o.precision(2); else o.precision(0); |
170 | o.setf(QTextStream::fixed); | 170 | o.setf(QTextStream::fixed); |
171 | o << s << " " << q << "Byte"; | 171 | o << s << " " << q << "Byte"; |
172 | desc = body.Parts()[i].Description(); | 172 | desc = body->Parts()[i]->Description(); |
173 | parentItem = searchParent(body.Parts()[i].Positionlist()); | 173 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
174 | if (parentItem) | 174 | if (parentItem) |
175 | { | 175 | { |
176 | AttachItem*temp = lastChild(parentItem); | 176 | AttachItem*temp = lastChild(parentItem); |
177 | if (temp) curItem = temp; | 177 | if (temp) curItem = temp; |
178 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 178 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
179 | attachments->setRootIsDecorated(true); | 179 | attachments->setRootIsDecorated(true); |
180 | curItem = parentItem; | 180 | curItem = parentItem; |
181 | } | 181 | } |
182 | else | 182 | else |
183 | { | 183 | { |
184 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 184 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | void ViewMail::slotShowHtml( bool state ) | 190 | void ViewMail::slotShowHtml( bool state ) |
191 | { | 191 | { |
192 | m_showHtml = state; | 192 | m_showHtml = state; |
193 | setText(); | 193 | setText(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 196 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
197 | { | 197 | { |
198 | if (!item ) | 198 | if (!item ) |
199 | return; | 199 | return; |
200 | 200 | ||
201 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 201 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
202 | { | 202 | { |
203 | setText(); | 203 | setText(); |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | QPopupMenu *menu = new QPopupMenu(); | 206 | QPopupMenu *menu = new QPopupMenu(); |
207 | int ret=0; | 207 | int ret=0; |
208 | 208 | ||
209 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 209 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
210 | { | 210 | { |
211 | menu->insertItem( tr( "Show Text" ), 1 ); | 211 | menu->insertItem( tr( "Show Text" ), 1 ); |
212 | } | 212 | } |
213 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 213 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
214 | menu->insertSeparator(1); | 214 | menu->insertSeparator(1); |
215 | 215 | ||
216 | ret = menu->exec( point, 0 ); | 216 | ret = menu->exec( point, 0 ); |
217 | 217 | ||
218 | switch(ret) | 218 | switch(ret) |
219 | { | 219 | { |
220 | case 0: | 220 | case 0: |
221 | { | 221 | { |
222 | MimeTypes types; | 222 | MimeTypes types; |
223 | types.insert( "all", "*" ); | 223 | types.insert( "all", "*" ); |
224 | QString str = OFileDialog::getSaveFileName( 1, | 224 | QString str = OFileDialog::getSaveFileName( 1, |
225 | "/", item->text( 2 ) , types, 0 ); | 225 | "/", item->text( 2 ) , types, 0 ); |
226 | 226 | ||
227 | if( !str.isEmpty() ) | 227 | if( !str.isEmpty() ) |
228 | { | 228 | { |
229 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 229 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
230 | if (content) | 230 | if (content) |
231 | { | 231 | { |
232 | QFile output(str); | 232 | QFile output(str); |
233 | output.open(IO_WriteOnly); | 233 | output.open(IO_WriteOnly); |
234 | output.writeBlock(content->Content(),content->Length()); | 234 | output.writeBlock(content->Content(),content->Length()); |
235 | output.close(); | 235 | output.close(); |
236 | delete content; | 236 | delete content; |
237 | } | 237 | } |
238 | } | 238 | } |
239 | } | 239 | } |
240 | break ; | 240 | break ; |
241 | 241 | ||
242 | case 1: | 242 | case 1: |
243 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 243 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
244 | { | 244 | { |
245 | setText(); | 245 | setText(); |
246 | } | 246 | } |
247 | else | 247 | else |
248 | { | 248 | { |
249 | if ( m_recMail->Wrapper() != 0l ) | 249 | if ( m_recMail->Wrapper() != 0l ) |
250 | { // make sure that there is a wrapper , even after delete or simular actions | 250 | { // make sure that there is a wrapper , even after delete or simular actions |
251 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 251 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | break; | 254 | break; |
255 | } | 255 | } |
256 | delete menu; | 256 | delete menu; |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | void ViewMail::setMail( RecMailP mail ) | 260 | void ViewMail::setMail(const RecMailP&mail ) |
261 | { | 261 | { |
262 | 262 | ||
263 | m_recMail = mail; | 263 | m_recMail = mail; |
264 | 264 | ||
265 | m_mail[0] = mail->getFrom(); | 265 | m_mail[0] = mail->getFrom(); |
266 | m_mail[1] = mail->getSubject(); | 266 | m_mail[1] = mail->getSubject(); |
267 | m_mail[3] = mail->getDate(); | 267 | m_mail[3] = mail->getDate(); |
268 | m_mail[4] = mail->Msgid(); | 268 | m_mail[4] = mail->Msgid(); |
269 | 269 | ||
270 | m_mail2[0] = mail->To(); | 270 | m_mail2[0] = mail->To(); |
271 | m_mail2[1] = mail->CC(); | 271 | m_mail2[1] = mail->CC(); |
272 | m_mail2[2] = mail->Bcc(); | 272 | m_mail2[2] = mail->Bcc(); |
273 | 273 | ||
274 | setText(); | 274 | setText(); |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | 278 | ||
279 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 279 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
280 | : ViewMailBase(parent, name, fl), _inLoop(false) | 280 | : ViewMailBase(parent, name, fl), _inLoop(false) |
281 | { | 281 | { |
282 | m_gotBody = false; | 282 | m_gotBody = false; |
283 | deleted = false; | 283 | deleted = false; |
284 | 284 | ||
285 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 285 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
286 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 286 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
287 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 287 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
288 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 288 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
289 | 289 | ||
290 | attachments->setEnabled(m_gotBody); | 290 | attachments->setEnabled(m_gotBody); |
291 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 291 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
292 | 292 | ||
293 | readConfig(); | 293 | readConfig(); |
294 | attachments->setSorting(-1); | 294 | attachments->setSorting(-1); |
295 | } | 295 | } |
296 | 296 | ||
297 | void ViewMail::readConfig() | 297 | void ViewMail::readConfig() |
298 | { | 298 | { |
299 | Config cfg( "mail" ); | 299 | Config cfg( "mail" ); |
300 | cfg.setGroup( "Settings" ); | 300 | cfg.setGroup( "Settings" ); |
301 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | 301 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); |
302 | showHtml->setOn( m_showHtml ); | 302 | showHtml->setOn( m_showHtml ); |
303 | } | 303 | } |
304 | 304 | ||
305 | void ViewMail::setText() | 305 | void ViewMail::setText() |
306 | { | 306 | { |
307 | 307 | ||
308 | QString toString; | 308 | QString toString; |
309 | QString ccString; | 309 | QString ccString; |
310 | QString bccString; | 310 | QString bccString; |
311 | 311 | ||
312 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 312 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
313 | { | 313 | { |
314 | toString += (*it); | 314 | toString += (*it); |
315 | } | 315 | } |
316 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 316 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
317 | { | 317 | { |
318 | ccString += (*it); | 318 | ccString += (*it); |
319 | } | 319 | } |
320 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 320 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
321 | { | 321 | { |
322 | bccString += (*it); | 322 | bccString += (*it); |
323 | } | 323 | } |
324 | 324 | ||
325 | setCaption( caption().arg( m_mail[0] ) ); | 325 | setCaption( caption().arg( m_mail[0] ) ); |
326 | 326 | ||
327 | m_mailHtml = "<html><body>" | 327 | m_mailHtml = "<html><body>" |
328 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 328 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
329 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 329 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
330 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 330 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
331 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 331 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
332 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 332 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
333 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 333 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
334 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 334 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
335 | "</td></tr></table><font face=fixed>"; | 335 | "</td></tr></table><font face=fixed>"; |
336 | 336 | ||
337 | if ( !m_showHtml ) | 337 | if ( !m_showHtml ) |
338 | { | 338 | { |
339 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 339 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
340 | } | 340 | } |
341 | else | 341 | else |
342 | { | 342 | { |
343 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 343 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
344 | } | 344 | } |
345 | // remove later in favor of a real handling | 345 | // remove later in favor of a real handling |
346 | m_gotBody = true; | 346 | m_gotBody = true; |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | ViewMail::~ViewMail() | 350 | ViewMail::~ViewMail() |
351 | { | 351 | { |
352 | m_recMail->Wrapper()->cleanMimeCache(); | 352 | m_recMail->Wrapper()->cleanMimeCache(); |
353 | hide(); | 353 | hide(); |
354 | } | 354 | } |
355 | 355 | ||
356 | void ViewMail::hide() | 356 | void ViewMail::hide() |
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h index 6875e3c..b60fb8e 100644 --- a/noncore/net/mail/viewmail.h +++ b/noncore/net/mail/viewmail.h | |||
@@ -1,73 +1,72 @@ | |||
1 | #ifndef VIEWMAIL_H | 1 | #ifndef VIEWMAIL_H |
2 | #define VIEWMAIL_H | 2 | #define VIEWMAIL_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstringlist.h> | 6 | #include <qstringlist.h> |
7 | #include <qvaluelist.h> | 7 | #include <qvaluelist.h> |
8 | 8 | ||
9 | #include "viewmailbase.h" | 9 | #include "viewmailbase.h" |
10 | #include <libmailwrapper/mailtypes.h> | 10 | #include <libmailwrapper/mailtypes.h> |
11 | 11 | ||
12 | 12 | ||
13 | class AttachItem : public QListViewItem | 13 | class AttachItem : public QListViewItem |
14 | { | 14 | { |
15 | public: | 15 | public: |
16 | AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 16 | AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
17 | const QString&fsize,int num,const QValueList<int>&path); | 17 | const QString&fsize,int num,const QValueList<int>&path); |
18 | AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 18 | AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
19 | const QString&fsize,int num,const QValueList<int>&path); | 19 | const QString&fsize,int num,const QValueList<int>&path); |
20 | int Partnumber() { return _partNum; } | 20 | int Partnumber() { return _partNum; } |
21 | bool isParentof(const QValueList<int>&path); | 21 | bool isParentof(const QValueList<int>&path); |
22 | 22 | ||
23 | private: | 23 | private: |
24 | int _partNum; | 24 | int _partNum; |
25 | /* needed for a better display of attachments */ | 25 | /* needed for a better display of attachments */ |
26 | QValueList<int> _path; | 26 | QValueList<int> _path; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | class ViewMail : public ViewMailBase | 29 | class ViewMail : public ViewMailBase |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | 32 | ||
33 | public: | 33 | public: |
34 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 34 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
35 | ~ViewMail(); | 35 | ~ViewMail(); |
36 | 36 | ||
37 | void hide(); | 37 | void hide(); |
38 | void exec(); | 38 | void exec(); |
39 | void setMail( RecMailP mail ); | 39 | void setMail(const RecMailP&mail ); |
40 | void setBody( RecBody body ); | 40 | void setBody(const RecBodyP&body); |
41 | bool deleted; | 41 | bool deleted; |
42 | 42 | ||
43 | protected: | 43 | protected: |
44 | QString deHtml(const QString &string); | 44 | QString deHtml(const QString &string); |
45 | AttachItem* searchParent(const QValueList<int>&path); | 45 | AttachItem* searchParent(const QValueList<int>&path); |
46 | AttachItem* lastChild(AttachItem*parent); | 46 | AttachItem* lastChild(AttachItem*parent); |
47 | 47 | ||
48 | protected slots: | 48 | protected slots: |
49 | void slotReply(); | 49 | void slotReply(); |
50 | void slotForward(); | 50 | void slotForward(); |
51 | void setText(); | 51 | void setText(); |
52 | void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); | 52 | void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); |
53 | void slotDeleteMail( ); | 53 | void slotDeleteMail( ); |
54 | void slotShowHtml( bool ); | 54 | void slotShowHtml( bool ); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | void readConfig(); | 57 | void readConfig(); |
58 | 58 | ||
59 | bool _inLoop; | 59 | bool _inLoop; |
60 | QString m_mailHtml; | 60 | QString m_mailHtml; |
61 | bool m_gotBody; | 61 | bool m_gotBody; |
62 | RecBody m_body; | 62 | RecBodyP m_body; |
63 | RecMailP m_recMail; | 63 | RecMailP m_recMail; |
64 | bool m_showHtml; | 64 | bool m_showHtml; |
65 | 65 | ||
66 | // 0 from 1 subject 2 bodytext 3 date | 66 | // 0 from 1 subject 2 bodytext 3 date |
67 | QMap <int,QString> m_mail; | 67 | QMap <int,QString> m_mail; |
68 | // 0 to 1 cc 2 bcc | 68 | // 0 to 1 cc 2 bcc |
69 | QMap <int,QStringList> m_mail2; | 69 | QMap <int,QStringList> m_mail2; |
70 | |||
71 | }; | 70 | }; |
72 | 71 | ||
73 | #endif | 72 | #endif |