author | zautrix <zautrix> | 2004-09-11 16:44:49 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-11 16:44:49 (UTC) |
commit | 06be094df4e34cc41db113d8c0e78eccde5365b5 (patch) (side-by-side diff) | |
tree | b99317f9c83886d05b83cdb49e066f414e0fde25 /kmicromail/libmailwrapper/mhwrapper.cpp | |
parent | 53e10fa5e66620ff1eba1c9d17738103ad511c91 (diff) | |
download | kdepimpi-06be094df4e34cc41db113d8c0e78eccde5365b5.zip kdepimpi-06be094df4e34cc41db113d8c0e78eccde5365b5.tar.gz kdepimpi-06be094df4e34cc41db113d8c0e78eccde5365b5.tar.bz2 |
Mail more useful
Diffstat (limited to 'kmicromail/libmailwrapper/mhwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp index 962dac0..641d4d9 100644 --- a/kmicromail/libmailwrapper/mhwrapper.cpp +++ b/kmicromail/libmailwrapper/mhwrapper.cpp @@ -20,97 +20,96 @@ MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) } //odebug << MHPath << oendl; QDir dir(MHPath); if (!dir.exists()) { dir.mkdir(MHPath); } init_storage(); } } void MHwrapper::init_storage() { int r; QString pre = MHPath; if (!m_storage) { m_storage = mailstorage_new(NULL); r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); if (r != MAIL_NO_ERROR) { qDebug(" error init storage "); mailstorage_free(m_storage); m_storage = 0; 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, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) { - qDebug("MHwrapper::listMessages "); init_storage(); if (!m_storage) { return; } QString f = buildPath(mailbox); int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); if (r!=MAIL_NO_ERROR) { qDebug("listMessages: error selecting folder! "); return; } parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); } QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() { QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); /* this is needed! */ if (m_storage) mailstorage_disconnect(m_storage); 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 RecMailP&mail) { init_storage(); if (!m_storage) { return; } int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); if (r!=MAIL_NO_ERROR) { qDebug("error selecting folder! "); @@ -149,97 +148,96 @@ RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) } body = parseMail(msg); mailmessage_fetch_result_free(msg,data); return body; } void MHwrapper::mbox_progress( size_t current, size_t maximum ) { qDebug("MBox Progress %d of %d",current,maximum ); //odebug << "MH " << current << " von " << maximum << "" << oendl; } QString MHwrapper::buildPath(const QString&p) { QString f=""; if (p.length()==0||p=="/") return MHPath; if (!p.startsWith(MHPath)) { f+=MHPath; } if (!p.startsWith("/")) { f+="/"; } f+=p; return f; } int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) { init_storage(); if (!m_storage) { return 0; } QString f; if (!pfolder) { // toplevel folder f = buildPath(folder); } else { f = pfolder->getName(); f+="/"; f+=folder; } int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); if (r != MAIL_NO_ERROR) { qDebug("error creating folder "); return 0; } - qDebug("Folder created "); return 1; } void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) { init_storage(); if (!m_storage) { return; } QString f = buildPath(Folder); int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); if (r!=MAIL_NO_ERROR) { qDebug("error selecting folder! "); return; } r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); if (r!=MAIL_NO_ERROR) { qDebug("error storing mail "); } return; } encodedString* MHwrapper::fetchRawBody(const RecMailP&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; } |