]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-location-manager.c
add myself to AUTHORS
[empathy.git] / libempathy-gtk / empathy-location-manager.c
1 /*
2  * Copyright (C) 2009 Collabora Ltd.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA  02110-1301  USA
18  *
19  * Authors: Pierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>
20  */
21
22 #include "config.h"
23
24 #include <string.h>
25 #include <time.h>
26
27 #include <glib/gi18n.h>
28
29 #include <telepathy-glib/account-manager.h>
30 #include <telepathy-glib/util.h>
31
32 #include <geoclue/geoclue-master.h>
33
34 #include <extensions/extensions.h>
35
36 #include "empathy-location-manager.h"
37 #include "empathy-conf.h"
38
39 #include "libempathy/empathy-enum-types.h"
40 #include "libempathy/empathy-location.h"
41 #include "libempathy/empathy-tp-contact-factory.h"
42 #include "libempathy/empathy-utils.h"
43
44 #define DEBUG_FLAG EMPATHY_DEBUG_LOCATION
45 #include "libempathy/empathy-debug.h"
46
47 /* Seconds before updating the location */
48 #define TIMEOUT 10
49 static EmpathyLocationManager *location_manager = NULL;
50
51 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyLocationManager)
52 typedef struct {
53     gboolean geoclue_is_setup;
54     /* Contains the location to be sent to accounts.  Geoclue is used
55      * to populate it.  This HashTable uses Telepathy's style (string,
56      * GValue). Keys are defined in empathy-location.h
57      */
58     GHashTable *location;
59
60     GeoclueResourceFlags resources;
61     GeoclueMasterClient *gc_client;
62     GeocluePosition *gc_position;
63     GeoclueAddress *gc_address;
64
65     gboolean reduce_accuracy;
66     TpAccountManager *account_manager;
67
68     /* The idle id for publish_on_idle func */
69     guint timeout_id;
70 } EmpathyLocationManagerPriv;
71
72 G_DEFINE_TYPE (EmpathyLocationManager, empathy_location_manager, G_TYPE_OBJECT);
73
74 static GObject *
75 location_manager_constructor (GType type,
76     guint n_construct_params,
77     GObjectConstructParam *construct_params)
78 {
79   GObject *retval;
80
81   if (location_manager == NULL)
82     {
83       retval = G_OBJECT_CLASS (empathy_location_manager_parent_class)->constructor
84           (type, n_construct_params, construct_params);
85
86       location_manager = EMPATHY_LOCATION_MANAGER (retval);
87       g_object_add_weak_pointer (retval, (gpointer) &location_manager);
88     }
89   else
90     {
91       retval = g_object_ref (location_manager);
92     }
93
94   return retval;
95 }
96
97 static void
98 location_manager_dispose (GObject *object)
99 {
100   EmpathyLocationManagerPriv *priv = GET_PRIV (object);
101
102   if (priv->account_manager != NULL)
103   {
104     g_object_unref (priv->account_manager);
105     priv->account_manager = NULL;
106   }
107
108   if (priv->gc_client != NULL)
109   {
110     g_object_unref (priv->gc_client);
111     priv->gc_client = NULL;
112   }
113
114   if (priv->gc_position != NULL)
115   {
116     g_object_unref (priv->gc_position);
117     priv->gc_position = NULL;
118   }
119
120   if (priv->gc_address != NULL)
121   {
122     g_object_unref (priv->gc_address);
123     priv->gc_address = NULL;
124   }
125
126   if (priv->location != NULL)
127   {
128     g_hash_table_unref (priv->location);
129     priv->location = NULL;
130   }
131
132   G_OBJECT_CLASS (empathy_location_manager_parent_class)->finalize (object);
133 }
134
135 static void
136 location_manager_get_property (GObject *object,
137                       guint param_id,
138                       GValue *value,
139                       GParamSpec *pspec)
140 {
141   /*EmpathyLocationManagerPriv *priv = GET_PRIV (object); */
142
143   switch (param_id)
144     {
145       default:
146         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
147         break;
148     };
149 }
150
151 static void
152 location_manager_set_property (GObject *object,
153                       guint param_id,
154                       const GValue *value,
155                       GParamSpec *pspec)
156 {
157   /* EmpathyLocationManagerPriv *priv = GET_PRIV (object); */
158
159   switch (param_id)
160     {
161       default:
162         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
163         break;
164     };
165 }
166
167 static void
168 empathy_location_manager_class_init (EmpathyLocationManagerClass *class)
169 {
170   GObjectClass *object_class;
171
172   object_class = G_OBJECT_CLASS (class);
173
174   object_class->constructor = location_manager_constructor;
175   object_class->dispose = location_manager_dispose;
176   object_class->get_property = location_manager_get_property;
177   object_class->set_property = location_manager_set_property;
178
179   g_type_class_add_private (object_class, sizeof (EmpathyLocationManagerPriv));
180 }
181
182 static void
183 publish_location (EmpathyLocationManager *self,
184     TpConnection *conn,
185     gboolean force_publication)
186 {
187   EmpathyLocationManagerPriv *priv = GET_PRIV (self);
188   guint connection_status = -1;
189   gboolean can_publish;
190   EmpathyConf *conf = empathy_conf_get ();
191   EmpathyTpContactFactory *factory;
192
193   if (!conn)
194     return;
195
196   if (!force_publication)
197     {
198       if (!empathy_conf_get_bool (conf, EMPATHY_PREFS_LOCATION_PUBLISH,
199             &can_publish))
200         return;
201
202       if (!can_publish)
203         return;
204     }
205
206   connection_status = tp_connection_get_status (conn, NULL);
207
208   if (connection_status != TP_CONNECTION_STATUS_CONNECTED)
209     return;
210
211   DEBUG ("Publishing %s location to connection %p",
212       (g_hash_table_size (priv->location) == 0 ? "empty" : ""),
213       conn);
214
215   factory = empathy_tp_contact_factory_dup_singleton (conn);
216   empathy_tp_contact_factory_set_location (factory, priv->location);
217   g_object_unref (factory);
218 }
219
220 typedef struct
221 {
222   EmpathyLocationManager *self;
223   gboolean force_publication;
224 } PublishToAllData;
225
226 static void
227 publish_to_all_am_prepared_cb (GObject *source_object,
228     GAsyncResult *result,
229     gpointer user_data)
230 {
231   TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
232   PublishToAllData *data = user_data;
233   GList *accounts, *l;
234   GError *error = NULL;
235
236   if (!tp_account_manager_prepare_finish (manager, result, &error))
237     {
238       DEBUG ("Failed to prepare account manager: %s", error->message);
239       g_error_free (error);
240       goto out;
241     }
242
243   accounts = tp_account_manager_get_valid_accounts (manager);
244   for (l = accounts; l; l = l->next)
245     {
246       TpConnection *conn = tp_account_get_connection (TP_ACCOUNT (l->data));
247
248       if (conn != NULL)
249         publish_location (data->self, conn, data->force_publication);
250     }
251   g_list_free (accounts);
252
253 out:
254   g_object_unref (data->self);
255   g_slice_free (PublishToAllData, data);
256 }
257
258 static void
259 publish_to_all_connections (EmpathyLocationManager *self,
260     gboolean force_publication)
261 {
262   EmpathyLocationManagerPriv *priv = GET_PRIV (self);
263   PublishToAllData *data;
264
265   data = g_slice_new0 (PublishToAllData);
266   data->self = g_object_ref (self);
267   data->force_publication = force_publication;
268
269   tp_account_manager_prepare_async (priv->account_manager, NULL,
270       publish_to_all_am_prepared_cb, data);
271 }
272
273 static gboolean
274 publish_on_idle (gpointer user_data)
275 {
276   EmpathyLocationManager *manager = EMPATHY_LOCATION_MANAGER (user_data);
277   EmpathyLocationManagerPriv *priv = GET_PRIV (manager);
278
279   priv->timeout_id = 0;
280   publish_to_all_connections (manager, TRUE);
281   return FALSE;
282 }
283
284 static void
285 new_connection_cb (TpAccount *account,
286     guint old_status,
287     guint new_status,
288     guint reason,
289     gchar *dbus_error_name,
290     GHashTable *details,
291     gpointer *self)
292 {
293   EmpathyLocationManagerPriv *priv = GET_PRIV (self);
294   TpConnection *conn;
295
296   conn = tp_account_get_connection (account);
297
298   DEBUG ("New connection %p", conn);
299
300   /* Don't publish if it is already planned (ie startup) */
301   if (priv->timeout_id == 0)
302     {
303       publish_location (EMPATHY_LOCATION_MANAGER (self), conn,
304           FALSE);
305     }
306 }
307
308 static void
309 update_timestamp (EmpathyLocationManager *self)
310 {
311   EmpathyLocationManagerPriv *priv= GET_PRIV (self);
312   GValue *new_value;
313   gint64 stamp64;
314   time_t timestamp;
315
316   timestamp = time (NULL);
317   stamp64 = (gint64) timestamp;
318   new_value = tp_g_value_slice_new_int64 (stamp64);
319   g_hash_table_insert (priv->location, g_strdup (EMPATHY_LOCATION_TIMESTAMP),
320       new_value);
321   DEBUG ("\t - Timestamp: %" G_GINT64_FORMAT, stamp64);
322 }
323
324 static void
325 address_changed_cb (GeoclueAddress *address,
326                     int timestamp,
327                     GHashTable *details,
328                     GeoclueAccuracy *accuracy,
329                     gpointer self)
330 {
331   GeoclueAccuracyLevel level;
332   EmpathyLocationManagerPriv *priv = GET_PRIV (self);
333   GHashTableIter iter;
334   gpointer key, value;
335
336   geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
337   DEBUG ("New address (accuracy level %d):", level);
338   /* FIXME: Publish accuracy level also considering the position's */
339
340   g_hash_table_remove (priv->location, EMPATHY_LOCATION_STREET);
341   g_hash_table_remove (priv->location, EMPATHY_LOCATION_AREA);
342   g_hash_table_remove (priv->location, EMPATHY_LOCATION_REGION);
343   g_hash_table_remove (priv->location, EMPATHY_LOCATION_COUNTRY);
344   g_hash_table_remove (priv->location, EMPATHY_LOCATION_COUNTRY_CODE);
345   g_hash_table_remove (priv->location, EMPATHY_LOCATION_POSTAL_CODE);
346
347   if (g_hash_table_size (details) == 0)
348     {
349       DEBUG ("\t - (Empty)");
350       return;
351     }
352
353   g_hash_table_iter_init (&iter, details);
354   while (g_hash_table_iter_next (&iter, &key, &value))
355     {
356       GValue *new_value;
357       /* Discard street information if reduced accuracy is on */
358       if (priv->reduce_accuracy &&
359           !tp_strdiff (key, EMPATHY_LOCATION_STREET))
360         continue;
361
362       new_value = tp_g_value_slice_new_string (value);
363       g_hash_table_insert (priv->location, g_strdup (key), new_value);
364
365       DEBUG ("\t - %s: %s", (gchar *) key, (gchar *) value);
366     }
367
368   update_timestamp (self);
369   if (priv->timeout_id == 0)
370     priv->timeout_id = g_timeout_add_seconds (TIMEOUT, publish_on_idle, self);
371 }
372
373 static void
374 initial_address_cb (GeoclueAddress *address,
375                     int timestamp,
376                     GHashTable *details,
377                     GeoclueAccuracy *accuracy,
378                     GError *error,
379                     gpointer self)
380 {
381   if (error)
382     {
383       DEBUG ("Error: %s", error->message);
384       g_error_free (error);
385     }
386   else
387     {
388       address_changed_cb (address, timestamp, details, accuracy, self);
389     }
390 }
391
392 static void
393 position_changed_cb (GeocluePosition *position,
394                      GeocluePositionFields fields,
395                      int timestamp,
396                      double latitude,
397                      double longitude,
398                      double altitude,
399                      GeoclueAccuracy *accuracy,
400                      gpointer self)
401 {
402   EmpathyLocationManagerPriv *priv = GET_PRIV (self);
403   GeoclueAccuracyLevel level;
404   gdouble mean, horizontal, vertical;
405   GValue *new_value;
406
407
408   geoclue_accuracy_get_details (accuracy, &level, &horizontal, &vertical);
409   DEBUG ("New position (accuracy level %d)", level);
410   if (level == GEOCLUE_ACCURACY_LEVEL_NONE)
411     return;
412
413   if (fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)
414     {
415
416       if (priv->reduce_accuracy)
417         /* Truncate at 1 decimal place */
418         longitude = ((int) (longitude * 10)) / 10.0;
419
420       new_value = tp_g_value_slice_new_double (longitude);
421       g_hash_table_insert (priv->location, g_strdup (EMPATHY_LOCATION_LON),
422           new_value);
423       DEBUG ("\t - Longitude: %f", longitude);
424     }
425   else
426     {
427       g_hash_table_remove (priv->location, EMPATHY_LOCATION_LON);
428     }
429
430   if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE)
431     {
432       if (priv->reduce_accuracy)
433         /* Truncate at 1 decimal place */
434         latitude = ((int) (latitude * 10)) / 10.0;
435
436       new_value = tp_g_value_slice_new_double (latitude);
437       g_hash_table_replace (priv->location, g_strdup (EMPATHY_LOCATION_LAT),
438           new_value);
439       DEBUG ("\t - Latitude: %f", latitude);
440     }
441   else
442     {
443       g_hash_table_remove (priv->location, EMPATHY_LOCATION_LAT);
444     }
445
446   if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE)
447     {
448       new_value = tp_g_value_slice_new_double (altitude);
449       g_hash_table_replace (priv->location, g_strdup (EMPATHY_LOCATION_ALT),
450           new_value);
451       DEBUG ("\t - Altitude: %f", altitude);
452     }
453   else
454     {
455       g_hash_table_remove (priv->location, EMPATHY_LOCATION_ALT);
456     }
457
458   if (level == GEOCLUE_ACCURACY_LEVEL_DETAILED)
459     {
460       mean = (horizontal + vertical) / 2.0;
461       new_value = tp_g_value_slice_new_double (mean);
462       g_hash_table_replace (priv->location,
463           g_strdup (EMPATHY_LOCATION_ACCURACY), new_value);
464       DEBUG ("\t - Accuracy: %f", mean);
465     }
466   else
467     {
468       g_hash_table_remove (priv->location, EMPATHY_LOCATION_ACCURACY);
469     }
470
471   update_timestamp (self);
472   if (priv->timeout_id == 0)
473     priv->timeout_id = g_timeout_add_seconds (TIMEOUT, publish_on_idle, self);
474 }
475
476 static void
477 initial_position_cb (GeocluePosition *position,
478                      GeocluePositionFields fields,
479                      int timestamp,
480                      double latitude,
481                      double longitude,
482                      double altitude,
483                      GeoclueAccuracy *accuracy,
484                      GError *error,
485                      gpointer self)
486 {
487   if (error)
488     {
489       DEBUG ("Error: %s", error->message);
490       g_error_free (error);
491     }
492   else
493     {
494       position_changed_cb (position, fields, timestamp, latitude, longitude,
495           altitude, accuracy, self);
496     }
497 }
498
499 static void
500 update_resources (EmpathyLocationManager *self)
501 {
502   EmpathyLocationManagerPriv *priv = GET_PRIV (self);
503
504   DEBUG ("Updating resources %d", priv->resources);
505
506   if (!priv->geoclue_is_setup)
507     return;
508
509   /* As per Geoclue bug #15126, using NONE results in no address
510    * being found as geoclue-manual report an empty address with
511    * accuracy = NONE */
512   if (!geoclue_master_client_set_requirements (priv->gc_client,
513           GEOCLUE_ACCURACY_LEVEL_COUNTRY, 0, TRUE, priv->resources,
514           NULL))
515     {
516       DEBUG ("set_requirements failed");
517       return;
518     }
519
520   geoclue_address_get_address_async (priv->gc_address,
521       initial_address_cb, self);
522   geoclue_position_get_position_async (priv->gc_position,
523       initial_position_cb, self);
524 }
525
526 static void
527 setup_geoclue (EmpathyLocationManager *self)
528 {
529   EmpathyLocationManagerPriv *priv = GET_PRIV (self);
530
531   GeoclueMaster *master;
532   GError *error = NULL;
533
534   DEBUG ("Setting up Geoclue");
535   master = geoclue_master_get_default ();
536   priv->gc_client = geoclue_master_create_client (master, NULL, &error);
537   g_object_unref (master);
538
539   if (priv->gc_client == NULL)
540     {
541       DEBUG ("Failed to GeoclueMasterClient: %s", error->message);
542       g_error_free (error);
543       return;
544     }
545
546   update_resources (self);
547
548   /* Get updated when the position is changes */
549   priv->gc_position = geoclue_master_client_create_position (
550       priv->gc_client, &error);
551   if (priv->gc_position == NULL)
552     {
553       DEBUG ("Failed to create GeocluePosition: %s", error->message);
554       g_error_free (error);
555       return;
556     }
557
558   g_signal_connect (G_OBJECT (priv->gc_position), "position-changed",
559       G_CALLBACK (position_changed_cb), self);
560
561   /* Get updated when the address changes */
562   priv->gc_address = geoclue_master_client_create_address (
563       priv->gc_client, &error);
564   if (priv->gc_address == NULL)
565     {
566       DEBUG ("Failed to create GeoclueAddress: %s", error->message);
567       g_error_free (error);
568       return;
569     }
570
571   g_signal_connect (G_OBJECT (priv->gc_address), "address-changed",
572       G_CALLBACK (address_changed_cb), self);
573
574   priv->geoclue_is_setup = TRUE;
575 }
576
577 static void
578 publish_cb (EmpathyConf *conf,
579             const gchar *key,
580             gpointer user_data)
581 {
582   EmpathyLocationManager *manager = EMPATHY_LOCATION_MANAGER (user_data);
583   EmpathyLocationManagerPriv *priv = GET_PRIV (manager);
584   gboolean can_publish;
585
586   DEBUG ("Publish Conf changed");
587
588
589   if (!empathy_conf_get_bool (conf, key, &can_publish))
590     return;
591
592   if (can_publish)
593     {
594       if (!priv->geoclue_is_setup)
595         setup_geoclue (manager);
596       /* if still not setup than the init failed */
597       if (!priv->geoclue_is_setup)
598         return;
599
600       geoclue_address_get_address_async (priv->gc_address,
601           initial_address_cb, manager);
602       geoclue_position_get_position_async (priv->gc_position,
603           initial_position_cb, manager);
604     }
605   else
606     {
607       /* As per XEP-0080: send an empty location to have remove current
608        * location from the servers
609        */
610       g_hash_table_remove_all (priv->location);
611       publish_to_all_connections (manager, TRUE);
612     }
613
614 }
615
616 static void
617 resource_cb (EmpathyConf  *conf,
618              const gchar *key,
619              gpointer user_data)
620 {
621   EmpathyLocationManager *manager = EMPATHY_LOCATION_MANAGER (user_data);
622   EmpathyLocationManagerPriv *priv = GET_PRIV (manager);
623   GeoclueResourceFlags resource = 0;
624   gboolean resource_enabled;
625
626   DEBUG ("%s changed", key);
627
628   if (!empathy_conf_get_bool (conf, key, &resource_enabled))
629     return;
630
631   if (!tp_strdiff (key, EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK))
632     resource = GEOCLUE_RESOURCE_NETWORK;
633   if (!tp_strdiff (key, EMPATHY_PREFS_LOCATION_RESOURCE_CELL))
634     resource = GEOCLUE_RESOURCE_CELL;
635   if (!tp_strdiff (key, EMPATHY_PREFS_LOCATION_RESOURCE_GPS))
636     resource = GEOCLUE_RESOURCE_GPS;
637
638   if (resource_enabled)
639     priv->resources |= resource;
640   else
641     priv->resources &= ~resource;
642
643   if (priv->geoclue_is_setup)
644     update_resources (manager);
645 }
646
647 static void
648 accuracy_cb (EmpathyConf  *conf,
649              const gchar *key,
650              gpointer user_data)
651 {
652   EmpathyLocationManager *manager = EMPATHY_LOCATION_MANAGER (user_data);
653   EmpathyLocationManagerPriv *priv = GET_PRIV (manager);
654
655   gboolean enabled;
656
657   DEBUG ("%s changed", key);
658
659   if (!empathy_conf_get_bool (conf, key, &enabled))
660     return;
661   priv->reduce_accuracy = enabled;
662
663   if (!priv->geoclue_is_setup)
664     return;
665
666   geoclue_address_get_address_async (priv->gc_address,
667       initial_address_cb, manager);
668   geoclue_position_get_position_async (priv->gc_position,
669       initial_position_cb, manager);
670 }
671
672 static void
673 account_manager_prepared_cb (GObject *source_object,
674     GAsyncResult *result,
675     gpointer user_data)
676 {
677   GList *accounts, *l;
678   TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
679   EmpathyLocationManager *self = user_data;
680   GError *error = NULL;
681
682   if (!tp_account_manager_prepare_finish (account_manager, result, &error))
683     {
684       DEBUG ("Failed to prepare account manager: %s", error->message);
685       g_error_free (error);
686       return;
687     }
688
689   accounts = tp_account_manager_get_valid_accounts (account_manager);
690   for (l = accounts; l != NULL; l = l->next)
691     {
692       TpAccount *account = TP_ACCOUNT (l->data);
693
694       empathy_signal_connect_weak (account, "status-changed",
695           G_CALLBACK (new_connection_cb), G_OBJECT (self));
696     }
697   g_list_free (accounts);
698 }
699
700 static void
701 empathy_location_manager_init (EmpathyLocationManager *self)
702 {
703   EmpathyConf               *conf;
704   EmpathyLocationManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
705       EMPATHY_TYPE_LOCATION_MANAGER, EmpathyLocationManagerPriv);
706
707   self->priv = priv;
708   priv->geoclue_is_setup = FALSE;
709   priv->location = g_hash_table_new_full (g_direct_hash, g_direct_equal,
710       g_free, (GDestroyNotify) tp_g_value_slice_free);
711
712   /* Setup account status callbacks */
713   priv->account_manager = tp_account_manager_dup ();
714
715   tp_account_manager_prepare_async (priv->account_manager, NULL,
716       account_manager_prepared_cb, self);
717
718   /* Setup settings status callbacks */
719   conf = empathy_conf_get ();
720   empathy_conf_notify_add (conf, EMPATHY_PREFS_LOCATION_PUBLISH, publish_cb,
721       self);
722   empathy_conf_notify_add (conf, EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK,
723       resource_cb, self);
724   empathy_conf_notify_add (conf, EMPATHY_PREFS_LOCATION_RESOURCE_CELL,
725       resource_cb, self);
726   empathy_conf_notify_add (conf, EMPATHY_PREFS_LOCATION_RESOURCE_GPS,
727       resource_cb, self);
728   empathy_conf_notify_add (conf, EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY,
729       accuracy_cb, self);
730
731   resource_cb (conf, EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK, self);
732   resource_cb (conf, EMPATHY_PREFS_LOCATION_RESOURCE_CELL, self);
733   resource_cb (conf, EMPATHY_PREFS_LOCATION_RESOURCE_GPS, self);
734   accuracy_cb (conf, EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY, self);
735   publish_cb (conf, EMPATHY_PREFS_LOCATION_PUBLISH, self);
736 }
737
738 EmpathyLocationManager *
739 empathy_location_manager_dup_singleton (void)
740 {
741   return EMPATHY_LOCATION_MANAGER (g_object_new (EMPATHY_TYPE_LOCATION_MANAGER,
742       NULL));
743 }