SUPL Push API Tutorial

This topic describes how the Symbian SUPL WAP Push plug-in uses the SUPL Push API (deprecated). Device creators can use this information if they want to implement their own SUPL INIT push plug-in.

Read SUPL Protocol Module Overview and SUPL Push API before reading this document.

Note: From Symbian^3 the SUPL Protocol Module is deprecated. For the preferred way of using SUPL see SUPL Proxy Protocol Module.

This document describes how the SUPL WAP Push plug-in uses the SUPL Push API.

Device creators only need to use the SUPL Push API to write their own SUPL INIT message handlers.

The Symbian WAP Push plug-in derives from CContentHandlerBase, the base class of push message handlers. It also implements MLbsSuplPushObserver to receive notification of SUPL INIT message delivery to the SUPL Protocol Module.

See <LBS_SOURCE_ROOT>/LbsSuplProtocolModule/SuplWapPush for the code for the WAP Push plug-in.

  1. Define a SUPL INIT handler class The Symbian WAP Push plug-in derives from CContentHandlerBase to receive SUPL WAP Push messages. It implements MLbsSuplPushObserver to receive notification of successful message delivery to the SUPL Protocol Module.
    
    NONSHARABLE_CLASS(CLbsSuplWapPush) : public CContentHandlerBase, public MLbsSuplPushObserver
        {
    public:
        static CLbsSuplWapPush* NewL();
        virtual ~CLbsSuplWapPush();
        
        virtual void OnSuplInitComplete(TLbsSuplPushChannel aChannel, TLbsSuplPushRequestId aReqId, 
                TInt aError, TInt aReserved);
    
        // From CPushHandlerBase
        virtual void HandleMessageL(CPushMessage* aPushMsg);
        
        // Other methods of CContentHandlerBase omitted here...
    
    };
    
    The plug-in's ConstructL() creates a new instance of CLbsSuplPush.
    
    // This handler uses the WAP channel
    iSuplPush = CLbsSuplPush::NewL(ELbsSuplPushChannelWAP, *this);
    
  2. Implement HandleMessageL() When the WAP Push plug-in receives a WAP Push message, it extracts the message body and calls CLbsSuplPush::SuplInit().
    
    void CLbsSuplWapPush::HandleMessageL(CPushMessage* aPushMsg)
        {
        LBSLOG(ELogP3, "SUPL WAP Push : CLbsSuplWapPush::HandleMessageL");
        if(aPushMsg)
            {
            TPtrC8 body;
            TBool hasBody=aPushMsg->GetMessageBody(body);
            if(hasBody)
                {
                TLbsSuplPushRequestId reqId;
                TInt err=iSuplPush->SuplInit(reqId, body, 0);
                if(KErrNone==err)
                    {
                    LBSLOG2(ELogP3,"SUPL WAP Push : Started to deliver the message, reqId=%d", reqId);
                    delete aPushMsg;
                    return;
                    }
                else
                    {
                    LBSLOG2(ELogP3,"SUPL WAP Push : CLbsSuplPush::SuplInit failed, err=%d", err);
                    }
                }
            else
                {
                LBSLOG(ELogP3, "SUPL WAP Push : Empty message body, the message is skipped");
                }
            delete aPushMsg;
            }
        else
            {
            LBSLOG(ELogP3, "SUPL WAP Push : Null message pointer, the message is skipped");
            }
     iPluginKiller->KillPushPlugin();
        }
    
  3. Implement MLbsSuplPushObserver::OnSuplInitComplete() When the SUPL Protocol Module processes the SUPL INIT message, the plug-in's MLbsSuplPushObserver::OnSuplInitComplete() method is called. The parameter aError may indicate a timeout or another error condition. The WAP Push plug-in is destroyed by the WAP Push Framework. Another instance of CLbsSuplWapPush is created by the framework to handle the next SUPL INIT received by WAP Push.
    
    void CLbsSuplWapPush::OnSuplInitComplete(TLbsSuplPushChannel /*aChannel*/, TLbsSuplPushRequestId aReqId, 
                TInt aError, TInt /*aReserved*/)
        {
        if(aError==KErrNone)
            {
            LBSLOG2(ELogP3,"SUPL WAP Push : Message delivered successfully, reqId=%d", aReqId);
            }
        else
            {
            LBSLOG3(ELogP3,"SUPL WAP Push : Message delivery failed, reqId=%d, err=%d", aReqId, aError);
            }
         iPluginKiller->KillPushPlugin();
        }
    
Related concepts
SUPL Push API