[PATCH 12/12] unit: handling type of connection into session api

Tomasz Bursztyka tomasz.bursztyka at linux.intel.com
Wed Feb 8 06:13:11 PST 2012


---
 unit/session-api.c  |   16 ++++++++++++++++
 unit/test-connman.h |    7 +++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/unit/session-api.c b/unit/session-api.c
index 7e3a3b1..ce07d14 100644
--- a/unit/session-api.c
+++ b/unit/session-api.c
@@ -39,6 +39,16 @@ static enum connman_session_state string2state(const char *state)
 	return CONNMAN_SESSION_STATE_DISCONNECTED;
 }
 
+static enum connman_session_state string2type(const char *type)
+{
+	if (g_strcmp0(type, "local") == 0)
+		return CONNMAN_SESSION_TYPE_LOCAL;
+	if (g_strcmp0(type, "internet") == 0)
+		return CONNMAN_SESSION_TYPE_INTERNET;
+
+	return CONNMAN_SESSION_TYPE_ANY;
+}
+
 static const char *roamingpolicy2string(enum connman_session_roaming_policy policy)
 {
 	switch (policy) {
@@ -251,6 +261,12 @@ static DBusMessage *notify_update(DBusConnection *conn,
 
 				info->interface = g_strdup(val);
 
+			} else if (g_str_equal(key, "ConnectionType")
+								== TRUE) {
+				const char *val;
+				dbus_message_iter_get_basic(&value, &val);
+
+				info->type = string2type(val);
 			} else {
 				g_assert(FALSE);
 				return __connman_error_invalid_arguments(msg);
diff --git a/unit/test-connman.h b/unit/test-connman.h
index d04e230..01b39bf 100644
--- a/unit/test-connman.h
+++ b/unit/test-connman.h
@@ -77,6 +77,12 @@ enum connman_session_state {
 	CONNMAN_SESSION_STATE_ONLINE         = 2,
 };
 
+enum connman_session_type {
+	CONNMAN_SESSION_TYPE_ANY      = 0,
+	CONNMAN_SESSION_TYPE_LOCAL    = 1,
+	CONNMAN_SESSION_TYPE_INTERNET = 2,
+};
+
 enum connman_session_roaming_policy {
 	CONNMAN_SESSION_ROAMING_POLICY_UNKNOWN		= 0,
 	CONNMAN_SESSION_ROAMING_POLICY_DEFAULT		= 1,
@@ -89,6 +95,7 @@ enum connman_session_roaming_policy {
 struct test_session_info {
 	char *bearer;
 	enum connman_session_state state;
+	enum connman_session_type type;
 	char *name;
 	/* ipv4, ipv6 dicts */
 	GSList *allowed_bearers;
-- 
1.7.8.4




More information about the connman mailing list