Commit 636b1140 authored by Tambet Ingo's avatar Tambet Ingo Committed by Tambet Ingo

2007-06-21 Tambet Ingo <tambet@ximian.com>

	* libnm-glib/Makefile.am: Add NMObject to build, remove nm-utils.[ch].

	* nm-utils.[ch]: Remove.

	* libnm-glib/nm-object.c: Implement a base class for all libnm-glib dbus-aware
	objects for easy property access and dbus connection handling.

	* libnm-glib/nm-client.c: Derive from NMObject.

	* libnm-glib/nm-device.c: Ditto.

	* libnm-glib/nm-device-802-3-ethernet.c: Changes for being based on NMObject.

	* libnm-glib/nm-device-802-11-wireless.c: Ditto.

	* libnm-glib/nm-ip4-config.c: Ditto.

	* libnm-glib/nm-access-point.c: Ditto.

	* libnm-util/nm-connection.c (nm_connection_compare): Add a stub for connection
	comparision. Currently used by the device activation code to determine if the new
	activation is the same as the old one.

	* src/nm-dbus-nmi.c (nm_dbus_get_user_key_for_network): Don't use the obsolete and
	wrong way of getting the dbus path for AP. Fixes the issue where the applet isn't
	able to ask password for the AP.

	* src/nm-device.c (nm_device_activate): Change the logic here - instead of giving
	up if the device is already connected, tear down it's connection (if it isn't the
	same as new one) and start the activation.

	* src/nm-manager.c: Add the beginnings of NMConnection storage and signals.

	* src/NetworkManagerAP.c (nm_ap_init): Set the default values to AP memebers, fixes
	the issue where all APs are always listed as encrypted.

	* src/NetworkManagerDbus.c (nm_dbus_get_object_path_for_network): Remove. APs have
	their own registered paths.

	* test/nm-tool.c (detail_device): Don't try to get active network from wireless
	device if it's not connected - dbus-glib will happily crash trying to marshal NULL.




git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2615 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 1519dc60
2007-06-21 Tambet Ingo <tambet@ximian.com>
* libnm-glib/Makefile.am: Add NMObject to build, remove nm-utils.[ch].
* nm-utils.[ch]: Remove.
* libnm-glib/nm-object.c: Implement a base class for all libnm-glib dbus-aware
objects for easy property access and dbus connection handling.
* libnm-glib/nm-client.c: Derive from NMObject.
* libnm-glib/nm-device.c: Ditto.
* libnm-glib/nm-device-802-3-ethernet.c: Changes for being based on NMObject.
* libnm-glib/nm-device-802-11-wireless.c: Ditto.
* libnm-glib/nm-ip4-config.c: Ditto.
* libnm-glib/nm-access-point.c: Ditto.
* libnm-util/nm-connection.c (nm_connection_compare): Add a stub for connection
comparision. Currently used by the device activation code to determine if the new
activation is the same as the old one.
* src/nm-dbus-nmi.c (nm_dbus_get_user_key_for_network): Don't use the obsolete and
wrong way of getting the dbus path for AP. Fixes the issue where the applet isn't
able to ask password for the AP.
* src/nm-device.c (nm_device_activate): Change the logic here - instead of giving
up if the device is already connected, tear down it's connection (if it isn't the
same as new one) and start the activation.
* src/nm-manager.c: Add the beginnings of NMConnection storage and signals.
* src/NetworkManagerAP.c (nm_ap_init): Set the default values to AP memebers, fixes
the issue where all APs are always listed as encrypted.
* src/NetworkManagerDbus.c (nm_dbus_get_object_path_for_network): Remove. APs have
their own registered paths.
* test/nm-tool.c (detail_device): Don't try to get active network from wireless
device if it's not connected - dbus-glib will happily crash trying to marshal NULL.
2007-06-13 Tambet Ingo <tambet@ximian.com>
* src/NetworkManagerAP.c (foreach_property_cb): Set WEP capabilities too!
......
......@@ -18,6 +18,7 @@ libnm_glib_la_CFLAGS = \
libnmincludedir = $(includedir)/libnm-glib
libnminclude_HEADERS = \
nm-object.h \
nm-client.h \
nm-device.h \
nm-device-802-3-ethernet.h \
......@@ -27,6 +28,7 @@ libnminclude_HEADERS = \
nm-vpn-connection.h
libnm_glib_la_SOURCES = \
nm-object.c \
nm-client.c \
nm-device.c \
nm-device-private.h \
......@@ -34,8 +36,6 @@ libnm_glib_la_SOURCES = \
nm-device-802-11-wireless.c \
nm-access-point.c \
nm-ip4-config.c \
nm-utils.c \
nm-utils.h \
nm-vpn-connection.c \
nm-marshal-main.c
......
#include "nm-access-point.h"
#include "NetworkManager.h"
#include "nm-utils.h"
#include "nm-access-point-bindings.h"
G_DEFINE_TYPE (NMAccessPoint, nm_access_point, DBUS_TYPE_G_PROXY)
G_DEFINE_TYPE (NMAccessPoint, nm_access_point, NM_TYPE_OBJECT)
#define NM_ACCESS_POINT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACCESS_POINT, NMAccessPointPrivate))
typedef struct {
DBusGProxy *ap_proxy;
int strength;
} NMAccessPointPrivate;
......@@ -27,6 +27,37 @@ nm_access_point_init (NMAccessPoint *ap)
{
}
static GObject*
constructor (GType type,
guint n_construct_params,
GObjectConstructParam *construct_params)
{
NMObject *object;
NMAccessPointPrivate *priv;
object = (NMObject *) G_OBJECT_CLASS (nm_access_point_parent_class)->constructor (type,
n_construct_params,
construct_params);
if (!object)
return NULL;
priv = NM_ACCESS_POINT_GET_PRIVATE (object);
priv->ap_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (object),
NM_DBUS_SERVICE,
nm_object_get_path (object),
NM_DBUS_INTERFACE_DEVICE);
dbus_g_proxy_add_signal (priv->ap_proxy, "StrengthChanged", G_TYPE_UCHAR, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->ap_proxy,
"StrengthChanged",
G_CALLBACK (strength_changed_proxy),
NULL,
NULL);
return G_OBJECT (object);
}
static void
nm_access_point_class_init (NMAccessPointClass *ap_class)
{
......@@ -34,6 +65,9 @@ nm_access_point_class_init (NMAccessPointClass *ap_class)
g_type_class_add_private (ap_class, sizeof (NMAccessPointPrivate));
/* virtual methods */
object_class->constructor = constructor;
/* signals */
signals[STRENGTH_CHANGED] =
g_signal_new ("strength-changed",
......@@ -50,23 +84,10 @@ nm_access_point_class_init (NMAccessPointClass *ap_class)
NMAccessPoint *
nm_access_point_new (DBusGConnection *connection, const char *path)
{
NMAccessPoint *ap;
ap = (NMAccessPoint *) g_object_new (NM_TYPE_ACCESS_POINT,
"name", NM_DBUS_SERVICE,
"path", path,
"interface", NM_DBUS_INTERFACE_ACCESS_POINT,
"connection", connection,
NULL);
dbus_g_proxy_add_signal (DBUS_G_PROXY (ap), "StrengthChanged", G_TYPE_UCHAR, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (DBUS_G_PROXY (ap),
"StrengthChanged",
G_CALLBACK (strength_changed_proxy),
NULL,
NULL);
return ap;
return (NMAccessPoint *) g_object_new (NM_TYPE_ACCESS_POINT,
NM_OBJECT_CONNECTION, connection,
NM_OBJECT_PATH, path,
NULL);
}
static void
......@@ -83,121 +104,57 @@ strength_changed_proxy (NMAccessPoint *ap, guchar strength)
guint32
nm_access_point_get_capabilities (NMAccessPoint *ap)
{
GValue value = {0,};
guint32 caps = 0;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
if (nm_dbus_get_property (DBUS_G_PROXY (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
"Capabilities",
&value))
caps = g_value_get_uint (&value);
return caps;
return nm_object_get_uint_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, "Capabilities");
}
gboolean
nm_access_point_is_encrypted (NMAccessPoint *ap)
{
GValue value = {0,};
int encrypted = FALSE;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), FALSE);
if (nm_dbus_get_property (DBUS_G_PROXY (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
"Encrypted",
&value))
encrypted = g_value_get_boolean (&value);
return encrypted;
return nm_object_get_boolean_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, "Encrypted");
}
char *
nm_access_point_get_essid (NMAccessPoint *ap)
{
GValue value = {0,};
char *essid = NULL;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL);
if (nm_dbus_get_property (DBUS_G_PROXY (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
"Essid",
&value))
essid = g_strdup (g_value_get_string (&value));
return essid;
return nm_object_get_string_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, "Essid");
}
gdouble
nm_access_point_get_frequency (NMAccessPoint *ap)
{
GValue value = {0,};
double freq = 0.0;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), freq);
if (nm_dbus_get_property (DBUS_G_PROXY (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
"Frequency",
&value))
freq = g_value_get_double (&value);
return freq;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
return nm_object_get_double_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, "Frequency");
}
char *
nm_access_point_get_hw_address (NMAccessPoint *ap)
{
GValue value = {0,};
char *address = NULL;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL);
if (nm_dbus_get_property (DBUS_G_PROXY (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
"HwAddress",
&value))
address = g_strdup (g_value_get_string (&value));
return address;
return nm_object_get_string_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, "HwAddress");
}
int
nm_access_point_get_mode (NMAccessPoint *ap)
{
GValue value = {0,};
int mode = 0;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
if (nm_dbus_get_property (DBUS_G_PROXY (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
"Mode",
&value))
mode = g_value_get_int (&value);
return mode;
return nm_object_get_int_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, "Mode");
}
guint32
nm_access_point_get_rate (NMAccessPoint *ap)
{
GValue value = {0,};
guint32 rate = 0;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
if (nm_dbus_get_property (DBUS_G_PROXY (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
"Rate",
&value))
rate = g_value_get_uint (&value);
return rate;
return nm_object_get_uint_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, "Rate");
}
int
......@@ -209,15 +166,8 @@ nm_access_point_get_strength (NMAccessPoint *ap)
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
if (priv->strength == 0) {
GValue value = {0,};
if (nm_dbus_get_property (DBUS_G_PROXY (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
"Strength",
&value))
priv->strength = g_value_get_int (&value);
}
if (priv->strength == 0)
priv->strength = nm_object_get_int_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, "Strength");
return priv->strength;
}
......@@ -10,14 +10,14 @@
#include <glib/gtypes.h>
#include <glib-object.h>
#include <dbus/dbus-glib.h>
#include "nm-object.h"
typedef struct {
DBusGProxy parent;
NMObject parent;
} NMAccessPoint;
typedef struct {
DBusGProxyClass parent;
NMObjectClass parent;
/* Signals */
void (*strength_changed) (NMAccessPoint *ap, gint8 strength);
......
This diff is collapsed.
......@@ -7,6 +7,7 @@
#include <dbus/dbus-glib.h>
#include <NetworkManager.h>
#include <NetworkManagerVPN.h>
#include "nm-object.h"
#include "nm-device.h"
#include "nm-vpn-connection.h"
......@@ -18,11 +19,11 @@
#define NM_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CLIENT, NMClientClass))
typedef struct {
DBusGProxy parent;
NMObject parent;
} NMClient;
typedef struct {
DBusGProxyClass parent;
NMObjectClass parent;
/* Signals */
void (*manager_running) (NMClient *client, gboolean running);
......
#include "nm-device-802-11-wireless.h"
#include "nm-device-private.h"
#include "nm-utils.h"
#include "nm-device-802-11-wireless-bindings.h"
......@@ -55,9 +54,9 @@ constructor (GType type,
priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (object);
priv->wireless_proxy = dbus_g_proxy_new_for_name (nm_device_get_connection (NM_DEVICE (object)),
priv->wireless_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
NM_DBUS_SERVICE,
nm_device_get_path (NM_DEVICE (object)),
nm_object_get_path (NM_OBJECT (object)),
NM_DBUS_INTERFACE_DEVICE_WIRELESS);
dbus_g_proxy_add_signal (priv->wireless_proxy, "NetworkAdded", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
......@@ -69,7 +68,7 @@ constructor (GType type,
dbus_g_proxy_connect_signal (priv->wireless_proxy, "NetworkRemoved",
G_CALLBACK (network_removed_proxy),
object, NULL);
return object;
}
......@@ -121,7 +120,7 @@ nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *device_class)
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
signals[NETWORK_ADDED] =
signals[NETWORK_REMOVED] =
g_signal_new ("network-removed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
......@@ -139,8 +138,8 @@ nm_device_802_11_wireless_new (DBusGConnection *connection, const char *path)
g_return_val_if_fail (path != NULL, NULL);
return (NMDevice80211Wireless *) g_object_new (NM_TYPE_DEVICE_802_11_WIRELESS,
NM_DEVICE_CONNECTION, connection,
NM_DEVICE_PATH, path,
NM_OBJECT_CONNECTION, connection,
NM_OBJECT_PATH, path,
NULL);
}
......@@ -149,8 +148,7 @@ nm_device_802_11_wireless_get_hw_address (NMDevice80211Wireless *device)
{
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), NULL);
return nm_dbus_get_string_property (nm_device_get_properties_proxy (NM_DEVICE (device)),
NM_DBUS_INTERFACE_DEVICE_WIRELESS, "HwAddress");
return nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, "HwAddress");
}
int
......@@ -158,8 +156,7 @@ nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *device)
{
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), 0);
return nm_dbus_get_int_property (nm_device_get_properties_proxy (NM_DEVICE (device)),
NM_DBUS_INTERFACE_DEVICE_WIRELESS, "Mode");
return nm_object_get_int_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, "Mode");
}
int
......@@ -167,8 +164,7 @@ nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *device)
{
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), 0);
return nm_dbus_get_int_property (nm_device_get_properties_proxy (NM_DEVICE (device)),
NM_DBUS_INTERFACE_DEVICE_WIRELESS, "Bitrate");
return nm_object_get_int_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, "Bitrate");
}
guint32
......@@ -176,8 +172,7 @@ nm_device_802_11_wireless_get_capabilities (NMDevice80211Wireless *device)
{
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), 0);
return nm_dbus_get_uint_property (nm_device_get_properties_proxy (NM_DEVICE (device)),
NM_DBUS_INTERFACE_DEVICE_WIRELESS, "WirelessCapabilities");
return nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, "WirelessCapabilities");
}
static NMAccessPoint *
......@@ -188,7 +183,7 @@ get_network (NMDevice80211Wireless *device, const char *path, gboolean create_if
ap = g_hash_table_lookup (priv->networks, path);
if (!ap && create_if_not_found) {
ap = nm_access_point_new (nm_device_get_connection (NM_DEVICE (device)), path);
ap = nm_access_point_new (nm_object_get_connection (NM_OBJECT (device)), path);
if (ap)
g_hash_table_insert (priv->networks, g_strdup (path), ap);
}
......@@ -204,9 +199,7 @@ nm_device_802_11_wireless_get_active_network (NMDevice80211Wireless *device)
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), NULL);
path = nm_dbus_get_object_path_property (nm_device_get_properties_proxy (NM_DEVICE (device)),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
"ActiveNetwork");
path = nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, "ActiveNetwork");
if (path) {
ap = get_network (device, path, TRUE);
g_free (path);
......
#include "nm-device-802-3-ethernet.h"
#include "nm-device-private.h"
#include "nm-utils.h"
#include "nm-device-802-3-ethernet-bindings.h"
......@@ -39,9 +38,9 @@ constructor (GType type,
priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (object);
priv->ethernet_proxy = dbus_g_proxy_new_for_name (nm_device_get_connection (NM_DEVICE (object)),
priv->ethernet_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
NM_DBUS_SERVICE,
nm_device_get_path (NM_DEVICE (object)),
nm_object_get_path (NM_OBJECT (object)),
NM_DBUS_INTERFACE_DEVICE_WIRED);
return object;
}
......@@ -80,8 +79,8 @@ nm_device_802_3_ethernet_new (DBusGConnection *connection, const char *path)
g_return_val_if_fail (path != NULL, NULL);
return (NMDevice8023Ethernet *) g_object_new (NM_TYPE_DEVICE_802_3_ETHERNET,
NM_DEVICE_CONNECTION, connection,
NM_DEVICE_PATH, path,
NM_OBJECT_CONNECTION, connection,
NM_OBJECT_PATH, path,
NULL);
}
......@@ -90,8 +89,7 @@ nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device)
{
g_return_val_if_fail (NM_IS_DEVICE_802_3_ETHERNET (device), 0);
return nm_dbus_get_int_property (nm_device_get_properties_proxy (NM_DEVICE (device)),
NM_DBUS_INTERFACE_DEVICE_WIRED, "Speed");
return nm_object_get_int_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, "Speed");
}
char *
......@@ -99,6 +97,5 @@ nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device)
{
g_return_val_if_fail (NM_IS_DEVICE_802_3_ETHERNET (device), NULL);
return nm_dbus_get_string_property (nm_device_get_properties_proxy (NM_DEVICE (device)),
NM_DBUS_INTERFACE_DEVICE_WIRED, "HwAddress");
return nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, "HwAddress");
}
#include "nm-device.h"
#include "nm-device-private.h"
#include "nm-utils.h"
#include "nm-device-bindings.h"
G_DEFINE_TYPE (NMDevice, nm_device, G_TYPE_OBJECT)
G_DEFINE_TYPE (NMDevice, nm_device, NM_TYPE_OBJECT)
#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
typedef struct {
DBusGConnection *connection;
char *path;
DBusGProxy *device_proxy;
DBusGProxy *properties_proxy;
NMDeviceState state;
gboolean disposed;
......@@ -52,39 +48,27 @@ constructor (GType type,
guint n_construct_params,
GObjectConstructParam *construct_params)
{
GObject *object;
NMObject *object;
NMDevicePrivate *priv;
object = G_OBJECT_CLASS (nm_device_parent_class)->constructor (type,
n_construct_params,
construct_params);
object = (NMObject *) G_OBJECT_CLASS (nm_device_parent_class)->constructor (type,
n_construct_params,
construct_params);
if (!object)
return NULL;
priv = NM_DEVICE_GET_PRIVATE (object);
if (priv->connection == NULL || priv->path == NULL) {
g_warning ("Connection or path not received.");
g_object_unref (object);
return NULL;
}
priv->device_proxy = dbus_g_proxy_new_for_name (priv->connection,
priv->device_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (object),
NM_DBUS_SERVICE,
priv->path,
nm_object_get_path (object),
NM_DBUS_INTERFACE_DEVICE);
dbus_g_proxy_add_signal (priv->device_proxy, "StateChanged", G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->device_proxy, "StateChanged",
G_CALLBACK (device_state_change_proxy),
object, NULL);
priv->properties_proxy = dbus_g_proxy_new_for_name (priv->connection,
NM_DBUS_SERVICE,
priv->path,
"org.freedesktop.DBus.Properties");
return object;
return G_OBJECT (object);
}
static void
......@@ -98,62 +82,10 @@ dispose (GObject *object)
priv->disposed = TRUE;
g_object_unref (priv->device_proxy);
g_object_unref (priv->properties_proxy);
dbus_g_connection_unref (priv->connection);
G_OBJECT_CLASS (nm_device_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
g_free (priv->path);
G_OBJECT_CLASS (nm_device_parent_class)->finalize (object);
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
switch (prop_id) {
case PROP_CONNECTION:
/* Construct only */
priv->connection = dbus_g_connection_ref ((DBusGConnection *) g_value_get_boxed (value));
break;
case PROP_PATH:
/* Construct only */
priv->path = g_strdup (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
switch (prop_id) {
case PROP_CONNECTION:
g_value_set_boxed (value, priv->connection);
break;
case PROP_PATH:
g_value_set_string (value, priv->path);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_device_class_init (NMDeviceClass *device_class)
{
......@@ -163,27 +95,7 @@ nm_device_class_init (NMDeviceClass *device_class)
/* virtual methods */
object_class->constructor = constructor;
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->dispose = dispose;
object_class->finalize = finalize;
/* porperties */
g_object_class_install_property
(object_class, PROP_CONNECTION,
g_param_spec_boxed (NM_DEVICE_CONNECTION,
"Connection",
"Connection",
DBUS_TYPE_G_CONNECTION,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_PATH,
g_param_spec_string (NM_DEVICE_PATH,
"Object Path",
"DBus Object Path",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/* signals */
signals[STATE_CHANGED] =
......@@ -213,8 +125,8 @@ NMDevice *
nm_device_new (DBusGConnection *connection, const char *path)
{
return (NMDevice *) g_object_new (NM_TYPE_DEVICE,
NM_DEVICE_CONNECTION, connection,
NM_DEVICE_PATH, path,
NM_OBJECT_CONNECTION, connection,
NM_OBJECT_PATH, path,
NULL);
}
......@@ -252,8 +164,7 @@ nm_device_get_iface (NMDevice *device)
{
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
return nm_dbus_get_string_property (NM_DEVICE_GET_PRIVATE (device)->properties_proxy,
NM_DBUS_INTERFACE_DEVICE, "Interface");
return nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Interface");
}
char *
......@@ -261,8 +172,7 @@ nm_device_get_udi (NMDevice *device)
{
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
return nm_dbus_get_string_property (NM_DEVICE_GET_PRIVATE (device)->properties_proxy,
NM_DBUS_INTERFACE_DEVICE, "Udi");
return nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Udi");
}
char *
......@@ -270,8 +180,7 @@ nm_device_get_driver (NMDevice *device)
{
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
return nm_dbus_get_string_property (NM_DEVICE_GET_PRIVATE (device)->properties_proxy,
NM_DBUS_INTERFACE_DEVICE, "Driver");
return nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Driver");
}
guint32
......@@ -279,8 +188,7 @@ nm_device_get_capabilities (NMDevice *device)
{
g_return_val_if_fail (NM_IS_DEVICE (device), 0);
return nm_dbus_get_uint_property (NM_DEVICE_GET_PRIVATE (device)->properties_proxy,
NM_DBUS_INTERFACE_DEVICE, "Capabilities");
return nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Capabilities");
}
guint32
......@@ -288,25 +196,21 @@ nm_device_get_ip4_address (NMDevice *device)
{
g_return_val_if_fail (NM_IS_DEVICE (device), 0);
return nm_dbus_get_uint_property (NM_DEVICE_GET_PRIVATE (device)->properties_proxy,
NM_DBUS_INTERFACE_DEVICE, "Ip4Address");
return nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip4Address");
}
NMIP4Config *
nm_device_get_ip4_config (NMDevice *device)
{
NMDevicePrivate *priv;
char *path;
NMIP4Config *config = NULL;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
path = nm_dbus_get_object_path_property (priv->properties_proxy,
NM_DBUS_INTERFACE_DEVICE,
"Ip4Config");
path = nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip4Config");
if (path) {
config = nm_ip4_config_new (priv->connection, path);
config = nm_ip4_config_new (nm_object_get_connection (NM_OBJECT (device)), path);
g_free (path);
}
......@@ -323,7 +227,7 @@ nm_device_get_state (NMDevice *device)
priv = NM_DEVICE_GET_PRIVATE (device);
if (priv->state == NM_DEVICE_STATE_UNKNOWN)