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

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.  *  SmlMenu.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *  MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  This file is intends for SIM-ME-Lock 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.  *------------------------------------------------------------------------------
  124.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  125.  *============================================================================== 
  126.  *******************************************************************************/
  127. #include "MMI_features.h"
  128. #include "StdC.h"
  129. #include "L4Dr1.h"
  130. #include "PixtelDataTypes.h"
  131. #include "wgui_categories.h"
  132. #include "wgui_categories_inputs.h"
  133. #include "wgui_categories_popup.h"
  134. #include "CustDataRes.h"
  135. #include "CustMenuRes.h"
  136. #include "EventsGProt.h"
  137. #include "DebugInitDef.h"
  138. #include "HistoryGprot.h"
  139. #include "ProtocolEvents.h"
  140. #include "CommonScreens.h"
  141. #include "Globaldefs.h"
  142. #include "NVRAMType.h"
  143. #include "NVRAMProt.h"
  144. #include "NVRAMEnum.h"
  145. #include "PersonalizationDef.h"
  146. #include "PersonalizationProt.h"
  147. #include "SettingDefs.h"
  148. #include "SettingGprots.h"
  149. #include "SettingsGdcl.h"       /* gSecuritySetupContext */
  150. #include "MainMenuDef.h"        /* MAIN_MENU_TITLE_SETTINGS_ICON */
  151. #include "CallSetUpEnum.h"      /* STR_RESTORE_PHONE */
  152. #include "SettingProfile.h"     /* ERROR_TONE */
  153. #include "ProfileGprots.h"      /* playRequestedTone */
  154. #include "IdleAppDef.h"         /* g_idle_context */
  155. #include "CustResDef.h"
  156. #ifdef __MMI_SML_UNLOCK_RETRY_TIMER__
  157. #include "SATDefs.h"            /* SAT_WAIT_STRING_ID */
  158. #include "gpioInc.h"
  159. #endif /* __MMI_SML_UNLOCK_RETRY_TIMER__ */
  160. #include "SimDetectionGprot.h"
  161. #include "custom_nvram_extra.h"
  162. #include "EventsDcl.h"          /* ShutdownSystemOperation */
  163. /* diamond, 2006/04/11 SML menu implementation */
  164. #ifdef __MMI_SML_MENU__
  165. void mmi_sml_entry_add_data(void);
  166. void mmi_sml_read_data_from_sim_query(void);
  167. void mmi_sml_verify_key_req(void);
  168. void mmi_sml_input_key(void);
  169. void mmi_sml_confirm_key(void);
  170. #if defined(__MMI_SML_AUTO_KEY_GEN__) && defined(MMI_ON_HARDWARE_P)
  171. extern void mmi_sml_auto_key_gen_implemetation(U8 *);
  172. #endif 
  173. mmi_sml_menu_struct g_sml_context;
  174. /*****************************************************************************
  175.  * FUNCTION
  176.  *  mmi_sml_reset_input_buffer
  177.  * DESCRIPTION
  178.  *  Reset input buffer of add data
  179.  * PARAMETERS
  180.  *  void
  181.  * RETURNS
  182.  *  void
  183.  *****************************************************************************/
  184. static void mmi_sml_reset_input_buffer(void)
  185. {
  186.     /*----------------------------------------------------------------*/
  187.     /* Local Variables                                                */
  188.     /*----------------------------------------------------------------*/
  189.     /*----------------------------------------------------------------*/
  190.     /* Code Body                                                      */
  191.     /*----------------------------------------------------------------*/
  192.     memset(g_sml_context.input_imsi, 0, (MAX_IMSI_LEN + 1) * ENCODING_LENGTH);
  193.     memset(g_sml_context.input_gid1, 0, (MAX_GID_LEN + 1) * ENCODING_LENGTH);
  194.     memset(g_sml_context.input_gid2, 0, (MAX_GID_LEN + 1) * ENCODING_LENGTH);
  195. }
  196. /*****************************************************************************
  197.  * FUNCTION
  198.  *  mmi_sml_init
  199.  * DESCRIPTION
  200.  *  SML initialization
  201.  * PARAMETERS
  202.  *  void
  203.  * RETURNS
  204.  *  void
  205.  *****************************************************************************/
  206. void mmi_sml_init(void)
  207. {
  208.     /*----------------------------------------------------------------*/
  209.     /* Local Variables                                                */
  210.     /*----------------------------------------------------------------*/
  211.     /*----------------------------------------------------------------*/
  212.     /* Code Body                                                      */
  213.     /*----------------------------------------------------------------*/
  214.     g_sml_context.operation_type = 0xFF;
  215.     g_sml_context.selected_category = 0;
  216.     g_sml_context.action_not_from_menu = 0;
  217.     mmi_sml_reset_input_buffer();
  218. }
  219. /*****************************************************************************
  220.  * FUNCTION
  221.  *  mmi_sml_is_gid1_valid
  222.  * DESCRIPTION
  223.  *  GID1 validation
  224.  * PARAMETERS
  225.  *  void
  226.  * RETURNS
  227.  *  
  228.  *****************************************************************************/
  229. static pBOOL mmi_sml_is_gid1_valid(void)
  230. {
  231.     /*----------------------------------------------------------------*/
  232.     /* Local Variables                                                */
  233.     /*----------------------------------------------------------------*/
  234.     /*----------------------------------------------------------------*/
  235.     /* Code Body                                                      */
  236.     /*----------------------------------------------------------------*/
  237.     if (g_sml_context.gid_valid_nibble & 0x01)
  238.     {
  239.         return MMI_TRUE;
  240.     }
  241.     else
  242.     {
  243.         return MMI_FALSE;
  244.     }
  245. }
  246. /*****************************************************************************
  247.  * FUNCTION
  248.  *  mmi_sml_is_gid2_valid
  249.  * DESCRIPTION
  250.  *  GID2 validation
  251.  * PARAMETERS
  252.  *  void
  253.  * RETURNS
  254.  *  
  255.  *****************************************************************************/
  256. static pBOOL mmi_sml_is_gid2_valid(void)
  257. {
  258.     /*----------------------------------------------------------------*/
  259.     /* Local Variables                                                */
  260.     /*----------------------------------------------------------------*/
  261.     /*----------------------------------------------------------------*/
  262.     /* Code Body                                                      */
  263.     /*----------------------------------------------------------------*/
  264.     if (g_sml_context.gid_valid_nibble & 0x10)
  265.     {
  266.         return MMI_TRUE;
  267.     }
  268.     else
  269.     {
  270.         return MMI_FALSE;
  271.     }
  272. }
  273. /*****************************************************************************
  274.  * FUNCTION
  275.  *  mmi_sml_password_screen_lsk_hdlr
  276.  * DESCRIPTION
  277.  *  
  278.  * PARAMETERS
  279.  *  text        [IN]         
  280.  *  cursor      [IN]         
  281.  *  length      [IN]        
  282.  * RETURNS
  283.  *  void
  284.  *****************************************************************************/
  285. static void mmi_sml_password_screen_lsk_hdlr(U8 *text, U8 *cursor, S32 length)
  286. {
  287.     /*----------------------------------------------------------------*/
  288.     /* Local Variables                                                */
  289.     /*----------------------------------------------------------------*/
  290.     /*----------------------------------------------------------------*/
  291.     /* Code Body                                                      */
  292.     /*----------------------------------------------------------------*/
  293. #if defined(__MMI_SML_AUTO_KEY_GEN__) && defined(MMI_ON_HARDWARE_P)
  294.     if (length > 0 && length < MIN_PASSWORD_LENGTH)
  295. #else 
  296.     if (length < MIN_PASSWORD_LENGTH)
  297. #endif 
  298.     {
  299.         /* if length is short then disable lsk */
  300.         ChangeLeftSoftkey(0, 0);
  301.         ClearKeyHandler(KEY_POUND, KEY_EVENT_UP);
  302.     }
  303.     else
  304.     {
  305.         /* if its valid length then enable lsk */
  306.         EnableLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  307.         SetKeyHandler(gSecuritySetupContext.PasswdLenCheckCallBack, KEY_POUND, KEY_EVENT_UP);
  308.     }
  309. }
  310. /*****************************************************************************
  311.  * FUNCTION
  312.  *  mmi_sml_popup_error_msg
  313.  * DESCRIPTION
  314.  *  Error string for input wrong key to unlock
  315.  * PARAMETERS
  316.  *  retry_count     [IN]        
  317.  * RETURNS
  318.  *  void
  319.  *****************************************************************************/
  320. void mmi_sml_popup_error_msg(U8 retry_count)
  321. {
  322.     /*----------------------------------------------------------------*/
  323.     /* Local Variables                                                */
  324.     /*----------------------------------------------------------------*/
  325.     /*----------------------------------------------------------------*/
  326.     /* Code Body                                                      */
  327.     /*----------------------------------------------------------------*/
  328.     if (retry_count == 1)
  329.     {
  330.         DisplayPopup((PU8) GetString(STR_ID_LAST_RETRY_MSG), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  331.     }
  332.     else
  333.     {
  334.         DisplayPopup((PU8) GetString(STR_ID_GENERAL_RETRY_MSG), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  335.     }
  336. }
  337. #ifdef __MMI_SML_UNLOCK_RETRY_TIMER__
  338. /*****************************************************************************
  339.  * FUNCTION
  340.  *  mmi_sml_count_retry_interval
  341.  * DESCRIPTION
  342.  *  Count the retry interval
  343.  * PARAMETERS
  344.  *  retry_count     [IN]        
  345.  * RETURNS
  346.  *  void
  347.  *****************************************************************************/
  348. S32 mmi_sml_count_retry_interval(U8 retry_count, U8 max_count)
  349. {
  350.     /*----------------------------------------------------------------*/
  351.     /* Local Variables                                                */
  352.     /*----------------------------------------------------------------*/
  353.     U8 i;
  354.     S32 interval = MIN_RETRY_INTERVAL;
  355.     /*----------------------------------------------------------------*/
  356.     /* Code Body                                                      */
  357.     /*----------------------------------------------------------------*/
  358.     for (i = 0; i < max_count - retry_count; i++)
  359.     {
  360.         interval *= 2;
  361.     }
  362.     return interval;
  363. }
  364. /*****************************************************************************
  365.  * FUNCTION
  366.  *  mmi_sml_set_next_attempt_function
  367.  * DESCRIPTION
  368.  *  Set expiration function and time
  369.  * PARAMETERS
  370.  *  func          [IN]
  371.  *  countdown     [IN]
  372.  * RETURNS
  373.  *  void
  374.  *****************************************************************************/
  375. void mmi_sml_set_next_attempt_function(FuncPtr func, S32 countdown)
  376. {
  377.     /*----------------------------------------------------------------*/
  378.     /* Local Variables                                                */
  379.     /*----------------------------------------------------------------*/
  380.     /*----------------------------------------------------------------*/
  381.     /* Code Body                                                      */
  382.     /*----------------------------------------------------------------*/
  383.     g_sml_context.next_attempt_hdlr = func;
  384.     g_sml_context.retry_countdown = countdown;
  385. }
  386. /*****************************************************************************
  387.  * FUNCTION
  388.  *  mmi_sml_set_next_attempt_expire
  389.  * DESCRIPTION
  390.  *  Expiration of next attempt timer
  391.  * PARAMETERS
  392.  *  void
  393.  * RETURNS
  394.  *  void
  395.  *****************************************************************************/
  396. void mmi_sml_set_next_attempt_expire(void)
  397. {
  398.     /*----------------------------------------------------------------*/
  399.     /* Local Variables                                                */
  400.     /*----------------------------------------------------------------*/
  401.     /*----------------------------------------------------------------*/
  402.     /* Code Body                                                      */
  403.     /*----------------------------------------------------------------*/
  404.     ExitCategory165Screen();
  405.     TurnOffBacklight();
  406.     (*g_sml_context.next_attempt_hdlr) ();
  407.     g_sml_context.next_attempt_hdlr = NULL;
  408.     g_sml_context.retry_countdown = 0;
  409. }
  410. /*****************************************************************************
  411.  * FUNCTION
  412.  *  sml_exit_please_wait_next_attempt
  413.  * DESCRIPTION
  414.  *  Exit screen of please wait for next attempt to unlock
  415.  * PARAMETERS
  416.  *  void
  417.  * RETURNS
  418.  *  void
  419.  *****************************************************************************/
  420. void sml_exit_please_wait_next_attempt(void)
  421. {
  422.     /*----------------------------------------------------------------*/
  423.     /* Local Variables                                                */
  424.     /*----------------------------------------------------------------*/
  425.     extern S32 Cat165CountDownValue;
  426.     /*----------------------------------------------------------------*/
  427.     /* Code Body                                                      */
  428.     /*----------------------------------------------------------------*/
  429.     g_sml_context.retry_countdown = Cat165CountDownValue;
  430. }
  431. /*****************************************************************************
  432.  * FUNCTION
  433.  *  mmi_sml_entry_please_wait_next_attempt
  434.  * DESCRIPTION
  435.  *  Entry screen of please wait for next attempt to unlock
  436.  * PARAMETERS
  437.  *  void
  438.  * RETURNS
  439.  *  void
  440.  *****************************************************************************/
  441. void mmi_sml_entry_please_wait_next_attempt(void)
  442. {
  443.     /*----------------------------------------------------------------*/
  444.     /* Local Variables                                                */
  445.     /*----------------------------------------------------------------*/
  446.     U8 *guiBuffer;
  447.     /*----------------------------------------------------------------*/
  448.     /* Code Body                                                      */
  449.     /*----------------------------------------------------------------*/
  450.     if (g_sml_context.retry_countdown == 0)
  451.     {
  452.         /* re-retry this screen and the timer is already expired */
  453.         mmi_sml_set_next_attempt_expire();
  454.         return;
  455.     }
  456.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_WAIT_ATTEMPT);
  457.     EntryNewScreen(SCR_ID_SML_WAIT_ATTEMPT, sml_exit_please_wait_next_attempt, mmi_sml_entry_please_wait_next_attempt, NULL);
  458.     DinitHistory(); /* only stay in this screen */
  459.     ShowCategory165Screen_ext(
  460.         0,
  461.         0,
  462.         0,
  463.         0,
  464.         get_string(SAT_WAIT_STRING_ID),
  465.         IMG_GLOBAL_WARNING,
  466.         g_sml_context.retry_countdown,
  467.         guiBuffer);
  468.     SetCat165TimerExpireFunc(mmi_sml_set_next_attempt_expire);  /* timeout to execute */
  469.     playRequestedTone(WARNING_TONE);
  470.     TurnOnBacklight(GPIO_BACKLIGHT_PERMANENT);
  471. }
  472. #endif /* __MMI_SML_UNLOCK_RETRY_TIMER__ */
  473. /*****************************************************************************
  474.  * FUNCTION
  475.  *  mmi_sml_convert_ansii_imsi_to_bcd
  476.  * DESCRIPTION
  477.  *  
  478.  * PARAMETERS
  479.  *  input       [IN]     
  480.  *  output      [OUT]     
  481.  * RETURNS
  482.  *  void
  483.  *****************************************************************************/
  484. void mmi_sml_convert_ansii_imsi_to_bcd(U8 *input, U8 *output)
  485. {
  486.     /*----------------------------------------------------------------*/
  487.     /* Local Variables                                                */
  488.     /*----------------------------------------------------------------*/
  489.     U8 i = 0, j = 0;
  490.     U8 low_byte = 9, high_byte = 0;
  491.     /*----------------------------------------------------------------*/
  492.     /* Code Body                                                      */
  493.     /*----------------------------------------------------------------*/
  494.     for (i = 0; i < MAX_IMSI_LEN; i++)
  495.     {
  496.         if (i % 2 == 0)
  497.         {
  498.             high_byte = *(input + i) - 0x30;
  499.             *(output + j) = (high_byte << 4) + low_byte;
  500.             j++;
  501.         }
  502.         else
  503.         {
  504.             low_byte = *(input + i) - 0x30;
  505.         }
  506.     }
  507. }
  508. /*****************************************************************************
  509.  * FUNCTION
  510.  *  mmi_sml_compact_data
  511.  * DESCRIPTION
  512.  *  
  513.  * PARAMETERS
  514.  *  input       [IN]     
  515.  *  output      [OUT]     
  516.  * RETURNS
  517.  *  void
  518.  *****************************************************************************/
  519. void mmi_sml_compact_data(U8 *input, U8 *output)
  520. {
  521.     /*----------------------------------------------------------------*/
  522.     /* Local Variables                                                */
  523.     /*----------------------------------------------------------------*/
  524.     U8 low_byte, high_byte;
  525.     /*----------------------------------------------------------------*/
  526.     /* Code Body                                                      */
  527.     /*----------------------------------------------------------------*/
  528.     high_byte = *input - 0x30;
  529.     low_byte = *(input + 1) - 0x30;
  530.     *output = (high_byte << 4) + low_byte; // byte 1
  531.     high_byte = *(input + 2) - 0x30;
  532.     low_byte = *(input + 3) - 0x30;
  533.     *(output + 1) = (high_byte << 4) + low_byte; // byte 2
  534.     switch (strlen((S8*) input))
  535.     {
  536.         case 5:
  537.             high_byte = *(input + 4) - 0x30;
  538.             low_byte = 0x0F;
  539.             *(output + 2) = (high_byte << 4) + low_byte; // byte 3
  540.             break;
  541.         case 6:
  542.             high_byte = *(input + 4) - 0x30;
  543.             low_byte = *(input + 5) - 0x30;
  544.             *(output + 2) = (high_byte << 4) + low_byte; // byte 3
  545.             break;
  546.         case 7:
  547.             high_byte = *(input + 4) - 0x30;
  548.             low_byte = 0x0F;
  549.             *(output + 2) = (high_byte << 4) + low_byte; // byte 3
  550.             high_byte = *(input + 5) - 0x30;
  551.             low_byte = *(input + 6) - 0x30;
  552.             *(output + 3) = (high_byte << 4) + low_byte; // byte 4
  553.             break;
  554.         case 8:
  555.             high_byte = *(input + 4) - 0x30;
  556.             low_byte = *(input + 5) - 0x30;
  557.             *(output + 2) = (high_byte << 4) + low_byte; // byte 3
  558.             high_byte = *(input + 6) - 0x30;
  559.             low_byte = *(input + 7) - 0x30;
  560.             *(output + 3) = (high_byte << 4) + low_byte; // byte 4
  561.             break;
  562.         default:
  563.            break;
  564.     }
  565. }
  566. #if defined(__MMI_SML_AUTO_KEY_GEN__) && defined(MMI_ON_HARDWARE_P)
  567. /*****************************************************************************
  568.  * FUNCTION
  569.  *  mmi_sml_set_auto_key_gen
  570.  * DESCRIPTION
  571.  *  Automatic key generation
  572.  * PARAMETERS
  573.  *  void
  574.  * RETURNS
  575.  *  void
  576.  *****************************************************************************/
  577. void mmi_sml_set_auto_key_gen(void)
  578. {
  579.     /*----------------------------------------------------------------*/
  580.     /* Local Variables                                                */
  581.     /*----------------------------------------------------------------*/
  582.     U8 auto_key[MAX_SIM_SETTING_PASSWD_LEN + 1];
  583.     /*----------------------------------------------------------------*/
  584.     /* Code Body                                                      */
  585.     /*----------------------------------------------------------------*/
  586.     mmi_sml_auto_key_gen_implemetation(auto_key);   /* defined in custom directory */
  587.     AnsiiToUnicodeString((S8*) gSecuritySetupContext.NewPassword, (S8*) auto_key);
  588.     AnsiiToUnicodeString((S8*) gSecuritySetupContext.ConfirmPassword, (S8*) auto_key);
  589.     mmi_sml_verify_key_req();
  590. }
  591. /*****************************************************************************
  592.  * FUNCTION
  593.  *  mmi_sml_entry_auto_key_gen_confirm
  594.  * DESCRIPTION
  595.  *  Automatic key generation confirmation
  596.  * PARAMETERS
  597.  *  void
  598.  * RETURNS
  599.  *  void
  600.  *****************************************************************************/
  601. void mmi_sml_entry_auto_key_gen_confirm(void)
  602. {
  603.     /*----------------------------------------------------------------*/
  604.     /* Local Variables                                                */
  605.     /*----------------------------------------------------------------*/
  606.     U8 *guiBuffer;
  607.     /*----------------------------------------------------------------*/
  608.     /* Code Body                                                      */
  609.     /*----------------------------------------------------------------*/
  610.     EntryNewScreen(SCR_ID_SML_AUTOKEY_CONFIRM, NULL, NULL, NULL);
  611.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_AUTOKEY_CONFIRM);
  612.     ShowCategory162Screen(
  613.         STR_GLOBAL_YES,
  614.         IMG_GLOBAL_YES,
  615.         STR_GLOBAL_NO,
  616.         IMG_GLOBAL_NO,
  617.         STR_ID_SML_AUTOKEY_CONFIRM,
  618.         IMG_GLOBAL_QUESTION,
  619.         guiBuffer);
  620.     SetLeftSoftkeyFunction(mmi_sml_set_auto_key_gen, KEY_EVENT_UP);
  621.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  622.     playRequestedTone(WARNING_TONE);
  623. }
  624. #endif /* defined(__MMI_SML_AUTO_KEY_GEN__) && defined(MMI_ON_HARDWARE_P) */ 
  625. /*****************************************************************************
  626.  * FUNCTION
  627.  *  mmi_sml_add_data_reboot_check
  628.  * DESCRIPTION
  629.  *  Reboot check for add data
  630.  * PARAMETERS
  631.  *  void
  632.  * RETURNS
  633.  *  void
  634.  *****************************************************************************/
  635. void mmi_sml_add_data_reboot_check(void)
  636. {
  637.     /*----------------------------------------------------------------*/
  638.     /* Local Variables                                                */
  639.     /*----------------------------------------------------------------*/
  640.     MMI_BOOL need_reboot = MMI_FALSE;
  641.     U8 tmp_gid1 = 0, tmp_gid2 = 0;
  642.     S8 tmp_imsi[MAX_IMSI_LEN + 1];
  643.     /*----------------------------------------------------------------*/
  644.     /* Code Body                                                      */
  645.     /*----------------------------------------------------------------*/
  646.     UnicodeToAnsii(tmp_imsi, (S8*) g_sml_context.input_imsi);
  647.     if (g_sml_context.selected_category == SML_CAT_SP ||
  648.         g_sml_context.selected_category == SML_CAT_C ||
  649.         g_sml_context.selected_category == SML_CAT_NS_SP || g_sml_context.selected_category == SML_CAT_SIM_C)
  650.     {
  651.         tmp_gid1 = (U8) gui_atoi((U16*) g_sml_context.input_gid1);
  652.     }
  653.     if (g_sml_context.selected_category == SML_CAT_C || g_sml_context.selected_category == SML_CAT_SIM_C)
  654.     {
  655.         tmp_gid2 = (U8) gui_atoi((U16*) g_sml_context.input_gid2);
  656.     }
  657.     switch (g_sml_context.selected_category)
  658.     {
  659.         case SML_CAT_N:
  660.         case SML_CAT_NS:
  661.         case SML_CAT_SIM:
  662.             if (strncmp((S8*) g_sml_context.imsi, tmp_imsi, strlen(tmp_imsi)) != 0)
  663.             {
  664.                 need_reboot = MMI_TRUE;
  665.             }
  666.             break;
  667.         case SML_CAT_SP:
  668.         case SML_CAT_NS_SP:
  669.             if (strncmp((S8*) g_sml_context.imsi, tmp_imsi, strlen(tmp_imsi)) != 0 || tmp_gid1 != g_sml_context.gid1)
  670.             {
  671.                 need_reboot = MMI_TRUE;
  672.             }
  673.             break;
  674.         case SML_CAT_C:
  675.         case SML_CAT_SIM_C:
  676.             if (strncmp((S8*) g_sml_context.imsi, tmp_imsi, strlen(tmp_imsi)) != 0 || tmp_gid1 != g_sml_context.gid1 ||
  677.                 tmp_gid2 != g_sml_context.gid2)
  678.             {
  679.                 need_reboot = MMI_TRUE;
  680.             }
  681.             break;
  682.         default:
  683.             break;
  684.     }
  685.     if (need_reboot)
  686.     {
  687.         DisplayPopup((PU8) GetString(STR_ID_SML_REBOOT_MSG), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, 0);
  688.         StartTimer(EM_NOTIFYDURATION_TIMER, ST_NOTIFYDURATION, ShutdownSystemOperation);
  689.     }
  690.     else
  691.     {
  692.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, 0);
  693.     }
  694. }
  695. /*****************************************************************************
  696.  * FUNCTION
  697.  *  mmi_sml_set_personalization_rsp
  698.  * DESCRIPTION
  699.  *  Verify lock/unlock key response
  700.  * PARAMETERS
  701.  *  info        [OUT]
  702.  * RETURNS
  703.  *  void
  704.  *****************************************************************************/
  705. void mmi_sml_set_personalization_rsp(void *info)
  706. {
  707.     /*----------------------------------------------------------------*/
  708.     /* Local Variables                                                */
  709.     /*----------------------------------------------------------------*/
  710.     mmi_smu_set_personalization_rsp_struct *resp;
  711.     /*----------------------------------------------------------------*/
  712.     /* Code Body                                                      */
  713.     /*----------------------------------------------------------------*/
  714.     resp = (mmi_smu_set_personalization_rsp_struct*) (info);
  715.     ClearProtocolEventHandler(PRT_MMI_SMU_SET_PERSONALIZATION_RSP);
  716.     if (g_sml_context.operation_type == SML_OP_ADD)
  717.     {
  718.         memset(gSecuritySetupContext.NewPassword, 0, (MAX_SIM_SETTING_PASSWD_LEN + 1) * ENCODING_LENGTH);
  719.         memset(gSecuritySetupContext.ConfirmPassword, 0, (MAX_SIM_SETTING_PASSWD_LEN + 1) * ENCODING_LENGTH);
  720.     }
  721.     /* update retry count for each set personalization request */
  722.     g_sml_context.retry_count[g_sml_context.selected_category] = resp->retry_count;
  723.     /* update state for each set personalization request */
  724.     g_sml_context.category_state[g_sml_context.selected_category] = resp->state;
  725.     if (resp->result.flag == L4C_OK)
  726.     {
  727.         switch (g_sml_context.operation_type)
  728.         {
  729.             case SML_OP_DISABLE:
  730.                 DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, 0);
  731.                 g_sml_context.category_state[g_sml_context.selected_category] = SML_STATE_DISABLE;
  732.                 break;
  733.             case SML_OP_ADD:
  734.                 mmi_sml_add_data_reboot_check();
  735.                 g_sml_context.used_records[g_sml_context.selected_category]++;
  736.                 break;
  737.             case SML_OP_REMOVE:
  738.                 DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, 0);
  739.                 g_sml_context.used_records[g_sml_context.selected_category] = 0;
  740.                 break;
  741.             default:
  742.                 DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, 0);
  743.                 break;
  744.         }
  745.     }
  746.     else
  747.     {
  748.         //DisplayPopup((PU8) GetString(STR_GLOBAL_UNFINISHED), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  749.         mmi_sml_popup_error_msg(resp->retry_count);
  750.     }
  751.     DeleteScreenIfPresent(SCR_ID_SML_FILL_DATA);
  752.     DeleteScreenIfPresent(SCR_ID_SML_INPUT_KEY);
  753.     DeleteScreenIfPresent(SCR_ID_SML_CONFIRM_KEY);
  754.     if (g_sml_context.action_not_from_menu)
  755.     {
  756.         DeleteScreenIfPresent(IDLE_SCREEN_DIGIT_HANDLER_ID);
  757.         g_sml_context.action_not_from_menu = 0;
  758.     }
  759. }
  760. /*****************************************************************************
  761.  * FUNCTION
  762.  *  mmi_sml_set_personalization_req
  763.  * DESCRIPTION
  764.  *  Verify lock/unlock key request
  765.  * PARAMETERS
  766.  *  key             [?]         [?]
  767.  *  category        [IN]        
  768.  *  operation       [IN]        
  769.  * RETURNS
  770.  *  void
  771.  *****************************************************************************/
  772. void mmi_sml_set_personalization_req(U8 *key, U8 category, U8 operation)
  773. {
  774.     /*----------------------------------------------------------------*/
  775.     /* Local Variables                                                */
  776.     /*----------------------------------------------------------------*/
  777.     MYQUEUE Message;
  778.     mmi_smu_set_personalization_req_struct *local_data;
  779.     S8 tmp_gid[MAX_GID_LEN + 1];
  780.     S8 tmp_imsi[MAX_IMSI_LEN + 1];
  781.     /*----------------------------------------------------------------*/
  782.     /* Code Body                                                      */
  783.     /*----------------------------------------------------------------*/
  784.     ClearAllKeyHandler();   /* ClearInputEventHandler(MMI_DEVICE_ALL); */
  785.     SetProtocolEventHandler(mmi_sml_set_personalization_rsp, PRT_MMI_SMU_SET_PERSONALIZATION_RSP);
  786.     PRINT_INFORMATION(("@@@@@ Sending request for query personalization status @@@@@"));
  787.     local_data =
  788.         (mmi_smu_set_personalization_req_struct*) OslConstructDataPtr(sizeof(mmi_smu_set_personalization_req_struct));
  789.     local_data->category = category;
  790.     local_data->op = operation;
  791.     memset(local_data->data, 0, 10);
  792.     if (key != NULL)
  793.     {
  794.         strcpy((S8*) local_data->key, (S8*) key);
  795.     }
  796.     else
  797.     {
  798.         local_data->key[0] = 0;
  799.     }
  800.     //strcpy((S8*)local_data->imei, (S8*)g_sml_context.input_imsi);
  801.     //strcpy((S8*)local_data->gid1, (S8*)g_sml_context.input_gid1);
  802.     //strcpy((S8*)local_data->gid2, (S8*)g_sml_context.input_gid2);
  803.     if (operation == SML_OP_ADD)
  804.     {
  805.         switch (g_sml_context.selected_category)
  806.         {
  807.             case SML_CAT_N:
  808.                 UnicodeToAnsii(tmp_imsi, (S8*) g_sml_context.input_imsi);
  809.                 mmi_sml_compact_data((U8*) tmp_imsi, local_data->data);
  810.                 local_data->len = 3;
  811.                 break;
  812.             case SML_CAT_NS:
  813.                 UnicodeToAnsii(tmp_imsi, (S8*) g_sml_context.input_imsi);
  814.                 mmi_sml_compact_data((U8*) tmp_imsi, local_data->data);
  815.                 local_data->len = 4;
  816.                 break;
  817.             case SML_CAT_SP:
  818.                 UnicodeToAnsii(tmp_imsi, (S8*) g_sml_context.input_imsi);
  819.                 mmi_sml_compact_data((U8*) tmp_imsi, local_data->data);
  820.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid1);
  821.                 local_data->data[3] = (U8) atoi(tmp_gid);
  822.                 local_data->len = 4;
  823.                 break;
  824.             case SML_CAT_C:
  825.                 UnicodeToAnsii(tmp_imsi, (S8*) g_sml_context.input_imsi);
  826.                 mmi_sml_compact_data((U8*) tmp_imsi, local_data->data);
  827.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid1);
  828.                 local_data->data[3] = (U8) atoi(tmp_gid);
  829.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid2);
  830.                 local_data->data[4] = (U8) atoi(tmp_gid);
  831.                 local_data->len = 5;
  832.                 break;
  833.             case SML_CAT_SIM:
  834.                 UnicodeToAnsii(tmp_imsi, (S8*) g_sml_context.input_imsi);
  835.                 mmi_sml_convert_ansii_imsi_to_bcd((U8*) tmp_imsi, local_data->data);
  836.                 local_data->len = 8;
  837.                 break;
  838.             case SML_CAT_NS_SP:
  839.                 UnicodeToAnsii(tmp_imsi, (S8*) g_sml_context.input_imsi);
  840.                 mmi_sml_compact_data((U8*) tmp_imsi, local_data->data);
  841.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid1);
  842.                 local_data->data[4] = (U8) atoi(tmp_gid);
  843.                 local_data->len = 5;
  844.                 break;
  845.             case SML_CAT_SIM_C:
  846.                 UnicodeToAnsii(tmp_imsi, (S8*) g_sml_context.input_imsi);
  847.                 mmi_sml_convert_ansii_imsi_to_bcd((U8*) tmp_imsi, local_data->data);
  848.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid1);
  849.                 local_data->data[8] = (U8) atoi(tmp_gid);
  850.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid2);
  851.                 local_data->data[9] = (U8) atoi(tmp_gid);
  852.                 local_data->len = 10;
  853.                 break;
  854.         }
  855.     }
  856.     else
  857.     {
  858.         local_data->len = 0;
  859.         //local_data->gid1 = 0;
  860.         //local_data->gid2 = 0;
  861.     }
  862.     Message.oslSrcId = MOD_MMI;
  863.     Message.oslDestId = MOD_L4C;
  864.     Message.oslMsgId = PRT_MMI_SMU_SET_PERSONALIZATION_REQ;
  865.     Message.oslDataPtr = (oslParaType*) local_data;
  866.     Message.oslPeerBuffPtr = NULL;
  867.     OslMsgSendExtQueue(&Message);
  868. }
  869. /*****************************************************************************
  870.  * FUNCTION
  871.  *  mmi_sml_verify_key_req
  872.  * DESCRIPTION
  873.  *  Verify lock/unlock key request
  874.  * PARAMETERS
  875.  *  void
  876.  * RETURNS
  877.  *  void
  878.  *****************************************************************************/
  879. void mmi_sml_verify_key_req(void)
  880. {
  881.     /*----------------------------------------------------------------*/
  882.     /* Local Variables                                                */
  883.     /*----------------------------------------------------------------*/
  884.     historyNode *History;
  885.     U8 key[MAX_SIM_SETTING_PASSWD_LEN + 1];
  886.     /*----------------------------------------------------------------*/
  887.     /* Code Body                                                      */
  888.     /*----------------------------------------------------------------*/
  889.     if (g_sml_context.key_state[g_sml_context.selected_category] == SML_KEY_EMPTY &&
  890.         g_sml_context.operation_type != SML_OP_UNLOCK)
  891.     {
  892.         /* check new key and confirmation key */
  893.         if (pfnUnicodeStrcmp((S8*) gSecuritySetupContext.NewPassword, (S8*) gSecuritySetupContext.ConfirmPassword) !=
  894.             0)
  895.         {
  896.             memset(gSecuritySetupContext.NewPassword, 0, (MAX_SIM_SETTING_PASSWD_LEN + 1) * ENCODING_LENGTH);
  897.             memset(gSecuritySetupContext.ConfirmPassword, 0, (MAX_SIM_SETTING_PASSWD_LEN + 1) * ENCODING_LENGTH);
  898.             DisplayPopup((PU8) GetString(STR_DIFF_PHONE), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  899.             DeleteScreenIfPresent(SCR_ID_SML_CONFIRM_KEY);
  900.             if (GetHistoryScrID(SCR_ID_SML_INPUT_KEY, &History) == ST_SUCCESS)
  901.             {
  902.                 if (History->inputBuffer != NULL)
  903.                 {
  904.                     memset(History->inputBuffer, 0, ENCODING_LENGTH);
  905.                 }
  906.                 if (History->guiBuffer != NULL)
  907.                 {
  908.                     memset(History->guiBuffer, 0, ENCODING_LENGTH);
  909.                 }
  910.             }
  911.             return;
  912.         }
  913.     }
  914.     UnicodeToAnsii((S8*) key, (S8*) gSecuritySetupContext.NewPassword);
  915.     if (g_sml_context.operation_type != SML_OP_ADD)
  916.     {
  917.         mmi_sml_reset_input_buffer();
  918.     }
  919.     mmi_sml_set_personalization_req(key, g_sml_context.selected_category, g_sml_context.operation_type);
  920. }
  921. /*****************************************************************************
  922.  * FUNCTION
  923.  *  mmi_sml_data_valid_check
  924.  * DESCRIPTION
  925.  *  Check the valiation of input data to add
  926.  * PARAMETERS
  927.  *  void
  928.  * RETURNS
  929.  *  pBOOL
  930.  *****************************************************************************/
  931. pBOOL mmi_sml_data_valid_check(void)
  932. {
  933.     /*----------------------------------------------------------------*/
  934.     /* Local Variables                                                */
  935.     /*----------------------------------------------------------------*/
  936.     pBOOL rtn = 1;
  937.     S8 tmp_gid[MAX_GID_LEN + 1];
  938.     /*----------------------------------------------------------------*/
  939.     /* Code Body                                                      */
  940.     /*----------------------------------------------------------------*/
  941.     switch (g_sml_context.selected_category)
  942.     {
  943.         case SML_CAT_N:
  944.             if (pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) > 0 &&
  945.                 pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) < MAX_NP_LEN - 1)
  946.             {
  947.                 rtn = 0;
  948.             }
  949.             break;
  950.         case SML_CAT_NS:
  951.             if (pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) > 0 &&
  952.                 pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) < MAX_NSP_LEN - 1)
  953.             {
  954.                 rtn = 0;
  955.             }
  956.             break;
  957.         case SML_CAT_SP:
  958.             if (pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) > 0 &&
  959.                 pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) < MAX_NP_LEN - 1)
  960.             {
  961.                 rtn = 0;
  962.             }
  963.             else
  964.             {
  965.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid1);
  966.                 if ((U16) atoi(tmp_gid) > 0xFF)
  967.                 {
  968.                     rtn = 0;
  969.                 }
  970.             }
  971.             break;
  972.         case SML_CAT_C:
  973.             if (pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) > 0 &&
  974.                 pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) < MAX_NP_LEN - 1)
  975.             {
  976.                 rtn = 0;
  977.             }
  978.             else
  979.             {
  980.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid1);
  981.                 if ((U16) atoi(tmp_gid) > 0xFF)
  982.                 {
  983.                     rtn = 0;
  984.                 }
  985.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid2);
  986.                 if ((U16) atoi(tmp_gid) > 0xFF)
  987.                 {
  988.                     rtn = 0;
  989.                 }
  990.             }
  991.             break;
  992.         case SML_CAT_SIM:
  993.             if (pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) > 0 &&
  994.                 pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) < MAX_IMSI_LEN)
  995.             {
  996.                 rtn = 0;
  997.             }
  998.             break;
  999.         case SML_CAT_NS_SP:
  1000.             if (pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) > 0 &&
  1001.                 pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) < MAX_NSP_LEN - 1)
  1002.             {
  1003.                 rtn = 0;
  1004.             }
  1005.             else
  1006.             {
  1007.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid1);
  1008.                 if ((U16) atoi(tmp_gid) > 0xFF)
  1009.                 {
  1010.                     rtn = 0;
  1011.                 }
  1012.             }
  1013.             break;
  1014.         case SML_CAT_SIM_C:
  1015.             if (pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) > 0 &&
  1016.                 pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) < MAX_IMSI_LEN)
  1017.             {
  1018.                 rtn = 0;
  1019.             }
  1020.             else
  1021.             {
  1022.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid1);
  1023.                 if ((U16) atoi(tmp_gid) > 0xFF)
  1024.                 {
  1025.                     rtn = 0;
  1026.                 }
  1027.                 UnicodeToAnsii(tmp_gid, (S8*) g_sml_context.input_gid2);
  1028.                 if ((U16) atoi(tmp_gid) > 0xFF)
  1029.                 {
  1030.                     rtn = 0;
  1031.                 }
  1032.             }
  1033.             break;
  1034.         default:
  1035.             break;
  1036.     }
  1037.     return rtn;
  1038. }
  1039. /*****************************************************************************
  1040.  * FUNCTION
  1041.  *  mmi_sml_allow_to_lock_or_unlock
  1042.  * DESCRIPTION
  1043.  *  Allow to send lock or unlock reuqest to L4C or not
  1044.  * PARAMETERS
  1045.  *  void
  1046.  * RETURNS
  1047.  *  pBOOL
  1048.  *****************************************************************************/
  1049. pBOOL mmi_sml_allow_to_lock_or_unlock(void)
  1050. {
  1051.     /*----------------------------------------------------------------*/
  1052.     /* Local Variables                                                */
  1053.     /*----------------------------------------------------------------*/
  1054.     /*----------------------------------------------------------------*/
  1055.     /* Code Body                                                      */
  1056.     /*----------------------------------------------------------------*/
  1057.     if (g_sml_context.operation_type == SML_OP_LOCK || g_sml_context.operation_type == SML_OP_UNLOCK)
  1058.     {
  1059.         if (g_sml_context.retry_count[g_sml_context.selected_category] == 0)
  1060.         {
  1061.             DisplayPopup((PU8) GetString(STR_ID_SML_BLOCK_MSG), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  1062.             return 0;
  1063.         }
  1064.         if (g_sml_context.operation_type == SML_OP_LOCK &&
  1065.             g_sml_context.category_state[g_sml_context.selected_category] == SML_STATE_LOCK)
  1066.         {
  1067.             DisplayPopup((PU8) GetString(STR_ID_SML_CAT_LOCKED), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, 0);
  1068.             return 0;
  1069.         }
  1070.         if (g_sml_context.operation_type == SML_OP_UNLOCK &&
  1071.             g_sml_context.category_state[g_sml_context.selected_category] == SML_STATE_UNLOCK)
  1072.         {
  1073.             DisplayPopup((PU8) GetString(STR_ID_SML_CAT_UNLOCKED), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, 0);
  1074.             return 0;
  1075.         }
  1076.         if (g_sml_context.used_records[g_sml_context.selected_category] == 0)
  1077.         {
  1078.             DisplayPopup((PU8) GetString(STR_ID_NO_DATA_MSG), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  1079.             return 0;
  1080.         }
  1081.         if (g_sml_context.category_state[g_sml_context.selected_category] == SML_STATE_AUTOLOCK)
  1082.         {
  1083.             DisplayPopup((PU8) GetString(STR_ID_SML_CAT_AUTOLOCKED), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  1084.             return 0;
  1085.         }
  1086.     }
  1087.     return 1;
  1088. }
  1089. /*****************************************************************************
  1090.  * FUNCTION
  1091.  *  mmi_sml_exit_confirm_key
  1092.  * DESCRIPTION
  1093.  *  SML password confirmation screen exit handler
  1094.  * PARAMETERS
  1095.  *  void
  1096.  * RETURNS
  1097.  *  void
  1098.  *****************************************************************************/
  1099. void mmi_sml_exit_confirm_key(void)
  1100. {
  1101.     /*----------------------------------------------------------------*/
  1102.     /* Local Variables                                                */
  1103.     /*----------------------------------------------------------------*/
  1104.     history Scr;    /* Variable to hold the history data */
  1105.     /*----------------------------------------------------------------*/
  1106.     /* Code Body                                                      */
  1107.     /*----------------------------------------------------------------*/
  1108.     Scr.scrnID = SCR_ID_SML_CONFIRM_KEY;
  1109.     Scr.entryFuncPtr = mmi_sml_confirm_key;
  1110.     pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) gSecuritySetupContext.ConfirmPassword);
  1111.     GetCategoryHistory(Scr.guiBuffer);
  1112.     AddHistory(Scr);
  1113. }
  1114. /*****************************************************************************
  1115.  * FUNCTION
  1116.  *  mmi_sml_confirm_key
  1117.  * DESCRIPTION
  1118.  *  SML password confirmation screen
  1119.  * PARAMETERS
  1120.  *  void
  1121.  * RETURNS
  1122.  *  void
  1123.  *****************************************************************************/
  1124. void mmi_sml_confirm_key(void)
  1125. {
  1126.     /*----------------------------------------------------------------*/
  1127.     /* Local Variables                                                */
  1128.     /*----------------------------------------------------------------*/
  1129.     U8 *guiBuffer;
  1130.     U8 *inputBuffer;
  1131.     /*----------------------------------------------------------------*/
  1132.     /* Code Body                                                      */
  1133.     /*----------------------------------------------------------------*/
  1134. #if defined(__MMI_SML_AUTO_KEY_GEN__) && defined(MMI_ON_HARDWARE_P)
  1135.     if (pfnUnicodeStrlen((S8*) gSecuritySetupContext.NewPassword) == 0)
  1136.     {
  1137.         mmi_sml_entry_auto_key_gen_confirm();
  1138.         return;
  1139.     }
  1140. #endif /* defined(__MMI_SML_AUTO_KEY_GEN__) && defined(MMI_ON_HARDWARE_P) */ 
  1141.     EntryNewScreen(SCR_ID_SML_CONFIRM_KEY, mmi_sml_exit_confirm_key, NULL, NULL);
  1142.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_CONFIRM_KEY);
  1143.     inputBuffer = GetCurrInputBuffer(SCR_ID_SML_CONFIRM_KEY);
  1144.     if (inputBuffer == NULL)
  1145.     {
  1146.         memset(gSecuritySetupContext.ConfirmPassword, 0, (MAX_SIM_SETTING_PASSWD_LEN + 1) * ENCODING_LENGTH);
  1147.     }
  1148.     else
  1149.     {
  1150.         pfnUnicodeStrcpy((S8*) gSecuritySetupContext.ConfirmPassword, (S8*) inputBuffer);
  1151.     }
  1152.     /* Hide LSK if input password length is not enough */
  1153.     RegisterInputBoxValidationFunction(mmi_sml_password_screen_lsk_hdlr);
  1154. #ifdef UI_SMALL_PIN_EDITOR_SCREEN
  1155.     enable_resized_small_screen();
  1156. #endif 
  1157.     ShowCategory111Screen(
  1158.         STR_GLOBAL_OK,
  1159.         IMG_GLOBAL_OK,
  1160.         STR_GLOBAL_BACK,
  1161.         IMG_GLOBAL_BACK,
  1162.         STR_SCR9031_CONFIRM_PW_CAPTION,
  1163.         INPUT_TYPE_NUMERIC_PASSWORD,
  1164.         gSecuritySetupContext.ConfirmPassword,
  1165.         (MAX_SIM_SETTING_PASSWD_LEN + 1),
  1166.         NULL,
  1167.         guiBuffer);
  1168.     SetCategory111RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1169.     SetKeyHandler(mmi_sml_verify_key_req, KEY_POUND, KEY_EVENT_UP);
  1170.     SetLeftSoftkeyFunction(mmi_sml_verify_key_req, KEY_EVENT_UP);
  1171.     gSecuritySetupContext.PasswdLenCheckCallBack = mmi_sml_verify_key_req;
  1172.     if (pfnUnicodeStrlen((S8*) gSecuritySetupContext.ConfirmPassword) < MIN_PASSWORD_LENGTH)
  1173.     {
  1174.         ChangeLeftSoftkey(0, 0);
  1175.         ClearKeyHandler(KEY_POUND, KEY_EVENT_UP);
  1176.     }
  1177. }
  1178. /*****************************************************************************
  1179.  * FUNCTION
  1180.  *  mmi_sml_exit_input_key
  1181.  * DESCRIPTION
  1182.  *  SML password input screen exit handler
  1183.  * PARAMETERS
  1184.  *  void
  1185.  * RETURNS
  1186.  *  void
  1187.  *****************************************************************************/
  1188. void mmi_sml_exit_input_key(void)
  1189. {
  1190.     /*----------------------------------------------------------------*/
  1191.     /* Local Variables                                                */
  1192.     /*----------------------------------------------------------------*/
  1193.     history Scr;    /* Variable to hold the history data */
  1194.     /*----------------------------------------------------------------*/
  1195.     /* Code Body                                                      */
  1196.     /*----------------------------------------------------------------*/
  1197.     Scr.scrnID = SCR_ID_SML_INPUT_KEY;
  1198.     Scr.entryFuncPtr = mmi_sml_input_key;
  1199.     pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) gSecuritySetupContext.NewPassword);
  1200.     GetCategoryHistory(Scr.guiBuffer);
  1201.     AddHistory(Scr);
  1202. }
  1203. /*****************************************************************************
  1204.  * FUNCTION
  1205.  *  mmi_sml_input_key
  1206.  * DESCRIPTION
  1207.  *  SML password input screen
  1208.  * PARAMETERS
  1209.  *  void
  1210.  * RETURNS
  1211.  *  void
  1212.  *****************************************************************************/
  1213. void mmi_sml_input_key(void)
  1214. {
  1215.     /*----------------------------------------------------------------*/
  1216.     /* Local Variables                                                */
  1217.     /*----------------------------------------------------------------*/
  1218.     U8 *guiBuffer;
  1219.     U8 *inputBuffer;
  1220.     S8 temp1[MAX_PASS_COUNTDOWN_DISP];
  1221.     S8 temp2[MAX_PASS_COUNTDOWN_DISP];
  1222.     /*----------------------------------------------------------------*/
  1223.     /* Code Body                                                      */
  1224.     /*----------------------------------------------------------------*/
  1225.     if (!mmi_sml_allow_to_lock_or_unlock())
  1226.     {
  1227.         return;
  1228.     }
  1229.     if (g_sml_context.operation_type == SML_OP_ADD && mmi_sml_data_valid_check() == 0)
  1230.     {
  1231.         DisplayPopup((PU8) GetString(STR_ID_SML_INVALID_DATA), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  1232.         return;
  1233.     }
  1234.     EntryNewScreen(SCR_ID_SML_INPUT_KEY, mmi_sml_exit_input_key, NULL, NULL);
  1235.     sprintf(temp1, " %d", g_sml_context.retry_count[g_sml_context.selected_category]);
  1236.     AnsiiToUnicodeString(temp2, temp1);
  1237.     pfnUnicodeStrcpy((S8*) temp1, (S8*) GetString(STR_PASS_TRIALS_REMAIN));
  1238.     pfnUnicodeStrcat((S8*) temp1, (S8*) temp2);
  1239.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_INPUT_KEY);
  1240.     inputBuffer = GetCurrInputBuffer(SCR_ID_SML_INPUT_KEY);
  1241.     if (inputBuffer == NULL)
  1242.     {
  1243.         memset(gSecuritySetupContext.NewPassword, 0, (MAX_SIM_SETTING_PASSWD_LEN + 1) * ENCODING_LENGTH);
  1244.     }
  1245.     else
  1246.     {
  1247.         pfnUnicodeStrcpy((S8*) gSecuritySetupContext.NewPassword, (S8*) inputBuffer);
  1248.     }
  1249.     /* Hide LSK if input password length is not enough */
  1250.     RegisterInputBoxValidationFunction(mmi_sml_password_screen_lsk_hdlr);
  1251. #ifdef UI_SMALL_PIN_EDITOR_SCREEN
  1252.     enable_resized_small_screen();
  1253. #endif 
  1254.     if (g_sml_context.key_state[g_sml_context.selected_category] == SML_KEY_SET ||
  1255.         (g_sml_context.key_state[g_sml_context.selected_category] == SML_KEY_EMPTY &&
  1256.          g_sml_context.operation_type == SML_OP_UNLOCK))
  1257.     {
  1258.         if (g_sml_context.operation_type == SML_OP_UNLOCK)
  1259.         {
  1260.             ShowCategory111Screen(
  1261.                 STR_GLOBAL_OK,
  1262.                 IMG_GLOBAL_OK,
  1263.                 STR_GLOBAL_BACK,
  1264.                 IMG_GLOBAL_BACK,
  1265.                 STR_RESTORE_PHONE,
  1266.                 INPUT_TYPE_NUMERIC_PASSWORD,
  1267.                 gSecuritySetupContext.NewPassword,
  1268.                 (MAX_SIM_SETTING_PASSWD_LEN + 1),
  1269.                 (U8*) temp1,    /* apply retry count */
  1270.                 guiBuffer);
  1271.         }
  1272.         else
  1273.         {
  1274.             ShowCategory111Screen(
  1275.                 STR_GLOBAL_OK,
  1276.                 IMG_GLOBAL_OK,
  1277.                 STR_GLOBAL_BACK,
  1278.                 IMG_GLOBAL_BACK,
  1279.                 STR_RESTORE_PHONE,
  1280.                 INPUT_TYPE_NUMERIC_PASSWORD,
  1281.                 gSecuritySetupContext.NewPassword,
  1282.                 (MAX_SIM_SETTING_PASSWD_LEN + 1),
  1283.                 NULL,   /* retry count only works for unlocking a category */
  1284.                 guiBuffer);
  1285.         }
  1286.         SetCategory111RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1287.         SetKeyHandler(mmi_sml_verify_key_req, KEY_POUND, KEY_EVENT_UP);
  1288.         SetLeftSoftkeyFunction(mmi_sml_verify_key_req, KEY_EVENT_UP);
  1289.         gSecuritySetupContext.PasswdLenCheckCallBack = mmi_sml_verify_key_req;
  1290.     }
  1291.     else
  1292.     {
  1293.         ShowCategory111Screen(
  1294.             STR_GLOBAL_OK,
  1295.             IMG_GLOBAL_OK,
  1296.             STR_GLOBAL_BACK,
  1297.             IMG_GLOBAL_BACK,
  1298.             STR_RESTORE_PHONE,
  1299.             INPUT_TYPE_NUMERIC_PASSWORD,
  1300.             gSecuritySetupContext.NewPassword,
  1301.             (MAX_SIM_SETTING_PASSWD_LEN + 1),
  1302.             NULL,   /* need to input key twice */
  1303.             guiBuffer);
  1304.         SetCategory111RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1305.         SetKeyHandler(mmi_sml_confirm_key, KEY_POUND, KEY_EVENT_UP);
  1306.         SetLeftSoftkeyFunction(mmi_sml_confirm_key, KEY_EVENT_UP);
  1307.         gSecuritySetupContext.PasswdLenCheckCallBack = mmi_sml_confirm_key;
  1308.     }
  1309.     if (g_sml_context.operation_type == SML_OP_UNLOCK ||
  1310. #if defined(__MMI_SML_AUTO_KEY_GEN__) && defined(MMI_ON_HARDWARE_P)
  1311.         ( pfnUnicodeStrlen((S8*) gSecuritySetupContext.NewPassword) > 0 && pfnUnicodeStrlen((S8*) gSecuritySetupContext.NewPassword) < MIN_PASSWORD_LENGTH) )
  1312. #else
  1313.         pfnUnicodeStrlen((S8*) gSecuritySetupContext.NewPassword) < MIN_PASSWORD_LENGTH)
  1314. #endif
  1315.     {
  1316.         ChangeLeftSoftkey(0, 0);
  1317.         ClearKeyHandler(KEY_POUND, KEY_EVENT_UP);
  1318.     }
  1319. }
  1320. /*****************************************************************************
  1321.  * FUNCTION
  1322.  *  mmi_sml_generic_highlight_handler
  1323.  * DESCRIPTION
  1324.  *  SML generic highlight handler
  1325.  * PARAMETERS
  1326.  *  index       [IN]        
  1327.  * RETURNS
  1328.  *  void
  1329.  *****************************************************************************/
  1330. void mmi_sml_generic_highlight_handler(S32 index)
  1331. {
  1332.     /*----------------------------------------------------------------*/
  1333.     /* Local Variables                                                */
  1334.     /*----------------------------------------------------------------*/
  1335.     U8 i;
  1336.     S32 count = -1;
  1337.     /*----------------------------------------------------------------*/
  1338.     /* Code Body                                                      */
  1339.     /*----------------------------------------------------------------*/
  1340.     g_sml_context.selected_category = (U8) index;
  1341.     /* count the deactivated items */
  1342.     for (i = 0; i < SML_CAT_SIZE; i++)
  1343.     {
  1344.         if (g_sml_context.category_state[i] == SML_STATE_DISABLE || g_sml_context.category_state[i] == SML_STATE_NULL)
  1345.         {
  1346.             g_sml_context.selected_category++;
  1347.         }
  1348.         else
  1349.         {
  1350.             count++;
  1351.         }
  1352.         if (count == index)
  1353.         {
  1354.             break;
  1355.         }
  1356.     }
  1357.     return;
  1358. }
  1359. /*****************************************************************************
  1360.  * FUNCTION
  1361.  *  mmi_sml_entry_lock_category_selection
  1362.  * DESCRIPTION
  1363.  *  Lock catrgories entry screen
  1364.  * PARAMETERS
  1365.  *  void
  1366.  * RETURNS
  1367.  *  void
  1368.  *****************************************************************************/
  1369. void mmi_sml_entry_lock_category_selection(void)
  1370. {
  1371.     /*----------------------------------------------------------------*/
  1372.     /* Local Variables                                                */
  1373.     /*----------------------------------------------------------------*/
  1374.     U8 nNumofItem = 0;  /* Need to get response from SMU */
  1375.     U8 *guiBuffer;
  1376.     U16 aStrItemList[SML_CAT_SIZE] =
  1377.         {STR_ID_CATEGORY_NP_LOCK, STR_ID_CATEGORY_NSP_LOCK, STR_ID_CATEGORY_SP_LOCK, STR_ID_CATEGORY_CP_LOCK,
  1378.         STR_ID_CATEGORY_SIMP_LOCK, STR_ID_CATEGORY_NSP_SP_LOCK, STR_ID_CATEGORY_SIMP_CP_LOCK};
  1379.     U16 nStrItemList[SML_CAT_SIZE];
  1380.     U8 i;
  1381.     /*----------------------------------------------------------------*/
  1382.     /* Code Body                                                      */
  1383.     /*----------------------------------------------------------------*/
  1384.     if (!mmi_bootup_is_sim_valid())
  1385.     {
  1386.         return;
  1387.     }
  1388.     EntryNewScreen(SCR_ID_SML_LOCK_MENU, NULL, mmi_sml_entry_lock_category_selection, NULL);
  1389.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_LOCK_MENU);
  1390.     RegisterHighlightHandler(mmi_sml_generic_highlight_handler);
  1391.     /* Hide some unsupported personalization categories */
  1392.     for (i = 0; i < SML_CAT_SIZE; i++)
  1393.     {
  1394.         if (g_sml_context.category_state[i] != SML_STATE_DISABLE && g_sml_context.category_state[i] != SML_STATE_NULL)
  1395.         {
  1396.             nStrItemList[nNumofItem] = aStrItemList[i];
  1397.             nNumofItem++;
  1398.         }
  1399.     }
  1400.     if (g_sml_context.operation_type != SML_OP_LOCK)
  1401.     {
  1402.         g_sml_context.operation_type = SML_OP_LOCK;
  1403.         g_sml_context.selected_category = 0;
  1404.     }
  1405.     if (nNumofItem == 0)
  1406.     {
  1407.         ShowCategory2Screen(
  1408.             STR_ID_SML_LOCK_MENU,
  1409.             MAIN_MENU_TITLE_SETTINGS_ICON,
  1410.             STR_GLOBAL_OK,
  1411.             IMG_GLOBAL_OK,
  1412.             0,
  1413.             0,
  1414.             STR_ID_EMPTY_CATEGORY_MSG,
  1415.             NULL);
  1416.         SetLeftSoftkeyFunction(EntryIdleScreen, KEY_EVENT_UP);
  1417.     }
  1418.     else
  1419.     {
  1420.         ShowCategory11Screen(
  1421.             STR_ID_SML_LOCK_MENU,
  1422.             MAIN_MENU_TITLE_SETTINGS_ICON,
  1423.             STR_GLOBAL_OK,
  1424.             IMG_GLOBAL_OK,
  1425.             STR_GLOBAL_BACK,
  1426.             IMG_GLOBAL_BACK,
  1427.             nNumofItem,
  1428.             nStrItemList,
  1429.             g_sml_context.selected_category,
  1430.             guiBuffer);
  1431.         SetLeftSoftkeyFunction(mmi_sml_input_key, KEY_EVENT_UP);
  1432.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1433.         SetKeyHandler(0, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1434.         SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1435.     }
  1436. }
  1437. /*****************************************************************************
  1438.  * FUNCTION
  1439.  *  mmi_sml_entry_unlock_category_selection
  1440.  * DESCRIPTION
  1441.  *  Unlock catrgories entry screen
  1442.  * PARAMETERS
  1443.  *  void
  1444.  * RETURNS
  1445.  *  void
  1446.  *****************************************************************************/
  1447. void mmi_sml_entry_unlock_category_selection(void)
  1448. {
  1449.     /*----------------------------------------------------------------*/
  1450.     /* Local Variables                                                */
  1451.     /*----------------------------------------------------------------*/
  1452.     U8 nNumofItem = 0;  /* Need to get response from SMU */
  1453.     U8 *guiBuffer;
  1454.     U16 aStrItemList[SML_CAT_SIZE] =
  1455.         {STR_ID_CATEGORY_NP_LOCK, STR_ID_CATEGORY_NSP_LOCK, STR_ID_CATEGORY_SP_LOCK, STR_ID_CATEGORY_CP_LOCK,
  1456.         STR_ID_CATEGORY_SIMP_LOCK, STR_ID_CATEGORY_NSP_SP_LOCK, STR_ID_CATEGORY_SIMP_CP_LOCK};
  1457.     U16 nStrItemList[SML_CAT_SIZE];
  1458.     U8 i;
  1459.     /*----------------------------------------------------------------*/
  1460.     /* Code Body                                                      */
  1461.     /*----------------------------------------------------------------*/
  1462.     if (!mmi_bootup_is_sim_valid())
  1463.     {
  1464.         return;
  1465.     }
  1466.     EntryNewScreen(SCR_ID_SML_UNLOCK_MENU, NULL, mmi_sml_entry_unlock_category_selection, NULL);
  1467.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_UNLOCK_MENU);
  1468.     RegisterHighlightHandler(mmi_sml_generic_highlight_handler);
  1469.     /* Hide some unsupported personalization categories */
  1470.     for (i = 0; i < SML_CAT_SIZE; i++)
  1471.     {
  1472.         if (g_sml_context.category_state[i] != SML_STATE_DISABLE && g_sml_context.category_state[i] != SML_STATE_NULL)
  1473.         {
  1474.             nStrItemList[nNumofItem] = aStrItemList[i];
  1475.             nNumofItem++;
  1476.         }
  1477.     }
  1478.     if (g_sml_context.operation_type != SML_OP_UNLOCK)
  1479.     {
  1480.         g_sml_context.operation_type = SML_OP_UNLOCK;
  1481.         g_sml_context.selected_category = 0;
  1482.     }
  1483.     if (nNumofItem == 0)
  1484.     {
  1485.         ShowCategory2Screen(
  1486.             STR_ID_SML_UNLOCK_MENU,
  1487.             MAIN_MENU_TITLE_SETTINGS_ICON,
  1488.             STR_GLOBAL_OK,
  1489.             IMG_GLOBAL_OK,
  1490.             0,
  1491.             0,
  1492.             STR_ID_EMPTY_CATEGORY_MSG,
  1493.             NULL);
  1494.         SetLeftSoftkeyFunction(EntryIdleScreen, KEY_EVENT_UP);
  1495.     }
  1496.     else
  1497.     {
  1498.         ShowCategory11Screen(
  1499.             STR_ID_SML_UNLOCK_MENU,
  1500.             MAIN_MENU_TITLE_SETTINGS_ICON,
  1501.             STR_GLOBAL_OK,
  1502.             IMG_GLOBAL_OK,
  1503.             STR_GLOBAL_BACK,
  1504.             IMG_GLOBAL_BACK,
  1505.             nNumofItem,
  1506.             nStrItemList,
  1507.             g_sml_context.selected_category,
  1508.             guiBuffer);
  1509.         SetLeftSoftkeyFunction(mmi_sml_input_key, KEY_EVENT_UP);
  1510.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1511.         SetKeyHandler(0, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1512.         SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1513.     }
  1514. }
  1515. /*****************************************************************************
  1516.  * FUNCTION
  1517.  *  mmi_sml_fill_add_data_editor
  1518.  * DESCRIPTION
  1519.  *  Inline editor of add data
  1520.  * PARAMETERS
  1521.  *  void
  1522.  * RETURNS
  1523.  *  void
  1524.  *****************************************************************************/
  1525. void mmi_sml_fill_add_data_editor(void)
  1526. {
  1527.     /*----------------------------------------------------------------*/
  1528.     /* Local Variables                                                */
  1529.     /*----------------------------------------------------------------*/
  1530.     /*----------------------------------------------------------------*/
  1531.     /* Code Body                                                      */
  1532.     /*----------------------------------------------------------------*/
  1533.     mmi_sml_reset_input_buffer();
  1534.     switch (g_sml_context.selected_category)
  1535.     {
  1536.         case SML_CAT_NS:
  1537.         case SML_CAT_NS_SP:
  1538.             SetInlineItemActivation(&wgui_inline_items[0], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1539.             SetInlineItemCaption(&wgui_inline_items[0], (U8*) GetString(STR_ID_SML_NSP_DATA));
  1540.             SetInlineItemActivation(&wgui_inline_items[1], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1541.             SetInlineItemTextEdit(
  1542.                 &wgui_inline_items[1],
  1543.                 (PU8) g_sml_context.input_imsi,
  1544.                 MAX_NSP_LEN + 1,
  1545.                 INPUT_TYPE_NUMERIC);
  1546.             break;
  1547.         case SML_CAT_SIM:
  1548.         case SML_CAT_SIM_C:
  1549.             SetInlineItemActivation(&wgui_inline_items[0], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1550.             SetInlineItemCaption(&wgui_inline_items[0], (U8*) GetString(STR_ID_SML_SIMP_DATA));
  1551.             SetInlineItemActivation(&wgui_inline_items[1], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1552.             SetInlineItemTextEdit(
  1553.                 &wgui_inline_items[1],
  1554.                 (PU8) g_sml_context.input_imsi,
  1555.                 MAX_IMSI_LEN + 1,
  1556.                 INPUT_TYPE_NUMERIC);
  1557.             break;
  1558.         case SML_CAT_N:
  1559.         case SML_CAT_SP:
  1560.         case SML_CAT_C:
  1561.         default:
  1562.             SetInlineItemActivation(&wgui_inline_items[0], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1563.             SetInlineItemCaption(&wgui_inline_items[0], (U8*) GetString(STR_ID_SML_NP_DATA));
  1564.             SetInlineItemActivation(&wgui_inline_items[1], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1565.             SetInlineItemTextEdit(
  1566.                 &wgui_inline_items[1],
  1567.                 (PU8) g_sml_context.input_imsi,
  1568.                 MAX_NP_LEN + 1,
  1569.                 INPUT_TYPE_NUMERIC);
  1570.             break;
  1571.     }
  1572.     SetInlineItemActivation(&wgui_inline_items[2], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1573.     SetInlineItemCaption(&wgui_inline_items[2], (U8*) GetString(STR_ID_SML_SP_DATA));
  1574.     SetInlineItemActivation(&wgui_inline_items[3], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1575.     SetInlineItemTextEdit(&wgui_inline_items[3], (PU8) g_sml_context.input_gid1, MAX_GID_LEN + 1, INPUT_TYPE_NUMERIC);
  1576.     SetInlineItemActivation(&wgui_inline_items[4], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1577.     SetInlineItemCaption(&wgui_inline_items[4], (U8*) GetString(STR_ID_SML_CP_DATA));
  1578.     SetInlineItemActivation(&wgui_inline_items[5], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1579.     SetInlineItemTextEdit(&wgui_inline_items[5], (PU8) g_sml_context.input_gid2, MAX_GID_LEN + 1, INPUT_TYPE_NUMERIC);
  1580. }
  1581. /*****************************************************************************
  1582.  * FUNCTION
  1583.  *  mmi_sml_process_add_data
  1584.  * DESCRIPTION
  1585.  *  Process of user input add data
  1586.  * PARAMETERS
  1587.  *  void
  1588.  * RETURNS
  1589.  *  void
  1590.  *****************************************************************************/
  1591. void mmi_sml_process_add_data(void)
  1592. {
  1593.     /*----------------------------------------------------------------*/
  1594.     /* Local Variables                                                */
  1595.     /*----------------------------------------------------------------*/
  1596.     /*----------------------------------------------------------------*/
  1597.     /* Code Body                                                      */
  1598.     /*----------------------------------------------------------------*/
  1599.     if (pfnUnicodeStrlen((S8*) g_sml_context.input_imsi) == 0 /* && pfnUnicodeStrlen((S8*)g_sml_context.input_gid1) == 0 */)
  1600.     {
  1601.         /* query for read data from SIM */
  1602.         mmi_sml_read_data_from_sim_query();
  1603.     }
  1604.     else
  1605.     {
  1606.         /* lock it */
  1607.         mmi_sml_input_key();
  1608.     }
  1609. }
  1610. /*****************************************************************************
  1611.  * FUNCTION
  1612.  *  mmi_sml_highlight_add_data
  1613.  * DESCRIPTION
  1614.  *  Highlight handler of input data to add
  1615.  * PARAMETERS
  1616.  *  index       [IN]        
  1617.  * RETURNS
  1618.  *  void
  1619.  *****************************************************************************/
  1620. void mmi_sml_highlight_add_data(S32 index)
  1621. {
  1622.     /*----------------------------------------------------------------*/
  1623.     /* Local Variables                                                */
  1624.     /*----------------------------------------------------------------*/
  1625.     /*----------------------------------------------------------------*/
  1626.     /* Code Body                                                      */
  1627.     /*----------------------------------------------------------------*/
  1628.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  1629.     SetCategory57LeftSoftkeyFunction(mmi_sml_process_add_data);
  1630. }
  1631. /*****************************************************************************
  1632.  * FUNCTION
  1633.  *  mmi_sml_exit_add_data
  1634.  * DESCRIPTION
  1635.  *  Exit screen of input data to add
  1636.  * PARAMETERS
  1637.  *  void
  1638.  * RETURNS
  1639.  *  void
  1640.  *****************************************************************************/
  1641. void mmi_sml_exit_add_data(void)
  1642. {
  1643.     /*----------------------------------------------------------------*/
  1644.     /* Local Variables                                                */
  1645.     /*----------------------------------------------------------------*/
  1646.     history h;
  1647.     U16 inputBufferSize;
  1648.     /*----------------------------------------------------------------*/
  1649.     /* Code Body                                                      */
  1650.     /*----------------------------------------------------------------*/
  1651.     CloseCategory57Screen();
  1652.     h.scrnID = SCR_ID_SML_FILL_DATA;
  1653.     h.entryFuncPtr = mmi_sml_entry_add_data;
  1654.     GetCategoryHistory(h.guiBuffer);
  1655.     inputBufferSize = (U16) GetCategory57DataSize();
  1656.     GetCategory57Data((U8*) h.inputBuffer);
  1657.     AddNHistory(h, inputBufferSize);
  1658. }
  1659. /*****************************************************************************
  1660.  * FUNCTION
  1661.  *  mmi_sml_entry_add_data
  1662.  * DESCRIPTION
  1663.  *  Entry screen of input data to add
  1664.  * PARAMETERS
  1665.  *  void
  1666.  * RETURNS
  1667.  *  void
  1668.  *****************************************************************************/
  1669. void mmi_sml_entry_add_data(void)
  1670. {
  1671.     /*----------------------------------------------------------------*/
  1672.     /* Local Variables                                                */
  1673.     /*----------------------------------------------------------------*/
  1674.     U8 *guiBuffer;          /* Buffer holding history data */
  1675.     U8 *inputBuffer;        /* added for inline edit history */
  1676.     U16 inputBufferSize;    /* added for inline edit history */
  1677.     U8 inputItems;
  1678.     /*----------------------------------------------------------------*/
  1679.     /* Code Body                                                      */
  1680.     /*----------------------------------------------------------------*/
  1681.     if (g_sml_context.category_state[g_sml_context.selected_category] == SML_STATE_LOCK)
  1682.     {
  1683.         DisplayPopup((PU8) GetString(STR_ID_UNLOCK_FIRST_MSG), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  1684.         return;
  1685.     }
  1686.     if (g_sml_context.used_records[g_sml_context.selected_category] ==
  1687.         g_sml_context.total_records[g_sml_context.selected_category])
  1688.     {
  1689.         DisplayPopup((PU8) GetString(STR_ID_NO_RECORD_MSG), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  1690.         return;
  1691.     }
  1692.     if (g_sml_context.category_state[g_sml_context.selected_category] == SML_STATE_AUTOLOCK)
  1693.     {
  1694.         DisplayPopup((PU8) GetString(STR_ID_SML_CAT_AUTOLOCKED), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  1695.         return;
  1696.     }
  1697.     EntryNewScreen(SCR_ID_SML_FILL_DATA, mmi_sml_exit_add_data, NULL, NULL);
  1698.     InitializeCategory57Screen();
  1699.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_FILL_DATA);
  1700.     inputBuffer = GetCurrNInputBuffer(SCR_ID_SML_FILL_DATA, &inputBufferSize);  /* added for inline edit history */
  1701.     mmi_sml_fill_add_data_editor();
  1702.     RegisterHighlightHandler(mmi_sml_highlight_add_data);
  1703.     switch (g_sml_context.selected_category)
  1704.     {
  1705.         case SML_CAT_SP:
  1706.         case SML_CAT_NS_SP:
  1707.             inputItems = 4;
  1708.             break;
  1709.         case SML_CAT_C:
  1710.         case SML_CAT_SIM_C:
  1711.             inputItems = 6;
  1712.             break;
  1713.         case SML_CAT_N:
  1714.         case SML_CAT_NS:
  1715.         case SML_CAT_SIM:
  1716.         default:
  1717.             inputItems = 2;
  1718.             break;
  1719.     }
  1720.     if (inputBuffer != NULL)
  1721.     {
  1722.         SetCategory57Data(wgui_inline_items, inputItems, inputBuffer);
  1723.     }
  1724.     ShowCategory57Screen(
  1725.         STR_ID_SML_ADD_MENU,
  1726.         MAIN_MENU_TITLE_SETTINGS_ICON,
  1727.         STR_GLOBAL_OK,
  1728.         IMG_GLOBAL_OK,
  1729.         STR_GLOBAL_BACK,
  1730.         IMG_GLOBAL_BACK,
  1731.         inputItems,
  1732.         NULL,
  1733.         wgui_inline_items,
  1734.         1,
  1735.         guiBuffer);
  1736.     DisableCategory57ScreenDone();
  1737.     SetCategory57RightSoftkeyFunctions(GoBackHistory, GoBackHistory);
  1738. }
  1739. /*****************************************************************************
  1740.  * FUNCTION
  1741.  *  mmi_sml_auto_generate_data
  1742.  * DESCRIPTION
  1743.  *  Automatic data generation from SIM
  1744.  * PARAMETERS
  1745.  *  void
  1746.  * RETURNS
  1747.  *  void
  1748.  *****************************************************************************/
  1749. void mmi_sml_auto_generate_data(void)
  1750. {
  1751.     /*----------------------------------------------------------------*/
  1752.     /* Local Variables                                                */
  1753.     /*----------------------------------------------------------------*/
  1754.     /*----------------------------------------------------------------*/
  1755.     /* Code Body                                                      */
  1756.     /*----------------------------------------------------------------*/
  1757.     switch (g_sml_context.selected_category)
  1758.     {
  1759.         case SML_CAT_N:
  1760.             AnsiiNToUnicodeString(
  1761.                 (S8*) g_sml_context.input_imsi,
  1762.                 (S8*) g_sml_context.imsi,
  1763.                 g_sml_context.digits_of_mcc_mnc);
  1764.             break;
  1765.         case SML_CAT_NS:
  1766.             AnsiiNToUnicodeString(
  1767.                 (S8*) g_sml_context.input_imsi,
  1768.                 (S8*) g_sml_context.imsi,
  1769.                 g_sml_context.digits_of_mcc_mnc + 2);
  1770.             break;
  1771.         case SML_CAT_SP:    /* 5 or 6 digits of IMSI + GID1 */
  1772.             if (!mmi_sml_is_gid1_valid())
  1773.             {
  1774.                 DisplayPopup((U8*) GetString(STR_ID_SML_NO_EF_GID), IMG_GLOBAL_WARNING, 0, 2000, (U8) ERROR_TONE);
  1775.                 return;
  1776.             }
  1777.             AnsiiNToUnicodeString(
  1778.                 (S8*) g_sml_context.input_imsi,
  1779.                 (S8*) g_sml_context.imsi,
  1780.                 g_sml_context.digits_of_mcc_mnc);
  1781.             gui_itoa(g_sml_context.gid1, (U16*) (&g_sml_context.input_gid1[0]), 10);
  1782.             break;
  1783.         case SML_CAT_C: /* 5 or 6 digits of IMSI + GID1 + GID2 */
  1784.             if (!mmi_sml_is_gid1_valid() || !mmi_sml_is_gid2_valid())
  1785.             {
  1786.                 DisplayPopup((U8*) GetString(STR_ID_SML_NO_EF_GID), IMG_GLOBAL_WARNING, 0, 2000, (U8) ERROR_TONE);
  1787.                 return;
  1788.             }
  1789.             AnsiiNToUnicodeString(
  1790.                 (S8*) g_sml_context.input_imsi,
  1791.                 (S8*) g_sml_context.imsi,
  1792.                 g_sml_context.digits_of_mcc_mnc);
  1793.             gui_itoa(g_sml_context.gid1, (U16*) (&g_sml_context.input_gid1[0]), 10);
  1794.             gui_itoa(g_sml_context.gid2, (U16*) (&g_sml_context.input_gid2[0]), 10);
  1795.             break;
  1796.         case SML_CAT_SIM:   /* IMSI */
  1797.             AnsiiToUnicodeString((S8*) g_sml_context.input_imsi, (S8*) g_sml_context.imsi);
  1798.             break;
  1799.         case SML_CAT_NS_SP: /* 7 or 8 digits of IMSI + GID1 */
  1800.             if (!mmi_sml_is_gid1_valid())
  1801.             {
  1802.                 DisplayPopup((U8*) GetString(STR_ID_SML_NO_EF_GID), IMG_GLOBAL_WARNING, 0, 2000, (U8) ERROR_TONE);
  1803.                 return;
  1804.             }
  1805.             AnsiiNToUnicodeString(
  1806.                 (S8*) g_sml_context.input_imsi,
  1807.                 (S8*) g_sml_context.imsi,
  1808.                 g_sml_context.digits_of_mcc_mnc + 2);
  1809.             gui_itoa(g_sml_context.gid1, (U16*) (&g_sml_context.input_gid1[0]), 10);
  1810.             break;
  1811.         case SML_CAT_SIM_C: /* IMSI + GID1 + GID2 */
  1812.             if (!mmi_sml_is_gid1_valid() || !mmi_sml_is_gid2_valid())
  1813.             {
  1814.                 DisplayPopup((U8*) GetString(STR_ID_SML_NO_EF_GID), IMG_GLOBAL_WARNING, 0, 2000, (U8) ERROR_TONE);
  1815.                 return;
  1816.             }
  1817.             AnsiiToUnicodeString((S8*) g_sml_context.input_imsi, (S8*) g_sml_context.imsi);
  1818.             gui_itoa(g_sml_context.gid1, (U16*) (&g_sml_context.input_gid1[0]), 10);
  1819.             gui_itoa(g_sml_context.gid2, (U16*) (&g_sml_context.input_gid2[0]), 10);
  1820.             break;
  1821.         default:
  1822.             break;
  1823.     }
  1824.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, 0);
  1825.     DeleteScreenIfPresent(SCR_ID_SML_FILL_DATA);
  1826.     GenericExitScreen(SCR_ID_SML_INPUT_KEY, mmi_sml_input_key); /* continue to input key after popup disappears */
  1827. }
  1828. /*****************************************************************************
  1829.  * FUNCTION
  1830.  *  mmi_sml_read_data_from_sim_query
  1831.  * DESCRIPTION
  1832.  *  Query for automatically read data from SIM to add
  1833.  * PARAMETERS
  1834.  *  void
  1835.  * RETURNS
  1836.  *  void
  1837.  *****************************************************************************/
  1838. void mmi_sml_read_data_from_sim_query(void)
  1839. {
  1840.     /*----------------------------------------------------------------*/
  1841.     /* Local Variables                                                */
  1842.     /*----------------------------------------------------------------*/
  1843.     U8 *guiBuffer;
  1844.     /*----------------------------------------------------------------*/
  1845.     /* Code Body                                                      */
  1846.     /*----------------------------------------------------------------*/
  1847.     EntryNewScreen(SCR_ID_SML_QUERY_POPUP, NULL, NULL, NULL);
  1848.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_QUERY_POPUP);
  1849.     ShowCategory162Screen(
  1850.         STR_GLOBAL_YES,
  1851.         IMG_GLOBAL_YES,
  1852.         STR_GLOBAL_NO,
  1853.         IMG_GLOBAL_NO,
  1854.         STR_ID_SML_QUREY_MSG,
  1855.         IMG_GLOBAL_QUESTION,
  1856.         guiBuffer);
  1857.     SetLeftSoftkeyFunction(mmi_sml_auto_generate_data, KEY_EVENT_UP);
  1858.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1859.     playRequestedTone(WARNING_TONE);
  1860. }
  1861. /*****************************************************************************
  1862.  * FUNCTION
  1863.  *  mmi_sml_entry_add_category_data
  1864.  * DESCRIPTION
  1865.  *  Add data catrgories entry screen
  1866.  * PARAMETERS
  1867.  *  void
  1868.  * RETURNS
  1869.  *  void
  1870.  *****************************************************************************/
  1871. void mmi_sml_entry_add_category_data(void)
  1872. {
  1873.     /*----------------------------------------------------------------*/
  1874.     /* Local Variables                                                */
  1875.     /*----------------------------------------------------------------*/
  1876.     U8 nNumofItem = 0;  /* Need to get response from SMU */
  1877.     U8 *guiBuffer;
  1878.     U16 aStrItemList[SML_CAT_SIZE] =
  1879.         {STR_ID_CATEGORY_NP_LOCK, STR_ID_CATEGORY_NSP_LOCK, STR_ID_CATEGORY_SP_LOCK, STR_ID_CATEGORY_CP_LOCK,
  1880.         STR_ID_CATEGORY_SIMP_LOCK, STR_ID_CATEGORY_NSP_SP_LOCK, STR_ID_CATEGORY_SIMP_CP_LOCK};
  1881.     U16 nStrItemList[SML_CAT_SIZE];
  1882.     U8 i;
  1883.     /*----------------------------------------------------------------*/
  1884.     /* Code Body                                                      */
  1885.     /*----------------------------------------------------------------*/
  1886.     if (!mmi_bootup_is_sim_valid())
  1887.     {
  1888.         return;
  1889.     }
  1890.     EntryNewScreen(SCR_ID_SML_ADD_MENU, NULL, mmi_sml_entry_add_category_data, NULL);
  1891.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_ADD_MENU);
  1892.     RegisterHighlightHandler(mmi_sml_generic_highlight_handler);
  1893.     /* Hide some unsupported personalization categories */
  1894.     for (i = 0; i < SML_CAT_SIZE; i++)
  1895.     {
  1896.         if (g_sml_context.category_state[i] != SML_STATE_DISABLE && g_sml_context.category_state[i] != SML_STATE_NULL)
  1897.         {
  1898.             nStrItemList[nNumofItem] = aStrItemList[i];
  1899.             nNumofItem++;
  1900.         }
  1901.     }
  1902.     if (g_sml_context.operation_type != SML_OP_ADD)
  1903.     {
  1904.         g_sml_context.operation_type = SML_OP_ADD;
  1905.         g_sml_context.selected_category = 0;
  1906.     }
  1907.     if (nNumofItem == 0)
  1908.     {
  1909.         ShowCategory2Screen(
  1910.             STR_ID_SML_ADD_MENU,
  1911.             MAIN_MENU_TITLE_SETTINGS_ICON,
  1912.             STR_GLOBAL_OK,
  1913.             IMG_GLOBAL_OK,
  1914.             0,
  1915.             0,
  1916.             STR_ID_EMPTY_CATEGORY_MSG,
  1917.             NULL);
  1918.         SetLeftSoftkeyFunction(EntryIdleScreen, KEY_EVENT_UP);
  1919.     }
  1920.     else
  1921.     {
  1922.         ShowCategory11Screen(
  1923.             STR_ID_SML_ADD_MENU,
  1924.             MAIN_MENU_TITLE_SETTINGS_ICON,
  1925.             STR_GLOBAL_OK,
  1926.             IMG_GLOBAL_OK,
  1927.             STR_GLOBAL_BACK,
  1928.             IMG_GLOBAL_BACK,
  1929.             nNumofItem,
  1930.             nStrItemList,
  1931.             g_sml_context.selected_category,
  1932.             guiBuffer);
  1933.         SetLeftSoftkeyFunction(mmi_sml_entry_add_data, KEY_EVENT_UP);
  1934.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1935.         SetKeyHandler(0, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1936.         SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1937.     }
  1938. }
  1939. /*****************************************************************************
  1940.  * FUNCTION
  1941.  *  mmi_sml_send_delete_req
  1942.  * DESCRIPTION
  1943.  *  Remove data
  1944.  * PARAMETERS
  1945.  *  void
  1946.  * RETURNS
  1947.  *  void
  1948.  *****************************************************************************/
  1949. void mmi_sml_send_delete_req(void)
  1950. {
  1951.     /*----------------------------------------------------------------*/
  1952.     /* Local Variables                                                */
  1953.     /*----------------------------------------------------------------*/
  1954.     /*----------------------------------------------------------------*/
  1955.     /* Code Body                                                      */
  1956.     /*----------------------------------------------------------------*/
  1957.     mmi_sml_set_personalization_req(NULL, g_sml_context.selected_category, g_sml_context.operation_type);
  1958. }
  1959. /*****************************************************************************
  1960.  * FUNCTION
  1961.  *  mmi_sml_entry_remove_confirm
  1962.  * DESCRIPTION
  1963.  *  Remove data confirmation
  1964.  * PARAMETERS
  1965.  *  void
  1966.  * RETURNS
  1967.  *  void
  1968.  *****************************************************************************/
  1969. void mmi_sml_entry_remove_confirm(void)
  1970. {
  1971.     /*----------------------------------------------------------------*/
  1972.     /* Local Variables                                                */
  1973.     /*----------------------------------------------------------------*/
  1974.     U8 *guiBuffer;
  1975.     /*----------------------------------------------------------------*/
  1976.     /* Code Body                                                      */
  1977.     /*----------------------------------------------------------------*/
  1978.     if (g_sml_context.category_state[g_sml_context.selected_category] == SML_STATE_LOCK)
  1979.     {
  1980.         DisplayPopup((PU8) GetString(STR_ID_UNLOCK_FIRST_MSG), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  1981.         return;
  1982.     }
  1983.     if (g_sml_context.used_records[g_sml_context.selected_category] == 0)
  1984.     {
  1985.         DisplayPopup((PU8) GetString(STR_ID_NO_DATA_MSG), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  1986.         return;
  1987.     }
  1988.     if (g_sml_context.category_state[g_sml_context.selected_category] == SML_STATE_AUTOLOCK)
  1989.     {
  1990.         DisplayPopup((PU8) GetString(STR_ID_SML_CAT_AUTOLOCKED), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  1991.         return;
  1992.     }
  1993.     EntryNewScreen(SCR_ID_SML_REMOVE_CONFIRM, NULL, NULL, NULL);
  1994.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_REMOVE_CONFIRM);
  1995.     ShowCategory162Screen(
  1996.         STR_GLOBAL_YES,
  1997.         IMG_GLOBAL_YES,
  1998.         STR_GLOBAL_NO,
  1999.         IMG_GLOBAL_NO,
  2000.         STR_GLOBAL_DELETE,
  2001.         IMG_GLOBAL_QUESTION,
  2002.         guiBuffer);
  2003.     SetLeftSoftkeyFunction(mmi_sml_send_delete_req, KEY_EVENT_UP);
  2004.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2005.     playRequestedTone(WARNING_TONE);
  2006. }
  2007. /*****************************************************************************
  2008.  * FUNCTION
  2009.  *  mmi_sml_entry_remove_category_data
  2010.  * DESCRIPTION
  2011.  *  Remove data catrgories entry screen
  2012.  * PARAMETERS
  2013.  *  void
  2014.  * RETURNS
  2015.  *  void
  2016.  *****************************************************************************/
  2017. void mmi_sml_entry_remove_category_data(void)
  2018. {
  2019.     /*----------------------------------------------------------------*/
  2020.     /* Local Variables                                                */
  2021.     /*----------------------------------------------------------------*/
  2022.     U8 nNumofItem = 0;  /* Need to get response from SMU */
  2023.     U8 *guiBuffer;
  2024.     U16 aStrItemList[SML_CAT_SIZE] =
  2025.         {STR_ID_CATEGORY_NP_LOCK, STR_ID_CATEGORY_NSP_LOCK, STR_ID_CATEGORY_SP_LOCK, STR_ID_CATEGORY_CP_LOCK,
  2026.         STR_ID_CATEGORY_SIMP_LOCK, STR_ID_CATEGORY_NSP_SP_LOCK, STR_ID_CATEGORY_SIMP_CP_LOCK};
  2027.     U16 nStrItemList[SML_CAT_SIZE];
  2028.     U8 i;
  2029.     /*----------------------------------------------------------------*/
  2030.     /* Code Body                                                      */
  2031.     /*----------------------------------------------------------------*/
  2032.     if (!mmi_bootup_is_sim_valid())
  2033.     {
  2034.         return;
  2035.     }
  2036.     EntryNewScreen(SCR_ID_SML_REMOVE_MENU, NULL, mmi_sml_entry_remove_category_data, NULL);
  2037.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_REMOVE_MENU);
  2038.     RegisterHighlightHandler(mmi_sml_generic_highlight_handler);
  2039.     /* Hide some unsupported personalization categories */
  2040.     for (i = 0; i < SML_CAT_SIZE; i++)
  2041.     {
  2042.         if (g_sml_context.category_state[i] != SML_STATE_DISABLE && g_sml_context.category_state[i] != SML_STATE_NULL)
  2043.         {
  2044.             nStrItemList[nNumofItem] = aStrItemList[i];
  2045.             nNumofItem++;
  2046.         }
  2047.     }
  2048.     if (g_sml_context.operation_type != SML_OP_REMOVE)
  2049.     {
  2050.         g_sml_context.operation_type = SML_OP_REMOVE;
  2051.         g_sml_context.selected_category = 0;
  2052.     }
  2053.     if (nNumofItem == 0)
  2054.     {
  2055.         ShowCategory2Screen(
  2056.             STR_ID_SML_REMOVE_MENU,
  2057.             MAIN_MENU_TITLE_SETTINGS_ICON,
  2058.             STR_GLOBAL_OK,
  2059.             IMG_GLOBAL_OK,
  2060.             0,
  2061.             0,
  2062.             STR_ID_EMPTY_CATEGORY_MSG,
  2063.             NULL);
  2064.         SetLeftSoftkeyFunction(EntryIdleScreen, KEY_EVENT_UP);
  2065.     }
  2066.     else
  2067.     {
  2068.         ShowCategory11Screen(
  2069.             STR_ID_SML_REMOVE_MENU,
  2070.             MAIN_MENU_TITLE_SETTINGS_ICON,
  2071.             STR_GLOBAL_OK,
  2072.             IMG_GLOBAL_OK,
  2073.             STR_GLOBAL_BACK,
  2074.             IMG_GLOBAL_BACK,
  2075.             nNumofItem,
  2076.             nStrItemList,
  2077.             g_sml_context.selected_category,
  2078.             guiBuffer);
  2079.         SetLeftSoftkeyFunction(mmi_sml_entry_remove_confirm, KEY_EVENT_UP);
  2080.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2081.         SetKeyHandler(0, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  2082.         SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2083.     }
  2084. }
  2085. /*****************************************************************************
  2086.  * FUNCTION
  2087.  *  mmi_sml_entry_deactivate_confirm
  2088.  * DESCRIPTION
  2089.  *  Permanent unlock confirmation
  2090.  * PARAMETERS
  2091.  *  void
  2092.  * RETURNS
  2093.  *  void
  2094.  *****************************************************************************/
  2095. void mmi_sml_entry_deactivate_confirm(void)
  2096. {
  2097.     /*----------------------------------------------------------------*/
  2098.     /* Local Variables                                                */
  2099.     /*----------------------------------------------------------------*/
  2100.     U8 *guiBuffer;
  2101.     /*----------------------------------------------------------------*/
  2102.     /* Code Body                                                      */
  2103.     /*----------------------------------------------------------------*/
  2104.     if (g_sml_context.category_state[g_sml_context.selected_category] == SML_STATE_LOCK)
  2105.     {
  2106.         DisplayPopup((PU8) GetString(STR_ID_UNLOCK_FIRST_MSG), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  2107.         return;
  2108.     }
  2109.     if (g_sml_context.category_state[g_sml_context.selected_category] == SML_STATE_AUTOLOCK)
  2110.     {
  2111.         DisplayPopup((PU8) GetString(STR_ID_SML_CAT_AUTOLOCKED), IMG_GLOBAL_ERROR, 0, ST_NOTIFYDURATION, ERROR_TONE);
  2112.         return;
  2113.     }
  2114.     EntryNewScreen(SCR_ID_SML_DEACTIVATE_CONFIRM, NULL, NULL, NULL);
  2115.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_REMOVE_CONFIRM);
  2116.     ShowCategory162Screen(
  2117.         STR_GLOBAL_YES,
  2118.         IMG_GLOBAL_YES,
  2119.         STR_GLOBAL_NO,
  2120.         IMG_GLOBAL_NO,
  2121.         STR_GLOBAL_DETACTIVATE,
  2122.         IMG_GLOBAL_QUESTION,
  2123.         guiBuffer);
  2124.     SetLeftSoftkeyFunction(mmi_sml_send_delete_req, KEY_EVENT_UP);
  2125.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2126.     playRequestedTone(WARNING_TONE);
  2127. }
  2128. /*****************************************************************************
  2129.  * FUNCTION
  2130.  *  mmi_sml_entry_permanent_unlock_selection
  2131.  * DESCRIPTION
  2132.  *  Permanent unlock catrgories entry screen
  2133.  * PARAMETERS
  2134.  *  void
  2135.  * RETURNS
  2136.  *  void
  2137.  *****************************************************************************/
  2138. void mmi_sml_entry_permanent_unlock_selection(void)
  2139. {
  2140.     /*----------------------------------------------------------------*/
  2141.     /* Local Variables                                                */
  2142.     /*----------------------------------------------------------------*/
  2143.     U8 nNumofItem = 0;  /* Need to get response from SMU */
  2144.     U8 *guiBuffer;
  2145.     U16 aStrItemList[SML_CAT_SIZE] =
  2146.         {STR_ID_CATEGORY_NP_LOCK, STR_ID_CATEGORY_NSP_LOCK, STR_ID_CATEGORY_SP_LOCK, STR_ID_CATEGORY_CP_LOCK,
  2147.         STR_ID_CATEGORY_SIMP_LOCK, STR_ID_CATEGORY_NSP_SP_LOCK, STR_ID_CATEGORY_SIMP_CP_LOCK};
  2148.     U16 nStrItemList[SML_CAT_SIZE];
  2149.     U8 i;
  2150.     /*----------------------------------------------------------------*/
  2151.     /* Code Body                                                      */
  2152.     /*----------------------------------------------------------------*/
  2153.     if (!mmi_bootup_is_sim_valid())
  2154.     {
  2155.         return;
  2156.     }
  2157.     EntryNewScreen(SCR_ID_SML_DEACTIVATE_MENU, NULL, mmi_sml_entry_permanent_unlock_selection, NULL);
  2158.     guiBuffer = GetCurrGuiBuffer(SCR_ID_SML_DEACTIVATE_MENU);
  2159.     RegisterHighlightHandler(mmi_sml_generic_highlight_handler);
  2160.     /* Hide some unsupported personalization categories */
  2161.     for (i = 0; i < SML_CAT_SIZE; i++)
  2162.     {
  2163.         if (g_sml_context.category_state[i] != SML_STATE_DISABLE && g_sml_context.category_state[i] != SML_STATE_NULL)
  2164.         {
  2165.             nStrItemList[nNumofItem] = aStrItemList[i];
  2166.             nNumofItem++;
  2167.         }
  2168.     }
  2169.     if (g_sml_context.operation_type != SML_OP_DISABLE)
  2170.     {
  2171.         g_sml_context.operation_type = SML_OP_DISABLE;
  2172.         g_sml_context.selected_category = 0;
  2173.     }
  2174.     if (nNumofItem == 0)
  2175.     {
  2176.         ShowCategory2Screen(
  2177.             STR_ID_SML_DEACTIVATE_MENU,
  2178.             MAIN_MENU_TITLE_SETTINGS_ICON,
  2179.             STR_GLOBAL_OK,
  2180.             IMG_GLOBAL_OK,
  2181.             0,
  2182.             0,
  2183.             STR_ID_EMPTY_CATEGORY_MSG,
  2184.             NULL);
  2185.         SetLeftSoftkeyFunction(EntryIdleScreen, KEY_EVENT_UP);
  2186.     }
  2187.     else
  2188.     {
  2189.         ShowCategory11Screen(
  2190.             STR_ID_SML_DEACTIVATE_MENU,
  2191.             MAIN_MENU_TITLE_SETTINGS_ICON,
  2192.             STR_GLOBAL_OK,
  2193.             IMG_GLOBAL_OK,
  2194.             STR_GLOBAL_BACK,
  2195.             IMG_GLOBAL_BACK,
  2196.             nNumofItem,
  2197.             nStrItemList,
  2198.             g_sml_context.selected_category,
  2199.             guiBuffer);
  2200.         SetLeftSoftkeyFunction(mmi_sml_entry_deactivate_confirm, KEY_EVENT_UP);
  2201.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2202.         SetKeyHandler(0, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  2203.         SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2204.     }
  2205. }
  2206. /*****************************************************************************
  2207.  * FUNCTION
  2208.  *  mmi_sml_send_lock_req_by_ssc
  2209.  * DESCRIPTION
  2210.  *  SSC for lock status query
  2211.  * PARAMETERS
  2212.  *  void
  2213.  * RETURNS
  2214.  *  void
  2215.  *****************************************************************************/
  2216. void mmi_sml_send_lock_req_by_ssc(void)
  2217. {
  2218.     /*----------------------------------------------------------------*/
  2219.     /* Local Variables                                                */
  2220.     /*----------------------------------------------------------------*/
  2221.     U8 ansii_ssc_string[MAX_DIAL_PAD];
  2222.     U8 *ptr1, *ptr2 = NULL;
  2223.     U8 i, count = 0, len;
  2224.     /*----------------------------------------------------------------*/
  2225.     /* Code Body                                                      */
  2226.     /*----------------------------------------------------------------*/
  2227.     UnicodeToAnsii((S8*) ansii_ssc_string, g_idle_context.DialPadCallBuffer);
  2228.     if (memcmp(ansii_ssc_string, SSC_SML_LOCK_CMD, strlen(SSC_SML_LOCK_CMD)) == 0)
  2229.     {
  2230.         ptr1 = ansii_ssc_string + strlen(SSC_SML_LOCK_CMD);
  2231.         len = strlen((S8*) ptr1);
  2232.         for (i = 0; i < len; i++)
  2233.         {
  2234.             if (*(ptr1 + i) == '#')
  2235.             {
  2236.                 count++;
  2237.                 *(ptr1 + i) = 0;
  2238.                 if (count == 1)
  2239.                 {
  2240.                     ptr2 = ptr1 + i + 1;
  2241.                 }
  2242.             }
  2243.         }
  2244.         if (count < 2)
  2245.         {
  2246.             /* input unfinished */
  2247.             return;
  2248.         }
  2249.         else
  2250.         {
  2251.             if (strlen((S8*) ptr1) > MAX_SIM_SETTING_PASSWD_LEN || strlen((S8*) ptr1) < MIN_PASSWORD_LENGTH)
  2252.             {
  2253.                 EntryScrInvalidPINPUKPLOCKLength(); /* invalid key length */
  2254.                 return;
  2255.             }
  2256.             /* send request */
  2257.             g_sml_context.selected_category = (U8) atoi((S8*) ptr2) - 1;
  2258.             if (g_sml_context.selected_category < SML_CAT_SIZE)
  2259.             {
  2260.                 g_sml_context.operation_type = SML_OP_LOCK;
  2261.                 if (!mmi_sml_allow_to_lock_or_unlock())
  2262.                 {
  2263.                     DeleteScreenIfPresent(IDLE_SCREEN_DIGIT_HANDLER_ID);
  2264.                     return;
  2265.                 }
  2266.                 g_sml_context.action_not_from_menu = 1;
  2267.                 mmi_sml_set_personalization_req(ptr1, g_sml_context.selected_category, SML_OP_LOCK);
  2268.             }
  2269.         }
  2270.     }
  2271.     else
  2272.     {
  2273.         /* wrong case for this function */
  2274.         return;
  2275.     }
  2276. }
  2277. /*****************************************************************************
  2278.  * FUNCTION
  2279.  *  mmi_sml_send_unlock_req_by_ssc
  2280.  * DESCRIPTION
  2281.  *  SSC for unlock status query
  2282.  * PARAMETERS
  2283.  *  void
  2284.  * RETURNS
  2285.  *  void
  2286.  *****************************************************************************/
  2287. void mmi_sml_send_unlock_req_by_ssc(void)
  2288. {
  2289.     /*----------------------------------------------------------------*/
  2290.     /* Local Variables                                                */
  2291.     /*----------------------------------------------------------------*/
  2292.     U8 ansii_ssc_string[MAX_DIAL_PAD];
  2293.     U8 *ptr1, *ptr2 = NULL;
  2294.     U8 i, count = 0, len;
  2295.     /*----------------------------------------------------------------*/
  2296.     /* Code Body                                                      */
  2297.     /*----------------------------------------------------------------*/
  2298.     UnicodeToAnsii((S8*) ansii_ssc_string, g_idle_context.DialPadCallBuffer);
  2299.     if (memcmp(ansii_ssc_string, SSC_SML_UNLOCK_CMD, strlen(SSC_SML_UNLOCK_CMD)) == 0)
  2300.     {
  2301.         ptr1 = ansii_ssc_string + strlen(SSC_SML_UNLOCK_CMD);
  2302.         len = strlen((S8*) ptr1);
  2303.         for (i = 0; i < len; i++)
  2304.         {
  2305.             if (*(ptr1 + i) == '#')
  2306.             {
  2307.                 count++;
  2308.                 *(ptr1 + i) = 0;
  2309.                 if (count == 1)
  2310.                 {
  2311.                     ptr2 = ptr1 + i + 1;
  2312.                 }
  2313.             }
  2314.         }
  2315.         if (count < 2)
  2316.         {
  2317.             /* input unfinished */
  2318.             return;
  2319.         }
  2320.         else
  2321.         {
  2322.             if (strlen((S8*) ptr1) > MAX_SIM_SETTING_PASSWD_LEN || strlen((S8*) ptr1) < MIN_PASSWORD_LENGTH)
  2323.             {
  2324.                 EntryScrInvalidPINPUKPLOCKLength(); /* invalid key length */
  2325.                 return;
  2326.             }
  2327.             /* send request */
  2328.             g_sml_context.selected_category = (U8) atoi((S8*) ptr2) - 1;
  2329.             if (g_sml_context.selected_category < SML_CAT_SIZE)
  2330.             {
  2331.                 g_sml_context.operation_type = SML_OP_UNLOCK;
  2332.                 if (!mmi_sml_allow_to_lock_or_unlock())
  2333.                 {
  2334.                     DeleteScreenIfPresent(IDLE_SCREEN_DIGIT_HANDLER_ID);
  2335.                     return;
  2336.                 }
  2337.                 g_sml_context.action_not_from_menu = 1;
  2338.                 mmi_sml_set_personalization_req(ptr1, g_sml_context.selected_category, SML_OP_UNLOCK);
  2339.             }
  2340.         }
  2341.     }
  2342.     else
  2343.     {
  2344.         /* wrong case for this function */
  2345.         return;
  2346.     }
  2347. }
  2348. /*****************************************************************************
  2349.  * FUNCTION
  2350.  *  mmi_sml_send_query_rsp_by_ssc
  2351.  * DESCRIPTION
  2352.  *  
  2353.  * PARAMETERS
  2354.  *  info        [OUT]
  2355.  * RETURNS
  2356.  *  void
  2357.  *****************************************************************************/
  2358. void mmi_sml_send_query_rsp_by_ssc(void *info)
  2359. {
  2360.     /*----------------------------------------------------------------*/
  2361.     /* Local Variables                                                */
  2362.     /*----------------------------------------------------------------*/
  2363.     mmi_smu_sml_status_rsp_struct *resp;
  2364.     /*----------------------------------------------------------------*/
  2365.     /* Code Body                                                      */
  2366.     /*----------------------------------------------------------------*/
  2367.     resp = (mmi_smu_sml_status_rsp_struct*) (info);
  2368.     ClearProtocolEventHandler(PRT_MMI_SMU_SML_STATUS_RSP);
  2369.     /* display this category is locked or unlocked */
  2370.     if (resp->state[g_sml_context.selected_category] == SML_STATE_AUTOLOCK)
  2371.     {
  2372.         DisplayPopup((PU8) GetString(STR_ID_SML_CAT_AUTOLOCKED), IMG_GLOBAL_ACTIVATED, 1, POPUP_TIME, 0);
  2373.     }
  2374.     else if (resp->state[g_sml_context.selected_category] == SML_STATE_LOCK)
  2375.     {
  2376.         DisplayPopup((PU8) GetString(STR_ID_SML_CAT_LOCKED), IMG_GLOBAL_ACTIVATED, 1, POPUP_TIME, 0);
  2377.     }
  2378.     else
  2379.     {
  2380.         DisplayPopup((PU8) GetString(STR_ID_SML_CAT_UNLOCKED), IMG_GLOBAL_ACTIVATED, 1, POPUP_TIME, 0);
  2381.     }
  2382.     DeleteScreenIfPresent(IDLE_SCREEN_DIGIT_HANDLER_ID);
  2383. }
  2384. /*****************************************************************************
  2385.  * FUNCTION
  2386.  *  mmi_sml_send_query_req_by_ssc
  2387.  * DESCRIPTION
  2388.  *  SSC for lock or unlock status query
  2389.  * PARAMETERS
  2390.  *  void
  2391.  * RETURNS
  2392.  *  void
  2393.  *****************************************************************************/
  2394. void mmi_sml_send_query_req_by_ssc(void)
  2395. {
  2396.     /*----------------------------------------------------------------*/
  2397.     /* Local Variables                                                */
  2398.     /*----------------------------------------------------------------*/
  2399.     U8 ansii_ssc_string[MAX_DIAL_PAD];
  2400.     U8 *ptr1;
  2401.     U8 i, count = 0, len;
  2402.     MYQUEUE Message;
  2403.     /*----------------------------------------------------------------*/
  2404.     /* Code Body                                                      */
  2405.     /*----------------------------------------------------------------*/
  2406.     UnicodeToAnsii((S8*) ansii_ssc_string, g_idle_context.DialPadCallBuffer);
  2407.     if (memcmp(ansii_ssc_string, SSC_SML_QUERY_CMD, strlen(SSC_SML_QUERY_CMD)) == 0)
  2408.     {
  2409.         ptr1 = ansii_ssc_string + strlen(SSC_SML_QUERY_CMD);
  2410.         len = strlen((S8*) ptr1);
  2411.         for (i = 0; i < len; i++)
  2412.         {
  2413.             if (*(ptr1 + i) == '#')
  2414.             {
  2415.                 count++;
  2416.                 *(ptr1 + i) = 0;
  2417.             }
  2418.         }
  2419.         if (count < 1)
  2420.         {
  2421.             /* input unfinished */
  2422.             return;
  2423.         }
  2424.         else
  2425.         {
  2426.             g_sml_context.selected_category = (U8) atoi((S8*) ptr1) - 1;
  2427.             if (g_sml_context.selected_category < SML_CAT_SIZE)
  2428.             {
  2429.                 /* send request */
  2430.                 ClearAllKeyHandler();   /* ClearInputEventHandler(MMI_DEVICE_ALL); */
  2431.                 SetProtocolEventHandler(mmi_sml_send_query_rsp_by_ssc, PRT_MMI_SMU_SML_STATUS_RSP);
  2432.                 PRINT_INFORMATION(("@@@@@ Sending request for query personalization status @@@@@"));
  2433.                 Message.oslSrcId = MOD_MMI;
  2434.                 Message.oslDestId = MOD_L4C;
  2435.                 Message.oslMsgId = PRT_MMI_SMU_SML_STATUS_REQ;
  2436.                 Message.oslDataPtr = NULL;  /* no parameters */
  2437.                 Message.oslPeerBuffPtr = NULL;
  2438.                 OslMsgSendExtQueue(&Message);
  2439.             }
  2440.             else
  2441.             {
  2442.                 /* wrong category */
  2443.                 return;
  2444.             }
  2445.         }
  2446.     }
  2447.     else
  2448.     {
  2449.         /* wrong case for this function */
  2450.         return;
  2451.     }
  2452. }
  2453. /*****************************************************************************
  2454.  * FUNCTION
  2455.  *  mmi_sml_power_on_query_rsp
  2456.  * DESCRIPTION
  2457.  *  
  2458.  * PARAMETERS
  2459.  *  info        [OUT]
  2460.  * RETURNS
  2461.  *  void
  2462.  *****************************************************************************/
  2463. void mmi_sml_power_on_query_rsp(void *info)
  2464. {
  2465.     /*----------------------------------------------------------------*/
  2466.     /* Local Variables                                                */
  2467.     /*----------------------------------------------------------------*/
  2468.     mmi_smu_sml_status_rsp_struct *resp;
  2469.     /*----------------------------------------------------------------*/
  2470.     /* Code Body                                                      */
  2471.     /*----------------------------------------------------------------*/
  2472.     resp = (mmi_smu_sml_status_rsp_struct*) (info);
  2473.     ClearProtocolEventHandler(PRT_MMI_SMU_SML_STATUS_RSP);
  2474.     memcpy(g_sml_context.category_state, resp->state, SML_CAT_SIZE);
  2475.     memcpy(g_sml_context.key_state, resp->key_state, SML_CAT_SIZE);
  2476.     memcpy(g_sml_context.total_records, resp->total_size_of_cat, SML_CAT_SIZE);
  2477.     memcpy(g_sml_context.used_records, resp->num_of_sets, SML_CAT_SIZE);
  2478.     memcpy(g_sml_context.retry_count, resp->retry_count, SML_CAT_SIZE);
  2479.     memset(g_sml_context.imsi, 0, MAX_IMSI_LEN + 1);
  2480.     strncpy((S8*) g_sml_context.imsi, (S8*) (resp->imsi) + 1, MAX_IMSI_LEN);
  2481.     g_sml_context.gid_valid_nibble = 0;
  2482.     if (resp->is_valid_gid1)
  2483.     {
  2484.         g_sml_context.gid_valid_nibble |= 0x01;
  2485.         g_sml_context.gid1 = resp->ef_gid1;
  2486.     }
  2487.     if (resp->is_valid_gid2)
  2488.     {
  2489.         g_sml_context.gid_valid_nibble |= 0x10;
  2490.         g_sml_context.gid2 = resp->ef_gid2;
  2491.     }
  2492.     if (resp->digits_of_mnc == 0)
  2493.     {
  2494.         g_sml_context.digits_of_mcc_mnc = 5;    /* default */
  2495.     }
  2496.     else
  2497.     {
  2498.         g_sml_context.digits_of_mcc_mnc = resp->digits_of_mnc + 3;
  2499.     }
  2500. }
  2501. /*****************************************************************************
  2502.  * FUNCTION
  2503.  *  mmi_sml_power_on_query_req
  2504.  * DESCRIPTION
  2505.  *  Power on period query
  2506.  * PARAMETERS
  2507.  *  void
  2508.  * RETURNS
  2509.  *  void
  2510.  *****************************************************************************/
  2511. void mmi_sml_power_on_query_req(void)
  2512. {
  2513.     /*----------------------------------------------------------------*/
  2514.     /* Local Variables                                                */
  2515.     /*----------------------------------------------------------------*/
  2516.     MYQUEUE Message;
  2517.     /*----------------------------------------------------------------*/
  2518.     /* Code Body                                                      */
  2519.     /*----------------------------------------------------------------*/
  2520.     ClearAllKeyHandler();   /* ClearInputEventHandler(MMI_DEVICE_ALL); */
  2521.     SetProtocolEventHandler(mmi_sml_power_on_query_rsp, PRT_MMI_SMU_SML_STATUS_RSP);
  2522.     PRINT_INFORMATION(("@@@@@ Sending request for query personalization status @@@@@"));
  2523.     Message.oslSrcId = MOD_MMI;
  2524.     Message.oslDestId = MOD_L4C;
  2525.     Message.oslMsgId = PRT_MMI_SMU_SML_STATUS_REQ;
  2526.     Message.oslDataPtr = NULL;  /* no parameters */
  2527.     Message.oslPeerBuffPtr = NULL;
  2528.     OslMsgSendExtQueue(&Message);
  2529. }
  2530. /*****************************************************************************
  2531.  * FUNCTION
  2532.  *  mmi_sml_auto_locked_fail
  2533.  * DESCRIPTION
  2534.  *  Auto lock failure
  2535.  * PARAMETERS
  2536.  *  void
  2537.  * RETURNS
  2538.  *  void
  2539.  *****************************************************************************/
  2540. static void mmi_sml_auto_locked_fail(void)
  2541. {
  2542.     /*----------------------------------------------------------------*/
  2543.     /* Local Variables                                                */
  2544.     /*----------------------------------------------------------------*/
  2545.     /*----------------------------------------------------------------*/
  2546.     /* Code Body                                                      */
  2547.     /*----------------------------------------------------------------*/
  2548.     DisplayPopup((PU8) GetString(STR_ID_SML_FAIL_TO_AUTOLOCK), IMG_GLOBAL_WARNING, 1, 2000, 0);
  2549. }
  2550. /*****************************************************************************
  2551.  * FUNCTION
  2552.  *  mmi_sml_auto_locked_done
  2553.  * DESCRIPTION
  2554.  *  Auto lock done
  2555.  * PARAMETERS
  2556.  *  void
  2557.  * RETURNS
  2558.  *  void
  2559.  *****************************************************************************/
  2560. static void mmi_sml_auto_locked_done(void)
  2561. {
  2562.     /*----------------------------------------------------------------*/
  2563.     /* Local Variables                                                */
  2564.     /*----------------------------------------------------------------*/
  2565.     /*----------------------------------------------------------------*/
  2566.     /* Code Body                                                      */
  2567.     /*----------------------------------------------------------------*/
  2568.     DisplayPopup((PU8) GetString(STR_ID_SML_AUTOLOCKED), IMG_GLOBAL_ACTIVATED, 1, 2000, 0);
  2569. }
  2570. /*****************************************************************************
  2571.  * FUNCTION
  2572.  *  mmi_sml_display_auto_locked_notification
  2573.  * DESCRIPTION
  2574.  *  Display a popup for auto locked SIM
  2575.  * PARAMETERS
  2576.  *  void
  2577.  * RETURNS
  2578.  *  void
  2579.  *****************************************************************************/
  2580. void mmi_sml_display_auto_locked_notification(void)
  2581. {
  2582.     /*----------------------------------------------------------------*/
  2583.     /* Local Variables                                                */
  2584.     /*----------------------------------------------------------------*/
  2585.     /*----------------------------------------------------------------*/
  2586.     /* Code Body                                                      */
  2587.     /*----------------------------------------------------------------*/
  2588.     if (g_sml_context.autolock_nibble != 0)
  2589.     {
  2590.         if (g_sml_context.autolock_nibble & 0x10)
  2591.         {
  2592.             StartTimer(SML_AUTOLOCK_IDLE_NOTIFY_TIMER, 3000, mmi_sml_auto_locked_done);
  2593.         }
  2594.         else
  2595.         {
  2596.             StartTimer(SML_AUTOLOCK_IDLE_NOTIFY_TIMER, 3000, mmi_sml_auto_locked_fail);
  2597.         }
  2598.     }
  2599. }
  2600. #endif /* __MMI_SML_MENU__ */