solid: drop button interface

now unused, the signals were never implemented either

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-03-30 05:20:24 +02:00
parent d9847b4290
commit d52a4a7c6b
22 changed files with 6 additions and 727 deletions

View file

@ -443,7 +443,6 @@ install(
Solid/AudioInterface Solid/AudioInterface
Solid/Battery Solid/Battery
Solid/Block Solid/Block
Solid/Button
Solid/Camera Solid/Camera
Solid/Device Solid/Device
Solid/DeviceInterface Solid/DeviceInterface

View file

@ -1 +0,0 @@
#include "../../solid/button.h"

View file

@ -35,7 +35,6 @@ set(solid_LIB_SRCS
networkinterface.cpp networkinterface.cpp
acadapter.cpp acadapter.cpp
battery.cpp battery.cpp
button.cpp
audiointerface.cpp audiointerface.cpp
predicate.cpp predicate.cpp
predicateparse.cpp predicateparse.cpp
@ -50,7 +49,6 @@ set(solid_LIB_SRCS
ifaces/audiointerface.cpp ifaces/audiointerface.cpp
ifaces/battery.cpp ifaces/battery.cpp
ifaces/block.cpp ifaces/block.cpp
ifaces/button.cpp
ifaces/camera.cpp ifaces/camera.cpp
ifaces/opticaldrive.cpp ifaces/opticaldrive.cpp
ifaces/device.cpp ifaces/device.cpp
@ -82,7 +80,6 @@ if(ENABLE_TESTING)
backends/fakehw/fakeaudiointerface.cpp backends/fakehw/fakeaudiointerface.cpp
backends/fakehw/fakebattery.cpp backends/fakehw/fakebattery.cpp
backends/fakehw/fakeblock.cpp backends/fakehw/fakeblock.cpp
backends/fakehw/fakebutton.cpp
backends/fakehw/fakecamera.cpp backends/fakehw/fakecamera.cpp
backends/fakehw/fakecdrom.cpp backends/fakehw/fakecdrom.cpp
backends/fakehw/fakedevice.cpp backends/fakehw/fakedevice.cpp
@ -117,7 +114,6 @@ if(UDEV_FOUND)
backends/udev/udevaudiointerface_p.cpp backends/udev/udevaudiointerface_p.cpp
backends/udev/udevportablemediaplayer.cpp backends/udev/udevportablemediaplayer.cpp
backends/udev/udevblock.cpp backends/udev/udevblock.cpp
backends/udev/udevbutton.cpp
backends/udev/udevstorageaccess.cpp backends/udev/udevstorageaccess.cpp
backends/udev/udevstoragevolume.cpp backends/udev/udevstoragevolume.cpp
backends/udev/udevstoragedrive.cpp backends/udev/udevstoragedrive.cpp
@ -233,7 +229,6 @@ install(
networkinterface.h networkinterface.h
acadapter.h acadapter.h
battery.h battery.h
button.h
audiointerface.h audiointerface.h
predicate.h predicate.h
powermanagement.h powermanagement.h

View file

@ -1,74 +0,0 @@
/*
Copyright 2006 Davide Bettio <davide.bettio@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "fakebutton.h"
using namespace Solid::Backends::Fake;
FakeButton::FakeButton(FakeDevice *device)
: FakeDeviceInterface(device)
{
}
FakeButton::~FakeButton()
{
}
Solid::Button::ButtonType FakeButton::type() const
{
QString buttontype = fakeDevice()->property("type").toString();
if (buttontype=="LidButton")
{
return Solid::Button::LidButton;
}
else if (buttontype=="PowerButton")
{
return Solid::Button::PowerButton;
}
else if (buttontype=="SleepButton")
{
return Solid::Button::SleepButton;
}
else
{
return Solid::Button::UnknownButtonType;
}
}
bool FakeButton::hasState() const
{
return fakeDevice()->property("hasState").toBool();
}
bool FakeButton::stateValue() const
{
return fakeDevice()->property("stateValue").toBool();
}
void FakeButton::press()
{
if (hasState()) fakeDevice()->setProperty("stateValue", !stateValue());
emit pressed(type(), fakeDevice()->udi());
}
#include "backends/fakehw/moc_fakebutton.cpp"

View file

@ -1,56 +0,0 @@
/*
Copyright 2006 Davide Bettio <davide.bettio@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLID_BACKENDS_FAKEHW_FAKEBUTTON_H
#define SOLID_BACKENDS_FAKEHW_FAKEBUTTON_H
#include "fakedeviceinterface.h"
#include <solid/ifaces/button.h>
namespace Solid
{
namespace Backends
{
namespace Fake
{
class FakeButton : public FakeDeviceInterface, virtual public Solid::Ifaces::Button
{
Q_OBJECT
Q_INTERFACES(Solid::Ifaces::Button)
public:
explicit FakeButton(FakeDevice *device);
~FakeButton();
public Q_SLOTS:
virtual Solid::Button::ButtonType type() const;
virtual bool hasState() const;
virtual bool stateValue() const;
void press();
Q_SIGNALS:
void pressed(Solid::Button::ButtonType type, const QString &udi);
};
}
}
}
#endif // SOLID_BACKENDS_FAKEHW_FAKEBUTTON_H

View file

@ -49,40 +49,6 @@
<property key="chargeState">discharging</property> <property key="chargeState">discharging</property>
</device> </device>
<!-- So that it looks like a laptop,
provide this computer a few buttons:
- power button
- sleep button
- lid switch -->
<device udi="/org/kde/solid/fakehw/acpi_PWB">
<property key="name">Power Button</property>
<property key="interfaces">Button</property>
<property key="parent">/org/kde/solid/fakehw/computer</property>
<property key="type">PowerButton</property>
<property key="hasState">false</property>
</device>
<device udi="/org/kde/solid/fakehw/acpi_SLPB">
<property key="name">Sleep Button</property>
<property key="interfaces">Button</property>
<property key="parent">/org/kde/solid/fakehw/computer</property>
<property key="type">SleepButton</property>
<property key="hasState">false</property>
</device>
<device udi="/org/kde/solid/fakehw/acpi_LID0">
<property key="name">Lid Switch</property>
<property key="interfaces">Button</property>
<property key="parent">/org/kde/solid/fakehw/computer</property>
<property key="type">LidButton</property>
<property key="hasState">true</property>
<property key="stateValue">false</property>
</device>
<!-- Two CPUs --> <!-- Two CPUs -->
<device udi="/org/kde/solid/fakehw/acpi_CPU0"> <device udi="/org/kde/solid/fakehw/acpi_CPU0">
<property key="name">Solid Processor #0</property> <property key="name">Solid Processor #0</property>
@ -126,9 +92,7 @@
<property key="bus">platform</property> <property key="bus">platform</property>
<property key="driveType">floppy</property> <property key="driveType">floppy</property>
<property key="isRemovable">true</property> <property key="isRemovable">true</property>
<property key="isEjectRequired">false</property>
<property key="isHotpluggable">false</property> <property key="isHotpluggable">false</property>
<property key="isMediaCheckEnabled">false</property>
</device> </device>
<!-- A (generally) virtual volume tracking the floppy drive state --> <!-- A (generally) virtual volume tracking the floppy drive state -->
<device udi="/org/kde/solid/fakehw/platform_floppy_0_storage_virt_volume"> <device udi="/org/kde/solid/fakehw/platform_floppy_0_storage_virt_volume">
@ -174,9 +138,7 @@
<property key="bus">scsi</property> <property key="bus">scsi</property>
<property key="driveType">disk</property> <property key="driveType">disk</property>
<property key="isRemovable">false</property> <property key="isRemovable">false</property>
<property key="isEjectRequired">false</property>
<property key="isHotpluggable">false</property> <property key="isHotpluggable">false</property>
<property key="isMediaCheckEnabled">false</property>
<property key="product">HD250GBSATA</property> <property key="product">HD250GBSATA</property>
</device> </device>
<!-- ... with five partitions: <!-- ... with five partitions:
@ -297,9 +259,7 @@
<property key="bus">ide</property> <property key="bus">ide</property>
<property key="driveType">cdrom</property> <property key="driveType">cdrom</property>
<property key="isRemovable">true</property> <property key="isRemovable">true</property>
<property key="isEjectRequired">true</property>
<property key="isHotpluggable">false</property> <property key="isHotpluggable">false</property>
<property key="isMediaCheckEnabled">true</property>
<property key="product">Solid DVD Writer</property> <property key="product">Solid DVD Writer</property>
<property key="supportedMedia">cdr,cdrw,dvd,dvdr,dvdrw</property> <property key="supportedMedia">cdr,cdrw,dvd,dvdr,dvdrw</property>
@ -344,9 +304,7 @@
<property key="bus">ide</property> <property key="bus">ide</property>
<property key="driveType">cdrom</property> <property key="driveType">cdrom</property>
<property key="isRemovable">true</property> <property key="isRemovable">true</property>
<property key="isEjectRequired">true</property>
<property key="isHotpluggable">false</property> <property key="isHotpluggable">false</property>
<property key="isMediaCheckEnabled">true</property>
<property key="product">Solid DVD Reader</property> <property key="product">Solid DVD Reader</property>
<property key="supportedMedia">cdr,cdrw,dvd,dvdr,dvdrw,dvdram,dvdplusr,dvdplusrw</property> <property key="supportedMedia">cdr,cdrw,dvd,dvdr,dvdrw,dvdram,dvdplusr,dvdplusrw</property>
@ -417,9 +375,7 @@
<property key="bus">usb</property> <property key="bus">usb</property>
<property key="driveType">disk</property> <property key="driveType">disk</property>
<property key="isRemovable">true</property> <property key="isRemovable">true</property>
<property key="isEjectRequired">true</property>
<property key="isHotpluggable">true</property> <property key="isHotpluggable">true</property>
<property key="isMediaCheckEnabled">true</property>
<property key="product">XO-Y4</property> <property key="product">XO-Y4</property>
<property key="accessMethod">MassStorage</property> <property key="accessMethod">MassStorage</property>

View file

@ -32,7 +32,6 @@
#include "fakenetworkinterface.h" #include "fakenetworkinterface.h"
#include "fakeacadapter.h" #include "fakeacadapter.h"
#include "fakebattery.h" #include "fakebattery.h"
#include "fakebutton.h"
#include "fakeaudiointerface.h" #include "fakeaudiointerface.h"
#include "fakevideo.h" #include "fakevideo.h"
#include "fakegraphic.h" #include "fakegraphic.h"
@ -285,9 +284,6 @@ QObject *FakeDevice::createDeviceInterface(const Solid::DeviceInterface::Type &t
case Solid::DeviceInterface::Battery: case Solid::DeviceInterface::Battery:
iface = new FakeBattery(this); iface = new FakeBattery(this);
break; break;
case Solid::DeviceInterface::Button:
iface = new FakeButton(this);
break;
case Solid::DeviceInterface::AudioInterface: case Solid::DeviceInterface::AudioInterface:
iface = new FakeAudioInterface(this); iface = new FakeAudioInterface(this);
break; break;

View file

@ -21,9 +21,6 @@
#include "fakedevice.h" #include "fakedevice.h"
// Qt includes
#include <QtXml/qdom.h>
#include <QtXml/qdom.h>
#include <QtXml/qdom.h> #include <QtXml/qdom.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QFile> #include <QtCore/QFile>
@ -65,7 +62,6 @@ FakeManager::FakeManager(QObject *parent, const QString &xmlFile)
<< Solid::DeviceInterface::NetworkInterface << Solid::DeviceInterface::NetworkInterface
<< Solid::DeviceInterface::AcAdapter << Solid::DeviceInterface::AcAdapter
<< Solid::DeviceInterface::Battery << Solid::DeviceInterface::Battery
<< Solid::DeviceInterface::Button
<< Solid::DeviceInterface::AudioInterface << Solid::DeviceInterface::AudioInterface
<< Solid::DeviceInterface::Video << Solid::DeviceInterface::Video
<< Solid::DeviceInterface::Graphic << Solid::DeviceInterface::Graphic

View file

@ -1,53 +0,0 @@
/*************************************************************************************
* Copyright (C) 2013 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*************************************************************************************/
#include "udevbutton.h"
using namespace Solid::Backends::UDev;
Button::Button(UDevDevice* device)
: DeviceInterface(device),
m_type(Solid::Button::UnknownButtonType)
{
if (m_device->devicePropertyExists("KEY")) {
m_type = Solid::Button::PowerButton;
} else if (m_device->devicePropertyExists("SW")) {
m_type = Solid::Button::LidButton;
}
// TODO: implement pressed() signal
}
Button::~Button()
{
}
bool Button::hasState() const
{
return true;
}
bool Button::stateValue() const
{
return true;
}
Solid::Button::ButtonType Button::type() const
{
return m_type;
}

View file

@ -1,55 +0,0 @@
/*************************************************************************************
* Copyright (C) 2013 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*************************************************************************************/
#ifndef SOLID_BACKENDS_UDEV_BUTTON_H
#define SOLID_BACKENDS_UDEV_BUTTON_H
#include <solid/ifaces/button.h>
#include "udevdeviceinterface.h"
namespace Solid
{
namespace Backends
{
namespace UDev
{
class Button : public DeviceInterface, virtual public Solid::Ifaces::Button
{
Q_OBJECT
Q_INTERFACES(Solid::Ifaces::Button)
public:
Button(UDevDevice *device);
virtual ~Button();
virtual bool hasState() const;
virtual bool stateValue() const;
virtual Solid::Button::ButtonType type() const;
Q_SIGNALS:
void pressed(Solid::Button::ButtonType type, const QString& udi);
private:
Solid::Button::ButtonType m_type;
};
}
}
}
#endif

View file

@ -32,7 +32,6 @@
#include "udevblock.h" #include "udevblock.h"
#include "udevaudiointerface.h" #include "udevaudiointerface.h"
#include "udevnetworkinterface.h" #include "udevnetworkinterface.h"
#include "udevbutton.h"
#include "udevgraphic.h" #include "udevgraphic.h"
#include "udevinput.h" #include "udevinput.h"
#include "udevmanager.h" #include "udevmanager.h"
@ -307,8 +306,6 @@ QString UDevDevice::icon() const
case Solid::AudioInterface::Modem: case Solid::AudioInterface::Modem:
return QLatin1String("modem"); return QLatin1String("modem");
} }
} else if (queryDeviceInterface(Solid::DeviceInterface::Button)) {
return QLatin1String("insert-button");
} else if (queryDeviceInterface(Solid::DeviceInterface::Graphic)) { } else if (queryDeviceInterface(Solid::DeviceInterface::Graphic)) {
return QLatin1String("video-display"); return QLatin1String("video-display");
} else if (queryDeviceInterface(Solid::DeviceInterface::Input)) { } else if (queryDeviceInterface(Solid::DeviceInterface::Input)) {
@ -490,21 +487,6 @@ QString UDevDevice::description() const
return i18n("WLAN Interface"); return i18n("WLAN Interface");
} }
return i18n("Networking Interface"); return i18n("Networking Interface");
} else if (queryDeviceInterface(Solid::DeviceInterface::Button)) {
const Button buttonIface(const_cast<UDevDevice *>(this));
switch (buttonIface.type()) {
case Solid::Button::LidButton:
return i18n("Lid Switch");
case Solid::Button::PowerButton:
return i18n("Power Button");
case Solid::Button::SleepButton:
return i18n("Sleep Button");
case Solid::Button::TabletButton:
return i18n("Tablet Button");
case Solid::Button::UnknownButtonType:
return i18n("Unknown Button");
}
return QString();
} else if (queryDeviceInterface(Solid::DeviceInterface::Graphic)) { } else if (queryDeviceInterface(Solid::DeviceInterface::Graphic)) {
return i18n("Graphic display"); return i18n("Graphic display");
} else if (queryDeviceInterface(Solid::DeviceInterface::Input)) { } else if (queryDeviceInterface(Solid::DeviceInterface::Input)) {
@ -578,9 +560,6 @@ bool UDevDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type)
case Solid::DeviceInterface::NetworkInterface: case Solid::DeviceInterface::NetworkInterface:
return m_device.subsystem() == "net"; return m_device.subsystem() == "net";
case Solid::DeviceInterface::Button:
return deviceProperty("ID_INPUT_KEY").toInt() == 1;
case Solid::DeviceInterface::Graphic: case Solid::DeviceInterface::Graphic:
return deviceProperty("PCI_CLASS").toInt() == 30000; return deviceProperty("PCI_CLASS").toInt() == 30000;
@ -646,9 +625,6 @@ QObject *UDevDevice::createDeviceInterface(const Solid::DeviceInterface::Type &t
case Solid::DeviceInterface::NetworkInterface: case Solid::DeviceInterface::NetworkInterface:
return new NetworkInterface(this); return new NetworkInterface(this);
case Solid::DeviceInterface::Button:
return new Button(this);
case Solid::DeviceInterface::Graphic: case Solid::DeviceInterface::Graphic:
return new Graphic(this); return new Graphic(this);

View file

@ -123,11 +123,6 @@ bool UDevManager::Private::checkOfInterest(const UdevQt::Device &device)
if (device.subsystem() == "input") { if (device.subsystem() == "input") {
const QStringList deviceProperties = device.deviceProperties(); const QStringList deviceProperties = device.deviceProperties();
// key
if (device.deviceProperty("ID_INPUT_KEY").toInt() == 1
&& (deviceProperties.contains("KEY") || deviceProperties.contains("SW"))) {
return true;
}
// mouse, keyboard or joystick // mouse, keyboard or joystick
if (device.deviceProperty("ID_INPUT_MOUSE").toInt() == 1 if (device.deviceProperty("ID_INPUT_MOUSE").toInt() == 1
|| device.deviceProperty("ID_INPUT_KEYBOARD").toInt() == 1 || device.deviceProperty("ID_INPUT_KEYBOARD").toInt() == 1
@ -167,7 +162,6 @@ UDevManager::UDevManager(QObject *parent)
<< Solid::DeviceInterface::PortableMediaPlayer << Solid::DeviceInterface::PortableMediaPlayer
<< Solid::DeviceInterface::Block << Solid::DeviceInterface::Block
<< Solid::DeviceInterface::Video << Solid::DeviceInterface::Video
<< Solid::DeviceInterface::Button
<< Solid::DeviceInterface::Graphic << Solid::DeviceInterface::Graphic
<< Solid::DeviceInterface::Input; << Solid::DeviceInterface::Input;
} }

View file

@ -1,58 +0,0 @@
/*
Copyright 2006 Davide Bettio <davide.bettio@kdemail.net>
Copyright 2007 Kevin Ottens <ervin@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "button.h"
#include "button_p.h"
#include "soliddefs_p.h"
#include <solid/ifaces/button.h>
Solid::Button::Button(QObject *backendObject)
: DeviceInterface(*new ButtonPrivate(), backendObject)
{
connect(backendObject, SIGNAL(pressed(Solid::Button::ButtonType,QString)),
this, SIGNAL(pressed(Solid::Button::ButtonType,QString)));
}
Solid::Button::~Button()
{
}
Solid::Button::ButtonType Solid::Button::type() const
{
Q_D(const Button);
return_SOLID_CALL(Ifaces::Button *, d->backendObject(), UnknownButtonType, type());
}
bool Solid::Button::hasState() const
{
Q_D(const Button);
return_SOLID_CALL(Ifaces::Button *, d->backendObject(), false, hasState());
}
bool Solid::Button::stateValue() const
{
Q_D(const Button);
return_SOLID_CALL(Ifaces::Button *, d->backendObject(), false, stateValue());
}
#include "moc_button.cpp"

View file

@ -1,129 +0,0 @@
/*
Copyright 2006 Davide Bettio <davide.bettio@kdemail.net>
Copyright 2007 Kevin Ottens <ervin@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLID_BUTTON_H
#define SOLID_BUTTON_H
#include <solid/solid_export.h>
#include <solid/deviceinterface.h>
namespace Solid
{
class ButtonPrivate;
class Device;
/**
* This device interface is available on button devices.
*
* A button is a device, like power button or lid switch, that can be pressed by user.
* Some buttons can have two states (Enabled/Disabled, On/Off ...), other buttons haven't state.
*
* @author Davide Bettio <davide.bettio@kdemail.net>
*/
class SOLID_EXPORT Button : public DeviceInterface
{
Q_OBJECT
Q_ENUMS(ButtonType)
Q_PROPERTY(ButtonType type READ type)
Q_PROPERTY(bool hasState READ hasState)
Q_PROPERTY(bool stateValue READ stateValue)
Q_DECLARE_PRIVATE(Button)
friend class Device;
public:
/**
* This enum type defines the type of button.
*
* - LidButton : The switch on a laptop that senses whether the lid is open or closed.
* - PowerButton : The main power button on the computer.
* - SleepButton : The sleep button on a computer capable of putting the computer into a suspend state.
* - TabletButton : The tablet switch on a laptop that senses if the monitor is rotated or not.
* - UnknownButtonType : The type of the button is unknow.
*/
enum ButtonType{ LidButton, PowerButton, SleepButton, UnknownButtonType, TabletButton };
private:
/**
* Creates a new Button object.
* You generally won't need this. It's created when necessary using
* Device::as().
*
* @param backendObject the device interface object provided by the backend
* @see Solid::Device::as()
*/
explicit Button(QObject *backendObject);
public:
/**
* Destroys a Button object.
*/
virtual ~Button();
/**
* Get the Solid::DeviceInterface::Type of the Button device interface.
*
* @return the Button device interface type
* @see Solid::DeviceInterface::Type
*/
static Type deviceInterfaceType() { return DeviceInterface::Button; }
/**
* Retrieves the type of button device.
*
* @return the type of button device.
* @see Solid::Button::ButtonType
*/
ButtonType type() const;
/**
* Indicates if the button mantains state (Can toggled on/off).
*
* @return true if the button maintains state, false otherwise.
* @see stateValue()
*/
bool hasState() const;
/**
* Retrieves the state of the button.
* A button can have two states (Enabled/Disabled, On/Off ...).
* Available only if hasState is true.
*
* @return true if the button is enabled, false otherwise.
* @see hasState()
*/
bool stateValue() const;
Q_SIGNALS:
/**
* This signal is emitted when the button is pressed.
*
* @param type the type of button device, it's one of
* the type Solid::Button::ButtonType
* @see Solid::Button::ButtonType
* @param udi the UDI of the button
*/
void pressed(Solid::Button::ButtonType type, const QString &udi);
};
}
#endif

View file

@ -1,37 +0,0 @@
/*
Copyright 2006 Davide Bettio <davide.bettio@kdemail.net>
Copyright 2007 Kevin Ottens <ervin@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLID_BUTTON_P_H
#define SOLID_BUTTON_P_H
#include "deviceinterface_p.h"
namespace Solid
{
class ButtonPrivate : public DeviceInterfacePrivate
{
public:
ButtonPrivate()
: DeviceInterfacePrivate() { }
};
}
#endif

View file

@ -52,8 +52,6 @@
#include <solid/ifaces/acadapter.h> #include <solid/ifaces/acadapter.h>
#include <solid/battery.h> #include <solid/battery.h>
#include <solid/ifaces/battery.h> #include <solid/ifaces/battery.h>
#include <solid/button.h>
#include <solid/ifaces/button.h>
#include <solid/audiointerface.h> #include <solid/audiointerface.h>
#include <solid/ifaces/audiointerface.h> #include <solid/ifaces/audiointerface.h>
#include <solid/video.h> #include <solid/video.h>
@ -207,9 +205,6 @@ const Solid::DeviceInterface *Solid::Device::asDeviceInterface(const DeviceInter
case DeviceInterface::Battery: case DeviceInterface::Battery:
iface = deviceinterface_cast(Ifaces::Battery, Battery, dev_iface); iface = deviceinterface_cast(Ifaces::Battery, Battery, dev_iface);
break; break;
case DeviceInterface::Button:
iface = deviceinterface_cast(Ifaces::Button, Button, dev_iface);
break;
case DeviceInterface::AudioInterface: case DeviceInterface::AudioInterface:
iface = deviceinterface_cast(Ifaces::AudioInterface, AudioInterface, dev_iface); iface = deviceinterface_cast(Ifaces::AudioInterface, AudioInterface, dev_iface);
break; break;

View file

@ -89,8 +89,6 @@ QString Solid::DeviceInterface::typeDescription(Type type)
return i18n("Ac Adapter"); return i18n("Ac Adapter");
case Solid::DeviceInterface::Battery: case Solid::DeviceInterface::Battery:
return i18n("Battery"); return i18n("Battery");
case Solid::DeviceInterface::Button:
return i18n("Button");
case Solid::DeviceInterface::AudioInterface: case Solid::DeviceInterface::AudioInterface:
return i18n("Audio Interface"); return i18n("Audio Interface");
case Solid::DeviceInterface::Video: case Solid::DeviceInterface::Video:

View file

@ -76,11 +76,10 @@ namespace Solid
NetworkInterface = 10, NetworkInterface = 10,
AcAdapter = 11, AcAdapter = 11,
Battery = 12, Battery = 12,
Button = 13, AudioInterface = 13,
AudioInterface = 14, Video = 14,
Video = 15, Graphic = 15,
Graphic = 16, Input = 16,
Input = 17,
Last = 0xffff Last = 0xffff
}; };

View file

@ -1,26 +0,0 @@
/*
Copyright 2006 Davide Bettio <davide.bettio@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "button.h"
Solid::Ifaces::Button::~Button()
{
}

View file

@ -1,89 +0,0 @@
/*
Copyright 2006 Davide Bettio <davide.bettio@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLID_IFACES_BUTTON_H
#define SOLID_IFACES_BUTTON_H
#include <solid/ifaces/deviceinterface.h>
#include <solid/button.h>
namespace Solid
{
namespace Ifaces
{
/**
* This device interface is available on button devices.
*
* A button is a device, like power button or lid switch, that can be pressed by user.
* Some buttons can have two states (Enabled/Disabled, On/Off ...), other buttons haven't state.
*
* @author Davide Bettio <davide.bettio@kdemail.net>
*/
class Button : virtual public DeviceInterface
{
public:
/**
* Destroys a Button object.
*/
virtual ~Button();
/**
* Retrieves the type of button device.
*
* @return the type of button device.
* @see Solid::Button::ButtonType
*/
virtual Solid::Button::ButtonType type() const = 0;
/**
* Indicates if the button mantains state (Can toggled on/off).
*
* @return true if the button maintains state, false otherwise.
* @see stateValue()
*/
virtual bool hasState() const = 0;
/**
* Retrieves the state of the button.
* A button can have two states (Enabled/Disabled, On/Off ...).
* Available only if hasState is true.
*
* @return true if the button is enabled, false otherwise.
* @see hasState()
*/
virtual bool stateValue() const = 0;
protected:
//Q_SIGNALS:
/**
* This signal is emitted when the button is pressed.
*
* @param type the type of button device, it's one of
* the type Solid::Button::ButtonType
* @see Solid::Button::ButtonType
*/
virtual void pressed(Solid::Button::ButtonType type, const QString &udi) = 0;
};
}
}
Q_DECLARE_INTERFACE(Solid::Ifaces::Button, "org.kde.Solid.Ifaces.Button/0.1")
#endif

View file

@ -134,8 +134,8 @@ void SolidHwTest::testManagerSignals()
// Finally we remove the device and spy the corresponding signal again // Finally we remove the device and spy the corresponding signal again
QSignalSpy removed(Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString))); QSignalSpy removed(Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString)));
fakeManager->unplug("/org/kde/solid/fakehw/acpi_CPU0"); fakeManager->unplug("/org/kde/solid/fakehw/acpi_CPU0");
QCOMPARE(added.count(), 1); QCOMPARE(removed.count(), 1);
QCOMPARE(added.at(0).at(0).toString(), QString("/org/kde/solid/fakehw/acpi_CPU0")); QCOMPARE(removed.at(0).at(0).toString(), QString("/org/kde/solid/fakehw/acpi_CPU0"));
// The Device object should become automatically invalid // The Device object should become automatically invalid
QVERIFY(!cpu.isValid()); QVERIFY(!cpu.isValid());
@ -144,53 +144,8 @@ void SolidHwTest::testManagerSignals()
fakeManager->plug("/org/kde/solid/fakehw/acpi_CPU0"); fakeManager->plug("/org/kde/solid/fakehw/acpi_CPU0");
} }
void SolidHwTest::testDeviceSignals()
{
// A button is a nice device for testing state changes, isn't it?
Solid::Backends::Fake::FakeDevice *fake = fakeManager->findDevice("/org/kde/solid/fakehw/acpi_LID0");
Solid::Device device("/org/kde/solid/fakehw/acpi_LID0");
// We'll spy our button
connect(fake, SIGNAL(propertyChanged(QStringList)),
this, SLOT(slotPropertyChanged(QStringList)));
QSignalSpy condition_raised(fake, SIGNAL(conditionRaised(QString,QString)));
fake->setProperty("stateValue", true); // The button is now pressed (modified property)
fake->raiseCondition("Lid Closed", "Why not?"); // Since it's a LID we notify this change
fake->setProperty("hactar", 42); // We add a property
fake->removeProperty("hactar"); // We remove a property
// 3 property changes occurred in the device
QCOMPARE(m_changesList.count(), 3);
QStringList changes;
// First one is a property modification for "button.state"
changes = m_changesList.at(0);
QCOMPARE(changes.count(), 1);
QVERIFY(changes.contains("stateValue"));
// Second one is a property added for "hactar"
changes = m_changesList.at(1);
QCOMPARE(changes.count(), 1);
QVERIFY(changes.contains("hactar"));
// Third one is a property removed for "hactar"
changes = m_changesList.at(2);
QCOMPARE(changes.count(), 1);
QVERIFY(changes.contains("hactar"));
// Only one condition has been raised in the device
QCOMPARE(condition_raised.count(), 1);
// It must be identical to the condition we raised by hand
QCOMPARE(condition_raised.at(0).at(0).toString(), QString("Lid Closed"));
QCOMPARE(condition_raised.at(0).at(1).toString(), QString("Why not?"));
}
void SolidHwTest::testDeviceExistence() void SolidHwTest::testDeviceExistence()
{ {
QCOMPARE(Solid::Device("/org/kde/solid/fakehw/acpi_LID0").isValid(), true);
QCOMPARE(Solid::Device("/org/kde/solid/fakehw/volume_label_SOLIDMAN_BEGINS").isValid(), true); QCOMPARE(Solid::Device("/org/kde/solid/fakehw/volume_label_SOLIDMAN_BEGINS").isValid(), true);
// Note the extra space // Note the extra space
@ -267,7 +222,6 @@ void SolidHwTest::testDeviceInterfaceIntrospection_data()
QTest::newRow("DeviceInterface: NetworkInterface") << "NetworkInterface" << (int)Solid::DeviceInterface::NetworkInterface; QTest::newRow("DeviceInterface: NetworkInterface") << "NetworkInterface" << (int)Solid::DeviceInterface::NetworkInterface;
QTest::newRow("DeviceInterface: AcAdapter") << "AcAdapter" << (int)Solid::DeviceInterface::AcAdapter; QTest::newRow("DeviceInterface: AcAdapter") << "AcAdapter" << (int)Solid::DeviceInterface::AcAdapter;
QTest::newRow("DeviceInterface: Battery") << "Battery" << (int)Solid::DeviceInterface::Battery; QTest::newRow("DeviceInterface: Battery") << "Battery" << (int)Solid::DeviceInterface::Battery;
QTest::newRow("DeviceInterface: Button") << "Button" << (int)Solid::DeviceInterface::Button;
QTest::newRow("DeviceInterface: AudioInterface") << "AudioInterface" << (int)Solid::DeviceInterface::AudioInterface; QTest::newRow("DeviceInterface: AudioInterface") << "AudioInterface" << (int)Solid::DeviceInterface::AudioInterface;
QTest::newRow("DeviceInterface: Graphic") << "Graphic" << (int)Solid::DeviceInterface::Graphic; QTest::newRow("DeviceInterface: Graphic") << "Graphic" << (int)Solid::DeviceInterface::Graphic;
QTest::newRow("DeviceInterface: Input") << "Input" << (int)Solid::DeviceInterface::Input; QTest::newRow("DeviceInterface: Input") << "Input" << (int)Solid::DeviceInterface::Input;

View file

@ -40,7 +40,6 @@ private slots:
void testAllDevices(); void testAllDevices();
void testDeviceBasicFeatures(); void testDeviceBasicFeatures();
void testManagerSignals(); void testManagerSignals();
void testDeviceSignals();
void testDeviceExistence(); void testDeviceExistence();
void testDeviceInterfaceIntrospection_data(); void testDeviceInterfaceIntrospection_data();
void testDeviceInterfaceIntrospection(); void testDeviceInterfaceIntrospection();