[Top][All Lists]

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

Re: GN_OP_OnSMS in nk6510

From: Pawel Kot
Subject: Re: GN_OP_OnSMS in nk6510
Date: Wed, 4 Jul 2007 14:08:23 +0200


On 7/4/07, Bastien Nocera <address@hidden> wrote:
Because I don't use horrible horrible globals, and I want to provide my
own callback data. As in:

Globals are usually horrible but not always :)

/* Set up the new SMS callback */
                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.

Fair enough. Just one more question, why do you need this:
+       void *call_notification_user_data;
} at_driver_instance;

take care,
Pawel Kot

reply via email to

[Prev in Thread] Current Thread [Next in Thread]