diff options
Diffstat (limited to 'libnm-glib')
-rw-r--r-- | libnm-glib/Makefile.am | 16 | ||||
-rw-r--r-- | libnm-glib/libnm-glib-test.c | 38 | ||||
-rw-r--r-- | libnm-glib/nm-access-point.c | 129 | ||||
-rw-r--r-- | libnm-glib/nm-active-connection.c | 101 | ||||
-rw-r--r-- | libnm-glib/nm-cdma-device.c | 9 | ||||
-rw-r--r-- | libnm-glib/nm-client.c | 145 | ||||
-rw-r--r-- | libnm-glib/nm-device-ethernet.c | 50 | ||||
-rw-r--r-- | libnm-glib/nm-device-wifi.c | 116 | ||||
-rw-r--r-- | libnm-glib/nm-device.c | 237 | ||||
-rw-r--r-- | libnm-glib/nm-device.h | 21 | ||||
-rw-r--r-- | libnm-glib/nm-dhcp4-config.c | 223 | ||||
-rw-r--r-- | libnm-glib/nm-dhcp4-config.h | 37 | ||||
-rw-r--r-- | libnm-glib/nm-gsm-device.c | 9 | ||||
-rw-r--r-- | libnm-glib/nm-ip4-config.c | 158 | ||||
-rw-r--r-- | libnm-glib/nm-ip4-config.h | 4 | ||||
-rw-r--r-- | libnm-glib/nm-object.c | 28 | ||||
-rw-r--r-- | libnm-glib/nm-serial-device.c | 27 | ||||
-rw-r--r-- | libnm-glib/nm-settings.c | 23 | ||||
-rw-r--r-- | libnm-glib/nm-vpn-plugin.c | 33 |
19 files changed, 1296 insertions, 108 deletions
diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am index 3b2fd8d313..d3c73b61c2 100644 --- a/libnm-glib/Makefile.am +++ b/libnm-glib/Makefile.am @@ -16,7 +16,9 @@ BUILT_SOURCES = \ nm-settings-system-bindings.h \ nm-vpn-connection-bindings.h \ nm-vpn-plugin-glue.h \ - nm-active-connection-bindings.h + nm-active-connection-bindings.h \ + nm-ip4-config-bindings.h \ + nm-dhcp4-config-bindings.h lib_LTLIBRARIES = libnm_glib.la libnm_glib_vpn.la @@ -49,7 +51,8 @@ libnminclude_HEADERS = \ nm-active-connection.h \ nm-dbus-connection.h \ nm-dbus-settings.h \ - nm-dbus-settings-system.h + nm-dbus-settings-system.h \ + nm-dhcp4-config.h libnm_glib_la_SOURCES = \ libnm_glib.c \ @@ -76,7 +79,8 @@ libnm_glib_la_SOURCES = \ nm-active-connection.c \ nm-dbus-connection.c \ nm-dbus-settings.c \ - nm-dbus-settings-system.c + nm-dbus-settings-system.c \ + nm-dhcp4-config.c libnm_glib_la_LIBADD = \ $(top_builddir)/libnm-util/libnm-util.la \ @@ -138,6 +142,12 @@ nm-vpn-plugin-glue.h: $(top_srcdir)/introspection/nm-vpn-plugin.xml nm-active-connection-bindings.h: $(top_srcdir)/introspection/nm-active-connection.xml dbus-binding-tool --prefix=nm_active_connection --mode=glib-client --output=$@ $< +nm-ip4-config-bindings.h: $(top_srcdir)/introspection/nm-ip4-config.xml + dbus-binding-tool --prefix=nm_ip4_config --mode=glib-client --output=$@ $< + +nm-dhcp4-config-bindings.h: $(top_srcdir)/introspection/nm-dhcp4-config.xml + dbus-binding-tool --prefix=nm_dhcp4_config --mode=glib-client --output=$@ $< + pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libnm_glib.pc libnm_glib_vpn.pc diff --git a/libnm-glib/libnm-glib-test.c b/libnm-glib/libnm-glib-test.c index 80844f4950..daa3abf832 100644 --- a/libnm-glib/libnm-glib-test.c +++ b/libnm-glib/libnm-glib-test.c @@ -106,18 +106,30 @@ dump_ip4_config (NMIP4Config *cfg) for (i = 0; i < ptr_array->len; i++) g_print ("\t%s\n", (const char *) g_ptr_array_index (ptr_array, i)); } +} - g_print ("IP4 NIS domain: %s\n", nm_ip4_config_get_nis_domain (cfg)); +static void +print_one_dhcp4_option (gpointer key, gpointer data, gpointer user_data) +{ + const char *option = (const char *) key; + const char *value = (const char *) data; - array = nm_ip4_config_get_nis_servers (cfg); - if (array) { - g_print ("IP4 NIS servers:\n"); - for (i = 0; i < array->len; i++) { - tmp = ip4_address_as_string (g_array_index (array, guint32, i)); - g_print ("\t%s\n", tmp); - g_free (tmp); - } - } + g_print (" %s: %s\n", option, value); +} + +static void +dump_dhcp4_config (NMDHCP4Config *config) +{ + GHashTable *options = NULL; + + if (!config) + return; + + g_print ("\nDHCP4 Options:\n"); + g_print ("-------------------------------------\n"); + + g_object_get (G_OBJECT (config), NM_DHCP4_CONFIG_OPTIONS, &options, NULL); + g_hash_table_foreach (options, print_one_dhcp4_option, NULL); } static void @@ -206,6 +218,8 @@ dump_device (NMDevice *device) dump_wired (NM_DEVICE_ETHERNET (device)); else if (NM_IS_DEVICE_WIFI (device)) dump_wireless (NM_DEVICE_WIFI (device)); + + dump_dhcp4_config (nm_device_get_dhcp4_config (device)); } static gboolean @@ -238,7 +252,7 @@ active_connections_changed (NMClient *client, GParamSpec *pspec, gpointer user_d g_print ("Active connections changed:\n"); connections = nm_client_get_active_connections (client); - for (i = 0; i < connections->len; i++) { + for (i = 0; connections && (i < connections->len); i++) { NMActiveConnection *connection; const GPtrArray *devices; @@ -266,7 +280,7 @@ test_get_active_connections (NMClient *client) g_print ("Active connections:\n"); connections = nm_client_get_active_connections (client); - for (i = 0; i < connections->len; i++) { + for (i = 0; connections && (i < connections->len); i++) { const GPtrArray *devices; g_print (" %s\n", nm_object_get_path (g_ptr_array_index (connections, i))); diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c index c06a161fd9..fba7532501 100644 --- a/libnm-glib/nm-access-point.c +++ b/libnm-glib/nm-access-point.c @@ -53,6 +53,15 @@ enum { #define DBUS_PROP_MAX_BITRATE "MaxBitrate" #define DBUS_PROP_STRENGTH "Strength" +/** + * nm_access_point_new: + * @connection: the #DBusGConnection + * @path: the DBusobject path of the access point + * + * Creates a new #NMAccessPoint. + * + * Returns: a new access point + **/ GObject * nm_access_point_new (DBusGConnection *connection, const char *path) { @@ -65,6 +74,14 @@ nm_access_point_new (DBusGConnection *connection, const char *path) NULL); } +/** + * nm_access_point_get_flags: + * @ap: a #NMAccessPoint + * + * Gets the flags of the access point + * + * Returns: the flags + **/ guint32 nm_access_point_get_flags (NMAccessPoint *ap) { @@ -82,6 +99,14 @@ nm_access_point_get_flags (NMAccessPoint *ap) return priv->flags; } +/** + * nm_access_point_get_wpa_flags: + * @ap: a #NMAccessPoint + * + * Gets the WPA flags of the access point. + * + * Returns: the WPA flags + **/ guint32 nm_access_point_get_wpa_flags (NMAccessPoint *ap) { @@ -99,6 +124,14 @@ nm_access_point_get_wpa_flags (NMAccessPoint *ap) return priv->wpa_flags; } +/** + * nm_access_point_get_rsn_flags: + * @ap: a #NMAccessPoint + * + * Gets the RSN flags of the access point. + * + * Returns: the RSN flags + **/ guint32 nm_access_point_get_rsn_flags (NMAccessPoint *ap) { @@ -116,6 +149,15 @@ nm_access_point_get_rsn_flags (NMAccessPoint *ap) return priv->rsn_flags; } +/** + * nm_access_point_get_ssid: + * @ap: a #NMAccessPoint + * + * Gets the SSID of the access point. + * + * Returns: the #GByteArray containing the SSID. This is the internal copy used by the + * access point, and must not be modified. + **/ const GByteArray * nm_access_point_get_ssid (NMAccessPoint *ap) { @@ -133,6 +175,14 @@ nm_access_point_get_ssid (NMAccessPoint *ap) return priv->ssid; } +/** + * nm_access_point_get_frequency: + * @ap: a #NMAccessPoint + * + * Gets the frequency of the access point. + * + * Returns: the frequency + **/ guint32 nm_access_point_get_frequency (NMAccessPoint *ap) { @@ -150,6 +200,15 @@ nm_access_point_get_frequency (NMAccessPoint *ap) return priv->frequency; } +/** + * nm_access_point_get_hw_address: + * @ap: a #NMAccessPoint + * + * Gets the hardware (MAC) address of the access point. + * + * Returns: the hardware address of the access point. This is the internal string used by the + * access point and must not be modified. + **/ const char * nm_access_point_get_hw_address (NMAccessPoint *ap) { @@ -167,6 +226,14 @@ nm_access_point_get_hw_address (NMAccessPoint *ap) return priv->hw_address; } +/** + * nm_access_point_get_mode: + * @ap: a #NMAccessPoint + * + * Gets the mode of the access point. + * + * Returns: the mode + **/ NM80211Mode nm_access_point_get_mode (NMAccessPoint *ap) { @@ -184,6 +251,14 @@ nm_access_point_get_mode (NMAccessPoint *ap) return priv->mode; } +/** + * nm_access_point_get_max_bitrate: + * @ap: a #NMAccessPoint + * + * Gets the maximum bit rate of the access point. + * + * Returns: the maximum bit rate + **/ guint32 nm_access_point_get_max_bitrate (NMAccessPoint *ap) { @@ -201,6 +276,14 @@ nm_access_point_get_max_bitrate (NMAccessPoint *ap) return priv->max_bitrate; } +/** + * nm_access_point_get_strength: + * @ap: + * + * Gets the current signal strength of the access point. + * + * Returns: the signal strength + **/ guint8 nm_access_point_get_strength (NMAccessPoint *ap) { @@ -371,6 +454,12 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) object_class->finalize = finalize; /* properties */ + + /** + * NMAccessPoint:flags: + * + * The flags of the access point. + **/ g_object_class_install_property (object_class, PROP_FLAGS, g_param_spec_uint (NM_ACCESS_POINT_FLAGS, @@ -381,6 +470,11 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) NM_802_11_AP_FLAGS_NONE, G_PARAM_READABLE)); + /** + * NMAccessPoint:wpa-flags: + * + * The WPA flags of the access point. + **/ g_object_class_install_property (object_class, PROP_WPA_FLAGS, g_param_spec_uint (NM_ACCESS_POINT_WPA_FLAGS, @@ -389,6 +483,11 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) 0, G_MAXUINT32, 0, G_PARAM_READABLE)); + /** + * NMAccessPoint:rsn-flags: + * + * The RSN flags of the access point. + **/ g_object_class_install_property (object_class, PROP_RSN_FLAGS, g_param_spec_uint (NM_ACCESS_POINT_RSN_FLAGS, @@ -397,6 +496,11 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) 0, G_MAXUINT32, 0, G_PARAM_READABLE)); + /** + * NMAccessPoint:ssid: + * + * The SSID of the access point. + **/ g_object_class_install_property (object_class, PROP_SSID, g_param_spec_boxed (NM_ACCESS_POINT_SSID, @@ -405,6 +509,11 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) NM_TYPE_SSID, G_PARAM_READABLE)); + /** + * NMAccessPoint:frequency: + * + * The frequency of the access point. + **/ g_object_class_install_property (object_class, PROP_FREQUENCY, g_param_spec_uint (NM_ACCESS_POINT_FREQUENCY, @@ -413,6 +522,11 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) 0, 10000, 0, G_PARAM_READABLE)); + /** + * NMAccessPoint:hw-address: + * + * The hardware address of the access point. + **/ g_object_class_install_property (object_class, PROP_HW_ADDRESS, g_param_spec_string (NM_ACCESS_POINT_HW_ADDRESS, @@ -421,6 +535,11 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) NULL, G_PARAM_READABLE)); + /** + * NMAccessPoint:mode: + * + * The mode of the access point. + **/ g_object_class_install_property (object_class, PROP_MODE, g_param_spec_uint (NM_ACCESS_POINT_MODE, @@ -429,6 +548,11 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) NM_802_11_MODE_ADHOC, NM_802_11_MODE_INFRA, NM_802_11_MODE_INFRA, G_PARAM_READABLE)); + /** + * NMAccessPoint:max-bitrate: + * + * The maximum bit rate of the access point. + **/ g_object_class_install_property (object_class, PROP_MAX_BITRATE, g_param_spec_uint (NM_ACCESS_POINT_MAX_BITRATE, @@ -437,6 +561,11 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) 0, G_MAXUINT32, 0, G_PARAM_READABLE)); + /** + * NMAccessPoint:strength: + * + * The current signal strength of the access point. + **/ g_object_class_install_property (object_class, PROP_STRENGTH, g_param_spec_uchar (NM_ACCESS_POINT_STRENGTH, diff --git a/libnm-glib/nm-active-connection.c b/libnm-glib/nm-active-connection.c index 9d2eac719a..3d3e3b67e3 100644 --- a/libnm-glib/nm-active-connection.c +++ b/libnm-glib/nm-active-connection.c @@ -50,6 +50,15 @@ enum { #define DBUS_PROP_STATE "State" #define DBUS_PROP_DEFAULT "Default" +/** + * nm_active_connection_new: + * @connection: the #DBusGConnection + * @path: the DBus object path of the device + * + * Creates a new #NMActiveConnection. + * + * Returns: a new active connection + **/ GObject * nm_active_connection_new (DBusGConnection *connection, const char *path) { @@ -73,6 +82,15 @@ get_scope_for_service_name (const char *service_name) return NM_CONNECTION_SCOPE_UNKNOWN; } +/** + * nm_active_connection_get_service_name: + * @connection: a #NMActiveConnection + * + * Gets the service name of the active connection. + * + * Returns: the service name. This is the internal string used by the + * connection, and must not be modified. + **/ const char * nm_active_connection_get_service_name (NMActiveConnection *connection) { @@ -91,6 +109,14 @@ nm_active_connection_get_service_name (NMActiveConnection *connection) return priv->service_name; } +/** + * nm_active_connection_get_scope: + * @connection: a #NMActiveConnection + * + * Gets the scope of the active connection. + * + * Returns: the connection's scope + **/ NMConnectionScope nm_active_connection_get_scope (NMActiveConnection *connection) { @@ -101,6 +127,15 @@ nm_active_connection_get_scope (NMActiveConnection *connection) return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->scope; } +/** + * nm_active_connection_get_connection: + * @connection: a #NMActiveConnection + * + * Gets the #NMConnection<!-- -->'s DBus object path. + * + * Returns: the object path of the #NMConnection inside of #NMActiveConnection. + * This is the internal string used by the connection, and must not be modified. + **/ const char * nm_active_connection_get_connection (NMActiveConnection *connection) { @@ -118,6 +153,15 @@ nm_active_connection_get_connection (NMActiveConnection *connection) return priv->connection; } +/** + * nm_active_connection_get_specific_object: + * @connection: a #NMActiveConnection + * + * Gets the "specific object" used at the activation. + * + * Returns: the specific object's DBus path. This is the internal string used by the + * connection, and must not be modified. + **/ const char * nm_active_connection_get_specific_object (NMActiveConnection *connection) { @@ -135,6 +179,15 @@ nm_active_connection_get_specific_object (NMActiveConnection *connection) return priv->specific_object; } +/** + * nm_active_connection_get_devices: + * @connection: a #NMActiveConnection + * + * Gets the #NMDevice<!-- -->s used for the active connections. + * + * Returns: the #GPtrArray containing #NMDevice<!-- -->s. + * This is the internal copy used by the connection, and must not be modified. + **/ const GPtrArray * nm_active_connection_get_devices (NMActiveConnection *connection) { @@ -160,6 +213,14 @@ nm_active_connection_get_devices (NMActiveConnection *connection) return handle_ptr_array_return (priv->devices); } +/** + * nm_active_connection_get_state: + * @connection: a #NMActiveConnection + * + * Gets the active connection's state. + * + * Returns: the state + **/ NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *connection) { @@ -177,6 +238,15 @@ nm_active_connection_get_state (NMActiveConnection *connection) return priv->state; } +/** + * nm_active_connection_get_default: + * @connection: a #NMActiveConnection + * + * Whether the active connection is the default one (that is, is used for the default route + * and DNS information). + * + * Returns: %TRUE if the active connection is the default one + **/ gboolean nm_active_connection_get_default (NMActiveConnection *connection) { @@ -350,6 +420,12 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) object_class->finalize = finalize; /* properties */ + + /** + * NMActiveConnection:service-name: + * + * The service name of the active connection. + **/ g_object_class_install_property (object_class, PROP_SERVICE_NAME, g_param_spec_string (NM_ACTIVE_CONNECTION_SERVICE_NAME, @@ -358,6 +434,11 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) NULL, G_PARAM_READABLE)); + /** + * NMActiveConnection:connection: + * + * The connection's path of the active connection. + **/ g_object_class_install_property (object_class, PROP_CONNECTION, g_param_spec_string (NM_ACTIVE_CONNECTION_CONNECTION, @@ -366,6 +447,11 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) NULL, G_PARAM_READABLE)); + /** + * NMActiveConnection:specific-object: + * + * The specific object's path of the active connection. + **/ g_object_class_install_property (object_class, PROP_SPECIFIC_OBJECT, g_param_spec_string (NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, @@ -374,6 +460,11 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) NULL, G_PARAM_READABLE)); + /** + * NMActiveConnection:device: + * + * The devices (#NMDevice) of the active connection. + **/ g_object_class_install_property (object_class, PROP_DEVICES, g_param_spec_boxed (NM_ACTIVE_CONNECTION_DEVICES, @@ -382,6 +473,11 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) NM_TYPE_OBJECT_ARRAY, G_PARAM_READABLE)); + /** + * NMActiveConnection:state: + * + * The state of the active connection. + **/ g_object_class_install_property (object_class, PROP_STATE, g_param_spec_uint (NM_ACTIVE_CONNECTION_STATE, @@ -392,6 +488,11 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) NM_ACTIVE_CONNECTION_STATE_UNKNOWN, G_PARAM_READABLE)); + /** + * NMActiveConnection:default: + * + * Whether the active connection is the default one. + **/ g_object_class_install_property (object_class, PROP_DEFAULT, g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT, diff --git a/libnm-glib/nm-cdma-device.c b/libnm-glib/nm-cdma-device.c index 9266707ecd..afd2b6a4ae 100644 --- a/libnm-glib/nm-cdma-device.c +++ b/libnm-glib/nm-cdma-device.c @@ -87,6 +87,15 @@ nm_cdma_device_class_init (NMCdmaDeviceClass *device_class) object_class->dispose = dispose; } +/** + * nm_cdma_device_new: + * @connection: the #DBusGConnection + * @path: the DBus object path of the device + * + * Creates a new #NMCdmaDevice. + * + * Returns: a new device + **/ GObject * nm_cdma_device_new (DBusGConnection *connection, const char *path) { diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index 050cc671b5..0def21e045 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -381,6 +381,12 @@ nm_client_class_init (NMClientClass *client_class) object_class->dispose = dispose; /* properties */ + + /** + * NMClient:state: + * + * The current daemon state. + **/ g_object_class_install_property (object_class, PROP_STATE, g_param_spec_uint (NM_CLIENT_STATE, @@ -389,6 +395,11 @@ nm_client_class_init (NMClientClass *client_class) NM_STATE_UNKNOWN, NM_STATE_DISCONNECTED, NM_STATE_UNKNOWN, G_PARAM_READABLE)); + /** + * NMClient::manager-running: + * + * Whether the daemon is running. + **/ g_object_class_install_property (object_class, PROP_MANAGER_RUNNING, g_param_spec_boolean (NM_CLIENT_MANAGER_RUNNING, @@ -397,6 +408,11 @@ nm_client_class_init (NMClientClass *client_class) FALSE, G_PARAM_READABLE)); + /** + * NMClient::wireless-enabled: + * + * Whether wireless is enabled. + **/ g_object_class_install_property (object_class, PROP_WIRELESS_ENABLED, g_param_spec_boolean (NM_CLIENT_WIRELESS_ENABLED, @@ -405,6 +421,11 @@ nm_client_class_init (NMClientClass *client_class) TRUE, G_PARAM_READWRITE)); + /** + * NMClient::wireless-hardware-enabled: + * + * Whether the wireless hardware is enabled. + **/ g_object_class_install_property (object_class, PROP_WIRELESS_HARDWARE_ENABLED, g_param_spec_boolean (NM_CLIENT_WIRELESS_HARDWARE_ENABLED, @@ -413,6 +434,11 @@ nm_client_class_init (NMClientClass *client_class) TRUE, G_PARAM_READABLE)); + /** + * NMClient::active-connections: + * + * The active connections. + **/ g_object_class_install_property (object_class, PROP_ACTIVE_CONNECTIONS, g_param_spec_boxed (NM_CLIENT_ACTIVE_CONNECTIONS, @@ -422,6 +448,14 @@ nm_client_class_init (NMClientClass *client_class) G_PARAM_READABLE)); /* signals */ + + /** + * NMClient::device-added: + * @client: the client that received the signal + * @device: the new device + * + * Notifies that a #NMDevice is added. + **/ signals[DEVICE_ADDED] = g_signal_new ("device-added", G_OBJECT_CLASS_TYPE (object_class), @@ -432,6 +466,13 @@ nm_client_class_init (NMClientClass *client_class) G_TYPE_NONE, 1, G_TYPE_OBJECT); + /** + * NMClient::device-removed: + * @widget: the client that received the signal + * @device: the removed device + * + * Notifies that a #NMDevice is removed. + **/ signals[DEVICE_REMOVED] = g_signal_new ("device-removed", G_OBJECT_CLASS_TYPE (object_class), @@ -443,6 +484,13 @@ nm_client_class_init (NMClientClass *client_class) G_TYPE_OBJECT); } +/** + * nm_client_new: + * + * Creates a new #NMClient. + * + * Returns: a new #NMClient + **/ NMClient * nm_client_new (void) { @@ -541,6 +589,15 @@ client_device_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data) } } +/** + * nm_client_get_devices: + * @client: a #NMClient + * + * Gets all the detected devices. + * + * Returns: a #GPtrArray containing all the #NMDevice<!-- -->s. + * The returned array is owned by the client and should not be modified. + **/ const GPtrArray * nm_client_get_devices (NMClient *client) { @@ -571,6 +628,15 @@ nm_client_get_devices (NMClient *client) return handle_ptr_array_return (priv->devices); } +/** + * nm_client_get_device_by_path: + * @client: a #NMClient + * @object_path: the object path to search for + * + * Gets a #NMDevice from a #NMClient. + * + * Returns: the #NMDevice for the given @object_path or %NULL if none is found. + **/ NMDevice * nm_client_get_device_by_path (NMClient *client, const char *object_path) { @@ -617,6 +683,19 @@ activate_cb (DBusGProxy *proxy, g_slice_free (ActivateDeviceInfo, info); } +/** + * nm_client_activate_connection: + * @client: a #NMClient + * @service_name: the connection's service name + * @connection_path: the connection's DBus path + * @device: the #NMDevice + * @specific_object: the device specific object (currently used only for + * activating wireless devices and should be the #NMAccessPoint<!-- -->'s path. + * @callback: the function to call when the call is done + * @user_data: user data to pass to the callback function + * + * Activates a connection with the given #NMDevice. + **/ void nm_client_activate_connection (NMClient *client, const char *service_name, @@ -653,6 +732,13 @@ nm_client_activate_connection (NMClient *client, info); } +/** + * nm_client_deactivate_connection: + * @client: a #NMClient + * @active: the #NMActiveConnection to deactivate + * + * Deactivates an active #NMActiveConnection. + **/ void nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active) { @@ -672,6 +758,15 @@ nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active) } } +/** + * nm_client_get_active_connections: + * @client: a #NMClient + * + * Gets the active connections. + * + * Returns: a #GPtrArray containing all the active #NMActiveConnection<!-- -->s. + * The returned array is owned by the client and should not be modified. + **/ const GPtrArray * nm_client_get_active_connections (NMClient *client) { @@ -684,6 +779,9 @@ nm_client_get_active_connections (NMClient *client) if (priv->active_connections) return handle_ptr_array_return (priv->active_connections); + if (!priv->manager_running) + return NULL; + if (!nm_object_get_property (NM_OBJECT (client), "org.freedesktop.DBus.Properties", "ActiveConnections", @@ -697,6 +795,14 @@ nm_client_get_active_connections (NMClient *client) return handle_ptr_array_return (priv->active_connections); } +/** + * nm_client_wireless_get_enabled: + * @client: a #NMClient + * + * Determines whether the wireless is enabled. + * + * Returns: %TRUE if wireless is enabled + **/ gboolean nm_client_wireless_get_enabled (NMClient *client) { @@ -705,6 +811,13 @@ nm_client_wireless_get_enabled (NMClient *client) return NM_CLIENT_GET_PRIVATE (client)->wireless_enabled; } +/** + * nm_client_wireless_set_enabled: + * @client: a #NMClient + * @enabled: %TRUE to enable wireless + * + * Enables or disables wireless devices. + **/ void nm_client_wireless_set_enabled (NMClient *client, gboolean enabled) { @@ -721,6 +834,14 @@ nm_client_wireless_set_enabled (NMClient *client, gboolean enabled) &value); } +/** + * nm_client_wireless_hardware_get_enabled: + * @client: a #NMClient + * + * Determines whether the wireless hardware is enabled. + * + * Returns: %TRUE if the wireless hardware is enabled + **/ gboolean nm_client_wireless_hardware_get_enabled (NMClient *client) { @@ -729,6 +850,14 @@ nm_client_wireless_hardware_get_enabled (NMClient *client) return NM_CLIENT_GET_PRIVATE (client)->wireless_hw_enabled; } +/** + * nm_client_get_state: + * @client: a #NMClient + * + * Gets the current daemon state. + * + * Returns: the current %NMState + **/ NMState nm_client_get_state (NMClient *client) { @@ -747,6 +876,14 @@ nm_client_get_state (NMClient *client) return priv->state; } +/** + * nm_client_sleep: + * @client: a #NMClient + * @sleep: %TRUE to put the daemon to sleep + * + * Enables or disables networking. When the daemon is put to sleep, it'll deactivate and disable + * all the active devices. + **/ void nm_client_sleep (NMClient *client, gboolean sleep) { @@ -760,6 +897,14 @@ nm_client_sleep (NMClient *client, gboolean sleep) } } +/** + * nm_client_get_manager_running: + * @client: a #NMClient + * + * Determines whether the daemon is running. + * + * Returns: %TRUE if the daemon is running + **/ gboolean nm_client_get_manager_running (NMClient *client) { diff --git a/libnm-glib/nm-device-ethernet.c b/libnm-glib/nm-device-ethernet.c index d8d43e55c3..57c423f8b5 100644 --- a/libnm-glib/nm-device-ethernet.c +++ b/libnm-glib/nm-device-ethernet.c @@ -32,6 +32,15 @@ enum { #define DBUS_PROP_SPEED "Speed" #define DBUS_PROP_CARRIER "Carrier" +/** + * nm_device_ethernet_new: + * @connection: the #DBusGConnection + * @path: the DBus object path of the device + * + * Creates a new #NMDeviceEthernet. + * + * Returns: a new device + **/ GObject * nm_device_ethernet_new (DBusGConnection *connection, const char *path) { @@ -44,6 +53,15 @@ nm_device_ethernet_new (DBusGConnection *connection, const char *path) NULL); } +/** + * nm_device_ethernet_get_hw_address: + * @device: a #NMDeviceEthernet + * + * Gets the hardware (MAC) address of the #NMDeviceEthernet + * + * Returns: the hardware address. This is the internal string used by the + * device, and must not be modified. + **/ const char * nm_device_ethernet_get_hw_address (NMDeviceEthernet *device) { @@ -61,6 +79,14 @@ nm_device_ethernet_get_hw_address (NMDeviceEthernet *device) return priv->hw_address; } +/** + * nm_device_ethernet_get_speed: + * @device: a #NMDeviceEthernet + * + * Gets the speed of the #NMDeviceEthernet. + * + * Returns: the speed of the device + **/ guint32 nm_device_ethernet_get_speed (NMDeviceEthernet *device) { @@ -78,6 +104,14 @@ nm_device_ethernet_get_speed (NMDeviceEthernet *device) return priv->speed; } +/** + * nm_device_ethernet_get_carrier: + * @device: a #NMDeviceEthernet + * + * Whether the device has carrier. + * + * Returns: %TRUE if the device has carrier + **/ gboolean nm_device_ethernet_get_carrier (NMDeviceEthernet *device) { @@ -214,6 +248,12 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *device_class) object_class->get_property = get_property; /* properties */ + + /** + * NMDeviceEthernet:hw-address: + * + * The hardware (MAC) address of the device. + **/ g_object_class_install_property (object_class, PROP_HW_ADDRESS, g_param_spec_string (NM_DEVICE_ETHERNET_HW_ADDRESS, @@ -222,6 +262,11 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *device_class) NULL, G_PARAM_READABLE)); + /** + * NMDeviceEthernet:speed: + * + * The speed of the device. + **/ g_object_class_install_property (object_class, PROP_SPEED, g_param_spec_uint (NM_DEVICE_ETHERNET_SPEED, @@ -230,6 +275,11 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *device_class) 0, G_MAXUINT32, 0, G_PARAM_READABLE)); + /** + * NMDeviceEthernet:carrier: + * + * Whether the device has carrier. + **/ g_object_class_install_property (object_class, PROP_CARRIER, g_param_spec_boolean (NM_DEVICE_ETHERNET_CARRIER, diff --git a/libnm-glib/nm-device-wifi.c b/libnm-glib/nm-device-wifi.c index ae2e753450..ac6b93e251 100644 --- a/libnm-glib/nm-device-wifi.c +++ b/libnm-glib/nm-device-wifi.c @@ -60,6 +60,15 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +/** + * nm_device_wifi_new: + * @connection: the #DBusGConnection + * @path: the DBus object path of the device + * + * Creates a new #NMDeviceWifi. + * + * Returns: a new device + **/ GObject * nm_device_wifi_new (DBusGConnection *connection, const char *path) { @@ -72,6 +81,15 @@ nm_device_wifi_new (DBusGConnection *connection, const char *path) NULL); } +/** + * nm_device_wifi_get_hw_address: + * @device: a #NMDeviceWifi + * + * Gets the hardware (MAC) address of the #NMDeviceWifi + * + * Returns: the hardware address. This is the internal string used by the + * device, and must not be modified. + **/ const char * nm_device_wifi_get_hw_address (NMDeviceWifi *device) { @@ -89,6 +107,14 @@ nm_device_wifi_get_hw_address (NMDeviceWifi *device) return priv->hw_address; } +/** + * nm_device_wifi_get_mode: + * @device: a #NMDeviceWifi + * + * Gets the #NMDeviceWifi mode. + * + * Returns: the mode + **/ NM80211Mode nm_device_wifi_get_mode (NMDeviceWifi *device) { @@ -106,6 +132,14 @@ nm_device_wifi_get_mode (NMDeviceWifi *device) return priv->mode; } +/** + * nm_device_wifi_get_bitrate: + * @device: a #NMDeviceWifi + * + * Gets the bit rate of the #NMDeviceWifi. + * + * Returns: the bit rate + **/ guint32 nm_device_wifi_get_bitrate (NMDeviceWifi *device) { @@ -137,6 +171,14 @@ nm_device_wifi_get_bitrate (NMDeviceWifi *device) return priv->rate; } +/** + * nm_device_wifi_get_capabilities: + * @device: a #NMDeviceWifi + * + * Gets the WIFI capabilities of the #NMDeviceWifi. + * + * Returns: the capabilities + **/ guint32 nm_device_wifi_get_capabilities (NMDeviceWifi *device) { @@ -154,6 +196,14 @@ nm_device_wifi_get_capabilities (NMDeviceWifi *device) return priv->wireless_caps; } +/** + * nm_device_wifi_get_active_access_point: + * @self: a #NMDeviceWifi + * + * Gets the active #NMAccessPoint. + * + * Returns: the access point or %NULL if none is active + **/ NMAccessPoint * nm_device_wifi_get_active_access_point (NMDeviceWifi *self) { @@ -196,6 +246,15 @@ nm_device_wifi_get_active_access_point (NMDeviceWifi *self) return priv->active_ap; } +/** + * nm_device_wifi_get_access_points: + * @self: a #NMDeviceWifi + * + * Gets all the scanned access points of the #NMDeviceWifi. + * + * Returns: a #GPtrArray containing all the scanned #NMAccessPoint<!-- -->s. + * The returned array is owned by the client and should not be modified. + **/ const GPtrArray * nm_device_wifi_get_access_points (NMDeviceWifi *self) { @@ -226,6 +285,15 @@ nm_device_wifi_get_access_points (NMDeviceWifi *self) return handle_ptr_array_return (priv->aps); } +/** + * nm_device_wifi_get_access_point_by_path: + * @self: a #NMDeviceWifi + * @path: the object path of the access point + * + * Gets a #NMAccessPoint by path. + * + * Returns: the access point or %NULL if none is found. + **/ NMAccessPoint * nm_device_wifi_get_access_point_by_path (NMDeviceWifi *self, const char *path) @@ -323,6 +391,13 @@ clean_up_aps (NMDeviceWifi *self, gboolean notify) } } +/** + * nm_device_wifi_set_wireless_enabled: + * @device: a #NMDeviceWifi + * @enabled: %TRUE to enable the device + * + * Enables or disables the wireless device. + **/ void nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, gboolean enabled) @@ -547,6 +622,12 @@ nm_device_wifi_class_init (NMDeviceWifiClass *device_class) object_class->finalize = finalize; /* properties */ + + /** + * NMDeviceWifi:hw-address: + * + * The hardware (MAC) address of the device. + **/ g_object_class_install_property (object_class, PROP_HW_ADDRESS, g_param_spec_string (NM_DEVICE_WIFI_HW_ADDRESS, @@ -555,6 +636,11 @@ nm_device_wifi_class_init (NMDeviceWifiClass *device_class) NULL, G_PARAM_READABLE)); + /** + * NMDeviceWifi:mode: + * + * The mode of the device. + **/ g_object_class_install_property (object_class, PROP_MODE, g_param_spec_uint (NM_DEVICE_WIFI_MODE, @@ -563,6 +649,11 @@ nm_device_wifi_class_init (NMDeviceWifiClass *device_class) NM_802_11_MODE_UNKNOWN, NM_802_11_MODE_INFRA, NM_802_11_MODE_INFRA, G_PARAM_READABLE)); + /** + * NMDeviceWifi:bitrate: + * + * The bit rate of the device. + **/ g_object_class_install_property (object_class, PROP_BITRATE, g_param_spec_uint (NM_DEVICE_WIFI_BITRATE, @@ -571,6 +662,11 @@ nm_device_wifi_class_init (NMDeviceWifiClass *device_class) 0, G_MAXUINT32, 0, G_PARAM_READABLE)); + /** + * NMDeviceWifi:active-access-point: + * + * The active #NMAccessPoint of the device. + **/ g_object_class_install_property (object_class, PROP_ACTIVE_ACCESS_POINT, g_param_spec_object (NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, @@ -579,6 +675,11 @@ nm_device_wifi_class_init (NMDeviceWifiClass *device_class) NM_TYPE_ACCESS_POINT, G_PARAM_READABLE)); + /** + * NMDeviceWifi:wireless-capabilities: + * + * The wireless capabilities of the device. + **/ g_object_class_install_property (object_class, PROP_WIRELESS_CAPABILITIES, g_param_spec_uint (NM_DEVICE_WIFI_CAPABILITIES, @@ -588,6 +689,14 @@ nm_device_wifi_class_init (NMDeviceWifiClass *device_class) G_PARAM_READABLE)); /* signals */ + + /** + * NMDeviceWifi::access-point-added: + * @device: the wifi device that received the signal + * @ap: the new access point + * + * Notifies that a #NMAccessPoint is added to the wifi device. + **/ signals[ACCESS_POINT_ADDED] = g_signal_new ("access-point-added", G_OBJECT_CLASS_TYPE (object_class), @@ -598,6 +707,13 @@ nm_device_wifi_class_init (NMDeviceWifiClass *device_class) G_TYPE_NONE, 1, G_TYPE_OBJECT); + /** + * NMDeviceWifi::access-point-removed: + * @device: the wifi device that received the signal + * @ap: the removed access point + * + * Notifies that a #NMAccessPoint is removed from the wifi device. + **/ signals[ACCESS_POINT_REMOVED] = g_signal_new ("access-point-removed", G_OBJECT_CLASS_TYPE (object_class), diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index 24ca876cfd..d142bfe29f 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -28,6 +28,8 @@ typedef struct { gboolean managed; NMIP4Config *ip4_config; gboolean null_ip4_config; + NMDHCP4Config *dhcp4_config; + gboolean null_dhcp4_config; NMDeviceState state; char *product; char *vendor; @@ -41,6 +43,7 @@ enum { PROP_CAPABILITIES, PROP_MANAGED, PROP_IP4_CONFIG, + PROP_DHCP4_CONFIG, PROP_STATE, PROP_PRODUCT, PROP_VENDOR, @@ -106,6 +109,46 @@ demarshal_ip4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint return TRUE; } +static gboolean +demarshal_dhcp4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object); + const char *path; + NMDHCP4Config *config = NULL; + DBusGConnection *connection; + + if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) + return FALSE; + + priv->null_dhcp4_config = FALSE; + + path = g_value_get_boxed (value); + if (path) { + if (!strcmp (path, "/")) + priv->null_dhcp4_config = TRUE; + else { + config = NM_DHCP4_CONFIG (nm_object_cache_get (path)); + if (config) + config = g_object_ref (config); + else { + connection = nm_object_get_connection (object); + config = NM_DHCP4_CONFIG (nm_dhcp4_config_new (connection, path)); + } + } + } + + if (priv->dhcp4_config) { + g_object_unref (priv->dhcp4_config); + priv->dhcp4_config = NULL; + } + + if (config) + priv->dhcp4_config = config; + + nm_object_queue_notify (object, NM_DEVICE_DHCP4_CONFIG); + return TRUE; +} + static void register_for_property_changed (NMDevice *device) { @@ -117,6 +160,7 @@ register_for_property_changed (NMDevice *device) { NM_DEVICE_CAPABILITIES, nm_object_demarshal_generic, &priv->capabilities }, { NM_DEVICE_MANAGED, nm_object_demarshal_generic, &priv->managed }, { NM_DEVICE_IP4_CONFIG, demarshal_ip4_config, &priv->ip4_config }, + { NM_DEVICE_DHCP4_CONFIG, demarshal_dhcp4_config, &priv->dhcp4_config }, { NULL }, }; @@ -198,6 +242,8 @@ dispose (GObject *object) g_object_unref (priv->proxy); if (priv->ip4_config) g_object_unref (priv->ip4_config); + if (priv->dhcp4_config) + g_object_unref (priv->dhcp4_config); G_OBJECT_CLASS (nm_device_parent_class)->dispose (object); } @@ -243,6 +289,9 @@ get_property (GObject *object, case PROP_IP4_CONFIG: g_value_set_object (value, nm_device_get_ip4_config (device)); break; + case PROP_DHCP4_CONFIG: + g_value_set_object (value, nm_device_get_dhcp4_config (device)); + break; case PROP_STATE: g_value_set_uint (value, nm_device_get_state (device)); break; @@ -272,6 +321,12 @@ nm_device_class_init (NMDeviceClass *device_class) object_class->finalize = finalize; /* properties */ + + /** + * NMDevice:interface: + * + * The interface of the device. + **/ g_object_class_install_property (object_class, PROP_INTERFACE, g_param_spec_string (NM_DEVICE_INTERFACE, @@ -280,6 +335,11 @@ nm_device_class_init (NMDeviceClass *device_class) NULL, G_PARAM_READABLE)); + /** + * NMDevice:udi: + * + * The HAL UDI of the device. + **/ g_object_class_install_property (object_class, PROP_UDI, g_param_spec_string (NM_DEVICE_UDI, @@ -288,6 +348,11 @@ nm_device_class_init (NMDeviceClass *device_class) NULL, G_PARAM_READABLE)); + /** + * NMDevice:driver: + * + * The driver of the device. + **/ g_object_class_install_property (object_class, PROP_DRIVER, g_param_spec_string (NM_DEVICE_DRIVER, @@ -296,6 +361,11 @@ nm_device_class_init (NMDeviceClass *device_class) NULL, G_PARAM_READABLE)); + /** + * NMDevice:capabilities: + * + * The capabilities of the device. + **/ g_object_class_install_property (object_class, PROP_CAPABILITIES, g_param_spec_uint (NM_DEVICE_CAPABILITIES, @@ -304,6 +374,11 @@ nm_device_class_init (NMDeviceClass *device_class) 0, G_MAXUINT32, 0, G_PARAM_READABLE)); + /** + * NMDevice:managed: + * + * Whether the device is managed by NetworkManager. + **/ g_object_class_install_property (object_class, PROP_MANAGED, g_param_spec_boolean (NM_DEVICE_MANAGED, @@ -312,6 +387,11 @@ nm_device_class_init (NMDeviceClass *device_class) FALSE, G_PARAM_READABLE)); + /** + * NMDevice:ip4-config: + * + * The #NMIP4Config of the device. + **/ g_object_class_install_property (object_class, PROP_IP4_CONFIG, g_param_spec_object (NM_DEVICE_IP4_CONFIG, @@ -320,6 +400,24 @@ nm_device_class_init (NMDeviceClass *device_class) NM_TYPE_IP4_CONFIG, G_PARAM_READABLE)); + /** + * NMDevice:dhcp4-config: + * + * The #NMDHCP4Config of the device. + **/ + g_object_class_install_property + (object_class, PROP_DHCP4_CONFIG, + g_param_spec_object (NM_DEVICE_DHCP4_CONFIG, + "DHCP4 Config", + "DHCP4 Config", + NM_TYPE_DHCP4_CONFIG, + G_PARAM_READABLE)); + + /** + * NMDevice:state: + * + * The state of the device. + **/ g_object_class_install_property (object_class, PROP_STATE, g_param_spec_uint (NM_DEVICE_STATE, @@ -328,6 +426,11 @@ nm_device_class_init (NMDeviceClass *device_class) 0, G_MAXUINT32, 0, G_PARAM_READABLE)); + /** + * NMDevice:vendor: + * + * The vendor string of the device. + **/ g_object_class_install_property (object_class, PROP_VENDOR, g_param_spec_string (NM_DEVICE_VENDOR, @@ -336,6 +439,11 @@ nm_device_class_init (NMDeviceClass *device_class) NULL, G_PARAM_READABLE)); + /** + * NMDevice:product: + * + * The product string of the device. + **/ g_object_class_install_property (object_class, PROP_PRODUCT, g_param_spec_string (NM_DEVICE_PRODUCT, @@ -345,6 +453,14 @@ nm_device_class_init (NMDeviceClass *device_class) G_PARAM_READABLE)); /* signals */ + + /** + * NMDevice::state-changed: + * @device: the client that received the signal + * @state: the new state of the device + * + * Notifies the state change of a #NMDevice. + **/ signals[STATE_CHANGED] = g_signal_new ("state-changed", G_OBJECT_CLASS_TYPE (object_class), @@ -356,6 +472,15 @@ nm_device_class_init (NMDeviceClass *device_class) G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT); } +/** + * nm_device_new: + * @connection: the #DBusGConnection + * @path: the DBus object path of the device + * + * Creates a new #NMDevice. + * + * Returns: a new device + **/ GObject * nm_device_new (DBusGConnection *connection, const char *path) { @@ -418,6 +543,15 @@ out: return G_OBJECT (device); } +/** + * nm_device_get_iface: + * @device: a #NMDevice + * + * Gets the interface name of the #NMDevice. + * + * Returns: the interface of the device. This is the internal string used by the + * device, and must not be modified. + **/ const char * nm_device_get_iface (NMDevice *device) { @@ -435,6 +569,15 @@ nm_device_get_iface (NMDevice *device) return priv->iface; } +/** + * nm_device_get_udi: + * @device: a #NMDevice + * + * Gets the HAL UDI of the #NMDevice. + * + * Returns: the HAL UDI of the device. This is the internal string used by the + * device, and must not be modified. + **/ const char * nm_device_get_udi (NMDevice *device) { @@ -452,6 +595,15 @@ nm_device_get_udi (NMDevice *device) return priv->udi; } +/** + * nm_device_get_driver: + * @device: a #NMDevice + * + * Gets the driver of the #NMDevice. + * + * Returns: the driver of the device. This is the internal string used by the + * device, and must not be modified. + **/ const char * nm_device_get_driver (NMDevice *device) { @@ -469,6 +621,14 @@ nm_device_get_driver (NMDevice *device) return priv->driver; } +/** + * nm_device_get_capabilities: + * @device: a #NMDevice + * + * Gets the device' capabilities. + * + * Returns: the capabilities + **/ guint32 nm_device_get_capabilities (NMDevice *device) { @@ -486,6 +646,14 @@ nm_device_get_capabilities (NMDevice *device) return priv->capabilities; } +/** + * nm_device_get_managed: + * @device: a #NMDevice + * + * Whether the #NMDevice is managed by NetworkManager. + * + * Returns: %TRUE if the device is managed by NetworkManager + **/ gboolean nm_device_get_managed (NMDevice *device) { @@ -503,6 +671,14 @@ nm_device_get_managed (NMDevice *device) return priv->managed; } +/** + * nm_device_get_ip4_config: + * @device: a #NMDevice + * + * Gets the current #NMIP4Config associated with the #NMDevice. + * + * Returns: the #NMIP4Config or %NULL if the device is not activated. + **/ NMIP4Config * nm_device_get_ip4_config (NMDevice *device) { @@ -529,6 +705,49 @@ nm_device_get_ip4_config (NMDevice *device) return priv->ip4_config; } +/** + * nm_device_get_dhcp4_config: + * @device: a #NMDevice + * + * Gets the current #NMDHCP4Config associated with the #NMDevice. + * + * Returns: the #NMDHCPConfig or %NULL if the device is not activated or not + * using DHCP. + **/ +NMDHCP4Config * +nm_device_get_dhcp4_config (NMDevice *device) +{ + NMDevicePrivate *priv; + char *path; + GValue value = { 0, }; + + g_return_val_if_fail (NM_IS_DEVICE (device), NULL); + + priv = NM_DEVICE_GET_PRIVATE (device); + if (priv->dhcp4_config) + return priv->dhcp4_config; + if (priv->null_dhcp4_config) + return 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); + demarshal_dhcp4_config (NM_OBJECT (device), NULL, &value, &priv->dhcp4_config); + g_value_unset (&value); + } + + return priv->dhcp4_config; +} + +/** + * nm_device_get_state: + * @device: a #NMDevice + * + * Gets the current #NMDevice state. + * + * Returns: the current device state + **/ NMDeviceState nm_device_get_state (NMDevice *device) { @@ -724,6 +943,15 @@ nm_device_update_description (NMDevice *device) nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_PRODUCT); } +/** + * nm_device_get_product: + * @device: a #NMDevice + * + * Gets the product string of the #NMDevice. + * + * Returns: the product name of the device. This is the internal string used by the + * device, and must not be modified. + **/ const char * nm_device_get_product (NMDevice *device) { @@ -737,6 +965,15 @@ nm_device_get_product (NMDevice *device) return priv->product; } +/** + * nm_device_get_vendor: + * @device: a #NMDevice + * + * Gets the vendor string of the #NMDevice. + * + * Returns: the vendor name of the device. This is the internal string used by the + * device, and must not be modified. + **/ const char * nm_device_get_vendor (NMDevice *device) { diff --git a/libnm-glib/nm-device.h b/libnm-glib/nm-device.h index 1b1214c5c3..f74d892c44 100644 --- a/libnm-glib/nm-device.h +++ b/libnm-glib/nm-device.h @@ -7,6 +7,7 @@ #include "nm-object.h" #include "NetworkManager.h" #include "nm-ip4-config.h" +#include "nm-dhcp4-config.h" #include "nm-connection.h" G_BEGIN_DECLS @@ -24,6 +25,7 @@ G_BEGIN_DECLS #define NM_DEVICE_CAPABILITIES "capabilities" #define NM_DEVICE_MANAGED "managed" #define NM_DEVICE_IP4_CONFIG "ip4-config" +#define NM_DEVICE_DHCP4_CONFIG "dhcp4-config" #define NM_DEVICE_STATE "state" #define NM_DEVICE_VENDOR "vendor" #define NM_DEVICE_PRODUCT "product" @@ -46,15 +48,16 @@ GType nm_device_get_type (void); GObject * nm_device_new (DBusGConnection *connection, const char *path); -const char * nm_device_get_iface (NMDevice *device); -const char * nm_device_get_udi (NMDevice *device); -const char * nm_device_get_driver (NMDevice *device); -guint32 nm_device_get_capabilities (NMDevice *device); -gboolean nm_device_get_managed (NMDevice *device); -NMIP4Config * nm_device_get_ip4_config (NMDevice *device); -NMDeviceState nm_device_get_state (NMDevice *device); -const char * nm_device_get_product (NMDevice *device); -const char * nm_device_get_vendor (NMDevice *device); +const char * nm_device_get_iface (NMDevice *device); +const char * nm_device_get_udi (NMDevice *device); +const char * nm_device_get_driver (NMDevice *device); +guint32 nm_device_get_capabilities (NMDevice *device); +gboolean nm_device_get_managed (NMDevice *device); +NMIP4Config * nm_device_get_ip4_config (NMDevice *device); +NMDHCP4Config * nm_device_get_dhcp4_config (NMDevice *device); +NMDeviceState nm_device_get_state (NMDevice *device); +const char * nm_device_get_product (NMDevice *device); +const char * nm_device_get_vendor (NMDevice *device); G_END_DECLS diff --git a/libnm-glib/nm-dhcp4-config.c b/libnm-glib/nm-dhcp4-config.c new file mode 100644 index 0000000000..a01be523c2 --- /dev/null +++ b/libnm-glib/nm-dhcp4-config.c @@ -0,0 +1,223 @@ +#include <string.h> + +#include "nm-dhcp4-config.h" +#include "NetworkManager.h" +#include "nm-types-private.h" +#include "nm-object-private.h" +#include "nm-utils.h" + +G_DEFINE_TYPE (NMDHCP4Config, nm_dhcp4_config, NM_TYPE_OBJECT) + +#define NM_DHCP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP4_CONFIG, NMDHCP4ConfigPrivate)) + +typedef struct { + DBusGProxy *proxy; + + GHashTable *options; +} NMDHCP4ConfigPrivate; + +enum { + PROP_0, + PROP_OPTIONS, + + LAST_PROP +}; + +static void +nm_dhcp4_config_init (NMDHCP4Config *config) +{ +} + +static void +copy_options (gpointer key, gpointer data, gpointer user_data) +{ + GHashTable *options = (GHashTable *) user_data; + GValue *value = (GValue *) data; + + g_hash_table_insert (options, g_strdup (key), g_value_dup_string (value)); +} + +static gboolean +demarshal_dhcp4_options (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) +{ + NMDHCP4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object); + GHashTable *new_options; + + g_hash_table_remove_all (priv->options); + + new_options = g_value_get_boxed (value); + if (new_options) + g_hash_table_foreach (new_options, copy_options, priv->options); + + nm_object_queue_notify (object, NM_DHCP4_CONFIG_OPTIONS); + return TRUE; +} + +static void +register_for_property_changed (NMDHCP4Config *config) +{ + NMDHCP4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (config); + const NMPropertiesChangedInfo property_changed_info[] = { + { NM_DHCP4_CONFIG_OPTIONS, demarshal_dhcp4_options, &priv->options }, + { NULL }, + }; + + nm_object_handle_properties_changed (NM_OBJECT (config), + priv->proxy, + property_changed_info); +} + +static GObject* +constructor (GType type, + guint n_construct_params, + GObjectConstructParam *construct_params) +{ + NMObject *object; + DBusGConnection *connection; + NMDHCP4ConfigPrivate *priv; + + object = (NMObject *) G_OBJECT_CLASS (nm_dhcp4_config_parent_class)->constructor (type, + n_construct_params, + construct_params); + if (!object) + return NULL; + + 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 (object); + + priv->proxy = dbus_g_proxy_new_for_name (connection, + NM_DBUS_SERVICE, + nm_object_get_path (object), + NM_DBUS_INTERFACE_DHCP4_CONFIG); + + register_for_property_changed (NM_DHCP4_CONFIG (object)); + + return G_OBJECT (object); +} + +static void +finalize (GObject *object) +{ + NMDHCP4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object); + + if (priv->options) + g_hash_table_destroy (priv->options); + + G_OBJECT_CLASS (nm_dhcp4_config_parent_class)->finalize (object); +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NMDHCP4Config *self = NM_DHCP4_CONFIG (object); + + switch (prop_id) { + case PROP_OPTIONS: + g_value_set_boxed (value, nm_dhcp4_config_get_options (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_dhcp4_config_class_init (NMDHCP4ConfigClass *config_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (config_class); + + g_type_class_add_private (config_class, sizeof (NMDHCP4ConfigPrivate)); + + /* virtual methods */ + object_class->constructor = constructor; + object_class->get_property = get_property; + object_class->finalize = finalize; + + /* properties */ + + /** + * NMDHCP4Config:options: + * + * The #GHashTable containing options of the configuration. + **/ + g_object_class_install_property + (object_class, PROP_OPTIONS, + g_param_spec_boxed (NM_DHCP4_CONFIG_OPTIONS, + "Options", + "Options", + G_TYPE_HASH_TABLE, + G_PARAM_READABLE)); +} + +/** + * nm_dhcp4_config_new: + * @connection: the #DBusGConnection + * @object_path: the DBus object path of the device + * + * Creates a new #NMDHCP4Config. + * + * Returns: a new configuration + **/ +GObject * +nm_dhcp4_config_new (DBusGConnection *connection, const char *object_path) +{ + return (GObject *) g_object_new (NM_TYPE_DHCP4_CONFIG, + NM_OBJECT_DBUS_CONNECTION, connection, + NM_OBJECT_DBUS_PATH, object_path, + NULL); +} + +/** + * nm_dhcp4_config_get_options: + * @self: a #NMDHCP4Config + * + * Gets all the options contained in the configuration. + * + * Returns: the #GHashTable containing strings for keys and values. + * This is the internal copy used by the configuration, and must not be modified. + **/ +GHashTable * +nm_dhcp4_config_get_options (NMDHCP4Config *self) +{ + NMDHCP4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (self); + GValue value = { 0, }; + + if (g_hash_table_size (priv->options)) + return priv->options; + + if (!nm_object_get_property (NM_OBJECT (self), + "org.freedesktop.DBus.Properties", + "Options", + &value)) + goto out; + + demarshal_dhcp4_options (NM_OBJECT (self), NULL, &value, &priv->options); + g_value_unset (&value); + +out: + return priv->options; +} + +/** + * nm_dhcp4_config_get_one_option: + * @self: a #NMDHCP4Config + * @option: the option to retrieve + * + * Gets one option by option name. + * + * Returns: the configuration option's value. This is the internal string used by the + * configuration, and must not be modified. + **/ +const char * +nm_dhcp4_config_get_one_option (NMDHCP4Config *self, const char *option) +{ + g_return_val_if_fail (NM_IS_DHCP4_CONFIG (self), NULL); + + return g_hash_table_lookup (nm_dhcp4_config_get_options (self), option); +} + diff --git a/libnm-glib/nm-dhcp4-config.h b/libnm-glib/nm-dhcp4-config.h new file mode 100644 index 0000000000..496dedd11c --- /dev/null +++ b/libnm-glib/nm-dhcp4-config.h @@ -0,0 +1,37 @@ +#ifndef NM_DHCP4_CONFIG_H +#define NM_DHCP4_CONFIG_H + +#include <glib/gtypes.h> +#include <glib-object.h> +#include <dbus/dbus-glib.h> +#include "nm-object.h" + +G_BEGIN_DECLS + +#define NM_TYPE_DHCP4_CONFIG (nm_dhcp4_config_get_type ()) +#define NM_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP4_CONFIG, NMDHCP4Config)) +#define NM_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP4_CONFIG, NMDHCP4ConfigClass)) +#define NM_IS_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP4_CONFIG)) +#define NM_IS_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_DHCP4_CONFIG)) + +typedef struct { + NMObject parent; +} NMDHCP4Config; + +typedef struct { + NMObjectClass parent; +} NMDHCP4ConfigClass; + +#define NM_DHCP4_CONFIG_OPTIONS "options" + +GType nm_dhcp4_config_get_type (void); + +GObject *nm_dhcp4_config_new (DBusGConnection *connection, const char *object_path); + +GHashTable * nm_dhcp4_config_get_options (NMDHCP4Config *config); + +const char * nm_dhcp4_config_get_one_option (NMDHCP4Config *config, const char *option); + +G_END_DECLS + +#endif /* NM_DHCP4_CONFIG_H */ diff --git a/libnm-glib/nm-gsm-device.c b/libnm-glib/nm-gsm-device.c index c3c28f46db..7db338c8a7 100644 --- a/libnm-glib/nm-gsm-device.c +++ b/libnm-glib/nm-gsm-device.c @@ -87,6 +87,15 @@ nm_gsm_device_class_init (NMGsmDeviceClass *device_class) object_class->dispose = dispose; } +/** + * nm_gsm_device_new: + * @connection: the #DBusGConnection + * @path: the DBus object path of the device + * + * Creates a new #NMGsmDevice. + * + * Returns: a new device + **/ NMGsmDevice * nm_gsm_device_new (DBusGConnection *connection, const char *path) { diff --git a/libnm-glib/nm-ip4-config.c b/libnm-glib/nm-ip4-config.c index 1382378d35..dac3085eaa 100644 --- a/libnm-glib/nm-ip4-config.c +++ b/libnm-glib/nm-ip4-config.c @@ -17,8 +17,6 @@ typedef struct { char *hostname; GArray *nameservers; GPtrArray *domains; - char *nis_domain; - GArray *nis_servers; GSList *routes; } NMIP4ConfigPrivate; @@ -28,8 +26,6 @@ enum { PROP_HOSTNAME, PROP_NAMESERVERS, PROP_DOMAINS, - PROP_NIS_DOMAIN, - PROP_NIS_SERVERS, PROP_ROUTES, LAST_PROP @@ -63,8 +59,6 @@ demarshal_ip4_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointe if (!strcmp (pspec->name, NM_IP4_CONFIG_NAMESERVERS)) nm_object_queue_notify (object, NM_IP4_CONFIG_NAMESERVERS); - else if (!strcmp (pspec->name, NM_IP4_CONFIG_NIS_SERVERS)) - nm_object_queue_notify (object, NM_IP4_CONFIG_NAMESERVERS); return TRUE; } @@ -102,8 +96,6 @@ register_for_property_changed (NMIP4Config *config) { NM_IP4_CONFIG_HOSTNAME, nm_object_demarshal_generic, &priv->hostname }, { NM_IP4_CONFIG_NAMESERVERS, demarshal_ip4_array, &priv->nameservers }, { NM_IP4_CONFIG_DOMAINS, demarshal_domains, &priv->domains }, - { NM_IP4_CONFIG_NIS_DOMAIN, nm_object_demarshal_generic, &priv->nis_domain }, - { NM_IP4_CONFIG_NIS_SERVERS, demarshal_ip4_array, &priv->nis_servers }, { NM_IP4_CONFIG_ROUTES, demarshal_ip4_routes_array, &priv->routes }, { NULL }, }; @@ -153,11 +145,8 @@ finalize (GObject *object) g_slist_free (priv->routes); g_free (priv->hostname); - g_free (priv->nis_domain); if (priv->nameservers) g_array_free (priv->nameservers, TRUE); - if (priv->nis_servers) - g_array_free (priv->nis_servers, TRUE); if (priv->domains) { g_ptr_array_foreach (priv->domains, (GFunc) g_free, NULL); @@ -189,12 +178,6 @@ get_property (GObject *object, case PROP_DOMAINS: g_value_set_boxed (value, nm_ip4_config_get_domains (self)); break; - case PROP_NIS_DOMAIN: - g_value_set_string (value, nm_ip4_config_get_nis_domain (self)); - break; - case PROP_NIS_SERVERS: - g_value_set_boxed (value, nm_ip4_config_get_nis_servers (self)); - break; case PROP_ROUTES: nm_utils_ip4_routes_to_gvalue (priv->routes, value); break; @@ -217,6 +200,12 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) object_class->finalize = finalize; /* properties */ + + /** + * NMIP4Config:addresses: + * + * The #GPtrArray containing #NMSettingIP4Address<!-- -->es of the configuration. + **/ g_object_class_install_property (object_class, PROP_ADDRESSES, g_param_spec_pointer (NM_IP4_CONFIG_ADDRESSES, @@ -224,6 +213,11 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) "Addresses", G_PARAM_READABLE)); + /** + * NMIP4Config:hostname: + * + * The host name string of the configuration. + **/ g_object_class_install_property (object_class, PROP_HOSTNAME, g_param_spec_string (NM_IP4_CONFIG_HOSTNAME, @@ -232,6 +226,11 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) NULL, G_PARAM_READABLE)); + /** + * NMIP4Config:nameservers: + * + * The #GArray containing name servers (%guint32<!-- -->es) of the configuration. + **/ g_object_class_install_property (object_class, PROP_NAMESERVERS, g_param_spec_boxed (NM_IP4_CONFIG_NAMESERVERS, @@ -240,6 +239,11 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) NM_TYPE_UINT_ARRAY, G_PARAM_READABLE)); + /** + * NMIP4Config:domains: + * + * The #GPtrArray containing domain strings of the configuration. + **/ g_object_class_install_property (object_class, PROP_DOMAINS, g_param_spec_boxed (NM_IP4_CONFIG_DOMAINS, @@ -248,22 +252,11 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) NM_TYPE_STRING_ARRAY, G_PARAM_READABLE)); - g_object_class_install_property - (object_class, PROP_NIS_DOMAIN, - g_param_spec_string (NM_IP4_CONFIG_NIS_DOMAIN, - "NIS domain", - "NIS domain", - NULL, - G_PARAM_READABLE)); - - g_object_class_install_property - (object_class, PROP_NIS_SERVERS, - g_param_spec_boxed (NM_IP4_CONFIG_NIS_SERVERS, - "NIS servers", - "NIS servers", - NM_TYPE_UINT_ARRAY, - G_PARAM_READABLE)); - + /** + * NMIP4Config:routes: + * + * The #GPtrArray containing #NMSettingIP4Route<!-- -->s of the configuration. + **/ g_object_class_install_property (object_class, PROP_ROUTES, g_param_spec_pointer (NM_IP4_CONFIG_ROUTES, @@ -272,6 +265,15 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) G_PARAM_READABLE)); } +/** + * nm_ip4_config_new: + * @connection: the #DBusGConnection + * @object_path: the DBus object path of the device + * + * Creates a new #NMIP4Config. + * + * Returns: a new IP4 configuration + **/ GObject * nm_ip4_config_new (DBusGConnection *connection, const char *object_path) { @@ -281,6 +283,15 @@ nm_ip4_config_new (DBusGConnection *connection, const char *object_path) NULL); } +/** + * nm_ip4_config_get_addresses: + * @config: a #NMIP4Config + * + * Gets the IP4 addresses (containing the address, prefix, and gateway). + * + * Returns: the #GSList containing #NMSettingIP4Address<!-- -->es. This is the internal copy + * used by the configuration and must not be modified. + **/ const GSList * nm_ip4_config_get_addresses (NMIP4Config *config) { @@ -306,6 +317,15 @@ nm_ip4_config_get_addresses (NMIP4Config *config) return priv->addresses; } +/** + * nm_ip4_config_get_hostname: + * @config: a #NMIP4Config + * + * Gets the host name. + * + * Returns: the host name from the configuration. This is the internal copy used by the + * configuration and must not be modified. + **/ const char * nm_ip4_config_get_hostname (NMIP4Config *config) { @@ -323,6 +343,15 @@ nm_ip4_config_get_hostname (NMIP4Config *config) return priv->hostname; } +/** + * nm_ip4_config_get_nameservers: + * @config: a #NMIP4Config + * + * Gets the domain name servers (DNS). + * + * Returns: the #GArray containing %guint32<!-- -->s. This is the internal copy used by the + * configuration and must not be modified. + **/ const GArray * nm_ip4_config_get_nameservers (NMIP4Config *config) { @@ -349,7 +378,15 @@ nm_ip4_config_get_nameservers (NMIP4Config *config) return priv->nameservers; } - +/** + * nm_ip4_config_get_domains: + * @config: a #NMIP4Config + * + * Gets the domain names. + * + * Returns: the #GPtrArray containing domains as strings. This is the + * internal copy used by the configuration, and must not be modified. + **/ const GPtrArray * nm_ip4_config_get_domains (NMIP4Config *config) { @@ -380,50 +417,15 @@ nm_ip4_config_get_domains (NMIP4Config *config) return handle_ptr_array_return (priv->domains); } -const char * -nm_ip4_config_get_nis_domain (NMIP4Config *config) -{ - NMIP4ConfigPrivate *priv; - - g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); - - priv = NM_IP4_CONFIG_GET_PRIVATE (config); - if (!priv->nis_domain) { - priv->nis_domain = nm_object_get_string_property (NM_OBJECT (config), - NM_DBUS_INTERFACE_IP4_CONFIG, - "NisDomain"); - } - - return priv->nis_domain; -} - -const GArray * -nm_ip4_config_get_nis_servers (NMIP4Config *config) -{ - NMIP4ConfigPrivate *priv; - GArray *array = NULL; - GValue value = {0,}; - - g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); - - priv = NM_IP4_CONFIG_GET_PRIVATE (config); - if (!priv->nis_servers) { - if (nm_object_get_property (NM_OBJECT (config), - NM_DBUS_INTERFACE_IP4_CONFIG, - "NisServers", - &value)) { - array = (GArray *) g_value_get_boxed (&value); - if (array && array->len) { - priv->nis_servers = g_array_sized_new (FALSE, TRUE, sizeof (guint32), array->len); - g_array_append_vals (priv->nis_servers, array->data, array->len); - } - g_value_unset (&value); - } - } - - return priv->nis_servers; -} - +/** + * nm_ip4_config_get_routes: + * @config: a #NMIP4Config + * + * Gets the routes. + * + * Returns: the #GSList containing #NMSettingIP4Route<!-- -->s. This is the + * internal copy used by the configuration, and must not be modified. + **/ const GSList * nm_ip4_config_get_routes (NMIP4Config *config) { diff --git a/libnm-glib/nm-ip4-config.h b/libnm-glib/nm-ip4-config.h index 79de2f8496..10ff688544 100644 --- a/libnm-glib/nm-ip4-config.h +++ b/libnm-glib/nm-ip4-config.h @@ -27,8 +27,6 @@ typedef struct { #define NM_IP4_CONFIG_HOSTNAME "hostname" #define NM_IP4_CONFIG_NAMESERVERS "nameservers" #define NM_IP4_CONFIG_DOMAINS "domains" -#define NM_IP4_CONFIG_NIS_DOMAIN "nis-domain" -#define NM_IP4_CONFIG_NIS_SERVERS "nis-servers" #define NM_IP4_CONFIG_ROUTES "routes" GType nm_ip4_config_get_type (void); @@ -39,8 +37,6 @@ const GSList * nm_ip4_config_get_addresses (NMIP4Config *config); const char * nm_ip4_config_get_hostname (NMIP4Config *config); const GArray * nm_ip4_config_get_nameservers (NMIP4Config *config); const GPtrArray *nm_ip4_config_get_domains (NMIP4Config *config); -const char * nm_ip4_config_get_nis_domain (NMIP4Config *config); -const GArray * nm_ip4_config_get_nis_servers (NMIP4Config *config); const GSList * nm_ip4_config_get_routes (NMIP4Config *config); G_END_DECLS diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index 9472f25280..b981306ed2 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -168,6 +168,12 @@ nm_object_class_init (NMObjectClass *nm_object_class) object_class->finalize = finalize; /* porperties */ + + /** + * NMObject:connection: + * + * The #DBusGConnection of the object. + **/ g_object_class_install_property (object_class, PROP_CONNECTION, g_param_spec_boxed (NM_OBJECT_DBUS_CONNECTION, @@ -176,6 +182,11 @@ nm_object_class_init (NMObjectClass *nm_object_class) DBUS_TYPE_G_CONNECTION, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + /** + * NMObject:path: + * + * The DBus object path. + **/ g_object_class_install_property (object_class, PROP_PATH, g_param_spec_string (NM_OBJECT_DBUS_PATH, @@ -185,6 +196,14 @@ nm_object_class_init (NMObjectClass *nm_object_class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } +/** + * nm_object_get_connection: + * @object: a #NMObject + * + * Gets the #NMObject's DBusGConnection. + * + * Returns: the connection + **/ DBusGConnection * nm_object_get_connection (NMObject *object) { @@ -193,6 +212,15 @@ nm_object_get_connection (NMObject *object) return NM_OBJECT_GET_PRIVATE (object)->connection; } +/** + * nm_object_get_path: + * @object: a #NMObject + * + * Gets the DBus path of the #NMObject. + * + * Returns: the object's path. This is the internal string used by the + * device, and must not be modified. + **/ const char * nm_object_get_path (NMObject *object) { diff --git a/libnm-glib/nm-serial-device.c b/libnm-glib/nm-serial-device.c index 65815d9cf8..2baf1a2751 100644 --- a/libnm-glib/nm-serial-device.c +++ b/libnm-glib/nm-serial-device.c @@ -26,6 +26,15 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +/** + * nm_serial_device_get_bytes_received: + * @self: a #NMSerialDevice + * + * Gets the amount of bytes received by the serial device. + * This counter is reset when the device is activated. + * + * Returns: bytes received + **/ guint32 nm_serial_device_get_bytes_received (NMSerialDevice *self) { @@ -34,6 +43,15 @@ nm_serial_device_get_bytes_received (NMSerialDevice *self) return NM_SERIAL_DEVICE_GET_PRIVATE (self)->in_bytes; } +/** + * nm_serial_device_get_bytes_sent: + * @self: a #NMSerialDevice + * + * Gets the amount of bytes sent by the serial device. + * This counter is reset when the device is activated. + * + * Returns: bytes sent + **/ guint32 nm_serial_device_get_bytes_sent (NMSerialDevice *self) { @@ -148,6 +166,15 @@ nm_serial_device_class_init (NMSerialDeviceClass *device_class) object_class->dispose = dispose; /* Signals */ + + /** + * NMSerialDevice::ppp-stats: + * @device: the serial device that received the signal + * @in_bytes: the amount of bytes received + * @out_bytes: the amount of bytes sent + * + * Notifies that a #NMAccessPoint is added to the wifi device. + **/ signals[PPP_STATS] = g_signal_new ("ppp-stats", G_OBJECT_CLASS_TYPE (object_class), diff --git a/libnm-glib/nm-settings.c b/libnm-glib/nm-settings.c index 303f93cfc5..3ac5b63340 100644 --- a/libnm-glib/nm-settings.c +++ b/libnm-glib/nm-settings.c @@ -7,6 +7,13 @@ #include "nm-dbus-glib-types.h" +/** + * nm_settings_error_quark: + * + * Setting error quark. + * + * Returns: the setting error quark + **/ GQuark nm_settings_error_quark (void) { @@ -80,6 +87,14 @@ nm_settings_class_init (NMSettingsClass *settings_class) settings_class->list_connections = NULL; /* signals */ + + /** + * NMSettings::new-connection: + * @setting: the setting that received the signal + * @connection: the new #NMExportedConnection + * + * Notifies that a new exported connection is added. + **/ settings_signals[S_NEW_CONNECTION] = g_signal_new ("new-connection", G_OBJECT_CLASS_TYPE (object_class), @@ -94,6 +109,14 @@ nm_settings_class_init (NMSettingsClass *settings_class) &dbus_glib_nm_settings_object_info); } +/** + * nm_settings_list_connections: + * @settings: + * + * Lists all the available connections. + * + * Returns: the #GSList containing #NMExportedConnection<!-- -->s + **/ GSList * nm_settings_list_connections (NMSettings *settings) { diff --git a/libnm-glib/nm-vpn-plugin.c b/libnm-glib/nm-vpn-plugin.c index 05e7bf3e8e..3ebd2fc17d 100644 --- a/libnm-glib/nm-vpn-plugin.c +++ b/libnm-glib/nm-vpn-plugin.c @@ -46,6 +46,7 @@ typedef struct { /* Temporary stuff */ guint connect_timer; guint quit_timer; + guint fail_stop_id; } NMVPNPluginPrivate; #define NM_VPN_PLUGIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_VPN_PLUGIN, NMVPNPluginPrivate)) @@ -257,10 +258,20 @@ quit_timer_expired (gpointer data) } static gboolean +fail_stop (gpointer data) +{ + NMVPNPlugin *plugin = NM_VPN_PLUGIN (data); + + nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPED); + return FALSE; +} + +static gboolean nm_vpn_plugin_connect (NMVPNPlugin *plugin, NMConnection *connection, GError **err) { + NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin); gboolean ret = FALSE; NMVPNServiceState state; @@ -293,8 +304,14 @@ nm_vpn_plugin_connect (NMVPNPlugin *plugin, case NM_VPN_SERVICE_STATE_INIT: nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STARTING); ret = NM_VPN_PLUGIN_GET_CLASS (plugin)->connect (plugin, connection, err); - if (!ret) - nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPED); + if (!ret) { + /* Stop the plugin from and idle handler so that the Connect + * method return gets sent before the STOP StateChanged signal. + */ + if (priv->fail_stop_id) + g_source_remove (priv->fail_stop_id); + priv->fail_stop_id = g_idle_add (fail_stop, plugin); + } break; default: @@ -584,6 +601,9 @@ dispose (GObject *object) priv->disposed = TRUE; + if (priv->fail_stop_id) + g_source_remove (priv->fail_stop_id); + state = nm_vpn_plugin_get_state (plugin); if (state == NM_VPN_SERVICE_STATE_STARTED || @@ -633,6 +653,11 @@ state_changed (NMVPNPlugin *plugin, NMVPNServiceState state) if (priv->quit_timer) g_source_remove (priv->quit_timer); + if (priv->fail_stop_id) { + g_source_remove (priv->fail_stop_id); + priv->fail_stop_id = 0; + } + /* Add a timer to make sure we do not wait indefinitely for the successful connect. */ priv->connect_timer = g_timeout_add_full (G_PRIORITY_DEFAULT, NM_VPN_PLUGIN_CONNECT_TIMER, @@ -655,6 +680,10 @@ state_changed (NMVPNPlugin *plugin, NMVPNServiceState state) if (priv->quit_timer) g_source_remove (priv->quit_timer); + if (priv->fail_stop_id) { + g_source_remove (priv->fail_stop_id); + priv->fail_stop_id = 0; + } break; } } |