summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper/mhwrapper.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/libmailwrapper/mhwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
index 403afcf..765a21c 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
@@ -17,7 +17,7 @@ MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name)
17 if (MHPath[MHPath.length()-1]=='/') { 17 if (MHPath[MHPath.length()-1]=='/') {
18 MHPath=MHPath.left(MHPath.length()-1); 18 MHPath=MHPath.left(MHPath.length()-1);
19 } 19 }
20 odebug << MHPath << oendl; 20 odebug << MHPath << oendl;
21 QDir dir(MHPath); 21 QDir dir(MHPath);
22 if (!dir.exists()) { 22 if (!dir.exists()) {
23 dir.mkdir(MHPath); 23 dir.mkdir(MHPath);
@@ -34,7 +34,7 @@ void MHwrapper::init_storage()
34 m_storage = mailstorage_new(NULL); 34 m_storage = mailstorage_new(NULL);
35 r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); 35 r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0);
36 if (r != MAIL_NO_ERROR) { 36 if (r != MAIL_NO_ERROR) {
37 odebug << "error initializing storage" << oendl; 37 odebug << "error initializing storage" << oendl;
38 mailstorage_free(m_storage); 38 mailstorage_free(m_storage);
39 m_storage = 0; 39 m_storage = 0;
40 return; 40 return;
@@ -42,7 +42,7 @@ void MHwrapper::init_storage()
42 } 42 }
43 r = mailstorage_connect(m_storage); 43 r = mailstorage_connect(m_storage);
44 if (r!=MAIL_NO_ERROR) { 44 if (r!=MAIL_NO_ERROR) {
45 odebug << "error connecting storage" << oendl; 45 odebug << "error connecting storage" << oendl;
46 mailstorage_free(m_storage); 46 mailstorage_free(m_storage);
47 m_storage = 0; 47 m_storage = 0;
48 } 48 }
@@ -71,7 +71,7 @@ void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSm
71 QString f = buildPath(mailbox); 71 QString f = buildPath(mailbox);
72 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 72 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
73 if (r!=MAIL_NO_ERROR) { 73 if (r!=MAIL_NO_ERROR) {
74 odebug << "listMessages: error selecting folder!" << oendl; 74 odebug << "listMessages: error selecting folder!" << oendl;
75 return; 75 return;
76 } 76 }
77 parseList(target,m_storage->sto_session,f); 77 parseList(target,m_storage->sto_session,f);
@@ -91,7 +91,7 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders()
91 clistcell*current=0; 91 clistcell*current=0;
92 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); 92 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist);
93 if (r != MAIL_NO_ERROR || !flist) { 93 if (r != MAIL_NO_ERROR || !flist) {
94 odebug << "error getting folder list" << oendl; 94 odebug << "error getting folder list" << oendl;
95 return folders; 95 return folders;
96 } 96 }
97 for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { 97 for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) {
@@ -111,12 +111,12 @@ void MHwrapper::deleteMail(const RecMailP&mail)
111 } 111 }
112 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 112 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
113 if (r!=MAIL_NO_ERROR) { 113 if (r!=MAIL_NO_ERROR) {
114 odebug << "error selecting folder!" << oendl; 114 odebug << "error selecting folder!" << oendl;
115 return; 115 return;
116 } 116 }
117 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); 117 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber());
118 if (r != MAIL_NO_ERROR) { 118 if (r != MAIL_NO_ERROR) {
119 odebug << "error deleting mail" << oendl; 119 odebug << "error deleting mail" << oendl;
120 } 120 }
121} 121}
122 122
@@ -141,7 +141,7 @@ RecBodyP MHwrapper::fetchBody( const RecMailP &mail )
141 } 141 }
142 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); 142 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
143 if (r != MAIL_NO_ERROR) { 143 if (r != MAIL_NO_ERROR) {
144 odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; 144 odebug << "Error fetching mail " << mail->getNumber() << "" << oendl;
145 return body; 145 return body;
146 } 146 }
147 body = parseMail(msg); 147 body = parseMail(msg);
@@ -151,7 +151,7 @@ RecBodyP MHwrapper::fetchBody( const RecMailP &mail )
151 151
152void MHwrapper::mbox_progress( size_t current, size_t maximum ) 152void MHwrapper::mbox_progress( size_t current, size_t maximum )
153{ 153{
154 odebug << "MH " << current << " von " << maximum << "" << oendl; 154 odebug << "MH " << current << " von " << maximum << "" << oendl;
155} 155}
156 156
157QString MHwrapper::buildPath(const QString&p) 157QString MHwrapper::buildPath(const QString&p)
@@ -184,13 +184,13 @@ int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QStri
184 f+="/"; 184 f+="/";
185 f+=folder; 185 f+=folder;
186 } 186 }
187 odebug << f << oendl; 187 odebug << f << oendl;
188 int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); 188 int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1());
189 if (r != MAIL_NO_ERROR) { 189 if (r != MAIL_NO_ERROR) {
190 odebug << "error creating folder " << r << "" << oendl; 190 odebug << "error creating folder " << r << "" << oendl;
191 return 0; 191 return 0;
192 } 192 }
193 odebug << "Folder created" << oendl; 193 odebug << "Folder created" << oendl;
194 return 1; 194 return 1;
195} 195}
196 196
@@ -203,12 +203,12 @@ void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder)
203 QString f = buildPath(Folder); 203 QString f = buildPath(Folder);
204 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 204 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
205 if (r!=MAIL_NO_ERROR) { 205 if (r!=MAIL_NO_ERROR) {
206 odebug << "error selecting folder!" << oendl; 206 odebug << "error selecting folder!" << oendl;
207 return; 207 return;
208 } 208 }
209 r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); 209 r = mailsession_append_message(m_storage->sto_session,(char*)msg,length);
210 if (r!=MAIL_NO_ERROR) { 210 if (r!=MAIL_NO_ERROR) {
211 odebug << "error storing mail" << oendl; 211 odebug << "error storing mail" << oendl;
212 } 212 }
213 return; 213 return;
214} 214}
@@ -225,7 +225,7 @@ encodedString* MHwrapper::fetchRawBody(const RecMailP&mail)
225 size_t size; 225 size_t size;
226 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 226 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
227 if (r!=MAIL_NO_ERROR) { 227 if (r!=MAIL_NO_ERROR) {
228 odebug << "error selecting folder!" << oendl; 228 odebug << "error selecting folder!" << oendl;
229 return result; 229 return result;
230 } 230 }
231 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); 231 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
@@ -249,14 +249,14 @@ void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &
249 QString f = buildPath(mailbox); 249 QString f = buildPath(mailbox);
250 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 250 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
251 if (r!=MAIL_NO_ERROR) { 251 if (r!=MAIL_NO_ERROR) {
252 odebug << "deleteMails: error selecting folder!" << oendl; 252 odebug << "deleteMails: error selecting folder!" << oendl;
253 return; 253 return;
254 } 254 }
255 QValueList<RecMailP>::ConstIterator it; 255 QValueList<RecMailP>::ConstIterator it;
256 for (it=target.begin(); it!=target.end();++it) { 256 for (it=target.begin(); it!=target.end();++it) {
257 r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); 257 r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber());
258 if (r != MAIL_NO_ERROR) { 258 if (r != MAIL_NO_ERROR) {
259 odebug << "error deleting mail" << oendl; 259 odebug << "error deleting mail" << oendl;
260 break; 260 break;
261 } 261 }
262 } 262 }
@@ -272,13 +272,13 @@ int MHwrapper::deleteAllMail(const FolderP&tfolder)
272 if (!tfolder) return 0; 272 if (!tfolder) return 0;
273 int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); 273 int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
274 if (r!=MAIL_NO_ERROR) { 274 if (r!=MAIL_NO_ERROR) {
275 odebug << "error selecting folder!" << oendl; 275 odebug << "error selecting folder!" << oendl;
276 return 0; 276 return 0;
277 } 277 }
278 mailmessage_list*l=0; 278 mailmessage_list*l=0;
279 r = mailsession_get_messages_list(m_storage->sto_session,&l); 279 r = mailsession_get_messages_list(m_storage->sto_session,&l);
280 if (r != MAIL_NO_ERROR) { 280 if (r != MAIL_NO_ERROR) {
281 odebug << "Error message list" << oendl; 281 odebug << "Error message list" << oendl;
282 res = 0; 282 res = 0;
283 } 283 }
284 unsigned j = 0; 284 unsigned j = 0;
@@ -309,7 +309,7 @@ int MHwrapper::deleteMbox(const FolderP&tfolder)
309 int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); 309 int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
310 310
311 if (r != MAIL_NO_ERROR) { 311 if (r != MAIL_NO_ERROR) {
312 odebug << "error deleting mail box" << oendl; 312 odebug << "error deleting mail box" << oendl;
313 return 0; 313 return 0;
314 } 314 }
315 QString cmd = "rm -rf "+tfolder->getName(); 315 QString cmd = "rm -rf "+tfolder->getName();
@@ -327,10 +327,10 @@ int MHwrapper::deleteMbox(const FolderP&tfolder)
327 *process << command; 327 *process << command;
328 removeMboxfailed = false; 328 removeMboxfailed = false;
329 if(!process->start(OProcess::Block, OProcess::All) ) { 329 if(!process->start(OProcess::Block, OProcess::All) ) {
330 odebug << "could not start process" << oendl; 330 odebug << "could not start process" << oendl;
331 return 0; 331 return 0;
332 } 332 }
333 odebug << "mail box deleted" << oendl; 333 odebug << "mail box deleted" << oendl;
334 return 1; 334 return 1;
335} 335}
336 336
@@ -379,15 +379,15 @@ void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,Abstract
379 return; 379 return;
380 } 380 }
381 if (targetWrapper != this) { 381 if (targetWrapper != this) {
382 odebug << "Using generic" << oendl; 382 odebug << "Using generic" << oendl;
383 Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); 383 Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit);
384 return; 384 return;
385 } 385 }
386 odebug << "Using internal routines for move/copy" << oendl; 386 odebug << "Using internal routines for move/copy" << oendl;
387 QString tf = buildPath(targetFolder); 387 QString tf = buildPath(targetFolder);
388 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 388 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
389 if (r != MAIL_NO_ERROR) { 389 if (r != MAIL_NO_ERROR) {
390 odebug << "Error selecting source mailbox" << oendl; 390 odebug << "Error selecting source mailbox" << oendl;
391 return; 391 return;
392 } 392 }
393 if (moveit) { 393 if (moveit) {
@@ -396,7 +396,7 @@ void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,Abstract
396 r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); 396 r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1());
397 } 397 }
398 if (r != MAIL_NO_ERROR) { 398 if (r != MAIL_NO_ERROR) {
399 odebug << "Error copy/moving mail internal (" << r << ")" << oendl; 399 odebug << "Error copy/moving mail internal (" << r << ")" << oendl;
400 } 400 }
401} 401}
402 402
@@ -408,21 +408,21 @@ void MHwrapper::mvcpAllMails(const FolderP&fromFolder,
408 return; 408 return;
409 } 409 }
410 if (targetWrapper != this) { 410 if (targetWrapper != this) {
411 odebug << "Using generic" << oendl; 411 odebug << "Using generic" << oendl;
412 Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); 412 Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
413 return; 413 return;
414 } 414 }
415 if (!fromFolder) return; 415 if (!fromFolder) return;
416 int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); 416 int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1());
417 if (r!=MAIL_NO_ERROR) { 417 if (r!=MAIL_NO_ERROR) {
418 odebug << "error selecting source folder!" << oendl; 418 odebug << "error selecting source folder!" << oendl;
419 return; 419 return;
420 } 420 }
421 QString tf = buildPath(targetFolder); 421 QString tf = buildPath(targetFolder);
422 mailmessage_list*l=0; 422 mailmessage_list*l=0;
423 r = mailsession_get_messages_list(m_storage->sto_session,&l); 423 r = mailsession_get_messages_list(m_storage->sto_session,&l);
424 if (r != MAIL_NO_ERROR) { 424 if (r != MAIL_NO_ERROR) {
425 odebug << "Error message list" << oendl; 425 odebug << "Error message list" << oendl;
426 } 426 }
427 unsigned j = 0; 427 unsigned j = 0;
428 for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { 428 for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) {
@@ -435,7 +435,7 @@ void MHwrapper::mvcpAllMails(const FolderP&fromFolder,
435 r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); 435 r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1());
436 } 436 }
437 if (r != MAIL_NO_ERROR) { 437 if (r != MAIL_NO_ERROR) {
438 odebug << "Error copy/moving mail internal (" << r << ")" << oendl; 438 odebug << "Error copy/moving mail internal (" << r << ")" << oendl;
439 break; 439 break;
440 } 440 }
441 } 441 }