From: Daniel Wagner <[email protected]>

We need to change the behavior for the AutoConnect=true case
with sessions. The use case is that we have only sessions users.
When no session asks for a connection the system should stay idle.
Currently when the system is idle, ConnMan will attempt immedidatly
to auto connect. When sessions are used, we can defer this until
an user/application does a Session.Connect().

Unfortunatly AutoConnect can't be changed at this point (we would need
a tristate boolean) we add a global flag which allows to change
the behavior of the auto connect state machine.
---
 src/main.c    | 14 ++++++++++++++
 src/main.conf |  7 +++++++
 2 files changed, 21 insertions(+)

diff --git a/src/main.c b/src/main.c
index e795b52..fe2b1d2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -63,6 +63,7 @@ static struct {
        bool bg_scan;
        char **pref_timeservers;
        unsigned int *auto_connect;
+       bool session_auto_connect_mode;
        unsigned int *preferred_techs;
        char **fallback_nameservers;
        unsigned int timeout_inputreq;
@@ -76,6 +77,7 @@ static struct {
        .bg_scan = true,
        .pref_timeservers = NULL,
        .auto_connect = NULL,
+       .session_auto_connect_mode = false,
        .preferred_techs = NULL,
        .fallback_nameservers = NULL,
        .timeout_inputreq = DEFAULT_INPUT_REQUEST_TIMEOUT,
@@ -90,6 +92,7 @@ static struct {
 #define CONF_BG_SCAN                    "BackgroundScanning"
 #define CONF_PREF_TIMESERVERS           "FallbackTimeservers"
 #define CONF_AUTO_CONNECT               "DefaultAutoConnectTechnologies"
+#define CONF_SESSION_AUTO_CONNECT       "SessionAutoConnectMode"
 #define CONF_PREFERRED_TECHS            "PreferredTechnologies"
 #define CONF_FALLBACK_NAMESERVERS       "FallbackNameservers"
 #define CONF_TIMEOUT_INPUTREQ           "InputRequestTimeout"
@@ -104,6 +107,7 @@ static const char *supported_options[] = {
        CONF_BG_SCAN,
        CONF_PREF_TIMESERVERS,
        CONF_AUTO_CONNECT,
+       CONF_SESSION_AUTO_CONNECT,
        CONF_PREFERRED_TECHS,
        CONF_FALLBACK_NAMESERVERS,
        CONF_TIMEOUT_INPUTREQ,
@@ -276,6 +280,13 @@ static void parse_config(GKeyFile *config)
 
        g_clear_error(&error);
 
+       boolean = g_key_file_get_boolean(config, "General",
+                                       CONF_SESSION_AUTO_CONNECT, &error);
+       if (!error)
+               connman_settings.session_auto_connect_mode = boolean;
+
+       g_clear_error(&error);
+
        str_list = __connman_config_get_string_list(config, "General",
                        CONF_PREFERRED_TECHS, &len, &error);
 
@@ -515,6 +526,9 @@ const char *connman_option_get_string(const char *key)
 
 bool connman_setting_get_bool(const char *key)
 {
+       if (g_str_equal(key, CONF_SESSION_AUTO_CONNECT))
+               return connman_settings.session_auto_connect_mode;
+
        if (g_str_equal(key, CONF_BG_SCAN))
                return connman_settings.bg_scan;
 
diff --git a/src/main.conf b/src/main.conf
index a2cac0e..de6bbe4 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -40,6 +40,13 @@
 # set up and saved to storage beforehand.
 # DefaultAutoConnectTechnologies =
 
+# Change the default behavior of AutoConnect.
+# A service will only auto connect when there is a session
+# requesting a connection. Use this flag only if you want
+# to use the Session API.
+# Default value is false.
+# SessionAutoConnectMode = false
+
 # List of preferred technologies from the most preferred
 # one to the least preferred one separated by commas ",".
 # Services of the listed technology type will be tried one
-- 
1.8.4.474.g128a96c

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to