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

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.  * Filename:
  37.  * ---------
  38.  *  History.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  *  MAUI
  43.  *
  44.  * Description:
  45.  * ------------
  46.  *  
  47.  *
  48.  * Author:
  49.  * -------
  50.  *  
  51.  *
  52.  *==============================================================================
  53.  *             HISTORY
  54.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  55.  *------------------------------------------------------------------------------
  56.  * removed!
  57.  *
  58.  * removed!
  59.  * removed!
  60.  * removed!
  61.  *
  62.  * removed!
  63.  * removed!
  64.  * removed!
  65.  *
  66.  * removed!
  67.  * removed!
  68.  * removed!
  69.  *
  70.  * removed!
  71.  * removed!
  72.  * removed!
  73.  *
  74.  * removed!
  75.  * removed!
  76.  * removed!
  77.  *
  78.  * removed!
  79.  * removed!
  80.  * removed!
  81.  *
  82.  * removed!
  83.  * removed!
  84.  * removed!
  85.  *
  86.  * removed!
  87.  * removed!
  88.  * removed!
  89.  *
  90.  * removed!
  91.  * removed!
  92.  * removed!
  93.  *
  94.  * removed!
  95.  * removed!
  96.  * removed!
  97.  *
  98.  * removed!
  99.  * removed!
  100.  * removed!
  101.  *
  102.  * removed!
  103.  * removed!
  104.  * removed!
  105.  *
  106.  * removed!
  107.  * removed!
  108.  * removed!
  109.  *
  110.  * removed!
  111.  * removed!
  112.  * removed!
  113.  *
  114.  * removed!
  115.  * removed!
  116.  * removed!
  117.  *
  118.  * removed!
  119.  * removed!
  120.  * removed!
  121.  *
  122.  * removed!
  123.  * removed!
  124.  * removed!
  125.  *
  126.  * removed!
  127.  * removed!
  128.  * removed!
  129.  *
  130.  * removed!
  131.  * removed!
  132.  * removed!
  133.  *
  134.  * removed!
  135.  * removed!
  136.  * removed!
  137.  *
  138.  * removed!
  139.  * removed!
  140.  * removed!
  141.  *
  142.  * removed!
  143.  * removed!
  144.  * removed!
  145.  *
  146.  * removed!
  147.  * removed!
  148.  * removed!
  149.  *
  150.  * removed!
  151.  * removed!
  152.  * removed!
  153.  *
  154.  * removed!
  155.  * removed!
  156.  * removed!
  157.  *
  158.  * removed!
  159.  * removed!
  160.  * removed!
  161.  *
  162.  * removed!
  163.  * removed!
  164.  * removed!
  165.  *
  166.  * removed!
  167.  * removed!
  168.  * removed!
  169.  *
  170.  * removed!
  171.  * removed!
  172.  * removed!
  173.  *
  174.  * removed!
  175.  * removed!
  176.  * removed!
  177.  *
  178.  * removed!
  179.  * removed!
  180.  * removed!
  181.  *
  182.  * removed!
  183.  * removed!
  184.  * removed!
  185.  *
  186.  * removed!
  187.  * removed!
  188.  * removed!
  189.  *
  190.  * removed!
  191.  * removed!
  192.  * removed!
  193.  *
  194.  * removed!
  195.  * removed!
  196.  * removed!
  197.  * removed!
  198.  *
  199.  * removed!
  200.  * removed!
  201.  * removed!
  202.  *
  203.  * removed!
  204.  * removed!
  205.  * removed!
  206.  *
  207.  * removed!
  208.  * removed!
  209.  * removed!
  210.  *
  211.  * removed!
  212.  * removed!
  213.  * removed!
  214.  *
  215.  * removed!
  216.  * removed!
  217.  * removed!
  218.  *
  219.  * removed!
  220.  * removed!
  221.  * removed!
  222.  *
  223.  * removed!
  224.  * removed!
  225.  * removed!
  226.  * removed!
  227.  * removed!
  228.  * removed!
  229.  * removed!
  230.  * removed!
  231.  * removed!
  232.  * removed!
  233.  * removed!
  234.  * removed!
  235.  * removed!
  236.  * removed!
  237.  * removed!
  238.  * removed!
  239.  * removed!
  240.  * removed!
  241.  * removed!
  242.  * removed!
  243.  *
  244.  * removed!
  245.  * removed!
  246.  * removed!
  247.  *
  248.  * removed!
  249.  * removed!
  250.  * removed!
  251.  *
  252.  * removed!
  253.  * removed!
  254.  * removed!
  255.  *
  256.  * removed!
  257.  * removed!
  258.  * removed!
  259.  *
  260.  * removed!
  261.  * removed!
  262.  * removed!
  263.  *
  264.  * removed!
  265.  * removed!
  266.  * removed!
  267.  *
  268.  * removed!
  269.  * removed!
  270.  * removed!
  271.  *
  272.  * removed!
  273.  * removed!
  274.  * removed!
  275.  *
  276.  * removed!
  277.  * removed!
  278.  * removed!
  279.  *
  280.  * removed!
  281.  * removed!
  282.  * removed!
  283.  *
  284.  * removed!
  285.  * removed!
  286.  * removed!
  287.  *
  288.  * removed!
  289.  * removed!
  290.  * removed!
  291.  *
  292.  * removed!
  293.  * removed!
  294.  * removed!
  295.  *
  296.  * removed!
  297.  * removed!
  298.  * removed!
  299.  *
  300.  * removed!
  301.  * removed!
  302.  * removed!
  303.  *
  304.  *------------------------------------------------------------------------------
  305.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  306.  *==============================================================================
  307.  *******************************************************************************/
  308. /**
  309.  * Copyright Notice
  310.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  311.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  312.  *  (It is illegal to remove this copyright notice from this software or any
  313.  *  portion of it)
  314.  */
  315. /**************************************************************
  316.    FILENAME : History.c
  317.    PURPOSE     : Implementation of Main LCD history stack
  318.    REMARKS     : nil
  319.    AUTHOR      : Manish
  320.    DATE     : Aug' 28, 2002
  321. **************************************************************/
  322. #include "MMI_features.h"
  323. #include "stdC.h"
  324. #include "L4Dr1.h"
  325. #include "GlobalConstants.h"
  326. #include "DebugInitDef.h"
  327. #include "PixtelDataTypes.h"
  328. #include "FrameworkStruct.h"
  329. #include "CustMenuRes.h"
  330. #include "OslMemory.h"
  331. #include "EventsGprot.h"
  332. #include "HistoryGprot.h"
  333. #include "HistoryDef.h"
  334. #include "HistoryDcl.h"
  335. #include "SubLCDHistoryGprot.h"
  336. #include "Unicodexdcl.h"
  337. #include "PixtelDataTypes.h"
  338. #include "l4dr.h"
  339. #include "MMI_trc.h"
  340. #include "gdi_include.h"        /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */
  341. #include "wgui_categories_util.h"       /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */
  342. #include "ProfilingEngine.h"
  343. typedef enum
  344. {
  345.     MMI_HIST_SMALLSCREEN_NONE,
  346.     MMI_HIST_SMALLSCREEN_ACTIVE,
  347.     MMI_HIST_SMALLSCREEN_ACTIVE_IN_EXIT_FUNC,
  348.     
  349.     /* add the enum value above here */
  350.     MMI_HIST_SMALLSCREEN_END
  351. }mmi_hist_smallscreen_state_enum;
  352. /* 
  353.  *   Extern Varibales 
  354.  */
  355. pBOOL IsBackHistory = FALSE;
  356. /* 
  357.  *   Local Variables 
  358.  */
  359. static pBOOL CheckMainLCDHistoryBack = FALSE;
  360. static historyCallback historyCBHandler[MAX_HISTORY];
  361. static historyNode historyData[MAX_HISTORY];    /* array of history data */
  362. static S16 currHistoryIndex = -1;
  363. static pBOOL bRoundOffFlag = 0;
  364. static MMI_BOOL bBackHistoryFlag = MMI_FALSE;
  365. /* static U8 is_del_cb_found = MMI_FALSE; // gilbert --- for modifying decrement() */
  366. /* 
  367.  *   Extern Function 
  368.  */
  369. /* 
  370.  *   Local Functions 
  371.  */
  372. static void ExecutePopHistory(void);
  373. static U8 SearchDelScrnIDCallbackHandler(U16 ScrnID, U16 *found_idx);
  374. static U8 ExecTopScrnCallbackHandler(void);
  375. static U8 ExecHistoryScrnCallBackHandle(U16 HistoryIndex);
  376. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  377. static S32 small_history_node = 0;
  378. /* static S32 check_for_small_history_node=0; */
  379. static mmi_hist_smallscreen_state_enum redrawing_old_screens = 0;
  380. S32 no_small_screen = 0;
  381. S32 small_screen_enabled = 0;
  382. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  383. #ifdef __MMI_UI_TAB_PANE__
  384. S32 disable_history_save = 0;
  385. #endif 
  386. /*****************************************************************************
  387.  * FUNCTION
  388.  *  mmi_free_history_buffer
  389.  * DESCRIPTION
  390.  *  Free history GUI buffer and Input buffer
  391.  *  
  392.  * PARAMETERS
  393.  *  id                [IN]        
  394.  * RETURNS
  395.  *  void
  396.  *****************************************************************************/
  397. void mmi_free_history_buffer(S16 id)
  398. {
  399.     if ((id >= 0) && (id <= currHistoryIndex))
  400.     {
  401.         if (historyData[id].guiBuffer)
  402.         {
  403.             OslMfree(historyData[id].guiBuffer);
  404.             historyData[id].guiBuffer = NULL;
  405.         }
  406.         if (historyData[id].inputBuffer)
  407.         {
  408.             if (historyData[id].mfreeFuncPtr)
  409.             {
  410.                 historyData[id].mfreeFuncPtr(historyData[id].inputBuffer);
  411.             }
  412.             else
  413.             {
  414.                 OslMfree(historyData[id].inputBuffer);
  415.             }
  416.             historyData[id].inputBuffer = NULL;
  417.         }
  418.     }
  419. }
  420. /*****************************************************************************
  421.  * FUNCTION
  422.  *  increment
  423.  * DESCRIPTION
  424.  *  increment the global currHistoryIndex
  425.  *  
  426.  *  increment the global currHistoryIndex
  427.  * PARAMETERS
  428.  *  void
  429.  * RETURNS
  430.  *  S16 - Current history index
  431.  *****************************************************************************/
  432. S16 increment()
  433. {
  434.     /*----------------------------------------------------------------*/
  435.     /* Local Variables                                                */
  436.     /*----------------------------------------------------------------*/
  437.     /*----------------------------------------------------------------*/
  438.     /* Code Body                                                      */
  439.     /*----------------------------------------------------------------*/
  440.     if (currHistoryIndex < MAX_HISTORY - 1)
  441.     {
  442.         ++currHistoryIndex;
  443.     }
  444.     else
  445.     {
  446.         currHistoryIndex = MIN_HISTORY + 1;
  447.         bRoundOffFlag = 1;
  448.     }
  449.     return currHistoryIndex;
  450. }
  451. /*****************************************************************************
  452.  * FUNCTION
  453.  *  decrement
  454.  * DESCRIPTION
  455.  *  decrement the global currHistoryIndex
  456.  *  
  457.  *  decrement the global currHistoryIndex
  458.  * PARAMETERS
  459.  *  void
  460.  * RETURNS
  461.  *  S16 - current history index
  462.  *****************************************************************************/
  463. static U8 decrement(void)
  464. {
  465.     /*----------------------------------------------------------------*/
  466.     /* Local Variables                                                */
  467.     /*----------------------------------------------------------------*/
  468.     U8 is_stop_delete = MMI_HIST_ALLOW_DELETING;  /* JL, if want to stop to run next decrement will return true. */
  469.     static U16 cb_history_idx = 0;
  470.     /*----------------------------------------------------------------*/
  471.     /* Code Body                                                      */
  472.     /*----------------------------------------------------------------*/
  473.     /* found the callback history screen */
  474. #if 0
  475. /* under construction !*/
  476. /* under construction !*/
  477. /* under construction !*/
  478. /* under construction !*/
  479. /* under construction !*/
  480. /* under construction !*/
  481. /* under construction !*/
  482. /* under construction !*/
  483. /* under construction !*/
  484. /* under construction !*/
  485. /* under construction !*/
  486. /* under construction !*/
  487. /* under construction !*/
  488. /* under construction !*/
  489. /* under construction !*/
  490. #endif /* 0 */ 
  491.     {
  492.         /* is_del_cb_found = SearchDelScrnIDCallbackHandler(historyData[currHistoryIndex].scrnID, &cb_history_idx); */
  493.         if (!bBackHistoryFlag)
  494.         {
  495.             if (SearchDelScrnIDCallbackHandler(historyData[currHistoryIndex].scrnID, &cb_history_idx))
  496.             {
  497.                 if (historyCBHandler[cb_history_idx].historydelCBPtr)
  498.                 {
  499.                     is_stop_delete = historyCBHandler[cb_history_idx].historydelCBPtr((void*)MMI_HIST_DELETE_SCREEN_TYPE);
  500.                     if (is_stop_delete == MMI_HIST_STOP_DELETING)
  501.                     {
  502.                         return MMI_HIST_STOP_DELETING;
  503.                     }
  504.                     ClearDelScrnIDCallbackHandler(historyCBHandler[cb_history_idx].scrnID, NULL);
  505.                 }
  506.             }
  507.         }
  508.     }
  509.     mmi_free_history_buffer(currHistoryIndex);
  510.     memset(&historyData[currHistoryIndex], 0, sizeof(historyNode));
  511.     if ((currHistoryIndex > MIN_HISTORY + 1) && (currHistoryIndex < MAX_HISTORY))
  512.     {
  513.         --currHistoryIndex;
  514.     }
  515.     else if ((currHistoryIndex == 1) && (bRoundOffFlag == 0))
  516.     {
  517.         currHistoryIndex = 0;
  518.     }
  519.     else if (currHistoryIndex == 0)
  520.     {
  521.         currHistoryIndex = -1;
  522.         bRoundOffFlag = 0;
  523.     }
  524.     else if (bRoundOffFlag)
  525.     {
  526.         currHistoryIndex = MAX_HISTORY - 1;
  527.         bRoundOffFlag = 0;
  528.     }
  529.     return is_stop_delete;
  530. }
  531. #ifdef OSL_MEMORY_DUMP
  532. /*****************************************************************************
  533.  * FUNCTION
  534.  *  AddHistoryReferenceMemoryRecord
  535.  * DESCRIPTION
  536.  *  adds a history along with memory record
  537.  *  
  538.  *  This is used to add a history
  539.  * PARAMETERS
  540.  *  addHistory      [IN]        
  541.  *  fileName        [IN]        
  542.  *  lineNumber      [IN]        
  543.  * RETURNS
  544.  *  void
  545.  *****************************************************************************/
  546. void AddHistoryReferenceMemoryRecord(history *addHistory, char *fileName, int lineNumber)
  547. {
  548.     /*----------------------------------------------------------------*/
  549.     /* Local Variables                                                */
  550.     /*----------------------------------------------------------------*/
  551.     S32 length = 0;
  552.     /*----------------------------------------------------------------*/
  553.     /* Code Body                                                      */
  554.     /*----------------------------------------------------------------*/
  555. #ifdef __MMI_UI_TAB_PANE__
  556.     if (disable_history_save)
  557.     {
  558.         return;
  559.     }
  560. #endif /* __MMI_UI_TAB_PANE__ */ 
  561. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  562.     if (redraw_in_small_screen_proceduer())
  563.     {
  564.         small_history_node = 0;
  565.         return;
  566.     }
  567. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  568.     /* 1. Check for OK pressed or BACK pressed */
  569.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_ADD_HISTREFMEMREC_HDLR, (IsBackHistory != MMI_TRUE)));
  570.     if (IsBackHistory != MMI_TRUE)
  571.     {
  572.         increment();
  573.         /* 3. Store History to History Data Structure */
  574.         memset(&historyData[currHistoryIndex], 0, sizeof(historyNode));
  575.         historyData[currHistoryIndex].scrnID = addHistory->scrnID;
  576.         historyData[currHistoryIndex].entryFuncPtr = addHistory->entryFuncPtr;
  577.     #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  578.         historyData[currHistoryIndex].isSmallScreen = (U16) small_history_node;
  579.     #endif 
  580.         length = pfnUnicodeStrlen((PS8) addHistory->inputBuffer);
  581.         MMI_ASSERT(length * ENCODING_LENGTH + ENCODING_LENGTH <= MAX_INPUT_BUFFER);
  582.         if (length)
  583.         {
  584.             historyData[currHistoryIndex].inputBuffer = OslMallocCHK(length * ENCODING_LENGTH + ENCODING_LENGTH, fileName, lineNumber);
  585.             pfnUnicodeStrcpy((PS8) historyData[currHistoryIndex].inputBuffer, (PS8) addHistory->inputBuffer);
  586.         }
  587.         historyData[currHistoryIndex].guiBuffer = OslMallocCHK(MAX_GUI_BUFFER, fileName, lineNumber);
  588.         memcpy(historyData[currHistoryIndex].guiBuffer, addHistory->guiBuffer, MAX_GUI_BUFFER);
  589.     }
  590. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  591.     small_history_node = 0;
  592. #endif 
  593.     IsBackHistory = MMI_FALSE;
  594. }
  595. #else /* OSL_MEMORY_DUMP */ 
  596. /*****************************************************************************
  597.  * FUNCTION
  598.  *  AddHistoryReference
  599.  * DESCRIPTION
  600.  *  adds a history
  601.  *  
  602.  *  This is used to add a history
  603.  * PARAMETERS
  604.  *  addHistory      [IN]        
  605.  * RETURNS
  606.  *  void
  607.  *****************************************************************************/
  608. void AddHistoryReference(history *addHistory)
  609. {
  610.     /*----------------------------------------------------------------*/
  611.     /* Local Variables                                                */
  612.     /*----------------------------------------------------------------*/
  613.     S32 length = 0;
  614.     /*----------------------------------------------------------------*/
  615.     /* Code Body                                                      */
  616.     /*----------------------------------------------------------------*/
  617. #ifdef __MMI_UI_TAB_PANE__
  618.     if (disable_history_save)
  619.     {
  620.         return;
  621.     }
  622. #endif /* __MMI_UI_TAB_PANE__ */ 
  623. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  624.     if (redraw_in_small_screen_proceduer())
  625.     {
  626.         small_history_node = 0;
  627.         return;
  628.     }
  629. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  630.     /* 1. Check for OK pressed or BACK pressed */
  631.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_ADD_HISTREF_HDLR, (IsBackHistory != MMI_TRUE)));
  632.     if (IsBackHistory != MMI_TRUE)
  633.     {
  634.         increment();
  635.         /* 3. Store History to History Data Structure */
  636.         memset(&historyData[currHistoryIndex], 0, sizeof(historyNode));
  637.         historyData[currHistoryIndex].scrnID = addHistory->scrnID;
  638.         historyData[currHistoryIndex].entryFuncPtr = addHistory->entryFuncPtr;
  639.     #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  640.         historyData[currHistoryIndex].isSmallScreen = (U16) small_history_node;
  641.     #endif 
  642.         length = pfnUnicodeStrlen((PS8) addHistory->inputBuffer);
  643.         MMI_ASSERT(length * ENCODING_LENGTH + ENCODING_LENGTH <= MAX_INPUT_BUFFER);
  644.         if (length)
  645.         {
  646.             historyData[currHistoryIndex].inputBuffer = OslMalloc(length * ENCODING_LENGTH + ENCODING_LENGTH);
  647.             pfnUnicodeStrcpy((PS8) historyData[currHistoryIndex].inputBuffer, (PS8) addHistory->inputBuffer);
  648.         }
  649.         historyData[currHistoryIndex].guiBuffer = OslMalloc(MAX_GUI_BUFFER);
  650.         memcpy(historyData[currHistoryIndex].guiBuffer, addHistory->guiBuffer, MAX_GUI_BUFFER);
  651.     }
  652. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  653.     small_history_node = 0;
  654. #endif 
  655.     IsBackHistory = MMI_FALSE;
  656. }
  657. #endif /* OSL_MEMORY_DUMP */ 
  658. /*****************************************************************************
  659.  * FUNCTION
  660.  *  AddNHistory_ext
  661.  * DESCRIPTION
  662.  *  adds a history with user specified size
  663.  *  
  664.  *  This is used to add a history where user specifies the size
  665.  * PARAMETERS
  666.  *  addHistory      [IN]        
  667.  *  size            [IN]        
  668.  * RETURNS
  669.  *  void
  670.  *****************************************************************************/
  671. /* MTK Leo add 0511, to reduce stack size */
  672. void AddNHistory_ext(history *addHistory, U16 size)
  673. /* MTK Leo end 0511 */
  674. {
  675.     /*----------------------------------------------------------------*/
  676.     /* Local Variables                                                */
  677.     /*----------------------------------------------------------------*/
  678.     /*----------------------------------------------------------------*/
  679.     /* Code Body                                                      */
  680.     /*----------------------------------------------------------------*/
  681. #ifdef __MMI_UI_TAB_PANE__
  682.     if (disable_history_save)
  683.     {
  684.         return;
  685.     }
  686. #endif /* __MMI_UI_TAB_PANE__ */ 
  687. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  688.     if (redraw_in_small_screen_proceduer())
  689.     {
  690.         small_history_node = 0;
  691.         return;
  692.     }
  693. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  694.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_ADD_NHIST_HDLR, size, (IsBackHistory != MMI_TRUE)));
  695.     /* 1. Check for OK pressed or BACK pressed */
  696.     if (IsBackHistory != MMI_TRUE)
  697.     {
  698.         increment();
  699.         /* 3. Store History to History Data Structure */
  700.         memset(&historyData[currHistoryIndex], 0, sizeof(historyNode));
  701.         historyData[currHistoryIndex].scrnID = addHistory->scrnID;
  702.         historyData[currHistoryIndex].entryFuncPtr = addHistory->entryFuncPtr;
  703.         /* PMT START MAUI_00157013_AND_MAUI_00157021 PATCH */
  704.     #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  705.         historyData[currHistoryIndex].isSmallScreen = (U16) small_history_node;
  706.     #endif 
  707.         MMI_ASSERT(size + ENCODING_LENGTH + 2 <= MAX_INPUT_BUFFER);
  708.         historyData[currHistoryIndex].inputBuffer = OslMalloc(size + ENCODING_LENGTH + 2);
  709.         memcpy(historyData[currHistoryIndex].inputBuffer, &size, 2);
  710.         memcpy((PS8) (historyData[currHistoryIndex].inputBuffer + 2), (PS8) addHistory->inputBuffer, (U32) size);
  711.         historyData[currHistoryIndex].guiBuffer = OslMalloc(MAX_GUI_BUFFER);
  712.         memcpy(historyData[currHistoryIndex].guiBuffer, addHistory->guiBuffer, MAX_GUI_BUFFER);
  713.     }
  714. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  715.     small_history_node = 0;
  716. #endif 
  717.     IsBackHistory = MMI_FALSE;
  718. }
  719. /*****************************************************************************
  720.  * FUNCTION
  721.  *  AddHistoryEx
  722.  * DESCRIPTION
  723.  *  adds a history with 
  724.  *  
  725.  *  The applications could assign the related function pointer
  726.  *  and let the MMI framework to get history data
  727.  * PARAMETERS
  728.  *  addHistory      [IN]        
  729.  *  size            [IN]        
  730.  * RETURNS
  731.  *  void
  732.  *****************************************************************************/
  733. MMI_BOOL AddHistoryEx(
  734.             U16 scrnID,                             /* the screen id */
  735.             FuncPtr entryFuncPtr,                   /* the screenˇs entry function */
  736.             HistoryGetData getGuiFuncPtr,           /* the function to get GUI data */
  737.             HistoryGetSize getInputBufSizeFuncPtr,  /* the function to get input buffer size */
  738.             HistoryGetData getInputBufFuncPtr,      /* the function to get input buffer */
  739.             MemAlloc mallocFuncPtr,                 /* the function to allocate memory */
  740.             MemFree mfreeFuncPtr)                  /* the function to free memory */
  741. {
  742.     /*----------------------------------------------------------------*/
  743.     /* Local Variables                                                */
  744.     /*----------------------------------------------------------------*/
  745.     S16 inputBuf_size;
  746.     /*----------------------------------------------------------------*/
  747.     /* Code Body                                                      */
  748.     /*----------------------------------------------------------------*/
  749. #ifdef __MMI_UI_TAB_PANE__
  750.     if (disable_history_save)
  751.     {
  752.         return MMI_TRUE;
  753.     }
  754. #endif /* __MMI_UI_TAB_PANE__ */ 
  755. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  756.     if (redraw_in_small_screen_proceduer())
  757.     {
  758.         small_history_node = 0;
  759.         return MMI_TRUE;
  760.     }
  761. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  762.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_ADD_HIST_EX_HDLR, (IsBackHistory != MMI_TRUE)));
  763.     /* Check for OK pressed or BACK pressed */
  764.     if (IsBackHistory != MMI_TRUE)
  765.     {
  766.         increment();
  767.         /* Store History to History Data Structure */
  768.         memset(&historyData[currHistoryIndex], 0, sizeof(historyNode));
  769.         historyData[currHistoryIndex].scrnID = scrnID;
  770.         historyData[currHistoryIndex].entryFuncPtr = entryFuncPtr;
  771.     #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  772.         historyData[currHistoryIndex].isSmallScreen = (U16) small_history_node;
  773.     #endif
  774.         MMI_ASSERT(getGuiFuncPtr);
  775.         historyData[currHistoryIndex].guiBuffer = OslMalloc(MAX_GUI_BUFFER);
  776.         getGuiFuncPtr(historyData[currHistoryIndex].guiBuffer);
  777.         historyData[currHistoryIndex].mallcFuncPtr = mallocFuncPtr;
  778.         historyData[currHistoryIndex].mfreeFuncPtr = mfreeFuncPtr;
  779.         if (getInputBufSizeFuncPtr)
  780.         {
  781.             MMI_ASSERT(getInputBufFuncPtr);
  782.             inputBuf_size = (S16)getInputBufSizeFuncPtr();
  783.             if(mallocFuncPtr)
  784.             {
  785.                 /* Check memory free function pointer is valid */
  786.                 MMI_ASSERT(mfreeFuncPtr);
  787.                 historyData[currHistoryIndex].inputBuffer = (U8*)mallocFuncPtr(inputBuf_size + ENCODING_LENGTH + 2);
  788.             }
  789.             else
  790.             {
  791.                 historyData[currHistoryIndex].inputBuffer = OslMalloc(inputBuf_size + ENCODING_LENGTH + 2);
  792.             }
  793.             memcpy(historyData[currHistoryIndex].inputBuffer, &inputBuf_size, 2);
  794.             getInputBufFuncPtr(historyData[currHistoryIndex].inputBuffer + 2);
  795.         }
  796.     }
  797. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  798.     small_history_node = 0;
  799. #endif 
  800.     IsBackHistory = MMI_FALSE;
  801.     return MMI_TRUE;
  802. }
  803. /*****************************************************************************
  804.  * FUNCTION
  805.  *  GetHistory
  806.  * DESCRIPTION
  807.  *  Used to get the history buffer for a screen id
  808.  * PARAMETERS
  809.  *  scrnID          [IN]        
  810.  *  ptrHistory      [IN]        
  811.  * RETURNS
  812.  *  U8 - Status , success or failure
  813.  *****************************************************************************/
  814. U8 GetHistory(U16 scrnID, history *ptrHistory)
  815. {
  816.     /*----------------------------------------------------------------*/
  817.     /* Local Variables                                                */
  818.     /*----------------------------------------------------------------*/
  819.     S16 count = 0;
  820.     U8 Status = ST_FAILURE;
  821.     U16 nSize;
  822.     /*----------------------------------------------------------------*/
  823.     /* Code Body                                                      */
  824.     /*----------------------------------------------------------------*/
  825.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_GET_HIST_HDLR, scrnID, currHistoryIndex));
  826.     count = currHistoryIndex;
  827.     do
  828.     {
  829.         if (scrnID == historyData[count].scrnID)
  830.         {
  831.             ptrHistory->entryFuncPtr = historyData[count].entryFuncPtr;
  832.             ptrHistory->scrnID = historyData[count].scrnID;
  833.             if (historyData[count].guiBuffer)
  834.             {
  835.                 memcpy(ptrHistory->guiBuffer, historyData[count].guiBuffer, MAX_GUI_BUFFER);
  836.             }
  837.             else
  838.             {
  839.                 memset(ptrHistory->guiBuffer, 0, MAX_GUI_BUFFER);
  840.             }
  841.             if (historyData[count].inputBuffer)
  842.                 /* 2 Bytes Are Added By UI To Keep Size Of InputBuffer Internally In AddNHistory */
  843.             {
  844.                 memcpy(&nSize, historyData[count].inputBuffer, 2);
  845.                 memcpy(
  846.                     ptrHistory->inputBuffer,
  847.                     historyData[count].inputBuffer + 2,
  848.                     (nSize > MAX_INPUT_BUFFER) ? MAX_INPUT_BUFFER : nSize);
  849.             }
  850.             else
  851.             {
  852.                 memset(ptrHistory->inputBuffer, 0, MAX_INPUT_BUFFER);
  853.             }
  854.             Status = ST_SUCCESS;
  855.             break;
  856.         }
  857.         if (count > MIN_HISTORY + 1 && count < MAX_HISTORY)
  858.         {
  859.             --count;
  860.         }
  861.         else
  862.         {
  863.             if (bRoundOffFlag)
  864.             {
  865.                 count = MAX_HISTORY - 1;
  866.             }
  867.             else
  868.             {
  869.                 break;  /* Status is by default FAILURE so no need to set again */
  870.             }
  871.         }
  872.     } while ((count != currHistoryIndex) && (historyData[count].entryFuncPtr != NULL));
  873.     return Status;
  874. }
  875. /*****************************************************************************
  876.  * FUNCTION
  877.  *  GetHistoryPointer
  878.  * DESCRIPTION
  879.  *  Used to get the reference of the history buffer for a screen id
  880.  * PARAMETERS
  881.  *  scrnID          [IN]        
  882.  *  ptrHistory      [IN]        
  883.  * RETURNS
  884.  *  U8 - Status
  885.  *****************************************************************************/
  886. U8 GetHistoryPointer(U16 scrnID, historyNode **ptrHistory)
  887. {
  888.     /*----------------------------------------------------------------*/
  889.     /* Local Variables                                                */
  890.     /*----------------------------------------------------------------*/
  891.     S16 count = 0;
  892.     U8 Status = ST_FAILURE;
  893.     /*----------------------------------------------------------------*/
  894.     /* Code Body                                                      */
  895.     /*----------------------------------------------------------------*/
  896.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_GET_HIST_SCRID_HDLR, scrnID, currHistoryIndex));
  897.     count = currHistoryIndex;
  898.     do
  899.     {
  900.         if (scrnID == historyData[count].scrnID)
  901.         {
  902.             *ptrHistory = &historyData[count];
  903.             Status = ST_SUCCESS;
  904.             break;
  905.         }
  906.         if (count > MIN_HISTORY + 1 && count < MAX_HISTORY)
  907.         {
  908.             --count;
  909.         }
  910.         else
  911.         {
  912.             if (bRoundOffFlag)
  913.             {
  914.                 count = MAX_HISTORY - 1;
  915.             }
  916.             else
  917.             {
  918.                 break;  /* Status is by default FAILURE so no need to set again */
  919.             }
  920.         }
  921.     } while ((count != currHistoryIndex) && (historyData[count].entryFuncPtr != NULL));
  922.     return Status;
  923. }
  924. /*****************************************************************************
  925.  * FUNCTION
  926.  *  GetHistoryScrID
  927.  * DESCRIPTION
  928.  *  Used to get the reference of the history buffer for a screen id
  929.  *  
  930.  *  Please change to use GetHistoryPointer,
  931.  *  rather than GetHistoryScrID
  932.  * PARAMETERS
  933.  *  scrnID          [IN]        
  934.  *  ptrHistory      [IN]        
  935.  * RETURNS
  936.  *  U8 - Status
  937.  *****************************************************************************/
  938. U8 GetHistoryScrID(U16 scrnID, historyNode **ptrHistory)
  939. {
  940.     /*----------------------------------------------------------------*/
  941.     /* Local Variables                                                */
  942.     /*----------------------------------------------------------------*/
  943.     /*----------------------------------------------------------------*/
  944.     /* Code Body                                                      */
  945.     /*----------------------------------------------------------------*/
  946.     return GetHistoryPointer(scrnID, ptrHistory);
  947. }
  948. /*****************************************************************************
  949.  * FUNCTION
  950.  *  GetNHistory
  951.  * DESCRIPTION
  952.  *  Used to get the history for a screen id, and also the history buffer size
  953.  * PARAMETERS
  954.  *  scrnID          [IN]        
  955.  *  ptrHistory      [IN]        
  956.  * RETURNS
  957.  *  U8 - Status
  958.  *****************************************************************************/
  959. U8 GetNHistory(U16 scrnID, history *ptrHistory)
  960. {
  961.     /*----------------------------------------------------------------*/
  962.     /* Local Variables                                                */
  963.     /*----------------------------------------------------------------*/
  964.     S16 count = 0;
  965.     U8 Status = ST_FAILURE;
  966.     U16 size;
  967.     /*----------------------------------------------------------------*/
  968.     /* Code Body                                                      */
  969.     /*----------------------------------------------------------------*/
  970.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_GET_NHIST_HDLR, scrnID, currHistoryIndex));
  971.     count = currHistoryIndex;
  972.     do
  973.     {
  974.         if (scrnID == historyData[count].scrnID)
  975.         {
  976.             ptrHistory->entryFuncPtr = historyData[count].entryFuncPtr;
  977.             ptrHistory->scrnID = historyData[count].scrnID;
  978.             if (historyData[count].guiBuffer)
  979.             {
  980.                 memcpy(ptrHistory->guiBuffer, historyData[count].guiBuffer, MAX_GUI_BUFFER);
  981.             }
  982.             else
  983.             {
  984.                 memset(ptrHistory->guiBuffer, 0, MAX_GUI_BUFFER);
  985.             }
  986.             if (historyData[count].inputBuffer)
  987.             {
  988.                 memcpy((PS8) & size, historyData[count].inputBuffer, 2);
  989.                 memcpy(ptrHistory->inputBuffer, (PS8) (historyData[count].inputBuffer + 2), size);
  990.             }
  991.             else
  992.             {
  993.                 memset(ptrHistory->inputBuffer, 0, MAX_INPUT_BUFFER);
  994.             }
  995.             Status = ST_SUCCESS;
  996.             break;
  997.         }
  998.         if (count > MIN_HISTORY + 1 && count < MAX_HISTORY)
  999.         {
  1000.             --count;
  1001.         }
  1002.         else
  1003.         {
  1004.             if (bRoundOffFlag)
  1005.             {
  1006.                 count = MAX_HISTORY - 1;
  1007.             }
  1008.             else
  1009.             {
  1010.                 break;  /* Status is by default FAILURE so no need to set again */
  1011.             }
  1012.         }
  1013.     } while ((count != currHistoryIndex) && (historyData[count].entryFuncPtr != NULL));
  1014.     return Status;
  1015. }
  1016. /*****************************************************************************
  1017.  * FUNCTION
  1018.  *  CheckIsBackHistory
  1019.  * DESCRIPTION
  1020.  *  Is in GoBackHistory
  1021.  *  
  1022.  *  This is typically used by entry function
  1023.  * PARAMETERS
  1024.  *  void
  1025.  * RETURNS
  1026.  *  pBOOL
  1027.  *****************************************************************************/
  1028. pBOOL CheckIsBackHistory(void)
  1029. {
  1030.     /*----------------------------------------------------------------*/
  1031.     /* Local Variables                                                */
  1032.     /*----------------------------------------------------------------*/
  1033.     /*----------------------------------------------------------------*/
  1034.     /* Code Body                                                      */
  1035.     /*----------------------------------------------------------------*/
  1036.     return IsBackHistory;
  1037. }
  1038. /*****************************************************************************
  1039.  * FUNCTION
  1040.  *  GoBackHistory
  1041.  * DESCRIPTION
  1042.  *  deletes previous screen history
  1043.  *  
  1044.  *  This is used to delete previous screen history
  1045.  * PARAMETERS
  1046.  *  void
  1047.  * RETURNS
  1048.  *  void
  1049.  *****************************************************************************/
  1050. #if defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__)
  1051. extern BOOL DirectMode;
  1052. extern void CallBackPowerOnAnimationCompleteWrapper(void);
  1053. #endif /* defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__) */ 
  1054. void GoBackHistory(void)
  1055. {
  1056.     /*----------------------------------------------------------------*/
  1057.     /* Local Variables                                                */
  1058.     /*----------------------------------------------------------------*/
  1059. #if defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__)
  1060.     BOOL Exit_From_FM = (DirectMode && currHistoryIndex == -1);
  1061. #endif 
  1062.     /*----------------------------------------------------------------*/
  1063.     /* Code Body                                                      */
  1064.     /*----------------------------------------------------------------*/
  1065. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1066.     if (redraw_in_small_screen_proceduer())
  1067.     {
  1068.         return;
  1069.     }
  1070. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1071.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_GO_BACK_HIST_HDLR));
  1072.     ExecutePopHistory();
  1073. #if defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__)
  1074.     if (Exit_From_FM)
  1075.     {
  1076.         CallBackPowerOnAnimationCompleteWrapper();
  1077.     }
  1078. #endif /* defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__) */ 
  1079. }
  1080. /*****************************************************************************
  1081.  * FUNCTION
  1082.  *  GoBackToHistory
  1083.  * DESCRIPTION
  1084.  *  Goes back to specified screen
  1085.  * PARAMETERS
  1086.  *  scrnid      [IN]        
  1087.  * RETURNS
  1088.  *  void
  1089.  *****************************************************************************/
  1090. U8 GoBackToHistory(U16 scrnid)
  1091. {
  1092.     /*----------------------------------------------------------------*/
  1093.     /* Local Variables                                                */
  1094.     /*----------------------------------------------------------------*/
  1095.     S16 count = 0;
  1096.     U8 Status = ST_FAILURE;
  1097.     /*----------------------------------------------------------------*/
  1098.     /* Code Body                                                      */
  1099.     /*----------------------------------------------------------------*/
  1100. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1101.     if (redraw_in_small_screen_proceduer())
  1102.     {
  1103.         return ST_SUCCESS;
  1104.     }
  1105. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1106.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_GO_BACK_TO_HIST_HDLR, scrnid));
  1107.     count = currHistoryIndex;
  1108.     do
  1109.     {
  1110.         if (historyData[currHistoryIndex].scrnID == scrnid)
  1111.         {
  1112.             Status = ST_SUCCESS;
  1113.             break;
  1114.         }
  1115.         /* Chack added when amit is doing testing on h/w for call management */
  1116.         if (currHistoryIndex > 0)
  1117.         {
  1118.             if (decrement() == MMI_HIST_STOP_DELETING)
  1119.             {
  1120.                 /* We abort the process here and don't handle original requirement */
  1121.                 Status = ST_SUCCESS;
  1122.                 break;
  1123.             }
  1124.         }
  1125.     } while ((count != currHistoryIndex) && (historyData[currHistoryIndex].entryFuncPtr != NULL)
  1126.              && (currHistoryIndex > 0));
  1127.     if (Status)
  1128.     {
  1129.         ExecutePopHistory();
  1130.     }
  1131.     else if (currHistoryIndex > -1)
  1132.     {
  1133.         /* To make sure the callback will run at topist screen */
  1134.         ExecTopScrnCallbackHandler();
  1135.         (*(historyData[0].entryFuncPtr)) ();
  1136.         currHistoryIndex = -1;
  1137.     }
  1138.     return Status;
  1139. }
  1140. /*****************************************************************************
  1141.  * FUNCTION
  1142.  *  GoBacknHistory
  1143.  * DESCRIPTION
  1144.  *  Goes 'n' screens back
  1145.  * PARAMETERS
  1146.  *  nHistory        [IN]        
  1147.  * RETURNS
  1148.  *  void
  1149.  *****************************************************************************/
  1150. void GoBacknHistory(U16 nHistory)
  1151. {
  1152.     /*----------------------------------------------------------------*/
  1153.     /* Local Variables                                                */
  1154.     /*----------------------------------------------------------------*/
  1155.     S16 Index = 0;
  1156.     S16 Count = 0;
  1157.     /*----------------------------------------------------------------*/
  1158.     /* Code Body                                                      */
  1159.     /*----------------------------------------------------------------*/
  1160. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1161.     if (redraw_in_small_screen_proceduer())
  1162.     {
  1163.         return;
  1164.     }
  1165. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1166.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_GO_BACK_NHIST_HDLR, nHistory));
  1167.     if (bRoundOffFlag)
  1168.     {
  1169.         Index = MAX_HISTORY + currHistoryIndex;
  1170.     }
  1171.     else
  1172.     {
  1173.         Index = currHistoryIndex;
  1174.     }
  1175.     if (Index >= nHistory)
  1176.     {
  1177.         for (Count = nHistory; Count >= 1; --Count)
  1178.         {
  1179.             /* JL, if want to stop to run next decrement will return true. */
  1180.             if (decrement() == MMI_HIST_STOP_DELETING)
  1181.             {
  1182.                 /* We abort the process here and don't handle original requirement */
  1183.                 break;
  1184.             }
  1185.         }
  1186.         ExecutePopHistory();
  1187.     }
  1188. }
  1189. /*****************************************************************************
  1190.  * FUNCTION
  1191.  *  ExecutePopHistory
  1192.  * DESCRIPTION
  1193.  *  executes current scrn & then deletes from history
  1194.  * PARAMETERS
  1195.  *  void
  1196.  * RETURNS
  1197.  *  void
  1198.  *****************************************************************************/
  1199. static void ExecutePopHistory(void)
  1200. {
  1201.     /*----------------------------------------------------------------*/
  1202.     /* Local Variables                                                */
  1203.     /*----------------------------------------------------------------*/
  1204.     /*----------------------------------------------------------------*/
  1205.     /* Code Body                                                      */
  1206.     /*----------------------------------------------------------------*/
  1207. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1208.     if (redraw_in_small_screen_proceduer())
  1209.     {
  1210.         return;
  1211.     }
  1212. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1213.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_EXE_POP_HIST_HDLR, GetActiveScreenId(), GetExitScrnID(), IsBackHistory, CheckMainLCDHistoryBack));
  1214.     IsBackHistory = MMI_TRUE;
  1215.     CheckMainLCDHistoryBack = MMI_TRUE;
  1216.     bBackHistoryFlag = MMI_TRUE;
  1217.     if (historyData[currHistoryIndex].entryFuncPtr && currHistoryIndex > 0)
  1218.     {
  1219.         U16 id;
  1220.         /* To make sure the callback will run at topist screen */
  1221.         ExecTopScrnCallbackHandler();
  1222.         //entryFuncPtr = (*(historyData[currHistoryIndex].entryFuncPtr));
  1223.         //decrement(MMI_TRUE);
  1224.         //entryFuncPtr();
  1225.         id = historyData[currHistoryIndex].scrnID;
  1226.     #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1227.         if (historyData[currHistoryIndex].isSmallScreen)
  1228.         {
  1229.             S32 i;
  1230.             S32 tmp = currHistoryIndex;
  1231.             i = currHistoryIndex - 1;
  1232.             while (historyData[i].isSmallScreen && i > 0)
  1233.             {
  1234.                 i--;
  1235.             }
  1236.             if ((currHistoryIndex == 0) || (i == 0 && historyData[i].isSmallScreen))
  1237.             {
  1238.                 clear_screen();
  1239.             }
  1240.             redrawing_old_screens = MMI_HIST_SMALLSCREEN_ACTIVE;
  1241.             MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_EXE_SMALL_SCREEN_BEGIN, currHistoryIndex, i));
  1242.             gdi_lcd_freeze(TRUE);
  1243.         #ifdef __MMI_INTERACTIVE_PROFILNG__
  1244.             mmi_frm_profiling_interactive_start();
  1245.         #endif 
  1246.             while ((i < currHistoryIndex) && (i >= 0))
  1247.             {
  1248.                 currHistoryIndex = i;
  1249.                 IsBackHistory = MMI_TRUE;
  1250.                 CheckMainLCDHistoryBack = MMI_TRUE;
  1251.                 if (historyData[i].entryFuncPtr)
  1252.                 {
  1253.                     (*(historyData[i].entryFuncPtr)) ();
  1254.                 }
  1255.                 i++;
  1256.             }
  1257.             gdi_lcd_freeze(FALSE);
  1258.             IsBackHistory = MMI_TRUE;
  1259.             CheckMainLCDHistoryBack = MMI_TRUE;
  1260.             redrawing_old_screens = MMI_HIST_SMALLSCREEN_ACTIVE_IN_EXIT_FUNC;
  1261.             currHistoryIndex = tmp;
  1262.             MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_EXE_SMALL_SCREEN_END, historyData[currHistoryIndex].scrnID, historyData[currHistoryIndex].entryFuncPtr));
  1263.             if (historyData[currHistoryIndex].entryFuncPtr)
  1264.             {
  1265.                 (*(historyData[currHistoryIndex].entryFuncPtr)) ();
  1266.             }
  1267.         #ifdef __MMI_INTERACTIVE_PROFILNG__
  1268.             mmi_frm_profiling_interactive_end();
  1269.             mmi_frm_profiling_interactive_show((U8*) L"S", MMI_FRM_PROFILING_MASK_1);
  1270.         #endif /* __MMI_INTERACTIVE_PROFILNG__ */ 
  1271.             if (id == historyData[currHistoryIndex].scrnID)
  1272.             {
  1273.                 decrement();
  1274.             }
  1275.             /*
  1276.              * We changet the small screen procedure state here.
  1277.              * When we execute the last entry function, 
  1278.              * it also executed the previous exit function.
  1279.              * We still don't want to add the history in that case.
  1280.              */
  1281.              redrawing_old_screens = MMI_HIST_SMALLSCREEN_NONE;
  1282.         }
  1283.         else
  1284.     #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1285.         {
  1286.         #ifdef __MMI_INTERACTIVE_PROFILNG__
  1287.             mmi_frm_profiling_interactive_start();
  1288.             if (historyData[currHistoryIndex].entryFuncPtr)
  1289.             {
  1290.                 (*(historyData[currHistoryIndex].entryFuncPtr)) ();
  1291.             }
  1292.             mmi_frm_profiling_interactive_end();
  1293.             mmi_frm_profiling_interactive_show((U8*) L"S", MMI_FRM_PROFILING_MASK_1);
  1294.         #else /* __MMI_INTERACTIVE_PROFILNG__ */ 
  1295.             if (historyData[currHistoryIndex].entryFuncPtr)
  1296.             {
  1297.                 (*(historyData[currHistoryIndex].entryFuncPtr)) ();
  1298.             }
  1299.         #endif /* __MMI_INTERACTIVE_PROFILNG__ */ 
  1300.             if (id == historyData[currHistoryIndex].scrnID)
  1301.             {
  1302.                 decrement();
  1303.             }
  1304.         }
  1305.     }
  1306.     else
  1307.     {
  1308.         extern void EntryIdleScreen(void);
  1309.         
  1310.         /* To make sure the callback will run at topist screen */
  1311.         ExecTopScrnCallbackHandler();
  1312.         /* Go to idle screen */
  1313.         currHistoryIndex = -1;
  1314.         if ((historyData[0].entryFuncPtr))
  1315.         {
  1316.         #ifdef __MMI_INTERACTIVE_PROFILNG__
  1317.             mmi_frm_profiling_interactive_start();
  1318.             (*(historyData[0].entryFuncPtr)) ();
  1319.             mmi_frm_profiling_interactive_end();
  1320.             mmi_frm_profiling_interactive_show((U8*) L"S", MMI_FRM_PROFILING_MASK_1);
  1321.         #else /* __MMI_INTERACTIVE_PROFILNG__ */ 
  1322.             (*(historyData[0].entryFuncPtr)) ();
  1323.         #endif /* __MMI_INTERACTIVE_PROFILNG__ */ 
  1324.         }
  1325.         if (historyData[0].entryFuncPtr != EntryIdleScreen)
  1326.         {
  1327.             /* EntryIdleScreen() will add the history in entry function */
  1328.             mmi_free_history_buffer(0);
  1329.             memset(&historyData[0], 0, sizeof(historyNode));
  1330.         }
  1331.         IsBackHistory = MMI_FALSE;
  1332.     }
  1333.     CheckMainLCDHistoryBack = MMI_FALSE;
  1334.     bBackHistoryFlag = MMI_FALSE;
  1335.     // reset delete CB flag, while go back screen.
  1336.     //is_del_cb_found = MMI_FALSE; // gilbert --- for modifying decrement()
  1337. }
  1338. /*****************************************************************************
  1339.  * FUNCTION
  1340.  *  GetCurrScrnId
  1341.  * DESCRIPTION
  1342.  *  Gets the id of the screen on the top of history stack.
  1343.  *  
  1344.  *  This is used to get current screen input buffer
  1345.  * PARAMETERS
  1346.  *  void
  1347.  * RETURNS
  1348.  *  U16 - Current Screen Id
  1349.  *****************************************************************************/
  1350. U16 GetCurrScrnId(void)
  1351. {
  1352.     /*----------------------------------------------------------------*/
  1353.     /* Local Variables                                                */
  1354.     /*----------------------------------------------------------------*/
  1355.     /*----------------------------------------------------------------*/
  1356.     /* Code Body                                                      */
  1357.     /*----------------------------------------------------------------*/
  1358.     return (historyData[currHistoryIndex].scrnID);
  1359. }
  1360. /*****************************************************************************
  1361.  * FUNCTION
  1362.  *  DeleteScreens
  1363.  * DESCRIPTION
  1364.  *  Deletes the screen IDs in the history
  1365.  *  The start screen ID and end screen ID will be deleted.
  1366.  *  If all screen IDs in the history are deleted
  1367.  *  successfully, the function returns ST_SUCCESS.
  1368.  *  If the parameters are error or someone screen
  1369.  *  ID can't be deleted successfully, the function
  1370.  *  returns ST_FAILURE.
  1371.  * PARAMETERS
  1372.  *  start_scrnid        [IN]        IN  the start screen ID (small number)
  1373.  *  end_scrnid          [IN]        IN  the end screen ID (big number)
  1374.  * RETURNS
  1375.  *  U8 - status
  1376.  *****************************************************************************/
  1377. U8 DeleteScreens(U16 start_scrnid, U16 end_scrnid)
  1378. {
  1379.     /*----------------------------------------------------------------*/
  1380.     /* Local Variables                                                */
  1381.     /*----------------------------------------------------------------*/
  1382.     S16 count = 0, del_cnt = 0, i = 0;
  1383.     U8 Status = ST_SUCCESS;
  1384.     /*----------------------------------------------------------------*/
  1385.     /* Code Body                                                      */
  1386.     /*----------------------------------------------------------------*/
  1387. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1388.     if (redraw_in_small_screen_proceduer())
  1389.     {
  1390.         return ST_SUCCESS;
  1391.     }
  1392. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1393.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_DEL_SCRS_HDLR, start_scrnid, end_scrnid));
  1394.     count = currHistoryIndex;
  1395.     if (start_scrnid > end_scrnid)
  1396.     {
  1397.         return ST_FAILURE;
  1398.     }
  1399.     while (count)
  1400.     {
  1401.         if ((start_scrnid <= historyData[count].scrnID) && (historyData[count].scrnID <= end_scrnid))
  1402.         {
  1403.             if (ExecHistoryScrnCallBackHandle(count) == MMI_HIST_STOP_DELETING)
  1404.             {
  1405.                 /*
  1406.                  * The screen won't want to delete. 
  1407.                  * We stop continue to delete the screens.
  1408.                  */
  1409.                 Status = ST_FAILURE;
  1410.                 break;
  1411.             }
  1412.             del_cnt++;
  1413.             /* Deleting the node */
  1414.             mmi_free_history_buffer(count);
  1415.             /* Shifting All the nodes by one notch */
  1416.             for (i = 0; i <= (currHistoryIndex - count); i++)
  1417.             {
  1418.                 memcpy(&historyData[count + i], &historyData[count + i + 1], sizeof(historyNode));
  1419.             }
  1420.         }
  1421.         count--;
  1422.     }
  1423.     currHistoryIndex -= del_cnt;
  1424.     MMI_ASSERT(currHistoryIndex>=0);
  1425.     memset(&historyData[currHistoryIndex + 1], 0, sizeof(historyNode));
  1426.     return Status;
  1427. }
  1428. /*****************************************************************************
  1429.  * FUNCTION
  1430.  *  DeleteBeyondScrTillScr
  1431.  * DESCRIPTION
  1432.  *  To delete scrns beyond scrn A
  1433.  *  till scrn B
  1434.  * PARAMETERS
  1435.  *  beyondScrnid        [IN]        
  1436.  *  tillScrnid          [IN]        
  1437.  * RETURNS
  1438.  *  U8 - status
  1439.  *****************************************************************************/
  1440. U8 DeleteBeyondScrTillScr(U16 beyondScrnid, U16 tillScrnid)
  1441. {
  1442.     /*----------------------------------------------------------------*/
  1443.     /* Local Variables                                                */
  1444.     /*----------------------------------------------------------------*/
  1445.     U8 Status = ST_SUCCESS;
  1446.     U16 count = 0, count1 = 0;
  1447.     S16 endScreenPresent = -1, startScreenPresent = -1;
  1448.     U16 screensDeleted = 0;
  1449.     /*----------------------------------------------------------------*/
  1450.     /* Code Body                                                      */
  1451.     /*----------------------------------------------------------------*/
  1452. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1453.     if (redraw_in_small_screen_proceduer())
  1454.     {
  1455.         return ST_SUCCESS;
  1456.     }
  1457. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1458.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_DEL_BEYOND_SCR_TILL_SCR_HDLR, beyondScrnid, tillScrnid));
  1459.     if (currHistoryIndex > 0)
  1460.     {
  1461.         count = currHistoryIndex;
  1462.         count1 = currHistoryIndex;
  1463.     }
  1464.     while (count)
  1465.     {
  1466.         if (historyData[count].scrnID == beyondScrnid)
  1467.         {
  1468.             startScreenPresent = count;
  1469.             break;
  1470.         }
  1471.         --count;
  1472.     }
  1473.     if (startScreenPresent > 0)
  1474.     {
  1475.         --count;
  1476.         /* if tillscrn is at index 0 */
  1477.         while (count || ((count == 0) && (historyData[0].scrnID == tillScrnid)))
  1478.         {
  1479.             if (historyData[count].scrnID == tillScrnid)
  1480.             {
  1481.                 endScreenPresent = count;
  1482.                 break;
  1483.             }
  1484.             --count;
  1485.         }
  1486.     }
  1487.     else
  1488.     {
  1489.         return ST_FAILURE;
  1490.     }
  1491.     MMI_ASSERT((startScreenPresent != -1) && (endScreenPresent != -1));
  1492.     for (count = startScreenPresent - 1; count >= endScreenPresent; count--)
  1493.     {
  1494.         if (ExecHistoryScrnCallBackHandle(count) == MMI_HIST_STOP_DELETING)
  1495.         {
  1496.             /*
  1497.              * The screen won't want to delete. 
  1498.              * We stop continue to delete the screens.
  1499.              */
  1500.             endScreenPresent = count + 1;
  1501.             Status = ST_FAILURE;
  1502.             break;
  1503.         }
  1504.         mmi_free_history_buffer(count);
  1505.         memset(&historyData[count], 0, sizeof(historyNode));
  1506.         currHistoryIndex--;
  1507.         screensDeleted++;
  1508.         if (count == 0)
  1509.         {
  1510.             /* count is U16 not S16 */
  1511.             break;
  1512.         }
  1513.     }
  1514.     memcpy(
  1515.         historyData + endScreenPresent,
  1516.         historyData + startScreenPresent,
  1517.         sizeof(historyNode) * (count1 - startScreenPresent + 1));
  1518.     memset(historyData + (currHistoryIndex + 1), 0, (sizeof(historyNode) * screensDeleted));
  1519.     return Status;
  1520. }
  1521. /*****************************************************************************
  1522.  * FUNCTION
  1523.  *  DeleteBetweenScreen
  1524.  * DESCRIPTION
  1525.  *  Deletes Between two Screens including the boundaries
  1526.  * PARAMETERS
  1527.  *  StartScrId      [IN]        
  1528.  *  EndScrId        [IN]        
  1529.  * RETURNS
  1530.  *  U16 - status
  1531.  *****************************************************************************/
  1532. U16 DeleteBetweenScreen(U16 StartScrId, U16 EndScrId)
  1533. {
  1534.     /*----------------------------------------------------------------*/
  1535.     /* Local Variables                                                */
  1536.     /*----------------------------------------------------------------*/
  1537.     U8 Status = ST_SUCCESS;
  1538.     U16 count = 0, count1 = 0;
  1539.     S16 endScreenPresent = -1, startScreenPresent = -1;
  1540.     U16 screensDeleted = 0;
  1541.     /*----------------------------------------------------------------*/
  1542.     /* Code Body                                                      */
  1543.     /*----------------------------------------------------------------*/
  1544. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1545.     if (redraw_in_small_screen_proceduer())
  1546.     {
  1547.         return ST_SUCCESS;
  1548.     }
  1549. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1550.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_DEL_BETWEEN_SCR_HDLR, StartScrId, EndScrId));
  1551.     if (currHistoryIndex > 0)
  1552.     {
  1553.         count = currHistoryIndex;
  1554.         count1 = currHistoryIndex;
  1555.     }
  1556.     while (count)
  1557.     {
  1558.         if (historyData[count].scrnID == EndScrId)
  1559.         {
  1560.             startScreenPresent = count;
  1561.             break;
  1562.         }
  1563.         --count;
  1564.     }
  1565.     if (startScreenPresent >= 0)
  1566.     {
  1567.         while (count)
  1568.         {
  1569.             if (historyData[count].scrnID == StartScrId)
  1570.             {
  1571.                 endScreenPresent = count;
  1572.                 break;
  1573.             }
  1574.             --count;
  1575.         }
  1576.     }
  1577.     else
  1578.     {
  1579.         return ST_FAILURE;
  1580.     }
  1581.     MMI_ASSERT((startScreenPresent != -1) && (endScreenPresent != -1));
  1582.     for (count = startScreenPresent; count >= endScreenPresent; count--)
  1583.     {
  1584.         if (ExecHistoryScrnCallBackHandle(count) == MMI_HIST_STOP_DELETING)
  1585.         {
  1586.             /*
  1587.              * The screen won't want to delete. 
  1588.              * We stop continue to delete the screens.
  1589.              */
  1590.             endScreenPresent = count + 1;
  1591.             Status = ST_FAILURE;
  1592.             break;
  1593.         }
  1594.         mmi_free_history_buffer(count);
  1595.         currHistoryIndex--;
  1596.         screensDeleted++;
  1597.         if (count == 0)
  1598.         {
  1599.             /* count is U16 not S16 */
  1600.             break;
  1601.         }
  1602.     }
  1603.     memcpy(
  1604.         historyData + endScreenPresent,
  1605.         historyData + startScreenPresent + 1,
  1606.         sizeof(historyNode) * (count1 - startScreenPresent + 1));
  1607.     memset(historyData + (currHistoryIndex + 1), 0, (sizeof(historyNode) * screensDeleted));
  1608.     return ST_SUCCESS;
  1609. }
  1610. /*****************************************************************************
  1611.  * FUNCTION
  1612.  *  DeleteScreenIfPresent
  1613.  * DESCRIPTION
  1614.  *  Deletes Screen from History
  1615.  * PARAMETERS
  1616.  *  ScrId       [IN]        
  1617.  * RETURNS
  1618.  *  U16 - status
  1619.  *****************************************************************************/
  1620. U16 DeleteScreenIfPresent(U16 ScrId)
  1621. {
  1622.     /*----------------------------------------------------------------*/
  1623.     /* Local Variables                                                */
  1624.     /*----------------------------------------------------------------*/
  1625.     U16 count, i;
  1626.     /*----------------------------------------------------------------*/
  1627.     /* Code Body                                                      */
  1628.     /*----------------------------------------------------------------*/
  1629. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1630.     if (redraw_in_small_screen_proceduer())
  1631.     {
  1632.         return ST_SUCCESS;
  1633.     }
  1634. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1635.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_DEL_SCR_IF_PRESENT_HDLR, ScrId));
  1636.     if (!IsScreenPresent(ScrId))
  1637.     {
  1638.         return ST_FAILURE;
  1639.     }
  1640.     count = currHistoryIndex;
  1641.     /* Locating the screen */
  1642.     while (count)
  1643.     {
  1644.         if (historyData[count].scrnID == ScrId)
  1645.         {
  1646.             break;
  1647.         }
  1648.         --count;
  1649.     }
  1650.     /*
  1651.      * Not support for stop callback at this funciton 
  1652.      * Because the application want to delete the special screen in the history,
  1653.      * we don't need to check the return value of the delete callback function.
  1654.      */
  1655.     ExecHistoryScrnCallBackHandle(count);
  1656.     /* Deleting the node */
  1657.     mmi_free_history_buffer(count);
  1658.     /* Shifting All the nodes by one notch */
  1659.     for (i = count + 1; i <= currHistoryIndex; i++, count++)
  1660.     {
  1661.         memcpy(&historyData[count], &historyData[i], sizeof(historyNode));
  1662.     }
  1663.     --currHistoryIndex;
  1664.     memset(&historyData[currHistoryIndex + 1], 0, sizeof(historyNode));
  1665.     return ST_SUCCESS;
  1666. }
  1667. /*****************************************************************************
  1668.  * FUNCTION
  1669.  *  DeleteScreenFromToNnodes
  1670.  * DESCRIPTION
  1671.  *  Deletes N nodes from  History starting from a particular screen
  1672.  * PARAMETERS
  1673.  *  ScrId           [IN]        
  1674.  *  num_nodes       [IN]        
  1675.  * RETURNS
  1676.  *  U16 - status
  1677.  *****************************************************************************/
  1678. U16 DeleteScreenFromToNnodes(U16 ScrId, U16 num_nodes)
  1679. {
  1680.     /*----------------------------------------------------------------*/
  1681.     /* Local Variables                                                */
  1682.     /*----------------------------------------------------------------*/
  1683.     U16 count, i;
  1684.     U16 temp = 0;
  1685.     U16 k = 0;
  1686.     /*----------------------------------------------------------------*/
  1687.     /* Code Body                                                      */
  1688.     /*----------------------------------------------------------------*/
  1689. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1690.     if (redraw_in_small_screen_proceduer())
  1691.     {
  1692.         return ST_SUCCESS;
  1693.     }
  1694. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1695.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_DEL_SCR_FROM_TO_N_NODE_HDLR, ScrId, num_nodes));
  1696.     if (!IsScreenPresent(ScrId))
  1697.     {
  1698.         return ST_FAILURE;
  1699.     }
  1700.     count = currHistoryIndex;
  1701.     /* Locating the screen */
  1702.     while (count)
  1703.     {
  1704.         if (historyData[count].scrnID == ScrId)
  1705.         {
  1706.             break;
  1707.         }
  1708.         --count;
  1709.     }
  1710.     for (temp = 0; temp < num_nodes; temp++)
  1711.     {
  1712.         /* Not support for stop callback at this funciton */
  1713.         if (ExecHistoryScrnCallBackHandle(count) == MMI_HIST_STOP_DELETING)
  1714.         {
  1715.             /*
  1716.              * The screen won't want to delete. 
  1717.              * We stop continue to delete the screens.
  1718.              */
  1719.             return ST_FAILURE;
  1720.         }
  1721.         /* Deleting the node */
  1722.         mmi_free_history_buffer(count);
  1723.         /* Shifting All the nodes by one notch */
  1724.         k = count;
  1725.         for (i = k + 1; i <= currHistoryIndex; i++, k++)
  1726.         {
  1727.             memcpy(&historyData[k], &historyData[i], sizeof(historyNode));
  1728.         }
  1729.         currHistoryIndex--;
  1730.         memset(&historyData[currHistoryIndex + 1], 0, sizeof(historyNode));
  1731.         count--;
  1732.         if ((count == 0) && ((temp + 1) < num_nodes))
  1733.         {
  1734.             return ST_FAILURE;
  1735.         }
  1736.     }
  1737.     return ST_SUCCESS;
  1738. }
  1739. /*****************************************************************************
  1740.  * FUNCTION
  1741.  *  DeleteFromScrUptoScr
  1742.  * DESCRIPTION
  1743.  *  Deletes screen from start scrnid to before end scrnid
  1744.  *  (include start scrnid but not include end scrnid)
  1745.  * PARAMETERS
  1746.  *  start_scrnid        [IN]        
  1747.  *  upto_scrnid         [IN]        
  1748.  * RETURNS
  1749.  *  U16 - status
  1750.  *****************************************************************************/
  1751. U8 DeleteFromScrUptoScr(U16 start_scrnid, U16 upto_scrnid)
  1752. {
  1753.     /*----------------------------------------------------------------*/
  1754.     /* Local Variables                                                */
  1755.     /*----------------------------------------------------------------*/
  1756.     U8 Status = ST_SUCCESS;
  1757.     S16 count = 0, count1 = 0;
  1758.     S16 endScreenPresent = -1, startScreenPresent = -1;
  1759.     U16 screensDeleted = 0;
  1760.     /*----------------------------------------------------------------*/
  1761.     /* Code Body                                                      */
  1762.     /*----------------------------------------------------------------*/
  1763. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1764.     if (redraw_in_small_screen_proceduer())
  1765.     {
  1766.         return ST_SUCCESS;
  1767.     }
  1768. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1769.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_DEL_FROM_SCR_UPTO_SCR_HDLR, start_scrnid, upto_scrnid));
  1770.     if (currHistoryIndex > 0)
  1771.     {
  1772.         count = currHistoryIndex;
  1773.         count1 = currHistoryIndex;
  1774.     }
  1775.     while (count)
  1776.     {
  1777.         if (historyData[count].scrnID == start_scrnid)
  1778.         {
  1779.             startScreenPresent = count;
  1780.             break;
  1781.         }
  1782.         --count;
  1783.     }
  1784.     if (startScreenPresent > 0)
  1785.     {
  1786.         --count;
  1787.         /* if tillscrn is at index 0 */
  1788.         while (count || ((count == 0) && (historyData[0].scrnID == upto_scrnid)))
  1789.         {
  1790.             if (historyData[count].scrnID == upto_scrnid)
  1791.             {
  1792.                 endScreenPresent = count;
  1793.                 break;
  1794.             }
  1795.             --count;
  1796.         }
  1797.     }
  1798.     else
  1799.     {
  1800.         return ST_FAILURE;
  1801.     }
  1802.     MMI_ASSERT((startScreenPresent != -1) && (endScreenPresent != -1));
  1803.     for (count = startScreenPresent; count > endScreenPresent; count--)
  1804.     {
  1805.         if (ExecHistoryScrnCallBackHandle(count) == MMI_HIST_STOP_DELETING)
  1806.         {
  1807.             /*
  1808.              * The screen won't want to delete. 
  1809.              * We stop continue to delete the screens.
  1810.              */
  1811.             endScreenPresent = count + 1;
  1812.             Status = ST_FAILURE;
  1813.             break;
  1814.         }
  1815.         mmi_free_history_buffer(count);
  1816.         memset(&historyData[count], 0, sizeof(historyNode));
  1817.         currHistoryIndex--;
  1818.         screensDeleted++;
  1819.     }
  1820.     memcpy(
  1821.         historyData + endScreenPresent + 1,
  1822.         historyData + startScreenPresent + 1,
  1823.         sizeof(historyNode) * (count1 - startScreenPresent));
  1824.     memset(historyData + (currHistoryIndex + 1), 0, (sizeof(historyNode) * screensDeleted));
  1825.     return Status;
  1826. }
  1827. /*****************************************************************************
  1828.  * FUNCTION
  1829.  *  InsertHistoryBeforeThisScrnReference
  1830.  * DESCRIPTION
  1831.  *  Insert new screen into history before this screen
  1832.  * PARAMETERS
  1833.  *  scrnId          [IN]        
  1834.  *  addHistory      [IN]         
  1835.  * RETURNS
  1836.  *  void
  1837.  *****************************************************************************/
  1838. void InsertHistoryBeforeThisScrnReference(U16 scrnId, history *addHistory)
  1839. {
  1840.     /*----------------------------------------------------------------*/
  1841.     /* Local Variables                                                */
  1842.     /*----------------------------------------------------------------*/
  1843.     U16 count = 0;
  1844.     U16 i = 0;
  1845.     S32 len = 0;
  1846.     /*----------------------------------------------------------------*/
  1847.     /* Code Body                                                      */
  1848.     /*----------------------------------------------------------------*/
  1849.     /* find this screen in history */
  1850.     if (!IsScreenPresent(scrnId))
  1851.     {
  1852.         return;
  1853.     }
  1854.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_INSERT_HIST_BEFORE_SCREEN_HDLR, scrnId));
  1855.     count = currHistoryIndex;
  1856.     /* Locating the screen */
  1857.     while (count)
  1858.     {
  1859.         if (historyData[count].scrnID == scrnId)
  1860.         {
  1861.             break;
  1862.         }
  1863.         --count;
  1864.     }
  1865.     increment();
  1866.     /* Shifting All the nodes by one notch */
  1867.     for (i = currHistoryIndex; i != count; i--)
  1868.     {
  1869.         memcpy(&historyData[i], &historyData[i - 1], sizeof(historyNode));
  1870.     }
  1871.     /* insert new screen in hostory   */
  1872.     memset(&historyData[count], 0, sizeof(historyNode));
  1873.     historyData[count].scrnID = addHistory->scrnID;
  1874.     historyData[count].entryFuncPtr = addHistory->entryFuncPtr;
  1875.     len = pfnUnicodeStrlen((PS8) addHistory->inputBuffer);
  1876.     if (len)
  1877.     {
  1878.         historyData[count].inputBuffer = OslMalloc(len * ENCODING_LENGTH + ENCODING_LENGTH);
  1879.         pfnUnicodeStrcpy((PS8) historyData[count].inputBuffer, (PS8) addHistory->inputBuffer);
  1880.     }
  1881.     historyData[count].guiBuffer = OslMalloc(MAX_GUI_BUFFER);
  1882.     memcpy(historyData[count].guiBuffer, addHistory->guiBuffer, MAX_GUI_BUFFER);
  1883.     /* return success */
  1884.     return;
  1885. }
  1886. /*****************************************************************************
  1887.  * FUNCTION
  1888.  *  GetScreenCountInHistory
  1889.  * DESCRIPTION
  1890.  *  Get the screen numbers in the history
  1891.  * PARAMETERS
  1892.  *  void
  1893.  * RETURNS
  1894.  *  S16 - screen count
  1895.  *****************************************************************************/
  1896. S16 GetScreenCountInHistory(void)
  1897. {
  1898.     /*----------------------------------------------------------------*/
  1899.     /* Local Variables                                                */
  1900.     /*----------------------------------------------------------------*/
  1901.     /*----------------------------------------------------------------*/
  1902.     /* Code Body                                                      */
  1903.     /*----------------------------------------------------------------*/
  1904.     return (currHistoryIndex + 1);
  1905. }
  1906. /*****************************************************************************
  1907.  * FUNCTION
  1908.  *  GetCurrInputBuffer
  1909.  * DESCRIPTION
  1910.  *  gets current screen input buffer
  1911.  *  
  1912.  *  This is used to get current screen input buffer
  1913.  * PARAMETERS
  1914.  *  scrnid      [IN]        
  1915.  * RETURNS
  1916.  *  U8* - history buffer
  1917.  *****************************************************************************/
  1918. U8 *GetCurrInputBuffer(U16 scrnid)
  1919. {
  1920.     /*----------------------------------------------------------------*/
  1921.     /* Local Variables                                                */
  1922.     /*----------------------------------------------------------------*/
  1923.     S16 count = 0;
  1924.     /*----------------------------------------------------------------*/
  1925.     /* Code Body                                                      */
  1926.     /*----------------------------------------------------------------*/
  1927.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_GET_CUR_INPUT_BUF_HDLR, scrnid));
  1928.     count = currHistoryIndex;
  1929.     if (historyData[currHistoryIndex].scrnID == scrnid)
  1930.     {
  1931.         return (historyData[count].inputBuffer);
  1932.     }
  1933.     else
  1934.     {
  1935.         return NULL;
  1936.     }
  1937. }
  1938. /*****************************************************************************
  1939.  * FUNCTION
  1940.  *  GetCurrNInputBuffer
  1941.  * DESCRIPTION
  1942.  *  Retrieve the input current screen input buffer
  1943.  *  
  1944.  *  Buffer can contain several null terminated
  1945.  *  strings , so along with pointer size is also
  1946.  *  returned
  1947.  * PARAMETERS
  1948.  *  scrnid      [IN]        
  1949.  *  size        [IN]        
  1950.  * RETURNS
  1951.  *  U8*
  1952.  *****************************************************************************/
  1953. U8 *GetCurrNInputBuffer(U16 scrnid, U16 *size)
  1954. {
  1955.     /*----------------------------------------------------------------*/
  1956.     /* Local Variables                                                */
  1957.     /*----------------------------------------------------------------*/
  1958.     S16 count = currHistoryIndex;
  1959.     /*----------------------------------------------------------------*/
  1960.     /* Code Body                                                      */
  1961.     /*----------------------------------------------------------------*/
  1962.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_GET_CUR_NINPUT_BUF_HDLR, scrnid));
  1963.     if (historyData[currHistoryIndex].scrnID == scrnid)
  1964.     {
  1965.         memcpy(size, historyData[count].inputBuffer, 2);
  1966.         return ((historyData[count].inputBuffer) + 2);
  1967.     }
  1968.     else
  1969.     {
  1970.         return NULL;
  1971.     }
  1972. }
  1973. /*****************************************************************************
  1974.  * FUNCTION
  1975.  *  GetCurrGuiBuffer
  1976.  * DESCRIPTION
  1977.  *  gets current screen gui buffer
  1978.  *  
  1979.  *  This is used to get current screen gui buffer
  1980.  * PARAMETERS
  1981.  *  scrnid      [IN]        
  1982.  * RETURNS
  1983.  *  U8*
  1984.  *****************************************************************************/
  1985. U8 *GetCurrGuiBuffer(U16 scrnid)
  1986. {
  1987.     /*----------------------------------------------------------------*/
  1988.     /* Local Variables                                                */
  1989.     /*----------------------------------------------------------------*/
  1990.     S16 count = 0;
  1991.     /*----------------------------------------------------------------*/
  1992.     /* Code Body                                                      */
  1993.     /*----------------------------------------------------------------*/
  1994.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_GET_CUR_GUI_BUF_HDLR, scrnid, currHistoryIndex));
  1995.     count = currHistoryIndex;
  1996.     if (historyData[count].scrnID == scrnid)
  1997.     {
  1998.         return (historyData[count].guiBuffer);
  1999.     }
  2000.     else
  2001.     {
  2002.         return NULL;
  2003.     }
  2004. }
  2005. /*****************************************************************************
  2006.  * FUNCTION
  2007.  *  InitHistory
  2008.  * DESCRIPTION
  2009.  *  Initialize the history data structure
  2010.  *  
  2011.  *  Initialize the history data structure
  2012.  * PARAMETERS
  2013.  *  main_root_ptr       [IN]        
  2014.  *  sub_root_ptr        [IN]        
  2015.  * RETURNS
  2016.  *  void
  2017.  *****************************************************************************/
  2018. void InitHistory(MainLcdHistoryCBPtr main_root_ptr, SubLcdHistoryCBPtr sub_root_ptr)
  2019. {
  2020.     /*----------------------------------------------------------------*/
  2021.     /* Local Variables                                                */
  2022.     /*----------------------------------------------------------------*/
  2023.     /* U16 count =0; */
  2024.     /*----------------------------------------------------------------*/
  2025.     /* Code Body                                                      */
  2026.     /*----------------------------------------------------------------*/
  2027. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  2028.     if (redraw_in_small_screen_proceduer())
  2029.     {
  2030.         return;
  2031.     }
  2032. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  2033.     memset(historyData, 0, sizeof(historyNode) * MAX_HISTORY);
  2034.     /* MTK added by JL for history callback */
  2035.     memset(historyCBHandler, 0, sizeof(historyCallback) * MAX_HISTORY);
  2036.     InitSubLCDHistory(sub_root_ptr);
  2037. }
  2038. /*****************************************************************************
  2039.  * FUNCTION
  2040.  *  HistoryDump
  2041.  * DESCRIPTION
  2042.  *  Dumps the history to file or debug window
  2043.  *  
  2044.  *  HistoryDump will be used for dbugging purposes
  2045.  * PARAMETERS
  2046.  *  void
  2047.  * RETURNS
  2048.  *  void
  2049.  *****************************************************************************/
  2050. void HistoryDump(void)
  2051. {
  2052.     /*----------------------------------------------------------------*/
  2053.     /* Local Variables                                                */
  2054.     /*----------------------------------------------------------------*/
  2055.     S16 count = 0;
  2056.     /*----------------------------------------------------------------*/
  2057.     /* Code Body                                                      */
  2058.     /*----------------------------------------------------------------*/
  2059.     count = currHistoryIndex;
  2060.     do
  2061.     {
  2062.         MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_DUMP_HDLR, count, historyData[count].scrnID));
  2063.         if (count > MIN_HISTORY && count < MAX_HISTORY)
  2064.         {
  2065.             --count;
  2066.         }
  2067.         else
  2068.         {
  2069.             if (bRoundOffFlag)
  2070.             {
  2071.                 count = MAX_HISTORY - 1;
  2072.             }
  2073.             else
  2074.             {
  2075.                 break;
  2076.             }
  2077.         }
  2078.     } while ((count != currHistoryIndex) && (historyData[count].entryFuncPtr != NULL));
  2079.     SubLCDHistoryDump();
  2080. }
  2081. /*****************************************************************************
  2082.  * FUNCTION
  2083.  *  HistoryReplace
  2084.  * DESCRIPTION
  2085.  *  To replace a specific history
  2086.  *  
  2087.  *  HistoryReplace will be used for a exist history
  2088.  * PARAMETERS
  2089.  *  out_scrn_id     [IN]        
  2090.  *  in_scrn_id      [IN]        
  2091.  *  in_src_func     [IN]        
  2092.  * RETURNS
  2093.  *  pBool
  2094.  *****************************************************************************/
  2095. pBOOL HistoryReplace(U16 out_scrn_id, U16 in_scrn_id, FuncPtr in_src_func)
  2096. {
  2097.     /*----------------------------------------------------------------*/
  2098.     /* Local Variables                                                */
  2099.     /*----------------------------------------------------------------*/
  2100.     S16 count = 0;
  2101.     /*----------------------------------------------------------------*/
  2102.     /* Code Body                                                      */
  2103.     /*----------------------------------------------------------------*/
  2104.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_HIST_REPLACE_HDLR, out_scrn_id, in_scrn_id));
  2105.     for (count = 0; ((count < MAX_HISTORY) && ((count <= currHistoryIndex) && (currHistoryIndex != -1))); count++)
  2106.     {
  2107.         /* Find the matched source history and then to write into destinate history */
  2108.         if (historyData[count].scrnID == out_scrn_id)
  2109.         {
  2110.             ClearDelScrnIDCallbackHandler(out_scrn_id, NULL);
  2111.             historyData[count].scrnID = in_scrn_id;
  2112.             historyData[count].entryFuncPtr = in_src_func;
  2113.             mmi_free_history_buffer(count);
  2114.             return MMI_TRUE;
  2115.         }
  2116.     }
  2117.     return MMI_FALSE;
  2118. }
  2119. /*****************************************************************************
  2120.  * FUNCTION
  2121.  *  ExecutecurrHisIndEntryFunc
  2122.  * DESCRIPTION
  2123.  *  executes current history handles  Entry function
  2124.  *  
  2125.  *  This is used to executes current history handles  Entry function.
  2126.  * PARAMETERS
  2127.  *  void
  2128.  * RETURNS
  2129.  *  void
  2130.  *****************************************************************************/
  2131. void ExecutecurrHisIndEntryFunc(void)
  2132. {
  2133.     /*----------------------------------------------------------------*/
  2134.     /* Local Variables                                                */
  2135.     /*----------------------------------------------------------------*/
  2136.     /*----------------------------------------------------------------*/
  2137.     /* Code Body                                                      */
  2138.     /*----------------------------------------------------------------*/
  2139.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EXEC_CURR_HIST_HDLR));
  2140.     if (historyData[currHistoryIndex].entryFuncPtr)
  2141.     {
  2142.         (*(historyData[currHistoryIndex].entryFuncPtr)) ();
  2143.     }
  2144. }
  2145. /*****************************************************************************
  2146.  * FUNCTION
  2147.  *  DeleteNHistory
  2148.  * DESCRIPTION
  2149.  *  Deletes 'n' history nodes from current history index
  2150.  *  
  2151.  *  This shall pop 'n' history nodes without invoking
  2152.  *  entry functions of the deleted nodes
  2153.  * PARAMETERS
  2154.  *  DeleteCount     [IN]        
  2155.  * RETURNS
  2156.  *  void
  2157.  *****************************************************************************/
  2158. void DeleteNHistory(U16 DeleteCount)
  2159. {
  2160.     /*----------------------------------------------------------------*/
  2161.     /* Local Variables                                                */
  2162.     /*----------------------------------------------------------------*/
  2163.     S16 Index = 0;
  2164.     S16 Count = 0;
  2165.     /*----------------------------------------------------------------*/
  2166.     /* Code Body                                                      */
  2167.     /*----------------------------------------------------------------*/
  2168. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  2169.     if (redraw_in_small_screen_proceduer())
  2170.     {
  2171.         return ;
  2172.     }
  2173. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  2174.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_DEL_NHIST_HDLR, DeleteCount));
  2175.     if (bRoundOffFlag)
  2176.     {
  2177.         Index = MAX_HISTORY + currHistoryIndex;
  2178.     }
  2179.     else
  2180.     {
  2181.         Index = currHistoryIndex;
  2182.     }
  2183.     if (Index >= DeleteCount)
  2184.     {
  2185.         for (Count = DeleteCount; Count >= 1; --Count)
  2186.         {
  2187.             /* JL, if want to stop to run next decrement will return true. */
  2188.             if (decrement() == MMI_HIST_STOP_DELETING)
  2189.             {
  2190.                 /* We abort the process here and don't handle original requirement */
  2191.                 break;
  2192.             }
  2193.         }
  2194.     }
  2195. }
  2196. /*****************************************************************************
  2197.  * FUNCTION
  2198.  *  DeleteUptoScrID
  2199.  * DESCRIPTION
  2200.  *  Go to a screen and delete historyall ahead of it
  2201.  * PARAMETERS
  2202.  *  scrnid      [IN]        
  2203.  * RETURNS
  2204.  *  U8 - status
  2205.  *****************************************************************************/
  2206. U8 DeleteUptoScrID(U16 scrnid)
  2207. {
  2208.     /*----------------------------------------------------------------*/
  2209.     /* Local Variables                                                */
  2210.     /*----------------------------------------------------------------*/
  2211.     S16 count = 0;
  2212.     U8 Status = ST_FAILURE;
  2213.     /*----------------------------------------------------------------*/
  2214.     /* Code Body                                                      */
  2215.     /*----------------------------------------------------------------*/
  2216. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  2217.     if (redraw_in_small_screen_proceduer())
  2218.     {
  2219.         return ST_SUCCESS;
  2220.     }
  2221. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  2222.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_DEL_UPTO_SCRID_HDLR, scrnid, currHistoryIndex));
  2223.     count = currHistoryIndex;
  2224.     if (!IsScreenPresent(scrnid))
  2225.     {
  2226.         return ST_FAILURE;
  2227.     }
  2228.     do
  2229.     {
  2230.         if (historyData[currHistoryIndex].scrnID == scrnid)
  2231.         {
  2232.             Status = ST_SUCCESS;
  2233.             break;
  2234.         }
  2235.         /* JL, if want to stop to run next decrement will return true. */
  2236.         if (decrement() == MMI_HIST_STOP_DELETING)
  2237.         {
  2238.             /* We abort the process here and don't handle original requirement */
  2239.             Status = ST_SUCCESS;
  2240.             break;
  2241.         }
  2242.     } while ((count != currHistoryIndex) && (historyData[currHistoryIndex].entryFuncPtr != NULL));
  2243.     return Status;
  2244. }
  2245. /*****************************************************************************
  2246.  * FUNCTION
  2247.  *  DeleteNScrId
  2248.  * DESCRIPTION
  2249.  *  Deletes up to screen id and go  beyond it one node
  2250.  * PARAMETERS
  2251.  *  scrnid      [IN]        
  2252.  * RETURNS
  2253.  *  U8 - status
  2254.  *****************************************************************************/
  2255. U8 DeleteNScrId(U16 scrnid)
  2256. {
  2257.     /*----------------------------------------------------------------*/
  2258.     /* Local Variables                                                */
  2259.     /*----------------------------------------------------------------*/
  2260.     S16 count = 0;
  2261.     U8 Status = ST_FAILURE;
  2262.     /*----------------------------------------------------------------*/
  2263.     /* Code Body                                                      */
  2264.     /*----------------------------------------------------------------*/
  2265. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  2266.     if (redraw_in_small_screen_proceduer())
  2267.     {
  2268.         return ST_SUCCESS;
  2269.     }
  2270. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  2271.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_DEL_NSCRID_HDLR, scrnid, currHistoryIndex));
  2272.     count = currHistoryIndex;
  2273.     if (!IsScreenPresent(scrnid))
  2274.     {
  2275.         return ST_FAILURE;
  2276.     }
  2277.     do
  2278.     {
  2279.         if (historyData[currHistoryIndex].scrnID == scrnid)
  2280.         {
  2281.             Status = ST_SUCCESS;
  2282.             break;
  2283.         }
  2284.         /* JL, if want to stop to run next decrement will return true. */
  2285.         if (decrement() == MMI_HIST_STOP_DELETING)
  2286.         {
  2287.             /* We abort the process here and don't handle original requirement */
  2288.             Status = ST_FAILURE;
  2289.             break;
  2290.         }
  2291.     } while ((count != currHistoryIndex) && (historyData[currHistoryIndex].entryFuncPtr != NULL));
  2292.     if (Status)
  2293.     {
  2294.         decrement();
  2295.     }
  2296.     return ST_SUCCESS;
  2297. }
  2298. /*****************************************************************************
  2299.  * FUNCTION
  2300.  *  GoBeyondMarkerScr
  2301.  * DESCRIPTION
  2302.  *  Go one node beyond  marker screen
  2303.  * PARAMETERS
  2304.  *  scrnid      [IN]        
  2305.  * RETURNS
  2306.  *  U8 - status
  2307.  *****************************************************************************/
  2308. U8 GoBeyondMarkerScr(U16 scrnid)
  2309. {
  2310.     /*----------------------------------------------------------------*/
  2311.     /* Local Variables                                                */
  2312.     /*----------------------------------------------------------------*/
  2313.     S16 count = 0;
  2314.     U8 Status = ST_FAILURE;
  2315.     /*----------------------------------------------------------------*/
  2316.     /* Code Body                                                      */
  2317.     /*----------------------------------------------------------------*/
  2318. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  2319.     if (redraw_in_small_screen_proceduer())
  2320.     {
  2321.         return ST_SUCCESS;
  2322.     }
  2323. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  2324.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_GO_BEYOND_MARKER_SCR_HDLR, scrnid, currHistoryIndex));
  2325.     count = currHistoryIndex;
  2326.     if (!IsScreenPresent(scrnid))
  2327.     {
  2328.         return ST_FAILURE;
  2329.     }
  2330.     do
  2331.     {
  2332.         if (historyData[currHistoryIndex].scrnID == scrnid)
  2333.         {
  2334.             Status = ST_SUCCESS;
  2335.             break;
  2336.         }
  2337.         /* JL, if want to stop to run next decrement will return true. */
  2338.         if (decrement() == MMI_HIST_STOP_DELETING)
  2339.         {
  2340.             /* We abort the process here and don't handle original requirement */
  2341.             Status = ST_FAILURE;
  2342.             break;
  2343.         }
  2344.     } while ((count != currHistoryIndex) && (historyData[currHistoryIndex].entryFuncPtr != NULL));
  2345.     if (Status)
  2346.     {
  2347.         decrement();
  2348.     }
  2349.     ExecutePopHistory();
  2350.     return ST_SUCCESS;
  2351. }
  2352. /*****************************************************************************
  2353.  * FUNCTION
  2354.  *  IsScreenPresent
  2355.  * DESCRIPTION
  2356.  *  Queries history for presence of a screen Id
  2357.  * PARAMETERS
  2358.  *  scrnId          [IN]        
  2359.  * RETURNS
  2360.  *  pBOOL
  2361.  *****************************************************************************/
  2362. pBOOL IsScreenPresent(U16 scrnId)
  2363. {
  2364.     /*----------------------------------------------------------------*/
  2365.     /* Local Variables                                                */
  2366.     /*----------------------------------------------------------------*/
  2367.     S16 count;
  2368.     /*----------------------------------------------------------------*/
  2369.     /* Code Body                                                      */
  2370.     /*----------------------------------------------------------------*/
  2371.     for (count = 0; ((count < MAX_HISTORY) && ((count <= currHistoryIndex) && (currHistoryIndex != -1))); count++)
  2372.     {
  2373.         if (historyData[count].scrnID == scrnId)
  2374.         {
  2375.             MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_IS_SCR_PRESENT_HDLR, scrnId, MMI_TRUE));
  2376.             return MMI_TRUE;
  2377.         }
  2378.     }
  2379.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_IS_SCR_PRESENT_HDLR, scrnId, MMI_FALSE));
  2380.     return MMI_FALSE;
  2381. }
  2382. /*****************************************************************************
  2383.  * FUNCTION
  2384.  *  IsMainLCDHistoryBack
  2385.  * DESCRIPTION
  2386.  *  Queries MainLCD history is back now or not
  2387.  * PARAMETERS
  2388.  *  void
  2389.  * RETURNS
  2390.  *  pBOOL
  2391.  *****************************************************************************/
  2392. pBOOL IsMainLCDHistoryBack(void)
  2393. {
  2394.     /*----------------------------------------------------------------*/
  2395.     /* Local Variables                                                */
  2396.     /*----------------------------------------------------------------*/
  2397.     /*----------------------------------------------------------------*/
  2398.     /* Code Body                                                      */
  2399.     /*----------------------------------------------------------------*/
  2400.     return CheckMainLCDHistoryBack;
  2401. }
  2402. /*****************************************************************************
  2403.  * FUNCTION
  2404.  *  GetPreviousScrnIdOf
  2405.  * DESCRIPTION
  2406.  *  Queries previous scrn id of this Id
  2407.  * PARAMETERS
  2408.  *  scrnId              [IN]        
  2409.  *  previousScrnId      [OUT]         
  2410.  * RETURNS
  2411.  *  pBOOL
  2412.  *****************************************************************************/
  2413. pBOOL GetPreviousScrnIdOf(U16 scrnId, U16 *previousScrnId)
  2414. {
  2415.     /*----------------------------------------------------------------*/
  2416.     /* Local Variables                                                */
  2417.     /*----------------------------------------------------------------*/
  2418.     S16 count;
  2419.     /*----------------------------------------------------------------*/
  2420.     /* Code Body                                                      */
  2421.     /*----------------------------------------------------------------*/
  2422.     for (count = 0; ((count < MAX_HISTORY) && ((count <= currHistoryIndex) && (currHistoryIndex != -1))); count++)
  2423.     {
  2424.         if (historyData[count].scrnID == scrnId)
  2425.         {
  2426.             if ((count - 1) >= 0)
  2427.             {
  2428.                 *previousScrnId = historyData[count - 1].scrnID;
  2429.                 MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_GET_PREVIOUS_SCR_IDOF_HDLR, scrnId,
  2430.                            historyData[count - 1].scrnID));
  2431.                 return MMI_TRUE;
  2432.             }
  2433.             MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_GET_PREVIOUS_SCR_IDOF_2_HDLR, scrnId));
  2434.             return MMI_FALSE;
  2435.         }
  2436.     }
  2437.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_GET_PREVIOUS_SCR_IDOF_2_HDLR, scrnId));
  2438.     return MMI_FALSE;
  2439. }
  2440. /*****************************************************************************
  2441.  * FUNCTION
  2442.  *  GetNextScrnIdOf
  2443.  * DESCRIPTION
  2444.  *  Queries next scrn id of this Id
  2445.  * PARAMETERS
  2446.  *  scrnId          [IN]        
  2447.  *  nextScrnId      [OUT]         
  2448.  * RETURNS
  2449.  *  pBOOL
  2450.  *****************************************************************************/
  2451. pBOOL GetNextScrnIdOf(U16 scrnId, U16 *nextScrnId)
  2452. {
  2453.     /*----------------------------------------------------------------*/
  2454.     /* Local Variables                                                */
  2455.     /*----------------------------------------------------------------*/
  2456.     S16 count;
  2457.     /*----------------------------------------------------------------*/
  2458.     /* Code Body                                                      */
  2459.     /*----------------------------------------------------------------*/
  2460.     for (count = 0; ((count < MAX_HISTORY) && ((count <= currHistoryIndex) && (currHistoryIndex != -1))); count++)
  2461.     {
  2462.         if (historyData[count].scrnID == scrnId)
  2463.         {
  2464.             if ((count + 1) <= currHistoryIndex)
  2465.             {
  2466.                 *nextScrnId = historyData[count + 1].scrnID;
  2467.                 return MMI_TRUE;
  2468.             }
  2469.             return MMI_FALSE;
  2470.         }
  2471.     }
  2472.     return MMI_FALSE;
  2473. }
  2474. /*****************************************************************************
  2475.  * FUNCTION
  2476.  *  IsCurrMarkerScreen
  2477.  * DESCRIPTION
  2478.  *  Check if the current screen is  marker screen.
  2479.  * PARAMETERS
  2480.  *  scrnid      [IN]        
  2481.  * RETURNS
  2482.  *  U8
  2483.  *****************************************************************************/
  2484. U8 IsCurrMarkerScreen(U16 scrnid)
  2485. {
  2486.     /*----------------------------------------------------------------*/
  2487.     /* Local Variables                                                */
  2488.     /*----------------------------------------------------------------*/
  2489.     /*----------------------------------------------------------------*/
  2490.     /* Code Body                                                      */
  2491.     /*----------------------------------------------------------------*/
  2492.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_IS_CUR_MARKER_SCR_HDLR, scrnid, historyData[currHistoryIndex].scrnID));
  2493.     return (historyData[currHistoryIndex].scrnID == scrnid);
  2494. }
  2495. /*****************************************************************************
  2496.  * FUNCTION
  2497.  *  ExecuteRootMainHistoryScreen
  2498.  * DESCRIPTION
  2499.  *  To execute the root history screen.
  2500.  * PARAMETERS
  2501.  *  funcPtr     [IN]        Reserve not use
  2502.  * RETURNS
  2503.  *  U8
  2504.  *****************************************************************************/
  2505. U8 ExecuteRootMainHistoryScreen(void *funcPtr)
  2506. {
  2507.     /*----------------------------------------------------------------*/
  2508.     /* Local Variables                                                */
  2509.     /*----------------------------------------------------------------*/
  2510.     U8 Status = ST_SUCCESS;
  2511.     S16 count = currHistoryIndex;
  2512.     /*----------------------------------------------------------------*/
  2513.     /* Code Body                                                      */
  2514.     /*----------------------------------------------------------------*/
  2515.     /* reserve not decrement: Memory is not being released bcos of one particular case of keypad lock */
  2516. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  2517.     if (redraw_in_small_screen_proceduer())
  2518.     {
  2519.         return ST_SUCCESS;
  2520.     }
  2521. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  2522.     /* To make sure the callback will run at topist screen, and callback for APP */
  2523.     ExecTopScrnCallbackHandler();
  2524.     if (currHistoryIndex <= 0)
  2525.     {
  2526.         if (historyData[0].entryFuncPtr)
  2527.         {
  2528.             (*(historyData[0].entryFuncPtr)) ();
  2529.         }
  2530.         return ST_SUCCESS;
  2531.     }
  2532.     /* down popup all others history to callback for APP */
  2533.     bBackHistoryFlag = MMI_TRUE;
  2534.     do
  2535.     {
  2536.         if (count == 0)
  2537.         {
  2538.             Status = ST_SUCCESS;
  2539.             break;
  2540.         }
  2541.         if (count > 0)
  2542.         {
  2543.             if (ExecHistoryScrnCallBackHandle(count) == MMI_HIST_STOP_DELETING)
  2544.             {
  2545.                 Status = ST_FAILURE;
  2546.                 break;
  2547.             }
  2548.         }
  2549.         /* To make sure back to idle screen will be free the history */
  2550.         mmi_free_history_buffer(count);
  2551.         count--;
  2552.     } while ((historyData[count].entryFuncPtr != NULL) && (count > 0));
  2553.     currHistoryIndex = count;
  2554.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EXEC_ROOT_HIST_HDLR, currHistoryIndex, Status));
  2555.     
  2556.     IsBackHistory = MMI_TRUE;
  2557.     if (Status == ST_FAILURE)
  2558.     {
  2559.         #if 0 /* we may need to keep guiBuffer and inputBuffer */
  2560. /* under construction !*/
  2561. /* under construction !*/
  2562.         #endif
  2563.         /* entry itself */
  2564.         if (historyData[count].entryFuncPtr)
  2565.         {
  2566.             (*(historyData[count].entryFuncPtr)) ();
  2567.         }
  2568.         #if 0 /* We may not need to remove one more node */
  2569. /* under construction !*/
  2570. /* under construction !*/
  2571.         #endif
  2572.         decrement();
  2573.         #if 0
  2574. /* under construction !*/
  2575. /* under construction !*/
  2576. /* under construction !*/
  2577. /* under construction !*/
  2578. /* under construction !*/
  2579. /* under construction !*/
  2580. /* under construction !*/
  2581. /* under construction !*/
  2582. /* under construction !*/
  2583. /* under construction !*/
  2584. /* under construction !*/
  2585. /* under construction !*/
  2586. /* under construction !*/
  2587. /* under construction !*/
  2588. /* under construction !*/
  2589. /* under construction !*/
  2590. /* under construction !*/
  2591. /* under construction !*/
  2592. /* under construction !*/
  2593. /* under construction !*/
  2594. /* under construction !*/
  2595.         #endif
  2596.     }
  2597.     else
  2598.     {
  2599.         if (historyData[currHistoryIndex].entryFuncPtr)
  2600.         {
  2601.             (*(historyData[currHistoryIndex].entryFuncPtr)) ();
  2602.         }
  2603.     }
  2604.     bBackHistoryFlag = MMI_FALSE;
  2605.     IsBackHistory = MMI_FALSE;
  2606.     return Status;
  2607. }
  2608. /*****************************************************************************
  2609.  * FUNCTION
  2610.  *  DinitHistory
  2611.  * DESCRIPTION
  2612.  *  Free the history node
  2613.  * PARAMETERS
  2614.  *  void
  2615.  * RETURNS
  2616.  *  void
  2617.  *****************************************************************************/
  2618. void DinitHistory(void)
  2619. {
  2620.     /*----------------------------------------------------------------*/
  2621.     /* Local Variables                                                */
  2622.     /*----------------------------------------------------------------*/
  2623.     U16 count = 0;
  2624.     /*----------------------------------------------------------------*/
  2625.     /* Code Body                                                      */
  2626.     /*----------------------------------------------------------------*/
  2627. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  2628.     if (redraw_in_small_screen_proceduer())
  2629.     {
  2630.         return;
  2631.     }
  2632. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  2633.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_DINIT_HIST_HDLR));
  2634.     if (currHistoryIndex > 0)
  2635.     {
  2636.         for (count = currHistoryIndex; count > 0; --count)
  2637.         {
  2638.             mmi_free_history_buffer(count);
  2639.             memset(&historyData[count], 0, sizeof(historyNode));
  2640.         }
  2641.     }
  2642.     /*
  2643.      * Free historyData[0] memory:
  2644.      * Here can't use mmi_free_history_buffer() 
  2645.      * because currHistoryIndex may be -1 in ExecutePopHistory and then
  2646.      * invoke DinitHistory() in EntryIdleScreen()
  2647.      */
  2648.     if (historyData[0].guiBuffer)
  2649.     {
  2650.         OslMfree(historyData[0].guiBuffer);
  2651.     }
  2652.     if (historyData[0].inputBuffer)
  2653.     {
  2654.         OslMfree(historyData[0].inputBuffer);
  2655.     }
  2656.     memset(&historyData[0], 0, sizeof(historyData));
  2657.     currHistoryIndex = -1;
  2658. }
  2659. /*****************************************************************************
  2660.  * FUNCTION
  2661.  *  SetDelScrnIDCallbackHandler
  2662.  * DESCRIPTION
  2663.  *  Register callback fucntion for delete screen occur.
  2664.  * PARAMETERS
  2665.  *  ScrnID      [IN]        
  2666.  *  funcPtr     [IN]        
  2667.  * RETURNS
  2668.  *  U8 - status
  2669.  *****************************************************************************/
  2670. U8 SetDelScrnIDCallbackHandler(U16 ScrnID, HistoryDelCBPtr funcPtr)
  2671. {
  2672.     /*----------------------------------------------------------------*/
  2673.     /* Local Variables                                                */
  2674.     /*----------------------------------------------------------------*/
  2675.     U16 count;
  2676.     /*----------------------------------------------------------------*/
  2677.     /* Code Body                                                      */
  2678.     /*----------------------------------------------------------------*/
  2679.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_SET_SCREEN_ID_CB_HDLR, ScrnID, funcPtr));
  2680.     /* MTK added by JL for history callback */
  2681.     for (count = 0; count < MAX_HISTORY; count++)
  2682.     {
  2683.         /* add new one, while scrnID and historydelCBPtr is NULL, means not found we can add a new one. */
  2684.         if ((historyCBHandler[count].scrnID == 0) && (historyCBHandler[count].historydelCBPtr == NULL))
  2685.         {
  2686.             historyCBHandler[count].scrnID = ScrnID;
  2687.             historyCBHandler[count].historydelCBPtr = funcPtr;
  2688.             return MMI_TRUE;
  2689.         }
  2690.         /* already exist, to overwrite, while ScrnID and funcPtr are not NULL, and fount ScrnID. */
  2691.         /*
  2692.          * Leo remove, each screen can only have one callback.
  2693.          * if ( (historyCBHandler[count].scrnID == ScrnID) && (historyCBHandler[count].historydelCBPtr != NULL) )
  2694.          */
  2695.         if (historyCBHandler[count].scrnID == ScrnID)
  2696.         {
  2697.             historyCBHandler[count].historydelCBPtr = funcPtr;
  2698.             return MMI_TRUE;
  2699.         }
  2700.     }
  2701.     MMI_ASSERT(MMI_FALSE);
  2702.     return MMI_FALSE;
  2703. }
  2704. /*****************************************************************************
  2705.  * FUNCTION
  2706.  *  ClearDelScrnIDCallbackHandler
  2707.  * DESCRIPTION
  2708.  *  Clear callback fucntion for delete screen occur.
  2709.  * PARAMETERS
  2710.  *  ScrnID      [IN]        
  2711.  *  funcPtr     [IN]        
  2712.  * RETURNS
  2713.  *  U8 - status
  2714.  *****************************************************************************/
  2715. U8 ClearDelScrnIDCallbackHandler(U16 ScrnID, HistoryDelCBPtr funcPtr)
  2716. {
  2717.     /*----------------------------------------------------------------*/
  2718.     /* Local Variables                                                */
  2719.     /*----------------------------------------------------------------*/
  2720.     U16 count, found_idx;
  2721.     /*----------------------------------------------------------------*/
  2722.     /* Code Body                                                      */
  2723.     /*----------------------------------------------------------------*/
  2724.     MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_CLR_SCREEN_ID_CB_HDLR, ScrnID, funcPtr));
  2725.     /* MTK added by JL for history callback */
  2726.     for (count = 0; count < MAX_HISTORY; count++)
  2727.     {
  2728.         /* found the delete one. */
  2729.         if (historyCBHandler[count].scrnID == ScrnID)
  2730.         {
  2731.             break;
  2732.         }
  2733.     }
  2734.     for (found_idx = count; found_idx < MAX_HISTORY - 1; found_idx++)
  2735.     {
  2736.         historyCBHandler[found_idx].scrnID = historyCBHandler[found_idx + 1].scrnID;
  2737.         historyCBHandler[found_idx].historydelCBPtr = historyCBHandler[found_idx + 1].historydelCBPtr;
  2738.     }
  2739.     /* set the last one. */
  2740.     historyCBHandler[MAX_HISTORY - 1].scrnID = 0;
  2741.     historyCBHandler[MAX_HISTORY - 1].historydelCBPtr = NULL;
  2742.     return 0;
  2743. }
  2744. /*****************************************************************************
  2745.  * FUNCTION
  2746.  *  SearchDelScrnIDCallbackHandler
  2747.  * DESCRIPTION
  2748.  *  Search index of the delete callback screen.
  2749.  * PARAMETERS
  2750.  *  ScrnID          [IN]        
  2751.  *  found_idx       [OUT]        
  2752.  * RETURNS
  2753.  *  U8 - status
  2754.  *****************************************************************************/
  2755. static U8 SearchDelScrnIDCallbackHandler(U16 ScrnID, U16 *found_idx)
  2756. {
  2757.     /*----------------------------------------------------------------*/
  2758.     /* Local Variables                                                */
  2759.     /*----------------------------------------------------------------*/
  2760.     U16 count;
  2761.     /*----------------------------------------------------------------*/
  2762.     /* Code Body                                                      */
  2763.     /*----------------------------------------------------------------*/
  2764. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  2765.     if (redraw_in_small_screen_proceduer())
  2766.     {
  2767.         return MMI_FALSE;
  2768.     }
  2769. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  2770.     for (count = 0; count < MAX_HISTORY; count++)
  2771.     {
  2772.         /* found the delete one. */
  2773.         if (historyCBHandler[count].scrnID == ScrnID)
  2774.         {
  2775.             MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_SRCH_DEL_SCRN_CB_HDLR, ScrnID, count));
  2776.             *found_idx = count;
  2777.             return MMI_TRUE;
  2778.         }
  2779.     }
  2780.     return MMI_FALSE;
  2781. }
  2782. /*****************************************************************************
  2783.  * FUNCTION
  2784.  *  ExecTopScrnCallbackHandler
  2785.  * DESCRIPTION
  2786.  *  Check if topist view screen exist in delete screen will be callback.
  2787.  * PARAMETERS
  2788.  *  void
  2789.  * RETURNS
  2790.  *  U8 - status
  2791.  *****************************************************************************/
  2792. static U8 ExecTopScrnCallbackHandler(void)
  2793. {
  2794.     /*----------------------------------------------------------------*/
  2795.     /* Local Variables                                                */
  2796.     /*----------------------------------------------------------------*/
  2797.     /*----------------------------------------------------------------*/
  2798.     /* Code Body                                                      */
  2799.     /*----------------------------------------------------------------*/
  2800.     return ExecTopScrnCallbackHandler_ex(1);
  2801. }
  2802. /*****************************************************************************
  2803.  * FUNCTION
  2804.  *  ExecTopScrnCallbackHandler_ex
  2805.  * DESCRIPTION
  2806.  *  
  2807.  * PARAMETERS
  2808.  *  is_main_hist        [IN]        
  2809.  * RETURNS
  2810.  *  
  2811.  *****************************************************************************/
  2812. U8 ExecTopScrnCallbackHandler_ex(U8 is_main_hist)
  2813. {
  2814.     /*----------------------------------------------------------------*/
  2815.     /* Local Variables                                                */
  2816.     /*----------------------------------------------------------------*/
  2817.     U8 is_stop_delete = MMI_FALSE;
  2818.     U16 cb_history_index;
  2819.     U16 scrnID;
  2820.     /*----------------------------------------------------------------*/
  2821.     /* Code Body                                                      */
  2822.     /*----------------------------------------------------------------*/
  2823.     if (is_main_hist)
  2824.     {
  2825.         scrnID = GetExitScrnID();
  2826.     }
  2827.     else
  2828.     {
  2829.         scrnID = GetSubLCDExitScrnId();
  2830.     }
  2831.     if (SearchDelScrnIDCallbackHandler(scrnID, &cb_history_index))
  2832.     {
  2833.         if (historyCBHandler[cb_history_index].historydelCBPtr)
  2834.         {
  2835.             is_stop_delete = historyCBHandler[cb_history_index].historydelCBPtr((void*)MMI_HIST_EXIT_SCREEN_TYPE);
  2836.         }
  2837.         MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EXEC_TOP_SCRN_CB_HDLR, is_stop_delete));
  2838.         ClearDelScrnIDCallbackHandler(historyCBHandler[cb_history_index].scrnID, NULL);
  2839.     }
  2840.     return is_stop_delete;
  2841. }
  2842. /*****************************************************************************
  2843.  * FUNCTION
  2844.  *  ExecHistoryScrnCallBackHandle
  2845.  * DESCRIPTION
  2846.  *  Check if the history screen exist in delete screen will be callback.
  2847.  * PARAMETERS
  2848.  *  HistoryIndex        [IN]        
  2849.  * RETURNS
  2850.  *  U8 - status
  2851.  *****************************************************************************/
  2852. static U8 ExecHistoryScrnCallBackHandle(U16 HistoryIndex)
  2853. {
  2854.     /*----------------------------------------------------------------*/
  2855.     /* Local Variables                                                */
  2856.     /*----------------------------------------------------------------*/
  2857.     /*----------------------------------------------------------------*/
  2858.     /* Code Body                                                      */
  2859.     /*----------------------------------------------------------------*/
  2860.     return ExecHistoryScrnCallBackHandle_ex(HistoryIndex, 1);
  2861. }
  2862. /*****************************************************************************
  2863.  * FUNCTION
  2864.  *  ExecHistoryScrnCallBackHandle_ex
  2865.  * DESCRIPTION
  2866.  *  
  2867.  * PARAMETERS
  2868.  *  HistoryIndex        [IN]        
  2869.  *  is_main_hist        [IN]        
  2870.  * RETURNS
  2871.  *  
  2872.  *****************************************************************************/
  2873. U8 ExecHistoryScrnCallBackHandle_ex(U16 HistoryIndex, U8 is_main_hist)
  2874. {
  2875.     /*----------------------------------------------------------------*/
  2876.     /* Local Variables                                                */
  2877.     /*----------------------------------------------------------------*/
  2878.     /* Not support for stop callback at this funciton */
  2879.     U16 cb_history_index;
  2880.     U16 scrnID;
  2881.     U8 is_stop_allow = MMI_FALSE;
  2882.     /*----------------------------------------------------------------*/
  2883.     /* Code Body                                                      */
  2884.     /*----------------------------------------------------------------*/
  2885.     if (is_main_hist)
  2886.     {
  2887.         /* main LCD history */
  2888.         scrnID = historyData[HistoryIndex].scrnID;
  2889.     }
  2890.     else
  2891.     {
  2892.         /* sub LCD history */
  2893.         scrnID = GetSubLCDScrnId(HistoryIndex);
  2894.     }
  2895.     if (SearchDelScrnIDCallbackHandler(scrnID, &cb_history_index))
  2896.     {
  2897.         if (historyCBHandler[cb_history_index].historydelCBPtr)
  2898.         {
  2899.             is_stop_allow = historyCBHandler[cb_history_index].historydelCBPtr((void*)MMI_HIST_DELETE_SCREEN_TYPE);
  2900.         }
  2901.         ClearDelScrnIDCallbackHandler(historyCBHandler[cb_history_index].scrnID, NULL);
  2902.     }
  2903.     if (is_stop_allow == MMI_TRUE)
  2904.     {
  2905.         MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EXEC_HIST_SCRN_CB_HDLR, HistoryIndex));
  2906.     }
  2907.     return is_stop_allow;
  2908. }
  2909. /*****************************************************************************
  2910.  * FUNCTION
  2911.  *  set_small_screen
  2912.  * DESCRIPTION
  2913.  *  Called by category to tell history that the screen being drawn is small.
  2914.  * PARAMETERS
  2915.  *  void
  2916.  * RETURNS
  2917.  *  void
  2918.  *****************************************************************************/
  2919. void set_small_screen(void)
  2920. {
  2921. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  2922.     /*----------------------------------------------------------------*/
  2923.     /* Local Variables                                                */
  2924.     /*----------------------------------------------------------------*/
  2925.     /*----------------------------------------------------------------*/
  2926.     /* Code Body                                                      */
  2927.     /*----------------------------------------------------------------*/
  2928.     if (no_small_screen)
  2929.     {
  2930.         return;
  2931.     }
  2932.     if (currHistoryIndex == -1)
  2933.     {
  2934.         clear_screen();
  2935.     }
  2936.     small_history_node = 1;
  2937. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  2938. }
  2939. /*****************************************************************************
  2940.  * FUNCTION
  2941.  *  mmi_is_redrawing_bk_screens
  2942.  * DESCRIPTION
  2943.  *  
  2944.  * PARAMETERS
  2945.  *  void
  2946.  * RETURNS
  2947.  *  
  2948.  *****************************************************************************/
  2949. S32 mmi_is_redrawing_bk_screens()
  2950. {
  2951. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  2952.     /*----------------------------------------------------------------*/
  2953.     /* Local Variables                                                */
  2954.     /*----------------------------------------------------------------*/
  2955.     /*----------------------------------------------------------------*/
  2956.     /* Code Body                                                      */
  2957.     /*----------------------------------------------------------------*/
  2958.     if (mmi_execute_scrn_exit_func())
  2959.     {
  2960.         if (redrawing_old_screens == MMI_HIST_SMALLSCREEN_ACTIVE ||
  2961.             redrawing_old_screens == MMI_HIST_SMALLSCREEN_ACTIVE_IN_EXIT_FUNC)
  2962.         {
  2963.             return 1;
  2964.         }
  2965.         else
  2966.         {
  2967.             return 0;
  2968.         }
  2969.     }
  2970.     else
  2971.     {
  2972.         return (redrawing_old_screens == MMI_HIST_SMALLSCREEN_ACTIVE) ? 1 : 0;
  2973.     }
  2974. #else /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  2975.     return 0;
  2976. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  2977. }
  2978. /*****************************************************************************
  2979.  * FUNCTION
  2980.  *  is_redrawing_old_screens
  2981.  * DESCRIPTION
  2982.  *  
  2983.  * PARAMETERS
  2984.  *  void
  2985.  * RETURNS
  2986.  *  
  2987.  *****************************************************************************/
  2988. S32 is_redrawing_old_screens()
  2989. {
  2990.     /*----------------------------------------------------------------*/
  2991.     /* Local Variables                                                */
  2992.     /*----------------------------------------------------------------*/
  2993.     /*----------------------------------------------------------------*/
  2994.     /* Code Body                                                      */
  2995.     /*----------------------------------------------------------------*/
  2996.     return mmi_is_redrawing_bk_screens();
  2997. }
  2998. /*****************************************************************************
  2999.  * FUNCTION
  3000.  *  reset_small_screen
  3001.  * DESCRIPTION
  3002.  *  Called by category to tell history that it is exiting from small screen.
  3003.  * PARAMETERS
  3004.  *  void
  3005.  * RETURNS
  3006.  *  void
  3007.  *****************************************************************************/
  3008. void reset_small_screen(void)
  3009. {
  3010. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  3011.     /*----------------------------------------------------------------*/
  3012.     /* Local Variables                                                */
  3013.     /*----------------------------------------------------------------*/
  3014.     /*----------------------------------------------------------------*/
  3015.     /* Code Body                                                      */
  3016.     /*----------------------------------------------------------------*/
  3017.     small_history_node = 0;
  3018.     no_small_screen = 0;
  3019. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  3020. }
  3021. /*****************************************************************************
  3022.  * FUNCTION
  3023.  *  restore_small_screen
  3024.  * DESCRIPTION
  3025.  *  Restores small screen
  3026.  * PARAMETERS
  3027.  *  void
  3028.  * RETURNS
  3029.  *  void
  3030.  *****************************************************************************/
  3031. void restore_small_screen(void)
  3032. {
  3033.     /*----------------------------------------------------------------*/
  3034.     /* Local Variables                                                */
  3035.     /*----------------------------------------------------------------*/
  3036.     /*----------------------------------------------------------------*/
  3037.     /* Code Body                                                      */
  3038.     /*----------------------------------------------------------------*/
  3039. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  3040.     no_small_screen = 0;
  3041. #endif 
  3042. }
  3043. /*****************************************************************************
  3044.  * FUNCTION
  3045.  *  force_no_small_screen
  3046.  * DESCRIPTION
  3047.  *  Called by Application to disable small screen history saving.
  3048.  * PARAMETERS
  3049.  *  void
  3050.  * RETURNS
  3051.  *  void
  3052.  *****************************************************************************/
  3053. void force_no_small_screen(void)
  3054. {
  3055.     /*----------------------------------------------------------------*/
  3056.     /* Local Variables                                                */
  3057.     /*----------------------------------------------------------------*/
  3058.     /*----------------------------------------------------------------*/
  3059.     /* Code Body                                                      */
  3060.     /*----------------------------------------------------------------*/
  3061. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  3062.     no_small_screen = 1;
  3063. #endif 
  3064. }
  3065. /*****************************************************************************
  3066.  * FUNCTION
  3067.  *  redraw_in_small_screen_proceduer
  3068.  * DESCRIPTION
  3069.  *  Check if in small screen procedure
  3070.  * PARAMETERS
  3071.  *  void
  3072.  * RETURNS
  3073.  *  if in small screen procedure
  3074.  *****************************************************************************/
  3075. MMI_BOOL redraw_in_small_screen_proceduer(void)
  3076. {
  3077.     /*----------------------------------------------------------------*/
  3078.     /* Local Variables                                                */
  3079.     /*----------------------------------------------------------------*/
  3080.     /*----------------------------------------------------------------*/
  3081.     /* Code Body                                                      */
  3082.     /*----------------------------------------------------------------*/
  3083.     if (is_redrawing_old_screens())
  3084.     {
  3085.         return MMI_TRUE;
  3086.     }
  3087.     return MMI_FALSE;
  3088. }
  3089. /* 
  3090.  * enable_resized_small_screen(), disable_resized_small_screen(), and whether_no_small_screen()
  3091.  * There is no relation with small screen process in history.
  3092.  * It's only used for tha WGUI and application and decide to 
  3093.  * show the small screen or the normal screen.
  3094.  */
  3095. /*****************************************************************************
  3096.  * FUNCTION
  3097.  *  enable_resized_small_screen
  3098.  * DESCRIPTION
  3099.  *  Called by application to enable the small screen.
  3100.  * PARAMETERS
  3101.  *  void
  3102.  * RETURNS
  3103.  *  void
  3104.  *****************************************************************************/
  3105. void enable_resized_small_screen(void)
  3106. {
  3107.     /*----------------------------------------------------------------*/
  3108.     /* Local Variables                                                */
  3109.     /*----------------------------------------------------------------*/
  3110.     /*----------------------------------------------------------------*/
  3111.     /* Code Body                                                      */
  3112.     /*----------------------------------------------------------------*/
  3113. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  3114.     small_screen_enabled = 1;
  3115. #endif 
  3116. }
  3117. /*****************************************************************************
  3118.  * FUNCTION
  3119.  *  disable_resized_small_screen
  3120.  * DESCRIPTION
  3121.  *  Called on exiting the small screen.
  3122.  * PARAMETERS
  3123.  *  void
  3124.  * RETURNS
  3125.  *  void
  3126.  *****************************************************************************/
  3127. void disable_resized_small_screen(void)
  3128. {
  3129.     /*----------------------------------------------------------------*/
  3130.     /* Local Variables                                                */
  3131.     /*----------------------------------------------------------------*/
  3132.     /*----------------------------------------------------------------*/
  3133.     /* Code Body                                                      */
  3134.     /*----------------------------------------------------------------*/
  3135. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  3136.     small_screen_enabled = 0;
  3137. #endif 
  3138. }
  3139. /*****************************************************************************
  3140.  * FUNCTION
  3141.  *  whether_no_small_screen
  3142.  * DESCRIPTION
  3143.  *  Tells whether small screen is enabled or not
  3144.  * PARAMETERS
  3145.  *  void
  3146.  * RETURNS
  3147.  *  void
  3148.  *****************************************************************************/
  3149. S32 whether_no_small_screen(void)
  3150. {
  3151. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  3152.     /*----------------------------------------------------------------*/
  3153.     /* Local Variables                                                */
  3154.     /*----------------------------------------------------------------*/
  3155.     /*----------------------------------------------------------------*/
  3156.     /* Code Body                                                      */
  3157.     /*----------------------------------------------------------------*/
  3158.     return small_screen_enabled;
  3159. #else /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  3160.     return 0;
  3161. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  3162. }
  3163. #ifdef __MMI_UI_TAB_PANE__
  3164. /*****************************************************************************
  3165.  * FUNCTION
  3166.  *  disable_history_saving
  3167.  * DESCRIPTION
  3168.  *  Disable history saving
  3169.  * PARAMETERS
  3170.  *  void
  3171.  * RETURNS
  3172.  *  void
  3173.  *****************************************************************************/
  3174. void disable_history_saving(void)
  3175. {
  3176.     /*----------------------------------------------------------------*/
  3177.     /* Local Variables                                                */
  3178.     /*----------------------------------------------------------------*/
  3179.     /*----------------------------------------------------------------*/
  3180.     /* Code Body                                                      */
  3181.     /*----------------------------------------------------------------*/
  3182.     disable_history_save = 1;
  3183. }
  3184. /*****************************************************************************
  3185.  * FUNCTION
  3186.  *  enable_history_saving
  3187.  * DESCRIPTION
  3188.  *  Enables history saving
  3189.  * PARAMETERS
  3190.  *  void
  3191.  * RETURNS
  3192.  *  void
  3193.  *****************************************************************************/
  3194. void enable_history_saving(void)
  3195. {
  3196.     /*----------------------------------------------------------------*/
  3197.     /* Local Variables                                                */
  3198.     /*----------------------------------------------------------------*/
  3199.     /*----------------------------------------------------------------*/
  3200.     /* Code Body                                                      */
  3201.     /*----------------------------------------------------------------*/
  3202.     disable_history_save = 0;
  3203. }
  3204. /*****************************************************************************
  3205.  * FUNCTION
  3206.  *  change_curr_gui_buffer
  3207.  * DESCRIPTION
  3208.  *  Changes the current gui buffer of the current screen
  3209.  *  
  3210.  *  This is used by tab pane as as tab pane history is on top of the screen.
  3211.  * PARAMETERS
  3212.  *  gui_buffer      [IN]     
  3213.  * RETURNS
  3214.  *  void
  3215.  *****************************************************************************/
  3216. void change_curr_gui_buffer(U8 *gui_buffer)
  3217. {
  3218.     /*----------------------------------------------------------------*/
  3219.     /* Local Variables                                                */
  3220.     /*----------------------------------------------------------------*/
  3221.     /*----------------------------------------------------------------*/
  3222.     /* Code Body                                                      */
  3223.     /*----------------------------------------------------------------*/
  3224.     memcpy(historyData[currHistoryIndex].guiBuffer, gui_buffer, MAX_GUI_BUFFER);
  3225. }
  3226. #endif /* __MMI_UI_TAB_PANE__ */