mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-14 20:18:39 +00:00
2007-09-25 Dan Williams <dcbw@redhat.com>
* introspection/nm-device.xml libnm-glib/nm-device.c libnm-glib/nm-device.h - Add 'Carrier' property to exported NMDevice objects * src/nm-device-interface.h src/nm-device-interface.c src/nm-device.c - Add a 'carrier' property to internal NMDevice objects git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2884 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
a8c55157db
commit
04f8d563fa
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2007-09-25 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* introspection/nm-device.xml
|
||||
libnm-glib/nm-device.c
|
||||
libnm-glib/nm-device.h
|
||||
- Add 'Carrier' property to exported NMDevice objects
|
||||
|
||||
* src/nm-device-interface.h
|
||||
src/nm-device-interface.c
|
||||
src/nm-device.c
|
||||
- Add a 'carrier' property to internal NMDevice objects
|
||||
|
||||
2007-09-25 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* src/nm-device-802-11-wireless.c
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
<property name="Ip4Address" type="i" access="read"/>
|
||||
<property name="State" type="u" access="read"/>
|
||||
<property name="Ip4Config" type="o" access="read"/>
|
||||
<property name="Carrier" type="b" access="read"/>
|
||||
|
||||
<!-- Ugh, but I see no other way of getting the type on the caller
|
||||
based on dbus object path only -->
|
||||
|
|
|
@ -11,11 +11,15 @@ typedef struct {
|
|||
DBusGProxy *device_proxy;
|
||||
NMDeviceState state;
|
||||
|
||||
gboolean carrier;
|
||||
gboolean carrier_valid;
|
||||
|
||||
gboolean disposed;
|
||||
} NMDevicePrivate;
|
||||
|
||||
enum {
|
||||
STATE_CHANGED,
|
||||
CARRIER_CHANGED,
|
||||
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
@ -33,6 +37,7 @@ enum {
|
|||
|
||||
|
||||
static void device_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data);
|
||||
static void device_carrier_changed_proxy (DBusGProxy *proxy, gboolean carrier, gpointer user_data);
|
||||
|
||||
static void
|
||||
nm_device_init (NMDevice *device)
|
||||
|
@ -40,6 +45,8 @@ nm_device_init (NMDevice *device)
|
|||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
||||
|
||||
priv->state = NM_DEVICE_STATE_UNKNOWN;
|
||||
priv->carrier = FALSE;
|
||||
priv->carrier_valid = FALSE;
|
||||
priv->disposed = FALSE;
|
||||
}
|
||||
|
||||
|
@ -68,6 +75,11 @@ constructor (GType type,
|
|||
dbus_g_proxy_connect_signal (priv->device_proxy, "StateChanged",
|
||||
G_CALLBACK (device_state_change_proxy),
|
||||
object, NULL);
|
||||
|
||||
dbus_g_proxy_add_signal (priv->device_proxy, "CarrierChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID);
|
||||
dbus_g_proxy_connect_signal (priv->device_proxy, "CarrierChanged",
|
||||
G_CALLBACK (device_carrier_changed_proxy),
|
||||
object, NULL);
|
||||
return G_OBJECT (object);
|
||||
}
|
||||
|
||||
|
@ -121,6 +133,19 @@ device_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
device_carrier_changed_proxy (DBusGProxy *proxy, gboolean carrier, gpointer user_data)
|
||||
{
|
||||
NMDevice *device = NM_DEVICE (user_data);
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
||||
|
||||
if ((priv->carrier != carrier) || !priv->carrier_valid) {
|
||||
priv->carrier_valid = TRUE;
|
||||
priv->carrier = carrier;
|
||||
g_signal_emit (device, signals[CARRIER_CHANGED], 0, carrier);
|
||||
}
|
||||
}
|
||||
|
||||
NMDevice *
|
||||
nm_device_new (DBusGConnection *connection, const char *path)
|
||||
{
|
||||
|
@ -310,6 +335,24 @@ nm_device_get_description (NMDevice *device)
|
|||
}
|
||||
|
||||
|
||||
gboolean
|
||||
nm_device_get_carrier (NMDevice *device)
|
||||
{
|
||||
NMDevicePrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
||||
|
||||
priv = NM_DEVICE_GET_PRIVATE (device);
|
||||
|
||||
if (!priv->carrier_valid) {
|
||||
priv->carrier = nm_object_get_boolean_property (NM_OBJECT (device),
|
||||
NM_DBUS_INTERFACE_DEVICE, "Carrier");
|
||||
priv->carrier_valid = TRUE;
|
||||
}
|
||||
|
||||
return priv->carrier;
|
||||
}
|
||||
|
||||
NMDeviceType
|
||||
nm_device_type_for_path (DBusGConnection *connection,
|
||||
const char *path)
|
||||
|
|
|
@ -27,6 +27,7 @@ typedef struct {
|
|||
|
||||
/* Signals */
|
||||
void (*state_changed) (NMDevice *device, NMDeviceState state);
|
||||
void (*carrier_changed) (NMDevice *device, gboolean carrier);
|
||||
} NMDeviceClass;
|
||||
|
||||
GType nm_device_get_type (void);
|
||||
|
@ -49,6 +50,7 @@ guint32 nm_device_get_ip4_address (NMDevice *device);
|
|||
NMIP4Config *nm_device_get_ip4_config (NMDevice *device);
|
||||
NMDeviceState nm_device_get_state (NMDevice *device);
|
||||
char *nm_device_get_description (NMDevice *device);
|
||||
gboolean nm_device_get_carrier (NMDevice *device);
|
||||
|
||||
NMDeviceType nm_device_type_for_path (DBusGConnection *connection,
|
||||
const char *path);
|
||||
|
|
|
@ -124,6 +124,14 @@ nm_device_interface_init (gpointer g_iface)
|
|||
0, G_MAXUINT32, DEVICE_TYPE_UNKNOWN,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_interface_install_property
|
||||
(g_iface,
|
||||
g_param_spec_boolean (NM_DEVICE_INTERFACE_CARRIER,
|
||||
"Carrier",
|
||||
"Carrier",
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/* Signals */
|
||||
g_signal_new ("state-changed",
|
||||
iface_type,
|
||||
|
|
|
@ -28,6 +28,7 @@ typedef enum
|
|||
#define NM_DEVICE_INTERFACE_IP4_CONFIG "ip4_config"
|
||||
#define NM_DEVICE_INTERFACE_STATE "state"
|
||||
#define NM_DEVICE_INTERFACE_DEVICE_TYPE "device_type" /* ugh */
|
||||
#define NM_DEVICE_INTERFACE_CARRIER "carrier"
|
||||
|
||||
typedef enum {
|
||||
NM_DEVICE_INTERFACE_PROP_FIRST = 0x1000,
|
||||
|
@ -40,7 +41,8 @@ typedef enum {
|
|||
NM_DEVICE_INTERFACE_PROP_IP4_ADDRESS,
|
||||
NM_DEVICE_INTERFACE_PROP_IP4_CONFIG,
|
||||
NM_DEVICE_INTERFACE_PROP_STATE,
|
||||
NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE
|
||||
NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE,
|
||||
NM_DEVICE_INTERFACE_PROP_CARRIER
|
||||
} NMDeviceInterfaceProp;
|
||||
|
||||
|
||||
|
|
|
@ -1713,6 +1713,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE:
|
||||
g_value_set_uint (value, priv->type);
|
||||
break;
|
||||
case NM_DEVICE_INTERFACE_PROP_CARRIER:
|
||||
g_value_set_boolean (value, priv->link_active);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -1781,6 +1784,10 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
g_object_class_override_property (object_class,
|
||||
NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE,
|
||||
NM_DEVICE_INTERFACE_DEVICE_TYPE);
|
||||
|
||||
g_object_class_override_property (object_class,
|
||||
NM_DEVICE_INTERFACE_PROP_CARRIER,
|
||||
NM_DEVICE_INTERFACE_CARRIER);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue