summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp27
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
@@ -54,35 +54,35 @@ void MHwrapper::clean_storage()
54 m_storage = 0; 54 m_storage = 0;
55 } 55 }
56} 56}
57 57
58MHwrapper::~MHwrapper() 58MHwrapper::~MHwrapper()
59{ 59{
60 clean_storage(); 60 clean_storage();
61} 61}
62 62
63void MHwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) 63void MHwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
64{ 64{
65 init_storage(); 65 init_storage();
66 if (!m_storage) { 66 if (!m_storage) {
67 return; 67 return;
68 } 68 }
69 QString f = buildPath(mailbox); 69 QString f = buildPath(mailbox);
70 int r = mailsession_select_folder(m_storage->sto_session,(char*)mailbox.latin1()); 70 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
71 if (r!=MAIL_NO_ERROR) { 71 if (r!=MAIL_NO_ERROR) {
72 qDebug("error selecting folder!"); 72 qDebug("listMessages: error selecting folder!");
73 return; 73 return;
74 } 74 }
75 parseList(target,m_storage->sto_session,f); 75 parseList(target,m_storage->sto_session,f);
76 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); 76 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count()));
77} 77}
78 78
79QList<Folder>* MHwrapper::listFolders() 79QList<Folder>* MHwrapper::listFolders()
80{ 80{
81 QList<Folder> * folders = new QList<Folder>(); 81 QList<Folder> * folders = new QList<Folder>();
82 folders->setAutoDelete( false ); 82 folders->setAutoDelete( false );
83 init_storage(); 83 init_storage();
84 if (!m_storage) { 84 if (!m_storage) {
85 return folders; 85 return folders;
86 } 86 }
87 mail_list*flist = 0; 87 mail_list*flist = 0;
88 clistcell*current=0; 88 clistcell*current=0;
@@ -223,44 +223,47 @@ encodedString* MHwrapper::fetchRawBody(const RecMail&mail)
223 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); 223 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
224 return 0; 224 return 0;
225 } 225 }
226 r = mailmessage_fetch(msg,&data,&size); 226 r = mailmessage_fetch(msg,&data,&size);
227 if (r != MAIL_NO_ERROR) { 227 if (r != MAIL_NO_ERROR) {
228 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); 228 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
229 if (msg) mailmessage_free(msg); 229 if (msg) mailmessage_free(msg);
230 return 0; 230 return 0;
231 } 231 }
232 result = new encodedString(data,size); 232 result = new encodedString(data,size);
233 if (msg) mailmessage_free(msg); 233 if (msg) mailmessage_free(msg);
234 return result; 234 return result;
235} 235}
236 236
237void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) 237void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
238{ 238{
239#if 0 239 QString f = buildPath(mailbox);
240 QString p = MHPath+"/"; 240 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
241 p+=mailbox; 241 if (r!=MAIL_NO_ERROR) {
242 mailmbox_folder*f = 0; 242 qDebug("deleteMails: error selecting folder!");
243 int r = mailmbox_init(p.latin1(),0,1,0,&f);
244 if (r != MAIL_NO_ERROR) {
245 qDebug("Error init folder");
246 return; 243 return;
247 } 244 }
248 deleteMails(f,target); 245 RecMail*c = 0;
249 mailmbox_done(f); 246 for (unsigned int i=0; i < target.count();++i) {
250#endif 247 c = target.at(i);
248 r = mailsession_remove_message(m_storage->sto_session,c->getNumber());
249 if (r != MAIL_NO_ERROR) {
250 qDebug("error deleting mail");
251 break;
252 }
253 }
251} 254}
252 255
253int MHwrapper::deleteAllMail(const Folder*tfolder) 256int MHwrapper::deleteAllMail(const Folder*tfolder)
254{ 257{
255 init_storage(); 258 init_storage();
256 if (!m_storage) { 259 if (!m_storage) {
257 return 0; 260 return 0;
258 } 261 }
259 int res = 1; 262 int res = 1;
260 if (!tfolder) return 0; 263 if (!tfolder) return 0;
261 int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); 264 int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
262 if (r!=MAIL_NO_ERROR) { 265 if (r!=MAIL_NO_ERROR) {
263 qDebug("error selecting folder!"); 266 qDebug("error selecting folder!");
264 return 0; 267 return 0;
265 } 268 }
266 mailmessage_list*l=0; 269 mailmessage_list*l=0;