Re: gnome-vfs/GIOChannel for parsing



On Mon, 2003-02-17 at 12:22, David Helder wrote:
> The thing that bugs me with GIOChannel is that there is no easy way to
> derive from it correctly.  It's implementions, GUnixIOChannel and
> GWin32IOChannel, are hidden.  So, I can't include the struct as the first
> member of my child struct like I normally would.  I could delegate using a
> sort of container GIOChannel, but this seems hacky and I'm not sure if
> watches would work right.  Has anyone been able to derive from GIOChannel?
> What did you do?

glib2 makes it a lot easier to write your own GIOChannel
implmentations.  In libsoup we have a GIOChannel for SSL.  Basically we
take an existing IO channel, get the fd and such from it and set up an
SSL connection.  We implement all of the IO channel funcs (GIOFuncs;
read, write, seek, close, create watch, free, set flags, get flags).  We
also create a watch structure, which gets instantiated in the
create_watch method and we implement the GSourceFuncs for that as well
(prepare, check, dispatch, finalize).

That was a crappy description, I realize.  Basically you can derive from
the base GIOChannel and write your own implementation.  If you want to
derive from the GUnixIOChannel class, your best bet is probably to take
an existing GIOChannel as an argument to yours and marshal the calls
yourself.  That's what we do for things like the set_flags and get_flags
methods on the SSL one.

Check out the implementation:
http://cvs.gnome.org/bonsai/cvsblame.cgi?file=libsoup%2Flibsoup/soup-openssl.c&rev=&root=/cvs/gnome

Joe




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]