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,334 +1,336 @@ | |||
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+"/"; |
70 | p+=mail->getMbox(); | 72 | p+=mail->getMbox(); |
71 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 73 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
72 | mailfolder*folder; | 74 | mailfolder*folder; |
73 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 75 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
74 | r = mailfolder_connect(folder); | 76 | r = mailfolder_connect(folder); |
75 | if (r != MAIL_NO_ERROR) { | 77 | if (r != MAIL_NO_ERROR) { |
76 | ; // << "Error initializing mbox" << oendl; | 78 | ; // << "Error initializing mbox" << oendl; |
77 | mailfolder_free(folder); | 79 | mailfolder_free(folder); |
78 | mailstorage_free(storage); | 80 | mailstorage_free(storage); |
79 | return; | 81 | return; |
80 | } | 82 | } |
81 | r = mailsession_remove_message(folder->fld_session,mail->getNumber()); | 83 | r = mailsession_remove_message(folder->fld_session,mail->getNumber()); |
82 | if (r != MAIL_NO_ERROR) { | 84 | if (r != MAIL_NO_ERROR) { |
83 | ; // << "error deleting mail" << oendl; | 85 | ; // << "error deleting mail" << oendl; |
84 | } | 86 | } |
85 | mailfolder_free(folder); | 87 | mailfolder_free(folder); |
86 | mailstorage_free(storage); | 88 | mailstorage_free(storage); |
87 | } | 89 | } |
88 | 90 | ||
89 | void MBOXwrapper::answeredMail(const RecMailP&) | 91 | void MBOXwrapper::answeredMail(const RecMailP&) |
90 | { | 92 | { |
91 | } | 93 | } |
92 | 94 | ||
93 | RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) | 95 | RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) |
94 | { | 96 | { |
95 | RecBodyP body = new RecBody(); | 97 | RecBodyP body = new RecBody(); |
96 | mailstorage*storage = mailstorage_new(NULL); | 98 | mailstorage*storage = mailstorage_new(NULL); |
97 | QString p = MBOXPath+"/"; | 99 | QString p = MBOXPath+"/"; |
98 | p+=mail->getMbox(); | 100 | p+=mail->getMbox(); |
99 | mailmessage * msg; | 101 | mailmessage * msg; |
100 | char*data=0; | 102 | char*data=0; |
101 | size_t size; | 103 | size_t size; |
102 | 104 | ||
103 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 105 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
104 | mailfolder*folder; | 106 | mailfolder*folder; |
105 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 107 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
106 | r = mailfolder_connect(folder); | 108 | r = mailfolder_connect(folder); |
107 | if (r != MAIL_NO_ERROR) { | 109 | if (r != MAIL_NO_ERROR) { |
108 | ; // << "Error initializing mbox" << oendl; | 110 | ; // << "Error initializing mbox" << oendl; |
109 | mailfolder_free(folder); | 111 | mailfolder_free(folder); |
110 | mailstorage_free(storage); | 112 | mailstorage_free(storage); |
111 | return body; | 113 | return body; |
112 | } | 114 | } |
113 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); | 115 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
114 | if (r != MAIL_NO_ERROR) { | 116 | if (r != MAIL_NO_ERROR) { |
115 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; | 117 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; |
116 | mailfolder_free(folder); | 118 | mailfolder_free(folder); |
117 | mailstorage_free(storage); | 119 | mailstorage_free(storage); |
118 | return body; | 120 | return body; |
119 | } | 121 | } |
120 | r = mailmessage_fetch(msg,&data,&size); | 122 | r = mailmessage_fetch(msg,&data,&size); |
121 | if (r != MAIL_NO_ERROR) { | 123 | if (r != MAIL_NO_ERROR) { |
122 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; | 124 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; |
123 | mailfolder_free(folder); | 125 | mailfolder_free(folder); |
124 | mailstorage_free(storage); | 126 | mailstorage_free(storage); |
125 | mailmessage_free(msg); | 127 | mailmessage_free(msg); |
126 | return body; | 128 | return body; |
127 | } | 129 | } |
128 | qDebug("MBOXwrapper::fetchBody "); | 130 | qDebug("MBOXwrapper::fetchBody "); |
129 | body = parseMail(msg); | 131 | body = parseMail(msg); |
130 | mailmessage_fetch_result_free(msg,data); | 132 | mailmessage_fetch_result_free(msg,data); |
131 | mailfolder_free(folder); | 133 | mailfolder_free(folder); |
132 | mailstorage_free(storage); | 134 | mailstorage_free(storage); |
133 | 135 | ||
134 | return body; | 136 | return body; |
135 | } | 137 | } |
136 | 138 | ||
137 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 139 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
138 | { | 140 | { |
139 | ; // << "MBOX " << current << " von " << maximum << "" << oendl; | 141 | ; // << "MBOX " << current << " von " << maximum << "" << oendl; |
140 | } | 142 | } |
141 | 143 | ||
142 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) | 144 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) |
143 | { | 145 | { |
144 | QString p = MBOXPath+"/"; | 146 | QString p = MBOXPath+"/"; |
145 | p+=folder; | 147 | p+=folder; |
146 | QFileInfo fi(p); | 148 | QFileInfo fi(p); |
147 | if (fi.exists()) { | 149 | if (fi.exists()) { |
148 | Global::statusMessage(i18n("Mailbox exists.")); | 150 | Global::statusMessage(i18n("Mailbox exists.")); |
149 | return 0; | 151 | return 0; |
150 | } | 152 | } |
151 | mailmbox_folder*f = 0; | 153 | mailmbox_folder*f = 0; |
152 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | 154 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { |
153 | Global::statusMessage(i18n("Error init folder")); | 155 | Global::statusMessage(i18n("Error init folder")); |
154 | return 0; | 156 | return 0; |
155 | } | 157 | } |
156 | if (f) mailmbox_done(f); | 158 | if (f) mailmbox_done(f); |
157 | return 1; | 159 | return 1; |
158 | } | 160 | } |
159 | 161 | ||
160 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 162 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
161 | { | 163 | { |
162 | QString p = MBOXPath+"/"; | 164 | QString p = MBOXPath+"/"; |
163 | p+=folder; | 165 | p+=folder; |
164 | mailmbox_folder*f = 0; | 166 | mailmbox_folder*f = 0; |
165 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 167 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
166 | if (r != MAIL_NO_ERROR) { | 168 | if (r != MAIL_NO_ERROR) { |
167 | Global::statusMessage(i18n("Error init folder")); | 169 | Global::statusMessage(i18n("Error init folder")); |
168 | return; | 170 | return; |
169 | } | 171 | } |
170 | r = mailmbox_append_message(f,msg,length); | 172 | r = mailmbox_append_message(f,msg,length); |
171 | if (r != MAIL_NO_ERROR) { | 173 | if (r != MAIL_NO_ERROR) { |
172 | Global::statusMessage(i18n("Error writing to message folder")); | 174 | Global::statusMessage(i18n("Error writing to message folder")); |
173 | } | 175 | } |
174 | mailmbox_done(f); | 176 | mailmbox_done(f); |
175 | } | 177 | } |
176 | 178 | ||
177 | encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) | 179 | encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) |
178 | { | 180 | { |
179 | RecBody body; | 181 | RecBody body; |
180 | mailstorage*storage = mailstorage_new(NULL); | 182 | mailstorage*storage = mailstorage_new(NULL); |
181 | QString p = MBOXPath+"/"; | 183 | QString p = MBOXPath+"/"; |
182 | p+=mail->getMbox(); | 184 | p+=mail->getMbox(); |
183 | mailmessage * msg; | 185 | mailmessage * msg; |
184 | char*data=0; | 186 | char*data=0; |
185 | size_t size; | 187 | size_t size; |
186 | 188 | ||
187 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 189 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
188 | mailfolder*folder; | 190 | mailfolder*folder; |
189 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 191 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
190 | r = mailfolder_connect(folder); | 192 | r = mailfolder_connect(folder); |
191 | if (r != MAIL_NO_ERROR) { | 193 | if (r != MAIL_NO_ERROR) { |
192 | Global::statusMessage(i18n("Error initializing mbox")); | 194 | Global::statusMessage(i18n("Error initializing mbox")); |
193 | mailfolder_free(folder); | 195 | mailfolder_free(folder); |
194 | mailstorage_free(storage); | 196 | mailstorage_free(storage); |
195 | return 0; | 197 | return 0; |
196 | } | 198 | } |
197 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); | 199 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
198 | if (r != MAIL_NO_ERROR) { | 200 | if (r != MAIL_NO_ERROR) { |
199 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 201 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
200 | mailfolder_free(folder); | 202 | mailfolder_free(folder); |
201 | mailstorage_free(storage); | 203 | mailstorage_free(storage); |
202 | return 0; | 204 | return 0; |
203 | } | 205 | } |
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(); |
255 | int res = 1; | 257 | int res = 1; |
256 | 258 | ||
257 | mailfolder*folder = 0; | 259 | mailfolder*folder = 0; |
258 | mailmessage_list*l=0; | 260 | mailmessage_list*l=0; |
259 | mailstorage*storage = mailstorage_new(NULL); | 261 | mailstorage*storage = mailstorage_new(NULL); |
260 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 262 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
261 | if (r != MAIL_NO_ERROR) { | 263 | if (r != MAIL_NO_ERROR) { |
262 | Global::statusMessage(i18n("Error initializing mbox")); | 264 | Global::statusMessage(i18n("Error initializing mbox")); |
263 | res = 0; | 265 | res = 0; |
264 | } | 266 | } |
265 | if (res) { | 267 | if (res) { |
266 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 268 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
267 | r = mailfolder_connect(folder); | 269 | r = mailfolder_connect(folder); |
268 | if (r != MAIL_NO_ERROR) { | 270 | if (r != MAIL_NO_ERROR) { |
269 | Global::statusMessage(i18n("Error initializing mbox")); | 271 | Global::statusMessage(i18n("Error initializing mbox")); |
270 | res = 0; | 272 | res = 0; |
271 | } | 273 | } |
272 | } | 274 | } |
273 | if (res) { | 275 | if (res) { |
274 | r = mailsession_get_messages_list(folder->fld_session,&l); | 276 | r = mailsession_get_messages_list(folder->fld_session,&l); |
275 | if (r != MAIL_NO_ERROR) { | 277 | if (r != MAIL_NO_ERROR) { |
276 | ; // << "Error message list" << oendl; | 278 | ; // << "Error message list" << oendl; |
277 | res=0; | 279 | res=0; |
278 | } | 280 | } |
279 | } | 281 | } |
280 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 282 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
281 | r = mailsession_remove_message(folder->fld_session,i+1); | 283 | r = mailsession_remove_message(folder->fld_session,i+1); |
282 | if (r != MAIL_NO_ERROR) { | 284 | if (r != MAIL_NO_ERROR) { |
283 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); | 285 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); |
284 | res = 0; | 286 | res = 0; |
285 | break; | 287 | break; |
286 | } | 288 | } |
287 | } | 289 | } |
288 | if (l) mailmessage_list_free(l); | 290 | if (l) mailmessage_list_free(l); |
289 | if (folder) mailfolder_free(folder); | 291 | if (folder) mailfolder_free(folder); |
290 | if (storage) mailstorage_free(storage); | 292 | if (storage) mailstorage_free(storage); |
291 | return res; | 293 | return res; |
292 | } | 294 | } |
293 | 295 | ||
294 | int MBOXwrapper::deleteMbox(const FolderP&tfolder) | 296 | int MBOXwrapper::deleteMbox(const FolderP&tfolder) |
295 | { | 297 | { |
296 | if (!tfolder) return 0; | 298 | if (!tfolder) return 0; |
297 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); | 299 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); |
298 | QFile fi(p); | 300 | QFile fi(p); |
299 | if (!fi.exists()) { | 301 | if (!fi.exists()) { |
300 | Global::statusMessage(i18n("Mailbox doesn't exist.")); | 302 | Global::statusMessage(i18n("Mailbox doesn't exist.")); |
301 | return 0; | 303 | return 0; |
302 | } | 304 | } |
303 | if (!fi.remove()) { | 305 | if (!fi.remove()) { |
304 | Global::statusMessage(i18n("Error deleting Mailbox.")); | 306 | Global::statusMessage(i18n("Error deleting Mailbox.")); |
305 | return 0; | 307 | return 0; |
306 | } | 308 | } |
307 | return 1; | 309 | return 1; |
308 | } | 310 | } |
309 | 311 | ||
310 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 312 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
311 | { | 313 | { |
312 | mailfolder*folder = 0; | 314 | mailfolder*folder = 0; |
313 | mailstorage*storage = mailstorage_new(NULL); | 315 | mailstorage*storage = mailstorage_new(NULL); |
314 | target_stat.message_count = 0; | 316 | target_stat.message_count = 0; |
315 | target_stat.message_unseen = 0; | 317 | target_stat.message_unseen = 0; |
316 | target_stat.message_recent = 0; | 318 | target_stat.message_recent = 0; |
317 | QString p = MBOXPath+"/"+mailbox; | 319 | QString p = MBOXPath+"/"+mailbox; |
318 | QFile fi(p); | 320 | QFile fi(p); |
319 | if (!fi.exists()) { | 321 | if (!fi.exists()) { |
320 | Global::statusMessage(i18n("Mailbox doesn't exist.")); | 322 | Global::statusMessage(i18n("Mailbox doesn't exist.")); |
321 | return; | 323 | return; |
322 | } | 324 | } |
323 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 325 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
324 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 326 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
325 | r = mailfolder_connect(folder); | 327 | r = mailfolder_connect(folder); |
326 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, | 328 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, |
327 | &target_stat.message_recent,&target_stat.message_unseen); | 329 | &target_stat.message_recent,&target_stat.message_unseen); |
328 | if (folder) mailfolder_free(folder); | 330 | if (folder) mailfolder_free(folder); |
329 | if (storage) mailstorage_free(storage); | 331 | if (storage) mailstorage_free(storage); |
330 | } | 332 | } |
331 | 333 | ||
332 | MAILLIB::ATYPE MBOXwrapper::getType()const | 334 | MAILLIB::ATYPE MBOXwrapper::getType()const |
333 | { | 335 | { |
334 | return MAILLIB::A_MBOX; | 336 | return MAILLIB::A_MBOX; |