summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp41
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h1
-rw-r--r--noncore/net/mail/pop3wrapper.cpp41
-rw-r--r--noncore/net/mail/pop3wrapper.h1
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 )
8 account = a; 8 account = a;
9 m_pop3 = NULL;
9} 10}
@@ -22,4 +23,24 @@ void POP3wrapper::listMessages( QList<RecMail> &target )
22{ 23{
24 int err = MAILPOP3_NO_ERROR;
25 char *header;
26 size_t length;
27 carray *messages;
28
23 login(); 29 login();
24 //TODO: list messages 30 mailpop3_list( m_pop3, &messages );
31
32 for ( int i = carray_count( messages ); i > 0; i-- ) {
33 mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 );
34
35 err = mailpop3_header( m_pop3, info->index, &header, &length );
36 if ( err != MAILPOP3_NO_ERROR ) {
37 qDebug( "POP3: error retrieving header msgid: %i", info->index );
38 logout();
39 return;
40 }
41 RecMail *mail = parseHeader( header );
42 mail->setNumber( info->index );
43 target.append( mail );
44 }
45
25 logout(); 46 logout();
@@ -27,5 +48,17 @@ void POP3wrapper::listMessages( QList<RecMail> &target )
27 48
49RecMail *POP3wrapper::parseHeader( const char *h )
50{
51 RecMail *mail = new RecMail();
52 QString header( h );
53
54 //TODO: parse header - maybe something like this is already implemented in libetpan?
55 mail->setSubject( "Blah blubb" );
56
57 return mail;
58}
59
28void POP3wrapper::login() 60void POP3wrapper::login()
29{ 61{
30 logout(); 62 if ( m_pop3 != NULL ) logout();
63
31 const char *server, *user, *pass; 64 const char *server, *user, *pass;
@@ -39,3 +72,3 @@ void POP3wrapper::login()
39 72
40 m_pop3 = mailpop3_new( 20, &pop3_progress ); 73 m_pop3 = mailpop3_new( 200, &pop3_progress );
41 74
@@ -67,3 +100,3 @@ void POP3wrapper::logout()
67 int err = MAILPOP3_NO_ERROR; 100 int err = MAILPOP3_NO_ERROR;
68 if ( !m_pop3 ) return; 101 if ( m_pop3 == NULL ) return;
69 err = mailpop3_quit( m_pop3 ); 102 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:
22private: 22private:
23 RecMail *parseHeader( const char *header );
23 POP3account *account; 24 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 )
8 account = a; 8 account = a;
9 m_pop3 = NULL;
9} 10}
@@ -22,4 +23,24 @@ void POP3wrapper::listMessages( QList<RecMail> &target )
22{ 23{
24 int err = MAILPOP3_NO_ERROR;
25 char *header;
26 size_t length;
27 carray *messages;
28
23 login(); 29 login();
24 //TODO: list messages 30 mailpop3_list( m_pop3, &messages );
31
32 for ( int i = carray_count( messages ); i > 0; i-- ) {
33 mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 );
34
35 err = mailpop3_header( m_pop3, info->index, &header, &length );
36 if ( err != MAILPOP3_NO_ERROR ) {
37 qDebug( "POP3: error retrieving header msgid: %i", info->index );
38 logout();
39 return;
40 }
41 RecMail *mail = parseHeader( header );
42 mail->setNumber( info->index );
43 target.append( mail );
44 }
45
25 logout(); 46 logout();
@@ -27,5 +48,17 @@ void POP3wrapper::listMessages( QList<RecMail> &target )
27 48
49RecMail *POP3wrapper::parseHeader( const char *h )
50{
51 RecMail *mail = new RecMail();
52 QString header( h );
53
54 //TODO: parse header - maybe something like this is already implemented in libetpan?
55 mail->setSubject( "Blah blubb" );
56
57 return mail;
58}
59
28void POP3wrapper::login() 60void POP3wrapper::login()
29{ 61{
30 logout(); 62 if ( m_pop3 != NULL ) logout();
63
31 const char *server, *user, *pass; 64 const char *server, *user, *pass;
@@ -39,3 +72,3 @@ void POP3wrapper::login()
39 72
40 m_pop3 = mailpop3_new( 20, &pop3_progress ); 73 m_pop3 = mailpop3_new( 200, &pop3_progress );
41 74
@@ -67,3 +100,3 @@ void POP3wrapper::logout()
67 int err = MAILPOP3_NO_ERROR; 100 int err = MAILPOP3_NO_ERROR;
68 if ( !m_pop3 ) return; 101 if ( m_pop3 == NULL ) return;
69 err = mailpop3_quit( m_pop3 ); 102 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:
22private: 22private:
23 RecMail *parseHeader( const char *header );
23 POP3account *account; 24 POP3account *account;