Diffstat (limited to 'noncore/net/mail/libmailwrapper/mhwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index 5adba55..512f778 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -331,3 +331,71 @@ const QString&MHwrapper::getName()const | |||
331 | { | 331 | { |
332 | return MHName; | 332 | return MHName; |
333 | } | 333 | } |
334 | void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
335 | { | ||
336 | init_storage(); | ||
337 | if (!m_storage) { | ||
338 | return; | ||
339 | } | ||
340 | if (targetWrapper != this) { | ||
341 | qDebug("Using generic"); | ||
342 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | ||
343 | return; | ||
344 | } | ||
345 | qDebug("Using internal routines for move/copy"); | ||
346 | QString tf = buildPath(targetFolder); | ||
347 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | ||
348 | if (r != MAIL_NO_ERROR) { | ||
349 | qDebug("Error selecting source mailbox"); | ||
350 | return; | ||
351 | } | ||
352 | if (moveit) { | ||
353 | r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | ||
354 | } else { | ||
355 | r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | ||
356 | } | ||
357 | if (r != MAIL_NO_ERROR) { | ||
358 | qDebug("Error copy/moving mail internal (%i)",r); | ||
359 | } | ||
360 | } | ||
361 | |||
362 | void MHwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
363 | { | ||
364 | init_storage(); | ||
365 | if (!m_storage) { | ||
366 | return; | ||
367 | } | ||
368 | if (targetWrapper != this) { | ||
369 | qDebug("Using generic"); | ||
370 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | ||
371 | return; | ||
372 | } | ||
373 | if (!fromFolder) return; | ||
374 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); | ||
375 | if (r!=MAIL_NO_ERROR) { | ||
376 | qDebug("error selecting source folder!"); | ||
377 | return; | ||
378 | } | ||
379 | QString tf = buildPath(targetFolder); | ||
380 | mailmessage_list*l=0; | ||
381 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | ||
382 | if (r != MAIL_NO_ERROR) { | ||
383 | qDebug("Error message list"); | ||
384 | } | ||
385 | unsigned j = 0; | ||
386 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { | ||
387 | mailmessage * msg; | ||
388 | msg = (mailmessage*)carray_get(l->msg_tab, i); | ||
389 | j = msg->msg_index; | ||
390 | if (moveit) { | ||
391 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); | ||
392 | } else { | ||
393 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); | ||
394 | } | ||
395 | if (r != MAIL_NO_ERROR) { | ||
396 | qDebug("Error copy/moving mail internal (%i)",r); | ||
397 | break; | ||
398 | } | ||
399 | } | ||
400 | if (l) mailmessage_list_free(l); | ||
401 | } | ||