SMSUtil.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:225k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*******************************************************************************
- * Filename:
- * ---------
- * SMSUtil.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- *
- *
- * Author:
- * -------
- *
- *
- *==============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *==============================================================================
- *******************************************************************************/
- #ifdef __MOD_SMSAL__
- #include "MMI_features.h"
- #include "stdC.h"
- #include "L4Dr1.h"
- #include "PixtelDataTypes.h"
- /* ... Add More MMI header */
- #include "EventsGprot.h"
- #include "HistoryGprot.h"
- #include "GlobalMenuItems.h"
- #include "GlobalConstants.h"
- #include "Globaldefs.h"
- #include "wgui_categories.h"
- #include "CustMenuRes.h"
- #include "CommonScreens.h"
- #include "Unicodexdcl.h"
- #include "TimerEvents.h"
- #include "DebugInitDef.h"
- #include "ProtocolEvents.h"
- /* ...Add MSG header */
- #include "customer_ps_inc.h"
- #include "mmi_msg_context.h"
- #include "MessagesL4Def.h"
- #include "MessagesResourceData.h"
- #include "MessagesMiscell.h"
- #include "MessagesExDcl.h"
- #include "SmsGuiInterfaceProt.h"
- #include "SMsGuiInterfaceType.h"
- #include "SmsPsHandler.h"
- #include "CellBroadcastType.h"
- #ifdef __MMI_MESSAGES_CHAT__
- #include "ChatAppGprot.h"
- #include "ChatAppDef.h"
- #endif /* __MMI_MESSAGES_CHAT__ */
- /* */
- #include "customer_ps_inc.h"
- #include "l4c2smsal_struct.h"
- #include "smsal_l4c_enum.h"
- #include "ems.h"
- /* */
- #include "Gui_ems.h"
- #include "wgui_ems.h"
- #include "GSM7BitDefaultAlphabet.h"
- /* */
- #include "PhoneBookGprot.h"
- #include "CallHistoryGProts.h"
- #include "IdleAppProt.h"
- #include "SettingProfile.h"
- #include "ProfileGprots.h"
- #include "AlarmFrameworkProt.h"
- #include "PhoneBookTypes.h"
- #include "SimDetectionGexdcl.h"
- #include "SettingDefs.h"
- #include "SettingsGdcl.h"
- /* */
- #include "wgui_status_icons.h"
- #include "KeyBrd.h"
- #include "DateTimeGprot.h"
- #include "SMSApi.h"
- #include "SMSStruct.h"
- #include "SMSFunc.h"
- #ifdef __MMI_UNIFIED_MESSAGE__
- #include "UnifiedMessageGProt.h"
- #endif
- #define smstest
- #define MMI_FRM_SMS_INVALID_INDEX 0xffff
- #ifndef MMI_FRM_SMS_INVALID_NUM
- #define MMI_FRM_SMS_INVALID_NUM 0xff
- #endif
- #ifndef MMI_FRM_SMS_MSG_LEN
- #define MMI_FRM_SMS_MSG_LEN 160
- #endif
- #ifndef MMI_FRM_SMS_MSG_CONTENT_NUM
- #define MMI_FRM_SMS_MSG_CONTENT_NUM 20
- #endif
- #ifndef MMI_FRM_SMS_ACTION_SIZE
- #define MMI_FRM_SMS_ACTION_SIZE 10
- #endif
- static U16 mmi_frm_sms_msgbox_size = 0;
- static U16 mmi_frm_sms_inbox_size = 0;
- static U16 mmi_frm_sms_outbox_size = 0;
- #ifdef __MMI_MESSAGES_DRAFT_BOX__
- static U16 mmi_frm_sms_drafts_size = 0;
- #endif
- static U8 mmi_frm_sms_list_done = FALSE;
- static mmi_frm_sms_deliver_msg_struct mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE + 1];
- static mmi_frm_sms_deliver_data_struct mmi_frm_sms_data[MMI_FRM_SMS_ACTION_SIZE + 1];
- static mmi_frm_sms_content_struct mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM + 1];
- #ifdef __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__
- static mmi_frm_sms_delivery_report_list_struct mmi_frm_sms_delivery_report_awaited[MMI_FRM_SMS_ACTION_SIZE];
- #endif
- static U8 mmi_frm_sms_awaited_counter[MMI_FRM_SMS_ACTION_SIZE];
- static U8 mmi_frm_sms_awaited_counting = FALSE;
- static U8 mmi_frm_sms_data_counter[MMI_FRM_SMS_ACTION_SIZE];
- static U8 mmi_frm_sms_data_counting = FALSE;
- static U16 mmi_frm_sms_data_checked = 0;
- #ifdef __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__
- static U8 mmi_frm_sms_delivery_report_awaited_next_available = 0;
- #endif
- #define ONE_DIGIT(value) ((value) % 10)
- #ifdef __MMI_MESSAGES_MOSES_FEATURE__
- const U8 MMI_FRM_SMS_MOSES_PATTERN[6] = {0xa1, 0x1a, 0x5f, 0x20, 0x0a,0x00};
- #endif /* __MMI_MESSAGES_MOSES_FEATURE__ */
- extern U8 GetSecondSemiOctetTarget(U8 ch);
- extern U8 GetFirstSemiOctetTarget(U8 ch);
- extern void EMS_ConvertGSM7BitDefaultEncodingToAsciiWithoutEMSlib(EMSData *data);
- #define MMI_SMS_EURO_SIGN (0x20AC)
- #define MMI_SMS_TEST_GSM7BIT_EXTENDED(c)
- ( (c==MMI_SMS_EURO_SIGN)
- || (c=='^')
- || (c=='{')
- || (c=='}')
- || (c=='\')
- || (c=='[')
- || (c=='~')
- || (c==']')
- || (c=='|')
- )
- /*****************************************************************************
- * FUNCTION
- * ComparePhoneNum
- * DESCRIPTION
- * It Compares phone numbers
- * PARAMETERS
- * src [IN]
- * dst [IN]
- * Source and destination phone number(?)
- * RETURNS
- * status
- *****************************************************************************/
- pBOOL ComparePhoneNum(PU8 src, PU8 dst)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- long num1 = 0, num2 = 0;
- U8 temp1, temp2;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- num1 = mmi_phb_util_convert_number_to_int(src);
- num2 = mmi_phb_util_convert_number_to_int(dst);
- if (num1 == num2)
- {
- if (src[0] == '+')
- {
- src++;
- }
- if (dst[0] == '+')
- {
- dst++;
- }
- temp1 = strcspn((PS8) src, "+pw*#");
- temp2 = strcspn((PS8) dst, "+pw*#");
- if (temp1 && temp2)
- {
- src = src + temp1;
- dst = dst + temp2;
- }
- if (!strcmp((PS8) src, (PS8) dst))
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- else
- {
- return FALSE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_convert_time_stamp
- * DESCRIPTION
- * convert time stamp
- * PARAMETERS
- * scts [?] Scts
- * timestamp [?] Timestamp
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_convert_time_stamp(U8 *scts, U8 *timestamp)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* No Timestamp */
- if (scts[0] == MMI_FRM_SMS_INVALID_NUM)
- {
- memset((S8*) timestamp, 0, 7);
- return;
- }
- /* year */
- timestamp[0] = ONE_DIGIT(GetSecondSemiOctetTarget(scts[0])) * 10 + ONE_DIGIT(GetFirstSemiOctetTarget(scts[0]));
- /* month */
- timestamp[1] = ONE_DIGIT(GetSecondSemiOctetTarget(scts[1])) * 10 + ONE_DIGIT(GetFirstSemiOctetTarget(scts[1]));
- /* day */
- timestamp[2] = ONE_DIGIT(GetSecondSemiOctetTarget(scts[2])) * 10 + ONE_DIGIT(GetFirstSemiOctetTarget(scts[2]));
- /* hour */
- timestamp[3] = ONE_DIGIT(GetSecondSemiOctetTarget(scts[3])) * 10 + ONE_DIGIT(GetFirstSemiOctetTarget(scts[3]));
- /* minute */
- timestamp[4] = ONE_DIGIT(GetSecondSemiOctetTarget(scts[4])) * 10 + ONE_DIGIT(GetFirstSemiOctetTarget(scts[4]));
- /* second */
- timestamp[5] = ONE_DIGIT(GetSecondSemiOctetTarget(scts[5])) * 10 + ONE_DIGIT(GetFirstSemiOctetTarget(scts[5]));
- /**timezone, convert date/time to one variable */
- timestamp[6] = ONE_DIGIT(GetSecondSemiOctetTarget(scts[6])) * 10 + ONE_DIGIT(GetFirstSemiOctetTarget(scts[6]));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_convert_mytime
- * DESCRIPTION
- * convert MYTIME to scts
- * PARAMETERS
- * scts [?] Scts
- * time [?]
- * b timestamp timestamp(?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_convert_mytime(U8 *scts, MYTIME *time)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 year = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (time->nYear > 2000)
- {
- year = (U8)(time->nYear - 2000);
- }
- else
- {
- year = (U8)(time->nYear - 1900);
- }
- scts[0] = ((year % 10) << 4) | (year / 10);
- scts[1] = ((time->nMonth % 10) << 4) | (time->nMonth / 10);
- scts[2] = ((time->nDay % 10) << 4) | (time->nDay / 10);
- scts[3] = ((time->nHour % 10) << 4) | (time->nHour / 10);
- scts[4] = ((time->nMin % 10) << 4) | (time->nMin / 10);
- scts[5] = ((time->nSec % 10) << 4) | (time->nSec / 10);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_add_new_sms
- * DESCRIPTION
- * free new sms buff
- * PARAMETERS
- * entry [IN] Entry
- * length [IN]
- * data [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_add_new_sms(mmi_frm_sms_deliver_msg_struct *entry, U16 length, U8 *data)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_frm_sms_concat_struct *concatinfo = (mmi_frm_sms_concat_struct*) & (entry->concat_info);
- U16 index = entry->index;
- U8 segment = 1;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((concatinfo->seg > concatinfo->total_seg) || (concatinfo->seg == 0) || (concatinfo->total_seg == 0))
- {
- concatinfo->seg = 1;
- concatinfo->total_seg = 1;
- }
- if (((concatinfo->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 = (concatinfo->seg) % g_frm_sms_cntx.mmi_frm_sms_msg_seg_size;
- }
- /* change seg info to start seg */
- concatinfo->seg =
- ((concatinfo->seg - 1) / g_frm_sms_cntx.mmi_frm_sms_msg_seg_size) * g_frm_sms_cntx.mmi_frm_sms_msg_seg_size + 1;
- mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].dcs = entry->dcs;
- mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].display_type = entry->display_type;
- #ifdef __MMI_MESSAGES_COPY__
- mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].storageType = entry->storageType;
- #endif
- mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].fo = entry->fo;
- mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].index = entry->index;
- mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].mti = entry->mti;
- mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].pid = entry->pid;
- memcpy(&(mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].concat_info), concatinfo, sizeof(smsal_concat_struct));
- memcpy(
- (S8*) & (mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].addr_number),
- (S8*) & (entry->addr_number),
- sizeof(l4c_number_struct));
- memcpy(
- (S8*) & (mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].sca_number),
- (S8*) & (entry->sca_number),
- sizeof(l4c_number_struct));
- memcpy((S8*) (mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].scts), (S8*) (entry->scts), 7);
- mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].msg_data[0] = MMI_FRM_SMS_MSG_CONTENT_NUM;
- mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].no_msg_data = entry->no_msg_data;
- /* handle message content part */
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].segment = segment;
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].msglen = length;
- if (mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data != NULL)
- {
- OslMfree(mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data);
- }
- if (length)
- {
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data = OslMalloc(length);
- memcpy(mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data, (S8*) data, length);
- }
- /* class 0 message */
- if (index == MMI_FRM_SMS_INVALID_INDEX)
- {
- return;
- }
- /* used index list entry, replace the old entry with the new one */
- if (mmi_frm_sms_index_list[index].segment != MMI_FRM_SMS_INVALID_NUM)
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsUtil.c] mmi_frm_sms_add_new_sms remove used L4 list entry %d-------*n",
- index));
- /* Free awaited list entry and content list entry if the replaced msg is in awaited list */
- /* The replaced segment is the first segment of awaited msg */
- if (mmi_frm_sms_index_list[index].prevtype == MMI_FRM_SMS_AWAITS)
- {
- U16 awaited_index = (U16) mmi_frm_sms_index_list[index].previndex;
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsUtil.c] first segment in awaited list ------*n"));
-
- /* Only one segment in the awaited msg. Just delete the awaited msg. */
- if (mmi_frm_sms_index_list[index].nextindex == MMI_FRM_SMS_INVALID_INDEX)
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsUtil.c] free awaited list %d-------*n",
- awaited_index));
- /* Stop the timer counter of the awaited list entry to be deleted */
- mmi_frm_sms_awaited_counter[awaited_index] = MMI_FRM_SMS_INVALID_NUM;
- mmi_frm_sms_free_awaited(awaited_index);
- }
- /* More than one segment in the awaited msg. Modify awaited msg and free content list entry. */
- else
- {
- U8 content_index = mmi_frm_sms_awaited[awaited_index].msg_data[0];
- MMI_ASSERT(mmi_frm_sms_awaited[awaited_index].no_msg_data >= mmi_frm_sms_content[content_index].msglen);
-
- mmi_frm_sms_awaited[awaited_index].no_msg_data -= mmi_frm_sms_content[content_index].msglen;
- mmi_frm_sms_awaited[awaited_index].msg_data[0] = mmi_frm_sms_content[content_index].nextindex;
-
- if (mmi_frm_sms_content[content_index].data != NULL)
- {
- OslMfree(mmi_frm_sms_content[content_index].data);
- mmi_frm_sms_content[content_index].data = NULL;
- }
- mmi_frm_sms_content[content_index].msglen = 0;
- mmi_frm_sms_content[content_index].nextindex = MMI_FRM_SMS_INVALID_NUM;
- mmi_frm_sms_content[content_index].segment = MMI_FRM_SMS_INVALID_NUM;
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsUtil.c] modify awaited list %d-------*n",
- awaited_index));
- mmi_frm_sms_remove_sms_entry(index);
- }
- }
- else if (mmi_frm_sms_index_list[index].prevtype == MMI_FRM_SMS_NOBOX)
- {
- U16 L4index = mmi_frm_sms_index_list[index].previndex;
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsUtil.c] type of segment is NOBOX ------*n"));
-
- while (mmi_frm_sms_index_list[L4index].prevtype == MMI_FRM_SMS_NOBOX)
- {
- L4index = mmi_frm_sms_index_list[L4index].previndex;
- }
- /* The replaced segment is in the awaited list */
- if (mmi_frm_sms_index_list[L4index].prevtype == MMI_FRM_SMS_AWAITS)
- {
- U16 awaited_index = (U16) mmi_frm_sms_index_list[L4index].previndex;
- U8 content_index = mmi_frm_sms_awaited[awaited_index].msg_data[0];
- U8 pre_content_index = MMI_FRM_SMS_INVALID_NUM;
- U8 segment = mmi_frm_sms_index_list[index].segment;
-
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsUtil.c] non-first segment in awaited list -------*n"));
- while(content_index != MMI_FRM_SMS_INVALID_NUM)
- {
- if (mmi_frm_sms_content[content_index].segment == segment)
- {
- break;
- }
- pre_content_index = content_index;
- content_index = mmi_frm_sms_content[content_index].nextindex;
- }
-
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "[SmsUtil.c] After search for content entry, segment=%d content_index=%d pre_content_index=%d n",
- segment, content_index, pre_content_index));
- if (content_index != MMI_FRM_SMS_INVALID_NUM && pre_content_index != MMI_FRM_SMS_INVALID_NUM)
- {
- MMI_ASSERT(mmi_frm_sms_awaited[awaited_index].no_msg_data >= mmi_frm_sms_content[content_index].msglen);
-
- mmi_frm_sms_awaited[awaited_index].no_msg_data -= mmi_frm_sms_content[content_index].msglen;
- mmi_frm_sms_content[pre_content_index].nextindex = mmi_frm_sms_content[content_index].nextindex;
-
- if (mmi_frm_sms_content[content_index].data != NULL)
- {
- OslMfree(mmi_frm_sms_content[content_index].data);
- mmi_frm_sms_content[content_index].data = NULL;
- }
- mmi_frm_sms_content[content_index].msglen = 0;
- mmi_frm_sms_content[content_index].nextindex = MMI_FRM_SMS_INVALID_NUM;
- mmi_frm_sms_content[content_index].segment = MMI_FRM_SMS_INVALID_NUM;
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsUtil.c] modify awaited list -------*n"));
- mmi_frm_sms_remove_sms_entry(index);
- }
- else
- {
- MMI_ASSERT(0);
- }
-
- }
-
- /* The replaced segment is in the message box */
- else
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsUtil.c] The replaced segment is in the message box -------*n"));
- mmi_frm_sms_remove_sms_entry(index);
- }
- }
-
- /* The replaced segment is in the message box */
- else
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsUtil.c] The replaced segment is in the message box-------*n"));
- mmi_frm_sms_remove_sms_entry(index);
- }
- }
- mmi_frm_sms_index_list[index].segment = mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].segment;
- mmi_frm_sms_index_list[index].nextindex = MMI_FRM_SMS_INVALID_INDEX;
- mmi_frm_sms_index_list[index].previndex = MMI_FRM_SMS_ACTION_SIZE;;
- mmi_frm_sms_index_list[index].prevtype = MMI_FRM_SMS_AWAITS;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_free_new_sms
- * DESCRIPTION
- * free new sms buff
- * PARAMETERS
- * void
- * entry(?) [IN] Entry
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_free_new_sms(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data != NULL)
- {
- OslMfree(mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data);
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data = NULL;
- }
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].msglen = 0;
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].nextindex = MMI_FRM_SMS_INVALID_NUM;
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].segment = MMI_FRM_SMS_INVALID_NUM;
- memset(
- (S8*) & mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE],
- MMI_FRM_SMS_INVALID_NUM,
- sizeof(mmi_frm_sms_deliver_msg_struct));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_free_awaited
- * DESCRIPTION
- * Free awaited message by index
- * PARAMETERS
- * index [IN] Index
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_free_awaited(U8 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 i = mmi_frm_sms_awaited[index].msg_data[0];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (i != MMI_FRM_SMS_INVALID_NUM)
- {
- U8 nextindex = mmi_frm_sms_content[i].nextindex;
- if (mmi_frm_sms_content[i].data != NULL)
- {
- OslMfree(mmi_frm_sms_content[i].data);
- mmi_frm_sms_content[i].data = NULL;
- }
- mmi_frm_sms_content[i].msglen = 0;
- mmi_frm_sms_content[i].nextindex = MMI_FRM_SMS_INVALID_NUM;
- mmi_frm_sms_content[i].segment = MMI_FRM_SMS_INVALID_NUM;
- i = nextindex;
- }
- memset((S8*) & mmi_frm_sms_awaited[index], MMI_FRM_SMS_INVALID_NUM, sizeof(mmi_frm_sms_deliver_msg_struct));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_add_new_data
- * DESCRIPTION
- * free new sms buff
- * PARAMETERS
- * entry [IN] Entry
- * length [IN]
- * data [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_add_new_data(mmi_frm_sms_deliver_data_struct *entry, U16 length, U8 *data)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_frm_sms_concat_struct *concatinfo = (mmi_frm_sms_concat_struct*) & (entry->concat_info);
- U8 segment = 1;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((concatinfo->seg > concatinfo->total_seg) || (concatinfo->seg == 0) || (concatinfo->total_seg == 0))
- {
- concatinfo->seg = 1;
- concatinfo->total_seg = 1;
- }
- if (((concatinfo->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 = (concatinfo->seg) % g_frm_sms_cntx.mmi_frm_sms_msg_seg_size;
- }
- /* change seg info to start seg */
- concatinfo->seg =
- ((concatinfo->seg - 1) / g_frm_sms_cntx.mmi_frm_sms_msg_seg_size) * g_frm_sms_cntx.mmi_frm_sms_msg_seg_size + 1;
- mmi_frm_sms_data[MMI_FRM_SMS_ACTION_SIZE].dest_mod_id = entry->dest_mod_id;
- mmi_frm_sms_data[MMI_FRM_SMS_ACTION_SIZE].dest_port = entry->dest_port;
- mmi_frm_sms_data[MMI_FRM_SMS_ACTION_SIZE].dcs = entry->dcs;
- mmi_frm_sms_data[MMI_FRM_SMS_ACTION_SIZE].mti = entry->mti;
- memcpy(&(mmi_frm_sms_data[MMI_FRM_SMS_ACTION_SIZE].concat_info), concatinfo, sizeof(smsal_concat_struct));
- memcpy((S8*) & (mmi_frm_sms_data[MMI_FRM_SMS_ACTION_SIZE].oa), (S8*) & (entry->oa), sizeof(l4c_number_struct));
- memcpy((S8*) (mmi_frm_sms_data[MMI_FRM_SMS_ACTION_SIZE].scts), (S8*) (entry->scts), 7);
- mmi_frm_sms_data[MMI_FRM_SMS_ACTION_SIZE].data[0] = MMI_FRM_SMS_MSG_CONTENT_NUM;
- mmi_frm_sms_data[MMI_FRM_SMS_ACTION_SIZE].message_len = entry->message_len;
- /* handle message content part */
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].segment = segment;
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].msglen = length;
- if (mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data != NULL)
- {
- OslMfree(mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data);
- }
- if (length)
- {
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data = OslMalloc(length);
- memcpy(mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data, (S8*) data, length);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_free_new_data
- * DESCRIPTION
- * free new sms buff
- * PARAMETERS
- * void
- * entry(?) [IN] Entry
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_free_new_data(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data != NULL)
- {
- OslMfree(mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data);
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data = NULL;
- }
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].msglen = 0;
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].nextindex = MMI_FRM_SMS_INVALID_NUM;
- mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].segment = MMI_FRM_SMS_INVALID_NUM;
- memset(
- (S8*) & mmi_frm_sms_data[MMI_FRM_SMS_ACTION_SIZE],
- MMI_FRM_SMS_INVALID_NUM,
- sizeof(mmi_frm_sms_deliver_data_struct));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_free_data
- * DESCRIPTION
- * Free SMS with port number by index
- * PARAMETERS
- * index [IN] Index
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_free_data(U8 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 i = mmi_frm_sms_data[index].data[0];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (i != MMI_FRM_SMS_INVALID_NUM)
- {
- U8 nextindex = mmi_frm_sms_content[i].nextindex;
- if (mmi_frm_sms_content[i].data != NULL)
- {
- OslMfree(mmi_frm_sms_content[i].data);
- mmi_frm_sms_content[i].data = NULL;
- }
- mmi_frm_sms_content[i].msglen = 0;
- mmi_frm_sms_content[i].nextindex = MMI_FRM_SMS_INVALID_NUM;
- mmi_frm_sms_content[i].segment = MMI_FRM_SMS_INVALID_NUM;
- i = nextindex;
- }
- memset((S8*) & mmi_frm_sms_data[index], MMI_FRM_SMS_INVALID_NUM, sizeof(mmi_frm_sms_deliver_data_struct));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_convert_new_data
- * DESCRIPTION
- * convert mt structure to entry structure
- * PARAMETERS
- * data [?] New data
- * entry [?] Message entry
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_convert_new_data(MMI_FRM_SMS_APP_DATA_IND_STRUCT *data, mmi_frm_sms_deliver_data_struct *entry)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- entry->dest_mod_id = data->dest_mod_id;
- entry->dest_port = data->dest_port;
- entry->src_port = data->src_port;
- entry->dcs = data->dcs;
- entry->mti = data->mti;
- entry->message_len = data->message_len;
- entry->concat_info = data->concat_info[0];
- memcpy(&entry->oa, &data->oa, sizeof(l4_addr_bcd_struct));
- memcpy(entry->scts, data->scts, 7);
- entry->data[0] = MMI_FRM_SMS_MSG_CONTENT_NUM;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_convert_new_sms
- * DESCRIPTION
- * convert mt structure to entry structure
- * PARAMETERS
- * data [?] Data
- * entry [?]
- * a index index(?)
- * b type type(?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_convert_new_sms(MMI_FRM_SMS_DELIVER_MSG_IND_STRUCT *data, mmi_frm_sms_deliver_msg_struct *entry)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- entry->fo = data->fo;
- memcpy(entry->scts, data->scts, 7);
- memcpy(&entry->sca_number, &data->sca_number, sizeof(l4c_number_struct));
- memcpy(&entry->addr_number, &data->oa_number, sizeof(l4c_number_struct));
- entry->pid = data->pid;
- entry->dcs = data->dcs;
- entry->ori_dcs = data->ori_dcs;
- entry->index = data->index; /* for awaited message, this is the start index */
- entry->mti = data->mti;
- entry->display_type = data->display_type;
- #ifdef __MMI_MESSAGES_COPY__
- entry->storageType = data->storage_type;
- #endif
- entry->concat_info = data->concat_info;
- entry->no_msg_data = data->no_msg_data;
- entry->msg_data[0] = MMI_FRM_SMS_MSG_CONTENT_NUM;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_convert_mt_to_entry
- * DESCRIPTION
- * convert mt structure to entry structure
- * PARAMETERS
- * data [?] Data
- * entry [?]
- * a index index(?)
- * b type type(?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_convert_mt_to_entry(mmi_frm_sms_deliver_msg_struct *data, mmi_frm_sms_msgbox_struct *entry)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 type;
- U8 numbertype = (data->addr_number.type == CSMCC_INTERNATIONAL_ADDR ||
- (data->addr_number.type & 0xf0) == 0x90) ? 1 : 0;
- mmi_frm_sms_concat_struct *concat = (mmi_frm_sms_concat_struct*) & (data->concat_info);
- MMI_BOOL is_compress = MMI_FALSE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset((S8*) entry->number, 0, MAX_DIGITS_SMS);
- if (numbertype)
- {
- entry->number[0] = '+';
- }
- memcpy(entry->number + numbertype, data->addr_number.number, data->addr_number.length);
- #ifdef __MMI_MESSAGES_MOSES_FEATURE__
- if ((data->addr_number.type & 0xd0) == 0xd0)
- {
- /* Support ORANGE MOSES requirement */
- if (data->addr_number.length == 5 &&
- strcmp((S8*)data->addr_number.number,(S8*)MMI_FRM_SMS_MOSES_PATTERN) == 0)
- {
- if (gOpNameValid && (pfnUnicodeStrlen(gOperatorName) != 0))
- {
- memset((S8*) entry->number, 0, sizeof(entry->number));
- UnicodeNToAnsii((S8*) entry->number, (S8*) gOperatorName, sizeof(entry->number));
- }
- }
- }
- #endif /* __MMI_MESSAGES_MOSES_FEATURE__ */
-
- type = MMI_FRM_SMS_UNREAD;
- #ifdef __MMI_UNIFIED_MESSAGE__
- #ifdef __MMI_MESSAGES_NOT_DISPLAY_8BIT_DCS_SMS_CONTENT__
- if (data->dcs == SMSAL_8BIT_DCS)
- {
- entry->msgtype = (SMSAL_MTI_UNSPECIFIED << 4) | type;
- }
- else
- #endif /* __MMI_MESSAGES_NOT_DISPLAY_8BIT_DCS_SMS_CONTENT__ */
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- {
- entry->msgtype = (data->mti << 4) | type;
- }
-
- /* Compress dcs SMS is not supported. */
- ems_decode_dcs(data->ori_dcs, &is_compress);
- if (is_compress)
- {
- entry->msgtype = (SMSAL_MTI_UNSPECIFIED << 4) | type;
- }
- entry->startseg =
- ((concat->seg - 1) / g_frm_sms_cntx.mmi_frm_sms_msg_seg_size) * g_frm_sms_cntx.mmi_frm_sms_msg_seg_size + 1;
- entry->totalseg = concat->total_seg;
- entry->startindex = data->index;
- #ifdef __MMI_MESSAGES_COPY__
- entry->storageType = data->storageType;
- #endif
- entry->ref = concat->ref;
- mmi_frm_sms_convert_time_stamp(data->scts, entry->timestamp);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_convert_mo_to_entry
- * DESCRIPTION
- * convert mo structure to entry structure
- * PARAMETERS
- * data [?] Data
- * entry [?]
- * index [IN] Index
- * status [IN]
- * totalsegment [IN]
- * reference [IN]
- * storagetype [IN]
- * time [?]
- * b type type(?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_convert_mo_to_entry(
- mmi_frm_sms_send_struct *data,
- mmi_frm_sms_msgbox_struct *entry,
- U16 index,
- U8 status,
- U8 totalsegment,
- U16 reference,
- U8 storagetype,
- MYTIME *time)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 type = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (status)
- {
- case SMSAL_REC_UNREAD:
- type = MMI_FRM_SMS_UNREAD;
- break;
- case SMSAL_REC_READ:
- type = MMI_FRM_SMS_INBOX;
- break;
- case SMSAL_STO_SENT:
- type = MMI_FRM_SMS_OUTBOX;
- break;
- case SMSAL_STO_UNSENT:
- type = MMI_FRM_SMS_DRAFTS;
- break;
- }
- entry->msgtype = (SMSAL_MTI_SUBMIT << 4) | type;
- entry->startindex = index;
- entry->startseg = 1;
- entry->totalseg = totalsegment;
- memset((S8*) entry->timestamp, 0, 7);
- memset((S8*) entry->number, 0, 21);
- memcpy((S8*) entry->number, (S8*) data->number, strlen((S8*) data->number));
- entry->ref = reference;
- #ifdef __MMI_MESSAGES_COPY__
- entry->storageType = storagetype;
- #endif
- if (storagetype == SMSAL_SM)
- {
- memset((S8*) entry->timestamp, 0, 7);
- }
- else
- {
- /* Add timestamp information */
- if (time->nYear > 2000)
- {
- entry->timestamp[0] = (U8) (time->nYear - 2000);
- }
- else
- {
- entry->timestamp[0] = (U8) (time->nYear - 1900);
- }
- entry->timestamp[1] = time->nMonth;
- entry->timestamp[2] = time->nDay;
- entry->timestamp[3] = time->nHour;
- entry->timestamp[4] = time->nMin;
- entry->timestamp[5] = time->nSec;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_convert_read_to_entry
- * DESCRIPTION
- * convert read structure to entry structure
- * PARAMETERS
- * data [?] Data
- * entry [?]
- * index [IN] Index
- * b type type(?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_convert_read_to_entry(
- MMI_FRM_SMS_GET_MSG_RSP_STRUCT *data,
- mmi_frm_sms_msgbox_struct *entry,
- U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 type;
- mmi_frm_sms_concat_struct *concat = (mmi_frm_sms_concat_struct*) & (data->concat_info);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (data->status)
- {
- case SMSAL_REC_UNREAD:
- type = MMI_FRM_SMS_UNREAD;
- break;
- case SMSAL_REC_READ:
- type = MMI_FRM_SMS_INBOX;
- break;
- case SMSAL_STO_SENT:
- type = MMI_FRM_SMS_OUTBOX;
- break;
- case SMSAL_STO_UNSENT:
- type = MMI_FRM_SMS_DRAFTS;
- break;
- default:
- type = MMI_FRM_SMS_NOBOX;
- break;
- }
- entry->msgtype = (data->mti << 4) | type;
- entry->startseg =
- ((concat->seg - 1) / g_frm_sms_cntx.mmi_frm_sms_msg_seg_size) * g_frm_sms_cntx.mmi_frm_sms_msg_seg_size + 1;
- entry->totalseg = concat->total_seg;
- memset((S8*) entry->number, 0, MAX_DIGITS_SMS);
- type = (data->addr_number.type == CSMCC_INTERNATIONAL_ADDR ||
- (data->addr_number.type & 0xf0) == 0x90) ? 1 : 0;
- if (type)
- {
- entry->number[0] = '+';
- }
- memcpy((S8*) & (entry->number[type]), (S8*) data->addr_number.number, data->addr_number.length);
-
- #ifdef __MMI_MESSAGES_MOSES_FEATURE__
- if ((data->addr_number.type & 0xd0) == 0xd0)
- {
- /* Support ORANGE MOSES requirement */
- if (data->addr_number.length == 5 &&
- strcmp((S8*)data->addr_number.number,(S8*)MMI_FRM_SMS_MOSES_PATTERN) == 0)
- {
- if (gOpNameValid && (pfnUnicodeStrlen(gOperatorName) != 0))
- {
- memset((S8*) entry->number, 0, sizeof(entry->number));
- UnicodeNToAnsii((S8*) entry->number, (S8*) gOperatorName, sizeof(entry->number));
- }
- }
- }
- #endif /* __MMI_MESSAGES_MOSES_FEATURE__ */
- entry->ref = concat->ref;
- entry->startindex = index;
- #ifdef __MMI_MESSAGES_COPY__
- entry->storageType = data->storage_type;
- #endif
- #ifdef __MMI_UNIFIED_MESSAGE__
- {
- U8 *content = NULL;
- content = OslMalloc(MMI_FRM_SMS_MSG_LEN);
- memset(content, 0, MMI_FRM_SMS_MSG_LEN);
- memset(entry->content, 0, sizeof(entry->content));
- mmi_frm_sms_get_read_sms_content(data, content);
- if (pfnUnicodeStrlen((S8*) content))
- {
- mmi_frm_sms_add_content_to_entry(entry, content);
- }
- OslMfree(content);
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- mmi_frm_sms_convert_time_stamp(data->scts, entry->timestamp);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_convert_startup_read_to_entry
- * DESCRIPTION
- * convert startup read structure to entry structure
- * PARAMETERS
- * data [?] Data
- * entry [?]
- * a index index(?)
- * b type type(?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_convert_startup_read_to_entry(
- MMI_FRM_SMS_STARTUP_READ_MSG_IND_STRUCT *data,
- mmi_frm_sms_msgbox_struct *entry)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 type;
- mmi_frm_sms_concat_struct concat;
- MMI_BOOL is_compress = MMI_FALSE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- concat.seg = (data->concat_info & 0xff000000) >> 24;
- concat.total_seg = (data->concat_info & 0x00ff0000) >> 16;
- concat.ref = (data->concat_info & 0x0000ffff);
- switch (data->status)
- {
- case SMSAL_REC_UNREAD:
- type = MMI_FRM_SMS_UNREAD;
- break;
- case SMSAL_REC_READ:
- type = MMI_FRM_SMS_INBOX;
- break;
- case SMSAL_STO_SENT:
- type = MMI_FRM_SMS_OUTBOX;
- break;
- case SMSAL_STO_UNSENT:
- type = MMI_FRM_SMS_DRAFTS;
- break;
- default:
- type = MMI_FRM_SMS_NOBOX;
- break;
- }
- #ifdef __MMI_UNIFIED_MESSAGE__
- #ifdef __MMI_MESSAGES_NOT_DISPLAY_8BIT_DCS_SMS_CONTENT__
- if (data->dcs == SMSAL_8BIT_DCS)
- {
- entry->msgtype = (SMSAL_MTI_UNSPECIFIED << 4) | type;
- }
- else
- #endif /* __MMI_MESSAGES_NOT_DISPLAY_8BIT_DCS_SMS_CONTENT__ */
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- {
- entry->msgtype = (data->mti << 4) | type;
- }
-
- /* Compress dcs SMS is not supported. */
- ems_decode_dcs(data->ori_dcs, &is_compress);
- if (is_compress)
- {
- entry->msgtype = (SMSAL_MTI_UNSPECIFIED << 4) | type;
- }
- entry->startseg =
- ((concat.seg - 1) / g_frm_sms_cntx.mmi_frm_sms_msg_seg_size) * g_frm_sms_cntx.mmi_frm_sms_msg_seg_size + 1;
- entry->totalseg = concat.total_seg;
- memset((S8*) entry->number, 0, MAX_DIGITS_SMS);
- type = (data->addr_number.type == CSMCC_INTERNATIONAL_ADDR ||
- (data->addr_number.type & 0xf0) == 0x90) ? 1 : 0;
- if (type)
- {
- entry->number[0] = '+';
- }
- memcpy((S8*) & (entry->number[type]), (S8*) data->addr_number.number, data->addr_number.length);
- #ifdef __MMI_MESSAGES_MOSES_FEATURE__
- if ((data->addr_number.type & 0xd0) == 0xd0)
- {
- /* Support ORANGE MOSES requirement */
- if (data->addr_number.length == 5 &&
- strcmp((S8*)data->addr_number.number,(S8*)MMI_FRM_SMS_MOSES_PATTERN) == 0)
- {
- if (gOpNameValid && (pfnUnicodeStrlen(gOperatorName) != 0))
- {
- memset((S8*) entry->number, 0, sizeof(entry->number));
- UnicodeNToAnsii((S8*) entry->number, (S8*) gOperatorName, sizeof(entry->number));
- }
- }
- }
- #endif /* __MMI_MESSAGES_MOSES_FEATURE__ */
- entry->ref = concat.ref;
- entry->startindex = data->index;
- mmi_frm_sms_convert_time_stamp(data->scts, entry->timestamp);
- #ifdef __MMI_MESSAGES_COPY__
- entry->storageType = data->storage_type;
- #endif
- #ifdef __MMI_UNIFIED_MESSAGE__
- {
- U8 *content = NULL;
- memset(entry->content, 0, sizeof(entry->content));
- content = OslMalloc(MMI_FRM_SMS_MSG_LEN);
- memset(content, 0, MMI_FRM_SMS_MSG_LEN);
- mmi_frm_sms_get_startup_sms_content(data, content);
- if (pfnUnicodeStrlen((S8*) content))
- {
- mmi_frm_sms_add_content_to_entry(entry, content);
- }
- OslMfree(content);
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_compare_entry
- * DESCRIPTION
- * convert mo structure to entry structure
- * PARAMETERS
- * index [IN] Index
- * data [?] Data
- * thissegment [IN]
- * b type type(?)
- * RETURNS
- * void
- *****************************************************************************/
- U8 mmi_frm_sms_compare_entry(U16 index, mmi_frm_sms_msgbox_struct *data, U8 thissegment)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* concatenate class0 message will have a MMI_FRM_SMS_INVALID_INDEX startindex */
- if ((data->startindex != MMI_FRM_SMS_INVALID_INDEX) && (mmi_frm_sms_msg_box[index].startindex == data->startindex))
- {
- return TRUE;
- }
- if ((mmi_frm_sms_msg_box[index].msgtype & 0xf0) == (data->msgtype & 0xf0))
- if (mmi_frm_sms_msg_box[index].ref == data->ref)
- if (mmi_frm_sms_msg_box[index].totalseg == data->totalseg)
- if (mmi_frm_sms_msg_box[index].startseg == data->startseg)
- if (ComparePhoneNum((U8*) data->number, (U8*) mmi_frm_sms_msg_box[index].number) == TRUE)
- {
- U16 i = mmi_frm_sms_msg_box[index].startindex;
- U16 previndex = MMI_FRM_SMS_INVALID_INDEX;
- while (i != MMI_FRM_SMS_INVALID_INDEX)
- {
- if (mmi_frm_sms_index_list[i].segment == thissegment)
- {
- return FALSE;
- }
- else if (mmi_frm_sms_index_list[i].segment > thissegment)
- {
- return TRUE;
- }
- previndex = i;
- i = mmi_frm_sms_index_list[i].nextindex;
- }
- if ((previndex != MMI_FRM_SMS_INVALID_INDEX) &&
- (mmi_frm_sms_index_list[previndex].segment < thissegment))
- {
- return TRUE;
- }
- }
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_add_sms_to_list
- * DESCRIPTION
- * mmi_frm_sms_add_sms_to_list
- * PARAMETERS
- * data [?] Data
- * index [IN] Index
- * b type type(?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_add_sms_to_list(mmi_frm_sms_msgbox_struct *data, U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 type = MMI_FRM_SMS_NOBOX;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((data->msgtype & MMI_FRM_SMS_UNREAD) == MMI_FRM_SMS_UNREAD)
- {
- type = MMI_FRM_SMS_UNREAD;
- }
- else if ((data->msgtype & MMI_FRM_SMS_INBOX) == MMI_FRM_SMS_INBOX)
- {
- type = MMI_FRM_SMS_INBOX;
- }
- else if ((data->msgtype & MMI_FRM_SMS_OUTBOX) == MMI_FRM_SMS_OUTBOX)
- {
- type = MMI_FRM_SMS_OUTBOX;
- }
- else if ((data->msgtype & MMI_FRM_SMS_DRAFTS) == MMI_FRM_SMS_DRAFTS)
- #ifdef __MMI_MESSAGES_DRAFT_BOX__
- type = MMI_FRM_SMS_DRAFTS;
- #else
- type = MMI_FRM_SMS_OUTBOX;
- #endif
- switch (type)
- {
- case MMI_FRM_SMS_INBOX:
- case MMI_FRM_SMS_UNREAD:
- {
- U16 i = 0;
- U16 j;
- while (i < mmi_frm_sms_inbox_size)
- {
- if (mmi_frm_sms_inbox_list[i] == index)
- {
- return;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[i]].timestamp[0] < data->timestamp[0])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[i]].timestamp[0] > data->timestamp[0])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[i]].timestamp[1] < data->timestamp[1])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[i]].timestamp[1] > data->timestamp[1])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[i]].timestamp[2] < data->timestamp[2])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[i]].timestamp[2] > data->timestamp[2])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[i]].timestamp[3] < data->timestamp[3])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[i]].timestamp[3] > data->timestamp[3])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[i]].timestamp[4] < data->timestamp[4])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[i]].timestamp[4] > data->timestamp[4])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[i]].timestamp[5] <= data->timestamp[5])
- {
- break;
- }
- i++;
- continue;
- }
- if (mmi_frm_sms_inbox_size > 0)
- {
- for (j = mmi_frm_sms_inbox_size; j > i; j--)
- {
- mmi_frm_sms_inbox_list[j] = mmi_frm_sms_inbox_list[j - 1];
- }
- }
- mmi_frm_sms_inbox_list[i] = index;
- mmi_frm_sms_inbox_size++;
- }
- break;
- case MMI_FRM_SMS_OUTBOX:
- #ifndef __MMI_MESSAGES_DRAFT_BOX__
- case MMI_FRM_SMS_DRAFTS:
- #endif
- {
- U16 i = 0;
- U16 j = 0;
- U16 k = 0;
- for (k = 0; k < mmi_frm_sms_outbox_size; k++)
- {
- if (mmi_frm_sms_outbox_list[k] == index)
- {
- return;
- }
- }
- /* No timestamp */
- if (data->timestamp[1] == 0)
- {
- mmi_frm_sms_outbox_list[mmi_frm_sms_outbox_size] = index;
- mmi_frm_sms_outbox_size++;
- }
- else
- {
- while (i < mmi_frm_sms_outbox_size)
- {
- if (mmi_frm_sms_outbox_list[i] == index)
- {
- return;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[i]].timestamp[0] < data->timestamp[0])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[i]].timestamp[0] > data->timestamp[0])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[i]].timestamp[1] < data->timestamp[1])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[i]].timestamp[1] > data->timestamp[1])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[i]].timestamp[2] < data->timestamp[2])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[i]].timestamp[2] > data->timestamp[2])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[i]].timestamp[3] < data->timestamp[3])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[i]].timestamp[3] > data->timestamp[3])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[i]].timestamp[4] < data->timestamp[4])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[i]].timestamp[4] > data->timestamp[4])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[i]].timestamp[5] <= data->timestamp[5])
- {
- break;
- }
- i++;
- continue;
- }
- if (mmi_frm_sms_outbox_size > 0)
- {
- for (j = mmi_frm_sms_outbox_size; j > i; j--)
- {
- mmi_frm_sms_outbox_list[j] = mmi_frm_sms_outbox_list[j - 1];
- }
- }
- mmi_frm_sms_outbox_list[i] = index;
- mmi_frm_sms_outbox_size++;
- }
- }
- break;
- #ifdef __MMI_MESSAGES_DRAFT_BOX__
- case MMI_FRM_SMS_DRAFTS:
- {
- U16 i = 0;
- U16 j = 0;
- U16 k = 0;
- for (k = 0; k < mmi_frm_sms_drafts_size; k++)
- {
- if (mmi_frm_sms_drafts_list[k] == index)
- {
- return;
- }
- }
- /* No timestamp */
- if (data->timestamp[1] == 0)
- {
- mmi_frm_sms_drafts_list[mmi_frm_sms_drafts_size] = index;
- mmi_frm_sms_drafts_size++;
- }
- else
- {
- while (i < mmi_frm_sms_drafts_size)
- {
- if (mmi_frm_sms_drafts_list[i] == index)
- {
- return;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[i]].timestamp[0] < data->timestamp[0])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[i]].timestamp[0] > data->timestamp[0])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[i]].timestamp[1] < data->timestamp[1])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[i]].timestamp[1] > data->timestamp[1])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[i]].timestamp[2] < data->timestamp[2])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[i]].timestamp[2] > data->timestamp[2])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[i]].timestamp[3] < data->timestamp[3])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[i]].timestamp[3] > data->timestamp[3])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[i]].timestamp[4] < data->timestamp[4])
- {
- break;
- }
- else if (mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[i]].timestamp[4] > data->timestamp[4])
- {
- i++;
- continue;
- }
- if (mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[i]].timestamp[5] <= data->timestamp[5])
- {
- break;
- }
- i++;
- continue;
- }
- if (mmi_frm_sms_drafts_size > 0)
- {
- for (j = mmi_frm_sms_drafts_size; j > i; j--)
- {
- mmi_frm_sms_drafts_list[j] = mmi_frm_sms_drafts_list[j - 1];
- }
- }
- mmi_frm_sms_drafts_list[i] = index;
- mmi_frm_sms_drafts_size++;
- }
- }
- break;
- #endif /* __MMI_MESSAGES_DRAFT_BOX__ */
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_remove_sms_from_list
- * DESCRIPTION
- * mmi_frm_sms_remove_sms_from_list
- * PARAMETERS
- * index [IN] Index
- * type [IN] Type
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_remove_sms_from_list(U16 index, U8 type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i = 0;
- U16 j = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_NOBOX) == MMI_FRM_SMS_INVALID_INDEX)
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[SmsUtil.c] mmi_frm_sms_remove_sms_from_list DO NOTHING -------*n"));
- return;
- }
- switch (type)
- {
- case MMI_FRM_SMS_INBOX:
- case MMI_FRM_SMS_UNREAD:
- while (i < mmi_frm_sms_inbox_size)
- {
- if (mmi_frm_sms_inbox_list[i] == index)
- {
- break;
- }
- i++;
- }
- for (j = i; j < (mmi_frm_sms_inbox_size - 1); j++)
- {
- mmi_frm_sms_inbox_list[j] = mmi_frm_sms_inbox_list[j + 1];
- }
- mmi_frm_sms_inbox_list[j] = MMI_FRM_SMS_INVALID_INDEX;
- mmi_frm_sms_inbox_size--;
- break;
- case MMI_FRM_SMS_OUTBOX:
- #ifndef __MMI_MESSAGES_DRAFT_BOX__
- case MMI_FRM_SMS_DRAFTS:
- #endif
- while (i < mmi_frm_sms_outbox_size)
- {
- if (mmi_frm_sms_outbox_list[i] == index)
- {
- break;
- }
- i++;
- }
- for (j = i; j < (mmi_frm_sms_outbox_size - 1); j++)
- {
- mmi_frm_sms_outbox_list[j] = mmi_frm_sms_outbox_list[j + 1];
- }
- mmi_frm_sms_outbox_list[j] = MMI_FRM_SMS_INVALID_INDEX;
- mmi_frm_sms_outbox_size--;
- break;
- #ifdef __MMI_MESSAGES_DRAFT_BOX__
- case MMI_FRM_SMS_DRAFTS:
- while (i < mmi_frm_sms_drafts_size)
- {
- if (mmi_frm_sms_drafts_list[i] == index)
- {
- break;
- }
- i++;
- }
- for (j = i; j < (mmi_frm_sms_drafts_size - 1); j++)
- {
- mmi_frm_sms_drafts_list[j] = mmi_frm_sms_drafts_list[j + 1];
- }
- mmi_frm_sms_drafts_list[j] = MMI_FRM_SMS_INVALID_INDEX;
- mmi_frm_sms_drafts_size--;
- break;
- #endif /* __MMI_MESSAGES_DRAFT_BOX__ */
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_add_sms_segment
- * DESCRIPTION
- * add one segment to sms entry
- * PARAMETERS
- * index [IN] Index
- * addindex [IN] Addindex
- * segment [IN] Segment
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_add_sms_segment(U16 index, U16 addindex, U8 segment)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 thisindex = mmi_frm_sms_msg_box[index].startindex;
- U8 islast = TRUE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_frm_sms_index_list[addindex].segment = segment;
- /* thisindex is the current smallest segment index of this message */
- if (mmi_frm_sms_index_list[thisindex].segment > segment)
- {
- islast = FALSE;
- /* addindex is inserted in the head, now addindex is the current smallest segment index of this message */
- mmi_frm_sms_msg_box[index].startindex = addindex;
- }
- else
- {
- while (mmi_frm_sms_index_list[thisindex].nextindex != MMI_FRM_SMS_INVALID_INDEX)
- {
- thisindex = mmi_frm_sms_index_list[thisindex].nextindex;
- if (mmi_frm_sms_index_list[thisindex].segment > segment)
- {
- islast = FALSE;
- break;
- }
- }
- }
- if (islast == TRUE)
- {
- /* addindex is inserted in the tail, now addindex is the current largest segment index of this message */
- mmi_frm_sms_index_list[thisindex].nextindex = addindex;
- mmi_frm_sms_index_list[addindex].nextindex = MMI_FRM_SMS_INVALID_INDEX;
- mmi_frm_sms_index_list[addindex].previndex = thisindex;
- mmi_frm_sms_index_list[addindex].prevtype = MMI_FRM_SMS_NOBOX;
- }
- else
- {
- /* addindex is inserted in the middle */
- mmi_frm_sms_index_list[addindex].nextindex = thisindex;
- mmi_frm_sms_index_list[addindex].previndex = mmi_frm_sms_index_list[thisindex].previndex;
- mmi_frm_sms_index_list[addindex].prevtype = mmi_frm_sms_index_list[thisindex].prevtype;
- if (mmi_frm_sms_index_list[thisindex].prevtype == MMI_FRM_SMS_NOBOX)
- {
- mmi_frm_sms_index_list[mmi_frm_sms_index_list[thisindex].previndex].nextindex = addindex;
- }
- mmi_frm_sms_index_list[thisindex].previndex = addindex;
- mmi_frm_sms_index_list[thisindex].prevtype = MMI_FRM_SMS_NOBOX;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_add_sms_entry
- * DESCRIPTION
- * add sms entry:
- * PARAMETERS
- * data [?]
- * L4index [IN]
- * thissegment [IN]
- * a index index(?)
- * b addindex addindex(?)
- * c segment segment(?)
- * RETURNS
- * index
- *****************************************************************************/
- U16 mmi_frm_sms_add_sms_entry(mmi_frm_sms_msgbox_struct *data, U16 L4index, U8 thissegment)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 addindex = g_frm_sms_cntx.mmi_frm_sms_msg_box_size;
- U16 emptyindex = g_frm_sms_cntx.mmi_frm_sms_msg_box_size;
- U8 found = FALSE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while ((found == FALSE) && (addindex > 0))
- {
- addindex--;
- if (mmi_frm_sms_msg_box[addindex].startindex == MMI_FRM_SMS_INVALID_INDEX)
- {
- emptyindex = addindex;
- continue;
- }
- if (mmi_frm_sms_compare_entry(addindex, data, thissegment) == TRUE)
- {
- found = TRUE;
- break;
- }
- }
- if (found == FALSE)
- {
- U8 type;
- if ((data->msgtype & MMI_FRM_SMS_INBOX) == MMI_FRM_SMS_INBOX)
- {
- type = MMI_FRM_SMS_INBOX;
- }
- else if ((data->msgtype & MMI_FRM_SMS_UNREAD) == MMI_FRM_SMS_UNREAD)
- {
- type = MMI_FRM_SMS_UNREAD;
- }
- else if ((data->msgtype & MMI_FRM_SMS_OUTBOX) == MMI_FRM_SMS_OUTBOX)
- {
- type = MMI_FRM_SMS_OUTBOX;
- }
- else
- {
- type = MMI_FRM_SMS_DRAFTS;
- }
- memcpy((S8*) & mmi_frm_sms_msg_box[emptyindex], (S8*) data, sizeof(mmi_frm_sms_msgbox_struct));
- mmi_frm_sms_index_list[L4index].segment = thissegment;
- /* mmi_frm_sms_index_list[L4index].nextindex=MMI_FRM_SMS_INVALID_INDEX; */
- mmi_frm_sms_index_list[L4index].previndex = emptyindex;
- mmi_frm_sms_index_list[L4index].prevtype = type;
- mmi_frm_sms_msgbox_size++;
- addindex = emptyindex;
- }
- else
- {
- #ifdef __MMI_MESSAGES_COPY__
- if (mmi_frm_sms_msg_box[addindex].storageType != MMI_FRM_SMS_PREFER_STORAGE)
- {
- mmi_frm_sms_msg_box[addindex].storageType = data->storageType;
- }
- #endif /* __MMI_MESSAGES_COPY__ */
- #ifdef __MMI_UNIFIED_MESSAGE__
- if (mmi_frm_sms_index_list[mmi_frm_sms_msg_box[addindex].startindex].segment == thissegment - 1)
- {
- if (pfnUnicodeStrlen((S8*) data->content))
- {
- if (pfnUnicodeStrlen((S8*) mmi_frm_sms_msg_box[addindex].content) <
- (mmi_msg_get_max_content_size() - 1))
- {
- /* append data->content to mmi_frm_sms_msg_box[addindex].content */
- U16 *temp_content;
- U16 temp_content_size = (U16) (mmi_msg_get_max_content_size() + 1) * ENCODING_LENGTH;
- temp_content = OslMalloc(temp_content_size);
- memset((S8*) temp_content, 0, temp_content_size);
- pfnUnicodeStrncpy(
- (S8*) temp_content,
- (S8*) mmi_frm_sms_msg_box[addindex].content,
- mmi_msg_get_max_content_size());
- pfnUnicodeStrncat(
- (S8*) temp_content,
- (S8*) data->content,
- (mmi_msg_get_max_content_size() - pfnUnicodeStrlen((S8*) temp_content)));
- mmi_frm_sms_add_content_to_entry(
- (mmi_frm_sms_msgbox_struct*) & mmi_frm_sms_msg_box[addindex],
- (U8*) temp_content);
- OslMfree(temp_content);
- }
- }
- }
- else if (mmi_frm_sms_index_list[mmi_frm_sms_msg_box[addindex].startindex].segment == thissegment + 1)
- {
- if (pfnUnicodeStrlen((S8*) data->content))
- {
- /* copy data->content to the beginning of mmi_frm_sms_msg_box[addindex].content */
- U16 *temp_content;
- U16 temp_content_size = (U16) (mmi_msg_get_max_content_size() + 1) * ENCODING_LENGTH;
- temp_content = OslMalloc(temp_content_size);
- memset((S8*) temp_content, 0, temp_content_size);
- pfnUnicodeStrncpy((S8*) temp_content, (S8*) data->content, mmi_msg_get_max_content_size());
- if (mmi_msg_get_max_content_size() > pfnUnicodeStrlen((S8*) temp_content))
- {
- pfnUnicodeStrncat(
- (S8*) temp_content,
- (S8*) mmi_frm_sms_msg_box[addindex].content,
- (mmi_msg_get_max_content_size() - pfnUnicodeStrlen((S8*) temp_content)));
- }
- mmi_frm_sms_add_content_to_entry(
- (mmi_frm_sms_msgbox_struct*) & mmi_frm_sms_msg_box[addindex],
- (U8*) temp_content);
- OslMfree(temp_content);
- }
- }
- else if (mmi_frm_sms_index_list[mmi_frm_sms_msg_box[addindex].startindex].segment > thissegment)
- {
- if (pfnUnicodeStrlen((S8*) data->content))
- {
- mmi_frm_sms_add_content_to_entry(
- (mmi_frm_sms_msgbox_struct*) & mmi_frm_sms_msg_box[addindex],
- (U8*) data->content);
- }
- }
- else
- {
- /* thissegment > start_segment + 1 */
- /* If thissegment is the last segment of received segments, append the content */
- if (pfnUnicodeStrlen((S8*) mmi_frm_sms_msg_box[addindex].content) <
- (mmi_msg_get_max_content_size() - 1))
- {
- U16 l4_index = mmi_frm_sms_index_list[mmi_frm_sms_msg_box[addindex].startindex].nextindex;
- if (l4_index == MMI_FRM_SMS_INVALID_INDEX)
- {
- /* Do nothing */
- ;
- }
- else
- {
- for (;;)
- {
- /* Received segments are continuous */
- if (mmi_frm_sms_index_list[l4_index].nextindex == MMI_FRM_SMS_INVALID_INDEX)
- {
- if ((mmi_frm_sms_index_list[l4_index].segment - 1 ) !=
- mmi_frm_sms_index_list[mmi_frm_sms_index_list[l4_index].previndex].segment)
- {
- /* Do nothing if received segments are not continuous */
- break;
- }
- /* thissegment is the last segment of received segments */
- if (thissegment == (mmi_frm_sms_index_list[l4_index].segment + 1 ))
- {
- /* Append the content */
- if (pfnUnicodeStrlen((S8*) data->content))
- {
- /* append data->content to mmi_frm_sms_msg_box[addindex].content */
- U16 *temp_content;
- U16 temp_content_size = (U16) (mmi_msg_get_max_content_size() + 1) * ENCODING_LENGTH;
- temp_content = OslMalloc(temp_content_size);
- memset((S8*) temp_content, 0, temp_content_size);
- pfnUnicodeStrncpy(
- (S8*) temp_content,
- (S8*) mmi_frm_sms_msg_box[addindex].content,
- mmi_msg_get_max_content_size());
- pfnUnicodeStrncat(
- (S8*) temp_content,
- (S8*) data->content,
- (mmi_msg_get_max_content_size() - pfnUnicodeStrlen((S8*) temp_content)));
- mmi_frm_sms_add_content_to_entry(
- (mmi_frm_sms_msgbox_struct*) & mmi_frm_sms_msg_box[addindex],
- (U8*) temp_content);
- OslMfree(temp_content);
-
- }
- }
- break;
- }
- if ((mmi_frm_sms_index_list[l4_index].segment - 1 ) !=
- mmi_frm_sms_index_list[mmi_frm_sms_index_list[l4_index].previndex].segment)
- {
- /* Do nothing if received segments are not continuous */
- break;
- }
- l4_index = mmi_frm_sms_index_list[l4_index].nextindex;
- }
- }
- }
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- mmi_frm_sms_add_sms_segment(addindex, L4index, thissegment);
- /* If one segment of the message is unread, the message shall be unread. */
- if ((data->msgtype & MMI_FRM_SMS_UNREAD) == MMI_FRM_SMS_UNREAD)
- {
- mmi_frm_sms_msg_box[addindex].msgtype = ((mmi_frm_sms_msg_box[addindex].msgtype & 0xf0) |
- (MMI_FRM_SMS_UNREAD));
- }
- }
- return addindex;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_remove_sms_entry
- * DESCRIPTION
- * remove sms entry:
- * PARAMETERS
- * index [IN] Index
- * b addindex addindex(?)
- * c segment segment(?)
- * RETURNS
- * index(?)
- *****************************************************************************/
- void mmi_frm_sms_remove_sms_entry(U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 previndex, nextindex;
- U8 type = mmi_frm_sms_index_list[index].prevtype;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- previndex = mmi_frm_sms_index_list[index].previndex;
- nextindex = mmi_frm_sms_index_list[index].nextindex;
- /* chat message is not in message box, so message box should remain unchanged and only delete index list entry */
- /* For message with only one segment, also update msg box and inbox/outbox/draft list */
- if ((type != MMI_FRM_SMS_NOBOX && type != MMI_FRM_SMS_AWAITS && type != MMI_FRM_SMS_DATA) &&
- (nextindex == MMI_FRM_SMS_INVALID_INDEX))
- {
- mmi_frm_sms_remove_sms_from_list(previndex, type);
- memset((S8*) & mmi_frm_sms_msg_box[previndex], 0xff, sizeof(mmi_frm_sms_msgbox_struct));
- }
- else
- {
- /* the first segment of message */
- if (type != MMI_FRM_SMS_NOBOX)
- {
- /* for message in awaited list, ex. chat msg, modify start index of awaitd list entry to next index */
- if (type == MMI_FRM_SMS_AWAITS || type == MMI_FRM_SMS_DATA)
- {
- mmi_frm_sms_awaited[previndex].index = nextindex;
- }
- /* for message in msg box, ex. inbox/outbox/draft message, modify start index of msg box entry to next index */
- else
- {
- mmi_frm_sms_msg_box[previndex].startindex = nextindex;
- }
- }
- /* the 2nd or after segment of message */
- else
- {
- mmi_frm_sms_index_list[previndex].nextindex = nextindex;
- }
- if (nextindex != MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_index_list[nextindex].prevtype = type;
- mmi_frm_sms_index_list[nextindex].previndex = previndex;
- }
- }
- memset((S8*) & mmi_frm_sms_index_list[index], 0xff, sizeof(mmi_frm_sms_index_struct));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_add_sms_to_msgbox
- * DESCRIPTION
- * add sms to msgbox
- * PARAMETERS
- * entry [?]
- * index [IN]
- * thisseg [IN]
- * a data data(?)
- * RETURNS
- * void
- *****************************************************************************/
- U16 mmi_frm_sms_add_sms_to_msgbox(mmi_frm_sms_msgbox_struct *entry, U16 index, U8 thisseg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 entryindex;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* add to msg entry */
- entryindex = mmi_frm_sms_add_sms_entry(entry, index, thisseg);
- /* update msg list */
- if (mmi_frm_sms_list_done)
- {
- mmi_frm_sms_add_sms_to_list(entry, entryindex);
- }
- return entryindex;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_index
- * DESCRIPTION
- * get sms index from bitmap
- * PARAMETERS
- * index [IN] Index
- * index_bitmap [?] Index_bitmap
- * RETURNS
- * void
- *****************************************************************************/
- U16 mmi_frm_sms_get_index(U16 index, U8 *index_bitmap)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 start_byte_idx, i;
- U8 start_bit_idx, j, mapping_byte;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- start_byte_idx = (index >> 3); /* divide 8 */
- start_bit_idx = (index & 0x7); /* reminder */
- for (i = start_byte_idx; i < ((g_frm_sms_cntx.mmi_frm_sms_msg_box_size >> 3) + 1); i++)
- {
- mapping_byte = index_bitmap[i];
- for (j = start_bit_idx; j < 8; j++)
- {
- if (((mapping_byte >> j) & 0x01) == 0x01)
- {
- return (i * 8 + j);
- }
- }
- start_bit_idx = 0;
- }
- return MMI_FRM_SMS_INVALID_INDEX;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_set_bitmap
- * DESCRIPTION
- * set bitmap from index
- * PARAMETERS
- * index [IN] Index
- * index_bitmap [?] Index_bitmap
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_set_bitmap(U16 index, U8 *index_bitmap)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 byte_index;
- U8 bit_index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- byte_index = (index >> 3); /* divide 8 */
- bit_index = (index & 0x7); /* reminder */
- index_bitmap[byte_index] |= (0x01 << bit_index);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_remove_sms_from_msgbox
- * DESCRIPTION
- * mmi_frm_sms_remove_sms_from_msgbox
- * PARAMETERS
- * data [?] Data
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_remove_sms_from_msgbox(U8 *data)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *index_bitmap = (U8*) data;
- U16 index = mmi_frm_sms_get_index(0, index_bitmap);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (index != MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_remove_sms_entry(index);
- index++;
- index = mmi_frm_sms_get_index(index, index_bitmap);
- }
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_create_sms_list
- * DESCRIPTION
- * mmi_frm_sms_create_sms_list
- * PARAMETERS
- * void
- * a data data(?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_create_sms_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (mmi_frm_sms_list_done != TRUE)
- {
- for (i = 0; i < g_frm_sms_cntx.mmi_frm_sms_msg_box_size; i++)
- {
- if (mmi_frm_sms_msg_box[i].startindex == MMI_FRM_SMS_INVALID_INDEX)
- {
- continue;
- }
- mmi_frm_sms_add_sms_to_list(&mmi_frm_sms_msg_box[i], i);
- }
- mmi_frm_sms_list_done = TRUE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_sms_list_index
- * DESCRIPTION
- * map message box index to message list index
- * PARAMETERS
- * type [?] Type
- * index [?] Index
- * msgbox_index [IN] Msgbox_index
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_sms_list_index(U8 *type, U16 *index, U16 msgbox_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (i < mmi_frm_sms_inbox_size)
- {
- if (mmi_frm_sms_inbox_list[i] == msgbox_index)
- {
- *type = MMI_FRM_SMS_INBOX;
- *index = i;
- return;
- }
- i++;
- }
- i = 0;
- while (i < mmi_frm_sms_outbox_size)
- {
- if (mmi_frm_sms_outbox_list[i] == msgbox_index)
- {
- *type = MMI_FRM_SMS_OUTBOX;
- *index = i;
- return;
- }
- i++;
- }
- #ifdef __MMI_MESSAGES_DRAFT_BOX__
- i = 0;
- while (i < mmi_frm_sms_drafts_size)
- {
- if (mmi_frm_sms_drafts_list[i] == msgbox_index)
- {
- *type = MMI_FRM_SMS_DRAFTS;
- *index = i;
- return;
- }
- i++;
- }
- #endif /* __MMI_MESSAGES_DRAFT_BOX__ */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_sms_index
- * DESCRIPTION
- * get sms index array, in sequence
- * PARAMETERS
- * type [IN] Type
- * index [IN] Index
- * l4_index [?] L4_index
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_sms_index(mmi_frm_sms_msgbox_enum type, U16 index, U16 *l4_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i = 0;
- U16 L4index = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < g_frm_sms_cntx.mmi_frm_sms_msg_seg_size; i++)
- {
- l4_index[i] = MMI_FRM_SMS_INVALID_INDEX;
- }
- switch (type)
- {
- case MMI_FRM_SMS_NOBOX:
- {
- L4index = mmi_frm_sms_msg_box[index].startindex;
- while (L4index != MMI_FRM_SMS_INVALID_INDEX)
- {
- l4_index[mmi_frm_sms_index_list[L4index].segment - 1] = L4index;
- L4index = mmi_frm_sms_index_list[L4index].nextindex;
- }
- }
- break;
- case MMI_FRM_SMS_INBOX:
- case MMI_FRM_SMS_UNREAD:
- {
- L4index = mmi_frm_sms_msg_box[mmi_frm_sms_inbox_list[index]].startindex;
- while (L4index != MMI_FRM_SMS_INVALID_INDEX)
- {
- l4_index[mmi_frm_sms_index_list[L4index].segment - 1] = L4index;
- L4index = mmi_frm_sms_index_list[L4index].nextindex;
- }
- }
- break;
- case MMI_FRM_SMS_OUTBOX:
- #ifndef __MMI_MESSAGES_DRAFT_BOX__
- case MMI_FRM_SMS_DRAFTS:
- #endif
- {
- L4index = mmi_frm_sms_msg_box[mmi_frm_sms_outbox_list[index]].startindex;
- while (L4index != MMI_FRM_SMS_INVALID_INDEX)
- {
- l4_index[mmi_frm_sms_index_list[L4index].segment - 1] = L4index;
- L4index = mmi_frm_sms_index_list[L4index].nextindex;
- }
- }
- break;
- #ifdef __MMI_MESSAGES_DRAFT_BOX__
- case MMI_FRM_SMS_DRAFTS:
- {
- L4index = mmi_frm_sms_msg_box[mmi_frm_sms_drafts_list[index]].startindex;
- while (L4index != MMI_FRM_SMS_INVALID_INDEX)
- {
- l4_index[mmi_frm_sms_index_list[L4index].segment - 1] = L4index;
- L4index = mmi_frm_sms_index_list[L4index].nextindex;
- }
- }
- break;
- #endif /* __MMI_MESSAGES_DRAFT_BOX__ */
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_sms_msgbox_index
- * DESCRIPTION
- * map L4 index to message box index
- * PARAMETERS
- * l4_index [IN] L4 index
- * msgbox_index [?] Msgbox_index
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_frm_sms_get_sms_msgbox_index(U16 l4_index, U16 *msgbox_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 L4index = l4_index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *msgbox_index = MMI_FRM_SMS_INVALID_INDEX;
- while (mmi_frm_sms_index_list[L4index].prevtype == MMI_FRM_SMS_NOBOX)
- {
- L4index = mmi_frm_sms_index_list[L4index].previndex;
- }
- if (mmi_frm_sms_index_list[L4index].prevtype != MMI_FRM_SMS_AWAITS &&
- mmi_frm_sms_index_list[L4index].prevtype != MMI_FRM_SMS_DATA)
- {
- *msgbox_index = mmi_frm_sms_index_list[L4index].previndex;
- }
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_sms_bitmap
- * DESCRIPTION
- * get sms index in bitmap
- * PARAMETERS
- * type [IN] Type
- * index [IN] Index
- * l4_index [?] L4_index
- * RETURNS
- * void
- *****************************************************************************/
- U8 mmi_frm_sms_get_sms_bitmap(U8 type, U16 index, U8 *l4_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i = 0;
- U16 startindex = index;
- U16 endindex = index + 1;
- U16 entryindex = 0;
- U16 L4index = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (mmi_frm_sms_list_done == FALSE)
- {
- return FALSE;
- }
- if (type & MMI_FRM_SMS_NOBOX)
- {
- mmi_frm_sms_set_bitmap(index, l4_index);
- }
- if (type & MMI_FRM_SMS_AWAITS)
- {
- for (i = startindex; i < endindex; i++)
- {
- entryindex = index;
- L4index = entryindex;
- while (L4index != MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_set_bitmap(L4index, l4_index);
- L4index = mmi_frm_sms_index_list[L4index].nextindex;
- }
- }
- }
- if ((type & MMI_FRM_SMS_INBOX) || (type & MMI_FRM_SMS_UNREAD))
- {
- if (index == MMI_FRM_SMS_INVALID_INDEX)
- {
- startindex = 0;
- endindex = mmi_frm_sms_inbox_size;
- }
- for (i = startindex; i < endindex; i++)
- {
- entryindex = mmi_frm_sms_inbox_list[i];
- L4index = mmi_frm_sms_msg_box[entryindex].startindex;
- while (L4index != MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_set_bitmap(L4index, l4_index);
- L4index = mmi_frm_sms_index_list[L4index].nextindex;
- }
- }
- }
- if ((type & MMI_FRM_SMS_OUTBOX)
- #ifndef __MMI_MESSAGES_DRAFT_BOX__
- || (type & MMI_FRM_SMS_DRAFTS)
- #endif
- )
- {
- if (index == MMI_FRM_SMS_INVALID_INDEX)
- {
- startindex = 0;
- endindex = mmi_frm_sms_outbox_size;
- }
- for (i = startindex; i < endindex; i++)
- {
- entryindex = mmi_frm_sms_outbox_list[i];
- L4index = mmi_frm_sms_msg_box[entryindex].startindex;
- while (L4index != MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_set_bitmap(L4index, l4_index);
- L4index = mmi_frm_sms_index_list[L4index].nextindex;
- }
- }
- }
- #ifdef __MMI_MESSAGES_DRAFT_BOX__
- if ((type & MMI_FRM_SMS_DRAFTS)
- #ifdef __MMI_UNIFIED_MESSAGE__
- || (type & MMI_FRM_SMS_UNSENT)
- #endif
- )
- {
- if (index == MMI_FRM_SMS_INVALID_INDEX)
- {
- startindex = 0;
- endindex = mmi_frm_sms_drafts_size;
- }
- for (i = startindex; i < endindex; i++)
- {
- entryindex = mmi_frm_sms_drafts_list[i];
- L4index = mmi_frm_sms_msg_box[entryindex].startindex;
- while (L4index != MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_set_bitmap(L4index, l4_index);
- L4index = mmi_frm_sms_index_list[L4index].nextindex;
- }
- }
- }
- #endif /* __MMI_MESSAGES_DRAFT_BOX__ */
- return TRUE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_add_awaited_segment
- * DESCRIPTION
- * add one segment to awaited entry
- * PARAMETERS
- * index [IN] The index found in mmi_frm_sms_awaited that matches the last entry
- * addindex [IN] Addindex
- * segment [IN] The current segment of the last entry in mmi_frm_sms_awaited
- * entry [?]
- * RETURNS
- * add success or fail
- *****************************************************************************/
- U8 mmi_frm_sms_add_awaited_segment(U8 index, U16 addindex, U8 segment, mmi_frm_sms_deliver_msg_struct *entry)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 thisindex = mmi_frm_sms_awaited[index].index;
- U8 islast = TRUE;
- U8 dataindex = 0;
- U8 thisdataindex = mmi_frm_sms_awaited[index].msg_data[0];
- U8 prevdataindex = MMI_FRM_SMS_INVALID_NUM;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* find an empty entry in the mmi_frm_sms_content in order to move the last entry to that entry */
- while (dataindex < MMI_FRM_SMS_MSG_CONTENT_NUM)
- {
- if (mmi_frm_sms_content[dataindex].msglen == 0)
- {
- break; /* found empty entry */
- }
- dataindex++;
- }
- /* if mmi_frm_sms_content is full and cannot find any empty entry, don't have to move */
- if (dataindex != MMI_FRM_SMS_MSG_CONTENT_NUM)
- {
- /* move the actual data of the last entry to the entry with the index dataindex in mmi_frm_sms_content */
- if (entry->no_msg_data)
- {
- mmi_frm_sms_content[dataindex].data = OslMalloc(entry->no_msg_data);
- memcpy(
- (S8*) mmi_frm_sms_content[dataindex].data,
- (S8*) mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data,
- entry->no_msg_data);
- }
- mmi_frm_sms_content[dataindex].msglen = entry->no_msg_data;
- mmi_frm_sms_content[dataindex].segment = segment;
- }
- mmi_frm_sms_awaited[index].no_msg_data += entry->no_msg_data;
- MMI_ASSERT(mmi_frm_sms_awaited[index].no_msg_data <= MMI_SMS_MAX_MSG_SEG * MMI_FRM_SMS_MSG_LEN);
- if (addindex != MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_index_list[addindex].segment = segment;
- }
- /* thisdataindex is the current smallest segment index of this message */
- if (mmi_frm_sms_content[thisdataindex].segment > segment)
- {
- islast = FALSE;
- /* dataindex is inserted in the head, now dataindex is the current smallest segment index of this message */
- mmi_frm_sms_content[dataindex].nextindex = thisdataindex;
- mmi_frm_sms_awaited[index].msg_data[0] = dataindex;
- if (addindex != MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_awaited[index].index = addindex;
- }
- }
- else
- {
- while (mmi_frm_sms_content[thisdataindex].nextindex != MMI_FRM_SMS_INVALID_NUM)
- {
- if (addindex != MMI_FRM_SMS_INVALID_INDEX)
- {
- thisindex = mmi_frm_sms_index_list[thisindex].nextindex;
- }
- prevdataindex = thisdataindex;
- thisdataindex = mmi_frm_sms_content[thisdataindex].nextindex;
- if (mmi_frm_sms_content[thisdataindex].segment > segment)
- {
- islast = FALSE;
- break;
- }
- }
- }
- if (islast == TRUE)
- {
- /* dataindex is inserted in the tail, now dataindex is the current largest segment index of this message */
- mmi_frm_sms_content[thisdataindex].nextindex = dataindex;
- mmi_frm_sms_content[dataindex].nextindex = MMI_FRM_SMS_INVALID_NUM;
- if (addindex != MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_index_list[thisindex].nextindex = addindex;
- mmi_frm_sms_index_list[addindex].nextindex = MMI_FRM_SMS_INVALID_INDEX;
- mmi_frm_sms_index_list[addindex].previndex = thisindex;
- mmi_frm_sms_index_list[addindex].prevtype = MMI_FRM_SMS_NOBOX;
- }
- }
- else
- {
- /* dataindex is inserted in the middle */
- if (prevdataindex != MMI_FRM_SMS_INVALID_NUM)
- {
- mmi_frm_sms_content[prevdataindex].nextindex = dataindex;
- }
- mmi_frm_sms_content[dataindex].nextindex = thisdataindex;
- if (addindex != MMI_FRM_SMS_INVALID_INDEX)
- {
- mmi_frm_sms_index_list[addindex].nextindex = thisindex;
- mmi_frm_sms_index_list[addindex].previndex = mmi_frm_sms_index_list[thisindex].previndex;
- mmi_frm_sms_index_list[addindex].prevtype = mmi_frm_sms_index_list[thisindex].prevtype;
- if (mmi_frm_sms_index_list[thisindex].prevtype == MMI_FRM_SMS_NOBOX)
- {
- mmi_frm_sms_index_list[mmi_frm_sms_index_list[thisindex].previndex].nextindex = addindex;
- }
- mmi_frm_sms_index_list[thisindex].previndex = addindex;
- mmi_frm_sms_index_list[thisindex].prevtype = MMI_FRM_SMS_NOBOX;
- }
- }
- /* mmi_frm_sms_content is full and cannot handle other new segment coming anymore */
- if (dataindex == MMI_FRM_SMS_MSG_CONTENT_NUM)
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_add_awaited_entry
- * DESCRIPTION
- * add sms to awaited list
- * PARAMETERS
- * void
- * a type type(?)
- * b index index(?)
- * c l4_index l4_index(?)
- * RETURNS
- * TRUE: inserted, FALSE: not inserted
- *****************************************************************************/
- U8 mmi_frm_sms_add_awaited_entry(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 i = 0;
- U8 dataindex = 0;
- U16 index = mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE].index;
- U16 length = mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].msglen;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (dataindex < MMI_FRM_SMS_MSG_CONTENT_NUM)
- {
- if (mmi_frm_sms_content[dataindex].segment == MMI_FRM_SMS_INVALID_NUM)
- {
- break; /* found empty entry */
- }
- dataindex++;
- }
- /* cannot find any empty entry in mmi_frm_sms_content */
- if (dataindex == MMI_FRM_SMS_MSG_CONTENT_NUM)
- {
- return MMI_FRM_SMS_INVALID_NUM;
- }
- mmi_frm_sms_content[dataindex].msglen = mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].msglen;
- mmi_frm_sms_content[dataindex].nextindex = mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].nextindex;
- mmi_frm_sms_content[dataindex].segment = mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].segment;
- // mmi_frm_sms_content[dataindex].data=mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data;
- // mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data=NULL;
- if (length)
- {
- mmi_frm_sms_content[dataindex].data = OslMalloc(length);
- memcpy(mmi_frm_sms_content[dataindex].data, mmi_frm_sms_content[MMI_FRM_SMS_MSG_CONTENT_NUM].data, length);
- }
- while (i < MMI_FRM_SMS_ACTION_SIZE)
- {
- if (mmi_frm_sms_awaited[i].msg_data[0] == MMI_FRM_SMS_INVALID_NUM)
- {
- memcpy(
- &(mmi_frm_sms_awaited[i]),
- &(mmi_frm_sms_awaited[MMI_FRM_SMS_ACTION_SIZE]),
- sizeof(mmi_frm_sms_deliver_msg_struct));
- mmi_frm_sms_awaited[i].msg_data[0] = dataindex;
- /* non-class 0 message!!!!!!! */
- if (index != MMI_FRM_SMS_INVALID_INDEX)
- mmi_frm_sms_index_list[index].previndex = i;;
- return i;
- }
- i++;
- }
- /* cannot find any empty entry in mmi_frm_sms_awaited */
- return MMI_FRM_SMS_INVALID_NUM;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_get_awaited_sms
- * DESCRIPTION
- * Get awaited SMS by index
- * PARAMETERS
- * index [IN] Index
- * entry [?] Message entry info
- * content [?] Message content
- * RETURNS
- * object present
- *****************************************************************************/
- U8 mmi_frm_sms_get_awaited_sms(U8 index, mmi_frm_sms_deliver_msg_struct *entry, U8 *content)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 i = 0;
- U8 nextindex = mmi_frm_sms_awaited[index].msg_data[0];
- EMSData *pEMSdata = NULL;
- U8 *textBuff;
- U8 *TPUD[10];
- U8 TPUDLEN[10];
- U8 is_obj_present = 0;
- U16 buffLen = mmi_frm_sms_awaited[index].no_msg_data;
- U16 textLen = 0;
- U8 totalseg = 0;
- EMSTATUS result;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memcpy((S8*) entry, (S8*) & mmi_frm_sms_awaited[index], sizeof(mmi_frm_sms_deliver_msg_struct));
- for (i = 0; i < 10; i++)
- {
- TPUDLEN[i] = 0;
- TPUD[i] = NULL;
- }
- i = 0;
- while (nextindex != MMI_FRM_SMS_INVALID_NUM && i < 10)
- {
- totalseg = i + 1; /* total segment that the TPUD is not NULL */
- TPUDLEN[i] = (U8) mmi_frm_sms_content[nextindex].msglen;
- TPUD[i] = (U8*) mmi_frm_sms_content[nextindex].data;
- nextindex = mmi_frm_sms_content[nextindex].nextindex;
- i++;
- }
- if (mmi_frm_sms_awaited[index].dcs == SMSAL_DEFAULT_DCS || mmi_frm_sms_awaited[index].dcs == SMSAL_8BIT_DCS)
- {
- buffLen *= 2;
- }
- if (buffLen)
- {
- pEMSdata = OslMalloc(sizeof(EMSData));
- /* MMI could only allocate 2K control buffer, so limit the max allocate buffer to 1600 here */
- buffLen = (buffLen < (MMI_FRM_SMS_MSG_LEN * 10)) ? buffLen : (MMI_FRM_SMS_MSG_LEN * 10);
- textBuff = OslMalloc(buffLen);
- result = EMSMsgPreview(
- totalseg,
- mmi_frm_sms_awaited[index].dcs,
- (U8) GetUDHIBit(mmi_frm_sms_awaited[index].fo),
- TPUD,
- TPUDLEN,
- buffLen,
- textBuff,
- &is_obj_present,
- &textLen);
- if (result == EMS_OK)
- {
- pEMSdata->textBuffer = textBuff;
- pEMSdata->textBufferSize = mmi_frm_sms_awaited[index].no_msg_data;
- pEMSdata->textLength = textLen;
- pEMSdata->dcs = mmi_frm_sms_awaited[index].dcs;
- EMS_ConvertGSM7BitDefaultEncodingToAsciiWithoutEMSlib(pEMSdata);
- entry->no_msg_data = pEMSdata->textLength;
- if (mmi_frm_sms_awaited[index].dcs == SMSAL_UCS2_DCS)
- {
- memcpy((S8*) content, (S8*) pEMSdata->textBuffer, pEMSdata->textLength);
- }
- else
- {
- S8 *pOutBuffer = (S8*) content;
- S8 *pInBuffer = (S8*) pEMSdata->textBuffer;
- U32 len = pEMSdata->textLength;
- /* 34.2.5.1 test case contains a null terminator in the message content but actually it is not the end of the message */
- /* UnicodeNToAnsii((S8*)content, (S8*)pEMSdata->textBuffer, pEMSdata->textLength); */
- while (len)
- {
- *pOutBuffer = *(pInBuffer);
- pInBuffer += 2;
- pOutBuffer++;
- len -= 2;
- }
- }
- }
- else
- {
- entry->no_msg_data = 0;
- memset((S8*) content, 0, ENCODING_LENGTH);
- }
- OslMfree(textBuff);
- OslMfree(pEMSdata);
- }
- else
- {
- memset((S8*) content, 0, ENCODING_LENGTH);
- }
- return is_obj_present;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_frm_sms_check_awaited_complete
- * DESCRIPTION
- * Check awaited message completeness
- * PARAMETERS
- * index [IN] Index
- * RETURNS
- * void
- *****************************************************************************/
- U8 mmi_frm_sms_check_awaited_complete(U8 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 i = 0;
- mmi_frm_sms_concat_struct *concat_info = (mmi_frm_sms_concat_struct*) & (mmi_frm_sms_awaited[index].concat_info);
- U8 total_seg = ((concat_info->total_seg - concat_info->seg + 1) > g_frm_sms_cntx.mmi_frm_sms_msg_seg_size) ?
- g_frm_sms_cntx.mmi_frm_sms_msg_seg_size : (concat_info->total_seg - concat_info->seg + 1);
- U8 dataindex = mmi_frm_sms_awaited[index].msg_data[0];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* if the message has only one segment */
- if (index == MMI_FRM_SMS_ACTION_SIZE)
- {