-rw-r--r-- | noncore/net/mail/accountview.cpp | 15 | ||||
-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 20 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 0 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 29 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.h | 7 | ||||
-rw-r--r-- | noncore/net/mail/pop3configui.ui | 68 |
10 files changed, 140 insertions, 27 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 662e555..0fe8475 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -54,45 +54,40 @@ void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) } void AccountView::populate( QList<Account> list ) { clear(); imapAccounts.clear(); mhAccounts.clear(); mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); Account *it; - for ( it = list.first(); it; it = list.next() ) - { - if ( it->getType() == MAILLIB::A_IMAP ) - { + for ( it = list.first(); it; it = list.next() ) { + if ( it->getType() == MAILLIB::A_IMAP ) { IMAPaccount *imap = static_cast<IMAPaccount *>(it); odebug << "added IMAP " + imap->getAccountName() << oendl; imapAccounts.append(new IMAPviewItem( imap, this )); - } - else if ( it->getType() == MAILLIB::A_POP3 ) - { + } else if ( it->getType() == MAILLIB::A_POP3 ) { POP3account *pop3 = static_cast<POP3account *>(it); odebug << "added POP3 " + pop3->getAccountName() << oendl; /* must not be hold 'cause it isn't required */ (void) new POP3viewItem( pop3, this ); - } - else if ( it->getType() == MAILLIB::A_NNTP ) - { + } else if ( it->getType() == MAILLIB::A_NNTP ) { NNTPaccount *nntp = static_cast<NNTPaccount *>(it); odebug << "added NNTP " + nntp->getAccountName() << oendl; /* must not be hold 'cause it isn't required */ (void) new NNTPviewItem( nntp, this ); + } else if ( it->getType() == MAILLIB::A_MH ) { } } } void AccountView::refresh(QListViewItem *item) { odebug << "AccountView refresh..." << oendl; if ( item ) { m_currentItem = item; QValueList<RecMailP> headerlist; diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index b0ce57d..b7c137d 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp @@ -413,34 +413,38 @@ void POP3config::slotConnectionToggle( int index ) portLine->setText( POP3_PORT ); } } void POP3config::fillValues() { accountLine->setText( data->getAccountName() ); serverLine->setText( data->getServer() ); portLine->setText( data->getPort() ); ComboBox1->setCurrentItem( data->ConnectionType() ); userLine->setText( data->getUser() ); passLine->setText( data->getPassword() ); + m_CheckSize->setChecked(data->getCheckMaxSize()); + m_MailLimitBox->setValue(data->getMaxSize()); } void POP3config::accept() { data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); data->setConnectionType( ComboBox1->currentItem() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); + data->setMaxSize(m_MailLimitBox->value()); + data->setCheckMaxSize(m_CheckSize->isChecked()); QDialog::accept(); } /** * SMTPconfig */ SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) : SMTPconfigUI( parent, name, modal, flags ) { data = account; 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 @@ -1,17 +1,19 @@ #include "genericwrapper.h" #include <libetpan/libetpan.h> #include "mailtypes.h" #include <opie2/odebug.h> +#include <qpe/timestring.h> +#include <qdatetime.h> using namespace Opie::Core; Genericwrapper::Genericwrapper() : AbstractMail() { bodyCache.clear(); m_storage = 0; m_folder = 0; } Genericwrapper::~Genericwrapper() { @@ -234,30 +236,29 @@ RecBodyP Genericwrapper::parseMail( mailmessage * msg ) /* is bound to msg and will be freed there */ mailmime * mime=0; RecBodyP body = new RecBody(); memset(&fields, 0, sizeof(struct mailmime_single_fields)); err = mailmessage_get_bodystructure(msg,&mime); QValueList<int>recList; traverseBody(body,msg,mime,recList); return body; } 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 ) { QString result( "" ); bool first = true; if (list == 0) return result; for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { mailimf_address *addr = (mailimf_address *) current->data; if ( !first ) { 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 @@ -228,30 +228,34 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma } int last = m_imap->imap_selection_info->sel_exists; if (last == 0) { Global::statusMessage(tr("Mailbox has no mails")); return; } else { } /* 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 ); 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; @@ -366,28 +370,28 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) RecMail * m = 0; mailimap_msg_att_item *item=0; clistcell *current,*c,*cf; mailimap_msg_att_dynamic*flist; mailimap_flag_fetch*cflag; int size; QBitArray mFlags(7); QStringList addresslist; 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; if (!flist->att_list) { continue; } cf = flist->att_list->first; for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { cflag = (mailimap_flag_fetch*)cf->data; if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { switch (cflag->fl_flag->fl_type) { case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ @@ -456,41 +460,47 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) while (h.length()>0 && h[h.length()-1]=='>') { h.remove(h.length()-1,1); } if (h.length()>0) { m->setInreply(QStringList(h)); } } if (head->env_message_id) { m->setMsgid(QString(head->env_message_id)); } } 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 */ if (mFlags.testBit(FLAG_DELETED) && m) { delete m; m = 0; } if (m) { m->setFlags(mFlags); - m->setMsgsize(size); } return m; } RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) { RecBodyP body = new RecBody(); const char *mb; int err = MAILIMAP_NO_ERROR; clist *result = 0; clistcell *current; mailimap_fetch_att *fetchAtt = 0; 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 @@ -1,32 +1,35 @@ #include <stdlib.h> #include "pop3wrapper.h" #include "mailtypes.h" #include "logindialog.h" #include <libetpan/libetpan.h> #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 using namespace Opie::Core; POP3wrapper::POP3wrapper( POP3account *a ) : Genericwrapper() { account = a; m_pop3 = NULL; msgTempName = a->getFileName()+"_msg_cache"; last_msg_id = 0; + m_maxsize = account->getMaxSize(); + m_checksize = account->getCheckMaxSize(); } POP3wrapper::~POP3wrapper() { logout(); QFile msg_cache(msgTempName); if (msg_cache.exists()) { msg_cache.remove(); } } void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { odebug << "POP3: " << current << " of " << maximum << "" << oendl; @@ -36,26 +39,30 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { int err = MAILPOP3_NO_ERROR; char *message = 0; size_t length = 0; RecBodyP body = new RecBody(); login(); if ( !m_pop3 ) { return body; } 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; } QFile msg_cache(msgTempName); cleanMimeCache(); if (mail->getNumber()!=last_msg_id) { if (msg_cache.exists()) { msg_cache.remove(); } msg_cache.open(IO_ReadWrite|IO_Truncate); 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 @@ -28,15 +28,17 @@ public: 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; 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 @@ -7,25 +7,24 @@ #include "settings.h" //#include "defines.h" #define IMAP_PORT "143" #define IMAP_SSL_PORT "993" #define SMTP_PORT "25" #define SMTP_SSL_PORT "465" #define POP3_PORT "110" #define POP3_SSL_PORT "995" #define NNTP_PORT "119" #define NNTP_SSL_PORT "563" - Settings::Settings() : QObject() { updateAccounts(); } void Settings::checkDirectory() { if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { system( "mkdir -p $HOME/Applications/opiemail" ); odebug << "$HOME/Applications/opiemail created" << oendl; } @@ -204,35 +203,39 @@ QString IMAPaccount::getFileName() return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; } POP3account::POP3account() : Account() { file = POP3account::getUniqueFileName(); accountName = "New POP3 Account"; ssl = false; connectionType = 1; type = MAILLIB::A_POP3; port = POP3_PORT; + m_CheckSize = true; + m_MaxSize = 1024; } POP3account::POP3account( QString filename ) : Account() { file = filename; accountName = "New POP3 Account"; ssl = false; connectionType = 1; type = MAILLIB::A_POP3; port = POP3_PORT; + m_CheckSize = true; + m_MaxSize = 1024; } QString POP3account::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); QStringList imap = dir.entryList( "pop3-*" ); do { unique.setNum( num++ ); @@ -244,52 +247,76 @@ QString POP3account::getUniqueFileName() void POP3account::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "POP3 Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); connectionType = conf->readNumEntry( "ConnectionType" ); 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; } void POP3account::save() { odebug << "saving " + getFileName() << oendl; Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "POP3 Account" ); conf->writeEntry( "Account", accountName ); conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "ConnectionType", connectionType ); 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; } 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() { file = SMTPaccount::getUniqueFileName(); accountName = "New SMTP Account"; ssl = false; connectionType = 1; login = false; useCC = false; useBCC = false; useReply = false; type = MAILLIB::A_SMTP; 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 @@ -80,28 +80,33 @@ private: class POP3account : public Account { public: POP3account(); POP3account( QString filename ); static QString getUniqueFileName(); 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 { public: SMTPaccount(); SMTPaccount( QString filename ); static QString getUniqueFileName(); virtual void read(); diff --git a/noncore/net/mail/pop3configui.ui b/noncore/net/mail/pop3configui.ui index 1014ef4..e560661 100644 --- a/noncore/net/mail/pop3configui.ui +++ b/noncore/net/mail/pop3configui.ui @@ -2,46 +2,46 @@ <class>POP3configUI</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>POP3configUI</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>314</width> + <width>302</width> <height>410</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Configure POP3</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> - <number>3</number> + <number>11</number> </property> <property stdset="1"> <name>spacing</name> - <number>3</number> + <number>6</number> </property> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout12</cstring> </property> <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> @@ -310,24 +310,82 @@ <name>name</name> <cstring>passLine</cstring> </property> <property stdset="1"> <name>echoMode</name> <enum>Password</enum> </property> </widget> </vbox> </widget> </hbox> </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>m_CheckSize</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>ask before downloading large mails</string> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout9</cstring> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>m_MailLimitLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Large mail size (kb):</string> + </property> + </widget> + <widget row="0" column="1" > + <class>QSpinBox</class> + <property stdset="1"> + <name>name</name> + <cstring>m_MailLimitBox</cstring> + </property> + <property stdset="1"> + <name>suffix</name> + <string> kB</string> + </property> + <property stdset="1"> + <name>maxValue</name> + <number>5120</number> + </property> + <property stdset="1"> + <name>minValue</name> + <number>1</number> + </property> + </widget> + </grid> + </widget> <spacer> <property> <name>name</name> <cstring>spacer</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> @@ -337,16 +395,20 @@ <size> <width>20</width> <height>20</height> </size> </property> </spacer> </vbox> </widget> <tabstops> <tabstop>accountLine</tabstop> <tabstop>serverLine</tabstop> <tabstop>portLine</tabstop> + <tabstop>ComboBox1</tabstop> + <tabstop>CommandEdit</tabstop> <tabstop>userLine</tabstop> <tabstop>passLine</tabstop> + <tabstop>m_CheckSize</tabstop> + <tabstop>m_MailLimitBox</tabstop> </tabstops> </UI> |