summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper
Side-by-side diff
Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp13
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp20
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp0
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp9
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/settings.cpp29
-rw-r--r--noncore/net/mail/libmailwrapper/settings.h7
7 files changed, 66 insertions, 14 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index 1caa375..5ec9415 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -3,6 +3,8 @@
#include "mailtypes.h"
#include <opie2/odebug.h>
+#include <qpe/timestring.h>
+#include <qdatetime.h>
using namespace Opie::Core;
Genericwrapper::Genericwrapper()
@@ -243,12 +245,11 @@ RecBodyP Genericwrapper::parseMail( mailmessage * msg )
QString Genericwrapper::parseDateTime( mailimf_date_time *date )
{
- char tmp[23];
-
- snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
- date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
-
- return QString( tmp );
+ QDateTime da(QDate(date->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec));
+ QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" ";
+ timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" ";
+ timestring.sprintf(timestring+" %+05i",date->dt_zone);
+ return timestring;
}
QString Genericwrapper::parseAddressList( mailimf_address_list *list )
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 9b7c0e0..fe75a15 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -237,12 +237,16 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( 1, last );
+
+
+ fetchType = mailimap_fetch_type_new_all();
+/*
fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
-
+*/
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
@@ -375,10 +379,10 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
if (!m_att) {
return m;
}
+ size = 0;
m = new RecMail();
for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
current = c;
- size = 0;
item = (mailimap_msg_att_item*)current->data;
if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
@@ -465,13 +469,20 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
}
} else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
#if 0
- mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
+ mailimap_date_time*date = item->att_data.att_static->att_data.att_internal_date;
+ if (date->dt_sec>60 || date->dt_sec<0) date->dt_sec=0;
+ //QDateTime da(QDate(d->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec));
+ QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" ";
+ timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" ";
+ timestring.sprintf(timestring+" %+05i",date->dt_zone);
+ m->setDate(timestring);
QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl;
odebug << da.toString() << oendl;
#endif
} else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
- size = item->att_data.att_static->att_data.att_rfc822_size;
+ //size = item->att_data.att_static->att_data.att_rfc822_size;
+ m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size);
}
}
/* msg is already deleted */
@@ -481,7 +492,6 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
}
if (m) {
m->setFlags(mFlags);
- m->setMsgsize(size);
}
return m;
}
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
index 403afcf..765a21c 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 3cfd1ee..2d66fc9 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -7,6 +7,7 @@
#include <opie2/odebug.h>
#include <qpe/global.h>
#include <qfile.h>
+#include <qmessagebox.h>
/* we don't fetch messages larger than 5 MB */
#define HARD_MSG_SIZE_LIMIT 5242880
@@ -18,6 +19,8 @@ POP3wrapper::POP3wrapper( POP3account *a )
m_pop3 = NULL;
msgTempName = a->getFileName()+"_msg_cache";
last_msg_id = 0;
+ m_maxsize = account->getMaxSize();
+ m_checksize = account->getCheckMaxSize();
}
POP3wrapper::~POP3wrapper() {
@@ -45,8 +48,12 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) {
}
mailmessage * mailmsg;
- if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) {
+ if (mail->Msgsize()/1024>m_maxsize && m_checksize && mail->getNumber()!=last_msg_id) {
+ QString quest = QString(tr("Download mail?\nIt is %1 kByte but your limit is %2 kByte")).arg(mail->Msgsize()/1024).arg(m_maxsize);
+ int yesno = QMessageBox::warning(0,tr("Download message"),
+ quest,tr("Yes"),tr("No"),QString::null,0,1);
odebug << "Message to large: " << mail->Msgsize() << "" << oendl;
+ if (yesno==1)
return body;
}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index 5101fa5..8c36cf9 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -37,6 +37,8 @@ protected:
void login();
POP3account *account;
mailstorage*m_pop3;
+ int m_maxsize;
+ bool m_checksize;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp
index 3c9b25c..09be91b 100644
--- a/noncore/net/mail/libmailwrapper/settings.cpp
+++ b/noncore/net/mail/libmailwrapper/settings.cpp
@@ -16,7 +16,6 @@
#define NNTP_PORT "119"
#define NNTP_SSL_PORT "563"
-
Settings::Settings()
: QObject()
{
@@ -213,6 +212,8 @@ POP3account::POP3account()
connectionType = 1;
type = MAILLIB::A_POP3;
port = POP3_PORT;
+ m_CheckSize = true;
+ m_MaxSize = 1024;
}
POP3account::POP3account( QString filename )
@@ -224,6 +225,8 @@ POP3account::POP3account( QString filename )
connectionType = 1;
type = MAILLIB::A_POP3;
port = POP3_PORT;
+ m_CheckSize = true;
+ m_MaxSize = 1024;
}
QString POP3account::getUniqueFileName()
@@ -253,6 +256,8 @@ void POP3account::read()
user = conf->readEntry( "User" );
password = conf->readEntryCrypt( "Password" );
offline = conf->readBoolEntry("Offline",false);
+ m_CheckSize = conf->readBoolEntry("Checkmaxsize",true);
+ m_MaxSize = conf->readNumEntry("Maxsize",1024);
delete conf;
}
@@ -271,6 +276,8 @@ void POP3account::save()
conf->writeEntry( "User", user );
conf->writeEntryCrypt( "Password", password );
conf->writeEntry( "Offline",offline);
+ conf->writeEntry("Checkmaxsize",m_CheckSize);
+ conf->writeEntry("Maxsize",m_MaxSize);
conf->write();
delete conf;
}
@@ -281,6 +288,26 @@ QString POP3account::getFileName()
return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file;
}
+bool POP3account::getCheckMaxSize()const
+{
+ return m_CheckSize;
+}
+
+void POP3account::setCheckMaxSize(bool aValue)
+{
+ m_CheckSize = aValue;
+}
+
+int POP3account::getMaxSize()const
+{
+ return m_MaxSize;
+}
+
+void POP3account::setMaxSize(int aValue)
+{
+ m_MaxSize = aValue;
+}
+
SMTPaccount::SMTPaccount()
: Account()
{
diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h
index bf27b97..8683a05 100644
--- a/noncore/net/mail/libmailwrapper/settings.h
+++ b/noncore/net/mail/libmailwrapper/settings.h
@@ -89,10 +89,15 @@ public:
virtual void read();
virtual void save();
virtual QString getFileName();
+ virtual bool getCheckMaxSize()const;
+ virtual void setCheckMaxSize(bool);
+ virtual int getMaxSize()const;
+ virtual void setMaxSize(int);
private:
QString file;
-
+ bool m_CheckSize;
+ int m_MaxSize;
};
class SMTPaccount : public Account