aboutsummaryrefslogtreecommitdiff
path: root/smartpen.h
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-06-07 21:22:45 +0200
committerJavier <dev.git@javispedro.com>2015-06-07 21:22:45 +0200
commita69e97943539a8abc4d2762638c169dc19c88516 (patch)
treef3516ea29745db65971247cee4c260b49f1067b2 /smartpen.h
downloadscribiu-a69e97943539a8abc4d2762638c169dc19c88516.tar.gz
scribiu-a69e97943539a8abc4d2762638c169dc19c88516.zip
initial import
Diffstat (limited to 'smartpen.h')
-rw-r--r--smartpen.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/smartpen.h b/smartpen.h
new file mode 100644
index 0000000..c93e016
--- /dev/null
+++ b/smartpen.h
@@ -0,0 +1,78 @@
+#ifndef SMARTPEN_H
+#define SMARTPEN_H
+
+#include <QtCore/QObject>
+#include <QtCore/QDateTime>
+#include <QtCore/QVariantMap>
+#include <openobex/obex.h>
+
+// TODO: These values are mostly random.
+#define SMARTPEN_DPI_X (800.0)
+#define SMARTPEN_DPI_Y (800.0)
+
+#define SMARTPEN_BLEED_X 333.3
+#define SMARTPEN_BLEED_Y 333.3
+
+class Smartpen : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit Smartpen(QObject *parent = 0);
+ ~Smartpen();
+
+ typedef QPair<int, int> Address;
+
+ bool isConnected() const;
+
+ enum Parameters {
+ PenName = 8011
+ };
+
+ QByteArray getObject(const QString& name);
+ QString getParameter(Parameters parameter);
+
+ QString getPenName();
+ QVariantMap getPenInfo();
+
+ struct ChangeReport {
+ QString guid;
+ QString title;
+ };
+
+ QList<ChangeReport> getChangeList(const QDateTime &from = QDateTime());
+
+ QByteArray getLspData(const QString &name, const QDateTime &from = QDateTime());
+ QByteArray getPaperReplay();
+
+ static qint64 toPenTime(const QDateTime &dt);
+ static QDateTime fromPenTime(qint64 t);
+
+ static QString toPenSerial(quint64 id);
+
+public slots:
+ bool connectToPen(const Address &addr);
+ void disconnectFromPen();
+
+signals:
+ void error();
+
+private:
+ static void obexEventCb(obex_t *handle, obex_object_t *obj,
+ int mode, int event, int obex_cmd, int obex_rsp);
+ void handleObexEvent(obex_object_t *object,
+ int event, int obex_cmd, int obex_rsp);
+ void handleObexRequestDone(obex_object_t *object, int obex_cmd, int obex_rsp);
+
+ static QString toPenSerialSegment(quint32 id, int len);
+
+ static QByteArray encodeUtf16(const QString &s);
+ void addConnHeader(obex_object_t *object) const;
+
+private:
+ obex_t * _obex;
+ quint32 _connId;
+ QByteArray _inBuf;
+};
+
+#endif // SMARTPEN_H