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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*******************************************************************************
  36.  *  Modification Notice:
  37.  *  --------------------------
  38.  *  This software is modified by MediaTek Inc. and the information contained
  39.  *  herein is confidential. The software may not be copied and the information
  40.  *  contained herein may not be used or disclosed except with the written
  41.  *  permission of MediaTek Inc. (C) 2001
  42.  *
  43.  *******************************************************************************/
  44.  /*******************************************************************************
  45.  * Filename:
  46.  * ---------
  47.  *   HistoryHelper.c
  48.  *
  49.  * Project:
  50.  * --------
  51.  *   Maui_Software
  52.  *
  53.  * Description:
  54.  * ------------
  55.  *  .......
  56.  *
  57.  * Author:
  58.  * -------
  59.  * -------
  60.  *
  61.  *------------------------------------------------------------------------------
  62.  * $Log$
  63.  *
  64.  * removed!
  65.  * removed!
  66.  * Don't notify USB when CM is over.
  67.  *
  68.  * removed!
  69.  * removed!
  70.  * 
  71.  *
  72.  * removed!
  73.  * removed!
  74.  * 
  75.  *
  76.  * removed!
  77.  * removed!
  78.  * Delete CTM editor screen after call ended.
  79.  *
  80.  * removed!
  81.  * removed!
  82.  * 
  83.  *
  84.  * removed!
  85.  * removed!
  86.  * 
  87.  *
  88.  * removed!
  89.  * removed!
  90.  * 
  91.  *
  92.  * removed!
  93.  * removed!
  94.  * 
  95.  *
  96.  * removed!
  97.  * removed!
  98.  * 
  99.  *
  100.  * removed!
  101.  * removed!
  102.  * 
  103.  *
  104.  * removed!
  105.  * removed!
  106.  * 
  107.  *
  108.  * removed!
  109.  * removed!
  110.  * 
  111.  *
  112.  * removed!
  113.  * removed!
  114.  * 
  115.  *
  116.  * removed!
  117.  * removed!
  118.  * 
  119.  *
  120.  * removed!
  121.  * removed!
  122.  * 
  123.  *
  124.  * removed!
  125.  * removed!
  126.  * 
  127.  *
  128.  * removed!
  129.  * removed!
  130.  * 
  131.  *
  132.  * removed!
  133.  * removed!
  134.  * 
  135.  *
  136.  * removed!
  137.  * removed!
  138.  * 
  139.  *
  140.  * removed!
  141.  * removed!
  142.  * 
  143.  *
  144.  * removed!
  145.  * removed!
  146.  * 
  147.  *
  148.  * removed!
  149.  * removed!
  150.  * 
  151.  *
  152.  * removed!
  153.  * removed!
  154.  * 
  155.  *
  156.  * removed!
  157.  * removed!
  158.  * 
  159.  *
  160.  * removed!
  161.  * removed!
  162.  * 
  163.  *
  164.  * removed!
  165.  * removed!
  166.  * 
  167.  *
  168.  * removed!
  169.  * removed!
  170.  * 
  171.  *
  172.  * removed!
  173.  * removed!
  174.  * 
  175.  *
  176.  * removed!
  177.  * removed!
  178.  * 
  179.  *
  180.  * removed!
  181.  * removed!
  182.  * 
  183.  *
  184.  * removed!
  185.  * removed!
  186.  * 
  187.  *
  188.  * removed!
  189.  * removed!
  190.  * 
  191.  *
  192.  * removed!
  193.  * removed!
  194.  * 
  195.  *
  196.  * removed!
  197.  * removed!
  198.  * 
  199.  *
  200.  * removed!
  201.  * removed!
  202.  * 
  203.  *
  204.  * removed!
  205.  * removed!
  206.  * 
  207.  *
  208.  * removed!
  209.  * removed!
  210.  * 
  211.  *
  212.  * removed!
  213.  * removed!
  214.  * 
  215.  *
  216.  * removed!
  217.  * removed!
  218.  * 
  219.  *
  220.  * removed!
  221.  * removed!
  222.  * 
  223.  *
  224.  * removed!
  225.  * removed!
  226.  * 
  227.  *
  228.  * removed!
  229.  * removed!
  230.  * 
  231.  *
  232.  * removed!
  233.  * removed!
  234.  * 
  235.  *
  236.  *******************************************************************************/
  237. /**
  238.  * Copyright Notice
  239.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  240.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  241.  *  (It is illegal to remove this copyright notice from this software or any
  242.  *  portion of it)
  243.  */
  244. /**************************************************************
  245.    FILENAME : HistoryHelper.c
  246.    PURPOSE     : Call Structure Management API
  247.    REMARKS     : nil
  248.    AUTHOR      : Ashish
  249.    DATE     : Nov 8,02
  250. **************************************************************/
  251. #include "stdC.h"
  252. #include "MMI_Features.h"
  253. #include "L4Dr.h"
  254. #include "L4Dr1.h"
  255. #include "PixtelDataTypes.h"
  256. #include "DebugInitDef.h"
  257. #include "GlobalScrEnum.h"
  258. #include "HistoryGprot.h"
  259. #include "SubLCDHistoryGprot.h"
  260. #include "Wgui_categories.h"
  261. #include "TimerEvents.h"
  262. #include "MMI_trc.h"
  263. #include "KeyBrd.h"
  264. #include "bootup.h"
  265. #include "PowerOnChargerProt.h"
  266. #include "USBDeviceGprot.h"
  267. #include "SATGProts.h"
  268. #include "SimDetectionGexdcl.h"
  269. #include "AlarmFrameworkProt.h"
  270. #include "AlarmDef.h"
  271. #ifdef __MMI_TODOLIST__
  272. #include "ToDoListEnum.h"
  273. #endif
  274. #include "MessagesMiscell.h"
  275. #include "PhonebookDef.h"
  276. #include "PhonebookGprot.h"
  277. #include "gpioInc.h"
  278. #include "ProfileGprots.h"
  279. #include "CallhistoryEnum.h"
  280. #include "mdi_datatype.h"
  281. #include "mdi_audio.h"
  282. #ifdef WAP_SUPPORT
  283. #include "wapadp.h"
  284. #endif 
  285. #include "Mdi_datatype.h"
  286. #include "Mdi_audio.h"
  287. #include "CallManagementIdDef.h"
  288. #include "CallManagementStruct.h"
  289. #include "CallStructureManagementProt.h"
  290. #include "CallsGprots.h"
  291. #include "CommonStubsProt.h"
  292. #include "RedialHelperGProt.h"
  293. #include "CallManagementGprot.h"
  294. #include "IncomingCallManagementProt.h"
  295. #include "OutgoingCallHelperProt.h"
  296. #include "OutgoingCallManagementProt.h"
  297. #include "HistoryHelperProt.h"
  298. #if defined(__MMI_BG_SOUND_EFFECT__)
  299. #include "BGSoundGProt.h"
  300. #endif 
  301. #if defined(__MMI_WEBCAM__)
  302. #include "ExtDeviceDefs.h"
  303. #endif 
  304. //static pBOOL                  gPOPUpFlag=FALSE;
  305. //static pBOOL                  gNotifySSFlag= FALSE;
  306. //static FuncPtr                        gCbackAfterSS=NULL;
  307. /* pBOOL noSave = TRUE; */
  308. PU8 gdispnameForSubLCD = NULL;
  309. #ifdef __MMI_CLAMCLOSE_BACK2IDLE__
  310. extern BOOL IsClamClose(void);
  311. //micha0601
  312. //extern U8 gIsInSATCall;
  313. #endif /* __MMI_CLAMCLOSE_BACK2IDLE__ */ 
  314. extern void mmi_msg_reset_new_msg_ind_call_end(void);
  315. extern U8 mmi_msg_need_new_msg_ind_call_end(void);
  316. /*****************************************************************************
  317.  * FUNCTION
  318.  *  EntryScrMarkerError
  319.  * DESCRIPTION
  320.  *  This function is the error screen which should never be
  321.  *  called.
  322.  * PARAMETERS
  323.  *  void
  324.  * RETURNS
  325.  *  void
  326.  *****************************************************************************/
  327. void EntryScrMarkerError(void)
  328. {
  329.     /*----------------------------------------------------------------*/
  330.     /* Local Variables                                                */
  331.     /*----------------------------------------------------------------*/
  332.     /*----------------------------------------------------------------*/
  333.     /* Code Body                                                      */
  334.     /*----------------------------------------------------------------*/
  335.     /* U8* guiBuffer; */
  336.     EntryNewScreen(CM_SCR_MARKER, NULL, NULL, NULL);
  337.     // guiBuffer = GetCurrGuiBuffer(CM_SCR_MARKER); /* Getting the Index from history  */
  338.     SetLeftSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  339.     StartTimer(CM_NOTIFYDURATION_TIMER, 1, GoBackfromNotifyScr);
  340. }
  341. /*****************************************************************************
  342.  * FUNCTION
  343.  *  AddMarkerToHistory
  344.  * DESCRIPTION
  345.  *  This function inserts a marker screen to history
  346.  * PARAMETERS
  347.  *  void
  348.  *  Screen(?)       [IN]        ID to add as marker screen
  349.  * RETURNS
  350.  *  void
  351.  *****************************************************************************/
  352. void AddMarkerToHistory(void)
  353. {
  354.     /*----------------------------------------------------------------*/
  355.     /* Local Variables                                                */
  356.     /*----------------------------------------------------------------*/
  357.     history scr101;
  358.     U16 nHistory = 0;
  359.     /*----------------------------------------------------------------*/
  360.     /* Code Body                                                      */
  361.     /*----------------------------------------------------------------*/
  362.     pfnUnicodeStrcpy((S8*) scr101.inputBuffer, (PS8) & nHistory);
  363.     scr101.scrnID = CM_SCR_MARKER;
  364.     scr101.entryFuncPtr = EntryScrMarkerError;
  365.     AddHistory(scr101);
  366. }
  367. /*****************************************************************************
  368.  * FUNCTION
  369.  *  DeleteUptoCmScreen
  370.  * DESCRIPTION
  371.  *  Helper to delete all screen upto marker
  372.  * PARAMETERS
  373.  *  void
  374.  * RETURNS
  375.  *  void
  376.  *****************************************************************************/
  377. void DeleteUptoCmScreen(void)
  378. {
  379.     /*----------------------------------------------------------------*/
  380.     /* Local Variables                                                */
  381.     /*----------------------------------------------------------------*/
  382.     /*----------------------------------------------------------------*/
  383.     /* Code Body                                                      */
  384.     /*----------------------------------------------------------------*/
  385.     DeleteUptoScrID(CM_SCR_MARKER);
  386. }
  387. /*****************************************************************************
  388.  * FUNCTION
  389.  *  DeleteAllCMSubLCDScreens
  390.  * DESCRIPTION
  391.  *  Deletes All Sub LCD Screens in history
  392.  * PARAMETERS
  393.  *  void
  394.  * RETURNS
  395.  *  void
  396.  *****************************************************************************/
  397. void DeleteAllCMSubLCDScreens(void)
  398. {
  399.     /*----------------------------------------------------------------*/
  400.     /* Local Variables                                                */
  401.     /*----------------------------------------------------------------*/
  402.     /*----------------------------------------------------------------*/
  403.     /* Code Body                                                      */
  404.     /*----------------------------------------------------------------*/
  405.     while (IsSubLCDScreenPresent(SUB_LCD_SCR_CM_ACTIVECALLSCREEN))
  406.     {
  407.         DeleteSubLCDScreen(SUB_LCD_SCR_CM_ACTIVECALLSCREEN);
  408.     }
  409.     while (IsSubLCDScreenPresent(SUB_LCD_SCR1001_CM_OUTGOINGCALLSCREEN))
  410.     {
  411.         DeleteSubLCDScreen(SUB_LCD_SCR1001_CM_OUTGOINGCALLSCREEN);
  412.     }
  413.     while (IsSubLCDScreenPresent(SUB_LCD_ITEMSCR_INCOMING_CALL))
  414.     {
  415.         DeleteSubLCDScreen(SUB_LCD_ITEMSCR_INCOMING_CALL);
  416.     }
  417. }
  418. /*****************************************************************************
  419.  * FUNCTION
  420.  *  DeleteIncomingCallOptionScreen
  421.  * DESCRIPTION
  422.  *  Deletes All incoming call option Screens in history
  423.  * PARAMETERS
  424.  *  void
  425.  * RETURNS
  426.  *  void
  427.  *****************************************************************************/
  428. void DeleteIncomingCallOptionScreen(void)
  429. {
  430.     /*----------------------------------------------------------------*/
  431.     /* Local Variables                                                */
  432.     /*----------------------------------------------------------------*/
  433.     U16 scrnId = 0;
  434.     /*----------------------------------------------------------------*/
  435.     /* Code Body                                                      */
  436.     /*----------------------------------------------------------------*/
  437.     GetPreviousScrnIdOf(SCR1009_CM_CALLLISTSCREEN, &scrnId);
  438.     if (scrnId == ITEM_SCR_INC_MACT_OPN)
  439.     {
  440.         DeleteScreenIfPresent(SCR1009_CM_CALLLISTSCREEN);
  441.     }
  442.     /* deflect need to delete dial pad and phb list if any */
  443.     GetNextScrnIdOf (ITEM_SCR_CALL_DEFLECT_DIGIT_HANDLER_ID, &scrnId);
  444.     if (scrnId == SCR_PBOOK_LIST)
  445.     {
  446.         DeleteScreenIfPresent(SCR_PBOOK_LIST);
  447.         DeleteScreenIfPresent(ITEM_SCR_CALL_DEFLECT_DIGIT_HANDLER_ID);
  448.     }
  449.     DeleteScreenIfPresent(ITEM_SCR_INC_MACT_OPN);
  450.     DeleteScreenIfPresent(ITEM_SCR_INCOMING_OPTIONS);
  451. }
  452. /*****************************************************************************
  453.  * FUNCTION
  454.  *  SetNotifySSFlag
  455.  * DESCRIPTION
  456.  *  Sets Notify SS Flag dpeneding on flag
  457.  * PARAMETERS
  458.  *  flag        [IN]        
  459.  * RETURNS
  460.  *  void
  461.  *****************************************************************************/
  462. void SetNotifySSFlag(pBOOL flag)
  463. {
  464.     /*----------------------------------------------------------------*/
  465.     /* Local Variables                                                */
  466.     /*----------------------------------------------------------------*/
  467.     /*----------------------------------------------------------------*/
  468.     /* Code Body                                                      */
  469.     /*----------------------------------------------------------------*/
  470.     cm_p->history_info.IsNotifySS = flag;
  471. }
  472. /*****************************************************************************
  473.  * FUNCTION
  474.  *  GetNotifySSFlag
  475.  * DESCRIPTION
  476.  *  Returns Notify SS Flag
  477.  * PARAMETERS
  478.  *  void
  479.  * RETURNS
  480.  *  flag
  481.  *****************************************************************************/
  482. pBOOL GetNotifySSFlag(void)
  483. {
  484.     /*----------------------------------------------------------------*/
  485.     /* Local Variables                                                */
  486.     /*----------------------------------------------------------------*/
  487.     /*----------------------------------------------------------------*/
  488.     /* Code Body                                                      */
  489.     /*----------------------------------------------------------------*/
  490.     return cm_p->history_info.IsNotifySS;
  491. }
  492. /*****************************************************************************
  493.  * FUNCTION
  494.  *  SetCbackAfterSS
  495.  * DESCRIPTION
  496.  *  Sets Function to be called after SS
  497.  * PARAMETERS
  498.  *  fptr            [IN]        
  499.  *  Function(?)     [IN]        
  500.  * RETURNS
  501.  *  void
  502.  *****************************************************************************/
  503. void SetCbackAfterSS(FuncPtr fptr)
  504. {
  505.     /*----------------------------------------------------------------*/
  506.     /* Local Variables                                                */
  507.     /*----------------------------------------------------------------*/
  508.     /*----------------------------------------------------------------*/
  509.     /* Code Body                                                      */
  510.     /*----------------------------------------------------------------*/
  511.     cm_p->history_info.CbackAfterNotifySS = fptr;
  512. }
  513. /*****************************************************************************
  514.  * FUNCTION
  515.  *  GetCbackAfterSS
  516.  * DESCRIPTION
  517.  *  Returns Function to be called after SS
  518.  * PARAMETERS
  519.  *  void
  520.  * RETURNS
  521.  *  void
  522.  *****************************************************************************/
  523. FuncPtr GetCbackAfterSS(void)
  524. {
  525.     /*----------------------------------------------------------------*/
  526.     /* Local Variables                                                */
  527.     /*----------------------------------------------------------------*/
  528.     /*----------------------------------------------------------------*/
  529.     /* Code Body                                                      */
  530.     /*----------------------------------------------------------------*/
  531.     return cm_p->history_info.CbackAfterNotifySS;
  532. }
  533. /*****************************************************************************
  534.  * FUNCTION
  535.  *  SetPOPUpFlag
  536.  * DESCRIPTION
  537.  *  
  538.  * PARAMETERS
  539.  *  flag        [IN]        
  540.  *  TRUE(?)     [IN]        For set, FALSE for not set
  541.  * RETURNS
  542.  *  void
  543.  *****************************************************************************/
  544. void SetPOPUpFlag(pBOOL flag)
  545. {
  546.     /*----------------------------------------------------------------*/
  547.     /* Local Variables                                                */
  548.     /*----------------------------------------------------------------*/
  549.     /*----------------------------------------------------------------*/
  550.     /* Code Body                                                      */
  551.     /*----------------------------------------------------------------*/
  552.     cm_p->history_info.IsPopUp = flag;
  553. }
  554. /*****************************************************************************
  555.  * FUNCTION
  556.  *  GetPOPUpFlag
  557.  * DESCRIPTION
  558.  *  Gets the LoudSpFromOption Flag Status
  559.  * PARAMETERS
  560.  *  void
  561.  *  TRUE(?)     [OUT]       For set, FALSE for not set
  562.  * RETURNS
  563.  *  void
  564.  *****************************************************************************/
  565. pBOOL GetPOPUpFlag(void)
  566. {
  567.     /*----------------------------------------------------------------*/
  568.     /* Local Variables                                                */
  569.     /*----------------------------------------------------------------*/
  570.     /*----------------------------------------------------------------*/
  571.     /* Code Body                                                      */
  572.     /*----------------------------------------------------------------*/
  573.     return cm_p->history_info.IsPopUp;
  574. }
  575. /*****************************************************************************
  576.  * FUNCTION
  577.  *  GetCmMarkerScrnID
  578.  * DESCRIPTION
  579.  *  This function checks marker screen id value.
  580.  * PARAMETERS
  581.  *  void
  582.  * RETURNS
  583.  *  U16
  584.  *****************************************************************************/
  585. U16 GetCmMarkerScrnID(void)
  586. {
  587.     /*----------------------------------------------------------------*/
  588.     /* Local Variables                                                */
  589.     /*----------------------------------------------------------------*/
  590.     /*----------------------------------------------------------------*/
  591.     /* Code Body                                                      */
  592.     /*----------------------------------------------------------------*/
  593.     return CM_SCR_MARKER;
  594. }
  595. /*****************************************************************************
  596.  * FUNCTION
  597.  *  SetNoSave
  598.  * DESCRIPTION
  599.  *  Controls access to global history store buffer
  600.  * PARAMETERS
  601.  *  void
  602.  * RETURNS
  603.  *  void
  604.  *****************************************************************************/
  605. void SetNoSave(void)
  606. {
  607.     /*----------------------------------------------------------------*/
  608.     /* Local Variables                                                */
  609.     /*----------------------------------------------------------------*/
  610.     /*----------------------------------------------------------------*/
  611.     /* Code Body                                                      */
  612.     /*----------------------------------------------------------------*/
  613.     cm_p->history_info.IsSave = FALSE;
  614. }
  615. /*****************************************************************************
  616.  * FUNCTION
  617.  *  CMHistoryHandler
  618.  * DESCRIPTION
  619.  *  Helper to perform last rites and exit application
  620.  * PARAMETERS
  621.  *  void
  622.  * RETURNS
  623.  *  void
  624.  *****************************************************************************/
  625. void CMHistoryHandler(void)
  626. {
  627. #ifdef __MMI_CLAMCLOSE_BACK2IDLE__
  628.     /*----------------------------------------------------------------*/
  629.     /* Local Variables                                                */
  630.     /*----------------------------------------------------------------*/
  631.     /*----------------------------------------------------------------*/
  632.     /* Code Body                                                      */
  633.     /*----------------------------------------------------------------*/
  634.     if (IsClamClose() == MMI_TRUE && !IsInSATCall())
  635.     {
  636.         DeleteScreenIfPresent(SCR8055_CALLS_LIST_DIALED);
  637.         DeleteScreenIfPresent(SCR8056_CALLS_LIST_MISSED);
  638.         DeleteScreenIfPresent(SCR8054_CALLS_LIST_RECEIVED);
  639.         DeleteScreenIfPresent(SCR8057_CALLS_LIST_MIXED);
  640.         DeleteScreenIfPresent(SCR_ID_ALM_INDICATION);
  641. #ifdef __MMI_TODOLIST__        
  642.         DeleteScreenIfPresent(SCR_TDL_REMINDER);
  643. #endif
  644.     }
  645. #endif /* __MMI_CLAMCLOSE_BACK2IDLE__ */ 
  646.     GoBackHistory();
  647. #ifdef __MMI_WEBCAM__
  648.     if (GetExitScrnID() == SCR_ID_USB_WEBCAM)
  649.     {
  650.         /* if is in webcam screen, do not proess End key handler */
  651.         return;
  652.     }
  653. #endif /* __MMI_WEBCAM__ */ 
  654. #ifdef __MMI_CLAMCLOSE_BACK2IDLE__
  655.     if (IsClamClose() == MMI_TRUE && cm_p->history_info.IsClamCloseEndCall == MMI_TRUE &&
  656.      !IsInSATCall() && (GetExitScrnID() != ITEM_SCR_MISSED_CALL))
  657.     {
  658.      cm_p->history_info.IsClamCloseEndCall = MMI_FALSE;
  659.         ExecuteCurrKeyHandler(KEY_END, KEY_EVENT_DOWN);
  660.     }
  661. #endif /* __MMI_CLAMCLOSE_BACK2IDLE__ */ 
  662. }
  663. /*****************************************************************************
  664.  * FUNCTION
  665.  *  GetOutOfCMApplication
  666.  * DESCRIPTION
  667.  *  Helper to perform last rites and exit application
  668.  * PARAMETERS
  669.  *  void
  670.  * RETURNS
  671.  *  void
  672.  *****************************************************************************/
  673. void GetOutOfCMApplication(void)
  674. {
  675.     /*----------------------------------------------------------------*/
  676.     /* Local Variables                                                */
  677.     /*----------------------------------------------------------------*/
  678. U8 type;
  679.     /*----------------------------------------------------------------*/
  680.     /* Code Body                                                      */
  681.     /*----------------------------------------------------------------*/
  682.     // XXX CAUTION: If any changes are being done here,
  683.     // corresponding changes have to be there in GetOutOfCMforAdjustHistory()
  684.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_GetOutOfCMApplication));
  685.     /* stop background sound effect */
  686. #if defined(__MMI_BG_SOUND_EFFECT__)
  687.     mmi_bgsnd_util_stop_play_sound_end_call();
  688. #endif 
  689.     /* low battery */
  690.     if (g_charbat_context.LowBatteryTxProhibitFlag == 1)
  691.     {
  692.         SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_IDLE_DURCNT_PROHIBIT);
  693.     }
  694.     else
  695.     {
  696.         SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_IDLE_DURCNT_NORMAL);
  697.     }
  698.     if (GetCallDeflectFlag() == TRUE)
  699.     {
  700.         DeleteScreenIfPresent(ITEM_SCR_CALL_DEFLECT_DIGIT_HANDLER_ID);
  701.         SetCallDeflectFlag(FALSE);
  702.     }
  703.     /* reset redial data */
  704.     if (IsRedialSet())
  705.     {
  706.         ResetRedialAttempts();
  707.     }
  708.     SetDialedDigitCalledFlag(FALSE);
  709.     mmi_phb_call_set_dial_from_list(MMI_PHB_NONE);
  710.     CHISTSetDialFromCallLogFlag(0);
  711. /* turn off speech if needed */
  712. type = mdi_audio_speech_get_app_id();
  713.     if (type == MDI_AUDIO_SPEECH_APP_ID_GSM)
  714.     {
  715.         mdi_audio_speech_session_stop(MDI_AUDIO_SPEECH_APP_ID_GSM);
  716.     }
  717.     else if (type == MDI_AUDIO_SPEECH_APP_ID_WCDMA)
  718.     {
  719.         mdi_audio_speech_session_stop(MDI_AUDIO_SPEECH_APP_ID_WCDMA);
  720.     }
  721.     /* stop voice recording */
  722.     if (GetVoiceRecordingFlag())
  723.     {
  724.         SetKeyPadStopVoiceRecordLongPress();
  725.     }
  726.     /* unmute phone */
  727.     if (TRUE == IsPhoneInMute())
  728.     {
  729.         UnMutethePhone();
  730.     }
  731.     /* turn off loud speaker */
  732.     if (GetHFreeHeld() == TRUE)
  733.     {
  734.         SetHFreeHeld(FALSE);
  735.         DisbleHandsFree();
  736.         SetLoudSpeaker(FALSE);
  737.     }
  738. #ifdef __MMI_BT_PROFILE__
  739. #ifdef __MMI_VOIP__
  740.     /* do not turn off sco link in case voip needs to turn on again */
  741.     if (mmi_voip_app_total_call() == 0)
  742.     {
  743.         PRINT_INFORMATION(("n[GetOutOfCMApplication] SCO Endsn"));
  744.         mmi_profiles_bt_call_end_callback();
  745.     }
  746.     else
  747.     {
  748.         PRINT_INFORMATION(("n[GetOutOfCMApplication] SCO Not Endsn"));
  749.     }
  750. #else
  751.     /* notify bt profiles call end */
  752.     mmi_profiles_bt_call_end_callback();
  753. #endif /* __MMI_VOIP__ */
  754. #endif /* __MMI_BT_PROFILE__ */ 
  755.     /* resume audio */
  756. #ifdef __MMI_CM_BLACK_LIST__
  757. if(GetBlackIncomingFlag() == FALSE)
  758.     {
  759. #endif /* __MMI_CM_BLACK_LIST__ */ 
  760.     mdi_audio_resume_background_play();
  761. #ifdef __MMI_CM_BLACK_LIST__
  762. }
  763.     SetBlackIncomingFlag(FALSE);
  764. #endif /* __MMI_CM_BLACK_LIST__ */
  765.     /* micha0831 */
  766.     SATCallTerminate();
  767.     /* reset DTMF flag */
  768.     SetDTMFFlag(TRUE);
  769.     /* reset state and exit */
  770.     ReinitalizeCallManagement();
  771.     SetCallAbortReqSentFlag(FALSE);
  772.     if (GetAbortCallRequestedFlag() == TRUE || GetTotalCallCount() == 0)
  773.     {
  774.         DeleteAllCMSubLCDScreens();
  775.         GoBackSubLCDHistory();
  776.         SetAbortCallRequestedFlag(FALSE);
  777.     }
  778. /* Delete background sound screen */
  779. #if defined(__MMI_BG_SOUND_EFFECT__)
  780.     mmi_bgsnd_util_delete_end_call_screen();
  781. #endif 
  782. /* Delete SCR_CTM_EDITOR  by Mick*/
  783. #ifdef __CTM_SUPPORT__
  784. DeleteScreenIfPresent(SCR_CTM_EDITOR);
  785. #endif /* __CTM_SUPPORT__ */ 
  786. #ifdef __MMI_VOIP__
  787.     if ((IsScreenPresent(CM_SCR_MARKER) && GetCMScrnFlag() == FALSE) || 
  788.         (GetCMScrnFlag() == TRUE && mmi_voip_app_total_call() != 0))
  789. #else
  790.     if ((IsScreenPresent(CM_SCR_MARKER)) && (GetCMScrnFlag() == FALSE))
  791. #endif
  792.     {
  793.         /* enter in-call option menu to go to other applications
  794.            delete CM screens only and go back to that application */
  795.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GetOutOfCMApplication1));
  796.         if (IsScreenPresent(SCR1003_CM_ACTIVECALLOPTIONS))
  797.         {
  798.             DeleteBetweenScreen(CM_SCR_MARKER, SCR1003_CM_ACTIVECALLOPTIONS);
  799.             DeleteIncomingCallOptionScreen();
  800.         }
  801.         else
  802.         {
  803.             if (!DeleteBetweenScreen(CM_SCR_MARKER, SCR_CM_ACTIVECALLSCREEN))
  804.             {
  805.                 DeleteScreenIfPresent(CM_SCR_MARKER);
  806.             }
  807.         }
  808.         CMHistoryHandler();
  809.         SetCMScrnFlag(TRUE);
  810.     }
  811.     else
  812.     {
  813.         /* all CM screens, delete all CM screen and go back */
  814.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GetOutOfCMApplication2));
  815.         DeleteNScrId(CM_SCR_MARKER);
  816.         CMHistoryHandler();
  817.     }
  818.     /* in case of USSD will have extra marker in history */
  819.     DeleteScreenIfPresent(CM_SCR_MARKER);
  820. /*
  821.  *#ifdef __MMI_USB_SUPPORT__
  822.  *    PendingUsbDetectionHdlr();
  823.  *#endif
  824.  */
  825.     AlmEnableExpiryHandler();
  826.     /* PendingAlarmReminder(); */
  827.     if (mmi_msg_need_new_msg_ind_call_end())
  828.     {
  829.         mmi_msg_reset_new_msg_ind_call_end();
  830.         /* PlayMessageArrivalTone(); */
  831.     }
  832. #ifdef OBIGO_SUPPORT    /* WAP_SUPPORT */
  833.     /* Callback for WAP widget */
  834.     widget_MMI_on_exit_CM();
  835. #endif /* OBIGO_SUPPORT */ 
  836.     return;
  837. }
  838. /*****************************************************************************
  839.  * FUNCTION
  840.  *  GetOutOfCMforAdjustHistory
  841.  * DESCRIPTION
  842.  *  Helper to perform last rites and exit application
  843.  * PARAMETERS
  844.  *  void
  845.  * RETURNS
  846.  *  void
  847.  *****************************************************************************/
  848. void GetOutOfCMforAdjustHistory(void)
  849. {
  850.     /*----------------------------------------------------------------*/
  851.     /* Local Variables                                                */
  852.     /*----------------------------------------------------------------*/
  853. U8 type;
  854.     /*----------------------------------------------------------------*/
  855.     /* Code Body                                                      */
  856.     /*----------------------------------------------------------------*/
  857.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_GetOutOfCMforAdjustHistory));
  858.     /* stop background sound effect */
  859. #if defined(__MMI_BG_SOUND_EFFECT__)
  860.     mmi_bgsnd_util_stop_play_sound_end_call();
  861. #endif 
  862.     /* low battery */
  863.     if (g_charbat_context.LowBatteryTxProhibitFlag == 1)
  864.     {
  865.         SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_IDLE_DURCNT_PROHIBIT);
  866.     }
  867.     else
  868.     {
  869.         SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_IDLE_DURCNT_NORMAL);
  870.     }
  871.     if (GetCallDeflectFlag() == TRUE)
  872.     {
  873.         DeleteScreenIfPresent(ITEM_SCR_CALL_DEFLECT_DIGIT_HANDLER_ID);
  874.         SetCallDeflectFlag(FALSE);
  875.     }
  876.     /* reset redial data */
  877.     if (IsRedialSet())
  878.     {
  879.         ResetRedialAttempts();
  880.     }
  881.     SetDialedDigitCalledFlag(FALSE);
  882.     mmi_phb_call_set_dial_from_list(MMI_PHB_NONE);
  883.     CHISTSetDialFromCallLogFlag(0);
  884. /* turn off speech if needed */
  885. type = mdi_audio_speech_get_app_id();
  886.     if (type == MDI_AUDIO_SPEECH_APP_ID_GSM)
  887.     {
  888.         mdi_audio_speech_session_stop(MDI_AUDIO_SPEECH_APP_ID_GSM);
  889.     }
  890.     else if (type == MDI_AUDIO_SPEECH_APP_ID_WCDMA)
  891.     {
  892.         mdi_audio_speech_session_stop(MDI_AUDIO_SPEECH_APP_ID_WCDMA);
  893.     }
  894.     /* stop voice recording */
  895.     if (GetVoiceRecordingFlag())
  896.     {
  897.         SetKeyPadStopVoiceRecordLongPress();
  898.     }
  899.     /* unmute phone */
  900.     if (TRUE == IsPhoneInMute())
  901.     {
  902.         UnMutethePhone();
  903.     }
  904.     /* turn off loud speaker */
  905.     if (GetHFreeHeld() == TRUE)
  906.     {
  907.         SetHFreeHeld(FALSE);
  908.         DisbleHandsFree();
  909.         SetLoudSpeaker(FALSE);
  910.     }
  911. #ifdef __MMI_BT_PROFILE__
  912. #ifdef __MMI_VOIP__
  913.     /* do not turn off sco link in case voip needs to turn on again */
  914.     if (mmi_voip_app_total_call() == 0)
  915.     {
  916.         PRINT_INFORMATION(("n[GetOutOfCMforAdjustHistory] SCO Endsn"));
  917.         mmi_profiles_bt_call_end_callback();
  918.     }
  919.     else
  920.     {
  921.         PRINT_INFORMATION(("n[GetOutOfCMforAdjustHistory] SCO Not Endsn"));
  922.     }
  923. #else
  924.     /* notify bt profiles call end */
  925.     mmi_profiles_bt_call_end_callback();
  926. #endif /* __MMI_VOIP__ */
  927. #endif /* __MMI_BT_PROFILE__ */ 
  928.     /* resume audio */
  929. #ifdef __MMI_CM_BLACK_LIST__
  930. if(GetBlackIncomingFlag() == FALSE)
  931.     {
  932. #endif /* __MMI_CM_BLACK_LIST__ */ 
  933.     mdi_audio_resume_background_play();
  934. #ifdef __MMI_CM_BLACK_LIST__
  935. }
  936.     SetBlackIncomingFlag(FALSE);
  937. #endif /* __MMI_CM_BLACK_LIST__ */
  938.     /* micha0831 */
  939.     SATCallTerminate();
  940.     /* reset DTMF flag */
  941.     SetDTMFFlag(TRUE);
  942.     /* reset state and exit */
  943.     ReinitalizeCallManagement();
  944.     SetCallAbortReqSentFlag(FALSE);
  945.     if (GetAbortCallRequestedFlag() == TRUE || GetTotalCallCount() == 0)
  946.     {
  947.         DeleteAllCMSubLCDScreens();
  948.         GoBackSubLCDHistory();
  949.         SetAbortCallRequestedFlag(FALSE);
  950.     }
  951. /* Delete background sound screen */
  952. #if defined(__MMI_BG_SOUND_EFFECT__)
  953.     mmi_bgsnd_util_delete_end_call_screen();
  954. #endif
  955. /* Delete SCR_CTM_EDITOR  by Mick*/
  956. #ifdef __CTM_SUPPORT__
  957. DeleteScreenIfPresent(SCR_CTM_EDITOR);
  958. #endif /* __CTM_SUPPORT__ */ 
  959. #ifdef __MMI_VOIP__
  960.     if ((IsScreenPresent(CM_SCR_MARKER) && GetCMScrnFlag() == FALSE) || 
  961.         (GetCMScrnFlag() == TRUE && mmi_voip_app_total_call() != 0))
  962. #else
  963.     if ((IsScreenPresent(CM_SCR_MARKER)) && (GetCMScrnFlag() == FALSE))
  964. #endif
  965.     {
  966.         /* enter in-call option menu to go to other applications
  967.            delete CM screens only */
  968.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GetOutOfCMforAdjustHistory1));
  969.         if (IsScreenPresent(SCR1003_CM_ACTIVECALLOPTIONS))
  970.         {
  971.             DeleteBetweenScreen(CM_SCR_MARKER, SCR1003_CM_ACTIVECALLOPTIONS);
  972.             DeleteIncomingCallOptionScreen();
  973.         }
  974.         else
  975.         {
  976.             if (!DeleteBetweenScreen(CM_SCR_MARKER, SCR_CM_ACTIVECALLSCREEN))
  977.             {
  978.                 DeleteScreenIfPresent(CM_SCR_MARKER);
  979.             }
  980.         }
  981.         SetCMScrnFlag(TRUE);
  982.     }
  983.     else
  984.     {
  985.         /* all CM screens, delete all CM screen */
  986.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GetOutOfCMforAdjustHistory2));
  987.         DeleteNScrId(CM_SCR_MARKER);
  988.     }
  989.     /* in case of USSD will have extra marker in hostory */
  990.     DeleteScreenIfPresent(CM_SCR_MARKER);
  991.     /*
  992.      * #ifdef __MMI_CLAMCLOSE_BACK2IDLE__
  993.      * if (IsClamClose())
  994.      * ExecuteCurrKeyHandler( KEY_END, KEY_EVENT_DOWN );
  995.      * #endif
  996.      */
  997. /*
  998.  *#ifdef __MMI_USB_SUPPORT__
  999.  *    PendingUsbDetectionHdlr();
  1000.  *#endif
  1001.  */
  1002.     AlmEnableExpiryHandler();
  1003.     /* PendingAlarmReminder(); */
  1004.     if (mmi_msg_need_new_msg_ind_call_end())
  1005.     {
  1006.         mmi_msg_reset_new_msg_ind_call_end();
  1007.         /* PlayMessageArrivalTone(); */
  1008.     }
  1009. #ifdef OBIGO_SUPPORT    /* WAP_SUPPORT */
  1010.     /* Callback for WAP widget */
  1011.     widget_MMI_on_exit_CM();
  1012. #endif /* OBIGO_SUPPORT */ 
  1013.     return;
  1014. }
  1015. /*****************************************************************************
  1016.  * FUNCTION
  1017.  *  GoBackfromNotifyScr
  1018.  * DESCRIPTION
  1019.  *  This is the function which is invoked when there is a timeout
  1020.  *  or user presses the LSK of the notification screen.
  1021.  *  
  1022.  *  This is the base function for all exit of the notification screen.
  1023.  * PARAMETERS
  1024.  *  void
  1025.  * RETURNS
  1026.  *  void
  1027.  *****************************************************************************/
  1028. void GoBackfromNotifyScr(void)
  1029. {
  1030.     /*----------------------------------------------------------------*/
  1031.     /* Local Variables                                                */
  1032.     /*----------------------------------------------------------------*/
  1033.     /*----------------------------------------------------------------*/
  1034.     /* Code Body                                                      */
  1035.     /*----------------------------------------------------------------*/
  1036.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_GoBackfromNotifyScr));
  1037.     StopTimer(CM_NOTIFYDURATION_TIMER);
  1038.     SetPOPUpFlag(FALSE);
  1039.     if (GetCbackAfterSS())
  1040.     {
  1041.         ExitScrShowSSEvent();
  1042.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GoBackfromNotifyScr1));
  1043.         return;
  1044.     }
  1045.     SetNotifySSFlag(FALSE);
  1046.     AdjustSubLcd();
  1047.     if (GetTotalCallCount() == 0)
  1048.     {
  1049.         mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_ENABLED);
  1050.         if (GetHFreeHeld() == TRUE)
  1051.         {
  1052.             SetHFreeHeld(FALSE);
  1053.             DisbleHandsFree();
  1054.             SetLoudSpeaker(FALSE);
  1055.         }
  1056.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GoBackfromNotifyScr2));
  1057.         GetOutOfCMApplication();
  1058.         return;
  1059.     }
  1060.     if (GetCurrentState() == CM_OUTGOING_STATE && GetActivatedCcbsFlag() != TRUE)
  1061.     {
  1062.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GoBackfromNotifyScr3));
  1063.         if (!IsScreenPresent(SCR1001_CM_OUTGOINGCALLSCREEN))
  1064.         {
  1065.             EntryScr1001OutgoingCall();
  1066.             if (IsScreenPresent(CM_SCR_MARKER) == FALSE)
  1067.             {
  1068.                 AddMarkerToHistory();
  1069.             }
  1070.         }
  1071.         else
  1072.         {
  1073.             GoBackToHistory(SCR1001_CM_OUTGOINGCALLSCREEN);
  1074.         }
  1075.         return;
  1076.     }
  1077.     /* MT call caller picture, ringtone...will be overwrite by MO call, 
  1078.        it needs to be restored afterwards */
  1079.     if (GetCurrentState() == CM_INCOMING_STATE && GetPreviousState() == CM_OUTGOING_STATE)
  1080.     {
  1081.         CM_CALL_HANDLE handle;
  1082.         PHB_CM_INTERFACE phb_data;
  1083.         handle = GetIncomingCallHandle();
  1084.         phb_data = mmi_phb_call_get_data_for_call_mgnt(GetCallNumber(handle), FALSE);
  1085.     #ifdef __MMI_INCOMING_CALL_VIDEO__
  1086.         /* waiting call and ccbs invoke can't use video for display */
  1087.         if (GetTotalCallCount() > 0 || GetCCBSFlag() == TRUE)
  1088.         {
  1089.             phb_data.videoId = 0;
  1090.         }
  1091.     #endif /* __MMI_INCOMING_CALL_VIDEO__ */ 
  1092.         SetCMPhoneBookStruct(&phb_data);
  1093.     }
  1094.     if (GetCurrScrnId() == DTMF_SCR_DISPLAY_ID)
  1095.     {
  1096.         if (GetCurrentState() == CM_INCOMING_STATE && 1 == GetTotalCallCount())
  1097.         {
  1098.             if (GetCallWaitFlag() && !GetNoTwiceRingFlag() 
  1099.                 && mdi_audio_is_speech_mode() == FALSE && IsAttemptToAnswer() == FALSE)
  1100.             {
  1101.                 SetWait2RingCallFlag(TRUE);
  1102.                 SetNoTwiceRingFlag(TRUE);
  1103.                 ShowIncomingCallIndication();
  1104.             }
  1105.         }
  1106.         GoBackHistory();
  1107.         return;
  1108.     }
  1109.     if (GetCurrentState() == CM_INCOMING_STATE)
  1110.     {
  1111.         if ((1 == GetTotalCallCount()) && (!IsScreenPresent(ITEMSCR_INCOMING_CALL)))
  1112.         {
  1113.             DeleteUptoScrID(CM_SCR_MARKER);
  1114.         }
  1115.         if (IsScreenPresent(ITEMSCR_INCOMING_CALL))
  1116.         {
  1117.             GoBackToHistory(ITEMSCR_INCOMING_CALL);
  1118.         }
  1119.         else if (IsScreenPresent(ITEMSCR_CCBS_INVOKE))
  1120.         {
  1121.             GoBackToHistory(ITEMSCR_CCBS_INVOKE);
  1122.         }
  1123.         else
  1124.         {
  1125.             EntryScrIncomingCallEvent();
  1126.         }
  1127.         if (GetTotalCallCount() == 1 && !GetRingingFlag() && IsAttemptToAnswer() == FALSE)
  1128.         {
  1129.             ShowIncomingCallIndication();
  1130.         }
  1131.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GoBackfromNotifyScr4));
  1132.         return;
  1133.     }
  1134.     DeleteIncomingCallOptionScreen();
  1135.     DeleteNScrId(ITEM_SCR_CALL_DEFLECT_DIGIT_HANDLER_ID);
  1136.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GoBackfromNotifyScr6));
  1137.     if (GetCMScrnFlag() == FALSE || IsScreenPresent(ITEM_SCR_USSN_MSG))
  1138.     {
  1139.         /* SS present, active call present, go back to SS screen */
  1140.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GoBackfromNotifyScr7));
  1141.         GoBackHistory();
  1142.         return;
  1143.     }
  1144.     if (GetWapCallPresent())
  1145.     {
  1146.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GoBackfromNotifyScr8));
  1147.         /* waiting call will add marker to history, need to be deleted before go back */
  1148.         DeleteScreenIfPresent(CM_SCR_MARKER);
  1149.         GoBackHistory();
  1150.         return;
  1151.     }
  1152.     if (IsScreenPresent(DTMF_SCR_DISPLAY_ID))
  1153.     {
  1154.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GoBackfromNotifyScr5));
  1155.         GoBackToHistory(DTMF_SCR_DISPLAY_ID);
  1156.         return;
  1157.     }
  1158.     if (GetTotalActiveCallCount() > 0 && IsScreenPresent(ITEM_SCR_CONFIRM_DTMF_STRING))
  1159.     {
  1160.         GoBackToHistory(ITEM_SCR_CONFIRM_DTMF_STRING);
  1161.         return;
  1162.     }
  1163.     if (IsScreenPresent(SCR_CM_ACTIVECALLSCREEN))
  1164.     {
  1165.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GoBackfromNotifyScr9));
  1166.         GoBackToHistory(SCR_CM_ACTIVECALLSCREEN);
  1167.     }
  1168. #ifdef __CTM_SUPPORT__
  1169.     else if (IsScreenPresent(SCR_CTM_TALKING))
  1170.     {
  1171.         GoBackToHistory(SCR_CTM_TALKING);
  1172.     }
  1173. #endif /* __CTM_SUPPORT__ */ 
  1174.     else
  1175.     {
  1176.         if (GetExitScrnID() == SCR_CM_ACTIVECALLSCREEN
  1177.     #ifdef __CTM_SUPPORT__
  1178.             || GetExitScrnID() == SCR_CTM_TALKING
  1179.     #endif 
  1180.             )
  1181.         {
  1182.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GoBackfromNotifyScr10));
  1183.             return;
  1184.         }
  1185.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_GoBackfromNotifyScr11));
  1186.         EntryScr1002ActiveCall();
  1187.         if (!IsScreenPresent(CM_SCR_MARKER))
  1188.         {
  1189.             AddMarkerToHistory();
  1190.         }
  1191.     }
  1192. }
  1193. /*****************************************************************************
  1194.  * FUNCTION
  1195.  *  AdjustHistoryForCM
  1196.  * DESCRIPTION
  1197.  *  This is the function which is invoked when there is a timeout
  1198.  *  or user presses the LSK of the notification screen.
  1199.  *  
  1200.  *  This is the base function for all exit of the notification screen.
  1201.  * PARAMETERS
  1202.  *  void
  1203.  * RETURNS
  1204.  *  void
  1205.  *****************************************************************************/
  1206. void AdjustHistoryForCM(void)
  1207. {
  1208.     /*----------------------------------------------------------------*/
  1209.     /* Local Variables                                                */
  1210.     /*----------------------------------------------------------------*/
  1211.     /*----------------------------------------------------------------*/
  1212.     /* Code Body                                                      */
  1213.     /*----------------------------------------------------------------*/
  1214.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_FUNC_AdjustHistoryForCM));
  1215.     if (GetCbackAfterSS())
  1216.     {
  1217.         ExitScrShowSSEvent();
  1218.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_AdjustHistoryForCM1));
  1219.         return;
  1220.     }
  1221.     SetNotifySSFlag(FALSE);
  1222.     AdjustSubLcd();
  1223.     if (GetTotalCallCount() == 0)
  1224.     {
  1225.         mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_ENABLED);
  1226.         /* side effect: sound recorder in call, the loud speaker cannot be turned off */
  1227.         if (GetHFreeHeld() == TRUE)
  1228.         {
  1229.             SetHFreeHeld(FALSE);
  1230.             DisbleHandsFree();
  1231.             SetLoudSpeaker(FALSE);
  1232.         }
  1233.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_AdjustHistoryForCM2));
  1234.         GetOutOfCMforAdjustHistory();
  1235.         return;
  1236.     }
  1237.     if (GetCurrentState() == CM_OUTGOING_STATE && GetActivatedCcbsFlag() != TRUE)
  1238.     {
  1239.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_AdjustHistoryForCM3));
  1240.         DeleteUptoScrID(SCR1001_CM_OUTGOINGCALLSCREEN);
  1241.         return;
  1242.     }
  1243.     if (GetCurrentState() == CM_INCOMING_STATE)
  1244.     {
  1245.         if ((1 == GetTotalCallCount()) && (!IsScreenPresent(ITEMSCR_INCOMING_CALL)))
  1246.         {
  1247.             DeleteUptoScrID(CM_SCR_MARKER);
  1248.         }
  1249.         DeleteUptoScrID(ITEMSCR_INCOMING_CALL);
  1250.         DeleteUptoScrID(ITEMSCR_CCBS_INVOKE);
  1251.         /* MT call caller picture, ringtone...will be overwrite by MO call, 
  1252.            it needs to be restored afterwards */
  1253.         if (GetPreviousState() == CM_OUTGOING_STATE)
  1254.         {
  1255.             CM_CALL_HANDLE handle;
  1256.             PHB_CM_INTERFACE phb_data;
  1257.             handle = GetIncomingCallHandle();
  1258.             phb_data = mmi_phb_call_get_data_for_call_mgnt(GetCallNumber(handle), FALSE);
  1259.         #ifdef __MMI_INCOMING_CALL_VIDEO__
  1260.             /* waiting call and ccbs invoke can't use video for display */
  1261.             if (GetTotalCallCount() > 0 || GetCCBSFlag() == TRUE)
  1262.             {
  1263.                 phb_data.videoId = 0;
  1264.             }
  1265.         #endif /* __MMI_INCOMING_CALL_VIDEO__ */ 
  1266.             SetCMPhoneBookStruct(&phb_data);
  1267.         }
  1268.         if (1 == GetTotalCallCount())
  1269.         {
  1270.             if (GetCallWaitFlag() && !GetNoTwiceRingFlag() 
  1271.                 && mdi_audio_is_speech_mode() == FALSE && IsAttemptToAnswer() == FALSE)
  1272.             {
  1273.                 SetWait2RingCallFlag(TRUE);
  1274.                 SetNoTwiceRingFlag(TRUE);
  1275.                 ShowIncomingCallIndication();
  1276.             }
  1277.         }
  1278.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_AdjustHistoryForCM4));
  1279.         return;
  1280.     }
  1281.     if (IsScreenPresent(DTMF_SCR_DISPLAY_ID))
  1282.     {
  1283.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_AdjustHistoryForCM5));
  1284.         DeleteUptoScrID(DTMF_SCR_DISPLAY_ID);
  1285.         return;
  1286.     }
  1287.     if (GetTotalActiveCallCount() > 0 && IsScreenPresent(ITEM_SCR_CONFIRM_DTMF_STRING))
  1288.     {
  1289.         DeleteUptoScrID(ITEM_SCR_CONFIRM_DTMF_STRING);
  1290.         return;
  1291.     }
  1292.     MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_AdjustHistoryForCM6));
  1293.     if (GetCMScrnFlag() == FALSE || IsScreenPresent(ITEM_SCR_USSN_MSG))
  1294.     {
  1295.         /* SS present, active call present, go back to SS screen */
  1296.         MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_AdjustHistoryForCM7));
  1297.         return;
  1298.     }
  1299.     if (IsScreenPresent(SCR_CM_ACTIVECALLSCREEN))
  1300.     {
  1301.         DeleteUptoScrID(SCR_CM_ACTIVECALLSCREEN);
  1302.     }
  1303. #ifdef __CTM_SUPPORT__
  1304.     else if (IsScreenPresent(SCR_CTM_TALKING))
  1305.     {
  1306.         DeleteUptoScrID(SCR_CTM_TALKING);
  1307.     }
  1308. #endif /* __CTM_SUPPORT__ */ 
  1309.     else
  1310.     {
  1311.         if (GetWapCallPresent())
  1312.         {
  1313.             return;
  1314.         }
  1315.         if (GetExitScrnID() == SCR_CM_ACTIVECALLSCREEN
  1316.     #ifdef __CTM_SUPPORT__
  1317.             || GetExitScrnID() == SCR_CTM_TALKING
  1318.     #endif 
  1319.             )
  1320.         {
  1321.             MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_AdjustHistoryForCM8));
  1322.             return;
  1323.         }
  1324.     #if 1
  1325.         EntryScr1002ActiveCall();
  1326.         if (!IsScreenPresent(CM_SCR_MARKER))
  1327.         {
  1328.             AddMarkerToHistory();
  1329.         }
  1330.     #else /* 1 */ 
  1331. /* under construction !*/
  1332. /* under construction !*/
  1333. /* under construction !*/
  1334. /* under construction !*/
  1335. /* under construction !*/
  1336. /* under construction !*/
  1337. /* under construction !*/
  1338. /* under construction !*/
  1339. /* under construction !*/
  1340. /* under construction !*/
  1341. /* under construction !*/
  1342. /* under construction !*/
  1343. /* under construction !*/
  1344. /* under construction !*/
  1345. /* under construction !*/
  1346. /* under construction !*/
  1347.     #endif /* 1 */ 
  1348.     }
  1349. }
  1350. /*****************************************************************************
  1351.  * FUNCTION
  1352.  *  AdjustSubLcd
  1353.  * DESCRIPTION
  1354.  *  Adjusts sub-lcd scrn according to state
  1355.  * PARAMETERS
  1356.  *  void
  1357.  * RETURNS
  1358.  *  void
  1359.  *****************************************************************************/
  1360. void AdjustSubLcd(void)
  1361. {
  1362.     /*----------------------------------------------------------------*/
  1363.     /* Local Variables                                                */
  1364.     /*----------------------------------------------------------------*/
  1365.     /*----------------------------------------------------------------*/
  1366.     /* Code Body                                                      */
  1367.     /*----------------------------------------------------------------*/
  1368.     ExecSubLCDCurrExitHandler();
  1369.     if ((GetCurrentState() == CM_ACTIVE_STATE) || (GetCurrentState() == CM_HOLD_STATE))
  1370.     {
  1371.         ShowCategory304Screen(IMG_CM_STATE_CONNECTED, NULL);
  1372.         SetSubLCDExitHandler(ExitSubLcdScr1002ActiveCall);
  1373.         return;
  1374.     }
  1375.     if ((GetCurrentState() == CM_OUTGOING_STATE))
  1376.     {
  1377.         ShowCategory311Screen(gdispnameForSubLCD, IMG_CM_SUBLCD_CALLING, NULL);
  1378.         SetSubLCDExitHandler(ExitSubLcdScr1001OutgoingCall);
  1379.         return;
  1380.     }
  1381.     if ((GetCurrentState() == CM_INCOMING_STATE))
  1382.     {
  1383.         if (GetTotalCallCount() == 1)
  1384.         {
  1385.             DeleteSubLCDScreen(SUB_LCD_SCR_CM_ACTIVECALLSCREEN);
  1386.         }
  1387.         ShowCategory311Screen(gdispnameForSubLCD, IMG_CM_SUBLCD_CALLING, NULL);
  1388.         SetSubLCDExitHandler(ExitSubLcdScrIncomingCallEvent);
  1389.         return;
  1390.     }
  1391. }