diff options
-rw-r--r-- | libnm/nm-access-point.c | 25 | ||||
-rw-r--r-- | libnm/nm-active-connection.c | 24 | ||||
-rw-r--r-- | libnm/nm-client.c | 73 | ||||
-rw-r--r-- | libnm/nm-device-adsl.c | 27 | ||||
-rw-r--r-- | libnm/nm-device-bond.c | 25 | ||||
-rw-r--r-- | libnm/nm-device-bridge.c | 25 | ||||
-rw-r--r-- | libnm/nm-device-bt.c | 25 | ||||
-rw-r--r-- | libnm/nm-device-ethernet.c | 25 | ||||
-rw-r--r-- | libnm/nm-device-generic.c | 24 | ||||
-rw-r--r-- | libnm/nm-device-infiniband.c | 25 | ||||
-rw-r--r-- | libnm/nm-device-modem.c | 24 | ||||
-rw-r--r-- | libnm/nm-device-olpc-mesh.c | 25 | ||||
-rw-r--r-- | libnm/nm-device-team.c | 25 | ||||
-rw-r--r-- | libnm/nm-device-vlan.c | 25 | ||||
-rw-r--r-- | libnm/nm-device-wifi.c | 37 | ||||
-rw-r--r-- | libnm/nm-device-wimax.c | 37 | ||||
-rw-r--r-- | libnm/nm-device.c | 57 | ||||
-rw-r--r-- | libnm/nm-dhcp4-config.c | 14 | ||||
-rw-r--r-- | libnm/nm-dhcp6-config.c | 14 | ||||
-rw-r--r-- | libnm/nm-ip4-config.c | 24 | ||||
-rw-r--r-- | libnm/nm-ip6-config.c | 24 | ||||
-rw-r--r-- | libnm/nm-object.c | 15 | ||||
-rw-r--r-- | libnm/nm-object.h | 3 | ||||
-rw-r--r-- | libnm/nm-vpn-connection.c | 25 | ||||
-rw-r--r-- | libnm/nm-wimax-nsp.c | 25 |
25 files changed, 302 insertions, 370 deletions
diff --git a/libnm/nm-access-point.c b/libnm/nm-access-point.c index 86c8def3ea..21dcc14da1 100644 --- a/libnm/nm-access-point.c +++ b/libnm/nm-access-point.c @@ -460,9 +460,9 @@ demarshal_ssid (NMObject *object, GParamSpec *pspec, GValue *value, gpointer fie } static void -register_properties (NMAccessPoint *ap) +init_dbus (NMObject *object) { - NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap); + NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_ACCESS_POINT_FLAGS, &priv->flags }, { NM_ACCESS_POINT_WPA_FLAGS, &priv->wpa_flags }, @@ -477,37 +477,30 @@ register_properties (NMAccessPoint *ap) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (ap), + NM_OBJECT_CLASS (nm_access_point_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_ACCESS_POINT); + _nm_object_register_properties (object, priv->proxy, property_info); } -static void -constructed (GObject *object) -{ - NMAccessPointPrivate *priv; - - G_OBJECT_CLASS (nm_access_point_parent_class)->constructed (object); - - priv = NM_ACCESS_POINT_GET_PRIVATE (object); - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_ACCESS_POINT); - register_properties (NM_ACCESS_POINT (object)); -} - static void nm_access_point_class_init (NMAccessPointClass *ap_class) { GObjectClass *object_class = G_OBJECT_CLASS (ap_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (ap_class); g_type_class_add_private (ap_class, sizeof (NMAccessPointPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; + nm_object_class->init_dbus = init_dbus; + /* properties */ /** diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c index a694f28706..3f970f001c 100644 --- a/libnm/nm-active-connection.c +++ b/libnm/nm-active-connection.c @@ -563,9 +563,9 @@ get_property (GObject *object, } static void -register_properties (NMActiveConnection *connection) +init_dbus (NMObject *object) { - NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection); + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_ACTIVE_CONNECTION_CONNECTION, &priv->connection }, { NM_ACTIVE_CONNECTION_ID, &priv->id }, @@ -586,36 +586,30 @@ register_properties (NMActiveConnection *connection) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (connection), + NM_OBJECT_CLASS (nm_active_connection_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_ACTIVE_CONNECTION); + _nm_object_register_properties (object, priv->proxy, property_info); } -static void -constructed (GObject *object) -{ - NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_ACTIVE_CONNECTION); - register_properties (NM_ACTIVE_CONNECTION (object)); -} - static void nm_active_connection_class_init (NMActiveConnectionClass *ap_class) { GObjectClass *object_class = G_OBJECT_CLASS (ap_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (ap_class); g_type_class_add_private (ap_class, sizeof (NMActiveConnectionPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; + nm_object_class->init_dbus = init_dbus; + /* properties */ /** diff --git a/libnm/nm-client.c b/libnm/nm-client.c index b4e3f68a8f..d6919d9995 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -170,10 +170,14 @@ wireless_enabled_cb (GObject *object, GParamSpec *pspec, gpointer user_data) poke_wireless_devices_with_rf_status (NM_CLIENT (object)); } +static void client_recheck_permissions (DBusGProxy *proxy, gpointer user_data); +static void active_connections_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data); +static void object_creation_failed_cb (GObject *object, GError *error, char *failed_path); + static void -register_properties (NMClient *client) +init_dbus (NMObject *object) { - NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_CLIENT_VERSION, &priv->version }, { NM_CLIENT_STATE, &priv->state }, @@ -193,9 +197,38 @@ register_properties (NMClient *client) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (client), + NM_OBJECT_CLASS (nm_client_parent_class)->init_dbus (object); + + priv->client_proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE); + _nm_object_register_properties (object, priv->client_proxy, property_info); + + /* Permissions */ + dbus_g_proxy_add_signal (priv->client_proxy, "CheckPermissions", G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->client_proxy, + "CheckPermissions", + G_CALLBACK (client_recheck_permissions), + object, + NULL); + + if (_nm_object_is_connection_private (NM_OBJECT (object))) + priv->manager_running = TRUE; + else { + priv->bus_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + g_assert (priv->bus_proxy); + + dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->bus_proxy, + "NameOwnerChanged", + G_CALLBACK (proxy_name_owner_changed), + object, NULL); + } } #define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network" @@ -1775,7 +1808,6 @@ constructor (GType type, static void constructed (GObject *object) { - NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object); GError *error = NULL; if (!nm_utils_init (&error)) { @@ -1786,36 +1818,6 @@ constructed (GObject *object) G_OBJECT_CLASS (nm_client_parent_class)->constructed (object); - priv->client_proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE); - - register_properties (NM_CLIENT (object)); - - /* Permissions */ - dbus_g_proxy_add_signal (priv->client_proxy, "CheckPermissions", G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->client_proxy, - "CheckPermissions", - G_CALLBACK (client_recheck_permissions), - object, - NULL); - - if (_nm_object_is_connection_private (NM_OBJECT (object))) - priv->manager_running = TRUE; - else { - priv->bus_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - g_assert (priv->bus_proxy); - - dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->bus_proxy, - "NameOwnerChanged", - G_CALLBACK (proxy_name_owner_changed), - object, NULL); - } - g_signal_connect (object, "notify::" NM_CLIENT_WIRELESS_ENABLED, G_CALLBACK (wireless_enabled_cb), NULL); @@ -2126,6 +2128,7 @@ static void nm_client_class_init (NMClientClass *client_class) { GObjectClass *object_class = G_OBJECT_CLASS (client_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (client_class); g_type_class_add_private (client_class, sizeof (NMClientPrivate)); @@ -2137,6 +2140,8 @@ nm_client_class_init (NMClientClass *client_class) object_class->dispose = dispose; object_class->finalize = finalize; + nm_object_class->init_dbus = init_dbus; + /* properties */ /** diff --git a/libnm/nm-device-adsl.c b/libnm/nm-device-adsl.c index 22ce1d2b9c..08ccb65a45 100644 --- a/libnm/nm-device-adsl.c +++ b/libnm/nm-device-adsl.c @@ -121,31 +121,23 @@ nm_device_adsl_init (NMDeviceAdsl *device) } static void -register_properties (NMDeviceAdsl *device) +init_dbus (NMObject *object) { - NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (device); + NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { - { NM_DEVICE_ADSL_CARRIER, &priv->carrier }, + { NM_DEVICE_ADSL_CARRIER, &priv->carrier }, { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_adsl_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_ADSL); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_adsl_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_ADSL); - register_properties (NM_DEVICE_ADSL (object)); -} - -static void dispose (GObject *object) { NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (object); @@ -190,15 +182,18 @@ static void nm_device_adsl_class_init (NMDeviceAdslClass *adsl_class) { GObjectClass *object_class = G_OBJECT_CLASS (adsl_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (adsl_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (adsl_class); g_type_class_add_private (object_class, sizeof (NMDeviceAdslPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c index d609a9b32c..9d0bcb6f5d 100644 --- a/libnm/nm-device-bond.c +++ b/libnm/nm-device-bond.c @@ -183,9 +183,9 @@ nm_device_bond_init (NMDeviceBond *device) } static void -register_properties (NMDeviceBond *device) +init_dbus (NMObject *object) { - NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (device); + NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_BOND_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_BOND_CARRIER, &priv->carrier }, @@ -193,23 +193,15 @@ register_properties (NMDeviceBond *device) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_bond_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_BOND); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_bond_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_BOND); - register_properties (NM_DEVICE_BOND (object)); -} - -static void dispose (GObject *object) { NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (object); @@ -265,15 +257,18 @@ static void nm_device_bond_class_init (NMDeviceBondClass *eth_class) { GObjectClass *object_class = G_OBJECT_CLASS (eth_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (eth_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (eth_class); g_type_class_add_private (eth_class, sizeof (NMDeviceBondPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; device_class->get_hw_address = get_hw_address; diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c index c3d096e8c0..1ea605d038 100644 --- a/libnm/nm-device-bridge.c +++ b/libnm/nm-device-bridge.c @@ -183,9 +183,9 @@ nm_device_bridge_init (NMDeviceBridge *device) } static void -register_properties (NMDeviceBridge *device) +init_dbus (NMObject *object) { - NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (device); + NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_BRIDGE_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_BRIDGE_CARRIER, &priv->carrier }, @@ -193,23 +193,15 @@ register_properties (NMDeviceBridge *device) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_bridge_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_BRIDGE); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_bridge_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_BRIDGE); - register_properties (NM_DEVICE_BRIDGE (object)); -} - -static void dispose (GObject *object) { NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (object); @@ -265,15 +257,18 @@ static void nm_device_bridge_class_init (NMDeviceBridgeClass *bridge_class) { GObjectClass *object_class = G_OBJECT_CLASS (bridge_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (bridge_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (bridge_class); g_type_class_add_private (bridge_class, sizeof (NMDeviceBridgePrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; device_class->get_hw_address = get_hw_address; diff --git a/libnm/nm-device-bt.c b/libnm/nm-device-bt.c index 74117fb98b..ab82129741 100644 --- a/libnm/nm-device-bt.c +++ b/libnm/nm-device-bt.c @@ -221,9 +221,9 @@ nm_device_bt_init (NMDeviceBt *device) } static void -register_properties (NMDeviceBt *device) +init_dbus (NMObject *object) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_BT_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_BT_NAME, &priv->name }, @@ -231,23 +231,15 @@ register_properties (NMDeviceBt *device) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_bt_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_BLUETOOTH); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_bt_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_BLUETOOTH); - register_properties (NM_DEVICE_BT (object)); -} - -static void dispose (GObject *object) { NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object); @@ -298,15 +290,18 @@ static void nm_device_bt_class_init (NMDeviceBtClass *bt_class) { GObjectClass *object_class = G_OBJECT_CLASS (bt_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (bt_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (bt_class); g_type_class_add_private (bt_class, sizeof (NMDeviceBtPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; device_class->get_hw_address = get_hw_address; diff --git a/libnm/nm-device-ethernet.c b/libnm/nm-device-ethernet.c index 1ecdd7481e..b022786a06 100644 --- a/libnm/nm-device-ethernet.c +++ b/libnm/nm-device-ethernet.c @@ -220,9 +220,9 @@ nm_device_ethernet_init (NMDeviceEthernet *device) } static void -register_properties (NMDeviceEthernet *device) +init_dbus (NMObject *object) { - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_ETHERNET_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS, &priv->perm_hw_address }, @@ -231,23 +231,15 @@ register_properties (NMDeviceEthernet *device) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_ethernet_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_WIRED); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_ethernet_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_WIRED); - register_properties (NM_DEVICE_ETHERNET (object)); -} - -static void dispose (GObject *object) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object); @@ -301,15 +293,18 @@ static void nm_device_ethernet_class_init (NMDeviceEthernetClass *eth_class) { GObjectClass *object_class = G_OBJECT_CLASS (eth_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (eth_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (eth_class); g_type_class_add_private (eth_class, sizeof (NMDeviceEthernetPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; device_class->get_hw_address = get_hw_address; diff --git a/libnm/nm-device-generic.c b/libnm/nm-device-generic.c index 81b21b1cc0..8bc08ac958 100644 --- a/libnm/nm-device-generic.c +++ b/libnm/nm-device-generic.c @@ -139,32 +139,24 @@ nm_device_generic_init (NMDeviceGeneric *device) } static void -register_properties (NMDeviceGeneric *device) +init_dbus (NMObject *object) { - NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (device); + NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_GENERIC_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_GENERIC_TYPE_DESCRIPTION, &priv->type_description }, { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_generic_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_GENERIC); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_GENERIC); - register_properties (NM_DEVICE_GENERIC (object)); -} - -static void dispose (GObject *object) { NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); @@ -212,15 +204,17 @@ static void nm_device_generic_class_init (NMDeviceGenericClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); g_type_class_add_private (klass, sizeof (NMDeviceGenericPrivate)); - object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + nm_object_class->init_dbus = init_dbus; + device_class->get_type_description = get_type_description; device_class->get_hw_address = get_hw_address; device_class->connection_compatible = connection_compatible; diff --git a/libnm/nm-device-infiniband.c b/libnm/nm-device-infiniband.c index bfdf753b9a..99eb0dbde4 100644 --- a/libnm/nm-device-infiniband.c +++ b/libnm/nm-device-infiniband.c @@ -172,32 +172,24 @@ nm_device_infiniband_init (NMDeviceInfiniband *device) } static void -register_properties (NMDeviceInfiniband *device) +init_dbus (NMObject *object) { - NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (device); + NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_INFINIBAND_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_INFINIBAND_CARRIER, &priv->carrier }, { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_infiniband_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_INFINIBAND); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_infiniband_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_INFINIBAND); - register_properties (NM_DEVICE_INFINIBAND (object)); -} - -static void dispose (GObject *object) { NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (object); @@ -244,15 +236,18 @@ static void nm_device_infiniband_class_init (NMDeviceInfinibandClass *eth_class) { GObjectClass *object_class = G_OBJECT_CLASS (eth_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (eth_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (eth_class); g_type_class_add_private (eth_class, sizeof (NMDeviceInfinibandPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; device_class->get_hw_address = get_hw_address; diff --git a/libnm/nm-device-modem.c b/libnm/nm-device-modem.c index 7d286190f3..400ef58cf6 100644 --- a/libnm/nm-device-modem.c +++ b/libnm/nm-device-modem.c @@ -186,32 +186,24 @@ nm_device_modem_init (NMDeviceModem *device) } static void -register_properties (NMDeviceModem *device) +init_dbus (NMObject *object) { - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_MODEM_MODEM_CAPABILITIES, &priv->caps }, { NM_DEVICE_MODEM_CURRENT_CAPABILITIES, &priv->current_caps }, { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_modem_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_MODEM); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_modem_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_MODEM); - register_properties (NM_DEVICE_MODEM (object)); -} - -static void get_property (GObject *object, guint prop_id, GValue *value, @@ -248,15 +240,17 @@ static void nm_device_modem_class_init (NMDeviceModemClass *modem_class) { GObjectClass *object_class = G_OBJECT_CLASS (modem_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (modem_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (modem_class); g_type_class_add_private (modem_class, sizeof (NMDeviceModemPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->dispose = dispose; + nm_object_class->init_dbus = init_dbus; + device_class->get_type_description = get_type_description; device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; diff --git a/libnm/nm-device-olpc-mesh.c b/libnm/nm-device-olpc-mesh.c index b51d656a3a..2416e3810a 100644 --- a/libnm/nm-device-olpc-mesh.c +++ b/libnm/nm-device-olpc-mesh.c @@ -169,9 +169,9 @@ nm_device_olpc_mesh_init (NMDeviceOlpcMesh *device) } static void -register_properties (NMDeviceOlpcMesh *device) +init_dbus (NMObject *object) { - NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (device); + NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_OLPC_MESH_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_OLPC_MESH_COMPANION, &priv->companion, NULL, NM_TYPE_DEVICE_WIFI }, @@ -179,23 +179,15 @@ register_properties (NMDeviceOlpcMesh *device) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_OLPC_MESH); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_OLPC_MESH); - register_properties (NM_DEVICE_OLPC_MESH (object)); -} - -static void dispose (GObject *object) { NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (object); @@ -246,15 +238,18 @@ static void nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *olpc_mesh_class) { GObjectClass *object_class = G_OBJECT_CLASS (olpc_mesh_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (olpc_mesh_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (olpc_mesh_class); g_type_class_add_private (olpc_mesh_class, sizeof (NMDeviceOlpcMeshPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; device_class->get_hw_address = get_hw_address; diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c index f1682e2786..3f45f18207 100644 --- a/libnm/nm-device-team.c +++ b/libnm/nm-device-team.c @@ -183,9 +183,9 @@ nm_device_team_init (NMDeviceTeam *device) } static void -register_properties (NMDeviceTeam *device) +init_dbus (NMObject *object) { - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (device); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_TEAM_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_TEAM_CARRIER, &priv->carrier }, @@ -193,23 +193,15 @@ register_properties (NMDeviceTeam *device) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_team_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_TEAM); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_team_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_TEAM); - register_properties (NM_DEVICE_TEAM (object)); -} - -static void dispose (GObject *object) { NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (object); @@ -265,15 +257,18 @@ static void nm_device_team_class_init (NMDeviceTeamClass *eth_class) { GObjectClass *object_class = G_OBJECT_CLASS (eth_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (eth_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (eth_class); g_type_class_add_private (eth_class, sizeof (NMDeviceTeamPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; device_class->get_hw_address = get_hw_address; diff --git a/libnm/nm-device-vlan.c b/libnm/nm-device-vlan.c index 9f44370bb2..8dd38dbdbe 100644 --- a/libnm/nm-device-vlan.c +++ b/libnm/nm-device-vlan.c @@ -199,9 +199,9 @@ nm_device_vlan_init (NMDeviceVlan *device) } static void -register_properties (NMDeviceVlan *device) +init_dbus (NMObject *object) { - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device); + NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_VLAN_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_VLAN_CARRIER, &priv->carrier }, @@ -209,23 +209,15 @@ register_properties (NMDeviceVlan *device) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_vlan_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_VLAN); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_vlan_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_VLAN); - register_properties (NM_DEVICE_VLAN (object)); -} - -static void dispose (GObject *object) { NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); @@ -275,15 +267,18 @@ static void nm_device_vlan_class_init (NMDeviceVlanClass *eth_class) { GObjectClass *object_class = G_OBJECT_CLASS (eth_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (eth_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (eth_class); g_type_class_add_private (eth_class, sizeof (NMDeviceVlanPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; + + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; device_class->get_hw_address = get_hw_address; diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index f581d06684..5a10553428 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -41,6 +41,7 @@ G_DEFINE_TYPE (NMDeviceWifi, nm_device_wifi, NM_TYPE_DEVICE) #define NM_DEVICE_WIFI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WIFI, NMDeviceWifiPrivate)) void _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, gboolean enabled); +static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data); typedef struct { NMDeviceWifi *device; @@ -512,6 +513,11 @@ static void nm_device_wifi_init (NMDeviceWifi *device) { _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_WIFI); + + g_signal_connect (device, + "notify::" NM_DEVICE_STATE, + G_CALLBACK (state_changed_cb), + NULL); } static void @@ -579,9 +585,9 @@ state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data) } static void -register_properties (NMDeviceWifi *device) +init_dbus (NMObject *object) { - NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device); + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_WIFI_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS, &priv->perm_hw_address }, @@ -593,7 +599,10 @@ register_properties (NMDeviceWifi *device) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_wifi_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_WIRELESS); + _nm_object_register_properties (object, priv->proxy, property_info); } @@ -614,22 +623,6 @@ access_point_removed (NMDeviceWifi *self, NMAccessPoint *ap) } static void -constructed (GObject *object) -{ - NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_wifi_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_WIRELESS); - register_properties (NM_DEVICE_WIFI (object)); - - g_signal_connect (NM_DEVICE (object), - "notify::" NM_DEVICE_STATE, - G_CALLBACK (state_changed_cb), - NULL); -} - -static void dispose (GObject *object) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object); @@ -671,18 +664,22 @@ static void nm_device_wifi_class_init (NMDeviceWifiClass *wifi_class) { GObjectClass *object_class = G_OBJECT_CLASS (wifi_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (wifi_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (wifi_class); g_type_class_add_private (wifi_class, sizeof (NMDeviceWifiPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; + + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; device_class->get_hw_address = get_hw_address; + wifi_class->access_point_removed = access_point_removed; /* properties */ diff --git a/libnm/nm-device-wimax.c b/libnm/nm-device-wimax.c index 471c1434f8..a63ce1bf89 100644 --- a/libnm/nm-device-wimax.c +++ b/libnm/nm-device-wimax.c @@ -40,6 +40,7 @@ G_DEFINE_TYPE (NMDeviceWimax, nm_device_wimax, NM_TYPE_DEVICE) #define NM_DEVICE_WIMAX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxPrivate)) void _nm_device_wimax_set_wireless_enabled (NMDeviceWimax *wimax, gboolean enabled); +static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data); typedef struct { DBusGProxy *proxy; @@ -388,6 +389,11 @@ static void nm_device_wimax_init (NMDeviceWimax *device) { _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_WIMAX); + + g_signal_connect (device, + "notify::" NM_DEVICE_STATE, + G_CALLBACK (state_changed_cb), + NULL); } static void @@ -496,9 +502,9 @@ state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data) } static void -register_properties (NMDeviceWimax *wimax) +init_dbus (NMObject *object) { - NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax); + NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_WIMAX_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_WIMAX_ACTIVE_NSP, &priv->active_nsp, NULL, NM_TYPE_WIMAX_NSP }, @@ -511,7 +517,10 @@ register_properties (NMDeviceWimax *wimax) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (wimax), + NM_OBJECT_CLASS (nm_device_wimax_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE_WIMAX); + _nm_object_register_properties (object, priv->proxy, property_info); } @@ -529,22 +538,6 @@ nsp_removed (NMDeviceWimax *self, NMWimaxNsp *nsp) } static void -constructed (GObject *object) -{ - NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_wimax_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_WIMAX); - register_properties (NM_DEVICE_WIMAX (object)); - - g_signal_connect (object, - "notify::" NM_DEVICE_STATE, - G_CALLBACK (state_changed_cb), - NULL); -} - -static void dispose (GObject *object) { NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object); @@ -569,17 +562,21 @@ static void nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class) { GObjectClass *object_class = G_OBJECT_CLASS (wimax_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (wimax_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (wimax_class); g_type_class_add_private (wimax_class, sizeof (NMDeviceWimaxPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->dispose = dispose; + + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; device_class->get_hw_address = get_hw_address; + wimax_class->nsp_removed = nsp_removed; /* properties */ diff --git a/libnm/nm-device.c b/libnm/nm-device.c index f83742f190..60a3b9bede 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -182,9 +182,16 @@ demarshal_state_reason (NMObject *object, GParamSpec *pspec, GValue *value, gpoi } static void -register_properties (NMDevice *device) +device_state_changed (DBusGProxy *proxy, + NMDeviceState new_state, + NMDeviceState old_state, + NMDeviceStateReason reason, + gpointer user_data); + +static void +init_dbus (NMObject *object) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_UDI, &priv->udi }, { NM_DEVICE_INTERFACE, &priv->iface }, @@ -214,9 +221,28 @@ register_properties (NMDevice *device) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (device), + NM_OBJECT_CLASS (nm_device_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DEVICE); + _nm_object_register_properties (object, priv->proxy, property_info); + + dbus_g_object_register_marshaller (g_cclosure_marshal_generic, + G_TYPE_NONE, + G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, + G_TYPE_INVALID); + + dbus_g_proxy_add_signal (priv->proxy, + "StateChanged", + G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, + G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (priv->proxy, "StateChanged", + G_CALLBACK (device_state_changed), + NM_DEVICE (object), + NULL); + } typedef struct { @@ -327,34 +353,14 @@ _nm_device_gtype_from_dtype (NMDeviceType dtype) static void constructed (GObject *object) { - NMDevicePrivate *priv; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_parent_class)->constructed (object); - priv = NM_DEVICE_GET_PRIVATE (object); /* Catch failure of subclasses to call _nm_device_set_device_type() */ g_warn_if_fail (priv->device_type != NM_DEVICE_TYPE_UNKNOWN); /* Catch a subclass setting the wrong type */ g_warn_if_fail (G_OBJECT_TYPE (object) == _nm_device_gtype_from_dtype (priv->device_type)); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE); - - register_properties (NM_DEVICE (object)); - - dbus_g_object_register_marshaller (g_cclosure_marshal_generic, - G_TYPE_NONE, - G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, - G_TYPE_INVALID); - - dbus_g_proxy_add_signal (priv->proxy, - "StateChanged", - G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, - G_TYPE_INVALID); - - dbus_g_proxy_connect_signal (priv->proxy, "StateChanged", - G_CALLBACK (device_state_changed), - NM_DEVICE (object), - NULL); } static void @@ -527,6 +533,7 @@ static void nm_device_class_init (NMDeviceClass *device_class) { GObjectClass *object_class = G_OBJECT_CLASS (device_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (device_class); g_type_class_add_private (device_class, sizeof (NMDevicePrivate)); @@ -537,6 +544,8 @@ nm_device_class_init (NMDeviceClass *device_class) object_class->dispose = dispose; object_class->finalize = finalize; + nm_object_class->init_dbus = init_dbus; + device_class->connection_compatible = connection_compatible; /* properties */ diff --git a/libnm/nm-dhcp4-config.c b/libnm/nm-dhcp4-config.c index dc8367942e..b1b5e3240a 100644 --- a/libnm/nm-dhcp4-config.c +++ b/libnm/nm-dhcp4-config.c @@ -72,15 +72,18 @@ demarshal_dhcp4_options (NMObject *object, GParamSpec *pspec, GValue *value, gpo } static void -register_properties (NMDhcp4Config *config) +init_dbus (NMObject *object) { - NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (config); + NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DHCP4_CONFIG_OPTIONS, &priv->options, demarshal_dhcp4_options }, { NULL }, }; - _nm_object_register_properties (NM_OBJECT (config), + NM_OBJECT_CLASS (nm_dhcp4_config_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DHCP4_CONFIG); + _nm_object_register_properties (object, priv->proxy, property_info); } @@ -94,8 +97,6 @@ constructed (GObject *object) priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DHCP4_CONFIG); - register_properties (NM_DHCP4_CONFIG (object)); } static void @@ -135,6 +136,7 @@ static void nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class); g_type_class_add_private (config_class, sizeof (NMDhcp4ConfigPrivate)); @@ -143,6 +145,8 @@ nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class) object_class->get_property = get_property; object_class->finalize = finalize; + nm_object_class->init_dbus = init_dbus; + /* properties */ /** diff --git a/libnm/nm-dhcp6-config.c b/libnm/nm-dhcp6-config.c index bea41d4e4a..dc639d3acd 100644 --- a/libnm/nm-dhcp6-config.c +++ b/libnm/nm-dhcp6-config.c @@ -72,15 +72,18 @@ demarshal_dhcp6_options (NMObject *object, GParamSpec *pspec, GValue *value, gpo } static void -register_properties (NMDhcp6Config *config) +init_dbus (NMObject *object) { - NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (config); + NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DHCP6_CONFIG_OPTIONS, &priv->options, demarshal_dhcp6_options }, { NULL }, }; - _nm_object_register_properties (NM_OBJECT (config), + NM_OBJECT_CLASS (nm_dhcp6_config_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_DHCP6_CONFIG); + _nm_object_register_properties (object, priv->proxy, property_info); } @@ -94,8 +97,6 @@ constructed (GObject *object) priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DHCP6_CONFIG); - register_properties (NM_DHCP6_CONFIG (object)); } static void @@ -135,6 +136,7 @@ static void nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class); g_type_class_add_private (config_class, sizeof (NMDhcp6ConfigPrivate)); @@ -143,6 +145,8 @@ nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class) object_class->get_property = get_property; object_class->finalize = finalize; + nm_object_class->init_dbus = init_dbus; + /* properties */ /** diff --git a/libnm/nm-ip4-config.c b/libnm/nm-ip4-config.c index 205a590438..727e2a6b30 100644 --- a/libnm/nm-ip4-config.c +++ b/libnm/nm-ip4-config.c @@ -115,9 +115,9 @@ demarshal_ip4_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, } static void -register_properties (NMIP4Config *config) +init_dbus (NMObject *object) { - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_IP4_CONFIG_GATEWAY, &priv->gateway, }, { NM_IP4_CONFIG_ADDRESSES, &priv->addresses, demarshal_ip4_address_array }, @@ -129,23 +129,15 @@ register_properties (NMIP4Config *config) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (config), + NM_OBJECT_CLASS (nm_ip4_config_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_IP4_CONFIG); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_ip4_config_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_IP4_CONFIG); - register_properties (NM_IP4_CONFIG (object)); -} - -static void finalize (GObject *object) { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object); @@ -219,14 +211,16 @@ static void nm_ip4_config_class_init (NMIP4ConfigClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class); g_type_class_add_private (config_class, sizeof (NMIP4ConfigPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->finalize = finalize; + nm_object_class->init_dbus = init_dbus; + /* properties */ /** diff --git a/libnm/nm-ip6-config.c b/libnm/nm-ip6-config.c index dd5807d9fc..29dc38a94d 100644 --- a/libnm/nm-ip6-config.c +++ b/libnm/nm-ip6-config.c @@ -116,9 +116,9 @@ demarshal_ip6_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, } static void -register_properties (NMIP6Config *config) +init_dbus (NMObject *object) { - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); + NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_IP6_CONFIG_GATEWAY, &priv->gateway, }, { NM_IP6_CONFIG_ADDRESSES, &priv->addresses, demarshal_ip6_address_array }, @@ -129,7 +129,10 @@ register_properties (NMIP6Config *config) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (config), + NM_OBJECT_CLASS (nm_ip6_config_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_IP6_CONFIG); + _nm_object_register_properties (object, priv->proxy, property_info); } @@ -292,17 +295,6 @@ nm_ip6_config_get_routes (NMIP6Config *config) } static void -constructed (GObject *object) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_ip6_config_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_IP6_CONFIG); - register_properties (NM_IP6_CONFIG (object)); -} - -static void finalize (GObject *object) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); @@ -373,14 +365,16 @@ static void nm_ip6_config_class_init (NMIP6ConfigClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class); g_type_class_add_private (config_class, sizeof (NMIP6ConfigPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->finalize = finalize; + nm_object_class->init_dbus = init_dbus; + /* properties */ /** diff --git a/libnm/nm-object.c b/libnm/nm-object.c index 4eed266ba8..4482d24d48 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -166,14 +166,21 @@ static void constructed (GObject *object) { NMObject *self = NM_OBJECT (object); - NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); if (G_OBJECT_CLASS (nm_object_parent_class)->constructed) G_OBJECT_CLASS (nm_object_parent_class)->constructed (object); - priv->properties_proxy = _nm_object_new_proxy (self, NULL, "org.freedesktop.DBus.Properties"); + NM_OBJECT_GET_CLASS (self)->init_dbus (self); +} + +static void +init_dbus (NMObject *object) +{ + NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); + + priv->properties_proxy = _nm_object_new_proxy (object, NULL, "org.freedesktop.DBus.Properties"); - if (_nm_object_is_connection_private (self)) + if (_nm_object_is_connection_private (object)) priv->nm_running = TRUE; else { priv->bus_proxy = dbus_g_proxy_new_for_name (priv->connection, @@ -389,6 +396,8 @@ nm_object_class_init (NMObjectClass *nm_object_class) object_class->dispose = dispose; object_class->finalize = finalize; + nm_object_class->init_dbus = init_dbus; + /* Properties */ /** diff --git a/libnm/nm-object.h b/libnm/nm-object.h index d50efafe91..6fcd589e12 100644 --- a/libnm/nm-object.h +++ b/libnm/nm-object.h @@ -72,6 +72,9 @@ typedef struct { GError *error, char *failed_path); + /* Methods */ + void (*init_dbus) (NMObject *object); + /*< private >*/ gpointer padding[8]; } NMObjectClass; diff --git a/libnm/nm-vpn-connection.c b/libnm/nm-vpn-connection.c index d50fb74f35..d816dde6f7 100644 --- a/libnm/nm-vpn-connection.c +++ b/libnm/nm-vpn-connection.c @@ -124,28 +124,21 @@ nm_vpn_connection_init (NMVpnConnection *connection) } static void -register_properties (NMVpnConnection *connection) +init_dbus (NMObject *object) { - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_VPN_CONNECTION_BANNER, &priv->banner }, { NM_VPN_CONNECTION_VPN_STATE, &priv->vpn_state }, { NULL }, }; - _nm_object_register_properties (NM_OBJECT (connection), + NM_OBJECT_CLASS (nm_vpn_connection_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_VPN_CONNECTION); + _nm_object_register_properties (object, priv->proxy, property_info); -} - -static void -constructed (GObject *object) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_vpn_connection_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_VPN_CONNECTION); dbus_g_object_register_marshaller (g_cclosure_marshal_generic, G_TYPE_NONE, @@ -157,8 +150,6 @@ constructed (GObject *object) G_CALLBACK (vpn_state_changed_proxy), object, NULL); - - register_properties (NM_VPN_CONNECTION (object)); } static void @@ -199,14 +190,16 @@ static void nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class) { GObjectClass *object_class = G_OBJECT_CLASS (connection_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (connection_class); g_type_class_add_private (connection_class, sizeof (NMVpnConnectionPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->finalize = finalize; + nm_object_class->init_dbus = init_dbus; + /* properties */ /** diff --git a/libnm/nm-wimax-nsp.c b/libnm/nm-wimax-nsp.c index 106f5bd2f0..168528f420 100644 --- a/libnm/nm-wimax-nsp.c +++ b/libnm/nm-wimax-nsp.c @@ -233,9 +233,9 @@ get_property (GObject *object, } static void -register_properties (NMWimaxNsp *nsp) +init_dbus (NMObject *object) { - NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (nsp); + NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_WIMAX_NSP_NAME, &priv->name }, { NM_WIMAX_NSP_SIGNAL_QUALITY, &priv->signal_quality }, @@ -243,36 +243,29 @@ register_properties (NMWimaxNsp *nsp) { NULL }, }; - _nm_object_register_properties (NM_OBJECT (nsp), + NM_OBJECT_CLASS (nm_wimax_nsp_parent_class)->init_dbus (object); + + priv->proxy = _nm_object_new_proxy (object, NULL, NM_DBUS_INTERFACE_WIMAX_NSP); + _nm_object_register_properties (object, priv->proxy, property_info); } static void -constructed (GObject *object) -{ - NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_wimax_nsp_parent_class)->constructed (object); - - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_WIMAX_NSP); - register_properties (NM_WIMAX_NSP (object)); -} - - -static void nm_wimax_nsp_class_init (NMWimaxNspClass *nsp_class) { GObjectClass *object_class = G_OBJECT_CLASS (nsp_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (nsp_class); g_type_class_add_private (nsp_class, sizeof (NMWimaxNspPrivate)); /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; + nm_object_class->init_dbus = init_dbus; + /* properties */ /** |