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

📄 capimms.c

📁 彩信MMS的全部代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    if (data != NULL && length > 0)
    {
        cont->data = M_ALLOC( (MemSize)length);
        if (cont->data == NULL)
        {
            MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
            MMSa_error(MMS_RESULT_RESTART_NEEDED);
            return;
        } 

        memcpy( cont->data, data, (unsigned int)length);
    } 

    
    if ( (instance = cohGetInstance(id)) != -1L )
    {
        sig = M_SIGNAL_SENDTO_IP( M_FSM_COH_GET, MMS_SIG_COH_GET_RSP, 
            instance, cont);
        if (sig == NULL)
        {
            MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
            MMSa_error(MMS_RESULT_RESTART_NEEDED);
            return;
        } 
    }
    else if ( (instance = cohPostInstance(id)) != -1L )
    {
        sig = M_SIGNAL_SENDTO_IP( M_FSM_COH_POST, MMS_SIG_COH_POST_RSP, 
            instance, cont);
        if (sig == NULL)
        {
            MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
            MMSa_error(MMS_RESULT_RESTART_NEEDED);
            return;
        } 
    }
    else
    {
        if (cont->data != NULL)
        {
            M_FREE(cont->data);
        } 

        M_FREE(cont);

        MMS_LOG_E(("MMSc_httpResponse: instance not found for request %d\n", id));
    } 
} 






void MMSc_httpSessionStartResponse(MmsResult errorNo)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_httpSessionStartResponse(%d)\n", errorNo));

    sig = M_SIGNAL_SENDTO_IU( M_FSM_COH_WAP, MMS_SIG_COH_WAP_START_RESPONSE, 
        0, errorNo);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_httpSessionStopResponse(MmsResult errorNo)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_httpSessionStopResponse(%d)\n", errorNo));

    sig = M_SIGNAL_SENDTO_IU( M_FSM_COH_WAP, MMS_SIG_COH_WAP_STOP_RESPONSE, 
        0, errorNo);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_importMessages(MmsFolderType toFolder)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_importMessages(%d)\n", toFolder));

    sig = M_SIGNAL_SENDTO_IP( M_FSM_MMH_IMPORT, MMS_SIG_MMH_IMPORT_START, 
        toFolder, NULL);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_moveMessage(MmsMsgId msgId, MmsFolderType toFolder)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_moveMessage(%lu,%d)\n", msgId, toFolder));

    sig = M_SIGNAL_SENDTO_UU( M_FSM_MMH_FETCH, MMS_SIG_MMH_MOVE_MSG, msgId, toFolder);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_push( MmsTimeSec date, CMN_BOOL isSmsBearer, unsigned long size, void *pdu)
{
    MmsSignal *sig;
    void *myPdu;

    MMS_LOG_E(("MMSc_push( date=%lu, isSmsBearer=%d, Size=%lu, <data>)\n", 
        date, isSmsBearer, size));

#ifdef MMS_LOG_PROTOCOL
    if (size == 0 || pdu == NULL)
    {
        char str[256];

        
        if (sprintf( str, "PUSH: No data, size=%lu, ptr=%d", size, (int)pdu) > 
            (int)sizeof(str))
        {
            MMS_LOG_I(("%s(%d): Wrote outside allocated memory!\n",
                __FILE__, __LINE__));
            MMSa_error(MMS_RESULT_RESTART_NEEDED);
            return;
        } 

        mmsWapLog( TRUE, (int)strlen(str), str);
    }
    else
    {
        
        mmsWapLog( TRUE, (int)size, pdu);
    } 
#endif 

    if (size == 0 || pdu == NULL)
    {
        MMS_LOG_I(("MMSc_push: No data received, size %ld, ptr %d.\n", 
            size, pdu));
        return; 
    } 

    myPdu = M_ALLOC( size);
    if (myPdu == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 

    memcpy( myPdu, pdu, size);

    sig = M_SIGNAL_SENDTO_IUUP( M_FSM_COH_PUSH_RECEIVE, MMS_SIG_COH_PUSH, 
        isSmsBearer, date, size, myPdu);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_retrieveCancel(MmsMsgId notifId)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_retrieveCancel(%lu)\n", notifId));

    sig = M_SIGNAL_SENDTO_U( M_FSM_MSR_RECEIVE, MMS_SIG_MSR_RECEIVE_CANCEL, notifId);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_retrieveMessage(MmsMsgId msgId)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_retrieveMessage(%lu)\n", msgId));

    sig = M_SIGNAL_SENDTO_U( M_FSM_MSR_RECEIVE, MMS_SIG_MSR_RECEIVE_DELAYED, 
        msgId);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_run(void)
{
    gMemSetInside( CMN_CLIENT_MMS, 1);
    
    if (setjmp( *gMemGetJmpBuf(CMN_CLIENT_MMS) ) == 0) 
    {
       


        mSignalProcess();
    }
    else 
    {
       




        MMSc_terminate(MMS_SHUTDOWN_CRITICAL);
        MMSa_error(MMS_RESULT_STOPPED);
    } 
    
    gMemSetInside( CMN_CLIENT_MMS, 0);
} 






void MMSc_sendCancel(MmsMsgId msgId)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_sendCancel(%lu)\n", msgId));

    sig = M_SIGNAL_SENDTO_U( M_FSM_MSR_SEND, MMS_SIG_MSR_SEND_CANCEL, msgId);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_sendMessage(MmsMsgId msgId)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_sendMessage(%lu)\n", msgId));
    
    sig = M_SIGNAL_SENDTO_U( M_FSM_MSR_SEND, MMS_SIG_MSR_SEND_MSG, msgId);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_sendReadReport(MmsMsgId msgId, MmsReadStatus readStatus)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_sendReadReport( %lu, %d)\n", msgId, (int)readStatus));
    
    sig = M_SIGNAL_SENDTO_IU( M_FSM_MSR_SEND, MMS_SIG_MSR_CREATE_RR, 
        readStatus, msgId);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_setConfigInt(MmsConfigInt variable, UINT32 value)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_setConfigInt(%d, %lu)\n", variable, value));

    sig = M_SIGNAL_SENDTO_UU( M_FSM_CORE_CONFIG, MMS_SIG_CORE_SET_CONFIG_INT, value, variable);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 

#ifdef MMS_EXTERNAL_DRM_ID_GENERATION





void MMSc_setDrmId( MmsMsgId msgId, INT32 bodyPartId, UINT32 drmId)
{
    MmsSignal *sig;
    
    MMS_LOG_E(("MMSc_setDrmId(%d,%d,%d)\n", 
        (int)msgId, (int)bodyPartId, (int)drmId));
    
    sig = M_SIGNAL_SENDTO_IUU(M_FSM_MMH_FETCH, MMS_SIG_MMH_SET_DRM_ID,
        bodyPartId, drmId, msgId);
    
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 
#endif 






void MMSc_setConfigStr(MmsConfigStr variable, char *value)
{
    char *tmp;
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_setConfigStr(%d, %s)\n", variable, 
        value == NULL ? "NULL" : value));

    



    if (value == NULL)
    {
        sig = M_SIGNAL_SENDTO_UP( M_FSM_CORE_CONFIG, 
            MMS_SIG_CORE_SET_CONFIG_STR, variable, value);
        if (sig == NULL)
        {
            MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
            MMSa_error(MMS_RESULT_RESTART_NEEDED);
            return;
        } 
    }
    else
    {
        tmp = M_ALLOC( strlen(value) + 1);
        if (tmp == NULL)
        {
            MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
            MMSa_error(MMS_RESULT_RESTART_NEEDED);
            return;
        } 

        strcpy( tmp, value);
        sig = M_SIGNAL_SENDTO_UP( M_FSM_CORE_CONFIG, 
            MMS_SIG_CORE_SET_CONFIG_STR, variable, tmp);
        if (sig == NULL)
        {
            MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
            MMSa_error(MMS_RESULT_RESTART_NEEDED);
            return;
        } 
    } 
} 






void MMSc_setMessageBody(MmsSetBodyParams params)
{
    MmsSignal *sig;
    MmsSetBodyParams *newParams;
     
    MMS_LOG_E(("MMSc_setMessageBody( id=%lu, size=%lu, targetType=%d)\n",
        params.msgId, params.bodyPart.dataSize, params.targetType));

    newParams = (MmsSetBodyParams *)M_ALLOC(sizeof(MmsSetBodyParams));
    if (newParams == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 

    memset( newParams, 0, sizeof(MmsSetBodyParams)); 
    newParams->bodyPart.storageType = params.bodyPart.storageType;
    newParams->bodyPart.dataSize = params.bodyPart.dataSize;
    newParams->targetType = params.targetType;
    newParams->msgId = params.msgId;
    if ( params.bodyPart.storageType == MMS_BODY_PART_AS_BUFFER)
    {
        newParams->bodyPart.data.buffer = 
            (unsigned char *)M_ALLOC(params.bodyPart.dataSize);
        if (newParams->bodyPart.data.buffer == NULL)
        {
            MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
            MMSa_error(MMS_RESULT_RESTART_NEEDED);
            return;
        } 

        memcpy( newParams->bodyPart.data.buffer,
            params.bodyPart.data.buffer, params.bodyPart.dataSize);
    }
    else
    {
        newParams->bodyPart.data.file.category = params.bodyPart.data.file.category;
        newParams->bodyPart.data.file.id = params.bodyPart.data.file.id;
    } 

    if ( !copyContentType( &newParams->contentType, &params.contentType) ||
        !copyEntryHeader(&newParams->entryHeader, params.entryHeader))
    {
        MMS_LOG_I(("%s(%d) Copy failed. Out of memory?\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 

    sig = M_SIGNAL_SENDTO_P( M_FSM_MMH_CREATE, MMS_SIG_MMH_SET_BODY_PART, newParams);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 







void MMSc_setMessageDate( MmsMsgId msgId, MmsTimeSec date)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_setMessageDate(%lu, %lu)\n", msgId, date));

    sig = M_SIGNAL_SENDTO_UU( M_FSM_MMH_CREATE, MMS_SIG_MMH_SET_DATE, 
        msgId, date);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_setMessageHeader( MmsMsgId msgId, UINT32 numOfBodyParts, 
    const MmsHeader *header)
{
    MmsHeader *toHeader;
    unsigned len = 0;
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_setMessageHeader( id=%lu, numOfBodyParts=%lu\n)", msgId, 
        numOfBodyParts));

    if (header == NULL)
    {
        MMS_LOG_I(("%s(%d): No action requested.\n", __FILE__, __LINE__));
        return;
    } 

    toHeader = (MmsHeader *)M_ALLOC(sizeof(MmsHeader));
    if (toHeader == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
        
    memset( toHeader, 0, sizeof(MmsHeader)); 
    if ( !copyAddressList( &toHeader->to, header->to) ||
        !copyAddressList( &toHeader->cc, header->cc) ||
        !copyAddressList( &toHeader->bcc, header->bcc) ||
        !copyAddress( &toHeader->from, &header->from) ||
        !copyEncText( &toHeader->subject, &header->subject))
    {
        MMS_LOG_I(("%s(%d) Copy failed. Out of memory?\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 

    toHeader->date = header->date;
    toHeader->msgClass.classIdentifier = header->msgClass.classIdentifier;
    if (header->msgClass.classIdentifier == MMS_MESSAGE_CLASS_IS_TEXT && 
        header->msgClass.textString != NULL)
    {
        len = strlen(header->msgClass.textString) + 1;
        toHeader->msgClass.textString = (char *)M_ALLOC(len);
        if (toHeader->msgClass.textString == NULL)
        {
            MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
            MMSa_error(MMS_RESULT_RESTART_NEEDED);
            return;
        } 

        memcpy(toHeader->msgClass.textString, header->msgClass.textString, len);
    } 

    toHeader->expiryTime = header->expiryTime;
    toHeader->deliveryTime = header->deliveryTime;
    toHeader->priority = header->priority;
    toHeader->visibility = header->visibility;
    toHeader->readReply = header->readReply;
    toHeader->deliveryReport = header->deliveryReport;
    
    toHeader->replyCharging = header->replyCharging;
    toHeader->replyChargingDeadline = header->replyChargingDeadline;
    toHeader->replyChargingSize = header->replyChargingSize;
    if (header->replyChargingId != NULL)
    {
        len = strlen(header->replyChargingId) + 1;
        toHeader->replyChargingId = (char *)M_ALLOC(len);
        if (toHeader->replyChargingId == NULL)
        {
            MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
            MMSa_error(MMS_RESULT_RESTART_NEEDED);
            return;
        } 

        memcpy(toHeader->replyChargingId, header->replyChargingId, len);
    } 

    toHeader->contentType = (MmsContentType *)M_ALLOC(sizeof(MmsContentType));
    if (toHeader->contentType == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 

    memset( toHeader->contentType, 0, sizeof(MmsContentType)); 
    if ( !copyContentType(toHeader->contentType, header->contentType))
    {
        MMS_LOG_I(("%s(%d) Copy failed. Out of memory?\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
    
    sig = M_SIGNAL_SENDTO_UUP( M_FSM_MMH_CREATE, MMS_SIG_MMH_SET_HEADER, 
        msgId, numOfBodyParts, toHeader);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_setMessageMetadata( MmsMsgId msgId, UINT8 metadata)
{
    MmsSignal *sig;
     
    MMS_LOG_E(("MMSc_setMessageMetadata( id=%lu, metadata=%lu)\n",
        msgId, (UINT32)metadata));

    sig = M_SIGNAL_SENDTO_UU( M_FSM_MMH_CREATE, MMS_SIG_MMH_SET_METADATA, 
        msgId, metadata);
    if (sig == NULL)
    {
        MMS_LOG_I(("%s(%d): Out of memory\n", __FILE__, __LINE__));
        MMSa_error(MMS_RESULT_RESTART_NEEDED);
        return;
    } 
} 






void MMSc_setMessageProtected( MmsMsgId msgId, CMN_BOOL isProtected)
{
    MmsSignal *sig;

    MMS_LOG_E(("MMSc_setMessageProtected(%lu, %d)\n", msgId, isProtected));

⌨️ 快捷键说明

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