From 6fcc1deee0a9549d753813f9406ea1d74a2a8e8c Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 13 Apr 2015 13:31:42 -0400 Subject: [PATCH] core: add an NMExportedObject base class Add NMExportedObject, make it the base class of all D-Bus-exported types, and move the nm-properties-changed-signal logic into it. (Also, make NMSettings use the same properties-changed code as everything else, which it was not previously doing, presumably for historical reasons). (This is mostly just shuffling code around at this point, but NMExportedObject will be more important in the gdbus port, since gdbus-codegen doesn't do a very good job of supporting objects that export multiple interfaces [as each NMDevice subclass does, for example], so we will need more glue/helper code in NMExportedObject then.) --- src/Makefile.am | 6 +- src/devices/adsl/nm-device-adsl.c | 4 +- src/devices/bluetooth/nm-device-bt.c | 3 +- src/devices/nm-device-bond.c | 4 +- src/devices/nm-device-bridge.c | 4 +- src/devices/nm-device-ethernet.c | 4 +- src/devices/nm-device-generic.c | 4 +- src/devices/nm-device-gre.c | 4 +- src/devices/nm-device-infiniband.c | 4 +- src/devices/nm-device-macvlan.c | 4 +- src/devices/nm-device-tun.c | 4 +- src/devices/nm-device-veth.c | 4 +- src/devices/nm-device-vlan.c | 4 +- src/devices/nm-device-vxlan.c | 4 +- src/devices/nm-device.c | 8 +- src/devices/nm-device.h | 6 +- src/devices/team/nm-device-team.c | 5 +- src/devices/wifi/nm-device-olpc-mesh.c | 4 +- src/devices/wifi/nm-device-wifi.c | 4 +- src/devices/wifi/nm-wifi-ap.c | 5 +- src/devices/wifi/nm-wifi-ap.h | 6 +- src/devices/wwan/nm-device-modem.c | 4 +- src/devices/wwan/nm-modem.c | 1 - src/dhcp-manager/tests/Makefile.am | 1 + src/nm-active-connection.c | 5 +- src/nm-active-connection.h | 7 +- src/nm-dbus-manager.c | 28 --- src/nm-dbus-manager.h | 4 - src/nm-dhcp4-config.c | 5 +- src/nm-dhcp4-config.h | 8 +- src/nm-dhcp6-config.c | 5 +- src/nm-dhcp6-config.h | 8 +- src/nm-exported-object.c | 247 ++++++++++++++++++ src/nm-exported-object.h | 53 ++++ src/nm-ip4-config.c | 5 +- src/nm-ip4-config.h | 8 +- src/nm-ip6-config.c | 5 +- src/nm-ip6-config.h | 7 +- src/nm-manager.c | 5 +- src/nm-manager.h | 8 +- src/nm-properties-changed-signal.c | 248 ------------------- src/nm-properties-changed-signal.h | 31 --- src/ppp-manager/nm-ppp-manager.c | 6 +- src/ppp-manager/nm-ppp-manager.h | 6 +- src/settings/nm-agent-manager.c | 6 +- src/settings/nm-agent-manager.h | 8 +- src/settings/nm-settings-connection.c | 6 +- src/settings/nm-settings-connection.h | 5 +- src/settings/nm-settings.c | 63 +---- src/settings/nm-settings.h | 7 +- src/settings/plugins/ifcfg-rh/plugin.c | 6 +- src/settings/plugins/ifcfg-rh/plugin.h | 6 +- src/settings/plugins/ifnet/Makefile.am | 1 + src/settings/plugins/ifnet/tests/Makefile.am | 1 + src/settings/plugins/ifupdown/Makefile.am | 1 + src/vpn-manager/nm-vpn-connection.c | 4 +- 56 files changed, 399 insertions(+), 515 deletions(-) create mode 100644 src/nm-exported-object.c create mode 100644 src/nm-exported-object.h delete mode 100644 src/nm-properties-changed-signal.c delete mode 100644 src/nm-properties-changed-signal.h diff --git a/src/Makefile.am b/src/Makefile.am index cc0a0aecd1..3181a1f099 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -324,6 +324,8 @@ nm_sources = \ nm-dispatcher.h \ nm-enum-types.c \ nm-enum-types.h \ + nm-exported-object.c \ + nm-exported-object.h \ nm-firewall-manager.c \ nm-firewall-manager.h \ nm-ip4-config.c \ @@ -344,8 +346,6 @@ nm_sources = \ nm-multi-index.h \ nm-policy.c \ nm-policy.h \ - nm-properties-changed-signal.c \ - nm-properties-changed-signal.h \ nm-rfkill-manager.c \ nm-rfkill-manager.h \ nm-session-monitor.h \ @@ -505,6 +505,8 @@ libnm_iface_helper_la_SOURCES = \ nm-route-manager.c \ nm-route-manager.h \ \ + nm-exported-object.c \ + nm-exported-object.h \ nm-ip4-config.c \ nm-ip4-config.h \ nm-ip6-config.c \ diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c index f5ed9d756f..a557a0c88f 100644 --- a/src/devices/adsl/nm-device-adsl.c +++ b/src/devices/adsl/nm-device-adsl.c @@ -39,7 +39,6 @@ #include "NetworkManagerUtils.h" #include "nm-logging.h" #include "nm-enum-types.h" -#include "nm-dbus-manager.h" #include "nm-platform.h" #include "ppp-manager/nm-ppp-manager.h" @@ -615,7 +614,6 @@ nm_device_adsl_class_init (NMDeviceAdslClass *klass) parent_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start; parent_class->deactivate = deactivate; - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_adsl_object_info); } diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index 1de5bed104..7fd793b451 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -1196,7 +1196,6 @@ nm_device_bt_class_init (NMDeviceBtClass *klass) G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_bt_object_info); } diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index a78761c3d7..734a84ea78 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -33,7 +33,6 @@ #include "nm-device-private.h" #include "nm-platform.h" #include "nm-dbus-glib-types.h" -#include "nm-dbus-manager.h" #include "nm-enum-types.h" #include "nm-device-factory.h" #include "nm-core-internal.h" @@ -542,8 +541,7 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_bond_object_info); } diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 3e70708db1..a0b1e83cbb 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -31,7 +31,6 @@ #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-dbus-glib-types.h" -#include "nm-dbus-manager.h" #include "nm-enum-types.h" #include "nm-platform.h" #include "nm-device-factory.h" @@ -466,8 +465,7 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_bridge_object_info); } diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index afd3a43415..8fcf4827fb 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -41,7 +41,6 @@ #include "ppp-manager/nm-ppp-manager.h" #include "nm-logging.h" #include "nm-enum-types.h" -#include "nm-dbus-manager.h" #include "nm-platform.h" #include "nm-platform-utils.h" #include "nm-dcb.h" @@ -1706,8 +1705,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_ethernet_object_info); } diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c index 0565153bb8..db5b2b6b4d 100644 --- a/src/devices/nm-device-generic.c +++ b/src/devices/nm-device-generic.c @@ -24,7 +24,6 @@ #include "nm-device-private.h" #include "nm-enum-types.h" #include "nm-platform.h" -#include "nm-dbus-manager.h" #include "nm-core-internal.h" #include "nm-device-generic-glue.h" @@ -203,7 +202,6 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_generic_object_info); } diff --git a/src/devices/nm-device-gre.c b/src/devices/nm-device-gre.c index b3510d2e25..53f2901d97 100644 --- a/src/devices/nm-device-gre.c +++ b/src/devices/nm-device-gre.c @@ -25,7 +25,6 @@ #include "nm-device-gre.h" #include "nm-device-private.h" -#include "nm-dbus-manager.h" #include "nm-logging.h" #include "nm-manager.h" #include "nm-platform.h" @@ -256,8 +255,7 @@ nm_device_gre_class_init (NMDeviceGreClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_gre_object_info); } diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index 62fbe8d558..98e2f1de09 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -30,7 +30,6 @@ #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-enum-types.h" -#include "nm-dbus-manager.h" #include "nm-activation-request.h" #include "nm-ip4-config.h" #include "nm-platform.h" @@ -295,8 +294,7 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_infiniband_object_info); } diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index 0bfe3fe9fc..42811f1a65 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -24,7 +24,6 @@ #include "nm-device-macvlan.h" #include "nm-device-private.h" -#include "nm-dbus-manager.h" #include "nm-logging.h" #include "nm-manager.h" #include "nm-platform.h" @@ -164,8 +163,7 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_macvlan_object_info); } diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index 5aaff8b1a0..d996470af5 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -25,7 +25,6 @@ #include "nm-device-tun.h" #include "nm-device-private.h" -#include "nm-dbus-manager.h" #include "nm-logging.h" #include "nm-platform.h" #include "nm-device-factory.h" @@ -258,8 +257,7 @@ nm_device_tun_class_init (NMDeviceTunClass *klass) FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_tun_object_info); } diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c index 04f03fbbe5..89ab4297f1 100644 --- a/src/devices/nm-device-veth.c +++ b/src/devices/nm-device-veth.c @@ -32,7 +32,6 @@ #include "nm-logging.h" #include "nm-manager.h" #include "nm-platform.h" -#include "nm-dbus-manager.h" #include "nm-device-factory.h" #include "nm-device-veth-glue.h" @@ -166,8 +165,7 @@ nm_device_veth_class_init (NMDeviceVethClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_veth_object_info); } diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index f2380e71d6..a31eb77b87 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -32,7 +32,6 @@ #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-enum-types.h" -#include "nm-dbus-manager.h" #include "nm-connection-provider.h" #include "nm-activation-request.h" #include "nm-ip4-config.h" @@ -606,8 +605,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_vlan_object_info); } diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index 186e00de00..50e698aded 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -24,7 +24,6 @@ #include "nm-device-vxlan.h" #include "nm-device-private.h" -#include "nm-dbus-manager.h" #include "nm-logging.h" #include "nm-manager.h" #include "nm-platform.h" @@ -342,8 +341,7 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_vxlan_object_info); } diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 4590c5f63d..5097e44807 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -55,7 +55,6 @@ #include "nm-dhcp6-config.h" #include "nm-rfkill-manager.h" #include "nm-firewall-manager.h" -#include "nm-properties-changed-signal.h" #include "nm-enum-types.h" #include "nm-settings-connection.h" #include "nm-connection-provider.h" @@ -79,7 +78,7 @@ static void ip_check_ping_watch_cb (GPid pid, gint status, gpointer user_data); #include "nm-device-glue.h" -G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, G_TYPE_OBJECT) +G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, NM_TYPE_EXPORTED_OBJECT) #define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate)) @@ -526,6 +525,7 @@ nm_device_dbus_export (NMDevice *self) priv->path = g_strdup_printf ("/org/freedesktop/NetworkManager/Devices/%d", devcount++); _LOGD (LOGD_DEVICE, "exported as %s", priv->path); + nm_dbus_manager_register_object (nm_dbus_manager_get (), priv->path, self); } @@ -9766,10 +9766,8 @@ nm_device_class_init (NMDeviceClass *klass) 0, NULL, NULL, NULL, G_TYPE_NONE, 0); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_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/nm-device.h b/src/devices/nm-device.h index cb4476435d..88c71b161e 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -25,7 +25,7 @@ #include #include -#include "nm-glib.h" +#include "nm-exported-object.h" #include "nm-dbus-interface.h" #include "nm-types.h" #include "nm-connection.h" @@ -104,7 +104,7 @@ typedef enum { /*< skip >*/ } NMDeviceCheckConAvailableFlags; struct _NMDevice { - GObject parent; + NMExportedObject parent; }; /* The flags have an relaxing meaning, that means, specifying more flags, can make @@ -118,7 +118,7 @@ typedef enum { /*< skip >*/ } NMDeviceCheckDevAvailableFlags; typedef struct { - GObjectClass parent; + NMExportedObjectClass parent; const char *connection_type; diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 1de22138b6..129f0bb26e 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -35,7 +35,6 @@ #include "nm-device-private.h" #include "nm-platform.h" #include "nm-dbus-glib-types.h" -#include "nm-dbus-manager.h" #include "nm-enum-types.h" #include "nm-team-enum-types.h" #include "nm-core-internal.h" @@ -824,7 +823,7 @@ nm_device_team_class_init (NMDeviceTeamClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_team_object_info); } diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 7dc7c11b00..cdc9606d61 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -50,7 +50,6 @@ #include "nm-setting-olpc-mesh.h" #include "nm-manager.h" #include "nm-enum-types.h" -#include "nm-dbus-manager.h" #include "nm-platform.h" #include "nm-wifi-enum-types.h" @@ -551,8 +550,7 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_olpc_mesh_object_info); } diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 62c64a125b..c6e1fa749e 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -29,7 +29,6 @@ #include #include "nm-glib.h" -#include "nm-dbus-manager.h" #include "nm-device.h" #include "nm-device-wifi.h" #include "nm-device-private.h" @@ -3062,8 +3061,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) scanning_allowed_accumulator, NULL, NULL, G_TYPE_BOOLEAN, 0); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (klass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), &dbus_glib_nm_device_wifi_object_info); } diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c index ca272a001c..804d3566a6 100644 --- a/src/devices/wifi/nm-wifi-ap.c +++ b/src/devices/wifi/nm-wifi-ap.c @@ -67,7 +67,7 @@ typedef struct #define NM_AP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_AP, NMAccessPointPrivate)) -G_DEFINE_TYPE (NMAccessPoint, nm_ap, G_TYPE_OBJECT) +G_DEFINE_TYPE (NMAccessPoint, nm_ap, NM_TYPE_EXPORTED_OBJECT) enum { PROP_0, @@ -1074,8 +1074,7 @@ nm_ap_class_init (NMAccessPointClass *ap_class) -1, G_MAXINT, -1, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (ap_class), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (ap_class), &dbus_glib_nm_access_point_object_info); } diff --git a/src/devices/wifi/nm-wifi-ap.h b/src/devices/wifi/nm-wifi-ap.h index 47e901ee22..3c8e2f009b 100644 --- a/src/devices/wifi/nm-wifi-ap.h +++ b/src/devices/wifi/nm-wifi-ap.h @@ -22,7 +22,7 @@ #ifndef __NETWORKMANAGER_ACCESS_POINT_H__ #define __NETWORKMANAGER_ACCESS_POINT_H__ -#include "nm-glib.h" +#include "nm-exported-object.h" #include "nm-dbus-interface.h" #include "nm-connection.h" @@ -45,11 +45,11 @@ #define NM_AP_LAST_SEEN "last-seen" typedef struct { - GObject parent; + NMExportedObject parent; } NMAccessPoint; typedef struct { - GObjectClass parent; + NMExportedObjectClass parent; } NMAccessPointClass; diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index 02b0e5af89..bd115b429a 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -28,7 +28,6 @@ #include "nm-device-private.h" #include "nm-rfkill-manager.h" #include "nm-logging.h" -#include "nm-dbus-manager.h" #include "nm-settings-connection.h" #include "nm-modem-broadband.h" #include "NetworkManagerUtils.h" @@ -795,7 +794,6 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (mclass), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (mclass), &dbus_glib_nm_device_modem_object_info); } diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 3385a6fd3b..eeab0390e7 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -26,7 +26,6 @@ #include "nm-platform.h" #include "nm-dbus-manager.h" #include "nm-setting-connection.h" -#include "nm-properties-changed-signal.h" #include "nm-logging.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" diff --git a/src/dhcp-manager/tests/Makefile.am b/src/dhcp-manager/tests/Makefile.am index 8aa79a29be..206974ba42 100644 --- a/src/dhcp-manager/tests/Makefile.am +++ b/src/dhcp-manager/tests/Makefile.am @@ -9,6 +9,7 @@ AM_CPPFLAGS = \ -DNETWORKMANAGER_COMPILATION \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) \ -DTESTDIR="\"$(abs_srcdir)\"" noinst_PROGRAMS = \ diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c index 4c449d1de9..3ffe5359a4 100644 --- a/src/nm-active-connection.c +++ b/src/nm-active-connection.c @@ -37,7 +37,7 @@ #include "nm-active-connection-glue.h" /* Base class for anything implementing the Connection.Active D-Bus interface */ -G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, G_TYPE_OBJECT) +G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_EXPORTED_OBJECT) #define NM_ACTIVE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ NM_TYPE_ACTIVE_CONNECTION, \ @@ -1066,8 +1066,7 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class) NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_UINT); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (ac_class), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_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 01568c8fe0..a483895ade 100644 --- a/src/nm-active-connection.h +++ b/src/nm-active-connection.h @@ -21,8 +21,7 @@ #ifndef __NETWORKMANAGER_ACTIVE_CONNECTION_H__ #define __NETWORKMANAGER_ACTIVE_CONNECTION_H__ -#include "nm-glib.h" -#include "nm-types.h" +#include "nm-exported-object.h" #include "nm-connection.h" #define NM_TYPE_ACTIVE_CONNECTION (nm_active_connection_get_type ()) @@ -61,11 +60,11 @@ #define NM_ACTIVE_CONNECTION_DEVICE_METERED_CHANGED "device-metered-changed" struct _NMActiveConnection { - GObject parent; + NMExportedObject parent; }; typedef struct { - GObjectClass parent; + NMExportedObjectClass parent; /* re-emits device state changes as a convenience for subclasses for * device states >= DISCONNECTED. diff --git a/src/nm-dbus-manager.c b/src/nm-dbus-manager.c index 0a664b0a12..48f0084228 100644 --- a/src/nm-dbus-manager.c +++ b/src/nm-dbus-manager.c @@ -29,7 +29,6 @@ #include "nm-glib.h" #include "nm-dbus-interface.h" #include "nm-dbus-manager.h" -#include "nm-properties-changed-signal.h" #include #include @@ -854,33 +853,6 @@ object_destroyed (NMDBusManager *self, gpointer object) g_hash_table_remove (NM_DBUS_MANAGER_GET_PRIVATE (self)->exported, object); } -void -nm_dbus_manager_register_exported_type (NMDBusManager *self, - GType object_type, - const DBusGObjectInfo *info) -{ - const char *properties_info, *dbus_name, *gobject_name, *tmp_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; - tmp_access = strchr (gobject_name, '\0') + 1; - properties_info = strchr (tmp_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, diff --git a/src/nm-dbus-manager.h b/src/nm-dbus-manager.h index a0e3121990..2ce12a2d41 100644 --- a/src/nm-dbus-manager.h +++ b/src/nm-dbus-manager.h @@ -104,10 +104,6 @@ gboolean nm_dbus_manager_get_caller_info_from_message (NMDBusManager *self, gulong *out_uid, gulong *out_pid); -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 ae945fdf33..08b5911503 100644 --- a/src/nm-dhcp4-config.c +++ b/src/nm-dhcp4-config.c @@ -30,7 +30,7 @@ #include "nm-dbus-glib-types.h" #include "nm-utils.h" -G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, G_TYPE_OBJECT) +G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, NM_TYPE_EXPORTED_OBJECT) #define NM_DHCP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigPrivate)) @@ -185,7 +185,6 @@ nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (config_class), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_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 c7f3797e24..29c3647ffa 100644 --- a/src/nm-dhcp4-config.h +++ b/src/nm-dhcp4-config.h @@ -21,9 +21,7 @@ #ifndef __NETWORKMANAGER_DHCP4_CONFIG_H__ #define __NETWORKMANAGER_DHCP4_CONFIG_H__ - -#include "nm-glib.h" -#include "nm-types.h" +#include "nm-exported-object.h" #define NM_TYPE_DHCP4_CONFIG (nm_dhcp4_config_get_type ()) #define NM_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP4_CONFIG, NMDhcp4Config)) @@ -33,11 +31,11 @@ #define NM_DHCP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigClass)) struct _NMDhcp4Config { - GObject parent; + NMExportedObject parent; }; typedef struct { - GObjectClass parent; + NMExportedObjectClass parent; } NMDhcp4ConfigClass; diff --git a/src/nm-dhcp6-config.c b/src/nm-dhcp6-config.c index f96807caba..e127443345 100644 --- a/src/nm-dhcp6-config.c +++ b/src/nm-dhcp6-config.c @@ -30,7 +30,7 @@ #include "nm-dbus-glib-types.h" #include "nm-utils.h" -G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, G_TYPE_OBJECT) +G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, NM_TYPE_EXPORTED_OBJECT) #define NM_DHCP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigPrivate)) @@ -185,7 +185,6 @@ nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (config_class), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_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 53d8b52a4f..e5688d06b5 100644 --- a/src/nm-dhcp6-config.h +++ b/src/nm-dhcp6-config.h @@ -21,9 +21,7 @@ #ifndef __NETWORKMANAGER_DHCP6_CONFIG_H__ #define __NETWORKMANAGER_DHCP6_CONFIG_H__ - -#include "nm-glib.h" -#include "nm-types.h" +#include "nm-exported-object.h" #define NM_TYPE_DHCP6_CONFIG (nm_dhcp6_config_get_type ()) #define NM_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP6_CONFIG, NMDhcp6Config)) @@ -33,11 +31,11 @@ #define NM_DHCP6_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigClass)) struct _NMDhcp6Config { - GObject parent; + NMExportedObject parent; }; typedef struct { - GObjectClass parent; + NMExportedObjectClass parent; } NMDhcp6ConfigClass; diff --git a/src/nm-exported-object.c b/src/nm-exported-object.c new file mode 100644 index 0000000000..c991b8b614 --- /dev/null +++ b/src/nm-exported-object.c @@ -0,0 +1,247 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2014-2015 Red Hat, Inc. + */ + +#include "config.h" + +#include + +#include "nm-exported-object.h" +#include "nm-dbus-glib-types.h" +#include "nm-logging.h" + +G_DEFINE_ABSTRACT_TYPE (NMExportedObject, nm_exported_object, G_TYPE_OBJECT) + +typedef struct { + GHashTable *pending_notifies; + guint notify_idle_id; +} NMExportedObjectPrivate; + +#define NM_EXPORTED_OBJECT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_EXPORTED_OBJECT, NMExportedObjectPrivate)) + +enum { + PROPERTIES_CHANGED, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +typedef struct { + GHashTable *properties; +} NMExportedObjectClassInfo; + +GQuark nm_exported_object_class_info_quark (void); +G_DEFINE_QUARK (NMExportedObjectClassInfo, nm_exported_object_class_info) + +/** + * nm_exported_object_class_add_interface: + * @object_class: an #NMExportedObjectClass + * @info: generated #DBusGObjectInfo for the class + * + * Adds @info to the list of D-Bus interfaces implemented by @object_class and + * sets up automatic dbus-glib handling for instances of that class. + * + * If @info includes any properties, then a "PropertiesChanged" signal will + * be emitted on @info's interface whenever any of those properties change on + * an exported instance of @object_class. + */ +void +nm_exported_object_class_add_interface (NMExportedObjectClass *object_class, + const DBusGObjectInfo *info) +{ + GType object_type = G_TYPE_FROM_CLASS (object_class); + NMExportedObjectClassInfo *classinfo; + const char *properties_info, *dbus_name, *gobject_name, *tmp_access; + char *hyphen_name, *p; + + dbus_g_object_type_install_info (object_type, info); + if (!info->exported_properties) + return; + + classinfo = g_type_get_qdata (object_type, nm_exported_object_class_info_quark ()); + if (!classinfo) { + classinfo = g_slice_new (NMExportedObjectClassInfo); + classinfo->properties = g_hash_table_new (g_str_hash, g_str_equal); + g_type_set_qdata (object_type, nm_exported_object_class_info_quark (), classinfo); + } + + 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; + tmp_access = strchr (gobject_name, '\0') + 1; + properties_info = strchr (tmp_access, '\0') + 1; + + if (strchr (gobject_name, '_')) { + hyphen_name = g_strdup (gobject_name); + for (p = hyphen_name; *p; p++) { + if (*p == '_') + *p = '-'; + } + g_assert (!g_hash_table_contains (classinfo->properties, hyphen_name)); + g_hash_table_insert (classinfo->properties, + (char *) g_intern_string (hyphen_name), + (char *) dbus_name); + g_free (hyphen_name); + } else { + g_assert (!g_hash_table_contains (classinfo->properties, (char *) gobject_name)); + g_hash_table_insert (classinfo->properties, + (char *) gobject_name, + (char *) dbus_name); + } + } +} + +static void +destroy_value (gpointer data) +{ + GValue *val = (GValue *) data; + + g_value_unset (val); + g_slice_free (GValue, val); +} + +static void +nm_exported_object_init (NMExportedObject *self) +{ + NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (self); + + priv->pending_notifies = g_hash_table_new_full (g_str_hash, g_str_equal, + NULL, destroy_value); +} + +static void +add_to_string (gpointer key, gpointer value, gpointer 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); + if (!g_value_transform ((GValue *) value, &str_val)) { + if (G_VALUE_HOLDS_OBJECT (value)) { + GObject *obj = g_value_get_object (value); + + 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 + g_string_append_printf (buf, "{%s: }, ", name); + } else + g_string_append_printf (buf, "{%s: %s}, ", name, g_value_get_string (&str_val)); + g_value_unset (&str_val); +} + +static gboolean +idle_emit_properties_changed (gpointer self) +{ + NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (self); + + priv->notify_idle_id = 0; + + if (nm_logging_enabled (LOGL_DEBUG, LOGD_DBUS_PROPS)) { + GString *buf = g_string_new (NULL); + + g_hash_table_foreach (priv->pending_notifies, add_to_string, buf); + nm_log_dbg (LOGD_DBUS_PROPS, "%s -> %s", G_OBJECT_TYPE_NAME (self), buf->str); + g_string_free (buf, TRUE); + } + + g_signal_emit (self, signals[PROPERTIES_CHANGED], 0, priv->pending_notifies); + g_hash_table_remove_all (priv->pending_notifies); + + return FALSE; +} + +static void +nm_exported_object_notify (GObject *object, GParamSpec *pspec) +{ + NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (object); + NMExportedObjectClassInfo *classinfo; + const char *dbus_property_name = NULL; + GValue *value; + GType type; + + for (type = G_OBJECT_TYPE (object); type; type = g_type_parent (type)) { + classinfo = g_type_get_qdata (type, nm_exported_object_class_info_quark ()); + if (!classinfo) + continue; + + dbus_property_name = g_hash_table_lookup (classinfo->properties, pspec->name); + if (dbus_property_name) + break; + } + if (!dbus_property_name) { + nm_log_trace (LOGD_DBUS_PROPS, "ignoring notification for prop %s on type %s", + pspec->name, G_OBJECT_TYPE_NAME (object)); + return; + } + + value = g_slice_new0 (GValue); + g_value_init (value, pspec->value_type); + g_object_get_property (object, pspec->name, value); + g_hash_table_insert (priv->pending_notifies, (char *) dbus_property_name, value); + + if (!priv->notify_idle_id) + priv->notify_idle_id = g_idle_add (idle_emit_properties_changed, object); +} + +static void +nm_exported_object_dispose (GObject *object) +{ + NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (object); + + g_hash_table_remove_all (priv->pending_notifies); + nm_clear_g_source (&priv->notify_idle_id); + + G_OBJECT_CLASS (nm_exported_object_parent_class)->dispose (object); +} + +static void +nm_exported_object_finalize (GObject *object) +{ + NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (object); + + g_hash_table_destroy (priv->pending_notifies); + + G_OBJECT_CLASS (nm_exported_object_parent_class)->finalize (object); +} + +static void +nm_exported_object_class_init (NMExportedObjectClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (NMExportedObjectPrivate)); + + object_class->notify = nm_exported_object_notify; + object_class->dispose = nm_exported_object_dispose; + object_class->finalize = nm_exported_object_finalize; + + signals[PROPERTIES_CHANGED] = g_signal_new ("properties-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT); + +} diff --git a/src/nm-exported-object.h b/src/nm-exported-object.h new file mode 100644 index 0000000000..d9f4d28f53 --- /dev/null +++ b/src/nm-exported-object.h @@ -0,0 +1,53 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2014 Red Hat, Inc. + */ + +#ifndef NM_EXPORTED_OBJECT_H +#define NM_EXPORTED_OBJECT_H + +#include + +#include "nm-glib.h" +#include "nm-types.h" + +G_BEGIN_DECLS + +#define NM_TYPE_EXPORTED_OBJECT (nm_exported_object_get_type ()) +#define NM_EXPORTED_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_EXPORTED_OBJECT, NMExportedObject)) +#define NM_EXPORTED_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_EXPORTED_OBJECT, NMExportedObjectClass)) +#define NM_IS_EXPORTED_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_EXPORTED_OBJECT)) +#define NM_IS_EXPORTED_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_EXPORTED_OBJECT)) +#define NM_EXPORTED_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_EXPORTED_OBJECT, NMExportedObjectClass)) + +typedef struct { + GObject parent; +} NMExportedObject; + +typedef struct { + GObjectClass parent; +} NMExportedObjectClass; + +GType nm_exported_object_get_type (void); + +void nm_exported_object_class_add_interface (NMExportedObjectClass *object_class, + const DBusGObjectInfo *info); + +G_END_DECLS + +#endif /* NM_EXPORTED_OBJECT_H */ diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index e23e364578..a30b5ea97a 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -37,7 +37,7 @@ #include "nm-core-internal.h" #include "gsystem-local-alloc.h" -G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, G_TYPE_OBJECT) +G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_EXPORTED_OBJECT) #define NM_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP4_CONFIG, NMIP4ConfigPrivate)) @@ -2410,7 +2410,6 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) g_object_class_install_properties (object_class, LAST_PROP, obj_properties); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (config_class), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class), &dbus_glib_nm_ip4_config_object_info); } diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h index 753b74cb9d..a5e30a7318 100644 --- a/src/nm-ip4-config.h +++ b/src/nm-ip4-config.h @@ -21,9 +21,7 @@ #ifndef __NETWORKMANAGER_IP4_CONFIG_H__ #define __NETWORKMANAGER_IP4_CONFIG_H__ - -#include "nm-glib.h" -#include "nm-types.h" +#include "nm-exported-object.h" #include "nm-setting-ip4-config.h" #define NM_TYPE_IP4_CONFIG (nm_ip4_config_get_type ()) @@ -34,11 +32,11 @@ #define NM_IP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass)) struct _NMIP4Config { - GObject parent; + NMExportedObject parent; }; typedef struct { - GObjectClass parent; + NMExportedObjectClass parent; } NMIP4ConfigClass; /* internal */ diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 2122f64f4d..7ac436500e 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -36,7 +36,7 @@ #include "nm-core-internal.h" #include "NetworkManagerUtils.h" -G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, G_TYPE_OBJECT) +G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_EXPORTED_OBJECT) #define NM_IP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP6_CONFIG, NMIP6ConfigPrivate)) @@ -2215,7 +2215,6 @@ nm_ip6_config_class_init (NMIP6ConfigClass *config_class) g_object_class_install_properties (object_class, LAST_PROP, obj_properties); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (config_class), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class), &dbus_glib_nm_ip6_config_object_info); } diff --git a/src/nm-ip6-config.h b/src/nm-ip6-config.h index 06919026c3..5404913494 100644 --- a/src/nm-ip6-config.h +++ b/src/nm-ip6-config.h @@ -23,8 +23,7 @@ #include -#include "nm-glib.h" -#include "nm-types.h" +#include "nm-exported-object.h" #include "nm-setting-ip6-config.h" #define NM_TYPE_IP6_CONFIG (nm_ip6_config_get_type ()) @@ -35,11 +34,11 @@ #define NM_IP6_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP6_CONFIG, NMIP6ConfigClass)) struct _NMIP6Config { - GObject parent; + NMExportedObject parent; }; typedef struct { - GObjectClass parent; + NMExportedObjectClass parent; } NMIP6ConfigClass; /* internal */ diff --git a/src/nm-manager.c b/src/nm-manager.c index 9a035c0fd4..96ec61ec33 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -194,7 +194,7 @@ typedef struct { #define NM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MANAGER, NMManagerPrivate)) -G_DEFINE_TYPE (NMManager, nm_manager, G_TYPE_OBJECT) +G_DEFINE_TYPE (NMManager, nm_manager, NM_TYPE_EXPORTED_OBJECT) enum { DEVICE_ADDED, @@ -5298,8 +5298,7 @@ nm_manager_class_init (NMManagerClass *manager_class) 0, NULL, NULL, NULL, G_TYPE_NONE, 0); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (manager_class), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (manager_class), &dbus_glib_nm_manager_object_info); dbus_g_error_domain_register (NM_MANAGER_ERROR, NM_DBUS_INTERFACE, NM_TYPE_MANAGER_ERROR); diff --git a/src/nm-manager.h b/src/nm-manager.h index 665a8dd701..d8b566851d 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -22,9 +22,7 @@ #ifndef __NETWORKMANAGER_MANAGER_H__ #define __NETWORKMANAGER_MANAGER_H__ - -#include "nm-glib.h" -#include "nm-types.h" +#include "nm-exported-object.h" #include "nm-connection.h" #define NM_TYPE_MANAGER (nm_manager_get_type ()) @@ -63,11 +61,11 @@ struct _NMManager { - GObject parent; + NMExportedObject parent; }; typedef struct { - GObjectClass parent; + NMExportedObjectClass parent; /* Signals */ void (*device_added) (NMManager *manager, NMDevice *device); diff --git a/src/nm-properties-changed-signal.c b/src/nm-properties-changed-signal.c deleted file mode 100644 index c6dbb3d532..0000000000 --- a/src/nm-properties-changed-signal.c +++ /dev/null @@ -1,248 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2008 - 2012 Red Hat, Inc. - */ - -#include "config.h" - -#include -#include - -#include -#include "nm-logging.h" -#include "nm-properties-changed-signal.h" -#include "nm-dbus-glib-types.h" - -typedef struct { - GHashTable *exported_props; - guint signal_id; -} NMPropertiesChangedClassInfo; - -typedef struct { - GHashTable *hash; - guint signal_id; - guint idle_id; -} 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) -{ - GValue *val = (GValue *) data; - - g_value_unset (val); - g_slice_free (GValue, val); -} - -static void -properties_changed_info_destroy (gpointer data) -{ - NMPropertiesChangedInfo *info = data; - - if (info->idle_id) - g_source_remove (info->idle_id); - - g_hash_table_destroy (info->hash); - g_slice_free (NMPropertiesChangedInfo, info); -} - -static void -add_to_string (gpointer key, gpointer value, gpointer 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); - if (!g_value_transform ((GValue *) value, &str_val)) { - if (G_VALUE_HOLDS_OBJECT (value)) { - GObject *obj = g_value_get_object (value); - - 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 - g_string_append_printf (buf, "{%s: }, ", name); - } else - g_string_append_printf (buf, "{%s: %s}, ", name, g_value_get_string (&str_val)); - g_value_unset (&str_val); -} - -static gboolean -properties_changed (gpointer data) -{ - GObject *object = G_OBJECT (data); - NMPropertiesChangedInfo *info = g_object_get_qdata (object, nm_properties_changed_signal_quark ()); - - g_assert (info); - - if (nm_logging_enabled (LOGL_DEBUG, LOGD_DBUS_PROPS)) { - GString *buf = g_string_new (NULL); - - g_hash_table_foreach (info->hash, add_to_string, buf); - nm_log_dbg (LOGD_DBUS_PROPS, "%s -> %s", G_OBJECT_TYPE_NAME (object), buf->str); - g_string_free (buf, TRUE); - } - - g_signal_emit (object, info->signal_id, 0, info->hash); - g_hash_table_remove_all (info->hash); - - return FALSE; -} - -static void -idle_id_reset (gpointer data) -{ - GObject *object = G_OBJECT (data); - 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 void -notify (GObject *object, GParamSpec *pspec) -{ - NMPropertiesChangedClassInfo *classinfo; - NMPropertiesChangedInfo *info; - const char *dbus_property_name = NULL; - GValue *value; - GType type; - - 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_trace (LOGD_DBUS_PROPS, "ignoring notification for prop %s on type %s", - pspec->name, G_OBJECT_TYPE_NAME (object)); - return; - } - - info = g_object_get_qdata (object, nm_properties_changed_signal_quark ()); - if (!info) { - 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, (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); -} - -static NMPropertiesChangedClassInfo * -nm_properties_changed_signal_setup_type (GType type) -{ - 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); - } - - 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); - - g_assert (!g_hash_table_contains (classinfo->exported_props, (char *) gobject_property_name)); - g_hash_table_insert (classinfo->exported_props, - (char *) gobject_property_name, - (char *) dbus_property_name); - - if (!strchr (gobject_property_name, '_')) - return; - hyphen_name = g_strdup (gobject_property_name); - for (p = hyphen_name; *p; p++) { - if (*p == '_') - *p = '-'; - } - g_assert (!g_hash_table_contains (classinfo->exported_props, hyphen_name)); - g_hash_table_insert (classinfo->exported_props, - (char *) g_intern_string (hyphen_name), - (char *) dbus_property_name); - g_free (hyphen_name); -} diff --git a/src/nm-properties-changed-signal.h b/src/nm-properties-changed-signal.h deleted file mode 100644 index 6f76e8a4ae..0000000000 --- a/src/nm-properties-changed-signal.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2008 Red Hat, Inc. - */ - -#ifndef _NM_PROPERTIES_CHANGED_SIGNAL_H_ -#define _NM_PROPERTIES_CHANGED_SIGNAL_H_ - -#include "nm-glib.h" - -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/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index 6e1e5c2a2a..0a45dd1542 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -95,7 +95,7 @@ typedef struct { #define NM_PPP_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_PPP_MANAGER, NMPPPManagerPrivate)) -G_DEFINE_TYPE (NMPPPManager, nm_ppp_manager, G_TYPE_OBJECT) +G_DEFINE_TYPE (NMPPPManager, nm_ppp_manager, NM_TYPE_EXPORTED_OBJECT) enum { STATE_CHANGED, @@ -672,8 +672,8 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class) G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (manager_class), - &dbus_glib_nm_ppp_manager_object_info); + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (manager_class), + &dbus_glib_nm_ppp_manager_object_info); } /*******************************************/ diff --git a/src/ppp-manager/nm-ppp-manager.h b/src/ppp-manager/nm-ppp-manager.h index 9528721532..057f40982f 100644 --- a/src/ppp-manager/nm-ppp-manager.h +++ b/src/ppp-manager/nm-ppp-manager.h @@ -23,7 +23,7 @@ #define __NETWORKMANAGER_PPP_MANAGER_H__ -#include "nm-glib.h" +#include "nm-exported-object.h" #include "nm-ppp-status.h" #include "nm-activation-request.h" #include "nm-connection.h" @@ -42,11 +42,11 @@ #define NM_PPP_MANAGER_PARENT_IFACE "parent-iface" typedef struct { - GObject parent; + NMExportedObject parent; } NMPPPManager; typedef struct { - GObjectClass parent; + NMExportedObjectClass parent; /* Signals */ void (*state_changed) (NMPPPManager *manager, NMPPPStatus status); diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c index 7da9ee5f43..f41c49636a 100644 --- a/src/settings/nm-agent-manager.c +++ b/src/settings/nm-agent-manager.c @@ -43,7 +43,7 @@ #include "nm-simple-connection.h" #include "NetworkManagerUtils.h" -G_DEFINE_TYPE (NMAgentManager, nm_agent_manager, G_TYPE_OBJECT) +G_DEFINE_TYPE (NMAgentManager, nm_agent_manager, NM_TYPE_EXPORTED_OBJECT) #define NM_AGENT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ NM_TYPE_AGENT_MANAGER, \ @@ -1622,8 +1622,8 @@ nm_agent_manager_class_init (NMAgentManagerClass *agent_manager_class) G_TYPE_NONE, 1, G_TYPE_OBJECT); - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (agent_manager_class), - &dbus_glib_nm_agent_manager_object_info); + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (agent_manager_class), + &dbus_glib_nm_agent_manager_object_info); dbus_g_error_domain_register (NM_AGENT_MANAGER_ERROR, NM_DBUS_INTERFACE_AGENT_MANAGER, diff --git a/src/settings/nm-agent-manager.h b/src/settings/nm-agent-manager.h index ab010edb71..4ece8940e0 100644 --- a/src/settings/nm-agent-manager.h +++ b/src/settings/nm-agent-manager.h @@ -22,9 +22,9 @@ #define __NETWORKMANAGER_AGENT_MANAGER_H__ #include -#include "nm-glib.h" + +#include "nm-exported-object.h" #include "nm-secret-agent.h" -#include "nm-types.h" #define NM_TYPE_AGENT_MANAGER (nm_agent_manager_get_type ()) #define NM_AGENT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_AGENT_MANAGER, NMAgentManager)) @@ -34,11 +34,11 @@ #define NM_AGENT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AGENT_MANAGER, NMAgentManagerClass)) struct _NMAgentManager { - GObject parent; + NMExportedObject parent; }; typedef struct { - GObjectClass parent; + NMExportedObjectClass parent; /* Signals */ void (*agent_registered) (NMAgentManager *agent_mgr, NMSecretAgent *agent); diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index 24e9395963..f8b2ad1dc4 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -36,7 +36,6 @@ #include "nm-auth-subject.h" #include "nm-agent-manager.h" #include "NetworkManagerUtils.h" -#include "nm-properties-changed-signal.h" #include "nm-core-internal.h" #include "gsystem-local-alloc.h" @@ -113,7 +112,7 @@ static void impl_settings_connection_clear_secrets (NMSettingsConnection *self, static void nm_settings_connection_connection_interface_init (NMConnectionInterface *iface); -G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, G_TYPE_OBJECT, +G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_EXPORTED_OBJECT, G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_settings_connection_connection_interface_init) ) @@ -2513,8 +2512,7 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (class), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (class), &dbus_glib_nm_settings_connection_object_info); } diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h index 0d3963d3df..734d917877 100644 --- a/src/settings/nm-settings-connection.h +++ b/src/settings/nm-settings-connection.h @@ -24,6 +24,7 @@ #include +#include "nm-exported-object.h" #include #include "nm-types.h" @@ -95,11 +96,11 @@ typedef void (*NMSettingsConnectionDeleteFunc) (NMSettingsConnection *self, gpointer user_data); struct _NMSettingsConnection { - GObject parent; + NMExportedObject parent; }; struct _NMSettingsConnectionClass { - GObjectClass parent; + NMExportedObjectClass parent; /* virtual methods */ void (*replace_and_commit) (NMSettingsConnection *self, diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 183a14b377..7dd2e694c7 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -156,7 +156,7 @@ static void unrecognized_specs_changed (NMSystemConfigInterface *config, gpointe static void connection_provider_init (NMConnectionProvider *cp_class); -G_DEFINE_TYPE_EXTENDED (NMSettings, nm_settings, G_TYPE_OBJECT, 0, +G_DEFINE_TYPE_EXTENDED (NMSettings, nm_settings, NM_TYPE_EXPORTED_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION_PROVIDER, connection_provider_init)) @@ -192,7 +192,6 @@ typedef struct { #define NM_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTINGS, NMSettingsPrivate)) enum { - PROPERTIES_CHANGED, CONNECTION_ADDED, CONNECTION_UPDATED, CONNECTION_UPDATED_BY_USER, @@ -456,51 +455,6 @@ nm_settings_get_connection_by_path (NMSettings *self, const char *path) return (NMSettingsConnection *) g_hash_table_lookup (priv->connections, path); } -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) -{ - GValue *value; - GHashTable *hash; - - value = g_slice_new0 (GValue); - hash = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL); - - g_value_init (value, pspec->value_type); - g_object_get_property (object, pspec->name, value); - g_hash_table_insert (hash, uscore_to_wincaps (pspec->name), value); - g_signal_emit (object, signals[PROPERTIES_CHANGED], 0, hash); - g_hash_table_destroy (hash); - g_value_unset (value); - g_slice_free (GValue, value); -} - gboolean nm_settings_has_connection (NMSettings *self, NMConnection *connection) { @@ -2329,7 +2283,6 @@ nm_settings_class_init (NMSettingsClass *class) g_type_class_add_private (class, sizeof (NMSettingsPrivate)); /* virtual methods */ - object_class->notify = notify; object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; @@ -2365,14 +2318,6 @@ nm_settings_class_init (NMSettingsClass *class) G_PARAM_STATIC_STRINGS)); /* signals */ - signals[PROPERTIES_CHANGED] = - g_signal_new ("properties-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsClass, properties_changed), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT); signals[CONNECTION_ADDED] = g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_ADDED, G_OBJECT_CLASS_TYPE (object_class), @@ -2435,14 +2380,14 @@ nm_settings_class_init (NMSettingsClass *class) g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (class), + &dbus_glib_nm_settings_object_info); + dbus_g_error_domain_register (NM_SETTINGS_ERROR, NM_DBUS_INTERFACE_SETTINGS, NM_TYPE_SETTINGS_ERROR); dbus_g_error_domain_register (NM_CONNECTION_ERROR, NM_DBUS_INTERFACE_SETTINGS_CONNECTION, NM_TYPE_CONNECTION_ERROR); - - dbus_g_object_type_install_info (NM_TYPE_SETTINGS, &dbus_glib_nm_settings_object_info); - } diff --git a/src/settings/nm-settings.h b/src/settings/nm-settings.h index 2c163cb73d..f28d010bdf 100644 --- a/src/settings/nm-settings.h +++ b/src/settings/nm-settings.h @@ -28,8 +28,7 @@ #include -#include "nm-glib.h" -#include "nm-types.h" +#include "nm-exported-object.h" #define NM_TYPE_SETTINGS (nm_settings_get_type ()) #define NM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS, NMSettings)) @@ -52,11 +51,11 @@ #define NM_SETTINGS_SIGNAL_AGENT_REGISTERED "agent-registered" struct _NMSettings { - GObject parent_instance; + NMExportedObject parent_instance; }; typedef struct { - GObjectClass parent_class; + NMExportedObjectClass parent_class; /* Signals */ void (*properties_changed) (NMSettings *self, GHashTable *properties); diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index cef69c13b2..4b968aa08d 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -98,7 +98,7 @@ static NMIfcfgConnection *update_connection (SCPluginIfcfg *plugin, static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); -G_DEFINE_TYPE_EXTENDED (SCPluginIfcfg, sc_plugin_ifcfg, G_TYPE_OBJECT, 0, +G_DEFINE_TYPE_EXTENDED (SCPluginIfcfg, sc_plugin_ifcfg, NM_TYPE_EXPORTED_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, system_config_interface_init)) @@ -897,8 +897,8 @@ sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class) NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (req_class), - &dbus_glib_nm_ifcfg_rh_object_info); + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (req_class), + &dbus_glib_nm_ifcfg_rh_object_info); } static void diff --git a/src/settings/plugins/ifcfg-rh/plugin.h b/src/settings/plugins/ifcfg-rh/plugin.h index 2f757edff0..85eb1f7a8d 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.h +++ b/src/settings/plugins/ifcfg-rh/plugin.h @@ -24,7 +24,7 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include "nm-glib.h" +#include "nm-exported-object.h" #define SC_TYPE_PLUGIN_IFCFG (sc_plugin_ifcfg_get_type ()) #define SC_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfg)) @@ -37,11 +37,11 @@ typedef struct _SCPluginIfcfg SCPluginIfcfg; typedef struct _SCPluginIfcfgClass SCPluginIfcfgClass; struct _SCPluginIfcfg { - GObject parent; + NMExportedObject parent; }; struct _SCPluginIfcfgClass { - GObjectClass parent; + NMExportedObjectClass parent; }; GType sc_plugin_ifcfg_get_type (void); diff --git a/src/settings/plugins/ifnet/Makefile.am b/src/settings/plugins/ifnet/Makefile.am index b0cfd9a11e..e2dec3b6f6 100644 --- a/src/settings/plugins/ifnet/Makefile.am +++ b/src/settings/plugins/ifnet/Makefile.am @@ -13,6 +13,7 @@ AM_CPPFLAGS = \ -DNETWORKMANAGER_COMPILATION \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) \ -DSYSCONFDIR=\"$(sysconfdir)\" -DSBINDIR=\"$(sbindir)\" diff --git a/src/settings/plugins/ifnet/tests/Makefile.am b/src/settings/plugins/ifnet/tests/Makefile.am index c41d4df94a..afb215bac8 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.am +++ b/src/settings/plugins/ifnet/tests/Makefile.am @@ -15,6 +15,7 @@ AM_CPPFLAGS= \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(CHECK_CFLAGS) \ $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ -DTEST_IFNET_DIR=\"$(abs_srcdir)\" \ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ diff --git a/src/settings/plugins/ifupdown/Makefile.am b/src/settings/plugins/ifupdown/Makefile.am index 0ca543e344..a67b96bd27 100644 --- a/src/settings/plugins/ifupdown/Makefile.am +++ b/src/settings/plugins/ifupdown/Makefile.am @@ -12,6 +12,7 @@ AM_CPPFLAGS = \ -DNETWORKMANAGER_COMPILATION \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ + $(DBUS_CFLAGS) \ $(GUDEV_CFLAGS) \ -DSYSCONFDIR=\"$(sysconfdir)\" diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index 4db6fff1d2..29a0e9798f 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -32,7 +32,6 @@ #include "nm-vpn-connection.h" #include "nm-ip4-config.h" #include "nm-ip6-config.h" -#include "nm-dbus-manager.h" #include "nm-platform.h" #include "nm-logging.h" #include "nm-active-connection.h" @@ -2362,8 +2361,7 @@ nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class) 0, NULL, NULL, NULL, G_TYPE_NONE, 0); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (object_class), + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (connection_class), &dbus_glib_nm_vpn_connection_object_info); }