summaryrefslogtreecommitdiff
path: root/noncore/net/mail/pop3wrapper.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/mail/pop3wrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/pop3wrapper.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index efd83ba..b85fbf6 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -1,31 +1,30 @@
#include <stdlib.h>
#include "pop3wrapper.h"
#include "mailtypes.h"
#include "logindialog.h"
-#include <libetpan/mailpop3.h>
-#include <libetpan/mailmime.h>
-#include <libetpan/data_message_driver.h>
+#include <libetpan/libetpan.h>
+#include <qpe/global.h>
#include <qfile.h>
/* we don't fetch messages larger than 5 MB */
#define HARD_MSG_SIZE_LIMIT 5242880
POP3wrapper::POP3wrapper( POP3account *a )
: Genericwrapper()
{
account = a;
m_pop3 = NULL;
msgTempName = a->getFileName()+"_msg_cache";
last_msg_id = 0;
}
POP3wrapper::~POP3wrapper()
{
logout();
QFile msg_cache(msgTempName);
if (msg_cache.exists()) {
msg_cache.remove();
}
}
void POP3wrapper::pop3_progress( size_t current, size_t maximum )
@@ -91,68 +90,70 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail )
msg_data->msg_message = message;
msg_data->msg_length = strlen(message);
/* parse the mail */
body = parseMail(msg);
/* clean up */
mailmessage_free(msg);
free(message);
/* finish */
return body;
}
void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
{
int err = MAILPOP3_NO_ERROR;
char * header = 0;
/* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
size_t length = 0;
carray * messages = 0;
login();
if (!m_pop3) return;
+
mailpop3_list( m_pop3, &messages );
for (unsigned int i = 0; i < carray_count(messages);++i) {
mailpop3_msg_info *info;
err = mailpop3_get_msg_info(m_pop3,i+1,&info);
if (info->msg_deleted)
continue;
err = mailpop3_header( m_pop3, info->msg_index, &header, &length );
if ( err != MAILPOP3_NO_ERROR ) {
qDebug( "POP3: error retrieving header msgid: %i", info->msg_index );
free(header);
return;
}
RecMail *mail = parseHeader( header );
mail->setNumber( info->msg_index );
mail->setWrapper(this);
mail->setMsgsize(info->msg_size);
target.append( mail );
free(header);
}
+ Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(carray_count(messages)-m_pop3->pop3_deleted_count));
}
void POP3wrapper::login()
{
/* we'll hold the line */
if ( m_pop3 != NULL ) return;
const char *server, *user, *pass;
uint16_t port;
int err = MAILPOP3_NO_ERROR;
server = account->getServer().latin1();
port = account->getPort().toUInt();
if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
user = strdup( login.getUser().latin1() );
pass = strdup( login.getPassword().latin1() );
} else {
// cancel
qDebug( "POP3: Login canceled" );