-rw-r--r-- | kmicromail/accountitem.cpp | 22 | ||||
-rw-r--r-- | kmicromail/accountview.cpp | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 67 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.h | 7 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 64 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.h | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 18 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.cpp | 23 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.h | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mboxwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/nntpwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.h | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/smtpwrapper.h | 1 | ||||
-rw-r--r-- | kmicromail/mailistviewitem.cpp | 7 |
17 files changed, 207 insertions, 21 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index 1698b40..7b9b881 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp @@ -93,9 +93,10 @@ QPopupMenu * POP3viewItem::getContextMenu() m->insertItem(QObject::tr("Disconnect",contextName),0); m->insertItem(QObject::tr("Set offline",contextName),1); - m->insertItem(QObject::tr("Download messages",contextName),2); + m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); } else { m->insertItem(QObject::tr("Set online",contextName),1); + m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); } } @@ -138,4 +139,6 @@ void POP3viewItem::contextMenuSelected(int which) break; case 2: // daunlood + if (account->getOffline()) + setOnOffline(); AccountView*bl = accountView(); if (!bl) return; @@ -514,8 +517,12 @@ QPopupMenu * IMAPviewItem::getContextMenu() m->insertItem(QObject::tr("Disconnect",contextName),2); m->insertItem(QObject::tr("Set offline",contextName),3); + m->insertSeparator(); + m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); } else { m->insertItem(QObject::tr("Set online",contextName),3); + m->insertSeparator(); + m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); } } @@ -571,4 +578,17 @@ void IMAPviewItem::contextMenuSelected(int id) refreshFolders(false); break; + case 4: // daunlood + { + if (account->getOffline()) { + contextMenuSelected( 3 ); + } + AccountView*bl = accountView(); + if (!bl) return; + AccountViewItem* in = findSubItem( "inbox" , 0); + if ( ! in ) + return; + bl->downloadMailsInbox(in->getFolder(),getWrapper()); + } + break; default: break; diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp index 85523b1..de8c5bb 100644 --- a/kmicromail/accountview.cpp +++ b/kmicromail/accountview.cpp @@ -142,4 +142,5 @@ void AccountView::setupFolderselect(Selectstore*sels) void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) { +#if 0 AbstractMail*targetMail = 0; QString targetFolder = ""; @@ -163,7 +164,9 @@ void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromW if ( sels.useSize->isChecked()) maxsize = sels.sizeSpinBox->value(); - fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); +#endif + fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); refreshCurrent(); + } diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index f876235..374d606 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp @@ -11,4 +11,5 @@ #include <qprogressbar.h> #include <qapplication.h> +#include <qmessagebox.h> #include <kdecore/kstandarddirs.h> @@ -159,4 +160,70 @@ void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) } } + +void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) +{ + qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); + // get local folder + Account * acc = getAccount(); + if ( !acc ) return; + QString lfName = acc->getLocalFolder(); + if ( lfName.isEmpty() ) + lfName = acc->getAccountName(); + // create local folder + if ( !targetMail->createMbox(lfName)) + { + QMessageBox::critical(0,tr("Error creating new Folder"), + tr("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); + return; + } + QValueList<RecMailP> t; + listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); + if ( t.count() == 0 ) { + Global::statusMessage(tr("There are no new messages")); + return; + } + QValueList<RecMailP> e; + targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); + qDebug("target has mails %d ", e.count()); + QValueList<RecMailP> n; + int iii = 0; + int count = t.count(); + while (iii < count ) { + RecMailP r = (*t.at( iii )); + bool found = false; + int jjj = 0; + int countE = e.count(); + while (jjj < countE ) { + RecMailP re = (*e.at( jjj )); + if ( re->isEqual(r) ) { + found = true; + break; + } + ++jjj; + } + if ( found ) + qDebug("found "); + else + qDebug("NOT found "); + + if ( !found ) { + n.append( r ); + } + ++iii; + } + if ( n.count() == 0 ) { + Global::statusMessage(tr("There are no new messages")); + return; + } + mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); + + +#if 0 + QValueList<RecMailP> t; + listMessages(fromFolder->getName(),t, maxSizeInKb); + mvcpMailList( t,targetFolder,targetWrapper,moveit); +#endif + +} void AbstractMail::mvcpAllMails(const FolderP&fromFolder, const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) diff --git a/kmicromail/libmailwrapper/abstractmail.h b/kmicromail/libmailwrapper/abstractmail.h index cae83f4..2069ca1 100644 --- a/kmicromail/libmailwrapper/abstractmail.h +++ b/kmicromail/libmailwrapper/abstractmail.h @@ -11,4 +11,7 @@ #include "mailtypes.h" + +#include "mailwrapper.h" + class IMAPwrapper; class POP3wrapper; @@ -39,5 +42,5 @@ public: virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; - + void downloadNewMails(const FolderP&fromFolder,AbstractMail*targetWrapper ); virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int sizeInKb = 0); @@ -56,4 +59,6 @@ public: virtual void logout()=0; + virtual Account* getAccount() = 0; + static AbstractMail* getWrapper(IMAPaccount *a); static AbstractMail* getWrapper(POP3account *a); diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index 9614d53..2b04847 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp @@ -4,4 +4,7 @@ #include "mailtypes.h" +#include <kconfig.h> +#include <kglobal.h> +#include <kstandarddirs.h> @@ -25,4 +28,46 @@ Genericwrapper::~Genericwrapper() cleanMimeCache(); } +QString Genericwrapper::parseDateTime( mailimf_date_time *date ) +{ + static bool init = false ; + if ( ! init ) { + KConfig kon ( locateLocal( "config", "korganizerrc" ) ); + kon.setGroup("Locale"); + KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); + QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); + KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); + KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); + kon.setGroup("Time & Date"); + KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), + kon.readNumEntry( "DaylightsavingStart", 90), + kon.readNumEntry( "DaylightsavingEnd",304) ); + KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); + + init = true; + + } + QDateTime dt (QDate(date->dt_year,date->dt_month, date->dt_day ),QTime(date->dt_hour, date->dt_min, date->dt_sec ) ); + int off = KGlobal::locale()->localTimeOffset( dt ); + dt = dt.addSecs( off*60 ); + QString ret = KGlobal::locale()->formatDateTime( dt,true,true); + if ( off < 0 ) + ret += " -"; + else + ret += " +"; + ret += QString::number( off / 60 ); + ret += "h"; +#if 0 + 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 ); + snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", + date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); + + + return QString( tmp ); +#endif + return ret; +} void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) @@ -243,15 +288,4 @@ 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 ); - snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", - date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); - - return QString( tmp ); -} QString Genericwrapper::parseAddressList( mailimf_address_list *list ) @@ -449,6 +483,12 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > & if (single_fields.fld_bcc) mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); - if (single_fields.fld_orig_date) + if (single_fields.fld_orig_date) { mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); + char tmp[23]; + struct mailimf_date_time* date = single_fields.fld_orig_date->dt_date_time; + snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", + date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); + mail->setIsoDate( QString( tmp ) ); + } // crashes when accessing pop3 account? if (single_fields.fld_message_id) { diff --git a/kmicromail/libmailwrapper/genericwrapper.h b/kmicromail/libmailwrapper/genericwrapper.h index 235e116..244212f 100644 --- a/kmicromail/libmailwrapper/genericwrapper.h +++ b/kmicromail/libmailwrapper/genericwrapper.h @@ -43,4 +43,5 @@ public: virtual void logout(){}; virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; + static QString parseDateTime( mailimf_date_time *date ); protected: @@ -50,5 +51,4 @@ protected: 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); diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 6faa524..5441a9b 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp @@ -8,4 +8,5 @@ #include "logindialog.h" #include <qprogressbar.h> +#include "genericwrapper.h" using namespace Opie::Core; @@ -457,6 +458,21 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) if ( head == NULL ) continue; - if ( head->env_date != NULL ) + if ( head->env_date != NULL ) { m->setDate(head->env_date); + struct mailimf_date_time result; + struct mailimf_date_time* date = &result; + struct mailimf_date_time **re = &date; + size_t length = m->getDate().length(); + size_t index = 0; + if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { + m->setDate( Genericwrapper::parseDateTime( date ) ); + char tmp[23]; + snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", + date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); + m->setIsoDate( QString( tmp ) ); + } else { + m->setIsoDate(head->env_date); + } + } if ( head->env_subject != NULL ) m->setSubject(convert_String((const char*)head->env_subject)); diff --git a/kmicromail/libmailwrapper/imapwrapper.h b/kmicromail/libmailwrapper/imapwrapper.h index db8ab5b..5535d8d 100644 --- a/kmicromail/libmailwrapper/imapwrapper.h +++ b/kmicromail/libmailwrapper/imapwrapper.h @@ -53,4 +53,5 @@ public: virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; + virtual Account* getAccount() { return account; }; protected: diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp index d43bdc6..1a4ffd1 100644 --- a/kmicromail/libmailwrapper/mailtypes.cpp +++ b/kmicromail/libmailwrapper/mailtypes.cpp @@ -24,5 +24,28 @@ RecMail::~RecMail() wrapper = 0; } +static bool stringCompareRec( const QString& s1, const QString& s2 ) +{ + if ( s1.isEmpty() && s2.isEmpty() ) + return true; + return s1 == s2; +} + +bool RecMail::isEqual( RecMail* r1 ) +{ + if ( !stringCompareRec( isodate, r1->isodate ) ) { + // qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); + return false; + } + if ( !stringCompareRec( from, r1->from ) ) { + //qDebug("from *%s* *%s* ", from.latin1(), r1->from.latin1()); + return false; + } + if ( !stringCompareRec( subject, r1->subject ) ) { + //qDebug("sub "); + return false; + } + return true; +} void RecMail::copy_old(const RecMail&old) { diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h index c317880..020278d 100644 --- a/kmicromail/libmailwrapper/mailtypes.h +++ b/kmicromail/libmailwrapper/mailtypes.h @@ -36,4 +36,5 @@ public: RecMail(const RecMail&old); virtual ~RecMail(); + bool isEqual( RecMail* r1 ); const unsigned int getNumber()const{return msg_number;} @@ -41,4 +42,6 @@ public: const QString&getDate()const{ return date; } void setDate( const QString&a ) { date = a; } + const QString&getIsoDate()const{ return isodate; } + void setIsoDate( const QString&a ) { isodate = a; } const QString&getFrom()const{ return from; } void setFrom( const QString&a ) { from = a; } @@ -73,5 +76,5 @@ public: protected: - QString subject,date,from,mbox,msg_id,replyto; + QString subject,date,isodate,from,mbox,msg_id,replyto; unsigned int msg_number,msg_size; QBitArray msg_flags; diff --git a/kmicromail/libmailwrapper/mboxwrapper.h b/kmicromail/libmailwrapper/mboxwrapper.h index 9731b85..d03940f 100644 --- a/kmicromail/libmailwrapper/mboxwrapper.h +++ b/kmicromail/libmailwrapper/mboxwrapper.h @@ -37,4 +37,5 @@ public: virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; + virtual Account* getAccount() { return 0; }; protected: diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp index cbc52d9..962dac0 100644 --- a/kmicromail/libmailwrapper/mhwrapper.cpp +++ b/kmicromail/libmailwrapper/mhwrapper.cpp @@ -66,4 +66,5 @@ MHwrapper::~MHwrapper() void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) { + qDebug("MHwrapper::listMessages "); init_storage(); if (!m_storage) { diff --git a/kmicromail/libmailwrapper/mhwrapper.h b/kmicromail/libmailwrapper/mhwrapper.h index 550824d..d1b7d1f 100644 --- a/kmicromail/libmailwrapper/mhwrapper.h +++ b/kmicromail/libmailwrapper/mhwrapper.h @@ -43,4 +43,5 @@ public: virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; + virtual Account* getAccount() { return 0; }; public slots: diff --git a/kmicromail/libmailwrapper/nntpwrapper.h b/kmicromail/libmailwrapper/nntpwrapper.h index 5d4e5ce..8c54f12 100644 --- a/kmicromail/libmailwrapper/nntpwrapper.h +++ b/kmicromail/libmailwrapper/nntpwrapper.h @@ -38,4 +38,5 @@ public: virtual const QString&getName()const; static void nntp_progress( size_t current, size_t maximum ); + virtual Account* getAccount() { return account; }; protected: diff --git a/kmicromail/libmailwrapper/pop3wrapper.h b/kmicromail/libmailwrapper/pop3wrapper.h index 7c70942..ebc2fc7 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.h +++ b/kmicromail/libmailwrapper/pop3wrapper.h @@ -35,5 +35,5 @@ public: virtual const QString&getName()const; static void pop3_progress( size_t current, size_t maximum ); - + virtual Account* getAccount() { return account; }; protected: void login(); diff --git a/kmicromail/libmailwrapper/smtpwrapper.h b/kmicromail/libmailwrapper/smtpwrapper.h index 105cbf5..ec42b56 100644 --- a/kmicromail/libmailwrapper/smtpwrapper.h +++ b/kmicromail/libmailwrapper/smtpwrapper.h @@ -28,4 +28,5 @@ public: static progressMailSend*sendProgress; + virtual Account* getAccount() { return m_SmtpAccount; }; signals: diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp index b92b0cf..484a635 100644 --- a/kmicromail/mailistviewitem.cpp +++ b/kmicromail/mailistviewitem.cpp @@ -54,9 +54,9 @@ void MailListViewItem::showEntry() } else { //setText(3, fsize + "MB"); - mKeyMap.insert(4, "M" +fsort ); + mKeyMap.insert(3, "M" +fsort ); } setText(1,mail_data->getSubject()); setText(2,mail_data->getFrom()); - +#if 0 QString date = mail_data->getDate(); @@ -99,7 +99,10 @@ void MailListViewItem::showEntry() date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); } + //qDebug("insert Date %s ", date.latin1()); // if ( date.left(1) != "1" || date.left(1) != "2" ) // date = date.mid(5); mKeyMap.insert(4,date); +#endif + mKeyMap.insert(4,mail_data->getIsoDate()); setText(4,mail_data->getDate()); } |