SolidModules
bluez-bluetoothinputdevice.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "bluez-bluetoothinputdevice.h"
00024
00025 #include <QtDBus>
00026
00027 #include <kdebug.h>
00028
00029 BluezBluetoothInputDevice::BluezBluetoothInputDevice(const QString &objectPath) : BluetoothInputDevice(0), m_objectPath(objectPath)
00030 {
00031 device = new QDBusInterface("org.bluez", m_objectPath,
00032 "org.bluez.Input", QDBusConnection::systemBus());
00033 #define connectInputDeviceToThis(signal, slot) \
00034 device->connection().connect("org.bluez", \
00035 objectPath, \
00036 "org.bluez.Input", \
00037 signal, this, SLOT(slot))
00038 connectInputDeviceToThis("PropertyChanged",slotPropertyChanged(const QString &,const QDBusVariant &));
00039
00040 }
00041
00042 BluezBluetoothInputDevice::~BluezBluetoothInputDevice()
00043 {
00044 delete device;
00045 }
00046
00047 QString BluezBluetoothInputDevice::ubi() const
00048 {
00049 return m_objectPath;
00050 }
00051
00052 QMap<QString,QVariant> BluezBluetoothInputDevice::getProperties() const
00053 {
00054 QDBusReply< QMap<QString,QVariant> > path = device->call("GetProperties");
00055 if (!path.isValid())
00056 return QMap<QString,QVariant>();
00057
00058 return path.value();
00059 }
00060
00061 void BluezBluetoothInputDevice::disconnect()
00062 {
00063 device->call("Disconnect");
00064 }
00065
00066 void BluezBluetoothInputDevice::connect()
00067 {
00068 device->call("Connect");
00069 }
00070
00071
00072
00073
00074 QString BluezBluetoothInputDevice::stringReply(const QString &method) const
00075 {
00076 QDBusReply< QString > reply = device->call(method);
00077 if (!reply.isValid())
00078 return QString();
00079
00080 return reply.value();
00081 }
00082
00083 bool BluezBluetoothInputDevice::boolReply(const QString &method) const
00084 {
00085 QDBusReply< bool > reply = device->call(method);
00086 if (!reply.isValid())
00087 return false;
00088
00089 return reply.value();
00090 }
00091
00092
00093
00094 void BluezBluetoothInputDevice::slotPropertyChanged(const QString & name, const QDBusVariant& value)
00095 {
00096 emit propertyChanged(name,value.variant());
00097 }
00098
00099 #include "bluez-bluetoothinputdevice.moc"