summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp60
-rw-r--r--noncore/net/mail/accountview.h16
-rw-r--r--noncore/net/mail/defines.h2
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp57
-rw-r--r--noncore/net/mail/pop3wrapper.cpp57
5 files changed, 153 insertions, 39 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index d725b87..8e21d39 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -23,8 +23,26 @@ POP3viewItem::~POP3viewItem()
-void POP3viewItem::refresh( QList<RecMail> &target )
+AbstractMail *POP3viewItem::getWrapper()
{
- qDebug( "POP3: refresh" );
- wrapper->listMessages("INBOX", target );
+ return wrapper;
}
+void POP3viewItem::refresh( QList<RecMail> & )
+{
+ QList<Folder> *folders = wrapper->listFolders();
+ QListViewItem *child = firstChild();
+ while ( child ) {
+ QListViewItem *tmp = child;
+ child = child->nextSibling();
+ delete tmp;
+ }
+ Folder *it;
+ QListViewItem*item = 0;
+ for ( it = folders->first(); it; it = folders->next() ) {
+ item = new POP3folderItem( it, this , item );
+ item->setSelectable(it->may_select());
+ }
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ folders->setAutoDelete(false);
+ delete folders;
+}
@@ -36,2 +54,31 @@ RecBody POP3viewItem::fetchBody( const RecMail &mail )
+POP3folderItem::~POP3folderItem()
+{
+ delete folder;
+}
+
+POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after )
+ : AccountViewItem( parent,after )
+{
+ folder = folderInit;
+ pop3 = parent;
+ if (folder->getDisplayName().lower()!="inbox") {
+ setPixmap( 0, PIXMAP_POP3FOLDER );
+ } else {
+ setPixmap( 0, PIXMAP_INBOXFOLDER);
+ }
+ setText( 0, folder->getDisplayName() );
+}
+
+void POP3folderItem::refresh(QList<RecMail>&target)
+{
+ if (folder->may_select())
+ pop3->getWrapper()->listMessages( folder->getName(),target );
+}
+
+RecBody POP3folderItem::fetchBody(const RecMail&aMail)
+{
+ return pop3->getWrapper()->fetchBody(aMail);
+}
+
/**
@@ -39,3 +86,2 @@ RecBody POP3viewItem::fetchBody( const RecMail &mail )
*/
-
IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent )
@@ -97,3 +143,7 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QList
imap = parent;
- setPixmap( 0, PIXMAP_IMAPFOLDER );
+ if (folder->getDisplayName().lower()!="inbox") {
+ setPixmap( 0, PIXMAP_IMAPFOLDER );
+ } else {
+ setPixmap( 0, PIXMAP_INBOXFOLDER);
+ }
setText( 0, folder->getDisplayName() );
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 04f9b7a..d035af4 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -33,3 +33,3 @@ public:
virtual RecBody fetchBody( const RecMail &mail );
-
+ AbstractMail *getWrapper();
private:
@@ -40,2 +40,15 @@ private:
+class POP3folderItem : public AccountViewItem
+{
+
+public:
+ POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
+ ~POP3folderItem();
+ virtual void refresh(QList<RecMail>&);
+ virtual RecBody fetchBody(const RecMail&);
+private:
+ Folder *folder;
+ POP3viewItem *pop3;
+};
+
class IMAPviewItem : public AccountViewItem
@@ -65,3 +78,2 @@ private:
IMAPviewItem *imap;
-
};
diff --git a/noncore/net/mail/defines.h b/noncore/net/mail/defines.h
index 679459d..c849f1a 100644
--- a/noncore/net/mail/defines.h
+++ b/noncore/net/mail/defines.h
@@ -16,2 +16,3 @@
#define PIC_POP3FOLDER "opiemail/pop3folder"
+#define PIC_INBOXFOLDER "opiemail/inbox"
@@ -27,2 +28,3 @@
#define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) )
+#define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) )
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 46c854b..2411399 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -1,2 +1,2 @@
-
+#include <stdlib.h>
#include "pop3wrapper.h"
@@ -45,4 +45,5 @@ RecBody POP3wrapper::parseBody( const char *message )
int err = MAILIMF_NO_ERROR;
- size_t curTok;
- mailimf_message *result;
+ /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
+ size_t curTok = 0;
+ mailimf_message *result = 0;
RecBody body;
@@ -50,3 +51,6 @@ RecBody POP3wrapper::parseBody( const char *message )
err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result );
- if ( err != MAILIMF_NO_ERROR ) return body;
+ if ( err != MAILIMF_NO_ERROR ) {
+ if (result) mailimf_message_free(result);
+ return body;
+ }
@@ -54,6 +58,6 @@ RecBody POP3wrapper::parseBody( const char *message )
qDebug( "POP3: bodytext found" );
- // TODO: why does this line segfault???? gdb says segfault in strlen(), maybe a bug in libetpan.
+ // when curTok isn't set to 0 this line will fault! 'cause upper line faults!
body.setBodytext( QString( result->msg_body->bd_text ) );
}
-
+ if (result) mailimf_message_free(result);
return body;
@@ -64,5 +68,6 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
int err = MAILPOP3_NO_ERROR;
- char *header;
- size_t length;
- carray *messages;
+ char * header = 0;
+ /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
+ size_t length = 0;
+ carray * messages = 0;
@@ -72,5 +77,6 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
- for ( int i = carray_count( messages ); i > 0; i-- ) {
- mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 );
-
+ //for ( int i = carray_count( messages ); i > 0; i-- ) {
+ for (unsigned int i = 0; i < carray_count(messages);++i) {
+ mailpop3_msg_info *info;
+ int r = mailpop3_get_msg_info(m_pop3,i+1,&info);
err = mailpop3_header( m_pop3, info->msg_index, &header, &length );
@@ -78,2 +84,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
qDebug( "POP3: error retrieving header msgid: %i", info->msg_index );
+ free(header);
logout();
@@ -85,4 +92,4 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
target.append( mail );
+ free(header);
}
-
logout();
@@ -93,6 +100,8 @@ RecMail *POP3wrapper::parseHeader( const char *header )
int err = MAILIMF_NO_ERROR;
- size_t curTok;
+ size_t curTok = 0;
RecMail *mail = new RecMail();
mailimf_fields *fields;
-
+ mailimf_references * refs;
+ mailimf_keywords*keys;
+
err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
@@ -119,2 +128,18 @@ RecMail *POP3wrapper::parseHeader( const char *header )
break;
+ case MAILIMF_FIELD_MESSAGE_ID:
+ mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value));
+ break;
+ case MAILIMF_FIELD_REFERENCES:
+ refs = field->fld_data.fld_references;
+ if (refs && refs->mid_list && clist_count(refs->mid_list)) {
+ char * text = (char*)refs->mid_list->first->data;
+ mail->setReplyto(QString(text));
+ }
+ break;
+ case MAILIMF_FIELD_KEYWORDS:
+ keys = field->fld_data.fld_keywords;
+ for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) {
+ qDebug("Keyword: %s",(char*)cur->data);
+ }
+ break;
default:
@@ -123,3 +148,3 @@ RecMail *POP3wrapper::parseHeader( const char *header )
}
-
+ if (fields) mailimf_fields_free(fields);
return mail;
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 46c854b..2411399 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -1,2 +1,2 @@
-
+#include <stdlib.h>
#include "pop3wrapper.h"
@@ -45,4 +45,5 @@ RecBody POP3wrapper::parseBody( const char *message )
int err = MAILIMF_NO_ERROR;
- size_t curTok;
- mailimf_message *result;
+ /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
+ size_t curTok = 0;
+ mailimf_message *result = 0;
RecBody body;
@@ -50,3 +51,6 @@ RecBody POP3wrapper::parseBody( const char *message )
err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result );
- if ( err != MAILIMF_NO_ERROR ) return body;
+ if ( err != MAILIMF_NO_ERROR ) {
+ if (result) mailimf_message_free(result);
+ return body;
+ }
@@ -54,6 +58,6 @@ RecBody POP3wrapper::parseBody( const char *message )
qDebug( "POP3: bodytext found" );
- // TODO: why does this line segfault???? gdb says segfault in strlen(), maybe a bug in libetpan.
+ // when curTok isn't set to 0 this line will fault! 'cause upper line faults!
body.setBodytext( QString( result->msg_body->bd_text ) );
}
-
+ if (result) mailimf_message_free(result);
return body;
@@ -64,5 +68,6 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
int err = MAILPOP3_NO_ERROR;
- char *header;
- size_t length;
- carray *messages;
+ char * header = 0;
+ /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
+ size_t length = 0;
+ carray * messages = 0;
@@ -72,5 +77,6 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
- for ( int i = carray_count( messages ); i > 0; i-- ) {
- mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 );
-
+ //for ( int i = carray_count( messages ); i > 0; i-- ) {
+ for (unsigned int i = 0; i < carray_count(messages);++i) {
+ mailpop3_msg_info *info;
+ int r = mailpop3_get_msg_info(m_pop3,i+1,&info);
err = mailpop3_header( m_pop3, info->msg_index, &header, &length );
@@ -78,2 +84,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
qDebug( "POP3: error retrieving header msgid: %i", info->msg_index );
+ free(header);
logout();
@@ -85,4 +92,4 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
target.append( mail );
+ free(header);
}
-
logout();
@@ -93,6 +100,8 @@ RecMail *POP3wrapper::parseHeader( const char *header )
int err = MAILIMF_NO_ERROR;
- size_t curTok;
+ size_t curTok = 0;
RecMail *mail = new RecMail();
mailimf_fields *fields;
-
+ mailimf_references * refs;
+ mailimf_keywords*keys;
+
err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
@@ -119,2 +128,18 @@ RecMail *POP3wrapper::parseHeader( const char *header )
break;
+ case MAILIMF_FIELD_MESSAGE_ID:
+ mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value));
+ break;
+ case MAILIMF_FIELD_REFERENCES:
+ refs = field->fld_data.fld_references;
+ if (refs && refs->mid_list && clist_count(refs->mid_list)) {
+ char * text = (char*)refs->mid_list->first->data;
+ mail->setReplyto(QString(text));
+ }
+ break;
+ case MAILIMF_FIELD_KEYWORDS:
+ keys = field->fld_data.fld_keywords;
+ for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) {
+ qDebug("Keyword: %s",(char*)cur->data);
+ }
+ break;
default:
@@ -123,3 +148,3 @@ RecMail *POP3wrapper::parseHeader( const char *header )
}
-
+ if (fields) mailimf_fields_free(fields);
return mail;