summaryrefslogtreecommitdiffabout
path: root/kmicromail
Side-by-side diff
Diffstat (limited to 'kmicromail') (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
@@ -5,24 +5,26 @@
#include <libmailwrapper/settings.h>
#include <libmailwrapper/mailwrapper.h>
#include <libmailwrapper/mailtypes.h>
#include <libmailwrapper/abstractmail.h>
/* OPIE */
#include <qpe/qpeapplication.h>
/* QT */
#include <qmessagebox.h>
#include <qpopupmenu.h>
+#include <qcheckbox.h>
+#include <qspinbox.h>
using namespace Opie::Core;
AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
: QListView( parent, name, flags )
{
connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
SLOT( refresh(QListViewItem*) ) );
connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) );
setSorting(0);
}
@@ -149,22 +151,26 @@ void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrappe
targetFolder = sels.currentFolder();
if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
targetFolder.isEmpty())
{
return;
}
if (sels.newFolder() && !targetMail->createMbox(targetFolder))
{
QMessageBox::critical(0,tr("Error creating new Folder"),
tr("<center>Error while creating<br>new folder - breaking.</center>"));
return;
}
- fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails());
+ int maxsize = 0;
+ if ( sels.useSize->isChecked())
+ maxsize = sels.sizeSpinBox->value();
+
+ fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
refreshCurrent();
}
bool AccountView::currentisDraft()
{
AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
if (!view) return false;
return view->isDraftfolder();
}
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,12 +1,13 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#include "abstractmail.h"
#include "imapwrapper.h"
#include "pop3wrapper.h"
#include "nntpwrapper.h"
#include "mhwrapper.h"
#include "mailtypes.h"
#include <kdecore/kstandarddirs.h>
#include <qfile.h>
#include <qtextstream.h>
@@ -128,42 +129,56 @@ QString AbstractMail::defaultLocalfolder()
return f;
}
QString AbstractMail::draftFolder()
{
return QString("Drafts");
}
/* temporary - will be removed when implemented in all classes */
void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &)
{
}
+void AbstractMail::deleteMailList(const QValueList<RecMailP>&target)
+{
+ qDebug("AbstractMail::deleteMailList:: Please reimplement! ");
+}
void AbstractMail::mvcpAllMails(const FolderP&fromFolder,
- const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+ const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb)
+{
+ QValueList<RecMailP> t;
+ listMessages(fromFolder->getName(),t, maxSizeInKb);
+ mvcpMailList( t,targetFolder,targetWrapper,moveit);
+
+}
+void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t,
+ const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
- QValueList<RecMailP> t;
- listMessages(fromFolder->getName(),t);
+
encodedString*st = 0;
- while (t.count()>0) {
- RecMailP r = (*t.begin());
+ int iii = 0;
+ int count = t.count();
+ while (iii < count ) {
+ RecMailP r = (*t.at( iii ));
st = fetchRawBody(r);
if (st) {
targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
delete st;
}
- t.remove(t.begin());
+ ++iii;
}
if (moveit) {
- deleteAllMail(fromFolder);
+ deleteMailList( t );
+ //deleteAllMail(fromFolder);
}
}
void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
encodedString*st = 0;
st = fetchRawBody(mail);
if (st) {
targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
delete st;
}
if (moveit) {
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,53 +1,57 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#ifndef __abstract_mail_
#define __abstract_mail_
#include "maildefines.h"
#include "settings.h"
#include <qobject.h>
#include <opie2/osmartpointer.h>
#include "mailtypes.h"
class IMAPwrapper;
class POP3wrapper;
class Folder;
class encodedString;
struct folderStat;
class AbstractMail:public QObject
{
Q_OBJECT
public:
AbstractMail(){};
virtual ~AbstractMail(){}
virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0;
- virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0;
+ virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target, int sizeInKb = 0 )=0;
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0;
virtual RecBodyP fetchBody(const RecMailP&mail)=0;
virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0;
virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0;
virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0;
virtual encodedString* fetchRawBody(const RecMailP&mail)=0;
virtual void deleteMail(const RecMailP&mail)=0;
+ virtual void deleteMailList(const QValueList<RecMailP>&target);
virtual void answeredMail(const RecMailP&mail)=0;
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0;
virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target);
virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0;
virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
- const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
+ const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int sizeInKb = 0);
+ virtual void mvcpMailList(const QValueList<RecMailP>& t,
+ const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual void cleanMimeCache(){};
/* mail box methods */
/* parameter is the box to create.
* if the implementing subclass has prefixes,
* them has to be appended automatic.
*/
virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0,
const QString& delemiter="/",bool getsubfolder=false);
virtual void logout()=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,12 +1,13 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#include "genericwrapper.h"
#include <libetpan/libetpan.h>
#include "mailtypes.h"
using namespace Opie::Core;
Genericwrapper::Genericwrapper()
: AbstractMail()
{
bodyCache.clear();
m_storage = 0;
@@ -383,25 +384,25 @@ QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies)
h.remove(0,1);
}
while (h.length()>0 && h[h.length()-1]=='>') {
h.remove(h.length()-1,1);
}
if (h.length()>0) {
res.append(h);
}
}
return res;
}
-void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to)
+void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb)
{
int r;
mailmessage_list * env_list = 0;
r = mailsession_get_messages_list(session,&env_list);
if (r != MAIL_NO_ERROR) {
; // odebug << "Error message list" << oendl;
return;
}
r = mailsession_get_envelopes_list(session, env_list);
if (r != MAIL_NO_ERROR) {
; // odebug << "Error filling message list" << oendl;
if (env_list) {
@@ -463,18 +464,19 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &
}
#if 0
refs = single_fields.fld_references;
if (refs && refs->mid_list && clist_count(refs->mid_list)) {
char * text = (char*)refs->mid_list->first->data;
mail->setReplyto(QString(text));
}
#endif
if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list &&
clist_count(single_fields.fld_in_reply_to->mid_list)) {
mail->setInreply(parseInreplies(single_fields.fld_in_reply_to));
}
- target.append(mail);
+ if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 )
+ target.append(mail);
}
if (env_list) {
mailmessage_list_free(env_list);
}
}
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,12 +1,13 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#ifndef __GENERIC_WRAPPER_H
#define __GENERIC_WRAPPER_H
#include "abstractmail.h"
#include <qmap.h>
#include <qstring.h>
#include <libetpan/clist.h>
class RecMail;
class RecBody;
class encodedString;
struct mailpop3;
@@ -45,23 +46,23 @@ public:
protected:
RecBodyP parseMail( mailmessage * msg );
QString parseMailboxList( mailimf_mailbox_list *list );
QString parseMailbox( mailimf_mailbox *box );
QString parseGroup( mailimf_group *group );
QString parseAddressList( mailimf_address_list *list );
QString parseDateTime( mailimf_date_time *date );
void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1);
static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime);
static void fillParameters(RecPartP&target,clist*parameters);
static QString getencoding(mailmime_mechanism*aEnc);
- virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false);
+ virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false, int maxSizeInKb = 0);
QStringList parseInreplies(mailimf_in_reply_to * in_replies);
QString msgTempName;
unsigned int last_msg_id;
QMap<QString,encodedString*> bodyCache;
mailstorage * m_storage;
mailfolder*m_folder;
};
#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,12 +1,13 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#include <stdlib.h>
#include <libetpan/libetpan.h>
#include <qpe/global.h>
#include <qapplication.h>
#include "imapwrapper.h"
#include "mailtypes.h"
#include "logindialog.h"
using namespace Opie::Core;
IMAPwrapper::IMAPwrapper( IMAPaccount *a )
: AbstractMail()
{
@@ -193,25 +194,25 @@ void IMAPwrapper::login()
void IMAPwrapper::logout()
{
int err = MAILIMAP_NO_ERROR;
if (!m_imap) return;
err = mailimap_logout( m_imap );
err = mailimap_close( m_imap );
mailimap_free( m_imap );
m_imap = 0;
m_Lastmbox = "";
}
-void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target )
+void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb)
{
int err = MAILIMAP_NO_ERROR;
clist *result = 0;
clistcell *current;
mailimap_fetch_type *fetchType = 0;
mailimap_set *set = 0;
login();
if (!m_imap) {
return;
}
/* select mailbox READONLY for operations */
@@ -241,28 +242,30 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma
mailimap_fetch_type_free( fetchType );
QString date,subject,from;
if ( err == MAILIMAP_NO_ERROR ) {
mailimap_msg_att * msg_att;
int i = 0;
for (current = clist_begin(result); current != 0; current=clist_next(current)) {
++i;
msg_att = (mailimap_msg_att*)current->data;
RecMail*m = parse_list_result(msg_att);
if (m) {
- m->setNumber(i);
- m->setMbox(mailbox);
- m->setWrapper(this);
- target.append(m);
+ if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) {
+ m->setNumber(i);
+ m->setMbox(mailbox);
+ m->setWrapper(this);
+ target.append(m);
+ }
}
}
Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count()));
} else {
Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response));
}
if (result) mailimap_fetch_list_free(result);
}
QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
{
const char *path, *mask;
@@ -857,25 +860,67 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which
char*t=enc->enc_value;
encoding=QString(enc->enc_value);
enc->enc_value=0L;
free(t);
}
}
if (which->bd_description) {
target_part->setDescription(QString(which->bd_description));
}
target_part->setEncoding(encoding);
target_part->setSize(which->bd_size);
}
+void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target)
+{
+ mailimap_flag_list*flist;
+ mailimap_set *set;
+ mailimap_store_att_flags * store_flags;
+ int err;
+ login();
+ if (!m_imap) {
+ return;
+ }
+ int iii = 0;
+ int count = target.count();
+ qDebug("imap remove count %d ", count);
+ while (iii < count ) {
+ qDebug("IMAP remove %d ", iii);
+ RecMailP mail = (*target.at( iii ));
+ err = selectMbox(mail->getMbox());
+ if ( err != MAILIMAP_NO_ERROR ) {
+ return;
+ }
+ flist = mailimap_flag_list_new_empty();
+ mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
+ store_flags = mailimap_store_att_flags_new_set_flags(flist);
+ set = mailimap_set_new_single(mail->getNumber());
+ err = mailimap_store(m_imap,set,store_flags);
+ mailimap_set_free( set );
+ mailimap_store_att_flags_free(store_flags);
+
+ if (err != MAILIMAP_NO_ERROR) {
+ // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
+ return;
+ }
+ // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
+ /* should we realy do that at this moment? */
+
+ err = mailimap_expunge(m_imap);
+ if (err != MAILIMAP_NO_ERROR) {
+ Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
+ }
+ ++iii;
+ }
+}
void IMAPwrapper::deleteMail(const RecMailP&mail)
{
mailimap_flag_list*flist;
mailimap_set *set;
mailimap_store_att_flags * store_flags;
int err;
login();
if (!m_imap) {
return;
}
err = selectMbox(mail->getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
@@ -886,29 +931,31 @@ void IMAPwrapper::deleteMail(const RecMailP&mail)
store_flags = mailimap_store_att_flags_new_set_flags(flist);
set = mailimap_set_new_single(mail->getNumber());
err = mailimap_store(m_imap,set,store_flags);
mailimap_set_free( set );
mailimap_store_att_flags_free(store_flags);
if (err != MAILIMAP_NO_ERROR) {
// odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
return;
}
// odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
/* should we realy do that at this moment? */
+
err = mailimap_expunge(m_imap);
if (err != MAILIMAP_NO_ERROR) {
- // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
+ Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
}
- // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl;
+ qDebug("IMAPwrapper::deleteMail ");
+
}
void IMAPwrapper::answeredMail(const RecMailP&mail)
{
mailimap_flag_list*flist;
mailimap_set *set;
mailimap_store_att_flags * store_flags;
int err;
login();
if (!m_imap) {
return;
}
@@ -1111,28 +1158,29 @@ const QString&IMAPwrapper::getName()const
// odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl;
return account->getAccountName();
}
encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail)
{
// dummy
QValueList<int> path;
return fetchRawPart(mail,path,false);
}
void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
- const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+ const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb)
{
- if (targetWrapper != this) {
- AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
+ if (targetWrapper != this || maxSizeInKb > 0 ) {
+ AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb);
+ qDebug("IMAPwrapper::mvcpAllMails::Using generic");
// odebug << "Using generic" << oendl;
return;
}
mailimap_set *set = 0;
login();
if (!m_imap) {
return;
}
int err = selectMbox(fromFolder->getName());
if ( err != MAILIMAP_NO_ERROR ) {
return;
}
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,12 +1,13 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#ifndef __IMAPWRAPPER
#define __IMAPWRAPPER
#include <qlist.h>
#include "mailwrapper.h"
#include "abstractmail.h"
#include <libetpan/clist.h>
struct mailimap;
struct mailimap_body;
struct mailimap_body_type_1part;
struct mailimap_body_type_text;
@@ -15,33 +16,34 @@ struct mailimap_body_type_msg;
struct mailimap_body_type_mpart;
struct mailimap_body_fields;
struct mailimap_msg_att;
class encodedString;
class IMAPwrapper : public AbstractMail
{
Q_OBJECT
public:
IMAPwrapper( IMAPaccount *a );
virtual ~IMAPwrapper();
virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
- virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
+ virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target , int sizeInKb = 0);
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMailP&mail);
+ void deleteMailList(const QValueList<RecMailP>&target);
virtual void answeredMail(const RecMailP&mail);
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
- const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
+ const QString&targetFolder,AbstractMail*targetWrapper,bool moveit,int sizeInKb = 0);
virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual RecBodyP fetchBody(const RecMailP&mail);
virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part);
virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part);
virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part);
virtual encodedString* fetchRawBody(const RecMailP&mail);
virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0,
const QString& delemiter="/",bool getsubfolder=false);
virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder);
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,12 +1,13 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#include "mhwrapper.h"
#include "mailtypes.h"
#include "mailwrapper.h"
#include <libetpan/libetpan.h>
#include <qdir.h>
#include <qmessagebox.h>
#include <stdlib.h>
#include <qpe/global.h>
#include <oprocess.h>
//#include <opie2/odebug.h>
using namespace Opie::Core;
@@ -53,37 +54,37 @@ void MHwrapper::clean_storage()
if (m_storage) {
mailstorage_disconnect(m_storage);
mailstorage_free(m_storage);
m_storage = 0;
}
}
MHwrapper::~MHwrapper()
{
clean_storage();
}
-void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target )
+void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb )
{
init_storage();
if (!m_storage) {
return;
}
QString f = buildPath(mailbox);
int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
if (r!=MAIL_NO_ERROR) {
qDebug("listMessages: error selecting folder! ");
return;
}
- parseList(target,m_storage->sto_session,f);
+ parseList(target,m_storage->sto_session,f, false, maxSizeInKb );
Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count()));
}
QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders()
{
QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >();
/* this is needed! */
if (m_storage) mailstorage_disconnect(m_storage);
init_storage();
if (!m_storage) {
return folders;
}
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,32 +1,33 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#ifndef __MH_WRAPPER_H
#define __MH_WRAPPER_H
#include "maildefines.h"
#include "genericwrapper.h"
#include <qstring.h>
class encodedString;
struct mailmbox_folder;
namespace Opie {namespace Core {class OProcess;}}
class MHwrapper : public Genericwrapper
{
Q_OBJECT
public:
MHwrapper(const QString & dir,const QString&name);
virtual ~MHwrapper();
- virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target );
+ virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 );
virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMailP&mail);
virtual void answeredMail(const RecMailP&mail);
virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0,
const QString&d="",bool s=false);
virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&);
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,12 +1,13 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#include "nntpwrapper.h"
#include "logindialog.h"
#include "mailtypes.h"
#include <qfile.h>
#include <stdlib.h>
#include <libetpan/libetpan.h>
@@ -89,32 +90,32 @@ RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) {
body = parseMail(mailmsg);
/* clean up */
if (mailmsg)
mailmessage_free(mailmsg);
if (message)
free(message);
return body;
}
-void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target )
+void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb)
{
login();
if (!m_nntp)
return;
uint32_t res_messages,res_recent,res_unseen;
mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen);
- parseList(target,m_nntp->sto_session,which,true);
+ parseList(target,m_nntp->sto_session,which,true, maxSizeInKb);
}
void NNTPwrapper::login()
{
if (account->getOffline())
return;
/* we'll hold the line */
if ( m_nntp != NULL )
return;
const char *server, *user, *pass;
QString User,Pass;
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,35 +1,36 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#ifndef __NNTPWRAPPER
#define __NNTPWRAPPER
#include "mailwrapper.h"
#include "genericwrapper.h"
#include <qstring.h>
#include <libetpan/clist.h>
class encodedString;
struct mailstorage;
struct mailfolder;
class NNTPwrapper : public Genericwrapper
{
Q_OBJECT
public:
NNTPwrapper( NNTPaccount *a );
virtual ~NNTPwrapper();
/* mailbox will be ignored */
- virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target );
+ virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 );
/* should only get the subscribed one */
virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
/* mailbox will be ignored */
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
QStringList listAllNewsgroups(const QString&mask = QString::null);
virtual void deleteMail(const RecMailP&mail);
virtual void answeredMail(const RecMailP&mail);
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
virtual RecBodyP fetchBody( const RecMailP &mail );
virtual encodedString* fetchRawBody(const RecMailP&mail);
virtual void logout();
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,12 +1,13 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#include <stdlib.h>
#include "pop3wrapper.h"
#include "mailtypes.h"
#include "logindialog.h"
#include <libetpan/libetpan.h>
#include <qpe/global.h>
#include <qfile.h>
/* we don't fetch messages larger than 5 MB */
#define HARD_MSG_SIZE_LIMIT 5242880
@@ -87,32 +88,32 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) {
}
body = parseMail(mailmsg);
/* clean up */
if (mailmsg)
mailmessage_free(mailmsg);
if (message)
free(message);
return body;
}
-void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target )
+void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb )
{
login();
if (!m_pop3)
return;
uint32_t res_messages,res_recent,res_unseen;
mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen);
- parseList(target,m_pop3->sto_session,"INBOX");
+ parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb);
Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages));
}
void POP3wrapper::login()
{
if (account->getOffline())
return;
/* we'll hold the line */
if ( m_pop3 != NULL )
return;
const char *server, *user, *pass;
@@ -183,24 +184,40 @@ void POP3wrapper::logout()
mailstorage_free(m_pop3);
m_pop3 = 0;
}
QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() {
QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>();
FolderP inb=new Folder("INBOX","/");
folders->append(inb);
return folders;
}
+void POP3wrapper::deleteMailList(QValueList<RecMailP>&target)
+{
+ login();
+ if (!m_pop3)
+ return;
+ int iii = 0;
+ int count = target.count();
+ while (iii < count ) {
+ RecMailP mail = (*target.at( iii ));
+ int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
+ if (err != MAIL_NO_ERROR) {
+ Global::statusMessage(tr("error deleting mail"));
+ }
+ ++iii;
+ }
+}
void POP3wrapper::deleteMail(const RecMailP&mail) {
login();
if (!m_pop3)
return;
int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
if (err != MAIL_NO_ERROR) {
Global::statusMessage(tr("error deleting mail"));
}
}
void POP3wrapper::answeredMail(const RecMailP&) {}
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,38 +1,40 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#ifndef __POP3WRAPPER
#define __POP3WRAPPER
#include "mailwrapper.h"
#include "genericwrapper.h"
#include <qstring.h>
class encodedString;
struct mailstorage;
struct mailfolder;
class POP3wrapper : public Genericwrapper
{
Q_OBJECT
public:
POP3wrapper( POP3account *a );
virtual ~POP3wrapper();
/* mailbox will be ignored */
- virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target );
+ virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 );
virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
/* mailbox will be ignored */
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMailP&mail);
virtual void answeredMail(const RecMailP&mail);
+ virtual void deleteMailList(QValueList<RecMailP>&target);
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
virtual RecBodyP fetchBody( const RecMailP &mail );
virtual encodedString* fetchRawBody(const RecMailP&mail);
virtual void logout();
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
static void pop3_progress( size_t current, size_t maximum );
protected:
void login();
POP3account *account;
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index d522ad0..3fbdcec 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,12 +1,13 @@
+// CHANGED 2004-09-31 Lutz Rogowski
// CHANGED 2004-08-06 Lutz Rogowski
#include "settingsdialog.h"
#include "opiemail.h"
#include "editaccounts.h"
#include "composemail.h"
#include "mailistviewitem.h"
#include "viewmail.h"
#include "selectstore.h"
#include "selectsmtp.h"
#include <qmessagebox.h>
@@ -269,24 +270,25 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
{
if (mailtype==MAILLIB::A_NNTP) {
m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
} else {
if (folderView->currentisDraft()) {
m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
}
m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
m->insertSeparator();
+ m->insertItem(tr("Copy/Move all selected mail"),this,SLOT(slotMoveCopyAllMail()));
m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
m->insertItem(tr("Clear selection"),this,SLOT(clearSelection()));
}
m->setFocus();
m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
delete m;
}
}
void OpieMail::slotShowFolders( bool show )
{
if ( show && folderView->isHidden() )
@@ -343,22 +345,64 @@ void OpieMail::slotMoveCopyMail()
return;
}
if (sels.newFolder() && !targetMail->createMbox(targetFolder))
{
QMessageBox::critical(0,tr("Error creating new Folder"),
tr("<center>Error while creating<br>new folder - breaking.</center>"));
return;
}
mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
folderView->refreshCurrent();
}
+void OpieMail::slotMoveCopyAllMail()
+{
+
+ if (!mailView->currentItem()) return;
+ QValueList<RecMailP> t;
+ 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 )
+ {
+ MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
+ while ( item ) {
+ if ( item->isSelected() ) {
+ t.append( item->data() );
+ }
+ item = (MailListViewItem*)item->nextSibling();
+ }
+ }
+ else
+ return;
+ if ( t.count() == 0 )
+ return;
+ RecMailP mail = t.first();
+ AbstractMail*targetMail = 0;
+ QString targetFolder = "";
+ Selectstore sels;
+ folderView->setupFolderselect(&sels);
+ if (!sels.exec()) return;
+ targetMail = sels.currentMail();
+ targetFolder = sels.currentFolder();
+ if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
+ targetFolder.isEmpty())
+ {
+ return;
+ }
+ if (sels.newFolder() && !targetMail->createMbox(targetFolder))
+ {
+ QMessageBox::critical(0,tr("Error creating new Folder"),
+ tr("<center>Error while creating<br>new folder - breaking.</center>"));
+ return;
+ }
+ mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
+ folderView->refreshCurrent();
+}
+
void OpieMail::reEditMail()
{
if (!mailView->currentItem()) return;
ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
compose.slotAdjustColumns();
compose.showMaximized();
compose.exec();
}
diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h
index 143b0c4..934f232 100644
--- a/kmicromail/opiemail.h
+++ b/kmicromail/opiemail.h
@@ -1,12 +1,13 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#ifndef OPIEMAIL_H
#define OPIEMAIL_H
#include "mainwindow.h"
#include <libmailwrapper/settings.h>
#include <opie2/osmartpointer.h>
#include <libmailwrapper/mailtypes.h>
class OpieMail : public MainWindow
{
Q_OBJECT
@@ -26,21 +27,22 @@ protected slots:
virtual void slotSendQueued();
virtual void slotSearchMails();
virtual void slotEditSettings();
virtual void slotEditAccounts();
virtual void displayMail();
virtual void slotDeleteMail();
virtual void slotDeleteAllMail();
virtual void mailHold(int, QListViewItem *,const QPoint&,int);
virtual void slotShowFolders( bool show );
virtual void refreshMailView(const QValueList<RecMailP>&);
virtual void mailLeftClicked( QListViewItem * );
virtual void slotMoveCopyMail();
+ virtual void slotMoveCopyAllMail();
virtual void reEditMail();
void clearSelection();
private:
Settings *settings;
};
#endif
diff --git a/kmicromail/selectstoreui.ui b/kmicromail/selectstoreui.ui
index 5f0e507..dd3fc92 100644
--- a/kmicromail/selectstoreui.ui
+++ b/kmicromail/selectstoreui.ui
@@ -2,66 +2,66 @@
<class>selectstoreui</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>selectstoreui</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>182</width>
- <height>273</height>
+ <width>275</width>
+ <height>304</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Select target box</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
- <vbox>
+ <grid>
<property stdset="1">
<name>margin</name>
- <number>1</number>
+ <number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
- <number>1</number>
+ <number>6</number>
</property>
- <widget>
+ <widget row="0" column="0" rowspan="1" colspan="2" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>headlabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&lt;b&gt;Store mail(s) to&lt;/b&gt;</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>AlignCenter</set>
</property>
<property>
<name>hAlign</name>
</property>
</widget>
- <widget>
+ <widget row="1" column="0" rowspan="1" colspan="2" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout2</cstring>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
@@ -131,122 +131,160 @@
<string>Account:</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>AlignVCenter|AlignRight</set>
</property>
<property>
<name>hAlign</name>
</property>
</widget>
</grid>
</widget>
- <widget>
+ <widget row="2" column="0" rowspan="1" colspan="2" >
<class>Line</class>
<property stdset="1">
<name>name</name>
<cstring>Line1</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
</widget>
- <widget>
+ <widget row="3" column="0" rowspan="1" colspan="2" >
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>newFoldersel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Create new folder</string>
</property>
</widget>
- <widget>
+ <widget row="4" column="0" rowspan="1" colspan="2" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>newFolderedit</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
</widget>
- <widget>
+ <widget row="5" column="0" rowspan="1" colspan="2" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>newFolderLabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Prefix will prepend, no need to enter it!</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>WordBreak|AlignCenter</set>
</property>
<property>
<name>hAlign</name>
</property>
<property>
<name>wordwrap</name>
</property>
</widget>
- <widget>
+ <widget row="6" column="0" rowspan="1" colspan="2" >
<class>Line</class>
<property stdset="1">
<name>name</name>
<cstring>Line2</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
</widget>
- <widget>
- <class>QCheckBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>selMove</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Move mail(s)</string>
- </property>
- </widget>
- <spacer>
+ <spacer row="9" column="0" >
<property>
<name>name</name>
<cstring>Spacer2</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
- </vbox>
+ <widget row="8" column="0" rowspan="1" colspan="2" >
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>selMove</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Move mail(s)</string>
+ </property>
+ </widget>
+ <widget row="7" column="0" >
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>useSize</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>apply only to mails smaller</string>
+ </property>
+ </widget>
+ <widget row="7" column="1" >
+ <class>QSpinBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>sizeSpinBox</cstring>
+ </property>
+ <property stdset="1">
+ <name>suffix</name>
+ <string> kB</string>
+ </property>
+ <property stdset="1">
+ <name>maxValue</name>
+ <number>8192</number>
+ </property>
+ <property stdset="1">
+ <name>minValue</name>
+ <number>1</number>
+ </property>
+ <property stdset="1">
+ <name>lineStep</name>
+ <number>1</number>
+ </property>
+ <property stdset="1">
+ <name>value</name>
+ <number>5</number>
+ </property>
+ </widget>
+ </grid>
</widget>
<connections>
<connection>
<sender>selMove</sender>
<signal>clicked()</signal>
<receiver>selectstoreui</receiver>
<slot>slotMoveMail()</slot>
</connection>
<connection>
<sender>newFoldersel</sender>
<signal>clicked()</signal>
<receiver>selectstoreui</receiver>