From 870b814aa2117c051c270bd6ed16977144ce38da Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 7 Aug 2009 06:27:27 -0700 Subject: Add support for AutoConnect property of services --- doc/service-api.txt | 5 +++++ src/service.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/doc/service-api.txt b/doc/service-api.txt index 7a350eea..a1dffa57 100644 --- a/doc/service-api.txt +++ b/doc/service-api.txt @@ -204,6 +204,11 @@ Properties string State [readonly] method. So for now it will be considered a read only property. + boolean AutoConnect [readonly] + + If set to true, this service will auto-connect + when not other connection is available. + string IPv4.Method [readwrite] The IPv4 configuration method. Possible values here diff --git a/src/service.c b/src/service.c index fb95cf0b..16b6d7ef 100644 --- a/src/service.c +++ b/src/service.c @@ -47,6 +47,7 @@ struct connman_service { connman_bool_t favorite; connman_bool_t hidden; connman_bool_t ignore; + connman_bool_t autoconnect; GTimeVal modified; unsigned int order; char *name; @@ -395,6 +396,9 @@ static DBusMessage *get_properties(DBusConnection *conn, connman_dbus_dict_append_variant(&dict, "Favorite", DBUS_TYPE_BOOLEAN, &service->favorite); + connman_dbus_dict_append_variant(&dict, "AutoConnect", + DBUS_TYPE_BOOLEAN, &service->autoconnect); + if (service->name != NULL) connman_dbus_dict_append_variant(&dict, "Name", DBUS_TYPE_STRING, &service->name); @@ -557,6 +561,9 @@ static connman_bool_t is_connecting(struct connman_service *service) static connman_bool_t is_ignore(struct connman_service *service) { + if (service->autoconnect == FALSE) + return TRUE; + if (service->ignore == TRUE) return TRUE; @@ -1620,6 +1627,8 @@ struct connman_service *__connman_service_create_from_device(struct connman_devi service->type = __connman_device_get_service_type(device); + service->autoconnect = FALSE; + service->device = device; service_register(service); @@ -1841,6 +1850,19 @@ struct connman_service *__connman_service_create_from_network(struct connman_net service->type = convert_network_type(network); + switch (service->type) { + case CONNMAN_SERVICE_TYPE_UNKNOWN: + case CONNMAN_SERVICE_TYPE_ETHERNET: + case CONNMAN_SERVICE_TYPE_WIMAX: + case CONNMAN_SERVICE_TYPE_BLUETOOTH: + case CONNMAN_SERVICE_TYPE_CELLULAR: + service->autoconnect = FALSE; + break; + case CONNMAN_SERVICE_TYPE_WIFI: + service->autoconnect = TRUE; + break; + } + service->state = CONNMAN_SERVICE_STATE_IDLE; update_from_network(service, network); -- cgit v1.2.3