not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / solid / bluez / bluez-bluetoothinputdevice.cpp
blob68965bfbb7dc83addfb68050ef20757ec645d4a5
1 /* This file is part of the KDE project
2 Copyright (C) 2007 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.
23 #include "bluez-bluetoothinputdevice.h"
25 #include <QtDBus>
27 #include <kdebug.h>
29 BluezBluetoothInputDevice::BluezBluetoothInputDevice(const QString &objectPath) : BluetoothInputDevice(0), m_objectPath(objectPath)
31 device = new QDBusInterface("org.bluez", m_objectPath,
32 "org.bluez.Input", QDBusConnection::systemBus());
33 #define connectInputDeviceToThis(signal, slot) \
34 device->connection().connect("org.bluez", \
35 objectPath, \
36 "org.bluez.Input", \
37 signal, this, SLOT(slot))
38 connectInputDeviceToThis("PropertyChanged",slotPropertyChanged(const QString &,const QDBusVariant &));
42 BluezBluetoothInputDevice::~BluezBluetoothInputDevice()
44 delete device;
47 QString BluezBluetoothInputDevice::ubi() const
49 return m_objectPath;
52 QMap<QString,QVariant> BluezBluetoothInputDevice::getProperties() const
54 QDBusReply< QMap<QString,QVariant> > path = device->call("GetProperties");
55 if (!path.isValid())
56 return QMap<QString,QVariant>();
58 return path.value();
61 void BluezBluetoothInputDevice::disconnect()
63 device->call("Disconnect");
66 void BluezBluetoothInputDevice::connect()
68 device->call("Connect");
72 /******************************/
74 QString BluezBluetoothInputDevice::stringReply(const QString &method) const
76 QDBusReply< QString > reply = device->call(method);
77 if (!reply.isValid())
78 return QString();
80 return reply.value();
83 bool BluezBluetoothInputDevice::boolReply(const QString &method) const
85 QDBusReply< bool > reply = device->call(method);
86 if (!reply.isValid())
87 return false;
89 return reply.value();
92 /******************************/
94 void BluezBluetoothInputDevice::slotPropertyChanged(const QString & name, const QDBusVariant& value)
96 emit propertyChanged(name,value.variant());
99 #include "bluez-bluetoothinputdevice.moc"