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

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.  * PhoneBookOperateMass.C
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is intends for phonebook mass operation.
  48.  *   Such as Copy All and Delete All.
  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.  * removed!
  97.  * removed!
  98.  * removed!
  99.  *
  100.  * removed!
  101.  * removed!
  102.  * removed!
  103.  *
  104.  * removed!
  105.  * removed!
  106.  * removed!
  107.  *
  108.  * removed!
  109.  * removed!
  110.  * removed!
  111.  *
  112.  * removed!
  113.  * removed!
  114.  * removed!
  115.  *
  116.  * removed!
  117.  * removed!
  118.  * removed!
  119.  *
  120.  * removed!
  121.  * removed!
  122.  * removed!
  123.  *
  124.  * removed!
  125.  * removed!
  126.  * removed!
  127.  *
  128.  * removed!
  129.  * removed!
  130.  * removed!
  131.  *
  132.  * removed!
  133.  * removed!
  134.  * removed!
  135.  *
  136.  * removed!
  137.  * removed!
  138.  * removed!
  139.  *
  140.  * removed!
  141.  * removed!
  142.  * removed!
  143.  *
  144.  * removed!
  145.  * removed!
  146.  * removed!
  147.  *
  148.  * removed!
  149.  * removed!
  150.  * removed!
  151.  *
  152.  * removed!
  153.  * removed!
  154.  * removed!
  155.  *
  156.  * removed!
  157.  * removed!
  158.  * removed!
  159.  *
  160.  * removed!
  161.  * removed!
  162.  * removed!
  163.  *
  164.  * removed!
  165.  * removed!
  166.  * removed!
  167.  *
  168.  * removed!
  169.  * removed!
  170.  * removed!
  171.  *
  172.  * removed!
  173.  * removed!
  174.  * removed!
  175.  *
  176.  * removed!
  177.  * removed!
  178.  * removed!
  179.  *
  180.  *------------------------------------------------------------------------------
  181.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  182.  *============================================================================
  183.  ****************************************************************************/
  184. #ifndef _PHONEBOOKOPERATEMASS_C
  185. #define _PHONEBOOKOPERATEMASS_C
  186. #include "MMI_features.h"
  187. #include "stdC.h"
  188. #include "L4Dr1.h"
  189. #include "PixtelDataTypes.h"
  190. #include "GlobalMenuItems.h"
  191. #include "DebugInitDef.h"
  192. #include "CustDataRes.h"
  193. #include "PixtelDataTypes.h"
  194. #include "ProtocolEvents.h"
  195. #include "PhoneBookGprot.h"
  196. #include "GlobalDefs.h"
  197. #include "EventsGprot.h"
  198. #include "wgui_categories.h"
  199. #include "wgui_categories_inputs.h"
  200. #include "wgui_categories_popup.h"
  201. #include "wgui_status_icons.h"       /* for Missed Call*/
  202. #include "GSM7BitDefaultAlphabet.h"
  203. #include "PhonebookDef.h"
  204. #include "PhoneBookProt.h"
  205. #include "HistoryGprot.h"
  206. #include "Unicodexdcl.h"
  207. #include "TimerEvents.h"
  208. #include "CustMenuRes.h"
  209. #include "NVRAMProt.h"
  210. #include "NVRAMType.h"
  211. #include "NVRAMEnum.h"
  212. #include "SettingDefs.h"
  213. #include "SettingGprots.h"
  214. #include "SettingsGdcl.h"
  215. #include "CallSetUpEnum.h"
  216. #include "CallsDefs.h"
  217. #include "CallsStruct.h"
  218. #include "gpioInc.h"
  219. #include "CommonScreens.h"
  220. #ifdef __MMI_VCARD__
  221. #include "FileManagerGProt.h"
  222. #include "vObjects.h"
  223. #include "vCard.h"
  224. #endif /* __MMI_VCARD__ */ 
  225. #if defined(__MMI_VRSD_DIAL__)
  226. #include "VRSDDial.h"
  227. #endif 
  228. #if defined(__MMI_VRSI__)
  229. #include "Mdi_datatype.h"
  230. #include "VRSIEnum.h"
  231. #include "VRSIType.h"
  232. #include "VRSIProt.h"
  233. #endif /* defined(__MMI_VRSI__) */ 
  234. #ifdef __J2ME__
  235. #include "j2me_custom_option.h"
  236. #endif
  237. #ifdef __SYNCML_SUPPORT__
  238. #include "SyncMLDef.h"
  239. #include "SyncMLGprot.h"
  240. #endif /* __SYNCML_SUPPORT__ */
  241. /* 
  242.  * Local Variable
  243.  */
  244. static U16 g_phb_mass_op_index;
  245. static U16 g_phb_mass_op_lookup_count;
  246. static BOOL g_phb_mass_op_abort;
  247. #ifdef __MMI_VCARD__
  248. static S8 pbvCardHomeNumber[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
  249. static S8 pbvCardCompanyName[(MAX_PB_COMPANY_LENGTH + 1) * ENCODING_LENGTH];
  250. static S8 pbvCardEmailAddress[(MAX_PB_EMAIL_LENGTH + 1) * ENCODING_LENGTH];
  251. static S8 pbvCardOfficeNumber[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
  252. static S8 pbvCardFaxNumber[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
  253. #if defined(__MMI_PHB_BIRTHDAY_FIELD__)
  254. static S8 pbvCardDay[3 * ENCODING_LENGTH];
  255. static S8 pbvCardMon[3 * ENCODING_LENGTH];
  256. static S8 pbvCardYear[6 * ENCODING_LENGTH];
  257. #endif /* defined(__MMI_PHB_BIRTHDAY_FIELD__) */ 
  258. #endif /* __MMI_VCARD__ */ 
  259. /* 
  260.  * Global Variable
  261.  */
  262. BOOL g_phb_mass_op_success = TRUE;
  263. U16 g_phb_mass_op_count;
  264. extern U16 PhoneBookEntryCount;
  265. extern MMI_PHB_ENTRY_BCD_STRUCT PhoneBook[MAX_PB_ENTRIES];
  266. #ifdef __MMI_PHB_USIM_FIELD__
  267. extern MMI_PHB_EMAIL_STRUCT phb_email[MAX_PB_SIM_ENTRIES];
  268. extern MMI_PHB_NUMBER_BCD_STRUCT phb_anr[MAX_PB_SIM_ENTRIES][3];
  269. extern S8 pbNickName[];
  270. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  271. #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
  272. extern PHB_OPTIONAL_FIELDS_STRUCT PhoneBookOptionalFields;
  273. #endif 
  274. extern U8 gPhonePassword[];
  275. extern U16 g_phb_name_index[];
  276. extern MMI_PHB_LOOKUP_NODE_STRUCT LookUpTable[];
  277. extern S8 pbName[];
  278. extern S8 pbNumber[];
  279. extern S8 pbHomeNumber[];
  280. extern S8 pbCompanyName[];
  281. extern S8 pbEmailAddress[];
  282. extern S8 pbOfficeNumber[];
  283. extern S8 pbFaxNumber[];
  284. #if defined(__MMI_PHB_EMAIL_SORT__)
  285. extern U8 g_phb_email_sorted;
  286. #endif 
  287. #if defined(__MMI_PHB_INFO_FIELD__)
  288. extern PHB_INFO_FIELDS_STRUCT PhoneBookInfoFields;
  289. #endif 
  290. /* 
  291.  * Local Functions
  292.  */
  293. static void mmi_phb_vcard_req(void *info);
  294. #ifdef __MMI_VCARD__
  295. static void mmi_phb_vcard_req_set_default_file(S8 *path);
  296. #endif 
  297. #ifdef __MMI_PHB_USIM_FIELD__
  298. static void mmi_phb_op_copy_all_to_usim_one_after_one_req(void);
  299. #endif 
  300. /* 
  301.  * Global Function
  302.  */
  303. extern void SECSETVerifyPINReq(U8 pin_type, U8 *ucs2_pin, U8 *ucs2_new_pin, FuncPtr success_callback);
  304. #define MMI_PHB_MASS_INIT
  305. /*****************************************************************************
  306.  * FUNCTION
  307.  *  mmi_phb_operate_mass_init
  308.  * DESCRIPTION
  309.  *  Initialization of "Copy All, Delete All" feature
  310.  * PARAMETERS
  311.  *  void
  312.  * RETURNS
  313.  *  void
  314.  *****************************************************************************/
  315. void mmi_phb_operate_mass_init(void)
  316. {
  317.     /*----------------------------------------------------------------*/
  318.     /* Local Variables                                                */
  319.     /*----------------------------------------------------------------*/
  320.     /*----------------------------------------------------------------*/
  321.     /* Code Body                                                      */
  322.     /*----------------------------------------------------------------*/
  323.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_operate_mass_init.>n", __FILE__,
  324.                          __LINE__));
  325.     /* Copy All */
  326.     SetHiliteHandler(MITEM104_PBOOK_COPY_ALL, mmi_phb_highlight_copy_all);
  327.     SetHiliteHandler(MITEM_PBOOK_COPY_ALL_SIM, mmi_phb_highlight_copy_all_from_sim);
  328.     SetHiliteHandler(MITEM_PBOOK_COPY_ALL_PHONE, mmi_phb_highlight_copy_all_from_phone);
  329.     SetHintHandler(MITEM_PBOOK_COPY_ALL_SIM, mmi_phb_hint_copy_all_from_sim);
  330.     SetHintHandler(MITEM_PBOOK_COPY_ALL_PHONE, mmi_phb_hint_copy_all_from_phone);
  331.     /* Delete All */
  332.     SetHiliteHandler(MITEM103_PBOOK_DELETE_ALL, mmi_phb_highlight_delete_all);
  333.     SetHiliteHandler(MITEM_PBOOK_DELETE_ALL_SIM, mmi_phb_highlight_delete_all_from_sim);
  334.     SetHiliteHandler(MITEM_PBOOK_DELETE_ALL_PHONE, mmi_phb_highlight_delete_all_from_phone);
  335.     SetHintHandler(MITEM_PBOOK_DELETE_ALL_SIM, mmi_phb_hint_delete_all_from_sim);
  336.     SetHintHandler(MITEM_PBOOK_DELETE_ALL_PHONE, mmi_phb_hint_delete_all_from_phone);
  337.     SetHiliteHandler(MENU_ID_PHB_DELETE_ALL_ONE_BY_ONE, mmi_phb_highlight_delete_all_one_by_one);
  338.     /* AT Command Update */
  339.     SetProtocolEventHandler(mmi_phb_ind_update, PRT_PHB_UPDATE_IND);
  340.     SetProtocolEventHandler(mmi_phb_vcard_req, PRT_PHB_VCARD_REQ_IND);
  341. }
  342. #define MMI_PHB_OP_COPY_ALL
  343. /*****************************************************************************
  344.  * FUNCTION
  345.  *  mmi_phb_highlight_copy_all
  346.  * DESCRIPTION
  347.  *  Highlight handler for "Copy All" in PHB main menu
  348.  * PARAMETERS
  349.  *  void
  350.  * RETURNS
  351.  *  void
  352.  *****************************************************************************/
  353. void mmi_phb_highlight_copy_all(void)
  354. {
  355.     /*----------------------------------------------------------------*/
  356.     /* Local Variables                                                */
  357.     /*----------------------------------------------------------------*/
  358.     /*----------------------------------------------------------------*/
  359.     /* Code Body                                                      */
  360.     /*----------------------------------------------------------------*/
  361.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_highlight_copy_all.>n", __FILE__,
  362.                          __LINE__));
  363.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  364.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  365.     SetLeftSoftkeyFunction(mmi_phb_entry_copy_all, KEY_EVENT_UP);
  366.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  367.     SetKeyHandler(mmi_phb_entry_copy_all, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  368.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  369. }
  370. /*****************************************************************************
  371.  * FUNCTION
  372.  *  mmi_phb_highlight_copy_all_from_sim
  373.  * DESCRIPTION
  374.  *  Highlight handler for "From SIM" in Copy All menu
  375.  * PARAMETERS
  376.  *  void
  377.  * RETURNS
  378.  *  void
  379.  *****************************************************************************/
  380. void mmi_phb_highlight_copy_all_from_sim(void)
  381. {
  382.     /*----------------------------------------------------------------*/
  383.     /* Local Variables                                                */
  384.     /*----------------------------------------------------------------*/
  385.     /*----------------------------------------------------------------*/
  386.     /* Code Body                                                      */
  387.     /*----------------------------------------------------------------*/
  388.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  389.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  390.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  391.     g_phb_cntx.selected_storage = MMI_SIM;
  392.     if (g_phb_cntx.sim_used)
  393.     {
  394.         ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  395.         SetLeftSoftkeyFunction(mmi_phb_entry_op_copy_all_confirm, KEY_EVENT_UP);
  396.     }
  397.     else
  398.     {
  399.         ChangeLeftSoftkey(0, 0);
  400.     }
  401. }
  402. /*****************************************************************************
  403.  * FUNCTION
  404.  *  mmi_phb_highlight_copy_all_from_phone
  405.  * DESCRIPTION
  406.  *  Highlight handler for "From Phone" in Copy All menu
  407.  * PARAMETERS
  408.  *  void
  409.  * RETURNS
  410.  *  void
  411.  *****************************************************************************/
  412. void mmi_phb_highlight_copy_all_from_phone(void)
  413. {
  414.     /*----------------------------------------------------------------*/
  415.     /* Local Variables                                                */
  416.     /*----------------------------------------------------------------*/
  417.     /*----------------------------------------------------------------*/
  418.     /* Code Body                                                      */
  419.     /*----------------------------------------------------------------*/
  420.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  421.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  422.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  423.     g_phb_cntx.selected_storage = MMI_NVRAM;
  424.     if (g_phb_cntx.phone_used)
  425.     {
  426.         ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  427.         SetLeftSoftkeyFunction(mmi_phb_entry_op_copy_all_confirm, KEY_EVENT_UP);
  428.     }
  429.     else
  430.     {
  431.         ChangeLeftSoftkey(0, 0);
  432.     }
  433. }
  434. /*****************************************************************************
  435.  * FUNCTION
  436.  *  mmi_phb_hint_copy_all_from_sim
  437.  * DESCRIPTION
  438.  *  Hint handler for "From SIM" in Copy All menu
  439.  * PARAMETERS
  440.  *  index       [IN]        
  441.  * RETURNS
  442.  *  void
  443.  *****************************************************************************/
  444. void mmi_phb_hint_copy_all_from_sim(U16 index)
  445. {
  446.     /*----------------------------------------------------------------*/
  447.     /* Local Variables                                                */
  448.     /*----------------------------------------------------------------*/
  449.     S8 simStatus[40];
  450.     /*----------------------------------------------------------------*/
  451.     /* Code Body                                                      */
  452.     /*----------------------------------------------------------------*/
  453.     memset((S8*) hintData[index], 0, sizeof(hintData[index]));
  454.     mmi_phb_memory_status_get_sim(simStatus);
  455.     pfnUnicodeStrcpy((S8*) hintData[index], simStatus);
  456. }
  457. /*****************************************************************************
  458.  * FUNCTION
  459.  *  mmi_phb_hint_copy_all_from_phone
  460.  * DESCRIPTION
  461.  *  Hint handler for "From Phone" in Copy All menu
  462.  * PARAMETERS
  463.  *  index       [IN]        
  464.  * RETURNS
  465.  *  void
  466.  *****************************************************************************/
  467. void mmi_phb_hint_copy_all_from_phone(U16 index)
  468. {
  469.     /*----------------------------------------------------------------*/
  470.     /* Local Variables                                                */
  471.     /*----------------------------------------------------------------*/
  472.     S8 phoneStatus[40];
  473.     /*----------------------------------------------------------------*/
  474.     /* Code Body                                                      */
  475.     /*----------------------------------------------------------------*/
  476.     memset((S8*) hintData[index], 0, sizeof(hintData[index]));
  477.     mmi_phb_memory_status_get_phone(phoneStatus);
  478.     pfnUnicodeStrcpy((S8*) hintData[index], phoneStatus);
  479. }
  480. /*****************************************************************************
  481.  * FUNCTION
  482.  *  mmi_phb_entry_copy_all
  483.  * DESCRIPTION
  484.  *  Draws the Copy All menu.
  485.  * PARAMETERS
  486.  *  void
  487.  * RETURNS
  488.  *  void
  489.  *****************************************************************************/
  490. void mmi_phb_entry_copy_all(void)
  491. {
  492.     /*----------------------------------------------------------------*/
  493.     /* Local Variables                                                */
  494.     /*----------------------------------------------------------------*/
  495.     U8 *guiBuffer;
  496.     U16 nStrItemList[2];
  497.     U16 nImgIltemList[2];
  498.     U8 *nHintList[2];
  499.     U16 nNumofItem;
  500.     U8 hilitedStorage;
  501.     U8 hilight_sim, highlight_phone;
  502.     /*----------------------------------------------------------------*/
  503.     /* Code Body                                                      */
  504.     /*----------------------------------------------------------------*/
  505.     hilight_sim = GetIndexOfStringId(MITEM104_PBOOK_COPY_ALL, MITEM_PBOOK_COPY_ALL_SIM);
  506.     highlight_phone = GetIndexOfStringId(MITEM104_PBOOK_COPY_ALL, MITEM_PBOOK_COPY_ALL_PHONE);
  507.     if (g_phb_cntx.prefer_storage == MMI_SIM)
  508.     {
  509.         if ((g_phb_cntx.sim_used > 0) || (g_phb_cntx.phone_used == 0))
  510.         {
  511.             hilitedStorage = hilight_sim;
  512.         }
  513.         else
  514.         {
  515.             hilitedStorage = highlight_phone;
  516.         }
  517.     }
  518.     else
  519.     {
  520.         if ((g_phb_cntx.phone_used > 0) || (g_phb_cntx.sim_used == 0))
  521.         {
  522.             hilitedStorage = highlight_phone;
  523.         }
  524.         else
  525.         {
  526.             hilitedStorage = hilight_sim;
  527.         }
  528.     }
  529.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_entry_copy_all.>n", __FILE__, __LINE__));
  530.     g_phb_mass_op_abort = FALSE;
  531.     if (!g_phb_cntx.phb_ready || g_phb_cntx.processing)
  532.     {
  533.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  534.     }
  535. #ifdef __MMI_PHB_USIM_FIELD__
  536.     else if (g_phb_cntx.is_usim && g_phb_cntx.usim_ready_stage != MMI_PHB_USIM_READY)
  537.     {
  538.         mmi_phb_entry_not_ready(STR_ID_PHB_PROCESSING_USIM);
  539.     }
  540. #endif /* __MMI_PHB_USIM_FIELD__ */
  541. #ifdef __SYNCML_SUPPORT__
  542.     else if (mmi_syncml_is_phb_sync_now())
  543.     {
  544.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  545.     }
  546. #endif /* __SYNCML_SUPPORT__ */
  547.     else if (PhoneBookEntryCount)
  548.     {
  549.         EntryNewScreen(SCR_COPY_ALL_MENU, mmi_phb_exit_copy_all, mmi_phb_entry_copy_all, NULL);
  550.         guiBuffer = GetCurrGuiBuffer(SCR_COPY_ALL_MENU);
  551.         nNumofItem = GetNumOfChild(MITEM104_PBOOK_COPY_ALL);
  552.         GetSequenceStringIds(MITEM104_PBOOK_COPY_ALL, nStrItemList);
  553.         GetSequenceImageIds(MITEM104_PBOOK_COPY_ALL, nImgIltemList);
  554.         SetParentHandler(MITEM104_PBOOK_COPY_ALL);
  555.         RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  556.         ConstructHintsList(MITEM104_PBOOK_COPY_ALL, nHintList);
  557.         ShowCategory52Screen(
  558.             STR_SCR_COPY_ALL_MENU_CAPTION,
  559.             IMG_SCR_PBOOK_CAPTION,
  560.             STR_GLOBAL_OK,
  561.             IMG_GLOBAL_OK,
  562.             STR_GLOBAL_BACK,
  563.             IMG_GLOBAL_BACK,
  564.             nNumofItem,
  565.             nStrItemList,
  566.             nImgIltemList,
  567.             nHintList,
  568.             0,
  569.             hilitedStorage,
  570.             guiBuffer);
  571.     }
  572.     else
  573.     {
  574.         DisplayPopup(
  575.             (PU8) GetString(STR_NO_ENTRIES_MESSAGE),
  576.             IMG_GLOBAL_EMPTY,
  577.             TRUE,
  578.             PHB_NOTIFY_TIMEOUT,
  579.             EMPTY_LIST_TONE);
  580.     }
  581. }
  582. /*****************************************************************************
  583.  * FUNCTION
  584.  *  mmi_phb_exit_copy_all
  585.  * DESCRIPTION
  586.  *  Exit function for mmi_phb_entry_copy_all()
  587.  * PARAMETERS
  588.  *  void
  589.  * RETURNS
  590.  *  void
  591.  *****************************************************************************/
  592. void mmi_phb_exit_copy_all(void)
  593. {
  594.     /*----------------------------------------------------------------*/
  595.     /* Local Variables                                                */
  596.     /*----------------------------------------------------------------*/
  597.     /*----------------------------------------------------------------*/
  598.     /* Code Body                                                      */
  599.     /*----------------------------------------------------------------*/
  600.     g_phb_cntx.end_scr_id = SCR_COPY_ALL_MENU;
  601. }
  602. /*****************************************************************************
  603.  * FUNCTION
  604.  *  mmi_phb_entry_op_copy_all_confirm
  605.  * DESCRIPTION
  606.  *  confirm copy all from sim or phone
  607.  * PARAMETERS
  608.  *  void
  609.  * RETURNS
  610.  *  void
  611.  *****************************************************************************/
  612. void mmi_phb_entry_op_copy_all_confirm(void)
  613. {
  614.     /*----------------------------------------------------------------*/
  615.     /* Local Variables                                                */
  616.     /*----------------------------------------------------------------*/
  617.     UI_string_type message;
  618.     /*----------------------------------------------------------------*/
  619.     /* Code Body                                                      */
  620.     /*----------------------------------------------------------------*/
  621.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_op_copy_all_confirm.>n", __FILE__,
  622.                          __LINE__));
  623.     if (g_phb_cntx.selected_storage == MMI_SIM)
  624.     {
  625.         message = get_string(STR_COPY_ALL_SIM); /* STR_OVERWRITE_TARGET; */
  626.     }
  627.     else
  628.     {
  629.         message = get_string(STR_COPY_ALL_PHONE);   /* STR_OVERWRITE_TARGET; */
  630.     }
  631.     DisplayConfirm(
  632.         STR_GLOBAL_YES,
  633.         IMG_GLOBAL_YES,
  634.         STR_GLOBAL_NO,
  635.         IMG_GLOBAL_NO,
  636.         message,
  637.         IMG_GLOBAL_QUESTION,
  638.         WARNING_TONE);
  639.     SetLeftSoftkeyFunction(mmi_phb_op_copy_all_pre_req, KEY_EVENT_UP);
  640.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  641. }
  642. /*****************************************************************************
  643.  * FUNCTION
  644.  *  mmi_phb_op_copy_all_pre_req
  645.  * DESCRIPTION
  646.  *  pre-entry function of copy all. check storage first.
  647.  * PARAMETERS
  648.  *  void
  649.  * RETURNS
  650.  *  void
  651.  *****************************************************************************/
  652. void mmi_phb_op_copy_all_pre_req(void)
  653. {
  654.     /*----------------------------------------------------------------*/
  655.     /* Local Variables                                                */
  656.     /*----------------------------------------------------------------*/
  657.     /*----------------------------------------------------------------*/
  658.     /* Code Body                                                      */
  659.     /*----------------------------------------------------------------*/
  660.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_op_copy_all_pre_req.>n", __FILE__,
  661.                          __LINE__));
  662.     if ((g_phb_cntx.selected_storage == MMI_NVRAM) && (g_phb_cntx.sim_used == g_phb_cntx.sim_total))
  663.     {
  664.         DisplayPopup((PU8) GetString(STR_SIM_FULL_MSG), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  665.         DeleteNScrId(SCR_COPY_ALL_MENU);
  666.     }
  667.     else if ((g_phb_cntx.selected_storage == MMI_SIM) && (g_phb_cntx.phone_used == g_phb_cntx.phone_total))
  668.     {
  669.         DisplayPopup((PU8) GetString(STR_PHONE_FULL_MSG), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  670.         DeleteNScrId(SCR_COPY_ALL_MENU);
  671.     }
  672.     else    /* Have free space, begin to copy all */
  673.     {
  674.         g_phb_mass_op_index = 0;
  675.         g_phb_mass_op_count = 0;
  676.         g_phb_cntx.processing = TRUE;
  677.         g_phb_cntx.copy_all = TRUE; /* copy all flag for distinguish copy all or delete all if sim refresh */
  678.         mmi_phb_show_mass_processing(STR_PHB_COPYING, IMG_COPIED);
  679.         DeleteNScrId(SCR_COPY_ALL_MENU);
  680.     #ifdef __MMI_PHB_USIM_FIELD__
  681.         if (g_phb_cntx.is_usim && g_phb_cntx.selected_storage == MMI_NVRAM)
  682.         {
  683.             mmi_phb_op_copy_all_to_usim_one_after_one_req();
  684.         }
  685.         else
  686.     #endif /* __MMI_PHB_USIM_FIELD__ */ 
  687.             mmi_phb_op_copy_all_one_after_one_req(g_phb_cntx.selected_storage);
  688.     }
  689. }
  690. /*****************************************************************************
  691.  * FUNCTION
  692.  *  mmi_phb_op_copy_all_one_after_one_req
  693.  * DESCRIPTION
  694.  *  Copy all one entry after one.
  695.  * PARAMETERS
  696.  *  from_storage        [IN]        
  697.  * RETURNS
  698.  *  void
  699.  *****************************************************************************/
  700. void mmi_phb_op_copy_all_one_after_one_req(U8 from_storage)
  701. {
  702.     /*----------------------------------------------------------------*/
  703.     /* Local Variables                                                */
  704.     /*----------------------------------------------------------------*/
  705.     MSG_PHB_SET_ENRTY_REQ_STRUCT *myMsgPtr;
  706.     MYQUEUE Message;
  707.     U16 store_index;
  708.     /*----------------------------------------------------------------*/
  709.     /* Code Body                                                      */
  710.     /*----------------------------------------------------------------*/
  711.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_op_copy_all_one_after_one_req.>n",
  712.                          __FILE__, __LINE__));
  713.     if (from_storage == MMI_SIM)
  714.         while ((g_phb_name_index[g_phb_mass_op_index] < MAX_PB_PHONE_ENTRIES) && (g_phb_mass_op_index < PhoneBookEntryCount))   /* Not in SIM */
  715.         {
  716.             g_phb_mass_op_index++;
  717.         }
  718.     else
  719.         while ((g_phb_name_index[g_phb_mass_op_index] >= MAX_PB_PHONE_ENTRIES) && (g_phb_mass_op_index < PhoneBookEntryCount))  /* Not in NVRAM */
  720.         {
  721.             g_phb_mass_op_index++;
  722.         }
  723.     if (g_phb_mass_op_index >= PhoneBookEntryCount)
  724.     {
  725.         mmi_phb_op_copy_all_done();
  726.         return;
  727.     }
  728.     store_index = g_phb_name_index[g_phb_mass_op_index];
  729. #if defined(__MMI_PHB_PINYIN_SORT__)    /* Make Pinyin cache for later sorting. */
  730.     mmi_phb_util_make_pinyin_cache(store_index);
  731. #endif 
  732.     myMsgPtr = (MSG_PHB_SET_ENRTY_REQ_STRUCT*) OslConstructDataPtr(sizeof(MSG_PHB_SET_ENRTY_REQ_STRUCT));
  733.     myMsgPtr->type = MMI_PHB_PHONEBOOK;
  734.     myMsgPtr->no_data = 1;
  735.     myMsgPtr->list.storage = (from_storage == MMI_SIM) ? MMI_NVRAM : MMI_SIM;
  736.     myMsgPtr->list.index = 0xFFFF;
  737.     myMsgPtr->list.record_index = 0xFFFF;
  738.     mmi_phb_op_set_entry_prepare_name_number_by_index(&myMsgPtr->list, store_index);
  739.     Message.oslSrcId = MOD_MMI;
  740.     Message.oslDestId = MOD_L4C;
  741.     Message.oslMsgId = PRT_PHB_SET_ENTRY_REQ;
  742.     Message.oslDataPtr = (oslParaType*) myMsgPtr;
  743.     Message.oslPeerBuffPtr = NULL;
  744.     OslMsgSendExtQueue(&Message);
  745.     SetProtocolEventHandler(mmi_phb_op_copy_all_one_after_one_rsp, PRT_PHB_SET_ENTRY_RSP);
  746. }
  747. /*****************************************************************************
  748.  * FUNCTION
  749.  *  mmi_phb_op_copy_all_one_after_one_rsp
  750.  * DESCRIPTION
  751.  *  copy all one entry set response.
  752.  * PARAMETERS
  753.  *  info        [?]     
  754.  * RETURNS
  755.  *  void
  756.  *****************************************************************************/
  757. void mmi_phb_op_copy_all_one_after_one_rsp(void *info)
  758. {
  759.     /*----------------------------------------------------------------*/
  760.     /* Local Variables                                                */
  761.     /*----------------------------------------------------------------*/
  762.     MSG_PHB_SET_ENRTY_RSP_STRUCT *localPtr;
  763.     S16 pError;
  764.     U8 copy_from, copy_to = 0;
  765.     U16 store_index;
  766.     U32 temp;
  767.     /*----------------------------------------------------------------*/
  768.     /* Code Body                                                      */
  769.     /*----------------------------------------------------------------*/
  770.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_op_copy_all_one_after_one_rsp.>n",
  771.                          __FILE__, __LINE__));
  772.     localPtr = (MSG_PHB_SET_ENRTY_RSP_STRUCT*) info;
  773.     if (localPtr->result.flag == 0 /* OK */ )
  774.     {
  775.         if (localPtr->list[0].storage == MMI_SIM)
  776.         {
  777.             g_phb_cntx.sim_used++;
  778.             store_index = localPtr->list[0].record_index + MAX_PB_PHONE_ENTRIES - 1;    /* Storage Location in array. */
  779.             copy_to = MMI_SIM;
  780.             copy_from = MMI_NVRAM;
  781.         }
  782.         else
  783.         {
  784.             g_phb_cntx.phone_used++;
  785.             store_index = localPtr->list[0].record_index - 1;   /* Storage Location in array. */
  786.             copy_to = MMI_NVRAM;
  787.             copy_from = MMI_SIM;
  788.             #ifdef __SYNCML_SUPPORT__
  789.                 mmi_syncml_phb_data_changed_notification(SYNCML_RECORD_ADD, store_index);
  790.             #endif
  791.         }
  792.         if (copy_to == MMI_NVRAM)
  793.         {
  794.             /* Clear Optional Field */
  795.         #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
  796.         #ifdef __MMI_PHB_USIM_FIELD__
  797.             U16 origin_index = g_phb_name_index[g_phb_mass_op_index];
  798.             mmi_phb_op_set_option_data_by_usim_index(origin_index, &PhoneBookOptionalFields);
  799.         #else /* __MMI_PHB_USIM_FIELD__ */ 
  800.             memset(&PhoneBookOptionalFields, 0, sizeof(PhoneBookOptionalFields));
  801.         #endif /* __MMI_PHB_USIM_FIELD__ */ 
  802.             WriteRecord(
  803.                 NVRAM_EF_PHB_FIELDS_LID,
  804.                 (U16) (store_index + 1),
  805.                 (void*)&PhoneBookOptionalFields,
  806.                 OPTIONAL_FIELDS_RECORD_SIZE,
  807.                 &pError);
  808.         #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */ 
  809.             /* Clear Optional Id */
  810.             mmi_phb_clear_optional_ids(store_index);
  811.             /* Clear video field. */
  812.         #if defined(__MMI_INCOMING_CALL_VIDEO__)
  813.             mmi_phb_video_delete_by_index(store_index);
  814.         #endif 
  815.             /* Clear birthday field */
  816.         #if defined(__MMI_PHB_BIRTHDAY_FIELD__)
  817.             mmi_phb_bday_delete_field(store_index);
  818.         #endif 
  819.         #if defined(__MMI_PHB_INFO_FIELD__)
  820.             mmi_phb_info_delete_field(store_index);
  821.         #endif 
  822.         }
  823.     #if defined(__MMI_PHB_CALLERGROUP_IN_SIM__)     /* Associate caller group in SIM card entry */
  824.         mmi_phb_copy_optional_ids(store_index, g_phb_name_index[g_phb_mass_op_index]);
  825.         if (copy_to == MMI_SIM)
  826.         {
  827.             mmi_phb_clear_optional_ids_for_sim(store_index);
  828.         }
  829.     #endif /* defined(__MMI_PHB_CALLERGROUP_IN_SIM__) */ 
  830.         /* Populate Number Field */
  831.         temp = mmi_phb_util_convert_number_to_int(localPtr->list[0].tel.number);
  832.         if (temp < INVALID_NUMBER)
  833.         {
  834.             LookUpTable[g_phb_cntx.lookup_table_count].store_index = store_index;
  835.             LookUpTable[g_phb_cntx.lookup_table_count++].number = temp;
  836.         }
  837.         /* Add result to Phonebook Storage */
  838.         mmi_phb_op_set_entry_rsp_name_number(&localPtr->list[0], store_index);
  839.         /* Update field flag */
  840.     #ifdef __MMI_PHB_USIM_FIELD__
  841.         if (g_phb_cntx.is_usim)
  842.         {
  843.             mmi_phb_op_update_field_flag(
  844.                 store_index,
  845.                 (S8*) localPtr->list[0].tel.number,
  846.                 (S8*) PhoneBookOptionalFields.homeNumber,
  847.                 (S8*) PhoneBookOptionalFields.officeNumber,
  848.                 (S8*) PhoneBookOptionalFields.faxNumber,
  849.                 (S8*) PhoneBookOptionalFields.emailAddress,
  850.                 TRUE);
  851.             mmi_phb_op_increase_lookup_table(
  852.                 store_index,
  853.                 NULL,
  854.                 (S8*) PhoneBookOptionalFields.faxNumber,
  855.                 (S8*) PhoneBookOptionalFields.homeNumber,
  856.                 (S8*) PhoneBookOptionalFields.officeNumber);
  857.         }
  858.         else
  859.     #endif /* __MMI_PHB_USIM_FIELD__ */ 
  860.             mmi_phb_op_update_field_flag(
  861.                 store_index,
  862.                 (S8*) localPtr->list[0].tel.number,
  863.                 NULL,
  864.                 NULL,
  865.                 NULL,
  866.                 NULL,
  867.                 TRUE);
  868.     #if defined(__MMI_PHB_PINYIN_SORT__)    /* Make Pinyin cache for later sorting. */
  869.         mmi_phb_util_make_pinyin_cache(store_index);
  870.     #endif 
  871.         /* Append new entry in the end of sorted list. Sorting when copy all done. */
  872.         g_phb_name_index[PhoneBookEntryCount] = store_index;
  873.         PhoneBookEntryCount++;
  874.         g_phb_mass_op_count++;
  875.         /* Insert email to email mapping table, not like name field, it should sort here. */
  876.     #if defined(__MMI_PHB_EMAIL_SORT__)     /* USIM won't go this way */
  877.         if ((copy_to == MMI_NVRAM) && (g_phb_email_sorted == 1))
  878.         {
  879.             mmi_phb_sort_email_insert_index(store_index);
  880.         }
  881.     #endif /* defined(__MMI_PHB_EMAIL_SORT__) */ 
  882.         if (g_phb_mass_op_abort)
  883.         {
  884.             g_phb_mass_op_success = FALSE;
  885.             mmi_phb_op_copy_all_done();
  886.         }
  887.         else
  888.         {
  889.             if ((copy_to == MMI_SIM && g_phb_mass_op_count < g_phb_cntx.phone_used) ||
  890.                 (copy_to == MMI_NVRAM && g_phb_mass_op_count < g_phb_cntx.sim_used))
  891.             {
  892.                 ++g_phb_mass_op_index;
  893.                 mmi_phb_op_copy_all_one_after_one_req(copy_from);
  894.             }
  895.             else
  896.             {
  897.                 mmi_phb_op_copy_all_done();
  898.             }
  899.         }
  900.     }
  901.     else
  902.     {
  903.         g_phb_mass_op_success = FALSE;
  904.         copy_from = (g_phb_name_index[g_phb_mass_op_index] >= MAX_PB_PHONE_ENTRIES) ? MMI_SIM : MMI_NVRAM;
  905.         /* Not copy fail due to capacity full. */
  906.         if ((localPtr->result.cause != MMI_PHB_CAUSE_CAPACITY_EXCEEDED) &&
  907.             ((copy_from == MMI_NVRAM && g_phb_mass_op_count < g_phb_cntx.phone_used) ||
  908.              (copy_from == MMI_SIM && g_phb_mass_op_count < g_phb_cntx.sim_used)))
  909.         {
  910.             g_phb_mass_op_index++;
  911.             mmi_phb_op_copy_all_one_after_one_req(copy_from);
  912.         }
  913.         else
  914.         {
  915.             mmi_phb_op_copy_all_done();
  916.         }
  917.     }
  918. }
  919. /*****************************************************************************
  920.  * FUNCTION
  921.  *  mmi_phb_op_copy_all_done
  922.  * DESCRIPTION
  923.  *  Display copy result
  924.  * PARAMETERS
  925.  *  void
  926.  * RETURNS
  927.  *  void
  928.  *****************************************************************************/
  929. void mmi_phb_op_copy_all_done(void)
  930. {
  931.     /*----------------------------------------------------------------*/
  932.     /* Local Variables                                                */
  933.     /*----------------------------------------------------------------*/
  934.     S8 outBuf[100], count[10];
  935.     /*----------------------------------------------------------------*/
  936.     /* Code Body                                                      */
  937.     /*----------------------------------------------------------------*/
  938.     g_phb_cntx.processing = FALSE;
  939.     g_phb_cntx.copy_all = FALSE;
  940.     TurnOnBacklight(1); /* Turn On Back Light When done */
  941.     DeleteScreenIfPresent(SCR_IN_PROGRESS_PHB);
  942.     /* Sort name index */
  943.     mmi_phb_sort_build_name_index();
  944.     /* Sort Number index */
  945.     mmi_phb_lookup_table_sort();
  946.     g_phb_cntx.refresh_list = MMI_PHB_ENTRY_REFRESH;
  947.     if (g_phb_mass_op_success)
  948.     {
  949.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, TRUE, PHB_NOTIFY_TIMEOUT, SUCCESS_TONE);
  950.     }
  951.     else if (gSecuritySetupContext.FdlStatus)   /* For FDN on Message */
  952.     {
  953.         DisplayPopup((PU8) GetString(STR_FDL_IS_ON), IMG_GLOBAL_UNFINISHED, TRUE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  954.         g_phb_mass_op_success = TRUE;
  955.     }
  956.     else    /* !g_phb_mass_op_success */
  957.     {
  958.         g_phb_mass_op_success = TRUE;
  959.         sprintf(count, "%d ", g_phb_mass_op_count);
  960.         AnsiiToUnicodeString(outBuf, count);
  961.         pfnUnicodeStrcat(outBuf, GetString(STR_ENTRIES_COPIED));
  962.         DisplayPopup((PU8) outBuf, IMG_GLOBAL_UNFINISHED, TRUE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  963.     }
  964.     /* Solve Copying Screen Hang Problem */
  965.     DeleteScreenIfPresent(SCR_COPY_ALL_PROGRESS);
  966.     /* add central command for vrsi. */
  967. #if defined(__MMI_VRSI__)
  968.     mmi_vrsi_init_central_abort();
  969.     /* mmi_vrsi_init_central_add_all(); */
  970. #endif /* defined(__MMI_VRSI__) */ 
  971. }
  972. #define MMI_PHB_OP_DELETE_ALL
  973. /*----------------------------------------------  Begin of PhoneBook Delete ALL -----------------------------------------*/
  974. /*****************************************************************************
  975.  * FUNCTION
  976.  *  mmi_phb_highlight_delete_all
  977.  * DESCRIPTION
  978.  *  Highlight handler for "Delete All" in PHb main menu
  979.  * PARAMETERS
  980.  *  void
  981.  * RETURNS
  982.  *  void
  983.  *****************************************************************************/
  984. void mmi_phb_highlight_delete_all(void)
  985. {
  986.     /*----------------------------------------------------------------*/
  987.     /* Local Variables                                                */
  988.     /*----------------------------------------------------------------*/
  989.     /*----------------------------------------------------------------*/
  990.     /* Code Body                                                      */
  991.     /*----------------------------------------------------------------*/
  992.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_highlight_delete_all.>n", __FILE__,
  993.                          __LINE__));
  994.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  995.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  996.     SetLeftSoftkeyFunction(mmi_phb_entry_delete_all, KEY_EVENT_UP);
  997.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  998.     SetKeyHandler(mmi_phb_entry_delete_all, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  999.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1000. }
  1001. /*****************************************************************************
  1002.  * FUNCTION
  1003.  *  mmi_phb_highlight_delete_all_from_sim
  1004.  * DESCRIPTION
  1005.  *  Highlight handler for "From SIM" in Delete All menu
  1006.  * PARAMETERS
  1007.  *  void
  1008.  * RETURNS
  1009.  *  void
  1010.  *****************************************************************************/
  1011. void mmi_phb_highlight_delete_all_from_sim(void)
  1012. {
  1013.     /*----------------------------------------------------------------*/
  1014.     /* Local Variables                                                */
  1015.     /*----------------------------------------------------------------*/
  1016.     /*----------------------------------------------------------------*/
  1017.     /* Code Body                                                      */
  1018.     /*----------------------------------------------------------------*/
  1019.     g_phb_cntx.selected_storage = MMI_SIM;
  1020.     if (g_phb_cntx.sim_used)
  1021.     {
  1022.         ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  1023.     #if defined(__MMI_PHB_DELETE_ALL_CHECK_PHONE_LOCK__) && defined(MMI_ON_HARDWARE_P)
  1024.         SetLeftSoftkeyFunction(mmi_phb_entry_delete_all_phone_lock, KEY_EVENT_UP);
  1025.         SetKeyHandler(mmi_phb_entry_delete_all_phone_lock, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1026.     #else /* defined(__MMI_PHB_DELETE_ALL_CHECK_PHONE_LOCK__) && defined(MMI_ON_HARDWARE_P) */ 
  1027.         SetLeftSoftkeyFunction(mmi_phb_entry_delete_all_confirm, KEY_EVENT_UP);
  1028.         ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1029.     #endif /* defined(__MMI_PHB_DELETE_ALL_CHECK_PHONE_LOCK__) && defined(MMI_ON_HARDWARE_P) */ 
  1030.     }
  1031.     else
  1032.     {
  1033.         ChangeLeftSoftkey(0, 0);
  1034.     }
  1035. }
  1036. /*****************************************************************************
  1037.  * FUNCTION
  1038.  *  mmi_phb_highlight_delete_all_from_phone
  1039.  * DESCRIPTION
  1040.  *  Highlight handler for "From Phone" in Delete All menu
  1041.  * PARAMETERS
  1042.  *  void
  1043.  * RETURNS
  1044.  *  void
  1045.  *****************************************************************************/
  1046. void mmi_phb_highlight_delete_all_from_phone(void)
  1047. {
  1048.     /*----------------------------------------------------------------*/
  1049.     /* Local Variables                                                */
  1050.     /*----------------------------------------------------------------*/
  1051.     /*----------------------------------------------------------------*/
  1052.     /* Code Body                                                      */
  1053.     /*----------------------------------------------------------------*/
  1054.     g_phb_cntx.selected_storage = MMI_NVRAM;
  1055.     if (g_phb_cntx.phone_used)
  1056.     {
  1057.         ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  1058.     #if defined(__MMI_PHB_DELETE_ALL_CHECK_PHONE_LOCK__) && defined(MMI_ON_HARDWARE_P)
  1059.         SetLeftSoftkeyFunction(mmi_phb_entry_delete_all_phone_lock, KEY_EVENT_UP);
  1060.         SetKeyHandler(mmi_phb_entry_delete_all_phone_lock, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1061.     #else /* defined(__MMI_PHB_DELETE_ALL_CHECK_PHONE_LOCK__) && defined(MMI_ON_HARDWARE_P) */ 
  1062.         SetLeftSoftkeyFunction(mmi_phb_entry_delete_all_confirm, KEY_EVENT_UP);
  1063.         ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1064.     #endif /* defined(__MMI_PHB_DELETE_ALL_CHECK_PHONE_LOCK__) && defined(MMI_ON_HARDWARE_P) */ 
  1065.     }
  1066.     else
  1067.     {
  1068.         ChangeLeftSoftkey(0, 0);
  1069.     }
  1070. }
  1071. /*****************************************************************************
  1072.  * FUNCTION
  1073.  *  mmi_phb_hint_delete_all_from_sim
  1074.  * DESCRIPTION
  1075.  *  Hint handler for "From SIM" in Delete All menu
  1076.  * PARAMETERS
  1077.  *  index       [IN]        
  1078.  * RETURNS
  1079.  *  void
  1080.  *****************************************************************************/
  1081. void mmi_phb_hint_delete_all_from_sim(U16 index)
  1082. {
  1083.     /*----------------------------------------------------------------*/
  1084.     /* Local Variables                                                */
  1085.     /*----------------------------------------------------------------*/
  1086.     S8 simStatus[40];
  1087.     /*----------------------------------------------------------------*/
  1088.     /* Code Body                                                      */
  1089.     /*----------------------------------------------------------------*/
  1090.     memset((S8*) hintData[index], 0, sizeof(hintData[index]));
  1091.     mmi_phb_memory_status_get_sim(simStatus);
  1092.     pfnUnicodeStrcpy((S8*) hintData[index], simStatus);
  1093. }
  1094. /*****************************************************************************
  1095.  * FUNCTION
  1096.  *  mmi_phb_hint_delete_all_from_phone
  1097.  * DESCRIPTION
  1098.  *  Hint handler for "From Phone" in Delete All menu
  1099.  * PARAMETERS
  1100.  *  index       [IN]        
  1101.  * RETURNS
  1102.  *  void
  1103.  *****************************************************************************/
  1104. void mmi_phb_hint_delete_all_from_phone(U16 index)
  1105. {
  1106.     /*----------------------------------------------------------------*/
  1107.     /* Local Variables                                                */
  1108.     /*----------------------------------------------------------------*/
  1109.     S8 phoneStatus[40];
  1110.     /*----------------------------------------------------------------*/
  1111.     /* Code Body                                                      */
  1112.     /*----------------------------------------------------------------*/
  1113.     memset((S8*) hintData[index], 0, sizeof(hintData[index]));
  1114.     mmi_phb_memory_status_get_phone(phoneStatus);
  1115.     pfnUnicodeStrcpy((S8*) hintData[index], phoneStatus);
  1116. }
  1117. /*****************************************************************************
  1118.  * FUNCTION
  1119.  *  mmi_phb_highlight_delete_all_one_by_one
  1120.  * DESCRIPTION
  1121.  *  Highlight handler for "One By One" in Delete All menu
  1122.  * PARAMETERS
  1123.  *  void
  1124.  * RETURNS
  1125.  *  void
  1126.  *****************************************************************************/
  1127. void mmi_phb_highlight_delete_all_one_by_one(void)
  1128. {
  1129.     /*----------------------------------------------------------------*/
  1130.     /* Local Variables                                                */
  1131.     /*----------------------------------------------------------------*/
  1132.     /*----------------------------------------------------------------*/
  1133.     /* Code Body                                                      */
  1134.     /*----------------------------------------------------------------*/
  1135.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  1136.     SetLeftSoftkeyFunction(mmi_phb_list_pre_delete_one_by_one, KEY_EVENT_UP);
  1137.     SetKeyHandler(mmi_phb_list_pre_delete_one_by_one, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1138. }
  1139. /*****************************************************************************
  1140.  * FUNCTION
  1141.  *  mmi_phb_entry_delete_all
  1142.  * DESCRIPTION
  1143.  *  Draws the Delete All menu
  1144.  * PARAMETERS
  1145.  *  void
  1146.  * RETURNS
  1147.  *  void
  1148.  *****************************************************************************/
  1149. void mmi_phb_entry_delete_all(void)
  1150. {
  1151.     /*----------------------------------------------------------------*/
  1152.     /* Local Variables                                                */
  1153.     /*----------------------------------------------------------------*/
  1154.     U8 *guiBuffer;
  1155.     U16 nStrItemList[3];
  1156.     U16 nImgIltemList[3];
  1157.     U8 *nHintList[3];
  1158.     U16 nNumofItem;
  1159.     U8 hilitedStorage;
  1160.     U8 hilight_sim, highlight_phone;
  1161.     /*----------------------------------------------------------------*/
  1162.     /* Code Body                                                      */
  1163.     /*----------------------------------------------------------------*/
  1164.     hilight_sim = GetIndexOfStringId(MITEM103_PBOOK_DELETE_ALL, MITEM_PBOOK_DELETE_ALL_SIM);
  1165.     highlight_phone = GetIndexOfStringId(MITEM103_PBOOK_DELETE_ALL, MITEM_PBOOK_DELETE_ALL_PHONE);
  1166.     if (g_phb_cntx.prefer_storage == MMI_SIM)
  1167.     {
  1168.         if (g_phb_cntx.sim_used > 0 || g_phb_cntx.phone_used == 0)
  1169.         {
  1170.             hilitedStorage = hilight_sim;
  1171.         }
  1172.         else
  1173.         {
  1174.             hilitedStorage = highlight_phone;
  1175.         }
  1176.     }
  1177.     else
  1178.     {
  1179.         if (g_phb_cntx.phone_used > 0 || g_phb_cntx.sim_used == 0)
  1180.         {
  1181.             hilitedStorage = highlight_phone;
  1182.         }
  1183.         else
  1184.         {
  1185.             hilitedStorage = hilight_sim;
  1186.         }
  1187.     }
  1188.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_entry_delete_all.>n", __FILE__,
  1189.                          __LINE__));
  1190.     if (!g_phb_cntx.phb_ready || g_phb_cntx.processing)
  1191.     {
  1192.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1193.     }
  1194. #ifdef __MMI_PHB_USIM_FIELD__
  1195.     else if (g_phb_cntx.is_usim && g_phb_cntx.usim_ready_stage != MMI_PHB_USIM_READY)
  1196.     {
  1197.         mmi_phb_entry_not_ready(STR_ID_PHB_PROCESSING_USIM);
  1198.     }
  1199. #endif /* __MMI_PHB_USIM_FIELD__ */
  1200. #ifdef __SYNCML_SUPPORT__
  1201.     else if (mmi_syncml_is_phb_sync_now())
  1202.     {
  1203.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  1204.     }
  1205. #endif /* __SYNCML_SUPPORT__ */
  1206.     else if (PhoneBookEntryCount)
  1207.     {
  1208.         EntryNewScreen(SCR_DELETE_ALL_MENU, mmi_phb_exit_delete_all, mmi_phb_entry_delete_all, NULL);
  1209.         guiBuffer = GetCurrGuiBuffer(SCR_DELETE_ALL_MENU);
  1210.         nNumofItem = GetNumOfChild(MITEM103_PBOOK_DELETE_ALL);
  1211.         GetSequenceStringIds(MITEM103_PBOOK_DELETE_ALL, nStrItemList);
  1212.         GetSequenceImageIds(MITEM103_PBOOK_DELETE_ALL, nImgIltemList);
  1213.         SetParentHandler(MITEM103_PBOOK_DELETE_ALL);
  1214.         RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1215.         ConstructHintsList(MITEM103_PBOOK_DELETE_ALL, nHintList);
  1216.         ShowCategory52Screen(
  1217.             STR_GLOBAL_DELETE,
  1218.             IMG_SCR_PBOOK_CAPTION,
  1219.             STR_GLOBAL_OK,
  1220.             IMG_GLOBAL_OK,
  1221.             STR_GLOBAL_BACK,
  1222.             IMG_GLOBAL_BACK,
  1223.             nNumofItem,
  1224.             nStrItemList,
  1225.             nImgIltemList,
  1226.             nHintList,
  1227.             0,
  1228.             hilitedStorage,
  1229.             guiBuffer);
  1230.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1231.         SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1232.     }
  1233.     else
  1234.     {
  1235.         DisplayPopup(
  1236.             (PU8) GetString(STR_NO_ENTRIES_MESSAGE),
  1237.             IMG_GLOBAL_EMPTY,
  1238.             TRUE,
  1239.             PHB_NOTIFY_TIMEOUT,
  1240.             EMPTY_LIST_TONE);
  1241.     }
  1242. }
  1243. /*****************************************************************************
  1244.  * FUNCTION
  1245.  *  mmi_phb_exit_delete_all
  1246.  * DESCRIPTION
  1247.  *  Exit function for mmi_phb_entry_delete_all()
  1248.  * PARAMETERS
  1249.  *  void
  1250.  * RETURNS
  1251.  *  void
  1252.  *****************************************************************************/
  1253. void mmi_phb_exit_delete_all(void)
  1254. {
  1255.     /*----------------------------------------------------------------*/
  1256.     /* Local Variables                                                */
  1257.     /*----------------------------------------------------------------*/
  1258.     /*----------------------------------------------------------------*/
  1259.     /* Code Body                                                      */
  1260.     /*----------------------------------------------------------------*/
  1261.     g_phb_cntx.end_scr_id = SCR_DELETE_ALL_MENU;
  1262. }
  1263. #if defined(__MMI_PHB_DELETE_ALL_CHECK_PHONE_LOCK__) && defined(MMI_ON_HARDWARE_P)
  1264. /*****************************************************************************
  1265.  * FUNCTION
  1266.  *  mmi_phb_exit_delete_all_phone_lock
  1267.  * DESCRIPTION
  1268.  *  Exit function for mmi_phb_entry_delete_all_phone_lock()
  1269.  * PARAMETERS
  1270.  *  void
  1271.  * RETURNS
  1272.  *  void
  1273.  *****************************************************************************/
  1274. void mmi_phb_exit_delete_all_phone_lock(void)
  1275. {
  1276.     /*----------------------------------------------------------------*/
  1277.     /* Local Variables                                                */
  1278.     /*----------------------------------------------------------------*/
  1279.     /*----------------------------------------------------------------*/
  1280.     /* Code Body                                                      */
  1281.     /*----------------------------------------------------------------*/
  1282.     g_phb_cntx.end_scr_id = SCR_ID_DELETE_ALL_CHECK_PHONE_LOCK;
  1283. }
  1284. /*****************************************************************************
  1285.  * FUNCTION
  1286.  *  mmi_phb_entry_delete_all_phone_lock
  1287.  * DESCRIPTION
  1288.  *  check phone lock before delete all
  1289.  * PARAMETERS
  1290.  *  void
  1291.  * RETURNS
  1292.  *  void
  1293.  *****************************************************************************/
  1294. void mmi_phb_entry_delete_all_phone_lock(void)
  1295. {
  1296.     /*----------------------------------------------------------------*/
  1297.     /* Local Variables                                                */
  1298.     /*----------------------------------------------------------------*/
  1299.     U8 *guiBuffer;
  1300.     /*----------------------------------------------------------------*/
  1301.     /* Code Body                                                      */
  1302.     /*----------------------------------------------------------------*/
  1303.     EntryNewScreen(
  1304.         SCR_ID_DELETE_ALL_CHECK_PHONE_LOCK,
  1305.         mmi_phb_exit_delete_all_phone_lock,
  1306.         mmi_phb_entry_delete_all_phone_lock,
  1307.         NULL);
  1308.     guiBuffer = GetCurrGuiBuffer(SCR_ID_DELETE_ALL_CHECK_PHONE_LOCK);
  1309.     if (guiBuffer == NULL)
  1310.     {
  1311.         memset(gPhonePassword, 0, (MAX_SIM_SETTING_PASSWD_LEN + 1));
  1312.     }
  1313.     RegisterInputBoxValidationFunction(RstrSettingPasswdScrSoftKeyFunc);
  1314.     ShowCategory111Screen(
  1315.         STR_GLOBAL_OK,
  1316.         IMG_GLOBAL_OK,
  1317.         STR_GLOBAL_BACK,
  1318.         IMG_GLOBAL_BACK,
  1319.         STR_RESTORE_PHONE,
  1320.         INPUT_TYPE_NUMERIC_PASSWORD,
  1321.         gPhonePassword,
  1322.         (MAX_SIM_SETTING_PASSWD_LEN + 1),
  1323.         NULL,
  1324.         NULL);
  1325.     SetCategory111RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1326.     SetLeftSoftkeyFunction(mmi_phb_delete_all_verify_phone_lock, KEY_EVENT_UP);
  1327.     SetKeyHandler(mmi_phb_delete_all_verify_phone_lock, KEY_POUND, KEY_EVENT_UP);
  1328.     /* micha0606 */
  1329.     gSecuritySetupContext.PasswdLenCheckCallBack = mmi_phb_delete_all_verify_phone_lock;
  1330.     if (pfnUnicodeStrlen((S8*) gPhonePassword) < MIN_PASSWORD_LENGTH)
  1331.     {
  1332.         ChangeLeftSoftkey(0, 0);
  1333.         ClearKeyHandler(KEY_POUND, KEY_EVENT_UP);
  1334.     }
  1335. }
  1336. /*****************************************************************************
  1337.  * FUNCTION
  1338.  *  mmi_phb_delete_all_verify_phone_lock
  1339.  * DESCRIPTION
  1340.  *  Call security function to check phone lock. Also provide call back function.
  1341.  * PARAMETERS
  1342.  *  void
  1343.  * RETURNS
  1344.  *  void
  1345.  *****************************************************************************/
  1346. void mmi_phb_delete_all_verify_phone_lock(void)
  1347. {
  1348.     /*----------------------------------------------------------------*/
  1349.     /* Local Variables                                                */
  1350.     /*----------------------------------------------------------------*/
  1351.     U8 tempBuffer[(MAX_SIM_SETTING_PASSWD_LEN + 1)];
  1352.     /*----------------------------------------------------------------*/
  1353.     /* Code Body                                                      */
  1354.     /*----------------------------------------------------------------*/
  1355.     memset(tempBuffer, 0, (MAX_SIM_SETTING_PASSWD_LEN + 1));
  1356.     SECSETVerifyPINReq(MMI_SETTING_TYPE_PHONELOCK, gPhonePassword, tempBuffer, mmi_phb_op_delete_all_pre_req);
  1357. }
  1358. #else /* defined(__MMI_PHB_DELETE_ALL_CHECK_PHONE_LOCK__) && defined(MMI_ON_HARDWARE_P) */ 
  1359. /*****************************************************************************
  1360.  * FUNCTION
  1361.  *  mmi_phb_entry_delete_all_confirm
  1362.  * DESCRIPTION
  1363.  *  Confirms before deleting all entries from the selected storage.
  1364.  * PARAMETERS
  1365.  *  void
  1366.  * RETURNS
  1367.  *  void
  1368.  *****************************************************************************/
  1369. void mmi_phb_entry_delete_all_confirm(void)
  1370. {
  1371.     /*----------------------------------------------------------------*/
  1372.     /* Local Variables                                                */
  1373.     /*----------------------------------------------------------------*/
  1374.     /*----------------------------------------------------------------*/
  1375.     /* Code Body                                                      */
  1376.     /*----------------------------------------------------------------*/
  1377.     if (g_phb_cntx.selected_storage == MMI_NVRAM)
  1378.     {
  1379.         DisplayConfirm(
  1380.             STR_GLOBAL_YES,
  1381.             IMG_GLOBAL_YES,
  1382.             STR_GLOBAL_NO,
  1383.             IMG_GLOBAL_NO,
  1384.             get_string(STR_DELETEALL_QUERY_PHONE_MSG),
  1385.             IMG_GLOBAL_QUESTION,
  1386.             WARNING_TONE);
  1387.     }
  1388.     else
  1389.     {
  1390.         DisplayConfirm(
  1391.             STR_GLOBAL_YES,
  1392.             IMG_GLOBAL_YES,
  1393.             STR_GLOBAL_NO,
  1394.             IMG_GLOBAL_NO,
  1395.             get_string(STR_DELETEALL_QUERY_SIM_MSG),
  1396.             IMG_GLOBAL_QUESTION,
  1397.             WARNING_TONE);
  1398.     }
  1399.     SetLeftSoftkeyFunction(mmi_phb_op_delete_all_pre_req, KEY_EVENT_UP);
  1400.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1401. }
  1402. #endif /* defined(__MMI_PHB_DELETE_ALL_CHECK_PHONE_LOCK__) && defined(MMI_ON_HARDWARE_P) */ 
  1403. /*****************************************************************************
  1404.  * FUNCTION
  1405.  *  mmi_phb_op_delete_all_pre_req
  1406.  * DESCRIPTION
  1407.  *  ();
  1408.  *  pre check before delete all.
  1409.  * PARAMETERS
  1410.  *  void
  1411.  * RETURNS
  1412.  *  void
  1413.  *****************************************************************************/
  1414. void mmi_phb_op_delete_all_pre_req(void)
  1415. {
  1416.     /*----------------------------------------------------------------*/
  1417.     /* Local Variables                                                */
  1418.     /*----------------------------------------------------------------*/
  1419.     /*----------------------------------------------------------------*/
  1420.     /* Code Body                                                      */
  1421.     /*----------------------------------------------------------------*/
  1422.     g_phb_mass_op_index = 0;
  1423.     g_phb_cntx.processing = TRUE;
  1424.     g_phb_cntx.copy_all = FALSE;
  1425.     g_phb_mass_op_abort = FALSE;
  1426.     g_phb_mass_op_count = 0;
  1427.     g_phb_mass_op_lookup_count = 0;
  1428.     mmi_phb_show_mass_processing(STR_PHB_DELETING, IMG_GLOBAL_DELETED);
  1429.     DeleteNScrId(SCR_DELETE_ALL_MENU);
  1430.     mmi_phb_op_delete_all_one_after_one_req(g_phb_cntx.selected_storage);
  1431. }
  1432. /*****************************************************************************
  1433.  * FUNCTION
  1434.  *  mmi_phb_op_delete_all_one_after_one_req
  1435.  * DESCRIPTION
  1436.  *  delete all one entry after one.
  1437.  * PARAMETERS
  1438.  *  delete_storage      [IN]        
  1439.  * RETURNS
  1440.  *  void
  1441.  *****************************************************************************/
  1442. void mmi_phb_op_delete_all_one_after_one_req(U8 delete_storage)
  1443. {
  1444.     /*----------------------------------------------------------------*/
  1445.     /* Local Variables                                                */
  1446.     /*----------------------------------------------------------------*/
  1447.     MSG_PHB_DELETE_ENTRY_REQ_STRUCT *myMsgPtr;
  1448.     MYQUEUE Message;
  1449.     U16 store_index;
  1450.     /*----------------------------------------------------------------*/
  1451.     /* Code Body                                                      */
  1452.     /*----------------------------------------------------------------*/
  1453.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_op_delete_all_one_after_one_req.>n",
  1454.                          __FILE__, __LINE__));
  1455.     if (delete_storage == MMI_SIM)
  1456.         while (g_phb_name_index[g_phb_mass_op_index] < MAX_PB_PHONE_ENTRIES)    /* Not in SIM */
  1457.         {
  1458.             g_phb_mass_op_index++;
  1459.         }
  1460.     else
  1461.         while (g_phb_name_index[g_phb_mass_op_index] >= MAX_PB_PHONE_ENTRIES)   /* Not in NVRAM */
  1462.         {
  1463.             g_phb_mass_op_index++;
  1464.         }
  1465.     store_index = g_phb_name_index[g_phb_mass_op_index];
  1466.     myMsgPtr = (MSG_PHB_DELETE_ENTRY_REQ_STRUCT*) OslConstructDataPtr(sizeof(MSG_PHB_DELETE_ENTRY_REQ_STRUCT));
  1467.     myMsgPtr->storage = delete_storage;
  1468.     myMsgPtr->del_all = MMI_FALSE;
  1469.     myMsgPtr->no_data = 1;
  1470.     myMsgPtr->type = MMI_PHB_PHONEBOOK;
  1471.     /*
  1472.      *The index means "record_index" here. This change only for MMI_PHB_PHONEBOOK(ADN) type
  1473.      * for other type( BDN ,FDN, MSISDN...) This field still need to use index as parameter.
  1474.      */
  1475.     myMsgPtr->index = (delete_storage == MMI_SIM) ? (store_index + 1) - MAX_PB_PHONE_ENTRIES : (store_index + 1);
  1476.     Message.oslSrcId = MOD_MMI;
  1477.     Message.oslDestId = MOD_L4C;
  1478.     Message.oslMsgId = PRT_PHB_DEL_ENTRY_REQ;
  1479.     Message.oslDataPtr = (oslParaType*) myMsgPtr;
  1480.     Message.oslPeerBuffPtr = NULL;
  1481.     SetProtocolEventHandler(mmi_phb_op_delete_all_one_after_one_rsp, PRT_PHB_DEL_ENTRY_RSP);
  1482.     OslMsgSendExtQueue(&Message);
  1483.     DeleteNScrId(SCR_DELETE_ALL_MENU);
  1484. }
  1485. /*****************************************************************************
  1486.  * FUNCTION
  1487.  *  mmi_phb_op_delete_all_one_after_one_rsp
  1488.  * DESCRIPTION
  1489.  *  response message after delete one entry.
  1490.  * PARAMETERS
  1491.  *  info        [?]     
  1492.  * RETURNS
  1493.  *  void
  1494.  *****************************************************************************/
  1495. void mmi_phb_op_delete_all_one_after_one_rsp(void *info)
  1496. {
  1497.     /*----------------------------------------------------------------*/
  1498.     /* Local Variables                                                */
  1499.     /*----------------------------------------------------------------*/
  1500.     MSG_PHB_DELETE_ENTRY_RSP_STRUCT *localPtr;
  1501.     U16 store_index;
  1502.     U16 record_index;
  1503.     U8 storage;
  1504.     /*----------------------------------------------------------------*/
  1505.     /* Code Body                                                      */
  1506.     /*----------------------------------------------------------------*/
  1507.     localPtr = (MSG_PHB_DELETE_ENTRY_RSP_STRUCT*) info;
  1508.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_op_delete_all_one_after_one_rsp.>n",
  1509.                          __FILE__, __LINE__));
  1510.     if (localPtr->result.flag == 0 /* OK */ )
  1511.     {
  1512.         store_index = g_phb_name_index[g_phb_mass_op_index];
  1513.         storage = (store_index >= MAX_PB_PHONE_ENTRIES) ? MMI_SIM : MMI_NVRAM;
  1514.         record_index = (storage == MMI_SIM) ? (store_index + 1) - MAX_PB_PHONE_ENTRIES : (store_index + 1);
  1515.         g_phb_mass_op_count++;
  1516.         PhbUpdateSpeedDial(storage, record_index, MMI_PHB_PHONEBOOK, NULL, NULL);
  1517.         if (store_index >= MAX_PB_PHONE_ENTRIES)    /* Record store in SIM, SIM index is begin from "MAX_PB_PHONE_ENTRIES" */
  1518.         {
  1519.             g_phb_cntx.sim_used--;
  1520.         #if defined(__MMI_PHB_EMAIL_SORT__) && defined(__MMI_PHB_USIM_FIELD__)
  1521.             if (g_phb_email_sorted == 1)
  1522.             {
  1523.                 mmi_phb_sort_email_delete_index(store_index);
  1524.             }
  1525.         #endif /* defined(__MMI_PHB_EMAIL_SORT__) && defined(__MMI_PHB_USIM_FIELD__) */ 
  1526.         }
  1527.         else
  1528.         {
  1529.             g_phb_cntx.phone_used--;
  1530.             /* Clear birthday field */
  1531.         #if defined(__MMI_PHB_BIRTHDAY_FIELD__) && defined(__MMI_BIRTHDAY_REMINDER__)
  1532.             mmi_phb_bday_delete_field(store_index);
  1533.         #endif 
  1534.             /* Remove email entry from email sort mapping table */
  1535.         #if defined(__MMI_PHB_EMAIL_SORT__)
  1536.             if (g_phb_email_sorted == 1)
  1537.             {
  1538.                 mmi_phb_sort_email_delete_index(store_index);
  1539.             }
  1540.         #endif /* defined(__MMI_PHB_EMAIL_SORT__) */ 
  1541.         #ifdef __SYNCML_SUPPORT__
  1542.             mmi_syncml_phb_data_changed_notification(SYNCML_RECORD_DELETE, store_index);
  1543.         #endif
  1544.         }
  1545.         /* Remove lookup table entry, and sort result when delete all done. */
  1546.         g_phb_mass_op_lookup_count += mmi_phb_op_clear_lookup_table_by_index(store_index);
  1547.     #if defined(__MMI_VRSD_DIAL__)
  1548.         /* remove voice dial tag if exists. */
  1549.         mmi_vrsddial_delete_tag_by_store_index(store_index);
  1550.     #endif /* defined(__MMI_VRSD_DIAL__) */ 
  1551.         /* clear phonebook entry and remove from index */
  1552.         mmi_phb_op_delete_update_index(store_index);
  1553.         if (g_phb_mass_op_abort)
  1554.         {
  1555.             g_phb_mass_op_success = FALSE;
  1556.             mmi_phb_op_delete_all_done();
  1557.         }
  1558.         else
  1559.         {
  1560.             if ((storage == MMI_SIM && g_phb_cntx.sim_used > 0) || (storage == MMI_NVRAM && g_phb_cntx.phone_used > 0))
  1561.             {
  1562.                 /* g_phb_mass_op_index++; */
  1563.                 mmi_phb_op_delete_all_one_after_one_req(storage);
  1564.             }
  1565.             else
  1566.             {
  1567.                 mmi_phb_op_delete_all_done();
  1568.             }
  1569.         }
  1570.     }
  1571.     else
  1572.     {
  1573.         g_phb_mass_op_success = FALSE;
  1574.         mmi_phb_op_delete_all_done();
  1575.     }
  1576. }
  1577. /*****************************************************************************
  1578.  * FUNCTION
  1579.  *  mmi_phb_op_delete_all_done
  1580.  * DESCRIPTION
  1581.  *  delete all done. displays result.
  1582.  * PARAMETERS
  1583.  *  void
  1584.  * RETURNS
  1585.  *  void
  1586.  *****************************************************************************/
  1587. void mmi_phb_op_delete_all_done(void)
  1588. {
  1589.     /*----------------------------------------------------------------*/
  1590.     /* Local Variables                                                */
  1591.     /*----------------------------------------------------------------*/
  1592.     S8 outBuf[100], count[10];
  1593.     /*----------------------------------------------------------------*/
  1594.     /* Code Body                                                      */
  1595.     /*----------------------------------------------------------------*/
  1596.     g_phb_cntx.processing = FALSE;
  1597.     TurnOnBacklight(1); /* Turn On Back Light When done */
  1598.     DeleteScreenIfPresent(SCR_IN_PROGRESS_PHB);
  1599.     g_phb_cntx.refresh_list = MMI_PHB_ENTRY_REFRESH;
  1600.     /* Sort lookup table */
  1601.     if (g_phb_mass_op_lookup_count)
  1602.     {
  1603.         mmi_phb_lookup_table_sort();
  1604.         g_phb_cntx.lookup_table_count -= g_phb_mass_op_lookup_count;
  1605.     }
  1606.     /* Clear up optional id field */
  1607.     if (g_phb_cntx.selected_storage == MMI_NVRAM)
  1608.     {
  1609.         mmi_phb_op_delete_all_update_optioal_id();
  1610.     }
  1611.     /* No need to clear video id, because it will reset when set new entry */
  1612.     /* Display result */
  1613.     if (g_phb_mass_op_success)
  1614.     {
  1615.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, TRUE, PHB_NOTIFY_TIMEOUT, SUCCESS_TONE);
  1616.     }
  1617.     else if (gSecuritySetupContext.FdlStatus)   /* For FDN on Message */
  1618.     {
  1619.         DisplayPopup((PU8) GetString(STR_FDL_IS_ON), IMG_GLOBAL_UNFINISHED, TRUE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  1620.         g_phb_mass_op_success = TRUE;
  1621.     }
  1622.     else if (!g_phb_mass_op_success)
  1623.     {
  1624.         g_phb_mass_op_success = TRUE;
  1625.         sprintf(count, "%d ", g_phb_mass_op_count);
  1626.         AnsiiToUnicodeString(outBuf, count);
  1627.         pfnUnicodeStrcat(outBuf, GetString(STR_ID_PHB_ENTRIES_DELETED));
  1628.         DisplayPopup((U8*) outBuf, IMG_GLOBAL_UNFINISHED, TRUE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  1629.     }
  1630.     /* Solve Copying Screen Hang Problem */
  1631.     DeleteScreenIfPresent(SCR_COPY_ALL_PROGRESS);
  1632.     /* Re-add all central command for vrsi. */
  1633. #if defined(__MMI_VRSI__)
  1634.     mmi_vrsi_init_central_abort();
  1635.     /* Also remove SD tag if entry is deleted. */
  1636. #if defined(__MMI_VRSI_TRAIN_TAG__)
  1637.     mmi_vrsi_ndial_central_update_sd_mapping();
  1638. #endif 
  1639.     /* mmi_vrsi_init_central_add_all(); */
  1640. #endif /* defined(__MMI_VRSI__) */ 
  1641. }
  1642. /*****************************************************************************
  1643.  * FUNCTION
  1644.  *  mmi_phb_refresh_phb_list
  1645.  * DESCRIPTION
  1646.  *  Refresh phonebook list screens
  1647.  * PARAMETERS
  1648.  *  void
  1649.  * RETURNS
  1650.  *  void
  1651.  *****************************************************************************/
  1652. static void mmi_phb_refresh_phb_list(void)
  1653. {
  1654.     /*----------------------------------------------------------------*/
  1655.     /* Local Variables                                                */
  1656.     /*----------------------------------------------------------------*/
  1657.     U16 scr_id = GetExitScrnID();
  1658.     /*----------------------------------------------------------------*/
  1659.     /* Code Body                                                      */
  1660.     /*----------------------------------------------------------------*/
  1661.     if (scr_id == SCR_PBOOK_LIST || scr_id == SCR_ID_PHB_QUICK_SEARCH_LIST)
  1662.     {
  1663.         DisplayPopup(
  1664.             (U8*) GetString(STR_GLOBAL_DONE),
  1665.             IMG_GLOBAL_ACTIVATED,
  1666.             MMI_FALSE,
  1667.             UI_POPUP_NOTIFYDURATION_TIME,
  1668.             (U8) SUCCESS_TONE);
  1669.     }
  1670. }
  1671. /*****************************************************************************
  1672.  * FUNCTION
  1673.  *  mmi_phb_ind_update_confirm
  1674.  * DESCRIPTION
  1675.  *  After MMI update done, send back confirm message.
  1676.  * PARAMETERS
  1677.  *  void
  1678.  * RETURNS
  1679.  *  void
  1680.  *****************************************************************************/
  1681. void mmi_phb_ind_update_confirm(void)
  1682. {
  1683.     /*----------------------------------------------------------------*/
  1684.     /* Local Variables                                                */
  1685.     /*----------------------------------------------------------------*/
  1686.     mmi_at_general_res_req_struct *myMsgPtr;
  1687.     MYQUEUE Message;
  1688.     /*----------------------------------------------------------------*/
  1689.     /* Code Body                                                      */
  1690.     /*----------------------------------------------------------------*/
  1691.     myMsgPtr = (mmi_at_general_res_req_struct*) OslConstructDataPtr(sizeof(mmi_at_general_res_req_struct));
  1692.     myMsgPtr->result = TRUE;
  1693.     Message.oslSrcId = MOD_MMI;
  1694.     Message.oslDestId = MOD_L4C;
  1695.     Message.oslMsgId = MSG_ID_MMI_AT_GENERAL_RES_REQ;
  1696.     Message.oslDataPtr = (oslParaType*) myMsgPtr;
  1697.     Message.oslPeerBuffPtr = NULL;
  1698.     OslMsgSendExtQueue(&Message);
  1699. }
  1700. /*****************************************************************************
  1701.  * FUNCTION
  1702.  *  mmi_phb_ind_update
  1703.  * DESCRIPTION
  1704.  *  This function handles the update indication  from stack,  after the phonebook has been
  1705.  *  updated through AT commands
  1706.  * PARAMETERS
  1707.  *  info        [?]     
  1708.  * RETURNS
  1709.  *  void
  1710.  *****************************************************************************/
  1711. void mmi_phb_ind_update(void *info)
  1712. {
  1713.     /*----------------------------------------------------------------*/
  1714.     /* Local Variables                                                */
  1715.     /*----------------------------------------------------------------*/
  1716.     MSG_PHB_UPDATE_IND_STRUCT *localPtr;
  1717.     /*----------------------------------------------------------------*/
  1718.     /* Code Body                                                      */
  1719.     /*----------------------------------------------------------------*/
  1720.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_ind_update.>n", __FILE__, __LINE__));
  1721.     localPtr = (MSG_PHB_UPDATE_IND_STRUCT*) info;
  1722.     switch (localPtr->action)
  1723.     {
  1724.         case MMI_PHB_UPDATE:
  1725.             if ((g_phb_cntx.sim_used == localPtr->sim_used) && (g_phb_cntx.phone_used == localPtr->nvram_used))
  1726.             {
  1727.                 mmi_phb_at_cmd_edit(info);
  1728.             }
  1729.             else
  1730.             {
  1731.                 mmi_phb_at_cmd_add(info);
  1732.             }
  1733.             break;
  1734.         case MMI_PHB_DELETE:
  1735.             mmi_phb_at_cmd_delete(info);
  1736.             break;
  1737.         case MMI_PHB_DELETE_ALL:
  1738.             /* currently, AT didn't have DELETE ALL cmd */
  1739.             mmi_phb_at_cmd_delete_all(info);
  1740.             break;
  1741.         case MMI_WRITE_LND:
  1742.         #if (MAX_PHB_LN_ENTRY > 20)
  1743.             if (chis_p->nDialedCalls < TOT_SIZE_OF_DIALED_LIST)
  1744.             {
  1745.                 chis_p->nDialedCalls++;
  1746.             }
  1747.         #else /* (MAX_PHB_LN_ENTRY > 20) */ 
  1748.             chis_p->nDialedCalls = (U8) localPtr->no_list;
  1749.         #endif /* (MAX_PHB_LN_ENTRY > 20) */ 
  1750.             break;
  1751.         case MMI_WRITE_LNM:
  1752.         #if (MAX_PHB_LN_ENTRY > 20)
  1753.             if (chis_p->nMissedCalls < TOT_SIZE_OF_DIALED_LIST)
  1754.             {
  1755.                 chis_p->nMissedCalls++;
  1756.             }
  1757.         #else /* (MAX_PHB_LN_ENTRY > 20) */ 
  1758.             chis_p->nMissedCalls = (U8) localPtr->no_list;
  1759.         #endif /* (MAX_PHB_LN_ENTRY > 20) */ 
  1760.             break;
  1761.         case MMI_WRITE_LNR:
  1762.         #if (MAX_PHB_LN_ENTRY > 20)
  1763.             if (chis_p->nRecvdCalls < TOT_SIZE_OF_DIALED_LIST)
  1764.             {
  1765.                 chis_p->nRecvdCalls++;
  1766.             }
  1767.         #else /* (MAX_PHB_LN_ENTRY > 20) */ 
  1768.             chis_p->nRecvdCalls = (U8) localPtr->no_list;
  1769.         #endif /* (MAX_PHB_LN_ENTRY > 20) */ 
  1770.             break;
  1771.         case MMI_DELETE_LND:
  1772.             if (localPtr->old_index < chis_p->nDialedCalls)
  1773.             {
  1774.                 chis_p->nDialedCalls--;
  1775.             }
  1776.             break;
  1777.         case MMI_DELETE_LNM:
  1778.             if (localPtr->old_index < chis_p->nMissedCalls)
  1779.             {
  1780.                 chis_p->nMissedCalls--;
  1781.                 if (localPtr->old_index < chis_p->nMissedCallBeforeView)
  1782.                 {
  1783.                     chis_p->nMissedCallBeforeView--;
  1784.                 }
  1785.                 if (chis_p->nMissedCalls == 0)
  1786.                 {
  1787.                     HideStatusIcon(STATUS_ICON_MISSED_CALL);
  1788.                     /* Add two statusicons on sublcd */
  1789.                 #ifndef __MMI_SUBLCD_SHORT_STATUSICON_LIST__
  1790.                     HideStatusIcon(STATUS_ICON_SUBLCD_MISSED_CALL);
  1791.                     UpdateSubLCDStatusIcons();
  1792.                 #endif /* __MMI_SUBLCD_SHORT_STATUSICON_LIST__ */ 
  1793.                 }
  1794.             }
  1795.             break;
  1796.         case MMI_DELETE_LNR:
  1797.             if (localPtr->old_index < chis_p->nRecvdCalls)
  1798.             {
  1799.                 chis_p->nRecvdCalls--;
  1800.             }
  1801.             break;
  1802.     }
  1803.     mmi_phb_ind_update_confirm();
  1804. }
  1805. /*****************************************************************************
  1806.  * FUNCTION
  1807.  *  mmi_phb_at_cmd_edit
  1808.  * DESCRIPTION
  1809.  *  Handles the phonebook update indication after an entry is edited through AT command
  1810.  * PARAMETERS
  1811.  *  info        [?]     
  1812.  * RETURNS
  1813.  *  void
  1814.  *****************************************************************************/
  1815. void mmi_phb_at_cmd_edit(void *info)
  1816. {
  1817.     /*----------------------------------------------------------------*/
  1818.     /* Local Variables                                                */
  1819.     /*----------------------------------------------------------------*/
  1820.     MSG_PHB_UPDATE_IND_STRUCT *localPtr;
  1821.     U16 deletedCnt = 0;
  1822.     U8 flag = 0;
  1823.     S16 pError;
  1824.     U16 store_index;
  1825.     /*----------------------------------------------------------------*/
  1826.     /* Code Body                                                      */
  1827.     /*----------------------------------------------------------------*/
  1828.     localPtr = (MSG_PHB_UPDATE_IND_STRUCT*) info;
  1829.     if (localPtr->list[0].storage == MMI_SIM)
  1830.     {
  1831.         store_index = localPtr->list[0].record_index + MAX_PB_PHONE_ENTRIES - 1;        /* Storage Location in array. */
  1832.     }
  1833.     else
  1834.     {
  1835.         store_index = localPtr->list[0].record_index - 1;   /* Storage Location in array. */
  1836.     }
  1837.     /* Clear lookup table first, add later if exists. */
  1838.     deletedCnt = mmi_phb_op_clear_lookup_table_by_index(store_index);
  1839.     if (localPtr->list[0].storage == MMI_NVRAM)
  1840.     {
  1841.         /* Clear Optional Field */
  1842.     #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
  1843.         memset(&PhoneBookOptionalFields, 0, sizeof(PhoneBookOptionalFields));
  1844.         WriteRecord(
  1845.             NVRAM_EF_PHB_FIELDS_LID,
  1846.             (U16) (store_index + 1),
  1847.             (void*)&PhoneBookOptionalFields,
  1848.             OPTIONAL_FIELDS_RECORD_SIZE,
  1849.             &pError);
  1850.     #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */ 
  1851.         /* Clear birthday field */
  1852.     #if defined(__MMI_PHB_BIRTHDAY_FIELD__)
  1853.         mmi_phb_bday_delete_field(store_index);
  1854.     #endif 
  1855.     #if defined(__MMI_PHB_INFO_FIELD__)
  1856.         mmi_phb_info_delete_field(store_index);
  1857.     #endif 
  1858.     #ifdef __SYNCML_SUPPORT__
  1859.         mmi_syncml_phb_data_changed_notification(SYNCML_RECORD_MODIFY, store_index);
  1860.     #endif
  1861.     }
  1862.     flag = mmi_phb_op_increase_lookup_table(store_index, (S8*) localPtr->list[0].tel.number, NULL, NULL, NULL);
  1863.     if (flag || deletedCnt)
  1864.     {
  1865.         mmi_phb_lookup_table_sort();
  1866.         g_phb_cntx.lookup_table_count -= deletedCnt;
  1867.     }
  1868.     PhoneBook[store_index].alpha_id.name_length = localPtr->list[0].alpha_id.name_length;
  1869.     PhoneBook[store_index].alpha_id.name_dcs = localPtr->list[0].alpha_id.name_dcs;
  1870.     InputboxConvertGSMToDeviceEncoding(
  1871.         localPtr->list[0].alpha_id.name,
  1872.         PhoneBook[store_index].alpha_id.name,
  1873.         localPtr->list[0].alpha_id.name_length,
  1874.         (MAX_PB_NAME_LENGTH + 1) * ENCODING_LENGTH,
  1875.         localPtr->list[0].alpha_id.name_dcs,
  1876.         0,
  1877.         1);
  1878.     PhoneBook[store_index].tel.type = localPtr->list[0].tel.type;
  1879.     PhoneBook[store_index].tel.length = localPtr->list[0].tel.length;
  1880.     mmi_phb_convert_to_bcd(
  1881.         PhoneBook[store_index].tel.number,
  1882.         localPtr->list[0].tel.number,
  1883.         (MAX_PB_NUMBER_LENGTH + 1) / 2);
  1884.     /* Update is column exists flag. */
  1885.     PhoneBook[store_index].field = 0;
  1886.     if (strlen((S8*) localPtr->list[0].tel.number))
  1887.     {
  1888.         PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_NUMBER;
  1889.     }
  1890.     /* Update Pinyin Cache for sort */
  1891. #if defined(__MMI_PHB_PINYIN_SORT__)
  1892.     mmi_phb_util_make_pinyin_cache(store_index);
  1893. #endif 
  1894.     /* Name sorting mapping table should Re-Sort HERE, and get the new highlight position!!! */
  1895.     mmi_phb_op_delete_update_index(store_index);
  1896.     mmi_phb_sort_insert_name_index(store_index);
  1897.     g_phb_cntx.refresh_list = MMI_PHB_ENTRY_REFRESH;
  1898.     /* Update email sorting mapping table */
  1899. #if defined(__MMI_PHB_EMAIL_SORT__)
  1900. #ifdef __MMI_PHB_USIM_FIELD__
  1901.     if (g_phb_email_sorted == 1)
  1902. #else 
  1903.     if ((localPtr->list[0].storage == MMI_NVRAM) && (g_phb_email_sorted == 1))
  1904. #endif 
  1905.     {
  1906.         mmi_phb_sort_email_delete_index(store_index);
  1907.         mmi_phb_sort_email_insert_index(store_index);
  1908.     }
  1909. #endif /* defined(__MMI_PHB_EMAIL_SORT__) */ 
  1910. }
  1911. /*****************************************************************************
  1912.  * FUNCTION
  1913.  *  mmi_phb_at_cmd_add
  1914.  * DESCRIPTION
  1915.  *  Handles the phonebook update indication after an entry is added through AT command
  1916.  * PARAMETERS
  1917.  *  info        [?]     
  1918.  * RETURNS
  1919.  *  void
  1920.  *****************************************************************************/
  1921. void mmi_phb_at_cmd_add(void *info)
  1922. {
  1923.     /*----------------------------------------------------------------*/
  1924.     /* Local Variables                                                */
  1925.     /*----------------------------------------------------------------*/
  1926.     MSG_PHB_UPDATE_IND_STRUCT *localPtr;
  1927.     S16 pError;
  1928.     U16 store_index;
  1929.     U8 flag = 0;
  1930.     /*----------------------------------------------------------------*/
  1931.     /* Code Body                                                      */
  1932.     /*----------------------------------------------------------------*/
  1933.     localPtr = (MSG_PHB_UPDATE_IND_STRUCT*) info;
  1934.     store_index = mmi_phb_op_get_store_index_and_increase_counter(localPtr->list[0].storage, localPtr->list[0].record_index);
  1935.     if (localPtr->list[0].storage == MMI_NVRAM)
  1936.     {
  1937.         /* Clear Optional Field */
  1938.     #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
  1939.         memset(&PhoneBookOptionalFields, 0, sizeof(PhoneBookOptionalFields));
  1940.         WriteRecord(
  1941.             NVRAM_EF_PHB_FIELDS_LID,
  1942.             (U16) (store_index + 1),
  1943.             (void*)&PhoneBookOptionalFields,
  1944.             OPTIONAL_FIELDS_RECORD_SIZE,
  1945.             &pError);
  1946.     #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */ 
  1947.         /* Clear video field. */
  1948.     #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1949.         mmi_phb_video_delete_by_index(store_index);
  1950.     #endif 
  1951.         /* Clear birthday field */
  1952.     #if defined(__MMI_PHB_BIRTHDAY_FIELD__)
  1953.         mmi_phb_bday_delete_field(store_index);
  1954.     #endif 
  1955.     #if defined(__MMI_PHB_INFO_FIELD__)
  1956.         mmi_phb_info_delete_field(store_index);
  1957.     #endif 
  1958.     #ifdef __SYNCML_SUPPORT__
  1959.         mmi_syncml_phb_data_changed_notification(SYNCML_RECORD_ADD, store_index);
  1960.     #endif
  1961.     }
  1962. #if !defined(__MMI_PHB_CALLERGROUP_IN_SIM__)    /* Associate caller group in SIM card entry */
  1963.     if (localPtr->list[0].storage == MMI_NVRAM)
  1964. #endif 
  1965.     {
  1966.         mmi_phb_clear_optional_ids(store_index);