Commit ec5a2827 authored by Ritesh Raj Sarraf's avatar Ritesh Raj Sarraf Committed by Frédéric Dalleau

Switch to new where-am-i demo tool

The old geoclue-get-address tool was specific to geoclue-0.xx and some
of the interfaces that it used is no more available with GeoClue2.

The newer where-am-i tool is part of the GeoClue2 package
Signed-off-by: Ritesh Raj Sarraf's avatarRitesh Raj Sarraf <ritesh.sarraf@collabora.com>
parent a53fbae5
......@@ -17,7 +17,6 @@ SUBDIRS = \
clutter-zoom/ \
common/ \
dbus/ \
geoclue/automated/ \
gstreamer-buffering/automated/ \
libsoup/automated/ \
networking/proxy-manual/ \
......@@ -40,6 +39,7 @@ COPY = \
common \
dbus \
folks \
geoclue/automated \
grilo \
gstreamer-decode \
inherit-config.sh \
......
====
profile:/usr/lib/geoclue/geoclue-master
profile:/usr/lib/geoclue-2.0/geoclue
sdmode:REJECTING
denied_mask:r
operation:open
......
usr/lib/apertis-tests/apparmor/geoclue
usr/lib/apertis-tests/geoclue/automated
usr/lib/apertis-tests/apparmor/automated usr/share/chaiwala-tests/apparmor/automated
usr/lib/apertis-tests/geoclue/automated usr/share/chaiwala-tests/geoclue/automated
usr/lib/apertis-tests/dbus/dos-match-rules usr/share/chaiwala-tests/dbus-dos-match-rules/manual
usr/lib/apertis-tests/dbus/dos-reply-time usr/share/chaiwala-tests/dbus-dos-reply-time/manual
......@@ -11,15 +11,14 @@ Build-Depends:
libclutter-1.0-dev,
libclutter-gst-3.0-dev,
libfolks-dev,
libgeoclue-dev,
libgrilo-0.2-dev,
libgrilo-0.3-dev,
libgstreamer1.0-dev,
libmx-2.0-0-dev,
libncurses5-dev,
libsoup2.4-dev,
libtelepathy-glib-dev,
libtool,
libtracker-sparql-1.0-dev,
libtracker-sparql-2.0-dev,
pkg-config,
python,
python3,
......@@ -100,8 +99,8 @@ Depends:
apparmor (>= 2.8.0-0ubuntu5co4),
apparmor-profiles,
chaiwala-apparmor-profiles,
gir1.2-grilo-0.2,
gir1.2-tracker-1.0,
gir1.2-grilo-0.3,
gir1.2-tracker-2.0,
python3-gi,
tracker (>= 0.14.1),
Description: Functional tests for Tracker AppArmor profiles/abstractions
......@@ -158,8 +157,8 @@ Depends:
apparmor-profiles,
chaiwala-apparmor-profiles,
chaiwala-tests,
geoclue,
geoclue-manual,
geoclue-2.0,
geoclue-2-demo,
Description: Functional tests for GeoCule AppArmor profiles/abstractions
This package tests Apertis AppArmor profiles for GeoClue.
......
# vim: set ts=8 tw=80 :
progs := geoclue-get-address
include ../../global-config.mk
LIBS := $(shell $(PKG_CONFIG) --libs --cflags geoclue glib-2.0 gobject-2.0)
all: $(progs)
%: %.c
$(CC) $(CFLAGS) -o $@ $< $(LIBS)
get-deps:
$(APT_GET) install geoclue-manual
install: .INSTALL
clean: .CLEAN
/*
* Taken from https://developer.gnome.org/geoclue/unstable/simple-master-example.html
* and heavily modified.
*
* Copyright 2008 by Garmin Ltd. or its subsidiaries
* Copyright 2013 Collabora Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <geoclue/geoclue-master.h>
#include <glib/gstdio.h>
static void
print_addr_field (gchar *key,
gchar *value,
gpointer user_data)
{
g_printf ("%s:\t%s\n", key, value);
}
int main()
{
GeoclueMaster *master;
GeoclueMasterClient *client;
GeoclueAddress *addr;
GHashTable *addr_details;
gboolean got_address = FALSE;
GError *error = NULL;
/* Create a MasterClient using Master */
master = geoclue_master_get_default ();
client = geoclue_master_create_client (master, NULL, &error);
g_object_unref (master);
if (!client) {
g_printerr ("Error creating GeoclueMasterClient: %s\n", error->message);
g_error_free (error);
return 1;
}
/* Set our requirements: We want at least city level accuracy, require signals,
and allow the use of network (but not e.g. GPS) */
if (!geoclue_master_client_set_requirements (client,
GEOCLUE_ACCURACY_LEVEL_LOCALITY,
0, TRUE,
GEOCLUE_RESOURCE_NETWORK,
&error)){
g_printerr ("set_requirements failed: %s", error->message);
g_error_free (error);
g_object_unref (client);
return 1;
}
/* Get an Address object */
addr = geoclue_master_client_create_address (client, NULL);
if (!addr) {
g_printerr ("Failed to get a address object");
g_object_unref (client);
return 1;
}
/* call get_position. We do not know which provider actually provides
the answer (although we could find out using MasterClient API) */
got_address = geoclue_address_get_address (addr,
NULL, /* timestamp */
&addr_details,
NULL, /* accuracy */
&error);
if (!got_address) {
g_printerr ("Error in geoclue_position_get_position: %s.\n", error->message);
g_clear_error (&error);
goto err;
}
if (g_hash_table_size (addr_details) == 0) {
g_printerr ("Error: Geoclue reported no addresses.\n");
goto err;
}
/* For details, see GEOCLUE_ADDRESS_KEY_* inside:
* http://cgit.freedesktop.org/geoclue/tree/geoclue/geoclue-types.h */
g_hash_table_foreach (addr_details,
(GHFunc) print_addr_field,
NULL);
return 0;
err:
g_object_unref (addr);
g_object_unref (client);
return 1;
}
......@@ -26,31 +26,23 @@ setup_success
###########
test_geoclue_manual_address() {
set -x
local cmd addr obj_path method
cmd="geoclue-get-address"
addr="org.freedesktop.Geoclue.Providers.Manual"
obj_path="/org/freedesktop/Geoclue/Providers/Manual"
method="org.freedesktop.Geoclue.Manual.SetAddressFields"
local cmd addr
cmd="/usr/lib/geoclue-2.0/demos/where-am-i"
addr="org.freedesktop.GeoClue2"
# Manual provider doesn't update the address without this
pkill 'geoclue-.+'
# Launch geoclue manually to allow LD_PRELOAD to work for
# chaiwala-apparmor-geoclue-tests
/usr/lib/geoclue/geoclue-master 2>&1 | sed -e 's/^/# /' &
/usr/lib/geoclue/geoclue-manual 2>&1 | sed -e 's/^/# /' &
/usr/lib/geoclue-2.0/geoclue
# FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=745971
# Wait for the name to be available (ready) on the bus
mc-wait-for-name "${addr}"
"${GDBUS}" call --session --dest "${addr}" \
--object-path "${obj_path}" \
--method "${method}" \
7200 "UK" "United Kingdom" "Cambridgeshire" "Cambridge" \
"Kett House" "CB1 2JH" "Station Road" 2>&1 | sed -e 's/^/# /'
# Unset LD_PRELOAD for this bit
LD_PRELOAD= "${TESTLIBDIR}/${cmd}"
LD_PRELOAD= "${cmd}"
ret=$?
pkill 'geoclue-.+'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment