Add support for default technology property
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 19 Jul 2009 20:04:41 +0000 (22:04 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 19 Jul 2009 20:04:41 +0000 (22:04 +0200)
doc/manager-api.txt
src/connman.h
src/manager.c
src/service.c

index 79761ce..e83ac10 100644 (file)
@@ -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
index 407bbe7..b30c893 100644 (file)
@@ -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);
 
index 814a063..711fa63 100644 (file)
@@ -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;
index 557a968..923a958 100644 (file)
@@ -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;