Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 74 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 28 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 4 |
3 files changed, 102 insertions, 4 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp new file mode 100644 index 0000000..08e97f4 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp @@ -0,0 +1,74 @@ + +#include "pop3wrapper.h" +#include "mailtypes.h" +#include <libetpan/mailpop3.h> + +POP3wrapper::POP3wrapper( POP3account *a ) +{ + account = a; +} + +POP3wrapper::~POP3wrapper() +{ + logout(); +} + +void POP3wrapper::pop3_progress( size_t current, size_t maximum ) +{ + qDebug( "POP3: %i of %i", current, maximum ); +} + +void POP3wrapper::listMessages( QList<RecMail> &target ) +{ + login(); + //TODO: list messages + logout(); +} + +void POP3wrapper::login() +{ + logout(); + const char *server, *user, *pass; + uint16_t port; + int err = MAILPOP3_NO_ERROR; + + server = account->getServer().latin1(); + port = account->getPort().toUInt(); + user = account->getUser().latin1(); + pass = account->getPassword().latin1(); + + m_pop3 = mailpop3_new( 20, &pop3_progress ); + + // connect + err = mailpop3_socket_connect( m_pop3, (char *) server, port ); + if ( err != MAILPOP3_NO_ERROR ) { + qDebug( "pop3: error connecting to %s\n reason: %s", server, + m_pop3->response ); + mailpop3_free( m_pop3 ); + m_pop3 = NULL; + return; + } + qDebug( "POP3: connected!" ); + + // login + // TODO: decide if apop or plain login should be used + err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); + if ( err != MAILPOP3_NO_ERROR ) { + qDebug( "pop3: error logging in: %s", m_pop3->response ); + logout(); + return; + } + + qDebug( "POP3: logged in!" ); +} + +void POP3wrapper::logout() +{ + int err = MAILPOP3_NO_ERROR; + if ( !m_pop3 ) return; + err = mailpop3_quit( m_pop3 ); + mailpop3_free( m_pop3 ); + m_pop3 = NULL; +} + + diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h new file mode 100644 index 0000000..b791409 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h @@ -0,0 +1,28 @@ +#ifndef __POP3WRAPPER +#define __POP3WRAPPER + +#include "mailwrapper.h" + +class RecMail; + +class POP3wrapper : public QObject +{ + Q_OBJECT + +public: + POP3wrapper( POP3account *a ); + virtual ~POP3wrapper(); + void listMessages( QList<RecMail> &target ); + static void pop3_progress( size_t current, size_t maximum ); + +protected: + void login(); + void logout(); + +private: + POP3account *account; + mailpop3 *m_pop3; + +}; + +#endif diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 9632301..b580954 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp @@ -134,3 +134,2 @@ QString IMAPaccount::getUniqueFileName() QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; @@ -212,3 +211,2 @@ QString POP3account::getUniqueFileName() QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; @@ -290,3 +288,2 @@ QString SMTPaccount::getUniqueFileName() QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; @@ -386,3 +383,2 @@ QString NNTPaccount::getUniqueFileName() QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; |