File indexing completed on 2024-04-28 15:17:54

0001 /*
0002  * BluezQt - Asynchronous Bluez wrapper library
0003  *
0004  * SPDX-FileCopyrightText: 2014 David Rosca <nowrep@gmail.com>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #ifndef BLUEZQT_MANAGER_P_H
0010 #define BLUEZQT_MANAGER_P_H
0011 
0012 #include <QDBusContext>
0013 #include <QHash>
0014 #include <QObject>
0015 
0016 #include "bluezagentmanager1.h"
0017 #include "bluezprofilemanager1.h"
0018 #include "dbusobjectmanager.h"
0019 #include "rfkill.h"
0020 #include "types.h"
0021 
0022 namespace BluezQt
0023 {
0024 typedef org::freedesktop::DBus::ObjectManager DBusObjectManager;
0025 typedef org::bluez::AgentManager1 BluezAgentManager;
0026 typedef org::bluez::ProfileManager1 BluezProfileManager;
0027 
0028 class Manager;
0029 class Adapter;
0030 class Device;
0031 class AdapterPrivate;
0032 
0033 class ManagerPrivate : public QObject, protected QDBusContext
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038     explicit ManagerPrivate(Manager *parent);
0039 
0040     void init();
0041     void nameHasOwnerFinished(QDBusPendingCallWatcher *watcher);
0042     void load();
0043     void getManagedObjectsFinished(QDBusPendingCallWatcher *watcher);
0044     void clear();
0045 
0046     AdapterPtr findUsableAdapter() const;
0047 
0048     void serviceRegistered();
0049     void serviceUnregistered();
0050     void interfacesAdded(const QDBusObjectPath &objectPath, const QVariantMapMap &interfaces);
0051     void interfacesRemoved(const QDBusObjectPath &objectPath, const QStringList &interfaces);
0052     void adapterRemoved(const AdapterPtr &adapter);
0053     void adapterPoweredChanged(bool powered);
0054     void rfkillStateChanged(Rfkill::State state);
0055 
0056     void addAdapter(const QString &adapterPath, const QVariantMap &properties);
0057     void addDevice(const QString &devicePath, const QVariantMap &properties);
0058     void removeAdapter(const QString &adapterPath);
0059     void removeDevice(const QString &devicePath);
0060 
0061     bool rfkillBlocked() const;
0062     void setUsableAdapter(const AdapterPtr &adapter);
0063 
0064     Manager *q;
0065     Rfkill *m_rfkill;
0066     DBusObjectManager *m_dbusObjectManager;
0067     BluezAgentManager *m_bluezAgentManager;
0068     BluezProfileManager *m_bluezProfileManager;
0069 
0070     QHash<QString, AdapterPtr> m_adapters;
0071     QHash<QString, DevicePtr> m_devices;
0072     AdapterPtr m_usableAdapter;
0073 
0074     bool m_initialized;
0075     bool m_bluezRunning;
0076     bool m_loaded;
0077     bool m_adaptersLoaded;
0078     bool m_bluetoothBlocked;
0079 
0080 Q_SIGNALS:
0081     void initError(const QString &errorText);
0082     void initFinished();
0083 
0084 private Q_SLOTS:
0085     void propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated);
0086     void dummy();
0087 };
0088 
0089 } // namespace BluezQt
0090 
0091 #endif // BLUEZQT_MANAGER_P_H