MessagesMiscell.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:281k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * 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:
- * ---------
- * MessagesMiscell.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This file is intends for MMI SMS APP.
- *
- * 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!
- *
- * 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!!
- *============================================================================
- ****************************************************************************/
- /**
- * Copyright Notice
- * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
- * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
- * (It is illegal to remove this copyright notice from this software or any
- * portion of it)
- */
- /******************************************************************************
- FILENAME : MessagesMiscell.c
- PURPOSE :
- REMARKS : nil
- AUTHOR : Magesh k
- DATE : 01-01-2003
- ******************************************************************************/
- #ifdef __MOD_SMSAL__
- /* Include: MMI header file */
- #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"
- // #include "QueueGprot.h"
- #include "Gui_ems.h"
- #include "wgui_ems.h"
- #include "wgui_categories_ems.h"//062706 revise
- #include "GSM7BitDefaultAlphabet.h"
- #include "SimDetectionGProt.h"
- /* */
- #include "CSP.h"
- #include "IdleAppDef.h"
- #include "CallManagementGprot.h"
- #include "CallStructureManagementProt.h"
- #include "PhoneBookGprot.h"
- #include "SSCStringHandle.h"
- #include "AlarmFrameworkProt.h"
- #include "ProfileGprots.h"
- #include "gpioInc.h"
- #include "KeyBrd.h"
- #include "SubLCDHistoryGprot.h"
- /* */
- #ifdef __MMI_MESSAGES_CLUB__
- #include "mmiapi_res.h"
- #endif
- #if defined(OBIGO_SUPPORT) && defined(MMS_SUPPORT)
- #include "Wap.h"
- #endif
- #ifdef __MMI_MESSAGES_CHAT__
- #include "ChatAppGprot.h"
- #include "ChatAppDef.h"
- #include "ChatGtype.h"
- #endif /* __MMI_MESSAGES_CHAT__ */
- #if defined(__MMI_MESSAGES_TEMPLATE__)
- #include "NVRAMEnum.h"
- #include "NVRAMProt.h"
- #include "NVRAMType.h"
- #if defined(_MUTILANG_TEMPLATE_) || defined(__MMI_MESSAGES_SIMCHINESE_TEMPLATE__)
- #include "FontRes.h"
- #include "FontDcl.h"
- #include "SSCStringHandle.h"
- #endif /* defined(_MUTILANG_TEMPLATE_) || defined(__MMI_MESSAGES_SIMCHINESE_TEMPLATE__) */
- #endif /* defined(__MMI_MESSAGES_TEMPLATE__) */
- #ifdef MMI_ON_HARDWARE_P
- #include "nvram_user_defs.h"
- #endif
- #include "SMSApi.h"
- #include "SMSStruct.h"
- #include "SMSFunc.h"
- #ifdef __MMI_UNIFIED_MESSAGE__
- #include "UnifiedMessageDef.h"
- #include "UnifiedMessageGProt.h"
- #include "DateTimeGprot.h"
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- #ifdef __MMI_UNIFIED_COMPOSER__
- #include "UnifiedComposerDef.h"
- #include "UnifiedComposerGProt.h"
- #endif /* __MMI_UNIFIED_COMPOSER__ */
- #if defined(__MMI_MESSAGES_TEMPLATE__)
- #ifndef NVRAM_SMS_TEMPL_RECORD_SIZE
- #define NVRAM_SMS_TEMPL_RECORD_SIZE 84
- #endif
- #ifndef NVRAM_SMS_RECORD_TOTAL
- #define NVRAM_SMS_RECORD_TOTAL 31
- #endif
- const U16 templateStrings[] =
- {
- STR_SMS_TEMPLATE_1,
- STR_SMS_TEMPLATE_2,
- STR_SMS_TEMPLATE_3,
- STR_SMS_TEMPLATE_4,
- STR_SMS_TEMPLATE_5,
- STR_SMS_TEMPLATE_6,
- STR_SMS_TEMPLATE_7,
- STR_SMS_TEMPLATE_8,
- STR_SMS_TEMPLATE_9,
- STR_SMS_TEMPLATE_10
- };
- #ifdef _MUTILANG_TEMPLATE_
- #define TOTAL_TEMPLATE_LANGUAGE 3
- extern pBOOL IsTrChineseSet(void);
- extern pBOOL IsSmChineseSet(void);
- #endif /* _MUTILANG_TEMPLATE_ */
- #if defined(_MUTILANG_TEMPLATE_) || defined(__MMI_MESSAGES_SIMCHINESE_TEMPLATE__)
- static U8 currLang[SSC_SIZE];
- extern sLanguageDetails *gLanguageArray;
- extern U16 gCurrLangIndex;
- #endif /* defined(_MUTILANG_TEMPLATE_) || defined(__MMI_MESSAGES_SIMCHINESE_TEMPLATE__) */ /* _MUTILANG_TEMPLATE_, __MMI_MESSAGES_SIMCHINESE_TEMPLATE__ */
- #endif /* defined(__MMI_MESSAGES_TEMPLATE__) */
- #ifdef __MMI_MESSAGES_CHAT__
- static U8 NewChatMessageFromXxxStr[(MAX_PHONE_NUMBER_OR_NAME_LENGTH + 1) * ENCODING_LENGTH];
- U16 gChatMsgFlag; /* Added By Alok */
- void GetNewChatMsgIndDisplayString(U8 *number, U8 length, U8 type);
- PU8 GetNewChatSmsIndDisplayStr(void);
- #endif /* __MMI_MESSAGES_CHAT__ */
- static FuncPtr endKeyDownFuncPtr = NULL;
- static U16 messagesCurrScrnID;
- static U8 *strBuff = NULL;
- extern msg_msgbox_info_struct msgbox_info;
- extern PendingSaveSendDataStruct PendingSaveSendData;
- extern U16 GetCmMarkerScrnID(void);
- extern EMSData *GetEMSDataForView(EMSData **p, U8 force);
- extern MMI_ALERT_TYPE GetMtCallAlertTypeEnum(void);
- extern kal_uint16 wap_get_screen_id(void);
- #include "gui_config.h"
- extern const U8 AsciiToDefaultArray[];
- extern const U8 ExtendedAsciiToDefaultArray[];
- extern const U8 DefaultToExtendedAsciiArray[];
- extern const U8 DefaultToAsciiArray[];
- /*****************************************************************************
- * FUNCTION
- * IsMMIInIdleState
- * DESCRIPTION
- * Check if MMI is in idle state (idle screen or screen saver)
- * PARAMETERS
- * void
- * RETURNS
- * 1: idle, 0: non-idle
- *****************************************************************************/
- U16 IsMMIInIdleState(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "* [MessagesMiscell.c] IsMMIInIdleState IsOnIdleScreen=%d,ScreenSaverRunFlag=%d*n",
- g_idle_context.IsOnIdleScreen, g_idle_context.ScreenSaverRunFlag));
- if (g_idle_context.IsOnIdleScreen || g_idle_context.ScreenSaverRunFlag)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * IsKeyPadLockState
- * DESCRIPTION
- * Check if MMI is in keypad lock state
- * PARAMETERS
- * void
- * RETURNS
- * keypad lock flag (1: lock, 0: unlock)
- *****************************************************************************/
- U8 IsKeyPadLockState(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_keylock_context.gKeyPadLockFlag;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_msg_set_phb_send_case
- * DESCRIPTION
- * Set PhbSmsInterfaceState
- * PARAMETERS
- * PhbSmsInterfaceState [IN]
- * a(?) [IN] PhbSmsInterfaceState
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_msg_set_phb_send_case(U8 PhbSmsInterfaceState)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_msg_cntx.PhbSmsInterfaceState = PhbSmsInterfaceState;
- }
- /*****************************************************************************
- * FUNCTION
- * GetCurrEndKeyDownHandler
- * DESCRIPTION
- * Get current end key down handler
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void GetCurrEndKeyDownHandler(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[MessagesMiscell.c] GetCurrEndKeyDownHandler -------*n"));
- endKeyDownFuncPtr = NULL;
- endKeyDownFuncPtr = GetKeyHandler(KEY_END, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * ExecCurrEndKeyDownHandler
- * DESCRIPTION
- * Execute current end key down handler
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ExecCurrEndKeyDownHandler(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[MessagesMiscell.c] ExecCurrEndKeyDownHandler -------*n"));
- if (endKeyDownFuncPtr != NULL)
- {
- (*endKeyDownFuncPtr) ();
- }
- }
- /*****************************************************************************
- * FUNCTION
- * GetMessagesCurrScrnID
- * DESCRIPTION
- * Get MSG current screen ID
- * PARAMETERS
- * void
- * RETURNS
- * messagesCurrScrnID
- *****************************************************************************/
- U16 GetMessagesCurrScrnID(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*[MessagesMiscell.c] GetMessagesCurrScrnID = %d", messagesCurrScrnID));
- return messagesCurrScrnID;
- }
- /*****************************************************************************
- * FUNCTION
- * SetMessagesCurrScrnID
- * DESCRIPTION
- * Set MSG current screen ID
- * PARAMETERS
- * scrnID [IN]
- * a(?) [IN] Screen ID
- * RETURNS
- * void
- *****************************************************************************/
- void SetMessagesCurrScrnID(U16 scrnID)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*[MessagesMiscell.c] SetMessagesCurrScrnID= %d", messagesCurrScrnID));
- messagesCurrScrnID = scrnID;
- }
- /*****************************************************************************
- * FUNCTION
- * SetMessagesScrnIdToDelHistoryNodes
- * DESCRIPTION
- * Set MSG screen ID for delete start
- * PARAMETERS
- * StartScrnId [IN]
- * a(?) [IN] Start screen ID
- * RETURNS
- * void
- *****************************************************************************/
- void SetMessagesScrnIdToDelHistoryNodes(U16 StartScrnId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[MessagesMiscell.c] SetMessagesScrnIdToDelHistoryNodes -------*n"));
- g_msg_cntx.MessagesScrnIdToDelHistoryNodes = StartScrnId;
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[MessagesMiscell.c] screen id = %d -------*n",
- g_msg_cntx.MessagesScrnIdToDelHistoryNodes));
- }
- /*****************************************************************************
- * FUNCTION
- * SetMessagesScrnIdDelUpToHistoryNodes
- * DESCRIPTION
- * Set MSG screen ID for delete start
- * PARAMETERS
- * StartScrnId [IN]
- * a(?) [IN] Start screen ID
- * RETURNS
- * void
- *****************************************************************************/
- void SetMessagesScrnIdDelUpToHistoryNodes(U16 StartScrnId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*-------[MessagesMiscell.c] SetMessagesScrnIdDelUpToHistoryNodes -------*n"));
- g_msg_cntx.MessagesScrnIdDelUptoHistoryNodes = StartScrnId;
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[MessagesMiscell.c] screen id = %d -------*n",
- g_msg_cntx.MessagesScrnIdDelUptoHistoryNodes));
- }
- /*****************************************************************************
- * FUNCTION
- * DeleteMessagesHistoryNodes
- * DESCRIPTION
- * Delete between MSG screens
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void DeleteMessagesHistoryNodes(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[MessagesMiscell.c] DeleteMessagesHistoryNodes -------*n"));
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[MessagesMiscell.c] Deleteted from %d -------*n",
- g_msg_cntx.MessagesScrnIdToDelHistoryNodes));
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[MessagesMiscell.c] Deleteted upto %d -------*n",
- g_msg_cntx.MessagesScrnIdDelUptoHistoryNodes));
- if (IsScreenPresent(g_msg_cntx.MessagesScrnIdToDelHistoryNodes) &&
- IsScreenPresent(g_msg_cntx.MessagesScrnIdDelUptoHistoryNodes))
- {
- if (DeleteBetweenScreen
- (g_msg_cntx.MessagesScrnIdToDelHistoryNodes, g_msg_cntx.MessagesScrnIdDelUptoHistoryNodes))
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[MessagesMiscell.c] Deleteted scrn id from %d to %d ---*n",
- g_msg_cntx.MessagesScrnIdToDelHistoryNodes,
- g_msg_cntx.MessagesScrnIdDelUptoHistoryNodes));
- g_msg_cntx.MessagesScrnIdToDelHistoryNodes = MESSAGES_SCR_ID_DEFINES_MAX;
- g_msg_cntx.MessagesScrnIdDelUptoHistoryNodes = MESSAGES_SCR_ID_DEFINES_MAX;
- return;
- }
- }
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[MessagesMiscell.c] Not deleteted scrn id from %d to %d ---*n",
- g_msg_cntx.MessagesScrnIdToDelHistoryNodes, g_msg_cntx.MessagesScrnIdDelUptoHistoryNodes));
- }
- /*****************************************************************************
- * FUNCTION
- * Messages2GoBackHistory
- * DESCRIPTION
- * Go back two screen history
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void Messages2GoBackHistory(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[MessagesMiscell.c] Messages2GoBackHistory -------*n"));
- GoBacknHistory(1);
- }
- /*****************************************************************************
- * FUNCTION
- * Messages4GoBackHistory
- * DESCRIPTION
- * Go back four screen history
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void Messages4GoBackHistory(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[MessagesMiscell.c] Messages4GoBackHistory -------*n"));
- GoBacknHistory(3);
- }
- /*****************************************************************************
- * FUNCTION
- * GetChildMenuIDIndexByParentMenuID
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * parentMenuId [IN]
- * childMenuId [IN]
- * a(?) [IN] Parent menu id
- * b(?) [IN] Child menu id
- * RETURNS
- * index >= 0: child manu id is a child of parent menu id, -1: if not
- *****************************************************************************/
- S32 GetChildMenuIDIndexByParentMenuID(U16 parentMenuId, U16 childMenuId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 index = 0;
- U16 nMenuItemList[MAX_SUB_MENUS];
- U16 numItems = GetNumOfChild(parentMenuId);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- GetSequenceItemIds(parentMenuId, nMenuItemList);
- for (index = 0; index < numItems; index++)
- {
- if (nMenuItemList[index] == childMenuId)
- {
- return index;
- }
- }
- return -1;
- }
- /*****************************************************************************
- * FUNCTION
- * GetHiliteIndex
- * DESCRIPTION
- * Get current highlight index
- * PARAMETERS
- * nIndex [IN]
- * a(?) [IN] Current highlight index
- * RETURNS
- * void
- *****************************************************************************/
- void GetHiliteIndex(S32 nIndex)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[SmsMoMtGuiInterface.c] GetHiliteIndex -------*n"));
- g_msg_cntx.currHiliteIndex = nIndex;
- }
- /*****************************************************************************
- * FUNCTION
- * GetMsgIndex
- * DESCRIPTION
- * Get current highlight message box index
- * PARAMETERS
- * nIndex [IN]
- * a(?) [IN] Current highlight index
- * RETURNS
- * void
- *****************************************************************************/
- void GetMsgIndex(S32 nIndex)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_msg_cntx.currBoxIndex = nIndex;
- }
- #if defined(__MMI_MESSAGES_EMS__)
- /*****************************************************************************
- * FUNCTION
- * EnableDisableAudioPlayback
- * DESCRIPTION
- * Decide to enable/disable audio playback
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void EnableDisableAudioPlayback(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_ALERT_TYPE alertType;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- alertType = GetMtCallAlertTypeEnum();
- if ((!isInCall()) &&
- (alertType == MMI_RING || alertType == MMI_VIBRATION_AND_RING || alertType == MMI_VIBRATION_THEN_RING))
- {
- EMS_enable_audio_playback();
- }
- else
- {
- EMS_disable_audio_playback();
- }
- }
- #endif /* defined(__MMI_MESSAGES_EMS__) */
- /*****************************************************************************
- * FUNCTION
- * PlayMessageArrivalTone
- * DESCRIPTION
- * Play message arrival tone
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void PlayMessageArrivalTone(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MMI_ALERT_TYPE alertType;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- alertType = GetMtCallAlertTypeEnum();
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[MessagesMiscell.c] PlayMessageArrivalTone -------*n"));
- if (alertType == MMI_VIBRATION_AND_RING || alertType == MMI_VIBRATION_THEN_RING || alertType == MMI_RING)
- {
- if (!isInCall())
- {
- playRequestedTone(MESSAGE_TONE);
- }
- else
- {
- playRequestedTone(SMS_IN_CALL_TONE);
- }
- }
- if ((alertType == MMI_VIBRATION_ONLY) || (alertType == MMI_VIBRATION_AND_RING) ||
- (alertType == MMI_VIBRATION_THEN_RING))
- {
- if ((!g_alm_frm_cntx.IsAlmTonePlaying) && (!isInCall()))
- {
- PlaySmsVibratorOnce();
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * InitMessageProtocolEventHandlers
- * DESCRIPTION
- * Init MSG protocol event handler when boot up
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void InitMessageProtocolEventHandlers(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_msg_init_msg_data();
- ResetCBInfoStructs();
- mmi_msg_set_protocol_event_handler();
- InitCellBroadcastProtocolEventHanler(); /* danger!! receiving new CB might cause reading nvram */
- }
- /*****************************************************************************
- * FUNCTION
- * InitMessagesApp
- * DESCRIPTION
- * Init MSG application when go to opening screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void InitMessagesApp(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- InitEMSDataStruct();
- mmi_msg_set_highlight_handler();
- /* mmi_msg_set_protocol_event_handler_after_init (); */
- InitCellBroadcastApp();
- }
- /*****************************************************************************
- * FUNCTION
- * DeInitMessagesApp
- * DESCRIPTION
- * Deinit MSG application
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void DeInitMessagesApp(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #if defined(__MMI_MESSAGES_TEMPLATE__)
- DeInitTemplates();
- #endif
- mmi_msg_deinit_msg_data();
- DeInitCellBroadcastApp();
- DeInitVoiceMailApp();
- DeInitEMSDataStruct();
- }
- /*****************************************************************************
- * FUNCTION
- * RestoreMessagesSettings
- * DESCRIPTION
- * Restore MSG settings
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void RestoreMessagesSettings(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[MessagesMiscell.c] RestoreMessagesSettings -------*n"));
- mmi_msg_restore_cb();
- }
- /*****************************************************************************
- * FUNCTION
- * IsMessagesReEntering
- * DESCRIPTION
- * Check if MSG application is reentered
- * PARAMETERS
- * void
- * RETURNS
- * TRUE: MSG application is reentered, FALSE: MSG application is not reentered
- *****************************************************************************/
- U8 IsMessagesReEntering(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[SmsMoMtGuiInterface.c] IsMessagesReEntering -------*n"));
- if (!mmi_frm_sms_check_action_pending())
- {
- U16 startScrnId = 0;
- U16 endScrnId = 0;
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[SmsMoMtGuiInterface.c] Messages not Busy -------*n"));
- #if (defined(OBIGO_SUPPORT) || defined (JATAAYU_SUPPORT)) && defined(MMS_SUPPORT)
- if ((IsScreenPresent(wap_get_screen_id())) && (!IsScreenPresent(SCR_ID_MSG_MAIN_MENU_NO_MMS)))
- {
- U16 ScrnId = 0;
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*---[SmsMoMtGuiInterface.c] WAP screen exists and SCR_ID_MSG_MAIN_MENU_NO_MMS not exists ---*n"));
- if (IsScreenPresent(SCR_ID_MSG_SMS_MAIN_MENU))
- {
- ScrnId = SCR_ID_MSG_SMS_MAIN_MENU;
- }
- #ifdef __MMI_UNIFIED_MESSAGE__
- else if (IsScreenPresent(SCR_ID_UM_MAIN))
- {
- startScrnId = SCR_ID_UM_MAIN;
- }
- #ifdef __MMI_UNIFIED_COMPOSER__
- else if (IsScreenPresent(SCR_ID_UC_EDITOR))
- {
- startScrnId = SCR_ID_UC_EDITOR;
- }
- #else /* __MMI_UNIFIED_COMPOSER__ */
- else if (IsScreenPresent(SCR_ID_UM_WRITE_MSG))
- {
- startScrnId = SCR_ID_UM_WRITE_MSG;
- }
- #endif /* __MMI_UNIFIED_COMPOSER__ */
- else if (IsScreenPresent(SCR_ID_UM_INBOX))
- {
- startScrnId = SCR_ID_UM_INBOX;
- }
- else if (IsScreenPresent(SCR_ID_UM_UNSENT))
- {
- startScrnId = SCR_ID_UM_UNSENT;
- }
- else if (IsScreenPresent(SCR_ID_UM_SENT))
- {
- startScrnId = SCR_ID_UM_SENT;
- }
- else if (IsScreenPresent(SCR_ID_UM_DRAFT))
- {
- startScrnId = SCR_ID_UM_DRAFT;
- }
- #else /* __MMI_UNIFIED_MESSAGE__ */
- else if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST))
- {
- ScrnId = SCR_ID_MSG_INBOX_LIST;
- }
- else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST))
- {
- ScrnId = SCR_ID_MSG_OUTBOX_LIST;
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- else if (IsScreenPresent(SCR_ID_MSG_VOICE_MAIL_LIST))
- {
- ScrnId = SCR_ID_MSG_VOICE_MAIL_LIST;
- }
- else if (IsScreenPresent(SCR_ID_MSG_WRITE))
- {
- ScrnId = SCR_ID_MSG_WRITE;
- }
- else if (IsScreenPresent(SCR_ID_MSG_INBOX_MSG))
- {
- ScrnId = SCR_ID_MSG_INBOX_MSG;
- }
- else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_MSG))
- {
- ScrnId = SCR_ID_MSG_DEFAULT_MSG;
- }
- #ifdef __MMI_MESSAGES_CHAT__
- else if (IsScreenPresent(CHAT_SCREEN_ROOM_ID))
- {
- ScrnId = CHAT_SCREEN_ROOM_ID;
- }
- #endif /* __MMI_MESSAGES_CHAT__ */
- if (ScrnId)
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[SmsMoMtGuiInterface.c] sms screen exists ---*n"));
- return TRUE;
- }
- return FALSE;
- }
- else
- #endif /* (defined(OBIGO_SUPPORT) || defined (JATAAYU_SUPPORT)) && defined(MMS_SUPPORT) */
- {
- /* get start screen id */
- if (IsScreenPresent(SCR_ID_MSG_MAIN_MENU_NO_MMS))
- {
- startScrnId = SCR_ID_MSG_MAIN_MENU_NO_MMS;
- }
- else if (IsScreenPresent(SCR_ID_MSG_MAIN_MENU))
- {
- startScrnId = SCR_ID_MSG_MAIN_MENU;
- }
- #ifdef __MMI_UNIFIED_MESSAGE__
- else if (IsScreenPresent(SCR_ID_UM_MAIN))
- {
- startScrnId = SCR_ID_UM_MAIN;
- }
- #ifdef __MMI_UNIFIED_COMPOSER__
- else if (IsScreenPresent(SCR_ID_UC_EDITOR))
- {
- startScrnId = SCR_ID_UC_EDITOR;
- }
- #else /* __MMI_UNIFIED_COMPOSER__ */
- else if (IsScreenPresent(SCR_ID_UM_WRITE_MSG))
- {
- startScrnId = SCR_ID_UM_WRITE_MSG;
- }
- #endif /* __MMI_UNIFIED_COMPOSER__ */
- else if (IsScreenPresent(SCR_ID_UM_INBOX))
- {
- startScrnId = SCR_ID_UM_INBOX;
- }
- else if (IsScreenPresent(SCR_ID_UM_UNSENT))
- {
- startScrnId = SCR_ID_UM_UNSENT;
- }
- else if (IsScreenPresent(SCR_ID_UM_SENT))
- {
- startScrnId = SCR_ID_UM_SENT;
- }
- else if (IsScreenPresent(SCR_ID_UM_DRAFT))
- {
- startScrnId = SCR_ID_UM_DRAFT;
- }
- #else /* __MMI_UNIFIED_MESSAGE__ */
- else if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST))
- {
- startScrnId = SCR_ID_MSG_INBOX_LIST;
- }
- else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST))
- {
- startScrnId = SCR_ID_MSG_OUTBOX_LIST;
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- else if (IsScreenPresent(SCR_ID_MSG_WRITE))
- {
- startScrnId = SCR_ID_MSG_WRITE;
- }
- else if (IsScreenPresent(SCR_ID_MSG_VOICE_MAIL_LIST))
- {
- startScrnId = SCR_ID_MSG_VOICE_MAIL_LIST;
- }
- else if (IsScreenPresent(SCR_ID_MSG_INBOX_MSG))
- {
- startScrnId = SCR_ID_MSG_INBOX_MSG;
- }
- else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_MSG))
- {
- startScrnId = SCR_ID_MSG_DEFAULT_MSG;
- }
- #ifdef __MMI_MESSAGES_CHAT__
- else if (IsScreenPresent(CHAT_SCREEN_ROOM_ID))
- {
- startScrnId = CHAT_SCREEN_ROOM_ID;
- }
- #endif /* __MMI_MESSAGES_CHAT__ */
- if (startScrnId)
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*---[MessagesMiscell.c] Start scrn id to be deleteted %d ---*n", startScrnId));
- GetPreviousScrnIdOf(GetCmMarkerScrnID(), &endScrnId);
- if (endScrnId)
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*---[MessagesMiscell.c] End scrn id to be deleteted %d ---*n", endScrnId));
- if (DeleteBetweenScreen(startScrnId, endScrnId))
- {
- g_msg_cntx.toDisplayMessageList = TO_DISPLAY_MESSAGE_LIST_NONE;
- mmi_frm_sms_delete_action_pending();
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
- "*---[MessagesMiscell.c] Deleteted scrn id from %d to %d and action---*n",
- startScrnId, endScrnId));
- return FALSE;
- }
- }
- }
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[MessagesMiscell.c] Not deleteted scrn id from %d to %d ---*n",
- startScrnId, endScrnId));
- return FALSE;
- }
- }
- else
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*[SmsMoMtGuiInterface.c] Messages state = %d", g_msg_cntx.msg_status));
- return TRUE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * PreEntryScrMessagesMenuList
- * DESCRIPTION
- * Before entry messages main menu, check if MSG application is reentered.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void PreEntryScrMessagesMenuList(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[SmsMoMtGuiInterface.c] PreEntryScrMessagesMenuList -------*n"));
- #ifdef __MMI_UNIFIED_MESSAGE__
- if (!mmi_um_is_available())
- {
- DisplayPopup(
- (PU8) GetString(STR_GLOBAL_NOT_AVAILABLE),
- IMG_GLOBAL_ERROR,
- 1,
- MESSAGES_POPUP_TIME_OUT,
- (U8) ERROR_TONE);
- }
- #else /* __MMI_UNIFIED_MESSAGE__ */
- if (IsMessagesReEntering())
- {
- DisplayPopup(
- (PU8) GetString(STR_SMS_MSG_NOT_READY_YET),
- IMG_GLOBAL_UNFINISHED,
- 1,
- MESSAGES_POPUP_TIME_OUT,
- (U8) ERROR_TONE);
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- else
- {
- EntryScrMessagesMenuList();
- }
- }
- /*****************************************************************************
- * FUNCTION
- * EntryScrMessagesMenuList
- * DESCRIPTION
- * Entry messages main menu screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void EntryScrMessagesMenuList(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer = NULL;
- U16 numItems = 0;
- U16 nStrItemList[MAX_SUB_MENUS];
- U16 itemIcons[MAX_SUB_MENUS];
- U16 screenId = SCR_ID_MSG_MAIN_MENU;
- #ifdef __MMI_MESSAGES_MULTI_APP__
- /* S32 menuItemId=-1; */
- #else /* __MMI_MESSAGES_MULTI_APP__ */
- U8 *popUpList[MAX_SUB_MENUS];
- //S32 menuItemId=-1;
- //S32 menuItemId1=-1;
- #endif /* __MMI_MESSAGES_MULTI_APP__ */
- /* S32 maskingByte=-1; */
- U8 **pPopUpList = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #if defined(__MMI_SMART_MESSAGE_MT__)
- mmi_nsm_set_msg_type(NORMAL_MESSAGE);
- #endif
- AlmEnableSPOF();
- #if (defined(OBIGO_SUPPORT) || defined (JATAAYU_SUPPORT)) && defined(MMS_SUPPORT)
- if ((isInCall()) || (IsScreenPresent(wap_get_screen_id())))
- {
- screenId = SCR_ID_MSG_MAIN_MENU_NO_MMS;
- }
- #endif /* (defined(OBIGO_SUPPORT) || defined (JATAAYU_SUPPORT)) && defined(MMS_SUPPORT) */
- EntryNewScreen(screenId, mmi_msg_exit_generic, EntryScrMessagesMenuList, NULL);
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[SmsMoMtGuiInterface.c] EntryScrMessagesMenuList %d-------*n",
- screenId));
- SetParentHandler(MAIN_MENU_MESSAGES_MENUID);
- RegisterHighlightHandler(ExecuteCurrHiliteHandler);
- mmi_msg_set_msg_menu_highlight_handler();
- #ifdef __MMI_MESSAGES_MULTI_APP__
- #if (defined(OBIGO_SUPPORT) || defined (JATAAYU_SUPPORT)) && defined(MMS_SUPPORT)
- //menuItemId=GetChildMenuIDIndexByParentMenuID(MAIN_MENU_MESSAGES_MENUID, MESSAGES_MENU_MMS_MENUID);
- //if(menuItemId!=-1)
- //{
- if (((isInCall() && !GetWapCallPresent())) || (IsScreenPresent(wap_get_screen_id())))
- /* ResetBit(maskingByte,menuItemId); */
- {
- mmi_frm_hide_menu_item(MESSAGES_MENU_MMS_MENUID);
- }
- else
- {
- if (mmi_bootup_is_sim_valid())
- {
- /* Message menu is shown if WLAN is on, not unhide the MMS menu if there is no SIM */
- mmi_frm_unhide_menu_item(MESSAGES_MENU_MMS_MENUID);
- }
- }
- /* } */
- #endif /* (defined(OBIGO_SUPPORT) || defined (JATAAYU_SUPPORT)) && defined(MMS_SUPPORT) */
- #if defined(__MMI_EMAIL__)
- //menuItemId=GetChildMenuIDIndexByParentMenuID(MAIN_MENU_MESSAGES_MENUID, MENU_ID_EMAIL_MAIN);
- //if(menuItemId!=-1)
- //{
- if (isInCall() && (!GetWapCallPresent())) /* CSD call */
- /* ResetBit(maskingByte,menuItemId); */
- {
- mmi_frm_hide_menu_item(MENU_ID_EMAIL_MAIN);
- }
- else
- {
- mmi_frm_unhide_menu_item(MENU_ID_EMAIL_MAIN);
- }
- /* } */
- #endif /* defined(__MMI_EMAIL__) */
- #if defined(__MMI_IMPS__)
- //menuItemId=GetChildMenuIDIndexByParentMenuID(MAIN_MENU_MESSAGES_MENUID, MENU_ID_IMPS_MAIN);
- //if(menuItemId!=-1)
- //{
- if (isInCall() && (!GetWapCallPresent())) /* CSD call */
- /* ResetBit(maskingByte,menuItemId); */
- {
- mmi_frm_hide_menu_item(MENU_ID_IMPS_MAIN);
- }
- else
- {
- mmi_frm_unhide_menu_item(MENU_ID_IMPS_MAIN);
- }
- /* } */
- #endif /* defined(__MMI_IMPS__) */
- #else /* __MMI_MESSAGES_MULTI_APP__ */
- /* hint updation */
- if (mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_NOBOX) != MMI_FRM_SMS_INVALID_INDEX)
- {
- msgbox_info.totalinbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_INBOX);
- msgbox_info.totaloutbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_OUTBOX);
- msgbox_info.totaldraftbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_DRAFTS);
- mmi_msg_set_msg_num_hint(msgbox_info.totalinbox, msgbox_info.totaloutbox, msgbox_info.totaldraftbox);
- RefreshMessagesMenuList();
- }
- ConstructHintsList(MAIN_MENU_MESSAGES_MENUID, popUpList);
- if (mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_NOBOX) != MMI_FRM_SMS_INVALID_INDEX)
- {
- pPopUpList = popUpList;
- }
- else
- {
- pPopUpList = NULL;
- }
- /* diamond, 2005/07/01 removed for new menu item architecture to CPHS */
- #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 !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- #endif /* __MMI_MESSAGES_MULTI_APP__ */ /* MMS_SUPPORT */
- //MaskItems(itemIcons,(U8)numItems,maskingByte);
- //MaskHiliteItems(MAIN_MENU_MESSAGES_MENUID, maskingByte);
- //numItems=MaskItems(nStrItemList,(U8)numItems,maskingByte);
- /* diamond, 2005/07/01 add _Ext to menu item functions */
- numItems = GetNumOfChild_Ext(MAIN_MENU_MESSAGES_MENUID);
- GetSequenceStringIds_Ext(MAIN_MENU_MESSAGES_MENUID, nStrItemList);
- GetSequenceImageIds_Ext(MAIN_MENU_MESSAGES_MENUID, itemIcons);
- g_msg_cntx.currBoxIndex = 0;
- g_msg_cntx.sendMessageCase = SEND_CASE_SEND_ONLY;
- g_msg_cntx.PhbSmsInterfaceState = MMI_SEND_ONLY;
- SetMessagesCurrScrnID(screenId);
- guiBuffer = GetCurrGuiBuffer(screenId);
- /* MTK Leo add, mini_tab_bar */
- #ifdef __MMI_WGUI_MINI_TAB_BAR__
- wgui_enable_mini_tab_bar(MAIN_MENU_MESSAGES_MENUID);
- #endif
- /* MTK Leo end */
- #ifdef __MMI_UNIFIED_MESSAGE__
- ShowCategory52Screen(
- STR_UM_MAIN_MENU_TITLE_ID,
- IMG_SMS_ENTRY_SCRN_CAPTION,
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- numItems,
- nStrItemList,
- itemIcons,
- (U8 **) pPopUpList,
- 0,
- 0,
- guiBuffer);
- #else /* __MMI_UNIFIED_MESSAGE__ */
- ShowCategory52Screen(
- STR_MESSAGE_MAIN_MENU_CAPTION,
- IMG_SMS_ENTRY_SCRN_CAPTION,
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- numItems,
- nStrItemList,
- itemIcons,
- (U8 **) pPopUpList,
- 0,
- 0,
- guiBuffer);
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /* SMS use number // */
- static BOOL IsValidPhnumChar(S32 ch);
- /*****************************************************************************
- * FUNCTION
- * IsAPhoneNumber
- * DESCRIPTION
- * Check if input is a number string
- * PARAMETERS
- * number [?]
- * a(?) [IN] String
- * RETURNS
- * 1: input is a number string, 0: input is not a number string
- *****************************************************************************/
- int IsAPhoneNumber(S8 *number)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- int c = *number;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[SmsMoMtGuiInterface.c] IsAPhoneNumber -------*n"));
- if (c != '+' && !IS_NUM(c))
- {
- return 0;
- }
- do
- {
- number += ENCODING_LENGTH;
- c = *number;
- if (c && !IS_NUM(c) && !IsValidPhnumChar(c))
- {
- return 0;
- }
- }
- while (c);
- return 1;
- }
- /*****************************************************************************
- * FUNCTION
- * IsValidPhnumChar
- * DESCRIPTION
- * Some special characters should be in use number list as well
- * PARAMETERS
- * ch [IN]
- * a(?) [IN] Character
- * RETURNS
- * 1: input is a number string, 0: input is not a number string
- *****************************************************************************/
- static BOOL IsValidPhnumChar(S32 ch)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- BOOL ret_value;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (ch)
- {
- case '+':
- case '*':
- case '#':
- case 'p':
- case 'P':
- case 'w':
- case 'W':
- ret_value = TRUE;
- break;
- default:
- ret_value = FALSE;
- break;
- }
- return ret_value;
- }
- /*****************************************************************************
- * FUNCTION
- * GetPhoneNumber
- * DESCRIPTION
- * Get phone number if input is not a number string
- * PARAMETERS
- * number [?]
- * a(?) [IN] String
- * RETURNS
- * number string
- *****************************************************************************/
- S8 *GetPhoneNumber(S8 *number)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[SmsMoMtGuiInterface.c] GetPhoneNumber -------*n"));
- if (number && !IsAPhoneNumber(number))
- {
- number = lookUpName(number);
- }
- return number;
- }
- /*****************************************************************************
- * FUNCTION
- * AlreadyExists
- * DESCRIPTION
- * Check if input number string already exists in use number list
- * PARAMETERS
- * thisNum [?]
- * n [IN]
- * a(?) [IN] Number string
- * b(?) [IN] Current use number amount
- * RETURNS
- * 1: input string exists in use number list, 0: input string doesn't exist in use number list
- *****************************************************************************/
- int AlreadyExists(S8 *thisNum, int n)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- n--;
- for (; n >= 0; n--)
- {
- if (!pfnUnicodeStrcmp(thisNum, g_msg_cntx.numbersList[n]))
- {
- return 1;
- }
- }
- return 0;
- }
- /*****************************************************************************
- * FUNCTION
- * GetAsciiOrUCS2Char
- * DESCRIPTION
- * Get Ascii or UCS2 character
- * PARAMETERS
- * buf [?]
- * a(?) [IN] Address of string
- * RETURNS
- * the description of return value, if any.
- *****************************************************************************/
- S16 GetAsciiOrUCS2Char(S8 *buf)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return (*buf + ((*(buf + 1)) << 8));
- }
- /*****************************************************************************
- * FUNCTION
- * GetAsciiOrUCS2Char_RV
- * DESCRIPTION
- * Get Ascii or UCS2 character
- * PARAMETERS
- * buf [?]
- * a(?) [IN] Address of string
- * RETURNS
- * the description of return value, if any.
- *****************************************************************************/
- S16 GetAsciiOrUCS2Char_RV(U8 *buf)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return (*(buf + 1) + ((*buf) << 8));
- }
- /*****************************************************************************
- * FUNCTION
- * PutAsciiOrUCS2Char
- * DESCRIPTION
- * Put Ascii or UCS2 chatacter
- * PARAMETERS
- * buf [?]
- * c [IN]
- * a(?) [IN/OUT] Address of string
- * b(?) [IN] Input character
- * RETURNS
- * the description of return value, if any.(?)
- *****************************************************************************/
- void PutAsciiOrUCS2Char(S8 *buf, S16 c)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *buf++ = c & 0xff;
- *buf = c >> 8;
- }
- /*****************************************************************************
- * FUNCTION
- * IsSymbolValid
- * DESCRIPTION
- * Check if symbol is valid to insert use number
- * PARAMETERS
- * c [IN] Current use number record length
- * inBracket [IN]
- * numIndex [IN]
- * a(?) [IN] Input character
- * b(?) [IN] Bracket waiting flag
- * RETURNS
- * 1: symbol is valid, 0: symbol is not valid
- *****************************************************************************/
- static U8 IsSymbolValid(int c, U8 inBracket, U8 numIndex)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 status = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (IS_NUM(c))
- {
- return 1;
- }
- numIndex = numIndex / ENCODING_LENGTH;
- switch (c)
- {
- case '+':
- if (numIndex == 0)
- {
- status = 1;
- }
- break;
- case '(':
- status = 1;
- break;
- case ')':
- if (inBracket)
- {
- status = 1;
- }
- break;
- case 'p':
- case 'w':
- case '-':
- if (numIndex >= USE_NUM_MIN_LENGTH)
- {
- status = 1;
- }
- break;
- default:
- status = 0;
- }
- return status;
- }
- /*****************************************************************************
- * FUNCTION
- * TruncateLastUnwantedSymbols
- * DESCRIPTION
- * Truncate use number last unwanted symbols
- * PARAMETERS
- * buf [?]
- * len [IN]
- * a(?) [IN/OUT] Address of string
- * b(?) [IN] String length
- * RETURNS
- * void
- *****************************************************************************/
- static void TruncateLastUnwantedSymbols(S8 *buf, int len)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- int i, last = 0;
- int c;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < len; i += ENCODING_LENGTH)
- {
- c = GetAsciiOrUCS2Char(&buf[i]);
- if ((c != 'p') && (c != 'w') && (c != '-'))
- {
- last = i;
- }
- }
- if (i > last)
- {
- last += ENCODING_LENGTH;
- }
- PutAsciiOrUCS2Char(&buf[last], ' ');
- }
- /*****************************************************************************
- * FUNCTION
- * ObtainNumbersFromMessageText
- * DESCRIPTION
- * Obtain number list from message content
- * PARAMETERS
- * phNumber [?]
- * smsText [?]
- * bufLen [IN]
- * startindex [IN]
- * a(?) [IN] Message phone number
- * d(?) [IN] Number list start index
- * c(?) [IN] Message length
- * b(?) [IN] Message content
- * RETURNS
- * current use number list amount
- *****************************************************************************/
- U16 ObtainNumbersFromMessageText(char *phNumber, U8 *smsText, U16 bufLen, U8 startindex)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- int i;
- int c;
- S8 thisNum[(MAX_DIGITS + 1) * ENCODING_LENGTH];
- int pickNow = 0;
- U8 inBracket = 0;
- int thisNumIndex = 0;
- int currNumListIndex = startindex;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (pfnUnicodeStrlen((S8*) phNumber))
- {
- phNumber = GetPhoneNumber(phNumber);
- if (phNumber)
- {
- if (g_msg_cntx.numbersList[currNumListIndex])
- {
- OslMfree(g_msg_cntx.numbersList[currNumListIndex]);
- }
- g_msg_cntx.numbersList[currNumListIndex] = OslMalloc((pfnUnicodeStrlen(phNumber) + 2) * ENCODING_LENGTH);
- pfnUnicodeStrcpy((S8*) g_msg_cntx.numbersList[currNumListIndex], phNumber);
- currNumListIndex++;
- }
- }
- if (currNumListIndex == MAX_USE_NUMBERS)
- {
- return (U16) currNumListIndex;
- }
- for (i = 0; i < bufLen;)
- {
- c = GetAsciiOrUCS2Char((S8*) & smsText[i]);
- i += ENCODING_LENGTH;
- if (IsSymbolValid(c, inBracket, (U8) thisNumIndex) && (thisNumIndex < (MAX_DIGITS - 1) * ENCODING_LENGTH))
- {
- if ((c != '-') && (c != '(') && (c != ')'))
- {
- PutAsciiOrUCS2Char(&thisNum[thisNumIndex], (S16) c);
- thisNumIndex += ENCODING_LENGTH;
- }
- if (c == '(')
- {
- inBracket++;
- }
- else if ((c == ')') && inBracket)
- {
- inBracket--;
- }
- }
- else
- {
- pickNow = 1;
- while (thisNumIndex && (i < bufLen))
- {
- if (!IS_NUM(c))
- {
- /* to handle the scenario number'+'number ex. "123+123" should be parsed as 123 and +123, instead of 123 */
- if (c == '+')
- {
- i -= ENCODING_LENGTH;
- }
- }
- /* a stream of number that exceeds 40 digits, the number starting from 41 digits will become the next use number */
- else /* c is a num */
- {
- i -= ENCODING_LENGTH;
- }
- break;
- // c = GetAsciiOrUCS2Char((S8*) & smsText[i]);
- // i += ENCODING_LENGTH;
- }
- }
- if (i >= bufLen)
- {
- pickNow = 1;
- }
- if (pickNow)
- {
- int c1 = 0;
- pickNow = 0;
- if (thisNumIndex && ((c1 = GetAsciiOrUCS2Char((S8*) & thisNum[thisNumIndex - ENCODING_LENGTH])) == 'w')
- || (c1 == 'p'))
- {
- TruncateLastUnwantedSymbols(thisNum, thisNumIndex);
- }
- PutAsciiOrUCS2Char(&thisNum[thisNumIndex], ' ');
- if (!AlreadyExists(thisNum, currNumListIndex))
- {
- if (thisNumIndex >= (USE_NUM_MIN_LENGTH * ENCODING_LENGTH))
- {
- if (g_msg_cntx.numbersList[currNumListIndex])
- {
- OslMfree(g_msg_cntx.numbersList[currNumListIndex]);
- }
- g_msg_cntx.numbersList[currNumListIndex] = OslMalloc((pfnUnicodeStrlen(thisNum) + 2) * ENCODING_LENGTH);
- pfnUnicodeStrcpy((S8*) g_msg_cntx.numbersList[currNumListIndex], thisNum);
- currNumListIndex++;
- if (currNumListIndex == MAX_USE_NUMBERS)
- {
- break;
- }
- }
- }
- thisNumIndex = 0;
- }
- }
- return (U16) currNumListIndex;
- }
- #ifdef __MMI_MESSAGES_CHAT__
- /*****************************************************************************
- * FUNCTION
- * ObtainChatNumbersFromMessageTextWrapper
- * DESCRIPTION
- * Obtain number list from chat message content
- * PARAMETERS
- * phNumber [?]
- * chatroomindex [IN]
- * a(?) [IN] Message phone number
- * b(?) [IN] Message room index
- * RETURNS
- * current use number list amount
- *****************************************************************************/
- U16 ObtainChatNumbersFromMessageTextWrapper(char *phNumber, S16 chatroomindex)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 bufLen = 0;
- U8 *smsText = NULL;
- S16 j;
- U16 currindex = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (j = 0; j < GetNumOfMessage(chatroomindex); j++)
- {
- smsText = GetMemoryPointer(j, chatroomindex);
- bufLen = (S16) pfnUnicodeStrlen((PS8) smsText);
- bufLen = bufLen * ENCODING_LENGTH;
- if (j == 0)
- {
- currindex = ObtainNumbersFromMessageText(phNumber, smsText, bufLen, 0);
- }
- else
- {
- currindex = ObtainNumbersFromMessageText(NULL, smsText, bufLen, (U8) currindex);
- }
- if (currindex == MAX_USE_NUMBERS)
- {
- return currindex;
- }
- }
- /* chat room message content is empty but the destination number should still be displayed in the use number list */
- if (GetNumOfMessage(chatroomindex) == 0)
- {
- if (pfnUnicodeStrlen((S8*) phNumber))
- {
- phNumber = GetPhoneNumber(phNumber);
- if (phNumber)
- {
- if (g_msg_cntx.numbersList[currindex])
- {
- OslMfree(g_msg_cntx.numbersList[currindex]);
- }
- g_msg_cntx.numbersList[currindex] = OslMalloc((pfnUnicodeStrlen(phNumber) + 2) * ENCODING_LENGTH);
- pfnUnicodeStrcpy((S8*) g_msg_cntx.numbersList[currindex], phNumber);
- currindex++;
- }
- }
- }
- return currindex;
- }
- /*****************************************************************************
- * FUNCTION
- * GetNewChatSmsIndDisplayStr
- * DESCRIPTION
- * Get chat message indication string for dislpay
- * PARAMETERS
- * void
- * RETURNS
- * NewChatMessageFromXxxStr
- *****************************************************************************/
- PU8 GetNewChatSmsIndDisplayStr(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("*-------[MessagesIdleApp.c] GetNewSmsIndDisplayStr -------*n"));
- return NewChatMessageFromXxxStr;
- }
- /*****************************************************************************
- * FUNCTION
- * GetNewChatMsgIndDisplayString
- * DESCRIPTION
- * Compose new chat message indication string
- * PARAMETERS
- * number [?]
- * length [IN]
- * type [IN]
- * a(?) [IN] Message phone number
- * c(?) [IN] Message number type
- * b(?) [IN] Message number length
- * RETURNS
- * void
- *****************************************************************************/
- void GetNewChatMsgIndDisplayString(U8 *number, U8 length, U8 type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION(("*-------[MessagesIdleApp.c] GetNewMsgIndDisplayString -------*n"));
- memset(&NewChatMessageFromXxxStr, 0, sizeof(NewChatMessageFromXxxStr));
- if (length)
- {
- PS8 phbName = NULL;
- PU8 pPhoneNumberPtr = ConvertL4NumberStructToDisplay(number, length, type);
- phbName = lookUpNumber((S8*) pPhoneNumberPtr);
- if (phbName != NULL)
- {
- if (pfnUnicodeStrcmp(phbName, ""))
- {
- pfnUnicodeStrncpy(
- (PS8) NewChatMessageFromXxxStr,
- (PS8) phbName,
- (U32) (sizeof(NewChatMessageFromXxxStr) / ENCODING_LENGTH) - 1);
- }
- else
- {
- pfnUnicodeStrncat(
- (PS8) NewChatMessageFromXxxStr,
- (PS8) pPhoneNumberPtr,
- (U32) (sizeof(NewChatMessageFromXxxStr) / ENCODING_LENGTH) - 1);
- }
- }
- else
- {
- pfnUnicodeStrncat(
- (PS8) NewChatMessageFromXxxStr,
- (PS8) pPhoneNumberPtr,
- (U32) (sizeof(NewChatMessageFromXxxStr) / ENCODING_LENGTH) - 1);
- }
- if (pPhoneNumberPtr)
- {
- OslMfree(pPhoneNumberPtr);
- pPhoneNumberPtr = NULL;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * DeleteChatMsg
- * DESCRIPTION
- * Delete chat message
- * PARAMETERS
- * index [IN]
- * a(?) [IN] Message index
- * RETURNS
- * void
- *****************************************************************************/
- void DeleteChatMsg(S32 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_msg_cntx.msg_ind_chat_index = (U16) index;
- }
- /*****************************************************************************
- * FUNCTION
- * GetConcatenatedMessage
- * DESCRIPTION
- * Concatenate message for chat room screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void GetConcatenatedMessage(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- EMSData *pEMSdata;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- GetEMSDataForView(&pEMSdata, 1); /* force to clear old content and initialize */
- EMSUnPack(pEMSdata, 1, PendingSaveSendData.totalSegments, PendingSaveSendData.TPUD_p, PendingSaveSendData.TPUDLen);
- return;
- }
- #endif /* __MMI_MESSAGES_CHAT__ */
- #ifdef __MMI_MESSAGES_TEMPLATE__
- /*****************************************************************************
- * FUNCTION
- * ReadTemplateFromNVRAM
- * DESCRIPTION
- * Read template from NVRAM
- * PARAMETERS
- * index [IN]
- * a(?) [IN] Index
- * RETURNS
- * void
- *****************************************************************************/
- void ReadTemplateFromNVRAM(U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (index >= NVRAM_SMS_RECORD_TOTAL)
- {
- PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "### ERROR: ReadTemplateFromNVRAM: index out of bound"));
- return;
- }
- memset(g_msg_cntx.scratchTemplRec, 0, NVRAM_SMS_TEMPL_RECORD_SIZE + ENCODING_LENGTH);
- if (ReadRecord(NVRAM_EF_SMS_LID, (U16) (index + 1), g_msg_cntx.scratchTemplRec, NVRAM_SMS_TEMPL_RECORD_SIZE, &error)
- < 0)
- {
- g_msg_cntx.scratchTemplRec[0] = ' ';
- }
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * WriteTemplateToNVRAM
- * DESCRIPTION
- * Write template to NVRAM
- * PARAMETERS
- * index [IN]
- * a(?) [IN] Index
- * RETURNS
- * TRUE: write success, FALSE: write fail
- *****************************************************************************/
- U8 WriteTemplateToNVRAM(U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (index >= NVRAM_SMS_RECORD_TOTAL)
- {
- return FALSE;
- }
- if (WriteRecord
- (NVRAM_EF_SMS_LID, (U16) (index + 1 + 1), g_msg_cntx.scratchTemplRec, NVRAM_SMS_TEMPL_RECORD_SIZE,
- &error) != NVRAM_SMS_TEMPL_RECORD_SIZE)
- {
- return FALSE;
- }
- return TRUE;
- }
- #if defined(_MUTILANG_TEMPLATE_) || defined(__MMI_MESSAGES_SIMCHINESE_TEMPLATE__)
- /*****************************************************************************
- * FUNCTION
- * SetTemplateLanguage
- * DESCRIPTION
- * Set template language
- * PARAMETERS
- * langtype [IN]
- * a(?) [IN] Language type
- * RETURNS
- * void
- *****************************************************************************/
- void SetTemplateLanguage(U8 langtype)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 i = 0;
- S16 error;
- S8 tempLang[SSC_SIZE];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(tempLang, 0, SSC_SIZE);
- switch (langtype)
- {
- case MSG_TEMPLATE_LANG_ENGLISH:
- memcpy(tempLang, SSC_ENGLISH, SSC_SIZE);
- break;
- case MSG_TEMPLATE_LANG_SIMCHINESE:
- memcpy(tempLang, SSC_SCHINESE, SSC_SIZE);
- break;
- case MSG_TEMPLATE_LANG_TRACHINESE:
- memcpy(tempLang, SSC_TCHINESE, SSC_SIZE);
- break;
- }
- for (i = 0; i < MAX_LANGUAGES; i++)
- {
- if (strcmp((PS8) gLanguageArray[i].aLangSSC, (S8*) tempLang) == 0)
- {
- if (gCurrLangIndex != i)
- {
- SetCurrentLanguage(i);
- WriteValue(NVRAM_SETTING_LANG, &i, DS_BYTE, &error);
- break;
- }
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * UnsetTemplateLanguage
- * DESCRIPTION
- * Unset template language
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void UnsetTemplateLanguage(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 i = 0;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < MAX_LANGUAGES; i++)
- {
- if (strcmp((PS8) gLanguageArray[i].aLangSSC, (PS8) currLang) == 0)
- {
- if (gCurrLangIndex != i)
- {
- SetCurrentLanguage(i);
- WriteValue(NVRAM_SETTING_LANG, &i, DS_BYTE, &error);
- break;
- }
- }
- }
- }
- #endif /* defined(_MUTILANG_TEMPLATE_) || defined(__MMI_MESSAGES_SIMCHINESE_TEMPLATE__) */
- /*****************************************************************************
- * FUNCTION
- * WriteDefaultTemplateToNVRAM
- * DESCRIPTION
- * Write default template to NVRAM
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- U8 WriteDefaultTemplateToNVRAM(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i = 0;
- S8 *tmpl_str;
- U8 result;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < NUM_TEMPLATES; i++)
- {
- U16 templateindex = i + CalTemplateBase();
- tmpl_str = GetString(templateStrings[i]);
- memset(g_msg_cntx.scratchTemplRec, 0, NVRAM_SMS_TEMPL_RECORD_SIZE + ENCODING_LENGTH);
- if (tmpl_str)
- {
- memcpy(g_msg_cntx.scratchTemplRec, tmpl_str, (pfnUnicodeStrlen(tmpl_str) + 1) * ENCODING_LENGTH);
- }
- result = WriteTemplateToNVRAM(templateindex);
- if (result == FALSE)
- {
- return FALSE;
- }
- }
- return TRUE;
- }
- /*****************************************************************************
- * FUNCTION
- * InitTemplates
- * DESCRIPTION
- * Init templates
- * PARAMETERS
- * void
- * RETURNS
- * TRUE: init success, FALSE: init fail
- *****************************************************************************/
- U8 InitTemplates(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- static int initDone = 0;
- static S8 templateSignature[MAX_TEMPLATE_LENGTH + 1] = "AAA";
- S8 buffer[NVRAM_SMS_TEMPL_RECORD_SIZE];
- S16 error;
- int i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (initDone)
- {
- return TRUE;
- }
- initDone = 1;
- if (ReadRecord(NVRAM_EF_SMS_LID, 1, buffer, NVRAM_SMS_TEMPL_RECORD_SIZE, &error) < 0)
- {
- buffer[0] = ' ';
- }
- if (buffer[0] == 'A')
- {
- return TRUE;
- }
- #if defined (_MUTILANG_TEMPLATE_) || defined (__MMI_MESSAGES_SIMCHINESE_TEMPLATE__)
- memset(currLang, 0, SSC_SIZE);
- memcpy(currLang, (PS8) gLanguageArray[gCurrLangIndex].aLangSSC, SSC_SIZE);
- #ifdef _MUTILANG_TEMPLATE_
- for (i = 0; i < TOTAL_TEMPLATE_LANGUAGE; i++)
- {
- SetTemplateLanguage((U8) i);
- if (!WriteDefaultTemplateToNVRAM())
- {
- return FALSE;
- }
- }
- #else /* _MUTILANG_TEMPLATE_ */
- SetTemplateLanguage(MSG_TEMPLATE_LANG_SIMCHINESE);
- if (!WriteDefaultTemplateToNVRAM())
- {
- return FALSE;
- }
- #endif /* _MUTILANG_TEMPLATE_ */
- UnsetTemplateLanguage();
- #else /* defined (_MUTILANG_TEMPLATE_) || defined (__MMI_MESSAGES_SIMCHINESE_TEMPLATE__) */
- if (!WriteDefaultTemplateToNVRAM())
- {
- return FALSE;
- }
- #endif /* defined (_MUTILANG_TEMPLATE_) || defined (__MMI_MESSAGES_SIMCHINESE_TEMPLATE__) */
- if (WriteRecord(NVRAM_EF_SMS_LID, 1, templateSignature, NVRAM_SMS_TEMPL_RECORD_SIZE, &error) <
- NVRAM_SMS_TEMPL_RECORD_SIZE)
- {
- return FALSE;
- }
- return TRUE;
- }
- /*****************************************************************************
- * FUNCTION
- * DeInitTemplates
- * DESCRIPTION
- * Deinit templates
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void DeInitTemplates(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- int i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < NUM_TEMPLATES; i++)
- {
- if (g_msg_cntx.templates[i])
- {
- OslMfree(g_msg_cntx.templates[i]);
- g_msg_cntx.templates[i] = NULL;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * LoadTemplatesInDisplayList
- * DESCRIPTION
- * Load templates to display list
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void LoadTemplatesInDisplayList(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- DeInitTemplates();
- for (i = 0; i < NUM_TEMPLATES; i++)
- {
- U16 templateindex = i + CalTemplateBase() + 1;
- ReadTemplateFromNVRAM(templateindex);
- g_msg_cntx.templates[i] = OslMalloc((pfnUnicodeStrlen(g_msg_cntx.scratchTemplRec) + 1) * ENCODING_LENGTH);
- pfnUnicodeStrcpy(g_msg_cntx.templates[i], g_msg_cntx.scratchTemplRec);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * GetTemplatesToEdit
- * DESCRIPTION
- * Get templates to edit.
- * PARAMETERS
- * buffer [?]
- * index [IN]
- * a(?) [IN/OUT] Address of string
- * b(?) [IN] Current highlight index
- * RETURNS
- * void
- *****************************************************************************/
- void GetTemplatesToEdit(S8 *buffer, U32 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_msg_cntx.templates[index])
- {
- pfnUnicodeStrcpy((PS8) buffer, (PS8) g_msg_cntx.templates[index]);
- }
- else
- {
- buffer[0] = buffer[1] = ' ';
- }
- }
- /*****************************************************************************
- * FUNCTION
- * DeleteTemplate
- * DESCRIPTION
- * Delete template
- * PARAMETERS
- * index [IN]
- * a(?) [IN] Index
- * RETURNS
- * TRUE: delete success, FALSE: delete fail
- *****************************************************************************/
- U8 DeleteTemplate(U32 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 templateindex = (U16) index + CalTemplateBase();
- U8 result;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(g_msg_cntx.scratchTemplRec, 0, NVRAM_SMS_TEMPL_RECORD_SIZE + ENCODING_LENGTH);
- result = WriteTemplateToNVRAM(templateindex);
- return result;
- }
- /*****************************************************************************
- * FUNCTION
- * StoreTemplate
- * DESCRIPTION
- * Store templates
- * PARAMETERS
- * index [IN]
- * a(?) [IN] Index
- * b(?) [IN] Address of string
- * RETURNS
- * TRUE: store success, FALSE: store fail
- *****************************************************************************/
- U8 StoreTemplate(U32 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 templateindex = (U16) index + CalTemplateBase();
- U8 result;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- result = WriteTemplateToNVRAM(templateindex);
- return result;
- }
- /*****************************************************************************
- * FUNCTION
- * CalTemplateBase
- * DESCRIPTION
- * Calculate template base
- * PARAMETERS
- * void
- * RETURNS
- * template base
- *****************************************************************************/
- U16 CalTemplateBase(void)
- {
- #ifdef _MUTILANG_TEMPLATE_
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 tempLangOffset = 0;
- U16 tempBase = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (IsTrChineseSet())
- {
- tempLangOffset = (U8) MSG_TEMPLATE_LANG_TRACHINESE;
- }
- else if (IsSmChineseSet())
- {
- tempLangOffset = (U8) MSG_TEMPLATE_LANG_SIMCHINESE;
- }
- else
- {
- tempLangOffset = (U8) MSG_TEMPLATE_LANG_ENGLISH;
- }
- tempBase = tempLangOffset * NUM_TEMPLATES;
- return tempBase;
- #else /* _MUTILANG_TEMPLATE_ */
- return 0;
- #endif /* _MUTILANG_TEMPLATE_ */