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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*******************************************************************************
  36.  * Filename:
  37.  * ---------
  38.  * ThemeArchiver.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  * DLT
  43.  *
  44.  * Description:
  45.  * ------------
  46.  * This file defines all message sequence between WAP & Theme Archiver.
  47.  *
  48.  * Author: Deepali
  49.  * -------
  50.  * -------
  51.  *
  52.  *==============================================================================
  53.  *             HISTORY
  54.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  55.  *------------------------------------------------------------------------------
  56.  * removed!
  57.  *
  58.  * removed!
  59.  * removed!
  60.  * removed!
  61.  *
  62.  * removed!
  63.  * removed!
  64.  * removed!
  65.  *
  66.  * removed!
  67.  * removed!
  68.  * removed!
  69.  *
  70.  * removed!
  71.  * removed!
  72.  * removed!
  73.  *
  74.  * removed!
  75.  * removed!
  76.  * removed!
  77.  *
  78.  * removed!
  79.  * removed!
  80.  * removed!
  81.  *
  82.  * removed!
  83.  * removed!
  84.  * removed!
  85.  *
  86.  * removed!
  87.  * removed!
  88.  * removed!
  89.  *
  90.  * removed!
  91.  * removed!
  92.  * removed!
  93.  *
  94.  * removed!
  95.  * removed!
  96.  * removed!
  97.  *
  98.  * removed!
  99.  * removed!
  100.  * removed!
  101.  *
  102.  * removed!
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  *------------------------------------------------------------------------------
  108.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  109.  *==============================================================================
  110.  *******************************************************************************/
  111. #ifndef _MMI_THEME_ARCHIVER_C
  112. #define _MMI_THEME_ARCHIVER_C
  113. #include "MMI_features.h"
  114. #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  115. #include "stdC.h"
  116. #include "PixtelDataTypes.h"
  117. #include "EventsGprot.h"
  118. #include "historyGprot.h"
  119. #include "ProtocolEvents.h"
  120. #include "QueueGprot.h"
  121. #include "OslMemory.h"
  122. #include "TimerEvents.h"
  123. #include "wgui_categories.h"
  124. #include "wgui_categories_inputs.h"
  125. #include "wgui_categories_popup.h"
  126. #include "wgui_categories_stopwatch.h"
  127. #include "Globaldefs.h"
  128. #include "GlobalScrEnum.h"
  129. #include "FunAndGamesDefs.h"
  130. #include "CommonScreens.h"
  131. #include "FileSystemDef.h"
  132. #include "FileManagerDef.h"
  133. #include "FileSystemGProt.h"
  134. #include "fs_type.h"
  135. #include "fs_func.h"
  136. #include "fs_errcode.h"
  137. #include "FileMgr.h"
  138. #include "SettingProfile.h"
  139. #include "stack_common.h"
  140. #include "Wap.h"
  141. #include "xml_def.h"
  142. #include "ThemeArchiverDef.h"
  143. #include "ThemeArchiverMsgStruct.h"
  144. #include "ThemeArchiverProt.h"
  145. #include "Calculator.h"
  146. #include "ThemeManager.h"
  147. #include "DLAgentDef.h"
  148. #include "DLAgentGprot.h"
  149. #ifndef MMI_ON_WIN32
  150. #include "app_ltlcom.h"
  151. #endif 
  152. ta_da_context_struct g_ta_da_context;
  153. /*****************************************************************************
  154.  * FUNCTION
  155.  *  mmi_da_handle_theme_content
  156.  * DESCRIPTION
  157.  *  Handles theme download through WAP
  158.  * PARAMETERS
  159.  *  filename_p      [IN]        
  160.  * RETURNS
  161.  *  void
  162.  *****************************************************************************/
  163. void mmi_ta_handle_theme_content(S8 *filename_p)
  164. {
  165.     /*----------------------------------------------------------------*/
  166.     /* Local Variables                                                */
  167.     /*----------------------------------------------------------------*/
  168.     /*----------------------------------------------------------------*/
  169.     /* Code Body                                                      */
  170.     /*----------------------------------------------------------------*/
  171.     history currHistory;
  172.     U16 nHistory = 0;
  173.     /*----------------------------------------------------------------*/
  174.     /* Code Body                                                      */
  175.     /*----------------------------------------------------------------*/
  176.     currHistory.scrnID = SCR_ID_DOWNLOAD_THM_STORAGE;
  177.     currHistory.entryFuncPtr = mmi_ta_entry_select_storage_screen;
  178.     memset((void*)currHistory.guiBuffer, 0, sizeof(currHistory.guiBuffer));
  179.     pfnUnicodeStrcpy((S8*) currHistory.inputBuffer, (S8*) & nHistory);
  180.     DisplayPopup(
  181.         (PU8) GetString(STR_THEME_FILE_DOWNLOADED),
  182.         IMG_GLOBAL_ACTIVATED,
  183.         1,
  184.         UI_POPUP_NOTIFYDURATION_TIME,
  185.         (U8) SUCCESS_TONE);
  186.     AddHistory(currHistory);
  187.     /*----------------------------------------------------------------*/
  188.     /* Code Body                                                      */
  189.     /*----------------------------------------------------------------*/
  190.     if (filename_p)
  191.     {
  192.         pfnUnicodeStrcpy((S8*) g_ta_da_context.file_name_with_path, (S8*) filename_p);
  193.     }
  194. }
  195. /*****************************************************************************
  196.  * FUNCTION
  197.  *  mmi_ta_receive_theme_file
  198.  * DESCRIPTION
  199.  *  Handles theme download through DLA
  200.  * PARAMETERS
  201.  *  session_id              [IN]        
  202.  *  mime_type               [IN]        
  203.  *  mime_subtype            [IN]        
  204.  *  action                  [IN]        
  205.  *  file_path               [IN]        
  206.  *  url                     [IN]        
  207.  *  mime_type_string        [IN]        
  208.  * RETURNS
  209.  *  NONE
  210.  *****************************************************************************/
  211. void mmi_ta_receive_theme_file(
  212.         S32 session_id,
  213.         S32 mime_type,
  214.         S32 mime_subtype,
  215.         S32 action,
  216.         PU16 file_path,
  217.         PS8 url,
  218.         PS8 mime_type_string)
  219. {
  220.     /*----------------------------------------------------------------*/
  221.     /* Local Variables                                                */
  222.     /*----------------------------------------------------------------*/
  223.     /*----------------------------------------------------------------*/
  224.     /* Code Body                                                      */
  225.     /*----------------------------------------------------------------*/
  226.     mmi_ta_handle_theme_content((S8*)file_path);
  227.     return;
  228. }
  229. /*****************************************************************************
  230.  * FUNCTION
  231.  *  mmi_ta_check_theme_file_version_compatibility
  232.  * DESCRIPTION
  233.  *  validates Theme version.
  234.  * PARAMETERS
  235.  *  theme_version       [IN]        
  236.  * RETURNS
  237.  *  true if compatible otherwise false
  238.  *****************************************************************************/
  239. U16 mmi_ta_check_theme_file_version_compatibility(FLOAT theme_version)
  240. {
  241.     /*----------------------------------------------------------------*/
  242.     /* Local Variables                                                */
  243.     /*----------------------------------------------------------------*/
  244.     U8 i;
  245.     FLOAT *VersionTable_p;
  246.     /*----------------------------------------------------------------*/
  247.     /* Code Body                                                      */
  248.     /*----------------------------------------------------------------*/
  249.     VersionTable_p = (FLOAT*) mmi_tm_get_theme_version_table();
  250.     for (i = 0; i < MAX_SUPPORTED_VERSION_NUM; i++)
  251.     {
  252.         if (VersionTable_p[i] == theme_version)
  253.         {
  254.             return TRUE;
  255.         }
  256.     }
  257.     return FALSE;
  258. }
  259. /*****************************************************************************
  260.  * FUNCTION
  261.  *  mmi_ta_check_theme_file_lcd_dim_compatibiltiy
  262.  * DESCRIPTION
  263.  *  validates LCD dimensions.
  264.  * PARAMETERS
  265.  *  lcd_width       [IN]        
  266.  *  lcd_height      [IN]        
  267.  * RETURNS
  268.  *  true if compatible otherwise false
  269.  *****************************************************************************/
  270. U16 mmi_ta_check_theme_file_lcd_dim_compatibiltiy(U32 lcd_width, U32 lcd_height)
  271. {
  272.     /*----------------------------------------------------------------*/
  273.     /* Local Variables                                                */
  274.     /*----------------------------------------------------------------*/
  275.     /*----------------------------------------------------------------*/
  276.     /* Code Body                                                      */
  277.     /*----------------------------------------------------------------*/
  278.     if (lcd_height == LCD_HEIGHT && lcd_width == LCD_WIDTH)
  279.     {
  280.         return TRUE;
  281.     }
  282.     else
  283.     {
  284.         return FALSE;
  285.     }
  286. }
  287. /*****************************************************************************
  288.  * FUNCTION
  289.  *  mmi_ta_check_theme_type_compatibility
  290.  * DESCRIPTION
  291.  *  validates Theme type.
  292.  * PARAMETERS
  293.  *  input_type_p        [?]     
  294.  * RETURNS
  295.  *  true if compatible otherwise false
  296.  *****************************************************************************/
  297. U16 mmi_ta_check_theme_type_compatibility(S8 *input_type_p)
  298. {
  299.     /*----------------------------------------------------------------*/
  300.     /* Local Variables                                                */
  301.     /*----------------------------------------------------------------*/
  302.     U8 i = 0;
  303.     /*----------------------------------------------------------------*/
  304.     /* Code Body                                                      */
  305.     /*----------------------------------------------------------------*/
  306.     for (i = 0; i < MAX_ACCEPTABLE_THEME_FILE_TYPE; i++)
  307.     {
  308.         if (strcmp(input_type_p, g_tad_acceptable_theme_filetypes_p[i]) == 0)
  309.         {
  310.             return TRUE;
  311.         }
  312.     }
  313.     return FALSE;
  314. }
  315. /*****************************************************************************
  316.  * FUNCTION
  317.  *  mmi_ta_entry_select_storage_screen
  318.  * DESCRIPTION
  319.  *  Show select storage screen.
  320.  * PARAMETERS
  321.  *  void
  322.  * RETURNS
  323.  *  void
  324.  *****************************************************************************/
  325. void mmi_ta_entry_select_storage_screen(void)
  326. {
  327.     /*----------------------------------------------------------------*/
  328.     /* Local Variables                                                */
  329.     /*----------------------------------------------------------------*/
  330.     U8 *guiBuffer_p;
  331.     U16 nStrItemList[MAX_SUB_MENUS];
  332.     U16 nNumofItem;
  333.     U16 nDispAttribute;
  334.     /*----------------------------------------------------------------*/
  335.     /* Code Body                                                      */
  336.     /*----------------------------------------------------------------*/
  337.     EntryNewScreen(SCR_ID_DOWNLOAD_THM_STORAGE, NULL, mmi_ta_entry_select_storage_screen, NULL);
  338.     guiBuffer_p = GetCurrGuiBuffer(SCR_ID_DOWNLOAD_THM_STORAGE);
  339.     nNumofItem = GetNumOfChild(MENU_DOWNLOAD_THEMES_STORAGE);
  340.     nDispAttribute = GetDispAttributeOfItem(MENU_DOWNLOAD_THEMES_STORAGE);
  341.     GetSequenceStringIds(MENU_DOWNLOAD_THEMES_STORAGE, nStrItemList);
  342.     SetParentHandler(MENU_DOWNLOAD_THEMES_STORAGE);
  343.     RegisterHighlightHandler(mmi_ta_select_dlt_storage_type);
  344.     ShowCategory11Screen(
  345.         STR_SELECT_STORAGE_TITLE_ID,
  346.         IMG_SELECT_STORAGE_TITLE_ID,
  347.         STR_GLOBAL_OK,
  348.         0,
  349.         STR_GLOBAL_BACK,
  350.         0,
  351.         nNumofItem,
  352.         nStrItemList,
  353.         0,
  354.         guiBuffer_p);
  355.     SetLeftSoftkeyFunction(mmi_ta_set_dlt_storage_type, KEY_EVENT_UP);
  356.     SetRightSoftkeyFunction(mmi_ta_exit_dlt_storage_type, KEY_EVENT_UP);
  357.     SetKeyHandler(DisplayIdleScreen, KEY_END, KEY_EVENT_DOWN);
  358. }
  359. /*****************************************************************************
  360.  * FUNCTION
  361.  *  mmi_ta_exit_dlt_storage_type
  362.  * DESCRIPTION
  363.  *  CallBack function for highlight movement on Select Storage screen.
  364.  * PARAMETERS
  365.  *  void
  366.  * RETURNS
  367.  *  void
  368.  *****************************************************************************/
  369. void mmi_ta_exit_dlt_storage_type(void)
  370. {
  371.     /*----------------------------------------------------------------*/
  372.     /* Local Variables                                                */
  373.     /*----------------------------------------------------------------*/
  374.     /*----------------------------------------------------------------*/
  375.     /* Code Body                                                      */
  376.     /*----------------------------------------------------------------*/
  377.     mmi_ta_delete_intermediate_dlt_files((U16*) g_ta_da_context.file_name_with_path);
  378.     GoBackHistory();
  379. }
  380. /*****************************************************************************
  381.  * FUNCTION
  382.  *  mmi_ta_select_dlt_storage_type
  383.  * DESCRIPTION
  384.  *  CallBack function for highlight movement on Select Storage screen.
  385.  * PARAMETERS
  386.  *  index       [IN]        
  387.  * RETURNS
  388.  *  void
  389.  *****************************************************************************/
  390. void mmi_ta_select_dlt_storage_type(S32 index)
  391. {
  392.     /*----------------------------------------------------------------*/
  393.     /* Local Variables                                                */
  394.     /*----------------------------------------------------------------*/
  395.     /*----------------------------------------------------------------*/
  396.     /* Code Body                                                      */
  397.     /*----------------------------------------------------------------*/
  398.     g_ta_da_context.current_hilite_storage_type = index;
  399. }
  400. /*****************************************************************************
  401.  * FUNCTION
  402.  *  mmi_ta_set_dlt_storage_type
  403.  * DESCRIPTION
  404.  *  Validate the selected storage type and set storage location for
  405.  *  theme download content.
  406.  * PARAMETERS
  407.  *  void
  408.  * RETURNS
  409.  *  void
  410.  *****************************************************************************/
  411. void mmi_ta_set_dlt_storage_type(void)
  412. {
  413.     /*----------------------------------------------------------------*/
  414.     /* Local Variables                                                */
  415.     /*----------------------------------------------------------------*/
  416.     S32 fs_RetDrv = 0;
  417.     U64 disk_free_space;
  418.     U64 file_size;
  419.     FS_DiskInfo disk_info;
  420.     FS_HANDLE file_handle;
  421.     /*----------------------------------------------------------------*/
  422.     /* Code Body                                                      */
  423.     /*----------------------------------------------------------------*/
  424.     switch (g_ta_da_context.current_hilite_storage_type)
  425.     {
  426.         case 0:
  427.             fs_RetDrv = FS_GetDrive(FS_DRIVE_V_NORMAL, 2, FS_DRIVE_V_NORMAL | FS_DRIVE_I_SYSTEM);
  428.             g_ta_da_context.curr_storage_type = THEME_TYPE_DOWNLOADED_PHONE;
  429.             break;
  430.         case 1:
  431.             fs_RetDrv = FS_GetDrive(FS_DRIVE_V_REMOVABLE, 1, FS_NO_ALT_DRIVE);
  432.             g_ta_da_context.curr_storage_type = THEME_TYPE_DOWNLOADED_CARD;
  433.             break;
  434.         default:
  435.             break;
  436.     }
  437.     if (fs_RetDrv >= 0)
  438.     {
  439.         S8 buf[6];
  440.         S32 create_result;
  441.         sprintf(buf, "%c:\", (U8) fs_RetDrv);
  442.         memset(subMenuData, 0, (FMGR_MAX_PATH_LEN + FMGR_MAX_FILE_LEN) * ENCODING_LENGTH);
  443.         AnsiiToUnicodeString((S8*) subMenuData, (S8*) buf);
  444.         file_handle = FS_Open((kal_uint16*) subMenuData, FS_OPEN_DIR | FS_READ_ONLY);
  445.         if (file_handle >= 0)
  446.         {
  447.             FS_Close(file_handle);
  448.             /* drive is avaiable */
  449.             FS_GetDiskInfo((PU16) subMenuData, &disk_info, FS_DI_BASIC_INFO | FS_DI_FREE_SPACE);
  450.             disk_free_space = disk_info.FreeClusters * disk_info.SectorsPerCluster * disk_info.BytesPerSector;
  451.             file_size = (U64) (g_ta_da_context.da_file_size * 1024);
  452.             if (disk_free_space >= file_size)
  453.             {
  454.                 pfnUnicodeStrcat((PS8) subMenuData, (PS8) FMGR_DEFAULT_FOLDER_THEMES);
  455.                 file_handle = FS_Open((kal_uint16*) subMenuData, FS_OPEN_DIR | FS_READ_ONLY);
  456.                 /* path already exist */
  457.                 if (file_handle >= 0)
  458.                 {
  459.                     FS_Close(file_handle);
  460.                     create_result = 0;
  461.                 }
  462.                 else
  463.                 {
  464.                     create_result = FS_CreateDir((PU16) subMenuData);
  465.                 }
  466.                 if (create_result == FS_WRITE_PROTECTION)
  467.                 {
  468.                     DisplayPopup(
  469.                         (PU8) GetString(STR_ID_DLT_WRITE_PROTECTED),
  470.                         IMG_GLOBAL_WARNING,
  471.                         0,
  472.                         UI_POPUP_NOTIFYDURATION_TIME,
  473.                         WARNING_TONE);
  474.                 }
  475.                 else if (create_result == FS_DISK_FULL)
  476.                 {
  477.                     DisplayPopup(
  478.                         (PU8) GetString(STR_ID_DLT_DISK_FULL),
  479.                         IMG_GLOBAL_WARNING,
  480.                         0,
  481.                         UI_POPUP_NOTIFYDURATION_TIME,
  482.                         WARNING_TONE);
  483.                 }
  484.                 else
  485.                 {
  486.                     mmi_ta_save_theme_content((PS8) subMenuData);
  487.                 }
  488.             }
  489.             else
  490.             {
  491.                 DisplayPopup(
  492.                     (PU8) GetString(STR_ID_DLT_UNSUFFICIENT_MEMORY),
  493.                     IMG_GLOBAL_WARNING,
  494.                     1,
  495.                     UI_POPUP_NOTIFYDURATION_TIME,
  496.                     WARNING_TONE);
  497.             }
  498.         }
  499.         else
  500.         {
  501.             DisplayPopup(
  502.                 (PU8) GetString(STR_ID_DLT_NO_MEMORY_CARD),
  503.                 IMG_GLOBAL_WARNING,
  504.                 1,
  505.                 UI_POPUP_NOTIFYDURATION_TIME,
  506.                 WARNING_TONE);
  507.         }
  508.     }
  509.     else
  510.     {
  511.         /* get drive error  */
  512.         DisplayPopup(
  513.             (PU8) GetString(STR_ID_DLT_NO_MEMORY_CARD),
  514.             IMG_GLOBAL_WARNING,
  515.             1,
  516.             UI_POPUP_NOTIFYDURATION_TIME,
  517.             WARNING_TONE);
  518.     }
  519. }
  520. /*****************************************************************************
  521.  * FUNCTION
  522.  *  mmi_ta_save_theme_content
  523.  * DESCRIPTION
  524.  *  Saves the Theme Content in the right folder
  525.  * PARAMETERS
  526.  *  filepath_p      [IN]        
  527.  * RETURNS
  528.  *  void
  529.  *****************************************************************************/
  530. void mmi_ta_save_theme_content(S8 *filepath_p)
  531. {
  532.     /*----------------------------------------------------------------*/
  533.     /* Local Variables                                                */
  534.     /*----------------------------------------------------------------*/
  535.     S8 *temp_file_name_p;
  536.     S8 temp_file_name[(FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH];
  537.     /*----------------------------------------------------------------*/
  538.     /* Code Body                                                      */
  539.     /*----------------------------------------------------------------*/
  540.     temp_file_name_p = mmi_ta_parse_url_extract_file_name((S8*) g_ta_da_context.file_name_with_path);
  541.     pfnUnicodeStrncpy(temp_file_name, temp_file_name_p, (FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH);
  542.     mmi_ta_check_if_file_alrdy_exist_in_fm((S8*) filepath_p, (S8*) temp_file_name);
  543.     pfnUnicodeStrcat((S8*) subMenuData, (S8*) temp_file_name);
  544.     FS_Move(
  545.         (const WCHAR*)g_ta_da_context.file_name_with_path,
  546.         (const WCHAR*)subMenuData,
  547.         FS_MOVE_KILL | FS_MOVE_OVERWRITE,
  548.         NULL, NULL, 0);
  549.     pfnUnicodeStrcpy((S8*) g_ta_da_context.file_name_with_path, (S8*) subMenuData);
  550.     mmi_ta_theme_download_complete_notification();
  551. }
  552. /*****************************************************************************
  553.  * FUNCTION
  554.  *  mmi_ta_theme_download_complete_notification
  555.  * DESCRIPTION
  556.  *  show download complete notification..
  557.  * PARAMETERS
  558.  *  void
  559.  * RETURNS
  560.  *  void
  561.  *****************************************************************************/
  562. void mmi_ta_theme_download_complete_notification(void)
  563. {
  564.     /*----------------------------------------------------------------*/
  565.     /* Local Variables                                                */
  566.     /*----------------------------------------------------------------*/
  567.     /*----------------------------------------------------------------*/
  568.     /* Code Body                                                      */
  569.     /*----------------------------------------------------------------*/
  570.     DisplayConfirm(
  571.         STR_GLOBAL_YES,
  572.         IMG_GLOBAL_YES,
  573.         STR_GLOBAL_NO,
  574.         IMG_GLOBAL_NO,
  575.         get_string(STR_ID_THEME_DOWNLOAD_COMPLETE),
  576.         IMG_GLOBAL_QUESTION,
  577.         WARNING_TONE);
  578.     DeleteScreenIfPresent(SCR_ID_DOWNLOAD_THM_STORAGE);
  579.     SetLeftSoftkeyFunction(mmi_ta_set_dlt_as_activated, KEY_EVENT_UP);
  580.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  581. }
  582. /*****************************************************************************
  583.  * FUNCTION
  584.  *  mmi_ta_set_dlt_as_activated
  585.  * DESCRIPTION
  586.  *  Apply downloaded theme as currrent theme.
  587.  * PARAMETERS
  588.  *  void
  589.  * RETURNS
  590.  *  void
  591.  *****************************************************************************/
  592. void mmi_ta_set_dlt_as_activated(void)
  593. {
  594.     /*----------------------------------------------------------------*/
  595.     /* Local Variables                                                */
  596.     /*----------------------------------------------------------------*/
  597.     int status;
  598.     S8 *temp_file_name_p;
  599.     S8 temp_file_name[(FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH];
  600.     /*----------------------------------------------------------------*/
  601.     /* Code Body                                                      */
  602.     /*----------------------------------------------------------------*/
  603.     /* This fn call will create history for the previous screen 
  604.        and the current screen will not be created in history */
  605.     EntryNewScreen(0, NULL, NULL, NULL);
  606.     ShowCategory66Screen(
  607.         STR_SCR3001_THEMES_CAPTION,
  608.         0,
  609.         0,
  610.         0,
  611.         0,
  612.         0,
  613.         (PU8) GetString(STR_ID_DLT_THM_PROGRESS),
  614.         IMG_THEME_ACTIVATION,
  615.         NULL);
  616.     DeleteScreenIfPresent(SCR_ID_DOWNLOAD_THM_STORAGE);
  617.     temp_file_name_p = mmi_ta_parse_url_extract_file_name((S8*) g_ta_da_context.file_name_with_path);
  618.     pfnUnicodeStrncpy(temp_file_name, temp_file_name_p, (FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH);
  619.     status = mmi_tm_activate_theme_from_fmgr(g_ta_da_context.curr_storage_type, (PU8) temp_file_name);
  620.     mmi_tm_handle_theme_activation_error_status((U16) status);  /* removed warning: by shariq */
  621. }
  622. /*****************************************************************************
  623.  * FUNCTION
  624.  *  mmi_ta_handle_abort_req
  625.  * DESCRIPTION
  626.  *  handle download abort request from JAS
  627.  * PARAMETERS
  628.  *  inMsg_p     [?]     
  629.  * RETURNS
  630.  *  void
  631.  *****************************************************************************/
  632. void mmi_ta_handle_abort_req(void *inMsg_p)
  633. {
  634.     /*----------------------------------------------------------------*/
  635.     /* Local Variables                                                */
  636.     /*----------------------------------------------------------------*/
  637.     /*----------------------------------------------------------------*/
  638.     /* Code Body                                                      */
  639.     /*----------------------------------------------------------------*/
  640.     /* For future use */
  641. }
  642. /*****************************************************************************
  643.  * FUNCTION
  644.  *  mmi_ta_parse_url_extract_file_name
  645.  * DESCRIPTION
  646.  *  extract file name from URL for non-oma
  647.  * PARAMETERS
  648.  *  path        [?]     
  649.  * RETURNS
  650.  *  true if successfully parsed otherwise false
  651.  *****************************************************************************/
  652. PS8 mmi_ta_parse_url_extract_file_name(S8 *path)
  653. {
  654.     /*----------------------------------------------------------------*/
  655.     /* Local Variables                                                */
  656.     /*----------------------------------------------------------------*/
  657.     S32 i, length;
  658.     /*----------------------------------------------------------------*/
  659.     /* Code Body                                                      */
  660.     /*----------------------------------------------------------------*/
  661.     length = pfnUnicodeStrlen(path) * 2;
  662.     i = length - 1;
  663.     while (i > 0)
  664.     {
  665.         if (path[i - 1] == '\' && path[i] == 0 && (i != length - ENCODING_LENGTH))
  666.         {
  667.             break;
  668.         }
  669.         i -= 2;
  670.     }
  671.     if (i < 0)
  672.     {
  673.         return NULL;
  674.     }
  675.     return &path[i + 1];
  676. }
  677. /*****************************************************************************
  678.  * FUNCTION
  679.  *  mmi_ta_delete_intermediate_dlt_files
  680.  * DESCRIPTION
  681.  *  To delete intermediate downloaded files.
  682.  * PARAMETERS
  683.  *  file_path_p     [?]     
  684.  * RETURNS
  685.  *  void
  686.  *****************************************************************************/
  687. void mmi_ta_delete_intermediate_dlt_files(U16 *file_path_p)
  688. {
  689.     /*----------------------------------------------------------------*/
  690.     /* Local Variables                                                */
  691.     /*----------------------------------------------------------------*/
  692.     FS_HANDLE fd;
  693.     /*----------------------------------------------------------------*/
  694.     /* Code Body                                                      */
  695.     /*----------------------------------------------------------------*/
  696.     /* if file exists. Delete it. */
  697.     fd = FS_Open((WCHAR*) file_path_p, FS_READ_WRITE);
  698.     if (fd >= 0)
  699.     {
  700.         FS_Close(fd);
  701.         FS_Delete((WCHAR*) file_path_p);
  702.     }
  703. }
  704. /*****************************************************************************
  705.  * FUNCTION
  706.  *  mmi_ta_check_if_file_alrdy_exist_in_fm
  707.  * DESCRIPTION
  708.  *  Check if file Already exists in File manager.
  709.  * PARAMETERS
  710.  *  file_path       [IN]        
  711.  *  file_name       [IN]        
  712.  *  PS8 file name and file path(?)
  713.  * RETURNS
  714.  *  void
  715.  *****************************************************************************/
  716. void mmi_ta_check_if_file_alrdy_exist_in_fm(PS8 file_path, PS8 file_name)
  717. {
  718.     /*----------------------------------------------------------------*/
  719.     /* Local Variables                                                */
  720.     /*----------------------------------------------------------------*/
  721.     FS_HANDLE fd;
  722.     U8 file_count = 0;
  723.     S8 tempStr[6];
  724.     S8 ucs2_dup_file_rename[12];
  725.     U8 len;
  726.     S8 file_ext_buf[(FMGR_MAX_EXT_LEN + 1) * ENCODING_LENGTH];
  727.     S8 *file_ext_p;
  728.     S8 temp_file_name[(FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH];
  729.     /*----------------------------------------------------------------*/
  730.     /* Code Body                                                      */
  731.     /*----------------------------------------------------------------*/
  732.     memset(temp_file_name, 0, (FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH);
  733.     pfnUnicodeStrncpy(temp_file_name, file_name, FMGR_MAX_FILE_LEN * ENCODING_LENGTH);
  734.     while (file_count < 65535)
  735.     {
  736.         memset(hintData, 0, (FMGR_MAX_PATH_LEN + FMGR_MAX_FILE_LEN) * ENCODING_LENGTH);
  737.         pfnUnicodeStrncpy((PS8) hintData, file_path, FMGR_PATH_BUFFER_SIZE - ENCODING_LENGTH);
  738.         pfnUnicodeStrncat((PS8) hintData, temp_file_name, (FMGR_MAX_FILE_LEN) * ENCODING_LENGTH);
  739.         file_count++;
  740.         fd = FS_Open((WCHAR*) hintData, FS_READ_ONLY);
  741.         if (fd >= 0)
  742.         {
  743.             FS_Close(fd);
  744.             sprintf(tempStr, "%d", file_count);
  745.             AnsiiToUnicodeString(ucs2_dup_file_rename, tempStr);
  746.             memset(temp_file_name, 0, (FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH);
  747.             pfnUnicodeStrncpy(temp_file_name, file_name, FMGR_MAX_FILE_LEN * ENCODING_LENGTH);
  748.             file_ext_p = (S8*) mmi_fmgr_extract_ext_file_name(temp_file_name);
  749.             pfnUnicodeStrcpy(file_ext_buf, file_ext_p);
  750.             mmi_ta_thmgr_hide_ext_name(temp_file_name);
  751.             len = FMGR_MAX_INPUT_FILE_LEN - pfnUnicodeStrlen(temp_file_name);
  752.             if (len >= pfnUnicodeStrlen(ucs2_dup_file_rename))
  753.             {
  754.                 pfnUnicodeStrcat(temp_file_name, ucs2_dup_file_rename);
  755.             }
  756.             else
  757.             {
  758.                 memset(temp_file_name + (FMGR_MAX_INPUT_FILE_LEN - 6) * ENCODING_LENGTH, 0, 12);
  759.                 AnsiiToUnicodeString(tempStr, "~");
  760.                 pfnUnicodeStrcat(temp_file_name, tempStr);
  761.                 pfnUnicodeStrcat(temp_file_name, ucs2_dup_file_rename);
  762.             }
  763.             AnsiiToUnicodeString(tempStr, ".");
  764.             pfnUnicodeStrcat(temp_file_name, tempStr);
  765.             pfnUnicodeStrcat(temp_file_name, file_ext_buf);
  766.         }
  767.         else
  768.         {
  769.             pfnUnicodeStrcpy(file_name, temp_file_name);
  770.             break;
  771.         }
  772.     }
  773. }
  774. /*****************************************************************************
  775.  * FUNCTION
  776.  *  mmi_ta_thmgr_hide_ext_name
  777.  * DESCRIPTION
  778.  *  hide extension file name
  779.  * PARAMETERS
  780.  *  file_name_p     [?]     
  781.  * RETURNS
  782.  *  void
  783.  *****************************************************************************/
  784. void mmi_ta_thmgr_hide_ext_name(S8 *file_name_p)
  785. {
  786.     /*----------------------------------------------------------------*/
  787.     /* Local Variables                                                */
  788.     /*----------------------------------------------------------------*/
  789.     /* find ext name - by finding "." */
  790.     S32 str_len;
  791.     S32 index;
  792.     /*----------------------------------------------------------------*/
  793.     /* Code Body                                                      */
  794.     /*----------------------------------------------------------------*/
  795.     str_len = pfnUnicodeStrlen(file_name_p);
  796.     index = (str_len - 1) * ENCODING_LENGTH;
  797.     while (index > 0)
  798.     {
  799.         if (pfnUnicodeStrncmp((PS8) & file_name_p[index], (PS8) L".", 1) == 0)
  800.         {
  801.             file_name_p[index] = '';
  802.             file_name_p[index + 1] = '';
  803.             break;
  804.         }
  805.         file_name_p[index] = '';
  806.         file_name_p[index + 1] = '';
  807.         index -= 2;
  808.     }
  809. }
  810. /*****************************************************************************
  811.  * FUNCTION
  812.  *  mmi_ta_parse_lcd_size
  813.  * DESCRIPTION
  814.  *  It parses the lcd height and lcd width string given in dd file
  815.  * PARAMETERS
  816.  *  lcd_size_string_p       [IN]        
  817.  *  lcd_height_p            [IN]        
  818.  *  lcd_width_p             [IN]        
  819.  * RETURNS
  820.  *  void
  821.  *****************************************************************************/
  822. void mmi_ta_parse_lcd_size(const S8 *lcd_size_string_p, S8 *lcd_height_p, S8 *lcd_width_p)
  823. {
  824.     /*----------------------------------------------------------------*/
  825.     /* Local Variables                                                */
  826.     /*----------------------------------------------------------------*/
  827.     int count1 = 0, count2 = 0;
  828.     S8 lcd_size_param[MAX_LCD_STRING_SIZE];
  829.     S8 temp_ch;
  830.     /*----------------------------------------------------------------*/
  831.     /* Code Body                                                      */
  832.     /*----------------------------------------------------------------*/
  833.     memset(lcd_size_param, 0, MAX_LCD_STRING_SIZE);
  834.     while (*lcd_size_string_p != '')
  835.     {
  836.         temp_ch = (S8) * lcd_size_string_p;
  837.         if (temp_ch != ':' && temp_ch != (S8) ';' && temp_ch != ' ' && temp_ch != 't')
  838.         {
  839.             lcd_size_param[count1] = temp_ch;
  840.             ++count1;
  841.         }
  842.         else if (*lcd_size_string_p == ':')
  843.         {
  844.             lcd_size_param[count1] = 0;
  845.             count1 = 0;
  846.             count2 = 0;
  847.             while (temp_ch == ':' || temp_ch == ';' || temp_ch == ' ' || temp_ch == 't')
  848.             {
  849.                 ++(lcd_size_string_p);
  850.                 temp_ch = (S8) * lcd_size_string_p;
  851.             }
  852.             while (temp_ch != '' && temp_ch != ':' && temp_ch != ';' && temp_ch != ' ' && temp_ch != 't')
  853.             {
  854.                 if (!strcmp(lcd_size_param, g_ta_theme_descriptor_tags_p[6]))
  855.                 {
  856.                     lcd_height_p[count2] = temp_ch;
  857.                     ++count2;
  858.                 }
  859.                 else if (!strcmp(lcd_size_param, g_ta_theme_descriptor_tags_p[7]))
  860.                 {
  861.                     lcd_width_p[count2] = temp_ch;
  862.                     ++count2;
  863.                 }
  864.                 ++(lcd_size_string_p);
  865.                 temp_ch = (S8) * lcd_size_string_p;
  866.             }
  867.             if (!strcmp(lcd_size_param, g_ta_theme_descriptor_tags_p[6]))
  868.             {
  869.                 lcd_height_p[count2] = 0;
  870.             }
  871.             else if (!strcmp(lcd_size_param, g_ta_theme_descriptor_tags_p[7]))
  872.             {
  873.                 lcd_width_p[count2] = 0;
  874.             }
  875.         }
  876.         ++(lcd_size_string_p);
  877.     }
  878. }
  879. /*****************************************************************************
  880.  * FUNCTION
  881.  *  mmi_ta_da_oma_install_check_hdlr
  882.  * DESCRIPTION
  883.  *  Its a OMA download callback function and called by download agent for validating the
  884.  *  theme descriptor file
  885.  * PARAMETERS
  886.  *  dd_file     [IN]        
  887.  * RETURNS
  888.  *  TRUE                   if descriptor file contains valid info
  889.  *  FALSE                  if descriptor file contains in-valid info
  890.  *****************************************************************************/
  891. BOOL mmi_ta_da_oma_install_check_hdlr(mmi_da_oma_dd_struct *dd_file)
  892. {
  893.     /*----------------------------------------------------------------*/
  894.     /* Local Variables                                                */
  895.     /*----------------------------------------------------------------*/
  896.     FLOAT theme_version;
  897.     U16 err_status;
  898.     S8 lcd_height_p[MAX_LCD_STRING_SIZE];
  899.     S8 lcd_width_p[MAX_LCD_STRING_SIZE];
  900.     memset(lcd_height_p, 0, MAX_LCD_STRING_SIZE);
  901.     memset(lcd_width_p, 0, MAX_LCD_STRING_SIZE);
  902.     /*----------------------------------------------------------------*/
  903.     /* Code Body                                                      */
  904.     /*----------------------------------------------------------------*/
  905.     /* Checking theme type compatibility */
  906.     if (!mmi_ta_check_theme_type_compatibility(dd_file->type[0]))
  907.     {
  908.         return FALSE;
  909.     }
  910. #if 0
  911. /* under construction !*/
  912. /* under construction !*/
  913. /* under construction !*/
  914. /* under construction !*/
  915. /* under construction !*/
  916. /* under construction !*/
  917. #endif
  918.     /* Checking theme type compatibility */
  919.     mmi_ta_parse_lcd_size(dd_file->installParam, (S8*) lcd_height_p, (S8*) lcd_width_p);
  920.     err_status = mmi_ta_check_theme_file_lcd_dim_compatibiltiy(
  921.                     (U32) atof((const char*)lcd_width_p),
  922.                     (U32) atof((const char*)lcd_height_p));
  923.     if (!err_status)
  924.     {
  925.         return FALSE;
  926.     }
  927.     return TRUE;
  928. }
  929. #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ // #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  930. #endif /* _MMI_THEME_ARCHIVER_C */ // #ifndef _MMI_THEME_ARCHIVER_C