diff options
-rw-r--r-- | libnm/nm-client.c | 93 | ||||
-rw-r--r-- | libnm/nm-client.h | 10 | ||||
-rw-r--r-- | libnm/nm-manager.c | 59 | ||||
-rw-r--r-- | libnm/nm-manager.h | 7 |
4 files changed, 168 insertions, 1 deletions
diff --git a/libnm/nm-client.c b/libnm/nm-client.c index c8ce2d6ec..7f4bfd67a 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -123,6 +123,8 @@ enum { PROP_WIMAX_HARDWARE_ENABLED, PROP_ACTIVE_CONNECTIONS, PROP_CONNECTIVITY, + PROP_CONNECTIVITY_CHECK_AVAILABLE, + PROP_CONNECTIVITY_CHECK_ENABLED, PROP_PRIMARY_CONNECTION, PROP_ACTIVATING_CONNECTION, PROP_DEVICES, @@ -474,6 +476,66 @@ nm_client_wimax_hardware_get_enabled (NMClient *client) } /** + * nm_client_connectivity_check_get_available: + * @client: a #NMClient + * + * Determine whether connectivity checking is available. This + * requires that the URI of a connectivity service has been set in the + * configuration file. + * + * Returns: %TRUE if connectivity checking is available. + */ +gboolean +nm_client_connectivity_check_get_available (NMClient *client) +{ + g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); + + if (!nm_client_get_nm_running (client)) + return FALSE; + + return nm_manager_connectivity_check_get_available (NM_CLIENT_GET_PRIVATE (client)->manager); +} + +/** + * nm_client_connectivity_check_get_enabled: + * @client: a #NMClient + * + * Determine whether connectivity checking is enabled. + * + * Returns: %TRUE if connectivity checking is enabled. + */ +gboolean +nm_client_connectivity_check_get_enabled (NMClient *client) +{ + g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); + + if (!nm_client_get_nm_running (client)) + return FALSE; + + return nm_manager_connectivity_check_get_enabled (NM_CLIENT_GET_PRIVATE (client)->manager); +} + +/** + * nm_client_connectivity_check_set_enabled: + * @client: a #NMClient + * @enabled: %TRUE to enable connectivity checking + * + * Enable or disable connectivity checking. Note that if a + * connectivity checking URI has not been configured, this will not + * have any effect. + */ +void +nm_client_connectivity_check_set_enabled (NMClient *client, gboolean enabled) +{ + g_return_if_fail (NM_IS_CLIENT (client)); + + if (!nm_client_get_nm_running (client)) + return; + + nm_manager_connectivity_check_set_enabled (NM_CLIENT_GET_PRIVATE (client)->manager, enabled); +} + +/** * nm_client_get_logging: * @client: a #NMClient * @level: (allow-none): return location for logging level string @@ -2593,6 +2655,7 @@ set_property (GObject *object, guint prop_id, case PROP_WIRELESS_ENABLED: case PROP_WWAN_ENABLED: case PROP_WIMAX_ENABLED: + case PROP_CONNECTIVITY_CHECK_ENABLED: if (priv->manager) g_object_set_property (G_OBJECT (priv->manager), pspec->name, value); break; @@ -2660,6 +2723,12 @@ get_property (GObject *object, guint prop_id, case PROP_CONNECTIVITY: g_value_set_enum (value, nm_client_get_connectivity (self)); break; + case PROP_CONNECTIVITY_CHECK_AVAILABLE: + g_value_set_boolean (value, nm_client_connectivity_check_get_available (self)); + break; + case PROP_CONNECTIVITY_CHECK_ENABLED: + g_value_set_boolean (value, nm_client_connectivity_check_get_enabled (self)); + break; case PROP_PRIMARY_CONNECTION: g_value_set_object (value, nm_client_get_primary_connection (self)); break; @@ -2898,6 +2967,30 @@ nm_client_class_init (NMClientClass *client_class) G_PARAM_STATIC_STRINGS)); /** + * NMClient::connectivity-check-available + * + * Whether a connectivity checking service has been configured. + */ + g_object_class_install_property + (object_class, PROP_CONNECTIVITY_CHECK_AVAILABLE, + g_param_spec_boolean (NM_CLIENT_CONNECTIVITY_CHECK_AVAILABLE, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + /** + * NMClient::connectivity-check-enabled + * + * Whether a connectivity checking service has been enabled. + */ + g_object_class_install_property + (object_class, PROP_CONNECTIVITY_CHECK_ENABLED, + g_param_spec_boolean (NM_CLIENT_CONNECTIVITY_CHECK_ENABLED, "", "", + FALSE, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + + /** * NMClient:primary-connection: * * The #NMActiveConnection of the device with the default route; diff --git a/libnm/nm-client.h b/libnm/nm-client.h index 5da16490e..75b49ceb5 100644 --- a/libnm/nm-client.h +++ b/libnm/nm-client.h @@ -50,6 +50,8 @@ G_BEGIN_DECLS #define NM_CLIENT_WIMAX_HARDWARE_ENABLED "wimax-hardware-enabled" #define NM_CLIENT_ACTIVE_CONNECTIONS "active-connections" #define NM_CLIENT_CONNECTIVITY "connectivity" +#define NM_CLIENT_CONNECTIVITY_CHECK_AVAILABLE "connectivity-check-available" +#define NM_CLIENT_CONNECTIVITY_CHECK_ENABLED "connectivity-check-enabled" #define NM_CLIENT_PRIMARY_CONNECTION "primary-connection" #define NM_CLIENT_ACTIVATING_CONNECTION "activating-connection" #define NM_CLIENT_DEVICES "devices" @@ -125,8 +127,9 @@ typedef enum { NM_CLIENT_PERMISSION_RELOAD = 13, NM_CLIENT_PERMISSION_CHECKPOINT_ROLLBACK = 14, NM_CLIENT_PERMISSION_ENABLE_DISABLE_STATISTICS = 15, + NM_CLIENT_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK = 16, - NM_CLIENT_PERMISSION_LAST = 15, + NM_CLIENT_PERMISSION_LAST = 16, } NMClientPermission; /** @@ -249,6 +252,11 @@ gboolean nm_client_wimax_get_enabled (NMClient *client); void nm_client_wimax_set_enabled (NMClient *client, gboolean enabled); gboolean nm_client_wimax_hardware_get_enabled (NMClient *client); +gboolean nm_client_connectivity_check_get_available (NMClient *client); +gboolean nm_client_connectivity_check_get_enabled (NMClient *client); +void nm_client_connectivity_check_set_enabled (NMClient *client, + gboolean enabled); + gboolean nm_client_get_logging (NMClient *client, char **level, char **domains, diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index 095b83d6e..004c5c9c9 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -83,6 +83,9 @@ typedef struct { gboolean wimax_enabled; gboolean wimax_hw_enabled; + + gboolean connectivity_check_available; + gboolean connectivity_check_enabled; } NMManagerPrivate; enum { @@ -99,6 +102,8 @@ enum { PROP_WIMAX_HARDWARE_ENABLED, PROP_ACTIVE_CONNECTIONS, PROP_CONNECTIVITY, + PROP_CONNECTIVITY_CHECK_AVAILABLE, + PROP_CONNECTIVITY_CHECK_ENABLED, PROP_PRIMARY_CONNECTION, PROP_ACTIVATING_CONNECTION, PROP_DEVICES, @@ -179,6 +184,8 @@ init_dbus (NMObject *object) { NM_MANAGER_WIMAX_HARDWARE_ENABLED, &priv->wimax_hw_enabled }, { NM_MANAGER_ACTIVE_CONNECTIONS, &priv->active_connections, NULL, NM_TYPE_ACTIVE_CONNECTION, "active-connection" }, { NM_MANAGER_CONNECTIVITY, &priv->connectivity }, + { NM_MANAGER_CONNECTIVITY_CHECK_AVAILABLE, &priv->connectivity_check_available }, + { NM_MANAGER_CONNECTIVITY_CHECK_ENABLED, &priv->connectivity_check_enabled }, { NM_MANAGER_PRIMARY_CONNECTION, &priv->primary_connection, NULL, NM_TYPE_ACTIVE_CONNECTION }, { NM_MANAGER_ACTIVATING_CONNECTION, &priv->activating_connection, NULL, NM_TYPE_ACTIVE_CONNECTION }, { NM_MANAGER_DEVICES, &priv->devices, NULL, NM_TYPE_DEVICE, "device" }, @@ -232,6 +239,8 @@ nm_permission_to_client (const char *nm) return NM_CLIENT_PERMISSION_CHECKPOINT_ROLLBACK; else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_STATISTICS)) return NM_CLIENT_PERMISSION_ENABLE_DISABLE_STATISTICS; + else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK)) + return NM_CLIENT_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK; return NM_CLIENT_PERMISSION_NONE; } @@ -502,6 +511,31 @@ nm_manager_wimax_hardware_get_enabled (NMManager *manager) } gboolean +nm_manager_connectivity_check_get_available (NMManager *manager) +{ + g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE); + + return NM_MANAGER_GET_PRIVATE (manager)->connectivity_check_available; +} + +gboolean +nm_manager_connectivity_check_get_enabled (NMManager *manager) +{ + return NM_MANAGER_GET_PRIVATE (manager)->connectivity_check_enabled; +} + +void +nm_manager_connectivity_check_set_enabled (NMManager *manager, gboolean enabled) +{ + g_return_if_fail (NM_IS_MANAGER (manager)); + + _nm_object_set_property (NM_OBJECT (manager), + NM_DBUS_INTERFACE, + "ConnectivityCheckEnabled", + "b", enabled); +} + +gboolean nm_manager_get_logging (NMManager *manager, char **level, char **domains, GError **error) { gboolean ret; @@ -1350,6 +1384,13 @@ set_property (GObject *object, guint prop_id, /* Let the property value flip when we get the change signal from NM */ } break; + case PROP_CONNECTIVITY_CHECK_ENABLED: + b = g_value_get_boolean (value); + if (priv->connectivity_check_enabled != b) { + nm_manager_connectivity_check_set_enabled (NM_MANAGER (object), b); + /* Let the property value flip when we get the change signal from NM */ + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1402,6 +1443,12 @@ get_property (GObject *object, case PROP_CONNECTIVITY: g_value_set_enum (value, priv->connectivity); break; + case PROP_CONNECTIVITY_CHECK_AVAILABLE: + g_value_set_boolean (value, priv->connectivity_check_available); + break; + case PROP_CONNECTIVITY_CHECK_ENABLED: + g_value_set_boolean (value, priv->connectivity_check_enabled); + break; case PROP_PRIMARY_CONNECTION: g_value_set_object (value, priv->primary_connection); break; @@ -1522,6 +1569,18 @@ nm_manager_class_init (NMManagerClass *manager_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property + (object_class, PROP_CONNECTIVITY_CHECK_AVAILABLE, + g_param_spec_boolean (NM_MANAGER_CONNECTIVITY_CHECK_AVAILABLE, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + g_object_class_install_property + (object_class, PROP_CONNECTIVITY_CHECK_ENABLED, + g_param_spec_boolean (NM_MANAGER_CONNECTIVITY_CHECK_ENABLED, "", "", + FALSE, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, PROP_PRIMARY_CONNECTION, g_param_spec_object (NM_MANAGER_PRIMARY_CONNECTION, "", "", NM_TYPE_ACTIVE_CONNECTION, diff --git a/libnm/nm-manager.h b/libnm/nm-manager.h index 7c63a3335..9a2439093 100644 --- a/libnm/nm-manager.h +++ b/libnm/nm-manager.h @@ -46,6 +46,8 @@ G_BEGIN_DECLS #define NM_MANAGER_WIMAX_HARDWARE_ENABLED "wimax-hardware-enabled" #define NM_MANAGER_ACTIVE_CONNECTIONS "active-connections" #define NM_MANAGER_CONNECTIVITY "connectivity" +#define NM_MANAGER_CONNECTIVITY_CHECK_AVAILABLE "connectivity-check-available" +#define NM_MANAGER_CONNECTIVITY_CHECK_ENABLED "connectivity-check-enabled" #define NM_MANAGER_PRIMARY_CONNECTION "primary-connection" #define NM_MANAGER_ACTIVATING_CONNECTION "activating-connection" #define NM_MANAGER_DEVICES "devices" @@ -97,6 +99,11 @@ gboolean nm_manager_wimax_get_enabled (NMManager *manager); void nm_manager_wimax_set_enabled (NMManager *manager, gboolean enabled); gboolean nm_manager_wimax_hardware_get_enabled (NMManager *manager); +gboolean nm_manager_connectivity_check_get_available (NMManager *manager); +gboolean nm_manager_connectivity_check_get_enabled (NMManager *manager); +void nm_manager_connectivity_check_set_enabled (NMManager *manager, + gboolean enabled); + gboolean nm_manager_get_logging (NMManager *manager, char **level, char **domains, |