Diffstat (limited to 'noncore/unsupported/mail2/bend') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/mail2/bend/bend.cpp | 116 | ||||
-rw-r--r-- | noncore/unsupported/mail2/bend/bend.h | 38 | ||||
-rw-r--r-- | noncore/unsupported/mail2/bend/bend.pro | 10 | ||||
-rw-r--r-- | noncore/unsupported/mail2/bend/bendimpl.cpp | 39 | ||||
-rw-r--r-- | noncore/unsupported/mail2/bend/bendimpl.h | 27 |
5 files changed, 230 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 | |||
diff --git a/noncore/unsupported/mail2/bend/bend.h b/noncore/unsupported/mail2/bend/bend.h new file mode 100644 index 0000000..cf50bc5 --- a/dev/null +++ b/noncore/unsupported/mail2/bend/bend.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #ifndef BEND_H | ||
2 | #define BEND_H | ||
3 | |||
4 | #include <qbutton.h> | ||
5 | |||
6 | class Config; | ||
7 | class QTimer; | ||
8 | class IMAPResponse; | ||
9 | |||
10 | class BenD : public QButton | ||
11 | { | ||
12 | Q_OBJECT | ||
13 | |||
14 | public: | ||
15 | BenD(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | ||
16 | |||
17 | protected: | ||
18 | void drawButton(QPainter *); | ||
19 | void drawButtonText(QPainter *); | ||
20 | void gotNewMail(); | ||
21 | QString rot13(const QString &input); | ||
22 | |||
23 | protected slots: | ||
24 | void slotCheck(); | ||
25 | void slotClicked(); | ||
26 | void slotSoundOff(); | ||
27 | void slotIMAPStatus(IMAPResponse &response); | ||
28 | |||
29 | private: | ||
30 | Config *_config; | ||
31 | QTimer *_intervalTimer; | ||
32 | int _intervalMs; | ||
33 | bool _ledOn; | ||
34 | |||
35 | }; | ||
36 | |||
37 | #endif | ||
38 | |||
diff --git a/noncore/unsupported/mail2/bend/bend.pro b/noncore/unsupported/mail2/bend/bend.pro new file mode 100644 index 0000000..fe7b22c --- a/dev/null +++ b/noncore/unsupported/mail2/bend/bend.pro | |||
@@ -0,0 +1,10 @@ | |||
1 | TEMPLATE =lib | ||
2 | CONFIG +=qt warn_on release | ||
3 | HEADERS +=bend.h \ | ||
4 | bendimpl.h | ||
5 | SOURCES +=bend.cpp \ | ||
6 | bendimpl.cpp | ||
7 | INCLUDEPATH +=$(OPIEDIR)/include ../libmail | ||
8 | LIBS +=-lmail -lqpe | ||
9 | TARGET =bend | ||
10 | DESTDIR +=$(OPIEDIR)/plugins/applets/ | ||
diff --git a/noncore/unsupported/mail2/bend/bendimpl.cpp b/noncore/unsupported/mail2/bend/bendimpl.cpp new file mode 100644 index 0000000..e616c68 --- a/dev/null +++ b/noncore/unsupported/mail2/bend/bendimpl.cpp | |||
@@ -0,0 +1,39 @@ | |||
1 | #include "bendimpl.h" | ||
2 | #include "bend.h" | ||
3 | |||
4 | BenDImpl::BenDImpl() | ||
5 | : _benD(0), ref(0) | ||
6 | { | ||
7 | |||
8 | } | ||
9 | |||
10 | BenDImpl::~BenDImpl() | ||
11 | { | ||
12 | delete _benD; | ||
13 | } | ||
14 | |||
15 | QWidget *BenDImpl::applet(QWidget *parent) | ||
16 | { | ||
17 | if (!_benD) _benD = new BenD(parent); | ||
18 | return _benD; | ||
19 | } | ||
20 | |||
21 | int BenDImpl::position() const | ||
22 | { | ||
23 | return 4; | ||
24 | } | ||
25 | |||
26 | QRESULT BenDImpl::queryInterface(const QUuid &uuid, QUnknownInterface **iface) | ||
27 | { | ||
28 | *iface = 0; | ||
29 | if (uuid == IID_QUnknown) *iface = this; | ||
30 | else if (uuid == IID_TaskbarApplet) *iface = this; | ||
31 | |||
32 | if (*iface) (*iface)->addRef(); | ||
33 | return QS_OK; | ||
34 | } | ||
35 | |||
36 | Q_EXPORT_INTERFACE() | ||
37 | { | ||
38 | Q_CREATE_INSTANCE(BenDImpl) | ||
39 | } | ||
diff --git a/noncore/unsupported/mail2/bend/bendimpl.h b/noncore/unsupported/mail2/bend/bendimpl.h new file mode 100644 index 0000000..c883f1b --- a/dev/null +++ b/noncore/unsupported/mail2/bend/bendimpl.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef BENDIMPL_H | ||
2 | #define BENDIMPL_H | ||
3 | |||
4 | #include <qpe/taskbarappletinterface.h> | ||
5 | |||
6 | class BenD; | ||
7 | |||
8 | class BenDImpl : public TaskbarAppletInterface | ||
9 | { | ||
10 | public: | ||
11 | BenDImpl(); | ||
12 | virtual ~BenDImpl(); | ||
13 | |||
14 | QRESULT queryInterface(const QUuid &uuid, QUnknownInterface **iface); | ||
15 | Q_REFCOUNT | ||
16 | |||
17 | virtual QWidget *applet(QWidget *parent); | ||
18 | virtual int position() const; | ||
19 | |||
20 | private: | ||
21 | BenD *_benD; | ||
22 | ulong ref; | ||
23 | |||
24 | }; | ||
25 | |||
26 | #endif | ||
27 | |||