Hi,

Certainly there are many ways to deliver events between two modules.
Stefano has mentioned a multi-thread approach above, and I can also
share some of my ideas.

You can utilize glib's signal mechanism
(http://library.gnome.org/devel/gobject/stable/signal.html). You just
need to create a signal object for your event, and use
g_signal_connect in sofsip_cli to associate this signal to a callback
function; on the other hand, in GUI module, you can call g_signal_emit
when the corresponding event occurs. By passing necessary data to
g_signal_emit function, the callback function you define above will be
invoked. The callback will get these data from its parameters and
perform necessary tasks afterwards.

If you found the above description a bit abstract, you can also take a
look at a concrete example in telepathy-sofiasip
(http://sourceforge.net/projects/tp-sofiasip).

1. event-target.h/.c defines some signal objects
2. tpsip_connection_start_connecting() in sip-connection.c connects
these signals to callbacks
3. tpsip_connection_sofia_callback() in sip-connection-sofia.c emits
the corresponding signal when a nua event occurs.

Hope this will help.

BR

Tan

On Thu, Dec 11, 2008 at 10:07 AM, Stefano Sabatini
<[EMAIL PROTECTED]> wrote:
> On date Thursday 2008-12-11 11:22:16 +0800, mingcheng hu phoned this:
>> Hi, all
>>       I want to write a soft phone  .The idea is to modify
>> sofsip_cli(reusing the functionality in C),writing a GUI bindings for these
>> C functions.
>>       The problem is how do I send a event from GUI to sofia event callback?
>
> In your application you may need two threads, the application thread
> which manages user/GUI events, and eventually executes sofia-sip/NUA
> operations, and the sofia-sip/NUA thread which manages SIP events and
> eventually executes application specific operations (e.g., ring a
> tone, refresh a view).
>
> Every thread manages its own events, so you don't need to "send" events
> to the other thread, you just need to perform some action
> (e.g. nua_invite, nua_message) and this will create some corresponding
> event which will be managed by the other thread (e.g. a state change,
> an incoming nua_r_invite 180/200 event).
>
> HTH, regards.
> --
> Stefano Sabatini
> http://www.reilabs.com
>
> ------------------------------------------------------------------------------
> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
> The future of the web can't happen without you.  Join us at MIX09 to help
> pave the way to the Next Web now. Learn more and register at
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
> _______________________________________________
> Sofia-sip-devel mailing list
> Sofia-sip-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel
>



-- 
Best Regards
Tan Miaoqing
Software engineer, Maemo Software
Nokia Devices R&D
http://users.tkk.fi/~mitan

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to