-rw-r--r-- | noncore/net/mail/libmailwrapper/statusmail.cpp | 10 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/statusmail.h | 10 | ||||
-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 |
5 files changed, 43 insertions, 19 deletions
diff --git a/noncore/net/mail/libmailwrapper/statusmail.cpp b/noncore/net/mail/libmailwrapper/statusmail.cpp index 3e1d8d1..9f4c47c 100644 --- a/noncore/net/mail/libmailwrapper/statusmail.cpp +++ b/noncore/net/mail/libmailwrapper/statusmail.cpp @@ -1,9 +1,7 @@ #include "statusmail.h" -#include "mailtypes.h" -#include "abstractmail.h" #include <qlist.h> -StatusMail::StatusMail(QList<Account>*list) +StatusMail::StatusMail(QList<Account>&list) { currentImapStat.message_count=0; currentImapStat.message_unseen=0; @@ -19,13 +17,13 @@ StatusMail::~StatusMail() { } -void StatusMail::initAccounts(QList<Account>*accounts) +void StatusMail::initAccounts(QList<Account>&accounts) { - if (!accounts) return; + Account *it; folderStat currentStat; AbstractMail * current = 0; - for ( it = accounts->first(); it; it = accounts->next() ) { + for ( it = accounts.first(); it; it = accounts.next() ) { if ( it->getType().compare( "IMAP" ) == 0 ) { IMAPaccount*ima = static_cast<IMAPaccount *>(it); current = AbstractMail::getWrapper(ima); diff --git a/noncore/net/mail/libmailwrapper/statusmail.h b/noncore/net/mail/libmailwrapper/statusmail.h index 498f7a3..2637232 100644 --- a/noncore/net/mail/libmailwrapper/statusmail.h +++ b/noncore/net/mail/libmailwrapper/statusmail.h @@ -1,14 +1,14 @@ #ifndef __MAIL_STATUS_H #define __MAIL_STATUS_H -#include <settings.h> -#include <abstractmail.h> -#include <mailtypes.h> +#include "settings.h" +#include "abstractmail.h" +#include "mailtypes.h" class StatusMail { public: - StatusMail(QList<Account>*list); + StatusMail(QList<Account>&list); virtual ~StatusMail(); /* this should be called if opiemail is starte or a mailbox touched - may be trough @@ -17,7 +17,7 @@ public: virtual void check_current_stat(folderStat&targetStat); protected: - void initAccounts(QList<Account>*list); + void initAccounts(QList<Account>&accounts); /* this must be cause we have to calculate the recent for pop3*/ folderStat currentImapStat; /* currentPop3Stat is the sum of messages in POP3 accounts in CURRENT loop 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 @@ -10,6 +10,9 @@ #include <qpe/config.h> #include <opie/odevice.h> +#include <qlist.h> + +#include <libmailwrapper/settings.h> #include "mailapplet.h" @@ -32,7 +35,7 @@ MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) 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; @@ -40,10 +43,15 @@ MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) 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 *) { } @@ -58,6 +66,15 @@ void MailApplet::slotClicked() { 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() { @@ -68,9 +85,12 @@ void MailApplet::slotCheck() { 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 ) ) { @@ -82,12 +102,13 @@ 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(); 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 @@ -3,6 +3,8 @@ #include <qbutton.h> +#include <libmailwrapper/statusmail.h> + class Config; class QTimer; @@ -12,6 +14,7 @@ class MailApplet : public QButton { public: MailApplet( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); + ~MailApplet(); protected: void drawButton(QPainter *); @@ -19,12 +22,14 @@ protected: void gotNewMail(); protected slots: + void startup(); void slotCheck(); void slotClicked(); private: Config *m_config; QTimer *m_intervalTimer; int m_intervalMs; + StatusMail* m_statusMail; }; 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 @@ -4,7 +4,7 @@ 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/ |