[telepathy-glib/master] spec 0.17.26 classes: make safe to extend

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Jun 10 07:20:08 PDT 2009


---
 telepathy-glib/account-manager.c            |   37 ++++++++++++++++++++++---
 telepathy-glib/account-manager.h            |    2 +
 telepathy-glib/account.c                    |   37 ++++++++++++++++++++++---
 telepathy-glib/account.h                    |    2 +
 telepathy-glib/channel-dispatch-operation.c |   38 +++++++++++++++++++++++---
 telepathy-glib/channel-dispatch-operation.h |    2 +
 telepathy-glib/channel-dispatcher.c         |   37 ++++++++++++++++++++++---
 telepathy-glib/channel-dispatcher.h         |    2 +
 telepathy-glib/channel-request.c            |   37 ++++++++++++++++++++++---
 telepathy-glib/channel-request.h            |    2 +
 telepathy-glib/client.c                     |   37 ++++++++++++++++++++++---
 telepathy-glib/client.h                     |    2 +
 12 files changed, 205 insertions(+), 30 deletions(-)

diff --git a/telepathy-glib/account-manager.c b/telepathy-glib/account-manager.c
index 0817c1a..72346a5 100644
--- a/telepathy-glib/account-manager.c
+++ b/telepathy-glib/account-manager.c
@@ -97,7 +97,6 @@ tp_account_manager_constructed (GObject *object)
 static void
 tp_account_manager_class_init (TpAccountManagerClass *klass)
 {
-  GType tp_type = TP_TYPE_ACCOUNT_MANAGER;
   TpProxyClass *proxy_class = (TpProxyClass *) klass;
   GObjectClass *object_class = (GObjectClass *) klass;
 
@@ -106,10 +105,38 @@ tp_account_manager_class_init (TpAccountManagerClass *klass)
   object_class->constructed = tp_account_manager_constructed;
 
   proxy_class->interface = TP_IFACE_QUARK_ACCOUNT_MANAGER;
-  tp_proxy_or_subclass_hook_on_interface_add (tp_type,
-      tp_cli_account_manager_add_signals);
-  tp_proxy_subclass_add_error_mapping (tp_type,
-      TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
+  tp_account_manager_init_known_interfaces ();
+}
+
+/**
+ * tp_account_manager_init_known_interfaces:
+ *
+ * Ensure that the known interfaces for TpAccountManager have been set up.
+ * This is done automatically when necessary, but for correct
+ * overriding of library interfaces by local extensions, you should
+ * call this function before calling
+ * tp_proxy_or_subclass_hook_on_interface_add() with first argument
+ * %TP_TYPE_ACCOUNT_MANAGER.
+ *
+ * Since: 0.7.UNRELEASED
+ */
+void
+tp_account_manager_init_known_interfaces (void)
+{
+  static gsize once = 0;
+
+  if (g_once_init_enter (&once))
+    {
+      GType tp_type = TP_TYPE_ACCOUNT_MANAGER;
+
+      tp_proxy_init_known_interfaces ();
+      tp_proxy_or_subclass_hook_on_interface_add (tp_type,
+          tp_cli_account_manager_add_signals);
+      tp_proxy_subclass_add_error_mapping (tp_type,
+          TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
+
+      g_once_init_leave (&once, 1);
+    }
 }
 
 /**
diff --git a/telepathy-glib/account-manager.h b/telepathy-glib/account-manager.h
index f7e84b2..f96321a 100644
--- a/telepathy-glib/account-manager.h
+++ b/telepathy-glib/account-manager.h
@@ -65,6 +65,8 @@ GType tp_account_manager_get_type (void);
 
 TpAccountManager *tp_account_manager_new (TpDBusDaemon *bus_daemon);
 
+void tp_account_manager_init_known_interfaces (void);
+
 G_END_DECLS
 
 #include <telepathy-glib/_gen/tp-cli-account-manager.h>
diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index 295fb42..3754ba2 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -132,7 +132,6 @@ tp_account_constructed (GObject *object)
 static void
 tp_account_class_init (TpAccountClass *klass)
 {
-  GType tp_type = TP_TYPE_ACCOUNT;
   TpProxyClass *proxy_class = (TpProxyClass *) klass;
   GObjectClass *object_class = (GObjectClass *) klass;
 
@@ -141,10 +140,38 @@ tp_account_class_init (TpAccountClass *klass)
   object_class->constructed = tp_account_constructed;
 
   proxy_class->interface = TP_IFACE_QUARK_ACCOUNT;
-  tp_proxy_or_subclass_hook_on_interface_add (tp_type,
-      tp_cli_account_add_signals);
-  tp_proxy_subclass_add_error_mapping (tp_type,
-      TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
+  tp_account_init_known_interfaces ();
+}
+
+/**
+ * tp_account_init_known_interfaces:
+ *
+ * Ensure that the known interfaces for TpAccount have been set up.
+ * This is done automatically when necessary, but for correct
+ * overriding of library interfaces by local extensions, you should
+ * call this function before calling
+ * tp_proxy_or_subclass_hook_on_interface_add() with first argument
+ * %TP_TYPE_ACCOUNT.
+ *
+ * Since: 0.7.UNRELEASED
+ */
+void
+tp_account_init_known_interfaces (void)
+{
+  static gsize once = 0;
+
+  if (g_once_init_enter (&once))
+    {
+      GType tp_type = TP_TYPE_ACCOUNT;
+
+      tp_proxy_init_known_interfaces ();
+      tp_proxy_or_subclass_hook_on_interface_add (tp_type,
+          tp_cli_account_add_signals);
+      tp_proxy_subclass_add_error_mapping (tp_type,
+          TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
+
+      g_once_init_leave (&once, 1);
+    }
 }
 
 /**
diff --git a/telepathy-glib/account.h b/telepathy-glib/account.h
index 3d6e629..4072d75 100644
--- a/telepathy-glib/account.h
+++ b/telepathy-glib/account.h
@@ -66,6 +66,8 @@ GType tp_account_get_type (void);
 TpAccount *tp_account_new (TpDBusDaemon *bus_daemon, const gchar *object_path,
     GError **error);
 
+void tp_account_init_known_interfaces (void);
+
 G_END_DECLS
 
 #include <telepathy-glib/_gen/tp-cli-account.h>
diff --git a/telepathy-glib/channel-dispatch-operation.c b/telepathy-glib/channel-dispatch-operation.c
index f47a14c..cf7fc3a 100644
--- a/telepathy-glib/channel-dispatch-operation.c
+++ b/telepathy-glib/channel-dispatch-operation.c
@@ -157,7 +157,6 @@ tp_channel_dispatch_operation_constructed (GObject *object)
 static void
 tp_channel_dispatch_operation_class_init (TpChannelDispatchOperationClass *klass)
 {
-  GType tp_type = TP_TYPE_CHANNEL_DISPATCH_OPERATION;
   TpProxyClass *proxy_class = (TpProxyClass *) klass;
   GObjectClass *object_class = (GObjectClass *) klass;
 
@@ -166,11 +165,40 @@ tp_channel_dispatch_operation_class_init (TpChannelDispatchOperationClass *klass
   object_class->constructed = tp_channel_dispatch_operation_constructed;
 
   proxy_class->interface = TP_IFACE_QUARK_CHANNEL_DISPATCH_OPERATION;
-  tp_proxy_or_subclass_hook_on_interface_add (tp_type,
-      tp_cli_channel_dispatch_operation_add_signals);
-  tp_proxy_subclass_add_error_mapping (tp_type,
-      TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
   proxy_class->must_have_unique_name = TRUE;
+
+  tp_channel_dispatch_operation_init_known_interfaces ();
+}
+
+/**
+ * tp_channel_dispatch_operation_init_known_interfaces:
+ *
+ * Ensure that the known interfaces for TpChannelDispatchOperation have been
+ * set up. This is done automatically when necessary, but for correct
+ * overriding of library interfaces by local extensions, you should
+ * call this function before calling
+ * tp_proxy_or_subclass_hook_on_interface_add() with first argument
+ * %TP_TYPE_CHANNEL_DISPATCH_OPERATION.
+ *
+ * Since: 0.7.UNRELEASED
+ */
+void
+tp_channel_dispatch_operation_init_known_interfaces (void)
+{
+  static gsize once = 0;
+
+  if (g_once_init_enter (&once))
+    {
+      GType tp_type = TP_TYPE_CHANNEL_DISPATCH_OPERATION;
+
+      tp_proxy_init_known_interfaces ();
+      tp_proxy_or_subclass_hook_on_interface_add (tp_type,
+          tp_cli_channel_dispatch_operation_add_signals);
+      tp_proxy_subclass_add_error_mapping (tp_type,
+          TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
+
+      g_once_init_leave (&once, 1);
+    }
 }
 
 /**
diff --git a/telepathy-glib/channel-dispatch-operation.h b/telepathy-glib/channel-dispatch-operation.h
index aaa5085..f9bc585 100644
--- a/telepathy-glib/channel-dispatch-operation.h
+++ b/telepathy-glib/channel-dispatch-operation.h
@@ -71,6 +71,8 @@ TpChannelDispatchOperation *tp_channel_dispatch_operation_new (
     TpDBusDaemon *bus_daemon, const gchar *object_path,
     GHashTable *immutable_properties, GError **error);
 
+void tp_channel_dispatch_operation_init_known_interfaces (void);
+
 G_END_DECLS
 
 #include <telepathy-glib/_gen/tp-cli-channel-dispatch-operation.h>
diff --git a/telepathy-glib/channel-dispatcher.c b/telepathy-glib/channel-dispatcher.c
index 7ec49d8..d688b87 100644
--- a/telepathy-glib/channel-dispatcher.c
+++ b/telepathy-glib/channel-dispatcher.c
@@ -100,7 +100,6 @@ tp_channel_dispatcher_constructed (GObject *object)
 static void
 tp_channel_dispatcher_class_init (TpChannelDispatcherClass *klass)
 {
-  GType tp_type = TP_TYPE_CHANNEL_DISPATCHER;
   TpProxyClass *proxy_class = (TpProxyClass *) klass;
   GObjectClass *object_class = (GObjectClass *) klass;
 
@@ -109,10 +108,38 @@ tp_channel_dispatcher_class_init (TpChannelDispatcherClass *klass)
   object_class->constructed = tp_channel_dispatcher_constructed;
 
   proxy_class->interface = TP_IFACE_QUARK_CHANNEL_DISPATCHER;
-  tp_proxy_or_subclass_hook_on_interface_add (tp_type,
-      tp_cli_channel_dispatcher_add_signals);
-  tp_proxy_subclass_add_error_mapping (tp_type,
-      TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
+  tp_channel_dispatcher_init_known_interfaces ();
+}
+
+/**
+ * tp_channel_dispatcher_init_known_interfaces:
+ *
+ * Ensure that the known interfaces for TpChannelDispatcher have been set up.
+ * This is done automatically when necessary, but for correct
+ * overriding of library interfaces by local extensions, you should
+ * call this function before calling
+ * tp_proxy_or_subclass_hook_on_interface_add() with first argument
+ * %TP_TYPE_CHANNEL_DISPATCHER.
+ *
+ * Since: 0.7.UNRELEASED
+ */
+void
+tp_channel_dispatcher_init_known_interfaces (void)
+{
+  static gsize once = 0;
+
+  if (g_once_init_enter (&once))
+    {
+      GType tp_type = TP_TYPE_CHANNEL_DISPATCHER;
+
+      tp_proxy_init_known_interfaces ();
+      tp_proxy_or_subclass_hook_on_interface_add (tp_type,
+          tp_cli_channel_dispatcher_add_signals);
+      tp_proxy_subclass_add_error_mapping (tp_type,
+          TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
+
+      g_once_init_leave (&once, 1);
+    }
 }
 
 /**
diff --git a/telepathy-glib/channel-dispatcher.h b/telepathy-glib/channel-dispatcher.h
index 197cd18..b886916 100644
--- a/telepathy-glib/channel-dispatcher.h
+++ b/telepathy-glib/channel-dispatcher.h
@@ -66,6 +66,8 @@ GType tp_channel_dispatcher_get_type (void);
 
 TpChannelDispatcher *tp_channel_dispatcher_new (TpDBusDaemon *bus_daemon);
 
+void tp_channel_dispatcher_init_known_interfaces (void);
+
 G_END_DECLS
 
 #include <telepathy-glib/_gen/tp-cli-channel-dispatcher.h>
diff --git a/telepathy-glib/channel-request.c b/telepathy-glib/channel-request.c
index 45ad969..a2992f6 100644
--- a/telepathy-glib/channel-request.c
+++ b/telepathy-glib/channel-request.c
@@ -167,7 +167,6 @@ tp_channel_request_constructed (GObject *object)
 static void
 tp_channel_request_class_init (TpChannelRequestClass *klass)
 {
-  GType tp_type = TP_TYPE_CHANNEL_REQUEST;
   TpProxyClass *proxy_class = (TpProxyClass *) klass;
   GObjectClass *object_class = (GObjectClass *) klass;
 
@@ -176,10 +175,7 @@ tp_channel_request_class_init (TpChannelRequestClass *klass)
   object_class->constructed = tp_channel_request_constructed;
 
   proxy_class->interface = TP_IFACE_QUARK_CHANNEL_REQUEST;
-  tp_proxy_or_subclass_hook_on_interface_add (tp_type,
-      tp_cli_channel_request_add_signals);
-  tp_proxy_subclass_add_error_mapping (tp_type,
-      TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
+  tp_channel_request_init_known_interfaces ();
   proxy_class->must_have_unique_name = TRUE;
 
   /**
@@ -198,6 +194,37 @@ tp_channel_request_class_init (TpChannelRequestClass *klass)
 }
 
 /**
+ * tp_channel_request_init_known_interfaces:
+ *
+ * Ensure that the known interfaces for TpChannelRequest have been set up.
+ * This is done automatically when necessary, but for correct
+ * overriding of library interfaces by local extensions, you should
+ * call this function before calling
+ * tp_proxy_or_subclass_hook_on_interface_add() with first argument
+ * %TP_TYPE_CHANNEL_REQUEST.
+ *
+ * Since: 0.7.UNRELEASED
+ */
+void
+tp_channel_request_init_known_interfaces (void)
+{
+  static gsize once = 0;
+
+  if (g_once_init_enter (&once))
+    {
+      GType tp_type = TP_TYPE_CHANNEL_REQUEST;
+
+      tp_proxy_init_known_interfaces ();
+      tp_proxy_or_subclass_hook_on_interface_add (tp_type,
+          tp_cli_channel_request_add_signals);
+      tp_proxy_subclass_add_error_mapping (tp_type,
+          TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
+
+      g_once_init_leave (&once, 1);
+    }
+}
+
+/**
  * tp_channel_request_new:
  * @bus_daemon: Proxy for the D-Bus daemon
  * @object_path: The non-NULL object path of this channel request
diff --git a/telepathy-glib/channel-request.h b/telepathy-glib/channel-request.h
index 50c9ce7..1c37d5f 100644
--- a/telepathy-glib/channel-request.h
+++ b/telepathy-glib/channel-request.h
@@ -67,6 +67,8 @@ TpChannelRequest *tp_channel_request_new (TpDBusDaemon *bus_daemon,
     const gchar *object_path, GHashTable *immutable_properties,
     GError **error);
 
+void tp_channel_request_init_known_interfaces (void);
+
 G_END_DECLS
 
 #include <telepathy-glib/_gen/tp-cli-channel-request.h>
diff --git a/telepathy-glib/client.c b/telepathy-glib/client.c
index 5927d91..ae88a56 100644
--- a/telepathy-glib/client.c
+++ b/telepathy-glib/client.c
@@ -98,7 +98,6 @@ tp_client_constructed (GObject *object)
 static void
 tp_client_class_init (TpClientClass *klass)
 {
-  GType tp_type = TP_TYPE_CLIENT;
   TpProxyClass *proxy_class = (TpProxyClass *) klass;
   GObjectClass *object_class = (GObjectClass *) klass;
 
@@ -107,8 +106,36 @@ tp_client_class_init (TpClientClass *klass)
   object_class->constructed = tp_client_constructed;
 
   proxy_class->interface = TP_IFACE_QUARK_CLIENT;
-  tp_proxy_or_subclass_hook_on_interface_add (tp_type,
-      tp_cli_client_add_signals);
-  tp_proxy_subclass_add_error_mapping (tp_type,
-      TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
+  tp_client_init_known_interfaces ();
+}
+
+/**
+ * tp_client_init_known_interfaces:
+ *
+ * Ensure that the known interfaces for TpClient have been set up.
+ * This is done automatically when necessary, but for correct
+ * overriding of library interfaces by local extensions, you should
+ * call this function before calling
+ * tp_proxy_or_subclass_hook_on_interface_add() with first argument
+ * %TP_TYPE_CLIENT.
+ *
+ * Since: 0.7.UNRELEASED
+ */
+void
+tp_client_init_known_interfaces (void)
+{
+  static gsize once = 0;
+
+  if (g_once_init_enter (&once))
+    {
+      GType tp_type = TP_TYPE_CLIENT;
+
+      tp_proxy_init_known_interfaces ();
+      tp_proxy_or_subclass_hook_on_interface_add (tp_type,
+          tp_cli_client_add_signals);
+      tp_proxy_subclass_add_error_mapping (tp_type,
+          TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
+
+      g_once_init_leave (&once, 1);
+    }
 }
diff --git a/telepathy-glib/client.h b/telepathy-glib/client.h
index fc88aef..49d5ec9 100644
--- a/telepathy-glib/client.h
+++ b/telepathy-glib/client.h
@@ -63,6 +63,8 @@ GType tp_client_get_type (void);
   (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_CLIENT, \
                               TpClientClass))
 
+void tp_client_init_known_interfaces (void);
+
 G_END_DECLS
 
 #include <telepathy-glib/_gen/tp-cli-client.h>
-- 
1.5.6.5




More information about the telepathy-commits mailing list