char *identifier;
char *path;
enum connman_service_type type;
- enum connman_service_mode mode;
enum connman_service_security security;
enum connman_service_state state_ipv4;
enum connman_service_state state_ipv6;
return NULL;
}
-static const char *mode2string(enum connman_service_mode mode)
-{
- switch (mode) {
- case CONNMAN_SERVICE_MODE_UNKNOWN:
- break;
- case CONNMAN_SERVICE_MODE_MANAGED:
- return "managed";
- case CONNMAN_SERVICE_MODE_ADHOC:
- return "adhoc";
- case CONNMAN_SERVICE_MODE_GPRS:
- return "gprs";
- case CONNMAN_SERVICE_MODE_EDGE:
- return "edge";
- case CONNMAN_SERVICE_MODE_UMTS:
- return "umts";
- }
-
- return NULL;
-}
-
static const char *security2string(enum connman_service_security security)
{
switch (security) {
return __connman_service_type2string(service->type);
}
-static void mode_changed(struct connman_service *service)
-{
- const char *str;
-
- str = mode2string(service->mode);
- if (str == NULL)
- return;
-
- connman_dbus_property_changed_basic(service->path,
- CONNMAN_SERVICE_INTERFACE, "Mode",
- DBUS_TYPE_STRING, &str);
-}
-
static void state_changed(struct connman_service *service)
{
enum connman_service_state state;
connman_dbus_dict_append_basic(dict, "Type",
DBUS_TYPE_STRING, &str);
- str = mode2string(service->mode);
- if (str != NULL)
- connman_dbus_dict_append_basic(dict, "Mode",
- DBUS_TYPE_STRING, &str);
-
connman_dbus_dict_append_array(dict, "Security",
DBUS_TYPE_STRING, append_security, service);
service->session_usage_count = 0;
service->type = CONNMAN_SERVICE_TYPE_UNKNOWN;
- service->mode = CONNMAN_SERVICE_MODE_UNKNOWN;
service->security = CONNMAN_SERVICE_SECURITY_UNKNOWN;
service->state_ipv4 = CONNMAN_SERVICE_STATE_UNKNOWN;
else {
service_complete(service);
__connman_profile_changed(FALSE);
- __connman_element_request_scan(CONNMAN_ELEMENT_TYPE_UNKNOWN);
+ __connman_device_request_scan(CONNMAN_DEVICE_TYPE_UNKNOWN);
}
}
+int __connman_service_set_ipconfig_ready(struct connman_service *service,
+ enum connman_ipconfig_type type)
+{
+ enum connman_service_state state;
+ int err = 0;
+
+ DBG("service %p (%s) type %d (%s)",
+ service, service ? service->identifier : NULL,
+ type, __connman_ipconfig_type2string(type));
+
+ if (service == NULL)
+ return -EINVAL;
+
+ state = combine_state(service->state_ipv4, service->state_ipv6);
+
+ if (state == CONNMAN_SERVICE_STATE_READY ||
+ state == CONNMAN_SERVICE_STATE_ONLINE) {
+ err = -EALREADY;
+ } else {
+ err = __connman_service_indicate_state(service,
+ CONNMAN_SERVICE_STATE_READY, type);
+ }
+
+ return err;
+}
+
int __connman_service_indicate_state(struct connman_service *service,
enum connman_service_state new_state,
enum connman_ipconfig_type type)
if (service_state == CONNMAN_SERVICE_STATE_IDLE ||
service_state == CONNMAN_SERVICE_STATE_FAILURE)
- __connman_element_request_scan(CONNMAN_ELEMENT_TYPE_UNKNOWN);
+ __connman_device_request_scan(CONNMAN_DEVICE_TYPE_UNKNOWN);
return 0;
}
return 0;
if (err == -EINPROGRESS) {
- service->timeout = g_timeout_add_seconds(CONNECT_TIMEOUT,
- connect_timeout, service);
+ if (service->timeout == 0)
+ service->timeout = g_timeout_add_seconds(
+ CONNECT_TIMEOUT, connect_timeout, service);
return -EINPROGRESS;
}
g_strcmp0(security, "ieee8021x") != 0)
return -EINVAL;
- device = __connman_element_find_device(CONNMAN_SERVICE_TYPE_WIFI);
+ device = __connman_device_find_device(CONNMAN_SERVICE_TYPE_WIFI);
if (device == NULL)
return -EOPNOTSUPP;
if (type == CONNMAN_IPCONFIG_TYPE_IPV6 &&
method == CONNMAN_IPCONFIG_METHOD_AUTO)
- __connman_service_indicate_state(service,
- CONNMAN_SERVICE_STATE_READY,
+ __connman_service_set_ipconfig_ready(service,
CONNMAN_IPCONFIG_TYPE_IPV6);
settings_changed(service, ipconfig);
return CONNMAN_SERVICE_TYPE_UNKNOWN;
}
-static enum connman_service_mode convert_wifi_mode(const char *mode)
-{
- if (mode == NULL)
- return CONNMAN_SERVICE_MODE_UNKNOWN;
- else if (g_str_equal(mode, "managed") == TRUE)
- return CONNMAN_SERVICE_MODE_MANAGED;
- else if (g_str_equal(mode, "adhoc") == TRUE)
- return CONNMAN_SERVICE_MODE_ADHOC;
- else
- return CONNMAN_SERVICE_MODE_UNKNOWN;
-}
-
static enum connman_service_security convert_wifi_security(const char *security)
{
if (security == NULL)
return CONNMAN_SERVICE_SECURITY_UNKNOWN;
}
-static enum connman_service_mode convert_cellular_mode(connman_uint8_t mode)
-{
- switch (mode) {
- case 0:
- case 1:
- return CONNMAN_SERVICE_MODE_GPRS;
- case 3:
- return CONNMAN_SERVICE_MODE_EDGE;
- case 2:
- case 4:
- case 5:
- case 6:
- return CONNMAN_SERVICE_MODE_UMTS;
- }
-
- return CONNMAN_SERVICE_MODE_UNKNOWN;
-}
-
static void update_from_network(struct connman_service *service,
struct connman_network *network)
{
service->hidden = TRUE;
}
- service->strength = connman_network_get_uint8(network, "Strength");
+ service->strength = connman_network_get_strength(network);
service->roaming = connman_network_get_bool(network, "Roaming");
if (service->strength == 0) {
service->strength = strength;
}
- str = connman_network_get_string(network, "WiFi.Mode");
- service->mode = convert_wifi_mode(str);
-
str = connman_network_get_string(network, "WiFi.Security");
service->security = convert_wifi_security(str);
- if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR) {
- connman_uint8_t value = connman_network_get_uint8(network,
- "Cellular.Mode");
-
- service->mode = convert_cellular_mode(value);
- } else if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
+ if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
service->wps = connman_network_get_bool(network, "WiFi.WPS");
if (service->strength > strength && service->network != NULL) {
void __connman_service_update_from_network(struct connman_network *network)
{
struct connman_service *service;
- enum connman_service_mode mode;
- connman_uint8_t strength, value;
+ connman_uint8_t strength;
connman_bool_t roaming;
GSequenceIter *iter;
const char *name;
if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
service->wps = connman_network_get_bool(network, "WiFi.WPS");
- strength = connman_network_get_uint8(service->network, "Strength");
+ strength = connman_network_get_strength(service->network);
if (strength == service->strength)
goto roaming;
roaming:
roaming = connman_network_get_bool(service->network, "Roaming");
if (roaming == service->roaming)
- goto done;
+ return;
stats_enable = stats_enabled(service);
if (stats_enable == TRUE)
iter = g_hash_table_lookup(service_hash, service->identifier);
if (iter != NULL)
g_sequence_sort_changed(iter, service_compare, NULL);
-
-done:
- if (service->type != CONNMAN_SERVICE_TYPE_CELLULAR)
- return;
-
- value = connman_network_get_uint8(service->network, "Cellular.Mode");
- mode = convert_cellular_mode(value);
-
- if (mode == service->mode)
- return;
-
- service->mode = mode;
-
- mode_changed(service);
}
void __connman_service_remove_from_network(struct connman_network *network)