summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-31 21:01:18 (UTC)
committer zautrix <zautrix>2004-08-31 21:01:18 (UTC)
commit3f5c51234c8068f3d4826a2a0066648ace21a19f (patch) (unidiff)
tree91b76c1c7ddec6628c573e409070070747d99feb
parent95f8d4f1de557bd25ae38807d970208399cec5d1 (diff)
downloadkdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.zip
kdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.tar.gz
kdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.tar.bz2
Enhancements of kopiemail
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountview.cpp8
-rw-r--r--kmicromail/libmailwrapper/abstractmail.cpp29
-rw-r--r--kmicromail/libmailwrapper/abstractmail.h8
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.cpp6
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.h3
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp68
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.h6
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.cpp5
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.h3
-rw-r--r--kmicromail/libmailwrapper/nntpwrapper.cpp5
-rw-r--r--kmicromail/libmailwrapper/nntpwrapper.h3
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.cpp21
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.h4
-rw-r--r--kmicromail/opiemail.cpp44
-rw-r--r--kmicromail/opiemail.h2
-rw-r--r--kmicromail/selectstoreui.ui88
16 files changed, 244 insertions, 59 deletions
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp
index 0893733..4ead545 100644
--- a/kmicromail/accountview.cpp
+++ b/kmicromail/accountview.cpp
@@ -1,40 +1,42 @@
1 1
2#include "accountview.h" 2#include "accountview.h"
3#include "accountitem.h" 3#include "accountitem.h"
4#include "selectstore.h" 4#include "selectstore.h"
5 5
6#include <libmailwrapper/settings.h> 6#include <libmailwrapper/settings.h>
7#include <libmailwrapper/mailwrapper.h> 7#include <libmailwrapper/mailwrapper.h>
8#include <libmailwrapper/mailtypes.h> 8#include <libmailwrapper/mailtypes.h>
9#include <libmailwrapper/abstractmail.h> 9#include <libmailwrapper/abstractmail.h>
10 10
11/* OPIE */ 11/* OPIE */
12#include <qpe/qpeapplication.h> 12#include <qpe/qpeapplication.h>
13 13
14/* QT */ 14/* QT */
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16#include <qpopupmenu.h> 16#include <qpopupmenu.h>
17#include <qcheckbox.h>
18#include <qspinbox.h>
17 19
18using namespace Opie::Core; 20using namespace Opie::Core;
19AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 21AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
20 : QListView( parent, name, flags ) 22 : QListView( parent, name, flags )
21{ 23{
22 connect( this, SIGNAL( selectionChanged(QListViewItem*) ), 24 connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
23 SLOT( refresh(QListViewItem*) ) ); 25 SLOT( refresh(QListViewItem*) ) );
24 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 26 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
25 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); 27 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) );
26 setSorting(0); 28 setSorting(0);
27} 29}
28 30
29AccountView::~AccountView() 31AccountView::~AccountView()
30{ 32{
31 imapAccounts.clear(); 33 imapAccounts.clear();
32 mhAccounts.clear(); 34 mhAccounts.clear();
33} 35}
34 36
35void AccountView::slotContextMenu(int id) 37void AccountView::slotContextMenu(int id)
36{ 38{
37 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 39 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
38 if (!view) return; 40 if (!view) return;
39 view->contextMenuSelected(id); 41 view->contextMenuSelected(id);
40} 42}
@@ -137,34 +139,38 @@ void AccountView::setupFolderselect(Selectstore*sels)
137 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 139 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
138 } 140 }
139} 141}
140 142
141void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) 143void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper)
142{ 144{
143 AbstractMail*targetMail = 0; 145 AbstractMail*targetMail = 0;
144 QString targetFolder = ""; 146 QString targetFolder = "";
145 Selectstore sels; 147 Selectstore sels;
146 setupFolderselect(&sels); 148 setupFolderselect(&sels);
147 if (!sels.exec()) return; 149 if (!sels.exec()) return;
148 targetMail = sels.currentMail(); 150 targetMail = sels.currentMail();
149 targetFolder = sels.currentFolder(); 151 targetFolder = sels.currentFolder();
150 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 152 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
151 targetFolder.isEmpty()) 153 targetFolder.isEmpty())
152 { 154 {
153 return; 155 return;
154 } 156 }
155 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 157 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
156 { 158 {
157 QMessageBox::critical(0,tr("Error creating new Folder"), 159 QMessageBox::critical(0,tr("Error creating new Folder"),
158 tr("<center>Error while creating<br>new folder - breaking.</center>")); 160 tr("<center>Error while creating<br>new folder - breaking.</center>"));
159 return; 161 return;
160 } 162 }
161 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); 163 int maxsize = 0;
164 if ( sels.useSize->isChecked())
165 maxsize = sels.sizeSpinBox->value();
166
167 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
162 refreshCurrent(); 168 refreshCurrent();
163} 169}
164 170
165bool AccountView::currentisDraft() 171bool AccountView::currentisDraft()
166{ 172{
167 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 173 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
168 if (!view) return false; 174 if (!view) return false;
169 return view->isDraftfolder(); 175 return view->isDraftfolder();
170} 176}
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp
index 128a7c0..3998abd 100644
--- a/kmicromail/libmailwrapper/abstractmail.cpp
+++ b/kmicromail/libmailwrapper/abstractmail.cpp
@@ -1,24 +1,25 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#include "abstractmail.h" 2#include "abstractmail.h"
2#include "imapwrapper.h" 3#include "imapwrapper.h"
3#include "pop3wrapper.h" 4#include "pop3wrapper.h"
4#include "nntpwrapper.h" 5#include "nntpwrapper.h"
5#include "mhwrapper.h" 6#include "mhwrapper.h"
6#include "mailtypes.h" 7#include "mailtypes.h"
7 8
8 9
9 10
10#include <kdecore/kstandarddirs.h> 11#include <kdecore/kstandarddirs.h>
11#include <qfile.h> 12#include <qfile.h>
12#include <qtextstream.h> 13#include <qtextstream.h>
13#include <stdlib.h> 14#include <stdlib.h>
14#include <libetpan/mailmime_content.h> 15#include <libetpan/mailmime_content.h>
15#include <libetpan/mailmime.h> 16#include <libetpan/mailmime.h>
16 17
17using namespace Opie::Core; 18using namespace Opie::Core;
18AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) 19AbstractMail* AbstractMail::getWrapper(IMAPaccount *a)
19{ 20{
20 return new IMAPwrapper(a); 21 return new IMAPwrapper(a);
21} 22}
22 23
23AbstractMail* AbstractMail::getWrapper(POP3account *a) 24AbstractMail* AbstractMail::getWrapper(POP3account *a)
24{ 25{
@@ -116,57 +117,71 @@ QString AbstractMail::gen_attachment_id()
116} 117}
117 118
118int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) 119int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool)
119{ 120{
120 return 0; 121 return 0;
121} 122}
122 123
123QString AbstractMail::defaultLocalfolder() 124QString AbstractMail::defaultLocalfolder()
124{ 125{
125 // QString f = getenv( "HOME" ); 126 // QString f = getenv( "HOME" );
126 QString f = locateLocal( "data", "kmicromail/localmail"); 127 QString f = locateLocal( "data", "kmicromail/localmail");
127 // f += "/Applications/opiemail/localmail"; 128 // f += "/Applications/opiemail/localmail";
128 return f; 129 return f;
129} 130}
130 131
131QString AbstractMail::draftFolder() 132QString AbstractMail::draftFolder()
132{ 133{
133 return QString("Drafts"); 134 return QString("Drafts");
134} 135}
135 136
136/* temporary - will be removed when implemented in all classes */ 137/* temporary - will be removed when implemented in all classes */
137void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) 138void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &)
138{ 139{
139} 140}
141void AbstractMail::deleteMailList(const QValueList<RecMailP>&target)
142{
143 qDebug("AbstractMail::deleteMailList:: Please reimplement! ");
140 144
145}
141void AbstractMail::mvcpAllMails(const FolderP&fromFolder, 146void AbstractMail::mvcpAllMails(const FolderP&fromFolder,
142 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 147 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb)
148{
149 QValueList<RecMailP> t;
150 listMessages(fromFolder->getName(),t, maxSizeInKb);
151 mvcpMailList( t,targetFolder,targetWrapper,moveit);
152
153}
154void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t,
155 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
143{ 156{
144 QValueList<RecMailP> t; 157
145 listMessages(fromFolder->getName(),t);
146 encodedString*st = 0; 158 encodedString*st = 0;
147 while (t.count()>0) { 159 int iii = 0;
148 RecMailP r = (*t.begin()); 160 int count = t.count();
161 while (iii < count ) {
162 RecMailP r = (*t.at( iii ));
149 st = fetchRawBody(r); 163 st = fetchRawBody(r);
150 if (st) { 164 if (st) {
151 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); 165 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
152 delete st; 166 delete st;
153 } 167 }
154 t.remove(t.begin()); 168 ++iii;
155 } 169 }
156 if (moveit) { 170 if (moveit) {
157 deleteAllMail(fromFolder); 171 deleteMailList( t );
172 //deleteAllMail(fromFolder);
158 } 173 }
159} 174}
160 175
161void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 176void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
162{ 177{
163 encodedString*st = 0; 178 encodedString*st = 0;
164 st = fetchRawBody(mail); 179 st = fetchRawBody(mail);
165 if (st) { 180 if (st) {
166 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); 181 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
167 delete st; 182 delete st;
168 } 183 }
169 if (moveit) { 184 if (moveit) {
170 deleteMail(mail); 185 deleteMail(mail);
171 } 186 }
172} 187}
diff --git a/kmicromail/libmailwrapper/abstractmail.h b/kmicromail/libmailwrapper/abstractmail.h
index e5d64a6..cae83f4 100644
--- a/kmicromail/libmailwrapper/abstractmail.h
+++ b/kmicromail/libmailwrapper/abstractmail.h
@@ -1,65 +1,69 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#ifndef __abstract_mail_ 2#ifndef __abstract_mail_
2#define __abstract_mail_ 3#define __abstract_mail_
3 4
4#include "maildefines.h" 5#include "maildefines.h"
5 6
6#include "settings.h" 7#include "settings.h"
7 8
8#include <qobject.h> 9#include <qobject.h>
9#include <opie2/osmartpointer.h> 10#include <opie2/osmartpointer.h>
10#include "mailtypes.h" 11#include "mailtypes.h"
11 12
12class IMAPwrapper; 13class IMAPwrapper;
13class POP3wrapper; 14class POP3wrapper;
14class Folder; 15class Folder;
15class encodedString; 16class encodedString;
16struct folderStat; 17struct folderStat;
17 18
18class AbstractMail:public QObject 19class AbstractMail:public QObject
19{ 20{
20 Q_OBJECT 21 Q_OBJECT
21public: 22public:
22 AbstractMail(){}; 23 AbstractMail(){};
23 virtual ~AbstractMail(){} 24 virtual ~AbstractMail(){}
24 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0; 25 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0;
25 virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0; 26 virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target, int sizeInKb = 0 )=0;
26 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; 27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0;
27 virtual RecBodyP fetchBody(const RecMailP&mail)=0; 28 virtual RecBodyP fetchBody(const RecMailP&mail)=0;
28 virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0; 29 virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0;
29 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0; 30 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0;
30 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0; 31 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0;
31 virtual encodedString* fetchRawBody(const RecMailP&mail)=0; 32 virtual encodedString* fetchRawBody(const RecMailP&mail)=0;
32 33
33 virtual void deleteMail(const RecMailP&mail)=0; 34 virtual void deleteMail(const RecMailP&mail)=0;
35 virtual void deleteMailList(const QValueList<RecMailP>&target);
34 virtual void answeredMail(const RecMailP&mail)=0; 36 virtual void answeredMail(const RecMailP&mail)=0;
35 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0; 37 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0;
36 virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target); 38 virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target);
37 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; 39 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0;
38 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; 40 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
39 41
40 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, 42 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
41 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 43 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int sizeInKb = 0);
44 virtual void mvcpMailList(const QValueList<RecMailP>& t,
45 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
42 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 46 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
43 47
44 virtual void cleanMimeCache(){}; 48 virtual void cleanMimeCache(){};
45 /* mail box methods */ 49 /* mail box methods */
46 /* parameter is the box to create. 50 /* parameter is the box to create.
47 * if the implementing subclass has prefixes, 51 * if the implementing subclass has prefixes,
48 * them has to be appended automatic. 52 * them has to be appended automatic.
49 */ 53 */
50 virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, 54 virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0,
51 const QString& delemiter="/",bool getsubfolder=false); 55 const QString& delemiter="/",bool getsubfolder=false);
52 virtual void logout()=0; 56 virtual void logout()=0;
53 57
54 static AbstractMail* getWrapper(IMAPaccount *a); 58 static AbstractMail* getWrapper(IMAPaccount *a);
55 static AbstractMail* getWrapper(POP3account *a); 59 static AbstractMail* getWrapper(POP3account *a);
56 static AbstractMail* getWrapper(NNTPaccount *a); 60 static AbstractMail* getWrapper(NNTPaccount *a);
57 /* mbox only! */ 61 /* mbox only! */
58 static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); 62 static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders");
59 static AbstractMail* getWrapper(Account*a); 63 static AbstractMail* getWrapper(Account*a);
60 64
61 static QString defaultLocalfolder(); 65 static QString defaultLocalfolder();
62 static QString draftFolder(); 66 static QString draftFolder();
63 67
64 virtual MAILLIB::ATYPE getType()const=0; 68 virtual MAILLIB::ATYPE getType()const=0;
65 virtual const QString&getName()const=0; 69 virtual const QString&getName()const=0;
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp
index f804e44..1fd4bb1 100644
--- a/kmicromail/libmailwrapper/genericwrapper.cpp
+++ b/kmicromail/libmailwrapper/genericwrapper.cpp
@@ -1,24 +1,25 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#include "genericwrapper.h" 2#include "genericwrapper.h"
2#include <libetpan/libetpan.h> 3#include <libetpan/libetpan.h>
3#include "mailtypes.h" 4#include "mailtypes.h"
4 5
5 6
6 7
7using namespace Opie::Core; 8using namespace Opie::Core;
8Genericwrapper::Genericwrapper() 9Genericwrapper::Genericwrapper()
9 : AbstractMail() 10 : AbstractMail()
10{ 11{
11 bodyCache.clear(); 12 bodyCache.clear();
12 m_storage = 0; 13 m_storage = 0;
13 m_folder = 0; 14 m_folder = 0;
14} 15}
15 16
16Genericwrapper::~Genericwrapper() 17Genericwrapper::~Genericwrapper()
17{ 18{
18 if (m_folder) { 19 if (m_folder) {
19 mailfolder_free(m_folder); 20 mailfolder_free(m_folder);
20 } 21 }
21 if (m_storage) { 22 if (m_storage) {
22 mailstorage_free(m_storage); 23 mailstorage_free(m_storage);
23 } 24 }
24 cleanMimeCache(); 25 cleanMimeCache();
@@ -371,49 +372,49 @@ void Genericwrapper::cleanMimeCache()
371 bodyCache.clear(); 372 bodyCache.clear();
372 ; // odebug << "Genericwrapper: cache cleaned" << oendl; 373 ; // odebug << "Genericwrapper: cache cleaned" << oendl;
373} 374}
374 375
375QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) 376QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies)
376{ 377{
377 QStringList res; 378 QStringList res;
378 if (!in_replies || !in_replies->mid_list) return res; 379 if (!in_replies || !in_replies->mid_list) return res;
379 clistiter * current = 0; 380 clistiter * current = 0;
380 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { 381 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) {
381 QString h((char*)current->data); 382 QString h((char*)current->data);
382 while (h.length()>0 && h[0]=='<') { 383 while (h.length()>0 && h[0]=='<') {
383 h.remove(0,1); 384 h.remove(0,1);
384 } 385 }
385 while (h.length()>0 && h[h.length()-1]=='>') { 386 while (h.length()>0 && h[h.length()-1]=='>') {
386 h.remove(h.length()-1,1); 387 h.remove(h.length()-1,1);
387 } 388 }
388 if (h.length()>0) { 389 if (h.length()>0) {
389 res.append(h); 390 res.append(h);
390 } 391 }
391 } 392 }
392 return res; 393 return res;
393} 394}
394 395
395void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) 396void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb)
396{ 397{
397 int r; 398 int r;
398 mailmessage_list * env_list = 0; 399 mailmessage_list * env_list = 0;
399 r = mailsession_get_messages_list(session,&env_list); 400 r = mailsession_get_messages_list(session,&env_list);
400 if (r != MAIL_NO_ERROR) { 401 if (r != MAIL_NO_ERROR) {
401 ; // odebug << "Error message list" << oendl; 402 ; // odebug << "Error message list" << oendl;
402 return; 403 return;
403 } 404 }
404 r = mailsession_get_envelopes_list(session, env_list); 405 r = mailsession_get_envelopes_list(session, env_list);
405 if (r != MAIL_NO_ERROR) { 406 if (r != MAIL_NO_ERROR) {
406 ; // odebug << "Error filling message list" << oendl; 407 ; // odebug << "Error filling message list" << oendl;
407 if (env_list) { 408 if (env_list) {
408 mailmessage_list_free(env_list); 409 mailmessage_list_free(env_list);
409 } 410 }
410 return; 411 return;
411 } 412 }
412 mailimf_references * refs = 0; 413 mailimf_references * refs = 0;
413 mailimf_in_reply_to * in_replies = 0; 414 mailimf_in_reply_to * in_replies = 0;
414 uint32_t i = 0; 415 uint32_t i = 0;
415 for(; i < carray_count(env_list->msg_tab) ; ++i) { 416 for(; i < carray_count(env_list->msg_tab) ; ++i) {
416 mailmessage * msg; 417 mailmessage * msg;
417 QBitArray mFlags(7); 418 QBitArray mFlags(7);
418 msg = (mailmessage*)carray_get(env_list->msg_tab, i); 419 msg = (mailmessage*)carray_get(env_list->msg_tab, i);
419 if (msg->msg_fields == NULL) { 420 if (msg->msg_fields == NULL) {
@@ -451,30 +452,31 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &
451 mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); 452 mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) );
452 // crashes when accessing pop3 account? 453 // crashes when accessing pop3 account?
453 if (single_fields.fld_message_id->mid_value) { 454 if (single_fields.fld_message_id->mid_value) {
454 mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); 455 mail->setMsgid(QString(single_fields.fld_message_id->mid_value));
455 ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; 456 ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl;
456 } 457 }
457 458
458 if (single_fields.fld_reply_to) { 459 if (single_fields.fld_reply_to) {
459 QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); 460 QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list);
460 if (t.count()>0) { 461 if (t.count()>0) {
461 mail->setReplyto(t[0]); 462 mail->setReplyto(t[0]);
462 } 463 }
463 } 464 }
464#if 0 465#if 0
465 refs = single_fields.fld_references; 466 refs = single_fields.fld_references;
466 if (refs && refs->mid_list && clist_count(refs->mid_list)) { 467 if (refs && refs->mid_list && clist_count(refs->mid_list)) {
467 char * text = (char*)refs->mid_list->first->data; 468 char * text = (char*)refs->mid_list->first->data;
468 mail->setReplyto(QString(text)); 469 mail->setReplyto(QString(text));
469 } 470 }
470#endif 471#endif
471 if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && 472 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)) { 473 clist_count(single_fields.fld_in_reply_to->mid_list)) {
473 mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); 474 mail->setInreply(parseInreplies(single_fields.fld_in_reply_to));
474 } 475 }
475 target.append(mail); 476 if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 )
477 target.append(mail);
476 } 478 }
477 if (env_list) { 479 if (env_list) {
478 mailmessage_list_free(env_list); 480 mailmessage_list_free(env_list);
479 } 481 }
480} 482}
diff --git a/kmicromail/libmailwrapper/genericwrapper.h b/kmicromail/libmailwrapper/genericwrapper.h
index 8be9212..235e116 100644
--- a/kmicromail/libmailwrapper/genericwrapper.h
+++ b/kmicromail/libmailwrapper/genericwrapper.h
@@ -1,24 +1,25 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#ifndef __GENERIC_WRAPPER_H 2#ifndef __GENERIC_WRAPPER_H
2#define __GENERIC_WRAPPER_H 3#define __GENERIC_WRAPPER_H
3 4
4#include "abstractmail.h" 5#include "abstractmail.h"
5#include <qmap.h> 6#include <qmap.h>
6#include <qstring.h> 7#include <qstring.h>
7#include <libetpan/clist.h> 8#include <libetpan/clist.h>
8 9
9class RecMail; 10class RecMail;
10class RecBody; 11class RecBody;
11class encodedString; 12class encodedString;
12struct mailpop3; 13struct mailpop3;
13struct mailmessage; 14struct mailmessage;
14struct mailmime; 15struct mailmime;
15struct mailmime_mechanism; 16struct mailmime_mechanism;
16struct mailimf_mailbox_list; 17struct mailimf_mailbox_list;
17struct mailimf_mailbox; 18struct mailimf_mailbox;
18struct mailimf_date_time; 19struct mailimf_date_time;
19struct mailimf_group; 20struct mailimf_group;
20struct mailimf_address_list; 21struct mailimf_address_list;
21struct mailsession; 22struct mailsession;
22struct mailstorage; 23struct mailstorage;
23struct mailfolder; 24struct mailfolder;
24struct mailimf_in_reply_to; 25struct mailimf_in_reply_to;
@@ -33,35 +34,35 @@ class Genericwrapper : public AbstractMail
33public: 34public:
34 Genericwrapper(); 35 Genericwrapper();
35 virtual ~Genericwrapper(); 36 virtual ~Genericwrapper();
36 37
37 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); 38 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part);
38 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); 39 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part);
39 virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); 40 virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part);
40 virtual void cleanMimeCache(); 41 virtual void cleanMimeCache();
41 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} 42 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;}
42 virtual void logout(){}; 43 virtual void logout(){};
43 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){};
44 45
45protected: 46protected:
46 RecBodyP parseMail( mailmessage * msg ); 47 RecBodyP parseMail( mailmessage * msg );
47 QString parseMailboxList( mailimf_mailbox_list *list ); 48 QString parseMailboxList( mailimf_mailbox_list *list );
48 QString parseMailbox( mailimf_mailbox *box ); 49 QString parseMailbox( mailimf_mailbox *box );
49 QString parseGroup( mailimf_group *group ); 50 QString parseGroup( mailimf_group *group );
50 QString parseAddressList( mailimf_address_list *list ); 51 QString parseAddressList( mailimf_address_list *list );
51 QString parseDateTime( mailimf_date_time *date ); 52 QString parseDateTime( mailimf_date_time *date );
52 53
53 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);
54 static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); 55 static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime);
55 static void fillParameters(RecPartP&target,clist*parameters); 56 static void fillParameters(RecPartP&target,clist*parameters);
56 static QString getencoding(mailmime_mechanism*aEnc); 57 static QString getencoding(mailmime_mechanism*aEnc);
57 virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); 58 virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false, int maxSizeInKb = 0);
58 QStringList parseInreplies(mailimf_in_reply_to * in_replies); 59 QStringList parseInreplies(mailimf_in_reply_to * in_replies);
59 60
60 QString msgTempName; 61 QString msgTempName;
61 unsigned int last_msg_id; 62 unsigned int last_msg_id;
62 QMap<QString,encodedString*> bodyCache; 63 QMap<QString,encodedString*> bodyCache;
63 mailstorage * m_storage; 64 mailstorage * m_storage;
64 mailfolder*m_folder; 65 mailfolder*m_folder;
65}; 66};
66 67
67#endif 68#endif
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index e0fb6f9..bb8bbfc 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -1,24 +1,25 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#include <stdlib.h> 2#include <stdlib.h>
2#include <libetpan/libetpan.h> 3#include <libetpan/libetpan.h>
3#include <qpe/global.h> 4#include <qpe/global.h>
4#include <qapplication.h> 5#include <qapplication.h>
5#include "imapwrapper.h" 6#include "imapwrapper.h"
6#include "mailtypes.h" 7#include "mailtypes.h"
7#include "logindialog.h" 8#include "logindialog.h"
8 9
9using namespace Opie::Core; 10using namespace Opie::Core;
10IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 11IMAPwrapper::IMAPwrapper( IMAPaccount *a )
11 : AbstractMail() 12 : AbstractMail()
12{ 13{
13 account = a; 14 account = a;
14 m_imap = 0; 15 m_imap = 0;
15 m_Lastmbox = ""; 16 m_Lastmbox = "";
16} 17}
17 18
18IMAPwrapper::~IMAPwrapper() 19IMAPwrapper::~IMAPwrapper()
19{ 20{
20 logout(); 21 logout();
21} 22}
22 23
23/* to avoid to often select statements in loops etc. 24/* to avoid to often select statements in loops etc.
24 we trust that we are logged in and connection is established!*/ 25 we trust that we are logged in and connection is established!*/
@@ -181,100 +182,102 @@ void IMAPwrapper::login()
181 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); 182 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
182 if ( err != MAILIMAP_NO_ERROR ) { 183 if ( err != MAILIMAP_NO_ERROR ) {
183 Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); 184 Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response));
184 ok = false; 185 ok = false;
185 } 186 }
186 } 187 }
187 if (!ok) { 188 if (!ok) {
188 err = mailimap_close( m_imap ); 189 err = mailimap_close( m_imap );
189 mailimap_free( m_imap ); 190 mailimap_free( m_imap );
190 m_imap = 0; 191 m_imap = 0;
191 } 192 }
192} 193}
193 194
194void IMAPwrapper::logout() 195void IMAPwrapper::logout()
195{ 196{
196 int err = MAILIMAP_NO_ERROR; 197 int err = MAILIMAP_NO_ERROR;
197 if (!m_imap) return; 198 if (!m_imap) return;
198 err = mailimap_logout( m_imap ); 199 err = mailimap_logout( m_imap );
199 err = mailimap_close( m_imap ); 200 err = mailimap_close( m_imap );
200 mailimap_free( m_imap ); 201 mailimap_free( m_imap );
201 m_imap = 0; 202 m_imap = 0;
202 m_Lastmbox = ""; 203 m_Lastmbox = "";
203} 204}
204 205
205void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) 206void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb)
206{ 207{
207 int err = MAILIMAP_NO_ERROR; 208 int err = MAILIMAP_NO_ERROR;
208 clist *result = 0; 209 clist *result = 0;
209 clistcell *current; 210 clistcell *current;
210 mailimap_fetch_type *fetchType = 0; 211 mailimap_fetch_type *fetchType = 0;
211 mailimap_set *set = 0; 212 mailimap_set *set = 0;
212 213
213 login(); 214 login();
214 if (!m_imap) { 215 if (!m_imap) {
215 return; 216 return;
216 } 217 }
217 /* select mailbox READONLY for operations */ 218 /* select mailbox READONLY for operations */
218 err = selectMbox(mailbox); 219 err = selectMbox(mailbox);
219 if ( err != MAILIMAP_NO_ERROR ) { 220 if ( err != MAILIMAP_NO_ERROR ) {
220 return; 221 return;
221 } 222 }
222 223
223 int last = m_imap->imap_selection_info->sel_exists; 224 int last = m_imap->imap_selection_info->sel_exists;
224 225
225 if (last == 0) { 226 if (last == 0) {
226 Global::statusMessage(tr("Mailbox has no mails")); 227 Global::statusMessage(tr("Mailbox has no mails"));
227 return; 228 return;
228 } else { 229 } else {
229 } 230 }
230 231
231 /* the range has to start at 1!!! not with 0!!!! */ 232 /* the range has to start at 1!!! not with 0!!!! */
232 set = mailimap_set_new_interval( 1, last ); 233 set = mailimap_set_new_interval( 1, last );
233 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 234 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
234 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 235 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
235 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); 236 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
236 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); 237 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
237 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); 238 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
238 239
239 err = mailimap_fetch( m_imap, set, fetchType, &result ); 240 err = mailimap_fetch( m_imap, set, fetchType, &result );
240 mailimap_set_free( set ); 241 mailimap_set_free( set );
241 mailimap_fetch_type_free( fetchType ); 242 mailimap_fetch_type_free( fetchType );
242 243
243 QString date,subject,from; 244 QString date,subject,from;
244 245
245 if ( err == MAILIMAP_NO_ERROR ) { 246 if ( err == MAILIMAP_NO_ERROR ) {
246 mailimap_msg_att * msg_att; 247 mailimap_msg_att * msg_att;
247 int i = 0; 248 int i = 0;
248 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 249 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
249 ++i; 250 ++i;
250 msg_att = (mailimap_msg_att*)current->data; 251 msg_att = (mailimap_msg_att*)current->data;
251 RecMail*m = parse_list_result(msg_att); 252 RecMail*m = parse_list_result(msg_att);
252 if (m) { 253 if (m) {
253 m->setNumber(i); 254 if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) {
254 m->setMbox(mailbox); 255 m->setNumber(i);
255 m->setWrapper(this); 256 m->setMbox(mailbox);
256 target.append(m); 257 m->setWrapper(this);
258 target.append(m);
259 }
257 } 260 }
258 } 261 }
259 Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); 262 Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count()));
260 } else { 263 } else {
261 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); 264 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response));
262 } 265 }
263 if (result) mailimap_fetch_list_free(result); 266 if (result) mailimap_fetch_list_free(result);
264} 267}
265 268
266QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() 269QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
267{ 270{
268 const char *path, *mask; 271 const char *path, *mask;
269 int err = MAILIMAP_NO_ERROR; 272 int err = MAILIMAP_NO_ERROR;
270 clist *result = 0; 273 clist *result = 0;
271 clistcell *current = 0; 274 clistcell *current = 0;
272 clistcell*cur_flag = 0; 275 clistcell*cur_flag = 0;
273 mailimap_mbx_list_flags*bflags = 0; 276 mailimap_mbx_list_flags*bflags = 0;
274 277
275 QValueList<FolderP>* folders = new QValueList<FolderP>(); 278 QValueList<FolderP>* folders = new QValueList<FolderP>();
276 login(); 279 login();
277 if (!m_imap) { 280 if (!m_imap) {
278 return folders; 281 return folders;
279 } 282 }
280 283
@@ -845,82 +848,126 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which
845 case MAILIMAP_BODY_FLD_ENC_BINARY: 848 case MAILIMAP_BODY_FLD_ENC_BINARY:
846 encoding="binary"; 849 encoding="binary";
847 break; 850 break;
848 case MAILIMAP_BODY_FLD_ENC_BASE64: 851 case MAILIMAP_BODY_FLD_ENC_BASE64:
849 encoding="base64"; 852 encoding="base64";
850 break; 853 break;
851 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: 854 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
852 encoding="quoted-printable"; 855 encoding="quoted-printable";
853 break; 856 break;
854 case MAILIMAP_BODY_FLD_ENC_OTHER: 857 case MAILIMAP_BODY_FLD_ENC_OTHER:
855 default: 858 default:
856 if (enc->enc_value) { 859 if (enc->enc_value) {
857 char*t=enc->enc_value; 860 char*t=enc->enc_value;
858 encoding=QString(enc->enc_value); 861 encoding=QString(enc->enc_value);
859 enc->enc_value=0L; 862 enc->enc_value=0L;
860 free(t); 863 free(t);
861 } 864 }
862 } 865 }
863 if (which->bd_description) { 866 if (which->bd_description) {
864 target_part->setDescription(QString(which->bd_description)); 867 target_part->setDescription(QString(which->bd_description));
865 } 868 }
866 target_part->setEncoding(encoding); 869 target_part->setEncoding(encoding);
867 target_part->setSize(which->bd_size); 870 target_part->setSize(which->bd_size);
868} 871}
872void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target)
873{
874 mailimap_flag_list*flist;
875 mailimap_set *set;
876 mailimap_store_att_flags * store_flags;
877 int err;
878 login();
879 if (!m_imap) {
880 return;
881 }
882 int iii = 0;
883 int count = target.count();
884 qDebug("imap remove count %d ", count);
885 while (iii < count ) {
886 qDebug("IMAP remove %d ", iii);
887 RecMailP mail = (*target.at( iii ));
869 888
889 err = selectMbox(mail->getMbox());
890 if ( err != MAILIMAP_NO_ERROR ) {
891 return;
892 }
893 flist = mailimap_flag_list_new_empty();
894 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
895 store_flags = mailimap_store_att_flags_new_set_flags(flist);
896 set = mailimap_set_new_single(mail->getNumber());
897 err = mailimap_store(m_imap,set,store_flags);
898 mailimap_set_free( set );
899 mailimap_store_att_flags_free(store_flags);
900
901 if (err != MAILIMAP_NO_ERROR) {
902 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
903 return;
904 }
905 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
906 /* should we realy do that at this moment? */
907
908 err = mailimap_expunge(m_imap);
909 if (err != MAILIMAP_NO_ERROR) {
910 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
911 }
912 ++iii;
913 }
914}
870void IMAPwrapper::deleteMail(const RecMailP&mail) 915void IMAPwrapper::deleteMail(const RecMailP&mail)
871{ 916{
872 mailimap_flag_list*flist; 917 mailimap_flag_list*flist;
873 mailimap_set *set; 918 mailimap_set *set;
874 mailimap_store_att_flags * store_flags; 919 mailimap_store_att_flags * store_flags;
875 int err; 920 int err;
876 login(); 921 login();
877 if (!m_imap) { 922 if (!m_imap) {
878 return; 923 return;
879 } 924 }
880 err = selectMbox(mail->getMbox()); 925 err = selectMbox(mail->getMbox());
881 if ( err != MAILIMAP_NO_ERROR ) { 926 if ( err != MAILIMAP_NO_ERROR ) {
882 return; 927 return;
883 } 928 }
884 flist = mailimap_flag_list_new_empty(); 929 flist = mailimap_flag_list_new_empty();
885 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 930 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
886 store_flags = mailimap_store_att_flags_new_set_flags(flist); 931 store_flags = mailimap_store_att_flags_new_set_flags(flist);
887 set = mailimap_set_new_single(mail->getNumber()); 932 set = mailimap_set_new_single(mail->getNumber());
888 err = mailimap_store(m_imap,set,store_flags); 933 err = mailimap_store(m_imap,set,store_flags);
889 mailimap_set_free( set ); 934 mailimap_set_free( set );
890 mailimap_store_att_flags_free(store_flags); 935 mailimap_store_att_flags_free(store_flags);
891 936
892 if (err != MAILIMAP_NO_ERROR) { 937 if (err != MAILIMAP_NO_ERROR) {
893 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; 938 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
894 return; 939 return;
895 } 940 }
896 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 941 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
897 /* should we realy do that at this moment? */ 942 /* should we realy do that at this moment? */
943
898 err = mailimap_expunge(m_imap); 944 err = mailimap_expunge(m_imap);
899 if (err != MAILIMAP_NO_ERROR) { 945 if (err != MAILIMAP_NO_ERROR) {
900 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; 946 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
901 } 947 }
902 // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; 948 qDebug("IMAPwrapper::deleteMail ");
949
903} 950}
904 951
905void IMAPwrapper::answeredMail(const RecMailP&mail) 952void IMAPwrapper::answeredMail(const RecMailP&mail)
906{ 953{
907 mailimap_flag_list*flist; 954 mailimap_flag_list*flist;
908 mailimap_set *set; 955 mailimap_set *set;
909 mailimap_store_att_flags * store_flags; 956 mailimap_store_att_flags * store_flags;
910 int err; 957 int err;
911 login(); 958 login();
912 if (!m_imap) { 959 if (!m_imap) {
913 return; 960 return;
914 } 961 }
915 err = selectMbox(mail->getMbox()); 962 err = selectMbox(mail->getMbox());
916 if ( err != MAILIMAP_NO_ERROR ) { 963 if ( err != MAILIMAP_NO_ERROR ) {
917 return; 964 return;
918 } 965 }
919 flist = mailimap_flag_list_new_empty(); 966 flist = mailimap_flag_list_new_empty();
920 mailimap_flag_list_add(flist,mailimap_flag_new_answered()); 967 mailimap_flag_list_add(flist,mailimap_flag_new_answered());
921 store_flags = mailimap_store_att_flags_new_add_flags(flist); 968 store_flags = mailimap_store_att_flags_new_add_flags(flist);
922 set = mailimap_set_new_single(mail->getNumber()); 969 set = mailimap_set_new_single(mail->getNumber());
923 err = mailimap_store(m_imap,set,store_flags); 970 err = mailimap_store(m_imap,set,store_flags);
924 mailimap_set_free( set ); 971 mailimap_set_free( set );
925 mailimap_store_att_flags_free(store_flags); 972 mailimap_store_att_flags_free(store_flags);
926 973
@@ -1099,52 +1146,53 @@ void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folde
1099 if (r != MAILIMAP_NO_ERROR) { 1146 if (r != MAILIMAP_NO_ERROR) {
1100 Global::statusMessage("Error storing mail!"); 1147 Global::statusMessage("Error storing mail!");
1101 } 1148 }
1102} 1149}
1103 1150
1104MAILLIB::ATYPE IMAPwrapper::getType()const 1151MAILLIB::ATYPE IMAPwrapper::getType()const
1105{ 1152{
1106 return account->getType(); 1153 return account->getType();
1107} 1154}
1108 1155
1109const QString&IMAPwrapper::getName()const 1156const QString&IMAPwrapper::getName()const
1110{ 1157{
1111 // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; 1158 // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl;
1112 return account->getAccountName(); 1159 return account->getAccountName();
1113} 1160}
1114 1161
1115encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) 1162encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail)
1116{ 1163{
1117 // dummy 1164 // dummy
1118 QValueList<int> path; 1165 QValueList<int> path;
1119 return fetchRawPart(mail,path,false); 1166 return fetchRawPart(mail,path,false);
1120} 1167}
1121 1168
1122void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, 1169void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
1123 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 1170 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb)
1124{ 1171{
1125 if (targetWrapper != this) { 1172 if (targetWrapper != this || maxSizeInKb > 0 ) {
1126 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); 1173 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb);
1174 qDebug("IMAPwrapper::mvcpAllMails::Using generic");
1127 // odebug << "Using generic" << oendl; 1175 // odebug << "Using generic" << oendl;
1128 return; 1176 return;
1129 } 1177 }
1130 mailimap_set *set = 0; 1178 mailimap_set *set = 0;
1131 login(); 1179 login();
1132 if (!m_imap) { 1180 if (!m_imap) {
1133 return; 1181 return;
1134 } 1182 }
1135 int err = selectMbox(fromFolder->getName()); 1183 int err = selectMbox(fromFolder->getName());
1136 if ( err != MAILIMAP_NO_ERROR ) { 1184 if ( err != MAILIMAP_NO_ERROR ) {
1137 return; 1185 return;
1138 } 1186 }
1139 int last = m_imap->imap_selection_info->sel_exists; 1187 int last = m_imap->imap_selection_info->sel_exists;
1140 set = mailimap_set_new_interval( 1, last ); 1188 set = mailimap_set_new_interval( 1, last );
1141 err = mailimap_copy(m_imap,set,targetFolder.latin1()); 1189 err = mailimap_copy(m_imap,set,targetFolder.latin1());
1142 mailimap_set_free( set ); 1190 mailimap_set_free( set );
1143 if ( err != MAILIMAP_NO_ERROR ) { 1191 if ( err != MAILIMAP_NO_ERROR ) {
1144 QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); 1192 QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response);
1145 Global::statusMessage(error_msg); 1193 Global::statusMessage(error_msg);
1146 // odebug << error_msg << oendl; 1194 // odebug << error_msg << oendl;
1147 return; 1195 return;
1148 } 1196 }
1149 if (moveit) { 1197 if (moveit) {
1150 deleteAllMail(fromFolder); 1198 deleteAllMail(fromFolder);
diff --git a/kmicromail/libmailwrapper/imapwrapper.h b/kmicromail/libmailwrapper/imapwrapper.h
index e56605a..222fe95 100644
--- a/kmicromail/libmailwrapper/imapwrapper.h
+++ b/kmicromail/libmailwrapper/imapwrapper.h
@@ -1,59 +1,61 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#ifndef __IMAPWRAPPER 2#ifndef __IMAPWRAPPER
2#define __IMAPWRAPPER 3#define __IMAPWRAPPER
3 4
4#include <qlist.h> 5#include <qlist.h>
5#include "mailwrapper.h" 6#include "mailwrapper.h"
6#include "abstractmail.h" 7#include "abstractmail.h"
7#include <libetpan/clist.h> 8#include <libetpan/clist.h>
8 9
9struct mailimap; 10struct mailimap;
10struct mailimap_body; 11struct mailimap_body;
11struct mailimap_body_type_1part; 12struct mailimap_body_type_1part;
12struct mailimap_body_type_text; 13struct mailimap_body_type_text;
13struct mailimap_body_type_basic; 14struct mailimap_body_type_basic;
14struct mailimap_body_type_msg; 15struct mailimap_body_type_msg;
15struct mailimap_body_type_mpart; 16struct mailimap_body_type_mpart;
16struct mailimap_body_fields; 17struct mailimap_body_fields;
17struct mailimap_msg_att; 18struct mailimap_msg_att;
18class encodedString; 19class encodedString;
19 20
20class IMAPwrapper : public AbstractMail 21class IMAPwrapper : public AbstractMail
21{ 22{
22 Q_OBJECT 23 Q_OBJECT
23public: 24public:
24 IMAPwrapper( IMAPaccount *a ); 25 IMAPwrapper( IMAPaccount *a );
25 virtual ~IMAPwrapper(); 26 virtual ~IMAPwrapper();
26 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); 27 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
27 virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); 28 virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target , int sizeInKb = 0);
28 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 29 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
29 30
30 virtual void deleteMail(const RecMailP&mail); 31 virtual void deleteMail(const RecMailP&mail);
32 void deleteMailList(const QValueList<RecMailP>&target);
31 virtual void answeredMail(const RecMailP&mail); 33 virtual void answeredMail(const RecMailP&mail);
32 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); 34 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder);
33 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);
34 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, 36 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
35 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 37 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit,int sizeInKb = 0);
36 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);
37 39
38 virtual RecBodyP fetchBody(const RecMailP&mail); 40 virtual RecBodyP fetchBody(const RecMailP&mail);
39 virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); 41 virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part);
40 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); 42 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part);
41 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); 43 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part);
42 virtual encodedString* fetchRawBody(const RecMailP&mail); 44 virtual encodedString* fetchRawBody(const RecMailP&mail);
43 45
44 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,
45 const QString& delemiter="/",bool getsubfolder=false); 47 const QString& delemiter="/",bool getsubfolder=false);
46 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder); 48 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder);
47 49
48 static void imap_progress( size_t current, size_t maximum ); 50 static void imap_progress( size_t current, size_t maximum );
49 51
50 virtual void logout(); 52 virtual void logout();
51 virtual MAILLIB::ATYPE getType()const; 53 virtual MAILLIB::ATYPE getType()const;
52 virtual const QString&getName()const; 54 virtual const QString&getName()const;
53 55
54protected: 56protected:
55 RecMail*parse_list_result(mailimap_msg_att*); 57 RecMail*parse_list_result(mailimap_msg_att*);
56 void login(); 58 void login();
57 bool start_tls(bool force=true); 59 bool start_tls(bool force=true);
58 60
59 virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); 61 virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp
index 7ef9b32..cbc52d9 100644
--- a/kmicromail/libmailwrapper/mhwrapper.cpp
+++ b/kmicromail/libmailwrapper/mhwrapper.cpp
@@ -1,24 +1,25 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#include "mhwrapper.h" 2#include "mhwrapper.h"
2#include "mailtypes.h" 3#include "mailtypes.h"
3#include "mailwrapper.h" 4#include "mailwrapper.h"
4#include <libetpan/libetpan.h> 5#include <libetpan/libetpan.h>
5#include <qdir.h> 6#include <qdir.h>
6#include <qmessagebox.h> 7#include <qmessagebox.h>
7#include <stdlib.h> 8#include <stdlib.h>
8#include <qpe/global.h> 9#include <qpe/global.h>
9#include <oprocess.h> 10#include <oprocess.h>
10//#include <opie2/odebug.h> 11//#include <opie2/odebug.h>
11 12
12using namespace Opie::Core; 13using namespace Opie::Core;
13MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) 14MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name)
14 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) 15 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name)
15{ 16{
16 if (MHPath.length()>0) { 17 if (MHPath.length()>0) {
17 if (MHPath[MHPath.length()-1]=='/') { 18 if (MHPath[MHPath.length()-1]=='/') {
18 MHPath=MHPath.left(MHPath.length()-1); 19 MHPath=MHPath.left(MHPath.length()-1);
19 } 20 }
20 //odebug << MHPath << oendl; 21 //odebug << MHPath << oendl;
21 QDir dir(MHPath); 22 QDir dir(MHPath);
22 if (!dir.exists()) { 23 if (!dir.exists()) {
23 dir.mkdir(MHPath); 24 dir.mkdir(MHPath);
24 } 25 }
@@ -41,61 +42,61 @@ void MHwrapper::init_storage()
41 } 42 }
42 } 43 }
43 r = mailstorage_connect(m_storage); 44 r = mailstorage_connect(m_storage);
44 if (r!=MAIL_NO_ERROR) { 45 if (r!=MAIL_NO_ERROR) {
45 qDebug("error connecting storage "); 46 qDebug("error connecting storage ");
46 mailstorage_free(m_storage); 47 mailstorage_free(m_storage);
47 m_storage = 0; 48 m_storage = 0;
48 } 49 }
49} 50}
50 51
51void MHwrapper::clean_storage() 52void MHwrapper::clean_storage()
52{ 53{
53 if (m_storage) { 54 if (m_storage) {
54 mailstorage_disconnect(m_storage); 55 mailstorage_disconnect(m_storage);
55 mailstorage_free(m_storage); 56 mailstorage_free(m_storage);
56 m_storage = 0; 57 m_storage = 0;
57 } 58 }
58} 59}
59 60
60MHwrapper::~MHwrapper() 61MHwrapper::~MHwrapper()
61{ 62{
62 clean_storage(); 63 clean_storage();
63} 64}
64 65
65void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) 66void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb )
66{ 67{
67 init_storage(); 68 init_storage();
68 if (!m_storage) { 69 if (!m_storage) {
69 return; 70 return;
70 } 71 }
71 QString f = buildPath(mailbox); 72 QString f = buildPath(mailbox);
72 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 73 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
73 if (r!=MAIL_NO_ERROR) { 74 if (r!=MAIL_NO_ERROR) {
74 qDebug("listMessages: error selecting folder! "); 75 qDebug("listMessages: error selecting folder! ");
75 return; 76 return;
76 } 77 }
77 parseList(target,m_storage->sto_session,f); 78 parseList(target,m_storage->sto_session,f, false, maxSizeInKb );
78 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); 79 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count()));
79} 80}
80 81
81QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() 82QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders()
82{ 83{
83 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); 84 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >();
84 /* this is needed! */ 85 /* this is needed! */
85 if (m_storage) mailstorage_disconnect(m_storage); 86 if (m_storage) mailstorage_disconnect(m_storage);
86 init_storage(); 87 init_storage();
87 if (!m_storage) { 88 if (!m_storage) {
88 return folders; 89 return folders;
89 } 90 }
90 mail_list*flist = 0; 91 mail_list*flist = 0;
91 clistcell*current=0; 92 clistcell*current=0;
92 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); 93 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist);
93 if (r != MAIL_NO_ERROR || !flist) { 94 if (r != MAIL_NO_ERROR || !flist) {
94 qDebug("error getting folder list "); 95 qDebug("error getting folder list ");
95 return folders; 96 return folders;
96 } 97 }
97 for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { 98 for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) {
98 QString t = (char*)current->data; 99 QString t = (char*)current->data;
99 t.replace(0,MHPath.length(),""); 100 t.replace(0,MHPath.length(),"");
100 folders->append(new MHFolder(t,MHPath)); 101 folders->append(new MHFolder(t,MHPath));
101 } 102 }
diff --git a/kmicromail/libmailwrapper/mhwrapper.h b/kmicromail/libmailwrapper/mhwrapper.h
index 4310c84..550824d 100644
--- a/kmicromail/libmailwrapper/mhwrapper.h
+++ b/kmicromail/libmailwrapper/mhwrapper.h
@@ -1,44 +1,45 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#ifndef __MH_WRAPPER_H 2#ifndef __MH_WRAPPER_H
2#define __MH_WRAPPER_H 3#define __MH_WRAPPER_H
3 4
4#include "maildefines.h" 5#include "maildefines.h"
5 6
6#include "genericwrapper.h" 7#include "genericwrapper.h"
7#include <qstring.h> 8#include <qstring.h>
8 9
9class encodedString; 10class encodedString;
10struct mailmbox_folder; 11struct mailmbox_folder;
11namespace Opie {namespace Core {class OProcess;}} 12namespace Opie {namespace Core {class OProcess;}}
12 13
13class MHwrapper : public Genericwrapper 14class MHwrapper : public Genericwrapper
14{ 15{
15 Q_OBJECT 16 Q_OBJECT
16public: 17public:
17 MHwrapper(const QString & dir,const QString&name); 18 MHwrapper(const QString & dir,const QString&name);
18 virtual ~MHwrapper(); 19 virtual ~MHwrapper();
19 20
20 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); 21 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 );
21 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); 22 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
22 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 23 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
23 24
24 virtual void deleteMail(const RecMailP&mail); 25 virtual void deleteMail(const RecMailP&mail);
25 virtual void answeredMail(const RecMailP&mail); 26 virtual void answeredMail(const RecMailP&mail);
26 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);
27 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, 28 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
28 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 29 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
29 30
30 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,
31 const QString&d="",bool s=false); 32 const QString&d="",bool s=false);
32 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); 33 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&);
33 34
34 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);
35 36
36 virtual RecBodyP fetchBody( const RecMailP &mail ); 37 virtual RecBodyP fetchBody( const RecMailP &mail );
37 static void mbox_progress( size_t current, size_t maximum ); 38 static void mbox_progress( size_t current, size_t maximum );
38 39
39 virtual encodedString* fetchRawBody(const RecMailP&mail); 40 virtual encodedString* fetchRawBody(const RecMailP&mail);
40 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);
41 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); 42 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
42 virtual MAILLIB::ATYPE getType()const; 43 virtual MAILLIB::ATYPE getType()const;
43 virtual const QString&getName()const; 44 virtual const QString&getName()const;
44 45
diff --git a/kmicromail/libmailwrapper/nntpwrapper.cpp b/kmicromail/libmailwrapper/nntpwrapper.cpp
index daa128e..f5d7f16 100644
--- a/kmicromail/libmailwrapper/nntpwrapper.cpp
+++ b/kmicromail/libmailwrapper/nntpwrapper.cpp
@@ -1,24 +1,25 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#include "nntpwrapper.h" 2#include "nntpwrapper.h"
2#include "logindialog.h" 3#include "logindialog.h"
3#include "mailtypes.h" 4#include "mailtypes.h"
4 5
5#include <qfile.h> 6#include <qfile.h>
6 7
7#include <stdlib.h> 8#include <stdlib.h>
8 9
9#include <libetpan/libetpan.h> 10#include <libetpan/libetpan.h>
10 11
11 12
12 13
13#define HARD_MSG_SIZE_LIMIT 5242880 14#define HARD_MSG_SIZE_LIMIT 5242880
14 15
15using namespace Opie::Core; 16using namespace Opie::Core;
16NNTPwrapper::NNTPwrapper( NNTPaccount *a ) 17NNTPwrapper::NNTPwrapper( NNTPaccount *a )
17: Genericwrapper() { 18: Genericwrapper() {
18 account = a; 19 account = a;
19 m_nntp = NULL; 20 m_nntp = NULL;
20 msgTempName = a->getFileName()+"_msg_cache"; 21 msgTempName = a->getFileName()+"_msg_cache";
21 last_msg_id = 0; 22 last_msg_id = 0;
22} 23}
23 24
24NNTPwrapper::~NNTPwrapper() { 25NNTPwrapper::~NNTPwrapper() {
@@ -77,56 +78,56 @@ RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) {
77 message = (char*)malloc(msg.length()+1*sizeof(char)); 78 message = (char*)malloc(msg.length()+1*sizeof(char));
78 memset(message,0,msg.length()+1); 79 memset(message,0,msg.length()+1);
79 memcpy(message,msg.latin1(),msg.length()); 80 memcpy(message,msg.latin1(),msg.length());
80 /* transform to libetpan stuff */ 81 /* transform to libetpan stuff */
81 mailmsg = mailmessage_new(); 82 mailmsg = mailmessage_new();
82 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); 83 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
83 generic_message_t * msg_data; 84 generic_message_t * msg_data;
84 msg_data = (generic_message_t *)mailmsg->msg_data; 85 msg_data = (generic_message_t *)mailmsg->msg_data;
85 msg_data->msg_fetched = 1; 86 msg_data->msg_fetched = 1;
86 msg_data->msg_message = message; 87 msg_data->msg_message = message;
87 msg_data->msg_length = strlen(message); 88 msg_data->msg_length = strlen(message);
88 } 89 }
89 body = parseMail(mailmsg); 90 body = parseMail(mailmsg);
90 91
91 /* clean up */ 92 /* clean up */
92 if (mailmsg) 93 if (mailmsg)
93 mailmessage_free(mailmsg); 94 mailmessage_free(mailmsg);
94 if (message) 95 if (message)
95 free(message); 96 free(message);
96 97
97 return body; 98 return body;
98} 99}
99 100
100 101
101void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) 102void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb)
102{ 103{
103 login(); 104 login();
104 if (!m_nntp) 105 if (!m_nntp)
105 return; 106 return;
106 uint32_t res_messages,res_recent,res_unseen; 107 uint32_t res_messages,res_recent,res_unseen;
107 mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); 108 mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen);
108 parseList(target,m_nntp->sto_session,which,true); 109 parseList(target,m_nntp->sto_session,which,true, maxSizeInKb);
109} 110}
110 111
111void NNTPwrapper::login() 112void NNTPwrapper::login()
112{ 113{
113 if (account->getOffline()) 114 if (account->getOffline())
114 return; 115 return;
115 /* we'll hold the line */ 116 /* we'll hold the line */
116 if ( m_nntp != NULL ) 117 if ( m_nntp != NULL )
117 return; 118 return;
118 119
119 const char *server, *user, *pass; 120 const char *server, *user, *pass;
120 QString User,Pass; 121 QString User,Pass;
121 uint16_t port; 122 uint16_t port;
122 int err = NEWSNNTP_NO_ERROR; 123 int err = NEWSNNTP_NO_ERROR;
123 124
124 server = account->getServer().latin1(); 125 server = account->getServer().latin1();
125 port = account->getPort().toUInt(); 126 port = account->getPort().toUInt();
126 127
127 user = pass = 0; 128 user = pass = 0;
128 129
129 if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { 130 if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) {
130 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 131 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
131 login.show(); 132 login.show();
132 if ( QDialog::Accepted == login.exec() ) { 133 if ( QDialog::Accepted == login.exec() ) {
diff --git a/kmicromail/libmailwrapper/nntpwrapper.h b/kmicromail/libmailwrapper/nntpwrapper.h
index 2fb82f2..5d4e5ce 100644
--- a/kmicromail/libmailwrapper/nntpwrapper.h
+++ b/kmicromail/libmailwrapper/nntpwrapper.h
@@ -1,47 +1,48 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#ifndef __NNTPWRAPPER 2#ifndef __NNTPWRAPPER
2#define __NNTPWRAPPER 3#define __NNTPWRAPPER
3 4
4#include "mailwrapper.h" 5#include "mailwrapper.h"
5#include "genericwrapper.h" 6#include "genericwrapper.h"
6#include <qstring.h> 7#include <qstring.h>
7#include <libetpan/clist.h> 8#include <libetpan/clist.h>
8 9
9class encodedString; 10class encodedString;
10struct mailstorage; 11struct mailstorage;
11struct mailfolder; 12struct mailfolder;
12 13
13class NNTPwrapper : public Genericwrapper 14class NNTPwrapper : public Genericwrapper
14{ 15{
15 16
16 Q_OBJECT 17 Q_OBJECT
17 18
18public: 19public:
19 NNTPwrapper( NNTPaccount *a ); 20 NNTPwrapper( NNTPaccount *a );
20 virtual ~NNTPwrapper(); 21 virtual ~NNTPwrapper();
21 22
22 /* mailbox will be ignored */ 23 /* mailbox will be ignored */
23 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); 24 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 );
24 /* should only get the subscribed one */ 25 /* should only get the subscribed one */
25 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); 26 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
26 /* mailbox will be ignored */ 27 /* mailbox will be ignored */
27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 28 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
28 QStringList listAllNewsgroups(const QString&mask = QString::null); 29 QStringList listAllNewsgroups(const QString&mask = QString::null);
29 virtual void deleteMail(const RecMailP&mail); 30 virtual void deleteMail(const RecMailP&mail);
30 virtual void answeredMail(const RecMailP&mail); 31 virtual void answeredMail(const RecMailP&mail);
31 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); 32 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
32 33
33 virtual RecBodyP fetchBody( const RecMailP &mail ); 34 virtual RecBodyP fetchBody( const RecMailP &mail );
34 virtual encodedString* fetchRawBody(const RecMailP&mail); 35 virtual encodedString* fetchRawBody(const RecMailP&mail);
35 virtual void logout(); 36 virtual void logout();
36 virtual MAILLIB::ATYPE getType()const; 37 virtual MAILLIB::ATYPE getType()const;
37 virtual const QString&getName()const; 38 virtual const QString&getName()const;
38 static void nntp_progress( size_t current, size_t maximum ); 39 static void nntp_progress( size_t current, size_t maximum );
39 40
40protected: 41protected:
41 void login(); 42 void login();
42 NNTPaccount *account; 43 NNTPaccount *account;
43 mailstorage* m_nntp; 44 mailstorage* m_nntp;
44 45
45 46
46}; 47};
47 48
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp
index e5d083a..7a84b30 100644
--- a/kmicromail/libmailwrapper/pop3wrapper.cpp
+++ b/kmicromail/libmailwrapper/pop3wrapper.cpp
@@ -1,24 +1,25 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#include <stdlib.h> 2#include <stdlib.h>
2#include "pop3wrapper.h" 3#include "pop3wrapper.h"
3#include "mailtypes.h" 4#include "mailtypes.h"
4#include "logindialog.h" 5#include "logindialog.h"
5#include <libetpan/libetpan.h> 6#include <libetpan/libetpan.h>
6 7
7 8
8#include <qpe/global.h> 9#include <qpe/global.h>
9#include <qfile.h> 10#include <qfile.h>
10 11
11/* we don't fetch messages larger than 5 MB */ 12/* we don't fetch messages larger than 5 MB */
12#define HARD_MSG_SIZE_LIMIT 5242880 13#define HARD_MSG_SIZE_LIMIT 5242880
13 14
14using namespace Opie::Core; 15using namespace Opie::Core;
15POP3wrapper::POP3wrapper( POP3account *a ) 16POP3wrapper::POP3wrapper( POP3account *a )
16: Genericwrapper() { 17: Genericwrapper() {
17 account = a; 18 account = a;
18 m_pop3 = NULL; 19 m_pop3 = NULL;
19 msgTempName = a->getFileName()+"_msg_cache"; 20 msgTempName = a->getFileName()+"_msg_cache";
20 last_msg_id = 0; 21 last_msg_id = 0;
21} 22}
22 23
23POP3wrapper::~POP3wrapper() { 24POP3wrapper::~POP3wrapper() {
24 logout(); 25 logout();
@@ -75,56 +76,56 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) {
75 delete message; 76 delete message;
76 message = (char*)malloc(msg.length()+1*sizeof(char)); 77 message = (char*)malloc(msg.length()+1*sizeof(char));
77 memset(message,0,msg.length()+1); 78 memset(message,0,msg.length()+1);
78 memcpy(message,msg.latin1(),msg.length()); 79 memcpy(message,msg.latin1(),msg.length());
79 /* transform to libetpan stuff */ 80 /* transform to libetpan stuff */
80 mailmsg = mailmessage_new(); 81 mailmsg = mailmessage_new();
81 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); 82 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
82 generic_message_t * msg_data; 83 generic_message_t * msg_data;
83 msg_data = (generic_message_t *)mailmsg->msg_data; 84 msg_data = (generic_message_t *)mailmsg->msg_data;
84 msg_data->msg_fetched = 1; 85 msg_data->msg_fetched = 1;
85 msg_data->msg_message = message; 86 msg_data->msg_message = message;
86 msg_data->msg_length = strlen(message); 87 msg_data->msg_length = strlen(message);
87 } 88 }
88 body = parseMail(mailmsg); 89 body = parseMail(mailmsg);
89 90
90 /* clean up */ 91 /* clean up */
91 if (mailmsg) 92 if (mailmsg)
92 mailmessage_free(mailmsg); 93 mailmessage_free(mailmsg);
93 if (message) 94 if (message)
94 free(message); 95 free(message);
95 96
96 return body; 97 return body;
97} 98}
98 99
99void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) 100void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb )
100{ 101{
101 login(); 102 login();
102 if (!m_pop3) 103 if (!m_pop3)
103 return; 104 return;
104 uint32_t res_messages,res_recent,res_unseen; 105 uint32_t res_messages,res_recent,res_unseen;
105 mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); 106 mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen);
106 parseList(target,m_pop3->sto_session,"INBOX"); 107 parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb);
107 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); 108 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages));
108} 109}
109 110
110void POP3wrapper::login() 111void POP3wrapper::login()
111{ 112{
112 if (account->getOffline()) 113 if (account->getOffline())
113 return; 114 return;
114 /* we'll hold the line */ 115 /* we'll hold the line */
115 if ( m_pop3 != NULL ) 116 if ( m_pop3 != NULL )
116 return; 117 return;
117 118
118 const char *server, *user, *pass; 119 const char *server, *user, *pass;
119 uint16_t port; 120 uint16_t port;
120 int err = MAILPOP3_NO_ERROR; 121 int err = MAILPOP3_NO_ERROR;
121 122
122 server = account->getServer().latin1(); 123 server = account->getServer().latin1();
123 port = account->getPort().toUInt(); 124 port = account->getPort().toUInt();
124 125
125 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 126 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
126 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 127 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
127 login.show(); 128 login.show();
128 if ( QDialog::Accepted == login.exec() ) { 129 if ( QDialog::Accepted == login.exec() ) {
129 // ok 130 // ok
130 user = login.getUser().latin1(); 131 user = login.getUser().latin1();
@@ -171,48 +172,64 @@ void POP3wrapper::login()
171 mailsession * session = m_pop3->sto_session; 172 mailsession * session = m_pop3->sto_session;
172 mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; 173 mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session;
173 if (mail) { 174 if (mail) {
174 mail->pop3_progr_fun = &pop3_progress; 175 mail->pop3_progr_fun = &pop3_progress;
175 } 176 }
176 } 177 }
177} 178}
178 179
179void POP3wrapper::logout() 180void POP3wrapper::logout()
180{ 181{
181 if ( m_pop3 == NULL ) 182 if ( m_pop3 == NULL )
182 return; 183 return;
183 mailstorage_free(m_pop3); 184 mailstorage_free(m_pop3);
184 m_pop3 = 0; 185 m_pop3 = 0;
185} 186}
186 187
187 188
188QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { 189QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() {
189 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); 190 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>();
190 FolderP inb=new Folder("INBOX","/"); 191 FolderP inb=new Folder("INBOX","/");
191 folders->append(inb); 192 folders->append(inb);
192 return folders; 193 return folders;
193} 194}
194 195
196void POP3wrapper::deleteMailList(QValueList<RecMailP>&target)
197{
198 login();
199 if (!m_pop3)
200 return;
201 int iii = 0;
202 int count = target.count();
203 while (iii < count ) {
204 RecMailP mail = (*target.at( iii ));
205 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
206 if (err != MAIL_NO_ERROR) {
207 Global::statusMessage(tr("error deleting mail"));
208 }
209 ++iii;
210 }
211}
195void POP3wrapper::deleteMail(const RecMailP&mail) { 212void POP3wrapper::deleteMail(const RecMailP&mail) {
196 login(); 213 login();
197 if (!m_pop3) 214 if (!m_pop3)
198 return; 215 return;
199 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); 216 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
200 if (err != MAIL_NO_ERROR) { 217 if (err != MAIL_NO_ERROR) {
201 Global::statusMessage(tr("error deleting mail")); 218 Global::statusMessage(tr("error deleting mail"));
202 } 219 }
203} 220}
204 221
205void POP3wrapper::answeredMail(const RecMailP&) {} 222void POP3wrapper::answeredMail(const RecMailP&) {}
206 223
207int POP3wrapper::deleteAllMail(const FolderP&) { 224int POP3wrapper::deleteAllMail(const FolderP&) {
208 login(); 225 login();
209 if (!m_pop3) 226 if (!m_pop3)
210 return 0; 227 return 0;
211 int res = 1; 228 int res = 1;
212 229
213 uint32_t result = 0; 230 uint32_t result = 0;
214 int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); 231 int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result);
215 if (err != MAIL_NO_ERROR) { 232 if (err != MAIL_NO_ERROR) {
216 Global::statusMessage(tr("Error getting folder info")); 233 Global::statusMessage(tr("Error getting folder info"));
217 return 0; 234 return 0;
218 } 235 }
diff --git a/kmicromail/libmailwrapper/pop3wrapper.h b/kmicromail/libmailwrapper/pop3wrapper.h
index 5101fa5..ee754a4 100644
--- a/kmicromail/libmailwrapper/pop3wrapper.h
+++ b/kmicromail/libmailwrapper/pop3wrapper.h
@@ -1,42 +1,44 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#ifndef __POP3WRAPPER 2#ifndef __POP3WRAPPER
2#define __POP3WRAPPER 3#define __POP3WRAPPER
3 4
4#include "mailwrapper.h" 5#include "mailwrapper.h"
5#include "genericwrapper.h" 6#include "genericwrapper.h"
6#include <qstring.h> 7#include <qstring.h>
7 8
8class encodedString; 9class encodedString;
9struct mailstorage; 10struct mailstorage;
10struct mailfolder; 11struct mailfolder;
11 12
12class POP3wrapper : public Genericwrapper 13class POP3wrapper : public Genericwrapper
13{ 14{
14 Q_OBJECT 15 Q_OBJECT
15 16
16public: 17public:
17 POP3wrapper( POP3account *a ); 18 POP3wrapper( POP3account *a );
18 virtual ~POP3wrapper(); 19 virtual ~POP3wrapper();
19 /* mailbox will be ignored */ 20 /* mailbox will be ignored */
20 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); 21 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 );
21 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); 22 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
22 /* mailbox will be ignored */ 23 /* mailbox will be ignored */
23 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 24 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
24 25
25 virtual void deleteMail(const RecMailP&mail); 26 virtual void deleteMail(const RecMailP&mail);
26 virtual void answeredMail(const RecMailP&mail); 27 virtual void answeredMail(const RecMailP&mail);
28 virtual void deleteMailList(QValueList<RecMailP>&target);
27 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); 29 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
28 30
29 virtual RecBodyP fetchBody( const RecMailP &mail ); 31 virtual RecBodyP fetchBody( const RecMailP &mail );
30 virtual encodedString* fetchRawBody(const RecMailP&mail); 32 virtual encodedString* fetchRawBody(const RecMailP&mail);
31 virtual void logout(); 33 virtual void logout();
32 virtual MAILLIB::ATYPE getType()const; 34 virtual MAILLIB::ATYPE getType()const;
33 virtual const QString&getName()const; 35 virtual const QString&getName()const;
34 static void pop3_progress( size_t current, size_t maximum ); 36 static void pop3_progress( size_t current, size_t maximum );
35 37
36protected: 38protected:
37 void login(); 39 void login();
38 POP3account *account; 40 POP3account *account;
39 mailstorage*m_pop3; 41 mailstorage*m_pop3;
40}; 42};
41 43
42#endif 44#endif
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index d522ad0..3fbdcec 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,24 +1,25 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
2 3
3#include "settingsdialog.h" 4#include "settingsdialog.h"
4#include "opiemail.h" 5#include "opiemail.h"
5#include "editaccounts.h" 6#include "editaccounts.h"
6#include "composemail.h" 7#include "composemail.h"
7#include "mailistviewitem.h" 8#include "mailistviewitem.h"
8#include "viewmail.h" 9#include "viewmail.h"
9#include "selectstore.h" 10#include "selectstore.h"
10#include "selectsmtp.h" 11#include "selectsmtp.h"
11 12
12#include <qmessagebox.h> 13#include <qmessagebox.h>
13 14
14#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
15#include <libmailwrapper/smtpwrapper.h> 16#include <libmailwrapper/smtpwrapper.h>
16#include <libmailwrapper/mailtypes.h> 17#include <libmailwrapper/mailtypes.h>
17#include <libmailwrapper/abstractmail.h> 18#include <libmailwrapper/abstractmail.h>
18/* OPIE */ 19/* OPIE */
19//#include <qpe/resource.h> 20//#include <qpe/resource.h>
20#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
21 22
22/* QT */ 23/* QT */
23 24
24using namespace Opie::Core; 25using namespace Opie::Core;
@@ -257,48 +258,49 @@ void OpieMail::clearSelection()
257 258
258} 259}
259 260
260void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 261void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
261{ 262{
262 if (!mailView->currentItem()) return; 263 if (!mailView->currentItem()) return;
263 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 264 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
264 /* just the RIGHT button - or hold on pda */ 265 /* just the RIGHT button - or hold on pda */
265 if (button!=2) {return;} 266 if (button!=2) {return;}
266 if (!item) return; 267 if (!item) return;
267 QPopupMenu *m = new QPopupMenu(0); 268 QPopupMenu *m = new QPopupMenu(0);
268 if (m) 269 if (m)
269 { 270 {
270 if (mailtype==MAILLIB::A_NNTP) { 271 if (mailtype==MAILLIB::A_NNTP) {
271 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 272 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
272// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 273// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
273 } else { 274 } else {
274 if (folderView->currentisDraft()) { 275 if (folderView->currentisDraft()) {
275 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); 276 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
276 } 277 }
277 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 278 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
278 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 279 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
279 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 280 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
280 m->insertSeparator(); 281 m->insertSeparator();
282 m->insertItem(tr("Copy/Move all selected mail"),this,SLOT(slotMoveCopyAllMail()));
281 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 283 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
282 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); 284 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection()));
283 } 285 }
284 m->setFocus(); 286 m->setFocus();
285 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 287 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
286 delete m; 288 delete m;
287 } 289 }
288} 290}
289 291
290void OpieMail::slotShowFolders( bool show ) 292void OpieMail::slotShowFolders( bool show )
291{ 293{
292 if ( show && folderView->isHidden() ) 294 if ( show && folderView->isHidden() )
293 { 295 {
294 folderView->show(); 296 folderView->show();
295 } 297 }
296 else if ( !show && !folderView->isHidden() ) 298 else if ( !show && !folderView->isHidden() )
297 { 299 {
298 folderView->hide(); 300 folderView->hide();
299 } 301 }
300} 302}
301 303
302void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 304void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
303{ 305{
304 MailListViewItem*item = 0; 306 MailListViewItem*item = 0;
@@ -331,34 +333,76 @@ void OpieMail::slotMoveCopyMail()
331 if (!mailView->currentItem()) return; 333 if (!mailView->currentItem()) return;
332 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 334 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
333 AbstractMail*targetMail = 0; 335 AbstractMail*targetMail = 0;
334 QString targetFolder = ""; 336 QString targetFolder = "";
335 Selectstore sels; 337 Selectstore sels;
336 folderView->setupFolderselect(&sels); 338 folderView->setupFolderselect(&sels);
337 if (!sels.exec()) return; 339 if (!sels.exec()) return;
338 targetMail = sels.currentMail(); 340 targetMail = sels.currentMail();
339 targetFolder = sels.currentFolder(); 341 targetFolder = sels.currentFolder();
340 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 342 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
341 targetFolder.isEmpty()) 343 targetFolder.isEmpty())
342 { 344 {
343 return; 345 return;
344 } 346 }
345 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 347 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
346 { 348 {
347 QMessageBox::critical(0,tr("Error creating new Folder"), 349 QMessageBox::critical(0,tr("Error creating new Folder"),
348 tr("<center>Error while creating<br>new folder - breaking.</center>")); 350 tr("<center>Error while creating<br>new folder - breaking.</center>"));
349 return; 351 return;
350 } 352 }
351 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 353 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
352 folderView->refreshCurrent(); 354 folderView->refreshCurrent();
353} 355}
354 356
357void OpieMail::slotMoveCopyAllMail()
358{
359
360 if (!mailView->currentItem()) return;
361 QValueList<RecMailP> t;
362 if ( QMessageBox::warning(this, tr("Copy/Move all selected mails"), tr("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
363 {
364 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
365 while ( item ) {
366 if ( item->isSelected() ) {
367 t.append( item->data() );
368 }
369 item = (MailListViewItem*)item->nextSibling();
370 }
371 }
372 else
373 return;
374 if ( t.count() == 0 )
375 return;
376 RecMailP mail = t.first();
377 AbstractMail*targetMail = 0;
378 QString targetFolder = "";
379 Selectstore sels;
380 folderView->setupFolderselect(&sels);
381 if (!sels.exec()) return;
382 targetMail = sels.currentMail();
383 targetFolder = sels.currentFolder();
384 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
385 targetFolder.isEmpty())
386 {
387 return;
388 }
389 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
390 {
391 QMessageBox::critical(0,tr("Error creating new Folder"),
392 tr("<center>Error while creating<br>new folder - breaking.</center>"));
393 return;
394 }
395 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
396 folderView->refreshCurrent();
397}
398
355void OpieMail::reEditMail() 399void OpieMail::reEditMail()
356{ 400{
357 if (!mailView->currentItem()) return; 401 if (!mailView->currentItem()) return;
358 402
359 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 403 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
360 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 404 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
361 compose.slotAdjustColumns(); 405 compose.slotAdjustColumns();
362 compose.showMaximized(); 406 compose.showMaximized();
363 compose.exec(); 407 compose.exec();
364} 408}
diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h
index 143b0c4..934f232 100644
--- a/kmicromail/opiemail.h
+++ b/kmicromail/opiemail.h
@@ -1,46 +1,48 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#ifndef OPIEMAIL_H 2#ifndef OPIEMAIL_H
2#define OPIEMAIL_H 3#define OPIEMAIL_H
3 4
4#include "mainwindow.h" 5#include "mainwindow.h"
5#include <libmailwrapper/settings.h> 6#include <libmailwrapper/settings.h>
6 7
7#include <opie2/osmartpointer.h> 8#include <opie2/osmartpointer.h>
8#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
9 10
10class OpieMail : public MainWindow 11class OpieMail : public MainWindow
11{ 12{
12 Q_OBJECT 13 Q_OBJECT
13 14
14public: 15public:
15 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 16 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
16 virtual ~OpieMail(); 17 virtual ~OpieMail();
17 static QString appName() { return QString::fromLatin1("opiemail"); } 18 static QString appName() { return QString::fromLatin1("opiemail"); }
18 19
19public slots: 20public slots:
20 virtual void slotwriteMail(const QString&name,const QString&email); 21 virtual void slotwriteMail(const QString&name,const QString&email);
21 virtual void slotwriteMail2(const QString&nameemail); 22 virtual void slotwriteMail2(const QString&nameemail);
22 virtual void slotComposeMail(); 23 virtual void slotComposeMail();
23 virtual void appMessage(const QCString &msg, const QByteArray &data); 24 virtual void appMessage(const QCString &msg, const QByteArray &data);
24 virtual void message(const QCString &msg, const QByteArray &data); 25 virtual void message(const QCString &msg, const QByteArray &data);
25protected slots: 26protected slots:
26 virtual void slotSendQueued(); 27 virtual void slotSendQueued();
27 virtual void slotSearchMails(); 28 virtual void slotSearchMails();
28 virtual void slotEditSettings(); 29 virtual void slotEditSettings();
29 virtual void slotEditAccounts(); 30 virtual void slotEditAccounts();
30 virtual void displayMail(); 31 virtual void displayMail();
31 virtual void slotDeleteMail(); 32 virtual void slotDeleteMail();
32 virtual void slotDeleteAllMail(); 33 virtual void slotDeleteAllMail();
33 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 34 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
34 virtual void slotShowFolders( bool show ); 35 virtual void slotShowFolders( bool show );
35 virtual void refreshMailView(const QValueList<RecMailP>&); 36 virtual void refreshMailView(const QValueList<RecMailP>&);
36 virtual void mailLeftClicked( QListViewItem * ); 37 virtual void mailLeftClicked( QListViewItem * );
37 virtual void slotMoveCopyMail(); 38 virtual void slotMoveCopyMail();
39 virtual void slotMoveCopyAllMail();
38 virtual void reEditMail(); 40 virtual void reEditMail();
39 void clearSelection(); 41 void clearSelection();
40 42
41private: 43private:
42 Settings *settings; 44 Settings *settings;
43 45
44}; 46};
45 47
46#endif 48#endif
diff --git a/kmicromail/selectstoreui.ui b/kmicromail/selectstoreui.ui
index 5f0e507..dd3fc92 100644
--- a/kmicromail/selectstoreui.ui
+++ b/kmicromail/selectstoreui.ui
@@ -1,79 +1,79 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>selectstoreui</class> 2<class>selectstoreui</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>selectstoreui</cstring> 7 <cstring>selectstoreui</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>182</width> 14 <width>275</width>
15 <height>273</height> 15 <height>304</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Select target box</string> 20 <string>Select target box</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <vbox> 28 <grid>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>1</number> 31 <number>11</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>1</number> 35 <number>6</number>
36 </property> 36 </property>
37 <widget> 37 <widget row="0" column="0" rowspan="1" colspan="2" >
38 <class>QLabel</class> 38 <class>QLabel</class>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>name</name> 40 <name>name</name>
41 <cstring>headlabel</cstring> 41 <cstring>headlabel</cstring>
42 </property> 42 </property>
43 <property stdset="1"> 43 <property stdset="1">
44 <name>text</name> 44 <name>text</name>
45 <string>&lt;b&gt;Store mail(s) to&lt;/b&gt;</string> 45 <string>&lt;b&gt;Store mail(s) to&lt;/b&gt;</string>
46 </property> 46 </property>
47 <property stdset="1"> 47 <property stdset="1">
48 <name>alignment</name> 48 <name>alignment</name>
49 <set>AlignCenter</set> 49 <set>AlignCenter</set>
50 </property> 50 </property>
51 <property> 51 <property>
52 <name>hAlign</name> 52 <name>hAlign</name>
53 </property> 53 </property>
54 </widget> 54 </widget>
55 <widget> 55 <widget row="1" column="0" rowspan="1" colspan="2" >
56 <class>QLayoutWidget</class> 56 <class>QLayoutWidget</class>
57 <property stdset="1"> 57 <property stdset="1">
58 <name>name</name> 58 <name>name</name>
59 <cstring>Layout2</cstring> 59 <cstring>Layout2</cstring>
60 </property> 60 </property>
61 <grid> 61 <grid>
62 <property stdset="1"> 62 <property stdset="1">
63 <name>margin</name> 63 <name>margin</name>
64 <number>0</number> 64 <number>0</number>
65 </property> 65 </property>
66 <property stdset="1"> 66 <property stdset="1">
67 <name>spacing</name> 67 <name>spacing</name>
68 <number>6</number> 68 <number>6</number>
69 </property> 69 </property>
70 <widget row="1" column="1" > 70 <widget row="1" column="1" >
71 <class>QComboBox</class> 71 <class>QComboBox</class>
72 <property stdset="1"> 72 <property stdset="1">
73 <name>name</name> 73 <name>name</name>
74 <cstring>folderSelection</cstring> 74 <cstring>folderSelection</cstring>
75 </property> 75 </property>
76 <property stdset="1"> 76 <property stdset="1">
77 <name>sizePolicy</name> 77 <name>sizePolicy</name>
78 <sizepolicy> 78 <sizepolicy>
79 <hsizetype>3</hsizetype> 79 <hsizetype>3</hsizetype>
@@ -119,146 +119,184 @@
119 <name>name</name> 119 <name>name</name>
120 <cstring>accountlabel</cstring> 120 <cstring>accountlabel</cstring>
121 </property> 121 </property>
122 <property stdset="1"> 122 <property stdset="1">
123 <name>sizePolicy</name> 123 <name>sizePolicy</name>
124 <sizepolicy> 124 <sizepolicy>
125 <hsizetype>1</hsizetype> 125 <hsizetype>1</hsizetype>
126 <vsizetype>1</vsizetype> 126 <vsizetype>1</vsizetype>
127 </sizepolicy> 127 </sizepolicy>
128 </property> 128 </property>
129 <property stdset="1"> 129 <property stdset="1">
130 <name>text</name> 130 <name>text</name>
131 <string>Account:</string> 131 <string>Account:</string>
132 </property> 132 </property>
133 <property stdset="1"> 133 <property stdset="1">
134 <name>alignment</name> 134 <name>alignment</name>
135 <set>AlignVCenter|AlignRight</set> 135 <set>AlignVCenter|AlignRight</set>
136 </property> 136 </property>
137 <property> 137 <property>
138 <name>hAlign</name> 138 <name>hAlign</name>
139 </property> 139 </property>
140 </widget> 140 </widget>
141 </grid> 141 </grid>
142 </widget> 142 </widget>
143 <widget> 143 <widget row="2" column="0" rowspan="1" colspan="2" >
144 <class>Line</class> 144 <class>Line</class>
145 <property stdset="1"> 145 <property stdset="1">
146 <name>name</name> 146 <name>name</name>
147 <cstring>Line1</cstring> 147 <cstring>Line1</cstring>
148 </property> 148 </property>
149 <property stdset="1"> 149 <property stdset="1">
150 <name>orientation</name> 150 <name>orientation</name>
151 <enum>Horizontal</enum> 151 <enum>Horizontal</enum>
152 </property> 152 </property>
153 </widget> 153 </widget>
154 <widget> 154 <widget row="3" column="0" rowspan="1" colspan="2" >
155 <class>QCheckBox</class> 155 <class>QCheckBox</class>
156 <property stdset="1"> 156 <property stdset="1">
157 <name>name</name> 157 <name>name</name>
158 <cstring>newFoldersel</cstring> 158 <cstring>newFoldersel</cstring>
159 </property> 159 </property>
160 <property stdset="1"> 160 <property stdset="1">
161 <name>text</name> 161 <name>text</name>
162 <string>Create new folder</string> 162 <string>Create new folder</string>
163 </property> 163 </property>
164 </widget> 164 </widget>
165 <widget> 165 <widget row="4" column="0" rowspan="1" colspan="2" >
166 <class>QLineEdit</class> 166 <class>QLineEdit</class>
167 <property stdset="1"> 167 <property stdset="1">
168 <name>name</name> 168 <name>name</name>
169 <cstring>newFolderedit</cstring> 169 <cstring>newFolderedit</cstring>
170 </property> 170 </property>
171 <property stdset="1"> 171 <property stdset="1">
172 <name>enabled</name> 172 <name>enabled</name>
173 <bool>false</bool> 173 <bool>false</bool>
174 </property> 174 </property>
175 </widget> 175 </widget>
176 <widget> 176 <widget row="5" column="0" rowspan="1" colspan="2" >
177 <class>QLabel</class> 177 <class>QLabel</class>
178 <property stdset="1"> 178 <property stdset="1">
179 <name>name</name> 179 <name>name</name>
180 <cstring>newFolderLabel</cstring> 180 <cstring>newFolderLabel</cstring>
181 </property> 181 </property>
182 <property stdset="1"> 182 <property stdset="1">
183 <name>text</name> 183 <name>text</name>
184 <string>Prefix will prepend, no need to enter it!</string> 184 <string>Prefix will prepend, no need to enter it!</string>
185 </property> 185 </property>
186 <property stdset="1"> 186 <property stdset="1">
187 <name>alignment</name> 187 <name>alignment</name>
188 <set>WordBreak|AlignCenter</set> 188 <set>WordBreak|AlignCenter</set>
189 </property> 189 </property>
190 <property> 190 <property>
191 <name>hAlign</name> 191 <name>hAlign</name>
192 </property> 192 </property>
193 <property> 193 <property>
194 <name>wordwrap</name> 194 <name>wordwrap</name>
195 </property> 195 </property>
196 </widget> 196 </widget>
197 <widget> 197 <widget row="6" column="0" rowspan="1" colspan="2" >
198 <class>Line</class> 198 <class>Line</class>
199 <property stdset="1"> 199 <property stdset="1">
200 <name>name</name> 200 <name>name</name>
201 <cstring>Line2</cstring> 201 <cstring>Line2</cstring>
202 </property> 202 </property>
203 <property stdset="1"> 203 <property stdset="1">
204 <name>orientation</name> 204 <name>orientation</name>
205 <enum>Horizontal</enum> 205 <enum>Horizontal</enum>
206 </property> 206 </property>
207 </widget> 207 </widget>
208 <widget> 208 <spacer row="9" column="0" >
209 <class>QCheckBox</class>
210 <property stdset="1">
211 <name>name</name>
212 <cstring>selMove</cstring>
213 </property>
214 <property stdset="1">
215 <name>text</name>
216 <string>Move mail(s)</string>
217 </property>
218 </widget>
219 <spacer>
220 <property> 209 <property>
221 <name>name</name> 210 <name>name</name>
222 <cstring>Spacer2</cstring> 211 <cstring>Spacer2</cstring>
223 </property> 212 </property>
224 <property stdset="1"> 213 <property stdset="1">
225 <name>orientation</name> 214 <name>orientation</name>
226 <enum>Vertical</enum> 215 <enum>Vertical</enum>
227 </property> 216 </property>
228 <property stdset="1"> 217 <property stdset="1">
229 <name>sizeType</name> 218 <name>sizeType</name>
230 <enum>Expanding</enum> 219 <enum>Expanding</enum>
231 </property> 220 </property>
232 <property> 221 <property>
233 <name>sizeHint</name> 222 <name>sizeHint</name>
234 <size> 223 <size>
235 <width>20</width> 224 <width>20</width>
236 <height>20</height> 225 <height>20</height>
237 </size> 226 </size>
238 </property> 227 </property>
239 </spacer> 228 </spacer>
240 </vbox> 229 <widget row="8" column="0" rowspan="1" colspan="2" >
230 <class>QCheckBox</class>
231 <property stdset="1">
232 <name>name</name>
233 <cstring>selMove</cstring>
234 </property>
235 <property stdset="1">
236 <name>text</name>
237 <string>Move mail(s)</string>
238 </property>
239 </widget>
240 <widget row="7" column="0" >
241 <class>QCheckBox</class>
242 <property stdset="1">
243 <name>name</name>
244 <cstring>useSize</cstring>
245 </property>
246 <property stdset="1">
247 <name>text</name>
248 <string>apply only to mails smaller</string>
249 </property>
250 </widget>
251 <widget row="7" column="1" >
252 <class>QSpinBox</class>
253 <property stdset="1">
254 <name>name</name>
255 <cstring>sizeSpinBox</cstring>
256 </property>
257 <property stdset="1">
258 <name>suffix</name>
259 <string> kB</string>
260 </property>
261 <property stdset="1">
262 <name>maxValue</name>
263 <number>8192</number>
264 </property>
265 <property stdset="1">
266 <name>minValue</name>
267 <number>1</number>
268 </property>
269 <property stdset="1">
270 <name>lineStep</name>
271 <number>1</number>
272 </property>
273 <property stdset="1">
274 <name>value</name>
275 <number>5</number>
276 </property>
277 </widget>
278 </grid>
241</widget> 279</widget>
242<connections> 280<connections>
243 <connection> 281 <connection>
244 <sender>selMove</sender> 282 <sender>selMove</sender>
245 <signal>clicked()</signal> 283 <signal>clicked()</signal>
246 <receiver>selectstoreui</receiver> 284 <receiver>selectstoreui</receiver>
247 <slot>slotMoveMail()</slot> 285 <slot>slotMoveMail()</slot>
248 </connection> 286 </connection>
249 <connection> 287 <connection>
250 <sender>newFoldersel</sender> 288 <sender>newFoldersel</sender>
251 <signal>clicked()</signal> 289 <signal>clicked()</signal>
252 <receiver>selectstoreui</receiver> 290 <receiver>selectstoreui</receiver>
253 <slot>slotCreateNewFolder()</slot> 291 <slot>slotCreateNewFolder()</slot>
254 </connection> 292 </connection>
255 <connection> 293 <connection>
256 <sender>accountSelection</sender> 294 <sender>accountSelection</sender>
257 <signal>activated(int)</signal> 295 <signal>activated(int)</signal>
258 <receiver>selectstoreui</receiver> 296 <receiver>selectstoreui</receiver>
259 <slot>slotAccountselected(int)</slot> 297 <slot>slotAccountselected(int)</slot>
260 </connection> 298 </connection>
261 <connection> 299 <connection>
262 <sender>folderSelection</sender> 300 <sender>folderSelection</sender>
263 <signal>activated(int)</signal> 301 <signal>activated(int)</signal>
264 <receiver>selectstoreui</receiver> 302 <receiver>selectstoreui</receiver>