author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kmicromail/libmailwrapper/mhwrapper.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'kmicromail/libmailwrapper/mhwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp index 787e85d..4cd7a94 100644 --- a/kmicromail/libmailwrapper/mhwrapper.cpp +++ b/kmicromail/libmailwrapper/mhwrapper.cpp | |||
@@ -1,23 +1,25 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "mhwrapper.h" | 2 | #include "mhwrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | //Added by qt3to4: | ||
9 | #include <Q3ValueList> | ||
8 | #include <stdlib.h> | 10 | #include <stdlib.h> |
9 | #include <qpe/global.h> | 11 | #include <qpe/global.h> |
10 | #include <klocale.h> | 12 | #include <klocale.h> |
11 | #include <kglobal.h> | 13 | #include <kglobal.h> |
12 | //#include <opie2/odebug.h> | 14 | //#include <opie2/odebug.h> |
13 | 15 | ||
14 | using namespace Opie::Core; | 16 | using namespace Opie::Core; |
15 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 17 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
16 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 18 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
17 | { | 19 | { |
18 | if (MHPath.length()>0) { | 20 | if (MHPath.length()>0) { |
19 | if (MHPath[MHPath.length()-1]=='/') { | 21 | if (MHPath[MHPath.length()-1]=='/') { |
20 | MHPath=MHPath.left(MHPath.length()-1); | 22 | MHPath=MHPath.left(MHPath.length()-1); |
21 | } | 23 | } |
22 | //odebug << MHPath << oendl; | 24 | //odebug << MHPath << oendl; |
23 | QDir dir(MHPath); | 25 | QDir dir(MHPath); |
@@ -51,51 +53,51 @@ void MHwrapper::init_storage() | |||
51 | } | 53 | } |
52 | 54 | ||
53 | void MHwrapper::clean_storage() | 55 | void MHwrapper::clean_storage() |
54 | { | 56 | { |
55 | if (m_storage) { | 57 | if (m_storage) { |
56 | mailstorage_disconnect(m_storage); | 58 | mailstorage_disconnect(m_storage); |
57 | mailstorage_free(m_storage); | 59 | mailstorage_free(m_storage); |
58 | m_storage = 0; | 60 | m_storage = 0; |
59 | } | 61 | } |
60 | } | 62 | } |
61 | 63 | ||
62 | MHwrapper::~MHwrapper() | 64 | MHwrapper::~MHwrapper() |
63 | { | 65 | { |
64 | clean_storage(); | 66 | clean_storage(); |
65 | } | 67 | } |
66 | 68 | ||
67 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) | 69 | void MHwrapper::listMessages(const QString & mailbox, Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) |
68 | { | 70 | { |
69 | init_storage(); | 71 | init_storage(); |
70 | if (!m_storage) { | 72 | if (!m_storage) { |
71 | return; | 73 | return; |
72 | } | 74 | } |
73 | QString f = buildPath(mailbox); | 75 | QString f = buildPath(mailbox); |
74 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 76 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
75 | if (r!=MAIL_NO_ERROR) { | 77 | if (r!=MAIL_NO_ERROR) { |
76 | qDebug("listMessages: error selecting folder! "); | 78 | qDebug("listMessages: error selecting folder! "); |
77 | return; | 79 | return; |
78 | } | 80 | } |
79 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); | 81 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); |
80 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); | 82 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); |
81 | } | 83 | } |
82 | 84 | ||
83 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 85 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
84 | { | 86 | { |
85 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 87 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* folders = new Q3ValueList<Opie::Core::OSmartPointer<Folder> >(); |
86 | /* this is needed! */ | 88 | /* this is needed! */ |
87 | if (m_storage) mailstorage_disconnect(m_storage); | 89 | if (m_storage) mailstorage_disconnect(m_storage); |
88 | init_storage(); | 90 | init_storage(); |
89 | if (!m_storage) { | 91 | if (!m_storage) { |
90 | return folders; | 92 | return folders; |
91 | } | 93 | } |
92 | mail_list*flist = 0; | 94 | mail_list*flist = 0; |
93 | clistcell*current=0; | 95 | clistcell*current=0; |
94 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 96 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
95 | if (r != MAIL_NO_ERROR || !flist) { | 97 | if (r != MAIL_NO_ERROR || !flist) { |
96 | qDebug("error getting folder list "); | 98 | qDebug("error getting folder list "); |
97 | return folders; | 99 | return folders; |
98 | } | 100 | } |
99 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 101 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
100 | QString t = (char*)current->data; | 102 | QString t = (char*)current->data; |
101 | t.replace(0,MHPath.length(),""); | 103 | t.replace(0,MHPath.length(),""); |
@@ -242,41 +244,41 @@ encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) | |||
242 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 244 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
243 | if (r != MAIL_NO_ERROR) { | 245 | if (r != MAIL_NO_ERROR) { |
244 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 246 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
245 | return 0; | 247 | return 0; |
246 | } | 248 | } |
247 | r = mailmessage_fetch(msg,&data,&size); | 249 | r = mailmessage_fetch(msg,&data,&size); |
248 | if (r != MAIL_NO_ERROR) { | 250 | if (r != MAIL_NO_ERROR) { |
249 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 251 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
250 | if (msg) mailmessage_free(msg); | 252 | if (msg) mailmessage_free(msg); |
251 | return 0; | 253 | return 0; |
252 | } | 254 | } |
253 | result = new encodedString(data,size); | 255 | result = new encodedString(data,size); |
254 | if (msg) mailmessage_free(msg); | 256 | if (msg) mailmessage_free(msg); |
255 | return result; | 257 | return result; |
256 | } | 258 | } |
257 | 259 | ||
258 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 260 | void MHwrapper::deleteMails(const QString & mailbox,const Q3ValueList<RecMailP> &target) |
259 | { | 261 | { |
260 | QString f = buildPath(mailbox); | 262 | QString f = buildPath(mailbox); |
261 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 263 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
262 | if (r!=MAIL_NO_ERROR) { | 264 | if (r!=MAIL_NO_ERROR) { |
263 | qDebug("deleteMails: error selecting folder! "); | 265 | qDebug("deleteMails: error selecting folder! "); |
264 | return; | 266 | return; |
265 | } | 267 | } |
266 | QValueList<RecMailP>::ConstIterator it; | 268 | Q3ValueList<RecMailP>::ConstIterator it; |
267 | for (it=target.begin(); it!=target.end();++it) { | 269 | for (it=target.begin(); it!=target.end();++it) { |
268 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); | 270 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); |
269 | if (r != MAIL_NO_ERROR) { | 271 | if (r != MAIL_NO_ERROR) { |
270 | qDebug("error deleting mail "); | 272 | qDebug("error deleting mail "); |
271 | break; | 273 | break; |
272 | } | 274 | } |
273 | } | 275 | } |
274 | } | 276 | } |
275 | 277 | ||
276 | int MHwrapper::deleteAllMail(const FolderP&tfolder) | 278 | int MHwrapper::deleteAllMail(const FolderP&tfolder) |
277 | { | 279 | { |
278 | init_storage(); | 280 | init_storage(); |
279 | if (!m_storage) { | 281 | if (!m_storage) { |
280 | return 0; | 282 | return 0; |
281 | } | 283 | } |
282 | int res = 1; | 284 | int res = 1; |