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

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.  * PhoneBookStubsToOthers.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   PhoneBook APIs for other applications
  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.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * removed!
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * removed!
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * removed!
  150.  *
  151.  * removed!
  152.  * removed!
  153.  * removed!
  154.  *
  155.  * removed!
  156.  * removed!
  157.  * removed!
  158.  *
  159.  * removed!
  160.  * removed!
  161.  * removed!
  162.  *
  163.  * removed!
  164.  * removed!
  165.  * removed!
  166.  *
  167.  * removed!
  168.  * removed!
  169.  * removed!
  170.  *
  171.  * removed!
  172.  * removed!
  173.  * removed!
  174.  *
  175.  * removed!
  176.  * removed!
  177.  * removed!
  178.  *
  179.  * removed!
  180.  * removed!
  181.  * removed!
  182.  *
  183.  * removed!
  184.  * removed!
  185.  * removed!
  186.  *
  187.  * removed!
  188.  * removed!
  189.  * removed!
  190.  *
  191.  * removed!
  192.  * removed!
  193.  * removed!
  194.  *
  195.  * removed!
  196.  * removed!
  197.  * removed!
  198.  *
  199.  * removed!
  200.  * removed!
  201.  * removed!
  202.  *
  203.  * removed!
  204.  * removed!
  205.  * removed!
  206.  *
  207.  * removed!
  208.  * removed!
  209.  * removed!
  210.  *
  211.  * removed!
  212.  * removed!
  213.  * removed!
  214.  *
  215.  * removed!
  216.  * removed!
  217.  * removed!
  218.  *
  219.  * removed!
  220.  * removed!
  221.  * removed!
  222.  *
  223.  * removed!
  224.  * removed!
  225.  * removed!
  226.  *
  227.  * removed!
  228.  * removed!
  229.  * removed!
  230.  *
  231.  * removed!
  232.  * removed!
  233.  * removed!
  234.  *
  235.  * removed!
  236.  * removed!
  237.  * removed!
  238.  *
  239.  * removed!
  240.  * removed!
  241.  * removed!
  242.  *
  243.  * removed!
  244.  * removed!
  245.  * removed!
  246.  *
  247.  * removed!
  248.  * removed!
  249.  * removed!
  250.  *
  251.  * removed!
  252.  * removed!
  253.  * removed!
  254.  *
  255.  * removed!
  256.  * removed!
  257.  * removed!
  258.  *
  259.  * removed!
  260.  * removed!
  261.  * removed!
  262.  *
  263.  * removed!
  264.  * removed!
  265.  * removed!
  266.  *
  267.  * removed!
  268.  * removed!
  269.  * removed!
  270.  *
  271.  * removed!
  272.  * removed!
  273.  * removed!
  274.  *
  275.  * removed!
  276.  * removed!
  277.  * removed!
  278.  *
  279.  * removed!
  280.  * removed!
  281.  * removed!
  282.  *
  283.  * removed!
  284.  * removed!
  285.  * removed!
  286.  *
  287.  * removed!
  288.  * removed!
  289.  * removed!
  290.  *
  291.  * removed!
  292.  * removed!
  293.  * removed!
  294.  *
  295.  * removed!
  296.  * removed!
  297.  * removed!
  298.  *
  299.  * removed!
  300.  * removed!
  301.  * removed!
  302.  *
  303.  * removed!
  304.  * removed!
  305.  * removed!
  306.  *
  307.  * removed!
  308.  * removed!
  309.  * removed!
  310.  *
  311.  * removed!
  312.  * removed!
  313.  * removed!
  314.  *
  315.  * removed!
  316.  * removed!
  317.  * removed!
  318.  *
  319.  * removed!
  320.  * removed!
  321.  * removed!
  322.  *
  323.  * removed!
  324.  * removed!
  325.  * removed!
  326.  *
  327.  * removed!
  328.  * removed!
  329.  * removed!
  330.  *
  331.  * removed!
  332.  * removed!
  333.  * removed!
  334.  *
  335.  * removed!
  336.  * removed!
  337.  * removed!
  338.  *
  339.  * removed!
  340.  * removed!
  341.  * removed!
  342.  *
  343.  * removed!
  344.  * removed!
  345.  * removed!
  346.  *
  347.  * removed!
  348.  * removed!
  349.  * removed!
  350.  *
  351.  * removed!
  352.  * removed!
  353.  * removed!
  354.  *
  355.  * removed!
  356.  * removed!
  357.  * removed!
  358.  *
  359.  * removed!
  360.  * removed!
  361.  * removed!
  362.  *
  363.  * removed!
  364.  * removed!
  365.  *
  366.  *
  367.  * removed!
  368.  * removed!
  369.  *
  370.  *
  371.  * removed!
  372.  * removed!
  373.  *
  374.  *
  375.  * removed!
  376.  * removed!
  377.  *
  378.  *
  379.  * removed!
  380.  * removed!
  381.  *
  382.  *
  383.  * removed!
  384.  * removed!
  385.  *
  386.  *
  387.  * removed!
  388.  * removed!
  389.  *
  390.  *
  391.  * removed!
  392.  * removed!
  393.  * removed!
  394.  *
  395.  * removed!
  396.  * removed!
  397.  *
  398.  *
  399.  * removed!
  400.  * removed!
  401.  *
  402.  *
  403.  * removed!
  404.  * removed!
  405.  *
  406.  *
  407.  * removed!
  408.  * removed!
  409.  *
  410.  *
  411.  * removed!
  412.  * removed!
  413.  *
  414.  *
  415.  * removed!
  416.  * removed!
  417.  *
  418.  *
  419.  * removed!
  420.  * removed!
  421.  *
  422.  *
  423.  *------------------------------------------------------------------------------
  424.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  425.  *============================================================================
  426.  ****************************************************************************/
  427. #ifndef _PHONEBOOKSTUBSTOOTHERS_C
  428. #define _PHONEBOOKSTUBSTOOTHERS_C
  429. #include "MMI_features.h"
  430. #include "StdC.h"
  431. #include "L4Dr1.h"
  432. #include "PixtelDataTypes.h"
  433. #include "kal_trace.h"  /* Debug Info */
  434. #include "DebugInitDef.h"       /* Debug Info */
  435. #include "mmi_trc.h"    /* Debug Info */
  436. #include "ProtocolEvents.h"
  437. #include "Gui_data_types.h"
  438. #include "AllAppGprot.h"
  439. #include "PhonebookDef.h"
  440. #include "PhonebookGprot.h"
  441. #include "PhonebookProt.h"
  442. #include "Unicodexdcl.h"
  443. #include "NVRAMProt.h"
  444. #include "NVRAMEnum.h"
  445. #include "IdleAppDef.h"
  446. #include "IdleAppProt.h"
  447. #include "TimerEvents.h"
  448. #include "GlobalDefs.h"
  449. #include "SpeedDial.h"
  450. #include "CommonScreens.h"
  451. #include "SimDetectionGprot.h"
  452. #include "wgui_categories_multimedia.h" /* For ShowCategory225Screen */
  453. #include "CallManagementGProt.h"        /* For isInCall */
  454. #include "ProfileGprots.h"              /* For IsSilentModeActivated */
  455. #if defined(MMS_SUPPORT)        /* For MMS */
  456. #include "NVRAMType.h"
  457. #include "wap_ps_struct.h"
  458. #endif /* defined(MMS_SUPPORT) */ 
  459. #if defined(__MOD_SMSAL__)
  460. #include "MessagesExDcl.h"
  461. #include "MessagesResourceData.h"
  462. #endif /* defined(__MOD_SMSAL__) */ 
  463. #if defined(__MMI_FILE_MANAGER__)       /* Also for __MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__ */
  464. #include "FileSystemDef.h"
  465. #include "gdi_include.h"        /* graphic library */
  466. #endif /* defined(__MMI_FILE_MANAGER__) */ 
  467. #include "SettingDefs.h"
  468. #include "SettingsGdcl.h"
  469. #include "SettingGenum.h"
  470. #include "SecuritySetup.h"
  471. #if defined(__MMI_EMAIL__)
  472. #include "EmailAppGProt.h"      /* Email App List Screen */
  473. #endif 
  474. #if defined(__MMI_VRSD_DIAL__)
  475. #include "mdi_datatype.h"
  476. #include "mdi_audio.h"
  477. #include "VRSD.h"
  478. #include "VRSDEnum.h"
  479. #include "VRSDDial.h"   /* Voice dial application list screen */
  480. #endif /* defined(__MMI_VRSD_DIAL__) */ 
  481. #if defined(__MMI_VRSI__)
  482. #include "Mdi_datatype.h"
  483. #include "VRSIEnum.h"
  484. #include "VRSIType.h"
  485. #include "VRSIProt.h"
  486. #endif /* defined(__MMI_VRSI__) */ 
  487. #if defined(MMS_SUPPORT)
  488. #include "Wapadp.h"
  489. #endif 
  490. #ifdef __MMI_PHB_BIRTHDAY_FIELD__
  491. #include "app_datetime.h"
  492. #endif
  493. #ifdef __J2ME__
  494. #include "j2me_custom_option.h"
  495. #endif
  496. #ifdef __SYNCML_SUPPORT__
  497. #include "vObjects.h"
  498. #include "vCard.h"
  499. #include "SyncMLDef.h"
  500. #include "SyncMLGprot.h"
  501. #endif /* __SYNCML_SUPPORT__ */
  502. #if defined(__MMI_PHB_QUICK_SEARCH__)
  503. #if defined(__MMI_T9__)
  504. #if defined(__MMI_T9_V7__)
  505. #include "t9ccapi.h"
  506. #include "T9Main.h"
  507. #else /* defined(__MMI_T9_V7__) */ 
  508. #include "T9api.h"
  509. #include "T9Main.h"
  510. #endif /* defined(__MMI_T9_V7__) */ 
  511. #endif /* defined(__MMI_T9__) */ 
  512. #if defined(__MMI_ZI__)
  513. #include "Zi8api.h"
  514. #ifndef ZI8_GETMODE_BOPOMOFO_NAME
  515. #define ZI8_GETMODE_BOPOMOFO_NAME ZI8_GETMODE_BOPOMOFO
  516. #endif 
  517. #ifndef ZI8_GETMODE_PINYIN_NAME
  518. #define ZI8_GETMODE_PINYIN_NAME ZI8_GETMODE_PINYIN
  519. #endif 
  520. #endif /* defined(__MMI_ZI__) */ 
  521. #if defined(__MMI_ITAP__)
  522. /* under construction !*/
  523. /* under construction !*/
  524. /* under construction !*/
  525. #endif /* defined(__MMI_ITAP__) */ 
  526. #include "wgui_categories_inputs.h"
  527. #endif /* defined(__MMI_PHB_QUICK_SEARCH__) */
  528. /*
  529.  * Define
  530.  */
  531. #if defined(__MMI_PHB_QUICK_SEARCH__)
  532. #define MMI_PHB_GENERIC_QUICK_SEARCH_INPUT_LENGTH 6
  533. #define MMI_PHB_CONVERT_BUFF_ZI 32      /* ZI convert function need 32 bytes for buffer. */
  534. #endif /* defined(__MMI_PHB_QUICK_SEARCH__) */
  535. #define BYTE_SIZE                      8        /* for g_phb_qsearch_bitmask */
  536. #define BYTE_SIZE_SHIFT_ARITHMETIC     3
  537. /*
  538.  * Local Variable
  539.  */
  540. static U8 phb_list_view_type;
  541. static mmi_phb_get_data_callback_type phb_list_view_call_back;
  542. #if defined(__MMI_MESSAGES_SEND_BY_GROUP__) || defined(__UNIFIED_COMPOSER_SUPPORT__)
  543. static mmi_phb_get_index_from_group_callback_type phb_group_view_call_back;
  544. #endif
  545. MMI_PHB_LIST_VIEW phbListView;
  546. U8 g_phb_enter_from;                            /* Identify Save number from idle screen */
  547. FuncPhbListCallback g_phb_list_callback = NULL; /* For generic list call back function */
  548. #if defined(__MMI_PHB_QUICK_SEARCH__)
  549. static U16 g_phb_generic_qsearch_cache[MAX_PB_ENTRIES];
  550. static U8 g_phb_generic_qsearch_bitmask[(MAX_PB_ENTRIES + 7) / 8];
  551. static U8 g_phb_generic_qsearch_input[(MMI_PHB_GENERIC_QUICK_SEARCH_INPUT_LENGTH + 1) * ENCODING_LENGTH];
  552. static U8 g_phb_generic_qsearch_is_cache = 0;   /* Check if cache already build */
  553. #endif /* defined(__MMI_PHB_QUICK_SEARCH__) */
  554. /*
  555.  * Global Variable
  556.  */
  557. extern U16 PhoneBookEntryCount;
  558. extern MMI_PHB_ENTRY_BCD_STRUCT PhoneBook[];
  559. #ifdef __MMI_PHB_USIM_FIELD__
  560. extern MMI_PHB_EMAIL_STRUCT phb_email[MAX_PB_SIM_ENTRIES];
  561. extern MMI_PHB_NUMBER_BCD_STRUCT phb_anr[MAX_PB_SIM_ENTRIES][3];
  562. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  563. extern const U8 AsciiToDefaultArray[];
  564. extern const U8 DefaultToAsciiArray[];
  565. #ifndef __MMI_PHB_NO_OPTIONAL_FIELD__
  566. extern PHB_OPTIONAL_FIELDS_STRUCT PhoneBookOptionalFields;
  567. #endif 
  568. extern U8 MMI_current_input_mode;
  569. extern S8 pbName[];
  570. extern S8 pbNumber[];
  571. extern S8 pbHomeNumber[];
  572. extern S8 pbCompanyName[];
  573. extern S8 pbEmailAddress[];
  574. extern S8 pbOfficeNumber[];
  575. extern S8 pbFaxNumber[];
  576. #ifdef __MMI_PHB_BIRTHDAY_FIELD__
  577. extern const kal_uint8 g_dt_day_per_mon[];
  578. extern S8 pbDay[];
  579. extern S8 pbMon[];
  580. extern S8 pbYear[];
  581. #endif /* __MMI_PHB_BIRTHDAY_FIELD__ */
  582. #if defined(__MMI_VOIP__)
  583. extern S8 pbVoip[(VOIP_URI_LEN) * ENCODING_LENGTH];
  584. #endif
  585. #if defined(__MMI_FILE_MANAGER__)
  586. extern S8 g_phb_file_path[];    /* Select file from file manager */
  587. static S8 phb_caller_pic_file_path[MMI_PHB_MAX_PATH_LENGTH];
  588. #endif /* defined(__MMI_FILE_MANAGER__) */ 
  589. extern U16 g_phb_name_index[];
  590. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  591. extern S8 g_phb_video_file_path[];  /* Select video file from file manager */
  592. #endif 
  593. //
  594. #if defined(__MMI_T9__)
  595. #if defined(__MMI_T9_V7__)
  596. extern T9CCAWFieldInfo FieldInfo;
  597. #else 
  598. extern T9FieldInfo FieldInfo;
  599. #endif 
  600. #endif /* defined(__MMI_T9__) */ 
  601. #if defined(__MMI_ITAP__)
  602. /* under construction !*/
  603. /* under construction !*/
  604. /* under construction !*/
  605. /* under construction !*/
  606. #endif /* defined(__MMI_ITAP__) */ 
  607. //
  608. /*
  609.  * Global Function
  610.  */
  611. extern void IdleShowScrInvalidLocation(void);
  612. extern void IdleShowScrNoPhoneNumEntry(void);
  613. extern void SendPhbEntryForDivert(U8[], U8[]);
  614. extern void CBackCallDeflectNumberFromPB(PS8 CallDeflectBuffer);
  615. extern void mmi_msg_get_number_from_phb(U8 name[], U8 number[]);
  616. #if defined(__MMI_MESSAGES_CHAT__)
  617. extern void SetNameNumberForChatScreen(U8 name[], U8 number[]);
  618. #endif 
  619. extern void mmi_msg_send_msg_to_group(U16, U16 *);
  620. extern void mmi_frm_sms_go_back_from_send(void);
  621. extern void mmi_frm_sms_end_key_from_send(void);
  622. extern MMI_PHB_ENTRY_STRUCT *mmi_phb_get_sim_entry(void);
  623. #ifdef __J2ME__
  624. extern void mmiapi_fullscreen_editor_set_number(S8* name, S8* number);
  625. #endif
  626. #if defined(__MMI_VRSI__) && defined(__MMI_VRSI_TRAIN_TAG__)
  627. static vrsi_sd_tag_struct* g_phb_vrsi_tag_list;
  628. #endif
  629. #if defined (JATAAYU_SUPPORT)
  630. extern void update_mms_number_from_phonebook(S8 *number);
  631. extern void update_mms_email_from_phonebook(S8 *email);
  632. #endif /* JATAAYU_SUPPORT */
  633. #define MMI_PHB_STUBS_TO_OTHERS_INIT
  634. /*****************************************************************************
  635.  * FUNCTION
  636.  *  mmi_phb_stubs_to_others_init
  637.  * DESCRIPTION
  638.  *  Initial function for phonebook search and sort.
  639.  * PARAMETERS
  640.  *  void
  641.  * RETURNS
  642.  *  void
  643.  *****************************************************************************/
  644. void mmi_phb_stubs_to_others_init(void)
  645. {
  646.     /*----------------------------------------------------------------*/
  647.     /* Local Variables                                                */
  648.     /*----------------------------------------------------------------*/
  649.     /*----------------------------------------------------------------*/
  650.     /* Code Body                                                      */
  651.     /*----------------------------------------------------------------*/
  652. #if defined(__MMI_PHB_QUICK_SEARCH__) && defined(__MMI_MULTITAP_FOR_STAR_AND_POUND__)
  653.     SetHiliteHandler(MENU_ID_PHB_SMS_QUICK_SEARCH_INPUT_METHOD, mmi_phb_generic_highlight_quick_search_input_method);
  654.     SetHiliteHandler(MENU_ID_PHB_SMS_QUICK_SEARCH_DONE, mmi_phb_generic_highlight_quick_search_done);
  655. #endif /* defined(__MMI_PHB_QUICK_SEARCH__) && defined(__MMI_MULTITAP_FOR_STAR_AND_POUND__) */ 
  656. }
  657. /*****************************************************************************
  658.  * FUNCTION
  659.  *  lookUpName
  660.  * DESCRIPTION
  661.  *  Search for the number entry for corresponding name input
  662.  * PARAMETERS
  663.  *  name        [IN]        Input name to be serach
  664.  * RETURNS
  665.  *  result number string if found
  666.  *****************************************************************************/
  667. PS8 lookUpName(PS8 name)
  668. {
  669.     /*----------------------------------------------------------------*/
  670.     /* Local Variables                                                */
  671.     /*----------------------------------------------------------------*/
  672.     U16 i;
  673.     U16 store_index;
  674.     /*----------------------------------------------------------------*/
  675.     /* Code Body                                                      */
  676.     /*----------------------------------------------------------------*/
  677.     for (i = 0; i < PhoneBookEntryCount; i++)
  678.     {
  679.         store_index = g_phb_name_index[i];
  680.         if (pfnUnicodeStrcmp((PS8) name, (PS8) PhoneBook[store_index].alpha_id.name) == 0)
  681.         {
  682.             mmi_phb_convert_get_ucs2_number(pbNumber, i);   /* BCD number format. */
  683.             return (S8*) pbNumber;
  684.         }
  685.     }
  686.     return NULL;
  687. }
  688. /*****************************************************************************
  689.  * FUNCTION
  690.  *  lookUpNumber
  691.  * DESCRIPTION
  692.  *  Search for the name entry for corresponding number input
  693.  * PARAMETERS
  694.  *  number      [IN]        Input number to be serach
  695.  * RETURNS
  696.  *  result name string if found
  697.  *****************************************************************************/
  698. PS8 lookUpNumber(PS8 number)
  699. {
  700.     /*----------------------------------------------------------------*/
  701.     /* Local Variables                                                */
  702.     /*----------------------------------------------------------------*/
  703.     U16 i;
  704.     U8 flag = 0;
  705.     U32 num;
  706.     U8 number_ASCII[MAX_PB_NUMBER_LENGTH + 1 + 1];
  707.     /*----------------------------------------------------------------*/
  708.     /* Code Body                                                      */
  709.     /*----------------------------------------------------------------*/
  710.     MMI_TRACE((MMI_TRACE_G4_PHB, MMI_PHB_FUNC_lookUpNumber));
  711.     memset(number_ASCII, 0, ENCODING_LENGTH);
  712.     UnicodeToAnsii((PS8) number_ASCII, (PS8) number);
  713.     /* Lookup into table when (1) lookup table not empty (2)Not Processing (3)All Entries populated and sorted */
  714.     if (g_phb_cntx.lookup_table_count && !g_phb_cntx.processing && (g_phb_cntx.populate_count == 0xffff)
  715.     #ifdef __SYNCML_SUPPORT__
  716.       && !(mmi_syncml_is_phb_sync_now())
  717.     #endif /* __SYNCML_SUPPORT__ */
  718.     )
  719.     {
  720.         num = mmi_phb_util_convert_number_to_int(number_ASCII);
  721.         if (num < INVALID_NUMBER)
  722.         {
  723.             i = mmi_phb_lookup_table_search(num, 0, (U16) (g_phb_cntx.lookup_table_count - 1), 
  724.                 (S8*) number_ASCII, MMI_STORAGE_BOTH);
  725.             if (i < 0xffff) /* i is storage location in array, begin from 0. */
  726.             {
  727.                 flag = 1;
  728.             }
  729.         }
  730.     }
  731.     if (flag)
  732.     {
  733.         return (PS8) PhoneBook[i].alpha_id.name;
  734.     }
  735.     else
  736.     {
  737.         return NULL;
  738.     }
  739. }
  740. /*****************************************************************************
  741.  * FUNCTION
  742.  *  mmi_phb_generic_enter_list
  743.  * DESCRIPTION
  744.  *  Phonebook list interface for other application.
  745.  * PARAMETERS
  746.  *  func_list       [IN]        
  747.  * RETURNS
  748.  *  void
  749.  *****************************************************************************/
  750. void mmi_phb_generic_enter_list(FuncPhbListCallback func_list)
  751. {
  752.     /*----------------------------------------------------------------*/
  753.     /* Local Variables                                                */
  754.     /*----------------------------------------------------------------*/
  755.     /*----------------------------------------------------------------*/
  756.     /* Code Body                                                      */
  757.     /*----------------------------------------------------------------*/
  758.     phbListView = MMI_PHB_LIST_FOR_ALL_SHARED;
  759.     g_phb_list_callback = func_list;
  760.     mmi_phb_list_pre_entry_second_level();
  761. }
  762. /*****************************************************************************
  763.  * FUNCTION
  764.  *  mmi_phb_generic_enter_list_result
  765.  * DESCRIPTION
  766.  *  choose entry result, send result back to caller app.
  767.  * PARAMETERS
  768.  *  void
  769.  * RETURNS
  770.  *  void
  771.  *****************************************************************************/
  772. void mmi_phb_generic_enter_list_result(void)
  773. {
  774.     /*----------------------------------------------------------------*/
  775.     /* Local Variables                                                */
  776.     /*----------------------------------------------------------------*/
  777.     S16 pError;
  778.     U16 store_index;
  779.     MMI_PHB_VCARD_STRUCT *result_entry = OslMalloc(sizeof(MMI_PHB_VCARD_STRUCT));
  780.     /*----------------------------------------------------------------*/
  781.     /* Code Body                                                      */
  782.     /*----------------------------------------------------------------*/
  783.     /* Clear buffer */
  784.     memset(result_entry, 0, sizeof(MMI_PHB_VCARD_STRUCT));
  785.     store_index = g_phb_name_index[g_phb_cntx.active_index_second];
  786.     /* Copy Name */
  787.     pfnUnicodeStrcpy(result_entry->name, (S8*) PhoneBook[store_index].alpha_id.name);
  788.     /* Copy Number - ASCII Type */
  789.     if (PhoneBook[store_index].tel.type == MMI_CSMCC_INTERNATIONAL_ADDR)
  790.     {
  791.         *result_entry->number = '+';
  792.         mmi_phb_convert_to_digit((U8*) result_entry->number+1, PhoneBook[store_index].tel.number, MAX_PB_NUMBER_LENGTH + 1);
  793.     }
  794.     else
  795.     {
  796.         mmi_phb_convert_to_digit((U8*) result_entry->number, PhoneBook[store_index].tel.number, MAX_PB_NUMBER_LENGTH + 1);
  797.     }
  798. #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
  799.     if (store_index < MAX_PB_PHONE_ENTRIES) /* in NVRAM */
  800.     {
  801.         ReadRecord(
  802.             NVRAM_EF_PHB_FIELDS_LID,
  803.             (U16) (store_index + 1),
  804.             (void*)&PhoneBookOptionalFields,
  805.             OPTIONAL_FIELDS_RECORD_SIZE,
  806.             &pError);
  807.         strcpy(result_entry->homeNumber, (PS8) PhoneBookOptionalFields.homeNumber);
  808.         strcpy(result_entry->officeNumber, (PS8) PhoneBookOptionalFields.officeNumber);
  809.         strcpy(result_entry->faxNumber, (PS8) PhoneBookOptionalFields.faxNumber);
  810.         strcpy(result_entry->emailAddress, (S8*) PhoneBookOptionalFields.emailAddress);
  811.         pfnUnicodeStrcpy(result_entry->companyName, (PS8) PhoneBookOptionalFields.companyName);
  812.     }
  813. #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */ 
  814.     /* Send back to email app. */
  815.     if (g_phb_list_callback != NULL)
  816.     {
  817.         g_phb_list_callback(result_entry);
  818.     }
  819.     OslMfree(result_entry);
  820.     g_phb_list_callback = NULL;
  821.     DeleteScreenIfPresent(SCR_PBOOK_LIST);
  822. }
  823. #define MMI_PHB_IDLE_SCREEN
  824. /*****************************************************************************
  825.  * FUNCTION
  826.  *  mmi_phb_idle_enter_phb_list
  827.  * DESCRIPTION
  828.  *  Displays PHB list from RSK of idle screen
  829.  * PARAMETERS
  830.  *  void
  831.  * RETURNS
  832.  *  void
  833.  *****************************************************************************/
  834. void mmi_phb_idle_enter_phb_list(void)
  835. {
  836.     /*----------------------------------------------------------------*/
  837.     /* Local Variables                                                */
  838.     /*----------------------------------------------------------------*/
  839.     /*----------------------------------------------------------------*/
  840.     /* Code Body                                                      */
  841.     /*----------------------------------------------------------------*/
  842.     g_idle_context.ToNameScrFromIdleApp = 1;
  843.     g_idle_context.RskPressedFromIdleApp = 1;
  844.     phbListView = MMI_PHB_LIST_FOR_PHB;
  845.     g_phb_cntx.highlight_entry = 0;
  846. #if defined(__MMI_PHB_RSK_QUICK_SEARCH__)
  847.     mmi_phb_quick_search_list_pre_entry();
  848. #else 
  849. #if defined(__MMI_PHB_NAME_LIST_FILTER__)
  850.     mmi_phb_nlf_list_pre_entry();
  851. #else /* defined(__MMI_PHB_NAME_LIST_FILTER__) */
  852.     mmi_phb_list_pre_entry();
  853. #endif /* defined(__MMI_PHB_NAME_LIST_FILTER__) */
  854. #endif /* defined(__MMI_PHB_RSK_QUICK_SEARCH__) */
  855. #if (!defined(__MMI_TOUCH_SCREEN__)) ||(defined(__MMI_TOUCH_SCREEN__) && defined(__MMI_TOUCH_SCREEN_WITH_NUMERIC_KEY__) && !defined(__MMI_SLIDE__))  //KP Jerry add "defined(__MMI_TOUCH_SCREEN__) && defined(__MMI_TOUCH_SCREEN_WITH_NUMERIC_KEY__)" on 2007-3-26
  856. #if (defined(__MMI_KEYPAD_LOCK_PATTERN_1__) && !defined(__MMI_DISABLE_KEYPAD_LOCK__))
  857.     if (g_idle_context.RskPressedFromIdleApp == 1)
  858.     {
  859.         StartTimer(KEYPAD_LOCK_TIMER, KEYPAD_LOCK_TIMEOUT, IdleHandleKeypadLockProcess);
  860.         SetKeyHandler(IdleHandlePoundKeyForKeypadLock, KEY_POUND, KEY_EVENT_UP);
  861.     }
  862. #endif /* (defined(__MMI_KEYPAD_LOCK_PATTERN_1__) && !defined(__MMI_DISABLE_KEYPAD_LOCK__)) */ 
  863. //KP Jerry add on 2007-3-26 start
  864. #if (defined(__MMI_KEYPAD_LOCK_PATTERN_3__) && !defined(__MMI_DISABLE_KEYPAD_LOCK__))
  865.     if (g_idle_context.RskPressedFromIdleApp == 1)
  866.     {
  867.         StartTimer(KEYPAD_LOCK_TIMER, KEYPAD_LOCK_TIMEOUT, IdleHandleKeypadLockProcess);
  868.         SetKeyHandler(IdleHandlePoundKeyForKeypadLock, KEY_STAR, KEY_EVENT_UP);
  869.     }
  870. #endif /* (defined(__MMI_KEYPAD_LOCK_PATTERN_3__) && !defined(__MMI_DISABLE_KEYPAD_LOCK__)) */ 
  871. //KP Jerry add on 2007-3-26 end
  872. //KP Jerry add on 2007-4-23 start
  873. #if (defined(__MMI_KEYPAD_LOCK_PATTERN_4__) && !defined(__MMI_DISABLE_KEYPAD_LOCK__))
  874.     if (g_idle_context.RskPressedFromIdleApp == 1)
  875.     {
  876.         StartTimer(KEYPAD_LOCK_TIMER, KEYPAD_LOCK_TIMEOUT, IdleHandleKeypadLockProcess);
  877.         SetKeyHandler(IdleHandlePoundKeyForKeypadLock, KEY_CAMERA, KEY_EVENT_UP);
  878.     }
  879. #endif /* (defined(__MMI_KEYPAD_LOCK_PATTERN_4__) && !defined(__MMI_DISABLE_KEYPAD_LOCK__)) */ 
  880. //KP Jerry add on 2007-4-23 end
  881. #endif /* __MMI_TOUCH_SCREEN__ */ 
  882. }
  883. /*****************************************************************************
  884.  * FUNCTION
  885.  *  SaveNumberFromIdleScrn
  886.  * DESCRIPTION
  887.  *  Saves number from idle screen
  888.  * PARAMETERS
  889.  *  number          [IN]        Number string to be saved
  890.  *  enter           [IN]        Enter location
  891.  * RETURNS
  892.  *  void
  893.  *****************************************************************************/
  894. void SaveNumberFromIdleScrn(PS8 number, U8 enter)
  895. {
  896.     /*----------------------------------------------------------------*/
  897.     /* Local Variables                                                */
  898.     /*----------------------------------------------------------------*/
  899.     /*----------------------------------------------------------------*/
  900.     /* Code Body                                                      */
  901.     /*----------------------------------------------------------------*/
  902.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<SaveNumberFromIdleScrn.>n", __FILE__, __LINE__));
  903.     /* Check number length first */
  904.     if (pfnUnicodeStrlen((PS8) number) > MAX_PB_NUMBER_LENGTH + 1)
  905.     {
  906.         DisplayPopup((PU8) GetString(STR_NUMBER_TOO_LONG), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  907.     }
  908.     /* Avoid add entry while copy all and delete all */
  909.     else if (!g_phb_cntx.phb_ready || g_phb_cntx.processing)
  910.     {
  911.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  912.     }
  913. #ifdef __MMI_PHB_USIM_FIELD__
  914.     else if (g_phb_cntx.is_usim && g_phb_cntx.usim_ready_stage != MMI_PHB_USIM_READY)
  915.     {
  916.         mmi_phb_entry_not_ready(STR_ID_PHB_PROCESSING_USIM);
  917.     }
  918. #endif /* __MMI_PHB_USIM_FIELD__ */
  919. #ifdef __SYNCML_SUPPORT__
  920.     else if (mmi_syncml_is_phb_sync_now())
  921.     {
  922.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  923.     }
  924. #endif /* __SYNCML_SUPPORT__ */
  925.     else
  926.     {
  927.         g_phb_cntx.set_done_flag = 1;
  928.         pfnUnicodeStrcpy(pbNumber, number);
  929.         g_phb_enter_from = enter;
  930.         mmi_phb_clear_old_history();
  931.         mmi_phb_op_add_pre_entry();
  932.     }
  933. }
  934. #ifdef __MMI_PHB_BIRTHDAY_FIELD__
  935. /*****************************************************************************
  936.  * FUNCTION
  937.  *  mmi_phb_retrieve_bday
  938.  * DESCRIPTION
  939.  *  parse birthday field of a vcard object.s
  940.  * PARAMETERS
  941.  *  b_string        [?]         
  942.  *  pb_year         [?]         
  943.  *  pb_mon          [?]         
  944.  *  pb_day          [?]         
  945.  *  change_flag     [IN]        
  946.  *  String(?)       [IN]        String read from file for one line
  947.  * RETURNS
  948.  *  parse error cause(?)
  949.  *****************************************************************************/
  950. void mmi_phb_retrieve_bday(S8 *b_string, S8 *pb_year, S8 *pb_mon, S8 *pb_day, BOOL change_flag)
  951. {
  952.     /*----------------------------------------------------------------*/
  953.     /* Local Variables                                                */
  954.     /*----------------------------------------------------------------*/
  955.     S8 temp_buf[10 + 1]; /* 19990101 or 1999-01-01 */
  956.     S8 ascii_buff[6];
  957.     U16 b_year;
  958.     U8 b_month;
  959.     U8 b_day;
  960.     U8 is_valid = TRUE;
  961.     U8 i;
  962.     /*----------------------------------------------------------------*/
  963.     /* Code Body                                                      */
  964.     /*----------------------------------------------------------------*/
  965.     /* b_string; */
  966.     memset(temp_buf, 0, sizeof(temp_buf));
  967.     strncpy(temp_buf, b_string, 10);
  968.     /* Year */
  969.     strncpy(ascii_buff, temp_buf, 4);
  970.     ascii_buff[4] = '';
  971.     AnsiiToUnicodeString(pb_year, ascii_buff);
  972.     b_year = (U16) gui_atoi((U16*) pb_year);
  973.     i = 4;
  974.     /* Month */
  975.     if (*(temp_buf + i) == '-')
  976.     {
  977.         i++;
  978.     }
  979.     strncpy(ascii_buff, temp_buf + i, 2);
  980.     ascii_buff[2] = '';
  981.     AnsiiToUnicodeString(pb_mon, ascii_buff);
  982.     b_month = (U8) gui_atoi((U16*) pb_mon);
  983.     i += 2;
  984.     /* Day */
  985.     if (*(temp_buf + i) == '-')
  986.     {
  987.         i++;
  988.     }    
  989.     strncpy(ascii_buff, temp_buf + i, 2);
  990.     ascii_buff[2] = '';
  991.     AnsiiToUnicodeString(pb_day, ascii_buff);
  992.     b_day = (U8) gui_atoi((U16*) pb_day);
  993.     if (b_year > MMI_PHB_BDAY_MAX_YEAR_INT || b_year < 1900)
  994.     {
  995.         is_valid = FALSE;
  996.     }
  997.     else if (b_month > 12)
  998.     {
  999.         is_valid = FALSE;
  1000.     }
  1001. #if defined(MMI_ON_HARDWARE_P)
  1002.     if (b_month == 2)
  1003.     {
  1004.         if (b_day > (g_dt_day_per_mon[b_month - 1] + applib_dt_is_leap_year(b_year)))
  1005.             is_valid = FALSE;
  1006.     }
  1007.     else if (b_day > g_dt_day_per_mon[b_month - 1])
  1008.     {
  1009.         is_valid = FALSE;
  1010.     }
  1011. #endif /* MMI_ON_HARDWARE_P */
  1012.     if (is_valid && change_flag)
  1013.     {
  1014.         mmi_phb_bday_set_changed();
  1015.     }
  1016.     else
  1017.     {
  1018.         mmi_phb_util_clear_bday_buffer();
  1019.     }
  1020. }
  1021. #endif /* __MMI_PHB_BIRTHDAY_FIELD__ */ 
  1022. #ifdef __MMI_BARCODEREADER__ /* could extend in the future */
  1023. /*****************************************************************************
  1024.  * FUNCTION
  1025.  *  mmi_phb_save_entry_from_barcode
  1026.  * DESCRIPTION
  1027.  *  Saves phonebook entry from barcode application
  1028.  * PARAMETERS
  1029.  *  ucs2_name       [IN]        Name string to be saved. Max length is MAX_PB_NAME_LENGTH
  1030.  *  number          [IN]        Number string to be saved(UCS2)
  1031.  *  opt_fields      [IN]        Optional fields
  1032.  *  b_day           [IN]         Birthday to be saved. Format: yyyymmdd. ex: 19750101
  1033.  *  info_fields     [IN]        Information fields
  1034.  *  nick_name       [IN]        Nick name string to be saved(UCS2). Max length is MAX_PB_NAME_LENGTH
  1035.  * RETURNS
  1036.  *  void
  1037.  *****************************************************************************/
  1038. void mmi_phb_save_entry_from_barcode(
  1039.         S8 *ucs2_name,
  1040.         S8 *number,
  1041.         PHB_OPTIONAL_FIELDS_STRUCT *opt_fields,
  1042.         S8 *b_day,
  1043.         PHB_INFO_FIELDS_STRUCT *info_fields,
  1044.         S8 *nick_name)
  1045. {
  1046.     /*----------------------------------------------------------------*/
  1047.     /* Local Variables                                                */
  1048.     /*----------------------------------------------------------------*/
  1049.     U8 name_extend_char_num = 0;
  1050.     /*----------------------------------------------------------------*/
  1051.     /* Code Body                                                      */
  1052.     /*----------------------------------------------------------------*/
  1053.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_save_entry_from_barcode.>n", __FILE__,
  1054.                          __LINE__));
  1055.     /* Check number length first */
  1056.     if ((pfnUnicodeStrlen(number) > MAX_PB_NUMBER_LENGTH + 1))
  1057.     {
  1058.         DisplayPopup((PU8) GetString(STR_NUMBER_TOO_LONG), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  1059.     }
  1060.     /* Avoid add entry while copy all and delete all */
  1061.     else if (!g_phb_cntx.phb_ready || g_phb_cntx.processing)
  1062.     {
  1063.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1064.     }
  1065. #ifdef __MMI_PHB_USIM_FIELD__
  1066.     else if (g_phb_cntx.is_usim && g_phb_cntx.usim_ready_stage != MMI_PHB_USIM_READY)
  1067.     {
  1068.         mmi_phb_entry_not_ready(STR_ID_PHB_PROCESSING_USIM);
  1069.     }
  1070. #endif /* __MMI_PHB_USIM_FIELD__ */
  1071. #ifdef __SYNCML_SUPPORT__
  1072.     else if (mmi_syncml_is_phb_sync_now())
  1073.     {
  1074.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  1075.     }
  1076. #endif /* __SYNCML_SUPPORT__ */
  1077.     else if (PhoneBookEntryCount == (g_phb_cntx.sim_total + g_phb_cntx.phone_total))
  1078.     {
  1079.         DisplayPopup((PU8) GetString(STR_PBOOK_FULL_MSG), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  1080.     }
  1081.     else
  1082.     {
  1083.         g_phb_cntx.set_done_flag = 1;
  1084.         g_phb_enter_from = MMI_PHB_ENTER_FROM_BARCODE;
  1085.         mmi_phb_clear_old_history();
  1086.         mmi_phb_util_clear_buffer(TRUE);
  1087.         if (ucs2_name)
  1088.         {        
  1089.             if (GetUCS2Flag(ucs2_name) == 1) /* there is chinese character, length = 14 */
  1090.             {
  1091.                 pfnUnicodeStrncpy(pbName, ucs2_name, (MAX_PB_NAME_LENGTH - 1) / 2);
  1092.             }
  1093.             else
  1094.             {
  1095.                 name_extend_char_num = GetUCS2ExtendedNum((PS8)ucs2_name, MAX_PB_NAME_LENGTH);
  1096.                 if ((pfnUnicodeStrlen(ucs2_name) + name_extend_char_num) > MAX_PB_NAME_LENGTH)
  1097.                 {           
  1098.                     pfnUnicodeStrncpy(pbName, ucs2_name, MAX_PB_NAME_LENGTH - name_extend_char_num);
  1099.                 }
  1100.                 else
  1101.                 {
  1102.                     pfnUnicodeStrncpy(pbName, ucs2_name, MAX_PB_NAME_LENGTH);
  1103.                 }
  1104.             }
  1105.         }
  1106.         if (number)
  1107.         {
  1108.             pfnUnicodeStrncpy(pbNumber, number, MAX_PB_NUMBER_LENGTH);
  1109.         }
  1110.         if (opt_fields)
  1111.         {
  1112.             AnsiiToUnicodeString(pbHomeNumber, (PS8) opt_fields->homeNumber);
  1113.             AnsiiToUnicodeString(pbEmailAddress, (PS8) opt_fields->emailAddress);
  1114.             AnsiiToUnicodeString(pbOfficeNumber, (PS8) opt_fields->officeNumber);
  1115.             pfnUnicodeStrcpy(pbCompanyName, (PS8) opt_fields->companyName);
  1116.             AnsiiToUnicodeString(pbFaxNumber, (PS8) opt_fields->faxNumber);
  1117.         }
  1118.     #ifdef __MMI_PHB_BIRTHDAY_FIELD__
  1119.         if (b_day)
  1120.         {
  1121.             mmi_phb_retrieve_bday(b_day, (S8*) pbYear, (S8*) pbMon, (S8*) pbDay, TRUE);
  1122.         }
  1123.     #endif /* __MMI_PHB_BIRTHDAY_FIELD__ */ 
  1124.     #ifdef __MMI_PHB_INFO_FIELD__
  1125.         if (info_fields)
  1126.         {
  1127.             pfnUnicodeStrcpy(pbTitle, (PS8) info_fields->title);
  1128.             pfnUnicodeStrcpy(pbUrl, (PS8) info_fields->url);
  1129.             AnsiiToUnicodeString(pbAddress, (PS8) info_fields->address);
  1130.             pfnUnicodeStrcpy(pbNote, (PS8) info_fields->note);
  1131.         }
  1132.     #endif /* __MMI_PHB_INFO_FIELD__ */ 
  1133.     #ifdef __MMI_PHB_USIM_FIELD__
  1134.         if (nick_name)
  1135.         {
  1136.             pfnUnicodeStrcpy(pbNickName, (PS8) info_fields->note);
  1137.         }
  1138.     #endif /* __MMI_PHB_USIM_FIELD__ */ 
  1139.         mmi_phb_entry_op_add_choose_storage();
  1140.     }
  1141. }
  1142. #endif /* __MMI_BARCODEREADER__ */ 
  1143. #ifdef __MMI_VOIP__
  1144. /*****************************************************************************
  1145.  * FUNCTION
  1146.  *  mmi_phb_call_get_data_for_voip
  1147.  * DESCRIPTION
  1148.  *  Returns the names/ringtone/image tag/caller group details for the incoming
  1149.  *  call number if it is present in PHB
  1150.  * PARAMETERS
  1151.  *  uri         [IN]        uri string to be matched
  1152.  *  is_mo_call  [IN]        dial_from_list only for mo call
  1153.  * RETURNS
  1154.  *  PHB_CM_INTERFACE  a interface structure
  1155.  *****************************************************************************/
  1156. PHB_VOIP_INTERFACE mmi_phb_call_get_data_for_voip(PU8 uri, BOOL is_mo_call)
  1157. {
  1158.     /*----------------------------------------------------------------*/
  1159.     /* Local Variables                                                */
  1160.     /*----------------------------------------------------------------*/
  1161.     U16 store_index = 0xffff, grp_id;
  1162.     PHB_VOIP_INTERFACE phbDetails;
  1163.     U8 flag = 0;
  1164.     U8 uri_ASCII[VOIP_URI_LEN];
  1165.     U8 *uri_ptr;
  1166.     PHB_OPTIONAL_IDS_STRUCT *opt_ids = NULL;
  1167.     PHB_CALLER_GROUP_STRUCT *callerGroups;
  1168. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1169.     U16 video_id;
  1170. #endif 
  1171.     /*----------------------------------------------------------------*/
  1172.     /* Code Body                                                      */
  1173.     /*----------------------------------------------------------------*/
  1174.     memset(uri_ASCII, 0, ENCODING_LENGTH);
  1175.     memset((void*)&phbDetails, 0, sizeof(phbDetails));
  1176.     phbDetails.pictureId = IMG_PHB_DEFAULT;
  1177.     phbDetails.dialInList = MMI_PHB_NONE;
  1178.     UnicodeToAnsii((PS8) uri_ASCII, (PS8) uri);
  1179.     PRINT_INFORMATION(("---[PhonebookStubsToOthers.c] mmi_phb_call_get_data_for_call_mgnt() => number: [%s] dial list:[%d] n", uri_ASCII, g_phb_cntx.dial_from_list));
  1180.     uri_ptr = uri_ASCII;
  1181.     /* Check if dial out from phonebook list */
  1182.     if (g_phb_cntx.dial_from_list == MMI_PHB_PHONEBOOK && is_mo_call)
  1183.     {
  1184.         g_phb_cntx.dial_from_list = MMI_PHB_NONE;
  1185.         flag = 1;
  1186.         store_index = g_phb_name_index[g_phb_cntx.active_index];
  1187.         phbDetails.dialInList = MMI_PHB_PHONEBOOK;
  1188.     }
  1189.     /* Map Number with one enrtry. */
  1190.     if (flag)
  1191.     {
  1192.         pfnUnicodeStrcpy((PS8) phbDetails.name, (PS8) PhoneBook[store_index].alpha_id.name);
  1193.         phbDetails.name_dcs = PhoneBook[store_index].alpha_id.name_dcs;
  1194.         /* Caller Group Setup */
  1195.     #if !defined(__MMI_PHB_CALLERGROUP_IN_SIM__)    /* Associate caller group in SIM card entry */
  1196.         if (store_index < MAX_PB_PHONE_ENTRIES)
  1197.     #endif 
  1198.         {
  1199.             callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  1200.             mmi_phb_read_optional_ids(store_index); /* i is store index */
  1201.             opt_ids = (PHB_OPTIONAL_IDS_STRUCT*) g_phb_cntx.optional_ids;
  1202.             grp_id = opt_ids->callerGroupID;
  1203.             if (grp_id)
  1204.             {
  1205.             #if defined(__MMI_CALLERGROUP_NO_ALERT__)
  1206.                 phbDetails.alertType = MMI_ALERT_NONE;
  1207.             #else
  1208.                 phbDetails.alertType = callerGroups[grp_id - 1].alertType;
  1209.             #endif
  1210.                 phbDetails.backlightId = callerGroups[grp_id - 1].LEDPatternId;
  1211.                 phbDetails.ringtoneId = callerGroups[grp_id - 1].ringToneID;
  1212.                 if (callerGroups[grp_id - 1].pictureTagID == 1) /* Associate Picture is in the file system. */
  1213.                 {
  1214.                 #if defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__)
  1215.                     phbDetails.pictureId = 1;
  1216.                     phbDetails.record_index = 5000 + grp_id;
  1217.                 #endif /* defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__) */ 
  1218.                 }
  1219.                 else if (callerGroups[grp_id - 1].pictureTagID != 0)   /* 0 means default image */
  1220.                 {
  1221.                     phbDetails.pictureId = callerGroups[grp_id - 1].pictureTagID;
  1222.                 }
  1223.             #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1224.                 if (callerGroups[grp_id - 1].VideoID)
  1225.                 {
  1226.                     phbDetails.videoId = callerGroups[grp_id - 1].VideoID;
  1227.                     phbDetails.video_record_index = (U16) (MAX_PB_PHONE_ENTRIES + grp_id);      /* MAX_PB_PHONE_ENTRIES for group 1 and so on. */
  1228.                 }
  1229.             #endif /* defined(__MMI_INCOMING_CALL_VIDEO__) */ 
  1230.             }
  1231.         }
  1232.         /* Personal Entry Setup, these will overwrite caller group setting. */
  1233.         if (store_index < MAX_PB_PHONE_ENTRIES)
  1234.         {
  1235.             /* Associate Pictures */
  1236.             if (opt_ids->pictureTagID == 1)
  1237.             {
  1238.             #if defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__)
  1239.                 phbDetails.pictureId = 1;
  1240.                 phbDetails.record_index = store_index + 1;  /* Record Must in NVRAM, so the record index is store_index + 1 */
  1241.             #endif /* defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__) */ 
  1242.             #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1243.                 phbDetails.videoId = 0;    /* If Image Selected, should not play caller group's video */
  1244.             #endif 
  1245.             }
  1246.             else if ((opt_ids->pictureTagID != IMG_PHB_DEFAULT) && (opt_ids->pictureTagID != 0x0000))
  1247.             {
  1248.                 phbDetails.pictureId = opt_ids->pictureTagID;
  1249.             #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1250.                 phbDetails.videoId = 0; /* If Image Selected, should not play caller group's video */
  1251.             #endif 
  1252.             }
  1253.             /* Associate Ring Tone */
  1254.             if (opt_ids->ringToneID)
  1255.             {
  1256.                 phbDetails.ringtoneId = opt_ids->ringToneID;
  1257.             }
  1258.             /* For Incoming Call Video */
  1259.         #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1260.             if ((video_id = mmi_phb_video_get_id_by_index(store_index)) != 0)
  1261.             {
  1262.                 phbDetails.videoId = video_id;
  1263.                 phbDetails.video_record_index = store_index + 1;    /* Record Must in NVRAM, so the record index is store_index + 1 */
  1264.             }
  1265.         #endif /* defined(__MMI_INCOMING_CALL_VIDEO__) */ 
  1266.         }
  1267.     }
  1268.     return phbDetails;
  1269. }
  1270. /*****************************************************************************
  1271.  * FUNCTION
  1272.  *  mmi_phb_save_entry_for_service_field
  1273.  * DESCRIPTION
  1274.  *  Saves number from idle screen
  1275.  * PARAMETERS
  1276.  *  uri             [IN]        uri to be saved
  1277.  *  enter           [IN]        Enter location
  1278.  * RETURNS
  1279.  *  void
  1280.  *****************************************************************************/
  1281. void mmi_phb_save_entry_for_service_field(PS8 uri, U8 enter)
  1282. {
  1283.     /*----------------------------------------------------------------*/
  1284.     /* Local Variables                                                */
  1285.     /*----------------------------------------------------------------*/
  1286.     /*----------------------------------------------------------------*/
  1287.     /* Code Body                                                      */
  1288.     /*----------------------------------------------------------------*/
  1289.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_save_entry_for_service_field.>n", __FILE__, __LINE__));
  1290.     /* Check uri length first */
  1291.     if (enter == MMI_PHB_ENTER_FROM_VOIP &&  pfnUnicodeStrlen((PS8)uri) >= VOIP_URI_LEN)
  1292.     {
  1293.         DisplayPopup((PU8) GetString(STR_GLOBAL_ERROR), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  1294.     }
  1295.     /* Avoid add entry while copy all and delete all */
  1296.     else if (!g_phb_cntx.phb_ready || g_phb_cntx.processing)
  1297.     {
  1298.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1299.     }
  1300. #ifdef __MMI_PHB_USIM_FIELD__
  1301.     else if (g_phb_cntx.is_usim && g_phb_cntx.usim_ready_stage != MMI_PHB_USIM_READY)
  1302.     {
  1303.         mmi_phb_entry_not_ready(STR_ID_PHB_PROCESSING_USIM);
  1304.     }
  1305. #endif /* __MMI_PHB_USIM_FIELD__ */
  1306. #ifdef __SYNCML_SUPPORT__
  1307.     else if (mmi_syncml_is_phb_sync_now())
  1308.     {
  1309.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  1310.     }
  1311. #endif /* __SYNCML_SUPPORT__ */
  1312.     else if (g_phb_cntx.phone_total == g_phb_cntx.phone_used)
  1313.     {
  1314.         DisplayPopup((PU8) GetString(STR_PHONE_FULL_MSG), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  1315.     }
  1316.     else
  1317.     {
  1318.         g_phb_cntx.set_done_flag = 1;
  1319.         g_phb_enter_from = MMI_PHB_ENTER_FROM_VOIP;
  1320.         mmi_phb_clear_old_history();
  1321.         mmi_phb_util_clear_buffer(TRUE);
  1322.         if (uri)
  1323.         {
  1324.             pfnUnicodeStrcpy(pbVoip, uri);
  1325.         }
  1326.         //mmi_phb_entry_op_add_choose_storage();
  1327.         g_phb_cntx.selected_storage = MMI_NVRAM;
  1328.         mmi_phb_entry_op_add_entry();
  1329.     }
  1330. }
  1331. #endif /* __MMI_VOIP__ */
  1332. /*****************************************************************************
  1333.  * FUNCTION
  1334.  *  mmi_phb_get_sim_entry_by_location
  1335.  * DESCRIPTION
  1336.  *  Return the number to idle screen for quick access
  1337.  * PARAMETERS
  1338.  *  entryNum        [IN]        Location to be search
  1339.  * RETURNS
  1340.  *  void
  1341.  *****************************************************************************/
  1342. void mmi_phb_get_sim_entry_by_location(U16 entryNum)
  1343. {
  1344.     /*----------------------------------------------------------------*/
  1345.     /* Local Variables                                                */
  1346.     /*----------------------------------------------------------------*/
  1347.     U16 i;
  1348.     U16 record_index;
  1349.     U8 hasEntry = 0;
  1350.     /*----------------------------------------------------------------*/
  1351.     /* Code Body                                                      */
  1352.     /*----------------------------------------------------------------*/
  1353.     if (!g_phb_cntx.phb_ready || g_phb_cntx.processing)
  1354.     {
  1355.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1356.     }
  1357. #ifdef __SYNCML_SUPPORT__
  1358.     else if (mmi_syncml_is_phb_sync_now())
  1359.     {
  1360.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  1361.     }
  1362. #endif /* __SYNCML_SUPPORT__ */
  1363.     else if (entryNum == 0 || entryNum > g_phb_cntx.sim_total)
  1364.     {
  1365.         IdleShowScrInvalidLocation();
  1366.     }
  1367.     else
  1368.     {
  1369.         for (i = 0; i < PhoneBookEntryCount; i++)
  1370.         {
  1371.             record_index = g_phb_name_index[i] - MAX_PB_PHONE_ENTRIES + 1;
  1372.             if (record_index == entryNum)
  1373.             {
  1374.                 g_phb_cntx.active_index = i;
  1375.                 hasEntry = 1;
  1376.                 mmi_phb_entry_op_view_entry();
  1377.             }
  1378.         }
  1379.         if (!hasEntry)
  1380.         {
  1381.             IdleShowScrNoPhoneNumEntry();
  1382.         }
  1383.     }
  1384. }
  1385. #define MMI_PHB_INTERFACE_FOR_CALL
  1386. /*****************************************************************************
  1387.  * FUNCTION
  1388.  *  mmi_phb_call_get_data_for_call_mgnt
  1389.  * DESCRIPTION
  1390.  *  Returns the names/ringtone/image tag/caller group details for the incoming
  1391.  *  call number if it is present in PHB
  1392.  * PARAMETERS
  1393.  *  number      [IN]        Number string to be matched
  1394.  *  is_mo_call  [IN]        dial_from_list only for mo call
  1395.  * RETURNS
  1396.  *  PHB_CM_INTERFACE  a interface structure
  1397.  *****************************************************************************/
  1398. PHB_CM_INTERFACE mmi_phb_call_get_data_for_call_mgnt(PU8 number, BOOL is_mo_call)
  1399. {
  1400.     /*----------------------------------------------------------------*/
  1401.     /* Local Variables                                                */
  1402.     /*----------------------------------------------------------------*/
  1403.     U16 store_index = 0xffff, grp_id;
  1404.     PHB_CM_INTERFACE phbDetails;
  1405.     U8 flag = 0;
  1406.     U32 num;
  1407.     U8 number_ASCII[MAX_PB_NUMBER_LENGTH + 1 + 1];
  1408.     U8 *number_ptr;
  1409.     PHB_OPTIONAL_IDS_STRUCT *opt_ids = NULL;
  1410.     PHB_CALLER_GROUP_STRUCT *callerGroups;
  1411.     S8 *str_P = NULL;
  1412. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1413.     U16 video_id;
  1414. #endif 
  1415.     /*----------------------------------------------------------------*/
  1416.     /* Code Body                                                      */
  1417.     /*----------------------------------------------------------------*/
  1418.     /* MMI_TRACE((MMI_TRACE_G4_PHB, MMI_PHB_FUNC_GetPHBDataForCM)); */
  1419.     memset(number_ASCII, 0, ENCODING_LENGTH);
  1420.     memset((void*)&phbDetails, 0, sizeof(phbDetails));
  1421.     phbDetails.pictureId = IMG_PHB_DEFAULT;
  1422.     phbDetails.dialInList = MMI_PHB_NONE;
  1423.     UnicodeToAnsii((PS8) number_ASCII, (PS8) number);
  1424.     PRINT_INFORMATION(("---[PhonebookStubsToOthers.c] mmi_phb_call_get_data_for_call_mgnt() => number: [%s] dial list:[%d] n", number_ASCII, g_phb_cntx.dial_from_list));
  1425.     /* convert P to p */
  1426.     str_P = strstr((S8*)number_ASCII, "P");
  1427.     if (str_P)
  1428.     {
  1429.         str_P[0] = 'p'; 
  1430.     }
  1431.     number_ptr = number_ASCII;
  1432.     /* Ignore  *31# and #31# case */
  1433.     while (((number_ptr[0] == '*') && (number_ptr[1] == '3') && (number_ptr[2] == '1') && (number_ptr[3] == '#')) ||
  1434.            ((number_ptr[0] == '#') && (number_ptr[1] == '3') && (number_ptr[2] == '1') && (number_ptr[3] == '#')))
  1435.     {
  1436.         number_ptr += 4;
  1437.     }
  1438.     /*  Display as Emergency Number */
  1439.     if (CheckValidEmergencyNo1((S8*) number))
  1440.     {
  1441.         AnsiiToUnicodeString((PS8) phbDetails.number, (S8*) number_ptr);
  1442.         g_phb_cntx.dial_from_list = MMI_PHB_NONE;   /* Clear dial from list flag */
  1443.         pfnUnicodeStrncpy((PS8) phbDetails.name, GetString(STR_EMERGENCY_NUMBER), MAX_PB_NAME_LENGTH);
  1444.         if (GetUCS2Flag((PS8) phbDetails.name))
  1445.         {
  1446.             phbDetails.name_dcs = MMI_PHB_UCS2;
  1447.         }
  1448.         else
  1449.         {
  1450.             phbDetails.name_dcs = MMI_PHB_ASCII;
  1451.         }
  1452.         return phbDetails;
  1453.     }
  1454.     /* Check if dial out from phonebook list */
  1455.     if (g_phb_cntx.dial_from_list == MMI_PHB_PHONEBOOK && is_mo_call)
  1456.     {
  1457.         g_phb_cntx.dial_from_list = MMI_PHB_NONE;
  1458.         flag = 1;
  1459.         store_index = g_phb_name_index[g_phb_cntx.active_index];
  1460.         phbDetails.dialInList = MMI_PHB_PHONEBOOK;
  1461.     }
  1462.     /*
  1463.      *  Check if dial out from FDN list,
  1464.      *  note that should enter here only from FDN list screen
  1465.      */
  1466.     else if (g_phb_cntx.dial_from_list == MMI_PHB_FDN && is_mo_call)
  1467.     {
  1468.         g_phb_cntx.dial_from_list = MMI_PHB_NONE;
  1469.         /* Fill up structure and return FDN data directly here */
  1470.         pfnUnicodeStrcpy(
  1471.             (S8*) phbDetails.name,
  1472.             (S8*) gFDLBDLContext.FDLBDLEntries[gFDLBDLContext.HighlightedFDN].alpha_id.name);
  1473.         phbDetails.name_dcs = gFDLBDLContext.FDLBDLEntries[gFDLBDLContext.HighlightedFDN].alpha_id.name_dcs;
  1474.         pfnUnicodeStrcpy(
  1475.             (S8*) phbDetails.number,
  1476.             (S8*) gFDLBDLContext.FDLBDLEntries[gFDLBDLContext.HighlightedFDN].tel.number);
  1477.         phbDetails.dialInList = MMI_PHB_FDN;
  1478.         return phbDetails;
  1479.     }
  1480.     /*
  1481.      *  Check if dial out from SDN list,
  1482.      *  note that should enter here only from SDN list screen
  1483.      */
  1484.     else if (g_phb_cntx.dial_from_list == MMI_PHB_SDN && is_mo_call)
  1485.     {
  1486.         MMI_PHB_ENTRY_STRUCT *sdn_entry = mmi_phb_get_sim_entry();
  1487.         g_phb_cntx.dial_from_list = MMI_PHB_NONE;
  1488.         /* Fill up structure and return SDN data directly here */
  1489.         pfnUnicodeStrcpy((S8*) phbDetails.name, (S8*) sdn_entry->alpha_id.name);
  1490.         phbDetails.name_dcs = sdn_entry->alpha_id.name_dcs;
  1491.         pfnUnicodeStrcpy((S8*) phbDetails.number, (S8*) sdn_entry->tel.number);
  1492.         phbDetails.dialInList = MMI_PHB_SDN;
  1493.         return phbDetails;
  1494.     }
  1495.     else /* Not dial from list. */
  1496.     {
  1497.         /* Lookup into table when (1)  lookup table not empty (2) Not Processing (3) All Entries populated and sorted */
  1498.         if (g_phb_cntx.lookup_table_count && !g_phb_cntx.processing && (g_phb_cntx.populate_count == 0xffff)
  1499.         #ifdef __SYNCML_SUPPORT__
  1500.             && !(mmi_syncml_is_phb_sync_now())
  1501.         #endif /* __SYNCML_SUPPORT__ */
  1502.         )
  1503.         {
  1504.             num = mmi_phb_util_convert_number_to_int(number_ASCII);
  1505.             if (num < INVALID_NUMBER)
  1506.             {
  1507.                 g_phb_cntx.searched_number_type = 0;
  1508.                 store_index = mmi_phb_lookup_table_search(num, 0, (U16)(g_phb_cntx.lookup_table_count - 1), 
  1509.                     (S8*) number_ptr, MMI_STORAGE_BOTH);
  1510.                 if (store_index < 0xffff)   /* i is storage location in array, begin from 0. */
  1511.                 {
  1512.                     flag = 1;
  1513.                 }
  1514.             }
  1515.         }
  1516.     }
  1517.     /* Map Number with one enrtry. */
  1518.     if (flag)
  1519.     {
  1520.         pfnUnicodeStrcpy((PS8) phbDetails.name, (PS8) PhoneBook[store_index].alpha_id.name);
  1521.         phbDetails.name_dcs = PhoneBook[store_index].alpha_id.name_dcs;
  1522.         if (phbDetails.dialInList != MMI_PHB_PHONEBOOK) /* CM should use its number if dial from Phonebook list */
  1523.         {
  1524.         #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
  1525.             if ((store_index < MAX_PB_PHONE_ENTRIES) && g_phb_cntx.searched_number_type != 0)
  1526.             {
  1527.                 switch (g_phb_cntx.searched_number_type)
  1528.                 {
  1529.                     case MMI_PHB_ENTRY_FIELD_HOME:
  1530.                         AnsiiToUnicodeString((PS8) phbDetails.number, (S8*) PhoneBookOptionalFields.homeNumber);
  1531.                         break;
  1532.                     case MMI_PHB_ENTRY_FIELD_OFFICE:
  1533.                         AnsiiToUnicodeString((PS8) phbDetails.number, (S8*) PhoneBookOptionalFields.officeNumber);
  1534.                         break;
  1535.                     case MMI_PHB_ENTRY_FIELD_FAX:
  1536.                         AnsiiToUnicodeString((PS8) phbDetails.number, (S8*) PhoneBookOptionalFields.faxNumber);
  1537.                         break;
  1538.                     default:
  1539.                         MMI_ASSERT(0);
  1540.                         break;
  1541.                 }
  1542.             }
  1543.             else
  1544.         #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */ 
  1545.             {
  1546.                 mmi_phb_convert_get_ucs2_number((S8*) phbDetails.number, store_index);
  1547.             }
  1548.         }
  1549.         /* Caller Group Setup */
  1550.     #if !defined(__MMI_PHB_CALLERGROUP_IN_SIM__)    /* Associate caller group in SIM card entry */
  1551.         if (store_index < MAX_PB_PHONE_ENTRIES)
  1552.     #endif 
  1553.         {
  1554.             callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  1555.             mmi_phb_read_optional_ids(store_index); /* i is store index */
  1556.             opt_ids = (PHB_OPTIONAL_IDS_STRUCT*) g_phb_cntx.optional_ids;
  1557.             grp_id = opt_ids->callerGroupID;
  1558.             if (grp_id)
  1559.             {
  1560.             #if defined(__MMI_CALLERGROUP_NO_ALERT__)
  1561.                 phbDetails.alertType = MMI_ALERT_NONE;
  1562.             #else
  1563.                 phbDetails.alertType = callerGroups[grp_id - 1].alertType;
  1564.             #endif
  1565.                 phbDetails.backlightId = callerGroups[grp_id - 1].LEDPatternId;
  1566.                 phbDetails.ringtoneId = callerGroups[grp_id - 1].ringToneID;
  1567.                 if (callerGroups[grp_id - 1].pictureTagID == 1) /* Associate Picture is in the file system. */
  1568.                 {
  1569.                 #if defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__)
  1570.                     phbDetails.pictureId = 1;
  1571.                     phbDetails.record_index = 5000 + grp_id;
  1572.                 #endif /* defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__) */ 
  1573.                 }
  1574.                 else if (callerGroups[grp_id - 1].pictureTagID != 0)    /* 0 means default image */
  1575.                 {
  1576.                     phbDetails.pictureId = callerGroups[grp_id - 1].pictureTagID;
  1577.                 }
  1578.             #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1579.                 if (callerGroups[grp_id - 1].VideoID)
  1580.                 {
  1581.                     phbDetails.videoId = callerGroups[grp_id - 1].VideoID;
  1582.                     phbDetails.video_record_index = (U16) (MAX_PB_PHONE_ENTRIES + grp_id);      /* MAX_PB_PHONE_ENTRIES for group 1 and so on. */
  1583.                 }
  1584.             #endif /* defined(__MMI_INCOMING_CALL_VIDEO__) */ 
  1585.             }
  1586.         }
  1587.         /*  Personal Entry Setup, these will overwrite caller group setting. */
  1588.         if (store_index < MAX_PB_PHONE_ENTRIES)
  1589.         {
  1590.             /* Associate Pictures */
  1591.             if (opt_ids->pictureTagID == 1)
  1592.             {
  1593.             #if defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__)
  1594.                 phbDetails.pictureId = 1;
  1595.                 phbDetails.record_index = store_index + 1;  /* Record Must in NVRAM, so the record index is store_index + 1 */
  1596.             #endif /* defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__) */ 
  1597.             #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1598.                 phbDetails.videoId = 0;                     /* If Image Selected, should not play caller group's video */
  1599.             #endif 
  1600.             }
  1601.             else if ((opt_ids->pictureTagID != IMG_PHB_DEFAULT) && (opt_ids->pictureTagID != 0x0000))
  1602.             {
  1603.                 phbDetails.pictureId = opt_ids->pictureTagID;
  1604.             #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1605.                 phbDetails.videoId = 0; /* If Image Selected, should not play caller group's video */
  1606.             #endif 
  1607.             }
  1608.             /* Associate Ring Tone */
  1609.             if (opt_ids->ringToneID)
  1610.             {
  1611.                 phbDetails.ringtoneId = opt_ids->ringToneID;
  1612.             }
  1613.             /* For Incoming Call Video */
  1614.         #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1615.             if ((video_id = mmi_phb_video_get_id_by_index(store_index)) != 0)
  1616.             {
  1617.                 phbDetails.videoId = video_id;
  1618.                 phbDetails.video_record_index = store_index + 1;        /* Record Must in NVRAM, so the record index is store_index + 1 */
  1619.             }
  1620.         #endif /* defined(__MMI_INCOMING_CALL_VIDEO__) */ 
  1621.         }
  1622.     }
  1623.     /*
  1624.      *   If entry is not found, try to search in FDN list to see if number can be match and dial out.
  1625.      *   This should be search when FDN is enable.
  1626.      *   Note: FDN list is stored in ADN storage when FDN is enable.
  1627.      */
  1628.     else if (gSecuritySetupContext.FdlStatus)
  1629.     {
  1630.         UnicodeToAnsii((PS8) number_ASCII, (PS8) number);
  1631.         store_index = mmi_phb_fdn_search_by_number((S8*) number_ASCII);
  1632.         if (store_index < 0xffff)
  1633.         {
  1634.             pfnUnicodeStrcpy((PS8) phbDetails.name, (PS8) PhoneBook[store_index].alpha_id.name);
  1635.             phbDetails.name_dcs = PhoneBook[store_index].alpha_id.name_dcs;
  1636.             mmi_phb_convert_get_ucs2_number((S8*) phbDetails.number, store_index);
  1637.         }
  1638.     }
  1639.     return phbDetails;
  1640. }
  1641. /*****************************************************************************
  1642.  * FUNCTION
  1643.  *  mmi_phb_call_set_dial_from_list
  1644.  * DESCRIPTION
  1645.  *  Let call management to set dial from list flag.
  1646.  * PARAMETERS
  1647.  *  value       [IN]        TRUE/FALSE value
  1648.  * RETURNS
  1649.  *  void
  1650.  *****************************************************************************/
  1651. void mmi_phb_call_set_dial_from_list(U8 value)
  1652. {
  1653.     /*----------------------------------------------------------------*/
  1654.     /* Local Variables                                                */
  1655.     /*----------------------------------------------------------------*/
  1656.     /*----------------------------------------------------------------*/
  1657.     /* Code Body                                                      */
  1658.     /*----------------------------------------------------------------*/
  1659.     g_phb_cntx.dial_from_list = value;
  1660. }
  1661. #if defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__) || defined(__MMI_FILE_MANAGER__)
  1662. /*****************************************************************************
  1663.  * FUNCTION
  1664.  *  mmi_phb_image_get_path_from_id
  1665.  * DESCRIPTION
  1666.  *  This function returns the phonebook associate picture image path by index.
  1667.  * PARAMETERS
  1668.  *  record_index        [IN]        Index of a phonebook record. (if >5000, it is a caller group image)
  1669.  * RETURNS
  1670.  *  full path of image
  1671.  *****************************************************************************/
  1672. S8 *mmi_phb_image_get_path_from_id(U16 record_index)
  1673. {
  1674.     /*----------------------------------------------------------------*/
  1675.     /* Local Variables                                                */
  1676.     /*----------------------------------------------------------------*/
  1677.     S16 drive;
  1678.     S8 *path;
  1679.     FS_HANDLE fh;
  1680.     S32 width, height;
  1681.     /*----------------------------------------------------------------*/
  1682.     /* Code Body                                                      */
  1683.     /*----------------------------------------------------------------*/
  1684.     MMI_TRACE((MMI_TRACE_G4_PHB, MMI_PHB_IMAGE_GET_PATH_FROM_ID_1, record_index));
  1685.     drive = MMI_PHB_DRV;
  1686.     if (drive > 0)
  1687.     {
  1688.         path = (S8*) phb_caller_pic_file_path;  /* Use global static buffer to store path */
  1689.         mmi_phb_image_get_full_path_by_index(record_index, path);
  1690.         /* Try to open file and check image format. If can't open, use default picture to display. */
  1691.         if (pfnUnicodeStrlen(path) > 0)
  1692.         {
  1693.             fh = FS_Open((U16*) path, FS_READ_ONLY);
  1694.             MMI_TRACE((MMI_TRACE_G4_PHB, MMI_PHB_IMAGE_GET_PATH_FROM_ID_2, fh));
  1695.             if (fh)
  1696.             {
  1697.                 FS_Close(fh);
  1698.                 if (gdi_image_get_dimension_file((S8*) path, &width, &height) >= 0)
  1699.                 {
  1700.                     MMI_TRACE((MMI_TRACE_G4_PHB, MMI_PHB_IMAGE_GET_PATH_FROM_ID_3));
  1701.                     return path;
  1702.                 }
  1703.             }
  1704.         }
  1705.     }
  1706.     return NULL;
  1707. }
  1708. #endif /* defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__) || defined(__MMI_FILE_MANAGER__) */ 
  1709. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1710. /*****************************************************************************
  1711.  * FUNCTION
  1712.  *  mmi_phb_video_get_path_from_id
  1713.  * DESCRIPTION
  1714.  *  This function returns the phonebook associate video path by index.
  1715.  * PARAMETERS
  1716.  *  record_index        [IN]        Index of a phonebook record.
  1717.  * RETURNS
  1718.  *  full path of image
  1719.  *****************************************************************************/
  1720. S8 *mmi_phb_video_get_path_from_id(U16 record_index)
  1721. {
  1722.     /*----------------------------------------------------------------*/
  1723.     /* Local Variables                                                */
  1724.     /*----------------------------------------------------------------*/
  1725.     U16 store_index = record_index - 1;
  1726.     U16 video_id = 0;
  1727.     PHB_CALLER_GROUP_STRUCT *callerGroups;
  1728.     /*----------------------------------------------------------------*/
  1729.     /* Code Body                                                      */
  1730.     /*----------------------------------------------------------------*/
  1731.     /* In phonebook entry */
  1732.     if (store_index < MAX_PB_PHONE_ENTRIES)
  1733.     {
  1734.         video_id = mmi_phb_video_get_id_by_index(store_index);
  1735.     }
  1736.     /* In caller group */
  1737.     else if ((store_index < (MAX_PB_PHONE_ENTRIES + MAX_PB_CALLER_GROUPS)) && (store_index >= MAX_PB_PHONE_ENTRIES))
  1738.     {
  1739.         callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  1740.         video_id = callerGroups[(store_index - MAX_PB_PHONE_ENTRIES)].VideoID;
  1741.     }
  1742.     return mmi_phb_caller_video_get_path_by_index(video_id);
  1743. }
  1744. #endif /* defined(__MMI_INCOMING_CALL_VIDEO__) */ 
  1745. /*****************************************************************************
  1746.  * FUNCTION
  1747.  *  mmi_phb_call_enter_from_divert
  1748.  * DESCRIPTION
  1749.  *  Displays the PHB list for call divert
  1750.  * PARAMETERS
  1751.  *  void
  1752.  * RETURNS
  1753.  *  void
  1754.  *****************************************************************************/
  1755. void mmi_phb_call_enter_from_divert(void)
  1756. {
  1757.     /*----------------------------------------------------------------*/
  1758.     /* Local Variables                                                */
  1759.     /*----------------------------------------------------------------*/
  1760.     /*----------------------------------------------------------------*/
  1761.     /* Code Body                                                      */
  1762.     /*----------------------------------------------------------------*/
  1763.     phbListView = MMI_PHB_LIST_FOR_SETTINGS;
  1764.     /* mmi_phb_list_pre_entry_second_level(); */
  1765.     g_phb_cntx.highlight_entry = 0;
  1766.     mmi_phb_entry_list(
  1767.         PhoneBookEntryCount,                /* Total Entry */
  1768.         STR_SCR_PBOOK_VIEW_CAPTION,         /* Title String */
  1769.         IMG_SCR_PBOOK_CAPTION,              /* Title Image */
  1770.         STR_GLOBAL_OK,                      /* LSK */
  1771.         IMG_GLOBAL_OK,                      /* LSK */
  1772.         mmi_phb_get_index_second_level,     /* Highlight Callback */
  1773.         mmi_phb_call_send_data_for_divert,  /* LSK Callback */
  1774.         mmi_phb_call_send_data_for_divert,  /* SEND Key Callback */
  1775.         mmi_phb_list_get_item,              /* List Callback */
  1776.         mmi_phb_list_get_hint,              /* Hint Callback */
  1777.         mmi_phb_call_enter_from_divert,     /* Re-Entry Callback */
  1778.         TRUE,                               /* Alpha Index */
  1779.         TRUE);                              /* Right Arrow Key */
  1780. }
  1781. /*****************************************************************************
  1782.  * FUNCTION
  1783.  *  mmi_phb_call_send_data_for_divert
  1784.  * DESCRIPTION
  1785.  *  Sends the names & numbers info of the selected
  1786.  *  PHB entry to call divert
  1787.  * PARAMETERS
  1788.  *  void
  1789.  * RETURNS
  1790.  *  void
  1791.  *****************************************************************************/
  1792. void mmi_phb_call_send_data_for_divert(void)
  1793. {
  1794.     /*----------------------------------------------------------------*/
  1795.     /* Local Variables                                                */
  1796.     /*----------------------------------------------------------------*/
  1797.     U16 store_index;
  1798.     /*----------------------------------------------------------------*/
  1799.     /* Code Body                                                      */
  1800.     /*----------------------------------------------------------------*/
  1801.     store_index = g_phb_name_index[g_phb_cntx.active_index_second];
  1802.     mmi_phb_convert_get_ucs2_number(pbNumber, store_index); /* BCD number format. */
  1803.     SendPhbEntryForDivert(PhoneBook[store_index].alpha_id.name, (U8*) pbNumber);
  1804. }
  1805. /*****************************************************************************
  1806.  * FUNCTION
  1807.  *  mmi_phb_call_enter_from_active_call
  1808.  * DESCRIPTION
  1809.  *  Displays PHB main menu from active call options
  1810.  * PARAMETERS
  1811.  *  void
  1812.  * RETURNS
  1813.  *  void
  1814.  *****************************************************************************/
  1815. void mmi_phb_call_enter_from_active_call(void)
  1816. {
  1817.     /*----------------------------------------------------------------*/
  1818.     /* Local Variables                                                */
  1819.     /*----------------------------------------------------------------*/
  1820.     /*----------------------------------------------------------------*/
  1821.     /* Code Body                                                      */
  1822.     /*----------------------------------------------------------------*/
  1823.     if (g_phb_cntx.processing)
  1824.     {
  1825.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1826.     }
  1827. #ifdef __SYNCML_SUPPORT__
  1828.     else if (mmi_syncml_is_phb_sync_now())
  1829.     {
  1830.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  1831.     }
  1832. #endif /* __SYNCML_SUPPORT__ */
  1833.     else
  1834.     {
  1835.      g_phb_enter_from = MMI_PHB_ENTER_NONE;
  1836.         mmi_phb_clear_old_history();
  1837.         mmi_phb_util_clear_buffer(TRUE);
  1838.         mmi_phb_entry_main_menu();
  1839.     }
  1840. }
  1841. /*****************************************************************************
  1842.  * FUNCTION
  1843.  *  mmi_phb_call_enter_from_deflect_option
  1844.  * DESCRIPTION
  1845.  *  Displays PHB list from incoming call deflect option
  1846.  * PARAMETERS
  1847.  *  void
  1848.  * RETURNS
  1849.  *  void
  1850.  *****************************************************************************/
  1851. void mmi_phb_call_enter_from_deflect_option(void)
  1852. {
  1853.     /*----------------------------------------------------------------*/
  1854.     /* Local Variables                                                */
  1855.     /*----------------------------------------------------------------*/
  1856.     /*----------------------------------------------------------------*/
  1857.     /* Code Body                                                      */
  1858.     /*----------------------------------------------------------------*/
  1859.     if (g_phb_cntx.processing)
  1860.     {
  1861.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1862.     }
  1863. #ifdef __SYNCML_SUPPORT__
  1864.     else if (mmi_syncml_is_phb_sync_now())
  1865.     {
  1866.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  1867.     }
  1868. #endif /* __SYNCML_SUPPORT__ */
  1869.     else
  1870.     {
  1871.         phbListView = MMI_PHB_LIST_FOR_CM;
  1872.         /* mmi_phb_list_pre_entry_second_level(); */
  1873.         g_phb_cntx.highlight_entry = 0;
  1874.         mmi_phb_entry_list(
  1875.             PhoneBookEntryCount,                    /* Total Entry */
  1876.             STR_SCR_PBOOK_VIEW_CAPTION,             /* Title String */
  1877.             IMG_SCR_PBOOK_CAPTION,                  /* Title Image */
  1878.             STR_GLOBAL_OK,                          /* LSK */
  1879.             IMG_GLOBAL_OK,                          /* LSK */
  1880.             mmi_phb_get_index_second_level,         /* Highlight Callback */
  1881.             mmi_phb_call_send_data_for_deflect,     /* LSK Callback */
  1882.             mmi_phb_call_send_data_for_deflect,     /* SEND Key Callback */
  1883.             mmi_phb_list_get_item,                  /* List Callback */
  1884.             mmi_phb_list_get_hint,                  /* Hint Callback */
  1885.             mmi_phb_call_enter_from_deflect_option, /* Re-Entry Callback */
  1886.             TRUE,                                   /* Alpha Index */
  1887.             TRUE);                                  /* Right Arrow Key */
  1888.     }
  1889. }
  1890. /*****************************************************************************
  1891.  * FUNCTION
  1892.  *  mmi_phb_call_send_data_for_deflect
  1893.  * DESCRIPTION
  1894.  *  Sends the numbers info of the selected
  1895.  *  entry for Call deflect
  1896.  * PARAMETERS
  1897.  *  void
  1898.  * RETURNS
  1899.  *  void
  1900.  *****************************************************************************/
  1901. void mmi_phb_call_send_data_for_deflect(void)
  1902. {
  1903.     /*----------------------------------------------------------------*/
  1904.     /* Local Variables                                                */
  1905.     /*----------------------------------------------------------------*/
  1906.     S8* phb_deflect_num;
  1907.     /*----------------------------------------------------------------*/
  1908.     /* Code Body                                                      */
  1909.     /*----------------------------------------------------------------*/
  1910.     phb_deflect_num = OslMalloc((MAX_PB_NUMBER_LENGTH+1+1)*ENCODING_LENGTH);
  1911.     mmi_phb_convert_get_ucs2_number(phb_deflect_num, g_phb_name_index[g_phb_cntx.active_index_second]);        /* BCD number format. */
  1912.     CBackCallDeflectNumberFromPB(phb_deflect_num);
  1913.     OslMfree(phb_deflect_num);
  1914. }
  1915. /*****************************************************************************
  1916.  * FUNCTION
  1917.  *  mmi_phb_list_enter_first_from_active_call
  1918.  * DESCRIPTION
  1919.  *  Enter phonebook list from active call to first item.
  1920.  * PARAMETERS
  1921.  *  void
  1922.  * RETURNS
  1923.  *  void
  1924.  *****************************************************************************/
  1925. void mmi_phb_list_enter_first_from_active_call(void)
  1926. {
  1927.     /*----------------------------------------------------------------*/
  1928.     /* Local Variables                                                */
  1929.     /*----------------------------------------------------------------*/
  1930.     /*----------------------------------------------------------------*/
  1931.     /* Code Body                                                      */
  1932.     /*----------------------------------------------------------------*/
  1933.     mmi_phb_list_enter_from_active_call(0);
  1934. }
  1935. /*****************************************************************************
  1936.  * FUNCTION
  1937.  *  mmi_phb_list_enter_last_from_active_call
  1938.  * DESCRIPTION
  1939.  *  Enter phonebook list from active call to last item.
  1940.  * PARAMETERS
  1941.  *  void
  1942.  * RETURNS
  1943.  *  void
  1944.  *****************************************************************************/
  1945. void mmi_phb_list_enter_last_from_active_call(void)
  1946. {
  1947.     /*----------------------------------------------------------------*/
  1948.     /* Local Variables                                                */
  1949.     /*----------------------------------------------------------------*/
  1950.     /*----------------------------------------------------------------*/
  1951.     /* Code Body                                                      */
  1952.     /*----------------------------------------------------------------*/
  1953.     mmi_phb_list_enter_from_active_call((U16) (PhoneBookEntryCount - 1));
  1954. }
  1955. /*****************************************************************************
  1956.  * FUNCTION
  1957.  *  mmi_phb_list_enter_from_active_call
  1958.  * DESCRIPTION
  1959.  *  enter phonebook list from active call, highlight on specific entry.
  1960.  *  (Note this function call will clear all phonebook history if exists)
  1961.  * PARAMETERS
  1962.  *  highlight_pos       [IN]        Highlight entry position.
  1963.  * RETURNS
  1964.  *  void
  1965.  *****************************************************************************/
  1966. void mmi_phb_list_enter_from_active_call(U16 highlight_pos)
  1967. {
  1968.     /*----------------------------------------------------------------*/
  1969.     /* Local Variables                                                */
  1970.     /*----------------------------------------------------------------*/
  1971.     /*----------------------------------------------------------------*/
  1972.     /* Code Body                                                      */
  1973.     /*----------------------------------------------------------------*/
  1974. #ifdef __SYNCML_SUPPORT__
  1975.     if (mmi_syncml_is_phb_sync_now())
  1976.     {
  1977.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  1978.     }
  1979.     else
  1980. #endif /* __SYNCML_SUPPORT__ */
  1981.     if (g_phb_cntx.phb_ready && !g_phb_cntx.processing)
  1982.     {
  1983.         if (PhoneBookEntryCount)
  1984.         {
  1985.             phbListView = MMI_PHB_LIST_FOR_PHB;
  1986.             g_phb_cntx.highlight_entry = highlight_pos;
  1987.             mmi_phb_clear_old_history();    /* Clear old phb history */
  1988.             mmi_phb_list_pre_entry();
  1989.         }
  1990.         else
  1991.         {
  1992.             DisplayPopup(
  1993.                 (PU8) GetString(STR_NO_ENTRIES_MESSAGE),
  1994.                 IMG_GLOBAL_EMPTY,
  1995.                 TRUE,
  1996.                 PHB_NOTIFY_TIMEOUT,
  1997.                 EMPTY_LIST_TONE);
  1998.         }
  1999.     }
  2000.     else
  2001.     {
  2002.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  2003.     }
  2004. }
  2005. #define MMI_PHB_INTERFACE_FOR_SMS
  2006. /*****************************************************************************
  2007.  * FUNCTION
  2008.  *  mmi_phb_sms_enter_send_entry
  2009.  * DESCRIPTION
  2010.  *  Displays the PHB list for SMS to send SMS
  2011.  *  to one or many numbers
  2012.  * PARAMETERS
  2013.  *  void
  2014.  * RETURNS
  2015.  *  void
  2016.  *****************************************************************************/
  2017. void mmi_phb_sms_enter_send_entry(void)
  2018. {
  2019.     /*----------------------------------------------------------------*/
  2020.     /* Local Variables                                                */
  2021.     /*----------------------------------------------------------------*/
  2022.     /*----------------------------------------------------------------*/
  2023.     /* Code Body                                                      */
  2024.     /*----------------------------------------------------------------*/
  2025.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_sms_enter_send_entry.>n", __FILE__,
  2026.                          __LINE__));
  2027.     phbListView = MMI_PHB_LIST_FOR_SMS;
  2028.     /* mmi_phb_list_pre_entry_second_level(); */
  2029.     g_phb_cntx.highlight_entry = 0;
  2030.     mmi_phb_entry_list(
  2031.         PhoneBookEntryCount,                /* Total Entry */
  2032.         STR_SCR_PBOOK_VIEW_CAPTION,         /* Title String */
  2033.         IMG_SCR_PBOOK_CAPTION,              /* Title Image */
  2034.         STR_GLOBAL_OK,                      /* LSK */
  2035.         IMG_GLOBAL_OK,                      /* LSK */
  2036.         mmi_phb_get_index_second_level,     /* Highlight Callback */
  2037.         mmi_phb_sms_send_data_choose_entry, /* LSK Callback */
  2038.         mmi_phb_sms_send_data_choose_entry, /* SEND Key Callback */
  2039.         mmi_phb_list_get_item,              /* List Callback */
  2040.         mmi_phb_list_get_hint,              /* Hint Callback */
  2041.         mmi_phb_sms_enter_send_entry,       /* Re-Entry Callback */
  2042.         TRUE,                               /* Alpha Index */
  2043.         TRUE);                              /* Right Arrow Key */
  2044. }
  2045. /*****************************************************************************
  2046.  * FUNCTION
  2047.  *  mmi_phb_entry_sms_choose_number
  2048.  * DESCRIPTION
  2049.  *  
  2050.  * PARAMETERS
  2051.  *  void
  2052.  * RETURNS
  2053.  *  void
  2054.  *****************************************************************************/
  2055. void mmi_phb_entry_sms_choose_number(void)
  2056. {
  2057.     /*----------------------------------------------------------------*/
  2058.     /* Local Variables                                                */
  2059.     /*----------------------------------------------------------------*/
  2060.     /*----------------------------------------------------------------*/
  2061.     /* Code Body                                                      */
  2062.     /*----------------------------------------------------------------*/
  2063.     mmi_phb_entry_list_choose_number(
  2064. #if defined(__MMI_PHB_QUICK_SEARCH__)
  2065.         g_phb_cntx.active_index_fourth,
  2066. #else
  2067.         g_phb_cntx.active_index_second,
  2068. #endif /* defined(__MMI_PHB_QUICK_SEARCH__) */
  2069.         mmi_phb_entry_sms_choose_number,
  2070.         mmi_phb_sms_send_data_for_entry_list,
  2071.         mmi_phb_sms_send_data_for_entry,
  2072.         STR_SMS_NUM_CANNOT_BE_EMPTY,
  2073.         FALSE);
  2074. }
  2075. //quick search start
  2076. #if defined(__MMI_PHB_QUICK_SEARCH__)
  2077. #if defined(__MMI_T9__) && (defined(__MMI_LANG_TR_CHINESE__) || defined(__MMI_LANG_SM_CHINESE__))
  2078. #if defined(__MMI_T9_V7__)
  2079. /*****************************************************************************
  2080.  * FUNCTION
  2081.  *  mmi_phb_generic_quick_search_convert_to_spelling
  2082.  * DESCRIPTION
  2083.  *  This function is just for template.
  2084.  * PARAMETERS
  2085.  *  input_string        [?]             
  2086.  *  output_string       [?]             
  2087.  *  out_len             [?]             
  2088.  *  a(?)                [IN/OUT]        First variable, used as returns
  2089.  *  b(?)                [IN]            Second variable
  2090.  * RETURNS
  2091.  *  the description of return value, if any.
  2092.  *****************************************************************************/
  2093. BOOL mmi_phb_generic_quick_search_convert_to_spelling(U8 *input_string, U8 *output_string, U8 *out_len)
  2094. {
  2095.     /*----------------------------------------------------------------*/
  2096.     /* Local Variables                                                */
  2097.     /*----------------------------------------------------------------*/
  2098.     S8 out = 0;
  2099.     U8 i = 0;
  2100.     T9STATUS t9ReturnCodes;
  2101.     /*----------------------------------------------------------------*/
  2102.     /* Code Body                                                      */
  2103.     /*----------------------------------------------------------------*/
  2104.     /* Should already switch to the proper input language in "mmi_phb_quick_search_convert_cache()". */
  2105.     if (input_string[0] != 0 || input_string[1] != 0)
  2106.     {
  2107.         if (MMI_current_input_mode == INPUT_MODE_MMI_SM_STROKE || MMI_current_input_mode == INPUT_MODE_MMI_TR_STROKE)
  2108.         {
  2109.             t9ReturnCodes = T9CCGetCharStrokes(&FieldInfo.CCFieldInfo, (U16*) input_string, 0);
  2110.         }
  2111.         else
  2112.         {
  2113.             t9ReturnCodes = T9CCGetCharSpell(&FieldInfo.CCFieldInfo, (U16*) input_string, 0);
  2114.         }
  2115.         if (t9ReturnCodes == 0)
  2116.         {
  2117.             switch (MMI_current_input_mode)
  2118.             {
  2119.                 case INPUT_MODE_MMI_MULTITAP_BPMF:
  2120.                     while ((FieldInfo.CCFieldInfo.pbSpellBuf[i] != 0x00) && (i <= 7))
  2121.                     {
  2122.                         *((U16*) (output_string + out)) = BPMFInternalToUnicode(FieldInfo.CCFieldInfo.pbSpellBuf[i]);
  2123.                         out = out + 2;
  2124.                         i = i + 1;
  2125.                     }
  2126.                     break;
  2127.                 case INPUT_MODE_MMI_MULTITAP_PINYIN:
  2128.                     while ((FieldInfo.CCFieldInfo.pbSpellBuf[i] != 0x00) && (i <= 7))
  2129.                     {
  2130.                         output_string[out] = FieldInfo.CCFieldInfo.pbSpellBuf[i];
  2131.                         output_string[out + 1] = 0;
  2132.                         out = out + 2;
  2133.                         i = i + 1;
  2134.                     }
  2135.                     break;
  2136.                 case INPUT_MODE_MMI_SM_STROKE:
  2137.                 case INPUT_MODE_MMI_TR_STROKE:
  2138.                     while ((FieldInfo.CCFieldInfo.pbKeyBuf[i] != 0x00) &&
  2139.                            (i < FieldInfo.CCFieldInfo.nKeyBufLen) && (i <= 7))
  2140.                     {
  2141.                         *((U16*) (output_string + out)) = StrokeInternalToUnicode(FieldInfo.CCFieldInfo.pbKeyBuf[i]);
  2142.                         out = out + 2;
  2143.                         i = i + 1;
  2144.                     }
  2145.                     break;
  2146.                 default:
  2147.                     break;
  2148.             }
  2149.             *out_len = i;
  2150.             return TRUE;
  2151.         }
  2152.         /* Input String Does not Converted. */
  2153.         memcpy(output_string, input_string, 2);
  2154.         *out_len = 1;
  2155.         return TRUE;
  2156.     }
  2157.     *out_len = 0;
  2158.     return FALSE;
  2159. }
  2160. /*****************************************************************************
  2161.  * FUNCTION
  2162.  *  mmi_phb_generic_quick_search_convert_cache
  2163.  * DESCRIPTION
  2164.  *  This function convert first character of name field into cache.
  2165.  * PARAMETERS
  2166.  *  index       [IN]        Phonebook entry index
  2167.  * RETURNS
  2168.  *  void
  2169.  *****************************************************************************/
  2170. void mmi_phb_generic_quick_search_convert_cache(U16 index)
  2171. {
  2172.     /*----------------------------------------------------------------*/
  2173.     /* Local Variables                                                */
  2174.     /*----------------------------------------------------------------*/
  2175.     T9STATUS t9ReturnCodes;
  2176.     /*----------------------------------------------------------------*/
  2177.     /* Code Body                                                      */
  2178.     /*----------------------------------------------------------------*/
  2179.     /* move change language function out from loop to speed up */
  2180.     if (MMI_current_input_mode == INPUT_MODE_MMI_SM_STROKE || MMI_current_input_mode == INPUT_MODE_MMI_TR_STROKE)
  2181.     {
  2182.         t9ReturnCodes = T9CCGetCharStrokes(&FieldInfo.CCFieldInfo, (U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name, 0);
  2183.     }
  2184.     else
  2185.     {
  2186.         t9ReturnCodes = T9CCGetCharSpell(&FieldInfo.CCFieldInfo, (U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name, 0);
  2187.     }
  2188.     if (t9ReturnCodes == 0)
  2189.     {
  2190.         switch (MMI_current_input_mode)
  2191.         {
  2192.             case INPUT_MODE_MMI_MULTITAP_BPMF:
  2193.                 g_phb_generic_qsearch_cache[index] = BPMFInternalToUnicode(FieldInfo.CCFieldInfo.pbSpellBuf[0]);
  2194.                 break;
  2195.             case INPUT_MODE_MMI_MULTITAP_PINYIN:
  2196.                 g_phb_generic_qsearch_cache[index] = FieldInfo.CCFieldInfo.pbSpellBuf[0];
  2197.                 break;
  2198.             case INPUT_MODE_MMI_SM_STROKE:
  2199.             case INPUT_MODE_MMI_TR_STROKE:
  2200.                 g_phb_generic_qsearch_cache[index] = StrokeInternalToUnicode(FieldInfo.CCFieldInfo.pbKeyBuf[0]);
  2201.                 break;
  2202.             default:
  2203.                 g_phb_generic_qsearch_cache[index] = *((U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name);
  2204.                 break;
  2205.         }
  2206.     }
  2207.     else
  2208.     {
  2209.         g_phb_generic_qsearch_cache[index] = *((U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name);
  2210.     }
  2211. }
  2212. #else /* defined(__MMI_T9_V7__) */ 
  2213. /*****************************************************************************
  2214.  * FUNCTION
  2215.  *  mmi_phb_generic_quick_search_convert_to_spelling
  2216.  * DESCRIPTION
  2217.  *  This function is just for template.
  2218.  * PARAMETERS
  2219.  *  input_string        [?]             
  2220.  *  output_string       [?]             
  2221.  *  out_len             [?]             
  2222.  *  a(?)                [IN/OUT]        First variable, used as returns
  2223.  *  b(?)                [IN]            Second variable
  2224.  * RETURNS
  2225.  *  the description of return value, if any.
  2226.  *****************************************************************************/
  2227. BOOL mmi_phb_generic_quick_search_convert_to_spelling(U8 *input_string, U8 *output_string, U8 *out_len)
  2228. {
  2229.     /*----------------------------------------------------------------*/
  2230.     /* Local Variables                                                */
  2231.     /*----------------------------------------------------------------*/
  2232.     S8 out = 0;
  2233.     U8 i = 0;
  2234.     T9Event t9EventInput;
  2235.     T9STATUS t9ReturnCodes;
  2236.     /*----------------------------------------------------------------*/
  2237.     /* Code Body                                                      */
  2238.     /*----------------------------------------------------------------*/
  2239.     /* Should already switch to the proper input language in "mmi_phb_quick_search_convert_cache()". */
  2240.     if (input_string[0] != 0 || input_string[1] != 0)
  2241.     {
  2242.         if (MMI_current_input_mode == INPUT_MODE_MMI_SM_STROKE || MMI_current_input_mode == INPUT_MODE_MMI_TR_STROKE)
  2243.         {
  2244.             t9EventInput.mType = T9EVTSTROKES;
  2245.         }
  2246.         else
  2247.         {
  2248.             t9EventInput.mType = T9EVTSPELLING;
  2249.         }
  2250.         t9EventInput.data.sLDBData.psBuf = (U16*) input_string;
  2251.         t9EventInput.data.sLDBData.mCtrlID = 0;
  2252.         t9ReturnCodes = T9HandleEvent(&FieldInfo, &t9EventInput);
  2253.         if (t9ReturnCodes == 0)
  2254.         {
  2255.             switch (MMI_current_input_mode)
  2256.             {
  2257.                 case INPUT_MODE_MMI_MULTITAP_BPMF:
  2258.                     while ((FieldInfo.uLangData.pAuxChinese->pbSpellBuf[i] != 0x00) && (i <= 7))
  2259.                     {
  2260.                         *((U16*) (output_string + out)) = BPMFInternalToUnicode(FieldInfo.uLangData.pAuxChinese->pbSpellBuf[i]);
  2261.                         out = out + 2;
  2262.                         i = i + 1;
  2263.                     }
  2264.                     break;
  2265.                 case INPUT_MODE_MMI_MULTITAP_PINYIN:
  2266.                     while ((FieldInfo.uLangData.pAuxChinese->pbSpellBuf[i] != 0x00) && (i <= 7))
  2267.                     {
  2268.                         output_string[out] = FieldInfo.uLangData.pAuxChinese->pbSpellBuf[i];
  2269.                         output_string[out + 1] = 0;
  2270.                         out = out + 2;
  2271.                         i = i + 1;
  2272.                     }
  2273.                     break;
  2274.                 case INPUT_MODE_MMI_SM_STROKE:
  2275.                 case INPUT_MODE_MMI_TR_STROKE:
  2276.                     while ((FieldInfo.uLangData.pAuxChinese->pbKeyBuf[i] != 0x00) &&
  2277.                            (i < FieldInfo.uLangData.pAuxChinese->nKeyBufLen) && (i <= 7))
  2278.                     {
  2279.                         *((U16*) (output_string + out)) = StrokeInternalToUnicode(FieldInfo.uLangData.pAuxChinese->pbKeyBuf[i]);
  2280.                         out = out + 2;
  2281.                         i = i + 1;
  2282.                     }
  2283.                     break;
  2284.                 default:
  2285.                     break;
  2286.             }
  2287.             *out_len = i;
  2288.             return TRUE;
  2289.         }
  2290.         /* Input String Does not Converted. */
  2291.         memcpy(output_string, input_string, 2);
  2292.         *out_len = 1;
  2293.         return TRUE;
  2294.     }
  2295.     *out_len = 0;
  2296.     return FALSE;
  2297. }
  2298. /*****************************************************************************
  2299.  * FUNCTION
  2300.  *  mmi_phb_generic_quick_search_convert_cache
  2301.  * DESCRIPTION
  2302.  *  This function convert first character of name field into cache.
  2303.  * PARAMETERS
  2304.  *  index       [IN]        Phonebook entry index
  2305.  * RETURNS
  2306.  *  void
  2307.  *****************************************************************************/
  2308. void mmi_phb_generic_quick_search_convert_cache(U16 index)
  2309. {
  2310.     /*----------------------------------------------------------------*/
  2311.     /* Local Variables                                                */
  2312.     /*----------------------------------------------------------------*/
  2313.     T9Event t9EventInput;
  2314.     T9STATUS t9ReturnCodes;
  2315.     /*----------------------------------------------------------------*/
  2316.     /* Code Body                                                      */
  2317.     /*----------------------------------------------------------------*/
  2318.     /* move change language function out from loop to speed up */
  2319.     if (MMI_current_input_mode == INPUT_MODE_MMI_SM_STROKE || MMI_current_input_mode == INPUT_MODE_MMI_TR_STROKE)
  2320.     {
  2321.         t9EventInput.mType = T9EVTSTROKES;
  2322.     }
  2323.     else
  2324.     {
  2325.         t9EventInput.mType = T9EVTSPELLING;
  2326.     }
  2327.     t9EventInput.data.sLDBData.psBuf = (U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name;
  2328.     t9EventInput.data.sLDBData.mCtrlID = 0;
  2329.     t9ReturnCodes = T9HandleEvent(&FieldInfo, &t9EventInput);
  2330.     if (t9ReturnCodes == 0)
  2331.     {
  2332.         switch (MMI_current_input_mode)
  2333.         {
  2334.             case INPUT_MODE_MMI_MULTITAP_BPMF:
  2335.                 g_phb_generic_qsearch_cache[index] = BPMFInternalToUnicode(FieldInfo.uLangData.pAuxChinese->pbSpellBuf[0]);
  2336.                 break;
  2337.             case INPUT_MODE_MMI_MULTITAP_PINYIN:
  2338.                 g_phb_generic_qsearch_cache[index] = FieldInfo.uLangData.pAuxChinese->pbSpellBuf[0];
  2339.                 break;
  2340.             case INPUT_MODE_MMI_SM_STROKE:
  2341.             case INPUT_MODE_MMI_TR_STROKE:
  2342.                 g_phb_generic_qsearch_cache[index] = StrokeInternalToUnicode(FieldInfo.uLangData.pAuxChinese->pbKeyBuf[0]);
  2343.                 break;
  2344.             default:
  2345.                 g_phb_generic_qsearch_cache[index] = *((U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name);
  2346.                 break;
  2347.         }
  2348.     }
  2349.     else
  2350.     {
  2351.         g_phb_generic_qsearch_cache[index] = *((U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name);
  2352.     }
  2353. }
  2354. #endif /* defined(__MMI_T9_V7__) */ 
  2355. #elif defined(__MMI_ZI__)
  2356. /*****************************************************************************
  2357.  * FUNCTION
  2358.  *  mmi_phb_generic_quick_search_convert_to_spelling
  2359.  * DESCRIPTION
  2360.  *  This function is just for template.
  2361.  * PARAMETERS
  2362.  *  input_string        [?]             
  2363.  *  output_string       [?]             
  2364.  *  out_len             [?]             
  2365.  *  a(?)                [IN/OUT]        First variable, used as returns
  2366.  *  b(?)                [IN]            Second variable
  2367.  * RETURNS
  2368.  *  the description of return value, if any.
  2369.  *****************************************************************************/
  2370. BOOL mmi_phb_generic_quick_search_convert_to_spelling(U8 *input_string, U8 *output_string, U8 *out_len)
  2371. {
  2372.     /*----------------------------------------------------------------*/
  2373.     /* Local Variables                                                */
  2374.     /*----------------------------------------------------------------*/
  2375.     S8 out = 0;
  2376.     U8 i = 0;
  2377.     U16 code;
  2378.     U16 mode;
  2379.     U16 pCharInfoBuffer[MMI_PHB_CONVERT_BUFF_ZI];
  2380.     U16 CharInfo;
  2381.     /*----------------------------------------------------------------*/
  2382.     /* Code Body                                                      */
  2383.     /*----------------------------------------------------------------*/
  2384.     /* Change convert mode according to input method. */
  2385.     switch (MMI_current_input_mode)
  2386.     {
  2387.         case INPUT_MODE_MMI_MULTITAP_BPMF:
  2388.             /* mode = ZI8_GETMODE_BOPOMOFO; */
  2389.             mode = ZI8_GETMODE_BOPOMOFO_NAME;
  2390.             break;
  2391.         case INPUT_MODE_MMI_MULTITAP_PINYIN:
  2392.             /* mode = ZI8_GETMODE_PINYIN; */
  2393.             mode = ZI8_GETMODE_PINYIN_NAME;
  2394.             break;
  2395.         case INPUT_MODE_MMI_SM_STROKE:
  2396.         case INPUT_MODE_MMI_TR_STROKE:
  2397.             mode = ZI8_GETMODE_STROKES;
  2398.             break;
  2399.         default:
  2400.             return FALSE;
  2401.             break;
  2402.     }
  2403.     if (input_string[0] != 0 || input_string[1] != 0)
  2404.     {
  2405.         memcpy(&code, input_string, 2);
  2406.         if ((code >= 0x4e00) && (code <= 0x9fa5) &&
  2407.             Zi8GetCharInfo(code, (U16*) pCharInfoBuffer, MMI_PHB_CONVERT_BUFF_ZI, mode))
  2408.         {
  2409.             switch (MMI_current_input_mode)
  2410.             {
  2411.                 case INPUT_MODE_MMI_MULTITAP_BPMF:
  2412.                     /* Do not convert tone */
  2413.                     while ((pCharInfoBuffer[i] != 0x0000) &&
  2414.                            ((pCharInfoBuffer[i] < 0xf431) || (pCharInfoBuffer[i] > 0xf435)))
  2415.                     {
  2416.                         CharInfo = pCharInfoBuffer[i] - ZI8_BASE_BPMF + 0x3105;
  2417.                         memcpy(output_string + out, &CharInfo, 2);
  2418.                         out = out + 2;
  2419.                         i = i + 1;
  2420.                     }
  2421.                     break;
  2422.                 case INPUT_MODE_MMI_MULTITAP_PINYIN:
  2423.                     /* Do not convert tone */
  2424.                     while ((pCharInfoBuffer[i] != 0x0000) &&
  2425.                            ((pCharInfoBuffer[i] < 0xf431) || (pCharInfoBuffer[i] > 0xf435)))