author | alwin <alwin> | 2004-01-06 12:57:52 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-06 12:57:52 (UTC) |
commit | 46753cb77877f4807ab9b1ba3e6c7a4eed7bc1bd (patch) (side-by-side diff) | |
tree | cd0b99b0856f65499f7d15aaf5670822183dd660 | |
parent | 71b6178795294dcdc85dee7a8ec8e8470c5b06e0 (diff) | |
download | opie-46753cb77877f4807ab9b1ba3e6c7a4eed7bc1bd.zip opie-46753cb77877f4807ab9b1ba3e6c7a4eed7bc1bd.tar.gz opie-46753cb77877f4807ab9b1ba3e6c7a4eed7bc1bd.tar.bz2 |
status of pop3 accounts slightly reworked
when starting opiemail from taskbar applet the status will be
reset
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/statusmail.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mail/taskbarapplet/mailapplet.cpp | 2 |
4 files changed, 16 insertions, 4 deletions
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index d8a36e7..bf91c63 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp @@ -304,32 +304,41 @@ void encodedString::copy_old(const encodedString&old) clean(); if (old.size>0 && old.content) { content = (char*)malloc(old.size*sizeof(char)); memcpy(content,old.content,size); size = old.size; } } const char*encodedString::Content()const { return content; } const int encodedString::Length()const { return size; } void encodedString::setContent(const char*nContent,int nSize) { if (nSize>0 && nContent) { content = (char*)malloc(nSize*sizeof(char)); memcpy(content,nContent,nSize); size = nSize; } } void encodedString::setContent(char*nContent,int nSize) { content = nContent; size = nSize; } + +folderStat&folderStat::operator=(const folderStat&old) +{ + message_count = old.message_count; + message_unseen = old.message_unseen; + message_recent = old.message_recent; + return *this; +} + diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index 05c4816..b2047cb 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h @@ -158,35 +158,36 @@ public: virtual ~encodedString(); /* returns a pointer to the content - do not delete yoursel! */ const char*Content()const; /* returns the lengths of the content 'cause it must not be a null-terminated string! */ const int Length()const; /* makes a deep copy of nContent! */ void setContent(const char*nContent,int nSize); /* Take over the nContent. Means: it will just copy the pointer, not the content. so make sure: No one else frees the string, the string has allocated with malloc for compatibility with c-based libs */ void setContent(char*nContent,int nSize); protected: char * content; unsigned int size; void init(); void copy_old(const encodedString&old); void clean(); }; struct folderStat { unsigned int message_count; unsigned int message_unseen; unsigned int message_recent; + folderStat&operator=(const folderStat&old); }; #endif diff --git a/noncore/net/mail/libmailwrapper/statusmail.cpp b/noncore/net/mail/libmailwrapper/statusmail.cpp index 98f6204..1d7d559 100644 --- a/noncore/net/mail/libmailwrapper/statusmail.cpp +++ b/noncore/net/mail/libmailwrapper/statusmail.cpp @@ -11,71 +11,73 @@ StatusMail::StatusMail(QList<Account>&list) connectionList.setAutoDelete(true); connectionList.clear(); initAccounts(list); } StatusMail::~StatusMail() { } void StatusMail::initAccounts(QList<Account>&accounts) { Account *it; folderStat currentStat; AbstractMail * current = 0; currentPop3Stat.message_count=0; currentPop3Stat.message_recent=0; currentPop3Stat.message_unseen=0; for ( it = accounts.first(); it; it = accounts.next() ) { if ( it->getType().compare( "IMAP" ) == 0 ) { IMAPaccount*ima = static_cast<IMAPaccount *>(it); current = AbstractMail::getWrapper(ima); connectionList.append(current); current->statusFolder(currentStat); currentImapStat.message_count+=currentStat.message_unseen; currentImapStat.message_count+=currentStat.message_recent; currentImapStat.message_count+=currentStat.message_count; } else if ( it->getType().compare( "POP3" ) == 0 ) { POP3account *pop3 = static_cast<POP3account *>(it); current = AbstractMail::getWrapper(pop3); connectionList.append(current); current->statusFolder(currentStat); - currentPop3Stat.message_count+=currentStat.message_unseen; - currentPop3Stat.message_count+=currentStat.message_recent; currentPop3Stat.message_count+=currentStat.message_count; } current->logout(); } - lastPop3Stat = currentPop3Stat; + qDebug("Pop3 init count: %i",currentPop3Stat.message_count); + currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; + lastPop3Stat.message_unseen = currentPop3Stat.message_unseen; + lastPop3Stat.message_recent = currentPop3Stat.message_recent; + lastPop3Stat.message_count = currentPop3Stat.message_count; } void StatusMail::reset_status() { lastPop3Stat = currentPop3Stat; } void StatusMail::check_current_stat(folderStat&targetStat) { AbstractMail*it = 0; folderStat currentStat; currentPop3Stat.message_recent = 0; currentPop3Stat.message_count = 0; currentPop3Stat.message_unseen = 0; currentImapStat = currentPop3Stat; for ( it = connectionList.first(); it; it = connectionList.next() ) { it->statusFolder(currentStat); it->logout(); if (it->getType().lower()=="imap") { currentImapStat.message_unseen+=currentStat.message_unseen; currentImapStat.message_recent+=currentStat.message_recent; currentImapStat.message_count+=currentStat.message_count; } else if (it->getType().lower()=="pop3") { currentPop3Stat.message_count+=currentStat.message_count; qDebug("Pop3 count: %i",currentPop3Stat.message_count); } } qDebug("Pop3 last: %i",lastPop3Stat.message_count); if (currentPop3Stat.message_count > lastPop3Stat.message_count) { currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; currentPop3Stat.message_unseen = currentPop3Stat.message_recent; } else { diff --git a/noncore/net/mail/taskbarapplet/mailapplet.cpp b/noncore/net/mail/taskbarapplet/mailapplet.cpp index 991b5fb..6078013 100644 --- a/noncore/net/mail/taskbarapplet/mailapplet.cpp +++ b/noncore/net/mail/taskbarapplet/mailapplet.cpp @@ -41,65 +41,65 @@ MailApplet::~MailApplet() { delete m_statusMail; if ( m_config ) delete m_config; } void MailApplet::paintEvent( QPaintEvent* ) { QPainter p( this ); p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/inbox" ) ); QFont f( "vera", AppLnk::smallIconSize() ); QFontMetrics fm( f ); p.setFont( f ); p.setPen( Qt::blue ); p.drawText( AppLnk::smallIconSize()/3, AppLnk::smallIconSize() - 2, QString::number( m_newMails ) ); return; } void MailApplet::mouseReleaseEvent( QMouseEvent* e ) { slotClicked(); } void MailApplet::slotClicked() { QCopEnvelope e( "QPE/System", "execute(QString)" ); e << QString( "opiemail" ); ODevice *device = ODevice::inst(); if ( !device-> ledList().isEmpty() ) { OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; device->setLedState( led, Led_Off ); } - // m_statusMails->reset_status(); + if (m_statusMail) m_statusMail->reset_status(); } void MailApplet::startup() { Settings *settings = new Settings(); QList<Account> ma = settings->getAccounts(); m_statusMail = new StatusMail( ma ); delete settings; m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; m_intervalTimer = new QTimer(); m_intervalTimer->start( m_intervalMs ); connect( m_intervalTimer, SIGNAL( timeout() ), this, SLOT( slotCheck() ) ); } void MailApplet::slotCheck() { // Check wether the check interval has been changed. int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; if ( newIntervalMs != m_intervalMs ) { m_intervalTimer->changeInterval( newIntervalMs ); m_intervalMs = newIntervalMs; } if (m_statusMail == 0) { return; } folderStat stat; m_statusMail->check_current_stat( stat ); m_newMails = stat.message_unseen; qDebug( QString( "test %1" ).arg( m_newMails ) ); if ( m_newMails > 0 ) { ODevice *device = ODevice::inst(); |