[Pkg-telepathy-commits] [telepathy-glib-1] 51/212: TpDBusDaemon: Remove code for watching names

Simon McVittie smcv at debian.org
Wed May 14 12:08:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-glib-1.

commit f61bd5eee438b338a1e430298285d1026c5077b6
Author: Xavier Claessens <xavier.claessens at collabora.com>
Date:   Wed Mar 26 13:05:39 2014 -0400

    TpDBusDaemon: Remove code for watching names
    
    GDBusConnection provide similar feature already.
    
    Reviewed-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
---
 .../telepathy-glib/telepathy-glib-sections.txt     |   3 -
 telepathy-glib/dbus-daemon.c                       | 360 +--------------------
 telepathy-glib/dbus-daemon.h                       |  11 -
 telepathy-glib/versions/main-1.0.abi               |   2 -
 tests/dbus/dbus.c                                  | 242 --------------
 5 files changed, 1 insertion(+), 617 deletions(-)

diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
index 23b9234..4493bec 100644
--- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
@@ -1929,9 +1929,6 @@ TpDBusDaemonClass
 tp_dbus_daemon_dup
 tp_dbus_daemon_new
 tp_dbus_daemon_get_unique_name
-TpDBusDaemonNameOwnerChangedCb
-tp_dbus_daemon_watch_name_owner
-tp_dbus_daemon_cancel_name_owner_watch
 TpDBusDaemonListNamesCb
 tp_dbus_daemon_list_names
 tp_dbus_daemon_list_activatable_names
diff --git a/telepathy-glib/dbus-daemon.c b/telepathy-glib/dbus-daemon.c
index 0b64018..d22ee0c 100644
--- a/telepathy-glib/dbus-daemon.c
+++ b/telepathy-glib/dbus-daemon.c
@@ -69,8 +69,7 @@ struct _TpDBusDaemon
 
 struct _TpDBusDaemonPrivate
 {
-  /* dup'd name => _NameOwnerWatch */
-  GHashTable *name_owner_watches;
+  gpointer dummy;
 };
 
 G_DEFINE_TYPE (TpDBusDaemon, tp_dbus_daemon, TP_TYPE_PROXY)
@@ -145,319 +144,6 @@ tp_dbus_daemon_new (GDBusConnection *connection)
         NULL));
 }
 
-typedef struct
-{
-  guint id;
-  gchar *last_owner;
-  GArray *callbacks;
-  gsize invoking;
-} _NameOwnerWatch;
-
-typedef struct
-{
-  TpDBusDaemonNameOwnerChangedCb callback;
-  gpointer user_data;
-  GDestroyNotify destroy;
-} _NameOwnerSubWatch;
-
-static void name_owner_watch_free (gpointer p);
-
-static void
-tp_dbus_daemon_maybe_free_name_owner_watch (TpDBusDaemon *self,
-    const gchar *name,
-    _NameOwnerWatch *watch)
-{
-  /* Check to see whether this (callback, user_data) pair is in the watch's
-   * array of callbacks. */
-  GArray *array = watch->callbacks;
-  /* 1 greater than an index into @array, to avoid it going negative: we
-   * iterate in reverse so we can delete elements without needing to adjust
-   * @i to compensate */
-  guint i;
-
-  if (watch->invoking > 0)
-    return;
-
-  DEBUG ("%s: %p (%u callbacks in %p)", name, watch, array->len, array);
-
-  for (i = array->len; i > 0; i--)
-    {
-      _NameOwnerSubWatch *entry = &g_array_index (array,
-          _NameOwnerSubWatch, i - 1);
-
-      if (entry->callback != NULL)
-        continue;
-
-      DEBUG ("compacting expired entry #%u", i - 1);
-
-      if (entry->destroy != NULL)
-        entry->destroy (entry->user_data);
-
-      g_array_remove_index (array, i - 1);
-    }
-
-  if (array->len == 0)
-    {
-      DEBUG ("no more callbacks, removing %p", watch);
-      g_hash_table_remove (self->priv->name_owner_watches, name);
-    }
-}
-
-static void
-_tp_dbus_daemon_name_owner_changed (TpDBusDaemon *self,
-                                    const gchar *name,
-                                    const gchar *new_owner)
-{
-  _NameOwnerWatch *watch = g_hash_table_lookup (self->priv->name_owner_watches,
-      name);
-  GArray *array;
-  guint i;
-
-  if (watch == NULL)
-    return;
-
-  /* This is partly to handle the case where an owner change happens
-   * while GetNameOwner is in flight, partly to be able to optimize by only
-   * calling GetNameOwner if we didn't already know, and partly because of a
-   * dbus-glib bug that means we get every signal twice
-   * (it thinks org.freedesktop.DBus is both a well-known name and a unique
-   * name). */
-  if (!tp_strdiff (watch->last_owner, new_owner))
-    return;
-
-  g_free (watch->last_owner);
-  watch->last_owner = g_strdup (new_owner);
-
-  /* We're calling out to user code which might end up removing its watch;
-   * tell it to be less destructive. Also hold a ref on self, to avoid it
-   * getting removed that way. */
-  array = watch->callbacks;
-  g_object_ref (self);
-  watch->invoking++;
-
-  for (i = 0; i < array->len; i++)
-    {
-      _NameOwnerSubWatch *subwatch = &g_array_index (array,
-          _NameOwnerSubWatch, i);
-
-      if (subwatch->callback != NULL)
-        subwatch->callback (self, name, new_owner, subwatch->user_data);
-    }
-
-  watch->invoking--;
-
-  tp_dbus_daemon_maybe_free_name_owner_watch (self, name, watch);
-  g_object_unref (self);
-}
-
-static void
-_tp_dbus_daemon_name_appeared_cb (GDBusConnection *connection G_GNUC_UNUSED,
-    const gchar *name,
-    const gchar *name_owner,
-    gpointer user_data)
-{
-  DEBUG ("%s is owned by %s", name, name_owner);
-  _tp_dbus_daemon_name_owner_changed (user_data, name, name_owner);
-}
-
-static void
-_tp_dbus_daemon_name_vanished_cb (GDBusConnection *connection,
-    const gchar *name,
-    gpointer user_data)
-{
-  if (tp_proxy_get_invalidated (user_data) != NULL)
-    {
-      /* telepathy-glib has not traditionally called "name owner lost"
-       * callbacks when the D-Bus connection dropped, which applications
-       * might be relying on. tests/dbus/dbus.c certainly does. */
-      DEBUG ("%s (ignoring because %p has been invalidated)", name, user_data);
-    }
-  else
-    {
-      DEBUG ("%s", name);
-      _tp_dbus_daemon_name_owner_changed (user_data, name, "");
-    }
-}
-
-/**
- * TpDBusDaemonNameOwnerChangedCb:
- * @bus_daemon: The D-Bus daemon
- * @name: The name whose ownership has changed or been discovered
- * @new_owner: The unique name that now owns @name
- * @user_data: Arbitrary user-supplied data as passed to
- *  tp_dbus_daemon_watch_name_owner()
- *
- * The signature of the callback called by tp_dbus_daemon_watch_name_owner().
- *
- * Since: 0.7.1
- */
-
-/**
- * tp_dbus_daemon_watch_name_owner:
- * @self: The D-Bus daemon
- * @name: The name whose ownership is to be watched
- * @callback: Callback to call when the ownership is discovered or changes
- * @user_data: Arbitrary data to pass to @callback
- * @destroy: Called to destroy @user_data when the name owner watch is
- *  cancelled due to tp_dbus_daemon_cancel_name_owner_watch()
- *
- * Arrange for @callback to be called with the owner of @name as soon as
- * possible (which might even be before this function returns!), then
- * again every time the ownership of @name changes.
- *
- * If multiple watches are registered for the same @name, they will be called
- * in the order they were registered.
- *
- * New code should use g_bus_watch_name() or similar instead.
- *
- * Since: 0.7.1
- */
-void
-tp_dbus_daemon_watch_name_owner (TpDBusDaemon *self,
-                                 const gchar *name,
-                                 TpDBusDaemonNameOwnerChangedCb callback,
-                                 gpointer user_data,
-                                 GDestroyNotify destroy)
-{
-  _NameOwnerWatch *watch = g_hash_table_lookup (self->priv->name_owner_watches,
-      name);
-  _NameOwnerSubWatch tmp = { callback, user_data, destroy };
-
-  g_return_if_fail (TP_IS_DBUS_DAEMON (self));
-  g_return_if_fail (tp_dbus_check_valid_bus_name (name,
-        TP_DBUS_NAME_TYPE_ANY, NULL));
-  g_return_if_fail (callback != NULL);
-
-  DEBUG ("%s", name);
-
-  if (watch == NULL)
-    {
-      /* Allocate a new watch */
-      watch = g_slice_new0 (_NameOwnerWatch);
-      watch->last_owner = NULL;
-      watch->callbacks = g_array_new (FALSE, FALSE,
-          sizeof (_NameOwnerSubWatch));
-      DEBUG ("- new watch %p (callbacks at %p)", watch, watch->callbacks);
-
-      g_hash_table_insert (self->priv->name_owner_watches, g_strdup (name),
-          watch);
-
-      watch->id = g_bus_watch_name_on_connection (
-          tp_proxy_get_dbus_connection (self),
-          name, G_BUS_NAME_WATCHER_FLAGS_NONE,
-          _tp_dbus_daemon_name_appeared_cb,
-          _tp_dbus_daemon_name_vanished_cb,
-          g_object_ref (self),
-          g_object_unref);
-    }
-  else
-    {
-      DEBUG ("- appending to existing watch %p (callbacks at %p)", watch,
-          watch->callbacks);
-    }
-
-  g_array_append_val (watch->callbacks, tmp);
-
-  if (watch->last_owner != NULL)
-    {
-      /* FIXME: should avoid reentrancy? */
-      DEBUG ("- already owned by %s", watch->last_owner);
-      callback (self, name, watch->last_owner, user_data);
-    }
-}
-
-static void
-name_owner_watch_free (gpointer p)
-{
-  _NameOwnerWatch *watch = p;
-
-  DEBUG ("%p (%u callbacks in %p)", watch, watch->callbacks->len,
-      watch->callbacks);
-
-  /* Clean up any leftöver callbacks. */
-  if (watch->callbacks->len > 0)
-    {
-      guint i;
-
-      for (i = 0; i < watch->callbacks->len; i++)
-        {
-          _NameOwnerSubWatch *entry = &g_array_index (watch->callbacks,
-              _NameOwnerSubWatch, i);
-
-          if (entry->destroy != NULL)
-            entry->destroy (entry->user_data);
-        }
-    }
-
-  g_bus_unwatch_name (watch->id);
-  g_array_unref (watch->callbacks);
-  g_free (watch->last_owner);
-  g_slice_free (_NameOwnerWatch, watch);
-}
-
-/**
- * tp_dbus_daemon_cancel_name_owner_watch: (skip)
- * @self: the D-Bus daemon
- * @name: the name that was being watched
- * @callback: the callback that was called
- * @user_data: the user data that was provided
- *
- * If there was a previous call to tp_dbus_daemon_watch_name_owner()
- * with exactly the given @name, @callback and @user_data, remove it.
- *
- * If more than one watch matching the details provided was active, remove
- * only the most recently added one.
- *
- * Returns: %TRUE if there was such a watch, %FALSE otherwise
- *
- * Since: 0.7.1
- */
-gboolean
-tp_dbus_daemon_cancel_name_owner_watch (TpDBusDaemon *self,
-                                        const gchar *name,
-                                        TpDBusDaemonNameOwnerChangedCb callback,
-                                        gconstpointer user_data)
-{
-  _NameOwnerWatch *watch = g_hash_table_lookup (self->priv->name_owner_watches,
-      name);
-
-  g_return_val_if_fail (TP_IS_DBUS_DAEMON (self), FALSE);
-  g_return_val_if_fail (name != NULL, FALSE);
-  g_return_val_if_fail (callback != NULL, FALSE);
-
-  DEBUG ("%s (%p)", name, watch);
-
-  if (watch != NULL)
-    {
-      /* Check to see whether this (callback, user_data) pair is in the watch's
-       * array of callbacks. */
-      GArray *array = watch->callbacks;
-      /* 1 greater than an index into @array, to avoid it going negative;
-       * we iterate in reverse to have "last in = first out" as documented. */
-      guint i;
-
-      DEBUG ("- %u watch(es) in %p", array->len, array);
-
-      for (i = array->len; i > 0; i--)
-        {
-          _NameOwnerSubWatch *entry = &g_array_index (array,
-              _NameOwnerSubWatch, i - 1);
-
-          if (entry->callback == callback && entry->user_data == user_data)
-            {
-              DEBUG ("- found matching callback and user data (#%u)", i - 1);
-              entry->callback = NULL;
-              tp_dbus_daemon_maybe_free_name_owner_watch (self, name, watch);
-              return TRUE;
-            }
-        }
-    }
-
-  /* We haven't found it */
-  DEBUG ("- did not find matching callback and user data");
-  return FALSE;
-}
-
 /* for internal use (TpChannel, TpConnection _new convenience functions) */
 gboolean
 _tp_dbus_daemon_get_name_owner (TpDBusDaemon *self,
@@ -1047,48 +733,6 @@ tp_dbus_daemon_init (TpDBusDaemon *self)
 {
   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TYPE_DBUS_DAEMON,
       TpDBusDaemonPrivate);
-
-  self->priv->name_owner_watches = g_hash_table_new_full (g_str_hash,
-      g_str_equal, g_free, name_owner_watch_free);
-}
-
-static void
-tp_dbus_daemon_dispose (GObject *object)
-{
-  TpDBusDaemon *self = TP_DBUS_DAEMON (object);
-
-  if (self->priv->name_owner_watches != NULL)
-    {
-      GHashTable *tmp = self->priv->name_owner_watches;
-      GHashTableIter iter;
-      gpointer k, v;
-
-      self->priv->name_owner_watches = NULL;
-      g_hash_table_iter_init (&iter, tmp);
-
-      while (g_hash_table_iter_next (&iter, &k, &v))
-        {
-          _NameOwnerWatch *watch = v;
-
-          /* it refs us while invoking stuff */
-          g_assert (watch->invoking == 0);
-          DEBUG ("removing watch for %s: %p", (gchar *) k, watch);
-          g_hash_table_iter_remove (&iter);
-        }
-
-      g_hash_table_unref (tmp);
-    }
-
-  G_OBJECT_CLASS (tp_dbus_daemon_parent_class)->dispose (object);
-}
-
-static void
-tp_dbus_daemon_finalize (GObject *object)
-{
-  GObjectFinalizeFunc chain_up = G_OBJECT_CLASS (tp_dbus_daemon_parent_class)->finalize;
-
-  if (chain_up != NULL)
-    chain_up (object);
 }
 
 static void
@@ -1100,8 +744,6 @@ tp_dbus_daemon_class_init (TpDBusDaemonClass *klass)
   g_type_class_add_private (klass, sizeof (TpDBusDaemonPrivate));
 
   object_class->constructor = tp_dbus_daemon_constructor;
-  object_class->dispose = tp_dbus_daemon_dispose;
-  object_class->finalize = tp_dbus_daemon_finalize;
 
   proxy_class->interface = TP_IFACE_QUARK_DBUS_DAEMON;
 }
diff --git a/telepathy-glib/dbus-daemon.h b/telepathy-glib/dbus-daemon.h
index e576ca4..f931eb3 100644
--- a/telepathy-glib/dbus-daemon.h
+++ b/telepathy-glib/dbus-daemon.h
@@ -57,17 +57,6 @@ TpDBusDaemon *tp_dbus_daemon_dup (GError **error) G_GNUC_WARN_UNUSED_RESULT;
 TpDBusDaemon *tp_dbus_daemon_new (GDBusConnection *connection)
   G_GNUC_WARN_UNUSED_RESULT;
 
-typedef void (*TpDBusDaemonNameOwnerChangedCb) (TpDBusDaemon *bus_daemon,
-    const gchar *name, const gchar *new_owner, gpointer user_data);
-
-void tp_dbus_daemon_watch_name_owner (TpDBusDaemon *self,
-    const gchar *name, TpDBusDaemonNameOwnerChangedCb callback,
-    gpointer user_data, GDestroyNotify destroy);
-
-gboolean tp_dbus_daemon_cancel_name_owner_watch (TpDBusDaemon *self,
-    const gchar *name, TpDBusDaemonNameOwnerChangedCb callback,
-    gconstpointer user_data);
-
 gboolean tp_dbus_daemon_request_name (TpDBusDaemon *self,
     const gchar *well_known_name, gboolean idempotent, GError **error);
 gboolean tp_dbus_daemon_release_name (TpDBusDaemon *self,
diff --git a/telepathy-glib/versions/main-1.0.abi b/telepathy-glib/versions/main-1.0.abi
index 9dce01d..1cfc872 100644
--- a/telepathy-glib/versions/main-1.0.abi
+++ b/telepathy-glib/versions/main-1.0.abi
@@ -796,7 +796,6 @@ tp_dbus_check_valid_bus_name
 tp_dbus_check_valid_interface_name
 tp_dbus_check_valid_member_name
 tp_dbus_check_valid_object_path
-tp_dbus_daemon_cancel_name_owner_watch
 tp_dbus_daemon_dup
 tp_dbus_daemon_get_type
 tp_dbus_daemon_get_unique_name
@@ -808,7 +807,6 @@ tp_dbus_daemon_release_name
 tp_dbus_daemon_request_name
 tp_dbus_daemon_try_register_object
 tp_dbus_daemon_unregister_object
-tp_dbus_daemon_watch_name_owner
 tp_dbus_errors_quark
 tp_dbus_properties_mixin_class_init
 tp_dbus_properties_mixin_dup_all
diff --git a/tests/dbus/dbus.c b/tests/dbus/dbus.c
index 2cd7b21..15a6322 100644
--- a/tests/dbus/dbus.c
+++ b/tests/dbus/dbus.c
@@ -132,245 +132,6 @@ test_properties (void)
   g_object_unref (bus);
 }
 
-static GPtrArray *events;
-static GMainLoop *mainloop;
-static gchar *two = "2", *five = "5";
-static gboolean had_owners = FALSE;
-
-static gboolean
-request_names (gpointer obj)
-{
-  GError *error = NULL;
-  guint ret;
-  gboolean ok;
-
-  ok = tp_cli_dbus_daemon_run_request_name (obj, -1,
-        "com.example", 0, &ret, &error, NULL);
-  g_assert_no_error (error);
-  g_assert (ok);
-  g_assert_cmpuint (ret, ==, 1);
-
-  ok = tp_cli_dbus_daemon_run_request_name (obj, -1,
-        "org.example", 0, &ret, &error, NULL);
-  g_assert_no_error (error);
-  g_assert (ok);
-  g_assert_cmpuint (ret, ==, 1);
-
-  ok = tp_cli_dbus_daemon_run_request_name (obj, -1,
-        "net.example", 0, &ret, &error, NULL);
-  g_assert_no_error (error);
-  g_assert (ok);
-  g_assert_cmpuint (ret, ==, 1);
-
-  return FALSE;
-}
-
-static gboolean
-release_names (gpointer obj)
-{
-  GError *error = NULL;
-  guint ret;
-  gboolean ok;
-
-  ok = tp_cli_dbus_daemon_run_release_name (obj, -1,
-        "org.example", &ret, &error, NULL);
-  g_assert_no_error (error);
-  g_assert (ok);
-  g_assert_cmpuint (ret, ==, 1);
-
-  ok = tp_cli_dbus_daemon_run_release_name (obj, -1,
-        "net.example", &ret, &error, NULL);
-  g_assert_no_error (error);
-  g_assert (ok);
-  g_assert_cmpuint (ret, ==, 1);
-
-  return FALSE;
-}
-
-static void
-noc (TpDBusDaemon *obj,
-     const gchar *name,
-     const gchar *new_owner,
-     gpointer user_data)
-{
-  const gchar *tag = user_data;
-
-  g_message ("[%s] %s -> <%s>", tag, name, new_owner);
-
-  g_ptr_array_add (events, g_strdup_printf ("[%s] %s %d",
-        tag, name, new_owner[0]));
-
-  if (new_owner[0] != '\0')
-    had_owners = TRUE;
-
-  if (!tp_strdiff (name, "net.example"))
-    {
-      if (new_owner[0] == '\0')
-        {
-          if (had_owners)
-            {
-              g_main_loop_quit (mainloop);
-            }
-          else
-            {
-              /* do it in an idle: re-entering this same watch callback
-               * doesn't seem to work under GDBus, and it was a terrible
-               * idea anyway */
-              g_idle_add_full (G_PRIORITY_DEFAULT,
-                  request_names, g_object_ref (obj), g_object_unref);
-            }
-        }
-      else
-        {
-          gboolean ok;
-
-          ok = tp_dbus_daemon_cancel_name_owner_watch (obj,
-                "org.example", noc, five);
-          g_assert (ok);
-
-          g_idle_add_full (G_PRIORITY_DEFAULT,
-              release_names, g_object_ref (obj), g_object_unref);
-        }
-    }
-}
-
-static void
-test_watch_name_owner (void)
-{
-  TpDBusDaemon *bus = tp_dbus_daemon_dup (NULL);
-  guint i;
-
-  events = g_ptr_array_new ();
-
-  tp_dbus_daemon_watch_name_owner (bus, "com.example", noc, "1", NULL);
-  tp_dbus_daemon_watch_name_owner (bus, "com.example", noc, two, NULL);
-  tp_dbus_daemon_watch_name_owner (bus, "com.example", noc, "3", NULL);
-  tp_dbus_daemon_cancel_name_owner_watch (bus, "com.example", noc, two);
-  tp_dbus_daemon_watch_name_owner (bus, "net.example", noc, "4", NULL);
-  tp_dbus_daemon_watch_name_owner (bus, "org.example", noc, five, NULL);
-
-  mainloop = g_main_loop_new (NULL, FALSE);
-  g_main_loop_run (mainloop);
-
-  g_assert_cmpuint (events->len, ==, 9);
-
-  /* 58 == ':' - i.e. the beginning of a unique name */
-  g_assert_cmpstr (g_ptr_array_index (events, 0), ==, "[1] com.example 0");
-  g_assert_cmpstr (g_ptr_array_index (events, 1), ==, "[3] com.example 0");
-  g_assert_cmpstr (g_ptr_array_index (events, 2), ==, "[4] net.example 0");
-  g_assert_cmpstr (g_ptr_array_index (events, 3), ==, "[5] org.example 0");
-
-  g_assert_cmpstr (g_ptr_array_index (events, 4), ==, "[1] com.example 58");
-  g_assert_cmpstr (g_ptr_array_index (events, 5), ==, "[3] com.example 58");
-  g_assert_cmpstr (g_ptr_array_index (events, 6), ==, "[5] org.example 58");
-  g_assert_cmpstr (g_ptr_array_index (events, 7), ==, "[4] net.example 58");
-  g_assert_cmpstr (g_ptr_array_index (events, 8), ==, "[4] net.example 0");
-
-  /* keep valgrind happy, at least in the successful case */
-  for (i = 0; i < events->len; i++)
-    {
-      g_free (events->pdata[i]);
-    }
-
-  g_ptr_array_unref (events);
-  g_main_loop_unref (mainloop);
-  mainloop = NULL;
-}
-
-/* Here's a regression test for a bug where, if a name owner watch callback
- * removes itself, subsequent callbacks for the same change would not fire.
- * This was because the implementation was an array of callbacks, with an index
- * i, calling each in turn. So imagine we're dispatching three callbacks,
- * starting with 'foo':
- *
- *   | foo | bar | baz |
- *     i=0
- *
- * If 'foo' cancels its own watch, it would be removed from the array. Then the
- * iteration would continue by incrementing i:
- *
- *   | bar | baz |
- *           i=1
- *
- * and 'bar' has not been called! Gulp. This test checks this case by setting
- * up ten numbered callbacks, each one of which removes itself and itself ±1,
- * so that each of (0, 1), (2, 3), (4, 5), (6, 7), (8, 9) should fire exactly
- * once. It should work regardless of the internal order of callbacks.
- */
-#define N_CALLBACK_PAIRS 5
-gboolean callbacks_fired[N_CALLBACK_PAIRS] =
-    { FALSE, FALSE, FALSE, FALSE, FALSE };
-/* Overwritten with '.' when "freed" */
-gchar user_data_flags[N_CALLBACK_PAIRS * 2 + 1] = "0123456789";
-
-static void
-free_fake_user_data (gpointer user_data)
-{
-  guint i = GPOINTER_TO_UINT (user_data);
-
-  if (user_data_flags[i] == '.')
-    g_error ("Double 'free' of user-data %u. Still to free: %s", i,
-        user_data_flags);
-
-  g_assert_cmpuint ((guint) user_data_flags[i], ==, i + '0');
-  user_data_flags[i] = '.';
-}
-
-static void
-bbf3_performed_cb (
-    TpDBusDaemon *bus_daemon,
-    const gchar *name,
-    const gchar *new_owner,
-    gpointer user_data)
-{
-  guint i = GPOINTER_TO_UINT (user_data);
-  guint even = i - (i % 2);
-  guint odd = even + 1;
-  guint j;
-
-  g_message ("%u fired; cancelling %u and %u", i, even, odd);
-  tp_dbus_daemon_cancel_name_owner_watch (bus_daemon, name, bbf3_performed_cb,
-      GUINT_TO_POINTER (even));
-  tp_dbus_daemon_cancel_name_owner_watch (bus_daemon, name, bbf3_performed_cb,
-      GUINT_TO_POINTER (odd));
-
-  g_assert (!callbacks_fired[even / 2]);
-  callbacks_fired[even / 2] = TRUE;
-
-  for (j = 0; j < N_CALLBACK_PAIRS; j++)
-    if (!callbacks_fired[j])
-      {
-        g_message ("still waiting for %u or %u, at least", j * 2, j * 2 + 1);
-        return;
-      }
-
-  g_main_loop_quit (mainloop);
-}
-
-static void
-cancel_watch_during_dispatch (void)
-{
-  TpDBusDaemon *bus = tp_dbus_daemon_dup (NULL);
-  guint i;
-
-  tp_dbus_daemon_request_name (bus, "ca.bbf3", FALSE, NULL);
-
-  for (i = 0; i < N_CALLBACK_PAIRS * 2; i++)
-    {
-      tp_dbus_daemon_watch_name_owner (bus, "ca.bbf3", bbf3_performed_cb,
-          GUINT_TO_POINTER (i), free_fake_user_data);
-      g_assert_cmpuint ((guint) user_data_flags[i], ==, i + '0');
-    }
-
-  mainloop = g_main_loop_new (NULL, FALSE);
-  g_main_loop_run (mainloop);
-  g_main_loop_unref (mainloop);
-  g_object_unref (bus);
-
-  /* everything should have been "freed" */
-  g_assert_cmpstr (user_data_flags, ==, "..........");
-}
-
 int
 main (int argc,
       char **argv)
@@ -379,9 +140,6 @@ main (int argc,
 
   g_test_add_func ("/dbus/validation", test_validation);
   g_test_add_func ("/dbus-daemon/properties", test_properties);
-  g_test_add_func ("/dbus-daemon/watch-name-owner", test_watch_name_owner);
-  g_test_add_func ("/dbus-daemon/cancel-watch-during-dispatch",
-      cancel_watch_during_dispatch);
 
   return tp_tests_run_with_bus ();
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-glib-1.git



More information about the Pkg-telepathy-commits mailing list