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

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.  *  Help.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.  *------------------------------------------------------------------------------
  67.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  68.  *==============================================================================
  69.  *******************************************************************************/
  70. /**
  71.  * Copyright Notice
  72.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  73.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  74.  *  (It is illegal to remove this copyright notice from this software or any
  75.  *  portion of it)
  76.  */
  77. /**************************************************************
  78.    FILENAME : Helpc.h
  79.    PURPOSE     : 
  80.    REMARKS     : nil
  81.    AUTHOR      : Manish Vohra
  82.    DATE     : 12/03/03
  83. **************************************************************/
  84. #include "StdC.h"
  85. #include "wgui_categories.h"
  86. #include "Globaldefs.h"
  87. #include "CustDataRes.h"
  88. #include "HistoryGprot.h"
  89. #include "HelpDef.h"
  90. #include "HelpDef.h"
  91. #include "HelpProt.h"
  92. #include "HelpDcl.h"
  93. #include "TimerEvents.h"
  94. #include "DebugInitDef.h"
  95. #include "Unicodexdcl.h"
  96. #include "GlobalDefs.h"
  97. #include "NVRAMProt.h"
  98. #include "NVRAMEnum.h"
  99. #include "NVRAMType.h"
  100. /*****************************************************************************
  101.  * FUNCTION
  102.  *  InitHelp
  103.  * DESCRIPTION
  104.  *  Initialize Help
  105.  *  
  106.  *  Call this function at boot up time find
  107.  *  help is enabled or not,
  108.  * PARAMETERS
  109.  *  void
  110.  * RETURNS
  111.  *  void
  112.  *****************************************************************************/
  113. void InitHelp(void)
  114. {
  115.     /*----------------------------------------------------------------*/
  116.     /* Local Variables                                                */
  117.     /*----------------------------------------------------------------*/
  118.     S16 error;
  119.     S32 status = -1;
  120.     /*----------------------------------------------------------------*/
  121.     /* Code Body                                                      */
  122.     /*----------------------------------------------------------------*/
  123.     gIsHelpEnabled = 1;
  124.     status = ReadValue(NVRAM_HELP_ENABLED_FLAG, &gIsHelpEnabled, DS_BYTE, &error);
  125.     if (error != NVRAM_READ_SUCCESS)
  126.     {
  127.         PRINT_INFORMATION(("[InitHelp] NVRAM READ FAILURE "));
  128.     }
  129. }
  130. /*****************************************************************************
  131.  * FUNCTION
  132.  *  SetHelpEnableFlag
  133.  * DESCRIPTION
  134.  *  Set a global variable
  135.  *  
  136.  *  This function is called by organizer when help is
  137.  *  made set in the Radio Button
  138.  * PARAMETERS
  139.  *  void
  140.  * RETURNS
  141.  *  void
  142.  *****************************************************************************/
  143. void SetHelpEnableFlag(void)
  144. {
  145.     /*----------------------------------------------------------------*/
  146.     /* Local Variables                                                */
  147.     /*----------------------------------------------------------------*/
  148.     /*----------------------------------------------------------------*/
  149.     /* Code Body                                                      */
  150.     /*----------------------------------------------------------------*/
  151.     gIsHelpEnabled = 1;
  152. }
  153. /*****************************************************************************
  154.  * FUNCTION
  155.  *  EntryScreenShowHelp
  156.  * DESCRIPTION
  157.  *  Entry function for Help Dispplay Screen
  158.  * PARAMETERS
  159.  *  void
  160.  * RETURNS
  161.  *  void
  162.  *****************************************************************************/
  163. void EntryScreenShowHelp(void)
  164. {
  165.     /*----------------------------------------------------------------*/
  166.     /* Local Variables                                                */
  167.     /*----------------------------------------------------------------*/
  168.     U16 currScrenID = 0;
  169.     U16 stringID;
  170.     /*----------------------------------------------------------------*/
  171.     /* Code Body                                                      */
  172.     /*----------------------------------------------------------------*/
  173.     currScrenID = GetCurrScreenID();
  174.     stringID = GetHelpStringID(currScrenID);
  175.     /* JL remove ExecuteCurrExitHandler(); */
  176.     EntryNewScreen(SCR_HELP, NULL, EntryScreenShowHelp, NULL);
  177.     ShowCategory21Screen(STR_HELP_CAPTION, 0, 0, 0, STR_GLOBAL_OK, 0, stringID, NULL);
  178.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  179.     /* JL remove SetExitHandler(SCR_HELP,ExitScreenShowHelp); */
  180. }
  181. /*****************************************************************************
  182.  * FUNCTION
  183.  *  ExitScreenShowHelp
  184.  * DESCRIPTION
  185.  *  Exit function for Help Dispplay Screen
  186.  * PARAMETERS
  187.  *  void
  188.  * RETURNS
  189.  *  void
  190.  *****************************************************************************/
  191. void ExitScreenShowHelp(void)
  192. {
  193.     /*----------------------------------------------------------------*/
  194.     /* Local Variables                                                */
  195.     /*----------------------------------------------------------------*/
  196.     history h;
  197.     S16 nHistory = 0;
  198.     /*----------------------------------------------------------------*/
  199.     /* Code Body                                                      */
  200.     /*----------------------------------------------------------------*/
  201.     h.scrnID = SCR_HELP;
  202.     h.entryFuncPtr = EntryScreenShowHelp;
  203.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  204.     GetCategoryHistory(h.guiBuffer);
  205.     AddHistory(h);
  206. }
  207. /*****************************************************************************
  208.  * FUNCTION
  209.  *  ShowHelp
  210.  * DESCRIPTION
  211.  *  Call back when phone is left idle for
  212.  *  some time
  213.  * PARAMETERS
  214.  *  void
  215.  * RETURNS
  216.  *  void
  217.  *****************************************************************************/
  218. void ShowHelp(void)
  219. {
  220.     /*----------------------------------------------------------------*/
  221.     /* Local Variables                                                */
  222.     /*----------------------------------------------------------------*/
  223.     U16 stringID;
  224.     /*----------------------------------------------------------------*/
  225.     /* Code Body                                                      */
  226.     /*----------------------------------------------------------------*/
  227.     stringID = GetCurrScreenID();
  228.     if (stringID)
  229.     {
  230.         EntryScreenShowHelp();
  231.     }
  232. }
  233. /*****************************************************************************
  234.  * FUNCTION
  235.  *  EnableHelp
  236.  * DESCRIPTION
  237.  *  Needs to be called in the entry functions
  238.  *  for which help needs to be displayed
  239.  * PARAMETERS
  240.  *  ScrnID          [IN]        
  241.  *  ScreenID(?)     [IN]        
  242.  * RETURNS
  243.  *  void
  244.  *****************************************************************************/
  245. void EnableHelp(U16 ScrnID)
  246. {
  247.     /*----------------------------------------------------------------*/
  248.     /* Local Variables                                                */
  249.     /*----------------------------------------------------------------*/
  250.     /*----------------------------------------------------------------*/
  251.     /* Code Body                                                      */
  252.     /*----------------------------------------------------------------*/
  253.     gCurrScreenID = ScrnID;
  254.     StartTimer(HELP_APPLICATION_TIMER, HELP_APPLICATION_TIMEOUT, ShowHelp);
  255. }
  256. /*****************************************************************************
  257.  * FUNCTION
  258.  *  DisableHelp
  259.  * DESCRIPTION
  260.  *  Needs to be called from the exit functions
  261.  *  of screens for which help needs to be displayed
  262.  * PARAMETERS
  263.  *  void
  264.  * RETURNS
  265.  *  void
  266.  *****************************************************************************/
  267. void DisableHelp(void)
  268. {
  269.     /*----------------------------------------------------------------*/
  270.     /* Local Variables                                                */
  271.     /*----------------------------------------------------------------*/
  272.     /*----------------------------------------------------------------*/
  273.     /* Code Body                                                      */
  274.     /*----------------------------------------------------------------*/
  275.     gCurrScreenID = 0;
  276.     StopTimer(HELP_APPLICATION_TIMER);
  277. }
  278. /*****************************************************************************
  279.  * FUNCTION
  280.  *  GetCurrScreenID
  281.  * DESCRIPTION
  282.  *  return the current Screen ID
  283.  * PARAMETERS
  284.  *  void
  285.  * RETURNS
  286.  *  void
  287.  *****************************************************************************/
  288. U16 GetCurrScreenID(void)
  289. {
  290.     /*----------------------------------------------------------------*/
  291.     /* Local Variables                                                */
  292.     /*----------------------------------------------------------------*/
  293.     /*----------------------------------------------------------------*/
  294.     /* Code Body                                                      */
  295.     /*----------------------------------------------------------------*/
  296.     return gCurrScreenID;
  297. }
  298. /*****************************************************************************
  299.  * FUNCTION
  300.  *  GetHelpStringID
  301.  * DESCRIPTION
  302.  *  return the current STRING ID
  303.  *  corresponding to the screen ID
  304.  * PARAMETERS
  305.  *  currScrenID     [IN]        
  306.  * RETURNS
  307.  *  void
  308.  *****************************************************************************/
  309. U16 GetHelpStringID(U16 currScrenID)
  310. {
  311.     /*----------------------------------------------------------------*/
  312.     /* Local Variables                                                */
  313.     /*----------------------------------------------------------------*/
  314.     U16 count = gMaxHelpStrings;
  315.     U8 flag = 0;
  316.     /*----------------------------------------------------------------*/
  317.     /* Code Body                                                      */
  318.     /*----------------------------------------------------------------*/
  319.     //MTK added by JL to avoid the infinite loop
  320.     //for(count; count >= 0; --count)
  321.     for (count = 0; count < gMaxHelpStrings; count++)
  322.     {
  323.         if (HelpArrMap[count].ScreenID == currScrenID)
  324.         {
  325.             flag = 1;
  326.             break;
  327.         }
  328.     }
  329.     if (flag)
  330.     {
  331.         return HelpArrMap[count].StringID;
  332.     }
  333.     return 0;
  334. }
  335. /*****************************************************************************
  336.  * FUNCTION
  337.  *  AddScreenHelp
  338.  * DESCRIPTION
  339.  *  Fills the HelpArrMap
  340.  * PARAMETERS
  341.  *  ScreenID        [IN]        
  342.  *  StringID        [IN]        
  343.  * RETURNS
  344.  *  void
  345.  *****************************************************************************/
  346. void AddScreenHelp(U16 ScreenID, U16 StringID)
  347. {
  348.     /*----------------------------------------------------------------*/
  349.     /* Local Variables                                                */
  350.     /*----------------------------------------------------------------*/
  351.     U16 count;
  352.     U8 flag = 1;
  353.     /*----------------------------------------------------------------*/
  354.     /* Code Body                                                      */
  355.     /*----------------------------------------------------------------*/
  356.     for (count = 0; count < gMaxHelpStrings; ++count)
  357.     {
  358.         if (HelpArrMap[count].ScreenID == ScreenID)
  359.         {
  360.             flag = 0;
  361.             break;
  362.         }
  363.     }
  364.     if (flag)
  365.     {
  366.         HelpArrMap[gMaxHelpStrings].ScreenID = ScreenID;
  367.         HelpArrMap[gMaxHelpStrings].StringID = StringID;
  368.         ++gMaxHelpStrings;
  369.     }
  370. }