-rw-r--r-- | noncore/net/mail/accountview.cpp | 31 | ||||
-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 28 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 86 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 60 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 21 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 47 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.h | 7 | ||||
-rw-r--r-- | noncore/net/mail/pop3configui.ui | 68 |
10 files changed, 238 insertions, 125 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 @@ -63,35 +63,30 @@ void AccountView::populate( QList<Account> list ) 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; + 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; + 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; + 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; + odebug << "AccountView refresh..." << oendl; if ( item ) { m_currentItem = item; @@ -164,8 +159,8 @@ void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrappe tr("<center>Error while creating<br>new folder - breaking.</center>")); return; } - odebug << "Targetfolder: " << targetFolder.latin1() << "" << oendl; - odebug << "Fromfolder: " << fromFolder->getName().latin1() << "" << oendl; + odebug << "Targetfolder: " << targetFolder.latin1() << "" << oendl; + odebug << "Fromfolder: " << fromFolder->getName().latin1() << "" << oendl; fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); refreshCurrent(); } 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 @@ -43,7 +43,7 @@ AccountListItem::AccountListItem( QListView *parent, Account *a) EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) : EditAccountsUI( parent, name, modal, flags ) { - odebug << "New Account Configuration Widget" << oendl; + odebug << "New Account Configuration Widget" << oendl; settings = s; mailList->addColumn( tr( "Account" ) ); @@ -83,7 +83,7 @@ void EditAccounts::slotFillLists() void EditAccounts::slotNewMail() { - odebug << "New Mail Account" << oendl; + odebug << "New Mail Account" << oendl; QString *selection = new QString(); SelectMailType selType( selection, this, 0, true ); selType.show(); @@ -97,7 +97,7 @@ void EditAccounts::slotNewAccount( const QString &type ) { if ( type.compare( "IMAP" ) == 0 ) { - odebug << "-> config IMAP" << oendl; + odebug << "-> config IMAP" << oendl; IMAPaccount *account = new IMAPaccount(); IMAPconfig imap( account, this, 0, true ); if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) @@ -113,7 +113,7 @@ void EditAccounts::slotNewAccount( const QString &type ) } else if ( type.compare( "POP3" ) == 0 ) { - odebug << "-> config POP3" << oendl; + odebug << "-> config POP3" << oendl; POP3account *account = new POP3account(); POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) @@ -129,7 +129,7 @@ void EditAccounts::slotNewAccount( const QString &type ) } else if ( type.compare( "SMTP" ) == 0 ) { - odebug << "-> config SMTP" << oendl; + odebug << "-> config SMTP" << oendl; SMTPaccount *account = new SMTPaccount(); SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) @@ -146,7 +146,7 @@ void EditAccounts::slotNewAccount( const QString &type ) } else if ( type.compare( "NNTP" ) == 0 ) { - odebug << "-> config NNTP" << oendl; + odebug << "-> config NNTP" << oendl; NNTPaccount *account = new NNTPaccount(); NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) @@ -215,7 +215,7 @@ void EditAccounts::slotDeleteAccount( Account *account ) void EditAccounts::slotEditMail() { - odebug << "Edit Mail Account" << oendl; + odebug << "Edit Mail Account" << oendl; if ( !mailList->currentItem() ) { QMessageBox::information( this, tr( "Error" ), @@ -244,13 +244,13 @@ void EditAccounts::slotDeleteMail() void EditAccounts::slotNewNews() { - odebug << "New News Account" << oendl; + odebug << "New News Account" << oendl; slotNewAccount( "NNTP" ); } void EditAccounts::slotEditNews() { - odebug << "Edit News Account" << oendl; + odebug << "Edit News Account" << oendl; if ( !newsList->currentItem() ) { QMessageBox::information( this, tr( "Error" ), @@ -265,7 +265,7 @@ void EditAccounts::slotEditNews() void EditAccounts::slotDeleteNews() { - odebug << "Delete News Account" << oendl; + odebug << "Delete News Account" << oendl; if ( !newsList->currentItem() ) { QMessageBox::information( this, tr( "Error" ), @@ -422,6 +422,8 @@ void POP3config::fillValues() 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() @@ -432,6 +434,8 @@ void POP3config::accept() data->setConnectionType( ComboBox1->currentItem() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); + data->setMaxSize(m_MailLimitBox->value()); + data->setCheckMaxSize(m_CheckSize->isChecked()); QDialog::accept(); } @@ -523,7 +527,7 @@ void NNTPconfig::slotGetNG() { data->save(); NNTPwrapper* tmp = new NNTPwrapper( data ); QStringList list = tmp->listAllNewsgroups(); - + ListViewGroups->clear(); for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { @@ -581,7 +585,7 @@ void NNTPconfig::save() for ( ; list_it.current(); ++list_it ) { if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { - odebug << list_it.current()->text(0) << oendl; + odebug << list_it.current()->text(0) << oendl; groupList.append( list_it.current()->text(0) ); } 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 @@ -31,7 +31,7 @@ int IMAPwrapper::selectMbox(const QString&mbox) } int err = mailimap_select( m_imap, (char*)mbox.latin1()); if ( err != MAILIMAP_NO_ERROR ) { - odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; + odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; m_Lastmbox = ""; return err; } @@ -42,7 +42,7 @@ int IMAPwrapper::selectMbox(const QString&mbox) void IMAPwrapper::imap_progress( size_t current, size_t maximum ) { qApp->processEvents(); - odebug << "IMAP: " << current << " of " << maximum << "" << oendl; + odebug << "IMAP: " << current << " of " << maximum << "" << oendl; } bool IMAPwrapper::start_tls(bool force_tls) @@ -54,7 +54,7 @@ bool IMAPwrapper::start_tls(bool force_tls) err = mailimap_capability(m_imap,&cap_data); if (err != MAILIMAP_NO_ERROR) { Global::statusMessage("error getting capabilities!"); - odebug << "error getting capabilities!" << oendl; + odebug << "error getting capabilities!" << oendl; return false; } clistiter * cur; @@ -75,7 +75,7 @@ bool IMAPwrapper::start_tls(bool force_tls) err = mailimap_starttls(m_imap); if (err != MAILIMAP_NO_ERROR && force_tls) { Global::statusMessage(tr("Server has no TLS support!")); - odebug << "Server has no TLS support!" << oendl; + odebug << "Server has no TLS support!" << oendl; try_tls = false; } else { mailstream_low * low; @@ -126,7 +126,7 @@ void IMAPwrapper::login() pass = login.getPassword().latin1(); } else { // cancel - odebug << "IMAP: Login canceled" << oendl; + odebug << "IMAP: Login canceled" << oendl; return; } } else { @@ -149,7 +149,7 @@ void IMAPwrapper::login() } if ( ssl ) { - odebug << "using ssl" << oendl; + odebug << "using ssl" << oendl; err = mailimap_ssl_connect( m_imap, (char*)server, port ); } else { err = mailimap_socket_connect( m_imap, (char*)server, port ); @@ -177,7 +177,7 @@ void IMAPwrapper::login() bool ok = true; if (force_tls && !try_tls) { Global::statusMessage(tr("Server has no TLS support!")); - odebug << "Server has no TLS support!" << oendl; + odebug << "Server has no TLS support!" << oendl; ok = false; } @@ -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 ); @@ -318,7 +322,7 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); } } else { - odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl; + odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl; } mailimap_list_result_free( result ); @@ -328,7 +332,7 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() mask = "*" ; path = account->getPrefix().latin1(); if (!path) path = ""; - odebug << path << oendl; + odebug << path << oendl; err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); if ( err == MAILIMAP_NO_ERROR ) { current = result->first; @@ -355,7 +359,7 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); } } else { - odebug << "error fetching folders " << m_imap->imap_response << "" << oendl; + odebug << "error fetching folders " << m_imap->imap_response << "" << oendl; } if (result) mailimap_list_result_free( result ); return folders; @@ -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; + 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; } @@ -525,7 +535,7 @@ RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) body_desc = item->att_data.att_static->att_data.att_body; traverseBody(mail,body_desc,body,0,path); } else { - odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; + odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; } if (result) mailimap_fetch_list_free(result); return body; @@ -637,7 +647,7 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int } } } else { - odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; + odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; } if (result) mailimap_fetch_list_free(result); return res; @@ -664,7 +674,7 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t id+=(j>0?" ":""); id+=QString("%1").arg(countlist[j]); } - odebug << "ID = " << id.latin1() << "" << oendl; + odebug << "ID = " << id.latin1() << "" << oendl; currentPart->setIdentifier(id); fillSinglePart(currentPart,part1); /* important: Check for is NULL 'cause a body can be empty! @@ -705,7 +715,7 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t id+=(j>0?" ":""); id+=QString("%1").arg(countlist[j]); } - odebug << "ID(mpart) = " << id.latin1() << "" << oendl; + odebug << "ID(mpart) = " << id.latin1() << "" << oendl; } traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); if (current_body->bd_type==MAILIMAP_BODY_MPART) { @@ -749,7 +759,7 @@ void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_tex } QString sub; sub = which->bd_media_text; - odebug << "Type= text/" << which->bd_media_text << "" << oendl; + odebug << "Type= text/" << which->bd_media_text << "" << oendl; target_part->setSubtype(sub.lower()); target_part->setLines(which->bd_lines); fillBodyFields(target_part,which->bd_fields); @@ -761,7 +771,7 @@ void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg* return; } target_part->setSubtype("rfc822"); - odebug << "Message part" << oendl; + odebug << "Message part" << oendl; /* we set this type to text/plain */ target_part->setLines(which->bd_lines); fillBodyFields(target_part,which->bd_fields); @@ -820,7 +830,7 @@ void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_ba } else { sub = ""; } - odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; + odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; target_part->setType(type.lower()); target_part->setSubtype(sub.lower()); fillBodyFields(target_part,which->bd_fields); @@ -896,16 +906,16 @@ void IMAPwrapper::deleteMail(const RecMailP&mail) mailimap_store_att_flags_free(store_flags); if (err != MAILIMAP_NO_ERROR) { - odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; + odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; return; } - odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; + 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; + odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; } - odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; + odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; } void IMAPwrapper::answeredMail(const RecMailP&mail) @@ -931,7 +941,7 @@ void IMAPwrapper::answeredMail(const RecMailP&mail) mailimap_store_att_flags_free(store_flags); if (err != MAILIMAP_NO_ERROR) { - odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; + odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; return; } } @@ -999,14 +1009,14 @@ int IMAPwrapper::deleteAllMail(const FolderP&folder) Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); return 0; } - odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; + 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)); return 0; } - odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; + odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; return 1; } @@ -1031,7 +1041,7 @@ int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,cons return 0; } } - odebug << "Creating " << pre.latin1() << "" << oendl; + odebug << "Creating " << pre.latin1() << "" << oendl; int res = mailimap_create(m_imap,pre.latin1()); if (res != MAILIMAP_NO_ERROR) { Global::statusMessage(tr("%1").arg(m_imap->imap_response)); @@ -1090,7 +1100,7 @@ void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) } } } else { - odebug << "Error retrieving status" << oendl; + odebug << "Error retrieving status" << oendl; } if (status) mailimap_mailbox_data_status_free(status); if (att_list) mailimap_status_att_list_free(att_list); @@ -1114,7 +1124,7 @@ MAILLIB::ATYPE IMAPwrapper::getType()const const QString&IMAPwrapper::getName()const { - odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; + odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; return account->getAccountName(); } @@ -1130,7 +1140,7 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, { if (targetWrapper != this) { AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); - odebug << "Using generic" << oendl; + odebug << "Using generic" << oendl; return; } mailimap_set *set = 0; @@ -1149,7 +1159,7 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, if ( err != MAILIMAP_NO_ERROR ) { QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); Global::statusMessage(error_msg); - odebug << error_msg << oendl; + odebug << error_msg << oendl; return; } if (moveit) { @@ -1160,7 +1170,7 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) { if (targetWrapper != this) { - odebug << "Using generic" << oendl; + odebug << "Using generic" << oendl; AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); return; } @@ -1179,7 +1189,7 @@ void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,Abstra if ( err != MAILIMAP_NO_ERROR ) { QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); Global::statusMessage(error_msg); - odebug << error_msg << oendl; + odebug << error_msg << oendl; return; } if (moveit) { 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 @@ -17,7 +17,7 @@ MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) if (MHPath[MHPath.length()-1]=='/') { MHPath=MHPath.left(MHPath.length()-1); } - odebug << MHPath << oendl; + odebug << MHPath << oendl; QDir dir(MHPath); if (!dir.exists()) { dir.mkdir(MHPath); @@ -34,7 +34,7 @@ void MHwrapper::init_storage() m_storage = mailstorage_new(NULL); r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); if (r != MAIL_NO_ERROR) { - odebug << "error initializing storage" << oendl; + odebug << "error initializing storage" << oendl; mailstorage_free(m_storage); m_storage = 0; return; @@ -42,7 +42,7 @@ void MHwrapper::init_storage() } r = mailstorage_connect(m_storage); if (r!=MAIL_NO_ERROR) { - odebug << "error connecting storage" << oendl; + odebug << "error connecting storage" << oendl; mailstorage_free(m_storage); m_storage = 0; } @@ -71,7 +71,7 @@ void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSm QString f = buildPath(mailbox); int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); if (r!=MAIL_NO_ERROR) { - odebug << "listMessages: error selecting folder!" << oendl; + odebug << "listMessages: error selecting folder!" << oendl; return; } parseList(target,m_storage->sto_session,f); @@ -91,7 +91,7 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() clistcell*current=0; int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); if (r != MAIL_NO_ERROR || !flist) { - odebug << "error getting folder list" << oendl; + odebug << "error getting folder list" << oendl; return folders; } for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { @@ -111,12 +111,12 @@ void MHwrapper::deleteMail(const RecMailP&mail) } int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); if (r!=MAIL_NO_ERROR) { - odebug << "error selecting folder!" << oendl; + odebug << "error selecting folder!" << oendl; return; } r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); if (r != MAIL_NO_ERROR) { - odebug << "error deleting mail" << oendl; + odebug << "error deleting mail" << oendl; } } @@ -141,7 +141,7 @@ RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) } r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); if (r != MAIL_NO_ERROR) { - odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; + odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; return body; } body = parseMail(msg); @@ -151,7 +151,7 @@ RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) void MHwrapper::mbox_progress( size_t current, size_t maximum ) { - odebug << "MH " << current << " von " << maximum << "" << oendl; + odebug << "MH " << current << " von " << maximum << "" << oendl; } QString MHwrapper::buildPath(const QString&p) @@ -184,13 +184,13 @@ int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QStri f+="/"; f+=folder; } - odebug << f << oendl; + odebug << f << oendl; int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); if (r != MAIL_NO_ERROR) { - odebug << "error creating folder " << r << "" << oendl; + odebug << "error creating folder " << r << "" << oendl; return 0; } - odebug << "Folder created" << oendl; + odebug << "Folder created" << oendl; return 1; } @@ -203,12 +203,12 @@ void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) QString f = buildPath(Folder); int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); if (r!=MAIL_NO_ERROR) { - odebug << "error selecting folder!" << oendl; + odebug << "error selecting folder!" << oendl; return; } r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); if (r!=MAIL_NO_ERROR) { - odebug << "error storing mail" << oendl; + odebug << "error storing mail" << oendl; } return; } @@ -225,7 +225,7 @@ encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) size_t size; int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); if (r!=MAIL_NO_ERROR) { - odebug << "error selecting folder!" << oendl; + odebug << "error selecting folder!" << oendl; return result; } r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); @@ -249,14 +249,14 @@ void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> & QString f = buildPath(mailbox); int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); if (r!=MAIL_NO_ERROR) { - odebug << "deleteMails: error selecting folder!" << oendl; + odebug << "deleteMails: error selecting folder!" << oendl; return; } QValueList<RecMailP>::ConstIterator it; for (it=target.begin(); it!=target.end();++it) { r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); if (r != MAIL_NO_ERROR) { - odebug << "error deleting mail" << oendl; + odebug << "error deleting mail" << oendl; break; } } @@ -272,13 +272,13 @@ int MHwrapper::deleteAllMail(const FolderP&tfolder) if (!tfolder) return 0; int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); if (r!=MAIL_NO_ERROR) { - odebug << "error selecting folder!" << oendl; + odebug << "error selecting folder!" << oendl; return 0; } mailmessage_list*l=0; r = mailsession_get_messages_list(m_storage->sto_session,&l); if (r != MAIL_NO_ERROR) { - odebug << "Error message list" << oendl; + odebug << "Error message list" << oendl; res = 0; } unsigned j = 0; @@ -309,7 +309,7 @@ int MHwrapper::deleteMbox(const FolderP&tfolder) int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); if (r != MAIL_NO_ERROR) { - odebug << "error deleting mail box" << oendl; + odebug << "error deleting mail box" << oendl; return 0; } QString cmd = "rm -rf "+tfolder->getName(); @@ -327,10 +327,10 @@ int MHwrapper::deleteMbox(const FolderP&tfolder) *process << command; removeMboxfailed = false; if(!process->start(OProcess::Block, OProcess::All) ) { - odebug << "could not start process" << oendl; + odebug << "could not start process" << oendl; return 0; } - odebug << "mail box deleted" << oendl; + odebug << "mail box deleted" << oendl; return 1; } @@ -379,15 +379,15 @@ void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,Abstract return; } if (targetWrapper != this) { - odebug << "Using generic" << oendl; + odebug << "Using generic" << oendl; Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); return; } - odebug << "Using internal routines for move/copy" << oendl; + odebug << "Using internal routines for move/copy" << oendl; QString tf = buildPath(targetFolder); int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); if (r != MAIL_NO_ERROR) { - odebug << "Error selecting source mailbox" << oendl; + odebug << "Error selecting source mailbox" << oendl; return; } if (moveit) { @@ -396,7 +396,7 @@ void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,Abstract r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); } if (r != MAIL_NO_ERROR) { - odebug << "Error copy/moving mail internal (" << r << ")" << oendl; + odebug << "Error copy/moving mail internal (" << r << ")" << oendl; } } @@ -408,21 +408,21 @@ void MHwrapper::mvcpAllMails(const FolderP&fromFolder, return; } if (targetWrapper != this) { - odebug << "Using generic" << oendl; + odebug << "Using generic" << oendl; Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); return; } if (!fromFolder) return; int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); if (r!=MAIL_NO_ERROR) { - odebug << "error selecting source folder!" << oendl; + odebug << "error selecting source folder!" << oendl; return; } QString tf = buildPath(targetFolder); mailmessage_list*l=0; r = mailsession_get_messages_list(m_storage->sto_session,&l); if (r != MAIL_NO_ERROR) { - odebug << "Error message list" << oendl; + odebug << "Error message list" << oendl; } unsigned j = 0; for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { @@ -435,7 +435,7 @@ void MHwrapper::mvcpAllMails(const FolderP&fromFolder, r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); } if (r != MAIL_NO_ERROR) { - odebug << "Error copy/moving mail internal (" << r << ")" << oendl; + odebug << "Error copy/moving mail internal (" << r << ")" << oendl; break; } } 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() { @@ -29,7 +32,7 @@ POP3wrapper::~POP3wrapper() { } void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { - odebug << "POP3: " << current << " of " << maximum << "" << oendl; + odebug << "POP3: " << current << " of " << maximum << "" << oendl; } RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { @@ -45,9 +48,13 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { } mailmessage * mailmsg; - if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { - odebug << "Message to large: " << mail->Msgsize() << "" << oendl; - return body; + 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); @@ -131,7 +138,7 @@ void POP3wrapper::login() pass = login.getPassword().latin1(); } else { // cancel - odebug << "POP3: Login canceled" << oendl; + odebug << "POP3: Login canceled" << oendl; return; } } else { @@ -163,7 +170,7 @@ void POP3wrapper::login() err = mailstorage_connect(m_pop3); if (err != MAIL_NO_ERROR) { - odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; + odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; Global::statusMessage(tr("Error initializing folder")); mailstorage_free(m_pop3); m_pop3 = 0; @@ -237,7 +244,7 @@ void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, &target_stat.message_recent,&target_stat.message_unseen); if (r != MAIL_NO_ERROR) { - odebug << "error getting folter status." << oendl; + odebug << "error getting folter status." << oendl; } } 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() { @@ -27,7 +26,7 @@ void Settings::checkDirectory() { if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { system( "mkdir -p $HOME/Applications/opiemail" ); - odebug << "$HOME/Applications/opiemail created" << oendl; + odebug << "$HOME/Applications/opiemail created" << oendl; } } @@ -55,28 +54,28 @@ void Settings::updateAccounts() QStringList imap = dir.entryList( "imap-*" ); for ( it = imap.begin(); it != imap.end(); it++ ) { - odebug << "Added IMAP account" << oendl; + odebug << "Added IMAP account" << oendl; IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); accounts.append( account ); } QStringList pop3 = dir.entryList( "pop3-*" ); for ( it = pop3.begin(); it != pop3.end(); it++ ) { - odebug << "Added POP account" << oendl; + odebug << "Added POP account" << oendl; POP3account *account = new POP3account( (*it).replace(0, 5, "") ); accounts.append( account ); } QStringList smtp = dir.entryList( "smtp-*" ); for ( it = smtp.begin(); it != smtp.end(); it++ ) { - odebug << "Added SMTP account" << oendl; + odebug << "Added SMTP account" << oendl; SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); accounts.append( account ); } QStringList nntp = dir.entryList( "nntp-*" ); for ( it = nntp.begin(); it != nntp.end(); it++ ) { - odebug << "Added NNTP account" << oendl; + odebug << "Added NNTP account" << oendl; NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); accounts.append( account ); } @@ -180,7 +179,7 @@ void IMAPaccount::read() void IMAPaccount::save() { - odebug << "saving " + getFileName() << oendl; + odebug << "saving " + getFileName() << oendl; Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); @@ -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,12 +256,14 @@ 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; } void POP3account::save() { - odebug << "saving " + getFileName() << oendl; + odebug << "saving " + getFileName() << oendl; Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); @@ -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() { @@ -340,7 +367,7 @@ void SMTPaccount::read() void SMTPaccount::save() { - odebug << "saving " + getFileName() << oendl; + odebug << "saving " + getFileName() << oendl; Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); @@ -417,7 +444,7 @@ void NNTPaccount::read() void NNTPaccount::save() { - odebug << "saving " + getFileName() << oendl; + odebug << "saving " + getFileName() << oendl; Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); 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 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 @@ -11,7 +11,7 @@ <rect> <x>0</x> <y>0</y> - <width>314</width> + <width>302</width> <height>410</height> </rect> </property> @@ -28,11 +28,11 @@ <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> @@ -319,6 +319,64 @@ </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> @@ -346,7 +404,11 @@ <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> |