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

MTK

开发平台:

C/C++

  1. #endif /* defined(__MMI_PHB_NAME_LIST_FILTER__) */
  2. /*****************************************************************************
  3.  * FUNCTION
  4.  *  mmi_phb_list_pre_entry_second_level
  5.  * DESCRIPTION
  6.  *  This function provide call back function before enter phonebook list
  7.  * PARAMETERS
  8.  *  void
  9.  * RETURNS
  10.  *  void
  11.  *****************************************************************************/
  12. void mmi_phb_list_pre_entry_second_level(void)
  13. {
  14.     /*----------------------------------------------------------------*/
  15.     /* Local Variables                                                */
  16.     /*----------------------------------------------------------------*/
  17.     /*----------------------------------------------------------------*/
  18.     /* Code Body                                                      */
  19.     /*----------------------------------------------------------------*/
  20.     void (*LSKEntryPtr) (void) = NULL;
  21.     void (*SendKeyPtr) (void) = NULL;
  22.     if ((phbListView == MMI_PHB_LIST_FOR_SMS) || (phbListView == MMI_PHB_LIST_FOR_CHAT) ||
  23.         (phbListView == MMI_PHB_LIST_FOR_SMS_SEARCH_NAME))
  24.     {
  25.         LSKEntryPtr = mmi_phb_sms_send_data_choose_entry;
  26.         SendKeyPtr = mmi_phb_sms_send_data_choose_entry;
  27.     }
  28.     else if (phbListView == MMI_PHB_LIST_FOR_CHAT_NO_CHECK)
  29.     {
  30.         LSKEntryPtr = mmi_phb_sms_send_data_for_entry_name_only;
  31.         SendKeyPtr = mmi_phb_sms_send_data_for_entry_name_only;
  32.     }
  33.     else if (phbListView == MMI_PHB_LIST_FOR_SPEED_DIAL)
  34.     {
  35.         LSKEntryPtr = PhbSetSpeedDialFormList;
  36.     }
  37. #if defined(OBIGO_SUPPORT) && defined(MMS_SUPPORT)
  38.     else if (phbListView == MMI_PHB_LIST_FOR_MMS_ALL)
  39.     {
  40.         LSKEntryPtr = mmi_phb_entry_mms_choose_number;
  41.     }
  42. #endif /* defined(OBIGO_SUPPORT) && defined(MMS_SUPPORT) */ 
  43.     else if (phbListView == MMI_PHB_LIST_FOR_ALL_SHARED)
  44.     {
  45.         LSKEntryPtr = mmi_phb_generic_enter_list_result;
  46.     }
  47.     if (phbListView != MMI_PHB_LIST_FOR_SMS_SEARCH_NAME)
  48.     {
  49.         g_phb_cntx.highlight_entry = 0;
  50.     }
  51. #if defined(__MMI_EMAIL__)
  52.     if (phbListView == MMI_PHB_LIST_FOR_EMAIL_APP)
  53.     {
  54.         U16 i;
  55.         U16 EntryCount = 0;
  56.         U16 store_index;
  57.         /* Allocate buffer for phonebook memeber list filter */
  58.         mmi_phb_list_allocate_filter();
  59.         /* Build list according to filter */
  60.         for (i = 0; i < PhoneBookEntryCount; i++)
  61.         {
  62.             store_index = g_phb_name_index[i];
  63.             if (PhoneBook[store_index].field & MMI_PHB_ENTRY_FIELD_EMAIL)
  64.             {
  65.                 g_phb_cntx.list_filter[EntryCount] = store_index;
  66.                 EntryCount++;
  67.             }
  68.         }
  69.         if (EntryCount)
  70.         {
  71.             mmi_phb_entry_list(
  72.                 EntryCount,                                 /* Total Entry */
  73.                 STR_SCR_PBOOK_VIEW_CAPTION,                 /* Title String */
  74.                 IMG_SCR_PBOOK_CAPTION,                      /* Title Image */
  75.                 STR_GLOBAL_OK,                              /* LSK */
  76.                 IMG_GLOBAL_OK,                              /* LSK */
  77.                 mmi_phb_get_index_by_store_location_second, /* Highlight Callback */
  78.                 mmi_phb_email_choose_entry,                 /* LSK Callback */
  79.                 mmi_phb_email_choose_entry,                 /* SEND Key Callback */
  80.                 mmi_phb_filter_list_get_item,               /* List Callback */
  81.                 mmi_phb_filter_list_get_hint,               /* Hint Callback */
  82.                 mmi_phb_list_pre_entry_second_level,        /* Re-Entry Callback */
  83.                 TRUE,                                       /* Alpha Index */
  84.                 TRUE);                                      /* Right Arrow Key */
  85.         }
  86.         else
  87.         {
  88.             DisplayPopup(
  89.                 (PU8) GetString(STR_ID_PHB_NO_ENTRY_TO_SELECT),
  90.                 IMG_GLOBAL_EMPTY,
  91.                 TRUE,
  92.                 PHB_NOTIFY_TIMEOUT,
  93.                 EMPTY_LIST_TONE);
  94.             mmi_phb_list_free_filter();
  95.         }
  96.     }
  97.     else
  98. #endif /* defined(__MMI_EMAIL__) */ 
  99.         mmi_phb_entry_list(
  100.             PhoneBookEntryCount,                    /* Total Entry */
  101.             STR_SCR_PBOOK_VIEW_CAPTION,             /* Title String */
  102.             IMG_SCR_PBOOK_CAPTION,                  /* Title Image */
  103.             STR_GLOBAL_OK,                          /* LSK */
  104.             IMG_GLOBAL_OK,                          /* LSK */
  105.             mmi_phb_get_index_second_level,         /* Highlight Callback */
  106.             LSKEntryPtr,                            /* LSK Callback */
  107.             SendKeyPtr,                             /* SEND Key Callback */
  108.             mmi_phb_list_get_item,                  /* List Callback */
  109.             mmi_phb_list_get_hint,                  /* Hint Callback */
  110.             mmi_phb_list_pre_entry_second_level,    /* Re-Entry Callback */
  111.             TRUE,                                   /* Alpha Index */
  112.             TRUE);                                  /* Right Arrow Key */
  113. }
  114. /*****************************************************************************
  115.  * FUNCTION
  116.  *  mmi_phb_list_pre_entry_for_fmgr_in_nvram
  117.  * DESCRIPTION
  118.  *  This function provide call back function before enter phonebook list
  119.  * PARAMETERS
  120.  *  void
  121.  * RETURNS
  122.  *  void
  123.  *****************************************************************************/
  124. #if defined(__MMI_FILE_MANAGER__)
  125. void mmi_phb_list_pre_entry_for_fmgr_in_nvram(void)
  126. {
  127.     /*----------------------------------------------------------------*/
  128.     /* Local Variables                                                */
  129.     /*----------------------------------------------------------------*/
  130.     U16 i;
  131.     U16 EntryCount = 0;
  132.     U16 store_index;
  133.     /*----------------------------------------------------------------*/
  134.     /* Code Body                                                      */
  135.     /*----------------------------------------------------------------*/
  136.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_list_pre_entry_for_fmgr_in_nvram.>n",
  137.                          __FILE__, __LINE__));
  138.     if (!g_phb_cntx.phb_ready || g_phb_cntx.processing)
  139.     {
  140.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  141.     }
  142. #ifdef __SYNCML_SUPPORT__
  143.     else if (mmi_syncml_is_phb_sync_now())
  144.     {
  145.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  146.     }
  147. #endif /* __SYNCML_SUPPORT__ */
  148.     else
  149.     {
  150.         /* Allocate buffer for phonebook memeber list filter */
  151.         mmi_phb_list_allocate_filter();
  152.         /* Find out entry in NVRAM and put it into filter list */
  153.         for (i = 0; i < PhoneBookEntryCount; i++)
  154.         {
  155.             store_index = g_phb_name_index[i];
  156.             if (store_index < MAX_PB_PHONE_ENTRIES)
  157.             {
  158.                 g_phb_cntx.list_filter[EntryCount] = store_index;
  159.                 EntryCount++;
  160.             }
  161.         }
  162.         if (EntryCount)
  163.         {
  164.             g_phb_cntx.highlight_entry = 0;
  165.             mmi_phb_entry_list(
  166.                 EntryCount,                                 /* Total Entry */
  167.                 STR_SCR_PBOOK_VIEW_CAPTION,                 /* Title String */
  168.                 IMG_SCR_PBOOK_CAPTION,                      /* Title Image */
  169.                 STR_GLOBAL_OK,                              /* LSK */
  170.                 IMG_GLOBAL_OK,                              /* LSK */
  171.                 mmi_phb_get_index_by_store_location,        /* Highlight Callback */
  172.                 mmi_phb_fmgr_pre_edit_entry,                /* LSK Callback */
  173.                 NULL,                                       /* SEND Key Callback */
  174.                 mmi_phb_filter_list_get_item,               /* List Callback */
  175.                 mmi_phb_filter_list_get_hint,               /* Hint Callback */
  176.                 mmi_phb_list_pre_entry_for_fmgr_in_nvram,   /* Re-Entry Callback */
  177.                 FALSE,                                      /* Alpha Index */
  178.                 TRUE);                                      /* Right Arrow Key */
  179.         }
  180.         else
  181.         {
  182.             DisplayPopup(
  183.                 (PU8) GetString(STR_ID_PHB_NO_ENTRY_TO_SELECT),
  184.                 IMG_GLOBAL_EMPTY,
  185.                 TRUE,
  186.                 PHB_NOTIFY_TIMEOUT,
  187.                 EMPTY_LIST_TONE);
  188.             mmi_phb_list_free_filter();
  189.         }
  190.     }
  191. }
  192. #endif /* defined(__MMI_FILE_MANAGER__) */ 
  193. /*****************************************************************************
  194.  * FUNCTION
  195.  *  mmi_phb_list_pre_delete_one_by_one
  196.  * DESCRIPTION
  197.  *  This function provide call back function before enter phonebook list
  198.  * PARAMETERS
  199.  *  void
  200.  * RETURNS
  201.  *  void
  202.  *****************************************************************************/
  203. void mmi_phb_list_pre_delete_one_by_one(void)
  204. {
  205.     /*----------------------------------------------------------------*/
  206.     /* Local Variables                                                */
  207.     /*----------------------------------------------------------------*/
  208.     /*----------------------------------------------------------------*/
  209.     /* Code Body                                                      */
  210.     /*----------------------------------------------------------------*/
  211.     phbListView = MMI_PHB_LIST_FOR_DELETE_ONE_BY_ONE;
  212.     g_phb_cntx.highlight_entry = 0;
  213.     g_phb_highlight_alpha = 0;
  214.     mmi_phb_entry_list(
  215.         PhoneBookEntryCount,                /* Total Entry */
  216.         STR_SCR_PBOOK_VIEW_CAPTION,         /* Title String */
  217.         IMG_SCR_PBOOK_CAPTION,              /* Title Image */
  218.         STR_GLOBAL_DELETE,                  /* LSK */
  219.         0,                                  /* IMAGE LSK */
  220.         mmi_phb_get_index,                  /* Highlight Callback */
  221.         mmi_phb_entry_op_delete_confirm,    /* LSK Callback */
  222.         NULL,                               /* SEND Key Callback */
  223.         mmi_phb_list_get_item,              /* List Callback */
  224.         mmi_phb_list_get_hint,              /* Hint Callback */
  225.         mmi_phb_list_pre_delete_one_by_one, /* Re-Entry Callback */
  226.         TRUE,                               /* Alpha Index */
  227.         FALSE);                             /* Right Arrow Key */
  228. }
  229. #ifdef __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__
  230. static S32 phb_numbers[MMI_PHB_MAX_NUMBER_COUNT];
  231. static S32 phb_total_number_present;
  232. static U8 current_highligted_item = 0;
  233. /*****************************************************************************
  234.  * FUNCTION
  235.  *  mmi_phb_inline_display_style
  236.  * DESCRIPTION
  237.  *  Returns the display style for the phonebook list(will return INLINE SELECT style always)
  238.  * PARAMETERS
  239.  *  item_index      [IN]        Actual index of the menuitem in the list
  240.  * RETURNS
  241.  *  U8 display style     TWO_LINE_MENUITEM_STYLE_DISPLAY_HORIZONTAL_SELECT
  242.  *****************************************************************************/
  243. U8 mmi_phb_inline_display_style(S32 item_index)
  244. {
  245.     /*----------------------------------------------------------------*/
  246.     /* Local Variables                                                */
  247.     /*----------------------------------------------------------------*/
  248.     S16 pError;
  249.     U16 store_index;
  250.     U8 entries_present = 0;
  251.     U8 pic_index;
  252.     /*----------------------------------------------------------------*/
  253.     /* Code Body                                                      */
  254.     /*----------------------------------------------------------------*/
  255.     store_index = g_phb_name_index[item_index];
  256.     mmi_phb_convert_get_ucs2_number(pbNumber, store_index);
  257.     if (store_index < MAX_PB_PHONE_ENTRIES) /* in NVRAM */
  258.     {
  259.         /*
  260.          * The view field array doesn't have two mandatory fields 
  261.          * * #define MAX_PB_MANDATORY_FIELDS   2
  262.          * * #define MAX_PB_VIEW_FIELDS        (MMI_PHB_FIELD_TOTAL - MAX_PB_MANDATORY_FIELDS) 
  263.          * * View Fields Array [MAX_PB_VIEW_FIELDS] 
  264.          * * MMI_PHB_FIELD_ORDER_ENUM has those 2 mandatory fields
  265.          * * so have to deduct MAX_PB_MANDATORY_FIELDS to arrive at the right index.
  266.          */
  267.         ReadRecord(
  268.             NVRAM_EF_PHB_FIELDS_LID,
  269.             (U16) (store_index + 1),
  270.             (void*)&PhoneBookOptionalFields,
  271.             OPTIONAL_FIELDS_RECORD_SIZE,
  272.             &pError);
  273.         mmi_phb_read_optional_ids(store_index);
  274.         if (*pbNumber)
  275.         {
  276.             ++entries_present;
  277.         }
  278.         if (g_phb_cntx.view_field[MMI_PHB_FIELD_HOME - MAX_PB_MANDATORY_FIELDS] && *PhoneBookOptionalFields.homeNumber)
  279.         {
  280.             ++entries_present;
  281.         }
  282.         if (g_phb_cntx.view_field[MMI_PHB_FIELD_OFFICE - MAX_PB_MANDATORY_FIELDS] &&
  283.             *PhoneBookOptionalFields.officeNumber)
  284.         {
  285.             ++entries_present;
  286.         }
  287.         if (g_phb_cntx.view_field[MMI_PHB_FIELD_FAX - MAX_PB_MANDATORY_FIELDS] && *PhoneBookOptionalFields.faxNumber)
  288.         {
  289.             ++entries_present;
  290.         }
  291.         pic_index = mmi_phb_get_image_index(((PHB_OPTIONAL_IDS_STRUCT*) g_phb_cntx.optional_ids)->pictureTagID);
  292.         if (g_phb_cntx.view_field[MMI_PHB_FIELD_PIC - MAX_PB_MANDATORY_FIELDS] &&    pic_index != 0)
  293.         {
  294.             if ((entries_present >= 1) || (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name)))
  295.             {
  296.                 return TWO_LINE_MENUITEM_STYLE_DISPLAY_HORIZONTAL_SELECT;
  297.             }
  298.         }
  299.         else
  300.         {
  301.             if ((entries_present > 1) ||
  302.                 (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name) && (entries_present >= 1)))
  303.             {
  304.                 return TWO_LINE_MENUITEM_STYLE_DISPLAY_HORIZONTAL_SELECT;
  305.             }
  306.         }
  307.     }
  308.     else
  309.     {
  310.         if (*pbNumber && (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name)))
  311.         {
  312.             return TWO_LINE_MENUITEM_STYLE_DISPLAY_HORIZONTAL_SELECT;
  313.         }
  314.     }
  315.     return 0;
  316. }
  317. /*****************************************************************************
  318.  * FUNCTION
  319.  *  mmi_phb_inline_default_value
  320.  * DESCRIPTION
  321.  *  Returns the default inline item to be shown with the entry(Only phone
  322.  *  numbers to be considered)
  323.  * PARAMETERS
  324.  *  item_index      [IN]        Actual index of the menuitem in the list
  325.  * RETURNS
  326.  *  S32
  327.  *****************************************************************************/
  328. S32 mmi_phb_inline_default_value(S32 item_index)
  329. {
  330.     /*----------------------------------------------------------------*/
  331.     /* Local Variables                                                */
  332.     /*----------------------------------------------------------------*/
  333.     /*----------------------------------------------------------------*/
  334.     /* Code Body                                                      */
  335.     /*----------------------------------------------------------------*/
  336.     return current_highligted_item;
  337. }
  338. /*****************************************************************************
  339.  * FUNCTION
  340.  *  mmi_phb_two_line_send_key_handler
  341.  * DESCRIPTION
  342.  *  This is the send key handler in case of two line menu item in phone book
  343.  * PARAMETERS
  344.  *  void
  345.  *  Input: NONE(?)
  346.  * RETURNS
  347.  *  void
  348.  *****************************************************************************/
  349. void mmi_phb_two_line_send_key_handler(void)
  350. {
  351.     /*----------------------------------------------------------------*/
  352.     /* Local Variables                                                */
  353.     /*----------------------------------------------------------------*/
  354.     U16 store_index;
  355.     U8 number_to_dial = 0;
  356.     UI_string_type dialing_number[MAX_PB_NUMBER_LENGTH + 1 + 1];
  357.     /*----------------------------------------------------------------*/
  358.     /* Code Body                                                      */
  359.     /*----------------------------------------------------------------*/
  360.     store_index = g_phb_name_index[g_phb_cntx.active_index];
  361.     while (phb_numbers[number_to_dial] != current_highligted_item + 1 && number_to_dial <= MMI_PHB_MAX_NUMBER_COUNT)
  362.     {
  363.         ++number_to_dial;
  364.     }
  365. #if defined(__IP_NUMBER__)
  366.     SetTempUseIPNumber(FALSE);
  367. #endif 
  368.     switch (number_to_dial)
  369.     {
  370.         case MMI_PHB_MOBILE_NUMBER:
  371.             mmi_phb_convert_get_ucs2_number(pbNumber, store_index);
  372.             g_phb_cntx.dial_from_list = MMI_PHB_PHONEBOOK;
  373.             MakeCall((PS8) pbNumber);
  374.             break;
  375.         case MMI_PHB_HOME_NUMBER:
  376.             AnsiiToUnicodeString((S8*) dialing_number, (S8*) PhoneBookOptionalFields.homeNumber);
  377.             g_phb_cntx.dial_from_list = MMI_PHB_PHONEBOOK;
  378.             MakeCall((PS8) dialing_number);
  379.             break;
  380.         case MMI_PHB_OFFICE_NUMBER:
  381.             AnsiiToUnicodeString((S8*) dialing_number, (PS8) PhoneBookOptionalFields.officeNumber);
  382.             g_phb_cntx.dial_from_list = MMI_PHB_PHONEBOOK;
  383.             MakeCall((PS8) dialing_number);
  384.             break;
  385.         case MMI_PHB_FAX_NUMBER:
  386.             AnsiiToUnicodeString((S8*) dialing_number, (PS8) PhoneBookOptionalFields.faxNumber);
  387.             g_phb_cntx.dial_from_list = MMI_PHB_PHONEBOOK;
  388.             MakeCall((PS8) dialing_number);
  389.             break;
  390.         default:
  391.             if (store_index >= MAX_PB_PHONE_ENTRIES)    /* Entry in SIM */
  392.             {
  393.                 mmi_phb_convert_get_ucs2_number(pbNumber, store_index); /* BCD number format. */
  394.                 if (pfnUnicodeStrlen(pbNumber))
  395.                 {
  396.                     g_phb_cntx.dial_from_list = MMI_PHB_PHONEBOOK;
  397.                     MakeCall((PS8) pbNumber);
  398.                     break;
  399.                 }
  400.             }
  401.             DisplayPopup(
  402.                 (PU8) GetString(STR_NO_NUMBER_TO_DIAL),
  403.                 IMG_GLOBAL_ERROR,
  404.                 FALSE,
  405.                 PHB_NOTIFY_TIMEOUT,
  406.                 ERROR_TONE);
  407.             break;
  408.     }
  409. }
  410. /*****************************************************************************
  411.  * FUNCTION
  412.  *  mmi_phb_inline_select_data
  413.  * DESCRIPTION
  414.  *  This function sets the relevant data for the phonebook entry
  415.  * PARAMETERS
  416.  *  item_index              [IN]        Menuitem index
  417.  *  inline_item_index       [IN]        Inline item index
  418.  *  str_buff                [IN]        Inline Item String to be shown
  419.  *  img_buff_p              [?]         Image to be shown with the inline item
  420.  *  thumbnail               [?]         Thumbnail picture to be shown with the inline item
  421.  * RETURNS
  422.  *  S32
  423.  *****************************************************************************/
  424. pBOOL mmi_phb_inline_select_data(
  425.         S32 item_index,
  426.         S32 inline_item_index,
  427.         UI_string_type str_buff,
  428.         PU8 *img_buff_p,
  429.         wgui_thumbnail_image_union *thumbnail)
  430. {
  431.     /*----------------------------------------------------------------*/
  432.     /* Local Variables                                                */
  433.     /*----------------------------------------------------------------*/
  434.     U16 store_index;
  435.     S16 next_phb_number_index = 0;
  436.     pBOOL val = FALSE;
  437.     /*----------------------------------------------------------------*/
  438.     /* Code Body                                                      */
  439.     /*----------------------------------------------------------------*/
  440.     store_index = g_phb_name_index[item_index];
  441.     current_highligted_item = inline_item_index;
  442.     while (phb_numbers[next_phb_number_index] != (inline_item_index + 1) &&
  443.            next_phb_number_index <= MMI_PHB_MAX_NUMBER_COUNT)
  444.     {
  445.         next_phb_number_index++;
  446.     }
  447.     if (!phb_total_number_present)
  448.     {
  449.         next_phb_number_index = -1;
  450.     }
  451.     switch (next_phb_number_index)
  452.     {
  453.         case MMI_PHB_MOBILE_NUMBER:
  454.             mmi_phb_convert_get_ucs2_number(pbNumber, store_index);
  455.             pfnUnicodeStrcpy((S8*) str_buff, (S8*) & pbNumber);
  456.             *img_buff_p = get_image((U16) (IMG_MOBILE_NUMBER));
  457.             val = TRUE;
  458.             break;
  459.         case MMI_PHB_HOME_NUMBER:
  460.             AnsiiToUnicodeString((S8*) str_buff, (S8*) PhoneBookOptionalFields.homeNumber);
  461.             *img_buff_p = get_image((U16) (IMG_HOME_NUMBER));
  462.             val = TRUE;
  463.             break;
  464.         case MMI_PHB_OFFICE_NUMBER:
  465.             AnsiiToUnicodeString((S8*) str_buff, (PS8) PhoneBookOptionalFields.officeNumber);
  466.             *img_buff_p = get_image((U16) (IMG_OFFICE_NUMBER));
  467.             val = TRUE;
  468.             break;
  469.         case MMI_PHB_FAX_NUMBER:
  470.             AnsiiToUnicodeString((S8*) str_buff, (PS8) PhoneBookOptionalFields.faxNumber);
  471.             *img_buff_p = get_image((U16) (IMG_FAX_NUMBER));
  472.             val = TRUE;
  473.             break;
  474.         default:
  475.             *img_buff_p = get_image((U16) UI_NULL_IMAGE);
  476.             AnsiiToUnicodeString((S8*) str_buff, (PS8) "");
  477.             val = TRUE;
  478.             break;
  479.     }
  480.     if (((PHB_OPTIONAL_IDS_STRUCT*) g_phb_cntx.optional_ids)->pictureTagID == 1)
  481.     {
  482.         thumbnail->path = mmi_phb_image_get_path_from_id((U16) (store_index + 1));
  483.     }
  484.     else
  485.     {
  486.         thumbnail->id = ((PHB_OPTIONAL_IDS_STRUCT*) g_phb_cntx.optional_ids)->pictureTagID;
  487.     }
  488.     return val;
  489. }
  490. /*****************************************************************************
  491.  * FUNCTION
  492.  *  mmi_phb_inline_select_done
  493.  * DESCRIPTION
  494.  *  Sets highlighted item to zero always
  495.  * PARAMETERS
  496.  *  menuitem_index      [IN]        Actual index of the menuitem in the list
  497.  *  selected_index      [IN]        Inline item currently selected
  498.  *****************************************************************************/
  499. void mmi_phb_inline_select_done(S32 menuitem_index, S32 selected_index)
  500. {
  501.     /*----------------------------------------------------------------*/
  502.     /* Local Variables                                                */
  503.     /*----------------------------------------------------------------*/
  504.     /*----------------------------------------------------------------*/
  505.     /* Code Body                                                      */
  506.     /*----------------------------------------------------------------*/
  507.     current_highligted_item = 0;
  508. }
  509. /*****************************************************************************
  510.  * FUNCTION
  511.  *  mmi_phb_inline_menuitem_properties
  512.  * DESCRIPTION
  513.  *  This function is used to get the properties of the selected menu item
  514.  * PARAMETERS
  515.  *  index                           [IN]        Menu item index
  516.  *  current_menuitem_properties     [?]         Structure to be filled for menuitem properties
  517.  * RETURNS
  518.  *  U8(?)
  519.  *****************************************************************************/
  520. void mmi_phb_inline_menuitem_properties(int index, wgui_two_line_menuitem_struct *current_menuitem_properties)
  521. {
  522.     /*----------------------------------------------------------------*/
  523.     /* Local Variables                                                */
  524.     /*----------------------------------------------------------------*/
  525.     U16 store_index;
  526.     S16 number_count = 0;
  527.     S16 entry_count = 0;
  528.     U8 pic_index;
  529.     /*----------------------------------------------------------------*/
  530.     /* Code Body                                                      */
  531.     /*----------------------------------------------------------------*/
  532.     store_index = g_phb_name_index[index];
  533.     current_menuitem_properties->image_flags = UI_TWO_LINE_MENUITEM_NO_THUMBNAIL;
  534.     if (store_index < MAX_PB_PHONE_ENTRIES) /* in NVRAM */
  535.     {
  536.         pic_index = mmi_phb_get_image_index(((PHB_OPTIONAL_IDS_STRUCT*) g_phb_cntx.optional_ids)->pictureTagID);
  537.         if (g_phb_cntx.view_field[MMI_PHB_FIELD_PIC - MAX_PB_MANDATORY_FIELDS])
  538.         {
  539.             current_menuitem_properties->image_flags |= UI_TWO_LINE_MENUITEM_LEFT_ALIGN_THUMBNAIL;
  540.             if (((PHB_OPTIONAL_IDS_STRUCT*) g_phb_cntx.optional_ids)->pictureTagID == 1)
  541.             {
  542.                 current_menuitem_properties->image_flags |= UI_TWO_LINE_MENUITEM_THUMBNAIL_IS_FILE;
  543.             }
  544.             else if (pic_index)
  545.             {
  546.                 current_menuitem_properties->image_flags |= UI_TWO_LINE_MENUITEM_THUMBNAIL_IS_ID;
  547.             }
  548.             else
  549.             {
  550.                 current_menuitem_properties->image_flags = UI_TWO_LINE_MENUITEM_NO_THUMBNAIL;
  551.             }
  552.         }
  553.         else
  554.         {
  555.             current_menuitem_properties->image_flags |= UI_TWO_LINE_MENUITEM_NO_THUMBNAIL;
  556.         }
  557.     }
  558.     memset(phb_numbers, 0, sizeof(phb_numbers));
  559.     mmi_phb_convert_get_ucs2_number(pbNumber, store_index);
  560.     /* entry_count signifies the array entry,number_count corresponds to the index of the phone number */
  561.     if (*pbNumber)
  562.     {
  563.         number_count++;
  564.         phb_numbers[entry_count] = number_count;
  565.     }
  566.     /*
  567.      * The view field array doesn't have two mandatory fields 
  568.      * * #define MAX_PB_MANDATORY_FIELDS   2
  569.      * * #define MAX_PB_VIEW_FIELDS        (MMI_PHB_FIELD_TOTAL - MAX_PB_MANDATORY_FIELDS) 
  570.      * * View Fields Array [MAX_PB_VIEW_FIELDS] 
  571.      * * MMI_PHB_FIELD_ORDER_ENUM has those 2 mandatory fields
  572.      * * so have to deduct MAX_PB_MANDATORY_FIELDS to arrive at the right index.
  573.      */
  574.     if (store_index < MAX_PB_PHONE_ENTRIES)
  575.     {
  576.         entry_count++;
  577.         if (g_phb_cntx.view_field[MMI_PHB_FIELD_HOME - MAX_PB_MANDATORY_FIELDS] && *PhoneBookOptionalFields.homeNumber)
  578.         {
  579.             number_count++;
  580.             phb_numbers[entry_count] = number_count;
  581.         }
  582.         entry_count++;
  583.         if (g_phb_cntx.view_field[MMI_PHB_FIELD_OFFICE - MAX_PB_MANDATORY_FIELDS] &&
  584.             *PhoneBookOptionalFields.officeNumber)
  585.         {
  586.             number_count++;
  587.             phb_numbers[entry_count] = number_count;
  588.         }
  589.         entry_count++;
  590.         if (g_phb_cntx.view_field[MMI_PHB_FIELD_FAX - MAX_PB_MANDATORY_FIELDS] && *PhoneBookOptionalFields.faxNumber)
  591.         {
  592.             number_count++;
  593.             phb_numbers[entry_count] = number_count;
  594.         }
  595.     }
  596.     phb_total_number_present = number_count;
  597.     current_menuitem_properties->num_of_items = phb_total_number_present;
  598.     current_menuitem_properties->defualt_value_callback = mmi_phb_inline_default_value;
  599.     current_menuitem_properties->complete_callback = mmi_phb_inline_select_done;
  600.     current_menuitem_properties->two_line_data_callback.get_data_for_horizontal_select = mmi_phb_inline_select_data;
  601. }
  602. #endif /* __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__ */ 
  603. /*****************************************************************************
  604.  * FUNCTION
  605.  *  mmi_phb_entry_list
  606.  * DESCRIPTION
  607.  *  This function is for entering phonebook entry List
  608.  * PARAMETERS
  609.  *  EntryCount          [IN]        
  610.  *  STR_TITLE           [IN]        
  611.  *  IMG_TITLE           [IN]        
  612.  *  STR_LSK             [IN]        
  613.  *  IMG_LSK             [IN]        
  614.  *  HighlightPtr        [IN]        
  615.  *  LSKPtr              [IN]        
  616.  *  SendKeyPtr          [IN]        
  617.  *  ItemPtr             [IN]        
  618.  *  HintPtr             [IN]        
  619.  *  EntryPtr            [IN]        
  620.  *  alpha_index         [IN]        
  621.  *  right_arrow         [IN]        
  622.  * RETURNS
  623.  *  void
  624.  *****************************************************************************/
  625. void mmi_phb_entry_list(
  626.         U16 EntryCount,
  627.         U16 STR_TITLE,
  628.         U16 IMG_TITLE,
  629.         U16 STR_LSK,
  630.         U16 IMG_LSK,
  631.         void (*HighlightPtr) (S32),
  632.         FunctionPtr LSKPtr,
  633.         FunctionPtr SendKeyPtr,
  634.         GetItemPtr ItemPtr,
  635.         GetHintPtr HintPtr,
  636.         FunctionPtr EntryPtr,
  637.         BOOL alpha_index,
  638.         BOOL right_arrow)
  639. {
  640.     /*----------------------------------------------------------------*/
  641.     /* Local Variables                                                */
  642.     /*----------------------------------------------------------------*/
  643.     U8 *guiBuffer;
  644.     /*----------------------------------------------------------------*/
  645.     /* Code Body                                                      */
  646.     /*----------------------------------------------------------------*/
  647.     /* Check if it can be list first */
  648.     if (!g_phb_cntx.phb_ready || g_phb_cntx.processing)
  649.     {
  650.         mmi_phb_list_free_filter();
  651.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  652.         return;
  653.     }
  654. #ifdef __SYNCML_SUPPORT__
  655.     else if (mmi_syncml_is_phb_sync_now())
  656.     {
  657.         mmi_phb_list_free_filter();
  658.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  659.         return;
  660.     }
  661. #endif /* __SYNCML_SUPPORT__ */
  662.     else if (PhoneBookEntryCount == 0)
  663.     {
  664.         mmi_phb_list_free_filter();
  665.         DisplayPopup(
  666.             (PU8) GetString(STR_NO_ENTRIES_MESSAGE),
  667.             IMG_GLOBAL_EMPTY,
  668.             TRUE,
  669.             PHB_NOTIFY_TIMEOUT,
  670.             EMPTY_LIST_TONE);
  671.         return;
  672.     }
  673.     /* Check if phonebook entry has been updated, and if need to use alpha_index function. */
  674.     if (g_phb_cntx.refresh_list && alpha_index)
  675.     {
  676.         mmi_phb_list_build_alpha_index(NULL, 0, TRUE, MMI_STORAGE_NONE);
  677.         g_phb_cntx.refresh_list = MMI_PHB_ENTRY_NO_CHANGE;
  678.     }
  679.     EntryNewScreen(SCR_PBOOK_LIST, mmi_phb_exit_list, EntryPtr, NULL);
  680.     guiBuffer = GetCurrGuiBuffer(SCR_PBOOK_LIST);
  681. #ifdef __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__
  682.     if (!guiBuffer)
  683.     {
  684.         current_highligted_item = 0;
  685.     }
  686. #endif /* __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__ */ 
  687.     if (g_phb_cntx.new_highlight_entry < 0xffff)
  688.     {
  689.         change_list_menu_category_history(guiBuffer, g_phb_cntx.new_highlight_entry, EntryCount, 0);
  690.         g_phb_cntx.new_highlight_entry = 0xffff;
  691.     }
  692. #if (defined __MMI_TOUCH_SCREEN__) && (defined __MMI_WGUI_CSK_ENABLE__)
  693.     if (phbListView == MMI_PHB_LIST_FOR_PHB && gInsertSimAppFlag != 1 && mmi_bootup_get_active_flight_mode() != 1)
  694.     {
  695.         EnableCenterSoftkey(0, IMG_CSK_DIAL_ICON);
  696.     }
  697. #endif /* (defined __MMI_TOUCH_SCREEN__) && (defined __MMI_WGUI_CSK_ENABLE__) */ 
  698.     RegisterHighlightHandler(HighlightPtr);
  699. #ifdef __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__
  700.     if (phbListView == MMI_PHB_LIST_FOR_PHB)
  701.     {
  702.         ShowCategory273Screen(
  703.             STR_TITLE,
  704.             IMG_TITLE,
  705.             STR_LSK,
  706.             IMG_LSK,
  707.             STR_GLOBAL_BACK,
  708.             IMG_GLOBAL_BACK,
  709.             EntryCount,
  710.             ItemPtr,
  711.             mmi_phb_inline_display_style,
  712.             mmi_phb_inline_menuitem_properties,
  713.             g_phb_cntx.highlight_entry,
  714.             guiBuffer);
  715.         wgui_register_list_item_selected_callback_all(UI_dummy_function);
  716.     }
  717.     else
  718. #endif /* __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__ */ 
  719.     {
  720.         ShowCategory184Screen(
  721.             STR_TITLE,
  722.             IMG_TITLE,
  723.             STR_LSK,
  724.             IMG_LSK,
  725.             STR_GLOBAL_BACK,
  726.             IMG_GLOBAL_BACK,
  727.             EntryCount,
  728.             ItemPtr,
  729.             HintPtr,
  730.             g_phb_cntx.highlight_entry,
  731.             guiBuffer);
  732.     }
  733.     /* register multi-tap function for fast jump, for full list only */
  734.     if (alpha_index)
  735.     {
  736.         register_multitap_no_draw_key_handlers();
  737.         set_multitap_functions(mmi_phb_list_alpha_index, mmi_phb_list_alpha_index_input_callback);
  738.         change_multitap_mode(0);
  739.     }
  740.     SetLeftSoftkeyFunction(LSKPtr, KEY_EVENT_UP);
  741. #ifdef __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__
  742.     if (phbListView != MMI_PHB_LIST_FOR_PHB)
  743. #endif /* __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__ */ 
  744.     {
  745.         if (right_arrow)
  746.         {
  747.             SetKeyHandler(LSKPtr, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  748.         }
  749.         else
  750.         {
  751.             ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  752.         }
  753.     }
  754.     if (gInsertSimAppFlag != 1 && mmi_bootup_get_active_flight_mode() != 1)
  755.     {
  756.         SetKeyHandler(SendKeyPtr, KEY_SEND, KEY_EVENT_UP);
  757.     #if (defined __MMI_TOUCH_SCREEN__) && (defined __MMI_WGUI_CSK_ENABLE__)
  758.         if (phbListView == MMI_PHB_LIST_FOR_PHB)
  759.         {
  760.             SetCenterSoftkeyFunction(SendKeyPtr, KEY_EVENT_UP);
  761.         }
  762.     #endif /* (defined __MMI_TOUCH_SCREEN__) && (defined __MMI_WGUI_CSK_ENABLE__) */ 
  763.     }
  764.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  765. #ifdef __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__
  766.     if (phbListView != MMI_PHB_LIST_FOR_PHB)
  767. #endif 
  768.     {
  769.         SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  770.     }
  771. #if defined(__IP_NUMBER__) && defined(__MMI_IP_KEY__)   /* For IP Dial Key */
  772. /* under construction !*/
  773. /* under construction !*/
  774. /* under construction !*/
  775. /* under construction !*/
  776. #endif /* defined(__IP_NUMBER__) && defined(__MMI_IP_KEY__) */ 
  777. }
  778. /*****************************************************************************
  779.  * FUNCTION
  780.  *  mmi_phb_exit_list
  781.  * DESCRIPTION
  782.  *  This function is for existing entering phonebook entry List
  783.  * PARAMETERS
  784.  *  void
  785.  * RETURNS
  786.  *  void
  787.  *****************************************************************************/
  788. void mmi_phb_exit_list(void)
  789. {
  790.     /*----------------------------------------------------------------*/
  791.     /* Local Variables                                                */
  792.     /*----------------------------------------------------------------*/
  793.     /*----------------------------------------------------------------*/
  794.     /* Code Body                                                      */
  795.     /*----------------------------------------------------------------*/
  796.     if (g_idle_context.ToNameScrFromIdleApp)
  797.     {
  798.         g_phb_cntx.start_scr_id = SCR_PBOOK_LIST;
  799.     }
  800.     /* Avoid: Entry from Name List and re-entry from MT-> Deflect */
  801.     if (!(phbListView == MMI_PHB_LIST_FOR_CM && 
  802.         g_phb_cntx.start_scr_id == SCR_PBOOK_LIST))
  803.     {
  804.         g_phb_cntx.end_scr_id = SCR_PBOOK_LIST;
  805.     }
  806. #if defined(__MMI_INTELLIGENT_CALL_ALERT__)
  807.     StopTimer(PHB_LIST_SPEAK_NAME_TIMER);
  808.     if (g_phb_is_speaking_name)
  809.     {
  810.         mdi_audio_stop_string();
  811.     }
  812. #endif /* defined(__MMI_INTELLIGENT_CALL_ALERT__) */ 
  813.     reset_multitaps();
  814.     StopTimer(KEYPAD_LOCK_TIMER);
  815. #if defined(__MMI_VRSD_DIAL__)
  816.     StopTimer(VRSD_DIAL_PLAYBACK_TIMER);
  817. #endif
  818. #if defined(__MMI_VRSI__) && defined(__MMI_VRSI_TRAIN_TAG__)
  819.     mmi_phb_vrsi_exit_entry_list();
  820. #endif
  821.     g_idle_context.ToNameScrFromIdleApp = 0;
  822.     g_idle_context.RskPressedFromIdleApp = 0;
  823.     /* Free Member List Filter if exists */
  824.     mmi_phb_list_free_filter();
  825. #if (defined __MMI_TOUCH_SCREEN__) && (defined __MMI_WGUI_CSK_ENABLE__)
  826.     if (gInsertSimAppFlag != 1 && mmi_bootup_get_active_flight_mode() != 1)
  827.     {
  828.         ResetCenterSoftkey();
  829.     }
  830. #endif /* (defined __MMI_TOUCH_SCREEN__) && (defined __MMI_WGUI_CSK_ENABLE__) */ 
  831. }
  832. /*****************************************************************************
  833.  * FUNCTION
  834.  *  mmi_phb_list_get_item
  835.  * DESCRIPTION
  836.  *  
  837.  * PARAMETERS
  838.  *  item_index          [IN]        
  839.  *  str_buff            [IN]        
  840.  *  img_buff_p          [?]         
  841.  *  str_img_mask        [IN]        
  842.  * RETURNS
  843.  *  
  844.  *****************************************************************************/
  845. pBOOL mmi_phb_list_get_item(S32 item_index, UI_string_type str_buff, PU8 *img_buff_p, U8 str_img_mask)
  846. {
  847.     /*----------------------------------------------------------------*/
  848.     /* Local Variables                                                */
  849.     /*----------------------------------------------------------------*/
  850.     U16 store_index;
  851.     /*----------------------------------------------------------------*/
  852.     /* Code Body                                                      */
  853.     /*----------------------------------------------------------------*/
  854.     if ((item_index < 0) || (item_index >= PhoneBookEntryCount))
  855.     {
  856.         return FALSE;
  857.     }
  858.     store_index = g_phb_name_index[item_index];
  859.     if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name))
  860.     {
  861.         pfnUnicodeStrcpy((S8*) str_buff, (S8*) PhoneBook[store_index].alpha_id.name);
  862.     }
  863.     else
  864.     {
  865.         mmi_phb_convert_get_ucs2_number((S8*) str_buff, store_index);
  866.     }
  867.     if (store_index >= MAX_PB_PHONE_ENTRIES)
  868.     {
  869.         *img_buff_p = get_image(IMG_STORAGE_SIM);
  870.     }
  871.     else
  872.     {
  873.         *img_buff_p = get_image(IMG_STORAGE_HANDSET);
  874.     }
  875.     return TRUE;
  876. }
  877. /*****************************************************************************
  878.  * FUNCTION
  879.  *  mmi_phb_list_get_hint
  880.  * DESCRIPTION
  881.  *  
  882.  * PARAMETERS
  883.  *  item_index      [IN]        
  884.  *  hint_array      [?]         
  885.  * RETURNS
  886.  *  
  887.  *****************************************************************************/
  888. S32 mmi_phb_list_get_hint(S32 item_index, UI_string_type *hint_array)
  889. {
  890.     /*----------------------------------------------------------------*/
  891.     /* Local Variables                                                */
  892.     /*----------------------------------------------------------------*/
  893.     U16 store_index;
  894.     S8 temp_number[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
  895.     /*----------------------------------------------------------------*/
  896.     /* Code Body                                                      */
  897.     /*----------------------------------------------------------------*/
  898.     store_index = g_phb_name_index[item_index];
  899.     mmi_phb_convert_get_ucs2_number((S8*) temp_number, store_index);
  900.     if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name) && pfnUnicodeStrlen((S8*) temp_number))
  901.     {
  902.         pfnUnicodeStrcpy((S8*) hint_array[0], (S8*) temp_number);
  903.     }
  904.     else
  905.     {
  906.         return 0;   /* No Hint Data */
  907.     }
  908.     return 1;   /* One hint data only, can be more hints. */
  909. }
  910. #if defined(__MMI_PHB_NAME_LIST_FILTER__)
  911. /*****************************************************************************
  912.  * FUNCTION
  913.  *  mmi_phb_nlf_entry_list
  914.  * DESCRIPTION
  915.  *  This function is for entering phonebook entry list with name list filter 
  916.  * PARAMETERS
  917.  *  EntryCount          [IN]        
  918.  *  STR_TITLE           [IN]        
  919.  *  IMG_TITLE           [IN]        
  920.  *  STR_LSK             [IN]        
  921.  *  IMG_LSK             [IN]        
  922.  *  HighlightPtr        [IN]        
  923.  *  LSKPtr              [IN]        
  924.  *  SendKeyPtr          [IN]        
  925.  *  ItemPtr             [IN]        
  926.  *  HintPtr             [IN]        
  927.  *  EntryPtr            [IN]        
  928.  *  alpha_index         [IN]        
  929.  *  right_arrow         [IN]        
  930.  * RETURNS
  931.  *  void
  932.  *****************************************************************************/
  933. void mmi_phb_nlf_entry_list(
  934.         U16 EntryCount,
  935.         U16 STR_TITLE,
  936.         U16 IMG_TITLE,
  937.         U16 STR_LSK,
  938.         U16 IMG_LSK,
  939.         void (*HighlightPtr) (S32),
  940.         FunctionPtr LSKPtr,
  941.         FunctionPtr SendKeyPtr,
  942.         GetItemPtr ItemPtr,
  943.         GetHintPtr HintPtr,
  944.         FunctionPtr EntryPtr,
  945.         BOOL alpha_index,
  946.         BOOL right_arrow)
  947. {
  948.     /*----------------------------------------------------------------*/
  949.     /* Local Variables                                                */
  950.     /*----------------------------------------------------------------*/
  951.     U8 *guiBuffer;
  952.     /*----------------------------------------------------------------*/
  953.     /* Code Body                                                      */
  954.     /*----------------------------------------------------------------*/
  955.     /* Check if it can be list first */
  956.     if(g_phb_cntx.name_list_filter == MMI_SIM)
  957.     {
  958.         g_phb_list_index_total = g_phb_cntx.sim_used;
  959.     }
  960.     else if(g_phb_cntx.name_list_filter == MMI_NVRAM)
  961.     {
  962.         g_phb_list_index_total = g_phb_cntx.phone_used;
  963.     }
  964.     else
  965.     {
  966.         g_phb_list_index_total = PhoneBookEntryCount;
  967.     }
  968.     
  969.     if (!g_phb_cntx.phb_ready || g_phb_cntx.processing)
  970.     {
  971.         mmi_phb_list_free_filter();
  972.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  973.         return;
  974.     }
  975.     else if (g_phb_list_index_total == 0)
  976.     {
  977.         mmi_phb_list_free_filter();
  978.         DisplayPopup(
  979.             (PU8) GetString(STR_NO_ENTRIES_MESSAGE),
  980.             IMG_GLOBAL_EMPTY,
  981.             TRUE,
  982.             PHB_NOTIFY_TIMEOUT,
  983.             EMPTY_LIST_TONE);
  984.         return;
  985.     }
  986.     /* Check if phonebook entry has been updated, and if need to use alpha_index function. */
  987.     if (g_phb_cntx.refresh_list && alpha_index)
  988.     {
  989.         mmi_phb_list_build_alpha_index(NULL, 0, TRUE, MMI_STORAGE_NONE);
  990.         g_phb_cntx.refresh_list = MMI_PHB_ENTRY_NO_CHANGE;
  991.     }
  992.     EntryNewScreen(SCR_PBOOK_LIST, mmi_phb_exit_list, EntryPtr, NULL);
  993.     guiBuffer = GetCurrGuiBuffer(SCR_PBOOK_LIST);
  994. #ifdef __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__
  995.     if (!guiBuffer)
  996.     {
  997.         current_highligted_item = 0;
  998.     }
  999. #endif /* __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__ */ 
  1000.     if (g_phb_cntx.new_highlight_entry < 0xffff)
  1001.     {
  1002.         change_list_menu_category_history(guiBuffer, g_phb_cntx.new_highlight_entry, EntryCount, 0);
  1003.         g_phb_cntx.new_highlight_entry = 0xffff;
  1004.     }
  1005. #if (defined __MMI_TOUCH_SCREEN__) && (defined __MMI_WGUI_CSK_ENABLE__)
  1006.     if (phbListView == MMI_PHB_LIST_FOR_PHB && gInsertSimAppFlag != 1 && mmi_bootup_get_active_flight_mode() != 1)
  1007.     {
  1008.         EnableCenterSoftkey(0, IMG_CSK_DIAL_ICON);
  1009.     }
  1010. #endif /* (defined __MMI_TOUCH_SCREEN__) && (defined __MMI_WGUI_CSK_ENABLE__) */ 
  1011.     RegisterHighlightHandler(HighlightPtr);
  1012. #ifdef __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__
  1013.     if (phbListView == MMI_PHB_LIST_FOR_PHB)
  1014.     {
  1015.         ShowCategory273Screen(
  1016.             STR_TITLE,
  1017.             IMG_TITLE,
  1018.             STR_LSK,
  1019.             IMG_LSK,
  1020.             STR_GLOBAL_BACK,
  1021.             IMG_GLOBAL_BACK,
  1022.             EntryCount,
  1023.             ItemPtr,
  1024.             mmi_phb_inline_display_style,
  1025.             mmi_phb_inline_menuitem_properties,
  1026.             g_phb_cntx.highlight_entry,
  1027.             guiBuffer);
  1028.     }
  1029.     else
  1030. #endif /* __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__ */ 
  1031.     {
  1032.         ShowCategory184Screen(
  1033.             STR_TITLE,
  1034.             IMG_TITLE,
  1035.             STR_LSK,
  1036.             IMG_LSK,
  1037.             STR_GLOBAL_BACK,
  1038.             IMG_GLOBAL_BACK,
  1039.             EntryCount,
  1040.             ItemPtr,
  1041.             HintPtr,
  1042.             g_phb_cntx.highlight_entry,
  1043.             guiBuffer);
  1044.     }
  1045.     /* register multi-tap function for fast jump, for full list only */
  1046.     if (alpha_index)
  1047.     {
  1048.         register_multitap_no_draw_key_handlers();
  1049.         set_multitap_functions(mmi_phb_list_alpha_index, mmi_phb_list_alpha_index_input_callback);
  1050.         change_multitap_mode(0);
  1051.     }
  1052.     SetLeftSoftkeyFunction(LSKPtr, KEY_EVENT_UP);
  1053. #ifdef __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__
  1054.     if (phbListView != MMI_PHB_LIST_FOR_PHB)
  1055. #endif /* __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__ */ 
  1056.     {
  1057.         if (right_arrow)
  1058.         {
  1059.             SetKeyHandler(LSKPtr, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1060.         }
  1061.         else
  1062.         {
  1063.             ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1064.         }
  1065.     }
  1066.     if (gInsertSimAppFlag != 1 && mmi_bootup_get_active_flight_mode() != 1)
  1067.     {
  1068.         SetKeyHandler(SendKeyPtr, KEY_SEND, KEY_EVENT_UP);
  1069.     #if (defined __MMI_TOUCH_SCREEN__) && (defined __MMI_WGUI_CSK_ENABLE__)
  1070.         if (phbListView == MMI_PHB_LIST_FOR_PHB)
  1071.         {
  1072.             SetCenterSoftkeyFunction(SendKeyPtr, KEY_EVENT_UP);
  1073.         }
  1074.     #endif /* (defined __MMI_TOUCH_SCREEN__) && (defined __MMI_WGUI_CSK_ENABLE__) */ 
  1075.     }
  1076.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1077. #ifdef __MMI_PHB_TWO_LINE_MENUITEM_DISPLAY__
  1078.     if (phbListView != MMI_PHB_LIST_FOR_PHB)
  1079. #endif 
  1080.     {
  1081.         SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1082.     }
  1083. #if defined(__IP_NUMBER__) && defined(__MMI_IP_KEY__)   /* For IP Dial Key */
  1084. /* under construction !*/
  1085. /* under construction !*/
  1086. /* under construction !*/
  1087. /* under construction !*/
  1088. #endif /* defined(__IP_NUMBER__) && defined(__MMI_IP_KEY__) */ 
  1089. }
  1090. /*****************************************************************************
  1091.  * FUNCTION
  1092.  *  mmi_phb_nlf_list_get_item
  1093.  * DESCRIPTION
  1094.  *  
  1095.  * PARAMETERS
  1096.  *  item_index          [IN]        
  1097.  *  str_buff            [IN]        
  1098.  *  img_buff_p          [?]         
  1099.  *  str_img_mask        [IN]        
  1100.  * RETURNS
  1101.  *  
  1102.  *****************************************************************************/
  1103. pBOOL mmi_phb_nlf_list_get_item(S32 item_index, UI_string_type str_buff, PU8 *img_buff_p, U8 str_img_mask)
  1104. {
  1105.     /*----------------------------------------------------------------*/
  1106.     /* Local Variables                                                */
  1107.     /*----------------------------------------------------------------*/
  1108.     U16 store_index = 0;
  1109.     S32 i=-1;
  1110.     S32 inner_index = 0;
  1111.     /*----------------------------------------------------------------*/
  1112.     /* Code Body                                                      */
  1113.     /*----------------------------------------------------------------*/
  1114.     if ((item_index < 0) || (item_index >= PhoneBookEntryCount))
  1115.     {
  1116.         return FALSE;
  1117.     }
  1118.     while (i < item_index)
  1119.     {
  1120.         store_index = g_phb_name_index[inner_index];
  1121.         if (g_phb_cntx.name_list_filter == MMI_SIM)
  1122.         {
  1123.             if (store_index >= MAX_PB_PHONE_ENTRIES)
  1124.             {
  1125.                 i++;
  1126.             }
  1127.         }
  1128.         else if (g_phb_cntx.name_list_filter == MMI_NVRAM)
  1129.         {
  1130.             if(store_index < MAX_PB_PHONE_ENTRIES)
  1131.             {
  1132.                 i++;
  1133.             }
  1134.         }
  1135.         else
  1136.         {
  1137.             i++;
  1138.         }
  1139.         inner_index ++;
  1140.     }
  1141.     if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name))
  1142.     {
  1143.         pfnUnicodeStrcpy((S8*) str_buff, (S8*) PhoneBook[store_index].alpha_id.name);
  1144.     }
  1145.     else
  1146.     {
  1147.         mmi_phb_convert_get_ucs2_number((S8*) str_buff, store_index);
  1148.     }
  1149.     if (store_index >= MAX_PB_PHONE_ENTRIES)
  1150.     {
  1151.         *img_buff_p = get_image(IMG_STORAGE_SIM);
  1152.     }
  1153.     else
  1154.     {
  1155.         *img_buff_p = get_image(IMG_STORAGE_HANDSET);
  1156.     }
  1157.     return TRUE;
  1158. }
  1159. /*****************************************************************************
  1160.  * FUNCTION
  1161.  *  mmi_phb_nlf_list_get_hint
  1162.  * DESCRIPTION
  1163.  *  
  1164.  * PARAMETERS
  1165.  *  item_index      [IN]        
  1166.  *  hint_array      [?]         
  1167.  * RETURNS
  1168.  *  
  1169.  *****************************************************************************/
  1170. S32 mmi_phb_nlf_list_get_hint(S32 item_index, UI_string_type *hint_array)
  1171. {
  1172.     /*----------------------------------------------------------------*/
  1173.     /* Local Variables                                                */
  1174.     /*----------------------------------------------------------------*/
  1175.     U16 store_index = 0;
  1176.     S8 temp_number[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
  1177.     S32 i=-1;
  1178.     S32 inner_index = 0;
  1179.     /*----------------------------------------------------------------*/
  1180.     /* Code Body                                                      */
  1181.     /*----------------------------------------------------------------*/
  1182.     while (i < item_index)
  1183.     {
  1184.         store_index = g_phb_name_index[inner_index];
  1185.         if (g_phb_cntx.name_list_filter == MMI_SIM)
  1186.         {
  1187.             if (store_index >= MAX_PB_PHONE_ENTRIES)
  1188.             {
  1189.                 i++;
  1190.             }
  1191.         }
  1192.         else if (g_phb_cntx.name_list_filter == MMI_NVRAM)
  1193.         {
  1194.             if(store_index < MAX_PB_PHONE_ENTRIES)
  1195.             {
  1196.                 i++;
  1197.             }
  1198.         }
  1199.         else
  1200.         {
  1201.             i++;
  1202.         }
  1203.         inner_index ++;
  1204.     }
  1205.     mmi_phb_convert_get_ucs2_number((S8*) temp_number, store_index);
  1206.     if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name) && pfnUnicodeStrlen((S8*) temp_number))
  1207.     {
  1208.         pfnUnicodeStrcpy((S8*) hint_array[0], (S8*) temp_number);
  1209.     }
  1210.     else
  1211.     {
  1212.         return 0;   /* No Hint Data */
  1213.     }
  1214.     return 1;   /* One hint data only, can be more hints. */
  1215. }
  1216. #endif /* defined(__MMI_PHB_NAME_LIST_FILTER__) */
  1217. /*****************************************************************************
  1218.  * FUNCTION
  1219.  *  mmi_phb_filter_list_get_item
  1220.  * DESCRIPTION
  1221.  *  
  1222.  * PARAMETERS
  1223.  *  item_index          [IN]        
  1224.  *  str_buff            [IN]        
  1225.  *  img_buff_p          [?]         
  1226.  *  str_img_mask        [IN]        
  1227.  * RETURNS
  1228.  *  
  1229.  *****************************************************************************/
  1230. pBOOL mmi_phb_filter_list_get_item(S32 item_index, UI_string_type str_buff, PU8 *img_buff_p, U8 str_img_mask)
  1231. {
  1232.     /*----------------------------------------------------------------*/
  1233.     /* Local Variables                                                */
  1234.     /*----------------------------------------------------------------*/
  1235.     U16 store_index;
  1236.     /*----------------------------------------------------------------*/
  1237.     /* Code Body                                                      */
  1238.     /*----------------------------------------------------------------*/
  1239.     store_index = g_phb_cntx.list_filter[item_index];
  1240.     if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name))
  1241.     {
  1242.         pfnUnicodeStrcpy((S8*) str_buff, (S8*) PhoneBook[store_index].alpha_id.name);
  1243.     }
  1244.     else
  1245.     {
  1246.         mmi_phb_convert_get_ucs2_number((S8*) str_buff, store_index);
  1247.     }
  1248.     if (store_index >= MAX_PB_PHONE_ENTRIES)
  1249.     {
  1250.         *img_buff_p = get_image(IMG_STORAGE_SIM);
  1251.     }
  1252.     else
  1253.     {
  1254.         *img_buff_p = get_image(IMG_STORAGE_HANDSET);
  1255.     }
  1256.     return TRUE;
  1257. }
  1258. /*****************************************************************************
  1259.  * FUNCTION
  1260.  *  mmi_phb_filter_list_get_hint
  1261.  * DESCRIPTION
  1262.  *  
  1263.  * PARAMETERS
  1264.  *  item_index      [IN]        
  1265.  *  hint_array      [?]         
  1266.  * RETURNS
  1267.  *  
  1268.  *****************************************************************************/
  1269. S32 mmi_phb_filter_list_get_hint(S32 item_index, UI_string_type *hint_array)
  1270. {
  1271.     /*----------------------------------------------------------------*/
  1272.     /* Local Variables                                                */
  1273.     /*----------------------------------------------------------------*/
  1274.     U16 store_index;
  1275.     S8 temp_number[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
  1276.     /*----------------------------------------------------------------*/
  1277.     /* Code Body                                                      */
  1278.     /*----------------------------------------------------------------*/
  1279.     store_index = g_phb_cntx.list_filter[item_index];
  1280.     mmi_phb_convert_get_ucs2_number((S8*) temp_number, store_index);
  1281.     if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name) && pfnUnicodeStrlen((S8*) temp_number))
  1282.     {
  1283.         pfnUnicodeStrcpy((S8*) hint_array[0], (S8*) temp_number);
  1284.     }
  1285.     else
  1286.     {
  1287.         return 0;
  1288.     }
  1289.     return 1;   /* One hint data only, can be more hints. */
  1290. }
  1291. /*****************************************************************************
  1292.  * FUNCTION
  1293.  *  mmi_phb_list_get_null_hint
  1294.  * DESCRIPTION
  1295.  *  No hint needed in the dynamic list.
  1296.  * PARAMETERS
  1297.  *  item_index      [IN]        
  1298.  *  hint_array      [?]         
  1299.  * RETURNS
  1300.  *  void
  1301.  *****************************************************************************/
  1302. S32 mmi_phb_list_get_null_hint(S32 item_index, UI_string_type *hint_array)
  1303. {
  1304.     /*----------------------------------------------------------------*/
  1305.     /* Local Variables                                                */
  1306.     /*----------------------------------------------------------------*/
  1307.     /*----------------------------------------------------------------*/
  1308.     /* Code Body                                                      */
  1309.     /*----------------------------------------------------------------*/
  1310.     return 0;
  1311. }
  1312. /*****************************************************************************
  1313.  * FUNCTION
  1314.  *  mmi_phb_choose_number_normal
  1315.  * DESCRIPTION
  1316.  *  choose normal phonebook entry number if has many(Only when IP number on)
  1317.  * PARAMETERS
  1318.  *  void
  1319.  * RETURNS
  1320.  *  void
  1321.  *****************************************************************************/
  1322. void mmi_phb_choose_number_normal(void)
  1323. {
  1324.     /*----------------------------------------------------------------*/
  1325.     /* Local Variables                                                */
  1326.     /*----------------------------------------------------------------*/
  1327.     /*----------------------------------------------------------------*/
  1328.     /* Code Body                                                      */
  1329.     /*----------------------------------------------------------------*/
  1330. #if defined(__IP_NUMBER__)
  1331.     SetTempUseIPNumber(FALSE);
  1332. #endif 
  1333.     mmi_phb_list_pre_choose_number();
  1334. }
  1335. /*****************************************************************************
  1336.  * FUNCTION
  1337.  *  mmi_phb_choose_number_ip_number
  1338.  * DESCRIPTION
  1339.  *  choose IP Dial phonebook entry number if has many(Only when IP number on)
  1340.  * PARAMETERS
  1341.  *  void
  1342.  * RETURNS
  1343.  *  void
  1344.  *****************************************************************************/
  1345. void mmi_phb_choose_number_ip_number(void)
  1346. {
  1347.     /*----------------------------------------------------------------*/
  1348.     /* Local Variables                                                */
  1349.     /*----------------------------------------------------------------*/
  1350.     /*----------------------------------------------------------------*/
  1351.     /* Code Body                                                      */
  1352.     /*----------------------------------------------------------------*/
  1353. #if defined(__IP_NUMBER__)
  1354.     SetTempUseIPNumber(TRUE);
  1355. #endif 
  1356.     mmi_phb_list_pre_choose_number();
  1357. }
  1358. /*****************************************************************************
  1359.  * FUNCTION
  1360.  *  mmi_phb_list_alpha_index
  1361.  * DESCRIPTION
  1362.  *  This function calculates the index of the entry to be highlighted, if the user jumps to some
  1363.  *  entry using multi-tap on PHB list screen.
  1364.  * PARAMETERS
  1365.  *  input       [IN]        Input character
  1366.  * RETURNS
  1367.  *  void
  1368.  *****************************************************************************/
  1369. void mmi_phb_list_alpha_index(U16 input)
  1370. {
  1371.     /*----------------------------------------------------------------*/
  1372.     /* Local Variables                                                */
  1373.     /*----------------------------------------------------------------*/
  1374.     /*----------------------------------------------------------------*/
  1375.     /* Code Body                                                      */
  1376.     /*----------------------------------------------------------------*/
  1377.     if (input >= 'A' && input <= 'Z')
  1378.     {
  1379.         g_phb_highlight_alpha = g_phb_alpha_index_list[input - 'A'];
  1380.         g_phb_highlight_alpha--;
  1381.     }
  1382. }
  1383. /*****************************************************************************
  1384.  * FUNCTION
  1385.  *  mmi_phb_list_alpha_index_input_callback
  1386.  * DESCRIPTION
  1387.  *  Jumps to the hilited entry
  1388.  * PARAMETERS
  1389.  *  void
  1390.  * RETURNS
  1391.  *  void
  1392.  *****************************************************************************/
  1393. void mmi_phb_list_alpha_index_input_callback(void)
  1394. {
  1395. #if defined(__MMI_FILE_MANAGER__) && defined(MMI_ON_HARDWARE_P)
  1396.     /*----------------------------------------------------------------*/
  1397.     /* Local Variables                                                */
  1398.     /*----------------------------------------------------------------*/
  1399.     /*----------------------------------------------------------------*/
  1400.     /* Code Body                                                      */
  1401.     /*----------------------------------------------------------------*/
  1402.     if (UI_device_height == 220 && UI_device_width == 176)
  1403.     {
  1404.         Cat212ShortCutHdlr(g_phb_highlight_alpha);  /* For image list fast jump */
  1405.     }
  1406.     else
  1407. #endif /* defined(__MMI_FILE_MANAGER__) && defined(MMI_ON_HARDWARE_P) */ 
  1408.         dynamic_list_goto_item(g_phb_highlight_alpha);  /* Use Dynamic List */
  1409. }
  1410. /*****************************************************************************
  1411.  * FUNCTION
  1412.  *  mmi_phb_list_build_alpha_index
  1413.  * DESCRIPTION
  1414.  *  Build up alpha index for each characters
  1415.  * PARAMETERS
  1416.  *  filter_list         [?]         
  1417.  *  filter_value        [IN]        
  1418.  *  is_equal            [IN]        
  1419.  *  storage             [IN]        
  1420.  * RETURNS
  1421.  *  void
  1422.  *****************************************************************************/
  1423. void mmi_phb_list_build_alpha_index(U16 *filter_list, U16 filter_value, BOOL is_equal, U8 storage)
  1424. {
  1425.     /*----------------------------------------------------------------*/
  1426.     /* Local Variables                                                */
  1427.     /*----------------------------------------------------------------*/
  1428.     U16 i, j, count = 0;
  1429.     BOOL valid_ch;
  1430.     U8 index = 0xff;
  1431.     U16 store_index;
  1432.     MMI_PHB_NAME_STRUCT *name_ptr;
  1433. #if defined(__MMI_PHB_PINYIN_SORT__)
  1434.     U8 *pinyin_ptr;
  1435. #endif 
  1436.     /*----------------------------------------------------------------*/
  1437.     /* Code Body                                                      */
  1438.     /*----------------------------------------------------------------*/
  1439.     /* Clear First */
  1440.     for (i = 0; i < ALPHA_LIST_LENGTH; i++)
  1441.     {
  1442.         g_phb_alpha_index_list[i] = 0;
  1443.     }
  1444.     for (i = 0; i < PhoneBookEntryCount; i++)
  1445.     {
  1446.         U16 filter_index;
  1447.         store_index = g_phb_name_index[i];
  1448.         /* exclude storage location */
  1449.         if (storage == MMI_SIM && store_index < MAX_PB_PHONE_ENTRIES)
  1450.         {
  1451.             continue;
  1452.         }
  1453.         else if (storage == MMI_NVRAM && store_index >= MAX_PB_PHONE_ENTRIES)
  1454.         {
  1455.             continue;
  1456.         }
  1457.         if (storage == MMI_SIM)
  1458.         {
  1459.             filter_index = store_index - MAX_PB_PHONE_ENTRIES;
  1460.         }
  1461.         else
  1462.         {
  1463.             filter_index = store_index;
  1464.         }
  1465.         /* Filter List */
  1466.         if (filter_list != NULL && is_equal)    /* Exclude item not in the filter list. */
  1467.         {
  1468.             if (filter_list[filter_index] != filter_value)
  1469.             {
  1470.                 continue;
  1471.             }
  1472.         }
  1473.         else if (filter_list != NULL && !is_equal)  /* Exclude item in the filter list. */
  1474.         {
  1475.             if (filter_list[filter_index] == filter_value)
  1476.             {
  1477.                 continue;
  1478.             }
  1479.         }
  1480.         /* All character store in MMI by using UCS2(two-bytes) format */
  1481.         name_ptr = &PhoneBook[store_index].alpha_id;
  1482.         if ((name_ptr->name[1] == 0x00) && (name_ptr->name[0] >= 'a') && (name_ptr->name[0] <= 'z'))    /* lower case */
  1483.         {
  1484.             index = name_ptr->name[0] - 'a';
  1485.             valid_ch = TRUE;
  1486.         }
  1487.         else if ((name_ptr->name[1] == 0x00) && (name_ptr->name[0] >= 'A') && (name_ptr->name[0] <= 'Z'))       /* upper case */
  1488.         {
  1489.             index = name_ptr->name[0] - 'A';
  1490.             valid_ch = TRUE;
  1491.         }
  1492.     #if defined(__MMI_PHB_PINYIN_SORT__)
  1493.         else if ((name_ptr->name[0] != 0x00) && (name_ptr->name[1] != 0x00))    /* A 2-bytes character */
  1494.         {
  1495.             mmi_phb_util_get_pinyin_cache(store_index, &pinyin_ptr);
  1496.             if (pinyin_ptr[0] >= 'a' && pinyin_ptr[0] <= 'z')
  1497.             {
  1498.                 index = pinyin_ptr[0] - 'a';
  1499.                 valid_ch = TRUE;
  1500.             }
  1501.             else
  1502.             {
  1503.                 valid_ch = FALSE;
  1504.             }
  1505.         }
  1506.     #endif /* defined(__MMI_PHB_PINYIN_SORT__) */ 
  1507.         else
  1508.         {
  1509.             valid_ch = FALSE;
  1510.         }
  1511.         /* Assign alpha index */
  1512.         if (index < ALPHA_LIST_LENGTH && g_phb_alpha_index_list[index] == 0 && valid_ch)
  1513.         {
  1514.             for (j = 0; j < index; j++)
  1515.                 if (g_phb_alpha_index_list[j] == 0)
  1516.                 {
  1517.                     g_phb_alpha_index_list[j] = count + 1;
  1518.                 }
  1519.             g_phb_alpha_index_list[index] = count + 1;
  1520.         }
  1521.         count++;
  1522.     }
  1523.     /* Handle unassigned index */
  1524.     count = 1;
  1525.     for (j = 0; j < ALPHA_LIST_LENGTH; j++)
  1526.     {
  1527.         if (g_phb_alpha_index_list[j] == 0)
  1528.         {
  1529.             g_phb_alpha_index_list[j] = count;
  1530.         }
  1531.         else
  1532.         {
  1533.             count = g_phb_alpha_index_list[j];
  1534.         }
  1535.     }
  1536. }
  1537. /*****************************************************************************
  1538.  * FUNCTION
  1539.  *  mmi_phb_list_pre_choose_number
  1540.  * DESCRIPTION
  1541.  *  Allows the user to choose one number to dial  if the entry has more than one number
  1542.  * PARAMETERS
  1543.  *  void
  1544.  * RETURNS
  1545.  *  void
  1546.  *****************************************************************************/
  1547. void mmi_phb_list_pre_choose_number(void)
  1548. {
  1549.     /*----------------------------------------------------------------*/
  1550.     /* Local Variables                                                */
  1551.     /*----------------------------------------------------------------*/
  1552.     /*----------------------------------------------------------------*/
  1553.     /* Code Body                                                      */
  1554.     /*----------------------------------------------------------------*/
  1555.     mmi_phb_entry_list_choose_number(
  1556.         g_phb_name_index[g_phb_cntx.active_index],
  1557.         mmi_phb_list_pre_choose_number,
  1558.         mmi_phb_list_make_call,
  1559.         MakeCall,
  1560.         STR_NO_NUMBER_TO_DIAL,
  1561.         TRUE);
  1562. }
  1563. /*****************************************************************************
  1564.  * FUNCTION
  1565.  *  mmi_phb_entry_list_choose_number
  1566.  * DESCRIPTION
  1567.  *  Allows the user to choose one number to some action  if the entry has more than one number
  1568.  * PARAMETERS
  1569.  *  store_index         [IN]        
  1570.  *  EntryFunc           [IN]        
  1571.  *  RSKFunc             [IN]        
  1572.  *  ActionFunc          [IN]        
  1573.  *  empty_str_id        [IN]        
  1574.  *  dial_list           [IN]        
  1575.  * RETURNS
  1576.  *  void
  1577.  *****************************************************************************/
  1578. void mmi_phb_entry_list_choose_number(
  1579.         U16 store_index,
  1580.         void (*EntryFunc) (void),
  1581.         void (*RSKFunc) (void),
  1582.         void (*ActionFunc) (S8*),
  1583.         U16 empty_str_id,
  1584.         BOOL dial_list)
  1585. {
  1586.     /*----------------------------------------------------------------*/
  1587.     /* Local Variables                                                */
  1588.     /*----------------------------------------------------------------*/
  1589.     U8 i = 0;
  1590.     U8 *guiBuffer;
  1591.     U16 numberTypeImageList[4];
  1592.     S16 pError;
  1593.     /*----------------------------------------------------------------*/
  1594.     /* Code Body                                                      */
  1595.     /*----------------------------------------------------------------*/
  1596. #ifdef __MMI_VOIP__
  1597.     phb_voip_number_index= 0xff;
  1598. #endif
  1599.     mmi_phb_convert_get_ucs2_number(pbNumber, store_index); /* BCD number format. */
  1600.     if (pfnUnicodeStrlen(pbNumber))
  1601.     {
  1602.         g_phb_cntx.number_to_dial[i] = (U8*) pbNumber;
  1603.         numberTypeImageList[i++] = IMG_MOBILE_NUMBER;
  1604.     }
  1605.     if (store_index >= MAX_PB_PHONE_ENTRIES)    /* Entry in SIM */
  1606.     {
  1607.     #ifdef __MMI_PHB_USIM_FIELD__
  1608.         if (g_phb_cntx.is_usim)
  1609.         {
  1610.             mmi_phb_convert_get_ucs2_anr(pbHomeNumber, pbOfficeNumber, pbFaxNumber, store_index);
  1611.             if (pfnUnicodeStrlen(pbHomeNumber))
  1612.             {
  1613.                 g_phb_cntx.number_to_dial[i] = (PU8) pbHomeNumber;
  1614.                 numberTypeImageList[i++] = IMG_ID_PHB_ANR;
  1615.             }
  1616.             AnsiiToUnicodeString(pbOfficeNumber, (PS8) PhoneBookOptionalFields.officeNumber);
  1617.             if (pfnUnicodeStrlen(pbOfficeNumber))
  1618.             {
  1619.                 g_phb_cntx.number_to_dial[i] = (PU8) pbOfficeNumber;
  1620.                 numberTypeImageList[i++] = IMG_ID_PHB_ANR;
  1621.             }
  1622.             AnsiiToUnicodeString(pbFaxNumber, (PS8) PhoneBookOptionalFields.faxNumber);
  1623.             if (pfnUnicodeStrlen(pbFaxNumber))
  1624.             {
  1625.                 g_phb_cntx.number_to_dial[i] = (PU8) pbFaxNumber;
  1626.                 numberTypeImageList[i++] = IMG_ID_PHB_ANR;
  1627.             }
  1628.         }
  1629.     #endif /* __MMI_PHB_USIM_FIELD__ */ 
  1630.     }
  1631.     else
  1632.     {
  1633.     #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
  1634.         /* Read Optional Number Fields */
  1635.         ReadRecord(
  1636.             NVRAM_EF_PHB_FIELDS_LID,
  1637.             (U16) (store_index + 1),
  1638.             (void*)&PhoneBookOptionalFields,
  1639.             OPTIONAL_FIELDS_RECORD_SIZE,
  1640.             &pError);
  1641.         AnsiiToUnicodeString(pbHomeNumber, (PS8) PhoneBookOptionalFields.homeNumber);
  1642.         if (pfnUnicodeStrlen(pbHomeNumber))
  1643.         {
  1644.             g_phb_cntx.number_to_dial[i] = (PU8) pbHomeNumber;
  1645.             numberTypeImageList[i++] = IMG_HOME_NUMBER;
  1646.         }
  1647.         AnsiiToUnicodeString(pbOfficeNumber, (PS8) PhoneBookOptionalFields.officeNumber);
  1648.         if (pfnUnicodeStrlen(pbOfficeNumber))
  1649.         {
  1650.             g_phb_cntx.number_to_dial[i] = (PU8) pbOfficeNumber;
  1651.             numberTypeImageList[i++] = IMG_OFFICE_NUMBER;
  1652.         }
  1653.         AnsiiToUnicodeString(pbFaxNumber, (PS8) PhoneBookOptionalFields.faxNumber);
  1654.         if (pfnUnicodeStrlen(pbFaxNumber))
  1655.         {
  1656.             g_phb_cntx.number_to_dial[i] = (PU8) pbFaxNumber;
  1657.             numberTypeImageList[i++] = IMG_FAX_NUMBER;
  1658.         }
  1659.     #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */ 
  1660.     }
  1661. #ifdef __MMI_VOIP__
  1662.     if (dial_list && store_index < MAX_PB_PHONE_ENTRIES)  /* make call */
  1663.     {
  1664.         ReadRecord(
  1665.             NVRAM_EF_PHB_VOIP_LID,
  1666.             (U16) (store_index + 1),
  1667.             (void*)&PhoneBookVoipField,
  1668.             VOIP_URI_LEN,
  1669.             &pError);
  1670.         AnsiiToUnicodeString(pbVoip, (PS8) PhoneBookVoipField);
  1671.         if (pfnUnicodeStrlen(pbVoip))
  1672.         {
  1673.             phb_voip_number_index = i;
  1674.             g_phb_cntx.number_to_dial[i] = (PU8) pbVoip;
  1675.             numberTypeImageList[i++] = IMG_ID_PHB_VOIP;
  1676.         }
  1677.     }
  1678. #endif /* __MMI_VOIP__ */
  1679.     if (!i)
  1680.     {
  1681.     #if defined(__IP_NUMBER__)
  1682.         SetTempUseIPNumber(FALSE);
  1683.     #endif 
  1684.         DisplayPopup((PU8) GetString(empty_str_id), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  1685.     }
  1686.     else if (i == 1)
  1687.     {
  1688.         if (dial_list)  /* Will dial from list after select entry */
  1689.         {
  1690.             g_phb_cntx.dial_from_list = MMI_PHB_PHONEBOOK;
  1691. #ifdef __MMI_VOIP__
  1692.             if (phb_voip_number_index != 0xff)
  1693.             {
  1694.                 mmi_voip_app_make_call((PU8)pbVoip);
  1695.                 return;
  1696.             }
  1697. #endif /* __MMI_VOIP__ */
  1698.         }
  1699.         ActionFunc((PS8) g_phb_cntx.number_to_dial[0]);
  1700.     }
  1701.     else
  1702.     {
  1703.     #if defined(__IP_NUMBER__)      /* Do not keep choose number screen in history when IP dial enable */
  1704.         EntryNewScreen(SCR_CHOOSE_NUMBER, mmi_phb_exit_list_choose_number, NULL, NULL);
  1705.     #else 
  1706.         EntryNewScreen(SCR_CHOOSE_NUMBER, mmi_phb_exit_list_choose_number, EntryFunc, NULL);
  1707.     #endif 
  1708.         guiBuffer = GetCurrGuiBuffer(SCR_CHOOSE_NUMBER);
  1709.         RegisterHighlightHandler(mmi_phb_get_index_third_level);
  1710.         ShowCategory53Screen(
  1711.             STR_CHOOSE_NUMBER_CAPTION,
  1712.             IMG_SCR_PBOOK_CAPTION,
  1713.             STR_GLOBAL_OK,
  1714.             IMG_GLOBAL_OK,
  1715.             STR_GLOBAL_BACK,
  1716.             IMG_GLOBAL_BACK,
  1717.             i,
  1718.             g_phb_cntx.number_to_dial,
  1719.             numberTypeImageList,
  1720.             NULL,
  1721.             0,
  1722.             0,
  1723.             guiBuffer);
  1724.         SetLeftSoftkeyFunction(RSKFunc, KEY_EVENT_UP);
  1725.         SetKeyHandler(RSKFunc, KEY_SEND, KEY_EVENT_UP);
  1726.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1727.     }
  1728. }
  1729. /*****************************************************************************
  1730.  * FUNCTION
  1731.  *  mmi_phb_exit_list_choose_number
  1732.  * DESCRIPTION
  1733.  *  exit function
  1734.  * PARAMETERS
  1735.  *  void
  1736.  * RETURNS
  1737.  *  void
  1738.  *****************************************************************************/
  1739. void mmi_phb_exit_list_choose_number(void)
  1740. {
  1741.     /*----------------------------------------------------------------*/
  1742.     /* Local Variables                                                */
  1743.     /*----------------------------------------------------------------*/
  1744.     /*----------------------------------------------------------------*/
  1745.     /* Code Body                                                      */
  1746.     /*----------------------------------------------------------------*/
  1747.     g_phb_cntx.end_scr_id = SCR_CHOOSE_NUMBER;
  1748. }
  1749. /*****************************************************************************
  1750.  * FUNCTION
  1751.  *  mmi_phb_list_make_call
  1752.  * DESCRIPTION
  1753.  *  Makes call to a number
  1754.  * PARAMETERS
  1755.  *  void
  1756.  * RETURNS
  1757.  *  void
  1758.  *****************************************************************************/
  1759. void mmi_phb_list_make_call(void)
  1760. {
  1761.     /*----------------------------------------------------------------*/
  1762.     /* Local Variables                                                */
  1763.     /*----------------------------------------------------------------*/
  1764.     /*----------------------------------------------------------------*/
  1765.     /* Code Body                                                      */
  1766.     /*----------------------------------------------------------------*/
  1767.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_list_make_call.>n", __FILE__, __LINE__));
  1768.     g_phb_cntx.dial_from_list = MMI_PHB_PHONEBOOK;
  1769. #ifdef __MMI_VOIP__
  1770.     if (phb_voip_number_index == g_phb_cntx.active_index_third)
  1771.     {
  1772.         mmi_voip_app_make_call(g_phb_cntx.number_to_dial[g_phb_cntx.active_index_third]);
  1773.     }
  1774.     else
  1775. #endif
  1776.     {
  1777.         MakeCall((PS8) g_phb_cntx.number_to_dial[g_phb_cntx.active_index_third]);
  1778.     }
  1779. }
  1780. #define MMI_PHB_UTIL_FUNC
  1781. #if defined(__MMI_INTELLIGENT_CALL_ALERT__)
  1782. /*****************************************************************************
  1783.  * FUNCTION
  1784.  *  mmi_phb_get_index_speak_name
  1785.  * DESCRIPTION
  1786.  *  Gets the index of the currently highlighted item in Phonebook menu list.
  1787.  * PARAMETERS
  1788.  *  nIndex      [IN]        Highlight index position
  1789.  * RETURNS
  1790.  *  void
  1791.  *****************************************************************************/
  1792. void mmi_phb_get_index_speak_name(S32 nIndex)
  1793. {
  1794.     /*----------------------------------------------------------------*/
  1795.     /* Local Variables                                                */
  1796.     /*----------------------------------------------------------------*/
  1797.     /*----------------------------------------------------------------*/
  1798.     /* Code Body                                                      */
  1799.     /*----------------------------------------------------------------*/
  1800.     g_phb_cntx.active_index = (U16) nIndex;
  1801.     StopTimer(PHB_LIST_SPEAK_NAME_TIMER);
  1802.     if (g_phb_is_speaking_name)
  1803.     {
  1804.         mdi_audio_stop_string();
  1805.     }
  1806.     if (g_phb_cntx.speak_name)
  1807.     {
  1808.         StartTimer(PHB_LIST_SPEAK_NAME_TIMER, UI_POPUP_NOTIFYDURATION_TIME, mmi_phb_list_speak_name);
  1809.     }
  1810. }
  1811. /*****************************************************************************
  1812.  * FUNCTION
  1813.  *  mmi_phb_get_index_speak_name_nlf
  1814.  * DESCRIPTION
  1815.  *  Gets the index of the currently highlighted item in Phonebook menu list 
  1816.  *  when name_list_filter opening.
  1817.  * PARAMETERS
  1818.  *  nIndex      [IN]        Highlight index position
  1819.  * RETURNS
  1820.  *  void
  1821.  *****************************************************************************/
  1822. void mmi_phb_get_index_speak_name_nlf(S32 nIndex)
  1823. {
  1824.     /*----------------------------------------------------------------*/
  1825.     /* Local Variables                                                */
  1826.     /*----------------------------------------------------------------*/
  1827.     U16 store_index = 0;
  1828.     S32 i = -1;
  1829. S32 inner_index = 0;
  1830.     /*----------------------------------------------------------------*/
  1831.     /* Code Body                                                      */
  1832.     /*----------------------------------------------------------------*/
  1833. while (i < nIndex)
  1834. {
  1835. store_index = g_phb_name_index[inner_index];
  1836. if (g_phb_cntx.name_list_filter == MMI_SIM)
  1837. {
  1838. if (store_index >= MAX_PB_PHONE_ENTRIES)
  1839. {
  1840. i++;
  1841. }
  1842. }
  1843. else if (g_phb_cntx.name_list_filter == MMI_NVRAM)
  1844. {
  1845. if(store_index < MAX_PB_PHONE_ENTRIES)
  1846. {
  1847. i++;
  1848. }
  1849. }
  1850. else
  1851. {
  1852. i++;
  1853. }
  1854. inner_index++;
  1855. }
  1856.     g_phb_cntx.active_index = (U16) (inner_index - 1);
  1857.     StopTimer(PHB_LIST_SPEAK_NAME_TIMER);
  1858.     if (g_phb_is_speaking_name)
  1859.     {
  1860.         mdi_audio_stop_string();
  1861.     }
  1862.     if (g_phb_cntx.speak_name)
  1863.     {
  1864.         StartTimer(PHB_LIST_SPEAK_NAME_TIMER, UI_POPUP_NOTIFYDURATION_TIME, mmi_phb_list_speak_name);
  1865.     }
  1866. }
  1867. /*****************************************************************************
  1868.  * FUNCTION
  1869.  *  mmi_phb_list_speak_name
  1870.  * DESCRIPTION
  1871.  *  Speak name or number for a phonebook entry.
  1872.  * PARAMETERS
  1873.  *  void
  1874.  * RETURNS
  1875.  *  void
  1876.  *****************************************************************************/
  1877. void mmi_phb_list_speak_name(void)
  1878. {
  1879.     /*----------------------------------------------------------------*/
  1880.     /* Local Variables                                                */
  1881.     /*----------------------------------------------------------------*/
  1882.     U16 store_index;
  1883.     U8 text[(MAX_PB_NAME_LENGTH + MAX_PB_NUMBER_LENGTH + 10) * ENCODING_LENGTH];
  1884.     U16 length = 0;
  1885.     /*----------------------------------------------------------------*/
  1886.     /* Code Body                                                      */
  1887.     /*----------------------------------------------------------------*/
  1888.     /* g_phb_cntx.active_index = (U16)nIndex; */
  1889. #ifdef __MMI_SILENT_MEETING_PROFILE__
  1890.     if (IsMeetingModeActivated())
  1891.     {
  1892.         /* not to play sound */
  1893.     }
  1894.     else
  1895. #endif /* __MMI_SILENT_MEETING_PROFILE__ */ 
  1896.         /* Flag is on and not in call */
  1897.     if (g_phb_cntx.speak_name && !isInCall() && !IsSilentModeActivated())
  1898.     {
  1899.         store_index = g_phb_name_index[g_phb_cntx.active_index];
  1900.     #if defined(SIMPLE_TTS) || defined(DIGIT_TONE_SUPPORT)
  1901.         /* Name */
  1902.         pfnUnicodeStrcpy((S8*) text, (S8*) PhoneBook[store_index].alpha_id.name);
  1903.         length = pfnUnicodeStrlen((S8*) text);
  1904.     #endif /* defined(SIMPLE_TTS) || defined(DIGIT_TONE_SUPPORT) */ 
  1905.         /* Append Number */
  1906.     #ifdef DIGIT_TONE_SUPPORT
  1907.         mmi_phb_convert_get_ucs2_number((S8*) (text + length * ENCODING_LENGTH), store_index);
  1908.         length += pfnUnicodeStrlen((S8*) (text + length * ENCODING_LENGTH));
  1909.     #endif /* DIGIT_TONE_SUPPORT */ 
  1910.         if (length > 0)
  1911.         {
  1912.             mdi_result result = mdi_audio_play_text_with_vol_path(
  1913.                                     (U8*) text,
  1914.                                     length,
  1915.                                     100,
  1916.                                     NULL,
  1917.                                     mmi_phb_speak_name_handler,
  1918.                                     GetRingVolumeLevel(),
  1919.                                     MDI_DEVICE_SPEAKER2);
  1920.             if (result == MDI_AUDIO_SUCCESS)
  1921.             {
  1922.                 g_phb_is_speaking_name = 1;
  1923.             }
  1924.             else
  1925.             {
  1926.                 g_phb_is_speaking_name = 0;
  1927.             }
  1928.         }
  1929.     }
  1930. }
  1931. #endif /* defined(__MMI_INTELLIGENT_CALL_ALERT__) */ 
  1932. /*****************************************************************************
  1933.  * FUNCTION
  1934.  *  mmi_phb_get_index
  1935.  * DESCRIPTION
  1936.  *  Gets the index of the currently highlighted item in Phonebook menu list.
  1937.  * PARAMETERS
  1938.  *  nIndex      [IN]        Highlight index position
  1939.  * RETURNS
  1940.  *  void
  1941.  *****************************************************************************/
  1942. void mmi_phb_get_index(S32 nIndex)
  1943. {
  1944.     /*----------------------------------------------------------------*/
  1945.     /* Local Variables                                                */
  1946.     /*----------------------------------------------------------------*/
  1947.     /*----------------------------------------------------------------*/
  1948.     /* Code Body                                                      */
  1949.     /*----------------------------------------------------------------*/
  1950.     g_phb_cntx.active_index = (U16) nIndex;
  1951. }
  1952. /*****************************************************************************
  1953.  * FUNCTION
  1954.  *  mmi_phb_get_index_nlf
  1955.  * DESCRIPTION
  1956.  *  Gets the index of the currently highlighted item in Phonebook menu list
  1957.  *  when name_list_filter opening
  1958.  * PARAMETERS
  1959.  *  nIndex      [IN]        Highlight index position
  1960.  * RETURNS
  1961.  *  void
  1962.  *****************************************************************************/
  1963. void mmi_phb_get_index_nlf(S32 nIndex)
  1964. {
  1965.     /*----------------------------------------------------------------*/
  1966.     /* Local Variables                                                */
  1967.     /*----------------------------------------------------------------*/
  1968.     U16 store_index = 0;
  1969.     S32 i = -1;
  1970. S32 inner_index = 0;
  1971.     /*----------------------------------------------------------------*/
  1972.     /* Code Body                                                      */
  1973.     /*----------------------------------------------------------------*/
  1974. while (i < nIndex)
  1975. {
  1976. store_index = g_phb_name_index[inner_index];
  1977. if (g_phb_cntx.name_list_filter == MMI_SIM)
  1978. {
  1979. if (store_index >= MAX_PB_PHONE_ENTRIES)
  1980. {
  1981. i++;
  1982. }
  1983. }
  1984. else if (g_phb_cntx.name_list_filter == MMI_NVRAM)
  1985. {
  1986. if(store_index < MAX_PB_PHONE_ENTRIES)
  1987. {
  1988. i++;
  1989. }
  1990. }
  1991. else
  1992. {
  1993. i++;
  1994. }
  1995. inner_index++;
  1996. }
  1997.     g_phb_cntx.active_index = (U16) (inner_index - 1);
  1998. }
  1999. /*****************************************************************************
  2000.  * FUNCTION
  2001.  *  mmi_phb_get_index_second_level
  2002.  * DESCRIPTION
  2003.  *  Gets the index of the currently highlighted item in Phonebook menu list.
  2004.  * PARAMETERS
  2005.  *  nIndex      [IN]        Highlight index position
  2006.  * RETURNS
  2007.  *  void
  2008.  *****************************************************************************/
  2009. void mmi_phb_get_index_second_level(S32 nIndex)
  2010. {
  2011.     /*----------------------------------------------------------------*/
  2012.     /* Local Variables                                                */
  2013.     /*----------------------------------------------------------------*/
  2014.     /*----------------------------------------------------------------*/
  2015.     /* Code Body                                                      */
  2016.     /*----------------------------------------------------------------*/
  2017.     g_phb_cntx.active_index_second = (U16) nIndex;
  2018. }
  2019. /*****************************************************************************
  2020.  * FUNCTION
  2021.  *  mmi_phb_get_index_third_level
  2022.  * DESCRIPTION
  2023.  *  Gets the index of the currently highlighted item in Phonebook menu list.
  2024.  * PARAMETERS
  2025.  *  nIndex      [IN]        Highlight index position
  2026.  * RETURNS
  2027.  *  void
  2028.  *****************************************************************************/
  2029. void mmi_phb_get_index_third_level(S32 nIndex)
  2030. {
  2031.     /*----------------------------------------------------------------*/
  2032.     /* Local Variables                                                */
  2033.     /*----------------------------------------------------------------*/
  2034.     /*----------------------------------------------------------------*/
  2035.     /* Code Body                                                      */
  2036.     /*----------------------------------------------------------------*/
  2037.     g_phb_cntx.active_index_third = (U16) nIndex;
  2038. }
  2039. /*****************************************************************************
  2040.  * FUNCTION
  2041.  *  mmi_phb_get_index_by_store_location
  2042.  * DESCRIPTION
  2043.  *  call back function for dynamic list to get index according to the fileter list.
  2044.  * PARAMETERS
  2045.  *  nIndex      [IN]        Highlight index position
  2046.  * RETURNS
  2047.  *  void
  2048.  *****************************************************************************/
  2049. void mmi_phb_get_index_by_store_location(S32 nIndex)
  2050. {
  2051.     /*----------------------------------------------------------------*/
  2052.     /* Local Variables                                                */
  2053.     /*----------------------------------------------------------------*/
  2054.     /*----------------------------------------------------------------*/
  2055.     /* Code Body                                                      */
  2056.     /*----------------------------------------------------------------*/
  2057.     g_phb_cntx.active_index = g_phb_cntx.list_filter[nIndex];
  2058. }
  2059. /*****************************************************************************
  2060.  * FUNCTION
  2061.  *  mmi_phb_get_index_by_store_location_second
  2062.  * DESCRIPTION
  2063.  *  call back function for dynamic list to get index according to the fileter list.
  2064.  * PARAMETERS
  2065.  *  nIndex      [IN]        Highlight index position
  2066.  * RETURNS
  2067.  *  void
  2068.  *****************************************************************************/
  2069. void mmi_phb_get_index_by_store_location_second(S32 nIndex)
  2070. {
  2071.     /*----------------------------------------------------------------*/
  2072.     /* Local Variables                                                */
  2073.     /*----------------------------------------------------------------*/
  2074.     /*----------------------------------------------------------------*/
  2075.     /* Code Body                                                      */
  2076.     /*----------------------------------------------------------------*/
  2077.     g_phb_cntx.active_index_second = g_phb_cntx.list_filter[nIndex];
  2078. }
  2079. /*****************************************************************************
  2080.  * FUNCTION
  2081.  *  mmi_phb_util_clear_buffer
  2082.  * DESCRIPTION
  2083.  *  Clears buffers used for adding/editing entry
  2084.  * PARAMETERS
  2085.  *  clear_number        [IN]        
  2086.  *  flag_number(?)      [IN]        TRUE: clear number buffer. FALSE: Keep number buffer
  2087.  * RETURNS
  2088.  *  void
  2089.  *****************************************************************************/
  2090. void mmi_phb_util_clear_buffer(BOOL clear_number)
  2091. {
  2092.     /*----------------------------------------------------------------*/
  2093.     /* Local Variables                                                */
  2094.     /*----------------------------------------------------------------*/
  2095.     /*----------------------------------------------------------------*/
  2096.     /* Code Body                                                      */
  2097.     /*----------------------------------------------------------------*/
  2098.     memset(pbName, 0, ENCODING_LENGTH);
  2099.     if (clear_number)
  2100.     {
  2101.         memset(pbNumber, 0, ENCODING_LENGTH);
  2102.     }
  2103.     memset(pbHomeNumber, 0, ENCODING_LENGTH);
  2104.     memset(pbCompanyName, 0, ENCODING_LENGTH);
  2105.     memset(pbEmailAddress, 0, ENCODING_LENGTH);
  2106.     memset(pbOfficeNumber, 0, ENCODING_LENGTH);
  2107.     memset(pbFaxNumber, 0, ENCODING_LENGTH);
  2108.     g_phb_cntx.selected_pic_index = 0;
  2109.     g_phb_cntx.selected_ring_index = 0;
  2110.     g_phb_cntx.selected_grp_index = 0;
  2111.     g_phb_cntx.image_location = MMI_PHB_IMAGE_NO_SELECT;
  2112. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  2113.     g_phb_cntx.selected_video_index = 0;
  2114.     g_phb_cntx.video_location = MMI_PHB_IMAGE_NO_SELECT;
  2115. #endif 
  2116. #if defined(__MMI_PHB_BIRTHDAY_FIELD__)
  2117.     mmi_phb_util_clear_bday_buffer();
  2118. #endif 
  2119. #if defined(__MMI_PHB_IMPS_FIELD__)
  2120.     memset(pbImps, 0, ENCODING_LENGTH);
  2121. #endif 
  2122. #if defined(__MMI_VOIP__)
  2123.     memset(pbVoip, 0, ENCODING_LENGTH);
  2124. #endif 
  2125. }
  2126. /*****************************************************************************
  2127.  * FUNCTION
  2128.  *  mmi_phb_go_back_2_history
  2129.  * DESCRIPTION
  2130.  *  Goes back two screens in history
  2131.  * PARAMETERS
  2132.  *  void
  2133.  * RETURNS
  2134.  *  void
  2135.  *****************************************************************************/
  2136. void mmi_phb_go_back_2_history(void)
  2137. {
  2138.     /*----------------------------------------------------------------*/
  2139.     /* Local Variables                                                */
  2140.     /*----------------------------------------------------------------*/
  2141.     /*----------------------------------------------------------------*/
  2142.     /* Code Body                                                      */
  2143.     /*----------------------------------------------------------------*/
  2144.     GoBacknHistory(1);
  2145. }
  2146. /*****************************************************************************
  2147.  * FUNCTION
  2148.  *  mmi_phb_go_back_3_history_and_clear
  2149.  * DESCRIPTION
  2150.  *  Goes back three screens in history
  2151.  * PARAMETERS
  2152.  *  void
  2153.  * RETURNS
  2154.  *  void
  2155.  *****************************************************************************/
  2156. void mmi_phb_go_back_3_history_and_clear(void)
  2157. {
  2158.     /*----------------------------------------------------------------*/
  2159.     /* Local Variables                                                */
  2160.     /*----------------------------------------------------------------*/
  2161.     /*----------------------------------------------------------------*/
  2162.     /* Code Body                                                      */
  2163.     /*----------------------------------------------------------------*/
  2164.     mmi_phb_util_clear_buffer(TRUE);
  2165.     GoBacknHistory(2);
  2166. }
  2167. /*****************************************************************************
  2168.  * FUNCTION
  2169.  *  mmi_phb_set_full_scr_lsk
  2170.  * DESCRIPTION
  2171.  *  Sets the LSK for Full-Screen editor
  2172.  * PARAMETERS
  2173.  *  void
  2174.  * RETURNS
  2175.  *  void
  2176.  *****************************************************************************/
  2177. void mmi_phb_set_full_scr_lsk(void)
  2178. {
  2179.     /*----------------------------------------------------------------*/
  2180.     /* Local Variables                                                */
  2181.     /*----------------------------------------------------------------*/
  2182.     /*----------------------------------------------------------------*/
  2183.     /* Code Body                                                      */
  2184.     /*----------------------------------------------------------------*/
  2185.     ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  2186.     SetLeftSoftkeyFunction(EntryScrForInputMethodAndDone, KEY_EVENT_UP);
  2187.     SetInputMethodAndDoneCaptionIcon(IMG_SCR_PBOOK_CAPTION);
  2188. }
  2189. /*****************************************************************************
  2190.  * FUNCTION
  2191.  *  mmi_phb_clear_old_history
  2192.  * DESCRIPTION
  2193.  *  Deletes old PHB screens from history if Phonebook is re-entered thru some other application
  2194.  * PARAMETERS
  2195.  *  void
  2196.  * RETURNS
  2197.  *  void
  2198.  *****************************************************************************/
  2199. void mmi_phb_clear_old_history(void)
  2200. {
  2201.     /*----------------------------------------------------------------*/
  2202.     /* Local Variables                                                */
  2203.     /*----------------------------------------------------------------*/
  2204.     /*----------------------------------------------------------------*/
  2205.     /* Code Body                                                      */
  2206.     /*----------------------------------------------------------------*/
  2207.     if (g_phb_cntx.start_scr_id && g_phb_cntx.end_scr_id && 
  2208.         IsScreenPresent(g_phb_cntx.start_scr_id))
  2209.     {
  2210.         if (g_phb_cntx.start_scr_id == g_phb_cntx.end_scr_id)
  2211.         {
  2212.             DeleteScreenIfPresent(g_phb_cntx.start_scr_id);
  2213.         }
  2214.         else
  2215.         {
  2216.             U16 end_scr_id = 0;
  2217.             GetPreviousScrnIdOf(GetCmMarkerScrnID(), &end_scr_id);
  2218.             if (end_scr_id) /* since editor common screen won't be save to g_phb_cntx.end_scr_id */
  2219.             {
  2220.                 g_phb_cntx.end_scr_id = end_scr_id;
  2221.             }
  2222.             DeleteBetweenScreen(g_phb_cntx.start_scr_id, g_phb_cntx.end_scr_id);
  2223.         #if defined(__MMI_INCOMING_CALL_VIDEO__)
  2224.             mmi_phb_video_free_buf();
  2225.         #endif 
  2226.         }
  2227.     }
  2228.     else if (g_phb_cntx.end_scr_id)
  2229.     {
  2230.         DeleteScreenIfPresent(g_phb_cntx.end_scr_id);
  2231.     }
  2232.     g_phb_cntx.start_scr_id = g_phb_cntx.end_scr_id = 0;
  2233. }
  2234. /*****************************************************************************
  2235.  * FUNCTION
  2236.  *  mmi_phb_reset_scr_id
  2237.  * DESCRIPTION
  2238.  *  Resets the start and end screen ids on main-menu and idle screen.
  2239.  * PARAMETERS
  2240.  *  void
  2241.  * RETURNS
  2242.  *  void
  2243.  *****************************************************************************/
  2244. void mmi_phb_reset_scr_id(void)
  2245. {
  2246.     /*----------------------------------------------------------------*/
  2247.     /* Local Variables                                                */
  2248.     /*----------------------------------------------------------------*/
  2249.     /*----------------------------------------------------------------*/
  2250.     /* Code Body                                                      */
  2251.     /*----------------------------------------------------------------*/
  2252.     g_phb_cntx.start_scr_id = g_phb_cntx.end_scr_id = 0;
  2253. }
  2254. #define MMI_PHB_IMAGE_LIST
  2255. #if defined(__MMI_FILE_MANAGER__) && defined(MMI_ON_HARDWARE_P)
  2256. /*****************************************************************************
  2257.  * FUNCTION
  2258.  *  mmi_phb_image_list1_draw_title_info
  2259.  * DESCRIPTION
  2260.  *  Draw image list 1 title info. It will draw image, name and number here.
  2261.  * PARAMETERS
  2262.  *  item_idx        [IN]        
  2263.  *  x1              [IN]        
  2264.  *  y1              [IN]        
  2265.  *  x2              [IN]        
  2266.  *  y2              [IN]        
  2267.  * RETURNS
  2268.  *  void
  2269.  *****************************************************************************/
  2270. void mmi_phb_image_list1_draw_title_info(S32 item_idx, S32 x1, S32 y1, S32 x2, S32 y2)
  2271. {
  2272.     /*----------------------------------------------------------------*/
  2273.     /* Local Variables                                                */
  2274.     /*----------------------------------------------------------------*/
  2275.     S32 char_height;
  2276.     S32 box_width, box_height;
  2277.     S32 img_box_width = 40, img_box_height = 40;
  2278.     S32 img_width, img_height;
  2279.     S32 img_draw_width, img_draw_height;
  2280.     S32 img_draw_offset_x, img_draw_offset_y;
  2281.     S32 spacing;
  2282.     S32 offset_x;   /* For name and image offset x */
  2283.     S32 offset_y;   /* For name and image offset y */
  2284.     S32 num_offset_y;
  2285.     S32 name_width;
  2286.     U16 store_index;
  2287.     S8 *image_path = NULL;
  2288.     PHB_OPTIONAL_IDS_STRUCT *opt_ids;
  2289.     S8 buffer_UCS2[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
  2290.     /*----------------------------------------------------------------*/
  2291.     /* Code Body                                                      */
  2292.     /*----------------------------------------------------------------*/
  2293.     /*
  2294.      *lock and push clip
  2295.      */
  2296.     gui_lock_double_buffer();
  2297.     gui_push_text_clip();
  2298.     gui_push_clip();
  2299.     gui_reset_clip();
  2300.     gui_reset_text_clip();
  2301.     /*
  2302.      * Get hint text info
  2303.      */
  2304.     store_index = g_phb_name_index[item_idx];
  2305.     mmi_phb_convert_get_ucs2_number((S8*) buffer_UCS2, store_index);
  2306.     /*
  2307.      * Calcuate text position
  2308.      */
  2309.     box_height = y2 - y1 + 1;
  2310.     box_width = x2 - x1 + 1;
  2311.     gui_set_font(&MMI_medium_font);
  2312.     char_height = gui_get_string_height((UI_string_type) GetString(STR_ID_PHB_MOBILE_NUMBER));
  2313.     spacing = (box_height - char_height * 2) / 3;
  2314.     offset_y = spacing + MMI_title_height + MMI_title_y;
  2315.     num_offset_y = spacing * 2 + char_height + MMI_title_height + MMI_title_y;
  2316.     if (r2lMMIFlag) /* For right to left language */
  2317.     {
  2318.         offset_x = x2 - img_box_width - 6;
  2319.     }
  2320.     else
  2321.     {
  2322.         offset_x = x1 + img_box_width + 6;
  2323.     }
  2324.     name_width = box_width - img_box_width - 12;
  2325.     /*
  2326.      * Draw Hint Text
  2327.      */
  2328.     gui_set_font(&MMI_medium_font);
  2329.     gui_reset_text_clip();
  2330.     gui_set_text_color(gui_color(0, 0, 0));
  2331.     /*
  2332.      * Draw name/number if not empty
  2333.      */
  2334.     if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name))
  2335.     {
  2336.         gui_print_truncated_text(offset_x, offset_y, name_width, (UI_string_type) PhoneBook[store_index].alpha_id.name);
  2337.         if (pfnUnicodeStrlen((S8*) buffer_UCS2))
  2338.         {
  2339.             gui_print_truncated_text(offset_x, num_offset_y, name_width, (UI_string_type) buffer_UCS2);
  2340.         }
  2341.     }
  2342.     else
  2343.     {
  2344.         gui_print_truncated_text(offset_x, offset_y, name_width, (UI_string_type) buffer_UCS2);
  2345.     }
  2346.     /*
  2347.      * Get Associate Picture path from file
  2348.      */
  2349.     if (store_index < MAX_PB_PHONE_ENTRIES)
  2350.     {
  2351.         mmi_phb_read_optional_ids(store_index); /* i is store index */
  2352.         opt_ids = (PHB_OPTIONAL_IDS_STRUCT*) g_phb_cntx.optional_ids;
  2353.         if (opt_ids->pictureTagID == 1)
  2354.         {
  2355.             image_path = mmi_phb_image_get_path_from_id((U16) (store_index + 1));
  2356.         }
  2357.     }
  2358.     /*
  2359.      * Draw Associate Picture thumb image
  2360.      */
  2361.     gui_push_clip();
  2362.     if (r2lMMIFlag) /* For right to left language */
  2363.     {
  2364.         offset_x = x2 - img_box_width - 2;
  2365.     }
  2366.     else
  2367.     {
  2368.         offset_x = x1 + 2;
  2369.     }
  2370.     offset_y = y1 + 2;
  2371.     gui_set_clip(offset_x, offset_y, offset_x + img_box_width, offset_y + img_box_height);
  2372.     /* Get image from file */
  2373. #ifdef __USB_IN_NORMAL_MODE__ 
  2374.     if (mmi_usb_is_in_mass_storage_mode())
  2375.     {
  2376.         gdi_image_draw_resized_id(offset_x, offset_y, img_box_width, img_box_height, IMG_ID_PHB_LIST_ICON1);
  2377.     }
  2378.     else
  2379. #endif /* __USB_IN_NORMAL_MODE */
  2380.     {    
  2381.         if ((image_path != NULL) && (gdi_image_get_dimension_file(image_path, &img_width, &img_height) >= 0))
  2382.         {
  2383.             gdi_util_fit_box(
  2384.                 GDI_UTIL_MODE_NO_RESIZE_OR_LONG_SIDE_FIT,
  2385.                 img_box_width,
  2386.                 img_box_height,
  2387.                 img_width,
  2388.                 img_height,
  2389.                 &img_draw_offset_x,
  2390.                 &img_draw_offset_y,
  2391.                 &img_draw_width,
  2392.                 &img_draw_height);
  2393.             gdi_image_draw_resized_file(
  2394.                 offset_x + img_draw_offset_x,
  2395.                 offset_y + img_draw_offset_y,
  2396.                 img_draw_width,
  2397.                 img_draw_height,
  2398.                 image_path);
  2399.         }
  2400.         else    /* Use default image */
  2401.         {
  2402.             gdi_image_draw_resized_id(offset_x, offset_y, img_box_width, img_box_height, IMG_ID_PHB_LIST_ICON1);
  2403.         }
  2404.     }
  2405.     gui_pop_clip();
  2406.     /*
  2407.      * pop clip , unlock and blt
  2408.      */
  2409.     gui_pop_clip();
  2410.     gui_pop_text_clip();
  2411.     gui_unlock_double_buffer();
  2412.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
  2413. }
  2414. /*****************************************************************************
  2415.  * FUNCTION
  2416.  *  mmi_phb_entry_image_list1
  2417.  * DESCRIPTION
  2418.  *  This function list all phonebook entry with picture info on the top.
  2419.  * PARAMETERS
  2420.  *  void
  2421.  * RETURNS
  2422.  *  void
  2423.  *****************************************************************************/
  2424. void mmi_phb_entry_image_list1(void)
  2425. {
  2426.     /*----------------------------------------------------------------*/
  2427.     /* Local Variables                                                */
  2428.     /*----------------------------------------------------------------*/
  2429.     U8 *guiBuffer;
  2430.     /*----------------------------------------------------------------*/
  2431.     /* Code Body                                                      */
  2432.     /*----------------------------------------------------------------*/
  2433.     /*
  2434.      * Check if it can be list in advance
  2435.      */
  2436.     if (!g_phb_cntx.phb_ready || g_phb_cntx.processing)
  2437.     {
  2438.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  2439.         return;
  2440.     }
  2441. #ifdef __SYNCML_SUPPORT__
  2442.     else if (mmi_syncml_is_phb_sync_now())
  2443.     {
  2444.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  2445.         return;
  2446.     }
  2447. #endif /* __SYNCML_SUPPORT__ */
  2448.     else if (PhoneBookEntryCount == 0)
  2449.     {
  2450.         DisplayPopup(
  2451.             (PU8) GetString(STR_NO_ENTRIES_MESSAGE),
  2452.             IMG_GLOBAL_EMPTY,
  2453.             TRUE,
  2454.             PHB_NOTIFY_TIMEOUT,
  2455.             EMPTY_LIST_TONE);
  2456.         return;
  2457.     }
  2458.     /*
  2459.      *Check if phonebook entry has been updated, and if need to use alpha_index function.
  2460.      */
  2461.     if (g_phb_cntx.refresh_list)
  2462.     {
  2463.         mmi_phb_list_build_alpha_index(NULL, 0, TRUE, MMI_STORAGE_NONE);
  2464.         g_phb_cntx.refresh_list = MMI_PHB_ENTRY_NO_CHANGE;
  2465.     }
  2466.     EntryNewScreen(SCR_PBOOK_LIST, mmi_phb_exit_list, mmi_phb_entry_image_list1, NULL);
  2467.     guiBuffer = GetCurrGuiBuffer(SCR_PBOOK_LIST);
  2468. #if defined(__MMI_TOUCH_SCREEN__) && defined(__MMI_WGUI_CSK_ENABLE__)
  2469.     if (gInsertSimAppFlag != 1 && mmi_bootup_get_active_flight_mode() != 1)
  2470.     {
  2471.         EnableCenterSoftkey(0, IMG_CSK_DIAL_ICON);
  2472.     }
  2473. #endif /* defined(__MMI_TOUCH_SCREEN__) && defined(__MMI_WGUI_CSK_ENABLE__) */ 
  2474. #if defined(__MMI_INTELLIGENT_CALL_ALERT__)
  2475.     RegisterHighlightHandler(mmi_phb_get_index_speak_name);
  2476. #else 
  2477.     RegisterHighlightHandler(mmi_phb_get_index);
  2478. #endif 
  2479.     ShowCategory212Screen(
  2480.         STR_SCR_PBOOK_VIEW_CAPTION,
  2481.         IMG_SCR_PBOOK_CAPTION,      /* Title */
  2482.         STR_GLOBAL_OPTIONS,
  2483.         IMG_GLOBAL_OPTIONS,         /* LSK */
  2484.         STR_GLOBAL_BACK,
  2485.         IMG_GLOBAL_BACK,            /* RSK */
  2486.         PhoneBookEntryCount,
  2487.         mmi_phb_list_get_item,
  2488.         mmi_phb_list_get_null_hint,
  2489.         mmi_phb_image_list1_draw_title_info,
  2490.         NULL,                       /* No call back needed when change highlight */
  2491.         2,                          /* Info box row count */
  2492.         0,                          /* info bg image id */
  2493.         g_phb_cntx.highlight_entry, /* Highlight item index */
  2494.         (U8*) guiBuffer);
  2495.     register_multitap_no_draw_key_handlers();
  2496.     set_multitap_functions(mmi_phb_list_alpha_index, mmi_phb_list_alpha_index_input_callback);
  2497.     change_multitap_mode(0);
  2498.     SetLeftSoftkeyFunction(mmi_phb_entry_op_option, KEY_EVENT_UP);
  2499.     SetKeyHandler(mmi_phb_entry_op_option, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  2500.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2501.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2502.     if (gInsertSimAppFlag != 1 && mmi_bootup_get_active_flight_mode() != 1)
  2503.     {
  2504.         SetKeyHandler(mmi_phb_choose_number_normal, KEY_SEND, KEY_EVENT_UP);
  2505.     #if defined(__MMI_TOUCH_SCREEN__) && defined(__MMI_WGUI_CSK_ENABLE__)
  2506.         SetCenterSoftkeyFunction(mmi_phb_choose_number_normal, KEY_EVENT_UP);
  2507.     #endif 
  2508.     }
  2509. }
  2510. #if defined(__MMI_PHB_NAME_LIST_FILTER__)
  2511. /*****************************************************************************
  2512.  * FUNCTION
  2513.  *  mmi_phb_nlf_image_list1_draw_title_info
  2514.  * DESCRIPTION
  2515.  *  Draw image list 1 title info. It will draw image, name and number here.
  2516.  * PARAMETERS
  2517.  *  item_idx        [IN]        
  2518.  *  x1              [IN]        
  2519.  *  y1              [IN]        
  2520.  *  x2              [IN]        
  2521.  *  y2              [IN]        
  2522.  * RETURNS
  2523.  *  void
  2524.  *****************************************************************************/
  2525. void mmi_phb_nlf_image_list1_draw_title_info(S32 item_idx, S32 x1, S32 y1, S32 x2, S32 y2)
  2526. {
  2527.     /*----------------------------------------------------------------*/
  2528.     /* Local Variables                                                */
  2529.     /*----------------------------------------------------------------*/
  2530.     S32 char_height;
  2531.     S32 box_width, box_height;
  2532.     S32 img_box_width = 40, img_box_height = 40;
  2533.     S32 img_width, img_height;
  2534.     S32 img_draw_width, img_draw_height;
  2535.     S32 img_draw_offset_x, img_draw_offset_y;
  2536.     S32 spacing;
  2537.     S32 offset_x;   /* For name and image offset x */
  2538.     S32 offset_y;   /* For name and image offset y */
  2539.     S32 num_offset_y;
  2540.     S32 name_width;
  2541.     U16 store_index = 0;
  2542.     S8 *image_path = NULL;
  2543.     PHB_OPTIONAL_IDS_STRUCT *opt_ids;
  2544.     S8 buffer_UCS2[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
  2545.     S32 i = -1;
  2546.     S32 inner_index = 0;
  2547.     /*----------------------------------------------------------------*/
  2548.     /* Code Body                                                      */
  2549.     /*----------------------------------------------------------------*/
  2550.     /*
  2551.      *lock and push clip
  2552.      */
  2553.     gui_lock_double_buffer();
  2554.     gui_push_text_clip();
  2555.     gui_push_clip();
  2556.     gui_reset_clip();
  2557.     gui_reset_text_clip();
  2558.     while (i < item_idx)
  2559.     {
  2560.         store_index = g_phb_name_index[inner_index];
  2561.         if (g_phb_cntx.name_list_filter == MMI_SIM)
  2562.         {
  2563.             if (store_index >= MAX_PB_PHONE_ENTRIES)
  2564.             {
  2565.                 i++;
  2566.             }
  2567.         }
  2568.         else if (g_phb_cntx.name_list_filter == MMI_NVRAM)
  2569.         {
  2570.             if(store_index < MAX_PB_PHONE_ENTRIES)
  2571.             {
  2572.                 i++;
  2573.             }
  2574.         }
  2575.         else
  2576.         {
  2577.             i++;
  2578.         }
  2579.         inner_index++;
  2580.     }
  2581.     /*
  2582.      * Get hint text info
  2583.      */
  2584.     mmi_phb_convert_get_ucs2_number((S8*) buffer_UCS2, store_index);
  2585.     /*
  2586.      * Calcuate text position
  2587.      */
  2588.     box_height = y2 - y1 + 1;
  2589.     box_width = x2 - x1 + 1;
  2590.     gui_set_font(&MMI_medium_font);
  2591.     char_height = gui_get_string_height((UI_string_type) GetString(STR_ID_PHB_MOBILE_NUMBER));
  2592.     spacing = (box_height - char_height * 2) / 3;
  2593.     offset_y = spacing + MMI_title_height + MMI_title_y;
  2594.     num_offset_y = spacing * 2 + char_height + MMI_title_height + MMI_title_y;
  2595.     if (r2lMMIFlag) /* For right to left language */
  2596.     {
  2597.         offset_x = x2 - img_box_width - 6;
  2598.     }
  2599.     else
  2600.     {
  2601.         offset_x = x1 + img_box_width + 6;
  2602.     }
  2603.     name_width = box_width - img_box_width - 12;
  2604.     /*
  2605.      * Draw Hint Text
  2606.      */
  2607.     gui_set_font(&MMI_medium_font);
  2608.     gui_reset_text_clip();
  2609.     gui_set_text_color(gui_color(0, 0, 0));
  2610.     /*
  2611.      * Draw name/number if not empty
  2612.      */
  2613.     if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name))
  2614.     {
  2615.         gui_print_truncated_text(offset_x, offset_y, name_width, (UI_string_type) PhoneBook[store_index].alpha_id.name);
  2616.         if (pfnUnicodeStrlen((S8*) buffer_UCS2))
  2617.         {
  2618.             gui_print_truncated_text(offset_x, num_offset_y, name_width, (UI_string_type) buffer_UCS2);
  2619.         }
  2620.     }
  2621.     else
  2622.     {
  2623.         gui_print_truncated_text(offset_x, offset_y, name_width, (UI_string_type) buffer_UCS2);
  2624.     }
  2625.     /*
  2626.      * Get Associate Picture path from file
  2627.      */
  2628.     if (store_index < MAX_PB_PHONE_ENTRIES)
  2629.     {
  2630.         mmi_phb_read_optional_ids(store_index); /* i is store index */
  2631.         opt_ids = (PHB_OPTIONAL_IDS_STRUCT*) g_phb_cntx.optional_ids;
  2632.         if (opt_ids->pictureTagID == 1)
  2633.         {
  2634.             image_path = mmi_phb_image_get_path_from_id((U16) (store_index + 1));
  2635.         }
  2636.     }
  2637.     /*
  2638.      * Draw Associate Picture thumb image
  2639.      */
  2640.     gui_push_clip();
  2641.     if (r2lMMIFlag) /* For right to left language */
  2642.     {
  2643.         offset_x = x2 - img_box_width - 2;
  2644.     }
  2645.     else
  2646.     {
  2647.         offset_x = x1 + 2;
  2648.     }
  2649.     offset_y = y1 + 2;
  2650.     gui_set_clip(offset_x, offset_y, offset_x + img_box_width, offset_y + img_box_height);
  2651.     /* Get image from file */
  2652. #ifdef __USB_IN_NORMAL_MODE__ 
  2653.     if (mmi_usb_is_in_mass_storage_mode())
  2654.     {
  2655.         gdi_image_draw_resized_id(offset_x, offset_y, img_box_width, img_box_height, IMG_ID_PHB_LIST_ICON1);
  2656.     }
  2657.     else
  2658. #endif /* __USB_IN_NORMAL_MODE */
  2659.     {    
  2660.         if ((image_path != NULL) && (gdi_image_get_dimension_file(image_path, &img_width, &img_height) >= 0))
  2661.         {
  2662.             gdi_util_fit_box(
  2663.                 GDI_UTIL_MODE_NO_RESIZE_OR_LONG_SIDE_FIT,
  2664.                 img_box_width,
  2665.                 img_box_height,
  2666.                 img_width,
  2667.                 img_height,
  2668.                 &img_draw_offset_x,
  2669.                 &img_draw_offset_y,
  2670.                 &img_draw_width,
  2671.                 &img_draw_height);
  2672.             gdi_image_draw_resized_file(
  2673.                 offset_x + img_draw_offset_x,
  2674.                 offset_y + img_draw_offset_y,
  2675.                 img_draw_width,
  2676.                 img_draw_height,
  2677.                 image_path);
  2678.         }
  2679.         else    /* Use default image */
  2680.         {
  2681.             gdi_image_draw_resized_id(offset_x, offset_y, img_box_width, img_box_height, IMG_ID_PHB_LIST_ICON1);
  2682.         }
  2683.     }
  2684.     gui_pop_clip();
  2685.     /*
  2686.      * pop clip , unlock and blt
  2687.      */
  2688.     gui_pop_clip();
  2689.     gui_pop_text_clip();
  2690.     gui_unlock_double_buffer();
  2691.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
  2692. }
  2693. /*****************************************************************************
  2694.  * FUNCTION
  2695.  *  mmi_phb_nlf_entry_image_list1
  2696.  * DESCRIPTION
  2697.  *  This function list all phonebook entry with picture info on the top with
  2698.  *  name list filter feature.
  2699.  * PARAMETERS
  2700.  *  void
  2701.  * RETURNS
  2702.  *  void
  2703.  *****************************************************************************/
  2704. void mmi_phb_nlf_entry_image_list1(void)
  2705. {
  2706.     /*----------------------------------------------------------------*/
  2707.     /* Local Variables                                                */
  2708.     /*----------------------------------------------------------------*/
  2709.     U8 *guiBuffer;
  2710.     /*----------------------------------------------------------------*/
  2711.     /* Code Body                                                      */
  2712.     /*----------------------------------------------------------------*/
  2713.     /*
  2714.      * Check if it can be list in advance
  2715.      */
  2716.     if (!g_phb_cntx.phb_ready || g_phb_cntx.processing)
  2717.     {
  2718.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  2719.         return;
  2720.     }
  2721.     else if (((g_phb_cntx.sim_used == 0) && (g_phb_cntx.name_list_filter == MMI_SIM)) || ((g_phb_cntx.phone_used == 0) && (g_phb_cntx.name_list_filter == MMI_NVRAM)) ||((PhoneBookEntryCount == 0) && (g_phb_cntx.name_list_filter == MMI_STORAGE_BOTH)))
  2722.     {
  2723.         DisplayPopup(
  2724.             (PU8) GetString(STR_NO_ENTRIES_MESSAGE),
  2725.             IMG_GLOBAL_EMPTY,
  2726.             TRUE,
  2727.             PHB_NOTIFY_TIMEOUT,
  2728.             EMPTY_LIST_TONE);
  2729.         return;
  2730.     }
  2731.     /*
  2732.      *Check if phonebook entry has been updated, and if need to use alpha_index function.
  2733.      */
  2734.     if (g_phb_cntx.refresh_list)
  2735.     {
  2736.         mmi_phb_list_build_alpha_index(NULL, 0, TRUE, MMI_STORAGE_NONE);
  2737.         g_phb_cntx.refresh_list = MMI_PHB_ENTRY_NO_CHANGE;
  2738.     }
  2739.     EntryNewScreen(SCR_PBOOK_LIST, mmi_phb_exit_list, mmi_phb_nlf_entry_image_list1, NULL);
  2740.     guiBuffer = GetCurrGuiBuffer(SCR_PBOOK_LIST);
  2741. #if defined(__MMI_TOUCH_SCREEN__) && defined(__MMI_WGUI_CSK_ENABLE__)
  2742.     if (gInsertSimAppFlag != 1 && mmi_bootup_get_active_flight_mode() != 1)
  2743.     {
  2744.         EnableCenterSoftkey(0, IMG_CSK_DIAL_ICON);
  2745.     }
  2746. #endif /* defined(__MMI_TOUCH_SCREEN__) && defined(__MMI_WGUI_CSK_ENABLE__) */ 
  2747. #if defined(__MMI_INTELLIGENT_CALL_ALERT__)
  2748.     RegisterHighlightHandler(mmi_phb_get_index_speak_name_nlf);
  2749. #else 
  2750.     RegisterHighlightHandler(mmi_phb_get_index_nlf);
  2751. #endif 
  2752. if(g_phb_cntx.name_list_filter == MMI_SIM)
  2753. {
  2754. g_phb_list_index_total = g_phb_cntx.sim_used;
  2755. }
  2756. else if(g_phb_cntx.name_list_filter == MMI_NVRAM)
  2757. {
  2758. g_phb_list_index_total = g_phb_cntx.phone_used;
  2759. }
  2760. else
  2761. {
  2762. g_phb_list_index_total = PhoneBookEntryCount;
  2763. }
  2764.     ShowCategory212Screen(
  2765.         STR_SCR_PBOOK_VIEW_CAPTION,
  2766.         IMG_SCR_PBOOK_CAPTION,      /* Title */
  2767.         STR_GLOBAL_OPTIONS,
  2768.         IMG_GLOBAL_OPTIONS,         /* LSK */
  2769.         STR_GLOBAL_BACK,
  2770.         IMG_GLOBAL_BACK,            /* RSK */
  2771. g_phb_list_index_total,
  2772.         mmi_phb_nlf_list_get_item,
  2773.         mmi_phb_list_get_null_hint,
  2774.         mmi_phb_nlf_image_list1_draw_title_info,
  2775.         NULL,                       /* No call back needed when change highlight */
  2776.         2,                          /* Info box row count */
  2777.         0,                          /* info bg image id */
  2778.         g_phb_cntx.highlight_entry, /* Highlight item index */
  2779.         (U8*) guiBuffer);
  2780.     register_multitap_no_draw_key_handlers();
  2781.     set_multitap_functions(mmi_phb_list_alpha_index, mmi_phb_list_alpha_index_input_callback);
  2782.     change_multitap_mode(0);
  2783.     SetLeftSoftkeyFunction(mmi_phb_entry_op_option, KEY_EVENT_UP);
  2784.     SetKeyHandler(mmi_phb_entry_op_option, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  2785.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2786.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2787.     if (gInsertSimAppFlag != 1 && mmi_bootup_get_active_flight_mode() != 1)
  2788.     {
  2789.         SetKeyHandler(mmi_phb_choose_number_normal, KEY_SEND, KEY_EVENT_UP);
  2790.     #if defined(__MMI_TOUCH_SCREEN__) && defined(__MMI_WGUI_CSK_ENABLE__)
  2791.         SetCenterSoftkeyFunction(mmi_phb_choose_number_normal, KEY_EVENT_UP);
  2792.     #endif 
  2793.     }
  2794. }
  2795. #endif /* defined(__MMI_PHB_NAME_LIST_FILTER__) */
  2796. #endif /* defined(__MMI_FILE_MANAGER__) && defined(MMI_ON_HARDWARE_P) */ 
  2797. #define MMI_PHB_UTIL_OBSELETE
  2798. U8 inPinyinSearchScreen = FALSE;    /* For PinYin Search, Obselete Now */
  2799. /*****************************************************************************
  2800.  * FUNCTION
  2801.  *  PbookListSearchEntryReq
  2802.  * DESCRIPTION
  2803.  *  Sends the request to stack to search for an entry based on the name entered by the user
  2804.  * PARAMETERS
  2805.  *  void
  2806.  * RETURNS
  2807.  *  void
  2808.  *****************************************************************************/
  2809. void PbookListSearchEntryReq(void)
  2810. {
  2811.     /*----------------------------------------------------------------*/
  2812.     /* Local Variables                                                */
  2813.     /*----------------------------------------------------------------*/
  2814.     /*----------------------------------------------------------------*/
  2815.     /* Code Body                                                      */
  2816.     /*----------------------------------------------------------------*/
  2817. }
  2818. #endif /* _PHONEBOOKMAIN_C */