summaryrefslogtreecommitdiffabout
path: root/kmicromail
Side-by-side diff
Diffstat (limited to 'kmicromail') (more/less context) (show whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp3
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.cpp55
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.h1
3 files changed, 35 insertions, 24 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index 3aec13d..110583f 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -160,34 +160,35 @@ void IMAPwrapper::login()
m_imap = mailimap_new( 20, &imap_progress );
/* connect */
bool ssl = false;
bool try_tls = false;
bool force_tls = false;
if ( account->ConnectionType() == 2 ) {
ssl = true;
}
if (account->ConnectionType()==1) {
force_tls = true;
}
if ( ssl ) {
- //qDebug("using ssl ");
+ qDebug("using ssl ");
err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port );
+ qDebug("back ");
} else {
err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port );
}
if ( err != MAILIMAP_NO_ERROR &&
err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
QString failure = "";
if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) {
failure="Connection refused";
} else {
failure="Unknown failure";
}
Global::statusMessage(i18n("error connecting imap server: %1").arg(failure));
mailimap_free( m_imap );
m_imap = 0;
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp
index de6d220..90b5d23 100644
--- a/kmicromail/libmailwrapper/mhwrapper.cpp
+++ b/kmicromail/libmailwrapper/mhwrapper.cpp
@@ -286,72 +286,81 @@ int MHwrapper::deleteAllMail(const FolderP&tfolder)
}
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;
}
+bool MHwrapper::rmDir(QString folder) // absolute path!
+{
+ QDir dir ( folder );
+ if ( !dir.exists() )
+ return false;
+ int i;
+ // qDebug("rmdir %s ",folder.latin1());
+ QStringList list = dir.entryList(QDir::Dirs|QDir::Files|QDir::NoSymLinks|QDir::Hidden );
+ for (i=0; i<list.count(); i++ ) {
+ bool result = true;
+ QString entry = folder+"/"+ list[i] ;
+ //qDebug("entry %s ",entry.latin1() );
+ QFileInfo fi ( entry );
+ if ( fi.isFile() ) {
+ //qDebug("file %s ",entry.latin1() );
+ result = QFile::remove ( entry ) ;
+ } else {
+ //qDebug("dir %s ",entry.latin1());
+ if ( list[i] != "." && list[i] != ".." )
+ result = rmDir( entry );
+ }
+ if ( ! result )
+ return false;
+ }
+ //qDebug("removing... ");
+ return QDir::root().rmdir ( folder, true );
+}
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;
+ //qDebug("*****************\ndel %s %s ", delDir.latin1(),tfolder->getName().latin1() );
+ if ( !rmDir( tfolder->getName() )) {
+ qDebug("error deleteing folder %s ",tfolder->getName().latin1());
}
-#endif
- qDebug("mail box deleted ");
+ else
+ qDebug("mail box deleted %s ", tfolder->getName().latin1());
return 1;
}
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);
diff --git a/kmicromail/libmailwrapper/mhwrapper.h b/kmicromail/libmailwrapper/mhwrapper.h
index 87f8ca1..36a443a 100644
--- a/kmicromail/libmailwrapper/mhwrapper.h
+++ b/kmicromail/libmailwrapper/mhwrapper.h
@@ -38,21 +38,22 @@ public:
virtual encodedString* fetchRawBody(const RecMailP&mail);
virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target);
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
virtual Account* getAccount() { return 0; };
public slots:
protected:
QString buildPath(const QString&p);
QString MHPath;
QString MHName;
void init_storage();
void clean_storage();
+ bool rmDir(QString folderabspath);
bool removeMboxfailed;
};
#endif