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

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.  *  Modification Notice:
  37.  *  --------------------------
  38.  *  This software is modified by MediaTek Inc. and the information contained
  39.  *  herein is confidential. The software may not be copied and the information
  40.  *  contained herein may not be used or disclosed except with the written
  41.  *  permission of MediaTek Inc. (C) 2001
  42.  *
  43.  *******************************************************************************/
  44.  /*******************************************************************************
  45.  * Filename:
  46.  * ---------
  47.  *   TextPhoneControl.c
  48.  *
  49.  * Project:
  50.  * --------
  51.  *   Maui_Software
  52.  *
  53.  * Description:
  54.  * ------------
  55.  *  .......
  56.  *
  57.  * Author:
  58.  * -------
  59.  * -------
  60.  *
  61.  *------------------------------------------------------------------------------
  62.  * $Log$
  63.  *
  64.  * removed!
  65.  * removed!
  66.  * 
  67.  *
  68.  * removed!
  69.  * removed!
  70.  * 
  71.  *
  72.  * removed!
  73.  * removed!
  74.  * 
  75.  *
  76.  * removed!
  77.  * removed!
  78.  * 
  79.  *
  80.  * removed!
  81.  * removed!
  82.  * 
  83.  *
  84.  * removed!
  85.  * removed!
  86.  * 
  87.  *
  88.  * removed!
  89.  * removed!
  90.  * 
  91.  *
  92.  * removed!
  93.  * removed!
  94.  * 
  95.  *
  96.  * removed!
  97.  * removed!
  98.  * 
  99.  *
  100.  * removed!
  101.  * removed!
  102.  * 
  103.  *
  104.  * removed!
  105.  * removed!
  106.  * 
  107.  *
  108.  * removed!
  109.  * removed!
  110.  * 
  111.  *
  112.  * removed!
  113.  * removed!
  114.  * 
  115.  *
  116.  * removed!
  117.  * removed!
  118.  * 
  119.  *
  120.  * removed!
  121.  * removed!
  122.  * 
  123.  *
  124.  * removed!
  125.  * removed!
  126.  * 
  127.  *
  128.  * removed!
  129.  * removed!
  130.  * 
  131.  *
  132.  * removed!
  133.  * removed!
  134.  * 
  135.  *
  136.  * removed!
  137.  * removed!
  138.  * 
  139.  *
  140.  *******************************************************************************/
  141. #ifdef __CTM_SUPPORT__
  142. // #define __CTM_DEBUG
  143. #include "stdC.h"
  144. #include "MMI_Features.h"
  145. #include "L4Dr.h"
  146. #include "L4Dr1.h"
  147. #include "TimerEvents.h"
  148. #include "PixtelDataTypes.h"
  149. #include "DebugInitDef.h"
  150. #include "EventsGprot.h"
  151. #include "GlobalDefs.h"
  152. #include "GlobalConstants.h"
  153. #include "GlobalMenuItems.h"
  154. #include "QueueGprot.h"
  155. #include "HistoryGprot.h"
  156. #include "CommonScreens.h"
  157. #include "NVRAMEnum.h"
  158. #include "NVRAMType.h"
  159. #include "NVRAMProt.h"
  160. #include "wgui_categories.h"
  161. #include "wgui_categories_util.h"
  162. #include "wgui_categories_inputs.h"
  163. #include "wgui_status_icons.h"
  164. #include "wgui_tab_bars.h"
  165. #include "wgui_categories_IMPS.h"
  166. #include "gpioInc.h"
  167. #include "SettingProfile.h"
  168. #include "CallManagementIDDef.h"
  169. #include "CallManagementStruct.h"
  170. #include "OutgoingCallHelperProt.h"
  171. #include "OutgoingCallManagementProt.h"
  172. #include "TextPhoneDef.h"
  173. #include "TextPhoneProt.h"
  174. static mmi_ctm_context_struct g_ctm_cntxt;
  175. mmi_ctm_context_struct *ctm_p = &g_ctm_cntxt;
  176. /*****************************************************************************
  177.  * FUNCTION
  178.  *  mmi_init_ctm_call
  179.  * DESCRIPTION
  180.  *  To Initialize the CTM Call application
  181.  *  
  182.  *  This function sets up the handlers required for event flow and
  183.  *  application management
  184.  * PARAMETERS
  185.  *  void
  186.  * RETURNS
  187.  *  void
  188.  *****************************************************************************/
  189. void mmi_init_ctm_call(void)
  190. {
  191.     /*----------------------------------------------------------------*/
  192.     /* Local Variables                                                */
  193.     /*----------------------------------------------------------------*/
  194.     S16 error;
  195.     /*----------------------------------------------------------------*/
  196.     /* Code Body                                                      */
  197.     /*----------------------------------------------------------------*/
  198.     memset(ctm_p, 0, sizeof(mmi_ctm_context_struct));
  199.     ReadValue(NVRAM_CTM_MODE, &ctm_p->status, DS_BYTE, &error);
  200.     ReadValue(NVRAM_CTM_SETTING, &ctm_p->mode_setting, DS_BYTE, &error);
  201.     if (ctm_p->status == 0xff)
  202.     {
  203.         ctm_p->status = FALSE;
  204.     }
  205.     if (ctm_p->mode_setting == 0xff)
  206.     {
  207.         ctm_p->mode_setting = MMI_CTM_SETTING_MANUAL_DIRECT;
  208.     }
  209.     mmi_ctm_send_get_default_req();
  210.     SetHiliteHandler(MITEM_CTM_MENU, highlight_ctm_main);
  211.     SetHiliteHandler(MITEM_CTM_MODE, highlight_ctm_mode);
  212.     SetHiliteHandler(MITEM_CTM_SETTING, highlight_ctm_setting);
  213.     SetHiliteHandler(MITEM_CTM_EDITOR_DONE, highlight_ctm_edit_done);
  214.     SetHiliteHandler(MITEM_CTM_INPUT_METHOD, highlight_ctm_input_method);
  215.     SetHintHandler(MITEM_CTM_MODE, hint_ctm_mode);
  216.     SetProtocolEventHandler(mmi_ctm_get_default_rsp_hdlr, MSG_ID_MMI_CTM_DEFAULT_CHANGED_IND);
  217.     SetProtocolEventHandler(mmi_ctm_connect_ind_hdlr, MSG_ID_MMI_CTM_CONNECTED_IND);
  218.     SetProtocolEventHandler(mmi_ctm_recv_text_ind_hdlr, MSG_ID_MMI_CTM_RECV_TEXT_IND);
  219.     /* SetProtocolEventHandler (mmi_ctm_tty_plug_ind_hdlr, MSG_ID_MMI_CTM_TTY_PLUG_IND); */
  220. }
  221. /*****************************************************************************
  222.  * FUNCTION
  223.  *  mmi_ctm_get_state
  224.  * DESCRIPTION
  225.  *  
  226.  * PARAMETERS
  227.  *  void
  228.  *  void(?)     [IN]        *
  229.  * RETURNS
  230.  *  void
  231.  *****************************************************************************/
  232. U8 mmi_ctm_get_state(void)
  233. {
  234.     /*----------------------------------------------------------------*/
  235.     /* Local Variables                                                */
  236.     /*----------------------------------------------------------------*/
  237.     /*----------------------------------------------------------------*/
  238.     /* Code Body                                                      */
  239.     /*----------------------------------------------------------------*/
  240.     return (U8) ctm_p->state;
  241. }
  242. /*****************************************************************************
  243.  * FUNCTION
  244.  *  mmi_ctm_set_state
  245.  * DESCRIPTION
  246.  *  
  247.  * PARAMETERS
  248.  *  state       [IN]        
  249.  *  void(?)     [IN]        *
  250.  * RETURNS
  251.  *  void
  252.  *****************************************************************************/
  253. void mmi_ctm_set_state(U8 state)
  254. {
  255.     /*----------------------------------------------------------------*/
  256.     /* Local Variables                                                */
  257.     /*----------------------------------------------------------------*/
  258.     /*----------------------------------------------------------------*/
  259.     /* Code Body                                                      */
  260.     /*----------------------------------------------------------------*/
  261.     PRINT_INFORMATION(("n SET CTM STATE:%d n", state));
  262.     ctm_p->state = state;
  263. }
  264. /*****************************************************************************
  265.  * FUNCTION
  266.  *  mmi_ctm_reset_buffer
  267.  * DESCRIPTION
  268.  *  
  269.  * PARAMETERS
  270.  *  void
  271.  *  void(?)     [IN]        *
  272.  * RETURNS
  273.  *  void
  274.  *****************************************************************************/
  275. void mmi_ctm_reset_buffer(void)
  276. {
  277.     /*----------------------------------------------------------------*/
  278.     /* Local Variables                                                */
  279.     /*----------------------------------------------------------------*/
  280.     /*----------------------------------------------------------------*/
  281.     /* Code Body                                                      */
  282.     /*----------------------------------------------------------------*/
  283.     memset(ctm_p->remote_buffer, 0, MAX_CTM_DATA_BUFFER_LEN);
  284.     memset(ctm_p->local_buffer, 0, MAX_CTM_DATA_BUFFER_LEN);
  285.     memset(ctm_p->pending_buffer, 0, MAX_CTM_EDITOR_BUFFER_LEN);
  286.     memset(ctm_p->editor_buffer, 0, MAX_CTM_EDITOR_BUFFER_LEN);
  287.     ctm_p->remote_len = 0;
  288.     ctm_p->local_len = 0;
  289.     ctm_p->pending_len = 0;
  290.     ctm_p->sent_len = 0;
  291. }
  292. /*****************************************************************************
  293.  * FUNCTION
  294.  *  highlight_ctm_main
  295.  * DESCRIPTION
  296.  *  
  297.  * PARAMETERS
  298.  *  void
  299.  *  void(?)     [IN]        *
  300.  * RETURNS
  301.  *  void
  302.  *****************************************************************************/
  303. void highlight_ctm_main(void)
  304. {
  305.     /*----------------------------------------------------------------*/
  306.     /* Local Variables                                                */
  307.     /*----------------------------------------------------------------*/
  308.     /*----------------------------------------------------------------*/
  309.     /* Code Body                                                      */
  310.     /*----------------------------------------------------------------*/
  311.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  312.     SetLeftSoftkeyFunction(entry_ctm_menu, KEY_EVENT_UP);
  313.     SetKeyHandler(entry_ctm_menu, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  314.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  315. }
  316. /*****************************************************************************
  317.  * FUNCTION
  318.  *  highlight_ctm_mode
  319.  * DESCRIPTION
  320.  *  
  321.  * PARAMETERS
  322.  *  void
  323.  *  void(?)     [IN]        *
  324.  * RETURNS
  325.  *  void
  326.  *****************************************************************************/
  327. void highlight_ctm_mode(void)
  328. {
  329.     /*----------------------------------------------------------------*/
  330.     /* Local Variables                                                */
  331.     /*----------------------------------------------------------------*/
  332.     /*----------------------------------------------------------------*/
  333.     /* Code Body                                                      */
  334.     /*----------------------------------------------------------------*/
  335.     if (ctm_p->status == TRUE)
  336.     {
  337.         ChangeLeftSoftkey(STR_GLOBAL_OFF, 0);
  338.     }
  339.     else
  340.     {
  341.         ChangeLeftSoftkey(STR_GLOBAL_ON, 0);
  342.     }
  343.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  344.     SetLeftSoftkeyFunction(mmi_ctm_toggle_mode, KEY_EVENT_UP);
  345. }
  346. /*****************************************************************************
  347.  * FUNCTION
  348.  *  highlight_ctm_setting
  349.  * DESCRIPTION
  350.  *  
  351.  * PARAMETERS
  352.  *  void
  353.  *  void(?)     [IN]        *
  354.  * RETURNS
  355.  *  void
  356.  *****************************************************************************/
  357. void highlight_ctm_setting(void)
  358. {
  359.     /*----------------------------------------------------------------*/
  360.     /* Local Variables                                                */
  361.     /*----------------------------------------------------------------*/
  362.     /*----------------------------------------------------------------*/
  363.     /* Code Body                                                      */
  364.     /*----------------------------------------------------------------*/
  365.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  366.     SetLeftSoftkeyFunction(entry_ctm_setting_selection, KEY_EVENT_UP);
  367.     SetKeyHandler(entry_ctm_setting_selection, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  368. }
  369. /*****************************************************************************
  370.  * FUNCTION
  371.  *  highlight_ctm_setting_items
  372.  * DESCRIPTION
  373.  *  
  374.  * PARAMETERS
  375.  *  index       [IN]        
  376.  *  void(?)     [IN]        *
  377.  * RETURNS
  378.  *  void
  379.  *****************************************************************************/
  380. void highlight_ctm_setting_items(S32 index)
  381. {
  382.     /*----------------------------------------------------------------*/
  383.     /* Local Variables                                                */
  384.     /*----------------------------------------------------------------*/
  385.     /*----------------------------------------------------------------*/
  386.     /* Code Body                                                      */
  387.     /*----------------------------------------------------------------*/
  388.     ctm_p->index = index;
  389. }
  390. /*****************************************************************************
  391.  * FUNCTION
  392.  *  highlight_ctm_edit_done
  393.  * DESCRIPTION
  394.  *  highlight handler for change input method in editor option
  395.  * PARAMETERS
  396.  *  void
  397.  * RETURNS
  398.  *  void
  399.  *****************************************************************************/
  400. void highlight_ctm_edit_done(void)
  401. {
  402.     /*----------------------------------------------------------------*/
  403.     /* Local Variables                                                */
  404.     /*----------------------------------------------------------------*/
  405.     /*----------------------------------------------------------------*/
  406.     /* Code Body                                                      */
  407.     /*----------------------------------------------------------------*/
  408.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  409.     SetLeftSoftkeyFunction(mmi_ctm_edit_done, KEY_EVENT_UP);
  410. }
  411. /*****************************************************************************
  412.  * FUNCTION
  413.  *  highlight_ctm_input_method
  414.  * DESCRIPTION
  415.  *  highlight handler for change input method in editor option
  416.  * PARAMETERS
  417.  *  void
  418.  * RETURNS
  419.  *  void
  420.  *****************************************************************************/
  421. void highlight_ctm_input_method(void)
  422. {
  423.     /*----------------------------------------------------------------*/
  424.     /* Local Variables                                                */
  425.     /*----------------------------------------------------------------*/
  426.     /*----------------------------------------------------------------*/
  427.     /* Code Body                                                      */
  428.     /*----------------------------------------------------------------*/
  429.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  430.     SetLeftSoftkeyFunction(EntryInputMethodScreen, KEY_EVENT_UP);
  431. }
  432. /*****************************************************************************
  433.  * FUNCTION
  434.  *  hint_ctm_mode
  435.  * DESCRIPTION
  436.  *  hint
  437.  * PARAMETERS
  438.  *  index       [IN]        
  439.  * RETURNS
  440.  *  void
  441.  *****************************************************************************/
  442. void hint_ctm_mode(U16 index)
  443. {
  444.     /*----------------------------------------------------------------*/
  445.     /* Local Variables                                                */
  446.     /*----------------------------------------------------------------*/
  447.     /*----------------------------------------------------------------*/
  448.     /* Code Body                                                      */
  449.     /*----------------------------------------------------------------*/
  450.     if (ctm_p->status == TRUE)
  451.     {
  452.         pfnUnicodeStrcpy((S8*) hintData[index], (S8*) GetString(STR_GLOBAL_ON));
  453.     }
  454.     else
  455.     {
  456.         pfnUnicodeStrcpy((S8*) hintData[index], (S8*) GetString(STR_GLOBAL_OFF));
  457.     }
  458.     return;
  459. }
  460. /*****************************************************************************
  461.  * FUNCTION
  462.  *  mmi_ctm_set_default_rsp_hdlr
  463.  * DESCRIPTION
  464.  *  
  465.  * PARAMETERS
  466.  *  info        [?]     
  467.  * RETURNS
  468.  *  void
  469.  *****************************************************************************/
  470. void mmi_ctm_set_default_rsp_hdlr(void *info)
  471. {
  472.     /*----------------------------------------------------------------*/
  473.     /* Local Variables                                                */
  474.     /*----------------------------------------------------------------*/
  475.     pBOOL result = TRUE;
  476. #ifndef __CTM_DEBUG
  477.     mmi_ctm_set_default_rsp_struct *rsp;
  478.     /*----------------------------------------------------------------*/
  479.     /* Code Body                                                      */
  480.     /*----------------------------------------------------------------*/
  481.     rsp = (mmi_ctm_set_default_rsp_struct*) info;
  482.     result = rsp->result;
  483. #endif /* __CTM_DEBUG */ 
  484.     PRINT_INFORMATION(("n CTM SET DEFAULT RSP n"));
  485.     if (result == TRUE)
  486.     {
  487.     }
  488.     else
  489.     {
  490.     }
  491. }
  492. /*****************************************************************************
  493.  * FUNCTION
  494.  *  mmi_ctm_get_default_rsp_hdlr
  495.  * DESCRIPTION
  496.  *  
  497.  * PARAMETERS
  498.  *  info        [?]     
  499.  * RETURNS
  500.  *  void
  501.  *****************************************************************************/
  502. void mmi_ctm_get_default_rsp_hdlr(void *info)
  503. {
  504.     /*----------------------------------------------------------------*/
  505.     /* Local Variables                                                */
  506.     /*----------------------------------------------------------------*/
  507.     pBOOL result = TRUE;
  508.     pBOOL on_off = TRUE;
  509.     U8 mode = CTM_DIRECT_MODE;
  510.     U8 mmi_mode;
  511. #ifndef __CTM_DEBUG
  512.     mmi_ctm_get_default_rsp_struct *rsp;
  513.     /*----------------------------------------------------------------*/
  514.     /* Code Body                                                      */
  515.     /*----------------------------------------------------------------*/
  516.     rsp = (mmi_ctm_get_default_rsp_struct*) info;
  517.     result = rsp->result;
  518.     on_off = rsp->is_turn_on;
  519.     mode = rsp->ctm_interface;
  520. #endif /* __CTM_DEBUG */ 
  521.     PRINT_INFORMATION(("n CTM GET DEFAULT RSP n"));
  522.     if (result == TRUE)
  523.     {
  524.         S16 error;
  525.         if (ctm_p->status != on_off)
  526.         {
  527.             ctm_p->status = on_off;
  528.             WriteValue(NVRAM_CTM_MODE, &ctm_p->status, DS_BYTE, &error);
  529.         }
  530.         switch (mode)
  531.         {
  532.             case CTM_BAUDOT_MODE:
  533.                 mmi_mode = MMI_CTM_SETTING_BAUDOT;
  534.                 break;
  535.             case CTM_HCO_MODE:
  536.                 mmi_mode = MMI_CTM_SETTING_HCO;
  537.                 break;
  538.             case CTM_VCO_MODE:
  539.                 mmi_mode = MMI_CTM_SETTING_VCO;
  540.                 break;
  541.             case CTM_DIRECT_MODE:
  542.                 /* MMI mode_setting should be auto or manual direct */
  543.                 if (ctm_p->mode_setting != MMI_CTM_SETTING_MANUAL_DIRECT &&
  544.                     ctm_p->mode_setting != MMI_CTM_SETTING_AUTO_DIRECT)
  545.                 {
  546.                     mmi_mode = MMI_CTM_SETTING_MANUAL_DIRECT;
  547.                 }
  548.                 else
  549.                 {
  550.                     mmi_mode = ctm_p->mode_setting;
  551.                 }
  552.                 break;
  553.             default:
  554.                 ASSERT(0);
  555.                 break;
  556.         }
  557.         /* MMI mode setting should be the same as L4 mode */
  558.         if (mmi_mode != ctm_p->mode_setting)
  559.         {
  560.             ctm_p->mode_setting = mmi_mode;
  561.             WriteValue(NVRAM_CTM_SETTING, &ctm_p->mode_setting, DS_BYTE, &error);
  562.         }
  563.         if (ctm_p->status == TRUE)
  564.         {
  565.             ShowStatusIcon(STATUS_ICON_TTY_INDICATOR);
  566.             /* only hide earphone when it's real tty, 
  567.                direct mode still take as earphone */
  568.             if (ctm_p->mode_setting < MMI_CTM_SETTING_MANUAL_DIRECT)
  569.             HideStatusIcon(STATUS_ICON_EARPHONE_INDICATOR);
  570.         }
  571.         else
  572.         {
  573.             HideStatusIcon(STATUS_ICON_TTY_INDICATOR);
  574.         }
  575.         UpdateStatusIcons();
  576.     }
  577.     //else
  578.     //ASSERT(0);
  579. }
  580. /*****************************************************************************
  581.  * FUNCTION
  582.  *  mmi_ctm_open_rsp_hdlr
  583.  * DESCRIPTION
  584.  *  
  585.  * PARAMETERS
  586.  *  info        [?]     
  587.  * RETURNS
  588.  *  void
  589.  *****************************************************************************/
  590. void mmi_ctm_open_rsp_hdlr(void *info)
  591. {
  592.     /*----------------------------------------------------------------*/
  593.     /* Local Variables                                                */
  594.     /*----------------------------------------------------------------*/
  595.     pBOOL result = TRUE;
  596.     U8 ctm_interface = CTM_DIRECT_MODE;
  597. #ifndef __CTM_DEBUG
  598.     mmi_ctm_open_rsp_struct *rsp;
  599.     /*----------------------------------------------------------------*/
  600.     /* Code Body                                                      */
  601.     /*----------------------------------------------------------------*/
  602.     rsp = (mmi_ctm_open_rsp_struct*) info;
  603.     result = rsp->result;
  604.     ctm_interface = rsp->ctm_interface;
  605. #endif /* __CTM_DEBUG */ 
  606.     PRINT_INFORMATION(("n CTM OPEN RSP n"));
  607.     if (ctm_p->state == MMI_CTM_STATE_OPENING)
  608.     {
  609.         if (result == TRUE)
  610.         {
  611.             /* open OK */
  612.             mmi_ctm_set_state(MMI_CTM_STATE_OPENED);
  613.             ctm_p->mode_activated = ctm_interface;
  614.         }
  615.         else
  616.         {
  617.             mmi_ctm_set_state(MMI_CTM_STATE_IDLE);
  618.         }
  619.         {
  620.             S8 mode = 0xff;
  621.             /* open fail */
  622.             if (ctm_p->tty_status == TRUE)
  623.             {
  624.                 /* with TTY, open as TTY */
  625.                 switch (ctm_p->mode_setting)
  626.                 {
  627.                     case MMI_CTM_SETTING_HCO:
  628.                         mode = CTM_HCO_MODE;
  629.                         break;
  630.                     case MMI_CTM_SETTING_VCO:
  631.                         mode = CTM_VCO_MODE;
  632.                         break;
  633.                     case MMI_CTM_SETTING_BAUDOT:
  634.                         mode = CTM_BAUDOT_MODE;
  635.                         break;
  636.                     default:
  637.                  /* CTM ON, earphone in, direct mode => keep open as direct mode, take it as earphone */
  638.                  mode = CTM_DIRECT_MODE;
  639.                         break;
  640.                 }
  641.             }
  642.             else
  643.             {
  644.                 switch (ctm_p->mode_setting)
  645.                 {
  646.                     case MMI_CTM_SETTING_AUTO_DIRECT:
  647.                     case MMI_CTM_SETTING_MANUAL_DIRECT:
  648.                         /* no TTY, open as direct */
  649.                         mode = CTM_DIRECT_MODE;
  650.                         break;
  651.                     default:
  652.                         break;
  653.                 }
  654.             }
  655.             ASSERT(ctm_p->mode_setting <= MMI_CTM_SETTING_AUTO_DIRECT);
  656.             if (mode != 0xff && mode != ctm_interface)
  657.             {
  658.                 mmi_ctm_set_state(MMI_CTM_STATE_OPENING);
  659.                 mmi_ctm_send_open_req(mode);
  660.                 return;
  661.             }
  662.         }
  663.     }
  664. }
  665. /*****************************************************************************
  666.  * FUNCTION
  667.  *  mmi_ctm_close_rsp_hdlr
  668.  * DESCRIPTION
  669.  *  
  670.  * PARAMETERS
  671.  *  info        [?]     
  672.  * RETURNS
  673.  *  void
  674.  *****************************************************************************/
  675. void mmi_ctm_close_rsp_hdlr(void *info)
  676. {
  677.     /*----------------------------------------------------------------*/
  678.     /* Local Variables                                                */
  679.     /*----------------------------------------------------------------*/
  680.     /*----------------------------------------------------------------*/
  681.     /* Code Body                                                      */
  682.     /*----------------------------------------------------------------*/
  683.     PRINT_INFORMATION(("n CTM CLOSE RSPn"));
  684.     if (ctm_p->state == MMI_CTM_STATE_CLOSING)
  685.     {
  686.         mmi_ctm_set_state(MMI_CTM_STATE_IDLE);
  687.     }
  688. }
  689. /*****************************************************************************
  690.  * FUNCTION
  691.  *  mmi_ctm_connect_rsp_hdlr
  692.  * DESCRIPTION
  693.  *  
  694.  * PARAMETERS
  695.  *  info        [?]     
  696.  * RETURNS
  697.  *  void
  698.  *****************************************************************************/
  699. void mmi_ctm_connect_rsp_hdlr(void *info)
  700. {
  701.     /*----------------------------------------------------------------*/
  702.     /* Local Variables                                                */
  703.     /*----------------------------------------------------------------*/
  704.     pBOOL result = TRUE;
  705. #ifndef __CTM_DEBUG
  706.     mmi_ctm_connect_rsp_struct *rsp;
  707.     /*----------------------------------------------------------------*/
  708.     /* Code Body                                                      */
  709.     /*----------------------------------------------------------------*/
  710.     rsp = (mmi_ctm_connect_rsp_struct*) info;
  711.     result = rsp->result;
  712. #endif /* __CTM_DEBUG */ 
  713.     PRINT_INFORMATION(("n CTM CONNECT RSPn"));
  714.     if (ctm_p->state == MMI_CTM_STATE_CONNECTING)
  715.     {
  716.         if (result == TRUE)
  717.         {
  718.             /* connect OK */
  719.             mmi_ctm_set_state(MMI_CTM_STATE_CONNECTED);
  720.             mmi_ctm_reset_buffer();
  721.             /* enter chat screen */
  722.             if (GetExitScrnID() == SCR_CTM_CONNECTING ||
  723.              GetExitScrnID() == SCR_CM_ACTIVECALLSCREEN)
  724.             {
  725.                 entry_ctm_talking();
  726.                 DeleteScreenIfPresent(SCR_CM_ACTIVECALLSCREEN);
  727.             }
  728.         }
  729.         else
  730.         {
  731.             /* connect fail */
  732.             mmi_ctm_set_state(MMI_CTM_STATE_OPENED);
  733.             DisplayPopup((PU8) GetString(STR_GLOBAL_UNFINISHED), IMG_GLOBAL_ERROR, 0, 2000, ERROR_TONE);
  734.         }
  735.     }
  736. #ifdef __CTM_DEBUG
  737.     StartTimer(CM_NOTIFYDURATION_TIMER, 2000, (FuncPtr) mmi_ctm_recv_text_ind_hdlr);
  738. #endif 
  739.     DeleteScreenIfPresent(SCR_CTM_CONNECTING);
  740. }
  741. /*****************************************************************************
  742.  * FUNCTION
  743.  *  mmi_ctm_connect_ind_hdlr
  744.  * DESCRIPTION
  745.  *  
  746.  * PARAMETERS
  747.  *  info        [?]     
  748.  * RETURNS
  749.  *  void
  750.  *****************************************************************************/
  751. void mmi_ctm_connect_ind_hdlr(void *info)
  752. {
  753.     /*----------------------------------------------------------------*/
  754.     /* Local Variables                                                */
  755.     /*----------------------------------------------------------------*/
  756.     /*----------------------------------------------------------------*/
  757.     /* Code Body                                                      */
  758.     /*----------------------------------------------------------------*/
  759.     if (ctm_p->state == MMI_CTM_STATE_OPENED || ctm_p->state == MMI_CTM_STATE_CONNECTING)
  760.     {
  761.         mmi_ctm_set_state(MMI_CTM_STATE_CONNECTED);
  762.         mmi_ctm_reset_buffer();
  763.     }
  764.     /* enter chat screen */
  765.     if (GetExitScrnID() == SCR_CM_ACTIVECALLSCREEN)
  766.     {
  767.         entry_ctm_talking();
  768.         DeleteScreenIfPresent(SCR_CM_ACTIVECALLSCREEN);
  769.     }
  770. }
  771. /*****************************************************************************
  772.  * FUNCTION
  773.  *  mmi_ctm_send_text_rsp_hdlr
  774.  * DESCRIPTION
  775.  *  
  776.  * PARAMETERS
  777.  *  info        [?]     
  778.  * RETURNS
  779.  *  void
  780.  *****************************************************************************/
  781. void mmi_ctm_send_text_rsp_hdlr(void *info)
  782. {
  783.     /*----------------------------------------------------------------*/
  784.     /* Local Variables                                                */
  785.     /*----------------------------------------------------------------*/
  786.     pBOOL result = TRUE;
  787.     U16 finished_len;
  788. #ifndef __CTM_DEBUG
  789.     mmi_ctm_send_text_rsp_struct *rsp;
  790.     /*----------------------------------------------------------------*/
  791.     /* Code Body                                                      */
  792.     /*----------------------------------------------------------------*/
  793.     rsp = (mmi_ctm_send_text_rsp_struct*) info;
  794.     result = rsp->result;
  795. #endif /* __CTM_DEBUG */ 
  796.     PRINT_INFORMATION(("n CTM SEND TEXT RSPn"));
  797.     finished_len = ctm_p->sent_len;
  798.     ctm_p->sent_len = 0;
  799.     if (result == TRUE)
  800.     {
  801.         if (MAX_CTM_DATA_COUNT - ctm_p->local_len > finished_len)
  802.         {
  803.             ctm_p->local_len += finished_len;
  804.             pfnUnicodeStrncat((PS8) ctm_p->local_buffer, (PS8) ctm_p->pending_buffer, finished_len);
  805.         }
  806.         else
  807.         {
  808.             memset(ctm_p->local_buffer, 0, MAX_CTM_DATA_BUFFER_LEN);
  809.             ctm_p->local_len = finished_len;
  810.             pfnUnicodeStrncpy((PS8) ctm_p->local_buffer, (PS8) ctm_p->pending_buffer, finished_len);
  811.         }
  812.         ctm_p->pending_len -= finished_len;
  813.         if (ctm_p->pending_len > 0)
  814.         {
  815.             pfnUnicodeStrcpy((PS8) ctm_p->pending_buffer, (PS8) & ctm_p->pending_buffer[finished_len << 1]);
  816.         }
  817.         else
  818.         {
  819.             memset(ctm_p->pending_buffer, 0, MAX_CTM_EDITOR_BUFFER_LEN);
  820.         }
  821.         if (finished_len > 0)
  822.         {
  823.             UpdateCategory430LSK(STR_GLOBAL_EDIT, 0);
  824.         }
  825.         if (GetExitScrnID() == SCR_CTM_TALKING)
  826.         {
  827.             if (ctm_p->pending_len == 0)
  828.             {
  829.                 ConfigureCategory430SendingBox(FALSE, 0);
  830.             }
  831.             else
  832.             {
  833.                 ConfigureCategory430SendingBox(TRUE, 0);
  834.             }
  835.         }
  836.     }
  837.     if (ctm_p->pending_len > 0)
  838.     {
  839.         mmi_ctm_send_text_req((PS8) ctm_p->pending_buffer, ctm_p->pending_len);
  840.     }
  841. }
  842. /*****************************************************************************
  843.  * FUNCTION
  844.  *  mmi_ctm_recv_text_ind_hdlr
  845.  * DESCRIPTION
  846.  *  
  847.  * PARAMETERS
  848.  *  info        [?]     
  849.  * RETURNS
  850.  *  void
  851.  *****************************************************************************/
  852. void mmi_ctm_recv_text_ind_hdlr(void *info)
  853. {
  854.     /*----------------------------------------------------------------*/
  855.     /* Local Variables                                                */
  856.     /*----------------------------------------------------------------*/
  857.     U16 space, len;
  858.     PU16 text;
  859. #ifdef __CTM_DEBUG
  860.     U16 temp[] = L"abc12345defn";
  861.     /*----------------------------------------------------------------*/
  862.     /* Code Body                                                      */
  863.     /*----------------------------------------------------------------*/
  864.     len = 12;
  865.     text = temp;
  866. #else /* __CTM_DEBUG */ 
  867.     mmi_ctm_recv_text_ind_struct *ind;
  868.     ind = (mmi_ctm_recv_text_ind_struct*) info;
  869.     len = ind->num_of_char;
  870.     text = ind->text;
  871. #endif /* __CTM_DEBUG */ 
  872.     PRINT_INFORMATION(("n CTM RECV TEXT INDn"));
  873.     len = mmi_skip_unicode_char(text, len, 0x0008);
  874.     space = MAX_CTM_DATA_COUNT - ctm_p->remote_len;
  875.     if (space > len)
  876.     {
  877.         ctm_p->remote_len += len;
  878.         pfnUnicodeStrcat((PS8) ctm_p->remote_buffer, (PS8) text);
  879.     }
  880.     else
  881.     {
  882.         ctm_p->remote_len = len;
  883.         pfnUnicodeStrcpy((PS8) ctm_p->remote_buffer, (PS8) text);
  884.     }
  885.     if (GetExitScrnID() == SCR_CTM_TALKING)
  886.     {
  887.         UpdateCategory430LogBox(TRUE, FALSE);
  888.     }
  889. #ifdef __CTM_DEBUG
  890.     StartTimer(CM_AUTOANSWER_NOTIFYDURATION_TIMER, 2000, (FuncPtr) mmi_ctm_recv_text_ind_hdlr);
  891. #endif 
  892. }
  893. /*****************************************************************************
  894.  * FUNCTION
  895.  *  mmi_ctm_tty_plug_ind_hdlr
  896.  * DESCRIPTION
  897.  *  
  898.  * PARAMETERS
  899.  *  info        [?]     
  900.  * RETURNS
  901.  *  void
  902.  *****************************************************************************/
  903. void mmi_ctm_tty_plug_ind_hdlr(void *info)
  904. {
  905.     /*----------------------------------------------------------------*/
  906.     /* Local Variables                                                */
  907.     /*----------------------------------------------------------------*/
  908.     mmi_ctm_tty_plug_ind_struct *ind;
  909.     /*----------------------------------------------------------------*/
  910.     /* Code Body                                                      */
  911.     /*----------------------------------------------------------------*/
  912.     ind = (mmi_ctm_tty_plug_ind_struct*) info;
  913.     /* ctm_p->tty_status = ind->is_plug_in; */
  914.     mmi_ctm_switch_tty_status(ind->is_plug_in);
  915. }
  916. /*****************************************************************************
  917.  * FUNCTION
  918.  *  mmi_ctm_switch_tty_status
  919.  * DESCRIPTION
  920.  *  
  921.  * PARAMETERS
  922.  *  is_present      [IN]        
  923.  *  void(?)         [IN]        *
  924.  * RETURNS
  925.  *  void
  926.  *****************************************************************************/
  927. void mmi_ctm_switch_tty_status(pBOOL is_present)
  928. {
  929.     /*----------------------------------------------------------------*/
  930.     /* Local Variables                                                */
  931.     /*----------------------------------------------------------------*/
  932.     /*----------------------------------------------------------------*/
  933.     /* Code Body                                                      */
  934.     /*----------------------------------------------------------------*/
  935.     if (is_present)
  936.     {
  937.         /* plug in */
  938.         if (mmi_ctm_get_mode())
  939.         {
  940.             /* CTM on, take as TTY */
  941.             ctm_p->tty_status = TRUE;
  942.             if ((ctm_p->state != MMI_CTM_STATE_IDLE &&
  943.                  ctm_p->mode_activated == CTM_DIRECT_MODE) ||
  944.                 (ctm_p->state == MMI_CTM_STATE_IDLE && GetTotalActiveCallCount() + GetTotalHoldCallCount() >= 1))
  945.             {
  946.                 S8 mode = 0xff;
  947.                 /* plug in, open again */
  948.                 if (ctm_p->state != MMI_CTM_STATE_IDLE)
  949.                 {
  950.                     mmi_ctm_set_state(MMI_CTM_STATE_CLOSING);
  951.                     mmi_ctm_send_close_req();
  952.                 }
  953.                 switch (ctm_p->mode_setting)
  954.                 {
  955.                     case MMI_CTM_SETTING_HCO:
  956.                         mode = CTM_HCO_MODE;
  957.                         break;
  958.                     case MMI_CTM_SETTING_VCO:
  959.                         mode = CTM_VCO_MODE;
  960.                         break;
  961.                     case MMI_CTM_SETTING_BAUDOT:
  962.                         mode = CTM_BAUDOT_MODE;
  963.                         break;
  964.                     default:
  965.                      /* CTM ON, earphone in, direct mode => keep open as direct mode, take it as earphone */
  966.                  mode = CTM_DIRECT_MODE;
  967.                         break;
  968.                 }
  969.                 if (mode != 0xff)
  970.                 {
  971.                     mmi_ctm_set_state(MMI_CTM_STATE_OPENING);
  972.                     mmi_ctm_send_open_req(mode);
  973.                 }
  974.             }
  975.         }
  976.         else
  977.         {
  978.             /* CTM off, take as headset */
  979.             ctm_p->tty_status = FALSE;
  980.         }
  981.     }
  982.     else
  983.     {
  984.         /* plug out */
  985.         ctm_p->tty_status = FALSE;
  986.         if (mmi_ctm_get_mode())
  987.         {
  988.             /* CTM on, TTY to direct */
  989.             if (ctm_p->state != MMI_CTM_STATE_IDLE)
  990.             {
  991.                 mmi_ctm_set_state(MMI_CTM_STATE_CLOSING);
  992.                 mmi_ctm_send_close_req();
  993.             }
  994.             if (((ctm_p->mode_setting == MMI_CTM_SETTING_AUTO_DIRECT ||
  995.                   ctm_p->mode_setting == MMI_CTM_SETTING_MANUAL_DIRECT) &&
  996.                  (ctm_p->mode_activated != CTM_DIRECT_MODE || 
  997.                   ctm_p->state == MMI_CTM_STATE_CLOSING)) ||
  998.                 (ctm_p->state == MMI_CTM_STATE_IDLE && GetTotalActiveCallCount() + GetTotalHoldCallCount() >= 1))
  999.             {
  1000.                 /* plug out, open again */
  1001.                 mmi_ctm_set_state(MMI_CTM_STATE_OPENING);
  1002.                 mmi_ctm_send_open_req(CTM_DIRECT_MODE);
  1003.             }
  1004.         }
  1005.         else
  1006.         {
  1007.             /* CTM off, do nothing */
  1008.         }
  1009.     }
  1010. }
  1011. /*****************************************************************************
  1012.  * FUNCTION
  1013.  *  mmi_ctm_send_open_req
  1014.  * DESCRIPTION
  1015.  *  
  1016.  * PARAMETERS
  1017.  *  mode        [IN]        
  1018.  *  void(?)     [IN]        *
  1019.  * RETURNS
  1020.  *  void
  1021.  *****************************************************************************/
  1022. void mmi_ctm_send_open_req(U8 mode)
  1023. {
  1024. #ifndef __CTM_DEBUG
  1025.     /*----------------------------------------------------------------*/
  1026.     /* Local Variables                                                */
  1027.     /*----------------------------------------------------------------*/
  1028.     MYQUEUE Message;
  1029.     mmi_ctm_open_req_struct *param;
  1030.     /*----------------------------------------------------------------*/
  1031.     /* Code Body                                                      */
  1032.     /*----------------------------------------------------------------*/
  1033.     /* ClearInputEventHandler(MMI_DEVICE_ALL); */
  1034.     Message.oslSrcId = MOD_MMI;
  1035.     Message.oslDestId = MOD_L4C;
  1036.     Message.oslMsgId = MSG_ID_MMI_CTM_OPEN_REQ;
  1037.     param = (mmi_ctm_open_req_struct*) OslConstructDataPtr(sizeof(mmi_ctm_open_req_struct));
  1038.     param->ctm_interface = mode;
  1039.     Message.oslDataPtr = (oslParaType*) param;
  1040.     Message.oslPeerBuffPtr = NULL;
  1041.     SetProtocolEventHandler(mmi_ctm_open_rsp_hdlr, MSG_ID_MMI_CTM_OPEN_RSP);
  1042.     OslMsgSendExtQueue(&Message);
  1043. #else /* __CTM_DEBUG */ 
  1044.     StartTimer(CM_NOTIFYDURATION_TIMER, 2000, (FuncPtr) mmi_ctm_open_rsp_hdlr);
  1045. #endif /* __CTM_DEBUG */ 
  1046.     PRINT_INFORMATION(("n CTM OPEN REQn"));
  1047. }
  1048. /*****************************************************************************
  1049.  * FUNCTION
  1050.  *  mmi_ctm_send_close_req
  1051.  * DESCRIPTION
  1052.  *  
  1053.  * PARAMETERS
  1054.  *  void
  1055.  *  void(?)     [IN]        *
  1056.  * RETURNS
  1057.  *  void
  1058.  *****************************************************************************/
  1059. void mmi_ctm_send_close_req(void)
  1060. {
  1061. #ifndef __CTM_DEBUG
  1062.     /*----------------------------------------------------------------*/
  1063.     /* Local Variables                                                */
  1064.     /*----------------------------------------------------------------*/
  1065.     MYQUEUE Message;
  1066.     /*----------------------------------------------------------------*/
  1067.     /* Code Body                                                      */
  1068.     /*----------------------------------------------------------------*/
  1069.     /* ClearInputEventHandler(MMI_DEVICE_ALL); */
  1070.     Message.oslSrcId = MOD_MMI;
  1071.     Message.oslDestId = MOD_L4C;
  1072.     Message.oslMsgId = MSG_ID_MMI_CTM_CLOSE_REQ;
  1073.     Message.oslDataPtr = NULL;
  1074.     Message.oslPeerBuffPtr = NULL;
  1075.     SetProtocolEventHandler(mmi_ctm_close_rsp_hdlr, MSG_ID_MMI_CTM_CLOSE_RSP);
  1076.     OslMsgSendExtQueue(&Message);
  1077. #else /* __CTM_DEBUG */ 
  1078.     StartTimer(CM_ALERT_NOTIFYDURATION_TIMER, 2000, (FuncPtr) mmi_ctm_close_rsp_hdlr);
  1079. #endif /* __CTM_DEBUG */ 
  1080.     PRINT_INFORMATION(("n CTM CLOSE REQn"));
  1081. }
  1082. /*****************************************************************************
  1083.  * FUNCTION
  1084.  *  mmi_ctm_send_connect_req
  1085.  * DESCRIPTION
  1086.  *  
  1087.  * PARAMETERS
  1088.  *  void
  1089.  *  void(?)     [IN]        *
  1090.  * RETURNS
  1091.  *  void
  1092.  *****************************************************************************/
  1093. void mmi_ctm_send_connect_req(void)
  1094. {
  1095. #ifndef __CTM_DEBUG
  1096.     /*----------------------------------------------------------------*/
  1097.     /* Local Variables                                                */
  1098.     /*----------------------------------------------------------------*/
  1099.     MYQUEUE Message;
  1100.     /*----------------------------------------------------------------*/
  1101.     /* Code Body                                                      */
  1102.     /*----------------------------------------------------------------*/
  1103.     ClearInputEventHandler(MMI_DEVICE_ALL);
  1104.     Message.oslSrcId = MOD_MMI;
  1105.     Message.oslDestId = MOD_L4C;
  1106.     Message.oslMsgId = MSG_ID_MMI_CTM_CONNECT_REQ;
  1107.     Message.oslDataPtr = NULL;
  1108.     Message.oslPeerBuffPtr = NULL;
  1109.     SetProtocolEventHandler(mmi_ctm_connect_rsp_hdlr, MSG_ID_MMI_CTM_CONNECT_RSP);
  1110.     OslMsgSendExtQueue(&Message);
  1111. #else /* __CTM_DEBUG */ 
  1112.     StartTimer(CM_NOTIFYDURATION_TIMER, 2000, (FuncPtr) mmi_ctm_connect_rsp_hdlr);
  1113. #endif /* __CTM_DEBUG */ 
  1114.     PRINT_INFORMATION(("n CTM CONNECT REQn"));
  1115. }
  1116. /*****************************************************************************
  1117.  * FUNCTION
  1118.  *  mmi_ctm_send_text_req
  1119.  * DESCRIPTION
  1120.  *  
  1121.  * PARAMETERS
  1122.  *  text        [IN]        
  1123.  *  length      [IN]        
  1124.  *  void(?)     [IN]        *
  1125.  * RETURNS
  1126.  *  void
  1127.  *****************************************************************************/
  1128. void mmi_ctm_send_text_req(PS8 text, U16 length)
  1129. {
  1130. #ifndef __CTM_DEBUG
  1131.     /*----------------------------------------------------------------*/
  1132.     /* Local Variables                                                */
  1133.     /*----------------------------------------------------------------*/
  1134.     MYQUEUE Message;
  1135.     mmi_ctm_send_text_req_struct *param;
  1136.     /*----------------------------------------------------------------*/
  1137.     /* Code Body                                                      */
  1138.     /*----------------------------------------------------------------*/
  1139.     ClearInputEventHandler(MMI_DEVICE_ALL);
  1140.     Message.oslSrcId = MOD_MMI;
  1141.     Message.oslDestId = MOD_L4C;
  1142.     Message.oslMsgId = MSG_ID_MMI_CTM_SEND_TEXT_REQ;
  1143.     param = (mmi_ctm_send_text_req_struct*) OslConstructDataPtr(sizeof(mmi_ctm_send_text_req_struct));
  1144.     if (length > CTM_SEND_TEXT_CHAR_MAX_NUM)
  1145.     {
  1146.         param->num_of_char = CTM_SEND_TEXT_CHAR_MAX_NUM;
  1147.         pfnUnicodeStrncpy((PS8) param->text, text, CTM_SEND_TEXT_CHAR_MAX_NUM);
  1148.     }
  1149.     else
  1150.     {
  1151.         param->num_of_char = length;
  1152.         pfnUnicodeStrcpy((PS8) param->text, text);
  1153.     }
  1154.     ctm_p->sent_len = param->num_of_char;
  1155.     Message.oslDataPtr = (oslParaType*) param;
  1156.     Message.oslPeerBuffPtr = NULL;
  1157.     SetProtocolEventHandler(mmi_ctm_send_text_rsp_hdlr, MSG_ID_MMI_CTM_SEND_TEXT_RSP);
  1158.     OslMsgSendExtQueue(&Message);
  1159. #else /* __CTM_DEBUG */ 
  1160.     if (length > CTM_SEND_TEXT_CHAR_MAX_NUM)
  1161.     {
  1162.         ctm_p->sent_len = CTM_SEND_TEXT_CHAR_MAX_NUM;
  1163.     }
  1164.     else
  1165.     {
  1166.         ctm_p->sent_len = length;
  1167.     }
  1168.     StartTimer(CM_NOTIFYDURATION_TIMER, 2000, (FuncPtr) mmi_ctm_send_text_rsp_hdlr);
  1169. #endif /* __CTM_DEBUG */ 
  1170.     PRINT_INFORMATION(("n CTM SEND TEXT REQn"));
  1171. }
  1172. /*****************************************************************************
  1173.  * FUNCTION
  1174.  *  mmi_ctm_send_set_default_req
  1175.  * DESCRIPTION
  1176.  *  
  1177.  * PARAMETERS
  1178.  *  on_off      [IN]        
  1179.  *  mode        [IN]        
  1180.  *  void(?)     [IN]        *
  1181.  * RETURNS
  1182.  *  void
  1183.  *****************************************************************************/
  1184. void mmi_ctm_send_set_default_req(pBOOL on_off, U8 mode)
  1185. {
  1186. #ifndef __CTM_DEBUG
  1187.     /*----------------------------------------------------------------*/
  1188.     /* Local Variables                                                */
  1189.     /*----------------------------------------------------------------*/
  1190.     MYQUEUE Message;
  1191.     mmi_ctm_set_default_req_struct *param;
  1192.     /*----------------------------------------------------------------*/
  1193.     /* Code Body                                                      */
  1194.     /*----------------------------------------------------------------*/
  1195.     ClearInputEventHandler(MMI_DEVICE_ALL);
  1196.     Message.oslSrcId = MOD_MMI;
  1197.     Message.oslDestId = MOD_L4C;
  1198.     Message.oslMsgId = MSG_ID_MMI_CTM_SET_DEFAULT_REQ;
  1199.     param = (mmi_ctm_set_default_req_struct*) OslConstructDataPtr(sizeof(mmi_ctm_set_default_req_struct));
  1200.     param->is_turn_on = on_off;
  1201.     switch (mode)
  1202.     {
  1203.         case MMI_CTM_SETTING_BAUDOT:
  1204.             param->ctm_interface = CTM_BAUDOT_MODE;
  1205.             break;
  1206.         case MMI_CTM_SETTING_HCO:
  1207.             param->ctm_interface = CTM_HCO_MODE;
  1208.             break;
  1209.         case MMI_CTM_SETTING_VCO:
  1210.             param->ctm_interface = CTM_VCO_MODE;
  1211.             break;
  1212.         default:
  1213.             param->ctm_interface = CTM_DIRECT_MODE;
  1214.             break;
  1215.     }
  1216.     Message.oslDataPtr = (oslParaType*) param;
  1217.     Message.oslPeerBuffPtr = NULL;
  1218.     SetProtocolEventHandler(mmi_ctm_set_default_rsp_hdlr, MSG_ID_MMI_CTM_SET_DEFAULT_RSP);
  1219.     OslMsgSendExtQueue(&Message);
  1220. #else /* __CTM_DEBUG */ 
  1221.     StartTimer(CM_NOTIFYDURATION_TIMER, 2000, (FuncPtr) mmi_ctm_set_default_rsp_hdlr);
  1222. #endif /* __CTM_DEBUG */ 
  1223.     PRINT_INFORMATION(("n CTM SEND SET DEFAULT REQn"));
  1224. }
  1225. /*****************************************************************************
  1226.  * FUNCTION
  1227.  *  mmi_ctm_send_get_default_req
  1228.  * DESCRIPTION
  1229.  *  
  1230.  * PARAMETERS
  1231.  *  void
  1232.  *  void(?)     [IN]        *
  1233.  * RETURNS
  1234.  *  void
  1235.  *****************************************************************************/
  1236. void mmi_ctm_send_get_default_req(void)
  1237. {
  1238. #ifndef __CTM_DEBUG
  1239.     /*----------------------------------------------------------------*/
  1240.     /* Local Variables                                                */
  1241.     /*----------------------------------------------------------------*/
  1242.     MYQUEUE Message;
  1243.     /*----------------------------------------------------------------*/
  1244.     /* Code Body                                                      */
  1245.     /*----------------------------------------------------------------*/
  1246.     Message.oslSrcId = MOD_MMI;
  1247.     Message.oslDestId = MOD_L4C;
  1248.     Message.oslMsgId = MSG_ID_MMI_CTM_GET_DEFAULT_REQ;
  1249.     Message.oslDataPtr = NULL;
  1250.     Message.oslPeerBuffPtr = NULL;
  1251.     SetProtocolEventHandler(mmi_ctm_get_default_rsp_hdlr, MSG_ID_MMI_CTM_GET_DEFAULT_RSP);
  1252.     OslMsgSendExtQueue(&Message);
  1253. #else /* __CTM_DEBUG */ 
  1254.     StartTimer(CM_NOTIFYDURATION_TIMER, 2000, (FuncPtr) mmi_ctm_get_default_rsp_hdlr);
  1255. #endif /* __CTM_DEBUG */ 
  1256.     PRINT_INFORMATION(("n CTM SEND GET DEFAULT REQn"));
  1257. }
  1258. /*****************************************************************************
  1259.  * FUNCTION
  1260.  *  mmi_ctm_connect
  1261.  * DESCRIPTION
  1262.  *  
  1263.  * PARAMETERS
  1264.  *  void
  1265.  *  void(?)     [IN]        *
  1266.  * RETURNS
  1267.  *  void
  1268.  *****************************************************************************/
  1269. void mmi_ctm_connect(void)
  1270. {
  1271.     /*----------------------------------------------------------------*/
  1272.     /* Local Variables                                                */
  1273.     /*----------------------------------------------------------------*/
  1274.     /*----------------------------------------------------------------*/
  1275.     /* Code Body                                                      */
  1276.     /*----------------------------------------------------------------*/
  1277.     if (ctm_p->state == MMI_CTM_STATE_OPENED)
  1278.     {
  1279.         mmi_ctm_set_state(MMI_CTM_STATE_CONNECTING);
  1280.         mmi_ctm_send_connect_req();
  1281.         entry_ctm_connect_animation();
  1282.     }
  1283.     else if (ctm_p->state == MMI_CTM_STATE_CONNECTED)
  1284.     {
  1285.         /* back to active screen to direct to chat screen */
  1286.         GoBackHistory();
  1287.     }
  1288. }
  1289. /*****************************************************************************
  1290.  * FUNCTION
  1291.  *  mmi_ctm_edit_done
  1292.  * DESCRIPTION
  1293.  *  
  1294.  * PARAMETERS
  1295.  *  void
  1296.  *  void(?)     [IN]        *
  1297.  * RETURNS
  1298.  *  void
  1299.  *****************************************************************************/
  1300. void mmi_ctm_edit_done(void)
  1301. {
  1302.     /*----------------------------------------------------------------*/
  1303.     /* Local Variables                                                */
  1304.     /*----------------------------------------------------------------*/
  1305.     /*----------------------------------------------------------------*/
  1306.     /* Code Body                                                      */
  1307.     /*----------------------------------------------------------------*/
  1308.     ctm_p->pending_len += pfnUnicodeStrlen((PS8) ctm_p->editor_buffer);
  1309.     pfnUnicodeStrcat((PS8) ctm_p->pending_buffer, (PS8) ctm_p->editor_buffer);
  1310.     memset(ctm_p->editor_buffer, 0, MAX_CTM_EDITOR_BUFFER_LEN);
  1311.     if (ctm_p->sent_len == 0)
  1312.     {
  1313.         mmi_ctm_send_text_req((PS8) ctm_p->pending_buffer, ctm_p->pending_len);
  1314.     }
  1315.     if (IsScreenPresent(SCR_CM_ACTIVECALLSCREEN))
  1316.     {
  1317.         GoBackToHistory(SCR_CM_ACTIVECALLSCREEN);
  1318.     }
  1319.     else if (IsScreenPresent(SCR_CTM_TALKING))
  1320.     {
  1321.         GoBackToHistory(SCR_CTM_TALKING);
  1322.     }
  1323.     else
  1324.     {
  1325.         ASSERT(0);
  1326.     }
  1327. }
  1328. /*****************************************************************************
  1329.  * FUNCTION
  1330.  *  mmi_ctm_toggle_mode
  1331.  * DESCRIPTION
  1332.  *  
  1333.  * PARAMETERS
  1334.  *  void
  1335.  *  void(?)     [IN]        *
  1336.  * RETURNS
  1337.  *  void
  1338.  *****************************************************************************/
  1339. void mmi_ctm_toggle_mode(void)
  1340. {
  1341.     /*----------------------------------------------------------------*/
  1342.     /* Local Variables                                                */
  1343.     /*----------------------------------------------------------------*/
  1344.     S16 error;
  1345.     U16 str_id;
  1346.     pBOOL old;
  1347.     /*----------------------------------------------------------------*/
  1348.     /* Code Body                                                      */
  1349.     /*----------------------------------------------------------------*/
  1350.     old = mmi_ctm_is_tty_on();
  1351.     if (ctm_p->status == TRUE)
  1352.     {
  1353.         ctm_p->status = FALSE;
  1354.     }
  1355.     else
  1356.     {
  1357.         ctm_p->status = TRUE;
  1358.     }
  1359.     WriteValue(NVRAM_CTM_MODE, &ctm_p->status, DS_BYTE, &error);
  1360.     mmi_ctm_send_set_default_req(ctm_p->status, ctm_p->mode_setting);
  1361.     if (ctm_p->status == TRUE)
  1362.     {
  1363.         /* off -> on */
  1364.         str_id = STR_CTM_ON_SELECTED;
  1365.         ShowStatusIcon(STATUS_ICON_TTY_INDICATOR);
  1366.         /* with earphone, take as TTY */
  1367.         ctm_p->tty_status = isEarphonePlugged;
  1368.         if (isEarphonePlugged == TRUE && mmi_ctm_is_tty_on())
  1369.         {
  1370.             str_id = STR_CTM_HEADSET_TO_TTY;
  1371.             /* deactivate earphone mode, Tim */
  1372.             mmi_profiles_earphone_plug_out_callback();
  1373.         #if (defined (__MMI_STATUS_ICON_EN_EARPHONE__) || defined(__MMI_BT_SUPPORT__))
  1374.             IdleResetStatusIcon(STATUS_ICON_EARPHONE_INDICATOR);
  1375.         #endif 
  1376.         }
  1377.     }
  1378.     else
  1379.     {
  1380.         /* on -> off */
  1381.         str_id = STR_CTM_OFF_SELECTED;
  1382.         HideStatusIcon(STATUS_ICON_TTY_INDICATOR);
  1383.         ctm_p->tty_status = FALSE;
  1384.         if (isEarphonePlugged == TRUE && old == TRUE)
  1385.         {
  1386.             str_id = STR_CTM_TTY_TO_HEADSET;
  1387.             /* activate earphone mode, Tim */
  1388.             mmi_profiles_earphone_plug_in_callback();
  1389.         #if (defined (__MMI_STATUS_ICON_EN_EARPHONE__) || defined(__MMI_BT_SUPPORT__))
  1390.             IdleSetStatusIcon(STATUS_ICON_EARPHONE_INDICATOR);
  1391.         #endif 
  1392.         }
  1393.     }
  1394.     DisplayPopup((PU8) GetString(str_id), IMG_GLOBAL_ACTIVATED, 1, 2000, SUCCESS_TONE);
  1395.     /*
  1396.      * hint_ctm_mode(GetCurrHiliteID());
  1397.      * RedrawCategoryFunction();
  1398.      * highlight_ctm_mode();
  1399.      */
  1400. }
  1401. /*****************************************************************************
  1402.  * FUNCTION
  1403.  *  mmi_ctm_setting_select
  1404.  * DESCRIPTION
  1405.  *  
  1406.  * PARAMETERS
  1407.  *  void
  1408.  *  void(?)     [IN]        *
  1409.  * RETURNS
  1410.  *  void
  1411.  *****************************************************************************/
  1412. void mmi_ctm_setting_select(void)
  1413. {
  1414.     /*----------------------------------------------------------------*/
  1415.     /* Local Variables                                                */
  1416.     /*----------------------------------------------------------------*/
  1417.     S16 error;
  1418.     U16 str_id = STR_GLOBAL_DONE;
  1419.     pBOOL old;
  1420.     /*----------------------------------------------------------------*/
  1421.     /* Code Body                                                      */
  1422.     /*----------------------------------------------------------------*/
  1423.     old = mmi_ctm_is_tty_on();
  1424.     ctm_p->mode_setting = (U8) ctm_p->index;
  1425.     WriteValue(NVRAM_CTM_SETTING, &ctm_p->mode_setting, DS_BYTE, &error);
  1426.     mmi_ctm_send_set_default_req(ctm_p->status, ctm_p->mode_setting);
  1427.  if (old == FALSE && mmi_ctm_is_tty_on() == TRUE)
  1428.     {
  1429.         /* off -> on */
  1430.         /* with earphone, take as TTY */
  1431.         if (isEarphonePlugged == TRUE)
  1432.         {
  1433.             str_id = STR_CTM_HEADSET_TO_TTY;
  1434.             /* deactivate earphone mode, Tim */
  1435.             mmi_profiles_earphone_plug_out_callback();
  1436.         #if (defined (__MMI_STATUS_ICON_EN_EARPHONE__) || defined(__MMI_BT_SUPPORT__))
  1437.             IdleResetStatusIcon(STATUS_ICON_EARPHONE_INDICATOR);
  1438.         #endif 
  1439.         }
  1440.     }
  1441.  else if (old == TRUE && mmi_ctm_is_tty_on() == FALSE)
  1442.     {
  1443.         /* on -> off */
  1444.         if (isEarphonePlugged == TRUE)
  1445.         {
  1446.             str_id = STR_CTM_TTY_TO_HEADSET;
  1447.             /* activate earphone mode, Tim */
  1448.             mmi_profiles_earphone_plug_in_callback();
  1449.         #if (defined (__MMI_STATUS_ICON_EN_EARPHONE__) || defined(__MMI_BT_SUPPORT__))
  1450.             IdleSetStatusIcon(STATUS_ICON_EARPHONE_INDICATOR);
  1451.         #endif 
  1452.         }
  1453.     }
  1454.     DisplayPopup((PU8) GetString(str_id), IMG_GLOBAL_ACTIVATED, 1, 2000, SUCCESS_TONE);
  1455.     DeleteScreenIfPresent(SCR_CTM_SETTING);
  1456. }
  1457. /*****************************************************************************
  1458.  * FUNCTION
  1459.  *  mmi_ctm_get_mode
  1460.  * DESCRIPTION
  1461.  *  
  1462.  * PARAMETERS
  1463.  *  void
  1464.  *  void(?)     [IN]        *
  1465.  * RETURNS
  1466.  *  void
  1467.  *****************************************************************************/
  1468. pBOOL mmi_ctm_get_mode(void)
  1469. {
  1470.     /*----------------------------------------------------------------*/
  1471.     /* Local Variables                                                */
  1472.     /*----------------------------------------------------------------*/
  1473.     /*----------------------------------------------------------------*/
  1474.     /* Code Body                                                      */
  1475.     /*----------------------------------------------------------------*/
  1476.     return ctm_p->status;
  1477. }
  1478. /*****************************************************************************
  1479.  * FUNCTION
  1480.  *  mmi_ctm_get_setting
  1481.  * DESCRIPTION
  1482.  *  
  1483.  * PARAMETERS
  1484.  *  void
  1485.  *  void(?)     [IN]        *
  1486.  * RETURNS
  1487.  *  void
  1488.  *****************************************************************************/
  1489. U8 mmi_ctm_get_setting(void)
  1490. {
  1491.     /*----------------------------------------------------------------*/
  1492.     /* Local Variables                                                */
  1493.     /*----------------------------------------------------------------*/
  1494.     /*----------------------------------------------------------------*/
  1495.     /* Code Body                                                      */
  1496.     /*----------------------------------------------------------------*/
  1497.     return ctm_p->mode_setting;
  1498. }
  1499. /*****************************************************************************
  1500.  * FUNCTION
  1501.  *  mmi_ctm_is_tty_on
  1502.  * DESCRIPTION
  1503.  *  
  1504.  * PARAMETERS
  1505.  *  void
  1506.  *  void(?)     [IN]        *
  1507.  * RETURNS
  1508.  *  void
  1509.  *****************************************************************************/
  1510. pBOOL mmi_ctm_is_tty_on(void)
  1511. {
  1512.     /*----------------------------------------------------------------*/
  1513.     /* Local Variables                                                */
  1514.     /*----------------------------------------------------------------*/
  1515.     /*----------------------------------------------------------------*/
  1516.     /* Code Body                                                      */
  1517.     /*----------------------------------------------------------------*/
  1518.     /* TTY on depends on status and setting */
  1519.     /* TTY status depends on status and earphone plug in or not */
  1520.     if (ctm_p->status == TRUE && 
  1521.        (ctm_p->mode_setting == MMI_CTM_SETTING_BAUDOT ||
  1522.         ctm_p->mode_setting == MMI_CTM_SETTING_HCO ||
  1523.         ctm_p->mode_setting == MMI_CTM_SETTING_VCO))
  1524.         return TRUE;
  1525.     else
  1526.        return FALSE;
  1527. }
  1528. /*****************************************************************************
  1529.  * FUNCTION
  1530.  *  mmi_ctm_get_tty_status
  1531.  * DESCRIPTION
  1532.  *  
  1533.  * PARAMETERS
  1534.  *  void
  1535.  *  void(?)     [IN]        *
  1536.  * RETURNS
  1537.  *  void
  1538.  *****************************************************************************/
  1539. pBOOL mmi_ctm_get_tty_status(void)
  1540. {
  1541.     /*----------------------------------------------------------------*/
  1542.     /* Local Variables                                                */
  1543.     /*----------------------------------------------------------------*/
  1544.     /*----------------------------------------------------------------*/
  1545.     /* Code Body                                                      */
  1546.     /*----------------------------------------------------------------*/
  1547.     return ctm_p->tty_status;
  1548. }
  1549. /*****************************************************************************
  1550.  * FUNCTION
  1551.  *  mmi_skip_unicode_char
  1552.  * DESCRIPTION
  1553.  *  
  1554.  * PARAMETERS
  1555.  *  str         [IN]        
  1556.  *  len         [IN]        
  1557.  *  ch          [IN]        
  1558.  *  void(?)     [IN]        *
  1559.  * RETURNS
  1560.  *  void
  1561.  *****************************************************************************/
  1562. U16 mmi_skip_unicode_char(PU16 str, U16 len, U16 ch)
  1563. {
  1564.     /*----------------------------------------------------------------*/
  1565.     /* Local Variables                                                */
  1566.     /*----------------------------------------------------------------*/
  1567.     U16 length, i;
  1568.     /*----------------------------------------------------------------*/
  1569.     /* Code Body                                                      */
  1570.     /*----------------------------------------------------------------*/
  1571.     length = len;
  1572.     for (i = 0; i < length; i++)
  1573.     {
  1574.         if (str[i] == ch)
  1575.         {
  1576.             pfnUnicodeStrcpy((PS8) & str[i], (PS8) & str[i + 1]);
  1577.             str[length] = 0;
  1578.             length--;
  1579.         }
  1580.     }
  1581.     return length;
  1582. }
  1583. /*****************************************************************************
  1584.  * FUNCTION
  1585.  *  mmi_ctm_set_tty_status
  1586.  * DESCRIPTION
  1587.  *  
  1588.  * PARAMETERS
  1589.  *  is_present      [IN]        
  1590.  *  void(?)         [IN]        *
  1591.  * RETURNS
  1592.  *  void
  1593.  *****************************************************************************/
  1594. void mmi_ctm_set_tty_status(pBOOL is_present)
  1595. {
  1596.     /*----------------------------------------------------------------*/
  1597.     /* Local Variables                                                */
  1598.     /*----------------------------------------------------------------*/
  1599.     /*----------------------------------------------------------------*/
  1600.     /* Code Body                                                      */
  1601.     /*----------------------------------------------------------------*/
  1602.     if (mmi_ctm_get_mode())
  1603.     {
  1604.         ctm_p->tty_status = is_present;
  1605.     }
  1606.     else
  1607.     {
  1608.         ctm_p->tty_status = FALSE;
  1609.     }
  1610. }
  1611. /*****************************************************************************
  1612.  * FUNCTION
  1613.  *  entry_ctm_menu
  1614.  * DESCRIPTION
  1615.  *  CTM main menu: Mode, Setting
  1616.  * PARAMETERS
  1617.  *  void
  1618.  *  void(?)     [IN]        *
  1619.  * RETURNS
  1620.  *  void
  1621.  *****************************************************************************/
  1622. void entry_ctm_menu(void)
  1623. {
  1624.     /*----------------------------------------------------------------*/
  1625.     /* Local Variables                                                */
  1626.     /*----------------------------------------------------------------*/
  1627.     U16 nStrItemList[4];
  1628.     U16 nNumofItem;
  1629.     S16 error;
  1630.     U8 *guiBuffer;
  1631.     static U8 *PopUpList[4];
  1632.     /*----------------------------------------------------------------*/
  1633.     /* Code Body                                                      */
  1634.     /*----------------------------------------------------------------*/
  1635.     EntryNewScreen(SCR_CTM_MENU, NULL, entry_ctm_menu, NULL);
  1636.     ReadValue(NVRAM_CTM_MODE, &ctm_p->status, DS_BYTE, &error);
  1637.     if (ctm_p->status == 0xff)
  1638.     {
  1639.         ctm_p->status = FALSE;
  1640.     }
  1641.     ReadValue(NVRAM_CTM_SETTING, &ctm_p->mode_setting, DS_BYTE, &error);
  1642.     if (ctm_p->mode_setting == 0xff)
  1643.     {
  1644.         ctm_p->mode_setting = MMI_CTM_SETTING_MANUAL_DIRECT;
  1645.     }
  1646.     guiBuffer = GetCurrGuiBuffer(SCR_CTM_MENU);
  1647.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1648.     nNumofItem = GetNumOfChild(MITEM_CTM_MENU);
  1649.     GetSequenceStringIds(MITEM_CTM_MENU, nStrItemList);
  1650.     SetParentHandler(MITEM_CTM_MENU);
  1651.     ConstructHintsList(MITEM_CTM_MENU, PopUpList);
  1652.     ShowCategory55Screen(
  1653.         STR_GLOBAL_OPTIONS,
  1654.         GetRootTitleIcon(MAIN_MENU_SETTINGS_MENUID),
  1655.         STR_GLOBAL_OK,
  1656.         IMG_GLOBAL_OK,
  1657.         STR_GLOBAL_BACK,
  1658.         IMG_GLOBAL_BACK,
  1659.         nNumofItem,
  1660.         nStrItemList,
  1661.         (U8 **) PopUpList,
  1662.         0,
  1663.         guiBuffer);
  1664.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1665.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1666.     return;
  1667. }
  1668. /*****************************************************************************
  1669.  * FUNCTION
  1670.  *  entry_ctm_setting_selection
  1671.  * DESCRIPTION
  1672.  *  
  1673.  * PARAMETERS
  1674.  *  void
  1675.  *  void(?)     [IN]        *
  1676.  * RETURNS
  1677.  *  void
  1678.  *****************************************************************************/
  1679. void entry_ctm_setting_selection(void)
  1680. {
  1681.     /*----------------------------------------------------------------*/
  1682.     /* Local Variables                                                */
  1683.     /*----------------------------------------------------------------*/
  1684.     U16 nStrItemList[20];
  1685.     U16 nNumofItem;
  1686.     U8 *guiBuffer;
  1687.     /*----------------------------------------------------------------*/
  1688.     /* Code Body                                                      */
  1689.     /*----------------------------------------------------------------*/
  1690.     EntryNewScreen(SCR_CTM_SETTING, NULL, entry_ctm_setting_selection, NULL);
  1691.     guiBuffer = GetCurrGuiBuffer(SCR_CTM_SETTING);
  1692.     RegisterHighlightHandler(highlight_ctm_setting_items);
  1693.     nNumofItem = GetNumOfChild(MITEM_CTM_SETTING);
  1694.     GetSequenceStringIds(MITEM_CTM_SETTING, nStrItemList);
  1695.     SetParentHandler(MITEM_CTM_SETTING);
  1696.     ShowCategory11Screen(
  1697.         STR_MITEM_CTM_SETTING,
  1698.         GetRootTitleIcon(MAIN_MENU_SETTINGS_MENUID),
  1699.         STR_GLOBAL_OK,
  1700.         0,
  1701.         STR_GLOBAL_BACK,
  1702.         0,
  1703.         nNumofItem,
  1704.         nStrItemList,
  1705.         ctm_p->mode_setting,
  1706.         guiBuffer);
  1707.     SetLeftSoftkeyFunction(mmi_ctm_setting_select, KEY_EVENT_UP);
  1708.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1709.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1710.     return;
  1711. }
  1712. /*****************************************************************************
  1713.  * FUNCTION
  1714.  *  entry_ctm_connect_animation
  1715.  * DESCRIPTION
  1716.  *  
  1717.  * PARAMETERS
  1718.  *  void
  1719.  *  void(?)     [IN]        *
  1720.  * RETURNS
  1721.  *  void
  1722.  *****************************************************************************/
  1723. void entry_ctm_connect_animation(void)
  1724. {
  1725.     /*----------------------------------------------------------------*/
  1726.     /* Local Variables                                                */
  1727.     /*----------------------------------------------------------------*/
  1728.     /*----------------------------------------------------------------*/
  1729.     /* Code Body                                                      */
  1730.     /*----------------------------------------------------------------*/
  1731.     EntryNewScreen(SCR_CTM_CONNECTING, NULL, entry_ctm_connect_animation, NULL);
  1732.     DeleteScreenIfPresent(SCR1003_CM_ACTIVECALLOPTIONS);
  1733.     ShowCategory66Screen(0, 0, 0, 0, 0, 0, (PU8) GetString(STR_CTM_CONNECTING), IMG_GLOBAL_PROGRESS, NULL);
  1734.     ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  1735. }
  1736. /*****************************************************************************
  1737.  * FUNCTION
  1738.  *  entry_ctm_talking
  1739.  * DESCRIPTION
  1740.  *  
  1741.  * PARAMETERS
  1742.  *  void
  1743.  *  void(?)     [IN]        *
  1744.  * RETURNS
  1745.  *  void
  1746.  *****************************************************************************/
  1747. void entry_ctm_talking(void)
  1748. {
  1749.     /*----------------------------------------------------------------*/
  1750.     /* Local Variables                                                */
  1751.     /*----------------------------------------------------------------*/
  1752.     U16 lsk = 0;
  1753.     /*----------------------------------------------------------------*/
  1754.     /* Code Body                                                      */
  1755.     /*----------------------------------------------------------------*/
  1756.     if (ctm_p->state < MMI_CTM_STATE_CONNECTED)
  1757.     {
  1758.         /* not connected, use default active screen */
  1759.         if (IsScreenPresent(SCR_CM_ACTIVECALLSCREEN))
  1760.         {
  1761.             GoBackToHistory(SCR_CM_ACTIVECALLSCREEN);
  1762.         }
  1763.         else
  1764.         {
  1765.             EntryScr1002ActiveCall();
  1766.         }
  1767.         return;
  1768.     }
  1769.     EntryNewScreen(SCR_CTM_TALKING, NULL, entry_ctm_talking, NULL);
  1770.     PRINT_INFORMATION(("nCTM TALKING SCREENn"));
  1771.     if (MAX_CTM_EDITOR_COUNT - ctm_p->pending_len > 0)
  1772.     {
  1773.         lsk = STR_GLOBAL_EDIT;
  1774.     }
  1775.     ShowCategory430Screen(
  1776.         STR_CTM_CHAT,
  1777.         0,
  1778.         lsk,
  1779.         0,
  1780.         STR_MITEM2041_CM_DROP,
  1781.         0,
  1782.         ctm_p->remote_buffer,
  1783.         ctm_p->remote_len,
  1784.         ctm_p->local_buffer,
  1785.         ctm_p->local_len,
  1786.         TRUE,
  1787.         MAX_CTM_EDITOR_COUNT,
  1788.         ctm_p->pending_buffer,
  1789.         0,
  1790.         (PU8) GetString(STR_CTM_REMOTE),
  1791.         (PU8) GetString(STR_CTM_LOCAL),
  1792.         NULL);
  1793.     SetLeftSoftkeyFunction(entry_ctm_editor, KEY_EVENT_UP);
  1794.     SetRightSoftkeyFunction(HangupAll, KEY_EVENT_UP);
  1795.     SetKeyHandler(HangupAll, KEY_END, KEY_EVENT_DOWN);
  1796. }
  1797. /*****************************************************************************
  1798.  * FUNCTION
  1799.  *  entry_ctm_editor
  1800.  * DESCRIPTION
  1801.  *  
  1802.  * PARAMETERS
  1803.  *  void
  1804.  *  void(?)     [IN]        *
  1805.  * RETURNS
  1806.  *  void
  1807.  *****************************************************************************/
  1808. void entry_ctm_editor(void)
  1809. {
  1810.     /*----------------------------------------------------------------*/
  1811.     /* Local Variables                                                */
  1812.     /*----------------------------------------------------------------*/
  1813.     U8 *guiBuffer;
  1814.     S32 length;
  1815.     /*----------------------------------------------------------------*/
  1816.     /* Code Body                                                      */
  1817.     /*----------------------------------------------------------------*/
  1818.     EntryNewScreen(SCR_CTM_EDITOR, NULL, entry_ctm_editor, NULL);
  1819.     guiBuffer = GetCurrGuiBuffer(SCR_CTM_EDITOR);
  1820.     length = MAX_CTM_EDITOR_COUNT - ctm_p->pending_len;
  1821.     ShowCategory5Screen(
  1822.         STR_GLOBAL_EDIT,
  1823.         0,
  1824.         STR_GLOBAL_OK,
  1825.         IMG_GLOBAL_OK,
  1826.         STR_GLOBAL_BACK,
  1827.         IMG_GLOBAL_BACK,
  1828.         (INPUT_TYPE_ALPHANUMERIC_UPPERCASE),
  1829.         (PU8) ctm_p->editor_buffer,
  1830.         length + 1,
  1831.         guiBuffer);
  1832.     ClearKeyHandler(KEY_POUND, KEY_EVENT_DOWN);
  1833.     SetLeftSoftkeyFunction(mmi_ctm_edit_done/*entry_ctm_editor_option*/, KEY_EVENT_UP);
  1834.     SetCategory5RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1835.     return;
  1836. }
  1837. /*****************************************************************************
  1838.  * FUNCTION
  1839.  *  ctm_return_to_editor
  1840.  * DESCRIPTION
  1841.  *  
  1842.  * PARAMETERS
  1843.  *  void
  1844.  *  void(?)     [IN]        *
  1845.  * RETURNS
  1846.  *  void
  1847.  *****************************************************************************/
  1848. void ctm_return_to_editor(void)
  1849. {
  1850.     /*----------------------------------------------------------------*/
  1851.     /* Local Variables                                                */
  1852.     /*----------------------------------------------------------------*/
  1853.     /*----------------------------------------------------------------*/
  1854.     /* Code Body                                                      */
  1855.     /*----------------------------------------------------------------*/
  1856.     GoBacknHistory(1);
  1857. }
  1858. /*****************************************************************************
  1859.  * FUNCTION
  1860.  *  entry_ctm_editor_option
  1861.  * DESCRIPTION
  1862.  *  
  1863.  * PARAMETERS
  1864.  *  void
  1865.  *  void(?)     [IN]        *
  1866.  * RETURNS
  1867.  *  void
  1868.  *****************************************************************************/
  1869. void entry_ctm_editor_option(void)
  1870. {
  1871.     /*----------------------------------------------------------------*/
  1872.     /* Local Variables                                                */
  1873.     /*----------------------------------------------------------------*/
  1874.     U16 nStrItemList[10];
  1875.     U8 *guiBuffer;
  1876.     U16 nNumofItem;
  1877.     /*----------------------------------------------------------------*/
  1878.     /* Code Body                                                      */
  1879.     /*----------------------------------------------------------------*/
  1880.     EntryNewScreen(SCR_CTM_EDITOR_OPTION, NULL, entry_ctm_editor_option, NULL);
  1881.     guiBuffer = GetCurrGuiBuffer(SCR_CTM_EDITOR_OPTION);
  1882.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1883.     nNumofItem = GetNumOfChild(MITEM_CTM_EDITOR_OPTION);
  1884.     GetSequenceStringIds(MITEM_CTM_EDITOR_OPTION, nStrItemList);
  1885.     SetParentHandler(MITEM_CTM_EDITOR_OPTION);
  1886.     ShowCategory15Screen(
  1887.         STR_GLOBAL_OPTIONS,
  1888.         0,
  1889.         STR_GLOBAL_OK,
  1890.         IMG_GLOBAL_OK,
  1891.         STR_GLOBAL_BACK,
  1892.         IMG_GLOBAL_BACK,
  1893.         nNumofItem,
  1894.         nStrItemList,
  1895.         (U16*) gIndexIconsImageList,
  1896.         1,
  1897.         0,
  1898.         guiBuffer);
  1899.     RegisterInputMethodScreenCloseFunction(ctm_return_to_editor);
  1900.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1901.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1902.     return;
  1903. }
  1904. #endif /* __CTM_SUPPORT__ */