author | alwin <alwin> | 2003-12-15 15:40:51 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-15 15:40:51 (UTC) |
commit | 2a4d7a2fcdf76c032a17135bff461bbf4089ad93 (patch) (unidiff) | |
tree | f8208fc563fb0b1af674b095d1dc547265f38c98 /noncore/net/mail | |
parent | 4acec249d48e57c911fc2544d92785b86d5f08d0 (diff) | |
download | opie-2a4d7a2fcdf76c032a17135bff461bbf4089ad93.zip opie-2a4d7a2fcdf76c032a17135bff461bbf4089ad93.tar.gz opie-2a4d7a2fcdf76c032a17135bff461bbf4089ad93.tar.bz2 |
delete mail implemented
test for read flags
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 50 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 50 |
2 files changed, 78 insertions, 22 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 2411399..b4a8f4b 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -17,5 +17,5 @@ POP3wrapper::~POP3wrapper() | |||
17 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | 17 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) |
18 | { | 18 | { |
19 | qDebug( "POP3: %i of %i", current, maximum ); | 19 | //qDebug( "POP3: %i of %i", current, maximum ); |
20 | } | 20 | } |
21 | 21 | ||
@@ -24,5 +24,5 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) | |||
24 | int err = MAILPOP3_NO_ERROR; | 24 | int err = MAILPOP3_NO_ERROR; |
25 | char *message; | 25 | char *message; |
26 | size_t length; | 26 | size_t length = 0; |
27 | 27 | ||
28 | login(); | 28 | login(); |
@@ -32,10 +32,7 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) | |||
32 | if ( err != MAILPOP3_NO_ERROR ) { | 32 | if ( err != MAILPOP3_NO_ERROR ) { |
33 | qDebug( "POP3: error retrieving body with index %i", mail.getNumber() ); | 33 | qDebug( "POP3: error retrieving body with index %i", mail.getNumber() ); |
34 | logout(); | ||
35 | return RecBody(); | 34 | return RecBody(); |
36 | } | 35 | } |
37 | 36 | ||
38 | logout(); | ||
39 | |||
40 | return parseBody( message ); | 37 | return parseBody( message ); |
41 | } | 38 | } |
@@ -76,13 +73,11 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
76 | mailpop3_list( m_pop3, &messages ); | 73 | mailpop3_list( m_pop3, &messages ); |
77 | 74 | ||
78 | //for ( int i = carray_count( messages ); i > 0; i-- ) { | ||
79 | for (unsigned int i = 0; i < carray_count(messages);++i) { | 75 | for (unsigned int i = 0; i < carray_count(messages);++i) { |
80 | mailpop3_msg_info *info; | 76 | mailpop3_msg_info *info; |
81 | int r = mailpop3_get_msg_info(m_pop3,i+1,&info); | 77 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); |
82 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); | 78 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); |
83 | if ( err != MAILPOP3_NO_ERROR ) { | 79 | if ( err != MAILPOP3_NO_ERROR ) { |
84 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); | 80 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); |
85 | free(header); | 81 | free(header); |
86 | logout(); | ||
87 | return; | 82 | return; |
88 | } | 83 | } |
@@ -90,8 +85,8 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
90 | mail->setNumber( info->msg_index ); | 85 | mail->setNumber( info->msg_index ); |
91 | mail->setWrapper(this); | 86 | mail->setWrapper(this); |
87 | mail->setMsgsize(info->msg_size); | ||
92 | target.append( mail ); | 88 | target.append( mail ); |
93 | free(header); | 89 | free(header); |
94 | } | 90 | } |
95 | logout(); | ||
96 | } | 91 | } |
97 | 92 | ||
@@ -104,4 +99,7 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
104 | mailimf_references * refs; | 99 | mailimf_references * refs; |
105 | mailimf_keywords*keys; | 100 | mailimf_keywords*keys; |
101 | QString status; | ||
102 | QString value; | ||
103 | QBitArray mFlags(7); | ||
106 | 104 | ||
107 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 105 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
@@ -143,9 +141,29 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
143 | } | 141 | } |
144 | break; | 142 | break; |
143 | case MAILIMF_FIELD_OPTIONAL_FIELD: | ||
144 | status = field->fld_data.fld_optional_field->fld_name; | ||
145 | value = field->fld_data.fld_optional_field->fld_value; | ||
146 | if (status.lower()=="status") { | ||
147 | if (value.lower()=="ro") { | ||
148 | mFlags.setBit(FLAG_SEEN); | ||
149 | } | ||
150 | } else if (status.lower()=="x-status") { | ||
151 | qDebug("X-Status: %s",value.latin1()); | ||
152 | if (value.lower()=="a") { | ||
153 | |||
154 | mFlags.setBit(FLAG_ANSWERED); | ||
155 | } | ||
156 | } else { | ||
157 | // qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name, | ||
158 | // field->fld_data.fld_optional_field->fld_value); | ||
159 | } | ||
160 | break; | ||
145 | default: | 161 | default: |
162 | qDebug("Non parsed field"); | ||
146 | break; | 163 | break; |
147 | } | 164 | } |
148 | } | 165 | } |
149 | if (fields) mailimf_fields_free(fields); | 166 | if (fields) mailimf_fields_free(fields); |
167 | mail->setFlags(mFlags); | ||
150 | return mail; | 168 | return mail; |
151 | } | 169 | } |
@@ -245,5 +263,6 @@ QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) | |||
245 | void POP3wrapper::login() | 263 | void POP3wrapper::login() |
246 | { | 264 | { |
247 | if ( m_pop3 != NULL ) logout(); | 265 | /* we'll hold the line */ |
266 | if ( m_pop3 != NULL ) return; | ||
248 | 267 | ||
249 | const char *server, *user, *pass; | 268 | const char *server, *user, *pass; |
@@ -298,4 +317,7 @@ void POP3wrapper::logout() | |||
298 | QList<Folder>* POP3wrapper::listFolders() | 317 | QList<Folder>* POP3wrapper::listFolders() |
299 | { | 318 | { |
319 | /* TODO: integrate MH directories | ||
320 | but not vor version 0.1 ;) | ||
321 | */ | ||
300 | QList<Folder> * folders = new QList<Folder>(); | 322 | QList<Folder> * folders = new QList<Folder>(); |
301 | folders->setAutoDelete( false ); | 323 | folders->setAutoDelete( false ); |
@@ -310,6 +332,12 @@ QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) | |||
310 | } | 332 | } |
311 | 333 | ||
312 | void POP3wrapper::deleteMail(const RecMail&) | 334 | void POP3wrapper::deleteMail(const RecMail&mail) |
313 | { | 335 | { |
336 | login(); | ||
337 | if (!m_pop3) return; | ||
338 | int err = mailpop3_dele(m_pop3,mail.getNumber()); | ||
339 | if (err != MAILPOP3_NO_ERROR) { | ||
340 | qDebug("error deleting mail"); | ||
341 | } | ||
314 | } | 342 | } |
315 | 343 | ||
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp index 2411399..b4a8f4b 100644 --- a/noncore/net/mail/pop3wrapper.cpp +++ b/noncore/net/mail/pop3wrapper.cpp | |||
@@ -17,5 +17,5 @@ POP3wrapper::~POP3wrapper() | |||
17 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | 17 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) |
18 | { | 18 | { |
19 | qDebug( "POP3: %i of %i", current, maximum ); | 19 | //qDebug( "POP3: %i of %i", current, maximum ); |
20 | } | 20 | } |
21 | 21 | ||
@@ -24,5 +24,5 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) | |||
24 | int err = MAILPOP3_NO_ERROR; | 24 | int err = MAILPOP3_NO_ERROR; |
25 | char *message; | 25 | char *message; |
26 | size_t length; | 26 | size_t length = 0; |
27 | 27 | ||
28 | login(); | 28 | login(); |
@@ -32,10 +32,7 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) | |||
32 | if ( err != MAILPOP3_NO_ERROR ) { | 32 | if ( err != MAILPOP3_NO_ERROR ) { |
33 | qDebug( "POP3: error retrieving body with index %i", mail.getNumber() ); | 33 | qDebug( "POP3: error retrieving body with index %i", mail.getNumber() ); |
34 | logout(); | ||
35 | return RecBody(); | 34 | return RecBody(); |
36 | } | 35 | } |
37 | 36 | ||
38 | logout(); | ||
39 | |||
40 | return parseBody( message ); | 37 | return parseBody( message ); |
41 | } | 38 | } |
@@ -76,13 +73,11 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
76 | mailpop3_list( m_pop3, &messages ); | 73 | mailpop3_list( m_pop3, &messages ); |
77 | 74 | ||
78 | //for ( int i = carray_count( messages ); i > 0; i-- ) { | ||
79 | for (unsigned int i = 0; i < carray_count(messages);++i) { | 75 | for (unsigned int i = 0; i < carray_count(messages);++i) { |
80 | mailpop3_msg_info *info; | 76 | mailpop3_msg_info *info; |
81 | int r = mailpop3_get_msg_info(m_pop3,i+1,&info); | 77 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); |
82 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); | 78 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); |
83 | if ( err != MAILPOP3_NO_ERROR ) { | 79 | if ( err != MAILPOP3_NO_ERROR ) { |
84 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); | 80 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); |
85 | free(header); | 81 | free(header); |
86 | logout(); | ||
87 | return; | 82 | return; |
88 | } | 83 | } |
@@ -90,8 +85,8 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
90 | mail->setNumber( info->msg_index ); | 85 | mail->setNumber( info->msg_index ); |
91 | mail->setWrapper(this); | 86 | mail->setWrapper(this); |
87 | mail->setMsgsize(info->msg_size); | ||
92 | target.append( mail ); | 88 | target.append( mail ); |
93 | free(header); | 89 | free(header); |
94 | } | 90 | } |
95 | logout(); | ||
96 | } | 91 | } |
97 | 92 | ||
@@ -104,4 +99,7 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
104 | mailimf_references * refs; | 99 | mailimf_references * refs; |
105 | mailimf_keywords*keys; | 100 | mailimf_keywords*keys; |
101 | QString status; | ||
102 | QString value; | ||
103 | QBitArray mFlags(7); | ||
106 | 104 | ||
107 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 105 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
@@ -143,9 +141,29 @@ RecMail *POP3wrapper::parseHeader( const char *header ) | |||
143 | } | 141 | } |
144 | break; | 142 | break; |
143 | case MAILIMF_FIELD_OPTIONAL_FIELD: | ||
144 | status = field->fld_data.fld_optional_field->fld_name; | ||
145 | value = field->fld_data.fld_optional_field->fld_value; | ||
146 | if (status.lower()=="status") { | ||
147 | if (value.lower()=="ro") { | ||
148 | mFlags.setBit(FLAG_SEEN); | ||
149 | } | ||
150 | } else if (status.lower()=="x-status") { | ||
151 | qDebug("X-Status: %s",value.latin1()); | ||
152 | if (value.lower()=="a") { | ||
153 | |||
154 | mFlags.setBit(FLAG_ANSWERED); | ||
155 | } | ||
156 | } else { | ||
157 | // qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name, | ||
158 | // field->fld_data.fld_optional_field->fld_value); | ||
159 | } | ||
160 | break; | ||
145 | default: | 161 | default: |
162 | qDebug("Non parsed field"); | ||
146 | break; | 163 | break; |
147 | } | 164 | } |
148 | } | 165 | } |
149 | if (fields) mailimf_fields_free(fields); | 166 | if (fields) mailimf_fields_free(fields); |
167 | mail->setFlags(mFlags); | ||
150 | return mail; | 168 | return mail; |
151 | } | 169 | } |
@@ -245,5 +263,6 @@ QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) | |||
245 | void POP3wrapper::login() | 263 | void POP3wrapper::login() |
246 | { | 264 | { |
247 | if ( m_pop3 != NULL ) logout(); | 265 | /* we'll hold the line */ |
266 | if ( m_pop3 != NULL ) return; | ||
248 | 267 | ||
249 | const char *server, *user, *pass; | 268 | const char *server, *user, *pass; |
@@ -298,4 +317,7 @@ void POP3wrapper::logout() | |||
298 | QList<Folder>* POP3wrapper::listFolders() | 317 | QList<Folder>* POP3wrapper::listFolders() |
299 | { | 318 | { |
319 | /* TODO: integrate MH directories | ||
320 | but not vor version 0.1 ;) | ||
321 | */ | ||
300 | QList<Folder> * folders = new QList<Folder>(); | 322 | QList<Folder> * folders = new QList<Folder>(); |
301 | folders->setAutoDelete( false ); | 323 | folders->setAutoDelete( false ); |
@@ -310,6 +332,12 @@ QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) | |||
310 | } | 332 | } |
311 | 333 | ||
312 | void POP3wrapper::deleteMail(const RecMail&) | 334 | void POP3wrapper::deleteMail(const RecMail&mail) |
313 | { | 335 | { |
336 | login(); | ||
337 | if (!m_pop3) return; | ||
338 | int err = mailpop3_dele(m_pop3,mail.getNumber()); | ||
339 | if (err != MAILPOP3_NO_ERROR) { | ||
340 | qDebug("error deleting mail"); | ||
341 | } | ||
314 | } | 342 | } |
315 | 343 | ||