diff options
author | Dan Winship <danw@gnome.org> | 2013-05-07 12:18:41 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2013-05-20 16:38:33 -0300 |
commit | 5a223b908954a67aef0c77ca29a251560eaace60 (patch) | |
tree | 698e97637f73aab6bfb7689ad044068f56052add /src | |
parent | 04cb58eacd1df9c25f0411b8c4062b0f9edcde0f (diff) | |
download | NetworkManager-5a223b908954a67aef0c77ca29a251560eaace60.tar.gz |
core: make nm-properties-changed-signal always export the right properties
Change the way that nm-properties-changed-signal works, and parse the
dbus-binding-tool-generated info to get the exact list of properties
that it's expected to export.
This makes NM_PROPERTY_PARAM_NO_EXPORT unnecessary, and also fixes the
problem of properties like NMDevice:hw-address being exported on
classes where it shouldn't be.
Diffstat (limited to 'src')
40 files changed, 248 insertions, 386 deletions
diff --git a/src/devices/nm-device-adsl.c b/src/devices/nm-device-adsl.c index c9acfdb666..e400a01a62 100644 --- a/src/devices/nm-device-adsl.c +++ b/src/devices/nm-device-adsl.c @@ -36,12 +36,12 @@ #include "nm-device-adsl.h" #include "nm-device-private.h" -#include "nm-properties-changed-signal.h" #include "NetworkManagerUtils.h" #include "nm-logging.h" #include "nm-enum-types.h" #include "nm-system.h" #include "nm-netlink-monitor.h" +#include "nm-dbus-manager.h" #include "ppp-manager/nm-ppp-manager.h" #include "nm-setting-adsl.h" @@ -85,13 +85,6 @@ typedef struct { } NMDeviceAdslPrivate; enum { - PROPERTIES_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { PROP_0, PROP_CARRIER, @@ -798,11 +791,7 @@ nm_device_adsl_class_init (NMDeviceAdslClass *klass) FALSE, G_PARAM_READABLE)); - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceAdslClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_adsl_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_adsl_object_info); } diff --git a/src/devices/nm-device-adsl.h b/src/devices/nm-device-adsl.h index 7ecb4350a4..5cd2c5668e 100644 --- a/src/devices/nm-device-adsl.h +++ b/src/devices/nm-device-adsl.h @@ -51,8 +51,6 @@ typedef struct { typedef struct { NMDeviceClass parent; - /* Signals */ - void (*properties_changed) (NMDeviceAdsl *device, GHashTable *properties); } NMDeviceAdslClass; GType nm_device_adsl_get_type (void); diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 3b8d23ae64..485862d9a9 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -27,12 +27,12 @@ #include "nm-device-bond.h" #include "nm-logging.h" -#include "nm-properties-changed-signal.h" #include "nm-utils.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-netlink-monitor.h" #include "nm-dbus-glib-types.h" +#include "nm-dbus-manager.h" #include "nm-enum-types.h" #include "nm-system.h" @@ -50,14 +50,6 @@ typedef struct { } NMDeviceBondPrivate; enum { - PROPERTIES_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { PROP_0, PROP_CARRIER, PROP_SLAVES, @@ -398,13 +390,9 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, G_PARAM_READABLE)); - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceBondClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_bond_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_bond_object_info); dbus_g_error_domain_register (NM_BOND_ERROR, NULL, NM_TYPE_BOND_ERROR); } diff --git a/src/devices/nm-device-bond.h b/src/devices/nm-device-bond.h index edbc86911b..84991ce648 100644 --- a/src/devices/nm-device-bond.h +++ b/src/devices/nm-device-bond.h @@ -50,8 +50,6 @@ typedef struct { typedef struct { NMDeviceWiredClass parent; - /* Signals */ - void (*properties_changed) (NMDeviceBond *device, GHashTable *properties); } NMDeviceBondClass; diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 1f5dd51d44..cfa98c6ed8 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -27,12 +27,12 @@ #include "nm-device-bridge.h" #include "nm-logging.h" -#include "nm-properties-changed-signal.h" #include "nm-utils.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-netlink-monitor.h" #include "nm-dbus-glib-types.h" +#include "nm-dbus-manager.h" #include "nm-enum-types.h" #include "nm-system.h" @@ -50,14 +50,6 @@ typedef struct { } NMDeviceBridgePrivate; enum { - PROPERTIES_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { PROP_0, PROP_CARRIER, PROP_SLAVES, @@ -430,13 +422,9 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass) DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, G_PARAM_READABLE)); - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceBridgeClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_bridge_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_bridge_object_info); dbus_g_error_domain_register (NM_BRIDGE_ERROR, NULL, NM_TYPE_BRIDGE_ERROR); } diff --git a/src/devices/nm-device-bridge.h b/src/devices/nm-device-bridge.h index e84daa9c56..7edfde2014 100644 --- a/src/devices/nm-device-bridge.h +++ b/src/devices/nm-device-bridge.h @@ -50,8 +50,6 @@ typedef struct { typedef struct { NMDeviceWiredClass parent; - /* Signals */ - void (*properties_changed) (NMDeviceBridge *device, GHashTable *properties); } NMDeviceBridgeClass; diff --git a/src/devices/nm-device-bt.c b/src/devices/nm-device-bt.c index b64e513dfb..813384ad2c 100644 --- a/src/devices/nm-device-bt.c +++ b/src/devices/nm-device-bt.c @@ -34,7 +34,6 @@ #include "nm-device-private.h" #include "nm-logging.h" #include "ppp-manager/nm-ppp-manager.h" -#include "nm-properties-changed-signal.h" #include "nm-setting-connection.h" #include "nm-setting-bluetooth.h" #include "nm-setting-cdma.h" @@ -89,7 +88,6 @@ enum { enum { PPP_STATS, - PROPERTIES_CHANGED, LAST_SIGNAL }; @@ -1311,12 +1309,9 @@ nm_device_bt_class_init (NMDeviceBtClass *klass) G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceBtClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_bt_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_bt_object_info); dbus_g_error_domain_register (NM_BT_ERROR, NULL, NM_TYPE_BT_ERROR); } diff --git a/src/devices/nm-device-bt.h b/src/devices/nm-device-bt.h index 64d0760eb0..2be9db382e 100644 --- a/src/devices/nm-device-bt.h +++ b/src/devices/nm-device-bt.h @@ -51,7 +51,6 @@ typedef struct { /* Signals */ void (*ppp_stats) (NMDeviceBt *device, guint32 in_bytes, guint32 out_bytes); - void (*properties_changed) (NMDeviceBt *device, GHashTable *properties); } NMDeviceBtClass; GType nm_device_bt_get_type (void); diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 976c22f363..ab828968c1 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -51,10 +51,10 @@ #include "nm-setting-bond.h" #include "ppp-manager/nm-ppp-manager.h" #include "nm-logging.h" -#include "nm-properties-changed-signal.h" #include "nm-utils.h" #include "nm-enum-types.h" #include "nm-netlink-monitor.h" +#include "nm-dbus-manager.h" #include "nm-device-ethernet-glue.h" @@ -99,14 +99,6 @@ typedef struct { } NMDeviceEthernetPrivate; enum { - PROPERTIES_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { PROP_0, PROP_PERM_HW_ADDRESS, PROP_SPEED, @@ -1432,13 +1424,9 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) FALSE, G_PARAM_READABLE)); - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceEthernetClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_ethernet_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_ethernet_object_info); dbus_g_error_domain_register (NM_ETHERNET_ERROR, NULL, NM_TYPE_ETHERNET_ERROR); } diff --git a/src/devices/nm-device-ethernet.h b/src/devices/nm-device-ethernet.h index 463bd62a75..24a66dce59 100644 --- a/src/devices/nm-device-ethernet.h +++ b/src/devices/nm-device-ethernet.h @@ -53,8 +53,6 @@ typedef struct { typedef struct { NMDeviceWiredClass parent; - /* Signals */ - void (*properties_changed) (NMDeviceEthernet *device, GHashTable *properties); } NMDeviceEthernetClass; diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c index 7a04efe98f..6aa19ac48e 100644 --- a/src/devices/nm-device-generic.c +++ b/src/devices/nm-device-generic.c @@ -24,9 +24,9 @@ #include "nm-device-private.h" #include "nm-enum-types.h" #include "nm-platform.h" -#include "nm-properties-changed-signal.h" #include "nm-utils.h" #include "nm-glib-compat.h" +#include "nm-dbus-manager.h" #include "nm-device-generic-glue.h" @@ -39,14 +39,6 @@ typedef struct { } NMDeviceGenericPrivate; enum { - PROPERTIES_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { PROP_0, PROP_TYPE_DESCRIPTION, @@ -217,13 +209,9 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - /* signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceGenericClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_generic_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_generic_object_info); dbus_g_error_domain_register (NM_DEVICE_GENERIC_ERROR, NULL, NM_TYPE_DEVICE_GENERIC_ERROR); } diff --git a/src/devices/nm-device-generic.h b/src/devices/nm-device-generic.h index 95634598bc..634e6aeee6 100644 --- a/src/devices/nm-device-generic.h +++ b/src/devices/nm-device-generic.h @@ -50,8 +50,6 @@ typedef struct { typedef struct { NMDeviceClass parent; - /* Signals */ - void (*properties_changed) (NMDeviceGeneric *device, GHashTable *properties); } NMDeviceGenericClass; GType nm_device_generic_get_type (void); diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index 5321e05da2..200370fce2 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -28,11 +28,11 @@ #include "nm-device-infiniband.h" #include "nm-logging.h" -#include "nm-properties-changed-signal.h" #include "nm-utils.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-enum-types.h" +#include "nm-dbus-manager.h" #include "nm-device-infiniband-glue.h" @@ -48,14 +48,6 @@ typedef struct { } NMDeviceInfinibandPrivate; enum { - PROPERTIES_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { PROP_0, PROP_CARRIER, @@ -360,13 +352,9 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass) FALSE, G_PARAM_READABLE)); - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceInfinibandClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_infiniband_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_infiniband_object_info); dbus_g_error_domain_register (NM_INFINIBAND_ERROR, NULL, NM_TYPE_INFINIBAND_ERROR); } diff --git a/src/devices/nm-device-infiniband.h b/src/devices/nm-device-infiniband.h index 983ede6a4f..685a741f61 100644 --- a/src/devices/nm-device-infiniband.h +++ b/src/devices/nm-device-infiniband.h @@ -49,8 +49,6 @@ typedef struct { typedef struct { NMDeviceWiredClass parent; - /* Signals */ - void (*properties_changed) (NMDeviceInfiniband *device, GHashTable *properties); } NMDeviceInfinibandClass; diff --git a/src/devices/nm-device-modem.c b/src/devices/nm-device-modem.c index 7c19f5850f..60228ab5e8 100644 --- a/src/devices/nm-device-modem.c +++ b/src/devices/nm-device-modem.c @@ -27,10 +27,10 @@ #include "nm-modem-cdma.h" #include "nm-modem-gsm.h" #include "nm-device-private.h" -#include "nm-properties-changed-signal.h" #include "nm-rfkill.h" #include "nm-logging.h" #include "nm-system.h" +#include "nm-dbus-manager.h" #if WITH_MODEM_MANAGER_1 #include "nm-modem-broadband.h" @@ -56,8 +56,8 @@ enum { }; enum { - PROPERTIES_CHANGED, ENABLE_CHANGED, + LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -506,7 +506,7 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass) "Modem", "Modem", NM_TYPE_MODEM, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_CAPABILITIES, g_param_spec_uint (NM_DEVICE_MODEM_CAPABILITIES, @@ -523,10 +523,6 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceModemClass, properties_changed)); - signals[ENABLE_CHANGED] = g_signal_new (NM_DEVICE_MODEM_ENABLE_CHANGED, G_OBJECT_CLASS_TYPE (object_class), @@ -535,6 +531,7 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (mclass), - &dbus_glib_nm_device_modem_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (mclass), + &dbus_glib_nm_device_modem_object_info); } diff --git a/src/devices/nm-device-modem.h b/src/devices/nm-device-modem.h index 85c626a366..aa0c7c351b 100644 --- a/src/devices/nm-device-modem.h +++ b/src/devices/nm-device-modem.h @@ -47,7 +47,6 @@ typedef struct { typedef struct { NMDeviceClass parent; - void (*properties_changed) (NMDeviceModem *self, GHashTable *properties); } NMDeviceModemClass; GType nm_device_modem_get_type (void); diff --git a/src/devices/nm-device-olpc-mesh.c b/src/devices/nm-device-olpc-mesh.c index 4bdddb9d1a..e73e3c24f2 100644 --- a/src/devices/nm-device-olpc-mesh.c +++ b/src/devices/nm-device-olpc-mesh.c @@ -48,12 +48,12 @@ #include "nm-logging.h" #include "NetworkManagerUtils.h" #include "nm-activation-request.h" -#include "nm-properties-changed-signal.h" #include "nm-setting-connection.h" #include "nm-setting-olpc-mesh.h" #include "nm-system.h" #include "nm-manager.h" #include "nm-enum-types.h" +#include "nm-dbus-manager.h" #include "wifi-utils.h" #if HAVE_WEXT #include "wifi-utils-wext.h" @@ -78,14 +78,6 @@ enum { LAST_PROP }; -enum { - PROPERTIES_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - #define NM_OLPC_MESH_ERROR (nm_olpc_mesh_error_quark ()) @@ -516,14 +508,12 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass) 0, G_MAXUINT32, 0, G_PARAM_READABLE)); - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceOlpcMeshClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_olpc_mesh_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_olpc_mesh_object_info); dbus_g_error_domain_register (NM_OLPC_MESH_ERROR, NULL, - NM_TYPE_OLPC_MESH_ERROR); + NM_TYPE_OLPC_MESH_ERROR); } static void diff --git a/src/devices/nm-device-olpc-mesh.h b/src/devices/nm-device-olpc-mesh.h index 6f44fb52d7..5d6bfab832 100644 --- a/src/devices/nm-device-olpc-mesh.h +++ b/src/devices/nm-device-olpc-mesh.h @@ -70,9 +70,6 @@ struct _NMDeviceOlpcMeshClass { NMDeviceClass parent; - /* Signals */ - void (*properties_changed) (NMDeviceOlpcMesh *device, - GHashTable *properties); }; diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 9ee66cd905..1a71091cae 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -29,13 +29,13 @@ #include "nm-device-vlan.h" #include "nm-logging.h" -#include "nm-properties-changed-signal.h" #include "nm-utils.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-netlink-monitor.h" #include "nm-enum-types.h" #include "nm-system.h" +#include "nm-dbus-manager.h" #include "nm-device-vlan-glue.h" @@ -61,14 +61,6 @@ typedef struct { } NMDeviceVlanPrivate; enum { - PROPERTIES_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { PROP_0, PROP_CARRIER, PROP_VLAN_ID, @@ -591,13 +583,9 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) 0, 4095, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceVlanClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_vlan_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_vlan_object_info); dbus_g_error_domain_register (NM_VLAN_ERROR, NULL, NM_TYPE_VLAN_ERROR); } diff --git a/src/devices/nm-device-vlan.h b/src/devices/nm-device-vlan.h index 68b1299320..ba6ce232ab 100644 --- a/src/devices/nm-device-vlan.h +++ b/src/devices/nm-device-vlan.h @@ -50,8 +50,6 @@ typedef struct { typedef struct { NMDeviceClass parent; - /* Signals */ - void (*properties_changed) (NMDeviceVlan *device, GHashTable *properties); } NMDeviceVlanClass; diff --git a/src/devices/nm-device-wifi.c b/src/devices/nm-device-wifi.c index 8fb5dd2b75..128248bdb1 100644 --- a/src/devices/nm-device-wifi.c +++ b/src/devices/nm-device-wifi.c @@ -37,6 +37,7 @@ #include <errno.h> #include "nm-glib-compat.h" +#include "nm-dbus-manager.h" #include "nm-device.h" #include "nm-device-wifi.h" #include "nm-device-private.h" @@ -47,7 +48,6 @@ #include "nm-supplicant-manager.h" #include "nm-supplicant-interface.h" #include "nm-supplicant-config.h" -#include "nm-properties-changed-signal.h" #include "nm-setting-connection.h" #include "nm-setting-wireless.h" #include "nm-setting-wireless-security.h" @@ -100,7 +100,6 @@ enum { ACCESS_POINT_ADDED, ACCESS_POINT_REMOVED, HIDDEN_AP_FOUND, - PROPERTIES_CHANGED, SCANNING_ALLOWED, LAST_SIGNAL @@ -3724,14 +3723,14 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) "Scanning", "Scanning", FALSE, - G_PARAM_READABLE | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READABLE)); g_object_class_install_property (object_class, PROP_IPW_RFKILL_STATE, g_param_spec_uint (NM_DEVICE_WIFI_IPW_RFKILL_STATE, "IpwRfkillState", "ipw rf-kill state", RFKILL_UNBLOCKED, RFKILL_HARD_BLOCKED, RFKILL_UNBLOCKED, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); /* Signals */ signals[ACCESS_POINT_ADDED] = @@ -3761,10 +3760,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) G_TYPE_NONE, 1, G_TYPE_OBJECT); - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceWifiClass, properties_changed)); - signals[SCANNING_ALLOWED] = g_signal_new ("scanning-allowed", G_OBJECT_CLASS_TYPE (object_class), @@ -3773,7 +3768,9 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) scanning_allowed_accumulator, NULL, NULL, G_TYPE_BOOLEAN, 0); - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_wifi_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_wifi_object_info); dbus_g_error_domain_register (NM_WIFI_ERROR, NULL, NM_TYPE_WIFI_ERROR); } diff --git a/src/devices/nm-device-wifi.h b/src/devices/nm-device-wifi.h index d4f16e062b..5731ac203b 100644 --- a/src/devices/nm-device-wifi.h +++ b/src/devices/nm-device-wifi.h @@ -83,7 +83,6 @@ struct _NMDeviceWifiClass void (*access_point_added) (NMDeviceWifi *device, NMAccessPoint *ap); void (*access_point_removed) (NMDeviceWifi *device, NMAccessPoint *ap); void (*hidden_ap_found) (NMDeviceWifi *device, NMAccessPoint *ap); - void (*properties_changed) (NMDeviceWifi *device, GHashTable *properties); gboolean (*scanning_allowed) (NMDeviceWifi *device); }; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 724c292bad..17f1647190 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -5025,7 +5025,7 @@ nm_device_class_init (NMDeviceClass *klass) "DeviceType", "DeviceType", 0, G_MAXUINT32, NM_DEVICE_TYPE_UNKNOWN, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_MANAGED, @@ -5057,7 +5057,7 @@ nm_device_class_init (NMDeviceClass *klass) "Type Description", "Device type description", NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_RFKILL_TYPE, @@ -5067,7 +5067,7 @@ nm_device_class_init (NMDeviceClass *klass) RFKILL_TYPE_WLAN, RFKILL_TYPE_MAX, RFKILL_TYPE_UNKNOWN, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_IFINDEX, @@ -5075,7 +5075,7 @@ nm_device_class_init (NMDeviceClass *klass) "Ifindex", "Ifindex", 0, G_MAXINT, 0, - G_PARAM_READABLE | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READABLE)); g_object_class_install_property (object_class, PROP_AVAILABLE_CONNECTIONS, @@ -5141,8 +5141,9 @@ nm_device_class_init (NMDeviceClass *klass) 0, NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_OBJECT); - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_object_info); dbus_g_error_domain_register (NM_DEVICE_ERROR, NULL, NM_TYPE_DEVICE_ERROR); } diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c index 541c39dfd1..763373abe6 100644 --- a/src/devices/wimax/nm-device-wimax.c +++ b/src/devices/wimax/nm-device-wimax.c @@ -37,7 +37,7 @@ #include "nm-device-private.h" #include "nm-system.h" #include "NetworkManagerUtils.h" -#include "nm-properties-changed-signal.h" +#include "nm-dbus-manager.h" #include "nm-connection.h" #include "nm-setting-connection.h" #include "nm-setting-wimax.h" @@ -67,7 +67,6 @@ enum { enum { NSP_ADDED, NSP_REMOVED, - PROPERTIES_CHANGED, LAST_SIGNAL }; @@ -1501,12 +1500,9 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *klass) G_TYPE_NONE, 1, G_TYPE_OBJECT); - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, G_STRUCT_OFFSET (NMDeviceWimaxClass, properties_changed)); - - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_wimax_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_wimax_object_info); dbus_g_error_domain_register (NM_WIMAX_ERROR, NULL, NM_TYPE_WIMAX_ERROR); } diff --git a/src/devices/wimax/nm-wimax-nsp.c b/src/devices/wimax/nm-wimax-nsp.c index 4e62d4fe76..efe3b05879 100644 --- a/src/devices/wimax/nm-wimax-nsp.c +++ b/src/devices/wimax/nm-wimax-nsp.c @@ -23,21 +23,12 @@ #include "NetworkManager.h" #include "nm-dbus-manager.h" #include "nm-setting-wimax.h" -#include "nm-properties-changed-signal.h" #include "nm-wimax-nsp-glue.h" #include "nm-utils.h" G_DEFINE_TYPE (NMWimaxNsp, nm_wimax_nsp, G_TYPE_OBJECT) enum { - PROPERTIES_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { PROP_0, PROP_NAME, @@ -245,11 +236,7 @@ nm_wimax_nsp_class_init (NMWimaxNspClass *klass) NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN, G_PARAM_READWRITE)); - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMWimaxNspClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_wimax_nsp_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_wimax_nsp_object_info); } diff --git a/src/nm-activation-request.h b/src/nm-activation-request.h index 1597109498..908db80c33 100644 --- a/src/nm-activation-request.h +++ b/src/nm-activation-request.h @@ -42,8 +42,6 @@ typedef struct { typedef struct { NMActiveConnectionClass parent; - /* Signals */ - void (*properties_changed) (NMActRequest *req, GHashTable *properties); } NMActRequestClass; GType nm_act_request_get_type (void); diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c index 9a9aaf0b93..7d183f827b 100644 --- a/src/nm-active-connection.c +++ b/src/nm-active-connection.c @@ -25,7 +25,6 @@ #include "nm-logging.h" #include "nm-dbus-glib-types.h" #include "nm-dbus-manager.h" -#include "nm-properties-changed-signal.h" #include "nm-device.h" #include "nm-settings-connection.h" @@ -77,12 +76,6 @@ enum { LAST_PROP }; -enum { - PROPERTIES_CHANGED, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - /****************************************************************/ NMActiveConnectionState @@ -379,11 +372,11 @@ dispose (GObject *object) } static void -nm_active_connection_class_init (NMActiveConnectionClass *vpn_class) +nm_active_connection_class_init (NMActiveConnectionClass *ac_class) { - GObjectClass *object_class = G_OBJECT_CLASS (vpn_class); + GObjectClass *object_class = G_OBJECT_CLASS (ac_class); - g_type_class_add_private (vpn_class, sizeof (NMActiveConnectionPrivate)); + g_type_class_add_private (ac_class, sizeof (NMActiveConnectionPrivate)); /* virtual methods */ object_class->get_property = get_property; @@ -462,49 +455,45 @@ nm_active_connection_class_init (NMActiveConnectionClass *vpn_class) "Internal Connection", "Internal connection", NM_TYPE_CONNECTION, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_INT_DEVICE, g_param_spec_object (NM_ACTIVE_CONNECTION_INT_DEVICE, "Internal device", "Internal device", NM_TYPE_DEVICE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_INT_USER_REQUESTED, g_param_spec_boolean (NM_ACTIVE_CONNECTION_INT_USER_REQUESTED, "User requested", "User requested", FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_INT_USER_UID, g_param_spec_ulong (NM_ACTIVE_CONNECTION_INT_USER_UID, "User UID", "User UID (if user requested)", 0, G_MAXULONG, 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_INT_ASSUMED, g_param_spec_boolean (NM_ACTIVE_CONNECTION_INT_ASSUMED, "Assumed", "Assumed", FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_INT_MASTER, g_param_spec_object (NM_ACTIVE_CONNECTION_INT_MASTER, "Internal master device", "Internal device", NM_TYPE_DEVICE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); - - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMActiveConnectionClass, properties_changed)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (vpn_class), - &dbus_glib_nm_active_connection_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (ac_class), + &dbus_glib_nm_active_connection_object_info); } diff --git a/src/nm-active-connection.h b/src/nm-active-connection.h index 2f17c58345..466701ceb1 100644 --- a/src/nm-active-connection.h +++ b/src/nm-active-connection.h @@ -59,8 +59,6 @@ typedef struct { typedef struct { GObjectClass parent; - /* Signals */ - void (*properties_changed) (NMActiveConnection *active, GHashTable *properties); } NMActiveConnectionClass; GType nm_active_connection_get_type (void); diff --git a/src/nm-dbus-manager.c b/src/nm-dbus-manager.c index 88f661744e..2c219861e8 100644 --- a/src/nm-dbus-manager.c +++ b/src/nm-dbus-manager.c @@ -27,6 +27,7 @@ #include "NetworkManager.h" #include "nm-dbus-manager.h" #include "nm-glib-compat.h" +#include "nm-properties-changed-signal.h" #include <dbus/dbus.h> #include <dbus/dbus-glib.h> @@ -782,6 +783,33 @@ object_destroyed (NMDBusManager *self, gpointer object) } void +nm_dbus_manager_register_exported_type (NMDBusManager *self, + GType object_type, + const DBusGObjectInfo *info) +{ + const char *properties_info, *dbus_name, *gobject_name, *access; + + dbus_g_object_type_install_info (object_type, info); + if (!info->exported_properties) + return; + + properties_info = info->exported_properties; + while (*properties_info) { + /* The format is: "interface\0DBusPropertyName\0gobject_property_name\0access\0" */ + dbus_name = strchr (properties_info, '\0') + 1; + gobject_name = strchr (dbus_name, '\0') + 1; + access = strchr (gobject_name, '\0') + 1; + properties_info = strchr (access, '\0') + 1; + + /* Note that nm-properties-changed-signal takes advantage of the + * fact that @dbus_name and @gobject_name are static data that won't + * ever be freed. + */ + nm_properties_changed_signal_add_property (object_type, dbus_name, gobject_name); + } +} + +void nm_dbus_manager_register_object (NMDBusManager *self, const char *path, gpointer object) diff --git a/src/nm-dbus-manager.h b/src/nm-dbus-manager.h index 83109aa90b..319252e87f 100644 --- a/src/nm-dbus-manager.h +++ b/src/nm-dbus-manager.h @@ -99,6 +99,10 @@ gboolean nm_dbus_manager_get_caller_info_from_message (NMDBusManager *self, char **out_sender, gulong *out_uid); +void nm_dbus_manager_register_exported_type (NMDBusManager *self, + GType object_type, + const DBusGObjectInfo *info); + void nm_dbus_manager_register_object (NMDBusManager *self, const char *path, gpointer object); diff --git a/src/nm-dhcp4-config.c b/src/nm-dhcp4-config.c index bb01fc51b4..a405aa870a 100644 --- a/src/nm-dhcp4-config.c +++ b/src/nm-dhcp4-config.c @@ -26,7 +26,6 @@ #include "nm-dhcp4-config.h" #include "nm-dhcp4-config-glue.h" #include "nm-dbus-glib-types.h" -#include "nm-properties-changed-signal.h" #include "nm-utils.h" @@ -47,14 +46,6 @@ enum { LAST_PROP }; -enum { - PROPERTIES_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - NMDHCP4Config * nm_dhcp4_config_new (void) @@ -194,11 +185,7 @@ nm_dhcp4_config_class_init (NMDHCP4ConfigClass *config_class) DBUS_TYPE_G_MAP_OF_VARIANT, G_PARAM_READABLE)); - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDHCP4ConfigClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (config_class), - &dbus_glib_nm_dhcp4_config_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (config_class), + &dbus_glib_nm_dhcp4_config_object_info); } diff --git a/src/nm-dhcp4-config.h b/src/nm-dhcp4-config.h index c5d78db9e1..6eb9ee5752 100644 --- a/src/nm-dhcp4-config.h +++ b/src/nm-dhcp4-config.h @@ -38,8 +38,6 @@ typedef struct { typedef struct { GObjectClass parent; - /* Signals */ - void (*properties_changed) (NMDHCP4Config *config, GHashTable *properties); } NMDHCP4ConfigClass; #define NM_DHCP4_CONFIG_OPTIONS "options" diff --git a/src/nm-dhcp6-config.c b/src/nm-dhcp6-config.c index 26c8d811c2..c50b8fdde4 100644 --- a/src/nm-dhcp6-config.c +++ b/src/nm-dhcp6-config.c @@ -26,7 +26,6 @@ #include "nm-dhcp6-config.h" #include "nm-dhcp6-config-glue.h" #include "nm-dbus-glib-types.h" -#include "nm-properties-changed-signal.h" #include "nm-utils.h" @@ -47,14 +46,6 @@ enum { LAST_PROP }; -enum { - PROPERTIES_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - NMDHCP6Config * nm_dhcp6_config_new (void) @@ -194,11 +185,7 @@ nm_dhcp6_config_class_init (NMDHCP6ConfigClass *config_class) DBUS_TYPE_G_MAP_OF_VARIANT, G_PARAM_READABLE)); - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDHCP6ConfigClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (config_class), - &dbus_glib_nm_dhcp6_config_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (config_class), + &dbus_glib_nm_dhcp6_config_object_info); } diff --git a/src/nm-dhcp6-config.h b/src/nm-dhcp6-config.h index ef742ac4af..2af6560788 100644 --- a/src/nm-dhcp6-config.h +++ b/src/nm-dhcp6-config.h @@ -38,8 +38,6 @@ typedef struct { typedef struct { GObjectClass parent; - /* Signals */ - void (*properties_changed) (NMDHCP6Config *config, GHashTable *properties); } NMDHCP6ConfigClass; #define NM_DHCP6_CONFIG_OPTIONS "options" diff --git a/src/nm-manager.c b/src/nm-manager.c index 1199921118..656807fbca 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -52,7 +52,6 @@ #include "nm-device-adsl.h" #include "nm-device-generic.h" #include "nm-system.h" -#include "nm-properties-changed-signal.h" #include "nm-setting-bluetooth.h" #include "nm-setting-connection.h" #include "nm-setting-wireless.h" @@ -262,7 +261,6 @@ enum { DEVICE_ADDED, DEVICE_REMOVED, STATE_CHANGED, - PROPERTIES_CHANGED, CHECK_PERMISSIONS, USER_PERMISSIONS_CHANGED, ACTIVE_CONNECTION_ADDED, @@ -4630,7 +4628,7 @@ nm_manager_class_init (NMManagerClass *manager_class) "Hostname", "Hostname", NULL, - G_PARAM_READABLE | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READABLE)); /* Sleeping is not exported over D-Bus */ g_object_class_install_property @@ -4639,7 +4637,7 @@ nm_manager_class_init (NMManagerClass *manager_class) "Sleeping", "Sleeping", FALSE, - G_PARAM_READABLE | NM_PROPERTY_PARAM_NO_EXPORT)); + G_PARAM_READABLE)); /* signals */ signals[DEVICE_ADDED] = @@ -4666,10 +4664,6 @@ nm_manager_class_init (NMManagerClass *manager_class) NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_UINT); - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMManagerClass, properties_changed)); - signals[CHECK_PERMISSIONS] = g_signal_new ("check-permissions", G_OBJECT_CLASS_TYPE (object_class), @@ -4698,8 +4692,9 @@ nm_manager_class_init (NMManagerClass *manager_class) 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_OBJECT); - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (manager_class), - &dbus_glib_nm_manager_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (manager_class), + &dbus_glib_nm_manager_object_info); dbus_g_error_domain_register (NM_MANAGER_ERROR, NULL, NM_TYPE_MANAGER_ERROR); dbus_g_error_domain_register (NM_LOGGING_ERROR, "org.freedesktop.NetworkManager.Logging", NM_TYPE_LOGGING_ERROR); diff --git a/src/nm-manager.h b/src/nm-manager.h index 26bb3db536..f4b4909d9e 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -80,7 +80,6 @@ typedef struct { void (*device_added) (NMManager *manager, NMDevice *device); void (*device_removed) (NMManager *manager, NMDevice *device); void (*state_changed) (NMManager *manager, guint state); - void (*properties_changed) (NMManager *manager, GHashTable *properties); } NMManagerClass; GType nm_manager_get_type (void); diff --git a/src/nm-properties-changed-signal.c b/src/nm-properties-changed-signal.c index ab679792cc..e0ba7371b1 100644 --- a/src/nm-properties-changed-signal.c +++ b/src/nm-properties-changed-signal.c @@ -23,19 +23,31 @@ #include <stdio.h> #include <dbus/dbus-glib.h> -#ifdef DEBUG #include "nm-logging.h" -#endif #include "nm-properties-changed-signal.h" #include "nm-dbus-glib-types.h" -#define NM_DBUS_PROPERTY_CHANGED "NM_DBUS_PROPERTY_CHANGED" +typedef struct { + GHashTable *exported_props; + guint signal_id; +} NMPropertiesChangedClassInfo; typedef struct { GHashTable *hash; - gulong signal_id; + guint signal_id; guint idle_id; -} PropertiesChangedInfo; +} NMPropertiesChangedInfo; + +static GQuark +nm_properties_changed_signal_quark (void) +{ + static GQuark q; + + if (G_UNLIKELY (q == 0)) + q = g_quark_from_static_string ("nm-properties-changed-signal"); + + return q; +} static void destroy_value (gpointer data) @@ -46,35 +58,23 @@ destroy_value (gpointer data) g_slice_free (GValue, val); } -static PropertiesChangedInfo * -properties_changed_info_new (void) -{ - PropertiesChangedInfo *info; - - info = g_slice_new0 (PropertiesChangedInfo); - info->hash = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - destroy_value); - return info; -} - static void properties_changed_info_destroy (gpointer data) { - PropertiesChangedInfo *info = (PropertiesChangedInfo *) data; + NMPropertiesChangedInfo *info = data; if (info->idle_id) g_source_remove (info->idle_id); g_hash_table_destroy (info->hash); - g_slice_free (PropertiesChangedInfo, info); + g_slice_free (NMPropertiesChangedInfo, info); } -#ifdef DEBUG static void add_to_string (gpointer key, gpointer value, gpointer user_data) { - char *buf = (char *) user_data; + const char *name = (const char *) key; + GString *buf = user_data; GValue str_val = G_VALUE_INIT; g_value_init (&str_val, G_TYPE_STRING); @@ -82,36 +82,33 @@ add_to_string (gpointer key, gpointer value, gpointer user_data) if (G_VALUE_HOLDS_OBJECT (value)) { GObject *obj = g_value_get_object (value); - if (g_value_get_object (value)) { - sprintf (buf + strlen (buf), "{%s: %p (%s)}, ", - (const char *) key, obj, G_OBJECT_TYPE_NAME (obj)); - } else { - sprintf (buf + strlen (buf), "{%s: %p}, ", (const char *) key, obj); - } + if (obj) { + g_string_append_printf (buf, "{%s: %p (%s)}, ", name, obj, + G_OBJECT_TYPE_NAME (obj)); + } else + g_string_append_printf (buf, "{%s: %p}, ", name, obj); } else - sprintf (buf + strlen (buf), "{%s: <transform error>}, ", (const char *) key); - } else { - sprintf (buf + strlen (buf), "{%s: %s}, ", (const char *) key, g_value_get_string (&str_val)); - } + g_string_append_printf (buf, "{%s: <transform error>}, ", name); + } else + g_string_append_printf (buf, "{%s: %s}, ", name, g_value_get_string (&str_val)); g_value_unset (&str_val); } -#endif static gboolean properties_changed (gpointer data) { GObject *object = G_OBJECT (data); - PropertiesChangedInfo *info = (PropertiesChangedInfo *) g_object_get_data (object, NM_DBUS_PROPERTY_CHANGED); + NMPropertiesChangedInfo *info = g_object_get_qdata (object, nm_properties_changed_signal_quark ()); g_assert (info); -#ifdef DEBUG - { - char buf[2048] = { 0, }; - g_hash_table_foreach (info->hash, add_to_string, &buf); - nm_log_dbg (LOGD_CORE, "%s -> %s", G_OBJECT_TYPE_NAME (object), buf); + if (nm_logging_level_enabled (LOGL_DEBUG)) { + GString *buf = g_string_new (NULL); + + g_hash_table_foreach (info->hash, add_to_string, buf); + nm_log_dbg (LOGD_CORE, "%s -> %s", G_OBJECT_TYPE_NAME (object), buf->str); + g_string_free (buf, TRUE); } -#endif g_signal_emit (object, info->signal_id, 0, info->hash); g_hash_table_remove_all (info->hash); @@ -123,82 +120,122 @@ static void idle_id_reset (gpointer data) { GObject *object = G_OBJECT (data); - PropertiesChangedInfo *info = (PropertiesChangedInfo *) g_object_get_data (object, NM_DBUS_PROPERTY_CHANGED); + NMPropertiesChangedInfo *info = g_object_get_qdata (object, nm_properties_changed_signal_quark ()); /* info is unset when the object is being destroyed */ if (info) info->idle_id = 0; } -static char* -uscore_to_wincaps (const char *uscore) -{ - const char *p; - GString *str; - gboolean last_was_uscore; - - last_was_uscore = TRUE; - - str = g_string_new (NULL); - p = uscore; - while (p && *p) { - if (*p == '-' || *p == '_') - last_was_uscore = TRUE; - else { - if (last_was_uscore) { - g_string_append_c (str, g_ascii_toupper (*p)); - last_was_uscore = FALSE; - } else - g_string_append_c (str, *p); - } - ++p; - } - - return g_string_free (str, FALSE); -} - static void notify (GObject *object, GParamSpec *pspec) { - PropertiesChangedInfo *info; + NMPropertiesChangedClassInfo *classinfo; + NMPropertiesChangedInfo *info; + const char *dbus_property_name = NULL; GValue *value; + GType type; - /* Ignore properties that shouldn't be exported */ - if (pspec->flags & NM_PROPERTY_PARAM_NO_EXPORT) + for (type = G_OBJECT_TYPE (object); type; type = g_type_parent (type)) { + classinfo = g_type_get_qdata (type, nm_properties_changed_signal_quark ()); + if (!classinfo) + continue; + + dbus_property_name = g_hash_table_lookup (classinfo->exported_props, pspec->name); + if (dbus_property_name) + break; + } + if (!dbus_property_name) { + nm_log_dbg (LOGD_CORE, "ignoring notification for prop %s on type %s", + pspec->name, G_OBJECT_TYPE_NAME (object)); return; + } - info = (PropertiesChangedInfo *) g_object_get_data (object, NM_DBUS_PROPERTY_CHANGED); + info = g_object_get_qdata (object, nm_properties_changed_signal_quark ()); if (!info) { - info = properties_changed_info_new (); - g_object_set_data_full (object, NM_DBUS_PROPERTY_CHANGED, info, properties_changed_info_destroy); - info->signal_id = g_signal_lookup ("properties-changed", G_OBJECT_TYPE (object)); - g_assert (info->signal_id); + info = g_slice_new0 (NMPropertiesChangedInfo); + info->hash = g_hash_table_new_full (g_str_hash, g_str_equal, + NULL, destroy_value); + info->signal_id = classinfo->signal_id; + + g_object_set_qdata_full (object, nm_properties_changed_signal_quark (), + info, properties_changed_info_destroy); } value = g_slice_new0 (GValue); g_value_init (value, pspec->value_type); g_object_get_property (object, pspec->name, value); - g_hash_table_insert (info->hash, uscore_to_wincaps (pspec->name), value); + g_hash_table_insert (info->hash, (char *) dbus_property_name, value); if (!info->idle_id) info->idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, properties_changed, object, idle_id_reset); } -guint -nm_properties_changed_signal_new (GObjectClass *object_class, - guint class_offset) +static NMPropertiesChangedClassInfo * +nm_properties_changed_signal_setup_type (GType type) { - guint id; + NMPropertiesChangedClassInfo *classinfo; + NMPropertiesChangedClassInfo *parent_classinfo = NULL; + GObjectClass *object_class; + GType parent; + classinfo = g_slice_new (NMPropertiesChangedClassInfo); + g_type_set_qdata (type, nm_properties_changed_signal_quark (), classinfo); + + object_class = g_type_class_ref (type); object_class->notify = notify; + g_type_class_unref (object_class); + + classinfo->exported_props = g_hash_table_new (g_str_hash, g_str_equal); + + /* See if we've already added the signal to a parent class. (We can't just use + * g_signal_lookup() here because it prints a warning if the signal doesn't exist!) + */ + parent = g_type_parent (type); + while (parent) { + parent_classinfo = g_type_get_qdata (parent, nm_properties_changed_signal_quark ()); + if (parent_classinfo) + break; + parent = g_type_parent (parent); + } - id = g_signal_new ("properties-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - class_offset, - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT); + if (parent_classinfo) + classinfo->signal_id = parent_classinfo->signal_id; + else { + classinfo->signal_id = g_signal_new ("properties-changed", + type, + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT); + } + + return classinfo; +} + +void +nm_properties_changed_signal_add_property (GType type, + const char *dbus_property_name, + const char *gobject_property_name) +{ + NMPropertiesChangedClassInfo *classinfo; + char *hyphen_name, *p; + + classinfo = g_type_get_qdata (type, nm_properties_changed_signal_quark ()); + if (!classinfo) + classinfo = nm_properties_changed_signal_setup_type (type); - return id; + g_hash_table_insert (classinfo->exported_props, + (char *) gobject_property_name, + (char *) dbus_property_name); + + hyphen_name = g_strdup (gobject_property_name); + for (p = hyphen_name; *p; p++) { + if (*p == '_') + *p = '-'; + } + g_hash_table_insert (classinfo->exported_props, + hyphen_name, + (char *) dbus_property_name); } diff --git a/src/nm-properties-changed-signal.h b/src/nm-properties-changed-signal.h index b87e34e185..97a3b2c024 100644 --- a/src/nm-properties-changed-signal.h +++ b/src/nm-properties-changed-signal.h @@ -24,9 +24,8 @@ #include <glib-object.h> -#define NM_PROPERTY_PARAM_NO_EXPORT (1 << (0 + G_PARAM_USER_SHIFT)) - -guint nm_properties_changed_signal_new (GObjectClass *object_class, - guint class_offset); +void nm_properties_changed_signal_add_property (GType type, + const char *dbus_property_name, + const char *gobject_property_name); #endif /* _NM_PROPERTIES_CHANGED_SIGNAL_H_ */ diff --git a/src/nm-wifi-ap.c b/src/nm-wifi-ap.c index fa9c53aefa..8c7bf40c3f 100644 --- a/src/nm-wifi-ap.c +++ b/src/nm-wifi-ap.c @@ -30,7 +30,6 @@ #include "nm-logging.h" #include "nm-dbus-manager.h" -#include "nm-properties-changed-signal.h" #include "nm-setting-wireless.h" #include "nm-glib-compat.h" @@ -68,14 +67,6 @@ typedef struct G_DEFINE_TYPE (NMAccessPoint, nm_ap, G_TYPE_OBJECT) enum { - PROPERTIES_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { PROP_0, PROP_FLAGS, PROP_WPA_FLAGS, @@ -304,13 +295,9 @@ nm_ap_class_init (NMAccessPointClass *ap_class) G_MININT8, G_MAXINT8, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMAccessPointClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (ap_class), - &dbus_glib_nm_access_point_object_info); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), + G_TYPE_FROM_CLASS (ap_class), + &dbus_glib_nm_access_point_object_info); } void diff --git a/src/nm-wifi-ap.h b/src/nm-wifi-ap.h index a1a0da9208..be650f6c28 100644 --- a/src/nm-wifi-ap.h +++ b/src/nm-wifi-ap.h @@ -51,8 +51,6 @@ typedef struct { typedef struct { GObjectClass parent; - /* Signals */ - void (*properties_changed) (NMAccessPoint *ap, GHashTable *properties); } NMAccessPointClass; GType nm_ap_get_type (void); |