From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Date: Tue, 7 May 2024 21:31:53 +0200
Subject: [PATCH] WIP: Use Google Maps Platform by default

---
 data/geoclue.conf.in | 12 ++++++------
 meson.build          |  1 +
 meson_options.txt    |  3 +++
 src/gclue-config.c   |  2 +-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/data/geoclue.conf.in b/data/geoclue.conf.in
index 9afb5e08f37c..fc650f2d5e68 100644
--- a/data/geoclue.conf.in
+++ b/data/geoclue.conf.in
@@ -47,21 +47,21 @@ enable=true
 # source will be used instead.
 enable=true
 
-# URL to the WiFi geolocation service. If not set, defaults to Mozilla's
-# Location Service with a hardcoded key. To use a custom key, uncomment this URL
-# while changing YOUR_KEY to your MLS API key.
-#url=https://location.services.mozilla.com/v1/geolocate?key=YOUR_KEY
-
-# To use the Google geolocation service instead of Mozilla's, uncomment this URL
+# URL to the WiFi geolocation service. If not set, defaults to Google's
+# Geolocation API with a hardcoded key. To use a custom key, uncomment this URL
 # while changing YOUR_KEY to your Google API key.
 #
 # WARNING: Please make sure that you are complying with the Google's ToS and
 #          policies if you uncomment this:
 #
 # https://developers.google.com/maps/documentation/geolocation/policies
 #
 #url=https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_KEY
 
+# To use the Mozilla's Location Service instead of Google's, uncomment this URL
+# while changing YOUR_KEY to your MLS API key.
+#url=https://location.services.mozilla.com/v1/geolocate?key=YOUR_KEY
+
 # Submit data to Mozilla Location Service
 # If set to true, geoclue will automatically submit network data to Mozilla
 # each time it gets a GPS lock.
diff --git a/meson.build b/meson.build
index b175096a9556..5cbcec2d9afc 100644
--- a/meson.build
+++ b/meson.build
@@ -31,6 +31,7 @@ conf.set_quoted('TEST_SRCDIR', meson.project_source_root() + '/data/')
 conf.set_quoted('LOCALEDIR', localedir)
 conf.set_quoted('SYSCONFDIR', sysconfdir)
 conf.set_quoted('MOZILLA_API_KEY', get_option('mozilla-api-key'))
+conf.set_quoted('GOOGLE_API_KEY', get_option('google-api-key'))
 conf.set10('GCLUE_USE_3G_SOURCE', get_option('3g-source'))
 conf.set10('GCLUE_USE_CDMA_SOURCE', get_option('cdma-source'))
 conf.set10('GCLUE_USE_MODEM_GPS_SOURCE', get_option('modem-gps-source'))
diff --git a/meson_options.txt b/meson_options.txt
index 5b8c42d2f6b9..69e76f013241 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -43,3 +43,6 @@ option('dbus-srv-user',
 option('mozilla-api-key',
        type: 'string', value: 'geoclue',
        description: 'Your API key for Mozilla Location Service')
+option('google-api-key',
+       type: 'string', value: 'geoclue',
+       description: 'Your API key for Google Maps Platform')
diff --git a/src/gclue-config.c b/src/gclue-config.c
index 70822ed225fd..faacfbe998b3 100644
--- a/src/gclue-config.c
+++ b/src/gclue-config.c
@@ -265,7 +265,7 @@ load_enable_source_config (GClueConfig *config,
         return enable;
 }
 
-#define DEFAULT_WIFI_URL "https://location.services.mozilla.com/v1/geolocate?key=" MOZILLA_API_KEY
+#define DEFAULT_WIFI_URL "https://www.googleapis.com/geolocation/v1/geolocate?key=" GOOGLE_API_KEY
 #define DEFAULT_WIFI_SUBMIT_URL "https://location.services.mozilla.com/v2/geosubmit?key=" MOZILLA_API_KEY
 #define DEFAULT_WIFI_SUBMIT_NICK "geoclue"
 
