📄 thememanager.c
字号:
result = mmi_tm_verify_theme_checksum(theme_file_name);
if (result == THEME_ERROR_SUCCESS)
{
theme_struct_p->theme_checksum_verified = CHECKSUM_VERIFIED_OK;
WriteRecord(
NVRAM_EF_THEME_MANAGER_LID,
1,
(void*)(g_tm_theme_list + g_tm_cntx.sys_thm_cnt),
NVRAM_EF_THEME_MANAGER_RECORD_SIZE,
&err);
}
else
{
theme_struct_p->theme_checksum_verified = CHECKSUM_VERIFIED_BAD;
WriteRecord(
NVRAM_EF_THEME_MANAGER_LID,
1,
(void*)(g_tm_theme_list + g_tm_cntx.sys_thm_cnt),
NVRAM_EF_THEME_MANAGER_RECORD_SIZE,
&err);
DRM_close_file(g_tm_cntx.theme_file_handle);
g_tm_cntx.theme_file_handle = last_theme_file_handle;
return THEME_ERROR_FILE_FORMAT_BAD;
}
}
memset(&g_tc_deviceInfo, 0, sizeof(tc_deviceinfo_struct));
memset(&g_tc_themeInfo, 0, sizeof(tc_theme_download_info_struct));
if (mmi_tm_theme_version_and_deviceinfo_check(theme_struct_p) != TRUE)
{
DRM_close_file(g_tm_cntx.theme_file_handle);
g_tm_cntx.theme_file_handle = last_theme_file_handle;
return THEME_ERROR_VERSION_FAILURE;
}
if (!mmi_ta_check_theme_file_lcd_dim_compatibiltiy(g_tc_deviceInfo.lcdwidth, g_tc_deviceInfo.lcdht))
{
DRM_close_file(g_tm_cntx.theme_file_handle);
g_tm_cntx.theme_file_handle = last_theme_file_handle;
return THEME_ERROR_LCD_SIZE_MISMATCH;
}
while (*g_tc_deviceInfo.model_ID[nmodels] && nmodels < MAX_PHONE_MODELS)
{
if (mmi_tm_check_theme_file_phone_model_compatibility((PS8) g_tc_deviceInfo.model_ID[nmodels]) == TRUE)
{
phonemodelcheck = TRUE;
break;
}
++nmodels;
}
if (!phonemodelcheck)
{
DRM_close_file(g_tm_cntx.theme_file_handle);
g_tm_cntx.theme_file_handle = last_theme_file_handle;
return THEME_ERROR_PHONE_MODEL_MISMATCH;
}
DRM_close_file(last_theme_file_handle);
g_tm_cntx.theme_has_alternate_image = FALSE;
g_tm_activated_theme.system_image_list = NULL;
g_tm_activated_theme.theme_image_details_list = g_tm_cntx.theme_image_list;
mmi_tm_reset_imageid_image_header_pool();
mmi_tm_reset_non_imageid_image_header_pool();
#ifdef __MMI_DLT_CACHE_SUPPORT__
g_tm_load_always_offset = 0;
mmi_tm_clear_ondemand_cache();
#endif /* __MMI_DLT_CACHE_SUPPORT__ */
g_tm_cntx.theme_imageid_image_count = 0;
memset(g_tm_theme_image_dirty_bits, 0, sizeof(g_tm_theme_image_dirty_bits));
g_tm_cntx.theme_has_wallpaper = FALSE;
g_tm_cntx.theme_has_screensaver = FALSE;
g_tm_cntx.theme_has_ringtone = FALSE;
if (!mmi_tc_convert_theme_file_to_mmi_theme(&(g_tm_activated_theme.theme), g_tm_cntx.theme_file_handle))
{
return THEME_ERROR_FAILURE;
}
mmi_tm_sort_theme_image_table();
set_MMI_theme(g_tm_activated_theme.theme);
MMI_apply_current_theme();
g_tm_cntx.curr_activated_theme_id = theme_struct_p->theme_id;
g_tm_cntx.curr_activated_theme_type = theme_struct_p->theme_type;
WriteValue(THEME_MANAGER_CURR_THEME_ID, (void*)&g_tm_cntx.curr_activated_theme_id, DS_DOUBLE, &err);
return THEME_ERROR_SUCCESS;
}
/*****************************************************************************
* FUNCTION
* mmi_tm_activate_theme_from_fmgr
* DESCRIPTION
* This function activates theme from file manager
* PARAMETERS
* theme_type [IN]
* theme_name_p [?]
* RETURNS
* theme error code
*****************************************************************************/
U8 mmi_tm_get_themes_for_fmgr(tm_theme_list_struct **theme_list_p, PS8 filename, tm_theme_type_enum storage_type);
tm_theme_error_enum mmi_tm_activate_theme_from_fmgr(tm_theme_type_enum theme_type, U8 *theme_name_p)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 i;
U8 found = 0;
tm_theme_error_enum result;
U32 len;
U16 filename[(MAX_THEME_NAME_LENGTH + 1)];
tm_theme_list_struct *theme_list_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if ( mmi_tm_get_usb_mode() )
{
return THEME_ERROR_USB_MODE_ON;
}
pfnUnicodeStrcpy((PS8) filename, (PS8) theme_name_p);
len = pfnUnicodeStrlen((S8*) filename);
for (i = 0; i < len; ++i)
{
if (filename[i] == 0x7E) /* tilde */
{
return THEME_ERROR_FILENAME_INCORRECT;
}
}
/* Check if theme already on the list */
for (i = g_tm_cntx.sys_thm_cnt; i < g_tm_cntx.total_thm_cnt; ++i)
{
if ((pfnUnicodeStrcmp((PS8) g_tm_theme_list[i].theme_name, (PS8) filename) == 0) &&
(g_tm_theme_list[i].theme_type == theme_type))
{
found = 1;
break;
}
}
if (found == 0)
{
/* Try to add theme to theme list */
mmi_tm_get_themes_for_fmgr(&theme_list_p, (PS8) filename, theme_type);
/* Theme still might not have been added: Check */
for (i = g_tm_cntx.sys_thm_cnt; i < g_tm_cntx.total_thm_cnt; ++i)
{
if ((pfnUnicodeStrcmp((PS8) g_tm_theme_list[i].theme_name, (PS8) filename) == 0) &&
(g_tm_theme_list[i].theme_type == theme_type))
{
found = 1;
break;
}
}
}
if (found == 0)
{
return THEME_ERROR_MAX_COUNT_REACHED;
}
else
{
if (g_tm_cntx.curr_activated_theme_id == g_tm_theme_list[i].theme_id)
{
return THEME_ERROR_ALREADY_ACTIVATED;
}
else
{
result = mmi_tm_activate_downloaded_theme(&g_tm_theme_list[i]);
}
}
if (result == THEME_ERROR_SUCCESS)
{
if (g_tm_cntx.theme_has_wallpaper)
{
ThemeManagerSetWallpaper(IMG_ID_DISPCHAR_THEME_WALLPAPER);
}
else
{
if (PhnsetIsWPCurrentTheme())
{
ThemeManagerSetWallpaper(IMG_ID_PHNSET_WP_START);
}
}
if (g_tm_cntx.theme_has_screensaver)
{
ThemeManagerSetScreensaver(IMG_ID_DISPCHAR_THEME_SCREENSAVER);
}
else
{
if (PhnsetIsScrSvrCurrentTheme())
{
ThemeManagerSetScreensaver(IMG_ID_PHNSET_SS_START);
}
}
if (g_tm_cntx.theme_has_ringtone)
{
ThemeManagerSetRingTone(CURRENT_THEME_INCOMING_CALL_TONE);
ThemeManagerSetAlarmTone(CURRENT_THEME_ALARM_EXPIRY_TONE);
}
else
{
ThemeManagerResetRingTone();
ThemeManagerResetAlarmTone();
}
if (mmi_tm_does_theme_have_alt_image())
{
initialize_status_icons();
}
}
return result;
}
/*****************************************************************************
* FUNCTION
* mmi_tm_delete_theme
* DESCRIPTION
* This function deletes the theme with the corresponding theme id
* PARAMETERS
* theme_id [IN]
* error_type [IN]
* RETURNS
* theme error code
*****************************************************************************/
tm_theme_error_enum mmi_tm_delete_theme(THEME_ID theme_id, PS32 error_type)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 i, found = 0;
S16 err;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = g_tm_cntx.sys_thm_cnt; i < g_tm_cntx.total_thm_cnt; ++i)
{
if (g_tm_theme_list[i].theme_id == theme_id)
{
found = 1;
break;
}
}
if (!found)
{
return THEME_ERROR_THEME_NOT_AVAILABLE;
}
else
{
U8 tmp_file_name[50];
U8 file_name[100];
if (g_tm_theme_list[i].theme_type == THEME_TYPE_DOWNLOADED_PHONE)
{
sprintf((PS8) tmp_file_name, "%c%s", MMI_PUBLIC_DRV, DOWNLOADED_THEMES_PATH);
AnsiiToUnicodeString((PS8) file_name, (PS8) tmp_file_name);
}
else
{
sprintf((PS8) tmp_file_name, "%c%s", MMI_CARD_DRV, DOWNLOADED_THEMES_PATH);
AnsiiToUnicodeString((PS8) file_name, (PS8) tmp_file_name);
}
pfnUnicodeStrcat((PS8) file_name, (PS8) g_tm_theme_list[i].theme_name);
if ((*error_type = FS_Delete((U16*) file_name)) == FS_NO_ERROR)
{
for (; i < g_tm_cntx.total_thm_cnt - 1; ++i)
{
memcpy((void*)&g_tm_theme_list[i], (void*)&g_tm_theme_list[i + 1], sizeof(tm_theme_list_struct));
}
memset((void*)&g_tm_theme_list[g_tm_cntx.total_thm_cnt - 1], 0, sizeof(tm_theme_list_struct));
WriteRecord(
NVRAM_EF_THEME_MANAGER_LID,
1,
(void*)(g_tm_theme_list + g_tm_cntx.sys_thm_cnt),
NVRAM_EF_THEME_MANAGER_RECORD_SIZE,
&err);
--g_tm_cntx.total_thm_cnt;
return THEME_ERROR_SUCCESS;
}
else
{
return THEME_ERROR_FAILURE;
}
}
}
/*****************************************************************************
* FUNCTION
* mmi_tm_delete_theme_from_fmgr
* DESCRIPTION
* This function deletes theme with the corresponding theme name from file manager
* PARAMETERS
* theme_type [IN]
* theme_name_p [?]
* error_type [IN]
* RETURNS
* theme error code
*****************************************************************************/
tm_theme_error_enum mmi_tm_delete_theme_from_fmgr(tm_theme_type_enum theme_type, U8 *theme_name_p, PS32 error_type)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 i, found = 0;
U8 tmp_file_name[50];
U8 file_name[100];
S16 err;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = g_tm_cntx.sys_thm_cnt; i < g_tm_cntx.total_thm_cnt; ++i)
{
if (!pfnUnicodeStrcmp((PS8) g_tm_theme_list[i].theme_name, (PS8) theme_name_p) &&
(g_tm_theme_list[i].theme_type == theme_type))
{
found = 1;
break;
}
}
if (theme_type == THEME_TYPE_DOWNLOADED_PHONE)
{
sprintf((PS8) tmp_file_name, "%c%s", MMI_PUBLIC_DRV, DOWNLOADED_THEMES_PATH);
AnsiiToUnicodeString((PS8) file_name, (PS8) tmp_file_name);
}
else
{
sprintf((PS8) tmp_file_name, "%c%s", MMI_CARD_DRV, DOWNLOADED_THEMES_PATH);
AnsiiToUnicodeString((PS8) file_name, (PS8) tmp_file_name);
}
pfnUnicodeStrcat((PS8) file_name, (PS8) theme_name_p);
if (found)
{
if (g_tm_theme_list[i].theme_id == g_tm_cntx.curr_activated_theme_id)
{
return THEME_ERROR_ALREADY_ACTIVATED;
}
if ((*error_type = FS_Delete((U16*) file_name)) == FS_NO_ERROR)
{
for (; i < g_tm_cntx.total_thm_cnt - 1; ++i)
{
memcpy((void*)&g_tm_theme_list[i], (void*)&g_tm_theme_list[i + 1], sizeof(tm_theme_list_struct));
}
memset((void*)&g_tm_theme_list[g_tm_cntx.total_thm_cnt - 1], 0, sizeof(tm_theme_list_struct));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -