summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mail2/bend
Side-by-side diff
Diffstat (limited to 'noncore/unsupported/mail2/bend') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/bend/bend.cpp116
-rw-r--r--noncore/unsupported/mail2/bend/bend.h38
-rw-r--r--noncore/unsupported/mail2/bend/bend.pro10
-rw-r--r--noncore/unsupported/mail2/bend/bendimpl.cpp39
-rw-r--r--noncore/unsupported/mail2/bend/bendimpl.h27
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 @@
+#include <qlayout.h>
+#include <qpixmap.h>
+#include <qlabel.h>
+#include <qtimer.h>
+#include <qdir.h>
+
+#include <qpe/qcopenvelope_qws.h>
+#include <qpe/resource.h>
+#include <qpe/config.h>
+
+#include <stdlib.h>
+
+#include "configfile.h"
+#include "imapresponse.h"
+#include "imaphandler.h"
+#include "zaurusstuff.h"
+#include "bend.h"
+
+BenD::BenD(QWidget *parent, const char *name, WFlags fl)
+ : QButton(parent, name, fl)
+{
+ _config = new Config("mail");
+ _config->setGroup("Settings");
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addItem(new QSpacerItem(0,0));
+
+ QLabel *pixmap = new QLabel(this);
+ pixmap->setPixmap(Resource::loadPixmap("mail/mailchecker"));
+ layout->addWidget(pixmap);
+
+ layout->addItem(new QSpacerItem(0,0));
+
+ hide();
+
+ connect(this, SIGNAL(clicked()), SLOT(slotClicked()));
+
+ if (!_config->readBoolEntry("Disabled", false)) {
+ _intervalMs = _config->readNumEntry("CheckEvery", 5) * 60000;
+ _intervalTimer = new QTimer();
+ _intervalTimer->start(_intervalMs);
+ connect(_intervalTimer, SIGNAL(timeout()), SLOT(slotCheck()));
+
+ QTimer::singleShot(0, this, SLOT(slotCheck()));
+ }
+}
+
+void BenD::drawButton(QPainter *) { }
+void BenD::drawButtonText(QPainter *) { }
+
+void BenD::slotClicked()
+{
+ QCopEnvelope e("QPE/System", "execute(QString)");
+ e << QString("mail");
+
+ if (_ledOn) {
+ ZaurusStuff::blinkLedOff();
+ _ledOn = false;
+ }
+}
+
+void BenD::slotCheck()
+{
+ // Check wether the check interval has been changed.
+ int newIntervalMs = _config->readNumEntry("CheckEvery", 5) * 60000;
+ if (newIntervalMs != _intervalMs) {
+ _intervalTimer->changeInterval(newIntervalMs);
+ _intervalMs = newIntervalMs;
+ }
+
+ QValueList<Account> acList = ConfigFile::getAccounts();
+ QValueList<Account>::Iterator ot;
+ for (ot = acList.begin(); ot != acList.end(); ot++) {
+ if (!((*ot).imapServer().isEmpty() ||
+ (*ot).imapPort().isEmpty() ||
+ (*ot).user().isEmpty() ||
+ (*ot).pass().isEmpty())) {
+ if (!((*ot).imapSsl() &&
+ (*ot).imapSslPort().isEmpty())) {
+ IMAPHandler *handler = new IMAPHandler(*ot);
+ handler->iStatus("INBOX", "RECENT");
+ connect(handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPStatus(IMAPResponse &)));
+ }
+ }
+ }
+}
+
+void BenD::slotIMAPStatus(IMAPResponse &response)
+{
+ disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPStatus(IMAPResponse &)));
+
+ if (response.statusResponse().status() == IMAPResponseEnums::OK) {
+ if (response.STATUS()[0].recent().toInt() > 0) {
+ if (isHidden()) show();
+ if (_config->readBoolEntry("BlinkLed", true))
+ ZaurusStuff::blinkLedOn();
+ if (_config->readBoolEntry("PlaySound", false)) {
+ ZaurusStuff::buzzerOn();
+ QTimer::singleShot(3000, this, SLOT(slotSoundOff()));
+ }
+ } else {
+ if (!isHidden()) hide();
+ if (!_ledOn) {
+ ZaurusStuff::blinkLedOff();
+ _ledOn = false;
+ }
+ }
+ response.imapHandler()->iLogout();
+ } else qWarning("BenD: WARNING: Couldn't retrieve INBOX status.");
+}
+
+void BenD::slotSoundOff()
+{
+ ZaurusStuff::buzzerOff();
+}
+
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 @@
+#ifndef BEND_H
+#define BEND_H
+
+#include <qbutton.h>
+
+class Config;
+class QTimer;
+class IMAPResponse;
+
+class BenD : public QButton
+{
+ Q_OBJECT
+
+public:
+ BenD(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
+
+protected:
+ void drawButton(QPainter *);
+ void drawButtonText(QPainter *);
+ void gotNewMail();
+ QString rot13(const QString &input);
+
+protected slots:
+ void slotCheck();
+ void slotClicked();
+ void slotSoundOff();
+ void slotIMAPStatus(IMAPResponse &response);
+
+private:
+ Config *_config;
+ QTimer *_intervalTimer;
+ int _intervalMs;
+ bool _ledOn;
+
+};
+
+#endif
+
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 @@
+TEMPLATE = lib
+CONFIG += qt warn_on release
+HEADERS += bend.h \
+ bendimpl.h
+SOURCES += bend.cpp \
+ bendimpl.cpp
+INCLUDEPATH += $(OPIEDIR)/include ../libmail
+LIBS += -lmail -lqpe
+TARGET = bend
+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 @@
+#include "bendimpl.h"
+#include "bend.h"
+
+BenDImpl::BenDImpl()
+ : _benD(0), ref(0)
+{
+
+}
+
+BenDImpl::~BenDImpl()
+{
+ delete _benD;
+}
+
+QWidget *BenDImpl::applet(QWidget *parent)
+{
+ if (!_benD) _benD = new BenD(parent);
+ return _benD;
+}
+
+int BenDImpl::position() const
+{
+ return 4;
+}
+
+QRESULT BenDImpl::queryInterface(const QUuid &uuid, QUnknownInterface **iface)
+{
+ *iface = 0;
+ if (uuid == IID_QUnknown) *iface = this;
+ else if (uuid == IID_TaskbarApplet) *iface = this;
+
+ if (*iface) (*iface)->addRef();
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE(BenDImpl)
+}
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 @@
+#ifndef BENDIMPL_H
+#define BENDIMPL_H
+
+#include <qpe/taskbarappletinterface.h>
+
+class BenD;
+
+class BenDImpl : public TaskbarAppletInterface
+{
+public:
+ BenDImpl();
+ virtual ~BenDImpl();
+
+ QRESULT queryInterface(const QUuid &uuid, QUnknownInterface **iface);
+ Q_REFCOUNT
+
+ virtual QWidget *applet(QWidget *parent);
+ virtual int position() const;
+
+private:
+ BenD *_benD;
+ ulong ref;
+
+};
+
+#endif
+