summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/taskbarapplet/mailapplet.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/net/mail/taskbarapplet/mailapplet.cpp b/noncore/net/mail/taskbarapplet/mailapplet.cpp
index f81dce8..31d5bfe 100644
--- a/noncore/net/mail/taskbarapplet/mailapplet.cpp
+++ b/noncore/net/mail/taskbarapplet/mailapplet.cpp
@@ -1,124 +1,126 @@
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> 13#include <qlist.h>
14 14
15#include <libmailwrapper/settings.h> 15#include <libmailwrapper/settings.h>
16 16
17#include "mailapplet.h" 17#include "mailapplet.h"
18 18
19using namespace Opie; 19using namespace Opie;
20 20
21MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl ) 21MailApplet::MailApplet( QWidget *parent, const char *name, WFlags fl )
22 : QButton( parent, name, fl ) { 22 : QButton( parent, name, fl ) {
23 23
24 m_config = new Config( "mail" ); 24 m_config = new Config( "mail" );
25 m_config->setGroup( "Applet" ); 25 m_config->setGroup( "Applet" );
26 26
27 QVBoxLayout *layout = new QVBoxLayout( this ); 27 QVBoxLayout *layout = new QVBoxLayout( this );
28 layout->addItem( new QSpacerItem( 0,0 ) ); 28 layout->addItem( new QSpacerItem( 0,0 ) );
29 29
30 QLabel *pixmap = new QLabel( this ); 30 QLabel *pixmap = new QLabel( this );
31 pixmap->setPixmap( Resource::loadPixmap( "mail/mailchecker" ) ); 31 pixmap->setPixmap( Resource::loadPixmap( "mail/mailchecker" ) );
32 layout->addWidget( pixmap ); 32 layout->addWidget( pixmap );
33 33
34 layout->addItem( new QSpacerItem( 0,0 ) ); 34 layout->addItem( new QSpacerItem( 0,0 ) );
35 35
36 hide(); 36 hide();
37 37
38 m_statusMail = 0;
39
38 connect( this, SIGNAL( clicked() ), SLOT( slotClicked() ) ); 40 connect( this, SIGNAL( clicked() ), SLOT( slotClicked() ) );
39 41
40 if ( !m_config->readBoolEntry( "Disabled", false ) ) { 42 if ( !m_config->readBoolEntry( "Disabled", false ) ) {
41 m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; 43 m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000;
42 m_intervalTimer = new QTimer(); 44 m_intervalTimer = new QTimer();
43 m_intervalTimer->start( m_intervalMs ); 45 m_intervalTimer->start( m_intervalMs );
44 connect( m_intervalTimer, SIGNAL(timeout() ), SLOT( slotCheck() ) ); 46 connect( m_intervalTimer, SIGNAL(timeout() ), SLOT( slotCheck() ) );
45 47
46 // delay 5 sec until the whole mail backend gets started .-) 48 // delay 5 sec until the whole mail backend gets started .-)
47 QTimer::singleShot( 5000, this, SLOT( startup() ) ); 49 QTimer::singleShot( 5000, this, SLOT( startup() ) );
48 } 50 }
49} 51}
50 52
51MailApplet::~MailApplet() { 53MailApplet::~MailApplet() {
52 delete m_statusMail; 54 if (m_statusMail) delete m_statusMail;
53} 55}
54 56
55void MailApplet::drawButton(QPainter *) { } 57void MailApplet::drawButton(QPainter *) { }
56void MailApplet::drawButtonText(QPainter *) { } 58void MailApplet::drawButtonText(QPainter *) { }
57 59
58void MailApplet::slotClicked() { 60void MailApplet::slotClicked() {
59 qDebug( " CLICKED" ); 61 qDebug( " CLICKED" );
60 QCopEnvelope e( "QPE/System", "execute(QString)" ); 62 QCopEnvelope e( "QPE/System", "execute(QString)" );
61 e << QString( "opiemail" ); 63 e << QString( "opiemail" );
62 64
63 ODevice *device = ODevice::inst(); 65 ODevice *device = ODevice::inst();
64 if ( !device-> ledList ( ). isEmpty ( ) ) { 66 if ( !device-> ledList ( ). isEmpty ( ) ) {
65 OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; 67 OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0];
66 68
67 device->setLedState( led, Led_Off ); 69 device->setLedState( led, Led_Off );
68 } 70 }
69 71
70 // m_statusMails->reset_status(); 72 // m_statusMails->reset_status();
71} 73}
72 74
73void MailApplet::startup() { 75void MailApplet::startup() {
74 Settings *settings = new Settings(); 76 Settings *settings = new Settings();
75 QList<Account> ma = settings->getAccounts(); 77 QList<Account> ma = settings->getAccounts();
76 StatusMail m_statusMail = StatusMail( ma ); 78 StatusMail m_statusMail = StatusMail( ma );
77 delete settings; 79 delete settings;
78} 80}
79 81
80void MailApplet::slotCheck() { 82void MailApplet::slotCheck() {
81 // Check wether the check interval has been changed. 83 // Check wether the check interval has been changed.
82 int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; 84 int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000;
83 if ( newIntervalMs != m_intervalMs ) { 85 if ( newIntervalMs != m_intervalMs ) {
84 m_intervalTimer->changeInterval( newIntervalMs ); 86 m_intervalTimer->changeInterval( newIntervalMs );
85 m_intervalMs = newIntervalMs; 87 m_intervalMs = newIntervalMs;
86 } 88 }
87 89
88 90
89 folderStat stat; 91 folderStat stat;
90 m_statusMail->check_current_stat( stat ); 92 m_statusMail->check_current_stat( stat );
91 93
92 qDebug( QString( "test %1" ).arg( stat.message_unseen ) ); 94 qDebug( QString( "test %1" ).arg( stat.message_unseen ) );
93 if ( stat.message_unseen > 0 ) { 95 if ( stat.message_unseen > 0 ) {
94 ODevice *device = ODevice::inst(); 96 ODevice *device = ODevice::inst();
95 if ( isHidden() ) show(); 97 if ( isHidden() ) show();
96 if ( m_config->readBoolEntry( "BlinkLed", true ) ) { 98 if ( m_config->readBoolEntry( "BlinkLed", true ) ) {
97 if ( !device-> ledList ( ).isEmpty( ) ) { 99 if ( !device-> ledList ( ).isEmpty( ) ) {
98 OLed led = ( device->ledList( ).contains( Led_Mail ) ) ? Led_Mail : device->ledList( ) [0]; 100 OLed led = ( device->ledList( ).contains( Led_Mail ) ) ? Led_Mail : device->ledList( ) [0];
99 device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); 101 device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On );
100 } 102 }
101 } 103 }
102 if ( m_config->readBoolEntry( "PlaySound", false ) ) 104 if ( m_config->readBoolEntry( "PlaySound", false ) )
103 device->alarmSound(); 105 device->alarmSound();
104 106
105 qDebug( QString( "test %1" ).arg( stat.message_unseen ) ); 107 qDebug( QString( "test %1" ).arg( stat.message_unseen ) );
106 108
107 Config cfg( "mail" ); 109 Config cfg( "mail" );
108 cfg.setGroup( "Status" ); 110 cfg.setGroup( "Status" );
109 cfg.writeEntry( "NewMails", ( int )stat.message_unseen ); 111 cfg.writeEntry( "NewMails", ( int )stat.message_unseen );
110 QCopEnvelope env( "QPE/Pim", "newMails(int)" ); 112 QCopEnvelope env( "QPE/Pim", "newMails(int)" );
111 env << stat.message_unseen; 113 env << stat.message_unseen;
112 114
113 } else { 115 } else {
114 ODevice *device = ODevice::inst(); 116 ODevice *device = ODevice::inst();
115 if ( !isHidden() ) hide(); 117 if ( !isHidden() ) hide();
116 if ( !device-> ledList( ).isEmpty( ) ) { 118 if ( !device-> ledList( ).isEmpty( ) ) {
117 OLed led = ( device->ledList( ).contains( Led_Mail ) ) ? Led_Mail : device->ledList( ) [0]; 119 OLed led = ( device->ledList( ).contains( Led_Mail ) ) ? Led_Mail : device->ledList( ) [0];
118 device->setLedState( led, Led_Off ); 120 device->setLedState( led, Led_Off );
119 } 121 }
120 } 122 }
121 123
122 // go trough accounts and check here 124 // go trough accounts and check here
123 // also trigger qcop call and save status to config 125 // also trigger qcop call and save status to config
124} 126}