BatteryClientBlackBerry.cpp [plain text]
#include "config.h"
#include "BatteryClientBlackBerry.h"
#if ENABLE(BATTERY_STATUS)
#include "BatteryController.h"
#include <stdio.h>
namespace WebCore {
BatteryClientBlackBerry::BatteryClientBlackBerry()
: m_tracker(0)
, m_controller(0)
{
}
void BatteryClientBlackBerry::setController(BatteryController* controller)
{
m_controller = controller;
}
void BatteryClientBlackBerry::startUpdating()
{
if (m_tracker)
m_tracker->resume();
else
m_tracker = BlackBerry::Platform::BatteryStatusTracker::create(this);
}
void BatteryClientBlackBerry::stopUpdating()
{
if (m_tracker)
m_tracker->suspend();
}
void BatteryClientBlackBerry::batteryControllerDestroyed()
{
delete this;
}
void BatteryClientBlackBerry::onLevelChange(bool charging, double chargingTime, double dischargingTime, double level)
{
if (!m_controller)
return;
m_controller->didChangeBatteryStatus("levelchange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
}
void BatteryClientBlackBerry::onChargingChange(bool charging, double chargingTime, double dischargingTime, double level)
{
if (!m_controller)
return;
m_controller->didChangeBatteryStatus("chargingchange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
}
void BatteryClientBlackBerry::onChargingTimeChange(bool charging, double chargingTime, double dischargingTime, double level)
{
if (!m_controller)
return;
m_controller->didChangeBatteryStatus("chargingtimechange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
}
void BatteryClientBlackBerry::onDischargingTimeChange(bool charging, double chargingTime, double dischargingTime, double level)
{
if (!m_controller)
return;
m_controller->didChangeBatteryStatus("dischargingtimechange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
}
}
#endif // BATTERY_STATUS