-rw-r--r-- | noncore/net/mail/accountview.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 302 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.h | 14 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 302 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 14 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.h | 17 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.h | 17 |
9 files changed, 427 insertions, 245 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index a531976..1bde886 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -63,3 +63,3 @@ QString IMAPfolderItem::fetchBody(const RecMail&aMail) | |||
63 | { | 63 | { |
64 | return imap->getWrapper()->fetchBody(folder->getName(),aMail); | 64 | return imap->getWrapper()->fetchBody(aMail); |
65 | } | 65 | } |
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index 7b78499..1acc036 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -4,3 +4,3 @@ | |||
4 | #include "imapwrapper.h" | 4 | #include "imapwrapper.h" |
5 | 5 | #include <libetpan/mailimap.h> | |
6 | 6 | ||
@@ -9,5 +9,11 @@ IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | |||
9 | account = a; | 9 | account = a; |
10 | m_imap = 0; | ||
10 | } | 11 | } |
11 | 12 | ||
12 | void imap_progress( size_t current, size_t maximum ) | 13 | IMAPwrapper::~IMAPwrapper() |
14 | { | ||
15 | logout(); | ||
16 | } | ||
17 | |||
18 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | ||
13 | { | 19 | { |
@@ -16,14 +22,9 @@ void imap_progress( size_t current, size_t maximum ) | |||
16 | 22 | ||
17 | void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | 23 | void IMAPwrapper::login() |
18 | { | 24 | { |
19 | const char *server, *user, *pass, *mb; | 25 | logout(); |
26 | const char *server, *user, *pass; | ||
20 | uint16_t port; | 27 | uint16_t port; |
21 | int err = MAILIMAP_NO_ERROR; | 28 | int err = MAILIMAP_NO_ERROR; |
22 | clist *result; | ||
23 | clistcell *current; | ||
24 | mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; | ||
25 | mailimap_fetch_type *fetchType; | ||
26 | mailimap_set *set; | ||
27 | 29 | ||
28 | mb = mailbox.latin1(); | ||
29 | server = account->getServer().latin1(); | 30 | server = account->getServer().latin1(); |
@@ -33,10 +34,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
33 | 34 | ||
34 | mailimap *imap = mailimap_new( 20, &imap_progress ); | 35 | m_imap = mailimap_new( 20, &imap_progress ); |
35 | if ( imap == NULL ) { | ||
36 | qDebug("IMAP Memory error"); | ||
37 | return; | ||
38 | } | ||
39 | |||
40 | /* connect */ | 36 | /* connect */ |
41 | err = mailimap_socket_connect( imap, (char*)server, port ); | 37 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
42 | if ( err != MAILIMAP_NO_ERROR && | 38 | if ( err != MAILIMAP_NO_ERROR && |
@@ -44,4 +40,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
44 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 40 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
45 | qDebug("error connecting server: %s",imap->response); | 41 | qDebug("error connecting server: %s",m_imap->response); |
46 | mailimap_free( imap ); | 42 | mailimap_free( m_imap ); |
43 | m_imap = 0; | ||
47 | return; | 44 | return; |
@@ -50,17 +47,41 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
50 | /* login */ | 47 | /* login */ |
51 | err = mailimap_login_simple( imap, (char*)user, (char*)pass ); | 48 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
52 | if ( err != MAILIMAP_NO_ERROR ) { | 49 | if ( err != MAILIMAP_NO_ERROR ) { |
53 | qDebug("error logging in imap: %s",imap->response); | 50 | qDebug("error logging in imap: %s",m_imap->response); |
54 | err = mailimap_close( imap ); | 51 | err = mailimap_close( m_imap ); |
55 | mailimap_free( imap ); | 52 | mailimap_free( m_imap ); |
56 | return; | 53 | m_imap = 0; |
57 | } | 54 | } |
55 | } | ||
56 | |||
57 | void IMAPwrapper::logout() | ||
58 | { | ||
59 | int err = MAILIMAP_NO_ERROR; | ||
60 | if (!m_imap) return; | ||
61 | err = mailimap_logout( m_imap ); | ||
62 | err = mailimap_close( m_imap ); | ||
63 | mailimap_free( m_imap ); | ||
64 | m_imap = 0; | ||
65 | } | ||
66 | |||
67 | void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | ||
68 | { | ||
69 | const char *mb; | ||
70 | int err = MAILIMAP_NO_ERROR; | ||
71 | clist *result; | ||
72 | clistcell *current; | ||
73 | mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; | ||
74 | mailimap_fetch_type *fetchType; | ||
75 | mailimap_set *set; | ||
58 | 76 | ||
77 | mb = mailbox.latin1(); | ||
78 | login(); | ||
79 | if (!m_imap) { | ||
80 | return; | ||
81 | } | ||
59 | /* select mailbox READONLY for operations */ | 82 | /* select mailbox READONLY for operations */ |
60 | err = mailimap_examine( imap, (char*)mb); | 83 | err = mailimap_examine( m_imap, (char*)mb); |
61 | if ( err != MAILIMAP_NO_ERROR ) { | 84 | if ( err != MAILIMAP_NO_ERROR ) { |
62 | qDebug("error selecting mailbox: %s",imap->response); | 85 | qDebug("error selecting mailbox: %s",m_imap->response); |
63 | err = mailimap_logout( imap ); | 86 | logout(); |
64 | err = mailimap_close( imap ); | ||
65 | mailimap_free( imap ); | ||
66 | return; | 87 | return; |
@@ -68,8 +89,7 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
68 | 89 | ||
69 | int last = imap->selection_info->exists; | 90 | int last = m_imap->selection_info->exists; |
91 | |||
70 | if (last == 0) { | 92 | if (last == 0) { |
71 | qDebug("mailbox has no mails"); | 93 | qDebug("mailbox has no mails"); |
72 | err = mailimap_logout( imap ); | 94 | logout(); |
73 | err = mailimap_close( imap ); | ||
74 | mailimap_free( imap ); | ||
75 | return; | 95 | return; |
@@ -77,3 +97,2 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
77 | 97 | ||
78 | |||
79 | result = clist_new(); | 98 | result = clist_new(); |
@@ -91,3 +110,3 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
91 | 110 | ||
92 | err = mailimap_fetch( imap, set, fetchType, &result ); | 111 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
93 | mailimap_set_free( set ); | 112 | mailimap_set_free( set ); |
@@ -108,2 +127,3 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
108 | m->setNumber(i); | 127 | m->setNumber(i); |
128 | m->setMbox(mailbox); | ||
109 | target.append(m); | 129 | target.append(m); |
@@ -113,9 +133,6 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
113 | } else { | 133 | } else { |
114 | qDebug("Error fetching headers: %s",imap->response); | 134 | qDebug("Error fetching headers: %s",m_imap->response); |
115 | } | 135 | } |
116 | 136 | logout(); | |
117 | err = mailimap_logout( imap ); | ||
118 | err = mailimap_close( imap ); | ||
119 | clist_free(result); | 137 | clist_free(result); |
120 | mailimap_free( imap ); | ||
121 | } | 138 | } |
@@ -124,4 +141,3 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
124 | { | 141 | { |
125 | const char *server, *user, *pass, *path, *mask; | 142 | const char *path, *mask; |
126 | uint16_t port; | ||
127 | int err = MAILIMAP_NO_ERROR; | 143 | int err = MAILIMAP_NO_ERROR; |
@@ -132,30 +148,7 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
132 | folders->setAutoDelete( true ); | 148 | folders->setAutoDelete( true ); |
133 | 149 | login(); | |
134 | server = account->getServer().latin1(); | 150 | if (!m_imap) { |
135 | port = account->getPort().toUInt(); | ||
136 | user = account->getUser().latin1(); | ||
137 | pass = account->getPassword().latin1(); | ||
138 | path = account->getPrefix().latin1(); | ||
139 | |||
140 | mailimap *imap = mailimap_new( 20, &imap_progress ); | ||
141 | if ( imap == NULL ) { | ||
142 | qDebug("error mailimap_new"); | ||
143 | return folders; | 151 | return folders; |
144 | } | 152 | } |
145 | |||
146 | err = mailimap_socket_connect( imap, (char*)server, port ); | ||
147 | if ( err != MAILIMAP_NO_ERROR && | ||
148 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | ||
149 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | ||
150 | mailimap_free(imap); | ||
151 | qDebug("error imap_socket_connect: %s",imap->response); | ||
152 | return folders; | ||
153 | } | ||
154 | 153 | ||
155 | err = mailimap_login_simple( imap, (char*)user, (char*)pass ); | ||
156 | if ( err != MAILIMAP_NO_ERROR ) { | ||
157 | mailimap_free(imap); | ||
158 | qDebug("error logging in: %s",imap->response); | ||
159 | return folders; | ||
160 | } | ||
161 | /* | 154 | /* |
@@ -169,3 +162,3 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
169 | mailimap_mailbox_list *list; | 162 | mailimap_mailbox_list *list; |
170 | err = mailimap_list( imap, (char*)"", (char*)mask, &result ); | 163 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
171 | if ( err == MAILIMAP_NO_ERROR ) { | 164 | if ( err == MAILIMAP_NO_ERROR ) { |
@@ -181,3 +174,3 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
181 | } else { | 174 | } else { |
182 | qDebug("error fetching folders: %s",imap->response); | 175 | qDebug("error fetching folders: %s",m_imap->response); |
183 | } | 176 | } |
@@ -189,4 +182,6 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
189 | mask = "*" ; | 182 | mask = "*" ; |
183 | path = account->getPrefix().latin1(); | ||
190 | result = clist_new(); | 184 | result = clist_new(); |
191 | err = mailimap_list( imap, (char*)path, (char*)mask, &result ); | 185 | qDebug(path); |
186 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | ||
192 | if ( err == MAILIMAP_NO_ERROR ) { | 187 | if ( err == MAILIMAP_NO_ERROR ) { |
@@ -205,8 +200,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
205 | } else { | 200 | } else { |
206 | qDebug("error fetching folders"); | 201 | qDebug("error fetching folders %s",m_imap->response); |
207 | } | 202 | } |
208 | mailimap_list_result_free( result ); | 203 | mailimap_list_result_free( result ); |
209 | err = mailimap_logout( imap ); | ||
210 | err = mailimap_close( imap ); | ||
211 | mailimap_free( imap ); | ||
212 | return folders; | 204 | return folders; |
@@ -275,3 +267,2 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
275 | } | 267 | } |
276 | |||
277 | cf = cf->next; | 268 | cf = cf->next; |
@@ -339,7 +330,7 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
339 | 330 | ||
340 | QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) | 331 | #if 1 |
332 | QString IMAPwrapper::fetchBody(const RecMail&mail) | ||
341 | { | 333 | { |
342 | QString body = ""; | 334 | QString body = ""; |
343 | const char *server, *user, *pass, *mb; | 335 | const char *mb; |
344 | uint16_t port; | ||
345 | int err = MAILIMAP_NO_ERROR; | 336 | int err = MAILIMAP_NO_ERROR; |
@@ -351,40 +342,126 @@ QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) | |||
351 | 342 | ||
352 | mb = mailbox.latin1(); | 343 | mb = mail.getMbox().latin1(); |
353 | server = account->getServer().latin1(); | ||
354 | port = account->getPort().toUInt(); | ||
355 | user = account->getUser().latin1(); | ||
356 | pass = account->getPassword().latin1(); | ||
357 | 344 | ||
358 | mailimap *imap = mailimap_new( 20, &imap_progress ); | 345 | login(); |
359 | if ( imap == NULL ) { | 346 | if (!m_imap) { |
360 | qDebug("IMAP Memory error"); | 347 | return body; |
348 | } | ||
349 | /* select mailbox READONLY for operations */ | ||
350 | err = mailimap_examine( m_imap, (char*)mb); | ||
351 | if ( err != MAILIMAP_NO_ERROR ) { | ||
352 | qDebug("error selecting mailbox: %s",m_imap->response); | ||
353 | logout(); | ||
361 | return body; | 354 | return body; |
362 | } | 355 | } |
356 | result = clist_new(); | ||
357 | /* the range has to start at 1!!! not with 0!!!! */ | ||
358 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | ||
359 | fetchAtt = mailimap_fetch_att_new_rfc822_text(); | ||
360 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | ||
361 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
362 | mailimap_set_free( set ); | ||
363 | mailimap_fetch_type_free( fetchType ); | ||
364 | |||
365 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | ||
366 | mailimap_msg_att * msg_att; | ||
367 | msg_att = (mailimap_msg_att*)current->data; | ||
368 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | ||
363 | 369 | ||
364 | /* connect */ | 370 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { |
365 | err = mailimap_socket_connect( imap, (char*)server, port ); | 371 | body = item->msg_att_static->rfc822_text; |
366 | if ( err != MAILIMAP_NO_ERROR && | 372 | } |
367 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 373 | } else { |
368 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 374 | qDebug("error fetching text: %s",m_imap->response); |
369 | qDebug("error connecting server: %s",imap->response); | ||
370 | mailimap_free( imap ); | ||
371 | return body; | ||
372 | } | 375 | } |
373 | 376 | ||
374 | /* login */ | 377 | clist_free(result); |
375 | err = mailimap_login_simple( imap, (char*)user, (char*)pass ); | 378 | logout(); |
376 | if ( err != MAILIMAP_NO_ERROR ) { | 379 | return body; |
377 | qDebug("error logging in imap: %s",imap->response); | 380 | } |
378 | err = mailimap_close( imap ); | 381 | |
379 | mailimap_free( imap ); | 382 | #else |
383 | QString IMAPwrapper::fetchBody(const RecMail&mail) | ||
384 | { | ||
385 | QString body = ""; | ||
386 | const char *mb; | ||
387 | int err = MAILIMAP_NO_ERROR; | ||
388 | clist *result; | ||
389 | clistcell *current; | ||
390 | mailimap_fetch_att *fetchAtt; | ||
391 | mailimap_fetch_type *fetchType; | ||
392 | mailimap_set *set; | ||
393 | mailimap_body*body_desc; | ||
394 | |||
395 | mb = mail.getMbox().latin1(); | ||
396 | |||
397 | login(); | ||
398 | if (!m_imap) { | ||
380 | return body; | 399 | return body; |
381 | } | 400 | } |
382 | |||
383 | /* select mailbox READONLY for operations */ | 401 | /* select mailbox READONLY for operations */ |
384 | err = mailimap_examine( imap, (char*)mb); | 402 | err = mailimap_examine( m_imap, (char*)mb); |
385 | if ( err != MAILIMAP_NO_ERROR ) { | 403 | if ( err != MAILIMAP_NO_ERROR ) { |
386 | qDebug("error selecting mailbox: %s",imap->response); | 404 | qDebug("error selecting mailbox: %s",m_imap->response); |
387 | err = mailimap_logout( imap ); | 405 | logout(); |
388 | err = mailimap_close( imap ); | 406 | return body; |
389 | mailimap_free( imap ); | 407 | } |
408 | result = clist_new(); | ||
409 | /* the range has to start at 1!!! not with 0!!!! */ | ||
410 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | ||
411 | fetchAtt = mailimap_fetch_att_new_body(); | ||
412 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | ||
413 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
414 | mailimap_set_free( set ); | ||
415 | mailimap_fetch_type_free( fetchType ); | ||
416 | |||
417 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | ||
418 | mailimap_msg_att * msg_att; | ||
419 | msg_att = (mailimap_msg_att*)current->data; | ||
420 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | ||
421 | body_desc = item->msg_att_static->body; | ||
422 | if (body_desc->type==MAILIMAP_BODY_1PART) { | ||
423 | body = searchBodyText(mail,body_desc->body_1part); | ||
424 | } else { | ||
425 | } | ||
426 | |||
427 | } else { | ||
428 | qDebug("error fetching body: %s",m_imap->response); | ||
429 | } | ||
430 | |||
431 | clist_free(result); | ||
432 | logout(); | ||
433 | return body; | ||
434 | } | ||
435 | #endif | ||
436 | |||
437 | QString IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription) | ||
438 | { | ||
439 | QString Body=""; | ||
440 | if (!mailDescription) { | ||
441 | return Body; | ||
442 | } | ||
443 | switch (mailDescription->type) { | ||
444 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | ||
445 | return getPlainBody(mail); | ||
446 | break; | ||
447 | default: | ||
448 | break; | ||
449 | } | ||
450 | return Body; | ||
451 | } | ||
452 | |||
453 | QString IMAPwrapper::getPlainBody(const RecMail&mail) | ||
454 | { | ||
455 | QString body = ""; | ||
456 | const char *mb; | ||
457 | int err = MAILIMAP_NO_ERROR; | ||
458 | clist *result; | ||
459 | clistcell *current; | ||
460 | mailimap_fetch_att *fetchAtt; | ||
461 | mailimap_fetch_type *fetchType; | ||
462 | mailimap_set *set; | ||
463 | |||
464 | mb = mail.getMbox().latin1(); | ||
465 | |||
466 | if (!m_imap) { | ||
390 | return body; | 467 | return body; |
@@ -396,3 +473,3 @@ QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) | |||
396 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 473 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
397 | err = mailimap_fetch( imap, set, fetchType, &result ); | 474 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
398 | mailimap_set_free( set ); | 475 | mailimap_set_free( set ); |
@@ -404,3 +481,2 @@ QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) | |||
404 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | 481 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; |
405 | |||
406 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { | 482 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { |
@@ -409,12 +485,6 @@ QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) | |||
409 | } else { | 485 | } else { |
410 | qDebug("error fetching text: %s",imap->response); | 486 | qDebug("error fetching text: %s",m_imap->response); |
411 | } | 487 | } |
412 | |||
413 | err = mailimap_logout( imap ); | ||
414 | err = mailimap_close( imap ); | ||
415 | mailimap_free( imap ); | ||
416 | clist_free(result); | 488 | clist_free(result); |
417 | |||
418 | return body; | 489 | return body; |
419 | } | 490 | } |
420 | |||
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h index 65c36e0..b02d26d 100644 --- a/noncore/net/mail/imapwrapper.h +++ b/noncore/net/mail/imapwrapper.h | |||
@@ -4,3 +4,5 @@ | |||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include <libetpan/mailimap.h> | 5 | |
6 | struct mailimap; | ||
7 | struct mailimap_body_type_1part; | ||
6 | 8 | ||
@@ -12,5 +14,7 @@ public: | |||
12 | IMAPwrapper( IMAPaccount *a ); | 14 | IMAPwrapper( IMAPaccount *a ); |
15 | virtual ~IMAPwrapper(); | ||
13 | QList<IMAPFolder>* listFolders(); | 16 | QList<IMAPFolder>* listFolders(); |
14 | void listMessages(const QString & mailbox,Maillist&target ); | 17 | void listMessages(const QString & mailbox,Maillist&target ); |
15 | QString fetchBody(const QString & mailbox,const RecMail&mail); | 18 | QString fetchBody(const RecMail&mail); |
19 | static void imap_progress( size_t current, size_t maximum ); | ||
16 | 20 | ||
@@ -18,2 +22,6 @@ protected: | |||
18 | RecMail*parse_list_result(mailimap_msg_att*); | 22 | RecMail*parse_list_result(mailimap_msg_att*); |
23 | void login(); | ||
24 | void logout(); | ||
25 | QString searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription); | ||
26 | QString getPlainBody(const RecMail&mail); | ||
19 | 27 | ||
@@ -21,3 +29,3 @@ private: | |||
21 | IMAPaccount *account; | 29 | IMAPaccount *account; |
22 | 30 | mailimap *m_imap; | |
23 | }; | 31 | }; |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 7b78499..1acc036 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -4,3 +4,3 @@ | |||
4 | #include "imapwrapper.h" | 4 | #include "imapwrapper.h" |
5 | 5 | #include <libetpan/mailimap.h> | |
6 | 6 | ||
@@ -9,5 +9,11 @@ IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | |||
9 | account = a; | 9 | account = a; |
10 | m_imap = 0; | ||
10 | } | 11 | } |
11 | 12 | ||
12 | void imap_progress( size_t current, size_t maximum ) | 13 | IMAPwrapper::~IMAPwrapper() |
14 | { | ||
15 | logout(); | ||
16 | } | ||
17 | |||
18 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | ||
13 | { | 19 | { |
@@ -16,14 +22,9 @@ void imap_progress( size_t current, size_t maximum ) | |||
16 | 22 | ||
17 | void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | 23 | void IMAPwrapper::login() |
18 | { | 24 | { |
19 | const char *server, *user, *pass, *mb; | 25 | logout(); |
26 | const char *server, *user, *pass; | ||
20 | uint16_t port; | 27 | uint16_t port; |
21 | int err = MAILIMAP_NO_ERROR; | 28 | int err = MAILIMAP_NO_ERROR; |
22 | clist *result; | ||
23 | clistcell *current; | ||
24 | mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; | ||
25 | mailimap_fetch_type *fetchType; | ||
26 | mailimap_set *set; | ||
27 | 29 | ||
28 | mb = mailbox.latin1(); | ||
29 | server = account->getServer().latin1(); | 30 | server = account->getServer().latin1(); |
@@ -33,10 +34,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
33 | 34 | ||
34 | mailimap *imap = mailimap_new( 20, &imap_progress ); | 35 | m_imap = mailimap_new( 20, &imap_progress ); |
35 | if ( imap == NULL ) { | ||
36 | qDebug("IMAP Memory error"); | ||
37 | return; | ||
38 | } | ||
39 | |||
40 | /* connect */ | 36 | /* connect */ |
41 | err = mailimap_socket_connect( imap, (char*)server, port ); | 37 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
42 | if ( err != MAILIMAP_NO_ERROR && | 38 | if ( err != MAILIMAP_NO_ERROR && |
@@ -44,4 +40,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
44 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 40 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
45 | qDebug("error connecting server: %s",imap->response); | 41 | qDebug("error connecting server: %s",m_imap->response); |
46 | mailimap_free( imap ); | 42 | mailimap_free( m_imap ); |
43 | m_imap = 0; | ||
47 | return; | 44 | return; |
@@ -50,17 +47,41 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
50 | /* login */ | 47 | /* login */ |
51 | err = mailimap_login_simple( imap, (char*)user, (char*)pass ); | 48 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
52 | if ( err != MAILIMAP_NO_ERROR ) { | 49 | if ( err != MAILIMAP_NO_ERROR ) { |
53 | qDebug("error logging in imap: %s",imap->response); | 50 | qDebug("error logging in imap: %s",m_imap->response); |
54 | err = mailimap_close( imap ); | 51 | err = mailimap_close( m_imap ); |
55 | mailimap_free( imap ); | 52 | mailimap_free( m_imap ); |
56 | return; | 53 | m_imap = 0; |
57 | } | 54 | } |
55 | } | ||
56 | |||
57 | void IMAPwrapper::logout() | ||
58 | { | ||
59 | int err = MAILIMAP_NO_ERROR; | ||
60 | if (!m_imap) return; | ||
61 | err = mailimap_logout( m_imap ); | ||
62 | err = mailimap_close( m_imap ); | ||
63 | mailimap_free( m_imap ); | ||
64 | m_imap = 0; | ||
65 | } | ||
66 | |||
67 | void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | ||
68 | { | ||
69 | const char *mb; | ||
70 | int err = MAILIMAP_NO_ERROR; | ||
71 | clist *result; | ||
72 | clistcell *current; | ||
73 | mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; | ||
74 | mailimap_fetch_type *fetchType; | ||
75 | mailimap_set *set; | ||
58 | 76 | ||
77 | mb = mailbox.latin1(); | ||
78 | login(); | ||
79 | if (!m_imap) { | ||
80 | return; | ||
81 | } | ||
59 | /* select mailbox READONLY for operations */ | 82 | /* select mailbox READONLY for operations */ |
60 | err = mailimap_examine( imap, (char*)mb); | 83 | err = mailimap_examine( m_imap, (char*)mb); |
61 | if ( err != MAILIMAP_NO_ERROR ) { | 84 | if ( err != MAILIMAP_NO_ERROR ) { |
62 | qDebug("error selecting mailbox: %s",imap->response); | 85 | qDebug("error selecting mailbox: %s",m_imap->response); |
63 | err = mailimap_logout( imap ); | 86 | logout(); |
64 | err = mailimap_close( imap ); | ||
65 | mailimap_free( imap ); | ||
66 | return; | 87 | return; |
@@ -68,8 +89,7 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
68 | 89 | ||
69 | int last = imap->selection_info->exists; | 90 | int last = m_imap->selection_info->exists; |
91 | |||
70 | if (last == 0) { | 92 | if (last == 0) { |
71 | qDebug("mailbox has no mails"); | 93 | qDebug("mailbox has no mails"); |
72 | err = mailimap_logout( imap ); | 94 | logout(); |
73 | err = mailimap_close( imap ); | ||
74 | mailimap_free( imap ); | ||
75 | return; | 95 | return; |
@@ -77,3 +97,2 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
77 | 97 | ||
78 | |||
79 | result = clist_new(); | 98 | result = clist_new(); |
@@ -91,3 +110,3 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
91 | 110 | ||
92 | err = mailimap_fetch( imap, set, fetchType, &result ); | 111 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
93 | mailimap_set_free( set ); | 112 | mailimap_set_free( set ); |
@@ -108,2 +127,3 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
108 | m->setNumber(i); | 127 | m->setNumber(i); |
128 | m->setMbox(mailbox); | ||
109 | target.append(m); | 129 | target.append(m); |
@@ -113,9 +133,6 @@ void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) | |||
113 | } else { | 133 | } else { |
114 | qDebug("Error fetching headers: %s",imap->response); | 134 | qDebug("Error fetching headers: %s",m_imap->response); |
115 | } | 135 | } |
116 | 136 | logout(); | |
117 | err = mailimap_logout( imap ); | ||
118 | err = mailimap_close( imap ); | ||
119 | clist_free(result); | 137 | clist_free(result); |
120 | mailimap_free( imap ); | ||
121 | } | 138 | } |
@@ -124,4 +141,3 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
124 | { | 141 | { |
125 | const char *server, *user, *pass, *path, *mask; | 142 | const char *path, *mask; |
126 | uint16_t port; | ||
127 | int err = MAILIMAP_NO_ERROR; | 143 | int err = MAILIMAP_NO_ERROR; |
@@ -132,30 +148,7 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
132 | folders->setAutoDelete( true ); | 148 | folders->setAutoDelete( true ); |
133 | 149 | login(); | |
134 | server = account->getServer().latin1(); | 150 | if (!m_imap) { |
135 | port = account->getPort().toUInt(); | ||
136 | user = account->getUser().latin1(); | ||
137 | pass = account->getPassword().latin1(); | ||
138 | path = account->getPrefix().latin1(); | ||
139 | |||
140 | mailimap *imap = mailimap_new( 20, &imap_progress ); | ||
141 | if ( imap == NULL ) { | ||
142 | qDebug("error mailimap_new"); | ||
143 | return folders; | 151 | return folders; |
144 | } | 152 | } |
145 | |||
146 | err = mailimap_socket_connect( imap, (char*)server, port ); | ||
147 | if ( err != MAILIMAP_NO_ERROR && | ||
148 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | ||
149 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | ||
150 | mailimap_free(imap); | ||
151 | qDebug("error imap_socket_connect: %s",imap->response); | ||
152 | return folders; | ||
153 | } | ||
154 | 153 | ||
155 | err = mailimap_login_simple( imap, (char*)user, (char*)pass ); | ||
156 | if ( err != MAILIMAP_NO_ERROR ) { | ||
157 | mailimap_free(imap); | ||
158 | qDebug("error logging in: %s",imap->response); | ||
159 | return folders; | ||
160 | } | ||
161 | /* | 154 | /* |
@@ -169,3 +162,3 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
169 | mailimap_mailbox_list *list; | 162 | mailimap_mailbox_list *list; |
170 | err = mailimap_list( imap, (char*)"", (char*)mask, &result ); | 163 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
171 | if ( err == MAILIMAP_NO_ERROR ) { | 164 | if ( err == MAILIMAP_NO_ERROR ) { |
@@ -181,3 +174,3 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
181 | } else { | 174 | } else { |
182 | qDebug("error fetching folders: %s",imap->response); | 175 | qDebug("error fetching folders: %s",m_imap->response); |
183 | } | 176 | } |
@@ -189,4 +182,6 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
189 | mask = "*" ; | 182 | mask = "*" ; |
183 | path = account->getPrefix().latin1(); | ||
190 | result = clist_new(); | 184 | result = clist_new(); |
191 | err = mailimap_list( imap, (char*)path, (char*)mask, &result ); | 185 | qDebug(path); |
186 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | ||
192 | if ( err == MAILIMAP_NO_ERROR ) { | 187 | if ( err == MAILIMAP_NO_ERROR ) { |
@@ -205,8 +200,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
205 | } else { | 200 | } else { |
206 | qDebug("error fetching folders"); | 201 | qDebug("error fetching folders %s",m_imap->response); |
207 | } | 202 | } |
208 | mailimap_list_result_free( result ); | 203 | mailimap_list_result_free( result ); |
209 | err = mailimap_logout( imap ); | ||
210 | err = mailimap_close( imap ); | ||
211 | mailimap_free( imap ); | ||
212 | return folders; | 204 | return folders; |
@@ -275,3 +267,2 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
275 | } | 267 | } |
276 | |||
277 | cf = cf->next; | 268 | cf = cf->next; |
@@ -339,7 +330,7 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
339 | 330 | ||
340 | QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) | 331 | #if 1 |
332 | QString IMAPwrapper::fetchBody(const RecMail&mail) | ||
341 | { | 333 | { |
342 | QString body = ""; | 334 | QString body = ""; |
343 | const char *server, *user, *pass, *mb; | 335 | const char *mb; |
344 | uint16_t port; | ||
345 | int err = MAILIMAP_NO_ERROR; | 336 | int err = MAILIMAP_NO_ERROR; |
@@ -351,40 +342,126 @@ QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) | |||
351 | 342 | ||
352 | mb = mailbox.latin1(); | 343 | mb = mail.getMbox().latin1(); |
353 | server = account->getServer().latin1(); | ||
354 | port = account->getPort().toUInt(); | ||
355 | user = account->getUser().latin1(); | ||
356 | pass = account->getPassword().latin1(); | ||
357 | 344 | ||
358 | mailimap *imap = mailimap_new( 20, &imap_progress ); | 345 | login(); |
359 | if ( imap == NULL ) { | 346 | if (!m_imap) { |
360 | qDebug("IMAP Memory error"); | 347 | return body; |
348 | } | ||
349 | /* select mailbox READONLY for operations */ | ||
350 | err = mailimap_examine( m_imap, (char*)mb); | ||
351 | if ( err != MAILIMAP_NO_ERROR ) { | ||
352 | qDebug("error selecting mailbox: %s",m_imap->response); | ||
353 | logout(); | ||
361 | return body; | 354 | return body; |
362 | } | 355 | } |
356 | result = clist_new(); | ||
357 | /* the range has to start at 1!!! not with 0!!!! */ | ||
358 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | ||
359 | fetchAtt = mailimap_fetch_att_new_rfc822_text(); | ||
360 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | ||
361 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
362 | mailimap_set_free( set ); | ||
363 | mailimap_fetch_type_free( fetchType ); | ||
364 | |||
365 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | ||
366 | mailimap_msg_att * msg_att; | ||
367 | msg_att = (mailimap_msg_att*)current->data; | ||
368 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | ||
363 | 369 | ||
364 | /* connect */ | 370 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { |
365 | err = mailimap_socket_connect( imap, (char*)server, port ); | 371 | body = item->msg_att_static->rfc822_text; |
366 | if ( err != MAILIMAP_NO_ERROR && | 372 | } |
367 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 373 | } else { |
368 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 374 | qDebug("error fetching text: %s",m_imap->response); |
369 | qDebug("error connecting server: %s",imap->response); | ||
370 | mailimap_free( imap ); | ||
371 | return body; | ||
372 | } | 375 | } |
373 | 376 | ||
374 | /* login */ | 377 | clist_free(result); |
375 | err = mailimap_login_simple( imap, (char*)user, (char*)pass ); | 378 | logout(); |
376 | if ( err != MAILIMAP_NO_ERROR ) { | 379 | return body; |
377 | qDebug("error logging in imap: %s",imap->response); | 380 | } |
378 | err = mailimap_close( imap ); | 381 | |
379 | mailimap_free( imap ); | 382 | #else |
383 | QString IMAPwrapper::fetchBody(const RecMail&mail) | ||
384 | { | ||
385 | QString body = ""; | ||
386 | const char *mb; | ||
387 | int err = MAILIMAP_NO_ERROR; | ||
388 | clist *result; | ||
389 | clistcell *current; | ||
390 | mailimap_fetch_att *fetchAtt; | ||
391 | mailimap_fetch_type *fetchType; | ||
392 | mailimap_set *set; | ||
393 | mailimap_body*body_desc; | ||
394 | |||
395 | mb = mail.getMbox().latin1(); | ||
396 | |||
397 | login(); | ||
398 | if (!m_imap) { | ||
380 | return body; | 399 | return body; |
381 | } | 400 | } |
382 | |||
383 | /* select mailbox READONLY for operations */ | 401 | /* select mailbox READONLY for operations */ |
384 | err = mailimap_examine( imap, (char*)mb); | 402 | err = mailimap_examine( m_imap, (char*)mb); |
385 | if ( err != MAILIMAP_NO_ERROR ) { | 403 | if ( err != MAILIMAP_NO_ERROR ) { |
386 | qDebug("error selecting mailbox: %s",imap->response); | 404 | qDebug("error selecting mailbox: %s",m_imap->response); |
387 | err = mailimap_logout( imap ); | 405 | logout(); |
388 | err = mailimap_close( imap ); | 406 | return body; |
389 | mailimap_free( imap ); | 407 | } |
408 | result = clist_new(); | ||
409 | /* the range has to start at 1!!! not with 0!!!! */ | ||
410 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | ||
411 | fetchAtt = mailimap_fetch_att_new_body(); | ||
412 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | ||
413 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
414 | mailimap_set_free( set ); | ||
415 | mailimap_fetch_type_free( fetchType ); | ||
416 | |||
417 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | ||
418 | mailimap_msg_att * msg_att; | ||
419 | msg_att = (mailimap_msg_att*)current->data; | ||
420 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | ||
421 | body_desc = item->msg_att_static->body; | ||
422 | if (body_desc->type==MAILIMAP_BODY_1PART) { | ||
423 | body = searchBodyText(mail,body_desc->body_1part); | ||
424 | } else { | ||
425 | } | ||
426 | |||
427 | } else { | ||
428 | qDebug("error fetching body: %s",m_imap->response); | ||
429 | } | ||
430 | |||
431 | clist_free(result); | ||
432 | logout(); | ||
433 | return body; | ||
434 | } | ||
435 | #endif | ||
436 | |||
437 | QString IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription) | ||
438 | { | ||
439 | QString Body=""; | ||
440 | if (!mailDescription) { | ||
441 | return Body; | ||
442 | } | ||
443 | switch (mailDescription->type) { | ||
444 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | ||
445 | return getPlainBody(mail); | ||
446 | break; | ||
447 | default: | ||
448 | break; | ||
449 | } | ||
450 | return Body; | ||
451 | } | ||
452 | |||
453 | QString IMAPwrapper::getPlainBody(const RecMail&mail) | ||
454 | { | ||
455 | QString body = ""; | ||
456 | const char *mb; | ||
457 | int err = MAILIMAP_NO_ERROR; | ||
458 | clist *result; | ||
459 | clistcell *current; | ||
460 | mailimap_fetch_att *fetchAtt; | ||
461 | mailimap_fetch_type *fetchType; | ||
462 | mailimap_set *set; | ||
463 | |||
464 | mb = mail.getMbox().latin1(); | ||
465 | |||
466 | if (!m_imap) { | ||
390 | return body; | 467 | return body; |
@@ -396,3 +473,3 @@ QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) | |||
396 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 473 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
397 | err = mailimap_fetch( imap, set, fetchType, &result ); | 474 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
398 | mailimap_set_free( set ); | 475 | mailimap_set_free( set ); |
@@ -404,3 +481,2 @@ QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) | |||
404 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | 481 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; |
405 | |||
406 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { | 482 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { |
@@ -409,12 +485,6 @@ QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) | |||
409 | } else { | 485 | } else { |
410 | qDebug("error fetching text: %s",imap->response); | 486 | qDebug("error fetching text: %s",m_imap->response); |
411 | } | 487 | } |
412 | |||
413 | err = mailimap_logout( imap ); | ||
414 | err = mailimap_close( imap ); | ||
415 | mailimap_free( imap ); | ||
416 | clist_free(result); | 488 | clist_free(result); |
417 | |||
418 | return body; | 489 | return body; |
419 | } | 490 | } |
420 | |||
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 65c36e0..b02d26d 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -4,3 +4,5 @@ | |||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include <libetpan/mailimap.h> | 5 | |
6 | struct mailimap; | ||
7 | struct mailimap_body_type_1part; | ||
6 | 8 | ||
@@ -12,5 +14,7 @@ public: | |||
12 | IMAPwrapper( IMAPaccount *a ); | 14 | IMAPwrapper( IMAPaccount *a ); |
15 | virtual ~IMAPwrapper(); | ||
13 | QList<IMAPFolder>* listFolders(); | 16 | QList<IMAPFolder>* listFolders(); |
14 | void listMessages(const QString & mailbox,Maillist&target ); | 17 | void listMessages(const QString & mailbox,Maillist&target ); |
15 | QString fetchBody(const QString & mailbox,const RecMail&mail); | 18 | QString fetchBody(const RecMail&mail); |
19 | static void imap_progress( size_t current, size_t maximum ); | ||
16 | 20 | ||
@@ -18,2 +22,6 @@ protected: | |||
18 | RecMail*parse_list_result(mailimap_msg_att*); | 22 | RecMail*parse_list_result(mailimap_msg_att*); |
23 | void login(); | ||
24 | void logout(); | ||
25 | QString searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription); | ||
26 | QString getPlainBody(const RecMail&mail); | ||
19 | 27 | ||
@@ -21,3 +29,3 @@ private: | |||
21 | IMAPaccount *account; | 29 | IMAPaccount *account; |
22 | 30 | mailimap *m_imap; | |
23 | }; | 31 | }; |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index ea9e7b2..7f67cd8 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp | |||
@@ -631,3 +631,3 @@ Mail::Mail() | |||
631 | RecMail::RecMail() | 631 | RecMail::RecMail() |
632 | :subject(""),date(""),msg_number(0),msg_flags(7) | 632 | :subject(""),date(""),mbox(""),msg_number(0),msg_flags(7) |
633 | { | 633 | { |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index 955a8e2..332034f 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h | |||
@@ -41,2 +41,13 @@ protected: | |||
41 | /* a class to describe mails in a mailbox */ | 41 | /* a class to describe mails in a mailbox */ |
42 | /* Attention! | ||
43 | From programmers point of view it would make sense to | ||
44 | store the mail body into this class, too. | ||
45 | But: not from the point of view of the device. | ||
46 | Mailbodies can be real large. So we request them when | ||
47 | needed from the mail-wrapper class direct from the server itself | ||
48 | (imap) or from a file-based cache (pop3?) | ||
49 | So there is no interface "const QString&body()" but you should | ||
50 | make a request to the mailwrapper with this class as parameter to | ||
51 | get the body. Same words for the attachments. | ||
52 | */ | ||
42 | class RecMail | 53 | class RecMail |
@@ -55,4 +66,6 @@ public: | |||
55 | void setSubject( const QString&s ) { subject = s; } | 66 | void setSubject( const QString&s ) { subject = s; } |
56 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 67 | const QString&getMbox()const{return mbox;} |
68 | void setMbox(const QString&box){mbox = box;} | ||
57 | const QBitArray&getFlags()const{return msg_flags;} | 69 | const QBitArray&getFlags()const{return msg_flags;} |
70 | void setFlags(const QBitArray&flags){msg_flags = flags;} | ||
58 | 71 | ||
@@ -64,3 +77,3 @@ public: | |||
64 | protected: | 77 | protected: |
65 | QString subject,date,from; | 78 | QString subject,date,from,mbox; |
66 | int msg_number; | 79 | int msg_number; |
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp index ea9e7b2..7f67cd8 100644 --- a/noncore/net/mail/mailwrapper.cpp +++ b/noncore/net/mail/mailwrapper.cpp | |||
@@ -631,3 +631,3 @@ Mail::Mail() | |||
631 | RecMail::RecMail() | 631 | RecMail::RecMail() |
632 | :subject(""),date(""),msg_number(0),msg_flags(7) | 632 | :subject(""),date(""),mbox(""),msg_number(0),msg_flags(7) |
633 | { | 633 | { |
diff --git a/noncore/net/mail/mailwrapper.h b/noncore/net/mail/mailwrapper.h index 955a8e2..332034f 100644 --- a/noncore/net/mail/mailwrapper.h +++ b/noncore/net/mail/mailwrapper.h | |||
@@ -41,2 +41,13 @@ protected: | |||
41 | /* a class to describe mails in a mailbox */ | 41 | /* a class to describe mails in a mailbox */ |
42 | /* Attention! | ||
43 | From programmers point of view it would make sense to | ||
44 | store the mail body into this class, too. | ||
45 | But: not from the point of view of the device. | ||
46 | Mailbodies can be real large. So we request them when | ||
47 | needed from the mail-wrapper class direct from the server itself | ||
48 | (imap) or from a file-based cache (pop3?) | ||
49 | So there is no interface "const QString&body()" but you should | ||
50 | make a request to the mailwrapper with this class as parameter to | ||
51 | get the body. Same words for the attachments. | ||
52 | */ | ||
42 | class RecMail | 53 | class RecMail |
@@ -55,4 +66,6 @@ public: | |||
55 | void setSubject( const QString&s ) { subject = s; } | 66 | void setSubject( const QString&s ) { subject = s; } |
56 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 67 | const QString&getMbox()const{return mbox;} |
68 | void setMbox(const QString&box){mbox = box;} | ||
57 | const QBitArray&getFlags()const{return msg_flags;} | 69 | const QBitArray&getFlags()const{return msg_flags;} |
70 | void setFlags(const QBitArray&flags){msg_flags = flags;} | ||
58 | 71 | ||
@@ -64,3 +77,3 @@ public: | |||
64 | protected: | 77 | protected: |
65 | QString subject,date,from; | 78 | QString subject,date,from,mbox; |
66 | int msg_number; | 79 | int msg_number; |