SolidModules
bluez-bluetoothinputdevice.cpp
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 Copyright (C) 2007 Will Stephenson <wstephenson@kde.org> 00003 Copyright (C) 2007 Daniel Gollub <dgollub@suse.de> 00004 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 00020 */ 00021 00022 #include "bluez-bluetoothinputdevice.h" 00023 00024 #include <QtDBus> 00025 00026 #include <kdebug.h> 00027 00028 BluezBluetoothInputDevice::BluezBluetoothInputDevice(const QString &objectPath, 00029 const QString &dest) : BluetoothInputDevice(0), m_objectPath(objectPath) 00030 { 00031 device = new QDBusInterface(dest, m_objectPath, 00032 "org.bluez.input.Device", QDBusConnection::systemBus()); 00033 00034 } 00035 00036 BluezBluetoothInputDevice::~BluezBluetoothInputDevice() 00037 { 00038 delete device; 00039 } 00040 00041 QString BluezBluetoothInputDevice::ubi() const 00042 { 00043 return m_objectPath; 00044 } 00045 00046 QString BluezBluetoothInputDevice::address() const 00047 { 00048 return stringReply("GetAddress"); 00049 } 00050 00051 bool BluezBluetoothInputDevice::isConnected() const 00052 { 00053 return boolReply("IsConnected"); 00054 } 00055 00056 QString BluezBluetoothInputDevice::name() const 00057 { 00058 return stringReply("GetName"); 00059 } 00060 00061 QString BluezBluetoothInputDevice::productID() const 00062 { 00063 return stringReply("GetProductID"); 00064 } 00065 00066 QString BluezBluetoothInputDevice::vendorID() const 00067 { 00068 return stringReply("GetVendorID"); 00069 } 00070 00071 void BluezBluetoothInputDevice::slotConnect() 00072 { 00073 device->call("Connect"); 00074 } 00075 00076 void BluezBluetoothInputDevice::slotDisconnect() 00077 { 00078 device->call("Disconnect"); 00079 } 00080 00081 /******************************/ 00082 00083 QString BluezBluetoothInputDevice::stringReply(const QString &method) const 00084 { 00085 QDBusReply< QString > reply = device->call(method); 00086 if (!reply.isValid()) 00087 return QString(); 00088 00089 return reply.value(); 00090 } 00091 00092 bool BluezBluetoothInputDevice::boolReply(const QString &method) const 00093 { 00094 QDBusReply< bool > reply = device->call(method); 00095 if (!reply.isValid()) 00096 return false; 00097 00098 return reply.value(); 00099 } 00100 00101 #include "bluez-bluetoothinputdevice.moc"