File indexing completed on 2024-04-28 16:43:20
0001 /* This file is part of the KDE libraries 0002 0003 SPDX-FileCopyrightText: 2010 Eduardo Robles Elvira <edulix@gmail.com> 0004 SPDX-FileCopyrightText: 2010 Rafael Fernández López <ereslibre@kde.org> 0005 SPDX-FileCopyrightText: 2010 UFO Coders <info@ufocoders.com> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #ifndef KIOBLUETOOTH_H 0011 #define KIOBLUETOOTH_H 0012 0013 #include "kdedbluedevil.h" 0014 0015 #include <QLoggingCategory> 0016 #include <QObject> 0017 #include <QUrl> 0018 0019 #include <kio/slavebase.h> 0020 0021 /** 0022 * @short This class implements a bluetooth kioslave that list devices and their services. 0023 */ 0024 class KioBluetoothPrivate; 0025 0026 class KioBluetooth : public QObject, public KIO::SlaveBase 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 KioBluetooth(const QByteArray &pool, const QByteArray &app); 0032 0033 struct Service { 0034 QString name; 0035 QString icon; 0036 QString mimetype; 0037 QString uuid; 0038 }; 0039 0040 /** 0041 * As our kio does not perform any service action, but just list devices and their services, the 0042 * get function shall not do much other than setting a mimetype and returning some data that 0043 * could be useful for the mimetype handler. 0044 */ 0045 void get(const QUrl &url) override; 0046 0047 /** 0048 * List current directory. There are two types of current directories in this kio: 0049 * 0050 * 1. First type, is the root dir, bluetooth:/. This directory is unique, and lists the remote 0051 * devices that our default bluetooth adapter sees. 0052 * 2. Remote device directory (something like bluetoth:/00_12_34_56_6d_34). This directory lists 0053 * the services provided by the given remote device. 0054 */ 0055 void listDir(const QUrl &url) override; 0056 0057 void stat(const QUrl &url) override; 0058 0059 /** 0060 * As at the momento we don't handle more than one level url paths, @p setHost has not much 0061 * difference with @p listDir 0062 * 0063 */ 0064 void setHost(const QString &hostname, quint16 port, const QString &user, const QString &pass) override; 0065 0066 /** 0067 * Returns a list of supported service names corresponding to the given uuids list. If an uuid is 0068 * not found in the uuids list, it is not added to the list of service names. 0069 */ 0070 QList<Service> getSupportedServices(const QStringList &uuids); 0071 0072 /** 0073 * Called by @p Bluetooth::listDir to create a "Received Files" folder entry. 0074 */ 0075 void listDownload(); 0076 0077 /** 0078 * Called by @p Bluetooth::listDir when listing root dir, bluetooth:/. 0079 */ 0080 void listDevices(); 0081 0082 /** 0083 * Called by @p Bluetooth::listDir when listing a remote device (something like 0084 * bluetoth:/00_12_34_56_6d_34) services. 0085 */ 0086 void listRemoteDeviceServices(); 0087 0088 public Q_SLOTS: 0089 void listDevice(const DeviceInfo device); 0090 0091 private: 0092 /** 0093 * This is set to true when @p setHost is called to list a given remote device, like for example 0094 * 00:2a:5E:8e:6e:f5. If listing the remote devices (bluetooth:/ uri), it's set back to false. 0095 */ 0096 bool m_hasCurrentHost; 0097 0098 /** 0099 * This is set in @p setHost when it's called to list a given remote device like for example 0100 * 00:2a:5E:8e:6e:f5. We don't directly set @p currentHost in @p setHost because libbludevil might not 0101 * have ready the remote bluetooth device yet ready at that time (it.s being created by the call 0102 * to @p Solid::Control::BluetoothDevice::createBluetoothRemoteDevice . 0103 */ 0104 QString m_currentHostname; 0105 0106 /** 0107 * Uppercase colon separated address (ex. 00:2A:5E:8E:6E:F5) 0108 */ 0109 QString m_currentHostAddress; 0110 0111 /** 0112 * This is an array containing as key the uuid and as value the name of the service that the 0113 * given uuid represents, and a representative icon. It only contains the supported service names. 0114 */ 0115 QMap<QString, Service> m_supportedServices; 0116 0117 /** 0118 * KDED DBus interface, used to communicate to the daemon since we need some status (like connected) 0119 */ 0120 org::kde::BlueDevil *m_kded; 0121 }; 0122 0123 Q_DECLARE_LOGGING_CATEGORY(BLUETOOTH) 0124 0125 #endif // KIOBLUETOOTH_H