Merge lp:~noskcaj/empathy/geoclue-2.0 into lp:~ubuntu-desktop/empathy/ubuntu
- geoclue-2.0
- Merge into ubuntu
Proposed by
Jackson Doak
Status: | Needs review |
---|---|
Proposed branch: | lp:~noskcaj/empathy/geoclue-2.0 |
Merge into: | lp:~ubuntu-desktop/empathy/ubuntu |
Diff against target: |
1473 lines (+10/-1425) 4 files modified
debian/changelog (+8/-0) debian/control (+2/-2) debian/patches/Revert-geoclue-2.0.patch (+0/-1422) debian/patches/series (+0/-1) |
To merge this branch: | bzr merge lp:~noskcaj/empathy/geoclue-2.0 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sebastien Bacher | Needs Information | ||
Review via email: mp+241187@code.launchpad.net |
Commit message
Description of the change
Use geoclue-2.0 now that it's in main
To post a comment you must log in.
Revision history for this message
Tim Lunn (darkxst) wrote : | # |
geoclue-2.0 uses mozilla location service, so the user would still get a location, just not from ubuntu-geoip.
Unmerged revisions
- 370. By Jackson Doak
-
* Use geoclue-2.0. LP: #1389336
- Drop Revert-geoclue- 2.0.patch
- Replace old geoclue deps with geoclue-2.0
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2014-10-28 17:30:15 +0000 | |||
3 | +++ debian/changelog 2014-11-08 20:15:08 +0000 | |||
4 | @@ -1,3 +1,11 @@ | |||
5 | 1 | empathy (3.12.6-0ubuntu2) vivid; urgency=medium | ||
6 | 2 | |||
7 | 3 | * Use geoclue-2.0. LP: #1389336 | ||
8 | 4 | - Drop Revert-geoclue-2.0.patch | ||
9 | 5 | - Replace old geoclue deps with geoclue-2.0 | ||
10 | 6 | |||
11 | 7 | -- Jackson Doak <noskcaj@ubuntu.com> Sat, 08 Nov 2014 16:24:34 +1100 | ||
12 | 8 | |||
13 | 1 | empathy (3.12.6-0ubuntu1) vivid; urgency=medium | 9 | empathy (3.12.6-0ubuntu1) vivid; urgency=medium |
14 | 2 | 10 | ||
15 | 3 | [ Jackson Doak ] | 11 | [ Jackson Doak ] |
16 | 4 | 12 | ||
17 | === modified file 'debian/control' | |||
18 | --- debian/control 2014-09-30 11:10:19 +0000 | |||
19 | +++ debian/control 2014-11-08 20:15:08 +0000 | |||
20 | @@ -29,7 +29,7 @@ | |||
21 | 29 | libgstreamer-plugins-base1.0-dev, | 29 | libgstreamer-plugins-base1.0-dev, |
22 | 30 | libnm-glib-dev (>= 0.7) [linux-any], | 30 | libnm-glib-dev (>= 0.7) [linux-any], |
23 | 31 | libnm-util-dev (>= 0.7) [linux-any], | 31 | libnm-util-dev (>= 0.7) [linux-any], |
25 | 32 | libgeoclue-dev (>= 0.12), | 32 | geoclue-2.0, |
26 | 33 | libgnome-keyring-dev (>= 2.26.0), | 33 | libgnome-keyring-dev (>= 2.26.0), |
27 | 34 | libgcr-3-dev (>= 2.91.4), | 34 | libgcr-3-dev (>= 2.91.4), |
28 | 35 | libfolks-dev (>= 0.9.5), | 35 | libfolks-dev (>= 0.9.5), |
29 | @@ -65,7 +65,7 @@ | |||
30 | 65 | telepathy-mission-control-5 (>= 1:5.12.0), | 65 | telepathy-mission-control-5 (>= 1:5.12.0), |
31 | 66 | gsettings-desktop-schemas, | 66 | gsettings-desktop-schemas, |
32 | 67 | gnome-icon-theme (>= 2.30.0), | 67 | gnome-icon-theme (>= 2.30.0), |
34 | 68 | geoclue, | 68 | geoclue-2.0, |
35 | 69 | telepathy-logger (>= 0.2.13), | 69 | telepathy-logger (>= 0.2.13), |
36 | 70 | dbus-x11, | 70 | dbus-x11, |
37 | 71 | gstreamer1.0-pulseaudio | 71 | gstreamer1.0-pulseaudio |
38 | 72 | 72 | ||
39 | === removed file 'debian/patches/Revert-geoclue-2.0.patch' | |||
40 | --- debian/patches/Revert-geoclue-2.0.patch 2014-09-24 08:08:59 +0000 | |||
41 | +++ debian/patches/Revert-geoclue-2.0.patch 1970-01-01 00:00:00 +0000 | |||
42 | @@ -1,1422 +0,0 @@ | |||
43 | 1 | Description: Revert 4 upstream git commits so we can use old geoclue | ||
44 | 2 | Reverted commits used for new geoclue: | ||
45 | 3 | https://git.gnome.org/browse/empathy/commit/?id=dcb5ddc560b51cc5eb59a2ef27d91cf279271f36 | ||
46 | 4 | https://git.gnome.org/browse/empathy/commit/?id=24238851a5f3617c52bd60d1f99ac5eef0c079a1 | ||
47 | 5 | https://git.gnome.org/browse/empathy/commit/?id=32529f49e3935b5f4fd747fcfe2d62322f86ec52 | ||
48 | 6 | https://git.gnome.org/browse/empathy/commit/?id=f6f6c6421e0e286db920d3e01fa64cc3ebe4f4df | ||
49 | 7 | Author: Jackson Doak <noskcaj@ubuntu.com> | ||
50 | 8 | Origin: upstream | ||
51 | 9 | Forwarded: not-needed | ||
52 | 10 | Last-Update: 2014-09-24 | ||
53 | 11 | |||
54 | 12 | --- empathy-3.12.6.orig/configure.ac | ||
55 | 13 | +++ empathy-3.12.6/configure.ac | ||
56 | 14 | @@ -73,7 +73,7 @@ GOA_REQUIRED=3.5.1 | ||
57 | 15 | |||
58 | 16 | # Optional deps | ||
59 | 17 | ENCHANT_REQUIRED=1.2.0 | ||
60 | 18 | -GEOCLUE_REQUIRED=1.99.3 | ||
61 | 19 | +GEOCLUE_REQUIRED=0.12 | ||
62 | 20 | GEOCODE_GLIB_REQUIRED=0.99.1 | ||
63 | 21 | ISO_CODES_REQUIRED=0.35 | ||
64 | 22 | NAUTILUS_SENDTO_REQUIRED=2.90.0 | ||
65 | 23 | @@ -416,18 +416,11 @@ AC_ARG_ENABLE(location, | ||
66 | 24 | if test "x$enable_location" != "xno"; then | ||
67 | 25 | PKG_CHECK_MODULES(GEOCLUE, | ||
68 | 26 | [ | ||
69 | 27 | - geoclue-2.0 >= $GEOCLUE_REQUIRED | ||
70 | 28 | + geoclue >= $GEOCLUE_REQUIRED | ||
71 | 29 | ], have_geoclue="yes", have_geoclue="no") | ||
72 | 30 | |||
73 | 31 | if test "x$have_geoclue" = "xyes"; then | ||
74 | 32 | - GEOCLUE_XML_FILE=`pkg-config --variable=dbus_interface geoclue-2.0` | ||
75 | 33 | - if test "x$GEOCLUE_XML_FILE" = "x"; then | ||
76 | 34 | - echo "Can't find dbus_interface variable in geoclue-2.0.pc" | ||
77 | 35 | - have_geoclue="no" | ||
78 | 36 | - else | ||
79 | 37 | - AC_DEFINE(HAVE_GEOCLUE, 1, [Define if you have geoclue-2]) | ||
80 | 38 | - AC_SUBST(GEOCLUE_XML_FILE) | ||
81 | 39 | - fi | ||
82 | 40 | + AC_DEFINE(HAVE_GEOCLUE, 1, [Define if you have geoclue]) | ||
83 | 41 | fi | ||
84 | 42 | else | ||
85 | 43 | have_geoclue="no" | ||
86 | 44 | --- empathy-3.12.6.orig/data/empathy.convert | ||
87 | 45 | +++ empathy-3.12.6/data/empathy.convert | ||
88 | 46 | @@ -54,5 +54,8 @@ close-main-window = /apps/empathy/hints/ | ||
89 | 47 | |||
90 | 48 | [org.gnome.Empathy.location] | ||
91 | 49 | publish = /apps/empathy/location/publish | ||
92 | 50 | +resource-network = /apps/empathy/location/resource_network | ||
93 | 51 | +resource-cell = /apps/empathy/location/resource_cell | ||
94 | 52 | +resource-gps = /apps/empathy/location/resource_gps | ||
95 | 53 | reduce-accuracy = /apps/empathy/location/reduce_accuracy | ||
96 | 54 | |||
97 | 55 | --- empathy-3.12.6.orig/data/org.gnome.Empathy.gschema.xml | ||
98 | 56 | +++ empathy-3.12.6/data/org.gnome.Empathy.gschema.xml | ||
99 | 57 | @@ -256,6 +256,21 @@ present them to the user immediately.</d | ||
100 | 58 | <summary>Empathy can publish the user's location</summary> | ||
101 | 59 | <description>Whether Empathy can publish the user's location to their contacts.</description> | ||
102 | 60 | </key> | ||
103 | 61 | + <key name="resource-network" type="b"> | ||
104 | 62 | + <default>true</default> | ||
105 | 63 | + <summary>Empathy can use the network to guess the location</summary> | ||
106 | 64 | + <description>Whether Empathy can use the network to guess the location.</description> | ||
107 | 65 | + </key> | ||
108 | 66 | + <key name="resource-cell" type="b"> | ||
109 | 67 | + <default>true</default> | ||
110 | 68 | + <summary>Empathy can use the cellular network to guess the location</summary> | ||
111 | 69 | + <description>Whether Empathy can use the cellular network to guess the location.</description> | ||
112 | 70 | + </key> | ||
113 | 71 | + <key name="resource-gps" type="b"> | ||
114 | 72 | + <default>false</default> | ||
115 | 73 | + <summary>Empathy can use the GPS to guess the location</summary> | ||
116 | 74 | + <description>Whether Empathy can use the GPS to guess the location.</description> | ||
117 | 75 | + </key> | ||
118 | 76 | <key name="reduce-accuracy" type="b"> | ||
119 | 77 | <default>true</default> | ||
120 | 78 | <summary>Empathy should reduce the location's accuracy</summary> | ||
121 | 79 | --- empathy-3.12.6.orig/libempathy-gtk/Makefile.am | ||
122 | 80 | +++ empathy-3.12.6/libempathy-gtk/Makefile.am | ||
123 | 81 | @@ -249,26 +249,11 @@ EXTRA_DIST = \ | ||
124 | 82 | $(ui_DATA) | ||
125 | 83 | |||
126 | 84 | if HAVE_GEOCLUE | ||
127 | 85 | -geoclue-interface.c: geoclue-interface.h | ||
128 | 86 | -geoclue-interface.h: Makefile.am | ||
129 | 87 | - gdbus-codegen \ | ||
130 | 88 | - --interface-prefix org.freedesktop.GeoClue2. \ | ||
131 | 89 | - --c-namespace GClue \ | ||
132 | 90 | - --generate-c-code geoclue-interface \ | ||
133 | 91 | - $(GEOCLUE_XML_FILE) | ||
134 | 92 | - | ||
135 | 93 | -BUILT_SOURCES += \ | ||
136 | 94 | - geoclue-interface.h \ | ||
137 | 95 | - geoclue-interface.c | ||
138 | 96 | - | ||
139 | 97 | libempathy_gtk_handwritten_source += \ | ||
140 | 98 | - empathy-location-manager.c \ | ||
141 | 99 | - empathy-geoclue-helper.c | ||
142 | 100 | + empathy-location-manager.c | ||
143 | 101 | |||
144 | 102 | libempathy_gtk_headers += \ | ||
145 | 103 | - empathy-location-manager.h \ | ||
146 | 104 | - empathy-geoclue-helper.h | ||
147 | 105 | - | ||
148 | 106 | + empathy-location-manager.h | ||
149 | 107 | else | ||
150 | 108 | EXTRA_DIST += \ | ||
151 | 109 | empathy-location-manager.c \ | ||
152 | 110 | --- empathy-3.12.6.orig/libempathy-gtk/empathy-geoclue-helper.c | ||
153 | 111 | +++ /dev/null | ||
154 | 112 | @@ -1,523 +0,0 @@ | ||
155 | 113 | -/* | ||
156 | 114 | - * empathy-geoclue-helper.c | ||
157 | 115 | - * | ||
158 | 116 | - * Copyright (C) 2013 Collabora Ltd. <http://www.collabora.co.uk/> | ||
159 | 117 | - * | ||
160 | 118 | - * This library is free software; you can redistribute it and/or | ||
161 | 119 | - * modify it under the terms of the GNU Lesser General Public | ||
162 | 120 | - * License as published by the Free Software Foundation; either | ||
163 | 121 | - * version 2.1 of the License, or (at your option) any later version. | ||
164 | 122 | - * | ||
165 | 123 | - * This library is distributed in the hope that it will be useful, | ||
166 | 124 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
167 | 125 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
168 | 126 | - * Lesser General Public License for more details. | ||
169 | 127 | - * | ||
170 | 128 | - * You should have received a copy of the GNU Lesser General Public | ||
171 | 129 | - * License along with this library; if not, write to the Free Software | ||
172 | 130 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
173 | 131 | - */ | ||
174 | 132 | - | ||
175 | 133 | -#include "config.h" | ||
176 | 134 | - | ||
177 | 135 | -#include <gio/gio.h> | ||
178 | 136 | - | ||
179 | 137 | -#include "empathy-geoclue-helper.h" | ||
180 | 138 | - | ||
181 | 139 | -#define DEBUG_FLAG EMPATHY_DEBUG_LOCATION | ||
182 | 140 | -#include "empathy-debug.h" | ||
183 | 141 | - | ||
184 | 142 | -#define GEOCLUE_BUS_NAME "org.freedesktop.GeoClue2" | ||
185 | 143 | - | ||
186 | 144 | -/** | ||
187 | 145 | - * SECTION: empathy-geoclue-helper | ||
188 | 146 | - * @title: EmpathyGeoclueHelper | ||
189 | 147 | - * @short_description: TODO | ||
190 | 148 | - * | ||
191 | 149 | - * TODO | ||
192 | 150 | - */ | ||
193 | 151 | - | ||
194 | 152 | -/** | ||
195 | 153 | - * EmpathyGeoclueHelper: | ||
196 | 154 | - * | ||
197 | 155 | - * Data structure representing a #EmpathyGeoclueHelper. | ||
198 | 156 | - * | ||
199 | 157 | - * Since: UNRELEASED | ||
200 | 158 | - */ | ||
201 | 159 | - | ||
202 | 160 | -/** | ||
203 | 161 | - * EmpathyGeoclueHelperClass: | ||
204 | 162 | - * | ||
205 | 163 | - * The class of a #EmpathyGeoclueHelper. | ||
206 | 164 | - * | ||
207 | 165 | - * Since: UNRELEASED | ||
208 | 166 | - */ | ||
209 | 167 | - | ||
210 | 168 | -static void async_initable_iface_init (GAsyncInitableIface *iface); | ||
211 | 169 | - | ||
212 | 170 | -G_DEFINE_TYPE_WITH_CODE (EmpathyGeoclueHelper, empathy_geoclue_helper, | ||
213 | 171 | - G_TYPE_OBJECT, | ||
214 | 172 | - G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, async_initable_iface_init)); | ||
215 | 173 | - | ||
216 | 174 | -enum | ||
217 | 175 | -{ | ||
218 | 176 | - PROP_DISTANCE_THRESHOLD = 1, | ||
219 | 177 | - PROP_LOCATION, | ||
220 | 178 | - N_PROPS | ||
221 | 179 | -}; | ||
222 | 180 | - | ||
223 | 181 | -enum | ||
224 | 182 | -{ | ||
225 | 183 | - SIG_LOCATION_CHANGED, | ||
226 | 184 | - LAST_SIGNAL | ||
227 | 185 | -}; | ||
228 | 186 | - | ||
229 | 187 | -static guint signals[LAST_SIGNAL]; | ||
230 | 188 | - | ||
231 | 189 | -struct _EmpathyGeoclueHelperPriv | ||
232 | 190 | -{ | ||
233 | 191 | - guint distance_threshold; | ||
234 | 192 | - GClueLocation *location; | ||
235 | 193 | - | ||
236 | 194 | - gboolean started; | ||
237 | 195 | - GClueClient *client; | ||
238 | 196 | -}; | ||
239 | 197 | - | ||
240 | 198 | -static void | ||
241 | 199 | -empathy_geoclue_helper_get_property (GObject *object, | ||
242 | 200 | - guint property_id, | ||
243 | 201 | - GValue *value, | ||
244 | 202 | - GParamSpec *pspec) | ||
245 | 203 | -{ | ||
246 | 204 | - EmpathyGeoclueHelper *self = EMPATHY_GEOCLUE_HELPER (object); | ||
247 | 205 | - | ||
248 | 206 | - switch (property_id) | ||
249 | 207 | - { | ||
250 | 208 | - case PROP_DISTANCE_THRESHOLD: | ||
251 | 209 | - g_value_set_uint (value, self->priv->distance_threshold); | ||
252 | 210 | - break; | ||
253 | 211 | - case PROP_LOCATION: | ||
254 | 212 | - g_value_set_object (value, self->priv->location); | ||
255 | 213 | - break; | ||
256 | 214 | - default: | ||
257 | 215 | - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | ||
258 | 216 | - break; | ||
259 | 217 | - } | ||
260 | 218 | -} | ||
261 | 219 | - | ||
262 | 220 | -static void | ||
263 | 221 | -empathy_geoclue_helper_set_property (GObject *object, | ||
264 | 222 | - guint property_id, | ||
265 | 223 | - const GValue *value, | ||
266 | 224 | - GParamSpec *pspec) | ||
267 | 225 | -{ | ||
268 | 226 | - EmpathyGeoclueHelper *self = EMPATHY_GEOCLUE_HELPER (object); | ||
269 | 227 | - | ||
270 | 228 | - switch (property_id) | ||
271 | 229 | - { | ||
272 | 230 | - case PROP_DISTANCE_THRESHOLD: | ||
273 | 231 | - self->priv->distance_threshold = g_value_get_uint (value); | ||
274 | 232 | - break; | ||
275 | 233 | - default: | ||
276 | 234 | - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | ||
277 | 235 | - break; | ||
278 | 236 | - } | ||
279 | 237 | -} | ||
280 | 238 | - | ||
281 | 239 | -static void | ||
282 | 240 | -empathy_geoclue_helper_constructed (GObject *object) | ||
283 | 241 | -{ | ||
284 | 242 | - //EmpathyGeoclueHelper *self = EMPATHY_GEOCLUE_HELPER (object); | ||
285 | 243 | - void (*chain_up) (GObject *) = | ||
286 | 244 | - ((GObjectClass *) empathy_geoclue_helper_parent_class)->constructed; | ||
287 | 245 | - | ||
288 | 246 | - chain_up (object); | ||
289 | 247 | -} | ||
290 | 248 | - | ||
291 | 249 | -static void | ||
292 | 250 | -empathy_geoclue_helper_dispose (GObject *object) | ||
293 | 251 | -{ | ||
294 | 252 | - EmpathyGeoclueHelper *self = EMPATHY_GEOCLUE_HELPER (object); | ||
295 | 253 | - void (*chain_up) (GObject *) = | ||
296 | 254 | - ((GObjectClass *) empathy_geoclue_helper_parent_class)->dispose; | ||
297 | 255 | - | ||
298 | 256 | - if (self->priv->started) | ||
299 | 257 | - { | ||
300 | 258 | - gclue_client_call_stop (self->priv->client, NULL, NULL, NULL); | ||
301 | 259 | - | ||
302 | 260 | - self->priv->started = FALSE; | ||
303 | 261 | - } | ||
304 | 262 | - | ||
305 | 263 | - g_clear_object (&self->priv->location); | ||
306 | 264 | - g_clear_object (&self->priv->client); | ||
307 | 265 | - | ||
308 | 266 | - chain_up (object); | ||
309 | 267 | -} | ||
310 | 268 | - | ||
311 | 269 | -static void | ||
312 | 270 | -empathy_geoclue_helper_finalize (GObject *object) | ||
313 | 271 | -{ | ||
314 | 272 | - //EmpathyGeoclueHelper *self = EMPATHY_GEOCLUE_HELPER (object); | ||
315 | 273 | - void (*chain_up) (GObject *) = | ||
316 | 274 | - ((GObjectClass *) empathy_geoclue_helper_parent_class)->finalize; | ||
317 | 275 | - | ||
318 | 276 | - chain_up (object); | ||
319 | 277 | -} | ||
320 | 278 | - | ||
321 | 279 | -static void | ||
322 | 280 | -empathy_geoclue_helper_class_init ( | ||
323 | 281 | - EmpathyGeoclueHelperClass *klass) | ||
324 | 282 | -{ | ||
325 | 283 | - GObjectClass *oclass = G_OBJECT_CLASS (klass); | ||
326 | 284 | - GParamSpec *spec; | ||
327 | 285 | - | ||
328 | 286 | - oclass->get_property = empathy_geoclue_helper_get_property; | ||
329 | 287 | - oclass->set_property = empathy_geoclue_helper_set_property; | ||
330 | 288 | - oclass->constructed = empathy_geoclue_helper_constructed; | ||
331 | 289 | - oclass->dispose = empathy_geoclue_helper_dispose; | ||
332 | 290 | - oclass->finalize = empathy_geoclue_helper_finalize; | ||
333 | 291 | - | ||
334 | 292 | - /** | ||
335 | 293 | - * EmpathyGeoclueHelper:distance-threshold: | ||
336 | 294 | - * | ||
337 | 295 | - * TODO | ||
338 | 296 | - * | ||
339 | 297 | - * Since: UNRELEASED | ||
340 | 298 | - */ | ||
341 | 299 | - spec = g_param_spec_uint ("distance-threshold", "distance-threshold", | ||
342 | 300 | - "DistanceThreshold", | ||
343 | 301 | - 0, G_MAXUINT32, 0, | ||
344 | 302 | - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); | ||
345 | 303 | - g_object_class_install_property (oclass, PROP_DISTANCE_THRESHOLD, spec); | ||
346 | 304 | - | ||
347 | 305 | - /** | ||
348 | 306 | - * EmpathyGeoclueHelper:location: | ||
349 | 307 | - * | ||
350 | 308 | - * TODO | ||
351 | 309 | - * | ||
352 | 310 | - * Since: UNRELEASED | ||
353 | 311 | - */ | ||
354 | 312 | - spec = g_param_spec_object ("location", "location", "GClueLocation", | ||
355 | 313 | - GCLUE_TYPE_LOCATION, | ||
356 | 314 | - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); | ||
357 | 315 | - g_object_class_install_property (oclass, PROP_LOCATION, spec); | ||
358 | 316 | - | ||
359 | 317 | - /** | ||
360 | 318 | - * EmpathyGeoclueHelper::location-changed: | ||
361 | 319 | - * @self: a #EmpathyGeoclueHelper | ||
362 | 320 | - * | ||
363 | 321 | - * TODO | ||
364 | 322 | - * | ||
365 | 323 | - * Since: UNRELEASED | ||
366 | 324 | - */ | ||
367 | 325 | - signals[SIG_LOCATION_CHANGED] = g_signal_new ("location-changed", | ||
368 | 326 | - G_OBJECT_CLASS_TYPE (klass), | ||
369 | 327 | - G_SIGNAL_RUN_LAST, | ||
370 | 328 | - 0, NULL, NULL, NULL, | ||
371 | 329 | - G_TYPE_NONE, | ||
372 | 330 | - 1, GCLUE_TYPE_LOCATION); | ||
373 | 331 | - | ||
374 | 332 | - g_type_class_add_private (klass, sizeof (EmpathyGeoclueHelperPriv)); | ||
375 | 333 | -} | ||
376 | 334 | - | ||
377 | 335 | -static void | ||
378 | 336 | -empathy_geoclue_helper_init (EmpathyGeoclueHelper *self) | ||
379 | 337 | -{ | ||
380 | 338 | - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, | ||
381 | 339 | - EMPATHY_TYPE_GEOCLUE_HELPER, EmpathyGeoclueHelperPriv); | ||
382 | 340 | -} | ||
383 | 341 | - | ||
384 | 342 | -static void | ||
385 | 343 | -location_cb (GObject *source, | ||
386 | 344 | - GAsyncResult *result, | ||
387 | 345 | - gpointer user_data) | ||
388 | 346 | -{ | ||
389 | 347 | - EmpathyGeoclueHelper *self = user_data; | ||
390 | 348 | - GError *error = NULL; | ||
391 | 349 | - | ||
392 | 350 | - g_clear_object (&self->priv->location); | ||
393 | 351 | - | ||
394 | 352 | - self->priv->location = gclue_location_proxy_new_finish (result, &error); | ||
395 | 353 | - if (self->priv->location == NULL) | ||
396 | 354 | - { | ||
397 | 355 | - DEBUG ("Failed to create Location proxy: %s", error->message); | ||
398 | 356 | - g_error_free (error); | ||
399 | 357 | - } | ||
400 | 358 | - | ||
401 | 359 | - g_signal_emit (self, signals[SIG_LOCATION_CHANGED], 0, self->priv->location); | ||
402 | 360 | - | ||
403 | 361 | - g_object_notify (G_OBJECT (self), "location"); | ||
404 | 362 | -} | ||
405 | 363 | - | ||
406 | 364 | -static void | ||
407 | 365 | -location_updated_cb (GClueClient *client, | ||
408 | 366 | - const gchar *old, | ||
409 | 367 | - const gchar *new, | ||
410 | 368 | - EmpathyGeoclueHelper *self) | ||
411 | 369 | -{ | ||
412 | 370 | - gclue_location_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, | ||
413 | 371 | - GEOCLUE_BUS_NAME, new, | ||
414 | 372 | - NULL, location_cb, self); | ||
415 | 373 | -} | ||
416 | 374 | - | ||
417 | 375 | -static void | ||
418 | 376 | -client_start_cb (GObject *source, | ||
419 | 377 | - GAsyncResult *result, | ||
420 | 378 | - gpointer user_data) | ||
421 | 379 | -{ | ||
422 | 380 | - GTask *task = user_data; | ||
423 | 381 | - EmpathyGeoclueHelper *self = g_task_get_source_object (task); | ||
424 | 382 | - GClueClient *client = GCLUE_CLIENT (source); | ||
425 | 383 | - GError *error = NULL; | ||
426 | 384 | - | ||
427 | 385 | - if (!gclue_client_call_start_finish (client, result, &error)) | ||
428 | 386 | - { | ||
429 | 387 | - DEBUG ("Failed to start Geoclue client: %s", error->message); | ||
430 | 388 | - g_error_free (error); | ||
431 | 389 | - return; | ||
432 | 390 | - } | ||
433 | 391 | - | ||
434 | 392 | - self->priv->started = TRUE; | ||
435 | 393 | - | ||
436 | 394 | - g_task_return_boolean (task, TRUE); | ||
437 | 395 | - g_object_unref (task); | ||
438 | 396 | -} | ||
439 | 397 | - | ||
440 | 398 | -static void | ||
441 | 399 | -client_cb (GObject *source, | ||
442 | 400 | - GAsyncResult *result, | ||
443 | 401 | - gpointer user_data) | ||
444 | 402 | -{ | ||
445 | 403 | - GTask *task = user_data; | ||
446 | 404 | - EmpathyGeoclueHelper *self = g_task_get_source_object (task); | ||
447 | 405 | - GError *error = NULL; | ||
448 | 406 | - | ||
449 | 407 | - self->priv->client = gclue_client_proxy_new_finish (result, &error); | ||
450 | 408 | - if (!gclue_client_proxy_new_for_bus_finish (result, &error)) | ||
451 | 409 | - { | ||
452 | 410 | - DEBUG ("Failed to create Geoclue client: %s", error->message); | ||
453 | 411 | - g_task_return_error (task, error); | ||
454 | 412 | - goto out; | ||
455 | 413 | - } | ||
456 | 414 | - | ||
457 | 415 | - g_signal_connect_object (self->priv->client, "location-updated", | ||
458 | 416 | - G_CALLBACK (location_updated_cb), self, 0); | ||
459 | 417 | - | ||
460 | 418 | - g_object_set (self->priv->client, | ||
461 | 419 | - "distance-threshold", self->priv->distance_threshold, | ||
462 | 420 | - NULL); | ||
463 | 421 | - | ||
464 | 422 | - g_task_return_boolean (task, TRUE); | ||
465 | 423 | - | ||
466 | 424 | -out: | ||
467 | 425 | - g_object_unref (task); | ||
468 | 426 | -} | ||
469 | 427 | - | ||
470 | 428 | -static void | ||
471 | 429 | -get_client_cb (GObject *source, | ||
472 | 430 | - GAsyncResult *result, | ||
473 | 431 | - gpointer user_data) | ||
474 | 432 | -{ | ||
475 | 433 | - GTask *task = user_data; | ||
476 | 434 | - GError *error = NULL; | ||
477 | 435 | - gchar *path; | ||
478 | 436 | - | ||
479 | 437 | - if (!gclue_manager_call_get_client_finish (GCLUE_MANAGER (source), &path, | ||
480 | 438 | - result, &error)) | ||
481 | 439 | - { | ||
482 | 440 | - DEBUG ("GetClient failed: %s", error->message); | ||
483 | 441 | - g_task_return_error (task, error); | ||
484 | 442 | - g_object_unref (task); | ||
485 | 443 | - return; | ||
486 | 444 | - } | ||
487 | 445 | - | ||
488 | 446 | - gclue_client_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, | ||
489 | 447 | - GEOCLUE_BUS_NAME, path, NULL, client_cb, task); | ||
490 | 448 | - | ||
491 | 449 | - g_free (path); | ||
492 | 450 | -} | ||
493 | 451 | - | ||
494 | 452 | -static void | ||
495 | 453 | -manager_cb (GObject *source, | ||
496 | 454 | - GAsyncResult *result, | ||
497 | 455 | - gpointer user_data) | ||
498 | 456 | -{ | ||
499 | 457 | - GTask *task = user_data; | ||
500 | 458 | - GError *error = NULL; | ||
501 | 459 | - GClueManager *mgr; | ||
502 | 460 | - | ||
503 | 461 | - mgr = gclue_manager_proxy_new_for_bus_finish (result, &error); | ||
504 | 462 | - if (mgr == NULL) | ||
505 | 463 | - { | ||
506 | 464 | - DEBUG ("Failed to create Geoclue manager: %s", error->message); | ||
507 | 465 | - g_task_return_error (task, error); | ||
508 | 466 | - g_object_unref (task); | ||
509 | 467 | - return; | ||
510 | 468 | - } | ||
511 | 469 | - | ||
512 | 470 | - gclue_manager_call_get_client (mgr, NULL, get_client_cb, task); | ||
513 | 471 | - g_object_unref (mgr); | ||
514 | 472 | -} | ||
515 | 473 | - | ||
516 | 474 | -void | ||
517 | 475 | -empathy_geoclue_helper_start_async (EmpathyGeoclueHelper *self, | ||
518 | 476 | - GAsyncReadyCallback callback, | ||
519 | 477 | - gpointer user_data) | ||
520 | 478 | -{ | ||
521 | 479 | - GTask *task; | ||
522 | 480 | - | ||
523 | 481 | - task = g_task_new (self, NULL, callback, user_data); | ||
524 | 482 | - | ||
525 | 483 | - if (self->priv->started) | ||
526 | 484 | - { | ||
527 | 485 | - g_task_return_boolean (task, TRUE); | ||
528 | 486 | - g_object_unref (task); | ||
529 | 487 | - return; | ||
530 | 488 | - } | ||
531 | 489 | - | ||
532 | 490 | - gclue_client_call_start (self->priv->client, NULL, client_start_cb, task); | ||
533 | 491 | -} | ||
534 | 492 | - | ||
535 | 493 | -gboolean | ||
536 | 494 | -empathy_geoclue_helper_start_finish (EmpathyGeoclueHelper *self, | ||
537 | 495 | - GAsyncResult *result, | ||
538 | 496 | - GError **error) | ||
539 | 497 | -{ | ||
540 | 498 | - g_return_val_if_fail (g_task_is_valid (result, self), FALSE); | ||
541 | 499 | - | ||
542 | 500 | - return g_task_propagate_boolean (G_TASK (result), error); | ||
543 | 501 | -} | ||
544 | 502 | - | ||
545 | 503 | -GClueLocation * | ||
546 | 504 | -empathy_geoclue_helper_get_location (EmpathyGeoclueHelper *self) | ||
547 | 505 | -{ | ||
548 | 506 | - return self->priv->location; | ||
549 | 507 | -} | ||
550 | 508 | - | ||
551 | 509 | -static void | ||
552 | 510 | -empathy_geoclue_helper_init_async (GAsyncInitable *initable, | ||
553 | 511 | - gint io_priority, | ||
554 | 512 | - GCancellable *cancellable, | ||
555 | 513 | - GAsyncReadyCallback callback, | ||
556 | 514 | - gpointer user_data) | ||
557 | 515 | -{ | ||
558 | 516 | - GTask *task; | ||
559 | 517 | - | ||
560 | 518 | - task = g_task_new (initable, cancellable, callback, user_data); | ||
561 | 519 | - | ||
562 | 520 | - gclue_manager_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, | ||
563 | 521 | - GEOCLUE_BUS_NAME, "/org/freedesktop/GeoClue2/Manager", | ||
564 | 522 | - NULL, manager_cb, task); | ||
565 | 523 | -} | ||
566 | 524 | - | ||
567 | 525 | -static gboolean | ||
568 | 526 | -empathy_geoclue_helper_init_finish (GAsyncInitable *initable, | ||
569 | 527 | - GAsyncResult *result, | ||
570 | 528 | - GError **error) | ||
571 | 529 | -{ | ||
572 | 530 | - g_return_val_if_fail (g_task_is_valid (result, initable), FALSE); | ||
573 | 531 | - | ||
574 | 532 | - return g_task_propagate_boolean (G_TASK (result), error); | ||
575 | 533 | -} | ||
576 | 534 | - | ||
577 | 535 | -static void | ||
578 | 536 | -async_initable_iface_init (GAsyncInitableIface *iface) | ||
579 | 537 | -{ | ||
580 | 538 | - iface->init_async = empathy_geoclue_helper_init_async; | ||
581 | 539 | - iface->init_finish = empathy_geoclue_helper_init_finish; | ||
582 | 540 | -} | ||
583 | 541 | - | ||
584 | 542 | -void | ||
585 | 543 | -empathy_geoclue_helper_new_async (guint distance_threshold, | ||
586 | 544 | - GAsyncReadyCallback callback, | ||
587 | 545 | - gpointer user_data) | ||
588 | 546 | -{ | ||
589 | 547 | - g_async_initable_new_async (EMPATHY_TYPE_GEOCLUE_HELPER, | ||
590 | 548 | - G_PRIORITY_DEFAULT, NULL, callback, user_data, | ||
591 | 549 | - "distance-threshold", distance_threshold, | ||
592 | 550 | - NULL); | ||
593 | 551 | -} | ||
594 | 552 | - | ||
595 | 553 | -EmpathyGeoclueHelper * | ||
596 | 554 | -empathy_geoclue_helper_new_finish (GAsyncResult *result, | ||
597 | 555 | - GError **error) | ||
598 | 556 | -{ | ||
599 | 557 | - GObject *object, *source_object; | ||
600 | 558 | - | ||
601 | 559 | - source_object = g_async_result_get_source_object (result); | ||
602 | 560 | - | ||
603 | 561 | - object = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), | ||
604 | 562 | - result, error); | ||
605 | 563 | - g_object_unref (source_object); | ||
606 | 564 | - | ||
607 | 565 | - if (object != NULL) | ||
608 | 566 | - return EMPATHY_GEOCLUE_HELPER (object); | ||
609 | 567 | - else | ||
610 | 568 | - return NULL; | ||
611 | 569 | -} | ||
612 | 570 | - | ||
613 | 571 | -static void | ||
614 | 572 | -new_started_cb (GObject *source, | ||
615 | 573 | - GAsyncResult *result, | ||
616 | 574 | - gpointer user_data) | ||
617 | 575 | -{ | ||
618 | 576 | - EmpathyGeoclueHelper *self = EMPATHY_GEOCLUE_HELPER (source); | ||
619 | 577 | - GTask *new_started_task = user_data; | ||
620 | 578 | - GError *error = NULL; | ||
621 | 579 | - | ||
622 | 580 | - if (!empathy_geoclue_helper_start_finish (self, result, &error)) | ||
623 | 581 | - { | ||
624 | 582 | - g_task_return_error (new_started_task, error); | ||
625 | 583 | - g_object_unref (self); | ||
626 | 584 | - goto out; | ||
627 | 585 | - } | ||
628 | 586 | - | ||
629 | 587 | - /* pass ownership of self to g_task_return_error */ | ||
630 | 588 | - g_task_return_pointer (new_started_task, self, g_object_unref); | ||
631 | 589 | - | ||
632 | 590 | -out: | ||
633 | 591 | - g_object_unref (new_started_task); | ||
634 | 592 | -} | ||
635 | 593 | - | ||
636 | 594 | -static void | ||
637 | 595 | -new_started_init_cb (GObject *source, | ||
638 | 596 | - GAsyncResult *result, | ||
639 | 597 | - gpointer user_data) | ||
640 | 598 | -{ | ||
641 | 599 | - GTask *new_started_task = user_data; | ||
642 | 600 | - EmpathyGeoclueHelper *self; | ||
643 | 601 | - GError *error = NULL; | ||
644 | 602 | - | ||
645 | 603 | - self = empathy_geoclue_helper_new_finish (result, &error); | ||
646 | 604 | - if (self == NULL) | ||
647 | 605 | - { | ||
648 | 606 | - g_task_return_error (new_started_task, error); | ||
649 | 607 | - g_object_unref (new_started_task); | ||
650 | 608 | - return; | ||
651 | 609 | - } | ||
652 | 610 | - | ||
653 | 611 | - /* Pass owernship of 'self' to new_started_cb */ | ||
654 | 612 | - empathy_geoclue_helper_start_async (self, new_started_cb, new_started_task); | ||
655 | 613 | -} | ||
656 | 614 | - | ||
657 | 615 | -void | ||
658 | 616 | -empathy_geoclue_helper_new_started_async (guint distance_threshold, | ||
659 | 617 | - GAsyncReadyCallback callback, | ||
660 | 618 | - gpointer user_data) | ||
661 | 619 | -{ | ||
662 | 620 | - GTask *new_started_task; | ||
663 | 621 | - | ||
664 | 622 | - new_started_task = g_task_new (NULL, NULL, callback, user_data); | ||
665 | 623 | - | ||
666 | 624 | - empathy_geoclue_helper_new_async (distance_threshold, new_started_init_cb, | ||
667 | 625 | - new_started_task); | ||
668 | 626 | -} | ||
669 | 627 | - | ||
670 | 628 | -EmpathyGeoclueHelper * | ||
671 | 629 | -empathy_geoclue_helper_new_started_finish (GAsyncResult *result, | ||
672 | 630 | - GError **error) | ||
673 | 631 | -{ | ||
674 | 632 | - g_return_val_if_fail (g_task_is_valid (result, NULL), NULL); | ||
675 | 633 | - | ||
676 | 634 | - return g_task_propagate_pointer (G_TASK (result), error); | ||
677 | 635 | -} | ||
678 | 636 | --- empathy-3.12.6.orig/libempathy-gtk/empathy-geoclue-helper.h | ||
679 | 637 | +++ /dev/null | ||
680 | 638 | @@ -1,99 +0,0 @@ | ||
681 | 639 | -/* | ||
682 | 640 | - * empathy-geoclue-helper.h | ||
683 | 641 | - * | ||
684 | 642 | - * Copyright (C) 2013 Collabora Ltd. <http://www.collabora.co.uk/> | ||
685 | 643 | - * | ||
686 | 644 | - * This library is free software; you can redistribute it and/or | ||
687 | 645 | - * modify it under the terms of the GNU Lesser General Public | ||
688 | 646 | - * License as published by the Free Software Foundation; either | ||
689 | 647 | - * version 2.1 of the License, or (at your option) any later version. | ||
690 | 648 | - * | ||
691 | 649 | - * This library is distributed in the hope that it will be useful, | ||
692 | 650 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
693 | 651 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
694 | 652 | - * Lesser General Public License for more details. | ||
695 | 653 | - * | ||
696 | 654 | - * You should have received a copy of the GNU Lesser General Public | ||
697 | 655 | - * License along with this library; if not, write to the Free Software | ||
698 | 656 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
699 | 657 | - */ | ||
700 | 658 | - | ||
701 | 659 | -#ifndef __EMPATHY_GEOCLUE_HELPER_H__ | ||
702 | 660 | -#define __EMPATHY_GEOCLUE_HELPER_H__ | ||
703 | 661 | - | ||
704 | 662 | -#include <glib-object.h> | ||
705 | 663 | - | ||
706 | 664 | -G_BEGIN_DECLS | ||
707 | 665 | - | ||
708 | 666 | -#include "geoclue-interface.h" | ||
709 | 667 | - | ||
710 | 668 | -typedef struct _EmpathyGeoclueHelper EmpathyGeoclueHelper; | ||
711 | 669 | -typedef struct _EmpathyGeoclueHelperClass EmpathyGeoclueHelperClass; | ||
712 | 670 | -typedef struct _EmpathyGeoclueHelperPriv EmpathyGeoclueHelperPriv; | ||
713 | 671 | - | ||
714 | 672 | -struct _EmpathyGeoclueHelperClass | ||
715 | 673 | -{ | ||
716 | 674 | - /*<private>*/ | ||
717 | 675 | - GObjectClass parent_class; | ||
718 | 676 | -}; | ||
719 | 677 | - | ||
720 | 678 | -struct _EmpathyGeoclueHelper | ||
721 | 679 | -{ | ||
722 | 680 | - /*<private>*/ | ||
723 | 681 | - GObject parent; | ||
724 | 682 | - EmpathyGeoclueHelperPriv *priv; | ||
725 | 683 | -}; | ||
726 | 684 | - | ||
727 | 685 | -GType empathy_geoclue_helper_get_type (void); | ||
728 | 686 | - | ||
729 | 687 | -/* TYPE MACROS */ | ||
730 | 688 | -#define EMPATHY_TYPE_GEOCLUE_HELPER \ | ||
731 | 689 | - (empathy_geoclue_helper_get_type ()) | ||
732 | 690 | -#define EMPATHY_GEOCLUE_HELPER(obj) \ | ||
733 | 691 | - (G_TYPE_CHECK_INSTANCE_CAST((obj), \ | ||
734 | 692 | - EMPATHY_TYPE_GEOCLUE_HELPER, \ | ||
735 | 693 | - EmpathyGeoclueHelper)) | ||
736 | 694 | -#define EMPATHY_GEOCLUE_HELPER_CLASS(klass) \ | ||
737 | 695 | - (G_TYPE_CHECK_CLASS_CAST((klass), \ | ||
738 | 696 | - EMPATHY_TYPE_GEOCLUE_HELPER, \ | ||
739 | 697 | - EmpathyGeoclueHelperClass)) | ||
740 | 698 | -#define EMPATHY_IS_GEOCLUE_HELPER(obj) \ | ||
741 | 699 | - (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ | ||
742 | 700 | - EMPATHY_TYPE_GEOCLUE_HELPER)) | ||
743 | 701 | -#define EMPATHY_IS_GEOCLUE_HELPER_CLASS(klass) \ | ||
744 | 702 | - (G_TYPE_CHECK_CLASS_TYPE((klass), \ | ||
745 | 703 | - EMPATHY_TYPE_GEOCLUE_HELPER)) | ||
746 | 704 | -#define EMPATHY_GEOCLUE_HELPER_GET_CLASS(obj) \ | ||
747 | 705 | - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ | ||
748 | 706 | - EMPATHY_TYPE_GEOCLUE_HELPER, \ | ||
749 | 707 | - EmpathyGeoclueHelperClass)) | ||
750 | 708 | - | ||
751 | 709 | -void empathy_geoclue_helper_new_async (guint distance_threshold, | ||
752 | 710 | - GAsyncReadyCallback callback, | ||
753 | 711 | - gpointer user_data); | ||
754 | 712 | - | ||
755 | 713 | -EmpathyGeoclueHelper * empathy_geoclue_helper_new_finish (GAsyncResult *result, | ||
756 | 714 | - GError **error); | ||
757 | 715 | - | ||
758 | 716 | -void empathy_geoclue_helper_new_started_async (guint distance_threshold, | ||
759 | 717 | - GAsyncReadyCallback callback, | ||
760 | 718 | - gpointer user_data); | ||
761 | 719 | - | ||
762 | 720 | -EmpathyGeoclueHelper * empathy_geoclue_helper_new_started_finish ( | ||
763 | 721 | - GAsyncResult *result, | ||
764 | 722 | - GError **error); | ||
765 | 723 | - | ||
766 | 724 | -void empathy_geoclue_helper_start_async (EmpathyGeoclueHelper *self, | ||
767 | 725 | - GAsyncReadyCallback callback, | ||
768 | 726 | - gpointer user_data); | ||
769 | 727 | - | ||
770 | 728 | -gboolean empathy_geoclue_helper_start_finish (EmpathyGeoclueHelper *self, | ||
771 | 729 | - GAsyncResult *result, | ||
772 | 730 | - GError **error); | ||
773 | 731 | - | ||
774 | 732 | -GClueLocation * empathy_geoclue_helper_get_location ( | ||
775 | 733 | - EmpathyGeoclueHelper *self); | ||
776 | 734 | - | ||
777 | 735 | -G_END_DECLS | ||
778 | 736 | - | ||
779 | 737 | -#endif /* #ifndef __EMPATHY_GEOCLUE_HELPER_H__*/ | ||
780 | 738 | --- empathy-3.12.6.orig/libempathy-gtk/empathy-location-manager.c | ||
781 | 739 | +++ empathy-3.12.6/libempathy-gtk/empathy-location-manager.c | ||
782 | 740 | @@ -24,11 +24,11 @@ | ||
783 | 741 | |||
784 | 742 | #include <telepathy-glib/telepathy-glib-dbus.h> | ||
785 | 743 | |||
786 | 744 | +#include <geoclue/geoclue-master.h> | ||
787 | 745 | #include <tp-account-widgets/tpaw-time.h> | ||
788 | 746 | |||
789 | 747 | #include "empathy-gsettings.h" | ||
790 | 748 | #include "empathy-location.h" | ||
791 | 749 | -#include "empathy-geoclue-helper.h" | ||
792 | 750 | |||
793 | 751 | #define DEBUG_FLAG EMPATHY_DEBUG_LOCATION | ||
794 | 752 | #include "empathy-debug.h" | ||
795 | 753 | @@ -37,16 +37,8 @@ | ||
796 | 754 | #define TIMEOUT 10 | ||
797 | 755 | static EmpathyLocationManager *location_manager = NULL; | ||
798 | 756 | |||
799 | 757 | -typedef enum | ||
800 | 758 | -{ | ||
801 | 759 | - GEOCLUE_NONE = 0, | ||
802 | 760 | - GEOCLUE_STARTING, | ||
803 | 761 | - GEOCLUE_STARTED, | ||
804 | 762 | - GEOCLUE_FAILED, | ||
805 | 763 | -} GeoclueStatus; | ||
806 | 764 | - | ||
807 | 765 | struct _EmpathyLocationManagerPrivate { | ||
808 | 766 | - GeoclueStatus geoclue_status; | ||
809 | 767 | + gboolean geoclue_is_setup; | ||
810 | 768 | /* Contains the location to be sent to accounts. Geoclue is used | ||
811 | 769 | * to populate it. This HashTable uses Telepathy's style (string, | ||
812 | 770 | * GValue). Keys are defined in empathy-location.h | ||
813 | 771 | @@ -55,9 +47,13 @@ struct _EmpathyLocationManagerPrivate { | ||
814 | 772 | |||
815 | 773 | GSettings *gsettings_loc; | ||
816 | 774 | |||
817 | 775 | + GeoclueResourceFlags resources; | ||
818 | 776 | + GeoclueMasterClient *gc_client; | ||
819 | 777 | + GeocluePosition *gc_position; | ||
820 | 778 | + GeoclueAddress *gc_address; | ||
821 | 779 | + | ||
822 | 780 | gboolean reduce_accuracy; | ||
823 | 781 | TpAccountManager *account_manager; | ||
824 | 782 | - EmpathyGeoclueHelper *geoclue; | ||
825 | 783 | |||
826 | 784 | /* The idle id for publish_on_idle func */ | ||
827 | 785 | guint timeout_id; | ||
828 | 786 | @@ -97,6 +93,9 @@ location_manager_dispose (GObject *objec | ||
829 | 787 | |||
830 | 788 | tp_clear_object (&self->priv->account_manager); | ||
831 | 789 | tp_clear_object (&self->priv->gsettings_loc); | ||
832 | 790 | + tp_clear_object (&self->priv->gc_client); | ||
833 | 791 | + tp_clear_object (&self->priv->gc_position); | ||
834 | 792 | + tp_clear_object (&self->priv->gc_address); | ||
835 | 793 | tp_clear_pointer (&self->priv->location, g_hash_table_unref); | ||
836 | 794 | |||
837 | 795 | if (dispose != NULL) | ||
838 | 796 | @@ -243,105 +242,333 @@ new_connection_cb (TpAccount *account, | ||
839 | 797 | } | ||
840 | 798 | |||
841 | 799 | static void | ||
842 | 800 | -update_location (EmpathyLocationManager *self, | ||
843 | 801 | - GClueLocation *proxy) | ||
844 | 802 | +update_timestamp (EmpathyLocationManager *self) | ||
845 | 803 | { | ||
846 | 804 | - gdouble latitude, longitude, accuracy; | ||
847 | 805 | - const gchar *desc; | ||
848 | 806 | gint64 timestamp; | ||
849 | 807 | |||
850 | 808 | - latitude = gclue_location_get_latitude (proxy); | ||
851 | 809 | - longitude = gclue_location_get_longitude (proxy); | ||
852 | 810 | - accuracy = gclue_location_get_accuracy (proxy); | ||
853 | 811 | - desc = gclue_location_get_description (proxy); | ||
854 | 812 | - | ||
855 | 813 | - DEBUG ("Location updated: (%f %f) accuracy: %f (%s)", | ||
856 | 814 | - latitude, longitude, accuracy, desc); | ||
857 | 815 | - | ||
858 | 816 | - if (self->priv->reduce_accuracy) | ||
859 | 817 | - { | ||
860 | 818 | - /* Truncate at 1 decimal place */ | ||
861 | 819 | - latitude = ((int) (latitude * 10)) / 10.0; | ||
862 | 820 | - longitude = ((int) (longitude * 10)) / 10.0; | ||
863 | 821 | + timestamp = tpaw_time_get_current (); | ||
864 | 822 | + tp_asv_set_int64 (self->priv->location, EMPATHY_LOCATION_TIMESTAMP, | ||
865 | 823 | + timestamp); | ||
866 | 824 | + | ||
867 | 825 | + DEBUG ("\t - Timestamp: %" G_GINT64_FORMAT, timestamp); | ||
868 | 826 | +} | ||
869 | 827 | + | ||
870 | 828 | +static void | ||
871 | 829 | +address_changed_cb (GeoclueAddress *address, | ||
872 | 830 | + int timestamp, | ||
873 | 831 | + GHashTable *details, | ||
874 | 832 | + GeoclueAccuracy *accuracy, | ||
875 | 833 | + gpointer user_data) | ||
876 | 834 | +{ | ||
877 | 835 | + EmpathyLocationManager *self = user_data; | ||
878 | 836 | + GeoclueAccuracyLevel level; | ||
879 | 837 | + GHashTableIter iter; | ||
880 | 838 | + gpointer key, value; | ||
881 | 839 | + | ||
882 | 840 | + geoclue_accuracy_get_details (accuracy, &level, NULL, NULL); | ||
883 | 841 | + DEBUG ("New address (accuracy level %d):", level); | ||
884 | 842 | + /* FIXME: Publish accuracy level also considering the position's */ | ||
885 | 843 | + | ||
886 | 844 | + g_hash_table_remove (self->priv->location, EMPATHY_LOCATION_STREET); | ||
887 | 845 | + g_hash_table_remove (self->priv->location, EMPATHY_LOCATION_AREA); | ||
888 | 846 | + g_hash_table_remove (self->priv->location, EMPATHY_LOCATION_REGION); | ||
889 | 847 | + g_hash_table_remove (self->priv->location, EMPATHY_LOCATION_COUNTRY); | ||
890 | 848 | + g_hash_table_remove (self->priv->location, EMPATHY_LOCATION_COUNTRY_CODE); | ||
891 | 849 | + g_hash_table_remove (self->priv->location, EMPATHY_LOCATION_POSTAL_CODE); | ||
892 | 850 | + | ||
893 | 851 | + if (g_hash_table_size (details) == 0) | ||
894 | 852 | + { | ||
895 | 853 | + DEBUG ("\t - (Empty)"); | ||
896 | 854 | + return; | ||
897 | 855 | + } | ||
898 | 856 | + | ||
899 | 857 | + g_hash_table_iter_init (&iter, details); | ||
900 | 858 | + while (g_hash_table_iter_next (&iter, &key, &value)) | ||
901 | 859 | + { | ||
902 | 860 | + /* Discard street information if reduced accuracy is on */ | ||
903 | 861 | + if (self->priv->reduce_accuracy && | ||
904 | 862 | + !tp_strdiff (key, EMPATHY_LOCATION_STREET)) | ||
905 | 863 | + continue; | ||
906 | 864 | + | ||
907 | 865 | + tp_asv_set_string (self->priv->location, key, value); | ||
908 | 866 | + | ||
909 | 867 | + DEBUG ("\t - %s: %s", (gchar *) key, (gchar *) value); | ||
910 | 868 | + } | ||
911 | 869 | + | ||
912 | 870 | + update_timestamp (self); | ||
913 | 871 | + if (self->priv->timeout_id == 0) | ||
914 | 872 | + self->priv->timeout_id = g_timeout_add_seconds (TIMEOUT, publish_on_idle, | ||
915 | 873 | + self); | ||
916 | 874 | +} | ||
917 | 875 | + | ||
918 | 876 | +static void | ||
919 | 877 | +initial_address_cb (GeoclueAddress *address, | ||
920 | 878 | + int timestamp, | ||
921 | 879 | + GHashTable *details, | ||
922 | 880 | + GeoclueAccuracy *accuracy, | ||
923 | 881 | + GError *error, | ||
924 | 882 | + gpointer self) | ||
925 | 883 | +{ | ||
926 | 884 | + if (error) | ||
927 | 885 | + { | ||
928 | 886 | + DEBUG ("Error: %s", error->message); | ||
929 | 887 | + g_error_free (error); | ||
930 | 888 | } | ||
931 | 889 | else | ||
932 | 890 | { | ||
933 | 891 | - /* Include the description only if we are not asked to reduce the | ||
934 | 892 | - * accuracy as it can contains a pretty specific description of the | ||
935 | 893 | - * location. */ | ||
936 | 894 | - tp_asv_set_string (self->priv->location, EMPATHY_LOCATION_DESCRIPTION, | ||
937 | 895 | - desc); | ||
938 | 896 | + address_changed_cb (address, timestamp, details, accuracy, self); | ||
939 | 897 | } | ||
940 | 898 | +} | ||
941 | 899 | |||
942 | 900 | - tp_asv_set_double (self->priv->location, EMPATHY_LOCATION_LAT, latitude); | ||
943 | 901 | - tp_asv_set_double (self->priv->location, EMPATHY_LOCATION_LON, longitude); | ||
944 | 902 | - tp_asv_set_double (self->priv->location, EMPATHY_LOCATION_ACCURACY, accuracy); | ||
945 | 903 | +static void | ||
946 | 904 | +position_changed_cb (GeocluePosition *position, | ||
947 | 905 | + GeocluePositionFields fields, | ||
948 | 906 | + int timestamp, | ||
949 | 907 | + double latitude, | ||
950 | 908 | + double longitude, | ||
951 | 909 | + double altitude, | ||
952 | 910 | + GeoclueAccuracy *accuracy, | ||
953 | 911 | + gpointer user_data) | ||
954 | 912 | +{ | ||
955 | 913 | + EmpathyLocationManager *self = user_data; | ||
956 | 914 | + GeoclueAccuracyLevel level; | ||
957 | 915 | + gdouble mean, horizontal, vertical; | ||
958 | 916 | |||
959 | 917 | - timestamp = tpaw_time_get_current (); | ||
960 | 918 | - tp_asv_set_int64 (self->priv->location, EMPATHY_LOCATION_TIMESTAMP, | ||
961 | 919 | - timestamp); | ||
962 | 920 | + geoclue_accuracy_get_details (accuracy, &level, &horizontal, &vertical); | ||
963 | 921 | + DEBUG ("New position (accuracy level %d)", level); | ||
964 | 922 | + if (level == GEOCLUE_ACCURACY_LEVEL_NONE) | ||
965 | 923 | + return; | ||
966 | 924 | + | ||
967 | 925 | + if (fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) | ||
968 | 926 | + { | ||
969 | 927 | + | ||
970 | 928 | + if (self->priv->reduce_accuracy) | ||
971 | 929 | + /* Truncate at 1 decimal place */ | ||
972 | 930 | + longitude = ((int) (longitude * 10)) / 10.0; | ||
973 | 931 | |||
974 | 932 | + tp_asv_set_double (self->priv->location, EMPATHY_LOCATION_LON, longitude); | ||
975 | 933 | + | ||
976 | 934 | + DEBUG ("\t - Longitude: %f", longitude); | ||
977 | 935 | + } | ||
978 | 936 | + else | ||
979 | 937 | + { | ||
980 | 938 | + g_hash_table_remove (self->priv->location, EMPATHY_LOCATION_LON); | ||
981 | 939 | + } | ||
982 | 940 | + | ||
983 | 941 | + if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE) | ||
984 | 942 | + { | ||
985 | 943 | + if (self->priv->reduce_accuracy) | ||
986 | 944 | + /* Truncate at 1 decimal place */ | ||
987 | 945 | + latitude = ((int) (latitude * 10)) / 10.0; | ||
988 | 946 | + | ||
989 | 947 | + tp_asv_set_double (self->priv->location, EMPATHY_LOCATION_LAT, latitude); | ||
990 | 948 | + | ||
991 | 949 | + DEBUG ("\t - Latitude: %f", latitude); | ||
992 | 950 | + } | ||
993 | 951 | + else | ||
994 | 952 | + { | ||
995 | 953 | + g_hash_table_remove (self->priv->location, EMPATHY_LOCATION_LAT); | ||
996 | 954 | + } | ||
997 | 955 | + | ||
998 | 956 | + if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE) | ||
999 | 957 | + { | ||
1000 | 958 | + tp_asv_set_double (self->priv->location, EMPATHY_LOCATION_ALT, altitude); | ||
1001 | 959 | + | ||
1002 | 960 | + DEBUG ("\t - Altitude: %f", altitude); | ||
1003 | 961 | + } | ||
1004 | 962 | + else | ||
1005 | 963 | + { | ||
1006 | 964 | + g_hash_table_remove (self->priv->location, EMPATHY_LOCATION_ALT); | ||
1007 | 965 | + } | ||
1008 | 966 | + | ||
1009 | 967 | + if (level == GEOCLUE_ACCURACY_LEVEL_DETAILED) | ||
1010 | 968 | + { | ||
1011 | 969 | + mean = (horizontal + vertical) / 2.0; | ||
1012 | 970 | + tp_asv_set_double (self->priv->location, EMPATHY_LOCATION_ACCURACY, mean); | ||
1013 | 971 | + | ||
1014 | 972 | + DEBUG ("\t - Accuracy: %f", mean); | ||
1015 | 973 | + } | ||
1016 | 974 | + else | ||
1017 | 975 | + { | ||
1018 | 976 | + g_hash_table_remove (self->priv->location, EMPATHY_LOCATION_ACCURACY); | ||
1019 | 977 | + } | ||
1020 | 978 | + | ||
1021 | 979 | + update_timestamp (self); | ||
1022 | 980 | if (self->priv->timeout_id == 0) | ||
1023 | 981 | self->priv->timeout_id = g_timeout_add_seconds (TIMEOUT, publish_on_idle, | ||
1024 | 982 | self); | ||
1025 | 983 | } | ||
1026 | 984 | |||
1027 | 985 | static void | ||
1028 | 986 | -location_changed_cb (EmpathyGeoclueHelper *geoclue, | ||
1029 | 987 | - GClueLocation *location, | ||
1030 | 988 | - EmpathyLocationManager *self) | ||
1031 | 989 | +initial_position_cb (GeocluePosition *position, | ||
1032 | 990 | + GeocluePositionFields fields, | ||
1033 | 991 | + int timestamp, | ||
1034 | 992 | + double latitude, | ||
1035 | 993 | + double longitude, | ||
1036 | 994 | + double altitude, | ||
1037 | 995 | + GeoclueAccuracy *accuracy, | ||
1038 | 996 | + GError *error, | ||
1039 | 997 | + gpointer self) | ||
1040 | 998 | { | ||
1041 | 999 | - update_location (self, location); | ||
1042 | 1000 | + if (error) | ||
1043 | 1001 | + { | ||
1044 | 1002 | + DEBUG ("Error: %s", error->message); | ||
1045 | 1003 | + g_error_free (error); | ||
1046 | 1004 | + } | ||
1047 | 1005 | + else | ||
1048 | 1006 | + { | ||
1049 | 1007 | + position_changed_cb (position, fields, timestamp, latitude, longitude, | ||
1050 | 1008 | + altitude, accuracy, self); | ||
1051 | 1009 | + } | ||
1052 | 1010 | } | ||
1053 | 1011 | |||
1054 | 1012 | static void | ||
1055 | 1013 | -geoclue_new_cb (GObject *source, | ||
1056 | 1014 | - GAsyncResult *result, | ||
1057 | 1015 | - gpointer user_data) | ||
1058 | 1016 | +set_requirements (EmpathyLocationManager *self, | ||
1059 | 1017 | + GeoclueSetRequirementsCallback callback) | ||
1060 | 1018 | { | ||
1061 | 1019 | - EmpathyLocationManager *self = EMPATHY_LOCATION_MANAGER (user_data); | ||
1062 | 1020 | - GError *error = NULL; | ||
1063 | 1021 | - GClueLocation *location; | ||
1064 | 1022 | + geoclue_master_client_set_requirements_async (self->priv->gc_client, | ||
1065 | 1023 | + GEOCLUE_ACCURACY_LEVEL_COUNTRY, 0, FALSE, self->priv->resources, | ||
1066 | 1024 | + callback, self); | ||
1067 | 1025 | +} | ||
1068 | 1026 | + | ||
1069 | 1027 | +static void | ||
1070 | 1028 | +update_resources_set_requirements_cb (GeoclueMasterClient *client, | ||
1071 | 1029 | + GError *error, | ||
1072 | 1030 | + gpointer userdata) | ||
1073 | 1031 | +{ | ||
1074 | 1032 | + EmpathyLocationManager *self = userdata; | ||
1075 | 1033 | |||
1076 | 1034 | - self->priv->geoclue = empathy_geoclue_helper_new_started_finish (result, | ||
1077 | 1035 | - &error); | ||
1078 | 1036 | + if (error != NULL) | ||
1079 | 1037 | + { | ||
1080 | 1038 | + DEBUG ("set_requirements failed: %s", error->message); | ||
1081 | 1039 | + g_error_free (error); | ||
1082 | 1040 | + return; | ||
1083 | 1041 | + } | ||
1084 | 1042 | |||
1085 | 1043 | - if (self->priv->geoclue == NULL) | ||
1086 | 1044 | + geoclue_address_get_address_async (self->priv->gc_address, | ||
1087 | 1045 | + initial_address_cb, self); | ||
1088 | 1046 | + geoclue_position_get_position_async (self->priv->gc_position, | ||
1089 | 1047 | + initial_position_cb, self); | ||
1090 | 1048 | +} | ||
1091 | 1049 | + | ||
1092 | 1050 | +static void | ||
1093 | 1051 | +update_resources (EmpathyLocationManager *self) | ||
1094 | 1052 | +{ | ||
1095 | 1053 | + DEBUG ("Updating resources %d", self->priv->resources); | ||
1096 | 1054 | + | ||
1097 | 1055 | + if (!self->priv->geoclue_is_setup) | ||
1098 | 1056 | + return; | ||
1099 | 1057 | + | ||
1100 | 1058 | + /* As per Geoclue bug #15126, using NONE results in no address | ||
1101 | 1059 | + * being found as geoclue-manual report an empty address with | ||
1102 | 1060 | + * accuracy = NONE */ | ||
1103 | 1061 | + set_requirements (self, update_resources_set_requirements_cb); | ||
1104 | 1062 | +} | ||
1105 | 1063 | + | ||
1106 | 1064 | +static void | ||
1107 | 1065 | +create_address_cb (GeoclueMasterClient *client, | ||
1108 | 1066 | + GeoclueAddress *address, | ||
1109 | 1067 | + GError *error, | ||
1110 | 1068 | + gpointer userdata) | ||
1111 | 1069 | +{ | ||
1112 | 1070 | + EmpathyLocationManager *self = userdata; | ||
1113 | 1071 | + | ||
1114 | 1072 | + if (error != NULL) | ||
1115 | 1073 | { | ||
1116 | 1074 | - DEBUG ("Failed to create Geoclue client: %s", error->message); | ||
1117 | 1075 | + DEBUG ("Failed to create GeoclueAddress: %s", error->message); | ||
1118 | 1076 | g_error_free (error); | ||
1119 | 1077 | - self->priv->geoclue_status = GEOCLUE_FAILED; | ||
1120 | 1078 | return; | ||
1121 | 1079 | } | ||
1122 | 1080 | |||
1123 | 1081 | - self->priv->geoclue_status = GEOCLUE_STARTED; | ||
1124 | 1082 | + self->priv->gc_address = address; | ||
1125 | 1083 | |||
1126 | 1084 | - g_signal_connect_object (self->priv->geoclue, "location-changed", | ||
1127 | 1085 | - G_CALLBACK (location_changed_cb), self, 0); | ||
1128 | 1086 | + g_signal_connect (G_OBJECT (self->priv->gc_address), "address-changed", | ||
1129 | 1087 | + G_CALLBACK (address_changed_cb), self); | ||
1130 | 1088 | |||
1131 | 1089 | - location = empathy_geoclue_helper_get_location (self->priv->geoclue); | ||
1132 | 1090 | - if (location != NULL) | ||
1133 | 1091 | - update_location (self, location); | ||
1134 | 1092 | + self->priv->geoclue_is_setup = TRUE; | ||
1135 | 1093 | } | ||
1136 | 1094 | |||
1137 | 1095 | static void | ||
1138 | 1096 | -setup_geoclue (EmpathyLocationManager *self) | ||
1139 | 1097 | +create_position_cb (GeoclueMasterClient *client, | ||
1140 | 1098 | + GeocluePosition *position, | ||
1141 | 1099 | + GError *error, | ||
1142 | 1100 | + gpointer userdata) | ||
1143 | 1101 | +{ | ||
1144 | 1102 | + EmpathyLocationManager *self = userdata; | ||
1145 | 1103 | + | ||
1146 | 1104 | + if (error != NULL) | ||
1147 | 1105 | + { | ||
1148 | 1106 | + DEBUG ("Failed to create GeocluePosition: %s", error->message); | ||
1149 | 1107 | + g_error_free (error); | ||
1150 | 1108 | + return; | ||
1151 | 1109 | + } | ||
1152 | 1110 | + | ||
1153 | 1111 | + self->priv->gc_position = position; | ||
1154 | 1112 | + | ||
1155 | 1113 | + g_signal_connect (G_OBJECT (self->priv->gc_position), "position-changed", | ||
1156 | 1114 | + G_CALLBACK (position_changed_cb), self); | ||
1157 | 1115 | + | ||
1158 | 1116 | + /* Get updated when the address changes */ | ||
1159 | 1117 | + geoclue_master_client_create_address_async (self->priv->gc_client, | ||
1160 | 1118 | + create_address_cb, self); | ||
1161 | 1119 | +} | ||
1162 | 1120 | + | ||
1163 | 1121 | +static void | ||
1164 | 1122 | +create_client_set_requirements_cb (GeoclueMasterClient *client, | ||
1165 | 1123 | + GError *error, | ||
1166 | 1124 | + gpointer userdata) | ||
1167 | 1125 | +{ | ||
1168 | 1126 | + EmpathyLocationManager *self = userdata; | ||
1169 | 1127 | + | ||
1170 | 1128 | + if (error != NULL) | ||
1171 | 1129 | + { | ||
1172 | 1130 | + DEBUG ("set_requirements failed: %s", error->message); | ||
1173 | 1131 | + g_error_free (error); | ||
1174 | 1132 | + return; | ||
1175 | 1133 | + } | ||
1176 | 1134 | + | ||
1177 | 1135 | + /* Get updated when the position is changes */ | ||
1178 | 1136 | + geoclue_master_client_create_position_async (self->priv->gc_client, | ||
1179 | 1137 | + create_position_cb, self); | ||
1180 | 1138 | +} | ||
1181 | 1139 | + | ||
1182 | 1140 | +static void | ||
1183 | 1141 | +create_client_cb (GeoclueMaster *master, | ||
1184 | 1142 | + GeoclueMasterClient *client, | ||
1185 | 1143 | + char *object_path, | ||
1186 | 1144 | + GError *error, | ||
1187 | 1145 | + gpointer userdata) | ||
1188 | 1146 | { | ||
1189 | 1147 | - switch (self->priv->geoclue_status) | ||
1190 | 1148 | + EmpathyLocationManager *self = userdata; | ||
1191 | 1149 | + | ||
1192 | 1150 | + if (error != NULL) | ||
1193 | 1151 | { | ||
1194 | 1152 | - case GEOCLUE_NONE: | ||
1195 | 1153 | - g_assert (self->priv->geoclue == NULL); | ||
1196 | 1154 | - self->priv->geoclue_status = GEOCLUE_STARTING; | ||
1197 | 1155 | - empathy_geoclue_helper_new_started_async (0, geoclue_new_cb, self); | ||
1198 | 1156 | - break; | ||
1199 | 1157 | - case GEOCLUE_STARTED: | ||
1200 | 1158 | - case GEOCLUE_STARTING: | ||
1201 | 1159 | - case GEOCLUE_FAILED: | ||
1202 | 1160 | + DEBUG ("Failed to create GeoclueMasterClient: %s", error->message); | ||
1203 | 1161 | + g_error_free (error); | ||
1204 | 1162 | return; | ||
1205 | 1163 | } | ||
1206 | 1164 | + | ||
1207 | 1165 | + /* @client seems be (transfer full) looking at the geoclue code; yeah for | ||
1208 | 1166 | + * undocumented API... */ | ||
1209 | 1167 | + self->priv->gc_client = client; | ||
1210 | 1168 | + | ||
1211 | 1169 | + set_requirements (self, create_client_set_requirements_cb); | ||
1212 | 1170 | } | ||
1213 | 1171 | |||
1214 | 1172 | static void | ||
1215 | 1173 | +setup_geoclue (EmpathyLocationManager *self) | ||
1216 | 1174 | +{ | ||
1217 | 1175 | + GeoclueMaster *master; | ||
1218 | 1176 | + | ||
1219 | 1177 | + DEBUG ("Setting up Geoclue"); | ||
1220 | 1178 | + master = geoclue_master_get_default (); | ||
1221 | 1179 | + | ||
1222 | 1180 | + geoclue_master_create_client_async (master, create_client_cb, self); | ||
1223 | 1181 | + | ||
1224 | 1182 | + g_object_unref (master); | ||
1225 | 1183 | + } | ||
1226 | 1184 | + | ||
1227 | 1185 | +static void | ||
1228 | 1186 | publish_cb (GSettings *gsettings_loc, | ||
1229 | 1187 | const gchar *key, | ||
1230 | 1188 | gpointer user_data) | ||
1231 | 1189 | @@ -352,7 +579,16 @@ publish_cb (GSettings *gsettings_loc, | ||
1232 | 1190 | |||
1233 | 1191 | if (g_settings_get_boolean (gsettings_loc, key)) | ||
1234 | 1192 | { | ||
1235 | 1193 | - setup_geoclue (self); | ||
1236 | 1194 | + if (!self->priv->geoclue_is_setup) | ||
1237 | 1195 | + setup_geoclue (self); | ||
1238 | 1196 | + /* if still not setup than the init failed */ | ||
1239 | 1197 | + if (!self->priv->geoclue_is_setup) | ||
1240 | 1198 | + return; | ||
1241 | 1199 | + | ||
1242 | 1200 | + geoclue_address_get_address_async (self->priv->gc_address, | ||
1243 | 1201 | + initial_address_cb, self); | ||
1244 | 1202 | + geoclue_position_get_position_async (self->priv->gc_position, | ||
1245 | 1203 | + initial_position_cb, self); | ||
1246 | 1204 | } | ||
1247 | 1205 | else | ||
1248 | 1206 | { | ||
1249 | 1207 | @@ -361,10 +597,54 @@ publish_cb (GSettings *gsettings_loc, | ||
1250 | 1208 | */ | ||
1251 | 1209 | g_hash_table_remove_all (self->priv->location); | ||
1252 | 1210 | publish_to_all_connections (self, TRUE); | ||
1253 | 1211 | - | ||
1254 | 1212 | - g_clear_object (&self->priv->geoclue); | ||
1255 | 1213 | - self->priv->geoclue_status = GEOCLUE_NONE; | ||
1256 | 1214 | } | ||
1257 | 1215 | + | ||
1258 | 1216 | +} | ||
1259 | 1217 | + | ||
1260 | 1218 | +static void | ||
1261 | 1219 | +resource_cb (GSettings *gsettings_loc, | ||
1262 | 1220 | + const gchar *key, | ||
1263 | 1221 | + gpointer user_data) | ||
1264 | 1222 | +{ | ||
1265 | 1223 | + EmpathyLocationManager *self = EMPATHY_LOCATION_MANAGER (user_data); | ||
1266 | 1224 | + GeoclueResourceFlags resource = 0; | ||
1267 | 1225 | + | ||
1268 | 1226 | + DEBUG ("%s changed", key); | ||
1269 | 1227 | + | ||
1270 | 1228 | + if (!tp_strdiff (key, EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK)) | ||
1271 | 1229 | + resource = GEOCLUE_RESOURCE_NETWORK; | ||
1272 | 1230 | + if (!tp_strdiff (key, EMPATHY_PREFS_LOCATION_RESOURCE_CELL)) | ||
1273 | 1231 | + resource = GEOCLUE_RESOURCE_CELL; | ||
1274 | 1232 | + if (!tp_strdiff (key, EMPATHY_PREFS_LOCATION_RESOURCE_GPS)) | ||
1275 | 1233 | + resource = GEOCLUE_RESOURCE_GPS; | ||
1276 | 1234 | + | ||
1277 | 1235 | + if (g_settings_get_boolean (gsettings_loc, key)) | ||
1278 | 1236 | + self->priv->resources |= resource; | ||
1279 | 1237 | + else | ||
1280 | 1238 | + self->priv->resources &= ~resource; | ||
1281 | 1239 | + | ||
1282 | 1240 | + if (self->priv->geoclue_is_setup) | ||
1283 | 1241 | + update_resources (self); | ||
1284 | 1242 | +} | ||
1285 | 1243 | + | ||
1286 | 1244 | +static void | ||
1287 | 1245 | +accuracy_cb (GSettings *gsettings_loc, | ||
1288 | 1246 | + const gchar *key, | ||
1289 | 1247 | + gpointer user_data) | ||
1290 | 1248 | +{ | ||
1291 | 1249 | + EmpathyLocationManager *self = EMPATHY_LOCATION_MANAGER (user_data); | ||
1292 | 1250 | + | ||
1293 | 1251 | + DEBUG ("%s changed", key); | ||
1294 | 1252 | + | ||
1295 | 1253 | + self->priv->reduce_accuracy = g_settings_get_boolean (gsettings_loc, key); | ||
1296 | 1254 | + | ||
1297 | 1255 | + if (!self->priv->geoclue_is_setup) | ||
1298 | 1256 | + return; | ||
1299 | 1257 | + | ||
1300 | 1258 | + geoclue_address_get_address_async (self->priv->gc_address, | ||
1301 | 1259 | + initial_address_cb, self); | ||
1302 | 1260 | + geoclue_position_get_position_async (self->priv->gc_position, | ||
1303 | 1261 | + initial_position_cb, self); | ||
1304 | 1262 | } | ||
1305 | 1263 | |||
1306 | 1264 | static void | ||
1307 | 1265 | @@ -402,6 +682,7 @@ empathy_location_manager_init (EmpathyLo | ||
1308 | 1266 | EMPATHY_TYPE_LOCATION_MANAGER, EmpathyLocationManagerPrivate); | ||
1309 | 1267 | |||
1310 | 1268 | self->priv = priv; | ||
1311 | 1269 | + priv->geoclue_is_setup = FALSE; | ||
1312 | 1270 | priv->location = tp_asv_new (NULL, NULL); | ||
1313 | 1271 | priv->gsettings_loc = g_settings_new (EMPATHY_PREFS_LOCATION_SCHEMA); | ||
1314 | 1272 | |||
1315 | 1273 | @@ -415,7 +696,25 @@ empathy_location_manager_init (EmpathyLo | ||
1316 | 1274 | g_signal_connect (priv->gsettings_loc, | ||
1317 | 1275 | "changed::" EMPATHY_PREFS_LOCATION_PUBLISH, | ||
1318 | 1276 | G_CALLBACK (publish_cb), self); | ||
1319 | 1277 | + g_signal_connect (priv->gsettings_loc, | ||
1320 | 1278 | + "changed::" EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK, | ||
1321 | 1279 | + G_CALLBACK (resource_cb), self); | ||
1322 | 1280 | + g_signal_connect (priv->gsettings_loc, | ||
1323 | 1281 | + "changed::" EMPATHY_PREFS_LOCATION_RESOURCE_CELL, | ||
1324 | 1282 | + G_CALLBACK (resource_cb), self); | ||
1325 | 1283 | + g_signal_connect (priv->gsettings_loc, | ||
1326 | 1284 | + "changed::" EMPATHY_PREFS_LOCATION_RESOURCE_GPS, | ||
1327 | 1285 | + G_CALLBACK (resource_cb), self); | ||
1328 | 1286 | + g_signal_connect (priv->gsettings_loc, | ||
1329 | 1287 | + "changed::" EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY, | ||
1330 | 1288 | + G_CALLBACK (accuracy_cb), self); | ||
1331 | 1289 | |||
1332 | 1290 | + resource_cb (priv->gsettings_loc, EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK, | ||
1333 | 1291 | + self); | ||
1334 | 1292 | + resource_cb (priv->gsettings_loc, EMPATHY_PREFS_LOCATION_RESOURCE_CELL, self); | ||
1335 | 1293 | + resource_cb (priv->gsettings_loc, EMPATHY_PREFS_LOCATION_RESOURCE_GPS, self); | ||
1336 | 1294 | + accuracy_cb (priv->gsettings_loc, EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY, | ||
1337 | 1295 | + self); | ||
1338 | 1296 | publish_cb (priv->gsettings_loc, EMPATHY_PREFS_LOCATION_PUBLISH, self); | ||
1339 | 1297 | } | ||
1340 | 1298 | |||
1341 | 1299 | --- empathy-3.12.6.orig/libempathy/empathy-gsettings.h | ||
1342 | 1300 | +++ empathy-3.12.6/libempathy/empathy-gsettings.h | ||
1343 | 1301 | @@ -83,6 +83,9 @@ G_BEGIN_DECLS | ||
1344 | 1302 | |||
1345 | 1303 | #define EMPATHY_PREFS_LOCATION_SCHEMA EMPATHY_PREFS_SCHEMA ".location" | ||
1346 | 1304 | #define EMPATHY_PREFS_LOCATION_PUBLISH "publish" | ||
1347 | 1305 | +#define EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK "resource-network" | ||
1348 | 1306 | +#define EMPATHY_PREFS_LOCATION_RESOURCE_CELL "resource-cell" | ||
1349 | 1307 | +#define EMPATHY_PREFS_LOCATION_RESOURCE_GPS "resource-gps" | ||
1350 | 1308 | #define EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY "reduce-accuracy" | ||
1351 | 1309 | |||
1352 | 1310 | #define EMPATHY_PREFS_LOGGER_SCHEMA "org.freedesktop.Telepathy.Logger" | ||
1353 | 1311 | --- empathy-3.12.6.orig/src/empathy-preferences.c | ||
1354 | 1312 | +++ empathy-3.12.6/src/empathy-preferences.c | ||
1355 | 1313 | @@ -191,6 +191,12 @@ preferences_setup_widgets (EmpathyPrefer | ||
1356 | 1314 | |||
1357 | 1315 | BIND_ACTIVE (loc, LOCATION_PUBLISH, | ||
1358 | 1316 | "checkbutton_location_publish"); | ||
1359 | 1317 | + BIND_ACTIVE (loc, LOCATION_RESOURCE_NETWORK, | ||
1360 | 1318 | + "checkbutton_location_resource_network"); | ||
1361 | 1319 | + BIND_ACTIVE (loc, LOCATION_RESOURCE_CELL, | ||
1362 | 1320 | + "checkbutton_location_resource_cell"); | ||
1363 | 1321 | + BIND_ACTIVE (loc, LOCATION_RESOURCE_GPS, | ||
1364 | 1322 | + "checkbutton_location_resource_gps"); | ||
1365 | 1323 | BIND_ACTIVE (loc, LOCATION_REDUCE_ACCURACY, | ||
1366 | 1324 | "checkbutton_location_reduce_accuracy"); | ||
1367 | 1325 | |||
1368 | 1326 | --- empathy-3.12.6.orig/src/empathy-preferences.ui | ||
1369 | 1327 | +++ empathy-3.12.6/src/empathy-preferences.ui | ||
1370 | 1328 | @@ -833,6 +833,94 @@ | ||
1371 | 1329 | <property name="position">1</property> | ||
1372 | 1330 | </packing> | ||
1373 | 1331 | </child> | ||
1374 | 1332 | + <child> | ||
1375 | 1333 | + <object class="GtkFrame" id="frame5"> | ||
1376 | 1334 | + <property name="visible">True</property> | ||
1377 | 1335 | + <property name="can_focus">False</property> | ||
1378 | 1336 | + <property name="label_xalign">0</property> | ||
1379 | 1337 | + <property name="shadow_type">none</property> | ||
1380 | 1338 | + <child> | ||
1381 | 1339 | + <object class="GtkAlignment" id="alignment4"> | ||
1382 | 1340 | + <property name="visible">True</property> | ||
1383 | 1341 | + <property name="can_focus">False</property> | ||
1384 | 1342 | + <property name="top_padding">6</property> | ||
1385 | 1343 | + <property name="left_padding">12</property> | ||
1386 | 1344 | + <child> | ||
1387 | 1345 | + <object class="GtkBox" id="vbox5"> | ||
1388 | 1346 | + <property name="visible">True</property> | ||
1389 | 1347 | + <property name="can_focus">False</property> | ||
1390 | 1348 | + <property name="orientation">vertical</property> | ||
1391 | 1349 | + <child> | ||
1392 | 1350 | + <object class="GtkCheckButton" id="checkbutton_location_resource_gps"> | ||
1393 | 1351 | + <property name="label" translatable="yes">_GPS</property> | ||
1394 | 1352 | + <property name="visible">True</property> | ||
1395 | 1353 | + <property name="can_focus">True</property> | ||
1396 | 1354 | + <property name="receives_default">False</property> | ||
1397 | 1355 | + <property name="use_action_appearance">False</property> | ||
1398 | 1356 | + <property name="use_underline">True</property> | ||
1399 | 1357 | + <property name="draw_indicator">True</property> | ||
1400 | 1358 | + </object> | ||
1401 | 1359 | + <packing> | ||
1402 | 1360 | + <property name="expand">False</property> | ||
1403 | 1361 | + <property name="fill">False</property> | ||
1404 | 1362 | + <property name="position">0</property> | ||
1405 | 1363 | + </packing> | ||
1406 | 1364 | + </child> | ||
1407 | 1365 | + <child> | ||
1408 | 1366 | + <object class="GtkCheckButton" id="checkbutton_location_resource_cell"> | ||
1409 | 1367 | + <property name="label" translatable="yes">_Cellphone</property> | ||
1410 | 1368 | + <property name="visible">True</property> | ||
1411 | 1369 | + <property name="can_focus">True</property> | ||
1412 | 1370 | + <property name="receives_default">False</property> | ||
1413 | 1371 | + <property name="use_action_appearance">False</property> | ||
1414 | 1372 | + <property name="use_underline">True</property> | ||
1415 | 1373 | + <property name="active">True</property> | ||
1416 | 1374 | + <property name="draw_indicator">True</property> | ||
1417 | 1375 | + </object> | ||
1418 | 1376 | + <packing> | ||
1419 | 1377 | + <property name="expand">False</property> | ||
1420 | 1378 | + <property name="fill">False</property> | ||
1421 | 1379 | + <property name="position">1</property> | ||
1422 | 1380 | + </packing> | ||
1423 | 1381 | + </child> | ||
1424 | 1382 | + <child> | ||
1425 | 1383 | + <object class="GtkCheckButton" id="checkbutton_location_resource_network"> | ||
1426 | 1384 | + <property name="label" translatable="yes">_Network (IP, Wi-Fi)</property> | ||
1427 | 1385 | + <property name="visible">True</property> | ||
1428 | 1386 | + <property name="can_focus">True</property> | ||
1429 | 1387 | + <property name="receives_default">False</property> | ||
1430 | 1388 | + <property name="use_action_appearance">False</property> | ||
1431 | 1389 | + <property name="use_underline">True</property> | ||
1432 | 1390 | + <property name="active">True</property> | ||
1433 | 1391 | + <property name="draw_indicator">True</property> | ||
1434 | 1392 | + </object> | ||
1435 | 1393 | + <packing> | ||
1436 | 1394 | + <property name="expand">False</property> | ||
1437 | 1395 | + <property name="fill">False</property> | ||
1438 | 1396 | + <property name="position">2</property> | ||
1439 | 1397 | + </packing> | ||
1440 | 1398 | + </child> | ||
1441 | 1399 | + </object> | ||
1442 | 1400 | + </child> | ||
1443 | 1401 | + </object> | ||
1444 | 1402 | + </child> | ||
1445 | 1403 | + <child type="label"> | ||
1446 | 1404 | + <object class="GtkLabel" id="label5"> | ||
1447 | 1405 | + <property name="visible">True</property> | ||
1448 | 1406 | + <property name="can_focus">False</property> | ||
1449 | 1407 | + <property name="label" translatable="yes">Location sources:</property> | ||
1450 | 1408 | + <attributes> | ||
1451 | 1409 | + <attribute name="weight" value="bold"/> | ||
1452 | 1410 | + </attributes> | ||
1453 | 1411 | + </object> | ||
1454 | 1412 | + </child> | ||
1455 | 1413 | + </object> | ||
1456 | 1414 | + <packing> | ||
1457 | 1415 | + <property name="expand">False</property> | ||
1458 | 1416 | + <property name="fill">True</property> | ||
1459 | 1417 | + <property name="position">2</property> | ||
1460 | 1418 | + </packing> | ||
1461 | 1419 | + </child> | ||
1462 | 1420 | </object> | ||
1463 | 1421 | <packing> | ||
1464 | 1422 | <property name="position">4</property> | ||
1465 | 1423 | 0 | ||
1466 | === modified file 'debian/patches/series' | |||
1467 | --- debian/patches/series 2014-09-24 08:32:39 +0000 | |||
1468 | +++ debian/patches/series 2014-11-08 20:15:08 +0000 | |||
1469 | @@ -8,4 +8,3 @@ | |||
1470 | 8 | 42_shell_running.patch | 8 | 42_shell_running.patch |
1471 | 9 | 43_quicklists.patch | 9 | 43_quicklists.patch |
1472 | 10 | ubuntu_launch_uoa_panel.patch | 10 | ubuntu_launch_uoa_panel.patch |
1473 | 11 | Revert-geoclue-2.0.patch |
Thanks, but what about the fact that geoclue doesn't support plugin and can't use ubuntu-geoip? What difference would that mean in the user experience?