Changeset 165418 in webkit


Ignore:
Timestamp:
Mar 10, 2014 5:23:20 PM (10 years ago)
Author:
mario.prada@samsung.com
Message:

[GTK] Add support for Geoclue2
https://bugs.webkit.org/show_bug.cgi?id=120185

Reviewed by Carlos Garcia Campos.

.:

Add support for Geoclue2 using autotools.

  • Source/autotools/FindDependencies.m4: Add support for handling

both Geoclue 1.0 and 2.0.

  • Source/autotools/PrintBuildConfiguration.m4: Print the version

of geoclue that is being used.

  • Source/autotools/SetupAutoconfHeader.m4: Define GEOCLUE_API_VERSION_2.
  • Source/autotools/SetupAutomake.m4: Likewise, for AM_CONDITIONAL.
  • Source/autotools/Versions.m4: Added minimum required version for Geoclue2.

Add support for Geoclue2 using CMake.

  • Source/cmake/FindGeoClue2.cmake: Added.
  • Source/cmake/OptionsGTK.cmake: Add support for handling Geoclue 1.0 and 2.0.
  • Source/cmakeconfig.h.cmake: Define WTF_USE_GEOCLUE2.

Source/WebCore:

Implement a new geolocation provider based on Geoclue2, which will only
be used if a good enough version of Geoclue2 is found at configure time.

  • GNUmakefile.am: Generate C-API for accessing the D-Bus API

provided by Geoclue2, and place it in DerivedSources.

  • GNUmakefile.list.am: Add GeolocationProviderGeoclue2.cpp, and

include the generated proxy files when using Geoclue2.

  • PlatformGTK.cmake: Likewise, for CMake based builds.
  • platform/geoclue/GeolocationProviderGeoclue.h: Modified to

accomodate the needs both for Geoclue and Geoclue2 providers.

  • platform/geoclue/GeolocationProviderGeoclue1.cpp: Renamed from Source/WebCore/platform/geoclue/GeolocationProviderGeoclue.cpp.

(GeolocationProviderGeoclue::getPositionCallback):
(GeolocationProviderGeoclue::positionChangedCallback):
(GeolocationProviderGeoclue::createGeocluePositionCallback):
(GeolocationProviderGeoclue::geoclueClientSetRequirementsCallback):
(GeolocationProviderGeoclue::createGeoclueClientCallback):
(GeolocationProviderGeoclue::GeolocationProviderGeoclue):
(GeolocationProviderGeoclue::~GeolocationProviderGeoclue):
(GeolocationProviderGeoclue::startUpdating):
(GeolocationProviderGeoclue::stopUpdating):
(GeolocationProviderGeoclue::setEnableHighAccuracy):
(GeolocationProviderGeoclue::initializeGeoclueClient):
(GeolocationProviderGeoclue::initializeGeocluePosition):
(GeolocationProviderGeoclue::updateClientRequirements):
(GeolocationProviderGeoclue::positionChanged):
(GeolocationProviderGeoclue::errorOccurred):

  • platform/geoclue/GeolocationProviderGeoclue2.cpp: Added.

(GeolocationProviderGeoclue::GeolocationProviderGeoclue):
(GeolocationProviderGeoclue::~GeolocationProviderGeoclue):
(GeolocationProviderGeoclue::startUpdating):
(GeolocationProviderGeoclue::stopUpdating):
(GeolocationProviderGeoclue::setEnableHighAccuracy):
(GeolocationProviderGeoclue::createGeoclueManagerProxyCallback):
(GeolocationProviderGeoclue::getGeoclueClientCallback):
(GeolocationProviderGeoclue::createGeoclueClientProxyCallback):
(GeolocationProviderGeoclue::startClientCallback):
(GeolocationProviderGeoclue::locationUpdatedCallback):
(GeolocationProviderGeoclue::createLocationProxyCallback):
(GeolocationProviderGeoclue::startGeoclueClient):
(GeolocationProviderGeoclue::updateLocation):
(GeolocationProviderGeoclue::errorOccurred):
(GeolocationProviderGeoclue::updateClientRequirements):

Location:
trunk
Files:
2 added
13 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r165386 r165418  
     12014-03-10  Mario Sanchez Prada  <mario.prada@samsung.com>
     2
     3        [GTK] Add support for Geoclue2
     4        https://bugs.webkit.org/show_bug.cgi?id=120185
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Patch by Anton Obzhirov <a.obzhirov@samsung.com> and Mario Sanchez Prada <mario.prada@samsung.com>
     9
     10        Add support for Geoclue2 using autotools.
     11
     12        * Source/autotools/FindDependencies.m4: Add support for handling
     13        both Geoclue 1.0 and 2.0.
     14        * Source/autotools/PrintBuildConfiguration.m4: Print the version
     15        of geoclue that is being used.
     16        * Source/autotools/SetupAutoconfHeader.m4: Define GEOCLUE_API_VERSION_2.
     17        * Source/autotools/SetupAutomake.m4: Likewise, for AM_CONDITIONAL.
     18        * Source/autotools/Versions.m4: Added minimum required version for Geoclue2.
     19
     20        Add support for Geoclue2 using CMake.
     21
     22        * Source/cmake/FindGeoClue2.cmake: Added.
     23        * Source/cmake/OptionsGTK.cmake:  Add support for handling Geoclue 1.0 and 2.0.
     24        * Source/cmakeconfig.h.cmake: Define WTF_USE_GEOCLUE2.
     25
    1262014-03-10  Martin Robinson  <mrobinson@igalia.com>
    227
  • trunk/Source/WebCore/ChangeLog

    r165417 r165418  
     12014-03-10  Mario Sanchez Prada  <mario.prada@samsung.com>
     2
     3        [GTK] Add support for Geoclue2
     4        https://bugs.webkit.org/show_bug.cgi?id=120185
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Patch by Anton Obzhirov <a.obzhirov@samsung.com> and Mario Sanchez Prada <mario.prada@samsung.com>
     9
     10        Implement a new geolocation provider based on Geoclue2, which will only
     11        be used if a good enough version of Geoclue2 is found  at configure time.
     12
     13        * GNUmakefile.am: Generate C-API for accessing the D-Bus API
     14        provided by Geoclue2, and place it in DerivedSources.
     15        * GNUmakefile.list.am: Add GeolocationProviderGeoclue2.cpp, and
     16        include the generated proxy files when using Geoclue2.
     17        * PlatformGTK.cmake: Likewise, for CMake based builds.
     18        * platform/geoclue/GeolocationProviderGeoclue.h: Modified to
     19        accomodate the needs both for Geoclue and Geoclue2 providers.
     20        * platform/geoclue/GeolocationProviderGeoclue1.cpp: Renamed from Source/WebCore/platform/geoclue/GeolocationProviderGeoclue.cpp.
     21        (GeolocationProviderGeoclue::getPositionCallback):
     22        (GeolocationProviderGeoclue::positionChangedCallback):
     23        (GeolocationProviderGeoclue::createGeocluePositionCallback):
     24        (GeolocationProviderGeoclue::geoclueClientSetRequirementsCallback):
     25        (GeolocationProviderGeoclue::createGeoclueClientCallback):
     26        (GeolocationProviderGeoclue::GeolocationProviderGeoclue):
     27        (GeolocationProviderGeoclue::~GeolocationProviderGeoclue):
     28        (GeolocationProviderGeoclue::startUpdating):
     29        (GeolocationProviderGeoclue::stopUpdating):
     30        (GeolocationProviderGeoclue::setEnableHighAccuracy):
     31        (GeolocationProviderGeoclue::initializeGeoclueClient):
     32        (GeolocationProviderGeoclue::initializeGeocluePosition):
     33        (GeolocationProviderGeoclue::updateClientRequirements):
     34        (GeolocationProviderGeoclue::positionChanged):
     35        (GeolocationProviderGeoclue::errorOccurred):
     36        * platform/geoclue/GeolocationProviderGeoclue2.cpp: Added.
     37        (GeolocationProviderGeoclue::GeolocationProviderGeoclue):
     38        (GeolocationProviderGeoclue::~GeolocationProviderGeoclue):
     39        (GeolocationProviderGeoclue::startUpdating):
     40        (GeolocationProviderGeoclue::stopUpdating):
     41        (GeolocationProviderGeoclue::setEnableHighAccuracy):
     42        (GeolocationProviderGeoclue::createGeoclueManagerProxyCallback):
     43        (GeolocationProviderGeoclue::getGeoclueClientCallback):
     44        (GeolocationProviderGeoclue::createGeoclueClientProxyCallback):
     45        (GeolocationProviderGeoclue::startClientCallback):
     46        (GeolocationProviderGeoclue::locationUpdatedCallback):
     47        (GeolocationProviderGeoclue::createLocationProxyCallback):
     48        (GeolocationProviderGeoclue::startGeoclueClient):
     49        (GeolocationProviderGeoclue::updateLocation):
     50        (GeolocationProviderGeoclue::errorOccurred):
     51        (GeolocationProviderGeoclue::updateClientRequirements):
     52
    1532014-03-10  Brent Fulgham  <bfulgham@apple.com>
    254
  • trunk/Source/WebCore/GNUmakefile.am

    r165060 r165418  
    387387endif  # END ENABLE_WEB_AUDIO
    388388
     389if USE_GEOCLUE2
     390DerivedSources/Platform/Geoclue2Interface.c: DerivedSources/Platform/Geoclue2Interface.h
     391DerivedSources/Platform/Geoclue2Interface.h:
     392        $(AM_V_GEN)gdbus-codegen --interface-prefix org.freedesktop.GeoClue2. --c-namespace Geoclue --generate-c-code DerivedSources/Platform/Geoclue2Interface $(GEOCLUE_DBUS_INTERFACE)
     393endif
     394
    389395IDL_PATH := \
    390396    $(WebCore)/Modules/battery \
  • trunk/Source/WebCore/GNUmakefile.list.am

    r165402 r165418  
    875875        DerivedSources/Platform/WebKitFontFamilyNames.cpp \
    876876        DerivedSources/Platform/WebKitFontFamilyNames.h
     877
     878if USE_GEOCLUE2
     879platform_built_sources += \
     880        DerivedSources/Platform/Geoclue2Interface.h \
     881        DerivedSources/Platform/Geoclue2Interface.c
     882endif
    877883
    878884# These files need to be part of WebCore otherwise they cause undefined
     
    55765582        Source/WebCore/platform/audio/ZeroPole.h \
    55775583        Source/WebCore/platform/geoclue/GeolocationProviderGeoclue.h \
    5578         Source/WebCore/platform/geoclue/GeolocationProviderGeoclue.cpp \
     5584        Source/WebCore/platform/geoclue/GeolocationProviderGeoclue1.cpp \
     5585        Source/WebCore/platform/geoclue/GeolocationProviderGeoclue2.cpp \
    55795586        Source/WebCore/platform/geoclue/GeolocationProviderGeoclueClient.h \
    55805587        Source/WebCore/platform/glib/BatteryProviderUPowerClient.h \
  • trunk/Source/WebCore/PlatformGTK.cmake

    r165378 r165418  
    4141    platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp
    4242
    43     platform/geoclue/GeolocationProviderGeoclue.cpp
     43    platform/geoclue/GeolocationProviderGeoclue1.cpp
     44    platform/geoclue/GeolocationProviderGeoclue2.cpp
    4445
    4546    platform/graphics/GraphicsContext3DPrivate.cpp
     
    243244    platform/gtk/WidgetRenderingContext.cpp
    244245)
     246
     247if (WTF_USE_GEOCLUE2)
     248    list(APPEND WebCore_SOURCES
     249        ${DERIVED_SOURCES_WEBCORE_DIR}/Geoclue2Interface.c
     250    )
     251    execute_process(COMMAND pkg-config --variable dbus_interface geoclue-2.0 OUTPUT_VARIABLE GEOCLUE_DBUS_INTERFACE)
     252    add_custom_command(
     253         OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/Geoclue2Interface.c ${DERIVED_SOURCES_WEBCORE_DIR}/Geoclue2Interface.h
     254         COMMAND gdbus-codegen --interface-prefix org.freedesktop.GeoClue2. --c-namespace Geoclue --generate-c-code ${DERIVED_SOURCES_WEBCORE_DIR}/Geoclue2Interface ${GEOCLUE_DBUS_INTERFACE}
     255    )
     256endif ()
    245257
    246258if (ENABLE_NETSCAPE_PLUGIN_API)
  • trunk/Source/WebCore/platform/geoclue/GeolocationProviderGeoclue.h

    r119249 r165418  
    11/*
    22 * Copyright (C) 2012 Igalia S.L.
     3 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
    34 *
    45 * This library is free software; you can redistribute it and/or
     
    2425
    2526#include "GeolocationProviderGeoclueClient.h"
     27#include <wtf/gobject/GRefPtr.h>
     28
     29#if USE(GEOCLUE2)
     30#include "Geoclue2Interface.h"
     31#else
    2632#include <geoclue/geoclue-master.h>
    2733#include <geoclue/geoclue-position.h>
    28 #include <wtf/gobject/GRefPtr.h>
     34#endif
    2935
    3036namespace WebCore {
     
    3945    void setEnableHighAccuracy(bool);
    4046
    41     // To be used from signal callbacks.
     47private:
     48#if USE(GEOCLUE2)
     49    static void createGeoclueManagerProxyCallback(GObject*, GAsyncResult*, GeolocationProviderGeoclue*);
     50    static void getGeoclueClientCallback(GObject*, GAsyncResult*, GeolocationProviderGeoclue*);
     51    static void createGeoclueClientProxyCallback(GObject*, GAsyncResult*, GeolocationProviderGeoclue*);
     52    static void startClientCallback(GObject*, GAsyncResult*, GeolocationProviderGeoclue*);
     53    static void locationUpdatedCallback(GeoclueClient*, const gchar*, const gchar*, GeolocationProviderGeoclue*);
     54    static void createLocationProxyCallback(GObject*, GAsyncResult*, GeolocationProviderGeoclue*);
     55
     56    void startGeoclueClient();
     57    void updateLocation(GeoclueLocation*);
     58#else
     59    static void getPositionCallback(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GError*, GeolocationProviderGeoclue*);
     60    static void positionChangedCallback(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GeolocationProviderGeoclue*);
     61    static void createGeocluePositionCallback(GeoclueMasterClient*, GeocluePosition*, GError*, GeolocationProviderGeoclue*);
     62    static void geoclueClientSetRequirementsCallback(GeoclueMasterClient*, GError*, GeolocationProviderGeoclue*);
     63    static void createGeoclueClientCallback(GeoclueMaster*, GeoclueMasterClient*, char*, GError*, GeolocationProviderGeoclue*);
     64
    4265    void initializeGeoclueClient(GeoclueMasterClient*);
    4366    void initializeGeocluePosition(GeocluePosition*);
     67    void positionChanged(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*);
     68#endif
     69
     70    void errorOccurred(const char*);
    4471    void updateClientRequirements();
    45     void positionChanged(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*);
    46     void errorOccurred(const char*);
    4772
    48 private:
    4973    GeolocationProviderGeoclueClient* m_client;
    5074
     75#if USE(GEOCLUE2)
     76    GRefPtr<GeoclueManager> m_managerProxy;
     77    GRefPtr<GeoclueClient> m_clientProxy;
     78#else
    5179    GRefPtr<GeoclueMasterClient> m_geoclueClient;
    5280    GRefPtr<GeocluePosition> m_geocluePosition;
     81#endif
    5382
    5483    double m_latitude;
  • trunk/Source/WebCore/platform/geoclue/GeolocationProviderGeoclue1.cpp

    r165417 r165418  
    2727#include "GeolocationProviderGeoclue.h"
    2828
    29 #if ENABLE(GEOLOCATION)
     29#if ENABLE(GEOLOCATION) && !USE(GEOCLUE2)
    3030
    3131using namespace WebCore;
    3232
    33 static void getPositionCallback(GeocluePosition* position, GeocluePositionFields fields, int timestamp, double latitude, double longitude, double altitude, GeoclueAccuracy* accuracy, GError* error, GeolocationProviderGeoclue* provider)
     33void GeolocationProviderGeoclue::getPositionCallback(GeocluePosition* position, GeocluePositionFields fields, int timestamp, double latitude, double longitude, double altitude, GeoclueAccuracy* accuracy, GError* error, GeolocationProviderGeoclue* provider)
    3434{
    3535    if (error) {
     
    4141}
    4242
    43 static void positionChangedCallback(GeocluePosition* position, GeocluePositionFields fields, int timestamp, double latitude, double longitude, double altitude, GeoclueAccuracy* accuracy, GeolocationProviderGeoclue* provider)
     43void GeolocationProviderGeoclue::positionChangedCallback(GeocluePosition* position, GeocluePositionFields fields, int timestamp, double latitude, double longitude, double altitude, GeoclueAccuracy* accuracy, GeolocationProviderGeoclue* provider)
    4444{
    4545    provider->positionChanged(position, fields, timestamp, latitude, longitude, altitude, accuracy);
    4646}
    4747
    48 static void createGeocluePositionCallback(GeoclueMasterClient*, GeocluePosition* position, GError *error, GeolocationProviderGeoclue* provider)
     48void GeolocationProviderGeoclue::createGeocluePositionCallback(GeoclueMasterClient*, GeocluePosition* position, GError *error, GeolocationProviderGeoclue* provider)
    4949{
    5050    if (error) {
     
    5656}
    5757
    58 static void geoclueClientSetRequirementsCallback(GeoclueMasterClient* client, GError* error, GeolocationProviderGeoclue* provider)
     58void GeolocationProviderGeoclue::geoclueClientSetRequirementsCallback(GeoclueMasterClient*, GError* error, GeolocationProviderGeoclue* provider)
    5959{
    6060    if (error) {
     
    6464}
    6565
    66 static void createGeoclueClientCallback(GeoclueMaster*, GeoclueMasterClient* client, char*, GError* error, GeolocationProviderGeoclue* provider)
     66void GeolocationProviderGeoclue::createGeoclueClientCallback(GeoclueMaster*, GeoclueMasterClient* client, char*, GError* error, GeolocationProviderGeoclue* provider)
    6767{
    6868    if (error) {
     
    7676GeolocationProviderGeoclue::GeolocationProviderGeoclue(GeolocationProviderGeoclueClient* client)
    7777    : m_client(client)
    78     , m_geoclueClient(0)
    79     , m_geocluePosition(0)
    8078    , m_latitude(0)
    8179    , m_longitude(0)
     
    155153}
    156154
    157 void GeolocationProviderGeoclue::positionChanged(GeocluePosition* position, GeocluePositionFields fields, int timestamp, double latitude, double longitude, double altitude, GeoclueAccuracy* accuracy)
     155void GeolocationProviderGeoclue::positionChanged(GeocluePosition*, GeocluePositionFields fields, int timestamp, double latitude, double longitude, double altitude, GeoclueAccuracy* accuracy)
    158156{
    159157    if (!(fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)) {
     
    177175}
    178176
    179 #endif // ENABLE(GEOLOCATION)
     177#endif // ENABLE(GEOLOCATION) && !USE(GEOCLUE2)
  • trunk/Source/autotools/FindDependencies.m4

    r165337 r165418  
    405405AC_SUBST([LIBXSLT_LIBS])
    406406
    407 # Check if geoclue is available.
     407# Check if geoclue is available, with a preference over Geoclue2 if present.
     408geolocation_description="none"
    408409if test "$enable_geolocation" = "yes"; then
    409     PKG_CHECK_MODULES([GEOCLUE], [geoclue])
     410    PKG_CHECK_MODULES([GEOCLUE2], [gio-unix-2.0 geoclue-2.0 >= geoclue2_required_version], [found_geoclue2=yes], [found_geoclue2=no])
     411    if test "$found_geoclue2" = "yes"; then
     412        GEOCLUE_CFLAGS="$GEOCLUE2_CFLAGS"
     413        GEOCLUE_LIBS="$GEOCLUE2_LIBS"
     414        GEOCLUE_DBUS_INTERFACE=`$PKG_CONFIG --variable dbus_interface geoclue-2.0`
     415        AC_SUBST(GEOCLUE_DBUS_INTERFACE)
     416        geolocation_description="Geoclue 2"
     417    else
     418        PKG_CHECK_MODULES([GEOCLUE], [geoclue])
     419        geolocation_description="Geoclue"
     420    fi
    410421    AC_SUBST([GEOCLUE_CFLAGS])
    411422    AC_SUBST([GEOCLUE_LIBS])
  • trunk/Source/autotools/PrintBuildConfiguration.m4

    r163440 r165418  
    1818 Optimized memory allocator                               : $enable_fast_malloc
    1919 Accelerated rendering backend                            : $acceleration_description
     20 Geolocation backend                                      : $geolocation_description
    2021
    2122Features:
  • trunk/Source/autotools/SetupAutoconfHeader.m4

    r156271 r165418  
    2626        AC_DEFINE([HAVE_GTK_UNIX_PRINTING], [1], [Define if GTK+ UNIX Printing is available])
    2727    fi
     28fi
     29
     30if test "$found_geoclue2" = "yes"; then
     31    AC_DEFINE([WTF_USE_GEOCLUE2], [1], [ ])
    2832fi
    2933
  • trunk/Source/autotools/SetupAutomake.m4

    r163440 r165418  
    3434AM_CONDITIONAL([TARGET_DIRECTFB], [test "$enable_directfb_target" = "yes"])
    3535
     36# Geoclue conditionals.
     37AM_CONDITIONAL([USE_GEOCLUE2],[test "$found_geoclue2" = "yes"])
     38
    3639# GStreamer feature conditionals.
    3740AM_CONDITIONAL([USE_GSTREAMER], [test "$enable_video" = "yes" || test "$enable_web_audio" = "yes"])
  • trunk/Source/autotools/Versions.m4

    r161870 r165418  
    2525m4_define([fontconfig_required_version], [2.5])
    2626m4_define([freetype2_required_version], [9.0])
     27m4_define([geoclue2_required_version], [2.1.5])
    2728m4_define([glib_required_version], [2.36.0])
    2829m4_define([gobject_introspection_required_version], [1.32.0])
  • trunk/Source/cmake/OptionsGTK.cmake

    r165378 r165418  
    205205
    206206if (ENABLE_GEOLOCATION)
    207     find_package(GeoClue)
     207    find_package(GeoClue2 2.1.5)
     208    if (GEOCLUE2_FOUND)
     209      set(WTF_USE_GEOCLUE2 1)
     210    else ()
     211      find_package(GeoClue)
     212      set(WTF_USE_GEOCLUE2 0)
     213    endif ()
    208214endif ()
    209215
  • trunk/Source/cmakeconfig.h.cmake

    r164943 r165418  
    124124#cmakedefine01 ENABLE_XSLT
    125125#cmakedefine01 USE_SYSTEM_MALLOC
     126#cmakedefine01 WTF_USE_GEOCLUE2
    126127#cmakedefine01 WTF_USE_TILED_BACKING_STORE
    127128#cmakedefine01 HAVE_LLVM
Note: See TracChangeset for help on using the changeset viewer.