summaryrefslogtreecommitdiff
authorharlekin <harlekin>2004-01-05 16:03:29 (UTC)
committer harlekin <harlekin>2004-01-05 16:03:29 (UTC)
commit9acbe167d22cf1bed17a0361fdcdadf7581d8127 (patch) (side-by-side diff)
tree41d8d8e5b2e243f1c9842452565c1e9c04d44250
parent22e51ed82162ef307f3f8cef21d3288147f18cad (diff)
downloadopie-9acbe167d22cf1bed17a0361fdcdadf7581d8127.zip
opie-9acbe167d22cf1bed17a0361fdcdadf7581d8127.tar.gz
opie-9acbe167d22cf1bed17a0361fdcdadf7581d8127.tar.bz2
integration of mailbox status stuff
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,10 +1,8 @@
#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;
@@ -18,15 +16,15 @@ 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);
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,24 +1,24 @@
#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 */
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();
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
@@ -2,8 +2,10 @@
#define MAILAPPLET_H
#include <qbutton.h>
+#include <libmailwrapper/statusmail.h>
+
class Config;
class QTimer;
class MailApplet : public QButton {
@@ -11,21 +13,24 @@ 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
@@ -3,9 +3,9 @@ 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/