summaryrefslogtreecommitdiff
path: root/libsowatch
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-09-18 04:26:20 +0200
committerJavier S. Pedro <maemo@javispedro.com>2011-09-18 04:26:20 +0200
commitc42d5abff1f5f51facc169dd593725d819c4c868 (patch)
tree9aa8bdef88bf89561c7726948541a1ba3906b81e /libsowatch
parentf225345d4de3b198a557fe3566f9630163e76d51 (diff)
downloadsowatch-c42d5abff1f5f51facc169dd593725d819c4c868.tar.gz
sowatch-c42d5abff1f5f51facc169dd593725d819c4c868.zip
separation into lib and plugins complete
Diffstat (limited to 'libsowatch')
-rw-r--r--libsowatch/declarativewatchlet.h3
-rw-r--r--libsowatch/graphicswatchlet.h3
-rw-r--r--libsowatch/libsowatch.pro45
-rw-r--r--libsowatch/notification.cpp13
-rw-r--r--libsowatch/notification.h40
-rw-r--r--libsowatch/notificationplugininterface.cpp7
-rw-r--r--libsowatch/notificationplugininterface.h29
-rw-r--r--libsowatch/sowatch.h1
-rw-r--r--libsowatch/sowatch_global.h10
-rw-r--r--libsowatch/watch.cpp51
-rw-r--r--libsowatch/watch.h29
-rw-r--r--libsowatch/watchpaintengine.cpp48
-rw-r--r--libsowatch/watchpaintengine.h5
-rw-r--r--libsowatch/watchplugininterface.h8
-rw-r--r--libsowatch/watchserver.cpp5
-rw-r--r--libsowatch/watchserver.h9
-rw-r--r--libsowatch/watchsimulator.cpp4
-rw-r--r--libsowatch/watchsimulator.h2
18 files changed, 181 insertions, 131 deletions
diff --git a/libsowatch/declarativewatchlet.h b/libsowatch/declarativewatchlet.h
index 1e94007..ea31a33 100644
--- a/libsowatch/declarativewatchlet.h
+++ b/libsowatch/declarativewatchlet.h
@@ -5,13 +5,14 @@
#include <QtDeclarative/QDeclarativeComponent>
#include <QtDeclarative/QDeclarativeItem>
#include "graphicswatchlet.h"
+#include "sowatch_global.h"
namespace sowatch
{
class DeclarativeWatchWrapper;
-class DeclarativeWatchlet : public GraphicsWatchlet
+class SOWATCH_EXPORT DeclarativeWatchlet : public GraphicsWatchlet
{
Q_OBJECT
public:
diff --git a/libsowatch/graphicswatchlet.h b/libsowatch/graphicswatchlet.h
index 9754062..d2cbb37 100644
--- a/libsowatch/graphicswatchlet.h
+++ b/libsowatch/graphicswatchlet.h
@@ -4,11 +4,12 @@
#include <QtGui/QGraphicsScene>
#include <QtGui/QRegion>
#include "watchlet.h"
+#include "sowatch_global.h"
namespace sowatch
{
-class GraphicsWatchlet : public Watchlet
+class SOWATCH_EXPORT GraphicsWatchlet : public Watchlet
{
Q_OBJECT
public:
diff --git a/libsowatch/libsowatch.pro b/libsowatch/libsowatch.pro
index a5b4fd8..38d3389 100644
--- a/libsowatch/libsowatch.pro
+++ b/libsowatch/libsowatch.pro
@@ -4,12 +4,12 @@
#
#-------------------------------------------------
-QT += gui dbus declarative
+QT += gui declarative
CONFIG += mobility
-MOBILITY += connectivity
-TARGET = libsowatch
+TARGET = sowatch
TEMPLATE = lib
+VERSION = 1.0.0
DEFINES += SOWATCH_LIBRARY
@@ -24,7 +24,9 @@ SOURCES += \
graphicswatchlet.cpp \
declarativewatchwrapper.cpp \
declarativewatchlet.cpp \
- watchplugininterface.cpp
+ watchplugininterface.cpp \
+ notification.cpp \
+ notificationplugininterface.cpp
HEADERS +=\
watchsimulator.h \
@@ -39,24 +41,11 @@ HEADERS +=\
declarativewatchwrapper.h \
declarativewatchlet.h \
sowatch_global.h \
- watchplugininterface.h
-
-FORMS +=
-
-install_headers.files =\
- watchsimulator.h \
- watchserver.h \
- watchpaintengine.h \
- watchmanager.h \
- watchlet.h \
- watch.h \
- testwatchlet.h \
- testdeclarativewatchlet.h \
- sowatch.h \
- graphicswatchlet.h \
- declarativewatchwrapper.h \
- declarativewatchlet.h \
- sowatch_global.h
+ watchplugininterface.h \
+ notification.h \
+ notificationplugininterface.h
+
+install_headers.files = $$HEADERS
symbian {
MMP_RULES += EXPORTUNFROZEN
@@ -84,3 +73,15 @@ unix:!symbian {
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libsowatch/notification.cpp b/libsowatch/notification.cpp
new file mode 100644
index 0000000..55f3e78
--- /dev/null
+++ b/libsowatch/notification.cpp
@@ -0,0 +1,13 @@
+#include "notification.h"
+
+using namespace sowatch;
+
+Notification::Notification(Type type, const QDateTime& dateTime, QString title, QString body)
+ : _type(type), _dateTime(dateTime), _title(title), _body(body)
+{
+}
+
+Notification::~Notification()
+{
+
+}
diff --git a/libsowatch/notification.h b/libsowatch/notification.h
new file mode 100644
index 0000000..7f463bf
--- /dev/null
+++ b/libsowatch/notification.h
@@ -0,0 +1,40 @@
+#ifndef NOTIFICATION_H
+#define NOTIFICATION_H
+
+#include <QtCore/QString>
+#include <QtCore/QDateTime>
+#include "sowatch_global.h"
+
+namespace sowatch
+{
+
+class SOWATCH_EXPORT Notification
+{
+public:
+ enum Type {
+ OtherNotification = 0,
+ EmailNotification,
+ CallNotification,
+ SmsNotification,
+ ImNotification,
+ TypeCount
+ };
+
+ Notification(Type type, const QDateTime& dateTime, QString title, QString body);
+ ~Notification();
+
+ inline Type type() const { return _type; }
+ inline QDateTime dateTime() const { return _dateTime; }
+ inline QString title() const { return _title; }
+ inline QString body() const { return _body; }
+
+protected:
+ Type _type;
+ QDateTime _dateTime;
+ QString _title;
+ QString _body;
+};
+
+}
+
+#endif // NOTIFICATION_H
diff --git a/libsowatch/notificationplugininterface.cpp b/libsowatch/notificationplugininterface.cpp
new file mode 100644
index 0000000..e32060a
--- /dev/null
+++ b/libsowatch/notificationplugininterface.cpp
@@ -0,0 +1,7 @@
+#include "notificationplugininterface.h"
+
+using namespace sowatch;
+
+NotificationPluginInterface::~NotificationPluginInterface()
+{
+}
diff --git a/libsowatch/notificationplugininterface.h b/libsowatch/notificationplugininterface.h
new file mode 100644
index 0000000..1a312a1
--- /dev/null
+++ b/libsowatch/notificationplugininterface.h
@@ -0,0 +1,29 @@
+#ifndef NOTIFICATIONPLUGININTERFACE_H
+#define NOTIFICATIONPLUGININTERFACE_H
+
+#include <QtPlugin>
+#include "sowatch_global.h"
+#include "notification.h"
+
+namespace sowatch
+{
+
+class Notification;
+
+class SOWATCH_EXPORT NotificationPluginInterface
+{
+public:
+ virtual ~NotificationPluginInterface();
+
+ int getCount(Notification::Type type);
+
+signals:
+ void incomingNotification(const Notification& n);
+ void unreadCountChanged(Notification::Type type);
+};
+
+}
+
+Q_DECLARE_INTERFACE(sowatch::NotificationPluginInterface, "com.javispedro.sowatch.NotificationPluginInterface")
+
+#endif // NOTIFICATIONPLUGININTERFACE_H
diff --git a/libsowatch/sowatch.h b/libsowatch/sowatch.h
index 0463389..8c56954 100644
--- a/libsowatch/sowatch.h
+++ b/libsowatch/sowatch.h
@@ -6,6 +6,7 @@
#include "watchlet.h"
#include "graphicswatchlet.h"
#include "declarativewatchlet.h"
+#include "notification.h"
#include "watchserver.h"
#include "watchsimulator.h"
#include "watchplugininterface.h"
diff --git a/libsowatch/sowatch_global.h b/libsowatch/sowatch_global.h
index a3b40e6..977bd53 100644
--- a/libsowatch/sowatch_global.h
+++ b/libsowatch/sowatch_global.h
@@ -9,4 +9,14 @@
# define SOWATCH_EXPORT Q_DECL_IMPORT
#endif
+#if defined(Q_WS_MAEMO_5)
+# define SOWATCH_DRIVERS_DIR "/opt/sowatch/drivers"
+# define SOWATCH_NOTIFICATIONS_DIR "/opt/sowatch/notifications"
+# define SOWATCH_WATCHLETS_DIR "/opt/sowatch/watchlets"
+#elif defined(Q_OS_LINUX)
+# define SOWATCH_DRIVERS_DIR "/usr/lib/sowatch/drivers"
+# define SOWATCH_NOTIFICATIONS_DIR "/usr/lib/sowatch/notifications"
+# define SOWATCH_WATCHLETS_DIR "/usr/lib/sowatch/watchlets"
+#endif
+
#endif // SOWATCH_GLOBAL_H
diff --git a/libsowatch/watch.cpp b/libsowatch/watch.cpp
index e8da790..7792693 100644
--- a/libsowatch/watch.cpp
+++ b/libsowatch/watch.cpp
@@ -3,60 +3,13 @@
using namespace sowatch;
-Watch::Watch(const QImage& image, QObject* parent) :
- QObject(parent), _image(image), _paintEngine(0)
+Watch::Watch(QObject* parent) :
+ QObject(parent)
{
}
Watch::~Watch()
{
- if (_paintEngine) {
- delete _paintEngine;
- }
-}
-
-QPaintEngine* Watch::paintEngine() const
-{
- if (!_paintEngine) {
- _paintEngine = new WatchPaintEngine(const_cast<Watch*>(this),
- const_cast<QImage*>(&_image));
- }
-
- return _paintEngine;
-}
-int Watch::metric(PaintDeviceMetric metric) const
-{
- switch (metric) {
- case PdmWidth:
- return _image.width();
- case PdmHeight:
- return _image.height();
- case PdmWidthMM:
- return _image.widthMM();
- case PdmHeightMM:
- return _image.heightMM();
- case PdmNumColors:
- return _image.numColors();
- case PdmDepth:
- return _image.depth();
- case PdmDpiX:
- return _image.logicalDpiX();
- case PdmDpiY:
- return _image.logicalDpiY();
- case PdmPhysicalDpiX:
- return _image.physicalDpiX();
- case PdmPhysicalDpiY:
- return _image.physicalDpiY();
- }
-
- return -1;
-}
-
-void Watch::update(const QRect &rect)
-{
- QList<QRect> rects;
- rects << rect;
- update(rects);
}
diff --git a/libsowatch/watch.h b/libsowatch/watch.h
index 3581ada..056bfe0 100644
--- a/libsowatch/watch.h
+++ b/libsowatch/watch.h
@@ -2,8 +2,10 @@
#define WATCH_H
#include <QtCore/QObject>
+#include <QtCore/QDateTime>
#include <QtGui/QPaintDevice>
#include <QtGui/QImage>
+#include "notification.h"
namespace sowatch
{
@@ -13,18 +15,22 @@ class Watch : public QObject, public QPaintDevice
Q_OBJECT
Q_PROPERTY(QString model READ model)
Q_PROPERTY(bool connected READ isConnected)
+ Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime)
+
public:
- explicit Watch(const QImage& image, QObject* parent = 0);
+ explicit Watch(QObject* parent = 0);
~Watch();
- QPaintEngine* paintEngine() const;
- int metric(PaintDeviceMetric metric) const;
-
- Q_INVOKABLE virtual QString model() const = 0;
- Q_INVOKABLE virtual bool isConnected() const = 0;
+ virtual QString model() const = 0;
+ virtual bool isConnected() const = 0;
/** Indicates if watch is too busy atm and we should limit frame rate. */
- Q_INVOKABLE virtual bool busy() const = 0;
+ virtual bool busy() const = 0;
+
+ virtual QDateTime dateTime() = 0;
+ virtual void setDateTime(const QDateTime& dateTime) = 0;
+
+ virtual void updateNotificationCount(Notification::Type type, int count) = 0;
signals:
void connected();
@@ -33,15 +39,8 @@ signals:
void buttonReleased(int button);
public slots:
- virtual void update(const QList<QRect>& rects) = 0;
- virtual void update(const QRect& rect);
virtual void vibrate(bool on) = 0;
-
-protected:
- QImage _image;
- mutable QPaintEngine* _paintEngine;
-
-friend class WatchPaintEngine;
+ virtual void showNotification(const Notification& n) = 0;
};
}
diff --git a/libsowatch/watchpaintengine.cpp b/libsowatch/watchpaintengine.cpp
index 18cfb60..6c509cb 100644
--- a/libsowatch/watchpaintengine.cpp
+++ b/libsowatch/watchpaintengine.cpp
@@ -6,29 +6,12 @@
using namespace sowatch;
-WatchPaintEngine::WatchPaintEngine(Watch* watch, QImage* image)
+WatchPaintEngine::WatchPaintEngine(Watch* watch)
: QPaintEngine(QPaintEngine::AllFeatures),
_watch(watch), _painter(),
_hasPen(false), _hasBrush(false), _clipEnabled(false)
{
- Q_UNUSED(image);
-}
-
-bool WatchPaintEngine::begin(QPaintDevice *pdev)
-{
- _damaged = QRegion();
- _watch = static_cast<Watch*>(pdev);
-
- return _painter.begin(&_watch->_image);
-}
-bool WatchPaintEngine::end()
-{
- bool ret = _painter.end();
- if (ret) {
- _watch->update(_damaged.rects().toList());
- }
- return ret;
}
void WatchPaintEngine::damageMappedRect(const QRect &r)
@@ -47,7 +30,7 @@ void WatchPaintEngine::damageRect(const QRect &r)
void WatchPaintEngine::damageRect(const QRectF &r)
{
- damageMappedRect(_transform.mapRect(r).toRect());
+ damageMappedRect(_transform.mapRect(r).toAlignedRect());
}
void WatchPaintEngine::damagePenStroke(const QLineF &line)
@@ -57,13 +40,16 @@ void WatchPaintEngine::damagePenStroke(const QLineF &line)
const qreal a = line.angle();
const qreal sn = sinf(a);
const qreal cs = cosf(a);
- const qreal w = _penWidth = 0.0 ? 1.0 : _penWidth;
+ const qreal w = _penWidth == 0.0 ? 1.0 : _penWidth;
const qreal x1 = line.x1();
const qreal x2 = line.x2();
- const qreal y1 = line.x1();
+ const qreal y1 = line.y1();
const qreal y2 = line.y2();
- damageRect(QRectF(x1-(w*sn/2.0f), y1+(w*cs/2.0f), x2+(w*sn/2.0f), y2-(w*cs/2.0f)).normalized());
+ QPointF p1(x1-(w*sn/2.0f), y1+(w*cs/2.0f));
+ QPointF p2(x2+(w*sn/2.0f), y2-(w*cs/2.0f));
+ QRectF r = QRectF(p1, p2).normalized();
+ damageRect(r);
}
void WatchPaintEngine::updateClipRegion(const QRegion& region, Qt::ClipOperation op)
@@ -140,24 +126,22 @@ void WatchPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRec
void WatchPaintEngine::drawPoints(const QPointF *points, int pointCount)
{
- const qreal penWidth = _painter.pen().widthF();
int i;
for (i = 0; i < pointCount; i++) {
const QPointF& p = points[i];
- damageRect(QRect(p.x() - penWidth/2, p.y() - penWidth/2,
- p.x() + penWidth/2, p.y() + penWidth/2));
+ damageRect(QRectF(p.x() - _penWidth/2.0f, p.y() - _penWidth/2.0f,
+ _penWidth, _penWidth));
}
_painter.drawPoints(points, pointCount);
}
void WatchPaintEngine::drawPoints(const QPoint *points, int pointCount)
{
- const qreal penWidth = _painter.pen().widthF();
int i;
for (i = 0; i < pointCount; i++) {
const QPoint& p = points[i];
- damageRect(QRect(p.x() - penWidth/2, p.y() - penWidth/2,
- p.x() + penWidth/2, p.y() + penWidth/2));
+ damageRect(QRect(p.x() - _penWidth/2, p.y() - _penWidth/2,
+ _penWidth, _penWidth));
}
_painter.drawPoints(points, pointCount);
}
@@ -225,8 +209,10 @@ void WatchPaintEngine::drawRects(const QRect *rects, int rectCount)
void WatchPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
{
- const qreal height = textItem.ascent() + textItem.descent();
- damageRect(QRect(p.x(), p.y(), p.x() + textItem.width(), p.y() + height));
+ const qreal ascent = textItem.ascent();
+ const qreal descent = textItem.descent();
+ const qreal w = textItem.width();
+ damageRect(QRect(p.x(), p.y() - ascent, w, ascent + descent));
_painter.drawTextItem(p, textItem);
}
@@ -269,7 +255,7 @@ void WatchPaintEngine::updateState(const QPaintEngineState &state)
}
if (flags & QPaintEngine::DirtyClipPath)
{
- QRegion region = state.clipPath().boundingRect().toRect();
+ QRegion region = state.clipPath().boundingRect().toAlignedRect();
updateClipRegion(region, state.clipOperation());
_painter.setClipPath(state.clipPath(), state.clipOperation());
}
diff --git a/libsowatch/watchpaintengine.h b/libsowatch/watchpaintengine.h
index 14181fa..14d8f61 100644
--- a/libsowatch/watchpaintengine.h
+++ b/libsowatch/watchpaintengine.h
@@ -11,10 +11,7 @@ class Watch;
class WatchPaintEngine : public QPaintEngine
{
public:
- WatchPaintEngine(Watch* watch, QImage* image);
-
- bool begin(QPaintDevice *pdev);
- bool end();
+ WatchPaintEngine(Watch* watch);
void drawEllipse(const QRectF &r);
void drawEllipse(const QRect &r);
diff --git a/libsowatch/watchplugininterface.h b/libsowatch/watchplugininterface.h
index 6b32385..e360dea 100644
--- a/libsowatch/watchplugininterface.h
+++ b/libsowatch/watchplugininterface.h
@@ -1,21 +1,23 @@
#ifndef WATCHPLUGININTERFACE_H
#define WATCHPLUGININTERFACE_H
-#include <QtCore/QObject>
+#include <QtPlugin>
+#include <QtCore/QSettings>
#include <QtCore/QStringList>
+#include "sowatch_global.h"
namespace sowatch
{
class Watch;
-class WatchPluginInterface
+class SOWATCH_EXPORT WatchPluginInterface
{
public:
virtual ~WatchPluginInterface();
virtual QStringList drivers() = 0;
- virtual Watch* getWatch(const QString& driver, const QString& connId, QObject *parent = 0) = 0;
+ virtual Watch* getWatch(const QString& driver, QSettings& settings, QObject *parent = 0) = 0;
};
}
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index ad49995..5ee8a90 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -36,6 +36,11 @@ void WatchServer::closeWatchlet()
_currentWatchlet = 0;
}
+void WatchServer::notification(const Notification &n)
+{
+ Q_UNUSED(n);
+}
+
void WatchServer::registerWatchlet(Watchlet *watchlet)
{
Q_ASSERT(watchlet->_server == this);
diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h
index 78454d4..f8bed67 100644
--- a/libsowatch/watchserver.h
+++ b/libsowatch/watchserver.h
@@ -4,16 +4,20 @@
#include <QtCore/QObject>
#include <QtCore/QMap>
+#include "sowatch_global.h"
+
namespace sowatch
{
class Watch;
class Watchlet;
+class Notification;
-class WatchServer : public QObject
+class SOWATCH_EXPORT WatchServer : public QObject
{
Q_OBJECT
- Q_PROPERTY(Watch* watch READ watch)
+ Q_PROPERTY(Watch* watch READ watch CONSTANT)
+
public:
explicit WatchServer(Watch* watch, QObject* parent = 0);
@@ -25,6 +29,7 @@ public:
signals:
public slots:
+ void notification(const Notification& n);
protected:
Watch* _watch;
diff --git a/libsowatch/watchsimulator.cpp b/libsowatch/watchsimulator.cpp
index 464f3a5..47496f2 100644
--- a/libsowatch/watchsimulator.cpp
+++ b/libsowatch/watchsimulator.cpp
@@ -4,8 +4,8 @@
using namespace sowatch;
-WatchSimulator::WatchSimulator(const QImage& image, QObject* parent) :
- Watch(image, parent)
+WatchSimulator::WatchSimulator(QObject* parent) :
+ Watch(parent)
{
}
diff --git a/libsowatch/watchsimulator.h b/libsowatch/watchsimulator.h
index 564118c..aa8586d 100644
--- a/libsowatch/watchsimulator.h
+++ b/libsowatch/watchsimulator.h
@@ -12,7 +12,7 @@ class WatchSimulator : public Watch
{
Q_OBJECT
public:
- explicit WatchSimulator(const QImage& image, QObject *parent = 0);
+ explicit WatchSimulator(QObject *parent = 0);
};
}