Commit 8e94cc70 authored by Kai Vehmanen's avatar Kai Vehmanen

Fixes to the su_glib API, updated the su_glib unit test to use g_main_loop_run().

darcs-hash:20060913150519-7659e-00229e73bffd067697620698a2e3dbbd2da07842.gz
parent cc1ce774
......@@ -50,7 +50,7 @@ libsofia-sip-ua-glib:
- Added sofia-sip/su_glib.h. The old sofia-sip/su_source.h is
deprecated, but still present. Similarly the functions su_root_source()
and su_root_source_create() have been deprecated and replaced with
su_glib_root_create() and su_glib_root_source().
su_glib_root_create() and su_glib_root_gsource().
- Added nua_glib::cancel-answered signal - emitted when the stack
receives an answer to previously sent CANCEL.
- This release is ABI/API compatible with libsofia-sip-ua-glib of 1.12.0. Note,
......
......@@ -42,7 +42,7 @@
SOFIA_BEGIN_DECLS
SOFIAPUBFUN su_root_t *su_glib_root_create(su_root_magic_t *) __attribute__((__malloc__));
SOFIAPUBFUN GSource *su_glib_root_source(su_root_t *);
SOFIAPUBFUN GSource *su_glib_root_gsource(su_root_t *);
SOFIA_END_DECLS
......
......@@ -48,7 +48,7 @@ Below is a simple example of how to use su-glib:
/* ... initialize other Sofia-SIP modules/functrions */
/* run the glib mainloop */
g_main_loop_unref(ptr);
g_main_loop_run(ptr);
@endcode
@section su_glib_todo Todo
......
......@@ -227,12 +227,28 @@ typedef struct _SuSource
#define enter (void)0
#endif
/*=============== Public function definitions ===============*/
/** Create a root that uses GSource as reactor */
su_root_t *su_root_source_create(su_root_magic_t *magic)
su_root_t *su_glib_root_create(su_root_magic_t *magic)
{
return su_root_create_with_port(magic, su_source_create());
}
/** Deprecated */
su_root_t *su_root_source_create(su_root_magic_t *magic)
{
return su_glib_root_create(magic);
}
GSource *su_glib_root_gsource(su_root_t *root)
{
g_assert(root);
return su_root_gsource(root);
}
/*=============== Private function definitions ===============*/
/**@internal
*
* Allocates and initializes a reactor and message port object.
......
......@@ -52,7 +52,7 @@ struct pinger;
#include "sofia-sip/su_wait.h"
#include "sofia-sip/su_log.h"
#include "sofia-sip/su_source.h"
#include "sofia-sip/su_glib.h"
struct pinger {
enum { PINGER = 1, PONGER = 2 } const sort;
......@@ -73,6 +73,7 @@ struct pinger {
short opt_family = AF_INET;
short opt_verbatim = 0;
short opt_singlethread = 0;
GMainLoop *global_gmainloop = NULL;
static su_socket_t udpsocket(void)
{
......@@ -249,9 +250,10 @@ do_recv(struct pinger *p, su_wait_t *w, void *p0)
void
do_exit(struct pinger *x, su_timer_t *t, void *x0)
{
g_assert(global_gmainloop);
if (opt_verbatim)
printf("do_exit at %s\n", snow(su_now()));
su_root_break(su_timer_root(t));
g_main_loop_quit(global_gmainloop);
}
int
......@@ -461,11 +463,14 @@ int main(int argc, char *argv[])
time_test();
root = su_root_source_create(NULL);
global_gmainloop = g_main_loop_new(NULL, FALSE);
g_assert(global_gmainloop);
root = su_glib_root_create(NULL);
if (!root) perror("su_root_glib_create"), exit(1);
if (!g_source_attach(su_root_gsource(root), NULL))
if (!g_source_attach(su_glib_root_gsource(root), g_main_loop_get_context(global_gmainloop)))
perror("g_source_attach"), exit(1);
su_root_threading(root, 0 && !opt_singlethread);
......@@ -485,7 +490,7 @@ int main(int argc, char *argv[])
init_ping, 0);
su_msg_send(start_msg);
su_root_run(root);
g_main_loop_run(global_gmainloop);
su_clone_wait(root, ping);
su_clone_wait(root, pong);
......@@ -498,6 +503,8 @@ int main(int argc, char *argv[])
}
su_root_destroy(root);
g_main_loop_unref(global_gmainloop), global_gmainloop = NULL;
if (opt_verbatim)
printf("%s exiting\n", argv0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment