summaryrefslogtreecommitdiff
path: root/libnm-glib/nm-device.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-glib/nm-device.c')
-rw-r--r--libnm-glib/nm-device.c174
1 files changed, 43 insertions, 131 deletions
diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c
index b198f526c..b8998f70b 100644
--- a/libnm-glib/nm-device.c
+++ b/libnm-glib/nm-device.c
@@ -18,19 +18,20 @@
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
- * Copyright (C) 2007 - 2011 Red Hat, Inc.
+ * Copyright (C) 2007 - 2010 Red Hat, Inc.
*/
#include <string.h>
+#define G_UDEV_API_IS_SUBJECT_TO_CHANGE
#include <gudev/gudev.h>
#include "NetworkManager.h"
#include "nm-device-ethernet.h"
#include "nm-device-wifi.h"
-#include "nm-device-modem.h"
+#include "nm-gsm-device.h"
+#include "nm-cdma-device.h"
#include "nm-device-bt.h"
-#include "nm-device-wimax.h"
#include "nm-device.h"
#include "nm-device-private.h"
#include "nm-object-private.h"
@@ -49,10 +50,9 @@ typedef struct {
char *iface;
char *ip_iface;
- NMDeviceType device_type;
char *udi;
char *driver;
- NMDeviceCapabilities capabilities;
+ guint32 capabilities;
gboolean managed;
gboolean firmware_missing;
NMIP4Config *ip4_config;
@@ -86,7 +86,6 @@ enum {
PROP_VENDOR,
PROP_DHCP6_CONFIG,
PROP_IP_INTERFACE,
- PROP_DEVICE_TYPE,
LAST_PROP
};
@@ -127,7 +126,9 @@ demarshal_ip4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
priv->null_ip4_config = TRUE;
else {
config = NM_IP4_CONFIG (_nm_object_cache_get (path));
- if (!config) {
+ if (config)
+ config = g_object_ref (config);
+ else {
connection = nm_object_get_connection (object);
config = NM_IP4_CONFIG (nm_ip4_config_new (connection, path));
}
@@ -165,7 +166,9 @@ demarshal_dhcp4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi
priv->null_dhcp4_config = TRUE;
else {
config = NM_DHCP4_CONFIG (_nm_object_cache_get (path));
- if (!config) {
+ if (config)
+ config = g_object_ref (config);
+ else {
connection = nm_object_get_connection (object);
config = NM_DHCP4_CONFIG (nm_dhcp4_config_new (connection, path));
}
@@ -203,7 +206,9 @@ demarshal_ip6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
priv->null_ip6_config = TRUE;
else {
config = NM_IP6_CONFIG (_nm_object_cache_get (path));
- if (!config) {
+ if (config)
+ config = g_object_ref (config);
+ else {
connection = nm_object_get_connection (object);
config = NM_IP6_CONFIG (nm_ip6_config_new (connection, path));
}
@@ -241,7 +246,9 @@ demarshal_dhcp6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi
priv->null_dhcp6_config = TRUE;
else {
config = NM_DHCP6_CONFIG (_nm_object_cache_get (path));
- if (!config) {
+ if (config)
+ config = g_object_ref (config);
+ else {
connection = nm_object_get_connection (object);
config = NM_DHCP6_CONFIG (nm_dhcp6_config_new (connection, path));
}
@@ -393,9 +400,6 @@ get_property (GObject *object,
NMDevice *device = NM_DEVICE (object);
switch (prop_id) {
- case PROP_DEVICE_TYPE:
- g_value_set_uint (value, nm_device_get_device_type (device));
- break;
case PROP_UDI:
g_value_set_string (value, nm_device_get_udi (device));
break;
@@ -445,26 +449,6 @@ get_property (GObject *object,
}
static void
-set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- NMDevice *self = NM_DEVICE (object);
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
-
- switch (prop_id) {
- case PROP_DEVICE_TYPE:
- /* Construct only */
- priv->device_type = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
nm_device_class_init (NMDeviceClass *device_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (device_class);
@@ -474,7 +458,6 @@ nm_device_class_init (NMDeviceClass *device_class)
/* virtual methods */
object_class->constructor = constructor;
object_class->get_property = get_property;
- object_class->set_property = set_property;
object_class->dispose = dispose;
object_class->finalize = finalize;
@@ -508,26 +491,9 @@ nm_device_class_init (NMDeviceClass *device_class)
G_PARAM_READABLE));
/**
- * NMDevice:device-type:
- *
- * The numeric type of the device.
- **/
- g_object_class_install_property
- (object_class, PROP_DEVICE_TYPE,
- g_param_spec_uint (NM_DEVICE_DEVICE_TYPE,
- "Device Type",
- "Numeric device type (ie ethernet, wifi, etc)",
- NM_DEVICE_TYPE_UNKNOWN, G_MAXUINT32, NM_DEVICE_TYPE_UNKNOWN,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- /**
* NMDevice:udi:
*
- * An operating-system specific device hardware identifier; this is not
- * unique to a specific hardware device across reboots or hotplugs. It
- * is an opaque string which for some device types (Bluetooth, Modem)
- * contains an identifier provided by the underlying hardware service daemon
- * such as Bluez or ModemManager, and clients can use this property to
- * request more information about the device from those services.
+ * The Unique Device Identifier of the device.
**/
g_object_class_install_property
(object_class, PROP_UDI,
@@ -708,7 +674,7 @@ nm_device_class_init (NMDeviceClass *device_class)
*
* Creates a new #NMDevice.
*
- * Returns: (transfer full): a new device
+ * Returns: a new device
**/
GObject *
nm_device_new (DBusGConnection *connection, const char *path)
@@ -718,7 +684,6 @@ nm_device_new (DBusGConnection *connection, const char *path)
GValue value = {0,};
GType dtype = 0;
NMDevice *device = NULL;
- NMDeviceType nm_dtype;
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
@@ -743,23 +708,22 @@ nm_device_new (DBusGConnection *connection, const char *path)
goto out;
}
- nm_dtype = g_value_get_uint (&value);
- switch (nm_dtype) {
+ switch (g_value_get_uint (&value)) {
case NM_DEVICE_TYPE_ETHERNET:
dtype = NM_TYPE_DEVICE_ETHERNET;
break;
case NM_DEVICE_TYPE_WIFI:
dtype = NM_TYPE_DEVICE_WIFI;
break;
- case NM_DEVICE_TYPE_MODEM:
- dtype = NM_TYPE_DEVICE_MODEM;
+ case NM_DEVICE_TYPE_GSM:
+ dtype = NM_TYPE_GSM_DEVICE;
+ break;
+ case NM_DEVICE_TYPE_CDMA:
+ dtype = NM_TYPE_CDMA_DEVICE;
break;
case NM_DEVICE_TYPE_BT:
dtype = NM_TYPE_DEVICE_BT;
break;
- case NM_DEVICE_TYPE_WIMAX:
- dtype = NM_TYPE_DEVICE_WIMAX;
- break;
default:
g_warning ("Unknown device type %d", g_value_get_uint (&value));
break;
@@ -769,7 +733,6 @@ nm_device_new (DBusGConnection *connection, const char *path)
device = (NMDevice *) g_object_new (dtype,
NM_OBJECT_DBUS_CONNECTION, connection,
NM_OBJECT_DBUS_PATH, path,
- NM_DEVICE_DEVICE_TYPE, nm_dtype,
NULL);
}
@@ -798,8 +761,7 @@ nm_device_get_iface (NMDevice *device)
if (!priv->iface) {
priv->iface = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE,
- "Interface",
- NULL);
+ "Interface");
}
return priv->iface;
@@ -826,30 +788,13 @@ nm_device_get_ip_iface (NMDevice *device)
if (!priv->ip_iface) {
priv->ip_iface = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE,
- "IpInterface",
- NULL);
+ "IpInterface");
}
return priv->ip_iface;
}
/**
- * nm_device_get_device_type:
- * @device: a #NMDevice
- *
- * Returns the numeric type of the #NMDevice, ie ethernet, wifi, etc.
- *
- * Returns: the device type
- **/
-NMDeviceType
-nm_device_get_device_type (NMDevice *self)
-{
- g_return_val_if_fail (NM_IS_DEVICE (self), NM_DEVICE_TYPE_UNKNOWN);
-
- return NM_DEVICE_GET_PRIVATE (self)->device_type;
-}
-
-/**
* nm_device_get_udi:
* @device: a #NMDevice
*
@@ -870,8 +815,7 @@ nm_device_get_udi (NMDevice *device)
if (!priv->udi) {
priv->udi = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE,
- "Udi",
- NULL);
+ "Udi");
}
return priv->udi;
@@ -897,8 +841,7 @@ nm_device_get_driver (NMDevice *device)
if (!priv->driver) {
priv->driver = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE,
- "Driver",
- NULL);
+ "Driver");
}
return priv->driver;
@@ -912,7 +855,7 @@ nm_device_get_driver (NMDevice *device)
*
* Returns: the capabilities
**/
-NMDeviceCapabilities
+guint32
nm_device_get_capabilities (NMDevice *device)
{
NMDevicePrivate *priv;
@@ -923,8 +866,7 @@ nm_device_get_capabilities (NMDevice *device)
if (!priv->capabilities) {
priv->capabilities = _nm_object_get_uint_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE,
- "Capabilities",
- NULL);
+ "Capabilities");
}
return priv->capabilities;
@@ -949,8 +891,7 @@ nm_device_get_managed (NMDevice *device)
if (!priv->managed) {
priv->managed = _nm_object_get_boolean_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE,
- "Managed",
- NULL);
+ "Managed");
}
return priv->managed;
@@ -977,8 +918,7 @@ nm_device_get_firmware_missing (NMDevice *device)
if (!priv->firmware_missing) {
priv->firmware_missing = _nm_object_get_boolean_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE,
- "FirmwareMissing",
- NULL);
+ "FirmwareMissing");
}
return priv->firmware_missing;
@@ -990,7 +930,7 @@ nm_device_get_firmware_missing (NMDevice *device)
*
* Gets the current #NMIP4Config associated with the #NMDevice.
*
- * Returns: (transfer none): the #NMIP4Config or %NULL if the device is not activated.
+ * Returns: the #NMIP4Config or %NULL if the device is not activated.
**/
NMIP4Config *
nm_device_get_ip4_config (NMDevice *device)
@@ -1007,7 +947,7 @@ nm_device_get_ip4_config (NMDevice *device)
if (priv->null_ip4_config)
return NULL;
- path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip4Config", NULL);
+ path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip4Config");
if (path) {
g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
g_value_take_boxed (&value, path);
@@ -1024,7 +964,7 @@ nm_device_get_ip4_config (NMDevice *device)
*
* Gets the current #NMDHCP4Config associated with the #NMDevice.
*
- * Returns: (transfer none): the #NMDHCPConfig or %NULL if the device is not activated or not
+ * Returns: the #NMDHCPConfig or %NULL if the device is not activated or not
* using DHCP.
**/
NMDHCP4Config *
@@ -1042,7 +982,7 @@ nm_device_get_dhcp4_config (NMDevice *device)
if (priv->null_dhcp4_config)
return NULL;
- path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Dhcp4Config", NULL);
+ path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Dhcp4Config");
if (path) {
g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
g_value_take_boxed (&value, path);
@@ -1059,7 +999,7 @@ nm_device_get_dhcp4_config (NMDevice *device)
*
* Gets the current #NMIP6Config associated with the #NMDevice.
*
- * Returns: (transfer none): the #NMIP6Config or %NULL if the device is not activated.
+ * Returns: the #NMIP6Config or %NULL if the device is not activated.
**/
NMIP6Config *
nm_device_get_ip6_config (NMDevice *device)
@@ -1076,7 +1016,7 @@ nm_device_get_ip6_config (NMDevice *device)
if (priv->null_ip6_config)
return NULL;
- path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip6Config", NULL);
+ path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip6Config");
if (path) {
g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
g_value_take_boxed (&value, path);
@@ -1093,7 +1033,7 @@ nm_device_get_ip6_config (NMDevice *device)
*
* Gets the current #NMDHCP6Config associated with the #NMDevice.
*
- * Returns: (transfer none): the #NMDHCPConfig or %NULL if the device is not activated or not
+ * Returns: the #NMDHCPConfig or %NULL if the device is not activated or not
* using DHCP.
**/
NMDHCP6Config *
@@ -1111,7 +1051,7 @@ nm_device_get_dhcp6_config (NMDevice *device)
if (priv->null_dhcp6_config)
return NULL;
- path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Dhcp6Config", NULL);
+ path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Dhcp6Config");
if (path) {
g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
g_value_take_boxed (&value, path);
@@ -1141,8 +1081,7 @@ nm_device_get_state (NMDevice *device)
if (priv->state == NM_DEVICE_STATE_UNKNOWN) {
priv->state = _nm_object_get_uint_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE,
- "State",
- NULL);
+ "State");
}
return priv->state;
@@ -1374,7 +1313,7 @@ deactivate_cb (DBusGProxy *proxy,
/**
* nm_device_disconnect:
* @device: a #NMDevice
- * @callback: (scope async): callback to be called when disconnect operation completes
+ * @callback: callback to be called when disconnect operation completes
* @user_data: caller-specific data passed to @callback
*
* Disconnects the device if currently connected, and prevents the device from
@@ -1400,30 +1339,3 @@ nm_device_disconnect (NMDevice *device,
info);
}
-/**
- * nm_device_filter_connections:
- * @device: an #NMDevice to filter connections for
- * @connections: a list of #NMConnection objects to filter
- *
- * Filters a given list of connections for a given #NMDevice object and return
- * connections which may be activated with the device. For example if @device
- * is a WiFi device that supports only WEP encryption, the returned list will
- * contain any WiFi connections in @connections that allow connection to
- * unencrypted or WEP-enabled SSIDs. The returned list will not contain
- * Ethernet, Bluetooth, WiFi WPA connections, or any other connection that is
- * incompatible with the device.
- *
- * Returns: (transfer container) (element-type NetworkManager.Connection): a
- * list of #NMConnection objects that could be activated with the given @device.
- * The elements of the list are owned by their creator and should not be freed
- * by the caller, but the returned list itself is owned by the caller and should
- * be freed with g_slist_free() when it is no longer required.
- **/
-GSList *
-nm_device_filter_connections (NMDevice *device, const GSList *connections)
-{
- if (NM_DEVICE_GET_CLASS (device)->filter_connections)
- return NM_DEVICE_GET_CLASS (device)->filter_connections (device, connections);
- return NULL;
-}
-