summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Lane <iain.lane@canonical.com>2019-07-22 15:55:15 +0100
committerThomas Haller <thaller@redhat.com>2019-07-22 21:03:09 +0200
commit8f8a1990ce1955226ac51d8bb1927caad4561b4d (patch)
tree4e7a970e5876b286a7a081c111033988da228266
parentb621aba5c213734d6bf672340efea8576d026ccc (diff)
libnm,core: Add ConnectivityCheckUri property and accessors
So that applications like GNOME Shell can hit the same URI to show the captive portal login page. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/209
-rw-r--r--introspection/org.freedesktop.NetworkManager.xml7
-rw-r--r--libnm/libnm.ver1
-rw-r--r--libnm/nm-client.c22
-rw-r--r--libnm/nm-client.h3
-rw-r--r--libnm/nm-manager.c6
-rw-r--r--libnm/nm-manager.h2
-rw-r--r--src/nm-manager.c21
-rw-r--r--src/nm-manager.h1
8 files changed, 61 insertions, 2 deletions
diff --git a/introspection/org.freedesktop.NetworkManager.xml b/introspection/org.freedesktop.NetworkManager.xml
index efd866db4..bb48941b2 100644
--- a/introspection/org.freedesktop.NetworkManager.xml
+++ b/introspection/org.freedesktop.NetworkManager.xml
@@ -528,6 +528,13 @@
<property name="ConnectivityCheckEnabled" type="b" access="readwrite"/>
<!--
+ ConnectivityCheckUri:
+
+ The URI that NetworkManager will hit to check if there is internet connectivity.
+ -->
+ <property name="ConnectivityCheckUri" type="s" access="read"/>
+
+ <!--
GlobalDnsConfiguration:
Dictionary of global DNS settings where the key is one of "searches",
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 52999f188..7118bf2bc 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -1611,6 +1611,7 @@ global:
libnm_1_20_0 {
global:
+ nm_client_connectivity_check_get_uri;
nm_device_modem_get_apn;
nm_device_modem_get_device_id;
nm_device_modem_get_operator_code;
diff --git a/libnm/nm-client.c b/libnm/nm-client.c
index 2a46f82cb..a95540ed1 100644
--- a/libnm/nm-client.c
+++ b/libnm/nm-client.c
@@ -553,6 +553,28 @@ nm_client_connectivity_check_set_enabled (NMClient *client, gboolean enabled)
}
/**
+ * nm_client_connectivity_check_get_uri:
+ * @client: a #NMClient
+ *
+ * Get the URI that will be queried to determine if there is internet
+ * connectivity.
+ *
+ * Returns: (transfer none): the connectivity URI in use
+ *
+ * Since: 1.20
+ */
+const char *
+nm_client_connectivity_check_get_uri (NMClient *client)
+{
+ g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
+
+ if (!nm_client_get_nm_running (client))
+ return NULL;
+
+ return nm_manager_connectivity_check_get_uri (NM_CLIENT_GET_PRIVATE (client)->manager);
+}
+
+/**
* nm_client_get_logging:
* @client: a #NMClient
* @level: (allow-none): return location for logging level string
diff --git a/libnm/nm-client.h b/libnm/nm-client.h
index b1cbf7071..f3835864c 100644
--- a/libnm/nm-client.h
+++ b/libnm/nm-client.h
@@ -265,6 +265,9 @@ NM_AVAILABLE_IN_1_10
void nm_client_connectivity_check_set_enabled (NMClient *client,
gboolean enabled);
+NM_AVAILABLE_IN_1_20
+const char *nm_client_connectivity_check_get_uri (NMClient *client);
+
gboolean nm_client_get_logging (NMClient *client,
char **level,
char **domains,
diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c
index 5bf6ec178..eb788de2c 100644
--- a/libnm/nm-manager.c
+++ b/libnm/nm-manager.c
@@ -605,6 +605,12 @@ nm_manager_connectivity_check_set_enabled (NMManager *manager, gboolean enabled)
"b", enabled);
}
+const char *
+nm_manager_connectivity_check_get_uri (NMManager *manager)
+{
+ return nmdbus_manager_get_connectivity_check_uri (NM_MANAGER_GET_PRIVATE (manager)->proxy);
+}
+
gboolean
nm_manager_get_logging (NMManager *manager, char **level, char **domains, GError **error)
{
diff --git a/libnm/nm-manager.h b/libnm/nm-manager.h
index 6a6099be9..23f090167 100644
--- a/libnm/nm-manager.h
+++ b/libnm/nm-manager.h
@@ -108,6 +108,8 @@ gboolean nm_manager_connectivity_check_get_enabled (NMManager *manager);
void nm_manager_connectivity_check_set_enabled (NMManager *manager,
gboolean enabled);
+const char *nm_manager_connectivity_check_get_uri (NMManager *manager);
+
gboolean nm_manager_get_logging (NMManager *manager,
char **level,
char **domains,
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 605e04e23..93bfb1472 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -132,6 +132,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMManager,
PROP_CONNECTIVITY,
PROP_CONNECTIVITY_CHECK_AVAILABLE,
PROP_CONNECTIVITY_CHECK_ENABLED,
+ PROP_CONNECTIVITY_CHECK_URI,
PROP_PRIMARY_CONNECTION,
PROP_PRIMARY_CONNECTION_TYPE,
PROP_ACTIVATING_CONNECTION,
@@ -1129,8 +1130,13 @@ _config_changed_cb (NMConfig *config, NMConfigData *config_data, NMConfigChangeF
if (NM_FLAGS_HAS (changes, NM_CONFIG_CHANGE_GLOBAL_DNS_CONFIG))
_notify (self, PROP_GLOBAL_DNS_CONFIGURATION);
- if ((!nm_config_data_get_connectivity_uri (config_data)) != (!nm_config_data_get_connectivity_uri (old_data)))
- _notify (self, PROP_CONNECTIVITY_CHECK_AVAILABLE);
+
+ if (!nm_streq0 (nm_config_data_get_connectivity_uri (config_data),
+ nm_config_data_get_connectivity_uri (old_data))) {
+ if ((!nm_config_data_get_connectivity_uri (config_data)) != (!nm_config_data_get_connectivity_uri (old_data)))
+ _notify (self, PROP_CONNECTIVITY_CHECK_AVAILABLE);
+ _notify (self, PROP_CONNECTIVITY_CHECK_URI);
+ }
g_object_thaw_notify (G_OBJECT (self));
}
@@ -7542,6 +7548,10 @@ get_property (GObject *object, guint prop_id,
case PROP_CONNECTIVITY_CHECK_ENABLED:
g_value_set_boolean (value, concheck_enabled (self, NULL));
break;
+ case PROP_CONNECTIVITY_CHECK_URI:
+ config_data = nm_config_get_data (priv->config);
+ g_value_set_string (value, nm_config_data_get_connectivity_uri (config_data));
+ break;
case PROP_PRIMARY_CONNECTION:
nm_dbus_utils_g_value_set_object_path (value, priv->primary_connection);
break;
@@ -8038,6 +8048,7 @@ static const NMDBusInterfaceInfoExtended interface_info_manager = {
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Connectivity", "u", NM_MANAGER_CONNECTIVITY),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("ConnectivityCheckAvailable", "b", NM_MANAGER_CONNECTIVITY_CHECK_AVAILABLE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READWRITABLE_L ("ConnectivityCheckEnabled", "b", NM_MANAGER_CONNECTIVITY_CHECK_ENABLED, NM_AUTH_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK, NM_AUDIT_OP_NET_CONTROL),
+ NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("ConnectivityCheckUri", "s", NM_MANAGER_CONNECTIVITY_CHECK_URI),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READWRITABLE_L ("GlobalDnsConfiguration", "a{sv}", NM_MANAGER_GLOBAL_DNS_CONFIGURATION, NM_AUTH_PERMISSION_SETTINGS_MODIFY_GLOBAL_DNS, NM_AUDIT_OP_NET_CONTROL),
),
),
@@ -8150,6 +8161,12 @@ nm_manager_class_init (NMManagerClass *manager_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_CONNECTIVITY_CHECK_URI] =
+ g_param_spec_string (NM_MANAGER_CONNECTIVITY_CHECK_URI, "", "",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
+
obj_properties[PROP_PRIMARY_CONNECTION] =
g_param_spec_string (NM_MANAGER_PRIMARY_CONNECTION, "", "",
NULL,
diff --git a/src/nm-manager.h b/src/nm-manager.h
index 5cb6febc9..966abce08 100644
--- a/src/nm-manager.h
+++ b/src/nm-manager.h
@@ -47,6 +47,7 @@
#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_CONNECTIVITY_CHECK_URI "connectivity-check-uri"
#define NM_MANAGER_PRIMARY_CONNECTION "primary-connection"
#define NM_MANAGER_PRIMARY_CONNECTION_TYPE "primary-connection-type"
#define NM_MANAGER_ACTIVATING_CONNECTION "activating-connection"