diff options
-rw-r--r-- | common/dbus.c | 4 | ||||
-rw-r--r-- | eglib/gmain.c | 114 | ||||
-rw-r--r-- | eglib/gmain.h | 2 | ||||
-rw-r--r-- | hcid/dbus-adapter.c | 2 | ||||
-rw-r--r-- | hcid/dbus-hci.c | 16 | ||||
-rw-r--r-- | hcid/dbus-rfcomm.c | 2 | ||||
-rw-r--r-- | hcid/dbus-security.c | 2 | ||||
-rw-r--r-- | hcid/dbus-service.c | 6 | ||||
-rw-r--r-- | hcid/dbus-test.c | 10 | ||||
-rw-r--r-- | hcid/hcid.h | 3 | ||||
-rw-r--r-- | hcid/security.c | 2 |
11 files changed, 81 insertions, 82 deletions
diff --git a/common/dbus.c b/common/dbus.c index bdcb1684..b6d852c3 100644 --- a/common/dbus.c +++ b/common/dbus.c @@ -453,7 +453,7 @@ static void remove_watch(DBusWatch *watch, void *data) dbus_watch_set_data(watch, NULL, NULL); if (info) { - g_io_remove_watch(info->watch_id); + g_source_remove(info->watch_id); g_io_channel_unref(info->io); dbus_connection_unref(info->conn); free(info); @@ -489,7 +489,7 @@ static void timeout_handler_free(void *data) if (!handler) return; - g_timeout_remove(handler->id); + g_source_remove(handler->id); free(handler); } diff --git a/eglib/gmain.c b/eglib/gmain.c index 8566265c..ea3adebd 100644 --- a/eglib/gmain.c +++ b/eglib/gmain.c @@ -174,21 +174,11 @@ static GMainContext *g_main_context_default() return default_context; } -gboolean g_source_remove(guint tag) +static gboolean g_io_remove_watch(GMainContext *context, guint id) { - /* Not implemented yet */ - return FALSE; -} - -void g_io_remove_watch(guint id) -{ - GMainContext *context = g_main_context_default(); GSList *l; struct watch *w; - if (!context) - return; - for (l = context->watches; l != NULL; l = l->next) { w = l->data; @@ -198,7 +188,7 @@ void g_io_remove_watch(guint id) context->watches = g_slist_remove(context->watches, w); watch_free(w); - return; + return TRUE; } for (l = context->proc_watches; l != NULL; l = l->next) { @@ -210,8 +200,64 @@ void g_io_remove_watch(guint id) context->proc_watches = g_slist_remove(context->proc_watches, w); watch_free(w); - return; + return TRUE; + } + + return FALSE; +} + +static gboolean g_timeout_remove(GMainContext *context, const guint id) +{ + GSList *l; + struct timeout *t; + + l = context->timeouts; + + while (l) { + t = l->data; + l = l->next; + + if (t->id != id) + continue; + + context->timeouts = g_slist_remove(context->timeouts, t); + free(t); + + return TRUE; } + + l = context->proc_timeouts; + + while (l) { + t = l->data; + l = l->next; + + if (t->id != id) + continue; + + context->proc_timeouts = g_slist_remove(context->proc_timeouts, t); + free(t); + + return TRUE; + } + + return FALSE; +} + +gboolean g_source_remove(guint tag) +{ + GMainContext *context = g_main_context_default(); + + if (!context) + return FALSE; + + if (g_io_remove_watch(context, tag)) + return TRUE; + + if (g_timeout_remove(context, tag)) + return TRUE; + + return FALSE; } int watch_prio_cmp(struct watch *w1, struct watch *w2) @@ -498,48 +544,6 @@ guint g_timeout_add(guint interval, GSourceFunc function, gpointer data) return t->id; } -gint g_timeout_remove(const guint id) -{ - GMainContext *context = g_main_context_default(); - GSList *l; - struct timeout *t; - - if (!context) - return -1; - - l = context->timeouts; - - while (l) { - t = l->data; - l = l->next; - - if (t->id != id) - continue; - - context->timeouts = g_slist_remove(context->timeouts, t); - free(t); - - return 0; - } - - l = context->proc_timeouts; - - while (l) { - t = l->data; - l = l->next; - - if (t->id != id) - continue; - - context->proc_timeouts = g_slist_remove(context->proc_timeouts, t); - free(t); - - return 0; - } - - return -1; -} - guint g_idle_add(GSourceFunc func, gpointer user_data) { /* Not implemented */ diff --git a/eglib/gmain.h b/eglib/gmain.h index 9c50b050..7080c687 100644 --- a/eglib/gmain.h +++ b/eglib/gmain.h @@ -100,14 +100,12 @@ guint g_io_add_watch(GIOChannel *channel, GIOCondition condition, guint g_io_add_watch_full(GIOChannel *channel, gint priority, GIOCondition condition, GIOFunc func, gpointer user_data, GDestroyNotify notify); -void g_io_remove_watch(guint id); GMainLoop *g_main_loop_new(GMainContext *context, gboolean is_running); void g_main_loop_run(GMainLoop *loop); void g_main_loop_quit(GMainLoop *loop); void g_main_loop_unref(GMainLoop *loop); guint g_timeout_add(guint interval, GSourceFunc function, gpointer data); -gint g_timeout_remove(const guint id); gboolean g_source_remove(guint tag); guint g_idle_add(GSourceFunc func, gpointer user_data); diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c index 50a28a57..8699499a 100644 --- a/hcid/dbus-adapter.c +++ b/hcid/dbus-adapter.c @@ -539,7 +539,7 @@ static DBusHandlerResult adapter_set_discoverable_to(DBusConnection *conn, return DBUS_HANDLER_RESULT_NEED_MEMORY; if (adapter->timeout_id) { - g_timeout_remove(adapter->timeout_id); + g_source_remove(adapter->timeout_id); adapter->timeout_id = 0; } diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c index 165eb142..25d6e01e 100644 --- a/hcid/dbus-hci.c +++ b/hcid/dbus-hci.c @@ -370,7 +370,7 @@ static void reply_pending_requests(const char *path, struct adapter *adapter) (name_cb_t) create_bond_req_exit, adapter); if (adapter->bonding->io_id) - g_io_remove_watch(adapter->bonding->io_id); + g_source_remove(adapter->bonding->io_id); g_io_channel_close(adapter->bonding->io); bonding_request_free(adapter->bonding); adapter->bonding = NULL; @@ -477,7 +477,7 @@ int unregister_adapter_path(const char *path) if (adapter->pending_dc) { error_no_such_adapter(adapter->pending_dc->conn, adapter->pending_dc->msg); - g_timeout_remove(adapter->pending_dc->timeout_id); + g_source_remove(adapter->pending_dc->timeout_id); dc_pending_timeout_cleanup(adapter); } @@ -739,7 +739,7 @@ int hcid_dbus_stop_device(uint16_t id) } /* cancel pending timeout */ if (adapter->timeout_id) { - g_timeout_remove(adapter->timeout_id); + g_source_remove(adapter->timeout_id); adapter->timeout_id = 0; } @@ -956,7 +956,7 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, (name_cb_t) create_bond_req_exit, adapter); if (adapter->bonding->io_id) - g_io_remove_watch(adapter->bonding->io_id); + g_source_remove(adapter->bonding->io_id); g_io_channel_close(adapter->bonding->io); bonding_request_free(adapter->bonding); adapter->bonding = NULL; @@ -1744,7 +1744,7 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, (name_cb_t) create_bond_req_exit, adapter); if (adapter->bonding->io_id) - g_io_remove_watch(adapter->bonding->io_id); + g_source_remove(adapter->bonding->io_id); g_io_channel_close(adapter->bonding->io); bonding_request_free(adapter->bonding); adapter->bonding = NULL; @@ -1760,7 +1760,7 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, else send_message_and_unref(adapter->pending_dc->conn, reply); - g_timeout_remove(adapter->pending_dc->timeout_id); + g_source_remove(adapter->pending_dc->timeout_id); dc_pending_timeout_cleanup(adapter); } @@ -1944,7 +1944,7 @@ void hcid_dbus_setscan_enable_complete(bdaddr_t *local) } if (adapter->timeout_id) { - g_timeout_remove(adapter->timeout_id); + g_source_remove(adapter->timeout_id); adapter->timeout_id = 0; } @@ -2036,7 +2036,7 @@ void create_bond_req_exit(const char *name, struct adapter *adapter) g_io_channel_close(adapter->bonding->io); if (adapter->bonding->io_id) - g_io_remove_watch(adapter->bonding->io_id); + g_source_remove(adapter->bonding->io_id); bonding_request_free(adapter->bonding); adapter->bonding = NULL; } diff --git a/hcid/dbus-rfcomm.c b/hcid/dbus-rfcomm.c index 5a893898..515a55aa 100644 --- a/hcid/dbus-rfcomm.c +++ b/hcid/dbus-rfcomm.c @@ -102,7 +102,7 @@ static void rfcomm_node_free(struct rfcomm_node *node) if (node->owner) free(node->owner); if (node->io) { - g_io_remove_watch(node->io_id); + g_source_remove(node->io_id); g_io_channel_unref(node->io); } if (node->conn) diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c index 98ca1df5..0a283124 100644 --- a/hcid/dbus-security.c +++ b/hcid/dbus-security.c @@ -74,7 +74,7 @@ static void passkey_agent_free(struct passkey_agent *agent) } if (agent->timeout) - g_timeout_remove(agent->timeout); + g_source_remove(agent->timeout); if (!agent->exited) release_agent(agent); diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c index ac3e4cc8..e1be0797 100644 --- a/hcid/dbus-service.c +++ b/hcid/dbus-service.c @@ -293,7 +293,7 @@ static DBusHandlerResult service_filter(DBusConnection *conn, } if (service->startup_timer) { - g_timeout_remove(service->startup_timer); + g_source_remove(service->startup_timer); service->startup_timer = 0; } else debug("service_filter: timeout was already removed!"); @@ -322,7 +322,7 @@ static void abort_startup(struct service *service, DBusConnection *conn, int eco dbus_connection_remove_filter(get_dbus_connection(), service_filter, service); - g_timeout_remove(service->startup_timer); + g_source_remove(service->startup_timer); service->startup_timer = 0; if (service->action) { @@ -350,7 +350,7 @@ static void service_died(GPid pid, gint status, gpointer data) abort_startup(service, get_dbus_connection(), ECANCELED); if (service->shutdown_timer) { - g_timeout_remove(service->shutdown_timer); + g_source_remove(service->shutdown_timer); service->shutdown_timer = 0; } diff --git a/hcid/dbus-test.c b/hcid/dbus-test.c index 1085d5c8..78766a49 100644 --- a/hcid/dbus-test.c +++ b/hcid/dbus-test.c @@ -156,7 +156,7 @@ static void audit_requestor_exited(const char *name, struct audit *audit) g_io_channel_close(audit->io); } if (audit->timeout) - g_timeout_remove(audit->timeout); + g_source_remove(audit->timeout); audit_free(audit); } @@ -282,7 +282,7 @@ static gboolean l2raw_data_callback(GIOChannel *io, GIOCondition cond, struct au return TRUE; if (audit->timeout) { - g_timeout_remove(audit->timeout); + g_source_remove(audit->timeout); audit->timeout = 0; } @@ -311,7 +311,7 @@ static gboolean l2raw_data_callback(GIOChannel *io, GIOCondition cond, struct au return TRUE; if (audit->timeout) { - g_timeout_remove(audit->timeout); + g_source_remove(audit->timeout); audit->timeout = 0; } @@ -325,7 +325,7 @@ static gboolean l2raw_data_callback(GIOChannel *io, GIOCondition cond, struct au failed: if (audit->timeout) { - g_timeout_remove(audit->timeout); + g_source_remove(audit->timeout); audit->timeout = 0; } @@ -546,7 +546,7 @@ static DBusHandlerResult cancel_audit_remote_device(DBusConnection *conn, g_io_channel_close(audit->io); } if (audit->timeout) - g_timeout_remove(audit->timeout); + g_source_remove(audit->timeout); audits = g_slist_remove(audits, audit); name_listener_remove(audit->conn, audit->requestor, diff --git a/hcid/hcid.h b/hcid/hcid.h index f8d58fc4..91b311f8 100644 --- a/hcid/hcid.h +++ b/hcid/hcid.h @@ -23,9 +23,6 @@ * */ -#define g_io_remove_watch g_source_remove -#define g_timeout_remove g_source_remove - #include <time.h> #include <sys/types.h> diff --git a/hcid/security.c b/hcid/security.c index ca984852..e14b98e9 100644 --- a/hcid/security.c +++ b/hcid/security.c @@ -882,7 +882,7 @@ void stop_security_manager(int hdev) info("Stopping security manager %d", hdev); - g_io_remove_watch(io_data[hdev].watch_id); + g_source_remove(io_data[hdev].watch_id); g_io_channel_unref(io_data[hdev].channel); io_data[hdev].watch_id = -1; io_data[hdev].channel = NULL; |