diff options
author | Dan Winship <danw@gnome.org> | 2011-12-20 15:15:42 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2012-02-03 10:33:43 -0600 |
commit | 9fd98ef91b90d9ea56440c2915280ea9d5d01ef2 (patch) | |
tree | 17188480e64aa02ca2b2fb56f8de2965a5609fed /libnm-glib/nm-device-infiniband.c | |
parent | ad5daa098c308ae58a6d54c453c73451044598fc (diff) | |
download | NetworkManager-9fd98ef91b90d9ea56440c2915280ea9d5d01ef2.tar.gz |
libnm-glib: implement GInitable/GAsyncInitable in NMObject
Implement GInitable and GAsyncInitable in NMObject, with
implementations that synchronously or asynchonously load all
properties, and change _nm_object_ensure_inited() to run
g_initable_init().
Update the object/object-array property handling to initialize the
objects after creating them (synchronously or asynchronously,
according to the situation), so that they will have all of their
properties preloaded before they are ever visible to the caller.
Move the non-blocking/non-failable parts of various objects'
constructor() methods to constructed(), and move the blocking/failable
parts to init(), and implement init_async() methods with non-blocking
versions of the blocking methods.
Make nm_device_new() and nm_client_new() call
_nm_object_ensure_inited(), to preserve the behaviour formerly
enforced by their construct() methods, that properties are guaranteed
to be initialized before any signals involving them are emitted.
Diffstat (limited to 'libnm-glib/nm-device-infiniband.c')
-rw-r--r-- | libnm-glib/nm-device-infiniband.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/libnm-glib/nm-device-infiniband.c b/libnm-glib/nm-device-infiniband.c index 384a348076..9ac38257bc 100644 --- a/libnm-glib/nm-device-infiniband.c +++ b/libnm-glib/nm-device-infiniband.c @@ -68,13 +68,17 @@ enum { GObject * nm_device_infiniband_new (DBusGConnection *connection, const char *path) { + GObject *device; + g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (path != NULL, NULL); - return g_object_new (NM_TYPE_DEVICE_INFINIBAND, - NM_OBJECT_DBUS_CONNECTION, connection, - NM_OBJECT_DBUS_PATH, path, - NULL); + device = g_object_new (NM_TYPE_DEVICE_INFINIBAND, + NM_OBJECT_DBUS_CONNECTION, connection, + NM_OBJECT_DBUS_PATH, path, + NULL); + _nm_object_ensure_inited (NM_OBJECT (device)); + return device; } /** @@ -168,19 +172,12 @@ register_properties (NMDeviceInfiniband *device) property_info); } -static GObject* -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) +static void +constructed (GObject *object) { - GObject *object; NMDeviceInfinibandPrivate *priv; - object = G_OBJECT_CLASS (nm_device_infiniband_parent_class)->constructor (type, - n_construct_params, - construct_params); - if (!object) - return NULL; + G_OBJECT_CLASS (nm_device_infiniband_parent_class)->constructed (object); priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (object); @@ -190,8 +187,6 @@ constructor (GType type, NM_DBUS_INTERFACE_DEVICE_INFINIBAND); register_properties (NM_DEVICE_INFINIBAND (object)); - - return object; } static void @@ -247,7 +242,7 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *eth_class) g_type_class_add_private (eth_class, sizeof (NMDeviceInfinibandPrivate)); /* virtual methods */ - object_class->constructor = constructor; + object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; |