author | jgf <jgf> | 2003-12-10 08:59:11 (UTC) |
---|---|---|
committer | jgf <jgf> | 2003-12-10 08:59:11 (UTC) |
commit | 434db5193380185cc1b6347ff5882ad558f401d4 (patch) (side-by-side diff) | |
tree | 0ebffad568e343ebb650dec9ed19699b91eb5961 /noncore/net/mail | |
parent | 9754061378940cf1d7637262305239deedc732b7 (diff) | |
download | opie-434db5193380185cc1b6347ff5882ad558f401d4.zip opie-434db5193380185cc1b6347ff5882ad558f401d4.tar.gz opie-434db5193380185cc1b6347ff5882ad558f401d4.tar.bz2 |
retrieve headers from mailbox
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 41 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 41 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.h | 1 |
4 files changed, 76 insertions, 8 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 08e97f4..6decb6a 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp @@ -8,2 +8,3 @@ POP3wrapper::POP3wrapper( POP3account *a ) account = a; + m_pop3 = NULL; } @@ -22,4 +23,24 @@ void POP3wrapper::listMessages( QList<RecMail> &target ) { + int err = MAILPOP3_NO_ERROR; + char *header; + size_t length; + carray *messages; + login(); - //TODO: list messages + mailpop3_list( m_pop3, &messages ); + + for ( int i = carray_count( messages ); i > 0; i-- ) { + mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); + + err = mailpop3_header( m_pop3, info->index, &header, &length ); + if ( err != MAILPOP3_NO_ERROR ) { + qDebug( "POP3: error retrieving header msgid: %i", info->index ); + logout(); + return; + } + RecMail *mail = parseHeader( header ); + mail->setNumber( info->index ); + target.append( mail ); + } + logout(); @@ -27,5 +48,17 @@ void POP3wrapper::listMessages( QList<RecMail> &target ) +RecMail *POP3wrapper::parseHeader( const char *h ) +{ + RecMail *mail = new RecMail(); + QString header( h ); + + //TODO: parse header - maybe something like this is already implemented in libetpan? + mail->setSubject( "Blah blubb" ); + + return mail; +} + void POP3wrapper::login() { - logout(); + if ( m_pop3 != NULL ) logout(); + const char *server, *user, *pass; @@ -39,3 +72,3 @@ void POP3wrapper::login() - m_pop3 = mailpop3_new( 20, &pop3_progress ); + m_pop3 = mailpop3_new( 200, &pop3_progress ); @@ -67,3 +100,3 @@ void POP3wrapper::logout() int err = MAILPOP3_NO_ERROR; - if ( !m_pop3 ) return; + if ( m_pop3 == NULL ) return; err = mailpop3_quit( m_pop3 ); diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index b791409..f242746 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h @@ -22,2 +22,3 @@ protected: private: + RecMail *parseHeader( const char *header ); POP3account *account; diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp index 08e97f4..6decb6a 100644 --- a/noncore/net/mail/pop3wrapper.cpp +++ b/noncore/net/mail/pop3wrapper.cpp @@ -8,2 +8,3 @@ POP3wrapper::POP3wrapper( POP3account *a ) account = a; + m_pop3 = NULL; } @@ -22,4 +23,24 @@ void POP3wrapper::listMessages( QList<RecMail> &target ) { + int err = MAILPOP3_NO_ERROR; + char *header; + size_t length; + carray *messages; + login(); - //TODO: list messages + mailpop3_list( m_pop3, &messages ); + + for ( int i = carray_count( messages ); i > 0; i-- ) { + mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); + + err = mailpop3_header( m_pop3, info->index, &header, &length ); + if ( err != MAILPOP3_NO_ERROR ) { + qDebug( "POP3: error retrieving header msgid: %i", info->index ); + logout(); + return; + } + RecMail *mail = parseHeader( header ); + mail->setNumber( info->index ); + target.append( mail ); + } + logout(); @@ -27,5 +48,17 @@ void POP3wrapper::listMessages( QList<RecMail> &target ) +RecMail *POP3wrapper::parseHeader( const char *h ) +{ + RecMail *mail = new RecMail(); + QString header( h ); + + //TODO: parse header - maybe something like this is already implemented in libetpan? + mail->setSubject( "Blah blubb" ); + + return mail; +} + void POP3wrapper::login() { - logout(); + if ( m_pop3 != NULL ) logout(); + const char *server, *user, *pass; @@ -39,3 +72,3 @@ void POP3wrapper::login() - m_pop3 = mailpop3_new( 20, &pop3_progress ); + m_pop3 = mailpop3_new( 200, &pop3_progress ); @@ -67,3 +100,3 @@ void POP3wrapper::logout() int err = MAILPOP3_NO_ERROR; - if ( !m_pop3 ) return; + if ( m_pop3 == NULL ) return; err = mailpop3_quit( m_pop3 ); diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h index b791409..f242746 100644 --- a/noncore/net/mail/pop3wrapper.h +++ b/noncore/net/mail/pop3wrapper.h @@ -22,2 +22,3 @@ protected: private: + RecMail *parseHeader( const char *header ); POP3account *account; |