/* Set up the new SMS callback */
gn_data_clear(&l->phone_state->data);
l->phone_state->data.on_sms = phonemgr_listener_new_sms_cb;
l->phone_state->data.user_data = l;
if (gn_sm_functions (GN_OP_OnSMS, &l->phone_state->data,
&l->phone_state->state) == GN_ERR_NONE) {
l->supports_sms_notif = TRUE;
}
And the callback would look like:
static gn_error
phonemgr_listener_new_sms_cb (gn_sms *message, struct gn_statemachine *state,
void *user_data)
{
PhonemgrListener *l = (PhonemgrListener *) user_data;
gn_sms *msg;
/* The message is allocated on the stack in the driver, so copy it */
msg = g_memdup (message, sizeof (gn_sms));
g_async_queue_push (l->queue, msg);
g_idle_add ((GSourceFunc) phonemgr_listener_push, l);
return GN_ERR_NONE;
}
PhonemgrListener is a GObject, and this sort of construct is usual in
signal/callback driven applications.