Diffstat (limited to 'noncore/net/mail/taskbarapplet/mailapplet.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/taskbarapplet/mailapplet.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
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 @@ | |||
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 | ||
16 | using namespace Opie; | 19 | using namespace Opie; |
17 | 20 | ||
18 | MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) | 21 | MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) |
@@ -37,14 +40,19 @@ MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) | |||
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() ) ); | ||
48 | } | ||
44 | } | 49 | } |
50 | |||
51 | MailApplet::~MailApplet() { | ||
52 | delete m_statusMail; | ||
45 | } | 53 | } |
46 | 54 | ||
47 | void MailApplet::drawButton(QPainter *) { } | 55 | void MailApplet::drawButton(QPainter *) { } |
48 | void MailApplet::drawButtonText(QPainter *) { } | 56 | void MailApplet::drawButtonText(QPainter *) { } |
49 | 57 | ||
50 | void MailApplet::slotClicked() { | 58 | void MailApplet::slotClicked() { |
@@ -55,42 +63,55 @@ void MailApplet::slotClicked() { | |||
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 | |||
73 | void 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 | ||
63 | void MailApplet::slotCheck() { | 80 | void 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]; |