aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2009-10-11 00:57:26 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2009-10-11 00:57:26 +0100
commitc5c18c155cfdc3edcbd764633761d33e3c5992a3 (patch)
tree1473c17473c26af70946f00ed06e247e79850789
parente046390da36e369c94af607fdedfe7b9f99d9e47 (diff)
Hacked up a B_EV_FLAG_FORCE_REPEAT event handler flag to make libpurple
happy.
-rw-r--r--lib/events.h4
-rw-r--r--lib/events_glib.c9
-rw-r--r--lib/events_libevent.c4
-rw-r--r--protocols/purple/purple.c2
4 files changed, 15 insertions, 4 deletions
diff --git a/lib/events.h b/lib/events.h
index 5bf2cfd8..fa30cf27 100644
--- a/lib/events.h
+++ b/lib/events.h
@@ -48,7 +48,9 @@
the given callback function. */
typedef enum {
B_EV_IO_READ = 1 << 0,
- B_EV_IO_WRITE = 1 << 1
+ B_EV_IO_WRITE = 1 << 1,
+ B_EV_FLAG_FORCE_ONCE = 1 << 16,
+ B_EV_FLAG_FORCE_REPEAT = 1 << 17,
} b_input_condition;
typedef gboolean (*b_event_handler)(gpointer data, gint fd, b_input_condition cond);
diff --git a/lib/events_glib.c b/lib/events_glib.c
index 2260ec4e..d6ac82cc 100644
--- a/lib/events_glib.c
+++ b/lib/events_glib.c
@@ -48,6 +48,7 @@
typedef struct _GaimIOClosure {
b_event_handler function;
gpointer data;
+ guint flags;
} GaimIOClosure;
static GMainLoop *loop = NULL;
@@ -86,7 +87,12 @@ static gboolean gaim_io_invoke(GIOChannel *source, GIOCondition condition, gpoin
if( !st )
event_debug( "Returned FALSE, cancelling.\n" );
- return st;
+ if (closure->flags & B_EV_FLAG_FORCE_ONCE)
+ return FALSE;
+ else if (closure->flags & B_EV_FLAG_FORCE_REPEAT)
+ return TRUE;
+ else
+ return st;
}
static void gaim_io_destroy(gpointer data)
@@ -104,6 +110,7 @@ gint b_input_add(gint source, b_input_condition condition, b_event_handler funct
closure->function = function;
closure->data = data;
+ closure->flags = condition;
if (condition & B_EV_IO_READ)
cond |= GAIM_READ_COND;
diff --git a/lib/events_libevent.c b/lib/events_libevent.c
index b52a5dd3..43d770ea 100644
--- a/lib/events_libevent.c
+++ b/lib/events_libevent.c
@@ -59,6 +59,7 @@ struct b_event_data
gint timeout;
b_event_handler function;
void *data;
+ guint flags;
};
void b_main_init()
@@ -149,7 +150,7 @@ static void b_event_passthrough( int fd, short event, void *data )
/* This event was killed already, don't touch it! */
return;
}
- else if( !st )
+ else if( !st && !( b_ev->flags & B_EV_FLAG_FORCE_REPEAT ) )
{
event_debug( "Handler returned FALSE: " );
b_event_remove( id_cur );
@@ -211,6 +212,7 @@ gint b_input_add( gint fd, b_input_condition condition, b_event_handler function
g_hash_table_insert( write_hash, &b_ev->evinfo.ev_fd, b_ev );
}
+ b_ev->flags = condition;
g_hash_table_insert( id_hash, &b_ev->id, b_ev );
return b_ev->id;
}
diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c
index 08c14edf..9ef70bd3 100644
--- a/protocols/purple/purple.c
+++ b/protocols/purple/purple.c
@@ -69,7 +69,7 @@ static guint prplcb_ev_timeout_add( guint interval, GSourceFunc func, gpointer u
static guint prplcb_ev_input_add( int fd, PurpleInputCondition cond, PurpleInputFunction func, gpointer udata )
{
- return (guint) b_input_add( fd, cond, (b_event_handler) func, udata );
+ return (guint) b_input_add( fd, cond | B_EV_FLAG_FORCE_REPEAT, (b_event_handler) func, udata );
}
static PurpleEventLoopUiOps glib_eventloops =