aboutsummaryrefslogtreecommitdiff
path: root/smartpenmanager.h
diff options
context:
space:
mode:
Diffstat (limited to 'smartpenmanager.h')
-rw-r--r--smartpenmanager.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/smartpenmanager.h b/smartpenmanager.h
index 42bdc06..a823709 100644
--- a/smartpenmanager.h
+++ b/smartpenmanager.h
@@ -19,10 +19,11 @@
#ifndef SMARTPENMANAGER_H
#define SMARTPENMANAGER_H
-#include <QtCore/QObject>
-#include <QtCore/QSocketNotifier>
#include <QtCore/QMap>
+#include <QtCore/QObject>
#include <QtCore/QPair>
+#include <QtCore/QSocketNotifier>
+#include <QtCore/QTimer>
#include "smartpensyncer.h"
struct udev;
@@ -37,28 +38,46 @@ public:
explicit SmartpenManager(QObject *parent = 0);
~SmartpenManager();
+ QStringList pensConnected() const;
QStringList pensBeingSynchronized() const;
signals:
void syncComplete(const QString &penName);
void syncFailed(const QString &penName);
+ void pensConnectedChanged();
void pensBeingSynchronizedChanged();
-public slots:
-
private slots:
void handleMonitorActivity();
void handleSyncerFinished();
+ void handleGotPenName(const QString &name);
+ void handleTimerNextTry();
private:
- void processDevice(udev_device *dev);
+ void processDeviceAdded(udev_device *dev);
+ void processDeviceRemoved(udev_device *dev);
+
+ void trySync(const Smartpen::Address &addr);
+ void scheduleNextTry();
+
+ static QString parseUdevEscapedString(const char *s);
private:
udev *_udev;
udev_monitor *_monitor;
QSocketNotifier *_notifier;
- QMap<Smartpen::Address, SmartpenSyncer*> _syncers;
+ struct PenInfo {
+ Smartpen::Address addr;
+ bool connected = false;
+ QString name;
+ SmartpenSyncer *syncer = 0;
+ QDateTime nextTry;
+ uint numRetries = 0;
+ };
+
+ QMap<Smartpen::Address, PenInfo> _pens;
+ QTimer *_nextTry;
};
#endif // SMARTPENMANAGER_H