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

📄 mreceive.c

📁 彩信MMS的全部代码
💻 C
📖 第 1 页 / 共 2 页
字号:
            if ((MmsResult)sig->i_param == MMS_RESULT_OK && mHeader != NULL)
            {    
                freeMmsNotification(&mHeader->notification); 
                M_FREE(mHeader); 
            }  
        }
        else if ((MmsResult)sig->i_param != MMS_RESULT_OK)
        {
            ret = (MmsResult)sig->i_param;
        } 
        else if ((MmsMsgType)sig->u_param1 != MMS_MSG_NOTIFICATION)
        {
            MMS_LOG_I(("%s(%d): Wrong PDU type (%d).\n", 
                __FILE__, __LINE__, (int)sig->u_param1));
            ret = MMS_RESULT_MESSAGE_CORRUPT;
        }
        else if (mHeader == NULL || mHeader->notification.contentLocation == NULL)
        {
            MMS_LOG_I(("%s(%d): Notification missing Content-location (%d,%s).\n", 
                __FILE__, __LINE__, mHeader, 
                mHeader == NULL ? "" : 
                    mHeader->notification.contentLocation == NULL ? "NULL" : 
                        mHeader->notification.contentLocation));
            ret = MMS_RESULT_MESSAGE_CORRUPT;
        }
        else if ((ret = msgPreparationCheck( mHeader->notification.length, 
            &msgId)) == MMS_RESULT_OK)
        {   
            

            


            fsm.msgIdToRetrieve = msgId;

             
            mmsSigCohGetPar = M_CALLOC(sizeof(MmsSigCohGetParam));
            mmsSigCohGetPar->uri = 
                M_ALLOC(strlen(mHeader->notification.contentLocation) + 1);
            
            
            (void)strcpy(mmsSigCohGetPar->uri, 
                mHeader->notification.contentLocation); 
            mmsSigCohGetPar->msgId = fsm.msgIdToRetrieve; 
            mmsSigCohGetPar->size = mHeader->notification.length; 
            
             
            M_SIGNAL_SENDTO_IUUP( M_FSM_COH_GET, MMS_SIG_COH_GET_MSG, 0,
                M_FSM_MSR_RECEIVE, MMS_SIG_MSR_RECEIVE_GET_RSP, mmsSigCohGetPar);
            
             
            freeMmsNotification(&mHeader->notification); 
            M_FREE(mHeader); 
        }
        else 
        {
             
            freeMmsNotification(&mHeader->notification); 
            M_FREE(mHeader); 
        }   

        if (ret != MMS_RESULT_OK)
        {
            MMSa_retrieveMessageResponse( ret, fsm.notifIdToRetrieve, 
                MMS_RTRV_STATUS_NONE, NULL);

            fsmClear();
        } 
        break; 

    case MMS_SIG_MSR_RECEIVE_GET_RSP:
        


        if (sig->p_param == NULL)
        {
            MMS_LOG_I(("MMS FSM MSR RECEIVE: Signal error, received no result.\n"));
            break;
        } 

        



        getResult = (MmsSigCohGetResultParam *)sig->p_param;
        ret = getResult->result;
        if (ret != MMS_RESULT_OK)
        {
            MMS_LOG_I(("%s(%d): Retrieve operation failed %d\n", 
                __FILE__, __LINE__, (int)ret));
            (void)fldrmgrCloseMessage( CMN_CLIENT_MMS, getResult->msgId);
#ifdef MMS_EXTERNAL_DRM_ID_GENERATION
            M_SIGNAL_SENDTO_IUP(M_FSM_MSR_RECEIVE, MMS_SIG_MSR_RECEIVE_GET_RSP_CONT,
                ret, getResult->msgId, sig->p_param);
#endif 
        }
        else
        {   
            fmResult = fldrmgrSetMessageSize( CMN_CLIENT_MMS, getResult->msgId,
                getResult->size);
            if (fmResult != FM_RESULT_OK)
            {   
                MMS_LOG_I(("%s(%d): Folder Mgr error %d when setSize msg file\n", 
                    __FILE__, __LINE__, fmResult));
                ret = checkFolderError(fmResult);
            } 

            

#ifdef MMS_EXTERNAL_DRM_ID_GENERATION
            M_SIGNAL_SENDTO_UP(M_FSM_MMH_FETCH, MMS_SIG_MMH_SET_ID_INFO_INIT,
			    getResult->msgId, sig->p_param);
        }  
        break;
	
    case MMS_SIG_MSR_RECEIVE_GET_RSP_CONT:
        getResult = (MmsSigCohGetResultParam *)sig->p_param;
        ret = sig->i_param;
        fmResult = fldrmgrCloseMessage( CMN_CLIENT_MMS, getResult->msgId);
        if (fmResult != FM_RESULT_OK)
        {   
            MMS_LOG_I(("%s(%d): Folder Mgr error %d when closing msg file\n", 
                __FILE__, __LINE__, fmResult));
            ret = checkFolderError(fmResult);
        }
#else  

            ret = createMsgInfoList( getResult->msgId, 0);
            fmResult = fldrmgrCloseMessage( CMN_CLIENT_MMS, getResult->msgId);
            if (fmResult != FM_RESULT_OK)
            {   
                MMS_LOG_I(("%s(%d): Folder Mgr error %d when closing msg file\n", 
                    __FILE__, __LINE__, fmResult));
                ret = checkFolderError(fmResult);
            } 
        }  
#endif 

        if (ret == MMS_RESULT_OK)   
        { 
            if (fsm.state == STATE_DELAYED_RETRIEVAL_ACTIVE)
            {   
                

                fmResult = fldrmgrSetFlagValid( CMN_CLIENT_MMS, 
                    fsm.notifIdToRetrieve, FALSE);
                if (fmResult != FM_RESULT_OK)
                {   
                    MMS_LOG_I(("%s(%d): Couldn't invalidate notification %d\n", 
                        __FILE__, __LINE__, fmResult));
                } 
            } 

            
            fmResult = fldrmgrSetFlagValid( CMN_CLIENT_MMS, getResult->msgId, TRUE);
            ret = checkFolderError( fmResult);
            if (ret != MMS_RESULT_OK)
            {
                MMS_LOG_I(("%s(%d): Couldn't set the msg as valid.\n", 
                    __FILE__, __LINE__));
            } 

            if (getResult->retrieveTransId != NULL)
            {   
                postAcknowledgeInd(getResult->retrieveTransId);
            } 
        }
        else 
        {   
            deleteUnusedFile(getResult->msgId);
        } 

        if (fsm.state == STATE_IMMEDIATE_RETRIEVAL_ACTIVE)
        {   
            fsm.param->result = ret;
            fsm.param->retrieveStatus = getResult->retrieveStatus;
            fsm.param->seqId = fsm.seqId;
            M_SIGNAL_SENDTO_P( fsm.requestingFsm, fsm.returnSignal, fsm.param);
            fsm.param = NULL;   

            data.immRetFinished.seqId = fsm.seqId;
            data.immRetFinished.result = ret;
            MMSa_status( MMS_CLIENT_STATUS_IMM_RET_FINISHED, 
                getResult->msgId, data);
        }
        else 
        {
            if (ret == MMS_RESULT_OK)
            {   

                M_SIGNAL_SENDTO_U( M_FSM_MSR_NOTIFY, 
                    MMS_SIG_MSR_REMOVE_DELAYED_NOTIFICATION, 
                    fsm.notifIdToRetrieve);
            } 

            MMSa_retrieveMessageResponse( ret, getResult->msgId,
                getResult->retrieveStatus, getResult->retrieveText);

            

            if (cfgGetInt(MMS_CFG_IMMEDIATE_RETRIEVAL))
            {
                M_SIGNAL_SENDTO( M_FSM_MSR_NOTIFY, 
                    MMS_SIG_MSR_CHECK_IMMEDIATE_RETRIEVALS); 
            } 
        } 

        fsmClear();

#ifndef MMS_RETAIN_ADAPTER_PARAMETERS
        cohGetFreeResultParam( getResult);
#else
        
        M_FREE(getResult);
#endif 
        break; 

    case MMS_SIG_MSR_RCV_ACK_RSP : 
        MMS_LOG_I(("MMS FSM MSR RECEIVE: Received MMS_SIG_MSR_RCV_ACK_RSP\n"));

        postParam = (MmsSigCohPostResultParam *)sig->p_param;
        if (postParam->result != MMS_RESULT_OK)
        {
            



            MMS_LOG_I(("MMS FSM MSR RECEIVE: Post of M-Acknowledge.ind failed %d\n",
                postParam->result));
        } 

        cohPostFreeResultParam(postParam);
        break;
    default:
        
        MMS_LOG_I(("MMS FSM MSR RECEIVE: received unknown signal %d\n", sig->type));
        break;
    } 
    
    mSignalDelete(sig);
} 




void msrReceiveTerminate(void)
{
    if (fsm.param)
    {
        
        msrReceiveFreeParam(fsm.param);
        fsm.param = NULL;
    } 

    fsmClear();
    mSignalDeregister(M_FSM_MSR_RECEIVE);
    
    MMS_LOG_I(("MMS FSM MSR RECEIVE: terminated\n"));
} 





static void postAcknowledgeInd(char *transId)
{
    UINT32 length;
    MmsSigCohPostParam *post;
    MmsAcknowledgeInd   ack;

    
    ack.transactionId = transId;
    ack.allowed = (MmsDeliveryReport)cfgGetInt(MMS_CFG_DELIVERY_REPORT);
    post = M_CALLOC(sizeof(MmsSigCohPostParam));
    post->isResponseRequested = TRUE;
    post->type = MMS_M_ACKNOWLEDGE_IND;
    post->data.pdu.packet = createWspAcknowledgeIndMsg( &ack, 
        &length, (MmsVersion)cfgGetInt(MMS_CFG_PROXY_RELAY_VERSION));
    post->data.pdu.length = length;

    if (post->data.pdu.packet == NULL)
    {
        MMS_LOG_I(("%s(%d): Couldn't create PDU\n", __FILE__, __LINE__));
    }
    else
    {
        M_SIGNAL_SENDTO_IUUP( M_FSM_COH_POST, MMS_SIG_COH_POST, 0,
            M_FSM_MSR_RECEIVE, MMS_SIG_MSR_RCV_ACK_RSP, post); 
    } 
} 














static MmsResult startImmediateRetrieval(const MmsSigMsrReceiveParam *p)
{
    UINT32 msgId;
    MmsSigCohGetParam *mmsSigCohGetPar; 
    MmsResult ret = MMS_RESULT_OK;
    char *trId;
    MmsVersion version;
    MmsNotification notif;
    MmsClientStatusData data;
    
    trId = getTransactionId( p->pdu, p->len);
    ret = parseMmsNotification( p->pdu, p->len, &notif, &version);
    if (ret != MMS_RESULT_OK)
    {
        MMS_LOG_I(("%s(%d): Failed to parse notification.\n", __FILE__, __LINE__));
    }
    else if (trId == NULL)
    {
        MMS_LOG_I(("%s(%d): Missing transaction ID.\n", __FILE__, __LINE__));
        ret = MMS_RESULT_COMM_HEADER_TAG;
    }
    else if ((ret = msgPreparationCheck( notif.length, &msgId)) == MMS_RESULT_OK)
    {   
        fsm.msgIdToRetrieve = msgId;
        fsm.param->msgId = msgId;
        mmsSigCohGetPar = (MmsSigCohGetParam*)M_ALLOC(sizeof(MmsSigCohGetParam));
        
        mmsSigCohGetPar->uri = M_ALLOC( strlen(notif.contentLocation) + 1);
        (void)strcpy( mmsSigCohGetPar->uri, notif.contentLocation);
        mmsSigCohGetPar->transactionId = M_ALLOC(strlen(trId) + 1);
        (void)strcpy(mmsSigCohGetPar->transactionId, trId); 
                
        mmsSigCohGetPar->msgId = msgId; 
        mmsSigCohGetPar->size = notif.length;

         
        M_SIGNAL_SENDTO_IUUP( M_FSM_COH_GET, MMS_SIG_COH_GET_MSG, 0, 
            M_FSM_MSR_RECEIVE, MMS_SIG_MSR_RECEIVE_GET_RSP, mmsSigCohGetPar);

        
        fsm.seqId = mmsWapGetUniqueId();
        data.immRetStart.seqId = fsm.seqId;
        data.immRetStart.notif = &notif;
        MMSa_status( MMS_CLIENT_STATUS_IMMEDIATE_RETRIEVAL, 
            fsm.msgIdToRetrieve, data);
    }
    else if (ret == MMS_RESULT_INSUFFICIENT_PERSISTENT_STORAGE)
    {
        

        MMS_LOG_I(("%s(%d): No disk during immediate retrieval.\n",
            __FILE__, __LINE__));
    }
    else 
    {
        MMS_LOG_I(("%s(%d): %d error occured.\n", __FILE__, __LINE__, ret));

         
        MMSa_error(ret);
    } 

    freeMmsNotification(&notif);

    return ret; 
} 

⌨️ 快捷键说明

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