From: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
Subject: Explicitly set the default interval for connectivity checking

This matches what is documented in the man page; 300 seconds as the default
value for the connectivity checking interval if it's not set in the config
file or passed as a command-line parameter.

---
 include/NetworkManager.h |    2 ++
 src/nm-config.c          |   16 ++++++++++++++--
 src/nm-connectivity.c    |    3 ++-
 3 files changed, 18 insertions(+), 3 deletions(-)

Index: b/src/nm-config.c
===================================================================
--- a/src/nm-config.c
+++ b/src/nm-config.c
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <stdio.h>
 
+#include "NetworkManager.h"
 #include "nm-config.h"
 
 #define NM_DEFAULT_SYSTEM_CONF_FILE  NMCONFDIR "/NetworkManager.conf"
@@ -140,6 +141,8 @@ fill_from_file (NMConfig *config,
 {
 	GKeyFile *kf;
 	gboolean success = FALSE;
+	int value;
+	GError *err;
 
 	if (g_file_test (path, G_FILE_TEST_EXISTS) == FALSE) {
 		g_set_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND, "file %s not found", path);
@@ -183,8 +186,17 @@ fill_from_file (NMConfig *config,
 
 		if (cli_connectivity_interval >= 0)
 			config->connectivity_interval = cli_connectivity_interval;
-		else
-			config->connectivity_interval = g_key_file_get_integer (kf, "connectivity", "interval", NULL);
+		else {
+			value = g_key_file_get_integer (kf, "connectivity", "interval", &err);
+			if (!err)
+				config->connectivity_interval = value;
+			else {
+				/* Using a default value here, which isn't a problem if connectivity
+				 * isn't set up, as uri would be NULL.
+				 */
+				config->connectivity_interval = NM_CONNECTIVITY_DEFAULT_INTERVAL;
+			}
+		}
 
 		if (cli_connectivity_response && strlen (cli_connectivity_response))
 			config->connectivity_response = g_strdup (cli_connectivity_response);
Index: b/src/nm-connectivity.c
===================================================================
--- a/src/nm-connectivity.c
+++ b/src/nm-connectivity.c
@@ -26,6 +26,7 @@
 #include <libsoup/soup.h>
 #endif
 
+#include "NetworkManager.h"
 #include "nm-connectivity.h"
 #include "nm-logging.h"
 #include "nm-manager.h"
@@ -390,7 +391,7 @@ nm_connectivity_class_init (NMConnectivi
 		 g_param_spec_uint (NM_CONNECTIVITY_INTERVAL,
 		                    "Interval",
 		                    "Connectivity check interval in seconds",
-		                    0, G_MAXUINT, 300,
+		                    0, G_MAXUINT, NM_CONNECTIVITY_DEFAULT_INTERVAL,
 		                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
 	g_object_class_install_property
Index: b/include/NetworkManager.h
===================================================================
--- a/include/NetworkManager.h
+++ b/include/NetworkManager.h
@@ -68,6 +68,8 @@
 #define NM_DBUS_INTERFACE_SECRET_AGENT    NM_DBUS_INTERFACE ".SecretAgent"
 #define NM_DBUS_PATH_SECRET_AGENT         "/org/freedesktop/NetworkManager/SecretAgent"
 
+#define NM_CONNECTIVITY_DEFAULT_INTERVAL	300
+
 /**
  * NMState:
  * @NM_STATE_UNKNOWN: networking state is unknown
