--- telepathy-mission-control-5-5.12.0/ChangeLog	2012-04-03 00:55:00.000000000 +0200
+++ telepathy-mission-control-5-5.12.1/ChangeLog	2012-07-11 12:56:17.000000000 +0200
@@ -1,3 +1,85 @@
+commit e824493e533f7c4ea9ae9066fb29b3298d9a8aa8
+Author: Xavier Claessens <xavier.claessens@collabora.co.uk>
+Date:   2012-07-11 12:49:04 +0200
+
+    Prepare 5.12.1 release
+
+commit 57d7c6360f04d8bc65320c42a5d8929fa3e3bc25
+Author: Xavier Claessens <xavier.claessens@collabora.co.uk>
+Date:   2012-07-11 12:14:11 +0200
+
+    Copy telepathy.am from telepathy-glib
+    
+    It make sure "make -j3 maintainer-foo" works
+
+commit 0daa22ca3858138aee10f8bf46a07fd15c1fcf49
+Author: Xavier Claessens <xavier.claessens@collabora.co.uk>
+Date:   2012-07-09 12:35:01 +0200
+
+    McdAccountManagerDefault: Fix a possible double free
+    
+    If the account is already in the hashtable, g_hash_table_insert()
+    will set @removed as value, but free it since the key already in
+    the table is kept.
+    
+    https://bugs.freedesktop.org/show_bug.cgi?id=51842
+
+commit 150c89d45c6b7d5a2d10bc36cff5689ea1ca72d8
+Author: Will Thompson <will.thompson@collabora.co.uk>
+Date:   2012-04-05 17:10:18 +0100
+
+    dispatch test: make sure Ensure-ing channels after delegation/presenting works
+
+commit 54f4fd22c09a342bb58da978b5a055e45f968897
+Author: Jonny Lamb <jonny.lamb@collabora.co.uk>
+Date:   2012-07-06 16:50:08 +0100
+
+    dispatcher: set channel state back to DISPATCHED after delegating & presenting
+    
+    _mcd_client_proxy_handle_channels sets the McdChannel state to
+    HANDLER_INVOKED, but when we were calling this in both delegate and
+    present operations, the state was not being set back to the DISPATCHED
+    state afterwards.
+    
+    The state being wrong meant that dispatching a channel after if had
+    been delegated or presented would not happen, as MC thought we were
+    still waiting for a handler response.
+    
+    Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
+
+commit c8ae24ffd03297d097b553997eda3807f1505748
+Author: Jonny Lamb <jonny.lamb@collabora.co.uk>
+Date:   2012-07-06 16:49:55 +0100
+
+    dispatcher: add more debug output when delegating channels
+    
+    Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
+
+commit 3d35096f9ccc69b8c3067ed85102694eda4a2855
+Author: Will Thompson <will.thompson@collabora.co.uk>
+Date:   2012-04-05 16:56:35 +0100
+
+    Modernize dispatcher/redispatch-channels.py a little
+
+commit 88642511bb9c6f66d2fe4aae1550893eb0d781b2
+Author: Jonny Lamb <jonny.lamb@collabora.co.uk>
+Date:   2012-04-03 11:13:55 -0400
+
+    stop using deprecated tp-glib functions
+    
+    tp_*_call_when_ready were replaced by tp_proxy_prepare_async a while
+    ago.
+    
+    Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
+
+commit edd10ce2948b29859006ca1e149e68097a3bd21b
+Author: Jonny Lamb <jonny.lamb@collabora.co.uk>
+Date:   2012-04-02 18:58:07 -0400
+
+    start working on version 5.12.1
+    
+    Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
+
 commit aeba9f785227e07bf26b14822b1b288041297910
 Author: Jonny Lamb <jonny.lamb@collabora.co.uk>
 Date:   2012-04-02 18:22:56 -0400
--- telepathy-mission-control-5-5.12.0/configure.ac	2012-04-03 00:50:06.000000000 +0200
+++ telepathy-mission-control-5-5.12.1/configure.ac	2012-07-11 12:55:01.000000000 +0200
@@ -1,7 +1,7 @@
 dnl Set the version number to e.g. 5.x.y immediately before a release.
 dnl Set the version number to e.g. 5.x.y+ immediately after (this will
 dnl enable -Werror).
-AC_INIT([telepathy-mission-control], [5.12.0])
+AC_INIT([telepathy-mission-control], [5.12.1])
 
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_SRCDIR(Makefile.am)
--- telepathy-mission-control-5-5.12.0/debian/changelog	2012-05-09 12:33:50.000000000 +0200
+++ telepathy-mission-control-5-5.12.1/debian/changelog	2012-07-24 13:42:01.000000000 +0200
@@ -1,3 +1,19 @@
+telepathy-mission-control-5 (1:5.12.1-2) UNRELEASED; urgency=low
+
+  * debian/gbp.conf: Set unstable branch names again.
+  * Add d/p/0001-Revert-stop-using-deprecated-tp-glib-functions.patch:
+    Revert "stop using deprecated tp-glib functions" to minimize delta with
+    current version in wheezy.
+
+ -- Laurent Bigonville <bigon@debian.org>  Tue, 24 Jul 2012 13:41:06 +0200
+
+telepathy-mission-control-5 (1:5.12.1-1) experimental; urgency=low
+
+  * New upstream release.
+  * debian/gbp.conf: Set experimental branch names again.
+
+ -- Jonny Lamb <jonny@debian.org>  Wed, 11 Jul 2012 16:17:34 +0100
+
 telepathy-mission-control-5 (1:5.12.0-2) unstable; urgency=low
 
   * Merge from experimental into unstable
--- telepathy-mission-control-5-5.12.0/debian/patches/0001-Revert-stop-using-deprecated-tp-glib-functions.patch	1970-01-01 01:00:00.000000000 +0100
+++ telepathy-mission-control-5-5.12.1/debian/patches/0001-Revert-stop-using-deprecated-tp-glib-functions.patch	2012-07-24 13:42:01.000000000 +0200
@@ -0,0 +1,195 @@
+From: Laurent Bigonville <bigon@bigon.be>
+Date: Tue, 24 Jul 2012 13:40:00 +0200
+Subject: Revert "stop using deprecated tp-glib functions"
+
+This reverts commit 88642511bb9c6f66d2fe4aae1550893eb0d781b2.
+---
+ src/mcd-channel.c    |   26 +++++++-------------------
+ src/mcd-connection.c |   24 ++++++++----------------
+ src/mcd-manager.c    |   14 +++++---------
+ 3 files changed, 20 insertions(+), 44 deletions(-)
+
+diff --git a/src/mcd-channel.c b/src/mcd-channel.c
+index 2d6d173..64d12a4 100644
+--- a/src/mcd-channel.c
++++ b/src/mcd-channel.c
+@@ -191,20 +191,11 @@ _mcd_channel_setup_group (McdChannel *channel)
+ }
+ 
+ static void
+-on_channel_ready (GObject *source_object, GAsyncResult *result, gpointer user_data)
++on_channel_ready (TpChannel *tp_chan, const GError *error, gpointer user_data)
+ {
+-    TpChannel *tp_chan = TP_CHANNEL (source_object);
+     McdChannel *channel, **channel_ptr = user_data;
+     McdChannelPrivate *priv;
+     gboolean requested, valid;
+-    GError *error = NULL;
+-
+-    if (!tp_proxy_prepare_finish (tp_chan, result, &error))
+-    {
+-        DEBUG ("failed to prepare channel: %s", error->message);
+-        g_clear_error (&error);
+-        return;
+-    }
+ 
+     channel = *channel_ptr;
+     if (channel)
+@@ -305,7 +296,7 @@ _mcd_channel_setup (McdChannel *channel, McdChannelPrivate *priv)
+     channel_ptr = g_slice_alloc (sizeof (McdChannel *));
+     *channel_ptr = channel;
+     g_object_add_weak_pointer ((GObject *)channel, (gpointer)channel_ptr);
+-    tp_proxy_prepare_async (priv->tp_chan, NULL, on_channel_ready, channel_ptr);
++    tp_channel_call_when_ready (priv->tp_chan, on_channel_ready, channel_ptr);
+ 
+     g_signal_connect (priv->tp_chan, "invalidated",
+ 		      G_CALLBACK (proxy_destroyed), channel);
+@@ -1398,21 +1389,18 @@ typedef struct {
+ } DepartData;
+ 
+ static void
+-mcd_channel_ready_to_depart_cb (GObject *source_object,
+-                                GAsyncResult *result,
++mcd_channel_ready_to_depart_cb (TpChannel *channel,
++                                const GError *error,
+                                 gpointer data)
+ {
+-    TpChannel *channel = TP_CHANNEL (source_object);
+     DepartData *d = data;
+-    GError *error = NULL;
+ 
+-    if (!tp_proxy_prepare_finish (channel, result, &error))
++    if (error != NULL)
+     {
+         DEBUG ("%s %d: %s", g_quark_to_string (error->domain), error->code,
+                error->message);
+         g_free (d->message);
+         g_slice_free (DepartData, d);
+-        g_clear_error (&error);
+         return;
+     }
+ 
+@@ -1468,8 +1456,8 @@ _mcd_channel_depart (McdChannel *channel,
+     d->reason = reason;
+     d->message = g_strdup (message);
+ 
+-    tp_proxy_prepare_async (channel->priv->tp_chan, NULL,
+-                            mcd_channel_ready_to_depart_cb, d);
++    tp_channel_call_when_ready (channel->priv->tp_chan,
++                                mcd_channel_ready_to_depart_cb, d);
+ }
+ 
+ /*
+diff --git a/src/mcd-connection.c b/src/mcd-connection.c
+index d5ac240..40a5952 100644
+--- a/src/mcd-connection.c
++++ b/src/mcd-connection.c
+@@ -1561,25 +1561,21 @@ mcd_connection_setup_pre_requests (McdConnection *connection)
+ }
+ 
+ static void
+-on_connection_ready (GObject *source_object, GAsyncResult *result,
+-                     gpointer user_data)
++on_connection_ready (TpConnection *tp_conn, const GError *error,
++		     gpointer user_data)
+ {
+-    TpConnection *tp_conn = TP_CONNECTION (source_object);
+     McdConnection *connection, **connection_ptr = user_data;
+     McdConnectionPrivate *priv;
+-    GError *error = NULL;
+ 
+     connection = *connection_ptr;
+     if (connection)
+ 	g_object_remove_weak_pointer ((GObject *)connection,
+ 				      (gpointer)connection_ptr);
+     g_slice_free (McdConnection *, connection_ptr);
+-
+-    if (!tp_proxy_prepare_finish (tp_conn, result, &error))
++    if (error)
+     {
+         DEBUG ("got error: %s", error->message);
+-        g_clear_error (&error);
+-        return;
++	return;
+     }
+ 
+     if (!connection) return;
+@@ -2292,7 +2288,7 @@ _mcd_connection_request_channel (McdConnection *connection, McdChannel *channel)
+     g_return_val_if_fail (priv->tp_conn != NULL, FALSE);
+     g_return_val_if_fail (TP_IS_CONNECTION (priv->tp_conn), FALSE);
+ 
+-    if (!tp_proxy_is_prepared (priv->tp_conn, TP_CONNECTION_FEATURE_CONNECTED))
++    if (!tp_connection_is_ready (priv->tp_conn))
+     {
+         /* don't request any channel until the connection is ready (because we
+          * don't know if the CM implements the Requests interface). The channel
+@@ -2720,10 +2716,6 @@ _mcd_connection_set_tp_connection (McdConnection *connection,
+ {
+     McdConnection **connection_ptr;
+     McdConnectionPrivate *priv;
+-    GQuark features[] = {
+-      TP_CONNECTION_FEATURE_CONNECTED,
+-      0
+-    };
+ 
+     g_return_if_fail (MCD_IS_CONNECTION (connection));
+     priv = connection->priv;
+@@ -2771,8 +2763,8 @@ _mcd_connection_set_tp_connection (McdConnection *connection,
+     *connection_ptr = connection;
+     g_object_add_weak_pointer ((GObject *)connection,
+                                (gpointer)connection_ptr);
+-    tp_proxy_prepare_async (priv->tp_conn, features,
+-                            on_connection_ready, connection_ptr);
++    tp_connection_call_when_ready (priv->tp_conn, on_connection_ready,
++                                   connection_ptr);
+ }
+ 
+ /**
+@@ -2794,7 +2786,7 @@ _mcd_connection_is_ready (McdConnection *self)
+     g_return_val_if_fail (MCD_IS_CONNECTION (self), FALSE);
+ 
+     return (self->priv->tp_conn != NULL) &&
+-        tp_proxy_is_prepared (self->priv->tp_conn, TP_CONNECTION_FEATURE_CONNECTED);
++        tp_connection_is_ready (self->priv->tp_conn);
+ }
+ 
+ gboolean
+diff --git a/src/mcd-manager.c b/src/mcd-manager.c
+index 1098cc3..d19cfc0 100644
+--- a/src/mcd-manager.c
++++ b/src/mcd-manager.c
+@@ -79,21 +79,16 @@ enum
+ static GQuark readiness_quark = 0;
+ 
+ static void
+-on_manager_ready (GObject *source_object,
+-                  GAsyncResult *result, gpointer user_data)
++on_manager_ready (TpConnectionManager *tp_conn_mgr, const GError *error,
++                  gpointer user_data, GObject *weak_object)
+ {
+-    TpConnectionManager *tp_conn_mgr = TP_CONNECTION_MANAGER (source_object);
+-    McdManager *manager = MCD_MANAGER (user_data);
++    McdManager *manager = MCD_MANAGER (weak_object);
+     McdManagerPrivate *priv;
+-    GError *error = NULL;
+-
+-    tp_proxy_prepare_finish (tp_conn_mgr, result, &error);
+ 
+     priv = manager->priv;
+     DEBUG ("manager %s is ready", priv->name);
+     priv->ready = TRUE;
+     _mcd_object_ready (manager, readiness_quark, error);
+-    g_clear_error (&error);
+ }
+ 
+ static gint
+@@ -203,7 +198,8 @@ mcd_manager_setup (McdManager *manager)
+         goto error;
+     }
+ 
+-    tp_proxy_prepare_async (priv->tp_conn_mgr, NULL, on_manager_ready, manager);
++    tp_connection_manager_call_when_ready (priv->tp_conn_mgr, on_manager_ready,
++                                           NULL, NULL, (GObject *)manager);
+ 
+     DEBUG ("Manager %s created", priv->name);
+     return TRUE;
--- telepathy-mission-control-5-5.12.0/debian/patches/series	1970-01-01 01:00:00.000000000 +0100
+++ telepathy-mission-control-5-5.12.1/debian/patches/series	2012-07-24 13:42:01.000000000 +0200
@@ -0,0 +1 @@
+0001-Revert-stop-using-deprecated-tp-glib-functions.patch
--- telepathy-mission-control-5-5.12.0/NEWS	2012-04-03 00:50:06.000000000 +0200
+++ telepathy-mission-control-5-5.12.1/NEWS	2012-07-11 12:55:01.000000000 +0200
@@ -1,3 +1,12 @@
+telepathy-mission-control 5.12.1 (2012-07-11)
+=============================================
+
+Fixes:
+
+• Stop using deprecated telepathy-glib symbols. (Jonny)
+• fdo#51842 - fix access to freed memory. (Xavier)
+• fix existing channel dispatching after using present/delegate. (Jonny)
+
 telepathy-mission-control 5.12.0 (2012-04-02)
 =============================================
 
--- telepathy-mission-control-5-5.12.0/src/mcd-account-manager-default.c	2011-12-23 08:39:57.000000000 +0100
+++ telepathy-mission-control-5-5.12.1/src/mcd-account-manager-default.c	2012-07-11 12:09:34.000000000 +0200
@@ -77,7 +77,7 @@
     {
       /* flag the whole account as purged */
       gchar *removed = g_strdup (account);
-      g_hash_table_insert (amd->removed_accounts, removed, removed);
+      g_hash_table_replace (amd->removed_accounts, removed, removed);
     }
   else
     {
--- telepathy-mission-control-5-5.12.0/src/mcd-channel.c	2011-12-23 08:39:57.000000000 +0100
+++ telepathy-mission-control-5-5.12.1/src/mcd-channel.c	2012-07-11 12:16:54.000000000 +0200
@@ -191,11 +191,20 @@
 }
 
 static void
-on_channel_ready (TpChannel *tp_chan, const GError *error, gpointer user_data)
+on_channel_ready (GObject *source_object, GAsyncResult *result, gpointer user_data)
 {
+    TpChannel *tp_chan = TP_CHANNEL (source_object);
     McdChannel *channel, **channel_ptr = user_data;
     McdChannelPrivate *priv;
     gboolean requested, valid;
+    GError *error = NULL;
+
+    if (!tp_proxy_prepare_finish (tp_chan, result, &error))
+    {
+        DEBUG ("failed to prepare channel: %s", error->message);
+        g_clear_error (&error);
+        return;
+    }
 
     channel = *channel_ptr;
     if (channel)
@@ -296,7 +305,7 @@
     channel_ptr = g_slice_alloc (sizeof (McdChannel *));
     *channel_ptr = channel;
     g_object_add_weak_pointer ((GObject *)channel, (gpointer)channel_ptr);
-    tp_channel_call_when_ready (priv->tp_chan, on_channel_ready, channel_ptr);
+    tp_proxy_prepare_async (priv->tp_chan, NULL, on_channel_ready, channel_ptr);
 
     g_signal_connect (priv->tp_chan, "invalidated",
 		      G_CALLBACK (proxy_destroyed), channel);
@@ -1389,18 +1398,21 @@
 } DepartData;
 
 static void
-mcd_channel_ready_to_depart_cb (TpChannel *channel,
-                                const GError *error,
+mcd_channel_ready_to_depart_cb (GObject *source_object,
+                                GAsyncResult *result,
                                 gpointer data)
 {
+    TpChannel *channel = TP_CHANNEL (source_object);
     DepartData *d = data;
+    GError *error = NULL;
 
-    if (error != NULL)
+    if (!tp_proxy_prepare_finish (channel, result, &error))
     {
         DEBUG ("%s %d: %s", g_quark_to_string (error->domain), error->code,
                error->message);
         g_free (d->message);
         g_slice_free (DepartData, d);
+        g_clear_error (&error);
         return;
     }
 
@@ -1456,8 +1468,8 @@
     d->reason = reason;
     d->message = g_strdup (message);
 
-    tp_channel_call_when_ready (channel->priv->tp_chan,
-                                mcd_channel_ready_to_depart_cb, d);
+    tp_proxy_prepare_async (channel->priv->tp_chan, NULL,
+                            mcd_channel_ready_to_depart_cb, d);
 }
 
 /*
--- telepathy-mission-control-5-5.12.0/src/mcd-connection.c	2011-12-23 08:39:57.000000000 +0100
+++ telepathy-mission-control-5-5.12.1/src/mcd-connection.c	2012-07-11 12:16:54.000000000 +0200
@@ -1561,21 +1561,25 @@
 }
 
 static void
-on_connection_ready (TpConnection *tp_conn, const GError *error,
-		     gpointer user_data)
+on_connection_ready (GObject *source_object, GAsyncResult *result,
+                     gpointer user_data)
 {
+    TpConnection *tp_conn = TP_CONNECTION (source_object);
     McdConnection *connection, **connection_ptr = user_data;
     McdConnectionPrivate *priv;
+    GError *error = NULL;
 
     connection = *connection_ptr;
     if (connection)
 	g_object_remove_weak_pointer ((GObject *)connection,
 				      (gpointer)connection_ptr);
     g_slice_free (McdConnection *, connection_ptr);
-    if (error)
+
+    if (!tp_proxy_prepare_finish (tp_conn, result, &error))
     {
         DEBUG ("got error: %s", error->message);
-	return;
+        g_clear_error (&error);
+        return;
     }
 
     if (!connection) return;
@@ -2288,7 +2292,7 @@
     g_return_val_if_fail (priv->tp_conn != NULL, FALSE);
     g_return_val_if_fail (TP_IS_CONNECTION (priv->tp_conn), FALSE);
 
-    if (!tp_connection_is_ready (priv->tp_conn))
+    if (!tp_proxy_is_prepared (priv->tp_conn, TP_CONNECTION_FEATURE_CONNECTED))
     {
         /* don't request any channel until the connection is ready (because we
          * don't know if the CM implements the Requests interface). The channel
@@ -2716,6 +2720,10 @@
 {
     McdConnection **connection_ptr;
     McdConnectionPrivate *priv;
+    GQuark features[] = {
+      TP_CONNECTION_FEATURE_CONNECTED,
+      0
+    };
 
     g_return_if_fail (MCD_IS_CONNECTION (connection));
     priv = connection->priv;
@@ -2763,8 +2771,8 @@
     *connection_ptr = connection;
     g_object_add_weak_pointer ((GObject *)connection,
                                (gpointer)connection_ptr);
-    tp_connection_call_when_ready (priv->tp_conn, on_connection_ready,
-                                   connection_ptr);
+    tp_proxy_prepare_async (priv->tp_conn, features,
+                            on_connection_ready, connection_ptr);
 }
 
 /**
@@ -2786,7 +2794,7 @@
     g_return_val_if_fail (MCD_IS_CONNECTION (self), FALSE);
 
     return (self->priv->tp_conn != NULL) &&
-        tp_connection_is_ready (self->priv->tp_conn);
+        tp_proxy_is_prepared (self->priv->tp_conn, TP_CONNECTION_FEATURE_CONNECTED);
 }
 
 gboolean
--- telepathy-mission-control-5-5.12.0/src/mcd-dispatcher.c	2011-12-23 08:39:57.000000000 +0100
+++ telepathy-mission-control-5-5.12.1/src/mcd-dispatcher.c	2012-07-11 12:16:54.000000000 +0200
@@ -2584,6 +2584,13 @@
     DelegateChannelsCtx *ctx = to_delegate->ctx;
     McdClientProxy *clt_proxy = MCD_CLIENT_PROXY (client);
 
+    /* If the delegation succeeded, the channel has a new handler. If
+     * the delegation failed, the channel still has the old
+     * handler. Either way, the channel still has a handler, so it has
+     * been successfully dispatched (from 'handler invoked'). */
+    _mcd_channel_set_status (to_delegate->channel,
+        MCD_CHANNEL_STATUS_DISPATCHED);
+
     if (error != NULL)
       {
         DEBUG ("Handler refused delegated channels");
@@ -2615,6 +2622,9 @@
     McdClientProxy *client;
     GList *channels = NULL;
 
+    DEBUG ("%s",
+        mcd_channel_get_object_path (to_delegate->channel));
+
     if (g_queue_get_length (to_delegate->handlers) == 0)
       {
         GValueArray *v;
@@ -2641,13 +2651,17 @@
             g_strdup (mcd_channel_get_object_path (to_delegate->channel)),
             v);
 
+        DEBUG ("...but failed to delegate it: %s",
+            mcd_channel_get_object_path (to_delegate->channel),
+            to_delegate->error->message);
+
         delegation_done (to_delegate);
         return;
       }
 
     client = g_queue_pop_head (to_delegate->handlers);
 
-    DEBUG ("Try delegating channels to %s", _mcd_client_proxy_get_unique_name (
+    DEBUG ("...trying client %s", _mcd_client_proxy_get_unique_name (
         client));
 
     channels = g_list_prepend (channels, to_delegate->channel);
@@ -2721,6 +2735,8 @@
     guint i;
     GList *l;
 
+    DEBUG ("called");
+
     if (!check_preferred_handler (preferred_handler, &error))
         goto error;
 
@@ -2812,10 +2828,17 @@
 static void
 present_handle_channels_cb (TpClient *client,
     const GError *error,
-    gpointer user_data G_GNUC_UNUSED,
+    gpointer user_data,
     GObject *weak_object)
 {
     DBusGMethodInvocation *context = user_data;
+    McdChannel *mcd_channel = MCD_CHANNEL (weak_object);
+
+    /* Whether presenting the channel succeeded or failed, the
+     * channel's handler hasn't been altered, so it must be set back
+     * to the dispatched state (from 'handler invoked'). */
+    _mcd_channel_set_status (mcd_channel,
+        MCD_CHANNEL_STATUS_DISPATCHED);
 
     if (error != NULL)
       {
@@ -2884,7 +2907,7 @@
 
     _mcd_client_proxy_handle_channels (client, -1, channels,
         user_action_time, NULL, present_handle_channels_cb,
-        context, NULL, NULL);
+        context, NULL, G_OBJECT (mcd_channel));
 
     g_list_free (channels);
     return;
--- telepathy-mission-control-5-5.12.0/src/mcd-manager.c	2011-12-23 08:39:57.000000000 +0100
+++ telepathy-mission-control-5-5.12.1/src/mcd-manager.c	2012-07-11 12:16:54.000000000 +0200
@@ -79,16 +79,21 @@
 static GQuark readiness_quark = 0;
 
 static void
-on_manager_ready (TpConnectionManager *tp_conn_mgr, const GError *error,
-                  gpointer user_data, GObject *weak_object)
+on_manager_ready (GObject *source_object,
+                  GAsyncResult *result, gpointer user_data)
 {
-    McdManager *manager = MCD_MANAGER (weak_object);
+    TpConnectionManager *tp_conn_mgr = TP_CONNECTION_MANAGER (source_object);
+    McdManager *manager = MCD_MANAGER (user_data);
     McdManagerPrivate *priv;
+    GError *error = NULL;
+
+    tp_proxy_prepare_finish (tp_conn_mgr, result, &error);
 
     priv = manager->priv;
     DEBUG ("manager %s is ready", priv->name);
     priv->ready = TRUE;
     _mcd_object_ready (manager, readiness_quark, error);
+    g_clear_error (&error);
 }
 
 static gint
@@ -198,8 +203,7 @@
         goto error;
     }
 
-    tp_connection_manager_call_when_ready (priv->tp_conn_mgr, on_manager_ready,
-                                           NULL, NULL, (GObject *)manager);
+    tp_proxy_prepare_async (priv->tp_conn_mgr, NULL, on_manager_ready, manager);
 
     DEBUG ("Manager %s created", priv->name);
     return TRUE;
--- telepathy-mission-control-5-5.12.0/tests/twisted/dispatcher/redispatch-channels.py	2011-12-23 08:39:57.000000000 +0100
+++ telepathy-mission-control-5-5.12.1/tests/twisted/dispatcher/redispatch-channels.py	2012-07-11 12:08:41.000000000 +0200
@@ -22,17 +22,49 @@
 import dbus.service
 
 from servicetest import call_async, assertEquals
-from mctest import exec_test, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
-        expect_client_setup
+from mctest import (
+    exec_test, SimulatedClient,
+    create_fakecm_account, enable_fakecm_account, SimulatedChannel,
+    expect_client_setup,
+    ChannelDispatcher, ChannelDispatchOperation, ChannelRequest)
 import constants as cs
 
-def test_delegate_channel(q, bus, mc, account, chan, empathy, empathy_bus, gs):
-    # Now gnome-shell wants to give the channel to another handle
-    gs_cd = bus.get_object(cs.CD, cs.CD_PATH)
-    gs_cd_iface = dbus.Interface(gs_cd, cs.CD)
+REQUEST = dbus.Dictionary({
+        cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT,
+        cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+        cs.TARGET_ID: 'juliet',
+        }, signature='sv')
+
+def test_ensure(q, bus, account, conn, chan, expected_handler_path):
+    """Tests that a client Ensure-ing the channel causes HandleChannels to be
+    called on the current handler. (Previously, DelegateChannels() and
+    PresentChannel() both broke this.)"""
+    cd = ChannelDispatcher(bus)
+    call_async(q, cd, 'EnsureChannel', account.object_path, REQUEST, 0, '')
+    e = q.expect('dbus-return', method='EnsureChannel')
+
+    cr = ChannelRequest(bus, e.value[0])
+    cr.Proceed()
 
-    call_async(q, gs_cd_iface, 'DelegateChannels',
+    e = q.expect('dbus-method-call', interface=cs.CONN_IFACE_REQUESTS,
+        method='EnsureChannel',
+        path=conn.object_path, args=[REQUEST], handled=False)
+    q.dbus_return(e.message, False,
+        chan.object_path, chan.immutable, signature='boa{sv}')
+
+    e = q.expect('dbus-method-call',
+            interface=cs.HANDLER, method='HandleChannels',
+            handled=False)
+    assertEquals(expected_handler_path, e.path)
+    q.dbus_return(e.message, signature='')
+
+def test_delegate_channel(q, bus, mc, account, conn, chan, empathy, empathy_bus, gs):
+    # Test that re-Ensure-ing works before we start Delegating and Presenting.
+    test_ensure(q, bus, account, conn, chan, gs.object_path)
+
+    # Now gnome-shell wants to give the channel to another handler
+    gs_cd = ChannelDispatcher(bus)
+    call_async(q, gs_cd, 'DelegateChannels',
         [chan.object_path], 0, "")
 
     # Empathy is asked to handle the channel and accept
@@ -46,11 +78,14 @@
     e = q.expect('dbus-return', method='DelegateChannels')
     assertEquals(([chan.object_path], {}), e.value)
 
-    # Let's play ping-pong channel! Empathy give the channel back to GS
-    emp_cd = empathy_bus.get_object(cs.CD, cs.CD_PATH)
-    emp_cd_iface = dbus.Interface(emp_cd, cs.CD)
-
-    call_async(q, emp_cd_iface, 'DelegateChannels',
+    # Test that re-Ensure-ing the channel still works, and sends it to
+    # the right place.
+    test_ensure(q, bus, account, conn, chan, empathy.object_path)
+
+    # Let's play ping-pong with the channel! Empathy gives the channel
+    # back to GS
+    emp_cd = ChannelDispatcher(empathy_bus)
+    call_async(q, emp_cd, 'DelegateChannels',
         [chan.object_path], 0, "")
 
     # gnome-shell is asked to handle the channel and accept
@@ -64,8 +99,12 @@
     e = q.expect('dbus-return', method='DelegateChannels')
     assertEquals(([chan.object_path], {}), e.value)
 
+    # Test that re-Ensure-ing the channel sttill works, and sends it
+    # to the right place.
+    test_ensure(q, bus, account, conn, chan, gs.object_path)
+
     # gnome-shell wants to give it back, again
-    call_async(q, gs_cd_iface, 'DelegateChannels',
+    call_async(q, gs_cd, 'DelegateChannels',
         [chan.object_path], 0, "")
 
     # Empathy is asked to handle the channel but refuses
@@ -80,14 +119,18 @@
     e = q.expect('dbus-return', method='DelegateChannels')
     assertEquals(([], {chan.object_path: (cs.NOT_AVAILABLE, 'No thanks')}), e.value)
 
+    # Test that re-Ensure-ing the channel sttill works, and sends it
+    # to the right place.
+    test_ensure(q, bus, account, conn, chan, gs.object_path)
+
     # Empathy doesn't handle the channel atm but tries to delegates it
-    call_async(q, emp_cd_iface, 'DelegateChannels',
+    call_async(q, emp_cd, 'DelegateChannels',
         [chan.object_path], 0, "")
 
     q.expect('dbus-error', method='DelegateChannels', name=cs.NOT_YOURS)
 
     # gnome-shell which is handling the channel asks to re-ensure it
-    call_async(q, gs_cd_iface, 'PresentChannel',
+    call_async(q, gs_cd, 'PresentChannel',
         chan.object_path, 0)
 
     # gnome-shell is asked to re-handle the channel
@@ -101,7 +144,7 @@
     q.expect('dbus-return', method='PresentChannel')
 
     # empathy which is not handling the channel asks to re-ensure it
-    call_async(q, emp_cd_iface, 'PresentChannel',
+    call_async(q, emp_cd, 'PresentChannel',
         chan.object_path, 0)
 
     # gnome-shell is asked to re-handle the channel
@@ -114,6 +157,10 @@
 
     q.expect('dbus-return', method='PresentChannel')
 
+    # Test that re-Ensure-ing the channel *still* works, and sends it
+    # to the right place.
+    test_ensure(q, bus, account, conn, chan, gs.object_path)
+
     # Empathy crashes
     empathy.release_name()
 
@@ -124,7 +171,7 @@
             )
 
     # gnome-shell wants to delegate, but there is no other handler
-    call_async(q, gs_cd_iface, 'DelegateChannels',
+    call_async(q, gs_cd, 'DelegateChannels',
         [chan.object_path], 0, "")
 
     e = q.expect('dbus-return', method='DelegateChannels')
@@ -160,7 +207,7 @@
     # wait for MC to download the properties
     expect_client_setup(q, [empathy, gs])
 
-    cd = bus.get_object(cs.CD, cs.CD_PATH)
+    cd = ChannelDispatcher(bus)
 
     # incoming text channel
     channel_properties = dbus.Dictionary(text_fixed_properties,
@@ -184,13 +231,12 @@
 
     channels, cdo_path,props = e.args
 
-    cdo = bus.get_object(cs.CD, cdo_path)
-    cdo_iface = dbus.Interface(cdo, cs.CDO)
+    cdo = ChannelDispatchOperation(bus, cdo_path)
 
     q.dbus_return(e.message, signature='')
 
     # gnome-shell handles the channel itself first
-    call_async(q, cdo_iface, 'HandleWith',
+    call_async(q, cdo, 'HandleWith',
             cs.tp_name_prefix + '.Client.GnomeShell')
 
     e = q.expect('dbus-method-call',
@@ -201,7 +247,7 @@
     q.dbus_return(e.message, signature='')
 
     # test delegating an incoming channel
-    test_delegate_channel(q, bus, mc, account, chan, empathy, empathy_bus, gs)
+    test_delegate_channel(q, bus, mc, account, conn, chan, empathy, empathy_bus, gs)
 
     # Empathy is back
     empathy = SimulatedClient(q, empathy_bus, 'EmpathyChat',
@@ -210,27 +256,21 @@
     expect_client_setup(q, [empathy])
 
     # gnome-shell requests a channel for itself
-    request = dbus.Dictionary({
-            cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT,
-            cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
-            cs.TARGET_ID: 'juliet',
-            }, signature='sv')
-
     call_async(q, cd, 'CreateChannelWithHints',
-            account.object_path, request, 0,
+            account.object_path, REQUEST, 0,
             cs.tp_name_prefix + '.Client.GnomeShell',
-            {}, dbus_interface=cs.CD)
+            {})
     e = q.expect('dbus-return', method='CreateChannelWithHints')
 
-    cr = bus.get_object(cs.AM, e.value[0])
-    cr.Proceed(dbus_interface=cs.CR)
+    cr = ChannelRequest(bus, e.value[0])
+    cr.Proceed()
 
     e = q.expect('dbus-method-call', interface=cs.CONN_IFACE_REQUESTS,
         method='CreateChannel',
-        path=conn.object_path, args=[request], handled=False)
+        path=conn.object_path, args=[REQUEST], handled=False)
 
     # channel is created
-    chan = SimulatedChannel(conn, request)
+    chan = SimulatedChannel(conn, REQUEST)
 
     q.dbus_return(e.message,
         chan.object_path, chan.immutable, signature='oa{sv}')
@@ -245,7 +285,7 @@
     q.dbus_return(e.message, signature='')
 
     # test delegating an outgoing channel
-    test_delegate_channel(q, bus, mc, account, chan, empathy, empathy_bus, gs)
+    test_delegate_channel(q, bus, mc, account, conn, chan, empathy, empathy_bus, gs)
 
 if __name__ == '__main__':
     exec_test(test, {})
--- telepathy-mission-control-5-5.12.0/tests/twisted/mctest.py	2012-04-03 00:43:52.000000000 +0200
+++ telepathy-mission-control-5-5.12.1/tests/twisted/mctest.py	2012-07-11 12:16:54.000000000 +0200
@@ -1087,6 +1087,16 @@
 
         servicetest.ProxyWrapper.__init__(self, bare_cd, cs.CD, {})
 
+class ChannelDispatchOperation(servicetest.ProxyWrapper):
+    def __init__(self, bus, path):
+        bare_cdo = bus.get_object(cs.CD, path)
+        servicetest.ProxyWrapper.__init__(self, bare_cdo, cs.CDO, {})
+
+class ChannelRequest(servicetest.ProxyWrapper):
+    def __init__(self, bus, path):
+        bare_cr = bus.get_object(cs.CD, path)
+        servicetest.ProxyWrapper.__init__(self, bare_cr, cs.CR, {})
+
 def connect_to_mc(q, bus, mc):
     account_manager = AccountManager(bus)
 
--- telepathy-mission-control-5-5.12.0/tools/telepathy.am	2012-03-08 23:17:57.000000000 +0100
+++ telepathy-mission-control-5-5.12.1/tools/telepathy.am	2012-07-11 12:15:52.000000000 +0200
@@ -45,9 +45,16 @@
 %.tar.gz.asc: %.tar.gz
 	$(AM_V_GEN)gpg --detach-sign --armor $@
 
-@PACKAGE@-@VERSION@.tar.gz: _is-release-check check distcheck
-
-maintainer-prepare-release: _is-release-check all distcheck release-mail
+@PACKAGE@-@VERSION@.tar.gz:
+	$(MAKE) _is-release-check
+	$(MAKE) check
+	$(MAKE) distcheck
+
+maintainer-prepare-release:
+	$(MAKE) _is-release-check
+	$(MAKE) all
+	$(MAKE) distcheck
+	$(MAKE) release-mail
 	git tag -s @PACKAGE@-@VERSION@ -m @PACKAGE@' '@VERSION@
 	gpg --detach-sign --armor @PACKAGE@-@VERSION@.tar.gz
 
@@ -67,7 +74,9 @@
 	rsync -vzP @PACKAGE@-@VERSION@.tar.gz telepathy.freedesktop.org:/srv/telepathy.freedesktop.org/www/releases/@PACKAGE@/@PACKAGE@-@VERSION@.tar.gz
 	rsync -vzP @PACKAGE@-@VERSION@.tar.gz.asc telepathy.freedesktop.org:/srv/telepathy.freedesktop.org/www/releases/@PACKAGE@/@PACKAGE@-@VERSION@.tar.gz.asc
 
-maintainer-make-release: maintainer-prepare-release maintainer-upload-release
+maintainer-make-release:
+	$(MAKE) maintainer-prepare-release
+	$(MAKE) maintainer-upload-release
 	@echo "Now:"
 	@echo " • bump the nano-version;"
 	@echo " • push the branch and tags upstream; and"
