📄 thememanager.c
字号:
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
mmi_tm_reset_image_header_pool(&(g_tm_cntx.imageid_images_headers));
memset(&g_tm_cntx.image_cache, 0xFF, sizeof(g_tm_cntx.image_cache));
}
/*****************************************************************************
* FUNCTION
* mmi_tm_reset_non_imageid_image_header_pool
* DESCRIPTION
* this function resets the image header pool buffer for images without IDs
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_tm_reset_non_imageid_image_header_pool(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
mmi_tm_reset_image_header_pool(&(g_tm_cntx.non_imageid_images_headers));
}
/*****************************************************************************
* FUNCTION
* mmi_tm_reset_image_header_pool
* DESCRIPTION
* this function resets the image header pool buffer
* PARAMETERS
* ds_p [?]
* RETURNS
* void
*****************************************************************************/
void mmi_tm_reset_image_header_pool(tm_theme_image_header_struct *ds_p)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ds_p->current_offset = 0;
}
/*****************************************************************************
* FUNCTION
* mmi_tm_add_image_header_to_pool
* DESCRIPTION
* this function adds image header to pool buffer
* PARAMETERS
* ds_p [?]
* buff [?]
* RETURNS
* void
*****************************************************************************/
void *mmi_tm_add_image_header_to_pool(tm_theme_image_header_struct *ds_p, void *buff)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
void *temp_ptr;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if ((ds_p->current_offset + ds_p->unit_size) > ds_p->total_pool_size)
{
return NULL;
}
else
{
memcpy((ds_p->mempool_p + ds_p->current_offset), buff, ds_p->unit_size);
temp_ptr = ds_p->mempool_p + ds_p->current_offset;
ds_p->current_offset += ds_p->unit_size;
return temp_ptr;
}
}
/*****************************************************************************
* FUNCTION
* mmi_tm_get_downloaded_theme_image
* DESCRIPTION
* It returns downloadable theme image pointer
* PARAMETERS
* image_offset [IN]
* nArrIndex [IN]
* RETURNS
* void
*****************************************************************************/
void *mmi_tm_get_downloaded_theme_image(U32 image_offset, S32 nArrIndex)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 size;
void *image_p;
U8 buff[MAX_THEME_IMAGE_HEADER_LENGTH] = {0};
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (FS_ParseFH(g_tm_cntx.theme_file_handle) >= 0)
{
if (g_tm_cntx.image_cache[nArrIndex].nOffset != -1)
{
return (void*)((S8*) g_tm_cntx.imageid_images_headers.mempool_p +
g_tm_cntx.image_cache[nArrIndex].nOffset);
}
if (DRM_seek_file(g_tm_cntx.theme_file_handle, image_offset, FS_FILE_BEGIN) >= 0 )
{
if (DRM_read_file(g_tm_cntx.theme_file_handle, buff, THEME_IMAGE_INFO_HEADER, (U32*) & size) !=
FS_NO_ERROR)
{
mmi_tm_handle_file_access_failed();
return NULL;
}
}
else
{
mmi_tm_handle_file_access_failed();
return NULL;
}
/* offset in next 4 bytes */
buff[8] = (U8) (image_offset & 0x000000ff);
buff[9] = (U8) ((image_offset >> 8) & 0x000000ff);
buff[10] = (U8) ((image_offset >> 16) & 0x000000ff);
buff[11] = (U8) ((image_offset >> 24) & 0x000000ff);
/* file handle in next 4 bytes */
buff[12] = (U8) (g_tm_cntx.theme_file_handle & 0x000000ff);
buff[13] = (U8) ((g_tm_cntx.theme_file_handle >> 8) & 0x000000ff);
buff[14] = (U8) ((g_tm_cntx.theme_file_handle >> 16) & 0x000000ff);
buff[15] = (U8) ((g_tm_cntx.theme_file_handle >> 24) & 0x000000ff);
image_p = mmi_tm_add_image_header_to_pool(&(g_tm_cntx.imageid_images_headers), buff);
if (image_p)
{
g_tm_cntx.image_cache[nArrIndex].nOffset =
(U16) ((S8*) image_p - (S8*) g_tm_cntx.imageid_images_headers.mempool_p);
return image_p;
}
}
return GetDefaultImage();
}
/*****************************************************************************
* FUNCTION
* mmi_tm_check_theme_file_phone_model_compatibility
* DESCRIPTION
* validates Theme Phone Model.
* PARAMETERS
* theme_phone_model [IN]
* RETURNS
* true if compatible otherwise false
*****************************************************************************/
U16 mmi_tm_check_theme_file_phone_model_compatibility(PS8 theme_phone_model)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (strncmp(theme_phone_model, mmi_get_phone_model(), MAX_MODEL_ID_LEN))
{
return FALSE;
}
else
{
return TRUE;
}
}
/*****************************************************************************
* FUNCTION
* mmi_tm_theme_version_and_deviceinfo_check
* DESCRIPTION
* It checks theme version and deviceinfo in DLT file(.med)
* PARAMETERS
* theme_struct_p [?]
* RETURNS
* true : if successfully checks,
* false : if unable to check
*****************************************************************************/
BOOL mmi_tm_theme_version_and_deviceinfo_check(tm_theme_list_struct *theme_struct_p)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 theme_file_name[(MAX_DWNL_THM_PATH_LEN + MAX_THEME_NAME_LENGTH) * ENCODING_LENGTH] = {0};
U8 tmp_path[50] = {0};
FS_HANDLE tmp_theme_file_handle;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
g_tm_checkThemeVersion = TRUE;
if (theme_struct_p->theme_type == THEME_TYPE_DOWNLOADED_PHONE)
{
sprintf((PS8) tmp_path, "%c%s", MMI_PUBLIC_DRV, DOWNLOADED_THEMES_PATH);
AnsiiToUnicodeString((PS8) theme_file_name, (PS8) tmp_path);
}
else
{
sprintf((PS8) tmp_path, "%c%s", MMI_CARD_DRV, DOWNLOADED_THEMES_PATH);
AnsiiToUnicodeString((PS8) theme_file_name, (PS8) tmp_path);
}
pfnUnicodeStrcat((PS8) theme_file_name, (PS8) theme_struct_p->theme_name);
// last_theme_file_handle = g_tm_cntx.theme_file_handle;
//tmp_theme_file_handle = DRM_open_file((U16*)theme_file_name, FS_READ_ONLY, 0/*DRM_PERMISSION_NONE*/);
tmp_theme_file_handle = DRM_open_file((U16*) theme_file_name, FS_READ_ONLY | FS_OPEN_SHARED, 0);
if (tmp_theme_file_handle < FS_NO_ERROR)
{
return FALSE;
}
if (xml_new_parser(&g_tc_parser) == -1)
{
return FALSE;
}
xml_register_element_handler(&g_tc_parser, mmi_tc_my_xml_elem_start_hdlr, mmi_tc_my_xml_elem_end_hdlr);
/* PMT DLT_FIXES - TK 20060321 START */
g_tc_parser.pos = THEME_FILE_SIZE_HEADER + THEME_CHECKSUM_HEADER_SIZE;
/* PMT DLT_FIXES - TK 20060321 END */
xml_parse_file_from_offset(&g_tc_parser, tmp_theme_file_handle);
DRM_close_file(tmp_theme_file_handle);
g_tm_checkThemeVersion = FALSE;
if (mmi_ta_check_theme_file_version_compatibility((FLOAT) g_tc_themeInfo.version))
{
return TRUE;
}
return FALSE;
}
#ifdef __MMI_DLT_CACHE_SUPPORT__
/*****************************************************************************
* FUNCTION
* mmi_tm_clear_ondemand_cache
* DESCRIPTION
* clears the ondemand cache by clearing pointer and making offset as zero
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_tm_clear_ondemand_cache(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U32 count = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
while (g_tm_load_ondemand_offset && count < g_tm_cntx.theme_imageid_image_count)
{
if (g_tm_cntx.theme_image_list[count].image_type == THEME_IMG_LOAD_ONDEMAND)
{
g_tm_cntx.theme_image_list[count].image_cache_ptr = NULL;
}
++count;
}
g_tm_load_ondemand_offset = 0;
}
/*****************************************************************************
* FUNCTION
* mmi_tm_get_image_load_type
* DESCRIPTION
* To determine the load type of an image
* PARAMETERS
* img_list_index [IN]
* RETURNS
*
*****************************************************************************/
tm_image_load_type_enum mmi_tm_get_image_load_type(U32 img_list_index)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return g_tm_cntx.theme_image_list[img_list_index].image_type;
}
/*****************************************************************************
* FUNCTION
* mmi_tm_find_img_in_cache
* DESCRIPTION
* returns image pointer
* PARAMETERS
* img_list_index [IN]
* type [IN]
* RETURNS
*
*****************************************************************************/
PU8 mmi_tm_find_img_in_cache(U32 img_list_index, tm_image_load_type_enum type)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return g_tm_cntx.theme_image_list[img_list_index].image_cache_ptr;
}
/*****************************************************************************
* FUNCTION
* mmi_tm_add_to_DLT_img_cache
* DESCRIPTION
* add an image to image cache
* PARAMETERS
* image_offset [IN]
* img_load_type [IN]
* RETURNS
*
*****************************************************************************/
PU8 mmi_tm_add_to_DLT_img_cache(U32 image_offset, tm_image_load_type_enum img_load_type)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 size;
U32 fp;
U8 buff[MAX_THEME_IMAGE_HEADER_LENGTH] = {0};
S32 image_file_size;
S32 dlt_img_cache_size;
PU8 image_buff;
PU32 cache_offset;
PU8 cache_ptr;
PU8 p_img_ret=NULL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -