From db8a2e1563f59e4dde4517013c7e346ffe95278e Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 21 Apr 2009 05:43:37 +0100 Subject: [PATCH] Send signals for service state changes --- src/service.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/service.c b/src/service.c index 7b765c2..d217441 100644 --- a/src/service.c +++ b/src/service.c @@ -138,6 +138,27 @@ static const char *state2string(enum connman_service_state state) return NULL; } +static void state_changed(struct connman_service *service) +{ + DBusMessage *signal; + DBusMessageIter entry; + const char *str; + + str = state2string(service->state); + if (str == NULL) + return; + + signal = dbus_message_new_signal(service->path, + CONNMAN_SERVICE_INTERFACE, "PropertyChanged"); + if (signal == NULL) + return; + + dbus_message_iter_init_append(signal, &entry); + connman_dbus_dict_append_variant(&entry, "State", + DBUS_TYPE_STRING, &str); + g_dbus_send_message(connection, signal); +} + static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -205,6 +226,8 @@ static DBusMessage *connect_service(DBusConnection *conn, return __connman_error_failed(msg); service->state = CONNMAN_SERVICE_STATE_READY; + + state_changed(service); } return __connman_error_not_supported(msg); @@ -220,6 +243,8 @@ static DBusMessage *disconnect_service(DBusConnection *conn, return __connman_error_failed(msg); service->state = CONNMAN_SERVICE_STATE_IDLE; + + state_changed(service); } return __connman_error_not_supported(msg); @@ -451,6 +476,8 @@ int __connman_service_set_carrier(struct connman_service *service, else service->state = CONNMAN_SERVICE_STATE_IDLE; + state_changed(service); + return connman_service_set_favorite(service, carrier); } @@ -461,6 +488,8 @@ int __connman_service_indicate_configuration(struct connman_service *service) service->state = CONNMAN_SERVICE_STATE_CONFIGURATION; + state_changed(service); + return 0; } -- 2.7.4