summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2014-03-29 21:11:49 -0400
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-01 14:36:48 +0100
commit955a87b38625cf6fc74676c0b1a218069d14b75f (patch)
tree94e3a7d130b087fa971f772d41a7629407845977
parent91fef8be6ce92eb1a05536fff3994a76f2f2ab08 (diff)
downloadtelepathy-glib-955a87b38625cf6fc74676c0b1a218069d14b75f.tar.gz
Use constructed instead of constructor in TpProxy and subclasses
-rw-r--r--telepathy-glib/channel.c18
-rw-r--r--telepathy-glib/connection-manager.c19
-rw-r--r--telepathy-glib/dbus-daemon.c15
-rw-r--r--telepathy-glib/proxy.c55
4 files changed, 41 insertions, 66 deletions
diff --git a/telepathy-glib/channel.c b/telepathy-glib/channel.c
index 23f0f3921..1fc123892 100644
--- a/telepathy-glib/channel.c
+++ b/telepathy-glib/channel.c
@@ -909,17 +909,15 @@ tp_channel_connection_invalidated_cb (TpConnection *conn,
g_object_unref (self);
}
-static GObject *
-tp_channel_constructor (GType type,
- guint n_params,
- GObjectConstructParam *params)
+static void
+tp_channel_constructed (GObject *object)
{
- GObjectClass *object_class = (GObjectClass *) tp_channel_parent_class;
- TpChannel *self = TP_CHANNEL (object_class->constructor (type,
- n_params, params));
+ TpChannel *self = TP_CHANNEL (object);
GError *error = NULL;
TpProxySignalConnection *sc;
+ G_OBJECT_CLASS (tp_channel_parent_class)->constructed (object);
+
g_assert (tp_proxy_get_factory (self) ==
tp_proxy_get_factory (self->priv->connection));
@@ -939,7 +937,7 @@ tp_channel_constructor (GType type,
CRITICAL ("Couldn't connect to Closed: %s", error->message);
g_assert_not_reached ();
g_error_free (error);
- return NULL;
+ return;
}
DEBUG ("%p: constructed with channel type \"%s\", handle #%d of type %d",
@@ -964,8 +962,6 @@ tp_channel_constructor (GType type,
_tp_channel_create_contacts);
_tp_channel_continue_introspection (self);
-
- return (GObject *) self;
}
static void
@@ -1146,7 +1142,7 @@ tp_channel_class_init (TpChannelClass *klass)
g_type_class_add_private (klass, sizeof (TpChannelPrivate));
- object_class->constructor = tp_channel_constructor;
+ object_class->constructed = tp_channel_constructed;
object_class->get_property = tp_channel_get_property;
object_class->set_property = tp_channel_set_property;
object_class->dispose = tp_channel_dispose;
diff --git a/telepathy-glib/connection-manager.c b/telepathy-glib/connection-manager.c
index 5c4e9310e..683eab4c7 100644
--- a/telepathy-glib/connection-manager.c
+++ b/telepathy-glib/connection-manager.c
@@ -778,19 +778,12 @@ tp_connection_manager_find_manager_file (const gchar *name)
return NULL;
}
-static GObject *
-tp_connection_manager_constructor (GType type,
- guint n_params,
- GObjectConstructParam *params)
+static void
+tp_connection_manager_constructed (GObject *object)
{
- GObjectClass *object_class =
- (GObjectClass *) tp_connection_manager_parent_class;
- TpConnectionManager *self =
- TP_CONNECTION_MANAGER (object_class->constructor (type, n_params,
- params));
+ TpConnectionManager *self = TP_CONNECTION_MANAGER (object);
- g_return_val_if_fail (tp_proxy_get_object_path (self) != NULL, NULL);
- g_return_val_if_fail (tp_proxy_get_bus_name (self) != NULL, NULL);
+ G_OBJECT_CLASS (tp_connection_manager_parent_class)->constructed (object);
/* Watch my D-Bus name */
self->priv->watch_id = g_bus_watch_name_on_connection (
@@ -809,8 +802,6 @@ tp_connection_manager_constructor (GType type,
self->priv->manager_file =
tp_connection_manager_find_manager_file (self->priv->name);
}
-
- return (GObject *) self;
}
static void
@@ -996,7 +987,7 @@ tp_connection_manager_class_init (TpConnectionManagerClass *klass)
g_type_class_add_private (klass, sizeof (TpConnectionManagerPrivate));
- object_class->constructor = tp_connection_manager_constructor;
+ object_class->constructed = tp_connection_manager_constructed;
object_class->get_property = tp_connection_manager_get_property;
object_class->set_property = tp_connection_manager_set_property;
object_class->dispose = tp_connection_manager_dispose;
diff --git a/telepathy-glib/dbus-daemon.c b/telepathy-glib/dbus-daemon.c
index bafe8e32f..936260394 100644
--- a/telepathy-glib/dbus-daemon.c
+++ b/telepathy-glib/dbus-daemon.c
@@ -621,20 +621,15 @@ tp_dbus_daemon_get_unique_name (TpDBusDaemon *self)
tp_proxy_get_dbus_connection (self));
}
-static GObject *
-tp_dbus_daemon_constructor (GType type,
- guint n_params,
- GObjectConstructParam *params)
+static void
+tp_dbus_daemon_constructed (GObject *object)
{
- GObjectClass *object_class = G_OBJECT_CLASS (tp_dbus_daemon_parent_class);
+ TpDBusDaemon *self = TP_DBUS_DAEMON (object);
- TpDBusDaemon *self = TP_DBUS_DAEMON (object_class->constructor (type,
- n_params, params));
+ G_OBJECT_CLASS (tp_dbus_daemon_parent_class)->constructed (object);
g_assert (!tp_strdiff (tp_proxy_get_bus_name (self), DBUS_SERVICE_DBUS));
g_assert (!tp_strdiff (tp_proxy_get_object_path (self), DBUS_PATH_DBUS));
-
- return (GObject *) self;
}
static void
@@ -652,7 +647,7 @@ tp_dbus_daemon_class_init (TpDBusDaemonClass *klass)
g_type_class_add_private (klass, sizeof (TpDBusDaemonPrivate));
- object_class->constructor = tp_dbus_daemon_constructor;
+ object_class->constructed = tp_dbus_daemon_constructed;
proxy_class->interface = TP_IFACE_QUARK_DBUS_DAEMON;
}
diff --git a/telepathy-glib/proxy.c b/telepathy-glib/proxy.c
index d1a72645e..14e2b4529 100644
--- a/telepathy-glib/proxy.c
+++ b/telepathy-glib/proxy.c
@@ -170,9 +170,9 @@ tp_dbus_errors_quark (void)
* TpProxyClass:
* @parent_class: The parent class structure
* @interface: If set non-zero by a subclass, #TpProxy will
- * automatically add this interface in its constructor
+ * automatically add this interface in its constructed
* @must_have_unique_name: If set %TRUE by a subclass, the #TpProxy
- * constructor will fail if a well-known bus name is given
+ * constructed will fail if a well-known bus name is given
*
* The class of a #TpProxy. The struct fields not documented here are reserved.
*
@@ -907,17 +907,31 @@ assert_feature_validity (TpProxy *self,
g_assert (TP_IS_CONNECTION (self));
}
-static GObject *
-tp_proxy_constructor (GType type,
- guint n_params,
- GObjectConstructParam *params)
+static void
+tp_proxy_constructed (GObject *object)
{
- GObjectClass *object_class = (GObjectClass *) tp_proxy_parent_class;
- TpProxy *self = TP_PROXY (object_class->constructor (type,
- n_params, params));
+ TpProxy *self = TP_PROXY (object);
TpProxyClass *klass = TP_PROXY_GET_CLASS (self);
GType proxy_parent_type = G_TYPE_FROM_CLASS (tp_proxy_parent_class);
GType ancestor_type;
+ GType type = G_TYPE_FROM_INSTANCE (object);
+
+ G_OBJECT_CLASS (tp_proxy_parent_class)->constructed (object);
+
+ g_assert (self->priv->dbus_connection != NULL);
+ g_assert (self->priv->object_path != NULL);
+ g_assert (self->priv->bus_name != NULL);
+ g_assert (tp_dbus_check_valid_object_path (self->priv->object_path, NULL));
+ g_assert (tp_dbus_check_valid_bus_name (self->priv->bus_name,
+ TP_DBUS_NAME_TYPE_ANY, NULL));
+
+ /* Some interfaces are stateful, so we only allow binding to a unique
+ * name, like in dbus_g_proxy_new_for_name_owner() */
+ if (klass->must_have_unique_name)
+ g_assert (g_dbus_is_unique_name (self->priv->bus_name));
+
+ DEBUG ("%s:%s -> %s %p", self->priv->bus_name, self->priv->object_path,
+ G_OBJECT_TYPE_NAME (self), self);
for (ancestor_type = type;
ancestor_type != proxy_parent_type && ancestor_type != 0;
@@ -968,18 +982,6 @@ tp_proxy_constructor (GType type,
g_array_unref (core_features);
}
- g_return_val_if_fail (self->priv->dbus_connection != NULL, NULL);
- g_return_val_if_fail (self->priv->object_path != NULL, NULL);
- g_return_val_if_fail (self->priv->bus_name != NULL, NULL);
-
- DEBUG ("%s:%s -> %s %p", self->priv->bus_name, self->priv->object_path,
- G_OBJECT_TYPE_NAME (self), self);
-
- g_return_val_if_fail (tp_dbus_check_valid_object_path (self->priv->object_path,
- NULL), NULL);
- g_return_val_if_fail (tp_dbus_check_valid_bus_name (self->priv->bus_name,
- TP_DBUS_NAME_TYPE_ANY, NULL), NULL);
-
tp_proxy_add_interface_by_id (self, TP_IFACE_QUARK_DBUS_INTROSPECTABLE);
tp_proxy_add_interface_by_id (self, TP_IFACE_QUARK_DBUS_PEER);
tp_proxy_add_interface_by_id (self, TP_IFACE_QUARK_DBUS_PROPERTIES);
@@ -989,13 +991,6 @@ tp_proxy_constructor (GType type,
tp_proxy_add_interface_by_id (self, klass->interface);
}
- /* Some interfaces are stateful, so we only allow binding to a unique
- * name, like in dbus_g_proxy_new_for_name_owner() */
- if (klass->must_have_unique_name)
- {
- g_return_val_if_fail (self->priv->bus_name[0] == ':', NULL);
- }
-
self->priv->gdbus_closed_signal = g_signal_connect_object (
self->priv->dbus_connection, "closed",
G_CALLBACK (tp_proxy_closed_cb), self, 0);
@@ -1016,8 +1011,6 @@ tp_proxy_constructor (GType type,
self,
NULL);
}
-
- return (GObject *) self;
}
static GQuark const no_quarks[] = { 0 };
@@ -1091,7 +1084,7 @@ tp_proxy_class_init (TpProxyClass *klass)
g_type_class_add_private (klass, sizeof (TpProxyPrivate));
- object_class->constructor = tp_proxy_constructor;
+ object_class->constructed = tp_proxy_constructed;
object_class->get_property = tp_proxy_get_property;
object_class->set_property = tp_proxy_set_property;
object_class->dispose = tp_proxy_dispose;