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

MTK

开发平台:

C/C++

  1.  *  void
  2.  *****************************************************************************/
  3. void HighlightThmOption(S32 nIndex)
  4. {
  5. #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  6.     /*----------------------------------------------------------------*/
  7.     /* Local Variables                                                */
  8.     /*----------------------------------------------------------------*/
  9.     /*----------------------------------------------------------------*/
  10.     /* Code Body                                                      */
  11.     /*----------------------------------------------------------------*/
  12.     if ((mmi_tm_get_usb_mode() || mmi_bootup_is_sim_removed()
  13. #ifdef __FLIGHT_MODE_SUPPORT__
  14.          || mmi_bootup_get_active_flight_mode()
  15. #endif 
  16.         ) && nIndex == 3)
  17.     {
  18.         nIndex++;
  19.     }
  20.     switch (nIndex)
  21.     {
  22.         case 0:
  23.             SetLeftSoftkeyFunction(ActivateTheme, KEY_EVENT_UP);
  24.             ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  25.             break;
  26.         case 1:
  27.             SetLeftSoftkeyFunction(EntryThmUpdatePeriod, KEY_EVENT_UP);
  28.             SetKeyHandler(EntryThmUpdatePeriod, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  29.             break;
  30.         case 2:
  31.             SetLeftSoftkeyFunction(EntryThmSetOrder, KEY_EVENT_UP);
  32.             SetKeyHandler(EntryThmSetOrder, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  33.             break;
  34.         case 3:
  35.             SetLeftSoftkeyFunction(preEntryThmDownload, KEY_EVENT_UP);
  36.             SetKeyHandler(EntryThmDownload, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  37.             break;
  38.         case 4:
  39.             SetLeftSoftkeyFunction(ThemeDeleteConfirmation, KEY_EVENT_UP);
  40.             ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  41.             break;
  42.     }
  43. #else /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  44.     switch (nIndex)
  45.     {
  46.         case 0:
  47.             SetLeftSoftkeyFunction(ActivateTheme, KEY_EVENT_UP);
  48.             ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  49.             break;
  50.         case 1:
  51.             SetLeftSoftkeyFunction(EntryThmUpdatePeriod, KEY_EVENT_UP);
  52.             SetKeyHandler(EntryThmUpdatePeriod, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  53.             break;
  54.         case 2:
  55.             SetLeftSoftkeyFunction(EntryThmSetOrder, KEY_EVENT_UP);
  56.             SetKeyHandler(EntryThmSetOrder, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  57.             break;
  58.     }
  59. #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  60. }
  61. /*****************************************************************************
  62.  * FUNCTION
  63.  *  EntryThmOptions
  64.  * DESCRIPTION
  65.  *  Entry func of themes option menu
  66.  * PARAMETERS
  67.  *  void
  68.  * RETURNS
  69.  *  void
  70.  *****************************************************************************/
  71. void EntryThmOptions(void)
  72. {
  73.     /*----------------------------------------------------------------*/
  74.     /* Local Variables                                                */
  75.     /*----------------------------------------------------------------*/
  76.     U8 *guiBuffer;
  77.     U16 ItemList[16];
  78.     U16 nItems;
  79. #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  80.     /* PMT DLT_FIXES - TK 20060321 START */
  81.     U8 *temp_name;
  82.     U8 nSystemThemeCount;
  83. #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  84.     /*----------------------------------------------------------------*/
  85.     /* Code Body                                                      */
  86.     /*----------------------------------------------------------------*/
  87.     /* PMT DLT_FIXES - TK 20060321 END */
  88.     EntryNewScreen(SCR_ID_THM_OPTIONS, NULL, EntryThmOptions, NULL);
  89.     ThmRedrawTheme();
  90. #ifndef __MMI_THEMES_V2_SUPPORT__
  91.     g_thm_cntx.IsInThmApp = 2;
  92. #endif 
  93. #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  94.     if (g_thm_cntx.CurrHiliteTheme == g_thm_cntx.CurrTheme)
  95.     {
  96.         /* PMT DNLD_THEME_FIXES: SUKRIT START BUG# MAUI_00221092 */
  97.         if (mmi_bootup_is_sim_removed()
  98.     #ifdef __FLIGHT_MODE_SUPPORT__
  99.             || mmi_bootup_get_active_flight_mode()
  100.     #endif 
  101.             )
  102.         {
  103.             nItems = GetNumOfChild(MENU3001_THEMES_LIST_1_FLIGHTMODE);
  104.             GetSequenceStringIds(MENU3001_THEMES_LIST_1_FLIGHTMODE, ItemList);
  105.         }
  106.         else
  107.         {
  108.             nItems = GetNumOfChild(MENU3001_THEMES_LIST_1);
  109.             GetSequenceStringIds(MENU3001_THEMES_LIST_1, ItemList);
  110.         }
  111.         /* PMT DNLD_THEME_FIXES: SUKRIT END BUG# MAUI_00221092 */
  112.     }
  113.     else
  114.     {
  115.         /* PMT DLT_FIXES - TK 20060321 START */
  116.         nSystemThemeCount = (U8) GetThemesNames((U8 ***) & temp_name);
  117.         if (nSystemThemeCount > MAX_SYSTEM_THEMES)
  118.         {
  119.             nSystemThemeCount = MAX_SYSTEM_THEMES;
  120.         }
  121.         if (g_temp_thm_index < nSystemThemeCount)
  122.             /* PMT DLT_FIXES - TK 20060321 START */
  123.         {
  124.             /* PMT DNLD_THEME_FIXES: SUKRIT START BUG# MAUI_00221092 */
  125.             if (mmi_bootup_is_sim_removed()
  126.         #ifdef __FLIGHT_MODE_SUPPORT__
  127.                 || mmi_bootup_get_active_flight_mode()
  128.         #endif 
  129.                 )
  130.             {
  131.                 nItems = GetNumOfChild(MENU3001_THEMES_LIST_1_FLIGHTMODE);
  132.                 GetSequenceStringIds(MENU3001_THEMES_LIST_1_FLIGHTMODE, ItemList);
  133.             }
  134.             else
  135.             {
  136.                 nItems = GetNumOfChild(MENU3001_THEMES_LIST_1);
  137.                 GetSequenceStringIds(MENU3001_THEMES_LIST_1, ItemList);
  138.             }
  139.             /* PMT DNLD_THEME_FIXES: SUKRIT END BUG# MAUI_00221092 */
  140.         }
  141.         else
  142.         {
  143.             /* PMT DNLD_THEME_FIXES: SUKRIT START BUG# MAUI_00221092 */
  144.             if (mmi_bootup_is_sim_removed()
  145.         #ifdef __FLIGHT_MODE_SUPPORT__
  146.                 || mmi_bootup_get_active_flight_mode()
  147.         #endif 
  148.                 )
  149.             {
  150.                 nItems = GetNumOfChild(MENU3001_THEMES_LIST_FLIGHTMODE);
  151.                 GetSequenceStringIds(MENU3001_THEMES_LIST_FLIGHTMODE, ItemList);
  152.             }
  153.             else
  154.             {
  155.                 nItems = GetNumOfChild(MENU3001_THEMES_LIST);
  156.                 GetSequenceStringIds(MENU3001_THEMES_LIST, ItemList);
  157.             }
  158.             /* PMT DNLD_THEME_FIXES: SUKRIT END BUG# MAUI_00221092 */
  159.         }
  160.     }
  161.     if (mmi_tm_get_usb_mode() == MMI_TRUE)
  162.     {
  163.         nItems = NO_OF_THEME_OPTION_MENUITEMS_IN_USB_MODE;  /* First Menuitem active, Second Update Period no other menu items */
  164.     }
  165. #else /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  166.     nItems = GetNumOfChild(MENU3001_THEMES_LIST);
  167.     GetSequenceStringIds(MENU3001_THEMES_LIST, ItemList);
  168. #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */     
  169.     SetParentHandler(MENU3001_THEMES_LIST);
  170.     RegisterHighlightHandler(HighlightThmOption);
  171.     guiBuffer = GetCurrGuiBuffer(SCR_ID_THM_OPTIONS);
  172.     RegisterHighlightHandler(HighlightThmOption);
  173.     ShowCategory52Screen(
  174.         STR_GLOBAL_OPTIONS,
  175.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  176.         STR_GLOBAL_OK,
  177.         IMG_GLOBAL_OK,
  178.         STR_GLOBAL_BACK,
  179.         IMG_GLOBAL_BACK,
  180.         nItems,
  181.         ItemList,
  182.         (PU16) gIndexIconsImageList,
  183.         NULL,
  184.         0,
  185.         0,
  186.         guiBuffer);
  187.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  188.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  189.     SetKeyHandler(ThmHandleEndKey, KEY_END, KEY_EVENT_DOWN);
  190. }
  191. /*****************************************************************************
  192. * FUNCTION
  193. *  mmi_thm_create_freq_table
  194. * DESCRIPTION
  195. *   This fuction builds the display information of the selected alarm, and then enter
  196. *  alarm screen.
  197. * PARAMETERS
  198. *  None.
  199. * RETURNS
  200. *  None.
  201. * GLOBALS AFFECTED
  202. *  None
  203. *****************************************************************************/
  204. /* void mmi_thm_create_freq_table(void)
  205.    {
  206.    g_themes_freq_set.AlmFreqSet[0] = OFF;
  207.    g_themes_freq_set.AlmFreqSet[1] = HOURLY ;
  208.    g_themes_freq_set.AlmFreqSet[2] = EVERYDAY;
  209.    g_themes_freq_set.AlmFreqSet[3] = WEEKLY;
  210.    g_themes_freq_set.AlmFreqSet[4] = MONTHLY;
  211.    g_themes_freq_set.AlmFreqSet[5] = SEASONALLY;
  212.    } */
  213. /*****************************************************************************
  214.  * FUNCTION
  215.  *  EntryThmUpdatePeriod
  216.  * DESCRIPTION
  217.  *  entry func of themes update period menu
  218.  * PARAMETERS
  219.  *  void
  220.  * RETURNS
  221.  *  void
  222.  *****************************************************************************/
  223. void EntryThmUpdatePeriod(void)
  224. {
  225.     /*----------------------------------------------------------------*/
  226.     /* Local Variables                                                */
  227.     /*----------------------------------------------------------------*/
  228.     U16 ItemList[16];
  229.     U16 nItems;
  230.     U8 *guiBuffer;
  231.     /*----------------------------------------------------------------*/
  232.     /* Code Body                                                      */
  233.     /*----------------------------------------------------------------*/
  234.     EntryNewScreen(SCR_ID_THM_UPDATE_PERIOD, ExitThmUpdatePeriod, NULL, NULL);
  235. #ifdef __MMI_THEMES_V2_SUPPORT__
  236.     g_thm_cntx.IsInThmApp = 1;
  237. #else 
  238.     g_thm_cntx.IsInThmApp = 2;
  239. #endif 
  240.     guiBuffer = GetCurrGuiBuffer(SCR_ID_THM_UPDATE_PERIOD);
  241.     nItems = GetNumOfChild(MENU3201_UPDATE_PERIOD);
  242.     GetSequenceStringIds(MENU3201_UPDATE_PERIOD, ItemList);
  243.     SetParentHandler(MENU3201_UPDATE_PERIOD);
  244.     RegisterHighlightHandler(HighlightThmUpdatePeriod);
  245.     ShowCategory11Screen(
  246.         STR_SCR3003_UPDATE_PERIOD_CAPTION,
  247.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  248.         STR_GLOBAL_OK,
  249.         IMG_GLOBAL_OK,
  250.         STR_GLOBAL_BACK,
  251.         IMG_GLOBAL_BACK,
  252.         nItems,
  253.         ItemList,
  254.         (U16) g_thm_cntx.CurrUpdatePeriod,
  255.         guiBuffer);
  256.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  257.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  258.     SetKeyHandler(ThmHandleEndKey, KEY_END, KEY_EVENT_DOWN);
  259. }
  260. /*****************************************************************************
  261.  * FUNCTION
  262.  *  ExitThmUpdatePeriod
  263.  * DESCRIPTION
  264.  *  Exit func of themes update period menu
  265.  * PARAMETERS
  266.  *  void
  267.  * RETURNS
  268.  *  void
  269.  *****************************************************************************/
  270. void ExitThmUpdatePeriod(void)
  271. {
  272.     /*----------------------------------------------------------------*/
  273.     /* Local Variables                                                */
  274.     /*----------------------------------------------------------------*/
  275.     history h;
  276.     S16 nHistory = 0;
  277.     /*----------------------------------------------------------------*/
  278.     /* Code Body                                                      */
  279.     /*----------------------------------------------------------------*/
  280.     /* reset IsSetFromMenu flag */
  281. #ifdef __MMI_THEMES_V2_SUPPORT__
  282.     g_thm_cntx.IsInThmApp = 0;
  283. #endif 
  284.     g_thm_cntx.IsSetFromMenu = 0;
  285.     h.scrnID = SCR_ID_THM_UPDATE_PERIOD;
  286.     h.entryFuncPtr = EntryThmUpdatePeriod;
  287.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  288.     GetCategoryHistory(h.guiBuffer);
  289.     AddHistory(h);
  290. }
  291. /*****************************************************************************
  292.  * FUNCTION
  293.  *  ActivateTheme
  294.  * DESCRIPTION
  295.  *  Activate theme select bu yser and write to NVRAM
  296.  * PARAMETERS
  297.  *  void
  298.  * RETURNS
  299.  *  void
  300.  *****************************************************************************/
  301. void ActivateTheme()
  302. {
  303. #ifdef __MMI_THEMES_V2_SUPPORT__
  304.     /*----------------------------------------------------------------*/
  305.     /* Local Variables                                                */
  306.     /*----------------------------------------------------------------*/
  307.     U16 result;
  308.     /*----------------------------------------------------------------*/
  309.     /* Code Body                                                      */
  310.     /*----------------------------------------------------------------*/
  311.     EntryNewScreen(0, NULL, NULL, NULL);
  312.     ShowCategory66Screen(
  313.         STR_SCR3001_THEMES_CAPTION,
  314.         0,
  315.         0,
  316.         0,
  317.         0,
  318.         0,
  319.         (PU8) GetString(STR_ID_DLT_THM_PROGRESS),
  320.         IMG_THEME_ACTIVATION,
  321.         NULL);
  322.     result = mmi_tm_activate_theme(g_thm_cntx.CurrHiliteTheme);
  323.     switch (result)
  324.     {
  325.         case THEME_ERROR_SUCCESS:
  326.             g_thm_cntx.CurrTheme = g_thm_cntx.CurrHiliteTheme;
  327.             g_thm_cntx.CurrThemeIndex = g_temp_thm_index;
  328.             SetThemes(g_thm_cntx.CurrTheme);
  329.             if (g_themes_freq_set[g_thm_cntx.CurrUpdatePeriod] != ALM_FREQ_OFF)
  330.             {
  331.                 SetStartPositionofCurIndex();
  332.             }
  333.             SetCurrOrderIndex(g_thm_cntx.CurrOrderIndex);
  334.             arrange_status_icons();
  335.             DisplayPopup(
  336.                 (PU8) GetString(STR_THEME_ACTIVATE_SUCCESS),
  337.                 IMG_GLOBAL_ACTIVATED,
  338.                 TRUE,
  339.                 UI_POPUP_NOTIFYDURATION_TIME,
  340.                 SUCCESS_TONE);
  341.             DeleteUptoScrID(SCR_ID_THM_MENU);
  342.             break;
  343.         case THEME_ERROR_ALREADY_ACTIVATED:
  344.             DisplayPopup(
  345.                 (PU8) GetString(STR_ID_FMGR_ALREADY_ACTIVE),
  346.                 IMG_GLOBAL_INFO,
  347.                 TRUE,
  348.                 UI_POPUP_NOTIFYDURATION_TIME,
  349.                 WARNING_TONE);
  350.             break;
  351.         #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  352.         case THEME_ERROR_THEME_NOT_AVAILABLE:
  353.             DisplayPopup(
  354.                 (PU8) GetString(STR_THEME_NOT_AVAILABLE),
  355.                 IMG_GLOBAL_ERROR,
  356.                 TRUE,
  357.                 UI_POPUP_NOTIFYDURATION_TIME,
  358.                 WARNING_TONE);
  359.             break;
  360.         case THEME_ERROR_FILE_FORMAT_BAD:
  361.             DisplayPopup(
  362.                 (PU8) GetString(STR_THEME_FORMAT_NOT_SUPPORTED),
  363.                 IMG_GLOBAL_ERROR,
  364.                 TRUE,
  365.                 UI_POPUP_NOTIFYDURATION_TIME,
  366.                 WARNING_TONE);
  367.             break;
  368.         case THEME_ERROR_FAILURE:
  369.             DisplayPopup(
  370.                 (PU8) GetString(STR_THEME_UNKNOWN_ERROR),
  371.                 IMG_GLOBAL_ERROR,
  372.                 TRUE,
  373.                 UI_POPUP_NOTIFYDURATION_TIME,
  374.                 ERROR_TONE);
  375.             break;
  376.         case THEME_ERROR_VERSION_FAILURE:
  377.             DisplayPopup(
  378.                 (PU8) GetString(STR_DOWNLOAD_THEME_UNSUPPORTED),
  379.                 IMG_GLOBAL_WARNING,
  380.                 0,
  381.                 UI_POPUP_NOTIFYDURATION_TIME,
  382.                 WARNING_TONE);
  383.             break;
  384.         case THEME_ERROR_PROCESS_QUEUE_SUCESS:
  385.             DisplayPopup(NULL, IMG_PROCESSING_PHONEBOOK, 1, UI_POPUP_NOTIFYDURATION_TIME, 0);
  386.             break;
  387.             /* PMT DNLD_THEME_FIXES: SHARIQ START BUG# MAUI_00192708 */
  388.         case THEME_ERROR_LCD_SIZE_MISMATCH:
  389.             DisplayPopup(
  390.                 (PU8) GetString(STR_LCD_SIZE_MISMATCH),
  391.                 IMG_GLOBAL_ERROR,
  392.                 TRUE,
  393.                 UI_POPUP_NOTIFYDURATION_TIME,
  394.                 WARNING_TONE);
  395.             break;
  396.         //PMT DNLD_THEME_FIXES: SHARIQ END BUG# MAUI_00192708
  397.         //PMT DNLD FIXES 20060513: SUKRIT START MAUI_00221313
  398.         case THEME_ERROR_FILENAME_INCORRECT:
  399.             DisplayPopup(
  400.                 (PU8) GetString(STR_THEME_ERROR_FILENAME_INCORRECT),
  401.                 IMG_GLOBAL_WARNING,
  402.                 0,
  403.                 UI_POPUP_NOTIFYDURATION_TIME,
  404.                 WARNING_TONE);
  405.             break;
  406.             /* PMT DNLD FIXES 20060513: SUKRIT END MAUI_00221313 */
  407.         case THEME_ERROR_PHONE_MODEL_MISMATCH:
  408.             DisplayPopup(
  409.                 (PU8) GetString(STR_THEME_ERROR_PHONE_MODEL_MISMATCH),
  410.                 IMG_GLOBAL_WARNING,
  411.                 0,
  412.                 UI_POPUP_NOTIFYDURATION_TIME,
  413.                 WARNING_TONE);
  414.             break;
  415.         default:
  416.             DisplayPopup(
  417.                 (PU8) GetString(STR_THEME_UNKNOWN_ERROR),
  418.                 IMG_GLOBAL_ERROR,
  419.                 TRUE,
  420.                 UI_POPUP_NOTIFYDURATION_TIME,
  421.                 ERROR_TONE);
  422.             break;
  423.         #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  424.     }
  425.     g_thm_cntx.IsInThmApp = 0;
  426. #else /* __MMI_THEMES_V2_SUPPORT__ */ 
  427.     if (g_thm_cntx.CurrHiliteTheme != g_thm_cntx.CurrTheme)
  428.     {
  429.         SetBothLCDThemes(g_thm_cntx.CurrHiliteTheme);
  430.         g_thm_cntx.CurrTheme = g_thm_cntx.CurrHiliteTheme;
  431.         if (g_themes_freq_set[g_thm_cntx.CurrUpdatePeriod] != ALM_FREQ_OFF)
  432.         {
  433.             SetStartPositionofCurIndex();
  434.         }
  435.         WriteThemesToNVRAM();
  436.     }
  437.     DisplayPopup(
  438.         (PU8) GetString(STR_THEME_ACTIVATE_SUCCESS),
  439.         IMG_GLOBAL_ACTIVATED,
  440.         TRUE,
  441.         UI_POPUP_NOTIFYDURATION_TIME,
  442.         0);
  443.     DeleteUptoScrID(SCR_ID_THM_MENU);
  444.     g_thm_cntx.IsInThmApp = 0;
  445. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  446. }
  447. #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  448. /*****************************************************************************
  449.  * FUNCTION
  450.  *  ThemeDeleteConfirmation
  451.  * DESCRIPTION
  452.  *  Function for theme delete confirmation
  453.  * PARAMETERS
  454.  *  void
  455.  * RETURNS
  456.  *  void
  457.  *****************************************************************************/
  458. void ThemeDeleteConfirmation(void)
  459. {
  460.     /*----------------------------------------------------------------*/
  461.     /* Local Variables                                                */
  462.     /*----------------------------------------------------------------*/
  463.     /*----------------------------------------------------------------*/
  464.     /* Code Body                                                      */
  465.     /*----------------------------------------------------------------*/
  466.     S8 str[100];
  467.     pfnUnicodeStrcpy((PS8) str, (PS8) get_string(STR_GLOBAL_DELETE));
  468.     pfnUnicodeStrcat((PS8) str, (PS8) L" ");
  469.     pfnUnicodeStrcat((PS8) str, (PS8) g_thm_cntx.ThemeName[g_temp_thm_index]);
  470.     DisplayConfirm(
  471.         STR_GLOBAL_YES,
  472.         IMG_GLOBAL_YES,
  473.         STR_GLOBAL_NO,
  474.         IMG_GLOBAL_NO,
  475.         (UI_string_type) str,
  476.         IMG_GLOBAL_QUESTION,
  477.         WARNING_TONE);
  478.     SetLeftSoftkeyFunction(DeleteTheme, KEY_EVENT_UP);
  479.     SetKeyHandler(DeleteTheme, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  480.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  481.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  482.     SetKeyHandler(ThmHandleEndKey, KEY_END, KEY_EVENT_DOWN);
  483. }
  484. /*****************************************************************************
  485.  * FUNCTION
  486.  *  DeleteTheme
  487.  * DESCRIPTION
  488.  *  Function to delete a theme from theme application
  489.  * PARAMETERS
  490.  *  void
  491.  * RETURNS
  492.  *  void
  493.  *****************************************************************************/
  494. void DeleteTheme()
  495. {
  496.     /*----------------------------------------------------------------*/
  497.     /* Local Variables                                                */
  498.     /*----------------------------------------------------------------*/
  499.     tm_theme_error_enum result;
  500.     S32 error_type;
  501.     /*----------------------------------------------------------------*/
  502.     /* Code Body                                                      */
  503.     /*----------------------------------------------------------------*/
  504.     result = mmi_tm_delete_theme(g_thm_cntx.CurrHiliteTheme, &error_type);
  505.     switch (result)
  506.     {
  507.         case THEME_ERROR_THEME_NOT_AVAILABLE:
  508.             DisplayPopup(
  509.                 (PU8) GetString(STR_THEME_NOT_AVAILABLE),
  510.                 IMG_GLOBAL_ERROR,
  511.                 TRUE,
  512.                 UI_POPUP_NOTIFYDURATION_TIME,
  513.                 ERROR_TONE);
  514.             break;
  515.         case THEME_ERROR_SUCCESS:
  516.             UpdateOrder(g_thm_cntx.CurrHiliteTheme);
  517.             /* DisplayPopup((PU8) GetString(STR_THEME_DELETE_SUCCESS),IMG_GLOBAL_ACTIVATED, TRUE, UI_POPUP_NOTIFYDURATION_TIME,0); */
  518.             DisplayPopup(
  519.                 (PU8) GetString(STR_GLOBAL_DONE),
  520.                 IMG_GLOBAL_ACTIVATED,
  521.                 TRUE,
  522.                 UI_POPUP_NOTIFYDURATION_TIME,
  523.                 SUCCESS_TONE);
  524.             break;
  525.         case THEME_ERROR_FAILURE:
  526.             DisplayPopup(
  527.                 (PU8) GetString(GetFileSystemErrorString(error_type)),
  528.                 IMG_GLOBAL_ERROR,
  529.                 TRUE,
  530.                 UI_POPUP_NOTIFYDURATION_TIME,
  531.                 ERROR_TONE);
  532.             break;
  533.     }
  534.     DeleteUptoScrID(SCR_ID_THM_MENU);
  535. }
  536. /*****************************************************************************
  537.  * FUNCTION
  538.  *  UpdateOrder
  539.  * DESCRIPTION
  540.  *  Function to update set order during deletion
  541.  * PARAMETERS
  542.  *  thm_del_ID      [IN]        
  543.  * RETURNS
  544.  *  void
  545.  *****************************************************************************/
  546. void UpdateOrder(U32 thm_del_ID)
  547. {
  548.     /*----------------------------------------------------------------*/
  549.     /* Local Variables                                                */
  550.     /*----------------------------------------------------------------*/
  551.     U16 i = 0;
  552.     U8 count = 0;
  553.     U16 tmpidlist[TOTAL_THEMES_COUNT];
  554.     /*----------------------------------------------------------------*/
  555.     /* Code Body                                                      */
  556.     /*----------------------------------------------------------------*/
  557.     g_thm_cntx.TotalTheme = mmi_tm_get_total_themes_count();
  558.     if (g_thm_cntx.CurrTheme == thm_del_ID)
  559.     {
  560.         g_thm_cntx.CurrTheme = DefaultThmID;
  561.         g_thm_cntx.CurrThemeIndex = DefaultThmIndex;
  562.     }
  563.     for (i = 0; i <= g_thm_cntx.CurrOrderIndex; i++)
  564.     {
  565.         if (thm_del_ID == g_thm_cntx.SetOrderIDList[i])
  566.         {
  567.             count++;
  568.         }
  569.     }
  570.     if (g_thm_cntx.CurrOrderIndex >= count)
  571.     {
  572.         g_thm_cntx.CurrOrderIndex = g_thm_cntx.CurrOrderIndex - count;
  573.     }
  574.     count = 0;
  575.     for (i = 0; i < g_thm_cntx.TotalTheme + 1; i++)
  576.     {
  577.         if (thm_del_ID != g_thm_cntx.SetOrderIDList[i])
  578.         {
  579.             tmpidlist[count] = g_thm_cntx.SetOrderIDList[i];
  580.             count++;
  581.         }
  582.     }
  583.     for (i = 0; i <= count; i++)
  584.     {
  585.         g_thm_cntx.SetOrderIDList[i] = tmpidlist[i];
  586.     }
  587.     for (i = count; i < g_thm_cntx.TotalTheme; i++)
  588.     {
  589.         g_thm_cntx.SetOrderIDList[i] = 0;
  590.     }
  591.     SetOrderIDList(g_thm_cntx.SetOrderIDList, count, g_thm_cntx.CurrOrderIndex);
  592.     WriteThemesToNVRAM();
  593. }
  594. #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  595. /*****************************************************************************
  596.  * FUNCTION
  597.  *  UpdateThemeOff
  598.  * DESCRIPTION
  599.  *  Cancel the update alarm set by user and write to NVRAM
  600.  * PARAMETERS
  601.  *  void
  602.  * RETURNS
  603.  *  void
  604.  *****************************************************************************/
  605. void UpdateThemeOff(void)
  606. {
  607.     /*----------------------------------------------------------------*/
  608.     /* Local Variables                                                */
  609.     /*----------------------------------------------------------------*/
  610.     /*----------------------------------------------------------------*/
  611.     /* Code Body                                                      */
  612.     /*----------------------------------------------------------------*/
  613.     g_thm_cntx.CurrOrderIndex = -1;
  614.     g_thm_cntx.IsOrderChanged = 0;
  615.     /* if previous setting is not off, some theme-alarm is set before, cancel the alarm */
  616.     if (g_themes_freq_set[g_thm_cntx.CurrUpdatePeriod] != ALM_FREQ_OFF)
  617.     {
  618.         AlmCancelAlarm(ALM_THM_START);
  619.     }
  620.     g_thm_cntx.CurrUpdatePeriod = mmi_alm_get_freq_order(THMEM_FREQ_NUM, g_themes_freq_set, ALM_FREQ_OFF);
  621.     WriteThemesToNVRAM();
  622.     DisplayPopup(
  623.         (PU8) GetString(STR_THEME_OFF_UPADTE_SUCCESS),
  624.         IMG_GLOBAL_ACTIVATED,
  625.         TRUE,
  626.         UI_POPUP_NOTIFYDURATION_TIME,
  627.         0);
  628.     DeleteUptoScrID(SCR_ID_THM_OPTIONS);
  629.     g_thm_cntx.IsInThmApp = 0;
  630. }
  631. /* PMT DNLD_THEME_FIXES: SHARIQ START BUG# MAUI_00191466 */
  632. /*****************************************************************************
  633.  * FUNCTION
  634.  *  AlarmExpireUpdateThemeOff
  635.  * DESCRIPTION
  636.  *  Sets the update theme alarm to off when no theme is present in set order list
  637.  * PARAMETERS
  638.  *  void
  639.  * RETURNS
  640.  *  void
  641.  *****************************************************************************/
  642. void AlarmExpireUpdateThemeOff(void)
  643. {
  644.     /*----------------------------------------------------------------*/
  645.     /* Local Variables                                                */
  646.     /*----------------------------------------------------------------*/
  647.     /*----------------------------------------------------------------*/
  648.     /* Code Body                                                      */
  649.     /*----------------------------------------------------------------*/
  650.     g_thm_cntx.CurrOrderIndex = -1;
  651.     g_thm_cntx.IsOrderChanged = 0;
  652.     /* if previous setting is not off, some theme-alarm is set before, cancel the alarm */
  653.     if (g_thm_cntx.CurrUpdatePeriod > 0)
  654.     {
  655.         AlmCancelAlarm(ALM_THM_START);
  656.     }
  657.     g_thm_cntx.CurrUpdatePeriod = ALM_FREQ_OFF;
  658.     WriteThemesToNVRAM();
  659.     g_thm_cntx.IsInThmApp = 0;
  660. }
  661. /* PMT DNLD_THEME_FIXES: SHARIQ END BUG# MAUI_00191466 */
  662. /*****************************************************************************
  663.  * FUNCTION
  664.  *  UpdateThemePeriod
  665.  * DESCRIPTION
  666.  *  Set update period and write to NVRAM
  667.  * PARAMETERS
  668.  *  void
  669.  * RETURNS
  670.  *  void
  671.  *****************************************************************************/
  672. void UpdateThemePeriod(void)
  673. {
  674.     /*----------------------------------------------------------------*/
  675.     /* Local Variables                                                */
  676.     /*----------------------------------------------------------------*/
  677.     /*----------------------------------------------------------------*/
  678.     /* Code Body                                                      */
  679.     /*----------------------------------------------------------------*/
  680.     /* Leo add for DLT */
  681. #ifdef __MMI_THEMES_V2_SUPPORT__
  682.     if (g_thm_cntx.IsSetFromMenu == 1 && g_thm_cntx.CurrHiliteItem != g_thm_cntx.CurrUpdatePeriod)
  683.     {
  684.         g_thm_cntx.CurrUpdatePeriod = g_thm_cntx.CurrHiliteItem;
  685.         g_thm_cntx.IsOrderChanged = 1;
  686.     }
  687. #else /* __MMI_THEMES_V2_SUPPORT__ */ 
  688.     if (g_thm_cntx.IsSetFromMenu == 1)
  689.     {
  690.         g_thm_cntx.CurrUpdatePeriod = g_thm_cntx.CurrHiliteItem;
  691.         g_thm_cntx.IsOrderChanged = 1;
  692.     }
  693. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  694.     SetStartPositionofCurIndex();
  695.     WriteThemesToNVRAM();
  696.     AlmSetAlarm(ALM_THM_START);
  697.     if (g_thm_cntx.IsSetFromMenu == 1)  /* not OFF */
  698.     {
  699.         DisplayPopup(
  700.             (PU8) GetString(STR_THEME_OFF_UPADTE_SUCCESS),
  701.             IMG_GLOBAL_ACTIVATED,
  702.             TRUE,
  703.             UI_POPUP_NOTIFYDURATION_TIME,
  704.             SUCCESS_TONE);
  705.         DeleteUptoScrID(SCR_ID_THM_OPTIONS);
  706.         g_thm_cntx.IsInThmApp = 0;
  707.     }
  708. }
  709. /* PMT NEERAJ START 20050804 */
  710. #ifdef __MMI_UI_TAB_PANE__
  711. S32 theme_alarm_update_ui_theme = 0;
  712. /*****************************************************************************
  713.  * FUNCTION
  714.  *  SetThemeAlarmCallBackUpdateUITheme
  715.  * DESCRIPTION
  716.  *  Sets Theme Ui Update to TRUE. This is required so that UI theme is updated
  717.  *  on screen exit
  718.  * PARAMETERS
  719.  *  void
  720.  * RETURNS
  721.  *  void
  722.  *****************************************************************************/
  723. void SetThemeAlarmCallBackUpdateUITheme(void)
  724. {
  725.     /*----------------------------------------------------------------*/
  726.     /* Local Variables                                                */
  727.     /*----------------------------------------------------------------*/
  728.     /*----------------------------------------------------------------*/
  729.     /* Code Body                                                      */
  730.     /*----------------------------------------------------------------*/
  731.     theme_alarm_update_ui_theme = 1;
  732. }
  733. /*****************************************************************************
  734.  * FUNCTION
  735.  *  ThemeAlarmCallBackUpdateUITheme
  736.  * DESCRIPTION
  737.  *  The function updates the UI Theme on common screen exit
  738.  * PARAMETERS
  739.  *  void
  740.  * RETURNS
  741.  *  void
  742.  *****************************************************************************/
  743. void ThemeAlarmCallBackUpdateUITheme(void)
  744. {
  745.     /*----------------------------------------------------------------*/
  746.     /* Local Variables                                                */
  747.     /*----------------------------------------------------------------*/
  748.     /*----------------------------------------------------------------*/
  749.     /* Code Body                                                      */
  750.     /*----------------------------------------------------------------*/
  751.     if (theme_alarm_update_ui_theme)
  752.     {
  753.         theme_alarm_update_ui_theme = 0;
  754.         check_and_set_title_theme_changed();
  755.     }
  756. }
  757. #endif /* __MMI_UI_TAB_PANE__ */ 
  758. /* PMT NEERAJ END 20050804 */
  759. /*****************************************************************************
  760.  * FUNCTION
  761.  *  ThemeAlarmCallBack
  762.  * DESCRIPTION
  763.  *  Call back function when theme alarm expires
  764.  * PARAMETERS
  765.  *  index           [IN]        
  766.  *  period          [?]         
  767.  *  power_on        [IN]        
  768.  * RETURNS
  769.  *  void
  770.  *****************************************************************************/
  771. U8 ThemeAlarmCallBack(U8 index, U16 *period, BOOL power_on)
  772. {
  773. #ifdef __J2ME__
  774. U8 IsJavaPlaying = FALSE;
  775. #endif
  776.     /*----------------------------------------------------------------*/
  777.     /* Local Variables                                                */
  778.     /*----------------------------------------------------------------*/
  779. #ifdef __MMI_THEMES_V2_SUPPORT__
  780.     U8 no_of_times, result=THEME_ERROR_FAILURE;
  781.     U16 order_theme_id, count, Index;
  782.     U32 *p;
  783.     /*----------------------------------------------------------------*/
  784.     /* Code Body                                                      */
  785.     /*----------------------------------------------------------------*/
  786.     /* PMT DNLD_THEME_FIXES: SHARIQ END BUG# MAUI_00221092 */
  787.     if (mmi_tm_get_usb_mode() == MMI_TRUE)
  788.     {
  789.         mmi_tm_set_was_theme_alarm_cb();
  790.         *period = ALM_WITHOUD_EXPIRY_PERIOD;
  791.         return ALM_HAS_NO_IND;
  792.     }
  793.     count = GetIDList(&p, &g_thm_cntx.CurrOrderIndex);
  794.     g_thm_cntx.CurrTheme = mmi_tm_get_current_theme_id();
  795.     g_thm_cntx.TotalTheme = mmi_tm_get_total_themes_count();
  796.     for (no_of_times = 0; no_of_times < g_thm_cntx.TotalTheme; no_of_times++)
  797.     {
  798.         g_thm_cntx.SetOrderIDList[no_of_times] = p[no_of_times];
  799.     }
  800.     Index = g_thm_cntx.CurrOrderIndex;
  801.     /* PMT DNLD_THEME_FIXES: SHARIQ START BUG# MAUI_00191466 */
  802.     if (count == 0)
  803.     {
  804.         AlarmExpireUpdateThemeOff();
  805.     }
  806.     /* PMT DNLD_THEME_FIXES: SHARIQ END BUG# MAUI_00191466 */
  807.     else
  808.         /* Fix for dodge ball game */
  809.     {
  810. //PMT DNLD FIXES 20060513: SUKRIT START MAUI_00192671
  811. #ifdef __J2ME__
  812.         if (GetActiveScreenId() == SCR_JAVA_APP)
  813. {
  814. EntryNewScreen(GLOBAL_SCR_DUMMY, NULL, NULL, NULL);
  815.             ShowCategory66Screen(
  816.                 STR_SCR3001_THEMES_CAPTION,
  817.                 0,
  818.                 0,
  819.                 0,
  820.                 0,
  821.                 0,
  822.                 (PU8) GetString(STR_ID_DLT_THM_PROGRESS),
  823.                 IMG_THEME_ACTIVATION,
  824.                 NULL);
  825. IsJavaPlaying = TRUE;
  826. }
  827.     #endif /* __J2ME__ */ 
  828. //PMT DNLD FIXES 20060513: SUKRIT END MAUI_00192671
  829.         for (no_of_times = 0; no_of_times < g_thm_cntx.TotalTheme; no_of_times++)
  830.         {
  831.             if ((g_thm_cntx.CurrOrderIndex == (g_thm_cntx.TotalTheme) - 1) ||
  832.                 g_thm_cntx.CurrOrderIndex >= g_thm_cntx.TotalTheme)
  833.             {
  834.                 g_thm_cntx.CurrOrderIndex = 0;
  835.             }
  836.             else
  837.             {
  838.                 g_thm_cntx.CurrOrderIndex++;
  839.             }
  840.             if (g_thm_cntx.CurrOrderIndex == Index)
  841.             {
  842.                 break;
  843.             }
  844.             order_theme_id = g_thm_cntx.SetOrderIDList[g_thm_cntx.CurrOrderIndex];
  845.             if (order_theme_id != g_thm_cntx.CurrTheme)
  846.             {
  847.             if (!g_alm_frm_cntx.IsPwronAlarm)
  848.             {
  849.                 if (g_thm_cntx.IsInThmApp == 0) /* is not in theme menu */
  850.                 {
  851.                     /* To exit previous screen, error case: multimedia screen will allocate lots of memory, and then the cache wallpaper will fail */
  852.                         /* 2006/12/31 */
  853.                         EntryNewScreen(GLOBAL_SCR_DUMMY, NULL, NULL, NULL);
  854.                     result = mmi_tm_activate_theme(order_theme_id);     /* PMT TM Coding Conventions - MOHD SHARIQ 20060406 */
  855.                     if (result == THEME_ERROR_SUCCESS)
  856.                     {
  857.                         g_thm_cntx.CurrTheme = order_theme_id;
  858.                             SetThemes(g_thm_cntx.CurrTheme);
  859.                         DisplayPopup(
  860.                             (PU8) GetString(STR_THEMES_ALARM_ACTIVATION),
  861.                             IMG_GLOBAL_ACTIVATED,
  862.                             TRUE,
  863.                             UI_POPUP_NOTIFYDURATION_TIME,
  864.                             SUCCESS_TONE);
  865. /* MAUI_00019098_Patch_01 Start */
  866. if( GetCurrScrnId() == SCR_WALLPAPER_VIEW )
  867. {
  868. DeleteUptoScrID(SCR_IDLE_SCR_DISP);
  869. }
  870. /* MAUI_00019098_Patch_01 End */
  871.                         SetCurrOrderIndex(g_thm_cntx.CurrOrderIndex);
  872.                         break;
  873.                     }
  874.                         else
  875.                         {
  876.                                 /* Go back to previous screen if the theme updation is failed */
  877.                                /* 2006/12/31 */
  878.                                 GoBackHistory();                                
  879.                            }
  880.                 }
  881.             }
  882.             else
  883.     {
  884.      result=mmi_tm_activate_theme(order_theme_id);
  885.                     //PMT SUKRIT START PMTSW00006364
  886.                 if (result == THEME_ERROR_SUCCESS)
  887.                 {
  888.                    g_thm_cntx.CurrTheme = order_theme_id;
  889.                     //PMT SUKRIT END PMTSW00006364
  890.                        SetThemes(g_thm_cntx.CurrTheme);
  891.                    SetCurrOrderIndex(g_thm_cntx.CurrOrderIndex);
  892.                    break;
  893.                     //PMT SUKRIT START PMTSW00006364
  894.                 }
  895.                     //PMT SUKRIT END PMTSW00006364
  896.     }
  897. }
  898. }
  899. //PMT DNLD FIXES 20060513: SUKRIT START MAUI_00192671
  900. #ifdef __J2ME__
  901. if(IsJavaPlaying == TRUE)
  902. {
  903. if(result != THEME_ERROR_SUCCESS)
  904. {
  905. DisplayPopup(
  906.                     (PU8) GetString(STR_THEME_UNKNOWN_ERROR),
  907.                     IMG_GLOBAL_ERROR,
  908.                     TRUE,
  909.                     UI_POPUP_NOTIFYDURATION_TIME,
  910.                     ERROR_TONE);
  911. }
  912. DeleteUptoScrID(SCR_JAVA_APP);
  913. }
  914. #endif
  915. //PMT DNLD FIXES 20060513: SUKRIT START MAUI_00192671
  916. }
  917.     /* Leo add for DLT */
  918.     WriteThemesToNVRAM();
  919.     /* Leo end */
  920. #else /* __MMI_THEMES_V2_SUPPORT__ */ 
  921.     U8 no_of_times;
  922.     U8 order_theme;
  923.     /* find the next index of theme to be updated */
  924.     for (no_of_times = 0; no_of_times < NO_OF_ORDERS; no_of_times++)
  925.     {
  926.         /* move order to next one */
  927.         if (g_thm_cntx.CurrOrderIndex == (NO_OF_ORDERS) - 1)
  928.         {
  929.             g_thm_cntx.CurrOrderIndex = 0;
  930.         }
  931.         else
  932.         {
  933.             g_thm_cntx.CurrOrderIndex++;
  934.         }
  935.         order_theme = g_thm_cntx.CurrOrderList[g_thm_cntx.CurrOrderIndex];
  936.         /* if found theme different to current one, found the first one */
  937.         if (order_theme != g_thm_cntx.CurrTheme && order_theme < g_thm_cntx.TotalTheme)
  938.         {
  939.             break;
  940.         }
  941.     }
  942. #ifdef __J2ME__
  943.     if (GetActiveScreenId() == SCR_JAVA_APP)
  944.     {
  945.         IsJavaPlaying = TRUE;
  946.         jvm_pause_dummy_screen();
  947.     }
  948. #endif /* __J2ME__ */ 
  949.     if (no_of_times < NO_OF_ORDERS)
  950.     {
  951.         g_thm_cntx.CurrTheme = order_theme;
  952.         WriteThemesToNVRAM();
  953.         if (!g_alm_frm_cntx.IsPwronAlarm)
  954.         {
  955.             if (g_thm_cntx.IsInThmApp == 0) /* is not in theme menu */
  956.             {
  957.                 SetThemes(g_thm_cntx.CurrTheme);
  958.                 /* PMT NEERAJ START 20050804 */
  959.             #ifdef __MMI_UI_TAB_PANE__
  960.                 SetThemeAlarmCallBackUpdateUITheme();
  961.             #endif 
  962.                 //PMT NEERAJ END 20050804
  963.                 //MTK Leo add, fix theme update issue
  964.                 //                              EntryNewScreen(GLOBAL_SCR_DUMMY, NULL, NULL, NULL);
  965.                 //                              GoBackHistory();
  966.             }
  967.             else if (g_thm_cntx.IsInThmApp == 1)
  968.             {
  969.                 /* SetExitHandler(SCR_ID_THM_MENU, NULL); */
  970.                 ClearExitHandler();
  971.                 EntryThmMenu();
  972.             }
  973.             order_theme++;
  974.         }
  975.         else
  976.         {
  977.             SetThemes(g_thm_cntx.CurrTheme);
  978.         }
  979.     }
  980. #ifdef __J2ME__
  981.     if (IsJavaPlaying == TRUE)
  982.     {
  983.         jvm_resume_dummy_screen();
  984.     }
  985. #endif /* __J2ME__ */ 
  986. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  987.     /* Leo add for DLT */
  988.     /* WriteThemesToNVRAM(); */
  989.     /* Leo end */
  990.     *period = ALM_WITHOUD_EXPIRY_PERIOD;
  991.     return ALM_HAS_NO_IND;
  992. }
  993. /*****************************************************************************
  994.  * FUNCTION
  995.  *  ReadThemesFromNVRAM
  996.  * DESCRIPTION
  997.  *  Read theme settings from NVRAM
  998.  * PARAMETERS
  999.  *  void
  1000.  * RETURNS
  1001.  *  void
  1002.  *****************************************************************************/
  1003. void ReadThemesFromNVRAM(void)
  1004. {
  1005.     /*----------------------------------------------------------------*/
  1006.     /* Local Variables                                                */
  1007.     /*----------------------------------------------------------------*/
  1008.     /* Leo add for DLT */
  1009. #ifndef __MMI_THEMES_V2_SUPPORT__
  1010.     S16 error = 0;
  1011.     U8 index = 0;
  1012.     U8 *temp_name;
  1013.     thm_nvram_struct nvram_theme;
  1014.     /*----------------------------------------------------------------*/
  1015.     /* Code Body                                                      */
  1016.     /*----------------------------------------------------------------*/
  1017.     /* initialize global contex */
  1018.     memset(&g_thm_cntx, 0, sizeof(g_thm_cntx));
  1019.     g_thm_cntx.TotalTheme = (U8) GetThemesNames((U8 ***) & temp_name);
  1020.     ReadRecord(NVRAM_EF_THEMES_VALUES, 1, &nvram_theme, 8, &error);
  1021.     /* to present abonromal case of NVRAM default value */
  1022.     if (nvram_theme.freq_type > ALM_FREQ_SEASONALLY)
  1023.     {
  1024.         g_thm_cntx.CurrUpdatePeriod = ALM_FREQ_OFF;
  1025.     }
  1026.     else
  1027.     {
  1028.         g_thm_cntx.CurrUpdatePeriod = (U8) (nvram_theme.freq_type);
  1029.     }
  1030.     g_thm_cntx.CurrTheme = nvram_theme.current_theme_index;
  1031.     /* set order list */
  1032.     if (nvram_theme.set_order_flag >= -1)    /* order has be set before */
  1033.     {
  1034.         g_thm_cntx.IsOrderChanged = 1;
  1035.         g_thm_cntx.CurrOrderIndex = nvram_theme.set_order_flag;
  1036.         for (index = 0; index < NO_OF_ORDERS; index++)
  1037.         {
  1038.             g_thm_cntx.CurrOrderList[index] = nvram_theme.themes_order[index];
  1039.         }
  1040.     }
  1041.     else
  1042.     {
  1043.         g_thm_cntx.IsOrderChanged = 0;
  1044.         g_thm_cntx.CurrOrderIndex = 0;
  1045.         for (index = 0; index < NO_OF_ORDERS; index++)
  1046.         {
  1047.             g_thm_cntx.CurrOrderList[index] = index;
  1048.         }
  1049.     }
  1050.     /* set and apply current theme */
  1051.     if (g_thm_cntx.CurrTheme >= g_thm_cntx.TotalTheme)
  1052.     {
  1053.         g_thm_cntx.CurrOrderIndex = 0;
  1054.         g_thm_cntx.CurrTheme = 0;
  1055.     }
  1056.     SetThemes(g_thm_cntx.CurrTheme);
  1057. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  1058.     /* Leo end */
  1059. }
  1060. /*****************************************************************************
  1061.  * FUNCTION
  1062.  *  ConstructThemeOrderList
  1063.  * DESCRIPTION
  1064.  *  function to construct themes order list
  1065.  * PARAMETERS
  1066.  *  void
  1067.  * RETURNS
  1068.  *  void
  1069.  *****************************************************************************/
  1070. #ifdef __MMI_THEMES_V2_SUPPORT__
  1071. void ConstructThemeOrderList(void)
  1072. {
  1073.     /*----------------------------------------------------------------*/
  1074.     /* Local Variables                                                */
  1075.     /*----------------------------------------------------------------*/
  1076.     S16 error = 0;
  1077.     U8 index = 0;
  1078.     thm_nvram_struct nvram_theme;
  1079.     /*----------------------------------------------------------------*/
  1080.     /* Code Body                                                      */
  1081.     /*----------------------------------------------------------------*/
  1082.     /* initialize global contex */
  1083.     g_thm_cntx.TotalTheme = mmi_tm_get_total_themes_count();
  1084. #if (defined(__MMI_THEMES_V2_SUPPORT__) || defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__))        /* ritesh */
  1085.     ReadRecord(NVRAM_EF_THEMES_VALUES, 1, &nvram_theme, 96, &error);
  1086. #endif 
  1087.     g_thm_cntx.CurrUpdatePeriod = (U8) (nvram_theme.freq_type);
  1088.     /* set order list */
  1089.     if (nvram_theme.set_order_flag >= -1)    /* order has be set before */
  1090.     {
  1091.         g_thm_cntx.IsOrderChanged = 1;
  1092.         g_thm_cntx.CurrOrderIndex = nvram_theme.set_order_flag;
  1093.         currorderindex = (U8) nvram_theme.set_order_flag;
  1094.         for (index = 0; index < TOTAL_THEMES_COUNT; index++)    /* ritesh */
  1095.         {
  1096.             /* g_thm_cntx.CurrOrderList[index] = nvram_theme.themes_order[index]; */
  1097.             setorderIDList[index] = nvram_theme.themes_order[index];
  1098.         }
  1099.     }
  1100.     else
  1101.     {
  1102.         g_thm_cntx.IsOrderChanged = 0;
  1103.     }
  1104.     /* set and apply current theme */
  1105. }
  1106. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  1107. /*****************************************************************************
  1108.  * FUNCTION
  1109.  *  WriteThemesToNVRAM
  1110.  * DESCRIPTION
  1111.  *  write theme settings to NVRAM
  1112.  * PARAMETERS
  1113.  *  void
  1114.  * RETURNS
  1115.  *  void
  1116.  *****************************************************************************/
  1117. void WriteThemesToNVRAM()
  1118. {
  1119.     /*----------------------------------------------------------------*/
  1120.     /* Local Variables                                                */
  1121.     /*----------------------------------------------------------------*/
  1122.     S32 index = 0;
  1123.     S16 error = 0;
  1124.     thm_nvram_struct nvram_theme;
  1125.     /*----------------------------------------------------------------*/
  1126.     /* Code Body                                                      */
  1127.     /*----------------------------------------------------------------*/
  1128. #ifdef __MMI_THEMES_V2_SUPPORT__
  1129.     nvram_theme.freq_type = g_thm_cntx.CurrUpdatePeriod;
  1130. #else 
  1131.     nvram_theme.freq_type = g_thm_cntx.CurrUpdatePeriod;
  1132. #endif 
  1133.     if (g_thm_cntx.IsOrderChanged == 1)
  1134. #ifdef __MMI_THEMES_V2_SUPPORT__
  1135.         nvram_theme.set_order_flag = currorderindex;    /* changes made on saturday 09/04/05 */
  1136. #else 
  1137.         nvram_theme.set_order_flag = g_thm_cntx.CurrOrderIndex;
  1138. #endif 
  1139.     if (g_thm_cntx.IsOrderChanged == 0)
  1140.     {
  1141.         nvram_theme.set_order_flag = -1;
  1142.     }
  1143. #ifndef __MMI_THEMES_V2_SUPPORT__
  1144.     if (g_thm_cntx.CurrTheme < g_thm_cntx.TotalTheme)
  1145.     {
  1146.         nvram_theme.current_theme_index = (U8) g_thm_cntx.CurrTheme;
  1147.     }
  1148.     else
  1149.     {
  1150.         g_thm_cntx.CurrTheme = nvram_theme.current_theme_index = 0;
  1151.     }
  1152. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  1153. #ifdef __MMI_THEMES_V2_SUPPORT__
  1154.     for (index = 0; index < TOTAL_THEMES_COUNT; index++)    /* ritesh */
  1155.     {
  1156.         nvram_theme.themes_order[index] = setorderIDList[index];
  1157.     }
  1158. #else /* __MMI_THEMES_V2_SUPPORT__ */ 
  1159.     for (index = 0; index < NO_OF_ORDERS; index++)
  1160.     {
  1161.         nvram_theme.themes_order[index] = g_thm_cntx.CurrOrderList[index];
  1162.     }
  1163. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  1164. #if (defined(__MMI_THEMES_V2_SUPPORT__) || defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__))        /* ritesh */
  1165.     WriteRecord(NVRAM_EF_THEMES_VALUES, 1, &nvram_theme, 96, &error);
  1166. #else 
  1167.     WriteRecord(NVRAM_EF_THEMES_VALUES, 1, &nvram_theme, 8, &error);
  1168. #endif 
  1169. }
  1170. /*****************************************************************************
  1171.  * FUNCTION
  1172.  *  UpdateThemeAlarm
  1173.  * DESCRIPTION
  1174.  *  Call by settings application when time/date change
  1175.  *  and set the alam of update theme according to current time/date
  1176.  * PARAMETERS
  1177.  *  void
  1178.  * RETURNS
  1179.  *  void
  1180.  *****************************************************************************/
  1181. void UpdateThemeAlarm(void)
  1182. {
  1183.     /*----------------------------------------------------------------*/
  1184.     /* Local Variables                                                */
  1185.     /*----------------------------------------------------------------*/
  1186.     /*----------------------------------------------------------------*/
  1187.     /* Code Body                                                      */
  1188.     /*----------------------------------------------------------------*/
  1189.     g_thm_cntx.IsSetFromMenu = 0;
  1190.     if (g_themes_freq_set[g_thm_cntx.CurrUpdatePeriod] != ALM_FREQ_OFF) /* not OFF */
  1191.     {
  1192.         UpdateThemePeriod();
  1193.     }
  1194. }
  1195. /*****************************************************************************
  1196.  * FUNCTION
  1197.  *  SetStartPositionofCurIndex
  1198.  * DESCRIPTION
  1199.  *  set the starting position of update order index
  1200.  * PARAMETERS
  1201.  *  void
  1202.  * RETURNS
  1203.  *  void
  1204.  *****************************************************************************/
  1205. void SetStartPositionofCurIndex(void)
  1206. {
  1207.     /*----------------------------------------------------------------*/
  1208.     /* Local Variables                                                */
  1209.     /*----------------------------------------------------------------*/
  1210.     U8 index = 0, flag = 0;
  1211.     U8 curr_order;
  1212.     /*----------------------------------------------------------------*/
  1213.     /* Code Body                                                      */
  1214.     /*----------------------------------------------------------------*/
  1215. #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  1216.     if (g_thm_cntx.CurrOrderIndex < 0 || g_thm_cntx.CurrOrderIndex >= TOTAL_THEMES_COUNT)
  1217. #else 
  1218.     if (g_thm_cntx.CurrOrderIndex < 0)
  1219. #endif 
  1220.         curr_order = 0;
  1221.     else
  1222.     {
  1223.         curr_order = (U8) g_thm_cntx.CurrOrderIndex;
  1224.     }
  1225.     /* find the position of current selected theme */
  1226. #ifdef __MMI_THEMES_V2_SUPPORT__
  1227.     for (index = 0; index < g_thm_cntx.TotalTheme; index++) /* ritesh */
  1228.     {
  1229.         if (g_thm_cntx.SetOrderIDList[curr_order] == g_thm_cntx.CurrTheme)
  1230.         {
  1231.             flag = 1;
  1232.             break;
  1233.         }
  1234.         if (curr_order == (g_thm_cntx.TotalTheme) - 1)
  1235.         {
  1236.             curr_order = 0;
  1237.         }
  1238.         else
  1239.         {
  1240.             curr_order++;
  1241.         }
  1242.     }
  1243. #else /* __MMI_THEMES_V2_SUPPORT__ */ 
  1244.     for (index = 0; index < NO_OF_ORDERS; index++)
  1245.     {
  1246.         if (g_thm_cntx.CurrOrderList[curr_order] == g_thm_cntx.CurrTheme)
  1247.         {
  1248.             flag = 1;
  1249.             break;
  1250.         }
  1251.         if (curr_order == (NO_OF_ORDERS) - 1)
  1252.         {
  1253.             curr_order = 0;
  1254.         }
  1255.         else
  1256.         {
  1257.             curr_order++;
  1258.         }
  1259.     }
  1260. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  1261.     if (flag == 1)  /* it's in the list */
  1262.     {
  1263.         g_thm_cntx.CurrOrderIndex = curr_order;
  1264.         g_thm_cntx.IsOrderChanged = 1;
  1265.     }
  1266.     else
  1267.     {
  1268.         g_thm_cntx.CurrOrderIndex = -1;
  1269.     }
  1270. }
  1271. /*****************************************************************************
  1272.  * FUNCTION
  1273.  *  ATSetTheme
  1274.  * DESCRIPTION
  1275.  *  To change theme setting from AT command
  1276.  * PARAMETERS
  1277.  *  index       [IN]        Index of theme to be set
  1278.  * RETURNS
  1279.  *  void
  1280.  *****************************************************************************/
  1281. BOOL ATSetTheme(U8 index)
  1282. {
  1283.     /*----------------------------------------------------------------*/
  1284.     /* Local Variables                                                */
  1285.     /*----------------------------------------------------------------*/
  1286.     /* added by ritesh for V2 support */
  1287. #ifdef __MMI_THEMES_V2_SUPPORT__
  1288.     U16 result;
  1289.     /*----------------------------------------------------------------*/
  1290.     /* Code Body                                                      */
  1291.     /*----------------------------------------------------------------*/
  1292.     if (g_thm_cntx.IsInThmApp == 0)
  1293.     {
  1294.         mmi_tm_get_themes(&thm_details);
  1295.         result = mmi_tm_activate_theme(thm_details[index].theme_id);    /* PMT TM Coding Conventions - MOHD SHARIQ 20060406 */
  1296.         SetThemes(g_thm_cntx.CurrTheme);
  1297.         switch (result)
  1298.         {
  1299.             case THEME_ERROR_SUCCESS:
  1300.                 g_thm_cntx.CurrTheme = thm_details[index].theme_id;
  1301.                 if (g_themes_freq_set[g_thm_cntx.CurrUpdatePeriod] != ALM_FREQ_OFF)
  1302.                 {
  1303.                     SetStartPositionofCurIndex();
  1304.                 }
  1305.                 SetCurrOrderIndex(g_thm_cntx.CurrOrderIndex);
  1306.                 DisplayPopup(
  1307.                     (PU8) GetString(STR_THEME_ACTIVATE_SUCCESS),
  1308.                     IMG_GLOBAL_ACTIVATED,
  1309.                     TRUE,
  1310.                     UI_POPUP_NOTIFYDURATION_TIME,
  1311.                     SUCCESS_TONE);
  1312.                 DeleteUptoScrID(SCR_ID_THM_MENU);
  1313.                 return MMI_TRUE;
  1314.                 /* break; */
  1315.             case THEME_ERROR_ALREADY_ACTIVATED:
  1316.                 DisplayPopup(
  1317.                     (PU8) GetString(STR_ID_FMGR_ALREADY_ACTIVE),
  1318.                     IMG_GLOBAL_INFO,
  1319.                     TRUE,
  1320.                     UI_POPUP_NOTIFYDURATION_TIME,
  1321.                     ERROR_TONE);
  1322.                 return MMI_FALSE;
  1323.                 /* break; */
  1324.             #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  1325.             case THEME_ERROR_THEME_NOT_AVAILABLE:
  1326.                 DisplayPopup(
  1327.                     (PU8) GetString(STR_THEME_NOT_AVAILABLE),
  1328.                     IMG_GLOBAL_ERROR,
  1329.                     TRUE,
  1330.                     UI_POPUP_NOTIFYDURATION_TIME,
  1331.                     WARNING_TONE);
  1332.                 return MMI_FALSE;
  1333.                 /* break; */
  1334.             case THEME_ERROR_FILE_FORMAT_BAD:
  1335.                 DisplayPopup(
  1336.                     (PU8) GetString(STR_THEME_FORMAT_NOT_SUPPORTED),
  1337.                     IMG_GLOBAL_ERROR,
  1338.                     TRUE,
  1339.                     UI_POPUP_NOTIFYDURATION_TIME,
  1340.                     WARNING_TONE);
  1341.                 return MMI_FALSE;
  1342.                 /* break; */
  1343.             case THEME_ERROR_FAILURE:
  1344.                 DisplayPopup(
  1345.                     (PU8) GetString(STR_THEME_UNKNOWN_ERROR),
  1346.                     IMG_GLOBAL_ERROR,
  1347.                     TRUE,
  1348.                     UI_POPUP_NOTIFYDURATION_TIME,
  1349.                     ERROR_TONE);
  1350.                 return MMI_FALSE;
  1351.                 /* break; */
  1352.             case THEME_ERROR_VERSION_FAILURE:
  1353.                 DisplayPopup(
  1354.                     (PU8) GetString(STR_DOWNLOAD_THEME_UNSUPPORTED),
  1355.                     IMG_GLOBAL_WARNING,
  1356.                     0,
  1357.                     UI_POPUP_NOTIFYDURATION_TIME,
  1358.                     WARNING_TONE);
  1359.                 return MMI_FALSE;
  1360.                 /* break; */
  1361.             case THEME_ERROR_PROCESS_QUEUE_SUCESS:
  1362.                 DisplayPopup(NULL, IMG_PROCESSING_PHONEBOOK, 1, UI_POPUP_NOTIFYDURATION_TIME, 0);
  1363.                 return MMI_FALSE;
  1364.                 /* break; */
  1365.                 /* PMT DNLD_THEME_FIXES: SHARIQ START BUG# MAUI_00192708 */
  1366.             case THEME_ERROR_LCD_SIZE_MISMATCH:
  1367.                 DisplayPopup(
  1368.                     (PU8) GetString(STR_LCD_SIZE_MISMATCH),
  1369.                     IMG_GLOBAL_ERROR,
  1370.                     TRUE,
  1371.                     UI_POPUP_NOTIFYDURATION_TIME,
  1372.                     WARNING_TONE);
  1373.                 return MMI_FALSE;
  1374.                 //PMT DNLD_THEME_FIXES: SHARIQ END BUG# MAUI_00192708
  1375.                 //PMT DNLD FIXES 20060513: SUKRIT START MAUI_00221313
  1376.             case THEME_ERROR_FILENAME_INCORRECT:
  1377.                 DisplayPopup(
  1378.                     (PU8) GetString(STR_THEME_ERROR_FILENAME_INCORRECT),
  1379.                     IMG_GLOBAL_WARNING,
  1380.                     0,
  1381.                     UI_POPUP_NOTIFYDURATION_TIME,
  1382.                     WARNING_TONE);
  1383.                 return MMI_FALSE;
  1384.                 /* PMT DNLD FIXES 20060513: SUKRIT END MAUI_00221313 */
  1385.             case THEME_ERROR_PHONE_MODEL_MISMATCH:
  1386.                 DisplayPopup(
  1387.                     (PU8) GetString(STR_THEME_ERROR_PHONE_MODEL_MISMATCH),
  1388.                     IMG_GLOBAL_WARNING,
  1389.                     0,
  1390.                     UI_POPUP_NOTIFYDURATION_TIME,
  1391.                     WARNING_TONE);
  1392.                 return MMI_FALSE;
  1393.             default:
  1394.                 DisplayPopup(
  1395.                     (PU8) GetString(STR_THEME_UNKNOWN_ERROR),
  1396.                     IMG_GLOBAL_ERROR,
  1397.                     TRUE,
  1398.                     UI_POPUP_NOTIFYDURATION_TIME,
  1399.                     ERROR_TONE);
  1400.                 return MMI_FALSE;
  1401.                 /* break; */
  1402.             #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  1403.         }
  1404.         WriteThemesToNVRAM();
  1405.     }
  1406.     else
  1407.     {
  1408.         return MMI_FALSE;
  1409.     }
  1410. #else /* __MMI_THEMES_V2_SUPPORT__ */ 
  1411.     /* index exceeds boundary or theme is not changed */
  1412.     if (index >= g_thm_cntx.TotalTheme || index == g_thm_cntx.CurrTheme)
  1413.     {
  1414.         return MMI_FALSE;
  1415.     }
  1416.     g_thm_cntx.CurrTheme = index;
  1417.     /* reset postion index of update period */
  1418.     if (g_themes_freq_set[g_thm_cntx.CurrUpdatePeriod] != ALM_FREQ_OFF)
  1419.     {
  1420.         SetStartPositionofCurIndex();
  1421.     }
  1422.     /* write change to NVRAM */
  1423.     WriteThemesToNVRAM();
  1424.     /* change theme */
  1425.     if (g_thm_cntx.IsInThmApp == 0) /* is not in theme menu */
  1426.     {
  1427.         SetBothLCDThemes(index);
  1428.         /* MTK Leo add, fix theme update issue */
  1429.         EntryNewScreen(GLOBAL_SCR_DUMMY, NULL, NULL, NULL);
  1430.         GoBackHistory();
  1431.     }
  1432.     else if (g_thm_cntx.IsInThmApp == 1)
  1433.     {
  1434.         /* SetExitHandler(SCR_ID_THM_MENU, NULL); */
  1435.         ClearExitHandler();
  1436.         EntryThmMenu();
  1437.     }
  1438.     return MMI_TRUE;
  1439. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  1440. }
  1441. #ifdef __MMI_THEMES_V2_SUPPORT__
  1442. /*****************************************************************************
  1443.  * FUNCTION
  1444.  *  SetOrderIDList
  1445.  * DESCRIPTION
  1446.  *  To construct set order ID list
  1447.  * PARAMETERS
  1448.  *  IDList              [?]         
  1449.  *  SetNoOfThemes       [IN]        
  1450.  *  index               [IN]        Of the activated theme
  1451.  *  three:(?)
  1452.  *  pointer to array of ID list(?)
  1453.  *  total no of themes in set order list(?)
  1454.  * RETURNS
  1455.  *  void
  1456.  *****************************************************************************/
  1457. void SetOrderIDList(U32 IDList[], U8 SetNoOfThemes, S16 index)
  1458. {
  1459.     /*----------------------------------------------------------------*/
  1460.     /* Local Variables                                                */
  1461.     /*----------------------------------------------------------------*/
  1462.     U8 i;
  1463.     /*----------------------------------------------------------------*/
  1464.     /* Code Body                                                      */
  1465.     /*----------------------------------------------------------------*/
  1466.     for (i = 0; i < g_thm_cntx.TotalTheme; i++)
  1467.     {
  1468.         setorderIDList[i] = IDList[i];
  1469.     }
  1470.     currorderindex = index;
  1471.     WriteThemesToNVRAM();
  1472. }
  1473. /*****************************************************************************
  1474.  * FUNCTION
  1475.  *  GetIDList
  1476.  * DESCRIPTION
  1477.  *  function to get set order ID List
  1478.  * PARAMETERS
  1479.  *  GetIDList       [IN]        
  1480.  *  index           [?]         
  1481.  * RETURNS
  1482.  *  void
  1483.  *****************************************************************************/
  1484. U8 GetIDList(U32 **GetIDList, S16 *index)
  1485. {
  1486.     /*----------------------------------------------------------------*/
  1487.     /* Local Variables                                                */
  1488.     /*----------------------------------------------------------------*/
  1489.     U8 count;
  1490.     /*----------------------------------------------------------------*/
  1491.     /* Code Body                                                      */
  1492.     /*----------------------------------------------------------------*/
  1493.     count = CheckForCorrectOrder();
  1494.     if (count == 0)
  1495.     {
  1496.         currorderindex = -1;
  1497.     }
  1498.     *GetIDList = setorderIDList;
  1499.     *index = currorderindex;
  1500.     WriteThemesToNVRAM();
  1501.     return count;
  1502. }
  1503. /*****************************************************************************
  1504.  * FUNCTION
  1505.  *  CheckForCorrectOrder
  1506.  * DESCRIPTION
  1507.  *  function to check for correct order in set order list
  1508.  * PARAMETERS
  1509.  *  void
  1510.  * RETURNS
  1511.  *  void
  1512.  *****************************************************************************/
  1513. U8 CheckForCorrectOrder(void)
  1514. {
  1515.     /*----------------------------------------------------------------*/
  1516.     /* Local Variables                                                */
  1517.     /*----------------------------------------------------------------*/
  1518.     U16 i, j = 0, set_flag = 0;
  1519.     U8 count = 0, totaltheme;
  1520.     U32 tempIDList[TOTAL_THEMES_COUNT];
  1521. /* MAUI_00019288_Patch_01 Start */
  1522. U16 actual_count = 0;
  1523. /* MAUI_00019288_Patch_01 End */
  1524.     /*----------------------------------------------------------------*/
  1525.     /* Code Body                                                      */
  1526.     /*----------------------------------------------------------------*/
  1527.     totaltheme = mmi_tm_get_themes(&thm_details);
  1528.     ConstructThemeOrderList();
  1529.     for (i = 0; i < TOTAL_THEMES_COUNT; i++)
  1530.     {
  1531.         while (j != totaltheme)
  1532.         {
  1533.             if (setorderIDList[i] == 0)
  1534.             {
  1535.                 tempIDList[i] = setorderIDList[i];
  1536.                 set_flag = 1;
  1537. /* MAUI_00019288_Patch_01 Start */
  1538. actual_count++;
  1539. /* MAUI_00019288_Patch_01 End */
  1540.                 break;
  1541.             }
  1542.             if (setorderIDList[i] == thm_details[j].theme_id)
  1543.             {
  1544.                 tempIDList[i] = setorderIDList[i];
  1545.                 count++;
  1546. /* MAUI_00019288_Patch_01 Start */
  1547. actual_count++;
  1548. /* MAUI_00019288_Patch_01 End */
  1549.                 set_flag = 1;
  1550.                 break;
  1551.             }
  1552.             j++;
  1553.         }
  1554.         if (set_flag == 0)
  1555.         {
  1556.             tempIDList[i] = -1;
  1557.             if (currorderindex >= i)
  1558.             {
  1559.                 currorderindex--;
  1560.             }
  1561.         }
  1562.         set_flag = 0;
  1563.         j = 0;
  1564.     }
  1565.     /* if(j==g_thm_cntx.TotalTheme-1 && setorderIDList[i]!=thm_details[j].theme_id )
  1566.        {
  1567.        if(currorderindex>0 && i<currorderindex)
  1568.        currorderindex=currorderindex-1;
  1569.        break;
  1570.        } */
  1571.     for (i = 0; i < TOTAL_THEMES_COUNT; i++)
  1572.     {
  1573.         if (tempIDList[i] != -1)
  1574.         {
  1575.             setorderIDList[set_flag++] = tempIDList[i];
  1576.         }
  1577.     }
  1578. /* MAUI_00019288_Patch_01 Start */
  1579. for (i = actual_count; i < TOTAL_THEMES_COUNT; i++)
  1580. /* MAUI_00019288_Patch_01 End */
  1581.     {
  1582.         setorderIDList[i] = -1;
  1583.     }
  1584.     return count;
  1585. }
  1586. /*****************************************************************************
  1587.  * FUNCTION
  1588.  *  SetCurrOrderIndex
  1589.  * DESCRIPTION
  1590.  *  function to set current order index
  1591.  * PARAMETERS
  1592.  *  index       [IN]        Of current theme in set order list
  1593.  * RETURNS
  1594.  *  void
  1595.  *****************************************************************************/
  1596. void SetCurrOrderIndex(S16 index)
  1597. {
  1598.     /*----------------------------------------------------------------*/
  1599.     /* Local Variables                                                */
  1600.     /*----------------------------------------------------------------*/
  1601.     /*----------------------------------------------------------------*/
  1602.     /* Code Body                                                      */
  1603.     /*----------------------------------------------------------------*/
  1604.     currorderindex = index;
  1605.     WriteThemesToNVRAM();
  1606. }
  1607. /*****************************************************************************
  1608.  * FUNCTION
  1609.  *  mmi_thm_isValidUrl
  1610.  * DESCRIPTION
  1611.  *  function to check valid url.
  1612.  * PARAMETERS
  1613.  *  pucURLText       [IN]        
  1614.  * RETURNS
  1615.  *  pBOOL
  1616.  *****************************************************************************/
  1617. pBOOL mmi_thm_isValidUrl(S8 *pucURLText)
  1618. {
  1619. S32 iLength ;
  1620. S32 iQueryIndex ;
  1621. S32 iSchemeIndex ;
  1622. S32 iHostIndex ;
  1623. S32 iHostEndIndex ;
  1624. S32 iPortIndex ;
  1625. S32 iPasswordIndex ;
  1626. S32 iPathIndex ;
  1627. S32 iAtIndex ;
  1628. S32 iHashIndex ;
  1629. S32 index ;
  1630. pBOOL bisValid  = TRUE ;
  1631. pBOOL bIsFileScheme  =  FALSE ;
  1632. iQueryIndex = iSchemeIndex = iHostIndex = iPortIndex = iAtIndex = iPathIndex = iPasswordIndex = iHashIndex = -1 ;
  1633. iHostEndIndex = 0 ;
  1634. iLength = strlen ((const char *) pucURLText) ;
  1635. for (index = 0; index < iLength; index++)
  1636. {
  1637. switch (pucURLText[index])
  1638. {
  1639. case '@':
  1640. if (iPasswordIndex > 0)
  1641. {
  1642. iHostIndex = index + 1 ;
  1643. iAtIndex = index ;
  1644. }
  1645. break ;
  1646. case '?':
  1647. iQueryIndex = index + 1 ;
  1648. break ;
  1649. case ':':
  1650. if (iQueryIndex < 0)
  1651. {
  1652. if (pucURLText [index + 1] == '/' && pucURLText [index + 2] == '/')
  1653. {
  1654. iSchemeIndex = index ;
  1655. index += 2 ;
  1656. }
  1657. else if (pucURLText [index + 1] == '/')
  1658. {
  1659. iSchemeIndex = index ;
  1660. }
  1661. else 
  1662. {
  1663. if (iPasswordIndex < 0)
  1664. {
  1665. iPasswordIndex = index + 1 ;
  1666. }
  1667. else
  1668. {
  1669. iPortIndex = index + 1 ;
  1670. }
  1671. }
  1672. }
  1673. break ;
  1674. case '#':
  1675. iHashIndex = index ;
  1676. break ;
  1677. case '/':
  1678. if (iQueryIndex < 0 && iPathIndex < 0 && pucURLText [index + 1] != '/' 
  1679. && pucURLText [index - 1] != '/')
  1680. {
  1681. iPathIndex = index ;
  1682. }
  1683. break ;
  1684. default:
  1685. break ;
  1686. }
  1687. if (iQueryIndex > 0)
  1688. {
  1689. break ;
  1690. }
  1691. }
  1692. if (iPortIndex < 0)
  1693. {
  1694. if (iPasswordIndex > 0 && iAtIndex < 0)
  1695. {
  1696. iPortIndex = iPasswordIndex ;
  1697. }
  1698. }
  1699. if (iHostIndex < 0) 
  1700. {
  1701. if (iSchemeIndex > 0)
  1702. {
  1703. iHostIndex = iSchemeIndex + 3 ;
  1704. }
  1705. else
  1706. {
  1707. iHostIndex = 0 ;
  1708. }
  1709. }
  1710. if (iPathIndex < 0)
  1711. {
  1712. if (iQueryIndex > 0)
  1713. {
  1714. iLength = iQueryIndex - 1 ;
  1715. }
  1716. else if (iHashIndex > 0)
  1717. {
  1718. iLength = iHashIndex ;
  1719. }
  1720. iPathIndex = iLength ;
  1721. iHostEndIndex = iLength - 1 ;
  1722. }
  1723. else
  1724. {
  1725. iHostEndIndex = iPathIndex - 1 ;
  1726. }
  1727. if (FALSE == bIsFileScheme)
  1728. {
  1729. if (mmi_thm_checkValidScheme (pucURLText, iSchemeIndex) == 0)
  1730. {
  1731. bisValid = FALSE ;
  1732. }
  1733. if (iPortIndex > 0)
  1734. {
  1735. if (mmi_thm_checkValidPort (pucURLText, iPortIndex, iPathIndex - 1) == 0)
  1736. {
  1737. bisValid =  FALSE ;
  1738. }
  1739. }
  1740. if (iPortIndex < 0)
  1741. {
  1742. if (mmi_thm_checkValidHostname (pucURLText, iHostIndex, iHostEndIndex) == 0)
  1743. {
  1744. bisValid =  FALSE ;
  1745. }
  1746. }
  1747. else
  1748. {
  1749. if (mmi_thm_checkValidHostname (pucURLText, iHostIndex, iPortIndex - 2) == 0)
  1750. {
  1751. bisValid =  FALSE ;
  1752. }
  1753. }
  1754. }
  1755. return bisValid;
  1756. }
  1757. /*****************************************************************************
  1758.  * FUNCTION
  1759.  *  mmi_thm_checkValidIpaddress
  1760.  * DESCRIPTION
  1761.  *  function to check valid Ip Address.
  1762.  * PARAMETERS
  1763.  *  psUrl_value        [IN]        
  1764.  *  iStart_index       [IN]
  1765.  *  iEnd_index         [IN]
  1766.  * RETURNS
  1767.  *  pBOOL
  1768.  *****************************************************************************/
  1769. pBOOL mmi_thm_checkValidIpaddress (S8 *psUrl_value, S32 iStart_index, S32 iEnd_index)
  1770. {
  1771. S32 index ;
  1772. S8 numeric_value [THEME_IPADDRESS_NUMERIC_LENGTH] ;
  1773. S32 iIndex ;
  1774. S32 iDots_count = 0 ;
  1775. S32 iActual_value ;
  1776. iIndex = 0 ;
  1777. memset (numeric_value, 0, THEME_IPADDRESS_NUMERIC_LENGTH) ; 
  1778. for (index = iStart_index; index <= iEnd_index; index++)
  1779. {
  1780. if ((psUrl_value [index] == '.') || ('' == psUrl_value [index]))
  1781. {
  1782. if ('.' == psUrl_value [index])
  1783. {
  1784. iDots_count++ ;
  1785. }
  1786. iActual_value = atoi ((S8 *) numeric_value) ;
  1787. if (iActual_value > 255 || iActual_value < 0)
  1788. {
  1789. return FALSE ;
  1790. }
  1791. if (iDots_count == 1)
  1792. {
  1793. if (iActual_value == 0)              
  1794. {
  1795. return FALSE ;
  1796. }
  1797. }
  1798. memset (numeric_value, 0, THEME_IPADDRESS_NUMERIC_LENGTH) ; 
  1799. iIndex = 0 ;
  1800. }
  1801. else if ((psUrl_value [index] >= THEME_NUMERIC_BEGIN && psUrl_value [index] <= THEME_NUMERIC_END))
  1802. {
  1803. if (iIndex == THEME_IPADDRESS_NUMERIC_LENGTH)
  1804. {
  1805. return FALSE ;
  1806. }
  1807. numeric_value [iIndex++] = (S8) psUrl_value [index] ;
  1808. }
  1809. else if ((psUrl_value [index] != THEME_NUMERIC_BEGIN && psUrl_value [index] != THEME_NUMERIC_END))
  1810. {
  1811. return FALSE ;
  1812. }
  1813. }
  1814. if (iDots_count != 3)
  1815. {
  1816. return FALSE ;
  1817. }
  1818. return TRUE ;
  1819. }
  1820. /*****************************************************************************
  1821.  * FUNCTION
  1822.  *  mmi_thm_checkValidScheme
  1823.  * DESCRIPTION
  1824.  *  function to check valid Scheme.
  1825.  * PARAMETERS
  1826.  *  pucURLText         [IN]        
  1827.  *  iSchemeIndex       [IN]
  1828.  * RETURNS
  1829.  *  pBOOL
  1830.  *****************************************************************************/
  1831. pBOOL mmi_thm_checkValidScheme (S8 *pucURLText, S32 iSchemeIndex)
  1832. {
  1833. S32 index ;
  1834. pBOOL  bValid = TRUE ;
  1835. if (iSchemeIndex > 0)
  1836. {
  1837. if (iSchemeIndex < 4)
  1838. {
  1839. bValid = FALSE ;
  1840. }
  1841. else
  1842. {
  1843. bValid = FALSE ;
  1844. for (index = 0; index < THEME_TOTAL_VALID_SCHEME; index++)
  1845. {
  1846. if (0 == strncmp ((S8 *) pucURLText, mmi_thm_ValidSchemeList[index], iSchemeIndex))
  1847. {
  1848. bValid = TRUE ;
  1849. index = THEME_TOTAL_VALID_SCHEME ;
  1850. }
  1851. }
  1852. index = iSchemeIndex++ ;
  1853. if (pucURLText [index] != ':' && pucURLText [++index] != '/' && pucURLText [++index] != '/')
  1854. {
  1855. bValid = FALSE ;
  1856. }
  1857. }
  1858. }
  1859. else
  1860. {
  1861. bValid = TRUE ;
  1862. }
  1863. return bValid ;
  1864. }
  1865. /*****************************************************************************
  1866.  * FUNCTION
  1867.  *  mmi_thm_checkValidPort
  1868.  * DESCRIPTION
  1869.  *  function to check valid Port.
  1870.  * PARAMETERS
  1871.  *  pucURLText         [IN]        
  1872.  *  iStartIndex        [IN]
  1873.  *  iEndIndex          [IN]
  1874.  * RETURNS
  1875.  *  pBOOL
  1876.  *****************************************************************************/
  1877. pBOOL mmi_thm_checkValidPort (S8 *pucURLText, S32 iStartIndex, S32 iEndIndex)
  1878. {
  1879. S32 index = 0 ;
  1880. pBOOL bIsValid = TRUE ;
  1881. if (iStartIndex > 0 && iEndIndex > 0)
  1882. {
  1883. for (index = iStartIndex; index <= iEndIndex; index++)
  1884. {
  1885. if (! (pucURLText [index] >= THEME_NUMERIC_BEGIN && pucURLText [index] <= THEME_NUMERIC_END))
  1886. {
  1887. bIsValid = FALSE ;
  1888. }
  1889. }
  1890. }
  1891. return bIsValid ;
  1892. }
  1893. /*****************************************************************************
  1894.  * FUNCTION
  1895.  *  mmi_thm_checkValidHostname
  1896.  * DESCRIPTION
  1897.  *  function to check Host Name.
  1898.  * PARAMETERS
  1899.  *  pucURLText         [IN]        
  1900.  *  iStartIndex        [IN]
  1901.  *  iEndIndex          [IN]
  1902.  * RETURNS
  1903.  *  pBOOL
  1904.  *****************************************************************************/
  1905. pBOOL mmi_thm_checkValidHostname (S8 *pucURLText, S32 iStartIndex, S32 iEndIndex)
  1906. {
  1907. S16 isIpAddress ;
  1908. S32 iDotsCount ;
  1909. pBOOL bIsValid = TRUE ;
  1910. S32 index ;
  1911. if (iStartIndex >= 0 && iEndIndex > 0)
  1912. {
  1913. isIpAddress = 1 ;
  1914. iDotsCount = 0 ;
  1915. if (pucURLText [iStartIndex] == '.' || pucURLText [iStartIndex] == '-')
  1916. {
  1917. bIsValid = FALSE ;
  1918. }
  1919. if (pucURLText [iEndIndex] == '.' || pucURLText [iEndIndex] == '-')
  1920. {
  1921. bIsValid = TRUE ;
  1922. }
  1923. if (TRUE == bIsValid)
  1924. {
  1925. for (index = iStartIndex; index <= iEndIndex; index++)
  1926. {
  1927. if (pucURLText [index] != '.' && pucURLText [index] != '-' && pucURLText [index] != '_')
  1928. {
  1929. if (! (pucURLText [index] >= THEME_NUMERIC_BEGIN && pucURLText [index] <= THEME_NUMERIC_END))
  1930. {
  1931. isIpAddress = 0 ;
  1932. if (! ((pucURLText [index] >= THEME_LOWER_CASE_ALPHA_BEGIN && pucURLText [index] <= 
  1933. THEME_LOWER_CASE_ALPHA_END) || (pucURLText [index] >= THEME_UPPER_CASE_ALPHA_BEGIN && pucURLText [index] <= THEME_UPPER_CASE_ALPHA_END)))
  1934. {
  1935. bIsValid = FALSE ;
  1936. }
  1937. }
  1938. }
  1939. else 
  1940. {
  1941. if (pucURLText [index] == '.')
  1942. {
  1943. iDotsCount++ ;
  1944. }
  1945. if (pucURLText [index + 1] == '.' || pucURLText [index + 1] == '-')
  1946. {
  1947. bIsValid = FALSE ;
  1948. }
  1949. }
  1950. }
  1951. if (isIpAddress == 1)
  1952. {
  1953. if (iDotsCount == 3)
  1954. {
  1955. bIsValid = mmi_thm_checkValidIpaddress (pucURLText, iStartIndex, iEndIndex) ;
  1956. }
  1957. else
  1958. {
  1959. bIsValid = FALSE ;
  1960. }
  1961. }
  1962. }
  1963. }
  1964. else
  1965. {
  1966. bIsValid = FALSE ;
  1967. }
  1968. return bIsValid ;
  1969. }
  1970. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  1971. #endif /* __MMI_THEMES_APPLICATION__ */ 
  1972. #endif /* _MMI_THEME_C */