diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-12-19 15:12:10 -0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-12-19 15:12:10 -0800 |
commit | 64dee569887c5c4e4a62a109f4ecf3c9093707bc (patch) | |
tree | 2c86201c2dd5e599af2b4de0d07c94c746ec2a43 /src | |
parent | 328d81c6cea8523694ca008e9f08008326f46439 (diff) | |
download | connman-64dee569887c5c4e4a62a109f4ecf3c9093707bc.tar.gz connman-64dee569887c5c4e4a62a109f4ecf3c9093707bc.tar.bz2 connman-64dee569887c5c4e4a62a109f4ecf3c9093707bc.zip |
Make use of property changed helper for arrays
Diffstat (limited to 'src')
-rw-r--r-- | src/device.c | 14 | ||||
-rw-r--r-- | src/network.c | 13 | ||||
-rw-r--r-- | src/notifier.c | 51 | ||||
-rw-r--r-- | src/profile.c | 54 |
4 files changed, 25 insertions, 107 deletions
diff --git a/src/device.c b/src/device.c index 45152459..fba934e8 100644 --- a/src/device.c +++ b/src/device.c @@ -480,19 +480,9 @@ static GDBusSignalTable device_signals[] = { static void emit_devices_signal(void) { - DBusMessage *signal; - DBusMessageIter iter; - - signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH, - CONNMAN_MANAGER_INTERFACE, "PropertyChanged"); - if (signal == NULL) - return; - - dbus_message_iter_init_append(signal, &iter); - connman_dbus_property_append_variable_array(&iter, "Devices", + connman_dbus_property_changed_array(CONNMAN_MANAGER_PATH, + CONNMAN_MANAGER_INTERFACE, "Devices", DBUS_TYPE_OBJECT_PATH, __connman_device_list, NULL); - - g_dbus_send_message(connection, signal); } static int register_interface(struct connman_element *element) diff --git a/src/network.c b/src/network.c index 81be9be7..6c1a359b 100644 --- a/src/network.c +++ b/src/network.c @@ -190,19 +190,10 @@ static void append_networks(DBusMessageIter *iter, void *user_data) static void emit_networks_signal(struct connman_device *device) { const char *path = connman_device_get_path(device); - DBusMessage *signal; - DBusMessageIter iter; - signal = dbus_message_new_signal(path, - CONNMAN_DEVICE_INTERFACE, "PropertyChanged"); - if (signal == NULL) - return; - - dbus_message_iter_init_append(signal, &iter); - connman_dbus_property_append_variable_array(&iter, "Networks", + connman_dbus_property_changed_array(path, + CONNMAN_DEVICE_INTERFACE, "Networks", DBUS_TYPE_OBJECT_PATH, append_networks, device); - - g_dbus_send_message(connection, signal); } static int register_interface(struct connman_element *element) diff --git a/src/notifier.c b/src/notifier.c index de371be3..8a14075b 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -127,46 +127,24 @@ void __connman_notifier_list_connected(DBusMessageIter *iter, void *user_data) static void technology_registered(enum connman_service_type type, connman_bool_t registered) { - DBusMessage *signal; - DBusMessageIter iter; - DBG("type %d registered %d", type, registered); - signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH, - CONNMAN_MANAGER_INTERFACE, "PropertyChanged"); - if (signal == NULL) - return; - - dbus_message_iter_init_append(signal, &iter); - connman_dbus_property_append_variable_array(&iter, - "AvailableTechnologies", DBUS_TYPE_STRING, - __connman_notifier_list_registered, NULL); - - g_dbus_send_message(connection, signal); + connman_dbus_property_changed_array(CONNMAN_MANAGER_PATH, + CONNMAN_MANAGER_INTERFACE, "AvailableTechnologies", + DBUS_TYPE_STRING, __connman_notifier_list_registered, NULL); } static void technology_enabled(enum connman_service_type type, connman_bool_t enabled) { - DBusMessage *signal; - DBusMessageIter iter; GSList *list; DBG("type %d enabled %d", type, enabled); - signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH, - CONNMAN_MANAGER_INTERFACE, "PropertyChanged"); - if (signal == NULL) - goto done; - - dbus_message_iter_init_append(signal, &iter); - connman_dbus_property_append_variable_array(&iter, - "EnabledTechnologies", DBUS_TYPE_STRING, - __connman_notifier_list_enabled, NULL); + connman_dbus_property_changed_array(CONNMAN_MANAGER_PATH, + CONNMAN_MANAGER_INTERFACE, "EnabledTechnologies", + DBUS_TYPE_STRING, __connman_notifier_list_enabled, NULL); - g_dbus_send_message(connection, signal); - -done: for (list = notifier_list; list; list = list->next) { struct connman_notifier *notifier = list->data; @@ -178,22 +156,11 @@ done: static void technology_connected(enum connman_service_type type, connman_bool_t connected) { - DBusMessage *signal; - DBusMessageIter iter; - DBG("type %d connected %d", type, connected); - signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH, - CONNMAN_MANAGER_INTERFACE, "PropertyChanged"); - if (signal == NULL) - return; - - dbus_message_iter_init_append(signal, &iter); - connman_dbus_property_append_variable_array(&iter, - "ConnectedTechnologies", DBUS_TYPE_STRING, - __connman_notifier_list_connected, NULL); - - g_dbus_send_message(connection, signal); + connman_dbus_property_changed_array(CONNMAN_MANAGER_PATH, + CONNMAN_MANAGER_INTERFACE, "ConnectedTechnologies", + DBUS_TYPE_STRING, __connman_notifier_list_connected, NULL); } void __connman_notifier_register(enum connman_service_type type) diff --git a/src/profile.c b/src/profile.c index 74fa0f75..43557042 100644 --- a/src/profile.c +++ b/src/profile.c @@ -60,21 +60,9 @@ void __connman_profile_list(DBusMessageIter *iter, void *user_data) static void profiles_changed(void) { - DBusMessage *signal; - DBusMessageIter iter; - - DBG(""); - - signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH, - CONNMAN_MANAGER_INTERFACE, "PropertyChanged"); - if (signal == NULL) - return; - - dbus_message_iter_init_append(signal, &iter); - connman_dbus_property_append_variable_array(&iter, "Profiles", + connman_dbus_property_changed_array(CONNMAN_MANAGER_PATH, + CONNMAN_MANAGER_INTERFACE, "Profiles", DBUS_TYPE_OBJECT_PATH, __connman_profile_list, NULL); - - g_dbus_send_message(connection, signal); } static void name_changed(struct connman_profile *profile) @@ -151,42 +139,24 @@ static guint changed_timeout = 0; static gboolean services_changed(gpointer user_data) { struct connman_profile *profile = default_profile; - DBusMessage *signal; - DBusMessageIter iter; + connman_dbus_append_cb_t function = NULL; changed_timeout = 0; if (profile == NULL) return FALSE; - signal = dbus_message_new_signal(profile->path, - CONNMAN_PROFILE_INTERFACE, "PropertyChanged"); - if (signal == NULL) - return FALSE; + if (g_strcmp0(profile->ident, PROFILE_DEFAULT_IDENT) == 0) { + function = __connman_service_list; - dbus_message_iter_init_append(signal, &iter); - if (g_strcmp0(profile->ident, PROFILE_DEFAULT_IDENT) == 0) - connman_dbus_property_append_variable_array(&iter, "Services", - DBUS_TYPE_OBJECT_PATH, __connman_service_list, NULL); - else - connman_dbus_property_append_variable_array(&iter, "Services", - DBUS_TYPE_OBJECT_PATH, NULL, NULL); - - g_dbus_send_message(connection, signal); - - if (g_strcmp0(profile->ident, PROFILE_DEFAULT_IDENT) != 0) - return FALSE; - - signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH, - CONNMAN_MANAGER_INTERFACE, "PropertyChanged"); - if (signal == NULL) - return FALSE; - - dbus_message_iter_init_append(signal, &iter); - connman_dbus_property_append_variable_array(&iter, "Services", - DBUS_TYPE_OBJECT_PATH, __connman_service_list, NULL); + connman_dbus_property_changed_array(CONNMAN_MANAGER_PATH, + CONNMAN_MANAGER_INTERFACE, "Services", + DBUS_TYPE_OBJECT_PATH, function, NULL); + } - g_dbus_send_message(connection, signal); + connman_dbus_property_changed_array(profile->path, + CONNMAN_PROFILE_INTERFACE, "Services", + DBUS_TYPE_OBJECT_PATH, function, NULL); return FALSE; } |