summaryrefslogtreecommitdiff
Unidiff
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,52 +1,50 @@
1#include "statusmail.h" 1#include "statusmail.h"
2#include "mailtypes.h"
3#include "abstractmail.h"
4#include <qlist.h> 2#include <qlist.h>
5 3
6StatusMail::StatusMail(QList<Account>*list) 4StatusMail::StatusMail(QList<Account>&list)
7{ 5{
8 currentImapStat.message_count=0; 6 currentImapStat.message_count=0;
9 currentImapStat.message_unseen=0; 7 currentImapStat.message_unseen=0;
10 currentImapStat.message_recent=0; 8 currentImapStat.message_recent=0;
11 lastPop3Stat = currentImapStat; 9 lastPop3Stat = currentImapStat;
12 currentPop3Stat = currentImapStat; 10 currentPop3Stat = currentImapStat;
13 connectionList.setAutoDelete(true); 11 connectionList.setAutoDelete(true);
14 connectionList.clear(); 12 connectionList.clear();
15 initAccounts(list); 13 initAccounts(list);
16} 14}
17 15
18StatusMail::~StatusMail() 16StatusMail::~StatusMail()
19{ 17{
20} 18}
21 19
22void StatusMail::initAccounts(QList<Account>*accounts) 20void StatusMail::initAccounts(QList<Account>&accounts)
23{ 21{
24 if (!accounts) return; 22
25 Account *it; 23 Account *it;
26 folderStat currentStat; 24 folderStat currentStat;
27 AbstractMail * current = 0; 25 AbstractMail * current = 0;
28 for ( it = accounts->first(); it; it = accounts->next() ) { 26 for ( it = accounts.first(); it; it = accounts.next() ) {
29 if ( it->getType().compare( "IMAP" ) == 0 ) { 27 if ( it->getType().compare( "IMAP" ) == 0 ) {
30 IMAPaccount*ima = static_cast<IMAPaccount *>(it); 28 IMAPaccount*ima = static_cast<IMAPaccount *>(it);
31 current = AbstractMail::getWrapper(ima); 29 current = AbstractMail::getWrapper(ima);
32 connectionList.append(current); 30 connectionList.append(current);
33 current->statusFolder(currentStat); 31 current->statusFolder(currentStat);
34 currentImapStat.message_count+=currentStat.message_unseen; 32 currentImapStat.message_count+=currentStat.message_unseen;
35 currentImapStat.message_count+=currentStat.message_recent; 33 currentImapStat.message_count+=currentStat.message_recent;
36 currentImapStat.message_count+=currentStat.message_count; 34 currentImapStat.message_count+=currentStat.message_count;
37 } else if ( it->getType().compare( "POP3" ) == 0 ) { 35 } else if ( it->getType().compare( "POP3" ) == 0 ) {
38 POP3account *pop3 = static_cast<POP3account *>(it); 36 POP3account *pop3 = static_cast<POP3account *>(it);
39 current = AbstractMail::getWrapper(pop3); 37 current = AbstractMail::getWrapper(pop3);
40 connectionList.append(current); 38 connectionList.append(current);
41 current->statusFolder(currentStat); 39 current->statusFolder(currentStat);
42 currentPop3Stat.message_count+=currentStat.message_unseen; 40 currentPop3Stat.message_count+=currentStat.message_unseen;
43 currentPop3Stat.message_count+=currentStat.message_recent; 41 currentPop3Stat.message_count+=currentStat.message_recent;
44 currentPop3Stat.message_count+=currentStat.message_count; 42 currentPop3Stat.message_count+=currentStat.message_count;
45 } 43 }
46 current->logout(); 44 current->logout();
47 } 45 }
48 lastPop3Stat = currentPop3Stat; 46 lastPop3Stat = currentPop3Stat;
49} 47}
50 48
51void StatusMail::reset_status() 49void StatusMail::reset_status()
52{ 50{
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 @@
1#ifndef __MAIL_STATUS_H 1#ifndef __MAIL_STATUS_H
2#define __MAIL_STATUS_H 2#define __MAIL_STATUS_H
3 3
4#include <settings.h> 4#include "settings.h"
5#include <abstractmail.h> 5#include "abstractmail.h"
6#include <mailtypes.h> 6#include "mailtypes.h"
7 7
8class StatusMail 8class StatusMail
9{ 9{
10public: 10public:
11 StatusMail(QList<Account>*list); 11 StatusMail(QList<Account>&list);
12 virtual ~StatusMail(); 12 virtual ~StatusMail();
13 13
14 /* this should be called if opiemail is starte or a mailbox touched - may be trough 14 /* this should be called if opiemail is starte or a mailbox touched - may be trough
15 a qcop signal or if tab on the taskbar applet*/ 15 a qcop signal or if tab on the taskbar applet*/
16 virtual void reset_status(); 16 virtual void reset_status();
17 virtual void check_current_stat(folderStat&targetStat); 17 virtual void check_current_stat(folderStat&targetStat);
18 18
19protected: 19protected:
20 void initAccounts(QList<Account>*list); 20 void initAccounts(QList<Account>&accounts);
21 /* this must be cause we have to calculate the recent for pop3*/ 21 /* this must be cause we have to calculate the recent for pop3*/
22 folderStat currentImapStat; 22 folderStat currentImapStat;
23 /* currentPop3Stat is the sum of messages in POP3 accounts in CURRENT loop 23 /* currentPop3Stat is the sum of messages in POP3 accounts in CURRENT loop
24 the recent are calculated to the difference of the LAST loop */ 24 the recent are calculated to the difference of the LAST loop */
25 folderStat currentPop3Stat; 25 folderStat currentPop3Stat;
26 /* lastPop3Stat is the sum of messages in LAST loop */ 26 /* lastPop3Stat is the sum of messages in LAST loop */
27 folderStat lastPop3Stat; 27 folderStat lastPop3Stat;
28 QList<AbstractMail> connectionList; 28 QList<AbstractMail> connectionList;
29}; 29};
30 30
31#endif 31#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 @@
1#include <qlayout.h> 1#include <qlayout.h>
2#include <qpixmap.h> 2#include <qpixmap.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qsound.h> 4#include <qsound.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdir.h> 6#include <qdir.h>
7 7
8#include <qpe/qcopenvelope_qws.h> 8#include <qpe/qcopenvelope_qws.h>
9#include <qpe/resource.h> 9#include <qpe/resource.h>
10#include <qpe/config.h> 10#include <qpe/config.h>
11 11
12#include <opie/odevice.h> 12#include <opie/odevice.h>
13#include <qlist.h>
14
15#include <libmailwrapper/settings.h>
13 16
14#include "mailapplet.h" 17#include "mailapplet.h"
15 18
16using namespace Opie; 19using namespace Opie;
17 20
18MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) 21MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl )
19 : QButton( parent, name, fl ) { 22 : QButton( parent, name, fl ) {
20 23
21 m_config = new Config( "mail" ); 24 m_config = new Config( "mail" );
22 m_config->setGroup( "Applet" ); 25 m_config->setGroup( "Applet" );
23 26
24 QVBoxLayout *layout = new QVBoxLayout( this ); 27 QVBoxLayout *layout = new QVBoxLayout( this );
25 layout->addItem( new QSpacerItem( 0,0 ) ); 28 layout->addItem( new QSpacerItem( 0,0 ) );
26 29
27 QLabel *pixmap = new QLabel( this ); 30 QLabel *pixmap = new QLabel( this );
28 pixmap->setPixmap( Resource::loadPixmap( "mail/mailchecker" ) ); 31 pixmap->setPixmap( Resource::loadPixmap( "mail/mailchecker" ) );
29 layout->addWidget( pixmap ); 32 layout->addWidget( pixmap );
30 33
31 layout->addItem( new QSpacerItem( 0,0 ) ); 34 layout->addItem( new QSpacerItem( 0,0 ) );
32 35
33 hide(); 36 hide();
34 37
35 connect( this, SIGNAL( clicked() ), SLOT( slotClicked() ) ); 38 connect( this, SIGNAL( clicked() ), SLOT( slotClicked() ) );
36 39
37 if ( !m_config->readBoolEntry( "Disabled", false ) ) { 40 if ( !m_config->readBoolEntry( "Disabled", false ) ) {
38 m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; 41 m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000;
39 m_intervalTimer = new QTimer(); 42 m_intervalTimer = new QTimer();
40 m_intervalTimer->start( m_intervalMs ); 43 m_intervalTimer->start( m_intervalMs );
41 connect( m_intervalTimer, SIGNAL(timeout() ), SLOT( slotCheck() ) ); 44 connect( m_intervalTimer, SIGNAL(timeout() ), SLOT( slotCheck() ) );
42 45
43 QTimer::singleShot( 0, this, SLOT( slotCheck() ) ); 46 // delay 5 sec until the whole mail backend gets started .-)
47 QTimer::singleShot( 5000, this, SLOT( startup() ) );
44 } 48 }
45} 49}
46 50
51MailApplet::~MailApplet() {
52 delete m_statusMail;
53}
54
47void MailApplet::drawButton(QPainter *) { } 55void MailApplet::drawButton(QPainter *) { }
48void MailApplet::drawButtonText(QPainter *) { } 56void MailApplet::drawButtonText(QPainter *) { }
49 57
50void MailApplet::slotClicked() { 58void MailApplet::slotClicked() {
51 qDebug( " CLICKED" ); 59 qDebug( " CLICKED" );
52 QCopEnvelope e( "QPE/System", "execute(QString)" ); 60 QCopEnvelope e( "QPE/System", "execute(QString)" );
53 e << QString( "opiemail" ); 61 e << QString( "opiemail" );
54 62
55 ODevice *device = ODevice::inst(); 63 ODevice *device = ODevice::inst();
56 if ( !device-> ledList ( ). isEmpty ( ) ) { 64 if ( !device-> ledList ( ). isEmpty ( ) ) {
57 OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; 65 OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0];
58 66
59 device->setLedState( led, Led_Off ); 67 device->setLedState( led, Led_Off );
60 } 68 }
69
70 // m_statusMails->reset_status();
71}
72
73void MailApplet::startup() {
74 Settings *settings = new Settings();
75 QList<Account> ma = settings->getAccounts();
76 StatusMail m_statusMail = StatusMail( ma );
77 delete settings;
61} 78}
62 79
63void MailApplet::slotCheck() { 80void MailApplet::slotCheck() {
64 // Check wether the check interval has been changed. 81 // Check wether the check interval has been changed.
65 int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; 82 int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000;
66 if ( newIntervalMs != m_intervalMs ) { 83 if ( newIntervalMs != m_intervalMs ) {
67 m_intervalTimer->changeInterval( newIntervalMs ); 84 m_intervalTimer->changeInterval( newIntervalMs );
68 m_intervalMs = newIntervalMs; 85 m_intervalMs = newIntervalMs;
69 } 86 }
70 87
71 int newMails = 0;
72 88
73 if ( true ) { 89 folderStat stat;
90 m_statusMail->check_current_stat( stat );
91
92 qDebug( QString( "test %1" ).arg( stat.message_unseen ) );
93 if ( stat.message_unseen > 0 ) {
74 ODevice *device = ODevice::inst(); 94 ODevice *device = ODevice::inst();
75 if ( isHidden() ) show(); 95 if ( isHidden() ) show();
76 if ( m_config->readBoolEntry( "BlinkLed", true ) ) { 96 if ( m_config->readBoolEntry( "BlinkLed", true ) ) {
77 if ( !device-> ledList ( ).isEmpty( ) ) { 97 if ( !device-> ledList ( ).isEmpty( ) ) {
78 OLed led = ( device->ledList( ).contains( Led_Mail ) ) ? Led_Mail : device->ledList( ) [0]; 98 OLed led = ( device->ledList( ).contains( Led_Mail ) ) ? Led_Mail : device->ledList( ) [0];
79 device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); 99 device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On );
80 } 100 }
81 } 101 }
82 if ( m_config->readBoolEntry( "PlaySound", false ) ) 102 if ( m_config->readBoolEntry( "PlaySound", false ) )
83 device->alarmSound(); 103 device->alarmSound();
84 104
105 qDebug( QString( "test %1" ).arg( stat.message_unseen ) );
106
85 Config cfg( "mail" ); 107 Config cfg( "mail" );
86 cfg.setGroup( "Status" ); 108 cfg.setGroup( "Status" );
87 cfg.writeEntry( "NewMails", newMails ); // todo 109 cfg.writeEntry( "NewMails", ( int )stat.message_unseen );
88
89 QCopEnvelope env( "QPE/Pim", "newMails(int)" ); 110 QCopEnvelope env( "QPE/Pim", "newMails(int)" );
90 env << newMails; 111 env << stat.message_unseen;
91 112
92 } else { 113 } else {
93 ODevice *device = ODevice::inst(); 114 ODevice *device = ODevice::inst();
94 if ( !isHidden() ) hide(); 115 if ( !isHidden() ) hide();
95 if ( !device-> ledList( ).isEmpty( ) ) { 116 if ( !device-> ledList( ).isEmpty( ) ) {
96 OLed led = ( device->ledList( ).contains( Led_Mail ) ) ? Led_Mail : device->ledList( ) [0]; 117 OLed led = ( device->ledList( ).contains( Led_Mail ) ) ? Led_Mail : device->ledList( ) [0];
97 device->setLedState( led, Led_Off ); 118 device->setLedState( led, Led_Off );
98 } 119 }
99 } 120 }
100 121
101 // go trough accounts and check here 122 // go trough accounts and check here
102 // also trigger qcop call and save status to config 123 // also trigger qcop call and save status to config
103} 124}
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 @@
1#ifndef MAILAPPLET_H 1#ifndef MAILAPPLET_H
2#define MAILAPPLET_H 2#define MAILAPPLET_H
3 3
4#include <qbutton.h> 4#include <qbutton.h>
5 5
6#include <libmailwrapper/statusmail.h>
7
6class Config; 8class Config;
7class QTimer; 9class QTimer;
8 10
9class MailApplet : public QButton { 11class MailApplet : public QButton {
10 12
11 Q_OBJECT 13 Q_OBJECT
12 14
13public: 15public:
14 MailApplet( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); 16 MailApplet( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
17 ~MailApplet();
15 18
16protected: 19protected:
17 void drawButton(QPainter *); 20 void drawButton(QPainter *);
18 void drawButtonText(QPainter *); 21 void drawButtonText(QPainter *);
19 void gotNewMail(); 22 void gotNewMail();
20 23
21protected slots: 24protected slots:
25 void startup();
22 void slotCheck(); 26 void slotCheck();
23 void slotClicked(); 27 void slotClicked();
24private: 28private:
25 Config *m_config; 29 Config *m_config;
26 QTimer *m_intervalTimer; 30 QTimer *m_intervalTimer;
27 int m_intervalMs; 31 int m_intervalMs;
32 StatusMail* m_statusMail;
28 33
29}; 34};
30 35
31#endif 36#endif
32 37
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 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG +=qt plugin warn_on release 2 CONFIG +=qt plugin warn_on release
3 HEADERS +=mailapplet.h \ 3 HEADERS +=mailapplet.h \
4 mailappletimpl.h 4 mailappletimpl.h
5 SOURCES +=mailapplet.cpp \ 5 SOURCES +=mailapplet.cpp \
6 mailappletimpl.cpp 6 mailappletimpl.cpp
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/noncore/net/mail
8 LIBS +=-lmailwrapper -lqpe -lopie 8 LIBS +=-lmailwrapper -lqpe -lopie
9 TARGET =mailapplet 9 TARGET =mailapplet
10 DESTDIR +=$(OPIEDIR)/plugins/applets/ 10 DESTDIR +=$(OPIEDIR)/plugins/applets/
11 11
12include ( $(OPIEDIR)/include.pro ) 12include ( $(OPIEDIR)/include.pro )