summaryrefslogtreecommitdiff
authoralwin <alwin>2004-01-08 02:52:13 (UTC)
committer alwin <alwin>2004-01-08 02:52:13 (UTC)
commit05d47b2603adfab0e16f7395e34b7aa56ce6d8de (patch) (unidiff)
tree4253654acb70b859fd0d32981132dffd35092b9f
parentdfa1477a28ecd90e08cf09aeecbe816e94bec0b5 (diff)
downloadopie-05d47b2603adfab0e16f7395e34b7aa56ce6d8de.zip
opie-05d47b2603adfab0e16f7395e34b7aa56ce6d8de.tar.gz
opie-05d47b2603adfab0e16f7395e34b7aa56ce6d8de.tar.bz2
move/copy mails to another folder resides inside wrappers so we can
use special funs of libetpan and/or mailserver itself (eg. imap) libetpan 0.32 requires for that feature a patch! (see libetpanstuff/) accounts marked as "offline" get a new icon TODO: - when creating a new folder while copy/move on imap-server, get the real resulting foldername when using prefix - implement usage of copy/move inside one mbox using special etpan funs
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,58 +1,71 @@
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}
@@ -68,48 +81,50 @@ QPopupMenu * POP3viewItem::getContextMenu()
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;
@@ -157,49 +172,49 @@ void POP3folderItem::contextMenuSelected(int 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) {
@@ -316,48 +331,49 @@ void IMAPviewItem::createNewFolder()
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 );
@@ -644,72 +660,68 @@ RecBody AccountView::fetchBody(const RecMail&aMail)
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{
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
@@ -27,48 +27,49 @@ public:
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
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
@@ -83,24 +83,43 @@ QString AbstractMail::gen_attachment_id()
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
@@ -14,48 +14,50 @@ class 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};
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
@@ -988,33 +988,64 @@ void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
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
@@ -10,48 +10,49 @@ struct 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);