1 /* This file is part of the KDE project
2 Copyright (C) 2006 Will Stephenson <wstephenson@kde.org>
3 Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
4 Copyright (C) 2008 Tom Patzig <tpatzig@suse.de>
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License version 2 as published by the Free Software Foundation.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
24 #include <QStringList>
26 #include "ifaces/bluetoothremotedevice.h"
28 #include "frontendobject_p.h"
30 #include "soliddefs_p.h"
31 #include "bluetoothmanager.h"
32 #include "bluetoothinterface.h"
38 class BluetoothRemoteDevicePrivate
: public FrontendObjectPrivate
41 BluetoothRemoteDevicePrivate(QObject
*parent
)
42 : FrontendObjectPrivate(parent
) { }
44 void setBackendObject(QObject
*object
);
49 Solid::Control::BluetoothRemoteDevice::BluetoothRemoteDevice(QObject
*backendObject
)
50 : QObject(), d_ptr(new BluetoothRemoteDevicePrivate(this))
52 Q_D(BluetoothRemoteDevice
);
53 d
->setBackendObject(backendObject
);
56 Solid::Control::BluetoothRemoteDevice::BluetoothRemoteDevice(const BluetoothRemoteDevice
&device
)
57 : QObject(), d_ptr(new BluetoothRemoteDevicePrivate(this))
59 Q_D(BluetoothRemoteDevice
);
60 d
->setBackendObject(device
.d_ptr
->backendObject());
63 Solid::Control::BluetoothRemoteDevice::~BluetoothRemoteDevice()
66 Solid::Control::BluetoothRemoteDevice
&Solid::Control::BluetoothRemoteDevice::operator=(const Solid::Control::BluetoothRemoteDevice
& dev
)
68 Q_D(BluetoothRemoteDevice
);
69 d
->setBackendObject(dev
.d_ptr
->backendObject());
74 bool Solid::Control::BluetoothRemoteDevice::operator==(const BluetoothRemoteDevice
& other
) const
76 return ubi() == other
.ubi();
79 QString
Solid::Control::BluetoothRemoteDevice::ubi() const
81 Q_D(const BluetoothRemoteDevice
);
82 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice
*, d
->backendObject(), QString(), ubi());
85 QMap
<QString
,QVariant
> Solid::Control::BluetoothRemoteDevice::getProperties()
87 Q_D(const BluetoothRemoteDevice
);
88 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice
*, d
->backendObject(), (QMap
< QString
,QVariant
>()), getProperties());
91 QVariant
Solid::Control::BluetoothRemoteDevice::getProperty(const QString
&key
)
93 QMap
<QString
, QVariant
> props
= getProperties();
94 if (props
.contains(key
))
100 QStringList
Solid::Control::BluetoothRemoteDevice::listNodes()
102 Q_D(const BluetoothRemoteDevice
);
103 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice
*, d
->backendObject(), QStringList(), listNodes());
106 void Solid::Control::BluetoothRemoteDevice::setProperty(const QString
&name
, const QVariant
&value
)
108 Q_D(const BluetoothRemoteDevice
);
109 SOLID_CALL(Ifaces::BluetoothRemoteDevice
*, d
->backendObject(), setProperty(name
,value
));
112 void Solid::Control::BluetoothRemoteDevice::cancelDiscovery()
114 Q_D(const BluetoothRemoteDevice
);
115 SOLID_CALL(Ifaces::BluetoothRemoteDevice
*, d
->backendObject(), cancelDiscovery());
118 void Solid::Control::BluetoothRemoteDevice::disconnect()
120 Q_D(const BluetoothRemoteDevice
);
121 SOLID_CALL(Ifaces::BluetoothRemoteDevice
*, d
->backendObject(), disconnect());
125 QString
Solid::Control::BluetoothRemoteDevice::address()
127 QVariant var
= getProperty("Address");
130 return var
.value
<QString
>();
134 // Q_D(const BluetoothRemoteDevice);
135 // return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), address());
138 bool Solid::Control::BluetoothRemoteDevice::isTrusted()
140 QVariant var
= getProperty("Trusted");
143 return var
.value
<bool>();
148 void Solid::Control::BluetoothRemoteDevice::setTrusted(bool trust
)
150 setProperty("Trusted",QVariant(trust
));
153 QString
Solid::Control::BluetoothRemoteDevice::icon()
155 QVariant var
= getProperty("Icon");
158 return var
.value
<QString
>();
163 QStringList
Solid::Control::BluetoothRemoteDevice::uuids()
165 QVariant var
= getProperty("UUIDs");
168 return var
.value
<QStringList
>();
170 return QStringList();
173 bool Solid::Control::BluetoothRemoteDevice::isConnected()
175 QVariant var
= getProperty("Connected");
178 return var
.value
<bool>();
184 bool Solid::Control::BluetoothRemoteDevice::isConnected() const
186 Q_D(const BluetoothRemoteDevice);
187 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), false, isConnected());
190 QString Solid::Control::BluetoothRemoteDevice::version() const
192 Q_D(const BluetoothRemoteDevice);
193 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), version());
196 QString Solid::Control::BluetoothRemoteDevice::revision() const
198 Q_D(const BluetoothRemoteDevice);
199 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), revision());
202 QString Solid::Control::BluetoothRemoteDevice::manufacturer() const
204 Q_D(const BluetoothRemoteDevice);
205 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), manufacturer());
208 QString Solid::Control::BluetoothRemoteDevice::company() const
210 Q_D(const BluetoothRemoteDevice);
211 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), company());
214 QString Solid::Control::BluetoothRemoteDevice::majorClass() const
216 Q_D(const BluetoothRemoteDevice);
217 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), majorClass());
220 QString Solid::Control::BluetoothRemoteDevice::minorClass() const
222 Q_D(const BluetoothRemoteDevice);
223 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), minorClass());
226 QStringList Solid::Control::BluetoothRemoteDevice::serviceClasses() const
228 Q_D(const BluetoothRemoteDevice);
229 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QStringList(), serviceClasses());
233 QString
Solid::Control::BluetoothRemoteDevice::name()
235 QVariant var
= getProperty("Name");
238 return var
.value
<QString
>();
242 // return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), name());
246 QString Solid::Control::BluetoothRemoteDevice::alias() const
248 Q_D(const BluetoothRemoteDevice);
249 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), alias());
252 QString Solid::Control::BluetoothRemoteDevice::lastSeen() const
254 Q_D(const BluetoothRemoteDevice);
255 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), lastSeen());
258 QString Solid::Control::BluetoothRemoteDevice::lastUsed() const
260 Q_D(const BluetoothRemoteDevice);
261 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), QString(), lastUsed());
264 bool Solid::Control::BluetoothRemoteDevice::hasBonding() const
266 Q_D(const BluetoothRemoteDevice);
267 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), false, hasBonding());
270 int Solid::Control::BluetoothRemoteDevice::pinCodeLength() const
272 Q_D(const BluetoothRemoteDevice);
273 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), 0, pinCodeLength());
276 int Solid::Control::BluetoothRemoteDevice::encryptionKeySize() const
278 Q_D(const BluetoothRemoteDevice);
279 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), 0, encryptionKeySize());
282 KJob *Solid::Control::BluetoothRemoteDevice::createBonding()
284 Q_D(BluetoothRemoteDevice);
285 return_SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), 0, createBonding());
288 void Solid::Control::BluetoothRemoteDevice::setAlias(const QString &alias)
290 Q_D(BluetoothRemoteDevice);
291 SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), setAlias(alias));
294 void Solid::Control::BluetoothRemoteDevice::clearAlias()
296 Q_D(BluetoothRemoteDevice);
297 SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), clearAlias());
300 void Solid::Control::BluetoothRemoteDevice::disconnect()
302 Q_D(BluetoothRemoteDevice);
303 SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), disconnect());
306 void Solid::Control::BluetoothRemoteDevice::cancelBondingProcess()
308 Q_D(BluetoothRemoteDevice);
309 SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), cancelBondingProcess());
312 void Solid::Control::BluetoothRemoteDevice::removeBonding()
314 Q_D(const BluetoothRemoteDevice);
315 SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), removeBonding());
317 void Solid::Control::BluetoothRemoteDevice::serviceHandles(const QString &filter) const
319 Q_D(const BluetoothRemoteDevice);
320 SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), serviceHandles(filter));
323 void Solid::Control::BluetoothRemoteDevice::serviceRecordAsXml(uint handle) const
325 Q_D(const BluetoothRemoteDevice);
326 SOLID_CALL(Ifaces::BluetoothRemoteDevice *, d->backendObject(), serviceRecordAsXml(handle));
330 void Solid::Control::BluetoothRemoteDevice::discoverServices(const QString
&filter
)
332 Q_D(const BluetoothRemoteDevice
);
333 SOLID_CALL(Ifaces::BluetoothRemoteDevice
*, d
->backendObject(), discoverServices(filter
));
336 void Solid::Control::BluetoothRemoteDevicePrivate::setBackendObject(QObject
*object
)
338 FrontendObjectPrivate::setBackendObject(object
);
342 QObject::connect(object, SIGNAL(classChanged(uint)),
343 parent(), SIGNAL(classChanged(uint)));
344 QObject::connect(object, SIGNAL(nameChanged(const QString &)),
345 parent(), SIGNAL(nameChanged(const QString &)));
346 QObject::connect(object, SIGNAL(nameResolvingFailed()),
347 parent(), SIGNAL(nameResolvingFailed()));
348 QObject::connect(object, SIGNAL(aliasChanged(const QString &)),
349 parent(), SIGNAL(aliasChanged(const QString &)));
350 QObject::connect(object, SIGNAL(aliasCleared()),
351 parent(), SIGNAL(aliasCleared()));
352 QObject::connect(object, SIGNAL(connected()),
353 parent(), SIGNAL(connected()));
354 QObject::connect(object, SIGNAL(requestDisconnection()),
355 parent(), SIGNAL(requestDisconnection()));
356 QObject::connect(object, SIGNAL(disconnected()),
357 parent(), SIGNAL(disconnected()));
358 QObject::connect(object, SIGNAL(bondingCreated()),
359 parent(), SIGNAL(bondingCreated()));
360 QObject::connect(object, SIGNAL(bondingRemoved()),
361 parent(), SIGNAL(bondingRemoved()));
362 QObject::connect(object, SIGNAL(serviceHandlesAvailable(const QString &, const QList<uint> &)),
363 parent(), SIGNAL(serviceHandlesAvailable(const QString &, const QList<uint> &)));
364 QObject::connect(object, SIGNAL(serviceRecordXmlAvailable(const QString &, const QString &)),
365 parent(), SIGNAL(serviceRecordXmlAvailable(const QString &, const QString &)));
368 QObject::connect(object
, SIGNAL(serviceDiscoverAvailable(const QString
&, const QMap
< uint
,QString
> &)),
369 parent(), SIGNAL(serviceDiscoverAvailable(const QString
&, const QMap
< uint
,QString
> &)));
370 QObject::connect(object
, SIGNAL(propertyChanged(const QString
&, const QVariant
&)),
371 parent(), SIGNAL(propertyChanged(const QString
&, const QVariant
&)));
372 QObject::connect(object
, SIGNAL(disconnectRequested()),
373 parent(), SIGNAL(disconnectRequested()));
374 QObject::connect(object
, SIGNAL(nodeCreated(const QString
&)),
375 parent(), SIGNAL(nodeCreated(const QString
&)));
376 QObject::connect(object
, SIGNAL(nodeRemoved(const QString
&)),
377 parent(), SIGNAL(nodeRemoved(const QString
&)));
384 #include "bluetoothremotedevice.moc"