Diffstat (limited to 'noncore/net/mail/taskbarapplet') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/taskbarapplet/mailapplet.cpp | 35 | ||||
-rw-r--r-- | noncore/net/mail/taskbarapplet/mailapplet.h | 5 | ||||
-rw-r--r-- | noncore/net/mail/taskbarapplet/taskbarapplet.pro | 2 |
3 files changed, 34 insertions, 8 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 @@ -7,12 +7,15 @@ #include <qpe/qcopenvelope_qws.h> #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; MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) @@ -29,24 +32,29 @@ MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) layout->addWidget( pixmap ); layout->addItem( new QSpacerItem( 0,0 ) ); hide(); - connect( this, SIGNAL( clicked() ), SLOT( slotClicked() ) ); + connect( this, SIGNAL( clicked() ), SLOT( slotClicked() ) ); if ( !m_config->readBoolEntry( "Disabled", false ) ) { m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; 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 *) { } void MailApplet::slotClicked() { qDebug( " CLICKED" ); QCopEnvelope e( "QPE/System", "execute(QString)" ); @@ -55,42 +63,55 @@ void MailApplet::slotClicked() { 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(); +} + +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. int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; if ( newIntervalMs != m_intervalMs ) { 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( ) ) { OLed led = ( device->ledList( ).contains( Led_Mail ) ) ? Led_Mail : device->ledList( ) [0]; device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); } } 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(); if ( !device-> ledList( ).isEmpty( ) ) { OLed led = ( device->ledList( ).contains( Led_Mail ) ) ? Led_Mail : device->ledList( ) [0]; diff --git a/noncore/net/mail/taskbarapplet/mailapplet.h b/noncore/net/mail/taskbarapplet/mailapplet.h index 34bdc22..8369176 100644 --- a/noncore/net/mail/taskbarapplet/mailapplet.h +++ b/noncore/net/mail/taskbarapplet/mailapplet.h @@ -1,32 +1,37 @@ #ifndef MAILAPPLET_H #define MAILAPPLET_H #include <qbutton.h> +#include <libmailwrapper/statusmail.h> + class Config; class QTimer; class MailApplet : public QButton { Q_OBJECT public: MailApplet( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); + ~MailApplet(); protected: void drawButton(QPainter *); void drawButtonText(QPainter *); void gotNewMail(); protected slots: + void startup(); void slotCheck(); void slotClicked(); private: Config *m_config; QTimer *m_intervalTimer; int m_intervalMs; + StatusMail* m_statusMail; }; #endif diff --git a/noncore/net/mail/taskbarapplet/taskbarapplet.pro b/noncore/net/mail/taskbarapplet/taskbarapplet.pro index 3c658e3..c54e87f 100644 --- a/noncore/net/mail/taskbarapplet/taskbarapplet.pro +++ b/noncore/net/mail/taskbarapplet/taskbarapplet.pro @@ -1,12 +1,12 @@ TEMPLATE = lib CONFIG += qt plugin warn_on release HEADERS += mailapplet.h \ mailappletimpl.h SOURCES += mailapplet.cpp \ mailappletimpl.cpp -INCLUDEPATH += $(OPIEDIR)/include +INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/noncore/net/mail LIBS += -lmailwrapper -lqpe -lopie TARGET = mailapplet DESTDIR += $(OPIEDIR)/plugins/applets/ include ( $(OPIEDIR)/include.pro ) |