gnokii-users
[Top][All Lists]
Advanced

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

Re: GN_OP_OnSMS in nk6510


From: Bastien Nocera
Subject: Re: GN_OP_OnSMS in nk6510
Date: Wed, 04 Jul 2007 12:36:56 +0100

On Wed, 2007-07-04 at 13:18 +0200, Pawel Kot wrote:
> Hi,
> 
> On 7/4/07, Bastien Nocera <address@hidden> wrote:
> > On Tue, 2007-07-03 at 21:04 +0200, Pawel Kot wrote:
> > > Hi,
> > >
> > > On 7/3/07, Bastien Nocera <address@hidden> wrote:
> > > > Is there any reason why GN_OP_OnSMS is disabled in the nk6510 driver?
> > >
> > > Well, there are few possibilities. Either nobody tested it or it didn't 
> > > work.
> > >
> > > > Finally, I want to be notified on calls (and check battery info
> > > > regularly) as well, and I can't seem to find a good example of using
> > > > both GN_OP_SetCallNotification and GN_OP_OnSMS. Are they exclusive, or
> > > > can I set both notifications at once?
> > >
> > > You can use both. But the subscription for FBUS are done by
> > > NK6510_Subscribe(). This way phone should send you an unsolicited
> > > frame with an incoming event (of given type).
> >
> > I just realised the callbacks were pretty useless to me, as they don't
> > push any sort of user provided pointer in the callback.
> 
> I fail to understand why would you need this.

Because I don't use horrible horrible globals, and I want to provide my
own callback data. As in:

/* 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.

-- 
Bastien Nocera <address@hidden> 





reply via email to

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