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

MTK

开发平台:

C/C++

  1.  *  void
  2.  *****************************************************************************/
  3. ACTION_RESULT ProcessCallsHeld(void *info)
  4. {
  5.     /*----------------------------------------------------------------*/
  6.     /* Local Variables                                                */
  7.     /*----------------------------------------------------------------*/
  8.     /*----------------------------------------------------------------*/
  9.     /* Code Body                                                      */
  10.     /*----------------------------------------------------------------*/
  11.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessCallsHeld));
  12.     if (GetTotalCallCount() > 0)
  13.     {
  14.         SyncCallList();
  15.     }
  16.     gAttempToAnswer = FALSE;
  17.     switch (GetPreviousState())
  18.     {
  19.         case CM_INCOMING_STATE:
  20.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ProcessCallsHeld));
  21.             SetCurrentState(CM_INCOMING_STATE);
  22.             SetPreviousState(CM_HOLD_STATE);
  23.             MakeHold();
  24.             GoBackHistory();
  25.             return CM_CALL_SUCCESS;
  26.         case CM_ACTIVE_STATE:
  27.             if (gAcceptIncoming)
  28.             {
  29.                 MakeHold();
  30.                 ProcessIncomingEvents(CM_PS_INCOMING_CALL_CONNECTED, info);
  31.                 gAcceptIncoming = FALSE;
  32.             }
  33.             else
  34.             {
  35.                 SetPreviousState(CM_HOLD_STATE);
  36.                 SetCurrentState(CM_ACTIVE_STATE);
  37.                 /* if(GetMissedCallFlag()==FALSE) */
  38.                 DeleteScreenIfPresent(ITEMSCR_INCOMING_CALL);
  39.                 SetIncomingCallStateActive();
  40.                 GoBackHistory();
  41.             }
  42.             return CM_CALL_SUCCESS;
  43.         case CM_HOLD_STATE:
  44.             SetPreviousState(GetCurrentState());
  45.             SetCurrentState(CM_HOLD_STATE);
  46.             GoBackHistory();
  47.             return CM_CALL_SUCCESS;
  48.         default:
  49.             return CM_CALL_FAILURE;
  50.     }
  51.     /* return CM_CALL_FAILURE; */
  52. }
  53. /*****************************************************************************
  54.  * FUNCTION
  55.  *  PsCBackIncomingCallRejected
  56.  * DESCRIPTION
  57.  *  This function is called back by the protocol stack when there
  58.  *  Incoming Call is reject
  59.  * PARAMETERS
  60.  *  info        [?]     
  61.  * RETURNS
  62.  *  void
  63.  *****************************************************************************/
  64. void PsCBackIncomingCallRejected(void *info)
  65. {
  66.     /*----------------------------------------------------------------*/
  67.     /* Local Variables                                                */
  68.     /*----------------------------------------------------------------*/
  69.     /*----------------------------------------------------------------*/
  70.     /* Code Body                                                      */
  71.     /*----------------------------------------------------------------*/
  72.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackIncomingCallRejected));
  73.     ProcessIncomingEvents(CM_PS_INCOMING_CALL_REJECTED, info);
  74.     SetProtocolEventHandler(PsCBackNetworkCallDropped, PRT_NWRK_CALL_RELEASE);
  75. }
  76. /*****************************************************************************
  77.  * FUNCTION
  78.  *  ProcessAcceptIncomingCall
  79.  * DESCRIPTION
  80.  *  This function is called by the state machine function accept
  81.  *  incoming call
  82.  * PARAMETERS
  83.  *  info            [?]         
  84.  *  any(?)          [IN]        Information associated with incoming call
  85.  *  result(?)       [OUT]       Of execution of function which may be success or failure
  86.  * RETURNS
  87.  *  void
  88.  *****************************************************************************/
  89. ACTION_RESULT ProcessAcceptIncomingCall(void *info)
  90. {
  91.     /*----------------------------------------------------------------*/
  92.     /* Local Variables                                                */
  93.     /*----------------------------------------------------------------*/
  94.     /*----------------------------------------------------------------*/
  95.     /* Code Body                                                      */
  96.     /*----------------------------------------------------------------*/
  97.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessAcceptIncomingCall));
  98.     SetCallHandleForStartTimeUpdate(GetIncomingCallHandle());
  99.     switch (GetPreviousState())
  100.     {
  101.         case CM_IDLE_STATE:
  102.             SetPreviousState(GetCurrentState());
  103.             SetCurrentState(CM_ACTIVE_STATE);
  104.             SetIncomingCallStateActive();
  105.             EntryScr1002ActiveCall();
  106.             /* check if entering SMS application in call */
  107.             if (IsScreenPresent(SCR_ID_MSG_MAIN_MENU_NO_MMS))
  108.             {
  109.                 mmi_frm_sms_delete_action_pending();
  110.             }
  111.             DeleteUptoCmScreen();
  112.             return CM_CALL_SUCCESS;
  113.         case CM_ACTIVE_STATE:
  114.             SetPreviousState(CM_INCOMING_STATE);
  115.             SetCurrentState(CM_ACTIVE_STATE);
  116.             SetIncomingCallStateActive();
  117.             /* SS present, waiting call should not use GoBackToHistory
  118.                to remove SS screen */
  119.             if (IsScreenPresent(ITEM_SCR_USSN_MSG))
  120.             {
  121.                 DeleteScreenIfPresent(SCR_CM_ACTIVECALLSCREEN);
  122.             }
  123.             if (IsScreenPresent(SCR_CM_ACTIVECALLSCREEN))
  124.             {
  125.                 /* check if entering SMS application in call */
  126.                 if (IsScreenPresent(SCR_ID_MSG_MAIN_MENU_NO_MMS))
  127.                 {
  128.                     mmi_frm_sms_delete_action_pending();
  129.                 }
  130.                 GoBackToHistory(SCR_CM_ACTIVECALLSCREEN);
  131.             }
  132.             else
  133.             {
  134.                 EntryScr1002ActiveCall();
  135.                 DeleteScreenIfPresent(ITEM_SCR_INC_ACTIVE_OPN);
  136.                 DeleteScreenIfPresent(ITEM_SCR_INCOMING_OPTIONS);
  137.                 if (!IsScreenPresent(CM_SCR_MARKER))
  138.                 {
  139.                     AddMarkerToHistory();
  140.                 }
  141.             }
  142.             return CM_CALL_SUCCESS;
  143.         case CM_HOLD_STATE:
  144.             SetIncomingCallStateActive();
  145.             if (GetTotalHoldCallCount() > 0)
  146.             {
  147.                 SetPreviousState(GetCurrentState());
  148.                 SetCurrentState(CM_ACTIVE_STATE);
  149.                 /* check if entering SMS application in call */
  150.                 if (IsScreenPresent(SCR_ID_MSG_MAIN_MENU_NO_MMS))
  151.                 {
  152.                     mmi_frm_sms_delete_action_pending();
  153.                 }
  154.                 /* GoBackToHistory(SCR_CM_ACTIVECALLSCREEN); */
  155.             }
  156.             else
  157.             {
  158.                 SetPreviousState(GetCurrentState());
  159.                 SetCurrentState(CM_ACTIVE_STATE);
  160.                 /* check if entering SMS application in call */
  161.                 if (IsScreenPresent(SCR_ID_MSG_MAIN_MENU_NO_MMS))
  162.                 {
  163.                     mmi_frm_sms_delete_action_pending();
  164.                 }
  165.                 /* GoBackToHistory(SCR_CM_ACTIVECALLSCREEN); */
  166.             }
  167.             /* SS present, waiting call should not use GoBackToHistory
  168.                to remove SS screen */
  169.             if (IsScreenPresent(ITEM_SCR_USSN_MSG))
  170.             {
  171.                 DeleteScreenIfPresent(SCR_CM_ACTIVECALLSCREEN);
  172.                 EntryScr1002ActiveCall();
  173.                 DeleteScreenIfPresent(ITEM_SCR_INC_ACTIVE_OPN);
  174.                 DeleteScreenIfPresent(ITEM_SCR_INCOMING_OPTIONS);
  175.             }
  176.             else
  177.             {
  178.                 GoBackToHistory(SCR_CM_ACTIVECALLSCREEN);
  179.             }
  180.             return CM_CALL_SUCCESS;
  181.         case CM_INCOMING_STATE:
  182.         case CM_OUTGOING_STATE:
  183.             SetPreviousState(CM_INCOMING_STATE);
  184.             SetCurrentState(CM_ACTIVE_STATE);
  185.             SetIncomingCallStateActive();
  186.             if (IsScreenPresent(SCR_CM_ACTIVECALLSCREEN))
  187.             {
  188.                 /* check if entering SMS application in call */
  189.                 if (IsScreenPresent(SCR_ID_MSG_MAIN_MENU_NO_MMS))
  190.                 {
  191.                     mmi_frm_sms_delete_action_pending();
  192.                 }
  193.                 GoBackToHistory(SCR_CM_ACTIVECALLSCREEN);
  194.             }
  195.             else
  196.             {
  197.                 EntryScr1002ActiveCall();
  198.                 /* check if entering SMS application in call */
  199.                 if (IsScreenPresent(SCR_ID_MSG_MAIN_MENU_NO_MMS))
  200.                 {
  201.                     mmi_frm_sms_delete_action_pending();
  202.                 }
  203.                 DeleteUptoCmScreen();
  204.             }
  205.             return CM_CALL_SUCCESS;
  206.         default:
  207.             return CM_CALL_FAILURE;
  208.     }
  209. }
  210. /*****************************************************************************
  211.  * FUNCTION
  212.  *  PsCBackselectedCallEnded
  213.  * DESCRIPTION
  214.  *  This function is called back by the protocol stack when there
  215.  *  selected active call ends
  216.  *  
  217.  *  info is actually the Call Handle
  218.  * PARAMETERS
  219.  *  info        [?]     
  220.  * RETURNS
  221.  *  void
  222.  *****************************************************************************/
  223. void PsCBackselectedCallEnded(void *info)
  224. {
  225.     /*----------------------------------------------------------------*/
  226.     /* Local Variables                                                */
  227.     /*----------------------------------------------------------------*/
  228.     /*----------------------------------------------------------------*/
  229.     /* Code Body                                                      */
  230.     /*----------------------------------------------------------------*/
  231.     SetProtocolEventHandler(PsCBackNetworkCallDropped, PRT_NWRK_CALL_RELEASE);
  232.     gMyCallHandle = DeriveCallHandle(info);
  233.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackselectedCallEnded, gMyCallHandle));
  234.     ProcessIncomingEvents(CM_PS_ACTIVE_CALL_DISCONNECTED, &gMyCallHandle);
  235. }
  236. /*****************************************************************************
  237.  * FUNCTION
  238.  *  PsCBackActiveCallEndedHeldRetrieved
  239.  * DESCRIPTION
  240.  *  This function is called back by the protocol stack when active
  241.  *  call ended for retrieve held
  242.  *  
  243.  *  info is actually the Call Handle
  244.  * PARAMETERS
  245.  *  info        [?]     
  246.  * RETURNS
  247.  *  void
  248.  *****************************************************************************/
  249. void PsCBackActiveCallEndedHeldRetrieved(void *info)
  250. {
  251.     /*----------------------------------------------------------------*/
  252.     /* Local Variables                                                */
  253.     /*----------------------------------------------------------------*/
  254.     /*----------------------------------------------------------------*/
  255.     /* Code Body                                                      */
  256.     /*----------------------------------------------------------------*/
  257.     SetProtocolEventHandler(PsCBackNetworkCallDropped, PRT_NWRK_CALL_RELEASE);
  258.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackActiveCallEndedHeldRetrieved));
  259.     gMyCallHandle = DeriveCallHandle(info);
  260.     ProcessIncomingEvents(CM_PS_ALL_ACTIVE_CALL_DISCONNECTED, &gMyCallHandle);
  261. }
  262. /*****************************************************************************
  263.  * FUNCTION
  264.  *  ProcessEndAllActiveCall
  265.  * DESCRIPTION
  266.  *  This function is called by the state machine function to
  267.  *  end all active call
  268.  * PARAMETERS
  269.  *  info        [?]         
  270.  *  Call(?)     [IN]        Handle
  271.  * RETURNS
  272.  *  void
  273.  *****************************************************************************/
  274. ACTION_RESULT ProcessEndAllActiveCall(void *info)
  275. {
  276.     /*----------------------------------------------------------------*/
  277.     /* Local Variables                                                */
  278.     /*----------------------------------------------------------------*/
  279.     CM_CALL_HANDLE *handle;
  280.     /*----------------------------------------------------------------*/
  281.     /* Code Body                                                      */
  282.     /*----------------------------------------------------------------*/
  283.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessEndAllActiveCall));
  284.     handle = (CM_CALL_HANDLE*) info;
  285.     /* Start by Julia: Drop call refinement */
  286.     if ((*handle) == -1)
  287.     {
  288.         PRINT_INFORMATION(("nBad call handle -1 in EndAllActiveCalln"));
  289.         return CM_CALL_FAILURE;
  290.     }
  291.     /* dropped call is already released due to rel complete */
  292.     else if (GetMMIStructIndexof(*handle) == -1)
  293.     {
  294.         PRINT_INFORMATION(("ncall already dropped in EndAllActiveCalln"));
  295.         return CM_CALL_SUCCESS;
  296.     }
  297.     /* End by Julia */
  298.     LogCallInfoForCallHistory(*handle);
  299.     GetEndTimeAndNotifyEndCallDuration(*handle);
  300.     SetCallState(*handle, CM_IDLE_STATE, TRUE);
  301.     return CM_CALL_SUCCESS;
  302. }
  303. /*****************************************************************************
  304.  * FUNCTION
  305.  *  CBackHangupAllActive
  306.  * DESCRIPTION
  307.  *  Hangs Up all Active Calls
  308.  * PARAMETERS
  309.  *  void
  310.  * RETURNS
  311.  *  void
  312.  *****************************************************************************/
  313. void CBackHangupAllActive(void)
  314. {
  315.     /*----------------------------------------------------------------*/
  316.     /* Local Variables                                                */
  317.     /*----------------------------------------------------------------*/
  318.     U16 holdCall;
  319.     /*----------------------------------------------------------------*/
  320.     /* Code Body                                                      */
  321.     /*----------------------------------------------------------------*/
  322.     SetChldReqSent(CM_ACTION_NONE);
  323.     /* if (gHold2End)
  324.        {
  325.        gHold2End = FALSE;
  326.        return;
  327.        } */
  328.     holdCall = GetTotalHoldCallCount();
  329.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_CBackHangupAllActive, holdCall));
  330.     if ((GetCurrentState() != CM_INCOMING_STATE) && !(holdCall >= 1))
  331.     {
  332.         GetOutOfCMApplication();
  333.         return;
  334.     }
  335.     else if (holdCall >= 1)
  336.     {
  337.         return;
  338.     }
  339. }
  340. /*****************************************************************************
  341.  * FUNCTION
  342.  *  CBackHangupAllActiveAcceptOther
  343.  * DESCRIPTION
  344.  *  Hangs Up all Active Calls Except Incoming
  345.  * PARAMETERS
  346.  *  info        [?]     
  347.  * RETURNS
  348.  *  void
  349.  *****************************************************************************/
  350. void CBackHangupAllActiveAcceptOther(void *info)
  351. {
  352.     /*----------------------------------------------------------------*/
  353.     /* Local Variables                                                */
  354.     /*----------------------------------------------------------------*/
  355.     U16 holdCall, result;
  356.     /*----------------------------------------------------------------*/
  357.     /* Code Body                                                      */
  358.     /*----------------------------------------------------------------*/
  359.     SetChldReqSent(CM_ACTION_NONE);
  360.     SetProtocolEventHandler(PsCBackNetworkCallDropped, PRT_NWRK_CALL_RELEASE);
  361.     if (CheckChldRequestSuccess(info, &result))
  362.     {
  363.         holdCall = GetTotalHoldCallCount();
  364.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_CBackHangupAllActiveAcceptOther, holdCall));
  365.         if (holdCall > 0)
  366.         {
  367.             ProcessIncomingEvents(CM_PS_HELD_CALL_ACTIVE, NULL);
  368.         }
  369.     }
  370.     else
  371.     {
  372.         /* fail to hold and accept => state not changed */
  373.         ResetAllHangupFlag();
  374. RestoreCallState();
  375.         if (GetTotalCallCount() > 0)
  376.         {
  377.             ShowCallManagementErrorMessage(result);
  378.         }
  379.     }
  380. }
  381. /*****************************************************************************
  382.  * FUNCTION
  383.  *  ProcessHold2Active
  384.  * DESCRIPTION
  385.  *  This function is called by the state machine function to
  386.  *  make hold call active
  387.  * PARAMETERS
  388.  *  info                    [?]         
  389.  *  Any(?)                  [IN]        Information associated with Held Call
  390.  *  ACTION_RESULT(?)        [OUT]       If the function was a success or failure
  391.  * RETURNS
  392.  *  void
  393.  *****************************************************************************/
  394. ACTION_RESULT ProcessHold2Active(void *info)
  395. {
  396.     /*----------------------------------------------------------------*/
  397.     /* Local Variables                                                */
  398.     /*----------------------------------------------------------------*/
  399.     /*----------------------------------------------------------------*/
  400.     /* Code Body                                                      */
  401.     /*----------------------------------------------------------------*/
  402.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessHold2Active));
  403.     if (GetTotalCallCount() > 0)
  404.     {
  405.         SyncCallList();
  406.     }
  407.     UpdateStateMachine();
  408.     MakeRetrieve();
  409.     switch (GetCurrentState())
  410.     {
  411.         case CM_INCOMING_STATE:
  412.             SetPreviousState(CM_ACTIVE_STATE);
  413.             GoBackHistory();
  414.             return CM_CALL_SUCCESS;
  415.         case CM_ACTIVE_STATE:
  416.             SetPreviousState(CM_HOLD_STATE);
  417.             GoBackToHistory(SCR_CM_ACTIVECALLSCREEN);
  418.             return CM_CALL_SUCCESS;
  419.         case CM_HOLD_STATE:
  420.             EntryScr1006NotifyRetrieveSucess();
  421.             if ((GetTotalCallCount() == GetTotalActiveCallCount()) && (GetTotalHoldCallCount() == 0))
  422.             {
  423.                 SetPreviousState(GetCurrentState());
  424.                 SetCurrentState(CM_ACTIVE_STATE);
  425.             }
  426.             return CM_CALL_SUCCESS;
  427.         default:
  428.             PRINT_INFORMATION(("File: [%s]  Line: [%d] <<Problem in Hold To active>>n", __FILE__, __LINE__));
  429.             return CM_CALL_FAILURE;
  430.     }
  431.     /* return CM_CALL_FAILURE; */
  432. }
  433. /*****************************************************************************
  434.  * FUNCTION
  435.  *  ProcessCCBSDialRequest
  436.  * DESCRIPTION
  437.  *  This function is called by the state machine function
  438.  *  to dial CCBS call
  439.  * PARAMETERS
  440.  *  info            [?]         
  441.  *  any(?)          [IN]        Information associated with ccbs
  442.  *  result(?)       [OUT]       Of execution of function which may be success or failure
  443.  * RETURNS
  444.  *  void
  445.  *****************************************************************************/
  446. ACTION_RESULT ProcessCCBSDialRequest(void *info)
  447. {
  448.     /*----------------------------------------------------------------*/
  449.     /* Local Variables                                                */
  450.     /*----------------------------------------------------------------*/
  451.     /*----------------------------------------------------------------*/
  452.     /* Code Body                                                      */
  453.     /*----------------------------------------------------------------*/
  454.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessCCBSDialRequest));
  455.     MakePsActiveHold((void*)CCBSDialResponse);
  456.     OutgoingProcessCMEvent(CM_PS_SHOW_OUTGOING_CALL_SCREEN, NULL);
  457.     return CM_CALL_SUCCESS;
  458. }
  459. /*****************************************************************************
  460.  * FUNCTION
  461.  *  CCBSDialResponse
  462.  * DESCRIPTION
  463.  *  This function is called back by the protocol
  464.  *  CCBS Dial response is recieved
  465.  *  
  466.  *  info is
  467.  * PARAMETERS
  468.  *  info        [?]     
  469.  * RETURNS
  470.  *  void
  471.  *****************************************************************************/
  472. void CCBSDialResponse(void *info)
  473. {
  474.     /*----------------------------------------------------------------*/
  475.     /* Local Variables                                                */
  476.     /*----------------------------------------------------------------*/
  477.     U16 result;
  478.     /*----------------------------------------------------------------*/
  479.     /* Code Body                                                      */
  480.     /*----------------------------------------------------------------*/
  481.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_CCBSDialResponse));
  482.     SetCCBSFlag(FALSE);
  483.     if (CheckChldRequestSuccess(info, &result))
  484.     {
  485.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_CCBSDialResponse1));
  486.     }
  487.     else
  488.     {
  489.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_CCBSDialResponse2));
  490.         ProcessIncomingFailureEvents(CM_PS_CCBS_INVOKE_DIAL, result);
  491.     }
  492. }
  493. /*****************************************************************************
  494.  * FUNCTION
  495.  *  ProcessCCBSRejectRequest
  496.  * DESCRIPTION
  497.  *  This function is called by the state machine function
  498.  *  to reject CCBS call
  499.  * PARAMETERS
  500.  *  info            [?]         
  501.  *  any(?)          [IN]        Information associated with ccbs
  502.  *  result(?)       [OUT]       Of execution of function which may be success or failure
  503.  * RETURNS
  504.  *  void
  505.  *****************************************************************************/
  506. ACTION_RESULT ProcessCCBSRejectRequest(void *info)
  507. {
  508.     /*----------------------------------------------------------------*/
  509.     /* Local Variables                                                */
  510.     /*----------------------------------------------------------------*/
  511.     /*----------------------------------------------------------------*/
  512.     /* Code Body                                                      */
  513.     /*----------------------------------------------------------------*/
  514.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ProcessCCBSRejectRequest));
  515.     MakePsSendUDUB((void*)PsCBackCCBSRejectResponse);
  516.     return CM_CALL_SUCCESS;
  517. }
  518. /*****************************************************************************
  519.  * FUNCTION
  520.  *  PsCBackCCBSRejectResponse
  521.  * DESCRIPTION
  522.  *  This function is called back by the protocol
  523.  *  stack when USSD data is recieved by n/w
  524.  *  
  525.  *  info is
  526.  * PARAMETERS
  527.  *  info        [?]     
  528.  * RETURNS
  529.  *  void
  530.  *****************************************************************************/
  531. void PsCBackCCBSRejectResponse(void *info)
  532. {
  533.     /*----------------------------------------------------------------*/
  534.     /* Local Variables                                                */
  535.     /*----------------------------------------------------------------*/
  536.     /*----------------------------------------------------------------*/
  537.     /* Code Body                                                      */
  538.     /*----------------------------------------------------------------*/
  539.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_PsCBackCCBSRejectResponse));
  540.     SetProtocolEventHandler(PsCBackNetworkCallDropped, PRT_NWRK_CALL_RELEASE);
  541.     ProcessIncomingEvents(CM_PS_INCOMING_CALL_REJECTED, info);
  542. }
  543. /*****************************************************************************
  544.  * FUNCTION
  545.  *  AcceptCallForAT
  546.  * DESCRIPTION
  547.  *  Accept Incoming Call from AT Command
  548.  * PARAMETERS
  549.  *  handle      [IN]        
  550.  * RETURNS
  551.  *  void
  552.  *****************************************************************************/
  553. void AcceptCallForAT(S16 handle)
  554. {
  555.     /*----------------------------------------------------------------*/
  556.     /* Local Variables                                                */
  557.     /*----------------------------------------------------------------*/
  558.     /*----------------------------------------------------------------*/
  559.     /* Code Body                                                      */
  560.     /*----------------------------------------------------------------*/
  561.     gAttempToAnswer = TRUE;
  562.     StopIncomingCallIndication();
  563. }
  564. #define PHB_PICTURE_TYPE_PIC_FILE                1
  565. //jerson add begin 20070622
  566. #ifdef  __MMI_ONEKEY_SNDREC_SUPPORT__
  567. extern void DummyEntrySoundRecorderInCall(void);
  568. #endif
  569. //jerson add end 20070622
  570. /*****************************************************************************
  571.  * FUNCTION
  572.  *  EntryScrIncomingCallEvent
  573.  * DESCRIPTION
  574.  *  This function is the entry screen for the incoming call
  575.  * PARAMETERS
  576.  *  void
  577.  * RETURNS
  578.  *  void
  579.  *****************************************************************************/
  580. void EntryScrIncomingCallEvent(void)
  581. {
  582.     /*----------------------------------------------------------------*/
  583.     /* Local Variables                                                */
  584.     /*----------------------------------------------------------------*/
  585.     MMI_ANSWERING_MODE *AnsMode;
  586.     PU8 guiBuffer;
  587.     PU8 tmpName;
  588.     S8 *imgPath = NULL;
  589.     CM_CALL_HANDLE tmp;
  590.     U16 imgId, icon_id = IMG_CM_ICON_LINE1;
  591.     BOOL needPlayRing = MMI_FALSE;
  592.     BOOL play_now = MMI_FALSE;
  593.     U8 display_type = WGUI_CATE_MOMT_RES_TYPE_IMAGE_ID;
  594.     /*----------------------------------------------------------------*/
  595.     /* Code Body                                                      */
  596.     /*----------------------------------------------------------------*/
  597.     AnsMode = GetAnswerMode();
  598.     EntryNewScreen(ITEMSCR_INCOMING_CALL, ExitScrIncomingCallEvent, NULL, NULL);
  599.     guiBuffer = GetCurrGuiBuffer(ITEMSCR_INCOMING_CALL);
  600.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_EntryScrIncomingCallEvent));
  601.     ClearKeyEvents();
  602. #if ((defined __MMI_WGUI_CSK_ENABLE__) && (defined __MMI_TOUCH_SCREEN__))
  603.     ResetCenterSoftkey();
  604. #endif 
  605.     DeleteScreenIfPresent(CM_SCR_RDL_TIME);
  606.     TurnOnBacklight(1);
  607.     if (guiBuffer == NULL)
  608.     {
  609.         mdi_audio_suspend_background_play();
  610.     }
  611.     if (IS_LOW_BATTERY())
  612.     {
  613.         /* Robin 1209 */
  614.         ChgrPlayLowBatTone();
  615.     }
  616. #ifdef __MMI_VOIP__
  617.     if ((GetTotalCallCount() == 1) && (CM_INCOMING_STATE == GetCurrentState()) && 
  618.         (gAttempToReject == MMI_FALSE) && (gAttempToAnswer == MMI_FALSE) &&
  619.         (mmi_voip_app_total_call() == 0))
  620. #else
  621.     if ((GetTotalCallCount() == 1) && (CM_INCOMING_STATE == GetCurrentState()) && 
  622.         (gAttempToReject == MMI_FALSE) && (gAttempToAnswer == MMI_FALSE))
  623. #endif
  624.     {
  625.         if (GetCallWaitFlag() && !GetNoTwiceRingFlag())
  626.         {
  627.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_EntryScrIncomingCallEvent));
  628.             SetWait2RingCallFlag(TRUE);
  629.             SetNoTwiceRingFlag(TRUE);
  630.             needPlayRing = MMI_TRUE;
  631.         }
  632.         if (GetRingingFlag() == FALSE && GetPreviousState() != CM_IDLE_STATE)
  633.         {
  634.             needPlayRing = MMI_TRUE;
  635.         }
  636.     }
  637.     tmp = GetIncomingCallHandle();
  638.     tmpName = GetCallName(tmp);
  639.     imgId = GetCallImgId(tmp);
  640.     gdispnameForSubLCD = tmpName;
  641. #if defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__)
  642.     if (imgId == PHB_PICTURE_TYPE_PIC_FILE)
  643.     {
  644.         imgPath = GetCallImgPath(tmp);
  645.         if (imgPath == NULL)
  646.         {
  647.             imgId = IMG_PHB_DEFAULT;
  648.         }
  649.         else
  650.         {
  651.             display_type = WGUI_CATE_MOMT_RES_TYPE_IMAGE_FILE;
  652.             imgId = 0;
  653.         }
  654.     }
  655. #endif /* defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__) */ 
  656.     if (isCSPPresent == 0 ||
  657. IsResetCSPGroupService(CSP_CPHS_TELESERVICES_SERVICE_GROUP, ALS))
  658.      icon_id = 0;
  659.     else
  660.     {
  661. if (GetIncomingCallType() == CM_AUX_VOICE_CALL)
  662. icon_id = IMG_CM_ICON_LINE2;
  663.     }
  664.     /* Start by Julia: Drop call refinement */
  665. /* disconnecting call pending */
  666.     if (GetDisconnectingCallHandle() != -1)
  667.     {
  668.         /* show sub before main LCD */
  669.         ForceSubLCDScreen(EntrySubLcdScrIncomingCallEvent);
  670.     #if 1
  671.       ShowCategory17Screen(0,   /* title_id */
  672.      0,                   /* left_softkey */
  673.      0,                   /* left_softkey_icon */
  674.      0,                   /* right_softkey */
  675.      0,                   /* right_softkey_icon */
  676.      0,                   /* NotificationStringId */ 
  677.      tmpName,             /* NameOrNumber */
  678.      NULL,                /* IP_Number */
  679. icon_id,//fred
  680.      IMG_PHB_DEFAULT,     /*default_image_id */
  681.      imgId,               /* resource_id */
  682.      imgPath,             /* resource_filename */
  683.      display_type, 
  684.      0,                   /* repeat_count, video/swflash only, repeat_count, 0 = infinite */
  685.      FALSE,               /* is_visaul_update, video/swflash only, update to LCM or not */
  686.      FALSE,               /* is_video_aud, video/swflash only, play video's audio */
  687.      FALSE,               /* is_play_aud_when_start */
  688.      guiBuffer);
  689.     #else /* 0 */ 
  690. /* under construction !*/
  691. /* under construction !*/
  692. /* under construction !*/
  693. /* under construction !*/
  694. /* under construction !*/
  695. /* under construction !*/
  696. /* under construction !*/
  697. /* under construction !*/
  698. /* under construction !*/
  699. /* under construction !*/
  700. /* under construction !*/
  701. /* under construction !*/
  702. /* under construction !*/
  703. /* under construction !*/
  704. /* under construction !*/
  705. /* under construction !*/
  706. /* under construction !*/
  707. /* under construction !*/
  708. /* under construction !*/
  709. /* under construction !*/
  710.     #endif /* 0 */ 
  711.     }
  712.     else
  713.         /* End by Julia */
  714.     /* no disconnecting call */
  715.     {
  716.     #ifdef __MMI_INCOMING_CALL_VIDEO__
  717.         if ((imgId & 0x8000) || ((imgId & 0x3fff) >= VDO_ID_PHB_MTCALL_1))
  718.         {
  719.             /* use video for display */
  720.             /* user defined video file or system default video resource */
  721.             BOOL video_sound = MMI_FALSE;
  722.             BOOL video_update = MMI_FALSE;
  723.             if (imgId & 0x8000)
  724.             {
  725.              /* file */
  726.                 imgPath = GetCallVideoPath(tmp);
  727.                 if (imgPath == NULL)
  728.                 {
  729.                 imgId = IMG_PHB_DEFAULT;
  730.             }
  731.             #ifdef __MMI_SWFLASH__
  732.                 else if (imgId & 0x2000)
  733.                 {
  734.                     display_type = WGUI_CATE_MOMT_RES_TYPE_SWFLASH_FILE;
  735.                     imgId = 0;
  736.                 }
  737.             #endif /* __MMI_SWFLASH__ */
  738.             else
  739.             {
  740.                     display_type = WGUI_CATE_MOMT_RES_TYPE_VIDEO_FILE;
  741.                     imgId = 0;
  742.                 }
  743.             }
  744.             else
  745.             {
  746.              /* resource */
  747.                 imgPath = NULL;
  748.                 imgId &= 0x3fff;
  749.             #ifdef __MMI_SWFLASH__ /* Check it's default sw flash or video */
  750.                 if (imgId >= MFH_ID_PHB_MTCALL_1)
  751.                 {
  752.                     display_type = WGUI_CATE_MOMT_RES_TYPE_SWFLASH_ID;
  753.                 }
  754.                 else
  755.             #endif /* __MMI_SWFLASH__ */
  756.                 {
  757.                 display_type = WGUI_CATE_MOMT_RES_TYPE_VIDEO_ID;
  758.             }
  759.             }
  760.         #if defined (__MMI_CLAMSHELL__) && !defined (__MMI_SLIDE__)
  761.             /* show sub before main LCD */
  762.             if (IsClamClose())
  763.             {
  764.                 /* show animated sub LCD */
  765.                 ForceSubLCDScreen(EntrySubLcdScrIncomingCallEvent);
  766.             }
  767.             else
  768.         #endif /* __MMI_CLAMSHELL__ */ 
  769.             {
  770.                 /* show static sub LCD */
  771.                 video_update = MMI_TRUE;
  772.                 ForceSubLCDScreen(EntrySubLcdScrStaticIncomingCallEvent);
  773.             }
  774.             if (cm_p->alert_info.RingToneId == CM_RINGTONE_VIDEO && gAttempToAnswer == FALSE)
  775.             {
  776.                 video_sound = MMI_TRUE;
  777.             }
  778.             if ((cm_p->alert_info.AlertType == MMI_RING) ||
  779.                 (cm_p->alert_info.AlertType == MMI_VIBRATION_AND_RING) ||
  780.                 ((cm_p->alert_info.AlertType == MMI_VIBRATION_THEN_RING) && (GetRingAfterVibFlag() == TRUE)))
  781.             {
  782.                 play_now = MMI_TRUE;
  783.             }
  784.         #if 1
  785.          ShowCategory17Screen(0,    /* title_id */
  786. STR_GLOBAL_OPTIONS,       /* left_softkey */
  787. IMG_GLOBAL_OPTIONS,       /* left_softkey_icon */
  788. INC_SCR_RSK_STR,          /* right_softkey */
  789. 0,                        /* right_softkey_icon */
  790. 0,                        /* NotificationStringId */ 
  791. tmpName,                  /* NameOrNumber */
  792. NULL,                     /* IP_Number */
  793. icon_id,//fred
  794. IMG_PHB_DEFAULT, 
  795. imgId,                    /* resource_id */
  796. imgPath,                  /* resource_filename */
  797. display_type,
  798. 0,                        /* repeat_count, video only, repeat_count, 0 = infinite */
  799. video_update,             /* is_visaul_update, video only, update to LCM or not */
  800. video_sound,              /* is_video_aud, video only, play video's audio */
  801. play_now,
  802. guiBuffer);               /* history_buffer */
  803.         #else /* 0 */ 
  804. /* under construction !*/
  805. /* under construction !*/
  806. /* under construction !*/
  807. /* under construction !*/
  808. /* under construction !*/
  809. /* under construction !*/
  810. /* under construction !*/
  811. /* under construction !*/
  812. /* under construction !*/
  813. /* under construction !*/
  814. /* under construction !*/
  815. /* under construction !*/
  816. /* under construction !*/
  817. /* under construction !*/
  818. /* under construction !*/
  819. /* under construction !*/
  820. /* under construction !*/
  821.         #endif /* 0 */ 
  822.             /* bad video, play default ring */
  823.             if (play_now == MMI_TRUE && video_sound == MMI_TRUE && 
  824.              (IsCategory17VideoValid() == MMI_FALSE 
  825. #ifdef __MMI_SWFLASH__            
  826.              && IsCategory17SWFlashValid() == MMI_FALSE
  827. #endif            
  828.              ))
  829.             {
  830.                 PHB_CM_INTERFACE *temp;
  831.                 needPlayRing = MMI_TRUE;
  832.                 temp = GetCMPhoneBookStruct();
  833.                 temp->videoId = 0;
  834.                 SetCMPhoneBookStruct(temp);
  835.             }
  836.         }
  837.         else    
  838.         /* use image for display */
  839.     #endif /* __MMI_INCOMING_CALL_VIDEO__ */ 
  840.         {
  841.             /* show sub before main LCD */
  842.             ForceSubLCDScreen(EntrySubLcdScrIncomingCallEvent);
  843.         #if 1
  844.       ShowCategory17Screen(0,  /* title_id */
  845. STR_GLOBAL_OPTIONS,   /* left_softkey */
  846. IMG_GLOBAL_OPTIONS,   /* left_softkey_icon */
  847. INC_SCR_RSK_STR,      /* right_softkey */
  848. 0,                    /* right_softkey_icon */
  849. 0,                    /* NotificationStringId */ 
  850. tmpName,              /* NameOrNumber */
  851. NULL,                 /* IP_Number */
  852. icon_id,//fred
  853. IMG_PHB_DEFAULT, 
  854. imgId,                /* resource_id */
  855. imgPath,              /* resource_filename */
  856. display_type,
  857. 0,                    /* repeat_count, video only, repeat_count, 0 = infinite */
  858. FALSE,                /* is_visaul_update, video only, update to LCM or not */
  859. FALSE,                /* is_video_aud, video only, play video's audio */
  860. FALSE,
  861. guiBuffer);           /* history_buffer */
  862.         #else /* 0 */ 
  863. /* under construction !*/
  864. /* under construction !*/
  865. /* under construction !*/
  866. /* under construction !*/
  867. /* under construction !*/
  868. /* under construction !*/
  869. /* under construction !*/
  870. /* under construction !*/
  871. /* under construction !*/
  872. /* under construction !*/
  873. /* under construction !*/
  874. /* under construction !*/
  875. /* under construction !*/
  876. /* under construction !*/
  877. /* under construction !*/
  878. /* under construction !*/
  879. /* under construction !*/
  880. /* under construction !*/
  881. /* under construction !*/
  882. /* under construction !*/
  883. /* under construction !*/
  884. /* under construction !*/
  885. /* under construction !*/
  886. /* under construction !*/
  887. /* under construction !*/
  888. /* under construction !*/
  889. /* under construction !*/
  890. /* under construction !*/
  891. /* under construction !*/
  892. /* under construction !*/
  893. /* under construction !*/
  894. /* under construction !*/
  895. /* under construction !*/
  896. /* under construction !*/
  897.             #ifdef __MMI_INCOMING_CALL_VIDEO__
  898. /* under construction !*/
  899. /* under construction !*/
  900. /* under construction !*/
  901. /* under construction !*/
  902. /* under construction !*/
  903.             #endif /* __MMI_INCOMING_CALL_VIDEO__ */ 
  904.         #endif /* 0 */ 
  905.         }
  906.     }
  907.     /* Start by Julia: Drop call refinement */
  908.     if (GetDisconnectingCallHandle() != -1)
  909.     {
  910.         SetKeyHandler(ReleaseCall, KEY_END, KEY_EVENT_DOWN);
  911.         return;
  912.     }
  913.     else
  914.         /* End by Julia */
  915.     {
  916.         if (GetTotalCallCount() > 1)
  917.         {
  918.             /* other call existed */
  919.             /* soft key */
  920.             SetLeftSoftkeyFunction(EntryScrIncomingMultipleOptions, KEY_EVENT_UP);
  921.             /* SEND, END key */
  922.             if (GetTotalActiveCallCount() == 0 || GetTotalHoldCallCount() == 0)
  923.             {
  924.                 SetKeyHandler(KbCBackCallIncomingAccepted, KEY_SEND, KEY_EVENT_DOWN);
  925.             }
  926.         #ifdef __MMI_CLAMSHELL__
  927.             SetKeyHandler(KbCBackCallIncomingRejected, KEY_END, KEY_EVENT_DOWN);
  928.         #else 
  929.             SetKeyHandler(KbCBackEndAllCallsExceptIncoming, KEY_END, KEY_EVENT_DOWN);
  930.         #endif 
  931.             /* group key */
  932.             if (!(EmergencyCallPresent() || IsWapCallPresent()))
  933.             {
  934.                 SetGroupKeyHandler(
  935.                     EnterScreenAndHandleDigit,
  936.                     (PU16) CMIdleScreenDigits,
  937.                     MAX_CM_SCREEN_DIGITS - 1,
  938.                     KEY_EVENT_DOWN);
  939.             #if ( (defined  __MMI_WGUI_CSK_ENABLE__) && (defined __MMI_TOUCH_SCREEN__) )
  940.      EnableCenterSoftkey(0, IMG_CSK_DIAL_ICON);
  941.              SetCenterSoftkeyFunction(EnterScreenAndHandleDigit, KEY_EVENT_UP);
  942.      redraw_center_softkey();    
  943. #endif
  944.             }
  945.             /* side key */
  946.             if (GetTotalActiveCallCount() > 0)
  947.             {
  948.                 SetSideVolumeKeysForCM();
  949.             }
  950.         }
  951.         else
  952.         {
  953.             /* no other call */
  954.             /* group key */
  955.             if (AnsMode->anyKey == TRUE)
  956.             {
  957.                 SetGroupKeyHandler(KbCBackCallIncomingAccepted, (PU16) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_DOWN);
  958.             }
  959.             else
  960.             {
  961.                 SetGroupKeyHandler(
  962.                     InvisibleDigitHandler,
  963.                     (PU16) CMIdleScreenDigits,
  964.                     MAX_CM_SCREEN_DIGITS - 1,
  965.                     KEY_EVENT_DOWN);
  966.             }
  967.             /* soft key */
  968.             SetLeftSoftkeyFunction(EntryScrIncomingOptions, KEY_EVENT_UP);
  969. //jerson add begin 20070622
  970. #ifdef  __MMI_ONEKEY_SNDREC_SUPPORT__
  971.      SetKeyHandler(DummyEntrySoundRecorderInCall,KEY_ENTER,KEY_EVENT_UP);
  972. #endif
  973. //jerson add end 20070622
  974.             /* SEND, END key */
  975.             SetKeyHandler(KbCBackCallIncomingAccepted, KEY_SEND, KEY_EVENT_DOWN);
  976.             SetKeyHandler(KbCBackCallIncomingRejected, KEY_END, KEY_EVENT_DOWN);
  977.             /* side key */
  978.         #ifdef __MMI_CLAMSHELL__
  979.         #ifdef __MMI_SIDEKEY_SUPPRESS_RING__
  980.             SetKeyHandler(StopIncomingCallIndication, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  981.             SetKeyHandler(KbCBackCallIncomingSuppressTone, KEY_VOL_DOWN, KEY_EVENT_UP);
  982.             SetKeyHandler(KbCBackCallIncomingRejectedNoTone, KEY_VOL_DOWN, KEY_EVENT_LONG_PRESS);
  983.         #else /* __MMI_SIDEKEY_SUPPRESS_RING__ */ 
  984.             SetKeyHandler(KbCBackCallIncomingAccepted, KEY_VOL_UP, KEY_EVENT_DOWN);
  985.             SetKeyHandler(KbCBackCallIncomingRejected, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  986.         #endif /* __MMI_SIDEKEY_SUPPRESS_RING__ */ 
  987. //KP Jerry add on 2007-2-12 start
  988. #else
  989. #ifdef __MMI_SIDEKEY_SUPPRESS_RING__
  990.             SetKeyHandler(StopIncomingCallIndication,KEY_RSK,KEY_EVENT_DOWN);   //old=  KEY_VOL_DOWN  //jerson modify 20070622
  991.      SetKeyHandler(KbCBackCallIncomingSuppressTone,KEY_RSK,KEY_EVENT_UP);
  992.      SetKeyHandler(KbCBackCallIncomingRejectedNoTone,KEY_RSK,KEY_EVENT_LONG_PRESS);
  993. #endif
  994. //KP Jerry add on 2007-2-12 end
  995.         #endif /* __MMI_CLAMSHELL__ */ 
  996.         }
  997.         SetRightSoftkeyFunction(KbCBackCallIncomingRejected, KEY_EVENT_UP);
  998.     }
  999.     if (needPlayRing == MMI_TRUE && gAttempToAnswer == MMI_FALSE)
  1000.     {
  1001.         ShowIncomingCallIndication();
  1002.     }
  1003.     if (gAttempToAnswer == TRUE)
  1004.     {
  1005.         ClearInputEventHandler(MMI_DEVICE_ALL);
  1006.     }
  1007. }
  1008. /*****************************************************************************
  1009.  * FUNCTION
  1010.  *  ExitScrIncomingCallEvent
  1011.  * DESCRIPTION
  1012.  *  This function is the exit screen for the incoming call
  1013.  * PARAMETERS
  1014.  *  void
  1015.  * RETURNS
  1016.  *  void
  1017.  *****************************************************************************/
  1018. void ExitScrIncomingCallEvent(void)
  1019. {
  1020.     /*----------------------------------------------------------------*/
  1021.     /* Local Variables                                                */
  1022.     /*----------------------------------------------------------------*/
  1023.     history scr101;
  1024.     U16 nHistory = 0;
  1025.     /*----------------------------------------------------------------*/
  1026.     /* Code Body                                                      */
  1027.     /*----------------------------------------------------------------*/
  1028.     if (-1 != GetIncomingCallHandle())
  1029.     {
  1030.         pfnUnicodeStrcpy((S8*) scr101.inputBuffer, (PS8) & nHistory);
  1031.         scr101.scrnID = ITEMSCR_INCOMING_CALL;
  1032.         scr101.entryFuncPtr = EntryScrIncomingCallEvent;
  1033.         GetCategoryHistory(scr101.guiBuffer);
  1034.         AddHistory(scr101);
  1035.     }
  1036. }
  1037. /*****************************************************************************
  1038.  * FUNCTION
  1039.  *  EntrySubLcdScrIncomingCallEvent
  1040.  * DESCRIPTION
  1041.  *  Entry screen for Sub Lcd Incoming Call
  1042.  * PARAMETERS
  1043.  *  void
  1044.  * RETURNS
  1045.  *  void
  1046.  *****************************************************************************/
  1047. void EntrySubLcdScrIncomingCallEvent(void)
  1048. {
  1049.     /*----------------------------------------------------------------*/
  1050.     /* Local Variables                                                */
  1051.     /*----------------------------------------------------------------*/
  1052.     /*----------------------------------------------------------------*/
  1053.     /* Code Body                                                      */
  1054.     /*----------------------------------------------------------------*/
  1055.     ExecSubLCDCurrExitHandler();
  1056.     ShowCategory311Screen(gdispnameForSubLCD, IMG_CM_SUBLCD_CALLING, NULL);
  1057.     SetSubLCDExitHandler(ExitSubLcdScrIncomingCallEvent);
  1058. }
  1059. #ifdef __MMI_INCOMING_CALL_VIDEO__
  1060. /*****************************************************************************
  1061.  * FUNCTION
  1062.  *  EntrySubLcdScrStaticIncomingCallEvent
  1063.  * DESCRIPTION
  1064.  *  Entry screen for Sub Lcd Incoming Call
  1065.  * PARAMETERS
  1066.  *  void
  1067.  * RETURNS
  1068.  *  void
  1069.  *****************************************************************************/
  1070. void EntrySubLcdScrStaticIncomingCallEvent(void)
  1071. {
  1072.     /*----------------------------------------------------------------*/
  1073.     /* Local Variables                                                */
  1074.     /*----------------------------------------------------------------*/
  1075.     /*----------------------------------------------------------------*/
  1076.     /* Code Body                                                      */
  1077.     /*----------------------------------------------------------------*/
  1078.     ExecSubLCDCurrExitHandler();
  1079.     ShowCategory332Screen(IMG_CM_STATE_CONNECTED);
  1080.     SetSubLCDExitHandler(ExitSubLcdScrStaticIncomingCallEvent);
  1081. }
  1082. #endif /* __MMI_INCOMING_CALL_VIDEO__ */ 
  1083. /*****************************************************************************
  1084.  * FUNCTION
  1085.  *  ExitSubLcdScrIncomingCallEvent
  1086.  * DESCRIPTION
  1087.  *  Exit Handler for Sub Lcd Incoming Call Screen
  1088.  * PARAMETERS
  1089.  *  void
  1090.  * RETURNS
  1091.  *  void
  1092.  *****************************************************************************/
  1093. void ExitSubLcdScrIncomingCallEvent(void)
  1094. {
  1095.     /*----------------------------------------------------------------*/
  1096.     /* Local Variables                                                */
  1097.     /*----------------------------------------------------------------*/
  1098.     /*----------------------------------------------------------------*/
  1099.     /* Code Body                                                      */
  1100.     /*----------------------------------------------------------------*/
  1101. #ifdef __MMI_INCOMING_CALL_VIDEO__
  1102.     StopCategory17Video();
  1103. #endif 
  1104.     if (-1 != GetIncomingCallHandle() && !IsSubLCDScreenPresent(SUB_LCD_ITEMSCR_INCOMING_CALL))
  1105.     {
  1106.         SubLCDHistoryNode SubLCDHistory;
  1107.         SubLCDHistory.entryFuncPtr = EntrySubLcdScrIncomingCallEvent;
  1108.         AddSubLCDHistoryWithScrID(&SubLCDHistory, SUB_LCD_ITEMSCR_INCOMING_CALL);
  1109.     }
  1110. }
  1111. #ifdef __MMI_INCOMING_CALL_VIDEO__
  1112. /*****************************************************************************
  1113.  * FUNCTION
  1114.  *  ExitSubLcdScrStaticIncomingCallEvent
  1115.  * DESCRIPTION
  1116.  *  Exit Handler for Sub Lcd Incoming Call Screen
  1117.  * PARAMETERS
  1118.  *  void
  1119.  * RETURNS
  1120.  *  void
  1121.  *****************************************************************************/
  1122. void ExitSubLcdScrStaticIncomingCallEvent(void)
  1123. {
  1124.     /*----------------------------------------------------------------*/
  1125.     /* Local Variables                                                */
  1126.     /*----------------------------------------------------------------*/
  1127.     /*----------------------------------------------------------------*/
  1128.     /* Code Body                                                      */
  1129.     /*----------------------------------------------------------------*/
  1130.     StopCategory17Video();
  1131.     if (-1 != GetIncomingCallHandle() && !IsSubLCDScreenPresent(SUB_LCD_ITEMSCR_INCOMING_CALL))
  1132.     {
  1133.         SubLCDHistoryNode SubLCDHistory;
  1134.         SubLCDHistory.entryFuncPtr = EntrySubLcdScrStaticIncomingCallEvent;
  1135.         AddSubLCDHistoryWithScrID(&SubLCDHistory, SUB_LCD_ITEMSCR_INCOMING_CALL);
  1136.     }
  1137. }
  1138. #endif /* __MMI_INCOMING_CALL_VIDEO__ */ 
  1139. /*****************************************************************************
  1140.  * FUNCTION
  1141.  *  EntryScrIncomingMultipleOptions
  1142.  * DESCRIPTION
  1143.  *  Entry screen for Incoming Call option menu when
  1144.  *  there are more than one calls
  1145.  * PARAMETERS
  1146.  *  void
  1147.  * RETURNS
  1148.  *  void
  1149.  *****************************************************************************/
  1150. void EntryScrIncomingMultipleOptions(void)
  1151. {
  1152.     /*----------------------------------------------------------------*/
  1153.     /* Local Variables                                                */
  1154.     /*----------------------------------------------------------------*/
  1155.     PU8 guiBuffer;
  1156.     static U8 *PopUpList[10];
  1157.     U16 nNumofItem;         /* Stores no of children in the submenu */
  1158.     U16 nStrItemList[10];   /* Stores the strings id of submenus returned */
  1159.     U16 menuId;
  1160.     S16 nActiveCall;
  1161.     U16 nHeldCall;
  1162.     /*----------------------------------------------------------------*/
  1163.     /* Code Body                                                      */
  1164.     /*----------------------------------------------------------------*/
  1165.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_EntryScrIncomingMultipleOptions));
  1166.     nActiveCall = GetTotalActiveCallCount();
  1167.     nHeldCall = GetTotalHoldCallCount();
  1168.     if (nActiveCall == 1 && nHeldCall == 0)
  1169.     {
  1170.         if (GetWapCallPresent())
  1171.         {
  1172.             menuId = MITEM_INC_WAP_OPT_PSEUDO;
  1173.         }
  1174.         else
  1175.         {
  1176.             menuId = MITEM_INC_ACT_OPT_PSEUDO;
  1177.         }
  1178.     }
  1179.     else if (nActiveCall == 0 && nHeldCall == 1)
  1180.     {
  1181.         menuId = MITEM_INC_HLD_OPT_PSEUDO;
  1182.     }
  1183.     else if (nActiveCall > 1 && nHeldCall == 0)
  1184.     {
  1185.         menuId = MITEM_IMA_OPT_PSEUDO;
  1186.     }
  1187.     else if (nActiveCall == 0 && nHeldCall > 1)
  1188.     {
  1189.         menuId = MITEM_INC_MHLD_OPT_PSEUDO;
  1190.     }
  1191.     else if (nActiveCall == 1 && nHeldCall == 1)
  1192.     {
  1193.         menuId = MITEM_IAH_OPT_PSEUDO;
  1194.     }
  1195.     else if (nActiveCall > 1 && nHeldCall > 0)
  1196.     {
  1197.         menuId = MITEM_IMAH_OPT_PSEUDO;
  1198.     }
  1199.     else if (nActiveCall > 0 && nHeldCall > 1)
  1200.     {
  1201.         menuId = MITEM_IAMH_OPT_PSEUDO;
  1202.     }
  1203.     else
  1204.     {
  1205.         return;
  1206.     }
  1207.     /* incoming call option menu will not enter other app, 
  1208.        no need to set CM flag */
  1209.     /* SetCMScrnFlag(TRUE); */
  1210.     EntryNewScreen(ITEM_SCR_INC_MACT_OPN, ExitScrIncomingMultipleOptions, NULL, NULL);
  1211.     guiBuffer = GetCurrGuiBuffer(ITEM_SCR_INC_MACT_OPN);    /* Getting the Index from history  */
  1212.     SetParentHandler(menuId);
  1213.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1214. #if defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__)
  1215.     if (mmi_bt_is_incall_aud_swap2bt())
  1216.     {
  1217.         mmi_frm_hide_menu_item(MITEM_INC_ACT_OPT_LOUDSP);
  1218.     }
  1219. #endif /* defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__) */ 
  1220. #ifdef __MMI_VOIP__
  1221.     /* hide call deflect option menu if voip call exists */
  1222.     if (mmi_voip_app_total_call())
  1223.     {
  1224.         mmi_frm_hide_menu_item(MITEM_INC_OPT_DEFLN);
  1225.     }
  1226. #endif /* __MMI_VOIP__ */
  1227.     nNumofItem = GetNumOfChild_Ext(menuId);
  1228.     GetSequenceStringIds_Ext(menuId, nStrItemList);
  1229.     ConstructHintsList(menuId, PopUpList);
  1230.     ShowCategory55Screen(
  1231.         STR_SCR1002_CAPTION,
  1232.         IMG_SCR1002_CAPTION,
  1233.         STR_GLOBAL_OK,
  1234.         IMG_GLOBAL_OK,
  1235.         STR_GLOBAL_BACK,
  1236.         IMG_GLOBAL_BACK,
  1237.         nNumofItem,
  1238.         nStrItemList,
  1239.         (U8 **) PopUpList,
  1240.         0,
  1241.         guiBuffer);
  1242.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1243.     if (nActiveCall == 0 || nHeldCall == 0)
  1244.     {
  1245.         SetKeyHandler(KbCBackCallIncomingAccepted, KEY_SEND, KEY_EVENT_DOWN);
  1246.     }
  1247. #ifdef __MMI_CLAMSHELL__
  1248.     SetKeyHandler(KbCBackCallIncomingRejected, KEY_END, KEY_EVENT_DOWN);
  1249. #else 
  1250.     SetKeyHandler(KbCBackEndAllCallsExceptIncoming, KEY_END, KEY_EVENT_DOWN);
  1251. #endif 
  1252.     SetSideVolumeKeysForCM();
  1253.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1254. }
  1255. /*****************************************************************************
  1256.  * FUNCTION
  1257.  *  ExitScrIncomingMultipleOptions
  1258.  * DESCRIPTION
  1259.  *  
  1260.  * PARAMETERS
  1261.  *  void
  1262.  * RETURNS
  1263.  *  void
  1264.  *****************************************************************************/
  1265. void ExitScrIncomingMultipleOptions(void)
  1266. {
  1267.     /*----------------------------------------------------------------*/
  1268.     /* Local Variables                                                */
  1269.     /*----------------------------------------------------------------*/
  1270.     history Scr1001;
  1271. U16 nHistory=0;
  1272.     /*----------------------------------------------------------------*/
  1273.     /* Code Body                                                      */
  1274.     /*----------------------------------------------------------------*/
  1275. #if defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__)
  1276.     mmi_frm_unhide_menu_item(MITEM_INC_ACT_OPT_LOUDSP);
  1277. #endif 
  1278.     Scr1001.scrnID = ITEM_SCR_INC_MACT_OPN;
  1279.     Scr1001.entryFuncPtr = EntryScrIncomingMultipleOptions;
  1280.     pfnUnicodeStrcpy((S8*) Scr1001.inputBuffer, (PS8) & nHistory);    
  1281.     GetCategoryHistory(Scr1001.guiBuffer);
  1282.     AddHistory(Scr1001);
  1283. }
  1284. /*****************************************************************************
  1285.  * FUNCTION
  1286.  *  EntryScrIncomingOptions
  1287.  * DESCRIPTION
  1288.  *  This function is the entry screen for the incoming call options
  1289.  * PARAMETERS
  1290.  *  void
  1291.  * RETURNS
  1292.  *  void
  1293.  *****************************************************************************/
  1294. void EntryScrIncomingOptions(void)
  1295. {
  1296.     /*----------------------------------------------------------------*/
  1297.     /* Local Variables                                                */
  1298.     /*----------------------------------------------------------------*/
  1299.     U8 *guiBuffer;
  1300.     S32 number_of_items = 0;
  1301.     U16 list_of_items[32];
  1302.     /*----------------------------------------------------------------*/
  1303.     /* Code Body                                                      */
  1304.     /*----------------------------------------------------------------*/
  1305.     EntryNewScreen(ITEM_SCR_INCOMING_OPTIONS, NULL, EntryScrIncomingOptions, NULL);
  1306.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_EntryScrIncomingOptions));
  1307.     /* incoming call option menu will not enter other app, 
  1308.        no need to set CM flag */
  1309.     /* SetCMScrnFlag(TRUE); */
  1310.     guiBuffer = GetCurrGuiBuffer(ITEM_SCR_INCOMING_OPTIONS);    /* Getting the Index from history  */
  1311. #ifdef __MMI_VOIP__
  1312.     /* hide call deflect option menu if voip call exists */
  1313.     if (mmi_voip_app_total_call())
  1314.     {
  1315.         mmi_frm_hide_menu_item(MITEM_INC_OPT_DEFLN);
  1316.     }
  1317. #endif /* __MMI_VOIP__ */
  1318.     number_of_items = GetNumOfChild_Ext(MITEM_OPT_PSEUDO);
  1319.     GetSequenceStringIds_Ext(MITEM_OPT_PSEUDO, list_of_items);
  1320.     
  1321.     SetParentHandler(MITEM_OPT_PSEUDO);
  1322.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1323.     ShowCategory1Screen(
  1324.         STR_SCR1002_CAPTION,
  1325.         0,
  1326.         STR_GLOBAL_OK,
  1327.         IMG_GLOBAL_OK,
  1328.         STR_GLOBAL_BACK,
  1329.         IMG_GLOBAL_BACK,
  1330.         number_of_items,
  1331.         list_of_items,
  1332.         0,
  1333.         guiBuffer);
  1334.     /*
  1335.      * Leo Remove, use category1 instead.
  1336.      * ShowCategory101Screen(STR_OPT_PSEUDO, 0,
  1337.      * STR_GLOBAL_OK, IMG_GLOBAL_OK,
  1338.      * STR_GLOBAL_BACK, IMG_GLOBAL_BACK,
  1339.      * MITEM_OPT_PSEUDO, guiBuffer);
  1340.      */
  1341.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1342.     SetKeyHandler(KbCBackCallIncomingRejected, KEY_END, KEY_EVENT_DOWN);
  1343.     SetKeyHandler(KbCBackCallIncomingAccepted, KEY_SEND, KEY_EVENT_DOWN);
  1344.     SetSideVolumeKeysForCM();
  1345.     /* 
  1346.      * #ifdef __MMI_SIDEKEY_SUPPRESS_RING__
  1347.      * SetKeyHandler(StopIncomingCallIndication,KEY_VOL_DOWN,KEY_EVENT_DOWN);
  1348.      * SetKeyHandler(KbCBackCallIncomingSuppressTone,KEY_VOL_DOWN,KEY_EVENT_UP);
  1349.      * SetKeyHandler(KbCBackCallIncomingRejectedNoTone,KEY_VOL_DOWN,KEY_EVENT_LONG_PRESS);
  1350.      * #else
  1351.      * SetKeyHandler(KbCBackCallIncomingAccepted,KEY_VOL_UP,KEY_EVENT_DOWN);
  1352.      * SetKeyHandler(KbCBackCallIncomingRejected,KEY_VOL_DOWN,KEY_EVENT_DOWN);
  1353.      * #endif
  1354.      */
  1355.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1356. }
  1357. /*****************************************************************************
  1358.  * FUNCTION
  1359.  *  EntryScrCcbsActivate
  1360.  * DESCRIPTION
  1361.  *  This function is the entry screen for displaying CCBS Info to user
  1362.  * PARAMETERS
  1363.  *  void
  1364.  * RETURNS
  1365.  *  void
  1366.  *****************************************************************************/
  1367. void EntryScrCcbsActivate(void)
  1368. {
  1369.     /*----------------------------------------------------------------*/
  1370.     /* Local Variables                                                */
  1371.     /*----------------------------------------------------------------*/
  1372.     /*----------------------------------------------------------------*/
  1373.     /* Code Body                                                      */
  1374.     /*----------------------------------------------------------------*/
  1375.     EntryNewScreen(ITEM_SCR_CCBS_IND, ExitScrCcbsActivate, NULL, NULL);
  1376.     ShowCategory123Screen(0, 0, STR_GLOBAL_YES, 0, STR_GLOBAL_NO, 0, STR_NFY_CCBS, IMG_GLOBAL_QUESTION, NULL);
  1377.     SetLeftSoftkeyFunction(ActivateCCBS, KEY_EVENT_UP);
  1378.     SetRightSoftkeyFunction(IgnoreCCBS, KEY_EVENT_UP);
  1379.     SetKeyHandler(IgnoreCCBS, KEY_END, KEY_EVENT_DOWN);
  1380.     if (GetTotalCallCount() == 0)
  1381.     {
  1382.         playRequestedTone(CCBS_TONE);
  1383.         SetErrorToneFlag(CCBS_TONE);
  1384.     }
  1385. }
  1386. /*****************************************************************************
  1387.  * FUNCTION
  1388.  *  ExitScrCcbsActivate
  1389.  * DESCRIPTION
  1390.  *  This function is the exit screen for CCBS info to user
  1391.  * PARAMETERS
  1392.  *  void
  1393.  * RETURNS
  1394.  *  void
  1395.  *****************************************************************************/
  1396. void ExitScrCcbsActivate(void)
  1397. {
  1398.     /*----------------------------------------------------------------*/
  1399.     /* Local Variables                                                */
  1400.     /*----------------------------------------------------------------*/
  1401.     /*----------------------------------------------------------------*/
  1402.     /* Code Body                                                      */
  1403.     /*----------------------------------------------------------------*/
  1404.     if (GetErrorToneFlag() > 0)
  1405.     {
  1406.         stopRequestedTone(GetErrorToneFlag());
  1407.         SetErrorToneFlag(0);
  1408.     }
  1409. }
  1410. /*****************************************************************************
  1411.  * FUNCTION
  1412.  *  EntryScrNotifyCCBSSuccess
  1413.  * DESCRIPTION
  1414.  *  This is a notification which does not have history and used when the
  1415.  *  ccbs activation is success with a timeout of CM_NOTIFY_TIMEOUT.
  1416.  *  
  1417.  *  This has to display the time,we need to have the time display catefory function.
  1418.  * PARAMETERS
  1419.  *  void
  1420.  * RETURNS
  1421.  *  void
  1422.  *****************************************************************************/
  1423. void EntryScrNotifyCCBSSuccess(void)
  1424. {
  1425.     /*----------------------------------------------------------------*/
  1426.     /* Local Variables                                                */
  1427.     /*----------------------------------------------------------------*/
  1428.     /*----------------------------------------------------------------*/
  1429.     /* Code Body                                                      */
  1430.     /*----------------------------------------------------------------*/
  1431.     EntryNewScreen(SCR_ECT_NFY_TRNT, ExitScrNotifyCMPopUpTone, NULL, NULL);
  1432.     ShowCategory62Screen(CCBS_ACTIVATED_STR, IMG_GLOBAL_ACTIVATED, NULL);
  1433.     if (GetTotalCallCount() == 0)
  1434.     {
  1435.         playRequestedTone(SUCCESS_TONE_IN_CALL);
  1436.         SetErrorToneFlag(SUCCESS_TONE_IN_CALL);
  1437.     }
  1438.     SetPOPUpFlag(TRUE);
  1439.     SetKeysForPOPUp();
  1440.     StartTimer(CM_NOTIFYDURATION_TIMER, CM_NOTIFY_TIMEOUT, GoBackfromNotifyScr);
  1441. }
  1442. /*****************************************************************************
  1443.  * FUNCTION
  1444.  *  EntryScrCCBSInvokeEvent
  1445.  * DESCRIPTION
  1446.  *  This function is the entry screen for the CCBS Invoke
  1447.  * PARAMETERS
  1448.  *  void
  1449.  * RETURNS
  1450.  *  void
  1451.  *****************************************************************************/
  1452. void EntryScrCCBSInvokeEvent(void)
  1453. {
  1454.     /*----------------------------------------------------------------*/
  1455.     /* Local Variables                                                */
  1456.     /*----------------------------------------------------------------*/
  1457.     PU8 guiBuffer;
  1458.     PU8 tmpName;
  1459.     S8 *imgPath = NULL;
  1460.     CM_CALL_HANDLE tmp;
  1461.     U16 imgId;
  1462.     BOOL needPlayRing = MMI_FALSE;
  1463.     /*----------------------------------------------------------------*/
  1464.     /* Code Body                                                      */
  1465.     /*----------------------------------------------------------------*/
  1466.     EntryNewScreen(ITEMSCR_CCBS_INVOKE, NULL, EntryScrCCBSInvokeEvent, NULL);
  1467.     TurnOnBacklight(1);
  1468.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_EntryScrCCBSInvokeEvent));
  1469.     if ((GetTotalCallCount() == 1) && (CM_INCOMING_STATE == GetCurrentState()))
  1470.     {
  1471.         if (GetCallWaitFlag())
  1472.         {
  1473.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_EntryScrIncomingCallEvent));
  1474.             SetWait2RingCallFlag(TRUE);
  1475.             needPlayRing = MMI_TRUE;
  1476.         }
  1477.     }
  1478.     guiBuffer = GetCurrGuiBuffer(ITEMSCR_CCBS_INVOKE);
  1479.     tmp = GetIncomingCallHandle();
  1480.     tmpName = GetCallName(tmp);
  1481.     imgId = GetCallImgId(tmp);
  1482. #if defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__)
  1483.     if (imgId == 1)
  1484.     {
  1485.         imgPath = GetCallImgPath(tmp);
  1486.         if (imgPath == NULL)
  1487.         {
  1488.             imgId = IMG_PHB_DEFAULT;
  1489.         }
  1490.     }
  1491. #endif /* defined(__MMI_PHB_CALL_SHOW_PICTURE_FROM_FILE__) */ 
  1492.     if (GetTotalCallCount() > 1)
  1493.     {
  1494.         if (imgId == 1)
  1495.         {
  1496.             ShowCategory18Screen(0, STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS, STR_GLOBAL_BACK, IMG_GLOBAL_BACK, 0, tmpName, NULL, 0,/*fred*/ 0, imgPath, FALSE, guiBuffer);  /* INC_SCR_NFY_CCBS_STR */
  1497.         }
  1498.         else
  1499.         {
  1500.             ShowCategory18Screen(0, STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS, STR_GLOBAL_BACK, IMG_GLOBAL_BACK, 0, tmpName, NULL, 0,/*fred*/ imgId, NULL, FALSE, guiBuffer); /* INC_SCR_NFY_CCBS_STR */
  1501.         }
  1502.         SetLeftSoftkeyFunction(EntryScrCCBSInvokeMultipleOptions, KEY_EVENT_UP);
  1503.         if (GetTotalActiveCallCount() == 0 || GetTotalHoldCallCount() == 0)
  1504.         {
  1505.             SetKeyHandler(KbCBackCCBSDialCall, KEY_SEND, KEY_EVENT_DOWN);
  1506.         }
  1507.     #ifdef __MMI_CLAMSHELL__
  1508.         SetKeyHandler(KbCBackCCBSInvokeRejected, KEY_END, KEY_EVENT_DOWN);
  1509.     #else 
  1510.         SetKeyHandler(KbCBackEndAllCallsExceptIncoming, KEY_END, KEY_EVENT_DOWN);
  1511.     #endif 
  1512.         SetSideVolumeKeysForCM();
  1513.     }
  1514.     else
  1515.     {
  1516.         if (imgId == 1)
  1517.         {
  1518.             ShowCategory18Screen(0, STR_GLOBAL_DIAL, 0, STR_GLOBAL_BACK, IMG_GLOBAL_BACK, 0, tmpName, NULL, 0,/*fred*/ 0, imgPath, FALSE, guiBuffer);      /* INC_SCR_NFY_CCBS_STR */
  1519.         }
  1520.         else
  1521.         {
  1522.             ShowCategory18Screen(0, STR_GLOBAL_DIAL, 0, STR_GLOBAL_BACK, IMG_GLOBAL_BACK, 0, tmpName, NULL, 0,/*fred*/ imgId, NULL, FALSE, guiBuffer);     /* INC_SCR_NFY_CCBS_STR */
  1523.         }
  1524.         SetLeftSoftkeyFunction(KbCBackCCBSDialCall, KEY_EVENT_UP);
  1525.         SetKeyHandler(KbCBackCCBSDialCall, KEY_SEND, KEY_EVENT_DOWN);
  1526.         SetKeyHandler(KbCBackCCBSInvokeRejected, KEY_END, KEY_EVENT_DOWN);
  1527.         SetKeyHandler(KbCBackCCBSDialCall, KEY_VOL_UP, KEY_EVENT_DOWN);
  1528.         SetKeyHandler(KbCBackCCBSInvokeRejected, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1529.     }
  1530.     SetRightSoftkeyFunction(KbCBackCCBSInvokeRejected, KEY_EVENT_UP);
  1531.     SetGroupKeyHandler(EnterScreenAndHandleDigit, (PU16) CMIdleScreenDigits, MAX_CM_SCREEN_DIGITS - 1, KEY_EVENT_DOWN);
  1532.     gdispnameForSubLCD = tmpName;
  1533.     ShowSubLCDScreen(EntrySubLcdScrIncomingCallEvent);
  1534.     if (needPlayRing == MMI_TRUE)
  1535.     {
  1536.         ShowIncomingCallIndication();
  1537.     }
  1538. }
  1539. /*****************************************************************************
  1540.  * FUNCTION
  1541.  *  EntryScrCCBSInvokeMultipleOptions
  1542.  * DESCRIPTION
  1543.  *  This function is the entry screen for the CCBS Invoke
  1544.  *  option menu when there are more than one calls
  1545.  * PARAMETERS
  1546.  *  void
  1547.  * RETURNS
  1548.  *  void
  1549.  *****************************************************************************/
  1550. void EntryScrCCBSInvokeMultipleOptions(void)
  1551. {
  1552.     /*----------------------------------------------------------------*/
  1553.     /* Local Variables                                                */
  1554.     /*----------------------------------------------------------------*/
  1555.     PU8 guiBuffer;
  1556.     static U8 *PopUpList[10];
  1557.     U16 nNumofItem;         /* Stores no of children in the submenu */
  1558.     U16 nStrItemList[10];   /* Stores the strings id of submenus returned */
  1559.     U16 menuId;
  1560.     S16 nActiveCall;
  1561.     U16 nHeldCall;
  1562.     /*----------------------------------------------------------------*/
  1563.     /* Code Body                                                      */
  1564.     /*----------------------------------------------------------------*/
  1565.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_EntryScrCCBSInvokeMultipleOptions));
  1566.     nActiveCall = GetTotalActiveCallCount();
  1567.     nHeldCall = GetTotalHoldCallCount();
  1568.     if (nActiveCall == 1 && nHeldCall == 0)
  1569.     {
  1570.         menuId = MITEM_CCBS_ACT_OPT_PSEUDO;
  1571.     }
  1572.     else if (nActiveCall == 0 && nHeldCall == 1)
  1573.     {
  1574.         menuId = MITEM_CCBS_HLD_OPT_PSEUDO;
  1575.     }
  1576.     else if (nActiveCall > 1 && nHeldCall == 0)
  1577.     {
  1578.         menuId = MITEM_CCBS_MACT_OPT_PSEUDO;
  1579.     }
  1580.     else if (nActiveCall == 0 && nHeldCall > 1)
  1581.     {
  1582.         menuId = MITEM_CCBS_MHLD_OPT_PSEUDO;
  1583.     }
  1584.     else if (nActiveCall == 1 && nHeldCall == 1)
  1585.     {
  1586.         menuId = MITEM_CCBS_ACT_HLD_OPT_PSEUDO;
  1587.     }
  1588.     else if (nActiveCall > 1 && nHeldCall > 0)
  1589.     {
  1590.         menuId = MITEM_CCBS_MACT_HLD_OPT_PSEUDO;
  1591.     }
  1592.     else if (nActiveCall > 0 && nHeldCall > 1)
  1593.     {
  1594.         menuId = MITEM_CCBS_ACT_MHLD_OPT_PSEUDO;
  1595.     }
  1596.     else
  1597.     {
  1598.         return;
  1599.     }
  1600.     EntryNewScreen(ITEM_SCR_CCBS_ACT_MHLD_OPN, NULL, EntryScrCCBSInvokeMultipleOptions, NULL);
  1601.     guiBuffer = GetCurrGuiBuffer(ITEM_SCR_CCBS_ACT_MHLD_OPN);
  1602.     SetParentHandler(menuId);
  1603.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1604.     nNumofItem = GetNumOfChild(menuId);
  1605.     GetSequenceStringIds(menuId, nStrItemList);
  1606.     ConstructHintsList(menuId, PopUpList);
  1607.     ShowCategory55Screen(
  1608.         STR_SCR1002_CAPTION,
  1609.         IMG_SCR1002_CAPTION,
  1610.         STR_GLOBAL_OK,
  1611.         IMG_GLOBAL_OK,
  1612.         STR_GLOBAL_BACK,
  1613.         IMG_GLOBAL_BACK,
  1614.         nNumofItem,
  1615.         nStrItemList,
  1616.         (U8 **) PopUpList,
  1617.         0,
  1618.         guiBuffer);
  1619.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1620.     if (GetTotalActiveCallCount() == 0 || GetTotalHoldCallCount() == 0)
  1621.     {
  1622.         SetKeyHandler(KbCBackCCBSDialCall, KEY_SEND, KEY_EVENT_DOWN);
  1623.     }
  1624. #ifdef __MMI_CLAMSHELL__
  1625.     SetKeyHandler(KbCBackCCBSInvokeRejected, KEY_END, KEY_EVENT_DOWN);
  1626. #else 
  1627.     SetKeyHandler(KbCBackEndAllCallsExceptIncoming, KEY_END, KEY_EVENT_DOWN);
  1628. #endif 
  1629.     SetSideVolumeKeysForCM();
  1630.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1631. }
  1632. /*****************************************************************************
  1633.  * FUNCTION
  1634.  *  EntryScrShowSSEvent
  1635.  * DESCRIPTION
  1636.  *  This function is the entry screen for displaying SS info to user
  1637.  * PARAMETERS
  1638.  *  void
  1639.  * RETURNS
  1640.  *  void
  1641.  *****************************************************************************/
  1642. void EntryScrShowSSEvent(void)
  1643. {
  1644.     /*----------------------------------------------------------------*/
  1645.     /* Local Variables                                                */
  1646.     /*----------------------------------------------------------------*/
  1647.     /* U8* guiBuffer; */
  1648.     U16 scrIdDisplay;
  1649. U8 ptrDisplayString[150];
  1650.     /*----------------------------------------------------------------*/
  1651.     /* Code Body                                                      */
  1652.     /*----------------------------------------------------------------*/
  1653.     scrIdDisplay = GetStrDisplayForId(gSSEvent);
  1654.     if (scrIdDisplay == 0)
  1655.     {
  1656.         return;
  1657.     }
  1658.     EntryNewScreen(ITEM_SCR_SS_NFY, ExitScrShowSSEvent, NULL, NULL);
  1659.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_EntryScrShowSSEvent));
  1660.     SetNotifySSFlag(TRUE);
  1661.     // guiBuffer = GetCurrGuiBuffer(ITEM_SCR_SS_NFY);   /* Getting the Index from history  */
  1662. pfnUnicodeStrcpy((PS8) ptrDisplayString, (PS8) GetString(scrIdDisplay));
  1663. if(gSSEventNotifyPresent) /* By Mick: present notification info to user*/
  1664. {
  1665. switch(gSSEventNotify)
  1666. {
  1667. case 1:  /* The call is forwarded : 00000001*/
  1668. pfnUnicodeStrcat((S8 *)ptrDisplayString, (S8 *)(L"."));
  1669. pfnUnicodeStrcat((S8 *)ptrDisplayString, (S8 *)(L"nn"));
  1670. pfnUnicodeStrcat((S8 *)ptrDisplayString, (S8 *)GetString(STR_ID_CALL_IS_FORWARDED_CALL));
  1671. pfnUnicodeStrcat((S8 *)ptrDisplayString, (S8 *)(L"."));
  1672. break;
  1673. case 2: /* 00000010 */
  1674. //UCS2Strcat((S8 *)ptrDisplayString, (S8 *)(L"(02)"));
  1675. break;
  1676. case 4: /* The received call is forwarded : 00000100*/
  1677. if(gSSEvent != CSMCC_NOTIFY_CF) /*avoid double call forwarded msg*/
  1678. {
  1679. pfnUnicodeStrcat((S8 *)ptrDisplayString, (S8 *)(L"."));
  1680. pfnUnicodeStrcat((S8 *)ptrDisplayString, (S8 *)(L"nn"));
  1681. pfnUnicodeStrcat((S8 *)ptrDisplayString, (S8 *)GetString(STR_ID_CALL_IS_FORWARDED));
  1682. pfnUnicodeStrcat((S8 *)ptrDisplayString, (S8 *)(L"."));
  1683. }
  1684. break;
  1685. default:
  1686. break;
  1687. }
  1688. }
  1689. ShowCategory63Screen((U8*) ptrDisplayString, 0, NULL);
  1690.     if (GetCurrentState() == CM_OUTGOING_STATE)
  1691.     {
  1692.         SetRightSoftkeyFunction(DropRequest, KEY_EVENT_UP);
  1693.         if (1 == GetTotalCallCount())
  1694.         {
  1695.             SetKeyHandler(DropRequest, KEY_END, KEY_EVENT_DOWN);
  1696.         }
  1697.         else
  1698.         {
  1699.             SetKeyHandler(HangupAll, KEY_END, KEY_EVENT_DOWN);
  1700.         }
  1701.     }
  1702.     SetLeftSoftkeyFunction(GoBackfromNotifyScr, KEY_EVENT_UP);
  1703.     SetPOPUpFlag(TRUE);
  1704.     SetKeysForPOPUp();
  1705.     StartTimer(CM_NOTIFYDURATION_TIMER, CM_NOTIFY_TIMEOUT, GoBackfromNotifyScr);
  1706. }
  1707. /*****************************************************************************
  1708.  * FUNCTION
  1709.  *  ExitScrShowSSEvent
  1710.  * DESCRIPTION
  1711.  *  This function is the exit screen for for displaying SS info to user
  1712.  * PARAMETERS
  1713.  *  void
  1714.  * RETURNS
  1715.  *  void
  1716.  *****************************************************************************/
  1717. void ExitScrShowSSEvent(void)
  1718. {
  1719.     /*----------------------------------------------------------------*/
  1720.     /* Local Variables                                                */
  1721.     /*----------------------------------------------------------------*/
  1722.     /*----------------------------------------------------------------*/
  1723.     /* Code Body                                                      */
  1724.     /*----------------------------------------------------------------*/
  1725.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_ExitScrShowSSEvent));
  1726.     StopTimer(CM_NOTIFYDURATION_TIMER);
  1727.     if (GetPOPUpFlag())
  1728.     {
  1729.         SetPOPUpFlag(FALSE);
  1730.         AdjustHistoryForCM();
  1731.     }
  1732.     SetNotifySSFlag(FALSE);
  1733.     if (GetCbackAfterSS())
  1734.     {
  1735.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ExitScrShowSSEvent1));
  1736.         if (GetCurrentState() == CM_INCOMING_STATE && IsScreenPresent(ITEMSCR_INCOMING_CALL))
  1737.         {
  1738.             SetCbackAfterSS(NULL);
  1739.             GoBackToHistory(ITEMSCR_INCOMING_CALL);
  1740.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ExitScrShowSSEvent2));
  1741.         }
  1742.         else if ((GetCbackAfterSS() == EntryScr1002ActiveCall) && IsScreenPresent(SCR_CM_ACTIVECALLSCREEN))
  1743.         {
  1744.             GoBackToHistory(SCR_CM_ACTIVECALLSCREEN);
  1745.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ExitScrShowSSEvent3));
  1746.         }
  1747.         else
  1748.         {
  1749.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_ExitScrShowSSEvent4));
  1750.             (*GetCbackAfterSS())();
  1751.         }
  1752.     }
  1753. }
  1754. /*****************************************************************************
  1755.  * FUNCTION
  1756.  *  HandleCallDelfectDigitEntry
  1757.  * DESCRIPTION
  1758.  *  This function is entered when a key
  1759.  *  is pressed at the Call Deflect screen.
  1760.  * PARAMETERS
  1761.  *  void
  1762.  * RETURNS
  1763.  *  void
  1764.  *****************************************************************************/
  1765. void HandleCallDelfectDigitEntry(void)
  1766. {
  1767.     /*----------------------------------------------------------------*/
  1768.     /* Local Variables                                                */
  1769.     /*----------------------------------------------------------------*/
  1770.     U16 Keycode, Keytype;
  1771.     /*----------------------------------------------------------------*/
  1772.     /* Code Body                                                      */
  1773.     /*----------------------------------------------------------------*/
  1774.     memset(CallDeflectBuffer, 0, sizeof(CallDeflectBuffer));
  1775.     GetkeyInfo(&Keycode, &Keytype);
  1776.     CallDeflectDigitKeyCode = Keycode;
  1777.     EntryCallDeflectDigitHandler();
  1778. }
  1779. /*****************************************************************************
  1780.  * FUNCTION
  1781.  *  EntryCallDeflectDigitHandler
  1782.  * DESCRIPTION
  1783.  *  Inputs the digits of a phone number for Call Deflection
  1784.  * PARAMETERS
  1785.  *  void
  1786.  * RETURNS
  1787.  *  void
  1788.  *****************************************************************************/
  1789. void EntryCallDeflectDigitHandler(void)
  1790. {
  1791.     /*----------------------------------------------------------------*/
  1792.     /* Local Variables                                                */
  1793.     /*----------------------------------------------------------------*/
  1794.     U8 *history_buffer;
  1795.     /*----------------------------------------------------------------*/
  1796.     /* Code Body                                                      */
  1797.     /*----------------------------------------------------------------*/
  1798.     EntryNewScreen(ITEM_SCR_CALL_DEFLECT_DIGIT_HANDLER_ID, ExitCallDeflectDigitHandler, NULL, NULL);
  1799.     cm_p->history_info.IsSave = TRUE;
  1800.     history_buffer = GetCurrGuiBuffer(ITEM_SCR_CALL_DEFLECT_DIGIT_HANDLER_ID);
  1801.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_EntryCallDeflectDigitHandler));
  1802.     RegisterInputBoxEmptyFunction(CallDeflectScreenEmpty);
  1803.     RegisterInputBoxNotEmptyFunction(CallDeflectScreenNotEmpty);
  1804.     ShowCategory16Screen(
  1805.         CALL_DEFLECT_SEARCH_LSK,
  1806.         0,
  1807.         STR_GLOBAL_BACK,
  1808.         IMG_GLOBAL_BACK,
  1809.         (U8*) CallDeflectBuffer,
  1810.         MAX_DIGIT,
  1811.         history_buffer);
  1812.     if (GetTotalCallCount() == 1)
  1813.     {
  1814.         SetKeyHandler(KbCBackCallIncomingRejected, KEY_END, KEY_EVENT_DOWN);
  1815.     }
  1816.     else
  1817.     {
  1818.     #ifdef __MMI_CLAMSHELL__
  1819.         SetKeyHandler(KbCBackCallIncomingRejected, KEY_END, KEY_EVENT_DOWN);
  1820.     #else 
  1821.         SetKeyHandler(KbCBackEndAllCallsExceptIncoming, KEY_END, KEY_EVENT_DOWN);
  1822.     #endif 
  1823.     }
  1824.     if ((CallDeflectDigitKeyCode >= KEY_0 && CallDeflectDigitKeyCode <= KEY_9) ||
  1825.         CallDeflectDigitKeyCode == KEY_STAR || CallDeflectDigitKeyCode == KEY_POUND)
  1826.     {
  1827.         ExecuteCurrKeyHandler(CallDeflectDigitKeyCode, KEY_EVENT_DOWN);
  1828.     }
  1829.     SetCategory16RightSoftkeyFunction(CheckBeforeGoBackHistory, KEY_EVENT_UP);
  1830. }
  1831. /*****************************************************************************
  1832.  * FUNCTION
  1833.  *  ExitCallDeflectDigitHandler
  1834.  * DESCRIPTION
  1835.  *  exit fn for Call Deflect digit handle
  1836.  * PARAMETERS
  1837.  *  void
  1838.  * RETURNS
  1839.  *  void
  1840.  *****************************************************************************/
  1841. void ExitCallDeflectDigitHandler(void)
  1842. {
  1843.     /*----------------------------------------------------------------*/
  1844.     /* Local Variables                                                */
  1845.     /*----------------------------------------------------------------*/
  1846.     /*----------------------------------------------------------------*/
  1847.     /* Code Body                                                      */
  1848.     /*----------------------------------------------------------------*/
  1849.     if (cm_p->history_info.IsSave)
  1850.     {
  1851.         history h;
  1852.         S16 nHistory = 0;
  1853.         h.scrnID = ITEM_SCR_CALL_DEFLECT_DIGIT_HANDLER_ID;
  1854.         h.entryFuncPtr = EntryCallDeflectDigitHandler;
  1855.         CallDeflectDigitKeyCode = -1;
  1856.         pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  1857.         GetCategoryHistory(h.guiBuffer);
  1858.         AddHistory(h);
  1859.     }
  1860.     else
  1861.     {
  1862.         cm_p->history_info.IsSave = TRUE;
  1863.     }
  1864. }
  1865. /*****************************************************************************
  1866.  * FUNCTION
  1867.  *  CallDeflectScreenEmpty
  1868.  * DESCRIPTION
  1869.  *  register function when screen is empty for call deflection
  1870.  * PARAMETERS
  1871.  *  void
  1872.  * RETURNS
  1873.  *  void
  1874.  *****************************************************************************/
  1875. void CallDeflectScreenEmpty(void)
  1876. {
  1877.     /*----------------------------------------------------------------*/
  1878.     /* Local Variables                                                */
  1879.     /*----------------------------------------------------------------*/
  1880.     /*----------------------------------------------------------------*/
  1881.     /* Code Body                                                      */
  1882.     /*----------------------------------------------------------------*/
  1883.     ChangeLeftSoftkey(CALL_DEFLECT_SEARCH_LSK, 0);
  1884.     SetLeftSoftkeyFunction(mmi_phb_call_enter_from_deflect_option, KEY_EVENT_UP);
  1885.     ClearKeyHandler(KEY_SEND, KEY_EVENT_DOWN);
  1886. #if ( (defined  __MMI_WGUI_CSK_ENABLE__) && defined (__MMI_TOUCH_SCREEN__) )
  1887. #if defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__)
  1888.     SetDialingKeypadCallHandler(UI_dummy_function);
  1889.     SetDialingKeypadIPCallHandler(UI_dummy_function);    //KP Jerry add on 2006-11-12
  1890.     SetDialingKeypadPhonebookHandler(mmi_phb_call_enter_from_deflect_option);
  1891. #else /* defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__) */ 
  1892.     SetCenterSoftkeyFunction(UI_dummy_function, KEY_EVENT_UP);
  1893. #endif /* defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__) */ 
  1894. #endif /* ( (defined  __MMI_WGUI_CSK_ENABLE__) && defined (__MMI_TOUCH_SCREEN__) ) */ 
  1895. }
  1896. /*****************************************************************************
  1897.  * FUNCTION
  1898.  *  CallDeflectScreenNotEmpty
  1899.  * DESCRIPTION
  1900.  *  register function when screen is not empty for call deflection
  1901.  * PARAMETERS
  1902.  *  void
  1903.  * RETURNS
  1904.  *  void
  1905.  *****************************************************************************/
  1906. void CallDeflectScreenNotEmpty(void)
  1907. {
  1908.     /*----------------------------------------------------------------*/
  1909.     /* Local Variables                                                */
  1910.     /*----------------------------------------------------------------*/
  1911.     /*----------------------------------------------------------------*/
  1912.     /* Code Body                                                      */
  1913.     /*----------------------------------------------------------------*/
  1914.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  1915.     SetLeftSoftkeyFunction(CallDeflectDigitCall, KEY_EVENT_UP);
  1916.     SetKeyHandler(CallDeflectDigitCall, KEY_SEND, KEY_EVENT_DOWN);
  1917. #if ( (defined  __MMI_WGUI_CSK_ENABLE__) && defined (__MMI_TOUCH_SCREEN__) )
  1918. #if defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__)
  1919.     SetDialingKeypadCallHandler(CallDeflectDigitCall);
  1920.     SetDialingKeypadIPCallHandler(CallDeflectDigitIPCall);     //KP Jerry add on 2006-11-12
  1921.     SetDialingKeypadPhonebookHandler(mmi_phb_call_enter_from_deflect_option);
  1922. #else /* defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__) */ 
  1923.     SetCenterSoftkeyFunction(CallDeflectDigitCall, KEY_EVENT_UP);
  1924. #endif /* defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__) */ 
  1925. #endif /* ( (defined  __MMI_WGUI_CSK_ENABLE__) && defined (__MMI_TOUCH_SCREEN__) ) */ 
  1926. }
  1927. /*****************************************************************************
  1928.  * FUNCTION
  1929.  *  CallDeflectDigitCall
  1930.  * DESCRIPTION
  1931.  *  Make a call from scratch pad
  1932.  * PARAMETERS
  1933.  *  void
  1934.  * RETURNS
  1935.  *  void
  1936.  *****************************************************************************/
  1937. void CallDeflectDigitCall(void)
  1938. {
  1939.     /*----------------------------------------------------------------*/
  1940.     /* Local Variables                                                */
  1941.     /*----------------------------------------------------------------*/
  1942.     /*----------------------------------------------------------------*/
  1943.     /* Code Body                                                      */
  1944.     /*----------------------------------------------------------------*/
  1945.     SetCallDeflectFlag(TRUE);
  1946.     MakeCall(CallDeflectBuffer);
  1947. }
  1948. //KP Jerry add on 2006-11-12 start
  1949. /**************************************************************
  1950. FUNCTION NAME : CallDeflectDigitIPCall
  1951.    PURPOSE : Make a IPcall from scratch pad
  1952. INPUT PARAMETERS : nil
  1953. OUTPUT PARAMETERS : nil
  1954. RETURNS : void
  1955. REMARKS :
  1956. **************************************************************/
  1957. void CallDeflectDigitIPCall(void)
  1958. {
  1959.        SetTempUseIPNumber(TRUE);
  1960.        SetCallDeflectFlag(TRUE);
  1961. MakeCall(CallDeflectBuffer);
  1962. }
  1963. //KP Jerry add on 2006-11-12 end
  1964. /*****************************************************************************
  1965.  * FUNCTION
  1966.  *  CBackCallDeflectNumberFromPB
  1967.  * DESCRIPTION
  1968.  *  
  1969.  * PARAMETERS
  1970.  *  number      [IN]        
  1971.  * RETURNS
  1972.  *  void
  1973.  *****************************************************************************/
  1974. void CBackCallDeflectNumberFromPB(PS8 number)
  1975. {
  1976.     /*----------------------------------------------------------------*/
  1977.     /* Local Variables                                                */
  1978.     /*----------------------------------------------------------------*/
  1979.     /*----------------------------------------------------------------*/
  1980.     /* Code Body                                                      */
  1981.     /*----------------------------------------------------------------*/
  1982.     memcpy(CallDeflectBuffer, number, MAX_NUMBER);
  1983.     CallDeflectDigitCall();
  1984. }
  1985. /*****************************************************************************
  1986.  * FUNCTION
  1987.  *  CheckBeforeGoBackHistory
  1988.  * DESCRIPTION
  1989.  *  exit fn for Call Deflect digit handle
  1990.  * PARAMETERS
  1991.  *  void
  1992.  * RETURNS
  1993.  *  void
  1994.  *****************************************************************************/
  1995. void CheckBeforeGoBackHistory(void)
  1996. {
  1997.     /*----------------------------------------------------------------*/
  1998.     /* Local Variables                                                */
  1999.     /*----------------------------------------------------------------*/
  2000.     /*----------------------------------------------------------------*/
  2001.     /* Code Body                                                      */
  2002.     /*----------------------------------------------------------------*/
  2003.     SetNoSave();
  2004.     if (0 == GetTotalCallCount())
  2005.     {
  2006.         GoBackfromNotifyScr();
  2007.     }
  2008.     else
  2009.     {
  2010.         GoBackHistory();
  2011.     }
  2012. }
  2013. /*****************************************************************************
  2014.  * FUNCTION
  2015.  *  EntryScrConfirmDTMFString
  2016.  * DESCRIPTION
  2017.  *  Entry func to screen prompting for dtmf
  2018.  *  confirmation
  2019.  * PARAMETERS
  2020.  *  void
  2021.  * RETURNS
  2022.  *  void
  2023.  *****************************************************************************/
  2024. void EntryScrConfirmDTMFString(void)
  2025. {
  2026.     /*----------------------------------------------------------------*/
  2027.     /* Local Variables                                                */
  2028.     /*----------------------------------------------------------------*/
  2029.     U8 tempBuf[MAX_DTMFBUF_DIGITS * ENCODING_LENGTH + 40];
  2030.     /*----------------------------------------------------------------*/
  2031.     /* Code Body                                                      */
  2032.     /*----------------------------------------------------------------*/
  2033.     memset(tempBuf, 0, sizeof(tempBuf));
  2034.     if (GetTotalActiveCallCount() < 1)
  2035.     {
  2036.         StartTimer(CM_NOTIFYDURATION_TIMER, 1, GoBackfromNotifyScr);
  2037.         return;
  2038.     }
  2039.     EntryNewScreen(ITEM_SCR_CONFIRM_DTMF_STRING, ExitScrConfirmDTMFString, NULL, NULL);
  2040.     cm_p->history_info.IsSave = TRUE;
  2041.     pfnUnicodeStrcpy((S8*) tempBuf, (S8*) GetString(STR_DTMF_CONFIRMATION));
  2042.     AnsiiToUnicodeString((S8*) tempBuf + (pfnUnicodeStrlen((S8*) tempBuf) * ENCODING_LENGTH), (S8*) gDTMFConfirmBuf);
  2043.     PRINT_INFORMATION(("EntryScrConfirmDTMFString show screen 1n"));
  2044.     ShowCategory66Screen(0, 0, STR_GLOBAL_YES, IMG_GLOBAL_YES, STR_GLOBAL_NO, IMG_GLOBAL_NO, tempBuf, 0, NULL);
  2045.     PRINT_INFORMATION(("EntryScrConfirmDTMFString show screen 2n"));
  2046.     SetLeftSoftkeyFunction(ConfirmDTMFString, KEY_EVENT_UP);
  2047.     SetRightSoftkeyFunction(IgnoreDTMFStringAndGoBackHistory, KEY_EVENT_UP);
  2048.     SetKeyHandler(IgnoreDTMFStringAndGoBackHistory, KEY_END, KEY_EVENT_DOWN);
  2049. }
  2050. /*****************************************************************************
  2051.  * FUNCTION
  2052.  *  ExitScrConfirmDTMFString
  2053.  * DESCRIPTION
  2054.  *  exit function for EntryScrConfirmDTMFString()
  2055.  * PARAMETERS
  2056.  *  void
  2057.  * RETURNS
  2058.  *  void
  2059.  *****************************************************************************/
  2060. void ExitScrConfirmDTMFString(void)
  2061. {
  2062.     /*----------------------------------------------------------------*/
  2063.     /* Local Variables                                                */
  2064.     /*----------------------------------------------------------------*/
  2065.     /*----------------------------------------------------------------*/
  2066.     /* Code Body                                                      */
  2067.     /*----------------------------------------------------------------*/
  2068.     if (cm_p->history_info.IsSave)
  2069.     {
  2070.         history scr101;
  2071.         U16 nHistory = 0;
  2072.         pfnUnicodeStrcpy((S8*) scr101.inputBuffer, (PS8) & nHistory);
  2073.         scr101.scrnID = ITEM_SCR_CONFIRM_DTMF_STRING;
  2074.         scr101.entryFuncPtr = EntryScrConfirmDTMFString;
  2075.         GetCategoryHistory(scr101.guiBuffer);
  2076.         AddHistory(scr101);
  2077.     }
  2078.     else
  2079.     {
  2080.         cm_p->history_info.IsSave = TRUE;
  2081.     }
  2082. }
  2083. /*****************************************************************************
  2084.  * FUNCTION
  2085.  *  NotifyMONumberChange
  2086.  * DESCRIPTION
  2087.  *  This function displays number change notification
  2088.  * PARAMETERS
  2089.  *  newNumber               [IN]        
  2090.  *  ptrDisplayString        [OUT]       
  2091.  * RETURNS
  2092.  *  void
  2093.  *****************************************************************************/
  2094. void NotifyMONumberChange(U8 *newNumber, U8 *ptrDisplayString)
  2095. {
  2096.     /*----------------------------------------------------------------*/
  2097.     /* Local Variables                                                */
  2098.     /*----------------------------------------------------------------*/
  2099.     S16 index;
  2100.     /*----------------------------------------------------------------*/
  2101.     /* Code Body                                                      */
  2102.     /*----------------------------------------------------------------*/
  2103.     if (GetCurrentState() != CM_OUTGOING_STATE)
  2104.     {
  2105.         return;
  2106.     }
  2107.     index = GetOutgoingCallIndex();
  2108.     if (index == -1)
  2109.     {
  2110.         return;
  2111.     }
  2112.     SetCalledNumber(index, newNumber);
  2113.     EntryNewScreen(ITEM_SCR_MO_NUM_CHANGE_NFY, ExitScrNotifyCMPopUp, NULL, NULL);
  2114.     ShowCategory63Screen((U8*) ptrDisplayString, 0, NULL);
  2115.     SetLeftSoftkeyFunction(GoBackfromNotifyScr, KEY_EVENT_UP);
  2116.     SetPOPUpFlag(TRUE);
  2117.     SetKeysForPOPUp();
  2118.     StartTimer(CM_NOTIFYDURATION_TIMER, CM_NOTIFY_TIMEOUT, GoBackfromNotifyScr);
  2119. }
  2120. /*****************************************************************************
  2121.  * FUNCTION
  2122.  *  InvisibleDigitHandler
  2123.  * DESCRIPTION
  2124.  *  Set group key handler for single MT call screen
  2125.  *  instead of enter dial pad screen
  2126.  * PARAMETERS
  2127.  *  void
  2128.  * RETURNS
  2129.  *  void
  2130.  *****************************************************************************/
  2131. void InvisibleDigitHandler(void)
  2132. {
  2133.     /*----------------------------------------------------------------*/
  2134.     /* Local Variables                                                */
  2135.     /*----------------------------------------------------------------*/
  2136.     /*----------------------------------------------------------------*/
  2137.     /* Code Body                                                      */
  2138.     /*----------------------------------------------------------------*/
  2139.     ClearDtmfBuf();
  2140.     AuxInvisibleDigitHandler();
  2141.     SetKeyHandler(MakeCallFromDTMFScr, KEY_SEND, KEY_EVENT_DOWN);
  2142.     SetGroupKeyHandler(AuxInvisibleDigitHandler, (PU16) CMIdleScreenDigits, MAX_CM_SCREEN_DIGITS - 1, KEY_EVENT_DOWN);
  2143. }
  2144. /*****************************************************************************
  2145.  * FUNCTION
  2146.  *  AuxInvisibleDigitHandler
  2147.  * DESCRIPTION
  2148.  *  Convert key digits to ascii to fill dtmf buffer
  2149.  * PARAMETERS
  2150.  *  void
  2151.  * RETURNS
  2152.  *  void
  2153.  *****************************************************************************/
  2154. void AuxInvisibleDigitHandler(void)
  2155. {
  2156.     /*----------------------------------------------------------------*/
  2157.     /* Local Variables                                                */
  2158.     /*----------------------------------------------------------------*/
  2159.     S16 keycode, keytype;
  2160.     U8 len;
  2161.     /*----------------------------------------------------------------*/
  2162.     /* Code Body                                                      */
  2163.     /*----------------------------------------------------------------*/
  2164.     GetkeyInfo((U16*) & keycode, (U16*) & keytype);
  2165.     len = (U8) pfnUnicodeStrlen((S8*) UnicodeDTMFPadCallBuffer);
  2166.     if (keycode >= KEY_0 && keycode <= KEY_9)
  2167.     {
  2168.         UnicodeDTMFPadCallBuffer[len * ENCODING_LENGTH] = keycode + '0';
  2169.     }
  2170.     else if (keycode == KEY_STAR)
  2171.     {
  2172.         UnicodeDTMFPadCallBuffer[len * ENCODING_LENGTH] = '*';
  2173.     }
  2174.     else if (keycode == KEY_POUND)
  2175.     {
  2176.         UnicodeDTMFPadCallBuffer[len * ENCODING_LENGTH] = '#';
  2177.     }
  2178. }
  2179. /****************************** CISS ***********************************************/
  2180. /*****************************************************************************
  2181.  * FUNCTION
  2182.  *  PsCBackUSSNInd
  2183.  * DESCRIPTION
  2184.  *  This function is intended for registering USSN Indication
  2185.  *  for PS Callback
  2186.  * PARAMETERS
  2187.  *  info        [?]     
  2188.  * RETURNS
  2189.  *  void
  2190.  *****************************************************************************/
  2191. void PsCBackUSSNInd(void *info)
  2192. {
  2193.     /*----------------------------------------------------------------*/
  2194.     /* Local Variables                                                */
  2195.     /*----------------------------------------------------------------*/
  2196.     /*----------------------------------------------------------------*/
  2197.     /* Code Body                                                      */
  2198.     /*----------------------------------------------------------------*/
  2199.     DeriveUSSNbuf(info);
  2200.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2201.     DeleteScreenIfPresent(ITEM_SCR_USSN_MSG);
  2202.     if (IsScreenPresent(SCR_CM_REQUESTINGUSSD))
  2203.     {
  2204.         HistoryReplace(SCR_CM_REQUESTINGUSSD, ITEM_SCR_USSN_MSG, EntryScrDisplayUSSNMsg);
  2205.         SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) USSRDelHistoryHdlr);
  2206.     }
  2207.     else
  2208.     {
  2209.         EntryScrDisplayUSSNMsg();
  2210. #ifdef __MMI_RECEIVE_USSD_TONE__
  2211.         playRequestedTone(WARNING_TONE);
  2212. #endif 
  2213.     }
  2214. }
  2215. /*****************************************************************************
  2216.  * FUNCTION
  2217.  *  PsCBackUSSRInd
  2218.  * DESCRIPTION
  2219.  *  This function is intended for registering USSR Indication
  2220.  *  for PS Callback
  2221.  * PARAMETERS
  2222.  *  info        [?]     
  2223.  * RETURNS
  2224.  *  void
  2225.  *****************************************************************************/
  2226. void PsCBackUSSRInd(void *info)
  2227. {
  2228.     /*----------------------------------------------------------------*/
  2229.     /* Local Variables                                                */
  2230.     /*----------------------------------------------------------------*/
  2231.     /*----------------------------------------------------------------*/
  2232.     /* Code Body                                                      */
  2233.     /*----------------------------------------------------------------*/
  2234.     DeriveUSSRbuf(info);
  2235.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2236.     if (IsScreenPresent(SCR_CM_REQUESTINGUSSD))
  2237.     {
  2238.         HistoryReplace(SCR_CM_REQUESTINGUSSD, ITEM_SCR_USSN_MSG, EntryScrDisplayUSSRMsg);
  2239.         SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) USSRDelHistoryHdlr);
  2240.     }
  2241.     else
  2242.     {
  2243.         EntryScrDisplayUSSRMsg();
  2244. #ifdef __MMI_RECEIVE_USSD_TONE__        /* for KLM only */
  2245.         playRequestedTone(WARNING_TONE);
  2246. #endif 
  2247.     }
  2248. }
  2249. /*****************************************************************************
  2250.  * FUNCTION
  2251.  *  EntryScrDisplayUSSNMsg
  2252.  * DESCRIPTION
  2253.  *  This function is the entry screen for displaying USSN info to user
  2254.  * PARAMETERS
  2255.  *  void
  2256.  * RETURNS
  2257.  *  void
  2258.  *****************************************************************************/
  2259. void EntryScrDisplayUSSNMsg(void)
  2260. {
  2261.     /*----------------------------------------------------------------*/
  2262.     /* Local Variables                                                */
  2263.     /*----------------------------------------------------------------*/
  2264.     history ss_scr;
  2265.     S16 nHistory = 0;
  2266.     /*----------------------------------------------------------------*/
  2267.     /* Code Body                                                      */
  2268.     /*----------------------------------------------------------------*/
  2269.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2270.     DeleteScreenIfPresent(ITEM_SCR_USSN_MSG);
  2271.     if ((GetCurrentState() == CM_OUTGOING_STATE) || (GetCurrentState() == CM_INCOMING_STATE))
  2272.     {
  2273.         TurnOnBacklight(TRUE);
  2274.         EntryNewScreen(POPUP_SCREENID, ExitDisplayPopup, NULL, NULL);
  2275.         RemoveSSReqScr();
  2276.         ss_scr.scrnID = ITEM_SCR_USSN_MSG;
  2277.         ss_scr.entryFuncPtr = EntryScrDisplayUSSNMsg;
  2278.         pfnUnicodeStrcpy((S8*) ss_scr.inputBuffer, (S8*) & nHistory);
  2279.         InsertHistoryBeforeThisScrnReference(CM_SCR_MARKER, &ss_scr);
  2280.         ShowCategory74Screen(
  2281.             STR_TITLE_SCR_USSN_MSG,
  2282.             0,
  2283.             STR_GLOBAL_OK,
  2284.             IMG_GLOBAL_OK,
  2285.             STR_GLOBAL_BACK,
  2286.             IMG_GLOBAL_BACK,
  2287.             (PU8) gUSSDbuf,
  2288.             pfnUnicodeStrlen(gUSSDbuf),
  2289.             NULL);
  2290.         SetGroupKeyHandler(PopupTimerFlagEnable, (PU16) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_DOWN);
  2291.         SetGroupKeyHandler(PopupCloseByPressAnyKey, (PU16) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_UP);
  2292.         StartTimer(POPUP_TIMER, 1000, PopupTimerOver);
  2293.     }
  2294.     else
  2295.     {
  2296.         EntryNewScreen(ITEM_SCR_USSN_MSG, NULL, EntryScrDisplayUSSNMsg, NULL);
  2297.         if (isInCall())
  2298.         {
  2299.             SetCMScrnFlag(MMI_FALSE);
  2300.         }
  2301.         RemoveSSReqScr();
  2302.         ShowCategory74Screen(
  2303.             STR_TITLE_SCR_USSN_MSG,
  2304.             0,
  2305.             STR_GLOBAL_OK,
  2306.             IMG_GLOBAL_OK,
  2307.             STR_GLOBAL_BACK,
  2308.             IMG_GLOBAL_BACK,
  2309.             (PU8) gUSSDbuf,
  2310.             pfnUnicodeStrlen(gUSSDbuf),
  2311.             NULL);
  2312.         SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) USSRDelHistoryHdlr);
  2313.         TurnOnBacklight(1);
  2314.         SetLeftSoftkeyFunction(MMIUSSNReceiveOK, KEY_EVENT_UP);
  2315.         SetRightSoftkeyFunction(MMIUSSNReceiveBack, KEY_EVENT_UP);
  2316.         SetKeyHandler(MMIUSSNReceiveEnd, KEY_END, KEY_EVENT_DOWN);
  2317.         SetKeyHandler(NULL, KEY_VOL_UP, KEY_EVENT_UP);
  2318.         SetKeyHandler(NULL, KEY_VOL_UP, KEY_LONG_PRESS);
  2319.         SetKeyHandler(NULL, KEY_VOL_DOWN, KEY_EVENT_UP);
  2320.         SetKeyHandler(NULL, KEY_VOL_DOWN, KEY_LONG_PRESS);
  2321.     }    
  2322. }
  2323. /*****************************************************************************
  2324.  * FUNCTION
  2325.  *  GoBackFromUSSNMsg
  2326.  * DESCRIPTION
  2327.  *  This function is the entry screen for displaying USSN info to user
  2328.  * PARAMETERS
  2329.  *  void
  2330.  * RETURNS
  2331.  *  void
  2332.  *****************************************************************************/
  2333. void GoBackFromUSSNMsg(void)
  2334. {
  2335.     /*----------------------------------------------------------------*/
  2336.     /* Local Variables                                                */
  2337.     /*----------------------------------------------------------------*/
  2338.     /*----------------------------------------------------------------*/
  2339.     /* Code Body                                                      */
  2340.     /*----------------------------------------------------------------*/
  2341.     if (isInCall())
  2342.     {
  2343.         SetCMScrnFlag(MMI_FALSE);
  2344.     }
  2345.     GoBackHistory();
  2346. }
  2347. /*****************************************************************************
  2348.  * FUNCTION
  2349.  *  MMIUSSNReceiveOK
  2350.  * DESCRIPTION
  2351.  *  Receive USSN OK
  2352.  * PARAMETERS
  2353.  *  void
  2354.  * RETURNS
  2355.  *  void
  2356.  *****************************************************************************/
  2357. void MMIUSSNReceiveOK(void)
  2358. {
  2359. ClearDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, NULL);
  2360.     GoBackFromUSSNMsg();
  2361. }
  2362. /*****************************************************************************
  2363.  * FUNCTION
  2364.  *  MMIUSSNReceiveAbort
  2365.  * DESCRIPTION
  2366.  *  Receive USSN Abort
  2367.  * PARAMETERS
  2368.  *  void
  2369.  * RETURNS
  2370.  *  void
  2371.  *****************************************************************************/
  2372. void MMIUSSNReceiveAbort(void)
  2373. {
  2374.     /*----------------------------------------------------------------*/
  2375.     /* Local Variables                                                */
  2376.     /*----------------------------------------------------------------*/
  2377.     MYQUEUE Message;
  2378.     /*----------------------------------------------------------------*/
  2379.     /* Code Body                                                      */
  2380.     /*----------------------------------------------------------------*/
  2381.     ResetCFCondStage();
  2382.     Message.oslSrcId = MOD_MMI;
  2383.     Message.oslDestId = MOD_L4C;
  2384.     Message.oslMsgId = PRT_SS_STRING_ABORT_REQ;
  2385.     Message.oslPeerBuffPtr = NULL;
  2386.     Message.oslDataPtr = NULL;
  2387.     ClearProtocolEventHandler(PRT_SS_STRING_ABORT_RSP);
  2388.     OslMsgSendExtQueue(&Message);
  2389. }
  2390. /*****************************************************************************
  2391.  * FUNCTION
  2392.  *  MMIUSSNReceiveBack
  2393.  * DESCRIPTION
  2394.  *  Receive USSN Back
  2395.  * PARAMETERS
  2396.  *  void
  2397.  * RETURNS
  2398.  *  void
  2399.  *****************************************************************************/
  2400. void MMIUSSNReceiveBack(void)
  2401. {
  2402.     /*----------------------------------------------------------------*/
  2403.     /* Local Variables                                                */
  2404.     /*----------------------------------------------------------------*/
  2405.     /*----------------------------------------------------------------*/
  2406.     /* Code Body                                                      */
  2407.     /*----------------------------------------------------------------*/
  2408.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2409.     MMIUSSNReceiveAbort();
  2410.     GoBackFromUSSNMsg();
  2411. }
  2412. /*****************************************************************************
  2413.  * FUNCTION
  2414.  *  MMIUSSNReceiveEnd
  2415.  * DESCRIPTION
  2416.  *  Receive USSN Back
  2417.  * PARAMETERS
  2418.  *  void
  2419.  * RETURNS
  2420.  *  void
  2421.  *****************************************************************************/
  2422. void MMIUSSNReceiveEnd(void)
  2423. {
  2424.     /*----------------------------------------------------------------*/
  2425.     /* Local Variables                                                */
  2426.     /*----------------------------------------------------------------*/
  2427.     /*----------------------------------------------------------------*/
  2428.     /* Code Body                                                      */
  2429.     /*----------------------------------------------------------------*/
  2430.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2431.     MMIUSSNReceiveAbort();
  2432.     if (isInCall())
  2433.     {
  2434.         SetCMScrnFlag(MMI_FALSE);
  2435.         GoBackHistory();
  2436.     }
  2437.     else
  2438.     {
  2439.         DisplayIdleScreen();
  2440.     }
  2441. }
  2442. /*****************************************************************************
  2443.  * FUNCTION
  2444.  *  EntryScrDisplayUSSRMsg
  2445.  * DESCRIPTION
  2446.  *  This function is the entry screen for displaying USSR info to user
  2447.  * PARAMETERS
  2448.  *  void
  2449.  * RETURNS
  2450.  *  void
  2451.  *****************************************************************************/
  2452. void EntryScrDisplayUSSRMsg(void)
  2453. {
  2454.     /*----------------------------------------------------------------*/
  2455.     /* Local Variables                                                */
  2456.     /*----------------------------------------------------------------*/
  2457.     history ss_scr;
  2458.     S16 nHistory = 0;
  2459.     /*----------------------------------------------------------------*/
  2460.     /* Code Body                                                      */
  2461.     /*----------------------------------------------------------------*/
  2462.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2463.     DeleteScreenIfPresent(ITEM_SCR_USSN_MSG);
  2464.     if ((GetCurrentState() == CM_OUTGOING_STATE) || (GetCurrentState() == CM_INCOMING_STATE))
  2465.     {
  2466.         TurnOnBacklight(TRUE);
  2467.         EntryNewScreen(POPUP_SCREENID, ExitDisplayPopup, NULL, NULL);
  2468.         RemoveSSReqScr();
  2469.         ss_scr.scrnID = ITEM_SCR_USSN_MSG;
  2470.         ss_scr.entryFuncPtr = EntryScrDisplayUSSRMsg;
  2471.         pfnUnicodeStrcpy((S8*) ss_scr.inputBuffer, (S8*) & nHistory);
  2472.         InsertHistoryBeforeThisScrnReference(CM_SCR_MARKER, &ss_scr);
  2473.         ShowCategory74Screen(
  2474.             STR_TITLE_SCR_USSR_MSG,
  2475.             0,
  2476.             STR_GLOBAL_REPLY,
  2477.             0,
  2478.             STR_GLOBAL_CANCEL,
  2479.             0,
  2480.             (PU8) gUSSDbuf,
  2481.             pfnUnicodeStrlen(gUSSDbuf),
  2482.             NULL);
  2483.         SetGroupKeyHandler(PopupTimerFlagEnable, (PU16) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_DOWN);
  2484.         SetGroupKeyHandler(PopupCloseByPressAnyKey, (PU16) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_UP);
  2485.         StartTimer(POPUP_TIMER, 1000, PopupTimerOver);
  2486.     }
  2487.     else
  2488.     {
  2489.         EntryNewScreen(ITEM_SCR_USSN_MSG, NULL, EntryScrDisplayUSSRMsg, NULL);
  2490.         RemoveSSReqScr();
  2491.         ShowCategory74Screen(
  2492.             STR_TITLE_SCR_USSR_MSG,
  2493.             0,
  2494.             STR_GLOBAL_REPLY,
  2495.             0,
  2496.             STR_GLOBAL_CANCEL,
  2497.             0,
  2498.             (PU8) gUSSDbuf,
  2499.             pfnUnicodeStrlen(gUSSDbuf),
  2500.             NULL);
  2501.         TurnOnBacklight(1);
  2502.         SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) USSRDelHistoryHdlr);
  2503.         SetRightSoftkeyFunction(AbortUSSDResultRequest, KEY_EVENT_UP);
  2504.         SetKeyHandler(AbortUSSDResultRequestEND, KEY_END, KEY_EVENT_DOWN);
  2505.         SetLeftSoftkeyFunction(EntryScrEditUSSRMsg, KEY_EVENT_UP);
  2506.         SetKeyHandler(NULL, KEY_VOL_UP, KEY_EVENT_UP);
  2507.         SetKeyHandler(NULL, KEY_VOL_UP, KEY_LONG_PRESS);
  2508.         SetKeyHandler(NULL, KEY_VOL_DOWN, KEY_EVENT_UP);
  2509.         SetKeyHandler(NULL, KEY_VOL_DOWN, KEY_LONG_PRESS);
  2510.     }    
  2511. }
  2512. /*****************************************************************************
  2513.  * FUNCTION
  2514.  *  USSRDelHistoryHdlr
  2515.  * DESCRIPTION
  2516.  *  
  2517.  * PARAMETERS
  2518.  *  in_param        [?]     
  2519.  * RETURNS
  2520.  *  U8
  2521.  *****************************************************************************/
  2522. U8 USSRDelHistoryHdlr(void *in_param)
  2523. {
  2524.     /*----------------------------------------------------------------*/
  2525.     /* Local Variables                                                */
  2526.     /*----------------------------------------------------------------*/
  2527.     MYQUEUE Message;
  2528.     /*----------------------------------------------------------------*/
  2529.     /* Code Body                                                      */
  2530.     /*----------------------------------------------------------------*/
  2531.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_MakePsDropUSSDReq));
  2532.     ResetCFCondStage();
  2533.     Message.oslSrcId = MOD_MMI;
  2534.     Message.oslDestId = MOD_L4C;
  2535.     Message.oslMsgId = PRT_SS_STRING_ABORT_REQ;
  2536.     Message.oslPeerBuffPtr = NULL;
  2537.     Message.oslDataPtr = NULL;
  2538.     ClearProtocolEventHandler(PRT_SS_STRING_ABORT_RSP);
  2539.     OslMsgSendExtQueue(&Message);
  2540.     return FALSE;
  2541. }
  2542. /*****************************************************************************
  2543.  * FUNCTION
  2544.  *  RegisterUSSRMsgKeyFunction
  2545.  * DESCRIPTION
  2546.  *  
  2547.  * PARAMETERS
  2548.  *  text        [?]         
  2549.  *  cursor      [?]         
  2550.  *  length      [IN]        
  2551.  * RETURNS
  2552.  *  void
  2553.  *****************************************************************************/
  2554. void RegisterUSSRMsgKeyFunction(U8 *text, U8 *cursor, S32 length)
  2555. {
  2556.     /*----------------------------------------------------------------*/
  2557.     /* Local Variables                                                */
  2558.     /*----------------------------------------------------------------*/
  2559.     /*----------------------------------------------------------------*/
  2560.     /* Code Body                                                      */
  2561.     /*----------------------------------------------------------------*/
  2562.     /* check the validity of the input password */
  2563.     if ((length) < 1)
  2564.     {
  2565.         /* if length is short then disable lsk */
  2566.         ChangeLeftSoftkey(0, 0);
  2567.     }
  2568.     else
  2569.     {
  2570.         /* if its valid length then enable lsk */
  2571.         EnableLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  2572.     }
  2573. }
  2574. /*****************************************************************************
  2575.  * FUNCTION
  2576.  *  EntryScrDisplayUSSDRes
  2577.  * DESCRIPTION
  2578.  *  This function is the entry screen for displaying USSN info to user
  2579.  * PARAMETERS
  2580.  *  void
  2581.  * RETURNS
  2582.  *  void
  2583.  *****************************************************************************/
  2584. void EntryScrDisplayUSSDRes(void)
  2585. {
  2586.     /*----------------------------------------------------------------*/
  2587.     /* Local Variables                                                */
  2588.     /*----------------------------------------------------------------*/
  2589.     history ss_scr;
  2590.     S16 nHistory = 0;
  2591.     /*----------------------------------------------------------------*/
  2592.     /* Code Body                                                      */
  2593.     /*----------------------------------------------------------------*/
  2594.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2595.     DeleteScreenIfPresent(ITEM_SCR_USSN_MSG);
  2596.     if ((GetCurrentState() == CM_OUTGOING_STATE) || (GetCurrentState() == CM_INCOMING_STATE))
  2597.     {
  2598.         TurnOnBacklight(TRUE);
  2599.         EntryNewScreen(POPUP_SCREENID, ExitDisplayPopup, NULL, NULL);
  2600.         RemoveSSReqScr();
  2601.         ss_scr.scrnID = ITEM_SCR_USSN_MSG;
  2602.         ss_scr.entryFuncPtr = EntryScrDisplayUSSDRes;
  2603.         pfnUnicodeStrcpy((S8*) ss_scr.inputBuffer, (S8*) & nHistory);
  2604.         InsertHistoryBeforeThisScrnReference(CM_SCR_MARKER, &ss_scr);
  2605.         ShowCategory74Screen(
  2606.             STR_TITLE_SCR_USSD_MSG,
  2607.             0,
  2608.             STR_GLOBAL_OK,
  2609.             IMG_GLOBAL_OK,
  2610.             0,
  2611.             0,
  2612.             (PU8) gUSSDbuf,
  2613.             pfnUnicodeStrlen(gUSSDbuf),
  2614.             NULL);
  2615.         SetGroupKeyHandler(PopupTimerFlagEnable, (PU16) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_DOWN);
  2616.         SetGroupKeyHandler(PopupCloseByPressAnyKey, (PU16) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_UP);
  2617.         StartTimer(POPUP_TIMER, 1000, PopupTimerOver);
  2618.     }
  2619.     else
  2620.     {
  2621.         SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2622.         EntryNewScreen(ITEM_SCR_USSN_MSG, NULL, EntryScrDisplayUSSDRes, NULL);
  2623.         RemoveSSReqScr();
  2624.         ShowCategory74Screen(
  2625.             STR_TITLE_SCR_USSD_MSG,
  2626.             0,
  2627.             STR_GLOBAL_OK,
  2628.             IMG_GLOBAL_OK,
  2629.             0,
  2630.             0,
  2631.             (PU8) gUSSDbuf,
  2632.             pfnUnicodeStrlen(gUSSDbuf),
  2633.             NULL);
  2634.         SetLeftSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2635.     }    
  2636. }
  2637. /*****************************************************************************
  2638.  * FUNCTION
  2639.  *  EntryScrEditUSSRMsg
  2640.  * DESCRIPTION
  2641.  *  This function is the entry screen for Editing USSR info by user
  2642.  * PARAMETERS
  2643.  *  void
  2644.  * RETURNS
  2645.  *  void
  2646.  *****************************************************************************/
  2647. void EntryScrEditUSSRMsg(void)
  2648. {
  2649.     /*----------------------------------------------------------------*/
  2650.     /* Local Variables                                                */
  2651.     /*----------------------------------------------------------------*/
  2652.     U8 *guiBuffer;  /* Buffer holding history data */
  2653.     /*----------------------------------------------------------------*/
  2654.     /* Code Body                                                      */
  2655.     /*----------------------------------------------------------------*/
  2656.     EntryNewScreen(ITEM_SCR_USSR_EDIT, NULL, EntryScrEditUSSRMsg, NULL);
  2657.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2658.     DeleteScreenIfPresent(ITEM_SCR_USSR_MSG);
  2659.     guiBuffer = GetCurrGuiBuffer(ITEM_SCR_USSR_EDIT);
  2660.     if (guiBuffer == NULL)
  2661.     {
  2662.         memset(g_callset_context.SSCFNum, 0, (MAX_CC_ADDR_LEN * ENCODING_LENGTH) + 2);
  2663.     }
  2664.     RegisterInputBoxValidationFunction(RegisterUSSRMsgKeyFunction);
  2665.     ShowCategory5Screen(
  2666.         STR_TITLE_SCR_USSR_EDIT_MSG,
  2667.         0,
  2668.         STR_GLOBAL_OK,
  2669.         IMG_GLOBAL_OK,
  2670.         STR_GLOBAL_BACK,
  2671.         IMG_GLOBAL_BACK,
  2672.         (S16) (INPUT_TYPE_KEYPAD_NUMERIC | INPUT_TYPE_ALPHANUMERIC_UPPERCASE | INPUT_TYPE_USE_ONLY_ENGLISH_MODES),
  2673.         (U8*) g_callset_context.SSCFNum,
  2674.         MAX_CC_ADDR_LEN,
  2675.         guiBuffer);
  2676.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSR_EDIT, (HistoryDelCBPtr) USSRDelHistoryHdlr);
  2677.     SetCategory5RightSoftkeyFunction(EditUSSRGoBack, KEY_EVENT_UP);
  2678.     SetKeyHandler(AbortUSSDResultRequestEND, KEY_END, KEY_EVENT_DOWN);
  2679.     SetLeftSoftkeyFunction(SendUSSRMsg, KEY_EVENT_UP);
  2680.     SetKeyHandler(NULL, KEY_VOL_UP, KEY_EVENT_UP);
  2681.     SetKeyHandler(NULL, KEY_VOL_UP, KEY_LONG_PRESS);
  2682.     SetKeyHandler(NULL, KEY_VOL_DOWN, KEY_EVENT_UP);
  2683.     SetKeyHandler(NULL, KEY_VOL_DOWN, KEY_LONG_PRESS);
  2684.     if (pfnUnicodeStrlen((S8*) g_callset_context.SSCFNum) == 0)
  2685.     {
  2686.         ChangeLeftSoftkey(0, 0);
  2687.     }
  2688. }
  2689. /*****************************************************************************
  2690.  * FUNCTION
  2691.  *  EditUSSRGoBack
  2692.  * DESCRIPTION
  2693.  *  Sends USSR
  2694.  * PARAMETERS
  2695.  *  void
  2696.  * RETURNS
  2697.  *  void
  2698.  *****************************************************************************/
  2699. void EditUSSRGoBack(void)
  2700. {
  2701.     /*----------------------------------------------------------------*/
  2702.     /* Local Variables                                                */
  2703.     /*----------------------------------------------------------------*/
  2704.     /*----------------------------------------------------------------*/
  2705.     /* Code Body                                                      */
  2706.     /*----------------------------------------------------------------*/
  2707.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSR_EDIT, (HistoryDelCBPtr) NULL);
  2708.     GoBackHistory();
  2709. }
  2710. /*****************************************************************************
  2711.  * FUNCTION
  2712.  *  SendUSSRMsg
  2713.  * DESCRIPTION
  2714.  *  Sends USSR
  2715.  * PARAMETERS
  2716.  *  void
  2717.  * RETURNS
  2718.  *  void
  2719.  *****************************************************************************/
  2720. void SendUSSRMsg(void)
  2721. {
  2722.     /*----------------------------------------------------------------*/
  2723.     /* Local Variables                                                */
  2724.     /*----------------------------------------------------------------*/
  2725.     PU8 Buf;
  2726.     /*----------------------------------------------------------------*/
  2727.     /* Code Body                                                      */
  2728.     /*----------------------------------------------------------------*/
  2729.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2730.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSR_EDIT, (HistoryDelCBPtr) NULL);
  2731.     DeleteScreenIfPresent(ITEM_SCR_USSN_MSG);
  2732.     ClearExitHandler();
  2733.     ClearDtmfBuf();
  2734.     FillDtmfBuff((PU8) g_callset_context.SSCFNum);
  2735.     Buf = GetDtmfBuffer();
  2736.     MakeMyCall((PS8) Buf);
  2737. }
  2738. /*****************************************************************************
  2739.  * FUNCTION
  2740.  *  AbortUSSDResultRequest
  2741.  * DESCRIPTION
  2742.  *  
  2743.  * PARAMETERS
  2744.  *  void
  2745.  * RETURNS
  2746.  *  void
  2747.  *****************************************************************************/
  2748. void AbortUSSDResultRequest(void)
  2749. {
  2750.     /*----------------------------------------------------------------*/
  2751.     /* Local Variables                                                */
  2752.     /*----------------------------------------------------------------*/
  2753.     /*----------------------------------------------------------------*/
  2754.     /* Code Body                                                      */
  2755.     /*----------------------------------------------------------------*/
  2756.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_AbortUSSDResultRequest));
  2757.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2758.     ClearExitHandler();
  2759.     MakePsDropUSSDReq(CBackDropUSSDReq);
  2760. }
  2761. /*****************************************************************************
  2762.  * FUNCTION
  2763.  *  AbortUSSDResultRequestEND
  2764.  * DESCRIPTION
  2765.  *  
  2766.  * PARAMETERS
  2767.  *  void
  2768.  * RETURNS
  2769.  *  void
  2770.  *****************************************************************************/
  2771. void AbortUSSDResultRequestEND(void)
  2772. {
  2773.     /*----------------------------------------------------------------*/
  2774.     /* Local Variables                                                */
  2775.     /*----------------------------------------------------------------*/
  2776.     /*----------------------------------------------------------------*/
  2777.     /* Code Body                                                      */
  2778.     /*----------------------------------------------------------------*/
  2779.     if (isInCall())
  2780.     {
  2781.         HangupAllCalls();
  2782.         return;
  2783.     }
  2784.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_AbortUSSDResultRequestEND));
  2785.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2786.     SetDelScrnIDCallbackHandler(ITEM_SCR_USSR_EDIT, (HistoryDelCBPtr) NULL);
  2787.     DeleteScreenIfPresent(ITEM_SCR_USSN_MSG);
  2788.     ClearExitHandler();
  2789.     MakePsDropUSSDReq(CBackDropUSSDReqEND);
  2790. }
  2791. /*****************************************************************************
  2792.  * FUNCTION
  2793.  *  ResumeSSScrInCall
  2794.  * DESCRIPTION
  2795.  *  
  2796.  * PARAMETERS
  2797.  *  void
  2798.  * RETURNS
  2799.  *  void
  2800.  *****************************************************************************/
  2801. void ResumeSSScrInCall(void)
  2802. {
  2803.     /*----------------------------------------------------------------*/
  2804.     /* Local Variables                                                */
  2805.     /*----------------------------------------------------------------*/
  2806.     history temphistory;
  2807.     /*----------------------------------------------------------------*/
  2808.     /* Code Body                                                      */
  2809.     /*----------------------------------------------------------------*/
  2810.     if (IsScreenPresent(ITEM_SCR_USSN_MSG))
  2811.     {
  2812.         GetHistory(ITEM_SCR_USSN_MSG, &temphistory);
  2813.         SetDelScrnIDCallbackHandler(ITEM_SCR_USSN_MSG, (HistoryDelCBPtr) NULL);
  2814.         SetDelScrnIDCallbackHandler(ITEM_SCR_USSR_EDIT, (HistoryDelCBPtr) NULL);
  2815.         DeleteScreenIfPresent(ITEM_SCR_USSN_MSG);
  2816.         DeleteScreenIfPresent(ITEM_SCR_USSR_EDIT);
  2817.         (*(temphistory.entryFuncPtr)) ();
  2818.     }
  2819.     else if (IsScreenPresent(SCR_CM_REQUESTINGUSSD))
  2820.     {
  2821.         GetHistory(SCR_CM_REQUESTINGUSSD, &temphistory);
  2822.         SetDelScrnIDCallbackHandler(SCR_CM_REQUESTINGUSSD, (HistoryDelCBPtr) NULL);
  2823.         DeleteScreenIfPresent(SCR_CM_REQUESTINGUSSD);
  2824.         (*(temphistory.entryFuncPtr)) ();
  2825.     }
  2826. }