/*
 * 
 *
 * Note that NULL state is called here CLIENT_PUSH_NULL_STATE. Condition 1
 * means that an action is unconditional.
 *
 * 
 */

STATE_NAME(CLIENT_PUSH_NULL_STATE)
STATE_NAME(CLIENT_PUSH_RECEIVING)

ROW(CLIENT_PUSH_NULL_STATE,
    TR_Invoke_Ind,
    current_event->u.TR_Invoke_Ind.tcl == 1 && pdu->type == ConfirmedPush,
    {
        pm->transaction_id = current_event->u.TR_Invoke_Ind.handle;
        indicate_confirmedpush(sm, pdu, pm->client_push_id);
    },
    CLIENT_PUSH_RECEIVING)

ROW(CLIENT_PUSH_RECEIVING,
    S_ConfirmedPush_Res,
    1,
    {
		WAPEvent *wtp_event;

		/* Send TR-Invoke.res to WTP */
		wtp_event = wap_event_create(TR_Invoke_Res);
		wtp_event->u.TR_Invoke_Res.handle = pm->transaction_id;
		dispatch_to_wtp_init(wtp_event);
    },
    CLIENT_PUSH_NULL_STATE)

ROW(CLIENT_PUSH_RECEIVING,
    S_PushAbort_Req,
    1,
    {
        send_abort(current_event->u.S_PushAbort_Req.reason, pm->transaction_id);
        indicate_pushabort(pm, WSP_ABORT_USERREQ);
    },
    CLIENT_PUSH_NULL_STATE)


ROW(CLIENT_PUSH_RECEIVING,
    Abort_Event,
    1,
    {
        send_abort(current_event->u.Abort_Event.reason, pm->transaction_id);
        indicate_pushabort(pm, current_event->u.Abort_Event.reason);
    },
    CLIENT_PUSH_NULL_STATE)

ROW(CLIENT_PUSH_RECEIVING,
    TR_Abort_Ind,
    current_event->u.TR_Abort_Ind.abort_code == WSP_ABORT_DISCONNECT,
    {
        WAPEvent *wsp_event;
        
        wsp_event = wap_event_create(Disconnect_Event);
        wsp_event->u.Disconnect_Event.session_handle = pm->client_push_id;
        list_append(queue, wsp_event);
    },
    CLIENT_PUSH_NULL_STATE)

ROW(CLIENT_PUSH_RECEIVING,
    TR_Abort_Ind,
    current_event->u.TR_Abort_Ind.abort_code == WSP_ABORT_SUSPEND,
    {
        WAPEvent *wsp_event;
        
        wsp_event = wap_event_create(Suspend_Event);
        wsp_event->u.Suspend_Event.session_handle = pm->client_push_id;
        list_append(queue, wsp_event);
    },
    CLIENT_PUSH_NULL_STATE)

ROW(CLIENT_PUSH_RECEIVING,
    TR_Abort_Ind,
    current_event->u.TR_Abort_Ind.abort_code != WSP_ABORT_DISCONNECT  &&
    current_event->u.TR_Abort_Ind.abort_code != WSP_ABORT_SUSPEND,
    {
        indicate_pushabort(pm, current_event->u.Push_Abort.reason);
    },
    CLIENT_PUSH_NULL_STATE)

#undef STATE_NAME
#undef ROW



