Changeset 117378 in webkit


Ignore:
Timestamp:
May 16, 2012 7:09:16 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL] Support for Battery Status API on the WebKit-Efl
https://bugs.webkit.org/show_bug.cgi?id=83254

Patch by Kihong Kwon <kihong.kwon@samsung.com> on 2012-05-16
Reviewed by Chang Shu.

.:

Add dependency check for e_ukit package which is in the e_dbus library.

  • Source/cmake/FindEFL.cmake:

Source/WebKit:

Add e_ukit library and include directory to get battery status of device.

  • PlatformEfl.cmake:

Source/WebKit/efl:

The set of e_dbus libraries, e_ukit library in particular, enables to support all types of battery status events (e.g., charging, chargingTime, dischargingTime, level).

  • WebCoreSupport/BatteryClientEfl.cpp:

(WebCore::BatteryClientEfl::BatteryClientEfl):
(WebCore::BatteryClientEfl::startUpdating):
(WebCore::BatteryClientEfl::stopUpdating):
(WebCore::BatteryClientEfl::setBatteryStatus):
(WebCore):
(WebCore::BatteryClientEfl::timerFired):
(WebCore::BatteryClientEfl::getBatteryStatus):
(WebCore::BatteryClientEfl::setBatteryClient):

  • WebCoreSupport/BatteryClientEfl.h:

(WebCore::BatteryClientEfl::batteryStatus):
(BatteryClientEfl):

Tools:

Add e_dbus libraries to jhbuild's modules list.

  • efl/jhbuild.modules:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r117327 r117378  
     12012-05-16  Kihong Kwon  <kihong.kwon@samsung.com>
     2
     3        [EFL] Support for Battery Status API on the WebKit-Efl
     4        https://bugs.webkit.org/show_bug.cgi?id=83254
     5
     6        Reviewed by Chang Shu.
     7
     8        Add dependency check for e_ukit package which is in the e_dbus library.
     9
     10        * Source/cmake/FindEFL.cmake:
     11
    1122012-05-16  Varun Jain  <varunjain@google.com>
    213
  • trunk/Source/WebKit/ChangeLog

    r117046 r117378  
     12012-05-16  Kihong Kwon  <kihong.kwon@samsung.com>
     2
     3        [EFL] Support for Battery Status API on the WebKit-Efl
     4        https://bugs.webkit.org/show_bug.cgi?id=83254
     5
     6        Reviewed by Chang Shu.
     7
     8        Add e_ukit library and include directory to get battery status of device.
     9
     10        * PlatformEfl.cmake:
     11
    1122012-05-15  Tomasz Morawski  <t.morawski@samsung.com>
    213
  • trunk/Source/WebKit/PlatformEfl.cmake

    r117046 r117378  
    2020    ${EFLDEPS_INCLUDE_DIRS}
    2121    ${EVAS_INCLUDE_DIRS}
     22    ${EUKIT_INCLUDE_DIRS}
    2223    ${LIBXML2_INCLUDE_DIR}
    2324    ${LIBXSLT_INCLUDE_DIR}
     
    125126    ${ECORE_X_LIBRARIES}
    126127    ${EFLDEPS_LIBRARIES}
     128    ${EUKIT_LIBRARIES}
    127129    ${FREETYPE_LIBRARIES}
    128130    ${LIBXML2_LIBRARIES}
  • trunk/Source/WebKit/efl/ChangeLog

    r117285 r117378  
     12012-05-16  Kihong Kwon  <kihong.kwon@samsung.com>
     2
     3        [EFL] Support for Battery Status API on the WebKit-Efl
     4        https://bugs.webkit.org/show_bug.cgi?id=83254
     5
     6        Reviewed by Chang Shu.
     7
     8        The set of e_dbus libraries, e_ukit library in particular, enables to support all types of battery status events (e.g., charging, chargingTime, dischargingTime, level).
     9
     10        * WebCoreSupport/BatteryClientEfl.cpp:
     11        (WebCore::BatteryClientEfl::BatteryClientEfl):
     12        (WebCore::BatteryClientEfl::startUpdating):
     13        (WebCore::BatteryClientEfl::stopUpdating):
     14        (WebCore::BatteryClientEfl::setBatteryStatus):
     15        (WebCore):
     16        (WebCore::BatteryClientEfl::timerFired):
     17        (WebCore::BatteryClientEfl::getBatteryStatus):
     18        (WebCore::BatteryClientEfl::setBatteryClient):
     19        * WebCoreSupport/BatteryClientEfl.h:
     20        (WebCore::BatteryClientEfl::batteryStatus):
     21        (BatteryClientEfl):
     22
    1232012-05-16  Thiago Marcos P. Santos  <thiago.santos@intel.com>
    224
  • trunk/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.cpp

    r110991 r117378  
    2424
    2525#include "BatteryController.h"
     26#include "EventNames.h"
     27#include <limits>
    2628
    2729namespace WebCore {
     
    2931BatteryClientEfl::BatteryClientEfl()
    3032    : m_controller(0)
     33    , m_timer(this, &BatteryClientEfl::timerFired)
     34    , m_batteryStatusRefreshInterval(1.0)
    3135{
    3236}
     
    3943void BatteryClientEfl::startUpdating()
    4044{
    41     // FIXME: Need to implement for getting battery status to the efl port.
     45    if (m_timer.isActive())
     46        return;
     47
     48    if (!e_dbus_init())
     49        return;
     50
     51    if (!e_ukit_init()) {
     52        e_dbus_shutdown();
     53        return;
     54    }
     55
     56    m_timer.startRepeating(m_batteryStatusRefreshInterval);
    4257}
    4358
    4459void BatteryClientEfl::stopUpdating()
    4560{
    46     // FIXME: Need to implement for getting battery status to the efl port
     61    m_timer.stop();
     62    e_ukit_shutdown();
     63    e_dbus_shutdown();
    4764}
    4865
     
    5471void BatteryClientEfl::setBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus> batteryStatus)
    5572{
    56     m_controller->didChangeBatteryStatus(eventType, batteryStatus);
     73    m_batteryStatus = batteryStatus;
     74    m_controller->didChangeBatteryStatus(eventType, m_batteryStatus);
     75}
     76
     77void BatteryClientEfl::timerFired(Timer<BatteryClientEfl>* timer)
     78{
     79    ASSERT_UNUSED(timer, timer == &m_timer);
     80    E_DBus_Connection* edbusConnection = e_dbus_bus_get(DBUS_BUS_SYSTEM);
     81    if (edbusConnection)
     82        e_upower_get_all_devices(edbusConnection, getBatteryStatus, static_cast<void*>(this));
     83}
     84
     85void BatteryClientEfl::getBatteryStatus(void* data, void* replyData, DBusError* dBusError)
     86{
     87    E_Ukit_Get_All_Devices_Return* eukitDeviceNames = static_cast<E_Ukit_Get_All_Devices_Return*>(replyData);
     88    if (!eukitDeviceNames || !eukitDeviceNames->strings || dbus_error_is_set(dBusError)) {
     89         dbus_error_free(dBusError);
     90         return;
     91    }
     92
     93    E_DBus_Connection* edbusConnection = e_dbus_bus_get(DBUS_BUS_SYSTEM);
     94    Eina_List* list;
     95    void* deviceName;
     96    EINA_LIST_FOREACH(eukitDeviceNames->strings, list, deviceName)
     97        e_upower_get_all_properties(edbusConnection, static_cast<char*>(deviceName), setBatteryClient, data);
     98}
     99
     100void BatteryClientEfl::setBatteryClient(void* data, void* replyData, DBusError* dBusError)
     101{
     102    E_Ukit_Get_All_Properties_Return* eukitPropertyNames = static_cast<E_Ukit_Get_All_Properties_Return*>(replyData);
     103
     104    if (!eukitPropertyNames || dbus_error_is_set(dBusError)) {
     105        dbus_error_free(dBusError);
     106        return;
     107    }
     108
     109    if (!eukitPropertyNames->properties)
     110        return;
     111
     112    E_Ukit_Property* property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "Type"));
     113    if (!property || property->val.u != E_UPOWER_SOURCE_BATTERY)
     114        return;
     115
     116    BatteryClientEfl* client = static_cast<BatteryClientEfl*>(data);
     117    BatteryStatus* clientBatteryStatus = client->batteryStatus();
     118    bool charging = false;
     119    bool chargingChanged = false;
     120    static unsigned chargingState = 0;
     121
     122    property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "State"));
     123    if (!property)
     124        return;
     125    if (!clientBatteryStatus || chargingState != property->val.u) {
     126        chargingChanged = true;
     127        chargingState = property->val.u;
     128        (chargingState == E_UPOWER_STATE_FULL || chargingState == E_UPOWER_STATE_CHARGING) ? charging = true : charging = false;
     129    } else
     130        charging = clientBatteryStatus->charging();
     131
     132    bool chargingTimeChanged = false;
     133    bool dischargingTimeChanged = false;
     134    double chargingTime = std::numeric_limits<double>::infinity();
     135    double dischargingTime = std::numeric_limits<double>::infinity();
     136
     137    if (charging) {
     138        if (!clientBatteryStatus || clientBatteryStatus->dischargingTime() != std::numeric_limits<double>::infinity())
     139            dischargingTimeChanged = true;
     140        dischargingTime = std::numeric_limits<double>::infinity();
     141        property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "TimeToFull"));
     142        if (!property)
     143            return;
     144        if (!clientBatteryStatus || clientBatteryStatus->chargingTime() != property->val.x)
     145            chargingTimeChanged = true;
     146        chargingTime = property->val.x;
     147    } else {
     148        if (!clientBatteryStatus || clientBatteryStatus->chargingTime() != std::numeric_limits<double>::infinity())
     149            chargingTimeChanged = true;
     150        chargingTime = std::numeric_limits<double>::infinity();
     151        property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "TimeToEmpty"));
     152        if (!property)
     153            return;
     154        if (!clientBatteryStatus || clientBatteryStatus->dischargingTime() != property->val.x)
     155            dischargingTimeChanged = true;
     156        dischargingTime = property->val.x;
     157    }
     158
     159    double level = 0;
     160    bool levelChanged = false;
     161
     162    property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "Percentage"));
     163    if (!property)
     164        return;
     165    if (!clientBatteryStatus || clientBatteryStatus->level() != property->val.d)
     166        levelChanged = true;
     167    level = property->val.d;
     168
     169    WTF::RefPtr<BatteryStatus> batteryStatus = BatteryStatus::create(charging, chargingTime, dischargingTime, level);
     170    if (chargingChanged)
     171        client->setBatteryStatus(eventNames().chargingchangeEvent, batteryStatus);
     172    if (chargingTimeChanged)
     173        client->setBatteryStatus(eventNames().chargingtimechangeEvent, batteryStatus);
     174    if (dischargingTimeChanged)
     175        client->setBatteryStatus(eventNames().dischargingtimechangeEvent, batteryStatus);
     176    if (levelChanged)
     177        client->setBatteryStatus(eventNames().levelchangeEvent, batteryStatus);
    57178}
    58179
  • trunk/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.h

    r110991 r117378  
    2424
    2525#include "BatteryClient.h"
     26#include "BatteryStatus.h"
     27#include "Timer.h"
     28#include <E_Ukit.h>
    2629#include <wtf/text/AtomicString.h>
    2730
     
    4245
    4346    void setBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus>);
     47    BatteryStatus* batteryStatus() { return m_batteryStatus.get(); }
    4448
    4549private:
     50    void timerFired(Timer<BatteryClientEfl>*);
     51    static void getBatteryStatus(void* data, void* replyData, DBusError*);
     52    static void setBatteryClient(void* data, void* replyData, DBusError*);
     53
    4654    BatteryController* m_controller;
     55    Timer<BatteryClientEfl> m_timer;
     56    RefPtr<BatteryStatus> m_batteryStatus;
     57    const double m_batteryStatusRefreshInterval;
    4758};
    4859
  • trunk/Source/cmake/FindEFL.cmake

    r107747 r117378  
    1010  ecore-file>=1.0.0
    1111  ecore-evas>=1.0.999.59763
    12   edje>=1.0.0)
     12  edje>=1.0.0
     13  eukit>=1.1.0)
    1314PKG_CHECK_MODULES (EINA REQUIRED eina>=1.0.0)
    1415PKG_CHECK_MODULES (ECORE_X ecore-x>=1.0.0)
    1516PKG_CHECK_MODULES (EVAS REQUIRED evas>=1.0.0)
     17PKG_CHECK_MODULES (EUKIT REQUIRED eukit>=1.1.0)
    1618
    1719FIND_PROGRAM (EDJE_CC_EXECUTABLE edje_cc)
  • trunk/Tools/ChangeLog

    r117298 r117378  
     12012-05-16  Kihong Kwon  <kihong.kwon@samsung.com>
     2
     3        [EFL] Support for Battery Status API on the WebKit-Efl
     4        https://bugs.webkit.org/show_bug.cgi?id=83254
     5
     6        Reviewed by Chang Shu.
     7
     8        Add e_dbus libraries to jhbuild's modules list.
     9
     10        * efl/jhbuild.modules:
     11
    1122012-05-16  Christophe Dumez  <christophe.dumez@intel.com>
    213
  • trunk/Tools/efl/jhbuild.modules

    r116776 r117378  
    1414      <dep package="libsoup"/>
    1515      <dep package="edje"/>
     16      <dep package="e_dbus"/>
    1617    </dependencies>
    1718  </metamodule>
     
    208209  </autotools>
    209210
     211  <autotools id="e_dbus">
     212    <branch module="e_dbus"
     213            repo="enlightenment.org"
     214            revision="68629"/>
     215    <dependencies>
     216      <dep package="ecore"/>
     217      <dep package="eina"/>
     218    </dependencies>
     219  </autotools>
     220
    210221</moduleset>
Note: See TracChangeset for help on using the changeset viewer.