diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-10 19:34:46 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-10 19:34:46 +0200 |
commit | ba9edaa568088900145bbd1004c864b7d408c38d (patch) | |
tree | d6bd8b68d9d9ade9b3cb1e4d484751badc3c9bbe /protocols/events_glib.c | |
parent | 67b6766489f1b9b5f2249659b0ddf260e6f8f51b (diff) |
Moved everything to the BitlBee event handling API.
Diffstat (limited to 'protocols/events_glib.c')
-rw-r--r-- | protocols/events_glib.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/protocols/events_glib.c b/protocols/events_glib.c index f3b27565..5a72b13c 100644 --- a/protocols/events_glib.c +++ b/protocols/events_glib.c @@ -46,24 +46,39 @@ #include "proxy.h" typedef struct _GaimIOClosure { - GaimInputFunction function; + b_event_handler function; guint result; gpointer data; } GaimIOClosure; +static GMainLoop *loop; + +void b_main_init() +{ + loop = g_main_new( FALSE ); +} + +void b_main_run() +{ + g_main_run( loop ); +} + +void b_main_quit() +{ + g_main_quit( loop ); +} + static gboolean gaim_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) { GaimIOClosure *closure = data; - GaimInputCondition gaim_cond = 0; + b_input_condition gaim_cond = 0; if (condition & GAIM_READ_COND) gaim_cond |= GAIM_INPUT_READ; if (condition & GAIM_WRITE_COND) gaim_cond |= GAIM_INPUT_WRITE; - closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond); - - return TRUE; + return closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond); } static void gaim_io_destroy(gpointer data) @@ -71,7 +86,7 @@ static void gaim_io_destroy(gpointer data) g_free(data); } -gint gaim_input_add(gint source, GaimInputCondition condition, GaimInputFunction function, gpointer data) +gint b_input_add(gint source, b_input_condition condition, b_event_handler function, gpointer data) { GaimIOClosure *closure = g_new0(GaimIOClosure, 1); GIOChannel *channel; @@ -93,8 +108,18 @@ gint gaim_input_add(gint source, GaimInputCondition condition, GaimInputFunction return closure->result; } -void gaim_input_remove(gint tag) +gint b_timeout_add(gint timeout, b_event_handler func, gpointer data) +{ + return g_timeout_add(timeout, func, data); +} + +void b_event_remove(gint tag) { if (tag > 0) g_source_remove(tag); } + +gboolean b_event_remove_by_data(gpointer data) +{ + return g_source_remove_by_user_data(data); +} |