File indexing completed on 2024-09-15 04:48:48
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Alejandro Fiestas Olivares <alex@eyeos.org> 0003 * SPDX-FileCopyrightText: 2010 Eduardo Robles Elvira <edulix@gmail.com> 0004 * SPDX-FileCopyrightText: 2010 UFO Coders <info@ufocoders.com> 0005 * SPDX-FileCopyrightText: 2014-2015 David Rosca <nowrep@gmail.com> 0006 * 0007 * SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include <QMap> 0013 0014 #include <KDEDModule> 0015 0016 #include <BluezQt/Manager> 0017 #include <BluezQt/ObexManager> 0018 0019 typedef QMap<QString, QString> DeviceInfo; 0020 typedef QMap<QString, DeviceInfo> QMapDeviceInfo; 0021 0022 class Q_DECL_EXPORT BlueDevilDaemon : public KDEDModule 0023 { 0024 Q_OBJECT 0025 Q_CLASSINFO("D-Bus Interface", "org.kde.BlueDevil") 0026 0027 public: 0028 BlueDevilDaemon(QObject *parent, const QList<QVariant> &); 0029 ~BlueDevilDaemon() override; 0030 0031 /** 0032 * Returns whether the daemon is in online mode (eg. Bluez services are 0033 * running and we have usable adapter) 0034 */ 0035 Q_SCRIPTABLE bool isOnline(); 0036 0037 /** 0038 * Returns QMap<Address, DeviceInfo> with all known devices 0039 */ 0040 Q_SCRIPTABLE QMapDeviceInfo allDevices(); 0041 0042 /** 0043 * Returns DeviceInfo for one device. 0044 */ 0045 Q_SCRIPTABLE DeviceInfo device(const QString &address); 0046 0047 /** 0048 * Starts discovery for timeout miliseconds (0 = forever) 0049 */ 0050 Q_SCRIPTABLE void startDiscovering(quint32 timeout); 0051 0052 /** 0053 * Stops discovery (if it was previously started) 0054 */ 0055 Q_SCRIPTABLE void stopDiscovering(); 0056 0057 BluezQt::Manager *manager() const; 0058 BluezQt::ObexManager *obexManager() const; 0059 0060 private Q_SLOTS: 0061 void initJobResult(BluezQt::InitManagerJob *job); 0062 void initObexJobResult(BluezQt::InitObexManagerJob *job); 0063 0064 void operationalChanged(bool operational); 0065 void obexOperationalChanged(bool operational); 0066 0067 void agentRegisted(BluezQt::PendingCall *call); 0068 void agentRequestedDefault(BluezQt::PendingCall *call); 0069 void obexAgentRegistered(BluezQt::PendingCall *call); 0070 0071 private: 0072 DeviceInfo deviceToInfo(BluezQt::DevicePtr device) const; 0073 0074 private: 0075 struct Private; 0076 Private *const d; 0077 };