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

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.  * DataAccountUtils.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   Utility functions for Data Account.
  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.  *
  86.  * removed!
  87.  * removed!
  88.  * removed!
  89.  *
  90.  * removed!
  91.  * removed!
  92.  * removed!
  93.  *
  94.  * removed!
  95.  * removed!
  96.  * removed!
  97.  *
  98.  * removed!
  99.  * removed!
  100.  * removed!
  101.  *
  102.  * removed!
  103.  * removed!
  104.  * removed!
  105.  *
  106.  * removed!
  107.  * removed!
  108.  * removed!
  109.  *
  110.  * removed!
  111.  * removed!
  112.  * removed!
  113.  *
  114.  * removed!
  115.  * removed!
  116.  * removed!
  117.  *
  118.  * removed!
  119.  * removed!
  120.  * removed!
  121.  *
  122.  * removed!
  123.  * removed!
  124.  * removed!
  125.  *
  126.  * removed!
  127.  * removed!
  128.  * removed!
  129.  *
  130.  * removed!
  131.  * removed!
  132.  * removed!
  133.  *
  134.  * removed!
  135.  * removed!
  136.  * removed!
  137.  *
  138.  * removed!
  139.  * removed!
  140.  * removed!
  141.  *
  142.  * removed!
  143.  * removed!
  144.  * removed!
  145.  *
  146.  * removed!
  147.  * removed!
  148.  * removed!
  149.  *
  150.  * removed!
  151.  * removed!
  152.  * removed!
  153.  *
  154.  * removed!
  155.  * removed!
  156.  * removed!
  157.  *
  158.  * removed!
  159.  * removed!
  160.  * removed!
  161.  *
  162.  * removed!
  163.  * removed!
  164.  * removed!
  165.  *
  166.  * removed!
  167.  * removed!
  168.  * removed!
  169.  *
  170.  * removed!
  171.  * removed!
  172.  * removed!
  173.  *
  174.  * removed!
  175.  * removed!
  176.  * removed!
  177.  *
  178.  * removed!
  179.  * removed!
  180.  * removed!
  181.  *
  182.  * removed!
  183.  * removed!
  184.  * removed!
  185.  *
  186.  * removed!
  187.  * removed!
  188.  * removed!
  189.  *
  190.  * removed!
  191.  * removed!
  192.  * removed!
  193.  *
  194.  *------------------------------------------------------------------------------
  195.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  196.  *============================================================================
  197.  ****************************************************************************/
  198. #include "DataAccountCommon.h"
  199. #include "CallManagementGProt.h"
  200. #include "gpioInc.h"
  201. #ifdef __MMI_WLAN_FEATURES__
  202. /***************************************************************************** 
  203. * Define
  204. *****************************************************************************/
  205. /***************************************************************************** 
  206. * Typedef 
  207. *****************************************************************************/
  208. /***************************************************************************** 
  209. * Local Variable
  210. *****************************************************************************/
  211. /***************************************************************************** 
  212. * Local Function
  213. *****************************************************************************/
  214. static void mmi_wlan_send_event_notify(dtcnt_bearer_state_enum state);
  215. /***************************************************************************** 
  216. * Global Variable
  217. *****************************************************************************/
  218. /***************************************************************************** 
  219. * Global Function
  220. *****************************************************************************/
  221. /*****************************************************************************
  222.  * FUNCTION
  223.  *  free_all_actions
  224.  * DESCRIPTION
  225.  *  
  226.  * PARAMETERS
  227.  *  handle                  [IN]        
  228.  *  action_to_remove        [?]         
  229.  * RETURNS
  230.  *  void
  231.  *****************************************************************************/
  232. static void delete_all_actions(wlan_action_struct **handle)
  233. {
  234.     /*----------------------------------------------------------------*/
  235.     /* Local Variables                                                */
  236.     /*----------------------------------------------------------------*/
  237.     wlan_action_struct *action_to_remove;
  238.     wlan_action_struct *iterator;
  239.     /*----------------------------------------------------------------*/
  240.     /* Code Body                                                      */
  241.     /*----------------------------------------------------------------*/
  242.     iterator = *handle;
  243.     while (iterator != NULL)
  244.     {
  245.         action_to_remove = iterator;
  246.         iterator = iterator->next;
  247.         ASSERT(action_to_remove != NULL);
  248.         OslMfree(action_to_remove);
  249.     }
  250.     
  251.     *handle = NULL;
  252.     
  253.     return;
  254. }
  255. /*****************************************************************************
  256.  * FUNCTION
  257.  *  free_action
  258.  * DESCRIPTION
  259.  *  
  260.  * PARAMETERS
  261.  *  handle                  [IN]        
  262.  *  action_to_remove        [?]         
  263.  * RETURNS
  264.  *  void
  265.  *****************************************************************************/
  266. static void free_action(wlan_action_struct **handle, wlan_action_struct *action_to_remove)
  267. {
  268.     /*----------------------------------------------------------------*/
  269.     /* Local Variables                                                */
  270.     /*----------------------------------------------------------------*/
  271.     wlan_action_struct *temp_action = *handle;
  272.     wlan_action_struct *prev_action = NULL;
  273.     /*----------------------------------------------------------------*/
  274.     /* Code Body                                                      */
  275.     /*----------------------------------------------------------------*/
  276.     if (action_to_remove == NULL)
  277.     {
  278.         return;
  279.     }
  280.     while (temp_action != action_to_remove)
  281.     {
  282.         prev_action = temp_action;
  283.         temp_action = temp_action->next;
  284.         ASSERT(temp_action != NULL);
  285.     }
  286.     if(prev_action)
  287.     {
  288.         prev_action->next = temp_action->next;
  289.     }
  290.     else
  291.     {
  292.         ASSERT(action_to_remove == *handle);
  293.         
  294.         *handle = action_to_remove->next;
  295.     }
  296.     
  297.     OslMfree(action_to_remove);
  298.     action_to_remove = NULL;
  299.     
  300.     return;
  301. }
  302. /*****************************************************************************
  303.  * FUNCTION
  304.  *  find_action
  305.  * DESCRIPTION
  306.  *  
  307.  * PARAMETERS
  308.  *  handle      [?]         
  309.  *  action      [IN]        
  310.  * RETURNS
  311.  *  
  312.  *****************************************************************************/
  313. static wlan_action_struct *find_action(wlan_action_struct *handle, wlan_action_enum action)
  314. {
  315.     /*----------------------------------------------------------------*/
  316.     /* Local Variables                                                */
  317.     /*----------------------------------------------------------------*/
  318.     wlan_action_struct *temp_action = handle;
  319.     /*----------------------------------------------------------------*/
  320.     /* Code Body                                                      */
  321.     /*----------------------------------------------------------------*/
  322.     if (temp_action == NULL)
  323.     {
  324.         return NULL;
  325.     }
  326.     do
  327.     {
  328.         if (temp_action->action == action)
  329.         {
  330.             return temp_action;
  331.         }
  332.         temp_action = temp_action->next;
  333.     }
  334.     while (temp_action != NULL);
  335.     return NULL;    /* Not found */
  336. }
  337. /*****************************************************************************
  338.  * FUNCTION
  339.  *  delete_action
  340.  * DESCRIPTION
  341.  *  
  342.  * PARAMETERS
  343.  *  handle      [IN]        
  344.  *  action      [IN]        
  345.  * RETURNS
  346.  *  void
  347.  *****************************************************************************/
  348. void delete_action(wlan_action_struct **handle, wlan_action_enum action)
  349. {
  350.     /*----------------------------------------------------------------*/
  351.     /* Local Variables                                                */
  352.     /*----------------------------------------------------------------*/
  353.     wlan_action_struct *temp_action = find_action(*handle, action);
  354.     /*----------------------------------------------------------------*/
  355.     /* Code Body                                                      */
  356.     /*----------------------------------------------------------------*/
  357.     free_action(handle, temp_action);
  358.     return;
  359. }
  360. /*****************************************************************************
  361.  * FUNCTION
  362.  *  do_action
  363.  * DESCRIPTION
  364.  *  
  365.  * PARAMETERS
  366.  *  void
  367.  * RETURNS
  368.  *  
  369.  *****************************************************************************/
  370. static BOOL do_action(void)
  371. {
  372.     /*----------------------------------------------------------------*/
  373.     /* Local Variables                                                */
  374.     /*----------------------------------------------------------------*/
  375.     wlan_action_struct *todo = g_wlan_display_context.actions;
  376.     /*----------------------------------------------------------------*/
  377.     /* Code Body                                                      */
  378.     /*----------------------------------------------------------------*/
  379.     if (todo == NULL)
  380.     {
  381.         return FALSE;   /* Nothing to do */
  382.     }
  383.     switch (todo->action)
  384.     {
  385.         case WLAN_ACTION_INIT:
  386.             mmi_wlan_abm_wifi_init_req_hdlr();
  387.             break;
  388.         case WLAN_ACTION_DEINIT:
  389.             mmi_wlan_abm_wifi_deinit_req_hdlr();
  390.             break;
  391.         case WLAN_ACTION_CONNECT:
  392.             mmi_wlan_abm_wifi_connect_req_hdlr(todo->data);
  393.             break;
  394.         case WLAN_ACTION_DISCONNECT:
  395.             mmi_wlan_abm_wifi_disconnect_req_hdlr();
  396.             break;
  397.         case WLAN_ACTION_SCAN:
  398.             mmi_wlan_abm_wifi_ap_list_req_hdlr();
  399.             break;
  400.         default:
  401.             ASSERT(0);
  402.     }
  403.     free_action(&g_wlan_display_context.actions, todo);
  404.     return TRUE;
  405. }
  406. /*****************************************************************************
  407.  * FUNCTION
  408.  *  add_action
  409.  * DESCRIPTION
  410.  *  
  411.  * PARAMETERS
  412.  *  handle      [IN]        
  413.  *  action      [IN]        
  414.  *  data        [?]         
  415.  * RETURNS
  416.  *  void
  417.  *****************************************************************************/
  418. void add_action(wlan_action_struct **handle, wlan_action_enum action, void *data)
  419. {
  420.     /*----------------------------------------------------------------*/
  421.     /* Local Variables                                                */
  422.     /*----------------------------------------------------------------*/
  423.     wlan_action_struct *prev_action;
  424.     wlan_action_struct *temp_action;
  425.     /*----------------------------------------------------------------*/
  426.     /* Code Body                                                      */
  427.     /*----------------------------------------------------------------*/
  428.     switch (action)
  429.     {
  430.         case WLAN_ACTION_INIT:
  431.             if (find_action(*handle, WLAN_ACTION_DEINIT) != NULL)
  432.             {
  433.                 delete_action(handle, WLAN_ACTION_DEINIT);
  434.                 return;
  435.             }
  436.             break;
  437.         case WLAN_ACTION_CONNECT:
  438.             break;
  439.         case WLAN_ACTION_DISCONNECT:
  440.             if (find_action(*handle, WLAN_ACTION_CONNECT) != NULL)
  441.             {
  442.                 delete_action(handle, WLAN_ACTION_CONNECT);
  443.                 return;
  444.             }
  445.             else
  446.             {
  447.                 delete_all_actions(handle);
  448.                 mmi_wlan_abm_wifi_disconnect_req_hdlr();
  449.                 return;
  450.             }
  451.             break;
  452.         case WLAN_ACTION_DEINIT:
  453.             if (find_action(*handle, WLAN_ACTION_INIT) != NULL)
  454.             {
  455.                 delete_action(handle, WLAN_ACTION_INIT);
  456.                 return;
  457.             }
  458.             break;
  459.         case WLAN_ACTION_SCAN:
  460.             break;
  461.     }
  462.     /* Avoid duplicate actions */
  463.     delete_action(handle, action);
  464.     temp_action = OslMalloc(sizeof(wlan_action_struct));
  465.     temp_action->action = action;
  466.     temp_action->data = data;
  467.     temp_action->next = NULL;
  468.     
  469.     if (*handle == NULL)
  470.     {
  471.         *handle = temp_action;
  472.     }
  473.     else
  474.     {
  475.         prev_action = *handle;
  476.         while (prev_action->next != NULL)
  477.         {
  478.             prev_action = prev_action->next;
  479.         }
  480.         prev_action->next = temp_action;
  481.     }
  482.     /* Execute next action if we are not in waiting state. */
  483.     switch (g_wlan_display_context.state)
  484.     {
  485.         case WLAN_STATE_NULL:
  486.         case WLAN_STATE_INIT:
  487.         case WLAN_STATE_CONNECTED:
  488.             if(g_wlan_display_context.scan_state == WLAN_SCAN_STATE_NULL)
  489.             {
  490.                 do_action();
  491.             }
  492.             break;
  493.     }
  494.     return;
  495. }
  496. /*****************************************************************************
  497.  * FUNCTION
  498.  *  bssinfo_to_profile
  499.  * DESCRIPTION
  500.  *  
  501.  * PARAMETERS
  502.  *  prof            [?]         
  503.  *  bssinfo         [?]         
  504.  *  passphrase      [IN]        
  505.  * RETURNS
  506.  *  void
  507.  *****************************************************************************/
  508. void bssinfo_to_profile(mmi_wlan_profile_struct *prof, supc_abm_bss_info_struct *bssinfo, const char *passphrase, int keylen)
  509. {
  510.     /*----------------------------------------------------------------*/
  511.     /* Local Variables                                                */
  512.     /*----------------------------------------------------------------*/
  513.     /*----------------------------------------------------------------*/
  514.     /* Code Body                                                      */
  515.     /*----------------------------------------------------------------*/
  516.     mmi_wlan_init_profile(prof);
  517.     prof->ssid_len = bssinfo->ssid_len;
  518.     strncpy((char*)prof->ssid, (const char*)bssinfo->ssid, bssinfo->ssid_len);
  519.     AnsiiNToUnicodeString((PS8) prof->name, (PS8) bssinfo->ssid, bssinfo->ssid_len);
  520.     prof->use_dhcp = TRUE;
  521.     switch (bssinfo->network_type)
  522.     {
  523.         case WNDRV_SUPC_NETWORK_AUTO_UNKNOWN:
  524.             /*prof->network_type = WLAN_NETWORK_TYPE_AUTO;*/
  525.             prof->network_type = WLAN_NETWORK_TYPE_INFRA;
  526.             break;
  527.         case WNDRV_SUPC_NETWORK_IBSS:
  528.             prof->network_type = WLAN_NETWORK_TYPE_ADHOC;
  529.             prof->channel = bssinfo->channel_number;
  530.             break;
  531.         case WNDRV_SUPC_NETWORK_INFRASTRUCTURE:
  532.             prof->network_type = WLAN_NETWORK_TYPE_INFRA;
  533.             break;
  534.     }
  535.     if (bssinfo->rsn_ie_info_p == TRUE)
  536.     {
  537.         if (bssinfo->rsn_ie_info.group_cipher & WPA_CIPHER_TKIP ||
  538.             bssinfo->rsn_ie_info.pairwise_cipher & WPA_CIPHER_TKIP)
  539.         {
  540.             prof->encrypt_mode = WLAN_ENCRYPT_MODE_TKIP;
  541.         }
  542.         if (bssinfo->rsn_ie_info.group_cipher & WPA_CIPHER_CCMP ||
  543.             bssinfo->rsn_ie_info.pairwise_cipher & WPA_CIPHER_CCMP)
  544.         {
  545.             prof->encrypt_mode = WLAN_ENCRYPT_MODE_AES;
  546.         }
  547.         if (bssinfo->rsn_ie_info.key_mgmt & WPA_KEY_MGMT_PSK)
  548.         {
  549.             prof->auth_mode = WLAN_AUTH_MODE_WPAPSK;
  550.         }
  551.         else
  552.         {
  553.             prof->auth_mode = WLAN_AUTH_MODE_WPA;
  554.         }
  555.         if (passphrase != NULL)
  556.         {
  557.             if(keylen == 64)
  558.             {
  559.                 hex_to_string(prof->psk, (U8 *)passphrase, 64);
  560.             }
  561.             else
  562.             {
  563.                 strcpy((char*)prof->passphrase, passphrase);
  564.             }
  565.         }
  566.     }
  567.     else if (bssinfo->wpa_ie_info_p == TRUE)
  568.     {
  569.         if (bssinfo->wpa_ie_info.group_cipher & WPA_CIPHER_TKIP ||
  570.             bssinfo->wpa_ie_info.pairwise_cipher & WPA_CIPHER_TKIP)
  571.         {
  572.             prof->encrypt_mode = WLAN_ENCRYPT_MODE_TKIP;
  573.         }
  574.         if (bssinfo->wpa_ie_info.group_cipher & WPA_CIPHER_CCMP ||
  575.             bssinfo->wpa_ie_info.pairwise_cipher & WPA_CIPHER_CCMP)
  576.         {
  577.             prof->encrypt_mode = WLAN_ENCRYPT_MODE_AES;
  578.         }
  579.         if (bssinfo->wpa_ie_info.key_mgmt & WPA_KEY_MGMT_PSK)
  580.         {
  581.             prof->auth_mode = WLAN_AUTH_MODE_WPAPSK;
  582.         }
  583.         else
  584.         {
  585.             prof->auth_mode = WLAN_AUTH_MODE_WPA;
  586.         }
  587.         if (passphrase != NULL)
  588.         {
  589.             if(keylen == 64)
  590.             {
  591.                 hex_to_string(prof->psk, (U8 *)passphrase, 64);
  592.             }
  593.             else
  594.             {
  595.                 strcpy((char*)prof->passphrase, passphrase);
  596.             }
  597.         }
  598.     }
  599.     else if (bssinfo->privacy > 0)
  600.     {
  601.         prof->auth_mode = WLAN_AUTH_MODE_SHARED;
  602.         prof->encrypt_mode = WLAN_ENCRYPT_MODE_WEP;
  603.         if (passphrase == NULL)
  604.         {
  605.             return;
  606.         }
  607.         switch (keylen)
  608.         {
  609.             case 5:
  610.                 prof->wep_key_len = WLAN_WEP_KEY_ENCRYPT_64;
  611.                 prof->wep_key_format = WLAN_WEP_KEY_FORMAT_ASCII;
  612.                 memcpy(prof->wep_key, passphrase, 5);
  613.                 break;
  614.             case 13:
  615.                 prof->wep_key_len = WLAN_WEP_KEY_ENCRYPT_128;
  616.                 prof->wep_key_format = WLAN_WEP_KEY_FORMAT_ASCII;
  617.                 memcpy(prof->wep_key, passphrase, 13);
  618.                 break;
  619.             default:
  620.                 ASSERT(0);
  621.                 break;
  622.         }
  623.     }
  624.     else
  625.     {
  626.         prof->auth_mode = WLAN_AUTH_MODE_OPEN;
  627.         prof->encrypt_mode = WLAN_ENCRYPT_MODE_NONE;
  628.     }
  629. }
  630. /*****************************************************************************
  631.  * FUNCTION
  632.  *  encode_profile
  633.  * DESCRIPTION
  634.  *  
  635.  * PARAMETERS
  636.  *  prof        [?]     
  637.  *  profile     [?]     
  638.  * RETURNS
  639.  *  
  640.  *****************************************************************************/
  641. static kal_bool encode_profile(wifi_data_account_profile_struct *prof, mmi_wlan_profile_struct *profile)
  642. {
  643.     /*----------------------------------------------------------------*/
  644.     /* Local Variables                                                */
  645.     /*----------------------------------------------------------------*/
  646.     /*----------------------------------------------------------------*/
  647.     /* Code Body                                                      */
  648.     /*----------------------------------------------------------------*/
  649.     memset(prof, 0, sizeof(wifi_data_account_profile_struct));
  650.     prof->ssid_len = profile->ssid_len;
  651.     memcpy(prof->ssid, profile->ssid, profile->ssid_len);
  652.     switch (profile->network_type)
  653.     {
  654.         /*case WLAN_NETWORK_TYPE_AUTO:
  655.             prof->network_type = WNDRV_SUPC_NETWORK_AUTO_UNKNOWN;
  656.             break;*/
  657.         case WLAN_NETWORK_TYPE_ADHOC:
  658.             prof->network_type = WNDRV_SUPC_NETWORK_IBSS;
  659.             prof->channel_number = profile->channel;
  660.             break;
  661.         case WLAN_NETWORK_TYPE_INFRA:
  662.             prof->network_type = WNDRV_SUPC_NETWORK_INFRASTRUCTURE;
  663.             break;
  664.         default:
  665.           ASSERT(0);
  666.     }
  667.     prof->priority = profile->priority;
  668.     prof->profile_id = profile->profile_id;
  669.     switch (profile->auth_mode)
  670.     {
  671.         case WLAN_AUTH_MODE_OPEN:
  672.             prof->key_mgmt = WPA_KEY_MGMT_NONE;
  673.             break;
  674.         case WLAN_AUTH_MODE_SHARED:
  675.             prof->proto = WPA_PROTO_RSN;
  676.             prof->key_mgmt = WPA_KEY_MGMT_NONE;
  677.             prof->auth_alg = WPA_AUTH_ALG_SHARED;
  678.             break;
  679.         case WLAN_AUTH_MODE_IEEE8021X:
  680.             prof->key_mgmt = WPA_KEY_MGMT_IEEE8021X_NO_WPA;
  681.             prof->auth_alg = WPA_AUTH_ALG_OPEN;
  682.             if (encode_eap_profile(prof, profile) == KAL_FALSE)
  683.             {
  684.                 return KAL_FALSE;
  685.             }
  686.             break;
  687.         case WLAN_AUTH_MODE_WPAPSK:
  688.             prof->proto = WPA_PROTO_WPA | WPA_PROTO_RSN;
  689.             prof->psk_p = KAL_TRUE;
  690.             /* prof->auth_alg = WPA_AUTH_ALG_OPEN; */
  691.             prof->key_mgmt = WPA_KEY_MGMT_PSK;
  692.             /* For OTA provisioning. Directly specify the 256-bits PSK, without
  693.                any passphrase. */
  694.             if (strlen((const char*)profile->passphrase) == 0)
  695.             {
  696.                 memcpy(prof->psk, profile->psk, 32);
  697.             }
  698.             else
  699.             {
  700.                 if (profile->psk[0] == 0)
  701.                 {
  702.                     /* Regenerate psk if it is not pre-generated. */
  703.                 #ifdef __MTK_TARGET__
  704.                     pbkdf2_sha1(
  705.                         (const char*)profile->passphrase,
  706.                         (const char*)prof->ssid,
  707.                         prof->ssid_len,
  708.                         4096,
  709.                         prof->psk,
  710.                         32);
  711.                 #else /* __MTK_TARGET__ */ 
  712.                     strcpy((char*)prof->psk, (const char*)profile->passphrase);
  713.                 #endif /* __MTK_TARGET__ */ 
  714.                 }
  715.                 else
  716.                 {
  717.                     memcpy(prof->psk, profile->psk, 32);
  718.                 }
  719.             }
  720.             break;
  721.         case WLAN_AUTH_MODE_WPA:
  722.             prof->proto = WPA_PROTO_WPA | WPA_PROTO_RSN;
  723.             prof->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
  724.             prof->auth_alg = WPA_AUTH_ALG_OPEN;
  725.             if (encode_eap_profile(prof, profile) == KAL_FALSE)
  726.             {
  727.                 return KAL_FALSE;
  728.             }
  729.             break;
  730.     }
  731.     switch (profile->encrypt_mode)
  732.     {
  733.         case WLAN_ENCRYPT_MODE_NONE:
  734.             prof->pairwise = WPA_CIPHER_NONE;
  735.             prof->group = WPA_CIPHER_NONE;
  736.             break;
  737.         case WLAN_ENCRYPT_MODE_WEP:
  738.             switch (profile->wep_key_len)
  739.             {
  740.                 case WLAN_WEP_KEY_ENCRYPT_64:
  741.                     prof->group = WPA_CIPHER_WEP40;
  742.                     prof->pairwise = WPA_CIPHER_WEP40;
  743.                     break;
  744.                 case WLAN_WEP_KEY_ENCRYPT_128:
  745.                     prof->group = WPA_CIPHER_WEP104;
  746.                     prof->pairwise = WPA_CIPHER_WEP104;
  747.                     break;
  748.                 default:    /* Invalid key len */
  749.                     prof->pairwise = WPA_CIPHER_NONE;
  750.                     prof->group = WPA_CIPHER_NONE;
  751.                     break;
  752.             }
  753.             break;
  754.         case WLAN_ENCRYPT_MODE_TKIP:
  755.             prof->pairwise = WPA_CIPHER_TKIP;
  756.             prof->group = WPA_CIPHER_TKIP;
  757.             break;
  758.         case WLAN_ENCRYPT_MODE_AES:
  759.             prof->pairwise = WPA_CIPHER_CCMP;
  760.             prof->group = WPA_CIPHER_CCMP;
  761.             break;
  762.     }
  763.     /* WEP key information */
  764.     if (profile->auth_mode == WLAN_AUTH_MODE_SHARED || profile->encrypt_mode == WLAN_ENCRYPT_MODE_WEP)
  765.     {
  766.         U8 i;
  767.         prof->wep_info_p = KAL_TRUE;
  768.         prof->wep_keys.wep_tx_keyidx = profile->wep_key_index;
  769.         for (i = 0; i < MAX_WEP_KEY_NUM; i++)
  770.         {
  771.             switch (profile->wep_key_len)
  772.             {
  773.                 case WLAN_WEP_KEY_ENCRYPT_64:
  774.                     prof->wep_keys.wep_key_len[i] = 5;
  775.                     if (profile->wep_key_format == WLAN_WEP_KEY_FORMAT_HEX)
  776.                     {
  777.                         if (hex_to_string(prof->wep_keys.wep_key[i], profile->wep_key, 10) == FALSE)
  778.                         {
  779.                             prof->wep_keys.wep_key_len[i] = 0;
  780.                         }
  781.                     }
  782.                     else
  783.                     {
  784.                         memcpy(&prof->wep_keys.wep_key[i], profile->wep_key, 5);
  785.                     }
  786.                     break;
  787.                 case WLAN_WEP_KEY_ENCRYPT_128:
  788.                     prof->wep_keys.wep_key_len[i] = 13;
  789.                     if (profile->wep_key_format == WLAN_WEP_KEY_FORMAT_HEX)
  790.                     {
  791.                         if (hex_to_string(prof->wep_keys.wep_key[i], profile->wep_key, 26) == FALSE)
  792.                         {
  793.                             prof->wep_keys.wep_key_len[i] = 0;
  794.                         }
  795.                     }
  796.                     else
  797.                     {
  798.                         memcpy(prof->wep_keys.wep_key[i], profile->wep_key, 13);
  799.                     }
  800.                     break;
  801.                 default:
  802.                     prof->wep_keys.wep_key_len[i] = 0;
  803.                     break;
  804.             }
  805.         }
  806.     }
  807.     return KAL_TRUE;
  808. }
  809. /*****************************************************************************
  810.  * FUNCTION
  811.  *  mmi_wlan_send_init_req
  812.  * DESCRIPTION
  813.  *  Response for wps query
  814.  * PARAMETERS
  815.  *  void
  816.  *  info(?)     [IN]        Local parameters from protocol
  817.  * RETURNS
  818.  *  void
  819.  *****************************************************************************/
  820. void mmi_wlan_send_init_req(void)
  821. {
  822.     /*----------------------------------------------------------------*/
  823.     /* Local Variables                                                */
  824.     /*----------------------------------------------------------------*/
  825.     /*----------------------------------------------------------------*/
  826.     /* Code Body                                                      */
  827.     /*----------------------------------------------------------------*/
  828.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_wlan_send_init_req() called. prev_state=%s, state=%s,",
  829.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  830.     
  831.     switch (g_wlan_display_context.prev_state)
  832.     {
  833.         case WLAN_STATE_NULL:
  834.             add_action(&g_wlan_display_context.actions, WLAN_ACTION_INIT, NULL);
  835.             break;
  836.         default:
  837.             ASSERT(0);  /* Invalid state */
  838.     }
  839. }
  840. /*****************************************************************************
  841.  * FUNCTION
  842.  *  mmi_wlan_send_deinit_req
  843.  * DESCRIPTION
  844.  *  
  845.  * PARAMETERS
  846.  *  void
  847.  * RETURNS
  848.  *  void
  849.  *****************************************************************************/
  850. void mmi_wlan_send_deinit_req(void)
  851. {
  852.     /*----------------------------------------------------------------*/
  853.     /* Local Variables                                                */
  854.     /*----------------------------------------------------------------*/
  855.     /*----------------------------------------------------------------*/
  856.     /* Code Body                                                      */
  857.     /*----------------------------------------------------------------*/
  858.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_wlan_send_deinit_req() called. prev_state=%s, state %s,",
  859.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  860.     
  861.     switch (g_wlan_display_context.prev_state)
  862.     {
  863.         case WLAN_STATE_INIT:
  864.         case WLAN_STATE_CONNECTED:
  865.             add_action(&g_wlan_display_context.actions, WLAN_ACTION_DEINIT, NULL);
  866.             break;
  867.         case WLAN_STATE_NULL:
  868.             if(g_wlan_display_context.state != WLAN_STATE_NULL)
  869.             {
  870.                 if (find_action(g_wlan_display_context.actions, WLAN_ACTION_CONNECT) != NULL)
  871.                 {
  872.                     add_action(&g_wlan_display_context.actions, WLAN_ACTION_DISCONNECT, NULL);
  873.                 }
  874.                 add_action(&g_wlan_display_context.actions, WLAN_ACTION_DEINIT, NULL);
  875.             }
  876.             break;
  877.         default:
  878.             ASSERT(0);  /* Invalid state */
  879.     }
  880. }
  881. /*****************************************************************************
  882.  * FUNCTION
  883.  *  mmi_wlan_send_connect_req
  884.  * DESCRIPTION
  885.  *  
  886.  * PARAMETERS
  887.  *  data        [?]     
  888.  * RETURNS
  889.  *  void
  890.  *****************************************************************************/
  891. void mmi_wlan_send_connect_req(mmi_wlan_profile_struct *data)
  892. {
  893.     /*----------------------------------------------------------------*/
  894.     /* Local Variables                                                */
  895.     /*----------------------------------------------------------------*/
  896.     /*----------------------------------------------------------------*/
  897.     /* Code Body                                                      */
  898.     /*----------------------------------------------------------------*/
  899.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_wlan_send_connect_req() called. prev_state=%s, state %s,",
  900.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  901.     
  902.     switch (g_wlan_display_context.prev_state)
  903.     {
  904.         case WLAN_STATE_NULL:
  905.             if (g_wlan_display_context.state == WLAN_STATE_INIT_WAIT)
  906.             {
  907.                 add_action(&g_wlan_display_context.actions, WLAN_ACTION_DEINIT, NULL);
  908.             }
  909.             else if (g_wlan_display_context.state == WLAN_STATE_CONNECT_WAIT)
  910.             {
  911.                 add_action(&g_wlan_display_context.actions, WLAN_ACTION_DISCONNECT, NULL);
  912.                 add_action(&g_wlan_display_context.actions, WLAN_ACTION_DEINIT, NULL);
  913.             }
  914.             add_action(&g_wlan_display_context.actions, WLAN_ACTION_INIT, NULL);
  915.             add_action(&g_wlan_display_context.actions, WLAN_ACTION_CONNECT, (void*)data);
  916.             break;
  917.         case WLAN_STATE_INIT:
  918.             if (g_wlan_display_context.state == WLAN_STATE_CONNECT_WAIT)
  919.             {
  920.                 add_action(&g_wlan_display_context.actions, WLAN_ACTION_DISCONNECT, NULL);
  921.             }
  922.             add_action(&g_wlan_display_context.actions, WLAN_ACTION_CONNECT, (void*)data);
  923.             break;
  924.         case WLAN_STATE_CONNECTED:
  925.             if (g_wlan_display_context.state == WLAN_STATE_DISCONNECT_WAIT)
  926.             {
  927.                 if (find_action(g_wlan_display_context.actions, WLAN_ACTION_DEINIT) != NULL)
  928.                 {
  929.                     add_action(&g_wlan_display_context.actions, WLAN_ACTION_INIT, NULL);
  930.                 }
  931.             }
  932.             else if(g_wlan_display_context.state == WLAN_STATE_DEINIT_WAIT)
  933.             {
  934.                 add_action(&g_wlan_display_context.actions, WLAN_ACTION_INIT, NULL);
  935.             }
  936.             else
  937.             {
  938.                 add_action(&g_wlan_display_context.actions, WLAN_ACTION_DISCONNECT, NULL);
  939.             }
  940.             add_action(&g_wlan_display_context.actions, WLAN_ACTION_CONNECT, (void*)data);
  941.             break;
  942.         default:
  943.             ASSERT(0);  /* Invalid state */
  944.     }
  945. }
  946. /*****************************************************************************
  947.  * FUNCTION
  948.  *  mmi_wlan_send_disconnect_req
  949.  * DESCRIPTION
  950.  *  
  951.  * PARAMETERS
  952.  *  void
  953.  * RETURNS
  954.  *  void
  955.  *****************************************************************************/
  956. void mmi_wlan_send_disconnect_req(void)
  957. {
  958.     /*----------------------------------------------------------------*/
  959.     /* Local Variables                                                */
  960.     /*----------------------------------------------------------------*/
  961.     /*----------------------------------------------------------------*/
  962.     /* Code Body                                                      */
  963.     /*----------------------------------------------------------------*/
  964.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_wlan_send_disconnect_req() called. prev_state=%s, state %s,",
  965.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  966.     if(g_wlan_display_context.prev_state == WLAN_STATE_CONNECTED ||
  967.        g_wlan_display_context.state == WLAN_STATE_CONNECT_WAIT)
  968.     {
  969.         add_action(&g_wlan_display_context.actions, WLAN_ACTION_DISCONNECT, NULL);
  970.     }
  971.     else
  972.     {
  973.         ASSERT(0);  /* Invalid state */
  974.     }
  975. }
  976. /*****************************************************************************
  977.  * FUNCTION
  978.  *  mmi_wlan_send_ap_list_req
  979.  * DESCRIPTION
  980.  *  
  981.  * PARAMETERS
  982.  *  void
  983.  * RETURNS
  984.  *  void
  985.  *****************************************************************************/
  986. void mmi_wlan_send_ap_list_req(void)
  987. {
  988.     /*----------------------------------------------------------------*/
  989.     /* Local Variables                                                */
  990.     /*----------------------------------------------------------------*/
  991.     /*----------------------------------------------------------------*/
  992.     /* Code Body                                                      */
  993.     /*----------------------------------------------------------------*/
  994.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_wlan_send_ap_list_req() called. prev_state=%s, state %s,",
  995.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  996.     switch (g_wlan_display_context.scan_state)
  997.     {
  998.         case WLAN_SCAN_STATE_ABORTING:
  999.             g_wlan_display_context.scan_state = WLAN_SCAN_STATE_WAITING;
  1000.             break;
  1001.         case WLAN_SCAN_STATE_WAITING:
  1002.             return; /* Do not send request if we are waiting for the search result */
  1003.     }
  1004.     if (g_wlan_display_context.prev_state == WLAN_STATE_NULL && 
  1005.         g_wlan_display_context.state != WLAN_STATE_CONNECT_WAIT)
  1006.     {
  1007.         add_action(&g_wlan_display_context.actions, WLAN_ACTION_INIT, NULL);
  1008.         add_action(&g_wlan_display_context.actions, WLAN_ACTION_SCAN, NULL);
  1009.     }
  1010.     else
  1011.     {
  1012.         if (g_wlan_display_context.state == WLAN_STATE_CONNECT_WAIT)
  1013.         {
  1014.             add_action(&g_wlan_display_context.actions, WLAN_ACTION_DISCONNECT, NULL);
  1015.         }
  1016.         add_action(&g_wlan_display_context.actions, WLAN_ACTION_SCAN, NULL);
  1017.     }
  1018. }
  1019. /*****************************************************************************
  1020.  * FUNCTION
  1021.  *  mmi_wlan_abm_wifi_init_req_hdlr
  1022.  * DESCRIPTION
  1023.  *  send request to query wps state
  1024.  * PARAMETERS
  1025.  *  void
  1026.  * RETURNS
  1027.  *  void
  1028.  *****************************************************************************/
  1029. void mmi_wlan_abm_wifi_init_req_hdlr(void)
  1030. {
  1031.     /*----------------------------------------------------------------*/
  1032.     /* Local Variables                                                */
  1033.     /*----------------------------------------------------------------*/
  1034.     MYQUEUE Message;
  1035.     /*----------------------------------------------------------------*/
  1036.     /* Code Body                                                      */
  1037.     /*----------------------------------------------------------------*/
  1038.     if(g_wlan_display_context.state == WLAN_STATE_INIT_WAIT)
  1039.     {
  1040.         return;
  1041.     }
  1042.     SetProtocolEventHandler(mmi_wlan_abm_wifi_init_cnf_hdlr, MSG_ID_MMI_ABM_WIFI_INIT_CNF);
  1043.     g_wlan_display_context.state = WLAN_STATE_INIT_WAIT;
  1044.     Message.oslSrcId = MOD_MMI;
  1045.     Message.oslDestId = MOD_ABM;
  1046.     Message.oslMsgId = MSG_ID_MMI_ABM_WIFI_INIT_REQ;
  1047.     Message.oslDataPtr = NULL;
  1048.     Message.oslPeerBuffPtr = NULL;
  1049.     OslMsgSendExtQueue(&Message);
  1050. }
  1051. /*****************************************************************************
  1052.  * FUNCTION
  1053.  *  mmi_wlan_abm_wifi_init_cnf_hdlr
  1054.  * DESCRIPTION
  1055.  *  Response for wps query
  1056.  * PARAMETERS
  1057.  *  info        [IN]        Local parameters from protocol
  1058.  * RETURNS
  1059.  *  void
  1060.  *****************************************************************************/
  1061. void mmi_wlan_abm_wifi_init_cnf_hdlr(void *info)
  1062. {
  1063.     /*----------------------------------------------------------------*/
  1064.     /* Local Variables                                                */
  1065.     /*----------------------------------------------------------------*/
  1066.     S16 error;
  1067.     mmi_abm_wifi_init_cnf_struct *cnf;
  1068.     /*----------------------------------------------------------------*/
  1069.     /* Code Body                                                      */
  1070.     /*----------------------------------------------------------------*/
  1071.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "MSG_ID_MMI_ABM_WIFI_INIT_CNF received. prev_state=%s, state %s,",
  1072.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  1073.     cnf = (mmi_abm_wifi_init_cnf_struct*) info;
  1074.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_WIFI_INIT_CNF);
  1075.     SetProtocolEventHandler(mmi_wlan_supc_mmi_wifi_curr_ap_info_ind_hdlr, MSG_ID_SUPC_MMI_WIFI_CURR_AP_INFO_IND);
  1076.     SetProtocolEventHandler(mmi_wlan_abm_wifi_connect_ind_hdlr, MSG_ID_MMI_ABM_WIFI_CONNECT_IND);
  1077.     SetProtocolEventHandler(mmi_wlan_abm_ipaddr_update_ind_hdlr, MSG_ID_MMI_ABM_IPADDR_UPDATE_IND);
  1078.     mmi_wlan_update_status_icon(IMG_ID_DTCNT_WLAN_STATUS_DISCONNECT, FALSE);
  1079.     g_wlan_display_context.state = WLAN_STATE_INIT;
  1080.     memcpy(g_wlan_display_context.mac_addr, cnf->mac_addr, MAX_MAC_ADDR_LEN);
  1081.     if(g_wlan_display_context.app_callback != NULL)
  1082.     {
  1083.         g_wlan_display_context.app_callback();
  1084.         g_wlan_display_context.app_callback = NULL;
  1085.     }
  1086.     mmi_wlan_send_event_notify(DTCNT_BEARER_STATE_INITIALIZED);
  1087.     if (do_action() == TRUE)
  1088.     {
  1089.         return;
  1090.     }
  1091.     /* If nothing to do then we can remove the progress screen and update the prev state */
  1092.     g_wlan_display_context.prev_state = WLAN_STATE_INIT;
  1093.     if(g_wlan_setting_context.start_on_bootup == FALSE)
  1094.     {
  1095.         g_wlan_setting_context.start_on_bootup = TRUE;
  1096.         if (WriteRecord(NVRAM_EF_WLAN_SETTING_LID, 1, &g_wlan_setting_context, NVRAM_MAX_WLAN_SETTING_SIZE, &error) <
  1097.             NVRAM_MAX_WLAN_SETTING_SIZE)
  1098.         {
  1099.             ASSERT(0);
  1100.         }
  1101.     }
  1102.     if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_PROCESSING)
  1103.     {
  1104.         GoBackHistory();
  1105.     }
  1106.     else
  1107.     {
  1108.         DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_PROCESSING);
  1109.     }
  1110. }
  1111. /*****************************************************************************
  1112.  * FUNCTION
  1113.  *  mmi_wlan_abm_wifi_deinit_req_hdlr
  1114.  * DESCRIPTION
  1115.  *  send request to query wps state
  1116.  * PARAMETERS
  1117.  *  void
  1118.  * RETURNS
  1119.  *  void
  1120.  *****************************************************************************/
  1121. void mmi_wlan_abm_wifi_deinit_req_hdlr(void)
  1122. {
  1123.     /*----------------------------------------------------------------*/
  1124.     /* Local Variables                                                */
  1125.     /*----------------------------------------------------------------*/
  1126.     MYQUEUE Message;
  1127.     /*----------------------------------------------------------------*/
  1128.     /* Code Body                                                      */
  1129.     /*----------------------------------------------------------------*/
  1130.     if(g_wlan_display_context.state == WLAN_STATE_DEINIT_WAIT)
  1131.     {
  1132.         return;
  1133.     }
  1134.     SetProtocolEventHandler(mmi_wlan_abm_wifi_deinit_cnf_hdlr, MSG_ID_MMI_ABM_WIFI_DEINIT_CNF);
  1135.     g_wlan_display_context.state = WLAN_STATE_DEINIT_WAIT;
  1136.     Message.oslSrcId = MOD_MMI;
  1137.     Message.oslDestId = MOD_ABM;
  1138.     Message.oslMsgId = MSG_ID_MMI_ABM_WIFI_DEINIT_REQ;
  1139.     Message.oslDataPtr = NULL;
  1140.     Message.oslPeerBuffPtr = NULL;
  1141.     OslMsgSendExtQueue(&Message);
  1142. }
  1143. /*****************************************************************************
  1144.  * FUNCTION
  1145.  *  mmi_wlan_abm_wifi_deinit_cnf_hdlr
  1146.  * DESCRIPTION
  1147.  *  Response for wps query
  1148.  * PARAMETERS
  1149.  *  info        [IN]        Local parameters from protocol
  1150.  * RETURNS
  1151.  *  void
  1152.  *****************************************************************************/
  1153. void mmi_wlan_abm_wifi_deinit_cnf_hdlr(void *info)
  1154. {
  1155.     /*----------------------------------------------------------------*/
  1156.     /* Local Variables                                                */
  1157.     /*----------------------------------------------------------------*/
  1158.     S16 error;
  1159.     mmi_abm_wifi_init_cnf_struct *cnf;
  1160.     /*----------------------------------------------------------------*/
  1161.     /* Code Body                                                      */
  1162.     /*----------------------------------------------------------------*/
  1163.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "MSG_ID_MMI_ABM_WIFI_DEINIT_CNF received. prev_state=%s, state %s,",
  1164.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  1165.     cnf = (mmi_abm_wifi_init_cnf_struct*) info;
  1166.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_WIFI_DEINIT_CNF);
  1167.     ClearProtocolEventHandler(MSG_ID_SUPC_MMI_WIFI_CURR_AP_INFO_IND);
  1168.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_WIFI_CONNECT_IND);
  1169.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_IPADDR_UPDATE_IND);
  1170.     mmi_wlan_update_status_icon(0, FALSE);
  1171.     g_wlan_display_context.state = WLAN_STATE_NULL;
  1172.     mmi_wlan_send_event_notify(DTCNT_BEARER_STATE_INACTIVE);
  1173.     if (do_action() == TRUE)
  1174.     {
  1175.         return;
  1176.     }
  1177.     /* If nothing to do then we can remove the progress screen and update the prev state */
  1178.     g_wlan_display_context.prev_state = WLAN_STATE_NULL;
  1179.     if(g_wlan_display_context.app_callback == NULL)
  1180.     {
  1181.         g_wlan_setting_context.start_on_bootup = FALSE;
  1182.         if (WriteRecord(NVRAM_EF_WLAN_SETTING_LID, 1, &g_wlan_setting_context, NVRAM_MAX_WLAN_SETTING_SIZE, &error) <
  1183.             NVRAM_MAX_WLAN_SETTING_SIZE)
  1184.         {
  1185.             ASSERT(0);
  1186.         }
  1187.     }
  1188.     if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_PROCESSING)
  1189.     {
  1190.         GoBackHistory();
  1191.     }
  1192.     else if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_CONN_STATUS)
  1193.     {
  1194.         mmi_wlan_redraw_conn_status_screen();
  1195.     }
  1196.     else
  1197.     {
  1198.         DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_PROCESSING);
  1199.     }
  1200.     if(g_wlan_display_context.app_callback != NULL)
  1201.     {
  1202.         g_wlan_display_context.app_callback();
  1203.         g_wlan_display_context.app_callback = NULL;
  1204.     }
  1205. }
  1206. /*****************************************************************************
  1207.  * FUNCTION
  1208.  *  mmi_wlan_abm_wifi_connect_req_hdlr
  1209.  * DESCRIPTION
  1210.  *  send request to query wps state
  1211.  * PARAMETERS
  1212.  *  data        [?]     
  1213.  * RETURNS
  1214.  *  void
  1215.  *****************************************************************************/
  1216. void mmi_wlan_abm_wifi_connect_req_hdlr(void *data)
  1217. {
  1218.     /*----------------------------------------------------------------*/
  1219.     /* Local Variables                                                */
  1220.     /*----------------------------------------------------------------*/
  1221.     S16 error;
  1222.     MYQUEUE Message;
  1223.     mmi_abm_wifi_connect_req_struct *p;
  1224.     /*----------------------------------------------------------------*/
  1225.     /* Code Body                                                      */
  1226.     /*----------------------------------------------------------------*/
  1227.     if (data == NULL)
  1228.     {
  1229.         U8 i, j, profile_num;
  1230.         for (i = 0, profile_num = 0; i < g_wlan_display_context.prof_num;)
  1231.         {
  1232.             p = (mmi_abm_wifi_connect_req_struct*) OslConstructDataPtr(sizeof(mmi_abm_wifi_connect_req_struct));
  1233.             for (j = 0; (i < g_wlan_display_context.prof_num) && (j < 2); i++, j++)
  1234.             {
  1235.                 memset(&p->profile_header_ptr[j], 0, sizeof(wifi_data_account_profile_struct));
  1236.                 
  1237.                 if (encode_profile(&p->profile_header_ptr[j], g_wlan_profile[i]) == KAL_FALSE)
  1238.                 {
  1239.                     continue;
  1240.                 }
  1241.             }
  1242.             profile_num += j;
  1243.             if(profile_num > 0)
  1244.             {                
  1245.                 p->selection_mode = AP_AUTOMATIC_SELECT;
  1246.                 p->num_of_profile = j;
  1247.                 p->more_flag = (i < g_wlan_display_context.prof_num) ? 1 : 0;
  1248.                 Message.oslSrcId = MOD_MMI;
  1249.                 Message.oslDestId = MOD_ABM;
  1250.                 Message.oslMsgId = MSG_ID_MMI_ABM_WIFI_CONNECT_REQ;
  1251.                 Message.oslDataPtr = (oslParaType*) p;
  1252.                 Message.oslPeerBuffPtr = NULL;
  1253.                 OslMsgSendExtQueue(&Message);
  1254.             }
  1255.             else
  1256.             {
  1257.                 OslFreeDataPtr(p);
  1258.                 return;
  1259.             }
  1260.         }
  1261.         if (profile_num > 0)
  1262.         {
  1263.             SetProtocolEventHandler(mmi_wlan_abm_wifi_connect_cnf_hdlr, MSG_ID_MMI_ABM_WIFI_CONNECT_CNF);
  1264.             g_wlan_display_context.state = WLAN_STATE_CONNECT_WAIT;
  1265.         }
  1266.         else
  1267.         {
  1268.             /* If we failed on generating profiles, set the state to be initialized */
  1269.      g_wlan_display_context.prev_state = g_wlan_display_context.state;
  1270.             if(g_wlan_setting_context.start_on_bootup == FALSE)
  1271.             {
  1272.                 g_wlan_setting_context.start_on_bootup = TRUE;
  1273.                 if (WriteRecord(NVRAM_EF_WLAN_SETTING_LID, 1, &g_wlan_setting_context, NVRAM_MAX_WLAN_SETTING_SIZE, &error) <
  1274.                     NVRAM_MAX_WLAN_SETTING_SIZE)
  1275.                 {
  1276.                     ASSERT(0);
  1277.                 }
  1278.             }
  1279.             return;
  1280.         }
  1281.     }
  1282.     else
  1283.     {
  1284.         p = (mmi_abm_wifi_connect_req_struct*) OslConstructDataPtr(sizeof(mmi_abm_wifi_connect_req_struct));
  1285.         if (encode_profile(&p->profile_header_ptr[0], (mmi_wlan_profile_struct*) data) == KAL_FALSE)
  1286.         {
  1287.             g_wlan_display_context.prev_state = g_wlan_display_context.state;
  1288.             OslFreeDataPtr(p);
  1289.             if(IsScreenPresent(SCR_ID_DTCNT_WLAN_PROCESSING))
  1290.             {
  1291.                 DisplayPopup(
  1292.                     (PU8) GetString(STR_ID_DTCNT_WLAN_ERROR_FILE_OPEN_FAILED),
  1293.                     IMG_GLOBAL_ERROR,
  1294.                     1,
  1295.                     DATA_ACCOUNT_NOTIFY_TIMEOUT,
  1296.                     ERROR_TONE);
  1297.                 DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_PROCESSING);
  1298.             }
  1299.             return;
  1300.         }
  1301.         p->num_of_profile = 1;
  1302.         p->selection_mode = AP_AUTOMATIC_SELECT;
  1303.         p->more_flag = 0;
  1304.         Message.oslSrcId = MOD_MMI;
  1305.         Message.oslDestId = MOD_ABM;
  1306.         Message.oslMsgId = MSG_ID_MMI_ABM_WIFI_CONNECT_REQ;
  1307.         Message.oslDataPtr = (oslParaType*) p;
  1308.         Message.oslPeerBuffPtr = NULL;
  1309.         OslMsgSendExtQueue(&Message);
  1310.         SetProtocolEventHandler(mmi_wlan_abm_wifi_connect_cnf_hdlr, MSG_ID_MMI_ABM_WIFI_CONNECT_CNF);
  1311.         g_wlan_display_context.state = WLAN_STATE_CONNECT_WAIT;
  1312.     }
  1313. }
  1314. /*****************************************************************************
  1315.  * FUNCTION
  1316.  *  mmi_wlan_abm_wifi_connect_cnf_hdlr
  1317.  * DESCRIPTION
  1318.  *  Response for wps query
  1319.  * PARAMETERS
  1320.  *  info        [IN]        Local parameters from protocol
  1321.  * RETURNS
  1322.  *  void
  1323.  *****************************************************************************/
  1324. void mmi_wlan_abm_wifi_connect_cnf_hdlr(void *info)
  1325. {
  1326.     /*----------------------------------------------------------------*/
  1327.     /* Local Variables                                                */
  1328.     /*----------------------------------------------------------------*/
  1329.     S16 error;
  1330.     U16 string_id;
  1331.     mmi_abm_wifi_connect_cnf_struct *cnf;
  1332.     /*----------------------------------------------------------------*/
  1333.     /* Code Body                                                      */
  1334.     /*----------------------------------------------------------------*/
  1335.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "MSG_ID_MMI_ABM_WIFI_CONNECT_CNF received. prev_state=%s, state %s,",
  1336.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  1337.     cnf = (mmi_abm_wifi_connect_cnf_struct*) info;
  1338.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_WIFI_CONNECT_CNF);
  1339.     SetProtocolEventHandler(mmi_wlan_abm_wifi_disconnect_ind_hdlr, MSG_ID_MMI_ABM_WIFI_DISCONNECT_IND);
  1340.     SetProtocolEventHandler(mmi_wlan_abm_ipaddr_conflict_ind_hdlr, MSG_ID_MMI_ABM_IPADDR_CONFLICT_IND);
  1341.     if (cnf->result == KAL_TRUE)
  1342.     {
  1343.         mmi_wlan_update_status_icon(IMG_ID_DTCNT_WLAN_STATUS_CONNECT1, FALSE);
  1344.         g_wlan_display_context.state = WLAN_STATE_CONNECTED;
  1345.         g_wlan_display_context.connected_wlan_profile = mmi_wlan_find_profile(cnf->profile_id);
  1346.         g_wlan_display_context.ssid_len = cnf->ssid_len;
  1347.         memcpy(g_wlan_display_context.ssid, cnf->ssid, cnf->ssid_len);
  1348.         memcpy(g_wlan_display_context.bssid, cnf->bssid, MAX_MAC_ADDR_LEN);
  1349.         g_wlan_display_context.curr_channel_number = cnf->channel_number;
  1350.         mmi_wlan_send_event_notify(DTCNT_BEARER_STATE_CONNECTED);
  1351.     }
  1352.     else
  1353.     {
  1354.         g_wlan_display_context.state = WLAN_STATE_INIT;
  1355.     }
  1356.     if (do_action() == TRUE)
  1357.     {
  1358.         return;
  1359.     }
  1360.     /* If nothing to do then we can remove the progress screen and update the prev state */
  1361.     g_wlan_display_context.prev_state = g_wlan_display_context.state;
  1362.     if(g_wlan_setting_context.start_on_bootup == FALSE)
  1363.     {
  1364.         g_wlan_setting_context.start_on_bootup = TRUE;
  1365.         if (WriteRecord(NVRAM_EF_WLAN_SETTING_LID, 1, &g_wlan_setting_context, NVRAM_MAX_WLAN_SETTING_SIZE, &error) <
  1366.             NVRAM_MAX_WLAN_SETTING_SIZE)
  1367.         {
  1368.             ASSERT(0);
  1369.         }
  1370.     }
  1371.     
  1372.     mmi_wlan_abm_ipaddr_change_req_hdlr();
  1373.     DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_PASSPHRASE_INPUT_OPT);
  1374.     DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_NETWORK_SETTINGS_OPT);
  1375.     DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_FIND_NETWORK_OPT);
  1376.     if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_PROCESSING)
  1377.     {
  1378.         if(cnf->result == KAL_FALSE)
  1379.         {
  1380.             switch(cnf->cause)
  1381.             {
  1382.             case SUPC_ABM_AUTH_FAIL:
  1383.                 string_id = STR_ID_DTCNT_WLAN_ERROR_AUTH_FAIL;
  1384.                 break;
  1385.             default:
  1386.                 string_id = STR_ID_DTCNT_WLAN_ERROR_CONNECT_FAIL;
  1387.                 break;                
  1388.             }
  1389.             
  1390.             DisplayPopup(
  1391.                 (PU8) GetString(string_id),
  1392.                 IMG_GLOBAL_ERROR,
  1393.                 1,
  1394.                 DATA_ACCOUNT_NOTIFY_TIMEOUT,
  1395.                 ERROR_TONE);
  1396.             DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_PROCESSING);
  1397.         }
  1398.         else
  1399.         {
  1400.             GoBackHistory();
  1401.         }
  1402.     }
  1403.     else if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_CONN_STATUS)
  1404.     {
  1405.         mmi_wlan_redraw_conn_status_screen();
  1406.     }
  1407.     else if(GetActiveScreenId() == SCR_ID_DTCNT_WLAN_NETWORK_SETTINGS)
  1408.     {
  1409.         mmi_wlan_redraw_network_settings_screen();
  1410.     }
  1411.     else
  1412.     {
  1413.         DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_PROCESSING);
  1414.     }
  1415. }
  1416. /*****************************************************************************
  1417.  * FUNCTION
  1418.  *  mmi_wlan_abm_wifi_connect_ind_hdlr
  1419.  * DESCRIPTION
  1420.  *  Response for wps query
  1421.  * PARAMETERS
  1422.  *  info        [IN]        Local parameters from protocol
  1423.  * RETURNS
  1424.  *  void
  1425.  *****************************************************************************/
  1426. void mmi_wlan_abm_wifi_connect_ind_hdlr(void *info)
  1427. {
  1428.     /*----------------------------------------------------------------*/
  1429.     /* Local Variables                                                */
  1430.     /*----------------------------------------------------------------*/
  1431.     mmi_abm_wifi_connect_ind_struct *ind;
  1432.     /*----------------------------------------------------------------*/
  1433.     /* Code Body                                                      */
  1434.     /*----------------------------------------------------------------*/
  1435.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "MSG_ID_MMI_ABM_WIFI_CONNECT_IND received. prev_state=%s, state %s,",
  1436.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  1437.     ind = (mmi_abm_wifi_connect_ind_struct*) info;
  1438.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_WIFI_CONNECT_CNF);
  1439.     SetProtocolEventHandler(mmi_wlan_abm_ipaddr_conflict_ind_hdlr, MSG_ID_MMI_ABM_IPADDR_CONFLICT_IND);
  1440.     SetProtocolEventHandler(mmi_wlan_abm_wifi_disconnect_ind_hdlr, MSG_ID_MMI_ABM_WIFI_DISCONNECT_IND);
  1441.     mmi_wlan_update_status_icon(IMG_ID_DTCNT_WLAN_STATUS_CONNECT1, FALSE);
  1442.     
  1443.     g_wlan_display_context.prev_state = g_wlan_display_context.state = WLAN_STATE_CONNECTED;
  1444.     g_wlan_display_context.connected_wlan_profile = mmi_wlan_find_profile(ind->profile_id);
  1445.     g_wlan_display_context.ssid_len = ind->ssid_len;
  1446.     memcpy(g_wlan_display_context.ssid, ind->ssid, ind->ssid_len);
  1447.     memcpy(g_wlan_display_context.bssid, ind->bssid, MAX_MAC_ADDR_LEN);
  1448.     g_wlan_display_context.curr_channel_number = ind->channel_number;
  1449.     mmi_wlan_send_event_notify(DTCNT_BEARER_STATE_CONNECTED);
  1450.     mmi_wlan_abm_ipaddr_change_req_hdlr();
  1451.     DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_PASSPHRASE_INPUT_OPT);
  1452.     DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_NETWORK_SETTINGS_OPT);
  1453.     DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_FIND_NETWORK_OPT);
  1454.     if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_PROCESSING)
  1455.     {
  1456.         GoBackHistory();
  1457.     }
  1458.     else if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_CONN_STATUS)
  1459.     {
  1460.         mmi_wlan_redraw_conn_status_screen();
  1461.     }
  1462.     else if(GetActiveScreenId() == SCR_ID_DTCNT_WLAN_NETWORK_SETTINGS)
  1463.     {
  1464.         mmi_wlan_redraw_network_settings_screen();
  1465.     }
  1466.     else
  1467.     {
  1468.         DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_PROCESSING);
  1469.     }
  1470. }
  1471. /*****************************************************************************
  1472.  * FUNCTION
  1473.  *  mmi_wlan_abm_wifi_disconnect_req_hdlr
  1474.  * DESCRIPTION
  1475.  *  send request to query wps state
  1476.  * PARAMETERS
  1477.  *  void
  1478.  * RETURNS
  1479.  *  void
  1480.  *****************************************************************************/
  1481. void mmi_wlan_abm_wifi_disconnect_req_hdlr(void)
  1482. {
  1483.     /*----------------------------------------------------------------*/
  1484.     /* Local Variables                                                */
  1485.     /*----------------------------------------------------------------*/
  1486.     MYQUEUE Message;
  1487.     /*----------------------------------------------------------------*/
  1488.     /* Code Body                                                      */
  1489.     /*----------------------------------------------------------------*/
  1490.     if(g_wlan_display_context.state == WLAN_STATE_DISCONNECT_WAIT)
  1491.     {
  1492.         return;
  1493.     }
  1494.     ASSERT(g_wlan_display_context.state == WLAN_STATE_CONNECT_WAIT || g_wlan_display_context.state == WLAN_STATE_CONNECTED);
  1495.     if(g_wlan_display_context.state == WLAN_STATE_CONNECT_WAIT)
  1496.     {
  1497.         ClearProtocolEventHandler(MSG_ID_MMI_ABM_WIFI_CONNECT_CNF);
  1498.     }
  1499.     
  1500.     SetProtocolEventHandler(mmi_wlan_abm_wifi_disconnect_cnf_hdlr, MSG_ID_MMI_ABM_WIFI_DISCONNECT_CNF);
  1501.     g_wlan_display_context.state = WLAN_STATE_DISCONNECT_WAIT;
  1502.     Message.oslSrcId = MOD_MMI;
  1503.     Message.oslDestId = MOD_ABM;
  1504.     Message.oslMsgId = MSG_ID_MMI_ABM_WIFI_DISCONNECT_REQ;
  1505.     Message.oslDataPtr = NULL;
  1506.     Message.oslPeerBuffPtr = NULL;
  1507.     OslMsgSendExtQueue(&Message);
  1508. }
  1509. /*****************************************************************************
  1510.  * FUNCTION
  1511.  *  mmi_wlan_abm_wifi_disconnect_cnf_hdlr
  1512.  * DESCRIPTION
  1513.  *  Response for wps query
  1514.  * PARAMETERS
  1515.  *  info        [IN]        Local parameters from protocol
  1516.  * RETURNS
  1517.  *  void
  1518.  *****************************************************************************/
  1519. void mmi_wlan_abm_wifi_disconnect_cnf_hdlr(void *info)
  1520. {
  1521.     /*----------------------------------------------------------------*/
  1522.     /* Local Variables                                                */
  1523.     /*----------------------------------------------------------------*/
  1524.     /*----------------------------------------------------------------*/
  1525.     /* Code Body                                                      */
  1526.     /*----------------------------------------------------------------*/
  1527.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "MSG_ID_MMI_ABM_WIFI_DISCONNECT_CNF received. prev_state=%s, state %s,",
  1528.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  1529.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_WIFI_DISCONNECT_CNF);
  1530.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_WIFI_DISCONNECT_IND);
  1531.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_IPADDR_CONFLICT_IND);
  1532.     mmi_wlan_update_status_icon(IMG_ID_DTCNT_WLAN_STATUS_DISCONNECT, FALSE);
  1533.     g_wlan_display_context.state = WLAN_STATE_INIT;
  1534.     g_wlan_display_context.connected_wlan_profile = NULL;
  1535.     g_wlan_display_context.ssid_len = 0;
  1536.     memset(g_wlan_display_context.ssid, 0, MAX_SSID_LEN);
  1537.     memset(g_wlan_display_context.bssid, 0, MAX_MAC_ADDR_LEN);
  1538.     mmi_wlan_send_event_notify(DTCNT_BEARER_STATE_INITIALIZED);
  1539.     if (do_action() == TRUE)
  1540.     {
  1541.         return;
  1542.     }
  1543.     /* If nothing to do then we can remove the progress screen and update the prev state */
  1544.     g_wlan_display_context.prev_state = g_wlan_display_context.state;
  1545.     if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_PROCESSING)
  1546.     {
  1547.         GoBackHistory();
  1548.     }
  1549.     else if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_CONN_STATUS)
  1550.     {
  1551.         mmi_wlan_redraw_conn_status_screen();
  1552.     }
  1553.     else if(GetActiveScreenId() == SCR_ID_DTCNT_WLAN_NETWORK_SETTINGS)
  1554.     {
  1555.         mmi_wlan_redraw_network_settings_screen();
  1556.     }
  1557.     else
  1558.     {
  1559.         DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_PROCESSING);
  1560.     }
  1561. }
  1562. /*****************************************************************************
  1563.  * FUNCTION
  1564.  *  mmi_wlan_abm_wifi_disconnect_ind_hdlr
  1565.  * DESCRIPTION
  1566.  *  Response for wps query
  1567.  * PARAMETERS
  1568.  *  info        [IN]        Local parameters from protocol
  1569.  * RETURNS
  1570.  *  void
  1571.  *****************************************************************************/
  1572. void mmi_wlan_abm_wifi_disconnect_ind_hdlr(void *info)
  1573. {
  1574.     /*----------------------------------------------------------------*/
  1575.     /* Local Variables                                                */
  1576.     /*----------------------------------------------------------------*/
  1577.     /*----------------------------------------------------------------*/
  1578.     /* Code Body                                                      */
  1579.     /*----------------------------------------------------------------*/
  1580.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "MSG_ID_MMI_ABM_WIFI_DISCONNECT_IND received. prev_state=%s, state %s,",
  1581.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  1582.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_WIFI_DISCONNECT_CNF);
  1583.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_WIFI_DISCONNECT_IND);
  1584.     ClearProtocolEventHandler(MSG_ID_MMI_ABM_IPADDR_CONFLICT_IND);
  1585.     mmi_wlan_update_status_icon(IMG_ID_DTCNT_WLAN_STATUS_DISCONNECT, FALSE);
  1586.     g_wlan_display_context.prev_state = g_wlan_display_context.state = WLAN_STATE_INIT;
  1587.     g_wlan_display_context.connected_wlan_profile = NULL;
  1588.     g_wlan_display_context.ssid_len = 0;
  1589.     memcpy(g_wlan_display_context.ssid, 0, MAX_SSID_LEN);
  1590.     memcpy(g_wlan_display_context.bssid, 0, MAX_MAC_ADDR_LEN);
  1591.     mmi_wlan_send_event_notify(DTCNT_BEARER_STATE_INITIALIZED);
  1592.     if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_CONN_STATUS)
  1593.     {
  1594.         mmi_wlan_redraw_conn_status_screen();
  1595.     }
  1596.     else if(GetActiveScreenId() == SCR_ID_DTCNT_WLAN_NETWORK_SETTINGS)
  1597.     {
  1598.         mmi_wlan_redraw_network_settings_screen();
  1599.     }
  1600. }
  1601. /*****************************************************************************
  1602.  * FUNCTION
  1603.  *  mmi_wlan_abm_wifi_ap_list_req_hdlr
  1604.  * DESCRIPTION
  1605.  *  send request to query wps state
  1606.  * PARAMETERS
  1607.  *  void
  1608.  * RETURNS
  1609.  *  void
  1610.  *****************************************************************************/
  1611. void mmi_wlan_abm_wifi_ap_list_req_hdlr(void)
  1612. {
  1613.     /*----------------------------------------------------------------*/
  1614.     /* Local Variables                                                */
  1615.     /*----------------------------------------------------------------*/
  1616.     MYQUEUE Message;
  1617.     /*----------------------------------------------------------------*/
  1618.     /* Code Body                                                      */
  1619.     /*----------------------------------------------------------------*/
  1620.     SetProtocolEventHandler(mmi_wlan_abm_wifi_ap_list_cnf_hdlr, MSG_ID_MMI_ABM_WIFI_AP_LIST_CNF);
  1621.     g_wlan_display_context.scan_state = WLAN_SCAN_STATE_WAITING;
  1622.     mmi_wlan_update_status_icon(IMG_ID_DTCNT_WLAN_STATUS_SCANNING, TRUE);
  1623.     Message.oslSrcId = MOD_MMI;
  1624.     Message.oslDestId = MOD_ABM;
  1625.     Message.oslMsgId = MSG_ID_MMI_ABM_WIFI_AP_LIST_REQ;
  1626.     Message.oslDataPtr = NULL;
  1627.     Message.oslPeerBuffPtr = NULL;
  1628.     OslMsgSendExtQueue(&Message);
  1629. }
  1630. /*****************************************************************************
  1631.  * FUNCTION
  1632.  *  mmi_wlan_abm_wifi_ap_list_cnf_hdlr
  1633.  * DESCRIPTION
  1634.  *  Response for wps query
  1635.  * PARAMETERS
  1636.  *  info        [IN]        Local parameters from protocol
  1637.  * RETURNS
  1638.  *  void
  1639.  *****************************************************************************/
  1640. void mmi_wlan_abm_wifi_ap_list_cnf_hdlr(void *info)
  1641. {
  1642.     /*----------------------------------------------------------------*/
  1643.     /* Local Variables                                                */
  1644.     /*----------------------------------------------------------------*/
  1645.     S16 error;
  1646.     U8 i, ap_list_num;
  1647.     mmi_abm_wifi_ap_list_cnf_struct *cnf;
  1648.     /*----------------------------------------------------------------*/
  1649.     /* Code Body                                                      */
  1650.     /*----------------------------------------------------------------*/
  1651.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "MSG_ID_MMI_ABM_WIFI_AP_LIST_CNF received. prev_state=%s, state %s,",
  1652.                          state2str(g_wlan_display_context.prev_state), state2str(g_wlan_display_context.state)));
  1653.     cnf = (mmi_abm_wifi_ap_list_cnf_struct*) info;
  1654.     if (g_wlan_display_context.scan_state == WLAN_SCAN_STATE_WAITING)
  1655.     {
  1656.         if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_SCAN_PROCESSING ||
  1657.             IsScreenPresent(SCR_ID_DTCNT_WLAN_SCAN_PROCESSING) == MMI_TRUE)
  1658.         {
  1659.             ap_list_num = g_wlan_display_context.ap_list_num;
  1660.             for (i = 0; i < cnf->num && ap_list_num < WNDRV_MAX_SCAN_RESULTS_NUM; i++)
  1661.             {
  1662.                 if (cnf->ap_list[i].ssid_len == 0 || cnf->ap_list[i].ssid[0] == 0)
  1663.                 {
  1664.                     continue;   /* Discard hidden AP */
  1665.                 }
  1666.                 memcpy(
  1667.                     &g_wlan_display_context.ap_list[ap_list_num++],
  1668.                     &cnf->ap_list[i],
  1669.                     sizeof(supc_abm_bss_info_struct));
  1670.             }
  1671.             g_wlan_display_context.ap_list_num = ap_list_num;
  1672.             if (cnf->more_flag == 0)
  1673.             {
  1674.                 ClearProtocolEventHandler(MSG_ID_MMI_ABM_WIFI_AP_LIST_CNF);
  1675.                 if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_SCAN_PROCESSING)
  1676.                 {
  1677.                     mmi_wlan_entry_scan_result();
  1678.                     DeleteScreenIfPresent(SCR_ID_DTCNT_WLAN_SCAN_PROCESSING);
  1679.                 }
  1680.                 else
  1681.                 {
  1682.                     HistoryReplace(
  1683.                         SCR_ID_DTCNT_WLAN_SCAN_PROCESSING,
  1684.                         SCR_ID_DTCNT_WLAN_SCAN_RESULT,
  1685.                         mmi_wlan_entry_scan_result);
  1686.                 }
  1687.             }
  1688.             else
  1689.             {
  1690.                 return;
  1691.             }
  1692.         }
  1693.     }
  1694.     else if (g_wlan_display_context.scan_state == WLAN_SCAN_STATE_ABORTING)
  1695.     {
  1696.         if (cnf->more_flag != 0)
  1697.         {
  1698.             /* Discard the result */
  1699.             return;
  1700.         }
  1701.     }
  1702.     mmi_wlan_update_status_icon(g_wlan_display_context.prev_status_icon, FALSE);
  1703.     g_wlan_display_context.scan_state = WLAN_SCAN_STATE_NULL;
  1704.     
  1705.     if (do_action() == TRUE)
  1706.     {
  1707.         return;
  1708.     }
  1709.     /* If nothing to do then we can remove the progress screen and update the prev state */
  1710.     g_wlan_display_context.prev_state = g_wlan_display_context.state;
  1711.     if(g_wlan_setting_context.start_on_bootup == FALSE)
  1712.     {
  1713.         g_wlan_setting_context.start_on_bootup = TRUE;
  1714.         if (WriteRecord(NVRAM_EF_WLAN_SETTING_LID, 1, &g_wlan_setting_context, NVRAM_MAX_WLAN_SETTING_SIZE, &error) <
  1715.             NVRAM_MAX_WLAN_SETTING_SIZE)
  1716.         {
  1717.             ASSERT(0);
  1718.         }
  1719.     }
  1720. }
  1721. /*****************************************************************************
  1722.  * FUNCTION
  1723.  *  mmi_wlan_abm_ipaddr_update_ind_hdlr
  1724.  * DESCRIPTION
  1725.  *  
  1726.  * PARAMETERS
  1727.  *  info        [?]     
  1728.  * RETURNS
  1729.  *  void
  1730.  *****************************************************************************/
  1731. void mmi_wlan_abm_ipaddr_update_ind_hdlr(void *info)
  1732. {
  1733.     /*----------------------------------------------------------------*/
  1734.     /* Local Variables                                                */
  1735.     /*----------------------------------------------------------------*/
  1736.     mmi_abm_ipaddr_update_ind_struct *ind;
  1737.     /*----------------------------------------------------------------*/
  1738.     /* Code Body                                                      */
  1739.     /*----------------------------------------------------------------*/
  1740.     ind = (mmi_abm_ipaddr_update_ind_struct*) info;
  1741.     memcpy(g_wlan_display_context.curr_ip_addr, ind->ip_addr, 4);
  1742.     memcpy(g_wlan_display_context.curr_netmask, ind->netmask, 4);
  1743.     memcpy(g_wlan_display_context.curr_gateway, ind->gateway, 4);
  1744.     memcpy(g_wlan_display_context.curr_dns1, ind->pri_dns_addr, 4);
  1745.     memcpy(g_wlan_display_context.curr_dns2, ind->sec_dns_addr, 4);
  1746.     if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_CONN_STATUS)
  1747.     {
  1748.         mmi_wlan_redraw_conn_status_screen();
  1749.     }
  1750.     g_wlan_display_context.notification_pending = FALSE;
  1751. }
  1752. /*****************************************************************************
  1753.  * FUNCTION
  1754.  *  mmi_wlan_supc_mmi_wifi_curr_ap_info_ind_hdlr
  1755.  * DESCRIPTION
  1756.  *  
  1757.  * PARAMETERS
  1758.  *  info        [?]     
  1759.  * RETURNS
  1760.  *  void
  1761.  *****************************************************************************/
  1762. void mmi_wlan_supc_mmi_wifi_curr_ap_info_ind_hdlr(void *info)
  1763. {
  1764.     /*----------------------------------------------------------------*/
  1765.     /* Local Variables                                                */
  1766.     /*----------------------------------------------------------------*/
  1767.     supc_mmi_wifi_curr_ap_info_ind_struct *ind;
  1768.     /*----------------------------------------------------------------*/
  1769.     /* Code Body                                                      */
  1770.     /*----------------------------------------------------------------*/
  1771.     ind = (supc_mmi_wifi_curr_ap_info_ind_struct*) info;
  1772.     g_wlan_display_context.rssi = (S32) ind->rssi;
  1773.     g_wlan_display_context.current_data_rate = ind->current_data_rate;
  1774.     if (GetActiveScreenId() == SCR_ID_DTCNT_WLAN_CONN_STATUS)
  1775.     {
  1776.         mmi_wlan_redraw_conn_status_screen();
  1777.     }
  1778.     else if(GetActiveScreenId() == SCR_ID_DTCNT_WLAN_NETWORK_SETTINGS)
  1779.     {
  1780.         mmi_wlan_redraw_network_settings_screen();
  1781.     }
  1782.     mmi_wlan_update_signal_level_icon();
  1783. }
  1784. /*****************************************************************************
  1785.  * FUNCTION
  1786.  *  mmi_wlan_abm_wifi_activate_req_ind_hdlr
  1787.  * DESCRIPTION
  1788.  *  
  1789.  * PARAMETERS
  1790.  *  info        [?]     
  1791.  * RETURNS
  1792.  *  void
  1793.  *****************************************************************************/
  1794. void mmi_wlan_abm_wifi_activate_req_ind_hdlr(void *info)
  1795. {
  1796.     /*----------------------------------------------------------------*/
  1797.     /* Local Variables                                                */
  1798.     /*----------------------------------------------------------------*/
  1799.     MYQUEUE Message;
  1800.     /*----------------------------------------------------------------*/
  1801.     /* Code Body                                                      */
  1802.     /*----------------------------------------------------------------*/
  1803.     if (mmi_bootup_get_active_flight_mode() != 0 || mmi_netset_get_active_preferred_mode() == 0 || g_wlan_display_context.prof_num < 1)
  1804.     {
  1805.         Message.oslSrcId = MOD_MMI;
  1806.         Message.oslDestId = MOD_ABM;
  1807.         Message.oslMsgId = MSG_ID_MMI_ABM_WIFI_ACTIVATE_REQ_REJ;
  1808.         Message.oslDataPtr = NULL;
  1809.         Message.oslPeerBuffPtr = NULL;
  1810.         OslMsgSendExtQueue(&Message);
  1811.         return;
  1812.     }
  1813.     if(g_wlan_display_context.prev_state == WLAN_STATE_NULL)
  1814.     {
  1815.         g_wlan_display_context.init_by_soc = TRUE;
  1816.     }
  1817.     else
  1818.     {
  1819.         g_wlan_display_context.init_by_soc = FALSE;
  1820.     }
  1821.     mmi_wlan_send_connect_req(NULL);
  1822. }
  1823. /*****************************************************************************
  1824.  * FUNCTION
  1825.  *  mmi_wlan_abm_wifi_deactivate_req_ind_hdlr
  1826.  * DESCRIPTION
  1827.  *  
  1828.  * PARAMETERS
  1829.  *  info        [?]     
  1830.  * RETURNS
  1831.  *  void
  1832.  *****************************************************************************/
  1833. void mmi_wlan_abm_wifi_deactivate_req_ind_hdlr(void *info)
  1834. {
  1835.     /*----------------------------------------------------------------*/
  1836.     /* Local Variables                                                */
  1837.     /*----------------------------------------------------------------*/
  1838.     MYQUEUE Message;
  1839.     /*----------------------------------------------------------------*/
  1840.     /* Code Body                                                      */
  1841.     /*----------------------------------------------------------------*/
  1842.     if (mmi_bootup_get_active_flight_mode() != 0 || mmi_netset_get_active_preferred_mode() == 0)
  1843.     {
  1844.         Message.oslSrcId = MOD_MMI;
  1845.         Message.oslDestId = MOD_ABM;
  1846.         Message.oslMsgId = MSG_ID_MMI_ABM_WIFI_DEACTIVATE_REQ_REJ;
  1847.         Message.oslDataPtr = NULL;
  1848.         Message.oslPeerBuffPtr = NULL;
  1849.         OslMsgSendExtQueue(&Message);
  1850.         return;
  1851.     }
  1852.     mmi_wlan_send_disconnect_req();
  1853.     if(g_wlan_display_context.init_by_soc)
  1854.     {
  1855.         mmi_wlan_send_deinit_req();
  1856.     }
  1857. }
  1858. /*****************************************************************************
  1859.  * FUNCTION
  1860.  *  mmi_wlan_reset_hw_on
  1861.  * DESCRIPTION
  1862.  *  
  1863.  * PARAMETERS
  1864.  *  void
  1865.  * RETURNS
  1866.  *  void
  1867.  *****************************************************************************/
  1868. void mmi_wlan_reset_hw_on(FuncPtr callback)
  1869. {
  1870.     /*----------------------------------------------------------------*/
  1871.     /* Local Variables                                                */
  1872.     /*----------------------------------------------------------------*/
  1873.     /*----------------------------------------------------------------*/
  1874.     /* Code Body                                                      */
  1875.     /*----------------------------------------------------------------*/
  1876.     if (g_wlan_setting_context.start_on_bootup == TRUE)
  1877.     {
  1878.         if (g_wlan_display_context.prof_num > 0)
  1879.         {
  1880.             mmi_wlan_send_connect_req(NULL);
  1881.         }
  1882.         else
  1883.         {
  1884.             mmi_wlan_send_init_req();
  1885.         }
  1886.         
  1887.         ASSERT(g_wlan_display_context.app_callback == NULL);
  1888.         if(callback != NULL)
  1889.         {
  1890.             g_wlan_display_context.app_callback = callback;
  1891.         }
  1892.         return;
  1893.     }
  1894.     if(callback != NULL)
  1895.     {
  1896.         callback();
  1897.     }
  1898. }
  1899. /*****************************************************************************
  1900.  * FUNCTION
  1901.  *  mmi_wlan_reset_hw_off
  1902.  * DESCRIPTION
  1903.  *  
  1904.  * PARAMETERS
  1905.  *  void
  1906.  * RETURNS
  1907.  *  void
  1908.  *****************************************************************************/
  1909. void mmi_wlan_reset_hw_off(FuncPtr callback)
  1910. {
  1911.     /*----------------------------------------------------------------*/
  1912.     /* Local Variables                                                */
  1913.     /*----------------------------------------------------------------*/
  1914.     /*----------------------------------------------------------------*/
  1915.     /* Code Body                                                      */
  1916.     /*----------------------------------------------------------------*/
  1917.     if(g_wlan_display_context.state != WLAN_STATE_NULL)
  1918.     {
  1919.         switch (g_wlan_display_context.prev_state)
  1920.         {
  1921.             case WLAN_STATE_INIT:
  1922.                 mmi_wlan_send_deinit_req();
  1923.                 break;
  1924.             case WLAN_STATE_CONNECTED:
  1925.                 mmi_wlan_send_disconnect_req();
  1926.                 mmi_wlan_send_deinit_req();
  1927.                 break;
  1928.         }
  1929.         ASSERT(g_wlan_display_context.app_callback == NULL);
  1930.         if(callback != NULL)
  1931.         {
  1932.             g_wlan_display_context.app_callback = callback;
  1933.         }
  1934.         return;
  1935.     }
  1936.     if(callback != NULL)
  1937.     {
  1938.         callback();
  1939.     }
  1940. }
  1941. /*****************************************************************************
  1942.  * FUNCTION
  1943.  *  mmi_wlan_abm_ipaddr_change_req_hdlr
  1944.  * DESCRIPTION
  1945.  *  send request to query wps state
  1946.  * PARAMETERS
  1947.  *  void
  1948.  * RETURNS
  1949.  *  void
  1950.  *****************************************************************************/
  1951. void mmi_wlan_abm_ipaddr_change_req_hdlr(void)
  1952. {
  1953.     /*----------------------------------------------------------------*/
  1954.     /* Local Variables                                                */
  1955.     /*----------------------------------------------------------------*/
  1956.     MYQUEUE Message;
  1957.     mmi_abm_ipaddr_change_req_struct *p;
  1958.     mmi_wlan_profile_struct *profile;
  1959.     /*----------------------------------------------------------------*/
  1960.     /* Code Body                                                      */
  1961.     /*----------------------------------------------------------------*/
  1962.     if (g_wlan_display_context.state != WLAN_STATE_CONNECTED)
  1963.     {
  1964.         return;
  1965.     }
  1966.     if (g_wlan_display_context.connected_wlan_profile == NULL)
  1967.     {
  1968.         profile = &g_wlan_display_context.temp_profile;
  1969.     }
  1970.     else
  1971.     {
  1972.         profile = g_wlan_display_context.connected_wlan_profile;
  1973.     }
  1974.     g_wlan_display_context.notification_pending = FALSE;
  1975.     p = (mmi_abm_ipaddr_change_req_struct*) OslConstructDataPtr(sizeof(mmi_abm_ipaddr_change_req_struct));
  1976.     /* SetProtocolEventHandler(mmi_wlan_abm_ipaddr_change_cnf_hdlr, MSG_ID_MMI_ABM_IPADDR_CHANGE_CNF); */
  1977.     p->use_dhcp = profile->use_dhcp;
  1978.     memcpy(p->ip_addr, profile->ip_addr, MAX_IPADDRES_LEN);
  1979.     memcpy(p->netmask, profile->netmask, MAX_IPADDRES_LEN);
  1980.     memcpy(p->gateway, profile->gateway, MAX_IPADDRES_LEN);
  1981.     memcpy(p->pri_dns_addr, profile->dns1, MAX_IPADDRES_LEN);
  1982.     memcpy(p->sec_dns_addr, profile->dns2, MAX_IPADDRES_LEN);
  1983.     /* g_wlan_display_context.use_dhcp = profile->use_dhcp; */
  1984.     /* Do not update display IP information if DHCP is TRUE */
  1985.     if(!profile->use_dhcp)
  1986.     {
  1987.         memcpy(g_wlan_display_context.curr_ip_addr, profile->ip_addr, 4);
  1988.         memcpy(g_wlan_display_context.curr_netmask, profile->netmask, 4);
  1989.         memcpy(g_wlan_display_context.curr_gateway, profile->gateway, 4);
  1990.         memcpy(g_wlan_display_context.curr_dns1, profile->dns1, 4);
  1991.         memcpy(g_wlan_display_context.curr_dns2, profile->dns2, 4);
  1992.     }
  1993.     Message.oslSrcId = MOD_MMI;
  1994.     Message.oslDestId = MOD_ABM;
  1995.     Message.oslMsgId = MSG_ID_MMI_ABM_IPADDR_CHANGE_REQ;
  1996.     Message.oslDataPtr = (oslParaType*) p;
  1997.     Message.oslPeerBuffPtr = NULL;
  1998.     OslMsgSendExtQueue(&Message);
  1999. }
  2000. /*****************************************************************************
  2001.  * FUNCTION
  2002.  *  mmi_wlan_abm_ipaddr_conflict_ind_hdlr
  2003.  * DESCRIPTION
  2004.  *  send request to query wps state
  2005.  * PARAMETERS
  2006.  *  info        [?]     
  2007.  * RETURNS
  2008.  *  void
  2009.  *****************************************************************************/
  2010. void mmi_wlan_abm_ipaddr_conflict_ind_hdlr(void *info)
  2011. {
  2012.     /*----------------------------------------------------------------*/
  2013.     /* Local Variables                                                */
  2014.     /*----------------------------------------------------------------*/
  2015.     /*----------------------------------------------------------------*/
  2016.     /* Code Body                                                      */
  2017.     /*----------------------------------------------------------------*/
  2018.     if (g_wlan_display_context.notification_pending == TRUE ||
  2019.         IsScreenPresent(SCR_ID_DTCNT_WLAN_IPADDR_CONFILICT_IND) == TRUE ||
  2020.         GetActiveScreenId() == SCR_ID_DTCNT_WLAN_IPADDR_CONFILICT_IND)
  2021.     {
  2022.         return;
  2023.     }
  2024.     TurnOnBacklight(1);
  2025.     /* Display it in idle screen or display popup otherwise */
  2026.     if (isInCall())
  2027.     {
  2028.         playRequestedTone(WARNING_TONE);
  2029.         g_wlan_display_context.notification_pending = TRUE;
  2030.     }
  2031.     else
  2032.     {
  2033.         mmi_dtcnt_entry_ipaddr_conflict_ind();
  2034.     }
  2035. }
  2036. /*****************************************************************************
  2037.  * FUNCTION
  2038.  *  mmi_wlan_add_event_notify_hdlr
  2039.  * DESCRIPTION
  2040.  *  add event notify callback handler.
  2041.  * PARAMETERS
  2042.  *  info        [?]     
  2043.  * RETURNS
  2044.  *  void
  2045.  *****************************************************************************/
  2046. BOOL mmi_wlan_add_event_notify_hdlr(FuncPtrShort event_callback)
  2047. {
  2048.     /*----------------------------------------------------------------*/
  2049.     /* Local Variables                                                */
  2050.     /*----------------------------------------------------------------*/
  2051.     int i;
  2052.     /*----------------------------------------------------------------*/
  2053.     /* Code Body                                                      */
  2054.     /*----------------------------------------------------------------*/
  2055.     for(i = 0; i < MAX_WLAN_EVENT_REGISTRAR_NUM; i++)
  2056.     {
  2057.         if(g_wlan_display_context.event_callback[i] == NULL)
  2058.         {
  2059.             g_wlan_display_context.event_callback[i] = event_callback;
  2060.             return TRUE;
  2061.         }
  2062.     }
  2063.     return FALSE;
  2064. }
  2065. /*****************************************************************************
  2066.  * FUNCTION
  2067.  *  mmi_wlan_remove_event_notify_hdlr
  2068.  * DESCRIPTION
  2069.  *  remove event notify callback handler.
  2070.  * PARAMETERS
  2071.  *  info        [?]     
  2072.  * RETURNS
  2073.  *  void
  2074.  *****************************************************************************/
  2075. BOOL mmi_wlan_remove_event_notify_hdlr(FuncPtrShort event_callback)
  2076. {
  2077.     /*----------------------------------------------------------------*/
  2078.     /* Local Variables                                                */
  2079.     /*----------------------------------------------------------------*/
  2080.     int i;
  2081.     /*----------------------------------------------------------------*/
  2082.     /* Code Body                                                      */
  2083.     /*----------------------------------------------------------------*/
  2084.     for(i = 0; i < MAX_WLAN_EVENT_REGISTRAR_NUM; i++)
  2085.     {
  2086.         if(g_wlan_display_context.event_callback[i] == event_callback)
  2087.         {
  2088.             g_wlan_display_context.event_callback[i] = NULL;
  2089.             return TRUE;
  2090.         }
  2091.     }
  2092.     return FALSE;
  2093. }
  2094. /*****************************************************************************
  2095.  * FUNCTION
  2096.  *  mmi_wlan_send_event_notify
  2097.  * DESCRIPTION
  2098.  *  dispatch event notofication to callback handler.
  2099.  * PARAMETERS
  2100.  *  info        [?]     
  2101.  * RETURNS
  2102.  *  void
  2103.  *****************************************************************************/
  2104. static void mmi_wlan_send_event_notify(dtcnt_bearer_state_enum state)
  2105. {
  2106.     /*----------------------------------------------------------------*/
  2107.     /* Local Variables                                                */
  2108.     /*----------------------------------------------------------------*/
  2109.     int i;
  2110.     /*----------------------------------------------------------------*/
  2111.     /* Code Body                                                      */
  2112.     /*----------------------------------------------------------------*/
  2113.     for(i = 0; i < MAX_WLAN_EVENT_REGISTRAR_NUM; i++)
  2114.     {
  2115.         if(g_wlan_display_context.event_callback[i] != NULL)
  2116.         {
  2117.             g_wlan_display_context.event_callback[i]((U16)state);
  2118.         }
  2119.     }
  2120. }
  2121. #endif /* __MMI_WLAN_FEATURES__ */