Diffstat (limited to 'kmicromail/libmailwrapper/mhwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp index f4133c0..de6d220 100644 --- a/kmicromail/libmailwrapper/mhwrapper.cpp +++ b/kmicromail/libmailwrapper/mhwrapper.cpp @@ -1,76 +1,76 @@ // CHANGED 2004-09-31 Lutz Rogowski #include "mhwrapper.h" #include "mailtypes.h" #include "mailwrapper.h" #include <libetpan/libetpan.h> #include <qdir.h> #include <qmessagebox.h> #include <stdlib.h> #include <qpe/global.h> -#include <oprocess.h> #include <klocale.h> -//#include <opie2/odebug.h> +#include <kglobal.h> +//#include <opie2/odebug.h> using namespace Opie::Core; MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) { if (MHPath.length()>0) { if (MHPath[MHPath.length()-1]=='/') { MHPath=MHPath.left(MHPath.length()-1); } //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 ) { 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! "); @@ -254,161 +254,155 @@ void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> & if (r!=MAIL_NO_ERROR) { qDebug("deleteMails: error selecting folder! "); return; } QValueList<RecMailP>::ConstIterator it; for (it=target.begin(); it!=target.end();++it) { r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); if (r != MAIL_NO_ERROR) { qDebug("error deleting mail "); break; } } } int MHwrapper::deleteAllMail(const FolderP&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(i18n("Error deleting mail %1").arg(i+1)); res = 0; break; } } if (l) mailmessage_list_free(l); return res; } int MHwrapper::deleteMbox(const FolderP&tfolder) { init_storage(); if (!m_storage) { return 0; } if (!tfolder) return 0; if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); if (r != MAIL_NO_ERROR) { qDebug("error deleting mail box "); return 0; } + QString delDir = locateLocal( "apps", "kopiemail")+ "localmail"; + qDebug("*****************\ndel %s %s ", delDir.latin1(),tfolder->getName().latin1() ); +#if 0 QString cmd = "rm -rf "+tfolder->getName(); QStringList command; command << "/bin/sh"; command << "-c"; command << cmd.latin1(); OProcess *process = new OProcess(); + /* connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT( processEnded(Opie::Core::OProcess*))); connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); - + */ *process << command; removeMboxfailed = false; if(!process->start(OProcess::Block, OProcess::All) ) { qDebug("could not start process "); return 0; } +#endif qDebug("mail box deleted "); return 1; } -void MHwrapper::processEnded(OProcess *p) -{ - if (p) delete p; -} - -void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) -{ - QString lineStr = buffer; - QMessageBox::warning( 0, i18n("Error"), lineStr ,i18n("Ok") ); - removeMboxfailed = true; -} void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) { init_storage(); if (!m_storage) { return; } target_stat.message_count = 0; target_stat.message_unseen = 0; target_stat.message_recent = 0; QString f = buildPath(mailbox); int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, &target_stat.message_recent,&target_stat.message_unseen); if (r != MAIL_NO_ERROR) { Global::statusMessage(i18n("Error retrieving status")); } } MAILLIB::ATYPE MHwrapper::getType()const { return MAILLIB::A_MH; } const QString&MHwrapper::getName()const { return MHName; } void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) { init_storage(); if (!m_storage) { return; } if (targetWrapper != this) { qDebug("Using generic "); Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); return; } qDebug("Using internal routines for move/copy "); QString tf = buildPath(targetFolder); int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); if (r != MAIL_NO_ERROR) { qDebug("Error selecting source mailbox "); return; } if (moveit) { r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); } else { r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); } if (r != MAIL_NO_ERROR) { qDebug("Error copy/moving mail internal "); } } void MHwrapper::mvcpAllMails(const FolderP&fromFolder, const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) { init_storage(); if (!m_storage) { return; } if (targetWrapper != this) { qDebug("Using generic "); |