not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / libs / solid / control / backends / fakebluetooth / fakebluetoothinterface.cpp
blobbc5de8768a803016c28359be940f3e8c64aaac35
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 #include <QStringList>
22 #include <QTimer>
24 #include "fakebluetoothinterface.h"
25 #include "fakebluetoothremotedevice.h"
27 #include <kdebug.h>
29 FakeBluetoothInterface::FakeBluetoothInterface(const QMap<QString, QVariant> & propertyMap, QObject * parent)
30 : Solid::Control::Ifaces::BluetoothInterface(parent), mPropertyMap(propertyMap)
32 mAddress = mPropertyMap["address"].toString();
33 mVersion = mPropertyMap["version"].toString();
34 mRevision = mPropertyMap["revision"].toString();
35 mManufacturer = mPropertyMap["manufacturer"].toString();
36 mCompany = mPropertyMap["company"].toString();
37 mMode = (Solid::Control::BluetoothInterface::Mode) mPropertyMap["mode"].toInt();
38 mDiscoverableTimeout = mPropertyMap["discoverableTimeout"].toInt();
39 mDiscoverable = mPropertyMap["isDiscoverable"].toBool();
40 mConnections.append(mPropertyMap["connections"].toString());
41 mMajorClass = mPropertyMap["majorClass"].toString();
42 mMinorClasses.append(mPropertyMap["minorClasses"].toString());
43 mMinorClass = mPropertyMap["minorClass"].toString();
44 mServiceClasses.append(mPropertyMap["serviceClasses"].toString());
45 mName = mPropertyMap["name"].toString();
46 mBondings.append(mPropertyMap["bondings"].toString());
47 mPeriodicDiscovery = mPropertyMap["isPeriodicDiscovery"].toBool();
48 mPeriodicDiscoveryNameResolving = mPropertyMap["periodicDiscoveryNameResolving"].toBool();
49 mRemoteDevices.append(mPropertyMap["remoteDevices"].toString());
50 mRecentRemoteDevices.append(mPropertyMap["recentRemoteDevices"].toString());
52 mUbi = mPropertyMap["ubi"].toString();
55 FakeBluetoothInterface::~FakeBluetoothInterface()
57 foreach (FakeBluetoothRemoteDevice *device, mBluetoothRemoteDevices) {
58 kDebug() << "DEVICE: " << device->ubi();
59 delete device;
62 mBluetoothRemoteDevices.clear();
65 QObject * FakeBluetoothInterface::createBluetoothRemoteDevice(const QString & ubi)
67 if (mBluetoothRemoteDevices.contains(ubi)) {
68 kDebug() << "found " << ubi;
69 return mBluetoothRemoteDevices[ubi];
70 } else {
71 kDebug() << "NOT found " << ubi;
72 return 0;
76 QStringList FakeBluetoothInterface::bluetoothRemoteDevices() const
78 kDebug() ;
79 return mBluetoothRemoteDevices.keys();
82 void FakeBluetoothInterface::discoverDevices()
84 kDebug() ;
85 QTimer::singleShot(1000, this,
86 SIGNAL(remoteDeviceFound(QString("/org/kde/solid/fakebluetooth/hci0/EE:EE:EE:EE:EE:EE"),
87 0, 99)));
88 QTimer::singleShot(5000, this,
89 SIGNAL(remoteDeviceFound(QString("/org/kde/solid/fakebluetooth/hci0/EE:FF:EE:FF:EE:FF"),
90 0, 42)));
94 /*************************************/
96 void FakeBluetoothInterface::injectDevice(const QString &ubi , FakeBluetoothRemoteDevice *device)
98 mBluetoothRemoteDevices.insert(ubi, device);
101 #include "fakebluetoothinterface.moc"