⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcnotif.c

📁 彩信MMS的全部代码
💻 C
字号:
/*
 * Copyright (C) Obigo AB, 2002-2005.
 * All rights reserved.
 *
 * This software is covered by the license agreement between
 * the end user and Obigo AB, and may be 
 * used and copied only in accordance with the terms of the 
 * said agreement.
 *
 * Obigo AB assumes no responsibility or 
 * liability for any errors or inaccuracies in this software, 
 * or any consequential, incidental or indirect damage arising
 * out of the use of the software.
 *
 */

















#include "cansilib.h"   
#include "cmnconf.h"    
#include "cmntypes.h"   
#include "aapicmn.h"    
#include "gmem.h"       

#include "mmsconf.h"    
#include "mmstypes.h"   
#include "aapimms.h"    
#include "msig.h"       
#include "mmem.h"       
#include "mcpdu.h"      
#include "mcnotif.h"    
#include "mcpost.h"     
#include "mnotify.h"    
#include "mcpdu.h"      
#include "mmpduc.h"     
#include "mconfig.h"    
   

#define INDEX_MSG_TYPE_VALUE  1  



typedef struct StructNotifyRespQueue
{
    MmsNotifIndInfo *data;              
    struct StructNotifyRespQueue *next; 
} NotifyRespQueue;


typedef struct 
{
    CMN_BOOL        isSendingNotifyResp;    
    NotifyRespQueue *queue;                 
} FsmData;















static FsmData fsmData;


static void cohPushReceiveMain(MmsSignal *sig);
static void freeNotifIndInfo(MmsNotifIndInfo *p);
static void sendNextNotifyResp(MmsNotifIndInfo *data);






void cohPushReceiveInit(void)
{
    fsmData.isSendingNotifyResp = FALSE;
    fsmData.queue = NULL;

    mSignalRegisterDst(M_FSM_COH_PUSH_RECEIVE, cohPushReceiveMain);
    
    MMS_LOG_I(("MMS FSM COH PUSH RECEIVE: initialized\n"));
} 






static void cohPushReceiveMain(MmsSignal *sig)
{
    unsigned char *pdu;
    MmsSigCohPostResultParam *postResult;
    MmsMsrNotificationParam *msrParam;
    CMN_BOOL isPduOk = FALSE;

    switch (sig->type)
    {
    case MMS_SIG_COH_PUSH : 
        MMS_LOG_I(("MMS FSM COH PUSH RECEIVE: Received MMS_SIG_COH_PUSH\n"));

        
        pdu = (unsigned char *)sig->p_param;
        if ( mmsPduUnrecognized( pdu, sig->u_param2) )
        {
            MMS_LOG_I(("%s(%d): Unrecognized PDU!\n", __FILE__, __LINE__));
        }
        else if ( !mmsPduSanityCheck( pdu, sig->u_param2) )
        {
            MMS_LOG_I(("%s(%d): Badly formatted PDU!\n", __FILE__, __LINE__));
        }
        else if (pdu[INDEX_MSG_TYPE_VALUE] != MMS_M_NOTIFICATION_IND && 
            pdu[INDEX_MSG_TYPE_VALUE] != MMS_M_DELIVERY_IND && 
            pdu[INDEX_MSG_TYPE_VALUE] != MMS_M_READ_ORIG_IND)
        {
            MMS_LOG_I(("%s(%d): Not a valid pushed PDU!\n", __FILE__, __LINE__));
        }
        else
        {
            msrParam = M_CALLOC(sizeof(MmsMsrNotificationParam));

            msrParam->time = sig->u_param1;
            msrParam->type = pdu[INDEX_MSG_TYPE_VALUE];
            msrParam->isSmsBearer = (CMN_BOOL)sig->i_param;
            msrParam->size = sig->u_param2;
            msrParam->pdu = sig->p_param;
            M_SIGNAL_SENDTO_P( M_FSM_MSR_NOTIFY, MMS_SIG_MSR_NOTIFICATION, 
                msrParam);

            isPduOk = TRUE;
        } 

        if ( !isPduOk )
        {
            if (sig->p_param != NULL)
            {
                M_FREE(sig->p_param);
            } 

            MMSa_error(MMS_RESULT_COMM_ILLEGAL_PDU);
        } 
        break;        
    case MMS_SIG_COH_NOTIFY_RESP : 
        MMS_LOG_I(("MMS FSM COH PUSH RECEIVE: Received MMS_SIG_COH_NOTIFY_RESP\n"));

        sendNextNotifyResp((MmsNotifIndInfo *)sig->p_param);
        break;
    case MMS_SIG_COH_NOTIFY_POST_RSP : 
        MMS_LOG_I(("MMS FSM COH PUSH RECEIVE: Received MMS_SIG_COH_NOTIFY_POST_RSP\n"));

        postResult = (MmsSigCohPostResultParam *)sig->p_param;
        if (postResult->result != MMS_RESULT_OK)
        {
            MMS_LOG_I(("MMS FSM COH PUSH RECEIVE: Post failed (%d)\n", 
                postResult->result));
        } 

        cohPostFreeResultParam(postResult);
        sendNextNotifyResp(NULL);
        break;
    default:
        
        MMS_LOG_I(("MMS FSM COH PUSH RECEIVE: received unknown signal\n"));
        break;
    } 
    
    mSignalDelete(sig);
} 




void cohPushReceiveTerminate(void)
{
    NotifyRespQueue *tmp;
    
    mSignalDeregister(M_FSM_COH_PUSH_RECEIVE);
    while (fsmData.queue != NULL)
    {
        tmp = fsmData.queue;
        fsmData.queue = fsmData.queue->next;
        freeNotifIndInfo(tmp->data);
        M_FREE(tmp);
    } 
    
    MMS_LOG_I(("MMS FSM COH PUSH RECEIVE: terminated\n"));
} 






static void freeNotifIndInfo(MmsNotifIndInfo *p)
{
    if (p != NULL)
    {
        M_FREE(p->transactionId);
        M_FREE(p);
    } 
} 






static void sendNextNotifyResp(MmsNotifIndInfo *data)
{
    MmsNotifIndInfo *notifIndInfo = NULL;
    MmsNotifyRespInd notifyResp;
    NotifyRespQueue *tmp;
    NotifyRespQueue *aNew = NULL;
    MmsSigCohPostParam *post;
    UINT32  length;

    if (data == NULL)                   
    {
        if (fsmData.queue == NULL)
        {   
            fsmData.isSendingNotifyResp = FALSE;
            return;
        } 

        
        notifIndInfo = fsmData.queue->data;
        tmp = fsmData.queue->next;
        M_FREE(fsmData.queue);
        fsmData.queue = tmp;
    }
    else if (fsmData.isSendingNotifyResp == FALSE) 
    {
        notifIndInfo = data;
        fsmData.isSendingNotifyResp = TRUE;
    }
    else                                
    {
        tmp = fsmData.queue;
        while (tmp != NULL && tmp->next != NULL)
        {
            tmp = tmp->next;
        } 
        
        aNew = M_CALLOC(sizeof(NotifyRespQueue));
        aNew->data = data;
        aNew->next = NULL;
        if (fsmData.queue == NULL)
        {
            fsmData.queue = aNew;
        }
        else
        {   
            tmp->next = aNew;
        } 
        
        return;
    } 

    
    notifyResp.transactionId = notifIndInfo->transactionId;
    notifyResp.status = notifIndInfo->msgStatus;
    notifyResp.allowed = (MmsDeliveryReport)notifIndInfo->deliveryReportFlag;

    post = (MmsSigCohPostParam *)M_CALLOC(sizeof(MmsSigCohPostParam));
    post->isResponseRequested = TRUE;
    post->type = MMS_M_NOTIFY_RESP; 
    post->data.pdu.packet = createWspNotifyRespIndMsg( &notifyResp, &length, 
        (MmsVersion)cfgGetInt(MMS_CFG_PROXY_RELAY_VERSION));
    post->data.pdu.length = length;
    freeNotifIndInfo(notifIndInfo);

    if (post->data.pdu.packet == NULL)
    {
        MMS_LOG_I(("%s(%d): Couldn't create NotifyResp.ind!\n",
            __FILE__, __LINE__));
        M_FREE(post);
    }
    else
    {
        M_SIGNAL_SENDTO_IUUP( 
            M_FSM_COH_POST,             
            MMS_SIG_COH_POST,           
            0,                          
            M_FSM_COH_PUSH_RECEIVE,     
            MMS_SIG_COH_NOTIFY_POST_RSP,
            post);                      
    } 
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -