summaryrefslogtreecommitdiff
authorjgf <jgf>2003-12-11 17:21:41 (UTC)
committer jgf <jgf>2003-12-11 17:21:41 (UTC)
commitefa09eadddc16220cc1e8a55da93115538b091bb (patch) (unidiff)
treef8186f84bd107c388507cc6a69ce5f6ce1aaccc9
parenta54fcb766991ed3d813be5f0b066998082378933 (diff)
downloadopie-efa09eadddc16220cc1e8a55da93115538b091bb.zip
opie-efa09eadddc16220cc1e8a55da93115538b091bb.tar.gz
opie-efa09eadddc16220cc1e8a55da93115538b091bb.tar.bz2
fetchBody in POP3 & weird segfault
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp6
-rw-r--r--noncore/net/mail/accountview.h2
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp111
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h13
-rw-r--r--noncore/net/mail/pop3wrapper.cpp111
-rw-r--r--noncore/net/mail/pop3wrapper.h13
6 files changed, 158 insertions, 98 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 6963027..c7b1eeb 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,132 +1,132 @@
1#include "accountview.h" 1#include "accountview.h"
2#include "imapwrapper.h" 2#include "imapwrapper.h"
3#include "pop3wrapper.h" 3#include "pop3wrapper.h"
4#include "mailtypes.h" 4#include "mailtypes.h"
5#include "defines.h" 5#include "defines.h"
6 6
7 7
8/** 8/**
9 * POP3 Account stuff 9 * POP3 Account stuff
10 */ 10 */
11 11
12POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) 12POP3viewItem::POP3viewItem( POP3account *a, QListView *parent )
13 : AccountViewItem( parent ) 13 : AccountViewItem( parent )
14{ 14{
15 account = a; 15 account = a;
16 wrapper = new POP3wrapper( account ); 16 wrapper = new POP3wrapper( account );
17 setPixmap( 0, PIXMAP_POP3FOLDER ); 17 setPixmap( 0, PIXMAP_POP3FOLDER );
18 setText( 0, account->getAccountName() ); 18 setText( 0, account->getAccountName() );
19} 19}
20 20
21POP3viewItem::~POP3viewItem() 21POP3viewItem::~POP3viewItem()
22{ 22{
23 delete wrapper; 23 delete wrapper;
24} 24}
25 25
26void POP3viewItem::refresh( QList<RecMail> &target ) 26void POP3viewItem::refresh( QList<RecMail> &target )
27{ 27{
28 qDebug( "POP3: refresh" ); 28 qDebug( "POP3: refresh" );
29 wrapper->listMessages( target ); 29 wrapper->listMessages( target );
30} 30}
31 31
32 32
33RecBody POP3viewItem::fetchBody( const RecMail & ) 33RecBody POP3viewItem::fetchBody( const RecMail &mail )
34{ 34{
35 qDebug( "POP3 fetchBody: IMPLEMENT ME!!" ); 35 qDebug( "POP3 fetchBody" );
36 return RecBody(); 36 return wrapper->fetchBody( mail );
37} 37}
38 38
39/** 39/**
40 * IMAP Account stuff 40 * IMAP Account stuff
41 */ 41 */
42 42
43IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) 43IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent )
44 : AccountViewItem( parent ) 44 : AccountViewItem( parent )
45{ 45{
46 account = a; 46 account = a;
47 wrapper = new IMAPwrapper( account ); 47 wrapper = new IMAPwrapper( account );
48 setPixmap( 0, PIXMAP_IMAPFOLDER ); 48 setPixmap( 0, PIXMAP_IMAPFOLDER );
49 setText( 0, account->getAccountName() ); 49 setText( 0, account->getAccountName() );
50 setOpen( true ); 50 setOpen( true );
51} 51}
52 52
53IMAPviewItem::~IMAPviewItem() 53IMAPviewItem::~IMAPviewItem()
54{ 54{
55 delete wrapper; 55 delete wrapper;
56} 56}
57 57
58IMAPwrapper *IMAPviewItem::getWrapper() 58IMAPwrapper *IMAPviewItem::getWrapper()
59{ 59{
60 return wrapper; 60 return wrapper;
61} 61}
62 62
63void IMAPviewItem::refresh(QList<RecMail>&) 63void IMAPviewItem::refresh(QList<RecMail>&)
64{ 64{
65 QList<IMAPFolder> *folders = wrapper->listFolders(); 65 QList<IMAPFolder> *folders = wrapper->listFolders();
66 66
67 QListViewItem *child = firstChild(); 67 QListViewItem *child = firstChild();
68 while ( child ) { 68 while ( child ) {
69 QListViewItem *tmp = child; 69 QListViewItem *tmp = child;
70 child = child->nextSibling(); 70 child = child->nextSibling();
71 delete tmp; 71 delete tmp;
72 } 72 }
73 73
74 IMAPFolder *it; 74 IMAPFolder *it;
75 for ( it = folders->first(); it; it = folders->next() ) { 75 for ( it = folders->first(); it; it = folders->next() ) {
76 (void) new IMAPfolderItem( it, this ); 76 (void) new IMAPfolderItem( it, this );
77 } 77 }
78} 78}
79 79
80RecBody IMAPviewItem::fetchBody(const RecMail&) 80RecBody IMAPviewItem::fetchBody(const RecMail&)
81{ 81{
82 return RecBody(); 82 return RecBody();
83} 83}
84 84
85IMAPfolderItem::~IMAPfolderItem() 85IMAPfolderItem::~IMAPfolderItem()
86{ 86{
87 delete folder; 87 delete folder;
88} 88}
89 89
90IMAPfolderItem::IMAPfolderItem( IMAPFolder *folderInit, IMAPviewItem *parent ) 90IMAPfolderItem::IMAPfolderItem( IMAPFolder *folderInit, IMAPviewItem *parent )
91 : AccountViewItem( parent ) 91 : AccountViewItem( parent )
92{ 92{
93 folder = folderInit; 93 folder = folderInit;
94 imap = parent; 94 imap = parent;
95 setPixmap( 0, PIXMAP_IMAPFOLDER ); 95 setPixmap( 0, PIXMAP_IMAPFOLDER );
96 setText( 0, folder->getDisplayName() ); 96 setText( 0, folder->getDisplayName() );
97} 97}
98 98
99void IMAPfolderItem::refresh(QList<RecMail>&target) 99void IMAPfolderItem::refresh(QList<RecMail>&target)
100{ 100{
101 imap->getWrapper()->listMessages( folder->getName(),target ); 101 imap->getWrapper()->listMessages( folder->getName(),target );
102} 102}
103 103
104RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) 104RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
105{ 105{
106 return imap->getWrapper()->fetchBody(aMail); 106 return imap->getWrapper()->fetchBody(aMail);
107} 107}
108 108
109/** 109/**
110 * Generic stuff 110 * Generic stuff
111 */ 111 */
112 112
113AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 113AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
114 : QListView( parent, name, flags ) 114 : QListView( parent, name, flags )
115{ 115{
116 connect( this, SIGNAL( clicked( QListViewItem * ) ), 116 connect( this, SIGNAL( clicked( QListViewItem * ) ),
117 SLOT( refresh( QListViewItem * ) ) ); 117 SLOT( refresh( QListViewItem * ) ) );
118} 118}
119 119
120void AccountView::populate( QList<Account> list ) 120void AccountView::populate( QList<Account> list )
121{ 121{
122 clear(); 122 clear();
123 123
124 Account *it; 124 Account *it;
125 for ( it = list.first(); it; it = list.next() ) { 125 for ( it = list.first(); it; it = list.next() ) {
126 if ( it->getType().compare( "IMAP" ) == 0 ) { 126 if ( it->getType().compare( "IMAP" ) == 0 ) {
127 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 127 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
128 qDebug( "added IMAP " + imap->getAccountName() ); 128 qDebug( "added IMAP " + imap->getAccountName() );
129 (void) new IMAPviewItem( imap, this ); 129 (void) new IMAPviewItem( imap, this );
130 } else if ( it->getType().compare( "POP3" ) == 0 ) { 130 } else if ( it->getType().compare( "POP3" ) == 0 ) {
131 POP3account *pop3 = static_cast<POP3account *>(it); 131 POP3account *pop3 = static_cast<POP3account *>(it);
132 qDebug( "added POP3 " + pop3->getAccountName() ); 132 qDebug( "added POP3 " + pop3->getAccountName() );
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index fe832ec..4cac673 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -1,88 +1,88 @@
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 6
7#include "settings.h" 7#include "settings.h"
8#include "mailwrapper.h" 8#include "mailwrapper.h"
9 9
10class IMAPwrapper; 10class IMAPwrapper;
11class POP3wrapper; 11class POP3wrapper;
12class RecMail; 12class RecMail;
13class RecBody; 13class RecBody;
14 14
15class AccountViewItem : public QListViewItem 15class AccountViewItem : public QListViewItem
16{ 16{
17 17
18public: 18public:
19 AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} 19 AccountViewItem( QListView *parent ) : QListViewItem( parent ) {}
20 AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {} 20 AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {}
21 virtual void refresh(QList<RecMail>&)=0; 21 virtual void refresh(QList<RecMail>&)=0;
22 virtual RecBody fetchBody(const RecMail&)=0; 22 virtual RecBody fetchBody(const RecMail&)=0;
23}; 23};
24 24
25class POP3viewItem : public AccountViewItem 25class POP3viewItem : public AccountViewItem
26{ 26{
27 27
28public: 28public:
29 POP3viewItem( POP3account *a, QListView *parent ); 29 POP3viewItem( POP3account *a, QListView *parent );
30 ~POP3viewItem(); 30 ~POP3viewItem();
31 virtual void refresh( QList<RecMail> &target ); 31 virtual void refresh( QList<RecMail> &target );
32 virtual RecBody fetchBody(const RecMail & ); 32 virtual RecBody fetchBody( const RecMail &mail );
33 33
34private: 34private:
35 POP3account *account; 35 POP3account *account;
36 POP3wrapper *wrapper; 36 POP3wrapper *wrapper;
37 37
38}; 38};
39 39
40class IMAPviewItem : public AccountViewItem 40class IMAPviewItem : public AccountViewItem
41{ 41{
42 42
43public: 43public:
44 IMAPviewItem( IMAPaccount *a, QListView *parent ); 44 IMAPviewItem( IMAPaccount *a, QListView *parent );
45 ~IMAPviewItem(); 45 ~IMAPviewItem();
46 virtual void refresh(QList<RecMail>&); 46 virtual void refresh(QList<RecMail>&);
47 virtual RecBody fetchBody(const RecMail&); 47 virtual RecBody fetchBody(const RecMail&);
48 IMAPwrapper *getWrapper(); 48 IMAPwrapper *getWrapper();
49 49
50private: 50private:
51 IMAPaccount *account; 51 IMAPaccount *account;
52 IMAPwrapper *wrapper; 52 IMAPwrapper *wrapper;
53 53
54}; 54};
55 55
56class IMAPfolderItem : public AccountViewItem 56class IMAPfolderItem : public AccountViewItem
57{ 57{
58 58
59public: 59public:
60 IMAPfolderItem( IMAPFolder *folder, IMAPviewItem *parent ); 60 IMAPfolderItem( IMAPFolder *folder, IMAPviewItem *parent );
61 ~IMAPfolderItem(); 61 ~IMAPfolderItem();
62 virtual void refresh(QList<RecMail>&); 62 virtual void refresh(QList<RecMail>&);
63 virtual RecBody fetchBody(const RecMail&); 63 virtual RecBody fetchBody(const RecMail&);
64 64
65private: 65private:
66 IMAPFolder *folder; 66 IMAPFolder *folder;
67 IMAPviewItem *imap; 67 IMAPviewItem *imap;
68 68
69}; 69};
70 70
71class AccountView : public QListView 71class AccountView : public QListView
72{ 72{
73 Q_OBJECT 73 Q_OBJECT
74 74
75public: 75public:
76 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 76 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
77 void populate( QList<Account> list ); 77 void populate( QList<Account> list );
78 RecBody fetchBody(const RecMail&aMail); 78 RecBody fetchBody(const RecMail&aMail);
79 79
80public slots: 80public slots:
81 void refreshAll(); 81 void refreshAll();
82 void refresh(QListViewItem *item); 82 void refresh(QListViewItem *item);
83 83
84signals: 84signals:
85 void refreshMailview(QList<RecMail>*); 85 void refreshMailview(QList<RecMail>*);
86}; 86};
87 87
88#endif 88#endif
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 633faf6..abb5a42 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -1,243 +1,270 @@
1 1
2#include "pop3wrapper.h" 2#include "pop3wrapper.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4#include <libetpan/mailpop3.h> 4#include <libetpan/mailpop3.h>
5 5
6POP3wrapper::POP3wrapper( POP3account *a ) 6POP3wrapper::POP3wrapper( POP3account *a )
7{ 7{
8 account = a; 8 account = a;
9 m_pop3 = NULL; 9 m_pop3 = NULL;
10} 10}
11 11
12POP3wrapper::~POP3wrapper() 12POP3wrapper::~POP3wrapper()
13{ 13{
14 logout(); 14 logout();
15} 15}
16 16
17void POP3wrapper::pop3_progress( size_t current, size_t maximum ) 17void POP3wrapper::pop3_progress( size_t current, size_t maximum )
18{ 18{
19 qDebug( "POP3: %i of %i", current, maximum ); 19 qDebug( "POP3: %i of %i", current, maximum );
20} 20}
21 21
22RecBody POP3wrapper::fetchBody( const RecMail &mail )
23{
24 int err = MAILPOP3_NO_ERROR;
25 char *message;
26 size_t length;
27
28 login();
29 if ( !m_pop3 ) return RecBody();
30
31 err = mailpop3_retr( m_pop3, mail.getNumber(), &message, &length );
32 if ( err != MAILPOP3_NO_ERROR ) {
33 qDebug( "POP3: error retrieving body with index %i", mail.getNumber() );
34 logout();
35 return RecBody();
36 }
37
38 logout();
39
40 return parseBody( message );
41}
42
43RecBody POP3wrapper::parseBody( const char *message )
44{
45 int err = MAILIMF_NO_ERROR;
46 size_t curTok;
47 mailimf_message *result;
48 RecBody body;
49
50 err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result );
51 if ( err != MAILIMF_NO_ERROR ) return body;
52
53 if ( result && result->msg_body && result->msg_body->bd_text ) {
54 qDebug( "POP3: bodytext found" );
55 // TODO: why does this line segfault???? gdb says segfault in strlen(), maybe a bug in libetpan.
56 body.setBodytext( QString( result->msg_body->bd_text ) );
57 }
58
59 return body;
60}
61
22void POP3wrapper::listMessages( QList<RecMail> &target ) 62void POP3wrapper::listMessages( QList<RecMail> &target )
23{ 63{
24 int err = MAILPOP3_NO_ERROR; 64 int err = MAILPOP3_NO_ERROR;
25 char *header; 65 char *header;
26 size_t length; 66 size_t length;
27 carray *messages; 67 carray *messages;
28 68
29 login(); 69 login();
30 if (!m_pop3) return; 70 if (!m_pop3) return;
31 mailpop3_list( m_pop3, &messages ); 71 mailpop3_list( m_pop3, &messages );
32 72
33 for ( int i = carray_count( messages ); i > 0; i-- ) { 73 for ( int i = carray_count( messages ); i > 0; i-- ) {
34 mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); 74 mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 );
35 75
36 err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); 76 err = mailpop3_header( m_pop3, info->msg_index, &header, &length );
37 if ( err != MAILPOP3_NO_ERROR ) { 77 if ( err != MAILPOP3_NO_ERROR ) {
38 qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); 78 qDebug( "POP3: error retrieving header msgid: %i", info->msg_index );
39 logout(); 79 logout();
40 return; 80 return;
41 } 81 }
42 RecMail *mail = parseHeader( header ); 82 RecMail *mail = parseHeader( header );
43 mail->setNumber( info->msg_index ); 83 mail->setNumber( info->msg_index );
44 target.append( mail ); 84 target.append( mail );
45 } 85 }
46 86
47 logout(); 87 logout();
48} 88}
49 89
50RecMail *POP3wrapper::parseHeader( const char *header ) 90RecMail *POP3wrapper::parseHeader( const char *header )
51{ 91{
52 int err = MAILIMF_NO_ERROR; 92 int err = MAILIMF_NO_ERROR;
53 size_t curTok; 93 size_t curTok;
54 RecMail *mail = new RecMail(); 94 RecMail *mail = new RecMail();
55 mailimf_fields *fields; 95 mailimf_fields *fields;
56 96
57 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); 97 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
58 for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { 98 for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
59 mailimf_field *field = (mailimf_field *) current->data; 99 mailimf_field *field = (mailimf_field *) current->data;
60 switch ( field->fld_type ) { 100 switch ( field->fld_type ) {
61 case MAILIMF_FIELD_FROM: 101 case MAILIMF_FIELD_FROM:
62 mail->setFrom( *parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); 102 mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
63 break; 103 break;
64 case MAILIMF_FIELD_TO: 104 case MAILIMF_FIELD_TO:
65 mail->setTo( *parseAddressList( field->fld_data.fld_to->to_addr_list ) ); 105 mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) );
66 break; 106 break;
67 case MAILIMF_FIELD_CC: 107 case MAILIMF_FIELD_CC:
68 mail->setCC( *parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); 108 mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) );
69 break; 109 break;
70 case MAILIMF_FIELD_BCC: 110 case MAILIMF_FIELD_BCC:
71 mail->setBcc( *parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); 111 mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) );
72 break; 112 break;
73 case MAILIMF_FIELD_SUBJECT: 113 case MAILIMF_FIELD_SUBJECT:
74 mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) ); 114 mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) );
75 break; 115 break;
76 case MAILIMF_FIELD_ORIG_DATE: 116 case MAILIMF_FIELD_ORIG_DATE:
77 mail->setDate( *parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); 117 mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) );
78 break; 118 break;
79 default: 119 default:
80 break; 120 break;
81 } 121 }
82 } 122 }
83 123
84 return mail; 124 return mail;
85} 125}
86 126
87QString *POP3wrapper::parseDateTime( mailimf_date_time *date ) 127QString POP3wrapper::parseDateTime( mailimf_date_time *date )
88{ 128{
89 char tmp[23]; 129 char tmp[23];
90 130
91 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 131 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
92 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 132 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
93 133
94 QString *result = new QString( tmp ); 134 return QString( tmp );
95
96 return result;
97} 135}
98 136
99QString *POP3wrapper::parseAddressList( mailimf_address_list *list ) 137QString POP3wrapper::parseAddressList( mailimf_address_list *list )
100{ 138{
101 QString *result = new QString( "" ); 139 QString result( "" );
102 140
103 bool first = true; 141 bool first = true;
104 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 142 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
105 mailimf_address *addr = (mailimf_address *) current->data; 143 mailimf_address *addr = (mailimf_address *) current->data;
106 144
107 if ( !first ) { 145 if ( !first ) {
108 result->append( "," ); 146 result.append( "," );
109 } else { 147 } else {
110 first = false; 148 first = false;
111 } 149 }
112 150
113 QString *tmp;
114
115 switch ( addr->ad_type ) { 151 switch ( addr->ad_type ) {
116 case MAILIMF_ADDRESS_MAILBOX: 152 case MAILIMF_ADDRESS_MAILBOX:
117 tmp = parseMailbox( addr->ad_data.ad_mailbox ); 153 result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
118 result->append( *tmp );
119 delete tmp;
120 break; 154 break;
121 case MAILIMF_ADDRESS_GROUP: 155 case MAILIMF_ADDRESS_GROUP:
122 tmp = parseGroup( addr->ad_data.ad_group ); 156 result.append( parseGroup( addr->ad_data.ad_group ) );
123 result->append( *tmp );
124 delete tmp;
125 break; 157 break;
126 default: 158 default:
127 qDebug( "POP3: unkown mailimf address type" ); 159 qDebug( "POP3: unkown mailimf address type" );
128 break; 160 break;
129 } 161 }
130 } 162 }
131 163
132 return result; 164 return result;
133} 165}
134 166
135QString *POP3wrapper::parseGroup( mailimf_group *group ) 167QString POP3wrapper::parseGroup( mailimf_group *group )
136{ 168{
137 QString *result = new QString( "" ); 169 QString result( "" );
138 170
139 result->append( group->grp_display_name ); 171 result.append( group->grp_display_name );
140 result->append( ": " ); 172 result.append( ": " );
141 173
142 if ( group->grp_mb_list != NULL ) { 174 if ( group->grp_mb_list != NULL ) {
143 QString *tmp = parseMailboxList( group->grp_mb_list ); 175 result.append( parseMailboxList( group->grp_mb_list ) );
144 result->append( *tmp );
145 delete tmp;
146 } 176 }
147 177
148 result->append( ";" ); 178 result.append( ";" );
149 179
150 return result; 180 return result;
151} 181}
152 182
153QString *POP3wrapper::parseMailbox( mailimf_mailbox *box ) 183QString POP3wrapper::parseMailbox( mailimf_mailbox *box )
154{ 184{
155 QString *result = new QString( "" ); 185 QString result( "" );
156 186
157 if ( box->mb_display_name == NULL ) { 187 if ( box->mb_display_name == NULL ) {
158 result->append( box->mb_addr_spec ); 188 result.append( box->mb_addr_spec );
159 } else { 189 } else {
160 result->append( box->mb_display_name ); 190 result.append( box->mb_display_name );
161 result->append( " <" ); 191 result.append( " <" );
162 result->append( box->mb_addr_spec ); 192 result.append( box->mb_addr_spec );
163 result->append( ">" ); 193 result.append( ">" );
164 } 194 }
165 195
166 return result; 196 return result;
167} 197}
168 198
169QString *POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) 199QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list )
170{ 200{
171 QString *result = new QString( "" ); 201 QString result( "" );
172 202
173 bool first = true; 203 bool first = true;
174 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { 204 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
175 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 205 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
176 206
177 if ( !first ) { 207 if ( !first ) {
178 result->append( "," ); 208 result.append( "," );
179 } else { 209 } else {
180 first = false; 210 first = false;
181 } 211 }
182 212
183 QString *tmp = parseMailbox( box ); 213 result.append( parseMailbox( box ) );
184 result->append( *tmp );
185 delete tmp;
186 } 214 }
187 215
188 return result; 216 return result;
189} 217}
190 218
191void POP3wrapper::login() 219void POP3wrapper::login()
192{ 220{
193 if ( m_pop3 != NULL ) logout(); 221 if ( m_pop3 != NULL ) logout();
194 222
195 const char *server, *user, *pass; 223 const char *server, *user, *pass;
196 uint16_t port; 224 uint16_t port;
197 int err = MAILPOP3_NO_ERROR; 225 int err = MAILPOP3_NO_ERROR;
198 226
199 server = account->getServer().latin1(); 227 server = account->getServer().latin1();
200 port = account->getPort().toUInt(); 228 port = account->getPort().toUInt();
201 user = account->getUser().latin1(); 229 user = account->getUser().latin1();
202 pass = account->getPassword().latin1(); 230 pass = account->getPassword().latin1();
203 231
204 m_pop3 = mailpop3_new( 200, &pop3_progress ); 232 m_pop3 = mailpop3_new( 200, &pop3_progress );
205 233
206 // connect 234 // connect
207 if (account->getSSL()) { 235 if (account->getSSL()) {
208 err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); 236 err = mailpop3_ssl_connect( m_pop3, (char*)server, port );
209 } else { 237 } else {
210 err = mailpop3_socket_connect( m_pop3, (char*)server, port ); 238 err = mailpop3_socket_connect( m_pop3, (char*)server, port );
211 } 239 }
212 240
213 if ( err != MAILPOP3_NO_ERROR ) { 241 if ( err != MAILPOP3_NO_ERROR ) {
214 qDebug( "pop3: error connecting to %s\n reason: %s", server, 242 qDebug( "pop3: error connecting to %s\n reason: %s", server,
215 m_pop3->pop3_response ); 243 m_pop3->pop3_response );
216 mailpop3_free( m_pop3 ); 244 mailpop3_free( m_pop3 );
217 m_pop3 = NULL; 245 m_pop3 = NULL;
218 return; 246 return;
219 } 247 }
220 qDebug( "POP3: connected!" ); 248 qDebug( "POP3: connected!" );
221 249
222 // login 250 // login
223 // TODO: decide if apop or plain login should be used 251 // TODO: decide if apop or plain login should be used
224 err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); 252 err = mailpop3_login( m_pop3, (char *) user, (char *) pass );
225 if ( err != MAILPOP3_NO_ERROR ) { 253 if ( err != MAILPOP3_NO_ERROR ) {
226 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); 254 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response );
227 logout(); 255 logout();
228 return; 256 return;
229 } 257 }
230 258
231 qDebug( "POP3: logged in!" ); 259 qDebug( "POP3: logged in!" );
232} 260}
233 261
234void POP3wrapper::logout() 262void POP3wrapper::logout()
235{ 263{
236 int err = MAILPOP3_NO_ERROR; 264 int err = MAILPOP3_NO_ERROR;
237 if ( m_pop3 == NULL ) return; 265 if ( m_pop3 == NULL ) return;
238 err = mailpop3_quit( m_pop3 ); 266 err = mailpop3_quit( m_pop3 );
239 mailpop3_free( m_pop3 ); 267 mailpop3_free( m_pop3 );
240 m_pop3 = NULL; 268 m_pop3 = NULL;
241} 269}
242 270
243
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index 4e4abad..995bed0 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -1,35 +1,38 @@
1#ifndef __POP3WRAPPER 1#ifndef __POP3WRAPPER
2#define __POP3WRAPPER 2#define __POP3WRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5 5
6class RecMail; 6class RecMail;
7class RecBody;
7struct mailpop3; 8struct mailpop3;
8 9
9class POP3wrapper : public QObject 10class POP3wrapper : public QObject
10{ 11{
11 Q_OBJECT 12 Q_OBJECT
12 13
13public: 14public:
14 POP3wrapper( POP3account *a ); 15 POP3wrapper( POP3account *a );
15 virtual ~POP3wrapper(); 16 virtual ~POP3wrapper();
16 void listMessages( QList<RecMail> &target ); 17 void listMessages( QList<RecMail> &target );
18 RecBody fetchBody( const RecMail &mail );
17 static void pop3_progress( size_t current, size_t maximum ); 19 static void pop3_progress( size_t current, size_t maximum );
18 20
19protected: 21protected:
20 void login(); 22 void login();
21 void logout(); 23 void logout();
22 24
23private: 25private:
24 RecMail *parseHeader( const char *header ); 26 RecMail *parseHeader( const char *header );
25 QString *parseMailboxList( mailimf_mailbox_list *list ); 27 RecBody parseBody( const char *message );
26 QString *parseMailbox( mailimf_mailbox *box ); 28 QString parseMailboxList( mailimf_mailbox_list *list );
27 QString *parseGroup( mailimf_group *group ); 29 QString parseMailbox( mailimf_mailbox *box );
28 QString *parseAddressList( mailimf_address_list *list ); 30 QString parseGroup( mailimf_group *group );
29 QString *parseDateTime( mailimf_date_time *date ); 31 QString parseAddressList( mailimf_address_list *list );
32 QString parseDateTime( mailimf_date_time *date );
30 POP3account *account; 33 POP3account *account;
31 mailpop3 *m_pop3; 34 mailpop3 *m_pop3;
32 35
33}; 36};
34 37
35#endif 38#endif
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 633faf6..abb5a42 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -1,243 +1,270 @@
1 1
2#include "pop3wrapper.h" 2#include "pop3wrapper.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4#include <libetpan/mailpop3.h> 4#include <libetpan/mailpop3.h>
5 5
6POP3wrapper::POP3wrapper( POP3account *a ) 6POP3wrapper::POP3wrapper( POP3account *a )
7{ 7{
8 account = a; 8 account = a;
9 m_pop3 = NULL; 9 m_pop3 = NULL;
10} 10}
11 11
12POP3wrapper::~POP3wrapper() 12POP3wrapper::~POP3wrapper()
13{ 13{
14 logout(); 14 logout();
15} 15}
16 16
17void POP3wrapper::pop3_progress( size_t current, size_t maximum ) 17void POP3wrapper::pop3_progress( size_t current, size_t maximum )
18{ 18{
19 qDebug( "POP3: %i of %i", current, maximum ); 19 qDebug( "POP3: %i of %i", current, maximum );
20} 20}
21 21
22RecBody POP3wrapper::fetchBody( const RecMail &mail )
23{
24 int err = MAILPOP3_NO_ERROR;
25 char *message;
26 size_t length;
27
28 login();
29 if ( !m_pop3 ) return RecBody();
30
31 err = mailpop3_retr( m_pop3, mail.getNumber(), &message, &length );
32 if ( err != MAILPOP3_NO_ERROR ) {
33 qDebug( "POP3: error retrieving body with index %i", mail.getNumber() );
34 logout();
35 return RecBody();
36 }
37
38 logout();
39
40 return parseBody( message );
41}
42
43RecBody POP3wrapper::parseBody( const char *message )
44{
45 int err = MAILIMF_NO_ERROR;
46 size_t curTok;
47 mailimf_message *result;
48 RecBody body;
49
50 err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result );
51 if ( err != MAILIMF_NO_ERROR ) return body;
52
53 if ( result && result->msg_body && result->msg_body->bd_text ) {
54 qDebug( "POP3: bodytext found" );
55 // TODO: why does this line segfault???? gdb says segfault in strlen(), maybe a bug in libetpan.
56 body.setBodytext( QString( result->msg_body->bd_text ) );
57 }
58
59 return body;
60}
61
22void POP3wrapper::listMessages( QList<RecMail> &target ) 62void POP3wrapper::listMessages( QList<RecMail> &target )
23{ 63{
24 int err = MAILPOP3_NO_ERROR; 64 int err = MAILPOP3_NO_ERROR;
25 char *header; 65 char *header;
26 size_t length; 66 size_t length;
27 carray *messages; 67 carray *messages;
28 68
29 login(); 69 login();
30 if (!m_pop3) return; 70 if (!m_pop3) return;
31 mailpop3_list( m_pop3, &messages ); 71 mailpop3_list( m_pop3, &messages );
32 72
33 for ( int i = carray_count( messages ); i > 0; i-- ) { 73 for ( int i = carray_count( messages ); i > 0; i-- ) {
34 mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); 74 mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 );
35 75
36 err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); 76 err = mailpop3_header( m_pop3, info->msg_index, &header, &length );
37 if ( err != MAILPOP3_NO_ERROR ) { 77 if ( err != MAILPOP3_NO_ERROR ) {
38 qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); 78 qDebug( "POP3: error retrieving header msgid: %i", info->msg_index );
39 logout(); 79 logout();
40 return; 80 return;
41 } 81 }
42 RecMail *mail = parseHeader( header ); 82 RecMail *mail = parseHeader( header );
43 mail->setNumber( info->msg_index ); 83 mail->setNumber( info->msg_index );
44 target.append( mail ); 84 target.append( mail );
45 } 85 }
46 86
47 logout(); 87 logout();
48} 88}
49 89
50RecMail *POP3wrapper::parseHeader( const char *header ) 90RecMail *POP3wrapper::parseHeader( const char *header )
51{ 91{
52 int err = MAILIMF_NO_ERROR; 92 int err = MAILIMF_NO_ERROR;
53 size_t curTok; 93 size_t curTok;
54 RecMail *mail = new RecMail(); 94 RecMail *mail = new RecMail();
55 mailimf_fields *fields; 95 mailimf_fields *fields;
56 96
57 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); 97 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
58 for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { 98 for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
59 mailimf_field *field = (mailimf_field *) current->data; 99 mailimf_field *field = (mailimf_field *) current->data;
60 switch ( field->fld_type ) { 100 switch ( field->fld_type ) {
61 case MAILIMF_FIELD_FROM: 101 case MAILIMF_FIELD_FROM:
62 mail->setFrom( *parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); 102 mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
63 break; 103 break;
64 case MAILIMF_FIELD_TO: 104 case MAILIMF_FIELD_TO:
65 mail->setTo( *parseAddressList( field->fld_data.fld_to->to_addr_list ) ); 105 mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) );
66 break; 106 break;
67 case MAILIMF_FIELD_CC: 107 case MAILIMF_FIELD_CC:
68 mail->setCC( *parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); 108 mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) );
69 break; 109 break;
70 case MAILIMF_FIELD_BCC: 110 case MAILIMF_FIELD_BCC:
71 mail->setBcc( *parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); 111 mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) );
72 break; 112 break;
73 case MAILIMF_FIELD_SUBJECT: 113 case MAILIMF_FIELD_SUBJECT:
74 mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) ); 114 mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) );
75 break; 115 break;
76 case MAILIMF_FIELD_ORIG_DATE: 116 case MAILIMF_FIELD_ORIG_DATE:
77 mail->setDate( *parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); 117 mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) );
78 break; 118 break;
79 default: 119 default:
80 break; 120 break;
81 } 121 }
82 } 122 }
83 123
84 return mail; 124 return mail;
85} 125}
86 126
87QString *POP3wrapper::parseDateTime( mailimf_date_time *date ) 127QString POP3wrapper::parseDateTime( mailimf_date_time *date )
88{ 128{
89 char tmp[23]; 129 char tmp[23];
90 130
91 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 131 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
92 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 132 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
93 133
94 QString *result = new QString( tmp ); 134 return QString( tmp );
95
96 return result;
97} 135}
98 136
99QString *POP3wrapper::parseAddressList( mailimf_address_list *list ) 137QString POP3wrapper::parseAddressList( mailimf_address_list *list )
100{ 138{
101 QString *result = new QString( "" ); 139 QString result( "" );
102 140
103 bool first = true; 141 bool first = true;
104 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 142 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
105 mailimf_address *addr = (mailimf_address *) current->data; 143 mailimf_address *addr = (mailimf_address *) current->data;
106 144
107 if ( !first ) { 145 if ( !first ) {
108 result->append( "," ); 146 result.append( "," );
109 } else { 147 } else {
110 first = false; 148 first = false;
111 } 149 }
112 150
113 QString *tmp;
114
115 switch ( addr->ad_type ) { 151 switch ( addr->ad_type ) {
116 case MAILIMF_ADDRESS_MAILBOX: 152 case MAILIMF_ADDRESS_MAILBOX:
117 tmp = parseMailbox( addr->ad_data.ad_mailbox ); 153 result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
118 result->append( *tmp );
119 delete tmp;
120 break; 154 break;
121 case MAILIMF_ADDRESS_GROUP: 155 case MAILIMF_ADDRESS_GROUP:
122 tmp = parseGroup( addr->ad_data.ad_group ); 156 result.append( parseGroup( addr->ad_data.ad_group ) );
123 result->append( *tmp );
124 delete tmp;
125 break; 157 break;
126 default: 158 default:
127 qDebug( "POP3: unkown mailimf address type" ); 159 qDebug( "POP3: unkown mailimf address type" );
128 break; 160 break;
129 } 161 }
130 } 162 }
131 163
132 return result; 164 return result;
133} 165}
134 166
135QString *POP3wrapper::parseGroup( mailimf_group *group ) 167QString POP3wrapper::parseGroup( mailimf_group *group )
136{ 168{
137 QString *result = new QString( "" ); 169 QString result( "" );
138 170
139 result->append( group->grp_display_name ); 171 result.append( group->grp_display_name );
140 result->append( ": " ); 172 result.append( ": " );
141 173
142 if ( group->grp_mb_list != NULL ) { 174 if ( group->grp_mb_list != NULL ) {
143 QString *tmp = parseMailboxList( group->grp_mb_list ); 175 result.append( parseMailboxList( group->grp_mb_list ) );
144 result->append( *tmp );
145 delete tmp;
146 } 176 }
147 177
148 result->append( ";" ); 178 result.append( ";" );
149 179
150 return result; 180 return result;
151} 181}
152 182
153QString *POP3wrapper::parseMailbox( mailimf_mailbox *box ) 183QString POP3wrapper::parseMailbox( mailimf_mailbox *box )
154{ 184{
155 QString *result = new QString( "" ); 185 QString result( "" );
156 186
157 if ( box->mb_display_name == NULL ) { 187 if ( box->mb_display_name == NULL ) {
158 result->append( box->mb_addr_spec ); 188 result.append( box->mb_addr_spec );
159 } else { 189 } else {
160 result->append( box->mb_display_name ); 190 result.append( box->mb_display_name );
161 result->append( " <" ); 191 result.append( " <" );
162 result->append( box->mb_addr_spec ); 192 result.append( box->mb_addr_spec );
163 result->append( ">" ); 193 result.append( ">" );
164 } 194 }
165 195
166 return result; 196 return result;
167} 197}
168 198
169QString *POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) 199QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list )
170{ 200{
171 QString *result = new QString( "" ); 201 QString result( "" );
172 202
173 bool first = true; 203 bool first = true;
174 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { 204 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
175 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 205 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
176 206
177 if ( !first ) { 207 if ( !first ) {
178 result->append( "," ); 208 result.append( "," );
179 } else { 209 } else {
180 first = false; 210 first = false;
181 } 211 }
182 212
183 QString *tmp = parseMailbox( box ); 213 result.append( parseMailbox( box ) );
184 result->append( *tmp );
185 delete tmp;
186 } 214 }
187 215
188 return result; 216 return result;
189} 217}
190 218
191void POP3wrapper::login() 219void POP3wrapper::login()
192{ 220{
193 if ( m_pop3 != NULL ) logout(); 221 if ( m_pop3 != NULL ) logout();
194 222
195 const char *server, *user, *pass; 223 const char *server, *user, *pass;
196 uint16_t port; 224 uint16_t port;
197 int err = MAILPOP3_NO_ERROR; 225 int err = MAILPOP3_NO_ERROR;
198 226
199 server = account->getServer().latin1(); 227 server = account->getServer().latin1();
200 port = account->getPort().toUInt(); 228 port = account->getPort().toUInt();
201 user = account->getUser().latin1(); 229 user = account->getUser().latin1();
202 pass = account->getPassword().latin1(); 230 pass = account->getPassword().latin1();
203 231
204 m_pop3 = mailpop3_new( 200, &pop3_progress ); 232 m_pop3 = mailpop3_new( 200, &pop3_progress );
205 233
206 // connect 234 // connect
207 if (account->getSSL()) { 235 if (account->getSSL()) {
208 err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); 236 err = mailpop3_ssl_connect( m_pop3, (char*)server, port );
209 } else { 237 } else {
210 err = mailpop3_socket_connect( m_pop3, (char*)server, port ); 238 err = mailpop3_socket_connect( m_pop3, (char*)server, port );
211 } 239 }
212 240
213 if ( err != MAILPOP3_NO_ERROR ) { 241 if ( err != MAILPOP3_NO_ERROR ) {
214 qDebug( "pop3: error connecting to %s\n reason: %s", server, 242 qDebug( "pop3: error connecting to %s\n reason: %s", server,
215 m_pop3->pop3_response ); 243 m_pop3->pop3_response );
216 mailpop3_free( m_pop3 ); 244 mailpop3_free( m_pop3 );
217 m_pop3 = NULL; 245 m_pop3 = NULL;
218 return; 246 return;
219 } 247 }
220 qDebug( "POP3: connected!" ); 248 qDebug( "POP3: connected!" );
221 249
222 // login 250 // login
223 // TODO: decide if apop or plain login should be used 251 // TODO: decide if apop or plain login should be used
224 err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); 252 err = mailpop3_login( m_pop3, (char *) user, (char *) pass );
225 if ( err != MAILPOP3_NO_ERROR ) { 253 if ( err != MAILPOP3_NO_ERROR ) {
226 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); 254 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response );
227 logout(); 255 logout();
228 return; 256 return;
229 } 257 }
230 258
231 qDebug( "POP3: logged in!" ); 259 qDebug( "POP3: logged in!" );
232} 260}
233 261
234void POP3wrapper::logout() 262void POP3wrapper::logout()
235{ 263{
236 int err = MAILPOP3_NO_ERROR; 264 int err = MAILPOP3_NO_ERROR;
237 if ( m_pop3 == NULL ) return; 265 if ( m_pop3 == NULL ) return;
238 err = mailpop3_quit( m_pop3 ); 266 err = mailpop3_quit( m_pop3 );
239 mailpop3_free( m_pop3 ); 267 mailpop3_free( m_pop3 );
240 m_pop3 = NULL; 268 m_pop3 = NULL;
241} 269}
242 270
243
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h
index 4e4abad..995bed0 100644
--- a/noncore/net/mail/pop3wrapper.h
+++ b/noncore/net/mail/pop3wrapper.h
@@ -1,35 +1,38 @@
1#ifndef __POP3WRAPPER 1#ifndef __POP3WRAPPER
2#define __POP3WRAPPER 2#define __POP3WRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5 5
6class RecMail; 6class RecMail;
7class RecBody;
7struct mailpop3; 8struct mailpop3;
8 9
9class POP3wrapper : public QObject 10class POP3wrapper : public QObject
10{ 11{
11 Q_OBJECT 12 Q_OBJECT
12 13
13public: 14public:
14 POP3wrapper( POP3account *a ); 15 POP3wrapper( POP3account *a );
15 virtual ~POP3wrapper(); 16 virtual ~POP3wrapper();
16 void listMessages( QList<RecMail> &target ); 17 void listMessages( QList<RecMail> &target );
18 RecBody fetchBody( const RecMail &mail );
17 static void pop3_progress( size_t current, size_t maximum ); 19 static void pop3_progress( size_t current, size_t maximum );
18 20
19protected: 21protected:
20 void login(); 22 void login();
21 void logout(); 23 void logout();
22 24
23private: 25private:
24 RecMail *parseHeader( const char *header ); 26 RecMail *parseHeader( const char *header );
25 QString *parseMailboxList( mailimf_mailbox_list *list ); 27 RecBody parseBody( const char *message );
26 QString *parseMailbox( mailimf_mailbox *box ); 28 QString parseMailboxList( mailimf_mailbox_list *list );
27 QString *parseGroup( mailimf_group *group ); 29 QString parseMailbox( mailimf_mailbox *box );
28 QString *parseAddressList( mailimf_address_list *list ); 30 QString parseGroup( mailimf_group *group );
29 QString *parseDateTime( mailimf_date_time *date ); 31 QString parseAddressList( mailimf_address_list *list );
32 QString parseDateTime( mailimf_date_time *date );
30 POP3account *account; 33 POP3account *account;
31 mailpop3 *m_pop3; 34 mailpop3 *m_pop3;
32 35
33}; 36};
34 37
35#endif 38#endif