-rw-r--r-- | noncore/net/mail/accountview.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 111 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 13 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 111 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.h | 13 |
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 | |||
@@ -30,10 +30,10 @@ void POP3viewItem::refresh( QList<RecMail> &target ) | |||
30 | } | 30 | } |
31 | 31 | ||
32 | 32 | ||
33 | RecBody POP3viewItem::fetchBody( const RecMail & ) | 33 | RecBody 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 | /** |
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 | |||
@@ -29,7 +29,7 @@ public: | |||
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 | ||
34 | private: | 34 | private: |
35 | POP3account *account; | 35 | POP3account *account; |
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 | |||
@@ -19,6 +19,46 @@ void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | |||
19 | qDebug( "POP3: %i of %i", current, maximum ); | 19 | qDebug( "POP3: %i of %i", current, maximum ); |
20 | } | 20 | } |
21 | 21 | ||
22 | RecBody 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 | |||
43 | RecBody 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 | |||
22 | void POP3wrapper::listMessages( QList<RecMail> &target ) | 62 | void POP3wrapper::listMessages( QList<RecMail> &target ) |
23 | { | 63 | { |
24 | int err = MAILPOP3_NO_ERROR; | 64 | int err = MAILPOP3_NO_ERROR; |
@@ -59,22 +99,22 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
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; |
@@ -84,44 +124,36 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
84 | return mail; | 124 | return mail; |
85 | } | 125 | } |
86 | 126 | ||
87 | QString *POP3wrapper::parseDateTime( mailimf_date_time *date ) | 127 | QString 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 | ||
99 | QString *POP3wrapper::parseAddressList( mailimf_address_list *list ) | 137 | QString 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" ); |
@@ -132,57 +164,53 @@ QString *POP3wrapper::parseAddressList( mailimf_address_list *list ) | |||
132 | return result; | 164 | return result; |
133 | } | 165 | } |
134 | 166 | ||
135 | QString *POP3wrapper::parseGroup( mailimf_group *group ) | 167 | QString 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 | ||
153 | QString *POP3wrapper::parseMailbox( mailimf_mailbox *box ) | 183 | QString 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 | ||
169 | QString *POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) | 199 | QString 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; |
@@ -240,4 +268,3 @@ void POP3wrapper::logout() | |||
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 | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | 5 | ||
6 | class RecMail; | 6 | class RecMail; |
7 | class RecBody; | ||
7 | struct mailpop3; | 8 | struct mailpop3; |
8 | 9 | ||
9 | class POP3wrapper : public QObject | 10 | class POP3wrapper : public QObject |
@@ -14,6 +15,7 @@ public: | |||
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 | ||
19 | protected: | 21 | protected: |
@@ -22,11 +24,12 @@ protected: | |||
22 | 24 | ||
23 | private: | 25 | private: |
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 | ||
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 | |||
@@ -19,6 +19,46 @@ void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | |||
19 | qDebug( "POP3: %i of %i", current, maximum ); | 19 | qDebug( "POP3: %i of %i", current, maximum ); |
20 | } | 20 | } |
21 | 21 | ||
22 | RecBody 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 | |||
43 | RecBody 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 | |||
22 | void POP3wrapper::listMessages( QList<RecMail> &target ) | 62 | void POP3wrapper::listMessages( QList<RecMail> &target ) |
23 | { | 63 | { |
24 | int err = MAILPOP3_NO_ERROR; | 64 | int err = MAILPOP3_NO_ERROR; |
@@ -59,22 +99,22 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
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; |
@@ -84,44 +124,36 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
84 | return mail; | 124 | return mail; |
85 | } | 125 | } |
86 | 126 | ||
87 | QString *POP3wrapper::parseDateTime( mailimf_date_time *date ) | 127 | QString 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 | ||
99 | QString *POP3wrapper::parseAddressList( mailimf_address_list *list ) | 137 | QString 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" ); |
@@ -132,57 +164,53 @@ QString *POP3wrapper::parseAddressList( mailimf_address_list *list ) | |||
132 | return result; | 164 | return result; |
133 | } | 165 | } |
134 | 166 | ||
135 | QString *POP3wrapper::parseGroup( mailimf_group *group ) | 167 | QString 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 | ||
153 | QString *POP3wrapper::parseMailbox( mailimf_mailbox *box ) | 183 | QString 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 | ||
169 | QString *POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) | 199 | QString 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; |
@@ -240,4 +268,3 @@ void POP3wrapper::logout() | |||
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 | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | 5 | ||
6 | class RecMail; | 6 | class RecMail; |
7 | class RecBody; | ||
7 | struct mailpop3; | 8 | struct mailpop3; |
8 | 9 | ||
9 | class POP3wrapper : public QObject | 10 | class POP3wrapper : public QObject |
@@ -14,6 +15,7 @@ public: | |||
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 | ||
19 | protected: | 21 | protected: |
@@ -22,11 +24,12 @@ protected: | |||
22 | 24 | ||
23 | private: | 25 | private: |
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 | ||