1 /* This file is part of the KDE project
2 Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
21 #ifndef FAKE_BLUETOOTH_INTERFACE_H
22 #define FAKE_BLUETOOTH_INTERFACE_H
29 #include <kdemacros.h>
31 #include <solid/control/ifaces/bluetoothinterface.h>
33 #include "fakebluetoothremotedevice.h"
35 using namespace Solid::Control::Ifaces
;
37 class KDE_EXPORT FakeBluetoothInterface
: public Solid::Control::Ifaces::BluetoothInterface
39 friend class FakeBluetoothManager
;
41 Q_INTERFACES(Solid::Control::Ifaces::BluetoothInterface
)
43 FakeBluetoothInterface(const QMap
<QString
, QVariant
> & propertyMap
,
45 virtual ~FakeBluetoothInterface();
47 QObject
* createBluetoothRemoteDevice(const QString
& ubi
);
48 QStringList
bluetoothRemoteDevices() const;
55 QString
address() const
57 kDebug() ; return mAddress
;
59 QString
version() const
63 QString
revision() const
67 QString
manufacturer() const
71 QString
company() const
75 Solid::Control::BluetoothInterface::Mode
mode() const
79 int discoverableTimeout() const
81 return mDiscoverableTimeout
;
83 bool isDiscoverable() const
87 QStringList
listConnections() const
91 QString
majorClass() const
95 QStringList
listAvailableMinorClasses() const
99 QString
minorClass() const
103 QStringList
serviceClasses() const
105 return mServiceClasses
;
111 QString
getRemoteName(const QString
&)
115 QStringList
listBondings() const
119 bool isPeriodicDiscoveryActive() const
121 return mPeriodicDiscovery
;
123 bool isPeriodicDiscoveryNameResolvingActive() const
125 return mPeriodicDiscoveryNameResolving
;
127 QStringList
listRemoteDevices() const
129 return mRemoteDevices
;
131 QStringList
listRecentRemoteDevices(const QDateTime
&) const
133 return mRecentRemoteDevices
;
135 bool isTrusted(const QString
& mac
)
140 void injectDevice(const QString
&, FakeBluetoothRemoteDevice
*);
148 QString mManufacturer
;
150 Solid::Control::BluetoothInterface::Mode mMode
;
151 int mDiscoverableTimeout
;
153 QStringList mConnections
;
155 QStringList mMinorClasses
;
157 QStringList mServiceClasses
;
158 QStringList mBondings
;
159 bool mPeriodicDiscovery
;
160 bool mPeriodicDiscoveryNameResolving
;
161 QStringList mRemoteDevices
;
162 QStringList mRecentRemoteDevices
;
164 QString mRemoveTrust
;
168 void setMode(const Solid::Control::BluetoothInterface::Mode mode
)
170 mMode
= mode
; /* emit modeChanged(mMode); */
172 void setDiscoverableTimeout(int timeout
)
176 void setMinorClass(const QString
&minorClass
)
178 mMinorClass
= minorClass
;
180 void setName(const QString
&name
)
184 void discoverDevices();
185 void discoverDevicesWithoutNameResolving()
187 void cancelDiscovery()
189 void startPeriodicDiscovery()
191 void stopPeriodicDiscovery()
193 void setPeriodicDiscoveryNameResolving(bool resolving
)
195 mPeriodicDiscoveryNameResolving
= resolving
;
197 void setTrusted(const QString
& mac
)
201 void removeTrust(const QString
& mac
)
207 void modeChanged(Solid::Control::BluetoothInterface::Mode mode
);
208 void discoverableTimeoutChanged(int timeout
);
209 void minorClassChanged(const QString
&minor
);
210 void nameChanged(const QString
&name
);
211 void discoveryStarted();
212 void discoveryCompleted();
213 void remoteDeviceFound(const QString
&ubi
, int deviceClass
, int rssi
);
214 void remoteDeviceDisappeared(const QString
&ubi
);
216 void remoteNameUpdated(const QString
&address
, const QString
&name
);
217 void remoteDeviceConnected(const QString
&address
);
218 void remoteDeviceDisconnected(const QString
&address
);
219 void trustAdded(const QString
&address
);
220 void trustRemoved(const QString
&address
);
221 void bondingCreated(const QString
&address
);
222 void bondingRemoved(const QString
&address
);
224 /* These methods are operations that are carried out by the manager
225 In a real backend they would be events coming up from the network layer */
226 void injectBluetooth(const QString
& ubi
, FakeBluetoothRemoteDevice
* device
);
227 QMap
<QString
, FakeBluetoothRemoteDevice
*> mBluetoothRemoteDevices
;
228 QMap
<QString
, QVariant
> mPropertyMap
;