/*
 * 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 ()
{
    DEBUG_CLOCK_START;
    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)));

    /*
     * 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?

    /*
     * Init the power-save-mode value, and connect to QmSystem2 signal
     */
    m_PowerSaveMode = (m_devicemode->getPSMState () ==
                       MeeGo::QmDeviceMode::PSMStateOn);
    connect (m_devicemode,
             SIGNAL (devicePSMStateChanged (MeeGo::QmDeviceMode::PSMState)),
             this, SLOT (PSMStateChanged (MeeGo::QmDeviceMode::PSMState)));
    #else
    /*
     * FIXME: To create an implementation without the QmSystem
     */
    #endif

    recalculateChargingInfo ();
    DEBUG_CLOCK_END("Data request");
}
/*
 * 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
}
Пример #3
0
BatteryNotifier::BatteryNotifier(QObject *parent) :
    QObject(parent), lowBatteryNotifier(0), notificationId(0), touchScreenLockActive(false)
    ,qmBattery(new MeeGo::QmBattery),
    qmDeviceMode(new MeeGo::QmDeviceMode),
    qmLed(new MeeGo::QmLED),
    chargerType(MeeGo::QmBattery::Unknown)
{
    connect(qmBattery, SIGNAL(batteryStateChanged(MeeGo::QmBattery::BatteryState)), this, SLOT(batteryStateChanged(MeeGo::QmBattery::BatteryState)));
    connect(qmBattery, SIGNAL(chargingStateChanged(MeeGo::QmBattery::ChargingState)), this, SLOT(chargingStateChanged(MeeGo::QmBattery::ChargingState)));
    connect(qmBattery, SIGNAL(chargerEvent(MeeGo::QmBattery::ChargerType)), this, SLOT(batteryChargerEvent(MeeGo::QmBattery::ChargerType)));

    connect(qmDeviceMode, SIGNAL(devicePSMStateChanged(MeeGo::QmDeviceMode::PSMState)), this, SLOT(devicePSMStateChanged(MeeGo::QmDeviceMode::PSMState)));

    // Init battery values delayed...
    initBattery();

    notificationTimer.setInterval(5000);
    notificationTimer.setSingleShot(true);
}