aboutsummaryrefslogtreecommitdiffstats
path: root/packages/tangogps/files/0003-Try-to-request-the-GPS-resource-from-ousaged.patch
blob: 09b2c2ad8a775486edb6afdc130792440a3e3c41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From 2562a173716141cd9ea5c227dfa52f04ce4205f8 Mon Sep 17 00:00:00 2001
From: Daniel Willmann <daniel@totalueberwachung.de>
Date: Tue, 22 Jul 2008 00:22:58 +0200
Subject: [PATCH] Try to request the GPS resource from ousaged

---
 configure.in        |    2 +-
 src/gps_functions.c |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/configure.in b/configure.in
index cf06033..2bc3cf9 100644
--- a/configure.in
+++ b/configure.in
@@ -23,7 +23,7 @@ AM_GLIB_GNU_GETTEXT
 
 AM_PROG_LIBTOOL
 
-PKG_CHECK_MODULES(PACKAGE, [gtk+-2.0 gdk-2.0 gconf-2.0 gypsy])
+PKG_CHECK_MODULES(PACKAGE, [gtk+-2.0 gdk-2.0 gconf-2.0 dbus-glib-1 gypsy])
 AC_SUBST(PACKAGE_CFLAGS)
 AC_SUBST(PACKAGE_LIBS)
 
diff --git a/src/gps_functions.c b/src/gps_functions.c
index 57646e1..0802e67 100644
--- a/src/gps_functions.c
+++ b/src/gps_functions.c
@@ -11,6 +11,7 @@
 #include <gypsy/gypsy-course.h>
 #include <gypsy/gypsy-satellite.h>
 
+#include <dbus/dbus-glib.h>
 #include <glib.h>
 #include <glib/gprintf.h>
 
@@ -705,6 +706,11 @@ static void on_satellites_changed(GypsySatellite *sat,  GPtrArray *sats, void *u
 #define GYPSY_OBJ_PATH "/org/freedesktop/Gypsy"
 
 int setup_gypsy() {
+	DBusGConnection *connection;
+	DBusGProxy *proxy;
+	GError *error;
+	int result;
+
 	gpsdata = g_new0(gps_data_t,1);
 
 	GypsyControl *gyctrl = gypsy_control_get_default();
@@ -723,6 +729,22 @@ int setup_gypsy() {
 	gpsdata->fix.mode = gypsy_device_get_fix_status(gydevice, NULL);
 	gpsdata->valid = gpsdata->fix.mode > 1;
 
+  error = NULL;
+  connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+  if (connection == NULL) {
+    g_printerr ("Failed to open connection to bus: %s\n",
+          error->message);
+    g_error_free (error);
+    proxy = NULL;
+  }
+
+  proxy = dbus_g_proxy_new_for_name (connection,
+             "org.freesmartphone.ousaged",
+             "/org/freesmartphone/Usage",
+             "org.freesmartphone.Usage");
+
+	dbus_g_proxy_call (proxy, "RequestResource", &error, G_TYPE_STRING, "GPS", G_TYPE_INVALID, G_TYPE_BOOLEAN, &result, G_TYPE_INVALID);
+
 	return 1;
 }
 
-- 
1.5.4.5