summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 3a0b30a..bc496f7 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -155,178 +155,178 @@ int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bo
155 return 1; 155 return 1;
156} 156}
157 157
158void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) 158void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
159{ 159{
160 QString p = MBOXPath+"/"; 160 QString p = MBOXPath+"/";
161 p+=folder; 161 p+=folder;
162 mailmbox_folder*f = 0; 162 mailmbox_folder*f = 0;
163 int r = mailmbox_init(p.latin1(),0,1,0,&f); 163 int r = mailmbox_init(p.latin1(),0,1,0,&f);
164 if (r != MAIL_NO_ERROR) { 164 if (r != MAIL_NO_ERROR) {
165 Global::statusMessage(tr("Error init folder")); 165 Global::statusMessage(tr("Error init folder"));
166 return; 166 return;
167 } 167 }
168 r = mailmbox_append_message(f,msg,length); 168 r = mailmbox_append_message(f,msg,length);
169 if (r != MAIL_NO_ERROR) { 169 if (r != MAIL_NO_ERROR) {
170 Global::statusMessage(tr("Error writing to message folder")); 170 Global::statusMessage(tr("Error writing to message folder"));
171 } 171 }
172 mailmbox_done(f); 172 mailmbox_done(f);
173} 173}
174 174
175encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail) 175encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail)
176{ 176{
177 RecBody body; 177 RecBody body;
178 mailstorage*storage = mailstorage_new(NULL); 178 mailstorage*storage = mailstorage_new(NULL);
179 QString p = MBOXPath+"/"; 179 QString p = MBOXPath+"/";
180 p+=mail.getMbox(); 180 p+=mail.getMbox();
181 mailmessage * msg; 181 mailmessage * msg;
182 char*data=0; 182 char*data=0;
183 size_t size; 183 size_t size;
184 184
185 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 185 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
186 mailfolder*folder; 186 mailfolder*folder;
187 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 187 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
188 r = mailfolder_connect(folder); 188 r = mailfolder_connect(folder);
189 if (r != MAIL_NO_ERROR) { 189 if (r != MAIL_NO_ERROR) {
190 Global::statusMessage(tr("Error initializing mbox")); 190 Global::statusMessage(tr("Error initializing mbox"));
191 mailfolder_free(folder); 191 mailfolder_free(folder);
192 mailstorage_free(storage); 192 mailstorage_free(storage);
193 return 0; 193 return 0;
194 } 194 }
195 r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); 195 r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg);
196 if (r != MAIL_NO_ERROR) { 196 if (r != MAIL_NO_ERROR) {
197 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); 197 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
198 mailfolder_free(folder); 198 mailfolder_free(folder);
199 mailstorage_free(storage); 199 mailstorage_free(storage);
200 return 0; 200 return 0;
201 } 201 }
202 r = mailmessage_fetch(msg,&data,&size); 202 r = mailmessage_fetch(msg,&data,&size);
203 if (r != MAIL_NO_ERROR) { 203 if (r != MAIL_NO_ERROR) {
204 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); 204 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
205 mailfolder_free(folder); 205 mailfolder_free(folder);
206 mailstorage_free(storage); 206 mailstorage_free(storage);
207 mailmessage_free(msg); 207 mailmessage_free(msg);
208 return 0; 208 return 0;
209 } 209 }
210 encodedString*result = new encodedString(data,size); 210 encodedString*result = new encodedString(data,size);
211 211
212 mailfolder_free(folder); 212 mailfolder_free(folder);
213 mailstorage_free(storage); 213 mailstorage_free(storage);
214 mailmessage_free(msg); 214 mailmessage_free(msg);
215 return result; 215 return result;
216} 216}
217 217
218void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) 218void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
219{ 219{
220 QString p = MBOXPath+"/"; 220 QString p = MBOXPath+"/";
221 p+=mailbox; 221 p+=mailbox;
222 mailmbox_folder*f = 0; 222 mailmbox_folder*f = 0;
223 int r = mailmbox_init(p.latin1(),0,1,0,&f); 223 int r = mailmbox_init(p.latin1(),0,1,0,&f);
224 if (r != MAIL_NO_ERROR) { 224 if (r != MAIL_NO_ERROR) {
225 qDebug("Error init folder"); 225 qDebug("Error init folder");
226 return; 226 return;
227 } 227 }
228 deleteMails(f,target); 228 deleteMails(f,target);
229 mailmbox_done(f); 229 mailmbox_done(f);
230} 230}
231 231
232void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) 232void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target)
233{ 233{
234 if (!f) return; 234 if (!f) return;
235 int r; 235 int r;
236 for (unsigned int i=0; i < target.count();++i) { 236 for (unsigned int i=0; i < target.count();++i) {
237 r = mailmbox_delete_msg(f,target.at(i)->getNumber()); 237 r = mailmbox_delete_msg(f,target.at(i)->getNumber());
238 if (r!=MAILMBOX_NO_ERROR) { 238 if (r!=MAILMBOX_NO_ERROR) {
239 qDebug("error delete mail"); 239 qDebug("error delete mail");
240 } 240 }
241 } 241 }
242 r = mailmbox_expunge(f); 242 r = mailmbox_expunge(f);
243 if (r != MAILMBOX_NO_ERROR) { 243 if (r != MAILMBOX_NO_ERROR) {
244 qDebug("error expunge mailbox"); 244 qDebug("error expunge mailbox");
245 } 245 }
246} 246}
247 247
248int MBOXwrapper::deleteAllMail(const Folder*tfolder) 248int MBOXwrapper::deleteAllMail(const Folder*tfolder)
249{ 249{
250 if (!tfolder) return 0; 250 if (!tfolder) return 0;
251 QString p = MBOXPath+tfolder->getDisplayName(); 251 QString p = MBOXPath+"/"+tfolder->getDisplayName();
252 int res = 1; 252 int res = 1;
253 253
254 mailfolder*folder = 0; 254 mailfolder*folder = 0;
255 mailmessage_list*l=0; 255 mailmessage_list*l=0;
256 mailstorage*storage = mailstorage_new(NULL); 256 mailstorage*storage = mailstorage_new(NULL);
257 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 257 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
258 if (r != MAIL_NO_ERROR) { 258 if (r != MAIL_NO_ERROR) {
259 Global::statusMessage(tr("Error initializing mbox")); 259 Global::statusMessage(tr("Error initializing mbox"));
260 res = 0; 260 res = 0;
261 } 261 }
262 if (res) { 262 if (res) {
263 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 263 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
264 r = mailfolder_connect(folder); 264 r = mailfolder_connect(folder);
265 if (r != MAIL_NO_ERROR) { 265 if (r != MAIL_NO_ERROR) {
266 Global::statusMessage(tr("Error initializing mbox")); 266 Global::statusMessage(tr("Error initializing mbox"));
267 res = 0; 267 res = 0;
268 } 268 }
269 } 269 }
270 if (res) { 270 if (res) {
271 r = mailsession_get_messages_list(folder->fld_session,&l); 271 r = mailsession_get_messages_list(folder->fld_session,&l);
272 if (r != MAIL_NO_ERROR) { 272 if (r != MAIL_NO_ERROR) {
273 qDebug("Error message list"); 273 qDebug("Error message list");
274 res=0; 274 res=0;
275 } 275 }
276 } 276 }
277 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { 277 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
278 r = mailsession_remove_message(folder->fld_session,i+1); 278 r = mailsession_remove_message(folder->fld_session,i+1);
279 if (r != MAIL_NO_ERROR) { 279 if (r != MAIL_NO_ERROR) {
280 Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); 280 Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
281 res = 0; 281 res = 0;
282 break; 282 break;
283 } 283 }
284 } 284 }
285 if (l) mailmessage_list_free(l); 285 if (l) mailmessage_list_free(l);
286 if (folder) mailfolder_free(folder); 286 if (folder) mailfolder_free(folder);
287 if (storage) mailstorage_free(storage); 287 if (storage) mailstorage_free(storage);
288 return res; 288 return res;
289} 289}
290 290
291int MBOXwrapper::deleteMbox(const Folder*tfolder) 291int MBOXwrapper::deleteMbox(const Folder*tfolder)
292{ 292{
293 if (!tfolder) return 0; 293 if (!tfolder) return 0;
294 QString p = MBOXPath+tfolder->getDisplayName(); 294 QString p = MBOXPath+"/"+tfolder->getDisplayName();
295 QFile fi(p); 295 QFile fi(p);
296 if (!fi.exists()) { 296 if (!fi.exists()) {
297 Global::statusMessage(tr("Mailbox doesn't exist.")); 297 Global::statusMessage(tr("Mailbox doesn't exist."));
298 return 0; 298 return 0;
299 } 299 }
300 if (!fi.remove()) { 300 if (!fi.remove()) {
301 Global::statusMessage(tr("Error deleting Mailbox.")); 301 Global::statusMessage(tr("Error deleting Mailbox."));
302 return 0; 302 return 0;
303 } 303 }
304 return 1; 304 return 1;
305} 305}
306 306
307void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) 307void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
308{ 308{
309 mailfolder*folder = 0; 309 mailfolder*folder = 0;
310 mailstorage*storage = mailstorage_new(NULL); 310 mailstorage*storage = mailstorage_new(NULL);
311 target_stat.message_count = 0; 311 target_stat.message_count = 0;
312 target_stat.message_unseen = 0; 312 target_stat.message_unseen = 0;
313 target_stat.message_recent = 0; 313 target_stat.message_recent = 0;
314 QString p = MBOXPath+"/"+mailbox; 314 QString p = MBOXPath+"/"+mailbox;
315 QFile fi(p); 315 QFile fi(p);
316 if (!fi.exists()) { 316 if (!fi.exists()) {
317 Global::statusMessage(tr("Mailbox doesn't exist.")); 317 Global::statusMessage(tr("Mailbox doesn't exist."));
318 return; 318 return;
319 } 319 }
320 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 320 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
321 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 321 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
322 r = mailfolder_connect(folder); 322 r = mailfolder_connect(folder);
323 r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, 323 r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count,
324 &target_stat.message_recent,&target_stat.message_unseen); 324 &target_stat.message_recent,&target_stat.message_unseen);
325 if (folder) mailfolder_free(folder); 325 if (folder) mailfolder_free(folder);
326 if (storage) mailstorage_free(storage); 326 if (storage) mailstorage_free(storage);
327} 327}
328 328
329const QString&MBOXwrapper::getType()const 329const QString&MBOXwrapper::getType()const
330{ 330{
331 return wrapperType; 331 return wrapperType;
332} 332}