...
 
Commits (856)
before_script:
- sed -i '/^#\sdeb-src /s/^#//' '/etc/apt/sources.list'
- apt-get update && apt-get build-dep --yes geoclue-2.0
- apt-get install --yes git gobject-introspection libmm-glib-dev wget
- apt-get install --yes libnotify-dev xsltproc gtk-doc-tools python3-pip
- apt-get install --yes ninja-build gettext modemmanager-dev
- pip3 install meson
# Ubuntu 14.04 is not supported, see README for details
#
# FIXME: Also disable gtk-doc on Ubuntu 16.04 cause it fails install. Would be nice to get it fixed.
ubuntu-16.04:
image: ubuntu:xenial
artifacts:
when: always
name: "xenial-${CI_COMMIT_REF_NAME}"
paths:
- "${CI_PROJECT_DIR}/build"
script: meson -Dgtk-doc=false build && ninja -C build && ninja -C build test && ninja -C build install
ubuntu-18.04:
image: ubuntu:bionic
artifacts:
when: always
name: "bionic-${CI_COMMIT_REF_NAME}"
paths:
- "${CI_PROJECT_DIR}/build"
script: meson build && ninja -C build && ninja -C build test && ninja -C build install
ubuntu-18.04-no-backend:
image: ubuntu:bionic
artifacts:
when: always
name: "bionic-no-backend-${CI_COMMIT_REF_NAME}"
paths:
- "${CI_PROJECT_DIR}/build"
script: meson -Denable-backend=false build && ninja -C build && ninja -C build test && ninja -C build install
This diff is collapsed.
This diff is collapsed.
# Building Geoclue
- The following are the dependencies needed to build Geoclue2. But If Geoclue2
is already included in your distro/OS, you should be able to use the
package manager's command to install all build depedndancies.
* gio (>= 2.44.0)
* gobject-introspection
* json-glib
* libsoup2.4 (>= 2.42)
* pkg-config
Fedora:
```shell
sudo dnf builddep geoclue2
```
Debian and Ubuntu:
```shell
sudo apt build-dep geoclue-2.0
```
- For a full-fledged build, you also want ModemManager (mm-glib),
avahi-client and avahi-glib. You want the latter two if you want to use the
[geoclue-share app](https://wiki.gnome.org/Apps/GeoclueShare). You also need
libnotify if you want to build the demo agent.
Fedora:
```shell
sudo dnf install ModemManager-devel
sudo dnf install avahi-devel
sudo dnf install avahi-glib-devel
sudo dnf install libnotify-devel
```
Debian and Ubuntu:
```shell
sudo apt install modemmanager-dev
sudo apt install libavahi-client-dev
sudo apt install libavahi-glib-dev
sudo apt install libnotify-dev
```
- [Install meson](https://mesonbuild.com/Getting-meson.html).
- Ensure you have a `geoclue` user on your system. If it already exists, you may
need to modify `/etc/passwd` file to make it a login user account by replacing
`/sbin/nologin` with `/bin/bash` (or the path to your preferred shell).
- Build and install geoclue.
```shell
meson --prefix=/usr --sysconfdir /etc -Ddbus-srv-user=geoclue build
# you may need to pass --libdir=/usr/lib64 on some systems (eg. Fedora)
ninja -C build
sudo ninja -C build install
```
- Then you can run it as:
```shell
sudo su geoclue # Starts a new shell as `geoclue` user
G_MESSAGES_DEBUG=Geoclue /usr/libexec/geoclue
```
If you get the following error, make sure `geoclue` process is not already
running:
```
> Failed to acquire name 'org.freedesktop.GeoClue2' on system bus or lost it
```
- Now you can test if Geoclue is running and working:
```shell
/usr/libexec/geoclue-2.0/demos/where-am-i
```
It will give your current location.
This diff is collapsed.
Geoclue: The Geoinformation Service
===================================
Geoclue is a D-Bus geoinformation service. The goal of the Geoclue project
is to make creating location-aware applications as simple as possible.
Geoclue is Free Software, licensed under GNU GPLv2+.
Geoclue comprises the following functionalities :
- WiFi-based geolocation (accuracy: in meters)
- GPS(A) receivers (accuracy: in centimeters)
- GPS of other devices on the local network, e.g smartphones (accuracy:
in centimeters)
- 3G modems (accuracy: in kilometers, unless modem has GPS)
- GeoIP (accuracy: city-level)
WiFi-based geolocation makes use of
[Mozilla Location Service](https://wiki.mozilla.org/CloudServices/Location).
If geoclue is unable to find you, you can easily fix that by installing
and running a
[simple app](https://wiki.mozilla.org/CloudServices/Location#Contributing) on
your phone. For using phone GPS, you'll need to install the latest version of
[GeoclueShare app](https://github.com/ankitstarski/GeoclueShare/releases)
on your phone (currently, this is supported only on Android devices).
Geoclue was also used for (reverse-)geocoding but that functionality has
been dropped in favour of the
[geocode-glib library](http://ftp.gnome.org/pub/GNOME/sources/geocode-glib/).
# History
Geoclue was started during the GNOME Summit 2006 in Boston. At least
Keith Preston and Tuomas Kuosmanen can be blamed. There was a total rewrite
after version 0.9.
Use tag "0.9" (as in git checkout 0.9) if you need the old code.
There was yet another rewrite that we call geoclue2. The first version to
introduce the re-write was version 1.99.
# Communication and Contribution
- Discussions take place on the
[GNOME Discourse](https://discourse.gnome.org/c/platform).
- The IRC chat for geoclue is on __#gnome-maps__ at irc.gimp.org .
- Issues are tracked on
[Gitlab](https://gitlab.freedesktop.org/geoclue/geoclue/issues).
# Get Source Code
The source code is available as a tar-ball and in a Git repository.
For latest release tarballs, use the `Download` option of Gitlab on the
[tag of your choice](https://gitlab.freedesktop.org/geoclue/geoclue/tags/).
Older (than 2.4.13) releases are available
[here](http://www.freedesktop.org/software/geoclue/releases/2.4/).
Git repository for Geoclue: https://gitlab.freedesktop.org/geoclue/geoclue
# Building Geoclue
The guidelines for building geoclue have been documented
[here](https://gitlab.freedesktop.org/geoclue/geoclue/blob/master/HACKING.md).
# Using Geoclue in an application
- __D-Bus API__: The documentation for using geoclue with D-Bus API is
[here](http://www.freedesktop.org/software/geoclue/docs/).
- __Libgeoclue API documentation__: The documentation is available
[here](https://www.freedesktop.org/software/geoclue/docs/libgeoclue/).
- __C user application__:
[Here](https://gitlab.freedesktop.org/geoclue/geoclue/blob/master/demo/where-am-i.c)
is an example showing a C application that uses
geoclue to locate its user.
.TH "GEOCLUE CONFIGURATION" 5
.SH NAME
geoclue.conf
\-
geoclue configuration parameters
.SH SYNOPSIS
.B @sysconfdir@/geoclue/geoclue.conf
.SH DESCRIPTION
.ad
.fi
The geoclue geoclue.conf configuration file specifies parameters that
control the operation of geoclue.
.PP
All configurations settings below are mandatory and the defaults are
what you see before you edit them in geoclue.conf. If you want to keep the default
values around, copy and comment out the appropriate line(s) before
changing them.
.SH AGENT CONFIGURATION OPTIONS
.B \fI[agent]
is used to begin the agent configuration.
.IP \fBwhitelist
.br
Whitelist of desktop IDs (without .desktop part) of all agents we recognise,
separated by a ';'.
.IP
.B whitelist=geoclue-demo-agent;gnome-shell;io.elementary.desktop.agent-geoclue2
.br
.IP \fB[network-nmea]
.br
Network NMEA source configuration options
.IP
.B \fBenable=true
.br
Fetch location from NMEA sources on local network?
.br
.IP \fB[3G]
.br
3G source configuration options
.IP
.B \fBenable=true
.br
Enable 3G source
.br
.IP \fB[cdma]
.br
CDMA source configuration options
.IP
.B \fBenable=true
.br
Enable CDMA source
.br
.IP \fB[modem-gps]
.br
Modem GPS source configuration options
.IP
.B \fBenable=true
.br
Enable Modem-GPS source
.br
.IP \fB[wifi]
.br
WiFi source configuration options
.IP
.B \fBenable=true
.br
Enable WiFi source
.IP
.B url=\fIhttps://location.services.mozilla.com/v1/geolocate?key=geoclue
.br
URL to the wifi geolocation service. The key can currenty be anything, just
needs to be present but that is likely going to change in future.
.IP
.B submit-data=false
Submit data to Mozilla Location Service
.br
If set to true, geoclue will automatically submit network data to Mozilla
each time it gets a GPS lock.
.IP
.B submission-url=\fIhttps://location.services.mozilla.com/v1/submit?key=geoclue
.br
URL to submission API of Mozilla Location Service
.IP
.B submission-nick=geoclue
.br
A nickname to submit network data with. A nickname must be 2-32 characters long.
.br
.SH APPLICATION CONFIGURATION OPTIONS
Having an entry here for an application with
.B allowed=true
means that geoclue will not ask agent to authorize the application. This is to
ensure that applications with built-in authorization mechanism (e.g web
browsers) do not have to be bound to agents.
.PP
If your application is denied access to location information and your
operating system doesn't provide any mechanism to change that, it is
likely a bug in your operation system (or geoclue). The solution is to
report the issue with all details, rather than adding your application
to this list.
.IP Format:
.RS
.B [random-app]
.br
Desktop ID of application without .desktop part
.PP
.B allowed=true|false
.br
Allowed access to location information?
.PP
.B system=true|false
.br
Is application a system component?
.PP
.B users=
.br
List of UIDs of all users for which this application is allowed location
info access, separate by ';'. Keep it empty for allowing it for all users.
.RE
.IP Examples:
.RS
.B [gnome-datetime-panel]
.br
allowed=true
.br
system=true
.br
users=
.PP
.B [gnome-color-panel]
.br
allowed=true
.br
system=true
.br
users=
.PP
.B [org.gnome.Shell]
.br
allowed=true
.br
system=true
.br
users=
.PP
.B [io.elementary.desktop.agent-geoclue2]
.br
allowed=true
.br
system=true
.br
users=
.PP
.B [epiphany]
.br
allowed=true
.br
system=false
.br
users=
.PP
.B [firefox]
.br
allowed=true
.br
system=false
.br
users=
.br
.SH AUTHOR
.na
.nf
Sachin Chand
# Configuration file for Geoclue
#
# NOTE: All configurations settings below are mandatory and the defaults are
# what you see before you edit them. If you want to keep the default
# values around, copy and comment out the appropriate line(s) before
# changing them.
# Agent configuration options
[agent]
# Whitelist of desktop IDs (without .desktop part) of all agents we recognise,
# separated by a ';'.
whitelist=@demo_agent@gnome-shell;io.elementary.desktop.agent-geoclue2
# Network NMEA source configuration options
[network-nmea]
# Fetch location from NMEA sources on local network?
enable=true
# 3G source configuration options
[3g]
# Enable 3G source
enable=true
# CDMA source configuration options
[cdma]
# Enable CDMA source
enable=true
# Modem GPS source configuration options
[modem-gps]
# Enable Modem-GPS source
enable=true
# WiFi source configuration options
[wifi]
# Enable WiFi source
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
# 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
# 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.
#
submit-data=false
# URL to submission API of Mozilla Location Service. If not set, defaults to
# Mozilla's API with a hardcoded key. To use a custom key, uncomment this URL
# while changing YOUR_KEY to your MLS API key.
#submission-url=https://location.services.mozilla.com/v1/submit?key=YOUR_KEY
# A nickname to submit network data with. A nickname must be 2-32 characters long.
submission-nick=geoclue
# Application configuration options
#
# NOTE: Having an entry here for an application with allowed=true means that
# geoclue will not ask agent to authorize the application. This is to
# ensure that applications with built-in authorization mechanism (e.g web
# browsers) do not have to be bound to agents.
#
# If your application is denied access to location information and your
# operating system doesn't provide any mechanism to change that, it is
# likely a bug in your operation system (or geoclue). The solution is to
# report the issue with all details, rather than adding your application
# to this list.
#
# Format:
#
# # Desktop ID of application without .desktop part
# [random-app]
#
# # Allowed access to location information?
# allowed=true|false
#
# # Is application a system component?
# system=true|false
#
# # List of UIDs of all users for which this application is allowed location
# # info access, separate by ';'. Keep it empty for allowing it for all users.
# users=
[gnome-datetime-panel]
allowed=true
system=true
users=
[gnome-color-panel]
allowed=true
system=true
users=
[org.gnome.Shell]
allowed=true
system=true
users=
[io.elementary.desktop.agent-geoclue2]
allowed=true
system=true
users=
[epiphany]
allowed=true
system=false
users=
[firefox]
allowed=true
system=false
users=
[Unit]
Description=Location Lookup Service
[Service]
Type=dbus
BusName=org.freedesktop.GeoClue2
User=@dbus_srv_user@
ExecStart=@libexecdir@/geoclue
# Filesystem lockdown
ProtectSystem=strict
ProtectKernelTunables=true
ProtectControlGroups=true
ProtectHome=true
PrivateTmp=true
# Network
PrivateNetwork=false
# Execute Mappings
MemoryDenyWriteExecute=true
# Modules
ProtectKernelModules=true
# Real-time
RestrictRealtime=true
# Privilege escalation
NoNewPrivileges=true
if get_option('enable-backend')
conf = configuration_data()
if get_option('demo-agent')
conf.set('demo_agent', 'geoclue-demo-agent;')
else
conf.set('demo_agent', '')
endif
conf_dir = join_paths(sysconfdir, 'geoclue')
configure_file(output: 'geoclue.conf',
input: 'geoclue.conf.in',
configuration: conf,
install_dir: conf_dir)
conf = configuration_data()
conf.set('libexecdir', libexecdir)
conf.set('dbus_srv_user', get_option('dbus-srv-user'))
conf.set('sysconfdir', sysconfdir)
service_dir = join_paths(datadir, 'dbus-1', 'system-services')
configure_file(output: 'org.freedesktop.GeoClue2.service',
input: 'org.freedesktop.GeoClue2.service.in',
configuration: conf,
install_dir: service_dir)
man_file = configure_file(output: 'geoclue.5',
input: 'geoclue.5.in',
configuration: conf)
install_man(man_file)
# DBus Service policy file
dbus_service_dir = get_option('dbus-sys-dir')
if dbus_service_dir == ''
dbus_service_dir = join_paths(sysconfdir, 'dbus-1', 'system.d')
endif
configure_file(output: 'org.freedesktop.GeoClue2.conf',
input: 'org.freedesktop.GeoClue2.conf.in',
configuration: conf,
install_dir: dbus_service_dir)
configure_file(output: 'org.freedesktop.GeoClue2.Agent.conf',
input: 'org.freedesktop.GeoClue2.Agent.conf.in',
configuration: conf,
install_dir: dbus_service_dir)
systemd_unit_dir = get_option('systemd-system-unit-dir')
if systemd_unit_dir == ''
dep = dependency('systemd', required: false)
if dep.found()
systemd_unit_dir = dep.get_pkgconfig_variable('systemdsystemunitdir')
endif
endif
if systemd_unit_dir != ''
configure_file(output: 'geoclue.service',
input: 'geoclue.service.in',
configuration: conf,
install_dir: systemd_unit_dir)
endif
endif
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="@dbus_srv_user@">
<allow send_interface="org.freedesktop.GeoClue2.Agent"
send_path="/org/freedesktop/GeoClue2/Agent"/>
<allow send_interface="org.freedesktop.DBus.Properties"
send_path="/org/freedesktop/GeoClue2/Agent"/>
</policy>
<policy user="root">
<allow send_interface="org.freedesktop.GeoClue2.Agent"
send_path="/org/freedesktop/GeoClue2/Agent"/>
<allow send_interface="org.freedesktop.DBus.Properties"
send_path="/org/freedesktop/GeoClue2/Agent"/>
</policy>
</busconfig>
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy context="default">
<!-- Allow everyone to talk to main service. We'll later add an agent to
only share the location if user allows it. -->
<allow send_destination="org.freedesktop.GeoClue2"/>
</policy>
<policy user="@dbus_srv_user@">
<!-- Only allow @dbus_srv_user@ to own the name on the bus -->
<allow own="org.freedesktop.GeoClue2"/>
<!-- Also give @dbus_srv_user@ access to wpa_supplicant API -->
<allow receive_sender="fi.w1.wpa_supplicant1"
receive_type="signal"/>
<allow send_destination="fi.w1.wpa_supplicant1"
send_interface="org.freedesktop.DBus.Properties"
send_member="Get"/>
<allow send_destination="fi.w1.wpa_supplicant1"
send_interface="org.freedesktop.DBus.Properties"
send_member="GetAll"/>
<allow send_destination="fi.w1.wpa_supplicant1"
send_interface="org.freedesktop.DBus.Introspectable"/>
<allow send_destination="fi.w1.wpa_supplicant1"
send_interface="fi.w1.wpa_supplicant1.Interface"
send_type="method_call"
send_member="Scan"/>
</policy>
<policy user="root">
<!-- Allow root to own the name on the bus -->
<allow own="org.freedesktop.GeoClue2"/>
</policy>
</busconfig>
[D-BUS Service]
Name=org.freedesktop.GeoClue2
Exec=@libexecdir@/geoclue
User=@dbus_srv_user@
SystemdService=geoclue.service
/* vim: set et ts=8 sw=8: */
/* agent.c
*
* Copyright 2013 Red Hat, Inc.
*
* Geoclue is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* Geoclue is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with Geoclue; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
*/
#include <config.h>
#include <gio/gio.h>
#include <locale.h>
#include <glib/gi18n.h>
#include <stdlib.h>
#include <libnotify/notify.h>
#include "gclue-service-agent.h"
/* Commandline options */
static gboolean version;
static GOptionEntry entries[] =
{
{ "version",
0,
0,
G_OPTION_ARG_NONE,
&version,
N_("Display version number"),
NULL },
{ NULL }
};
GClueServiceAgent *agent = NULL;
static void
on_get_bus_ready (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GError *error = NULL;
GDBusConnection *connection;
connection = g_bus_get_finish (res, &error);
if (connection == NULL) {
g_critical ("Failed to get connection to system bus: %s",
error->message);
g_error_free (error);
exit (-2);
}
agent = gclue_service_agent_new (connection);
}
#define ABS_PATH ABS_SRCDIR "/agent"
int
main (int argc, char **argv)
{
GMainLoop *main_loop;
GError *error = NULL;
GOptionContext *context;
setlocale (LC_ALL, "");
textdomain (GETTEXT_PACKAGE);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
g_set_application_name ("GeoClue Agent");
notify_init (_("GeoClue"));
context = g_option_context_new ("- Geoclue Agent service");
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
if (!g_option_context_parse (context, &argc, &argv, &error)) {
g_critical ("option parsing failed: %s\n", error->message);
exit (-1);
}
if (version) {
g_print ("%s\n", PACKAGE_VERSION);
exit (0);
}
g_bus_get (G_BUS_TYPE_SYSTEM,
NULL,
on_get_bus_ready,
NULL);
main_loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (main_loop);
if (agent != NULL)
g_object_unref (agent);
g_main_loop_unref (main_loop);
return 0;
}
This diff is collapsed.
/* vim: set et ts=8 sw=8: */
/* gclue-service-agent.h
*
* Copyright 2013 Red Hat, Inc.
*
* Geoclue is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* Geoclue is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with Geoclue; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
*/
#ifndef GCLUE_SERVICE_AGENT_H
#define GCLUE_SERVICE_AGENT_H
#include <glib-object.h>
#include "geoclue-agent-interface.h"
G_BEGIN_DECLS
#define GCLUE_TYPE_SERVICE_AGENT (gclue_service_agent_get_type())
#define GCLUE_SERVICE_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCLUE_TYPE_SERVICE_AGENT, GClueServiceAgent))
#define GCLUE_SERVICE_AGENT_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCLUE_TYPE_SERVICE_AGENT, GClueServiceAgent const))
#define GCLUE_SERVICE_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCLUE_TYPE_SERVICE_AGENT, GClueServiceAgentClass))
#define GCLUE_IS_SERVICE_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCLUE_TYPE_SERVICE_AGENT))
#define GCLUE_IS_SERVICE_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCLUE_TYPE_SERVICE_AGENT))
#define GCLUE_SERVICE_AGENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCLUE_TYPE_SERVICE_AGENT, GClueServiceAgentClass))
typedef struct _GClueServiceAgent GClueServiceAgent;
typedef struct _GClueServiceAgentClass GClueServiceAgentClass;
typedef struct _GClueServiceAgentPrivate GClueServiceAgentPrivate;
struct _GClueServiceAgent
{
GClueAgentSkeleton parent;
/*< private >*/
GClueServiceAgentPrivate *priv;
};
struct _GClueServiceAgentClass
{
GClueAgentSkeletonClass parent_class;
};
GType gclue_service_agent_get_type (void) G_GNUC_CONST;
GClueServiceAgent * gclue_service_agent_new (GDBusConnection *connection);
G_END_DECLS
#endif /* GCLUE_SERVICE_AGENT_H */
[Desktop Entry]
Name=Geoclue Demo agent
GenericName=Demo geoclue agent
Keywords=geolocation;
Exec=@libexecdir@/geoclue-2.0/demos/agent
Icon=mark-location-symbolic
NotShowIn=GNOME;
NoDisplay=true
Terminal=false
Type=Application
[Desktop Entry]
Name=Where am I?
GenericName=Demo geolocation application
Comment=Find your current location
Keywords=geolocation;
Exec=@libexecdir@/geoclue-2.0/demos/where-am-i
Icon=mark-location-symbolic
NoDisplay=true
Terminal=true
Type=Application
X-Geoclue-Reason=Allows your current location to be shown on terminal.
#!/usr/bin/env python3
# A simple script that copies a given file (first arg) to a given location
# (second arg).
import sys
import os
from shutil import copy
if len(sys.argv) < 3:
print('Usage: ' + sys.argv[0] + ' SOURCE_FILE DESTINATION_DIR')
sys.exit(-1)
try:
dest_dir = os.environ['DESTDIR'] + '/' + sys.argv[2]
except KeyError:
dest_dir = sys.argv[2]
try:
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
except OSError:
print ('Error: Creating directory. ' + dest_dir)
copy(sys.argv[1], dest_dir)
desktop_dir = join_paths(datadir, 'applications')
demo_dir = join_paths(libexecdir, 'geoclue-2.0', 'demos')
i18n = import('i18n')
desktop_conf = configuration_data()
desktop_conf.set('libexecdir', libexecdir)
if get_option('libgeoclue')
include_dirs = [ configinc,
libgeoclue_public_api_inc,
include_directories('../libgeoclue') ]
executable('where-am-i',
'where-am-i.c',
include_directories: include_dirs,
dependencies: [base_deps, libgeoclue_dep],
install: true,
install_dir: demo_dir)
desktop_in = configure_file(output: 'geoclue-where-am-i.desktop.in',
input: 'geoclue-where-am-i.desktop.in.in',
configuration: desktop_conf)
i18n.merge_file(output: 'geoclue-where-am-i.desktop',
input: desktop_in,
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: desktop_dir)
endif
if get_option('demo-agent')
include_dirs = [ configinc,
libgeoclue_public_api_inc ]
sources = [ 'gclue-service-agent.h',
'gclue-service-agent.c',
'agent.c',
geoclue_agent_sources ]
deps = base_deps + [ dependency('libnotify') ]
executable('agent',
sources,
include_directories: include_dirs,
dependencies: deps,
install: true,
install_dir: demo_dir)
desktop_in = configure_file(output: 'geoclue-demo-agent.desktop.in',
input: 'geoclue-demo-agent.desktop.in.in',
configuration: desktop_conf)
desktop_file = i18n.merge_file(output: 'geoclue-demo-agent.desktop',
input: desktop_in,
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: desktop_dir)
# Also install in the autostart directory.
autostart_dir = join_paths(sysconfdir, 'xdg', 'autostart')
meson.add_install_script('install-file.py',
desktop_file.full_path(),
autostart_dir)
endif
/* vim: set et ts=8 sw=8: */
/* where-am-i.c
*
* Copyright 2013 Red Hat, Inc.
*
* Geoclue is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* Geoclue is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with Geoclue; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
*/
#include <config.h>
#include <stdlib.h>
#include <locale.h>
#include <glib/gi18n.h>
#include <geoclue.h>
/* Commandline options */
static gint timeout = 30; /* seconds */
static GClueAccuracyLevel accuracy_level = GCLUE_ACCURACY_LEVEL_EXACT;
static gint time_threshold;
static GOptionEntry entries[] =
{
{ "timeout",
't',
0,
G_OPTION_ARG_INT,
&timeout,
N_("Exit after T seconds. Default: 30"),
"T" },
{ "time-threshold",
'i',
0,
G_OPTION_ARG_INT,
&time_threshold,
N_("Only report location update after T seconds. "
"Default: 0 (report new location without any delay)"),
"T" },
{ "accuracy-level",
'a',
0,
G_OPTION_ARG_INT,
&accuracy_level,
N_("Request accuracy level A. "
"Country = 1, "
"City = 4, "
"Neighborhood = 5, "
"Street = 6, "
"Exact = 8."),
"A" },
{ NULL }
};
GClueSimple *simple = NULL;
GClueClient *client = NULL;
GMainLoop *main_loop;
static gboolean
on_location_timeout (gpointer user_data)
{
g_clear_object (&client);
g_clear_object (&simple);
g_main_loop_quit (main_loop);
return FALSE;
}
static void
print_location (GClueSimple *simple)
{
GClueLocation *location;
gdouble altitude, speed, heading;
GVariant *timestamp;
GTimeVal tv = { 0 };
const char *desc;
location = gclue_simple_get_location (simple);
g_print ("\nNew location:\n");
g_print ("Latitude: %f°\nLongitude: %f°\nAccuracy: %f meters\n",
gclue_location_get_latitude (location),
gclue_location_get_longitude (location),
gclue_location_get_accuracy (location));
altitude = gclue_location_get_altitude (location);
if (altitude != -G_MAXDOUBLE)
g_print ("Altitude: %f meters\n", altitude);
speed = gclue_location_get_speed (location);
if (speed >= 0)
g_print ("Speed: %f meters/second\n", speed);
heading = gclue_location_get_heading (location);
if (heading >= 0)
g_print ("Heading: %f°\n", heading);
desc = gclue_location_get_description (location);
if (strlen (desc) > 0)
g_print ("Description: %s\n", desc);
timestamp = gclue_location_get_timestamp (location);
if (timestamp) {
GDateTime *date_time;
gchar *str;
g_variant_get (timestamp, "(tt)", &tv.tv_sec, &tv.tv_usec);
date_time = g_date_time_new_from_timeval_local (&tv);
str = g_date_time_format
(date_time,
"%c (%s seconds since the Epoch)");
g_date_time_unref (date_time);
g_print ("Timestamp: %s\n", str);
g_free (str);
}
}
static void
on_client_active_notify (GClueClient *client,
GParamSpec *pspec,
gpointer user_data)
{
if (gclue_client_get_active (client))
return;
g_print ("Geolocation disabled. Quitting..\n");
on_location_timeout (NULL);
}
static void
on_simple_ready (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GError *error = NULL;
simple = gclue_simple_new_finish (res, &error);
if (error != NULL) {
g_critical ("Failed to connect to GeoClue2 service: %s", error->message);
exit (-1);
}
client = gclue_simple_get_client (simple);
if (client) {
g_object_ref (client);
g_print ("Client object: %s\n",
g_dbus_proxy_get_object_path (G_DBUS_PROXY (client)));
if (time_threshold > 0) {
gclue_client_set_time_threshold (client, time_threshold);
}
g_signal_connect (client,
"notify::active",
G_CALLBACK (on_client_active_notify),
NULL);
}
print_location (simple);
g_signal_connect (simple,
"notify::location",
G_CALLBACK (print_location),
NULL);
}
gint
main (gint argc, gchar *argv[])
{
GOptionContext *context;
GError *error = NULL;
setlocale (LC_ALL, "");
textdomain (GETTEXT_PACKAGE);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
context = g_option_context_new ("- Where am I?");
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
if (!g_option_context_parse (context, &argc, &argv, &error)) {
g_critical ("option parsing failed: %s\n", error->message);
exit (-1);
}
g_option_context_free (context);
g_timeout_add_seconds (timeout, on_location_timeout, NULL);
gclue_simple_new ("geoclue-where-am-i",
accuracy_level,
NULL,
on_simple_ready,
NULL);
main_loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (main_loop);
return EXIT_SUCCESS;
}
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
<bookinfo>
<title>Geoclue Reference Manual</title>
<releaseinfo>Version &version;</releaseinfo>
<authorgroup>
<author>
<firstname>Zeeshan</firstname>
<surname>Ali (Khattak)</surname>
<affiliation>
<address>
<email>zeeshanak@gnome.org</email>
</address>
</affiliation>
</author>
</authorgroup>
<copyright>
<year>2013, 2014</year>
<holder>Red Hat, Inc.</holder>
</copyright>
<legalnotice>
<para>
Permission is granted to copy, distribute and/or modify this
document under the terms of the <citetitle>GNU Free
Documentation License</citetitle>, Version 1.1 or any later
version published by the Free Software Foundation with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. You may obtain a copy of the <citetitle>GNU Free
Documentation License</citetitle> from the Free Software
Foundation by visiting <ulink type="http"
url="http://www.fsf.org">their Web site</ulink> or by writing
to:
<address>
The Free Software Foundation, Inc.,
<street>59 Temple Place</street> - Suite 330,
<city>Boston</city>, <state>MA</state> <postcode>02111-1307</postcode>,
<country>USA</country>
</address>
</para>
<para>
Many of the names used by companies to distinguish their
products and services are claimed as trademarks. Where those
names appear in any GNOME documentation, and those trademarks
are made aware to the members of the GNOME Documentation
Project, the names have been printed in caps or initial caps.
</para>
</legalnotice>
</bookinfo>
<reference id="ref-dbus">
<title>D-Bus API Reference</title>
<partintro>
<para>
This part documents the D-Bus interface used to access the
Geoclue service.
</para>
</partintro>
<xi:include href="../interface/docs-org.freedesktop.GeoClue2.Manager.xml"/>
<xi:include href="../interface/docs-org.freedesktop.GeoClue2.Client.xml"/>
<xi:include href="../interface/docs-org.freedesktop.GeoClue2.Location.xml"/>
<xi:include href="xml/gclue-enums.xml"/>
</reference>
<reference id="ref-agent-dbus">
<title>Agent D-Bus API Reference</title>
<partintro>
<para>
This part documents the D-Bus interface that application-authorizing
agents must implement.
</para>
</partintro>
<xi:include href="../interface/docs-org.freedesktop.GeoClue2.Agent.xml"/>
</reference>
<index>
<title>Index</title>
</index>
<!-- License -->
<appendix id="license">
<title>License</title>
<para>
<programlisting><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../COPYING" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</para>
</appendix>
</book>
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
<bookinfo>
<title>Libgeoclue Reference Manual</title>
<releaseinfo>Version &version;</releaseinfo>
<authorgroup>
<author>
<firstname>Zeeshan</firstname>
<surname>Ali (Khattak)</surname>
<affiliation>
<address>
<email>zeeshanak@gnome.org</email>
</address>
</affiliation>
</author>
</authorgroup>
<copyright>
<year>2015</year>
<holder>Red Hat, Inc.</holder>
</copyright>
<legalnotice>
<para>
Permission is granted to copy, distribute and/or modify this
document under the terms of the <citetitle>GNU Free
Documentation License</citetitle>, Version 1.1 or any later
version published by the Free Software Foundation with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. You may obtain a copy of the <citetitle>GNU Free
Documentation License</citetitle> from the Free Software
Foundation by visiting <ulink type="http"
url="http://www.fsf.org">their Web site</ulink> or by writing
to:
<address>
The Free Software Foundation, Inc.,
<street>59 Temple Place</street> - Suite 330,
<city>Boston</city>, <state>MA</state> <postcode>02111-1307</postcode>,
<country>USA</country>
</address>
</para>
<para>
Many of the names used by companies to distinguish their
products and services are claimed as trademarks. Where those
names appear in any GNOME documentation, and those trademarks
are made aware to the members of the GNOME Documentation
Project, the names have been printed in caps or initial caps.
</para>
</legalnotice>
</bookinfo>
<chapter>
<title>Common enums and flags helpers</title>
<xi:include href="xml/gclue-enums.xml"/>
</chapter>
<chapter>
<title>Convenience API</title>
<xi:include href="xml/gclue-simple.xml"/>
</chapter>
<chapter>
<title>The Manager object</title>
<xi:include href="xml/gclue-manager.xml"/>
<xi:include href="xml/gclue-manager-proxy.xml"/>
</chapter>
<chapter>
<title>The Client object</title>
<xi:include href="xml/gclue-client.xml"/>
<xi:include href="xml/gclue-client-proxy.xml"/>
</chapter>
<chapter>
<title>The Location object</title>
<xi:include href="xml/gclue-location.xml"/>
<xi:include href="xml/gclue-location-proxy.xml"/>
</chapter>
<index>
<title>Index</title>
</index>
<!-- License -->
<appendix id="license">
<title>License</title>
<para>
<programlisting><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="COPYING.LIB" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</para>
</appendix>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
</book>
<SECTION>
<FILE>GClueClient</FILE>
<TITLE>GClueClient</TITLE>
<SUBSECTION Private>
GCLUE_CLIENT_SKELETON
GCLUE_CLIENT_SKELETON_CLASS
GCLUE_CLIENT_SKELETON_GET_CLASS
GCLUE_IS_CLIENT_SKELETON
GCLUE_IS_CLIENT_SKELETON_CLASS
GCLUE_TYPE_CLIENT_SKELETON
GClueClientSkeleton
GClueClientSkeletonClass
GClueClientSkeletonPrivate
gclue_client_skeleton_get_type
gclue_client_skeleton_new
</SECTION>
<SECTION>
<FILE>gclue-client</FILE>
<TITLE>GClueClient</TITLE>
gclue_client_interface_info
gclue_client_override_properties
gclue_client_emit_location_updated
gclue_client_call_start
gclue_client_call_start_finish
gclue_client_call_start_sync
gclue_client_call_stop
gclue_client_call_stop_finish
gclue_client_call_stop_sync
gclue_client_get_location
gclue_client_dup_location
gclue_client_set_location
gclue_client_get_distance_threshold
gclue_client_set_distance_threshold
gclue_client_get_desktop_id
gclue_client_dup_desktop_id
gclue_client_set_desktop_id
gclue_client_get_requested_accuracy_level
gclue_client_set_requested_accuracy_level
gclue_client_get_active
gclue_client_set_active
<SUBSECTION Standard>
GCLUE_CLIENT
GCLUE_CLIENT_GET_IFACE
GCLUE_IS_CLIENT
GCLUE_TYPE_CLIENT
GClueClient
GClueClientIface
gclue_client_get_type
<SUBSECTION Private>
gclue_client_complete_start
gclue_client_complete_stop
</SECTION>
<SECTION>
<FILE>gclue-client-proxy</FILE>
<TITLE>GClueClientProxy</TITLE>
gclue_client_proxy_create
gclue_client_proxy_create_finish
gclue_client_proxy_create_sync
gclue_client_proxy_create_full
gclue_client_proxy_create_full_finish
gclue_client_proxy_create_full_sync
gclue_client_proxy_new
gclue_client_proxy_new_finish
gclue_client_proxy_new_sync
gclue_client_proxy_new_for_bus
gclue_client_proxy_new_for_bus_finish
gclue_client_proxy_new_for_bus_sync
gclue_client_get_time_threshold
gclue_client_set_time_threshold
<SUBSECTION Standard>
GCLUE_CLIENT_PROXY
GCLUE_CLIENT_PROXY_CLASS
GCLUE_CLIENT_PROXY_GET_CLASS
GCLUE_IS_CLIENT_PROXY
GCLUE_IS_CLIENT_PROXY_CLASS
GCLUE_TYPE_CLIENT_PROXY
GClueClientProxy
GClueClientProxyClass
gclue_client_proxy_get_type
<SUBSECTION Private>
GClueClientProxyPrivate
</SECTION>
<SECTION>
<FILE>gclue-enums</FILE>
GClueAccuracyLevel
GCLUE_TYPE_ACCURACY_LEVEL
gclue_accuracy_level_get_type
GClueClientProxyCreateFlags
GCLUE_TYPE_CLIENT_PROXY_CREATE_FLAGS
gclue_client_proxy_create_flags_get_type
<SUBSECTION Private>
gclue_accuracy_level_build_string_from_mask
gclue_accuracy_level_get_string
</SECTION>
<SECTION>
<FILE>gclue-helpers</FILE>
</SECTION>
<SECTION>
<FILE>GClueLocation</FILE>
<TITLE>GClueLocation</TITLE>
<SUBSECTION Private>
GCLUE_IS_LOCATION_SKELETON
GCLUE_IS_LOCATION_SKELETON_CLASS
GCLUE_LOCATION_SKELETON
GCLUE_LOCATION_SKELETON_CLASS
GCLUE_LOCATION_SKELETON_GET_CLASS
GCLUE_TYPE_LOCATION_SKELETON
GClueLocationSkeleton
GClueLocationSkeletonClass
GClueLocationSkeletonPrivate
gclue_location_skeleton_get_type
gclue_location_skeleton_new
</SECTION>
<SECTION>
<FILE>gclue-location</FILE>
<TITLE>GClueLocation</TITLE>
gclue_location_interface_info
gclue_location_override_properties
gclue_location_get_latitude
gclue_location_set_latitude
gclue_location_get_longitude
gclue_location_set_longitude
gclue_location_get_accuracy
gclue_location_set_accuracy
gclue_location_get_altitude
gclue_location_set_altitude
gclue_location_get_speed
gclue_location_set_speed
gclue_location_get_heading
gclue_location_set_heading
gclue_location_get_description
gclue_location_dup_description
gclue_location_set_description
gclue_location_get_timestamp
gclue_location_dup_timestamp
gclue_location_set_timestamp
<SUBSECTION Standard>
GCLUE_IS_LOCATION
GCLUE_LOCATION
GCLUE_LOCATION_GET_IFACE
GCLUE_TYPE_LOCATION
GClueLocation
GClueLocationIface
gclue_location_get_type
</SECTION>
<SECTION>
<FILE>gclue-location-proxy</FILE>
<TITLE>GClueLocationProxy</TITLE>
gclue_location_proxy_new
gclue_location_proxy_new_finish
gclue_location_proxy_new_sync
gclue_location_proxy_new_for_bus
gclue_location_proxy_new_for_bus_finish
gclue_location_proxy_new_for_bus_sync
<SUBSECTION Standard>
GCLUE_IS_LOCATION_PROXY
GCLUE_IS_LOCATION_PROXY_CLASS
GCLUE_LOCATION_PROXY
GCLUE_LOCATION_PROXY_CLASS
GCLUE_LOCATION_PROXY_GET_CLASS
GCLUE_TYPE_LOCATION_PROXY
GClueLocationProxy
GClueLocationProxyClass
GClueLocationProxyPrivate
gclue_location_proxy_get_type
</SECTION>
<SECTION>
<FILE>GClueManager</FILE>
<TITLE>GClueManager</TITLE>
</SECTION>
<SECTION>
<FILE>gclue-manager</FILE>
<TITLE>GClueManager</TITLE>
gclue_manager_interface_info
gclue_manager_override_properties
gclue_manager_call_get_client
gclue_manager_call_get_client_finish
gclue_manager_call_get_client_sync
gclue_manager_call_add_agent
gclue_manager_call_add_agent_finish
gclue_manager_call_add_agent_sync
gclue_manager_get_in_use
gclue_manager_set_in_use
gclue_manager_get_available_accuracy_level
gclue_manager_set_available_accuracy_level
<SUBSECTION Standard>
GCLUE_IS_MANAGER
GCLUE_MANAGER
GCLUE_MANAGER_GET_IFACE
GCLUE_TYPE_MANAGER
GClueManager
GClueManagerIface
gclue_manager_get_type
<SUBSECTION Private>
GCLUE_IS_MANAGER_SKELETON
GCLUE_IS_MANAGER_SKELETON_CLASS
GCLUE_MANAGER_SKELETON
GCLUE_MANAGER_SKELETON_CLASS
GCLUE_MANAGER_SKELETON_GET_CLASS
GCLUE_TYPE_MANAGER_SKELETON
GClueManagerSkeleton
GClueManagerSkeletonClass
GClueManagerSkeletonPrivate
gclue_manager_skeleton_get_type
gclue_manager_skeleton_new
gclue_manager_complete_get_client
gclue_manager_complete_add_agent
</SECTION>
<SECTION>
<FILE>gclue-manager-proxy</FILE>
<TITLE>GClueManagerProxy</TITLE>
gclue_manager_proxy_new
gclue_manager_proxy_new_finish
gclue_manager_proxy_new_sync
gclue_manager_proxy_new_for_bus
gclue_manager_proxy_new_for_bus_finish
gclue_manager_proxy_new_for_bus_sync
<SUBSECTION Standard>
GCLUE_IS_MANAGER_PROXY
GCLUE_IS_MANAGER_PROXY_CLASS
GCLUE_MANAGER_PROXY
GCLUE_MANAGER_PROXY_CLASS
GCLUE_MANAGER_PROXY_GET_CLASS
GCLUE_TYPE_MANAGER_PROXY
GClueManagerProxy
GClueManagerProxyClass
gclue_manager_proxy_get_type
<SUBSECTION Private>
GClueManagerProxyPrivate
</SECTION>
<SECTION>
<SECTION>
<FILE>gclue-simple</FILE>
<TITLE>GClueSimple</TITLE>
gclue_simple_new
gclue_simple_new_finish
gclue_simple_new_sync
gclue_simple_get_client
gclue_simple_get_location
<SUBSECTION Standard>
GCLUE_IS_SIMPLE
GCLUE_IS_SIMPLE_CLASS
GCLUE_SIMPLE
GCLUE_SIMPLE_CLASS
GCLUE_SIMPLE_GET_CLASS
GCLUE_TYPE_SIMPLE
GClueSimple
GClueSimpleClass
GClueSimplePrivate
gclue_simple_get_type
</SECTION>
conf = configuration_data()
conf.set_quoted('VERSION', gclue_version)
version_file = configure_file(output: 'version.xml',
input: 'version.xml.in',
configuration: conf)
content_files = [ '../../COPYING.LIB' ]
scan_options = [ '--ignore-headers=config.h', '--rebuild-types' ]
# Extra options to supply to gtkdoc-mkdb
mkdb_options = [ '--output-format=xml' ]
src_dir = [ 'public-api', 'libgeoclue' ]
fixxref_options = [ '--extra-dir=../html' ]
gnome.gtkdoc('libgeoclue',
main_xml: 'libgeoclue-docs.xml',
content_files: content_files,
gobject_typesfile: 'libgeoclue.types',
dependencies: libgeoclue_dep,
scan_args: scan_options,
fixxref_args: fixxref_options,
src_dir: src_dir,