Diffstat (limited to 'noncore/net/mail/taskbarapplet/mailapplet.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/taskbarapplet/mailapplet.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/noncore/net/mail/taskbarapplet/mailapplet.cpp b/noncore/net/mail/taskbarapplet/mailapplet.cpp index 5ba7085..f81dce8 100644 --- a/noncore/net/mail/taskbarapplet/mailapplet.cpp +++ b/noncore/net/mail/taskbarapplet/mailapplet.cpp @@ -9,8 +9,11 @@ #include <qpe/resource.h> #include <qpe/config.h> #include <opie/odevice.h> +#include <qlist.h> + +#include <libmailwrapper/settings.h> #include "mailapplet.h" using namespace Opie; @@ -39,10 +42,15 @@ MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) m_intervalTimer = new QTimer(); m_intervalTimer->start( m_intervalMs ); connect( m_intervalTimer, SIGNAL(timeout() ), SLOT( slotCheck() ) ); - QTimer::singleShot( 0, this, SLOT( slotCheck() ) ); + // delay 5 sec until the whole mail backend gets started .-) + QTimer::singleShot( 5000, this, SLOT( startup() ) ); + } } + +MailApplet::~MailApplet() { + delete m_statusMail; } void MailApplet::drawButton(QPainter *) { } void MailApplet::drawButtonText(QPainter *) { } @@ -57,8 +65,17 @@ void MailApplet::slotClicked() { OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; device->setLedState( led, Led_Off ); } + + // m_statusMails->reset_status(); +} + +void MailApplet::startup() { + Settings *settings = new Settings(); + QList<Account> ma = settings->getAccounts(); + StatusMail m_statusMail = StatusMail( ma ); + delete settings; } void MailApplet::slotCheck() { // Check wether the check interval has been changed. @@ -67,11 +84,14 @@ void MailApplet::slotCheck() { m_intervalTimer->changeInterval( newIntervalMs ); m_intervalMs = newIntervalMs; } - int newMails = 0; - if ( true ) { + folderStat stat; + m_statusMail->check_current_stat( stat ); + + qDebug( QString( "test %1" ).arg( stat.message_unseen ) ); + if ( stat.message_unseen > 0 ) { ODevice *device = ODevice::inst(); if ( isHidden() ) show(); if ( m_config->readBoolEntry( "BlinkLed", true ) ) { if ( !device-> ledList ( ).isEmpty( ) ) { @@ -81,14 +101,15 @@ void MailApplet::slotCheck() { } if ( m_config->readBoolEntry( "PlaySound", false ) ) device->alarmSound(); + qDebug( QString( "test %1" ).arg( stat.message_unseen ) ); + Config cfg( "mail" ); cfg.setGroup( "Status" ); - cfg.writeEntry( "NewMails", newMails ); // todo - + cfg.writeEntry( "NewMails", ( int )stat.message_unseen ); QCopEnvelope env( "QPE/Pim", "newMails(int)" ); - env << newMails; + env << stat.message_unseen; } else { ODevice *device = ODevice::inst(); if ( !isHidden() ) hide(); |