-rw-r--r-- | noncore/net/mail/accountview.cpp | 60 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 16 | ||||
-rw-r--r-- | noncore/net/mail/defines.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 57 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 57 |
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 | |||
@@ -22,10 +22,28 @@ POP3viewItem::~POP3viewItem() | |||
22 | } | 22 | } |
23 | 23 | ||
24 | void POP3viewItem::refresh( QList<RecMail> &target ) | 24 | AbstractMail *POP3viewItem::getWrapper() |
25 | { | 25 | { |
26 | qDebug( "POP3: refresh" ); | 26 | return wrapper; |
27 | wrapper->listMessages("INBOX", target ); | ||
28 | } | 27 | } |
29 | 28 | ||
29 | void POP3viewItem::refresh( QList<RecMail> & ) | ||
30 | { | ||
31 | QList<Folder> *folders = wrapper->listFolders(); | ||
32 | QListViewItem *child = firstChild(); | ||
33 | while ( child ) { | ||
34 | QListViewItem *tmp = child; | ||
35 | child = child->nextSibling(); | ||
36 | delete tmp; | ||
37 | } | ||
38 | Folder *it; | ||
39 | QListViewItem*item = 0; | ||
40 | for ( it = folders->first(); it; it = folders->next() ) { | ||
41 | item = new POP3folderItem( it, this , item ); | ||
42 | item->setSelectable(it->may_select()); | ||
43 | } | ||
44 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
45 | folders->setAutoDelete(false); | ||
46 | delete folders; | ||
47 | } | ||
30 | 48 | ||
31 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) | 49 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) |
@@ -35,8 +53,36 @@ RecBody POP3viewItem::fetchBody( const RecMail &mail ) | |||
35 | } | 53 | } |
36 | 54 | ||
55 | POP3folderItem::~POP3folderItem() | ||
56 | { | ||
57 | delete folder; | ||
58 | } | ||
59 | |||
60 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) | ||
61 | : AccountViewItem( parent,after ) | ||
62 | { | ||
63 | folder = folderInit; | ||
64 | pop3 = parent; | ||
65 | if (folder->getDisplayName().lower()!="inbox") { | ||
66 | setPixmap( 0, PIXMAP_POP3FOLDER ); | ||
67 | } else { | ||
68 | setPixmap( 0, PIXMAP_INBOXFOLDER); | ||
69 | } | ||
70 | setText( 0, folder->getDisplayName() ); | ||
71 | } | ||
72 | |||
73 | void POP3folderItem::refresh(QList<RecMail>&target) | ||
74 | { | ||
75 | if (folder->may_select()) | ||
76 | pop3->getWrapper()->listMessages( folder->getName(),target ); | ||
77 | } | ||
78 | |||
79 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) | ||
80 | { | ||
81 | return pop3->getWrapper()->fetchBody(aMail); | ||
82 | } | ||
83 | |||
37 | /** | 84 | /** |
38 | * IMAP Account stuff | 85 | * IMAP Account stuff |
39 | */ | 86 | */ |
40 | |||
41 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 87 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) |
42 | : AccountViewItem( parent ) | 88 | : AccountViewItem( parent ) |
@@ -96,5 +142,9 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QList | |||
96 | folder = folderInit; | 142 | folder = folderInit; |
97 | imap = parent; | 143 | imap = parent; |
98 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 144 | if (folder->getDisplayName().lower()!="inbox") { |
145 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | ||
146 | } else { | ||
147 | setPixmap( 0, PIXMAP_INBOXFOLDER); | ||
148 | } | ||
99 | setText( 0, folder->getDisplayName() ); | 149 | setText( 0, folder->getDisplayName() ); |
100 | } | 150 | } |
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 | |||
@@ -32,5 +32,5 @@ public: | |||
32 | virtual void refresh( QList<RecMail> &target ); | 32 | virtual void refresh( QList<RecMail> &target ); |
33 | virtual RecBody fetchBody( const RecMail &mail ); | 33 | virtual RecBody fetchBody( const RecMail &mail ); |
34 | 34 | AbstractMail *getWrapper(); | |
35 | private: | 35 | private: |
36 | POP3account *account; | 36 | POP3account *account; |
@@ -39,4 +39,17 @@ private: | |||
39 | }; | 39 | }; |
40 | 40 | ||
41 | class POP3folderItem : public AccountViewItem | ||
42 | { | ||
43 | |||
44 | public: | ||
45 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); | ||
46 | ~POP3folderItem(); | ||
47 | virtual void refresh(QList<RecMail>&); | ||
48 | virtual RecBody fetchBody(const RecMail&); | ||
49 | private: | ||
50 | Folder *folder; | ||
51 | POP3viewItem *pop3; | ||
52 | }; | ||
53 | |||
41 | class IMAPviewItem : public AccountViewItem | 54 | class IMAPviewItem : public AccountViewItem |
42 | { | 55 | { |
@@ -64,5 +77,4 @@ private: | |||
64 | Folder *folder; | 77 | Folder *folder; |
65 | IMAPviewItem *imap; | 78 | IMAPviewItem *imap; |
66 | |||
67 | }; | 79 | }; |
68 | 80 | ||
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 | |||
@@ -15,4 +15,5 @@ | |||
15 | #define PIC_IMAPFOLDER "opiemail/imapfolder" | 15 | #define PIC_IMAPFOLDER "opiemail/imapfolder" |
16 | #define PIC_POP3FOLDER "opiemail/pop3folder" | 16 | #define PIC_POP3FOLDER "opiemail/pop3folder" |
17 | #define PIC_INBOXFOLDER "opiemail/inbox" | ||
17 | 18 | ||
18 | #define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) | 19 | #define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) |
@@ -26,4 +27,5 @@ | |||
26 | #define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) | 27 | #define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) |
27 | #define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) | 28 | #define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) |
29 | #define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) ) | ||
28 | 30 | ||
29 | #define IMAP_PORT "143" | 31 | #define IMAP_PORT "143" |
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,3 +1,3 @@ | |||
1 | 1 | #include <stdlib.h> | |
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
@@ -44,17 +44,21 @@ RecBody POP3wrapper::parseBody( const char *message ) | |||
44 | { | 44 | { |
45 | int err = MAILIMF_NO_ERROR; | 45 | int err = MAILIMF_NO_ERROR; |
46 | size_t curTok; | 46 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ |
47 | mailimf_message *result; | 47 | size_t curTok = 0; |
48 | mailimf_message *result = 0; | ||
48 | RecBody body; | 49 | RecBody body; |
49 | 50 | ||
50 | err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result ); | 51 | err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result ); |
51 | if ( err != MAILIMF_NO_ERROR ) return body; | 52 | if ( err != MAILIMF_NO_ERROR ) { |
53 | if (result) mailimf_message_free(result); | ||
54 | return body; | ||
55 | } | ||
52 | 56 | ||
53 | if ( result && result->msg_body && result->msg_body->bd_text ) { | 57 | if ( result && result->msg_body && result->msg_body->bd_text ) { |
54 | qDebug( "POP3: bodytext found" ); | 58 | qDebug( "POP3: bodytext found" ); |
55 | // TODO: why does this line segfault???? gdb says segfault in strlen(), maybe a bug in libetpan. | 59 | // when curTok isn't set to 0 this line will fault! 'cause upper line faults! |
56 | body.setBodytext( QString( result->msg_body->bd_text ) ); | 60 | body.setBodytext( QString( result->msg_body->bd_text ) ); |
57 | } | 61 | } |
58 | 62 | if (result) mailimf_message_free(result); | |
59 | return body; | 63 | return body; |
60 | } | 64 | } |
@@ -63,7 +67,8 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
63 | { | 67 | { |
64 | int err = MAILPOP3_NO_ERROR; | 68 | int err = MAILPOP3_NO_ERROR; |
65 | char *header; | 69 | char * header = 0; |
66 | size_t length; | 70 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ |
67 | carray *messages; | 71 | size_t length = 0; |
72 | carray * messages = 0; | ||
68 | 73 | ||
69 | login(); | 74 | login(); |
@@ -71,10 +76,12 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
71 | mailpop3_list( m_pop3, &messages ); | 76 | mailpop3_list( m_pop3, &messages ); |
72 | 77 | ||
73 | for ( int i = carray_count( messages ); i > 0; i-- ) { | 78 | //for ( int i = carray_count( messages ); i > 0; i-- ) { |
74 | mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); | 79 | for (unsigned int i = 0; i < carray_count(messages);++i) { |
75 | 80 | mailpop3_msg_info *info; | |
81 | int r = mailpop3_get_msg_info(m_pop3,i+1,&info); | ||
76 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); | 82 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); |
77 | if ( err != MAILPOP3_NO_ERROR ) { | 83 | if ( err != MAILPOP3_NO_ERROR ) { |
78 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); | 84 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); |
85 | free(header); | ||
79 | logout(); | 86 | logout(); |
80 | return; | 87 | return; |
@@ -84,6 +91,6 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
84 | mail->setWrapper(this); | 91 | mail->setWrapper(this); |
85 | target.append( mail ); | 92 | target.append( mail ); |
93 | free(header); | ||
86 | } | 94 | } |
87 | |||
88 | logout(); | 95 | logout(); |
89 | } | 96 | } |
@@ -92,8 +99,10 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
92 | { | 99 | { |
93 | int err = MAILIMF_NO_ERROR; | 100 | int err = MAILIMF_NO_ERROR; |
94 | size_t curTok; | 101 | size_t curTok = 0; |
95 | RecMail *mail = new RecMail(); | 102 | RecMail *mail = new RecMail(); |
96 | mailimf_fields *fields; | 103 | mailimf_fields *fields; |
97 | 104 | mailimf_references * refs; | |
105 | mailimf_keywords*keys; | ||
106 | |||
98 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 107 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
99 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { | 108 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { |
@@ -118,9 +127,25 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
118 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); | 127 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); |
119 | break; | 128 | break; |
129 | case MAILIMF_FIELD_MESSAGE_ID: | ||
130 | mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value)); | ||
131 | break; | ||
132 | case MAILIMF_FIELD_REFERENCES: | ||
133 | refs = field->fld_data.fld_references; | ||
134 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | ||
135 | char * text = (char*)refs->mid_list->first->data; | ||
136 | mail->setReplyto(QString(text)); | ||
137 | } | ||
138 | break; | ||
139 | case MAILIMF_FIELD_KEYWORDS: | ||
140 | keys = field->fld_data.fld_keywords; | ||
141 | for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) { | ||
142 | qDebug("Keyword: %s",(char*)cur->data); | ||
143 | } | ||
144 | break; | ||
120 | default: | 145 | default: |
121 | break; | 146 | break; |
122 | } | 147 | } |
123 | } | 148 | } |
124 | 149 | if (fields) mailimf_fields_free(fields); | |
125 | return mail; | 150 | return mail; |
126 | } | 151 | } |
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,3 +1,3 @@ | |||
1 | 1 | #include <stdlib.h> | |
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
@@ -44,17 +44,21 @@ RecBody POP3wrapper::parseBody( const char *message ) | |||
44 | { | 44 | { |
45 | int err = MAILIMF_NO_ERROR; | 45 | int err = MAILIMF_NO_ERROR; |
46 | size_t curTok; | 46 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ |
47 | mailimf_message *result; | 47 | size_t curTok = 0; |
48 | mailimf_message *result = 0; | ||
48 | RecBody body; | 49 | RecBody body; |
49 | 50 | ||
50 | err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result ); | 51 | err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result ); |
51 | if ( err != MAILIMF_NO_ERROR ) return body; | 52 | if ( err != MAILIMF_NO_ERROR ) { |
53 | if (result) mailimf_message_free(result); | ||
54 | return body; | ||
55 | } | ||
52 | 56 | ||
53 | if ( result && result->msg_body && result->msg_body->bd_text ) { | 57 | if ( result && result->msg_body && result->msg_body->bd_text ) { |
54 | qDebug( "POP3: bodytext found" ); | 58 | qDebug( "POP3: bodytext found" ); |
55 | // TODO: why does this line segfault???? gdb says segfault in strlen(), maybe a bug in libetpan. | 59 | // when curTok isn't set to 0 this line will fault! 'cause upper line faults! |
56 | body.setBodytext( QString( result->msg_body->bd_text ) ); | 60 | body.setBodytext( QString( result->msg_body->bd_text ) ); |
57 | } | 61 | } |
58 | 62 | if (result) mailimf_message_free(result); | |
59 | return body; | 63 | return body; |
60 | } | 64 | } |
@@ -63,7 +67,8 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
63 | { | 67 | { |
64 | int err = MAILPOP3_NO_ERROR; | 68 | int err = MAILPOP3_NO_ERROR; |
65 | char *header; | 69 | char * header = 0; |
66 | size_t length; | 70 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ |
67 | carray *messages; | 71 | size_t length = 0; |
72 | carray * messages = 0; | ||
68 | 73 | ||
69 | login(); | 74 | login(); |
@@ -71,10 +76,12 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
71 | mailpop3_list( m_pop3, &messages ); | 76 | mailpop3_list( m_pop3, &messages ); |
72 | 77 | ||
73 | for ( int i = carray_count( messages ); i > 0; i-- ) { | 78 | //for ( int i = carray_count( messages ); i > 0; i-- ) { |
74 | mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); | 79 | for (unsigned int i = 0; i < carray_count(messages);++i) { |
75 | 80 | mailpop3_msg_info *info; | |
81 | int r = mailpop3_get_msg_info(m_pop3,i+1,&info); | ||
76 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); | 82 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); |
77 | if ( err != MAILPOP3_NO_ERROR ) { | 83 | if ( err != MAILPOP3_NO_ERROR ) { |
78 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); | 84 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); |
85 | free(header); | ||
79 | logout(); | 86 | logout(); |
80 | return; | 87 | return; |
@@ -84,6 +91,6 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
84 | mail->setWrapper(this); | 91 | mail->setWrapper(this); |
85 | target.append( mail ); | 92 | target.append( mail ); |
93 | free(header); | ||
86 | } | 94 | } |
87 | |||
88 | logout(); | 95 | logout(); |
89 | } | 96 | } |
@@ -92,8 +99,10 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
92 | { | 99 | { |
93 | int err = MAILIMF_NO_ERROR; | 100 | int err = MAILIMF_NO_ERROR; |
94 | size_t curTok; | 101 | size_t curTok = 0; |
95 | RecMail *mail = new RecMail(); | 102 | RecMail *mail = new RecMail(); |
96 | mailimf_fields *fields; | 103 | mailimf_fields *fields; |
97 | 104 | mailimf_references * refs; | |
105 | mailimf_keywords*keys; | ||
106 | |||
98 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 107 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
99 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { | 108 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { |
@@ -118,9 +127,25 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
118 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); | 127 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); |
119 | break; | 128 | break; |
129 | case MAILIMF_FIELD_MESSAGE_ID: | ||
130 | mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value)); | ||
131 | break; | ||
132 | case MAILIMF_FIELD_REFERENCES: | ||
133 | refs = field->fld_data.fld_references; | ||
134 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | ||
135 | char * text = (char*)refs->mid_list->first->data; | ||
136 | mail->setReplyto(QString(text)); | ||
137 | } | ||
138 | break; | ||
139 | case MAILIMF_FIELD_KEYWORDS: | ||
140 | keys = field->fld_data.fld_keywords; | ||
141 | for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) { | ||
142 | qDebug("Keyword: %s",(char*)cur->data); | ||
143 | } | ||
144 | break; | ||
120 | default: | 145 | default: |
121 | break; | 146 | break; |
122 | } | 147 | } |
123 | } | 148 | } |
124 | 149 | if (fields) mailimf_fields_free(fields); | |
125 | return mail; | 150 | return mail; |
126 | } | 151 | } |