summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/statusmail.cpp10
-rw-r--r--noncore/net/mail/libmailwrapper/statusmail.h10
-rw-r--r--noncore/net/mail/taskbarapplet/mailapplet.cpp33
-rw-r--r--noncore/net/mail/taskbarapplet/mailapplet.h5
-rw-r--r--noncore/net/mail/taskbarapplet/taskbarapplet.pro2
5 files changed, 42 insertions, 18 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,12 +1,10 @@
#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;
currentImapStat.message_recent=0;
lastPop3Stat = currentImapStat;
currentPop3Stat = currentImapStat;
@@ -16,19 +14,19 @@ StatusMail::StatusMail(QList<Account>*list)
}
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);
connectionList.append(current);
current->statusFolder(currentStat);
currentImapStat.message_count+=currentStat.message_unseen;
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,26 +1,26 @@
#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
a qcop signal or if tab on the taskbar applet*/
virtual void reset_status();
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
the recent are calculated to the difference of the LAST loop */
folderStat currentPop3Stat;
/* lastPop3Stat is the sum of messages in LAST 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
@@ -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 )
@@ -37,14 +40,19 @@ MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl )
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() {
@@ -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 )