author | conber <conber> | 2002-06-19 13:33:18 (UTC) |
---|---|---|
committer | conber <conber> | 2002-06-19 13:33:18 (UTC) |
commit | 6eed7b58b02de6efb49a67f3da3dabbd3aeaa27b (patch) (unidiff) | |
tree | 834e7d2d431cf5264c86c468d1e24364da618661 | |
parent | 952cb1ec42e827f1bc45f9d3f0a1b685ff545790 (diff) | |
download | opie-6eed7b58b02de6efb49a67f3da3dabbd3aeaa27b.zip opie-6eed7b58b02de6efb49a67f3da3dabbd3aeaa27b.tar.gz opie-6eed7b58b02de6efb49a67f3da3dabbd3aeaa27b.tar.bz2 |
changed bend to use ODevice
-rw-r--r-- | noncore/unsupported/mail2/bend/bend.cpp | 44 | ||||
-rw-r--r-- | noncore/unsupported/mail2/bend/bend.h | 3 |
2 files changed, 14 insertions, 33 deletions
diff --git a/noncore/unsupported/mail2/bend/bend.cpp b/noncore/unsupported/mail2/bend/bend.cpp index fe3b736..681aca2 100644 --- a/noncore/unsupported/mail2/bend/bend.cpp +++ b/noncore/unsupported/mail2/bend/bend.cpp | |||
@@ -1,127 +1,111 @@ | |||
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 <stdlib.h> | 12 | #include <opie/odevice.h> |
13 | 13 | ||
14 | #include "configfile.h" | ||
15 | #include "imapresponse.h" | 14 | #include "imapresponse.h" |
16 | #include "imaphandler.h" | 15 | #include "imaphandler.h" |
17 | #include "zaurusstuff.h" | 16 | #include "configfile.h" |
18 | #include "bend.h" | 17 | #include "bend.h" |
19 | 18 | ||
20 | BenD::BenD(QWidget *parent, const char *name, WFlags fl) | 19 | BenD::BenD(QWidget *parent, const char *name, WFlags fl) |
21 | : QButton(parent, name, fl) | 20 | : QButton(parent, name, fl) |
22 | { | 21 | { |
23 | _zaurus = false; | ||
24 | if (QFile("/dev/sharp_buz").exists()) _zaurus = true; | ||
25 | |||
26 | _config = new Config("mail"); | 22 | _config = new Config("mail"); |
27 | _config->setGroup("Settings"); | 23 | _config->setGroup("Settings"); |
28 | 24 | ||
29 | QVBoxLayout *layout = new QVBoxLayout(this); | 25 | QVBoxLayout *layout = new QVBoxLayout(this); |
30 | layout->addItem(new QSpacerItem(0,0)); | 26 | layout->addItem(new QSpacerItem(0,0)); |
31 | 27 | ||
32 | QLabel *pixmap = new QLabel(this); | 28 | QLabel *pixmap = new QLabel(this); |
33 | pixmap->setPixmap(Resource::loadPixmap("mail/mailchecker")); | 29 | pixmap->setPixmap(Resource::loadPixmap("mail/mailchecker")); |
34 | layout->addWidget(pixmap); | 30 | layout->addWidget(pixmap); |
35 | 31 | ||
36 | layout->addItem(new QSpacerItem(0,0)); | 32 | layout->addItem(new QSpacerItem(0,0)); |
37 | 33 | ||
38 | hide(); | 34 | hide(); |
39 | 35 | ||
40 | connect(this, SIGNAL(clicked()), SLOT(slotClicked())); | 36 | connect(this, SIGNAL(clicked()), SLOT(slotClicked())); |
41 | 37 | ||
42 | if (!_config->readBoolEntry("Disabled", false)) { | 38 | if (!_config->readBoolEntry("Disabled", false)) { |
43 | _intervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; | 39 | _intervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; |
44 | _intervalTimer = new QTimer(); | 40 | _intervalTimer = new QTimer(); |
45 | _intervalTimer->start(_intervalMs); | 41 | _intervalTimer->start(_intervalMs); |
46 | connect(_intervalTimer, SIGNAL(timeout()), SLOT(slotCheck())); | 42 | connect(_intervalTimer, SIGNAL(timeout()), SLOT(slotCheck())); |
47 | 43 | ||
48 | QTimer::singleShot(0, this, SLOT(slotCheck())); | 44 | QTimer::singleShot(0, this, SLOT(slotCheck())); |
49 | } | 45 | } |
50 | } | 46 | } |
51 | 47 | ||
52 | void BenD::drawButton(QPainter *) { } | 48 | void BenD::drawButton(QPainter *) { } |
53 | void BenD::drawButtonText(QPainter *) { } | 49 | void BenD::drawButtonText(QPainter *) { } |
54 | 50 | ||
55 | void BenD::slotClicked() | 51 | void BenD::slotClicked() |
56 | { | 52 | { |
57 | QCopEnvelope e("QPE/System", "execute(QString)"); | 53 | QCopEnvelope e("QPE/System", "execute(QString)"); |
58 | e << QString("mail"); | 54 | e << QString("mail"); |
59 | 55 | ||
60 | if (_ledOn) { | 56 | ODevice *device = ODevice::inst(); |
61 | ZaurusStuff::blinkLedOff(); | 57 | if (device->led(1) == OLED_BlinkSlow) |
62 | _ledOn = false; | 58 | device->setLed(1, OLED_Off); |
63 | } | ||
64 | } | 59 | } |
65 | 60 | ||
66 | void BenD::slotCheck() | 61 | void BenD::slotCheck() |
67 | { | 62 | { |
68 | // Check wether the check interval has been changed. | 63 | // Check wether the check interval has been changed. |
69 | int newIntervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; | 64 | int newIntervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; |
70 | if (newIntervalMs != _intervalMs) { | 65 | if (newIntervalMs != _intervalMs) { |
71 | _intervalTimer->changeInterval(newIntervalMs); | 66 | _intervalTimer->changeInterval(newIntervalMs); |
72 | _intervalMs = newIntervalMs; | 67 | _intervalMs = newIntervalMs; |
73 | #ifndef QT_NO_DEBUG | 68 | #ifndef QT_NO_DEBUG |
74 | qWarning("BenD: Detected interval change"); | 69 | qWarning("BenD: Detected interval change"); |
75 | #endif | 70 | #endif |
76 | } | 71 | } |
77 | 72 | ||
78 | QValueList<Account> acList = ConfigFile::getAccounts(); | 73 | QValueList<Account> acList = ConfigFile::getAccounts(); |
79 | QValueList<Account>::Iterator ot; | 74 | QValueList<Account>::Iterator ot; |
80 | for (ot = acList.begin(); ot != acList.end(); ot++) { | 75 | for (ot = acList.begin(); ot != acList.end(); ot++) { |
81 | if (!((*ot).imapServer().isEmpty() || | 76 | if (!((*ot).imapServer().isEmpty() || |
82 | (*ot).imapPort().isEmpty() || | 77 | (*ot).imapPort().isEmpty() || |
83 | (*ot).user().isEmpty() || | 78 | (*ot).user().isEmpty() || |
84 | (*ot).pass().isEmpty())) { | 79 | (*ot).pass().isEmpty())) { |
85 | if (!((*ot).imapSsl() && | 80 | if (!((*ot).imapSsl() && |
86 | (*ot).imapSslPort().isEmpty())) { | 81 | (*ot).imapSslPort().isEmpty())) { |
87 | IMAPHandler *handler = new IMAPHandler(*ot); | 82 | IMAPHandler *handler = new IMAPHandler(*ot); |
88 | handler->iStatus("INBOX", "RECENT"); | 83 | handler->iStatus("INBOX", "RECENT"); |
89 | connect(handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPStatus(IMAPResponse &))); | 84 | connect(handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPStatus(IMAPResponse &))); |
90 | } | 85 | } |
91 | } | 86 | } |
92 | } | 87 | } |
93 | } | 88 | } |
94 | 89 | ||
95 | void BenD::slotIMAPStatus(IMAPResponse &response) | 90 | void BenD::slotIMAPStatus(IMAPResponse &response) |
96 | { | 91 | { |
97 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPStatus(IMAPResponse &))); | 92 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPStatus(IMAPResponse &))); |
98 | 93 | ||
99 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 94 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
100 | if (response.STATUS()[0].recent().toInt() > 0) { | 95 | if (response.STATUS()[0].recent().toInt() > 0) { |
96 | ODevice *device = ODevice::inst(); | ||
101 | if (isHidden()) show(); | 97 | if (isHidden()) show(); |
102 | if (_config->readBoolEntry("BlinkLed", true)) | 98 | if (_config->readBoolEntry("BlinkLed", true)) |
103 | ZaurusStuff::blinkLedOn(); | 99 | device->setLed(1, OLED_BlinkSlow); |
104 | if (_config->readBoolEntry("PlaySound", false)) { | 100 | if (_config->readBoolEntry("PlaySound", false)) |
105 | if (_zaurus) { | 101 | device->alarmSound(); |
106 | ZaurusStuff::buzzerOn(); | ||
107 | QTimer::singleShot(3000, this, SLOT(slotSoundOff())); | ||
108 | } else { | ||
109 | QSound::play(Resource::findSound("mail/newmail")); | ||
110 | } | ||
111 | } | ||
112 | } else { | 102 | } else { |
103 | ODevice *device = ODevice::inst(); | ||
113 | if (!isHidden()) hide(); | 104 | if (!isHidden()) hide(); |
114 | if (!_ledOn) { | 105 | if (device->led(1) == OLED_BlinkSlow) |
115 | ZaurusStuff::blinkLedOff(); | 106 | device->setLed(1, OLED_Off); |
116 | _ledOn = false; | ||
117 | } | ||
118 | } | 107 | } |
119 | response.imapHandler()->iLogout(); | 108 | response.imapHandler()->iLogout(); |
120 | } else qWarning("BenD: WARNING: Couldn't retrieve INBOX status."); | 109 | } else qWarning("BenD: WARNING: Couldn't retrieve INBOX status."); |
121 | } | 110 | } |
122 | 111 | ||
123 | void BenD::slotSoundOff() | ||
124 | { | ||
125 | ZaurusStuff::buzzerOff(); | ||
126 | } | ||
127 | |||
diff --git a/noncore/unsupported/mail2/bend/bend.h b/noncore/unsupported/mail2/bend/bend.h index 7972929..233c552 100644 --- a/noncore/unsupported/mail2/bend/bend.h +++ b/noncore/unsupported/mail2/bend/bend.h | |||
@@ -1,38 +1,35 @@ | |||
1 | #ifndef BEND_H | 1 | #ifndef BEND_H |
2 | #define BEND_H | 2 | #define BEND_H |
3 | 3 | ||
4 | #include <qbutton.h> | 4 | #include <qbutton.h> |
5 | 5 | ||
6 | class Config; | 6 | class Config; |
7 | class QTimer; | 7 | class QTimer; |
8 | class IMAPResponse; | 8 | class IMAPResponse; |
9 | 9 | ||
10 | class BenD : public QButton | 10 | class BenD : public QButton |
11 | { | 11 | { |
12 | Q_OBJECT | 12 | Q_OBJECT |
13 | 13 | ||
14 | public: | 14 | public: |
15 | BenD(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 15 | BenD(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
16 | 16 | ||
17 | protected: | 17 | protected: |
18 | void drawButton(QPainter *); | 18 | void drawButton(QPainter *); |
19 | void drawButtonText(QPainter *); | 19 | void drawButtonText(QPainter *); |
20 | void gotNewMail(); | 20 | void gotNewMail(); |
21 | QString rot13(const QString &input); | ||
22 | 21 | ||
23 | protected slots: | 22 | protected slots: |
24 | void slotCheck(); | 23 | void slotCheck(); |
25 | void slotClicked(); | 24 | void slotClicked(); |
26 | void slotSoundOff(); | ||
27 | void slotIMAPStatus(IMAPResponse &response); | 25 | void slotIMAPStatus(IMAPResponse &response); |
28 | 26 | ||
29 | private: | 27 | private: |
30 | Config *_config; | 28 | Config *_config; |
31 | QTimer *_intervalTimer; | 29 | QTimer *_intervalTimer; |
32 | int _intervalMs; | 30 | int _intervalMs; |
33 | bool _zaurus, _ledOn; | ||
34 | 31 | ||
35 | }; | 32 | }; |
36 | 33 | ||
37 | #endif | 34 | #endif |
38 | 35 | ||