author | alwin <alwin> | 2003-12-28 02:45:07 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-28 02:45:07 (UTC) |
commit | d1a7eb08cad465c5fc0de53f75aaecf7803f0945 (patch) (unidiff) | |
tree | 422b73af760cdd44e4fbbc96bd6876a15939ff19 /noncore | |
parent | e889485e945d8fa9564566f286114be10d2a1ce5 (diff) | |
download | opie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.zip opie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.tar.gz opie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.tar.bz2 |
- dir handling for mbox accounts (delete, new, delete all mail)
- fixed memory leaks in mbox account class
- reduced count of used string constants while using "tr" with context string
- mbox displays messages into global status bar
- fixed a possible raise condition when deleting a mail directory
-rw-r--r-- | noncore/net/mail/accountview.cpp | 143 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 18 | ||||
-rw-r--r-- | noncore/net/mail/genericwrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.cpp | 126 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.h | 8 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/mboxwrapper.cpp | 126 | ||||
-rw-r--r-- | noncore/net/mail/mboxwrapper.h | 8 | ||||
-rw-r--r-- | noncore/net/mail/newmaildir.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/newmaildir.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.h | 3 |
14 files changed, 375 insertions, 86 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 8aac14b..30765cf 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -176,28 +176,28 @@ void IMAPviewItem::refreshFolders(bool force) | |||
176 | item = titem; | 176 | item = titem; |
177 | } else { | 177 | } else { |
178 | item = new IMAPfolderItem( it, this , item ); | 178 | item = new IMAPfolderItem( it, this , item ); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | delete folders; | 181 | delete folders; |
182 | } | 182 | } |
183 | 183 | ||
184 | QPopupMenu * IMAPviewItem::getContextMenu() | 184 | QPopupMenu * IMAPviewItem::getContextMenu() |
185 | { | 185 | { |
186 | QPopupMenu *m = new QPopupMenu(0); | 186 | QPopupMenu *m = new QPopupMenu(0); |
187 | if (m) { | 187 | if (m) { |
188 | m->insertItem(QObject::tr("Refresh folder list","IMAPviewItem"),0); | 188 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
189 | m->insertItem(QObject::tr("Create new folder","IMAPviewItem"),1); | 189 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
190 | m->insertSeparator(); | 190 | m->insertSeparator(); |
191 | m->insertItem(QObject::tr("Disconnect","IMAPviewItem"),2); | 191 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
192 | } | 192 | } |
193 | return m; | 193 | return m; |
194 | } | 194 | } |
195 | 195 | ||
196 | void IMAPviewItem::createNewFolder() | 196 | void IMAPviewItem::createNewFolder() |
197 | { | 197 | { |
198 | Newmdirdlg ndirdlg; | 198 | Newmdirdlg ndirdlg; |
199 | ndirdlg.showMaximized(); | 199 | ndirdlg.showMaximized(); |
200 | if (ndirdlg.exec()) { | 200 | if (ndirdlg.exec()) { |
201 | QString ndir = ndirdlg.Newdir(); | 201 | QString ndir = ndirdlg.Newdir(); |
202 | bool makesubs = ndirdlg.subpossible(); | 202 | bool makesubs = ndirdlg.subpossible(); |
203 | QString delemiter = "/"; | 203 | QString delemiter = "/"; |
@@ -282,43 +282,43 @@ void IMAPfolderItem::refresh(QList<RecMail>&target) | |||
282 | } | 282 | } |
283 | 283 | ||
284 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | 284 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) |
285 | { | 285 | { |
286 | return imap->getWrapper()->fetchBody(aMail); | 286 | return imap->getWrapper()->fetchBody(aMail); |
287 | } | 287 | } |
288 | 288 | ||
289 | QPopupMenu * IMAPfolderItem::getContextMenu() | 289 | QPopupMenu * IMAPfolderItem::getContextMenu() |
290 | { | 290 | { |
291 | QPopupMenu *m = new QPopupMenu(0); | 291 | QPopupMenu *m = new QPopupMenu(0); |
292 | if (m) { | 292 | if (m) { |
293 | if (folder->may_select()) { | 293 | if (folder->may_select()) { |
294 | m->insertItem(QObject::tr("Refresh header list","IMAPfolderItem"),0); | 294 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
295 | m->insertItem(QObject::tr("Delete all mails","IMAPfolderItem"),1); | 295 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
296 | } | 296 | } |
297 | if (folder->no_inferior()==false) { | 297 | if (folder->no_inferior()==false) { |
298 | m->insertItem(QObject::tr("Create new subfolder","IMAPfolderItem"),2); | 298 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
299 | } | 299 | } |
300 | if (folder->getDisplayName().lower()!="inbox") { | 300 | if (folder->getDisplayName().lower()!="inbox") { |
301 | m->insertItem(QObject::tr("Delete folder","IMAPfolderItem"),3); | 301 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | return m; | 304 | return m; |
305 | } | 305 | } |
306 | 306 | ||
307 | void IMAPfolderItem::deleteAllMails() | 307 | void IMAPfolderItem::deleteAllMails() |
308 | { | 308 | { |
309 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails","IMAPfolderItem"), | 309 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), |
310 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>","IMAPfolderItem").arg(folder->getDisplayName()), | 310 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()), |
311 | QObject::tr("Yes","IMAPfolderItem"), | 311 | QObject::tr("Yes",contextName), |
312 | QObject::tr("No","IMAPfolderItem"),QString::null,1,1); | 312 | QObject::tr("No",contextName),QString::null,1,1); |
313 | qDebug("Auswahl: %i",yesno); | 313 | qDebug("Auswahl: %i",yesno); |
314 | if (yesno == 0) { | 314 | if (yesno == 0) { |
315 | if (imap->getWrapper()->deleteAllMail(folder)) { | 315 | if (imap->getWrapper()->deleteAllMail(folder)) { |
316 | AccountView * view = (AccountView*)listView(); | 316 | AccountView * view = (AccountView*)listView(); |
317 | if (view) view->refreshCurrent(); | 317 | if (view) view->refreshCurrent(); |
318 | } | 318 | } |
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | void IMAPfolderItem::createNewFolder() | 322 | void IMAPfolderItem::createNewFolder() |
323 | { | 323 | { |
324 | Newmdirdlg ndirdlg; | 324 | Newmdirdlg ndirdlg; |
@@ -326,34 +326,39 @@ void IMAPfolderItem::createNewFolder() | |||
326 | if (ndirdlg.exec()) { | 326 | if (ndirdlg.exec()) { |
327 | QString ndir = ndirdlg.Newdir(); | 327 | QString ndir = ndirdlg.Newdir(); |
328 | bool makesubs = ndirdlg.subpossible(); | 328 | bool makesubs = ndirdlg.subpossible(); |
329 | QString delemiter = Delemiter(); | 329 | QString delemiter = Delemiter(); |
330 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { | 330 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { |
331 | imap->refreshFolders(true); | 331 | imap->refreshFolders(true); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | void IMAPfolderItem::deleteFolder() | 336 | void IMAPfolderItem::deleteFolder() |
337 | { | 337 | { |
338 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder","IMAPfolderItem"), | 338 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
339 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>","IMAPfolderItem").arg(folder->getDisplayName()), | 339 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
340 | QObject::tr("Yes","IMAPfolderItem"), | 340 | QObject::tr("Yes",contextName), |
341 | QObject::tr("No","IMAPfolderItem"),QString::null,1,1); | 341 | QObject::tr("No",contextName),QString::null,1,1); |
342 | qDebug("Auswahl: %i",yesno); | 342 | qDebug("Auswahl: %i",yesno); |
343 | if (yesno == 0) { | 343 | if (yesno == 0) { |
344 | if (imap->getWrapper()->deleteMbox(folder)) { | 344 | if (imap->getWrapper()->deleteMbox(folder)) { |
345 | /* be carefull - after that this object is destroyd so don't call | 345 | QListView*v=listView(); |
346 | IMAPviewItem * box = imap; | ||
347 | /* be carefull - after that this object is destroyd so don't use | ||
346 | * any member of it after that call!!*/ | 348 | * any member of it after that call!!*/ |
347 | imap->refreshFolders(true); | 349 | imap->refreshFolders(true); |
350 | if (v) { | ||
351 | v->setSelected(box,true); | ||
352 | } | ||
348 | } | 353 | } |
349 | } | 354 | } |
350 | } | 355 | } |
351 | 356 | ||
352 | void IMAPfolderItem::contextMenuSelected(int id) | 357 | void IMAPfolderItem::contextMenuSelected(int id) |
353 | { | 358 | { |
354 | qDebug("Selected id: %i",id); | 359 | qDebug("Selected id: %i",id); |
355 | AccountView * view = (AccountView*)listView(); | 360 | AccountView * view = (AccountView*)listView(); |
356 | switch(id) { | 361 | switch(id) { |
357 | case 0: | 362 | case 0: |
358 | view->refreshCurrent(); | 363 | view->refreshCurrent(); |
359 | break; | 364 | break; |
@@ -366,24 +371,26 @@ void IMAPfolderItem::contextMenuSelected(int id) | |||
366 | case 3: | 371 | case 3: |
367 | deleteFolder(); | 372 | deleteFolder(); |
368 | break; | 373 | break; |
369 | default: | 374 | default: |
370 | break; | 375 | break; |
371 | } | 376 | } |
372 | } | 377 | } |
373 | 378 | ||
374 | /** | 379 | /** |
375 | * Generic stuff | 380 | * Generic stuff |
376 | */ | 381 | */ |
377 | 382 | ||
383 | const QString AccountViewItem::contextName="AccountViewItem"; | ||
384 | |||
378 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 385 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
379 | : QListView( parent, name, flags ) | 386 | : QListView( parent, name, flags ) |
380 | { | 387 | { |
381 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), | 388 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), |
382 | SLOT( refresh( QListViewItem * ) ) ); | 389 | SLOT( refresh( QListViewItem * ) ) ); |
383 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | 390 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, |
384 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); | 391 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); |
385 | 392 | ||
386 | setSorting(0); | 393 | setSorting(0); |
387 | } | 394 | } |
388 | 395 | ||
389 | void AccountView::slotContextMenu(int id) | 396 | void AccountView::slotContextMenu(int id) |
@@ -481,48 +488,90 @@ MBOXviewItem::MBOXviewItem( const QString&aPath, QListView *parent ) | |||
481 | MBOXviewItem::~MBOXviewItem() | 488 | MBOXviewItem::~MBOXviewItem() |
482 | { | 489 | { |
483 | delete wrapper; | 490 | delete wrapper; |
484 | } | 491 | } |
485 | 492 | ||
486 | AbstractMail *MBOXviewItem::getWrapper() | 493 | AbstractMail *MBOXviewItem::getWrapper() |
487 | { | 494 | { |
488 | return wrapper; | 495 | return wrapper; |
489 | } | 496 | } |
490 | 497 | ||
491 | void MBOXviewItem::refresh( QList<RecMail> & ) | 498 | void MBOXviewItem::refresh( QList<RecMail> & ) |
492 | { | 499 | { |
500 | refresh(false); | ||
501 | } | ||
502 | |||
503 | void MBOXviewItem::refresh(bool force) | ||
504 | { | ||
505 | if (childCount()>0 && force==false) return; | ||
493 | QList<Folder> *folders = wrapper->listFolders(); | 506 | QList<Folder> *folders = wrapper->listFolders(); |
494 | QListViewItem *child = firstChild(); | 507 | QListViewItem *child = firstChild(); |
495 | while ( child ) { | 508 | while ( child ) { |
496 | QListViewItem *tmp = child; | 509 | QListViewItem *tmp = child; |
497 | child = child->nextSibling(); | 510 | child = child->nextSibling(); |
498 | delete tmp; | 511 | delete tmp; |
499 | } | 512 | } |
500 | Folder *it; | 513 | Folder *it; |
501 | QListViewItem*item = 0; | 514 | QListViewItem*item = 0; |
502 | for ( it = folders->first(); it; it = folders->next() ) { | 515 | for ( it = folders->first(); it; it = folders->next() ) { |
503 | item = new MBOXfolderItem( it, this , item ); | 516 | item = new MBOXfolderItem( it, this , item ); |
504 | item->setSelectable(it->may_select()); | 517 | item->setSelectable(it->may_select()); |
505 | } | 518 | } |
506 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 519 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
507 | folders->setAutoDelete(false); | 520 | folders->setAutoDelete(false); |
508 | delete folders; | 521 | delete folders; |
509 | } | 522 | } |
510 | 523 | ||
511 | RecBody MBOXviewItem::fetchBody( const RecMail &mail ) | 524 | RecBody MBOXviewItem::fetchBody( const RecMail &mail ) |
512 | { | 525 | { |
513 | qDebug( "POP3 fetchBody" ); | 526 | qDebug( "MBOX fetchBody" ); |
514 | return wrapper->fetchBody( mail ); | 527 | return wrapper->fetchBody( mail ); |
515 | } | 528 | } |
516 | 529 | ||
530 | QPopupMenu * MBOXviewItem::getContextMenu() | ||
531 | { | ||
532 | QPopupMenu *m = new QPopupMenu(0); | ||
533 | if (m) { | ||
534 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | ||
535 | m->insertItem(QObject::tr("Create new folder",contextName),1); | ||
536 | } | ||
537 | return m; | ||
538 | } | ||
539 | |||
540 | void MBOXviewItem::createFolder() | ||
541 | { | ||
542 | Newmdirdlg ndirdlg(0,0,true); | ||
543 | ndirdlg.showMaximized(); | ||
544 | if (ndirdlg.exec()) { | ||
545 | QString ndir = ndirdlg.Newdir(); | ||
546 | if (wrapper->createMbox(ndir)) { | ||
547 | refresh(true); | ||
548 | } | ||
549 | } | ||
550 | } | ||
551 | |||
552 | void MBOXviewItem::contextMenuSelected(int which) | ||
553 | { | ||
554 | switch (which) { | ||
555 | case 0: | ||
556 | refresh(true); | ||
557 | break; | ||
558 | case 1: | ||
559 | createFolder(); | ||
560 | break; | ||
561 | default: | ||
562 | break; | ||
563 | } | ||
564 | } | ||
565 | |||
517 | MBOXfolderItem::~MBOXfolderItem() | 566 | MBOXfolderItem::~MBOXfolderItem() |
518 | { | 567 | { |
519 | delete folder; | 568 | delete folder; |
520 | } | 569 | } |
521 | 570 | ||
522 | MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QListViewItem*after ) | 571 | MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QListViewItem*after ) |
523 | : AccountViewItem( parent,after ) | 572 | : AccountViewItem( parent,after ) |
524 | { | 573 | { |
525 | folder = folderInit; | 574 | folder = folderInit; |
526 | mbox = parent; | 575 | mbox = parent; |
527 | if (folder->getDisplayName().lower() == "outgoing") { | 576 | if (folder->getDisplayName().lower() == "outgoing") { |
528 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 577 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
@@ -535,12 +584,72 @@ MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QList | |||
535 | } | 584 | } |
536 | 585 | ||
537 | void MBOXfolderItem::refresh(QList<RecMail>&target) | 586 | void MBOXfolderItem::refresh(QList<RecMail>&target) |
538 | { | 587 | { |
539 | if (folder->may_select()) | 588 | if (folder->may_select()) |
540 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 589 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
541 | } | 590 | } |
542 | 591 | ||
543 | RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) | 592 | RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) |
544 | { | 593 | { |
545 | return mbox->getWrapper()->fetchBody(aMail); | 594 | return mbox->getWrapper()->fetchBody(aMail); |
546 | } | 595 | } |
596 | |||
597 | void MBOXfolderItem::deleteAllMails() | ||
598 | { | ||
599 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | ||
600 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()), | ||
601 | QObject::tr("Yes",contextName), | ||
602 | QObject::tr("No",contextName),QString::null,1,1); | ||
603 | qDebug("Auswahl: %i",yesno); | ||
604 | if (yesno == 0) { | ||
605 | if (mbox->getWrapper()->deleteAllMail(folder)) { | ||
606 | AccountView * view = (AccountView*)listView(); | ||
607 | if (view) view->refreshCurrent(); | ||
608 | } | ||
609 | } | ||
610 | } | ||
611 | |||
612 | void MBOXfolderItem::deleteFolder() | ||
613 | { | ||
614 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | ||
615 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | ||
616 | QObject::tr("Yes",contextName), | ||
617 | QObject::tr("No",contextName),QString::null,1,1); | ||
618 | qDebug("Auswahl: %i",yesno); | ||
619 | if (yesno == 0) { | ||
620 | if (mbox->getWrapper()->deleteMbox(folder)) { | ||
621 | QListView*v=listView(); | ||
622 | MBOXviewItem * box = mbox; | ||
623 | /* be carefull - after that this object is destroyd so don't use | ||
624 | * any member of it after that call!!*/ | ||
625 | mbox->refresh(true); | ||
626 | if (v) { | ||
627 | v->setSelected(box,true); | ||
628 | } | ||
629 | } | ||
630 | } | ||
631 | } | ||
632 | |||
633 | QPopupMenu * MBOXfolderItem::getContextMenu() | ||
634 | { | ||
635 | QPopupMenu *m = new QPopupMenu(0); | ||
636 | if (m) { | ||
637 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | ||
638 | m->insertItem(QObject::tr("Delete folder",contextName),1); | ||
639 | } | ||
640 | return m; | ||
641 | } | ||
642 | |||
643 | void MBOXfolderItem::contextMenuSelected(int which) | ||
644 | { | ||
645 | switch(which) { | ||
646 | case 0: | ||
647 | deleteAllMails(); | ||
648 | break; | ||
649 | case 1: | ||
650 | deleteFolder(); | ||
651 | break; | ||
652 | default: | ||
653 | break; | ||
654 | } | ||
655 | } | ||
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index e7fe038..98abf44 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -15,24 +15,26 @@ class QPopupMenu; | |||
15 | 15 | ||
16 | class AccountViewItem : public QListViewItem | 16 | class AccountViewItem : public QListViewItem |
17 | { | 17 | { |
18 | 18 | ||
19 | public: | 19 | public: |
20 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} | 20 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} |
21 | AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} | 21 | AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} |
22 | AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} | 22 | AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} |
23 | virtual void refresh(QList<RecMail>&)=0; | 23 | virtual void refresh(QList<RecMail>&)=0; |
24 | virtual RecBody fetchBody(const RecMail&)=0; | 24 | virtual RecBody fetchBody(const RecMail&)=0; |
25 | virtual QPopupMenu * getContextMenu(){return 0;}; | 25 | virtual QPopupMenu * getContextMenu(){return 0;}; |
26 | virtual void contextMenuSelected(int){} | 26 | virtual void contextMenuSelected(int){} |
27 | protected: | ||
28 | static const QString contextName; | ||
27 | }; | 29 | }; |
28 | 30 | ||
29 | class POP3viewItem : public AccountViewItem | 31 | class POP3viewItem : public AccountViewItem |
30 | { | 32 | { |
31 | 33 | ||
32 | public: | 34 | public: |
33 | POP3viewItem( POP3account *a, QListView *parent ); | 35 | POP3viewItem( POP3account *a, QListView *parent ); |
34 | ~POP3viewItem(); | 36 | ~POP3viewItem(); |
35 | virtual void refresh( QList<RecMail> &target ); | 37 | virtual void refresh( QList<RecMail> &target ); |
36 | virtual RecBody fetchBody( const RecMail &mail ); | 38 | virtual RecBody fetchBody( const RecMail &mail ); |
37 | AbstractMail *getWrapper(); | 39 | AbstractMail *getWrapper(); |
38 | private: | 40 | private: |
@@ -79,62 +81,76 @@ private: | |||
79 | }; | 81 | }; |
80 | 82 | ||
81 | class IMAPfolderItem : public AccountViewItem | 83 | class IMAPfolderItem : public AccountViewItem |
82 | { | 84 | { |
83 | 85 | ||
84 | public: | 86 | public: |
85 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); | 87 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); |
86 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); | 88 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); |
87 | ~IMAPfolderItem(); | 89 | ~IMAPfolderItem(); |
88 | virtual void refresh(QList<RecMail>&); | 90 | virtual void refresh(QList<RecMail>&); |
89 | virtual RecBody fetchBody(const RecMail&); | 91 | virtual RecBody fetchBody(const RecMail&); |
90 | bool matchName(const QString&name)const; | 92 | bool matchName(const QString&name)const; |
91 | virtual void deleteAllMails(); | ||
92 | virtual QPopupMenu * getContextMenu(); | 93 | virtual QPopupMenu * getContextMenu(); |
93 | virtual void contextMenuSelected(int); | 94 | virtual void contextMenuSelected(int); |
94 | virtual const QString& Delemiter()const; | 95 | virtual const QString& Delemiter()const; |
95 | protected: | 96 | protected: |
96 | virtual void createNewFolder(); | 97 | virtual void createNewFolder(); |
97 | virtual void deleteFolder(); | 98 | virtual void deleteFolder(); |
99 | virtual void deleteAllMails(); | ||
98 | 100 | ||
99 | private: | 101 | private: |
100 | Folder *folder; | 102 | Folder *folder; |
101 | IMAPviewItem *imap; | 103 | IMAPviewItem *imap; |
102 | }; | 104 | }; |
103 | 105 | ||
104 | class MBOXviewItem : public AccountViewItem | 106 | class MBOXviewItem : public AccountViewItem |
105 | { | 107 | { |
108 | friend class MBOXfolderItem; | ||
106 | 109 | ||
107 | public: | 110 | public: |
108 | // MBOXviewItem( MBOXaccount *a, QListView *parent ); | 111 | // MBOXviewItem( MBOXaccount *a, QListView *parent ); |
109 | MBOXviewItem( const QString&aMboxPath, QListView *parent ); | 112 | MBOXviewItem( const QString&aMboxPath, QListView *parent ); |
110 | ~MBOXviewItem(); | 113 | ~MBOXviewItem(); |
111 | virtual void refresh( QList<RecMail> &target ); | 114 | virtual void refresh( QList<RecMail> &target ); |
112 | virtual RecBody fetchBody( const RecMail &mail ); | 115 | virtual RecBody fetchBody( const RecMail &mail ); |
113 | AbstractMail *getWrapper(); | 116 | AbstractMail *getWrapper(); |
117 | virtual QPopupMenu * getContextMenu(); | ||
118 | virtual void contextMenuSelected(int); | ||
119 | |||
120 | protected: | ||
121 | virtual void refresh(bool force=false); | ||
122 | virtual void createFolder(); | ||
123 | |||
114 | private: | 124 | private: |
115 | // MBOXaccount *account; | 125 | // MBOXaccount *account; |
116 | QString m_Path; | 126 | QString m_Path; |
117 | AbstractMail *wrapper; | 127 | AbstractMail *wrapper; |
118 | 128 | ||
119 | }; | 129 | }; |
120 | 130 | ||
121 | class MBOXfolderItem : public AccountViewItem | 131 | class MBOXfolderItem : public AccountViewItem |
122 | { | 132 | { |
123 | 133 | ||
124 | public: | 134 | public: |
125 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); | 135 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); |
126 | ~MBOXfolderItem(); | 136 | ~MBOXfolderItem(); |
127 | virtual void refresh(QList<RecMail>&); | 137 | virtual void refresh(QList<RecMail>&); |
128 | virtual RecBody fetchBody(const RecMail&); | 138 | virtual RecBody fetchBody(const RecMail&); |
139 | virtual QPopupMenu * getContextMenu(); | ||
140 | virtual void contextMenuSelected(int); | ||
141 | |||
142 | protected: | ||
143 | virtual void deleteAllMails(); | ||
144 | virtual void deleteFolder(); | ||
129 | private: | 145 | private: |
130 | Folder *folder; | 146 | Folder *folder; |
131 | MBOXviewItem *mbox; | 147 | MBOXviewItem *mbox; |
132 | }; | 148 | }; |
133 | 149 | ||
134 | class AccountView : public QListView | 150 | class AccountView : public QListView |
135 | { | 151 | { |
136 | Q_OBJECT | 152 | Q_OBJECT |
137 | 153 | ||
138 | public: | 154 | public: |
139 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 155 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
140 | void populate( QList<Account> list ); | 156 | void populate( QList<Account> list ); |
diff --git a/noncore/net/mail/genericwrapper.h b/noncore/net/mail/genericwrapper.h index 12f6928..90c4b50 100644 --- a/noncore/net/mail/genericwrapper.h +++ b/noncore/net/mail/genericwrapper.h | |||
@@ -40,20 +40,18 @@ protected: | |||
40 | RecBody parseMail( mailmessage * msg ); | 40 | RecBody parseMail( mailmessage * msg ); |
41 | QString parseMailboxList( mailimf_mailbox_list *list ); | 41 | QString parseMailboxList( mailimf_mailbox_list *list ); |
42 | QString parseMailbox( mailimf_mailbox *box ); | 42 | QString parseMailbox( mailimf_mailbox *box ); |
43 | QString parseGroup( mailimf_group *group ); | 43 | QString parseGroup( mailimf_group *group ); |
44 | QString parseAddressList( mailimf_address_list *list ); | 44 | QString parseAddressList( mailimf_address_list *list ); |
45 | QString parseDateTime( mailimf_date_time *date ); | 45 | QString parseDateTime( mailimf_date_time *date ); |
46 | 46 | ||
47 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); | 47 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); |
48 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); | 48 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); |
49 | static void fillParameters(RecPart&target,clist*parameters); | 49 | static void fillParameters(RecPart&target,clist*parameters); |
50 | static QString getencoding(mailmime_mechanism*aEnc); | 50 | static QString getencoding(mailmime_mechanism*aEnc); |
51 | 51 | ||
52 | POP3account *account; | ||
53 | mailpop3 *m_pop3; | ||
54 | QString msgTempName; | 52 | QString msgTempName; |
55 | unsigned int last_msg_id; | 53 | unsigned int last_msg_id; |
56 | QMap<QString,encodedString*> bodyCache; | 54 | QMap<QString,encodedString*> bodyCache; |
57 | }; | 55 | }; |
58 | 56 | ||
59 | #endif | 57 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h index 12f6928..90c4b50 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.h +++ b/noncore/net/mail/libmailwrapper/genericwrapper.h | |||
@@ -40,20 +40,18 @@ protected: | |||
40 | RecBody parseMail( mailmessage * msg ); | 40 | RecBody parseMail( mailmessage * msg ); |
41 | QString parseMailboxList( mailimf_mailbox_list *list ); | 41 | QString parseMailboxList( mailimf_mailbox_list *list ); |
42 | QString parseMailbox( mailimf_mailbox *box ); | 42 | QString parseMailbox( mailimf_mailbox *box ); |
43 | QString parseGroup( mailimf_group *group ); | 43 | QString parseGroup( mailimf_group *group ); |
44 | QString parseAddressList( mailimf_address_list *list ); | 44 | QString parseAddressList( mailimf_address_list *list ); |
45 | QString parseDateTime( mailimf_date_time *date ); | 45 | QString parseDateTime( mailimf_date_time *date ); |
46 | 46 | ||
47 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); | 47 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); |
48 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); | 48 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); |
49 | static void fillParameters(RecPart&target,clist*parameters); | 49 | static void fillParameters(RecPart&target,clist*parameters); |
50 | static QString getencoding(mailmime_mechanism*aEnc); | 50 | static QString getencoding(mailmime_mechanism*aEnc); |
51 | 51 | ||
52 | POP3account *account; | ||
53 | mailpop3 *m_pop3; | ||
54 | QString msgTempName; | 52 | QString msgTempName; |
55 | unsigned int last_msg_id; | 53 | unsigned int last_msg_id; |
56 | QMap<QString,encodedString*> bodyCache; | 54 | QMap<QString,encodedString*> bodyCache; |
57 | }; | 55 | }; |
58 | 56 | ||
59 | #endif | 57 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 6d69263..162a0c9 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,76 +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 <libetpan/mailstorage.h> | ||
6 | #include <qdir.h> | 5 | #include <qdir.h> |
7 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <qpe/global.h> | ||
8 | 8 | ||
9 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) | 9 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) |
10 | : Genericwrapper(),MBOXPath(mbox_dir) | 10 | : Genericwrapper(),MBOXPath(mbox_dir) |
11 | { | 11 | { |
12 | QDir dir(MBOXPath); | 12 | QDir dir(MBOXPath); |
13 | if (!dir.exists()) { | 13 | if (!dir.exists()) { |
14 | dir.mkdir(MBOXPath); | 14 | dir.mkdir(MBOXPath); |
15 | } | 15 | } |
16 | } | 16 | } |
17 | 17 | ||
18 | MBOXwrapper::~MBOXwrapper() | 18 | MBOXwrapper::~MBOXwrapper() |
19 | { | 19 | { |
20 | } | 20 | } |
21 | 21 | ||
22 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 22 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) |
23 | { | 23 | { |
24 | mailstorage*storage = mailstorage_new(NULL); | 24 | mailstorage*storage = mailstorage_new(NULL); |
25 | QString p = MBOXPath+"/"; | 25 | QString p = MBOXPath+"/"; |
26 | p+=mailbox; | 26 | p+=mailbox; |
27 | char*fname = 0; | 27 | |
28 | 28 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | |
29 | fname = strdup(p.latin1()); | ||
30 | |||
31 | int r = mbox_mailstorage_init(storage,fname,0,0,0); | ||
32 | mailfolder*folder; | 29 | mailfolder*folder; |
33 | folder = mailfolder_new( storage,fname,NULL); | 30 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
34 | r = mailfolder_connect(folder); | 31 | r = mailfolder_connect(folder); |
35 | if (r != MAIL_NO_ERROR) { | 32 | if (r != MAIL_NO_ERROR) { |
36 | qDebug("Error initializing mbox"); | 33 | qDebug("Error initializing mbox"); |
37 | mailfolder_free(folder); | 34 | mailfolder_free(folder); |
38 | mailstorage_free(storage); | 35 | mailstorage_free(storage); |
39 | free(fname); | ||
40 | return; | 36 | return; |
41 | } | 37 | } |
42 | mailmessage_list * env_list = 0; | 38 | mailmessage_list * env_list = 0; |
43 | r = mailsession_get_messages_list(folder->fld_session,&env_list); | 39 | r = mailsession_get_messages_list(folder->fld_session,&env_list); |
44 | if (r != MAIL_NO_ERROR) { | 40 | if (r != MAIL_NO_ERROR) { |
45 | qDebug("Error message list"); | 41 | qDebug("Error message list"); |
46 | mailfolder_free(folder); | 42 | mailfolder_free(folder); |
47 | mailstorage_free(storage); | 43 | mailstorage_free(storage); |
48 | free(fname); | ||
49 | return; | 44 | return; |
50 | } | 45 | } |
51 | r = mailsession_get_envelopes_list(folder->fld_session, env_list); | 46 | r = mailsession_get_envelopes_list(folder->fld_session, env_list); |
52 | if (r != MAIL_NO_ERROR) { | 47 | if (r != MAIL_NO_ERROR) { |
53 | qDebug("Error filling message list"); | 48 | qDebug("Error filling message list"); |
54 | if (env_list) { | 49 | if (env_list) { |
55 | mailmessage_list_free(env_list); | 50 | mailmessage_list_free(env_list); |
56 | } | 51 | } |
57 | mailfolder_free(folder); | 52 | mailfolder_free(folder); |
58 | mailstorage_free(storage); | 53 | mailstorage_free(storage); |
59 | free(fname); | ||
60 | return; | 54 | return; |
61 | } | 55 | } |
62 | mailimf_references * refs; | 56 | mailimf_references * refs; |
63 | 57 | ||
64 | for(int i = 0 ; i < carray_count(env_list->msg_tab) ; ++i) { | 58 | uint32_t i = 0; |
59 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | ||
65 | mailmessage * msg; | 60 | mailmessage * msg; |
66 | QBitArray mFlags(7); | 61 | QBitArray mFlags(7); |
67 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 62 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
68 | if (msg->msg_fields == NULL) { | 63 | if (msg->msg_fields == NULL) { |
69 | qDebug("could not fetch envelope of message %i", i); | 64 | qDebug("could not fetch envelope of message %i", i); |
70 | continue; | 65 | continue; |
71 | } | 66 | } |
72 | RecMail * mail = new RecMail(); | 67 | RecMail * mail = new RecMail(); |
73 | mail->setWrapper(this); | 68 | mail->setWrapper(this); |
74 | mail_flags * flag_result = 0; | 69 | mail_flags * flag_result = 0; |
75 | r = mailmessage_get_flags(msg,&flag_result); | 70 | r = mailmessage_get_flags(msg,&flag_result); |
76 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 71 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
@@ -101,52 +96,51 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | |||
101 | char * text = (char*)refs->mid_list->first->data; | 96 | char * text = (char*)refs->mid_list->first->data; |
102 | mail->setReplyto(QString(text)); | 97 | mail->setReplyto(QString(text)); |
103 | } | 98 | } |
104 | 99 | ||
105 | target.append(mail); | 100 | target.append(mail); |
106 | } | 101 | } |
107 | if (env_list) { | 102 | if (env_list) { |
108 | mailmessage_list_free(env_list); | 103 | mailmessage_list_free(env_list); |
109 | } | 104 | } |
110 | mailfolder_disconnect(folder); | 105 | mailfolder_disconnect(folder); |
111 | mailfolder_free(folder); | 106 | mailfolder_free(folder); |
112 | mailstorage_free(storage); | 107 | mailstorage_free(storage); |
113 | free(fname); | 108 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(i)); |
114 | } | 109 | } |
115 | 110 | ||
116 | QList<Folder>* MBOXwrapper::listFolders() | 111 | QList<Folder>* MBOXwrapper::listFolders() |
117 | { | 112 | { |
118 | QList<Folder> * folders = new QList<Folder>(); | 113 | QList<Folder> * folders = new QList<Folder>(); |
119 | folders->setAutoDelete( false ); | 114 | folders->setAutoDelete( false ); |
120 | QDir dir(MBOXPath); | 115 | QDir dir(MBOXPath); |
121 | if (!dir.exists()) return folders; | 116 | if (!dir.exists()) return folders; |
122 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 117 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
123 | QStringList entries = dir.entryList(); | 118 | QStringList entries = dir.entryList(); |
124 | QStringList::ConstIterator it = entries.begin(); | 119 | QStringList::ConstIterator it = entries.begin(); |
125 | for (;it!=entries.end();++it) { | 120 | for (;it!=entries.end();++it) { |
126 | Folder*inb=new Folder(*it,"/"); | 121 | Folder*inb=new Folder(*it,"/"); |
127 | folders->append(inb); | 122 | folders->append(inb); |
128 | } | 123 | } |
129 | return folders; | 124 | return folders; |
130 | } | 125 | } |
131 | 126 | ||
132 | void MBOXwrapper::deleteMail(const RecMail&mail) | 127 | void MBOXwrapper::deleteMail(const RecMail&mail) |
133 | { | 128 | { |
134 | mailstorage*storage = mailstorage_new(NULL); | 129 | mailstorage*storage = mailstorage_new(NULL); |
135 | QString p = MBOXPath+"/"; | 130 | QString p = MBOXPath+"/"; |
136 | p+=mail.getMbox(); | 131 | p+=mail.getMbox(); |
137 | mailmessage * msg; | 132 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
138 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | ||
139 | mailfolder*folder; | 133 | mailfolder*folder; |
140 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 134 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
141 | r = mailfolder_connect(folder); | 135 | r = mailfolder_connect(folder); |
142 | if (r != MAIL_NO_ERROR) { | 136 | if (r != MAIL_NO_ERROR) { |
143 | qDebug("Error initializing mbox"); | 137 | qDebug("Error initializing mbox"); |
144 | mailfolder_free(folder); | 138 | mailfolder_free(folder); |
145 | mailstorage_free(storage); | 139 | mailstorage_free(storage); |
146 | return; | 140 | return; |
147 | } | 141 | } |
148 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); | 142 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); |
149 | if (r != MAIL_NO_ERROR) { | 143 | if (r != MAIL_NO_ERROR) { |
150 | qDebug("error deleting mail"); | 144 | qDebug("error deleting mail"); |
151 | } | 145 | } |
152 | mailfolder_free(folder); | 146 | mailfolder_free(folder); |
@@ -158,27 +152,27 @@ void MBOXwrapper::answeredMail(const RecMail&) | |||
158 | } | 152 | } |
159 | 153 | ||
160 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | 154 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) |
161 | { | 155 | { |
162 | RecBody body; | 156 | RecBody body; |
163 | mailstorage*storage = mailstorage_new(NULL); | 157 | mailstorage*storage = mailstorage_new(NULL); |
164 | QString p = MBOXPath+"/"; | 158 | QString p = MBOXPath+"/"; |
165 | p+=mail.getMbox(); | 159 | p+=mail.getMbox(); |
166 | mailmessage * msg; | 160 | mailmessage * msg; |
167 | char*data=0; | 161 | char*data=0; |
168 | size_t size; | 162 | size_t size; |
169 | 163 | ||
170 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | 164 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
171 | mailfolder*folder; | 165 | mailfolder*folder; |
172 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 166 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
173 | r = mailfolder_connect(folder); | 167 | r = mailfolder_connect(folder); |
174 | if (r != MAIL_NO_ERROR) { | 168 | if (r != MAIL_NO_ERROR) { |
175 | qDebug("Error initializing mbox"); | 169 | qDebug("Error initializing mbox"); |
176 | mailfolder_free(folder); | 170 | mailfolder_free(folder); |
177 | mailstorage_free(storage); | 171 | mailstorage_free(storage); |
178 | return body; | 172 | return body; |
179 | } | 173 | } |
180 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 174 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
181 | if (r != MAIL_NO_ERROR) { | 175 | if (r != MAIL_NO_ERROR) { |
182 | qDebug("Error fetching mail %i",mail.getNumber()); | 176 | qDebug("Error fetching mail %i",mail.getNumber()); |
183 | mailfolder_free(folder); | 177 | mailfolder_free(folder); |
184 | mailstorage_free(storage); | 178 | mailstorage_free(storage); |
@@ -196,98 +190,178 @@ RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | |||
196 | mailmessage_fetch_result_free(msg,data); | 190 | mailmessage_fetch_result_free(msg,data); |
197 | mailfolder_free(folder); | 191 | mailfolder_free(folder); |
198 | mailstorage_free(storage); | 192 | mailstorage_free(storage); |
199 | 193 | ||
200 | return body; | 194 | return body; |
201 | } | 195 | } |
202 | 196 | ||
203 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 197 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
204 | { | 198 | { |
205 | qDebug("MBOX %i von %i",current,maximum); | 199 | qDebug("MBOX %i von %i",current,maximum); |
206 | } | 200 | } |
207 | 201 | ||
208 | void MBOXwrapper::createFolder(const QString&) | 202 | int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) |
209 | { | 203 | { |
204 | QString p = MBOXPath+"/"; | ||
205 | p+=folder; | ||
206 | QFileInfo fi(p); | ||
207 | if (fi.exists()) { | ||
208 | Global::statusMessage(tr("Mailbox exists.")); | ||
209 | return 0; | ||
210 | } | ||
211 | mailmbox_folder*f = 0; | ||
212 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | ||
213 | Global::statusMessage(tr("Error init folder")); | ||
214 | return 0; | ||
215 | } | ||
216 | if (f) mailmbox_done(f); | ||
217 | return 1; | ||
210 | } | 218 | } |
211 | 219 | ||
212 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 220 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
213 | { | 221 | { |
214 | QString p = MBOXPath+"/"; | 222 | QString p = MBOXPath+"/"; |
215 | p+=folder; | 223 | p+=folder; |
216 | mailmbox_folder*f = 0; | 224 | mailmbox_folder*f = 0; |
217 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 225 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
218 | if (r != MAIL_NO_ERROR) { | 226 | if (r != MAIL_NO_ERROR) { |
219 | qDebug("Error init folder"); | 227 | Global::statusMessage(tr("Error init folder")); |
220 | return; | 228 | return; |
221 | } | 229 | } |
222 | r = mailmbox_append_message(f,msg,length); | 230 | r = mailmbox_append_message(f,msg,length); |
223 | if (r != MAIL_NO_ERROR) { | 231 | if (r != MAIL_NO_ERROR) { |
224 | qDebug("Error writing message folder"); | 232 | Global::statusMessage(tr("Error writing to message folder")); |
225 | } | 233 | } |
226 | mailmbox_done(f); | 234 | mailmbox_done(f); |
227 | } | 235 | } |
228 | 236 | ||
229 | void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | 237 | void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) |
230 | { | 238 | { |
231 | RecBody body; | 239 | RecBody body; |
232 | mailstorage*storage = mailstorage_new(NULL); | 240 | mailstorage*storage = mailstorage_new(NULL); |
233 | QString p = MBOXPath+"/"; | 241 | QString p = MBOXPath+"/"; |
234 | p+=mail.getMbox(); | 242 | p+=mail.getMbox(); |
235 | mailmessage * msg; | 243 | mailmessage * msg; |
236 | char*data=0; | 244 | char*data=0; |
237 | size_t size; | 245 | size_t size; |
238 | 246 | ||
239 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | 247 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
240 | mailfolder*folder; | 248 | mailfolder*folder; |
241 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 249 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
242 | r = mailfolder_connect(folder); | 250 | r = mailfolder_connect(folder); |
243 | if (r != MAIL_NO_ERROR) { | 251 | if (r != MAIL_NO_ERROR) { |
244 | qDebug("Error initializing mbox"); | 252 | Global::statusMessage(tr("Error initializing mbox")); |
245 | mailfolder_free(folder); | 253 | mailfolder_free(folder); |
246 | mailstorage_free(storage); | 254 | mailstorage_free(storage); |
247 | return; | 255 | return; |
248 | } | 256 | } |
249 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 257 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
250 | if (r != MAIL_NO_ERROR) { | 258 | if (r != MAIL_NO_ERROR) { |
251 | qDebug("Error fetching mail %i",mail.getNumber()); | 259 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
252 | mailfolder_free(folder); | 260 | mailfolder_free(folder); |
253 | mailstorage_free(storage); | 261 | mailstorage_free(storage); |
254 | return; | 262 | return; |
255 | } | 263 | } |
256 | r = mailmessage_fetch(msg,&data,&size); | 264 | r = mailmessage_fetch(msg,&data,&size); |
257 | if (r != MAIL_NO_ERROR) { | 265 | if (r != MAIL_NO_ERROR) { |
258 | qDebug("Error fetching mail %i",mail.getNumber()); | 266 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
259 | mailfolder_free(folder); | 267 | mailfolder_free(folder); |
260 | mailstorage_free(storage); | 268 | mailstorage_free(storage); |
261 | mailmessage_free(msg); | 269 | mailmessage_free(msg); |
262 | return; | 270 | return; |
263 | } | 271 | } |
264 | *target = data; | 272 | *target = data; |
265 | *length = size; | 273 | *length = size; |
266 | mailfolder_free(folder); | 274 | mailfolder_free(folder); |
267 | mailstorage_free(storage); | 275 | mailstorage_free(storage); |
268 | mailmessage_free(msg); | 276 | mailmessage_free(msg); |
269 | } | 277 | } |
270 | 278 | ||
271 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 279 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
272 | { | 280 | { |
273 | QString p = MBOXPath+"/"; | 281 | QString p = MBOXPath+"/"; |
274 | p+=mailbox; | 282 | p+=mailbox; |
275 | mailmbox_folder*f = 0; | 283 | mailmbox_folder*f = 0; |
276 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 284 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
277 | if (r != MAIL_NO_ERROR) { | 285 | if (r != MAIL_NO_ERROR) { |
278 | qDebug("Error init folder"); | 286 | qDebug("Error init folder"); |
279 | return; | 287 | return; |
280 | } | 288 | } |
289 | deleteMails(f,target); | ||
290 | mailmbox_done(f); | ||
291 | } | ||
292 | |||
293 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | ||
294 | { | ||
295 | if (!f) return; | ||
296 | int r; | ||
281 | for (unsigned int i=0; i < target.count();++i) { | 297 | for (unsigned int i=0; i < target.count();++i) { |
282 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); | 298 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); |
283 | if (r!=MAILMBOX_NO_ERROR) { | 299 | if (r!=MAILMBOX_NO_ERROR) { |
284 | qDebug("error delete mail"); | 300 | qDebug("error delete mail"); |
285 | } | 301 | } |
286 | } | 302 | } |
287 | r = mailmbox_expunge(f); | 303 | r = mailmbox_expunge(f); |
288 | if (r != MAILMBOX_NO_ERROR) { | 304 | if (r != MAILMBOX_NO_ERROR) { |
289 | qDebug("error expunge mailbox"); | 305 | qDebug("error expunge mailbox"); |
290 | } | 306 | } |
291 | mailmbox_done(f); | 307 | } |
308 | |||
309 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) | ||
310 | { | ||
311 | if (!tfolder) return 0; | ||
312 | QString p = MBOXPath+tfolder->getDisplayName(); | ||
313 | int res = 1; | ||
314 | |||
315 | mailfolder*folder = 0; | ||
316 | mailmessage_list*l=0; | ||
317 | mailstorage*storage = mailstorage_new(NULL); | ||
318 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | ||
319 | if (r != MAIL_NO_ERROR) { | ||
320 | Global::statusMessage(tr("Error initializing mbox")); | ||
321 | res = 0; | ||
322 | } | ||
323 | if (res) { | ||
324 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | ||
325 | r = mailfolder_connect(folder); | ||
326 | if (r != MAIL_NO_ERROR) { | ||
327 | Global::statusMessage(tr("Error initializing mbox")); | ||
328 | res = 0; | ||
329 | } | ||
330 | } | ||
331 | if (res) { | ||
332 | r = mailsession_get_messages_list(folder->fld_session,&l); | ||
333 | if (r != MAIL_NO_ERROR) { | ||
334 | qDebug("Error message list"); | ||
335 | res=0; | ||
336 | } | ||
337 | } | ||
338 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | ||
339 | r = mailsession_remove_message(folder->fld_session,i+1); | ||
340 | if (r != MAIL_NO_ERROR) { | ||
341 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | ||
342 | res = 0; | ||
343 | break; | ||
344 | } | ||
345 | } | ||
346 | if (l) mailmessage_list_free(l); | ||
347 | if (folder) mailfolder_free(folder); | ||
348 | if (storage) mailstorage_free(storage); | ||
349 | return res; | ||
350 | } | ||
351 | |||
352 | int MBOXwrapper::deleteMbox(const Folder*tfolder) | ||
353 | { | ||
354 | if (!tfolder) return 0; | ||
355 | QString p = MBOXPath+tfolder->getDisplayName(); | ||
356 | QFile fi(p); | ||
357 | if (!fi.exists()) { | ||
358 | Global::statusMessage(tr("Mailbox doesn't exist.")); | ||
359 | return 0; | ||
360 | } | ||
361 | if (!fi.remove()) { | ||
362 | Global::statusMessage(tr("Error deleting Mailbox.")); | ||
363 | return 0; | ||
364 | } | ||
365 | return 1; | ||
292 | } | 366 | } |
293 | 367 | ||
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index f64ad52..226a544 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -1,35 +1,41 @@ | |||
1 | #ifndef __MBOX_WRAPPER_H | 1 | #ifndef __MBOX_WRAPPER_H |
2 | #define __MBOX_WRAPPER_H | 2 | #define __MBOX_WRAPPER_H |
3 | 3 | ||
4 | #include "genericwrapper.h" | 4 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | struct mailmbox_folder; | ||
9 | 10 | ||
10 | class MBOXwrapper : public Genericwrapper | 11 | class MBOXwrapper : public Genericwrapper |
11 | { | 12 | { |
12 | Q_OBJECT | 13 | Q_OBJECT |
13 | public: | 14 | public: |
14 | MBOXwrapper(const QString & dir); | 15 | MBOXwrapper(const QString & dir); |
15 | virtual ~MBOXwrapper(); | 16 | virtual ~MBOXwrapper(); |
16 | 17 | ||
17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 18 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
18 | virtual QList<Folder>* listFolders(); | 19 | virtual QList<Folder>* listFolders(); |
19 | 20 | ||
20 | virtual void deleteMail(const RecMail&mail); | 21 | virtual void deleteMail(const RecMail&mail); |
21 | virtual void answeredMail(const RecMail&mail); | 22 | virtual void answeredMail(const RecMail&mail); |
22 | virtual void createFolder(const QString&aFolder); | 23 | |
24 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | ||
25 | virtual int deleteMbox(const Folder*); | ||
26 | |||
23 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 27 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
24 | 28 | ||
25 | virtual RecBody fetchBody( const RecMail &mail ); | 29 | virtual RecBody fetchBody( const RecMail &mail ); |
26 | static void mbox_progress( size_t current, size_t maximum ); | 30 | static void mbox_progress( size_t current, size_t maximum ); |
27 | 31 | ||
28 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); | 32 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); |
29 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); | 33 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); |
34 | virtual int deleteAllMail(const Folder*); | ||
30 | 35 | ||
31 | protected: | 36 | protected: |
37 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | ||
32 | QString MBOXPath; | 38 | QString MBOXPath; |
33 | }; | 39 | }; |
34 | 40 | ||
35 | #endif | 41 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index efd83ba..b85fbf6 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,19 +1,18 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include <libetpan/mailpop3.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <libetpan/mailmime.h> | 6 | #include <qpe/global.h> |
7 | #include <libetpan/data_message_driver.h> | ||
8 | #include <qfile.h> | 7 | #include <qfile.h> |
9 | 8 | ||
10 | /* we don't fetch messages larger than 5 MB */ | 9 | /* we don't fetch messages larger than 5 MB */ |
11 | #define HARD_MSG_SIZE_LIMIT 5242880 | 10 | #define HARD_MSG_SIZE_LIMIT 5242880 |
12 | 11 | ||
13 | POP3wrapper::POP3wrapper( POP3account *a ) | 12 | POP3wrapper::POP3wrapper( POP3account *a ) |
14 | : Genericwrapper() | 13 | : Genericwrapper() |
15 | { | 14 | { |
16 | account = a; | 15 | account = a; |
17 | m_pop3 = NULL; | 16 | m_pop3 = NULL; |
18 | msgTempName = a->getFileName()+"_msg_cache"; | 17 | msgTempName = a->getFileName()+"_msg_cache"; |
19 | last_msg_id = 0; | 18 | last_msg_id = 0; |
@@ -103,44 +102,46 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) | |||
103 | } | 102 | } |
104 | 103 | ||
105 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | 104 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) |
106 | { | 105 | { |
107 | int err = MAILPOP3_NO_ERROR; | 106 | int err = MAILPOP3_NO_ERROR; |
108 | char * header = 0; | 107 | char * header = 0; |
109 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ | 108 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ |
110 | size_t length = 0; | 109 | size_t length = 0; |
111 | carray * messages = 0; | 110 | carray * messages = 0; |
112 | 111 | ||
113 | login(); | 112 | login(); |
114 | if (!m_pop3) return; | 113 | if (!m_pop3) return; |
114 | |||
115 | mailpop3_list( m_pop3, &messages ); | 115 | mailpop3_list( m_pop3, &messages ); |
116 | 116 | ||
117 | for (unsigned int i = 0; i < carray_count(messages);++i) { | 117 | for (unsigned int i = 0; i < carray_count(messages);++i) { |
118 | mailpop3_msg_info *info; | 118 | mailpop3_msg_info *info; |
119 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); | 119 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); |
120 | if (info->msg_deleted) | 120 | if (info->msg_deleted) |
121 | continue; | 121 | continue; |
122 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); | 122 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); |
123 | if ( err != MAILPOP3_NO_ERROR ) { | 123 | if ( err != MAILPOP3_NO_ERROR ) { |
124 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); | 124 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); |
125 | free(header); | 125 | free(header); |
126 | return; | 126 | return; |
127 | } | 127 | } |
128 | RecMail *mail = parseHeader( header ); | 128 | RecMail *mail = parseHeader( header ); |
129 | mail->setNumber( info->msg_index ); | 129 | mail->setNumber( info->msg_index ); |
130 | mail->setWrapper(this); | 130 | mail->setWrapper(this); |
131 | mail->setMsgsize(info->msg_size); | 131 | mail->setMsgsize(info->msg_size); |
132 | target.append( mail ); | 132 | target.append( mail ); |
133 | free(header); | 133 | free(header); |
134 | } | 134 | } |
135 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(carray_count(messages)-m_pop3->pop3_deleted_count)); | ||
135 | } | 136 | } |
136 | 137 | ||
137 | void POP3wrapper::login() | 138 | void POP3wrapper::login() |
138 | { | 139 | { |
139 | /* we'll hold the line */ | 140 | /* we'll hold the line */ |
140 | if ( m_pop3 != NULL ) return; | 141 | if ( m_pop3 != NULL ) return; |
141 | 142 | ||
142 | const char *server, *user, *pass; | 143 | const char *server, *user, *pass; |
143 | uint16_t port; | 144 | uint16_t port; |
144 | int err = MAILPOP3_NO_ERROR; | 145 | int err = MAILPOP3_NO_ERROR; |
145 | 146 | ||
146 | server = account->getServer().latin1(); | 147 | server = account->getServer().latin1(); |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index b738cca..7502720 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -17,16 +17,17 @@ public: | |||
17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
18 | virtual QList<Folder>* listFolders(); | 18 | virtual QList<Folder>* listFolders(); |
19 | 19 | ||
20 | virtual void deleteMail(const RecMail&mail); | 20 | virtual void deleteMail(const RecMail&mail); |
21 | virtual void answeredMail(const RecMail&mail); | 21 | virtual void answeredMail(const RecMail&mail); |
22 | 22 | ||
23 | virtual RecBody fetchBody( const RecMail &mail ); | 23 | virtual RecBody fetchBody( const RecMail &mail ); |
24 | static void pop3_progress( size_t current, size_t maximum ); | 24 | static void pop3_progress( size_t current, size_t maximum ); |
25 | 25 | ||
26 | protected: | 26 | protected: |
27 | void login(); | 27 | void login(); |
28 | void logout(); | 28 | void logout(); |
29 | 29 | POP3account *account; | |
30 | mailpop3 *m_pop3; | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | #endif | 33 | #endif |
diff --git a/noncore/net/mail/mboxwrapper.cpp b/noncore/net/mail/mboxwrapper.cpp index 6d69263..162a0c9 100644 --- a/noncore/net/mail/mboxwrapper.cpp +++ b/noncore/net/mail/mboxwrapper.cpp | |||
@@ -1,76 +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 <libetpan/mailstorage.h> | ||
6 | #include <qdir.h> | 5 | #include <qdir.h> |
7 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <qpe/global.h> | ||
8 | 8 | ||
9 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) | 9 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) |
10 | : Genericwrapper(),MBOXPath(mbox_dir) | 10 | : Genericwrapper(),MBOXPath(mbox_dir) |
11 | { | 11 | { |
12 | QDir dir(MBOXPath); | 12 | QDir dir(MBOXPath); |
13 | if (!dir.exists()) { | 13 | if (!dir.exists()) { |
14 | dir.mkdir(MBOXPath); | 14 | dir.mkdir(MBOXPath); |
15 | } | 15 | } |
16 | } | 16 | } |
17 | 17 | ||
18 | MBOXwrapper::~MBOXwrapper() | 18 | MBOXwrapper::~MBOXwrapper() |
19 | { | 19 | { |
20 | } | 20 | } |
21 | 21 | ||
22 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 22 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) |
23 | { | 23 | { |
24 | mailstorage*storage = mailstorage_new(NULL); | 24 | mailstorage*storage = mailstorage_new(NULL); |
25 | QString p = MBOXPath+"/"; | 25 | QString p = MBOXPath+"/"; |
26 | p+=mailbox; | 26 | p+=mailbox; |
27 | char*fname = 0; | 27 | |
28 | 28 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | |
29 | fname = strdup(p.latin1()); | ||
30 | |||
31 | int r = mbox_mailstorage_init(storage,fname,0,0,0); | ||
32 | mailfolder*folder; | 29 | mailfolder*folder; |
33 | folder = mailfolder_new( storage,fname,NULL); | 30 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
34 | r = mailfolder_connect(folder); | 31 | r = mailfolder_connect(folder); |
35 | if (r != MAIL_NO_ERROR) { | 32 | if (r != MAIL_NO_ERROR) { |
36 | qDebug("Error initializing mbox"); | 33 | qDebug("Error initializing mbox"); |
37 | mailfolder_free(folder); | 34 | mailfolder_free(folder); |
38 | mailstorage_free(storage); | 35 | mailstorage_free(storage); |
39 | free(fname); | ||
40 | return; | 36 | return; |
41 | } | 37 | } |
42 | mailmessage_list * env_list = 0; | 38 | mailmessage_list * env_list = 0; |
43 | r = mailsession_get_messages_list(folder->fld_session,&env_list); | 39 | r = mailsession_get_messages_list(folder->fld_session,&env_list); |
44 | if (r != MAIL_NO_ERROR) { | 40 | if (r != MAIL_NO_ERROR) { |
45 | qDebug("Error message list"); | 41 | qDebug("Error message list"); |
46 | mailfolder_free(folder); | 42 | mailfolder_free(folder); |
47 | mailstorage_free(storage); | 43 | mailstorage_free(storage); |
48 | free(fname); | ||
49 | return; | 44 | return; |
50 | } | 45 | } |
51 | r = mailsession_get_envelopes_list(folder->fld_session, env_list); | 46 | r = mailsession_get_envelopes_list(folder->fld_session, env_list); |
52 | if (r != MAIL_NO_ERROR) { | 47 | if (r != MAIL_NO_ERROR) { |
53 | qDebug("Error filling message list"); | 48 | qDebug("Error filling message list"); |
54 | if (env_list) { | 49 | if (env_list) { |
55 | mailmessage_list_free(env_list); | 50 | mailmessage_list_free(env_list); |
56 | } | 51 | } |
57 | mailfolder_free(folder); | 52 | mailfolder_free(folder); |
58 | mailstorage_free(storage); | 53 | mailstorage_free(storage); |
59 | free(fname); | ||
60 | return; | 54 | return; |
61 | } | 55 | } |
62 | mailimf_references * refs; | 56 | mailimf_references * refs; |
63 | 57 | ||
64 | for(int i = 0 ; i < carray_count(env_list->msg_tab) ; ++i) { | 58 | uint32_t i = 0; |
59 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | ||
65 | mailmessage * msg; | 60 | mailmessage * msg; |
66 | QBitArray mFlags(7); | 61 | QBitArray mFlags(7); |
67 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 62 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
68 | if (msg->msg_fields == NULL) { | 63 | if (msg->msg_fields == NULL) { |
69 | qDebug("could not fetch envelope of message %i", i); | 64 | qDebug("could not fetch envelope of message %i", i); |
70 | continue; | 65 | continue; |
71 | } | 66 | } |
72 | RecMail * mail = new RecMail(); | 67 | RecMail * mail = new RecMail(); |
73 | mail->setWrapper(this); | 68 | mail->setWrapper(this); |
74 | mail_flags * flag_result = 0; | 69 | mail_flags * flag_result = 0; |
75 | r = mailmessage_get_flags(msg,&flag_result); | 70 | r = mailmessage_get_flags(msg,&flag_result); |
76 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 71 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
@@ -101,52 +96,51 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | |||
101 | char * text = (char*)refs->mid_list->first->data; | 96 | char * text = (char*)refs->mid_list->first->data; |
102 | mail->setReplyto(QString(text)); | 97 | mail->setReplyto(QString(text)); |
103 | } | 98 | } |
104 | 99 | ||
105 | target.append(mail); | 100 | target.append(mail); |
106 | } | 101 | } |
107 | if (env_list) { | 102 | if (env_list) { |
108 | mailmessage_list_free(env_list); | 103 | mailmessage_list_free(env_list); |
109 | } | 104 | } |
110 | mailfolder_disconnect(folder); | 105 | mailfolder_disconnect(folder); |
111 | mailfolder_free(folder); | 106 | mailfolder_free(folder); |
112 | mailstorage_free(storage); | 107 | mailstorage_free(storage); |
113 | free(fname); | 108 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(i)); |
114 | } | 109 | } |
115 | 110 | ||
116 | QList<Folder>* MBOXwrapper::listFolders() | 111 | QList<Folder>* MBOXwrapper::listFolders() |
117 | { | 112 | { |
118 | QList<Folder> * folders = new QList<Folder>(); | 113 | QList<Folder> * folders = new QList<Folder>(); |
119 | folders->setAutoDelete( false ); | 114 | folders->setAutoDelete( false ); |
120 | QDir dir(MBOXPath); | 115 | QDir dir(MBOXPath); |
121 | if (!dir.exists()) return folders; | 116 | if (!dir.exists()) return folders; |
122 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 117 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
123 | QStringList entries = dir.entryList(); | 118 | QStringList entries = dir.entryList(); |
124 | QStringList::ConstIterator it = entries.begin(); | 119 | QStringList::ConstIterator it = entries.begin(); |
125 | for (;it!=entries.end();++it) { | 120 | for (;it!=entries.end();++it) { |
126 | Folder*inb=new Folder(*it,"/"); | 121 | Folder*inb=new Folder(*it,"/"); |
127 | folders->append(inb); | 122 | folders->append(inb); |
128 | } | 123 | } |
129 | return folders; | 124 | return folders; |
130 | } | 125 | } |
131 | 126 | ||
132 | void MBOXwrapper::deleteMail(const RecMail&mail) | 127 | void MBOXwrapper::deleteMail(const RecMail&mail) |
133 | { | 128 | { |
134 | mailstorage*storage = mailstorage_new(NULL); | 129 | mailstorage*storage = mailstorage_new(NULL); |
135 | QString p = MBOXPath+"/"; | 130 | QString p = MBOXPath+"/"; |
136 | p+=mail.getMbox(); | 131 | p+=mail.getMbox(); |
137 | mailmessage * msg; | 132 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
138 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | ||
139 | mailfolder*folder; | 133 | mailfolder*folder; |
140 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 134 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
141 | r = mailfolder_connect(folder); | 135 | r = mailfolder_connect(folder); |
142 | if (r != MAIL_NO_ERROR) { | 136 | if (r != MAIL_NO_ERROR) { |
143 | qDebug("Error initializing mbox"); | 137 | qDebug("Error initializing mbox"); |
144 | mailfolder_free(folder); | 138 | mailfolder_free(folder); |
145 | mailstorage_free(storage); | 139 | mailstorage_free(storage); |
146 | return; | 140 | return; |
147 | } | 141 | } |
148 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); | 142 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); |
149 | if (r != MAIL_NO_ERROR) { | 143 | if (r != MAIL_NO_ERROR) { |
150 | qDebug("error deleting mail"); | 144 | qDebug("error deleting mail"); |
151 | } | 145 | } |
152 | mailfolder_free(folder); | 146 | mailfolder_free(folder); |
@@ -158,27 +152,27 @@ void MBOXwrapper::answeredMail(const RecMail&) | |||
158 | } | 152 | } |
159 | 153 | ||
160 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | 154 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) |
161 | { | 155 | { |
162 | RecBody body; | 156 | RecBody body; |
163 | mailstorage*storage = mailstorage_new(NULL); | 157 | mailstorage*storage = mailstorage_new(NULL); |
164 | QString p = MBOXPath+"/"; | 158 | QString p = MBOXPath+"/"; |
165 | p+=mail.getMbox(); | 159 | p+=mail.getMbox(); |
166 | mailmessage * msg; | 160 | mailmessage * msg; |
167 | char*data=0; | 161 | char*data=0; |
168 | size_t size; | 162 | size_t size; |
169 | 163 | ||
170 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | 164 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
171 | mailfolder*folder; | 165 | mailfolder*folder; |
172 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 166 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
173 | r = mailfolder_connect(folder); | 167 | r = mailfolder_connect(folder); |
174 | if (r != MAIL_NO_ERROR) { | 168 | if (r != MAIL_NO_ERROR) { |
175 | qDebug("Error initializing mbox"); | 169 | qDebug("Error initializing mbox"); |
176 | mailfolder_free(folder); | 170 | mailfolder_free(folder); |
177 | mailstorage_free(storage); | 171 | mailstorage_free(storage); |
178 | return body; | 172 | return body; |
179 | } | 173 | } |
180 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 174 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
181 | if (r != MAIL_NO_ERROR) { | 175 | if (r != MAIL_NO_ERROR) { |
182 | qDebug("Error fetching mail %i",mail.getNumber()); | 176 | qDebug("Error fetching mail %i",mail.getNumber()); |
183 | mailfolder_free(folder); | 177 | mailfolder_free(folder); |
184 | mailstorage_free(storage); | 178 | mailstorage_free(storage); |
@@ -196,98 +190,178 @@ RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | |||
196 | mailmessage_fetch_result_free(msg,data); | 190 | mailmessage_fetch_result_free(msg,data); |
197 | mailfolder_free(folder); | 191 | mailfolder_free(folder); |
198 | mailstorage_free(storage); | 192 | mailstorage_free(storage); |
199 | 193 | ||
200 | return body; | 194 | return body; |
201 | } | 195 | } |
202 | 196 | ||
203 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 197 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
204 | { | 198 | { |
205 | qDebug("MBOX %i von %i",current,maximum); | 199 | qDebug("MBOX %i von %i",current,maximum); |
206 | } | 200 | } |
207 | 201 | ||
208 | void MBOXwrapper::createFolder(const QString&) | 202 | int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) |
209 | { | 203 | { |
204 | QString p = MBOXPath+"/"; | ||
205 | p+=folder; | ||
206 | QFileInfo fi(p); | ||
207 | if (fi.exists()) { | ||
208 | Global::statusMessage(tr("Mailbox exists.")); | ||
209 | return 0; | ||
210 | } | ||
211 | mailmbox_folder*f = 0; | ||
212 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | ||
213 | Global::statusMessage(tr("Error init folder")); | ||
214 | return 0; | ||
215 | } | ||
216 | if (f) mailmbox_done(f); | ||
217 | return 1; | ||
210 | } | 218 | } |
211 | 219 | ||
212 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 220 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
213 | { | 221 | { |
214 | QString p = MBOXPath+"/"; | 222 | QString p = MBOXPath+"/"; |
215 | p+=folder; | 223 | p+=folder; |
216 | mailmbox_folder*f = 0; | 224 | mailmbox_folder*f = 0; |
217 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 225 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
218 | if (r != MAIL_NO_ERROR) { | 226 | if (r != MAIL_NO_ERROR) { |
219 | qDebug("Error init folder"); | 227 | Global::statusMessage(tr("Error init folder")); |
220 | return; | 228 | return; |
221 | } | 229 | } |
222 | r = mailmbox_append_message(f,msg,length); | 230 | r = mailmbox_append_message(f,msg,length); |
223 | if (r != MAIL_NO_ERROR) { | 231 | if (r != MAIL_NO_ERROR) { |
224 | qDebug("Error writing message folder"); | 232 | Global::statusMessage(tr("Error writing to message folder")); |
225 | } | 233 | } |
226 | mailmbox_done(f); | 234 | mailmbox_done(f); |
227 | } | 235 | } |
228 | 236 | ||
229 | void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | 237 | void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) |
230 | { | 238 | { |
231 | RecBody body; | 239 | RecBody body; |
232 | mailstorage*storage = mailstorage_new(NULL); | 240 | mailstorage*storage = mailstorage_new(NULL); |
233 | QString p = MBOXPath+"/"; | 241 | QString p = MBOXPath+"/"; |
234 | p+=mail.getMbox(); | 242 | p+=mail.getMbox(); |
235 | mailmessage * msg; | 243 | mailmessage * msg; |
236 | char*data=0; | 244 | char*data=0; |
237 | size_t size; | 245 | size_t size; |
238 | 246 | ||
239 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | 247 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
240 | mailfolder*folder; | 248 | mailfolder*folder; |
241 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 249 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
242 | r = mailfolder_connect(folder); | 250 | r = mailfolder_connect(folder); |
243 | if (r != MAIL_NO_ERROR) { | 251 | if (r != MAIL_NO_ERROR) { |
244 | qDebug("Error initializing mbox"); | 252 | Global::statusMessage(tr("Error initializing mbox")); |
245 | mailfolder_free(folder); | 253 | mailfolder_free(folder); |
246 | mailstorage_free(storage); | 254 | mailstorage_free(storage); |
247 | return; | 255 | return; |
248 | } | 256 | } |
249 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 257 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
250 | if (r != MAIL_NO_ERROR) { | 258 | if (r != MAIL_NO_ERROR) { |
251 | qDebug("Error fetching mail %i",mail.getNumber()); | 259 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
252 | mailfolder_free(folder); | 260 | mailfolder_free(folder); |
253 | mailstorage_free(storage); | 261 | mailstorage_free(storage); |
254 | return; | 262 | return; |
255 | } | 263 | } |
256 | r = mailmessage_fetch(msg,&data,&size); | 264 | r = mailmessage_fetch(msg,&data,&size); |
257 | if (r != MAIL_NO_ERROR) { | 265 | if (r != MAIL_NO_ERROR) { |
258 | qDebug("Error fetching mail %i",mail.getNumber()); | 266 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
259 | mailfolder_free(folder); | 267 | mailfolder_free(folder); |
260 | mailstorage_free(storage); | 268 | mailstorage_free(storage); |
261 | mailmessage_free(msg); | 269 | mailmessage_free(msg); |
262 | return; | 270 | return; |
263 | } | 271 | } |
264 | *target = data; | 272 | *target = data; |
265 | *length = size; | 273 | *length = size; |
266 | mailfolder_free(folder); | 274 | mailfolder_free(folder); |
267 | mailstorage_free(storage); | 275 | mailstorage_free(storage); |
268 | mailmessage_free(msg); | 276 | mailmessage_free(msg); |
269 | } | 277 | } |
270 | 278 | ||
271 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 279 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
272 | { | 280 | { |
273 | QString p = MBOXPath+"/"; | 281 | QString p = MBOXPath+"/"; |
274 | p+=mailbox; | 282 | p+=mailbox; |
275 | mailmbox_folder*f = 0; | 283 | mailmbox_folder*f = 0; |
276 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 284 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
277 | if (r != MAIL_NO_ERROR) { | 285 | if (r != MAIL_NO_ERROR) { |
278 | qDebug("Error init folder"); | 286 | qDebug("Error init folder"); |
279 | return; | 287 | return; |
280 | } | 288 | } |
289 | deleteMails(f,target); | ||
290 | mailmbox_done(f); | ||
291 | } | ||
292 | |||
293 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | ||
294 | { | ||
295 | if (!f) return; | ||
296 | int r; | ||
281 | for (unsigned int i=0; i < target.count();++i) { | 297 | for (unsigned int i=0; i < target.count();++i) { |
282 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); | 298 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); |
283 | if (r!=MAILMBOX_NO_ERROR) { | 299 | if (r!=MAILMBOX_NO_ERROR) { |
284 | qDebug("error delete mail"); | 300 | qDebug("error delete mail"); |
285 | } | 301 | } |
286 | } | 302 | } |
287 | r = mailmbox_expunge(f); | 303 | r = mailmbox_expunge(f); |
288 | if (r != MAILMBOX_NO_ERROR) { | 304 | if (r != MAILMBOX_NO_ERROR) { |
289 | qDebug("error expunge mailbox"); | 305 | qDebug("error expunge mailbox"); |
290 | } | 306 | } |
291 | mailmbox_done(f); | 307 | } |
308 | |||
309 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) | ||
310 | { | ||
311 | if (!tfolder) return 0; | ||
312 | QString p = MBOXPath+tfolder->getDisplayName(); | ||
313 | int res = 1; | ||
314 | |||
315 | mailfolder*folder = 0; | ||
316 | mailmessage_list*l=0; | ||
317 | mailstorage*storage = mailstorage_new(NULL); | ||
318 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | ||
319 | if (r != MAIL_NO_ERROR) { | ||
320 | Global::statusMessage(tr("Error initializing mbox")); | ||
321 | res = 0; | ||
322 | } | ||
323 | if (res) { | ||
324 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | ||
325 | r = mailfolder_connect(folder); | ||
326 | if (r != MAIL_NO_ERROR) { | ||
327 | Global::statusMessage(tr("Error initializing mbox")); | ||
328 | res = 0; | ||
329 | } | ||
330 | } | ||
331 | if (res) { | ||
332 | r = mailsession_get_messages_list(folder->fld_session,&l); | ||
333 | if (r != MAIL_NO_ERROR) { | ||
334 | qDebug("Error message list"); | ||
335 | res=0; | ||
336 | } | ||
337 | } | ||
338 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | ||
339 | r = mailsession_remove_message(folder->fld_session,i+1); | ||
340 | if (r != MAIL_NO_ERROR) { | ||
341 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | ||
342 | res = 0; | ||
343 | break; | ||
344 | } | ||
345 | } | ||
346 | if (l) mailmessage_list_free(l); | ||
347 | if (folder) mailfolder_free(folder); | ||
348 | if (storage) mailstorage_free(storage); | ||
349 | return res; | ||
350 | } | ||
351 | |||
352 | int MBOXwrapper::deleteMbox(const Folder*tfolder) | ||
353 | { | ||
354 | if (!tfolder) return 0; | ||
355 | QString p = MBOXPath+tfolder->getDisplayName(); | ||
356 | QFile fi(p); | ||
357 | if (!fi.exists()) { | ||
358 | Global::statusMessage(tr("Mailbox doesn't exist.")); | ||
359 | return 0; | ||
360 | } | ||
361 | if (!fi.remove()) { | ||
362 | Global::statusMessage(tr("Error deleting Mailbox.")); | ||
363 | return 0; | ||
364 | } | ||
365 | return 1; | ||
292 | } | 366 | } |
293 | 367 | ||
diff --git a/noncore/net/mail/mboxwrapper.h b/noncore/net/mail/mboxwrapper.h index f64ad52..226a544 100644 --- a/noncore/net/mail/mboxwrapper.h +++ b/noncore/net/mail/mboxwrapper.h | |||
@@ -1,35 +1,41 @@ | |||
1 | #ifndef __MBOX_WRAPPER_H | 1 | #ifndef __MBOX_WRAPPER_H |
2 | #define __MBOX_WRAPPER_H | 2 | #define __MBOX_WRAPPER_H |
3 | 3 | ||
4 | #include "genericwrapper.h" | 4 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | struct mailmbox_folder; | ||
9 | 10 | ||
10 | class MBOXwrapper : public Genericwrapper | 11 | class MBOXwrapper : public Genericwrapper |
11 | { | 12 | { |
12 | Q_OBJECT | 13 | Q_OBJECT |
13 | public: | 14 | public: |
14 | MBOXwrapper(const QString & dir); | 15 | MBOXwrapper(const QString & dir); |
15 | virtual ~MBOXwrapper(); | 16 | virtual ~MBOXwrapper(); |
16 | 17 | ||
17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 18 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
18 | virtual QList<Folder>* listFolders(); | 19 | virtual QList<Folder>* listFolders(); |
19 | 20 | ||
20 | virtual void deleteMail(const RecMail&mail); | 21 | virtual void deleteMail(const RecMail&mail); |
21 | virtual void answeredMail(const RecMail&mail); | 22 | virtual void answeredMail(const RecMail&mail); |
22 | virtual void createFolder(const QString&aFolder); | 23 | |
24 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | ||
25 | virtual int deleteMbox(const Folder*); | ||
26 | |||
23 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 27 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
24 | 28 | ||
25 | virtual RecBody fetchBody( const RecMail &mail ); | 29 | virtual RecBody fetchBody( const RecMail &mail ); |
26 | static void mbox_progress( size_t current, size_t maximum ); | 30 | static void mbox_progress( size_t current, size_t maximum ); |
27 | 31 | ||
28 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); | 32 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); |
29 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); | 33 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); |
34 | virtual int deleteAllMail(const Folder*); | ||
30 | 35 | ||
31 | protected: | 36 | protected: |
37 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | ||
32 | QString MBOXPath; | 38 | QString MBOXPath; |
33 | }; | 39 | }; |
34 | 40 | ||
35 | #endif | 41 | #endif |
diff --git a/noncore/net/mail/newmaildir.cpp b/noncore/net/mail/newmaildir.cpp index 3fc66f4..ab0d4e3 100644 --- a/noncore/net/mail/newmaildir.cpp +++ b/noncore/net/mail/newmaildir.cpp | |||
@@ -1,21 +1,25 @@ | |||
1 | #include "newmaildir.h" | 1 | #include "newmaildir.h" |
2 | #include <qdialog.h> | 2 | #include <qdialog.h> |
3 | #include <qvariant.h> | 3 | #include <qvariant.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qcheckbox.h> | 5 | #include <qcheckbox.h> |
6 | 6 | ||
7 | Newmdirdlg::Newmdirdlg( QWidget* parent, const char* name) | 7 | Newmdirdlg::Newmdirdlg( QWidget* parent, const char* name,bool no_sub) |
8 | : Newmdirdlgui(parent,name,true),ndir(""),possible_subs(false) | 8 | : Newmdirdlgui(parent,name,true),ndir(""),possible_subs(false) |
9 | { | 9 | { |
10 | if (no_sub) { | ||
11 | subdirsPossibleBox->setChecked(false); | ||
12 | subdirsPossibleBox->hide(); | ||
13 | } | ||
10 | } | 14 | } |
11 | 15 | ||
12 | Newmdirdlg::~Newmdirdlg() | 16 | Newmdirdlg::~Newmdirdlg() |
13 | { | 17 | { |
14 | } | 18 | } |
15 | 19 | ||
16 | void Newmdirdlg::accept() | 20 | void Newmdirdlg::accept() |
17 | { | 21 | { |
18 | ndir = dirnameEdit->text(); | 22 | ndir = dirnameEdit->text(); |
19 | possible_subs = subdirsPossibleBox->isChecked(); | 23 | possible_subs = subdirsPossibleBox->isChecked(); |
20 | if (ndir.isEmpty()) { | 24 | if (ndir.isEmpty()) { |
21 | return; | 25 | return; |
diff --git a/noncore/net/mail/newmaildir.h b/noncore/net/mail/newmaildir.h index 1eb904e..496eaf4 100644 --- a/noncore/net/mail/newmaildir.h +++ b/noncore/net/mail/newmaildir.h | |||
@@ -1,20 +1,20 @@ | |||
1 | #include "newmaildirui.h" | 1 | #include "newmaildirui.h" |
2 | #include <qvariant.h> | 2 | #include <qvariant.h> |
3 | 3 | ||
4 | class Newmdirdlg : public Newmdirdlgui | 4 | class Newmdirdlg : public Newmdirdlgui |
5 | { | 5 | { |
6 | Q_OBJECT | 6 | Q_OBJECT |
7 | public: | 7 | public: |
8 | Newmdirdlg( QWidget* parent = 0, const char* name = 0); | 8 | Newmdirdlg( QWidget* parent = 0, const char* name = 0,bool no_sub=false); |
9 | ~Newmdirdlg(); | 9 | ~Newmdirdlg(); |
10 | 10 | ||
11 | const QString&Newdir()const; | 11 | const QString&Newdir()const; |
12 | const bool subpossible()const; | 12 | const bool subpossible()const; |
13 | 13 | ||
14 | protected slots: | 14 | protected slots: |
15 | virtual void accept(); | 15 | virtual void accept(); |
16 | 16 | ||
17 | protected: | 17 | protected: |
18 | QString ndir; | 18 | QString ndir; |
19 | bool possible_subs; | 19 | bool possible_subs; |
20 | }; | 20 | }; |
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp index efd83ba..b85fbf6 100644 --- a/noncore/net/mail/pop3wrapper.cpp +++ b/noncore/net/mail/pop3wrapper.cpp | |||
@@ -1,19 +1,18 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include <libetpan/mailpop3.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <libetpan/mailmime.h> | 6 | #include <qpe/global.h> |
7 | #include <libetpan/data_message_driver.h> | ||
8 | #include <qfile.h> | 7 | #include <qfile.h> |
9 | 8 | ||
10 | /* we don't fetch messages larger than 5 MB */ | 9 | /* we don't fetch messages larger than 5 MB */ |
11 | #define HARD_MSG_SIZE_LIMIT 5242880 | 10 | #define HARD_MSG_SIZE_LIMIT 5242880 |
12 | 11 | ||
13 | POP3wrapper::POP3wrapper( POP3account *a ) | 12 | POP3wrapper::POP3wrapper( POP3account *a ) |
14 | : Genericwrapper() | 13 | : Genericwrapper() |
15 | { | 14 | { |
16 | account = a; | 15 | account = a; |
17 | m_pop3 = NULL; | 16 | m_pop3 = NULL; |
18 | msgTempName = a->getFileName()+"_msg_cache"; | 17 | msgTempName = a->getFileName()+"_msg_cache"; |
19 | last_msg_id = 0; | 18 | last_msg_id = 0; |
@@ -103,44 +102,46 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) | |||
103 | } | 102 | } |
104 | 103 | ||
105 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | 104 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) |
106 | { | 105 | { |
107 | int err = MAILPOP3_NO_ERROR; | 106 | int err = MAILPOP3_NO_ERROR; |
108 | char * header = 0; | 107 | char * header = 0; |
109 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ | 108 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ |
110 | size_t length = 0; | 109 | size_t length = 0; |
111 | carray * messages = 0; | 110 | carray * messages = 0; |
112 | 111 | ||
113 | login(); | 112 | login(); |
114 | if (!m_pop3) return; | 113 | if (!m_pop3) return; |
114 | |||
115 | mailpop3_list( m_pop3, &messages ); | 115 | mailpop3_list( m_pop3, &messages ); |
116 | 116 | ||
117 | for (unsigned int i = 0; i < carray_count(messages);++i) { | 117 | for (unsigned int i = 0; i < carray_count(messages);++i) { |
118 | mailpop3_msg_info *info; | 118 | mailpop3_msg_info *info; |
119 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); | 119 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); |
120 | if (info->msg_deleted) | 120 | if (info->msg_deleted) |
121 | continue; | 121 | continue; |
122 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); | 122 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); |
123 | if ( err != MAILPOP3_NO_ERROR ) { | 123 | if ( err != MAILPOP3_NO_ERROR ) { |
124 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); | 124 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); |
125 | free(header); | 125 | free(header); |
126 | return; | 126 | return; |
127 | } | 127 | } |
128 | RecMail *mail = parseHeader( header ); | 128 | RecMail *mail = parseHeader( header ); |
129 | mail->setNumber( info->msg_index ); | 129 | mail->setNumber( info->msg_index ); |
130 | mail->setWrapper(this); | 130 | mail->setWrapper(this); |
131 | mail->setMsgsize(info->msg_size); | 131 | mail->setMsgsize(info->msg_size); |
132 | target.append( mail ); | 132 | target.append( mail ); |
133 | free(header); | 133 | free(header); |
134 | } | 134 | } |
135 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(carray_count(messages)-m_pop3->pop3_deleted_count)); | ||
135 | } | 136 | } |
136 | 137 | ||
137 | void POP3wrapper::login() | 138 | void POP3wrapper::login() |
138 | { | 139 | { |
139 | /* we'll hold the line */ | 140 | /* we'll hold the line */ |
140 | if ( m_pop3 != NULL ) return; | 141 | if ( m_pop3 != NULL ) return; |
141 | 142 | ||
142 | const char *server, *user, *pass; | 143 | const char *server, *user, *pass; |
143 | uint16_t port; | 144 | uint16_t port; |
144 | int err = MAILPOP3_NO_ERROR; | 145 | int err = MAILPOP3_NO_ERROR; |
145 | 146 | ||
146 | server = account->getServer().latin1(); | 147 | server = account->getServer().latin1(); |
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h index b738cca..7502720 100644 --- a/noncore/net/mail/pop3wrapper.h +++ b/noncore/net/mail/pop3wrapper.h | |||
@@ -17,16 +17,17 @@ public: | |||
17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
18 | virtual QList<Folder>* listFolders(); | 18 | virtual QList<Folder>* listFolders(); |
19 | 19 | ||
20 | virtual void deleteMail(const RecMail&mail); | 20 | virtual void deleteMail(const RecMail&mail); |
21 | virtual void answeredMail(const RecMail&mail); | 21 | virtual void answeredMail(const RecMail&mail); |
22 | 22 | ||
23 | virtual RecBody fetchBody( const RecMail &mail ); | 23 | virtual RecBody fetchBody( const RecMail &mail ); |
24 | static void pop3_progress( size_t current, size_t maximum ); | 24 | static void pop3_progress( size_t current, size_t maximum ); |
25 | 25 | ||
26 | protected: | 26 | protected: |
27 | void login(); | 27 | void login(); |
28 | void logout(); | 28 | void logout(); |
29 | 29 | POP3account *account; | |
30 | mailpop3 *m_pop3; | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | #endif | 33 | #endif |