#include <errno.h>
-#include <gdbus/gdbus.h>
+#include <gdbus.h>
#include "test-connman.h"
return CONNMAN_SESSION_STATE_DISCONNECTED;
}
-static enum connman_session_state string2type(const char *type)
+static enum connman_session_type string2type(const char *type)
{
+ if (g_strcmp0(type, "any") == 0)
+ return CONNMAN_SESSION_TYPE_ANY;
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) {
- case CONNMAN_SESSION_ROAMING_POLICY_UNKNOWN:
- break;
- case CONNMAN_SESSION_ROAMING_POLICY_DEFAULT:
- return "default";
- case CONNMAN_SESSION_ROAMING_POLICY_ALWAYS:
- return "always";
- case CONNMAN_SESSION_ROAMING_POLICY_FORBIDDEN:
- return "forbidden";
- case CONNMAN_SESSION_ROAMING_POLICY_NATIONAL:
- return "national";
- case CONNMAN_SESSION_ROAMING_POLICY_INTERNATIONAL:
- return "international";
- }
-
- return "";
-}
-
-static enum connman_session_roaming_policy string2roamingpolicy(const char *policy)
-{
- if (g_strcmp0(policy, "default") == 0)
- return CONNMAN_SESSION_ROAMING_POLICY_DEFAULT;
- else if (g_strcmp0(policy, "always") == 0)
- return CONNMAN_SESSION_ROAMING_POLICY_ALWAYS;
- else if (g_strcmp0(policy, "forbidden") == 0)
- return CONNMAN_SESSION_ROAMING_POLICY_FORBIDDEN;
- else if (g_strcmp0(policy, "national") == 0)
- return CONNMAN_SESSION_ROAMING_POLICY_NATIONAL;
- else if (g_strcmp0(policy, "international") == 0)
- return CONNMAN_SESSION_ROAMING_POLICY_INTERNATIONAL;
- else
- return CONNMAN_SESSION_ROAMING_POLICY_UNKNOWN;
+ return CONNMAN_SESSION_TYPE_UNKNOWN;
}
void bearer_info_cleanup(gpointer data, gpointer user_data)
return __connman_error_invalid_arguments(msg);
}
break;
- case DBUS_TYPE_BOOLEAN:
- if (g_str_equal(key, "Priority") == TRUE) {
- dbus_message_iter_get_basic(&value,
- &info->priority);
-
- } else if (g_str_equal(key, "AvoidHandover") == TRUE) {
- dbus_message_iter_get_basic(&value,
- &info->avoid_handover);
-
- } else if (g_str_equal(key, "StayConnected") == TRUE) {
- dbus_message_iter_get_basic(&value,
- &info->stay_connected);
-
- } else if (g_str_equal(key, "EmergencyCall") == TRUE) {
- dbus_message_iter_get_basic(&value,
- &info->ecall);
-
- } else {
- g_assert(FALSE);
- return __connman_error_invalid_arguments(msg);
- }
- break;
- case DBUS_TYPE_UINT32:
- if (g_str_equal(key, "PeriodicConnect") == TRUE) {
- dbus_message_iter_get_basic(&value,
- &info->periodic_connect);
-
- } else if (g_str_equal(key, "IdleTimeout") == TRUE) {
- dbus_message_iter_get_basic(&value,
- &info->idle_timeout);
-
- } else if (g_str_equal(key, "SessionMarker") == TRUE) {
- dbus_message_iter_get_basic(&value,
- &info->marker);
-
- } else {
- g_assert(FALSE);
- return __connman_error_invalid_arguments(msg);
- }
- break;
case DBUS_TYPE_STRING:
if (g_str_equal(key, "State") == TRUE) {
const char *val;
info->name = g_strdup(val);
- } else if (g_str_equal(key, "RoamingPolicy") == TRUE) {
- const char *val;
- dbus_message_iter_get_basic(&value, &val);
- info->roaming_policy =
- string2roamingpolicy(val);
-
} else if (g_str_equal(key, "Interface") == TRUE) {
const char *val;
dbus_message_iter_get_basic(&value, &val);
}
static const GDBusMethodTable notify_methods[] = {
- { _GDBUS_METHOD("Release", "", "", NULL, NULL, notify_release) },
- { _GDBUS_METHOD("Update", "a{sv}", "",
+ { GDBUS_METHOD("Release", NULL, NULL, notify_release) },
+ { GDBUS_METHOD("Update",
GDBUS_ARGS({ "settings", "a{sv}" }), NULL,
notify_update) },
{ },
for (list = info->allowed_bearers;
list != NULL; list = list->next) {
- struct test_bearer_info *info = list->data;
+ struct test_bearer_info *bearer_info = list->data;
dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
- &info->name);
+ &bearer_info->name);
}
}
void session_append_settings(DBusMessageIter *dict,
struct test_session_info *info)
{
- const char *policy;
-
- connman_dbus_dict_append_basic(dict, "Priority",
- DBUS_TYPE_BOOLEAN,
- &info->priority);
+ if (info->allowed_bearers == NULL)
+ return;
connman_dbus_dict_append_array(dict, "AllowedBearers",
DBUS_TYPE_STRING,
append_allowed_bearers,
info);
-
- connman_dbus_dict_append_basic(dict, "AvoidHandover",
- DBUS_TYPE_BOOLEAN,
- &info->avoid_handover);
-
- connman_dbus_dict_append_basic(dict, "StayConnected",
- DBUS_TYPE_BOOLEAN,
- &info->stay_connected);
-
- connman_dbus_dict_append_basic(dict, "PeriodicConnect",
- DBUS_TYPE_UINT32,
- &info->periodic_connect);
-
- connman_dbus_dict_append_basic(dict, "IdleTimeout",
- DBUS_TYPE_UINT32,
- &info->idle_timeout);
-
- connman_dbus_dict_append_basic(dict, "EmergencyCall",
- DBUS_TYPE_BOOLEAN,
- &info->ecall);
-
- policy = roamingpolicy2string(info->roaming_policy);
- connman_dbus_dict_append_basic(dict, "RoamingPolicy",
- DBUS_TYPE_STRING,
- &policy);
}
DBusMessage *session_connect(DBusConnection *connection,