[telepathy-glib/master] Forbid _add_interface_by_id after invalidation.

Will Thompson will.thompson at collabora.co.uk
Fri May 15 09:09:59 PDT 2009


Also, removing the corresponding regression test added a few patches
ago because this is now illegal.
---
 telepathy-glib/proxy.c           |    4 ++-
 tests/dbus/Makefile.am           |    4 --
 tests/dbus/invalidate-add-call.c |   65 --------------------------------------
 3 files changed, 3 insertions(+), 70 deletions(-)
 delete mode 100644 tests/dbus/invalidate-add-call.c

diff --git a/telepathy-glib/proxy.c b/telepathy-glib/proxy.c
index c6d24c5..658880b 100644
--- a/telepathy-glib/proxy.c
+++ b/telepathy-glib/proxy.c
@@ -479,7 +479,7 @@ tp_proxy_iface_destroyed_cb (DBusGProxy *dgproxy,
 
 /**
  * tp_proxy_add_interface_by_id:
- * @self: the TpProxy
+ * @self: the TpProxy, which must not have become #TpProxy::invalidated.
  * @interface: quark representing the interface to be added
  *
  * Declare that this proxy supports a given interface.
@@ -510,6 +510,8 @@ tp_proxy_add_interface_by_id (TpProxy *self,
           NULL),
        NULL);
 
+  g_return_val_if_fail (NULL == tp_proxy_get_invalidated (self), NULL);
+
   if (iface_proxy == NULL)
     {
       /* we don't want to actually create it just yet - dbus-glib will
diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index f01648a..049d550 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -23,7 +23,6 @@ noinst_PROGRAMS = \
     test-get-interface-after-invalidate \
     test-group-mixin \
     test-handle-set \
-    test-invalidate-add-call \
     test-invalidated-while-invoking-signals \
     test-message-mixin \
     test-params-cm \
@@ -94,9 +93,6 @@ test_group_mixin_SOURCES = group-mixin.c
 
 test_handle_set_SOURCES = handle-set.c
 
-test_invalidate_add_call_SOURCES = \
-    invalidate-add-call.c
-
 test_invalidated_while_invoking_signals_SOURCES = \
     invalidated-while-invoking-signals.c
 
diff --git a/tests/dbus/invalidate-add-call.c b/tests/dbus/invalidate-add-call.c
deleted file mode 100644
index 3d5056b..0000000
--- a/tests/dbus/invalidate-add-call.c
+++ /dev/null
@@ -1,65 +0,0 @@
-#include <glib-object.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/debug.h>
-#include <telepathy-glib/errors.h>
-#include <telepathy-glib/interfaces.h>
-#include <telepathy-glib/proxy.h>
-#include <telepathy-glib/proxy-subclass.h>
-#include <telepathy-glib/util.h>
-
-#include "_gen/svc.h"
-#include "tests/lib/myassert.h"
-
-int
-main (int argc, char **argv)
-{
-  DBusGConnection *bus;
-  TpProxy *proxy;
-  GValue *value;
-  GError e = { TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "gabba gabba hey" };
-  GError *error = NULL;
-
-  tp_debug_set_flags ("all");
-  g_type_init ();
-  bus = tp_get_bus ();
-
-  /* Open a D-Bus connection to myself */
-  proxy = TP_PROXY (g_object_new (TP_TYPE_PROXY,
-      "dbus-connection", bus,
-      "bus-name",
-          dbus_bus_get_unique_name (dbus_g_connection_get_connection (bus)),
-      "object-path", "/",
-      NULL));
-
-  MYASSERT (tp_proxy_has_interface (proxy, "org.freedesktop.DBus.Properties"),
-      "");
-
-  /* Invalidate it */
-  tp_proxy_invalidate (proxy, &e);
-
-  MYASSERT (!tp_proxy_has_interface (proxy, "org.freedesktop.DBus.Properties"),
-      "");
-
-  /* Now forcibly re-add the Properties interface... */
-  tp_proxy_add_interface_by_id (proxy, TP_IFACE_QUARK_DBUS_PROPERTIES);
-
-  MYASSERT (tp_proxy_has_interface (proxy, "org.freedesktop.DBus.Properties"),
-      "");
-
-  /* ...and try to call a method on it, which should fail immediately with the
-   * given invalidation reason.
-   */
-  MYASSERT (!tp_cli_dbus_properties_run_get (proxy, -1,
-        "com.example.WithProperties", "ReadOnly", &value, &error, NULL), "");
-  MYASSERT_SAME_ERROR (error, &e);
-
-  g_error_free (error);
-
-  g_object_unref (proxy);
-
-  return 0;
-}
-- 
1.5.6.5




More information about the telepathy-commits mailing list