summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-11 15:41:30 (UTC)
committer zautrix <zautrix>2004-09-11 15:41:30 (UTC)
commit32f9963a39236d08718a36d5adad2a0c5c4e2602 (patch) (unidiff)
tree8856a90d505df8dc3afa0d72541f27cb68913a0d
parentd7a273f40838f56205c1377ed0bcc5457bd46ea3 (diff)
downloadkdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.zip
kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.gz
kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.bz2
Mail enhancements
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountitem.cpp22
-rw-r--r--kmicromail/accountview.cpp5
-rw-r--r--kmicromail/libmailwrapper/abstractmail.cpp67
-rw-r--r--kmicromail/libmailwrapper/abstractmail.h7
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.cpp64
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.h2
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp18
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.h1
-rw-r--r--kmicromail/libmailwrapper/mailtypes.cpp23
-rw-r--r--kmicromail/libmailwrapper/mailtypes.h5
-rw-r--r--kmicromail/libmailwrapper/mboxwrapper.h1
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.cpp1
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.h1
-rw-r--r--kmicromail/libmailwrapper/nntpwrapper.h1
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.h2
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.h1
-rw-r--r--kmicromail/mailistviewitem.cpp9
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
@@ -1,235 +1,238 @@
1 1
2#include "accountitem.h" 2#include "accountitem.h"
3#include "accountview.h" 3#include "accountview.h"
4#include "newmaildir.h" 4#include "newmaildir.h"
5#include "nntpgroupsdlg.h" 5#include "nntpgroupsdlg.h"
6#include "defines.h" 6#include "defines.h"
7 7
8#include <libmailwrapper/mailtypes.h> 8#include <libmailwrapper/mailtypes.h>
9#include <libmailwrapper/abstractmail.h> 9#include <libmailwrapper/abstractmail.h>
10#include <libmailwrapper/mailwrapper.h> 10#include <libmailwrapper/mailwrapper.h>
11/* OPIE */ 11/* OPIE */
12//#include <qpe/qpeapplication.h> 12//#include <qpe/qpeapplication.h>
13 13
14/* QT */ 14/* QT */
15#include <qpopupmenu.h> 15#include <qpopupmenu.h>
16#include <qmessagebox.h> 16#include <qmessagebox.h>
17#include <kiconloader.h> 17#include <kiconloader.h>
18 18
19using namespace Opie::Core; 19using namespace Opie::Core;
20#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} 20#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );}
21/** 21/**
22 * POP3 Account stuff 22 * POP3 Account stuff
23 */ 23 */
24POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) 24POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
25 : AccountViewItem( parent ) 25 : AccountViewItem( parent )
26{ 26{
27 account = a; 27 account = a;
28 wrapper = AbstractMail::getWrapper( account ); 28 wrapper = AbstractMail::getWrapper( account );
29 SETPIX(PIXMAP_POP3FOLDER); 29 SETPIX(PIXMAP_POP3FOLDER);
30#if 0 30#if 0
31 if (!account->getOffline()) 31 if (!account->getOffline())
32 { 32 {
33 setPixmap( 0, ); 33 setPixmap( 0, );
34 } 34 }
35 else 35 else
36 { 36 {
37 setPixmap( 0, PIXMAP_OFFLINE ); 37 setPixmap( 0, PIXMAP_OFFLINE );
38 } 38 }
39#endif 39#endif
40 setText( 0, account->getAccountName() ); 40 setText( 0, account->getAccountName() );
41 setOpen( true ); 41 setOpen( true );
42} 42}
43 43
44POP3viewItem::~POP3viewItem() 44POP3viewItem::~POP3viewItem()
45{ 45{
46 delete wrapper; 46 delete wrapper;
47} 47}
48 48
49AbstractMail *POP3viewItem::getWrapper() 49AbstractMail *POP3viewItem::getWrapper()
50{ 50{
51 return wrapper; 51 return wrapper;
52} 52}
53 53
54void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) 54void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & )
55{ 55{
56 refresh(); 56 refresh();
57} 57}
58 58
59void POP3viewItem::refresh() 59void 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
80RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) 80RECBODYP POP3viewItem::fetchBody( const RecMailP &mail )
81{ 81{
82 82
83 return wrapper->fetchBody( mail ); 83 return wrapper->fetchBody( mail );
84} 84}
85 85
86QPopupMenu * POP3viewItem::getContextMenu() 86QPopupMenu * 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
105void POP3viewItem::disconnect() 106void 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
117void POP3viewItem::setOnOffline() 118void 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
129void POP3viewItem::contextMenuSelected(int which) 130void 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
151POP3folderItem::~POP3folderItem() 154POP3folderItem::~POP3folderItem()
152{} 155{}
153 156
154POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) 157POP3folderItem::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
169void POP3folderItem::refresh(QValueList<RecMailP>&target) 172void 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
175RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) 178RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail)
176{ 179{
177 return pop3->getWrapper()->fetchBody(aMail); 180 return pop3->getWrapper()->fetchBody(aMail);
178} 181}
179 182
180QPopupMenu * POP3folderItem::getContextMenu() 183QPopupMenu * 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);
188 } 191 }
189 return m; 192 return m;
190} 193}
191 194
192void POP3folderItem::downloadMails() 195void POP3folderItem::downloadMails()
193{ 196{
194 AccountView*bl = pop3->accountView(); 197 AccountView*bl = pop3->accountView();
195 if (!bl) return; 198 if (!bl) return;
196 bl->downloadMails(folder,pop3->getWrapper()); 199 bl->downloadMails(folder,pop3->getWrapper());
197} 200}
198 201
199void POP3folderItem::contextMenuSelected(int which) 202void POP3folderItem::contextMenuSelected(int which)
200{ 203{
201 AccountView * view = (AccountView*)listView(); 204 AccountView * view = (AccountView*)listView();
202 switch (which) 205 switch (which)
203 { 206 {
204 case 0: 207 case 0:
205 /* must be 'cause pop3 lists are cached */ 208 /* must be 'cause pop3 lists are cached */
206 pop3->getWrapper()->logout(); 209 pop3->getWrapper()->logout();
207 view->refreshCurrent(); 210 view->refreshCurrent();
208 break; 211 break;
209 case 1: 212 case 1:
210 deleteAllMail(pop3->getWrapper(),folder); 213 deleteAllMail(pop3->getWrapper(),folder);
211 break; 214 break;
212 case 2: 215 case 2:
213 downloadMails(); 216 downloadMails();
214 break; 217 break;
215 default: 218 default:
216 break; 219 break;
217 } 220 }
218} 221}
219 222
220/** 223/**
221 * NNTP Account stuff 224 * NNTP Account stuff
222 */ 225 */
223NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) 226NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent )
224 : AccountViewItem( parent ) 227 : AccountViewItem( parent )
225{ 228{
226 account = a; 229 account = a;
227 wrapper = AbstractMail::getWrapper( account ); 230 wrapper = AbstractMail::getWrapper( account );
228 //FIXME 231 //FIXME
229 SETPIX(PIXMAP_POP3FOLDER); 232 SETPIX(PIXMAP_POP3FOLDER);
230#if 0 233#if 0
231 if (!account->getOffline()) 234 if (!account->getOffline())
232 { 235 {
233 setPixmap( 0, ); 236 setPixmap( 0, );
234 } 237 }
235 else 238 else
@@ -420,249 +423,266 @@ void NNTPfolderItem::contextMenuSelected(int which)
420 423
421/** 424/**
422 * IMAP Account stuff 425 * IMAP Account stuff
423 */ 426 */
424IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) 427IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
425 : AccountViewItem( parent ) 428 : AccountViewItem( parent )
426{ 429{
427 account = a; 430 account = a;
428 wrapper = AbstractMail::getWrapper( account ); 431 wrapper = AbstractMail::getWrapper( account );
429 SETPIX(PIXMAP_IMAPFOLDER); 432 SETPIX(PIXMAP_IMAPFOLDER);
430 setText( 0, account->getAccountName() ); 433 setText( 0, account->getAccountName() );
431 setOpen( true ); 434 setOpen( true );
432} 435}
433 436
434IMAPviewItem::~IMAPviewItem() 437IMAPviewItem::~IMAPviewItem()
435{ 438{
436 delete wrapper; 439 delete wrapper;
437} 440}
438 441
439AbstractMail *IMAPviewItem::getWrapper() 442AbstractMail *IMAPviewItem::getWrapper()
440{ 443{
441 return wrapper; 444 return wrapper;
442} 445}
443 446
444void IMAPviewItem::refresh(QValueList<RecMailP>&) 447void IMAPviewItem::refresh(QValueList<RecMailP>&)
445{ 448{
446 refreshFolders(false); 449 refreshFolders(false);
447} 450}
448 451
449const QStringList&IMAPviewItem::subFolders() 452const QStringList&IMAPviewItem::subFolders()
450{ 453{
451 return currentFolders; 454 return currentFolders;
452} 455}
453 456
454void IMAPviewItem::refreshFolders(bool force) 457void IMAPviewItem::refreshFolders(bool force)
455{ 458{
456 if (childCount()>0 && force==false) return; 459 if (childCount()>0 && force==false) return;
457 if (account->getOffline()) return; 460 if (account->getOffline()) return;
458 461
459 removeChilds(); 462 removeChilds();
460 currentFolders.clear(); 463 currentFolders.clear();
461 QValueList<FolderP> * folders = wrapper->listFolders(); 464 QValueList<FolderP> * folders = wrapper->listFolders();
462 465
463 QValueList<FolderP>::Iterator it; 466 QValueList<FolderP>::Iterator it;
464 QListViewItem*item = 0; 467 QListViewItem*item = 0;
465 QListViewItem*titem = 0; 468 QListViewItem*titem = 0;
466 QString fname,del,search; 469 QString fname,del,search;
467 int pos; 470 int pos;
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
504QPopupMenu * IMAPviewItem::getContextMenu() 507QPopupMenu * 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
525void IMAPviewItem::createNewFolder() 532void 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
547void IMAPviewItem::contextMenuSelected(int id) 554void 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
578RECBODYP IMAPviewItem::fetchBody(const RecMailP&) 598RECBODYP IMAPviewItem::fetchBody(const RecMailP&)
579{ 599{
580 return new RecBody(); 600 return new RecBody();
581} 601}
582 602
583bool IMAPviewItem::offline() 603bool IMAPviewItem::offline()
584{ 604{
585 return account->getOffline(); 605 return account->getOffline();
586} 606}
587 607
588IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) 608IMAPfolderItem::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
603IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 623IMAPfolderItem::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
618IMAPfolderItem::~IMAPfolderItem() 638IMAPfolderItem::~IMAPfolderItem()
619{} 639{}
620 640
621const QString& IMAPfolderItem::Delemiter()const 641const QString& IMAPfolderItem::Delemiter()const
622{ 642{
623 return folder->Separator(); 643 return folder->Separator();
624} 644}
625 645
626void IMAPfolderItem::refresh(QValueList<RecMailP>&target) 646void IMAPfolderItem::refresh(QValueList<RecMailP>&target)
627{ 647{
628 if (folder->may_select()) 648 if (folder->may_select())
629 { 649 {
630 imap->getWrapper()->listMessages( folder->getName(),target ); 650 imap->getWrapper()->listMessages( folder->getName(),target );
631 } 651 }
632 else 652 else
633 { 653 {
634 target.clear(); 654 target.clear();
635 } 655 }
636} 656}
637 657
638RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) 658RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail)
639{ 659{
640 return imap->getWrapper()->fetchBody(aMail); 660 return imap->getWrapper()->fetchBody(aMail);
641} 661}
642 662
643QPopupMenu * IMAPfolderItem::getContextMenu() 663QPopupMenu * IMAPfolderItem::getContextMenu()
644{ 664{
645 QPopupMenu *m = new QPopupMenu(0); 665 QPopupMenu *m = new QPopupMenu(0);
646 if (m) 666 if (m)
647 { 667 {
648 if (folder->may_select()) 668 if (folder->may_select())
649 { 669 {
650 m->insertItem(QObject::tr("Refresh header list",contextName),0); 670 m->insertItem(QObject::tr("Refresh header list",contextName),0);
651 m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); 671 m->insertItem(QObject::tr("Move/Copie all mails",contextName),4);
652 m->insertItem(QObject::tr("Delete all mails",contextName),1); 672 m->insertItem(QObject::tr("Delete all mails",contextName),1);
653 } 673 }
654 if (folder->no_inferior()==false) 674 if (folder->no_inferior()==false)
655 { 675 {
656 m->insertItem(QObject::tr("Create new subfolder",contextName),2); 676 m->insertItem(QObject::tr("Create new subfolder",contextName),2);
657 } 677 }
658 if (folder->getDisplayName().lower()!="inbox") 678 if (folder->getDisplayName().lower()!="inbox")
659 { 679 {
660 m->insertItem(QObject::tr("Delete folder",contextName),3); 680 m->insertItem(QObject::tr("Delete folder",contextName),3);
661 } 681 }
662 } 682 }
663 return m; 683 return m;
664} 684}
665 685
666void IMAPfolderItem::createNewFolder() 686void IMAPfolderItem::createNewFolder()
667{ 687{
668 Newmdirdlg ndirdlg; 688 Newmdirdlg ndirdlg;
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp
index 85523b1..de8c5bb 100644
--- a/kmicromail/accountview.cpp
+++ b/kmicromail/accountview.cpp
@@ -48,156 +48,159 @@ void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
48 AccountViewItem *view = static_cast<AccountViewItem *>(item); 48 AccountViewItem *view = static_cast<AccountViewItem *>(item);
49 QPopupMenu*m = view->getContextMenu(); 49 QPopupMenu*m = view->getContextMenu();
50 if (!m) return; 50 if (!m) return;
51 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 51 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
52 m->setFocus(); 52 m->setFocus();
53 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 53 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
54 delete m; 54 delete m;
55} 55}
56 56
57void AccountView::populate( QList<Account> list ) 57void AccountView::populate( QList<Account> list )
58{ 58{
59 clear(); 59 clear();
60 60
61 imapAccounts.clear(); 61 imapAccounts.clear();
62 mhAccounts.clear(); 62 mhAccounts.clear();
63 63
64 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); 64 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
65 65
66 Account *it; 66 Account *it;
67 for ( it = list.first(); it; it = list.next() ) 67 for ( it = list.first(); it; it = list.next() )
68 { 68 {
69 if ( it->getType() == MAILLIB::A_IMAP ) 69 if ( it->getType() == MAILLIB::A_IMAP )
70 { 70 {
71 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 71 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
72 imapAccounts.append(new IMAPviewItem( imap, this )); 72 imapAccounts.append(new IMAPviewItem( imap, this ));
73 } 73 }
74 else if ( it->getType() == MAILLIB::A_POP3 ) 74 else if ( it->getType() == MAILLIB::A_POP3 )
75 { 75 {
76 POP3account *pop3 = static_cast<POP3account *>(it); 76 POP3account *pop3 = static_cast<POP3account *>(it);
77 /* must not be hold 'cause it isn't required */ 77 /* must not be hold 'cause it isn't required */
78 (void) new POP3viewItem( pop3, this ); 78 (void) new POP3viewItem( pop3, this );
79 } 79 }
80 else if ( it->getType() == MAILLIB::A_NNTP ) 80 else if ( it->getType() == MAILLIB::A_NNTP )
81 { 81 {
82 NNTPaccount *nntp = static_cast<NNTPaccount *>(it); 82 NNTPaccount *nntp = static_cast<NNTPaccount *>(it);
83 /* must not be hold 'cause it isn't required */ 83 /* must not be hold 'cause it isn't required */
84 (void) new NNTPviewItem( nntp, this ); 84 (void) new NNTPviewItem( nntp, this );
85 } 85 }
86 } 86 }
87} 87}
88 88
89void AccountView::refresh(QListViewItem *item) 89void AccountView::refresh(QListViewItem *item)
90{ 90{
91 if ( item ) 91 if ( item )
92 { 92 {
93 m_currentItem = item; 93 m_currentItem = item;
94 QValueList<RecMailP> headerlist; 94 QValueList<RecMailP> headerlist;
95 AccountViewItem *view = static_cast<AccountViewItem *>(item); 95 AccountViewItem *view = static_cast<AccountViewItem *>(item);
96 view->refresh(headerlist); 96 view->refresh(headerlist);
97 emit refreshMailview(headerlist); 97 emit refreshMailview(headerlist);
98 } 98 }
99} 99}
100 100
101void AccountView::refreshCurrent() 101void 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
111void AccountView::refreshAll() 111void AccountView::refreshAll()
112{ 112{
113} 113}
114 114
115RecBodyP AccountView::fetchBody(const RecMailP&aMail) 115RecBodyP 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
123void AccountView::setupFolderselect(Selectstore*sels) 123void 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}
142void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) 142void 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
170void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) 173void 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
198bool AccountView::currentisDraft() 201bool 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,210 +1,277 @@
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
21using namespace Opie::Core; 22using namespace Opie::Core;
22AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) 23AbstractMail* AbstractMail::getWrapper(IMAPaccount *a)
23{ 24{
24 return new IMAPwrapper(a); 25 return new IMAPwrapper(a);
25} 26}
26 27
27AbstractMail* AbstractMail::getWrapper(POP3account *a) 28AbstractMail* AbstractMail::getWrapper(POP3account *a)
28{ 29{
29 return new POP3wrapper(a); 30 return new POP3wrapper(a);
30} 31}
31 32
32AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) 33AbstractMail* AbstractMail::getWrapper(NNTPaccount *a)
33{ 34{
34 return new NNTPwrapper(a); 35 return new NNTPwrapper(a);
35} 36}
36 37
37AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) 38AbstractMail* 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
42AbstractMail* AbstractMail::getWrapper(Account*a) 43AbstractMail* 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
60encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) 61encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc)
61{ 62{
62 // odebug << "Decode string start" << oendl; 63 // odebug << "Decode string start" << oendl;
63 char*result_text; 64 char*result_text;
64 size_t index = 0; 65 size_t index = 0;
65 /* reset for recursive use! */ 66 /* reset for recursive use! */
66 size_t target_length = 0; 67 size_t target_length = 0;
67 result_text = 0; 68 result_text = 0;
68 int mimetype = MAILMIME_MECHANISM_7BIT; 69 int mimetype = MAILMIME_MECHANISM_7BIT;
69 if (enc.lower()=="quoted-printable") { 70 if (enc.lower()=="quoted-printable") {
70 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 71 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
71 } else if (enc.lower()=="base64") { 72 } else if (enc.lower()=="base64") {
72 mimetype = MAILMIME_MECHANISM_BASE64; 73 mimetype = MAILMIME_MECHANISM_BASE64;
73 } else if (enc.lower()=="8bit") { 74 } else if (enc.lower()=="8bit") {
74 mimetype = MAILMIME_MECHANISM_8BIT; 75 mimetype = MAILMIME_MECHANISM_8BIT;
75 } else if (enc.lower()=="binary") { 76 } else if (enc.lower()=="binary") {
76 mimetype = MAILMIME_MECHANISM_BINARY; 77 mimetype = MAILMIME_MECHANISM_BINARY;
77 } 78 }
78 79
79 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, 80 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
80 &result_text,&target_length); 81 &result_text,&target_length);
81 82
82 encodedString* result = new encodedString(); 83 encodedString* result = new encodedString();
83 if (err == MAILIMF_NO_ERROR) { 84 if (err == MAILIMF_NO_ERROR) {
84 result->setContent(result_text,target_length); 85 result->setContent(result_text,target_length);
85 } 86 }
86 //odebug << "Decode string finished" << oendl; 87 //odebug << "Decode string finished" << oendl;
87 return result; 88 return result;
88} 89}
89 90
90QString AbstractMail::convert_String(const char*text) 91QString AbstractMail::convert_String(const char*text)
91{ 92{
92 //size_t index = 0; 93 //size_t index = 0;
93 char*res = 0; 94 char*res = 0;
94 int err = MAILIMF_NO_ERROR; 95 int err = MAILIMF_NO_ERROR;
95 96
96 QString result(text); 97 QString result(text);
97 98
98 /* due a bug in libetpan it isn't usable this moment */ 99 /* due a bug in libetpan it isn't usable this moment */
99/* int err = mailmime_encoded_phrase_parse("iso-8859-1", 100/* int err = mailmime_encoded_phrase_parse("iso-8859-1",
100 text, strlen(text),&index, "iso-8859-1",&res);*/ 101 text, strlen(text),&index, "iso-8859-1",&res);*/
101 //odebug << "Input: " << text << "" << oendl; 102 //odebug << "Input: " << text << "" << oendl;
102 if (err == MAILIMF_NO_ERROR && res && strlen(res)) { 103 if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
103// result = QString(res); 104// result = QString(res);
104// odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl; 105// odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl;
105 } 106 }
106 if (res) free(res); 107 if (res) free(res);
107 return result; 108 return result;
108} 109}
109 110
110/* cp & paste from launcher */ 111/* cp & paste from launcher */
111QString AbstractMail::gen_attachment_id() 112QString AbstractMail::gen_attachment_id()
112{ 113{
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
122int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) 123int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool)
123{ 124{
124 return 0; 125 return 0;
125} 126}
126 127
127QString AbstractMail::defaultLocalfolder() 128QString 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
135QString AbstractMail::draftFolder() 136QString 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 */
141void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) 142void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &)
142{ 143{
143} 144}
144void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) 145void 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
163void 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}
161void AbstractMail::mvcpAllMails(const FolderP&fromFolder, 228void 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}
169void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, 236void 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
199void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 266void 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);
209 } 276 }
210} 277}
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
13class IMAPwrapper; 16class IMAPwrapper;
14class POP3wrapper; 17class POP3wrapper;
15class Folder; 18class Folder;
16class encodedString; 19class encodedString;
17struct folderStat; 20struct folderStat;
18 21
19class AbstractMail:public QObject 22class AbstractMail:public QObject
20{ 23{
21 Q_OBJECT 24 Q_OBJECT
22public: 25public:
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
71protected: 76protected:
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,122 +1,167 @@
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
8using namespace Opie::Core; 11using namespace Opie::Core;
9Genericwrapper::Genericwrapper() 12Genericwrapper::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
17Genericwrapper::~Genericwrapper() 20Genericwrapper::~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}
30QString 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
28void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) 73void 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 }
75 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { 120 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
76 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { 121 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
77 field = (mailmime_field*)current->data; 122 field = (mailmime_field*)current->data;
78 switch(field->fld_type) { 123 switch(field->fld_type) {
79 case MAILMIME_FIELD_TRANSFER_ENCODING: 124 case MAILMIME_FIELD_TRANSFER_ENCODING:
80 target->setEncoding(getencoding(field->fld_data.fld_encoding)); 125 target->setEncoding(getencoding(field->fld_data.fld_encoding));
81 break; 126 break;
82 case MAILMIME_FIELD_ID: 127 case MAILMIME_FIELD_ID:
83 target->setIdentifier(field->fld_data.fld_id); 128 target->setIdentifier(field->fld_data.fld_id);
84 break; 129 break;
85 case MAILMIME_FIELD_DESCRIPTION: 130 case MAILMIME_FIELD_DESCRIPTION:
86 target->setDescription(field->fld_data.fld_description); 131 target->setDescription(field->fld_data.fld_description);
87 break; 132 break;
88 default: 133 default:
89 break; 134 break;
90 } 135 }
91 } 136 }
92 } 137 }
93} 138}
94 139
95void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) 140void Genericwrapper::fillParameters(RecPartP&target,clist*parameters)
96{ 141{
97 if (!parameters) {return;} 142 if (!parameters) {return;}
98 clistcell*current=0; 143 clistcell*current=0;
99 mailmime_parameter*param; 144 mailmime_parameter*param;
100 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { 145 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
101 param = (mailmime_parameter*)current->data; 146 param = (mailmime_parameter*)current->data;
102 if (param) { 147 if (param) {
103 target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 148 target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
104 } 149 }
105 } 150 }
106} 151}
107 152
108QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) 153QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
109{ 154{
110 QString enc="7bit"; 155 QString enc="7bit";
111 if (!aEnc) return enc; 156 if (!aEnc) return enc;
112 switch(aEnc->enc_type) { 157 switch(aEnc->enc_type) {
113 case MAILMIME_MECHANISM_7BIT: 158 case MAILMIME_MECHANISM_7BIT:
114 enc = "7bit"; 159 enc = "7bit";
115 break; 160 break;
116 case MAILMIME_MECHANISM_8BIT: 161 case MAILMIME_MECHANISM_8BIT:
117 enc = "8bit"; 162 enc = "8bit";
118 break; 163 break;
119 case MAILMIME_MECHANISM_BINARY: 164 case MAILMIME_MECHANISM_BINARY:
120 enc = "binary"; 165 enc = "binary";
121 break; 166 break;
122 case MAILMIME_MECHANISM_QUOTED_PRINTABLE: 167 case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
@@ -149,203 +194,192 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m
149 clistiter * cur = 0; 194 clistiter * cur = 0;
150 QString b; 195 QString b;
151 RecPartP part = new RecPart(); 196 RecPartP part = new RecPart();
152 197
153 switch (mime->mm_type) { 198 switch (mime->mm_type) {
154 case MAILMIME_SINGLE: 199 case MAILMIME_SINGLE:
155 { 200 {
156 QValueList<int>countlist = recList; 201 QValueList<int>countlist = recList;
157 countlist.append(current_count); 202 countlist.append(current_count);
158 r = mailmessage_fetch_section(message,mime,&data,&len); 203 r = mailmessage_fetch_section(message,mime,&data,&len);
159 part->setSize(len); 204 part->setSize(len);
160 part->setPositionlist(countlist); 205 part->setPositionlist(countlist);
161 b = gen_attachment_id(); 206 b = gen_attachment_id();
162 part->setIdentifier(b); 207 part->setIdentifier(b);
163 fillSingleBody(part,message,mime); 208 fillSingleBody(part,message,mime);
164 if (part->Type()=="text" && target->Bodytext().isNull()) { 209 if (part->Type()=="text" && target->Bodytext().isNull()) {
165 encodedString*rs = new encodedString(); 210 encodedString*rs = new encodedString();
166 rs->setContent(data,len); 211 rs->setContent(data,len);
167 encodedString*res = decode_String(rs,part->Encoding()); 212 encodedString*res = decode_String(rs,part->Encoding());
168 if (countlist.count()>2) { 213 if (countlist.count()>2) {
169 bodyCache[b]=rs; 214 bodyCache[b]=rs;
170 target->addPart(part); 215 target->addPart(part);
171 } else { 216 } else {
172 delete rs; 217 delete rs;
173 } 218 }
174 b = QString(res->Content()); 219 b = QString(res->Content());
175 delete res; 220 delete res;
176 target->setBodytext(b); 221 target->setBodytext(b);
177 target->setDescription(part); 222 target->setDescription(part);
178 } else { 223 } else {
179 bodyCache[b]=new encodedString(data,len); 224 bodyCache[b]=new encodedString(data,len);
180 target->addPart(part); 225 target->addPart(part);
181 } 226 }
182 } 227 }
183 break; 228 break;
184 case MAILMIME_MULTIPLE: 229 case MAILMIME_MULTIPLE:
185 { 230 {
186 unsigned int ccount = 1; 231 unsigned int ccount = 1;
187 mailmime*cbody=0; 232 mailmime*cbody=0;
188 QValueList<int>countlist = recList; 233 QValueList<int>countlist = recList;
189 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { 234 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
190 cbody = (mailmime*)clist_content(cur); 235 cbody = (mailmime*)clist_content(cur);
191 if (cbody->mm_type==MAILMIME_MULTIPLE) { 236 if (cbody->mm_type==MAILMIME_MULTIPLE) {
192 RecPartP targetPart = new RecPart(); 237 RecPartP targetPart = new RecPart();
193 targetPart->setType("multipart"); 238 targetPart->setType("multipart");
194 countlist.append(current_count); 239 countlist.append(current_count);
195 targetPart->setPositionlist(countlist); 240 targetPart->setPositionlist(countlist);
196 target->addPart(targetPart); 241 target->addPart(targetPart);
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
231RecBodyP Genericwrapper::parseMail( mailmessage * msg ) 276RecBodyP 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
245QString 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
257QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 291QString 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
288QString Genericwrapper::parseGroup( mailimf_group *group ) 322QString 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
304QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) 338QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
305{ 339{
306 QString result( "" ); 340 QString result( "" );
307 341
308 if ( box->mb_display_name == NULL ) { 342 if ( box->mb_display_name == NULL ) {
309 result.append( box->mb_addr_spec ); 343 result.append( box->mb_addr_spec );
310 } else { 344 } else {
311 result.append( convert_String(box->mb_display_name).latin1() ); 345 result.append( convert_String(box->mb_display_name).latin1() );
312 result.append( " <" ); 346 result.append( " <" );
313 result.append( box->mb_addr_spec ); 347 result.append( box->mb_addr_spec );
314 result.append( ">" ); 348 result.append( ">" );
315 } 349 }
316 350
317 return result; 351 return result;
318} 352}
319 353
320QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) 354QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
321{ 355{
322 QString result( "" ); 356 QString result( "" );
323 357
324 bool first = true; 358 bool first = true;
325 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { 359 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
326 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 360 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
327 361
328 if ( !first ) { 362 if ( !first ) {
329 result.append( "," ); 363 result.append( "," );
330 } else { 364 } else {
331 first = false; 365 first = false;
332 } 366 }
333 367
334 result.append( parseMailbox( box ) ); 368 result.append( parseMailbox( box ) );
335 } 369 }
336 370
337 return result; 371 return result;
338} 372}
339 373
340encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) 374encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part)
341{ 375{
342 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); 376 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier());
343 if (it==bodyCache.end()) return new encodedString(); 377 if (it==bodyCache.end()) return new encodedString();
344 encodedString*t = decode_String(it.data(),part->Encoding()); 378 encodedString*t = decode_String(it.data(),part->Encoding());
345 return t; 379 return t;
346} 380}
347 381
348encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) 382encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part)
349{ 383{
350 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); 384 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier());
351 if (it==bodyCache.end()) return new encodedString(); 385 if (it==bodyCache.end()) return new encodedString();
@@ -355,127 +389,133 @@ encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part)
355 389
356QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) 390QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part)
357{ 391{
358 encodedString*t = fetchDecodedPart(mail,part); 392 encodedString*t = fetchDecodedPart(mail,part);
359 QString text=t->Content(); 393 QString text=t->Content();
360 delete t; 394 delete t;
361 return text; 395 return text;
362} 396}
363 397
364void Genericwrapper::cleanMimeCache() 398void Genericwrapper::cleanMimeCache()
365{ 399{
366 QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); 400 QMap<QString,encodedString*>::Iterator it = bodyCache.begin();
367 for (;it!=bodyCache.end();++it) { 401 for (;it!=bodyCache.end();++it) {
368 encodedString*t = it.data(); 402 encodedString*t = it.data();
369 //it.setValue(0); 403 //it.setValue(0);
370 if (t) delete t; 404 if (t) delete t;
371 } 405 }
372 bodyCache.clear(); 406 bodyCache.clear();
373 ; // odebug << "Genericwrapper: cache cleaned" << oendl; 407 ; // odebug << "Genericwrapper: cache cleaned" << oendl;
374} 408}
375 409
376QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) 410QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies)
377{ 411{
378 QStringList res; 412 QStringList res;
379 if (!in_replies || !in_replies->mid_list) return res; 413 if (!in_replies || !in_replies->mid_list) return res;
380 clistiter * current = 0; 414 clistiter * current = 0;
381 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { 415 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) {
382 QString h((char*)current->data); 416 QString h((char*)current->data);
383 while (h.length()>0 && h[0]=='<') { 417 while (h.length()>0 && h[0]=='<') {
384 h.remove(0,1); 418 h.remove(0,1);
385 } 419 }
386 while (h.length()>0 && h[h.length()-1]=='>') { 420 while (h.length()>0 && h[h.length()-1]=='>') {
387 h.remove(h.length()-1,1); 421 h.remove(h.length()-1,1);
388 } 422 }
389 if (h.length()>0) { 423 if (h.length()>0) {
390 res.append(h); 424 res.append(h);
391 } 425 }
392 } 426 }
393 return res; 427 return res;
394} 428}
395 429
396void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) 430void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb)
397{ 431{
398 int r; 432 int r;
399 mailmessage_list * env_list = 0; 433 mailmessage_list * env_list = 0;
400 r = mailsession_get_messages_list(session,&env_list); 434 r = mailsession_get_messages_list(session,&env_list);
401 if (r != MAIL_NO_ERROR) { 435 if (r != MAIL_NO_ERROR) {
402 ; // odebug << "Error message list" << oendl; 436 ; // odebug << "Error message list" << oendl;
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
10class RecMail; 10class RecMail;
11class RecBody; 11class RecBody;
12class encodedString; 12class encodedString;
13struct mailpop3; 13struct mailpop3;
14struct mailmessage; 14struct mailmessage;
15struct mailmime; 15struct mailmime;
16struct mailmime_mechanism; 16struct mailmime_mechanism;
17struct mailimf_mailbox_list; 17struct mailimf_mailbox_list;
18struct mailimf_mailbox; 18struct mailimf_mailbox;
19struct mailimf_date_time; 19struct mailimf_date_time;
20struct mailimf_group; 20struct mailimf_group;
21struct mailimf_address_list; 21struct mailimf_address_list;
22struct mailsession; 22struct mailsession;
23struct mailstorage; 23struct mailstorage;
24struct mailfolder; 24struct mailfolder;
25struct mailimf_in_reply_to; 25struct 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 */
31class Genericwrapper : public AbstractMail 31class Genericwrapper : public AbstractMail
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34public: 34public:
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
46protected: 47protected:
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,105 +1,106 @@
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
11using namespace Opie::Core; 12using namespace Opie::Core;
12int IMAPwrapper::mMax = 0; 13int IMAPwrapper::mMax = 0;
13int IMAPwrapper::mCurrent = 0; 14int IMAPwrapper::mCurrent = 0;
14 15
15IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 16IMAPwrapper::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
25IMAPwrapper::~IMAPwrapper() 26IMAPwrapper::~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!*/
32int IMAPwrapper::selectMbox(const QString&mbox) 33int 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
46void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 47void 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}
56void IMAPwrapper::progress( QString m ) 57void IMAPwrapper::progress( QString m )
57{ 58{
58 59
59 static QString mProgrMess; 60 static QString mProgrMess;
60 if ( m != QString::null ) { 61 if ( m != QString::null ) {
61 mProgrMess = m; 62 mProgrMess = m;
62 mCurrent = 0; 63 mCurrent = 0;
63 return; 64 return;
64 } 65 }
65 QString mess; 66 QString mess;
66 //qDebug("progress "); 67 //qDebug("progress ");
67 if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); 68 if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax);
68 else mess = mProgrMess +tr(" message %1").arg( mCurrent++); 69 else mess = mProgrMess +tr(" message %1").arg( mCurrent++);
69 Global::statusMessage(mess); 70 Global::statusMessage(mess);
70 qApp->processEvents(); 71 qApp->processEvents();
71} 72}
72bool IMAPwrapper::start_tls(bool force_tls) 73bool IMAPwrapper::start_tls(bool force_tls)
73{ 74{
74 int err; 75 int err;
75 bool try_tls; 76 bool try_tls;
76 mailimap_capability_data * cap_data = 0; 77 mailimap_capability_data * cap_data = 0;
77 78
78 err = mailimap_capability(m_imap,&cap_data); 79 err = mailimap_capability(m_imap,&cap_data);
79 if (err != MAILIMAP_NO_ERROR) { 80 if (err != MAILIMAP_NO_ERROR) {
80 Global::statusMessage("error getting capabilities!"); 81 Global::statusMessage("error getting capabilities!");
81 return false; 82 return false;
82 } 83 }
83 clistiter * cur; 84 clistiter * cur;
84 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { 85 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) {
85 struct mailimap_capability * cap; 86 struct mailimap_capability * cap;
86 cap = (struct mailimap_capability *)clist_content(cur); 87 cap = (struct mailimap_capability *)clist_content(cur);
87 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { 88 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) {
88 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { 89 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) {
89 try_tls = true; 90 try_tls = true;
90 break; 91 break;
91 } 92 }
92 } 93 }
93 } 94 }
94 if (cap_data) { 95 if (cap_data) {
95 mailimap_capability_data_free(cap_data); 96 mailimap_capability_data_free(cap_data);
96 } 97 }
97 if (try_tls) { 98 if (try_tls) {
98 err = mailimap_starttls(m_imap); 99 err = mailimap_starttls(m_imap);
99 if (err != MAILIMAP_NO_ERROR && force_tls) { 100 if (err != MAILIMAP_NO_ERROR && force_tls) {
100 Global::statusMessage(tr("Server has no TLS support!")); 101 Global::statusMessage(tr("Server has no TLS support!"));
101 try_tls = false; 102 try_tls = false;
102 } else { 103 } else {
103 mailstream_low * low; 104 mailstream_low * low;
104 mailstream_low * new_low; 105 mailstream_low * new_low;
105 low = mailstream_get_low(m_imap->imap_stream); 106 low = mailstream_get_low(m_imap->imap_stream);
@@ -363,194 +364,209 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
363 list = (mailimap_mailbox_list *) current->data; 364 list = (mailimap_mailbox_list *) current->data;
364 // it is better use the deep copy mechanism of qt itself 365 // it is better use the deep copy mechanism of qt itself
365 // instead of using strdup! 366 // instead of using strdup!
366 temp = list->mb_name; 367 temp = list->mb_name;
367 if (temp.lower()=="inbox") 368 if (temp.lower()=="inbox")
368 continue; 369 continue;
369 if (temp.lower()==account->getPrefix().lower()) 370 if (temp.lower()==account->getPrefix().lower())
370 continue; 371 continue;
371 if ( (bflags = list->mb_flag) ) { 372 if ( (bflags = list->mb_flag) ) {
372 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 373 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
373 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 374 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
374 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { 375 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
375 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { 376 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
376 no_inferiors = true; 377 no_inferiors = true;
377 } 378 }
378 } 379 }
379 } 380 }
380 del = list->mb_delimiter; 381 del = list->mb_delimiter;
381 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); 382 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
382 } 383 }
383 } else { 384 } else {
384 qDebug("error fetching folders "); 385 qDebug("error fetching folders ");
385 386
386 } 387 }
387 if (result) mailimap_list_result_free( result ); 388 if (result) mailimap_list_result_free( result );
388 return folders; 389 return folders;
389} 390}
390 391
391RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 392RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
392{ 393{
393 RecMail * m = 0; 394 RecMail * m = 0;
394 mailimap_msg_att_item *item=0; 395 mailimap_msg_att_item *item=0;
395 clistcell *current,*c,*cf; 396 clistcell *current,*c,*cf;
396 mailimap_msg_att_dynamic*flist; 397 mailimap_msg_att_dynamic*flist;
397 mailimap_flag_fetch*cflag; 398 mailimap_flag_fetch*cflag;
398 int size; 399 int size;
399 QBitArray mFlags(7); 400 QBitArray mFlags(7);
400 QStringList addresslist; 401 QStringList addresslist;
401 402
402 if (!m_att) { 403 if (!m_att) {
403 return m; 404 return m;
404 } 405 }
405 m = new RecMail(); 406 m = new RecMail();
406 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 407 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
407 current = c; 408 current = c;
408 size = 0; 409 size = 0;
409 item = (mailimap_msg_att_item*)current->data; 410 item = (mailimap_msg_att_item*)current->data;
410 if ( !item ) 411 if ( !item )
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() );
509#endif 525#endif
510 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { 526 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
511 size = item->att_data.att_static->att_data.att_rfc822_size; 527 size = item->att_data.att_static->att_data.att_rfc822_size;
512 } 528 }
513 } 529 }
514 /* msg is already deleted */ 530 /* msg is already deleted */
515 if (mFlags.testBit(FLAG_DELETED) && m) { 531 if (mFlags.testBit(FLAG_DELETED) && m) {
516 delete m; 532 delete m;
517 m = 0; 533 m = 0;
518 } 534 }
519 if (m) { 535 if (m) {
520 m->setFlags(mFlags); 536 m->setFlags(mFlags);
521 m->setMsgsize(size); 537 m->setMsgsize(size);
522 } 538 }
523 return m; 539 return m;
524} 540}
525 541
526RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) 542RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
527{ 543{
528 RecBodyP body = new RecBody(); 544 RecBodyP body = new RecBody();
529 const char *mb; 545 const char *mb;
530 int err = MAILIMAP_NO_ERROR; 546 int err = MAILIMAP_NO_ERROR;
531 clist *result = 0; 547 clist *result = 0;
532 clistcell *current; 548 clistcell *current;
533 mailimap_fetch_att *fetchAtt = 0; 549 mailimap_fetch_att *fetchAtt = 0;
534 mailimap_fetch_type *fetchType = 0; 550 mailimap_fetch_type *fetchType = 0;
535 mailimap_set *set = 0; 551 mailimap_set *set = 0;
536 mailimap_body*body_desc = 0; 552 mailimap_body*body_desc = 0;
537 553
538 mb = mail->getMbox().latin1(); 554 mb = mail->getMbox().latin1();
539 555
540 login(); 556 login();
541 if (!m_imap) { 557 if (!m_imap) {
542 return body; 558 return body;
543 } 559 }
544 err = selectMbox(mail->getMbox()); 560 err = selectMbox(mail->getMbox());
545 if ( err != MAILIMAP_NO_ERROR ) { 561 if ( err != MAILIMAP_NO_ERROR ) {
546 return body; 562 return body;
547 } 563 }
548 564
549 /* the range has to start at 1!!! not with 0!!!! */ 565 /* the range has to start at 1!!! not with 0!!!! */
550 set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); 566 set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() );
551 fetchAtt = mailimap_fetch_att_new_bodystructure(); 567 fetchAtt = mailimap_fetch_att_new_bodystructure();
552 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 568 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
553 err = mailimap_fetch( m_imap, set, fetchType, &result ); 569 err = mailimap_fetch( m_imap, set, fetchType, &result );
554 mailimap_set_free( set ); 570 mailimap_set_free( set );
555 mailimap_fetch_type_free( fetchType ); 571 mailimap_fetch_type_free( fetchType );
556 572
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
@@ -1,84 +1,85 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#ifndef __IMAPWRAPPER 2#ifndef __IMAPWRAPPER
3#define __IMAPWRAPPER 3#define __IMAPWRAPPER
4 4
5#include <qlist.h> 5#include <qlist.h>
6#include "mailwrapper.h" 6#include "mailwrapper.h"
7#include "abstractmail.h" 7#include "abstractmail.h"
8#include <libetpan/clist.h> 8#include <libetpan/clist.h>
9 9
10struct mailimap; 10struct mailimap;
11struct mailimap_body; 11struct mailimap_body;
12struct mailimap_body_type_1part; 12struct mailimap_body_type_1part;
13struct mailimap_body_type_text; 13struct mailimap_body_type_text;
14struct mailimap_body_type_basic; 14struct mailimap_body_type_basic;
15struct mailimap_body_type_msg; 15struct mailimap_body_type_msg;
16struct mailimap_body_type_mpart; 16struct mailimap_body_type_mpart;
17struct mailimap_body_fields; 17struct mailimap_body_fields;
18struct mailimap_msg_att; 18struct mailimap_msg_att;
19class encodedString; 19class encodedString;
20 20
21class IMAPwrapper : public AbstractMail 21class IMAPwrapper : public AbstractMail
22{ 22{
23 Q_OBJECT 23 Q_OBJECT
24public: 24public:
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
56protected: 57protected:
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,122 +1,145 @@
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
7using namespace Opie::Core; 7using namespace Opie::Core;
8RecMail::RecMail() 8RecMail::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
14RecMail::RecMail(const RecMail&old) 14RecMail::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
22RecMail::~RecMail() 22RecMail::~RecMail()
23{ 23{
24 wrapper = 0; 24 wrapper = 0;
25} 25}
26static 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
33bool 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}
27void RecMail::copy_old(const RecMail&old) 50void 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
46void RecMail::init() 69void 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
56void RecMail::setWrapper(AbstractMail*awrapper) 79void RecMail::setWrapper(AbstractMail*awrapper)
57{ 80{
58 wrapper = awrapper; 81 wrapper = awrapper;
59} 82}
60 83
61AbstractMail* RecMail::Wrapper() 84AbstractMail* RecMail::Wrapper()
62{ 85{
63 return wrapper; 86 return wrapper;
64} 87}
65 88
66void RecMail::setTo(const QStringList&list) 89void RecMail::setTo(const QStringList&list)
67{ 90{
68 to = list; 91 to = list;
69} 92}
70 93
71const QStringList&RecMail::To()const 94const QStringList&RecMail::To()const
72{ 95{
73 return to; 96 return to;
74} 97}
75 98
76void RecMail::setCC(const QStringList&list) 99void RecMail::setCC(const QStringList&list)
77{ 100{
78 cc = list; 101 cc = list;
79} 102}
80 103
81const QStringList&RecMail::CC()const 104const QStringList&RecMail::CC()const
82{ 105{
83 return cc; 106 return cc;
84} 107}
85 108
86void RecMail::setBcc(const QStringList&list) 109void RecMail::setBcc(const QStringList&list)
87{ 110{
88 bcc = list; 111 bcc = list;
89} 112}
90 113
91const QStringList& RecMail::Bcc()const 114const QStringList& RecMail::Bcc()const
92{ 115{
93 return bcc; 116 return bcc;
94} 117}
95 118
96void RecMail::setInreply(const QStringList&list) 119void RecMail::setInreply(const QStringList&list)
97{ 120{
98 in_reply_to = list; 121 in_reply_to = list;
99} 122}
100 123
101const QStringList& RecMail::Inreply()const 124const QStringList& RecMail::Inreply()const
102{ 125{
103 return in_reply_to; 126 return in_reply_to;
104} 127}
105 128
106void RecMail::setReferences(const QStringList&list) 129void RecMail::setReferences(const QStringList&list)
107{ 130{
108 references = list; 131 references = list;
109} 132}
110 133
111const QStringList& RecMail::References()const 134const QStringList& RecMail::References()const
112{ 135{
113 return references; 136 return references;
114} 137}
115 138
116RecPart::RecPart() 139RecPart::RecPart()
117 : Opie::Core::ORefCount(), 140 : Opie::Core::ORefCount(),
118 m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) 141 m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0)
119{ 142{
120 m_Parameters.clear(); 143 m_Parameters.clear();
121 m_poslist.clear(); 144 m_poslist.clear();
122} 145}
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,171 +1,174 @@
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
19class AbstractMail; 19class 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*/
32class RecMail:public Opie::Core::ORefCount 32class RecMail:public Opie::Core::ORefCount
33{ 33{
34public: 34public:
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
74protected: 77protected:
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
84typedef Opie::Core::OSmartPointer<RecMail> RecMailP; 87typedef Opie::Core::OSmartPointer<RecMail> RecMailP;
85typedef QMap<QString,QString> part_plist_t; 88typedef QMap<QString,QString> part_plist_t;
86 89
87class RecPart:public Opie::Core::ORefCount 90class RecPart:public Opie::Core::ORefCount
88{ 91{
89protected: 92protected:
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
96public: 99public:
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};
124 127
125typedef Opie::Core::OSmartPointer<RecPart> RecPartP; 128typedef Opie::Core::OSmartPointer<RecPart> RecPartP;
126 129
127class RecBody:public Opie::Core::ORefCount 130class RecBody:public Opie::Core::ORefCount
128{ 131{
129protected: 132protected:
130 QString m_BodyText; 133 QString m_BodyText;
131 QValueList<RecPartP> m_PartsList; 134 QValueList<RecPartP> m_PartsList;
132 RecPartP m_description; 135 RecPartP m_description;
133 136
134public: 137public:
135 RecBody(); 138 RecBody();
136 RecBody(const RecBody&old); 139 RecBody(const RecBody&old);
137 virtual ~RecBody(); 140 virtual ~RecBody();
138 void setBodytext(const QString&); 141 void setBodytext(const QString&);
139 const QString& Bodytext()const; 142 const QString& Bodytext()const;
140 143
141 void setDescription(const RecPartP&des); 144 void setDescription(const RecPartP&des);
142 const RecPartP& Description()const; 145 const RecPartP& Description()const;
143 146
144 void setParts(const QValueList<RecPartP>&parts); 147 void setParts(const QValueList<RecPartP>&parts);
145 const QValueList<RecPartP>& Parts()const; 148 const QValueList<RecPartP>& Parts()const;
146 void addPart(const RecPartP&part); 149 void addPart(const RecPartP&part);
147}; 150};
148 151
149typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; 152typedef Opie::Core::OSmartPointer<RecBody> RecBodyP;
150 153
151class encodedString 154class encodedString
152{ 155{
153public: 156public:
154 encodedString(); 157 encodedString();
155 /* 158 /*
156 creates an new content string. 159 creates an new content string.
157 it makes a deep copy of it! 160 it makes a deep copy of it!
158 */ 161 */
159 encodedString(const char*nContent,unsigned int length); 162 encodedString(const char*nContent,unsigned int length);
160 /* 163 /*
161 Take over the nContent. Means: it will just copy the pointer, not the content. 164 Take over the nContent. Means: it will just copy the pointer, not the content.
162 so make sure: No one else frees the string, the string has allocated with 165 so make sure: No one else frees the string, the string has allocated with
163 malloc for compatibility with c-based libs 166 malloc for compatibility with c-based libs
164 */ 167 */
165 encodedString(char*nContent,unsigned int nSize); 168 encodedString(char*nContent,unsigned int nSize);
166 /* copy construkor - makes ALWAYS a deep copy!!!! */ 169 /* copy construkor - makes ALWAYS a deep copy!!!! */
167 encodedString(const encodedString&old); 170 encodedString(const encodedString&old);
168 /* assign operator - makes ALWAYS a deep copy!!!! */ 171 /* assign operator - makes ALWAYS a deep copy!!!! */
169 encodedString& operator=(const encodedString&old); 172 encodedString& operator=(const encodedString&old);
170 /* destructor - cleans the content */ 173 /* destructor - cleans the content */
171 virtual ~encodedString(); 174 virtual ~encodedString();
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
7class encodedString; 7class encodedString;
8struct mailmbox_folder; 8struct mailmbox_folder;
9 9
10class MBOXwrapper : public Genericwrapper 10class MBOXwrapper : public Genericwrapper
11{ 11{
12 Q_OBJECT 12 Q_OBJECT
13 13
14public: 14public:
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
40protected: 41protected:
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
@@ -1,163 +1,164 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#include "mhwrapper.h" 2#include "mhwrapper.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5#include <libetpan/libetpan.h> 5#include <libetpan/libetpan.h>
6#include <qdir.h> 6#include <qdir.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <stdlib.h> 8#include <stdlib.h>
9#include <qpe/global.h> 9#include <qpe/global.h>
10#include <oprocess.h> 10#include <oprocess.h>
11//#include <opie2/odebug.h> 11//#include <opie2/odebug.h>
12 12
13using namespace Opie::Core; 13using namespace Opie::Core;
14MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) 14MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name)
15 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) 15 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name)
16{ 16{
17 if (MHPath.length()>0) { 17 if (MHPath.length()>0) {
18 if (MHPath[MHPath.length()-1]=='/') { 18 if (MHPath[MHPath.length()-1]=='/') {
19 MHPath=MHPath.left(MHPath.length()-1); 19 MHPath=MHPath.left(MHPath.length()-1);
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
30void MHwrapper::init_storage() 30void 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
52void MHwrapper::clean_storage() 52void 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
61MHwrapper::~MHwrapper() 61MHwrapper::~MHwrapper()
62{ 62{
63 clean_storage(); 63 clean_storage();
64} 64}
65 65
66void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) 66void 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
82QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() 83QValueList<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
107void MHwrapper::deleteMail(const RecMailP&mail) 108void 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! ");
116 return; 117 return;
117 } 118 }
118 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); 119 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber());
119 if (r != MAIL_NO_ERROR) { 120 if (r != MAIL_NO_ERROR) {
120 qDebug("error deleting mail "); 121 qDebug("error deleting mail ");
121 } 122 }
122} 123}
123 124
124void MHwrapper::answeredMail(const RecMailP&) 125void MHwrapper::answeredMail(const RecMailP&)
125{ 126{
126} 127}
127 128
128RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) 129RecBodyP MHwrapper::fetchBody( const RecMailP &mail )
129{ 130{
130 RecBodyP body = new RecBody(); 131 RecBodyP body = new RecBody();
131 init_storage(); 132 init_storage();
132 if (!m_storage) { 133 if (!m_storage) {
133 return body; 134 return body;
134 } 135 }
135 mailmessage * msg; 136 mailmessage * msg;
136 char*data=0; 137 char*data=0;
137 138
138 /* mail should hold the complete path! */ 139 /* mail should hold the complete path! */
139 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 140 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
140 if (r != MAIL_NO_ERROR) { 141 if (r != MAIL_NO_ERROR) {
141 return body; 142 return body;
142 } 143 }
143 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); 144 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
144 if (r != MAIL_NO_ERROR) { 145 if (r != MAIL_NO_ERROR) {
145 qDebug("Error fetching mail "); 146 qDebug("Error fetching mail ");
146 147
147 return body; 148 return body;
148 } 149 }
149 body = parseMail(msg); 150 body = parseMail(msg);
150 mailmessage_fetch_result_free(msg,data); 151 mailmessage_fetch_result_free(msg,data);
151 return body; 152 return body;
152} 153}
153 154
154void MHwrapper::mbox_progress( size_t current, size_t maximum ) 155void MHwrapper::mbox_progress( size_t current, size_t maximum )
155{ 156{
156 qDebug("MBox Progress %d of %d",current,maximum ); 157 qDebug("MBox Progress %d of %d",current,maximum );
157 //odebug << "MH " << current << " von " << maximum << "" << oendl; 158 //odebug << "MH " << current << " von " << maximum << "" << oendl;
158} 159}
159 160
160QString MHwrapper::buildPath(const QString&p) 161QString MHwrapper::buildPath(const QString&p)
161{ 162{
162 QString f=""; 163 QString f="";
163 if (p.length()==0||p=="/") 164 if (p.length()==0||p=="/")
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
10class encodedString; 10class encodedString;
11struct mailmbox_folder; 11struct mailmbox_folder;
12namespace Opie {namespace Core {class OProcess;}} 12namespace Opie {namespace Core {class OProcess;}}
13 13
14class MHwrapper : public Genericwrapper 14class MHwrapper : public Genericwrapper
15{ 15{
16 Q_OBJECT 16 Q_OBJECT
17public: 17public:
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
46public slots: 47public 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 *);
50protected: 51protected:
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
10class encodedString; 10class encodedString;
11struct mailstorage; 11struct mailstorage;
12struct mailfolder; 12struct mailfolder;
13 13
14class NNTPwrapper : public Genericwrapper 14class NNTPwrapper : public Genericwrapper
15{ 15{
16 16
17 Q_OBJECT 17 Q_OBJECT
18 18
19public: 19public:
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
41protected: 42protected:
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
9class encodedString; 9class encodedString;
10struct mailstorage; 10struct mailstorage;
11struct mailfolder; 11struct mailfolder;
12 12
13class POP3wrapper : public Genericwrapper 13class POP3wrapper : public Genericwrapper
14{ 14{
15 Q_OBJECT 15 Q_OBJECT
16 16
17public: 17public:
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; };
38protected: 38protected:
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
16class SMTPaccount; 16class SMTPaccount;
17class AbstractMail; 17class AbstractMail;
18 18
19class SMTPwrapper : public Generatemail 19class SMTPwrapper : public Generatemail
20{ 20{
21 Q_OBJECT 21 Q_OBJECT
22 22
23public: 23public:
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
31signals: 32signals:
32 void queuedMails( int ); 33 void queuedMails( int );
33 34
34protected: 35protected:
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
58protected slots: 59protected 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
@@ -1,143 +1,146 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2#include "mailistviewitem.h" 2#include "mailistviewitem.h"
3#include <libmailwrapper/abstractmail.h> 3#include <libmailwrapper/abstractmail.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <kiconloader.h> 5#include <kiconloader.h>
6//#include <qpe/resource.h> 6//#include <qpe/resource.h>
7 7
8MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 8MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
9 :QListViewItem(parent,item),mail_data() 9 :QListViewItem(parent,item),mail_data()
10{ 10{
11} 11}
12 12
13void MailListViewItem::showEntry() 13void 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
107void MailListViewItem::storeData(const RecMailP&data) 110void MailListViewItem::storeData(const RecMailP&data)
108{ 111{
109 mail_data = data; 112 mail_data = data;
110} 113}
111void MailListViewItem::setSortKey(int column,const QString &key) 114void MailListViewItem::setSortKey(int column,const QString &key)
112{ 115{
113 mKeyMap.insert(column,key); 116 mKeyMap.insert(column,key);
114} 117}
115QString MailListViewItem::key(int column, bool) const 118QString 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
134const RecMailP& MailListViewItem::data()const 137const RecMailP& MailListViewItem::data()const
135{ 138{
136 return mail_data; 139 return mail_data;
137} 140}
138 141
139MAILLIB::ATYPE MailListViewItem::wrapperType() 142MAILLIB::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}