summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-07-16 09:33:50 +0200
committerMarcel Holtmann <marcel@holtmann.org>2009-07-16 09:33:50 +0200
commite8f78a580ab93dfe436d5e88aaa65f4d470f017d (patch)
tree99e1940621f52055ff8625072835746b2b5832de /src
parent6b7fe4f0d4a22e6f880287ac396f5fe13a7432f5 (diff)
downloadconnman-e8f78a580ab93dfe436d5e88aaa65f4d470f017d.tar.gz
connman-e8f78a580ab93dfe436d5e88aaa65f4d470f017d.tar.bz2
connman-e8f78a580ab93dfe436d5e88aaa65f4d470f017d.zip
Delay the update of service list by 2 seconds
Diffstat (limited to 'src')
-rw-r--r--src/connection.c9
-rw-r--r--src/connman.h2
-rw-r--r--src/profile.c29
3 files changed, 33 insertions, 7 deletions
diff --git a/src/connection.c b/src/connection.c
index 6939e441..7c81c0d2 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -656,15 +656,20 @@ static void update_order(void)
}
}
-void __connman_connection_update_gateway(void)
+gboolean __connman_connection_update_gateway(void)
{
struct gateway_data *active_gateway, *default_gateway;
+ gboolean updated = FALSE;
update_order();
active_gateway = find_active_gateway();
default_gateway = find_default_gateway();
- if (active_gateway && active_gateway != default_gateway)
+ if (active_gateway && active_gateway != default_gateway) {
del_route(active_gateway->element, active_gateway->gateway);
+ updated = TRUE;
+ }
+
+ return updated;
}
diff --git a/src/connman.h b/src/connman.h
index 4b461f12..bfc7fdf9 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -188,7 +188,7 @@ void __connman_ipv4_cleanup(void);
int __connman_connection_init(void);
void __connman_connection_cleanup(void);
-void __connman_connection_update_gateway(void);
+gboolean __connman_connection_update_gateway(void);
int __connman_udev_init(void);
void __connman_udev_cleanup(void);
diff --git a/src/profile.c b/src/profile.c
index 683e46a8..0f7c793f 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -65,18 +65,20 @@ static void append_services(DBusMessageIter *entry)
dbus_message_iter_close_container(entry, &value);
}
-void __connman_profile_changed(void)
+static guint changed_timeout = 0;
+
+static gboolean services_changed(gpointer user_data)
{
const char *path = __connman_profile_active_path();
DBusMessage *signal;
DBusMessageIter entry;
- __connman_connection_update_gateway();
+ changed_timeout = 0;
signal = dbus_message_new_signal(path,
CONNMAN_PROFILE_INTERFACE, "PropertyChanged");
if (signal == NULL)
- return;
+ return FALSE;
dbus_message_iter_init_append(signal, &entry);
append_services(&entry);
@@ -85,11 +87,30 @@ void __connman_profile_changed(void)
signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH,
CONNMAN_MANAGER_INTERFACE, "PropertyChanged");
if (signal == NULL)
- return;
+ return FALSE;
dbus_message_iter_init_append(signal, &entry);
append_services(&entry);
g_dbus_send_message(connection, signal);
+
+ return FALSE;
+}
+
+void __connman_profile_changed(void)
+{
+ DBG("");
+
+ if (changed_timeout > 0) {
+ g_source_remove(changed_timeout);
+ changed_timeout = 0;
+ }
+
+ if (__connman_connection_update_gateway() == TRUE) {
+ services_changed(NULL);
+ return;
+ }
+
+ changed_timeout = g_timeout_add_seconds(2, services_changed, NULL);
}
int __connman_profile_add_device(struct connman_device *device)