From: Sebastian Reichel <s...@ring0.de> * Add rewind option * watch PRI in addition to IN
This is needed to watch some sysfs files on the N900, for example this one: /sys/devices/platform/gpio-switch/proximity/state Signed-off-by: Sebastian Reichel <s...@ring0.de> --- libfsobasics/fsobasics/utilities.vala | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libfsobasics/fsobasics/utilities.vala b/libfsobasics/fsobasics/utilities.vala index 1a2008b..21bbcab 100644 --- a/libfsobasics/fsobasics/utilities.vala +++ b/libfsobasics/fsobasics/utilities.vala @@ -523,14 +523,16 @@ namespace FsoFramework { namespace Async { private GLib.IOChannel channel; private ActionFunc actionfunc; private char[] buffer; + private bool rewind; - public ReactorChannel( int fd, owned ActionFunc actionfunc, size_t bufferlength = 512 ) + public ReactorChannel( int fd, owned ActionFunc actionfunc, size_t bufferlength = 512, bool rewind = false ) { assert( fd > -1 ); channel = new GLib.IOChannel.unix_new( fd ); - watch = channel.add_watch( GLib.IOCondition.IN | GLib.IOCondition.HUP, onActionFromChannel ); + watch = channel.add_watch( GLib.IOCondition.IN | GLib.IOCondition.PRI | GLib.IOCondition.HUP, onActionFromChannel ); this.fd = fd; this.actionfunc = actionfunc; + this.rewind = rewind; buffer = new char[ bufferlength ]; } @@ -559,10 +561,12 @@ namespace FsoFramework { namespace Async { return false; } - if ( ( condition & IOCondition.IN ) == IOCondition.IN ) + if ( ( ( condition & IOCondition.IN ) == IOCondition.IN ) || + ( ( condition & IOCondition.PRI ) == IOCondition.PRI ) ) { assert( fd != -1 ); assert( buffer != null ); + if( rewind ) Posix.lseek(fd, 0, Posix.SEEK_SET); ssize_t bytesread = Posix.read( fd, buffer, buffer.length ); actionfunc( buffer, bytesread ); return true; -- 1.7.1 _______________________________________________ Smartphones-userland mailing list Smartphones-userland@linuxtogo.org http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/smartphones-userland