author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/net/mail/libmailwrapper/mhwrapper.cpp | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/net/mail/libmailwrapper/mhwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index dfc00d8..df7f773 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -229,196 +229,196 @@ encodedString* MHwrapper::fetchRawBody(const RecMail&mail) | |||
229 | if (r!=MAIL_NO_ERROR) { | 229 | if (r!=MAIL_NO_ERROR) { |
230 | qDebug("error selecting folder!"); | 230 | qDebug("error selecting folder!"); |
231 | return result; | 231 | return result; |
232 | } | 232 | } |
233 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); | 233 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); |
234 | if (r != MAIL_NO_ERROR) { | 234 | if (r != MAIL_NO_ERROR) { |
235 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 235 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
236 | return 0; | 236 | return 0; |
237 | } | 237 | } |
238 | r = mailmessage_fetch(msg,&data,&size); | 238 | r = mailmessage_fetch(msg,&data,&size); |
239 | if (r != MAIL_NO_ERROR) { | 239 | if (r != MAIL_NO_ERROR) { |
240 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 240 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
241 | if (msg) mailmessage_free(msg); | 241 | if (msg) mailmessage_free(msg); |
242 | return 0; | 242 | return 0; |
243 | } | 243 | } |
244 | result = new encodedString(data,size); | 244 | result = new encodedString(data,size); |
245 | if (msg) mailmessage_free(msg); | 245 | if (msg) mailmessage_free(msg); |
246 | return result; | 246 | return result; |
247 | } | 247 | } |
248 | 248 | ||
249 | void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 249 | void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
250 | { | 250 | { |
251 | QString f = buildPath(mailbox); | 251 | QString f = buildPath(mailbox); |
252 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 252 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
253 | if (r!=MAIL_NO_ERROR) { | 253 | if (r!=MAIL_NO_ERROR) { |
254 | qDebug("deleteMails: error selecting folder!"); | 254 | qDebug("deleteMails: error selecting folder!"); |
255 | return; | 255 | return; |
256 | } | 256 | } |
257 | RecMail*c = 0; | 257 | RecMail*c = 0; |
258 | for (unsigned int i=0; i < target.count();++i) { | 258 | for (unsigned int i=0; i < target.count();++i) { |
259 | c = target.at(i); | 259 | c = target.at(i); |
260 | r = mailsession_remove_message(m_storage->sto_session,c->getNumber()); | 260 | r = mailsession_remove_message(m_storage->sto_session,c->getNumber()); |
261 | if (r != MAIL_NO_ERROR) { | 261 | if (r != MAIL_NO_ERROR) { |
262 | qDebug("error deleting mail"); | 262 | qDebug("error deleting mail"); |
263 | break; | 263 | break; |
264 | } | 264 | } |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | int MHwrapper::deleteAllMail(const Folder*tfolder) | 268 | int MHwrapper::deleteAllMail(const Folder*tfolder) |
269 | { | 269 | { |
270 | init_storage(); | 270 | init_storage(); |
271 | if (!m_storage) { | 271 | if (!m_storage) { |
272 | return 0; | 272 | return 0; |
273 | } | 273 | } |
274 | int res = 1; | 274 | int res = 1; |
275 | if (!tfolder) return 0; | 275 | if (!tfolder) return 0; |
276 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 276 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
277 | if (r!=MAIL_NO_ERROR) { | 277 | if (r!=MAIL_NO_ERROR) { |
278 | qDebug("error selecting folder!"); | 278 | qDebug("error selecting folder!"); |
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
281 | mailmessage_list*l=0; | 281 | mailmessage_list*l=0; |
282 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 282 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
283 | if (r != MAIL_NO_ERROR) { | 283 | if (r != MAIL_NO_ERROR) { |
284 | qDebug("Error message list"); | 284 | qDebug("Error message list"); |
285 | res = 0; | 285 | res = 0; |
286 | } | 286 | } |
287 | unsigned j = 0; | 287 | unsigned j = 0; |
288 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 288 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
289 | mailmessage * msg; | 289 | mailmessage * msg; |
290 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 290 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
291 | j = msg->msg_index; | 291 | j = msg->msg_index; |
292 | r = mailsession_remove_message(m_storage->sto_session,j); | 292 | r = mailsession_remove_message(m_storage->sto_session,j); |
293 | if (r != MAIL_NO_ERROR) { | 293 | if (r != MAIL_NO_ERROR) { |
294 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 294 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
295 | res = 0; | 295 | res = 0; |
296 | break; | 296 | break; |
297 | } | 297 | } |
298 | } | 298 | } |
299 | if (l) mailmessage_list_free(l); | 299 | if (l) mailmessage_list_free(l); |
300 | return res; | 300 | return res; |
301 | } | 301 | } |
302 | 302 | ||
303 | int MHwrapper::deleteMbox(const Folder*tfolder) | 303 | int MHwrapper::deleteMbox(const Folder*tfolder) |
304 | { | 304 | { |
305 | init_storage(); | 305 | init_storage(); |
306 | if (!m_storage) { | 306 | if (!m_storage) { |
307 | return 0; | 307 | return 0; |
308 | } | 308 | } |
309 | if (!tfolder) return 0; | 309 | if (!tfolder) return 0; |
310 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 310 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
311 | 311 | ||
312 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 312 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
313 | 313 | ||
314 | if (r != MAIL_NO_ERROR) { | 314 | if (r != MAIL_NO_ERROR) { |
315 | qDebug("error deleting mail box"); | 315 | qDebug("error deleting mail box"); |
316 | return 0; | 316 | return 0; |
317 | } | 317 | } |
318 | QString cmd = "rm -rf "+tfolder->getName(); | 318 | QString cmd = "rm -rf "+tfolder->getName(); |
319 | QStringList command; | 319 | QStringList command; |
320 | command << "/bin/sh"; | 320 | command << "/bin/sh"; |
321 | command << "-c"; | 321 | command << "-c"; |
322 | command << cmd.latin1(); | 322 | command << cmd.latin1(); |
323 | OProcess *process = new OProcess(); | 323 | OProcess *process = new OProcess(); |
324 | 324 | ||
325 | connect(process, SIGNAL(processExited(OProcess *)), | 325 | connect(process, SIGNAL(processExited(OProcess*)), |
326 | this, SLOT( processEnded(OProcess *))); | 326 | this, SLOT( processEnded(OProcess*))); |
327 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), | 327 | connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)), |
328 | this, SLOT( oprocessStderr(OProcess *, char *, int))); | 328 | this, SLOT( oprocessStderr(OProcess*,char*,int))); |
329 | 329 | ||
330 | *process << command; | 330 | *process << command; |
331 | removeMboxfailed = false; | 331 | removeMboxfailed = false; |
332 | if(!process->start(OProcess::Block, OProcess::All) ) { | 332 | if(!process->start(OProcess::Block, OProcess::All) ) { |
333 | qDebug("could not start process"); | 333 | qDebug("could not start process"); |
334 | return 0; | 334 | return 0; |
335 | } | 335 | } |
336 | qDebug("mail box deleted"); | 336 | qDebug("mail box deleted"); |
337 | return 1; | 337 | return 1; |
338 | } | 338 | } |
339 | 339 | ||
340 | void MHwrapper::processEnded(OProcess *p) | 340 | void MHwrapper::processEnded(OProcess *p) |
341 | { | 341 | { |
342 | if (p) delete p; | 342 | if (p) delete p; |
343 | } | 343 | } |
344 | 344 | ||
345 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) | 345 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) |
346 | { | 346 | { |
347 | QString lineStr = buffer; | 347 | QString lineStr = buffer; |
348 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); | 348 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); |
349 | removeMboxfailed = true; | 349 | removeMboxfailed = true; |
350 | } | 350 | } |
351 | 351 | ||
352 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 352 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
353 | { | 353 | { |
354 | init_storage(); | 354 | init_storage(); |
355 | if (!m_storage) { | 355 | if (!m_storage) { |
356 | return; | 356 | return; |
357 | } | 357 | } |
358 | target_stat.message_count = 0; | 358 | target_stat.message_count = 0; |
359 | target_stat.message_unseen = 0; | 359 | target_stat.message_unseen = 0; |
360 | target_stat.message_recent = 0; | 360 | target_stat.message_recent = 0; |
361 | QString f = buildPath(mailbox); | 361 | QString f = buildPath(mailbox); |
362 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, | 362 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, |
363 | &target_stat.message_recent,&target_stat.message_unseen); | 363 | &target_stat.message_recent,&target_stat.message_unseen); |
364 | if (r != MAIL_NO_ERROR) { | 364 | if (r != MAIL_NO_ERROR) { |
365 | Global::statusMessage(tr("Error retrieving status")); | 365 | Global::statusMessage(tr("Error retrieving status")); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | const QString&MHwrapper::getType()const | 369 | const QString&MHwrapper::getType()const |
370 | { | 370 | { |
371 | return wrapperType; | 371 | return wrapperType; |
372 | } | 372 | } |
373 | 373 | ||
374 | const QString&MHwrapper::getName()const | 374 | const QString&MHwrapper::getName()const |
375 | { | 375 | { |
376 | return MHName; | 376 | return MHName; |
377 | } | 377 | } |
378 | void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 378 | void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
379 | { | 379 | { |
380 | init_storage(); | 380 | init_storage(); |
381 | if (!m_storage) { | 381 | if (!m_storage) { |
382 | return; | 382 | return; |
383 | } | 383 | } |
384 | if (targetWrapper != this) { | 384 | if (targetWrapper != this) { |
385 | qDebug("Using generic"); | 385 | qDebug("Using generic"); |
386 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 386 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
387 | return; | 387 | return; |
388 | } | 388 | } |
389 | qDebug("Using internal routines for move/copy"); | 389 | qDebug("Using internal routines for move/copy"); |
390 | QString tf = buildPath(targetFolder); | 390 | QString tf = buildPath(targetFolder); |
391 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 391 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); |
392 | if (r != MAIL_NO_ERROR) { | 392 | if (r != MAIL_NO_ERROR) { |
393 | qDebug("Error selecting source mailbox"); | 393 | qDebug("Error selecting source mailbox"); |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | if (moveit) { | 396 | if (moveit) { |
397 | r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | 397 | r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); |
398 | } else { | 398 | } else { |
399 | r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | 399 | r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); |
400 | } | 400 | } |
401 | if (r != MAIL_NO_ERROR) { | 401 | if (r != MAIL_NO_ERROR) { |
402 | qDebug("Error copy/moving mail internal (%i)",r); | 402 | qDebug("Error copy/moving mail internal (%i)",r); |
403 | } | 403 | } |
404 | } | 404 | } |
405 | 405 | ||
406 | void MHwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 406 | void MHwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
407 | { | 407 | { |
408 | init_storage(); | 408 | init_storage(); |
409 | if (!m_storage) { | 409 | if (!m_storage) { |
410 | return; | 410 | return; |
411 | } | 411 | } |
412 | if (targetWrapper != this) { | 412 | if (targetWrapper != this) { |
413 | qDebug("Using generic"); | 413 | qDebug("Using generic"); |
414 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 414 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | if (!fromFolder) return; | 417 | if (!fromFolder) return; |
418 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); | 418 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); |
419 | if (r!=MAIL_NO_ERROR) { | 419 | if (r!=MAIL_NO_ERROR) { |
420 | qDebug("error selecting source folder!"); | 420 | qDebug("error selecting source folder!"); |
421 | return; | 421 | return; |
422 | } | 422 | } |
423 | QString tf = buildPath(targetFolder); | 423 | QString tf = buildPath(targetFolder); |
424 | mailmessage_list*l=0; | 424 | mailmessage_list*l=0; |