diff options
author | Dan Williams <dcbw@redhat.com> | 2013-03-01 22:58:31 +0100 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2013-04-08 11:30:32 -0500 |
commit | 661d09852d9b572932a6229a4092be6ee670cfab (patch) | |
tree | a931cb9998fb00cdf2a6a5d21fa1139a2580df80 /libnm-glib | |
parent | 44f350c99d0a7e7fed66b5fd839e5f97335610a6 (diff) | |
download | NetworkManager-661d09852d9b572932a6229a4092be6ee670cfab.tar.gz |
libnm-glib: use helpers to create dbus proxies
When using a private connection, we need to use dbus_g_proxy_new_for_peer()
because the bus isn't involved. Since many parts of libnm-glib create a
proxy for their corresponding remote object, consolidate the proxy creation
logic.
A later patch will add logic to use a private connection versus a bus-based
one.
Diffstat (limited to 'libnm-glib')
26 files changed, 81 insertions, 206 deletions
diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c index 9326d3abce..ade8d6ee61 100644 --- a/libnm-glib/nm-access-point.c +++ b/libnm-glib/nm-access-point.c @@ -540,12 +540,7 @@ constructed (GObject *object) G_OBJECT_CLASS (nm_access_point_parent_class)->constructed (object); priv = NM_ACCESS_POINT_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_ACCESS_POINT); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_ACCESS_POINT); register_properties (NM_ACCESS_POINT (object)); } diff --git a/libnm-glib/nm-active-connection.c b/libnm-glib/nm-active-connection.c index 65f9ea9512..e446d93c2d 100644 --- a/libnm-glib/nm-active-connection.c +++ b/libnm-glib/nm-active-connection.c @@ -32,6 +32,7 @@ #include "nm-connection.h" #include "nm-vpn-connection.h" #include "nm-glib-compat.h" +#include "nm-dbus-helpers-private.h" static GType _nm_active_connection_type_for_path (DBusGConnection *connection, const char *path); @@ -114,10 +115,7 @@ _nm_active_connection_type_for_path (DBusGConnection *connection, GValue value = G_VALUE_INIT; GType type; - proxy = dbus_g_proxy_new_for_name (connection, - NM_DBUS_SERVICE, - path, - "org.freedesktop.DBus.Properties"); + proxy = _nm_dbus_new_proxy_for_connection (connection, path, "org.freedesktop.DBus.Properties"); if (!proxy) { g_warning ("%s: couldn't create D-Bus object proxy.", __func__); return G_TYPE_INVALID; @@ -194,8 +192,7 @@ _nm_active_connection_type_for_path_async (DBusGConnection *connection, async_data->callback = callback; async_data->user_data = user_data; - proxy = dbus_g_proxy_new_for_name (connection, NM_DBUS_SERVICE, path, - "org.freedesktop.DBus.Properties"); + proxy = _nm_dbus_new_proxy_for_connection (connection, path, "org.freedesktop.DBus.Properties"); dbus_g_proxy_begin_call (proxy, "Get", async_got_type, async_data, NULL, G_TYPE_STRING, NM_DBUS_INTERFACE_ACTIVE_CONNECTION, @@ -449,17 +446,11 @@ register_properties (NMActiveConnection *connection) static void constructed (GObject *object) { - NMActiveConnectionPrivate *priv; + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object); - priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_ACTIVE_CONNECTION); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_ACTIVE_CONNECTION); register_properties (NM_ACTIVE_CONNECTION (object)); } diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index 5a0111bf13..5709e09013 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -1477,20 +1477,13 @@ constructor (GType type, static void constructed (GObject *object) { - DBusGConnection *connection; - NMClientPrivate *priv; + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object); nm_utils_init (NULL); G_OBJECT_CLASS (nm_client_parent_class)->constructed (object); - priv = NM_CLIENT_GET_PRIVATE (object); - connection = nm_object_get_connection (NM_OBJECT (object)); - - priv->client_proxy = dbus_g_proxy_new_for_name (connection, - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE); + priv->client_proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE); register_properties (NM_CLIENT (object)); @@ -1502,7 +1495,7 @@ constructed (GObject *object) object, NULL); - priv->bus_proxy = dbus_g_proxy_new_for_name (connection, + priv->bus_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); diff --git a/libnm-glib/nm-device-adsl.c b/libnm-glib/nm-device-adsl.c index a2c21746bb..d79519936a 100644 --- a/libnm-glib/nm-device-adsl.c +++ b/libnm-glib/nm-device-adsl.c @@ -159,17 +159,11 @@ register_properties (NMDeviceAdsl *device) static void constructed (GObject *object) { - NMDeviceAdslPrivate *priv; + NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_adsl_parent_class)->constructed (object); - priv = NM_DEVICE_ADSL_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE_ADSL); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_ADSL); register_properties (NM_DEVICE_ADSL (object)); } diff --git a/libnm-glib/nm-device-bond.c b/libnm-glib/nm-device-bond.c index 5cecadf5ef..0b313b17de 100644 --- a/libnm-glib/nm-device-bond.c +++ b/libnm-glib/nm-device-bond.c @@ -222,17 +222,11 @@ register_properties (NMDeviceBond *device) static void constructed (GObject *object) { - NMDeviceBondPrivate *priv; + NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_bond_parent_class)->constructed (object); - priv = NM_DEVICE_BOND_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE_BOND); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_BOND); register_properties (NM_DEVICE_BOND (object)); } diff --git a/libnm-glib/nm-device-bridge.c b/libnm-glib/nm-device-bridge.c index 3bf470abe1..6e00920e13 100644 --- a/libnm-glib/nm-device-bridge.c +++ b/libnm-glib/nm-device-bridge.c @@ -230,17 +230,11 @@ register_properties (NMDeviceBridge *device) static void constructed (GObject *object) { - NMDeviceBridgePrivate *priv; + NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_bridge_parent_class)->constructed (object); - priv = NM_DEVICE_BRIDGE_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE_BRIDGE); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_BRIDGE); register_properties (NM_DEVICE_BRIDGE (object)); } diff --git a/libnm-glib/nm-device-bt.c b/libnm-glib/nm-device-bt.c index 050767b85d..20312a6261 100644 --- a/libnm-glib/nm-device-bt.c +++ b/libnm-glib/nm-device-bt.c @@ -258,11 +258,7 @@ constructed (GObject *object) G_OBJECT_CLASS (nm_device_bt_parent_class)->constructed (object); - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE_BLUETOOTH); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_BLUETOOTH); register_properties (NM_DEVICE_BT (object)); } diff --git a/libnm-glib/nm-device-ethernet.c b/libnm-glib/nm-device-ethernet.c index 376533e439..3831f64cdb 100644 --- a/libnm-glib/nm-device-ethernet.c +++ b/libnm-glib/nm-device-ethernet.c @@ -259,17 +259,11 @@ register_properties (NMDeviceEthernet *device) static void constructed (GObject *object) { - NMDeviceEthernetPrivate *priv; + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_ethernet_parent_class)->constructed (object); - priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE_WIRED); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_WIRED); register_properties (NM_DEVICE_ETHERNET (object)); } diff --git a/libnm-glib/nm-device-infiniband.c b/libnm-glib/nm-device-infiniband.c index 9bde425bef..a42bce0456 100644 --- a/libnm-glib/nm-device-infiniband.c +++ b/libnm-glib/nm-device-infiniband.c @@ -205,17 +205,11 @@ register_properties (NMDeviceInfiniband *device) static void constructed (GObject *object) { - NMDeviceInfinibandPrivate *priv; + NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_infiniband_parent_class)->constructed (object); - priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE_INFINIBAND); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_INFINIBAND); register_properties (NM_DEVICE_INFINIBAND (object)); } diff --git a/libnm-glib/nm-device-modem.c b/libnm-glib/nm-device-modem.c index 785eaad53a..35c757cb6a 100644 --- a/libnm-glib/nm-device-modem.c +++ b/libnm-glib/nm-device-modem.c @@ -179,17 +179,11 @@ register_properties (NMDeviceModem *device) static void constructed (GObject *object) { - NMDeviceModemPrivate *priv; + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_modem_parent_class)->constructed (object); - priv = NM_DEVICE_MODEM_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE_MODEM); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_MODEM); register_properties (NM_DEVICE_MODEM (object)); } diff --git a/libnm-glib/nm-device-olpc-mesh.c b/libnm-glib/nm-device-olpc-mesh.c index 95a60256e6..6235569fff 100644 --- a/libnm-glib/nm-device-olpc-mesh.c +++ b/libnm-glib/nm-device-olpc-mesh.c @@ -208,17 +208,11 @@ register_properties (NMDeviceOlpcMesh *device) static void constructed (GObject *object) { - NMDeviceOlpcMeshPrivate *priv; + NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->constructed (object); - priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE_OLPC_MESH); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_OLPC_MESH); register_properties (NM_DEVICE_OLPC_MESH (object)); } diff --git a/libnm-glib/nm-device-vlan.c b/libnm-glib/nm-device-vlan.c index 8028bbdde2..539a687f36 100644 --- a/libnm-glib/nm-device-vlan.c +++ b/libnm-glib/nm-device-vlan.c @@ -219,17 +219,11 @@ register_properties (NMDeviceVlan *device) static void constructed (GObject *object) { - NMDeviceVlanPrivate *priv; + NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_vlan_parent_class)->constructed (object); - priv = NM_DEVICE_VLAN_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE_VLAN); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_VLAN); register_properties (NM_DEVICE_VLAN (object)); } diff --git a/libnm-glib/nm-device-wifi.c b/libnm-glib/nm-device-wifi.c index ca2dff4f0a..ebad1210dc 100644 --- a/libnm-glib/nm-device-wifi.c +++ b/libnm-glib/nm-device-wifi.c @@ -654,17 +654,11 @@ register_properties (NMDeviceWifi *device) static void constructed (GObject *object) { - NMDeviceWifiPrivate *priv; + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_wifi_parent_class)->constructed (object); - priv = NM_DEVICE_WIFI_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE_WIRELESS); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_WIRELESS); register_properties (NM_DEVICE_WIFI (object)); g_signal_connect (NM_DEVICE (object), diff --git a/libnm-glib/nm-device-wimax.c b/libnm-glib/nm-device-wimax.c index 46dafec27b..82e48ff9e7 100644 --- a/libnm-glib/nm-device-wimax.c +++ b/libnm-glib/nm-device-wimax.c @@ -568,17 +568,11 @@ register_properties (NMDeviceWimax *wimax) static void constructed (GObject *object) { - NMDeviceWimaxPrivate *priv; + NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_wimax_parent_class)->constructed (object); - priv = NM_DEVICE_WIMAX_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE_WIMAX); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_WIMAX); register_properties (NM_DEVICE_WIMAX (object)); g_signal_connect (object, diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index 323ae442c0..89ea6ecfbd 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -47,6 +47,7 @@ #include "nm-dbus-glib-types.h" #include "nm-glib-compat.h" #include "nm-utils.h" +#include "nm-dbus-helpers-private.h" static GType _nm_device_type_for_path (DBusGConnection *connection, const char *path); @@ -319,10 +320,7 @@ constructed (GObject *object) /* Catch a subclass setting the wrong type */ g_warn_if_fail (G_OBJECT_TYPE (object) == _nm_device_gtype_from_dtype (priv->device_type)); - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DEVICE); + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE); register_properties (NM_DEVICE (object)); @@ -849,10 +847,7 @@ _nm_device_type_for_path (DBusGConnection *connection, GValue value = G_VALUE_INIT; NMDeviceType nm_dtype; - proxy = dbus_g_proxy_new_for_name (connection, - NM_DBUS_SERVICE, - path, - "org.freedesktop.DBus.Properties"); + proxy = _nm_dbus_new_proxy_for_connection (connection, path, "org.freedesktop.DBus.Properties"); if (!proxy) { g_warning ("%s: couldn't create D-Bus object proxy.", __func__); return G_TYPE_INVALID; @@ -951,8 +946,7 @@ _nm_device_type_for_path_async (DBusGConnection *connection, async_data->callback = callback; async_data->user_data = user_data; - proxy = dbus_g_proxy_new_for_name (connection, NM_DBUS_SERVICE, path, - "org.freedesktop.DBus.Properties"); + proxy = _nm_dbus_new_proxy_for_connection (connection, path, "org.freedesktop.DBus.Properties"); dbus_g_proxy_begin_call (proxy, "Get", async_got_type, async_data, NULL, G_TYPE_STRING, NM_DBUS_INTERFACE_DEVICE, diff --git a/libnm-glib/nm-dhcp4-config.c b/libnm-glib/nm-dhcp4-config.c index 60fc4251b4..a861d98204 100644 --- a/libnm-glib/nm-dhcp4-config.c +++ b/libnm-glib/nm-dhcp4-config.c @@ -90,21 +90,13 @@ register_properties (NMDHCP4Config *config) static void constructed (GObject *object) { - DBusGConnection *connection; - NMDHCP4ConfigPrivate *priv; + NMDHCP4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object); G_OBJECT_CLASS (nm_dhcp4_config_parent_class)->constructed (object); - priv = NM_DHCP4_CONFIG_GET_PRIVATE (object); priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - connection = nm_object_get_connection (NM_OBJECT (object)); - - priv->proxy = dbus_g_proxy_new_for_name (connection, - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DHCP4_CONFIG); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DHCP4_CONFIG); register_properties (NM_DHCP4_CONFIG (object)); } diff --git a/libnm-glib/nm-dhcp6-config.c b/libnm-glib/nm-dhcp6-config.c index b8066a0582..ef6006b05d 100644 --- a/libnm-glib/nm-dhcp6-config.c +++ b/libnm-glib/nm-dhcp6-config.c @@ -90,21 +90,13 @@ register_properties (NMDHCP6Config *config) static void constructed (GObject *object) { - DBusGConnection *connection; - NMDHCP6ConfigPrivate *priv; + NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->constructed (object); - priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - connection = nm_object_get_connection (NM_OBJECT (object)); - - priv->proxy = dbus_g_proxy_new_for_name (connection, - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_DHCP6_CONFIG); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DHCP6_CONFIG); register_properties (NM_DHCP6_CONFIG (object)); } diff --git a/libnm-glib/nm-ip4-config.c b/libnm-glib/nm-ip4-config.c index 862e7a01a1..1ccf4bd0e1 100644 --- a/libnm-glib/nm-ip4-config.c +++ b/libnm-glib/nm-ip4-config.c @@ -135,19 +135,11 @@ register_properties (NMIP4Config *config) static void constructed (GObject *object) { - DBusGConnection *connection; - NMIP4ConfigPrivate *priv; + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object); G_OBJECT_CLASS (nm_ip4_config_parent_class)->constructed (object); - priv = NM_IP4_CONFIG_GET_PRIVATE (object); - connection = nm_object_get_connection (NM_OBJECT (object)); - - priv->proxy = dbus_g_proxy_new_for_name (connection, - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_IP4_CONFIG); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_IP4_CONFIG); register_properties (NM_IP4_CONFIG (object)); } diff --git a/libnm-glib/nm-ip6-config.c b/libnm-glib/nm-ip6-config.c index 988dcd3034..b651b0dd45 100644 --- a/libnm-glib/nm-ip6-config.c +++ b/libnm-glib/nm-ip6-config.c @@ -219,19 +219,11 @@ nm_ip6_config_get_routes (NMIP6Config *config) static void constructed (GObject *object) { - DBusGConnection *connection; - NMIP6ConfigPrivate *priv; + NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); G_OBJECT_CLASS (nm_ip6_config_parent_class)->constructed (object); - priv = NM_IP6_CONFIG_GET_PRIVATE (object); - connection = nm_object_get_connection (NM_OBJECT (object)); - - priv->proxy = dbus_g_proxy_new_for_name (connection, - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_IP6_CONFIG); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_IP6_CONFIG); register_properties (NM_IP6_CONFIG (object)); } diff --git a/libnm-glib/nm-object-private.h b/libnm-glib/nm-object-private.h index 7ec2162fb5..3c99f59e92 100644 --- a/libnm-glib/nm-object-private.h +++ b/libnm-glib/nm-object-private.h @@ -39,6 +39,9 @@ typedef struct { GType object_type; } NMPropertiesInfo; +DBusGProxy *_nm_object_new_proxy (NMObject *self, + const char *path, + const char *interface); void _nm_object_register_properties (NMObject *object, DBusGProxy *proxy, diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index ead65ca06a..b133fee72b 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -32,6 +32,7 @@ #include "nm-glib-compat.h" #include "nm-types.h" #include "nm-glib-marshal.h" +#include "nm-dbus-helpers-private.h" #define DEBUG 0 @@ -157,10 +158,9 @@ constructed (GObject *object) if (G_OBJECT_CLASS (nm_object_parent_class)->constructed) G_OBJECT_CLASS (nm_object_parent_class)->constructed (object); - priv->properties_proxy = dbus_g_proxy_new_for_name (priv->connection, - NM_DBUS_SERVICE, - priv->path, - "org.freedesktop.DBus.Properties"); + priv->properties_proxy = _nm_object_new_proxy (NM_OBJECT (object), + NULL, + "org.freedesktop.DBus.Properties"); } static gboolean @@ -1450,3 +1450,12 @@ _nm_object_reload_properties_finish (NMObject *object, GAsyncResult *result, GEr return g_simple_async_result_get_op_res_gboolean (simple); } + +DBusGProxy * +_nm_object_new_proxy (NMObject *self, const char *path, const char *interface) +{ + NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self); + + return _nm_dbus_new_proxy_for_connection (priv->connection, path ? path : priv->path, interface); +} + diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c index 4337907980..4e2bd24393 100644 --- a/libnm-glib/nm-remote-connection.c +++ b/libnm-glib/nm-remote-connection.c @@ -29,8 +29,10 @@ #include <nm-setting-connection.h> #include "nm-remote-connection.h" #include "nm-remote-connection-private.h" +#include "nm-object-private.h" #include "nm-dbus-glib-types.h" #include "nm-glib-compat.h" +#include "nm-dbus-helpers-private.h" #define NM_REMOTE_CONNECTION_BUS "bus" #define NM_REMOTE_CONNECTION_DBUS_CONNECTION "dbus-connection" @@ -359,16 +361,14 @@ nm_remote_connection_new (DBusGConnection *bus, static void constructed (GObject *object) { - NMRemoteConnectionPrivate *priv; + NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (object); - priv = NM_REMOTE_CONNECTION_GET_PRIVATE (object); g_assert (priv->bus); g_assert (nm_connection_get_path (NM_CONNECTION (object))); - priv->proxy = dbus_g_proxy_new_for_name (priv->bus, - NM_DBUS_SERVICE, - nm_connection_get_path (NM_CONNECTION (object)), - NM_DBUS_IFACE_SETTINGS_CONNECTION); + priv->proxy = _nm_dbus_new_proxy_for_connection (priv->bus, + nm_connection_get_path (NM_CONNECTION (object)), + NM_DBUS_IFACE_SETTINGS_CONNECTION); g_assert (priv->proxy); dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT); diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c index 13ee61a06a..0bfe150742 100644 --- a/libnm-glib/nm-remote-settings.c +++ b/libnm-glib/nm-remote-settings.c @@ -29,6 +29,8 @@ #include "nm-dbus-glib-types.h" #include "nm-remote-settings.h" #include "nm-remote-connection-private.h" +#include "nm-object-private.h" +#include "nm-dbus-helpers-private.h" #include "nm-glib-compat.h" static void nm_remote_settings_initable_iface_init (GInitableIface *iface); @@ -893,10 +895,9 @@ constructed (GObject *object) G_CALLBACK (name_owner_changed), object, NULL); - priv->proxy = dbus_g_proxy_new_for_name (priv->bus, - NM_DBUS_SERVICE, - NM_DBUS_PATH_SETTINGS, - NM_DBUS_IFACE_SETTINGS); + priv->proxy = _nm_dbus_new_proxy_for_connection (priv->bus, + NM_DBUS_PATH_SETTINGS, + NM_DBUS_IFACE_SETTINGS); g_assert (priv->proxy); dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT); @@ -913,10 +914,9 @@ constructed (GObject *object) /* D-Bus properties proxy */ - priv->props_proxy = dbus_g_proxy_new_for_name (priv->bus, - NM_DBUS_SERVICE, - NM_DBUS_PATH_SETTINGS, - "org.freedesktop.DBus.Properties"); + priv->props_proxy = _nm_dbus_new_proxy_for_connection (priv->bus, + NM_DBUS_PATH_SETTINGS, + "org.freedesktop.DBus.Properties"); g_assert (priv->props_proxy); /* Monitor properties */ diff --git a/libnm-glib/nm-secret-agent.c b/libnm-glib/nm-secret-agent.c index 1049f0e8e1..b636263b72 100644 --- a/libnm-glib/nm-secret-agent.c +++ b/libnm-glib/nm-secret-agent.c @@ -23,13 +23,11 @@ #include <dbus/dbus-glib-lowlevel.h> #include "nm-glib-compat.h" - -#include <NetworkManager.h> - +#include "NetworkManager.h" #include "nm-secret-agent.h" #include "nm-glib-enum-types.h" #include "nm-glib-marshal.h" -#include "NetworkManager.h" +#include "nm-dbus-helpers-private.h" static void impl_secret_agent_get_secrets (NMSecretAgent *self, GHashTable *connection_hash, @@ -826,10 +824,9 @@ nm_secret_agent_init (NMSecretAgent *self) G_CALLBACK (name_owner_changed), self, NULL); - priv->manager_proxy = dbus_g_proxy_new_for_name (priv->bus, - NM_DBUS_SERVICE, - NM_DBUS_PATH_AGENT_MANAGER, - NM_DBUS_INTERFACE_AGENT_MANAGER); + priv->manager_proxy = _nm_dbus_new_proxy_for_connection (priv->bus, + NM_DBUS_PATH_AGENT_MANAGER, + NM_DBUS_INTERFACE_AGENT_MANAGER); if (!priv->manager_proxy) { g_warning ("Couldn't create NM agent manager proxy."); return; diff --git a/libnm-glib/nm-vpn-connection.c b/libnm-glib/nm-vpn-connection.c index 1fe59e5ee8..213e986a9b 100644 --- a/libnm-glib/nm-vpn-connection.c +++ b/libnm-glib/nm-vpn-connection.c @@ -167,16 +167,11 @@ register_properties (NMVPNConnection *connection) static void constructed (GObject *object) { - NMVPNConnectionPrivate *priv; + NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object); G_OBJECT_CLASS (nm_vpn_connection_parent_class)->constructed (object); - priv = NM_VPN_CONNECTION_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_VPN_CONNECTION); + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_VPN_CONNECTION); dbus_g_object_register_marshaller (_nm_glib_marshal_VOID__UINT_UINT, G_TYPE_NONE, diff --git a/libnm-glib/nm-wimax-nsp.c b/libnm-glib/nm-wimax-nsp.c index baa4b3e162..b837f9cb42 100644 --- a/libnm-glib/nm-wimax-nsp.c +++ b/libnm-glib/nm-wimax-nsp.c @@ -278,17 +278,11 @@ register_properties (NMWimaxNsp *nsp) static void constructed (GObject *object) { - NMWimaxNspPrivate *priv; + NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (object); G_OBJECT_CLASS (nm_wimax_nsp_parent_class)->constructed (object); - priv = NM_WIMAX_NSP_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_WIMAX_NSP); - + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_WIMAX_NSP); register_properties (NM_WIMAX_NSP (object)); } |