Diffstat (limited to 'noncore/net/mail/pop3wrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp index abb5a42..49c3b7a 100644 --- a/noncore/net/mail/pop3wrapper.cpp +++ b/noncore/net/mail/pop3wrapper.cpp | |||
@@ -38,49 +38,49 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) | |||
38 | logout(); | 38 | logout(); |
39 | 39 | ||
40 | return parseBody( message ); | 40 | return parseBody( message ); |
41 | } | 41 | } |
42 | 42 | ||
43 | RecBody POP3wrapper::parseBody( const char *message ) | 43 | RecBody POP3wrapper::parseBody( const char *message ) |
44 | { | 44 | { |
45 | int err = MAILIMF_NO_ERROR; | 45 | int err = MAILIMF_NO_ERROR; |
46 | size_t curTok; | 46 | size_t curTok; |
47 | mailimf_message *result; | 47 | mailimf_message *result; |
48 | RecBody body; | 48 | RecBody body; |
49 | 49 | ||
50 | err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result ); | 50 | err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result ); |
51 | if ( err != MAILIMF_NO_ERROR ) return body; | 51 | if ( err != MAILIMF_NO_ERROR ) return body; |
52 | 52 | ||
53 | if ( result && result->msg_body && result->msg_body->bd_text ) { | 53 | if ( result && result->msg_body && result->msg_body->bd_text ) { |
54 | qDebug( "POP3: bodytext found" ); | 54 | qDebug( "POP3: bodytext found" ); |
55 | // TODO: why does this line segfault???? gdb says segfault in strlen(), maybe a bug in libetpan. | 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 ) ); | 56 | body.setBodytext( QString( result->msg_body->bd_text ) ); |
57 | } | 57 | } |
58 | 58 | ||
59 | return body; | 59 | return body; |
60 | } | 60 | } |
61 | 61 | ||
62 | void POP3wrapper::listMessages( QList<RecMail> &target ) | 62 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) |
63 | { | 63 | { |
64 | int err = MAILPOP3_NO_ERROR; | 64 | int err = MAILPOP3_NO_ERROR; |
65 | char *header; | 65 | char *header; |
66 | size_t length; | 66 | size_t length; |
67 | carray *messages; | 67 | carray *messages; |
68 | 68 | ||
69 | login(); | 69 | login(); |
70 | if (!m_pop3) return; | 70 | if (!m_pop3) return; |
71 | mailpop3_list( m_pop3, &messages ); | 71 | mailpop3_list( m_pop3, &messages ); |
72 | 72 | ||
73 | for ( int i = carray_count( messages ); i > 0; i-- ) { | 73 | for ( int i = carray_count( messages ); i > 0; i-- ) { |
74 | 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 ); |
75 | 75 | ||
76 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); | 76 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); |
77 | if ( err != MAILPOP3_NO_ERROR ) { | 77 | if ( err != MAILPOP3_NO_ERROR ) { |
78 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); | 78 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); |
79 | logout(); | 79 | logout(); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | RecMail *mail = parseHeader( header ); | 82 | RecMail *mail = parseHeader( header ); |
83 | mail->setNumber( info->msg_index ); | 83 | mail->setNumber( info->msg_index ); |
84 | target.append( mail ); | 84 | target.append( mail ); |
85 | } | 85 | } |
86 | 86 | ||
@@ -247,24 +247,43 @@ void POP3wrapper::login() | |||
247 | } | 247 | } |
248 | qDebug( "POP3: connected!" ); | 248 | qDebug( "POP3: connected!" ); |
249 | 249 | ||
250 | // login | 250 | // login |
251 | // TODO: decide if apop or plain login should be used | 251 | // TODO: decide if apop or plain login should be used |
252 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); | 252 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); |
253 | if ( err != MAILPOP3_NO_ERROR ) { | 253 | if ( err != MAILPOP3_NO_ERROR ) { |
254 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); | 254 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); |
255 | logout(); | 255 | logout(); |
256 | return; | 256 | return; |
257 | } | 257 | } |
258 | 258 | ||
259 | qDebug( "POP3: logged in!" ); | 259 | qDebug( "POP3: logged in!" ); |
260 | } | 260 | } |
261 | 261 | ||
262 | void POP3wrapper::logout() | 262 | void POP3wrapper::logout() |
263 | { | 263 | { |
264 | int err = MAILPOP3_NO_ERROR; | 264 | int err = MAILPOP3_NO_ERROR; |
265 | if ( m_pop3 == NULL ) return; | 265 | if ( m_pop3 == NULL ) return; |
266 | err = mailpop3_quit( m_pop3 ); | 266 | err = mailpop3_quit( m_pop3 ); |
267 | mailpop3_free( m_pop3 ); | 267 | mailpop3_free( m_pop3 ); |
268 | m_pop3 = NULL; | 268 | m_pop3 = NULL; |
269 | } | 269 | } |
270 | 270 | ||
271 | |||
272 | QList<Folder>* POP3wrapper::listFolders() | ||
273 | { | ||
274 | QList<Folder> * folders = new QList<Folder>(); | ||
275 | folders->setAutoDelete( true ); | ||
276 | Folder*inb=new Folder("INBOX"); | ||
277 | folders->append(inb); | ||
278 | return folders; | ||
279 | } | ||
280 | |||
281 | QString POP3wrapper::fetchPart(const RecMail&,const QValueList<int>&,bool) | ||
282 | { | ||
283 | return ""; | ||
284 | } | ||
285 | |||
286 | QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) | ||
287 | { | ||
288 | return ""; | ||
289 | } | ||