not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / libs / solid / control / backends / fakebluetooth / fakebluetoothinterface.h
blobf7aa0c3b108f1f9fbb6084f8b9359935cb0a5d8c
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
24 #include <QString>
25 #include <QVariant>
27 #include <kdebug.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;
40 Q_OBJECT
41 Q_INTERFACES(Solid::Control::Ifaces::BluetoothInterface)
42 public:
43 FakeBluetoothInterface(const QMap<QString, QVariant> & propertyMap,
44 QObject *parent = 0);
45 virtual ~FakeBluetoothInterface();
47 QObject * createBluetoothRemoteDevice(const QString & ubi);
48 QStringList bluetoothRemoteDevices() const;
50 QString ubi() const
52 return mUbi;
55 QString address() const
57 kDebug() ; return mAddress;
59 QString version() const
61 return mVersion;
63 QString revision() const
65 return mRevision;
67 QString manufacturer() const
69 return mManufacturer;
71 QString company() const
73 return mCompany;
75 Solid::Control::BluetoothInterface::Mode mode() const
77 return mMode;
79 int discoverableTimeout() const
81 return mDiscoverableTimeout;
83 bool isDiscoverable() const
85 return mDiscoverable;
87 QStringList listConnections() const
89 return mConnections;
91 QString majorClass() const
93 return mMajorClass;
95 QStringList listAvailableMinorClasses() const
97 return mMinorClasses;
99 QString minorClass() const
101 return mMinorClass;
103 QStringList serviceClasses() const
105 return mServiceClasses;
107 QString name() const
109 return mName;
111 QString getRemoteName(const QString &)
113 return "";
115 QStringList listBondings() const
117 return mBondings;
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)
137 return true;
140 void injectDevice(const QString &, FakeBluetoothRemoteDevice *);
141 private:
142 int mTimeout;
143 QString mName;
144 QString mUbi;
145 QString mAddress;
146 QString mVersion;
147 QString mRevision;
148 QString mManufacturer;
149 QString mCompany;
150 Solid::Control::BluetoothInterface::Mode mMode;
151 int mDiscoverableTimeout;
152 bool mDiscoverable;
153 QStringList mConnections;
154 QString mMajorClass;
155 QStringList mMinorClasses;
156 QString mMinorClass;
157 QStringList mServiceClasses;
158 QStringList mBondings;
159 bool mPeriodicDiscovery;
160 bool mPeriodicDiscoveryNameResolving;
161 QStringList mRemoteDevices;
162 QStringList mRecentRemoteDevices;
163 QString mSetTrusted;
164 QString mRemoveTrust;
167 public Q_SLOTS:
168 void setMode(const Solid::Control::BluetoothInterface::Mode mode)
170 mMode = mode; /* emit modeChanged(mMode); */
172 void setDiscoverableTimeout(int timeout)
174 mTimeout = timeout;
176 void setMinorClass(const QString &minorClass)
178 mMinorClass = minorClass;
180 void setName(const QString &name)
182 mName = 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)
199 mSetTrusted = mac;
201 void removeTrust(const QString& mac)
203 mRemoveTrust = mac;
206 Q_SIGNALS:
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);
223 protected:
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;
231 #endif