summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.in.in14
-rw-r--r--src/configure_Dialog.ui2
-rw-r--r--src/dbusHAL.cpp671
-rw-r--r--src/dbusHAL.h55
-rw-r--r--src/detailed_Dialog.ui2
-rw-r--r--src/detaileddialog.cpp8
-rw-r--r--src/hardware.cpp781
-rw-r--r--src/hardware.h22
-rw-r--r--src/hardware_battery.cpp531
-rw-r--r--src/hardware_battery.h45
-rw-r--r--src/hardware_cpu.cpp33
-rw-r--r--src/hardware_cpu.h5
-rw-r--r--src/kpowersave.cpp91
-rw-r--r--src/kpowersave.h33
14 files changed, 625 insertions, 1668 deletions
diff --git a/configure.in.in b/configure.in.in
index 7cf2fb5..c2d1d4f 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -131,7 +131,7 @@ else
echo "enabled faked sysfs - proc environment: no"
fi
-pkg_modules="dbus-1 >= 0.6, hal >= 0.5.6"
+pkg_modules="dbus-1 >= 0.6"
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
# get dbus system bus socket
@@ -145,18 +145,6 @@ AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS_SOCKET, ["$DBUS_SYSTEM_BUS_SOCKET"],
[dbus system bus socket path])
-#check for PolicyKit version
-LIBHAL_POLICYCHECK=no
-AC_CHECK_LIB([hal], [libhal_device_is_caller_privileged], [LIBHAL_POLICYCHECK=yes], [LIBHAL_POLICYCHECK=no])
-if test "x$LIBHAL_POLICYCHECK" = "xyes"; then
- AC_DEFINE([USE_LIBHAL_POLICYCHECK],1,[Set if should use libhal to check policy.])
-fi
-
-#check for HAL version >= 0.5.10
-if $PKG_CONFIG --atleast-version 0.5.10 hal; then
- AC_DEFINE([HAVE_HAL_0_5_10],1,[Set if we use HAL >= 0.5.10])
-fi
-
# check for dbus qt bindings --> copied from KNetworkmanager
safe_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $PACKAGE_CFLAGS $all_includes"
diff --git a/src/configure_Dialog.ui b/src/configure_Dialog.ui
index 98f2dfb..fe27b0c 100644
--- a/src/configure_Dialog.ui
+++ b/src/configure_Dialog.ui
@@ -2163,7 +2163,7 @@
</connection>
<connection>
<sender>listBox_schemes</sender>
- <signal>currentChanged(QListBoxItem*)</signal>
+ <signal>currentChanged(TQListBoxItem*)</signal>
<receiver>configure_Dialog</receiver>
<slot>listBox_schemes_currentChanged()</slot>
</connection>
diff --git a/src/dbusHAL.cpp b/src/dbusHAL.cpp
index 4bac9c8..48686a3 100644
--- a/src/dbusHAL.cpp
+++ b/src/dbusHAL.cpp
@@ -42,9 +42,7 @@ dbusHAL::dbusHAL(){
kdDebugFuncIn(trace);
dbus_is_connected = false;
- hal_is_connected = false;
aquiredPolicyPower = false;
- hal_ctx = NULL;
// add pointer to this for filter_function()
myInstance=this;
@@ -53,8 +51,6 @@ dbusHAL::dbusHAL(){
kdError() << "Can't connect to D-Bus" << endl;
m_dBusQtConnection = NULL;
}
- if(!initHAL())
- kdError() << "Can't connect to HAL" << endl;
kdDebugFuncOut(trace);
}
@@ -80,16 +76,6 @@ bool dbusHAL::isConnectedToDBUS() {
}
/*!
- * This function return information about connection status to the HAL daemon.
- * \return boolean with the state of the connection to HAL
- * \retval true if connected
- * \retval false if disconnected
- */
-bool dbusHAL::isConnectedToHAL() {
- return hal_is_connected;
-}
-
-/*!
* This function return information if the org.freedesktop.Policy.Power
* interface was claimed.
* \return boolean with the status of claim the interface
@@ -107,12 +93,10 @@ bool dbusHAL::aquiredPolicyPowerInterface() {
* \retval false if unsuccessful
*/
bool dbusHAL::reconnect() {
- // free HAL context
- freeHAL();
// close D-Bus connection
close();
// init D-Bus conntection and HAL context
- return (initDBUS() && initHAL());
+ return (initDBUS());
}
/*!
@@ -176,20 +160,6 @@ bool dbusHAL::initDBUS(){
"interface='org.freedesktop.DBus',"
"member='NameOwnerChanged'", NULL);
- /* add a match rule to catch all signals going through the bus with HAL interface */
- dbus_bus_add_match( dbus_connection, "type='signal',"
- "interface='org.freedesktop.Hal.Manager',"
- "member='DeviceAdded'", NULL);
- dbus_bus_add_match( dbus_connection, "type='signal',"
- "interface='org.freedesktop.Hal.Manager',"
- "member='DeviceRemoved'", NULL);
- dbus_bus_add_match( dbus_connection, "type='signal',"
- "interface='org.freedesktop.Hal.Device',"
- "member='PropertyModified'", NULL);
- dbus_bus_add_match( dbus_connection, "type='signal',"
- "interface='org.freedesktop.Hal.Device',"
- "member='Condition'", NULL);
-
/* add a match rule to catch all signals going through the bus with ConsoleKit Interface */
dbus_bus_add_match( dbus_connection, "type='signal',"
"interface='org.freedesktop.ConsoleKit.Session',"
@@ -318,418 +288,7 @@ bool dbusHAL::isPolicyPowerIfaceOwned(){
}
/* ----> DBUS section :: END <---- */
-/* ----> HAL section :: START <---- */
-
-/*!
- * This function initialise the connection to HAL over the D-Bus daemon.
- * \return boolean with the result of the operation
- * \retval true if successful initialised HAL connection and context
- * \retval false if unsuccessful
- */
-bool dbusHAL::initHAL(){
- kdDebugFuncIn(trace);
-
- if ( !dbus_is_connected ) {
- freeHAL();
- return false;
- } else if ( hal_is_connected && (hal_ctx != NULL)) {
- return true;
- }
-
- // could not connect to HAL, reset all and try again
- freeHAL();
-
- DBusError error;
- dbus_error_init(&error);
-
- dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
- if (dbus_connection == NULL || dbus_error_is_set(&error)) {
- kdError() << "could not open connection to system bus: " << error.message << endl;
- dbus_error_free(&error);
- return false;
- }
-
- bool hal_is_ready = dbus_bus_name_has_owner(dbus_connection, "org.freedesktop.Hal", &error);
-
- if (!hal_is_ready) {
- kdWarning() << "HAL is not ready. We will try later... " << endl;
-
- if ( dbus_error_is_set( &error ) ) {
- kdError() << "Error checking if hal service exists: " << error.message << endl;
- dbus_error_free( &error );
- }
-
- freeHAL();
- return false;
- }
-
- if((hal_ctx = libhal_ctx_new()) == NULL) {
- kdError() << "Could not init HAL context" << endl;
- return false;
- }
-
- /* setup dbus connection for hal */
- if (!libhal_ctx_set_dbus_connection(hal_ctx, dbus_connection)) {
- kdError() << "Could not set up connection to dbus for hal" << endl;
- freeHAL();
- return false;
- }
-
- /* init the hal library */
- if (!libhal_ctx_init(hal_ctx, &error)) {
- kdError() << "Could not init hal library: " << error.message << endl;
- freeHAL();
- return false;
- }
-
- hal_is_connected = true;
-
- kdDebugFuncOut(trace);
- return hal_is_connected;
-}
-
-/*!
- * This function free the hal connection/context.
- */
-void dbusHAL::freeHAL(){
-
- if ( hal_ctx != NULL ) {
- libhal_ctx_free( hal_ctx );
- hal_ctx = NULL;
- }
- hal_is_connected = false;
-}
-
-/*!
- * This function try a reconnect to the HAL daemon only.
- * \return boolean with the result of the operation
- * \retval true if successful reconnected to HAL
- * \retval false if unsuccessful
- */
-bool dbusHAL::reconnectHAL() {
- // free HAL context
- freeHAL();
- // init HAL context
- return (initHAL());
-}
-
-/*!
- * This function query a integer property from HAL for a given device
- * \param udi TQString with the UDI of the device
- * \param property TQString with the property
- * \param returnval pointer to the return value
- * \return If the query was successful or not
- */
-bool dbusHAL::halGetPropertyInt(TQString udi, TQString property, int *returnval){
- kdDebugFuncIn(trace);
-
- bool ret = false;
-
- if (!initHAL() || udi.isEmpty() || property.isEmpty())
- goto out;
-
- DBusError error;
- dbus_error_init(&error);
-
- if (!libhal_device_property_exists(hal_ctx, udi.ascii(), property.ascii(), &error)) {
- kdWarning() << "Property: " << property << " for: " << udi << " doesn't exist." << endl;
- goto out;
- }
-
- *returnval = libhal_device_get_property_int(hal_ctx, udi.ascii(), property.ascii(), &error);
-
- if (dbus_error_is_set(&error)) {
- kdError() << "Fetching property: " << property << " for: " << udi
- << " failed with: " << error.message << endl;
- dbus_error_free(&error);
- goto out;
- } else {
- ret = true;
- }
-
-out:
- kdDebugFuncOut(trace);
- return true;
-}
-
-/*!
- * This function query a boolean property from HAL for a given device
- * \param udi TQString with the UDI of the device
- * \param property TQString with the property
- * \param returnval pointer to the return value
- * \return If the query was successful or not
- */
-bool dbusHAL::halGetPropertyBool(TQString udi, TQString property, bool *returnval){
- kdDebugFuncIn(trace);
-
- bool ret = false;
-
- if (!initHAL() || udi.isEmpty() || property.isEmpty())
- goto out;
-
- DBusError error;
- dbus_error_init(&error);
-
- if (!libhal_device_property_exists(hal_ctx, udi.ascii(), property.ascii(), &error)) {
- kdWarning() << "Property: " << property << " for: " << udi << " doesn't exist." << endl;
- goto out;
- }
-
- *returnval = libhal_device_get_property_bool(hal_ctx, udi.ascii(), property.ascii(), &error);
-
- if (dbus_error_is_set(&error)) {
- kdError() << "Fetching property: " << property << " for: " << udi
- << " failed with: " << error.message << endl;
- dbus_error_free(&error);
- goto out;
- } else {
- ret = true;
- }
-
-out:
- kdDebugFuncOut(trace);
- return ret;
-}
-
-
-/*!
- * This function query a Sting property from HAL for a given device
- * \param udi TQString with the UDI of the device
- * \param property TQString with the property
- * \param returnval pointer to the return value
- * \return If the query was successful or not
- */
-bool dbusHAL::halGetPropertyString(TQString udi, TQString property, TQString *returnval){
- kdDebugFuncIn(trace);
-
- bool ret = false;
-
- if (!initHAL() || udi.isEmpty() || property.isEmpty())
- goto out;
-
- DBusError error;
- dbus_error_init(&error);
-
- if (!libhal_device_property_exists(hal_ctx, udi.ascii(), property.ascii(), &error)) {
- kdWarning() << "Property: " << property << " for: " << udi << " doesn't exist." << endl;
- goto out;
- }
-
- *returnval = libhal_device_get_property_string(hal_ctx, udi.ascii(), property.ascii(), &error);
-
- if (dbus_error_is_set(&error)) {
- kdError() << "Fetching property: " << property << " for: " << udi
- << " failed with: " << error.message << endl;
- dbus_error_free(&error);
- goto out;
- } else {
- ret = true;
- }
-
-out:
- kdDebugFuncOut(trace);
- return ret;
-}
-
-/*!
- * This function query a String List property from HAL for a given device
- * \param udi TQString with the udi of the device
- * \param property TQString with the property to query
- * \param devices TQStringList to return the values
- * \return If the query was successful or not
- */
-bool dbusHAL::halGetPropertyStringList (TQString udi, TQString property, TQStringList *devices) {
- kdDebugFuncIn(trace);
-
- bool ret = false;
-
- if (!initHAL() || udi.isEmpty() || property.isEmpty())
- goto out;
-
- DBusError error;
- char ** found;
-
- dbus_error_init(&error);
-
- if (!libhal_device_property_exists(hal_ctx, udi.ascii(), property.ascii(), &error)) {
- kdWarning() << "Property: " << property << " for: " << udi << " doesn't exist." << endl;
- goto out;
- }
-
- found = libhal_device_get_property_strlist (hal_ctx, udi.ascii(), property.ascii(), &error);
-
- if (dbus_error_is_set(&error)) {
- kdWarning() << "Error while query existing strlist Property: " << property
- << " for: " << udi << " error: " << error.message << endl;
- dbus_error_free(&error);
- libhal_free_string_array(found);
- goto out;
- } else {
- for (int i = 0; found[i] != NULL ; ++i) {
- TQString _to_add = found[i];
- if (!_to_add.isEmpty()) *devices += _to_add;
- }
- libhal_free_string_array(found);
- ret = true;
- }
-
-out:
- kdDebugFuncOut(trace);
- return ret;
-}
-
-
-/*!
- * This function query a capability from HAL for a given device
- * \param udi TQString with the UDI of the device
- * \param capability TQString with the capability to query
- * \param returnval pointer to the return value as boolean
- * \return If the query was successful or not
- */
-bool dbusHAL::halQueryCapability(TQString udi, TQString capability, bool *returnval) {
- kdDebugFuncIn(trace);
-
- bool ret = false;
-
- if (!initHAL() || udi.isEmpty() || capability.isEmpty())
- goto out;
-
- DBusError error;
- dbus_error_init(&error);
-
- *returnval = libhal_device_query_capability(hal_ctx, udi.ascii(), capability.ascii(), &error);
- if (dbus_error_is_set(&error)) {
- kdError() << "Fetching capability: " << capability << " for: " << udi
- << " failed with: " << error.message << endl;
- dbus_error_free(&error);
- goto out;
- } else {
- ret = true;
- }
-
-out:
- kdDebugFuncOut(trace);
- return ret;
-}
-
-/*!
- * Use this function to check if a device has a specia property/key.
- * \param udi TQString with the UDI of the device
- * \param property TQString with the property
- * \return If the query was successful or not
- */
-bool dbusHAL::halDevicePropertyExist(TQString udi, TQString property ) {
- kdDebugFuncIn(trace);
-
- bool ret = false;
-
- if (!initHAL() || udi.isEmpty() || property.isEmpty())
- goto out;
-
- DBusError error;
- dbus_error_init(&error);
-
- if (! libhal_device_property_exists (hal_ctx, udi.ascii(), property.ascii(), &error)) {
- if (dbus_error_is_set(&error)) {
- kdError() << "Fetching existing property: " << property << " for: " << udi
- << " failed with: " << error.message << endl;
- dbus_error_free(&error);
- }
- goto out;
- } else {
- ret = true;
- }
-
-out:
- kdDebugFuncOut(trace);
- return ret;
-}
-
-/*!
- * Use this function to search find devices with a give capability
- * \param capability TQString with the capability to query
- * \param devices TQStringList to return the found devices
- * \return If the query was successful or not
- */
-bool dbusHAL::halFindDeviceByCapability (TQString capability, TQStringList *devices) {
- kdDebugFuncIn(trace);
-
- DBusError error;
- char ** found;
- int num = 0;
- bool ret = false;
-
- if (!initHAL() || capability.isEmpty())
- goto out;
-
- dbus_error_init(&error);
-
- found = libhal_find_device_by_capability (hal_ctx, capability.ascii(), &num, &error);
-
- if (dbus_error_is_set(&error)) {
- kdError() << "Could not get list of devices with capability: " << capability
- << " error: " << error.message << endl;
- dbus_error_free(&error);
- libhal_free_string_array(found);
- goto out;
- } else {
- for (int i = 0; i < num; ++i) {
- TQString _to_add = found[i];
- if (!_to_add.isEmpty()) *devices += _to_add;
- }
- libhal_free_string_array(found);
- ret = true;
- }
-
-out:
- kdDebugFuncOut(trace);
- return ret;
-}
-
-/*!
- * Use this function to search find devices with a special string property
- * \param property TQString with the name of the property
- * \param keyval TQString with value of the string property
- * \param devices TQStringList to return the found devices
- * \return If the query was successful or not
- */
-bool dbusHAL::halFindDeviceByString (TQString property, TQString keyval, TQStringList *devices) {
- kdDebugFuncIn(trace);
-
- DBusError error;
- char ** found;
- int num = 0;
- bool ret = false;
-
- if (!initHAL() || property.isEmpty() || keyval.isEmpty())
- goto out;
-
- dbus_error_init(&error);
-
- found = libhal_manager_find_device_string_match (hal_ctx, property.ascii(), keyval.ascii(), &num, &error);
-
- if (dbus_error_is_set(&error)) {
- kdError() << "Could not get list of devices with key: " << property
- << "and string value: " << keyval << " error: " << error.message << endl;
- dbus_error_free(&error);
- libhal_free_string_array(found);
- goto out;
- } else {
- for (int i = 0; i < num; ++i) {
- TQString _to_add = found[i];
- if (!_to_add.isEmpty()) *devices += _to_add;
- }
- libhal_free_string_array(found);
- ret = true;
- }
-
-out:
- kdDebugFuncOut(trace);
- return ret;
-}
-
-/* ----> HAL section :: END <---- */
/* ----> D-Bus methode calls functions :: START <---- */
/*!
* This function call a D-Bus method
@@ -868,102 +427,6 @@ out:
return ret;
}
-/*!
- * Function to call a suspend and call if resumed \ref callBackSuspend()
- * to emit a resume signal.
- * \param suspend a char pointer with the name of the suspend interface
- * \return If the query was successful or not
- */
-bool dbusHAL::dbusMethodCallSuspend ( const char *suspend ) {
- kdDebugFuncIn(trace);
-
- DBusMessage *message;
- DBusError error;
- DBusPendingCall* pcall = NULL;
- bool ret = false;
-
- dbus_error_init(&error);
- dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
-
- if (dbus_error_is_set(&error)) {
- kdError() << "Could not get dbus connection: " << error.message << endl;
- dbus_error_free(&error);
- goto out;
- }
-
- message = dbus_message_new_method_call( HAL_SERVICE, HAL_COMPUTER_UDI, HAL_PM_IFACE, suspend);
- if (strcmp( suspend, "Suspend") == 0) {
- int wake_up = 0;
- dbus_message_append_args (message, DBUS_TYPE_INT32, &wake_up, DBUS_TYPE_INVALID);
- }
-
- if (message) {
- // need to set INT_MAX as default and not -1
- dbus_connection_send_with_reply (dbus_connection, message, &pcall, INT_MAX);
- if (pcall) {
- dbus_pending_call_ref (pcall); // really needed?
- dbus_pending_call_set_notify (pcall, dbusHAL::callBackSuspend, NULL, NULL);
- }
- dbus_message_unref (message);
- ret = true;
- }
-
-out:
- kdDebugFuncOut(trace);
- return ret;
-}
-
-/*!
- * Slot called by D-Bus as set in \ref dbusMethodCallSuspend()
- * Here we emit the resume signal.
- */
-void dbusHAL::callBackSuspend (DBusPendingCall* pcall, void* /*data*/) {
- kdDebugFuncIn(trace);
-
- DBusMessage* reply = NULL;
- DBusError error;
- int result;
- bool failed = false;
-
- if (!pcall) {
- kdError() << "dbusHAL::callBackSuspend - DBusPendingCall not set, return" << endl;
- kdDebugFuncOut(trace);
- return;
- }
-
- reply = dbus_pending_call_steal_reply (pcall);
- if (reply == NULL) {
- kdError() << "dbusHAL::callBackSuspend - Got no reply, return" << endl;
- goto out;
- }
-
- dbus_error_init(&error);
-
- if (!dbus_message_get_args (reply, &error, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID)) {
- if (dbus_error_is_set(&error)) {
- kdError() << "Could not get argument from reply: " << error.message << endl;
- dbus_error_free(&error);
- }
-
- kdWarning() << "dbusHAL::callBackSuspend dbus_message_get_args failed, maybe timouted" << endl;
- failed = true;
- }
-
- dbus_message_unref (reply);
-
-out:
- dbus_pending_call_unref (pcall);
-
- if (failed)
- emit ((dbusHAL*) myInstance)->backFromSuspend( -1 );
- else
- emit ((dbusHAL*) myInstance)->backFromSuspend( result );
-
- kdDebugFuncOut(trace);
- return;
-}
-
-
/* ----> D-Bus methode calls functions :: END <---- */
/* ---> PolicyKit method call section :: START <--- */
@@ -998,38 +461,6 @@ int dbusHAL::isUserPrivileged(TQString privilege, TQString udi, TQString ressour
_unique_name = dbus_bus_get_unique_name(dbus_connection);
_privilege = privilege.latin1();
-#ifdef USE_LIBHAL_POLICYCHECK
- DBusError error;
- char *result;
-
- if (udi.isEmpty()) {
- kdError() << "No UDI given ... could not lookup privileges" << endl;
- goto out;
- }
- if (!hal_is_connected) {
- kdError() << "HAL not running, could not call libhal for lookup privileges" << endl;
- goto out;
- }
-
- dbus_error_init(&error);
- result = libhal_device_is_caller_privileged ( hal_ctx, udi.latin1(), _privilege, _unique_name, &error);
-
- if ( dbus_error_is_set( &error ) ) {
- kdWarning() << "Error while lookup privileges: " << error.message << endl;
- dbus_error_free( &error );
- retval = -1;
- } else {
- if (!strcmp(result, "yes")) {
- retval = 1;
- } else if (!strcmp(result, "no")) {
- retval = 0;
- } else {
- retval = -1;
- }
- }
-
- libhal_free_string(result);
-#else
// not sure if we need this, but to avoid problems
dbus_bool_t _retval;
const char *_ressource;
@@ -1049,7 +480,6 @@ int dbusHAL::isUserPrivileged(TQString privilege, TQString udi, TQString ressour
} else {
retval = (int) _retval;
}
-#endif
out:
kdDebugFuncOut(trace);
@@ -1157,22 +587,7 @@ filterFunction (DBusConnection *connection, DBusMessage *message, void */*data*/
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &service,
DBUS_TYPE_STRING, &old_owner,
DBUS_TYPE_STRING, &new_owner, DBUS_TYPE_INVALID)) {
- if (!strcmp(service, "org.freedesktop.Hal")) {
- if (!strcmp(new_owner, "") && strcmp(old_owner, "")) {
- // Hal service stopped.
- kdDebug() << "=== org.freedesktop.Hal terminated ===" << endl;
- ((dbusHAL*) myInstance)->emitMsgReceived( DBUS_EVENT,
- "hal.terminate",
- NULL );
- }
- else if (!strcmp(old_owner, "") && strcmp(new_owner, "")) {
- // Hal service started.
- kdDebug() << "=== org.freedesktop.Hal started ===" << endl;
- ((dbusHAL*) myInstance)->emitMsgReceived( DBUS_EVENT,
- "hal.started",
- NULL );
- }
- } else if (!strcmp(service, "org.freedesktop.Policy.Power")) {
+ if (!strcmp(service, "org.freedesktop.Policy.Power")) {
const char *own_name;
own_name = dbus_bus_get_unique_name(((dbusHAL*) myInstance)->get_DBUS_connection());
@@ -1195,88 +610,6 @@ filterFunction (DBusConnection *connection, DBusMessage *message, void */*data*/
}
kdDebugFuncOut(trace);
return DBUS_HANDLER_RESULT_HANDLED;
- } else if (ifaceType.startsWith("org.freedesktop.Hal.Manager")) {
- kdDebug() << "Received from org.freedesktop.Hal.Manager" << endl;
- char *udi;
-
- const char *signal = dbus_message_get_member( message );
- /* get the first argument. This must be a string at the moment */
- dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &value, DBUS_TYPE_INVALID );
-
- if ( dbus_error_is_set( &error ) ) {
- kdWarning() << "Received signal, but no string argument: " << error.message << endl;
- dbus_error_free( &error );
- kdDebugFuncOut(trace);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- if (dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &udi, DBUS_TYPE_INVALID )) {
- if (! strcmp(signal, "DeviceRemoved") || ! strcmp(signal, "DeviceAdded")) {
- ((dbusHAL*) myInstance)->emitMsgReceived( HAL_DEVICE, signal, udi );
- kdDebug() << "org.freedesktop.Hal.Manager: uid: " << udi
- << " signal: " << signal << endl;
- } else {
- kdWarning() << "Received unknown signal from org.freedesktop.Hal.Manager: "
- << signal << endl;
- }
- }
- kdDebugFuncOut(trace);
- return DBUS_HANDLER_RESULT_HANDLED;
-
- } else if (ifaceType.startsWith("org.freedesktop.Hal.Device")) {
- const char *udi = dbus_message_get_path (message);
- const char *signal = dbus_message_get_member( message );
-
- /* Code taken from libhal */
- if (! strcmp(signal, "PropertyModified")) {
- if (trace) kdDebug() << "-------- PropertyModified ------" << endl;
- int i, num_modifications;
- DBusMessageIter iter;
- DBusMessageIter iter_array;
-
- dbus_message_iter_init (message, &iter);
- dbus_message_iter_get_basic (&iter, &num_modifications);
- dbus_message_iter_next (&iter);
-
- dbus_message_iter_recurse (&iter, &iter_array);
-
- for (i = 0; i < num_modifications; i++) {
- dbus_bool_t removed, added;
- char *key;
- DBusMessageIter iter_struct;
-
- dbus_message_iter_recurse (&iter_array, &iter_struct);
-
- dbus_message_iter_get_basic (&iter_struct, &key);
- dbus_message_iter_next (&iter_struct);
- dbus_message_iter_get_basic (&iter_struct, &removed);
- dbus_message_iter_next (&iter_struct);
- dbus_message_iter_get_basic (&iter_struct, &added);
-
- /* don't check if we really need this device, check this in an other class */
- ((dbusHAL*) myInstance)->emitMsgReceived( HAL_PROPERTY_CHANGED, udi, key);
- kdDebug() << "PropertyModified: uid: " << udi << " key: " << key << endl;
-
- dbus_message_iter_next (&iter_array);
- }
- } else if (! strcmp(signal, "Condition")) {
- if (trace) kdDebug() << "-------- Condition ------" << endl;
- char *name, *detail;
-
- dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &value, DBUS_TYPE_INVALID );
-
- if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &name,
- DBUS_TYPE_STRING, &detail, DBUS_TYPE_INVALID)) {
- ((dbusHAL*) myInstance)->emitMsgReceived( HAL_CONDITION, name, detail );
- } else {
- if (dbus_error_is_set( &error )) dbus_error_free( &error );
- }
- } else {
- kdDebug() << "Received unknown signal from org.freedesktop.Hal.Device: "
- << signal << endl;
- }
- kdDebugFuncOut(trace);
- return DBUS_HANDLER_RESULT_HANDLED;
} else if (ifaceType.startsWith("org.freedesktop.ConsoleKit.Session")) {
kdDebug() << "Received from org.freedesktop.ConsoleKit.Session" << endl;
diff --git a/src/dbusHAL.h b/src/dbusHAL.h
index d3a3754..9a2e613 100644
--- a/src/dbusHAL.h
+++ b/src/dbusHAL.h
@@ -48,17 +48,9 @@
#include <dbus/message.h>
#include <dbus/connection.h>
-// HAL Library
-#include <hal/libhal.h>
-
// kpowersave - Header
#include "kpowersave_debug.h"
-#define HAL_SERVICE "org.freedesktop.Hal"
-#define HAL_PM_IFACE "org.freedesktop.Hal.Device.SystemPowerManagement"
-#define HAL_LPANEL_IFACE "org.freedesktop.Hal.Device.LaptopPanel"
-#define HAL_CPUFREQ_IFACE "org.freedesktop.Hal.Device.CPUFreq"
-#define HAL_COMPUTER_UDI "/org/freedesktop/Hal/devices/computer"
#define CK_SERVICE "org.freedesktop.ConsoleKit"
#define CK_MANAGER_IFACE "org.freedesktop.ConsoleKit.Manager"
#define CK_MANAGER_OBJECT "/org/freedesktop/ConsoleKit/Manager"
@@ -84,8 +76,6 @@ private:
DBusQt::Connection* m_dBusQtConnection;
//! real connection to D-Bus
DBusConnection *dbus_connection;
- //! HAL context
- LibHalContext *hal_ctx;
//! to store information if KPowersave is connected to D-Bus
/*!
@@ -94,13 +84,6 @@ private:
* \li false: if disconnected
*/
bool dbus_is_connected;
- //! to store information if KPowersave is connected to HAL
- /*!
- * This boolean represent information about the state of the connection to HAL
- * \li true: if connected
- * \li false: if disconnected
- */
- bool hal_is_connected;
//! if we could claim the org.freedesktop.Policy.Power interface
/*!
@@ -119,15 +102,6 @@ private:
DBusBusType dbus_type, void *retvalue, int retval_type,
int first_arg_type, va_list var_args);
- //! function to be called back by DBusPendingCall::dbus_pending_call_set_notify()
- static void callBackSuspend (DBusPendingCall* pcall, void* /*data*/);
-
- /* HAL helper functions */
- //! to initialise the connection to HAL
- bool initHAL();
- //! to free the HAL context
- void freeHAL();
-
public:
//! default constructor
@@ -137,8 +111,6 @@ public:
//! to reconnect to D-Bus and HAL
bool reconnect();
- //! to reconnect only HAL
- bool reconnectHAL();
//! to close the connection to D-Bus and HAL
bool close();
@@ -152,36 +124,12 @@ public:
// --- helper to get private members of the class --- //
//! to get information if KPowersave is connected to D-Bus
bool isConnectedToDBUS();
- //! to get information if KPowersave is connected to HAL
- bool isConnectedToHAL();
//! to get info about claim org.freedesktop.Policy.Power interface
bool aquiredPolicyPowerInterface();
- //! return the current HAL context
- LibHalContext *get_HAL_context();
//! return the current DBus connection
DBusConnection *get_DBUS_connection();
- /* HAL device information stuff */
- //! Query a integer device property from HAL
- bool halGetPropertyInt(TQString udi, TQString property, int *returnval);
- //! Query a bolean device property from HAL
- bool halGetPropertyBool(TQString udi, TQString property, bool *returnval);
- //! Query a string device property from HAL
- bool halGetPropertyString(TQString udi, TQString property, TQString *returnval);
- //! Query a string list device property from HAL
- bool halGetPropertyStringList (TQString udi, TQString property, TQStringList *devices);
- //! Query a capability for a HAL device
- bool halQueryCapability(TQString udi, TQString capability, bool *returnval);
-
- /* functions to find devices and check stuff */
- //! check if a property exist on a device
- bool halDevicePropertyExist(TQString udi, TQString property);
- //! to find a device by capability
- bool halFindDeviceByCapability (TQString capability, TQStringList *devices);
- //! to find a device by a string property
- bool halFindDeviceByString (TQString property, TQString keyval, TQStringList *devices);
-
/* D-Bus helper functions */
/* functions to call methodes */
@@ -192,9 +140,6 @@ public:
bool dbusSystemMethodCall( TQString interface, TQString path, TQString object, TQString method,
void *retvalue, int retval_type, int first_arg_type, ... );
- //! to call a suspend method on HAL
- bool dbusMethodCallSuspend ( const char *suspend );
-
/* PolicyKit call helper */
//! check if the user has a requested privilege
int isUserPrivileged( TQString privilege, TQString udi, TQString ressource = "", TQString user = TQString());
diff --git a/src/detailed_Dialog.ui b/src/detailed_Dialog.ui
index 46309ff..cb2eac8 100644
--- a/src/detailed_Dialog.ui
+++ b/src/detailed_Dialog.ui
@@ -341,7 +341,7 @@
<cstring>tl_powerConsDesc</cstring>
</property>
<property name="text">
- <string>Power Consumtion: </string>
+ <string>Power Consumption: </string>
</property>
</widget>
<widget class="TQLabel">
diff --git a/src/detaileddialog.cpp b/src/detaileddialog.cpp
index a8cc129..40ae521 100644
--- a/src/detaileddialog.cpp
+++ b/src/detaileddialog.cpp
@@ -479,12 +479,12 @@ void detaileddialog::setInfos() {
displayValue += i18n("no") + "\n";
}
- display += i18n("HAL Daemon:");
- displayValue += i18n("running");
+ display += i18n("TDE hardware subsystem:");
+ displayValue += i18n("active");
}
else {
- display += i18n("HAL Daemon:");
- displayValue += i18n("not running");
+ display += i18n("TDE hardware subsystem:");
+ displayValue += i18n("not available");
}
if(!display.isEmpty())
diff --git a/src/hardware.cpp b/src/hardware.cpp
index ab65969..227c7a5 100644
--- a/src/hardware.cpp
+++ b/src/hardware.cpp
@@ -31,6 +31,9 @@
#include <tqtimer.h>
#include <tqdir.h>
+// keycode definitions
+#include <linux/input.h>
+
// include own header
#include "hardware.h"
#include "kpowersave_debug.h"
@@ -43,14 +46,17 @@ HardwareInfo::HardwareInfo() {
// init members
acadapter = true;
lidclose = false;
- dbus_terminated = true;
- hal_terminated = true;
laptop = false;
brightness = false;
brightness_in_hardware = false;
schedPowerSavings = false;
sessionIsActive = true; // assume as first we are active
+ // initialize connection to the TDE hardware library
+ m_hwdevices = KGlobal::hardwareDevices();
+ connect(m_hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(processHardwareChangedEvent(TDEGenericDevice*)));
+ connect(m_hwdevices, TQT_SIGNAL(eventDeviceKeyPressed(unsigned int, TDEEventDevice*)), this, TQT_SLOT(processKeyPressEvent(unsigned int, TDEEventDevice*)));
+
// update everything the first time
update_info_ac_changed = true;
update_info_cpufreq_policy_changed = true;
@@ -72,11 +78,6 @@ HardwareInfo::HardwareInfo() {
dbus_HAL = new dbusHAL();
if (dbus_HAL->isConnectedToDBUS()) {
dbus_terminated = false;
- if (dbus_HAL->isConnectedToHAL()) {
- hal_terminated = false;
- } else {
- kdError() << "Could not connect to HAL" << endl;
- }
} else {
kdError() << "Could not connect to D-Bus & HAL" << endl;
}
@@ -92,11 +93,6 @@ HardwareInfo::HardwareInfo() {
updatePrimaryBatteries();
- // connect to signals
- connect(dbus_HAL, TQT_SIGNAL(msgReceived_withStringString( msg_type, TQString, TQString )),
- this, TQT_SLOT(processMessage( msg_type, TQString, TQString )));
- connect(dbus_HAL, TQT_SIGNAL(backFromSuspend(int)), this, TQT_SLOT(handleResumeSignal(int)));
-
kdDebugFuncOut(trace);
}
@@ -104,40 +100,6 @@ HardwareInfo::HardwareInfo() {
HardwareInfo::~HardwareInfo() {
kdDebugFuncIn(trace);
- delete dbus_HAL;
- dbus_HAL = NULL;
-
- kdDebugFuncOut(trace);
-}
-
-/*!
- * This funtion is used to handle the reconnect to the D-Bus daemon
- */
-void HardwareInfo::reconnectDBUS() {
- kdDebugFuncIn(trace);
-
- if (!dbus_HAL->isConnectedToDBUS()) {
- bool _reconnect = dbus_HAL->reconnect();
-
- if (!_reconnect && !dbus_HAL->isConnectedToDBUS()) {
- //reconnect failed
- emit dbusRunning(DBUS_NOT_RUNNING);
- TQTimer::singleShot(4000, this, TQT_SLOT(reconnectDBUS()));
- } else if (!_reconnect && dbus_HAL->isConnectedToDBUS()) {
- // reset everything, we are reconnected
- dbus_terminated = false;
- hal_terminated = true;
- emit dbusRunning(DBUS_RUNNING);
- } else if (_reconnect) {
- // reset everything, we are reconnected
- dbus_terminated = false;
- hal_terminated = false;
- reinitHardwareInfos();
- emit dbusRunning(hal_terminated);
- emit halRunning(DBUS_RUNNING);
- }
- }
-
kdDebugFuncOut(trace);
}
@@ -150,43 +112,101 @@ void HardwareInfo::reconnectDBUS() {
bool HardwareInfo::reinitHardwareInfos () {
kdDebugFuncIn(trace);
- if (dbus_HAL->isConnectedToDBUS() && dbus_HAL->isConnectedToHAL()) {
- /* first cleanup */
- acadapter = true;
- lidclose = false;
- laptop = false;
- brightness = false;
- has_APM = false;
- has_ACPI = false;
+ /* first cleanup */
+ acadapter = true;
+ lidclose = false;
+ laptop = false;
+ brightness = false;
+ has_APM = false;
+ has_ACPI = false;
+
+ update_info_ac_changed = true;
+ update_info_cpufreq_policy_changed = true;
+ update_info_primBattery_changed = true;
- update_info_ac_changed = true;
- update_info_cpufreq_policy_changed = true;
- update_info_primBattery_changed = true;
-
- allUDIs = TQStringList();
+ allUDIs = TQStringList();
- BatteryList.clear();
- primaryBatteries = new BatteryCollection(BAT_PRIMARY);
+ BatteryList.clear();
+ primaryBatteries = new BatteryCollection(BAT_PRIMARY);
- // check the current desktop session again
- checkConsoleKitSession();
-
- /* reinit hardware data */
- checkPowermanagement();
- checkIsLaptop();
- checkBrightness();
- checkCPUFreq();
- checkSuspend();
- intialiseHWInfo();
- // getSchedPowerSavings();
- updatePrimaryBatteries();
-
- kdDebugFuncOut(trace);
- return true;
+ /* reinit hardware data */
+ checkPowermanagement();
+ checkIsLaptop();
+ checkBrightness();
+ checkCPUFreq();
+ checkSuspend();
+ intialiseHWInfo();
+ // getSchedPowerSavings();
+ updatePrimaryBatteries();
+
+ kdDebugFuncOut(trace);
+ return true;
+}
+
+/*!
+ * This funtion is used to parse changed hardware nofifications from the TDE hardware library
+ * \param device a \ref TDEGenericDevice* which should be processed
+ */
+void HardwareInfo::processHardwareChangedEvent (TDEGenericDevice* device) {
+ kdDebugFuncIn(trace);
+
+ if (allUDIs.contains( device->uniqueID() )) {
+ if (device->type() == TDEGenericDeviceType::PowerSupply) {
+ TQTimer::singleShot(50, this, TQT_SLOT(checkACAdapterState()));
+ } else if (device->type() == TDEGenericDeviceType::Battery) {
+ // this is a battery event
+ updateBatteryValues(device);
+ } else if (device->type() == TDEGenericDeviceType::Event) {
+ TDEEventDevice* edevice = dynamic_cast<TDEEventDevice*>(device);
+ if (edevice) {
+ if (edevice->eventType() == TDEEventDeviceType::ACPILidSwitch) {
+ TQTimer::singleShot(50, this, TQT_SLOT(checkLidcloseState()));
+ }
+ }
+ } else if (device->type() == TDEGenericDeviceType::Backlight) {
+ TQTimer::singleShot(50, this, TQT_SLOT(checkBrightness()));
+ }
+ // TODO: add needed code
} else {
- kdDebugFuncOut(trace);
- return false;
+ kdDebug() << "unmonitored device changed: " << device->uniqueID() << endl;
}
+
+ kdDebugFuncOut(trace);
+}
+
+/*!
+ * This funtion is used to parse changed hardware nofifications from the TDE hardware library
+ * \param keycode a keycode which should be processed
+ * \param edevice the \ref TDEEventDevice* from whence the keypress originated
+ */
+void HardwareInfo::processKeyPressEvent(unsigned int keycode, TDEEventDevice* edevice) {
+ kdDebugFuncIn(trace);
+
+ // FIXME
+ // How can I get specific button press/release information (instead of just "something happened to the button") from the TDE hardware library?
+ // FIXME
+ // How are sleep buttons normally handled? On my Thinkpad pressing Fn+Sleep doesn't generate an event from the ACPI sleep button event device...
+ // TODO: Check if we really need to monitor this events. We get maybe also
+ // HAL_PROPERTY_CHANGED event for the key
+// if (message.startsWith("ButtonPressed")) {
+ kdDebug() << "ButtonPressed event from TDE HW library " << endl;
+ if ((edevice->eventType() == TDEEventDeviceType::ACPIPowerButton) && (keycode == KEY_POWER)) {
+ TQTimer::singleShot(50, this, TQT_SLOT(emitPowerButtonPressed()));
+ } else if ((edevice->eventType() == TDEEventDeviceType::ACPISleepButton) && (keycode == KEY_SLEEP)) {
+ TQTimer::singleShot(50, this, TQT_SLOT(emitSleepButtonPressed()));
+// } else if (value.startsWith("hibernate")) {
+// TQTimer::singleShot(50, this, TQT_SLOT(emitS2diskButtonPressed()));
+// } else if (value.startsWith("brightness-")) {
+// if (!brightness_in_hardware && value.endsWith("-up"))
+// TQTimer::singleShot(50, this, TQT_SLOT(brightnessUpPressed()));
+// else if (!brightness_in_hardware && value.endsWith("-down"))
+// TQTimer::singleShot(50, this, TQT_SLOT(brightnessDownPressed()));
+ }
+// } else {
+// kdDebug() << "Unmonitored HAL_CONDITION: " << message << " : " << value << endl;
+// }
+
+ kdDebugFuncOut(trace);
}
/*!
@@ -203,29 +223,6 @@ void HardwareInfo::processMessage (msg_type type, TQString message, TQString val
case ACPI_EVENT:
// we don't handle acpi events here atm
break;
- case DBUS_EVENT:
- kdDebug() << "D-Bus Event: " << value << endl;
- if ( message.startsWith("dbus.terminate")){
- // TODO: addapt from pdaemon
- dbus_terminated = true;
- TQTimer::singleShot(4000, this, TQT_SLOT(reconnectDBUS()));
- }
- else if ( message.startsWith("hal.")) {
- if ( message.startsWith("hal.terminate")) {
- hal_terminated = true;
- emit halRunning(false);
- // TODO: update data
- emit generalDataChanged();
- } else if ( message.startsWith("hal.started")) {
- hal_terminated = false;
- reinitHardwareInfos();
- emit halRunning( true );
- // TODO: update data
- emit generalDataChanged();
- }
- // TODO: addapt from pdaemon
- }
- break;
case HAL_DEVICE:
// --> we can maybe ignore these events except for batteries, not shure atm
int _type;
@@ -275,50 +272,6 @@ void HardwareInfo::processMessage (msg_type type, TQString message, TQString val
kdDebug() << "Unknown HAL_DEVICE message: " << message << endl;
}
break;
- case HAL_PROPERTY_CHANGED:
- if (!message.isEmpty() && allUDIs.contains( message )) {
- if (value.startsWith( "ac_adapter.present" )) {
- TQTimer::singleShot(50, this, TQT_SLOT(checkACAdapterState()));
- } else if (value.startsWith( "battery." )) {
- // this is a battery event
- updateBatteryValues(message, value);
- } else if (value.startsWith( "button.state.value" )) {
- if (message.startsWith( *udis["lidclose"] )) {
- TQTimer::singleShot(50, this, TQT_SLOT(checkLidcloseState()));
- }
- } else if (value.startsWith( "laptop_panel")) {
- if (message.startsWith( *udis["laptop_panel"] )) {
- TQTimer::singleShot(50, this, TQT_SLOT(checkBrightness()));
- }
- }
- // TODO: add needed code
- } else {
- kdDebug() << "HAL_PROPERTY_CHANGED for unmonitored device: " << value << endl;
- }
- break;
- case HAL_CONDITION:
- // TODO: Check if we really need to monitor this events. We get maybe also
- // HAL_PROPERTY_CHANGED event for the key
- if (message.startsWith("ButtonPressed")) {
- kdDebug() << "ButtonPressed event from HAL: " << value << endl;
- if (value.startsWith("lid")) {
- TQTimer::singleShot(50, this, TQT_SLOT(checkLidcloseState()));
- } else if (value.startsWith("power")) {
- TQTimer::singleShot(50, this, TQT_SLOT(emitPowerButtonPressed()));
- } else if (value.startsWith("sleep") || value.startsWith("suspend")) {
- TQTimer::singleShot(50, this, TQT_SLOT(emitSleepButtonPressed()));
- } else if (value.startsWith("hibernate")) {
- TQTimer::singleShot(50, this, TQT_SLOT(emitS2diskButtonPressed()));
- } else if (value.startsWith("brightness-")) {
- if (!brightness_in_hardware && value.endsWith("-up"))
- TQTimer::singleShot(50, this, TQT_SLOT(brightnessUpPressed()));
- else if (!brightness_in_hardware && value.endsWith("-down"))
- TQTimer::singleShot(50, this, TQT_SLOT(brightnessDownPressed()));
- }
- } else {
- kdDebug() << "Unmonitored HAL_CONDITION: " << message << " : " << value << endl;
- }
- break;
case CONSOLEKIT_SESSION_ACTIVE:
if (!message.isEmpty() && !value.isEmpty()) {
if (message == consoleKitSession) {
@@ -426,7 +379,6 @@ bool HardwareInfo::checkConsoleKitSession () {
return retval;
}
-
/*!
* This function check for a given UDI, if we should handle a device
* \param _udi TQString with the UDI of the device
@@ -440,18 +392,21 @@ bool HardwareInfo::checkIfHandleDevice ( TQString _udi, int *type) {
TQStringList _cap;
bool ret = true;
+
+ TDEGenericDevice* hwdevice = m_hwdevices->findByUniqueID(_udi);
- if (dbus_HAL->halGetPropertyStringList( _udi, "info.capabilities", &_cap) && !_cap.isEmpty()) {
- if (_cap.contains("ac_adapter")) {
+ if (hwdevice) {
+ TDEGenericDeviceType::TDEGenericDeviceType devtype = hwdevice->type();
+ if (devtype == TDEGenericDeviceType::PowerSupply) {
*type = BATTERY;
- } else if (_cap.contains("button")) {
- TQString _val;
- if (dbus_HAL->halGetPropertyString( _udi, "button.type", &_val)) {
- if (_val.startsWith("lid")) {
+ } else if (devtype == TDEGenericDeviceType::Event) {
+ TDEEventDevice* edevice = dynamic_cast<TDEEventDevice*>(hwdevice);
+ if (edevice) {
+ if (edevice->eventType() == TDEEventDeviceType::ACPILidSwitch) {
*type = LID;
- } else if ( _val.startsWith("power")) {
+ } else if (edevice->eventType() == TDEEventDeviceType::ACPIPowerButton) {
*type = BUTTON_POWER;
- } else if ( _val.startsWith("sleep")) {
+ } else if (edevice->eventType() == TDEEventDeviceType::ACPISleepButton) {
*type = BUTTON_SLEEP;
} else {
ret = false;
@@ -459,13 +414,13 @@ bool HardwareInfo::checkIfHandleDevice ( TQString _udi, int *type) {
} else {
ret = false;
}
- } else if (_cap.contains("battery")) {
+ } else if (devtype == TDEGenericDeviceType::Battery) {
*type = BATTERY;
- } else if (_cap.contains("laptop_panel")) {
+ } else if (devtype == TDEGenericDeviceType::Backlight) {
*type = LAPTOP_PANEL;
} else {
ret = false;
- kdDebug() << "Device with capability " << _cap.join(", ") << " unhandled" << endl;
+ kdDebug() << "Device with type " << devtype << " unhandled" << endl;
}
} else {
ret = false;
@@ -516,15 +471,13 @@ void HardwareInfo::checkIsLaptop () {
kdDebugFuncIn(trace);
TQString ret;
-
- if (dbus_HAL->halGetPropertyString(HAL_COMPUTER_UDI, "system.formfactor", &ret)) {
- if (!ret.isEmpty() && ret.startsWith("laptop"))
- laptop = true;
- else
- laptop = false;
- } else {
- // error case
+ TDERootSystemDevice* rdevice = m_hwdevices->rootSystemDevice();
+
+ if (rdevice->formFactor() == TDESystemFormFactor::Laptop) {
+ laptop = true;
+ }
+ else {
laptop = false;
}
@@ -532,7 +485,7 @@ void HardwareInfo::checkIsLaptop () {
}
/*!
- * The function checks wether the machine support ACPI/APM/PMU or not.
+ * The function checks whether the machine support ACPI/APM/PMU or not.
*/
void HardwareInfo::checkPowermanagement() {
kdDebugFuncIn(trace);
@@ -542,97 +495,63 @@ void HardwareInfo::checkPowermanagement() {
has_APM = false;
has_ACPI = false;
has_PMU = false;
-
- if (dbus_HAL->halGetPropertyString( HAL_COMPUTER_UDI, "power_management.type", &ret)) {
-
- if (ret.isEmpty()) {
- return;
- } else if (ret.startsWith("acpi")) {
- has_ACPI = true;
- } else if (ret.startsWith("apm")) {
- has_APM = true;
- } else if (ret.startsWith("pmu")) {
- has_PMU = true;
- }
+
+ TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::OtherACPI);
+ if (hwlist.count() > 0) {
+ has_ACPI = true;
}
+
+ // FIXME
+ // Do we even need to detect APM and PMU devices in the year 2012?!?
kdDebugFuncOut(trace);
}
/*!
- * The function checks wether the machine can suspend/standby.
+ * The function checks whether the machine can suspend/standby.
*/
void HardwareInfo::checkSuspend() {
kdDebugFuncIn(trace);
- TQStringList ret;
- bool _ret_b = false;
-
suspend_states = SuspendStates();
- if (dbus_HAL->halGetPropertyStringList( HAL_COMPUTER_UDI, HAL_PM_IFACE ".method_names",
- &ret )) {
- // check for suspend2ram
- if (dbus_HAL->halGetPropertyBool( HAL_COMPUTER_UDI, "power_management.can_suspend", &_ret_b ) ||
- dbus_HAL->halGetPropertyBool( HAL_COMPUTER_UDI, "power_management.can_suspend_to_ram",
- &_ret_b )) {
- suspend_states.suspend2ram_can = _ret_b;
- if (_ret_b) {
- if (ret.contains( "Suspend" )) {
- suspend_states.suspend2ram = true;
- suspend_states.suspend2ram_allowed = dbus_HAL->isUserPrivileged(PRIV_SUSPEND,
- HAL_COMPUTER_UDI);
+ suspend_states.suspend2ram = false;
+ suspend_states.suspend2ram_can = false;
+ suspend_states.suspend2ram_allowed = -1;
+ suspend_states.suspend2disk = false;
+ suspend_states.suspend2disk_can = false;
+ suspend_states.suspend2disk_allowed = -1;
+ suspend_states.standby = false;
+ suspend_states.standby_can = false;
+ suspend_states.standby_allowed = -1;
+
+ TDERootSystemDevice* rdevice = m_hwdevices->rootSystemDevice();
+ TDESystemPowerStateList powerStates = rdevice->powerStates();
+ if (powerStates.count() > 0) {
+ TDESystemPowerStateList::iterator it;
+ for (it = powerStates.begin(); it != powerStates.end(); ++it) {
+ if ((*it) == TDESystemPowerState::Active) {
+ //
}
- } else {
- suspend_states.suspend2ram = false;
- suspend_states.suspend2ram_allowed = -1;
+ if ((*it) == TDESystemPowerState::Standby) {
+ suspend_states.standby = true;
+ suspend_states.standby_allowed = rdevice->canStandby();
+ suspend_states.standby_can = suspend_states.standby_allowed & suspend_states.standby;
}
- } else {
- suspend_states.suspend2ram_can = false;
- suspend_states.suspend2ram = false;
- suspend_states.suspend2ram_allowed = -1;
- }
-
- // check for suspend2disk
- if (dbus_HAL->halGetPropertyBool( HAL_COMPUTER_UDI, "power_management.can_hibernate", &_ret_b ) ||
- dbus_HAL->halGetPropertyBool( HAL_COMPUTER_UDI, "power_management.can_suspend_to_disk",
- &_ret_b )) {
- suspend_states.suspend2disk_can = _ret_b;
- if (_ret_b) {
- if (ret.contains( "Hibernate" )) {
- suspend_states.suspend2disk = true;
- suspend_states.suspend2disk_allowed =
- dbus_HAL->isUserPrivileged(PRIV_HIBERNATE,
- HAL_COMPUTER_UDI);
+ if ((*it) == TDESystemPowerState::Suspend) {
+ suspend_states.suspend2ram = true;
+ suspend_states.suspend2ram_allowed = rdevice->canSuspend();
+ suspend_states.suspend2ram_can = suspend_states.suspend2ram_allowed & suspend_states.suspend2ram;
}
- } else {
- suspend_states.suspend2disk = false;
- suspend_states.suspend2disk_allowed = -1;
- }
- } else {
- suspend_states.suspend2disk_can = false;
- suspend_states.suspend2disk = false;
- suspend_states.suspend2disk_allowed = -1;
- }
-
- // check for StandBy
- if (dbus_HAL->halGetPropertyBool( HAL_COMPUTER_UDI, "power_management.can_standby", &_ret_b )) {
- suspend_states.standby_can = _ret_b;
- if (_ret_b) {
- if (ret.contains( "Standby" )) {
- suspend_states.standby = true;
- suspend_states.standby_allowed = dbus_HAL->isUserPrivileged(PRIV_STANDBY,
- HAL_COMPUTER_UDI);
+ if ((*it) == TDESystemPowerState::Hibernate) {
+ suspend_states.suspend2disk = true;
+ suspend_states.suspend2disk_allowed = rdevice->canSuspend();
+ suspend_states.suspend2disk_can = suspend_states.suspend2disk_allowed & suspend_states.suspend2disk;
}
- } else {
- suspend_states.standby = false;
- suspend_states.standby_allowed = -1;
+ if ((*it) == TDESystemPowerState::PowerOff) {
+ //
}
- } else {
- suspend_states.standby_can = false;
- suspend_states.standby = false;
- suspend_states.standby_allowed = -1;
}
}
@@ -640,17 +559,20 @@ void HardwareInfo::checkSuspend() {
}
/*!
- * The function checks wether the machine support CPU frequency changes
- * via HAL.
+ * The function checks whether the machine support CPU frequency changes
*/
void HardwareInfo::checkCPUFreq() {
kdDebugFuncIn(trace);
-
- bool ret = false;
- if (dbus_HAL->halQueryCapability( HAL_COMPUTER_UDI, "cpufreq_control", &ret )) {
- cpuFreq = ret;
- cpuFreqAllowed = dbus_HAL->isUserPrivileged( PRIV_CPUFREQ, HAL_COMPUTER_UDI);
+ // Use the first CPU in the list; permissions are probably the same across all CPUs
+ TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::CPU);
+ TDEGenericDevice *hwdevice;
+ hwdevice = hwlist.first();
+ TDECPUDevice *cpudevice = static_cast<TDECPUDevice*>(hwdevice);
+
+ if (!cpudevice->scalingDriver().isNull()) {
+ cpuFreq = true;
+ cpuFreqAllowed = cpudevice->canSetGovernor();
checkCurrentCPUFreqPolicy();
} else {
@@ -666,33 +588,30 @@ void HardwareInfo::checkCPUFreq() {
*/
cpufreq_type HardwareInfo::checkCurrentCPUFreqPolicy() {
kdDebugFuncIn(trace);
+
+ // Use the first CPU in the list; permissions are probably the same across all CPUs
+ TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::CPU);
+ TDEGenericDevice *hwdevice;
+ hwdevice = hwlist.first();
+ TDECPUDevice *cpudevice = static_cast<TDECPUDevice*>(hwdevice);
- char *gov;
+ TQString gov = cpudevice->governor();
cpufreq_type _current = UNKNOWN_CPUFREQ;
if (cpuFreq) {
-
- if (dbus_HAL->dbusSystemMethodCall( HAL_SERVICE, HAL_COMPUTER_UDI,
- HAL_CPUFREQ_IFACE, "GetCPUFreqGovernor",
- &gov, DBUS_TYPE_STRING, DBUS_TYPE_INVALID)) {
- if (gov != NULL) {
- kdDebug() << "got CPU Freq gov: " << gov << endl;
- if (!strcmp(gov, "ondemand") || !strcmp(gov, "userspace") ||
- !strcmp(gov, "conservative")) {
- _current = DYNAMIC;
- } else if (!strcmp(gov, "powersave")) {
- _current = POWERSAVE;
- } else if (!strcmp(gov, "performance")) {
- _current = PERFORMANCE;
- } else {
- kdError() << "Got unknown CPUFreq Policy back: " << gov << endl;
- }
- cpuFreqGovernor = gov;
- }
- else {
- kdWarning() << "Could not get information about current governor" << endl;
+ if (!gov.isNull()) {
+ kdDebug() << "got CPU Freq gov: " << gov << endl;
+ if ((gov == "ondemand") || (gov == "userspace") || (gov == "conservative")) {
+ _current = DYNAMIC;
+ } else if (gov == "powersave") {
+ _current = POWERSAVE;
+ } else if (gov =="performance") {
+ _current = PERFORMANCE;
+ } else {
+ kdError() << "Got unknown CPUFreq Policy back: " << gov << endl;
}
+ cpuFreqGovernor = gov;
} else {
kdWarning() << "Could not get information about current governor" << endl;
}
@@ -714,7 +633,7 @@ cpufreq_type HardwareInfo::checkCurrentCPUFreqPolicy() {
/*!
- * The function checks wether the machine provide a brightness interface and init
+ * The function checks whether the machine provide a brightness interface and init
* (if needed) brightness information.
*/
void HardwareInfo::checkBrightness() {
@@ -726,42 +645,36 @@ void HardwareInfo::checkBrightness() {
currentBrightnessLevel = -1;
availableBrightnessLevels = -1;
- if( dbus_HAL->halFindDeviceByCapability("laptop_panel", &devices)) {
- if (devices.isEmpty()) {
- udis.remove("laptop_panel");
- kdDebug() << "no device with category laptop_panel found" << endl;
- kdDebugFuncOut(trace);
- return;
- } else {
- int retval;
-
-
- kdDebug() << "laptop_panel device found: " << devices.first() << endl;
- // we should asume there is only one laptop panel device in the system
- if (dbus_HAL->halGetPropertyInt(devices.first(), "laptop_panel.num_levels", &retval )) {
- udis.insert("laptop_panel", new TQString( devices.first() ));
- if (!allUDIs.contains( devices.first() ))
- allUDIs.append( devices.first() );
-
- if (retval > 1) {
- dbus_HAL->halGetPropertyBool(devices.first(), "laptop_panel.brightness_in_hardware",
- &brightness_in_hardware);
-
- availableBrightnessLevels = retval;
-#ifdef USE_LIBHAL_POLICYCHECK
- brightnessAllowed = dbus_HAL->isUserPrivileged( PRIV_LAPTOP_PANEL,
- devices.first());
- // TODO: check brightnessAllowed
-#endif
- brightness = true;
- // get the current level via GetBrightness
- checkCurrentBrightness();
- } else {
- kdError() << "Found a Panel, but laptop_panel.num_levels < 2, which means "
- << "KPowersave can't set usefull values" << endl;
- }
- }
+ // Use the first backlight in the list
+ TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::Backlight);
+ TDEGenericDevice *hwdevice;
+ hwdevice = hwlist.first();
+ TDEBacklightDevice *backlightdevice = static_cast<TDEBacklightDevice*>(hwdevice);
+
+ if (backlightdevice) {
+ udis.insert("laptop_panel", new TQString( hwdevice->uniqueID() ));
+ if (!allUDIs.contains( hwdevice->uniqueID() )) {
+ allUDIs.append( hwdevice->uniqueID() );
}
+
+ availableBrightnessLevels = backlightdevice->brightnessSteps();
+
+ if (availableBrightnessLevels > 1) {
+ brightnessAllowed = backlightdevice->canSetBrightness();
+
+ brightness = true;
+ // get the current level via GetBrightness
+ checkCurrentBrightness();
+ }
+ else {
+ availableBrightnessLevels = -1;
+ }
+ }
+ else {
+ udis.remove("laptop_panel");
+ kdDebug() << "no device with category laptop_panel found" << endl;
+ kdDebugFuncOut(trace);
+ return;
}
kdDebugFuncOut(trace);
@@ -775,12 +688,14 @@ void HardwareInfo::checkCurrentBrightness() {
kdDebugFuncIn(trace);
if (brightness) {
- int retval;
- // get the current level via GetBrightness
- if (dbus_HAL->dbusSystemMethodCall( HAL_SERVICE, *udis["laptop_panel"], HAL_LPANEL_IFACE,
- "GetBrightness", &retval, DBUS_TYPE_INT32,
- DBUS_TYPE_INVALID ) ) {
- currentBrightnessLevel = (int) retval;
+ // Use the first backlight in the list
+ TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::Backlight);
+ TDEGenericDevice *hwdevice;
+ hwdevice = hwlist.first();
+ TDEBacklightDevice *backlightdevice = static_cast<TDEBacklightDevice*>(hwdevice);
+
+ if (backlightdevice) {
+ currentBrightnessLevel = backlightdevice->rawBrightness();
}
}
@@ -798,54 +713,43 @@ void HardwareInfo::checkCurrentBrightness() {
bool HardwareInfo::intialiseHWInfo() {
kdDebugFuncIn(trace);
- TQStringList ret;
-
- if (!dbus_HAL->isConnectedToDBUS() || !dbus_HAL->isConnectedToHAL())
- return false;
+ TDEGenericDevice *hwdevice;
+ TDEGenericHardwareList hwlist;
- if( dbus_HAL->halFindDeviceByCapability("ac_adapter", &ret)) {
- // there should be normaly only one device, but let be sure
- for ( TQStringList::iterator it = ret.begin(); it != ret.end(); ++it ) {
- // we need a deep copy
- udis.insert("acadapter", new TQString( *it ));
- if (!allUDIs.contains( *it ))
- allUDIs.append( *it );
- checkACAdapterState();
+ hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::PowerSupply);
+ for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) {
+ udis.insert("acadapter", new TQString( hwdevice->uniqueID() ));
+ if (!allUDIs.contains( hwdevice->uniqueID() )) {
+ allUDIs.append( hwdevice->uniqueID() );
}
+ checkACAdapterState();
}
-
- ret.clear();
-
- if( dbus_HAL->halFindDeviceByString("button.type", "lid", &ret)) {
- // there should be normaly only one device, but let be sure
- for ( TQStringList::iterator it = ret.begin(); it != ret.end(); ++it ) {
- // we need a deep copy
- udis.insert("lidclose", new TQString( *it ));
- if (!allUDIs.contains( *it ))
- allUDIs.append( *it );
+
+ hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::Event);
+ for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) {
+ TDEEventDevice* edevice = dynamic_cast<TDEEventDevice*>(hwdevice);
+ if (edevice->eventType() == TDEEventDeviceType::ACPILidSwitch) {
+ udis.insert("lidclose", new TQString( hwdevice->uniqueID() ));
+ if (!allUDIs.contains( hwdevice->uniqueID() )) {
+ allUDIs.append( hwdevice->uniqueID() );
+ }
checkLidcloseState();
}
}
- ret.clear();
-
// find batteries and fill battery information
- if( dbus_HAL->halFindDeviceByCapability("battery", &ret)) {
- if (!ret.isEmpty()) {
- // there should be normaly only one device, but let be sure
- for ( TQStringList::iterator it = ret.begin(); it != ret.end(); ++it ) {
- if (!allUDIs.contains( *it ))
- allUDIs.append( *it );
- BatteryList.append( new Battery(dbus_HAL, *it) );
- }
-
- // connect to signals for primary batteries:
- Battery *bat;
- for (bat = BatteryList.first(); bat; bat = BatteryList.next() ) {
- if (bat->getType() == BAT_PRIMARY) {
- connect(bat, TQT_SIGNAL(changedBattery()),this, TQT_SLOT(updatePrimaryBatteries()));
- }
- }
+ hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::Battery);
+ for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) {
+ if (!allUDIs.contains( hwdevice->uniqueID() )) {
+ allUDIs.append( hwdevice->uniqueID() );
+ }
+ BatteryList.append( new Battery( hwdevice->uniqueID() ) );
+ }
+ // connect to signals for primary batteries:
+ Battery *bat;
+ for (bat = BatteryList.first(); bat; bat = BatteryList.next() ) {
+ if (bat->getType() == BAT_PRIMARY) {
+ connect(bat, TQT_SIGNAL(changedBattery()),this, TQT_SLOT(updatePrimaryBatteries()));
}
}
@@ -862,7 +766,9 @@ void HardwareInfo::checkACAdapterState() {
if ( udis["acadapter"] ) {
bool _state;
- if (dbus_HAL->halGetPropertyBool(*udis["acadapter"] , "ac_adapter.present", &_state )) {
+ TDEMainsPowerDevice* mdevice = dynamic_cast<TDEMainsPowerDevice*>(m_hwdevices->findByUniqueID(*udis["acadapter"]));
+ if (mdevice) {
+ _state = mdevice->online();
if (_state != acadapter) {
acadapter = _state;
update_info_ac_changed = true;
@@ -870,7 +776,8 @@ void HardwareInfo::checkACAdapterState() {
} else {
update_info_ac_changed = false;
}
- } else {
+ }
+ else {
// we use true as default e.g. for workstations
acadapter = true;
}
@@ -888,7 +795,9 @@ void HardwareInfo::checkLidcloseState() {
if ( udis["lidclose"] ) {
bool _state;
- if (dbus_HAL->halGetPropertyBool(*udis["lidclose"] , "button.state.value", &_state )) {
+ TDEEventDevice* edevice = dynamic_cast<TDEEventDevice*>(m_hwdevices->findByUniqueID(*udis["lidclose"]));
+ if (edevice) {
+ _state = (edevice->activeSwitches() & TDESwitchType::Lid);
if (_state != lidclose) {
lidclose = _state;
emit lidclosetStatus( lidclose );
@@ -907,20 +816,23 @@ void HardwareInfo::checkLidcloseState() {
* \param udi TQString with the UDI of the battery
* \param property TQString with the changed property
*/
-void HardwareInfo::updateBatteryValues (TQString udi, TQString property) {
+void HardwareInfo::updateBatteryValues (TDEGenericDevice* device) {
kdDebugFuncIn(trace);
- if (!udi.isEmpty() && allUDIs.contains( udi )) {
+ if (device && allUDIs.contains( device->uniqueID() )) {
// find effected battery object
Battery *bat;
for (bat = BatteryList.first(); bat; bat = BatteryList.next() ) {
- if (udi.startsWith( bat->getUdi())) {
- // found a battery with udi
- bat->updateProperty(udi, property);
+ if (device->uniqueID().startsWith( bat->getUdi())) {
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(device);
+ if (bdevice) {
+ // found a battery with udi
+ bat->updateProperty(bdevice);
+ }
}
}
} else {
- kdDebug() << "UDI is empty or not in the list of monitored devices: " << udi << endl;
+ kdDebug() << "UDI is empty or not in the list of monitored devices " << endl;
}
kdDebugFuncOut(trace);
@@ -995,15 +907,15 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
calledSuspend = TQTime();
- if (dbus_HAL->isConnectedToDBUS() && dbus_HAL->isConnectedToHAL()) {
+ TDERootSystemDevice* rdevice = m_hwdevices->rootSystemDevice();
+
+ if (rdevice) {
switch (suspend) {
case SUSPEND2DISK:
if (suspend_states.suspend2disk && (suspend_states.suspend2disk_allowed != 0)) {
- if (dbus_HAL->dbusMethodCallSuspend("Hibernate")) {
+ if (rdevice->setPowerState(TDESystemPowerState::Hibernate)) {
calledSuspend.start();
return true;
- } else {
- return false;
}
} else {
if ( !suspend_states.suspend2disk )
@@ -1016,7 +928,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
break;
case SUSPEND2RAM:
if (suspend_states.suspend2ram && (suspend_states.suspend2ram_allowed != 0)) {
- if (dbus_HAL->dbusMethodCallSuspend("Suspend")) {
+ if (rdevice->setPowerState(TDESystemPowerState::Suspend)) {
calledSuspend.start();
return true;
} else {
@@ -1033,7 +945,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
break;
case STANDBY:
if (suspend_states.standby && (suspend_states.standby_allowed != 0)) {
- if (dbus_HAL->dbusMethodCallSuspend("Standby")) {
+ if (rdevice->setPowerState(TDESystemPowerState::Standby)) {
calledSuspend.start();
return true;
} else {
@@ -1083,9 +995,16 @@ bool HardwareInfo::setBrightness ( int level, int percent ){
}
}
- if (dbus_HAL->isConnectedToDBUS() && dbus_HAL->isConnectedToHAL()) {
- if (!brightness)
+ // Use the first backlight in the list
+ TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::Backlight);
+ TDEGenericDevice *hwdevice;
+ hwdevice = hwlist.first();
+ TDEBacklightDevice *backlightdevice = static_cast<TDEBacklightDevice*>(hwdevice);
+
+ if (backlightdevice) {
+ if (!brightness) {
checkBrightness();
+ }
if (!brightness || (level < 0 ) || (level >= availableBrightnessLevels)) {
kdError() << "Change brightness or requested level not supported " << endl;
@@ -1094,12 +1013,8 @@ bool HardwareInfo::setBrightness ( int level, int percent ){
kdDebug() << "Brightness level not changed, requested level == current level" << endl;
retval = true;
} else {
- if (dbus_HAL->dbusSystemMethodCall( HAL_SERVICE, *udis["laptop_panel"],
- HAL_LPANEL_IFACE, "SetBrightness",
- DBUS_TYPE_INT32, &level,
- DBUS_TYPE_INVALID )) {
- retval = true;
- }
+ backlightdevice->setRawBrightness(level);
+ retval = true;
}
}
}
@@ -1130,8 +1045,10 @@ bool HardwareInfo::setCPUFreq ( cpufreq_type cpufreq, int limit ) {
kdError() << "Could not set CPU Freq, this not the needed privileges." << endl;
return false;
}
-
- if (dbus_HAL->isConnectedToDBUS() && dbus_HAL->isConnectedToHAL()) {
+
+ TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::CPU);
+
+ if (hwlist.count() > 0) {
dbus_bool_t consider = (dbus_bool_t) getAcAdapter();
TQStringList dynamic;
@@ -1163,16 +1080,10 @@ bool HardwareInfo::setCPUFreq ( cpufreq_type cpufreq, int limit ) {
break;
}
}
-
- // set dynamic performance limit
- if (!dbus_HAL->dbusSystemMethodCall( HAL_SERVICE, HAL_COMPUTER_UDI,
- HAL_CPUFREQ_IFACE,
- "SetCPUFreqPerformance",
- DBUS_TYPE_INT32, &limit,
- DBUS_TYPE_INVALID)) {
- kdError() << "Could not call/set SetCPUFreqPerformance with value: "
- << limit << endl;
- }
+
+#if 0
+ // FIXME
+ // What does "SetCPUFreqConsiderNice" actually do??!?!
// correct set ondemand
if (!dbus_HAL->dbusSystemMethodCall( HAL_SERVICE, HAL_COMPUTER_UDI,
@@ -1183,6 +1094,21 @@ bool HardwareInfo::setCPUFreq ( cpufreq_type cpufreq, int limit ) {
kdError() << "Couldn't set SetCPUFreqConsiderNice for DYNAMIC" << endl;
}
+#endif
+ // Set performance limits on all CPUs
+ TDEGenericDevice *hwdevice;
+ TDECPUDevice *cpudevice;
+ for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) {
+ cpudevice = static_cast<TDECPUDevice*>(hwdevice);
+ // set dynamic performance limit
+ // scale the desired limit so that when limit==0 the minFrequency() is used, and when limit==100 the maxFrequency() is used
+ double cpuLimit = cpudevice->maxFrequency() - cpudevice->minFrequency();
+ cpuLimit = (cpuLimit * limit) / 100.0;
+ cpuLimit = cpudevice->maxFrequency() + cpuLimit;
+ cpudevice->setMaximumScalingFrequency(cpuLimit);
+
+ }
+
break;
case POWERSAVE:
if (!setCPUFreqGovernor("powersave")) {
@@ -1221,14 +1147,16 @@ bool HardwareInfo::setCPUFreqGovernor( const char *governor ) {
int reply;
bool ret = true;
- kdDebug() << "Try to set CPUFreq to governor: " << governor << endl;
- if (!dbus_HAL->dbusSystemMethodCall( HAL_SERVICE, HAL_COMPUTER_UDI,
- HAL_CPUFREQ_IFACE, "SetCPUFreqGovernor",
- &reply, DBUS_TYPE_INVALID,
- DBUS_TYPE_STRING, &governor,
- DBUS_TYPE_INVALID)) {
- kdError() << "Could not set CPU Freq to governor: " << governor << endl;
- ret = false;
+ TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::CPU);
+ TDEGenericDevice *hwdevice;
+ TDECPUDevice *cpudevice;
+ // Set governor on all CPUs
+ for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) {
+ cpudevice = static_cast<TDECPUDevice*>(hwdevice);
+ cpudevice->setGovernor(governor);
+ if (cpudevice->governor() != governor) {
+ ret = false;
+ }
}
kdDebugFuncOut(trace);
@@ -1248,30 +1176,9 @@ bool HardwareInfo::setPowerSave( bool on ) {
bool retval = false;
- if (dbus_HAL->isConnectedToDBUS() && dbus_HAL->isConnectedToHAL()) {
- dbus_bool_t _tmp = (dbus_bool_t) on;
- int reply;
-
-#ifdef USE_LIBHAL_POLICYCHECK
- if (dbus_HAL->isUserPrivileged(PRIV_SETPOWERSAVE, HAL_COMPUTER_UDI) != 0) {
-#else
- if (true) {
-#endif
- if (!dbus_HAL->dbusSystemMethodCall( HAL_SERVICE, HAL_COMPUTER_UDI,
- HAL_PM_IFACE, "SetPowerSave",
- &reply, DBUS_TYPE_INT32,
- DBUS_TYPE_BOOLEAN, &_tmp,
- DBUS_TYPE_INVALID)) {
- kdError() << "Could not call/set SetPowerSave on HAL, "
- << "could be a bug in HAL spec" << endl;
- } else {
- retval = true;
- }
- } else {
- kdError() << "The user isn't allowed to call SetPowerSave() on HAL. "
- << "Maybe KPowersave run not in a active session." << endl;
- }
- }
+ // FIXME
+ // Set up power saving to the best of our ability using "raw" functions
+ printf("[FIXME] HardwareInfo::setPowerSave unimplemented!\n\r"); fflush(stdout);
kdDebugFuncOut(trace);
return retval;
@@ -1288,20 +1195,7 @@ bool HardwareInfo::getSchedPowerSavings() {
bool returnval = false;
- if (dbus_HAL->isConnectedToDBUS() && dbus_HAL->isConnectedToHAL()) {
- dbus_bool_t ret;
-
- //NOTE: the kernel only allow 1/0 for the related sysfs entry
- if (dbus_HAL->dbusSystemMethodCall( HAL_SERVICE, HAL_COMPUTER_UDI,
- HAL_CPUFREQ_IFACE, "GetSchedPowerSavings",
- &ret, DBUS_TYPE_BOOLEAN, DBUS_TYPE_INVALID)) {
- schedPowerSavings = ((ret != 0) ? true: false);
- returnval = true;
- } else {
- schedPowerSavings = false;
- kdWarning() << "Could not call GetSchedPowerSavings() " << endl;
- }
- }
+ // What does the HAL method GetSchedPowerSavings actually do?!?!?
kdDebugFuncOut(trace);
return returnval;
@@ -1319,20 +1213,7 @@ bool HardwareInfo::setSchedPowerSavings( bool enable ) {
bool retval = false;
- if (dbus_HAL->isConnectedToDBUS() && dbus_HAL->isConnectedToHAL()) {
- dbus_bool_t _tmp = (dbus_bool_t) enable;
-
- //NOTE: the kernel only allow 1/0 for the related sysfs entry
- if (dbus_HAL->dbusSystemMethodCall( HAL_SERVICE, HAL_COMPUTER_UDI,
- HAL_CPUFREQ_IFACE,
- "SetCPUFreqPerformance",
- DBUS_TYPE_BOOLEAN, &_tmp,
- DBUS_TYPE_INVALID)) {
- retval = true;
- } else {
- kdWarning() << "Could not call SetSchedPowerSavings() " << endl;
- }
- }
+ // What does the HAL method SetCPUFreqPerformance actually do?!?!?
kdDebugFuncOut(trace);
return retval;
@@ -1629,7 +1510,9 @@ bool HardwareInfo::isLaptop() const {
* \retval false if not connected
*/
bool HardwareInfo::isOnline() const {
- return (!dbus_terminated && !hal_terminated);
+ // FIXME
+ // Is there ANY case where the TDE hardware library would not function?
+ return true;
}
/*!
@@ -1701,7 +1584,13 @@ bool HardwareInfo::currentSessionIsActive() const {
* \retval -1 unknown
*/
int HardwareInfo::isCpuFreqAllowed () {
- cpuFreqAllowed = dbus_HAL->isUserPrivileged( PRIV_CPUFREQ, HAL_COMPUTER_UDI);
+ // Use the first CPU in the list; permissions are probably the same across all CPUs
+ TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::CPU);
+ TDEGenericDevice *hwdevice;
+ hwdevice = hwlist.first();
+ TDECPUDevice *cpudevice = static_cast<TDECPUDevice*>(hwdevice);
+
+ cpuFreqAllowed = cpudevice->canSetGovernor();
return cpuFreqAllowed;
}
diff --git a/src/hardware.h b/src/hardware.h
index a3cdc2e..f902499 100644
--- a/src/hardware.h
+++ b/src/hardware.h
@@ -45,6 +45,9 @@
#include <tqptrlist.h>
#include <tqdict.h>
+// TDE hardware library
+#include <tdehardwaredevices.h>
+
// HAL Library
#include <hal/libhal.h>
@@ -125,6 +128,8 @@ class HardwareInfo : public TQObject{
private:
+ TDEHardwareDevices *m_hwdevices;
+
//! pointer to the dbusHAL connection class
dbusHAL *dbus_HAL;
@@ -315,12 +320,16 @@ private:
bool setSchedPowerSavings( bool enable );
//! find and update a battery information
- void updateBatteryValues (TQString udi, TQString property);
+ void updateBatteryValues (TDEGenericDevice* device);
private slots:
//! to fetch events from D-Bus and handle them
void processMessage (msg_type type, TQString message, TQString value);
+ //! to fetch events from the TDE hardware library and handle them
+ void processHardwareChangedEvent (TDEGenericDevice*);
+ //! to fetch keypresses from the TDE hardware library and handle them
+ void processKeyPressEvent (unsigned int, TDEEventDevice*);
//! to update \ref primaryBatteries
void updatePrimaryBatteries ();
//! to set \ref update_info_primBattery_changed
@@ -331,9 +340,6 @@ private slots:
void checkACAdapterState();
//! check if brightness change is possible
void checkBrightness();
-
- //! TQT_SLOT to handle the reconnect to D-Bus
- void reconnectDBUS();
//! TQT_SLOT to forward signal about changed battery warning state
void emitBatteryWARNState (int type, int state);
@@ -423,14 +429,6 @@ public:
* \li false: If D-Bus not terminated
*/
bool dbus_terminated;
- //! boolean which tell us if the HAL daemon was terminated
- /*!
- * This boolean contains information if the HAL daemon terminated and
- * we recieved "hal.terminate"
- * \li true: If HAL terminated
- * \li false: If HAL not terminated
- */
- bool hal_terminated;
// --> functions
//! default constructor
diff --git a/src/hardware_battery.cpp b/src/hardware_battery.cpp
index b9809e8..21dc5c9 100644
--- a/src/hardware_battery.cpp
+++ b/src/hardware_battery.cpp
@@ -26,38 +26,54 @@
#include "hardware_battery.h"
-/*! The default constructor of the class Battery. */
-Battery::Battery(dbusHAL* _dbus_HAL) : dbus_HAL(_dbus_HAL) {
- kdDebugFuncIn(trace);
-
- udi = TQString();
- initialized = false;
-
- initDefault();
- init(NULL);
-
- kdDebugFuncOut(trace);
-}
+// FOR REFERENCE
+// udi = '/org/freedesktop/Hal/devices/bme'
+// info.addons = { 'hald-addon-bme' } (string list)
+// maemo.charger.type = 'host 500 mA' (string)
+// maemo.charger.connection_status = 'connected' (string)
+// maemo.rechargeable.charging_status = 'on' (string)
+// maemo.rechargeable.positive_rate = true (bool)
+// battery.present = true (bool)
+// info.product = 'Battery (BME-HAL)' (string)
+// info.subsystem = 'unknown' (string)
+// battery.is_rechargeable = true (bool)
+// info.udi = '/org/freedesktop/Hal/devices/bme' (string)
+// battery.charge_level.unit = 'bars' (string)
+// battery.remaining_time = 7200 (0x1c20) (int)
+// battery.type = 'pda' (string)
+// battery.charge_level.percentage = 71 (0x47) (int)
+// battery.charge_level.design = 8 (0x8) (int)
+// battery.charge_level.capacity_state = 'ok' (string)
+// battery.rechargeable.is_discharging = false (bool)
+// battery.charge_level.last_full = 7 (0x7) (int)
+// battery.reporting.design = 1258 (0x4ea) (int)
+// battery.reporting.last_full = 867 (0x363) (int)
+// battery.reporting.current = 903 (0x387) (int)
+// battery.voltage.unit = 'mV' (string)
+// battery.voltage.design = 4200 (0x1068) (int)
+// info.category = 'battery' (string)
+// battery.voltage.current = 3947 (0xf6b) (int)
+// battery.remaining_time.calculate_per_time = false (bool)
+// info.parent = '/org/freedesktop/Hal/devices/computer' (string)
+// battery.charge_level.current = 7 (0x7) (int)
+// battery.rechargeable.is_charging = true (bool)
+// info.capabilities = { 'battery' } (string list)
+// battery.reporting.unit = 'mAh' (string)
/*! The default constructor of the class Battery. */
-Battery::Battery( dbusHAL* _dbus_HAL, TQString _udi ) : dbus_HAL(_dbus_HAL), udi(_udi) {
+Battery::Battery( TQString _udi ) {
if (trace) kdDebug() << funcinfo << "IN , udi: " << udi << endl;
-
- initialized = false;
- initDefault();
- init(NULL);
+ m_hwdevices = KGlobal::hardwareDevices();
- kdDebugFuncOut(trace);
-}
+ udi = _udi;
-/*! The default constructor of the class Battery. */
-Battery::Battery() {
- kdDebugFuncIn(trace);
+ connect(m_hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(updateProperty(TDEGenericDevice*)));
+
initialized = false;
initDefault();
- udi = TQString();
+ init();
kdDebugFuncOut(trace);
}
@@ -94,26 +110,18 @@ void Battery::initDefault() {
}
//! initialize this battery object with values from HAL
-void Battery::init(dbusHAL* _dbus_HAL) {
+void Battery::init() {
kdDebugFuncIn(trace);
- if (_dbus_HAL != NULL)
- dbus_HAL = _dbus_HAL;
-
// read battery information from HAL
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- //couldnt connect to HAL
- state=BAT_HAL_ERROR;
+ if (resetUdi(udi)) {
+ //udi is valid
+ recheck(); //fills all values
+ //ready here for now
} else {
- if (resetUdi(udi)) {
- //udi is valid
- recheck(); //fills all values
- //ready here for now
- } else {
- //udi is invalid or is no battery
- state=BAT_HAL_ERROR;
- kdWarning() << "Warning: Battery::init cannot make use of udi " << udi << endl;
- }
+ //udi is invalid or is no battery
+ state=BAT_HAL_ERROR;
+ kdWarning() << "Warning: Battery::init cannot make use of udi " << udi << endl;
}
initialized = true;
@@ -127,10 +135,11 @@ void Battery::init(dbusHAL* _dbus_HAL) {
void Battery::minRecheck() {
kdDebugFuncIn(trace);
- //first check whether HAL is available
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
//grr... no luck
- kdError() << "Battery::recheck couldn't connect to HAL" << endl;
+ kdError() << "Battery::recheck couldn't find battery" << endl;
kdDebugFuncOut(trace);
return;
}
@@ -160,10 +169,11 @@ void Battery::minRecheck() {
void Battery::recheck() {
kdDebugFuncIn(trace);
- //first check whether HAL is available
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
//grr... no luck
- kdError() << "Battery::recheck couldn't connect to HAL" << endl;
+ kdError() << "Battery::recheck couldn't find battery" << endl;
kdDebugFuncOut(trace);
return;
}
@@ -203,44 +213,40 @@ bool Battery::checkBatteryPresent () {
kdDebugFuncIn(trace);
bool _present = false;
-
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkBatteryPresent couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
- if (dbus_HAL->halGetPropertyBool(udi,"battery.present", &_present)) {
- if (_present != present) {
- present = _present;
-
- // force depending changes
- if (_present) {
- // should be now present
- recheck();
- }
- if (!_present) {
- //Uhhh, battery is not present, so we need to reset battery to default.
- initDefault();
- checkBatteryType();
- state = BAT_NONE;
- }
-
- if (initialized) {
- emit changedBatteryPresent();
- emit changedBattery();
- }
+ _present = bdevice->installed();
+ if (_present != present) {
+ present = _present;
+
+ // force depending changes
+ if (_present) {
+ // should be now present
+ recheck();
+ }
+ if (!_present) {
+ //Uhhh, battery is not present, so we need to reset battery to default.
+ initDefault();
+ checkBatteryType();
+ state = BAT_NONE;
}
- // also query the serial ... no need to do this in a extra place
- dbus_HAL->halGetPropertyString(udi, "battery.serial", &serial);
-
- } else {
- //query was not successfull
- kdDebug() << "Query of battery.present of " << udi << " wasn't successfull." << endl;
- //..but we assume its there try on
- present = true;
+ if (initialized) {
+ emit changedBatteryPresent();
+ emit changedBattery();
+ }
}
+
+ // also query the serial ... no need to do this in a extra place
+ serial = bdevice->serialNumber();
kdDebugFuncOut(trace);
return true;
@@ -258,12 +264,22 @@ bool Battery::checkBatteryType () {
TQString tmp_qstring;
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkBatteryType couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
+ // FIXME
+ // How can we get battery type from TDE HW library (i.e. how to get type from sysfs)?
+ // For now just report any batteries as primary...
+ type = BAT_PRIMARY;
+ return true;
+
+#if 0
if (dbus_HAL->halGetPropertyString(udi,"battery.type", &tmp_qstring)) {
if (tmp_qstring.compare("primary") == 0) {
type = BAT_PRIMARY;
@@ -290,6 +306,7 @@ bool Battery::checkBatteryType () {
kdDebugFuncOut(trace);
return false;
}
+#endif
}
//! to check battery.technology
@@ -303,9 +320,12 @@ bool Battery::checkBatteryTechnology () {
kdDebugFuncIn(trace);
TQString tmp_qstring;
-
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkBatteryTechnology couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
@@ -316,20 +336,14 @@ bool Battery::checkBatteryTechnology () {
return false;
}
- if (dbus_HAL->halGetPropertyString(udi,"battery.technology", &tmp_qstring)) {
- if (!tmp_qstring.isEmpty()) {
- technology = TQString(tmp_qstring);
- } else {
- technology = TQString("UNKNOWN");
- }
- kdDebugFuncOut(trace);
- return true;
+ tmp_qstring = bdevice->technology();
+ if (!tmp_qstring.isEmpty()) {
+ technology = TQString(tmp_qstring);
} else {
- //query was not successfull, but this property is optional
technology = TQString("UNKNOWN");
- kdDebugFuncOut(trace);
- return false;
}
+ kdDebugFuncOut(trace);
+ return true;
}
@@ -344,9 +358,12 @@ bool Battery::checkCapacityState () {
kdDebugFuncIn(trace);
TQString tmp_qstring;
-
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkCapacityState couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
@@ -357,16 +374,20 @@ bool Battery::checkCapacityState () {
return false;
}
- if (dbus_HAL->halGetPropertyString(udi, "battery.charge_level.capacity_state", &tmp_qstring)) {
- capacity_state = TQString(tmp_qstring);
- kdDebugFuncOut(trace);
- return true;
- } else {
- //query was not successfull, but this property is optional
- capacity_state = TQString();
- kdDebugFuncOut(trace);
- return false;
+ capacity_state = "unknown";
+ TDEBatteryStatus::TDEBatteryStatus batteryStatus = bdevice->status();
+ if (batteryStatus == TDEBatteryStatus::Charging) {
+ capacity_state = "charging";
+ }
+ if (batteryStatus == TDEBatteryStatus::Discharging) {
+ capacity_state = "discharging";
}
+ if (batteryStatus == TDEBatteryStatus::Full) {
+ capacity_state = "full";
+ }
+
+ kdDebugFuncOut(trace);
+ return true;
}
@@ -379,9 +400,12 @@ bool Battery::checkCapacityState () {
*/
bool Battery::checkChargeLevelCurrent () {
kdDebugFuncIn(trace);
-
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkChargeLevelCurrent couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
@@ -392,20 +416,15 @@ bool Battery::checkChargeLevelCurrent () {
return false;
}
- if (dbus_HAL->halGetPropertyInt(udi, "battery.charge_level.current", &charge_level_current)) {
- if (charge_level_current < 0) {
- //overflow?
- charge_level_current = 0;
- }
- kdDebugFuncOut(trace);
- return true;
- } else {
- //query was not successfull (is mandatory)
- kdError() << "Couldn't request charge_level.current for udi: " << udi << endl;
- state = BAT_NONE;
- kdDebugFuncOut(trace);
- return false;
+ // FIXME VERIFY CORRECTNESS
+ // what does kpowersave expect to see in charge_level_current (battery.charge_level.current)?
+ charge_level_current = bdevice->energy();
+ if (charge_level_current < 0) {
+ //overflow?
+ charge_level_current = 0;
}
+ kdDebugFuncOut(trace);
+ return true;
}
@@ -419,8 +438,11 @@ bool Battery::checkChargeLevelCurrent () {
bool Battery::checkChargeLevelLastfull () {
kdDebugFuncIn(trace);
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkChargeLevelLastfull couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
@@ -431,20 +453,15 @@ bool Battery::checkChargeLevelLastfull () {
return false;
}
- if (dbus_HAL->halGetPropertyInt(udi, "battery.charge_level.last_full", &charge_level_lastfull)) {
- if (charge_level_lastfull < charge_level_current ) {
- //possible overflow?
- charge_level_lastfull = charge_level_current;
- }
- kdDebugFuncOut(trace);
- return true;
- } else {
- //query was not successfull (is mandatory)
- kdError() << "couldn't query last_full of udi: " << udi << endl;
- charge_level_lastfull = 0; // set back to 0
- kdDebugFuncOut(trace);
- return false;
+ // FIXME VERIFY CORRECTNESS
+ // what does kpowersave expect to see in charge_level_lastfull (battery.charge_level.last_full)?
+ charge_level_lastfull = bdevice->maximumEnergy();
+ if (charge_level_lastfull < charge_level_current ) {
+ //possible overflow?
+ charge_level_lastfull = charge_level_current;
}
+ kdDebugFuncOut(trace);
+ return true;
}
//! to check battery.charge_level.rate
@@ -456,9 +473,12 @@ bool Battery::checkChargeLevelLastfull () {
*/
bool Battery::checkChargeLevelRate () {
kdDebugFuncIn(trace);
-
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkChargeLevelRate couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
@@ -471,22 +491,17 @@ bool Battery::checkChargeLevelRate () {
int _rate = present_rate;
- if (dbus_HAL->halGetPropertyInt(udi, "battery.charge_level.rate", &present_rate)) {
- if (present_rate < 0 )
- present_rate = 0;
+ // FIXME VERIFY CORRECTNESS
+ // what does kpowersave expect to see in present_rate (battery.charge_level.rate)?
+ present_rate = bdevice->dischargeRate();
+ if (present_rate < 0 )
+ present_rate = 0;
- if (present_rate != _rate)
- emit changedBattery();
+ if (present_rate != _rate)
+ emit changedBattery();
- kdDebugFuncOut(trace);
- return true;
- } else {
- //query was not successfull but this is optional
- kdError() << "Couldn't request charge_level.rate for udi: " << udi << endl;
- present_rate = 0;
- kdDebugFuncOut(trace);
- return false;
- }
+ kdDebugFuncOut(trace);
+ return true;
}
@@ -500,8 +515,11 @@ bool Battery::checkChargeLevelRate () {
bool Battery::checkChargeLevelUnit () {
kdDebugFuncOut(trace);
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkChargeLevelRate couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
@@ -512,15 +530,13 @@ bool Battery::checkChargeLevelUnit () {
return false;
}
- if (!dbus_HAL->halGetPropertyString(udi, "battery.charge_level.unit", &charge_level_unit)) {
- //query was not successfull but this is optional
- kdWarning() << "Couldn't request charge_level.unit for udi: " << udi << endl;
- kdDebugFuncOut(trace);
- return false;
- } else {
- kdDebugFuncOut(trace);
- return true;
- }
+ // FIXME VERIFY CORRECTNESS
+ // what does kpowersave expect to see in charge_level_unit (battery.charge_level.unit)?
+ charge_level_unit = "wH";
+ //query was not successfull but this is optional
+ kdWarning() << "Couldn't request charge_level.unit for udi: " << udi << endl;
+ kdDebugFuncOut(trace);
+ return false;
}
//! to check battery.charge_level.design
@@ -533,8 +549,11 @@ bool Battery::checkChargeLevelUnit () {
bool Battery::checkChargeLevelDesign () {
kdDebugFuncIn(trace);
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkChargeLevelDesign couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
@@ -545,18 +564,15 @@ bool Battery::checkChargeLevelDesign () {
return false;
}
- if (dbus_HAL->halGetPropertyInt(udi, "battery.charge_level.design", &design_capacity)) {
- if (design_capacity < 0)
- design_capacity = 0;
-
- kdDebugFuncOut(trace);
- return true;
- } else {
- //query was not successfull (is mandatory but not critical)
- kdWarning() << "Couldn't request charge_level.design for udi: " << udi << endl;
- kdDebugFuncOut(trace);
- return false;
+ // FIXME VERIFY CORRECTNESS
+ // what does kpowersave expect to see in design_capacity (battery.charge_level.last_full)?
+ design_capacity = bdevice->maximumDesignEnergy();
+ if (design_capacity < 0) {
+ design_capacity = 0;
}
+
+ kdDebugFuncOut(trace);
+ return true;
}
@@ -574,8 +590,11 @@ bool Battery::checkRemainingPercentage () {
int _val = 0;
int _state = -1;
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkRemainingPercentage couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
@@ -586,24 +605,13 @@ bool Battery::checkRemainingPercentage () {
return false;
}
- if (dbus_HAL->halGetPropertyInt(udi, "battery.charge_level.percentage", &_val)) {
- if (_val > 100) {
- _val = 100;
- } else if (_val < 0) {
- _val = 0;
- }
- ret = true;
- } else {
- //query was not successfull, but this property is optional
- //so we calculate it from charge_level
- if (charge_level_current > 0) {
- _val = (int)((float)(charge_level_current * 100) / (float)charge_level_lastfull);
- ret = true;
- } else {
- kdError() << "Couldn't query percentage of udi: " << udi
- << ". and charge_level_current >= 0" << endl;
- }
+ _val = bdevice->chargePercent();
+ if (_val > 100) {
+ _val = 100;
+ } else if (_val < 0) {
+ _val = 0;
}
+ ret = true;
if (charge_level_percentage != _val) {
if (initialized) {
@@ -660,8 +668,11 @@ bool Battery::checkRemainingTime () {
int _min = 0;
bool _ret = false;
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkRemainingTime couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
@@ -672,23 +683,9 @@ bool Battery::checkRemainingTime () {
return false;
}
- if (dbus_HAL->halGetPropertyInt(udi, "battery.remaining_time", &_min)) {
- _min /= 60;
- _ret = true;
- } else {
- //query was not successfull, but this is optional
- //and even very unlikely to be present
-
- //try to get it via charge_level_current and present_rate
- if (charge_level_current > 0 && present_rate > 0) {
- _min = ((charge_level_current * 60 )/ present_rate) ;
- _ret = true;
- } else {
- //we don't know it better
- _min = 0;
- _ret = false;
- }
- }
+ _min = bdevice->timeRemaining();
+ _min /= 60;
+ _ret = true;
if (remaining_minutes != _min) {
if (initialized) {
@@ -718,34 +715,32 @@ bool Battery::checkChargingState () {
bool _ret = false;
int _c_state = -1;
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- kdError() << "Couldn't connect to HAL" << endl;
+ // First make sure the battery object is still available
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(m_hwdevices->findByUniqueID(udi));
+ if (!bdevice) {
+ //grr... no luck
+ kdError() << "Battery::checkChargingState couldn't find battery" << endl;
kdDebugFuncOut(trace);
return false;
}
-
if (!present) {
kdWarning() << "No need to update property, battery not present." << endl;
kdDebugFuncOut(trace);
return false;
}
- if (dbus_HAL->halGetPropertyBool(udi, "battery.rechargeable.is_charging", &tmp_bool) &&
- dbus_HAL->halGetPropertyBool(udi, "battery.rechargeable.is_discharging", &tmp_bool2)) {
- if (tmp_bool && !tmp_bool2) {
- _c_state = CHARGING;
- } else if (tmp_bool2 && !tmp_bool) {
- _c_state = DISCHARGING;
- } else {
- _c_state = UNKNOWN_STATE;
- }
-
- _ret = true;
+ tmp_bool = (bdevice->status() == TDEBatteryStatus::Charging);
+ tmp_bool2 = (bdevice->status() == TDEBatteryStatus::Discharging);
+
+ if (tmp_bool && !tmp_bool2) {
+ _c_state = CHARGING;
+ } else if (tmp_bool2 && !tmp_bool) {
+ _c_state = DISCHARGING;
} else {
- kdError() << "Couldn't get current charging state for udi: " << udi << endl;
_c_state = UNKNOWN_STATE;
- _ret = false;
}
+
+ _ret = true;
if (charging_state != _c_state) {
if (initialized) {
@@ -766,64 +761,16 @@ bool Battery::checkChargingState () {
/*!
* Check for the given property new values from HAL and set them to
* the battery variables.
- * \param _udi TQString with the UDI of the device to recheck
- * \param _property TQString with the property which was changed
- * \return boolean with the result of the operation
- * \retval true if the update was successfull
- * \retval false if the update couldn't be applied
+ * \param device TDEGenericDevice
*/
-bool Battery::updateProperty(TQString _udi, TQString _property) {
+void Battery::updateProperty(TDEGenericDevice* device) {
kdDebugFuncIn(trace);
- //first check whether HAL is available
- if (!dbus_HAL->isConnectedToHAL() && !dbus_HAL->reconnect()) {
- //grr... no luck
- kdError() << "Battery::updateProperty couldn't connect to HAL" << endl;
- kdDebugFuncOut(trace);
- return false;
- }
-
- bool ret = true;
-
- if (udi.startsWith(_udi)) {
- // handle different keys and update only the needed
- if (_property.startsWith("battery.present")) {
- if (!checkBatteryPresent()) ret = false;
- } else if (_property.startsWith("battery.type")) {
- if (!checkBatteryType()) ret = false;
- } else if (_property.startsWith("battery.charge_level.capacity_state")) {
- if (!checkCapacityState()) ret= false;
- } else if (_property.startsWith("battery.charge_level.current")) {
- if (!checkChargeLevelCurrent()) ret = false;
- } else if (_property.startsWith("battery.charge_level.rate")) {
- if (!checkChargeLevelRate()) ret = false;
- } else if (_property.startsWith("battery.charge_level.percentage")) {
- if (!checkRemainingPercentage()) ret = false;
- } else if (_property.startsWith("battery.remaining_time")) {
- if (!checkRemainingTime()) ret = false;
- } else if (_property.startsWith("battery.rechargeable.is_")) {
- if (!checkChargingState()) ret = false;
- } else if (_property.startsWith("battery.charge_level.last_full")) {
- if (!checkChargeLevelLastfull()) ret = false;
- // --> changes on this keys should normally not happen except if battery was added /removed
- } else if (_property.startsWith("battery.technology")) {
- if (!checkBatteryTechnology()) ret = false;
- } else if (_property.startsWith("battery.charge_level.unit")) {
- if (!checkChargeLevelUnit()) ret = false;
- } else if (_property.startsWith("battery.charge_level.design")) {
- if (!checkChargeLevelDesign()) ret = false;
- } else {
- kdDebug() << "Unknown or unhandled device property: " << _property
- << " for device with udi: " << _udi << endl;
- ret = false;
- }
- } else {
- kdError() << "Given UDI doesn't match the UDI of this battery object." << endl;
- ret = false;
+ if (device->uniqueID() == udi) {
+ recheck();
}
kdDebugFuncOut(trace);
- return ret;
}
//! Resets the current HAL udi used by the one given
@@ -838,23 +785,9 @@ bool Battery::updateProperty(TQString _udi, TQString _property) {
bool Battery::resetUdi(TQString _udi) {
kdDebugFuncIn(trace);
- bool tmp_result=false;
-
- //trivial pre-check to eliminate totally dumb _udi strings
- if (!_udi.isNull() && !_udi.isEmpty() && _udi.startsWith("/org/freedesktop/Hal/devices/")) {
-
- //ok, now lets ask HAL if its really a battery
- if (dbus_HAL->isConnectedToHAL() || dbus_HAL->reconnect()) {
-
- dbus_HAL->halQueryCapability(_udi,"battery",&tmp_result);
-
- } else {
- kdError() << "Battery::resetUdi couldn't connect to HAL" << endl;
- }
-
- } else {
- kdError() << "Battery::resetUdi received empty or invalid udi" << endl;
- }
+ // FIXME
+ // What does this function do outside of HAL!?!? Should it even exist any more?
+ bool tmp_result=true;
kdDebugFuncOut(trace);
return tmp_result;
diff --git a/src/hardware_battery.h b/src/hardware_battery.h
index 2506c83..1eaa7b0 100644
--- a/src/hardware_battery.h
+++ b/src/hardware_battery.h
@@ -42,6 +42,9 @@
#include <tqstringlist.h>
#include <tqobject.h>
+// TDE hardware library
+#include <tdehardwaredevices.h>
+
#include "dbusHAL.h"
class Battery : public TQObject {
@@ -50,12 +53,11 @@ class Battery : public TQObject {
private:
- //! Internal reference to dbusHAL for communication with HAL daemon
- dbusHAL* dbus_HAL;
+ TDEHardwareDevices *m_hwdevices;
- //! HAL udi of the battery to represent
+ //! TDE hardware library udi of the battery to represent
/*!
- * This TQString holds the HAL udi adress of the battery.
+ * This TQString holds the TDE hardware library udi adress of the battery.
* \li empty: all primary batteries are represented
* \li e.g. "/org/freedesktop/Hal/devices/acpi_BAT0": first acpi battery
*/
@@ -67,10 +69,10 @@ private:
* \li e.g. "LION"
*/
TQString technology;
- //! Current charging state of this battery as reported by HAL
+ //! Current charging state of this battery as reported by TDE hardware library
/*!
- * This TQString tells the current capacity_state HAL is reporting.
- * \li as of current HAL spec: "ok", "critical"
+ * This TQString tells the current capacity_state TDE hardware library is reporting.
+ * \li as of current TDE hardware library spec: "ok", "critical"
*/
TQString capacity_state;
//! Unit of charge_level_unit and charge_level_lastfull.
@@ -116,7 +118,7 @@ private:
* \li BAT_LOW: batterylevel is already low
* \li BAT_CRIT: batterylevel has become really critical
* \li BAT_NONE: battery state not available
- * \li BAT_HAL_ERROR: battery state couldn't be retrieved because of a HAL error
+ * \li BAT_TDE hardware library_ERROR: battery state couldn't be retrieved because of a TDE hardware library error
*/
int state;
//! Current charging state of this battery
@@ -221,31 +223,30 @@ signals:
void changedBatteryWarnState (int state);
//! emitted if any Battery state changed
void changedBattery();
-
+
+public slots:
+ //! update a property on device event
+ void updateProperty(TDEGenericDevice*);
+
public:
//! default constructor
- Battery( dbusHAL* _dbus_HAL, TQString _udi );
- //! default constructor
- Battery( dbusHAL* _dbus_HAL );
- //! this constructor forces the use of init with dbuHAL pointer set!
- Battery();
+ Battery( TQString _udi );
//! default destructor
~Battery();
- //! initialize this battery object with values from HAL
- void init( dbusHAL* _dbus_HAL = NULL );
+ //! initialize this battery object with values from TDE hardware library
+ void init();
//! recheck all properties of the battery
void recheck();
//! rechecks only minimalistic set properties
void minRecheck();
- //! update a property on HAL event
- bool updateProperty(TQString _udi, TQString _property);
+
//ro-Interface to internal data
- //! reports the HAL udi of this battery
+ //! reports the TDE hardware library udi of this battery
TQString getUdi() const;
- //! reports HAL capacity_state value
+ //! reports TDE hardware library capacity_state value
TQString getCapacityState() const;
//! reports the physical unit of values like DesignCapacity, PresentRate and Lastfull
TQString getChargelevelUnit() const;
@@ -282,9 +283,9 @@ public:
int getCritLevel() const;
//writeable access to internals
- //! Resets the current HAL udi used by the one given
+ //! Resets the current TDE hardware library udi used by the one given
/*!
- * The given TQString will be (checked and) used as new HAL udi for the battery.
+ * The given TQString will be (checked and) used as new TDE hardware library udi for the battery.
* But don't forget to do a recheck of the battery afterwards.
* \li returns TRUE: if reset was successfull
* \li returns FALSE: if reset couldn't be applied
diff --git a/src/hardware_cpu.cpp b/src/hardware_cpu.cpp
index 1473a6d..5847dd9 100644
--- a/src/hardware_cpu.cpp
+++ b/src/hardware_cpu.cpp
@@ -46,6 +46,8 @@ CPUInfo::CPUInfo() {
update_info_cpufreq_speed_changed = true;
numOfCPUs = -1;
+
+ m_hwdevices = KGlobal::hardwareDevices();
kdDebugFuncOut(trace);
}
@@ -60,35 +62,8 @@ CPUInfo::~CPUInfo() {
* Returns the total count of CPUs - _not_ the last CPU ID!
*/
int CPUInfo::getCPUNum() {
- kdDebugFuncIn(trace);
-
- int cpu_id=0;
- TQDir tmp_dir;
- TQString cpu_path = "/sys/devices/system/cpu/cpu0/";
-#ifdef FAKE_CPU
- cpu_path.prepend("/tmp/foo");
-#endif
-
- // let check if we support cpufreq in general
- if (tmp_dir.exists(tmp_dir.absFilePath(cpu_path + "cpufreq/scaling_cur_freq", true))) {
- cpuFreqHW = true;
- } else {
- cpuFreqHW = false;
- }
-
- TQString tmp_path = tmp_dir.absFilePath(cpu_path, true);
-
- while (tmp_dir.exists(tmp_path)) {
- int tmp = cpu_id;
-
- cpu_id++;
- cpu_path.replace(TQString::number(tmp), TQString::number(cpu_id));
- tmp_path = tmp_dir.absFilePath(cpu_path, true);
- }
-
- kdDebug() << "getCPUNum() return: '" << cpu_id << "'" << endl;
- kdDebugFuncOut(trace);
- return cpu_id;
+ TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::CPU);
+ return hwlist.count();
}
/*!
diff --git a/src/hardware_cpu.h b/src/hardware_cpu.h
index 32254d9..7d9c94d 100644
--- a/src/hardware_cpu.h
+++ b/src/hardware_cpu.h
@@ -43,6 +43,9 @@
#include <tqobject.h>
#include <tqvaluelist.h>
+// TDE hardware library
+#include <tdehardwaredevices.h>
+
// own headers
#include "kpowersave_debug.h"
@@ -57,6 +60,8 @@ private:
/*! This contains the number of CPUs in the current system */
int numOfCPUs;
+ TDEHardwareDevices *m_hwdevices;
+
public:
//! represent the current Throttling of the CPU
diff --git a/src/kpowersave.cpp b/src/kpowersave.cpp
index b1c3a35..3f19e22 100644
--- a/src/kpowersave.cpp
+++ b/src/kpowersave.cpp
@@ -102,8 +102,6 @@ kpowersave::kpowersave( bool force_acpi_check, bool trace_func ) : KSystemTray(0
// connect to error mesages
connect(autoSuspend, TQT_SIGNAL(displayErrorMsg(TQString)), this, TQT_SLOT(showErrorMessage(TQString)));
- connect(hwinfo, TQT_SIGNAL(halRunning(bool)), this, TQT_SLOT(showHalErrorMsg()));
- connect(hwinfo, TQT_SIGNAL(dbusRunning(int)), this, TQT_SLOT(showDBusErrorMsg(int)));
// connect to events
connect(hwinfo, TQT_SIGNAL(lidclosetStatus(bool)), this, TQT_SLOT(handleLidEvent(bool)));
@@ -121,7 +119,6 @@ kpowersave::kpowersave( bool force_acpi_check, bool trace_func ) : KSystemTray(0
config_dialog_shown = false;
suspend_dialog_shown = false;
detailedIsShown = false;
- hal_error_shown = false;
icon_set_colored = false;
icon_BG_is_colored = false;
@@ -134,9 +131,6 @@ kpowersave::kpowersave( bool force_acpi_check, bool trace_func ) : KSystemTray(0
BAT_WARN_ICON_Timer = new TQTimer(this);
connect(BAT_WARN_ICON_Timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(do_setIconBG()));
- DISPLAY_HAL_ERROR_Timer = new TQTimer(this);
- connect(DISPLAY_HAL_ERROR_Timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(showHalErrorMsg()));
-
AUTODIMM_Timer = new TQTimer(this);
initMenu();
@@ -287,7 +281,7 @@ void kpowersave::showConfigureDialog() {
i18n("Warning").ascii(), 15000);
}
} else {
- configDlg->setWindowState(configDlg->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
+ configDlg->setWindowState((configDlg->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
configDlg->setActiveWindow();
}
@@ -317,7 +311,7 @@ void kpowersave::loadIcon(){
BatteryCollection *primary = hwinfo->getPrimaryBatteries();
- if (hwinfo->hal_terminated || !hwinfo->isOnline() ) {
+ if ( !hwinfo->isOnline() ) {
pixmap_name_tmp = TQString("ERROR");
}
else if (hwinfo->getAcAdapter() || primary->getBatteryState() == BAT_NONE) {
@@ -461,7 +455,7 @@ void kpowersave::updateTooltip(){
num3.setNum(minutes % 60);
num3 = num3.rightJustify(2, '0');
- if (hwinfo->hal_terminated){
+ if ( !hwinfo->isOnline() ){
tmp = i18n("No information about battery and AC status available");
}
else if (hwinfo->getAcAdapter()) {
@@ -1648,85 +1642,6 @@ void kpowersave::closedetaileddialog() {
}
/*!
- * \b TQT_SLOT used to display error messages related to D-Bus in kpowersave. This function
- * block all messeges which we have in kpowersave!
- * TODO: do something usefull
- */
-void kpowersave::showDBusErrorMsg( int type ){
- kdDebugFuncIn(trace);
-
- static bool displayed = false;
-
- TQString msg;
- TQString dlg_name;
-
- switch (type) {
- case DBUS_RUNNING:
- update();
- return;
- case DBUS_NOT_RUNNING:
- msg = i18n("The D-Bus daemon is not running.\nStarting it will "
- "provide full functionality: /etc/init.d/dbus start");
- dlg_name = "dbusNotRunning";
- break;
- default:
- kdDebugFuncOut(trace);
- return;
- }
-
- if (!displayed && !dlg_name.isEmpty()) {
- infoDialog *dlg = new infoDialog( config, i18n("Warning"), msg,
- i18n("Don't show this message again."), dlg_name);
-
- if (!dlg->dialogIsDisabled()) {
- dlg->show();
- }
- // set this always to true ... this should reduce the calls
- displayed = true;
- }
-
- kdDebugFuncOut(trace);
-}
-
-/*!
- * \b TQT_SLOT to display the HAL error message. We use this
- * function to delay the message, and prevent display them is HAL or
- * powersaved restarted.
- */
-void kpowersave::showHalErrorMsg() {
- kdDebugFuncIn(trace);
-
- if (hwinfo->isOnline()) {
- // HAL is back!
- update();
- }
- if (!hwinfo->dbus_terminated) {
- if(hal_error_shown && !DISPLAY_HAL_ERROR_Timer->isActive() && hwinfo->hal_terminated){
- KPassivePopup::message( i18n("ERROR"),
- i18n("Could not get information from HAL. The haldaemon is "
- "maybe not running."),
- SmallIcon("messagebox_warning", 20), this,
- i18n("Error").ascii(), 5000);
- }
- else if (hwinfo->hal_terminated && !hal_error_shown && !DISPLAY_HAL_ERROR_Timer->isActive()) {
- hal_error_shown = true;
- DISPLAY_HAL_ERROR_Timer->start(HAL_ERROR_MSG_intervall, true);
- }
- else if (!hwinfo->hal_terminated) {
- hal_error_shown = false;
- DISPLAY_HAL_ERROR_Timer->stop();
- }
- } else {
- // only for the case that HAL is also down with dbus and not back after restart
- if (hwinfo->hal_terminated && !hal_error_shown && !DISPLAY_HAL_ERROR_Timer->isActive())
- DISPLAY_HAL_ERROR_Timer->start(HAL_ERROR_MSG_intervall, true);
- }
-
- kdDebugFuncOut(trace);
- return;
-}
-
-/*!
* \b TQT_SLOT used to display messeges in kpowersave. This function
* block all messeges which we have in kpowersave!
*/
diff --git a/src/kpowersave.h b/src/kpowersave.h
index 6d3f124..574d5c8 100644
--- a/src/kpowersave.h
+++ b/src/kpowersave.h
@@ -156,14 +156,6 @@ private:
* \li false: if not
*/
bool suspend_dialog_shown;
- //! represent display state of HAL error message
- /*!
- * This boolean represent information about the current state of
- * the HAL error message
- * \li true: if the errormessage was already displayed in this context
- * \li false: if not
- */
- bool hal_error_shown;
//! tell if the display should get dimmed down
/*!
@@ -238,13 +230,6 @@ private:
*/
static const int BAT_icon_BG_intervall = 1000;
- //! TQTimer-interval for display HAL error message
- /*!
- * Time intervall to delay display the HAL error message to prevent displayed
- * the message if only HAL or powersave is restarted. The value is 15000 msec/ 15 sec.
- */
- static const int HAL_ERROR_MSG_intervall = 15000;
-
//! type of current running suspend
/*! TQString store the name of the current running suspend*/
TQString suspendType;
@@ -288,12 +273,6 @@ private:
* The timerinterval is defined in \ref BAT_icon_BG_intervall .
*/
TQTimer *BAT_WARN_ICON_Timer;
- //! Timer to delay the HAL error message
- /*!
- * This timer is used to add a delay befor display the HAL error message
- * The timerinterval is defined in \ref HAL_ERROR_MSG_intervall .
- */
- TQTimer *DISPLAY_HAL_ERROR_Timer;
//! Timer to dimm down/up the brightness
/*!
* This timer is used dimm the display up and down. The timerinterval
@@ -329,11 +308,11 @@ private:
private slots:
- //! send command for stand-by to the HAL daemon
+ //! send command for stand-by to the TDE hardware library
bool do_standby();
- //! send command for suspend_to_disk to the HAL daemon
+ //! send command for suspend_to_disk to the TDE hardware library
bool do_suspend2disk();
- //! send command for suspend_to_RAM to the HAL daemon
+ //! send command for suspend_to_RAM to the TDE hardware library
bool do_suspend2ram();
//! show warning dialog or call autosuspend if signal \ref inactivity::inactivityTimeExpired() recieved
@@ -348,7 +327,7 @@ private slots:
void do_setIconBG();
//! to set the autosuspend on/off over the menu
void do_setAutosuspend();
- //! sets the CPU Freq policy via the HAL daemon
+ //! sets the CPU Freq policy via the TDE hardware library
void do_setSpeedPolicy( int );
//! called if there are problems with starting yast module
void slotConfigProcessExited( KProcess * );
@@ -423,10 +402,6 @@ private slots:
//! this emit the KNotify events if the machine resumed
void handleResumeSignal();
- //! to display HAL error msg
- void showHalErrorMsg( );
- //! this is invoked to display powersave error message
- void showDBusErrorMsg( int );
//! this show a blocking dialog from kpowersave with the given message
void showErrorMessage( TQString msg );