summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/mhwrapper.cpp
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper/mhwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp
index 7ef9b32..cbc52d9 100644
--- a/kmicromail/libmailwrapper/mhwrapper.cpp
+++ b/kmicromail/libmailwrapper/mhwrapper.cpp
@@ -1,24 +1,25 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#include "mhwrapper.h" 2#include "mhwrapper.h"
2#include "mailtypes.h" 3#include "mailtypes.h"
3#include "mailwrapper.h" 4#include "mailwrapper.h"
4#include <libetpan/libetpan.h> 5#include <libetpan/libetpan.h>
5#include <qdir.h> 6#include <qdir.h>
6#include <qmessagebox.h> 7#include <qmessagebox.h>
7#include <stdlib.h> 8#include <stdlib.h>
8#include <qpe/global.h> 9#include <qpe/global.h>
9#include <oprocess.h> 10#include <oprocess.h>
10//#include <opie2/odebug.h> 11//#include <opie2/odebug.h>
11 12
12using namespace Opie::Core; 13using namespace Opie::Core;
13MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) 14MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name)
14 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) 15 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name)
15{ 16{
16 if (MHPath.length()>0) { 17 if (MHPath.length()>0) {
17 if (MHPath[MHPath.length()-1]=='/') { 18 if (MHPath[MHPath.length()-1]=='/') {
18 MHPath=MHPath.left(MHPath.length()-1); 19 MHPath=MHPath.left(MHPath.length()-1);
19 } 20 }
20 //odebug << MHPath << oendl; 21 //odebug << MHPath << oendl;
21 QDir dir(MHPath); 22 QDir dir(MHPath);
22 if (!dir.exists()) { 23 if (!dir.exists()) {
23 dir.mkdir(MHPath); 24 dir.mkdir(MHPath);
24 } 25 }
@@ -41,61 +42,61 @@ void MHwrapper::init_storage()
41 } 42 }
42 } 43 }
43 r = mailstorage_connect(m_storage); 44 r = mailstorage_connect(m_storage);
44 if (r!=MAIL_NO_ERROR) { 45 if (r!=MAIL_NO_ERROR) {
45 qDebug("error connecting storage "); 46 qDebug("error connecting storage ");
46 mailstorage_free(m_storage); 47 mailstorage_free(m_storage);
47 m_storage = 0; 48 m_storage = 0;
48 } 49 }
49} 50}
50 51
51void MHwrapper::clean_storage() 52void MHwrapper::clean_storage()
52{ 53{
53 if (m_storage) { 54 if (m_storage) {
54 mailstorage_disconnect(m_storage); 55 mailstorage_disconnect(m_storage);
55 mailstorage_free(m_storage); 56 mailstorage_free(m_storage);
56 m_storage = 0; 57 m_storage = 0;
57 } 58 }
58} 59}
59 60
60MHwrapper::~MHwrapper() 61MHwrapper::~MHwrapper()
61{ 62{
62 clean_storage(); 63 clean_storage();
63} 64}
64 65
65void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) 66void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb )
66{ 67{
67 init_storage(); 68 init_storage();
68 if (!m_storage) { 69 if (!m_storage) {
69 return; 70 return;
70 } 71 }
71 QString f = buildPath(mailbox); 72 QString f = buildPath(mailbox);
72 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 73 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
73 if (r!=MAIL_NO_ERROR) { 74 if (r!=MAIL_NO_ERROR) {
74 qDebug("listMessages: error selecting folder! "); 75 qDebug("listMessages: error selecting folder! ");
75 return; 76 return;
76 } 77 }
77 parseList(target,m_storage->sto_session,f); 78 parseList(target,m_storage->sto_session,f, false, maxSizeInKb );
78 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); 79 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count()));
79} 80}
80 81
81QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() 82QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders()
82{ 83{
83 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); 84 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >();
84 /* this is needed! */ 85 /* this is needed! */
85 if (m_storage) mailstorage_disconnect(m_storage); 86 if (m_storage) mailstorage_disconnect(m_storage);
86 init_storage(); 87 init_storage();
87 if (!m_storage) { 88 if (!m_storage) {
88 return folders; 89 return folders;
89 } 90 }
90 mail_list*flist = 0; 91 mail_list*flist = 0;
91 clistcell*current=0; 92 clistcell*current=0;
92 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); 93 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist);
93 if (r != MAIL_NO_ERROR || !flist) { 94 if (r != MAIL_NO_ERROR || !flist) {
94 qDebug("error getting folder list "); 95 qDebug("error getting folder list ");
95 return folders; 96 return folders;
96 } 97 }
97 for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { 98 for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) {
98 QString t = (char*)current->data; 99 QString t = (char*)current->data;
99 t.replace(0,MHPath.length(),""); 100 t.replace(0,MHPath.length(),"");
100 folders->append(new MHFolder(t,MHPath)); 101 folders->append(new MHFolder(t,MHPath));
101 } 102 }