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

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.  *   CallManagementIncoming.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.  * Add compile option for touch screen.
  67.  *
  68.  * removed!
  69.  * removed!
  70.  * Disable center key
  71.  *
  72.  * removed!
  73.  * removed!
  74.  * 
  75.  *
  76.  * removed!
  77.  * removed!
  78.  * Add compile option
  79.  *
  80.  * removed!
  81.  * removed!
  82.  * 
  83.  *
  84.  * removed!
  85.  * removed!
  86.  * clear Delete Screen Handler after user selects OK
  87.  *
  88.  * removed!
  89.  * removed!
  90.  * Don't resume audio when the incoming call is in black list.
  91.  *
  92.  * removed!
  93.  * removed!
  94.  * allow English character (uppercase and lowercase)
  95.  *
  96.  * removed!
  97.  * removed!
  98.  * enable center key and set handler for it.
  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.  * removed!
  141.  * removed!
  142.  * 
  143.  *
  144.  * removed!
  145.  * removed!
  146.  * 
  147.  *
  148.  * removed!
  149.  * removed!
  150.  * 
  151.  *
  152.  * removed!
  153.  * removed!
  154.  * 
  155.  *
  156.  * removed!
  157.  * removed!
  158.  * 
  159.  *
  160.  * removed!
  161.  * removed!
  162.  * 
  163.  *
  164.  * removed!
  165.  * removed!
  166.  * 
  167.  *
  168.  * removed!
  169.  * removed!
  170.  * 
  171.  *
  172.  * removed!
  173.  * removed!
  174.  * 
  175.  *
  176.  * removed!
  177.  * removed!
  178.  * 
  179.  *
  180.  * removed!
  181.  * removed!
  182.  * 
  183.  *
  184.  * removed!
  185.  * removed!
  186.  * 
  187.  *
  188.  * removed!
  189.  * removed!
  190.  * 
  191.  *
  192.  * removed!
  193.  * removed!
  194.  * 
  195.  *
  196.  * removed!
  197.  * removed!
  198.  * 
  199.  *
  200.  * removed!
  201.  * removed!
  202.  * 
  203.  *
  204.  * removed!
  205.  * removed!
  206.  * 
  207.  *
  208.  * removed!
  209.  * removed!
  210.  * 
  211.  *
  212.  * removed!
  213.  * removed!
  214.  * 
  215.  *
  216.  * removed!
  217.  * removed!
  218.  * 
  219.  *
  220.  * removed!
  221.  * removed!
  222.  * 
  223.  *
  224.  * removed!
  225.  * removed!
  226.  * 
  227.  *
  228.  * removed!
  229.  * removed!
  230.  * 
  231.  *
  232.  * removed!
  233.  * removed!
  234.  * 
  235.  *
  236.  * removed!
  237.  * removed!
  238.  * 
  239.  *
  240.  * removed!
  241.  * removed!
  242.  * 
  243.  *
  244.  * removed!
  245.  * removed!
  246.  * 
  247.  *
  248.  * removed!
  249.  * removed!
  250.  * 
  251.  *
  252.  * removed!
  253.  * removed!
  254.  * 
  255.  *
  256.  * removed!
  257.  * removed!
  258.  * 
  259.  *
  260.  * removed!
  261.  * removed!
  262.  * 
  263.  *
  264.  * removed!
  265.  * removed!
  266.  * 
  267.  *
  268.  * removed!
  269.  * removed!
  270.  * 
  271.  *
  272.  * removed!
  273.  * removed!
  274.  * 
  275.  *
  276.  * removed!
  277.  * removed!
  278.  * 
  279.  *
  280.  * removed!
  281.  * removed!
  282.  * 
  283.  *
  284.  * removed!
  285.  * removed!
  286.  * 
  287.  *
  288.  * removed!
  289.  * removed!
  290.  * 
  291.  *
  292.  * removed!
  293.  * removed!
  294.  * 
  295.  *
  296.  * removed!
  297.  * removed!
  298.  * 
  299.  *
  300.  * removed!
  301.  * removed!
  302.  * 
  303.  *
  304.  * removed!
  305.  * removed!
  306.  * 
  307.  *
  308.  * removed!
  309.  * removed!
  310.  * 
  311.  *
  312.  * removed!
  313.  * removed!
  314.  * 
  315.  *
  316.  * removed!
  317.  * removed!
  318.  * 
  319.  *
  320.  * removed!
  321.  * removed!
  322.  * 
  323.  *
  324.  * removed!
  325.  * removed!
  326.  * 
  327.  *
  328.  * removed!
  329.  * removed!
  330.  * 
  331.  *
  332.  * removed!
  333.  * removed!
  334.  * 
  335.  *
  336.  * removed!
  337.  * removed!
  338.  * 
  339.  *
  340.  * removed!
  341.  * removed!
  342.  * 
  343.  *
  344.  * removed!
  345.  * removed!
  346.  * 
  347.  *
  348.  * removed!
  349.  * removed!
  350.  * 
  351.  *
  352.  * removed!
  353.  * removed!
  354.  * 
  355.  *
  356.  * removed!
  357.  * removed!
  358.  * 
  359.  *
  360.  * removed!
  361.  * removed!
  362.  * 
  363.  *
  364.  * removed!
  365.  * removed!
  366.  * 
  367.  *
  368.  * removed!
  369.  * removed!
  370.  * 
  371.  *
  372.  * removed!
  373.  * removed!
  374.  * 
  375.  *
  376.  * removed!
  377.  * removed!
  378.  * 
  379.  *
  380.  * removed!
  381.  * removed!
  382.  * 
  383.  *
  384.  * removed!
  385.  * removed!
  386.  * 
  387.  *
  388.  * removed!
  389.  * removed!
  390.  * 
  391.  *
  392.  * removed!
  393.  * removed!
  394.  * 
  395.  *
  396.  * removed!
  397.  * removed!
  398.  * 
  399.  *
  400.  * removed!
  401.  * removed!
  402.  * 
  403.  *
  404.  * removed!
  405.  * removed!
  406.  * 
  407.  *
  408.  * removed!
  409.  * removed!
  410.  * 
  411.  *
  412.  * removed!
  413.  * removed!
  414.  * 
  415.  *
  416.  * removed!
  417.  * removed!
  418.  * 
  419.  *
  420.  * removed!
  421.  * removed!
  422.  * 
  423.  *
  424.  * removed!
  425.  * removed!
  426.  * 
  427.  *
  428.  * removed!
  429.  * removed!
  430.  * 
  431.  *
  432.  * removed!
  433.  * removed!
  434.  * 
  435.  *
  436.  * removed!
  437.  * removed!
  438.  * 
  439.  *
  440.  * removed!
  441.  * removed!
  442.  * 
  443.  *
  444.  * removed!
  445.  * removed!
  446.  * 
  447.  *
  448.  * removed!
  449.  * removed!
  450.  * 
  451.  *
  452.  * removed!
  453.  * removed!
  454.  * 
  455.  *
  456.  * removed!
  457.  * removed!
  458.  * 
  459.  *
  460.  * removed!
  461.  * removed!
  462.  * 
  463.  *
  464.  * removed!
  465.  * removed!
  466.  * 
  467.  *
  468.  * removed!
  469.  * removed!
  470.  * 
  471.  *
  472.  * removed!
  473.  * removed!
  474.  * 
  475.  *
  476.  * removed!
  477.  * removed!
  478.  * 
  479.  *
  480.  * removed!
  481.  * removed!
  482.  * 
  483.  *
  484.  * removed!
  485.  * removed!
  486.  * 
  487.  *
  488.  * removed!
  489.  * removed!
  490.  * 
  491.  *
  492.  * removed!
  493.  * removed!
  494.  * 
  495.  *
  496.  * removed!
  497.  * removed!
  498.  * 
  499.  *
  500.  * removed!
  501.  * removed!
  502.  * 
  503.  *
  504.  * removed!
  505.  * removed!
  506.  * 
  507.  *
  508.  * removed!
  509.  * removed!
  510.  * 
  511.  *
  512.  * removed!
  513.  * removed!
  514.  * 
  515.  *
  516.  * removed!
  517.  * removed!
  518.  * 
  519.  *
  520.  *******************************************************************************/
  521. /**
  522.  * Copyright Notice
  523.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  524.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  525.  *  (It is illegal to remove this copyright notice from this software or any
  526.  *  portion of it)
  527.  */
  528. /**************************************************************
  529.    FILENAME : CallManagementIncoming.c
  530.    PURPOSE     : Call Management application
  531.    REMARKS     : To keep in mind that History must always be saved
  532.               Skipping nodes it to be decided
  533.    AUTHOR      : Ashish
  534.    DATE     : Nov 8,02
  535. **************************************************************/
  536. #include "stdC.h"
  537. #include "MMI_Features.h"
  538. #include "L4Dr.h"
  539. #include "L4Dr1.h"
  540. #include "PixtelDataTypes.h"
  541. #include "DebugInitDef.h"
  542. #include "MMI_trc.h"
  543. #include "ProtocolEvents.h"
  544. #include "EventsGprot.h"
  545. #include "HistoryGprot.h"
  546. #include "SubLCDHistoryGprot.h"
  547. #include "GlobalDefs.h"
  548. #include "GlobalStruct.h"
  549. #include "GlobalScrEnum.h"
  550. #include "WrapperGprot.h"
  551. #include "KeyBrd.h"
  552. #include "TimerEvents.h"
  553. #include "wgui.h"
  554. #include "Wgui_categories_popup.h"
  555. #include "wgui_categories_CM.h"
  556. #include "wgui_categories_util.h"
  557. #include "wgui_categories_inputs.h"
  558. #include "wgui_categories_multimedia.h"
  559. #include "CSP.h"
  560. #include "gdi_include.h"        /* for GDI's color define */
  561. #include "ProfileGprots.h"
  562. #include "BootUp.h"
  563. #include "PowerOnChargerProt.h"
  564. #include "MessagesExDcl.h"
  565. #include "SmsPsHandler.h"
  566. #include "MessagesResourceData.h"
  567. #include "SMSApi.h"
  568. #include "AlarmFrameworkProt.h"
  569. #include "SATDefs.h"
  570. #include "SATGProts.h"
  571. #include "SimDetectionGexdcl.h"
  572. #include "gpioInc.h"
  573. #include "PhoneBookDef.h"
  574. #include "PhoneBookGprot.h"
  575. #include "CallSetUp.h"
  576. #include "mdi_datatype.h"
  577. #include "mdi_audio.h"
  578. #include "AudioInc.h"
  579. #ifdef __CTM_SUPPORT__
  580. #include "TextPhoneDef.h"
  581. #include "TextPhoneProt.h"
  582. #endif /* __CTM_SUPPORT__ */ 
  583. #ifdef __MMI_VOIP__
  584. #include "VoIPGProt.h"
  585. #endif
  586. #include "CallManagementIdDef.h"
  587. #include "CallManagementStruct.h"
  588. #include "CallStructureManagementProt.h"
  589. #include "CmErrorTypes.h"
  590. #include "CmErrorHandlersProt.h"
  591. #include "HistoryHelperProt.h"
  592. #include "RedialHelperGProt.h"
  593. #include "CommonStubsProt.h"
  594. #include "PsCallHelperDef.h"
  595. #include "mmiapi_struct.h"
  596. #include "PsCallHelperGprot.h"
  597. #include "CallManagementGprot.h"
  598. #include "OutgoingCallHelperProt.h"
  599. #include "OutgoingCallManagementProt.h"
  600. #include "MessagesResourceData.h"
  601. #include "IncomingCallManagementProt.h"
  602. #include "PhonebookDef.h"       /* For enum IMG_PHB_DEFAULT */
  603. #include "CommonScreens.h"      /* for popup window timer. */
  604. #ifdef __MMI_BT_HP_SUPPORT__
  605. #include "BTMMIHPGprots.h"
  606. #endif 
  607. #ifdef __MMI_BT_SUPPORT__
  608. #include "BTMMIScrGprots.h"
  609. #endif 
  610. #if defined (JATAAYU_SUPPORT) && defined (WAP_SUPPORT)
  611. #include "ddl.h"
  612. #include "jcutils.h"
  613. #include "jcerror.h"
  614. #include "jdd_tapi.h"
  615. #endif
  616. /* static CM_CALL_HANDLE gCallToEnd;// This is the call Selected for ending */
  617. static CM_CALL_HANDLE gMyCallHandle;
  618. static S8 CallDeflectBuffer[MAX_NUMBER];
  619. static U8 gDTMFConfirmBuf[MAX_DTMFBUF_DIGITS];
  620. static U8 cashSign[8];
  621. static U8 AocBuffer[10];
  622. static pBOOL gAttempToReject = FALSE;
  623. static pBOOL gAttempToAnswer = FALSE;
  624. static pBOOL gAcceptIncoming = FALSE;   /* tells if there is a incoming call waiting to be accepted */
  625. /* static pBOOL gHold2End=FALSE;// tells if there is a pending hold call 2 end */
  626. /* static U16 gIdleScreenDigitsAnyKeyAnswer[MAX_CM_SCREEN_DIGITS_ANYKEY] =
  627.    {
  628.    KEY_0,KEY_1,KEY_2,KEY_3,
  629.    KEY_4,KEY_5,KEY_6,KEY_7,
  630.    KEY_8,KEY_9,KEY_STAR,KEY_POUND,
  631.    KEY_UP_ARROW,
  632.    KEY_DOWN_ARROW,
  633.    KEY_LEFT_ARROW,
  634.    KEY_RIGHT_ARROW,
  635.    KEY_CLEAR, KEY_ENTER, KEY_QUICK_ACS
  636.    }; */
  637. S16 CallDeflectDigitKeyCode = -1;
  638. U16 gSSEvent = 0;
  639. MMI_BOOL gSSEventNotifyPresent = MMI_FALSE;
  640. U16 gSSEventNotify = 0;
  641. extern U8 isEarphonePlugged;
  642. extern U32 gSumACMValue;
  643. extern S8 gUSSDbuf[];
  644. extern S8 UnicodeDTMFPadCallBuffer[];
  645. extern const U16 CMIdleScreenDigits[];
  646. extern PU8 gdispnameForSubLCD;
  647. extern U8 isCSPPresent;
  648. #ifdef WAP_SUPPORT
  649. extern int wap_bearer_csd_is_disc(void);
  650. #endif 
  651. #ifdef __MMI_CLAMSHELL__
  652. extern BOOL IsClamClose(void);
  653. #endif 
  654. extern void show_call_cost_UI(PU8 symbol, PU8 value);
  655. /*****************************************************************************
  656.  * FUNCTION
  657.  *  ReinitalizeIncomingCall
  658.  * DESCRIPTION
  659.  *  To Re-Initialize the Incoming Call Management Application
  660.  * PARAMETERS
  661.  *  void
  662.  * RETURNS
  663.  *  void
  664.  *****************************************************************************/
  665. void ReinitalizeIncomingCall(void)
  666. {
  667.     /*----------------------------------------------------------------*/
  668.     /* Local Variables                                                */
  669.     /*----------------------------------------------------------------*/
  670.     /*----------------------------------------------------------------*/
  671.     /* Code Body                                                      */
  672.     /*----------------------------------------------------------------*/
  673.     SetProtocolEventHandler(PsCBackIncomingCallAccepted, PRT_INCOMINGCALL_ACCEPT_SUCCESS);
  674.     SetProtocolEventHandler(PsCBackCallIncoming, PRT_INCOMINGCALL_EVENT);
  675.     SetProtocolEventHandler(PsCBackCallWait, PRT_INCOMING_CALL_WAIT);
  676.     SetProtocolEventHandler(PsCBackSpeechIndication, PRT_SPEECH_IND_EVENT);
  677.     SetProtocolEventHandler(PsCBackAocIndication, PRT_AOC_EVENT_IND);
  678.     SetProtocolEventHandler(PsCBackNotifySSInd, PRT_NOTIFY_SS_EVENT);
  679.     SetProtocolEventHandler(PsCBackCcbsActivate, PRT_OUTGOING_DISCONNECT_IND);
  680.     SetProtocolEventHandler(PsCBackCCBSInvoked, PRT_CCBS_NOTIFY_IND);
  681.     SetProtocolEventHandler(PsCBackConfirmDTMFString, PRT_DTMF_CONFIRM_IND);
  682.     SetProtocolEventHandler(PsCBackNetworkCallDropped, PRT_NWRK_CALL_RELEASE);
  683.     SetProtocolEventHandler(PsCBackUSSNInd, PRT_USSN_IND);
  684.     SetProtocolEventHandler(PsCBackUSSRInd, PRT_USSR_IND);
  685.     SetProtocolEventHandler(CALLSETClipRsp, PRT_MMI_SS_CLIP_INTERROGATE_IND);
  686.     SetProtocolEventHandler(CALLSETClirRsp, PRT_MMI_SS_CLIR_INTERROGATE_IND);
  687.     SetProtocolEventHandler(CALLSETColpRsp, PRT_MMI_SS_COLP_INTERROGATE_IND);
  688.     SetProtocolEventHandler(CALLSETColrRsp, PRT_MMI_SS_COLR_INTERROGATE_IND);
  689.     SetProtocolEventHandler(CALLSETCnapRsp, PRT_MMI_SS_CNAP_INTERROGATE_IND);
  690.     SetProtocolEventHandler(CALLSETCcbsQueryRsp, PRT_MMI_SS_CCBS_RSP);
  691.     SetProtocolEventHandler(CALLSETEmlppQueryRsp, PRT_MMI_SS_EMLPP_RSP);
  692.     SetProtocolEventHandler(CALLSETWaitingRsp, PRT_MMI_SS_CALL_WAIT_RSP);
  693.     SetProtocolEventHandler(CALLSETForwardRsp, PRT_MMI_SS_CALL_FORWARD_RSP);
  694.     SetProtocolEventHandler(CALLSETBarringRsp, PRT_MMI_SS_CALL_BARRING_RSP);
  695.     SetProtocolEventHandler(CALLSETBarringPassRsp, PRT_MMI_SS_CHANGE_PASSWORD_RSP);
  696. }
  697. /*****************************************************************************
  698.  * FUNCTION
  699.  *  InitIncomingCall
  700.  * DESCRIPTION
  701.  *  To Initialize the Incoming Call Management Application
  702.  *  
  703.  *  This function sets up the handlers required for event flow and
  704.  *  application management
  705.  * PARAMETERS
  706.  *  void
  707.  * RETURNS
  708.  *  void
  709.  *****************************************************************************/
  710. void InitIncomingCall(void)
  711. {
  712.     /*----------------------------------------------------------------*/
  713.     /* Local Variables                                                */
  714.     /*----------------------------------------------------------------*/
  715.     /*----------------------------------------------------------------*/
  716.     /* Code Body                                                      */
  717.     /*----------------------------------------------------------------*/
  718.     ReinitalizeIncomingCall();
  719.     SetHiliteHandler(MITEM_INC_OPT_ANSWER, HiliteMenuIncomingAnswer);
  720.     SetHiliteHandler(MITEM_INC_OPT_DEFLN, HiliteMenuIncomingCallDeflection);
  721.     SetHiliteHandler(MITEM_CCBS_OPT_DIAL, HiliteMenuCCBSDial);
  722.     SetHiliteHandler(MITEM_INC_ACT_OPT_END_ACT, HiliteM2019AllActiveEnd);
  723.     SetHiliteHandler(MITEM_IAH_OPT_END_ACT, HiliteM2019AllActiveEnd);
  724.     SetHiliteHandler(MITEM_IMA_OPT_END_ONE_ACT, HiliteM2011SingleActiveEnd);
  725.     SetHiliteHandler(MITEM_IMAH_OPT_END_ONE_ACT, HiliteM2019AllActiveEnd);
  726.     SetHiliteHandler(MITEM_IMA_OPT_END_ALL_ACT, HiliteMenuEndAllCalls);
  727.     SetHiliteHandler(MITEM_INC_MHLD_OPT_END, HiliteMenuEndAllCalls);
  728.     SetHiliteHandler(MITEM_IAH_OPT_END_ALL, HiliteMenuEndAllCalls);
  729.     SetHiliteHandler(MITEM_INC_HLD_OPT_END, HiliteM2020AllHeldEnd);
  730.     SetHiliteHandler(MITEM_IAH_OPT_END_HLD, HiliteM2020AllHeldEnd);
  731.     SetHiliteHandler(MITEM_IAMH_ALL_HELD_END, HiliteM2020AllHeldEnd);
  732.     SetHiliteHandler(MITEM_INC_ACT_OPT_HOLD_ACT, HiliteM2014Swap);
  733.     SetHiliteHandler(MITEM_IMA_OPT_HOLD_CONF, HiliteM2014Swap);
  734.     SetHiliteHandler(MITEM_INC_HLD_OPT_RTRV, HiliteM2014Swap);
  735.     SetHiliteHandler(MITEM_INC_MHLD_OPT_RTRV, HiliteM2014Swap);
  736.     SetHiliteHandler(MITEM_IAH_OPT_SWAP, HiliteM2014Swap);
  737.     SetHiliteHandler(MITEM_IAH_OPT_CONFER, HiliteM2015Conference);
  738.     SetHiliteHandler(MITEM_IAH_OPT_TRANSFER, HiliteM2017Transfer);
  739.     SetHiliteHandler(MITEM_IMA_OPT_SPLIT, HiliteM2018Split);
  740.     SetHiliteHandler(MITEM_INC_ACT_OPT_MUTE, HiliteM2020Mute);
  741.     SetHiliteHandler(MITEM_INC_ACT_OPT_LOUDSP, HiliteM2023LoudSp);
  742. }
  743. /*****************************************************************************
  744.  * FUNCTION
  745.  *  HiliteMenuIncomingAnswer
  746.  * DESCRIPTION
  747.  *  Hilite function for Incoming Answer
  748.  * PARAMETERS
  749.  *  void
  750.  * RETURNS
  751.  *  void
  752.  *****************************************************************************/
  753. void HiliteMenuIncomingAnswer(void)
  754. {
  755.     /*----------------------------------------------------------------*/
  756.     /* Local Variables                                                */
  757.     /*----------------------------------------------------------------*/
  758.     /*----------------------------------------------------------------*/
  759.     /* Code Body                                                      */
  760.     /*----------------------------------------------------------------*/
  761.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  762.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  763.     SetLeftSoftkeyFunction(KbCBackCallIncomingAccepted, KEY_EVENT_UP);
  764.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  765. }
  766. /*****************************************************************************
  767.  * FUNCTION
  768.  *  HiliteMenuIncomingCallDeflection
  769.  * DESCRIPTION
  770.  *  Hilite function for Call Deflection
  771.  * PARAMETERS
  772.  *  void
  773.  * RETURNS
  774.  *  void
  775.  *****************************************************************************/
  776. void HiliteMenuIncomingCallDeflection(void)
  777. {
  778.     /*----------------------------------------------------------------*/
  779.     /* Local Variables                                                */
  780.     /*----------------------------------------------------------------*/
  781.     /*----------------------------------------------------------------*/
  782.     /* Code Body                                                      */
  783.     /*----------------------------------------------------------------*/
  784.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_HiliteMenuIncomingCallDeflection));
  785.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  786.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  787.     SetLeftSoftkeyFunction(HandleCallDelfectDigitEntry, KEY_EVENT_UP);
  788.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  789. }
  790. /*****************************************************************************
  791.  * FUNCTION
  792.  *  HiliteMenuCCBSDial
  793.  * DESCRIPTION
  794.  *  hilite handler to invoke the function that dials the ccbs call
  795.  * PARAMETERS
  796.  *  void
  797.  * RETURNS
  798.  *  void
  799.  *****************************************************************************/
  800. void HiliteMenuCCBSDial(void)
  801. {
  802.     /*----------------------------------------------------------------*/
  803.     /* Local Variables                                                */
  804.     /*----------------------------------------------------------------*/
  805.     /*----------------------------------------------------------------*/
  806.     /* Code Body                                                      */
  807.     /*----------------------------------------------------------------*/
  808.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_HiliteMenuCCBSDial));
  809.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  810.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  811.     SetLeftSoftkeyFunction(KbCBackCCBSDialCall, KEY_EVENT_UP);
  812.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  813. }
  814. /*****************************************************************************
  815.  * FUNCTION
  816.  *  HiliteMenuEndAllCalls
  817.  * DESCRIPTION
  818.  *  Hilite function End all call
  819.  * PARAMETERS
  820.  *  void
  821.  * RETURNS
  822.  *  void
  823.  *****************************************************************************/
  824. void HiliteMenuEndAllCalls(void)
  825. {
  826.     /*----------------------------------------------------------------*/
  827.     /* Local Variables                                                */
  828.     /*----------------------------------------------------------------*/
  829.     /*----------------------------------------------------------------*/
  830.     /* Code Body                                                      */
  831.     /*----------------------------------------------------------------*/
  832.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_HiliteMenuEndAllCalls));
  833.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  834.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  835.     SetLeftSoftkeyFunction(KbCBackEndAllCallsExceptIncoming, KEY_EVENT_UP);
  836.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  837. }
  838. /*****************************************************************************
  839.  * FUNCTION
  840.  *  PsCBackCallIncoming
  841.  * DESCRIPTION
  842.  *  This function is called back by the protocol stack when there
  843.  *  is an incoming call
  844.  *  
  845.  *  The toHistory is so that the Incoming Call Screen is saved
  846.  * PARAMETERS
  847.  *  info        [?]     
  848.  * RETURNS
  849.  *  void
  850.  *****************************************************************************/
  851. void PsCBackCallIncoming(void *info)
  852. {
  853.     /*----------------------------------------------------------------*/
  854.     /* Local Variables                                                */
  855.     /*----------------------------------------------------------------*/
  856.     /*----------------------------------------------------------------*/
  857.     /* Code Body                                                      */
  858.     /*----------------------------------------------------------------*/
  859.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackCallIncoming));
  860.     ProcessIncomingEvents(CM_PS_CALL_INCOMING, info);
  861. }
  862. /*****************************************************************************
  863.  * FUNCTION
  864.  *  PsCBackCallWait
  865.  * DESCRIPTION
  866.  *  This function is called back by the protocol stack when there
  867.  *  is an incoming call
  868.  *  
  869.  *  The toHistory is so that the Incoming Call Screen is saved
  870.  * PARAMETERS
  871.  *  info        [?]     
  872.  * RETURNS
  873.  *  void
  874.  *****************************************************************************/
  875. void PsCBackCallWait(void *info)
  876. {
  877.     /*----------------------------------------------------------------*/
  878.     /* Local Variables                                                */
  879.     /*----------------------------------------------------------------*/
  880.     /*----------------------------------------------------------------*/
  881.     /* Code Body                                                      */
  882.     /*----------------------------------------------------------------*/
  883.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackCallWait));
  884.     ProcessIncomingEvents(CM_PS_CALL_WAIT, info);
  885. }
  886. /*****************************************************************************
  887.  * FUNCTION
  888.  *  PsCBackNetworkCallDropped
  889.  * DESCRIPTION
  890.  *  This function is called back by the protocol stack when the
  891.  *  Netowrk drops incoming call
  892.  * PARAMETERS
  893.  *  info        [?]     
  894.  * RETURNS
  895.  *  void
  896.  *****************************************************************************/
  897. void PsCBackNetworkCallDropped(void *info)
  898. {
  899.     /*----------------------------------------------------------------*/
  900.     /* Local Variables                                                */
  901.     /*----------------------------------------------------------------*/
  902.     /*----------------------------------------------------------------*/
  903.     /* Code Body                                                      */
  904.     /*----------------------------------------------------------------*/
  905.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackNetworkCallDropped));
  906.     if (GetInternalAlert() == TRUE)
  907.     {
  908.         StopInternalOutgoingTone();
  909.     }
  910. #if defined (JATAAYU_SUPPORT) && defined (WAP_SUPPORT)
  911. mmi_jdd_tapi_make_call_result(JC_ERR_TAPI_NETWORK_UNREACHABLE);
  912. #endif
  913.     ProcessIncomingEvents(CM_PS_NWK_CALL_DROP, info);
  914. }
  915. /*****************************************************************************
  916.  * FUNCTION
  917.  *  PsCBackActivatedCCBS
  918.  * DESCRIPTION
  919.  *  This function is called back by the protocol stack when there
  920.  *  CCBS activation response is received
  921.  * PARAMETERS
  922.  *  info        [?]     
  923.  * RETURNS
  924.  *  void
  925.  *****************************************************************************/
  926. void PsCBackActivatedCCBS(void *info)
  927. {
  928.     /*----------------------------------------------------------------*/
  929.     /* Local Variables                                                */
  930.     /*----------------------------------------------------------------*/
  931.     U16 result;
  932.     /*----------------------------------------------------------------*/
  933.     /* Code Body                                                      */
  934.     /*----------------------------------------------------------------*/
  935.     if (CheckChldRequestSuccess(info, &result))
  936.     {
  937.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_PsCBackActivatedCCBS1));
  938.         ProcessIncomingEvents(CM_PS_ACTIVATED_CCBS, info);
  939.     }
  940.     else
  941.     {
  942.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_PsCBackActivatedCCBS2));
  943.         ProcessIncomingFailureEvents(CM_PS_ACTIVATED_CCBS, result);
  944.     }
  945. }
  946. /*****************************************************************************
  947.  * FUNCTION
  948.  *  PsCBackCcbsActivate
  949.  * DESCRIPTION
  950.  *  This function is called back by the protocol stack when there
  951.  *  is outgoing call disconnect indication(CCBS)
  952.  * PARAMETERS
  953.  *  info        [?]     
  954.  * RETURNS
  955.  *  void
  956.  *****************************************************************************/
  957. void PsCBackCcbsActivate(void *info)
  958. {
  959.     /*----------------------------------------------------------------*/
  960.     /* Local Variables                                                */
  961.     /*----------------------------------------------------------------*/
  962.     U16 result;
  963.     /*----------------------------------------------------------------*/
  964.     /* Code Body                                                      */
  965.     /*----------------------------------------------------------------*/
  966.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackCcbsActivate));
  967.     result = CheckRspCcbsFlag(info);
  968.     if (result == TRUE)
  969.     {
  970.         ProcessIncomingEvents(CM_PS_CCBS_ACTIVATE, info);
  971.     }
  972. }
  973. /*****************************************************************************
  974.  * FUNCTION
  975.  *  PsCBackCCBSInvoked
  976.  * DESCRIPTION
  977.  *  This function is called back by the protocol stack when CCBS
  978.  *  notification is there
  979.  * PARAMETERS
  980.  *  info        [?]     
  981.  * RETURNS
  982.  *  void
  983.  *****************************************************************************/
  984. void PsCBackCCBSInvoked(void *info)
  985. {
  986.     /*----------------------------------------------------------------*/
  987.     /* Local Variables                                                */
  988.     /*----------------------------------------------------------------*/
  989.     /*----------------------------------------------------------------*/
  990.     /* Code Body                                                      */
  991.     /*----------------------------------------------------------------*/
  992.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackCCBSInvoked));
  993.     SetCCBSFlag(TRUE);
  994.     ProcessIncomingEvents(CM_PS_CCBS_INVOKE, info);
  995. }
  996. /*****************************************************************************
  997.  * FUNCTION
  998.  *  PsCBackNotifySSInd
  999.  * DESCRIPTION
  1000.  *  This function is intended for registering no on operation
  1001.  *  for PS Callback
  1002.  * PARAMETERS
  1003.  *  info        [?]     
  1004.  * RETURNS
  1005.  *  void
  1006.  *****************************************************************************/
  1007. void PsCBackNotifySSInd(void *info)
  1008. {
  1009.     /*----------------------------------------------------------------*/
  1010.     /* Local Variables                                                */
  1011.     /*----------------------------------------------------------------*/
  1012.     /*----------------------------------------------------------------*/
  1013.     /* Code Body                                                      */
  1014.     /*----------------------------------------------------------------*/
  1015.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackNotifySSInd));
  1016.     ProcessIncomingEvents(CM_PS_SS_EVENT, info);
  1017. }
  1018. /*****************************************************************************
  1019.  * FUNCTION
  1020.  *  PsCBackSpeechIndication
  1021.  * DESCRIPTION
  1022.  *  This function is called back by the protocol stack when the
  1023.  *  Held Call is made active.
  1024.  * PARAMETERS
  1025.  *  info        [?]     
  1026.  * RETURNS
  1027.  *  void
  1028.  *****************************************************************************/
  1029. void PsCBackSpeechIndication(void *info)
  1030. {
  1031.     /*----------------------------------------------------------------*/
  1032.     /* Local Variables                                                */
  1033.     /*----------------------------------------------------------------*/
  1034.     /*----------------------------------------------------------------*/
  1035.     /* Code Body                                                      */
  1036.     /*----------------------------------------------------------------*/
  1037.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackSpeechIndication));
  1038.     ProcessIncomingEvents(CM_PS_SPEECH_IND, info);
  1039. }
  1040. /*****************************************************************************
  1041.  * FUNCTION
  1042.  *  PsCBackAocIndication
  1043.  * DESCRIPTION
  1044.  *  This function is called back by the protocol stack when the AOC
  1045.  *  indication is sent by the PS
  1046.  *  
  1047.  *  Info passed to the function is the call handle
  1048.  * PARAMETERS
  1049.  *  info        [?]     
  1050.  * RETURNS
  1051.  *  void
  1052.  *****************************************************************************/
  1053. void PsCBackAocIndication(void *info)
  1054. {
  1055.     /*----------------------------------------------------------------*/
  1056.     /* Local Variables                                                */
  1057.     /*----------------------------------------------------------------*/
  1058.     /*----------------------------------------------------------------*/
  1059.     /* Code Body                                                      */
  1060.     /*----------------------------------------------------------------*/
  1061.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackAocIndication));
  1062.     ProcessIncomingEvents(CM_PS_AOC_INDICATION, info);
  1063. }
  1064. /*****************************************************************************
  1065.  * FUNCTION
  1066.  *  PsCBackConfirmDTMFString
  1067.  * DESCRIPTION
  1068.  *  This is CBack for -- Indication
  1069.  * PARAMETERS
  1070.  *  info        [?]         
  1071.  *  data(?)     [IN]        From PS
  1072.  * RETURNS
  1073.  *  void
  1074.  *****************************************************************************/
  1075. void PsCBackConfirmDTMFString(void *info)
  1076. {
  1077.     /*----------------------------------------------------------------*/
  1078.     /* Local Variables                                                */
  1079.     /*----------------------------------------------------------------*/
  1080.     MMI_DTMF_CONFIRM_IND *msg = (MMI_DTMF_CONFIRM_IND*) info;
  1081.     /*----------------------------------------------------------------*/
  1082.     /* Code Body                                                      */
  1083.     /*----------------------------------------------------------------*/
  1084.     memset(gDTMFConfirmBuf, 0, MAX_DTMFBUF_DIGITS);
  1085.     strcpy((PS8) gDTMFConfirmBuf, (PS8) msg->digits);
  1086.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackAocIndication));
  1087. if (GetExitScrnID() == SCR_CM_ACTIVECALLSCREEN)
  1088.         SetGroupKeyHandler(
  1089.             NULL,
  1090.             (PU16) CMIdleScreenDigits,
  1091.             MAX_CM_SCREEN_DIGITS - 1,
  1092.             KEY_EVENT_DOWN);
  1093.     #if ( (defined  __MMI_WGUI_CSK_ENABLE__) && (defined __MMI_TOUCH_SCREEN__) )
  1094.         SetCenterSoftkeyFunction(NULL, KEY_EVENT_UP);
  1095.     #endif 
  1096.     ProcessIncomingEvents(CM_PS_CONFIRM_DTMF_STRING, NULL);
  1097. }
  1098. /*****************************************************************************
  1099.  * FUNCTION
  1100.  *  NotifyCMClampOpen
  1101.  * DESCRIPTION
  1102.  *  Clamp Open Handler for CM
  1103.  * PARAMETERS
  1104.  *  void
  1105.  * RETURNS
  1106.  *  void
  1107.  *****************************************************************************/
  1108. #ifdef __MMI_CLAMSHELL__
  1109. void NotifyCMClampOpen(void)
  1110. {
  1111.     /*----------------------------------------------------------------*/
  1112.     /* Local Variables                                                */
  1113.     /*----------------------------------------------------------------*/
  1114.     /*----------------------------------------------------------------*/
  1115.     /* Code Body                                                      */
  1116.     /*----------------------------------------------------------------*/
  1117.     if (GetCurrentState() == CM_INCOMING_STATE)
  1118.     {
  1119.         if (TRUE == (((MMI_ANSWERING_MODE*) GetAnswerMode())->coverAnswer))
  1120.         {
  1121.             KbCBackCallIncomingAccepted();
  1122.         }
  1123.     #ifdef __MMI_INCOMING_CALL_VIDEO__
  1124.         else
  1125.         {
  1126.             CM_CALL_HANDLE handle;
  1127.             U16 imgId;
  1128.             handle = GetIncomingCallHandle();
  1129.             imgId = GetCallImgId(handle);
  1130.             /* overwrite sub LCD with static image */
  1131.             if ((imgId & 0x8000) || ((imgId & 0x3fff) >= VDO_ID_PHB_MTCALL_1))
  1132.             {
  1133.                 /* user defined video file or system default video resource */
  1134.                 /* draw static sub LCD */
  1135.                 DisableCategory17VideoUpdate();
  1136.                 ShowCategory332Screen(IMG_CM_STATE_CONNECTED);
  1137.                 EnableCategory17VideoUpdate();
  1138.             }
  1139.         }
  1140.     #endif /* __MMI_INCOMING_CALL_VIDEO__ */ 
  1141.     }
  1142. }
  1143. /*****************************************************************************
  1144.  * FUNCTION
  1145.  *  NotifyCMClampClose
  1146.  * DESCRIPTION
  1147.  *  Clamp Close Handler for CM
  1148.  * PARAMETERS
  1149.  *  void
  1150.  * RETURNS
  1151.  *  void
  1152.  *****************************************************************************/
  1153. void NotifyCMClampClose(void)
  1154. {
  1155.     /*----------------------------------------------------------------*/
  1156.     /* Local Variables                                                */
  1157.     /*----------------------------------------------------------------*/
  1158.     /*----------------------------------------------------------------*/
  1159.     /* Code Body                                                      */
  1160.     /*----------------------------------------------------------------*/
  1161.     if (isEarphonePlugged
  1162. #if defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__)
  1163.         || mmi_bt_is_incall_aud_swap2bt() == MMI_TRUE
  1164. #endif 
  1165.         )
  1166.     {
  1167.         return;
  1168.     }
  1169.     if (isInCall())
  1170.     {
  1171. cm_p->history_info.IsClamCloseEndCall = MMI_TRUE;
  1172.     }
  1173.     DeInitCM();
  1174. }
  1175. #endif /* __MMI_CLAMSHELL__ */ 
  1176. /*****************************************************************************
  1177.  * FUNCTION
  1178.  *  HangupAllCalls
  1179.  * DESCRIPTION
  1180.  *  Hangs Up All Calls
  1181.  * PARAMETERS
  1182.  *  void
  1183.  * RETURNS
  1184.  *  void
  1185.  *****************************************************************************/
  1186. void HangupAllCalls(void)
  1187. {
  1188.     /*----------------------------------------------------------------*/
  1189.     /* Local Variables                                                */
  1190.     /*----------------------------------------------------------------*/
  1191.     CM_CALL_HANDLE handle;
  1192.     /*----------------------------------------------------------------*/
  1193.     /* Code Body                                                      */
  1194.     /*----------------------------------------------------------------*/
  1195.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_HangupAllCalls));
  1196. #ifdef WAP_SUPPORT
  1197.     if (GetWapCallPresent() && wap_bearer_csd_is_disc())
  1198.     {
  1199.         return;
  1200.     }
  1201. #endif /* WAP_SUPPORT */ 
  1202.     /* Start by Julia: Drop call refinement */
  1203.     if (GetDisconnectingCallHandle() != -1)
  1204.     {
  1205.         ReleaseCall();
  1206.         return;
  1207.     }
  1208.     SetNotifySSFlag(FALSE);
  1209.     /* End by Julia */
  1210.     if (GetCurrentState() == CM_OUTGOING_STATE && GetTotalCallCount() == 1)
  1211.     {
  1212.         handle = GetOutgoingCallHandle();
  1213.         SetDropRequestFlag(TRUE);
  1214.         if ((GetCallflag(handle, TRUE) & CM_HANGUP_REQUESTED) == 0)
  1215.         {
  1216.             OutgoingProcessCMEvent(CM_KB_HANGUPREQ, &handle);
  1217.         }
  1218.     }
  1219.     /* hangup single MT call should use reject instead of rel all */
  1220.     else if (GetCurrentState() == CM_INCOMING_STATE && GetTotalCallCount() == 1
  1221.             && gAttempToAnswer == FALSE)
  1222.     {
  1223.         KbCBackCallIncomingRejected();
  1224.     }
  1225.     else
  1226.     {
  1227.         U8 flag;
  1228.         /* swapping can't decide which call is active and held, 
  1229.            issue rel all req instead */
  1230.         flag = GetAllCallFlags();
  1231.         if ((GetTotalActiveCallCount() > 0) && (GetTotalHoldCallCount() > 0) &&
  1232.             (((flag & CM_SWAP_REQUESTED) != 0) || ((flag & CM_CONF_REQUESTED) != 0) ||
  1233.              ((flag & CM_ECT_REQUESTED) != 0)))
  1234.         {
  1235.             SetAllCallsHangupFlag();
  1236.             ProcessIncomingEvents(CM_KB_HANG_ALL_CALLS, NULL);
  1237.         }
  1238.     #ifdef __MMI_CLAMSHELL__
  1239.         /* attemp to answer waiting call and press END key 
  1240.            should rel all calls because we can't be sure of 
  1241.            current call state and rel active or rel held */
  1242.         else if (GetCurrentState() == CM_INCOMING_STATE && GetTotalCallCount() > 1
  1243.                  && IsClamClose() == FALSE && gAttempToAnswer == FALSE)
  1244.         {
  1245.             KbCBackCallIncomingRejected();
  1246.         }
  1247.     #endif /* __MMI_CLAMSHELL__ */ 
  1248.         else if (GetChldReqSent() == 0)
  1249.         {
  1250.             if ((GetTotalActiveCallCount() > 0) && (GetTotalHoldCallCount() > 0) &&
  1251.                 (((flag & CM_SWAP_REQUESTED) == 0) || ((flag & CM_CONF_REQUESTED) == 0))
  1252.         #ifdef __MMI_CLAMSHELL__
  1253.                 && IsClamClose() == FALSE
  1254.         #endif 
  1255.                 )
  1256.             {
  1257.                 /* clam open */
  1258.                 /* rel active and accept */
  1259.                 ProcessIncomingEvents(CM_KB_END_ALL_ACTIVE_RETRIEVE_HELD, NULL);
  1260.                 return;
  1261.             }
  1262.         }
  1263.             SetAllCallsHangupFlag();
  1264.             ProcessIncomingEvents(CM_KB_HANG_ALL_CALLS, NULL);
  1265.     }
  1266. }
  1267. /*****************************************************************************
  1268.  * FUNCTION
  1269.  *  KbCBackCallIncomingAccepted
  1270.  * DESCRIPTION
  1271.  *  This function is called back by the keyboard handler
  1272.  *  when the user selects accepts incoming call
  1273.  * PARAMETERS
  1274.  *  void
  1275.  * RETURNS
  1276.  *  void
  1277.  *****************************************************************************/
  1278. void KbCBackCallIncomingAccepted(void)
  1279. {
  1280.     /*----------------------------------------------------------------*/
  1281.     /* Local Variables                                                */
  1282.     /*----------------------------------------------------------------*/
  1283.     CM_CALL_HANDLE handle;
  1284.     /*----------------------------------------------------------------*/
  1285.     /* Code Body                                                      */
  1286.     /*----------------------------------------------------------------*/
  1287.     if (g_charbat_context.LowBatteryTxProhibitFlag == 1)
  1288.     {
  1289.         SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_TALK_DURCNT_PROHIBIT);
  1290.     }
  1291.     else
  1292.     {
  1293.         SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_TALK_DURCNT_NORMAL);
  1294.     }
  1295.     g_charbat_context.LowBatteryCutOffCallCnt = 0;
  1296.     if ((GetTotalActiveCallCount() > 0 && GetTotalHoldCallCount() > 0) || 
  1297.      CheckAllCallflag() == TRUE ||
  1298.      GetIncomingCallType() != CSMCC_VOICE_CALL)
  1299.     {
  1300.         ShowCallManagementErrorMessage(NO_ACTIVE_CALL);
  1301.         return;
  1302.     }
  1303.     /* preempt auto answer by manual answer before timeout */
  1304.     if (GetAutoAnswerFlag() == TRUE)
  1305.     {
  1306.         StopTimer(CM_AUTOANSWER_NOTIFYDURATION_TIMER);
  1307.         SetAutoAnswerFlag(FALSE);
  1308.     }
  1309.     if (GetWapCallPresent() || GetActiveCallType() == CM_DATA_CALL
  1310. #ifdef __CTM_SUPPORT__
  1311.         || IsScreenPresent(SCR_CTM_TALKING)
  1312. #endif 
  1313.         )
  1314.     {
  1315.         KbCBackEndActiveAcceptIncomingCall();
  1316.         ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1317.         ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_UP);
  1318.         ClearKeyHandler(KEY_VOL_UP, KEY_EVENT_DOWN);
  1319.         ClearKeyHandler(KEY_VOL_UP, KEY_EVENT_UP);
  1320.         return;
  1321.     }
  1322.     handle = GetIncomingCallHandle();
  1323.     if ((GetCallflag(handle, TRUE) & CM_HANGUP_REQUESTED))
  1324.     {
  1325.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_KbCBackCallIncomingAccepted));
  1326.         return;
  1327.     }
  1328. #ifdef __MMI_BT_HP_SUPPORT__
  1329.     if (mmi_bt_get_sco_state() != MMIBT_SCO_CON)
  1330.     {
  1331.         mmi_bt_set_answer_by_ag_flag(MMI_TRUE);
  1332.     }
  1333. #endif /* __MMI_BT_HP_SUPPORT__ */ 
  1334.     UnSilencethePhone();
  1335.     StopIncomingCallIndication();
  1336.     ProcessIncomingEvents(CM_KB_INCOMING_CALL_ACCEPT, NULL);
  1337.     ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1338.     ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_UP);
  1339.     ClearKeyHandler(KEY_VOL_UP, KEY_EVENT_DOWN);
  1340.     ClearKeyHandler(KEY_VOL_UP, KEY_EVENT_UP);
  1341. }
  1342. /*****************************************************************************
  1343.  * FUNCTION
  1344.  *  KbCBackCallIncomingRejected
  1345.  * DESCRIPTION
  1346.  *  This function is called back by the keyboard handler
  1347.  *  when the user selects rejects incoming call
  1348.  * PARAMETERS
  1349.  *  void
  1350.  * RETURNS
  1351.  *  void
  1352.  *****************************************************************************/
  1353. void KbCBackCallIncomingRejected(void)
  1354. {
  1355.     /*----------------------------------------------------------------*/
  1356.     /* Local Variables                                                */
  1357.     /*----------------------------------------------------------------*/
  1358.     /*----------------------------------------------------------------*/
  1359.     /* Code Body                                                      */
  1360.     /*----------------------------------------------------------------*/
  1361.     gAttempToReject = TRUE;
  1362.     UnSilencethePhone();
  1363.     StopIncomingCallIndication();
  1364.     ProcessIncomingEvents(CM_KB_INCOMING_CALL_REJECT, NULL);
  1365.     ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1366.     ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_UP);
  1367.     ClearKeyHandler(KEY_VOL_UP, KEY_EVENT_DOWN);
  1368.     ClearKeyHandler(KEY_VOL_UP, KEY_EVENT_UP);
  1369.     /* if (GetExitScrnID() ==  ITEMSCR_INCOMING_CALL)
  1370.        {
  1371.        #ifdef __MMI_INCOMING_CALL_VIDEO__
  1372.        CM_CALL_HANDLE handle;
  1373.        U16 imgId;
  1374.        
  1375.        handle = GetIncomingCallHandle();
  1376.        imgId = GetCallImgId(handle);
  1377.        
  1378.        // pause video 
  1379.        if ((imgId & 0x8000) || ((imgId & 0x3fff) >= VDO_ID_PHB_MTCALL_1))
  1380.        StopCategory17Video();
  1381.        else
  1382.        #endif
  1383.        MOMTHideAnimation();
  1384.        } */
  1385. }
  1386. #ifdef __MMI_SIDEKEY_SUPPRESS_RING__
  1387. /*****************************************************************************
  1388.  * FUNCTION
  1389.  *  KbCBackCallIncomingRejectedNoTone
  1390.  * DESCRIPTION
  1391.  *  Reject MT call and stop ring tone when long press
  1392.  *  or double press side down key
  1393.  * PARAMETERS
  1394.  *  void
  1395.  * RETURNS
  1396.  *  void
  1397.  *****************************************************************************/
  1398. void KbCBackCallIncomingRejectedNoTone(void)
  1399. {
  1400.     /*----------------------------------------------------------------*/
  1401.     /* Local Variables                                                */
  1402.     /*----------------------------------------------------------------*/
  1403.     /*----------------------------------------------------------------*/
  1404.     /* Code Body                                                      */
  1405.     /*----------------------------------------------------------------*/
  1406.     gAttempToReject = TRUE;
  1407.     UnSilencethePhone();
  1408.     //ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_UP);
  1409.     ClearKeyHandler(KEY_RSK, KEY_EVENT_UP);  //jerson modify 20070622
  1410.     ProcessIncomingEvents(CM_KB_INCOMING_CALL_REJECT, NULL);
  1411. }
  1412. /*****************************************************************************
  1413.  * FUNCTION
  1414.  *  KbCBackCallIncomingSuppressTone
  1415.  * DESCRIPTION
  1416.  *  Set key handler for side down key in its first press
  1417.  * PARAMETERS
  1418.  *  void
  1419.  * RETURNS
  1420.  *  void
  1421.  *****************************************************************************/
  1422. void KbCBackCallIncomingSuppressTone(void)
  1423. {
  1424.     /*----------------------------------------------------------------*/
  1425.     /* Local Variables                                                */
  1426.     /*----------------------------------------------------------------*/
  1427.     /*----------------------------------------------------------------*/
  1428.     /* Code Body                                                      */
  1429.     /*----------------------------------------------------------------*/
  1430.     //SetKeyHandler(KbCBackCallIncomingRejectedNoTone, KEY_VOL_DOWN, KEY_EVENT_UP);
  1431.     SetKeyHandler(KbCBackCallIncomingRejectedNoTone, KEY_RSK, KEY_EVENT_UP);  //jerson modify 20070622
  1432. }
  1433. #endif /* __MMI_SIDEKEY_SUPPRESS_RING__ */ 
  1434. /*****************************************************************************
  1435.  * FUNCTION
  1436.  *  KbCBackEndActiveAcceptIncomingCall
  1437.  * DESCRIPTION
  1438.  *  End active and accept waiting call
  1439.  * PARAMETERS
  1440.  *  void
  1441.  * RETURNS
  1442.  *  void
  1443.  *****************************************************************************/
  1444. void KbCBackEndActiveAcceptIncomingCall(void)
  1445. {
  1446.     /*----------------------------------------------------------------*/
  1447.     /* Local Variables                                                */
  1448.     /*----------------------------------------------------------------*/
  1449.     /*----------------------------------------------------------------*/
  1450.     /* Code Body                                                      */
  1451.     /*----------------------------------------------------------------*/
  1452.     StopIncomingCallIndication();
  1453.     ProcessIncomingEvents(CM_KB_END_ACTIVE_ACCEPT_INCOMING, NULL);
  1454. }
  1455. /**************************************************************
  1456.    FUNCTION NAME     : KbCBackEndSelectiveActiveCall(void)
  1457.    PURPOSE           : This function is called back by the keyboard handler
  1458.                          when the user selects option to End an active call
  1459.    INPUT PARAMETERS  : nil
  1460.    OUTPUT PARAMETERS : nil
  1461.    RETURNS           : void
  1462.    REMARKS           : nil
  1463. **************************************************************/
  1464. /* void KbCBackEndSelectiveActiveCall(void)
  1465.    {
  1466.    if (gCallToEnd!=-1)
  1467.    MakePsEndSelectiveCall ((void*)PsCBackselectedCallEnded, gCallToEnd);
  1468.    else
  1469.    PRINT_INFORMATION(("CM_TEST File: [%s]  Line: [%d] <<No Call To End>>n",__FILE__,__LINE__));
  1470.    } */
  1471. /*****************************************************************************
  1472.  * FUNCTION
  1473.  *  KbCBackEndAllCallsExceptIncoming
  1474.  * DESCRIPTION
  1475.  *  This function is called back by the keyboard handler
  1476.  *  when the user selects rejects incoming call
  1477.  * PARAMETERS
  1478.  *  void
  1479.  * RETURNS
  1480.  *  void
  1481.  *****************************************************************************/
  1482. void KbCBackEndAllCallsExceptIncoming(void)
  1483. {
  1484.     /*----------------------------------------------------------------*/
  1485.     /* Local Variables                                                */
  1486.     /*----------------------------------------------------------------*/
  1487.     /*----------------------------------------------------------------*/
  1488.     /* Code Body                                                      */
  1489.     /*----------------------------------------------------------------*/
  1490.     UnSilencethePhone();
  1491.     OutgoingProcessCMEvent(CM_KB_HANGUPALLREQ, (void*)NULL);
  1492. }
  1493. /*****************************************************************************
  1494.  * FUNCTION
  1495.  *  IgnoreCCBS
  1496.  * DESCRIPTION
  1497.  *  To invoke the function that ignore the CCBS invoke
  1498.  *  
  1499.  *  yet to  implement
  1500.  * PARAMETERS
  1501.  *  void
  1502.  * RETURNS
  1503.  *  void
  1504.  *****************************************************************************/
  1505. void IgnoreCCBS(void)
  1506. {
  1507.     /*----------------------------------------------------------------*/
  1508.     /* Local Variables                                                */
  1509.     /*----------------------------------------------------------------*/
  1510.     /*----------------------------------------------------------------*/
  1511.     /* Code Body                                                      */
  1512.     /*----------------------------------------------------------------*/
  1513.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_IgnoreCCBS));
  1514.     SetDialIndication(FALSE);
  1515.     SetActivatedCcbsFlag(FALSE);
  1516.     DropRequest();
  1517. }
  1518. /*****************************************************************************
  1519.  * FUNCTION
  1520.  *  ActivateCCBS
  1521.  * DESCRIPTION
  1522.  *  To invoke the function that activates the CCBS
  1523.  *  
  1524.  *  yet to  implement
  1525.  * PARAMETERS
  1526.  *  void
  1527.  * RETURNS
  1528.  *  void
  1529.  *****************************************************************************/
  1530. void ActivateCCBS(void)
  1531. {
  1532.     /*----------------------------------------------------------------*/
  1533.     /* Local Variables                                                */
  1534.     /*----------------------------------------------------------------*/
  1535.     /*----------------------------------------------------------------*/
  1536.     /* Code Body                                                      */
  1537.     /*----------------------------------------------------------------*/
  1538.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ActivateCCBS));
  1539.     SetActivatedCcbsFlag(TRUE);
  1540.     MakePsActivateCCBS((void*)PsCBackActivatedCCBS);
  1541. }
  1542. /*****************************************************************************
  1543.  * FUNCTION
  1544.  *  KbCBackCCBSDialCall
  1545.  * DESCRIPTION
  1546.  *  This function is called back by the keyboard handler
  1547.  *  when the user selects dial ccbs
  1548.  * PARAMETERS
  1549.  *  void
  1550.  * RETURNS
  1551.  *  void
  1552.  *****************************************************************************/
  1553. void KbCBackCCBSDialCall(void)
  1554. {
  1555.     /*----------------------------------------------------------------*/
  1556.     /* Local Variables                                                */
  1557.     /*----------------------------------------------------------------*/
  1558.     /*----------------------------------------------------------------*/
  1559.     /* Code Body                                                      */
  1560.     /*----------------------------------------------------------------*/
  1561.     UnSilencethePhone();
  1562.     StopIncomingCallIndication();
  1563.     CCBSUpdateCallInfo();
  1564.     ProcessIncomingEvents(CM_PS_CCBS_INVOKE_DIAL, NULL);
  1565.     ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1566.     ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_UP);
  1567.     ClearKeyHandler(KEY_VOL_UP, KEY_EVENT_DOWN);
  1568.     ClearKeyHandler(KEY_VOL_UP, KEY_EVENT_UP);
  1569. }
  1570. /*****************************************************************************
  1571.  * FUNCTION
  1572.  *  KbCBackCCBSInvokeRejected
  1573.  * DESCRIPTION
  1574.  *  This function is called back by the keyboard handler
  1575.  *  when the user selects rejects ccbs invoke
  1576.  * PARAMETERS
  1577.  *  void
  1578.  * RETURNS
  1579.  *  void
  1580.  *****************************************************************************/
  1581. void KbCBackCCBSInvokeRejected(void)
  1582. {
  1583.     /*----------------------------------------------------------------*/
  1584.     /* Local Variables                                                */
  1585.     /*----------------------------------------------------------------*/
  1586.     /*----------------------------------------------------------------*/
  1587.     /* Code Body                                                      */
  1588.     /*----------------------------------------------------------------*/
  1589.     UnSilencethePhone();
  1590.     StopIncomingCallIndication();
  1591.     ProcessIncomingEvents(CM_PS_CCBS_INVOKE_REJECT, NULL);
  1592.     ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1593.     ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_UP);
  1594.     ClearKeyHandler(KEY_VOL_UP, KEY_EVENT_DOWN);
  1595.     ClearKeyHandler(KEY_VOL_UP, KEY_EVENT_UP);
  1596. }
  1597. /*****************************************************************************
  1598.  * FUNCTION
  1599.  *  IgnoreDTMFStringAndGoBackHistory
  1600.  * DESCRIPTION
  1601.  *  cancels sending dtmf string
  1602.  * PARAMETERS
  1603.  *  void
  1604.  * RETURNS
  1605.  *  void
  1606.  *****************************************************************************/
  1607. void IgnoreDTMFStringAndGoBackHistory(void)
  1608. {
  1609.     /*----------------------------------------------------------------*/
  1610.     /* Local Variables                                                */
  1611.     /*----------------------------------------------------------------*/
  1612.     /*----------------------------------------------------------------*/
  1613.     /* Code Body                                                      */
  1614.     /*----------------------------------------------------------------*/
  1615.     PRINT_INFORMATION(("IgnoreDTMFStringAndGoBackHistoryn"));
  1616.     SetNoSave();
  1617.     GoBackHistory();
  1618. }
  1619. /*****************************************************************************
  1620.  * FUNCTION
  1621.  *  ConfirmDTMFString
  1622.  * DESCRIPTION
  1623.  *  Send confirm dtmf notification to ps
  1624.  * PARAMETERS
  1625.  *  void
  1626.  * RETURNS
  1627.  *  void
  1628.  *****************************************************************************/
  1629. void ConfirmDTMFString(void)
  1630. {
  1631.     /*----------------------------------------------------------------*/
  1632.     /* Local Variables                                                */
  1633.     /*----------------------------------------------------------------*/
  1634.     /*----------------------------------------------------------------*/
  1635.     /* Code Body                                                      */
  1636.     /*----------------------------------------------------------------*/
  1637.     SetNoSave();
  1638.     MakePsSendDTMFString(gDTMFConfirmBuf);
  1639.     StartTimer(CM_NOTIFYDURATION_TIMER, 1, GoBackfromNotifyScr);
  1640. }
  1641. /*****************************************************************************
  1642.  * FUNCTION
  1643.  *  SetKeysForPOPUp
  1644.  * DESCRIPTION
  1645.  *  Sets Group Handler for all Keys on Popup
  1646.  * PARAMETERS
  1647.  *  void
  1648.  * RETURNS
  1649.  *  void
  1650.  *****************************************************************************/
  1651. void SetKeysForPOPUp(void)
  1652. {
  1653.     /*----------------------------------------------------------------*/
  1654.     /* Local Variables                                                */
  1655.     /*----------------------------------------------------------------*/
  1656.     /*----------------------------------------------------------------*/
  1657.     /* Code Body                                                      */
  1658.     /*----------------------------------------------------------------*/
  1659.     SetGroupKeyHandler((FuncPtr) POPUPHandler, (PU16) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_DOWN);
  1660.     SetKeyHandler(HangupAllCalls, KEY_END, KEY_EVENT_DOWN);
  1661. }
  1662. /*****************************************************************************
  1663.  * FUNCTION
  1664.  *  POPUPHandler
  1665.  * DESCRIPTION
  1666.  *  Group Key Handler for all Keys on CM Popups
  1667.  * PARAMETERS
  1668.  *  void
  1669.  * RETURNS
  1670.  *  void
  1671.  *****************************************************************************/
  1672. void POPUPHandler(void)
  1673. {
  1674.     /*----------------------------------------------------------------*/
  1675.     /* Local Variables                                                */
  1676.     /*----------------------------------------------------------------*/
  1677.     /*----------------------------------------------------------------*/
  1678.     /* Code Body                                                      */
  1679.     /*----------------------------------------------------------------*/
  1680.     StopTimer(CM_NOTIFYDURATION_TIMER);
  1681.     GoBackfromNotifyScr();
  1682. }
  1683. /*****************************************************************************
  1684.  * FUNCTION
  1685.  *  ProcessHeadsetKeyPress
  1686.  * DESCRIPTION
  1687.  *  HeadSet Key Handling Depending on various conditions
  1688.  * PARAMETERS
  1689.  *  void
  1690.  * RETURNS
  1691.  *  void
  1692.  *****************************************************************************/
  1693. extern void mmi_frm_sms_abort_sms(void);
  1694. extern U16 GetCurrScreenID(void);
  1695. void ProcessHeadsetKeyPress(void)
  1696. {
  1697.     /*----------------------------------------------------------------*/
  1698.     /* Local Variables                                                */
  1699.     /*----------------------------------------------------------------*/
  1700.     /*----------------------------------------------------------------*/
  1701.     /* Code Body                                                      */
  1702.     /*----------------------------------------------------------------*/
  1703.     if ((GetCurrScreenID() == SCR_ID_MSG_SENDING) && isInCall())
  1704.     {
  1705.         mmi_frm_sms_abort_sms();
  1706.     }
  1707.     else if (GetCurrentState() == CM_INCOMING_STATE)
  1708.     {
  1709.         if (GetTotalActiveCallCount() >= 1 && GetTotalHoldCallCount() >= 1)
  1710.         {
  1711.             SwapCall();
  1712.         }
  1713.         else if (GetTotalCallCount() > 1)
  1714.         {
  1715.             /* more than 1 call, auto answer can't work */
  1716.             if ((gAttempToReject == FALSE) && (gAttempToAnswer == FALSE))
  1717.             {
  1718.                 KbCBackCallIncomingAccepted();
  1719.             }
  1720.         }
  1721.         else
  1722.         {
  1723.             if ((gAttempToReject == FALSE) && (gAttempToAnswer == FALSE) && (GetAutoAnswerFlag() == 0))
  1724.             {
  1725.                 KbCBackCallIncomingAccepted();
  1726.             }
  1727.         }
  1728.     }
  1729.     else if (GetCurrentState() == CM_OUTGOING_STATE)
  1730.     {
  1731.         if (1 == GetTotalCallCount())
  1732.         {
  1733.             DropRequest();
  1734.         }
  1735.         else
  1736.         {
  1737.             HangupAll();
  1738.         }
  1739.     }
  1740.     else if ((GetCurrentState() == CM_ACTIVE_STATE) || (GetCurrentState() == CM_HOLD_STATE))
  1741.     {
  1742.         HangupAll();
  1743.     }
  1744. }
  1745. /*****************************************************************************
  1746.  * FUNCTION
  1747.  *  ProcessIncomingEvents
  1748.  * DESCRIPTION
  1749.  *  This function is the entry into the Call Management State
  1750.  *  Machine.
  1751.  *  
  1752.  *  This function controls the Incoming Call management applicaion
  1753.  *  as per keyboard event and protocol event
  1754.  * PARAMETERS
  1755.  *  event           [IN]        
  1756.  *  info            [?]         
  1757.  *  Incoming(?)     [IN]        Event Type, Any information associated with the event
  1758.  * RETURNS
  1759.  *  void
  1760.  *****************************************************************************/
  1761. void ProcessIncomingEvents(CM_EVENT_TYPES event, void *info)
  1762. {
  1763.     /*----------------------------------------------------------------*/
  1764.     /* Local Variables                                                */
  1765.     /*----------------------------------------------------------------*/
  1766.     ACTION_RESULT result;
  1767.     /* Start by Julia: Drop call refinement */
  1768.     CM_CALL_HANDLE handle;
  1769.     /*----------------------------------------------------------------*/
  1770.     /* Code Body                                                      */
  1771.     /*----------------------------------------------------------------*/
  1772.     /* End by Julia */
  1773.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessIncomingEvents));
  1774.     switch (event)
  1775.     {
  1776.    /******************* indications *********************/
  1777.         case CM_PS_CALL_INCOMING:
  1778.             /* incoming call */
  1779.         #ifdef __MMI_VOIP__
  1780.             if (mmi_voip_get_outgoing_call_id() != -1)
  1781.             {
  1782.                 mmi_voip_entry_abort_call();
  1783.             }
  1784.             if (mmi_voip_get_incoming_call_id() != -1)
  1785.             {
  1786.                 /* do not clear key handler in case voip registered key handler is useless */
  1787.                 SetClearKeyFlag(FALSE);
  1788.                 ProcessIncomingEvents(CM_KB_INCOMING_CALL_REJECT, info);
  1789.             }
  1790.             else if (mmi_voip_app_total_call() != 0)
  1791.             {
  1792.                 ProcessIncomingEvents(CM_PS_CALL_WAIT, info);
  1793.             }
  1794.             else
  1795.         #endif
  1796.             {
  1797.                 result = ProcessIncomingCallEvent(info);
  1798.             }
  1799.             if (result != CM_CALL_SUCCESS)
  1800.             {
  1801.                 if (result == CM_NO_INCOMING)
  1802.                 {
  1803.                     PRINT_INFORMATION(("File: [%s]  Line: [%d] <<** State Machine ** Cannot Accept anymore incoming calls>>n", __FILE__, __LINE__));
  1804.                 }
  1805.                 else
  1806.                 {
  1807.                     PRINT_INFORMATION(("CM_TEST File: [%s]  Line: [%d] <<Error Processing Incoming Call Event>>n",
  1808.                                        __FILE__, __LINE__));
  1809.                 }
  1810.             }
  1811.             break;
  1812.         case CM_PS_CALL_WAIT:
  1813.             /* waiting call */
  1814.             // Start by Julia: Drop call refinement
  1815.             // automatically release all disconnecting call before incoming call comes in 
  1816.             SetAutoReleaseFlag(TRUE);
  1817.             ReleaseCall();
  1818.             /* End by Julia */
  1819.             result = ProcessCallWait(info);
  1820.             if (result != CM_CALL_SUCCESS)
  1821.             {
  1822.                 PRINT_INFORMATION(("File: [%s]  Line: [%d] <<** Error processing waiting call>>n", __FILE__,
  1823.                                    __LINE__));
  1824.             }
  1825.             break;
  1826.         case CM_PS_CCBS_ACTIVATE:
  1827.             /* CCBS available ind */
  1828.             EntryScrCcbsActivate();
  1829.             break;
  1830.         case CM_PS_CCBS_INVOKE:
  1831.             /* CCBS invoke */
  1832.             result = ProcessInvokedCcbs(info);
  1833.             if (result != CM_CALL_SUCCESS)
  1834.             {
  1835.                 PRINT_INFORMATION(("CM_TEST File: [%s]  Line: [%d] <<Error Processing CCBS Invoke Event>>n", __FILE__,
  1836.                                    __LINE__));
  1837.             }
  1838.             break;
  1839.         case CM_PS_INCOMING_CALL_DROPPED:
  1840.             /* MT drop */
  1841.             SetIncomingCallDroppedFlag(TRUE);
  1842.             result = ProcessIncomingCallRejected(info);
  1843.             if (result != CM_CALL_SUCCESS)
  1844.             {
  1845.                 PRINT_INFORMATION(("File: [%s]  Line: [%d] <<** State Machine ** Could Not drop incoming call>>n",
  1846.                                    __FILE__, __LINE__));
  1847.             }
  1848.             break;
  1849.         case CM_PS_NWK_CALL_DROP:
  1850.             /* call drop */
  1851.             result = ProcessEndCallIdAndGoBack(info);
  1852.             if (result != CM_CALL_SUCCESS)
  1853.             {
  1854.                 PRINT_INFORMATION(("CM_TEST File: [%s]  Line: [%d] <<Error Processing Network Drop Event>>n", __FILE__,
  1855.                                    __LINE__));
  1856.             }
  1857.             break;
  1858.         case CM_PS_SS_EVENT:
  1859.             ProcessShowSSEventNotification(info);
  1860.             break;
  1861.         case CM_PS_SPEECH_IND:
  1862.             ReverseSpeechIndication(info);
  1863.             break;
  1864.         case CM_PS_AOC_INDICATION:
  1865.             result = ProcessAocIndication(info);
  1866.             if (result != CM_CALL_SUCCESS)
  1867.             {
  1868.                 PRINT_INFORMATION(("File: [%s]  Line: [%d] <<** State Machine ** Error In processing AOC >>n",
  1869.                                    __FILE__, __LINE__));
  1870.             }
  1871.             break;
  1872.         case CM_PS_CONFIRM_DTMF_STRING:
  1873.             /* DTMF confirm ind */
  1874.             StartTimer(CM_AUTO_DTMF_CONFIRM_TIMER, CM_NOTIFY_TIMEOUT, EntryScrConfirmDTMFString);
  1875.             break;
  1876.    /****************** request/responses ***********************/
  1877.         case CM_KB_INCOMING_CALL_ACCEPT:
  1878.             /* SEND key in MT call */
  1879.             ProcessStateCheckIncomingCall();
  1880.             break;
  1881.         case CM_PS_INCOMING_CALL_CONNECTED:
  1882.             /* SEND key rsp */
  1883.             result = ProcessAcceptIncomingCall(info);
  1884.             if (result != CM_CALL_SUCCESS)
  1885.             {
  1886.                 PRINT_INFORMATION(("File: [%s]  Line: [%d] <<** State Machine ** COuld Not accept incoming call>>n",
  1887.                                    __FILE__, __LINE__));
  1888.             }
  1889.             break;
  1890.         case CM_PS_ACTIVE_CALL_HELD:
  1891.             result = ProcessCallsHeld(info);
  1892.             if (result != CM_CALL_SUCCESS)
  1893.             {
  1894.                 PRINT_INFORMATION(("File: [%s]  Line: [%d] <<** State Machine ** Could Not hold active call>>n",
  1895.                                    __FILE__, __LINE__));
  1896.             }
  1897.             break;
  1898.         case CM_KB_INCOMING_CALL_REJECT:
  1899.             handle = GetIncomingCallHandle();
  1900.             /* END key in MT call */
  1901.             if (GetTotalCallCount() > 1)
  1902.             {
  1903.                 /* Start by Julia: Drop call refinement */
  1904.                 SetCallState(handle, CM_DISCONNECTING_STATE, TRUE);
  1905.                 // End by Julia
  1906.                 MakePsSendUDUB((void*)PsCBackIncomingCallRejected);    /* special case for ending waitng call */
  1907.             }
  1908.             else
  1909.             {
  1910.                 /* Start by Julia: Drop call refinement */
  1911.                 SetCallState(handle, CM_DISCONNECTING_STATE, TRUE);
  1912.                 // End by Julia
  1913.                 MakePsAthRequest((void*)PsCBackIncomingCallRejected);
  1914.             }
  1915.             break;
  1916.         case CM_PS_INCOMING_CALL_REJECTED:
  1917.             /* 0 send / END key rsp */
  1918.             result = ProcessIncomingCallRejected(info);
  1919.             if (result != CM_CALL_SUCCESS)
  1920.             {
  1921.                 PRINT_INFORMATION(("File: [%s]  Line: [%d] <<** State Machine ** Could Not drop incoming call>>n",
  1922.                                    __FILE__, __LINE__));
  1923.             }
  1924.             break;
  1925.         case CM_KB_END_ACTIVE_ACCEPT_INCOMING:
  1926.             /* 1 send */
  1927.             /* Start by Julia: Drop call refinement */
  1928.             SetAllActiveCallState(CM_DISCONNECTING_STATE);
  1929.             //EntryScr1002ActiveCall();
  1930.             // End by Julia
  1931.             gAttempToAnswer = TRUE;
  1932.             MakePsHangupallActiveAcceptOtherRequest((void*)PsCBackselectedCallEnded);
  1933.             SetProtocolEventHandler(PsCBackCheckChldIncomingCallAccepted, PRT_END_CHLD_RSP);
  1934.             break;
  1935.         case CM_PS_ACTIVE_CALL_DISCONNECTED:
  1936.             /* 1 send / Menu End Single release ind */
  1937.             OutgoingProcessCMEvent(CM_PS_HANGUPSUC, info);
  1938.             break;
  1939.         case CM_KB_END_ALL_ACTIVE_RETRIEVE_HELD:
  1940.             /* 1 send */
  1941.             /* Start by Julia: Drop call refinement */
  1942.             SetAllActiveCallState(CM_DISCONNECTING_STATE);
  1943.             //EntryScr1002ActiveCall();
  1944.             // End by Julia
  1945.             MakePsHangupallActiveAcceptOtherRequest((void*)PsCBackActiveCallEndedHeldRetrieved);
  1946.             break;
  1947.         case CM_PS_ALL_ACTIVE_CALL_DISCONNECTED:
  1948.             /* 1 send release ind */
  1949.             result = ProcessEndAllActiveCall(info);
  1950.             if (result != CM_CALL_SUCCESS)
  1951.             {
  1952.                 PRINT_INFORMATION(("File: [%s]  Line: [%d] <<** State Machine ** Could Not end all active calls>>n",
  1953.                                    __FILE__, __LINE__));
  1954.             }
  1955.             break;
  1956.         case CM_PS_HELD_CALL_ACTIVE:
  1957.             /* 1 send rsp */
  1958.             result = ProcessHold2Active(info);
  1959.             if (result != CM_CALL_SUCCESS)
  1960.             {
  1961.                 PRINT_INFORMATION(("File: [%s]  Line: [%d] <<** State Machine ** Could Not make hold call active>>n",
  1962.                                    __FILE__, __LINE__));
  1963.             }
  1964.             break;
  1965.         case CM_PS_CCBS_INVOKE_DIAL:
  1966.             /* SEND key in CCBS invoke, change to KB */
  1967.             result = ProcessCCBSDialRequest(info);
  1968.             if (result != CM_CALL_SUCCESS)
  1969.             {
  1970.                 PRINT_INFORMATION(("File: [%s]  Line: [%d] <<** Error processing Dial CCBS>>n", __FILE__, __LINE__));
  1971.             }
  1972.             break;
  1973.         case CM_PS_ACTIVATED_CCBS:
  1974.             /* 5 send rsp */
  1975.             EntryScrNotifyCCBSSuccess();
  1976.             break;
  1977.         case CM_PS_CCBS_INVOKE_REJECT:
  1978.             /* END key in CCBS invoke */
  1979.             result = ProcessCCBSRejectRequest(info);
  1980.             if (result != CM_CALL_SUCCESS)
  1981.             {
  1982.                 PRINT_INFORMATION(("File: [%s]  Line: [%d] <<** Error processing Dial CCBS>>n", __FILE__, __LINE__));
  1983.             }
  1984.             break;
  1985.         case CM_KB_HANG_ALL_CALLS:
  1986.             /* END key in MMI, move to outgoingcallmanagement */
  1987.             /* Start by Julia: Drop call refinement */
  1988.             /*
  1989.              * #ifdef __MMI_CLAMSHELL__
  1990.              * if (IsClamClose() == FALSE)
  1991.              * #endif
  1992.              */
  1993.             SetAllCallState(CM_DISCONNECTING_STATE);
  1994.             //EntryScr1002ActiveCall();
  1995.             // End by Julia
  1996.             if (-1 != GetIncomingCallHandle())
  1997.             {
  1998.                 StopIncomingCallIndication();
  1999.             }
  2000.             MakePsHangupallCallsRequest((void*)HangupallReqSucess);
  2001.             break;
  2002.         default:
  2003.             PRINT_INFORMATION(("File: [%s]  Line: [%d] <<Not Valid State Machine event>>n", __FILE__, __LINE__));
  2004.             break;
  2005.     }
  2006. }
  2007. /*****************************************************************************
  2008.  * FUNCTION
  2009.  *  ProcessIncomingCallEvent
  2010.  * DESCRIPTION
  2011.  *  This function is called by the state machine function
  2012.  *  hold Process an incoming call
  2013.  * PARAMETERS
  2014.  *  info            [?]         
  2015.  *  any(?)          [IN]        Information associated with incoming call
  2016.  *  result(?)       [OUT]       Of execution of function which may be success or failure
  2017.  * RETURNS
  2018.  *  void
  2019.  *****************************************************************************/
  2020. ACTION_RESULT ProcessIncomingCallEvent(void *info)
  2021. {
  2022.     /*----------------------------------------------------------------*/
  2023.     /* Local Variables                                                */
  2024.     /*----------------------------------------------------------------*/
  2025.     IncomingCall myIncmg;
  2026.     U8 TempNumber[MAX_NUMBER];
  2027.     /*----------------------------------------------------------------*/
  2028.     /* Code Body                                                      */
  2029.     /*----------------------------------------------------------------*/
  2030.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessIncomingCallEvent));
  2031.     gAttempToAnswer = FALSE;
  2032.     DeriveCallInfo(info, &myIncmg);
  2033.     SetAnswerMode(NULL);
  2034. SetCallWaitFlag(FALSE);
  2035.     AnsiiToUnicodeString((PS8) TempNumber, (PS8) myIncmg.Number);
  2036.     pfnUnicodeStrcpy((PS8) myIncmg.Number, (PS8) TempNumber);
  2037.     AlmDisableExpiryHandler();
  2038.     switch (GetCurrentState())
  2039.     {
  2040.         case CM_IDLE_STATE:
  2041.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ProcessIncomingCallEvent1));
  2042.             SetPreviousState(GetCurrentState());
  2043.             SetCurrentState(CM_INCOMING_STATE);
  2044.     #if defined(__MMI_BT_PROFILE__) && defined(__BT_INBAND_RING__ )
  2045.          mmi_profiles_bt_call_start_callback();
  2046. #endif
  2047.             AddNewCallInfo(
  2048.                 myIncmg.Number,
  2049.                 GetCurrentState(),
  2050.                 GetPreviousState(),
  2051.                 CM_CALL_MT,
  2052.                 (CM_CALL_HANDLE) myIncmg.callHandle,
  2053.                 myIncmg.callType);
  2054.             /* Start by Julia */
  2055.     #ifdef __MMI_CM_BLACK_LIST__
  2056.             if (BlockedHandle((CM_CALL_HANDLE) myIncmg.callHandle) == TRUE)
  2057.             {
  2058.              SetBlackIncomingFlag(TRUE);
  2059.                 ProcessIncomingEvents(CM_KB_INCOMING_CALL_REJECT, info);
  2060.                 return CM_CALL_SUCCESS;
  2061.             }
  2062.     #endif /* __MMI_CM_BLACK_LIST__ */ 
  2063.             /* End by Julia */
  2064.             if (GetPriorityCall() == TRUE)
  2065.             {
  2066.                 return CM_CALL_SUCCESS;
  2067.             }
  2068.             SetAnswerMode(GetAnsweringMode());
  2069.             if (((MMI_ANSWERING_MODE*) GetAnswerMode())->automatic == TRUE)
  2070.             {
  2071.                 SetAutoAnswerFlag(TRUE);
  2072.                 StartTimer(
  2073.                     CM_AUTOANSWER_NOTIFYDURATION_TIMER,
  2074.                     CM_AUTOANSWER_NOTIFY_TIMEOUT,
  2075.                     KbCBackCallIncomingAccepted);
  2076.             }
  2077.         #ifdef __J2ME__
  2078.             {
  2079.                 extern void jvm_enter_incoming_call_notify(void);
  2080.                 jvm_enter_incoming_call_notify();
  2081.             }
  2082.         #endif /* __J2ME__ */ 
  2083.             EntryScrIncomingCallEvent();
  2084.             if (!GetRingingFlag())
  2085.             {
  2086.                 ShowIncomingCallIndication();
  2087.             }
  2088.             AddMarkerToHistory();
  2089.             return CM_CALL_SUCCESS;
  2090.         case CM_OUTGOING_STATE:
  2091.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ProcessIncomingCallEvent2));
  2092.             if (cm_p->redial_info.RedialTimer == TRUE)
  2093.             {
  2094.                 SetPreviousState(GetCurrentState());
  2095.                 SetCurrentState(CM_INCOMING_STATE);
  2096.                 AddNewCallInfo(
  2097.                     myIncmg.Number,
  2098.                     GetCurrentState(),
  2099.                     GetPreviousState(),
  2100.                     CM_CALL_MT,
  2101.                     (CM_CALL_HANDLE) myIncmg.callHandle,
  2102.                     myIncmg.callType);
  2103.                 /* Start by Julia */
  2104.             #ifdef __MMI_CM_BLACK_LIST__
  2105.                 if (BlockedHandle((CM_CALL_HANDLE) myIncmg.callHandle) == TRUE)
  2106.                 {
  2107.                     ProcessIncomingEvents(CM_KB_INCOMING_CALL_REJECT, info);
  2108.                     return CM_CALL_SUCCESS;
  2109.                 }
  2110.             #endif /* __MMI_CM_BLACK_LIST__ */ 
  2111.                 /* End by Julia */
  2112.                 if (GetPriorityCall() == TRUE)
  2113.                 {
  2114.                     return CM_CALL_SUCCESS;
  2115.                 }
  2116.                 ResetRedialAttempts();
  2117.                 EntryScrIncomingCallEvent();
  2118.                 ShowIncomingCallIndication();
  2119.                 if (!IsScreenPresent(CM_SCR_MARKER))
  2120.                 {
  2121.                     AddMarkerToHistory();
  2122.                 }
  2123.                 return CM_CALL_SUCCESS;
  2124.             }
  2125.             /* amanda add 0326, MO MT collision */
  2126.             else
  2127.             {
  2128.                 SetPreviousState(GetCurrentState());
  2129.                 SetCurrentState(CM_INCOMING_STATE);
  2130.                 AddNewCallInfo(
  2131.                     myIncmg.Number,
  2132.                     GetCurrentState(),
  2133.                     GetPreviousState(),
  2134.                     CM_CALL_MT,
  2135.                     (CM_CALL_HANDLE) myIncmg.callHandle,
  2136.                     myIncmg.callType);
  2137.                 /* Start by Julia */
  2138.             #ifdef __MMI_CM_BLACK_LIST__
  2139.                 if (BlockedHandle((CM_CALL_HANDLE) myIncmg.callHandle) == TRUE)
  2140.                 {
  2141.                     ProcessIncomingEvents(CM_KB_INCOMING_CALL_REJECT, info);
  2142.                     return CM_CALL_SUCCESS;
  2143.                 }
  2144.             #endif /* __MMI_CM_BLACK_LIST__ */ 
  2145.                 /* End by Julia */
  2146.                 if (GetPriorityCall() == TRUE)
  2147.                 {
  2148.                     return CM_CALL_SUCCESS;
  2149.                 }
  2150.                 EntryScrIncomingCallEvent();
  2151.                 ShowIncomingCallIndication();
  2152.                 DeleteUptoScrID(CM_SCR_MARKER);
  2153.                 if (!IsScreenPresent(CM_SCR_MARKER))
  2154.                 {
  2155.                     AddMarkerToHistory();
  2156.                 }
  2157.                 return CM_CALL_SUCCESS;
  2158.             }
  2159.     }
  2160.     return CM_CALL_FAILURE;
  2161. }
  2162. /*****************************************************************************
  2163.  * FUNCTION
  2164.  *  ProcessCallWait
  2165.  * DESCRIPTION
  2166.  *  This function is called by the state machine function
  2167.  *  hold Process an incoming call
  2168.  * PARAMETERS
  2169.  *  info            [?]         
  2170.  *  any(?)          [IN]        Information associated with incoming call
  2171.  *  result(?)       [OUT]       Of execution of function which may be success or failure
  2172.  * RETURNS
  2173.  *  void
  2174.  *****************************************************************************/
  2175. ACTION_RESULT ProcessCallWait(void *info)
  2176. {
  2177.     /*----------------------------------------------------------------*/
  2178.     /* Local Variables                                                */
  2179.     /*----------------------------------------------------------------*/
  2180.     IncomingCall myIncmg;
  2181.     U8 TempNumber[MAX_NUMBER];
  2182.     /*----------------------------------------------------------------*/
  2183.     /* Code Body                                                      */
  2184.     /*----------------------------------------------------------------*/
  2185.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessCallWait));
  2186.     gAttempToAnswer = FALSE;
  2187.     SetPreviousState(GetCurrentState());
  2188.     SetCurrentState(CM_INCOMING_STATE);
  2189.     SetCallWaitFlag(TRUE);
  2190.     DeriveCallInfoFromWait(info, &myIncmg);
  2191.     AnsiiToUnicodeString((PS8) TempNumber, (PS8) myIncmg.Number);
  2192.     pfnUnicodeStrcpy((PS8) myIncmg.Number, (PS8) TempNumber);
  2193.     AddNewCallInfo(
  2194.         myIncmg.Number,
  2195.         GetCurrentState(),
  2196.         GetPreviousState(),
  2197.         CM_CALL_MT,
  2198.         (CM_CALL_HANDLE) myIncmg.callHandle,
  2199.         myIncmg.callType);
  2200.     /* Start by Julia */
  2201. #ifdef __MMI_CM_BLACK_LIST__
  2202.     if (BlockedHandle((CM_CALL_HANDLE) myIncmg.callHandle) == TRUE)
  2203.     {
  2204.         ProcessIncomingEvents(CM_KB_INCOMING_CALL_REJECT, info);
  2205.         return CM_CALL_SUCCESS;
  2206.     }
  2207. #endif /* __MMI_CM_BLACK_LIST__ */ 
  2208.     /* End by Julia */
  2209. #ifdef __J2ME__
  2210.     {
  2211.         extern void jvm_enter_incoming_call_notify(void);
  2212.         jvm_enter_incoming_call_notify();
  2213.     }
  2214. #endif /* __J2ME__ */ 
  2215.     EntryScrIncomingCallEvent();
  2216.     StartRingTone(TONE_CALL_WAITING);
  2217.     if (!IsScreenPresent(CM_SCR_MARKER))
  2218.     {
  2219.         AddMarkerToHistory();
  2220.     }
  2221.     return CM_CALL_SUCCESS;
  2222. }
  2223. /*****************************************************************************
  2224.  * FUNCTION
  2225.  *  ProcessInvokedCcbs
  2226.  * DESCRIPTION
  2227.  *  This function is called when CCBS
  2228.  *  invoked notification is there
  2229.  * PARAMETERS
  2230.  *  info            [?]         
  2231.  *  result(?)       [OUT]       Of execution of function which may be success or failure
  2232.  * RETURNS
  2233.  *  void
  2234.  *****************************************************************************/
  2235. ACTION_RESULT ProcessInvokedCcbs(void *info)
  2236. {
  2237.     /*----------------------------------------------------------------*/
  2238.     /* Local Variables                                                */
  2239.     /*----------------------------------------------------------------*/
  2240.     IncomingCall myIncmg;
  2241.     U8 TempNumber[MAX_NUMBER];
  2242.     /*----------------------------------------------------------------*/
  2243.     /* Code Body                                                      */
  2244.     /*----------------------------------------------------------------*/
  2245.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessInvokedCcbs));
  2246.     DeriveCcbsCallInfo(info, &myIncmg);
  2247.     AnsiiToUnicodeString((PS8) TempNumber, (PS8) myIncmg.Number);
  2248.     pfnUnicodeStrcpy((PS8) myIncmg.Number, (PS8) TempNumber);
  2249.     if (GetCurrentState() != CM_INCOMING_STATE)
  2250.     {
  2251.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ProcessInvokedCcbs));
  2252.         SetPreviousState(GetCurrentState());
  2253.         SetCurrentState(CM_INCOMING_STATE);
  2254.         AddNewCallInfo(
  2255.             myIncmg.Number,
  2256.             GetCurrentState(),
  2257.             GetPreviousState(),
  2258.             CM_CALL_MT,
  2259.             (CM_CALL_HANDLE) myIncmg.callHandle,
  2260.             CSMCC_VOICE_CALL);
  2261.         EntryScrCCBSInvokeEvent();
  2262.         if (!IsScreenPresent(CM_SCR_MARKER))
  2263.         {
  2264.             AddMarkerToHistory();
  2265.         }
  2266.         return CM_CALL_SUCCESS;
  2267.     }
  2268.     return CM_CALL_FAILURE;
  2269. }
  2270. /*****************************************************************************
  2271.  * FUNCTION
  2272.  *  ProcessIncomingCallRejected
  2273.  * DESCRIPTION
  2274.  *  This function is called by the state machine function reject
  2275.  *  incoming call
  2276.  * PARAMETERS
  2277.  *  info            [?]         
  2278.  *  any(?)          [IN]        Information associated with incoming call
  2279.  *  Success(?)      [OUT]       Or failure
  2280.  * RETURNS
  2281.  *  void
  2282.  *****************************************************************************/
  2283. ACTION_RESULT ProcessIncomingCallRejected(void *info)
  2284. {
  2285.     /*----------------------------------------------------------------*/
  2286.     /* Local Variables                                                */
  2287.     /*----------------------------------------------------------------*/
  2288.     U8 flag = 0;    /* Set if previous state is outgoing */
  2289.     /*----------------------------------------------------------------*/
  2290.     /* Code Body                                                      */
  2291.     /*----------------------------------------------------------------*/
  2292.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessIncomingCallRejected));
  2293.     if ((GetTotalCallCount() > 1) && (GetIncomingCallHandle() != ((MMI_RELEASE_IND*) info)->call_id))
  2294.     {
  2295.         /* use chld to reject */
  2296.         /* dropped is not MT call, use default drop call handler */
  2297.         PsCBackNetworkCallDropped(info);
  2298.     #ifdef __MMI_VOIP__
  2299.         /* call back voip to connect voip */
  2300.         if ((mmi_voip_app_total_call() != 0) && (mmi_voip_app_get_conn_flag() == MMI_VOIP_CALL_CONN_VOIP))
  2301.         {
  2302.             mmi_voip_app_set_conn_flag(MMI_VOIP_CALL_CONN_NONE);
  2303.             mmi_voip_entry_ans_to_conn_voip();
  2304.         }
  2305.     #endif /* __MMI_VOIP__ */
  2306.         return CM_CALL_SUCCESS;
  2307.     }
  2308.     else if ((GetTotalCallCount() == 1 && GetCurrentState() != CM_INCOMING_STATE) || (GetIncomingCallHandle() == -1))
  2309.     {
  2310.         /* use ath to reject or call already dropped when ath rsp comes */
  2311.         CM_CALL_HANDLE handle;
  2312.         PRINT_INFORMATION(("ProcessIncomingCallRejected: not incoming state"));
  2313.         handle = GetHungUpHandle();
  2314.         if (handle != -1)
  2315.         {
  2316.             OutgoingProcessCMEvent(CM_PS_HANGUPSUC, (void*)&handle);
  2317.         }
  2318.     #ifdef __MMI_VOIP__
  2319.         /* call back voip to connect voip */
  2320.         if ((mmi_voip_app_total_call() != 0) && (mmi_voip_app_get_conn_flag() == MMI_VOIP_CALL_CONN_VOIP))
  2321.         {
  2322.             mmi_voip_app_set_conn_flag(MMI_VOIP_CALL_CONN_NONE);
  2323.             mmi_voip_entry_ans_to_conn_voip();
  2324.         }
  2325.     #endif /* __MMI_VOIP__ */
  2326.         return CM_CALL_SUCCESS;
  2327.     }
  2328.     gAttempToReject = FALSE;
  2329.     ResetCallflag(GetIncomingCallHandle(), CM_HANGUP_REQUESTED, TRUE);
  2330.     SetProtocolEventHandler(PsCBackNetworkCallDropped, PRT_NWRK_CALL_RELEASE);
  2331.     switch (GetPreviousState())
  2332.     {
  2333.         case CM_IDLE_STATE:
  2334.             SetPreviousState(CM_INCOMING_STATE);
  2335.             SetCurrentState(CM_IDLE_STATE);
  2336.             break;
  2337.         case CM_HOLD_STATE:
  2338.             if (GetTotalHoldCallCount() > 0)
  2339.             {
  2340.                 SetCurrentState(CM_HOLD_STATE);
  2341.                 SetPreviousState(CM_INCOMING_STATE);
  2342.             }
  2343.             else
  2344.             {
  2345.                 SetCurrentState(CM_IDLE_STATE);
  2346.                 SetPreviousState(CM_IDLE_STATE);
  2347.             }
  2348.             break;
  2349.         case CM_ACTIVE_STATE:
  2350.             if (GetTotalActiveCallCount() > 0)
  2351.             {
  2352.                 SetCurrentState(CM_ACTIVE_STATE);
  2353.                 SetPreviousState(CM_INCOMING_STATE);
  2354.             }
  2355.             else
  2356.             {
  2357.                 SetCurrentState(CM_IDLE_STATE);
  2358.                 SetPreviousState(CM_IDLE_STATE);
  2359.             }
  2360.             break;
  2361.         case CM_INCOMING_STATE:
  2362.             if (GetCurrentState() == CM_OUTGOING_STATE)
  2363.             {
  2364.             }
  2365.             else if (GetCurrentState() == CM_INCOMING_STATE)
  2366.             {
  2367.             }
  2368.             else if (GetTotalActiveCallCount() > 0)
  2369.             {
  2370.                 SetCurrentState(CM_ACTIVE_STATE);
  2371.             }
  2372.             else if (GetTotalHoldCallCount() > 0)
  2373.             {
  2374.                 SetCurrentState(CM_HOLD_STATE);
  2375.             }
  2376.             else
  2377.             {
  2378.                 SetCurrentState(CM_IDLE_STATE);
  2379.             }
  2380.             break;
  2381.         case CM_OUTGOING_STATE:
  2382.             flag = 1;
  2383.             break;
  2384.         default:
  2385.             PRINT_INFORMATION(("Previous State is Unknown this should not happenn"));
  2386.         #ifdef __MMI_VOIP__
  2387.             /* call back voip to connect voip */
  2388.             if ((mmi_voip_app_total_call() != 0) && (mmi_voip_app_get_conn_flag() == MMI_VOIP_CALL_CONN_VOIP))
  2389.             {
  2390.                 mmi_voip_app_set_conn_flag(MMI_VOIP_CALL_CONN_NONE);
  2391.                 mmi_voip_entry_ans_to_conn_voip();
  2392.             }
  2393.         #endif /* __MMI_VOIP__ */
  2394.             return CM_CALL_FAILURE;
  2395.     }
  2396.     if (GetIncomingCallDroppedFlag())
  2397.     {
  2398.         SetIncomingCallDroppedFlag(FALSE);
  2399.         StopIncomingCallIndication();
  2400.     }
  2401.     /* if(GetMissedCallFlag()==FALSE) */
  2402.     DeleteScreenIfPresent(ITEMSCR_INCOMING_CALL);
  2403.     DeleteIncomingCallOptionScreen();
  2404.     if (GetCCBSFlag() == TRUE)
  2405.     {
  2406.         /* don't log CCBS call */
  2407.         PurgeIncomingCallStructure();
  2408.         GoBackfromNotifyScr();
  2409.         SetCCBSFlag(FALSE);
  2410.     }
  2411.     else
  2412.     {
  2413.         LogCallInfoForCallHistory(GetIncomingCallHandle());
  2414.         PurgeIncomingCallStructure();
  2415.     }
  2416.     if (1 == flag)
  2417.     {
  2418.         UpdateStateMachine();
  2419.     }
  2420. #ifdef __MMI_VOIP__
  2421.     /* call back voip to connect voip */
  2422.     if ((mmi_voip_app_total_call() != 0) && (mmi_voip_app_get_conn_flag() == MMI_VOIP_CALL_CONN_VOIP))
  2423.     {
  2424.         mmi_voip_app_set_conn_flag(MMI_VOIP_CALL_CONN_NONE);
  2425.         mmi_voip_entry_ans_to_conn_voip();
  2426.     }
  2427. #endif /* __MMI_VOIP__ */
  2428.     return CM_CALL_SUCCESS;
  2429. }
  2430. /*****************************************************************************
  2431.  * FUNCTION
  2432.  *  ProcessEndCallIdAndGoBack
  2433.  * DESCRIPTION
  2434.  *  This function is called by the state machine function in
  2435.  *  to make call to protocol stack to get call list to sync with MMI
  2436.  * PARAMETERS
  2437.  *  info        [?]     
  2438.  * RETURNS
  2439.  *  void
  2440.  *****************************************************************************/
  2441. ACTION_RESULT ProcessEndCallIdAndGoBack(void *info)
  2442. {
  2443.     /*----------------------------------------------------------------*/
  2444.     /* Local Variables                                                */
  2445.     /*----------------------------------------------------------------*/
  2446.     CM_CALL_HANDLE handle;
  2447.     CALL_STATE state;
  2448.     /*----------------------------------------------------------------*/
  2449.     /* Code Body                                                      */
  2450.     /*----------------------------------------------------------------*/
  2451.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessEndCallIdAndGoBack));
  2452.     handle = DeriveCallHandle(info);
  2453.     state = GetCurrentState();
  2454.     if (GetMMIStructIndexof(handle) == -1)
  2455.     {
  2456.         PRINT_INFORMATION(("ncall already dropped in ProcessEndCallIdAndGoBackn"));
  2457.         return CM_CALL_SUCCESS;
  2458.     }
  2459.     SetCallEndCause((U16) ((MMI_RELEASE_IND*) info)->cause);
  2460.     if (GetCallDirFlag(handle) == CM_CALL_MO_STK)
  2461.     {
  2462.         if (state == CM_OUTGOING_STATE)
  2463.         {
  2464.             SATCallExitCause(SAT_CALL_DISCONNECT_BEFORE_CONNECT);
  2465.         }
  2466.         else if (state == CM_ACTIVE_STATE || state == CM_HOLD_STATE)
  2467.         {
  2468.             SATCallExitCause(SAT_CALL_DISCONNECT_AFTER_CONNECT);
  2469.         }
  2470.     }
  2471.     state = GetCallState(handle);
  2472.     /* when there's pending req on the dropped call, sync all call state with PS */
  2473.     if (GetCallflag(handle, TRUE) & (~CM_HANGUP_REQUESTED) != 0)
  2474.     {
  2475.         SyncCallList();
  2476.     }
  2477.     switch (state)
  2478.     {
  2479.         case CM_INCOMING_STATE:
  2480.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ProcessEndCallIdAndGoBack1));
  2481.             SetCallEndCause(0);
  2482.             ProcessIncomingEvents(CM_PS_INCOMING_CALL_DROPPED, info);
  2483.             return CM_CALL_SUCCESS;
  2484.         case CM_OUTGOING_STATE:
  2485.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ProcessEndCallIdAndGoBack2));
  2486.             LogCallInfoForCallHistory(GetOutgoingCallHandle());
  2487.             GetEndTimeAndLogUnconnectedMOCall();
  2488.             if (IsRedialSet())
  2489.             {
  2490.                 MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ProcessEndCallIdAndGoBack3));
  2491.                 SetRedialNumber();
  2492.                 OutgoingProcessCMFailureEvent(CM_PS_CALLCONNECTED, GetCallEndCause());
  2493.                 /* SetCallEndCause(0); */
  2494.                 SetCallEndedBeforeConnFlag(FALSE);
  2495.                 return CM_CALL_SUCCESS;
  2496.             }
  2497.             SetCallState(handle, CM_IDLE_STATE, TRUE);
  2498.             UpdateStateMachine();
  2499.             if (GetCurrentState() == CM_OUTGOING_STATE)
  2500.             {
  2501.                 SetCurrentState(GetPreviousState());
  2502.                 SetPreviousState(CM_OUTGOING_STATE);
  2503.             }
  2504.             EntryScr1004NotifyEndCallDuration();
  2505.             return CM_CALL_SUCCESS;
  2506.         case CM_HOLD_STATE:
  2507.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ProcessEndCallIdAndGoBack4));
  2508.             if (GetCurrentState() == CM_OUTGOING_STATE)
  2509.             {
  2510.                 LogCallInfoForCallHistory(handle);
  2511.                 GetEndTimeAndNotifyEndCallDuration(handle);
  2512.                 SetCallState(handle, CM_IDLE_STATE, TRUE);
  2513.                 if (GetTotalHoldCallCount() == GetTotalCallCount())
  2514.                 {
  2515.                     SetPreviousState(CM_OUTGOING_STATE);
  2516.                     SetCurrentState(CM_HOLD_STATE);
  2517.                 }
  2518.                 return CM_CALL_SUCCESS;
  2519.             }
  2520.             SetCallflag(handle, CM_HANGUP_REQUESTED, TRUE);
  2521.             OutgoingProcessCMEvent(CM_PS_HANGUPSUC, (void*)&handle);
  2522.             return CM_CALL_SUCCESS;
  2523.         case CM_ACTIVE_STATE:
  2524.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ProcessEndCallIdAndGoBack5));
  2525.             SetCallflag(handle, CM_HANGUP_REQUESTED, TRUE);
  2526.             OutgoingProcessCMEvent(CM_PS_HANGUPSUC, (void*)&handle);
  2527.             return CM_CALL_SUCCESS;
  2528.         default:
  2529.             PRINT_INFORMATION(("<<** State Machine ** Not valid call state for handle>>n"));
  2530.             return CM_CALL_FAILURE;
  2531.     }
  2532.     return CM_CALL_FAILURE;
  2533. }
  2534. /*****************************************************************************
  2535.  * FUNCTION
  2536.  *  ProcessShowSSEventNotification
  2537.  * DESCRIPTION
  2538.  *  This function derives SS information from PS and calls necessary
  2539.  *  entry function to show string
  2540.  * PARAMETERS
  2541.  *  info        [?]         
  2542.  *  data(?)     [IN]        From PS
  2543.  * RETURNS
  2544.  *  void
  2545.  *****************************************************************************/
  2546. void ProcessShowSSEventNotification(void *info)
  2547. {
  2548.     /*----------------------------------------------------------------*/
  2549.     /* Local Variables                                                */
  2550.     /*----------------------------------------------------------------*/
  2551.     /*----------------------------------------------------------------*/
  2552.     /* Code Body                                                      */
  2553.     /*----------------------------------------------------------------*/
  2554.     DeriveSSEvent(info);
  2555.     EntryScrShowSSEvent();
  2556. }
  2557. /*****************************************************************************
  2558.  * FUNCTION
  2559.  *  ProcessAocIndication
  2560.  * DESCRIPTION
  2561.  *  This function is called by the state machine function in
  2562.  *  to make call to protocol stack to get call list to sync with MMI
  2563.  * PARAMETERS
  2564.  *  info        [?]     
  2565.  * RETURNS
  2566.  *  void
  2567.  *****************************************************************************/
  2568. ACTION_RESULT ProcessAocIndication(void *info)
  2569. {
  2570.     /*----------------------------------------------------------------*/
  2571.     /* Local Variables                                                */
  2572.     /*----------------------------------------------------------------*/
  2573.     U32 acmIndValue;
  2574.     U8 temp[8];
  2575.     /*----------------------------------------------------------------*/
  2576.     /* Code Body                                                      */
  2577.     /*----------------------------------------------------------------*/
  2578.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessAocIndication));
  2579.     SetShowAOC(TRUE);
  2580.     memset(cashSign, 0, sizeof(cashSign));
  2581.     cashSign[0] = '$';
  2582.     acmIndValue = DeriveCcmValue(info);
  2583.     gSumACMValue += acmIndValue;
  2584.     memset((S8*) temp, 0, sizeof(temp));
  2585.     sprintf((S8*) temp, "%d", (U32) gSumACMValue);
  2586.     AnsiiToUnicodeString((S8*) AocBuffer, (S8*) temp);
  2587.     switch (GetCurrentState())
  2588.     {
  2589.      case CM_OUTGOING_STATE:
  2590.         case CM_HOLD_STATE:
  2591.         case CM_ACTIVE_STATE:
  2592.             show_call_cost_UI(cashSign, (PU8) AocBuffer);
  2593.             return CM_CALL_SUCCESS;
  2594.         default:
  2595.             PRINT_INFORMATION(("<<** Cannot Process AOC indication in this state>>n"));
  2596.             return CM_CALL_FAILURE;
  2597.     }
  2598. }
  2599. /*****************************************************************************
  2600.  * FUNCTION
  2601.  *  ReverseSpeechIndication
  2602.  * DESCRIPTION
  2603.  *  This function is called reverse the speech
  2604.  * PARAMETERS
  2605.  *  info        [?]         
  2606.  *  Info(?)     [IN]        From the PS
  2607.  * RETURNS
  2608.  *  void
  2609.  *****************************************************************************/
  2610. void ReverseSpeechIndication(void *info)
  2611. {
  2612.     /*----------------------------------------------------------------*/
  2613.     /* Local Variables                                                */
  2614.     /*----------------------------------------------------------------*/
  2615.     pBOOL status;
  2616.     U8 type;
  2617.     /*----------------------------------------------------------------*/
  2618.     /* Code Body                                                      */
  2619.     /*----------------------------------------------------------------*/
  2620.     status = CheckStatusOfSpeech(info, &type);
  2621. if (GetCurrentState() == CM_OUTGOING_STATE && status == TRUE)
  2622. {
  2623.      SetSpeechFlag(TRUE);
  2624.      if (GetExitScrnID() == SCR1001_CM_OUTGOINGCALLSCREEN)
  2625.      {
  2626.          SetGroupKeyHandler(
  2627.              EnterScreenAndHandleDigit,
  2628.              (PU16) CMIdleScreenDigits,
  2629.              MAX_CM_SCREEN_DIGITS - 1,
  2630.              KEY_EVENT_DOWN);
  2631. #if ( (defined  __MMI_WGUI_CSK_ENABLE__) && (defined __MMI_TOUCH_SCREEN__) && !(defined __MMI_TOUCH_IDLESCREEN_SHORTCUTS__))    /* PMT MANISH   20050623 */
  2632.      EnableCenterSoftkey(0, IMG_CSK_DIAL_ICON);
  2633.             SetCenterSoftkeyFunction(EnterScreenAndHandleDigit, KEY_EVENT_UP);
  2634.      redraw_center_softkey();    
  2635. #endif         
  2636.      }
  2637. }
  2638. #ifdef __CTM_SUPPORT__
  2639.     /* close ctm before turn off speech */
  2640.     if (status == FALSE && ctm_p->state >= MMI_CTM_STATE_OPENED)
  2641.     {
  2642.         mmi_ctm_send_close_req();
  2643.         mmi_ctm_set_state(MMI_CTM_STATE_CLOSING);
  2644.     }
  2645. #endif /* __CTM_SUPPORT__ */ 
  2646.     MakePsReverseSpeechStatus(status, type);
  2647. #ifdef __CTM_SUPPORT__
  2648.     /* open ctm after turn on speech */
  2649.     if (status == TRUE && ctm_p->status == TRUE && 
  2650.      (ctm_p->state == MMI_CTM_STATE_IDLE || 
  2651.      ctm_p->state == MMI_CTM_STATE_CLOSING))
  2652.     {
  2653.         S8 mode = 0xff;
  2654.         if (ctm_p->tty_status == TRUE)
  2655.         {
  2656.             /* with TTY, open as TTY */
  2657.             switch (ctm_p->mode_setting)
  2658.             {
  2659.                 case MMI_CTM_SETTING_HCO:
  2660.                     mode = CTM_HCO_MODE;
  2661.                     break;
  2662.                 case MMI_CTM_SETTING_VCO:
  2663.                     mode = CTM_VCO_MODE;
  2664.                     break;
  2665.                 case MMI_CTM_SETTING_BAUDOT:
  2666.                     mode = CTM_BAUDOT_MODE;
  2667.                     break;
  2668.                 default:
  2669.                    /* CTM ON, earphone in, direct mode => no CTM function, take it as earphone */
  2670.                    mode = CTM_DIRECT_MODE;
  2671.                     break;
  2672.             }
  2673.         }
  2674.         else
  2675.         {
  2676.             switch (ctm_p->mode_setting)
  2677.             {
  2678.                 case MMI_CTM_SETTING_AUTO_DIRECT:
  2679.                 case MMI_CTM_SETTING_MANUAL_DIRECT:
  2680.                     /* no TTY, open as direct */
  2681.                     mode = CTM_DIRECT_MODE;
  2682.                     break;
  2683.                 default:
  2684.                     break;
  2685.             }
  2686.         }
  2687.         if (mode != 0xff)
  2688.         {
  2689.             mmi_ctm_send_open_req(mode);
  2690.             mmi_ctm_set_state(MMI_CTM_STATE_OPENING);
  2691.         }
  2692.     }
  2693. #endif /* __CTM_SUPPORT__ */ 
  2694. }
  2695. /*****************************************************************************
  2696.  * FUNCTION
  2697.  *  IsAttemptToAnswer
  2698.  * DESCRIPTION
  2699.  *  
  2700.  *  
  2701.  * PARAMETERS
  2702.  *  void
  2703.  * RETURNS
  2704.  *  void
  2705.  *****************************************************************************/
  2706. pBOOL IsAttemptToAnswer(void)
  2707. {
  2708.     return gAttempToAnswer;
  2709. }
  2710. #ifdef __MMI_VOIP__
  2711. /**************************************************************
  2712.  * FUNCTION
  2713.  *  mmi_voip_entry_ans_to_disconn_gsm
  2714.  * DESCRIPTION
  2715.  *  
  2716.  * PARAMETERS
  2717.  *  void
  2718.  * RETURNS
  2719.  *  void
  2720.  **************************************************************/
  2721. void mmi_voip_entry_ans_to_disconn_gsm(void)
  2722. {
  2723.     HangupAllCalls();
  2724. }
  2725. /*****************************************************************************
  2726.  * FUNCTION
  2727.  *  mmi_voip_entry_ans_to_conn_gsm
  2728.  * DESCRIPTION
  2729.  *  
  2730.  * PARAMETERS
  2731.  *  void
  2732.  * RETURNS
  2733.  *  void
  2734.  *****************************************************************************/
  2735. void mmi_voip_entry_ans_to_conn_gsm(void)
  2736. {
  2737.     if (GetTotalActiveCallCount() > 0)
  2738.     {
  2739.         gAcceptIncoming = TRUE;
  2740.         SetHoldFlag();
  2741.         MakePsActiveHold((void*)PsCBackActiveCallsHeld);
  2742.     }
  2743.     else
  2744.     {
  2745.         MakePsCallAcceptIncoming((void*)PsCBackIncomingCallAccepted);
  2746.     }
  2747. }
  2748. #endif /* __MMI_VOIP__ */
  2749. /*****************************************************************************
  2750.  * FUNCTION
  2751.  *  ProcessStateCheckIncomingCall
  2752.  * DESCRIPTION
  2753.  *  This function is called by the state machine function to
  2754.  *  decide what to do before accepting an incoming call
  2755.  * PARAMETERS
  2756.  *  void
  2757.  * RETURNS
  2758.  *  void
  2759.  *****************************************************************************/
  2760. void ProcessStateCheckIncomingCall(void)
  2761. {
  2762.     /*----------------------------------------------------------------*/
  2763.     /* Local Variables                                                */
  2764.     /*----------------------------------------------------------------*/
  2765.     /*----------------------------------------------------------------*/
  2766.     /* Code Body                                                      */
  2767.     /*----------------------------------------------------------------*/
  2768.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessStateCheckIncomingCall));
  2769.     gAttempToAnswer = TRUE;
  2770. #ifdef __MMI_VOIP__
  2771.     /* release all voip calls before answering gsm call */
  2772.     if (mmi_voip_app_total_call())
  2773.     {
  2774.         mmi_voip_app_set_conn_flag(MMI_VOIP_CALL_CONN_GSM);
  2775.         mmi_voip_entry_ans_to_disconn_voip();
  2776.     }
  2777.     else
  2778. #endif /* __MMI_VOIP__ */
  2779.     {
  2780.         if (GetTotalActiveCallCount() > 0)
  2781.         {
  2782.             gAcceptIncoming = TRUE;
  2783.             SetHoldFlag();
  2784.             MakePsActiveHold((void*)PsCBackActiveCallsHeld);
  2785.         }
  2786.         else
  2787.         {
  2788.             MakePsCallAcceptIncoming((void*)PsCBackIncomingCallAccepted);
  2789.         }
  2790.     }
  2791. }
  2792. /*****************************************************************************
  2793.  * FUNCTION
  2794.  *  PsCBackIncomingCallAccepted
  2795.  * DESCRIPTION
  2796.  *  This function is called back by the protocol stack when there
  2797.  *  Incoming Call is accepted
  2798.  * PARAMETERS
  2799.  *  info        [?]     
  2800.  * RETURNS
  2801.  *  void
  2802.  *****************************************************************************/
  2803. void PsCBackIncomingCallAccepted(void *info)
  2804. {
  2805.     /*----------------------------------------------------------------*/
  2806.     /* Local Variables                                                */
  2807.     /*----------------------------------------------------------------*/
  2808.     U16 result;
  2809.     /*----------------------------------------------------------------*/
  2810.     /* Code Body                                                      */
  2811.     /*----------------------------------------------------------------*/
  2812.     gAttempToAnswer = FALSE;
  2813.     if (CheckAtaSuccess(info, &result))
  2814.     {
  2815.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_PsCBackIncomingCallAccepted1));
  2816.         ProcessIncomingEvents(CM_PS_INCOMING_CALL_CONNECTED, info);
  2817.     }
  2818.     else if (GetIncomingCallHandle() != -1)
  2819.     {
  2820.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_PsCBackIncomingCallAccepted2));
  2821.         /* accept fail doesn't imply call is disconnected */
  2822.         ProcessIncomingFailureEvents(CM_PS_INCOMING_CALL_CONNECTED, result);
  2823.     }
  2824. }
  2825. /*****************************************************************************
  2826.  * FUNCTION
  2827.  *  PsCBackCheckChldIncomingCallAccepted
  2828.  * DESCRIPTION
  2829.  *  This function is required to check the chld response and call
  2830.  *  necessary function
  2831.  *  
  2832.  *  This call back is registered in case it is required to
  2833.  *  accept incoming call via a chld request.
  2834.  * PARAMETERS
  2835.  *  info        [?]     
  2836.  * RETURNS
  2837.  *  void
  2838.  *****************************************************************************/
  2839. void PsCBackCheckChldIncomingCallAccepted(void *info)
  2840. {
  2841.     /*----------------------------------------------------------------*/
  2842.     /* Local Variables                                                */
  2843.     /*----------------------------------------------------------------*/
  2844.     U16 cause;
  2845.     /*----------------------------------------------------------------*/
  2846.     /* Code Body                                                      */
  2847.     /*----------------------------------------------------------------*/
  2848.     SetChldReqSent(CM_ACTION_NONE);
  2849.     if (CheckChldRequestSuccess(info, &cause))
  2850.     {
  2851.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_PsCBackCheckChldIncomingCallAccepted1));
  2852.         ProcessIncomingEvents(CM_PS_INCOMING_CALL_CONNECTED, info);
  2853.     }
  2854.     else
  2855.     {
  2856.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_PsCBackCheckChldIncomingCallAccepted2));
  2857.         SetProtocolEventHandler(PsCBackNetworkCallDropped, PRT_NWRK_CALL_RELEASE);
  2858.         ProcessIncomingFailureEvents(CM_PS_INCOMING_CALL_CONNECTED, cause);
  2859.     }
  2860. }
  2861. /*****************************************************************************
  2862.  * FUNCTION
  2863.  *  PsCBackActiveCallsHeld
  2864.  * DESCRIPTION
  2865.  *  This function is called back by the protocol stack when there
  2866.  *  Active call is held
  2867.  * PARAMETERS
  2868.  *  info        [?]     
  2869.  * RETURNS
  2870.  *  void
  2871.  *****************************************************************************/
  2872. void PsCBackActiveCallsHeld(void *info)
  2873. {
  2874.     /*----------------------------------------------------------------*/
  2875.     /* Local Variables                                                */
  2876.     /*----------------------------------------------------------------*/
  2877.     U16 result;
  2878.     /*----------------------------------------------------------------*/
  2879.     /* Code Body                                                      */
  2880.     /*----------------------------------------------------------------*/
  2881.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackActiveCallsHeld));
  2882.     if (CheckChldRequestSuccess(info, &result))
  2883.     {
  2884.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_PsCBackActiveCallsHeld1));
  2885.         ProcessIncomingEvents(CM_PS_ACTIVE_CALL_HELD, info);
  2886.     }
  2887.     else
  2888.     {
  2889.         ResetHoldFlag();
  2890.         gAttempToAnswer = FALSE;
  2891.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_PsCBackActiveCallsHeld2, result));
  2892.         ProcessIncomingFailureEvents(CM_PS_ACTIVE_CALL_HELD, result);
  2893.         SetProtocolEventHandler(PsCBackNetworkCallDropped, PRT_NWRK_CALL_RELEASE);
  2894.     }
  2895. }
  2896. /*****************************************************************************
  2897.  * FUNCTION
  2898.  *  ProcessCallsHeld
  2899.  * DESCRIPTION
  2900.  *  This function is called by the state machine function
  2901.  *  hold a call
  2902.  * PARAMETERS
  2903.  *  info            [?]         
  2904.  *  any(?)          [IN]        Information associated with held call
  2905.  *  result(?)       [OUT]       Of execution of function which may be success or failure
  2906.  * RETURNS