📄 mcreate.c
字号:
case MMS_SIG_MMH_CREATE_RR_GOT_HEADER :
MMS_LOG_I(("MMS FSM MMH CREATE: MMS_SIG_MMH_CREATE_RR_GOT_HEADER\n"));
if ((MmsVersion)sig->u_param2 == MMS_VERSION_10 ||
cfgGetInt(MMS_CFG_PROXY_RELAY_VERSION) == MMS_VERSION_10)
{
msgPart = (MmsMessagePart *)sig->p_param;
if ((MmsResult)sig->i_param != MMS_RESULT_OK)
{
result = (MmsResult)sig->i_param;
}
else if (msgPart->header.readReply != MMS_READ_REPLY_YES)
{
result = MMS_RESULT_NO_REPORT;
}
else if ( msgPart->header.msgClass.classIdentifier != MMS_MESSAGE_CLASS_AUTO
&& msgPart->header.readReply == MMS_READ_REPLY_YES)
{
result = createRrMessage( &msgPart->header, &msgId);
}
else
{
result = MMS_RESULT_NO_REPORT;
}
if (msgPart != NULL)
{
freeMmsHeader( &msgPart->header);
M_FREE( msgPart);
msgPart = NULL;
}
if (result == MMS_RESULT_OK)
{
result = checkFolderError( fldrmgrCloseMessage ( CMN_CLIENT_MMS, msgId));
}
M_SIGNAL_SENDTO_IU( fsm.callingFsm, fsm.returnSignal, result, msgId);
}
else
{
msgPart = (MmsMessagePart *)sig->p_param;
if ((MmsResult)sig->i_param != MMS_RESULT_OK)
{
result = (MmsResult)sig->i_param;
}
else if (msgPart->header.readReply != MMS_READ_REPLY_YES)
{
result = MMS_RESULT_NO_REPORT;
}
else if ( msgPart->header.msgClass.classIdentifier != MMS_MESSAGE_CLASS_AUTO
&& msgPart->header.readReply == MMS_READ_REPLY_YES)
{
version = (MmsVersion)cfgGetInt(MMS_CFG_PROXY_RELAY_VERSION);
pdu = createWspReadReport(&msgPart->header, &messageSize, &result,
fsm.readStatus, version);
}
else
{
result = MMS_RESULT_NO_REPORT;
}
if (msgPart != NULL)
{
freeMmsHeader(&msgPart->header);
M_FREE(msgPart);
msgPart = NULL;
}
M_SIGNAL_SENDTO_IUUP( fsm.callingFsm, fsm.altReturnSignal, result,
messageSize, MMS_M_READ_REC_IND, pdu);
}
fsm.isBusy = FALSE;
break;
case MMS_SIG_MMH_CREATE_FORWARD :
MMS_LOG_I(("MMS FSM MMH CREATE: MMS_SIG_MMH_CREATE_FORWARD\n"));
fsm.isBusy = TRUE;
result = MMS_RESULT_OK;
if ((fmResult = fldrmgrOpenMessage( CMN_CLIENT_MMS, sig->u_param2,
FM_READ)) != FM_RESULT_OK)
{
MMS_LOG_I(("%s(%d): Open Msg failed. Error=%d\n",
__FILE__, __LINE__, fmResult));
result = checkFolderError(fmResult);
}
else if ((fmResult = fldrmgrGetMessageSize( CMN_CLIENT_MMS,
sig->u_param2, &messageSize)) != FM_RESULT_OK)
{
MMS_LOG_I(("%s(%d): Get Msg size failed. Error=%d\n",
__FILE__, __LINE__, fmResult));
result = checkFolderError(fmResult);
}
else if ((version = (MmsVersion)cfgGetInt(MMS_CFG_PROXY_RELAY_VERSION))
< MMS_VERSION_11)
{
result = MMS_RESULT_INVALID_VERSION;
}
else if (messageSize > MMS_MAX_NOTIFICATION_SIZE)
{
MMS_LOG_I(("%s(%d): Size of indicated msg is too large. "
"This is probably not the msgId of a notification.\n",
__FILE__, __LINE__, fmResult));
result = MMS_RESULT_ERROR_CREATING_FORWARD;
}
else
{
headerData = M_ALLOC(messageSize);
if ((fmResult = fldrmgrGetMessage( CMN_CLIENT_MMS, sig->u_param2,
0, messageSize, &bytesRead, headerData)) != FM_RESULT_OK)
{
MMS_LOG_I(("%s(%d): Error=%d\n", __FILE__, __LINE__, fmResult));
result = checkFolderError(fmResult);
}
else if (bytesRead != messageSize)
{
MMS_LOG_I(("%s(%d): Error!\n", __FILE__, __LINE__));
result = MMS_RESULT_FILE_READ_ERROR;
}
else if ( (fmResult = fldrmgrCloseMessage( CMN_CLIENT_MMS,
sig->u_param2)) != FM_RESULT_OK)
{
MMS_LOG_I(("%s(%d): Error=%d\n", __FILE__, __LINE__, fmResult));
result = checkFolderError(fmResult);
}
else if ( (result = parseContentLocation( headerData,
messageSize, &uri)) == MMS_RESULT_OK)
{
pdu = createWspForward((MmsForward *)sig->p_param,
uri, &messageSize, &result, (unsigned char)version);
M_SIGNAL_SENDTO_IUUP(sig->i_param, sig->u_param1, result,
messageSize, MMS_M_FORWARD_REQ, pdu);
M_FREE(uri);
}
M_FREE(headerData);
}
if (result != MMS_RESULT_OK)
{
M_SIGNAL_SENDTO_IUUP(sig->i_param, sig->u_param1, result,
0, MMS_M_FORWARD_REQ, NULL);
}
freeMmsForward((MmsForward *)sig->p_param);
fsm.isBusy = FALSE;
break;
case MMS_SIG_MMH_GET_METADATA :
flag = fldrmgrGetMetadata( CMN_CLIENT_MMS, sig->u_param1);
if (flag == 0xff)
{
result = MMS_RESULT_MESSAGE_ID_NOT_FOUND;
flag = 0;
}
else
{
result = MMS_RESULT_OK;
}
MMSa_getMessageMetadataResponse(result,flag);
break;
case MMS_SIG_MMH_SET_METADATA :
fmResult = fldrmgrSetMetadata( CMN_CLIENT_MMS, sig->u_param1,
(UINT8)sig->u_param2);
result = checkFolderError( fmResult);
MMSa_setMessageMetadataResponse(result);
break;
case MMS_SIG_MMH_GET_IS_READ :
fmResult = fldrmgrGetFlag( CMN_CLIENT_MMS, sig->u_param1,
CMN_ATTRIBUTE_READ, &isRead);
result = checkFolderError(fmResult);
if (result != MMS_RESULT_OK)
{
MMS_LOG_I(("%s(%d): Get isRead flag failed. Error=%d\n",
__FILE__, __LINE__, fmResult));
}
MMSa_getMessageReadResponse( result, isRead);
break;
case MMS_SIG_MMH_SET_IS_READ :
fmResult = fldrmgrSetFlag( CMN_CLIENT_MMS, sig->u_param1,
CMN_ATTRIBUTE_READ, (CMN_BOOL)sig->u_param2);
result = checkFolderError(fmResult);
MMSa_setMessageReadResponse(result);
break;
case MMS_SIG_MMH_SET_IS_PROTECTED :
fmResult = fldrmgrSetFlag( CMN_CLIENT_MMS, sig->u_param1,
CMN_ATTRIBUTE_PROTECTED, (CMN_BOOL)sig->u_param2);
result = checkFolderError(fmResult);
MMSa_setMessageProtectedResponse(result);
break;
case MMS_SIG_MMH_GET_DATE :
theDate = fldrmgrGetDate( CMN_CLIENT_MMS, sig->u_param1);
MMSa_getMessageDateResponse( MMS_RESULT_OK, theDate);
break;
case MMS_SIG_MMH_SET_DATE :
msgType = msgSetDate( (MmsMsgId)sig->u_param1);
if (msgType != MMS_M_SEND_REQ && msgType != MMS_M_NOTIFICATION_IND)
{
MMS_LOG_I(("%s(%d): Not allowed to change date for %d.\n",
__FILE__, __LINE__, msgType));
result = MMS_RESULT_ERROR;
}
else
{
fmResult = fldrmgrSetDate( CMN_CLIENT_MMS, sig->u_param1, sig->u_param2);
result = checkFolderError(fmResult);
}
MMSa_setMessageDateResponse(result);
break;
case MMS_SIG_MMH_FILE_FORMAT_CONVERTED :
convertFileFormat();
break;
default :
MMS_LOG_I(("MMS FSM MMH CREATE received: Unknown sig %d\n", sig->type));
break;
}
mSignalDelete(sig);
}
void mmhCreateTerminate(void)
{
mSignalDeregister(M_FSM_MMH_CREATE);
MMS_LOG_I(("MMS FSM MMH CREATE: terminated\n"));
}
static MmsMessageType msgSetDate( MmsMsgId msgId)
{
MmsHeaderValue msgType;
FmResult fmResult;
UINT32 messageSize = 0;
unsigned char *pdu = NULL;
UINT32 bytesRead = 0;
if ((fmResult = fldrmgrOpenMessage( CMN_CLIENT_MMS, msgId,
FM_READ)) != FM_RESULT_OK)
{
MMS_LOG_I(("%s(%d): Open Msg failed. Error=%d\n",
__FILE__, __LINE__, fmResult));
return (MmsMessageType)0;
}
else if ((fmResult = fldrmgrGetMessageSize( CMN_CLIENT_MMS, msgId,
&messageSize)) != FM_RESULT_OK)
{
MMS_LOG_I(("%s(%d): Get Msg size failed. Error=%d\n",
__FILE__, __LINE__, fmResult));
return (MmsMessageType)0;
}
else if (messageSize > MMS_MAX_CHUNK_SIZE)
{
messageSize = MMS_MAX_CHUNK_SIZE;
}
pdu = M_ALLOC(messageSize);
if ((fmResult = fldrmgrGetMessage( CMN_CLIENT_MMS, msgId, 0, messageSize,
&bytesRead, pdu)) != FM_RESULT_OK)
{
MMS_LOG_I(("%s(%d): Error=%d\n", __FILE__, __LINE__, fmResult));
msgType.messageType = 0;
}
if ( (fmResult = fldrmgrCloseMessage( CMN_CLIENT_MMS, msgId)) != FM_RESULT_OK)
{
MMS_LOG_I(("%s(%d): Error=%d\n", __FILE__, __LINE__, fmResult));
msgType.messageType = 0;
}
if (!mmsPduGet( pdu, bytesRead, X_MMS_MESSAGE_TYPE, &msgType))
{
MMS_LOG_I(("%s(%d): Mandatory field X-Mms-Message-Type is missing.",
__FILE__, __LINE__));
msgType.messageType = 0;
}
else if (msgType.messageType != MMS_M_SEND_REQ)
{
MMS_LOG_I(("%s(%d): Cannot change date for %d.",
__FILE__, __LINE__, (int)msgType.messageType));
}
M_FREE(pdu);
return (MmsMessageType)msgType.messageType;
}
MmsResult storeToFile( unsigned char *buf, UINT32 size, char category,
UINT32 msgId, INT32 position)
{
INT32 writeResult = 0;
MmsResult result = MMS_RESULT_OK;
if ( position == -1L)
{
position = FILEa_getSize( category, msgId);
if ( position == -1L)
{
MMS_LOG_I(("%s(%d): unable to get file size",
__FILE__, __LINE__));
result = MMS_RESULT_FILE_READ_ERROR;
return result;
}
}
writeResult = FILEa_write( category, msgId, buf, position, (INT32)size);
if ( writeResult < 0)
{
result = MMS_RESULT_ERROR;
MMS_LOG_I(("%s(%d): unable to write to file id %lu in category %c\n",
__FILE__, __LINE__, msgId, category));
}
else if( (UINT32)writeResult < size)
{
result = MMS_RESULT_INSUFFICIENT_PERSISTENT_STORAGE;
MMS_LOG_I(("%s(%d): unable to write to file id %lu in category %c\n",
__FILE__, __LINE__, msgId, category));
}
return result;
}
static MmsResult storeToFm( unsigned char *data, UINT32 position,
UINT32 length, UINT32 msgId)
{
FmResult result;
result = fldrmgrSetMessage( CMN_CLIENT_MMS, msgId, data, length, position);
return checkFolderError( result);
}
static MmsResult storeWspHeader(const UINT32 msgId,
const UINT32 numOfBodyParts, MmsHeader *header)
{
MmsResult result;
unsigned char *encHeader;
UINT32 encHeaderLen;
MmsVersion version;
if ( header->msgClass.classIdentifier == MMS_MESSAGE_CLASS_AUTO)
{
header->msgClass.classIdentifier = MMS_MESSAGE_CLASS_PERSONAL;
}
version = (MmsVersion)cfgGetInt(MMS_CFG_PROXY_RELAY_VERSION);
if ((encHeader = createWspSendHeader( header, numOfBodyParts, &encHeaderLen,
&result, version)) != NULL)
{
result = storeToFm( encHeader, FM_APPEND, encHeaderLen, msgId);
}
M_FREE( encHeader);
encHeader = NULL;
return result;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -