File indexing completed on 2024-05-12 05:36:52

0001 /*
0002  * SPDX-FileCopyrightText: 2018-2019 Daniel Vrátil <dvratil@kde.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef KDED_BOLT_H
0008 #define KDED_BOLT_H
0009 
0010 #include "manager.h"
0011 
0012 #include <kdedmodule.h>
0013 
0014 #include <QList>
0015 #include <QMap>
0016 #include <QSharedPointer>
0017 #include <QTimer>
0018 
0019 class KNotification;
0020 namespace Bolt
0021 {
0022 class Device;
0023 }
0024 
0025 class Q_DECL_EXPORT KDEDBolt : public KDEDModule
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     using BoltDeviceList = QList<QSharedPointer<Bolt::Device>>;
0031 
0032     KDEDBolt(QObject *parent, const QVariantList &args);
0033     ~KDEDBolt() override;
0034 
0035 protected:
0036     virtual void notify();
0037 
0038     BoltDeviceList sortDevices(const BoltDeviceList &devices);
0039 
0040 private:
0041     enum AuthMode {
0042         Enroll,
0043         Authorize,
0044     };
0045     void authorizeDevices(BoltDeviceList devices, AuthMode mode);
0046 
0047 protected:
0048     Bolt::Manager mManager;
0049     BoltDeviceList mPendingDevices;
0050     QMap<KNotification *, BoltDeviceList> mNotifiedDevices;
0051     QTimer mPendingDeviceTimer;
0052 };
0053 
0054 #endif // KDED_BOLT_H