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

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.  * PhoneBookCallerGroups.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   Implemantation of "Caller Group" feature in the Phonebook Application
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  *------------------------------------------------------------------------------
  140.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  141.  *============================================================================
  142.  ****************************************************************************/
  143. #ifndef _PHONEBOOKCALLERGROUP_C
  144. #define _PHONEBOOKCALLERGROUP_C
  145. #include "MMI_features.h"
  146. #include "stdC.h"
  147. #include "L4Dr1.h"
  148. #include "PixtelDataTypes.h"
  149. #include "GlobalConstants.h"
  150. #include "DebugInitDef.h"
  151. #include "ProtocolEvents.h"
  152. #include "HistoryGprot.h"
  153. #include "wgui_categories.h"
  154. #include "wgui_categories_inputs.h"
  155. #include "wgui_categories_popup.h"
  156. #include "PhonebookDef.h"
  157. #include "PhoneBookTypes.h"
  158. #include "PhonebookProt.h"
  159. #include "PhonebookGprot.h"
  160. #include "QueueGProt.h"
  161. #include "mainmenudef.h"
  162. #include "Unicodexdcl.h"
  163. #include "GlobalDefs.h"
  164. #include "TimerEvents.h"
  165. #include "NVRAMEnum.h"
  166. #include "NVRAMProt.h"
  167. #include "NVRAMType.h"
  168. #include "ProfileGprots.h"
  169. #include "gpioinc.h"
  170. #include "DownloadDefs.h"
  171. #include "DownloadProtos.h"
  172. #include "CommonScreens.h"
  173. #include "ProfilesEnum.h"       /* For Alert Type String ID */
  174. #include "CallManagementGprot.h"
  175. #ifdef __MMI_PROFILE_EXTMELODY_SUPPORT__
  176. #include "FileMgr.h"
  177. #include "ProfileMgrGProt.h"
  178. #include "Conversions.h"
  179. #endif /* __MMI_PROFILE_EXTMELODY_SUPPORT__ */ 
  180. #if defined(__MMI_MESSAGES_SEND_BY_GROUP__)
  181. #include "MessagesExDcl.h"
  182. #include "SMSGuiInterfaceProt.h"
  183. #endif /* defined(__MMI_MESSAGES_SEND_BY_GROUP__) */ 
  184. #ifdef __J2ME__
  185. #include "j2me_custom_option.h"
  186. #endif
  187. #if defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC)
  188. #include "PhonebookJavaHandler.h"
  189. #endif
  190. #if defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__)
  191. #include "ThemeManager.h"
  192. #endif
  193. #ifdef __SYNCML_SUPPORT__
  194. #include "SyncMLDef.h"
  195. #include "SyncMLGprot.h"
  196. #endif /* __SYNCML_SUPPORT__ */
  197. #define MAX_CALLER_GRP_USIM_ITEMS 2
  198. /*
  199.  * Local Variable
  200.  */
  201. static U16 g_phb_last_ring_tone_id = 0;
  202. static U16 g_phb_curr_ring_tone_id = 0;
  203. static U8 g_phb_last_pattern_id = 0;
  204. static U8 g_phb_curr_pattern_id = 0;
  205. #ifdef __MMI_PHB_USIM_FIELD__
  206. static U8 phb_delete_grp_flag;
  207. #endif 
  208. #if defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__)        /* Caller Group Member List */
  209. static U16 g_phb_callergroup_member_count;
  210. static U16 *g_phb_callergroup_ptr = NULL;
  211. static U8 g_phb_callergroup_member_index = 10;
  212. #endif /* defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__) */ 
  213. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  214. extern U8 g_phb_video_item_index;
  215. extern BOOL g_phb_video_view;
  216. extern BOOL g_phb_swflash_view;
  217. #endif /* defined(__MMI_INCOMING_CALL_VIDEO__) */ 
  218. /*
  219.  * Global Variable
  220.  */
  221. extern InlineItem wgui_inline_items[];
  222. extern pBOOL viewOnce;
  223. extern MMI_PHB_LIST_VIEW phbListView;
  224. extern U8 gPictureItemIndex;
  225. #if defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__)        /* Caller Group Member List */
  226. extern U16 PhoneBookEntryCount;
  227. extern MMI_PHB_ENTRY_BCD_STRUCT PhoneBook[];
  228. #endif /* defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__) */ 
  229. extern U16 g_phb_name_index[];
  230. extern S8 pbName[];
  231. #ifdef __MMI_PHB_USIM_FIELD__
  232. extern S8 pbNumber[];   /* dummy number for save gas */
  233. #endif 
  234. extern U8 *myCallerGrpnames[];
  235. #if defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC)
  236. extern U8 g_phb_enter_from;
  237. #endif
  238. /*
  239.  * Local Function
  240.  */
  241. static void mmi_phb_entry_callergroup_phone_detail(void);
  242. #ifdef __MMI_PHB_USIM_FIELD__
  243. static void mmi_phb_entry_callergroup_usim_detail(void);
  244. static void mmi_phb_gas_pre_save(void);
  245. static void mmi_phb_callergroup_member_usim_set_req(void);
  246. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  247. /*
  248.  * Global Function
  249.  */
  250. /*****************************************************************************
  251.  * FUNCTION
  252.  *  mmi_phb_caller_group_init
  253.  * DESCRIPTION
  254.  *  Initialization of "Caller Group" feature
  255.  * PARAMETERS
  256.  *  void
  257.  * RETURNS
  258.  *  void
  259.  *****************************************************************************/
  260. void mmi_phb_caller_group_init(void)
  261. {
  262.     /*----------------------------------------------------------------*/
  263.     /* Local Variables                                                */
  264.     /*----------------------------------------------------------------*/
  265.     /*----------------------------------------------------------------*/
  266.     /* Code Body                                                      */
  267.     /*----------------------------------------------------------------*/
  268.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_caller_group_init.>n", __FILE__,
  269.                          __LINE__));
  270.     SetHiliteHandler(MITEM109_PBOOK_CALLER_GROUPS, mmi_phb_highlight_callergroup);
  271. #if defined (__MMI_PHB_CALLERGROUP_MEMBER_LIST__)
  272.     SetHiliteHandler(MENU_ID_PHB_CALLERGROUP_MEMBER_ADD_MEMBER, mmi_phb_highlight_callergroup_member_add);
  273.     SetHiliteHandler(MENU_ID_PHB_CALLERGROUP_MEMBER_DELETE_MEMBER, mmi_phb_highlight_callergroup_member_delete);
  274. #endif /* defined (__MMI_PHB_CALLERGROUP_MEMBER_LIST__) */ 
  275. }
  276. /*****************************************************************************
  277.  * FUNCTION
  278.  *  mmi_phb_callergroup_restore_default
  279.  * DESCRIPTION
  280.  *  Sets Caller Groups default values. This is an external API called by restore defaults application
  281.  * PARAMETERS
  282.  *  void
  283.  * RETURNS
  284.  *  BOOL: TRUE if restore successfully, else FALSE
  285.  *****************************************************************************/
  286. BOOL mmi_phb_callergroup_restore_default(void)
  287. {
  288.     /*----------------------------------------------------------------*/
  289.     /* Local Variables                                                */
  290.     /*----------------------------------------------------------------*/
  291.     S16 pError;
  292.     U8 i, midiToneStartId, midiToneTotalId;
  293.     PHB_CALLER_GROUP_STRUCT *callerGroups;
  294.     /*----------------------------------------------------------------*/
  295.     /* Code Body                                                      */
  296.     /*----------------------------------------------------------------*/
  297.     callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  298.     GetMidiRange(&midiToneStartId, &midiToneTotalId);
  299.     for (i = 0; i < MAX_PB_CALLER_GROUPS; ++i)
  300.     {
  301.     #if defined(__MMI_CALLERGROUP_NO_ALERT__)
  302.         callerGroups[i].alertType = MMI_ALERT_NONE;
  303.     #else 
  304.         callerGroups[i].alertType = MMI_RING;
  305.     #endif 
  306.         callerGroups[i].ringToneID = midiToneStartId;
  307.         callerGroups[i].pictureTagID = IMG_PHB_DEFAULT;
  308.     #if defined(__MMI_STATUS_LED__)
  309.         callerGroups[i].LEDPatternId = 1;   /* pattern 1 */
  310.     #else 
  311.         callerGroups[i].LEDPatternId = 0;   /* no pattern */
  312.     #endif 
  313.         callerGroups[i].is_modified = 0;    /* Restore to default name */
  314.         /* Restore Name according to language */
  315.         pfnUnicodeStrncpy(
  316.             (PS8) callerGroups[i].groupName,
  317.             GetString((U16) (STR_CALLER_GROUP_1 + i)),
  318.             MAX_GRP_NAME_LENGTH);
  319.     }
  320.     WriteRecord(NVRAM_EF_PHB_CALLER_GROUPS_LID, 1, callerGroups, CALLER_GROUPS_RECORD_SIZE, &pError);
  321.     if (pError == NVRAM_WRITE_SUCCESS)
  322.     {
  323.         return TRUE;
  324.     }
  325.     else
  326.     {
  327.         return FALSE;
  328.     }
  329. }
  330. /*****************************************************************************
  331.  * FUNCTION
  332.  *  mmi_phb_callergroup_set_name_by_language
  333.  * DESCRIPTION
  334.  *  Sets Caller Groups name values according to current language.
  335.  *  This is an external API called by restore defaults application
  336.  * PARAMETERS
  337.  *  void
  338.  * RETURNS
  339.  *  BOOL: TRUE if restore successfully, else FALSE(?)
  340.  *****************************************************************************/
  341. void mmi_phb_callergroup_set_name_by_language(void)
  342. {
  343.     /*----------------------------------------------------------------*/
  344.     /* Local Variables                                                */
  345.     /*----------------------------------------------------------------*/
  346.     S16 pError;
  347.     U8 i;
  348.     PHB_CALLER_GROUP_STRUCT callerGroups[MAX_PB_CALLER_GROUPS];
  349.     /*----------------------------------------------------------------*/
  350.     /* Code Body                                                      */
  351.     /*----------------------------------------------------------------*/
  352.     ReadRecord(NVRAM_EF_PHB_CALLER_GROUPS_LID, 1, callerGroups, CALLER_GROUPS_RECORD_SIZE, &pError);
  353.     if (pError == NVRAM_READ_SUCCESS)
  354.     {
  355.         for (i = 0; i < MAX_PB_CALLER_GROUPS; ++i)
  356.         {
  357.             if (callerGroups[i].is_modified == 0)   /* User not modify yet */
  358.             {
  359.                 pfnUnicodeStrncpy(
  360.                     (PS8) callerGroups[i].groupName,
  361.                     GetString((U16) (STR_CALLER_GROUP_1 + i)),
  362.                     MAX_GRP_NAME_LENGTH);
  363.             }
  364.         }
  365.         WriteRecord(NVRAM_EF_PHB_CALLER_GROUPS_LID, 1, callerGroups, CALLER_GROUPS_RECORD_SIZE, &pError);
  366.         if ((pError == NVRAM_WRITE_SUCCESS) && (g_phb_cntx.caller_group != NULL) && g_phb_cntx.nvram_data_init)
  367.         {
  368.             memcpy(g_phb_cntx.caller_group, callerGroups, CALLER_GROUPS_RECORD_SIZE);
  369.         }
  370.     }
  371. }
  372. /*****************************************************************************
  373.  * FUNCTION
  374.  *  mmi_phb_highlight_callergroup
  375.  * DESCRIPTION
  376.  *  Highlight handler for Caller Group in PHB main menu
  377.  * PARAMETERS
  378.  *  void
  379.  * RETURNS
  380.  *  void
  381.  *****************************************************************************/
  382. void mmi_phb_highlight_callergroup(void)
  383. {
  384.     /*----------------------------------------------------------------*/
  385.     /* Local Variables                                                */
  386.     /*----------------------------------------------------------------*/
  387.     /*----------------------------------------------------------------*/
  388.     /* Code Body                                                      */
  389.     /*----------------------------------------------------------------*/
  390.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  391.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  392.     phbListView = MMI_PHB_LIST_FOR_PHB;
  393.     SetLeftSoftkeyFunction(mmi_phb_entry_callergroup, KEY_EVENT_UP);
  394.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  395.     SetKeyHandler(mmi_phb_entry_callergroup, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  396.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  397. }
  398. /*****************************************************************************
  399.  * FUNCTION
  400.  *  mmi_phb_entry_callergroup
  401.  * DESCRIPTION
  402.  *  Displays the list of available Caller Groups
  403.  * PARAMETERS
  404.  *  void
  405.  * RETURNS
  406.  *  void
  407.  *****************************************************************************/
  408. void mmi_phb_entry_callergroup(void)
  409. {
  410.     /*----------------------------------------------------------------*/
  411.     /* Local Variables                                                */
  412.     /*----------------------------------------------------------------*/
  413. #ifdef __MMI_PHB_USIM_FIELD__
  414.     MMI_PHB_NAME_STRUCT *usim_caller_groups = (MMI_PHB_NAME_STRUCT*) g_phb_cntx.usim_group;
  415. #endif
  416.     U8 *grpNames[MAX_PB_CALLER_GROUPS + MAX_PB_USIM_GROUPS];
  417.     U16 i;
  418.     U8 *guiBuffer;
  419.     PHB_CALLER_GROUP_STRUCT *callerGroups;
  420.     /*----------------------------------------------------------------*/
  421.     /* Code Body                                                      */
  422.     /*----------------------------------------------------------------*/
  423.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_entry_callergroup.>n", __FILE__,
  424.                          __LINE__));
  425. #ifdef __SYNCML_SUPPORT__
  426.     if (mmi_syncml_is_phb_sync_now())
  427.     {
  428.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  429.         return;
  430.     }
  431. #endif /* __SYNCML_SUPPORT__ */
  432.     if (!g_phb_cntx.nvram_data_init)
  433.     {
  434.         mmi_phb_init_get_data_from_nvram();
  435.         g_phb_cntx.nvram_data_init = TRUE;
  436.     }
  437.     EntryNewScreen(SCR_CALLER_GROUPS, mmi_phb_exit_callergroup, mmi_phb_entry_callergroup, NULL);
  438.     guiBuffer = GetCurrGuiBuffer(SCR_CALLER_GROUPS);    /* Getting the Index from history */
  439.     callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  440.     for (i = 0; i < MAX_PB_CALLER_GROUPS; i++)
  441.     {
  442.         grpNames[i] = callerGroups[i].groupName;
  443.     }
  444. #ifdef __MMI_PHB_USIM_FIELD__
  445.     for (i = MAX_PB_CALLER_GROUPS; i < MAX_PB_CALLER_GROUPS + g_phb_cntx.gas_total; i++)
  446.     {
  447.         if (pfnUnicodeStrlen((PS8) usim_caller_groups[i - MAX_PB_CALLER_GROUPS].name) > 0)
  448.         {
  449.             grpNames[i] = usim_caller_groups[i - MAX_PB_CALLER_GROUPS].name;
  450.         }
  451.         else
  452.         {
  453.             grpNames[i] = (U8*) GetString(STR_GLOBAL_EMPTY_LIST);
  454.         }
  455.     }
  456. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  457. #if defined(__MMI_MESSAGES_SEND_BY_GROUP__) || defined(__UNIFIED_COMPOSER_SUPPORT__)
  458.     if (phbListView == MMI_PHB_LIST_FOR_GET_ADDRESS_FROM_GROUP)
  459.     {
  460.         RegisterHighlightHandler(mmi_phb_get_index_second_level);
  461.         SetMessagesCurrScrnID(SCR_CALLER_GROUPS);
  462.         ShowCategory53Screen(STR_SCR_CALLER_GROUP_CAPTION, IMG_SCR_PBOOK_CAPTION,
  463.                              STR_GLOBAL_OK, IMG_GLOBAL_OK, STR_GLOBAL_BACK, IMG_GLOBAL_BACK,
  464.             #ifdef __MMI_PHB_USIM_FIELD__
  465.                              g_phb_cntx.gas_total +
  466.             #endif 
  467.                              MAX_PB_CALLER_GROUPS,
  468.                              grpNames, (U16*) gIndexIconsImageList, NULL, 0, 0, guiBuffer);
  469.         SetLeftSoftkeyFunction(mmi_phb_sms_send_data_for_group, KEY_EVENT_UP);
  470.     }
  471.     else
  472. #endif /* defined(__MMI_MESSAGES_SEND_BY_GROUP__) || defined(__UNIFIED_COMPOSER_SUPPORT__) */ 
  473.     {
  474.         RegisterHighlightHandler(mmi_phb_get_index);
  475.         ShowCategory53Screen(STR_SCR_CALLER_GROUP_CAPTION, IMG_SCR_PBOOK_CAPTION,
  476.                              STR_GLOBAL_OK, IMG_GLOBAL_OK, STR_GLOBAL_BACK, IMG_GLOBAL_BACK,
  477.             #ifdef __MMI_PHB_USIM_FIELD__
  478.                              g_phb_cntx.gas_total +
  479.             #endif 
  480.                              MAX_PB_CALLER_GROUPS,
  481.                              grpNames, (U16*) gIndexIconsImageList, NULL, 0, 0, guiBuffer);
  482.     #if defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__)
  483.         if (phbListView == MMI_PHB_LIST_FOR_SAVE_FROM_FILE_MGR)
  484.         {
  485.             SetLeftSoftkeyFunction(mmi_phb_fmgr_pre_edit_callergrp, KEY_EVENT_UP);
  486.         }
  487.         else
  488.     #endif /* defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__) */ 
  489.         {
  490.             SetLeftSoftkeyFunction(mmi_phb_entry_callergroup_detail, KEY_EVENT_UP);
  491.             SetKeyHandler(mmi_phb_entry_callergroup_detail, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  492.         }
  493.     }
  494.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  495.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  496. }
  497. /*****************************************************************************
  498.  * FUNCTION
  499.  *  mmi_phb_exit_callergroup
  500.  * DESCRIPTION
  501.  *  Exit function of mmi_phb_entry_callergroup()
  502.  * PARAMETERS
  503.  *  void
  504.  * RETURNS
  505.  *  void
  506.  *****************************************************************************/
  507. void mmi_phb_exit_callergroup(void)
  508. {
  509.     /*----------------------------------------------------------------*/
  510.     /* Local Variables                                                */
  511.     /*----------------------------------------------------------------*/
  512.     /*----------------------------------------------------------------*/
  513.     /* Code Body                                                      */
  514.     /*----------------------------------------------------------------*/
  515.     g_phb_cntx.end_scr_id = SCR_CALLER_GROUPS;
  516. #if defined(__MMI_MESSAGES_SEND_BY_GROUP__)
  517.     mmi_msg_exit_generic();
  518. #endif 
  519. }
  520. /*****************************************************************************
  521.  * FUNCTION
  522.  *  mmi_phb_entry_callergroup_detail
  523.  * DESCRIPTION
  524.  *  Displayes the attributes of the selected Caller Group and also allows to edit it
  525.  * PARAMETERS
  526.  *  void
  527.  * RETURNS
  528.  *  void
  529.  *****************************************************************************/
  530. void mmi_phb_entry_callergroup_detail(void)
  531. {
  532. #ifdef __MMI_PHB_USIM_FIELD__
  533.     /*----------------------------------------------------------------*/
  534.     /* Local Variables                                                */
  535.     /*----------------------------------------------------------------*/
  536.     /*----------------------------------------------------------------*/
  537.     /* Code Body                                                      */
  538.     /*----------------------------------------------------------------*/
  539.     if (g_phb_cntx.active_index >= MAX_PB_CALLER_GROUPS)
  540.     {
  541.         mmi_phb_entry_callergroup_usim_detail();
  542.     }
  543.     else
  544. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  545.     {
  546.         mmi_phb_entry_callergroup_phone_detail();
  547.     }
  548. }
  549. /*****************************************************************************
  550.  * FUNCTION
  551.  *  mmi_phb_entry_callergroup_phone_detail
  552.  * DESCRIPTION
  553.  *  Displayes the attributes of the selected Caller Group and also allows to edit it
  554.  * PARAMETERS
  555.  *  void
  556.  * RETURNS
  557.  *  void
  558.  *****************************************************************************/
  559. void mmi_phb_entry_callergroup_phone_detail(void)
  560. {
  561.     /*----------------------------------------------------------------*/
  562.     /* Local Variables                                                */
  563.     /*----------------------------------------------------------------*/
  564.     U8 *guiBuffer;
  565.     U8 *inputBuffer;
  566.     U16 inputBufferSize;
  567.     U8 j = 0;
  568.     U16 CGDetailsImageList[MAX_CALLER_GRP_ITEMS];
  569.     PHB_CALLER_GROUP_STRUCT *callerGroups = NULL;
  570. #if defined __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  571.     BOOL found_theme_tone = TRUE;
  572. #endif
  573.     /*----------------------------------------------------------------*/
  574.     /* Code Body                                                      */
  575.     /*----------------------------------------------------------------*/
  576.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_entry_callergroup_phone_detail.>n",
  577.                          __FILE__, __LINE__));
  578.     mmi_phb_build_led_and_alert_list();
  579.     mmi_phb_build_ring_tone_list();
  580.     mmi_phb_build_image_list();
  581. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  582.     mmi_phb_build_video_list();
  583. #endif 
  584.     EntryNewScreen(SCR_CALLER_GRP_DETAILS, mmi_phb_exit_callergroup_detail, NULL, NULL);
  585.     InitializeCategory57Screen();
  586.     guiBuffer = GetCurrGuiBuffer(SCR_CALLER_GRP_DETAILS);
  587.     inputBuffer = GetCurrNInputBuffer(SCR_CALLER_GRP_DETAILS, &inputBufferSize);
  588.     callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  589.     pfnUnicodeStrcpy(pbName, (PS8) callerGroups[g_phb_cntx.active_index].groupName);
  590.     g_phb_cntx.selected_alert_index = callerGroups[g_phb_cntx.active_index].alertType;
  591. #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  592.     if (callerGroups[g_phb_cntx.active_index].ringToneID == CURRENT_THEME_INCOMING_CALL_TONE && mmi_tm_get_current_theme_ringtone() == FALSE)
  593.     {
  594.         g_phb_cntx.selected_ring_index = 0;
  595.         found_theme_tone = FALSE;
  596.     }
  597.     else
  598. #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */
  599.     {
  600.         g_phb_cntx.selected_ring_index = mmi_phb_get_ring_tone_index(callerGroups[g_phb_cntx.active_index].ringToneID);
  601.     }
  602.     g_phb_cntx.selected_pattern_index = callerGroups[g_phb_cntx.active_index].LEDPatternId;
  603.     g_phb_cntx.selected_pic_index = mmi_phb_get_image_index(callerGroups[g_phb_cntx.active_index].pictureTagID);
  604. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  605.     g_phb_cntx.selected_video_index = mmi_phb_get_video_index(callerGroups[g_phb_cntx.active_index].VideoID);
  606.     if (guiBuffer == NULL)  /* First Time Enter and Not Enter From File Manager */
  607.     {
  608.         U16 video_id = callerGroups[g_phb_cntx.active_index].VideoID;
  609.         g_phb_cntx.video_audio = ((video_id == 0) || (video_id & 0x4000)) ? 1 : 0;
  610.         /*Change Inline select prompt message.*/
  611.         if( g_phb_cntx.selected_video_index == g_phb_cntx.total_video_id - 1)
  612.         {
  613.             g_phb_cntx.video_name_list[g_phb_cntx.total_video_id - 1] = (U8*)GetString(STR_ID_PHB_FMGR_IMAGE_SELECTED);
  614.             g_phb_cntx.video_location = MMI_PHB_IMAGE_SELECT_PATH;
  615.         }
  616. #ifdef __MMI_SWFLASH__
  617.         else if( g_phb_cntx.selected_video_index == g_phb_cntx.total_video_id - 2)
  618.         {
  619.             g_phb_cntx.video_name_list[g_phb_cntx.total_video_id - 2] = (U8*)GetString(STR_ID_PHB_FMGR_IMAGE_SELECTED);
  620.             g_phb_cntx.video_location = MMI_PHB_SWFLASH_SELECT_PATH;
  621.         }
  622. #endif /* __MMI_SWFLASH__ */
  623.         /* Check if can load video path */
  624.         if (!mmi_phb_video_get_path_by_index(video_id))
  625.         {
  626.             g_phb_cntx.video_location = MMI_PHB_IMAGE_NO_SELECT;
  627.         }
  628.     }
  629. #endif /* defined(__MMI_INCOMING_CALL_VIDEO__) */ 
  630. #if defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__)
  631.     if (guiBuffer == NULL)  /* && (g_phb_cntx.set_done_flag != 2)) */
  632.     {
  633.         if (callerGroups[g_phb_cntx.active_index].pictureTagID == 1)
  634.         {
  635.             g_phb_cntx.image_location = MMI_PHB_IMAGE_CALLER_GROUP;
  636.         }
  637.         else
  638.         {
  639.             g_phb_cntx.image_location = MMI_PHB_IMAGE_NO_SELECT;
  640.         }
  641.     }
  642.     if (g_phb_cntx.image_location != MMI_PHB_IMAGE_NO_SELECT)   /* Change Inline select prompt message. */
  643.     {
  644.         g_phb_cntx.image_name_list[g_phb_cntx.total_image_id - 1] = (U8*) GetString(STR_ID_PHB_FMGR_IMAGE_SELECTED);
  645.     }
  646. #endif /* defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__) */ 
  647.     /* Caller Group Name */
  648.     SetInlineItemActivation(&wgui_inline_items[j], KEY_LSK, KEY_EVENT_UP);
  649.     SetInlineItemFullScreenEdit(
  650.         &wgui_inline_items[j],
  651.         STR_GRP_NAME_CAPTION,
  652.         IMG_SCR_PBOOK_CAPTION,
  653.         (PU8) pbName,
  654.         MAX_GRP_NAME_LENGTH + 1,
  655.         INPUT_TYPE_ALPHANUMERIC_UPPERCASE);
  656.     SetInlineFullScreenEditCustomFunction(&wgui_inline_items[j], mmi_phb_set_full_scr_lsk);
  657.     CGDetailsImageList[j++] = IMG_CG_NAME;
  658.     /* Alert Setting */
  659. #if !defined(__MMI_CALLERGROUP_NO_ALERT__)
  660.     SetInlineItemActivation(&wgui_inline_items[j], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  661.     SetInlineItemSelect(
  662.         &wgui_inline_items[j],
  663.         MAX_PB_ALERT_TYPES + 1,
  664.         g_phb_cntx.alert_name_list,
  665.         &g_phb_cntx.selected_alert_index);
  666.     CGDetailsImageList[j++] = IMG_CG_ALERT_TYPE;
  667. #endif /* !defined(__MMI_CALLERGROUP_NO_ALERT__) */ 
  668.     /* Ring Tone Setting */
  669.     SetInlineItemActivation(&wgui_inline_items[j], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  670.     SetInlineItemSelect(
  671.         &wgui_inline_items[j],
  672.         g_phb_cntx.total_ring_tone,
  673.         g_phb_cntx.ring_tone_name_list,
  674.         &g_phb_cntx.selected_ring_index);
  675.     RegisterInlineSelectHighlightHandler(&wgui_inline_items[j], mmi_phb_ring_tone_highlight_hdlr);
  676.     CGDetailsImageList[j++] = IMG_CG_RING_TONE;
  677.     /* Associate Picture */
  678.     SetInlineItemActivation(&wgui_inline_items[j], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  679.     SetInlineItemSelect(
  680.         &wgui_inline_items[j],
  681.         g_phb_cntx.total_image_id,
  682.         g_phb_cntx.image_name_list,
  683.         &g_phb_cntx.selected_pic_index);
  684. #if defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__)
  685.     RegisterInlineSelectHighlightHandler(&wgui_inline_items[j], mmi_phb_image_highlight_hdlr);
  686. #endif 
  687.     gPictureItemIndex = j;
  688.     CGDetailsImageList[j++] = IMG_CG_PICTURE;
  689.     /* LED Setting */
  690. #if defined(__MMI_STATUS_LED__)
  691.     SetInlineItemActivation(&wgui_inline_items[j], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  692.     SetInlineItemSelect(
  693.         &wgui_inline_items[j],
  694.         MAX_PB_LED_PATTERNS + 1,
  695.         g_phb_cntx.led_name_list,
  696.         &g_phb_cntx.selected_pattern_index);
  697.     RegisterInlineSelectHighlightHandler(&wgui_inline_items[j], mmi_phb_led_pattern_highlight_hdlr);
  698.     CGDetailsImageList[j++] = IMG_CG_INDICATOR_LITE;
  699. #endif /* defined(__MMI_STATUS_LED__) */ 
  700.     /* Incoming call video */
  701. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  702.     SetInlineItemActivation(&wgui_inline_items[j], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  703.     SetInlineItemSelect(
  704.         &wgui_inline_items[j],
  705.         g_phb_cntx.total_video_id,
  706.         g_phb_cntx.video_name_list,
  707.         &g_phb_cntx.selected_video_index);
  708.     RegisterInlineSelectHighlightHandler(&wgui_inline_items[j], mmi_phb_video_highlight_hdlr);
  709.     g_phb_video_item_index = j;
  710.     CGDetailsImageList[j++] = IMG_ID_PHB_ASSOCIATE_VIDEO;
  711. #endif /* defined(__MMI_INCOMING_CALL_VIDEO__) */ 
  712.     /* Caller Group Member List */
  713. #if defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__)
  714.     SetInlineItemActivation(&wgui_inline_items[j], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  715.     SetInlineItemDisplayOnly(&wgui_inline_items[j], (U8*) GetString(STR_ID_PHB_CALLERGROUP_MEMBER_LIST));
  716.     g_phb_callergroup_member_index = j;
  717.     CGDetailsImageList[j++] = IMG_ID_PHB_CALLERGRP_MEMBER;
  718. #endif /* defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__) */ 
  719.     RegisterHighlightHandler(mmi_phb_callergroup_highlight_hdlr);
  720.     if (inputBuffer != NULL)
  721.     {
  722.         SetCategory57Data(wgui_inline_items, j, inputBuffer);
  723.         if (viewOnce)   /* Reconfig only if view fields has turned on */
  724.         {
  725.             viewOnce = FALSE;
  726.             /* If select from file but no image selected, clear it to default */
  727.             if ((g_phb_cntx.selected_pic_index == g_phb_cntx.total_image_id - 1) &&
  728.                 (g_phb_cntx.image_location == MMI_PHB_IMAGE_NO_SELECT))
  729.             {
  730.                 g_phb_cntx.selected_pic_index = 0;
  731.             }
  732.             else if (g_phb_cntx.selected_pic_index != g_phb_cntx.total_image_id - 1)
  733.             {
  734.                 g_phb_cntx.selected_pic_index = g_phb_cntx.selected_pic_in_view;
  735.             }
  736.             ReConfigureInlineItemSelect(
  737.                 &wgui_inline_items[gPictureItemIndex],
  738.                 g_phb_cntx.total_image_id,
  739.                 g_phb_cntx.image_name_list,
  740.                 &g_phb_cntx.selected_pic_index);
  741.         #if defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__)
  742.             RegisterInlineSelectHighlightHandler(&wgui_inline_items[gPictureItemIndex], mmi_phb_image_highlight_hdlr);
  743.         #endif 
  744.             SetInlineDoneFlag(guiBuffer);
  745.         }
  746.     #if defined(__MMI_INCOMING_CALL_VIDEO__)
  747.         if (g_phb_video_view)
  748.         {
  749.             g_phb_video_view = FALSE;
  750.             if ((g_phb_cntx.selected_video_index == g_phb_cntx.total_video_id - 1) &&
  751.                 (g_phb_cntx.video_location == MMI_PHB_IMAGE_NO_SELECT))
  752.             {
  753.                 g_phb_cntx.selected_video_index = 0;
  754.             }
  755.             ReConfigureInlineItemSelect(
  756.                 &wgui_inline_items[g_phb_video_item_index],
  757.                 g_phb_cntx.total_video_id,
  758.                 g_phb_cntx.video_name_list,
  759.                 &g_phb_cntx.selected_video_index);
  760.             RegisterInlineSelectHighlightHandler(
  761.                 &wgui_inline_items[g_phb_video_item_index],
  762.                 mmi_phb_video_highlight_hdlr);
  763.             SetInlineDoneFlag(guiBuffer);
  764.         }
  765.     #ifdef __MMI_SWFLASH__
  766.         else if (g_phb_swflash_view)
  767.         {
  768.             g_phb_swflash_view = FALSE;
  769.             if ((g_phb_cntx.selected_video_index == g_phb_cntx.total_video_id - 2) &&
  770.                 (g_phb_cntx.video_location == MMI_PHB_IMAGE_NO_SELECT))
  771.             {
  772.                 g_phb_cntx.selected_video_index = 0;
  773.             }
  774.             ReConfigureInlineItemSelect(
  775.                 &wgui_inline_items[g_phb_video_item_index],
  776.                 g_phb_cntx.total_video_id,
  777.                 g_phb_cntx.video_name_list,
  778.                 &g_phb_cntx.selected_video_index);
  779.             RegisterInlineSelectHighlightHandler(&wgui_inline_items[g_phb_video_item_index], mmi_phb_video_highlight_hdlr);
  780.             SetInlineDoneFlag(guiBuffer);
  781.         }
  782.     #endif /*  __MMI_SWFLASH__ */
  783.     #endif /* defined(__MMI_INCOMING_CALL_VIDEO__) */ 
  784.     }
  785.     ShowCategory57Screen(
  786.         STR_SCR_CG_DETAILS_CAPTION,
  787.         IMG_SCR_PBOOK_CAPTION,
  788.         STR_GLOBAL_EDIT,
  789.         IMG_EDIT_LSK,
  790.         STR_GLOBAL_DONE,
  791.         IMG_DONE_RSK,
  792.         j,
  793.         CGDetailsImageList,
  794.         wgui_inline_items,
  795.         0,
  796.         guiBuffer);
  797. #ifdef __MMI_PHB_USIM_FIELD__
  798.     if (g_phb_cntx.active_index >= MAX_PB_CALLER_GROUPS)
  799.     {
  800.         SetCategory57RightSoftkeyFunctions(mmi_phb_gas_pre_save, GoBackHistory);
  801.     }
  802.     else
  803. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  804.         SetCategory57RightSoftkeyFunctions(mmi_phb_callergroup_detail_pre_save, GoBackHistory);
  805.     if (g_phb_cntx.set_done_flag)
  806.     {
  807.         g_phb_cntx.set_done_flag = 0;
  808.         set_wgui_inline_list_menu_changed();
  809.     }
  810. #ifdef __MMI_PROFILE_EXTMELODY_SUPPORT__
  811.     /* Check if associate audio in file system exists. */
  812.     if ((guiBuffer == NULL) &&
  813.         (callerGroups[g_phb_cntx.active_index].ringToneID >= PMG_EXT_MELODY_BEGIN) &&
  814.         (callerGroups[g_phb_cntx.active_index].ringToneID <= PMG_EXT_MELODY_END) &&
  815.         !PmgQueryFileExistById(callerGroups[g_phb_cntx.active_index].ringToneID))
  816.     {
  817.         DisplayPopup(
  818.             (PU8) GetString(STR_ID_PHB_AUDIO_ID_NOT_EXIST),
  819.             IMG_GLOBAL_ERROR,
  820.             FALSE,
  821.             PHB_NOTIFY_TIMEOUT,
  822.             ERROR_TONE);
  823.     }
  824. #endif /* __MMI_PROFILE_EXTMELODY_SUPPORT__ */ 
  825. #if defined __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  826.     if (guiBuffer == NULL && found_theme_tone == FALSE)
  827.     {
  828.         DisplayPopup(
  829.           (PU8) GetString(STR_ID_PHB_THEME_TONE_NOT_FOUND),
  830.           IMG_GLOBAL_ERROR,
  831.           FALSE,
  832.           PHB_NOTIFY_TIMEOUT,
  833.           ERROR_TONE);
  834.     }
  835. #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */
  836. }
  837. /*****************************************************************************
  838.  * FUNCTION
  839.  *  mmi_phb_exit_callergroup_detail
  840.  * DESCRIPTION
  841.  *  Exit function for mmi_phb_entry_callergroup_detail()
  842.  * PARAMETERS
  843.  *  void
  844.  * RETURNS
  845.  *  void
  846.  *****************************************************************************/
  847. void mmi_phb_exit_callergroup_detail(void)
  848. {
  849.     /*----------------------------------------------------------------*/
  850.     /* Local Variables                                                */
  851.     /*----------------------------------------------------------------*/
  852.     history h;
  853.     U16 inputBufferSize;
  854.     /*----------------------------------------------------------------*/
  855.     /* Code Body                                                      */
  856.     /*----------------------------------------------------------------*/
  857.     g_phb_cntx.end_scr_id = SCR_CALLER_GRP_DETAILS;
  858.     gPictureItemIndex = 10;
  859.     mmi_phb_stop_ring_tone_id();
  860.     mmi_phb_stop_led_pattern_id();
  861.     CloseCategory57Screen();
  862.     h.scrnID = SCR_CALLER_GRP_DETAILS;
  863.     h.entryFuncPtr = mmi_phb_entry_callergroup_detail;
  864.     GetCategoryHistory(h.guiBuffer);
  865.     inputBufferSize = (U16) GetCategory57DataSize();
  866.     GetCategory57Data((U8*) h.inputBuffer);
  867.     AddNHistory(h, inputBufferSize);
  868. }
  869. /*****************************************************************************
  870.  * FUNCTION
  871.  *  mmi_phb_callergroup_highlight_hdlr
  872.  * DESCRIPTION
  873.  *  Highlight handler for Caller Groups details screen
  874.  * PARAMETERS
  875.  *  index       [IN]        Highlight position
  876.  * RETURNS
  877.  *  void
  878.  *****************************************************************************/
  879. void mmi_phb_callergroup_highlight_hdlr(S32 index)
  880. {
  881.     /*----------------------------------------------------------------*/
  882.     /* Local Variables                                                */
  883.     /*----------------------------------------------------------------*/
  884.     /*----------------------------------------------------------------*/
  885.     /* Code Body                                                      */
  886.     /*----------------------------------------------------------------*/
  887.     mmi_phb_stop_ring_tone_id();
  888.     mmi_phb_stop_led_pattern_id();
  889.     /* Highlight on image item */
  890. #if defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__)
  891.     if ((index == gPictureItemIndex) && (g_phb_cntx.selected_pic_index == (g_phb_cntx.total_image_id - 1)))     /* View Image File */
  892.     {
  893.         ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  894.         SetLeftSoftkeyFunction(mmi_phb_image_pre_entry_option, KEY_EVENT_UP);
  895.     }
  896.     else if ((index == gPictureItemIndex) && (g_phb_cntx.selected_pic_index < (g_phb_cntx.total_image_id - 1))) /* View Image ID through Category screen */
  897.     {
  898.         ChangeLeftSoftkey(STR_VIEW_LSK, IMG_VIEW_LSK);
  899.         SetLeftSoftkeyFunction(mmi_phb_entry_op_edit_view_picture, KEY_EVENT_UP);
  900.     }
  901. #else /* defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__) */ 
  902.     if (index == gPictureItemIndex)
  903.     {
  904.         ChangeLeftSoftkey(STR_VIEW_LSK, IMG_VIEW_LSK);
  905.         SetLeftSoftkeyFunction(mmi_phb_entry_op_edit_view_picture, KEY_EVENT_UP);
  906.     }
  907. #endif /* defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__) */ 
  908.     /* Highlight on incoming call video item */
  909. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  910.     if (index == g_phb_video_item_index)
  911.     {
  912.         if (g_phb_cntx.selected_video_index == (g_phb_cntx.total_video_id - 1))
  913.         {
  914.             ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  915.             SetLeftSoftkeyFunction(mmi_phb_video_pre_entry_file_option, KEY_EVENT_UP);
  916.         }
  917.         else if (g_phb_cntx.selected_video_index != 0)
  918.         {
  919.             ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  920.             SetLeftSoftkeyFunction(mmi_phb_entry_video_default_option, KEY_EVENT_UP);
  921.         }
  922.         else
  923.         {
  924.             ChangeLeftSoftkey(0, 0);
  925.             ClearKeyHandler(KEY_LSK, KEY_EVENT_UP);
  926.         }
  927.     }
  928. #endif /* defined(__MMI_INCOMING_CALL_VIDEO__) */ 
  929.     /* Highlight on member list item */
  930. #if defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__)
  931.     if (index == g_phb_callergroup_member_index)
  932.     {
  933.         ChangeLeftSoftkey(STR_GLOBAL_OK, STR_GLOBAL_OK);
  934.         SetLeftSoftkeyFunction(mmi_phb_callergroup_member_pre_enter_list, KEY_EVENT_UP);
  935.     }
  936. #endif /* defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__) */ 
  937. }
  938. /*****************************************************************************
  939.  * FUNCTION
  940.  *  mmi_phb_callergroup_name_is_duplicated
  941.  * DESCRIPTION
  942.  *  Checks if name is duplicated before saving the Caller Group details
  943.  * PARAMETERS
  944.  *  void
  945.  * RETURNS
  946.  *  void
  947.  *****************************************************************************/
  948. BOOL mmi_phb_callergroup_name_is_duplicated(U16 group_index, S8* group_name)
  949. {
  950.     /*----------------------------------------------------------------*/
  951.     /* Local Variables                                                */
  952.     /*----------------------------------------------------------------*/
  953.     U8 i;
  954.     PHB_CALLER_GROUP_STRUCT *callerGroups;
  955.     /*----------------------------------------------------------------*/
  956.     /* Code Body                                                      */
  957.     /*----------------------------------------------------------------*/
  958.     callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  959.     /* Each group name can not be the same. */
  960.     for (i = 0; i < MAX_PB_CALLER_GROUPS; ++i)
  961.     {
  962.         if (i != group_index)
  963.         {
  964.             if (!pfnUnicodeStrcmp((PS8) callerGroups[i].groupName, group_name))
  965.             {
  966.                 return TRUE;
  967.             }
  968.         }
  969.     }
  970.     return FALSE;
  971. }
  972. /*****************************************************************************
  973.  * FUNCTION
  974.  *  mmi_phb_callergroup_detail_pre_save
  975.  * DESCRIPTION
  976.  *  Checks before saving the Caller Group details
  977.  * PARAMETERS
  978.  *  void
  979.  * RETURNS
  980.  *  void
  981.  *****************************************************************************/
  982. void mmi_phb_callergroup_detail_pre_save(void)
  983. {
  984.     /*----------------------------------------------------------------*/
  985.     /* Local Variables                                                */
  986.     /*----------------------------------------------------------------*/
  987.     /*----------------------------------------------------------------*/
  988.     /* Code Body                                                      */
  989.     /*----------------------------------------------------------------*/
  990.     if (mmi_phb_callergroup_name_is_duplicated(g_phb_cntx.active_index, pbName))
  991.     {
  992.         DisplayPopup((PU8) GetString(STR_CG_RENAME_FAIL_MSG), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  993.     }
  994.     else
  995.     {
  996.         mmi_phb_entry_callergroup_detail_save_confirm();
  997.     }
  998. }
  999. /*****************************************************************************
  1000.  * FUNCTION
  1001.  *  mmi_phb_entry_callergroup_detail_save_confirm
  1002.  * DESCRIPTION
  1003.  *  Confirms for saving Caller groups details
  1004.  * PARAMETERS
  1005.  *  void
  1006.  * RETURNS
  1007.  *  void
  1008.  *****************************************************************************/
  1009. void mmi_phb_entry_callergroup_detail_save_confirm(void)
  1010. {
  1011.     /*----------------------------------------------------------------*/
  1012.     /* Local Variables                                                */
  1013.     /*----------------------------------------------------------------*/
  1014.     /*----------------------------------------------------------------*/
  1015.     /* Code Body                                                      */
  1016.     /*----------------------------------------------------------------*/
  1017.     DisplayConfirm(
  1018.         STR_GLOBAL_YES,
  1019.         IMG_GLOBAL_YES,
  1020.         STR_GLOBAL_NO,
  1021.         IMG_GLOBAL_NO,
  1022.         get_string(STR_GLOBAL_SAVE),
  1023.         IMG_GLOBAL_QUESTION,
  1024.         WARNING_TONE);
  1025. #ifdef __MMI_PHB_USIM_FIELD__
  1026.     if (g_phb_cntx.active_index >= MAX_PB_CALLER_GROUPS)
  1027.     {
  1028.         SetLeftSoftkeyFunction(mmi_phb_gas_save_req, KEY_EVENT_UP);
  1029.     }
  1030.     else
  1031. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  1032.         SetLeftSoftkeyFunction(mmi_phb_callergroup_detail_save, KEY_EVENT_UP);
  1033.     SetRightSoftkeyFunction(mmi_phb_go_back_2_history, KEY_EVENT_UP);
  1034. }
  1035. /*****************************************************************************
  1036.  * FUNCTION
  1037.  *  mmi_phb_callergroup_detail_save
  1038.  * DESCRIPTION
  1039.  *  Saves the Caller Group details on the NVRAM
  1040.  * PARAMETERS
  1041.  *  void
  1042.  * RETURNS
  1043.  *  void
  1044.  *****************************************************************************/
  1045. void mmi_phb_callergroup_detail_save(void)
  1046. {
  1047.     /*----------------------------------------------------------------*/
  1048.     /* Local Variables                                                */
  1049.     /*----------------------------------------------------------------*/
  1050.     S16 pError;
  1051.     BOOL copy_image = TRUE, copy_video = TRUE;
  1052.     PHB_CALLER_GROUP_STRUCT *callerGroups;
  1053.     /*----------------------------------------------------------------*/
  1054.     /* Code Body                                                      */
  1055.     /*----------------------------------------------------------------*/
  1056.     mmi_phb_show_in_progress(STR_GLOBAL_SAVING, IMG_GLOBAL_SAVE);
  1057.     callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  1058.     pfnUnicodeStrcpy((S8*) callerGroups[g_phb_cntx.active_index].groupName, pbName);
  1059.     /* Ring Tone Setting */
  1060.     callerGroups[g_phb_cntx.active_index].ringToneID = g_phb_cntx.ring_tone_list[g_phb_cntx.selected_ring_index];
  1061.     /* Image Setting */
  1062. #if defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__)
  1063.     if (g_phb_cntx.selected_pic_index != g_phb_cntx.total_image_id - 1) /* De-select the file if selection is not from file. */
  1064.     {
  1065.         g_phb_cntx.image_location = MMI_PHB_IMAGE_NO_SELECT;
  1066.     }
  1067.     else if (g_phb_cntx.image_location == MMI_PHB_IMAGE_NO_SELECT)      /* Set selection to none if not select picture from file */
  1068.     {
  1069.         g_phb_cntx.selected_pic_index = 0;
  1070.     }
  1071.     copy_image = mmi_phb_image_update_by_index((U16) (g_phb_cntx.active_index + 5001)); /* Copy image to folder in file system, 5001 for group 1 and so on. */
  1072.     if (!copy_image)    /* Edit image fail. */
  1073.     {
  1074.         g_phb_cntx.selected_pic_index = 0;
  1075.     }
  1076.     if (g_phb_cntx.selected_pic_index == g_phb_cntx.total_image_id - 1)
  1077.     {
  1078.         callerGroups[g_phb_cntx.active_index].pictureTagID = 1;
  1079.     }
  1080.     else
  1081. #endif /* defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__) */ 
  1082.         callerGroups[g_phb_cntx.active_index].pictureTagID = g_phb_cntx.image_id_list[g_phb_cntx.selected_pic_index];
  1083.     /* Alert Setting */
  1084. #if defined(__MMI_CALLERGROUP_NO_ALERT__)
  1085.     callerGroups[g_phb_cntx.active_index].alertType = MMI_ALERT_NONE;
  1086. #else 
  1087.     callerGroups[g_phb_cntx.active_index].alertType = (MMI_ALERT_TYPE) g_phb_cntx.selected_alert_index;
  1088. #endif 
  1089.     /* LED setting */
  1090. #if defined(__MMI_STATUS_LED__)
  1091.     callerGroups[g_phb_cntx.active_index].LEDPatternId = (U8) g_phb_cntx.selected_pattern_index;
  1092. #else 
  1093.     callerGroups[g_phb_cntx.active_index].LEDPatternId = 0; /* no pattern */
  1094. #endif 
  1095.     /* Incoming call video setting */
  1096. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  1097.     callerGroups[g_phb_cntx.active_index].VideoID = mmi_phb_video_update_by_index_for_path(callerGroups[g_phb_cntx.active_index].VideoID, &copy_video);
  1098. #endif 
  1099.     /* Check if name is modified. */
  1100.     if ((callerGroups[g_phb_cntx.active_index].is_modified == 0) &&
  1101.         (pfnUnicodeStrcmp
  1102.          ((S8*) callerGroups[g_phb_cntx.active_index].groupName,
  1103.           GetString((U16) (STR_CALLER_GROUP_1 + g_phb_cntx.active_index))) != 0))
  1104.     {
  1105.         callerGroups[g_phb_cntx.active_index].is_modified = 1;
  1106.     }
  1107.     WriteRecord(NVRAM_EF_PHB_CALLER_GROUPS_LID, 1, callerGroups, CALLER_GROUPS_RECORD_SIZE, &pError);
  1108.     /* Data update success, but image or video add fail */
  1109.     if (!copy_image || !copy_video)
  1110.     {
  1111.         S8 str_buff[64 * 2];
  1112.         memset(str_buff, 0, 2);
  1113.         if (!copy_image)
  1114.         {
  1115.             pfnUnicodeStrcat(str_buff, GetString(STR_ID_PHB_OP_IMAGE_FAIL));
  1116.         }
  1117.         if (!copy_video)
  1118.         {
  1119.             if (!copy_image)
  1120.             {
  1121.                 pfnUnicodeStrcat(str_buff, GetString(STR_ID_PHB_OP_COMMA));
  1122.             }
  1123.             pfnUnicodeStrcat(str_buff, GetString(STR_ID_PHB_OP_VIDEO_FAIL));
  1124.         }
  1125.         pfnUnicodeStrcat(str_buff, GetString(STR_ID_PHB_EDIT_FAIL));
  1126.         DisplayPopup((U8*) str_buff, IMG_GLOBAL_ERROR, TRUE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  1127.     }
  1128.     else
  1129.     {
  1130.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, TRUE, PHB_NOTIFY_TIMEOUT, SUCCESS_TONE);
  1131.     }
  1132.     if (!DeleteNScrId(SCR_ID_PHB_FMGR_SAVE_OPTION)) /* Enter From Save image from file manager */
  1133.     {
  1134.         DeleteNScrId(SCR_CALLER_GRP_DETAILS);   /* Enter from caller group */
  1135.     }
  1136. }
  1137. #define MMI_PHB_CALLER_GROUP_MEMBER
  1138. /*-------------------------------------------------Caller Group Member List -----------------------------------------------------------*/
  1139. #if defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__)
  1140. /*****************************************************************************
  1141.  * FUNCTION
  1142.  *  mmi_phb_highlight_callergroup_member_add
  1143.  * DESCRIPTION
  1144.  *  Highlight function.
  1145.  * PARAMETERS
  1146.  *  void
  1147.  * RETURNS
  1148.  *  void
  1149.  *****************************************************************************/
  1150. void mmi_phb_highlight_callergroup_member_add(void)
  1151. {
  1152.     /*----------------------------------------------------------------*/
  1153.     /* Local Variables                                                */
  1154.     /*----------------------------------------------------------------*/
  1155.     /*----------------------------------------------------------------*/
  1156.     /* Code Body                                                      */
  1157.     /*----------------------------------------------------------------*/
  1158.     SetLeftSoftkeyFunction(mmi_phb_callergroup_member_pre_enter_add, KEY_EVENT_UP);
  1159.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1160.     SetKeyHandler(mmi_phb_callergroup_member_pre_enter_add, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1161.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1162. }
  1163. /*****************************************************************************
  1164.  * FUNCTION
  1165.  *  mmi_phb_highlight_callergroup_member_delete
  1166.  * DESCRIPTION
  1167.  *  Highlight function
  1168.  * PARAMETERS
  1169.  *  void
  1170.  * RETURNS
  1171.  *  void
  1172.  *****************************************************************************/
  1173. void mmi_phb_highlight_callergroup_member_delete(void)
  1174. {
  1175.     /*----------------------------------------------------------------*/
  1176.     /* Local Variables                                                */
  1177.     /*----------------------------------------------------------------*/
  1178.     /*----------------------------------------------------------------*/
  1179.     /* Code Body                                                      */
  1180.     /*----------------------------------------------------------------*/
  1181.     SetLeftSoftkeyFunction(mmi_phb_entry_callergroup_member_delete, KEY_EVENT_UP);
  1182.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1183.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1184.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1185. }
  1186. /*****************************************************************************
  1187.  * FUNCTION
  1188.  *  mmi_phb_entry_callergroup_member_list
  1189.  * DESCRIPTION
  1190.  *  Entry function of phonebook caller group member list.
  1191.  *  Will show list if any entry exists, or will display "add" screen at begin.
  1192.  * PARAMETERS
  1193.  *  void
  1194.  * RETURNS
  1195.  *  void
  1196.  *****************************************************************************/
  1197. void mmi_phb_entry_callergroup_member_list(void)
  1198. {
  1199.     /*----------------------------------------------------------------*/
  1200.     /* Local Variables                                                */
  1201.     /*----------------------------------------------------------------*/
  1202.     U8 *guiBuffer;
  1203.     S8 state;
  1204.     /*----------------------------------------------------------------*/
  1205.     /* Code Body                                                      */
  1206.     /*----------------------------------------------------------------*/
  1207.     EntryNewScreen(SCR_ID_PHB_CALLERGROUP_MEMBER_LIST, mmi_phb_exit_callergroup_member_list, NULL, NULL);
  1208.     guiBuffer = GetCurrGuiBuffer(SCR_ID_PHB_CALLERGROUP_MEMBER_LIST);
  1209.     state = (S8) - 1;
  1210.     if (guiBuffer != NULL)
  1211.     {
  1212.         state = get_list_menu_category_history_state(SCR_ID_PHB_CALLERGROUP_MEMBER_LIST, guiBuffer);
  1213.         if (state != -1)
  1214.         {
  1215.             phbListView = (U8) state;
  1216.             g_phb_callergroup_member_count = mmi_phb_callergroup_member_count_number((U8) phbListView);
  1217.         }
  1218.     }
  1219. #ifdef __MMI_PHB_USIM_FIELD__
  1220.     if (g_phb_cntx.active_index < MAX_PB_CALLER_GROUPS)
  1221. #endif 
  1222.     {
  1223.         /* Allocate a buffer to store caller group of each entry to enhance speed. */
  1224.         if (g_phb_callergroup_ptr == NULL)
  1225.     #if (MAX_PB_ENTRIES >= 1000)
  1226.             g_phb_callergroup_ptr = (U16*) g_phb_list_filter;
  1227.     #else /* (MAX_PB_ENTRIES >= 1000) */ 
  1228.     #if defined(__MMI_PHB_CALLERGROUP_IN_SIM__)     /* Associate caller group in SIM card entry */
  1229.             g_phb_callergroup_ptr = OslMalloc(MAX_PB_ENTRIES * sizeof(U16));
  1230.     #else 
  1231.             g_phb_callergroup_ptr = OslMalloc(MAX_PB_PHONE_ENTRIES * sizeof(U16));
  1232.     #endif 
  1233.     #endif /* (MAX_PB_ENTRIES >= 1000) */ /* MAX_PB_ENTRIES >= 1000 */
  1234.         /* After allocate buffer, make cache for caller group of each entry. */
  1235.         mmi_phb_callergroup_member_make_group_id_cache();
  1236.     }
  1237.     if (phbListView == MMI_PHB_LIST_FOR_VIEW_MEMBER_LIST)
  1238.     {
  1239.         /* Build alpha index list */
  1240.     #if defined(__MMI_PHB_CALLERGROUP_IN_SIM__)     /* Associate caller group in SIM card entry */
  1241.         mmi_phb_list_build_alpha_index(
  1242.             g_phb_callergroup_ptr,
  1243.             (U16) (g_phb_cntx.active_index + 1),
  1244.             TRUE,
  1245.             MMI_STORAGE_NONE);
  1246.     #else /* defined(__MMI_PHB_CALLERGROUP_IN_SIM__) */ 
  1247.     #ifdef __MMI_PHB_USIM_FIELD__
  1248.         if (g_phb_cntx.active_index >= MAX_PB_CALLER_GROUPS)
  1249.         {
  1250.             mmi_phb_list_build_alpha_index(
  1251.                 (U16*) g_phb_cntx.group_type,
  1252.                 (U16) (g_phb_cntx.active_index + 1 - MAX_PB_CALLER_GROUPS),
  1253.                 TRUE,
  1254.                 MMI_SIM);
  1255.         }
  1256.         else
  1257.     #endif /* __MMI_PHB_USIM_FIELD__ */ 
  1258.             mmi_phb_list_build_alpha_index(g_phb_callergroup_ptr, (U16) (g_phb_cntx.active_index + 1), TRUE, MMI_NVRAM);
  1259.     #endif /* defined(__MMI_PHB_CALLERGROUP_IN_SIM__) */ 
  1260.         g_phb_cntx.refresh_list = 1;
  1261.         RegisterHighlightHandler(mmi_phb_get_index_second_level);
  1262.         ShowCategory184Screen(
  1263.             STR_ID_PHB_CALLERGROUP_MEMBER_LIST,
  1264.             IMG_SCR_PBOOK_CAPTION,
  1265.             STR_GLOBAL_OPTIONS,
  1266.             IMG_GLOBAL_OPTIONS,
  1267.             STR_GLOBAL_BACK,
  1268.             IMG_GLOBAL_BACK,
  1269.             g_phb_callergroup_member_count,
  1270.             mmi_phb_callergroup_member_list_get_item,
  1271.             mmi_phb_callergroup_member_list_get_hint,
  1272.             g_phb_cntx.highlight_entry,
  1273.             guiBuffer);
  1274.         SetLeftSoftkeyFunction(mmi_phb_entry_callergroup_member_option, KEY_EVENT_UP);
  1275.         SetKeyHandler(mmi_phb_entry_callergroup_member_option, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1276.     }
  1277.     else if (phbListView == MMI_PHB_LIST_FOR_ADD_MEMBER_LIST)
  1278.     {
  1279.         /* Build alpha index list */
  1280.     #if defined(__MMI_PHB_CALLERGROUP_IN_SIM__)     /* Associate caller group in SIM card entry */
  1281.         mmi_phb_list_build_alpha_index(
  1282.             (U16*) g_phb_callergroup_ptr,
  1283.             (U16) (g_phb_cntx.active_index + 1),
  1284.             FALSE,
  1285.             MMI_STORAGE_NONE);
  1286.     #else /* defined(__MMI_PHB_CALLERGROUP_IN_SIM__) */ 
  1287.         mmi_phb_list_build_alpha_index(
  1288.             (U16*) g_phb_callergroup_ptr,
  1289.             (U16) (g_phb_cntx.active_index + 1),
  1290.             FALSE,
  1291.             MMI_NVRAM);
  1292.     #endif /* defined(__MMI_PHB_CALLERGROUP_IN_SIM__) */ 
  1293.         g_phb_cntx.refresh_list = 1;
  1294.         RegisterHighlightHandler(mmi_phb_get_index_third_level);
  1295.         ShowCategory184Screen(
  1296.             STR_SCR_PBOOK_VIEW_CAPTION,
  1297.             IMG_SCR_PBOOK_CAPTION,
  1298.             STR_GLOBAL_ADD,
  1299.             0,
  1300.             STR_GLOBAL_BACK,
  1301.             0,
  1302.             g_phb_callergroup_member_count,
  1303.             mmi_phb_callergroup_member_list_get_item,
  1304.             mmi_phb_callergroup_member_list_get_hint,
  1305.             g_phb_cntx.highlight_entry,
  1306.             guiBuffer);
  1307.         SetLeftSoftkeyFunction(mmi_phb_entry_callergroup_member_add, KEY_EVENT_UP);
  1308.     }
  1309.     /* register multitap key for fast jump by alpha index */
  1310.     register_multitap_no_draw_key_handlers();
  1311.     set_multitap_functions(mmi_phb_list_alpha_index, mmi_phb_list_alpha_index_input_callback);
  1312.     change_multitap_mode(0);
  1313.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1314.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1315. }
  1316. /*****************************************************************************
  1317.  * FUNCTION
  1318.  *  mmi_phb_exit_callergroup_member_list
  1319.  * DESCRIPTION
  1320.  *  Exit function of caller group member list.
  1321.  * PARAMETERS
  1322.  *  void
  1323.  * RETURNS
  1324.  *  void
  1325.  *****************************************************************************/
  1326. void mmi_phb_exit_callergroup_member_list(void)
  1327. {
  1328.     /*----------------------------------------------------------------*/
  1329.     /* Local Variables                                                */
  1330.     /*----------------------------------------------------------------*/
  1331.     history h;
  1332.     S16 nHistory = 0;
  1333.     S8 state = (S8) phbListView;
  1334.     /*----------------------------------------------------------------*/
  1335.     /* Code Body                                                      */
  1336.     /*----------------------------------------------------------------*/
  1337.     g_phb_cntx.end_scr_id = SCR_ID_PHB_CALLERGROUP_MEMBER_LIST;
  1338.     h.scrnID = SCR_ID_PHB_CALLERGROUP_MEMBER_LIST;
  1339.     h.entryFuncPtr = mmi_phb_entry_callergroup_member_list;
  1340.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  1341.     GetCategoryHistory(h.guiBuffer);
  1342.     set_list_menu_category_history_state(SCR_ID_PHB_CALLERGROUP_MEMBER_LIST, h.guiBuffer, state);
  1343.     AddHistory(h);
  1344.     /* Free memory */
  1345. #if (MAX_PB_ENTRIES < 1000)
  1346.     if (g_phb_callergroup_ptr)
  1347.     {
  1348.         OslMfree(g_phb_callergroup_ptr);
  1349.         g_phb_callergroup_ptr = NULL;
  1350.     }
  1351. #endif /* (MAX_PB_ENTRIES < 1000) */ /* MAX_PB_ENTRIES < 1000 */
  1352. }
  1353. /*****************************************************************************
  1354.  * FUNCTION
  1355.  *  mmi_phb_entry_callergroup_member_option
  1356.  * DESCRIPTION
  1357.  *  Entry function of caller group member list options.
  1358.  * PARAMETERS
  1359.  *  void
  1360.  * RETURNS
  1361.  *  void
  1362.  *****************************************************************************/
  1363. void mmi_phb_entry_callergroup_member_option(void)
  1364. {
  1365.     /*----------------------------------------------------------------*/
  1366.     /* Local Variables                                                */
  1367.     /*----------------------------------------------------------------*/
  1368.     U8 *guiBuffer;
  1369.     U16 nStrItemList[2];
  1370.     U16 nNumofItem;
  1371.     /*----------------------------------------------------------------*/
  1372.     /* Code Body                                                      */
  1373.     /*----------------------------------------------------------------*/
  1374.     EntryNewScreen(
  1375.         SCR_ID_PHB_CALLERGROUP_MEMBER_VIEW_OPTION,
  1376.         mmi_phb_exit_callergroup_member_option,
  1377.         mmi_phb_entry_callergroup_member_option,
  1378.         NULL);
  1379.     guiBuffer = GetCurrGuiBuffer(SCR_ID_PHB_CALLERGROUP_MEMBER_VIEW_OPTION);
  1380.     nNumofItem = GetNumOfChild(MENU_ID_PHB_CALLERGROUP_MEMBER_VIEW_OPTION);
  1381.     GetSequenceStringIds(MENU_ID_PHB_CALLERGROUP_MEMBER_VIEW_OPTION, nStrItemList);
  1382.     SetParentHandler(MENU_ID_PHB_CALLERGROUP_MEMBER_VIEW_OPTION);
  1383.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1384.     /* Show Add New Only. */
  1385.     if (((guiBuffer == NULL) && (g_phb_callergroup_member_count == 0)) ||
  1386.         (mmi_phb_callergroup_member_count_number(MMI_PHB_LIST_FOR_VIEW_MEMBER_LIST) == 0))
  1387.     {
  1388.         nNumofItem = 1;
  1389.     }
  1390.     ShowCategory15Screen(
  1391.         STR_ID_PHB_CALLERGROUP_MEMBER_LIST,
  1392.         IMG_SCR_PBOOK_CAPTION,
  1393.         STR_GLOBAL_OK,
  1394.         IMG_GLOBAL_OK,
  1395.         STR_GLOBAL_BACK,
  1396.         IMG_GLOBAL_BACK,
  1397.         nNumofItem,
  1398.         nStrItemList,
  1399.         (U16*) gIndexIconsImageList,
  1400.         LIST_MENU,
  1401.         0,
  1402.         guiBuffer);
  1403. }
  1404. /*****************************************************************************
  1405.  * FUNCTION
  1406.  *  mmi_phb_exit_callergroup_member_option
  1407.  * DESCRIPTION
  1408.  *  Exit function
  1409.  * PARAMETERS
  1410.  *  void
  1411.  * RETURNS
  1412.  *  void
  1413.  *****************************************************************************/
  1414. void mmi_phb_exit_callergroup_member_option(void)
  1415. {
  1416.     /*----------------------------------------------------------------*/
  1417.     /* Local Variables                                                */
  1418.     /*----------------------------------------------------------------*/
  1419.     /*----------------------------------------------------------------*/
  1420.     /* Code Body                                                      */
  1421.     /*----------------------------------------------------------------*/
  1422.     g_phb_cntx.end_scr_id = SCR_ID_PHB_CALLERGROUP_MEMBER_VIEW_OPTION;
  1423. }
  1424. /*****************************************************************************
  1425.  * FUNCTION
  1426.  *  mmi_phb_entry_callergroup_member_add
  1427.  * DESCRIPTION
  1428.  *  This function is just for template.
  1429.  * PARAMETERS
  1430.  *  void
  1431.  * RETURNS
  1432.  *  void
  1433.  *****************************************************************************/
  1434. void mmi_phb_entry_callergroup_member_add(void)
  1435. {
  1436.     /*----------------------------------------------------------------*/
  1437.     /* Local Variables                                                */
  1438.     /*----------------------------------------------------------------*/
  1439.     /*----------------------------------------------------------------*/
  1440.     /* Code Body                                                      */
  1441.     /*----------------------------------------------------------------*/
  1442.     DisplayConfirm(
  1443.         STR_GLOBAL_YES,
  1444.         IMG_GLOBAL_YES,
  1445.         STR_GLOBAL_NO,
  1446.         IMG_GLOBAL_NO,
  1447.         get_string(STR_GLOBAL_ADD),
  1448.         IMG_GLOBAL_QUESTION,
  1449.         WARNING_TONE);
  1450. #ifdef __MMI_PHB_USIM_FIELD__
  1451.     if (g_phb_cntx.active_index >= MAX_PB_CALLER_GROUPS)
  1452.     {
  1453.         phb_delete_grp_flag = FALSE;
  1454.         SetLeftSoftkeyFunction(mmi_phb_callergroup_member_usim_set_req, KEY_EVENT_UP);
  1455.     }
  1456.     else
  1457. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  1458.         SetLeftSoftkeyFunction(mmi_phb_callergroup_member_add_member, KEY_EVENT_UP);
  1459.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1460. }
  1461. /*****************************************************************************
  1462.  * FUNCTION
  1463.  *  mmi_phb_entry_callergroup_member_delete
  1464.  * DESCRIPTION
  1465.  *  This function is just for template.
  1466.  * PARAMETERS
  1467.  *  void
  1468.  * RETURNS
  1469.  *  void
  1470.  *****************************************************************************/
  1471. void mmi_phb_entry_callergroup_member_delete(void)
  1472. {
  1473.     /*----------------------------------------------------------------*/
  1474.     /* Local Variables                                                */
  1475.     /*----------------------------------------------------------------*/
  1476.     /*----------------------------------------------------------------*/
  1477.     /* Code Body                                                      */
  1478.     /*----------------------------------------------------------------*/
  1479.     DisplayConfirm(
  1480.         STR_GLOBAL_YES,
  1481.         IMG_GLOBAL_YES,
  1482.         STR_GLOBAL_NO,
  1483.         IMG_GLOBAL_NO,
  1484.         get_string(STR_DELETE_QUERY_MSG),
  1485.         IMG_GLOBAL_QUESTION,
  1486.         WARNING_TONE);
  1487. #ifdef __MMI_PHB_USIM_FIELD__
  1488.     if (g_phb_cntx.active_index >= MAX_PB_CALLER_GROUPS)
  1489.     {
  1490.         phb_delete_grp_flag = TRUE;
  1491.         SetLeftSoftkeyFunction(mmi_phb_callergroup_member_usim_set_req, KEY_EVENT_UP);
  1492.     }
  1493.     else
  1494. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  1495.         SetLeftSoftkeyFunction(mmi_phb_callergroup_member_delete_member, KEY_EVENT_UP);
  1496.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1497. }
  1498. /*****************************************************************************
  1499.  * FUNCTION
  1500.  *  mmi_phb_callergroup_member_list_get_item
  1501.  * DESCRIPTION
  1502.  *  Item call back function for dynamic list
  1503.  * PARAMETERS
  1504.  *  item_index          [IN]        
  1505.  *  str_buff            [IN]        
  1506.  *  img_buff_p          [?]         
  1507.  *  str_img_mask        [IN]        
  1508.  * RETURNS
  1509.  *  void
  1510.  *****************************************************************************/
  1511. pBOOL mmi_phb_callergroup_member_list_get_item(
  1512.         S32 item_index,
  1513.         UI_string_type str_buff,
  1514.         PU8 *img_buff_p,
  1515.         U8 str_img_mask)
  1516. {
  1517.     /*----------------------------------------------------------------*/
  1518.     /* Local Variables                                                */
  1519.     /*----------------------------------------------------------------*/
  1520.     U16 i;
  1521.     /*----------------------------------------------------------------*/
  1522.     /* Code Body                                                      */
  1523.     /*----------------------------------------------------------------*/
  1524.     if ((item_index < 0) || (item_index > PhoneBookEntryCount))
  1525.     {
  1526.         return FALSE;
  1527.     }
  1528.     i = mmi_phb_callergroup_member_get_index((U8) phbListView, (U16) item_index);
  1529.     if (pfnUnicodeStrlen((S8*) PhoneBook[i].alpha_id.name))
  1530.     {
  1531.         pfnUnicodeStrcpy((S8*) str_buff, (S8*) PhoneBook[i].alpha_id.name);
  1532.     }
  1533.     else
  1534.     {
  1535.         mmi_phb_convert_get_ucs2_number((S8*) str_buff, i);
  1536.     }
  1537.     if (i < MAX_PB_PHONE_ENTRIES)
  1538.     {
  1539.         *img_buff_p = get_image(IMG_STORAGE_HANDSET);
  1540.     }
  1541.     else
  1542.     {
  1543.         *img_buff_p = get_image(IMG_STORAGE_SIM);
  1544.     }
  1545.     return TRUE;
  1546. }
  1547. /*****************************************************************************
  1548.  * FUNCTION
  1549.  *  mmi_phb_callergroup_member_list_get_hint
  1550.  * DESCRIPTION
  1551.  *  hint call back function for dynamic list
  1552.  * PARAMETERS
  1553.  *  item_index      [IN]        
  1554.  *  hint_array      [?]         
  1555.  * RETURNS
  1556.  *  void
  1557.  *****************************************************************************/
  1558. S32 mmi_phb_callergroup_member_list_get_hint(S32 item_index, UI_string_type *hint_array)
  1559. {
  1560.     /*----------------------------------------------------------------*/
  1561.     /* Local Variables                                                */
  1562.     /*----------------------------------------------------------------*/
  1563.     U16 i;
  1564.     S8 temp_number[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
  1565.     /*----------------------------------------------------------------*/
  1566.     /* Code Body                                                      */
  1567.     /*----------------------------------------------------------------*/
  1568.     if ((item_index < 0) || (item_index > PhoneBookEntryCount))
  1569.     {
  1570.         return FALSE;
  1571.     }
  1572.     i = mmi_phb_callergroup_member_get_index((U8) phbListView, (U16) item_index);
  1573.     mmi_phb_convert_get_ucs2_number((S8*) temp_number, i);
  1574.     if (pfnUnicodeStrlen((S8*) PhoneBook[i].alpha_id.name) && pfnUnicodeStrlen((S8*) temp_number))
  1575.     {
  1576.         pfnUnicodeStrcpy((S8*) hint_array[0], (S8*) temp_number);
  1577.     }
  1578.     else
  1579.     {
  1580.         return 0;
  1581.     }
  1582.     return 1;   /* One hint data only, can be more hints. */
  1583. }
  1584. /*****************************************************************************
  1585.  * FUNCTION
  1586.  *  mmi_phb_callergroup_member_pre_enter_list
  1587.  * DESCRIPTION
  1588.  *  This function is just for template.
  1589.  * PARAMETERS
  1590.  *  void
  1591.  * RETURNS
  1592.  *  void
  1593.  *****************************************************************************/
  1594. void mmi_phb_callergroup_member_pre_enter_list(void)
  1595. {
  1596.     /*----------------------------------------------------------------*/
  1597.     /* Local Variables                                                */
  1598.     /*----------------------------------------------------------------*/
  1599.     /*----------------------------------------------------------------*/
  1600.     /* Code Body                                                      */
  1601.     /*----------------------------------------------------------------*/
  1602. #ifdef __SYNCML_SUPPORT__
  1603.     if (mmi_syncml_is_phb_sync_now())
  1604.     {
  1605.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  1606.     }
  1607.     else
  1608. #endif /* __SYNCML_SUPPORT__ */
  1609.     if (g_phb_cntx.phb_ready && !g_phb_cntx.processing)
  1610.     {
  1611.         if (PhoneBookEntryCount)
  1612.         {
  1613.             g_phb_cntx.highlight_entry = 0;
  1614.             phbListView = MMI_PHB_LIST_FOR_VIEW_MEMBER_LIST;
  1615.             g_phb_callergroup_member_count = mmi_phb_callergroup_member_count_number((U8) phbListView);
  1616.             if (g_phb_callergroup_member_count > 0)
  1617.             {
  1618.                 mmi_phb_entry_callergroup_member_list();
  1619.             }
  1620.             else
  1621.             {
  1622.                 mmi_phb_entry_callergroup_member_option();
  1623.             }
  1624.         }
  1625.         else
  1626.         {
  1627.             DisplayPopup(
  1628.                 (PU8) GetString(STR_NO_ENTRIES_MESSAGE),
  1629.                 IMG_GLOBAL_EMPTY,
  1630.                 TRUE,
  1631.                 PHB_NOTIFY_TIMEOUT,
  1632.                 EMPTY_LIST_TONE);
  1633.         }
  1634.     }
  1635.     else
  1636.     {
  1637.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1638.     }
  1639. }
  1640. /*****************************************************************************
  1641.  * FUNCTION
  1642.  *  mmi_phb_callergroup_member_pre_enter_add
  1643.  * DESCRIPTION
  1644.  *  This function is just for template.
  1645.  * PARAMETERS
  1646.  *  void
  1647.  * RETURNS
  1648.  *  void
  1649.  *****************************************************************************/
  1650. void mmi_phb_callergroup_member_pre_enter_add(void)
  1651. {
  1652.     /*----------------------------------------------------------------*/
  1653.     /* Local Variables                                                */
  1654.     /*----------------------------------------------------------------*/
  1655.     /*----------------------------------------------------------------*/
  1656.     /* Code Body                                                      */
  1657.     /*----------------------------------------------------------------*/
  1658.     phbListView = MMI_PHB_LIST_FOR_ADD_MEMBER_LIST;
  1659.     g_phb_callergroup_member_count = mmi_phb_callergroup_member_count_number((U8) phbListView);
  1660.     if (g_phb_callergroup_member_count > 0)
  1661.     {
  1662.         mmi_phb_entry_callergroup_member_list();
  1663.     }
  1664.     else
  1665.     {
  1666.         DisplayPopup(
  1667.             (PU8) GetString(STR_ID_PHB_NO_ENTRY_TO_SELECT),
  1668.             IMG_GLOBAL_EMPTY,
  1669.             TRUE,
  1670.             PHB_NOTIFY_TIMEOUT,
  1671.             EMPTY_LIST_TONE);
  1672.     }
  1673. }
  1674. /*****************************************************************************
  1675.  * FUNCTION
  1676.  *  mmi_phb_callergroup_member_add_member
  1677.  * DESCRIPTION
  1678.  *  This function is just for template.
  1679.  * PARAMETERS
  1680.  *  void
  1681.  * RETURNS
  1682.  *  void
  1683.  *****************************************************************************/
  1684. void mmi_phb_callergroup_member_add_member(void)
  1685. {
  1686.     /*----------------------------------------------------------------*/
  1687.     /* Local Variables                                                */
  1688.     /*----------------------------------------------------------------*/
  1689.     U16 count, i;
  1690.     S16 pError;
  1691.     U16 store_index;
  1692.     U8 optid_record, optid_index, current_record = 0;
  1693.     PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
  1694.     /*----------------------------------------------------------------*/
  1695.     /* Code Body                                                      */
  1696.     /*----------------------------------------------------------------*/
  1697.     count = 0;
  1698.     for (i = 0; i < PhoneBookEntryCount; i++)
  1699.     {
  1700.         store_index = g_phb_name_index[i];
  1701.     #if !defined(__MMI_PHB_CALLERGROUP_IN_SIM__)    /* Associate caller group in SIM card entry */
  1702.         if (store_index < MAX_PB_PHONE_ENTRIES) /* In NVRAM */
  1703.     #endif 
  1704.         {
  1705.             /* Get optional IDs record. */
  1706.             optid_record = (store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
  1707.             optid_index = store_index - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
  1708.             if (optid_record != current_record)
  1709.             {
  1710.                 ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1711.                 current_record = optid_record;
  1712.             }
  1713.             /* Get index */
  1714.             if (PhbOptIDs[optid_index].callerGroupID != (g_phb_cntx.active_index + 1))
  1715.             {
  1716.                 if (count == g_phb_cntx.active_index_third)
  1717.                 {
  1718.                     break;
  1719.                 }
  1720.                 count++;
  1721.             }
  1722.         }
  1723.     }
  1724.     store_index = g_phb_name_index[i];
  1725.     /* Read optional ID field and write it back. */
  1726.     optid_record = (store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
  1727.     optid_index = store_index - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
  1728.     ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1729.     PhbOptIDs[optid_index].callerGroupID = g_phb_cntx.active_index + 1;
  1730.     WriteRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1731.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, TRUE, PHB_NOTIFY_TIMEOUT, SUCCESS_TONE);
  1732.     g_phb_callergroup_member_count++;
  1733.     g_phb_cntx.highlight_entry = 0;
  1734.     DeleteNScrId(SCR_ID_PHB_CALLERGROUP_MEMBER_VIEW_OPTION);
  1735.     phbListView = MMI_PHB_LIST_FOR_VIEW_MEMBER_LIST;
  1736.     g_phb_callergroup_member_count = mmi_phb_callergroup_member_count_number((U8) phbListView);
  1737.     if (g_phb_callergroup_member_count == 1)
  1738.     {
  1739.         mmi_phb_entry_callergroup_member_list();
  1740.     }
  1741. }
  1742. /*****************************************************************************
  1743.  * FUNCTION
  1744.  *  mmi_phb_callergroup_member_delete_member
  1745.  * DESCRIPTION
  1746.  *  This function is just for template.
  1747.  * PARAMETERS
  1748.  *  void
  1749.  * RETURNS
  1750.  *  void
  1751.  *****************************************************************************/
  1752. void mmi_phb_callergroup_member_delete_member(void)
  1753. {
  1754.     /*----------------------------------------------------------------*/
  1755.     /* Local Variables                                                */
  1756.     /*----------------------------------------------------------------*/
  1757.     U16 count, i;
  1758.     S16 pError;
  1759.     U16 store_index;
  1760.     U8 optid_record, optid_index, current_record = 0;
  1761.     PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
  1762.     /*----------------------------------------------------------------*/
  1763.     /* Code Body                                                      */
  1764.     /*----------------------------------------------------------------*/
  1765.     /* PHB_CALLER_GROUP_STRUCT* callerGroups; */
  1766.     /* callerGroups = (PHB_CALLER_GROUP_STRUCT*)g_phb_cntx.caller_group; */
  1767.     count = 0;
  1768.     for (i = 0; i < PhoneBookEntryCount; i++)
  1769.     {
  1770.         store_index = g_phb_name_index[i];
  1771.     #if !defined(__MMI_PHB_CALLERGROUP_IN_SIM__)    /* Associate caller group in SIM card entry */
  1772.         if (store_index < MAX_PB_PHONE_ENTRIES)
  1773.     #endif 
  1774.         {
  1775.             /* Get optional IDs record. */
  1776.             optid_record = (store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
  1777.             optid_index = store_index - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
  1778.             if (optid_record != current_record)
  1779.             {
  1780.                 ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1781.                 current_record = optid_record;
  1782.             }
  1783.             if ((g_phb_cntx.active_index + 1) == PhbOptIDs[optid_index].callerGroupID)
  1784.             {
  1785.                 if (count == g_phb_cntx.active_index_second)
  1786.                 {
  1787.                     break;
  1788.                 }
  1789.                 count++;
  1790.             }
  1791.         }
  1792.     }
  1793.     store_index = g_phb_name_index[i];
  1794.     /* Read optional ID field and write it back. */
  1795.     optid_record = (store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
  1796.     optid_index = store_index - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
  1797.     ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1798.     PhbOptIDs[optid_index].callerGroupID = 0;
  1799.     WriteRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1800.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, TRUE, PHB_NOTIFY_TIMEOUT, SUCCESS_TONE);
  1801.     if (mmi_phb_callergroup_member_count_number(MMI_PHB_LIST_FOR_VIEW_MEMBER_LIST) == 0)
  1802.     {
  1803.         DeleteNScrId(SCR_ID_PHB_CALLERGROUP_MEMBER_LIST);
  1804.     }
  1805.     else
  1806.     {
  1807.         g_phb_cntx.highlight_entry = 0;
  1808.         DeleteUptoScrID(SCR_ID_PHB_CALLERGROUP_MEMBER_LIST);
  1809.     }
  1810. }
  1811. /*****************************************************************************
  1812.  * FUNCTION
  1813.  *  mmi_phb_callergroup_member_count_number
  1814.  * DESCRIPTION
  1815.  *  This function is just for template.
  1816.  * PARAMETERS
  1817.  *  list_enum       [IN]        
  1818.  * RETURNS
  1819.  *  void
  1820.  *****************************************************************************/
  1821. U16 mmi_phb_callergroup_member_count_number(U8 list_enum)
  1822. {
  1823.     /*----------------------------------------------------------------*/
  1824.     /* Local Variables                                                */
  1825.     /*----------------------------------------------------------------*/
  1826.     U16 i, j, count = 0;
  1827.     S16 pError;
  1828.     U8 optid_record, optid_index, current_record = 0;
  1829.     PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
  1830.     /*----------------------------------------------------------------*/
  1831.     /* Code Body                                                      */
  1832.     /*----------------------------------------------------------------*/
  1833. #ifdef __MMI_PHB_USIM_FIELD__
  1834.     if (g_phb_cntx.active_index >= MAX_PB_CALLER_GROUPS)
  1835.     {
  1836.         for (i = 0; i < MAX_PB_SIM_ENTRIES; i++)
  1837.         {
  1838.             if (((list_enum == MMI_PHB_LIST_FOR_VIEW_MEMBER_LIST) &&
  1839.                  g_phb_cntx.group_type[i] == (g_phb_cntx.active_index - MAX_PB_CALLER_GROUPS + 1))
  1840.                 ||
  1841.                 ((list_enum == MMI_PHB_LIST_FOR_ADD_MEMBER_LIST) &&
  1842.                  g_phb_cntx.group_type[i] != (g_phb_cntx.active_index - MAX_PB_CALLER_GROUPS + 1)))
  1843.             {
  1844.                 for (j = 0; j < PhoneBookEntryCount; j++)
  1845.                 {
  1846.                     if ((i + MAX_PB_PHONE_ENTRIES) == g_phb_name_index[j])
  1847.                     {
  1848.                         count++;
  1849.                         break;
  1850.                     }
  1851.                 }
  1852.             }
  1853.         }
  1854.         return count;
  1855.     }
  1856. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  1857. #if defined(__MMI_PHB_CALLERGROUP_IN_SIM__)     /* Associate caller group in SIM card entry */
  1858.     for (i = 0; i < MAX_PB_ENTRIES; i++)
  1859. #else 
  1860.     for (i = 0; i < MAX_PB_PHONE_ENTRIES; i++)
  1861. #endif 
  1862.     {
  1863.         /* Get optional IDs record. */
  1864.         optid_record = (i / OPTIONAL_IDS_RECORD_TOTAL) + 1;
  1865.         optid_index = i - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
  1866.         if (optid_record != current_record)
  1867.         {
  1868.             ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1869.             current_record = optid_record;
  1870.         }
  1871.         /* Count Entry Number */
  1872.         if (((list_enum == MMI_PHB_LIST_FOR_VIEW_MEMBER_LIST) &&
  1873.              (PhbOptIDs[optid_index].callerGroupID) == (g_phb_cntx.active_index + 1))
  1874.             ||
  1875.             ((list_enum == MMI_PHB_LIST_FOR_ADD_MEMBER_LIST) &&
  1876.              (PhbOptIDs[optid_index].callerGroupID != (g_phb_cntx.active_index + 1))))
  1877.         {
  1878.             for (j = 0; j < PhoneBookEntryCount; j++)
  1879.                 if (i == g_phb_name_index[j])
  1880.                 {
  1881.                     count++;
  1882.                     break;
  1883.                 }
  1884.         }
  1885.     }
  1886.     return count;
  1887. }
  1888. /*****************************************************************************
  1889.  * FUNCTION
  1890.  *  mmi_phb_callergroup_member_make_group_id_cache
  1891.  * DESCRIPTION
  1892.  *  Allocate a buffer and make cache for callergroup of each phonebook entry.
  1893.  *  This is to reduce the NVRAM when showing in list screen.
  1894.  * PARAMETERS
  1895.  *  void
  1896.  * RETURNS
  1897.  *  void
  1898.  *****************************************************************************/
  1899. void mmi_phb_callergroup_member_make_group_id_cache(void)
  1900. {
  1901.     /*----------------------------------------------------------------*/
  1902.     /* Local Variables                                                */
  1903.     /*----------------------------------------------------------------*/
  1904.     U16 store_index;
  1905.     S16 pError;
  1906.     U8 optid_record, optid_index, current_record = 0;
  1907.     PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
  1908.     /*----------------------------------------------------------------*/
  1909.     /* Code Body                                                      */
  1910.     /*----------------------------------------------------------------*/
  1911. #if defined(__MMI_PHB_CALLERGROUP_IN_SIM__)     /* Associate caller group in SIM card entry */
  1912.     for (store_index = 0; store_index < MAX_PB_ENTRIES; store_index++)
  1913. #else 
  1914.     for (store_index = 0; store_index < MAX_PB_PHONE_ENTRIES; store_index++)
  1915. #endif 
  1916.     {
  1917.         /* Get optional IDs record. */
  1918.         optid_record = (store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
  1919.         optid_index = store_index - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
  1920.         if (optid_record != current_record)
  1921.         {
  1922.             ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1923.             current_record = optid_record;
  1924.         }
  1925.         g_phb_callergroup_ptr[store_index] = (U16) PhbOptIDs[optid_index].callerGroupID;
  1926.     }
  1927. }
  1928. /*****************************************************************************
  1929.  * FUNCTION
  1930.  *  mmi_phb_callergroup_member_get_index
  1931.  * DESCRIPTION
  1932.  *  This function is just for template.
  1933.  * PARAMETERS
  1934.  *  list_enum       [IN]        
  1935.  *  item_index      [IN]        
  1936.  * RETURNS
  1937.  *  void
  1938.  *****************************************************************************/
  1939. U16 mmi_phb_callergroup_member_get_index(U8 list_enum, U16 item_index)
  1940. {
  1941.     /*----------------------------------------------------------------*/
  1942.     /* Local Variables                                                */
  1943.     /*----------------------------------------------------------------*/
  1944.     U16 i, count = 0;
  1945.     U16 store_index = 0;
  1946.     /*----------------------------------------------------------------*/
  1947.     /* Code Body                                                      */
  1948.     /*----------------------------------------------------------------*/
  1949. #ifdef __MMI_PHB_USIM_FIELD__
  1950.     if (g_phb_cntx.active_index >= MAX_PB_CALLER_GROUPS)
  1951.     {
  1952.         for (i = 0; i < PhoneBookEntryCount; i++)
  1953.         {
  1954.             store_index = g_phb_name_index[i];
  1955.             /* Associate caller group in USIM card entry */
  1956.             if (store_index >= MAX_PB_PHONE_ENTRIES)
  1957.             {
  1958.                 U16 filter_index = store_index - MAX_PB_PHONE_ENTRIES;
  1959.                 if (((list_enum == MMI_PHB_LIST_FOR_VIEW_MEMBER_LIST) &&
  1960.                      (g_phb_cntx.group_type[filter_index] == (g_phb_cntx.active_index + 1 - MAX_PB_CALLER_GROUPS)))
  1961.                     ||
  1962.                     ((list_enum == MMI_PHB_LIST_FOR_ADD_MEMBER_LIST) &&
  1963.                      (g_phb_cntx.group_type[filter_index] != (g_phb_cntx.active_index + 1 - MAX_PB_CALLER_GROUPS))))
  1964.                 {
  1965.                     if (count == item_index)
  1966.                     {
  1967.                         break;
  1968.                     }
  1969.                     count++;
  1970.                 }
  1971.             }
  1972.         }
  1973.         return store_index;
  1974.     }
  1975. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  1976.     for (i = 0; i < PhoneBookEntryCount; i++)
  1977.     {
  1978.         store_index = g_phb_name_index[i];
  1979.     #if !defined(__MMI_PHB_CALLERGROUP_IN_SIM__)    /* Associate caller group in SIM card entry */
  1980.         if (store_index < MAX_PB_PHONE_ENTRIES)
  1981.     #endif 
  1982.         {
  1983.             if (((list_enum == MMI_PHB_LIST_FOR_VIEW_MEMBER_LIST) &&
  1984.                  (g_phb_callergroup_ptr[store_index] == (g_phb_cntx.active_index + 1)))
  1985.                 ||
  1986.                 ((list_enum == MMI_PHB_LIST_FOR_ADD_MEMBER_LIST) &&
  1987.                  (g_phb_callergroup_ptr[store_index] != (g_phb_cntx.active_index + 1))))
  1988.             {
  1989.                 if (count == item_index)
  1990.                 {
  1991.                     break;
  1992.                 }
  1993.                 count++;
  1994.             }
  1995.         }
  1996.     }
  1997.     return store_index;
  1998. }
  1999. #endif /* defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__) */ /* END of #if defined( __MMI_PHB_CALLERGROUP_MEMBER_LIST__   ) */
  2000. /*--------------------------------------------END Caller Group Member List -----------------------------------------------------------*/
  2001. #define MMI_PHB_INLINE_ITEM
  2002. /*****************************************************************************
  2003.  * FUNCTION
  2004.  *  mmi_phb_ring_tone_highlight_hdlr
  2005.  * DESCRIPTION
  2006.  *  Highlight handler for ringtones inline selection list
  2007.  * PARAMETERS
  2008.  *  ringToneIndex       [IN]        Ring tone id for play
  2009.  * RETURNS
  2010.  *  void
  2011.  *****************************************************************************/
  2012. void mmi_phb_ring_tone_highlight_hdlr(S32 ringToneIndex)
  2013. {
  2014.     /*----------------------------------------------------------------*/
  2015.     /* Local Variables                                                */
  2016.     /*----------------------------------------------------------------*/
  2017.     /*----------------------------------------------------------------*/
  2018.     /* Code Body                                                      */
  2019.     /*----------------------------------------------------------------*/
  2020.     mmi_phb_stop_ring_tone_id();
  2021.     if (ringToneIndex)
  2022.     {
  2023.         g_phb_curr_ring_tone_id = g_phb_cntx.ring_tone_list[ringToneIndex];
  2024.         g_phb_last_ring_tone_id = g_phb_curr_ring_tone_id;
  2025.         StartTimer(PHB_NOTIFYDURATION_TIMER, 1000, mmi_phb_play_ring_tone_id);
  2026.     }
  2027. }
  2028. /*****************************************************************************
  2029.  * FUNCTION
  2030.  *  mmi_phb_play_ring_tone_id
  2031.  * DESCRIPTION
  2032.  *  Plays the selected ringtone
  2033.  * PARAMETERS
  2034.  *  void
  2035.  * RETURNS
  2036.  *  void
  2037.  *****************************************************************************/
  2038. void mmi_phb_play_ring_tone_id(void)
  2039. {
  2040.     /*----------------------------------------------------------------*/
  2041.     /* Local Variables                                                */
  2042.     /*----------------------------------------------------------------*/
  2043.     /*----------------------------------------------------------------*/
  2044.     /* Code Body                                                      */
  2045.     /*----------------------------------------------------------------*/
  2046.     /* g_phb_last_ring_tone_id = g_phb_curr_ring_tone_id; */
  2047.     StopTimer(PHB_NOTIFYDURATION_TIMER);
  2048.     /* Play ring tone repeatedly */
  2049.     if (!IsSilentModeActivated() && !isInCall())    /* need to check if it's in call because phonebook use this function, too */
  2050.     {
  2051.     #ifdef __MMI_SILENT_MEETING_PROFILE__
  2052.         if (!IsMeetingModeActivated())
  2053.     #endif 
  2054.             AudioPlayReq(g_phb_curr_ring_tone_id, (U8) DEVICE_AUDIO_PLAY_INFINITE);
  2055.     }
  2056. }
  2057. /*****************************************************************************
  2058.  * FUNCTION
  2059.  *  mmi_phb_stop_ring_tone_id
  2060.  * DESCRIPTION
  2061.  *  Stops the currently played ringtone
  2062.  * PARAMETERS
  2063.  *  void
  2064.  * RETURNS
  2065.  *  void
  2066.  *****************************************************************************/
  2067. void mmi_phb_stop_ring_tone_id(void)
  2068. {
  2069.     /*----------------------------------------------------------------*/
  2070.     /* Local Variables                                                */
  2071.     /*----------------------------------------------------------------*/
  2072.     /*----------------------------------------------------------------*/
  2073.     /* Code Body                                                      */
  2074.     /*----------------------------------------------------------------*/
  2075.     if (g_phb_last_ring_tone_id)
  2076.     {
  2077.         StopTimer(PHB_NOTIFYDURATION_TIMER);
  2078.         AudioStopReq(g_phb_last_ring_tone_id);
  2079.     }
  2080.     g_phb_last_ring_tone_id = 0;
  2081. }
  2082. /*****************************************************************************
  2083.  * FUNCTION
  2084.  *  mmi_phb_led_pattern_highlight_hdlr
  2085.  * DESCRIPTION
  2086.  *  Highlight handler for LED patterns inline selection list
  2087.  * PARAMETERS
  2088.  *  index       [IN]        Index for play
  2089.  * RETURNS
  2090.  *  void
  2091.  *****************************************************************************/
  2092. void mmi_phb_led_pattern_highlight_hdlr(S32 index)
  2093. {
  2094.     /*----------------------------------------------------------------*/
  2095.     /* Local Variables                                                */
  2096.     /*----------------------------------------------------------------*/
  2097.     /*----------------------------------------------------------------*/
  2098.     /* Code Body                                                      */
  2099.     /*----------------------------------------------------------------*/
  2100.     mmi_phb_stop_led_pattern_id();
  2101.     if (index)
  2102.     {
  2103.         g_phb_curr_pattern_id = (U8) index;
  2104.         g_phb_last_pattern_id = g_phb_curr_pattern_id;
  2105.         StartTimer(PHB_NOTIFYDURATION_TIMER, 1000, mmi_phb_play_led_pattern_id);
  2106.     }
  2107. }
  2108. /*****************************************************************************
  2109.  * FUNCTION
  2110.  *  mmi_phb_play_led_pattern_id
  2111.  * DESCRIPTION
  2112.  *  Plays the selected LED pattern
  2113.  * PARAMETERS
  2114.  *  void
  2115.  * RETURNS
  2116.  *  void
  2117.  *****************************************************************************/
  2118. void mmi_phb_play_led_pattern_id(void)
  2119. {
  2120.     /*----------------------------------------------------------------*/
  2121.     /* Local Variables                                                */
  2122.     /*----------------------------------------------------------------*/
  2123.     /*----------------------------------------------------------------*/
  2124.     /* Code Body                                                      */
  2125.     /*----------------------------------------------------------------*/
  2126.     /* g_phb_last_pattern_id = g_phb_curr_pattern_id; */
  2127.     StopTimer(PHB_NOTIFYDURATION_TIMER);
  2128.     PlayPatternCallerGroup(g_phb_curr_pattern_id);
  2129. }
  2130. /*****************************************************************************
  2131.  * FUNCTION
  2132.  *  mmi_phb_stop_led_pattern_id
  2133.  * DESCRIPTION
  2134.  *  Stops the currently played LED pattern
  2135.  * PARAMETERS
  2136.  *  void
  2137.  * RETURNS
  2138.  *  void
  2139.  *****************************************************************************/
  2140. void mmi_phb_stop_led_pattern_id(void)
  2141. {
  2142.     /*----------------------------------------------------------------*/
  2143.     /* Local Variables                                                */
  2144.     /*----------------------------------------------------------------*/
  2145.     /*----------------------------------------------------------------*/
  2146.     /* Code Body                                                      */
  2147.     /*----------------------------------------------------------------*/
  2148.     if (g_phb_last_pattern_id)
  2149.     {
  2150.         StopTimer(PHB_NOTIFYDURATION_TIMER);
  2151.         StopPatternCallerGroup(g_phb_last_pattern_id);
  2152.     }
  2153.     g_phb_last_pattern_id = 0;
  2154. }
  2155. /*****************************************************************************
  2156.  * FUNCTION
  2157.  *  mmi_phb_build_led_and_alert_list
  2158.  * DESCRIPTION
  2159.  *  Builds the Ringtone, Pictures, Alerts & Patterns list for inline selection
  2160.  * PARAMETERS
  2161.  *  void
  2162.  * RETURNS
  2163.  *  void
  2164.  *****************************************************************************/
  2165. void mmi_phb_build_led_and_alert_list(void)
  2166. {
  2167.     /*----------------------------------------------------------------*/
  2168.     /* Local Variables                                                */
  2169.     /*----------------------------------------------------------------*/
  2170.     /*----------------------------------------------------------------*/
  2171.     /* Code Body                                                      */
  2172.     /*----------------------------------------------------------------*/
  2173.     /* Use the same string ID with ProfilesEnum.h */
  2174. #if defined(__MMI_STATUS_LED__)
  2175.     g_phb_cntx.led_name_list[0] = (PU8) GetString(STR_GLOBAL_NONE);
  2176.     g_phb_cntx.led_name_list[1] = (PU8) GetString(STR_LIGHT_STATUS_COLOR1);
  2177.     g_phb_cntx.led_name_list[2] = (PU8) GetString(STR_LIGHT_STATUS_COLOR2);
  2178.     g_phb_cntx.led_name_list[3] = (PU8) GetString(STR_LIGHT_STATUS_COLOR3);
  2179.     g_phb_cntx.led_name_list[4] = (PU8) GetString(STR_LIGHT_STATUS_COLOR4);
  2180.     g_phb_cntx.led_name_list[5] = (PU8) GetString(STR_LIGHT_STATUS_COLOR5);
  2181.     g_phb_cntx.led_name_list[6] = (PU8) GetString(STR_LIGHT_STATUS_COLOR6);
  2182. #endif /* defined(__MMI_STATUS_LED__) */ 
  2183.     /* Use Same String ID with ProfilesEnum.h  */
  2184.     g_phb_cntx.alert_name_list[0] = (PU8) GetString(STR_GLOBAL_NONE);
  2185.     g_phb_cntx.alert_name_list[1] = (PU8) GetString(STR_RING);
  2186.     g_phb_cntx.alert_name_list[2] = (PU8) GetString(STR_VIBRATION_ONLY);
  2187.     g_phb_cntx.alert_name_list[3] = (PU8) GetString(STR_VIBRATION_AND_RING);
  2188.     g_phb_cntx.alert_name_list[4] = (PU8) GetString(STR_VIBRATION_THEN_RING);
  2189. #if defined(__MMI_STATUS_LED__)
  2190.     g_phb_cntx.alert_name_list[5] = (PU8) GetString(STR_SILENT);
  2191. #endif 
  2192. }
  2193. /*****************************************************************************
  2194.  * FUNCTION
  2195.  *  mmi_phb_build_ring_tone_list
  2196.  * DESCRIPTION
  2197.  *  Builds the ringtone list for inline selection
  2198.  * PARAMETERS
  2199.  *  void
  2200.  * RETURNS
  2201.  *  void
  2202.  *****************************************************************************/
  2203. void mmi_phb_build_ring_tone_list(void)
  2204. {
  2205.     /*----------------------------------------------------------------*/
  2206.     /* Local Variables                                                */
  2207.     /*----------------------------------------------------------------*/
  2208.     U8 i = 0, j;
  2209.     U8 ringToneStartId, ringToneTotalId, midiToneStartId, midiToneTotalId;
  2210.     U8 factoryTonesCnt;     /* Factory Default */
  2211.     U8 factoryMelodiesCnt, composedMelodiesCnt, downloadMelodiesCnt, downloadEmsMelodiesCnt;    /* iMelody */
  2212.     U8 downloadTonesCnt;    /* WAP download */
  2213.     U8 extMelodyCnt;        /* File Manager Associate. */
  2214.     S8 dummyStr[8];
  2215.     /* Default Factory Tones. */
  2216.     DYNAUDIOINFO *factoryTones;
  2217.     /* iMelody support */
  2218. #if defined(__MMI_IMELODY_SUPPORT__)
  2219.     DYNAUDIOINFO *factoryMelodies;
  2220. #if defined(__MMI_RING_COMPOSER__)
  2221.     DYNAUDIOINFO *composedMelodies;
  2222. #endif 
  2223. #endif /* defined(__MMI_IMELODY_SUPPORT__) */ 
  2224.     /* External Melody, select from file manager. */
  2225. #if defined(__MMI_PROFILE_EXTMELODY_SUPPORT__)
  2226.     DYNEXTMELODYINFO *ExtMelodyInfo;
  2227. #endif 
  2228. #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  2229.     DYNAUDIOINFO *DownloadThemeTones;
  2230. #endif 
  2231.     /*----------------------------------------------------------------*/
  2232.     /* Code Body                                                      */
  2233.     /*----------------------------------------------------------------*/
  2234.     /* Default Factory Tones. */
  2235.     GetRingToneRange(&ringToneStartId, &ringToneTotalId);
  2236.     GetMidiRange(&midiToneStartId, &midiToneTotalId);
  2237.     factoryTonesCnt = GetFactoryTonesInfo(&factoryTones);
  2238.     /* iMelody support */
  2239. #if defined(__MMI_IMELODY_SUPPORT__)
  2240.     factoryMelodiesCnt = GetFactoryIMelodyInfo(&factoryMelodies);
  2241.     downloadMelodiesCnt = 0;
  2242.     downloadEmsMelodiesCnt = 0;
  2243. #if defined(__MMI_RING_COMPOSER__)
  2244.     composedMelodiesCnt = GetComposedIMelodyInfo(&composedMelodies);
  2245. #else 
  2246.     composedMelodiesCnt = 0;
  2247. #endif 
  2248. #else /* defined(__MMI_IMELODY_SUPPORT__) */ 
  2249.     factoryMelodiesCnt = 0;
  2250.     downloadMelodiesCnt = 0;
  2251.     downloadEmsMelodiesCnt = 0;
  2252.     composedMelodiesCnt = 0;
  2253. #endif /* defined(__MMI_IMELODY_SUPPORT__) */ 
  2254.     downloadTonesCnt = 0;
  2255.     /* External Melody, select from file manager. */
  2256. #if defined(__MMI_PROFILE_EXTMELODY_SUPPORT__)
  2257.     extMelodyCnt = PmgGetExtMelodyInfo(&ExtMelodyInfo);
  2258. #else 
  2259.     extMelodyCnt = 0;
  2260. #endif 
  2261.     /*
  2262.      *  The following section will Begin to associate label for inline selection.
  2263.      */
  2264.     g_phb_cntx.total_ring_tone = 1 + ringToneTotalId
  2265.         + midiToneTotalId
  2266.         + factoryTonesCnt
  2267.         + factoryMelodiesCnt
  2268.         + downloadTonesCnt + downloadMelodiesCnt + composedMelodiesCnt + downloadEmsMelodiesCnt + extMelodyCnt;
  2269.     g_phb_cntx.ring_tone_name_list[0] = (PU8) GetString(STR_GLOBAL_NONE);
  2270.     g_phb_cntx.ring_tone_list[0] = 0;
  2271.     pfnUnicodeStrcpy((PS8) subMenuData[0], GetString(STR_GLOBAL_NONE));
  2272.     /* Default Factory Tones. */
  2273.     for (j = 0; j < ringToneTotalId; ++j)
  2274.     {
  2275.         pfnUnicodeStrcpy((PS8) subMenuData[++i], GetString(STR_PROFILES_RING));
  2276.         gui_itoa((j + 1), (UI_string_type) dummyStr, 10);
  2277.         pfnUnicodeStrcat((PS8) subMenuData[i], dummyStr);
  2278.         g_phb_cntx.ring_tone_list[i] = j + ringToneStartId;
  2279.         g_phb_cntx.ring_tone_name_list[i] = subMenuData[i];
  2280.     }
  2281.     for (j = 0; j < midiToneTotalId; ++j)
  2282.     {
  2283.         pfnUnicodeStrcpy((PS8) subMenuData[++i], GetString(STR_PROFILES_MIDI));
  2284.         gui_itoa((j + 1), (UI_string_type) dummyStr, 10);
  2285.         pfnUnicodeStrcat((PS8) subMenuData[i], dummyStr);
  2286.         g_phb_cntx.ring_tone_list[i] = j + midiToneStartId;
  2287.         g_phb_cntx.ring_tone_name_list[i] = subMenuData[i];
  2288.     }
  2289.     for (j = 0; j < factoryTonesCnt; ++j)
  2290.     {
  2291.         g_phb_cntx.ring_tone_list[++i] = factoryTones[j].AudioId;
  2292.         g_phb_cntx.ring_tone_name_list[i] = factoryTones[j].AudioName;
  2293.     }
  2294.     /* iMelody support */
  2295. #if defined(__MMI_IMELODY_SUPPORT__)
  2296.     for (j = 0; j < factoryMelodiesCnt; ++j)
  2297.     {
  2298.         g_phb_cntx.ring_tone_list[++i] = factoryMelodies[j].AudioId;
  2299.         g_phb_cntx.ring_tone_name_list[i] = factoryMelodies[j].AudioName;
  2300.     }
  2301. #if defined(__MMI_RING_COMPOSER__)
  2302.     for (j = 0; j < composedMelodiesCnt; ++j)
  2303.     {
  2304.         g_phb_cntx.ring_tone_list[++i] = composedMelodies[j].AudioId;
  2305.         g_phb_cntx.ring_tone_name_list[i] = composedMelodies[j].AudioName;
  2306.     }
  2307. #endif /* defined(__MMI_RING_COMPOSER__) */ 
  2308. #endif /* defined(__MMI_IMELODY_SUPPORT__) */ 
  2309. #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  2310.     if (GetThemeV2TonesInfo(&DownloadThemeTones) != 0 && mmi_tm_get_current_theme_ringtone())
  2311.     {
  2312.         ++g_phb_cntx.total_ring_tone;
  2313.         pfnUnicodeStrcpy((PS8) subMenuData[++i], GetString(STR_PROFILES_CURR_THEME));
  2314.         g_phb_cntx.ring_tone_list[i] = DownloadThemeTones->AudioId;
  2315.         g_phb_cntx.ring_tone_name_list[i] = subMenuData[i];
  2316.     }
  2317. #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  2318.     /* External Melody, select from file manager. */
  2319. #if defined(__MMI_PROFILE_EXTMELODY_SUPPORT__)
  2320.     for (j = 0; j < MAXIMUM_EXT_MELODY_NUM; ++j)
  2321.     {
  2322.         if (PmgIsEmptySlot(j) == MMI_TRUE)
  2323.         {
  2324.             continue;
  2325.         }
  2326.         g_phb_cntx.ring_tone_list[++i] = ExtMelodyInfo->info[j].id;
  2327.         if (IS_EXTMELODY_SHORTNAME(ExtMelodyInfo->info[j].filepath))
  2328.         {
  2329.             mmi_chset_mixed_text_to_ucs2_str(
  2330.                 subMenuData[i],
  2331.                 (FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH,
  2332.                 (U8*) ExtMelodyInfo->info[j].filename,
  2333.                 g_chset_text_encoding);
  2334.         }
  2335.         else
  2336.         {
  2337.             pfnUnicodeStrcpy((PS8) subMenuData[i], (PS8) ExtMelodyInfo->info[j].filename);
  2338.         }
  2339.     #if (!defined(__MMI_SHOW_FILE_EXT__))
  2340.         PmgRemoveFileExt((S8*) subMenuData[i]);
  2341.     #elif (!defined(__MMI_SHOW_DAF_FILE_EXT__))
  2342.         PmgRemoveFileDAFExt((S8*) subMenuData[i]);
  2343.     #endif 
  2344.         g_phb_cntx.ring_tone_name_list[i] = subMenuData[i];
  2345.     }
  2346. #endif /* defined(__MMI_PROFILE_EXTMELODY_SUPPORT__) */ 
  2347. }
  2348. /*****************************************************************************
  2349.  * FUNCTION
  2350.  *  mmi_phb_build_image_list
  2351.  * DESCRIPTION
  2352.  *  Builds Images list for inline selection
  2353.  * PARAMETERS
  2354.  *  void
  2355.  * RETURNS
  2356.  *  void
  2357.  *****************************************************************************/
  2358. void mmi_phb_build_image_list(void)
  2359. {
  2360.     /*----------------------------------------------------------------*/
  2361.     /* Local Variables                                                */
  2362.     /*----------------------------------------------------------------*/
  2363.     U8 i = 0, j;
  2364.     U8 maxSystemImages = 4;
  2365.     DYNIMAGEINFO *fullScrFactoryImages, *associatedFactoryImages;
  2366.     U8 fullScrFactoryImagesCnt, associatedFactoryImagesCnt;
  2367.     /*----------------------------------------------------------------*/
  2368.     /* Code Body                                                      */
  2369.     /*----------------------------------------------------------------*/
  2370.     /* System Default Image */
  2371.     fullScrFactoryImagesCnt = GetFullScreenFactoryImagesInfo(&fullScrFactoryImages);
  2372.     associatedFactoryImagesCnt = GetAssociatedFactoryImagesInfo(&associatedFactoryImages);
  2373.     g_phb_cntx.total_image_id = 1 + maxSystemImages + fullScrFactoryImagesCnt + associatedFactoryImagesCnt;
  2374.     /* System Default Image */
  2375.     g_phb_cntx.image_name_list[0] = (PU8) GetString(STR_GLOBAL_NONE);
  2376.     g_phb_cntx.image_id_list[0] = IMG_PHB_DEFAULT;
  2377.     for (j = 0; j < maxSystemImages; ++j)
  2378.     {
  2379.         g_phb_cntx.image_name_list[++i] = (PU8) GetString((U16) (STR_PICTURE_1 + j));
  2380.         g_phb_cntx.image_id_list[i] = IMG_PHB_PICTURE1 + j;
  2381.     }
  2382.     for (j = 0; j < fullScrFactoryImagesCnt; ++j)
  2383.     {
  2384.         g_phb_cntx.image_name_list[++i] = fullScrFactoryImages[j].ImageName;
  2385.         g_phb_cntx.image_id_list[i] = fullScrFactoryImages[j].ImagesId;
  2386.     }
  2387.     for (j = 0; j < associatedFactoryImagesCnt; ++j)
  2388.     {
  2389.         g_phb_cntx.image_name_list[++i] = associatedFactoryImages[j].ImageName;
  2390.         g_phb_cntx.image_id_list[i] = associatedFactoryImages[j].ImagesId;
  2391.     }
  2392.     /* Select Image From File Manager */
  2393. #if defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__)
  2394.     g_phb_cntx.total_image_id++;
  2395.     g_phb_cntx.image_name_list[++i] = (U8*) GetString(STR_ID_PHB_FMGR_IMAGE_SELECT_FILE);
  2396.     g_phb_cntx.image_id_list[i] = 1;
  2397. #endif /* defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__) */ 
  2398. }
  2399. /*****************************************************************************
  2400.  * FUNCTION
  2401.  *  mmi_phb_build_caller_group_list
  2402.  * DESCRIPTION
  2403.  *  Builds caller group list for inline selection
  2404.  * PARAMETERS
  2405.  *  void
  2406.  * RETURNS
  2407.  *  void
  2408.  *****************************************************************************/
  2409. void mmi_phb_build_caller_group_list(void)
  2410. {
  2411.     /*----------------------------------------------------------------*/
  2412.     /* Local Variables                                                */
  2413.     /*----------------------------------------------------------------*/
  2414.     U8 i;
  2415.     PHB_CALLER_GROUP_STRUCT *callerGroups;
  2416.     /*----------------------------------------------------------------*/
  2417.     /* Code Body                                                      */
  2418.     /*----------------------------------------------------------------*/
  2419.     callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  2420.     myCallerGrpnames[0] = (PU8) GetString(STR_GLOBAL_NONE);
  2421.     for (i = 1; i <= MAX_PB_CALLER_GROUPS; i++)
  2422.     {
  2423.         myCallerGrpnames[i] = callerGroups[i - 1].groupName;
  2424.     }
  2425. }
  2426. #ifdef __MMI_PHB_USIM_FIELD__
  2427. /*****************************************************************************
  2428.  * FUNCTION
  2429.  *  mmi_phb_build_usim_group_list
  2430.  * DESCRIPTION
  2431.  *  Builds caller group list for inline selection
  2432.  * PARAMETERS
  2433.  *  void
  2434.  * RETURNS
  2435.  *  void
  2436.  *****************************************************************************/
  2437. void mmi_phb_build_usim_group_list(void)
  2438. {
  2439.     /*----------------------------------------------------------------*/
  2440.     /* Local Variables                                                */
  2441.     /*----------------------------------------------------------------*/
  2442.     U8 i;
  2443.     MMI_PHB_NAME_STRUCT *callerGroups;
  2444.     /*----------------------------------------------------------------*/
  2445.     /* Code Body                                                      */
  2446.     /*----------------------------------------------------------------*/
  2447.     callerGroups = (MMI_PHB_NAME_STRUCT*) g_phb_cntx.usim_group;
  2448.     myCallerGrpnames[0] = (PU8) GetString(STR_GLOBAL_NONE);
  2449.     for (i = 1; i <= g_phb_cntx.gas_total; i++)
  2450.     {
  2451.         myCallerGrpnames[i] = callerGroups[i - 1].name;
  2452.     }
  2453. }
  2454. /*****************************************************************************
  2455.  * FUNCTION
  2456.  *  mmi_phb_entry_callergroup_usim_detail
  2457.  * DESCRIPTION
  2458.  *  Builds caller group list for inline selection
  2459.  * PARAMETERS
  2460.  *  void
  2461.  * RETURNS
  2462.  *  void
  2463.  *****************************************************************************/
  2464. void mmi_phb_entry_callergroup_usim_detail(void)
  2465. {
  2466.     /*----------------------------------------------------------------*/
  2467.     /* Local Variables                                                */
  2468.     /*----------------------------------------------------------------*/
  2469.     U8 *guiBuffer;
  2470.     U8 *inputBuffer;
  2471.     U16 inputBufferSize;
  2472.     U8 j = 0;
  2473.     U16 CGDetailsImageList[MAX_CALLER_GRP_USIM_ITEMS];
  2474.     MMI_PHB_NAME_STRUCT *usim_caller_groups = NULL;
  2475.     /*----------------------------------------------------------------*/
  2476.     /* Code Body                                                      */
  2477.     /*----------------------------------------------------------------*/
  2478.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_entry_callergroup_usim_detail.>n",
  2479.                          __FILE__, __LINE__));
  2480.     EntryNewScreen(SCR_CALLER_GRP_DETAILS, mmi_phb_exit_callergroup_detail, NULL, NULL);
  2481.     InitializeCategory57Screen();
  2482.     guiBuffer = GetCurrGuiBuffer(SCR_CALLER_GRP_DETAILS);
  2483.     inputBuffer = GetCurrNInputBuffer(SCR_CALLER_GRP_DETAILS, &inputBufferSize);
  2484.     usim_caller_groups = (MMI_PHB_NAME_STRUCT*) g_phb_cntx.usim_group;
  2485.     pfnUnicodeStrcpy(pbName, (PS8) usim_caller_groups[g_phb_cntx.active_index - MAX_PB_CALLER_GROUPS].name);
  2486.     /* Caller Group Name */
  2487.     SetInlineItemActivation(&wgui_inline_items[j], KEY_LSK, KEY_EVENT_UP);
  2488. #if defined(__PHB_0x81_SUPPORT__)
  2489.     SetInlineItemFullScreenEdit_ext(
  2490.         &wgui_inline_items[j],
  2491.         STR_ID_PHB_NAME,
  2492.         IMG_SCR_PBOOK_CAPTION,
  2493.         (PU8) pbName,
  2494.         g_phb_cntx.group_name_len + 1,
  2495.         (INPUT_TYPE_ALPHANUMERIC_UPPERCASE | INPUT_TYPE_USE_ENCODING_BASED_LENGTH | INPUT_TYPE_ONE_LESS_CHARACTER | INPUT_TYPE_GSM_EXTENDED_HANDLING),
  2496.         INPUT_TYPE_EXT_USE_0x81_ENCODING);
  2497. #else /* defined(__PHB_0x81_SUPPORT__) */ 
  2498.     SetInlineItemFullScreenEdit(
  2499.         &wgui_inline_items[j],
  2500.         STR_ID_PHB_NAME,
  2501.         IMG_SCR_PBOOK_CAPTION,
  2502.         (PU8) pbName,
  2503.         g_phb_cntx.group_name_len + 1,
  2504.         (INPUT_TYPE_ALPHANUMERIC_UPPERCASE | INPUT_TYPE_USE_ENCODING_BASED_LENGTH | INPUT_TYPE_ONE_LESS_CHARACTER | INPUT_TYPE_GSM_EXTENDED_HANDLING));
  2505. #endif /* defined(__PHB_0x81_SUPPORT__) */ 
  2506.     SetInlineItemFullScreenEdit(
  2507.         &wgui_inline_items[j],
  2508.         STR_GRP_NAME_CAPTION,
  2509.         IMG_SCR_PBOOK_CAPTION,
  2510.         (PU8) pbName,
  2511.         g_phb_cntx.group_name_len + 1,
  2512.         INPUT_TYPE_ALPHANUMERIC_UPPERCASE);
  2513.     SetInlineFullScreenEditCustomFunction(&wgui_inline_items[j], mmi_phb_set_full_scr_lsk);
  2514.     CGDetailsImageList[j++] = IMG_CG_NAME;
  2515.     /* Caller Group Member List */
  2516. #if defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__)
  2517.     SetInlineItemActivation(&wgui_inline_items[j], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  2518.     SetInlineItemDisplayOnly(&wgui_inline_items[j], (U8*) GetString(STR_ID_PHB_CALLERGROUP_MEMBER_LIST));
  2519.     g_phb_callergroup_member_index = j;
  2520.     CGDetailsImageList[j++] = IMG_ID_PHB_CALLERGRP_MEMBER;
  2521. #endif /* defined(__MMI_PHB_CALLERGROUP_MEMBER_LIST__) */ 
  2522.     RegisterHighlightHandler(mmi_phb_callergroup_highlight_hdlr);
  2523.     if (inputBuffer != NULL)
  2524.     {
  2525.         SetCategory57Data(wgui_inline_items, j, inputBuffer);
  2526.     }
  2527.     ShowCategory57Screen(
  2528.         STR_SCR_CG_DETAILS_CAPTION,
  2529.         IMG_SCR_PBOOK_CAPTION,
  2530.         STR_GLOBAL_EDIT,
  2531.         IMG_EDIT_LSK,
  2532.         STR_GLOBAL_DONE,
  2533.         IMG_DONE_RSK,
  2534.         j,
  2535.         CGDetailsImageList,
  2536.         wgui_inline_items,
  2537.         0,
  2538.         guiBuffer);
  2539.     SetCategory57RightSoftkeyFunctions(mmi_phb_gas_pre_save, GoBackHistory);
  2540.     if (g_phb_cntx.set_done_flag)
  2541.     {
  2542.         g_phb_cntx.set_done_flag = 0;
  2543.         set_wgui_inline_list_menu_changed();
  2544.     }
  2545. }
  2546. /*****************************************************************************
  2547.  * FUNCTION
  2548.  *  mmi_phb_gas_save_rsp
  2549.  * DESCRIPTION
  2550.  *  Response of saving the Caller Group Name to SIM GAS
  2551.  * PARAMETERS
  2552.  *  info        [?]     
  2553.  * RETURNS
  2554.  *  void
  2555.  *****************************************************************************/
  2556. void mmi_phb_gas_save_rsp(void *info)
  2557. {
  2558.     /*----------------------------------------------------------------*/
  2559.     /* Local Variables                                                */
  2560.     /*----------------------------------------------------------------*/
  2561.     MMI_PHB_NAME_STRUCT *caller_groups = NULL;
  2562.     MSG_PHB_SET_ENRTY_RSP_STRUCT *localPtr;
  2563.     /*----------------------------------------------------------------*/
  2564.     /* Code Body                                                      */
  2565.     /*----------------------------------------------------------------*/
  2566.     localPtr = (MSG_PHB_SET_ENRTY_RSP_STRUCT*) info;
  2567.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_gas_save_rsp.>n", __FILE__, __LINE__));
  2568. #if defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC)
  2569.     if (g_phb_enter_from == MMI_PHB_ENTER_FROM_JAVA)
  2570.     {
  2571.         if (localPtr->result.flag == 0) /* Set Entry Success */
  2572.         {
  2573.             mmi_phb_java_set_group_info_rsp(MMI_PHB_JAVA_SUCCESS);
  2574.         }
  2575.         else
  2576.         {
  2577.             mmi_phb_java_set_group_info_rsp(MMI_PHB_JAVA_ERROR);
  2578.         }
  2579.         g_phb_enter_from = MMI_PHB_ENTER_NONE;
  2580.         return;
  2581.     }
  2582. #endif /* defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC) */ 
  2583.     if (localPtr->result.flag == 0) /* Set Entry Success */
  2584.     {
  2585.         caller_groups = (MMI_PHB_NAME_STRUCT*) g_phb_cntx.usim_group;
  2586.         pfnUnicodeStrcpy((S8*) caller_groups[g_phb_cntx.active_index - MAX_PB_CALLER_GROUPS].name, pbName);
  2587.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, TRUE, PHB_NOTIFY_TIMEOUT, SUCCESS_TONE);
  2588.     }
  2589.     else
  2590.     {
  2591.         DisplayPopup(
  2592.             (PU8) GetString(STR_GLOBAL_UNFINISHED),
  2593.             IMG_GLOBAL_UNFINISHED,
  2594.             TRUE,
  2595.             PHB_NOTIFY_TIMEOUT,
  2596.             ERROR_TONE);
  2597.     }
  2598.     DeleteNScrId(SCR_CALLER_GRP_DETAILS);   /* Enter from caller group */
  2599. }
  2600. /*****************************************************************************
  2601.  * FUNCTION
  2602.  *  mmi_phb_gas_save_req
  2603.  * DESCRIPTION
  2604.  *  Sends the request to the stack to save the information of a phonebook entry.
  2605.  * PARAMETERS
  2606.  *  void
  2607.  * RETURNS
  2608.  *  the description of return value, if any.(?)
  2609.  *****************************************************************************/
  2610. void mmi_phb_gas_save_req(void)
  2611. {
  2612.     /*----------------------------------------------------------------*/
  2613.     /* Local Variables                                                */
  2614.     /*----------------------------------------------------------------*/
  2615.     MSG_PHB_SET_ENRTY_REQ_STRUCT *myMsgPtr;
  2616.     MYQUEUE Message;
  2617.     /*----------------------------------------------------------------*/
  2618.     /* Code Body                                                      */
  2619.     /*----------------------------------------------------------------*/
  2620.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_gas_save_req.>n", __FILE__, __LINE__));
  2621.     myMsgPtr = (MSG_PHB_SET_ENRTY_REQ_STRUCT*) OslConstructDataPtr(sizeof(MSG_PHB_SET_ENRTY_REQ_STRUCT));
  2622. #if defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC)
  2623.     if (g_phb_enter_from == MMI_PHB_ENTER_FROM_JAVA)
  2624.     {
  2625.         myMsgPtr->list.index = g_phb_cntx.java_store_index;
  2626.         myMsgPtr->list.record_index = g_phb_cntx.java_store_index;
  2627.     }
  2628.     else
  2629. #endif /* defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC) */
  2630.     {
  2631.         mmi_phb_show_in_progress(STR_GLOBAL_SAVING, IMG_GLOBAL_SAVE);
  2632.         myMsgPtr->list.index = g_phb_cntx.active_index - MAX_PB_CALLER_GROUPS + 1;
  2633.         myMsgPtr->list.record_index = g_phb_cntx.active_index - MAX_PB_CALLER_GROUPS + 1;
  2634.     }
  2635.     myMsgPtr->type = MMI_PHB_GAS;
  2636.     myMsgPtr->no_data = 1;
  2637.     myMsgPtr->list.storage = MMI_SIM;
  2638.     mmi_phb_op_set_entry_prepare_name_number(&myMsgPtr->list, pbName, pbNumber);
  2639.     Message.oslSrcId = MOD_MMI;
  2640.     Message.oslDestId = MOD_L4C;
  2641.     Message.oslMsgId = PRT_PHB_SET_ENTRY_REQ;
  2642.     Message.oslDataPtr = (oslParaType*) myMsgPtr;
  2643.     Message.oslPeerBuffPtr = NULL;
  2644.     SetProtocolEventHandler(mmi_phb_gas_save_rsp, PRT_PHB_SET_ENTRY_RSP);
  2645.     OslMsgSendExtQueue(&Message);
  2646. }
  2647. /*****************************************************************************
  2648.  * FUNCTION
  2649.  *  mmi_phb_gas_is_duplicated
  2650.  * DESCRIPTION
  2651.  *  Checks if name is duplicated before saving the Caller Group details
  2652.  * PARAMETERS
  2653.  *  group_index        [IN]     
  2654.  *  group_name         [IN]     
  2655.  * RETURNS
  2656.  *  void
  2657.  *****************************************************************************/
  2658. BOOL mmi_phb_gas_is_duplicated(U16 group_index, S8* group_name)
  2659. {
  2660.     /*----------------------------------------------------------------*/
  2661.     /* Local Variables                                                */
  2662.     /*----------------------------------------------------------------*/
  2663.     U8 i;
  2664.     MMI_PHB_NAME_STRUCT *caller_groups;
  2665.     /*----------------------------------------------------------------*/
  2666.     /* Code Body                                                      */
  2667.     /*----------------------------------------------------------------*/
  2668.     caller_groups = (MMI_PHB_NAME_STRUCT*) g_phb_cntx.usim_group;
  2669.     /* Each group name can not be the same. */
  2670.     for (i = 0; i < MAX_PB_USIM_GROUPS; ++i)
  2671.     {
  2672.         if (i != group_index)
  2673.         {
  2674.             if (!pfnUnicodeStrcmp((PS8) caller_groups[i].name, group_name))
  2675.             {
  2676.                 return TRUE;
  2677.             }
  2678.         }
  2679.     }
  2680.     return FALSE;
  2681. }
  2682. /*****************************************************************************
  2683.  * FUNCTION
  2684.  *  mmi_phb_gas_pre_save
  2685.  * DESCRIPTION
  2686.  *  Checks before saving the Caller Group Name
  2687.  * PARAMETERS
  2688.  *  void
  2689.  * RETURNS
  2690.  *  void
  2691.  *****************************************************************************/
  2692. static void mmi_phb_gas_pre_save(void)
  2693. {
  2694.     /*----------------------------------------------------------------*/
  2695.     /* Local Variables                                                */
  2696.     /*----------------------------------------------------------------*/
  2697.     /*----------------------------------------------------------------*/
  2698.     /* Code Body                                                      */
  2699.     /*----------------------------------------------------------------*/
  2700.     ASSERT(g_phb_cntx.active_index    >= MAX_PB_CALLER_GROUPS);
  2701.     if (mmi_phb_gas_is_duplicated((U16)(g_phb_cntx.active_index - MAX_PB_CALLER_GROUPS), pbName))
  2702.     {
  2703.         DisplayPopup((PU8) GetString(STR_CG_RENAME_FAIL_MSG), IMG_GLOBAL_ERROR, FALSE, PHB_NOTIFY_TIMEOUT, ERROR_TONE);
  2704.     }
  2705.     else
  2706.     {
  2707.         mmi_phb_entry_callergroup_detail_save_confirm();
  2708.     }
  2709. }
  2710. /*****************************************************************************
  2711.  * FUNCTION
  2712.  *  mmi_phb_callergroup_member_usim_set_rsp
  2713.  * DESCRIPTION
  2714.  *  This function is just for template.
  2715.  * PARAMETERS
  2716.  *  info        [?]     
  2717.  * RETURNS
  2718.  *  void
  2719.  *****************************************************************************/
  2720. static void mmi_phb_callergroup_member_usim_set_rsp(void *info)
  2721. {
  2722.     /*----------------------------------------------------------------*/
  2723.     /* Local Variables                                                */
  2724.     /*----------------------------------------------------------------*/
  2725.     MSG_PHB_SET_GRP_RSP_STRUCT *localPtr;
  2726.     U16 record_index;
  2727.     /*----------------------------------------------------------------*/
  2728.     /* Code Body                                                      */
  2729.     /*----------------------------------------------------------------*/
  2730.     localPtr = (MSG_PHB_SET_GRP_RSP_STRUCT*) info;
  2731.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_callergroup_member_usim_set_rsp.>n",
  2732.                          __FILE__, __LINE__));
  2733.     if (localPtr->result.flag == 0) /* Set GRP OK */
  2734.     {
  2735.         record_index = localPtr->record_index;
  2736.         if (phb_delete_grp_flag)
  2737.         {
  2738.             g_phb_cntx.group_type[record_index - 1] = 0;
  2739.         }
  2740.         else
  2741.         {
  2742.             g_phb_cntx.group_type[record_index - 1] = g_phb_cntx.active_index + 1 - MAX_PB_CALLER_GROUPS;
  2743.         }
  2744.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, TRUE, PHB_NOTIFY_TIMEOUT, SUCCESS_TONE);
  2745.         g_phb_callergroup_member_count++;
  2746.     }
  2747.     else
  2748.     {
  2749.         DisplayPopup(
  2750.             (PU8) GetString(STR_GLOBAL_UNFINISHED),
  2751.             IMG_GLOBAL_UNFINISHED,
  2752.             TRUE,
  2753.             PHB_NOTIFY_TIMEOUT,
  2754.             ERROR_TONE);
  2755.     }
  2756.     g_phb_cntx.highlight_entry = 0;
  2757.     DeleteNScrId(SCR_ID_PHB_CALLERGROUP_MEMBER_VIEW_OPTION);
  2758.     phbListView = MMI_PHB_LIST_FOR_VIEW_MEMBER_LIST;
  2759.     g_phb_callergroup_member_count = mmi_phb_callergroup_member_count_number((U8) phbListView);
  2760.     if (g_phb_callergroup_member_count == 1)
  2761.     {
  2762.         mmi_phb_entry_callergroup_member_list();
  2763.     }
  2764. }
  2765. /*****************************************************************************
  2766.  * FUNCTION
  2767.  *  mmi_phb_callergroup_member_usim_set_req
  2768.  * DESCRIPTION
  2769.  *  This function is just for template.
  2770.  * PARAMETERS
  2771.  *  void
  2772.  * RETURNS
  2773.  *  void
  2774.  *****************************************************************************/
  2775. static void mmi_phb_callergroup_member_usim_set_req(void)
  2776. {
  2777.     /*----------------------------------------------------------------*/
  2778.     /* Local Variables                                                */
  2779.     /*----------------------------------------------------------------*/
  2780.     MSG_PHB_SET_GRP_REQ_STRUCT *myMsgPtr;
  2781.     MYQUEUE Message;
  2782.     U16 store_index;
  2783.     /*----------------------------------------------------------------*/
  2784.     /* Code Body                                                      */
  2785.     /*----------------------------------------------------------------*/
  2786.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_callergroup_member_usim_set_req.>n",
  2787.                          __FILE__, __LINE__));
  2788.     mmi_phb_show_in_progress(STR_GLOBAL_SAVING, IMG_GLOBAL_SAVE);
  2789.     myMsgPtr = (MSG_PHB_SET_GRP_REQ_STRUCT*) OslConstructDataPtr(sizeof(MSG_PHB_SET_GRP_REQ_STRUCT));
  2790.     if (phb_delete_grp_flag)
  2791.     {
  2792.         myMsgPtr->group_type = 0;
  2793.         store_index = mmi_phb_callergroup_member_get_index(
  2794.                         MMI_PHB_LIST_FOR_VIEW_MEMBER_LIST,
  2795.                         g_phb_cntx.active_index_second);
  2796.     }
  2797.     else
  2798.     {
  2799.         myMsgPtr->group_type = g_phb_cntx.active_index + 1 - MAX_PB_CALLER_GROUPS;
  2800.         store_index = mmi_phb_callergroup_member_get_index(
  2801.                         MMI_PHB_LIST_FOR_ADD_MEMBER_LIST,
  2802.                         g_phb_cntx.active_index_third);
  2803.     }
  2804.     myMsgPtr->record_index = store_index + 1 - MAX_PB_PHONE_ENTRIES;
  2805.     Message.oslSrcId = MOD_MMI;
  2806.     Message.oslDestId = MOD_L4C;
  2807.     Message.oslMsgId = PRT_PHB_SET_GRP_REQ;
  2808.     Message.oslDataPtr = (oslParaType*) myMsgPtr;
  2809.     Message.oslPeerBuffPtr = NULL;
  2810.     SetProtocolEventHandler(mmi_phb_callergroup_member_usim_set_rsp, PRT_PHB_SET_GRP_RSP);
  2811.     OslMsgSendExtQueue(&Message);
  2812. }
  2813. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  2814. #if defined(__MMI_INCOMING_CALL_VIDEO__)
  2815. /*****************************************************************************
  2816.  * FUNCTION
  2817.  *  mmi_phb_build_video_list
  2818.  * DESCRIPTION
  2819.  *  Builds Video list for inline selection
  2820.  * PARAMETERS
  2821.  *  void
  2822.  * RETURNS
  2823.  *  void
  2824.  *****************************************************************************/
  2825. void mmi_phb_build_video_list(void)
  2826. {
  2827.     /*----------------------------------------------------------------*/
  2828.     /* Local Variables                                                */
  2829.     /*----------------------------------------------------------------*/
  2830.     U8 count = 0;
  2831.     U16 i;
  2832.     /*----------------------------------------------------------------*/
  2833.     /* Code Body                                                      */
  2834.     /*----------------------------------------------------------------*/
  2835.     /* System Default video */
  2836.     g_phb_cntx.video_name_list[count] = (U8*) GetString(STR_GLOBAL_NONE);
  2837.     g_phb_cntx.video_id_list[count] = 0;
  2838.     g_phb_cntx.total_video_id = 1;
  2839. #ifdef __MMI_SWFLASH__
  2840.     for (i = 0 ; i < MMI_PHB_SWFLASH_TOTAL; i++)
  2841.     {
  2842.         g_phb_cntx.video_name_list[++count] = (U8*)GetString((U16)(STR_ID_PHB_SWFLASH_1+i));
  2843.         g_phb_cntx.video_id_list[count] = MFH_ID_PHB_MTCALL_1 + i;
  2844.         g_phb_cntx.total_video_id++;
  2845.     }
  2846. #endif /* __MMI_SWFLASH__ */
  2847. #ifdef __MMI_INCOMING_CALL_VIDEO_EMBEDED__     //KP Jerry add on 2006-11-21
  2848.     for (i = 0; i < 1; i++)
  2849.     {
  2850.         g_phb_cntx.video_name_list[++count] = (U8*) GetString((U16) (STR_ID_PHB_VIDEO_1 + i));
  2851.         g_phb_cntx.video_id_list[count] = VDO_ID_PHB_MTCALL_1 + i;
  2852.         g_phb_cntx.total_video_id++;
  2853.     }
  2854. #endif/*__MMI_INCOMING_CALL_VIDEO_EMBEDED__*/     //KP Jerry add on 2006-11-21
  2855. #ifdef __MMI_SWFLASH__
  2856.     /* Select From SWFlash */
  2857.     g_phb_cntx.video_name_list[++count] = (U8*)GetString(STR_ID_PHB_CALLER_VIDEO_FROM_SWFLASH);
  2858.     g_phb_cntx.video_id_list[count] = 0xA000;
  2859.     g_phb_cntx.total_video_id++;
  2860. #endif /* __MMI_SWFLASH__ */
  2861.     /* Select From File */
  2862.     g_phb_cntx.video_name_list[++count] = (U8*) GetString(STR_ID_PHB_FMGR_IMAGE_SELECT_FILE);
  2863.     g_phb_cntx.video_id_list[count] = 0x8000;
  2864.     g_phb_cntx.total_video_id++;
  2865. }
  2866. /*****************************************************************************
  2867.  * FUNCTION
  2868.  *  mmi_phb_get_video_index
  2869.  * DESCRIPTION
  2870.  *  Retrieve video list index by video id.
  2871.  * PARAMETERS
  2872.  *  video_id        [IN]        
  2873.  * RETURNS
  2874.  *  void
  2875.  *****************************************************************************/
  2876. U8 mmi_phb_get_video_index(U16 video_id)
  2877. {
  2878.     /*----------------------------------------------------------------*/
  2879.     /* Local Variables                                                */
  2880.     /*----------------------------------------------------------------*/
  2881.     U8 i;
  2882.     /*----------------------------------------------------------------*/
  2883.     /* Code Body                                                      */
  2884.     /*----------------------------------------------------------------*/
  2885.     /* An external video resource */
  2886.     if (video_id & 0x8000)
  2887.     {
  2888. #ifdef __MMI_SWFLASH__
  2889.         if (video_id & 0x2000)
  2890.         {
  2891.             return (U8)(g_phb_cntx.total_video_id-2);
  2892.         }
  2893. #endif /* __MMI_SWFLASH__ */
  2894.         return (U8) (g_phb_cntx.total_video_id - 1);
  2895.     }
  2896.     /* An internal video resource, mask it to get resource id */
  2897.     video_id &= 0x3FFF;
  2898.     if (video_id)
  2899.     {
  2900.         for (i = 0; i < (g_phb_cntx.total_video_id - 1); i++)
  2901.         {
  2902.             if (video_id == g_phb_cntx.video_id_list[i])
  2903.             {
  2904.                 return i;
  2905.             }
  2906.         }
  2907.     }
  2908.     return 0;
  2909. }
  2910. #endif /* defined(__MMI_INCOMING_CALL_VIDEO__) */ 
  2911. /*****************************************************************************
  2912.  * FUNCTION
  2913.  *  mmi_phb_get_ring_tone_index
  2914.  * DESCRIPTION
  2915.  *  Gets the index of the current ringtone in ringtone list
  2916.  * PARAMETERS
  2917.  *  ringToneId          [IN]        
  2918.  *  ringToneID(?)       [IN]        Ring tone id  for lookup
  2919.  * RETURNS
  2920.  *  void
  2921.  *****************************************************************************/
  2922. U8 mmi_phb_get_ring_tone_index(U16 ringToneId)
  2923. {
  2924.     /*----------------------------------------------------------------*/
  2925.     /* Local Variables                                                */
  2926.     /*----------------------------------------------------------------*/
  2927.     U8 i;
  2928.     /*----------------------------------------------------------------*/
  2929.     /* Code Body                                                      */
  2930.     /*----------------------------------------------------------------*/
  2931.     if (ringToneId)
  2932.     {
  2933.         for (i = 0; i < g_phb_cntx.total_ring_tone; ++i)
  2934.         {
  2935.             if (g_phb_cntx.ring_tone_list[i] == ringToneId)
  2936.             {
  2937.                 break;
  2938.             }
  2939.         }
  2940.         return i;
  2941.     }
  2942.     else
  2943.     {
  2944.         return 0;
  2945.     }
  2946. }
  2947. /*****************************************************************************
  2948.  * FUNCTION
  2949.  *  mmi_phb_get_image_index
  2950.  * DESCRIPTION
  2951.  *  Gets the index of the current image tag in  images list
  2952.  * PARAMETERS
  2953.  *  imageId         [IN]        Image for lookup
  2954.  * RETURNS
  2955.  *  void
  2956.  *****************************************************************************/
  2957. U8 mmi_phb_get_image_index(U16 imageId)
  2958. {
  2959.     /*----------------------------------------------------------------*/
  2960.     /* Local Variables                                                */
  2961.     /*----------------------------------------------------------------*/
  2962.     U8 i;
  2963.     /*----------------------------------------------------------------*/
  2964.     /* Code Body                                                      */
  2965.     /*----------------------------------------------------------------*/
  2966.     if (imageId)
  2967.     {
  2968.         for (i = 0; i < g_phb_cntx.total_image_id; ++i)
  2969.         {
  2970.             if (g_phb_cntx.image_id_list[i] == imageId)
  2971.             {
  2972.                 break;
  2973.             }
  2974.         }
  2975.         return i;
  2976.     }
  2977.     else
  2978.     {
  2979.         return 0;
  2980.     }
  2981. }
  2982. #if defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC)
  2983. /*****************************************************************************
  2984.  * FUNCTION
  2985.  *  mmi_phb_callergroup_copy_group_info
  2986.  * DESCRIPTION
  2987.  *  Displays the list of available Caller Groups
  2988.  * PARAMETERS
  2989.  *  group_index         [IN]
  2990.  *  group_name          [OUT]        
  2991.  * RETURNS
  2992.  *  void
  2993.  *****************************************************************************/
  2994. void mmi_phb_callergroup_copy_group_info(U8 group_index, U8* group_name)
  2995. {
  2996.     /*----------------------------------------------------------------*/
  2997.     /* Local Variables                                                */
  2998.     /*----------------------------------------------------------------*/
  2999. #ifdef __MMI_PHB_USIM_FIELD__
  3000.     MMI_PHB_NAME_STRUCT *usim_caller_groups = (MMI_PHB_NAME_STRUCT*) g_phb_cntx.usim_group;
  3001. #endif
  3002.     /*----------------------------------------------------------------*/
  3003.     /* Code Body                                                      */
  3004.     /*----------------------------------------------------------------*/
  3005.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_callergroup_copy_group_info.>n", __FILE__,
  3006.                          __LINE__));
  3007.     if (!g_phb_cntx.nvram_data_init)
  3008.     {
  3009.         mmi_phb_init_get_data_from_nvram();
  3010.         g_phb_cntx.nvram_data_init = TRUE;
  3011.     }
  3012.     if (group_index < MAX_PB_CALLER_GROUPS)
  3013.     {
  3014.         PHB_CALLER_GROUP_STRUCT *callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  3015.         pfnUnicodeStrcpy((S8*)group_name, (S8*)callerGroups[group_index].groupName);
  3016.     }
  3017. #ifdef __MMI_PHB_USIM_FIELD__
  3018.     else
  3019.     {
  3020.         if (pfnUnicodeStrlen((PS8) usim_caller_groups[group_index- MAX_PB_CALLER_GROUPS].name) > 0)
  3021.         {
  3022.             pfnUnicodeStrcpy((S8*)group_name, (S8*)usim_caller_groups[group_index - MAX_PB_CALLER_GROUPS].name);
  3023.         }
  3024.         else
  3025.         {
  3026.             pfnUnicodeStrcpy((S8*)group_name, (S8*)GetString(STR_GLOBAL_EMPTY_LIST));
  3027.         }
  3028.     }
  3029. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  3030. }
  3031. #endif /* defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC) */
  3032. #endif /* _PHONEBOOKCALLERGROUP_C */