SMSMsg.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:209k
- }
- }
- else
- {
- mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAINVALID);
- mmi_frm_sms_free_savesms_data();
- return;
- }
- }
- else if (saveSMS->string != NULL && saveSMS->stringlength > 0)
- {
- textbufucs2 = OslMalloc((saveSMS->stringlength) * ENCODING_LENGTH);
- memset((S8*) textbufucs2, 0, ((saveSMS->stringlength) * ENCODING_LENGTH));
- memcpy(textbufucs2, saveSMS->string, ((saveSMS->stringlength) * ENCODING_LENGTH));
- }
- if (textbufucs2)
- {
- EMSTATUS EMSSetPortResult = EMS_OK;
- EMSTATUS EMSSetClassResult = EMS_OK;
- ReleaseEMSEditBuffer();
- pEMS = GetEMSDataForEdit(0, 1);
- #ifdef MMI_ON_HARDWARE_P
- if ((saveSMS->sendrequire & MMI_FRM_SMS_SAVE_PORT) == MMI_FRM_SMS_SAVE_PORT)
- {
- EMSSetPortResult = EMSSetPortNum(pEMS, saveSMS->srcport, saveSMS->desport);
- }
- if ((saveSMS->sendrequire & MMI_FRM_SMS_SAVE_CLASS) == MMI_FRM_SMS_SAVE_CLASS)
- {
- EMSSetClassResult = EMSSetMsgClass(pEMS, saveSMS->dcs_class);
- }
- if ((EMSSetPortResult != EMS_OK) || (EMSSetClassResult != EMS_OK))
- {
- mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_ERROR);
- mmi_frm_sms_free_savesms_data();
- OslMfree(textbufucs2);
- return;
- }
- #endif /* MMI_ON_HARDWARE_P */
- if (saveSMS->filename != NULL)
- {
- result = AppendEMSString(
- INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
- pEMS,
- (U8*) textbufucs2,
- saveSMS->dcs,
- temphistory.guiBuffer);
- }
- else if (saveSMS->string != NULL)
- {
- EMSSetDCS(pEMS, saveSMS->dcs);
- result = AddString(pEMS, (U8*) textbufucs2, saveSMS->stringlength, NULL);
- }
- OslMfree(textbufucs2);
- if ((saveSMS->filename != NULL && result == 0) || (saveSMS->string != NULL && result != EMS_OK))
- {
- mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAEXCEED);
- mmi_frm_sms_free_savesms_data();
- return;
- }
- }
- /* JP added to save a NSm message */
- #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
- if (saveSMS->desport == 0x158A)
- {
- EMSData *pEMS = NULL;
- ReleaseEMSEditBuffer();
- pEMS = GetEMSDataForEdit(0, 0);
- EMSSetPortNum(pEMS, saveSMS->srcport, saveSMS->desport);
- EMSSetDCS(pEMS, saveSMS->dcs);
- AddString(pEMS, (U8*) saveSMS->string, saveSMS->stringlength, NULL);
- }
- #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */
- result = mmi_frm_sms_pack_sms();
- if (result != EMS_OK)
- {
- mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAINVALID);
- mmi_frm_sms_free_savesms_data();
- }
- else
- {
- PendingSaveSendData.nextSegment = 0;
- PendingSaveSendData.presentSegments = 0;
- GetDateTime(&sms_saved_time);
- if (saveSMS->sendrequire & MMI_FRM_SMS_SAVE_DISPLAY_SAVING_SCREEN)
- {
- mmi_frm_sms_entry_save();
- }
- mmi_frm_sms_save_sms_seg();
- }
- }
- /* loop handle */
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_read_sms_rsp
- * DESCRIPTION
- * Read SMS response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_read_sms_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_MSG_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- U8 type;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_MSG_RSP);
- if (msgRsp->result == TRUE)
- {
- memcpy(PendingSaveSendData.TPUD_p[PendingSaveSendData.presentSegments], msgRsp->msg_data, msgRsp->no_msg_data);
- PendingSaveSendData.TPUDLen[PendingSaveSendData.presentSegments] = (U8) msgRsp->no_msg_data;
- PendingSaveSendData.TPUD_udhi[PendingSaveSendData.presentSegments] = (U8) GetUDHIBit(msgRsp->fo);
- PendingSaveSendData.mti = msgRsp->mti;
- PendingSaveSendData.dcs = msgRsp->dcs;
- PendingSaveSendData.st = msgRsp->st;
- }
- else
- {
- PendingSaveSendData.TPUD_p[PendingSaveSendData.presentSegments] = NULL;
- PendingSaveSendData.TPUDLen[PendingSaveSendData.presentSegments] = 0;
- PendingSaveSendData.TPUD_udhi[PendingSaveSendData.presentSegments] = KAL_FALSE;
- }
- if (PendingSaveSendData.nextSegment < PendingSaveSendData.totalSegments && mmi_frm_sms_read_sms_seg() == TRUE)
- {
- return;
- }
- else
- {
- result = MMI_FRM_SMS_OK;
- if (msgRsp->result == TRUE)
- {
- switch (msgRsp->status)
- {
- case SMSAL_REC_UNREAD:
- type = (msgRsp->mti << 4) | MMI_FRM_SMS_UNREAD;
- break;
- case SMSAL_REC_READ:
- type = (msgRsp->mti << 4) | MMI_FRM_SMS_INBOX;
- break;
- case SMSAL_STO_SENT:
- type = (msgRsp->mti << 4) | MMI_FRM_SMS_OUTBOX;
- break;
- case SMSAL_STO_UNSENT:
- type = (msgRsp->mti << 4) | MMI_FRM_SMS_DRAFTS;
- break;
- }
- mmi_frm_sms_unpack_sms(msgRsp->dcs, msgRsp->fo, msgRsp->ori_dcs); /* change pendingsavesenddata struct */
- }
- else
- {
- PendingSaveSendData.mti = SMSAL_MTI_UNSPECIFIED;
- type = (SMSAL_MTI_UNSPECIFIED << 4) | MMI_FRM_SMS_NOBOX;
- }
- mmi_frm_sms_callback_action(&type, result);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_read_sms_seg
- * DESCRIPTION
- * Read SMS segment
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- U8 mmi_frm_sms_read_sms_seg(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (PendingSaveSendData.nextSegment < g_frm_sms_cntx.mmi_frm_sms_msg_seg_size)
- {
- if (PendingSaveSendData.l4index[PendingSaveSendData.nextSegment] != MMI_FRM_SMS_INVALID_INDEX)
- {
- MMI_FRM_SMS_GET_MSG_REQ_STRUCT *msgReq;
- msgReq = (MMI_FRM_SMS_GET_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- msgReq->index = PendingSaveSendData.l4index[PendingSaveSendData.nextSegment];
- msgReq->change_status = g_mmi_frm_sms_change_status;
- SetProtocolEventHandler(mmi_frm_sms_read_sms_rsp, PRT_MSG_ID_MMI_SMS_GET_MSG_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_MSG_REQ, (oslParaType*) msgReq, NULL);
- PendingSaveSendData.presentSegments = PendingSaveSendData.nextSegment;
- PendingSaveSendData.nextSegment++;
- return TRUE;
- }
- PendingSaveSendData.nextSegment++;
- }
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_read_sms_req
- * DESCRIPTION
- * Read SMS request
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_read_sms_req(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 *index = (U16*) inMsg;
- U8 segment = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (segment = 0; segment < g_frm_sms_cntx.mmi_frm_sms_msg_seg_size; segment++)
- {
- PendingSaveSendData.l4index[segment] = index[segment];
- PendingSaveSendData.TPUD_udhi[segment] = 0;
- PendingSaveSendData.TPUDLen[segment] = 0;
- PendingSaveSendData.TPUD_p[segment] = &PendingSaveSendData.TPUD[segment * MMI_FRM_SMS_MSG_LEN];
- }
- PendingSaveSendData.totalSegments = (U8) index[g_frm_sms_cntx.mmi_frm_sms_msg_seg_size];
- OslMfree(inMsg);
- PendingSaveSendData.dcs = 0;
- PendingSaveSendData.nextSegment = 0;
- PendingSaveSendData.presentSegments = 0;
- mmi_frm_sms_read_sms_seg();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_sms_rsp
- * DESCRIPTION
- * Get SMS response: update message box
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_sms_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_MSG_RSP_STRUCT*) inMsg;
- mmi_frm_sms_msgbox_struct *entry;
- U8 segment = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_MSG_RSP);
-
- if (msgRsp->result == TRUE)
- {
- entry = OslMalloc(sizeof(mmi_frm_sms_msgbox_struct));
- if (((msgRsp->concat_info.seg) % g_frm_sms_cntx.mmi_frm_sms_msg_seg_size) == 0)
- {
- segment = (U8) g_frm_sms_cntx.mmi_frm_sms_msg_seg_size;
- }
- else
- {
- segment = (msgRsp->concat_info.seg) % g_frm_sms_cntx.mmi_frm_sms_msg_seg_size;
- }
- mmi_frm_sms_convert_read_to_entry(msgRsp, entry, readIndex);
- mmi_frm_sms_add_sms_to_msgbox(entry, readIndex, segment);
-
- OslMfree(entry);
- mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_OK);
- }
- else
- {
- mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_ERROR);
- }
-
- #ifdef __MMI_UNIFIED_MESSAGE__
- mmi_msg_send_refresh_ind(UM_MSG_BOX_TYPE_INBOX | UM_MSG_BOX_TYPE_UNSENT | UM_MSG_BOX_TYPE_SENT |
- UM_MSG_BOX_TYPE_DRAFT);
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_sms_req
- * DESCRIPTION
- * Get SMS request for updating message box
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_sms_req(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 *index = (U16*) inMsg;
- MMI_FRM_SMS_GET_MSG_REQ_STRUCT *msgReq;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msgReq = (MMI_FRM_SMS_GET_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- readIndex = *index;
- msgReq->index = *index;
- msgReq->change_status = FALSE;
- SetProtocolEventHandler(mmi_frm_sms_get_sms_rsp, PRT_MSG_ID_MMI_SMS_GET_MSG_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_MSG_REQ, (oslParaType*) msgReq, NULL);
- OslMfree(inMsg);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_delete_sms_rsp
- * DESCRIPTION
- * Delete SMS response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_delete_sms_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_DEL_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_DEL_MSG_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- //KP Jerry add on 2007-4-26 start
- #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
- FIREWALL_SMSINFO* pTemp = (FIREWALL_SMSINFO*)Get_Firewall_SmsInfo();
- #endif
- //KP Jerry add on 2007-4-26 end
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
- if (msgRsp->result == TRUE)
- {
- result = MMI_FRM_SMS_OK;
- //KP Jerry add on 2007-4-26 start
- #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
- if(pTemp->Firewall_SMSDeleteFlag)
- {
- mmi_frm_sms_remove_sms_entry(pTemp->Firewall_Index);
- }
- else
- #endif
- //KP Jerry add on 2007-4-26 end
- mmi_frm_sms_remove_sms_from_msgbox(msgRsp->del_bitmap);
- }
- mmi_frm_sms_callback_action(NULL, result);
- }
- /* use index array delete at once!!! */
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_delete_sms_req
- * DESCRIPTION
- * Delete SMS request
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_delete_sms_req(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_DEL_MSG_REQ_STRUCT *msgReq;
- U8 *index = (U8*) inMsg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- //KP Jerry modify on 2007-4-26 start
- #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
- FIREWALL_SMSINFO* pTemp = (FIREWALL_SMSINFO*)Get_Firewall_SmsInfo();
- if(pTemp->Firewall_SMSDeleteFlag)
- {
- msgReq = (MMI_FRM_SMS_DEL_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- msgReq->del_flag = SMSAL_DEL_INDEXED_MSG;
- msgReq->index = pTemp->Firewall_Index;
- SetProtocolEventHandler(mmi_frm_sms_delete_sms_rsp, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_DEL_MSG_REQ, (oslParaType*) msgReq, NULL);
- OslMfree(inMsg);
- }
- else
- {
- msgReq = (MMI_FRM_SMS_DEL_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- msgReq->del_flag = SMSAL_DEL_BITMAP;
- memcpy((S8*) msgReq->del_bitmap, (S8*) index, 480);
- SetProtocolEventHandler(mmi_frm_sms_delete_sms_rsp, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_DEL_MSG_REQ, (oslParaType*) msgReq, NULL);
- OslMfree(inMsg);
- }
- #else
- msgReq = (MMI_FRM_SMS_DEL_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- msgReq->del_flag = SMSAL_DEL_BITMAP;
- memcpy((S8*) msgReq->del_bitmap, (S8*) index, 480);
- SetProtocolEventHandler(mmi_frm_sms_delete_sms_rsp, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_DEL_MSG_REQ, (oslParaType*) msgReq, NULL);
- OslMfree(inMsg);
- #endif
- //KP Jerry modify on 2007-4-26 end
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_profile_name_rsp
- * DESCRIPTION
- * Get profile name response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_profile_name_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_PROFILE_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_PROFILE_PARAMS_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_RSP);
- if (msgRsp->result == TRUE)
- {
- U16 tempLen = ((MAX_PROFILE_NAME_LEN * ENCODING_LENGTH) + ENCODING_LENGTH);
- U8 *tempbuf = OslMalloc(tempLen);
- memset((PS8) tempbuf, 0, (tempLen));
- /* tempbuf = CovertStringForPlatform (msgRsp->profile_name.name, msgRsp->profile_name.name_length, msgRsp->profile_name.name_dcs, &outLen); */
- if (msgRsp->profile_name.name_length > 0)
- {
- /* add null terminator */
- if (msgRsp->profile_name.name_dcs == SMSAL_DEFAULT_DCS)
- {
- if (msgRsp->profile_name.name_length < sizeof(msgRsp->profile_name.name))
- {
- msgRsp->profile_name.name[msgRsp->profile_name.name_length] = 0;
- }
- }
- else
- {
- if ((msgRsp->profile_name.name_length + 1) < sizeof(msgRsp->profile_name.name))
- {
- msgRsp->profile_name.name[msgRsp->profile_name.name_length] = 0;
- msgRsp->profile_name.name[msgRsp->profile_name.name_length + 1] = 0;
- }
- }
-
- InputboxConvertGSMToDeviceEncoding(
- msgRsp->profile_name.name,
- tempbuf,
- msgRsp->profile_name.name_length,
- tempLen,
- msgRsp->profile_name.name_dcs,
- 0,
- 1);
- }
- memcpy((PS8) profileList->profileName[profileList->currReqProfileNo], tempbuf, tempLen);
- if (tempbuf)
- {
- OslMfree(tempbuf);
- tempbuf = NULL;
- }
- profileList->currReqProfileNo++;
- result = MMI_FRM_SMS_OK;
- }
- if ((profileList->currReqProfileNo >= profileList->currMaxPsProfiles) || (result == MMI_FRM_SMS_ERROR))
- {
- if (profileList->currMaxPsProfiles > 0)
- {
- S16 errorCode = 0;
- ReadValue(NVRAM_SMS_ACTIVE_PROFILE_INDEX, &(profileList->currReqProfileNo), DS_BYTE, &errorCode);
- if (profileList->currReqProfileNo >= profileList->currMaxPsProfiles)
- {
- profileList->currReqProfileNo = 0;
- WriteValue(NVRAM_SMS_ACTIVE_PROFILE_INDEX, &(profileList->currReqProfileNo), DS_BYTE, &errorCode);
- }
- }
- mmi_frm_sms_callback_action((void*)profileList, result);
- OslMfree(profileList);
- }
- else
- {
- mmi_frm_sms_get_profile_name_req(&(profileList->currReqProfileNo));
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_profile_name_req
- * DESCRIPTION
- * Get profile name request
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_profile_name_req(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_PROFILE_PARAMS_REQ_STRUCT *msgReq;
- U8 index = *(U8*) inMsg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msgReq = (MMI_FRM_SMS_GET_PROFILE_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- msgReq->profile_no = index;
- SetProtocolEventHandler(mmi_frm_sms_get_profile_name_rsp, PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_RSP);
- mmi_frm_sms_send_message(
- MOD_MMI,
- MOD_L4C,
- 0,
- PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_REQ,
- (oslParaType*) msgReq,
- NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_profile_num_rsp
- * DESCRIPTION
- * Get profile number response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_profile_num_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_PROFILE_NUM_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_PROFILE_NUM_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- profileList = OslMalloc(sizeof(msg_profile_list_struct));
- profileList->currMaxPsProfiles = 0;
- profileList->currReqProfileNo = 0;
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_PROFILE_NUM_RSP);
- if (msgRsp->result == TRUE)
- {
- profileList->currMaxPsProfiles = msgRsp->profile_no;
- profileList->profileNameLength = msgRsp->name_len;
- result = MMI_FRM_SMS_OK;
- }
- if (profileList->currMaxPsProfiles == 0)
- {
- mmi_frm_sms_callback_action((void*)profileList, result);
- OslMfree(profileList);
- }
- else
- {
- mmi_frm_sms_get_profile_name_req(&(profileList->currReqProfileNo));
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_profile_num_req
- * DESCRIPTION
- * Get profile number request
- * PARAMETERS
- * dummy [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_profile_num_req(void *dummy)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(mmi_frm_sms_get_profile_num_rsp, PRT_MSG_ID_MMI_SMS_GET_PROFILE_NUM_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_PROFILE_NUM_REQ, NULL, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_profile_detail_rsp
- * DESCRIPTION
- * Get profile detail response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_profile_detail_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_PROFILE_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_PROFILE_PARAMS_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- profileDetail = OslMalloc(sizeof(msg_profile_edit_struct));
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_RSP);
- if (msgRsp->result == TRUE)
- {
- U16 tempLen = ((MAX_PROFILE_NAME_LEN * ENCODING_LENGTH) + ENCODING_LENGTH);
- U8 *tempbuf = OslMalloc(tempLen);
- U8 type = (msgRsp->sc_addr.type == CSMCC_INTERNATIONAL_ADDR) ? 1 : 0;
- memset((PS8) tempbuf, 0, (tempLen));
- //tempbuff = CovertStringForPlatform (msgRsp->profile_name.name, msgRsp->profile_name.name_length,
- // msgRsp->profile_name.name_dcs, &outLen);
- if (msgRsp->profile_name.name_length > 0)
- {
- /* add null terminator */
- if (msgRsp->profile_name.name_dcs == SMSAL_DEFAULT_DCS)
- {
- if (msgRsp->profile_name.name_length < sizeof(msgRsp->profile_name.name))
- {
- msgRsp->profile_name.name[msgRsp->profile_name.name_length] = 0;
- }
- }
- else
- {
- if ((msgRsp->profile_name.name_length + 1) < sizeof(msgRsp->profile_name.name))
- {
- msgRsp->profile_name.name[msgRsp->profile_name.name_length] = 0;
- msgRsp->profile_name.name[msgRsp->profile_name.name_length + 1] = 0;
- }
- }
-
- InputboxConvertGSMToDeviceEncoding(
- msgRsp->profile_name.name,
- tempbuf,
- msgRsp->profile_name.name_length,
- tempLen,
- msgRsp->profile_name.name_dcs,
- 0,
- 1);
- }
- memset((PS8) profileDetail->profileName, 0, (MAX_PROFILE_NAME_LEN * ENCODING_LENGTH) + ENCODING_LENGTH);
- memcpy((PS8) profileDetail->profileName, (PS8) tempbuf, tempLen);
- profileDetail->profileNameDcs = msgRsp->profile_name.name_dcs;
- if (tempbuf)
- {
- OslMfree(tempbuf);
- tempbuf = NULL;
- }
- profileDetail->vpIndex = (U32) msgRsp->vp;
- profileDetail->msgTypeIndex = (U32) msgRsp->pid;
- if (type)
- {
- AnsiiToUnicodeString((PS8) profileDetail->scAddress, (PS8) "+");
- }
- AnsiiNToUnicodeString(
- (PS8) profileDetail->scAddress + (type * ENCODING_LENGTH),
- (PS8) msgRsp->sc_addr.number,
- msgRsp->sc_addr.length);
- memset(
- (void*)&profileDetail->scAddress[(msgRsp->sc_addr.length + type) * ENCODING_LENGTH],
- 0,
- ENCODING_LENGTH);
- result = MMI_FRM_SMS_OK;
- }
- mmi_frm_sms_callback_action((void*)profileDetail, result);
- OslMfree(profileDetail);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_profile_detail_req
- * DESCRIPTION
- * Get profile detail request
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_profile_detail_req(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_PROFILE_PARAMS_REQ_STRUCT *msgReq;
- U8 index = *(U8*) inMsg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msgReq = (MMI_FRM_SMS_GET_PROFILE_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- msgReq->profile_no = index;
- SetProtocolEventHandler(mmi_frm_sms_get_profile_detail_rsp, PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_RSP);
- mmi_frm_sms_send_message(
- MOD_MMI,
- MOD_L4C,
- 0,
- PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_REQ,
- (oslParaType*) msgReq,
- NULL);
- OslMfree(inMsg);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_profile_detail_rsp
- * DESCRIPTION
- * Set profile detail response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_profile_detail_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_SET_PROFILE_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_PROFILE_PARAMS_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_PROFILE_PARAMS_RSP);
- if (msgRsp->result == TRUE)
- {
- result = MMI_FRM_SMS_OK;
- }
- mmi_frm_sms_callback_action((void*)profileDetail, result);
- OslMfree(profileDetail);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_profile_detail_req
- * DESCRIPTION
- * Set profile detail response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_profile_detail_req(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_SET_PROFILE_PARAMS_REQ_STRUCT *msgReq;
- msg_profile_edit_struct *profile = (msg_profile_edit_struct*) inMsg;
- S8 scAddress[MAX_DIGITS + 1];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- profileDetail = OslMalloc(sizeof(msg_profile_edit_struct));
- memcpy(profileDetail, profile, sizeof(msg_profile_edit_struct));
- msgReq = (MMI_FRM_SMS_SET_PROFILE_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- msgReq->para_ind = 0;
- if (!IsResetCSPGroupService(CSP_TELESERVICES_SERVICE_GROUP, CSP_Validity_Period))
- {
- msgReq->vp = (U8) profile->vpIndex;
- msgReq->para_ind |= SMSAL_PARA_VP;
- }
- if (!IsResetCSPGroupService(CSP_TELESERVICES_SERVICE_GROUP, CSP_Protocol_ID))
- {
- msgReq->pid = (U8) profile->msgTypeIndex;
- msgReq->para_ind |= SMSAL_PARA_PID;
- }
- if (profile->profileNameDcs == PHB_UCS2)
- {
- msgReq->profile_name.name_dcs = MMI_PHB_UCS2;
- msgReq->profile_name.name_length = ((U8) pfnUnicodeStrlen((PS8) profile->profileName)) * ENCODING_LENGTH;
- InputboxConvertDeviceEncodingToGSM(
- (PU8) profile->profileName,
- msgReq->profile_name.name,
- MAX_PROFILE_NAME_LEN,
- MMI_PHB_UCS2,
- 0,
- 1);
- }
- else
- {
- msgReq->profile_name.name_dcs = MMI_PHB_ASCII;
- msgReq->profile_name.name_length = InputboxConvertDeviceEncodingToGSM(
- (PU8) profile->profileName,
- msgReq->profile_name.name,
- MAX_PROFILE_NAME_LEN,
- MMI_PHB_ASCII,
- 0,
- 1) - 1;
- }
- memset(&msgReq->profile_name.name[msgReq->profile_name.name_length], 0, 1);
- msgReq->para_ind |= SMSAL_PARA_PROFILE_NAME;
- memset(&scAddress, 0, MAX_DIGITS_SMS * ENCODING_LENGTH);
- UnicodeNToAnsii((PS8) scAddress, (PS8) profile->scAddress, MAX_DIGITS_SMS * ENCODING_LENGTH);
- msgReq->profile_no = profile->profileIndex;
- if (scAddress[0] == '+')
- {
- msgReq->sc_addr.type = CSMCC_INTERNATIONAL_ADDR;
- msgReq->sc_addr.length = (strlen(scAddress) > MAX_DIGITS_SMS) ? (MAX_DIGITS_SMS - 1) : (strlen(scAddress) - 1);
- memcpy(msgReq->sc_addr.number, scAddress + 1, msgReq->sc_addr.length);
- }
- else
- {
- msgReq->sc_addr.type = CSMCC_DEFAULT_ADDR_TYPE;
- msgReq->sc_addr.length =
- (strlen(scAddress) > (MAX_DIGITS_SMS - 1)) ? (MAX_DIGITS_SMS - 1) : (strlen(scAddress));
- memcpy(msgReq->sc_addr.number, scAddress, msgReq->sc_addr.length);
- }
- memset(&msgReq->sc_addr.number[msgReq->sc_addr.length], 0, 1);
- msgReq->para_ind |= SMSAL_PARA_SCA;
- SetProtocolEventHandler(mmi_frm_sms_set_profile_detail_rsp, PRT_MSG_ID_MMI_SMS_SET_PROFILE_PARAMS_RSP);
- mmi_frm_sms_send_message(
- MOD_MMI,
- MOD_L4C,
- 0,
- PRT_MSG_ID_MMI_SMS_SET_PROFILE_PARAMS_REQ,
- (oslParaType*) msgReq,
- NULL);
- OslMfree(inMsg);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_common_settings_rsp
- * DESCRIPTION
- * Get common settings response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_common_settings_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_COMMON_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_COMMON_PARAMS_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- U8 settings[2] = {0, 0};
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_RSP);
- if (msgRsp->result == TRUE)
- {
- settings[0] = msgRsp->status_report;
- settings[1] = msgRsp->reply_path;
- result = MMI_FRM_SMS_OK;
- #ifdef __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__
- g_frm_sms_cntx.mmi_frm_sms_delivery_report_setting = msgRsp->status_report;
- #endif
- }
- mmi_frm_sms_callback_action((void*)settings, result);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_common_settings_req
- * DESCRIPTION
- * Get common settings request
- * PARAMETERS
- * dummy [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_common_settings_req(void *dummy)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(mmi_frm_sms_get_common_settings_rsp, PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_REQ, NULL, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_common_settings_rsp
- * DESCRIPTION
- * Set common settings response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_common_settings_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_SET_COMMON_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_COMMON_PARAMS_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_RSP);
- if (msgRsp->result == TRUE)
- {
- result = MMI_FRM_SMS_OK;
- #ifdef __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__
- g_frm_sms_cntx.mmi_frm_sms_delivery_report_setting = g_frm_sms_cntx.mmi_frm_sms_delivery_report_temp_setting;
- #endif
- }
- mmi_frm_sms_callback_action(NULL, result);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_common_settings_req
- * DESCRIPTION
- * Set common settings request
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_common_settings_req(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_SET_COMMON_PARAMS_REQ_STRUCT *msgReq;
- U8 *DrRp = (U8*) inMsg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msgReq = (MMI_FRM_SMS_SET_COMMON_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- if (IsResetCSPGroupService(CSP_TELESERVICES_SERVICE_GROUP, CSP_Del_Conf))
- {
- if (DrRp[0] == 0)
- {
- DrRp[0] = 0;
- DrRp[1] = 0;
- }
- else /* DrRp[0] == 1 */
- {
- DrRp[0] = 0;
- DrRp[1] = 1;
- }
- }
- msgReq->status_report = DrRp[0];
- msgReq->reply_path = DrRp[1];
- msgReq->para_ind = SMSAL_COM_PARA_STATUS_REP | SMSAL_COM_PARA_REPLY_PATH;
- #ifdef __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__
- g_frm_sms_cntx.mmi_frm_sms_delivery_report_temp_setting = msgReq->status_report;
- #endif
- SetProtocolEventHandler(mmi_frm_sms_set_common_settings_rsp, PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_RSP);
- mmi_frm_sms_send_message(
- MOD_MMI,
- MOD_L4C,
- 0,
- PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_REQ,
- (oslParaType*) msgReq,
- NULL);
- OslMfree(inMsg);
- }
- #ifdef __MMI_MESSAGES_PREFER_STORAGE_MEMORY_STATUS__
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_memory_status_rsp
- * DESCRIPTION
- * Get memory status response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_memory_status_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_MSG_NUM_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_MSG_NUM_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- msg_mem_status_struct memory;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_RSP);
- if (msgRsp->result == TRUE)
- {
- memory.simTotal = msgRsp->total_sim_num;
- memory.meTotal = msgRsp->total_me_num;
- memory.simUsed = msgRsp->in_sim_no + msgRsp->out_sim_no;
- memory.meUsed = msgRsp->in_me_no + msgRsp->out_me_no;
- result = MMI_FRM_SMS_OK;
- }
- mmi_frm_sms_callback_action((void*)&memory, result);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_memory_status_req
- * DESCRIPTION
- * Get memory status request
- * PARAMETERS
- * dummy [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_memory_status_req(void *dummy)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(mmi_frm_sms_get_memory_status_rsp, PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_REQ, NULL, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_preferred_storage_rsp
- * DESCRIPTION
- * Get preferred storage response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_preferred_storage_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_PREFERRED_STORAGE_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_PREFERRED_STORAGE_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- U8 storage = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_PREFERRED_STORAGE_RSP);
- if (msgRsp->result == TRUE)
- {
- if (msgRsp->info.mem2 == SMSAL_SM || msgRsp->info.mem2 == SMSAL_SM_PREFER)
- {
- storage = SMSAL_SM;
- }
- else
- {
- storage = SMSAL_ME;
- }
- result = MMI_FRM_SMS_OK;
- }
- mmi_frm_sms_callback_action((void*)&storage, result);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_preferred_storage_req
- * DESCRIPTION
- * Get preferred storage request
- * PARAMETERS
- * dummy [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_preferred_storage_req(void *dummy)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(mmi_frm_sms_get_preferred_storage_rsp, PRT_MSG_ID_MMI_SMS_GET_PREFERRED_STORAGE_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_PREFERRED_STORAGE_REQ, NULL, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_preferred_storage_rsp
- * DESCRIPTION
- * Set preferred storage response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_preferred_storage_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_SET_PREFERRED_STORAGE_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_PREFERRED_STORAGE_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- U8 preferStorage = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_PREFERRED_STORAGE_RSP);
- if ((msgRsp->result) == TRUE)
- {
- if (msgRsp->param.mem2 == SMSAL_SM || msgRsp->param.mem2 == SMSAL_SM_PREFER)
- {
- preferStorage = SMSAL_SM;
- }
- else
- {
- preferStorage = SMSAL_ME;
- }
- result = MMI_FRM_SMS_OK;
- }
- mmi_frm_sms_callback_action((void*)&preferStorage, result);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_preferred_storage_req
- * DESCRIPTION
- * Set preferred storage request
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_preferred_storage_req(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_SET_PREFERRED_STORAGE_REQ_STRUCT *msgReq;
- U8 storage = *(U8*) inMsg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msgReq = (MMI_FRM_SMS_SET_PREFERRED_STORAGE_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- msgReq->mem2 = storage;
- msgReq->mem1 = SMSAL_STORAGE_UNSPECIFIED;
- #ifdef __MMI_MESSAGES_PREFER_STORAGE_ONLY_FOR_MO_SMS__
- msgReq->mem3 = SMSAL_STORAGE_UNSPECIFIED;
- #else
- msgReq->mem3 = storage;
- #endif
- SetProtocolEventHandler(mmi_frm_sms_set_preferred_storage_rsp, PRT_MSG_ID_MMI_SMS_SET_PREFERRED_STORAGE_RSP);
- mmi_frm_sms_send_message(
- MOD_MMI,
- MOD_L4C,
- 0,
- PRT_MSG_ID_MMI_SMS_SET_PREFERRED_STORAGE_REQ,
- (oslParaType*) msgReq,
- NULL);
- OslMfree(inMsg);
- }
- #endif /* __MMI_MESSAGES_PREFER_STORAGE_MEMORY_STATUS__ */
- #ifdef __MMI_GPRS_FEATURES__
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_preferred_bearer_rsp
- * DESCRIPTION
- * Get preferred bearer response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_preferred_bearer_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_COMMON_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_COMMON_PARAMS_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- U8 bearer = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_RSP);
- if (msgRsp->result == TRUE)
- {
- if (msgRsp->bearer_service == SMS_PREFER_GPRS)
- {
- bearer = MMI_SMS_PREFER_GPRS;
- }
- else if (msgRsp->bearer_service == SMS_PREFER_GSM)
- {
- bearer = MMI_SMS_PREFER_GSM;
- }
- else if (msgRsp->bearer_service == SMS_GSM_ONLY)
- {
- bearer = MMI_SMS_GSM_ONLY;
- }
- result = MMI_FRM_SMS_OK;
- }
- mmi_frm_sms_callback_action((void*)&bearer, result);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_preferred_bearer_req
- * DESCRIPTION
- * Get preferred bearer request
- * PARAMETERS
- * dummy [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_preferred_bearer_req(void *dummy)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(mmi_frm_sms_get_preferred_bearer_rsp, PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_REQ, NULL, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_preferred_bearer_rsp
- * DESCRIPTION
- * Set preferred bearer response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_preferred_bearer_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_SET_COMMON_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_COMMON_PARAMS_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_RSP);
- if ((msgRsp->result) == TRUE)
- {
- result = MMI_FRM_SMS_OK;
- }
- mmi_frm_sms_callback_action(NULL, result);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_preferred_bearer_req
- * DESCRIPTION
- * Set preferred bearer request
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_preferred_bearer_req(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_SET_COMMON_PARAMS_REQ_STRUCT *msgReq;
- U8 bearer = *(U8*) inMsg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msgReq = (MMI_FRM_SMS_SET_COMMON_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- switch (bearer)
- {
- case MMI_SMS_PREFER_GPRS:
- bearer = SMS_PREFER_GPRS;
- break;
- case MMI_SMS_PREFER_GSM:
- bearer = SMS_PREFER_GSM;
- break;
- case MMI_SMS_GSM_ONLY:
- bearer = SMS_GSM_ONLY;
- break;
- }
- msgReq->bearer_service = bearer;
- msgReq->para_ind = SMSAL_COM_PARA_BEARER;
- SetProtocolEventHandler(mmi_frm_sms_set_preferred_bearer_rsp, PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_RSP);
- mmi_frm_sms_send_message(
- MOD_MMI,
- MOD_L4C,
- 0,
- PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_REQ,
- (oslParaType*) msgReq,
- NULL);
- OslMfree(inMsg);
- }
- #endif /* __MMI_GPRS_FEATURES__ */
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_mailbox_info_rsp
- * DESCRIPTION
- * Get mailbox info response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_mailbox_info_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_MAILBOX_ADDRESS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_MAILBOX_ADDRESS_RSP_STRUCT*) inMsg;
- mmi_frm_sms_mailbox_struct mailboxInfo;
- U16 result = MMI_FRM_SMS_ERROR;
- U8 i = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_RSP);
- if (msgRsp->result == TRUE)
- {
- mailboxInfo.mailboxNumber = msgRsp->mailbox_num;
- mailboxInfo.mailboxNameLength = msgRsp->alpha_length;
- for (i = 0; i < mailboxInfo.mailboxNumber; i++)
- {
- U8 type = (msgRsp->mailbox_info[i].number_info.type == CSMCC_INTERNATIONAL_ADDR) ? 1 : 0;
- U8 length = msgRsp->mailbox_info[i].number_info.length;
- U16 nameLen = (msgRsp->mailbox_info[i].name.name_length + 1) * ENCODING_LENGTH;
- mailboxInfo.mailboxNameDcs[i] = msgRsp->mailbox_info[i].name.name_dcs;
- mailboxInfo.pMailBoxName[i] = OslMalloc(nameLen);
- memset(mailboxInfo.pMailBoxName[i], 0, nameLen);
- if (msgRsp->mailbox_info[i].name.name_length > 0)
- {
- /* add null terminator */
- if (msgRsp->mailbox_info[i].name.name_dcs == SMSAL_DEFAULT_DCS)
- {
- if (msgRsp->mailbox_info[i].name.name_length < sizeof(msgRsp->mailbox_info[i].name.name))
- {
- msgRsp->mailbox_info[i].name.name[msgRsp->mailbox_info[i].name.name_length] = 0;
- }
- }
- else
- {
- if ((msgRsp->mailbox_info[i].name.name_length + 1) < sizeof(msgRsp->mailbox_info[i].name.name))
- {
- msgRsp->mailbox_info[i].name.name[msgRsp->mailbox_info[i].name.name_length] = 0;
- msgRsp->mailbox_info[i].name.name[msgRsp->mailbox_info[i].name.name_length + 1] = 0;
- }
- }
-
- InputboxConvertGSMToDeviceEncoding(
- msgRsp->mailbox_info[i].name.name,
- mailboxInfo.pMailBoxName[i],
- msgRsp->mailbox_info[i].name.name_length,
- nameLen,
- msgRsp->mailbox_info[i].name.name_dcs,
- 0,
- 1);
- }
- //mailboxInfo.pMailBoxName[i] = CovertStringForPlatform (msgRsp->mailbox_info[i].name.name,
- //msgRsp->mailbox_info[i].name.name_length, msgRsp->mailbox_info[i].name.name_dcs, &outlen);
- mailboxInfo.pMailBoxNumber[i] = OslMalloc((type + length + 1) * ENCODING_LENGTH);
- if (type)
- {
- AnsiiToUnicodeString((PS8) mailboxInfo.pMailBoxNumber[i], (PS8) "+");
- }
- AnsiiNToUnicodeString(
- (PS8) (mailboxInfo.pMailBoxNumber[i] + (type * ENCODING_LENGTH)),
- (PS8) msgRsp->mailbox_info[i].number_info.number,
- length);
- memset(mailboxInfo.pMailBoxNumber[i] + ((type + length) * ENCODING_LENGTH), 0, ENCODING_LENGTH);
- }
- result = MMI_FRM_SMS_OK;
- }
- mmi_frm_sms_callback_action((void*)&mailboxInfo, result);
- for (i = 0; i < mailboxInfo.mailboxNumber; i++)
- {
- if (mailboxInfo.pMailBoxName[i])
- {
- OslMfree(mailboxInfo.pMailBoxName[i]);
- }
- if (mailboxInfo.pMailBoxNumber[i])
- {
- OslMfree(mailboxInfo.pMailBoxNumber[i]);
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_mailbox_info_req
- * DESCRIPTION
- * Get mailbox info request
- * PARAMETERS
- * dummy [?]
- * inMsg(?) [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_mailbox_info_req(void *dummy)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(mmi_frm_sms_get_mailbox_info_rsp, PRT_MSG_ID_MMI_SMS_GET_MAILBOX_ADDRESS_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_MAILBOX_ADDRESS_REQ, NULL, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_mailbox_info_rsp
- * DESCRIPTION
- * Set mailbox info response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_mailbox_info_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_SET_MAILBOX_ADDRESS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_MAILBOX_ADDRESS_RSP_STRUCT*) inMsg;
- U16 result = MMI_FRM_SMS_ERROR;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_MAILBOX_ADDRESS_RSP);
- if ((msgRsp->result) == TRUE)
- {
- result = MMI_FRM_SMS_OK;
- }
- mmi_frm_sms_callback_action(mailboxDetail, result);
- OslMfree(mailboxDetail);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_mailbox_info_req
- * DESCRIPTION
- * Set mailbox info request
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_mailbox_info_req(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_SET_MAILBOX_ADDRESS_REQ_STRUCT *msgReq;
- msg_mailbox_edit_struct *mailbox = (msg_mailbox_edit_struct*) inMsg;
- S8 mailboxAddress[MAX_DIGITS + 1];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mailboxDetail = OslMalloc(sizeof(msg_mailbox_edit_struct));
- memcpy(mailboxDetail, mailbox, sizeof(msg_mailbox_edit_struct));
- msgReq = (MMI_FRM_SMS_SET_MAILBOX_ADDRESS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- if (mailbox->mailboxNameDcs == PHB_UCS2)
- {
- msgReq->name.name_dcs = MMI_PHB_UCS2;
- msgReq->name.name_length = ((U8) pfnUnicodeStrlen((PS8) mailbox->mailboxName)) * ENCODING_LENGTH;
- InputboxConvertDeviceEncodingToGSM(
- (PU8) mailbox->mailboxName,
- msgReq->name.name,
- MAX_PROFILE_NAME_LEN,
- MMI_PHB_UCS2,
- 0,
- 1);
- }
- else
- {
- msgReq->name.name_dcs = MMI_PHB_ASCII;
- msgReq->name.name_length = InputboxConvertDeviceEncodingToGSM(
- (PU8) mailbox->mailboxName,
- msgReq->name.name,
- MAX_PROFILE_NAME_LEN,
- MMI_PHB_ASCII,
- 0,
- 1) - 1;
- }
- memset(&msgReq->name.name[msgReq->name.name_length], 0, 1);
- memset(mailboxAddress, 0, MAX_DIGITS_SMS * ENCODING_LENGTH);
- UnicodeNToAnsii((PS8) mailboxAddress, (PS8) mailbox->mailboxAddress, MAX_DIGITS_SMS * ENCODING_LENGTH);
- msgReq->mailbox_num = mailbox->mailboxIndex;
- if (mailboxAddress[0] == '+')
- {
- msgReq->num_addr.type = CSMCC_INTERNATIONAL_ADDR;
- msgReq->num_addr.length =
- (strlen(mailboxAddress) > MAX_DIGITS_SMS) ? (MAX_DIGITS_SMS - 1) : (strlen(mailboxAddress) - 1);
- memcpy(msgReq->num_addr.number, mailboxAddress + 1, msgReq->num_addr.length);
- }
- else
- {
- msgReq->num_addr.type = CSMCC_DEFAULT_ADDR_TYPE;
- msgReq->num_addr.length =
- (strlen(mailboxAddress) > (MAX_DIGITS_SMS - 1)) ? (MAX_DIGITS_SMS - 1) : (strlen(mailboxAddress));
- memcpy(msgReq->num_addr.number, mailboxAddress, msgReq->num_addr.length);
- }
- memset(&msgReq->num_addr.number[msgReq->num_addr.length], 0, 1);
- SetProtocolEventHandler(mmi_frm_sms_set_mailbox_info_rsp, PRT_MSG_ID_MMI_SMS_SET_MAILBOX_ADDRESS_RSP);
- mmi_frm_sms_send_message(
- MOD_MMI,
- MOD_L4C,
- 0,
- PRT_MSG_ID_MMI_SMS_SET_MAILBOX_ADDRESS_REQ,
- (oslParaType*) msgReq,
- NULL);
- OslMfree(inMsg);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_sync_msg_ind
- * DESCRIPTION
- * Handle sync indication
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_sync_msg_ind(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_SYNC_MSG_IND_STRUCT *msgInd = (MMI_FRM_SMS_SYNC_MSG_IND_STRUCT*) inMsg;
- U8 i = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (msgInd->action)
- {
- case L4C_AT_SMS_ADD:
- mmi_frm_sms_get_sms(NULL, MOD_MMI, msgInd->index);
- break;
- case L4C_AT_SMS_READ_CMGR:
- case L4C_AT_SMS_READ_CMGL:
- {
- U16 msgbox_index = 0;
- U8 msg_type = 0;
- mmi_frm_sms_get_sms_msgbox_index(msgInd->index, &msgbox_index);
- if (msgbox_index != MMI_FRM_SMS_INVALID_INDEX)
- {
- msg_type = (mmi_frm_sms_msg_box[msgbox_index].msgtype & 0x0f);
- /* From UNREAD to READ */
- if (msg_type == MMI_FRM_SMS_UNREAD && msgInd->status == SMSAL_REC_READ)
- {
- mmi_frm_sms_set_sms_status(MMI_FRM_SMS_NOBOX, msgbox_index, MMI_FRM_SMS_INBOX);
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsMsg.c] mmi_frm_sms_sync_msg_ind UNREAD index %d is updated-------*n",
- msgInd->index));
- }
- /* From READ to UNREAD */
- else if (msg_type == MMI_FRM_SMS_INBOX && msgInd->status == SMSAL_REC_UNREAD)
- {
- mmi_frm_sms_set_sms_status(MMI_FRM_SMS_NOBOX, msgbox_index, MMI_FRM_SMS_UNREAD);
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsMsg.c] mmi_frm_sms_sync_msg_ind UNREAD index %d is updated-------*n",
- msgInd->index));
- }
- /* Do nothing if from READ to READ and from UNREAD to UNREAD */
- }
- else
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsMsg.c] mmi_frm_sms_sync_msg_ind READ no MSG BOX index %d-------*n",
- msgInd->index));
- }
- break;
- }
- case L4C_AT_SMS_DELETE:
- mmi_frm_sms_remove_sms_from_msgbox(msgInd->del_bitmap);
- break;
- case L4C_SMS_SIM_REFRESH:
- mmi_frm_sms_ready_ind(NULL);
- break;
- }
- while (i < mmi_frm_sms_interrupt_handler_size)
- {
- if (mmi_frm_sms_interrupt_handler[i].msgid == PRT_MSG_ID_MMI_SMS_SYNC_MSG_IND)
- {
- mmi_frm_sms_interrupt_handler[i].callback(NULL, MOD_MMI, (U16) msgInd->action);
- break;
- }
- i++;
- }
- /* Design for flow control */
- if (msgInd->action == L4C_AT_SMS_READ_CMGR)
- {
- mmi_sms_sync_msg_res_req_struct *msgReq;
- msgReq = (mmi_sms_sync_msg_res_req_struct*) OslConstructDataPtr(sizeof(*msgReq));
- msgReq->result = TRUE;
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, MSG_ID_MMI_SMS_SYNC_MSG_RES_REQ, (oslParaType*) msgReq, NULL);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_sim_refresh_ind
- * DESCRIPTION
- * Handle sim refresh indication from SAT
- * PARAMETERS
- * dummy [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_sim_refresh_ind(U16 dummy)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 current_screen = GetExitScrnID();
- BOOL in_sms_screen = TRUE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[SmsMsg.c] mmi_frm_sms_sim_refresh_ind SIM Refresh -------*n"));
- g_frm_sms_cntx.mmi_frm_sms_ready = FALSE;
- #ifdef __MMI_UNIFIED_MESSAGE__
- #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
- if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST_OPTION) || current_screen == SCR_ID_MSG_INBOX_LIST_OPTION)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_LIST_OPTION);
- }
- else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION) || current_screen == SCR_ID_MSG_OUTBOX_LIST_OPTION)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
- }
- else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_LIST_OPTION) || current_screen == SCR_ID_MSG_DEFAULT_LIST_OPTION)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_LIST_OPTION);
- }
- else
- #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */
- if (IsScreenPresent(SCR_ID_MSG_INBOX_MSG) || current_screen == SCR_ID_MSG_INBOX_MSG)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_MSG);
- }
- else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG) || current_screen == SCR_ID_MSG_OUTBOX_MSG)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
- }
- else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_MSG) || current_screen == SCR_ID_MSG_DEFAULT_MSG)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_MSG);
- }
- else if (IsScreenPresent(SCR_ID_MSG_SETTINGS) || current_screen == SCR_ID_MSG_SETTINGS)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_SETTINGS);
- }
- else if (IsScreenPresent(SCR_ID_MSG_VOICE_MAIL_LIST) || current_screen == SCR_ID_MSG_VOICE_MAIL_LIST)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_VOICE_MAIL_LIST);
- }
- else if (IsScreenPresent(SCR_ID_MSG_CB_MAIN_MENU) || current_screen == SCR_ID_MSG_CB_MAIN_MENU)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_CB_MAIN_MENU);
- }
- else if (IsScreenPresent(SCR_ID_MSG_TEMPLATE_LIST) || current_screen == SCR_ID_MSG_TEMPLATE_LIST)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_TEMPLATE_LIST);
- }
- else if (IsScreenPresent(SCR_ID_MSG_WRITE) || current_screen == SCR_ID_MSG_WRITE)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE);
- }
- else
- {
- in_sms_screen = FALSE;
- }
- #else /* __MMI_UNIFIED_MESSAGE__ */
- if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST) || current_screen == SCR_ID_MSG_INBOX_LIST)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_LIST);
- }
- else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST) || current_screen == SCR_ID_MSG_OUTBOX_LIST)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST);
- }
- #ifdef __MMI_MESSAGES_DRAFT_BOX__
- else if (IsScreenPresent(SCR_ID_MSG_DRAFTBOX_LIST) || current_screen == SCR_ID_MSG_DRAFTBOX_LIST)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DRAFTBOX_LIST);
- }
- #endif /* __MMI_MESSAGES_DRAFT_BOX__ */
- else if (IsScreenPresent(SCR_ID_MSG_SETTINGS) || current_screen == SCR_ID_MSG_SETTINGS)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_SETTINGS);
- }
- else if (IsScreenPresent(SCR_ID_MSG_VOICE_MAIL_LIST) || current_screen == SCR_ID_MSG_VOICE_MAIL_LIST)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_VOICE_MAIL_LIST);
- }
- else if (IsScreenPresent(SCR_ID_MSG_CB_MAIN_MENU) || current_screen == SCR_ID_MSG_CB_MAIN_MENU)
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_CB_MAIN_MENU);
- }
- else if (IsScreenPresent(SCR_ID_MSG_WRITE))
- {
- /* Only delete SMS screens if sending or saving SMS messages */
- if (mmi_frm_sms_check_action_pending())
- {
- SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE);
- }
- else
- {
- in_sms_screen = FALSE;
- }
- }
- else
- {
- in_sms_screen = FALSE;
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- if (in_sms_screen)
- {
- DisplayPopup(
- (PU8) GetString(STR_SMS_SIM_REFRESH),
- IMG_GLOBAL_WARNING,
- 1,
- MESSAGES_POPUP_TIME_OUT,
- (U8) WARNING_TONE);
- }
- mmi_frm_sms_delete_action_pending();
- if (in_sms_screen)
- {
- DeleteMessagesHistoryNodes();
- }
- mmi_frm_sms_delete_screen_history();
- #ifdef __MMI_UNIFIED_MESSAGE__
- mmi_um_handle_sim_refresh(UM_MSG_TYPE_SMS, in_sms_screen);
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- }
- #ifdef __MMI_MESSAGES_COPY__
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_copy_sms_callback
- * DESCRIPTION
- * generic callback action for SMS copy
- * PARAMETERS
- * result [IN] cause
- * cause [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_copy_sms_callback(U16 result, U8 cause)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- copyResult = OslMalloc(sizeof(mmi_frm_sms_copy_result_struct));
- copyResult->msg_number = g_frm_sms_copy_info.copy_msg_number;
- copyResult->cause = cause;
- mmi_frm_sms_callback_action(copyResult, result);
- OslMfree(copyResult);
- copyResult = NULL;
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_copy_sms_rollback_rsp
- * DESCRIPTION
- * Delete SMS response for rollback
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_copy_sms_rollback_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_DEL_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_DEL_MSG_RSP_STRUCT*) inMsg;
- U8 result = MMI_FRM_SMS_ERROR;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
- if (msgRsp->result == TRUE)
- {
- mmi_frm_sms_remove_sms_from_msgbox(msgRsp->del_bitmap);
- }
- mmi_frm_sms_copy_sms_callback((U16) result, result);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_copy_sms_move_rsp
- * DESCRIPTION
- * Delete SMS response for move action
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_copy_sms_move_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_DEL_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_DEL_MSG_RSP_STRUCT*) inMsg;
- U8 result = MMI_FRM_SMS_ERROR;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
- if (msgRsp->result == TRUE)
- {
- result = MMI_FRM_SMS_OK;
- mmi_frm_sms_remove_sms_from_msgbox(msgRsp->del_bitmap);
- g_frm_sms_copy_info.copy_msg_number++;
- g_frm_sms_copy_info.present_L4_index = MMI_FRM_SMS_INVALID_INDEX;
- g_frm_sms_copy_info.dst_msg_index = MMI_FRM_SMS_INVALID_INDEX;
- g_frm_sms_copy_info.handled_msg_number++;
- /* all msgs are handled */
- if (g_frm_sms_copy_info.handled_msg_number >= g_frm_sms_copy_info.total_msg_number)
- {
- if (g_frm_sms_copy_info.is_memory_full)
- {
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_MEMFULL, MMI_FRM_SMS_MEMFULL);
- }
- else
- {
- mmi_frm_sms_copy_sms_callback((U16) result, result);
- }
- return;
- }
- /* handle the next msg */
- else
- {
- /* g_frm_sms_copy_info.present_msg_index++; */
- #ifdef __MMI_UNIFIED_MESSAGE__
- if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_UNSENT)
- {
- MMI_ASSERT(mmi_frm_sms_get_next_unsent_msg(&g_frm_sms_copy_info.present_msg_index));
- }
- else if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_DRAFTS)
- {
- MMI_ASSERT(mmi_frm_sms_get_next_draft_msg(&g_frm_sms_copy_info.present_msg_index));
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- mmi_frm_sms_pre_copy_sms_req(NULL);
- return;
- }
- }
- else
- {
- mmi_frm_sms_copy_sms_callback((U16) result, result);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_copy_sms_seg_rsp
- * DESCRIPTION
- * copy one sms segment rsp
- * PARAMETERS
- * inMsg [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_copy_sms_seg_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_COPY_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_COPY_MSG_RSP_STRUCT*) inMsg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_COPY_MSG_RSP);
- if (msgRsp->result == TRUE)
- {
- U16 msgindex = 0;
- mmi_frm_sms_msgbox_struct *entry;
- switch (g_frm_sms_copy_info.msg_list_type)
- {
- case MMI_FRM_SMS_NOBOX:
- msgindex = g_frm_sms_copy_info.present_msg_index;
- break;
- case MMI_FRM_SMS_INBOX:
- case MMI_FRM_SMS_UNREAD:
- msgindex = mmi_frm_sms_inbox_list[g_frm_sms_copy_info.present_msg_index];
- break;
- case MMI_FRM_SMS_OUTBOX:
- #ifndef __MMI_MESSAGES_DRAFT_BOX__
- case MMI_FRM_SMS_DRAFTS:
- #endif
- msgindex = mmi_frm_sms_outbox_list[g_frm_sms_copy_info.present_msg_index];
- break;
- #ifdef __MMI_MESSAGES_DRAFT_BOX__
- case MMI_FRM_SMS_DRAFTS:
- #ifdef __MMI_UNIFIED_MESSAGE__
- case MMI_FRM_SMS_UNSENT:
- #endif
- msgindex = mmi_frm_sms_drafts_list[g_frm_sms_copy_info.present_msg_index];
- break;
- #endif /* __MMI_MESSAGES_DRAFT_BOX__ */
- }
- /* kal_uint8 result;
- //kal_uint16 cause;
- //kal_uint8 action;
- kal_uint8 dst_storage;
- kal_uint16 src_index;
- kal_uint16 dst_index; */
- entry = OslMalloc(sizeof(mmi_frm_sms_msgbox_struct));
- memcpy((S8*) entry, (S8*) & mmi_frm_sms_msg_box[msgindex], sizeof(mmi_frm_sms_msgbox_struct));
- /* if(entry->storageType != MMI_FRM_SMS_PREFER_STORAGE) */
- entry->storageType = msgRsp->dst_storage;
- entry->startindex = msgRsp->dst_index;
- /* There is not timestamp info for outbox SMS stored in SIM */
- if (g_frm_sms_copy_info.msg_list_type != MMI_FRM_SMS_INBOX && g_frm_sms_copy_info.msg_list_type != MMI_FRM_SMS_UNREAD)
- {
- if (msgRsp->dst_storage == SMSAL_SM)
- {
- memset(entry->timestamp, 0, sizeof(entry->timestamp));
- }
- }
- #ifdef __MMI_UNIFIED_MESSAGE__
- /* The MMI SMS content is added in the first segment */
- if (mmi_frm_sms_index_list[msgRsp->src_index].segment != 1)
- {
- memset(entry->content,0,sizeof(entry->content));
- }
-
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- g_frm_sms_copy_info.dst_msg_index = mmi_frm_sms_add_sms_to_msgbox(entry, msgRsp->dst_index, mmi_frm_sms_index_list[msgRsp->src_index].segment);
- OslMfree(entry);
- /* remaing unsent segment of this msg */
- if (mmi_frm_sms_index_list[g_frm_sms_copy_info.present_L4_index].nextindex != MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_copy_sms_seg_req();
- return;
- }
- /* total segments of this msg have sent */
- else
- {
- U8 type;
- U16 list_index;
- mmi_frm_sms_get_sms_list_index(&type, &list_index, g_frm_sms_copy_info.dst_msg_index);
- /* delete original msg if action == move */
- if (g_frm_sms_copy_info.action == SMSAL_MOVE_MSG)
- {
- U8 *data = OslMalloc(sizeof(U8) * 480);
- U16 deleteMsgIndex = 0;
- /* Check if the new msg is added in front of the original one in the list */
- if (list_index <= g_frm_sms_copy_info.present_msg_index)
- {
- g_frm_sms_copy_info.present_msg_index++;
- }
- deleteMsgIndex = g_frm_sms_copy_info.present_msg_index;
- memset((S8*) data, 0, sizeof(U8) * 480);
- #if (0)
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* (0) */
- /* swap the new added one with the original next one */
- //mmi_frm_sms_swap_list_index(g_frm_sms_copy_info.msg_list_type, (U16)g_frm_sms_copy_info.present_msg_index , list_index);
- //deleteMsgIndex = list_index;
- if (mmi_frm_sms_get_sms_bitmap((U8) g_frm_sms_copy_info.msg_list_type, deleteMsgIndex, data) == FALSE)
- {
- OslMfree(data);
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_ERROR, MMI_FRM_SMS_ERROR);
- return;
- }
- else
- {
- MMI_FRM_SMS_DEL_MSG_REQ_STRUCT *msgReq;
- msgReq = (MMI_FRM_SMS_DEL_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- msgReq->del_flag = SMSAL_DEL_BITMAP;
- memcpy((S8*) msgReq->del_bitmap, (S8*) data, 480);
- OslMfree(data);
- SetProtocolEventHandler(mmi_frm_sms_copy_sms_move_rsp, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
- mmi_frm_sms_send_message(
- MOD_MMI,
- MOD_L4C,
- 0,
- PRT_MSG_ID_MMI_SMS_DEL_MSG_REQ,
- (oslParaType*) msgReq,
- NULL);
- return;
- }
- }
- /* Check if the new msg is added in front of the original one in the list */
- if (list_index <= g_frm_sms_copy_info.present_msg_index)
- {
- g_frm_sms_copy_info.present_msg_index++;
- g_frm_sms_copy_info.handled_msg_number++;
- }
- /* if action == copy */
- g_frm_sms_copy_info.copy_msg_number++;
- g_frm_sms_copy_info.present_L4_index = MMI_FRM_SMS_INVALID_INDEX;
- g_frm_sms_copy_info.dst_msg_index = MMI_FRM_SMS_INVALID_INDEX;
- g_frm_sms_copy_info.handled_msg_number++;
- /* The new msg is already in list. Get new list size if copy all */
- if (g_frm_sms_copy_info.total_msg_number > 1)
- {
- g_frm_sms_copy_info.total_msg_number = mmi_frm_sms_get_sms_list_size(g_frm_sms_copy_info.msg_list_type);
- }
- /* all msgs are handled */
- if (g_frm_sms_copy_info.handled_msg_number >= g_frm_sms_copy_info.total_msg_number)
- {
- if (g_frm_sms_copy_info.is_memory_full)
- {
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_MEMFULL, MMI_FRM_SMS_MEMFULL);
- }
- else
- {
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_OK, MMI_FRM_SMS_OK);
- }
- return;
- }
- /* handle the next msg */
- else
- {
- g_frm_sms_copy_info.present_msg_index++;
- #ifdef __MMI_UNIFIED_MESSAGE__
- if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_UNSENT)
- {
- MMI_ASSERT(mmi_frm_sms_get_next_unsent_msg(&g_frm_sms_copy_info.present_msg_index));
- }
- else if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_DRAFTS)
- {
- MMI_ASSERT(mmi_frm_sms_get_next_draft_msg(&g_frm_sms_copy_info.present_msg_index));
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- mmi_frm_sms_pre_copy_sms_req(NULL);
- return;
- }
- }
- }
- /* if(msgRsp->result == TRUE) */
- else
- {
- /* kal_uint8 result;
- kal_uint16 cause;
- kal_uint8 action;
- kal_uint8 dst_storage;
- kal_uint16 src_index;
- kal_uint16 dst_index; */
- /* first segment , no need to rollback */
- if (g_frm_sms_copy_info.dst_msg_index == MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_ERROR, MMI_FRM_SMS_ERROR);
- return;
- }
- /* rollback the last incomplete copied msg */
- else
- {
- U8 *data = OslMalloc(sizeof(U8) * 480);
- memset((S8*) data, 0, sizeof(U8) * 480);
- if (mmi_frm_sms_get_sms_bitmap
- (MMI_FRM_SMS_AWAITS, mmi_frm_sms_msg_box[g_frm_sms_copy_info.dst_msg_index].startindex, data) == FALSE)
- {
- OslMfree(data);
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_ERROR, MMI_FRM_SMS_ERROR);
- return;
- }
- else
- {
- MMI_FRM_SMS_DEL_MSG_REQ_STRUCT *msgReq;
- msgReq = (MMI_FRM_SMS_DEL_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- msgReq->del_flag = SMSAL_DEL_BITMAP;
- memcpy((S8*) msgReq->del_bitmap, (S8*) data, 480);
- SetProtocolEventHandler(mmi_frm_sms_copy_sms_rollback_rsp, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
- mmi_frm_sms_send_message(
- MOD_MMI,
- MOD_L4C,
- 0,
- PRT_MSG_ID_MMI_SMS_DEL_MSG_REQ,
- (oslParaType*) msgReq,
- NULL);
- OslMfree(data);
- return;
- }
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_copy_sms_seg_req
- * DESCRIPTION
- * copy one sms segment req
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_copy_sms_seg_req()
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_COPY_MSG_REQ_STRUCT *msgReq;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msgReq = (MMI_FRM_SMS_COPY_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
- /* first segment of message */
- if (g_frm_sms_copy_info.present_L4_index == MMI_FRM_SMS_INVALID_INDEX)
- {
- U16 msgindex = 0;
- switch (g_frm_sms_copy_info.msg_list_type)
- {
- case MMI_FRM_SMS_NOBOX:
- msgindex = g_frm_sms_copy_info.present_msg_index;
- break;
- case MMI_FRM_SMS_INBOX:
- case MMI_FRM_SMS_UNREAD:
- msgindex = mmi_frm_sms_inbox_list[g_frm_sms_copy_info.present_msg_index];
- break;
- case MMI_FRM_SMS_OUTBOX:
- #ifndef __MMI_MESSAGES_DRAFT_BOX__
- case MMI_FRM_SMS_DRAFTS:
- #endif
- msgindex = mmi_frm_sms_outbox_list[g_frm_sms_copy_info.present_msg_index];
- break;
- #ifdef __MMI_MESSAGES_DRAFT_BOX__
- case MMI_FRM_SMS_DRAFTS:
- #ifdef __MMI_UNIFIED_MESSAGE__
- case MMI_FRM_SMS_UNSENT:
- #endif
- msgindex = mmi_frm_sms_drafts_list[g_frm_sms_copy_info.present_msg_index];
- break;
- #endif /* __MMI_MESSAGES_DRAFT_BOX__ */
- }
- g_frm_sms_copy_info.present_L4_index = mmi_frm_sms_msg_box[msgindex].startindex;
- }
- /* not the first segment */
- else
- { /* check if the nextindex == invalid index in mmi_frm_sms_copy_sms_seg_rsp, not here */
- g_frm_sms_copy_info.present_L4_index = mmi_frm_sms_index_list[g_frm_sms_copy_info.present_L4_index].nextindex;
- }
- msgReq->action = SMSAL_COPY_MSG;
- msgReq->dst_storage = g_frm_sms_copy_info.dst_storage;
- msgReq->src_index = g_frm_sms_copy_info.present_L4_index;
- SetProtocolEventHandler(mmi_frm_sms_copy_sms_seg_rsp, PRT_MSG_ID_MMI_SMS_COPY_MSG_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_COPY_MSG_REQ, (oslParaType*) msgReq, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_pre_copy_sms_rsp
- * DESCRIPTION
- * Get memory status response
- * PARAMETERS
- * inMsg [IN] Input message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_pre_copy_sms_rsp(void *inMsg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_GET_MSG_NUM_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_MSG_NUM_RSP_STRUCT*) inMsg;
- U8 segmentNumber = mmi_frm_sms_get_sms_received_size(g_frm_sms_copy_info.msg_list_type, g_frm_sms_copy_info.present_msg_index);
- U16 availableMemorySize = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_RSP);
- if (msgRsp->result == TRUE)
- {
- if (g_frm_sms_copy_info.dst_storage == SMSAL_SM)
- {
- availableMemorySize = msgRsp->total_sim_num - msgRsp->in_sim_no - msgRsp->out_sim_no;
- }
- else /* SMSAL_ME */
- {
- availableMemorySize = msgRsp->total_me_num - msgRsp->in_me_no - msgRsp->out_me_no;
- }
- if (availableMemorySize == 0) /* no more available Memory */
- {
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_MEMFULL, MMI_FRM_SMS_MEMFULL);
- return;
- }
- else if (availableMemorySize < segmentNumber) /* not enough for this msg, try the next msg */
- {
- g_frm_sms_copy_info.is_memory_full = TRUE;
- g_frm_sms_copy_info.handled_msg_number++;
- if (g_frm_sms_copy_info.handled_msg_number >= g_frm_sms_copy_info.total_msg_number)
- {
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_MEMFULL, MMI_FRM_SMS_MEMFULL);
- return;
- }
- else
- {
- g_frm_sms_copy_info.present_msg_index++;
- #ifdef __MMI_UNIFIED_MESSAGE__
- if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_UNSENT)
- {
- MMI_ASSERT(mmi_frm_sms_get_next_unsent_msg(&g_frm_sms_copy_info.present_msg_index));
- }
- else if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_DRAFTS)
- {
- MMI_ASSERT(mmi_frm_sms_get_next_draft_msg(&g_frm_sms_copy_info.present_msg_index));
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- mmi_frm_sms_pre_copy_sms_req(NULL);
- }
- }
- else
- {
- mmi_frm_sms_copy_sms_seg_req();
- }
- }
- else
- {
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_ERROR, MMI_FRM_SMS_ERROR);
- return;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_pre_copy_sms_req
- * DESCRIPTION
- * pre-copy SMS : check before copy SMS
- * PARAMETERS
- * dummy [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_pre_copy_sms_req(void *dummy)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* check if user aborts SMS copy action */
- if (g_frm_sms_copy_info.is_aborted)
- {
- g_frm_sms_copy_info.is_aborted = FALSE;
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_ABORT, MMI_FRM_SMS_ABORT);
- return;
- }
- /* check msg storage */
- while (mmi_frm_sms_get_sms_storage(g_frm_sms_copy_info.msg_list_type, g_frm_sms_copy_info.present_msg_index) ==
- g_frm_sms_copy_info.dst_storage)
- {
- g_frm_sms_copy_info.handled_msg_number++;
- /* copy one by one should not enter this loop, or will return here */
- if (g_frm_sms_copy_info.handled_msg_number >= g_frm_sms_copy_info.total_msg_number)
- {
- if (g_frm_sms_copy_info.is_memory_full)
- {
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_MEMFULL, MMI_FRM_SMS_MEMFULL);
- }
- else
- {
- mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_OK, MMI_FRM_SMS_OK);
- }
- return;
- }
- /* only for copy all */
- g_frm_sms_copy_info.present_msg_index++;
- #ifdef __MMI_UNIFIED_MESSAGE__
- if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_UNSENT)
- {
- MMI_ASSERT(mmi_frm_sms_get_next_unsent_msg(&g_frm_sms_copy_info.present_msg_index));
- }
- else if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_DRAFTS)
- {
- MMI_ASSERT(mmi_frm_sms_get_next_draft_msg(&g_frm_sms_copy_info.present_msg_index));
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- }
- SetProtocolEventHandler(mmi_frm_sms_pre_copy_sms_rsp, PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_RSP);
- mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_REQ, NULL, NULL);
- }
- #endif /* __MMI_MESSAGES_COPY__ */
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_startup_wap_browser_req
- * DESCRIPTION
- * extract url in SMS text and link to WAP browser
- * PARAMETERS
- * type [IN]
- * URL [?]
- * RETURNS
- * void
- *****************************************************************************/
- #ifdef __MMI_MESSAGES_USE_URL__
- void mmi_frm_sms_startup_wap_browser_req(U8 type, void *URL)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_FRM_SMS_WAP_BROWSER_STARTUP_REQ *open_url_req;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- open_url_req = (MMI_FRM_SMS_WAP_BROWSER_STARTUP_REQ*) OslConstructDataPtr(sizeof(*open_url_req));
- open_url_req->type = type;
- memset(open_url_req->url, 0, sizeof(open_url_req->url));
- strncpy((char*)open_url_req->url, (const char*) URL, (sizeof(open_url_req->url) - 1));
- mmi_frm_sms_send_message(MOD_MMI, MOD_WAP, 0, MSG_ID_WAP_BROWSER_STARTUP_REQ, (void*)open_url_req, NULL);
- }
- #endif /* __MMI_MESSAGES_USE_URL__ */
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_entry_write_msg_req
- * DESCRIPTION
- * entry write msg screen with content
- * PARAMETERS
- * entry_write_data [?]
- * void* data(?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_entry_write_msg_req(void *entry_write_data)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_frm_sms_api_entry_write_struct *data = (mmi_frm_sms_api_entry_write_struct*) entry_write_data;
- EMSData *pEMS;
- S8 *textbuf = NULL;
- S8 *textbufucs2 = NULL;
- U16 textlen = 0;
- U16 result = 0;
- history temphistory;
- #ifdef __MMI_UNIFIED_COMPOSER__
- U8* addr = NULL;
- U16 type = MMI_UC_STATE_WRITE_NEW_MSG;
- #endif /* __MMI_UNIFIED_COMPOSER__ */
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (data->filename != NULL)
- {
- S32 errorCode = 0;
- FILE_HANDLE emsObjectFilePtr;
- emsObjectFilePtr = pfopen((U8*) data->filename, PFS_READ);
- /* the file exists without error */
- if (!pfOpenError(emsObjectFilePtr))
- {
- textlen = (U16) GetFSFileSize(emsObjectFilePtr);
- /* the file size is 0 */
- if (textlen == 0)
- {
- pfclose(emsObjectFilePtr);
- DisplayPopup(
- (PU8) GetString(STR_SMS_FAILURE_DATA_EMPTY),
- IMG_GLOBAL_UNFINISHED,
- 1,
- MESSAGES_POPUP_TIME_OUT,
- (U8) ERROR_TONE);
- return;
- }
- if (data->dcs == SMSAL_8BIT_DCS)
- {
- /* the file is too large. */
- if (textlen > (MMI_FRM_SMS_MSG_LEN * MMI_SMS_MAX_MSG_SEG / ENCODING_LENGTH) ||
- textlen > ((MMI_FRM_SMS_MAX_CONTROL_BUFFER_SIZE / ENCODING_LENGTH) - 1))
- {
- pfclose(emsObjectFilePtr);
- DisplayPopup(
- (PU8) GetString(STR_SMS_FAILURE_DATA_EXCEED),
- IMG_GLOBAL_UNFINISHED,
- 1,
- MESSAGES_POPUP_TIME_OUT,
- (U8) ERROR_TONE);
- return;
- }
- /* the file size is allowed */
- textbuf = OslMalloc(textlen + 1);
- pfread(textbuf, 1, textlen, emsObjectFilePtr, &errorCode);
- pfclose(emsObjectFilePtr);
- /* the file content is corrupted */
- if (pfError(errorCode))
- {
- DisplayPopup(
- (PU8) GetString(STR_SMS_FAILURE_DATA_INVALID),
- IMG_GLOBAL_UNFINISHED,
- 1,
- MESSAGES_POPUP_TIME_OUT,
- (U8) ERROR_TONE);
- OslMfree(textbuf);
- return;
- }
- /* the file content is allowed */
- textbufucs2 = OslMalloc((textlen + 1) * ENCODING_LENGTH);
- AnsiiNToUnicodeString(textbufucs2, textbuf, textlen);
- memset(textbufucs2 + textlen * ENCODING_LENGTH, 0, ENCODING_LENGTH);
- OslMfree(textbuf);
- }
- /* UCS2 and DEFAULT DCS */
- else
- {
- /* the file is too large. */
- if (textlen > (MMI_FRM_SMS_MSG_LEN * MMI_SMS_MAX_MSG_SEG) ||
- textlen > (MMI_FRM_SMS_MAX_CONTROL_BUFFER_SIZE - ENCODING_LENGTH))
- {
- pfclose(emsObjectFilePtr);
- DisplayPopup(
- (PU8) GetString(STR_SMS_FAILURE_DATA_EXCEED),
- IMG_GLOBAL_UNFINISHED,
- 1,
- MESSAGES_POPUP_TIME_OUT,
- (U8) ERROR_TONE);
- return;
- }
- /* the file size is allowed */
- textbuf = OslMalloc(textlen + ENCODING_LENGTH);
- pfread(textbuf, 1, textlen, emsObjectFilePtr, &errorCode);
- pfclose(emsObjectFilePtr);
- /* the file content is corrupted */
- if (pfError(errorCode))
- {
- DisplayPopup(
- (PU8) GetString(STR_SMS_FAILURE_DATA_INVALID),
- IMG_GLOBAL_UNFINISHED,
- 1,
- MESSAGES_POPUP_TIME_OUT,
- (U8) ERROR_TONE);
- OslMfree(textbuf);
- return;
- }
- /* the file content is allowed */
- textbufucs2 = OslMalloc((textlen + ENCODING_LENGTH));
- memset(textbufucs2, 0, (textlen + ENCODING_LENGTH));
- memcpy(textbufucs2, textbuf, textlen);
- OslMfree(textbuf);
- }
- }
- else
- {
- DisplayPopup(
- (PU8) GetString(STR_SMS_FAILURE_DATA_INVALID),
- IMG_GLOBAL_UNFINISHED,
- 1,
- MESSAGES_POPUP_TIME_OUT,
- (U8) ERROR_TONE);
- return;
- }
- }
- else if (data->string != NULL && data->stringlength > 0)
- {
- textbufucs2 = OslMalloc((data->stringlength) * ENCODING_LENGTH);
- memset((S8*) textbufucs2, 0, ((data->stringlength) * ENCODING_LENGTH));
- memcpy(textbufucs2, data->string, ((data->stringlength) * ENCODING_LENGTH));
- }
- else
- {
- ReleaseEMSEditBuffer();
- }
- if (textbufucs2)
- {
- EMSTATUS EMSSetPortResult = EMS_OK;
- EMSTATUS EMSSetClassResult = EMS_OK;
- ReleaseEMSEditBuffer();
- pEMS = GetEMSDataForEdit(0, 1);
- #ifdef MMI_ON_HARDWARE_P
- if ((data->flag & MMI_FRM_SMS_ENTRY_WRITE_PORT) == MMI_FRM_SMS_ENTRY_WRITE_PORT)
- {
- EMSSetPortResult = EMSSetPortNum(pEMS, data->srcport, data->desport);
- }
- if ((data->flag & MMI_FRM_SMS_ENTRY_WRITE_CLASS) == MMI_FRM_SMS_ENTRY_WRITE_CLASS)
- {
- EMSSetClassResult = EMSSetMsgClass(pEMS, data->dcs_class);
- }
- if ((EMSSetPortResult != EMS_OK) || (EMSSetClassResult != EMS_OK))
- {
- DisplayPopup(
- (PU8) GetString(STR_SMS_FAILURE_DATA_INVALID),
- IMG_GLOBAL_UNFINISHED,
- 1,
- MESSAGES_POPUP_TIME_OUT,
- (U8) ERROR_TONE);
- OslMfree(textbufucs2);
- return;
- }
- #endif /* MMI_ON_HARDWARE_P */
- if (data->filename != NULL)
- {
- result = AppendEMSString(
- INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
- pEMS,
- (U8*) textbufucs2,
- data->dcs,
- temphistory.guiBuffer);
- }
- else if (data->string != NULL)
- {
- EMSSetDCS(pEMS, data->dcs);
- result = AddString(pEMS, (U8*) textbufucs2, data->stringlength, NULL);
- }
- OslMfree(textbufucs2);
- if ((data->filename != NULL && result == 0) || (data->string != NULL && result != EMS_OK))
- {
- DisplayPopup(
- (PU8) GetString(STR_SMS_FAILURE_DATA_EXCEED),
- IMG_GLOBAL_UNFINISHED,
- 1,
- MESSAGES_POPUP_TIME_OUT,
- (U8) ERROR_TONE);;
- return;
- }
- }
- #ifdef __MMI_UNIFIED_COMPOSER__
- if ((data->flag & MMI_FRM_SMS_ENTRY_WRITE_REPLY) == MMI_FRM_SMS_ENTRY_WRITE_REPLY)
- {
- if (data->ascii_addr && strlen((S8*)data->ascii_addr))
- {
- addr = data->ascii_addr;
- type = MMI_UC_STATE_REPLY;
- }
- }
- mmi_msg_entry_uc(addr, type, 0, MMI_UC_MSG_TYPE_SMS_ONLY);
- #else /* __MMI_UNIFIED_COMPOSER__ */
- if ((data->flag & MMI_FRM_SMS_ENTRY_WRITE_REPLY) == MMI_FRM_SMS_ENTRY_WRITE_REPLY)
- {
- if (data->ascii_addr && strlen((S8*)data->ascii_addr))
- {
- strncpy((S8*)g_msg_cntx.smsPhoneNumber, (S8*)data->ascii_addr, MAX_DIGITS_SMS - 1);
- g_msg_cntx.sendMessageCase = SEND_CASE_REPLY_FROM_OTHER_APP;
- }
- }
- mmi_msg_entry_write_msg();
- #endif /* __MMI_UNIFIED_COMPOSER__ */
-
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_protocol_event_handler
- * DESCRIPTION
- * Set protocol event handler
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_protocol_event_handler(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(mmi_frm_sms_new_sms_ind, PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND);
- SetProtocolEventHandler(mmi_frm_sms_new_data_ind, PRT_MSG_ID_MMI_SMS_APP_DATA_IND);
- SetProtocolEventHandler(mmi_frm_sms_ready_ind, PRT_MSG_ID_MMI_SMS_READY_IND);
- SetProtocolEventHandler(mmi_frm_sms_startup_begin_ind, PRT_MSG_ID_MMI_SMS_STARTUP_BEGIN_IND);
- SetProtocolEventHandler(mmi_frm_sms_status_report_ind, PRT_MSG_ID_MMI_SMS_STATUS_REPORT_IND);
- SetProtocolEventHandler(mmi_frm_sms_mem_avai_ind, PRT_MSG_ID_MMI_SMS_MEM_AVAILABLE_IND);
- SetProtocolEventHandler(mmi_frm_sms_mem_exceed_ind, PRT_MSG_ID_MMI_SMS_MEM_EXCEED_IND);
- SetProtocolEventHandler(mmi_frm_sms_mem_full_ind, PRT_MSG_ID_MMI_SMS_MEM_FULL_IND);
- SetProtocolEventHandler(mmi_frm_sms_msg_waiting_ind, PRT_MSG_ID_MMI_SMS_MSG_WAITING_IND);
- SetProtocolEventHandler(mmi_frm_sms_sync_msg_ind, PRT_MSG_ID_MMI_SMS_SYNC_MSG_IND);
- }
- #endif /* __MOD_SMSAL__ */