author | conber <conber> | 2002-06-15 09:46:14 (UTC) |
---|---|---|
committer | conber <conber> | 2002-06-15 09:46:14 (UTC) |
commit | 7f2eef29708380844922f34f59ba4e9beefbf7c3 (patch) (unidiff) | |
tree | f57125fbaabddecc35d6677f1b9e48a4594165d5 /noncore/unsupported/mail2/bend/bend.cpp | |
parent | 0acbdd392814589df303b6e50c79d9822e3db27a (diff) | |
download | opie-7f2eef29708380844922f34f59ba4e9beefbf7c3.zip opie-7f2eef29708380844922f34f59ba4e9beefbf7c3.tar.gz opie-7f2eef29708380844922f34f59ba4e9beefbf7c3.tar.bz2 |
initial checkin
Diffstat (limited to 'noncore/unsupported/mail2/bend/bend.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/mail2/bend/bend.cpp | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/noncore/unsupported/mail2/bend/bend.cpp b/noncore/unsupported/mail2/bend/bend.cpp new file mode 100644 index 0000000..b4da3ac --- a/dev/null +++ b/noncore/unsupported/mail2/bend/bend.cpp | |||
@@ -0,0 +1,116 @@ | |||
1 | #include <qlayout.h> | ||
2 | #include <qpixmap.h> | ||
3 | #include <qlabel.h> | ||
4 | #include <qtimer.h> | ||
5 | #include <qdir.h> | ||
6 | |||
7 | #include <qpe/qcopenvelope_qws.h> | ||
8 | #include <qpe/resource.h> | ||
9 | #include <qpe/config.h> | ||
10 | |||
11 | #include <stdlib.h> | ||
12 | |||
13 | #include "configfile.h" | ||
14 | #include "imapresponse.h" | ||
15 | #include "imaphandler.h" | ||
16 | #include "zaurusstuff.h" | ||
17 | #include "bend.h" | ||
18 | |||
19 | BenD::BenD(QWidget *parent, const char *name, WFlags fl) | ||
20 | : QButton(parent, name, fl) | ||
21 | { | ||
22 | _config = new Config("mail"); | ||
23 | _config->setGroup("Settings"); | ||
24 | |||
25 | QVBoxLayout *layout = new QVBoxLayout(this); | ||
26 | layout->addItem(new QSpacerItem(0,0)); | ||
27 | |||
28 | QLabel *pixmap = new QLabel(this); | ||
29 | pixmap->setPixmap(Resource::loadPixmap("mail/mailchecker")); | ||
30 | layout->addWidget(pixmap); | ||
31 | |||
32 | layout->addItem(new QSpacerItem(0,0)); | ||
33 | |||
34 | hide(); | ||
35 | |||
36 | connect(this, SIGNAL(clicked()), SLOT(slotClicked())); | ||
37 | |||
38 | if (!_config->readBoolEntry("Disabled", false)) { | ||
39 | _intervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; | ||
40 | _intervalTimer = new QTimer(); | ||
41 | _intervalTimer->start(_intervalMs); | ||
42 | connect(_intervalTimer, SIGNAL(timeout()), SLOT(slotCheck())); | ||
43 | |||
44 | QTimer::singleShot(0, this, SLOT(slotCheck())); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | void BenD::drawButton(QPainter *) { } | ||
49 | void BenD::drawButtonText(QPainter *) { } | ||
50 | |||
51 | void BenD::slotClicked() | ||
52 | { | ||
53 | QCopEnvelope e("QPE/System", "execute(QString)"); | ||
54 | e << QString("mail"); | ||
55 | |||
56 | if (_ledOn) { | ||
57 | ZaurusStuff::blinkLedOff(); | ||
58 | _ledOn = false; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | void BenD::slotCheck() | ||
63 | { | ||
64 | // Check wether the check interval has been changed. | ||
65 | int newIntervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; | ||
66 | if (newIntervalMs != _intervalMs) { | ||
67 | _intervalTimer->changeInterval(newIntervalMs); | ||
68 | _intervalMs = newIntervalMs; | ||
69 | } | ||
70 | |||
71 | QValueList<Account> acList = ConfigFile::getAccounts(); | ||
72 | QValueList<Account>::Iterator ot; | ||
73 | for (ot = acList.begin(); ot != acList.end(); ot++) { | ||
74 | if (!((*ot).imapServer().isEmpty() || | ||
75 | (*ot).imapPort().isEmpty() || | ||
76 | (*ot).user().isEmpty() || | ||
77 | (*ot).pass().isEmpty())) { | ||
78 | if (!((*ot).imapSsl() && | ||
79 | (*ot).imapSslPort().isEmpty())) { | ||
80 | IMAPHandler *handler = new IMAPHandler(*ot); | ||
81 | handler->iStatus("INBOX", "RECENT"); | ||
82 | connect(handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPStatus(IMAPResponse &))); | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | |||
88 | void BenD::slotIMAPStatus(IMAPResponse &response) | ||
89 | { | ||
90 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPStatus(IMAPResponse &))); | ||
91 | |||
92 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | ||
93 | if (response.STATUS()[0].recent().toInt() > 0) { | ||
94 | if (isHidden()) show(); | ||
95 | if (_config->readBoolEntry("BlinkLed", true)) | ||
96 | ZaurusStuff::blinkLedOn(); | ||
97 | if (_config->readBoolEntry("PlaySound", false)) { | ||
98 | ZaurusStuff::buzzerOn(); | ||
99 | QTimer::singleShot(3000, this, SLOT(slotSoundOff())); | ||
100 | } | ||
101 | } else { | ||
102 | if (!isHidden()) hide(); | ||
103 | if (!_ledOn) { | ||
104 | ZaurusStuff::blinkLedOff(); | ||
105 | _ledOn = false; | ||
106 | } | ||
107 | } | ||
108 | response.imapHandler()->iLogout(); | ||
109 | } else qWarning("BenD: WARNING: Couldn't retrieve INBOX status."); | ||
110 | } | ||
111 | |||
112 | void BenD::slotSoundOff() | ||
113 | { | ||
114 | ZaurusStuff::buzzerOff(); | ||
115 | } | ||
116 | |||