summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp40
-rw-r--r--noncore/net/mail/accountview.h1
-rw-r--r--noncore/net/mail/defines.h3
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp19
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h2
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp31
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h1
7 files changed, 83 insertions, 14 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index eea021f..b7de7b9 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,229 +1,244 @@
1#include "accountview.h" 1#include "accountview.h"
2#include <libmailwrapper/mailtypes.h> 2#include <libmailwrapper/mailtypes.h>
3#include <libmailwrapper/abstractmail.h> 3#include <libmailwrapper/abstractmail.h>
4#include "defines.h" 4#include "defines.h"
5#include "newmaildir.h" 5#include "newmaildir.h"
6#include "selectstore.h" 6#include "selectstore.h"
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qpopupmenu.h> 8#include <qpopupmenu.h>
9 9
10#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );}
10/** 11/**
11 * POP3 Account stuff 12 * POP3 Account stuff
12 */ 13 */
13POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) 14POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
14 : AccountViewItem( parent ) 15 : AccountViewItem( parent )
15{ 16{
16 account = a; 17 account = a;
17 wrapper = AbstractMail::getWrapper( account ); 18 wrapper = AbstractMail::getWrapper( account );
18 setPixmap( 0, PIXMAP_POP3FOLDER ); 19 SETPIX(PIXMAP_POP3FOLDER);
20#if 0
21 if (!account->getOffline()) {
22 setPixmap( 0, );
23 } else {
24 setPixmap( 0, PIXMAP_OFFLINE );
25 }
26#endif
19 setText( 0, account->getAccountName() ); 27 setText( 0, account->getAccountName() );
20 setOpen( true ); 28 setOpen( true );
21} 29}
22 30
23POP3viewItem::~POP3viewItem() 31POP3viewItem::~POP3viewItem()
24{ 32{
25 delete wrapper; 33 delete wrapper;
26} 34}
27 35
28AbstractMail *POP3viewItem::getWrapper() 36AbstractMail *POP3viewItem::getWrapper()
29{ 37{
30 return wrapper; 38 return wrapper;
31} 39}
32 40
33void POP3viewItem::refresh( QList<RecMail> & ) 41void POP3viewItem::refresh( QList<RecMail> & )
34{ 42{
43 refresh();
44}
45
46void POP3viewItem::refresh()
47{
35 if (account->getOffline()) return; 48 if (account->getOffline()) return;
36 QList<Folder> *folders = wrapper->listFolders(); 49 QList<Folder> *folders = wrapper->listFolders();
37 QListViewItem *child = firstChild(); 50 QListViewItem *child = firstChild();
38 while ( child ) { 51 while ( child ) {
39 QListViewItem *tmp = child; 52 QListViewItem *tmp = child;
40 child = child->nextSibling(); 53 child = child->nextSibling();
41 delete tmp; 54 delete tmp;
42 } 55 }
43 Folder *it; 56 Folder *it;
44 QListViewItem*item = 0; 57 QListViewItem*item = 0;
45 for ( it = folders->first(); it; it = folders->next() ) { 58 for ( it = folders->first(); it; it = folders->next() ) {
46 item = new POP3folderItem( it, this , item ); 59 item = new POP3folderItem( it, this , item );
47 item->setSelectable(it->may_select()); 60 item->setSelectable(it->may_select());
48 } 61 }
49 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 62 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
50 folders->setAutoDelete(false); 63 folders->setAutoDelete(false);
51 delete folders; 64 delete folders;
52} 65}
53 66
54RecBody POP3viewItem::fetchBody( const RecMail &mail ) 67RecBody POP3viewItem::fetchBody( const RecMail &mail )
55{ 68{
56 qDebug( "POP3 fetchBody" ); 69 qDebug( "POP3 fetchBody" );
57 return wrapper->fetchBody( mail ); 70 return wrapper->fetchBody( mail );
58} 71}
59 72
60QPopupMenu * POP3viewItem::getContextMenu() 73QPopupMenu * POP3viewItem::getContextMenu()
61{ 74{
62 QPopupMenu *m = new QPopupMenu(0); 75 QPopupMenu *m = new QPopupMenu(0);
63 if (m) { 76 if (m) {
64 if (!account->getOffline()) { 77 if (!account->getOffline()) {
65 m->insertItem(QObject::tr("Disconnect",contextName),0); 78 m->insertItem(QObject::tr("Disconnect",contextName),0);
66 m->insertItem(QObject::tr("Set offline",contextName),1); 79 m->insertItem(QObject::tr("Set offline",contextName),1);
67 } else { 80 } else {
68 m->insertItem(QObject::tr("Set online",contextName),1); 81 m->insertItem(QObject::tr("Set online",contextName),1);
69 } 82 }
70 } 83 }
71 return m; 84 return m;
72} 85}
73 86
74void POP3viewItem::disconnect() 87void POP3viewItem::disconnect()
75{ 88{
76 QListViewItem *child = firstChild(); 89 QListViewItem *child = firstChild();
77 while ( child ) { 90 while ( child ) {
78 QListViewItem *tmp = child; 91 QListViewItem *tmp = child;
79 child = child->nextSibling(); 92 child = child->nextSibling();
80 delete tmp; 93 delete tmp;
81 } 94 }
82 wrapper->logout(); 95 wrapper->logout();
83} 96}
84 97
85void POP3viewItem::setOnOffline() 98void POP3viewItem::setOnOffline()
86{ 99{
87 if (!account->getOffline()) { 100 if (!account->getOffline()) {
88 disconnect(); 101 disconnect();
89 } 102 }
90 account->setOffline(!account->getOffline()); 103 account->setOffline(!account->getOffline());
91 account->save(); 104 account->save();
105 SETPIX(PIXMAP_POP3FOLDER);
106 refresh();
92} 107}
93 108
94void POP3viewItem::contextMenuSelected(int which) 109void POP3viewItem::contextMenuSelected(int which)
95{ 110{
96 switch (which) { 111 switch (which) {
97 case 0: 112 case 0:
98 disconnect(); 113 disconnect();
99 break; 114 break;
100 case 1: 115 case 1:
101 setOnOffline(); 116 setOnOffline();
102 break; 117 break;
103 } 118 }
104} 119}
105 120
106POP3folderItem::~POP3folderItem() 121POP3folderItem::~POP3folderItem()
107{ 122{
108 delete folder; 123 delete folder;
109} 124}
110 125
111POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) 126POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after )
112 : AccountViewItem( parent,after ) 127 : AccountViewItem( parent,after )
113{ 128{
114 folder = folderInit; 129 folder = folderInit;
115 pop3 = parent; 130 pop3 = parent;
116 if (folder->getDisplayName().lower()!="inbox") { 131 if (folder->getDisplayName().lower()!="inbox") {
117 setPixmap( 0, PIXMAP_POP3FOLDER ); 132 setPixmap( 0, PIXMAP_POP3FOLDER );
118 } else { 133 } else {
119 setPixmap( 0, PIXMAP_INBOXFOLDER); 134 setPixmap( 0, PIXMAP_INBOXFOLDER);
120 } 135 }
121 setText( 0, folder->getDisplayName() ); 136 setText( 0, folder->getDisplayName() );
122} 137}
123 138
124void POP3folderItem::refresh(QList<RecMail>&target) 139void POP3folderItem::refresh(QList<RecMail>&target)
125{ 140{
126 if (folder->may_select()) 141 if (folder->may_select())
127 pop3->getWrapper()->listMessages( folder->getName(),target ); 142 pop3->getWrapper()->listMessages( folder->getName(),target );
128} 143}
129 144
130RecBody POP3folderItem::fetchBody(const RecMail&aMail) 145RecBody POP3folderItem::fetchBody(const RecMail&aMail)
131{ 146{
132 return pop3->getWrapper()->fetchBody(aMail); 147 return pop3->getWrapper()->fetchBody(aMail);
133} 148}
134 149
135QPopupMenu * POP3folderItem::getContextMenu() 150QPopupMenu * POP3folderItem::getContextMenu()
136{ 151{
137 QPopupMenu *m = new QPopupMenu(0); 152 QPopupMenu *m = new QPopupMenu(0);
138 if (m) { 153 if (m) {
139 m->insertItem(QObject::tr("Refresh header list",contextName),0); 154 m->insertItem(QObject::tr("Refresh header list",contextName),0);
140 m->insertItem(QObject::tr("Delete all mails",contextName),1); 155 m->insertItem(QObject::tr("Delete all mails",contextName),1);
141 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); 156 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
142 } 157 }
143 return m; 158 return m;
144} 159}
145 160
146void POP3folderItem::downloadMails() 161void POP3folderItem::downloadMails()
147{ 162{
148 AccountView*bl = pop3->accountView(); 163 AccountView*bl = pop3->accountView();
149 if (!bl) return; 164 if (!bl) return;
150 bl->downloadMails(folder,pop3->getWrapper()); 165 bl->downloadMails(folder,pop3->getWrapper());
151} 166}
152 167
153void POP3folderItem::contextMenuSelected(int which) 168void POP3folderItem::contextMenuSelected(int which)
154{ 169{
155 AccountView * view = (AccountView*)listView(); 170 AccountView * view = (AccountView*)listView();
156 switch (which) { 171 switch (which) {
157 case 0: 172 case 0:
158 /* must be 'cause pop3 lists are cached */ 173 /* must be 'cause pop3 lists are cached */
159 pop3->getWrapper()->logout(); 174 pop3->getWrapper()->logout();
160 view->refreshCurrent(); 175 view->refreshCurrent();
161 break; 176 break;
162 case 1: 177 case 1:
163 deleteAllMail(pop3->getWrapper(),folder); 178 deleteAllMail(pop3->getWrapper(),folder);
164 break; 179 break;
165 case 2: 180 case 2:
166 downloadMails(); 181 downloadMails();
167 break; 182 break;
168 default: 183 default:
169 break; 184 break;
170 } 185 }
171} 186}
172 187
173/** 188/**
174 * IMAP Account stuff 189 * IMAP Account stuff
175 */ 190 */
176IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) 191IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
177 : AccountViewItem( parent ) 192 : AccountViewItem( parent )
178{ 193{
179 account = a; 194 account = a;
180 wrapper = AbstractMail::getWrapper( account ); 195 wrapper = AbstractMail::getWrapper( account );
181 setPixmap( 0, PIXMAP_IMAPFOLDER ); 196 SETPIX(PIXMAP_IMAPFOLDER);
182 setText( 0, account->getAccountName() ); 197 setText( 0, account->getAccountName() );
183 setOpen( true ); 198 setOpen( true );
184} 199}
185 200
186IMAPviewItem::~IMAPviewItem() 201IMAPviewItem::~IMAPviewItem()
187{ 202{
188 delete wrapper; 203 delete wrapper;
189} 204}
190 205
191AbstractMail *IMAPviewItem::getWrapper() 206AbstractMail *IMAPviewItem::getWrapper()
192{ 207{
193 return wrapper; 208 return wrapper;
194} 209}
195 210
196IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) 211IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start)
197{ 212{
198 IMAPfolderItem*pitem,*sitem; 213 IMAPfolderItem*pitem,*sitem;
199 if (!start) pitem = (IMAPfolderItem*)firstChild(); 214 if (!start) pitem = (IMAPfolderItem*)firstChild();
200 else pitem = (IMAPfolderItem*)start->firstChild(); 215 else pitem = (IMAPfolderItem*)start->firstChild();
201 while (pitem) { 216 while (pitem) {
202 if (pitem->matchName(path)) { 217 if (pitem->matchName(path)) {
203 break; 218 break;
204 } 219 }
205 if (pitem->childCount()>0) { 220 if (pitem->childCount()>0) {
206 sitem = findSubItem(path,pitem); 221 sitem = findSubItem(path,pitem);
207 if (sitem) { 222 if (sitem) {
208 pitem = sitem; 223 pitem = sitem;
209 break; 224 break;
210 } 225 }
211 } 226 }
212 pitem=(IMAPfolderItem*)pitem->nextSibling(); 227 pitem=(IMAPfolderItem*)pitem->nextSibling();
213 } 228 }
214 return pitem; 229 return pitem;
215} 230}
216 231
217void IMAPviewItem::refresh(QList<RecMail>&) 232void IMAPviewItem::refresh(QList<RecMail>&)
218{ 233{
219 refreshFolders(false); 234 refreshFolders(false);
220} 235}
221 236
222void IMAPviewItem::removeChilds() 237void IMAPviewItem::removeChilds()
223{ 238{
224 QListViewItem *child = firstChild(); 239 QListViewItem *child = firstChild();
225 while ( child ) { 240 while ( child ) {
226 QListViewItem *tmp = child; 241 QListViewItem *tmp = child;
227 child = child->nextSibling(); 242 child = child->nextSibling();
228 delete tmp; 243 delete tmp;
229 } 244 }
@@ -292,96 +307,97 @@ QPopupMenu * IMAPviewItem::getContextMenu()
292 m->insertItem(QObject::tr("Disconnect",contextName),2); 307 m->insertItem(QObject::tr("Disconnect",contextName),2);
293 m->insertItem(QObject::tr("Set offline",contextName),3); 308 m->insertItem(QObject::tr("Set offline",contextName),3);
294 } else { 309 } else {
295 m->insertItem(QObject::tr("Set online",contextName),3); 310 m->insertItem(QObject::tr("Set online",contextName),3);
296 } 311 }
297 } 312 }
298 return m; 313 return m;
299} 314}
300 315
301void IMAPviewItem::createNewFolder() 316void IMAPviewItem::createNewFolder()
302{ 317{
303 Newmdirdlg ndirdlg; 318 Newmdirdlg ndirdlg;
304 ndirdlg.showMaximized(); 319 ndirdlg.showMaximized();
305 if (ndirdlg.exec()) { 320 if (ndirdlg.exec()) {
306 QString ndir = ndirdlg.Newdir(); 321 QString ndir = ndirdlg.Newdir();
307 bool makesubs = ndirdlg.subpossible(); 322 bool makesubs = ndirdlg.subpossible();
308 QString delemiter = "/"; 323 QString delemiter = "/";
309 IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); 324 IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
310 if (item) { 325 if (item) {
311 delemiter = item->Delemiter(); 326 delemiter = item->Delemiter();
312 } 327 }
313 if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { 328 if (wrapper->createMbox(ndir,0,delemiter,makesubs)) {
314 refreshFolders(true); 329 refreshFolders(true);
315 } 330 }
316 } 331 }
317} 332}
318 333
319void IMAPviewItem::contextMenuSelected(int id) 334void IMAPviewItem::contextMenuSelected(int id)
320{ 335{
321 qDebug("Id selected: %i",id); 336 qDebug("Id selected: %i",id);
322 switch (id) { 337 switch (id) {
323 case 0: 338 case 0:
324 refreshFolders(true); 339 refreshFolders(true);
325 break; 340 break;
326 case 1: 341 case 1:
327 createNewFolder(); 342 createNewFolder();
328 break; 343 break;
329 case 2: 344 case 2:
330 removeChilds(); 345 removeChilds();
331 wrapper->logout(); 346 wrapper->logout();
332 break; 347 break;
333 case 3: 348 case 3:
334 if (account->getOffline()==false) { 349 if (account->getOffline()==false) {
335 removeChilds(); 350 removeChilds();
336 wrapper->logout(); 351 wrapper->logout();
337 } 352 }
338 account->setOffline(!account->getOffline()); 353 account->setOffline(!account->getOffline());
339 account->save(); 354 account->save();
355 SETPIX(PIXMAP_IMAPFOLDER);
340 refreshFolders(false); 356 refreshFolders(false);
341 break; 357 break;
342 default: 358 default:
343 break; 359 break;
344 } 360 }
345} 361}
346 362
347RecBody IMAPviewItem::fetchBody(const RecMail&) 363RecBody IMAPviewItem::fetchBody(const RecMail&)
348{ 364{
349 return RecBody(); 365 return RecBody();
350} 366}
351 367
352bool IMAPviewItem::offline() 368bool IMAPviewItem::offline()
353{ 369{
354 return account->getOffline(); 370 return account->getOffline();
355} 371}
356 372
357IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) 373IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
358 : AccountViewItem( parent , after ) 374 : AccountViewItem( parent , after )
359{ 375{
360 folder = folderInit; 376 folder = folderInit;
361 imap = parent; 377 imap = parent;
362 if (folder->getDisplayName().lower()!="inbox") { 378 if (folder->getDisplayName().lower()!="inbox") {
363 setPixmap( 0, PIXMAP_IMAPFOLDER ); 379 setPixmap( 0, PIXMAP_IMAPFOLDER );
364 } else { 380 } else {
365 setPixmap( 0, PIXMAP_INBOXFOLDER); 381 setPixmap( 0, PIXMAP_INBOXFOLDER);
366 } 382 }
367 setText( 0, folder->getDisplayName() ); 383 setText( 0, folder->getDisplayName() );
368} 384}
369 385
370IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 386IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
371 : AccountViewItem( parent,after ) 387 : AccountViewItem( parent,after )
372{ 388{
373 folder = folderInit; 389 folder = folderInit;
374 imap = master; 390 imap = master;
375 if (folder->getDisplayName().lower()!="inbox") { 391 if (folder->getDisplayName().lower()!="inbox") {
376 setPixmap( 0, PIXMAP_IMAPFOLDER ); 392 setPixmap( 0, PIXMAP_IMAPFOLDER );
377 } else { 393 } else {
378 setPixmap( 0, PIXMAP_INBOXFOLDER); 394 setPixmap( 0, PIXMAP_INBOXFOLDER);
379 } 395 }
380 setText( 0, folder->getDisplayName() ); 396 setText( 0, folder->getDisplayName() );
381} 397}
382 398
383IMAPfolderItem::~IMAPfolderItem() 399IMAPfolderItem::~IMAPfolderItem()
384{ 400{
385 delete folder; 401 delete folder;
386} 402}
387 403
@@ -620,120 +636,116 @@ void AccountView::refresh(QListViewItem *item) {
620 emit refreshMailview(&headerlist); 636 emit refreshMailview(&headerlist);
621 } 637 }
622} 638}
623 639
624void AccountView::refreshCurrent() 640void AccountView::refreshCurrent()
625{ 641{
626 m_currentItem = currentItem(); 642 m_currentItem = currentItem();
627 if ( !m_currentItem ) return; 643 if ( !m_currentItem ) return;
628 QList<RecMail> headerlist; 644 QList<RecMail> headerlist;
629 headerlist.setAutoDelete(true); 645 headerlist.setAutoDelete(true);
630 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 646 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
631 view->refresh(headerlist); 647 view->refresh(headerlist);
632 emit refreshMailview(&headerlist); 648 emit refreshMailview(&headerlist);
633} 649}
634 650
635void AccountView::refreshAll() 651void AccountView::refreshAll()
636{ 652{
637 653
638} 654}
639 655
640RecBody AccountView::fetchBody(const RecMail&aMail) 656RecBody AccountView::fetchBody(const RecMail&aMail)
641{ 657{
642 QListViewItem*item = selectedItem (); 658 QListViewItem*item = selectedItem ();
643 if (!item) return RecBody(); 659 if (!item) return RecBody();
644 AccountViewItem *view = static_cast<AccountViewItem *>(item); 660 AccountViewItem *view = static_cast<AccountViewItem *>(item);
645 return view->fetchBody(aMail); 661 return view->fetchBody(aMail);
646} 662}
647 663
648void AccountView::setupFolderselect(Selectstore*sels) 664void AccountView::setupFolderselect(Selectstore*sels)
649{ 665{
650 sels->showMaximized(); 666 sels->showMaximized();
651 QStringList sFolders; 667 QStringList sFolders;
652 unsigned int i = 0; 668 unsigned int i = 0;
653 for (i=0; i < mboxAccounts.count();++i) { 669 for (i=0; i < mboxAccounts.count();++i) {
654 mboxAccounts[i]->refresh(false); 670 mboxAccounts[i]->refresh(false);
655 sFolders = mboxAccounts[i]->subFolders(); 671 sFolders = mboxAccounts[i]->subFolders();
656 sels->addAccounts(mboxAccounts[i]->getWrapper(),sFolders); 672 sels->addAccounts(mboxAccounts[i]->getWrapper(),sFolders);
657 } 673 }
658 for (i=0; i < imapAccounts.count();++i) { 674 for (i=0; i < imapAccounts.count();++i) {
659 if (imapAccounts[i]->offline()) 675 if (imapAccounts[i]->offline())
660 continue; 676 continue;
661 imapAccounts[i]->refreshFolders(false); 677 imapAccounts[i]->refreshFolders(false);
662 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 678 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
663 } 679 }
664} 680}
665 681
666void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) 682void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper)
667{ 683{
668 unsigned int i = 0;
669 AbstractMail*targetMail = 0; 684 AbstractMail*targetMail = 0;
670 QString targetFolder = ""; 685 QString targetFolder = "";
671 Selectstore sels; 686 Selectstore sels;
672 setupFolderselect(&sels); 687 setupFolderselect(&sels);
673 if (!sels.exec()) return; 688 if (!sels.exec()) return;
674 targetMail = sels.currentMail(); 689 targetMail = sels.currentMail();
675 targetFolder = sels.currentFolder(); 690 targetFolder = sels.currentFolder();
676 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 691 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
677 targetFolder.isEmpty()) { 692 targetFolder.isEmpty()) {
678 return; 693 return;
679 } 694 }
680 695 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) {
681 QList<RecMail> t; 696 QMessageBox::critical(0,tr("Error creating new Folder"),
682 fromWrapper->listMessages(fromFolder->getName(),t); 697 tr("<center>Error while creating<br>new folder - breaking.</center>"));
683 encodedString*st = 0; 698 return;
684 for (i = 0; i < t.count();++i) {
685 RecMail*r = t.at(i);
686 st = fromWrapper->fetchRawBody(*r);
687 if (st) {
688 targetMail->storeMessage(st->Content(),st->Length(),targetFolder);
689 delete st;
690 }
691 } 699 }
700 qDebug("Targetfolder: %s",targetFolder.latin1());
701 qDebug("Fromfolder: %s",fromFolder->getName().latin1());
702 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails());
703 refreshCurrent();
692} 704}
693 705
694/** 706/**
695 * MBOX Account stuff 707 * MBOX Account stuff
696 */ 708 */
697 709
698MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent ) 710MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent )
699 : AccountViewItem( parent ) 711 : AccountViewItem( parent )
700{ 712{
701 m_Path = aPath; 713 m_Path = aPath;
702 /* be carefull - the space within settext is wanted - thats why the string twice */ 714 /* be carefull - the space within settext is wanted - thats why the string twice */
703 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); 715 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders");
704 setPixmap( 0, PIXMAP_LOCALFOLDER ); 716 setPixmap( 0, PIXMAP_LOCALFOLDER );
705 setText( 0, " Local Folders" ); 717 setText( 0, " Local Folders" );
706 setOpen( true ); 718 setOpen( true );
707} 719}
708 720
709MBOXviewItem::~MBOXviewItem() 721MBOXviewItem::~MBOXviewItem()
710{ 722{
711 delete wrapper; 723 delete wrapper;
712} 724}
713 725
714AbstractMail *MBOXviewItem::getWrapper() 726AbstractMail *MBOXviewItem::getWrapper()
715{ 727{
716 return wrapper; 728 return wrapper;
717} 729}
718 730
719void MBOXviewItem::refresh( QList<RecMail> & ) 731void MBOXviewItem::refresh( QList<RecMail> & )
720{ 732{
721 refresh(false); 733 refresh(false);
722} 734}
723 735
724void MBOXviewItem::refresh(bool force) 736void MBOXviewItem::refresh(bool force)
725{ 737{
726 if (childCount()>0 && force==false) return; 738 if (childCount()>0 && force==false) return;
727 QList<Folder> *folders = wrapper->listFolders(); 739 QList<Folder> *folders = wrapper->listFolders();
728 QListViewItem *child = firstChild(); 740 QListViewItem *child = firstChild();
729 while ( child ) { 741 while ( child ) {
730 QListViewItem *tmp = child; 742 QListViewItem *tmp = child;
731 child = child->nextSibling(); 743 child = child->nextSibling();
732 delete tmp; 744 delete tmp;
733 } 745 }
734 Folder *it; 746 Folder *it;
735 QListViewItem*item = 0; 747 QListViewItem*item = 0;
736 for ( it = folders->first(); it; it = folders->next() ) { 748 for ( it = folders->first(); it; it = folders->next() ) {
737 item = new MBOXfolderItem( it, this , item ); 749 item = new MBOXfolderItem( it, this , item );
738 item->setSelectable(it->may_select()); 750 item->setSelectable(it->may_select());
739 } 751 }
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 48f52c7..df916c1 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -3,96 +3,97 @@
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7#include <libmailwrapper/settings.h> 7#include <libmailwrapper/settings.h>
8#include <libmailwrapper/mailwrapper.h> 8#include <libmailwrapper/mailwrapper.h>
9#include <libmailwrapper/abstractmail.h> 9#include <libmailwrapper/abstractmail.h>
10 10
11class POP3wrapper; 11class POP3wrapper;
12class RecMail; 12class RecMail;
13class RecBody; 13class RecBody;
14class QPopupMenu; 14class QPopupMenu;
15class Selectstore; 15class Selectstore;
16class AccountView; 16class AccountView;
17 17
18class AccountViewItem : public QListViewItem 18class AccountViewItem : public QListViewItem
19{ 19{
20 20
21public: 21public:
22 AccountViewItem( AccountView *parent ); 22 AccountViewItem( AccountView *parent );
23 AccountViewItem( QListViewItem *parent); 23 AccountViewItem( QListViewItem *parent);
24 AccountViewItem( QListViewItem *parent , QListViewItem*after ); 24 AccountViewItem( QListViewItem *parent , QListViewItem*after );
25 virtual ~AccountViewItem(); 25 virtual ~AccountViewItem();
26 virtual void refresh(QList<RecMail>&)=0; 26 virtual void refresh(QList<RecMail>&)=0;
27 virtual RecBody fetchBody(const RecMail&)=0; 27 virtual RecBody fetchBody(const RecMail&)=0;
28 virtual QPopupMenu * getContextMenu(){return 0;}; 28 virtual QPopupMenu * getContextMenu(){return 0;};
29 virtual void contextMenuSelected(int){} 29 virtual void contextMenuSelected(int){}
30 virtual AccountView*accountView(); 30 virtual AccountView*accountView();
31protected: 31protected:
32 virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); 32 virtual void deleteAllMail(AbstractMail*wrapper,Folder*f);
33 static const QString contextName; 33 static const QString contextName;
34 AccountView*m_Backlink; 34 AccountView*m_Backlink;
35}; 35};
36 36
37class POP3viewItem : public AccountViewItem 37class POP3viewItem : public AccountViewItem
38{ 38{
39 39
40public: 40public:
41 POP3viewItem( POP3account *a, AccountView *parent ); 41 POP3viewItem( POP3account *a, AccountView *parent );
42 virtual ~POP3viewItem(); 42 virtual ~POP3viewItem();
43 virtual void refresh( QList<RecMail> &target ); 43 virtual void refresh( QList<RecMail> &target );
44 virtual RecBody fetchBody( const RecMail &mail ); 44 virtual RecBody fetchBody( const RecMail &mail );
45 AbstractMail *getWrapper(); 45 AbstractMail *getWrapper();
46 virtual QPopupMenu * getContextMenu(); 46 virtual QPopupMenu * getContextMenu();
47 virtual void contextMenuSelected(int); 47 virtual void contextMenuSelected(int);
48 48
49protected: 49protected:
50 POP3account *account; 50 POP3account *account;
51 virtual void refresh();
51 AbstractMail *wrapper; 52 AbstractMail *wrapper;
52 void disconnect(); 53 void disconnect();
53 void setOnOffline(); 54 void setOnOffline();
54}; 55};
55 56
56class POP3folderItem : public AccountViewItem 57class POP3folderItem : public AccountViewItem
57{ 58{
58 59
59public: 60public:
60 POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); 61 POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
61 virtual ~POP3folderItem(); 62 virtual ~POP3folderItem();
62 virtual void refresh(QList<RecMail>&); 63 virtual void refresh(QList<RecMail>&);
63 virtual RecBody fetchBody(const RecMail&); 64 virtual RecBody fetchBody(const RecMail&);
64 virtual QPopupMenu * getContextMenu(); 65 virtual QPopupMenu * getContextMenu();
65 virtual void contextMenuSelected(int); 66 virtual void contextMenuSelected(int);
66 67
67protected: 68protected:
68 void downloadMails(); 69 void downloadMails();
69 Folder *folder; 70 Folder *folder;
70 POP3viewItem *pop3; 71 POP3viewItem *pop3;
71}; 72};
72 73
73class IMAPfolderItem; 74class IMAPfolderItem;
74 75
75class IMAPviewItem : public AccountViewItem 76class IMAPviewItem : public AccountViewItem
76{ 77{
77 friend class IMAPfolderItem; 78 friend class IMAPfolderItem;
78public: 79public:
79 IMAPviewItem( IMAPaccount *a, AccountView *parent ); 80 IMAPviewItem( IMAPaccount *a, AccountView *parent );
80 virtual ~IMAPviewItem(); 81 virtual ~IMAPviewItem();
81 virtual void refresh(QList<RecMail>&); 82 virtual void refresh(QList<RecMail>&);
82 virtual RecBody fetchBody(const RecMail&); 83 virtual RecBody fetchBody(const RecMail&);
83 AbstractMail *getWrapper(); 84 AbstractMail *getWrapper();
84 virtual QPopupMenu * getContextMenu(); 85 virtual QPopupMenu * getContextMenu();
85 virtual void contextMenuSelected(int); 86 virtual void contextMenuSelected(int);
86 const QStringList&subFolders(); 87 const QStringList&subFolders();
87 virtual void refreshFolders(bool force=false); 88 virtual void refreshFolders(bool force=false);
88 bool offline(); 89 bool offline();
89 90
90protected: 91protected:
91 IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); 92 IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0);
92 virtual void createNewFolder(); 93 virtual void createNewFolder();
93 virtual void removeChilds(); 94 virtual void removeChilds();
94 IMAPaccount *account; 95 IMAPaccount *account;
95 AbstractMail *wrapper; 96 AbstractMail *wrapper;
96 QStringList currentFolders; 97 QStringList currentFolders;
97}; 98};
98 99
diff --git a/noncore/net/mail/defines.h b/noncore/net/mail/defines.h
index ebe8e08..d840f09 100644
--- a/noncore/net/mail/defines.h
+++ b/noncore/net/mail/defines.h
@@ -1,54 +1,57 @@
1#ifndef DEFINE_CONSTANTS_H 1#ifndef DEFINE_CONSTANTS_H
2#define DEFINE_CONSTANTS_H 2#define DEFINE_CONSTANTS_H
3 3
4#include <qpe/resource.h> 4#include <qpe/resource.h>
5 5
6#define USER_AGENT "OpieMail v0.3" 6#define USER_AGENT "OpieMail v0.3"
7 7
8#define PIC_COMPOSEMAIL "mail/composemail" 8#define PIC_COMPOSEMAIL "mail/composemail"
9#define PIC_SENDQUEUED "mail/sendqueued" 9#define PIC_SENDQUEUED "mail/sendqueued"
10#define PIC_SHOWFOLDERS "mail/showfolders" 10#define PIC_SHOWFOLDERS "mail/showfolders"
11#define PIC_SYNC "mail/sync" 11#define PIC_SYNC "mail/sync"
12#define PIC_IMAPFOLDER "mail/imapfolder" 12#define PIC_IMAPFOLDER "mail/imapfolder"
13#define PIC_MBOXFOLDER "mail/mboxfolder" 13#define PIC_MBOXFOLDER "mail/mboxfolder"
14#define PIC_POP3FOLDER "mail/pop3folder" 14#define PIC_POP3FOLDER "mail/pop3folder"
15#define PIC_INBOXFOLDER "mail/inbox" 15#define PIC_INBOXFOLDER "mail/inbox"
16#define PIC_OUTBOXFOLDER "mail/outbox" 16#define PIC_OUTBOXFOLDER "mail/outbox"
17#define PIC_LOCALFOLDER "mail/localfolder" 17#define PIC_LOCALFOLDER "mail/localfolder"
18 18
19#define PIC_OFFLINE "mail/notconnected"
20
19#define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) 21#define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) )
20#define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) 22#define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) )
21#define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) 23#define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) )
22#define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) 24#define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) )
23#define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) 25#define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) )
24#define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) 26#define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) )
25#define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) 27#define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) )
26 28
27#define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) 29#define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) )
28#define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) 30#define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) )
29#define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) ) 31#define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) )
30#define PIXMAP_MBOXFOLDER QPixmap( Resource::loadPixmap( PIC_MBOXFOLDER ) ) 32#define PIXMAP_MBOXFOLDER QPixmap( Resource::loadPixmap( PIC_MBOXFOLDER ) )
31#define PIXMAP_OUTBOXFOLDER QPixmap( Resource::loadPixmap( PIC_OUTBOXFOLDER) ) 33#define PIXMAP_OUTBOXFOLDER QPixmap( Resource::loadPixmap( PIC_OUTBOXFOLDER) )
32#define PIXMAP_LOCALFOLDER QPixmap( Resource::loadPixmap( PIC_LOCALFOLDER) ) 34#define PIXMAP_LOCALFOLDER QPixmap( Resource::loadPixmap( PIC_LOCALFOLDER) )
35#define PIXMAP_OFFLINE QPixmap( Resource::loadPixmap( PIC_OFFLINE) )
33 36
34#define IMAP_PORT "143" 37#define IMAP_PORT "143"
35#define IMAP_SSL_PORT "993" 38#define IMAP_SSL_PORT "993"
36#define SMTP_PORT "25" 39#define SMTP_PORT "25"
37#define SMTP_SSL_PORT "465" 40#define SMTP_SSL_PORT "465"
38#define POP3_PORT "110" 41#define POP3_PORT "110"
39#define POP3_SSL_PORT "995" 42#define POP3_SSL_PORT "995"
40#define NNTP_PORT "119" 43#define NNTP_PORT "119"
41#define NNTP_SSL_PORT "563" 44#define NNTP_SSL_PORT "563"
42 45
43/* used for decoding imapfoldername */ 46/* used for decoding imapfoldername */
44#define UNDEFINED 64 47#define UNDEFINED 64
45#define MAXLINE 76 48#define MAXLINE 76
46#define UTF16MASK 0x03FFUL 49#define UTF16MASK 0x03FFUL
47#define UTF16SHIFT 10 50#define UTF16SHIFT 10
48#define UTF16BASE 0x10000UL 51#define UTF16BASE 0x10000UL
49#define UTF16HIGHSTART 0xD800UL 52#define UTF16HIGHSTART 0xD800UL
50#define UTF16HIGHEND 0xDBFFUL 53#define UTF16HIGHEND 0xDBFFUL
51#define UTF16LOSTART 0xDC00UL 54#define UTF16LOSTART 0xDC00UL
52#define UTF16LOEND 0xDFFFUL 55#define UTF16LOEND 0xDFFFUL
53 56
54#endif 57#endif
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 3dd2fce..4b4c728 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -59,48 +59,67 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin
59QString AbstractMail::convert_String(const char*text) 59QString AbstractMail::convert_String(const char*text)
60{ 60{
61 size_t index = 0; 61 size_t index = 0;
62 char*res = 0; 62 char*res = 0;
63 63
64 /* attention - doesn't work with arm systems! */ 64 /* attention - doesn't work with arm systems! */
65 int err = mailmime_encoded_phrase_parse("iso-8859-1", 65 int err = mailmime_encoded_phrase_parse("iso-8859-1",
66 text, strlen(text),&index, "iso-8859-1",&res); 66 text, strlen(text),&index, "iso-8859-1",&res);
67 if (err != MAILIMF_NO_ERROR) { 67 if (err != MAILIMF_NO_ERROR) {
68 if (res) free(res); 68 if (res) free(res);
69 return QString(text); 69 return QString(text);
70 } 70 }
71 if (res) { 71 if (res) {
72 QString result(res); 72 QString result(res);
73 free(res); 73 free(res);
74 return result; 74 return result;
75 } 75 }
76 return QString(text); 76 return QString(text);
77} 77}
78 78
79/* cp & paste from launcher */ 79/* cp & paste from launcher */
80QString AbstractMail::gen_attachment_id() 80QString AbstractMail::gen_attachment_id()
81{ 81{
82 QFile file( "/proc/sys/kernel/random/uuid" ); 82 QFile file( "/proc/sys/kernel/random/uuid" );
83 if (!file.open(IO_ReadOnly ) ) 83 if (!file.open(IO_ReadOnly ) )
84 return QString::null; 84 return QString::null;
85 85
86 QTextStream stream(&file); 86 QTextStream stream(&file);
87 87
88 return "{" + stream.read().stripWhiteSpace() + "}"; 88 return "{" + stream.read().stripWhiteSpace() + "}";
89} 89}
90 90
91int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) 91int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool)
92{ 92{
93 return 0; 93 return 0;
94} 94}
95 95
96QString AbstractMail::defaultLocalfolder() 96QString AbstractMail::defaultLocalfolder()
97{ 97{
98 QString f = getenv( "HOME" ); 98 QString f = getenv( "HOME" );
99 f += "/Applications/opiemail/localmail"; 99 f += "/Applications/opiemail/localmail";
100 return f; 100 return f;
101} 101}
102 102
103/* temporary - will be removed when implemented in all classes */ 103/* temporary - will be removed when implemented in all classes */
104void AbstractMail::deleteMails(const QString &,QList<RecMail> &) 104void AbstractMail::deleteMails(const QString &,QList<RecMail> &)
105{ 105{
106} 106}
107
108void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
109{
110 QList<RecMail> t;
111 listMessages(fromFolder->getName(),t);
112 encodedString*st = 0;
113 while (t.count()>0) {
114 RecMail*r = t.at(0);
115 st = fetchRawBody(*r);
116 if (st) {
117 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
118 delete st;
119 }
120 t.removeFirst();
121 }
122 if (moveit) {
123 deleteAllMail(fromFolder);
124 }
125}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 15d83cb..8debaae 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -1,62 +1,64 @@
1#ifndef __abstract_mail_ 1#ifndef __abstract_mail_
2#define __abstract_mail_ 2#define __abstract_mail_
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include "settings.h" 5#include "settings.h"
6 6
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9class RecPart; 9class RecPart;
10class IMAPwrapper; 10class IMAPwrapper;
11class POP3wrapper; 11class POP3wrapper;
12class Folder; 12class Folder;
13class encodedString; 13class encodedString;
14struct folderStat; 14struct folderStat;
15 15
16class AbstractMail:public QObject 16class AbstractMail:public QObject
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19public: 19public:
20 AbstractMail(){}; 20 AbstractMail(){};
21 virtual ~AbstractMail(){} 21 virtual ~AbstractMail(){}
22 virtual QList<Folder>* listFolders()=0; 22 virtual QList<Folder>* listFolders()=0;
23 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; 23 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
24 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; 24 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0;
25 virtual RecBody fetchBody(const RecMail&mail)=0; 25 virtual RecBody fetchBody(const RecMail&mail)=0;
26 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; 26 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
27 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; 27 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
28 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; 28 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
29 virtual encodedString* fetchRawBody(const RecMail&mail)=0; 29 virtual encodedString* fetchRawBody(const RecMail&mail)=0;
30 30
31 virtual void deleteMail(const RecMail&mail)=0; 31 virtual void deleteMail(const RecMail&mail)=0;
32 virtual void answeredMail(const RecMail&mail)=0; 32 virtual void answeredMail(const RecMail&mail)=0;
33 virtual int deleteAllMail(const Folder*)=0; 33 virtual int deleteAllMail(const Folder*)=0;
34 virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); 34 virtual void deleteMails(const QString & FolderName,QList<RecMail> &target);
35 virtual int deleteMbox(const Folder*)=0; 35 virtual int deleteMbox(const Folder*)=0;
36 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; 36 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
37 37
38 virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
39
38 virtual void cleanMimeCache(){}; 40 virtual void cleanMimeCache(){};
39 /* mail box methods */ 41 /* mail box methods */
40 /* parameter is the box to create. 42 /* parameter is the box to create.
41 * if the implementing subclass has prefixes, 43 * if the implementing subclass has prefixes,
42 * them has to be appended automatic. 44 * them has to be appended automatic.
43 */ 45 */
44 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); 46 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
45 virtual void logout()=0; 47 virtual void logout()=0;
46 48
47 static AbstractMail* getWrapper(IMAPaccount *a); 49 static AbstractMail* getWrapper(IMAPaccount *a);
48 static AbstractMail* getWrapper(POP3account *a); 50 static AbstractMail* getWrapper(POP3account *a);
49 /* mbox only! */ 51 /* mbox only! */
50 static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); 52 static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders");
51 53
52 static QString defaultLocalfolder(); 54 static QString defaultLocalfolder();
53 55
54 virtual const QString&getType()const=0; 56 virtual const QString&getType()const=0;
55 virtual const QString&getName()const=0; 57 virtual const QString&getName()const=0;
56 58
57protected: 59protected:
58 static encodedString*decode_String(const encodedString*text,const QString&enc); 60 static encodedString*decode_String(const encodedString*text,const QString&enc);
59 static QString convert_String(const char*text); 61 static QString convert_String(const char*text);
60 static QString gen_attachment_id(); 62 static QString gen_attachment_id();
61}; 63};
62#endif 64#endif
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index bb74de9..23c678b 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -964,57 +964,88 @@ void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
964 att_list = mailimap_status_att_list_new_empty(); 964 att_list = mailimap_status_att_list_new_empty();
965 if (!att_list) return; 965 if (!att_list) return;
966 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); 966 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES);
967 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); 967 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT);
968 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); 968 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN);
969 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); 969 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status);
970 if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { 970 if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) {
971 for (cur = clist_begin(status->st_info_list); 971 for (cur = clist_begin(status->st_info_list);
972 cur != NULL ; cur = clist_next(cur)) { 972 cur != NULL ; cur = clist_next(cur)) {
973 mailimap_status_info * status_info; 973 mailimap_status_info * status_info;
974 status_info = (mailimap_status_info *)clist_content(cur); 974 status_info = (mailimap_status_info *)clist_content(cur);
975 switch (status_info->st_att) { 975 switch (status_info->st_att) {
976 case MAILIMAP_STATUS_ATT_MESSAGES: 976 case MAILIMAP_STATUS_ATT_MESSAGES:
977 target_stat.message_count = status_info->st_value; 977 target_stat.message_count = status_info->st_value;
978 break; 978 break;
979 case MAILIMAP_STATUS_ATT_RECENT: 979 case MAILIMAP_STATUS_ATT_RECENT:
980 target_stat.message_recent = status_info->st_value; 980 target_stat.message_recent = status_info->st_value;
981 break; 981 break;
982 case MAILIMAP_STATUS_ATT_UNSEEN: 982 case MAILIMAP_STATUS_ATT_UNSEEN:
983 target_stat.message_unseen = status_info->st_value; 983 target_stat.message_unseen = status_info->st_value;
984 break; 984 break;
985 } 985 }
986 } 986 }
987 } else { 987 } else {
988 qDebug("Error retrieving status"); 988 qDebug("Error retrieving status");
989 } 989 }
990 if (status) mailimap_mailbox_data_status_free(status); 990 if (status) mailimap_mailbox_data_status_free(status);
991 if (att_list) mailimap_status_att_list_free(att_list); 991 if (att_list) mailimap_status_att_list_free(att_list);
992} 992}
993 993
994void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) 994void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
995{ 995{
996 login(); 996 login();
997 if (!m_imap) return; 997 if (!m_imap) return;
998 if (!msg) return; 998 if (!msg) return;
999 int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); 999 int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length);
1000 if (r != MAILIMAP_NO_ERROR) { 1000 if (r != MAILIMAP_NO_ERROR) {
1001 Global::statusMessage("Error storing mail!"); 1001 Global::statusMessage("Error storing mail!");
1002 } 1002 }
1003} 1003}
1004 1004
1005const QString&IMAPwrapper::getType()const 1005const QString&IMAPwrapper::getType()const
1006{ 1006{
1007 return account->getType(); 1007 return account->getType();
1008} 1008}
1009 1009
1010const QString&IMAPwrapper::getName()const 1010const QString&IMAPwrapper::getName()const
1011{ 1011{
1012 qDebug("Get name: %s",account->getAccountName().latin1());
1012 return account->getAccountName(); 1013 return account->getAccountName();
1013} 1014}
1014 1015
1015encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) 1016encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail)
1016{ 1017{
1017 // dummy 1018 // dummy
1018 QValueList<int> path; 1019 QValueList<int> path;
1019 return fetchRawPart(mail,path,false); 1020 return fetchRawPart(mail,path,false);
1020} 1021}
1022
1023void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
1024{
1025 qDebug("mvcp mail imap");
1026 if (targetWrapper != this) {
1027 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
1028 qDebug("Using generic");
1029 return;
1030 }
1031 qDebug("Using internal");
1032 mailimap_set *set = 0;
1033
1034 int err = mailimap_select( m_imap, fromFolder->getName().latin1());
1035 if ( err != MAILIMAP_NO_ERROR ) {
1036 Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response));
1037 return;
1038 }
1039
1040 int last = m_imap->imap_selection_info->sel_exists;
1041 set = mailimap_set_new_interval( 1, last );
1042 err = mailimap_copy(m_imap,set,targetFolder.latin1());
1043 if ( err != MAILIMAP_NO_ERROR ) {
1044 Global::statusMessage(tr("error copy mails: %1").arg(m_imap->imap_response));
1045 return;
1046 }
1047 mailimap_set_free( set );
1048 if (moveit) {
1049 deleteAllMail(fromFolder);
1050 }
1051}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index b2bd7e9..07c6210 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -1,73 +1,74 @@
1#ifndef __IMAPWRAPPER 1#ifndef __IMAPWRAPPER
2#define __IMAPWRAPPER 2#define __IMAPWRAPPER
3 3
4#include <qlist.h> 4#include <qlist.h>
5#include "mailwrapper.h" 5#include "mailwrapper.h"
6#include "abstractmail.h" 6#include "abstractmail.h"
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8 8
9struct mailimap; 9struct mailimap;
10struct mailimap_body; 10struct mailimap_body;
11struct mailimap_body_type_1part; 11struct mailimap_body_type_1part;
12struct mailimap_body_type_text; 12struct mailimap_body_type_text;
13struct mailimap_body_type_basic; 13struct mailimap_body_type_basic;
14struct mailimap_body_type_msg; 14struct mailimap_body_type_msg;
15struct mailimap_body_type_mpart; 15struct mailimap_body_type_mpart;
16struct mailimap_body_fields; 16struct mailimap_body_fields;
17struct mailimap_msg_att; 17struct mailimap_msg_att;
18class encodedString; 18class encodedString;
19 19
20class IMAPwrapper : public AbstractMail 20class IMAPwrapper : public AbstractMail
21{ 21{
22 Q_OBJECT 22 Q_OBJECT
23public: 23public:
24 IMAPwrapper( IMAPaccount *a ); 24 IMAPwrapper( IMAPaccount *a );
25 virtual ~IMAPwrapper(); 25 virtual ~IMAPwrapper();
26 virtual QList<Folder>* listFolders(); 26 virtual QList<Folder>* listFolders();
27 virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); 27 virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
28 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 28 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
29 29
30 virtual void deleteMail(const RecMail&mail); 30 virtual void deleteMail(const RecMail&mail);
31 virtual void answeredMail(const RecMail&mail); 31 virtual void answeredMail(const RecMail&mail);
32 virtual int deleteAllMail(const Folder*folder); 32 virtual int deleteAllMail(const Folder*folder);
33 virtual void storeMessage(const char*msg,size_t length, const QString&folder); 33 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
34 virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
34 35
35 virtual RecBody fetchBody(const RecMail&mail); 36 virtual RecBody fetchBody(const RecMail&mail);
36 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); 37 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
37 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); 38 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
38 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); 39 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
39 virtual encodedString* fetchRawBody(const RecMail&mail); 40 virtual encodedString* fetchRawBody(const RecMail&mail);
40 41
41 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); 42 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
42 virtual int deleteMbox(const Folder*folder); 43 virtual int deleteMbox(const Folder*folder);
43 44
44 static void imap_progress( size_t current, size_t maximum ); 45 static void imap_progress( size_t current, size_t maximum );
45 46
46 virtual void logout(); 47 virtual void logout();
47 virtual const QString&getType()const; 48 virtual const QString&getType()const;
48 virtual const QString&getName()const; 49 virtual const QString&getName()const;
49 50
50protected: 51protected:
51 RecMail*parse_list_result(mailimap_msg_att*); 52 RecMail*parse_list_result(mailimap_msg_att*);
52 void login(); 53 void login();
53 54
54 virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); 55 virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
55 virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); 56 virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call);
56 57
57 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); 58 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
58 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); 59 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
59 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); 60 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
60 void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); 61 void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
61 void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); 62 void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which);
62 void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); 63 void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
63 64
64 /* just helpers */ 65 /* just helpers */
65 static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); 66 static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
66 static QStringList address_list_to_stringlist(clist*list); 67 static QStringList address_list_to_stringlist(clist*list);
67 68
68 69
69 IMAPaccount *account; 70 IMAPaccount *account;
70 mailimap *m_imap; 71 mailimap *m_imap;
71}; 72};
72 73
73#endif 74#endif