summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore 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.cpp35
-rw-r--r--noncore/net/mail/taskbarapplet/mailapplet.h5
-rw-r--r--noncore/net/mail/taskbarapplet/taskbarapplet.pro2
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,60 +1,58 @@
#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;
connectionList.setAutoDelete(true);
connectionList.clear();
initAccounts(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;
currentImapStat.message_count+=currentStat.message_recent;
currentImapStat.message_count+=currentStat.message_count;
} else if ( it->getType().compare( "POP3" ) == 0 ) {
POP3account *pop3 = static_cast<POP3account *>(it);
current = AbstractMail::getWrapper(pop3);
connectionList.append(current);
current->statusFolder(currentStat);
currentPop3Stat.message_count+=currentStat.message_unseen;
currentPop3Stat.message_count+=currentStat.message_recent;
currentPop3Stat.message_count+=currentStat.message_count;
}
current->logout();
}
lastPop3Stat = currentPop3Stat;
}
void StatusMail::reset_status()
{
lastPop3Stat = currentPop3Stat;
}
void StatusMail::check_current_stat(folderStat&targetStat)
{
AbstractMail*it = 0;
folderStat currentStat;
currentPop3Stat.message_recent = 0;
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,31 +1,31 @@
#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 */
folderStat lastPop3Stat;
QList<AbstractMail> connectionList;
};
#endif
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
@@ -1,103 +1,124 @@
#include <qlayout.h>
#include <qpixmap.h>
#include <qlabel.h>
#include <qsound.h>
#include <qtimer.h>
#include <qdir.h>
#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 )
: QButton( parent, name, fl ) {
m_config = new Config( "mail" );
m_config->setGroup( "Applet" );
QVBoxLayout *layout = new QVBoxLayout( this );
layout->addItem( new QSpacerItem( 0,0 ) );
QLabel *pixmap = new QLabel( this );
pixmap->setPixmap( Resource::loadPixmap( "mail/mailchecker" ) );
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)" );
e << QString( "opiemail" );
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];
device->setLedState( led, Led_Off );
}
}
// go trough accounts and check here
// also trigger qcop call and save status to config
}
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 )