diff options
-rw-r--r-- | doc/manager-api.txt | 7 | ||||
-rw-r--r-- | src/connman.h | 2 | ||||
-rw-r--r-- | src/manager.c | 30 | ||||
-rw-r--r-- | src/service.c | 5 | ||||
-rw-r--r-- | src/session.c | 20 |
5 files changed, 63 insertions, 1 deletions
diff --git a/doc/manager-api.txt b/doc/manager-api.txt index c92c2957..f07e185e 100644 --- a/doc/manager-api.txt +++ b/doc/manager-api.txt @@ -277,3 +277,10 @@ Properties string State [readonly] itself. It is just provided here for convenience of applications only dealing with the current active profile. + + boolean SessionMode [readwrite] + + This disables the auto connect feature. It should be + enabled when the Session API is used. + + The default value is false. diff --git a/src/connman.h b/src/connman.h index d5973407..4196127e 100644 --- a/src/connman.h +++ b/src/connman.h @@ -608,6 +608,8 @@ unsigned int __connman_rtnl_update_interval_remove(unsigned int interval); int __connman_rtnl_request_update(void); int __connman_rtnl_send(const void *buf, size_t len); +connman_bool_t __connman_session_mode(); +void __connman_session_set_mode(connman_bool_t enable); int __connman_session_release(const char *owner); struct connman_service *__connman_session_request(const char *bearer, const char *owner); int __connman_session_init(void); diff --git a/src/manager.c b/src/manager.c index 0a11f5da..198875da 100644 --- a/src/manager.c +++ b/src/manager.c @@ -32,7 +32,7 @@ static DBusMessage *get_properties(DBusConnection *conn, { DBusMessage *reply; DBusMessageIter array, dict; - connman_bool_t offlinemode; + connman_bool_t offlinemode, sessionmode; const char *str; DBG("conn %p", conn); @@ -82,6 +82,11 @@ static DBusMessage *get_properties(DBusConnection *conn, connman_dbus_dict_append_array(&dict, "EnabledDebugs", DBUS_TYPE_STRING, __connman_debug_list_enabled, NULL); + sessionmode = __connman_session_mode(); + connman_dbus_dict_append_basic(&dict, "SessionMode", + DBUS_TYPE_BOOLEAN, + &sessionmode); + connman_dbus_dict_close(&array, &dict); return reply; @@ -122,6 +127,15 @@ static DBusMessage *set_property(DBusConnection *conn, dbus_message_iter_get_basic(&value, &str); return __connman_error_not_supported(msg); + } else if (g_str_equal(name, "SessionMode") == TRUE) { + connman_bool_t sessionmode; + + if (type != DBUS_TYPE_BOOLEAN) + return __connman_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&value, &sessionmode); + + __connman_session_set_mode(sessionmode); } else return __connman_error_invalid_property(msg); @@ -442,6 +456,13 @@ static DBusMessage *connect_service(DBusConnection *conn, DBG("conn %p", conn); + if (__connman_session_mode() == TRUE) { + connman_info("Session mode enabled: " + "direct service connect disabled"); + + return __connman_error_failed(msg, -EINVAL); + } + err = __connman_service_create_and_connect(msg); if (err < 0) { if (err == -EINPROGRESS) { @@ -463,6 +484,13 @@ static DBusMessage *connect_provider(DBusConnection *conn, DBG("conn %p", conn); + if (__connman_session_mode() == TRUE) { + connman_info("Session mode enabled: " + "direct provider connect disabled"); + + return __connman_error_failed(msg, -EINVAL); + } + err = __connman_provider_create_and_connect(msg); if (err < 0) { if (err == -EINPROGRESS) { diff --git a/src/service.c b/src/service.c index 7a9185de..d07cead0 100644 --- a/src/service.c +++ b/src/service.c @@ -2484,6 +2484,11 @@ void __connman_service_auto_connect(void) DBG(""); + if (__connman_session_mode() == TRUE) { + DBG("Session mode enabled: auto connect disabled"); + return; + } + iter = g_sequence_get_begin_iter(service_list); while (g_sequence_iter_is_end(iter) == FALSE) { diff --git a/src/session.c b/src/session.c index b192350c..391899fb 100644 --- a/src/session.c +++ b/src/session.c @@ -32,6 +32,7 @@ static DBusConnection *connection; static GHashTable *session_hash; static GHashTable *bearer_hash; +static connman_bool_t sessionmode; struct connman_bearer { gint refcount; @@ -262,6 +263,24 @@ failed_connect: return NULL; } +connman_bool_t __connman_session_mode() +{ + return sessionmode; +} + +void __connman_session_set_mode(connman_bool_t enable) +{ + DBG("enable %d", enable); + + if (sessionmode == enable) + return; + + sessionmode = enable; + + if (sessionmode == TRUE) + __connman_service_disconnect_all(); +} + int __connman_session_init(void) { DBG(""); @@ -276,6 +295,7 @@ int __connman_session_init(void) bearer_hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, remove_bearer); + sessionmode = FALSE; return 0; } |