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

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.  *
  37.  * Filename:
  38.  * ---------
  39.  * DateAndTime.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is intends for date/time setting application
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * removed!
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * removed!
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * removed!
  150.  *
  151.  * removed!
  152.  * removed!
  153.  * removed!
  154.  *
  155.  *------------------------------------------------------------------------------
  156.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  157.  *============================================================================
  158.  ****************************************************************************/
  159. /*
  160.  * Copyright Notice
  161.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  162.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  163.  *  (It is illegal to remove this copyright notice from this software or any
  164.  *  portion of it)
  165.  */
  166. /**************************************************************
  167.    FILENAME : DateAndTime.c
  168.    PURPOSE     : nil
  169.    REMARKS     : nil
  170.    AUTHOR      : Gurinder Singh Chhabra
  171.    DATE     : Oct 24, 2003
  172. **************************************************************/
  173. #ifndef _DATEANDTIME_C
  174. #define _DATEANDTIME_C
  175. /*  Include: MMI header file */
  176. #include "MMI_features.h"
  177. #include "stdC.h"
  178. #include "L4Dr1.h"
  179. #include "PixtelDataTypes.h"
  180. #include "NVRAMType.h"
  181. #include "NVRAMProt.h"
  182. #include "NVRAMEnum.h"
  183. #include "MainMenuDef.h"
  184. #include "AlarmFrameworkProt.h"
  185. #include "EventsGprot.h"
  186. #include "historyGprot.h"
  187. #include "wgui_categories.h"
  188. #include "wgui_datetime.h"
  189. #include "wgui_categories_sublcd.h"
  190. #include "Globaldefs.h"
  191. #include "IdleAppDef.h"
  192. #include "HardwareEvents.h"
  193. #include "DebugInitDef.h"
  194. #include "AudioInc.h"
  195. #include "Thrdosinterface.h"
  196. #include "OSThreadInterfaceGprot.h"
  197. #include "CallsDefs.h"
  198. #include "ProtocolEvents.h"
  199. #include "settingstructs.h"
  200. #include "SettingsGexdcl.h"
  201. #include "settinggprots.h"
  202. #include "settingprot.h"
  203. #include "SimDetectionGprot.h"
  204. #include "QueueGprot.h"
  205. #include "ProtocolEvents.h"
  206. #include "SettingProfile.h"
  207. #include "L4Dr.h"
  208. #include "CommonScreens.h"
  209. #include "worldclock.h"
  210. #include "AlarmGprot.h"
  211. #include "IdleAppProt.h"
  212. #include "DateTimeGprot.h"
  213. #include "WallpaperDefs.h"
  214. #include "DownloadDefs.h"
  215. #include "ScreenSaverDefs.h"
  216. #include "PhoneSetup.h"
  217. #include "PhoneSetupGprots.h"
  218. #include "NITZ.h"
  219. #include "wgui_inline_edit.h"   /* for MAX_INLINE_ITEMS */
  220. /*  Include: PS header file */
  221. /* 
  222.  * Define
  223.  */
  224. #define NUM_CITYS (NUMBER_OF_CITY-1)
  225. #define MAX_CITY_NUM 100
  226. #define DOUBLE_DIGIT 10
  227. #define MMI_DT_YEAR_BOUNDARY 30
  228. typedef enum
  229. {
  230. #ifndef __MMI_HIDE_HOMECITY__
  231.     PHNSET_DT_MNU_HOMECT,
  232. #endif 
  233. #ifndef __MMI_SEPARATE_DT_SETTING__
  234.     PHNSET_DT_MNU_DT,
  235.     PHNSET_DT_MNU_DATEANDFORMAT = PHNSET_DT_MNU_DT,
  236.     PHNSET_DT_MNU_FMT,
  237.     PHNSET_DT_MNU_TIMEANDFORMAT = PHNSET_DT_MNU_FMT,
  238. #else /* __MMI_SEPARATE_DT_SETTING__ */ 
  239.     PHNSET_DT_MNU_DT,
  240.     PHNSET_DT_MNU_FMT,
  241.     PHNSET_DT_MNU_DATEANDFORMAT,
  242.     PHNSET_DT_MNU_TIMEANDFORMAT,
  243. #endif /* __MMI_SEPARATE_DT_SETTING__ */ 
  244. #if (defined(__MMI_NITZ__) && defined(__MMI_AUTOTIMEZONE_IN_DATEANDTIME__))
  245.     PHNSET_DT_MNU_NITZ,
  246. #endif 
  247.     PHNSET_DT_MNU_LAST
  248. } phnset_DT_menu_enum;
  249. #ifndef YEARFORMATE
  250. #define YEARFORMATE 2000
  251. #endif 
  252. #ifndef NEGATIVE
  253. #define NEGATIVE 0
  254. #endif 
  255. #ifndef POSITIVE
  256. #define POSITIVE 1
  257. #endif 
  258. /* 
  259.  * Typedef 
  260.  */
  261. /* 
  262.  * Local Variable
  263.  */
  264. static U8 *date_formats[NUM_DATE_FORMATS];
  265. static U8 *time_formats[NUM_TIME_FORMATS];
  266. /* static U8 *menu_time_date_list[PHNSET_DT_MNU_LAST]; */
  267. static U8 *DSTString[2];
  268. static U8 *homeCityDataPtr[MAX_CITY_NUM]; 
  269. /* 
  270.  * Global Variable
  271.  */
  272. extern MYTIME MyTime;
  273. extern BOOL SetFromAT;
  274. extern rtc_format_struct gclockData;
  275. extern U8 g_dst;
  276. /* 
  277.  * Global Function
  278.  */
  279. extern void EntryIdleScreen(void);
  280. extern void DateTimerProc(void);
  281. /* extern void updateSPOFDateChanged(void) ; */
  282. extern void updateAlarmsDateChanged(void);
  283. extern FLOAT GetTimeZone(U8 cityIndex);
  284. #ifdef __MMI_TODOLIST__
  285. extern void InitToDoListApp(void);
  286. #endif 
  287. /* 
  288.  * Time and Date
  289.  */
  290. /*****************************************************************************
  291.  * FUNCTION
  292.  *  HighlightPhnsetTimeAndDate
  293.  * DESCRIPTION
  294.  *  This function is Highlight handler for Phonesetup-> Time and Date
  295.  *  Follow functions: EntryPhnsetTimeAndDate
  296.  * PARAMETERS
  297.  *  void
  298.  * RETURNS
  299.  *  void
  300.  *****************************************************************************/
  301. void HighlightPhnsetTimeAndDate(void)
  302. {
  303.     /*----------------------------------------------------------------*/
  304.     /* Local Variables                                                */
  305.     /*----------------------------------------------------------------*/
  306.     /*----------------------------------------------------------------*/
  307.     /* Code Body                                                      */
  308.     /*----------------------------------------------------------------*/
  309.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  310.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  311.     SetLeftSoftkeyFunction(EntryPhnsetTimeAndDate, KEY_EVENT_UP);
  312.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  313.     SetKeyHandler(EntryPhnsetTimeAndDate, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  314.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  315.     /* datetimeindex=0; */
  316.     g_phnset_cntx_p->curHightlightItem = 0;
  317. }
  318. /*****************************************************************************
  319.  * FUNCTION
  320.  *  EntryPhnsetTimeAndDate
  321.  * DESCRIPTION
  322.  *  This function is Entry function for Phonesetup->Time and Date
  323.  *  Following functions:
  324.  * PARAMETERS
  325.  *  void
  326.  * RETURNS
  327.  *  void
  328.  *****************************************************************************/
  329. void EntryPhnsetTimeAndDate(void)
  330. {
  331.     /*----------------------------------------------------------------*/
  332.     /* Local Variables                                                */
  333.     /*----------------------------------------------------------------*/
  334.     U8 *guiBuffer;                          /* Buffer holding history data */
  335.     U16 nNumofItem = 0;
  336.     U8 *pop_up_datetime[MAX_SUB_MENUS];     /* Pointers to HintHandlers */
  337.     U16 menu_time_date_list[MAX_SUB_MENUS]; /* Stores the strings id of submenus returned */
  338.     /*----------------------------------------------------------------*/
  339.     /* Code Body                                                      */
  340.     /*----------------------------------------------------------------*/
  341.     /* Call Exit Handler */
  342.     EntryNewScreen(SCR9041_TIMEANDDATE, ExitPhnsetTimeAndDate, EntryPhnsetTimeAndDate, NULL);
  343.     /* Get current screen to gui buffer  for history purposes */
  344.     guiBuffer = GetCurrGuiBuffer(SCR9041_TIMEANDDATE);
  345.     /* Retrieve no of child of menu item to be displayed */
  346.     nNumofItem = GetNumOfChild_Ext(MENU9141_TIME_AND_DATE);
  347.     /* Retrieve string ids in sequence of given menu item to be displayed */
  348.     GetSequenceStringIds_Ext(MENU9141_TIME_AND_DATE, menu_time_date_list);
  349.     /* Set current parent id */
  350.     SetParentHandler(MENU9141_TIME_AND_DATE);
  351.     /* Construct Dynamic Menu list */
  352. #if 0
  353. #ifndef __MMI_HIDE_HOMECITY__
  354. /* under construction !*/
  355. #endif
  356. /* under construction !*/
  357. /* under construction !*/
  358. /* under construction !*/
  359. /* under construction !*/
  360. #if (defined(__MMI_NITZ__) && defined(__MMI_AUTOTIMEZONE_IN_DATEANDTIME__) )
  361. /* under construction !*/
  362. #endif
  363. #endif /* 0 */ 
  364.     /* Register highlight handler to be called in menu screen */
  365.     /* RegisterHighlightHandler(PhnsetTimeAndDateHiliteHandler); */
  366.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  367.     /* if this list is not constructed before entry home city then,after bootup popup will be empty--vanita */
  368.     ConstructHintsList(MENU9141_TIME_AND_DATE, pop_up_datetime);
  369.     /* Display Category Screen */
  370.     ShowCategory52Screen(
  371.         STR_MENU9141_TIME_AND_DATE,
  372.         MAIN_MENU_TITLE_SETTINGS_ICON,
  373.         STR_GLOBAL_OK,
  374.         IMG_GLOBAL_OK,
  375.         STR_GLOBAL_BACK,
  376.         IMG_GLOBAL_BACK,
  377.         nNumofItem,
  378.         menu_time_date_list,
  379.         (PU16) gIndexIconsImageList,
  380.         pop_up_datetime,
  381.         0,
  382.         g_phnset_cntx_p->curHightlightItem,
  383.         guiBuffer);
  384.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  385.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  386. }
  387. /*****************************************************************************
  388. * FUNCTION
  389. *  mmi_dt_set_unset_dst
  390. * DESCRIPTION
  391. *   This function is Highlight handler for Phonesetup-> Time and Date
  392. *   Follow functions: EntryPhnsetMainMenuStyle
  393. *
  394. * PARAMETERS
  395. *  a  IN/OUT 
  396. *  b  IN       
  397. * RETURNS
  398. *  void
  399. * GLOBALS AFFECTED
  400. *  NULL
  401. *****************************************************************************/
  402. #if 0
  403. /* under construction !*/
  404. /* under construction !*/
  405. #ifdef MMI_ON_HARDWARE_P
  406. /* under construction !*/
  407. /* under construction !*/
  408. /* under construction !*/
  409. /* under construction !*/
  410. /* under construction !*/
  411. /* under construction !*/
  412. /* under construction !*/
  413. /* under construction !*/
  414. /* under construction !*/
  415. /* under construction !*/
  416. /* under construction !*/
  417. /* under construction !*/
  418. /* under construction !*/
  419. /* under construction !*/
  420. /* under construction !*/
  421. /* under construction !*/
  422. /* under construction !*/
  423. /* under construction !*/
  424. /* under construction !*/
  425. /* under construction !*/
  426. /* under construction !*/
  427. /* under construction !*/
  428. /* under construction !*/
  429. /* under construction !*/
  430. /* under construction !*/
  431. /* under construction !*/
  432. /* under construction !*/
  433. /* under construction !*/
  434. /* under construction !*/
  435. /* under construction !*/
  436. /* under construction !*/
  437. /* under construction !*/
  438. /* under construction !*/
  439. /* under construction !*/
  440. /* under construction !*/
  441. /* under construction !*/
  442. /* under construction !*/
  443. /* under construction !*/
  444. /* under construction !*/
  445. /* under construction !*/
  446. /* under construction !*/
  447. /* under construction !*/
  448. /* under construction !*/
  449. /* under construction !*/
  450. /* under construction !*/
  451. /* under construction !*/
  452. /* under construction !*/
  453. /* under construction !*/
  454. /* under construction !*/
  455. /* under construction !*/
  456. #endif
  457. /* under construction !*/
  458. #endif /* 0 */ 
  459. /*****************************************************************************
  460.  * FUNCTION
  461.  *  ExitPhnsetTimeAndDate
  462.  * DESCRIPTION
  463.  *  This function is Exit function for Phonesetup->Time and Date
  464.  *  Functionality:
  465.  * PARAMETERS
  466.  *  void
  467.  * RETURNS
  468.  *  void
  469.  *****************************************************************************/
  470. void ExitPhnsetTimeAndDate(void)
  471. {
  472. #if (defined(__MMI_NITZ__) && defined(__MMI_AUTOTIMEZONE_IN_DATEANDTIME__))
  473.     /*----------------------------------------------------------------*/
  474.     /* Local Variables                                                */
  475.     /*----------------------------------------------------------------*/
  476.     S16 error;
  477.     /*----------------------------------------------------------------*/
  478.     /* Code Body                                                      */
  479.     /*----------------------------------------------------------------*/
  480.     if (g_phnset_cntx_p->NITZDirtyFlag == TRUE)
  481.     {
  482.         WriteValue(NVRAM_SETTING_AUTOUPDATE_DT_TIME, &(g_phnset_cntx_p->curNITZStatus), DS_BYTE, &error);
  483.         g_phnset_cntx_p->NITZDirtyFlag = FALSE;
  484.     }
  485. #endif /* (defined(__MMI_NITZ__) && defined(__MMI_AUTOTIMEZONE_IN_DATEANDTIME__)) */ /* #if (defined(__MMI_NITZ__) && defined(__MMI_AUTOTIMEZONE_IN_DATEANDTIME__) ) */
  486. }
  487. #if 0
  488. /* under construction !*/
  489. /* under construction !*/
  490. /* under construction !*/
  491. /* under construction !*/
  492. /* under construction !*/
  493. /* under construction !*/
  494. /* under construction !*/
  495. /* under construction !*/
  496. /* under construction !*/
  497. /* under construction !*/
  498. /* under construction !*/
  499. /* under construction !*/
  500. /* under construction !*/
  501. /* under construction !*/
  502. /* under construction !*/
  503. /* under construction !*/
  504. /* under construction !*/
  505. /* under construction !*/
  506. /* under construction !*/
  507. #ifndef __MMI_HIDE_HOMECITY__
  508. /* under construction !*/
  509. /* under construction !*/
  510. /* under construction !*/
  511. /* under construction !*/
  512. /* under construction !*/
  513. /* under construction !*/
  514. /* under construction !*/
  515. #endif
  516. /* under construction !*/
  517. /* under construction !*/
  518. /* under construction !*/
  519. /* under construction !*/
  520. /* under construction !*/
  521. /* under construction !*/
  522. /* under construction !*/
  523. /* under construction !*/
  524. /* under construction !*/
  525. /* under construction !*/
  526. /* under construction !*/
  527. /* under construction !*/
  528. /* under construction !*/
  529. /* under construction !*/
  530. /* under construction !*/
  531. /* under construction !*/
  532. /* under construction !*/
  533. /* under construction !*/
  534. /* under construction !*/
  535. /* under construction !*/
  536. #if (defined(__MMI_NITZ__) && defined(__MMI_AUTOTIMEZONE_IN_DATEANDTIME__) )
  537. /* under construction !*/
  538. /* under construction !*/
  539. /* under construction !*/
  540. #endif
  541. /* under construction !*/
  542. /* under construction !*/
  543. /* under construction !*/
  544. /* under construction !*/
  545. /* under construction !*/
  546. /* under construction !*/
  547. /* under construction !*/
  548. /* under construction !*/
  549. /* under construction !*/
  550. /* under construction !*/
  551. /* under construction !*/
  552. /* under construction !*/
  553. /* under construction !*/
  554. /* under construction !*/
  555. /* under construction !*/
  556. /* under construction !*/
  557. /* under construction !*/
  558. /* under construction !*/
  559. /* under construction !*/
  560. /* under construction !*/
  561. /* under construction !*/
  562. /* under construction !*/
  563. /* under construction !*/
  564. #endif /* 0 */ 
  565. /* 
  566.  * Set Date/Time
  567.  */
  568. /*****************************************************************************
  569.  * FUNCTION
  570.  *  HintPhnsetTimeAndDate
  571.  * DESCRIPTION
  572.  *  This function is hint handling function
  573.  *  for Phonesetup -> Time and Data ( Set Home City, Auto Update Date and Time)
  574.  *  Functionality:
  575.  * PARAMETERS
  576.  *  index       [IN]        
  577.  * RETURNS
  578.  *  void
  579.  *****************************************************************************/
  580. void HintPhnsetTimeAndDate(U16 index)
  581. {
  582.     /*----------------------------------------------------------------*/
  583.     /* Local Variables                                                */
  584.     /*----------------------------------------------------------------*/
  585.     /*----------------------------------------------------------------*/
  586.     /* Code Body                                                      */
  587.     /*----------------------------------------------------------------*/
  588.     if (index == 0) /* Time and Date */
  589.     {
  590.         pfnUnicodeStrcpy((S8*) hintData[index], (S8*) g_phnset_cntx_p->CurHomeCityStrPtr);
  591.     }
  592. #if( defined(__MMI_AUTOTIMEZONE_IN_DATEANDTIME__) && defined(__MMI_NITZ__))
  593.     else if (index == 3)    /* NITZ */
  594.     {
  595.         if (g_phnset_cntx_p->curNITZStatus)
  596.         {
  597.             pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_GLOBAL_ON));
  598.             Category53ChangeItemDescription(index, hintData[index]);
  599.             ChangeLeftSoftkey(STR_GLOBAL_OFF, 0);
  600.         }
  601.         else
  602.         {
  603.             pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_GLOBAL_OFF));
  604.             Category53ChangeItemDescription(index, hintData[index]);
  605.             ChangeLeftSoftkey(STR_GLOBAL_ON, 0);
  606.         }
  607.         RedrawCategoryFunction();
  608.     }
  609. #endif /* ( defined(__MMI_AUTOTIMEZONE_IN_DATEANDTIME__) && defined(__MMI_NITZ__)) */ /* #if( defined( __MMI_AUTOTIMEZONE_IN_DATEANDTIME__) && defined(__MMI_NITZ__) ) */
  610.     else    /* Others, no hint */
  611.     {
  612.         pfnUnicodeStrcpy((S8*) hintData[index], NULL);
  613.     }
  614. }
  615. /*****************************************************************************
  616.  * FUNCTION
  617.  *  HighlightPhnsetSetHomeCity
  618.  * DESCRIPTION
  619.  *  This function is Highlight handler for Phonesetup-> Time And Date -> Set Home City
  620.  *  Follow functions: EntryPhnsetSetHomeCity
  621.  * PARAMETERS
  622.  *  void
  623.  * RETURNS
  624.  *  void
  625.  *****************************************************************************/
  626. #ifndef __MMI_HIDE_HOMECITY__
  627. void HighlightPhnsetSetHomeCity(void)
  628. {
  629.     /*----------------------------------------------------------------*/
  630.     /* Local Variables                                                */
  631.     /*----------------------------------------------------------------*/
  632.     /*----------------------------------------------------------------*/
  633.     /* Code Body                                                      */
  634.     /*----------------------------------------------------------------*/
  635.     /* datetimeindex = 0; */
  636.     g_phnset_cntx_p->curHightlightItem = PHNSET_DT_MNU_HOMECT;
  637. #ifndef __MMI_WC_TZ_SUPPORT__
  638. SetLeftSoftkeyFunction(EntryPhnsetSetHomeCity,KEY_EVENT_UP);
  639.     SetKeyHandler(EntryPhnsetSetHomeCity, KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
  640. #else
  641.     SetLeftSoftkeyFunction(EntryWcBrowseCity,KEY_EVENT_UP);
  642.     SetKeyHandler(EntryWcBrowseCity, KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
  643. #endif
  644.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);    /* Robin 1201 */
  645. }
  646. #endif /* __MMI_HIDE_HOMECITY__ */ 
  647. /*****************************************************************************
  648.  * FUNCTION
  649.  *  PhnsetTimeEditorCallback
  650.  * DESCRIPTION
  651.  *  This function is to fills the Data to set the time in case Set Time is called from AT.
  652.  *  Functionality:
  653.  * PARAMETERS
  654.  *  par1        [IN]        
  655.  *  par2        [IN]        
  656.  *  par3        [IN]        
  657.  *  par4        [IN]        
  658.  * RETURNS
  659.  *  void
  660.  *****************************************************************************/
  661. /* static void setting_timeedit_callback(U8 *par1, U8 *par2,U8 *par3,U8 *par4) */
  662. void PhnsetTimeEditorCallback(U8 *par1, U8 *par2, U8 *par3, U8 *par4)
  663. {
  664.     /*----------------------------------------------------------------*/
  665.     /* Local Variables                                                */
  666.     /*----------------------------------------------------------------*/
  667.     /*----------------------------------------------------------------*/
  668.     /* Code Body                                                      */
  669.     /*----------------------------------------------------------------*/
  670.     if ((par2[0] == 0 && par3[0] == 0))
  671.     {
  672.     #ifdef __UCS2_ENCODING
  673.         pfnUnicodeStrcat((PS8) par1, (PS8) gHour);
  674.         pfnUnicodeStrcat((PS8) par1, (PS8) ":");
  675.         pfnUnicodeStrcat((PS8) par1, (PS8) gMinute);
  676.     #else /* __UCS2_ENCODING */ 
  677.         strcat((PS8) par1, (PS8) gHour);
  678.         strcat((PS8) par1, (PS8) "/");
  679.         strcat((PS8) par1, (PS8) gMinute);
  680.     #endif /* __UCS2_ENCODING */ 
  681.     }
  682.     else
  683.     {
  684.     #ifdef __UCS2_ENCODING
  685.         pfnUnicodeStrcpy((PS8) par1, (PS8) par2);
  686.         pfnUnicodeStrcat((PS8) par1, (PS8) ":");
  687.         pfnUnicodeStrcat((PS8) par1, (PS8) par3);
  688.     #else /* __UCS2_ENCODING */ 
  689.         strcpy((PS8) par1, (PS8) par2);
  690.         strcat((PS8) par1, (PS8) ":");
  691.         strcat((PS8) par1, (PS8) par3);
  692.     #endif /* __UCS2_ENCODING */ 
  693.     }
  694. }
  695. /*****************************************************************************
  696.  * FUNCTION
  697.  *  PhnsetDateEditorCallback
  698.  * DESCRIPTION
  699.  *  This function is to fills the Data to set the time in case Set Time is called from AT.
  700.  *  Functionality:
  701.  * PARAMETERS
  702.  *  par1        [IN]        
  703.  *  par2        [IN]        
  704.  *  par3        [IN]        
  705.  *  par4        [IN]        
  706.  * RETURNS
  707.  *  void
  708.  *****************************************************************************/
  709. /* void setting_dateedit_callback(U8 *par1, U8 *par2,U8 *par3,U8 *par4) */
  710. void PhnsetDateEditorCallback(U8 *par1, U8 *par2, U8 *par3, U8 *par4)
  711. {
  712.     /*----------------------------------------------------------------*/
  713.     /* Local Variables                                                */
  714.     /*----------------------------------------------------------------*/
  715.     /*----------------------------------------------------------------*/
  716.     /* Code Body                                                      */
  717.     /*----------------------------------------------------------------*/
  718.     if ((par2[0] == 0 && par3[0] == 0))
  719.     {
  720.     #ifdef __UCS2_ENCODING
  721.         pfnUnicodeStrcpy((PS8) par1, (PS8) gYear);
  722.         pfnUnicodeStrcat((PS8) par1, (PS8) "/");
  723.         pfnUnicodeStrcat((PS8) par1, (PS8) gMonth);
  724.         pfnUnicodeStrcat((PS8) par1, (PS8) "/");
  725.         pfnUnicodeStrcat((PS8) par1, (PS8) gDate);
  726.     #else /* __UCS2_ENCODING */ 
  727.         strcpy((PS8) par1, (PS8) gYear);
  728.         strcat((PS8) par1, (PS8) "/");
  729.         strcat((PS8) par1, (PS8) gMonth);
  730.         strcat((PS8) par1, (PS8) "/");
  731.         strcat((PS8) par1, (PS8) gDate);
  732.     #endif /* __UCS2_ENCODING */ 
  733.     }
  734.     else
  735.     {
  736.     #ifdef __UCS2_ENCODING
  737.         pfnUnicodeStrcpy((PS8) par1, (PS8) par4);
  738.         pfnUnicodeStrcat((PS8) par1, (PS8) "/");
  739.         pfnUnicodeStrcat((PS8) par1, (PS8) par3);
  740.         pfnUnicodeStrcat((PS8) par1, (PS8) "/");
  741.         pfnUnicodeStrcat((PS8) par1, (PS8) par2);
  742.     #else /* __UCS2_ENCODING */ 
  743.         strcpy((PS8) par1, (PS8) par4);
  744.         strcat((PS8) par1, (PS8) "/");
  745.         strcat((PS8) par1, (PS8) par3);
  746.         strcat((PS8) par1, (PS8) "/");
  747.         strcat((PS8) par1, (PS8) par2);
  748.     #endif /* __UCS2_ENCODING */ 
  749.     }
  750. }
  751. /*****************************************************************************
  752.  * FUNCTION
  753.  *  HighlightPhnsetSetDST
  754.  * DESCRIPTION
  755.  *  This function is Highlight handler for Phonesetup-> Time And Date -> Set Format
  756.  *  Follow functions: EntryPhnsetSetFormat
  757.  * PARAMETERS
  758.  *  index       [IN]        
  759.  * RETURNS
  760.  *  void
  761.  *****************************************************************************/
  762. void HighlightPhnsetSetDST(S32 index)
  763. {
  764.     /*----------------------------------------------------------------*/
  765.     /* Local Variables                                                */
  766.     /*----------------------------------------------------------------*/
  767.     /*----------------------------------------------------------------*/
  768.     /* Code Body                                                      */
  769.     /*----------------------------------------------------------------*/
  770.     /* no change */
  771.     if (index != g_phnset_cntx_p->prevDST)
  772.     {
  773.         MYTIME incTime;
  774.         MYTIME currTime;
  775.         MYTIME result;
  776.         U8 dummyString[5];  /* max length is of year 4 */
  777.         memset(&incTime, 0, sizeof(MYTIME));
  778.         memset(&currTime, 0, sizeof(MYTIME));
  779.         incTime.nHour = 1;
  780.         currTime.nHour = (U8) gui_atoi((UI_string_type) gHour);
  781.         currTime.nMin = (U8) gui_atoi((UI_string_type) gMinute);
  782.         currTime.nMonth = (U8) gui_atoi((UI_string_type) gMonth);
  783.         currTime.nDay = (U8) gui_atoi((UI_string_type) gDate);
  784.         currTime.nYear = (U16) gui_atoi((UI_string_type) gYear);
  785.         if (index == 0)
  786.         {
  787.             /* on -> off */
  788.             DecrementTime(currTime, incTime, &result);
  789.         }
  790.         else
  791.         {
  792.             /* off -> on */
  793.             IncrementTime(currTime, incTime, &result);
  794.         }
  795.         if (result.nYear > 2030 || result.nYear < 2000)
  796.         {
  797.             playRequestedTone(ERROR_TONE);
  798.             return;
  799.         }
  800.         sprintf(gHour, "%02d", result.nHour);
  801.         sprintf(gMinute, "%02d", result.nMin);
  802.         sprintf(gYear, "%2d", result.nYear);
  803.         sprintf(gMonth, "%02d", result.nMonth);
  804.         sprintf(gDate, "%02d", result.nDay);
  805.         strcpy((PS8) dummyString, gHour);
  806.         AnsiiToUnicodeString((PS8) gHour, (PS8) dummyString);
  807.         strcpy((PS8) dummyString, gMinute);
  808.         AnsiiToUnicodeString((PS8) gMinute, (PS8) dummyString);
  809.         strcpy((PS8) dummyString, gYear);
  810.         AnsiiToUnicodeString((PS8) gYear, (PS8) dummyString);
  811.         strcpy((PS8) dummyString, gMonth);
  812.         AnsiiToUnicodeString((PS8) gMonth, (PS8) dummyString);
  813.         strcpy((PS8) dummyString, gDate);
  814.         AnsiiToUnicodeString((PS8) gDate, (PS8) dummyString);
  815.         g_phnset_cntx_p->prevDST = index;
  816.     }
  817.     RedrawCategory57Screen();
  818. }
  819. static U16 setting_date_time_list_of_icons[NUM_ITEMS_DATE_TIME_ENTRY_SCREEN] = 
  820. {
  821.     IMG_TIME, IMG_TIME_AND_DATE_BLANK, IMG_CAL, IMG_TIME_AND_DATE_BLANK, SUN_ICON, IMG_TIME_AND_DATE_BLANK
  822. };
  823. static U16 setting_date_time_format_list_of_icons[] = 
  824. {
  825.     IMG_TIME, IMG_TIME_AND_DATE_BLANK, IMG_CAL, IMG_TIME_AND_DATE_BLANK
  826. };
  827. #ifndef __MMI_SEPARATE_DT_SETTING__
  828. /*****************************************************************************
  829.  * FUNCTION
  830.  *  HighlightPhnsetSetDT
  831.  * DESCRIPTION
  832.  *  This function is Highlight handler for Phonesetup-> Time And Date -> Set Time/Date
  833.  *  Follow functions: EntryPhnsetSetDT
  834.  * PARAMETERS
  835.  *  void
  836.  * RETURNS
  837.  *  void
  838.  *****************************************************************************/
  839. void HighlightPhnsetSetDT(void)
  840. {
  841.     /*----------------------------------------------------------------*/
  842.     /* Local Variables                                                */
  843.     /*----------------------------------------------------------------*/
  844.     /*----------------------------------------------------------------*/
  845.     /* Code Body                                                      */
  846.     /*----------------------------------------------------------------*/
  847.     /* datetimeindex = 1; */
  848.     g_phnset_cntx_p->curHightlightItem = PHNSET_DT_MNU_DT;
  849.     memset(gHour, 0, sizeof(gHour));
  850.     memset(gMinute, 0, sizeof(gMinute));
  851.     memset(gDate, 0, sizeof(gDate));
  852.     memset(gMonth, 0, sizeof(gMonth));
  853.     memset(gYear, 0, sizeof(gYear));
  854.     //highlightedDateSetItem =0;
  855.     //g_phnset_cntx_p->curHightlightItem = 0;
  856.     SetLeftSoftkeyFunction(EntryPhnsetSetDT, KEY_EVENT_UP);
  857.     SetKeyHandler(EntryPhnsetSetDT, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  858.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);    /* Robin 1201 */
  859. }
  860. /*****************************************************************************
  861.  * FUNCTION
  862.  *  HighlightPhnsetSetFormat
  863.  * DESCRIPTION
  864.  *  This function is Highlight handler for Phonesetup-> Time And Date -> Set Format
  865.  *  Follow functions: EntryPhnsetSetFormat
  866.  * PARAMETERS
  867.  *  void
  868.  * RETURNS
  869.  *  void
  870.  *****************************************************************************/
  871. void HighlightPhnsetSetFormat(void)
  872. {
  873.     /*----------------------------------------------------------------*/
  874.     /* Local Variables                                                */
  875.     /*----------------------------------------------------------------*/
  876.     /*----------------------------------------------------------------*/
  877.     /* Code Body                                                      */
  878.     /*----------------------------------------------------------------*/
  879.     /* datetimeindex = 2; */
  880.     g_phnset_cntx_p->curHightlightItem = PHNSET_DT_MNU_FMT;
  881.     /* highlightedDateFormatItem = 0; */
  882.     SetLeftSoftkeyFunction(EntryPhnsetSetFormat, KEY_EVENT_UP);
  883.     SetKeyHandler(EntryPhnsetSetFormat, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  884.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);    /* Robin 1201 */
  885. }
  886. #endif /* __MMI_SEPARATE_DT_SETTING__ */ 
  887. /*****************************************************************************
  888.  * FUNCTION
  889.  *  PhnsetInlineSetDTHiliteHdlr
  890.  * DESCRIPTION
  891.  *  This function is Inline line editor Highlight handler for Phonesetup-> Time and Date -> Set Time/Date
  892.  *  Follow functions: PhnsetSetDT
  893.  * PARAMETERS
  894.  *  currId      [IN]        
  895.  * RETURNS
  896.  *  void
  897.  *****************************************************************************/
  898. static void PhnsetInlineSetDTHiliteHdlr(S32 currId)
  899. {
  900.     /*----------------------------------------------------------------*/
  901.     /* Local Variables                                                */
  902.     /*----------------------------------------------------------------*/
  903.     /*----------------------------------------------------------------*/
  904.     /* Code Body                                                      */
  905.     /*----------------------------------------------------------------*/
  906.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  907.     SetCategory57LeftSoftkeyFunction(PhnsetSetDT);
  908.     g_phnset_cntx_p->curHightlightItem = (U8) currId;
  909. }
  910. /*****************************************************************************
  911.  * FUNCTION
  912.  *  EntryPhnsetSetDT
  913.  * DESCRIPTION
  914.  *  Set Date And Time Entry Function
  915.  *  
  916.  *  This Screen Uses Category 57 and Text Box Edit For Data Entry.
  917.  * PARAMETERS
  918.  *  void
  919.  * RETURNS
  920.  *  void
  921.  *****************************************************************************/
  922. void EntryPhnsetSetDT(void)
  923. {
  924.     /*----------------------------------------------------------------*/
  925.     /* Local Variables                                                */
  926.     /*----------------------------------------------------------------*/
  927.     U8 *guiBuffer;
  928.     U8 *inputBuffer;        /* added for inline edit history */
  929.     U16 inputBufferSize;    /* added for inline edit history */
  930.     extern wgui_inline_item wgui_inline_items[];
  931.     /*----------------------------------------------------------------*/
  932.     /* Code Body                                                      */
  933.     /*----------------------------------------------------------------*/
  934.     EntryNewScreen(SCR_ID_PHNSET_SET_DT, ExitPhnsetSetDT, NULL, NULL);
  935.     guiBuffer = GetCurrGuiBuffer(SCR_ID_PHNSET_SET_DT);
  936.     InitializeCategory57Screen();
  937.     PhnsetSetDTFillInlineStruct((void*)wgui_inline_items);
  938.     inputBuffer = GetCurrNInputBuffer(SCR_ID_PHNSET_SET_DT, &inputBufferSize);  /* added for inline edit history */
  939.     if (inputBuffer != NULL)
  940.     {
  941.         SetCategory57Data(wgui_inline_items, NUM_ITEMS_DATE_TIME_ENTRY_SCREEN, inputBuffer);
  942.     }
  943.     SetLeftSoftkeyFunction(PhnsetSetDT, KEY_EVENT_UP);
  944.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  945.     RegisterHighlightHandler(PhnsetInlineSetDTHiliteHdlr);
  946.     ShowCategory57Screen(
  947.         STR_ID_PHNSET_SET_DT,
  948.         IMG_SCR_SETTING_CAPTION,
  949.         STR_GLOBAL_OK,
  950.         IMG_GLOBAL_OK,
  951.         STR_GLOBAL_BACK,
  952.         IMG_GLOBAL_BACK,
  953.         NUM_ITEMS_DATE_TIME_ENTRY_SCREEN,
  954.         setting_date_time_list_of_icons,
  955.         wgui_inline_items,
  956.         0,
  957.         guiBuffer);
  958.     DisableCategory57ScreenDone();
  959.     SetCategory57RightSoftkeyFunctions(PhnsetSetDT, GoBackHistory);
  960. }
  961. /*****************************************************************************
  962.  * FUNCTION
  963.  *  ExitPhnsetSetDT
  964.  * DESCRIPTION
  965.  *  This function is Exit function for Phonesetup-> Time and Date -> Set Time/Date
  966.  *  Functionality:
  967.  * PARAMETERS
  968.  *  void
  969.  * RETURNS
  970.  *  void
  971.  *****************************************************************************/
  972. void ExitPhnsetSetDT(void)
  973. {
  974.     /*----------------------------------------------------------------*/
  975.     /* Local Variables                                                */
  976.     /*----------------------------------------------------------------*/
  977.     history Scr;
  978.     S16 nHistory = 0;
  979.     U16 inputBufferSize;    /* added for inline edit history */
  980.     /*----------------------------------------------------------------*/
  981.     /* Code Body                                                      */
  982.     /*----------------------------------------------------------------*/
  983.     stopRequestedTone(ERROR_TONE);
  984.     Scr.scrnID = SCR_ID_PHNSET_SET_DT;
  985.     CloseCategory57Screen();
  986.     Scr.entryFuncPtr = EntryPhnsetSetDT;
  987.     pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) & nHistory);
  988.     GetCategory57History(Scr.guiBuffer);
  989.     inputBufferSize = (U16) GetCategory57DataSize();    /* added for inline edit history */
  990.     GetCategory57Data((U8*) Scr.inputBuffer);           /* added for inline edit history */
  991.     AddNHistory(Scr, (U16) inputBufferSize);            /* added for inline edit history */
  992. }
  993. /*****************************************************************************
  994.  * FUNCTION
  995.  *  PhnsetSetDTFillInlineStruct
  996.  * DESCRIPTION
  997.  *  This function is to fill inline selection structure for Phonesetup-> Time and Date -> Set Time/Date
  998.  *  Functionality:
  999.  * PARAMETERS
  1000.  *  p       [IN]        
  1001.  * RETURNS
  1002.  *  void
  1003.  *****************************************************************************/
  1004. void PhnsetSetDTFillInlineStruct(void *p)
  1005. {
  1006.     /*----------------------------------------------------------------*/
  1007.     /* Local Variables                                                */
  1008.     /*----------------------------------------------------------------*/
  1009.     MYTIME currTime;
  1010.     U8 dummyString[5];  /* max length is of year 4 */
  1011.     wgui_inline_item *setting_inline_edit_items = (wgui_inline_item*) p;
  1012.     /*----------------------------------------------------------------*/
  1013.     /* Code Body                                                      */
  1014.     /*----------------------------------------------------------------*/
  1015.     GetDateTime(&currTime);
  1016.     sprintf(gHour, "%02d", currTime.nHour);
  1017.     sprintf(gMinute, "%02d", currTime.nMin);
  1018.     sprintf(gYear, "%2d", currTime.nYear);
  1019.     sprintf(gMonth, "%02d", currTime.nMonth);
  1020.     sprintf(gDate, "%02d", currTime.nDay);
  1021.     strcpy((PS8) dummyString, gHour);
  1022.     AnsiiToUnicodeString((PS8) gHour, (PS8) dummyString);
  1023.     strcpy((PS8) dummyString, gMinute);
  1024.     AnsiiToUnicodeString((PS8) gMinute, (PS8) dummyString);
  1025.     strcpy((PS8) dummyString, gYear);
  1026.     AnsiiToUnicodeString((PS8) gYear, (PS8) dummyString);
  1027.     strcpy((PS8) dummyString, gMonth);
  1028.     AnsiiToUnicodeString((PS8) gMonth, (PS8) dummyString);
  1029.     strcpy((PS8) dummyString, gDate);
  1030.     AnsiiToUnicodeString((PS8) gDate, (PS8) dummyString);
  1031.     DSTString[0] = (PU8) GetString(STR_GLOBAL_OFF);
  1032.     DSTString[1] = (PU8) GetString(STR_GLOBAL_ON);
  1033.     if (SetFromAT == FALSE)
  1034.     {
  1035.         S16 Err;
  1036.         SetInlineItemActivation(&(setting_inline_edit_items[1]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, KEY_EVENT_UP);
  1037.         SetInlineItemActivation(&(setting_inline_edit_items[3]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, KEY_EVENT_UP);
  1038.         /* amanda dst */
  1039.         SetInlineItemActivation(&(setting_inline_edit_items[5]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, KEY_EVENT_UP);
  1040.         SetInlineItemCaption(&(setting_inline_edit_items[0]), (U8*) GetString(STR_ENTER_TIME_FORMAT_DISP_CAPTION));
  1041.         SetInlineItemTime(
  1042.             &(setting_inline_edit_items[1]),
  1043.             (U8*) gHour,
  1044.             (U8*) gMinute,
  1045.             g_phnset_cntx_p->AM_PM_flag,
  1046.             PhnsetTimeEditorCallback);
  1047.         SetInlineItemFullWidth(&setting_inline_edit_items[1]);
  1048.         EnableInlineItemBoundary(&setting_inline_edit_items[1]);
  1049.         RightJustifyInlineItem(&setting_inline_edit_items[1]);
  1050.         SetInlineItemCaption(&(setting_inline_edit_items[2]), (U8*) GetString(STR_ENTER_DATE_FORMAT_DISP_CAPTION));
  1051.         SetInlineItemDate(
  1052.             &(setting_inline_edit_items[3]),
  1053.             (U8*) gDate,
  1054.             (U8*) gMonth,
  1055.             (U8*) gYear,
  1056.             PhnsetDateEditorCallback);
  1057.         SetInlineItemFullWidth(&setting_inline_edit_items[3]);
  1058.         EnableInlineItemBoundary(&setting_inline_edit_items[3]);
  1059.         RightJustifyInlineItem(&setting_inline_edit_items[3]);
  1060.         set_inline_date_boundary(2030, 2000, 12, 1);
  1061.         /* amanda dst */
  1062.         ReadValue(NVRAM_SETTING_DT_DST, &(g_phnset_cntx_p->currentDST), DS_BYTE, &Err);
  1063.         SetInlineItemCaption(&(setting_inline_edit_items[4]), (U8*) GetString(STR_ID_PHNSET_SET_DST));
  1064.         SetInlineItemSelect(&(setting_inline_edit_items[5]), 2, (U8 **) DSTString, &g_phnset_cntx_p->currentDST);
  1065.         SetInlineItemFullWidth(&setting_inline_edit_items[5]);
  1066.         RegisterInlineSelectHighlightHandler(&setting_inline_edit_items[5], HighlightPhnsetSetDST);
  1067.         EnableInlineItemBoundary(&setting_inline_edit_items[5]);
  1068.         if (!IsScreenPresent(SCR_ID_PHNSET_SET_DT))
  1069.         {
  1070.             g_phnset_cntx_p->prevDST = g_phnset_cntx_p->currentDST;
  1071.         }
  1072.     }
  1073. }
  1074. /*****************************************************************************
  1075.  * FUNCTION
  1076.  *  PhnsetSetDT
  1077.  * DESCRIPTION
  1078.  *  This function is to set date and time for Phonesetup-> Time and Date -> Set Time/DAte
  1079.  *  Functionality:
  1080.  * PARAMETERS
  1081.  *  void
  1082.  * RETURNS
  1083.  *  void
  1084.  *****************************************************************************/
  1085. void PhnsetSetDT(void)
  1086. {
  1087.     /*----------------------------------------------------------------*/
  1088.     /* Local Variables                                                */
  1089.     /*----------------------------------------------------------------*/
  1090.     /*----------------------------------------------------------------*/
  1091.     /* Code Body                                                      */
  1092.     /*----------------------------------------------------------------*/
  1093.     if ((gui_atoi((UI_string_type) gHour) > 23) || (gui_atoi((UI_string_type) gMinute) > 59)
  1094.         || (gui_atoi((UI_string_type) gYear) > 2030) || (gui_atoi((UI_string_type) gYear) < 2000)
  1095.         || (gui_atoi((UI_string_type) gMonth) > 12) || (gui_atoi((UI_string_type) gMonth) < 1)
  1096.         || (gui_atoi((UI_string_type) gDate) > 31) ||
  1097.         (LastDayOfMonth((U8) gui_atoi((UI_string_type) gMonth), (U8) gui_atoi((UI_string_type) gYear)) <
  1098.          gui_atoi((UI_string_type) gDate)))
  1099.     {
  1100.         DisplayPopup((PU8) GetString(STR_SETTIME_UNFINISHED), IMG_GLOBAL_WARNING, 1, ST_NOTIFYDURATION, ERROR_TONE);
  1101.     }
  1102.     else
  1103.     {
  1104.         U8 flag;
  1105.         S16 error;
  1106.         ReadValue(NVRAM_SETTING_DT_DST, &flag, DS_BYTE, &error);
  1107.         if (flag != g_phnset_cntx_p->currentDST)
  1108.         {
  1109.             mmi_dt_set_dst((U8) g_phnset_cntx_p->currentDST);
  1110.         }
  1111.         PhnsetSendSetTimeReqMessage();
  1112.     }
  1113. }
  1114. /* 
  1115.  * Set Format
  1116.  */
  1117. /*****************************************************************************
  1118.  * FUNCTION
  1119.  *  EntryPhnsetSetFormat
  1120.  * DESCRIPTION
  1121.  *  This function is Entry function for Phonesetup-> Time and Date -> Set Format
  1122.  *  Following functions:
  1123.  * PARAMETERS
  1124.  *  void
  1125.  * RETURNS
  1126.  *  void
  1127.  *****************************************************************************/
  1128. void EntryPhnsetSetFormat(void)
  1129. {
  1130.     /*----------------------------------------------------------------*/
  1131.     /* Local Variables                                                */
  1132.     /*----------------------------------------------------------------*/
  1133.     U8 *guiBuffer;
  1134.     U8 *inputBuffer;        /* added for inline edit history */
  1135.     U16 inputBufferSize;    /* added for inline edit history */
  1136.     extern wgui_inline_item wgui_inline_items[];
  1137.     /*----------------------------------------------------------------*/
  1138.     /* Code Body                                                      */
  1139.     /*----------------------------------------------------------------*/
  1140.     EntryNewScreen(SETTINGS_SET_TIME_FORMAT_SCREENID, ExitPhnsetSetFormat, NULL, NULL);
  1141.     guiBuffer = GetCurrGuiBuffer(SETTINGS_SET_TIME_FORMAT_SCREENID);
  1142.     InitializeCategory57Screen();
  1143.     memset(wgui_inline_items, 0, sizeof(wgui_inline_item) * MAX_INLINE_ITEMS);
  1144.     PhnsetSetFormatFillInlineStruct((void*)wgui_inline_items);
  1145.     inputBuffer = GetCurrNInputBuffer(SETTINGS_SET_TIME_FORMAT_SCREENID, &inputBufferSize);     /* added for inline edit history */
  1146.     if (inputBuffer != NULL)    /* added for inline edit history */
  1147.     {
  1148.         SetCategory57Data(wgui_inline_items, NUM_ITEMS_DATE_TIME_FORMAT_ENTRY_SCREEN, inputBuffer);     /* sets the data */
  1149.     }
  1150.     RegisterHighlightHandler(PhnsetSetFormatHiliteHandler);
  1151.     ShowCategory57Screen(
  1152.         STR_DATE_TIME_SET_FORMAT_CAPTION,
  1153.         IMG_SCR_SETTING_CAPTION,
  1154.         STR_GLOBAL_OK,
  1155.         IMG_GLOBAL_OK,
  1156.         STR_GLOBAL_BACK,
  1157.         STR_GLOBAL_BACK,
  1158.         NUM_ITEMS_DATE_TIME_FORMAT_ENTRY_SCREEN,
  1159.         setting_date_time_format_list_of_icons,
  1160.         wgui_inline_items,
  1161.         0,
  1162.         guiBuffer);
  1163.     SetCategory57RightSoftkeyFunctions(PhnsetSetFormat, GoBackHistory);
  1164.     DisableCategory57ScreenDone();
  1165. }
  1166. /*****************************************************************************
  1167.  * FUNCTION
  1168.  *  ExitPhnsetSetFormat
  1169.  * DESCRIPTION
  1170.  *  This function is Exit function for Phonesetup->Time and Date -> Set Format
  1171.  *  Functionality:
  1172.  * PARAMETERS
  1173.  *  void
  1174.  * RETURNS
  1175.  *  void
  1176.  *****************************************************************************/
  1177. void ExitPhnsetSetFormat(void)
  1178. {
  1179.     /*----------------------------------------------------------------*/
  1180.     /* Local Variables                                                */
  1181.     /*----------------------------------------------------------------*/
  1182.     history Scr;
  1183.     S16 nHistory = 0;
  1184.     U16 inputBufferSize;    /* added for inline edit history */
  1185.     /*----------------------------------------------------------------*/
  1186.     /* Code Body                                                      */
  1187.     /*----------------------------------------------------------------*/
  1188.     Scr.scrnID = SETTINGS_SET_TIME_FORMAT_SCREENID;
  1189.     Scr.entryFuncPtr = EntryPhnsetSetFormat;
  1190.     pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) & nHistory);
  1191.     GetCategory57History(Scr.guiBuffer);
  1192.     inputBufferSize = (U16) GetCategory57DataSize();    /* added for inline edit history */
  1193.     GetCategory57Data((U8*) Scr.inputBuffer);           /* added for inline edit history */
  1194.     AddNHistory(Scr, (U16) inputBufferSize);            /* added for inline edit history */
  1195. }
  1196. /*****************************************************************************
  1197.  * FUNCTION
  1198.  *  PhnsetSetFormatFillInlineStruct
  1199.  * DESCRIPTION
  1200.  *  This function is to fill inline selection structure for Phonesetup-> Time and Date -> Set Format
  1201.  *  Functionality:
  1202.  * PARAMETERS
  1203.  *  p       [IN]        
  1204.  * RETURNS
  1205.  *  void
  1206.  *****************************************************************************/
  1207. void PhnsetSetFormatFillInlineStruct(void *p)
  1208. {
  1209.     /*----------------------------------------------------------------*/
  1210.     /* Local Variables                                                */
  1211.     /*----------------------------------------------------------------*/
  1212.     wgui_inline_item *setting_inline_format_items = (wgui_inline_item*) p;
  1213.     /*----------------------------------------------------------------*/
  1214.     /* Code Body                                                      */
  1215.     /*----------------------------------------------------------------*/
  1216.     time_formats[0] = (PU8) GetString(STR_12);
  1217.     time_formats[1] = (PU8) GetString(STR_24);
  1218.     date_formats[0] = (PU8) GetString(STR_DD_MMM_YYYY_H);
  1219.     date_formats[1] = (PU8) GetString(STR_DD_MM_YYYY_S);
  1220.     date_formats[2] = (PU8) GetString(STR_MM_DD_YYYY_S);
  1221.     date_formats[3] = (PU8) GetString(STR_YYYY_MM_DD_S);
  1222.     date_formats[4] = (PU8) GetString(STR_YYYY_MM_DD_H);
  1223.     date_formats[5] = (PU8) GetString(STR_MMM_DD_YYYY);
  1224.     g_phnset_cntx_p->CurTimeFmt = PhnsetGetTimeFormat();
  1225.     g_phnset_cntx_p->CurDateFmt = PhnsetGetDateFormat();
  1226.     SetInlineItemActivation(&(setting_inline_format_items[1]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1227.     SetInlineItemActivation(&(setting_inline_format_items[3]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1228.     SetInlineItemCaption(&(setting_inline_format_items[0]), (U8*) GetString(STR_TIME_FORMAT_CAPTION));
  1229.     SetInlineItemSelect(
  1230.         &(setting_inline_format_items[1]),
  1231.         NUM_TIME_FORMATS,
  1232.         time_formats,
  1233.         (PS32) & (g_phnset_cntx_p->CurTimeFmt));
  1234.     SetInlineItemCaption(&(setting_inline_format_items[2]), (U8*) GetString(STR_DATE_FORMAT_CAPTION));
  1235.     SetInlineItemSelect(
  1236.         &(setting_inline_format_items[3]),
  1237.         NUM_DATE_FORMATS,
  1238.         date_formats,
  1239.         (PS32) & (g_phnset_cntx_p->CurDateFmt));
  1240. }
  1241. /*****************************************************************************
  1242.  * FUNCTION
  1243.  *  PhnsetSetFormat
  1244.  * DESCRIPTION
  1245.  *  This function is to set date/time format for PhoneSetup->Time and Date->Set Format
  1246.  *  Functionality:
  1247.  * PARAMETERS
  1248.  *  void
  1249.  * RETURNS
  1250.  *  void
  1251.  *****************************************************************************/
  1252. void PhnsetSetFormat(void)
  1253. {
  1254.     /*----------------------------------------------------------------*/
  1255.     /* Local Variables                                                */
  1256.     /*----------------------------------------------------------------*/
  1257.     /*----------------------------------------------------------------*/
  1258.     /* Code Body                                                      */
  1259.     /*----------------------------------------------------------------*/
  1260.     //chgcnt = 0;
  1261.     //oneoccured = 0;
  1262.     if (((U8) g_phnset_cntx_p->CurTimeFmt != PhnsetGetTimeFormat()) ||
  1263.         ((U8) (g_phnset_cntx_p->CurDateFmt) != PhnsetGetDateFormat()))
  1264.     {
  1265.         /* Save New Time Format To NVRAM if Value is Changed. */
  1266.         PhnsetSetTimeFormat((U8) g_phnset_cntx_p->CurTimeFmt);
  1267.         /* Save New Date Format To NVRAM if Value is Changed. */
  1268.         PhnsetSetDateFormat((U8) g_phnset_cntx_p->CurDateFmt);
  1269.     }
  1270.     SUBLCD_RedrawCategoryFunction();
  1271.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, SUCCESS_TONE);
  1272.     DeleteUptoScrID(SCR9041_TIMEANDDATE);
  1273. }
  1274. /*****************************************************************************
  1275.  * FUNCTION
  1276.  *  PhnsetSetFormatHiliteHandler
  1277.  * DESCRIPTION
  1278.  *  This function is Highlight handler for Phonesetup->Time and Date->Set Format
  1279.  *  Follow functions: PhnsetSetFormat
  1280.  * PARAMETERS
  1281.  *  highliteIndex       [IN]        
  1282.  * RETURNS
  1283.  *  void
  1284.  *****************************************************************************/
  1285. /* void hilite_handler_set_format(S32 highliteIndex) */
  1286. void PhnsetSetFormatHiliteHandler(S32 highliteIndex)
  1287. {
  1288.     /*----------------------------------------------------------------*/
  1289.     /* Local Variables                                                */
  1290.     /*----------------------------------------------------------------*/
  1291.     /*----------------------------------------------------------------*/
  1292.     /* Code Body                                                      */
  1293.     /*----------------------------------------------------------------*/
  1294.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  1295.     SetCategory57LeftSoftkeyFunction(PhnsetSetFormat);
  1296.     /* highlightedDateFormatItem=(U8)highliteIndex; */
  1297. }
  1298. // #else // __MMI_SEPARATE_DT_SETTING__
  1299. #define NUMBER_OF_ITEMS_IN_DATEANDFORMAT 4
  1300. /*
  1301.  * 1. title of date format
  1302.  * * 2. format of date
  1303.  * * 3. title of date
  1304.  * * 4. value of date
  1305.  */
  1306. #define NUMBER_OF_ITEMS_IN_TIMEANDFORMAT 6
  1307. /*
  1308.  * 1. title of time format
  1309.  * * 2. format of time
  1310.  * * 3. title of time
  1311.  * * 4. value of time
  1312.  * * 5. title of DST
  1313.  * * 6. value of DST
  1314.  */
  1315. /*****************************************************************************
  1316.  * FUNCTION
  1317.  *  HighlightPhnsetSetTimeAndFormat
  1318.  * DESCRIPTION
  1319.  *  This function is Highlight handler for Phonesetup-> Time And Date -> Set Format
  1320.  *  Follow functions: EntryPhnsetSetFormat
  1321.  * PARAMETERS
  1322.  *  void
  1323.  * RETURNS
  1324.  *  void
  1325.  *****************************************************************************/
  1326. void HighlightPhnsetSetTimeAndFormat(void)
  1327. {
  1328.     /*----------------------------------------------------------------*/
  1329.     /* Local Variables                                                */
  1330.     /*----------------------------------------------------------------*/
  1331.     /*----------------------------------------------------------------*/
  1332.     /* Code Body                                                      */
  1333.     /*----------------------------------------------------------------*/
  1334.     /* datetimeindex = 2; */
  1335.     g_phnset_cntx_p->curHightlightItem = PHNSET_DT_MNU_TIMEANDFORMAT;
  1336.     /* highlightedDateFormatItem = 0; */
  1337.     SetLeftSoftkeyFunction(EntryPhnsetSetTimeAndFormat, KEY_EVENT_UP);
  1338.     SetKeyHandler(EntryPhnsetSetTimeAndFormat, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1339.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);    /* Robin 1201 */
  1340. }
  1341. /*****************************************************************************
  1342.  * FUNCTION
  1343.  *  HighlightPhnsetSetDateAndFormat
  1344.  * DESCRIPTION
  1345.  *  This function is Highlight handler for Phonesetup-> Time And Date -> Set Time/Date
  1346.  *  Follow functions: EntryPhnsetSetDT
  1347.  * PARAMETERS
  1348.  *  void
  1349.  * RETURNS
  1350.  *  void
  1351.  *****************************************************************************/
  1352. void HighlightPhnsetSetDateAndFormat(void)
  1353. {
  1354.     /*----------------------------------------------------------------*/
  1355.     /* Local Variables                                                */
  1356.     /*----------------------------------------------------------------*/
  1357.     /*----------------------------------------------------------------*/
  1358.     /* Code Body                                                      */
  1359.     /*----------------------------------------------------------------*/
  1360.     /* datetimeindex = 1; */
  1361.     g_phnset_cntx_p->curHightlightItem = PHNSET_DT_MNU_DATEANDFORMAT;
  1362.     //highlightedDateSetItem =0;
  1363.     //g_phnset_cntx_p->curHightlightItem = 0;
  1364.     SetLeftSoftkeyFunction(EntryPhnsetSetDateAndFormat, KEY_EVENT_UP);
  1365.     SetKeyHandler(EntryPhnsetSetDateAndFormat, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1366.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);    /* Robin 1201 */
  1367. }
  1368. /*****************************************************************************
  1369.  * FUNCTION
  1370.  *  PhnsetInlineSetDTAndFormatHiliteHdlr
  1371.  * DESCRIPTION
  1372.  *  This function is Inline line editor Highlight handler for Phonesetup-> Time and Date -> Set Time/Date
  1373.  *  Follow functions: PhnsetSetDT
  1374.  * PARAMETERS
  1375.  *  currId      [IN]        
  1376.  * RETURNS
  1377.  *  void
  1378.  *****************************************************************************/
  1379. static void PhnsetInlineSetDTAndFormatHiliteHdlr(S32 currId)
  1380. {
  1381.     /*----------------------------------------------------------------*/
  1382.     /* Local Variables                                                */
  1383.     /*----------------------------------------------------------------*/
  1384.     /*----------------------------------------------------------------*/
  1385.     /* Code Body                                                      */
  1386.     /*----------------------------------------------------------------*/
  1387.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  1388.     SetCategory57LeftSoftkeyFunction(PhnsetSetDTAndFormat);
  1389. }
  1390. /*****************************************************************************
  1391.  * FUNCTION
  1392.  *  EntryPhnsetSetDateAndFormat
  1393.  * DESCRIPTION
  1394.  *  Set Date And Time Entry Function
  1395.  *  
  1396.  *  This Screen Uses Category 57 and Text Box Edit For Data Entry.
  1397.  * PARAMETERS
  1398.  *  void
  1399.  * RETURNS
  1400.  *  void
  1401.  *****************************************************************************/
  1402. void EntryPhnsetSetDateAndFormat(void)
  1403. {
  1404.     /*----------------------------------------------------------------*/
  1405.     /* Local Variables                                                */
  1406.     /*----------------------------------------------------------------*/
  1407.     U8 *guiBuffer;
  1408.     U8 *inputBuffer;        /* added for inline edit history */
  1409.     U16 inputBufferSize;    /* added for inline edit history */
  1410.     extern wgui_inline_item wgui_inline_items[];
  1411.     U16 setting_date_time_list_of_icons[NUMBER_OF_ITEMS_IN_DATEANDFORMAT] = 
  1412.     {
  1413.         IMG_CAL,
  1414.         IMG_TIME_AND_DATE_BLANK,
  1415.         IMG_CAL,
  1416.         IMG_TIME_AND_DATE_BLANK,
  1417.     };
  1418.     /*----------------------------------------------------------------*/
  1419.     /* Code Body                                                      */
  1420.     /*----------------------------------------------------------------*/
  1421.     EntryNewScreen(SCR_ID_PHNSET_SET_DATEANDFORMAT, ExitPhnsetSetDateAndFormat, NULL, NULL);
  1422.     guiBuffer = GetCurrGuiBuffer(SCR_ID_PHNSET_SET_DATEANDFORMAT);
  1423.     InitializeCategory57Screen();
  1424.     PhnsetSetDTAndFormatFillInlineStruct((void*)wgui_inline_items);
  1425.     inputBuffer = GetCurrNInputBuffer(SCR_ID_PHNSET_SET_DATEANDFORMAT, &inputBufferSize);       /* added for inline edit history */
  1426.     if (inputBuffer != NULL)
  1427.     {
  1428.         SetCategory57Data(wgui_inline_items, NUMBER_OF_ITEMS_IN_DATEANDFORMAT, inputBuffer);
  1429.     }
  1430.     SetLeftSoftkeyFunction(PhnsetSetDTAndFormat, KEY_EVENT_UP);
  1431.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1432.     RegisterHighlightHandler(PhnsetInlineSetDTAndFormatHiliteHdlr);
  1433.     ShowCategory57Screen(
  1434.         STR_ID_PHNSET_SET_DATEANDFORMAT,
  1435.         IMG_SCR_SETTING_CAPTION,
  1436.         STR_GLOBAL_OK,
  1437.         IMG_GLOBAL_OK,
  1438.         STR_GLOBAL_BACK,
  1439.         IMG_GLOBAL_BACK,
  1440.         NUMBER_OF_ITEMS_IN_DATEANDFORMAT,
  1441.         setting_date_time_list_of_icons,
  1442.         wgui_inline_items,
  1443.         0,
  1444.         guiBuffer);
  1445.     DisableCategory57ScreenDone();
  1446.     SetCategory57RightSoftkeyFunctions(PhnsetSetDTAndFormat, GoBackHistory);
  1447. }
  1448. /*****************************************************************************
  1449.  * FUNCTION
  1450.  *  ExitPhnsetSetDateAndFormat
  1451.  * DESCRIPTION
  1452.  *  This function is Exit function for Phonesetup-> Time and Date -> Set Time/Date
  1453.  *  Functionality:
  1454.  * PARAMETERS
  1455.  *  void
  1456.  * RETURNS
  1457.  *  void
  1458.  *****************************************************************************/
  1459. void ExitPhnsetSetDateAndFormat(void)
  1460. {
  1461.     /*----------------------------------------------------------------*/
  1462.     /* Local Variables                                                */
  1463.     /*----------------------------------------------------------------*/
  1464.     history Scr;
  1465.     S16 nHistory = 0;
  1466.     U16 inputBufferSize;    /* added for inline edit history */
  1467.     /*----------------------------------------------------------------*/
  1468.     /* Code Body                                                      */
  1469.     /*----------------------------------------------------------------*/
  1470.     Scr.scrnID = SCR_ID_PHNSET_SET_DATEANDFORMAT;
  1471.     CloseCategory57Screen();
  1472.     Scr.entryFuncPtr = EntryPhnsetSetDateAndFormat;
  1473.     pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) & nHistory);
  1474.     GetCategory57History(Scr.guiBuffer);
  1475.     inputBufferSize = (U16) GetCategory57DataSize();    /* added for inline edit history */
  1476.     GetCategory57Data((U8*) Scr.inputBuffer);           /* added for inline edit history */
  1477.     AddNHistory(Scr, (U16) inputBufferSize);            /* added for inline edit history */
  1478. }
  1479. /*****************************************************************************
  1480.  * FUNCTION
  1481.  *  EntryPhnsetSetTimeAndFormat
  1482.  * DESCRIPTION
  1483.  *  Set Date And Time Entry Function
  1484.  *  
  1485.  *  This Screen Uses Category 57 and Text Box Edit For Data Entry.
  1486.  * PARAMETERS
  1487.  *  void
  1488.  * RETURNS
  1489.  *  void
  1490.  *****************************************************************************/
  1491. void EntryPhnsetSetTimeAndFormat(void)
  1492. {
  1493.     /*----------------------------------------------------------------*/
  1494.     /* Local Variables                                                */
  1495.     /*----------------------------------------------------------------*/
  1496.     U8 *guiBuffer;
  1497.     U8 *inputBuffer;        /* added for inline edit history */
  1498.     U16 inputBufferSize;    /* added for inline edit history */
  1499.     extern wgui_inline_item wgui_inline_items[];
  1500.     U16 setting_date_time_list_of_icons[NUM_ITEMS_DATE_TIME_ENTRY_SCREEN] = 
  1501.     {
  1502.         IMG_TIME,
  1503.         IMG_TIME_AND_DATE_BLANK,
  1504.         IMG_TIME,
  1505.         IMG_TIME_AND_DATE_BLANK,
  1506.         SUN_ICON,
  1507.         IMG_TIME_AND_DATE_BLANK
  1508.     };
  1509.     /*----------------------------------------------------------------*/
  1510.     /* Code Body                                                      */
  1511.     /*----------------------------------------------------------------*/
  1512.     EntryNewScreen(SCR_ID_PHNSET_SET_TIMEANDFORMAT, ExitPhnsetSetTimeAndFormat, NULL, NULL);
  1513.     guiBuffer = GetCurrGuiBuffer(SCR_ID_PHNSET_SET_TIMEANDFORMAT);
  1514.     InitializeCategory57Screen();
  1515.     PhnsetSetDTAndFormatFillInlineStruct((void*)wgui_inline_items);
  1516.     inputBuffer = GetCurrNInputBuffer(SCR_ID_PHNSET_SET_TIMEANDFORMAT, &inputBufferSize);       /* added for inline edit history */
  1517.     if (inputBuffer != NULL)
  1518.     {
  1519.         SetCategory57Data(wgui_inline_items, NUMBER_OF_ITEMS_IN_TIMEANDFORMAT, inputBuffer);
  1520.     }
  1521.     SetLeftSoftkeyFunction(PhnsetSetDTAndFormat, KEY_EVENT_UP);
  1522.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1523.     RegisterHighlightHandler(PhnsetInlineSetDTAndFormatHiliteHdlr);
  1524.     ShowCategory57Screen(
  1525.         STR_ID_PHNSET_SET_TIMEANDFORMAT,
  1526.         IMG_SCR_SETTING_CAPTION,
  1527.         STR_GLOBAL_OK,
  1528.         IMG_GLOBAL_OK,
  1529.         STR_GLOBAL_BACK,
  1530.         IMG_GLOBAL_BACK,
  1531.         NUMBER_OF_ITEMS_IN_TIMEANDFORMAT,
  1532.         setting_date_time_list_of_icons,
  1533.         wgui_inline_items,
  1534.         0,
  1535.         guiBuffer);
  1536.     DisableCategory57ScreenDone();
  1537.     SetCategory57RightSoftkeyFunctions(PhnsetSetDTAndFormat, GoBackHistory);
  1538. }
  1539. /*****************************************************************************
  1540.  * FUNCTION
  1541.  *  ExitPhnsetSetTimeAndFormat
  1542.  * DESCRIPTION
  1543.  *  This function is Exit function for Phonesetup-> Time and Date -> Set Time/Date
  1544.  *  Functionality:
  1545.  * PARAMETERS
  1546.  *  void
  1547.  * RETURNS
  1548.  *  void
  1549.  *****************************************************************************/
  1550. void ExitPhnsetSetTimeAndFormat(void)
  1551. {
  1552.     /*----------------------------------------------------------------*/
  1553.     /* Local Variables                                                */
  1554.     /*----------------------------------------------------------------*/
  1555.     history Scr;
  1556.     S16 nHistory = 0;
  1557.     U16 inputBufferSize;    /* added for inline edit history */
  1558.     /*----------------------------------------------------------------*/
  1559.     /* Code Body                                                      */
  1560.     /*----------------------------------------------------------------*/
  1561.     Scr.scrnID = SCR_ID_PHNSET_SET_TIMEANDFORMAT;
  1562.     CloseCategory57Screen();
  1563.     Scr.entryFuncPtr = EntryPhnsetSetTimeAndFormat;
  1564.     pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) & nHistory);
  1565.     GetCategory57History(Scr.guiBuffer);
  1566.     inputBufferSize = (U16) GetCategory57DataSize();    /* added for inline edit history */
  1567.     GetCategory57Data((U8*) Scr.inputBuffer);           /* added for inline edit history */
  1568.     AddNHistory(Scr, (U16) inputBufferSize);            /* added for inline edit history */
  1569. }
  1570. /*****************************************************************************
  1571.  * FUNCTION
  1572.  *  PhnsetSetDTAndFormatFillInlineStruct
  1573.  * DESCRIPTION
  1574.  *  This function is to fill inline selection structure for Phonesetup-> Time and Date -> Set Time/Date
  1575.  *  Functionality:
  1576.  * PARAMETERS
  1577.  *  p       [IN]        
  1578.  * RETURNS
  1579.  *  void
  1580.  *****************************************************************************/
  1581. void PhnsetSetDTAndFormatFillInlineStruct(void *p)
  1582. {
  1583.     /*----------------------------------------------------------------*/
  1584.     /* Local Variables                                                */
  1585.     /*----------------------------------------------------------------*/
  1586.     MYTIME currTime;
  1587.     U8 dummyString[5];  /* max length is of year 4 */
  1588.     wgui_inline_item *setting_inline_edit_items = (wgui_inline_item*) p;
  1589.     /*----------------------------------------------------------------*/
  1590.     /* Code Body                                                      */
  1591.     /*----------------------------------------------------------------*/
  1592.     GetDateTime(&currTime);
  1593. #if defined(__MMI_NITZ__)
  1594.     /* If Change In Date Time Triggered From NITZ */
  1595.     if (g_nitz_cntx.IsAccepted == TRUE)
  1596.     {
  1597.         memcpy(&currTime, &g_nitz_cntx.NITZTime, sizeof(MYTIME));
  1598.     }
  1599. #endif /* defined(__MMI_NITZ__) */ 
  1600.     if (g_phnset_cntx_p->curHightlightItem == PHNSET_DT_MNU_DATEANDFORMAT)
  1601.     {
  1602.         date_formats[0] = (PU8) GetString(STR_DD_MMM_YYYY_H);
  1603.         date_formats[1] = (PU8) GetString(STR_DD_MM_YYYY_S);
  1604.         date_formats[2] = (PU8) GetString(STR_MM_DD_YYYY_S);
  1605.         date_formats[3] = (PU8) GetString(STR_YYYY_MM_DD_S);
  1606.         date_formats[4] = (PU8) GetString(STR_YYYY_MM_DD_H);
  1607.         date_formats[5] = (PU8) GetString(STR_MMM_DD_YYYY);
  1608.         g_phnset_cntx_p->CurDateFmt = PhnsetGetDateFormat();
  1609.         sprintf(gYear, "%2d", currTime.nYear);
  1610.         sprintf(gMonth, "%02d", currTime.nMonth);
  1611.         sprintf(gDate, "%02d", currTime.nDay);
  1612.         strcpy((PS8) dummyString, gYear);
  1613.         AnsiiToUnicodeString((PS8) gYear, (PS8) dummyString);
  1614.         strcpy((PS8) dummyString, gMonth);
  1615.         AnsiiToUnicodeString((PS8) gMonth, (PS8) dummyString);
  1616.         strcpy((PS8) dummyString, gDate);
  1617.         AnsiiToUnicodeString((PS8) gDate, (PS8) dummyString);
  1618.         if (SetFromAT == FALSE)
  1619.         {
  1620.             SetInlineItemActivation(
  1621.                 &(setting_inline_edit_items[1]),
  1622.                 INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  1623.                 KEY_EVENT_UP);
  1624.             SetInlineItemActivation(
  1625.                 &(setting_inline_edit_items[3]),
  1626.                 INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  1627.                 KEY_EVENT_UP);
  1628.             SetInlineItemCaption(&(setting_inline_edit_items[0]), (U8*) GetString(STR_DATE_FORMAT_CAPTION));
  1629.             SetInlineItemSelect(
  1630.                 &(setting_inline_edit_items[1]),
  1631.                 NUM_DATE_FORMATS,
  1632.                 date_formats,
  1633.                 (PS32) & (g_phnset_cntx_p->CurDateFmt));
  1634.             SetInlineItemCaption(&(setting_inline_edit_items[2]), (U8*) GetString(STR_ENTER_DATE_FORMAT_DISP_CAPTION));
  1635.             SetInlineItemDate(
  1636.                 &(setting_inline_edit_items[3]),
  1637.                 (U8*) gDate,
  1638.                 (U8*) gMonth,
  1639.                 (U8*) gYear,
  1640.                 PhnsetDateEditorCallback);
  1641.             SetInlineItemFullWidth(&setting_inline_edit_items[3]);
  1642.             EnableInlineItemBoundary(&setting_inline_edit_items[3]);
  1643.             RightJustifyInlineItem(&setting_inline_edit_items[3]);
  1644.             set_inline_date_boundary(2030, 2000, 12, 1);
  1645.         }
  1646.     }
  1647.     else if (g_phnset_cntx_p->curHightlightItem == PHNSET_DT_MNU_TIMEANDFORMAT)
  1648.     {
  1649.         time_formats[0] = (PU8) GetString(STR_12);
  1650.         time_formats[1] = (PU8) GetString(STR_24);
  1651.         g_phnset_cntx_p->CurTimeFmt = PhnsetGetTimeFormat();
  1652.         sprintf(gHour, "%02d", currTime.nHour);
  1653.         sprintf(gMinute, "%02d", currTime.nMin);
  1654.         strcpy((PS8) dummyString, gHour);
  1655.         AnsiiToUnicodeString((PS8) gHour, (PS8) dummyString);
  1656.         strcpy((PS8) dummyString, gMinute);
  1657.         AnsiiToUnicodeString((PS8) gMinute, (PS8) dummyString);
  1658.         DSTString[0] = (PU8) GetString(STR_GLOBAL_OFF);
  1659.         DSTString[1] = (PU8) GetString(STR_GLOBAL_ON);
  1660.         if (SetFromAT == FALSE)
  1661.         {
  1662.             S16 Err;
  1663.             SetInlineItemActivation(
  1664.                 &(setting_inline_edit_items[1]),
  1665.                 INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  1666.                 KEY_EVENT_UP);
  1667.             SetInlineItemActivation(
  1668.                 &(setting_inline_edit_items[3]),
  1669.                 INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  1670.                 KEY_EVENT_UP);
  1671.             /* amanda dst */
  1672.             SetInlineItemActivation(
  1673.                 &(setting_inline_edit_items[5]),
  1674.                 INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  1675.                 KEY_EVENT_UP);
  1676.             SetInlineItemCaption(&(setting_inline_edit_items[0]), (U8*) GetString(STR_TIME_FORMAT_CAPTION));
  1677.             SetInlineItemSelect(
  1678.                 &(setting_inline_edit_items[1]),
  1679.                 NUM_TIME_FORMATS,
  1680.                 time_formats,
  1681.                 (PS32) & (g_phnset_cntx_p->CurTimeFmt));
  1682.             SetInlineItemCaption(&(setting_inline_edit_items[2]), (U8*) GetString(STR_ENTER_TIME_FORMAT_DISP_CAPTION));
  1683.             SetInlineItemTime(
  1684.                 &(setting_inline_edit_items[3]),
  1685.                 (U8*) gHour,
  1686.                 (U8*) gMinute,
  1687.                 g_phnset_cntx_p->AM_PM_flag,
  1688.                 PhnsetTimeEditorCallback);
  1689.             SetInlineItemFullWidth(&setting_inline_edit_items[3]);
  1690.             EnableInlineItemBoundary(&setting_inline_edit_items[3]);
  1691.             RightJustifyInlineItem(&setting_inline_edit_items[3]);
  1692.             /* amanda dst */
  1693.             ReadValue(NVRAM_SETTING_DT_DST, &(g_phnset_cntx_p->currentDST), DS_BYTE, &Err);
  1694.             SetInlineItemCaption(&(setting_inline_edit_items[4]), (U8*) GetString(STR_ID_PHNSET_SET_DST));
  1695.             SetInlineItemSelect(&(setting_inline_edit_items[5]), 2, (U8 **) DSTString, &g_phnset_cntx_p->currentDST);
  1696.             SetInlineItemFullWidth(&setting_inline_edit_items[5]);
  1697.             RegisterInlineSelectHighlightHandler(&setting_inline_edit_items[5], HighlightPhnsetSetDST);
  1698.             EnableInlineItemBoundary(&setting_inline_edit_items[5]);
  1699.             if (!IsScreenPresent(SCR_ID_PHNSET_SET_DT))
  1700.             {
  1701.                 g_phnset_cntx_p->prevDST = g_phnset_cntx_p->currentDST;
  1702.             }
  1703.         }
  1704.     }
  1705. }
  1706. /*****************************************************************************
  1707.  * FUNCTION
  1708.  *  PhnsetSetDTAndFormat
  1709.  * DESCRIPTION
  1710.  *  This function is to set date/time format for PhoneSetup->Time and Date->Set Format
  1711.  *  Functionality:
  1712.  * PARAMETERS
  1713.  *  void
  1714.  * RETURNS
  1715.  *  void
  1716.  *****************************************************************************/
  1717. void PhnsetSetDTAndFormat(void)
  1718. {
  1719.     /*----------------------------------------------------------------*/
  1720.     /* Local Variables                                                */
  1721.     /*----------------------------------------------------------------*/
  1722.     /*----------------------------------------------------------------*/
  1723.     /* Code Body                                                      */
  1724.     /*----------------------------------------------------------------*/
  1725.     if (((g_phnset_cntx_p->curHightlightItem == PHNSET_DT_MNU_TIMEANDFORMAT) &&
  1726.          ((gui_atoi((UI_string_type) gHour) > 23) || (gui_atoi((UI_string_type) gMinute) > 59)))
  1727.         || ((g_phnset_cntx_p->curHightlightItem == PHNSET_DT_MNU_DATEANDFORMAT) &&
  1728.             ((gui_atoi((UI_string_type) gYear) > 2030) || (gui_atoi((UI_string_type) gYear) < 2000)
  1729.              || (gui_atoi((UI_string_type) gMonth) > 12) || (gui_atoi((UI_string_type) gMonth) < 1)
  1730.              || (gui_atoi((UI_string_type) gDate) > 31)
  1731.              || (LastDayOfMonth((U8) gui_atoi((UI_string_type) gMonth), (U8) gui_atoi((UI_string_type) gYear)) <
  1732.                  gui_atoi((UI_string_type) gDate)))))
  1733.     {
  1734.         DisplayPopup((PU8) GetString(STR_SETTIME_UNFINISHED), IMG_GLOBAL_WARNING, 1, ST_NOTIFYDURATION, ERROR_TONE);
  1735.     }
  1736.     else
  1737.     {
  1738.         U8 flag;
  1739.         S16 error;
  1740.         ReadValue(NVRAM_SETTING_DT_DST, &flag, DS_BYTE, &error);
  1741.         if (flag != g_phnset_cntx_p->currentDST)
  1742.         {
  1743.             mmi_dt_set_dst((U8) g_phnset_cntx_p->currentDST);
  1744.         }
  1745.         PhnsetSendSetTimeReqMessage();
  1746.     }
  1747.     if (((U8) g_phnset_cntx_p->CurTimeFmt != PhnsetGetTimeFormat()) ||
  1748.         ((U8) (g_phnset_cntx_p->CurDateFmt) != PhnsetGetDateFormat()))
  1749.     {
  1750.         /* Save New Time Format To NVRAM if Value is Changed. */
  1751.         PhnsetSetTimeFormat((U8) g_phnset_cntx_p->CurTimeFmt);
  1752.         /* Save New Date Format To NVRAM if Value is Changed. */
  1753.         PhnsetSetDateFormat((U8) g_phnset_cntx_p->CurDateFmt);
  1754.     }
  1755.     SUBLCD_RedrawCategoryFunction();
  1756.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, SUCCESS_TONE);
  1757.     DeleteUptoScrID(SCR9041_TIMEANDDATE);
  1758. }
  1759. /* 
  1760.  * Home City
  1761.  */
  1762. /*****************************************************************************
  1763.  * FUNCTION
  1764.  *  PhnsetInitTimeNDate
  1765.  * DESCRIPTION
  1766.  *  This function is to
  1767.  *  Functionality:
  1768.  * PARAMETERS
  1769.  *  void
  1770.  * RETURNS
  1771.  *  void
  1772.  *****************************************************************************/
  1773. void PhnsetInitTimeNDate(void)
  1774. {
  1775.     /*----------------------------------------------------------------*/
  1776.     /* Local Variables                                                */
  1777.     /*----------------------------------------------------------------*/
  1778.     /*----------------------------------------------------------------*/
  1779.     /* Code Body                                                      */
  1780.     /*----------------------------------------------------------------*/
  1781.     /* 
  1782.      * int i =0;
  1783.      * for(i =0;i< NUM_CITYS;i++)
  1784.      * city_list[i]=STR_WCLOCK_CITY1 +i;
  1785.      * 
  1786.      * for(i =0;i< NUM_CITYS;i++)
  1787.      * city_number_icon[i] = IMG_TIME_AND_DATE_BLANK;
  1788.      */
  1789.     PhnsetConstructCityList();
  1790.     g_phnset_cntx_p->CurHomeCityStrPtr = homeCityDataPtr[g_phnset_cntx_p->currentCity];
  1791. }
  1792. /* Robin 0330: */
  1793. #if 0
  1794. /* under construction !*/
  1795. /* under construction !*/
  1796. /* under construction !*/
  1797. /* under construction !*/
  1798. /* under construction !*/
  1799. /* under construction !*/
  1800. /* under construction !*/
  1801. /* under construction !*/
  1802. /* under construction !*/
  1803. /* under construction !*/
  1804. /* under construction !*/
  1805. /* under construction !*/
  1806. /* under construction !*/
  1807. /* under construction !*/
  1808. /* under construction !*/
  1809. /* under construction !*/
  1810. /* under construction !*/
  1811. /* under construction !*/
  1812. /* under construction !*/
  1813. /* under construction !*/
  1814. #endif /* 0 */ 
  1815. /*****************************************************************************
  1816.  * FUNCTION
  1817.  *  PhnsetReadNvmHomeCityIdxNStoreCityName
  1818.  * DESCRIPTION
  1819.  *  This function is to (1) Read home city index from nvram
  1820.  *  (2) Store city name (digits) in global variable
  1821.  *  Functionality:
  1822.  * PARAMETERS
  1823.  *  void
  1824.  * RETURNS
  1825.  *  void
  1826.  *****************************************************************************/
  1827. void PhnsetReadNvmHomeCityIdxNStoreCityName(void)   /* Used on Language change */
  1828. {
  1829.     /*----------------------------------------------------------------*/
  1830.     /* Local Variables                                                */
  1831.     /*----------------------------------------------------------------*/
  1832.     S16 error;
  1833.     /*----------------------------------------------------------------*/
  1834.     /* Code Body                                                      */
  1835.     /*----------------------------------------------------------------*/
  1836.     ReadValue(CURRENT_CITY, &(g_phnset_cntx_p->currentCity), DS_BYTE, &error);
  1837.     if (error != NVRAM_READ_SUCCESS)
  1838.     {
  1839.         g_phnset_cntx_p->currentCity = 0;
  1840.     }
  1841.     else if (g_phnset_cntx_p->currentCity > NUM_CITYS)
  1842.     {
  1843.         g_phnset_cntx_p->currentCity = 0;
  1844.     }
  1845.     g_phnset_cntx_p->CurHomeCityStrID = TimeZoneData[g_phnset_cntx_p->currentCity + 1].CityName;
  1846. }
  1847. /*****************************************************************************
  1848.  * FUNCTION
  1849.  *  PhnsetReinitHomeCity
  1850.  * DESCRIPTION
  1851.  *  This function is to Restore the city index when language change
  1852.  *  Functionality: !!!NOTICE!!! the function should use together with PhnsetReadNvmHomeCityIdxNStoreCityName()
  1853.  * PARAMETERS
  1854.  *  void
  1855.  * RETURNS
  1856.  *  void
  1857.  *****************************************************************************/
  1858. void PhnsetReinitHomeCity(void) /* Used on Language change, together with PhnsetReadNvmHomeCityIdxNStoreCityName()  */
  1859. {
  1860.     /*----------------------------------------------------------------*/
  1861.     /* Local Variables                                                */
  1862.     /*----------------------------------------------------------------*/
  1863.     S16 error;
  1864.     U8 i;
  1865.     U8 num_city = NUMBER_OF_CITY;
  1866.     /*----------------------------------------------------------------*/
  1867.     /* Code Body                                                      */
  1868.     /*----------------------------------------------------------------*/
  1869.     PhnsetConstructCityList();
  1870.     for (i = 0; i < num_city; i++)
  1871.     {
  1872.         if (TimeZoneData[i].CityName == g_phnset_cntx_p->CurHomeCityStrID)
  1873.         {
  1874.             g_phnset_cntx_p->currentCity = i - 1;
  1875.             WriteValue(CURRENT_CITY, &(g_phnset_cntx_p->currentCity), DS_BYTE, &error);
  1876.             break;
  1877.         }
  1878.     }
  1879.     g_phnset_cntx_p->CurHomeCityStrPtr = homeCityDataPtr[g_phnset_cntx_p->currentCity];
  1880. }
  1881. /*****************************************************************************
  1882.  * FUNCTION
  1883.  *  PhnsetInitSetTimeNDateNvram
  1884.  * DESCRIPTION
  1885.  *  This function is to read global variable from nvram
  1886.  *  for Phonesetup -> Time and Date ->Set Home City
  1887.  *  ->Set Time/Date
  1888.  *  ->Set Format
  1889.  *  Functionality:
  1890.  * PARAMETERS
  1891.  *  void
  1892.  * RETURNS
  1893.  *  void
  1894.  *****************************************************************************/
  1895. void PhnsetInitSetTimeNDateNvram(void)
  1896. {
  1897.     /*----------------------------------------------------------------*/
  1898.     /* Local Variables                                                */
  1899.     /*----------------------------------------------------------------*/
  1900.     /*----------------------------------------------------------------*/
  1901.     /* Code Body                                                      */
  1902.     /*----------------------------------------------------------------*/
  1903.     //Robin 0330:
  1904.     //GetDateTimeSetupNvRam();
  1905.     PhnsetReadNvmHomeCityIdxNStoreCityName();
  1906.     g_phnset_cntx_p->CurTimeFmt = PhnsetGetTimeFormat();
  1907.     g_phnset_cntx_p->CurDateFmt = PhnsetGetDateFormat();
  1908. }
  1909. /*****************************************************************************
  1910.  * FUNCTION
  1911.  *  PhnsetConstructCityList
  1912.  * DESCRIPTION
  1913.  *  This function is to
  1914.  *  Functionality:
  1915.  * PARAMETERS
  1916.  *  void
  1917.  * RETURNS
  1918.  *  void
  1919.  *****************************************************************************/
  1920. void PhnsetConstructCityList(void)
  1921. {
  1922.     /*----------------------------------------------------------------*/
  1923.     /* Local Variables                                                */
  1924.     /*----------------------------------------------------------------*/
  1925.     int i, maxCities;
  1926.     /*----------------------------------------------------------------*/
  1927.     /* Code Body                                                      */
  1928.     /*----------------------------------------------------------------*/
  1929.     for (i = 0; i < NUM_CITYS; i++)
  1930.     {
  1931.         homeCityDataPtr[i] = (PU8) ((GetString) ((U16) (TimeZoneData[i + 1].CityName)));
  1932.     }
  1933. }
  1934. #ifndef __MMI_HIDE_HOMECITY__
  1935. /*****************************************************************************
  1936.  * FUNCTION
  1937.  *  mmi_setting_home_city_async_callback
  1938.  * DESCRIPTION
  1939.  *  This function is callback function for generating asynchronous list.
  1940.  * PARAMETERS
  1941.  *  void
  1942.  * RETURNS
  1943.  *  void
  1944.  *****************************************************************************/
  1945. pBOOL mmi_setting_home_city_async_callback(S32 item_index, UI_string_type str_buff, PU8 *img_buff_p, U8 str_img_mask)
  1946. {
  1947.     /*----------------------------------------------------------------*/
  1948.     /* Local Variables                                                */
  1949.     /*----------------------------------------------------------------*/
  1950.     /*----------------------------------------------------------------*/
  1951.     /* Code Body                                                      */
  1952.     /*----------------------------------------------------------------*/
  1953.     pfnUnicodeStrcpy(
  1954.         (S8*) str_buff,
  1955.         (S8*) ((GetString)((U16) (TimeZoneData[item_index + 1].CityName))));
  1956. if (item_index == g_phnset_cntx_p->currentCity)
  1957. {
  1958. *img_buff_p = get_image(IMG_VICON);
  1959. }
  1960. else
  1961. {
  1962.      *img_buff_p = 0;
  1963.     }
  1964.     return TRUE;
  1965. }
  1966. /*****************************************************************************
  1967.  * FUNCTION
  1968.  *  EntryPhnsetSetHomeCity
  1969.  * DESCRIPTION
  1970.  *  This function is Entry function for Phonesetup->Time and Date->Set Homecity
  1971.  *  Following functions: PhnsetSetHomeCity
  1972.  * PARAMETERS
  1973.  *  void
  1974.  * RETURNS
  1975.  *  void
  1976.  *****************************************************************************/
  1977. void EntryPhnsetSetHomeCity(void)
  1978. {
  1979.     /*----------------------------------------------------------------*/
  1980.     /* Local Variables                                                */
  1981.     /*----------------------------------------------------------------*/
  1982.     U8 *guiBuffer;
  1983.     U8 maxCities = 0;
  1984.     /*----------------------------------------------------------------*/
  1985.     /* Code Body                                                      */
  1986.     /*----------------------------------------------------------------*/
  1987.     EntryNewScreen(SETTINGS_SETHOMECITY_SCREENID, NULL, EntryPhnsetSetHomeCity, NULL);
  1988.     guiBuffer = GetCurrGuiBuffer(SETTINGS_SETHOMECITY_SCREENID);
  1989.     PhnsetReadNvmHomeCityIdxNStoreCityName();
  1990.     PhnsetConstructCityList();
  1991.     g_phnset_cntx_p->curHightlightItem = (U32) g_phnset_cntx_p->currentCity;
  1992.     maxCities = ((NUM_CITYS > MAX_SUB_MENUS) ? MAX_SUB_MENUS : NUM_CITYS);
  1993.     ShowCategory184Screen(
  1994.         STR_MENU9142_SETHOMECITY,
  1995.         IMG_SCR_SETTING_CAPTION,
  1996.         STR_GLOBAL_OK,
  1997.         IMG_GLOBAL_OK,
  1998.         STR_GLOBAL_BACK,
  1999.         IMG_GLOBAL_BACK,
  2000.         NUM_CITYS,
  2001.         mmi_setting_home_city_async_callback,
  2002.         NULL,
  2003.         g_phnset_cntx_p->curHightlightItem,
  2004.         guiBuffer);
  2005.     RegisterHighlightHandler(PhnsetHomeCityIdxHiliteHandler);
  2006.     if (!IsChineseSet())
  2007.     {
  2008.         set_numberless_multitap();
  2009.         register_multitap_no_draw_key_handlers();
  2010.         set_multitap_functions(PhnsetHCMultiTapHdlr, PhnsetHCMultiTapCompleteHdlr);
  2011.         change_multitap_mode(0);
  2012.     }
  2013.     SetLeftSoftkeyFunction(PhnsetSetHomeCity, KEY_EVENT_UP);
  2014.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2015.     SetKeyHandler(NULL, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  2016.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2017. }
  2018. #endif /* __MMI_HIDE_HOMECITY__ */ 
  2019. /*****************************************************************************
  2020.  * FUNCTION
  2021.  *  PhnsetSetHomeCity
  2022.  * DESCRIPTION
  2023.  *  This function is to set home city for Phonesetup->Time and Date->Set Homecity
  2024.  *  Following functions:
  2025.  * PARAMETERS
  2026.  *  void
  2027.  * RETURNS
  2028.  *  void
  2029.  *****************************************************************************/
  2030. #ifndef __MMI_HIDE_HOMECITY__
  2031. void PhnsetSetHomeCity(void)
  2032. {
  2033.     /*----------------------------------------------------------------*/
  2034.     /* Local Variables                                                */
  2035.     /*----------------------------------------------------------------*/
  2036.     S16 error;
  2037.     S16 tmpCity;
  2038.     /*----------------------------------------------------------------*/
  2039.     /* Code Body                                                      */
  2040.     /*----------------------------------------------------------------*/
  2041. ReadValue(CURRENT_CITY, &tmpCity, DS_BYTE, &error);
  2042.            
  2043. #ifndef __MMI_WC_TZ_SUPPORT__    
  2044. g_phnset_cntx_p->currentCity = (U8) g_phnset_cntx_p->curHightlightItem;
  2045. if (!IsChineseSet())
  2046.     {
  2047.         disable_active_multitap();
  2048.     }
  2049.     if (tmpCity != (U8) g_phnset_cntx_p->curHightlightItem)
  2050. {
  2051.         g_phnset_cntx_p->CurHomeCityStrPtr = homeCityDataPtr[g_phnset_cntx_p->currentCity];
  2052. WriteValue(CURRENT_CITY, &(g_phnset_cntx_p->currentCity), DS_BYTE, &error);
  2053. }
  2054. tmpCity = (S16)(GetTimeZone(PhnsetGetHomeCity()) * 4);
  2055. #else
  2056. if ( g_wc_cntx.CurrCityIndex != 0)
  2057.     {
  2058.         g_phnset_cntx_p->currentCity = g_wc_cntx.CurrCityIndex - 1;
  2059.     }
  2060.     else
  2061.     {
  2062.         g_phnset_cntx_p->currentCity = 0xff;
  2063.     }
  2064.     if (tmpCity != (U8) g_phnset_cntx_p->currentCity)
  2065. {
  2066. g_phnset_cntx_p->CurHomeCityStrPtr = (U8*)GetString(TimeZoneData[g_wc_cntx.CurrCityIndex].CityName);
  2067. WriteValue(CURRENT_CITY, &(g_phnset_cntx_p->currentCity), DS_BYTE, &error);
  2068. }
  2069. tmpCity = (S16)(g_wc_cntx.CurrTZ * 4);
  2070. #endif         
  2071.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, SUCCESS_TONE);
  2072.     WriteValue(NVRAM_TIMEZONE, &tmpCity, DS_SHORT, &error);
  2073.     DeleteNHistory(1);
  2074.     //Robin 0330:
  2075.     //ShowIdleAppSubLcd();
  2076.     SUBLCD_RedrawCategoryFunction();
  2077. }
  2078. #endif /* __MMI_HIDE_HOMECITY__ */ 
  2079. /*****************************************************************************
  2080.  * FUNCTION
  2081.  *  PhnsetHomeCityIdxHiliteHandler
  2082.  * DESCRIPTION
  2083.  *  This function is Highlight handler for Phonesetup->Time and Date->Set Homecity -> (list)
  2084.  *  Follow functions: EntryPhnsetMainMenuStyle
  2085.  * PARAMETERS
  2086.  *  cityIndex       [IN]        
  2087.  * RETURNS
  2088.  *  void
  2089.  *****************************************************************************/
  2090. void PhnsetHomeCityIdxHiliteHandler(S32 cityIndex)
  2091. {
  2092.     /*----------------------------------------------------------------*/
  2093.     /* Local Variables                                                */
  2094.     /*----------------------------------------------------------------*/
  2095.     /*----------------------------------------------------------------*/
  2096.     /* Code Body                                                      */
  2097.     /*----------------------------------------------------------------*/
  2098.     g_phnset_cntx_p->curHightlightItem = (U32) cityIndex;
  2099. }
  2100. /*****************************************************************************
  2101.  * FUNCTION
  2102.  *  PhnsetGetHomeCity
  2103.  * DESCRIPTION
  2104.  *  This function is to get current home city setting
  2105.  *  Functionality:
  2106.  * PARAMETERS
  2107.  *  void
  2108.  * RETURNS
  2109.  *  void
  2110.  *****************************************************************************/
  2111. U8 PhnsetGetHomeCity(void)
  2112. {
  2113.     /*----------------------------------------------------------------*/
  2114.     /* Local Variables                                                */
  2115.     /*----------------------------------------------------------------*/
  2116.     /*----------------------------------------------------------------*/
  2117.     /* Code Body                                                      */
  2118.     /*----------------------------------------------------------------*/
  2119.     return g_phnset_cntx_p->currentCity;
  2120. }
  2121. /*****************************************************************************
  2122.  * FUNCTION
  2123.  *  PhnsetHCGetNearbyIdx
  2124.  * DESCRIPTION
  2125.  *  This function is to get the nearby city index when multitap presing at browsing home city in english mode
  2126.  *  for Phonesetup->Time and Date->Home City
  2127.  *  Functionality:
  2128.  * PARAMETERS
  2129.  *  inp     [IN]        
  2130.  * RETURNS
  2131.  *  void
  2132.  *****************************************************************************/
  2133. U8 PhnsetHCGetNearbyIdx(UI_character_type inp)
  2134. {
  2135.     /*----------------------------------------------------------------*/
  2136.     /* Local Variables                                                */
  2137.     /*----------------------------------------------------------------*/
  2138.     U16 n1 = 0;
  2139.     U8 i, maxCities = 0;
  2140.     /*----------------------------------------------------------------*/
  2141.     /* Code Body                                                      */
  2142.     /*----------------------------------------------------------------*/
  2143.     if ((inp >= (UI_character_type) 'A' && inp <= (UI_character_type) 'Z') ||
  2144.         (inp >= (UI_character_type) 'a' && inp <= (UI_character_type) 'z'))
  2145.     {
  2146.         for (i = 0; i < NUM_CITYS; i++)
  2147.         {
  2148.             memcpy(&n1, homeCityDataPtr[i], ENCODING_LENGTH);
  2149.             if (n1 >= inp)
  2150.             {
  2151.                 return (U8) (i);
  2152.             }
  2153.         }
  2154.         if (i == NUM_CITYS)
  2155.         {
  2156.             return i - 1;
  2157.         }
  2158.         else
  2159.         {
  2160.             return 0;
  2161.         }
  2162.     }
  2163.     return 0;
  2164. }
  2165. /*****************************************************************************
  2166.  * FUNCTION
  2167.  *  PhnsetHCMultiTapHdlr
  2168.  * DESCRIPTION
  2169.  *  This function is multitap handler when browsing home city in english mode
  2170.  *  for Phonesetup->Time and Date->Home City
  2171.  *  Functionality:
  2172.  * PARAMETERS
  2173.  *  inp     [IN]        
  2174.  * RETURNS
  2175.  *  void
  2176.  *****************************************************************************/
  2177. void PhnsetHCMultiTapHdlr(UI_character_type inp)
  2178. {
  2179.     /*----------------------------------------------------------------*/
  2180.     /* Local Variables                                                */
  2181.     /*----------------------------------------------------------------*/
  2182.     /*----------------------------------------------------------------*/
  2183.     /* Code Body                                                      */
  2184.     /*----------------------------------------------------------------*/
  2185.     g_phnset_cntx_p->curHightlightItem = (U32) PhnsetHCGetNearbyIdx(inp);
  2186.     dynamic_list_goto_item((S32) g_phnset_cntx_p->curHightlightItem);
  2187. }
  2188. /*****************************************************************************
  2189.  * FUNCTION
  2190.  *  PhnsetHCMultiTapCompleteHdlr
  2191.  * DESCRIPTION
  2192.  *  This function is to
  2193.  *  Functionality:
  2194.  * PARAMETERS
  2195.  *  void
  2196.  * RETURNS
  2197.  *  void
  2198.  *****************************************************************************/
  2199. void PhnsetHCMultiTapCompleteHdlr(void)
  2200. {
  2201.     /*----------------------------------------------------------------*/
  2202.     /* Local Variables                                                */
  2203.     /*----------------------------------------------------------------*/
  2204.     /*----------------------------------------------------------------*/
  2205.     /* Code Body                                                      */
  2206.     /*----------------------------------------------------------------*/
  2207.     dynamic_list_goto_item((S32) g_phnset_cntx_p->curHightlightItem);
  2208. }
  2209. /*****************************************************************************
  2210.  * FUNCTION
  2211.  *  PhnsetSetDTFromAT
  2212.  * DESCRIPTION
  2213.  *  This function is to set date and time from AT command
  2214.  *  Functionality:
  2215.  * PARAMETERS
  2216.  *  mytime      [IN]        
  2217.  * RETURNS
  2218.  *  void
  2219.  *****************************************************************************/
  2220. MMI_BOOL PhnsetSetDTFromAT(MYTIME mytime)
  2221. {
  2222.     /*----------------------------------------------------------------*/
  2223.     /* Local Variables                                                */
  2224.     /*----------------------------------------------------------------*/
  2225. #ifdef MMI_ON_HARDWARE_P
  2226.     MYQUEUE msgStruct;
  2227. #endif 
  2228.     RTCTIMEFORMAT *time;
  2229.     U8 dummyString[5 * ENCODING_LENGTH];    /* max is year 2003 */
  2230.     /*----------------------------------------------------------------*/
  2231.     /* Code Body                                                      */
  2232.     /*----------------------------------------------------------------*/
  2233.     if (mytime.nYear < 1970 || mytime.nYear > 2030
  2234.         || mytime.nMonth > 12 ||
  2235.         mytime.nDay > LastDayOfMonth(mytime.nMonth, mytime.nYear) || mytime.nHour > 23 || mytime.nMin > 59)
  2236.     {
  2237.         return MMI_FALSE;
  2238.     }
  2239.     sprintf(gHour, "%d", mytime.nHour);
  2240.     sprintf(gMinute, "%d", mytime.nMin);
  2241.     sprintf(gYear, "%d", mytime.nYear);
  2242.     sprintf(gMonth, "%d", mytime.nMonth);
  2243.     sprintf(gDate, "%d", mytime.nDay);
  2244.     AnsiiToUnicodeString((PS8) dummyString, (PS8) gHour);
  2245.     pfnUnicodeStrcpy((PS8) gHour, (PS8) dummyString);
  2246.     AnsiiToUnicodeString((PS8) dummyString, (PS8) gMinute);
  2247.     pfnUnicodeStrcpy((PS8) gMinute, (PS8) dummyString);
  2248.     AnsiiToUnicodeString((PS8) dummyString, (PS8) gYear);
  2249.     pfnUnicodeStrcpy((PS8) gYear, (PS8) dummyString);
  2250.     AnsiiToUnicodeString((PS8) dummyString, (PS8) gMonth);
  2251.     pfnUnicodeStrcpy((PS8) gMonth, (PS8) dummyString);
  2252.     AnsiiToUnicodeString((PS8) dummyString, (PS8) gDate);
  2253.     pfnUnicodeStrcpy((PS8) gDate, (PS8) dummyString);
  2254.     time = OslConstructDataPtr(sizeof(RTCTIMEFORMAT));
  2255.     time->info.alarm_format = 0;
  2256.     time->info.alarm_index = 0;
  2257.     time->info.type = 0;
  2258.     time->info.text[0] = '';
  2259.     time->info.recurr = 0;
  2260.     time->info.data_time.rtc_sec = mytime.nSec;
  2261.     time->info.data_time.rtc_min = mytime.nMin;
  2262.     time->info.data_time.rtc_hour = mytime.nHour;
  2263. #ifdef __MTK_TARGET__
  2264.     time->rtc_type = RTC_TIME_CLOCK_IND;
  2265.     time->set_type = RTC_SETTING_TYPE_DATETIME;
  2266.     time->info.data_time.rtc_day = mytime.nDay;         /* gclockData.rtc_hour; */
  2267.     time->info.data_time.rtc_mon = mytime.nMonth;       /* gclockData.rtc_mon; */
  2268.     time->info.data_time.rtc_wday = mytime.DayIndex;    /* gclockData.rtc_wday; */
  2269.     time->info.data_time.rtc_year = mytime.nYear - YEARFORMATE; /* gclockData.rtc_year; */
  2270.     msgStruct.oslSrcId = MOD_MMI;
  2271.     msgStruct.oslDestId = MOD_L4C;
  2272.     msgStruct.oslMsgId = HW_SET_TIME_REQ;
  2273.     msgStruct.oslSapId = 0;
  2274.     msgStruct.oslDataPtr = (oslParaType*) time;
  2275.     msgStruct.oslPeerBuffPtr = NULL;
  2276.     OslMsgSendExtQueue(&msgStruct);
  2277.     PhnsetSendSetTimeReqMessage();
  2278. #else /* __MTK_TARGET__ */ 
  2279.     time->rtc_type = 0;
  2280.     time->set_type = 2;
  2281.     time->info.data_time.rtc_day = mytime.nDay;
  2282.     time->info.data_time.rtc_mon = mytime.nMonth;
  2283.     time->info.data_time.rtc_wday = 0;
  2284.     time->info.data_time.rtc_year = (U8) (mytime.nYear - 1900);
  2285.     {
  2286.         RESULTSTRUCT resp;
  2287.         resp.result = 1;
  2288.         PhnsetSetTimeResHdlr(&resp);
  2289.     }
  2290. #endif /* __MTK_TARGET__ */ 
  2291.     return MMI_TRUE;
  2292. }
  2293. /*****************************************************************************
  2294.  * FUNCTION
  2295.  *  PhnsetSendSetTimeReqMessage
  2296.  * DESCRIPTION
  2297.  *  This function is to send set time request to L4
  2298.  *  for Phonesetup->Time and Date->Set Time/Date
  2299.  *  Functionality:
  2300.  * PARAMETERS
  2301.  *  void
  2302.  * RETURNS
  2303.  *  void
  2304.  *****************************************************************************/
  2305. void PhnsetSendSetTimeReqMessage(void)
  2306. {
  2307.     /*----------------------------------------------------------------*/
  2308.     /* Local Variables                                                */
  2309.     /*----------------------------------------------------------------*/
  2310. #ifdef MMI_ON_HARDWARE_P
  2311.     MYQUEUE msgStruct;
  2312. #endif 
  2313.     RTCTIMEFORMAT *time;
  2314.     /*----------------------------------------------------------------*/
  2315.     /* Code Body                                                      */
  2316.     /*----------------------------------------------------------------*/
  2317.     g_phnset_cntx_p->settime.hour = (U8) gui_atoi((UI_string_type) gHour);
  2318.     g_phnset_cntx_p->settime.minutes = (U8) gui_atoi((UI_string_type) gMinute);
  2319.     g_phnset_cntx_p->settime.month = (U8) gui_atoi((UI_string_type) gMonth);
  2320.     g_phnset_cntx_p->settime.date = (U8) gui_atoi((UI_string_type) gDate);
  2321.     g_phnset_cntx_p->settime.year = (U16) gui_atoi((UI_string_type) gYear);
  2322.     if (SetFromAT == FALSE)
  2323.     {
  2324.         SetProtocolEventHandler(PhnsetSetTimeResHdlr, HW_SET_TIME_REQ_SUCCESS);
  2325.     }
  2326.     else
  2327.     {
  2328.         SetProtocolEventHandler(PhnsetSetTimeResHdlrForAT, HW_SET_TIME_REQ_SUCCESS);
  2329.         SetFromAT = FALSE;
  2330.         return;
  2331.     }
  2332.     time = OslConstructDataPtr(sizeof(RTCTIMEFORMAT));
  2333.     time->info.alarm_format = 0;
  2334.     time->info.alarm_index = 0;
  2335.     time->info.type = 0;
  2336.     time->info.text[0] = '';
  2337.     time->info.recurr = 0;
  2338.     time->info.data_time.rtc_sec = 0;
  2339.     time->info.data_time.rtc_min = g_phnset_cntx_p->settime.minutes;
  2340.     time->info.data_time.rtc_hour = g_phnset_cntx_p->settime.hour;
  2341. #ifdef __MTK_TARGET__
  2342.     time->rtc_type = RTC_TIME_CLOCK_IND;
  2343.     time->set_type = RTC_SETTING_TYPE_DATETIME;
  2344.     time->info.data_time.rtc_day = g_phnset_cntx_p->settime.date;
  2345.     time->info.data_time.rtc_mon = g_phnset_cntx_p->settime.month;
  2346.     time->info.data_time.rtc_wday = gclockData.rtc_wday;
  2347.     time->info.data_time.rtc_year = g_phnset_cntx_p->settime.year - YEARFORMATE;
  2348.     msgStruct.oslSrcId = MOD_MMI;
  2349.     msgStruct.oslDestId = MOD_L4C;
  2350.     msgStruct.oslMsgId = HW_SET_TIME_REQ;
  2351.     msgStruct.oslSapId = 0;
  2352.     msgStruct.oslDataPtr = (oslParaType*) time;
  2353.     msgStruct.oslPeerBuffPtr = NULL;
  2354.     OslMsgSendExtQueue(&msgStruct);
  2355. #else /* __MTK_TARGET__ */ 
  2356.     time->rtc_type = 0;
  2357.     time->set_type = 2;
  2358.     time->info.data_time.rtc_day = g_phnset_cntx_p->settime.date;
  2359.     time->info.data_time.rtc_mon = g_phnset_cntx_p->settime.month;
  2360.     time->info.data_time.rtc_wday = 0;
  2361.     time->info.data_time.rtc_year = (U8) (g_phnset_cntx_p->settime.year - 1900);
  2362.     {
  2363.         RESULTSTRUCT resp;
  2364.         resp.result = 1;
  2365.         PhnsetSetTimeResHdlr(&resp);
  2366.     }
  2367. #endif /* __MTK_TARGET__ */ 
  2368. }
  2369. /*****************************************************************************
  2370.  * FUNCTION
  2371.  *  PhnsetSetTimeResHdlr
  2372.  * DESCRIPTION
  2373.  *  This function is Set time response handler (MSG_ID_MMI_EQ_SET_RTC_TIME_RSP)
  2374.  *  for Phonesetup->Time and Date->Set Time/Date
  2375.  *  Functionality:
  2376.  * PARAMETERS
  2377.  *  info        [IN]        
  2378.  * RETURNS
  2379.  *  void
  2380.  *****************************************************************************/
  2381. void PhnsetSetTimeResHdlr(void *info)
  2382. {
  2383.     /*----------------------------------------------------------------*/
  2384.     /* Local Variables                                                */
  2385.     /*----------------------------------------------------------------*/
  2386.     RESULTSTRUCT *resp;
  2387.     /*----------------------------------------------------------------*/
  2388.     /* Code Body                                                      */
  2389.     /*----------------------------------------------------------------*/
  2390.     resp = (RESULTSTRUCT*) (info);
  2391.     if (resp->result == 1)
  2392.     {
  2393.     #ifdef __MTK_TARGET__
  2394.         gclockData.rtc_year = g_phnset_cntx_p->settime.year - YEARFORMATE;
  2395.         gclockData.rtc_mon = g_phnset_cntx_p->settime.month;
  2396.         gclockData.rtc_day = g_phnset_cntx_p->settime.date;
  2397.         gclockData.rtc_hour = g_phnset_cntx_p->settime.hour;
  2398.         gclockData.rtc_min = g_phnset_cntx_p->settime.minutes;
  2399.     #else /* __MTK_TARGET__ */ 
  2400.         MyTime.nHour = g_phnset_cntx_p->settime.hour;
  2401.         MyTime.nMin = g_phnset_cntx_p->settime.minutes;
  2402.         MyTime.nYear = g_phnset_cntx_p->settime.year;
  2403.         MyTime.nMonth = g_phnset_cntx_p->settime.month;
  2404.         MyTime.nDay = g_phnset_cntx_p->settime.date;
  2405.         DateTimerProc();
  2406.     #endif /* __MTK_TARGET__ */ 
  2407.         /* Lisen0522 */
  2408.         update_mainlcd_dt_display();
  2409.         update_sublcd_dt_display();
  2410.         //              AsyncEvent = FALSE;
  2411.         //              oneoccured=1;
  2412.         AlmReInitialize();
  2413.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, ST_NOTIFYDURATION, SUCCESS_TONE);
  2414.         DeleteNHistory(1);
  2415.     }
  2416.     else
  2417.     {
  2418.         /* AsyncEvent = FALSE; */
  2419.         DisplayPopup((PU8) GetString(STR_GLOBAL_UNFINISHED), IMG_GLOBAL_UNFINISHED, 1, ST_NOTIFYDURATION, ERROR_TONE);
  2420.         /* oneoccured = 1; */
  2421.     }
  2422. }
  2423. /*****************************************************************************
  2424.  * FUNCTION
  2425.  *  PhnsetSetTimeResHdlrForAT
  2426.  * DESCRIPTION
  2427.  *  This function is Set time response handler (MSG_ID_MMI_EQ_SET_RTC_TIME_RSP)
  2428.  *  for AT command, update idle screen, no popup
  2429.  *  Functionality:
  2430.  * PARAMETERS
  2431.  *  info        [IN]        
  2432.  * RETURNS
  2433.  *  void
  2434.  *****************************************************************************/
  2435. void PhnsetSetTimeResHdlrForAT(void *info)
  2436. {
  2437.     /*----------------------------------------------------------------*/
  2438.     /* Local Variables                                                */
  2439.     /*----------------------------------------------------------------*/
  2440.     RESULTSTRUCT *resp;
  2441.     /*----------------------------------------------------------------*/
  2442.     /* Code Body                                                      */
  2443.     /*----------------------------------------------------------------*/
  2444.     resp = (RESULTSTRUCT*) (info);
  2445.     if (resp->result == 1)
  2446.     {
  2447.     #ifdef __MTK_TARGET__
  2448.         gclockData.rtc_hour = g_phnset_cntx_p->settime.hour;
  2449.         gclockData.rtc_min = g_phnset_cntx_p->settime.minutes;
  2450.         gclockData.rtc_mon = g_phnset_cntx_p->settime.month;
  2451.         gclockData.rtc_day = g_phnset_cntx_p->settime.date;
  2452.         gclockData.rtc_year = g_phnset_cntx_p->settime.year - YEARFORMATE;
  2453.     #else /* __MTK_TARGET__ */ 
  2454.         MyTime.nHour = g_phnset_cntx_p->settime.hour;
  2455.         MyTime.nMin = g_phnset_cntx_p->settime.minutes;
  2456.         MyTime.nMonth = g_phnset_cntx_p->settime.month;
  2457.         MyTime.nDay = g_phnset_cntx_p->settime.date;
  2458.         MyTime.nYear = g_phnset_cntx_p->settime.year;
  2459.         DateTimerProc();
  2460.     #endif /* __MTK_TARGET__ */ 
  2461.         update_mainlcd_dt_display();
  2462.         update_sublcd_dt_display();
  2463.         AlmReInitialize();
  2464.     }
  2465. }
  2466. /*****************************************************************************
  2467.  * FUNCTION
  2468.  *  PhnsetGetTimeFormat
  2469.  * DESCRIPTION
  2470.  *  This function is to get time format
  2471.  *  Functionality:
  2472.  * PARAMETERS
  2473.  *  void
  2474.  * RETURNS
  2475.  *  void
  2476.  *****************************************************************************/
  2477. U8 PhnsetGetTimeFormat(void)
  2478. {
  2479.     /*----------------------------------------------------------------*/
  2480.     /* Local Variables                                                */
  2481.     /*----------------------------------------------------------------*/
  2482.     S16 error;
  2483.     U8 output;
  2484.     /*----------------------------------------------------------------*/
  2485.     /* Code Body                                                      */
  2486.     /*----------------------------------------------------------------*/
  2487.     ReadValue(TIME_FORMAT, &output, DS_BYTE, &error);
  2488.     /* output = output & 0x0F; */
  2489.     if ((error != NVRAM_READ_SUCCESS) || output > NUM_TIME_FORMATS)
  2490.     {
  2491.         return 1;   /* default format */
  2492.     }
  2493.     else
  2494.     {
  2495.         return output;
  2496.     }
  2497. }
  2498. /*****************************************************************************
  2499.  * FUNCTION
  2500.  *  PhnsetGetDateFormat
  2501.  * DESCRIPTION
  2502.  *  This function is to get date format
  2503.  *  Functionality:
  2504.  * PARAMETERS
  2505.  *  void
  2506.  * RETURNS
  2507.  *  void
  2508.  *****************************************************************************/
  2509. U8 PhnsetGetDateFormat(void)
  2510. {
  2511.     /*----------------------------------------------------------------*/
  2512.     /* Local Variables                                                */
  2513.     /*----------------------------------------------------------------*/
  2514.     S16 error;
  2515.     U8 output;
  2516.     /*----------------------------------------------------------------*/
  2517.     /* Code Body                                                      */
  2518.     /*----------------------------------------------------------------*/
  2519.     ReadValue(DATE_FORMAT, &output, DS_BYTE, &error);
  2520.     /* output = output >> 4; */
  2521.     if ((error != NVRAM_READ_SUCCESS || output > NUM_DATE_FORMATS))
  2522.     {
  2523.         return 0;   /* default format */
  2524.     }
  2525.     else
  2526.     {
  2527.         return output;  /* first four bits */
  2528.     }
  2529. }
  2530. /*****************************************************************************
  2531.  * FUNCTION
  2532.  *  PhnsetSetTimeFormat
  2533.  * DESCRIPTION
  2534.  *  This function is to set time format
  2535.  *  Functionality:
  2536.  * PARAMETERS
  2537.  *  timeformat      [IN]        
  2538.  * RETURNS
  2539.  *  void
  2540.  *****************************************************************************/
  2541. S16 PhnsetSetTimeFormat(U8 timeformat)
  2542. {
  2543.     /*----------------------------------------------------------------*/
  2544.     /* Local Variables                                                */
  2545.     /*----------------------------------------------------------------*/
  2546.     S16 error = NVRAM_WRITE_SUCCESS;
  2547.     U8 input = timeformat;
  2548.     /*----------------------------------------------------------------*/
  2549.     /* Code Body                                                      */
  2550.     /*----------------------------------------------------------------*/
  2551.     if (timeformat != PhnsetGetTimeFormat())
  2552.     {
  2553.         WriteValue(TIME_FORMAT, &input, DS_BYTE, &error);
  2554.         gCurrentOnOff = input;
  2555.         /* chgcnt ++; */
  2556.     }
  2557.     return error;
  2558. }
  2559. /*****************************************************************************
  2560.  * FUNCTION
  2561.  *  PhnsetSetDateFormat
  2562.  * DESCRIPTION
  2563.  *  This function is to set date format
  2564.  *  Functionality:
  2565.  * PARAMETERS
  2566.  *  dateformat      [IN]        
  2567.  * RETURNS
  2568.  *  void
  2569.  *****************************************************************************/
  2570. S16 PhnsetSetDateFormat(U8 dateformat)
  2571. {
  2572.     /*----------------------------------------------------------------*/
  2573.     /* Local Variables                                                */
  2574.     /*----------------------------------------------------------------*/
  2575.     S16 error = NVRAM_WRITE_SUCCESS;
  2576.     U8 input = dateformat;
  2577.     /*----------------------------------------------------------------*/
  2578.     /* Code Body                                                      */
  2579.     /*----------------------------------------------------------------*/
  2580.     if (dateformat != PhnsetGetDateFormat())
  2581.     {
  2582.         WriteValue(DATE_FORMAT, &input, DS_BYTE, &error);
  2583.         gCurrentOnOff = input;
  2584.         //SendMessageDateAndShowScreen();
  2585.         //chgcnt ++;
  2586.     }
  2587.     return error;
  2588. }
  2589. /*****************************************************************************
  2590.  * FUNCTION
  2591.  *  ATSetHomeCity
  2592.  * DESCRIPTION
  2593.  *  Set home city from AT command
  2594.  * PARAMETERS
  2595.  *  CityIndex       [IN]        
  2596.  * RETURNS
  2597.  *  void
  2598.  *****************************************************************************/
  2599. BOOL ATSetHomeCity(U8 CityIndex)
  2600. {
  2601.     /*----------------------------------------------------------------*/
  2602.     /* Local Variables                                                */
  2603.     /*----------------------------------------------------------------*/
  2604.     U8 PrevCity;
  2605. S16 timezone;
  2606.     S16 error;
  2607.     /*----------------------------------------------------------------*/
  2608.     /* Code Body                                                      */
  2609.     /*----------------------------------------------------------------*/
  2610.     /* index exceeds boundary */
  2611.     /* remove the 0 (none case), so size of home city table shall minus by 1 */
  2612.     if (CityIndex > (NUMBER_OF_CITY - 1) || CityIndex == 0)
  2613.     {
  2614.         return MMI_FALSE;
  2615.     }
  2616.     CityIndex -= 1; /* Sync to the index of highlite */
  2617.     /* read current city index from NVRAM */
  2618.     ReadValue(CURRENT_CITY, &PrevCity, DS_BYTE, &error);
  2619.     {
  2620.         g_phnset_cntx_p->currentCity = CityIndex;
  2621.         /* retrieve string pointer of city name */
  2622.         /* The index of menu is bigger than that one of TimeZoneData */
  2623.         g_phnset_cntx_p->CurHomeCityStrPtr =
  2624.             (PU8) ((GetString) ((U16) (TimeZoneData[g_phnset_cntx_p->currentCity + 1].CityName)));
  2625.         /* write city index to NVRAM */
  2626.         WriteValue(CURRENT_CITY, &(g_phnset_cntx_p->currentCity), DS_BYTE, &error);
  2627.         /* write NITZ setting to NVRAM */
  2628.         timezone = (S16) (GetTimeZone(PhnsetGetHomeCity()) * 4);
  2629. WriteValue(NVRAM_TIMEZONE, &timezone, DS_SHORT, &error);
  2630.         /* update sub lcd display */
  2631.         ShowIdleAppSubLcd();
  2632.     }
  2633.     return MMI_TRUE;
  2634. }
  2635. #if ( defined(__MMI_NITZ__) && defined(__MMI_AUTOTIMEZONE_IN_DATEANDTIME__))
  2636. /*****************************************************************************
  2637.  * FUNCTION
  2638.  *  PhnsetGetNITZFuncStatus
  2639.  * DESCRIPTION
  2640.  *  This function is to get NITZ function on/off status
  2641.  *  Functionality: Only exist when (__MMI_NITZ__) and (!__MMI_AUTOTIMEZONE_IN_DATEANDTIME__)
  2642.  * PARAMETERS
  2643.  *  void
  2644.  * RETURNS
  2645.  *  void
  2646.  *****************************************************************************/
  2647. MMI_BOOL PhnsetGetNITZFuncStatus(void)
  2648. {
  2649.     /*----------------------------------------------------------------*/
  2650.     /* Local Variables                                                */
  2651.     /*----------------------------------------------------------------*/
  2652.     U8 data = 0;
  2653.     S16 error;
  2654.     /*----------------------------------------------------------------*/
  2655.     /* Code Body                                                      */
  2656.     /*----------------------------------------------------------------*/
  2657.     ReadValue(NVRAM_SETTING_AUTOUPDATE_DT_TIME, &data, DS_BYTE, &error);
  2658.     if (data == 1)
  2659.     {
  2660.         return MMI_TRUE;
  2661.     }
  2662.     else if (data == 0xff)
  2663.     {
  2664.         data = RstGetNITZStatusDefault();
  2665.         WriteValue(NVRAM_SETTING_AUTOUPDATE_DT_TIME, &data, DS_BYTE, &error);
  2666.         return MMI_FALSE;
  2667.     }
  2668.     else
  2669.     {
  2670.         return MMI_FALSE;
  2671.     }
  2672. }
  2673. /*****************************************************************************
  2674.  * FUNCTION
  2675.  *  HintPhnsetNITZ
  2676.  * DESCRIPTION
  2677.  *  This function is hint handling function
  2678.  *  for Phonesetup -> Auto Update of Date and Time
  2679.  *  Functionality:
  2680.  * PARAMETERS
  2681.  *  index       [IN]        
  2682.  * RETURNS
  2683.  *  void
  2684.  *****************************************************************************/
  2685. void HintPhnsetNITZ(U16 index)
  2686. {
  2687.     /*----------------------------------------------------------------*/
  2688.     /* Local Variables                                                */
  2689.     /*----------------------------------------------------------------*/
  2690.     /*----------------------------------------------------------------*/
  2691.     /* Code Body                                                      */
  2692.     /*----------------------------------------------------------------*/
  2693.     if (PhnsetGetNITZFuncStatus())
  2694.     {
  2695.         g_phnset_cntx_p->curNITZStatus = 1;
  2696.         pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_GLOBAL_ON));
  2697.     }
  2698.     else
  2699.     {
  2700.         g_phnset_cntx_p->curNITZStatus = 0;
  2701.         pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_GLOBAL_OFF));
  2702.     }
  2703. }
  2704. /*****************************************************************************
  2705.  * FUNCTION
  2706.  *  HighlightPhnsetNITZ
  2707.  * DESCRIPTION
  2708.  *  This function is highlight handler for Phonesetup-> Auto Update Date and Time
  2709.  *  Follow functions:tEntryAutoUpdateDtTime
  2710.  * PARAMETERS
  2711.  *  void
  2712.  * RETURNS
  2713.  *  void
  2714.  *****************************************************************************/
  2715. void HighlightPhnsetNITZ(void)
  2716. {
  2717.     /*----------------------------------------------------------------*/
  2718.     /* Local Variables                                                */
  2719.     /*----------------------------------------------------------------*/
  2720.     /*----------------------------------------------------------------*/
  2721.     /* Code Body                                                      */
  2722.     /*----------------------------------------------------------------*/
  2723.     /* datetimeindex = 3; */
  2724.     g_phnset_cntx_p->curHightlightItem = PHNSET_DT_MNU_NITZ;
  2725.     //highlightedDateSetItem =0;
  2726.     //g_phnset_cntx_p->curHightlightItem = 0;
  2727.     /* Set the LSK to Off when Auto Update is ON */
  2728.     if (g_phnset_cntx_p->curNITZStatus == 1)
  2729.     {
  2730.         ChangeLeftSoftkey(STR_GLOBAL_OFF, 0);
  2731.     }
  2732.     else
  2733.     {
  2734.         ChangeLeftSoftkey(STR_GLOBAL_ON, 0);
  2735.     }
  2736.     /* Change right soft key icon and label */
  2737.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  2738.     /* Change left soft key icon and label */
  2739.     SetKeyHandler(0, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  2740.     /* Register function for left soft key */
  2741.     SetLeftSoftkeyFunction(EntryPhnsetNITZ, KEY_EVENT_UP);
  2742.     /* Register function for right soft key */
  2743.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2744.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2745. }
  2746. /*****************************************************************************
  2747.  * FUNCTION
  2748.  *  EntryPhnsetNITZ
  2749.  * DESCRIPTION
  2750.  *  This function is Left softkey handler for Phonesetup-> Auto Update Date and Time
  2751.  *  Functionality: Toggle status only
  2752.  * PARAMETERS
  2753.  *  void
  2754.  * RETURNS
  2755.  *  void
  2756.  *****************************************************************************/
  2757. void EntryPhnsetNITZ(void)
  2758. {
  2759.     /*----------------------------------------------------------------*/
  2760.     /* Local Variables                                                */
  2761.     /*----------------------------------------------------------------*/
  2762.     U16 index;
  2763.     /*----------------------------------------------------------------*/
  2764.     /* Code Body                                                      */
  2765.     /*----------------------------------------------------------------*/
  2766.     /* index = (U16)datetimeindex; */
  2767.     index = GetCurrHiliteID();
  2768.     /* Toggle Auto Update of Date And Time */
  2769.     if (g_phnset_cntx_p->curNITZStatus == 0)
  2770.     {
  2771.         g_phnset_cntx_p->curNITZStatus = 1;
  2772.     }
  2773.     else
  2774.     {
  2775.         g_phnset_cntx_p->curNITZStatus = 0;
  2776.     }
  2777.     /* Store the updated Value */
  2778.     g_phnset_cntx_p->NITZDirtyFlag = TRUE;
  2779.     if (g_phnset_cntx_p->curNITZStatus)
  2780.     {
  2781.         pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_GLOBAL_ON));
  2782.         Category53ChangeItemDescription(index, hintData[index]);
  2783.         ChangeLeftSoftkey(STR_GLOBAL_OFF, 0);
  2784.     }
  2785.     else
  2786.     {
  2787.         pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_GLOBAL_OFF));
  2788.         Category53ChangeItemDescription(index, hintData[index]);
  2789.         ChangeLeftSoftkey(STR_GLOBAL_ON, 0);
  2790.     }
  2791.     RedrawCategoryFunction();
  2792.     HighlightPhnsetNITZ();
  2793. }
  2794. #endif  /* #if ( defined(__MMI_NITZ__) && defined(__MMI_AUTOTIMEZONE_IN_DATEANDTIME__)   )  */
  2795. #ifdef __MMI_WC_TZ_SUPPORT__
  2796. U8 mmi_wc_entry_from_phnset(void)
  2797. {
  2798.     if (IsScreenPresent(SCR9041_TIMEANDDATE) && 
  2799.         g_phnset_cntx_p->curHightlightItem == PHNSET_DT_MNU_HOMECT
  2800.         )
  2801.     {
  2802.         return MMI_TRUE;
  2803.     }
  2804.     else
  2805.     {
  2806.         return MMI_FALSE;
  2807.     }
  2808. }
  2809. #endif
  2810. #endif /* _DATEANDTIME_C */