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/mboxwrapper.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/mboxwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/mboxwrapper.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/kmicromail/libmailwrapper/mboxwrapper.cpp b/kmicromail/libmailwrapper/mboxwrapper.cpp index 87f8c8a..888cae2 100644 --- a/kmicromail/libmailwrapper/mboxwrapper.cpp +++ b/kmicromail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,69 +1,71 @@ | |||
1 | #include "mboxwrapper.h" | 1 | #include "mboxwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | //Added by qt3to4: | ||
7 | #include <Q3ValueList> | ||
6 | #include <stdlib.h> | 8 | #include <stdlib.h> |
7 | #include <klocale.h> | 9 | #include <klocale.h> |
8 | 10 | ||
9 | 11 | ||
10 | #include <qpe/global.h> | 12 | #include <qpe/global.h> |
11 | 13 | ||
12 | using namespace Opie::Core; | 14 | using namespace Opie::Core; |
13 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) | 15 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) |
14 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) | 16 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
15 | { | 17 | { |
16 | QDir dir(MBOXPath); | 18 | QDir dir(MBOXPath); |
17 | if (!dir.exists()) { | 19 | if (!dir.exists()) { |
18 | dir.mkdir(MBOXPath); | 20 | dir.mkdir(MBOXPath); |
19 | } | 21 | } |
20 | } | 22 | } |
21 | 23 | ||
22 | MBOXwrapper::~MBOXwrapper() | 24 | MBOXwrapper::~MBOXwrapper() |
23 | { | 25 | { |
24 | } | 26 | } |
25 | 27 | ||
26 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) | 28 | void MBOXwrapper::listMessages(const QString & mailbox, Q3ValueList<RecMailP> &target ) |
27 | { | 29 | { |
28 | mailstorage*storage = mailstorage_new(NULL); | 30 | mailstorage*storage = mailstorage_new(NULL); |
29 | QString p = MBOXPath+"/"; | 31 | QString p = MBOXPath+"/"; |
30 | p+=mailbox; | 32 | p+=mailbox; |
31 | 33 | ||
32 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 34 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
33 | mailfolder*folder; | 35 | mailfolder*folder; |
34 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 36 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
35 | r = mailfolder_connect(folder); | 37 | r = mailfolder_connect(folder); |
36 | if (r != MAIL_NO_ERROR) { | 38 | if (r != MAIL_NO_ERROR) { |
37 | //odebug << "Error initializing mbox" << oendl; | 39 | //odebug << "Error initializing mbox" << oendl; |
38 | mailfolder_free(folder); | 40 | mailfolder_free(folder); |
39 | mailstorage_free(storage); | 41 | mailstorage_free(storage); |
40 | return; | 42 | return; |
41 | } | 43 | } |
42 | 44 | ||
43 | parseList(target,folder->fld_session,mailbox); | 45 | parseList(target,folder->fld_session,mailbox); |
44 | 46 | ||
45 | mailfolder_disconnect(folder); | 47 | mailfolder_disconnect(folder); |
46 | mailfolder_free(folder); | 48 | mailfolder_free(folder); |
47 | mailstorage_free(storage); | 49 | mailstorage_free(storage); |
48 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); | 50 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); |
49 | } | 51 | } |
50 | 52 | ||
51 | QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() | 53 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() |
52 | { | 54 | { |
53 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 55 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* folders = new Q3ValueList<Opie::Core::OSmartPointer<Folder> >(); |
54 | QDir dir(MBOXPath); | 56 | QDir dir(MBOXPath); |
55 | if (!dir.exists()) return folders; | 57 | if (!dir.exists()) return folders; |
56 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 58 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
57 | QStringList entries = dir.entryList(); | 59 | QStringList entries = dir.entryList(); |
58 | QStringList::ConstIterator it = entries.begin(); | 60 | QStringList::ConstIterator it = entries.begin(); |
59 | for (;it!=entries.end();++it) { | 61 | for (;it!=entries.end();++it) { |
60 | FolderP inb=new Folder(*it,"/"); | 62 | FolderP inb=new Folder(*it,"/"); |
61 | folders->append(inb); | 63 | folders->append(inb); |
62 | } | 64 | } |
63 | return folders; | 65 | return folders; |
64 | } | 66 | } |
65 | 67 | ||
66 | void MBOXwrapper::deleteMail(const RecMailP & mail) | 68 | void MBOXwrapper::deleteMail(const RecMailP & mail) |
67 | { | 69 | { |
68 | mailstorage*storage = mailstorage_new(NULL); | 70 | mailstorage*storage = mailstorage_new(NULL); |
69 | QString p = MBOXPath+"/"; | 71 | QString p = MBOXPath+"/"; |
@@ -204,51 +206,51 @@ encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) | |||
204 | r = mailmessage_fetch(msg,&data,&size); | 206 | r = mailmessage_fetch(msg,&data,&size); |
205 | if (r != MAIL_NO_ERROR) { | 207 | if (r != MAIL_NO_ERROR) { |
206 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 208 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
207 | mailfolder_free(folder); | 209 | mailfolder_free(folder); |
208 | mailstorage_free(storage); | 210 | mailstorage_free(storage); |
209 | mailmessage_free(msg); | 211 | mailmessage_free(msg); |
210 | return 0; | 212 | return 0; |
211 | } | 213 | } |
212 | encodedString*result = new encodedString(data,size); | 214 | encodedString*result = new encodedString(data,size); |
213 | 215 | ||
214 | mailfolder_free(folder); | 216 | mailfolder_free(folder); |
215 | mailstorage_free(storage); | 217 | mailstorage_free(storage); |
216 | mailmessage_free(msg); | 218 | mailmessage_free(msg); |
217 | return result; | 219 | return result; |
218 | } | 220 | } |
219 | 221 | ||
220 | void MBOXwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 222 | void MBOXwrapper::deleteMails(const QString & mailbox,const Q3ValueList<RecMailP> &target) |
221 | { | 223 | { |
222 | QString p = MBOXPath+"/"; | 224 | QString p = MBOXPath+"/"; |
223 | p+=mailbox; | 225 | p+=mailbox; |
224 | mailmbox_folder*f = 0; | 226 | mailmbox_folder*f = 0; |
225 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 227 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
226 | if (r != MAIL_NO_ERROR) { | 228 | if (r != MAIL_NO_ERROR) { |
227 | ; // << "Error init folder" << oendl; | 229 | ; // << "Error init folder" << oendl; |
228 | return; | 230 | return; |
229 | } | 231 | } |
230 | deleteMails(f,target); | 232 | deleteMails(f,target); |
231 | mailmbox_done(f); | 233 | mailmbox_done(f); |
232 | } | 234 | } |
233 | 235 | ||
234 | void MBOXwrapper::deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target) | 236 | void MBOXwrapper::deleteMails(mailmbox_folder*f,const Q3ValueList<RecMailP> &target) |
235 | { | 237 | { |
236 | if (!f) return; | 238 | if (!f) return; |
237 | int r; | 239 | int r; |
238 | QValueList<RecMailP>::ConstIterator it; | 240 | Q3ValueList<RecMailP>::ConstIterator it; |
239 | for (it=target.begin(); it != target.end();++it) { | 241 | for (it=target.begin(); it != target.end();++it) { |
240 | r = mailmbox_delete_msg(f,(*it)->getNumber()); | 242 | r = mailmbox_delete_msg(f,(*it)->getNumber()); |
241 | if (r!=MAILMBOX_NO_ERROR) { | 243 | if (r!=MAILMBOX_NO_ERROR) { |
242 | ; // << "error delete mail" << oendl; | 244 | ; // << "error delete mail" << oendl; |
243 | } | 245 | } |
244 | } | 246 | } |
245 | r = mailmbox_expunge(f); | 247 | r = mailmbox_expunge(f); |
246 | if (r != MAILMBOX_NO_ERROR) { | 248 | if (r != MAILMBOX_NO_ERROR) { |
247 | ; // << "error expunge mailbox" << oendl; | 249 | ; // << "error expunge mailbox" << oendl; |
248 | } | 250 | } |
249 | } | 251 | } |
250 | 252 | ||
251 | int MBOXwrapper::deleteAllMail(const FolderP&tfolder) | 253 | int MBOXwrapper::deleteAllMail(const FolderP&tfolder) |
252 | { | 254 | { |
253 | if (!tfolder) return 0; | 255 | if (!tfolder) return 0; |
254 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); | 256 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); |