author | zautrix <zautrix> | 2004-09-11 15:41:30 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-11 15:41:30 (UTC) |
commit | 32f9963a39236d08718a36d5adad2a0c5c4e2602 (patch) (unidiff) | |
tree | 8856a90d505df8dc3afa0d72541f27cb68913a0d /kmicromail | |
parent | d7a273f40838f56205c1377ed0bcc5457bd46ea3 (diff) | |
download | kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.zip kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.gz kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.bz2 |
Mail enhancements
-rw-r--r-- | kmicromail/accountitem.cpp | 22 | ||||
-rw-r--r-- | kmicromail/accountview.cpp | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 67 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.h | 7 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 64 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.h | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 18 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.cpp | 23 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.h | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mboxwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/nntpwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.h | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/smtpwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/mailistviewitem.cpp | 9 |
17 files changed, 208 insertions, 22 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index 1698b40..7b9b881 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp | |||
@@ -47,141 +47,144 @@ POP3viewItem::~POP3viewItem() | |||
47 | } | 47 | } |
48 | 48 | ||
49 | AbstractMail *POP3viewItem::getWrapper() | 49 | AbstractMail *POP3viewItem::getWrapper() |
50 | { | 50 | { |
51 | return wrapper; | 51 | return wrapper; |
52 | } | 52 | } |
53 | 53 | ||
54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
55 | { | 55 | { |
56 | refresh(); | 56 | refresh(); |
57 | } | 57 | } |
58 | 58 | ||
59 | void POP3viewItem::refresh() | 59 | void POP3viewItem::refresh() |
60 | { | 60 | { |
61 | if (account->getOffline()) return; | 61 | if (account->getOffline()) return; |
62 | QValueList<FolderP> *folders = wrapper->listFolders(); | 62 | QValueList<FolderP> *folders = wrapper->listFolders(); |
63 | QListViewItem *child = firstChild(); | 63 | QListViewItem *child = firstChild(); |
64 | while ( child ) | 64 | while ( child ) |
65 | { | 65 | { |
66 | QListViewItem *tmp = child; | 66 | QListViewItem *tmp = child; |
67 | child = child->nextSibling(); | 67 | child = child->nextSibling(); |
68 | delete tmp; | 68 | delete tmp; |
69 | } | 69 | } |
70 | QValueList<FolderP>::ConstIterator it; | 70 | QValueList<FolderP>::ConstIterator it; |
71 | QListViewItem*item = 0; | 71 | QListViewItem*item = 0; |
72 | for ( it = folders->begin(); it!=folders->end(); ++it) | 72 | for ( it = folders->begin(); it!=folders->end(); ++it) |
73 | { | 73 | { |
74 | item = new POP3folderItem( (*it), this , item ); | 74 | item = new POP3folderItem( (*it), this , item ); |
75 | item->setSelectable( (*it)->may_select()); | 75 | item->setSelectable( (*it)->may_select()); |
76 | } | 76 | } |
77 | delete folders; | 77 | delete folders; |
78 | } | 78 | } |
79 | 79 | ||
80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | 80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
81 | { | 81 | { |
82 | 82 | ||
83 | return wrapper->fetchBody( mail ); | 83 | return wrapper->fetchBody( mail ); |
84 | } | 84 | } |
85 | 85 | ||
86 | QPopupMenu * POP3viewItem::getContextMenu() | 86 | QPopupMenu * POP3viewItem::getContextMenu() |
87 | { | 87 | { |
88 | QPopupMenu *m = new QPopupMenu(0); | 88 | QPopupMenu *m = new QPopupMenu(0); |
89 | if (m) | 89 | if (m) |
90 | { | 90 | { |
91 | if (!account->getOffline()) | 91 | if (!account->getOffline()) |
92 | { | 92 | { |
93 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 93 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
94 | m->insertItem(QObject::tr("Set offline",contextName),1); | 94 | m->insertItem(QObject::tr("Set offline",contextName),1); |
95 | m->insertItem(QObject::tr("Download messages",contextName),2); | 95 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); |
96 | } | 96 | } |
97 | else | 97 | else |
98 | { | 98 | { |
99 | m->insertItem(QObject::tr("Set online",contextName),1); | 99 | m->insertItem(QObject::tr("Set online",contextName),1); |
100 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); | ||
100 | } | 101 | } |
101 | } | 102 | } |
102 | return m; | 103 | return m; |
103 | } | 104 | } |
104 | 105 | ||
105 | void POP3viewItem::disconnect() | 106 | void POP3viewItem::disconnect() |
106 | { | 107 | { |
107 | QListViewItem *child = firstChild(); | 108 | QListViewItem *child = firstChild(); |
108 | while ( child ) | 109 | while ( child ) |
109 | { | 110 | { |
110 | QListViewItem *tmp = child; | 111 | QListViewItem *tmp = child; |
111 | child = child->nextSibling(); | 112 | child = child->nextSibling(); |
112 | delete tmp; | 113 | delete tmp; |
113 | } | 114 | } |
114 | wrapper->logout(); | 115 | wrapper->logout(); |
115 | } | 116 | } |
116 | 117 | ||
117 | void POP3viewItem::setOnOffline() | 118 | void POP3viewItem::setOnOffline() |
118 | { | 119 | { |
119 | if (!account->getOffline()) | 120 | if (!account->getOffline()) |
120 | { | 121 | { |
121 | disconnect(); | 122 | disconnect(); |
122 | } | 123 | } |
123 | account->setOffline(!account->getOffline()); | 124 | account->setOffline(!account->getOffline()); |
124 | account->save(); | 125 | account->save(); |
125 | SETPIX(PIXMAP_POP3FOLDER); | 126 | SETPIX(PIXMAP_POP3FOLDER); |
126 | refresh(); | 127 | refresh(); |
127 | } | 128 | } |
128 | 129 | ||
129 | void POP3viewItem::contextMenuSelected(int which) | 130 | void POP3viewItem::contextMenuSelected(int which) |
130 | { | 131 | { |
131 | switch (which) | 132 | switch (which) |
132 | { | 133 | { |
133 | case 0: | 134 | case 0: |
134 | disconnect(); | 135 | disconnect(); |
135 | break; | 136 | break; |
136 | case 1: | 137 | case 1: |
137 | setOnOffline(); | 138 | setOnOffline(); |
138 | break; | 139 | break; |
139 | case 2: // daunlood | 140 | case 2: // daunlood |
141 | if (account->getOffline()) | ||
142 | setOnOffline(); | ||
140 | AccountView*bl = accountView(); | 143 | AccountView*bl = accountView(); |
141 | if (!bl) return; | 144 | if (!bl) return; |
142 | AccountViewItem* in = findSubItem( "inbox" , 0); | 145 | AccountViewItem* in = findSubItem( "inbox" , 0); |
143 | if ( ! in ) | 146 | if ( ! in ) |
144 | return; | 147 | return; |
145 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); | 148 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); |
146 | setOnOffline(); | 149 | setOnOffline(); |
147 | break; | 150 | break; |
148 | } | 151 | } |
149 | } | 152 | } |
150 | 153 | ||
151 | POP3folderItem::~POP3folderItem() | 154 | POP3folderItem::~POP3folderItem() |
152 | {} | 155 | {} |
153 | 156 | ||
154 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 157 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
155 | : AccountViewItem(folderInit,parent,after ) | 158 | : AccountViewItem(folderInit,parent,after ) |
156 | { | 159 | { |
157 | pop3 = parent; | 160 | pop3 = parent; |
158 | if (folder->getDisplayName().lower()!="inbox") | 161 | if (folder->getDisplayName().lower()!="inbox") |
159 | { | 162 | { |
160 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 163 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
161 | } | 164 | } |
162 | else | 165 | else |
163 | { | 166 | { |
164 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 167 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
165 | } | 168 | } |
166 | setText( 0, folder->getDisplayName() ); | 169 | setText( 0, folder->getDisplayName() ); |
167 | } | 170 | } |
168 | 171 | ||
169 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 172 | void POP3folderItem::refresh(QValueList<RecMailP>&target) |
170 | { | 173 | { |
171 | if (folder->may_select()) | 174 | if (folder->may_select()) |
172 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 175 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
173 | } | 176 | } |
174 | 177 | ||
175 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 178 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
176 | { | 179 | { |
177 | return pop3->getWrapper()->fetchBody(aMail); | 180 | return pop3->getWrapper()->fetchBody(aMail); |
178 | } | 181 | } |
179 | 182 | ||
180 | QPopupMenu * POP3folderItem::getContextMenu() | 183 | QPopupMenu * POP3folderItem::getContextMenu() |
181 | { | 184 | { |
182 | QPopupMenu *m = new QPopupMenu(0); | 185 | QPopupMenu *m = new QPopupMenu(0); |
183 | if (m) | 186 | if (m) |
184 | { | 187 | { |
185 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 188 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
186 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 189 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
187 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 190 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
@@ -468,153 +471,170 @@ void IMAPviewItem::refreshFolders(bool force) | |||
468 | 471 | ||
469 | for ( it = folders->begin(); it!=folders->end(); ++it) | 472 | for ( it = folders->begin(); it!=folders->end(); ++it) |
470 | { | 473 | { |
471 | if ((*it)->getDisplayName().lower()=="inbox") | 474 | if ((*it)->getDisplayName().lower()=="inbox") |
472 | { | 475 | { |
473 | item = new IMAPfolderItem( (*it), this , item ); | 476 | item = new IMAPfolderItem( (*it), this , item ); |
474 | folders->remove(it); | 477 | folders->remove(it); |
475 | break; | 478 | break; |
476 | } | 479 | } |
477 | } | 480 | } |
478 | for ( it = folders->begin(); it!=folders->end(); ++it) | 481 | for ( it = folders->begin(); it!=folders->end(); ++it) |
479 | { | 482 | { |
480 | fname = (*it)->getDisplayName(); | 483 | fname = (*it)->getDisplayName(); |
481 | currentFolders.append((*it)->getName()); | 484 | currentFolders.append((*it)->getName()); |
482 | pos = fname.findRev((*it)->Separator()); | 485 | pos = fname.findRev((*it)->Separator()); |
483 | if (pos != -1) | 486 | if (pos != -1) |
484 | { | 487 | { |
485 | fname = fname.left(pos); | 488 | fname = fname.left(pos); |
486 | } | 489 | } |
487 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 490 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
488 | if (pitem) | 491 | if (pitem) |
489 | { | 492 | { |
490 | titem = item; | 493 | titem = item; |
491 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 494 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
492 | /* setup the short name */ | 495 | /* setup the short name */ |
493 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); | 496 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); |
494 | item = titem; | 497 | item = titem; |
495 | } | 498 | } |
496 | else | 499 | else |
497 | { | 500 | { |
498 | item = new IMAPfolderItem( (*it), this , item ); | 501 | item = new IMAPfolderItem( (*it), this , item ); |
499 | } | 502 | } |
500 | } | 503 | } |
501 | delete folders; | 504 | delete folders; |
502 | } | 505 | } |
503 | 506 | ||
504 | QPopupMenu * IMAPviewItem::getContextMenu() | 507 | QPopupMenu * IMAPviewItem::getContextMenu() |
505 | { | 508 | { |
506 | QPopupMenu *m = new QPopupMenu(0); | 509 | QPopupMenu *m = new QPopupMenu(0); |
507 | if (m) | 510 | if (m) |
508 | { | 511 | { |
509 | if (!account->getOffline()) | 512 | if (!account->getOffline()) |
510 | { | 513 | { |
511 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 514 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
512 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 515 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
513 | m->insertSeparator(); | 516 | m->insertSeparator(); |
514 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 517 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
515 | m->insertItem(QObject::tr("Set offline",contextName),3); | 518 | m->insertItem(QObject::tr("Set offline",contextName),3); |
519 | m->insertSeparator(); | ||
520 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); | ||
516 | } | 521 | } |
517 | else | 522 | else |
518 | { | 523 | { |
519 | m->insertItem(QObject::tr("Set online",contextName),3); | 524 | m->insertItem(QObject::tr("Set online",contextName),3); |
525 | m->insertSeparator(); | ||
526 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); | ||
520 | } | 527 | } |
521 | } | 528 | } |
522 | return m; | 529 | return m; |
523 | } | 530 | } |
524 | 531 | ||
525 | void IMAPviewItem::createNewFolder() | 532 | void IMAPviewItem::createNewFolder() |
526 | { | 533 | { |
527 | Newmdirdlg ndirdlg; | 534 | Newmdirdlg ndirdlg; |
528 | 535 | ||
529 | ndirdlg.showMaximized(); | 536 | ndirdlg.showMaximized(); |
530 | if ( ndirdlg.exec() ) | 537 | if ( ndirdlg.exec() ) |
531 | { | 538 | { |
532 | QString ndir = ndirdlg.Newdir(); | 539 | QString ndir = ndirdlg.Newdir(); |
533 | bool makesubs = ndirdlg.subpossible(); | 540 | bool makesubs = ndirdlg.subpossible(); |
534 | QString delemiter = "/"; | 541 | QString delemiter = "/"; |
535 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 542 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
536 | if (item) | 543 | if (item) |
537 | { | 544 | { |
538 | delemiter = item->Delemiter(); | 545 | delemiter = item->Delemiter(); |
539 | } | 546 | } |
540 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 547 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
541 | { | 548 | { |
542 | refreshFolders(true); | 549 | refreshFolders(true); |
543 | } | 550 | } |
544 | } | 551 | } |
545 | } | 552 | } |
546 | 553 | ||
547 | void IMAPviewItem::contextMenuSelected(int id) | 554 | void IMAPviewItem::contextMenuSelected(int id) |
548 | { | 555 | { |
549 | 556 | ||
550 | switch (id) | 557 | switch (id) |
551 | { | 558 | { |
552 | case 0: | 559 | case 0: |
553 | refreshFolders(true); | 560 | refreshFolders(true); |
554 | break; | 561 | break; |
555 | case 1: | 562 | case 1: |
556 | createNewFolder(); | 563 | createNewFolder(); |
557 | break; | 564 | break; |
558 | case 2: | 565 | case 2: |
559 | removeChilds(); | 566 | removeChilds(); |
560 | wrapper->logout(); | 567 | wrapper->logout(); |
561 | break; | 568 | break; |
562 | case 3: | 569 | case 3: |
563 | if (account->getOffline()==false) | 570 | if (account->getOffline()==false) |
564 | { | 571 | { |
565 | removeChilds(); | 572 | removeChilds(); |
566 | wrapper->logout(); | 573 | wrapper->logout(); |
567 | } | 574 | } |
568 | account->setOffline(!account->getOffline()); | 575 | account->setOffline(!account->getOffline()); |
569 | account->save(); | 576 | account->save(); |
570 | SETPIX(PIXMAP_IMAPFOLDER); | 577 | SETPIX(PIXMAP_IMAPFOLDER); |
571 | refreshFolders(false); | 578 | refreshFolders(false); |
572 | break; | 579 | break; |
580 | case 4: // daunlood | ||
581 | { | ||
582 | if (account->getOffline()) { | ||
583 | contextMenuSelected( 3 ); | ||
584 | } | ||
585 | AccountView*bl = accountView(); | ||
586 | if (!bl) return; | ||
587 | AccountViewItem* in = findSubItem( "inbox" , 0); | ||
588 | if ( ! in ) | ||
589 | return; | ||
590 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); | ||
591 | } | ||
592 | break; | ||
573 | default: | 593 | default: |
574 | break; | 594 | break; |
575 | } | 595 | } |
576 | } | 596 | } |
577 | 597 | ||
578 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) | 598 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
579 | { | 599 | { |
580 | return new RecBody(); | 600 | return new RecBody(); |
581 | } | 601 | } |
582 | 602 | ||
583 | bool IMAPviewItem::offline() | 603 | bool IMAPviewItem::offline() |
584 | { | 604 | { |
585 | return account->getOffline(); | 605 | return account->getOffline(); |
586 | } | 606 | } |
587 | 607 | ||
588 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 608 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
589 | : AccountViewItem( folderInit, parent , after ) | 609 | : AccountViewItem( folderInit, parent , after ) |
590 | { | 610 | { |
591 | imap = parent; | 611 | imap = parent; |
592 | if (folder->getDisplayName().lower()!="inbox") | 612 | if (folder->getDisplayName().lower()!="inbox") |
593 | { | 613 | { |
594 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 614 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
595 | } | 615 | } |
596 | else | 616 | else |
597 | { | 617 | { |
598 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 618 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
599 | } | 619 | } |
600 | setText( 0, folder->getDisplayName() ); | 620 | setText( 0, folder->getDisplayName() ); |
601 | } | 621 | } |
602 | 622 | ||
603 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 623 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
604 | : AccountViewItem(folderInit, parent,after ) | 624 | : AccountViewItem(folderInit, parent,after ) |
605 | { | 625 | { |
606 | imap = master; | 626 | imap = master; |
607 | if (folder->getDisplayName().lower()!="inbox") | 627 | if (folder->getDisplayName().lower()!="inbox") |
608 | { | 628 | { |
609 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 629 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
610 | } | 630 | } |
611 | else | 631 | else |
612 | { | 632 | { |
613 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 633 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
614 | } | 634 | } |
615 | setText( 0, folder->getDisplayName() ); | 635 | setText( 0, folder->getDisplayName() ); |
616 | } | 636 | } |
617 | 637 | ||
618 | IMAPfolderItem::~IMAPfolderItem() | 638 | IMAPfolderItem::~IMAPfolderItem() |
619 | {} | 639 | {} |
620 | 640 | ||
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp index 85523b1..de8c5bb 100644 --- a/kmicromail/accountview.cpp +++ b/kmicromail/accountview.cpp | |||
@@ -96,108 +96,111 @@ void AccountView::refresh(QListViewItem *item) | |||
96 | view->refresh(headerlist); | 96 | view->refresh(headerlist); |
97 | emit refreshMailview(headerlist); | 97 | emit refreshMailview(headerlist); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | void AccountView::refreshCurrent() | 101 | void AccountView::refreshCurrent() |
102 | { | 102 | { |
103 | m_currentItem = currentItem(); | 103 | m_currentItem = currentItem(); |
104 | if ( !m_currentItem ) return; | 104 | if ( !m_currentItem ) return; |
105 | QValueList<RecMailP> headerlist; | 105 | QValueList<RecMailP> headerlist; |
106 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 106 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
107 | view->refresh(headerlist); | 107 | view->refresh(headerlist); |
108 | emit refreshMailview(headerlist); | 108 | emit refreshMailview(headerlist); |
109 | } | 109 | } |
110 | 110 | ||
111 | void AccountView::refreshAll() | 111 | void AccountView::refreshAll() |
112 | { | 112 | { |
113 | } | 113 | } |
114 | 114 | ||
115 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) | 115 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) |
116 | { | 116 | { |
117 | QListViewItem*item = selectedItem (); | 117 | QListViewItem*item = selectedItem (); |
118 | if (!item) return new RecBody(); | 118 | if (!item) return new RecBody(); |
119 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 119 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
120 | return view->fetchBody(aMail); | 120 | return view->fetchBody(aMail); |
121 | } | 121 | } |
122 | 122 | ||
123 | void AccountView::setupFolderselect(Selectstore*sels) | 123 | void AccountView::setupFolderselect(Selectstore*sels) |
124 | { | 124 | { |
125 | sels->showMaximized(); | 125 | sels->showMaximized(); |
126 | QStringList sFolders; | 126 | QStringList sFolders; |
127 | unsigned int i = 0; | 127 | unsigned int i = 0; |
128 | for (i=0; i < mhAccounts.count();++i) | 128 | for (i=0; i < mhAccounts.count();++i) |
129 | { | 129 | { |
130 | mhAccounts[i]->refresh(false); | 130 | mhAccounts[i]->refresh(false); |
131 | sFolders = mhAccounts[i]->subFolders(); | 131 | sFolders = mhAccounts[i]->subFolders(); |
132 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 132 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
133 | } | 133 | } |
134 | for (i=0; i < imapAccounts.count();++i) | 134 | for (i=0; i < imapAccounts.count();++i) |
135 | { | 135 | { |
136 | if (imapAccounts[i]->offline()) | 136 | if (imapAccounts[i]->offline()) |
137 | continue; | 137 | continue; |
138 | imapAccounts[i]->refreshFolders(false); | 138 | imapAccounts[i]->refreshFolders(false); |
139 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 139 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) | 142 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) |
143 | { | 143 | { |
144 | #if 0 | ||
144 | AbstractMail*targetMail = 0; | 145 | AbstractMail*targetMail = 0; |
145 | QString targetFolder = ""; | 146 | QString targetFolder = ""; |
146 | Selectstore sels; | 147 | Selectstore sels; |
147 | setupFolderselect(&sels); | 148 | setupFolderselect(&sels); |
148 | if (!sels.exec()) return; | 149 | if (!sels.exec()) return; |
149 | targetMail = sels.currentMail(); | 150 | targetMail = sels.currentMail(); |
150 | targetFolder = sels.currentFolder(); | 151 | targetFolder = sels.currentFolder(); |
151 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 152 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
152 | targetFolder.isEmpty()) | 153 | targetFolder.isEmpty()) |
153 | { | 154 | { |
154 | return; | 155 | return; |
155 | } | 156 | } |
156 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 157 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
157 | { | 158 | { |
158 | QMessageBox::critical(0,tr("Error creating new Folder"), | 159 | QMessageBox::critical(0,tr("Error creating new Folder"), |
159 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 160 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
160 | return; | 161 | return; |
161 | } | 162 | } |
162 | int maxsize = 0; | 163 | int maxsize = 0; |
163 | if ( sels.useSize->isChecked()) | 164 | if ( sels.useSize->isChecked()) |
164 | maxsize = sels.sizeSpinBox->value(); | 165 | maxsize = sels.sizeSpinBox->value(); |
165 | |||
166 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 166 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
167 | #endif | ||
168 | fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); | ||
167 | refreshCurrent(); | 169 | refreshCurrent(); |
170 | |||
168 | } | 171 | } |
169 | 172 | ||
170 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 173 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
171 | { | 174 | { |
172 | AbstractMail*targetMail = 0; | 175 | AbstractMail*targetMail = 0; |
173 | QString targetFolder = ""; | 176 | QString targetFolder = ""; |
174 | Selectstore sels; | 177 | Selectstore sels; |
175 | setupFolderselect(&sels); | 178 | setupFolderselect(&sels); |
176 | if (!sels.exec()) return; | 179 | if (!sels.exec()) return; |
177 | targetMail = sels.currentMail(); | 180 | targetMail = sels.currentMail(); |
178 | targetFolder = sels.currentFolder(); | 181 | targetFolder = sels.currentFolder(); |
179 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 182 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
180 | targetFolder.isEmpty()) | 183 | targetFolder.isEmpty()) |
181 | { | 184 | { |
182 | return; | 185 | return; |
183 | } | 186 | } |
184 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 187 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
185 | { | 188 | { |
186 | QMessageBox::critical(0,tr("Error creating new Folder"), | 189 | QMessageBox::critical(0,tr("Error creating new Folder"), |
187 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 190 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
188 | return; | 191 | return; |
189 | } | 192 | } |
190 | int maxsize = 0; | 193 | int maxsize = 0; |
191 | if ( sels.useSize->isChecked()) | 194 | if ( sels.useSize->isChecked()) |
192 | maxsize = sels.sizeSpinBox->value(); | 195 | maxsize = sels.sizeSpinBox->value(); |
193 | 196 | ||
194 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 197 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
195 | refreshCurrent(); | 198 | refreshCurrent(); |
196 | } | 199 | } |
197 | 200 | ||
198 | bool AccountView::currentisDraft() | 201 | bool AccountView::currentisDraft() |
199 | { | 202 | { |
200 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 203 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
201 | if (!view) return false; | 204 | if (!view) return false; |
202 | return view->isDraftfolder(); | 205 | return view->isDraftfolder(); |
203 | } | 206 | } |
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index f876235..374d606 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -1,60 +1,61 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "abstractmail.h" | 2 | #include "abstractmail.h" |
3 | #include "imapwrapper.h" | 3 | #include "imapwrapper.h" |
4 | #include "pop3wrapper.h" | 4 | #include "pop3wrapper.h" |
5 | #include "nntpwrapper.h" | 5 | #include "nntpwrapper.h" |
6 | #include "mhwrapper.h" | 6 | #include "mhwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | 9 | ||
10 | 10 | ||
11 | #include <qprogressbar.h> | 11 | #include <qprogressbar.h> |
12 | #include <qapplication.h> | 12 | #include <qapplication.h> |
13 | #include <qmessagebox.h> | ||
13 | 14 | ||
14 | #include <kdecore/kstandarddirs.h> | 15 | #include <kdecore/kstandarddirs.h> |
15 | #include <qfile.h> | 16 | #include <qfile.h> |
16 | #include <qtextstream.h> | 17 | #include <qtextstream.h> |
17 | #include <stdlib.h> | 18 | #include <stdlib.h> |
18 | #include <libetpan/mailmime_content.h> | 19 | #include <libetpan/mailmime_content.h> |
19 | #include <libetpan/mailmime.h> | 20 | #include <libetpan/mailmime.h> |
20 | 21 | ||
21 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
22 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 23 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
23 | { | 24 | { |
24 | return new IMAPwrapper(a); | 25 | return new IMAPwrapper(a); |
25 | } | 26 | } |
26 | 27 | ||
27 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 28 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
28 | { | 29 | { |
29 | return new POP3wrapper(a); | 30 | return new POP3wrapper(a); |
30 | } | 31 | } |
31 | 32 | ||
32 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 33 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
33 | { | 34 | { |
34 | return new NNTPwrapper(a); | 35 | return new NNTPwrapper(a); |
35 | } | 36 | } |
36 | 37 | ||
37 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 38 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
38 | { | 39 | { |
39 | return new MHwrapper(a,name); | 40 | return new MHwrapper(a,name); |
40 | } | 41 | } |
41 | 42 | ||
42 | AbstractMail* AbstractMail::getWrapper(Account*a) | 43 | AbstractMail* AbstractMail::getWrapper(Account*a) |
43 | { | 44 | { |
44 | if (!a) return 0; | 45 | if (!a) return 0; |
45 | switch (a->getType()) { | 46 | switch (a->getType()) { |
46 | case MAILLIB::A_IMAP: | 47 | case MAILLIB::A_IMAP: |
47 | return new IMAPwrapper((IMAPaccount*)a); | 48 | return new IMAPwrapper((IMAPaccount*)a); |
48 | break; | 49 | break; |
49 | case MAILLIB::A_POP3: | 50 | case MAILLIB::A_POP3: |
50 | return new POP3wrapper((POP3account*)a); | 51 | return new POP3wrapper((POP3account*)a); |
51 | break; | 52 | break; |
52 | case MAILLIB::A_NNTP: | 53 | case MAILLIB::A_NNTP: |
53 | return new NNTPwrapper((NNTPaccount*)a); | 54 | return new NNTPwrapper((NNTPaccount*)a); |
54 | break; | 55 | break; |
55 | default: | 56 | default: |
56 | return 0; | 57 | return 0; |
57 | } | 58 | } |
58 | } | 59 | } |
59 | 60 | ||
60 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 61 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
@@ -113,96 +114,162 @@ QString AbstractMail::gen_attachment_id() | |||
113 | QFile file( "/proc/sys/kernel/random/uuid" ); | 114 | QFile file( "/proc/sys/kernel/random/uuid" ); |
114 | if (!file.open(IO_ReadOnly ) ) | 115 | if (!file.open(IO_ReadOnly ) ) |
115 | return QString::null; | 116 | return QString::null; |
116 | 117 | ||
117 | QTextStream stream(&file); | 118 | QTextStream stream(&file); |
118 | 119 | ||
119 | return "{" + stream.read().stripWhiteSpace() + "}"; | 120 | return "{" + stream.read().stripWhiteSpace() + "}"; |
120 | } | 121 | } |
121 | 122 | ||
122 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) | 123 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) |
123 | { | 124 | { |
124 | return 0; | 125 | return 0; |
125 | } | 126 | } |
126 | 127 | ||
127 | QString AbstractMail::defaultLocalfolder() | 128 | QString AbstractMail::defaultLocalfolder() |
128 | { | 129 | { |
129 | // QString f = getenv( "HOME" ); | 130 | // QString f = getenv( "HOME" ); |
130 | QString f = locateLocal( "data", "kopiemail/localmail"); | 131 | QString f = locateLocal( "data", "kopiemail/localmail"); |
131 | // f += "/Applications/opiemail/localmail"; | 132 | // f += "/Applications/opiemail/localmail"; |
132 | return f; | 133 | return f; |
133 | } | 134 | } |
134 | 135 | ||
135 | QString AbstractMail::draftFolder() | 136 | QString AbstractMail::draftFolder() |
136 | { | 137 | { |
137 | return QString("Drafts"); | 138 | return QString("Drafts"); |
138 | } | 139 | } |
139 | 140 | ||
140 | /* temporary - will be removed when implemented in all classes */ | 141 | /* temporary - will be removed when implemented in all classes */ |
141 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 142 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
142 | { | 143 | { |
143 | } | 144 | } |
144 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | 145 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) |
145 | { | 146 | { |
146 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | 147 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); |
147 | // this is currently re-implemented in pop3wrapper and imapwrapper | 148 | // this is currently re-implemented in pop3wrapper and imapwrapper |
148 | int iii = 0; | 149 | int iii = 0; |
149 | int count = target.count(); | 150 | int count = target.count(); |
150 | QWidget wid; | 151 | QWidget wid; |
151 | wid.show(); | 152 | wid.show(); |
152 | while (iii < count ) { | 153 | while (iii < count ) { |
153 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 154 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
154 | wid.raise(); | 155 | wid.raise(); |
155 | qApp->processEvents(); | 156 | qApp->processEvents(); |
156 | RecMailP mail = (*target.at( iii )); | 157 | RecMailP mail = (*target.at( iii )); |
157 | deleteMail(mail); | 158 | deleteMail(mail); |
158 | ++iii; | 159 | ++iii; |
159 | } | 160 | } |
160 | } | 161 | } |
162 | |||
163 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) | ||
164 | { | ||
165 | qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); | ||
166 | // get local folder | ||
167 | Account * acc = getAccount(); | ||
168 | if ( !acc ) return; | ||
169 | QString lfName = acc->getLocalFolder(); | ||
170 | if ( lfName.isEmpty() ) | ||
171 | lfName = acc->getAccountName(); | ||
172 | // create local folder | ||
173 | if ( !targetMail->createMbox(lfName)) | ||
174 | { | ||
175 | QMessageBox::critical(0,tr("Error creating new Folder"), | ||
176 | tr("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); | ||
177 | return; | ||
178 | } | ||
179 | QValueList<RecMailP> t; | ||
180 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); | ||
181 | if ( t.count() == 0 ) { | ||
182 | Global::statusMessage(tr("There are no new messages")); | ||
183 | return; | ||
184 | } | ||
185 | QValueList<RecMailP> e; | ||
186 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); | ||
187 | qDebug("target has mails %d ", e.count()); | ||
188 | QValueList<RecMailP> n; | ||
189 | int iii = 0; | ||
190 | int count = t.count(); | ||
191 | while (iii < count ) { | ||
192 | RecMailP r = (*t.at( iii )); | ||
193 | bool found = false; | ||
194 | int jjj = 0; | ||
195 | int countE = e.count(); | ||
196 | while (jjj < countE ) { | ||
197 | RecMailP re = (*e.at( jjj )); | ||
198 | if ( re->isEqual(r) ) { | ||
199 | found = true; | ||
200 | break; | ||
201 | } | ||
202 | ++jjj; | ||
203 | } | ||
204 | if ( found ) | ||
205 | qDebug("found "); | ||
206 | else | ||
207 | qDebug("NOT found "); | ||
208 | |||
209 | if ( !found ) { | ||
210 | n.append( r ); | ||
211 | } | ||
212 | ++iii; | ||
213 | } | ||
214 | if ( n.count() == 0 ) { | ||
215 | Global::statusMessage(tr("There are no new messages")); | ||
216 | return; | ||
217 | } | ||
218 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); | ||
219 | |||
220 | |||
221 | #if 0 | ||
222 | QValueList<RecMailP> t; | ||
223 | listMessages(fromFolder->getName(),t, maxSizeInKb); | ||
224 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | ||
225 | #endif | ||
226 | |||
227 | } | ||
161 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 228 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
162 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 229 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
163 | { | 230 | { |
164 | QValueList<RecMailP> t; | 231 | QValueList<RecMailP> t; |
165 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 232 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
166 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 233 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
167 | 234 | ||
168 | } | 235 | } |
169 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, | 236 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, |
170 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 237 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
171 | { | 238 | { |
172 | encodedString*st = 0; | 239 | encodedString*st = 0; |
173 | int iii = 0; | 240 | int iii = 0; |
174 | int count = t.count(); | 241 | int count = t.count(); |
175 | if ( count == 0 ) | 242 | if ( count == 0 ) |
176 | return; | 243 | return; |
177 | // wel, processevents is qite strange, we need a widget for getting | 244 | // wel, processevents is qite strange, we need a widget for getting |
178 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displayed | 245 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displayed |
179 | QWidget wid; | 246 | QWidget wid; |
180 | wid.show(); | 247 | wid.show(); |
181 | while (iii < count ) { | 248 | while (iii < count ) { |
182 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); | 249 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); |
183 | wid.raise(); | 250 | wid.raise(); |
184 | qApp->processEvents(); | 251 | qApp->processEvents(); |
185 | RecMailP r = (*t.at( iii )); | 252 | RecMailP r = (*t.at( iii )); |
186 | st = fetchRawBody(r); | 253 | st = fetchRawBody(r); |
187 | if (st) { | 254 | if (st) { |
188 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 255 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
189 | delete st; | 256 | delete st; |
190 | } | 257 | } |
191 | ++iii; | 258 | ++iii; |
192 | } | 259 | } |
193 | if (moveit) { | 260 | if (moveit) { |
194 | deleteMailList( t ); | 261 | deleteMailList( t ); |
195 | //deleteAllMail(fromFolder); | 262 | //deleteAllMail(fromFolder); |
196 | } | 263 | } |
197 | } | 264 | } |
198 | 265 | ||
199 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 266 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
200 | { | 267 | { |
201 | encodedString*st = 0; | 268 | encodedString*st = 0; |
202 | st = fetchRawBody(mail); | 269 | st = fetchRawBody(mail); |
203 | if (st) { | 270 | if (st) { |
204 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 271 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
205 | delete st; | 272 | delete st; |
206 | } | 273 | } |
207 | if (moveit) { | 274 | if (moveit) { |
208 | deleteMail(mail); | 275 | deleteMail(mail); |
diff --git a/kmicromail/libmailwrapper/abstractmail.h b/kmicromail/libmailwrapper/abstractmail.h index cae83f4..2069ca1 100644 --- a/kmicromail/libmailwrapper/abstractmail.h +++ b/kmicromail/libmailwrapper/abstractmail.h | |||
@@ -1,76 +1,81 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __abstract_mail_ | 2 | #ifndef __abstract_mail_ |
3 | #define __abstract_mail_ | 3 | #define __abstract_mail_ |
4 | 4 | ||
5 | #include "maildefines.h" | 5 | #include "maildefines.h" |
6 | 6 | ||
7 | #include "settings.h" | 7 | #include "settings.h" |
8 | 8 | ||
9 | #include <qobject.h> | 9 | #include <qobject.h> |
10 | #include <opie2/osmartpointer.h> | 10 | #include <opie2/osmartpointer.h> |
11 | #include "mailtypes.h" | 11 | #include "mailtypes.h" |
12 | 12 | ||
13 | |||
14 | #include "mailwrapper.h" | ||
15 | |||
13 | class IMAPwrapper; | 16 | class IMAPwrapper; |
14 | class POP3wrapper; | 17 | class POP3wrapper; |
15 | class Folder; | 18 | class Folder; |
16 | class encodedString; | 19 | class encodedString; |
17 | struct folderStat; | 20 | struct folderStat; |
18 | 21 | ||
19 | class AbstractMail:public QObject | 22 | class AbstractMail:public QObject |
20 | { | 23 | { |
21 | Q_OBJECT | 24 | Q_OBJECT |
22 | public: | 25 | public: |
23 | AbstractMail(){}; | 26 | AbstractMail(){}; |
24 | virtual ~AbstractMail(){} | 27 | virtual ~AbstractMail(){} |
25 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0; | 28 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0; |
26 | virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target, int sizeInKb = 0 )=0; | 29 | virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target, int sizeInKb = 0 )=0; |
27 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 30 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
28 | virtual RecBodyP fetchBody(const RecMailP&mail)=0; | 31 | virtual RecBodyP fetchBody(const RecMailP&mail)=0; |
29 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0; | 32 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0; |
30 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0; | 33 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0; |
31 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0; | 34 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0; |
32 | virtual encodedString* fetchRawBody(const RecMailP&mail)=0; | 35 | virtual encodedString* fetchRawBody(const RecMailP&mail)=0; |
33 | 36 | ||
34 | virtual void deleteMail(const RecMailP&mail)=0; | 37 | virtual void deleteMail(const RecMailP&mail)=0; |
35 | virtual void deleteMailList(const QValueList<RecMailP>&target); | 38 | virtual void deleteMailList(const QValueList<RecMailP>&target); |
36 | virtual void answeredMail(const RecMailP&mail)=0; | 39 | virtual void answeredMail(const RecMailP&mail)=0; |
37 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0; | 40 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0; |
38 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target); | 41 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target); |
39 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; | 42 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; |
40 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 43 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
41 | 44 | void downloadNewMails(const FolderP&fromFolder,AbstractMail*targetWrapper ); | |
42 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 45 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
43 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int sizeInKb = 0); | 46 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int sizeInKb = 0); |
44 | virtual void mvcpMailList(const QValueList<RecMailP>& t, | 47 | virtual void mvcpMailList(const QValueList<RecMailP>& t, |
45 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 48 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
46 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 49 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
47 | 50 | ||
48 | virtual void cleanMimeCache(){}; | 51 | virtual void cleanMimeCache(){}; |
49 | /* mail box methods */ | 52 | /* mail box methods */ |
50 | /* parameter is the box to create. | 53 | /* parameter is the box to create. |
51 | * if the implementing subclass has prefixes, | 54 | * if the implementing subclass has prefixes, |
52 | * them has to be appended automatic. | 55 | * them has to be appended automatic. |
53 | */ | 56 | */ |
54 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, | 57 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, |
55 | const QString& delemiter="/",bool getsubfolder=false); | 58 | const QString& delemiter="/",bool getsubfolder=false); |
56 | virtual void logout()=0; | 59 | virtual void logout()=0; |
57 | 60 | ||
61 | virtual Account* getAccount() = 0; | ||
62 | |||
58 | static AbstractMail* getWrapper(IMAPaccount *a); | 63 | static AbstractMail* getWrapper(IMAPaccount *a); |
59 | static AbstractMail* getWrapper(POP3account *a); | 64 | static AbstractMail* getWrapper(POP3account *a); |
60 | static AbstractMail* getWrapper(NNTPaccount *a); | 65 | static AbstractMail* getWrapper(NNTPaccount *a); |
61 | /* mbox only! */ | 66 | /* mbox only! */ |
62 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); | 67 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
63 | static AbstractMail* getWrapper(Account*a); | 68 | static AbstractMail* getWrapper(Account*a); |
64 | 69 | ||
65 | static QString defaultLocalfolder(); | 70 | static QString defaultLocalfolder(); |
66 | static QString draftFolder(); | 71 | static QString draftFolder(); |
67 | 72 | ||
68 | virtual MAILLIB::ATYPE getType()const=0; | 73 | virtual MAILLIB::ATYPE getType()const=0; |
69 | virtual const QString&getName()const=0; | 74 | virtual const QString&getName()const=0; |
70 | 75 | ||
71 | protected: | 76 | protected: |
72 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 77 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
73 | static QString convert_String(const char*text); | 78 | static QString convert_String(const char*text); |
74 | static QString gen_attachment_id(); | 79 | static QString gen_attachment_id(); |
75 | }; | 80 | }; |
76 | #endif | 81 | #endif |
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index 9614d53..2b04847 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,74 +1,119 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "genericwrapper.h" | 2 | #include "genericwrapper.h" |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <kconfig.h> | ||
7 | #include <kglobal.h> | ||
8 | #include <kstandarddirs.h> | ||
6 | 9 | ||
7 | 10 | ||
8 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
9 | Genericwrapper::Genericwrapper() | 12 | Genericwrapper::Genericwrapper() |
10 | : AbstractMail() | 13 | : AbstractMail() |
11 | { | 14 | { |
12 | bodyCache.clear(); | 15 | bodyCache.clear(); |
13 | m_storage = 0; | 16 | m_storage = 0; |
14 | m_folder = 0; | 17 | m_folder = 0; |
15 | } | 18 | } |
16 | 19 | ||
17 | Genericwrapper::~Genericwrapper() | 20 | Genericwrapper::~Genericwrapper() |
18 | { | 21 | { |
19 | if (m_folder) { | 22 | if (m_folder) { |
20 | mailfolder_free(m_folder); | 23 | mailfolder_free(m_folder); |
21 | } | 24 | } |
22 | if (m_storage) { | 25 | if (m_storage) { |
23 | mailstorage_free(m_storage); | 26 | mailstorage_free(m_storage); |
24 | } | 27 | } |
25 | cleanMimeCache(); | 28 | cleanMimeCache(); |
26 | } | 29 | } |
30 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | ||
31 | { | ||
32 | static bool init = false ; | ||
33 | if ( ! init ) { | ||
34 | KConfig kon ( locateLocal( "config", "korganizerrc" ) ); | ||
35 | kon.setGroup("Locale"); | ||
36 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); | ||
37 | QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); | ||
38 | KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); | ||
39 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | ||
40 | kon.setGroup("Time & Date"); | ||
41 | KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), | ||
42 | kon.readNumEntry( "DaylightsavingStart", 90), | ||
43 | kon.readNumEntry( "DaylightsavingEnd",304) ); | ||
44 | KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); | ||
45 | |||
46 | init = true; | ||
47 | |||
48 | } | ||
49 | QDateTime dt (QDate(date->dt_year,date->dt_month, date->dt_day ),QTime(date->dt_hour, date->dt_min, date->dt_sec ) ); | ||
50 | int off = KGlobal::locale()->localTimeOffset( dt ); | ||
51 | dt = dt.addSecs( off*60 ); | ||
52 | QString ret = KGlobal::locale()->formatDateTime( dt,true,true); | ||
53 | if ( off < 0 ) | ||
54 | ret += " -"; | ||
55 | else | ||
56 | ret += " +"; | ||
57 | ret += QString::number( off / 60 ); | ||
58 | ret += "h"; | ||
59 | #if 0 | ||
60 | char tmp[23]; | ||
61 | |||
62 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | ||
63 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
64 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | ||
65 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
66 | |||
67 | |||
68 | return QString( tmp ); | ||
69 | #endif | ||
70 | return ret; | ||
71 | } | ||
27 | 72 | ||
28 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 73 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
29 | { | 74 | { |
30 | if (!mime) { | 75 | if (!mime) { |
31 | return; | 76 | return; |
32 | } | 77 | } |
33 | mailmime_field*field = 0; | 78 | mailmime_field*field = 0; |
34 | mailmime_single_fields fields; | 79 | mailmime_single_fields fields; |
35 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 80 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
36 | if (mime->mm_mime_fields != NULL) { | 81 | if (mime->mm_mime_fields != NULL) { |
37 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 82 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
38 | mime->mm_content_type); | 83 | mime->mm_content_type); |
39 | } | 84 | } |
40 | 85 | ||
41 | mailmime_content*type = fields.fld_content; | 86 | mailmime_content*type = fields.fld_content; |
42 | clistcell*current; | 87 | clistcell*current; |
43 | if (!type) { | 88 | if (!type) { |
44 | target->setType("text"); | 89 | target->setType("text"); |
45 | target->setSubtype("plain"); | 90 | target->setSubtype("plain"); |
46 | } else { | 91 | } else { |
47 | target->setSubtype(type->ct_subtype); | 92 | target->setSubtype(type->ct_subtype); |
48 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 93 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
49 | case MAILMIME_DISCRETE_TYPE_TEXT: | 94 | case MAILMIME_DISCRETE_TYPE_TEXT: |
50 | target->setType("text"); | 95 | target->setType("text"); |
51 | break; | 96 | break; |
52 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 97 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
53 | target->setType("image"); | 98 | target->setType("image"); |
54 | break; | 99 | break; |
55 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 100 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
56 | target->setType("audio"); | 101 | target->setType("audio"); |
57 | break; | 102 | break; |
58 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 103 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
59 | target->setType("video"); | 104 | target->setType("video"); |
60 | break; | 105 | break; |
61 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 106 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
62 | target->setType("application"); | 107 | target->setType("application"); |
63 | break; | 108 | break; |
64 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 109 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
65 | default: | 110 | default: |
66 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 111 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
67 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 112 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
68 | } | 113 | } |
69 | break; | 114 | break; |
70 | } | 115 | } |
71 | if (type->ct_parameters) { | 116 | if (type->ct_parameters) { |
72 | fillParameters(target,type->ct_parameters); | 117 | fillParameters(target,type->ct_parameters); |
73 | } | 118 | } |
74 | } | 119 | } |
@@ -197,107 +242,96 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m | |||
197 | } | 242 | } |
198 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 243 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
199 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 244 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
200 | countlist = recList; | 245 | countlist = recList; |
201 | } | 246 | } |
202 | ++ccount; | 247 | ++ccount; |
203 | } | 248 | } |
204 | } | 249 | } |
205 | break; | 250 | break; |
206 | case MAILMIME_MESSAGE: | 251 | case MAILMIME_MESSAGE: |
207 | { | 252 | { |
208 | QValueList<int>countlist = recList; | 253 | QValueList<int>countlist = recList; |
209 | countlist.append(current_count); | 254 | countlist.append(current_count); |
210 | /* the own header is always at recursion 0 - we don't need that */ | 255 | /* the own header is always at recursion 0 - we don't need that */ |
211 | if (current_rec > 0) { | 256 | if (current_rec > 0) { |
212 | part->setPositionlist(countlist); | 257 | part->setPositionlist(countlist); |
213 | r = mailmessage_fetch_section(message,mime,&data,&len); | 258 | r = mailmessage_fetch_section(message,mime,&data,&len); |
214 | part->setSize(len); | 259 | part->setSize(len); |
215 | part->setPositionlist(countlist); | 260 | part->setPositionlist(countlist); |
216 | b = gen_attachment_id(); | 261 | b = gen_attachment_id(); |
217 | part->setIdentifier(b); | 262 | part->setIdentifier(b); |
218 | part->setType("message"); | 263 | part->setType("message"); |
219 | part->setSubtype("rfc822"); | 264 | part->setSubtype("rfc822"); |
220 | bodyCache[b]=new encodedString(data,len); | 265 | bodyCache[b]=new encodedString(data,len); |
221 | target->addPart(part); | 266 | target->addPart(part); |
222 | } | 267 | } |
223 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 268 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
224 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 269 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
225 | } | 270 | } |
226 | } | 271 | } |
227 | break; | 272 | break; |
228 | } | 273 | } |
229 | } | 274 | } |
230 | 275 | ||
231 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) | 276 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) |
232 | { | 277 | { |
233 | int err = MAILIMF_NO_ERROR; | 278 | int err = MAILIMF_NO_ERROR; |
234 | mailmime_single_fields fields; | 279 | mailmime_single_fields fields; |
235 | /* is bound to msg and will be freed there */ | 280 | /* is bound to msg and will be freed there */ |
236 | mailmime * mime=0; | 281 | mailmime * mime=0; |
237 | RecBodyP body = new RecBody(); | 282 | RecBodyP body = new RecBody(); |
238 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 283 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
239 | err = mailmessage_get_bodystructure(msg,&mime); | 284 | err = mailmessage_get_bodystructure(msg,&mime); |
240 | QValueList<int>recList; | 285 | QValueList<int>recList; |
241 | traverseBody(body,msg,mime,recList); | 286 | traverseBody(body,msg,mime,recList); |
242 | return body; | 287 | return body; |
243 | } | 288 | } |
244 | 289 | ||
245 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | ||
246 | { | ||
247 | char tmp[23]; | ||
248 | |||
249 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | ||
250 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
251 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | ||
252 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
253 | |||
254 | return QString( tmp ); | ||
255 | } | ||
256 | 290 | ||
257 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 291 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
258 | { | 292 | { |
259 | QString result( "" ); | 293 | QString result( "" ); |
260 | 294 | ||
261 | bool first = true; | 295 | bool first = true; |
262 | if (list == 0) return result; | 296 | if (list == 0) return result; |
263 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 297 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
264 | mailimf_address *addr = (mailimf_address *) current->data; | 298 | mailimf_address *addr = (mailimf_address *) current->data; |
265 | 299 | ||
266 | if ( !first ) { | 300 | if ( !first ) { |
267 | result.append( "," ); | 301 | result.append( "," ); |
268 | } else { | 302 | } else { |
269 | first = false; | 303 | first = false; |
270 | } | 304 | } |
271 | 305 | ||
272 | switch ( addr->ad_type ) { | 306 | switch ( addr->ad_type ) { |
273 | case MAILIMF_ADDRESS_MAILBOX: | 307 | case MAILIMF_ADDRESS_MAILBOX: |
274 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 308 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
275 | break; | 309 | break; |
276 | case MAILIMF_ADDRESS_GROUP: | 310 | case MAILIMF_ADDRESS_GROUP: |
277 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 311 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
278 | break; | 312 | break; |
279 | default: | 313 | default: |
280 | ; // odebug << "Generic: unkown mailimf address type" << oendl; | 314 | ; // odebug << "Generic: unkown mailimf address type" << oendl; |
281 | break; | 315 | break; |
282 | } | 316 | } |
283 | } | 317 | } |
284 | 318 | ||
285 | return result; | 319 | return result; |
286 | } | 320 | } |
287 | 321 | ||
288 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 322 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
289 | { | 323 | { |
290 | QString result( "" ); | 324 | QString result( "" ); |
291 | 325 | ||
292 | result.append( group->grp_display_name ); | 326 | result.append( group->grp_display_name ); |
293 | result.append( ": " ); | 327 | result.append( ": " ); |
294 | 328 | ||
295 | if ( group->grp_mb_list != NULL ) { | 329 | if ( group->grp_mb_list != NULL ) { |
296 | result.append( parseMailboxList( group->grp_mb_list ) ); | 330 | result.append( parseMailboxList( group->grp_mb_list ) ); |
297 | } | 331 | } |
298 | 332 | ||
299 | result.append( ";" ); | 333 | result.append( ";" ); |
300 | 334 | ||
301 | return result; | 335 | return result; |
302 | } | 336 | } |
303 | 337 | ||
@@ -403,79 +437,85 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > & | |||
403 | return; | 437 | return; |
404 | } | 438 | } |
405 | r = mailsession_get_envelopes_list(session, env_list); | 439 | r = mailsession_get_envelopes_list(session, env_list); |
406 | if (r != MAIL_NO_ERROR) { | 440 | if (r != MAIL_NO_ERROR) { |
407 | ; // odebug << "Error filling message list" << oendl; | 441 | ; // odebug << "Error filling message list" << oendl; |
408 | if (env_list) { | 442 | if (env_list) { |
409 | mailmessage_list_free(env_list); | 443 | mailmessage_list_free(env_list); |
410 | } | 444 | } |
411 | return; | 445 | return; |
412 | } | 446 | } |
413 | mailimf_references * refs = 0; | 447 | mailimf_references * refs = 0; |
414 | mailimf_in_reply_to * in_replies = 0; | 448 | mailimf_in_reply_to * in_replies = 0; |
415 | uint32_t i = 0; | 449 | uint32_t i = 0; |
416 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 450 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
417 | mailmessage * msg; | 451 | mailmessage * msg; |
418 | QBitArray mFlags(7); | 452 | QBitArray mFlags(7); |
419 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 453 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
420 | if (msg->msg_fields == NULL) { | 454 | if (msg->msg_fields == NULL) { |
421 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; | 455 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; |
422 | continue; | 456 | continue; |
423 | } | 457 | } |
424 | RecMailP mail = new RecMail(); | 458 | RecMailP mail = new RecMail(); |
425 | mail->setWrapper(this); | 459 | mail->setWrapper(this); |
426 | mail_flags * flag_result = 0; | 460 | mail_flags * flag_result = 0; |
427 | r = mailmessage_get_flags(msg,&flag_result); | 461 | r = mailmessage_get_flags(msg,&flag_result); |
428 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 462 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
429 | mFlags.setBit(FLAG_SEEN); | 463 | mFlags.setBit(FLAG_SEEN); |
430 | } | 464 | } |
431 | mailimf_single_fields single_fields; | 465 | mailimf_single_fields single_fields; |
432 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 466 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
433 | mail->setMsgsize(msg->msg_size); | 467 | mail->setMsgsize(msg->msg_size); |
434 | mail->setFlags(mFlags); | 468 | mail->setFlags(mFlags); |
435 | mail->setMbox(mailbox); | 469 | mail->setMbox(mailbox); |
436 | mail->setNumber(msg->msg_index); | 470 | mail->setNumber(msg->msg_index); |
437 | if (single_fields.fld_subject) | 471 | if (single_fields.fld_subject) |
438 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 472 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
439 | if (single_fields.fld_from) | 473 | if (single_fields.fld_from) |
440 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 474 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
441 | if (!mbox_as_to) { | 475 | if (!mbox_as_to) { |
442 | if (single_fields.fld_to) | 476 | if (single_fields.fld_to) |
443 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 477 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
444 | } else { | 478 | } else { |
445 | mail->setTo(mailbox); | 479 | mail->setTo(mailbox); |
446 | } | 480 | } |
447 | if (single_fields.fld_cc) | 481 | if (single_fields.fld_cc) |
448 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 482 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
449 | if (single_fields.fld_bcc) | 483 | if (single_fields.fld_bcc) |
450 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 484 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
451 | if (single_fields.fld_orig_date) | 485 | if (single_fields.fld_orig_date) { |
452 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 486 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); |
487 | char tmp[23]; | ||
488 | struct mailimf_date_time* date = single_fields.fld_orig_date->dt_date_time; | ||
489 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | ||
490 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
491 | mail->setIsoDate( QString( tmp ) ); | ||
492 | } | ||
453 | // crashes when accessing pop3 account? | 493 | // crashes when accessing pop3 account? |
454 | if (single_fields.fld_message_id) { | 494 | if (single_fields.fld_message_id) { |
455 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 495 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
456 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; | 496 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; |
457 | } | 497 | } |
458 | if (single_fields.fld_reply_to) { | 498 | if (single_fields.fld_reply_to) { |
459 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | 499 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); |
460 | if (t.count()>0) { | 500 | if (t.count()>0) { |
461 | mail->setReplyto(t[0]); | 501 | mail->setReplyto(t[0]); |
462 | } | 502 | } |
463 | } | 503 | } |
464 | #if 0 | 504 | #if 0 |
465 | refs = single_fields.fld_references; | 505 | refs = single_fields.fld_references; |
466 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 506 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
467 | char * text = (char*)refs->mid_list->first->data; | 507 | char * text = (char*)refs->mid_list->first->data; |
468 | mail->setReplyto(QString(text)); | 508 | mail->setReplyto(QString(text)); |
469 | } | 509 | } |
470 | #endif | 510 | #endif |
471 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && | 511 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && |
472 | clist_count(single_fields.fld_in_reply_to->mid_list)) { | 512 | clist_count(single_fields.fld_in_reply_to->mid_list)) { |
473 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); | 513 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); |
474 | } | 514 | } |
475 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) | 515 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) |
476 | target.append(mail); | 516 | target.append(mail); |
477 | } | 517 | } |
478 | if (env_list) { | 518 | if (env_list) { |
479 | mailmessage_list_free(env_list); | 519 | mailmessage_list_free(env_list); |
480 | } | 520 | } |
481 | } | 521 | } |
diff --git a/kmicromail/libmailwrapper/genericwrapper.h b/kmicromail/libmailwrapper/genericwrapper.h index 235e116..244212f 100644 --- a/kmicromail/libmailwrapper/genericwrapper.h +++ b/kmicromail/libmailwrapper/genericwrapper.h | |||
@@ -1,68 +1,68 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __GENERIC_WRAPPER_H | 2 | #ifndef __GENERIC_WRAPPER_H |
3 | #define __GENERIC_WRAPPER_H | 3 | #define __GENERIC_WRAPPER_H |
4 | 4 | ||
5 | #include "abstractmail.h" | 5 | #include "abstractmail.h" |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
9 | 9 | ||
10 | class RecMail; | 10 | class RecMail; |
11 | class RecBody; | 11 | class RecBody; |
12 | class encodedString; | 12 | class encodedString; |
13 | struct mailpop3; | 13 | struct mailpop3; |
14 | struct mailmessage; | 14 | struct mailmessage; |
15 | struct mailmime; | 15 | struct mailmime; |
16 | struct mailmime_mechanism; | 16 | struct mailmime_mechanism; |
17 | struct mailimf_mailbox_list; | 17 | struct mailimf_mailbox_list; |
18 | struct mailimf_mailbox; | 18 | struct mailimf_mailbox; |
19 | struct mailimf_date_time; | 19 | struct mailimf_date_time; |
20 | struct mailimf_group; | 20 | struct mailimf_group; |
21 | struct mailimf_address_list; | 21 | struct mailimf_address_list; |
22 | struct mailsession; | 22 | struct mailsession; |
23 | struct mailstorage; | 23 | struct mailstorage; |
24 | struct mailfolder; | 24 | struct mailfolder; |
25 | struct mailimf_in_reply_to; | 25 | struct mailimf_in_reply_to; |
26 | 26 | ||
27 | /* this class hold just the funs shared between | 27 | /* this class hold just the funs shared between |
28 | * mbox and pop3 (later mh, too) mail access. | 28 | * mbox and pop3 (later mh, too) mail access. |
29 | * it is not desigend to make a instance of it! | 29 | * it is not desigend to make a instance of it! |
30 | */ | 30 | */ |
31 | class Genericwrapper : public AbstractMail | 31 | class Genericwrapper : public AbstractMail |
32 | { | 32 | { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | public: | 34 | public: |
35 | Genericwrapper(); | 35 | Genericwrapper(); |
36 | virtual ~Genericwrapper(); | 36 | virtual ~Genericwrapper(); |
37 | 37 | ||
38 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); | 38 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); |
39 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); | 39 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); |
40 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); | 40 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); |
41 | virtual void cleanMimeCache(); | 41 | virtual void cleanMimeCache(); |
42 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} | 42 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} |
43 | virtual void logout(){}; | 43 | virtual void logout(){}; |
44 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; | 44 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; |
45 | static QString parseDateTime( mailimf_date_time *date ); | ||
45 | 46 | ||
46 | protected: | 47 | protected: |
47 | RecBodyP parseMail( mailmessage * msg ); | 48 | RecBodyP parseMail( mailmessage * msg ); |
48 | QString parseMailboxList( mailimf_mailbox_list *list ); | 49 | QString parseMailboxList( mailimf_mailbox_list *list ); |
49 | QString parseMailbox( mailimf_mailbox *box ); | 50 | QString parseMailbox( mailimf_mailbox *box ); |
50 | QString parseGroup( mailimf_group *group ); | 51 | QString parseGroup( mailimf_group *group ); |
51 | QString parseAddressList( mailimf_address_list *list ); | 52 | QString parseAddressList( mailimf_address_list *list ); |
52 | QString parseDateTime( mailimf_date_time *date ); | ||
53 | 53 | ||
54 | void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); | 54 | void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); |
55 | static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); | 55 | static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); |
56 | static void fillParameters(RecPartP&target,clist*parameters); | 56 | static void fillParameters(RecPartP&target,clist*parameters); |
57 | static QString getencoding(mailmime_mechanism*aEnc); | 57 | static QString getencoding(mailmime_mechanism*aEnc); |
58 | virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false, int maxSizeInKb = 0); | 58 | virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false, int maxSizeInKb = 0); |
59 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); | 59 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); |
60 | 60 | ||
61 | QString msgTempName; | 61 | QString msgTempName; |
62 | unsigned int last_msg_id; | 62 | unsigned int last_msg_id; |
63 | QMap<QString,encodedString*> bodyCache; | 63 | QMap<QString,encodedString*> bodyCache; |
64 | mailstorage * m_storage; | 64 | mailstorage * m_storage; |
65 | mailfolder*m_folder; | 65 | mailfolder*m_folder; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | #endif | 68 | #endif |
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 6faa524..5441a9b 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,57 +1,58 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | #include "genericwrapper.h" | ||
10 | 11 | ||
11 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
12 | int IMAPwrapper::mMax = 0; | 13 | int IMAPwrapper::mMax = 0; |
13 | int IMAPwrapper::mCurrent = 0; | 14 | int IMAPwrapper::mCurrent = 0; |
14 | 15 | ||
15 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 16 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
16 | : AbstractMail() | 17 | : AbstractMail() |
17 | { | 18 | { |
18 | account = a; | 19 | account = a; |
19 | m_imap = 0; | 20 | m_imap = 0; |
20 | m_Lastmbox = ""; | 21 | m_Lastmbox = ""; |
21 | mCurrent = 0; | 22 | mCurrent = 0; |
22 | mMax = 0; | 23 | mMax = 0; |
23 | } | 24 | } |
24 | 25 | ||
25 | IMAPwrapper::~IMAPwrapper() | 26 | IMAPwrapper::~IMAPwrapper() |
26 | { | 27 | { |
27 | logout(); | 28 | logout(); |
28 | } | 29 | } |
29 | 30 | ||
30 | /* to avoid to often select statements in loops etc. | 31 | /* to avoid to often select statements in loops etc. |
31 | we trust that we are logged in and connection is established!*/ | 32 | we trust that we are logged in and connection is established!*/ |
32 | int IMAPwrapper::selectMbox(const QString&mbox) | 33 | int IMAPwrapper::selectMbox(const QString&mbox) |
33 | { | 34 | { |
34 | if (mbox == m_Lastmbox) { | 35 | if (mbox == m_Lastmbox) { |
35 | return MAILIMAP_NO_ERROR; | 36 | return MAILIMAP_NO_ERROR; |
36 | } | 37 | } |
37 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 38 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
38 | if ( err != MAILIMAP_NO_ERROR ) { | 39 | if ( err != MAILIMAP_NO_ERROR ) { |
39 | m_Lastmbox = ""; | 40 | m_Lastmbox = ""; |
40 | return err; | 41 | return err; |
41 | } | 42 | } |
42 | m_Lastmbox = mbox; | 43 | m_Lastmbox = mbox; |
43 | return err; | 44 | return err; |
44 | } | 45 | } |
45 | 46 | ||
46 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 47 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
47 | { | 48 | { |
48 | //qDebug("imap progress %d of %d ",current,maximum ); | 49 | //qDebug("imap progress %d of %d ",current,maximum ); |
49 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); | 50 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); |
50 | //qApp->processEvents() | 51 | //qApp->processEvents() |
51 | static int last = 0; | 52 | static int last = 0; |
52 | if ( last != current ) | 53 | if ( last != current ) |
53 | IMAPwrapper::progress(); | 54 | IMAPwrapper::progress(); |
54 | last = current; | 55 | last = current; |
55 | } | 56 | } |
56 | void IMAPwrapper::progress( QString m ) | 57 | void IMAPwrapper::progress( QString m ) |
57 | { | 58 | { |
@@ -411,98 +412,113 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
411 | continue; | 412 | continue; |
412 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 413 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
413 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 414 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
414 | if (!flist || !flist->att_list) { | 415 | if (!flist || !flist->att_list) { |
415 | continue; | 416 | continue; |
416 | } | 417 | } |
417 | cf = flist->att_list->first; | 418 | cf = flist->att_list->first; |
418 | if( ! cf ) | 419 | if( ! cf ) |
419 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 420 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
420 | cflag = (mailimap_flag_fetch*)cf->data; | 421 | cflag = (mailimap_flag_fetch*)cf->data; |
421 | if( ! cflag ) | 422 | if( ! cflag ) |
422 | qDebug("imap:not cflag "); | 423 | qDebug("imap:not cflag "); |
423 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 424 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
424 | switch (cflag->fl_flag->fl_type) { | 425 | switch (cflag->fl_flag->fl_type) { |
425 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 426 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
426 | mFlags.setBit(FLAG_ANSWERED); | 427 | mFlags.setBit(FLAG_ANSWERED); |
427 | break; | 428 | break; |
428 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 429 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
429 | mFlags.setBit(FLAG_FLAGGED); | 430 | mFlags.setBit(FLAG_FLAGGED); |
430 | break; | 431 | break; |
431 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 432 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
432 | mFlags.setBit(FLAG_DELETED); | 433 | mFlags.setBit(FLAG_DELETED); |
433 | break; | 434 | break; |
434 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 435 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
435 | mFlags.setBit(FLAG_SEEN); | 436 | mFlags.setBit(FLAG_SEEN); |
436 | break; | 437 | break; |
437 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 438 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
438 | mFlags.setBit(FLAG_DRAFT); | 439 | mFlags.setBit(FLAG_DRAFT); |
439 | break; | 440 | break; |
440 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 441 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
441 | break; | 442 | break; |
442 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 443 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
443 | break; | 444 | break; |
444 | default: | 445 | default: |
445 | break; | 446 | break; |
446 | } | 447 | } |
447 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 448 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
448 | mFlags.setBit(FLAG_RECENT); | 449 | mFlags.setBit(FLAG_RECENT); |
449 | } | 450 | } |
450 | } | 451 | } |
451 | continue; | 452 | continue; |
452 | } | 453 | } |
453 | if ( item->att_data.att_static == NULL ) | 454 | if ( item->att_data.att_static == NULL ) |
454 | continue; | 455 | continue; |
455 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 456 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
456 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 457 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
457 | if ( head == NULL ) | 458 | if ( head == NULL ) |
458 | continue; | 459 | continue; |
459 | if ( head->env_date != NULL ) | 460 | if ( head->env_date != NULL ) { |
460 | m->setDate(head->env_date); | 461 | m->setDate(head->env_date); |
462 | struct mailimf_date_time result; | ||
463 | struct mailimf_date_time* date = &result; | ||
464 | struct mailimf_date_time **re = &date; | ||
465 | size_t length = m->getDate().length(); | ||
466 | size_t index = 0; | ||
467 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | ||
468 | m->setDate( Genericwrapper::parseDateTime( date ) ); | ||
469 | char tmp[23]; | ||
470 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | ||
471 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
472 | m->setIsoDate( QString( tmp ) ); | ||
473 | } else { | ||
474 | m->setIsoDate(head->env_date); | ||
475 | } | ||
476 | } | ||
461 | if ( head->env_subject != NULL ) | 477 | if ( head->env_subject != NULL ) |
462 | m->setSubject(convert_String((const char*)head->env_subject)); | 478 | m->setSubject(convert_String((const char*)head->env_subject)); |
463 | //m->setSubject(head->env_subject); | 479 | //m->setSubject(head->env_subject); |
464 | if (head->env_from!=NULL) { | 480 | if (head->env_from!=NULL) { |
465 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 481 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
466 | if (addresslist.count()) { | 482 | if (addresslist.count()) { |
467 | m->setFrom(addresslist.first()); | 483 | m->setFrom(addresslist.first()); |
468 | } | 484 | } |
469 | } | 485 | } |
470 | if (head->env_to!=NULL) { | 486 | if (head->env_to!=NULL) { |
471 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 487 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
472 | m->setTo(addresslist); | 488 | m->setTo(addresslist); |
473 | } | 489 | } |
474 | if (head->env_cc!=NULL) { | 490 | if (head->env_cc!=NULL) { |
475 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 491 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
476 | m->setCC(addresslist); | 492 | m->setCC(addresslist); |
477 | } | 493 | } |
478 | if (head->env_bcc!=NULL) { | 494 | if (head->env_bcc!=NULL) { |
479 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 495 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
480 | m->setBcc(addresslist); | 496 | m->setBcc(addresslist); |
481 | } | 497 | } |
482 | /* reply to address, eg. email. */ | 498 | /* reply to address, eg. email. */ |
483 | if (head->env_reply_to!=NULL) { | 499 | if (head->env_reply_to!=NULL) { |
484 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 500 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
485 | if (addresslist.count()) { | 501 | if (addresslist.count()) { |
486 | m->setReplyto(addresslist.first()); | 502 | m->setReplyto(addresslist.first()); |
487 | } | 503 | } |
488 | } | 504 | } |
489 | if (head->env_in_reply_to!=NULL) { | 505 | if (head->env_in_reply_to!=NULL) { |
490 | QString h(head->env_in_reply_to); | 506 | QString h(head->env_in_reply_to); |
491 | while (h.length()>0 && h[0]=='<') { | 507 | while (h.length()>0 && h[0]=='<') { |
492 | h.remove(0,1); | 508 | h.remove(0,1); |
493 | } | 509 | } |
494 | while (h.length()>0 && h[h.length()-1]=='>') { | 510 | while (h.length()>0 && h[h.length()-1]=='>') { |
495 | h.remove(h.length()-1,1); | 511 | h.remove(h.length()-1,1); |
496 | } | 512 | } |
497 | if (h.length()>0) { | 513 | if (h.length()>0) { |
498 | m->setInreply(QStringList(h)); | 514 | m->setInreply(QStringList(h)); |
499 | } | 515 | } |
500 | } | 516 | } |
501 | if (head->env_message_id != NULL) { | 517 | if (head->env_message_id != NULL) { |
502 | m->setMsgid(QString(head->env_message_id)); | 518 | m->setMsgid(QString(head->env_message_id)); |
503 | } | 519 | } |
504 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 520 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
505 | #if 0 | 521 | #if 0 |
506 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 522 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
507 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 523 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
508 | qDebug("time %s ",da.toString().latin1() ); | 524 | qDebug("time %s ",da.toString().latin1() ); |
diff --git a/kmicromail/libmailwrapper/imapwrapper.h b/kmicromail/libmailwrapper/imapwrapper.h index db8ab5b..5535d8d 100644 --- a/kmicromail/libmailwrapper/imapwrapper.h +++ b/kmicromail/libmailwrapper/imapwrapper.h | |||
@@ -7,78 +7,79 @@ | |||
7 | #include "abstractmail.h" | 7 | #include "abstractmail.h" |
8 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
9 | 9 | ||
10 | struct mailimap; | 10 | struct mailimap; |
11 | struct mailimap_body; | 11 | struct mailimap_body; |
12 | struct mailimap_body_type_1part; | 12 | struct mailimap_body_type_1part; |
13 | struct mailimap_body_type_text; | 13 | struct mailimap_body_type_text; |
14 | struct mailimap_body_type_basic; | 14 | struct mailimap_body_type_basic; |
15 | struct mailimap_body_type_msg; | 15 | struct mailimap_body_type_msg; |
16 | struct mailimap_body_type_mpart; | 16 | struct mailimap_body_type_mpart; |
17 | struct mailimap_body_fields; | 17 | struct mailimap_body_fields; |
18 | struct mailimap_msg_att; | 18 | struct mailimap_msg_att; |
19 | class encodedString; | 19 | class encodedString; |
20 | 20 | ||
21 | class IMAPwrapper : public AbstractMail | 21 | class IMAPwrapper : public AbstractMail |
22 | { | 22 | { |
23 | Q_OBJECT | 23 | Q_OBJECT |
24 | public: | 24 | public: |
25 | IMAPwrapper( IMAPaccount *a ); | 25 | IMAPwrapper( IMAPaccount *a ); |
26 | virtual ~IMAPwrapper(); | 26 | virtual ~IMAPwrapper(); |
27 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 27 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
28 | virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target , int sizeInKb = 0); | 28 | virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target , int sizeInKb = 0); |
29 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 29 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
30 | 30 | ||
31 | virtual void deleteMail(const RecMailP&mail); | 31 | virtual void deleteMail(const RecMailP&mail); |
32 | void deleteMailList(const QValueList<RecMailP>&target); | 32 | void deleteMailList(const QValueList<RecMailP>&target); |
33 | virtual void answeredMail(const RecMailP&mail); | 33 | virtual void answeredMail(const RecMailP&mail); |
34 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); | 34 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); |
35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
36 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 36 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
37 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit,int sizeInKb = 0); | 37 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit,int sizeInKb = 0); |
38 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 38 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
39 | 39 | ||
40 | virtual RecBodyP fetchBody(const RecMailP&mail); | 40 | virtual RecBodyP fetchBody(const RecMailP&mail); |
41 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); | 41 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); |
42 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); | 42 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); |
43 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); | 43 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); |
44 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 44 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
45 | 45 | ||
46 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, | 46 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, |
47 | const QString& delemiter="/",bool getsubfolder=false); | 47 | const QString& delemiter="/",bool getsubfolder=false); |
48 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder); | 48 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder); |
49 | 49 | ||
50 | static void imap_progress( size_t current, size_t maximum ); | 50 | static void imap_progress( size_t current, size_t maximum ); |
51 | 51 | ||
52 | virtual void logout(); | 52 | virtual void logout(); |
53 | virtual MAILLIB::ATYPE getType()const; | 53 | virtual MAILLIB::ATYPE getType()const; |
54 | virtual const QString&getName()const; | 54 | virtual const QString&getName()const; |
55 | virtual Account* getAccount() { return account; }; | ||
55 | 56 | ||
56 | protected: | 57 | protected: |
57 | RecMail*parse_list_result(mailimap_msg_att*); | 58 | RecMail*parse_list_result(mailimap_msg_att*); |
58 | void login(); | 59 | void login(); |
59 | bool start_tls(bool force=true); | 60 | bool start_tls(bool force=true); |
60 | 61 | ||
61 | virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 62 | virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
62 | virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); | 63 | virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); |
63 | int selectMbox(const QString&mbox); | 64 | int selectMbox(const QString&mbox); |
64 | 65 | ||
65 | void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description); | 66 | void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description); |
66 | void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which); | 67 | void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which); |
67 | void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which); | 68 | void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which); |
68 | void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which); | 69 | void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which); |
69 | void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which); | 70 | void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which); |
70 | void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 71 | void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
71 | 72 | ||
72 | /* just helpers */ | 73 | /* just helpers */ |
73 | static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); | 74 | static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); |
74 | static QStringList address_list_to_stringlist(clist*list); | 75 | static QStringList address_list_to_stringlist(clist*list); |
75 | 76 | ||
76 | static void progress(QString mess = QString::null); | 77 | static void progress(QString mess = QString::null); |
77 | static int mCurrent; | 78 | static int mCurrent; |
78 | static int mMax; | 79 | static int mMax; |
79 | IMAPaccount *account; | 80 | IMAPaccount *account; |
80 | mailimap *m_imap; | 81 | mailimap *m_imap; |
81 | QString m_Lastmbox; | 82 | QString m_Lastmbox; |
82 | }; | 83 | }; |
83 | 84 | ||
84 | #endif | 85 | #endif |
diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp index d43bdc6..1a4ffd1 100644 --- a/kmicromail/libmailwrapper/mailtypes.cpp +++ b/kmicromail/libmailwrapper/mailtypes.cpp | |||
@@ -1,74 +1,97 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | //#include <opie2/odebug.h> | 3 | //#include <opie2/odebug.h> |
4 | 4 | ||
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
6 | 6 | ||
7 | using namespace Opie::Core; | 7 | using namespace Opie::Core; |
8 | RecMail::RecMail() | 8 | RecMail::RecMail() |
9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
10 | { | 10 | { |
11 | init(); | 11 | init(); |
12 | } | 12 | } |
13 | 13 | ||
14 | RecMail::RecMail(const RecMail&old) | 14 | RecMail::RecMail(const RecMail&old) |
15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
16 | { | 16 | { |
17 | init(); | 17 | init(); |
18 | copy_old(old); | 18 | copy_old(old); |
19 | // odebug << "Copy constructor RecMail" << oendl; | 19 | // odebug << "Copy constructor RecMail" << oendl; |
20 | } | 20 | } |
21 | 21 | ||
22 | RecMail::~RecMail() | 22 | RecMail::~RecMail() |
23 | { | 23 | { |
24 | wrapper = 0; | 24 | wrapper = 0; |
25 | } | 25 | } |
26 | static bool stringCompareRec( const QString& s1, const QString& s2 ) | ||
27 | { | ||
28 | if ( s1.isEmpty() && s2.isEmpty() ) | ||
29 | return true; | ||
30 | return s1 == s2; | ||
31 | } | ||
26 | 32 | ||
33 | bool RecMail::isEqual( RecMail* r1 ) | ||
34 | { | ||
35 | if ( !stringCompareRec( isodate, r1->isodate ) ) { | ||
36 | // qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); | ||
37 | return false; | ||
38 | } | ||
39 | if ( !stringCompareRec( from, r1->from ) ) { | ||
40 | //qDebug("from *%s* *%s* ", from.latin1(), r1->from.latin1()); | ||
41 | return false; | ||
42 | } | ||
43 | if ( !stringCompareRec( subject, r1->subject ) ) { | ||
44 | //qDebug("sub "); | ||
45 | return false; | ||
46 | } | ||
47 | |||
48 | return true; | ||
49 | } | ||
27 | void RecMail::copy_old(const RecMail&old) | 50 | void RecMail::copy_old(const RecMail&old) |
28 | { | 51 | { |
29 | subject = old.subject; | 52 | subject = old.subject; |
30 | date = old.date; | 53 | date = old.date; |
31 | mbox = old.mbox; | 54 | mbox = old.mbox; |
32 | msg_id = old.msg_id; | 55 | msg_id = old.msg_id; |
33 | msg_size = old.msg_size; | 56 | msg_size = old.msg_size; |
34 | msg_number = old.msg_number; | 57 | msg_number = old.msg_number; |
35 | from = old.from; | 58 | from = old.from; |
36 | msg_flags = old.msg_flags; | 59 | msg_flags = old.msg_flags; |
37 | to = old.to; | 60 | to = old.to; |
38 | cc = old.cc; | 61 | cc = old.cc; |
39 | bcc = old.bcc; | 62 | bcc = old.bcc; |
40 | wrapper = old.wrapper; | 63 | wrapper = old.wrapper; |
41 | in_reply_to = old.in_reply_to; | 64 | in_reply_to = old.in_reply_to; |
42 | references = old.references; | 65 | references = old.references; |
43 | replyto = old.replyto; | 66 | replyto = old.replyto; |
44 | } | 67 | } |
45 | 68 | ||
46 | void RecMail::init() | 69 | void RecMail::init() |
47 | { | 70 | { |
48 | to.clear(); | 71 | to.clear(); |
49 | cc.clear(); | 72 | cc.clear(); |
50 | bcc.clear(); | 73 | bcc.clear(); |
51 | in_reply_to.clear(); | 74 | in_reply_to.clear(); |
52 | references.clear(); | 75 | references.clear(); |
53 | wrapper = 0; | 76 | wrapper = 0; |
54 | } | 77 | } |
55 | 78 | ||
56 | void RecMail::setWrapper(AbstractMail*awrapper) | 79 | void RecMail::setWrapper(AbstractMail*awrapper) |
57 | { | 80 | { |
58 | wrapper = awrapper; | 81 | wrapper = awrapper; |
59 | } | 82 | } |
60 | 83 | ||
61 | AbstractMail* RecMail::Wrapper() | 84 | AbstractMail* RecMail::Wrapper() |
62 | { | 85 | { |
63 | return wrapper; | 86 | return wrapper; |
64 | } | 87 | } |
65 | 88 | ||
66 | void RecMail::setTo(const QStringList&list) | 89 | void RecMail::setTo(const QStringList&list) |
67 | { | 90 | { |
68 | to = list; | 91 | to = list; |
69 | } | 92 | } |
70 | 93 | ||
71 | const QStringList&RecMail::To()const | 94 | const QStringList&RecMail::To()const |
72 | { | 95 | { |
73 | return to; | 96 | return to; |
74 | } | 97 | } |
diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h index c317880..020278d 100644 --- a/kmicromail/libmailwrapper/mailtypes.h +++ b/kmicromail/libmailwrapper/mailtypes.h | |||
@@ -1,123 +1,126 @@ | |||
1 | #ifndef __MAIL_TYPES_H | 1 | #ifndef __MAIL_TYPES_H |
2 | #define __MAIL_TYPES_H | 2 | #define __MAIL_TYPES_H |
3 | 3 | ||
4 | #define FLAG_ANSWERED 0 | 4 | #define FLAG_ANSWERED 0 |
5 | #define FLAG_FLAGGED 1 | 5 | #define FLAG_FLAGGED 1 |
6 | #define FLAG_DELETED 2 | 6 | #define FLAG_DELETED 2 |
7 | #define FLAG_SEEN 3 | 7 | #define FLAG_SEEN 3 |
8 | #define FLAG_DRAFT 4 | 8 | #define FLAG_DRAFT 4 |
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <opie2/osmartpointer.h> | 11 | #include <opie2/osmartpointer.h> |
12 | 12 | ||
13 | #include <qbitarray.h> | 13 | #include <qbitarray.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qstringlist.h> | 15 | #include <qstringlist.h> |
16 | #include <qmap.h> | 16 | #include <qmap.h> |
17 | #include <qvaluelist.h> | 17 | #include <qvaluelist.h> |
18 | 18 | ||
19 | class AbstractMail; | 19 | class AbstractMail; |
20 | /* a class to describe mails in a mailbox */ | 20 | /* a class to describe mails in a mailbox */ |
21 | /* Attention! | 21 | /* Attention! |
22 | From programmers point of view it would make sense to | 22 | From programmers point of view it would make sense to |
23 | store the mail body into this class, too. | 23 | store the mail body into this class, too. |
24 | But: not from the point of view of the device. | 24 | But: not from the point of view of the device. |
25 | Mailbodies can be real large. So we request them when | 25 | Mailbodies can be real large. So we request them when |
26 | needed from the mail-wrapper class direct from the server itself | 26 | needed from the mail-wrapper class direct from the server itself |
27 | (imap) or from a file-based cache (pop3?) | 27 | (imap) or from a file-based cache (pop3?) |
28 | So there is no interface "const QString&body()" but you should | 28 | So there is no interface "const QString&body()" but you should |
29 | make a request to the mailwrapper with this class as parameter to | 29 | make a request to the mailwrapper with this class as parameter to |
30 | get the body. Same words for the attachments. | 30 | get the body. Same words for the attachments. |
31 | */ | 31 | */ |
32 | class RecMail:public Opie::Core::ORefCount | 32 | class RecMail:public Opie::Core::ORefCount |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | RecMail(); | 35 | RecMail(); |
36 | RecMail(const RecMail&old); | 36 | RecMail(const RecMail&old); |
37 | virtual ~RecMail(); | 37 | virtual ~RecMail(); |
38 | bool isEqual( RecMail* r1 ); | ||
38 | 39 | ||
39 | const unsigned int getNumber()const{return msg_number;} | 40 | const unsigned int getNumber()const{return msg_number;} |
40 | void setNumber(unsigned int number){msg_number=number;} | 41 | void setNumber(unsigned int number){msg_number=number;} |
41 | const QString&getDate()const{ return date; } | 42 | const QString&getDate()const{ return date; } |
42 | void setDate( const QString&a ) { date = a; } | 43 | void setDate( const QString&a ) { date = a; } |
44 | const QString&getIsoDate()const{ return isodate; } | ||
45 | void setIsoDate( const QString&a ) { isodate = a; } | ||
43 | const QString&getFrom()const{ return from; } | 46 | const QString&getFrom()const{ return from; } |
44 | void setFrom( const QString&a ) { from = a; } | 47 | void setFrom( const QString&a ) { from = a; } |
45 | const QString&getSubject()const { return subject; } | 48 | const QString&getSubject()const { return subject; } |
46 | void setSubject( const QString&s ) { subject = s; } | 49 | void setSubject( const QString&s ) { subject = s; } |
47 | const QString&getMbox()const{return mbox;} | 50 | const QString&getMbox()const{return mbox;} |
48 | void setMbox(const QString&box){mbox = box;} | 51 | void setMbox(const QString&box){mbox = box;} |
49 | void setMsgid(const QString&id){msg_id=id;} | 52 | void setMsgid(const QString&id){msg_id=id;} |
50 | const QString&Msgid()const{return msg_id;} | 53 | const QString&Msgid()const{return msg_id;} |
51 | void setReplyto(const QString&reply){replyto=reply;} | 54 | void setReplyto(const QString&reply){replyto=reply;} |
52 | const QString&Replyto()const{return replyto;} | 55 | const QString&Replyto()const{return replyto;} |
53 | void setMsgsize(unsigned int size){msg_size = size;} | 56 | void setMsgsize(unsigned int size){msg_size = size;} |
54 | const unsigned int Msgsize()const{return msg_size;} | 57 | const unsigned int Msgsize()const{return msg_size;} |
55 | 58 | ||
56 | 59 | ||
57 | void setTo(const QStringList&list); | 60 | void setTo(const QStringList&list); |
58 | const QStringList&To()const; | 61 | const QStringList&To()const; |
59 | void setCC(const QStringList&list); | 62 | void setCC(const QStringList&list); |
60 | const QStringList&CC()const; | 63 | const QStringList&CC()const; |
61 | void setBcc(const QStringList&list); | 64 | void setBcc(const QStringList&list); |
62 | const QStringList&Bcc()const; | 65 | const QStringList&Bcc()const; |
63 | void setInreply(const QStringList&list); | 66 | void setInreply(const QStringList&list); |
64 | const QStringList&Inreply()const; | 67 | const QStringList&Inreply()const; |
65 | void setReferences(const QStringList&list); | 68 | void setReferences(const QStringList&list); |
66 | const QStringList&References()const; | 69 | const QStringList&References()const; |
67 | 70 | ||
68 | const QBitArray&getFlags()const{return msg_flags;} | 71 | const QBitArray&getFlags()const{return msg_flags;} |
69 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 72 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
70 | 73 | ||
71 | void setWrapper(AbstractMail*wrapper); | 74 | void setWrapper(AbstractMail*wrapper); |
72 | AbstractMail* Wrapper(); | 75 | AbstractMail* Wrapper(); |
73 | 76 | ||
74 | protected: | 77 | protected: |
75 | QString subject,date,from,mbox,msg_id,replyto; | 78 | QString subject,date,isodate,from,mbox,msg_id,replyto; |
76 | unsigned int msg_number,msg_size; | 79 | unsigned int msg_number,msg_size; |
77 | QBitArray msg_flags; | 80 | QBitArray msg_flags; |
78 | QStringList to,cc,bcc,in_reply_to,references; | 81 | QStringList to,cc,bcc,in_reply_to,references; |
79 | AbstractMail*wrapper; | 82 | AbstractMail*wrapper; |
80 | void init(); | 83 | void init(); |
81 | void copy_old(const RecMail&old); | 84 | void copy_old(const RecMail&old); |
82 | }; | 85 | }; |
83 | 86 | ||
84 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; | 87 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; |
85 | typedef QMap<QString,QString> part_plist_t; | 88 | typedef QMap<QString,QString> part_plist_t; |
86 | 89 | ||
87 | class RecPart:public Opie::Core::ORefCount | 90 | class RecPart:public Opie::Core::ORefCount |
88 | { | 91 | { |
89 | protected: | 92 | protected: |
90 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 93 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
91 | unsigned int m_lines,m_size; | 94 | unsigned int m_lines,m_size; |
92 | part_plist_t m_Parameters; | 95 | part_plist_t m_Parameters; |
93 | /* describes the position in the mail */ | 96 | /* describes the position in the mail */ |
94 | QValueList<int> m_poslist; | 97 | QValueList<int> m_poslist; |
95 | 98 | ||
96 | public: | 99 | public: |
97 | RecPart(); | 100 | RecPart(); |
98 | RecPart(const RecPart&); | 101 | RecPart(const RecPart&); |
99 | virtual ~RecPart(); | 102 | virtual ~RecPart(); |
100 | 103 | ||
101 | const QString&Type()const; | 104 | const QString&Type()const; |
102 | void setType(const QString&type); | 105 | void setType(const QString&type); |
103 | const QString&Subtype()const; | 106 | const QString&Subtype()const; |
104 | void setSubtype(const QString&subtype); | 107 | void setSubtype(const QString&subtype); |
105 | const QString&Identifier()const; | 108 | const QString&Identifier()const; |
106 | void setIdentifier(const QString&identifier); | 109 | void setIdentifier(const QString&identifier); |
107 | const QString&Encoding()const; | 110 | const QString&Encoding()const; |
108 | void setEncoding(const QString&encoding); | 111 | void setEncoding(const QString&encoding); |
109 | const QString&Description()const; | 112 | const QString&Description()const; |
110 | void setDescription(const QString&desc); | 113 | void setDescription(const QString&desc); |
111 | void setLines(unsigned int lines); | 114 | void setLines(unsigned int lines); |
112 | const unsigned int Lines()const; | 115 | const unsigned int Lines()const; |
113 | void setSize(unsigned int size); | 116 | void setSize(unsigned int size); |
114 | const unsigned int Size()const; | 117 | const unsigned int Size()const; |
115 | 118 | ||
116 | 119 | ||
117 | void setParameters(const part_plist_t&list); | 120 | void setParameters(const part_plist_t&list); |
118 | const part_plist_t&Parameters()const; | 121 | const part_plist_t&Parameters()const; |
119 | void addParameter(const QString&key,const QString&value); | 122 | void addParameter(const QString&key,const QString&value); |
120 | const QString searchParamter(const QString&key)const; | 123 | const QString searchParamter(const QString&key)const; |
121 | void setPositionlist(const QValueList<int>&poslist); | 124 | void setPositionlist(const QValueList<int>&poslist); |
122 | const QValueList<int>& Positionlist()const; | 125 | const QValueList<int>& Positionlist()const; |
123 | }; | 126 | }; |
diff --git a/kmicromail/libmailwrapper/mboxwrapper.h b/kmicromail/libmailwrapper/mboxwrapper.h index 9731b85..d03940f 100644 --- a/kmicromail/libmailwrapper/mboxwrapper.h +++ b/kmicromail/libmailwrapper/mboxwrapper.h | |||
@@ -1,46 +1,47 @@ | |||
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 encodedString; | 7 | class encodedString; |
8 | struct mailmbox_folder; | 8 | struct mailmbox_folder; |
9 | 9 | ||
10 | class MBOXwrapper : public Genericwrapper | 10 | class MBOXwrapper : public Genericwrapper |
11 | { | 11 | { |
12 | Q_OBJECT | 12 | Q_OBJECT |
13 | 13 | ||
14 | public: | 14 | public: |
15 | MBOXwrapper(const QString & dir,const QString&name); | 15 | MBOXwrapper(const QString & dir,const QString&name); |
16 | virtual ~MBOXwrapper(); | 16 | virtual ~MBOXwrapper(); |
17 | 17 | ||
18 | virtual void listMessages(const QString & mailbox, QValueList<RecMailP>&target ); | 18 | virtual void listMessages(const QString & mailbox, QValueList<RecMailP>&target ); |
19 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 19 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
21 | 21 | ||
22 | virtual void deleteMail(const RecMailP&mail); | 22 | virtual void deleteMail(const RecMailP&mail); |
23 | virtual void answeredMail(const RecMailP&mail); | 23 | virtual void answeredMail(const RecMailP&mail); |
24 | 24 | ||
25 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, | 25 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, |
26 | const QString&d="",bool s=false); | 26 | const QString&d="",bool s=false); |
27 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); | 27 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); |
28 | 28 | ||
29 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 29 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
30 | 30 | ||
31 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 31 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
32 | static void mbox_progress( size_t current, size_t maximum ); | 32 | static void mbox_progress( size_t current, size_t maximum ); |
33 | 33 | ||
34 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 34 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
35 | virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target); | 35 | virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target); |
36 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 36 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
37 | virtual MAILLIB::ATYPE getType()const; | 37 | virtual MAILLIB::ATYPE getType()const; |
38 | virtual const QString&getName()const; | 38 | virtual const QString&getName()const; |
39 | virtual Account* getAccount() { return 0; }; | ||
39 | 40 | ||
40 | protected: | 41 | protected: |
41 | static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target); | 42 | static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target); |
42 | QString MBOXPath; | 43 | QString MBOXPath; |
43 | QString MBOXName; | 44 | QString MBOXName; |
44 | }; | 45 | }; |
45 | 46 | ||
46 | #endif | 47 | #endif |
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp index cbc52d9..962dac0 100644 --- a/kmicromail/libmailwrapper/mhwrapper.cpp +++ b/kmicromail/libmailwrapper/mhwrapper.cpp | |||
@@ -20,96 +20,97 @@ MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | |||
20 | } | 20 | } |
21 | //odebug << MHPath << oendl; | 21 | //odebug << MHPath << oendl; |
22 | QDir dir(MHPath); | 22 | QDir dir(MHPath); |
23 | if (!dir.exists()) { | 23 | if (!dir.exists()) { |
24 | dir.mkdir(MHPath); | 24 | dir.mkdir(MHPath); |
25 | } | 25 | } |
26 | init_storage(); | 26 | init_storage(); |
27 | } | 27 | } |
28 | } | 28 | } |
29 | 29 | ||
30 | void MHwrapper::init_storage() | 30 | void MHwrapper::init_storage() |
31 | { | 31 | { |
32 | int r; | 32 | int r; |
33 | QString pre = MHPath; | 33 | QString pre = MHPath; |
34 | if (!m_storage) { | 34 | if (!m_storage) { |
35 | m_storage = mailstorage_new(NULL); | 35 | m_storage = mailstorage_new(NULL); |
36 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 36 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
37 | if (r != MAIL_NO_ERROR) { | 37 | if (r != MAIL_NO_ERROR) { |
38 | qDebug(" error init storage "); | 38 | qDebug(" error init storage "); |
39 | mailstorage_free(m_storage); | 39 | mailstorage_free(m_storage); |
40 | m_storage = 0; | 40 | m_storage = 0; |
41 | return; | 41 | return; |
42 | } | 42 | } |
43 | } | 43 | } |
44 | r = mailstorage_connect(m_storage); | 44 | r = mailstorage_connect(m_storage); |
45 | if (r!=MAIL_NO_ERROR) { | 45 | if (r!=MAIL_NO_ERROR) { |
46 | qDebug("error connecting storage "); | 46 | qDebug("error connecting storage "); |
47 | mailstorage_free(m_storage); | 47 | mailstorage_free(m_storage); |
48 | m_storage = 0; | 48 | m_storage = 0; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void MHwrapper::clean_storage() | 52 | void MHwrapper::clean_storage() |
53 | { | 53 | { |
54 | if (m_storage) { | 54 | if (m_storage) { |
55 | mailstorage_disconnect(m_storage); | 55 | mailstorage_disconnect(m_storage); |
56 | mailstorage_free(m_storage); | 56 | mailstorage_free(m_storage); |
57 | m_storage = 0; | 57 | m_storage = 0; |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | MHwrapper::~MHwrapper() | 61 | MHwrapper::~MHwrapper() |
62 | { | 62 | { |
63 | clean_storage(); | 63 | clean_storage(); |
64 | } | 64 | } |
65 | 65 | ||
66 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) | 66 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) |
67 | { | 67 | { |
68 | qDebug("MHwrapper::listMessages "); | ||
68 | init_storage(); | 69 | init_storage(); |
69 | if (!m_storage) { | 70 | if (!m_storage) { |
70 | return; | 71 | return; |
71 | } | 72 | } |
72 | QString f = buildPath(mailbox); | 73 | QString f = buildPath(mailbox); |
73 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 74 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
74 | if (r!=MAIL_NO_ERROR) { | 75 | if (r!=MAIL_NO_ERROR) { |
75 | qDebug("listMessages: error selecting folder! "); | 76 | qDebug("listMessages: error selecting folder! "); |
76 | return; | 77 | return; |
77 | } | 78 | } |
78 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); | 79 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); |
79 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 80 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
80 | } | 81 | } |
81 | 82 | ||
82 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 83 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
83 | { | 84 | { |
84 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 85 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
85 | /* this is needed! */ | 86 | /* this is needed! */ |
86 | if (m_storage) mailstorage_disconnect(m_storage); | 87 | if (m_storage) mailstorage_disconnect(m_storage); |
87 | init_storage(); | 88 | init_storage(); |
88 | if (!m_storage) { | 89 | if (!m_storage) { |
89 | return folders; | 90 | return folders; |
90 | } | 91 | } |
91 | mail_list*flist = 0; | 92 | mail_list*flist = 0; |
92 | clistcell*current=0; | 93 | clistcell*current=0; |
93 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 94 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
94 | if (r != MAIL_NO_ERROR || !flist) { | 95 | if (r != MAIL_NO_ERROR || !flist) { |
95 | qDebug("error getting folder list "); | 96 | qDebug("error getting folder list "); |
96 | return folders; | 97 | return folders; |
97 | } | 98 | } |
98 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 99 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
99 | QString t = (char*)current->data; | 100 | QString t = (char*)current->data; |
100 | t.replace(0,MHPath.length(),""); | 101 | t.replace(0,MHPath.length(),""); |
101 | folders->append(new MHFolder(t,MHPath)); | 102 | folders->append(new MHFolder(t,MHPath)); |
102 | } | 103 | } |
103 | mail_list_free(flist); | 104 | mail_list_free(flist); |
104 | return folders; | 105 | return folders; |
105 | } | 106 | } |
106 | 107 | ||
107 | void MHwrapper::deleteMail(const RecMailP&mail) | 108 | void MHwrapper::deleteMail(const RecMailP&mail) |
108 | { | 109 | { |
109 | init_storage(); | 110 | init_storage(); |
110 | if (!m_storage) { | 111 | if (!m_storage) { |
111 | return; | 112 | return; |
112 | } | 113 | } |
113 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 114 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
114 | if (r!=MAIL_NO_ERROR) { | 115 | if (r!=MAIL_NO_ERROR) { |
115 | qDebug("error selecting folder! "); | 116 | qDebug("error selecting folder! "); |
diff --git a/kmicromail/libmailwrapper/mhwrapper.h b/kmicromail/libmailwrapper/mhwrapper.h index 550824d..d1b7d1f 100644 --- a/kmicromail/libmailwrapper/mhwrapper.h +++ b/kmicromail/libmailwrapper/mhwrapper.h | |||
@@ -1,61 +1,62 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __MH_WRAPPER_H | 2 | #ifndef __MH_WRAPPER_H |
3 | #define __MH_WRAPPER_H | 3 | #define __MH_WRAPPER_H |
4 | 4 | ||
5 | #include "maildefines.h" | 5 | #include "maildefines.h" |
6 | 6 | ||
7 | #include "genericwrapper.h" | 7 | #include "genericwrapper.h" |
8 | #include <qstring.h> | 8 | #include <qstring.h> |
9 | 9 | ||
10 | class encodedString; | 10 | class encodedString; |
11 | struct mailmbox_folder; | 11 | struct mailmbox_folder; |
12 | namespace Opie {namespace Core {class OProcess;}} | 12 | namespace Opie {namespace Core {class OProcess;}} |
13 | 13 | ||
14 | class MHwrapper : public Genericwrapper | 14 | class MHwrapper : public Genericwrapper |
15 | { | 15 | { |
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | public: | 17 | public: |
18 | MHwrapper(const QString & dir,const QString&name); | 18 | MHwrapper(const QString & dir,const QString&name); |
19 | virtual ~MHwrapper(); | 19 | virtual ~MHwrapper(); |
20 | 20 | ||
21 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); | 21 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); |
22 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 22 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
24 | 24 | ||
25 | virtual void deleteMail(const RecMailP&mail); | 25 | virtual void deleteMail(const RecMailP&mail); |
26 | virtual void answeredMail(const RecMailP&mail); | 26 | virtual void answeredMail(const RecMailP&mail); |
27 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 27 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
28 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 28 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
29 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 29 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
30 | 30 | ||
31 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, | 31 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, |
32 | const QString&d="",bool s=false); | 32 | const QString&d="",bool s=false); |
33 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); | 33 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); |
34 | 34 | ||
35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
36 | 36 | ||
37 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 37 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
38 | static void mbox_progress( size_t current, size_t maximum ); | 38 | static void mbox_progress( size_t current, size_t maximum ); |
39 | 39 | ||
40 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 40 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
41 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); | 41 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); |
42 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 42 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
43 | virtual MAILLIB::ATYPE getType()const; | 43 | virtual MAILLIB::ATYPE getType()const; |
44 | virtual const QString&getName()const; | 44 | virtual const QString&getName()const; |
45 | virtual Account* getAccount() { return 0; }; | ||
45 | 46 | ||
46 | public slots: | 47 | public slots: |
47 | /* for deleting maildirs we are using a system call */ | 48 | /* for deleting maildirs we are using a system call */ |
48 | virtual void oprocessStderr(Opie::Core::OProcess*, char *buffer, int ); | 49 | virtual void oprocessStderr(Opie::Core::OProcess*, char *buffer, int ); |
49 | virtual void processEnded(Opie::Core::OProcess *); | 50 | virtual void processEnded(Opie::Core::OProcess *); |
50 | protected: | 51 | protected: |
51 | QString buildPath(const QString&p); | 52 | QString buildPath(const QString&p); |
52 | QString MHPath; | 53 | QString MHPath; |
53 | QString MHName; | 54 | QString MHName; |
54 | 55 | ||
55 | void init_storage(); | 56 | void init_storage(); |
56 | void clean_storage(); | 57 | void clean_storage(); |
57 | 58 | ||
58 | bool removeMboxfailed; | 59 | bool removeMboxfailed; |
59 | }; | 60 | }; |
60 | 61 | ||
61 | #endif | 62 | #endif |
diff --git a/kmicromail/libmailwrapper/nntpwrapper.h b/kmicromail/libmailwrapper/nntpwrapper.h index 5d4e5ce..8c54f12 100644 --- a/kmicromail/libmailwrapper/nntpwrapper.h +++ b/kmicromail/libmailwrapper/nntpwrapper.h | |||
@@ -1,49 +1,50 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __NNTPWRAPPER | 2 | #ifndef __NNTPWRAPPER |
3 | #define __NNTPWRAPPER | 3 | #define __NNTPWRAPPER |
4 | 4 | ||
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | #include "genericwrapper.h" | 6 | #include "genericwrapper.h" |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
9 | 9 | ||
10 | class encodedString; | 10 | class encodedString; |
11 | struct mailstorage; | 11 | struct mailstorage; |
12 | struct mailfolder; | 12 | struct mailfolder; |
13 | 13 | ||
14 | class NNTPwrapper : public Genericwrapper | 14 | class NNTPwrapper : public Genericwrapper |
15 | { | 15 | { |
16 | 16 | ||
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | 18 | ||
19 | public: | 19 | public: |
20 | NNTPwrapper( NNTPaccount *a ); | 20 | NNTPwrapper( NNTPaccount *a ); |
21 | virtual ~NNTPwrapper(); | 21 | virtual ~NNTPwrapper(); |
22 | 22 | ||
23 | /* mailbox will be ignored */ | 23 | /* mailbox will be ignored */ |
24 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); | 24 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); |
25 | /* should only get the subscribed one */ | 25 | /* should only get the subscribed one */ |
26 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 26 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
27 | /* mailbox will be ignored */ | 27 | /* mailbox will be ignored */ |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
29 | QStringList listAllNewsgroups(const QString&mask = QString::null); | 29 | QStringList listAllNewsgroups(const QString&mask = QString::null); |
30 | virtual void deleteMail(const RecMailP&mail); | 30 | virtual void deleteMail(const RecMailP&mail); |
31 | virtual void answeredMail(const RecMailP&mail); | 31 | virtual void answeredMail(const RecMailP&mail); |
32 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 32 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
33 | 33 | ||
34 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 34 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
35 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 35 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
36 | virtual void logout(); | 36 | virtual void logout(); |
37 | virtual MAILLIB::ATYPE getType()const; | 37 | virtual MAILLIB::ATYPE getType()const; |
38 | virtual const QString&getName()const; | 38 | virtual const QString&getName()const; |
39 | static void nntp_progress( size_t current, size_t maximum ); | 39 | static void nntp_progress( size_t current, size_t maximum ); |
40 | virtual Account* getAccount() { return account; }; | ||
40 | 41 | ||
41 | protected: | 42 | protected: |
42 | void login(); | 43 | void login(); |
43 | NNTPaccount *account; | 44 | NNTPaccount *account; |
44 | mailstorage* m_nntp; | 45 | mailstorage* m_nntp; |
45 | 46 | ||
46 | 47 | ||
47 | }; | 48 | }; |
48 | 49 | ||
49 | #endif | 50 | #endif |
diff --git a/kmicromail/libmailwrapper/pop3wrapper.h b/kmicromail/libmailwrapper/pop3wrapper.h index 7c70942..ebc2fc7 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.h +++ b/kmicromail/libmailwrapper/pop3wrapper.h | |||
@@ -1,44 +1,44 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __POP3WRAPPER | 2 | #ifndef __POP3WRAPPER |
3 | #define __POP3WRAPPER | 3 | #define __POP3WRAPPER |
4 | 4 | ||
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | #include "genericwrapper.h" | 6 | #include "genericwrapper.h" |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | 8 | ||
9 | class encodedString; | 9 | class encodedString; |
10 | struct mailstorage; | 10 | struct mailstorage; |
11 | struct mailfolder; | 11 | struct mailfolder; |
12 | 12 | ||
13 | class POP3wrapper : public Genericwrapper | 13 | class POP3wrapper : public Genericwrapper |
14 | { | 14 | { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | 16 | ||
17 | public: | 17 | public: |
18 | POP3wrapper( POP3account *a ); | 18 | POP3wrapper( POP3account *a ); |
19 | virtual ~POP3wrapper(); | 19 | virtual ~POP3wrapper(); |
20 | /* mailbox will be ignored */ | 20 | /* mailbox will be ignored */ |
21 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); | 21 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); |
22 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 22 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
23 | /* mailbox will be ignored */ | 23 | /* mailbox will be ignored */ |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
25 | 25 | ||
26 | virtual void deleteMail(const RecMailP&mail); | 26 | virtual void deleteMail(const RecMailP&mail); |
27 | virtual void deleteMailList(const QValueList<RecMailP>&target); | 27 | virtual void deleteMailList(const QValueList<RecMailP>&target); |
28 | virtual void answeredMail(const RecMailP&mail); | 28 | virtual void answeredMail(const RecMailP&mail); |
29 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 29 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
30 | 30 | ||
31 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 31 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
32 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 32 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
33 | virtual void logout(); | 33 | virtual void logout(); |
34 | virtual MAILLIB::ATYPE getType()const; | 34 | virtual MAILLIB::ATYPE getType()const; |
35 | virtual const QString&getName()const; | 35 | virtual const QString&getName()const; |
36 | static void pop3_progress( size_t current, size_t maximum ); | 36 | static void pop3_progress( size_t current, size_t maximum ); |
37 | 37 | virtual Account* getAccount() { return account; }; | |
38 | protected: | 38 | protected: |
39 | void login(); | 39 | void login(); |
40 | POP3account *account; | 40 | POP3account *account; |
41 | mailstorage*m_pop3; | 41 | mailstorage*m_pop3; |
42 | }; | 42 | }; |
43 | 43 | ||
44 | #endif | 44 | #endif |
diff --git a/kmicromail/libmailwrapper/smtpwrapper.h b/kmicromail/libmailwrapper/smtpwrapper.h index 105cbf5..ec42b56 100644 --- a/kmicromail/libmailwrapper/smtpwrapper.h +++ b/kmicromail/libmailwrapper/smtpwrapper.h | |||
@@ -1,63 +1,64 @@ | |||
1 | // -*- Mode: C++; -*- | 1 | // -*- Mode: C++; -*- |
2 | #ifndef SMTPwrapper_H | 2 | #ifndef SMTPwrapper_H |
3 | #define SMTPwrapper_H | 3 | #define SMTPwrapper_H |
4 | 4 | ||
5 | #include <qpe/applnk.h> | 5 | #include <qpe/applnk.h> |
6 | 6 | ||
7 | #include <qbitarray.h> | 7 | #include <qbitarray.h> |
8 | #include <qdatetime.h> | 8 | #include <qdatetime.h> |
9 | #include <libetpan/clist.h> | 9 | #include <libetpan/clist.h> |
10 | 10 | ||
11 | #include "settings.h" | 11 | #include "settings.h" |
12 | #include "generatemail.h" | 12 | #include "generatemail.h" |
13 | 13 | ||
14 | #include <opie2/osmartpointer.h> | 14 | #include <opie2/osmartpointer.h> |
15 | 15 | ||
16 | class SMTPaccount; | 16 | class SMTPaccount; |
17 | class AbstractMail; | 17 | class AbstractMail; |
18 | 18 | ||
19 | class SMTPwrapper : public Generatemail | 19 | class SMTPwrapper : public Generatemail |
20 | { | 20 | { |
21 | Q_OBJECT | 21 | Q_OBJECT |
22 | 22 | ||
23 | public: | 23 | public: |
24 | SMTPwrapper(SMTPaccount * aSmtp); | 24 | SMTPwrapper(SMTPaccount * aSmtp); |
25 | virtual ~SMTPwrapper(); | 25 | virtual ~SMTPwrapper(); |
26 | bool sendMail(const Opie::Core::OSmartPointer<Mail>& mail,bool later=false ); | 26 | bool sendMail(const Opie::Core::OSmartPointer<Mail>& mail,bool later=false ); |
27 | bool flushOutbox(); | 27 | bool flushOutbox(); |
28 | 28 | ||
29 | static progressMailSend*sendProgress; | 29 | static progressMailSend*sendProgress; |
30 | virtual Account* getAccount() { return m_SmtpAccount; }; | ||
30 | 31 | ||
31 | signals: | 32 | signals: |
32 | void queuedMails( int ); | 33 | void queuedMails( int ); |
33 | 34 | ||
34 | protected: | 35 | protected: |
35 | mailsmtp *m_smtp; | 36 | mailsmtp *m_smtp; |
36 | SMTPaccount * m_SmtpAccount; | 37 | SMTPaccount * m_SmtpAccount; |
37 | 38 | ||
38 | void connect_server(); | 39 | void connect_server(); |
39 | void disc_server(); | 40 | void disc_server(); |
40 | int start_smtp_tls(); | 41 | int start_smtp_tls(); |
41 | 42 | ||
42 | 43 | ||
43 | bool smtpSend( mailmime *mail,bool later); | 44 | bool smtpSend( mailmime *mail,bool later); |
44 | 45 | ||
45 | static void storeMail(const char*mail, size_t length, const QString&box); | 46 | static void storeMail(const char*mail, size_t length, const QString&box); |
46 | static QString mailsmtpError( int err ); | 47 | static QString mailsmtpError( int err ); |
47 | static void progress( size_t current, size_t maximum ); | 48 | static void progress( size_t current, size_t maximum ); |
48 | 49 | ||
49 | int smtpSend(char*from,clist*rcpts,const char*data,size_t size); | 50 | int smtpSend(char*from,clist*rcpts,const char*data,size_t size); |
50 | 51 | ||
51 | void storeMail(mailmime*mail, const QString&box); | 52 | void storeMail(mailmime*mail, const QString&box); |
52 | 53 | ||
53 | int sendQueuedMail(AbstractMail*wrap,const Opie::Core::OSmartPointer<RecMail>&which); | 54 | int sendQueuedMail(AbstractMail*wrap,const Opie::Core::OSmartPointer<RecMail>&which); |
54 | void storeFailedMail(const char*data,unsigned int size, const char*failuremessage); | 55 | void storeFailedMail(const char*data,unsigned int size, const char*failuremessage); |
55 | 56 | ||
56 | int m_queuedMail; | 57 | int m_queuedMail; |
57 | 58 | ||
58 | protected slots: | 59 | protected slots: |
59 | void emitQCop( int queued ); | 60 | void emitQCop( int queued ); |
60 | 61 | ||
61 | }; | 62 | }; |
62 | 63 | ||
63 | #endif | 64 | #endif |
diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp index b92b0cf..484a635 100644 --- a/kmicromail/mailistviewitem.cpp +++ b/kmicromail/mailistviewitem.cpp | |||
@@ -8,136 +8,139 @@ | |||
8 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 8 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
9 | :QListViewItem(parent,item),mail_data() | 9 | :QListViewItem(parent,item),mail_data() |
10 | { | 10 | { |
11 | } | 11 | } |
12 | 12 | ||
13 | void MailListViewItem::showEntry() | 13 | void MailListViewItem::showEntry() |
14 | { | 14 | { |
15 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { | 15 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { |
16 | setPixmap( 0, SmallIcon ( "kmmsgreplied") ); | 16 | setPixmap( 0, SmallIcon ( "kmmsgreplied") ); |
17 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { | 17 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { |
18 | /* I think it looks nicer if there are not such a log of icons but only on mails | 18 | /* I think it looks nicer if there are not such a log of icons but only on mails |
19 | replied or new - Alwin*/ | 19 | replied or new - Alwin*/ |
20 | //setPixmap( 0,SmallIcon ("kmmsgunseen") ); | 20 | //setPixmap( 0,SmallIcon ("kmmsgunseen") ); |
21 | } else { | 21 | } else { |
22 | setPixmap( 0,SmallIcon ( "kmmsgnew") ); | 22 | setPixmap( 0,SmallIcon ( "kmmsgnew") ); |
23 | } | 23 | } |
24 | double s = mail_data->Msgsize(); | 24 | double s = mail_data->Msgsize(); |
25 | int w = 0; | 25 | int w = 0; |
26 | s/=1024; | 26 | s/=1024; |
27 | if (s>999.0) { | 27 | if (s>999.0) { |
28 | s/=1024.0; | 28 | s/=1024.0; |
29 | ++w; | 29 | ++w; |
30 | } | 30 | } |
31 | QString fsort; | 31 | QString fsort; |
32 | fsort.sprintf( "%.2f", s ); | 32 | fsort.sprintf( "%.2f", s ); |
33 | QString fsize = QString::number( s, 'f', 2 ); | 33 | QString fsize = QString::number( s, 'f', 2 ); |
34 | // 1.23 | 34 | // 1.23 |
35 | // 11.23 | 35 | // 11.23 |
36 | // 111.23 | 36 | // 111.23 |
37 | // 999.23 maxlen | 37 | // 999.23 maxlen |
38 | switch(fsize.length() ) { | 38 | switch(fsize.length() ) { |
39 | case 4: | 39 | case 4: |
40 | fsort = "00" + fsize ; | 40 | fsort = "00" + fsize ; |
41 | break; | 41 | break; |
42 | case 5: | 42 | case 5: |
43 | fsort = "0" + fsize ; | 43 | fsort = "0" + fsize ; |
44 | break; | 44 | break; |
45 | default: | 45 | default: |
46 | fsort = fsize ; | 46 | fsort = fsize ; |
47 | break; | 47 | break; |
48 | 48 | ||
49 | } | 49 | } |
50 | if ( w == 0 ) { | 50 | if ( w == 0 ) { |
51 | setText(3, fsize + "kB" ); | 51 | setText(3, fsize + "kB" ); |
52 | mKeyMap.insert(3, "k" + fsort); | 52 | mKeyMap.insert(3, "k" + fsort); |
53 | //setText(3, "kB" + fsort ); // test only | 53 | //setText(3, "kB" + fsort ); // test only |
54 | } else { | 54 | } else { |
55 | //setText(3, fsize + "MB"); | 55 | //setText(3, fsize + "MB"); |
56 | mKeyMap.insert(4, "M" +fsort ); | 56 | mKeyMap.insert(3, "M" +fsort ); |
57 | } | 57 | } |
58 | setText(1,mail_data->getSubject()); | 58 | setText(1,mail_data->getSubject()); |
59 | setText(2,mail_data->getFrom()); | 59 | setText(2,mail_data->getFrom()); |
60 | 60 | #if 0 | |
61 | QString date = mail_data->getDate(); | 61 | QString date = mail_data->getDate(); |
62 | 62 | ||
63 | int kom = date.find( ",")+2; | 63 | int kom = date.find( ",")+2; |
64 | if ( kom == 1 ) | 64 | if ( kom == 1 ) |
65 | kom = 0; | 65 | kom = 0; |
66 | if ( date.mid(kom,1) == " ") | 66 | if ( date.mid(kom,1) == " ") |
67 | ++kom; | 67 | ++kom; |
68 | if ( date.mid(kom+1,1) == " " ) | 68 | if ( date.mid(kom+1,1) == " " ) |
69 | date = "0" + date.mid( kom ); | 69 | date = "0" + date.mid( kom ); |
70 | else if ( kom ) | 70 | else if ( kom ) |
71 | date = date.mid( kom ); | 71 | date = date.mid( kom ); |
72 | if ( kom || date.mid(2,1 ) == " ") { | 72 | if ( kom || date.mid(2,1 ) == " ") { |
73 | QString mon = date.mid(3,3); | 73 | QString mon = date.mid(3,3); |
74 | QString so = 00; | 74 | QString so = 00; |
75 | if ( mon == "Jan" ) | 75 | if ( mon == "Jan" ) |
76 | so = "01"; | 76 | so = "01"; |
77 | else if ( mon == "Feb" ) | 77 | else if ( mon == "Feb" ) |
78 | so = "02"; | 78 | so = "02"; |
79 | else if ( mon == "Mar" ) | 79 | else if ( mon == "Mar" ) |
80 | so = "03"; | 80 | so = "03"; |
81 | else if ( mon == "Apr" ) | 81 | else if ( mon == "Apr" ) |
82 | so = "04"; | 82 | so = "04"; |
83 | else if ( mon == "May" ) | 83 | else if ( mon == "May" ) |
84 | so = "05"; | 84 | so = "05"; |
85 | else if ( mon == "Jun" ) | 85 | else if ( mon == "Jun" ) |
86 | so = "06"; | 86 | so = "06"; |
87 | else if ( mon == "Jul" ) | 87 | else if ( mon == "Jul" ) |
88 | so = "07"; | 88 | so = "07"; |
89 | else if ( mon == "Aug" ) | 89 | else if ( mon == "Aug" ) |
90 | so = "08"; | 90 | so = "08"; |
91 | else if ( mon == "Sep" ) | 91 | else if ( mon == "Sep" ) |
92 | so = "09"; | 92 | so = "09"; |
93 | else if ( mon == "Oct" ) | 93 | else if ( mon == "Oct" ) |
94 | so = "10"; | 94 | so = "10"; |
95 | else if ( mon == "Nov" ) | 95 | else if ( mon == "Nov" ) |
96 | so = "11"; | 96 | so = "11"; |
97 | else if ( mon == "Dec" ) | 97 | else if ( mon == "Dec" ) |
98 | so = "12"; | 98 | so = "12"; |
99 | date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); | 99 | date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); |
100 | } | 100 | } |
101 | //qDebug("insert Date %s ", date.latin1()); | ||
101 | // if ( date.left(1) != "1" || date.left(1) != "2" ) | 102 | // if ( date.left(1) != "1" || date.left(1) != "2" ) |
102 | // date = date.mid(5); | 103 | // date = date.mid(5); |
103 | mKeyMap.insert(4,date); | 104 | mKeyMap.insert(4,date); |
105 | #endif | ||
106 | mKeyMap.insert(4,mail_data->getIsoDate()); | ||
104 | setText(4,mail_data->getDate()); | 107 | setText(4,mail_data->getDate()); |
105 | } | 108 | } |
106 | 109 | ||
107 | void MailListViewItem::storeData(const RecMailP&data) | 110 | void MailListViewItem::storeData(const RecMailP&data) |
108 | { | 111 | { |
109 | mail_data = data; | 112 | mail_data = data; |
110 | } | 113 | } |
111 | void MailListViewItem::setSortKey(int column,const QString &key) | 114 | void MailListViewItem::setSortKey(int column,const QString &key) |
112 | { | 115 | { |
113 | mKeyMap.insert(column,key); | 116 | mKeyMap.insert(column,key); |
114 | } | 117 | } |
115 | QString MailListViewItem::key(int column, bool) const | 118 | QString MailListViewItem::key(int column, bool) const |
116 | { | 119 | { |
117 | // to make is fast, we use here special cases | 120 | // to make is fast, we use here special cases |
118 | if ( column == 3 || column == 4 ) { | 121 | if ( column == 3 || column == 4 ) { |
119 | return *mKeyMap.find(column); | 122 | return *mKeyMap.find(column); |
120 | } | 123 | } |
121 | if ( column == 1 ) { | 124 | if ( column == 1 ) { |
122 | if ( text(1).left(4).lower() == "re: " ) | 125 | if ( text(1).left(4).lower() == "re: " ) |
123 | return text(1).mid(4); | 126 | return text(1).mid(4); |
124 | 127 | ||
125 | } | 128 | } |
126 | return text(column); | 129 | return text(column); |
127 | /* | 130 | /* |
128 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | 131 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); |
129 | if (it == mKeyMap.end()) return text(column); | 132 | if (it == mKeyMap.end()) return text(column); |
130 | else return *it; | 133 | else return *it; |
131 | */ | 134 | */ |
132 | } | 135 | } |
133 | 136 | ||
134 | const RecMailP& MailListViewItem::data()const | 137 | const RecMailP& MailListViewItem::data()const |
135 | { | 138 | { |
136 | return mail_data; | 139 | return mail_data; |
137 | } | 140 | } |
138 | 141 | ||
139 | MAILLIB::ATYPE MailListViewItem::wrapperType() | 142 | MAILLIB::ATYPE MailListViewItem::wrapperType() |
140 | { | 143 | { |
141 | if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; | 144 | if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; |
142 | return mail_data->Wrapper()->getType(); | 145 | return mail_data->Wrapper()->getType(); |
143 | } | 146 | } |