SpeedDial.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:54k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * SpeedDial.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is intends for Speed dial application
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  *------------------------------------------------------------------------------
  96.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  97.  *============================================================================
  98.  ****************************************************************************/
  99. /**
  100.  * Copyright Notice
  101.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  102.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  103.  *  (It is illegal to remove this copyright notice from this software or any
  104.  *  portion of it)
  105.  */
  106. /**************************************************************
  107.    FILENAME : SpeedDial.c
  108.    PURPOSE     : Speed Dial Application 
  109.    REMARKS     : nil
  110.    AUTHOR      : Hariprasad, Vanita Jain
  111.    DATE     : Dec 5,02
  112. **************************************************************/
  113. #ifndef _SPEEDDIAL_C
  114. #define _SPEEDDIAL_C
  115. /*  Include: MMI header file */
  116. #include "MMI_features.h"
  117. #include "stdC.h"
  118. #include "L4Dr1.h"
  119. #include "PixtelDataTypes.h"
  120. #include "DebugInitDef.h"
  121. #include "ProtocolEvents.h"
  122. #include "PhonebookDef.h"
  123. #include "PhoneBookTypes.h"
  124. #include "PhonebookGprot.h"
  125. #include "Phonebookprot.h"
  126. #include "wgui_categories.h"
  127. #include "mainmenudef.h"
  128. #include "CallManagementGprot.h"
  129. #include "Unicodexdcl.h"
  130. #include "GlobalDefs.h"
  131. #include "SettingDefs.h"
  132. #include "SpeedDial.h"
  133. #include "NVRAMProt.h"
  134. #include "NVRAMEnum.h"
  135. #include "NVRAMType.h"
  136. #include "GlobalMenuItems.h"
  137. #include "TimerEvents.h"
  138. #include "CommonScreens.h"
  139. #include "SettingDefs.h"
  140. #include "SettingsGdcl.h"
  141. #include "SimDetectionGexdcl.h"
  142. #include "SimDetectionGprot.h"
  143. #ifdef __SYNCML_SUPPORT__
  144. #include "SyncMLDef.h"
  145. #include "SyncMLGprot.h"
  146. #endif /* __SYNCML_SUPPORT__ */
  147. /* 
  148.  * Define
  149.  */
  150. /* 
  151.  * Typedef 
  152.  */
  153. /* 
  154.  * Local Variable
  155.  */
  156. SpeedDialInfo speedDialTable[MAX_SPEED_DIAL_NUMBER];
  157. static pBOOL CurrentSpeedTypeChange = FALSE;
  158. U8 speedKeyIndex = 0, CurrentSpeedType = 0;
  159. S16 currentKeyIndex = 0;
  160. pBOOL readNVRAM = FALSE;
  161. /* 
  162.  * Global Variable
  163.  */
  164. extern MMI_PHB_ENTRY_BCD_STRUCT PhoneBook[];
  165. extern U16 g_phb_name_index[];
  166. extern U16 PhoneBookEntryCount;
  167. /* 
  168.  * Global Function
  169.  */
  170. extern void mmi_phb_init_build_lookup_table(void);
  171. /*****************************************************************************
  172.  * FUNCTION
  173.  *  HintPhbSpeedDial
  174.  * DESCRIPTION
  175.  *  This function is hint handling function
  176.  *  for Phonesetup -> SpeedDial
  177.  *  Functionality:
  178.  * PARAMETERS
  179.  *  index       [IN]            
  180.  *  a(?)        [IN/OUT]        
  181.  *  b(?)        [IN]            
  182.  * RETURNS
  183.  *  void
  184.  *****************************************************************************/
  185. void HintPhbSpeedDial(U16 index)
  186. {
  187.     /*----------------------------------------------------------------*/
  188.     /* Local Variables                                                */
  189.     /*----------------------------------------------------------------*/
  190.     /*----------------------------------------------------------------*/
  191.     /* Code Body                                                      */
  192.     /*----------------------------------------------------------------*/
  193.     if (PhbGetSpeedDialStatus())
  194.     {
  195.         pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_GLOBAL_ON));
  196.     }
  197.     else
  198.     {
  199.         pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_GLOBAL_OFF));
  200.     }
  201. }
  202. /*****************************************************************************
  203.  * FUNCTION
  204.  *  HighlightPhbSpeedDial
  205.  * DESCRIPTION
  206.  *  This function is highlight handler for Phonesetup-> SpeedDial
  207.  *  Follow functions: EntryPhbSpeedDial
  208.  * PARAMETERS
  209.  *  void
  210.  *  a(?)        [IN/OUT]        
  211.  *  b(?)        [IN]            
  212.  * RETURNS
  213.  *  void
  214.  *****************************************************************************/
  215. void HighlightPhbSpeedDial(void)
  216. {
  217.     /*----------------------------------------------------------------*/
  218.     /* Local Variables                                                */
  219.     /*----------------------------------------------------------------*/
  220.     /*----------------------------------------------------------------*/
  221.     /* Code Body                                                      */
  222.     /*----------------------------------------------------------------*/
  223.     /* 2 Change right soft key icon and label */
  224.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  225.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  226.     /* 3 Register function for left soft key */
  227.     SetLeftSoftkeyFunction(EntryPhbSpeedDial, KEY_EVENT_UP);
  228.     SetKeyHandler(EntryPhbSpeedDial, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  229.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  230.     /* 4 Register function for right soft key */
  231.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  232. }
  233. /*****************************************************************************
  234.  * FUNCTION
  235.  *  EntryPhbSpeedDial
  236.  * DESCRIPTION
  237.  *  This function is Entry function for Phonesetup-> SpeedDial
  238.  *  Following functions:
  239.  * PARAMETERS
  240.  *  void
  241.  *  a(?)        [IN/OUT]        
  242.  *  b(?)        [IN]            
  243.  * RETURNS
  244.  *  void
  245.  *****************************************************************************/
  246. void EntryPhbSpeedDial(void)
  247. {
  248.     /*----------------------------------------------------------------*/
  249.     /* Local Variables                                                */
  250.     /*----------------------------------------------------------------*/
  251.     U16 nStrItemList[MAX_SUB_MENUS];    /* Stores the strings id of submenus returned */
  252.     U16 nNumofItem;                     /* Stores no of children in the submenu */
  253.     U16 nDispAttribute;                 /* Stores display attribue */
  254.     U8 *guiBuffer;                      /* Buffer holding history data */
  255.     U8 *SpeedDialType[MAX_SUB_MENUS];
  256.     /*----------------------------------------------------------------*/
  257.     /* Code Body                                                      */
  258.     /*----------------------------------------------------------------*/
  259.     /* Call Exit Handler */
  260.     EntryNewScreen(SCR_SETTING_SPEED_DIAL, ExitPhbSpeedDial, EntryPhbSpeedDial, NULL);
  261.     /* Get current screen to gui buffer  for history purposes */
  262.     guiBuffer = GetCurrGuiBuffer(SCR_SETTING_SPEED_DIAL);
  263.     /* Retrieve no of child of menu item to be displayed */
  264.     nNumofItem = GetNumOfChild_Ext(MENU_SETTING_SPEED_DIAL);
  265.     /* Get attribute of menu to be displayed */
  266.     nDispAttribute = GetDispAttributeOfItem(MENU9102_INITIAL_SETUP);
  267.     /* Retrieve string ids in sequence of given menu item to be displayed */
  268.     GetSequenceStringIds_Ext(MENU_SETTING_SPEED_DIAL, nStrItemList);
  269.     /* Set current parent id */
  270.     SetParentHandler(MENU_SETTING_SPEED_DIAL);
  271.     /* Register highlight handler to be called in menu screen */
  272.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  273.     /* Construct the Hints List */
  274.     ConstructHintsList(MENU_SETTING_SPEED_DIAL, SpeedDialType);
  275.     /* Display Category1 Screen */
  276.     ShowCategory52Screen(
  277.         STR_MENU_SETTING_SPEED_DIAL,
  278.         GetRootTitleIcon(MENU_SETTING_SPEED_DIAL) /* MAIN_MENU_TITLE_SETTINGS_ICON */ ,
  279.         STR_GLOBAL_OK,
  280.         IMG_GLOBAL_OK,
  281.         STR_GLOBAL_BACK,
  282.         IMG_GLOBAL_BACK,
  283.         nNumofItem,
  284.         nStrItemList,
  285.         (PU16) gIndexIconsImageList,
  286.         SpeedDialType,
  287.         0,
  288.         0,
  289.         guiBuffer);
  290.     /* Register function with right softkey */
  291.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  292.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  293. }
  294. /*****************************************************************************
  295.  * FUNCTION
  296.  *  ExitPhbSpeedDial
  297.  * DESCRIPTION
  298.  *  This function is Exit function for Phonesetup-> SpeedDial
  299.  *  Functionality:  Save speed dial status
  300.  * PARAMETERS
  301.  *  void
  302.  *  a(?)        [IN/OUT]        
  303.  *  b(?)        [IN]            
  304.  * RETURNS
  305.  *  void
  306.  *****************************************************************************/
  307. void ExitPhbSpeedDial(void)
  308. {
  309.     /*----------------------------------------------------------------*/
  310.     /* Local Variables                                                */
  311.     /*----------------------------------------------------------------*/
  312.     S16 error;
  313.     /*----------------------------------------------------------------*/
  314.     /* Code Body                                                      */
  315.     /*----------------------------------------------------------------*/
  316.     /* Save To NVRAM if Value is Changed */
  317.     if (CurrentSpeedTypeChange == TRUE)
  318.     {
  319.         WriteValue(NVRAM_SETTING_SPEED_DIAL, &CurrentSpeedType, DS_BYTE, &error);
  320.         CurrentSpeedTypeChange = FALSE;
  321.     }
  322. }
  323. /*****************************************************************************
  324.  * FUNCTION
  325.  *  HighlightPhbSpeedDialStatus
  326.  * DESCRIPTION
  327.  *  This function is highlight handler for Phonesetup-> SpeedDial -> Status
  328.  *  Follow functions: EntryPhbSpeedDialStatus
  329.  * PARAMETERS
  330.  *  void
  331.  *  a(?)        [IN/OUT]        
  332.  *  b(?)        [IN]            
  333.  * RETURNS
  334.  *  void
  335.  *****************************************************************************/
  336. void HighlightPhbSpeedDialStatus(void)
  337. {
  338.     /*----------------------------------------------------------------*/
  339.     /* Local Variables                                                */
  340.     /*----------------------------------------------------------------*/
  341.     U16 index;
  342.     /*----------------------------------------------------------------*/
  343.     /* Code Body                                                      */
  344.     /*----------------------------------------------------------------*/
  345.     index = GetCurrHiliteID();
  346.     /* If Speed Dial is On Change The LSK to OFF */
  347.     if (CurrentSpeedType == 1)
  348.     {
  349.         ChangeLeftSoftkey(STR_GLOBAL_OFF, 0);
  350.     }
  351.     /* Else Chnage it to ON */
  352.     else
  353.     {
  354.         ChangeLeftSoftkey(STR_GLOBAL_ON, 0);
  355.     }
  356.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  357.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_UP);
  358.     SetLeftSoftkeyFunction(EntryPhbSpeedDialStatus, KEY_EVENT_UP);
  359.     SetKeyHandler(0, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  360.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  361.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  362. }
  363. /*****************************************************************************
  364.  * FUNCTION
  365.  *  EntryPhbSpeedDialStatus
  366.  * DESCRIPTION
  367.  *  This function is Entry function for Phonesetup-> SpeedDial -> Enable Speed Dial
  368.  *  Functionality: toggle on/off
  369.  * PARAMETERS
  370.  *  void
  371.  *  a(?)        [IN/OUT]        
  372.  *  b(?)        [IN]            
  373.  * RETURNS
  374.  *  void
  375.  *****************************************************************************/
  376. void EntryPhbSpeedDialStatus(void)
  377. {
  378.     /*----------------------------------------------------------------*/
  379.     /* Local Variables                                                */
  380.     /*----------------------------------------------------------------*/
  381.     U16 index;
  382.     /*----------------------------------------------------------------*/
  383.     /* Code Body                                                      */
  384.     /*----------------------------------------------------------------*/
  385.     index = GetCurrHiliteID();
  386.     /* If Speed Dial is On Then Turn It Off */
  387.     if (CurrentSpeedType == 1)
  388.     {
  389.         CurrentSpeedType = 0;
  390.     }
  391.     /* Else Turn it On */
  392.     else
  393.     {
  394.         CurrentSpeedType = 1;
  395.     }
  396.     /* Store the updated Value */
  397.     CurrentSpeedTypeChange = TRUE;
  398.     if (CurrentSpeedType)
  399.     {
  400.         pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_GLOBAL_ON));
  401.         Category52ChangeItemDescription(index, hintData[index]);
  402.         ChangeLeftSoftkey(STR_GLOBAL_OFF, 0);
  403.     }
  404.     else
  405.     {
  406.         pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_GLOBAL_OFF));
  407.         Category52ChangeItemDescription(index, hintData[index]);
  408.         ChangeLeftSoftkey(STR_GLOBAL_ON, 0);
  409.     }
  410.     /* Redraw the Category Screen with Modified Values */
  411.     RedrawCategoryFunction();
  412.     /* Highlite Speed Dial Status Option */
  413.     HighlightPhbSpeedDialStatus();
  414. }
  415. /*****************************************************************************
  416.  * FUNCTION
  417.  *  PhbInitSpeedDial
  418.  * DESCRIPTION
  419.  *  This function is to init highlight handler for speed dial
  420.  *  Functionality:HighlightPhbSpeedDialSetNum
  421.  * PARAMETERS
  422.  *  void
  423.  *  a(?)        [IN/OUT]        
  424.  *  b(?)        [IN]            
  425.  * RETURNS
  426.  *  void
  427.  *****************************************************************************/
  428. void PhbInitSpeedDial(void)
  429. {
  430.     /*----------------------------------------------------------------*/
  431.     /* Local Variables                                                */
  432.     /*----------------------------------------------------------------*/
  433.     /*----------------------------------------------------------------*/
  434.     /* Code Body                                                      */
  435.     /*----------------------------------------------------------------*/
  436.     SetHiliteHandler(MENU_SETTING_SPEED_DIAL, HighlightPhbSpeedDial);
  437.     SetHiliteHandler(MITEM113_PBOOK_SPEED_DIAL, HighlightPhbSpeedDialSetNum);
  438.     SetHiliteHandler(MENU_SETTING_SPEED_STATUS, HighlightPhbSpeedDialStatus);
  439.     SetHintHandler(MENU_SETTING_SPEED_DIAL, HintPhbSpeedDial);
  440.     SetHintHandler(MENU_SETTING_SPEED_STATUS, HintPhbSpeedDial);        /* SetHintHandler(MENU_SETTING_SPEED_STATUS,HintSpeedDialOn); */
  441.     SetHiliteHandler(MENU_ID_SPEED_DIAL_OP_EDIT, HighlightPhbSpeedDialSetNumOptionEdit);
  442.     SetHiliteHandler(MENU_ID_SPEED_DIAL_OP_DEL, HighlightPhbSpeedDialSetNumOptionDel);
  443. }
  444. /*****************************************************************************
  445.  * FUNCTION
  446.  *  HighlightPhbSpeedDialSetNum
  447.  * DESCRIPTION
  448.  *  This function is Highlight handler for Phonebook-> Speeddial
  449.  *  Follow functions: EntryPhbSpeedDial
  450.  * PARAMETERS
  451.  *  void
  452.  *  a(?)        [IN/OUT]        
  453.  *  b(?)        [IN]            
  454.  * RETURNS
  455.  *  void
  456.  *****************************************************************************/
  457. void HighlightPhbSpeedDialSetNum()
  458. {
  459.     /*----------------------------------------------------------------*/
  460.     /* Local Variables                                                */
  461.     /*----------------------------------------------------------------*/
  462.     /*----------------------------------------------------------------*/
  463.     /* Code Body                                                      */
  464.     /*----------------------------------------------------------------*/
  465.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  466.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  467.     SetLeftSoftkeyFunction(EntryPhbSpeedDialSetNum, KEY_EVENT_UP);
  468.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  469.     SetKeyHandler(EntryPhbSpeedDialSetNum, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  470.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  471. }
  472. /*****************************************************************************
  473.  * FUNCTION
  474.  *  EntryPhbSpeedDialSetNum
  475.  * DESCRIPTION
  476.  *  This function is Entry function for Phonesetup->IdleScreenDisplay
  477.  *  Following functions:
  478.  * PARAMETERS
  479.  *  void
  480.  *  a(?)        [IN/OUT]        
  481.  *  b(?)        [IN]            
  482.  * RETURNS
  483.  *  void
  484.  *****************************************************************************/
  485. void EntryPhbSpeedDialSetNum(void)
  486. {
  487.     /*----------------------------------------------------------------*/
  488.     /* Local Variables                                                */
  489.     /*----------------------------------------------------------------*/
  490.     U8 *guiBuffer, i;
  491.     U8 *speedKeyName[MAX_SPEED_DIAL_NUMBER];
  492.     /*----------------------------------------------------------------*/
  493.     /* Code Body                                                      */
  494.     /*----------------------------------------------------------------*/
  495.     /* U8 *speedKeyNumber[MAX_SPEED_DIAL_NUMBER]; */
  496. #ifdef __SYNCML_SUPPORT__
  497.     if (mmi_syncml_is_phb_sync_now())
  498.     {
  499.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  500.     }
  501.     else
  502. #endif /* __SYNCML_SUPPORT__ */
  503.     if (g_phb_cntx.phb_ready && !g_phb_cntx.processing)
  504.     {
  505.         EntryNewScreen(SCR_SPEED_DIAL_LIST, wgui_restore_list_menu_slim_style, EntryPhbSpeedDialSetNum, NULL);
  506.         for (i = 0; i < MAX_SPEED_DIAL_NUMBER; ++i)
  507.         {
  508.             if (pfnUnicodeStrlen((PS8) speedDialTable[i].name) || pfnUnicodeStrlen((PS8) speedDialTable[i].number))
  509.             {
  510.                 if (pfnUnicodeStrlen((PS8) speedDialTable[i].name))     /* An entry with name */
  511.                 {
  512.                     speedKeyName[i] = speedDialTable[i].name;
  513.                     if (pfnUnicodeStrlen((PS8) speedDialTable[i].number))
  514.                     {
  515.                         subMenuDataPtrs[i] = speedDialTable[i].number;
  516.                     }
  517.                     else
  518.                     {
  519.                         subMenuDataPtrs[i] = NULL;
  520.                     }
  521.                 }
  522.                 else    /* An entry with number only */
  523.                 {
  524.                     speedKeyName[i] = speedDialTable[i].number;
  525.                     subMenuDataPtrs[i] = NULL;
  526.                 }
  527.             }
  528.             else    /* Entry without name and number */
  529.             {
  530.                 speedKeyName[i] = (PU8) GetString(STR_GLOBAL_EMPTY_LIST);
  531.                 subMenuDataPtrs[i] = NULL;
  532.             }
  533.         }
  534.         wgui_override_list_menu_slim_style(WGUI_LIST_MENU_SLIM_STYLE_DRAW_ICON);
  535.         guiBuffer = GetCurrGuiBuffer(SCR_SPEED_DIAL_LIST);
  536.         RegisterHighlightHandler(PhbSpeedDailEntryHiliteHandler);
  537.         ShowCategory53Screen(
  538.             STR_SCR_SPEED_DIAL_LIST_CAPTION,
  539.             GetRootTitleIcon(MENU_SETTING_SPEED_DIAL) /* MAIN_MENU_TITLE_SETTINGS_ICON */ ,
  540.             STR_GLOBAL_OPTIONS,
  541.             IMG_GLOBAL_OPTIONS,
  542.             STR_GLOBAL_BACK,
  543.             IMG_GLOBAL_BACK,
  544.             MAX_SPEED_DIAL_NUMBER,
  545.             speedKeyName,
  546.             (U16*) (gIndexIconsImageList + 1),
  547.             subMenuDataPtrs,
  548.             0,
  549.             0,
  550.             guiBuffer);
  551.         SetKeyHandler(PhbMakeCallFromSpeedDial, KEY_SEND, KEY_EVENT_UP);
  552.         SetLeftSoftkeyFunction(EntryPhbSpeedDialSetNumOption, KEY_EVENT_UP);
  553.         SetKeyHandler(EntryPhbSpeedDialSetNumOption, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  554.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  555.         SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  556.     }
  557.     else
  558.     {
  559.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  560.     }
  561. }
  562. /* MTK 20041011 Wilson, Add operation menu for speed dial */
  563. /*****************************************************************************
  564.  * FUNCTION
  565.  *  HighlightPhbSpeedDialSetNumOptionEdit
  566.  * DESCRIPTION
  567.  *  This function is Highlight handler for Speeddial->Edit
  568.  *  Follow functions: EntryPhbSpeedDial
  569.  * PARAMETERS
  570.  *  void
  571.  *  a(?)        [IN/OUT]        
  572.  *  b(?)        [IN]            
  573.  * RETURNS
  574.  *  void
  575.  *****************************************************************************/
  576. void HighlightPhbSpeedDialSetNumOptionEdit(void)
  577. {
  578.     /*----------------------------------------------------------------*/
  579.     /* Local Variables                                                */
  580.     /*----------------------------------------------------------------*/
  581.     /*----------------------------------------------------------------*/
  582.     /* Code Body                                                      */
  583.     /*----------------------------------------------------------------*/
  584.     SetLeftSoftkeyFunction(mmi_phb_speed_dial_enter_phb, KEY_EVENT_UP);
  585.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  586.     SetKeyHandler(mmi_phb_speed_dial_enter_phb, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  587.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  588. }
  589. /*****************************************************************************
  590.  * FUNCTION
  591.  *  HighlightPhbSpeedDialSetNumOptionDel
  592.  * DESCRIPTION
  593.  *  This function is Highlight handler for Speeddial->Delete
  594.  *  Follow functions: EntryPhbSpeedDial
  595.  * PARAMETERS
  596.  *  void
  597.  *  a(?)        [IN/OUT]        
  598.  *  b(?)        [IN]            
  599.  * RETURNS
  600.  *  void
  601.  *****************************************************************************/
  602. void HighlightPhbSpeedDialSetNumOptionDel(void)
  603. {
  604.     /*----------------------------------------------------------------*/
  605.     /* Local Variables                                                */
  606.     /*----------------------------------------------------------------*/
  607.     /*----------------------------------------------------------------*/
  608.     /* Code Body                                                      */
  609.     /*----------------------------------------------------------------*/
  610.     SetLeftSoftkeyFunction(EntryPhbSpeedDialSetNumDelConfirm, KEY_EVENT_UP);
  611.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  612.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  613.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  614. }
  615. /*****************************************************************************
  616.  * FUNCTION
  617.  *  EntryPhbSpeedDialSetNumOption
  618.  * DESCRIPTION
  619.  *  This function is Entry function for Speed Dial Operation
  620.  *  Following functions:
  621.  * PARAMETERS
  622.  *  void
  623.  *  a(?)        [IN/OUT]        
  624.  *  b(?)        [IN]            
  625.  * RETURNS
  626.  *  void
  627.  *****************************************************************************/
  628. void EntryPhbSpeedDialSetNumOption(void)
  629. {
  630.     /*----------------------------------------------------------------*/
  631.     /* Local Variables                                                */
  632.     /*----------------------------------------------------------------*/
  633.     U8 *guiBuffer;
  634.     U16 nStrItemList[3];
  635.     U16 nNumofItem;
  636.     /*----------------------------------------------------------------*/
  637.     /* Code Body                                                      */
  638.     /*----------------------------------------------------------------*/
  639.     EntryNewScreen(SCR_ID_SPEED_DIAL_SET_NUM_OPTION, NULL, EntryPhbSpeedDialSetNumOption, NULL);
  640.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SPEED_DIAL_SET_NUM_OPTION);
  641.     nNumofItem = GetNumOfChild(MENU_ID_SPEED_DIAL_OPERATION);
  642.     GetSequenceStringIds(MENU_ID_SPEED_DIAL_OPERATION, nStrItemList);
  643.     SetParentHandler(MENU_ID_SPEED_DIAL_OPERATION);
  644.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  645.     /* Record Empty - Remove Delete Operation */
  646.     if (!pfnUnicodeStrlen((S8*) speedDialTable[currentKeyIndex].name) &&
  647.         !pfnUnicodeStrlen((S8*) speedDialTable[currentKeyIndex].number))
  648.     {
  649.         nNumofItem--;
  650.     }
  651.     ShowCategory15Screen(
  652.         STR_SCR_SPEED_DIAL_LIST_CAPTION,
  653.         GetRootTitleIcon(MENU_SETTING_SPEED_DIAL),
  654.         STR_GLOBAL_OK,
  655.         IMG_GLOBAL_OK,
  656.         STR_GLOBAL_BACK,
  657.         IMG_GLOBAL_BACK,
  658.         nNumofItem,
  659.         nStrItemList,
  660.         (U16*) gIndexIconsImageList,
  661.         LIST_MENU,
  662.         0,
  663.         guiBuffer);
  664. }
  665. /*****************************************************************************
  666.  * FUNCTION
  667.  *  EntryPhbSpeedDialSetNumDelConfirm
  668.  * DESCRIPTION
  669.  *  Delete confirmation screen.
  670.  * PARAMETERS
  671.  *  void
  672.  *  a(?)        [IN/OUT]        
  673.  *  b(?)        [IN]            
  674.  * RETURNS
  675.  *  void
  676.  *****************************************************************************/
  677. void EntryPhbSpeedDialSetNumDelConfirm(void)
  678. {
  679.     /*----------------------------------------------------------------*/
  680.     /* Local Variables                                                */
  681.     /*----------------------------------------------------------------*/
  682.     /*----------------------------------------------------------------*/
  683.     /* Code Body                                                      */
  684.     /*----------------------------------------------------------------*/
  685.     DisplayConfirm(
  686.         STR_GLOBAL_YES,
  687.         IMG_GLOBAL_YES,
  688.         STR_GLOBAL_NO,
  689.         IMG_GLOBAL_NO,
  690.         get_string(STR_GLOBAL_DELETE),
  691.         IMG_GLOBAL_QUESTION,
  692.         WARNING_TONE);
  693.     SetLeftSoftkeyFunction(PhbDelSpeedDialFromList, KEY_EVENT_UP);
  694.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  695. }
  696. /* END MTK 20041011 Wilson */
  697. /*****************************************************************************
  698.  * FUNCTION
  699.  *  PhbGetSpeedDialInfo
  700.  * DESCRIPTION
  701.  *  Start a timer to read speeddial from NVRAM after enter idle screen.
  702.  *  (Avoid timeout callback to read NVRAM before enter idle screen.)
  703.  * PARAMETERS
  704.  *  void
  705.  *  a(?)        [IN/OUT]        
  706.  *  b(?)        [IN]            
  707.  * RETURNS
  708.  *  void
  709.  *****************************************************************************/
  710. void PhbGetSpeedDialInfo(void)
  711. {
  712.     /*----------------------------------------------------------------*/
  713.     /* Local Variables                                                */
  714.     /*----------------------------------------------------------------*/
  715.     extern U8 gInsertSimAppFlag;
  716.     /*----------------------------------------------------------------*/
  717.     /* Code Body                                                      */
  718.     /*----------------------------------------------------------------*/
  719.     StopTimer(PHB_READ_SPEED_DIAL_TIMER);
  720.     if (gInsertSimAppFlag == 1)
  721.     {
  722.         g_phb_cntx.phb_ready = TRUE;
  723.         mmi_phb_init_build_lookup_table();
  724.         return;
  725.     }
  726.     if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  727.     {
  728.         /* Start a timer to avoid extensive NVRAM access which may cause MMI hang shortly */
  729.         StartTimer(PHB_READ_SPEED_DIAL_TIMER, 500, PhbGetSpeedDialInfo_Ext);
  730.     }
  731.     else
  732.     {
  733.         /* Retry again until enter idle screen. */
  734.         StartTimer(PHB_READ_SPEED_DIAL_TIMER, 500, PhbGetSpeedDialInfo);
  735.     }
  736. }
  737. /*****************************************************************************
  738.  * FUNCTION
  739.  *  PhbGetSpeedDialInfo_Ext
  740.  * DESCRIPTION
  741.  *  This function is to get the first non-empty speed dial entry and send query to L4
  742.  *  Functionality:
  743.  * PARAMETERS
  744.  *  void
  745.  *  a(?)        [IN/OUT]        
  746.  *  b(?)        [IN]            
  747.  * RETURNS
  748.  *  void
  749.  *****************************************************************************/
  750. void PhbGetSpeedDialInfo_Ext(void)
  751. {
  752.     /*----------------------------------------------------------------*/
  753.     /* Local Variables                                                */
  754.     /*----------------------------------------------------------------*/
  755.     /*----------------------------------------------------------------*/
  756.     /* Code Body                                                      */
  757.     /*----------------------------------------------------------------*/
  758.     /* S16 error; */
  759.     PhbReadSpeedDialNVRAM();
  760.     for (speedKeyIndex = 0; speedKeyIndex < MAX_SPEED_DIAL_NUMBER; speedKeyIndex++)
  761.     {
  762.         if (speedDialTable[speedKeyIndex].record_index != 0)
  763.         {
  764.             U16 store_index;
  765.             if (speedDialTable[speedKeyIndex].storage == MMI_SIM)
  766.             {
  767.                 store_index = speedDialTable[speedKeyIndex].record_index + MAX_PB_PHONE_ENTRIES - 1;
  768.             }
  769.             else
  770.             {
  771.                 store_index = speedDialTable[speedKeyIndex].record_index - 1;
  772.             }
  773.             PhbSetSpeedDialPhbIndex(store_index);
  774.         }
  775.     }
  776.     g_phb_cntx.phb_ready = TRUE;
  777.     mmi_phb_init_build_lookup_table();
  778. }
  779. /*****************************************************************************
  780.  * FUNCTION
  781.  *  PhbGetSpeedDialPhbIndexReq
  782.  * DESCRIPTION
  783.  *  Gets the Phonebook entry from L4 based on index,
  784.  *  storage & type
  785.  *  
  786.  *  Used by speed dial
  787.  * PARAMETERS
  788.  *  storage     [IN]        
  789.  *  rIndex      [IN]        
  790.  *  type        [IN]        
  791.  * RETURNS
  792.  *  void
  793.  *****************************************************************************/
  794. void PhbGetSpeedDialPhbIndexReq(U8 storage, U16 rIndex, U8 type)
  795. {
  796. #if defined(MMI_ON_WIN32)
  797.     /*----------------------------------------------------------------*/
  798.     /* Local Variables                                                */
  799.     /*----------------------------------------------------------------*/
  800.     /*----------------------------------------------------------------*/
  801.     /* Code Body                                                      */
  802.     /*----------------------------------------------------------------*/
  803.     PhbSetSpeedDialPhbIndex(0xffff);
  804. #else /* defined(MMI_ON_WIN32) */ 
  805.     /* If FDN in On, Don't Query Sim Entry */
  806.     if (gSecuritySetupContext.FdlStatus && (storage == MMI_SIM))
  807.     {
  808.         PhbSetSpeedDialPhbIndex(0xffff);
  809.     }
  810.     else
  811.     {
  812.         MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT *myMsgPtr;
  813.         MYQUEUE Message;
  814.         PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<PhbGetSpeedDialPhbIndexReq.>n", __FILE__,
  815.                              __LINE__));
  816.         myMsgPtr =
  817.             (MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT*)
  818.             OslConstructDataPtr(sizeof(MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT));
  819.         myMsgPtr->index = 0xFFFF;
  820.         myMsgPtr->record_index = rIndex;
  821.         myMsgPtr->storage = storage;
  822.         myMsgPtr->type = MMI_PHB_PHONEBOOK;
  823.         myMsgPtr->no_data = 1;
  824.         Message.oslSrcId = MOD_MMI;
  825.         Message.oslDestId = MOD_L4C;
  826.         Message.oslMsgId = PRT_PHB_GET_ENTRY_BY_INDEX_REQ;
  827.         Message.oslDataPtr = (oslParaType*) myMsgPtr;
  828.         Message.oslPeerBuffPtr = NULL;
  829.         SetProtocolEventHandler(PhbGetSpeedDialPhbIndexRsp, PRT_PHB_GET_ENTRY_BY_INDEX_RSP);
  830.         OslMsgSendExtQueue(&Message);
  831.     }
  832. #endif /* defined(MMI_ON_WIN32) */ 
  833. }
  834. /*****************************************************************************
  835.  * FUNCTION
  836.  *  PhbGetSpeedDialPhbIndexRsp
  837.  * DESCRIPTION
  838.  *  Response handler for PhbGetSpeedDialPhbIndexReq()
  839.  * PARAMETERS
  840.  *  info        [?]     
  841.  * RETURNS
  842.  *  void
  843.  *****************************************************************************/
  844. void PhbGetSpeedDialPhbIndexRsp(void *info)
  845. {
  846.     /*----------------------------------------------------------------*/
  847.     /* Local Variables                                                */
  848.     /*----------------------------------------------------------------*/
  849.     MSG_PHB_GET_ENTRY_BY_INDEX_RSP_STRUCT *localPtr;
  850.     U16 store_index;
  851.     /*----------------------------------------------------------------*/
  852.     /* Code Body                                                      */
  853.     /*----------------------------------------------------------------*/
  854.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<PhbGetSpeedDialPhbIndexRsp.>n", __FILE__,
  855.                          __LINE__));
  856.     localPtr = (MSG_PHB_GET_ENTRY_BY_INDEX_RSP_STRUCT*) info;
  857.     if (localPtr->result.flag == 0 /* OK */ )
  858.     {
  859.         if (localPtr->no_list)
  860.         {
  861.             if (localPtr->list[0].storage == MMI_SIM)
  862.             {
  863.                 store_index = localPtr->list[0].record_index + MAX_PB_PHONE_ENTRIES - 1;
  864.             }
  865.             else
  866.             {
  867.                 store_index = localPtr->list[0].record_index - 1;
  868.             }
  869.             PhbSetSpeedDialPhbIndex(store_index);
  870.         }
  871.         else
  872.         {
  873.             PhbSetSpeedDialPhbIndex(0xffff);
  874.         }
  875.     }
  876.     else
  877.     {
  878.         PhbSetSpeedDialPhbIndex(0xffff);
  879.     }
  880. }
  881. /*****************************************************************************
  882.  * FUNCTION
  883.  *  PhbSetSpeedDialPhbIndex
  884.  * DESCRIPTION
  885.  *  This function is to continue get speed dial entry and send query to L4
  886.  *  Functionality:
  887.  * PARAMETERS
  888.  *  store_index     [IN]            
  889.  * RETURNS
  890.  *  void
  891.  *****************************************************************************/
  892. void PhbSetSpeedDialPhbIndex(U16 store_index)
  893. {
  894.     /*----------------------------------------------------------------*/
  895.     /* Local Variables                                                */
  896.     /*----------------------------------------------------------------*/
  897.     /*----------------------------------------------------------------*/
  898.     /* Code Body                                                      */
  899.     /*----------------------------------------------------------------*/
  900.     if (store_index != 0xffff)
  901.     {
  902.         U16 pos;
  903.         for (pos = 0; pos < PhoneBookEntryCount; pos++)
  904.         {
  905.             if (g_phb_name_index[pos] == store_index)
  906.             {
  907.                 pfnUnicodeStrcpy((PS8) speedDialTable[speedKeyIndex].name, (PS8) PhoneBook[store_index].alpha_id.name);
  908.                 mmi_phb_convert_get_ucs2_number((S8*) speedDialTable[speedKeyIndex].number, store_index);
  909.                 break;
  910.             }
  911.         }
  912.     }
  913.     else if (!(gSecuritySetupContext.FdlStatus && (speedDialTable[speedKeyIndex].storage == MMI_SIM)))
  914.     {
  915.         memset(speedDialTable[speedKeyIndex].name, 0, ENCODING_LENGTH);
  916.         memset(speedDialTable[speedKeyIndex].number, 0, ENCODING_LENGTH);
  917.     }
  918. #if 0
  919. /* under construction !*/
  920. /* under construction !*/
  921. /* under construction !*/
  922. /* under construction !*/
  923. /* under construction !*/
  924. /* under construction !*/
  925. /* under construction !*/
  926. /* under construction !*/
  927. /* under construction !*/
  928. /* under construction !*/
  929. /* under construction !*/
  930. /* under construction !*/
  931. /* under construction !*/
  932. /* under construction !*/
  933. /* under construction !*/
  934. /* under construction !*/
  935. /* under construction !*/
  936. #endif /* 0 */ 
  937. }
  938. /*****************************************************************************
  939.  * FUNCTION
  940.  *  PhbReadSpeedDialNVRAM
  941.  * DESCRIPTION
  942.  *  This function is to read speed dial record from nvram
  943.  *  Functionality:
  944.  * PARAMETERS
  945.  *  void
  946.  *  a(?)        [IN/OUT]        
  947.  *  b(?)        [IN]            
  948.  * RETURNS
  949.  *  void
  950.  *****************************************************************************/
  951. void PhbReadSpeedDialNVRAM(void)
  952. {
  953.     /*----------------------------------------------------------------*/
  954.     /* Local Variables                                                */
  955.     /*----------------------------------------------------------------*/
  956.     S16 error;
  957. #if 0
  958. /* under construction !*/
  959. /* under construction !*/
  960. /* under construction !*/
  961. /* under construction !*/
  962. /* under construction !*/
  963. #else /* 0 */ 
  964.     /*----------------------------------------------------------------*/
  965.     /* Code Body                                                      */
  966.     /*----------------------------------------------------------------*/
  967.     ReadRecord(NVRAM_EF_PHONEBOOK_SPEEDDIAL_LID, 1, speedDialTable, NVRAM_SPEEDDIAL_RECORD_SIZE, &error);
  968. #endif /* 0 */ 
  969. }
  970. /*****************************************************************************
  971.  * FUNCTION
  972.  *  PhbSetSpeedDialFormList
  973.  * DESCRIPTION
  974.  *  This function is to set speed dial entry form phone book list
  975.  *  Functionality:
  976.  * PARAMETERS
  977.  *  void
  978.  *  a(?)        [IN/OUT]        
  979.  *  b(?)        [IN]            
  980.  * RETURNS
  981.  *  void
  982.  *****************************************************************************/
  983. void PhbSetSpeedDialFormList(void)
  984. {
  985.     /*----------------------------------------------------------------*/
  986.     /* Local Variables                                                */
  987.     /*----------------------------------------------------------------*/
  988.     S16 error;
  989.     U8 tempNumber[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
  990.     U16 store_index;
  991.     U8 storage;
  992.     U16 record_index;
  993.     /*----------------------------------------------------------------*/
  994.     /* Code Body                                                      */
  995.     /*----------------------------------------------------------------*/
  996.     store_index = g_phb_name_index[g_phb_cntx.active_index_second];
  997.     if (!(PhoneBook[store_index].field & MMI_PHB_ENTRY_FIELD_NUMBER))
  998.     {
  999.         DisplayPopup(
  1000.             (PU8) GetString(STR_SPEEDDIAL_NO_NUM_TODIAL_TEXT),
  1001.             IMG_GLOBAL_ERROR,
  1002.             1,
  1003.             ST_NOTIFYDURATION,
  1004.             ERROR_TONE);
  1005.         return;
  1006.     }
  1007.     if (store_index < MAX_PB_PHONE_ENTRIES)
  1008.     {
  1009.         storage = MMI_NVRAM;
  1010.         record_index = store_index + 1;
  1011.     }
  1012.     else
  1013.     {
  1014.         storage = MMI_SIM;
  1015.         record_index = store_index - MAX_PB_PHONE_ENTRIES + 1;
  1016.     }
  1017.     /* Do not update if record is same */
  1018.     if ((speedDialTable[currentKeyIndex].storage == storage) &&
  1019.         (speedDialTable[currentKeyIndex].type == MMI_PHB_PHONEBOOK) &&
  1020.         (speedDialTable[currentKeyIndex].record_index == record_index) &&
  1021.         (pfnUnicodeStrcmp((PS8) speedDialTable[currentKeyIndex].name, (PS8) PhoneBook[store_index].alpha_id.name) == 0))
  1022.     {
  1023.         mmi_phb_convert_get_ucs2_number((S8*) tempNumber, store_index);
  1024.         if (pfnUnicodeStrcmp((PS8) speedDialTable[currentKeyIndex].number, (PS8) tempNumber) == 0)
  1025.         {
  1026.             GoBackHistory();
  1027.             return;
  1028.         }
  1029.     }
  1030.     speedDialTable[currentKeyIndex].storage = storage;
  1031.     speedDialTable[currentKeyIndex].type = MMI_PHB_PHONEBOOK;
  1032.     speedDialTable[currentKeyIndex].record_index = record_index;
  1033.     pfnUnicodeStrcpy((PS8) speedDialTable[currentKeyIndex].name, (PS8) PhoneBook[store_index].alpha_id.name);
  1034.     mmi_phb_convert_get_ucs2_number((S8*) speedDialTable[currentKeyIndex].number, store_index);
  1035.     WriteRecord(NVRAM_EF_PHONEBOOK_SPEEDDIAL_LID, 1, speedDialTable, NVRAM_SPEEDDIAL_RECORD_SIZE, &error);
  1036.     DisplayPopup(
  1037.         (U8*) GetString(STR_GLOBAL_DONE),
  1038.         IMG_GLOBAL_ACTIVATED,
  1039.         TRUE,
  1040.         UI_POPUP_NOTIFYDURATION_TIME,
  1041.         SUCCESS_TONE);
  1042.     DeleteUptoScrID(SCR_SPEED_DIAL_LIST);
  1043. }
  1044. /* Robin 0327: */
  1045. /* MTK 20041011 Wilson, Add operation menu for speed dial */
  1046. /*****************************************************************************
  1047.  * FUNCTION
  1048.  *  PhbDelSpeedDialFromList
  1049.  * DESCRIPTION
  1050.  *  This function is to remove speed dial entry
  1051.  *  Functionality:
  1052.  * PARAMETERS
  1053.  *  void
  1054.  *  a(?)        [IN/OUT]        
  1055.  *  b(?)        [IN]            
  1056.  * RETURNS
  1057.  *  void
  1058.  *****************************************************************************/
  1059. void PhbDelSpeedDialFromList(void)
  1060. {
  1061.     /*----------------------------------------------------------------*/
  1062.     /* Local Variables                                                */
  1063.     /*----------------------------------------------------------------*/
  1064.     S16 error;
  1065.     /*----------------------------------------------------------------*/
  1066.     /* Code Body                                                      */
  1067.     /*----------------------------------------------------------------*/
  1068.     memset(&speedDialTable[currentKeyIndex], 0, sizeof(SpeedDialInfo));
  1069.     WriteRecord(NVRAM_EF_PHONEBOOK_SPEEDDIAL_LID, 1, speedDialTable, NVRAM_SPEEDDIAL_RECORD_SIZE, &error);
  1070.     DisplayPopup(
  1071.         (U8*) GetString(STR_GLOBAL_DONE),
  1072.         IMG_GLOBAL_ACTIVATED,
  1073.         TRUE,
  1074.         UI_POPUP_NOTIFYDURATION_TIME,
  1075.         SUCCESS_TONE);
  1076.     DeleteUptoScrID(SCR_SPEED_DIAL_LIST);
  1077. }
  1078. /* END MTK 20041011 Wilson */
  1079. /*****************************************************************************
  1080.  * FUNCTION
  1081.  *  PhbSpeedDailEntryHiliteHandler
  1082.  * DESCRIPTION
  1083.  *  This function is Highlight handler for Phonebook->SpeedDial->Set Number
  1084.  *  Follow functions: EntryPhnsetMainMenuStyle
  1085.  * PARAMETERS
  1086.  *  index       [IN]            
  1087.  *  a(?)        [IN/OUT]        
  1088.  *  b(?)        [IN]            
  1089.  * RETURNS
  1090.  *  void
  1091.  *****************************************************************************/
  1092. void PhbSpeedDailEntryHiliteHandler(S32 index)
  1093. {
  1094.     /*----------------------------------------------------------------*/
  1095.     /* Local Variables                                                */
  1096.     /*----------------------------------------------------------------*/
  1097.     /*----------------------------------------------------------------*/
  1098.     /* Code Body                                                      */
  1099.     /*----------------------------------------------------------------*/
  1100.     currentKeyIndex = (S16) index;
  1101. }
  1102. /*****************************************************************************
  1103.  * FUNCTION
  1104.  *  PhbMakeCallFromSpeedDial
  1105.  * DESCRIPTION
  1106.  *  This function is to make phone call by pressing SEND key from speed dial screen
  1107.  *  Functionality:
  1108.  * PARAMETERS
  1109.  *  void
  1110.  *  a(?)        [IN/OUT]        
  1111.  *  b(?)        [IN]            
  1112.  * RETURNS
  1113.  *  void
  1114.  *****************************************************************************/
  1115. void PhbMakeCallFromSpeedDial(void)
  1116. {
  1117.     /*----------------------------------------------------------------*/
  1118.     /* Local Variables                                                */
  1119.     /*----------------------------------------------------------------*/
  1120.     /*----------------------------------------------------------------*/
  1121.     /* Code Body                                                      */
  1122.     /*----------------------------------------------------------------*/
  1123.     if (!speedDialTable[currentKeyIndex].record_index)
  1124.     {
  1125.         DisplayPopup(
  1126.             (PU8) GetString(STR_SPEEDDIAL_NO_NUM_TODIAL_TEXT),
  1127.             IMG_GLOBAL_ERROR,
  1128.             1,
  1129.             ST_NOTIFYDURATION,
  1130.             ERROR_TONE);
  1131.     }
  1132.     else
  1133.     {
  1134.         if (!pfnUnicodeStrlen((PS8) speedDialTable[currentKeyIndex].number))
  1135.         {
  1136.             DisplayPopup(
  1137.                 (PU8) GetString(STR_SPEEDDIAL_NO_NUM_TODIAL_TEXT),
  1138.                 IMG_GLOBAL_ERROR,
  1139.                 1,
  1140.                 ST_NOTIFYDURATION,
  1141.                 ERROR_TONE);
  1142.         }
  1143.         else
  1144.         {
  1145.             /* micha0420 */
  1146.             if (gSecuritySetupContext.FdlStatus && (speedDialTable[currentKeyIndex].storage == MMI_SIM))
  1147.             {
  1148.                 DisplayPopup(
  1149.                     (PU8) GetString(STR_GLOBAL_NOT_DONE),
  1150.                     IMG_GLOBAL_UNFINISHED,
  1151.                     1,
  1152.                     ST_NOTIFYDURATION,
  1153.                     ERROR_TONE);
  1154.             }
  1155.             else
  1156.             {
  1157.                 PhbSpeedDialLookupNumberFromList(currentKeyIndex);
  1158.                 MakeCall((PS8) speedDialTable[currentKeyIndex].number);
  1159.             }
  1160.         }
  1161.     }
  1162. }
  1163. /*****************************************************************************
  1164.  * FUNCTION
  1165.  *  PhbGetSpeedDialNum
  1166.  * DESCRIPTION
  1167.  *  This function is to get speed dail number by keyID (2~9) when LP digit number from idle screen
  1168.  *  Functionality:
  1169.  * PARAMETERS
  1170.  *  keyId       [IN]            
  1171.  *  a(?)        [IN/OUT]        
  1172.  *  b(?)        [IN]            
  1173.  * RETURNS
  1174.  *  void
  1175.  *****************************************************************************/
  1176. PS8 PhbGetSpeedDialNum(U16 keyId)
  1177. {
  1178.     /*----------------------------------------------------------------*/
  1179.     /* Local Variables                                                */
  1180.     /*----------------------------------------------------------------*/
  1181.     PS8 number;
  1182.     /*----------------------------------------------------------------*/
  1183.     /* Code Body                                                      */
  1184.     /*----------------------------------------------------------------*/
  1185.     if (keyId < 2)
  1186.     {
  1187.         return NULL;
  1188.     }
  1189.     if (pfnUnicodeStrlen((PS8) speedDialTable[keyId - 2].number))
  1190.     {
  1191.         PhbSpeedDialLookupNumberFromList((U16) (keyId - 2));
  1192.         number = (PS8) speedDialTable[keyId - 2].number;
  1193.         return number;
  1194.     }
  1195.     else
  1196.     {
  1197.         return NULL;
  1198.     }
  1199. }
  1200. /*****************************************************************************
  1201.  * FUNCTION
  1202.  *  PhbUpdateSpeedDial
  1203.  * DESCRIPTION
  1204.  *  This function is an update function to modify certain speed dial entry when user change from phone book
  1205.  *  Functionality:
  1206.  * PARAMETERS
  1207.  *  storage             [IN]            
  1208.  *  record_index        [IN]            
  1209.  *  type                [IN]            
  1210.  *  name                [?]             
  1211.  *  number              [?]             
  1212.  *  a(?)                [IN/OUT]        
  1213.  *  b(?)                [IN]            
  1214.  * RETURNS
  1215.  *  void
  1216.  *****************************************************************************/
  1217. void PhbUpdateSpeedDial(U8 storage, U16 record_index, U8 type, U8 *name, U8 *number)
  1218. {
  1219.     /*----------------------------------------------------------------*/
  1220.     /* Local Variables                                                */
  1221.     /*----------------------------------------------------------------*/
  1222.     S16 error;
  1223.     U8 i, flag = 0;
  1224.     /*----------------------------------------------------------------*/
  1225.     /* Code Body                                                      */
  1226.     /*----------------------------------------------------------------*/
  1227.     for (i = 0; i < MAX_SPEED_DIAL_NUMBER; ++i)
  1228.     {
  1229.         if ((speedDialTable[i].storage == storage) && (speedDialTable[i].record_index == record_index))
  1230.         {
  1231.             if (name == NULL && number == NULL)
  1232.             {
  1233.                 speedDialTable[i].storage = 0;
  1234.                 speedDialTable[i].type = 0;
  1235.                 speedDialTable[i].record_index = 0;
  1236.                 memset(speedDialTable[i].name, 0, ENCODING_LENGTH);
  1237.                 memset(speedDialTable[i].number, 0, ENCODING_LENGTH);
  1238.             }
  1239.             else
  1240.             {
  1241.                 pfnUnicodeStrcpy((PS8) speedDialTable[i].name, (PS8) name);
  1242.                 pfnUnicodeStrcpy((PS8) speedDialTable[i].number, (PS8) number);
  1243.             }
  1244.             flag = 1;
  1245.         }
  1246.     }
  1247.     if (flag)
  1248.     {
  1249.         WriteRecord(NVRAM_EF_PHONEBOOK_SPEEDDIAL_LID, 1, speedDialTable, NVRAM_SPEEDDIAL_RECORD_SIZE, &error);
  1250.     }
  1251. }
  1252. /*****************************************************************************
  1253.  * FUNCTION
  1254.  *  PhbDeleteAllSpeedDial
  1255.  * DESCRIPTION
  1256.  *  This function is an update function to delete all speed dial entry when delete all entry from phone book
  1257.  *  Functionality:
  1258.  * PARAMETERS
  1259.  *  storage     [IN]            
  1260.  *  type        [IN]            
  1261.  *  a(?)        [IN/OUT]        
  1262.  *  b(?)        [IN]            
  1263.  * RETURNS
  1264.  *  void
  1265.  *****************************************************************************/
  1266. void PhbDeleteAllSpeedDial(U8 storage, U8 type)
  1267. {
  1268.     /*----------------------------------------------------------------*/
  1269.     /* Local Variables                                                */
  1270.     /*----------------------------------------------------------------*/
  1271.     U8 i, flag = 0;
  1272.     S16 error;
  1273.     /*----------------------------------------------------------------*/
  1274.     /* Code Body                                                      */
  1275.     /*----------------------------------------------------------------*/
  1276.     for (i = 0; i < MAX_SPEED_DIAL_NUMBER; ++i)
  1277.     {
  1278.         if (speedDialTable[i].storage == storage)
  1279.         {
  1280.             memset(&speedDialTable[i], 0, sizeof(speedDialTable[i]));
  1281.             flag = 1;
  1282.         }
  1283.     }
  1284.     if (flag)
  1285.     {
  1286.         WriteRecord(NVRAM_EF_PHONEBOOK_SPEEDDIAL_LID, 1, speedDialTable, NVRAM_SPEEDDIAL_RECORD_SIZE, &error);
  1287.     }
  1288. }
  1289. /*****************************************************************************
  1290.  * FUNCTION
  1291.  *  PhbRestoreSpeedDial
  1292.  * DESCRIPTION
  1293.  *  This function is to restore speed dail to default value (all empty)
  1294.  *  Functionality:
  1295.  * PARAMETERS
  1296.  *  void
  1297.  *  a(?)        [IN/OUT]        
  1298.  *  b(?)        [IN]            
  1299.  * RETURNS
  1300.  *  void
  1301.  *****************************************************************************/
  1302. MMI_BOOL PhbRestoreSpeedDial(void)
  1303. {
  1304.     /*----------------------------------------------------------------*/
  1305.     /* Local Variables                                                */
  1306.     /*----------------------------------------------------------------*/
  1307.     S16 error;
  1308.     /*----------------------------------------------------------------*/
  1309.     /* Code Body                                                      */
  1310.     /*----------------------------------------------------------------*/
  1311.     memset(speedDialTable, 0, NVRAM_SPEEDDIAL_RECORD_SIZE);
  1312.     WriteRecord(NVRAM_EF_PHONEBOOK_SPEEDDIAL_LID, 1, speedDialTable, NVRAM_SPEEDDIAL_RECORD_SIZE, &error);
  1313.     return MMI_TRUE;
  1314. }
  1315. /*****************************************************************************
  1316.  * FUNCTION
  1317.  *  PhbGetSpeedDialStatus
  1318.  * DESCRIPTION
  1319.  *  This function is to get speed dial on/off status
  1320.  *  Functionality:
  1321.  * PARAMETERS
  1322.  *  void
  1323.  *  a(?)        [IN/OUT]        
  1324.  *  b(?)        [IN]            
  1325.  * RETURNS
  1326.  *  void
  1327.  *****************************************************************************/
  1328. MMI_BOOL PhbGetSpeedDialStatus(void)
  1329. {
  1330.     /*----------------------------------------------------------------*/
  1331.     /* Local Variables                                                */
  1332.     /*----------------------------------------------------------------*/
  1333.     U8 data = 0;
  1334.     S16 error;
  1335.     /*----------------------------------------------------------------*/
  1336.     /* Code Body                                                      */
  1337.     /*----------------------------------------------------------------*/
  1338.     ReadValue(NVRAM_SETTING_SPEED_DIAL, &data, DS_BYTE, &error);
  1339.     if (data == 1)
  1340.     {
  1341.         CurrentSpeedType = 1;
  1342.         return MMI_TRUE;
  1343.     }
  1344.     else
  1345.     {
  1346.         CurrentSpeedType = 0;
  1347.         return MMI_FALSE;
  1348.     }
  1349. }
  1350. /*****************************************************************************
  1351.  * FUNCTION
  1352.  *  PhbSpeedDialLookupNumberFromList
  1353.  * DESCRIPTION
  1354.  *  Check if the entry exist in phonebook list, if Yes, dial out from list, do not lookup number again
  1355.  * PARAMETERS
  1356.  *  speed_index     [IN]        speed dial entry index
  1357.  * RETURNS
  1358.  *  void
  1359.  *****************************************************************************/
  1360. void PhbSpeedDialLookupNumberFromList(U16 speed_index)
  1361. {
  1362.     /*----------------------------------------------------------------*/
  1363.     /* Local Variables                                                */
  1364.     /*----------------------------------------------------------------*/
  1365.     U16 i;
  1366.     U16 store_index;
  1367.     /*----------------------------------------------------------------*/
  1368.     /* Code Body                                                      */
  1369.     /*----------------------------------------------------------------*/
  1370.     /*
  1371.      * Check if the entry exist in phonebook list, if Yes, dial out from list, do not lookup number again
  1372.      */
  1373.     if (speedDialTable[speed_index].storage == MMI_SIM)
  1374.     {
  1375.         store_index = speedDialTable[speed_index].record_index + MAX_PB_PHONE_ENTRIES - 1;
  1376.     }
  1377.     else
  1378.     {
  1379.         store_index = speedDialTable[speed_index].record_index - 1;
  1380.     }
  1381.     for (i = 0; i < PhoneBookEntryCount; i++)
  1382.         if (g_phb_name_index[i] == store_index)
  1383.         {
  1384.             g_phb_cntx.dial_from_list = MMI_PHB_PHONEBOOK;
  1385.             g_phb_cntx.active_index = i;
  1386.             break;
  1387.         }
  1388. }
  1389. #endif /* _SPEEDDIAL_C */