author | zautrix <zautrix> | 2004-08-31 21:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-31 21:01:18 (UTC) |
commit | 3f5c51234c8068f3d4826a2a0066648ace21a19f (patch) (unidiff) | |
tree | 91b76c1c7ddec6628c573e409070070747d99feb /kmicromail/libmailwrapper/mhwrapper.cpp | |
parent | 95f8d4f1de557bd25ae38807d970208399cec5d1 (diff) | |
download | kdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.zip kdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.tar.gz kdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.tar.bz2 |
Enhancements of kopiemail
Diffstat (limited to 'kmicromail/libmailwrapper/mhwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 5 |
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,125 +1,126 @@ | |||
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 | ||
12 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
13 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 14 | MHwrapper::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 | } |
25 | init_storage(); | 26 | init_storage(); |
26 | } | 27 | } |
27 | } | 28 | } |
28 | 29 | ||
29 | void MHwrapper::init_storage() | 30 | void MHwrapper::init_storage() |
30 | { | 31 | { |
31 | int r; | 32 | int r; |
32 | QString pre = MHPath; | 33 | QString pre = MHPath; |
33 | if (!m_storage) { | 34 | if (!m_storage) { |
34 | m_storage = mailstorage_new(NULL); | 35 | m_storage = mailstorage_new(NULL); |
35 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 36 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
36 | if (r != MAIL_NO_ERROR) { | 37 | if (r != MAIL_NO_ERROR) { |
37 | qDebug(" error init storage "); | 38 | qDebug(" error init storage "); |
38 | mailstorage_free(m_storage); | 39 | mailstorage_free(m_storage); |
39 | m_storage = 0; | 40 | m_storage = 0; |
40 | return; | 41 | return; |
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 | ||
51 | void MHwrapper::clean_storage() | 52 | void 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 | ||
60 | MHwrapper::~MHwrapper() | 61 | MHwrapper::~MHwrapper() |
61 | { | 62 | { |
62 | clean_storage(); | 63 | clean_storage(); |
63 | } | 64 | } |
64 | 65 | ||
65 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 66 | void 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 | ||
81 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 82 | QValueList<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 | } |
102 | mail_list_free(flist); | 103 | mail_list_free(flist); |
103 | return folders; | 104 | return folders; |
104 | } | 105 | } |
105 | 106 | ||
106 | void MHwrapper::deleteMail(const RecMailP&mail) | 107 | void MHwrapper::deleteMail(const RecMailP&mail) |
107 | { | 108 | { |
108 | init_storage(); | 109 | init_storage(); |
109 | if (!m_storage) { | 110 | if (!m_storage) { |
110 | return; | 111 | return; |
111 | } | 112 | } |
112 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 113 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
113 | if (r!=MAIL_NO_ERROR) { | 114 | if (r!=MAIL_NO_ERROR) { |
114 | qDebug("error selecting folder! "); | 115 | qDebug("error selecting folder! "); |
115 | return; | 116 | return; |
116 | } | 117 | } |
117 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); | 118 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); |
118 | if (r != MAIL_NO_ERROR) { | 119 | if (r != MAIL_NO_ERROR) { |
119 | qDebug("error deleting mail "); | 120 | qDebug("error deleting mail "); |
120 | } | 121 | } |
121 | } | 122 | } |
122 | 123 | ||
123 | void MHwrapper::answeredMail(const RecMailP&) | 124 | void MHwrapper::answeredMail(const RecMailP&) |
124 | { | 125 | { |
125 | } | 126 | } |