author | alwin <alwin> | 2004-01-08 21:51:32 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-08 21:51:32 (UTC) |
commit | fb30e3e116d8616cb05b3765ae1aed5f7e96c74e (patch) (side-by-side diff) | |
tree | 393ebb7b913c01697146ac804d980f8b8713f81a | |
parent | b672058ac470a1b9534296fa8bc4b8725ab7913b (diff) | |
download | opie-fb30e3e116d8616cb05b3765ae1aed5f7e96c74e.zip opie-fb30e3e116d8616cb05b3765ae1aed5f7e96c74e.tar.gz opie-fb30e3e116d8616cb05b3765ae1aed5f7e96c74e.tar.bz2 |
- last functions re-implemented
- small bugfix
TODO:
remove twice code within pop3/mh/mbox wrapper
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index 85f9cf0..5adba55 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp @@ -38,67 +38,67 @@ void MHwrapper::init_storage() return; } } r = mailstorage_connect(m_storage); if (r!=MAIL_NO_ERROR) { qDebug("error connecting storage"); mailstorage_free(m_storage); m_storage = 0; } } void MHwrapper::clean_storage() { if (m_storage) { mailstorage_disconnect(m_storage); mailstorage_free(m_storage); m_storage = 0; } } MHwrapper::~MHwrapper() { clean_storage(); } void MHwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) { init_storage(); if (!m_storage) { return; } QString f = buildPath(mailbox); - int r = mailsession_select_folder(m_storage->sto_session,(char*)mailbox.latin1()); + int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); if (r!=MAIL_NO_ERROR) { - qDebug("error selecting folder!"); + qDebug("listMessages: error selecting folder!"); return; } parseList(target,m_storage->sto_session,f); Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); } QList<Folder>* MHwrapper::listFolders() { QList<Folder> * folders = new QList<Folder>(); folders->setAutoDelete( false ); init_storage(); if (!m_storage) { return folders; } mail_list*flist = 0; clistcell*current=0; int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); if (r != MAIL_NO_ERROR || !flist) { qDebug("error getting folder list"); return folders; } for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { QString t = (char*)current->data; t.replace(0,MHPath.length(),""); folders->append(new MHFolder(t,MHPath)); } mail_list_free(flist); return folders; } void MHwrapper::deleteMail(const RecMail&mail) { @@ -207,76 +207,79 @@ encodedString* MHwrapper::fetchRawBody(const RecMail&mail) { encodedString*result = 0; init_storage(); if (!m_storage) { return result; } mailmessage * msg = 0; char*data=0; size_t size; int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); if (r!=MAIL_NO_ERROR) { qDebug("error selecting folder!"); return result; } r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); if (r != MAIL_NO_ERROR) { Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); return 0; } r = mailmessage_fetch(msg,&data,&size); if (r != MAIL_NO_ERROR) { Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); if (msg) mailmessage_free(msg); return 0; } result = new encodedString(data,size); if (msg) mailmessage_free(msg); return result; } void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) { -#if 0 - QString p = MHPath+"/"; - p+=mailbox; - mailmbox_folder*f = 0; - int r = mailmbox_init(p.latin1(),0,1,0,&f); - if (r != MAIL_NO_ERROR) { - qDebug("Error init folder"); + QString f = buildPath(mailbox); + int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); + if (r!=MAIL_NO_ERROR) { + qDebug("deleteMails: error selecting folder!"); return; } - deleteMails(f,target); - mailmbox_done(f); -#endif + RecMail*c = 0; + for (unsigned int i=0; i < target.count();++i) { + c = target.at(i); + r = mailsession_remove_message(m_storage->sto_session,c->getNumber()); + if (r != MAIL_NO_ERROR) { + qDebug("error deleting mail"); + break; + } + } } int MHwrapper::deleteAllMail(const Folder*tfolder) { init_storage(); if (!m_storage) { return 0; } int res = 1; if (!tfolder) return 0; int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); if (r!=MAIL_NO_ERROR) { qDebug("error selecting folder!"); return 0; } mailmessage_list*l=0; r = mailsession_get_messages_list(m_storage->sto_session,&l); if (r != MAIL_NO_ERROR) { qDebug("Error message list"); res = 0; } unsigned j = 0; for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { mailmessage * msg; msg = (mailmessage*)carray_get(l->msg_tab, i); j = msg->msg_index; r = mailsession_remove_message(m_storage->sto_session,j); if (r != MAIL_NO_ERROR) { Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); res = 0; break; } |