]> git.0d.be Git - empathy.git/commitdiff
Merge commit 'jtellier/reconnect-account'
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 27 Aug 2009 13:41:32 +0000 (14:41 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 27 Aug 2009 13:41:32 +0000 (14:41 +0100)
libempathy-gtk/libempathy-gtk.pc.in
libempathy/empathy-account-manager.c
libempathy/empathy-account.c
libempathy/empathy-account.h
libempathy/libempathy.pc.in
po/POTFILES.in
src/empathy-call-window.c

index 8ac9f5ca68ea3f4bb6dd82764f03078ce791680a..e0e3f80889e2f3c628e069d0c0d59b74db57abe8 100644 (file)
@@ -6,8 +6,8 @@ includedir=@includedir@
 Name: libempathy-gtk
 Description:  Empathy interface library
 Requires: pkg-config >= 0.21
-Requires.private: glib-2.0, gobject-2.0, gtk+-2.0, libmissioncontrol, \
+Requires.private: glib-2.0, gobject-2.0, gtk+-2.0, \
                   libempathy, telepathy-glib, libcanberra-gtk
 Version: @VERSION@
 Libs: -L${libdir} -lempathy-gtk
-Cflags: -I${includedir} 
+Cflags: -I${includedir}
index 75de6f19342bd02247f7769bd8825c195cec1982..5548a90e6ea598a664f6a0073e395c2633b801fe 100644 (file)
@@ -363,6 +363,76 @@ empathy_account_manager_ensure_account (EmpathyAccountManager *manager,
 }
 
 
+static void
+account_manager_ensure_all_accounts (EmpathyAccountManager *manager,
+    GPtrArray *accounts)
+{
+  int i, missing_accounts;
+  GHashTableIter iter;
+  EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
+  gpointer value;
+  EmpathyAccount *account;
+  gboolean found = FALSE;
+  const gchar *name;
+
+  /* ensure all accounts coming from MC5 first */
+  for (i = 0; i < accounts->len; i++)
+    {
+      name = g_ptr_array_index (accounts, i);
+
+      account = empathy_account_manager_ensure_account (manager, name);
+      empathy_account_refresh_properties (account);
+    }
+
+  missing_accounts = empathy_account_manager_get_count (manager) -
+    accounts->len;
+
+  if (missing_accounts > 0)
+    {
+      /* look for accounts we have and the Tp AccountManager doesn't,
+       * and remove them from our cache.
+       */
+
+      DEBUG ("%d missing accounts", missing_accounts);
+
+      g_hash_table_iter_init (&iter, priv->accounts);
+
+      while (g_hash_table_iter_next (&iter, NULL, &value) &&
+            missing_accounts > 0)
+        {
+          account = value;
+
+          /* look for this account in the AccountManager provided array */
+          for (i = 0; i < accounts->len; i++)
+            {
+              name = g_ptr_array_index (accounts, i);
+
+              if (!tp_strdiff
+                  (name, empathy_account_get_unique_name (account)))
+                {
+                  found = TRUE;
+                  break;
+                }
+            }
+
+          if (!found)
+            {
+              DEBUG ("Account %s was not found, remove it from the cache",
+                    empathy_account_get_unique_name (account));
+
+             g_object_ref (account);
+             g_hash_table_iter_remove (&iter);
+             g_signal_emit (manager, signals[ACCOUNT_DELETED], 0, account);
+             g_object_unref (account);
+
+              missing_accounts--;
+            }
+
+          found = FALSE;
+        }
+    }
+}
+
 static void
 account_manager_got_all_cb (TpProxy *proxy,
     GHashTable *properties,
@@ -372,7 +442,6 @@ account_manager_got_all_cb (TpProxy *proxy,
 {
   EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (weak_object);
   GPtrArray *accounts;
-  int i;
 
   if (error != NULL)
     {
@@ -384,14 +453,7 @@ account_manager_got_all_cb (TpProxy *proxy,
     EMPATHY_ARRAY_TYPE_OBJECT);
 
   if (accounts != NULL)
-    {
-      for (i = 0; i < accounts->len; i++)
-        {
-          gchar *name = g_ptr_array_index (accounts, i);
-
-          empathy_account_manager_ensure_account (manager, name);
-        }
-    }
+    account_manager_ensure_all_accounts (manager, accounts);
 
   empathy_account_manager_check_ready (manager);
 }
@@ -411,6 +473,24 @@ account_validity_changed_cb (TpAccountManager *proxy,
   empathy_account_manager_ensure_account (manager, path);
 }
 
+static void
+account_manager_start_mc5 (TpDBusDaemon *bus)
+{
+  TpProxy *mc5_proxy;
+
+  /* trigger MC5 starting */
+  mc5_proxy = g_object_new (TP_TYPE_PROXY,
+    "dbus-daemon", bus,
+    "dbus-connection", tp_proxy_get_dbus_connection (TP_PROXY (bus)),
+    "bus-name", MC5_BUS_NAME,
+    "object-path", "/",
+    NULL);
+
+  tp_cli_dbus_peer_call_ping (mc5_proxy, -1, NULL, NULL, NULL, NULL);
+
+  g_object_unref (mc5_proxy);
+}
+
 static void
 account_manager_name_owner_cb (TpDBusDaemon *proxy,
     const gchar *name,
@@ -420,32 +500,43 @@ account_manager_name_owner_cb (TpDBusDaemon *proxy,
   EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
   EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
 
-  tp_dbus_daemon_cancel_name_owner_watch (proxy, name,
-    account_manager_name_owner_cb, user_data);
+  DEBUG ("Name owner changed for %s, new name: %s", name, new_owner);
 
-  priv->tp_manager = tp_account_manager_new (priv->dbus);
+  if (EMP_STR_EMPTY (new_owner))
+    {
+      /* MC5 quit or crashed for some reason, let's start it again */
+      account_manager_start_mc5 (priv->dbus);
 
-  tp_cli_account_manager_connect_to_account_validity_changed (
-      priv->tp_manager,
-      account_validity_changed_cb,
-      NULL,
-      NULL,
-      G_OBJECT (manager),
-      NULL);
+      g_object_unref (priv->tp_manager);
+      priv->tp_manager = NULL;
+      return;
+    }
 
-  tp_cli_dbus_properties_call_get_all (priv->tp_manager, -1,
-    TP_IFACE_ACCOUNT_MANAGER,
-    account_manager_got_all_cb,
-    NULL,
-    NULL,
-    G_OBJECT (manager));
+  if (priv->tp_manager == NULL)
+    {
+      priv->tp_manager = tp_account_manager_new (priv->dbus);
+
+      tp_cli_account_manager_connect_to_account_validity_changed (
+          priv->tp_manager,
+          account_validity_changed_cb,
+          NULL,
+          NULL,
+          G_OBJECT (manager),
+          NULL);
+
+      tp_cli_dbus_properties_call_get_all (priv->tp_manager, -1,
+          TP_IFACE_ACCOUNT_MANAGER,
+          account_manager_got_all_cb,
+          NULL,
+          NULL,
+          G_OBJECT (manager));
+    }
 }
 
 static void
 empathy_account_manager_init (EmpathyAccountManager *manager)
 {
   EmpathyAccountManagerPriv *priv;
-  TpProxy *mc5_proxy;
 
   priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
       EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerPriv);
@@ -467,17 +558,7 @@ empathy_account_manager_init (EmpathyAccountManager *manager)
       manager,
       NULL);
 
-  /* trigger MC5 starting */
-  mc5_proxy = g_object_new (TP_TYPE_PROXY,
-    "dbus-daemon", priv->dbus,
-    "dbus-connection", tp_proxy_get_dbus_connection (TP_PROXY (priv->dbus)),
-    "bus-name", MC5_BUS_NAME,
-    "object-path", "/",
-    NULL);
-
-  tp_cli_dbus_peer_call_ping (mc5_proxy, -1, NULL, NULL, NULL, NULL);
-
-  g_object_unref (mc5_proxy);
+  account_manager_start_mc5 (priv->dbus);
 }
 
 static void
@@ -547,9 +628,9 @@ do_constructor (GType type,
 
   if (!manager_singleton)
     {
-      retval = G_OBJECT_CLASS (empathy_account_manager_parent_class)->constructor (type,
-                                                                                   n_construct_params,
-                                                                                   construct_params);
+      retval = G_OBJECT_CLASS
+        (empathy_account_manager_parent_class)->constructor (type,
+            n_construct_params, construct_params);
       manager_singleton = EMPATHY_ACCOUNT_MANAGER (retval);
       g_object_add_weak_pointer (retval, (gpointer) &manager_singleton);
     }
@@ -715,7 +796,8 @@ empathy_account_manager_get_connected_accounts (EmpathyAccountManager *manager)
 }
 
 int
-empathy_account_manager_get_connecting_accounts (EmpathyAccountManager *manager)
+empathy_account_manager_get_connecting_accounts (
+    EmpathyAccountManager *manager)
 {
   EmpathyAccountManagerPriv *priv;
 
index b508f3952077dae54f063ee7b9f77e597e90f4d8..0e4758baa648cb198f4675a3c771effdef581aa9 100644 (file)
@@ -348,7 +348,7 @@ empathy_account_got_all_cb (TpProxy *proxy,
 {
   EmpathyAccount *account = EMPATHY_ACCOUNT (weak_object);
 
-  DEBUG ("Got initial set of properties for %s",
+  DEBUG ("Got whole set of properties for %s",
     empathy_account_get_unique_name (account));
 
   if (error != NULL)
@@ -475,12 +475,7 @@ empathy_account_constructed (GObject *object)
     empathy_account_removed_cb,
     NULL, NULL, object, NULL);
 
-  tp_cli_dbus_properties_call_get_all (priv->account, -1,
-    TP_IFACE_ACCOUNT,
-    empathy_account_got_all_cb,
-    NULL,
-    NULL,
-    G_OBJECT (account));
+  empathy_account_refresh_properties (account);
 }
 
 static void empathy_account_dispose (GObject *object);
@@ -957,17 +952,20 @@ empathy_account_set_enabled_async (EmpathyAccount *account,
       return;
     }
 
-  acc_manager = empathy_account_manager_dup_singleton ();
-  presence = empathy_account_manager_get_requested_global_presence
-    (acc_manager, &status, &status_message);
+  if (enabled)
+    {
+      acc_manager = empathy_account_manager_dup_singleton ();
+      presence = empathy_account_manager_get_requested_global_presence
+       (acc_manager, &status, &status_message);
 
-  if (presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
-    empathy_account_request_presence (account, presence, status,
-        status_message);
+      if (presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
+       empathy_account_request_presence (account, presence, status,
+            status_message);
 
-  g_object_unref (acc_manager);
-  g_free (status);
-  g_free (status_message);
+      g_object_unref (acc_manager);
+      g_free (status);
+      g_free (status_message);
+    }
 
   g_value_init (&value, G_TYPE_BOOLEAN);
   g_value_set_boolean (&value, enabled);
@@ -1218,3 +1216,19 @@ empathy_account_remove_finish (EmpathyAccount *account,
   return TRUE;
 }
 
+void
+empathy_account_refresh_properties (EmpathyAccount *account)
+{
+  EmpathyAccountPriv *priv;
+
+  g_return_if_fail (EMPATHY_IS_ACCOUNT (account));
+
+  priv = GET_PRIV (account);
+
+  tp_cli_dbus_properties_call_get_all (priv->account, -1,
+    TP_IFACE_ACCOUNT,
+    empathy_account_got_all_cb,
+    NULL,
+    NULL,
+    G_OBJECT (account));
+}
index 8a22335eaa3f8581e2bc8a0e2ee1d9410c111843..e789ca702dbc56632e3105753f2375ef98c20474 100644 (file)
@@ -110,6 +110,8 @@ void empathy_account_request_presence (EmpathyAccount *account,
 
 const GHashTable *empathy_account_get_parameters (EmpathyAccount *account);
 
+void empathy_account_refresh_properties (EmpathyAccount *account);
+
 
 G_END_DECLS
 
index 6c1f81038d93d3cbc94cb11fc7baf02f5b1f2175..6dd89fd5a652ed015d841492818a0841caa6747c 100644 (file)
@@ -6,8 +6,8 @@ includedir=@includedir@
 Name: libempathy
 Description:  Empathy base library
 Requires: pkg-config >= 0.21
-Requires.private: glib-2.0, gobject-2.0, libxml-2.0, libmissioncontrol, \
+Requires.private: glib-2.0, gobject-2.0, libxml-2.0, \
                   gio-2.0, gio-unix-2.0, telepathy-glib
 Version: @VERSION@
 Libs: -L${libdir} -lempathy
-Cflags: -I${includedir} 
+Cflags: -I${includedir}
index b7dcd7828407a6e90545755d776921c3c6e8a431..bf356f06d0d90591f222d68d46dfacd97666c2a4 100644 (file)
@@ -91,4 +91,4 @@ src/empathy-tube-dispatch.c
 [type: gettext/glade]src/empathy-call-window-fullscreen.ui
 src/empathy-map-view.c
 [type: gettext/glade]src/empathy-map-view.ui
-src/empathy-debug-dialog.c
+src/empathy-debug-window.c
index f7ba242326fadb68f4dd71202d124a59a6882308..fed71b9952b7812f03f78a428dba0467ff1f30fd 100644 (file)
@@ -1403,6 +1403,8 @@ empathy_call_window_connected (gpointer user_data)
   EmpathyTpCall *call;
   gboolean can_send_video;
 
+  empathy_sound_stop (EMPATHY_SOUND_PHONE_OUTGOING);
+
   can_send_video = priv->video_input != NULL && priv->contact != NULL &&
     empathy_contact_can_voip_video (priv->contact);
 
@@ -1471,7 +1473,6 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
       g_timer_start (priv->timer);
       priv->timer_id = g_idle_add  (empathy_call_window_connected, self);
       priv->call_state = CONNECTED;
-      empathy_sound_stop (EMPATHY_SOUND_PHONE_OUTGOING);
     }
 
   switch (media_type)