From e5884a7a2ee413798e41825a3665dd48d2331f3b Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 19 Jul 2009 22:04:41 +0200 Subject: [PATCH] Add support for default technology property --- doc/manager-api.txt | 5 +++++ src/connman.h | 1 + src/manager.c | 5 +++++ src/service.c | 20 ++++++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/doc/manager-api.txt b/doc/manager-api.txt index 79761ce..e83ac10 100644 --- a/doc/manager-api.txt +++ b/doc/manager-api.txt @@ -147,6 +147,11 @@ Properties string State [readonly] The list of connected technologies. The strings are the same as the ones from the service type. + string DefaultTechnology [readonly] + + The current connected technology which holds the + default route. + boolean OfflineMode [readwrite] The offline mode indicates the global setting for diff --git a/src/connman.h b/src/connman.h index 407bbe7..b30c893 100644 --- a/src/connman.h +++ b/src/connman.h @@ -255,6 +255,7 @@ int __connman_service_init(void); void __connman_service_cleanup(void); void __connman_service_list(DBusMessageIter *iter); +const char *__connman_service_default(void); void __connman_service_put(struct connman_service *service); diff --git a/src/manager.c b/src/manager.c index 814a063..711fa63 100644 --- a/src/manager.c +++ b/src/manager.c @@ -247,6 +247,11 @@ static DBusMessage *get_properties(DBusConnection *conn, append_enabled_technologies(&dict); append_connected_technologies(&dict); + str = __connman_service_default(); + if (str != NULL) + connman_dbus_dict_append_variant(&dict, "DefaultTechnology", + DBUS_TYPE_STRING, &str); + dbus_message_iter_close_container(&array, &dict); return reply; diff --git a/src/service.c b/src/service.c index 557a968..923a958 100644 --- a/src/service.c +++ b/src/service.c @@ -210,6 +210,26 @@ static enum connman_service_error string2error(const char *error) return CONNMAN_SERVICE_ERROR_UNKNOWN; } +const char *__connman_service_default(void) +{ + struct connman_service *service; + GSequenceIter *iter; + + iter = g_sequence_get_begin_iter(service_list); + + if (g_sequence_iter_is_end(iter) == TRUE) + return ""; + + service = g_sequence_get(iter); + if (service == NULL) + return ""; + + if (service->state != CONNMAN_SERVICE_STATE_READY) + return ""; + + return type2string(service->type); +} + static void state_changed(struct connman_service *service) { DBusMessage *signal; -- 2.7.4