|
Loading...
|
connman@connman.net
[Prev] Thread [Next] | [Prev] Date [Next]
[PATCH 07/12] session: filtering session state update according to connection type Tomasz Bursztyka Wed Feb 15 01:00:26 2012
---
src/session.c | 47 ++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/src/session.c b/src/session.c
index b846e2d..b67b2ea 100644
--- a/src/session.c
+++ b/src/session.c
@@ -547,6 +547,28 @@ static void append_notify(DBusMessageIter *dict,
session->append_all = FALSE;
}
+static connman_bool_t is_type_matching_state(enum connman_session_state *state,
+ enum connman_session_type type)
+{
+ switch (type) {
+ case CONNMAN_SESSION_TYPE_ANY:
+ return TRUE;
+ case CONNMAN_SESSION_TYPE_LOCAL:
+ if (*state >= CONNMAN_SESSION_STATE_CONNECTED) {
+ *state = CONNMAN_SESSION_STATE_CONNECTED;
+ return TRUE;
+ }
+
+ break;
+ case CONNMAN_SESSION_TYPE_INTERNET:
+ if (*state == CONNMAN_SESSION_STATE_ONLINE)
+ return TRUE;
+ break;
+ }
+
+ return FALSE;
+}
+
static connman_bool_t compute_notifiable_changes(struct connman_session
*session)
{
struct session_info *info_last = session->info_last;
@@ -1005,7 +1027,13 @@ static void deselect_and_disconnect(struct
connman_session *session,
static void select_connected_service(struct session_info *info,
struct service_entry *entry)
{
- info->state = service_to_session_state(entry->state);
+ enum connman_session_state state;
+
+ state = service_to_session_state(entry->state);
+ if (is_type_matching_state(&state, info->type) == FALSE)
+ return;
+
+ info->state = state;
info->entry = entry;
info->entry->reason = info->reason;
@@ -1165,8 +1193,14 @@ static void session_changed(struct connman_session
*session,
DBG("session %p trigger %s reason %s", session, trigger2string(trigger),
reason2string(info->reason));
- if (info->entry != NULL)
- info->state = service_to_session_state(info->entry->state);
+ if (info->entry != NULL) {
+ enum connman_session_state state;
+
+ state = service_to_session_state(info->entry->state);
+
+ if (is_type_matching_state(&state, info->type) == TRUE)
+ info->state = state;
+ }
switch (trigger) {
case CONNMAN_SESSION_TRIGGER_UNKNOWN:
@@ -1201,6 +1235,13 @@ static void session_changed(struct connman_session
*session,
g_sequence_free(service_list_last);
}
+ if (info->type != info_last->type) {
+ if (info->state >= CONNMAN_SESSION_STATE_CONNECTED &&
+ is_type_matching_state(&info->state,
+ info->type) == FALSE)
+ deselect_and_disconnect(session, info->reason);
+ }
+
if (info->state == CONNMAN_SESSION_STATE_DISCONNECTED) {
select_and_connect(session,
CONNMAN_SESSION_REASON_FREE_RIDE);
--
1.7.8.4
_______________________________________________
connman mailing list
[EMAIL PROTECTED]
http://lists.connman.net/listinfo/connman
- [PATCH 00/12 - v5] Session state, connection type and fixes Tomasz Bursztyka 2012/02/15
- [PATCH 01/12] session: changing online property to a state property Tomasz Bursztyka 2012/02/15
- [PATCH 02/12] session: refactor and optimize how notification are raised and when Tomasz Bursztyka 2012/02/15
- [PATCH 03/12] session: do not notify an ipconfig change if the session is not connected Tomasz Bursztyka 2012/02/15
- [PATCH 04/12] service: adding a function to know the connected state of an ipconfig Tomasz Bursztyka 2012/02/15
- [PATCH 05/12] session: do not notify ipconfig content if it's not in a connected state Tomasz Bursztyka 2012/02/15
- [PATCH 06/12] session: introducing a property to select a type on which the state gets up on Tomasz Bursztyka 2012/02/15
- [PATCH 07/12] session: filtering session state update according to connection type Tomasz Bursztyka 2012/02/15 <=
- [PATCH 08/12] doc: updated session api documentation Tomasz Bursztyka 2012/02/15
- [PATCH 09/12] test: fixing type conversion bug in test-session Tomasz Bursztyka 2012/02/15
- [PATCH 10/12] test: modify test-session to handle a new property Tomasz Bursztyka 2012/02/15
- [PATCH 11/12] unit: switching from online to state property into test-session Tomasz Bursztyka 2012/02/15
- [PATCH 12/12] unit: handling type of connection into session api Tomasz Bursztyka 2012/02/15
- Re: [PATCH 00/12 - v5] Session state, connection type and fixes Patrik Flykt 2012/02/28