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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * PhoneBookExtraNumber.C
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   Implementation of feature "Owner Number", "Service Dial Number",
  48.  *   and "SOS number"
  49.  *
  50.  * Author:
  51.  * -------
  52.  * -------
  53.  *
  54.  *============================================================================
  55.  *             HISTORY
  56.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  57.  *------------------------------------------------------------------------------
  58.  * removed!
  59.  *
  60.  * removed!
  61.  * removed!
  62.  * removed!
  63.  *
  64.  * removed!
  65.  * removed!
  66.  * removed!
  67.  *
  68.  * removed!
  69.  * removed!
  70.  * removed!
  71.  *
  72.  * removed!
  73.  * removed!
  74.  * removed!
  75.  *
  76.  * removed!
  77.  * removed!
  78.  * removed!
  79.  *
  80.  * removed!
  81.  * removed!
  82.  * removed!
  83.  *
  84.  * removed!
  85.  * removed!
  86.  * removed!
  87.  *
  88.  * removed!
  89.  * removed!
  90.  * removed!
  91.  *
  92.  * removed!
  93.  * removed!
  94.  * removed!
  95.  *
  96.  *------------------------------------------------------------------------------
  97.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  98.  *============================================================================
  99.  ****************************************************************************/
  100. #ifndef _PHONEBOOKEXTRANUMBER_C
  101. #define _PHONEBOOKEXTRANUMBER_C
  102. #include "MMI_features.h"
  103. #include "StdC.h"
  104. #include "L4Dr1.h"
  105. #include "PixtelDataTypes.h"
  106. #include "GlobalMenuItems.h"
  107. #include "GSM7BitDefaultAlphabet.h"
  108. #include "DebugInitDef.h"
  109. #include "GlobalDefs.h"
  110. #include "EventsGprot.h"
  111. #include "wgui_categories.h"
  112. #include "wgui_categories_inputs.h"
  113. #include "wgui_categories_popup.h"
  114. #include "PhonebookDef.h"
  115. #include "PhoneBookTypes.h"
  116. #include "PhoneBookProt.h"
  117. #include "PhoneBookGprot.h"
  118. #include "HistoryGprot.h"
  119. #include "NVRAMEnum.h"
  120. #include "NVRAMProt.h"
  121. #include "ProtocolEvents.h"
  122. #include "Unicodexdcl.h"
  123. #include "QueueGProt.h"
  124. #include "TimerEvents.h"
  125. #include "SimDetectionGexdcl.h"
  126. #include "CommonScreens.h"
  127. #include "CallSetUp.h"
  128. #include "SettingDefs.h"        /* For FDN */
  129. #include "SettingsGdcl.h"       /* For FDN */
  130. #include "SpeedDial.h"
  131. #include "CallManagementGProt.h"
  132. /* 
  133.  * Local Variable
  134.  */
  135. static MMI_PHB_ENTRY_STRUCT g_phb_sim_list[MAX_SIM_ENTRIES];    /* Maximum entry of MSISDN, SDL and SOS in SIM */
  136. static U16 g_phb_sim_list_count;
  137. U16 g_phb_read_index;
  138. static MMI_SOS_NUMBER_STRUCT g_phb_nvram_list[MAX_NVRAM_SOS_ENTRIES];   /* Emergency Number in NVRAM */
  139. static U8 *g_phb_sos_list[MAX_SIM_SOS_ENTRIES + MAX_NVRAM_SOS_ENTRIES];
  140. static BOOL g_phb_edit_owner = FALSE;
  141. static BOOL g_phb_operate_owner = FALSE;
  142. static U8 g_phb_sos_nvram_read = 0;
  143. static U16 g_phb_fdn_count = 0;         /* For FDN Lookup List */
  144. static U8 g_phb_is_get_entry_rsp = 1;   /* Check if already get response for previous request. */
  145. /* 
  146.  * Global Variable
  147.  */
  148. extern S8 pbName[];
  149. extern S8 pbNumber[];
  150. extern wgui_inline_item wgui_inline_items[];
  151. extern MMI_OWNER_NUMBER_STRUCT gDispOwnerNumber[2]; /* Owner number associate with Line ID */
  152. extern MMI_PHB_ENTRY_BCD_STRUCT PhoneBook[];
  153. /* 
  154.  * Global Function
  155.  */
  156. extern void RefreshDisplayOwnerNumber(U8 lineid);   /* Owner number associate with Line ID */
  157. extern void MakeCall(PS8);                          /* For Service Dial Number */
  158. #define MMI_PHB_EXTRA_NUMBER
  159. /*****************************************************************************
  160.  * FUNCTION
  161.  *  mmi_phb_extra_number_init
  162.  * DESCRIPTION
  163.  *  Initialization of Owner Number feature
  164.  * PARAMETERS
  165.  *  void
  166.  * RETURNS
  167.  *  void
  168.  *****************************************************************************/
  169. void mmi_phb_extra_number_init(void)
  170. {
  171.     /*----------------------------------------------------------------*/
  172.     /* Local Variables                                                */
  173.     /*----------------------------------------------------------------*/
  174.     /*----------------------------------------------------------------*/
  175.     /* Code Body                                                      */
  176.     /*----------------------------------------------------------------*/
  177.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_extra_number_init.>n", __FILE__,
  178.                          __LINE__));
  179.     SetHiliteHandler(MENU_ID_PHB_EXTRA_NUMBER, mmi_phb_highlight_extra_number);
  180.     SetHiliteHandler(MITEM105_PBOOK_OWNER_NUMBER, mmi_phb_highlight_owner_number);
  181.     SetHiliteHandler(MITEM1051_OWNER_NUMBER_ERASE, mmi_phb_highlight_owner_number_erase);
  182.     SetHiliteHandler(MITEM1052_OWNER_NUMBER_EDIT, mmi_phb_highlight_owner_number_edit);
  183.     SetHiliteHandler(MENU_PHONEBOOK_SERVICENUMBER, mmi_phb_highlight_sdn_list);
  184. }
  185. /*****************************************************************************
  186.  * FUNCTION
  187.  *  mmi_phb_highlight_extra_number
  188.  * DESCRIPTION
  189.  *  highlight function of extra number
  190.  * PARAMETERS
  191.  *  void
  192.  * RETURNS
  193.  *  void
  194.  *****************************************************************************/
  195. void mmi_phb_highlight_extra_number(void)
  196. {
  197.     /*----------------------------------------------------------------*/
  198.     /* Local Variables                                                */
  199.     /*----------------------------------------------------------------*/
  200.     /*----------------------------------------------------------------*/
  201.     /* Code Body                                                      */
  202.     /*----------------------------------------------------------------*/
  203.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  204.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  205.     SetLeftSoftkeyFunction(mmi_phb_entry_extra_number, KEY_EVENT_UP);
  206.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  207.     SetKeyHandler(mmi_phb_entry_extra_number, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  208.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  209. }
  210. /*****************************************************************************
  211.  * FUNCTION
  212.  *  mmi_phb_entry_extra_number
  213.  * DESCRIPTION
  214.  *  entry function of extra number
  215.  * PARAMETERS
  216.  *  void
  217.  * RETURNS
  218.  *  void
  219.  *****************************************************************************/
  220. void mmi_phb_entry_extra_number(void)
  221. {
  222.     /*----------------------------------------------------------------*/
  223.     /* Local Variables                                                */
  224.     /*----------------------------------------------------------------*/
  225.     U8 *guiBuffer;
  226.     U16 nStrItemList[5];
  227.     U8 *nHintList[5];
  228.     U16 nNumofItem;
  229.     /*----------------------------------------------------------------*/
  230.     /* Code Body                                                      */
  231.     /*----------------------------------------------------------------*/
  232.     EntryNewScreen(SCR_ID_PHB_SPECIAL_NUMBER, mmi_phb_exit_extra_number, mmi_phb_entry_extra_number, NULL);
  233.     guiBuffer = GetCurrGuiBuffer(SCR_ID_PHB_SPECIAL_NUMBER);
  234.     nNumofItem = GetNumOfChild(MENU_ID_PHB_EXTRA_NUMBER);
  235.     GetSequenceStringIds(MENU_ID_PHB_EXTRA_NUMBER, nStrItemList);
  236.     SetParentHandler(MENU_ID_PHB_EXTRA_NUMBER);
  237.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  238.     ConstructHintsList(MENU_ID_PHB_EXTRA_NUMBER, nHintList);
  239.     ShowCategory52Screen(
  240.         STR_ID_PHB_EXTRA_NUMBER,
  241.         IMG_SCR_PBOOK_CAPTION,
  242.         STR_GLOBAL_OK,
  243.         IMG_GLOBAL_OK,
  244.         STR_GLOBAL_BACK,
  245.         IMG_GLOBAL_BACK,
  246.         nNumofItem,
  247.         nStrItemList,
  248.         (U16*) gIndexIconsImageList,
  249.         nHintList,
  250.         0,
  251.         0,
  252.         guiBuffer);
  253. }
  254. /*****************************************************************************
  255.  * FUNCTION
  256.  *  mmi_phb_exit_extra_number
  257.  * DESCRIPTION
  258.  *  exit function of extra number
  259.  * PARAMETERS
  260.  *  void
  261.  * RETURNS
  262.  *  void
  263.  *****************************************************************************/
  264. void mmi_phb_exit_extra_number(void)
  265. {
  266.     /*----------------------------------------------------------------*/
  267.     /* Local Variables                                                */
  268.     /*----------------------------------------------------------------*/
  269.     /*----------------------------------------------------------------*/
  270.     /* Code Body                                                      */
  271.     /*----------------------------------------------------------------*/
  272.     g_phb_cntx.end_scr_id = SCR_ID_PHB_SPECIAL_NUMBER;
  273. }
  274. /* --------------------------------------  Begin of Phone Book Owner Number ------------------------------------------- */
  275. #define MMI_PHB_OWNER_NUMBER
  276. /*****************************************************************************
  277.  * FUNCTION
  278.  *  mmi_phb_highlight_owner_number
  279.  * DESCRIPTION
  280.  *  Highlight handler for Owner Number in PHB main menu
  281.  * PARAMETERS
  282.  *  void
  283.  * RETURNS
  284.  *  void
  285.  *****************************************************************************/
  286. void mmi_phb_highlight_owner_number(void)
  287. {
  288.     /*----------------------------------------------------------------*/
  289.     /* Local Variables                                                */
  290.     /*----------------------------------------------------------------*/
  291.     /*----------------------------------------------------------------*/
  292.     /* Code Body                                                      */
  293.     /*----------------------------------------------------------------*/
  294.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_highlight_owner_number.>n", __FILE__,
  295.                          __LINE__));
  296.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  297.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  298.     SetLeftSoftkeyFunction(mmi_phb_owner_number_pre_req, KEY_EVENT_UP);
  299.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  300.     SetKeyHandler(mmi_phb_owner_number_pre_req, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  301.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  302. }
  303. /*****************************************************************************
  304.  * FUNCTION
  305.  *  mmi_phb_highlight_owner_number_erase
  306.  * DESCRIPTION
  307.  *  Highlight handler for owner number's option "Erase"
  308.  * PARAMETERS
  309.  *  void
  310.  * RETURNS
  311.  *  void
  312.  *****************************************************************************/
  313. void mmi_phb_highlight_owner_number_erase(void)
  314. {
  315.     /*----------------------------------------------------------------*/
  316.     /* Local Variables                                                */
  317.     /*----------------------------------------------------------------*/
  318.     /*----------------------------------------------------------------*/
  319.     /* Code Body                                                      */
  320.     /*----------------------------------------------------------------*/
  321.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_highlight_owner_number_erase.>n",
  322.                          __FILE__, __LINE__));
  323.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  324.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  325.     SetLeftSoftkeyFunction(mmi_phb_owner_number_pre_erase, KEY_EVENT_UP);
  326.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  327.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  328.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  329. }
  330. /*****************************************************************************
  331.  * FUNCTION
  332.  *  mmi_phb_highlight_owner_number_edit
  333.  * DESCRIPTION
  334.  *  Highlight handler for owner number's option "Edit"
  335.  * PARAMETERS
  336.  *  void
  337.  * RETURNS
  338.  *  void
  339.  *****************************************************************************/
  340. void mmi_phb_highlight_owner_number_edit(void)
  341. {
  342.     /*----------------------------------------------------------------*/
  343.     /* Local Variables                                                */
  344.     /*----------------------------------------------------------------*/
  345.     /*----------------------------------------------------------------*/
  346.     /* Code Body                                                      */
  347.     /*----------------------------------------------------------------*/
  348.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_highlight_owner_number_edit.>n", __FILE__,
  349.                          __LINE__));
  350.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  351.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  352.     SetLeftSoftkeyFunction(mmi_phb_owner_number_pre_edit, KEY_EVENT_UP);
  353.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  354.     SetKeyHandler(mmi_phb_owner_number_pre_edit, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  355.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  356. }
  357. /*****************************************************************************
  358.  * FUNCTION
  359.  *  mmi_phb_owner_number_pre_req
  360.  * DESCRIPTION
  361.  *  Checks and calls the L4 request function
  362.  * PARAMETERS
  363.  *  void
  364.  * RETURNS
  365.  *  void
  366.  *****************************************************************************/
  367. void mmi_phb_owner_number_pre_req(void)
  368. {
  369.     /*----------------------------------------------------------------*/
  370.     /* Local Variables                                                */
  371.     /*----------------------------------------------------------------*/
  372.     /*----------------------------------------------------------------*/
  373.     /* Code Body                                                      */
  374.     /*----------------------------------------------------------------*/
  375.     if (g_phb_cntx.phb_ready)
  376.     {
  377.         mmi_phb_show_in_progress(STR_PROCESSING_PHONEBOOK, IMG_PROCESSING_PHONEBOOK);
  378.         mmi_phb_owner_number_get_entry_req();
  379.     }
  380.     else
  381.     {
  382.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  383.     }
  384. }
  385. /*****************************************************************************
  386.  * FUNCTION
  387.  *  mmi_phb_owner_number_get_entry_req
  388.  * DESCRIPTION
  389.  *  Sends the L4 request to fetch the owner numbers
  390.  * PARAMETERS
  391.  *  void
  392.  * RETURNS
  393.  *  void
  394.  *****************************************************************************/
  395. void mmi_phb_owner_number_get_entry_req(void)
  396. {
  397.     /*----------------------------------------------------------------*/
  398.     /* Local Variables                                                */
  399.     /*----------------------------------------------------------------*/
  400.     MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT *myMsgPtr;
  401.     MYQUEUE Message;
  402.     /*----------------------------------------------------------------*/
  403.     /* Code Body                                                      */
  404.     /*----------------------------------------------------------------*/
  405.     if (!g_phb_is_get_entry_rsp)
  406.     {
  407.         return;
  408.     }
  409.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_owner_number_get_entry_req.>n", __FILE__,
  410.                          __LINE__));
  411.     myMsgPtr =
  412.         (MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT*) OslConstructDataPtr(sizeof(MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT));
  413.     myMsgPtr->index = 1;
  414.     myMsgPtr->record_index = 0xFFFF;
  415.     myMsgPtr->storage = MMI_SIM;
  416.     myMsgPtr->type = MMI_PHB_MSISDN;
  417.     myMsgPtr->no_data = MAX_ENTRIES_IN_LIST;
  418.     Message.oslSrcId = MOD_MMI;
  419.     Message.oslDestId = MOD_L4C;
  420.     Message.oslMsgId = PRT_PHB_GET_ENTRY_BY_INDEX_REQ;
  421.     Message.oslDataPtr = (oslParaType*) myMsgPtr;
  422.     Message.oslPeerBuffPtr = NULL;
  423.     SetProtocolEventHandler(mmi_phb_owner_number_get_entry_rsp, PRT_PHB_GET_ENTRY_BY_INDEX_RSP);
  424.     OslMsgSendExtQueue(&Message);
  425.     g_phb_is_get_entry_rsp = 0;
  426. }
  427. /*****************************************************************************
  428.  * FUNCTION
  429.  *  mmi_phb_owner_number_get_entry_rsp
  430.  * DESCRIPTION
  431.  *  Reads the owner numbers back from PS
  432.  * PARAMETERS
  433.  *  info        [IN]        Return response from L4
  434.  * RETURNS
  435.  *  void
  436.  *****************************************************************************/
  437. void mmi_phb_owner_number_get_entry_rsp(void *info)
  438. {
  439.     /*----------------------------------------------------------------*/
  440.     /* Local Variables                                                */
  441.     /*----------------------------------------------------------------*/
  442.     MSG_PHB_GET_ENTRY_BY_INDEX_RSP_STRUCT *localPtr;
  443.     U16 i;
  444.     /*----------------------------------------------------------------*/
  445.     /* Code Body                                                      */
  446.     /*----------------------------------------------------------------*/
  447.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_owner_number_get_entry_rsp.>n", __FILE__,
  448.                          __LINE__));
  449.     g_phb_is_get_entry_rsp = 1; /* Get Response From L4 */
  450.     localPtr = (MSG_PHB_GET_ENTRY_BY_INDEX_RSP_STRUCT*) info;
  451.     if (localPtr->result.flag == 0 /* OK */ )
  452.     {
  453.         g_phb_sim_list_count = (localPtr->no_list < MAX_SIM_ENTRIES) ? localPtr->no_list : MAX_SIM_ENTRIES;
  454.         for (i = 0; i < g_phb_sim_list_count && i < MAX_PB_OWNER_NUMBERS; i++)
  455.         {
  456.             g_phb_sim_list[i].storage = localPtr->list[i].storage;
  457.             g_phb_sim_list[i].index = localPtr->list[i].index;
  458.             g_phb_sim_list[i].record_index = localPtr->list[i].record_index;
  459.             g_phb_sim_list[i].tel.type = localPtr->list[i].tel.type;
  460.             g_phb_sim_list[i].tel.length = localPtr->list[i].tel.length;
  461.             g_phb_sim_list[i].alpha_id.name_length = localPtr->list[i].alpha_id.name_length;
  462.             g_phb_sim_list[i].alpha_id.name_dcs = localPtr->list[i].alpha_id.name_dcs;
  463.             InputboxConvertGSMToDeviceEncoding(
  464.                 localPtr->list[i].alpha_id.name,
  465.                 g_phb_sim_list[i].alpha_id.name,
  466.                 localPtr->list[i].alpha_id.name_length,
  467.                 (g_phb_cntx.owner_name_len + 1) * ENCODING_LENGTH,
  468.                 localPtr->list[i].alpha_id.name_dcs,
  469.                 0,
  470.                 1);
  471.             if ((g_phb_sim_list[i].tel.length > 0) && ((g_phb_sim_list[i].tel.type & 0x10) != 0))
  472.             {
  473.                 g_phb_sim_list[i].tel.number[0] = '+';
  474.                 AnsiiToUnicodeString(
  475.                     (PS8) (g_phb_sim_list[i].tel.number + ENCODING_LENGTH),
  476.                     (PS8) localPtr->list[i].tel.number);
  477.             }
  478.             else
  479.             {
  480.                 AnsiiToUnicodeString((PS8) g_phb_sim_list[i].tel.number, (PS8) localPtr->list[i].tel.number);
  481.             }
  482.         }
  483.     }
  484.     else    /* TBD - what to do if result flag is false */
  485.     {
  486.         g_phb_sim_list_count = 0;
  487.     }
  488.     /* Owner number associate with Line ID */
  489.     memset((void*)&gDispOwnerNumber, 0, sizeof(gDispOwnerNumber));
  490.     for (i = 0; ((i < MAX_LINE_NUM) && (i < g_phb_sim_list_count)); ++i)
  491.     {
  492.         if (pfnUnicodeStrlen((PS8) g_phb_sim_list[i].alpha_id.name))
  493.         {
  494.             pfnUnicodeStrncpy(
  495.                 (PS8) gDispOwnerNumber[i].name,
  496.                 (PS8) g_phb_sim_list[i].alpha_id.name,
  497.                 MAX_PB_NAME_LENGTH + 1);
  498.         }
  499.         if (pfnUnicodeStrlen((PS8) g_phb_sim_list[i].tel.number))
  500.         {
  501.             pfnUnicodeStrncpy(
  502.                 (PS8) gDispOwnerNumber[i].number,
  503.                 (PS8) g_phb_sim_list[i].tel.number,
  504.                 MAX_PB_NUMBER_LENGTH + 1);
  505.         }
  506.     }
  507.     RefreshDisplayOwnerNumber((U8) g_callset_context.LineID);
  508.     if (g_phb_operate_owner)
  509.     {
  510.         g_phb_operate_owner = FALSE;
  511.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, TRUE, PHB_NOTIFY_TIMEOUT, SUCCESS_TONE);
  512.         DeleteScreenIfPresent(SCR_OWNER_NUMBER_EDIT);
  513.         DeleteScreenIfPresent(SCR_OWNER_NUMBER_OPTIONS);
  514.     }
  515.     else if (g_phb_sim_list_count)
  516.     {
  517.         /* Display result screen only when processing screen is not interrupted. */
  518.         if (GetActiveScreenId() != SCR_IN_PROGRESS_PHB)
  519.         {
  520.             return;
  521.         }
  522. #if defined(__MMI_PHB_ALS_SUPPORT__)
  523.         if ((g_callset_context.LineID == LINE2) && (g_phb_sim_list_count == 1))
  524.         {
  525.             DisplayPopup(
  526.                 (PU8) GetString(STR_NO_OWNER_NUMBER_MESSAGE),
  527.                 IMG_GLOBAL_EMPTY,
  528.                 TRUE,
  529.                 PHB_NOTIFY_TIMEOUT,
  530.                 ERROR_TONE);
  531.         }
  532.         else
  533. #endif /* defined(__MMI_PHB_ALS_SUPPORT__) */
  534.         {
  535.             mmi_phb_entry_owner_number();
  536.         }
  537.     }
  538.     else
  539.     {
  540.         DisplayPopup(
  541.             (PU8) GetString(STR_NO_OWNER_NUMBER_MESSAGE),
  542.             IMG_GLOBAL_EMPTY,
  543.             TRUE,
  544.             PHB_NOTIFY_TIMEOUT,
  545.             ERROR_TONE);
  546.     }
  547. }
  548. /*****************************************************************************
  549.  * FUNCTION
  550.  *  mmi_phb_entry_owner_number
  551.  * DESCRIPTION
  552.  *  Displays the owner numbers list
  553.  * PARAMETERS
  554.  *  void
  555.  * RETURNS
  556.  *  void
  557.  *****************************************************************************/
  558. void mmi_phb_entry_owner_number(void)
  559. {
  560.     /*----------------------------------------------------------------*/
  561.     /* Local Variables                                                */
  562.     /*----------------------------------------------------------------*/
  563.     U8 *names[MAX_PB_OWNER_NUMBERS];
  564.     U16 i;
  565.     U8 *guiBuffer;
  566.     /*----------------------------------------------------------------*/
  567.     /* Code Body                                                      */
  568.     /*----------------------------------------------------------------*/
  569.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_entry_owner_number.>n", __FILE__,
  570.                          __LINE__));
  571.     EntryNewScreen(SCR_OWNER_NUMBERS, mmi_phb_exit_owner_number, mmi_phb_entry_owner_number, NULL);
  572.     guiBuffer = GetCurrGuiBuffer(SCR_OWNER_NUMBERS);
  573. #if defined(__MMI_PHB_ALS_SUPPORT__)
  574.     i = (U16) g_callset_context.LineID;
  575.     if (pfnUnicodeStrlen((PS8) g_phb_sim_list[i].alpha_id.name))
  576.     {
  577.         names[0] = g_phb_sim_list[i].alpha_id.name;
  578.         if (pfnUnicodeStrlen((PS8) g_phb_sim_list[i].tel.number))
  579.         {
  580.             subMenuDataPtrs[0] = g_phb_sim_list[i].tel.number;
  581.         }
  582.         else
  583.         {
  584.             subMenuDataPtrs[0] = (PU8) GetString(STR_GLOBAL_EMPTY_LIST);
  585.         }
  586.     }
  587.     else
  588.     {
  589.         if (pfnUnicodeStrlen((PS8) g_phb_sim_list[i].tel.number))
  590.         {
  591.             names[0] = g_phb_sim_list[i].tel.number;
  592.             subMenuDataPtrs[0] = NULL;         
  593.         }
  594.         else
  595.         {
  596.             names[0] = (PU8) GetString(STR_GLOBAL_EMPTY_LIST);
  597.             subMenuDataPtrs[0] = NULL;
  598.         }     
  599.     }
  600.     g_phb_cntx.active_index = (U16) g_callset_context.LineID;
  601.     g_phb_sim_list_count = 1;
  602. #else /* defined(__MMI_PHB_ALS_SUPPORT__) */
  603. #if defined(__MMI_PHB_DISPLAY_ONE_MSISDN__)
  604.     g_phb_sim_list_count = 1;
  605. #endif 
  606.     for (i = 0; i < g_phb_sim_list_count; i++)
  607.     {
  608.         if (pfnUnicodeStrlen((PS8) g_phb_sim_list[i].alpha_id.name))
  609.         {
  610.             names[i] = g_phb_sim_list[i].alpha_id.name;
  611.             if (pfnUnicodeStrlen((PS8) g_phb_sim_list[i].tel.number))
  612.             {
  613.                 subMenuDataPtrs[i] = g_phb_sim_list[i].tel.number;
  614.             }
  615.             else
  616.             {
  617.                 subMenuDataPtrs[i] = (PU8) GetString(STR_GLOBAL_EMPTY_LIST);
  618.             }
  619.         }
  620.         else
  621.         {
  622.             if (pfnUnicodeStrlen((PS8) g_phb_sim_list[i].tel.number))
  623.             {
  624.                 names[i] = g_phb_sim_list[i].tel.number;
  625.                 subMenuDataPtrs[i] = NULL;
  626.             }
  627.             else
  628.             {
  629.                 names[i] = (PU8) GetString(STR_GLOBAL_EMPTY_LIST);
  630.                 subMenuDataPtrs[i] = NULL;
  631.             }
  632.         }
  633.     }
  634.     RegisterHighlightHandler(mmi_phb_get_index);
  635. #endif /* defined(__MMI_PHB_ALS_SUPPORT__) */
  636.     ShowCategory53Screen(
  637.         STR_MITEM105,
  638.         IMG_SCR_PBOOK_CAPTION,
  639.         STR_GLOBAL_OPTIONS,
  640.         IMG_GLOBAL_OPTIONS,
  641.         STR_GLOBAL_BACK,
  642.         IMG_GLOBAL_BACK,
  643.         g_phb_sim_list_count,
  644.         names,
  645.         (U16*) gIndexIconsImageList,
  646.         subMenuDataPtrs,
  647.         0,
  648.         0,
  649.         guiBuffer);
  650.     SetLeftSoftkeyFunction(mmi_phb_entry_onwer_number_option, KEY_EVENT_UP);
  651.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  652.     SetKeyHandler(mmi_phb_entry_onwer_number_option, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  653.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  654. }
  655. /*****************************************************************************
  656.  * FUNCTION
  657.  *  mmi_phb_exit_owner_number
  658.  * DESCRIPTION
  659.  *  Exit function of mmi_phb_entry_owner_number()
  660.  * PARAMETERS
  661.  *  void
  662.  * RETURNS
  663.  *  void
  664.  *****************************************************************************/
  665. void mmi_phb_exit_owner_number(void)
  666. {
  667.     /*----------------------------------------------------------------*/
  668.     /* Local Variables                                                */
  669.     /*----------------------------------------------------------------*/
  670.     /*----------------------------------------------------------------*/
  671.     /* Code Body                                                      */
  672.     /*----------------------------------------------------------------*/
  673.     if (g_phb_cntx.start_scr_id == 0)
  674.     {
  675.         g_phb_cntx.start_scr_id = GetCurrScrnId();
  676.     }
  677.     g_phb_cntx.end_scr_id = SCR_OWNER_NUMBERS;
  678. }
  679. /*****************************************************************************
  680.  * FUNCTION
  681.  *  mmi_phb_entry_onwer_number_option
  682.  * DESCRIPTION
  683.  *  Draws the menu for Owner number options
  684.  * PARAMETERS
  685.  *  void
  686.  * RETURNS
  687.  *  void
  688.  *****************************************************************************/
  689. void mmi_phb_entry_onwer_number_option(void)
  690. {
  691.     /*----------------------------------------------------------------*/
  692.     /* Local Variables                                                */
  693.     /*----------------------------------------------------------------*/
  694.     U8 *guiBuffer;
  695.     U16 nStrItemList[2];
  696.     U16 nNumofItem;
  697.     /*----------------------------------------------------------------*/
  698.     /* Code Body                                                      */
  699.     /*----------------------------------------------------------------*/
  700.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_entry_onwer_number_option.>n", __FILE__,
  701.                          __LINE__));
  702.     EntryNewScreen(SCR_OWNER_NUMBER_OPTIONS, mmi_phb_exit_onwer_number_option, mmi_phb_entry_onwer_number_option, NULL);
  703.     guiBuffer = GetCurrGuiBuffer(SCR_OWNER_NUMBER_OPTIONS); /* Getting the Index from history  */
  704.     nNumofItem = GetNumOfChild(MITEM105_OWNER_NUMBER_OPTIONS);
  705.     GetSequenceStringIds(MITEM105_OWNER_NUMBER_OPTIONS, nStrItemList);
  706.     SetParentHandler(MITEM105_OWNER_NUMBER_OPTIONS);
  707.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  708.     ShowCategory15Screen(
  709.         STR_MITEM105,
  710.         IMG_SCR_PBOOK_CAPTION,
  711.         STR_GLOBAL_OK,
  712.         IMG_GLOBAL_OK,
  713.         STR_GLOBAL_BACK,
  714.         IMG_GLOBAL_BACK,
  715.         nNumofItem,
  716.         nStrItemList,
  717.         (U16*) gIndexIconsImageList,
  718.         LIST_MENU,
  719.         0,
  720.         guiBuffer);
  721. }
  722. /*****************************************************************************
  723.  * FUNCTION
  724.  *  mmi_phb_exit_onwer_number_option
  725.  * DESCRIPTION
  726.  *  Exit function of mmi_phb_entry_onwer_number_option()
  727.  * PARAMETERS
  728.  *  void
  729.  * RETURNS
  730.  *  void
  731.  *****************************************************************************/
  732. void mmi_phb_exit_onwer_number_option(void)
  733. {
  734.     /*----------------------------------------------------------------*/
  735.     /* Local Variables                                                */
  736.     /*----------------------------------------------------------------*/
  737.     /*----------------------------------------------------------------*/
  738.     /* Code Body                                                      */
  739.     /*----------------------------------------------------------------*/
  740.     g_phb_cntx.end_scr_id = SCR_OWNER_NUMBER_OPTIONS;
  741. }
  742. /*****************************************************************************
  743.  * FUNCTION
  744.  *  mmi_phb_owner_number_pre_erase
  745.  * DESCRIPTION
  746.  *  Confirms before erasing the owner number
  747.  * PARAMETERS
  748.  *  void
  749.  * RETURNS
  750.  *  void
  751.  *****************************************************************************/
  752. void mmi_phb_owner_number_pre_erase(void)
  753. {
  754.     /*----------------------------------------------------------------*/
  755.     /* Local Variables                                                */
  756.     /*----------------------------------------------------------------*/
  757.     /*----------------------------------------------------------------*/
  758.     /* Code Body                                                      */
  759.     /*----------------------------------------------------------------*/
  760.     if (pfnUnicodeStrlen((S8*) g_phb_sim_list[g_phb_cntx.active_index].alpha_id.name) ||
  761.         pfnUnicodeStrlen((S8*) g_phb_sim_list[g_phb_cntx.active_index].tel.number))
  762.     {
  763.         mmi_phb_entry_owner_number_erase_confirm();
  764.     }
  765.     else
  766.     {
  767.         DisplayPopup(
  768.             (PU8) GetString(STR_GLOBAL_EMPTY_LIST),
  769.             IMG_GLOBAL_EMPTY,
  770.             TRUE,
  771.             PHB_NOTIFY_TIMEOUT,
  772.             EMPTY_LIST_TONE);
  773.     }
  774. }
  775. /*****************************************************************************
  776.  * FUNCTION
  777.  *  mmi_phb_entry_owner_number_erase_confirm
  778.  * DESCRIPTION
  779.  *  Confirms before erasing the owner number
  780.  * PARAMETERS
  781.  *  void
  782.  * RETURNS
  783.  *  void
  784.  *****************************************************************************/
  785. void mmi_phb_entry_owner_number_erase_confirm(void)
  786. {
  787.     /*----------------------------------------------------------------*/
  788.     /* Local Variables                                                */
  789.     /*----------------------------------------------------------------*/
  790.     /*----------------------------------------------------------------*/
  791.     /* Code Body                                                      */
  792.     /*----------------------------------------------------------------*/
  793.     DisplayConfirm(
  794.         STR_GLOBAL_YES,
  795.         IMG_GLOBAL_YES,
  796.         STR_GLOBAL_NO,
  797.         IMG_GLOBAL_NO,
  798.         get_string(STR_ERASE_QUERY),
  799.         IMG_GLOBAL_QUESTION,
  800.         WARNING_TONE);
  801.     SetLeftSoftkeyFunction(mmi_phb_owner_number_erase_req, KEY_EVENT_UP);
  802.     SetRightSoftkeyFunction(mmi_phb_go_back_2_history, KEY_EVENT_UP);
  803. }
  804. /*****************************************************************************
  805.  * FUNCTION
  806.  *  mmi_phb_owner_number_erase_req
  807.  * DESCRIPTION
  808.  *  Sends the L4 request to erase the owner number
  809.  * PARAMETERS
  810.  *  void
  811.  * RETURNS
  812.  *  void
  813.  *****************************************************************************/
  814. void mmi_phb_owner_number_erase_req(void)
  815. {
  816.     /*----------------------------------------------------------------*/
  817.     /* Local Variables                                                */
  818.     /*----------------------------------------------------------------*/
  819.     /*
  820.      * MSG_PHB_SET_ENRTY_REQ_STRUCT *myMsgPtr;
  821.      * MYQUEUE Message;
  822.      * 
  823.      * g_phb_operate_owner = TRUE;
  824.      * 
  825.      * PRINT_INFORMATION_2((MMI_TRACE_G4_PHB,"File: [%s]  Line: [%d] <<mmi_phb_owner_number_erase_req.>n",__FILE__,__LINE__));
  826.      * mmi_phb_show_in_progress(STR_PHB_ERASING, IMG_GLOBAL_ERASED);
  827.      * 
  828.      * myMsgPtr = (MSG_PHB_SET_ENRTY_REQ_STRUCT*) OslConstructDataPtr(sizeof(MSG_PHB_SET_ENRTY_REQ_STRUCT));
  829.      * myMsgPtr->type = MMI_PHB_MSISDN;
  830.      * myMsgPtr->no_data = 0;
  831.      * myMsgPtr->list.storage = MMI_SIM;
  832.      * myMsgPtr->list.index = g_phb_sim_list[g_phb_cntx.active_index].index;
  833.      * myMsgPtr->list.record_index = 0xFFFF;
  834.      * memset(myMsgPtr->list.alpha_id.name, 0, ENCODING_LENGTH);
  835.      * myMsgPtr->list.alpha_id.name_length = 0;
  836.      * myMsgPtr->list.alpha_id.name_dcs = MMI_PHB_ASCII;
  837.      * 
  838.      * myMsgPtr->list.tel.type = MMI_CSMCC_DEFAULT_ADDR_TYPE; //DEFAULT
  839.      * myMsgPtr->list.tel.length = 0;
  840.      * memset(myMsgPtr->list.tel.number, 0, ENCODING_LENGTH);
  841.      * 
  842.      * Message.oslSrcId     = MOD_MMI;
  843.      * Message.oslDestId    = MOD_L4C;
  844.      * Message.oslMsgId     = PRT_PHB_SET_ENTRY_REQ;
  845.      * Message.oslDataPtr      = (oslParaType *)myMsgPtr;
  846.      * Message.oslPeerBuffPtr  = NULL;
  847.      * 
  848.      * SetProtocolEventHandler(mmi_phb_owner_number_erase_rsp   ,PRT_PHB_SET_ENTRY_RSP);
  849.      * OslMsgSendExtQueue(&Message);
  850.      * DeleteNScrId(SCR_OWNER_NUMBER_OPTIONS);
  851.      */
  852.     MSG_PHB_DELETE_ENTRY_REQ_STRUCT *myMsgPtr;
  853.     MYQUEUE Message;
  854.     /*----------------------------------------------------------------*/
  855.     /* Code Body                                                      */
  856.     /*----------------------------------------------------------------*/
  857.     /* If not enter from edit request, that is enter from erase request, so enter processing screen. */
  858.     if (!g_phb_edit_owner)
  859.     {
  860.         g_phb_operate_owner = TRUE;
  861.         PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_owner_number_erase_req.>n", __FILE__,
  862.                              __LINE__));
  863.         mmi_phb_show_in_progress(STR_PHB_ERASING, IMG_GLOBAL_ERASED);
  864.     }
  865.     myMsgPtr = (MSG_PHB_DELETE_ENTRY_REQ_STRUCT*) OslConstructDataPtr(sizeof(MSG_PHB_DELETE_ENTRY_REQ_STRUCT));
  866.     myMsgPtr->storage = MMI_SIM;
  867.     myMsgPtr->del_all = MMI_FALSE;
  868.     myMsgPtr->no_data = 1;
  869.     myMsgPtr->type = MMI_PHB_MSISDN;
  870.     myMsgPtr->index = g_phb_sim_list[g_phb_cntx.active_index].index;
  871.     Message.oslSrcId = MOD_MMI;
  872.     Message.oslDestId = MOD_L4C;
  873.     Message.oslMsgId = PRT_PHB_DEL_ENTRY_REQ;
  874.     Message.oslDataPtr = (oslParaType*) myMsgPtr;
  875.     Message.oslPeerBuffPtr = NULL;
  876.     SetProtocolEventHandler(mmi_phb_owner_number_erase_rsp, PRT_PHB_DEL_ENTRY_RSP);
  877.     OslMsgSendExtQueue(&Message);
  878.     /* If not enter from edit request, that is enter from erase request, so erase screen. */
  879.     //if(!g_phb_edit_owner)
  880.     //   DeleteNScrId(SCR_PBOOK_ENTRY_OPTIONS);
  881. }
  882. /*****************************************************************************
  883.  * FUNCTION
  884.  *  mmi_phb_owner_number_erase_rsp
  885.  * DESCRIPTION
  886.  *  Response handler for Owner number erase request
  887.  * PARAMETERS
  888.  *  info        [IN]        Return result from L4
  889.  * RETURNS
  890.  *  void
  891.  *****************************************************************************/
  892. void mmi_phb_owner_number_erase_rsp(void *info)
  893. {
  894.     /*----------------------------------------------------------------*/
  895.     /* Local Variables                                                */
  896.     /*----------------------------------------------------------------*/
  897.     //MSG_PHB_SET_ENRTY_RSP_STRUCT* localPtr;
  898.     //localPtr = (MSG_PHB_SET_ENRTY_RSP_STRUCT *)info;
  899.     MSG_PHB_DELETE_ENTRY_RSP_STRUCT *localPtr;
  900.     /*----------------------------------------------------------------*/
  901.     /* Code Body                                                      */
  902.     /*----------------------------------------------------------------*/
  903.     localPtr = (MSG_PHB_DELETE_ENTRY_RSP_STRUCT*) info;
  904.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_owner_number_erase_rsp.>n", __FILE__,
  905.                          __LINE__));
  906.     /* If this is erase response before save request,  continue to set entry. */
  907.     if (g_phb_edit_owner)
  908.     {
  909.         mmi_phb_owner_number_edit_req();
  910.         return;
  911.     }
  912.     if (localPtr->result.flag == 0 /* OK */ )
  913.     {
  914.         mmi_phb_owner_number_get_entry_req();
  915.     }
  916.     else
  917.     {
  918.         g_phb_operate_owner = FALSE;
  919.         DisplayPopup(
  920.             (PU8) GetString(STR_GLOBAL_UNFINISHED),
  921.             IMG_GLOBAL_UNFINISHED,
  922.             TRUE,
  923.             PHB_NOTIFY_TIMEOUT,
  924.             ERROR_TONE);
  925.         DeleteScreenIfPresent(SCR_OWNER_NUMBER_OPTIONS);
  926.     }
  927. }
  928. /*****************************************************************************
  929.  * FUNCTION
  930.  *  mmi_phb_owner_number_pre_edit
  931.  * DESCRIPTION
  932.  *  Sets the buffers before editing the owner number
  933.  * PARAMETERS
  934.  *  void
  935.  * RETURNS
  936.  *  void
  937.  *****************************************************************************/
  938. void mmi_phb_owner_number_pre_edit(void)
  939. {
  940.     /*----------------------------------------------------------------*/
  941.     /* Local Variables                                                */
  942.     /*----------------------------------------------------------------*/
  943.     /*----------------------------------------------------------------*/
  944.     /* Code Body                                                      */
  945.     /*----------------------------------------------------------------*/
  946.     memset(pbName, 0, ENCODING_LENGTH);
  947.     pfnUnicodeStrcpy((PS8) pbName, (PS8) g_phb_sim_list[g_phb_cntx.active_index].alpha_id.name);
  948.     memset(pbNumber, 0, ENCODING_LENGTH);
  949.     pfnUnicodeStrcpy((PS8) pbNumber, (PS8) g_phb_sim_list[g_phb_cntx.active_index].tel.number);
  950.     mmi_phb_entry_owner_number_edit();
  951. }
  952. /*****************************************************************************
  953.  * FUNCTION
  954.  *  mmi_phb_entry_owner_number_edit
  955.  * DESCRIPTION
  956.  *  Inline edit screen to edit Owner number
  957.  * PARAMETERS
  958.  *  void
  959.  * RETURNS
  960.  *  void
  961.  *****************************************************************************/
  962. void mmi_phb_entry_owner_number_edit(void)
  963. {
  964.     /*----------------------------------------------------------------*/
  965.     /* Local Variables                                                */
  966.     /*----------------------------------------------------------------*/
  967.     U8 *guiBuffer;
  968.     U8 *inputBuffer;
  969.     U16 inputBufferSize;
  970.     U16 DetailPbNameImageList[2];
  971.     /*----------------------------------------------------------------*/
  972.     /* Code Body                                                      */
  973.     /*----------------------------------------------------------------*/
  974.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<OwnerNumberEdit.>n", __FILE__, __LINE__));
  975.     EntryNewScreen(SCR_OWNER_NUMBER_EDIT, mmi_phb_exit_owner_number_edit, NULL, NULL);
  976.     InitializeCategory57Screen();
  977.     guiBuffer = GetCurrGuiBuffer(SCR_OWNER_NUMBER_EDIT);
  978.     inputBuffer = GetCurrNInputBuffer(SCR_OWNER_NUMBER_EDIT, &inputBufferSize);
  979.     SetInlineItemActivation(&wgui_inline_items[0], KEY_LSK, KEY_EVENT_UP);
  980.     SetInlineItemFullScreenEdit(
  981.         &wgui_inline_items[0],
  982.         STR_OWNER_NAME_CAPTION,
  983.         IMG_SCR_PBOOK_CAPTION,
  984.         (PU8) pbName,
  985.         g_phb_cntx.owner_name_len + 1,
  986.         INPUT_TYPE_ALPHANUMERIC_UPPERCASE | INPUT_TYPE_USE_ENCODING_BASED_LENGTH | INPUT_TYPE_ONE_LESS_CHARACTER | INPUT_TYPE_GSM_EXTENDED_HANDLING);
  987.     SetInlineFullScreenEditCustomFunction(&wgui_inline_items[0], mmi_phb_set_full_scr_lsk);
  988.     DetailPbNameImageList[0] = IMG_NAME;
  989.     SetInlineItemActivation(&wgui_inline_items[1], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  990.     SetInlineItemTextEdit(
  991.         &wgui_inline_items[1],
  992.         (PU8) pbNumber,
  993.         MAX_PB_NUMBER_LENGTH + 1,
  994.         INPUT_TYPE_PHONE_NUMBER | INPUT_TYPE_PLUS_CHARACTER_HANDLING);
  995.     DisableInlineItemHighlight(&wgui_inline_items[1]);
  996.     DetailPbNameImageList[1] = IMG_MOBILE_NUMBER;
  997.     if (inputBuffer != NULL)
  998.     {
  999.         SetCategory57Data(wgui_inline_items, 2, inputBuffer);
  1000.     }
  1001.     ShowCategory57Screen(
  1002.         STR_GLOBAL_EDIT,
  1003.         IMG_SCR_PBOOK_CAPTION,
  1004.         STR_GLOBAL_EDIT,
  1005.         IMG_EDIT_LSK,
  1006.         STR_GLOBAL_DONE,
  1007.         IMG_DONE_RSK,
  1008.         2,
  1009.         DetailPbNameImageList,
  1010.         wgui_inline_items,
  1011.         0,
  1012.         guiBuffer);
  1013.     SetCategory57RightSoftkeyFunctions(mmi_phb_entry_owner_number_edit_confirm, GoBackHistory);
  1014. }
  1015. /*****************************************************************************
  1016.  * FUNCTION
  1017.  *  mmi_phb_exit_owner_number_edit
  1018.  * DESCRIPTION
  1019.  *  Exit function of mmi_phb_entry_owner_number_edit()
  1020.  * PARAMETERS
  1021.  *  void
  1022.  * RETURNS
  1023.  *  void
  1024.  *****************************************************************************/
  1025. void mmi_phb_exit_owner_number_edit(void)
  1026. {
  1027.     /*----------------------------------------------------------------*/
  1028.     /* Local Variables                                                */
  1029.     /*----------------------------------------------------------------*/
  1030.     history h;
  1031.     U16 inputBufferSize;
  1032.     /*----------------------------------------------------------------*/
  1033.     /* Code Body                                                      */
  1034.     /*----------------------------------------------------------------*/
  1035.     g_phb_cntx.end_scr_id = SCR_OWNER_NUMBER_EDIT;
  1036.     CloseCategory57Screen();
  1037.     h.scrnID = SCR_OWNER_NUMBER_EDIT;
  1038.     h.entryFuncPtr = mmi_phb_entry_owner_number_edit;
  1039.     GetCategoryHistory(h.guiBuffer);
  1040.     inputBufferSize = (U16) GetCategory57DataSize();
  1041.     GetCategory57Data((U8*) h.inputBuffer);
  1042.     AddNHistory(h, inputBufferSize);
  1043. }
  1044. /*****************************************************************************
  1045.  * FUNCTION
  1046.  *  mmi_phb_entry_owner_number_edit_confirm
  1047.  * DESCRIPTION
  1048.  *  Confirms before saving the owner number
  1049.  * PARAMETERS
  1050.  *  void
  1051.  * RETURNS
  1052.  *  void
  1053.  *****************************************************************************/
  1054. void mmi_phb_entry_owner_number_edit_confirm(void)
  1055. {
  1056.     /*----------------------------------------------------------------*/
  1057.     /* Local Variables                                                */
  1058.     /*----------------------------------------------------------------*/
  1059.     /*----------------------------------------------------------------*/
  1060.     /* Code Body                                                      */
  1061.     /*----------------------------------------------------------------*/
  1062.     DisplayConfirm(
  1063.         STR_GLOBAL_YES,
  1064.         IMG_GLOBAL_YES,
  1065.         STR_GLOBAL_NO,
  1066.         IMG_GLOBAL_NO,
  1067.         get_string(STR_GLOBAL_SAVE),
  1068.         IMG_GLOBAL_QUESTION,
  1069.         WARNING_TONE);
  1070.     SetLeftSoftkeyFunction(mmi_phb_owner_number_edit_req, KEY_EVENT_UP);
  1071.     SetRightSoftkeyFunction(mmi_phb_go_back_3_history_and_clear, KEY_EVENT_UP);
  1072. }
  1073. /*****************************************************************************
  1074.  * FUNCTION
  1075.  *  mmi_phb_owner_number_edit_req
  1076.  * DESCRIPTION
  1077.  *  Send the L4 request to save the owner number
  1078.  * PARAMETERS
  1079.  *  void
  1080.  * RETURNS
  1081.  *  void
  1082.  *****************************************************************************/
  1083. void mmi_phb_owner_number_edit_req(void)
  1084. {
  1085.     /*----------------------------------------------------------------*/
  1086.     /* Local Variables                                                */
  1087.     /*----------------------------------------------------------------*/
  1088.     MSG_PHB_SET_ENRTY_REQ_STRUCT *myMsgPtr;
  1089.     MYQUEUE Message;
  1090. #if defined(__PHB_0x81_SUPPORT__)
  1091.     U8 length;
  1092. #endif 
  1093.     /*----------------------------------------------------------------*/
  1094.     /* Code Body                                                      */
  1095.     /*----------------------------------------------------------------*/
  1096.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_owner_number_edit_req.>n", __FILE__,
  1097.                          __LINE__));
  1098.     g_phb_operate_owner = TRUE;
  1099.     if (g_phb_sim_list[g_phb_cntx.active_index].tel.length >= 20)       /* need erase first to release ext1 */
  1100.     {
  1101.         /* Erase record before save */
  1102.         if (!g_phb_edit_owner)
  1103.         {
  1104.             g_phb_edit_owner = TRUE;
  1105.             mmi_phb_show_in_progress(STR_GLOBAL_SAVING, IMG_GLOBAL_SAVE);
  1106.             mmi_phb_owner_number_erase_req();
  1107.             return;
  1108.         }
  1109.         else
  1110.         {
  1111.             g_phb_edit_owner = FALSE;
  1112.         }
  1113.     }
  1114.     else
  1115.     {
  1116.         mmi_phb_show_in_progress(STR_GLOBAL_SAVING, IMG_GLOBAL_SAVE);
  1117.     }
  1118.     myMsgPtr = (MSG_PHB_SET_ENRTY_REQ_STRUCT*) OslConstructDataPtr(sizeof(MSG_PHB_SET_ENRTY_REQ_STRUCT));
  1119.     myMsgPtr->type = MMI_PHB_MSISDN;
  1120.     myMsgPtr->no_data = 0;
  1121.     myMsgPtr->list.storage = MMI_SIM;
  1122.     myMsgPtr->list.index = g_phb_sim_list[g_phb_cntx.active_index].index;
  1123.     myMsgPtr->list.record_index = 0xFFFF;
  1124.     if (GetUCS2Flag(pbName))
  1125.     {
  1126.         myMsgPtr->list.alpha_id.name_dcs = MMI_PHB_UCS2;
  1127.         myMsgPtr->list.alpha_id.name_length = ((U8) pfnUnicodeStrlen(pbName)) * ENCODING_LENGTH;
  1128.         InputboxConvertDeviceEncodingToGSM(
  1129.             (PU8) pbName,
  1130.             myMsgPtr->list.alpha_id.name,
  1131.             MAX_PS_NAME_LENGTH,
  1132.             MMI_PHB_UCS2,
  1133.             0,
  1134.             1);
  1135.     #if defined(__PHB_0x81_SUPPORT__)       /* Support maximum length of 0x81 UCS2 */
  1136.         if ((length = mmi_phb_convert_to_0x81((S8*) myMsgPtr->list.alpha_id.name, TRUE)) > 0)
  1137.         {
  1138.             myMsgPtr->list.alpha_id.name_dcs = 0x09;
  1139.             myMsgPtr->list.alpha_id.name_length = length;
  1140.         }
  1141.     #endif /* defined(__PHB_0x81_SUPPORT__) */ 
  1142.     }
  1143.     else
  1144.     {
  1145.         myMsgPtr->list.alpha_id.name_dcs = MMI_PHB_ASCII;
  1146.         myMsgPtr->list.alpha_id.name_length = InputboxConvertDeviceEncodingToGSM(
  1147.                                                 (PU8) pbName,
  1148.                                                 myMsgPtr->list.alpha_id.name,
  1149.                                                 MAX_PS_NAME_LENGTH,
  1150.                                                 MMI_PHB_ASCII,
  1151.                                                 0,
  1152.                                                 1) - 1;
  1153.     }
  1154.     if (pbNumber[0] == '+')
  1155.     {
  1156.         myMsgPtr->list.tel.type = MMI_CSMCC_INTERNATIONAL_ADDR; /* INTERNATIONAL */
  1157.         myMsgPtr->list.tel.length = (U8) pfnUnicodeStrlen(pbNumber + ENCODING_LENGTH);
  1158.         UnicodeToAnsii((PS8) myMsgPtr->list.tel.number, pbNumber + ENCODING_LENGTH);
  1159.     }
  1160.     else
  1161.     {
  1162.         myMsgPtr->list.tel.type = MMI_CSMCC_DEFAULT_ADDR_TYPE;  /* DEFAULT */
  1163.         myMsgPtr->list.tel.length = (U8) pfnUnicodeStrlen(pbNumber);
  1164.         UnicodeToAnsii((PS8) myMsgPtr->list.tel.number, pbNumber);
  1165.     }
  1166.     Message.oslSrcId = MOD_MMI;
  1167.     Message.oslDestId = MOD_L4C;
  1168.     Message.oslMsgId = PRT_PHB_SET_ENTRY_REQ;
  1169.     Message.oslDataPtr = (oslParaType*) myMsgPtr;
  1170.     Message.oslPeerBuffPtr = NULL;
  1171.     SetProtocolEventHandler(mmi_phb_owner_number_edit_rsp, PRT_PHB_SET_ENTRY_RSP);
  1172.     OslMsgSendExtQueue(&Message);
  1173.     /* DeleteNScrId(SCR_OWNER_NUMBER_OPTIONS); */
  1174. }
  1175. /*****************************************************************************
  1176.  * FUNCTION
  1177.  *  mmi_phb_owner_number_edit_rsp
  1178.  * DESCRIPTION
  1179.  *  Response hanlder for owner number edit request
  1180.  * PARAMETERS
  1181.  *  info        [IN]        Return response from L4
  1182.  * RETURNS
  1183.  *  void
  1184.  *****************************************************************************/
  1185. void mmi_phb_owner_number_edit_rsp(void *info)
  1186. {
  1187.     /*----------------------------------------------------------------*/
  1188.     /* Local Variables                                                */
  1189.     /*----------------------------------------------------------------*/
  1190.     MSG_PHB_SET_ENRTY_RSP_STRUCT *localPtr;
  1191.     /*----------------------------------------------------------------*/
  1192.     /* Code Body                                                      */
  1193.     /*----------------------------------------------------------------*/
  1194.     localPtr = (MSG_PHB_SET_ENRTY_RSP_STRUCT*) info;
  1195.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_owner_number_edit_rsp.>n", __FILE__,
  1196.                          __LINE__));
  1197.     if (localPtr->result.flag == 0 /* OK */ )
  1198.     {
  1199.         mmi_phb_owner_number_get_entry_req();
  1200.     }
  1201.     else
  1202.     {
  1203.         g_phb_operate_owner = FALSE;
  1204.         if (localPtr->result.cause == MMI_SIM_EF_RECORD_FULL)
  1205.         {
  1206.             DisplayPopup(
  1207.                 (PU8) GetString(STR_NOT_SAVED_NUMBER_TOO_LONG),
  1208.                 IMG_GLOBAL_ERROR,
  1209.                 FALSE,
  1210.                 PHB_NOTIFY_TIMEOUT,
  1211.                 ERROR_TONE);
  1212.         }
  1213.         else
  1214.         {
  1215.             DisplayPopup(
  1216.                 (PU8) GetString(STR_GLOBAL_UNFINISHED),
  1217.                 IMG_GLOBAL_UNFINISHED,
  1218.                 TRUE,
  1219.                 PHB_NOTIFY_TIMEOUT,
  1220.                 ERROR_TONE);
  1221.         }
  1222.         DeleteScreenIfPresent(SCR_OWNER_NUMBER_EDIT);
  1223.         DeleteScreenIfPresent(SCR_OWNER_NUMBER_OPTIONS);
  1224.     }
  1225. }
  1226. /* --------------------------------------  END of Phone Book Owner Number ------------------------------------------- */
  1227. /* --------------------------------------  Begin of Phone Book Service Dial Number ------------------------------------------- */
  1228. #define MMI_PHB_SDN_LIST
  1229. /*****************************************************************************
  1230.  * FUNCTION
  1231.  *  mmi_phb_highlight_sdn_list
  1232.  * DESCRIPTION
  1233.  *  Highlight handler for SDL in PHB main menu
  1234.  * PARAMETERS
  1235.  *  void
  1236.  * RETURNS
  1237.  *  void
  1238.  *****************************************************************************/
  1239. void mmi_phb_highlight_sdn_list(void)
  1240. {
  1241.     /*----------------------------------------------------------------*/
  1242.     /* Local Variables                                                */
  1243.     /*----------------------------------------------------------------*/
  1244.     /*----------------------------------------------------------------*/
  1245.     /* Code Body                                                      */
  1246.     /*----------------------------------------------------------------*/
  1247.     SetLeftSoftkeyFunction(mmi_phb_sdn_list_pre_entry, KEY_EVENT_UP);
  1248.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1249.     SetKeyHandler(mmi_phb_sdn_list_pre_entry, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1250.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1251. }
  1252. /*****************************************************************************
  1253.  * FUNCTION
  1254.  *  mmi_phb_sdn_list_pre_entry
  1255.  * DESCRIPTION
  1256.  *  Checks and calls the L4 request function to fetch SDL numbers
  1257.  * PARAMETERS
  1258.  *  void
  1259.  * RETURNS
  1260.  *  void
  1261.  *****************************************************************************/
  1262. void mmi_phb_sdn_list_pre_entry(void)
  1263. {
  1264.     /*----------------------------------------------------------------*/
  1265.     /* Local Variables                                                */
  1266.     /*----------------------------------------------------------------*/
  1267.     /*----------------------------------------------------------------*/
  1268.     /* Code Body                                                      */
  1269.     /*----------------------------------------------------------------*/
  1270.     if (g_phb_cntx.phb_ready)
  1271.     {
  1272.         mmi_phb_show_in_progress(STR_PROCESSING_PHONEBOOK, IMG_PROCESSING_PHONEBOOK);
  1273.         g_phb_sim_list_count = 0;
  1274.         g_phb_read_index = 1;
  1275.         mmi_phb_sdn_get_entry_req();
  1276.     }
  1277.     else
  1278.     {
  1279.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1280.     }
  1281. }
  1282. /*****************************************************************************
  1283.  * FUNCTION
  1284.  *  mmi_phb_sdn_get_entry_req
  1285.  * DESCRIPTION
  1286.  *  Sends the request to L4 to get the SDL numbers
  1287.  * PARAMETERS
  1288.  *  void
  1289.  * RETURNS
  1290.  *  void
  1291.  *****************************************************************************/
  1292. void mmi_phb_sdn_get_entry_req(void)
  1293. {
  1294.     /*----------------------------------------------------------------*/
  1295.     /* Local Variables                                                */
  1296.     /*----------------------------------------------------------------*/
  1297.     MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT *myMsgPtr;
  1298.     MYQUEUE Message;
  1299.     /*----------------------------------------------------------------*/
  1300.     /* Code Body                                                      */
  1301.     /*----------------------------------------------------------------*/
  1302.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<LoadAllFdlist.>n", __FILE__, __LINE__));
  1303.     myMsgPtr =
  1304.         (MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT*) OslIntConstructDataPtr(sizeof(MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT));
  1305.     myMsgPtr->index = g_phb_read_index; /* Begin from 1 */
  1306.     myMsgPtr->record_index = 0xFFFF;
  1307.     myMsgPtr->storage = MMI_SIM;
  1308.     myMsgPtr->type = MMI_PHB_SDN;
  1309.     myMsgPtr->no_data = MAX_ENTRIES_IN_LIST;
  1310.     Message.oslSrcId = MOD_MMI;
  1311.     Message.oslDestId = MOD_L4C;
  1312.     Message.oslMsgId = PRT_PHB_GET_ENTRY_BY_INDEX_REQ;
  1313.     Message.oslDataPtr = (oslParaType*) myMsgPtr;
  1314.     Message.oslPeerBuffPtr = NULL;
  1315.     SetProtocolEventHandler(mmi_phb_sdn_get_entry_rsp, PRT_PHB_GET_ENTRY_BY_INDEX_RSP);
  1316.     OslMsgSendExtQueue(&Message);
  1317. }
  1318. /*****************************************************************************
  1319.  * FUNCTION
  1320.  *  mmi_phb_sdn_get_entry_rsp
  1321.  * DESCRIPTION
  1322.  *  Reads the SDL numbers back from L4
  1323.  * PARAMETERS
  1324.  *  info        [IN]        Return result from L4
  1325.  * RETURNS
  1326.  *  void
  1327.  *****************************************************************************/
  1328. void mmi_phb_sdn_get_entry_rsp(void *info)
  1329. {
  1330.     /*----------------------------------------------------------------*/
  1331.     /* Local Variables                                                */
  1332.     /*----------------------------------------------------------------*/
  1333.     MSG_PHB_GET_ENTRY_BY_INDEX_RSP_STRUCT *localPtr;
  1334.     U16 i;
  1335.     /*----------------------------------------------------------------*/
  1336.     /* Code Body                                                      */
  1337.     /*----------------------------------------------------------------*/
  1338.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<GetAllFdlEntries.>n", __FILE__, __LINE__));
  1339.     localPtr = (MSG_PHB_GET_ENTRY_BY_INDEX_RSP_STRUCT*) info;
  1340.     if (localPtr->result.flag == 0 /* OK */ )
  1341.     {
  1342.         /* Begin to assign to list */
  1343.         for (i = 0; i < localPtr->no_list; i++)
  1344.         {
  1345.             /* No Space */
  1346.             if (g_phb_sim_list_count >= MAX_SIM_ENTRIES)
  1347.             {
  1348.                 continue;
  1349.             }
  1350.             /* Empty Entry */
  1351.             if ((localPtr->list[i].alpha_id.name_length == 0) && (localPtr->list[i].tel.length == 0))
  1352.             {
  1353.                 continue;
  1354.             }
  1355.             g_phb_sim_list[g_phb_sim_list_count].storage = localPtr->list[i].storage;
  1356.             g_phb_sim_list[g_phb_sim_list_count].index = localPtr->list[i].index;
  1357.             g_phb_sim_list[g_phb_sim_list_count].record_index = localPtr->list[i].record_index;
  1358.             g_phb_sim_list[g_phb_sim_list_count].tel.type = localPtr->list[i].tel.type;
  1359.             g_phb_sim_list[g_phb_sim_list_count].tel.length = localPtr->list[i].tel.length;
  1360.             g_phb_sim_list[g_phb_sim_list_count].alpha_id.name_length = localPtr->list[i].alpha_id.name_length;
  1361.             g_phb_sim_list[g_phb_sim_list_count].alpha_id.name_dcs = localPtr->list[i].alpha_id.name_dcs;
  1362.             if (g_phb_sim_list[g_phb_sim_list_count].alpha_id.name_dcs == MMI_PHB_UCS2)
  1363.             {
  1364.                 BigEndianToLittleEndian(
  1365.                     (PS8) g_phb_sim_list[g_phb_sim_list_count].alpha_id.name,
  1366.                     (PS8) localPtr->list[i].alpha_id.name);
  1367.             }
  1368.             else
  1369.             {
  1370.                 AnsiiToUnicodeString(
  1371.                     (PS8) g_phb_sim_list[g_phb_sim_list_count].alpha_id.name,
  1372.                     (PS8) localPtr->list[i].alpha_id.name);
  1373.             }
  1374.             if ((localPtr->list[i].tel.length > 0) && ((localPtr->list[i].tel.type & 0x10) != 0))
  1375.             {
  1376.                 g_phb_sim_list[g_phb_sim_list_count].tel.number[0] = '+';
  1377.                 AnsiiToUnicodeString(
  1378.                     (PS8) (g_phb_sim_list[g_phb_sim_list_count].tel.number + ENCODING_LENGTH),
  1379.                     (PS8) localPtr->list[i].tel.number);
  1380.             }
  1381.             else
  1382.             {
  1383.                 AnsiiToUnicodeString(
  1384.                     (PS8) g_phb_sim_list[g_phb_sim_list_count].tel.number,
  1385.                     (PS8) localPtr->list[i].tel.number);
  1386.             }
  1387.             g_phb_sim_list_count++;
  1388.         }
  1389.         /* Try to read more entry if exists. */
  1390.         if (localPtr->no_list == MAX_ENTRIES_IN_LIST)
  1391.         {
  1392.             g_phb_read_index += MAX_ENTRIES_IN_LIST;
  1393.             mmi_phb_sdn_get_entry_req();
  1394.             return;
  1395.         }
  1396.     }
  1397.     else
  1398.     {
  1399.         /* TBD - what to do if result flag is false */
  1400.     }
  1401.     if (g_phb_sim_list_count)
  1402.     {
  1403.         mmi_phb_entry_sdn_list();
  1404.     }
  1405.     else
  1406.     {
  1407.         DisplayPopup(
  1408.             (PU8) GetString(STR_SDL_NO_LIST_TEXT),
  1409.             IMG_GLOBAL_WARNING,
  1410.             FALSE,
  1411.             PHB_NOTIFY_TIMEOUT,
  1412.             WARNING_TONE);
  1413.     }
  1414. }
  1415. /*****************************************************************************
  1416.  * FUNCTION
  1417.  *  mmi_phb_entry_sdn_list
  1418.  * DESCRIPTION
  1419.  *  Displays the Service Dail Numbers
  1420.  * PARAMETERS
  1421.  *  void
  1422.  * RETURNS
  1423.  *  void
  1424.  *****************************************************************************/
  1425. void mmi_phb_entry_sdn_list(void)
  1426. {
  1427.     /*----------------------------------------------------------------*/
  1428.     /* Local Variables                                                */
  1429.     /*----------------------------------------------------------------*/
  1430.     U8 i;
  1431.     U8 *guiBuffer;
  1432.     U8 *names[MAX_SIM_ENTRIES];
  1433.     /*----------------------------------------------------------------*/
  1434.     /* Code Body                                                      */
  1435.     /*----------------------------------------------------------------*/
  1436.     EntryNewScreen(SCR_SDN_LIST, mmi_phb_exit_sdn_list, mmi_phb_entry_sdn_list, NULL);
  1437.     guiBuffer = GetCurrGuiBuffer(SCR_SDN_LIST);
  1438.     for (i = 0; i < g_phb_sim_list_count; ++i)
  1439.     {
  1440.         if (pfnUnicodeStrlen((PS8) g_phb_sim_list[i].alpha_id.name))
  1441.         {
  1442.             names[i] = g_phb_sim_list[i].alpha_id.name;
  1443.             if (pfnUnicodeStrlen((PS8) g_phb_sim_list[i].tel.number))
  1444.             {
  1445.                 subMenuDataPtrs[i] = g_phb_sim_list[i].tel.number;
  1446.             }
  1447.             else
  1448.             {
  1449.                 subMenuDataPtrs[i] = (PU8) GetString(STR_GLOBAL_EMPTY_LIST);
  1450.             }
  1451.         }
  1452.         else
  1453.         {
  1454.             if (pfnUnicodeStrlen((PS8) g_phb_sim_list[i].tel.number))
  1455.             {
  1456.                 names[i] = g_phb_sim_list[i].tel.number;
  1457.                 subMenuDataPtrs[i] = NULL;
  1458.             }
  1459.             else
  1460.             {
  1461.                 names[i] = (PU8) GetString(STR_GLOBAL_EMPTY_LIST);
  1462.                 subMenuDataPtrs[i] = NULL;
  1463.             }
  1464.         }
  1465.     }
  1466.     RegisterHighlightHandler(mmi_phb_get_index);
  1467.     ShowCategory53Screen(
  1468.         STR_CALL_SDL_CAPTION,
  1469.         IMG_SCR_PBOOK_CAPTION,
  1470.         STR_GLOBAL_DIAL,
  1471.         IMG_SDL_CALL_LSK,
  1472.         STR_GLOBAL_BACK,
  1473.         IMG_GLOBAL_BACK,
  1474.         g_phb_sim_list_count,
  1475.         names,
  1476.         (U16*) gIndexIconsImageList,
  1477.         subMenuDataPtrs,
  1478.         0,
  1479.         0,
  1480.         guiBuffer);
  1481.     SetLeftSoftkeyFunction(mmi_phb_sdn_list_make_call, KEY_EVENT_UP);
  1482.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1483.     SetKeyHandler(mmi_phb_sdn_list_make_call, KEY_SEND, KEY_EVENT_UP);
  1484.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1485. }
  1486. /*****************************************************************************
  1487.  * FUNCTION
  1488.  *  mmi_phb_exit_sdn_list
  1489.  * DESCRIPTION
  1490.  *  Exit function of mmi_phb_entry_sdn_list()
  1491.  * PARAMETERS
  1492.  *  void
  1493.  * RETURNS
  1494.  *  void
  1495.  *****************************************************************************/
  1496. void mmi_phb_exit_sdn_list(void)
  1497. {
  1498.     /*----------------------------------------------------------------*/
  1499.     /* Local Variables                                                */
  1500.     /*----------------------------------------------------------------*/
  1501.     /*----------------------------------------------------------------*/
  1502.     /* Code Body                                                      */
  1503.     /*----------------------------------------------------------------*/
  1504.     g_phb_cntx.end_scr_id = SCR_SDN_LIST;
  1505. }
  1506. /*****************************************************************************
  1507.  * FUNCTION
  1508.  *  mmi_phb_sdn_list_make_call
  1509.  * DESCRIPTION
  1510.  *  Makes call to an SDL number
  1511.  * PARAMETERS
  1512.  *  void
  1513.  * RETURNS
  1514.  *  void
  1515.  *****************************************************************************/
  1516. void mmi_phb_sdn_list_make_call(void)
  1517. {
  1518.     /*----------------------------------------------------------------*/
  1519.     /* Local Variables                                                */
  1520.     /*----------------------------------------------------------------*/
  1521.     /*----------------------------------------------------------------*/
  1522.     /* Code Body                                                      */
  1523.     /*----------------------------------------------------------------*/
  1524.     if (pfnUnicodeStrlen((PS8) g_phb_sim_list[g_phb_cntx.active_index].tel.number))
  1525.     {
  1526.         g_phb_cntx.dial_from_list = MMI_PHB_SDN;
  1527.         if (g_phb_sim_list[g_phb_cntx.active_index].tel.number[0] == '+' &&
  1528.             g_phb_sim_list[g_phb_cntx.active_index].tel.number[(UCS2Strlen
  1529.                                                                 ((const S8*)(g_phb_sim_list[g_phb_cntx.active_index].
  1530.                                                                               tel.number)) - 1) * ENCODING_LENGTH] ==
  1531.             '#')
  1532.         {
  1533.             MakeCall((PS8) g_phb_sim_list[g_phb_cntx.active_index].tel.number + 2);
  1534.         }
  1535.         else
  1536.         {
  1537.             MakeCall((PS8) g_phb_sim_list[g_phb_cntx.active_index].tel.number);
  1538.         }
  1539.     }
  1540.     else
  1541.     {
  1542.         DisplayPopup((PU8) GetString(STR_NO_NUMBER_TO_DIAL), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  1543.     }
  1544. }
  1545. /* --------------------------------------  END of Phone Book Service Dial Number ------------------------------------------- */
  1546. /* --------------------------------------  Begin of Phone Book SOS(Emergency) Number ------------------------------------------- */
  1547. #define MMI_PHB_SOS_LIST
  1548. /*****************************************************************************
  1549.  * FUNCTION
  1550.  *  mmi_phb_sos_list_init
  1551.  * DESCRIPTION
  1552.  *  Initialization of SOS numbers feature
  1553.  * PARAMETERS
  1554.  *  void
  1555.  * RETURNS
  1556.  *  void
  1557.  *****************************************************************************/
  1558. void mmi_phb_sos_list_init(void)
  1559. {
  1560.     /*----------------------------------------------------------------*/
  1561.     /* Local Variables                                                */
  1562.     /*----------------------------------------------------------------*/
  1563.     /*----------------------------------------------------------------*/
  1564.     /* Code Body                                                      */
  1565.     /*----------------------------------------------------------------*/
  1566.     SetHiliteHandler(MITEM116_PBOOK_SOS_NUMBER, mmi_phb_highlight_sos_list);
  1567. }
  1568. /*****************************************************************************
  1569.  * FUNCTION
  1570.  *  mmi_phb_highlight_sos_list
  1571.  * DESCRIPTION
  1572.  *  Highlight handler for SOS number
  1573.  * PARAMETERS
  1574.  *  void
  1575.  * RETURNS
  1576.  *  void
  1577.  *****************************************************************************/
  1578. void mmi_phb_highlight_sos_list(void)
  1579. {
  1580.     /*----------------------------------------------------------------*/
  1581.     /* Local Variables                                                */
  1582.     /*----------------------------------------------------------------*/
  1583.     /*----------------------------------------------------------------*/
  1584.     /* Code Body                                                      */
  1585.     /*----------------------------------------------------------------*/
  1586.     SetLeftSoftkeyFunction(mmi_phb_sos_list_pre_entry, KEY_EVENT_UP);
  1587.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1588.     SetKeyHandler(mmi_phb_sos_list_pre_entry, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1589.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1590. }
  1591. /*****************************************************************************
  1592.  * FUNCTION
  1593.  *  mmi_phb_sos_list_pre_entry
  1594.  * DESCRIPTION
  1595.  *  Checks and calls the L4 reuest function to fetch SOS numbers
  1596.  * PARAMETERS
  1597.  *  void
  1598.  * RETURNS
  1599.  *  void
  1600.  *****************************************************************************/
  1601. void mmi_phb_sos_list_pre_entry(void)
  1602. {
  1603.     /*----------------------------------------------------------------*/
  1604.     /* Local Variables                                                */
  1605.     /*----------------------------------------------------------------*/
  1606.     /*----------------------------------------------------------------*/
  1607.     /* Code Body                                                      */
  1608.     /*----------------------------------------------------------------*/
  1609.     if (g_phb_cntx.phb_ready)
  1610.     {
  1611.         mmi_phb_show_in_progress(STR_PROCESSING_PHONEBOOK, IMG_PROCESSING_PHONEBOOK);
  1612.         mmi_phb_sos_list_get_entry_req();
  1613.     }
  1614.     else
  1615.     {
  1616.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1617.     }
  1618. }
  1619. /*****************************************************************************
  1620.  * FUNCTION
  1621.  *  mmi_phb_sos_list_get_entry_req
  1622.  * DESCRIPTION
  1623.  *  Sends the request to L4 to get the SOS numbers
  1624.  * PARAMETERS
  1625.  *  void
  1626.  * RETURNS
  1627.  *  void
  1628.  *****************************************************************************/
  1629. void mmi_phb_sos_list_get_entry_req(void)
  1630. {
  1631.     /*----------------------------------------------------------------*/
  1632.     /* Local Variables                                                */
  1633.     /*----------------------------------------------------------------*/
  1634.     MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT *myMsgPtr;
  1635.     MYQUEUE Message;
  1636.     /*----------------------------------------------------------------*/
  1637.     /* Code Body                                                      */
  1638.     /*----------------------------------------------------------------*/
  1639.     myMsgPtr =
  1640.         (MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT*) OslIntConstructDataPtr(sizeof(MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT));
  1641.     myMsgPtr->index = 1;
  1642.     myMsgPtr->record_index = 0xFFFF;
  1643.     myMsgPtr->storage = MMI_SIM;
  1644.     myMsgPtr->type = MMI_PHB_ECC;
  1645.     myMsgPtr->no_data = MAX_ENTRIES_IN_LIST;
  1646.     Message.oslSrcId = MOD_MMI;
  1647.     Message.oslDestId = MOD_L4C;
  1648.     Message.oslMsgId = PRT_PHB_GET_ENTRY_BY_INDEX_REQ;
  1649.     Message.oslDataPtr = (oslParaType*) myMsgPtr;
  1650.     Message.oslPeerBuffPtr = NULL;
  1651.     SetProtocolEventHandler(mmi_phb_sos_list_get_entry_rsp, PRT_PHB_GET_ENTRY_BY_INDEX_RSP);
  1652.     OslMsgSendExtQueue(&Message);
  1653. }
  1654. /*****************************************************************************
  1655.  * FUNCTION
  1656.  *  mmi_phb_sos_list_get_entry_rsp
  1657.  * DESCRIPTION
  1658.  *  Reads SOS numbers from L4
  1659.  * PARAMETERS
  1660.  *  info        [IN]        Return from L4
  1661.  * RETURNS
  1662.  *  void
  1663.  *****************************************************************************/
  1664. void mmi_phb_sos_list_get_entry_rsp(void *info)
  1665. {
  1666.     /*----------------------------------------------------------------*/
  1667.     /* Local Variables                                                */
  1668.     /*----------------------------------------------------------------*/
  1669.     MSG_PHB_GET_ENTRY_BY_INDEX_RSP_STRUCT *localPtr;
  1670.     U16 i;
  1671.     U8 number[MAX_PB_NUMBER_LENGTH + 1 + 1];
  1672.     /*----------------------------------------------------------------*/
  1673.     /* Code Body                                                      */
  1674.     /*----------------------------------------------------------------*/
  1675.     localPtr = (MSG_PHB_GET_ENTRY_BY_INDEX_RSP_STRUCT*) info;
  1676.     if (localPtr->result.flag == 0 /* OK */ )
  1677.     {
  1678.         g_phb_sim_list_count = (localPtr->no_list < MAX_SIM_ENTRIES) ? localPtr->no_list : MAX_SIM_ENTRIES;
  1679.         for (i = 0; i < g_phb_sim_list_count && i < MAX_SIM_SOS_ENTRIES; ++i)
  1680.         {
  1681.             g_phb_sim_list[i].storage = localPtr->list[i].storage;
  1682.             g_phb_sim_list[i].index = localPtr->list[i].index;
  1683.             g_phb_sim_list[i].record_index = localPtr->list[i].record_index;
  1684.             g_phb_sim_list[i].tel.type = localPtr->list[i].tel.type;
  1685.             if ((g_phb_sim_list[i].tel.length > 0) && ((g_phb_sim_list[i].tel.type & 0x10) != 0))
  1686.             {
  1687.                 number[0] = '+';
  1688.                 memcpy((void*)&number[1], (void*)&localPtr->list[i].tel.number[0], MAX_PB_NUMBER_LENGTH - 1);
  1689.                 AnsiiToUnicodeString((PS8) & g_phb_sim_list[i].tel.number, (PS8) number);
  1690.             }
  1691.             else
  1692.             {
  1693.                 g_phb_sim_list[i].tel.length = localPtr->list[i].tel.length;
  1694.                 memcpy((void*)&number, (void*)&localPtr->list[i].tel.number, MAX_PB_NUMBER_LENGTH);
  1695.                 AnsiiToUnicodeString((PS8) & g_phb_sim_list[i].tel.number, (PS8) number);
  1696.             }
  1697.         }
  1698.     }
  1699.     else    /* TBD - what to do if result flag is false */
  1700.     {
  1701.         g_phb_sim_list_count = 0;
  1702.     }
  1703.     mmi_phb_entry_sos_list();
  1704. }
  1705. /*****************************************************************************
  1706.  * FUNCTION
  1707.  *  mmi_phb_entry_sos_list
  1708.  * DESCRIPTION
  1709.  *  Displays the SOS list
  1710.  * PARAMETERS
  1711.  *  void
  1712.  * RETURNS
  1713.  *  void
  1714.  *****************************************************************************/
  1715. void mmi_phb_entry_sos_list(void)
  1716. {
  1717.     /*----------------------------------------------------------------*/
  1718.     /* Local Variables                                                */
  1719.     /*----------------------------------------------------------------*/
  1720.     U8 *guiBuffer;
  1721.     S32 index = 0;
  1722.     S32 display_index = 0;
  1723.     S16 error = 0;
  1724.     U8 *sub_ptr[MAX_NVRAM_SOS_ENTRIES + MAX_SIM_ENTRIES];
  1725.     /*----------------------------------------------------------------*/
  1726.     /* Code Body                                                      */
  1727.     /*----------------------------------------------------------------*/
  1728.     /* Read from NVRAM for one time */
  1729.     if (g_phb_sos_nvram_read == 0)
  1730.     {
  1731.         for (index = 0; index < MAX_NVRAM_SOS_ENTRIES; index++)
  1732.         {
  1733.             ReadRecord(
  1734.                 NVRAM_EF_PHONEBOOK_SOS_LID,
  1735.                 (U16) (index + 1),
  1736.                 &g_phb_nvram_list[index],
  1737.                 NVRAM_SOS_RECORD_SIZE,
  1738.                 &error);
  1739.         }
  1740.         g_phb_sos_nvram_read = 1;
  1741.     }
  1742.     /* Prepare list */
  1743.     for (index = 0; index < g_phb_sim_list_count; ++index)
  1744.     {
  1745.         g_phb_sos_list[display_index] = (U8*) g_phb_sim_list[index].tel.number;
  1746.         sub_ptr[display_index++] = (U8*) GetString(STR_SOSLIST_INCARD);
  1747.     }
  1748.     for (; index < (MAX_NVRAM_SOS_ENTRIES + g_phb_sim_list_count); ++index)
  1749.     {
  1750.         if (g_phb_nvram_list[index - g_phb_sim_list_count].length == 0xFF ||
  1751.             g_phb_nvram_list[index - g_phb_sim_list_count].length == 0)
  1752.         {
  1753.         #if defined(__MMI_PHB_SOS_NUM_EDIT__)
  1754.             g_phb_sos_list[display_index] = (U8*) GetString(STR_GLOBAL_EMPTY_LIST);
  1755.             sub_ptr[display_index++] = (U8*) GetString(STR_SOSLIST_NVRAM);
  1756.         #endif /* defined(__MMI_PHB_SOS_NUM_EDIT__) */ 
  1757.         }
  1758.         else
  1759.         {
  1760.             g_phb_sos_list[display_index] = (U8*) g_phb_nvram_list[index - g_phb_sim_list_count].number;
  1761.             sub_ptr[display_index++] = (U8*) GetString(STR_SOSLIST_NVRAM);
  1762.         }
  1763.     }
  1764. #if !defined(__MMI_PHB_SOS_NUM_EDIT__)
  1765.     if (display_index == 0)
  1766.     {
  1767.         DisplayPopup((PU8) GetString(STR_GLOBAL_EMPTY), IMG_GLOBAL_EMPTY, TRUE, PHB_NOTIFY_TIMEOUT, EMPTY_LIST_TONE);
  1768.         return;
  1769.     }
  1770. #endif /* !defined(__MMI_PHB_SOS_NUM_EDIT__) */ 
  1771.     EntryNewScreen(SCR_SOS_DISPLAY, mmi_phb_exit_sos_list, mmi_phb_entry_sos_list, NULL);
  1772.     guiBuffer = GetCurrGuiBuffer(SCR_SOS_DISPLAY);
  1773.     RegisterHighlightHandler(mmi_phb_sos_list_get_index);
  1774.     for (index = 0; index < display_index; index++) /* subMenuDataPtrs[] will be clear in EntryNewScreen, so reassign here. */
  1775.     {
  1776.         subMenuDataPtrs[index] = sub_ptr[index];
  1777.     }
  1778. #if defined(__MMI_PHB_SOS_NUM_EDIT__)
  1779.     ShowCategory53Screen(
  1780.         STR_DISPLAY_SOS_CAPTION,
  1781.         IMG_SCR_PBOOK_CAPTION,
  1782.         STR_GLOBAL_EDIT,
  1783.         IMG_GLOBAL_OPTIONS,
  1784.         STR_GLOBAL_BACK,
  1785.         IMG_GLOBAL_BACK,
  1786.         display_index /* (MAX_NVRAM_SOS_ENTRIES + g_phb_sim_list_count ) */ ,
  1787.         g_phb_sos_list,
  1788.         (U16*) gIndexIconsImageList,
  1789.         subMenuDataPtrs,
  1790.         0,
  1791.         0,
  1792.         guiBuffer);
  1793. #else /* defined(__MMI_PHB_SOS_NUM_EDIT__) */ 
  1794.     ShowCategory53Screen(
  1795.         STR_DISPLAY_SOS_CAPTION,
  1796.         IMG_SCR_PBOOK_CAPTION,
  1797.         STR_GLOBAL_DIAL,
  1798.         IMG_GLOBAL_OPTIONS,
  1799.         STR_GLOBAL_BACK,
  1800.         IMG_GLOBAL_BACK,
  1801.         display_index /* (MAX_NVRAM_SOS_ENTRIES + g_phb_sim_list_count ) */ ,
  1802.         g_phb_sos_list,
  1803.         (U16*) gIndexIconsImageList,
  1804.         subMenuDataPtrs,
  1805.         0,
  1806.         0,
  1807.         guiBuffer);
  1808.     SetLeftSoftkeyFunction(mmi_phb_sos_list_pre_confirm_call, KEY_EVENT_UP);
  1809. #endif /* defined(__MMI_PHB_SOS_NUM_EDIT__) */ 
  1810.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1811.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1812.     SetKeyHandler(mmi_phb_sos_list_pre_confirm_call, KEY_SEND, KEY_EVENT_UP);
  1813. }
  1814. /*****************************************************************************
  1815.  * FUNCTION
  1816.  *  mmi_phb_exit_sos_list
  1817.  * DESCRIPTION
  1818.  *  Exit function of mmi_phb_entry_sos_list()
  1819.  * PARAMETERS
  1820.  *  void
  1821.  * RETURNS
  1822.  *  void
  1823.  *****************************************************************************/
  1824. void mmi_phb_exit_sos_list(void)
  1825. {
  1826.     /*----------------------------------------------------------------*/
  1827.     /* Local Variables                                                */
  1828.     /*----------------------------------------------------------------*/
  1829.     /*----------------------------------------------------------------*/
  1830.     /* Code Body                                                      */
  1831.     /*----------------------------------------------------------------*/
  1832.     g_phb_cntx.end_scr_id = SCR_SOS_DISPLAY;
  1833. }
  1834. /*****************************************************************************
  1835.  * FUNCTION
  1836.  *  mmi_phb_sos_list_get_index
  1837.  * DESCRIPTION
  1838.  *  (S32)
  1839.  *  Gets the index of currently highlighted SOS number.Also sets the LSK accordingly.
  1840.  * PARAMETERS
  1841.  *  index       [IN]        Highlight index
  1842.  * RETURNS
  1843.  *  void
  1844.  *****************************************************************************/
  1845. void mmi_phb_sos_list_get_index(S32 index)
  1846. {
  1847.     /*----------------------------------------------------------------*/
  1848.     /* Local Variables                                                */
  1849.     /*----------------------------------------------------------------*/
  1850.     /*----------------------------------------------------------------*/
  1851.     /* Code Body                                                      */
  1852.     /*----------------------------------------------------------------*/
  1853.     g_phb_cntx.active_index = (S16) index;
  1854. #if defined(__MMI_PHB_SOS_NUM_EDIT__)
  1855.     if (pfnUnicodeStrcmp((PS8) subMenuDataPtrs[g_phb_cntx.active_index], (PS8) GetString(STR_SOSLIST_INCARD)) == 0)
  1856.     {
  1857.         ChangeLeftSoftkey(0, 0);
  1858.         ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_UP);
  1859.     }
  1860.     else
  1861.     {
  1862.         ChangeLeftSoftkey(STR_GLOBAL_EDIT, IMG_GLOBAL_OK);
  1863.         SetLeftSoftkeyFunction(mmi_phb_sos_list_pre_entry_number, KEY_EVENT_UP);
  1864.         SetKeyHandler(mmi_phb_sos_list_pre_entry_number, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1865.     }
  1866. #endif /* defined(__MMI_PHB_SOS_NUM_EDIT__) */ 
  1867. }
  1868. #if defined(__MMI_PHB_SOS_NUM_EDIT__)
  1869. /*****************************************************************************
  1870.  * FUNCTION
  1871.  *  mmi_phb_sos_list_pre_entry_number
  1872.  * DESCRIPTION
  1873.  *  Calls the function to edit the SOS number
  1874.  * PARAMETERS
  1875.  *  void
  1876.  * RETURNS
  1877.  *  void
  1878.  *****************************************************************************/
  1879. void mmi_phb_sos_list_pre_entry_number(void)
  1880. {
  1881.     /*----------------------------------------------------------------*/
  1882.     /* Local Variables                                                */
  1883.     /*----------------------------------------------------------------*/
  1884.     /*----------------------------------------------------------------*/
  1885.     /* Code Body                                                      */
  1886.     /*----------------------------------------------------------------*/
  1887.     if (!pfnUnicodeStrcmp((PS8) g_phb_sos_list[g_phb_cntx.active_index], (PS8) GetString(STR_GLOBAL_EMPTY_LIST)))
  1888.     {
  1889.         memset(pbNumber, 0, ENCODING_LENGTH);
  1890.     }
  1891.     else
  1892.     {
  1893.         pfnUnicodeStrcpy((PS8) pbNumber, (PS8) g_phb_sos_list[g_phb_cntx.active_index]);
  1894.     }
  1895.     mmi_phb_entry_sos_list_enter_number();
  1896. }
  1897. /*****************************************************************************
  1898.  * FUNCTION
  1899.  *  mmi_phb_entry_sos_list_enter_number
  1900.  * DESCRIPTION
  1901.  *  Accpt user input for SOS number
  1902.  * PARAMETERS
  1903.  *  void
  1904.  * RETURNS
  1905.  *  void
  1906.  *****************************************************************************/
  1907. void mmi_phb_entry_sos_list_enter_number(void)
  1908. {
  1909.     /*----------------------------------------------------------------*/
  1910.     /* Local Variables                                                */
  1911.     /*----------------------------------------------------------------*/
  1912.     U8 *guiBuffer;
  1913.     /*----------------------------------------------------------------*/
  1914.     /* Code Body                                                      */
  1915.     /*----------------------------------------------------------------*/
  1916.     EntryNewScreen(SCR_ENTER_SOS_NUMBER, mmi_phb_exit_sos_list_enter_number, mmi_phb_entry_sos_list_enter_number, NULL);
  1917.     guiBuffer = GetCurrGuiBuffer(SCR_ENTER_SOS_NUMBER);
  1918.     ShowCategory5Screen(
  1919.         STR_GLOBAL_EDIT,
  1920.         IMG_SCR_PBOOK_CAPTION,
  1921.         STR_GLOBAL_OK,
  1922.         IMG_GLOBAL_OK,
  1923.         STR_GLOBAL_BACK,
  1924.         IMG_GLOBAL_BACK,
  1925.         INPUT_TYPE_PHONE_NUMBER,
  1926.         (PU8) pbNumber,
  1927.         MAX_PB_NUMBER_LENGTH + 1,
  1928.         guiBuffer);
  1929.     SetLeftSoftkeyFunction(mmi_phb_sos_list_update_entry, KEY_EVENT_UP);
  1930.     SetCategory5RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1931. }
  1932. /*****************************************************************************
  1933.  * FUNCTION
  1934.  *  mmi_phb_exit_sos_list_enter_number
  1935.  * DESCRIPTION
  1936.  *  Exit function of mmi_phb_exit_sos_list_enter_number()
  1937.  * PARAMETERS
  1938.  *  void
  1939.  * RETURNS
  1940.  *  void
  1941.  *****************************************************************************/
  1942. void mmi_phb_exit_sos_list_enter_number(void)
  1943. {
  1944.     /*----------------------------------------------------------------*/
  1945.     /* Local Variables                                                */
  1946.     /*----------------------------------------------------------------*/
  1947.     /*----------------------------------------------------------------*/
  1948.     /* Code Body                                                      */
  1949.     /*----------------------------------------------------------------*/
  1950.     g_phb_cntx.end_scr_id = SCR_ENTER_SOS_NUMBER;
  1951. }
  1952. /*****************************************************************************
  1953.  * FUNCTION
  1954.  *  mmi_phb_sos_list_update_entry
  1955.  * DESCRIPTION
  1956.  *  Saves the SOS number on NVRAM
  1957.  * PARAMETERS
  1958.  *  void
  1959.  * RETURNS
  1960.  *  void
  1961.  *****************************************************************************/
  1962. void mmi_phb_sos_list_update_entry(void)
  1963. {
  1964.     /*----------------------------------------------------------------*/
  1965.     /* Local Variables                                                */
  1966.     /*----------------------------------------------------------------*/
  1967.     S16 error;
  1968.     S32 str_len = 0;
  1969.     /*----------------------------------------------------------------*/
  1970.     /* Code Body                                                      */
  1971.     /*----------------------------------------------------------------*/
  1972.     str_len = pfnUnicodeStrlen((PS8) pbNumber);
  1973.     pfnUnicodeStrcpy((PS8) g_phb_nvram_list[g_phb_cntx.active_index].number, (PS8) pbNumber);
  1974.     g_phb_nvram_list[g_phb_cntx.active_index].length = (U8) str_len;
  1975.     g_phb_nvram_list[g_phb_cntx.active_index].type = 0;
  1976.     str_len = WriteRecord(
  1977.                 NVRAM_EF_PHONEBOOK_SOS_LID,
  1978.                 (U16) (g_phb_cntx.active_index + 1),
  1979.                 &g_phb_nvram_list[g_phb_cntx.active_index],
  1980.                 NVRAM_SOS_RECORD_SIZE,
  1981.                 &error);
  1982.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, TRUE, PHB_NOTIFY_TIMEOUT, SUCCESS_TONE);
  1983.     DeleteNScrId(SCR_ENTER_SOS_NUMBER);
  1984. }
  1985. #endif /* defined(__MMI_PHB_SOS_NUM_EDIT__) */ 
  1986. /*****************************************************************************
  1987.  * FUNCTION
  1988.  *  mmi_phb_sos_list_pre_confirm_call
  1989.  * DESCRIPTION
  1990.  *  Asks before calling to an SOS number
  1991.  * PARAMETERS
  1992.  *  void
  1993.  * RETURNS
  1994.  *  void
  1995.  *****************************************************************************/
  1996. void mmi_phb_sos_list_pre_confirm_call(void)
  1997. {
  1998.     /*----------------------------------------------------------------*/
  1999.     /* Local Variables                                                */
  2000.     /*----------------------------------------------------------------*/
  2001.     /*----------------------------------------------------------------*/
  2002.     /* Code Body                                                      */
  2003.     /*----------------------------------------------------------------*/
  2004.     if (pfnUnicodeStrcmp((PS8) g_phb_sos_list[g_phb_cntx.active_index], (PS8) GetString(STR_GLOBAL_EMPTY_LIST)) == 0)
  2005.     {
  2006.         DisplayPopup((PU8) GetString(STR_NO_NUMBER_TO_DIAL), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  2007.     }
  2008.     else
  2009.     {
  2010.         mmi_phb_entry_sos_list_confirm_call();
  2011.     }
  2012. }
  2013. /*****************************************************************************
  2014.  * FUNCTION
  2015.  *  mmi_phb_entry_sos_list_confirm_call
  2016.  * DESCRIPTION
  2017.  *  Confirm Make SOS Call
  2018.  * PARAMETERS
  2019.  *  void
  2020.  * RETURNS
  2021.  *  void
  2022.  *****************************************************************************/
  2023. void mmi_phb_entry_sos_list_confirm_call(void)
  2024. {
  2025.     /*----------------------------------------------------------------*/
  2026.     /* Local Variables                                                */
  2027.     /*----------------------------------------------------------------*/
  2028.     /*----------------------------------------------------------------*/
  2029.     /* Code Body                                                      */
  2030.     /*----------------------------------------------------------------*/
  2031.     DisplayConfirm(
  2032.         STR_GLOBAL_YES,
  2033.         IMG_GLOBAL_YES,
  2034.         STR_GLOBAL_NO,
  2035.         IMG_GLOBAL_NO,
  2036.         get_string(STR_GLOBAL_DIAL),
  2037.         IMG_GLOBAL_QUESTION,
  2038.         WARNING_TONE);
  2039.     SetLeftSoftkeyFunction(mmi_phb_sos_list_make_call, KEY_EVENT_UP);
  2040.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2041. }
  2042. /*****************************************************************************
  2043.  * FUNCTION
  2044.  *  mmi_phb_sos_list_make_call
  2045.  * DESCRIPTION
  2046.  *  Makes call to the SOS number
  2047.  * PARAMETERS
  2048.  *  void
  2049.  * RETURNS
  2050.  *  void
  2051.  *****************************************************************************/
  2052. void mmi_phb_sos_list_make_call(void)
  2053. {
  2054.     /*----------------------------------------------------------------*/
  2055.     /* Local Variables                                                */
  2056.     /*----------------------------------------------------------------*/
  2057.     /*----------------------------------------------------------------*/
  2058.     /* Code Body                                                      */
  2059.     /*----------------------------------------------------------------*/
  2060.     /* calling an exit function that does nothing */
  2061.     EntryNewScreen(SCR_CONFIRM_SOS_CALL, NULL, NULL, NULL);
  2062.     MakeCall((S8*) g_phb_sos_list[g_phb_cntx.active_index]);
  2063. }
  2064. /*****************************************************************************
  2065.  * FUNCTION
  2066.  *  mmi_phb_check_valid_sos_number
  2067.  * DESCRIPTION
  2068.  *  (PS8)
  2069.  *  number  IN number for check
  2070.  * PARAMETERS
  2071.  *  number      [IN]        
  2072.  * RETURNS
  2073.  *  U8 number type
  2074.  *****************************************************************************/
  2075. U8 mmi_phb_check_valid_sos_number(PS8 number)
  2076. {
  2077.     /*----------------------------------------------------------------*/
  2078.     /* Local Variables                                                */
  2079.     /*----------------------------------------------------------------*/
  2080.     U16 index = 0;
  2081.     S16 error = 0;
  2082.     S32 nNumLen;
  2083.     S32 nLen;
  2084.     /*----------------------------------------------------------------*/
  2085.     /* Code Body                                                      */
  2086.     /*----------------------------------------------------------------*/
  2087.     if (g_phb_sos_nvram_read == 0)
  2088.     {
  2089.         for (index = 0; index < MAX_NVRAM_SOS_ENTRIES; index++)
  2090.         {
  2091.             ReadRecord(
  2092.                 NVRAM_EF_PHONEBOOK_SOS_LID,
  2093.                 (U16) (index + 1),
  2094.                 &g_phb_nvram_list[index],
  2095.                 NVRAM_SOS_RECORD_SIZE,
  2096.                 &error);
  2097.         }
  2098.         g_phb_sos_nvram_read = 1;
  2099.     }
  2100.     nNumLen = pfnUnicodeStrlen(number);
  2101.     for (index = 0; index < g_phb_sim_list_count; index++)
  2102.     {
  2103.         nLen = pfnUnicodeStrlen((S8*) g_phb_sim_list[index].tel.number);
  2104.         if (nLen == nNumLen)
  2105.         {
  2106.             if ((pfnUnicodeStrcmp((PS8) g_phb_sim_list[index].tel.number, (PS8) number) == 0))
  2107.             {
  2108.                 return 2;
  2109.             }
  2110.         }
  2111.         else if (nLen > nNumLen)
  2112.         {
  2113.             if ((pfnUnicodeStrncmp((PS8) g_phb_sim_list[index].tel.number, (PS8) number, nNumLen) == 0))
  2114.             {
  2115.                 return 1;
  2116.             }
  2117.         }
  2118.     }
  2119.     for (index = 0; index < MAX_NVRAM_SOS_ENTRIES; index++)
  2120.     {
  2121.         nLen = pfnUnicodeStrlen((S8*) g_phb_nvram_list[index].number);
  2122.         if (nLen == nNumLen)
  2123.         {
  2124.             if ((pfnUnicodeStrcmp((PS8) g_phb_nvram_list[index].number, (PS8) number) == 0))
  2125.             {
  2126.                 return 2;
  2127.             }
  2128.         }
  2129.         else if (nLen > nNumLen)
  2130.         {
  2131.             if ((pfnUnicodeStrncmp((PS8) g_phb_nvram_list[index].number, (PS8) number, nNumLen) == 0))
  2132.             {
  2133.                 return 1;
  2134.             }
  2135.         }
  2136.     }
  2137.     return FALSE;
  2138. }
  2139. /* --------------------------------------  END of Phone Book SOS(Emergeny) Number ------------------------------------------- */
  2140. #define MMI_PHB_FDN_SEARCH_LIST
  2141. /*****************************************************************************
  2142.  * FUNCTION
  2143.  *  mmi_phb_fdn_get_list_to_ram
  2144.  * DESCRIPTION
  2145.  *  This function is to load FDN list into ADN storage. Because when FDN is enable
  2146.  *  ADN will not be read from SIM card. This FDN list is for number lookup in call.
  2147.  * PARAMETERS
  2148.  *  void
  2149.  * RETURNS
  2150.  *  void
  2151.  *****************************************************************************/
  2152. void mmi_phb_fdn_get_list_to_ram(void)
  2153. {
  2154.     /*----------------------------------------------------------------*/
  2155.     /* Local Variables                                                */
  2156.     /*----------------------------------------------------------------*/
  2157.     /*----------------------------------------------------------------*/
  2158.     /* Code Body                                                      */
  2159.     /*----------------------------------------------------------------*/
  2160.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_fdn_get_list_to_ram.>n", __FILE__,
  2161.                          __LINE__));
  2162.     if (g_phb_cntx.sim_used == 0)
  2163.     {
  2164.         g_phb_fdn_count = 0;
  2165.         mmi_phb_fdn_get_list_to_ram_req();
  2166.     }
  2167.     else
  2168.     {
  2169.         PhbGetSpeedDialInfo();  /* Retrieve Speed Dial List after retrieve FDN list, because they all use same message. */
  2170.     }
  2171. }
  2172. /*****************************************************************************
  2173.  * FUNCTION
  2174.  *  mmi_phb_fdn_get_list_to_ram_req
  2175.  * DESCRIPTION
  2176.  *  This function is to retrieve FDN list
  2177.  * PARAMETERS
  2178.  *  void
  2179.  * RETURNS
  2180.  *  void
  2181.  *****************************************************************************/
  2182. void mmi_phb_fdn_get_list_to_ram_req(void)
  2183. {
  2184.     /*----------------------------------------------------------------*/
  2185.     /* Local Variables                                                */
  2186.     /*----------------------------------------------------------------*/
  2187.     MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT *pMsgIndexReq = NULL;
  2188.     MYQUEUE Message;
  2189.     /*----------------------------------------------------------------*/
  2190.     /* Code Body                                                      */
  2191.     /*----------------------------------------------------------------*/
  2192.     pMsgIndexReq =
  2193.         (MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT*) OslConstructDataPtr(sizeof(MSG_PHB_GET_ENTRY_BY_INDEX_REQ_STRUCT));
  2194.     pMsgIndexReq->index = g_phb_fdn_count + 1;
  2195.     pMsgIndexReq->record_index = 0xFFFF;
  2196.     pMsgIndexReq->storage = MMI_SIM;
  2197.     pMsgIndexReq->type = MMI_PHB_FDN;
  2198.     pMsgIndexReq->no_data = MAX_ENTRIES_IN_LIST;
  2199.     Message.oslSrcId = MOD_MMI;
  2200.     Message.oslDestId = MOD_L4C;
  2201.     Message.oslMsgId = PRT_PHB_GET_ENTRY_BY_INDEX_REQ;
  2202.     Message.oslDataPtr = (oslParaType*) pMsgIndexReq;
  2203.     Message.oslPeerBuffPtr = NULL;
  2204.     SetProtocolEventHandler(mmi_phb_fdn_get_list_to_ram_rsp, PRT_PHB_GET_ENTRY_BY_INDEX_RSP);
  2205.     OslMsgSendExtQueue(&Message);
  2206. }
  2207. /*****************************************************************************
  2208.  * FUNCTION
  2209.  *  mmi_phb_fdn_get_list_to_ram_rsp
  2210.  * DESCRIPTION
  2211.  *  This function is to convert FDN retrievie result to ADN storage.
  2212.  * PARAMETERS
  2213.  *  info        [?]     
  2214.  * RETURNS
  2215.  *  void
  2216.  *****************************************************************************/
  2217. void mmi_phb_fdn_get_list_to_ram_rsp(void *info)
  2218. {
  2219.     /*----------------------------------------------------------------*/
  2220.     /* Local Variables                                                */
  2221.     /*----------------------------------------------------------------*/
  2222.     MSG_PHB_GET_ENTRY_BY_INDEX_RSP_STRUCT *localPtr;
  2223.     U16 i;
  2224.     U16 store_index;
  2225.     /*----------------------------------------------------------------*/
  2226.     /* Code Body                                                      */
  2227.     /*----------------------------------------------------------------*/
  2228.     localPtr = (MSG_PHB_GET_ENTRY_BY_INDEX_RSP_STRUCT*) info;
  2229.     if (localPtr->result.flag == 0 /* OK */ )
  2230.     {
  2231.         for (i = 0; i < localPtr->no_list; i++)
  2232.         {
  2233.             if (g_phb_fdn_count < MAX_SIM_ENTRIES)
  2234.             {
  2235.                 store_index = g_phb_fdn_count + MAX_PB_PHONE_ENTRIES;
  2236.                 g_phb_fdn_count++;
  2237.             }
  2238.             else
  2239.             {
  2240.                 continue;
  2241.             }
  2242.             /* Parse Name Field */
  2243.             PhoneBook[store_index].alpha_id.name_length = localPtr->list[i].alpha_id.name_length;
  2244.             PhoneBook[store_index].alpha_id.name_dcs = localPtr->list[i].alpha_id.name_dcs;
  2245.             InputboxConvertGSMToDeviceEncoding(
  2246.                 localPtr->list[i].alpha_id.name,
  2247.                 PhoneBook[store_index].alpha_id.name,
  2248.                 localPtr->list[i].alpha_id.name_length,
  2249.                 (MAX_PB_NAME_LENGTH + 1) * ENCODING_LENGTH,
  2250.                 localPtr->list[i].alpha_id.name_dcs,
  2251.                 0,
  2252.                 1);
  2253.             /* Parse Tel Number */
  2254.             PhoneBook[store_index].tel.type = localPtr->list[i].tel.type;
  2255.             PhoneBook[store_index].tel.length = localPtr->list[i].tel.length;
  2256.             mmi_phb_convert_to_bcd(
  2257.                 PhoneBook[store_index].tel.number,
  2258.                 localPtr->list[i].tel.number,
  2259.                 (MAX_PB_NUMBER_LENGTH + 1) / 2);
  2260.         }
  2261.         if (localPtr->no_list == MAX_ENTRIES_IN_LIST)
  2262.         {
  2263.             mmi_phb_fdn_get_list_to_ram_req();
  2264.             return;
  2265.         }
  2266.     }
  2267.     /* Retrieve Speed Dial List after retrieve FDN list, because they all use same message. */
  2268.     PhbGetSpeedDialInfo();
  2269. }
  2270. /*****************************************************************************
  2271.  * FUNCTION
  2272.  *  mmi_phb_fdn_search_by_number
  2273.  * DESCRIPTION
  2274.  *  This function is to match calling number with FDN list store in ADN storage
  2275.  *  Only match when FDN is enable
  2276.  * PARAMETERS
  2277.  *  number      [IN]        ASCII format number
  2278.  * RETURNS
  2279.  *  result index
  2280.  *****************************************************************************/
  2281. U16 mmi_phb_fdn_search_by_number(S8 *number)
  2282. {
  2283.     /*----------------------------------------------------------------*/
  2284.     /* Local Variables                                                */
  2285.     /*----------------------------------------------------------------*/
  2286.     U16 i;
  2287.     U16 store_index;
  2288.     U8 tempNumber[MAX_PB_NUMBER_LENGTH + 1 + 1];
  2289.     /*----------------------------------------------------------------*/
  2290.     /* Code Body                                                      */
  2291.     /*----------------------------------------------------------------*/
  2292.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_fdn_search_by_number.>n", __FILE__,
  2293.                          __LINE__));
  2294.     if (g_phb_cntx.sim_used > 0)    /* ADN is read out from SIM card, so there is no storing FDN entry data. */
  2295.     {
  2296.         return 0xffff;
  2297.     }
  2298.     for (i = 0; i < g_phb_fdn_count; i++)
  2299.     {
  2300.         store_index = i + MAX_PB_PHONE_ENTRIES;
  2301.         if (PhoneBook[store_index].tel.type == MMI_CSMCC_INTERNATIONAL_ADDR)
  2302.         {
  2303.             tempNumber[0] = '+';
  2304.             mmi_phb_convert_to_digit(
  2305.                 (U8*) (tempNumber + 1),
  2306.                 PhoneBook[store_index].tel.number,
  2307.                 MAX_PB_NUMBER_LENGTH + 1);
  2308.         }
  2309.         else
  2310.         {
  2311.             mmi_phb_convert_to_digit(tempNumber, PhoneBook[store_index].tel.number, MAX_PB_NUMBER_LENGTH + 1);
  2312.         }
  2313.         if (!strcmp((S8*) tempNumber, number))
  2314.         {
  2315.             return store_index;
  2316.         }
  2317.     }
  2318.     return 0xffff;
  2319. }
  2320. /*****************************************************************************
  2321.  * FUNCTION
  2322.  *  mmi_phb_get_sim_entry
  2323.  * DESCRIPTION
  2324.  *  This function is to get sdn entry for mmi_phb_call_get_call_data_for_call_mgnt
  2325.  * PARAMETERS
  2326.  *  void
  2327.  * RETURNS
  2328.  *  result MMI_PHB_ENTRY_STRUCT*
  2329.  *****************************************************************************/
  2330. MMI_PHB_ENTRY_STRUCT *mmi_phb_get_sim_entry(void)
  2331. {
  2332.     /*----------------------------------------------------------------*/
  2333.     /* Local Variables                                                */
  2334.     /*----------------------------------------------------------------*/
  2335.     /*----------------------------------------------------------------*/
  2336.     /* Code Body                                                      */
  2337.     /*----------------------------------------------------------------*/
  2338.     return &g_phb_sim_list[g_phb_cntx.active_index];
  2339. }
  2340. #endif /* _PHONEBOOKEXTRANUMBER_C */