]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-location-manager.c
Merge branch 'gnome-3-8'
[empathy.git] / libempathy-gtk / empathy-location-manager.c
index ec7810f7d597b15ffc164dc6ae4bcff3846b3226..3a97c94cf49009b50dcd5f48e0fd00447c3441da 100644 (file)
  */
 
 #include "config.h"
-
-#include <string.h>
-#include <time.h>
-
-#include <glib/gi18n-lib.h>
-
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/util.h>
+#include "empathy-location-manager.h"
 
 #include <geoclue/geoclue-master.h>
 
-#include <extensions/extensions.h>
-
-#include "empathy-location-manager.h"
-
-#include "libempathy/empathy-enum-types.h"
-#include "libempathy/empathy-gsettings.h"
-#include "libempathy/empathy-location.h"
-#include "libempathy/empathy-utils.h"
-#include "libempathy/empathy-time.h"
+#include "empathy-gsettings.h"
+#include "empathy-location.h"
+#include "empathy-time.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_LOCATION
-#include "libempathy/empathy-debug.h"
+#include "empathy-debug.h"
 
 /* Seconds before updating the location */
 #define TIMEOUT 10
@@ -189,7 +176,7 @@ publish_to_all_am_prepared_cb (GObject *source_object,
       goto out;
     }
 
-  accounts = tp_account_manager_get_valid_accounts (manager);
+  accounts = tp_account_manager_dup_valid_accounts (manager);
   for (l = accounts; l; l = l->next)
     {
       TpConnection *conn = tp_account_get_connection (TP_ACCOUNT (l->data));
@@ -197,7 +184,7 @@ publish_to_all_am_prepared_cb (GObject *source_object,
       if (conn != NULL)
         publish_location (data->self, conn, data->force_publication);
     }
-  g_list_free (accounts);
+  g_list_free_full (accounts, g_object_unref);
 
 out:
   g_object_unref (data->self);
@@ -452,6 +439,7 @@ update_resources_set_requirements_cb (GeoclueMasterClient *client,
   if (error != NULL)
     {
       DEBUG ("set_requirements failed: %s", error->message);
+      g_error_free (error);
       return;
     }
 
@@ -476,7 +464,8 @@ update_resources (EmpathyLocationManager *self)
 }
 
 static void
-create_client_set_requirements_cb (GeoclueMasterClient *client,
+create_address_cb (GeoclueMasterClient *client,
+    GeoclueAddress *address,
     GError *error,
     gpointer userdata)
 {
@@ -484,37 +473,61 @@ create_client_set_requirements_cb (GeoclueMasterClient *client,
 
   if (error != NULL)
     {
-      DEBUG ("set_requirements failed: %s", error->message);
+      DEBUG ("Failed to create GeoclueAddress: %s", error->message);
+      g_error_free (error);
       return;
     }
 
-  /* Get updated when the position is changes */
-  self->priv->gc_position = geoclue_master_client_create_position (
-      self->priv->gc_client, &error);
-  if (self->priv->gc_position == NULL)
+  self->priv->gc_address = address;
+
+  g_signal_connect (G_OBJECT (self->priv->gc_address), "address-changed",
+      G_CALLBACK (address_changed_cb), self);
+
+  self->priv->geoclue_is_setup = TRUE;
+}
+
+static void
+create_position_cb (GeoclueMasterClient *client,
+    GeocluePosition *position,
+    GError *error,
+    gpointer userdata)
+{
+  EmpathyLocationManager *self = userdata;
+
+  if (error != NULL)
     {
       DEBUG ("Failed to create GeocluePosition: %s", error->message);
       g_error_free (error);
       return;
     }
 
+  self->priv->gc_position = position;
+
   g_signal_connect (G_OBJECT (self->priv->gc_position), "position-changed",
       G_CALLBACK (position_changed_cb), self);
 
   /* Get updated when the address changes */
-  self->priv->gc_address = geoclue_master_client_create_address (
-      self->priv->gc_client, &error);
-  if (self->priv->gc_address == NULL)
+  geoclue_master_client_create_address_async (self->priv->gc_client,
+      create_address_cb, self);
+}
+
+static void
+create_client_set_requirements_cb (GeoclueMasterClient *client,
+    GError *error,
+    gpointer userdata)
+{
+  EmpathyLocationManager *self = userdata;
+
+  if (error != NULL)
     {
-      DEBUG ("Failed to create GeoclueAddress: %s", error->message);
+      DEBUG ("set_requirements failed: %s", error->message);
       g_error_free (error);
       return;
     }
 
-  g_signal_connect (G_OBJECT (self->priv->gc_address), "address-changed",
-      G_CALLBACK (address_changed_cb), self);
-
-  self->priv->geoclue_is_setup = TRUE;
+  /* Get updated when the position is changes */
+  geoclue_master_client_create_position_async (self->priv->gc_client,
+      create_position_cb, self);
 }
 
 static void
@@ -529,6 +542,7 @@ create_client_cb (GeoclueMaster *master,
   if (error != NULL)
     {
       DEBUG ("Failed to create GeoclueMasterClient: %s", error->message);
+      g_error_free (error);
       return;
     }
 
@@ -648,7 +662,7 @@ account_manager_prepared_cb (GObject *source_object,
       return;
     }
 
-  accounts = tp_account_manager_get_valid_accounts (account_manager);
+  accounts = tp_account_manager_dup_valid_accounts (account_manager);
   for (l = accounts; l != NULL; l = l->next)
     {
       TpAccount *account = TP_ACCOUNT (l->data);
@@ -656,7 +670,7 @@ account_manager_prepared_cb (GObject *source_object,
       tp_g_signal_connect_object (account, "status-changed",
           G_CALLBACK (new_connection_cb), self, 0);
     }
-  g_list_free (accounts);
+  g_list_free_full (accounts, g_object_unref);
 }
 
 static void