author | alwin <alwin> | 2003-12-15 15:40:51 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-15 15:40:51 (UTC) |
commit | 2a4d7a2fcdf76c032a17135bff461bbf4089ad93 (patch) (side-by-side diff) | |
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 @@ -18,3 +18,3 @@ void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { - qDebug( "POP3: %i of %i", current, maximum ); + //qDebug( "POP3: %i of %i", current, maximum ); } @@ -25,3 +25,3 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) char *message; - size_t length; + size_t length = 0; @@ -33,3 +33,2 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) qDebug( "POP3: error retrieving body with index %i", mail.getNumber() ); - logout(); return RecBody(); @@ -37,4 +36,2 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) - logout(); - return parseBody( message ); @@ -77,6 +74,5 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) - //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_get_msg_info(m_pop3,i+1,&info); err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); @@ -85,3 +81,2 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) free(header); - logout(); return; @@ -91,2 +86,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) mail->setWrapper(this); + mail->setMsgsize(info->msg_size); target.append( mail ); @@ -94,3 +90,2 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) } - logout(); } @@ -105,2 +100,5 @@ RecMail *POP3wrapper::parseHeader( const char *header ) mailimf_keywords*keys; + QString status; + QString value; + QBitArray mFlags(7); @@ -144,3 +142,22 @@ RecMail *POP3wrapper::parseHeader( const char *header ) break; + case MAILIMF_FIELD_OPTIONAL_FIELD: + status = field->fld_data.fld_optional_field->fld_name; + value = field->fld_data.fld_optional_field->fld_value; + if (status.lower()=="status") { + if (value.lower()=="ro") { + mFlags.setBit(FLAG_SEEN); + } + } else if (status.lower()=="x-status") { + qDebug("X-Status: %s",value.latin1()); + if (value.lower()=="a") { + + mFlags.setBit(FLAG_ANSWERED); + } + } else { +// qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name, +// field->fld_data.fld_optional_field->fld_value); + } + break; default: + qDebug("Non parsed field"); break; @@ -149,2 +166,3 @@ RecMail *POP3wrapper::parseHeader( const char *header ) if (fields) mailimf_fields_free(fields); + mail->setFlags(mFlags); return mail; @@ -246,3 +264,4 @@ void POP3wrapper::login() { - if ( m_pop3 != NULL ) logout(); + /* we'll hold the line */ + if ( m_pop3 != NULL ) return; @@ -299,2 +318,5 @@ QList<Folder>* POP3wrapper::listFolders() { + /* TODO: integrate MH directories + but not vor version 0.1 ;) + */ QList<Folder> * folders = new QList<Folder>(); @@ -311,4 +333,10 @@ QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) -void POP3wrapper::deleteMail(const RecMail&) +void POP3wrapper::deleteMail(const RecMail&mail) { + login(); + if (!m_pop3) return; + int err = mailpop3_dele(m_pop3,mail.getNumber()); + if (err != MAILPOP3_NO_ERROR) { + qDebug("error deleting mail"); + } } 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 @@ -18,3 +18,3 @@ void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { - qDebug( "POP3: %i of %i", current, maximum ); + //qDebug( "POP3: %i of %i", current, maximum ); } @@ -25,3 +25,3 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) char *message; - size_t length; + size_t length = 0; @@ -33,3 +33,2 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) qDebug( "POP3: error retrieving body with index %i", mail.getNumber() ); - logout(); return RecBody(); @@ -37,4 +36,2 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) - logout(); - return parseBody( message ); @@ -77,6 +74,5 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) - //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_get_msg_info(m_pop3,i+1,&info); err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); @@ -85,3 +81,2 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) free(header); - logout(); return; @@ -91,2 +86,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) mail->setWrapper(this); + mail->setMsgsize(info->msg_size); target.append( mail ); @@ -94,3 +90,2 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) } - logout(); } @@ -105,2 +100,5 @@ RecMail *POP3wrapper::parseHeader( const char *header ) mailimf_keywords*keys; + QString status; + QString value; + QBitArray mFlags(7); @@ -144,3 +142,22 @@ RecMail *POP3wrapper::parseHeader( const char *header ) break; + case MAILIMF_FIELD_OPTIONAL_FIELD: + status = field->fld_data.fld_optional_field->fld_name; + value = field->fld_data.fld_optional_field->fld_value; + if (status.lower()=="status") { + if (value.lower()=="ro") { + mFlags.setBit(FLAG_SEEN); + } + } else if (status.lower()=="x-status") { + qDebug("X-Status: %s",value.latin1()); + if (value.lower()=="a") { + + mFlags.setBit(FLAG_ANSWERED); + } + } else { +// qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name, +// field->fld_data.fld_optional_field->fld_value); + } + break; default: + qDebug("Non parsed field"); break; @@ -149,2 +166,3 @@ RecMail *POP3wrapper::parseHeader( const char *header ) if (fields) mailimf_fields_free(fields); + mail->setFlags(mFlags); return mail; @@ -246,3 +264,4 @@ void POP3wrapper::login() { - if ( m_pop3 != NULL ) logout(); + /* we'll hold the line */ + if ( m_pop3 != NULL ) return; @@ -299,2 +318,5 @@ QList<Folder>* POP3wrapper::listFolders() { + /* TODO: integrate MH directories + but not vor version 0.1 ;) + */ QList<Folder> * folders = new QList<Folder>(); @@ -311,4 +333,10 @@ QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) -void POP3wrapper::deleteMail(const RecMail&) +void POP3wrapper::deleteMail(const RecMail&mail) { + login(); + if (!m_pop3) return; + int err = mailpop3_dele(m_pop3,mail.getNumber()); + if (err != MAILPOP3_NO_ERROR) { + qDebug("error deleting mail"); + } } |