Commit c1dd3b6e authored by Dan Winship's avatar Dan Winship

core: move D-Bus export/unexport into NMExportedObject

Move D-Bus export/unexport handling into NMExportedObject and remove
type-specific export/get_path methods (export paths are now specified
at the class level, and NMExportedObject handles the counters for all
exported types automatically).

Since all exportable objects now use the same get_path() method, we
can also add some helper methods to simplify get_property()
implementations for object-path and object-path-array properties.
parent 6fcc1dee
......@@ -2904,3 +2904,46 @@ nm_utils_setpgid (gpointer unused G_GNUC_UNUSED)
pid = getpid ();
setpgid (pid, pid);
}
/**
* nm_utils_g_value_set_object_path:
* @value: a #GValue, initialized to store an object path
* @object: (allow-none): an #NMExportedObject
*
* Sets @value to @object's object path. If @object is %NULL, or not
* exported, @value is set to "/".
*/
void
nm_utils_g_value_set_object_path (GValue *value, gpointer object)
{
g_return_if_fail (!object || NM_IS_EXPORTED_OBJECT (object));
if (object && nm_exported_object_is_exported (object))
g_value_set_boxed (value, nm_exported_object_get_path (object));
else
g_value_set_boxed (value, "/");
}
/**
* nm_utils_g_value_set_object_path_array:
* @value: a #GValue, initialized to store an object path
* @objects: a #GSList of #NMExportedObjects
*
* Sets @value to an array of object paths of the objects in @objects.
*/
void
nm_utils_g_value_set_object_path_array (GValue *value, GSList *objects)
{
GPtrArray *paths;
GSList *iter;
paths = g_ptr_array_new ();
for (iter = objects; iter; iter = iter->next) {
NMExportedObject *object = iter->data;
if (!nm_exported_object_is_exported (object))
continue;
g_ptr_array_add (paths, g_strdup (nm_exported_object_get_path (object)));
}
g_value_take_boxed (value, paths);
}
......@@ -262,4 +262,7 @@ gboolean nm_utils_get_testing_initialized (void);
NMUtilsTestFlags nm_utils_get_testing (void);
void _nm_utils_set_testing (NMUtilsTestFlags flags);
void nm_utils_g_value_set_object_path (GValue *value, gpointer object);
void nm_utils_g_value_set_object_path_array (GValue *value, GSList *objects);
#endif /* __NETWORKMANAGER_UTILS_H__ */
......@@ -475,18 +475,14 @@ static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
GPtrArray *slaves;
GSList *list, *iter;
GSList *list;
switch (prop_id) {
break;
case PROP_SLAVES:
slaves = g_ptr_array_new ();
list = nm_device_master_get_slaves (NM_DEVICE (object));
for (iter = list; iter; iter = iter->next)
g_ptr_array_add (slaves, g_strdup (nm_device_get_path (NM_DEVICE (iter->data))));
nm_utils_g_value_set_object_path_array (value, list);
g_slist_free (list);
g_value_take_boxed (value, slaves);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......
......@@ -401,17 +401,14 @@ static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
GPtrArray *slaves;
GSList *list, *iter;
GSList *list;
switch (prop_id) {
break;
case PROP_SLAVES:
slaves = g_ptr_array_new ();
list = nm_device_master_get_slaves (NM_DEVICE (object));
for (iter = list; iter; iter = iter->next)
g_ptr_array_add (slaves, g_strdup (nm_device_get_path (NM_DEVICE (iter->data))));
nm_utils_g_value_set_object_path_array (value, list);
g_slist_free (list);
g_value_take_boxed (value, slaves);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......
......@@ -136,7 +136,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_PARENT:
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->props.parent_ifindex);
g_value_set_boxed (value, parent ? nm_device_get_path (parent) : "/");
nm_utils_g_value_set_object_path (value, parent);
break;
case PROP_INPUT_FLAGS:
g_value_set_uint (value, priv->props.input_flags);
......
......@@ -114,7 +114,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_PARENT:
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->props.parent_ifindex);
g_value_set_boxed (value, parent ? nm_device_get_path (parent) : "/");
nm_utils_g_value_set_object_path (value, parent);
break;
case PROP_MODE:
g_value_set_string (value, priv->props.mode);
......
......@@ -136,7 +136,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_PEER:
peer = get_peer (self);
g_value_set_boxed (value, peer ? nm_device_get_path (peer) : "/");
nm_utils_g_value_set_object_path (value, peer);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......
......@@ -514,7 +514,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_PARENT:
g_value_set_boxed (value, priv->parent ? nm_device_get_path (priv->parent) : "/");
nm_utils_g_value_set_object_path (value, priv->parent);
break;
case PROP_INT_PARENT_DEVICE:
g_value_set_object (value, priv->parent);
......
......@@ -156,7 +156,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_PARENT:
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->props.parent_ifindex);
g_value_set_boxed (value, parent ? nm_device_get_path (parent) : "/");
nm_utils_g_value_set_object_path (value, parent);
break;
case PROP_ID:
g_value_set_uint (value, priv->props.id);
......
......@@ -45,7 +45,6 @@
#include "nm-rdisc.h"
#include "nm-lndp-rdisc.h"
#include "nm-dhcp-manager.h"
#include "nm-dbus-manager.h"
#include "nm-logging.h"
#include "nm-activation-request.h"
#include "nm-ip4-config.h"
......@@ -198,7 +197,6 @@ typedef struct {
GSList *pending_actions;
char * udi;
char * path;
char * iface; /* may change, could be renamed by user */
int ifindex;
char * ip_iface;
......@@ -512,31 +510,6 @@ nm_device_has_capability (NMDevice *self, NMDeviceCapabilities caps)
/***********************************************************/
void
nm_device_dbus_export (NMDevice *self)
{
static guint32 devcount = 0;
NMDevicePrivate *priv;
g_return_if_fail (NM_IS_DEVICE (self));
priv = NM_DEVICE_GET_PRIVATE (self);
g_return_if_fail (priv->path == NULL);
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);
}
const char *
nm_device_get_path (NMDevice *self)
{
g_return_val_if_fail (self != NULL, NULL);
return NM_DEVICE_GET_PRIVATE (self)->path;
}
const char *
nm_device_get_udi (NMDevice *self)
{
......@@ -6388,25 +6361,23 @@ nm_device_set_ip4_config (NMDevice *self,
nm_ip4_config_replace (old_config, new_config, &has_changes);
if (has_changes) {
_LOGD (LOGD_IP4, "update IP4Config instance (%s)",
nm_ip4_config_get_dbus_path (old_config));
nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config)));
}
} else {
has_changes = TRUE;
priv->ip4_config = g_object_ref (new_config);
if (success && !nm_ip4_config_get_dbus_path (new_config)) {
/* Export over D-Bus */
nm_ip4_config_export (new_config);
}
if (success && !nm_exported_object_is_exported (NM_EXPORTED_OBJECT (new_config)))
nm_exported_object_export (NM_EXPORTED_OBJECT (new_config));
_LOGD (LOGD_IP4, "set IP4Config instance (%s)",
nm_ip4_config_get_dbus_path (new_config));
nm_exported_object_get_path (NM_EXPORTED_OBJECT (new_config)));
}
} else if (old_config) {
has_changes = TRUE;
priv->ip4_config = NULL;
_LOGD (LOGD_IP4, "clear IP4Config instance (%s)",
nm_ip4_config_get_dbus_path (old_config));
nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config)));
/* Device config is invalid if combined config is invalid */
g_clear_object (&priv->dev_ip4_config);
}
......@@ -6523,25 +6494,23 @@ nm_device_set_ip6_config (NMDevice *self,
nm_ip6_config_replace (old_config, new_config, &has_changes);
if (has_changes) {
_LOGD (LOGD_IP6, "update IP6Config instance (%s)",
nm_ip6_config_get_dbus_path (old_config));
nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config)));
}
} else {
has_changes = TRUE;
priv->ip6_config = g_object_ref (new_config);
if (success && !nm_ip6_config_get_dbus_path (new_config)) {
/* Export over D-Bus */
nm_ip6_config_export (new_config);
}
if (success && !nm_exported_object_is_exported (NM_EXPORTED_OBJECT (new_config)))
nm_exported_object_export (NM_EXPORTED_OBJECT (new_config));
_LOGD (LOGD_IP6, "set IP6Config instance (%s)",
nm_ip6_config_get_dbus_path (new_config));
nm_exported_object_get_path (NM_EXPORTED_OBJECT (new_config)));
}
} else if (old_config) {
has_changes = TRUE;
priv->ip6_config = NULL;
_LOGD (LOGD_IP6, "clear IP6Config instance (%s)",
nm_ip6_config_get_dbus_path (old_config));
nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config)));
}
nm_default_route_manager_ip6_update_default_route (nm_default_route_manager_get (), self);
......@@ -9157,7 +9126,6 @@ finalize (GObject *object)
g_slist_free_full (priv->pending_actions, g_free);
g_clear_pointer (&priv->physical_port_id, g_free);
g_free (priv->udi);
g_free (priv->path);
g_free (priv->iface);
g_free (priv->ip_iface);
g_free (priv->driver);
......@@ -9297,7 +9265,6 @@ get_property (GObject *object, guint prop_id,
{
NMDevice *self = NM_DEVICE (object);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
const char *ac_path = NULL;
GPtrArray *array;
GHashTableIter iter;
NMConnection *connection;
......@@ -9340,28 +9307,16 @@ get_property (GObject *object, guint prop_id,
g_value_set_uint (value, priv->mtu);
break;
case PROP_IP4_CONFIG:
if (ip_config_valid (priv->state) && priv->ip4_config)
g_value_set_boxed (value, nm_ip4_config_get_dbus_path (priv->ip4_config));
else
g_value_set_boxed (value, "/");
nm_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->ip4_config : NULL);
break;
case PROP_DHCP4_CONFIG:
if (ip_config_valid (priv->state) && priv->dhcp4_config)
g_value_set_boxed (value, nm_dhcp4_config_get_dbus_path (priv->dhcp4_config));
else
g_value_set_boxed (value, "/");
nm_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->dhcp4_config : NULL);
break;
case PROP_IP6_CONFIG:
if (ip_config_valid (priv->state) && priv->ip6_config)
g_value_set_boxed (value, nm_ip6_config_get_dbus_path (priv->ip6_config));
else
g_value_set_boxed (value, "/");
nm_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->ip6_config : NULL);
break;
case PROP_DHCP6_CONFIG:
if (ip_config_valid (priv->state) && priv->dhcp6_config)
g_value_set_boxed (value, nm_dhcp6_config_get_dbus_path (priv->dhcp6_config));
else
g_value_set_boxed (value, "/");
nm_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->dhcp6_config : NULL);
break;
case PROP_STATE:
g_value_set_uint (value, priv->state);
......@@ -9371,9 +9326,7 @@ get_property (GObject *object, guint prop_id,
dbus_g_type_struct_set (value, 0, priv->state, 1, priv->state_reason, G_MAXUINT);
break;
case PROP_ACTIVE_CONNECTION:
if (priv->act_request)
ac_path = nm_active_connection_get_path (NM_ACTIVE_CONNECTION (priv->act_request));
g_value_set_boxed (value, ac_path ? ac_path : "/");
nm_utils_g_value_set_object_path (value, priv->act_request);
break;
case PROP_DEVICE_TYPE:
g_value_set_uint (value, priv->type);
......@@ -9431,9 +9384,12 @@ static void
nm_device_class_init (NMDeviceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (klass);
g_type_class_add_private (object_class, sizeof (NMDevicePrivate));
exported_object_class->export_path = NM_DBUS_PATH "/Devices/%u";
/* Virtual methods */
object_class->dispose = dispose;
object_class->finalize = finalize;
......
......@@ -265,9 +265,6 @@ typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device,
GType nm_device_get_type (void);
const char * nm_device_get_path (NMDevice *dev);
void nm_device_dbus_export (NMDevice *device);
void nm_device_finish_init (NMDevice *device);
const char * nm_device_get_udi (NMDevice *dev);
......
......@@ -740,18 +740,14 @@ static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
GPtrArray *slaves;
GSList *list, *iter;
GSList *list;
switch (prop_id) {
break;
case PROP_SLAVES:
slaves = g_ptr_array_new ();
list = nm_device_master_get_slaves (NM_DEVICE (object));
for (iter = list; iter; iter = iter->next)
g_ptr_array_add (slaves, g_strdup (nm_device_get_path (NM_DEVICE (iter->data))));
nm_utils_g_value_set_object_path_array (value, list);
g_slist_free (list);
g_value_take_boxed (value, slaves);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......
......@@ -475,10 +475,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_COMPANION:
if (priv->companion)
g_value_set_boxed (value, nm_device_get_path (priv->companion));
else
g_value_set_boxed (value, "/");
nm_utils_g_value_set_object_path (value, priv->companion);
break;
case PROP_ACTIVE_CHANNEL:
g_value_set_uint (value, nm_platform_mesh_get_channel (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (device))));
......
......@@ -381,7 +381,7 @@ set_current_ap (NMDeviceWifi *self, NMAccessPoint *new_ap, gboolean recheck_avai
if (force_remove_old_ap || mode == NM_802_11_MODE_ADHOC || mode == NM_802_11_MODE_AP || nm_ap_get_fake (old_ap)) {
emit_ap_added_removed (self, ACCESS_POINT_REMOVED, old_ap, FALSE);
g_hash_table_remove (priv->aps, nm_ap_get_dbus_path (old_ap));
g_hash_table_remove (priv->aps, nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_ap)));
if (recheck_available_connections)
nm_device_recheck_available_connections (NM_DEVICE (self));
}
......@@ -983,7 +983,7 @@ can_auto_connect (NMDevice *device,
ap = find_first_compatible_ap (self, connection, FALSE);
if (ap) {
/* All good; connection is usable */
*specific_object = (char *) nm_ap_get_dbus_path (ap);
*specific_object = (char *) nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap));
return TRUE;
}
......@@ -1025,7 +1025,7 @@ impl_device_get_access_points (NMDeviceWifi *self,
NMAccessPoint *ap = NM_AP (iter->data);
if (nm_ap_get_ssid (ap))
g_ptr_array_add (*aps, g_strdup (nm_ap_get_dbus_path (ap)));
g_ptr_array_add (*aps, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap))));
}
g_slist_free (sorted);
return TRUE;
......@@ -1041,7 +1041,7 @@ impl_device_get_all_access_points (NMDeviceWifi *self,
*aps = g_ptr_array_new ();
sorted = get_sorted_ap_list (self);
for (iter = sorted; iter; iter = iter->next)
g_ptr_array_add (*aps, g_strdup (nm_ap_get_dbus_path (NM_AP (iter->data))));
g_ptr_array_add (*aps, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (iter->data))));
g_slist_free (sorted);
return TRUE;
}
......@@ -1494,7 +1494,7 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
NMAccessPoint *ap;
NMAccessPoint *found_ap = NULL;
const GByteArray *ssid;
const char *bssid;
const char *bssid, *ap_path;
g_return_if_fail (self != NULL);
g_return_if_fail (properties != NULL);
......@@ -1538,10 +1538,8 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
nm_ap_update_from_properties (found_ap, object_path, properties);
} else {
nm_ap_dump (ap, "added ", nm_device_get_iface (NM_DEVICE (self)));
nm_ap_export_to_dbus (ap);
g_hash_table_insert (priv->aps,
(gpointer) nm_ap_get_dbus_path (ap),
g_object_ref (ap));
ap_path = nm_exported_object_export (NM_EXPORTED_OBJECT (ap));
g_hash_table_insert (priv->aps, (gpointer) ap_path, g_object_ref (ap));
emit_ap_added_removed (self, ACCESS_POINT_ADDED, ap, TRUE);
}
......@@ -1606,7 +1604,7 @@ supplicant_iface_bss_removed_cb (NMSupplicantInterface *iface,
} else {
nm_ap_dump (ap, "removed ", nm_device_get_iface (NM_DEVICE (self)));
emit_ap_added_removed (self, ACCESS_POINT_REMOVED, ap, TRUE);
g_hash_table_remove (priv->aps, nm_ap_get_dbus_path (ap));
g_hash_table_remove (priv->aps, nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)));
schedule_ap_list_dump (self);
}
}
......@@ -2302,7 +2300,8 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
}
if (ap) {
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), nm_ap_get_dbus_path (ap));
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)));
goto done;
}
......@@ -2318,13 +2317,13 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
if (nm_ap_is_hotspot (ap))
nm_ap_set_address (ap, nm_device_get_hw_address (device));
nm_ap_export_to_dbus (ap);
g_hash_table_insert (priv->aps, (gpointer) nm_ap_get_dbus_path (ap), ap);
ap_path = nm_exported_object_export (NM_EXPORTED_OBJECT (ap));
g_hash_table_insert (priv->aps, (gpointer) ap_path, ap);
g_object_freeze_notify (G_OBJECT (self));
set_current_ap (self, ap, FALSE, FALSE);
emit_ap_added_removed (self, ACCESS_POINT_ADDED, ap, TRUE);
g_object_thaw_notify (G_OBJECT (self));
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), nm_ap_get_dbus_path (ap));
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), ap_path);
return NM_ACT_STAGE_RETURN_SUCCESS;
done:
......@@ -2695,7 +2694,8 @@ activation_success_handler (NMDevice *device)
nm_ap_set_max_bitrate (priv->current_ap, nm_platform_wifi_get_rate (NM_PLATFORM_GET, ifindex));
}
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), nm_ap_get_dbus_path (priv->current_ap));
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
nm_exported_object_get_path (NM_EXPORTED_OBJECT (priv->current_ap)));
}
periodic_update (self);
......@@ -2925,10 +2925,7 @@ get_property (GObject *object, guint prop_id,
g_value_take_boxed (value, array);
break;
case PROP_ACTIVE_ACCESS_POINT:
if (priv->current_ap)
g_value_set_boxed (value, nm_ap_get_dbus_path (priv->current_ap));
else
g_value_set_boxed (value, "/");
nm_utils_g_value_set_object_path (value, priv->current_ap);
break;
case PROP_SCANNING:
g_value_set_boolean (value, nm_supplicant_interface_get_scanning (priv->sup_iface));
......
......@@ -30,7 +30,6 @@
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-dbus-manager.h"
#include "nm-core-internal.h"
#include "nm-setting-wireless.h"
......@@ -43,9 +42,7 @@
*/
typedef struct
{
char *dbus_path;
char *supplicant_path; /* D-Bus object path of this AP from wpa_supplicant */
guint32 id; /* ID for stable sorting of APs */
/* Scanned or cached values */
GByteArray * ssid;
......@@ -94,20 +91,13 @@ nm_ap_get_supplicant_path (NMAccessPoint *ap)
return NM_AP_GET_PRIVATE (ap)->supplicant_path;
}
const char *
nm_ap_get_dbus_path (NMAccessPoint *ap)
{
g_return_val_if_fail (NM_IS_AP (ap), NULL);
return NM_AP_GET_PRIVATE (ap)->dbus_path;
}
guint32
nm_ap_get_id (NMAccessPoint *ap)
{
g_return_val_if_fail (NM_IS_AP (ap), 0);
g_return_val_if_fail (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (ap)), 0);
return NM_AP_GET_PRIVATE (ap)->id;
return atoi (strrchr (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)), '/') + 1);
}
const GByteArray * nm_ap_get_ssid (const NMAccessPoint *ap)
......@@ -299,6 +289,7 @@ guint32
nm_ap_get_max_bitrate (NMAccessPoint *ap)
{
g_return_val_if_fail (NM_IS_AP (ap), 0);
g_return_val_if_fail (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (ap)), 0);
return NM_AP_GET_PRIVATE (ap)->max_bitrate;
}
......@@ -876,32 +867,11 @@ nm_ap_complete_connection (NMAccessPoint *self,
/*****************************************************************/
void
nm_ap_export_to_dbus (NMAccessPoint *ap)
{
NMAccessPointPrivate *priv;
static guint32 counter = 0;
g_return_if_fail (NM_IS_AP (ap));
priv = NM_AP_GET_PRIVATE (ap);
if (priv->dbus_path) {
nm_log_err (LOGD_CORE, "Tried to export AP %s twice.", priv->dbus_path);
return;
}
priv->id = counter++;
priv->dbus_path = g_strdup_printf (NM_DBUS_PATH_ACCESS_POINT "/%d", priv->id);
nm_dbus_manager_register_object (nm_dbus_manager_get (), priv->dbus_path, ap);
}
static void
nm_ap_init (NMAccessPoint *ap)
{
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (ap);
priv->dbus_path = NULL;
priv->mode = NM_802_11_MODE_INFRA;
priv->flags = NM_802_11_AP_FLAGS_NONE;
priv->wpa_flags = NM_802_11_AP_SEC_NONE;
......@@ -914,7 +884,6 @@ finalize (GObject *object)
{
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object);
g_free (priv->dbus_path);
g_free (priv->supplicant_path);
if (priv->ssid)
g_byte_array_free (priv->ssid, TRUE);
......@@ -988,6 +957,7 @@ static void
nm_ap_class_init (NMAccessPointClass *ap_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (ap_class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (ap_class);
const NM80211ApSecurityFlags all_sec_flags = NM_802_11_AP_SEC_NONE
| NM_802_11_AP_SEC_PAIR_WEP40
| NM_802_11_AP_SEC_PAIR_WEP104
......@@ -1002,6 +972,8 @@ nm_ap_class_init (NMAccessPointClass *ap_class)
g_type_class_add_private (ap_class, sizeof (NMAccessPointPrivate));
exported_object_class->export_path = NM_DBUS_PATH_ACCESS_POINT "/%u";
/* virtual methods */
object_class->set_property = set_property;
object_class->get_property = get_property;
......
......@@ -58,7 +58,6 @@ GType nm_ap_get_type (void);
NMAccessPoint * nm_ap_new_from_properties (const char *supplicant_path,
GVariant *properties);
NMAccessPoint * nm_ap_new_fake_from_connection (NMConnection *connection);
void nm_ap_export_to_dbus (NMAccessPoint *ap);
void nm_ap_update_from_properties (NMAccessPoint *ap,
const char *supplicant_path,
......@@ -72,7 +71,6 @@ gboolean nm_ap_complete_connection (NMAccessPoint *self,
gboolean lock_bssid,
GError **error);
const char * nm_ap_get_dbus_path (NMAccessPoint *ap);
const char * nm_ap_get_supplicant_path (NMAccessPoint *ap);
guint32 nm_ap_get_id (NMAccessPoint *ap);
const GByteArray *nm_ap_get_ssid (const NMAccessPoint *ap);
......
......@@ -24,7 +24,6 @@
#include <string.h>
#include "nm-modem.h"
#include "nm-platform.h"
#include "nm-dbus-manager.h"
#include "nm-setting-connection.h"
#include "nm-logging.h"
#include "NetworkManagerUtils.h"
......
......@@ -27,7 +27,6 @@
#include "nm-dbus-interface.h"
#include "nm-logging.h"
#include "nm-dbus-glib-types.h"
#include "nm-dbus-manager.h"
#include "nm-device.h"
#include "nm-settings-connection.h"
#include "nm-auth-utils.h"
......@@ -45,7 +44,6 @@ G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_EXPORT
typedef struct {
NMConnection *connection;
char *path;
char *specific_object;
NMDevice *device;
......@@ -228,7 +226,7 @@ nm_active_connection_set_connection (NMActiveConnection *self,
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
/* Can't change connection after the ActiveConnection is exported over D-Bus */
g_return_if_fail (priv->path == NULL);
g_return_if_fail (!nm_exported_object_is_exported (NM_EXPORTED_OBJECT (self)));
g_return_if_fail (priv->connection == NULL || !NM_IS_SETTINGS_CONNECTION (priv->connection));
if (priv->connection)
......@@ -236,12 +234,6 @@ nm_active_connection_set_connection (NMActiveConnection *self,
priv->connection = g_object_ref (connection);
}
const char *
nm_active_connection_get_path (NMActiveConnection *self)
{
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->path;
}
const char *
nm_active_connection_get_specific_object (NMActiveConnection *self)
{
......@@ -317,18 +309,6 @@ nm_active_connection_get_default6 (NMActiveConnection *self)
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->is_default6;
}
void
nm_active_connection_export (NMActiveConnection *self)
{
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
static guint32 counter = 0;
g_assert (priv->device || priv->vpn);
priv->path = g_strdup_printf (NM_DBUS_PATH "/ActiveConnection/%d", counter++);
nm_dbus_manager_register_object (nm_dbus_manager_get (), priv->path, self);
}
NMAuthSubject *
nm_active_connection_get_subject (NMActiveConnection *self)
{
......@@ -566,7 +546,7 @@ nm_active_connection_set_master (NMActiveConnection *self, NMActiveConnection *m
/* Master is write-once, and must be set before exporting the object */
g_return_if_fail (priv->master == NULL);
g_return_if_fail (priv->path == NULL);
g_return_if_fail (!nm_exported_object_is_exported (NM_EXPORTED_OBJECT (self)));
if (priv->device) {
/* Note, the master ActiveConnection may not yet have a device */
g_return_if_fail (priv->device != nm_active_connection_get_device (master));
......@@ -792,7 +772,7 @@ get_property (GObject *object, guint prop_id,
case PROP_DEVICES:
devices = g_ptr_array_sized_new (1);
if (priv->device && priv->state < NM_ACTIVE_CONNECTION_STATE_DEACTIVATED)
g_ptr_array_add (devices, g_strdup (nm_device_get_path (priv->device)));
g_ptr_array_add (devices, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (priv->device))));
g_value_take_boxed (value, devices);
break;
case PROP_STATE:
......@@ -830,7 +810,7 @@ get_property (GObject *object, guint prop_id,
case PROP_MASTER:
if (priv->master)
master_device = nm_active_connection_get_device (priv->master);
g_value_set_boxed (value, master_device ? nm_device_get_path (master_device) : "/");
nm_utils_g_value_set_object_path (value, master_device);
break;
case PROP_INT_SUBJECT:
g_value_set_object (value, priv->subject);
......@@ -874,8 +854,6 @@ dispose (GObject *object)
priv->chain = NULL;
}
g_free (priv->path);
priv->path = NULL;
g_free (priv->specific_object);
priv->specific_object = NULL;
......@@ -898,9 +876,12 @@ static void
nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (ac_class);
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (ac_class);
g_type_class_add_private (ac_class, sizeof (NMActiveConnectionPrivate));