BatteryClientBlackBerry.cpp [plain text]
#include "config.h"
#include "BatteryClientBlackBerry.h"
#if ENABLE(BATTERY_STATUS)
#include "BatteryController.h"
#include "WebPage_p.h"
#include <stdio.h>
namespace WebCore {
BatteryClientBlackBerry::BatteryClientBlackBerry(BlackBerry::WebKit::WebPagePrivate* webPagePrivate)
: m_webPagePrivate(webPagePrivate)
, m_isActive(false)
{
}
void BatteryClientBlackBerry::startUpdating()
{
if (!m_isActive) {
BlackBerry::Platform::BatteryStatusHandler::instance()->addListener(this);
m_isActive = true;
}
}
void BatteryClientBlackBerry::stopUpdating()
{
if (m_isActive) {
BlackBerry::Platform::BatteryStatusHandler::instance()->removeListener(this);
m_isActive = false;
}
}
void BatteryClientBlackBerry::batteryControllerDestroyed()
{
delete this;
}
void BatteryClientBlackBerry::onStatusChange(bool charging, double chargingTime, double dischargingTime, double level)
{
BatteryController::from(m_webPagePrivate->m_page)->updateBatteryStatus(BatteryStatus::create(charging, chargingTime, dischargingTime, level));
}
}
#endif // BATTERY_STATUS