From 04c0be97d5b59ca4c1c0fcc626584e04b3e0f480 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 7 Jan 2010 11:42:40 -0800 Subject: [PATCH] Add support for setting immutable flag from configurations --- include/service.h | 3 --- src/config.c | 3 +++ src/connman.h | 4 ++++ src/service.c | 37 +++++++++++++++++++++++++++++++++---- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/include/service.h b/include/service.h index 3368ba0..3c345fa 100644 --- a/include/service.h +++ b/include/service.h @@ -92,9 +92,6 @@ void connman_service_unref(struct connman_service *service); enum connman_service_type connman_service_get_type(struct connman_service *service); char *connman_service_get_interface(struct connman_service *service); -int connman_service_set_favorite(struct connman_service *service, - connman_bool_t favorite); - #ifdef __cplusplus } #endif diff --git a/src/config.c b/src/config.c index 274d9c2..4b6e3ef 100644 --- a/src/config.c +++ b/src/config.c @@ -392,6 +392,9 @@ static void provision_service(gpointer key, gpointer value, gpointer user_data) if (memcmp(config->ssid, ssid, ssid_len) != 0) return; + __connman_service_set_immutable(service, TRUE); + __connman_service_set_favorite(service, TRUE); + if (config->eap) __connman_service_set_string(service, "EAP", config->eap); diff --git a/src/connman.h b/src/connman.h index cc3bd08..a6619df 100644 --- a/src/connman.h +++ b/src/connman.h @@ -374,6 +374,10 @@ void __connman_service_remove_from_network(struct connman_network *network); const char *__connman_service_get_path(struct connman_service *service); unsigned int __connman_service_get_order(struct connman_service *service); struct connman_network *__connman_service_get_network(struct connman_service *service); +int __connman_service_set_favorite(struct connman_service *service, + connman_bool_t favorite); +int __connman_service_set_immutable(struct connman_service *service, + connman_bool_t immutable); void __connman_service_set_string(struct connman_service *service, const char *key, const char *value); diff --git a/src/service.c b/src/service.c index b4f8a4e..24133d6 100644 --- a/src/service.c +++ b/src/service.c @@ -314,13 +314,29 @@ static void strength_changed(struct connman_service *service) static void favorite_changed(struct connman_service *service) { + if (service->path == NULL) + return; + connman_dbus_property_changed_basic(service->path, CONNMAN_SERVICE_INTERFACE, "Favorite", DBUS_TYPE_BOOLEAN, &service->favorite); } +static void immutable_changed(struct connman_service *service) +{ + if (service->path == NULL) + return; + + connman_dbus_property_changed_basic(service->path, + CONNMAN_SERVICE_INTERFACE, "Immutable", + DBUS_TYPE_BOOLEAN, &service->immutable); +} + static void roaming_changed(struct connman_service *service) { + if (service->path == NULL) + return; + connman_dbus_property_changed_basic(service->path, CONNMAN_SERVICE_INTERFACE, "Roaming", DBUS_TYPE_BOOLEAN, &service->roaming); @@ -328,6 +344,9 @@ static void roaming_changed(struct connman_service *service) static void autoconnect_changed(struct connman_service *service) { + if (service->path == NULL) + return; + connman_dbus_property_changed_basic(service->path, CONNMAN_SERVICE_INTERFACE, "AutoConnect", DBUS_TYPE_BOOLEAN, &service->autoconnect); @@ -1097,7 +1116,7 @@ static DBusMessage *remove_service(DBusConnection *conn, set_idle(service); - connman_service_set_favorite(service, FALSE); + __connman_service_set_favorite(service, FALSE); __connman_storage_save_service(service); return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); @@ -1426,13 +1445,13 @@ __connman_service_get_network(struct connman_service *service) } /** - * connman_service_set_favorite: + * __connman_service_set_favorite: * @service: service structure * @favorite: favorite value * * Change the favorite setting of service */ -int connman_service_set_favorite(struct connman_service *service, +int __connman_service_set_favorite(struct connman_service *service, connman_bool_t favorite) { GSequenceIter *iter; @@ -1455,6 +1474,16 @@ int connman_service_set_favorite(struct connman_service *service, return 0; } +int __connman_service_set_immutable(struct connman_service *service, + connman_bool_t immutable) +{ + service->immutable = immutable; + + immutable_changed(service); + + return 0; +} + void __connman_service_set_string(struct connman_service *service, const char *key, const char *value) { @@ -1533,7 +1562,7 @@ int __connman_service_indicate_state(struct connman_service *service, if (state == CONNMAN_SERVICE_STATE_READY) { set_reconnect_state(service, TRUE); - connman_service_set_favorite(service, TRUE); + __connman_service_set_favorite(service, TRUE); reply_pending(service, 0); -- 2.7.4