Commit 0ce0091d authored by Dario Freddi's avatar Dario Freddi

Fix build and loading logic

parent 47c19228
......@@ -21,7 +21,7 @@ include(KDE4Defaults)
option(WITH_XINERAMA "Xinerama support for multi-headed X displays" ON)
find_package(Strigi)
find_package(UDev)
set_package_properties(Strigi PROPERTIES DESCRIPTION "Desktop indexing and search support"
URL "http://strigi.sourceforge.net"
TYPE REQUIRED
......@@ -68,6 +68,11 @@ set_package_properties(OpenGLES PROPERTIES DESCRIPTION "The OpenGLES libraries"
URL "http://www.khronos.org/opengles"
TYPE OPTIONAL
)
macro_optional_find_package(UDev)
set_package_properties(UDev PROPERTIES DESCRIPTION "The UDev Libraries"
TYPE OPTIONAL
PURPOSE "Allows support for UPower backend in PowerDevil - STRONGLY RECOMMENDED"
)
if(Q_WS_X11)
......
# - Try to find UDev
# Once done this will define
#
# UDEV_FOUND - system has UDev
# UDEV_INCLUDE_DIR - the libudev include directory
# UDEV_LIBS - The libudev libraries
# Copyright (c) 2010, Rafael Fernández López, <ereslibre@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
find_path(UDEV_INCLUDE_DIR libudev.h)
find_library(UDEV_LIBS udev)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(UDev DEFAULT_MSG UDEV_INCLUDE_DIR UDEV_LIBS)
mark_as_advanced(UDEV_INCLUDE_DIR UDEV_LIBS)
......@@ -3,45 +3,47 @@
########################## UPower Backend #####################################
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/backends/upower
${X11_INCLUDE_DIR}
${X11_Xrandr_INCLUDE_PATH})
set(powerdevilupowerbackend_SRCS
backends/upower/upowersuspendjob.cpp
backends/upower/login1suspendjob.cpp
backends/upower/powerdevilupowerbackend.cpp
backends/upower/xrandrbrightness.cpp
backends/upower/xrandrx11helper.cpp
backends/upower/udevqtclient.cpp
backends/upower/udevqtdevice.cpp
)
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/dbus/org.freedesktop.UPower.xml
${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/dbus/org.freedesktop.UPower.Device.xml
PROPERTIES NO_NAMESPACE TRUE)
qt4_add_dbus_interface(powerdevilupowerbackend_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/dbus/org.freedesktop.UPower.xml
upower_interface)
qt4_add_dbus_interface(powerdevilupowerbackend_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/dbus/org.freedesktop.UPower.Device.xml
upower_device_interface)
qt4_add_dbus_interface(powerdevilupowerbackend_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/dbus/org.freedesktop.UPower.KbdBacklight.xml
upower_kbdbacklight_interface)
set(powerdevilupowerbackend_LIBS ${X11_LIBRARIES} ${QT_QTGUI_LIBRARY} ${X11_Xrandr_LIB} ${KDE4_KDEUI_LIBRARY})
## backlight helper executable
kde4_add_executable(backlighthelper backends/upower/backlighthelper.cpp ${backlighthelper_mocs})
target_link_libraries(backlighthelper ${KDE4_KDECORE_LIBS})
install(TARGETS backlighthelper DESTINATION ${LIBEXEC_INSTALL_DIR})
kde4_install_auth_helper_files(backlighthelper org.kde.powerdevil.backlighthelper root)
kde4_install_auth_actions(org.kde.powerdevil.backlighthelper ${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/backlight_helper_actions.actions)
if (UDEV_FOUND)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/backends/upower
${X11_INCLUDE_DIR}
${X11_Xrandr_INCLUDE_PATH})
set(powerdevilupowerbackend_SRCS
backends/upower/upowersuspendjob.cpp
backends/upower/login1suspendjob.cpp
backends/upower/powerdevilupowerbackend.cpp
backends/upower/xrandrbrightness.cpp
backends/upower/xrandrx11helper.cpp
backends/upower/udevqtclient.cpp
backends/upower/udevqtdevice.cpp
)
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/dbus/org.freedesktop.UPower.xml
${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/dbus/org.freedesktop.UPower.Device.xml
PROPERTIES NO_NAMESPACE TRUE)
qt4_add_dbus_interface(powerdevilupowerbackend_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/dbus/org.freedesktop.UPower.xml
upower_interface)
qt4_add_dbus_interface(powerdevilupowerbackend_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/dbus/org.freedesktop.UPower.Device.xml
upower_device_interface)
qt4_add_dbus_interface(powerdevilupowerbackend_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/dbus/org.freedesktop.UPower.KbdBacklight.xml
upower_kbdbacklight_interface)
set(powerdevilupowerbackend_LIBS ${X11_LIBRARIES} ${QT_QTGUI_LIBRARY} ${X11_Xrandr_LIB} ${KDE4_KDEUI_LIBRARY} ${UDEV_LIBS})
## backlight helper executable
kde4_add_executable(backlighthelper backends/upower/backlighthelper.cpp ${backlighthelper_mocs})
target_link_libraries(backlighthelper ${KDE4_KDECORE_LIBS})
install(TARGETS backlighthelper DESTINATION ${LIBEXEC_INSTALL_DIR})
kde4_install_auth_helper_files(backlighthelper org.kde.powerdevil.backlighthelper root)
kde4_install_auth_actions(org.kde.powerdevil.backlighthelper ${CMAKE_CURRENT_SOURCE_DIR}/backends/upower/backlight_helper_actions.actions)
endif (UDEV_FOUND)
########################## HAL Backend #####################################
......
......@@ -92,5 +92,8 @@ target_link_libraries(powerdevilui
${QT_QTGUI_LIBRARY}
)
macro_bool_to_01(UDEV_FOUND HAVE_UDEV)
configure_file(config-powerdevil.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-powerdevil.h )
install(TARGETS powerdevilui ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES powerdevil.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded)
......@@ -116,7 +116,7 @@ void PowerDevilUPowerBackend::init()
m_kbdBacklight = new OrgFreedesktopUPowerKbdBacklightInterface(UPOWER_SERVICE, "/org/freedesktop/UPower/KbdBacklight", QDBusConnection::systemBus(), this);
m_brightnessControl = new XRandrBrightness();
if (!m_brightnessControl->isSupported()) {
qDebug() << "Using helper";
kDebug() << "Using helper";
KAuth::Action action("org.kde.powerdevil.backlighthelper.syspath");
action.setHelperID(HELPER_ID);
KAuth::ActionReply reply = action.execute();
......@@ -124,14 +124,14 @@ void PowerDevilUPowerBackend::init()
m_syspath = reply.data()["syspath"].toString();
m_syspath = QFileInfo(m_syspath).readLink();
}
UdevQt::Client *client = new UdevQt::Client(QStringList("backlight"), this);
connect(client, SIGNAL(deviceChanged(UdevQt::Device)), SLOT(onDeviceChanged(UdevQt::Device)));
} else {
qDebug() << "Using XRandR";
kDebug() << "Using XRandR";
m_randrHelper = new XRandRX11Helper();
connect(m_randrHelper, SIGNAL(brightnessChanged()), this, SLOT(slotScreenBrightnessChanged()));
}
m_randrHelper = new XRandRX11Helper();
UdevQt::Client *client = new UdevQt::Client(QStringList("backlight"), this);
connect(client, SIGNAL(deviceChanged(UdevQt::Device)), SLOT(deviceChanged(UdevQt::Device)));
connect(m_randrHelper, SIGNAL(brightnessChanged()), this, SLOT(slotScreenBrightnessChanged()));
// Capabilities
setCapabilities(SignalResumeFromSuspend);
......@@ -215,7 +215,7 @@ void PowerDevilUPowerBackend::init()
setBackendIsReady(controls, supported);
}
void PowerDevilUPowerBackend::deviceChanged(const UdevQt::Device &device)
void PowerDevilUPowerBackend::onDeviceChanged(const UdevQt::Device &device)
{
qDebug() << "Udev device changed";
qDebug() << m_syspath;
......@@ -337,6 +337,7 @@ bool PowerDevilUPowerBackend::setBrightness(float brightnessValue, PowerDevil::B
void PowerDevilUPowerBackend::slotScreenBrightnessChanged()
{
float newBrightness = brightness(Screen);
kDebug() << "Brightness changed!!";
if (!qFuzzyCompare(newBrightness, m_cachedBrightnessMap[Screen])) {
m_cachedBrightnessMap[Screen] = newBrightness;
onBrightnessChanged(Screen, m_cachedBrightnessMap[Screen]);
......
......@@ -69,7 +69,7 @@ private slots:
void slotPropertyChanged();
void slotLogin1Resuming(bool active);
void slotScreenBrightnessChanged();
void deviceChanged(const UdevQt::Device &device);
void onDeviceChanged(const UdevQt::Device &device);
private:
// upower devices
......
/* Defines if you have UDev */
#cmakedefine HAVE_UDEV 1
......@@ -23,6 +23,8 @@
#include "backends/upower/powerdevilupowerbackend.h"
#include "backends/hal/powerdevilhalbackend.h"
#include <config-powerdevil.h>
#include <KDebug>
namespace PowerDevil {
......@@ -30,6 +32,7 @@ namespace BackendLoader {
BackendInterface* loadBackend(QObject *parent)
{
#ifdef HAVE_UDEV
// Check UPower first
kDebug() << "Loading UPower backend...";
if (PowerDevilUPowerBackend::isAvailable()) {
......@@ -38,6 +41,7 @@ BackendInterface* loadBackend(QObject *parent)
}
kDebug() << "Failed!";
#endif
// If we are here, try HAL
kDebug() << "Loading HAL backend...";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment