void BatteryBusinessLogic::setPSMValue ( bool enabled) { bool ret = false; #ifdef HAVE_QMSYSTEM ret = m_devicemode->setPSMState ( enabled ? QmDeviceMode::PSMStateOn : QmDeviceMode::PSMStateOff); #else /* * FIXME: To implement the setting of the power save mode without the help * of the QmSystem library. */ #endif if (ret) { // Change succeed, we don't need to wait for QmSystem reply, we can emit // the PSMValueChanged asap to update the UI. SYS_DEBUG ("Emitting PSMValueReceived(%s)", SYS_BOOL(enabled)); emit PSMValueReceived (enabled); } else { SYS_WARNING ("Failed to set PSM mode to %s", enabled ? "QmDeviceMode::PSMStateOn" : "QmDeviceMode::PSMStateOff"); } }
/*! * This slot will be called when the device power save mode is changed. The * method will send the PSMValueReceived() signal. */ void BatteryBusinessLogic::PSMStateChanged ( MeeGo::QmDeviceMode::PSMState state) { bool enabled = state == QmDeviceMode::PSMStateOn; SYS_DEBUG ("Emitting PSMValueReceived (%s)", SYS_BOOL(enabled)); emit PSMValueReceived (enabled); }
/*! * This slot will be called when the device power save mode is changed. The * method will send the PSMValueReceived() signal. */ void BatteryBusinessLogic::PSMStateChanged ( MeeGo::QmDeviceMode::PSMState state) { m_PowerSaveMode = (state == MeeGo::QmDeviceMode::PSMStateOn); SYS_DEBUG ("Emitting PSMValueReceived (%s)", SYS_BOOL (m_PowerSaveMode)); emit PSMValueReceived (m_PowerSaveMode); }
/* * This function does the initialization and signal connection to QmBattery and * QmDeviceMode, and emits all the signals with the current values... * * FIXME: This function should be called realize() or something... */ void BatteryBusinessLogic::requestValues () { if (m_initialized) return; m_initialized = true; #ifdef HAVE_QMSYSTEM SYS_DEBUG ("Connecting to the signals of the QmBattery class"); connect ( m_battery, SIGNAL(chargerEvent(MeeGo::QmBattery::ChargerType)), this, SLOT(batteryChargerEvent(MeeGo::QmBattery::ChargerType))); connect ( m_battery, SIGNAL(chargingStateChanged(MeeGo::QmBattery::ChargingState)), this, SLOT(chargingStateChanged(MeeGo::QmBattery::ChargingState))); connect ( m_battery, SIGNAL(batteryStateChanged(MeeGo::QmBattery::BatteryState)), this, SLOT (batteryStateChanged(MeeGo::QmBattery::BatteryState))); // This will emit the batteryCharging signal, // and the remainingTimeValuesChanged signal chargingStateChanged (m_battery->getChargingState ()); /* * We have two signals showing that the battery energy level has been * changed. We listen both of these signals. */ SYS_DEBUG ("Connecting to the signals of the QmBattery class"); connect (m_battery, SIGNAL (batteryRemainingCapacityChanged (int, int)), this, SLOT (batteryRemCapacityChanged (int, int))); // batteryBarValueReceived also emitted by chargingStateChanged ^^^ // FIXME: Why? connect (m_devicemode, SIGNAL (devicePSMStateChanged (MeeGo::QmDeviceMode::PSMState)), this, SLOT (PSMStateChanged (MeeGo::QmDeviceMode::PSMState))); SYS_DEBUG ("Emitting PSMValueReceived(%s)", SYS_BOOL(m_devicemode->getPSMState () == QmDeviceMode::PSMStateOn)); emit PSMValueReceived (m_devicemode->getPSMState () == QmDeviceMode::PSMStateOn); #else /* * FIXME: To create an implementation without the QmSystem */ #endif }