From 5cb277888995edecfafd83fed4cf2bd510052a4b Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 12 Apr 2020 00:45:32 +0200 Subject: port to qt5, libusb 1.0, and openobex 1.7 --- smartpenmanager.h | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'smartpenmanager.h') 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 -#include #include +#include #include +#include +#include #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 _syncers; + struct PenInfo { + Smartpen::Address addr; + bool connected = false; + QString name; + SmartpenSyncer *syncer = 0; + QDateTime nextTry; + uint numRetries = 0; + }; + + QMap _pens; + QTimer *_nextTry; }; #endif // SMARTPENMANAGER_H -- cgit v1.2.3