geocode-glib: Add a backend abstraction
Add an abstraction for backends, the GeocodeBackend interface, and split the existing Nominatim code out into an implementation of that, GeocodeNominatim. Parameterise this implementation so the default instance uses nominatim.gnome.org, but other instances can be created which use other Nominatim servers. Rebase GeocodeForward and GeocodeReverse on GeocodeBackend so that they use the new abstraction, and can have their backends changed to use a custom GeocodeBackend instance. The default is the global GNOME GeocodeNominatim instance. The GeocodeNominatim class uses the same Nominatim code as before, moved from GeocodeForward and GeocodeReverse. In order to be backend-agnostic, the parameters accepted by GeocodeBackend methods use the XEP-0080 keys and GValues, rather than anything specific to Nominatim, which means that some of the parameter-handling code had to be reworked slightly. GeocodeNominatim delegates its network requests to virtual methods — the default implementations of these use libsoup as before, but a follow-up commit will add a derived class which tests the Nominatim implementation by overriding them to check the generated network requests. This adds the following new API, but does not break backwards compatibility: • GeocodeBackend • GeocodeNominatim • geocode_[forward|reverse]_set_backend() This requires the recently-bumped GIO dependency of 2.44. Largely based on a patch by Aleksander Morgado <aleksander.morgado@collabora.co.uk>. https://bugzilla.gnome.org/show_bug.cgi?id=756311
parent
4b6bb1f3
Please register or sign in to comment