EbookFramework.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:303k
源码类别:
MTK
开发平台:
C/C++
- * img_buff_p [IN]
- * str_img_mask [IN]
- * RETURNS
- * void
- *****************************************************************************/
- pBOOL ebr_get_book_mark_name_list(S32 item_index, UI_string_type str_buff, PU8 *img_buff_p, U8 str_img_mask)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy(
- (S8*) str_buff,
- (S8*) g_curr_book_cntx_p->g_nfo_book_struct.book_marks[item_index].bookmark_name);
- *img_buff_p = get_image(gIndexIconsImageList[item_index]);
- return TRUE;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_count_of_book_marks
- * DESCRIPTION
- * Count the number of book marks present
- * PARAMETERS
- * void
- * RETURNS
- * S16
- *****************************************************************************/
- S16 ebr_frm_get_count_of_book_marks(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 no_of_book_marks = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (g_curr_book_cntx_p->g_nfo_book_struct.book_marks[no_of_book_marks].bookmark_name[0] != 0 && (no_of_book_marks<EBR_FRM_MAX_NO_OF_BOOKMARKS))
- {
- no_of_book_marks++;
- }
- return no_of_book_marks;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_full_screen_flag_status
- * DESCRIPTION
- * Get the status of full screen flag
- * PARAMETERS
- * void
- * RETURNS
- * S16
- *****************************************************************************/
- S16 ebr_frm_get_full_screen_flag_status(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->g_nfo_book_struct.settings.screen_mode == 0)
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_auto_scroll_flag_status
- * DESCRIPTION
- * Get the status of full screen flag
- * PARAMETERS
- * void
- * RETURNS
- * S16
- *****************************************************************************/
- S16 ebr_frm_get_auto_scroll_flag_status(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_flag == 0)
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_create_new_file_path
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_create_new_file_path(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(g_curr_book_cntx_p->fmgr_file_path, 0, sizeof(g_curr_book_cntx_p->fmgr_file_path));
- pfnUnicodeStrcpy(
- (S8*) g_curr_book_cntx_p->fmgr_file_path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_DEFAULT));
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_is_book_shelf_path
- * DESCRIPTION
- * Check whetther the path is for bookshelf
- * PARAMETERS
- * path [IN]
- * RETURNS
- * S32
- *****************************************************************************/
- S32 ebr_fmgr_is_book_shelf_path(PS8 path)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 nfo_path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH] = {0};
- U32 driveCount = 0;
- S8 driveLatter[FMGR_TOTAL_STORAGE];
- U8 driveNum;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(driveLatter, 0, FMGR_TOTAL_STORAGE);
- mmi_fmgr_get_exist_drive_letter(driveLatter, &driveNum);
- while (driveLatter[driveCount] != 0)
- {
- pfnUnicodeStrcpy((S8*) nfo_path, (S8*) ebr_frm_get_file_path(driveLatter[driveCount], EBR_FRM_SEARCH_DEFAULT));
- ebr_frm_convert_to_upper((S16*) nfo_path);
- ebr_frm_convert_to_upper((S16*) path);
- if (!pfnUnicodeStrcmp((S8*) nfo_path, (S8*) path))
- {
- g_curr_book_cntx_p->memory_type_selected = driveLatter[driveCount];
- return driveLatter[driveCount];
- }
- driveCount++;
- }
- return -1;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_get_file_name
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- S8 *ebr_fmgr_get_file_name(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return (S8*) g_curr_book_cntx_p->book_name_path;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_set_file_type
- * DESCRIPTION
- * Set the file type
- * PARAMETERS
- * file_name [IN]
- * type [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_fmgr_set_file_type(S8 *file_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 strlen_file_name = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- strlen_file_name = pfnUnicodeStrlen((const S8*)file_name);
- if ((g_curr_book_cntx_p->nfo_name[strlen_file_name * 2 - 6] == 't') ||
- (g_curr_book_cntx_p->nfo_name[strlen_file_name * 2 - 6] == 'T'))
- {
- g_curr_book_cntx_p->g_fmgr_book_type = EBR_FRM_FILE_TYPE_TXT;
- }
- else
- {
- g_curr_book_cntx_p->g_fmgr_book_type = EBR_FRM_FILE_TYPE_PDB;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_set_file_name
- * DESCRIPTION
- * Sets the File name for File manager
- * PARAMETERS
- * fmgr_file_name [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_fmgr_set_file_name(PS8 fmgr_file_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((S8*) g_curr_book_cntx_p->book_name_path, (S8*) fmgr_file_name);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_set_selected_file_name
- * DESCRIPTION
- * Gets the name of the selected book
- * PARAMETERS
- * file_info [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_set_selected_file_name(FMGR_FILE_INFO_STRUCT *file_info)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 tmp_path_buf[(FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (file_info->is_short)
- {
- memset(tmp_path_buf, 0, (FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- mmi_chset_mixed_text_to_ucs2_str(
- (U8*) tmp_path_buf,
- (FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH,
- (U8*) file_info->file_name,
- g_chset_text_encoding);
- pfnUnicodeStrcpy((S8*) g_curr_book_cntx_p->nfo_name, (S8*) tmp_path_buf);
- }
- else
- {
- pfnUnicodeStrcpy((S8*) g_curr_book_cntx_p->nfo_name, (S8*) file_info->file_name);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_get_selected_file_name
- * DESCRIPTION
- * Gets the name of the selected book
- * PARAMETERS
- * void
- * RETURNS
- * S8*
- *****************************************************************************/
- U8 *ebr_get_selected_file_name(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return (U8*) g_curr_book_cntx_p->nfo_name;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_book_size
- * DESCRIPTION
- * Gets the Size of the ebook
- * PARAMETERS
- * void
- * RETURNS
- * S8*
- *****************************************************************************/
- S32 ebr_frm_get_book_size(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE file_hnd;
- U32 file_size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ebr_frm_create_book_path();
- file_hnd = FS_Open((const WCHAR*)g_curr_book_cntx_p->book_name_path, FS_READ_ONLY);
- FS_GetFileSize(file_hnd, (U32*) & file_size);
- FS_Close(file_hnd);
- return file_size;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_create_book_path
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_create_book_path(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy(
- (S8*) g_curr_book_cntx_p->book_name_path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((PS8) g_curr_book_cntx_p->book_name_path, (PS8) g_curr_book_cntx_p->nfo_name);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_book_name
- * DESCRIPTION
- * Gets the Name of the Ebook
- * PARAMETERS
- * void
- * RETURNS
- * S8*
- *****************************************************************************/
- S8 *ebr_frm_get_book_name(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return (S8*) g_curr_book_cntx_p->nfo_name;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_restore_default_book_shelf_settings
- * DESCRIPTION
- * Restores the default settings for Book shelf
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- S32 ebr_frm_restore_default_book_shelf_settings(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- ebr_frm_setting_struct g_setting;
- ebr_frm_setting_struct *g_setting_list = &g_setting;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- #ifndef MMI_ON_HARDWARE_P
- if (g_setting_list->common_settings.encoding_format == 0xff)
- {
- g_setting_list->common_settings.encoding_format = EBOOK_WESTERN_WINDOWS;
- g_setting_list->common_settings.font_size = EBR_FONT_SIZE_MEDIUM;
- g_setting_list->common_settings.font_style = EBR_FONT_STYLE_NORMAL;
- g_setting_list->memory_type = (S8)MMI_PUBLIC_DRV;
- g_setting_list->common_settings.screen_mode = EBR_FULL_SCREEN_OFF;
- g_setting_list->common_settings.auto_scroll_settings.scroll_flag = EBR_SCROLL_OFF;
- g_setting_list->common_settings.auto_scroll_settings.scroll_speed = EBR_AUTO_SCROLL_SPEED_1;
- g_setting_list->common_settings.auto_scroll_settings.scroll_type = EBR_SCROLL_BY_PAGE;
- }
- WriteRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- #endif /* MMI_ON_HARDWARE_P */
- /* ebr_app_display_pop_up_default_settings_restored(); */
- ebr_frm_restore_default_settings_for_each_book(g_setting_list);
- return 1;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_restore_default_nvram
- * DESCRIPTION
- * Restores Factory Default
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_restore_default_nvram(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- ebr_frm_setting_struct g_setting;
- ebr_frm_setting_struct *g_setting_list = &g_setting;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- g_setting_list->common_settings.encoding_format = EBOOK_WESTERN_WINDOWS;
- g_setting_list->common_settings.font_size = EBR_FONT_SIZE_MEDIUM;
- g_setting_list->common_settings.font_style = EBR_FONT_STYLE_NORMAL;
- g_setting_list->memory_type = (S8)MMI_PUBLIC_DRV;
- g_setting_list->common_settings.screen_mode = EBR_FULL_SCREEN_OFF;
- g_setting_list->common_settings.auto_scroll_settings.scroll_flag = EBR_SCROLL_OFF;
- g_setting_list->common_settings.auto_scroll_settings.scroll_speed = EBR_AUTO_SCROLL_SPEED_1;
- g_setting_list->common_settings.auto_scroll_settings.scroll_type = EBR_SCROLL_BY_PAGE;
- WriteRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_restore_default_settings_for_each_book
- * DESCRIPTION
- * Restores the default settings for Book shelf
- * PARAMETERS
- * g_setting_list [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_restore_default_settings_for_each_book(ebr_frm_setting_struct *g_setting_list)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FS_HANDLE fh_cur;
- FS_DOSDirEntry file_info;
- S8 path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH];
- U8 filename[MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH];
- U32 driveCount = 0;
- S8 driveLatter[FMGR_TOTAL_STORAGE];
- U8 driveNum;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(driveLatter, 0, FMGR_TOTAL_STORAGE);
- mmi_fmgr_get_exist_drive_letter(driveLatter, &driveNum);
- while (driveLatter[driveCount] != 0)
- {
- g_curr_book_cntx_p->memory_type_selected = driveLatter[driveCount];
- pfnUnicodeStrcpy(
- (S8*) path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_NFO));
- if ((fh_cur = FS_FindFirst(
- (const WCHAR*)path,
- 0,
- 0,
- &file_info,
- (U16*) filename,
- MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH)) >= 0)
- {
- do
- {
- if (!(file_info.Attributes & FS_ATTR_DIR))
- {
- ebr_frm_open_nfo_file_and_restore_default(
- g_curr_book_cntx_p->memory_type_selected,
- filename,
- g_setting_list);
- }
- } while ((FS_FindNext(fh_cur, &file_info, (U16*) filename, MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH) ==
- FS_NO_ERROR));
- FS_FindClose(fh_cur);
- }
- driveCount++;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_open_nfo_file_and_restore_default
- * DESCRIPTION
- * Restores the default settings for each book
- * PARAMETERS
- * memory_type_selected [IN]
- * filename [IN]
- * g_setting_list [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_open_nfo_file_and_restore_default(
- S32 memory_type_selected,
- U8 *filename,
- ebr_frm_setting_struct *g_setting_list)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE nfo_hnd;
- S8 path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH];
- U32 size;
- S32 retval;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((S8*) path, (S8*) ebr_frm_get_file_path(memory_type_selected, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((S8*) path, (S8*) filename);
- nfo_hnd = FS_Open((const WCHAR*)path, FS_READ_WRITE);
- if (nfo_hnd > 0)
- {
- FS_Read(nfo_hnd, &g_curr_book_cntx_p->g_nfo_book_struct, sizeof(g_curr_book_cntx_p->g_nfo_book_struct), &size);
- g_curr_book_cntx_p->g_nfo_book_struct.settings.font_size = g_setting_list->common_settings.font_size;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.font_style = g_setting_list->common_settings.font_style;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.screen_mode = g_setting_list->common_settings.screen_mode;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.encoding_format =
- g_setting_list->common_settings.encoding_format;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_flag =
- g_setting_list->common_settings.auto_scroll_settings.scroll_flag;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_speed =
- g_setting_list->common_settings.auto_scroll_settings.scroll_speed;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_type =
- g_setting_list->common_settings.auto_scroll_settings.scroll_type;
- FS_Seek(nfo_hnd, 0, FS_FILE_BEGIN);
- retval = FS_Write(
- nfo_hnd,
- &g_curr_book_cntx_p->g_nfo_book_struct,
- sizeof(g_curr_book_cntx_p->g_nfo_book_struct),
- &size);
- FS_Close(nfo_hnd);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_delete_all_from_book_shelf
- * DESCRIPTION
- * Delete all books from Book Shelf
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_delete_all_from_book_shelf(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FS_HANDLE fh_cur;
- FS_DOSDirEntry file_info;
- S8 path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH];
- S8 ebook_path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH];
- WCHAR filename[MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH];
- S16 retval;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy(
- (S8*) path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_NFO));
- if ((fh_cur = FS_FindFirst(
- (const WCHAR*)path,
- 0,
- 0,
- &file_info,
- (U16*) filename,
- MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH)) >= 0)
- {
- do
- {
- if (!(file_info.Attributes & FS_ATTR_DIR))
- {
- pfnUnicodeStrcpy(
- (S8*) ebook_path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((S8*) ebook_path, (S8*) filename);
- retval = FS_Delete((const WCHAR*)ebook_path);
- }
- } while ((FS_FindNext(fh_cur, &file_info, (U16*) filename, MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH) ==
- FS_NO_ERROR));
- FS_FindClose(fh_cur);
- }
- pfnUnicodeStrcpy(
- (S8*) path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_PDB));
- if ((fh_cur = FS_FindFirst(
- (const WCHAR*)path,
- 0,
- 0,
- &file_info,
- (U16*) filename,
- MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH)) >= 0)
- {
- do
- {
- if (!(file_info.Attributes & FS_ATTR_DIR))
- {
- pfnUnicodeStrcpy(
- (S8*) ebook_path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((S8*) ebook_path, (S8*) filename);
- retval = FS_Delete((const WCHAR*)ebook_path);
- }
- } while ((FS_FindNext(fh_cur, &file_info, (U16*) filename, MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH) ==
- FS_NO_ERROR));
- FS_FindClose(fh_cur);
- }
- pfnUnicodeStrcpy(
- (S8*) path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_TXT));
- if ((fh_cur = FS_FindFirst(
- (const WCHAR*)path,
- 0,
- 0,
- &file_info,
- (U16*) filename,
- MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH)) >= 0)
- {
- do
- {
- if (!(file_info.Attributes & FS_ATTR_DIR))
- {
- pfnUnicodeStrcpy(
- (S8*) ebook_path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((S8*) ebook_path, (S8*) filename);
- retval = FS_Delete((const WCHAR*)ebook_path);
- }
- } while ((FS_FindNext(fh_cur, &file_info, (U16*) filename, MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH) ==
- FS_NO_ERROR));
- FS_FindClose(fh_cur);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_restore_default_book_settings
- * DESCRIPTION
- * Restore default settings for Book
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- S32 ebr_frm_restore_default_book_settings(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- S16 retval;
- U32 size;
- FILE_HANDLE nfo_hnd_local;
- ebr_frm_setting_struct g_setting;
- ebr_frm_setting_struct *g_setting_list = &g_setting;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nfo_hnd_local = ebr_frm_get_nfo_handle();
- if (nfo_hnd_local <= 0)
- {
- FS_Close(nfo_hnd_local);
- return 0;
- }
- ReadRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- g_curr_book_cntx_p->g_nfo_book_struct.settings = g_setting_list->common_settings;
- FS_Seek(nfo_hnd_local, 0, FS_FILE_BEGIN);
- retval = FS_Write(
- nfo_hnd_local,
- &g_curr_book_cntx_p->g_nfo_book_struct,
- sizeof(g_curr_book_cntx_p->g_nfo_book_struct),
- &size);
- FS_Close(nfo_hnd_local);
- return !retval;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_memory_type_selected
- * DESCRIPTION
- * Get memory type selected
- * PARAMETERS
- * void
- * RETURNS
- * ebr_memory_type_enum
- *****************************************************************************/
- ebr_memory_type_enum ebr_frm_get_memory_type_selected(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- ebr_frm_setting_struct g_setting;
- ebr_frm_setting_struct *g_setting_list = &g_setting;
- S16 error;
- MMI_BOOL status;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- g_curr_book_cntx_p->memory_type_selected = g_setting_list->memory_type;
- status = mmi_fmgr_is_drive_letter_valid(g_curr_book_cntx_p->memory_type_selected);
- if (status && FS_GetDevStatus(g_curr_book_cntx_p->memory_type_selected, FS_MOUNT_STATE_ENUM) == FS_NO_ERROR)
- {
- return g_curr_book_cntx_p->memory_type_selected;
- }
- else
- {
- g_setting_list->memory_type = MMI_PUBLIC_DRV;
- WriteRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- }
- g_curr_book_cntx_p->memory_type_selected = g_setting_list->memory_type;
- return g_curr_book_cntx_p->memory_type_selected;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_fmgr_get_nfo_handle
- * DESCRIPTION
- * Get nfo handle for File manager
- * PARAMETERS
- * file_name [IN]
- * RETURNS
- * FILE_HANDLE
- *****************************************************************************/
- FILE_HANDLE ebr_frm_fmgr_get_nfo_handle(S8 *file_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 nfo_path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH] = {0};
- FILE_HANDLE nfo_hnd;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy(
- (S8*) nfo_path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((S8*) nfo_path, (S8*) file_name);
- nfo_hnd = FS_Open((const WCHAR*)nfo_path, FS_READ_WRITE);
- return nfo_hnd;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_write_default_value_for_nfo_id_in_nvram
- * DESCRIPTION
- * Write default value for NFO in NVRAM
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_write_default_value_for_nfo_id_in_nvram(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 local_nfo_id = 0;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- WriteValue(NVRAM_EBOOK_NFO_LID, (void*)&local_nfo_id, DS_SHORT, &error);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_get_file_name_call_back
- * DESCRIPTION
- * Get the file name
- * PARAMETERS
- * fmgr_file_name [IN]
- * file_name [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_fmgr_get_file_name_call_back(S8 *fmgr_file_name, S8 *file_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 nfo_path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH];
- ebr_frm_book_struct nfo_struct;
- U32 size;
- FILE_HANDLE nfo_hnd;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->memory_type_selected = ebr_get_drive_type();
- pfnUnicodeStrcpy(
- (S8*) nfo_path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((S8*) nfo_path, fmgr_file_name);
- nfo_hnd = FS_Open((const WCHAR*)nfo_path, FS_READ_ONLY);
- if (nfo_hnd > 0)
- {
- FS_Seek(nfo_hnd, 0, FS_FILE_BEGIN);
- FS_Read(nfo_hnd, &nfo_struct, sizeof(ebr_frm_book_struct), &size);
- }
- FS_Close(nfo_hnd);
- pfnUnicodeStrcpy((S8*) file_name, (S8*) nfo_struct.e_book_name);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_get_display_name_call_back
- * DESCRIPTION
- * Get the display file name
- * PARAMETERS
- * fmgr_file_name [IN]
- * book_type [IN]
- * file_name [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_fmgr_get_display_name_call_back(S8 *fmgr_file_name, ebr_frm_filetype_enum book_type, S8 *file_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 nfo_path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH];
- FILE_HANDLE file_hnd;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->memory_type_selected = ebr_get_drive_type();
- pfnUnicodeStrcpy(
- (S8*) nfo_path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((S8*) nfo_path, fmgr_file_name);
- file_hnd = FS_Open((const WCHAR*)nfo_path, FS_READ_ONLY);
- if (book_type == EBR_FRM_FILE_TYPE_PDB)
- {
- pfnUnicodeStrncpy((S8*) file_name, (S8*) fmgr_file_name, pfnUnicodeStrlen((const S8*)fmgr_file_name) - 4);
- }
- else
- {
- pfnUnicodeStrncpy((S8*) file_name, (S8*) fmgr_file_name, pfnUnicodeStrlen((const S8*)fmgr_file_name) - 4);
- }
- FS_Close(file_hnd);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_get_file_size_and_name
- * DESCRIPTION
- * Get the file name and size
- * PARAMETERS
- * fmgr_file_name [IN]
- * RETURNS
- * FILE_HANDLE
- *****************************************************************************/
- S8 *ebr_fmgr_get_file_size_and_name(S8 *fmgr_file_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE nfo_hnd;
- ebr_frm_book_struct book_struct;
- U32 size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nfo_hnd = ebr_frm_fmgr_get_nfo_handle(fmgr_file_name);
- FS_Read(nfo_hnd, &book_struct, sizeof(ebr_frm_book_struct), &size);
- FS_Close(nfo_hnd);
- return (S8*) book_struct.e_book_name;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_get_file_size
- * DESCRIPTION
- * Get the file size
- * PARAMETERS
- * fmgr_file_name [IN]
- * RETURNS
- * FILE_HANDLE
- *****************************************************************************/
- U32 ebr_fmgr_get_file_size(S8 *fmgr_file_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE file_hnd;
- U8 file_path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH];
- U32 size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy(
- (S8*) file_path,
- (S8*) (ebr_frm_get_file_path(ebr_frm_get_memory_type_selected(), EBR_FRM_SEARCH_DEFAULT)));
- pfnUnicodeStrcat((S8*) file_path, (const S8*)fmgr_file_name);
- file_hnd = FS_Open((const WCHAR*)file_path, FS_READ_ONLY);
- FS_GetFileSize(file_hnd, &size);
- FS_Close(file_hnd);
- return size;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_fmgr_pre_entry_open_book
- * DESCRIPTION
- * Pre entry function for Open book
- * PARAMETERS
- * file_name [IN]
- * file_path [IN]
- * file_ext [IN]
- * RETURNS
- * FILE_HANDLE
- *****************************************************************************/
- S32 ebr_frm_fmgr_pre_entry_open_book(S8 *file_name, S8 *file_path, S8 *file_ext)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 file_extension_name[FMGR_MAX_FILE_LEN * ENCODING_LENGTH];
- S8 file_extension_name_ansii[FMGR_MAX_FILE_LEN * ENCODING_LENGTH];
- S32 nfo_id;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcat((S8*) file_path, (S8*) file_name);
- pfnUnicodeStrcpy((S8*) file_extension_name, (S8*) file_ext);
- ebr_frm_convert_to_upper((S16*) file_extension_name);
- UnicodeToAnsii((S8*) file_extension_name_ansii, (S8*) file_extension_name);
- if (mmi_fmgr_is_drive_letter_valid(g_curr_book_cntx_p->memory_type_selected))
- {
- if (!strcmp(file_extension_name_ansii, EBR_FILE_TYPE_TXT))
- {
- g_curr_book_cntx_p->g_fmgr_book_type = EBR_FRM_FILE_TYPE_TXT;
- nfo_id = ebr_fmgr_get_nfo_id_for_txt_file(g_curr_book_cntx_p->memory_type_selected, file_name);
- return nfo_id;
- }
- else
- {
- g_curr_book_cntx_p->g_fmgr_book_type = EBR_FRM_FILE_TYPE_PDB;
- nfo_id = ebr_fmgr_get_nfo_id_for_pdb_file(g_curr_book_cntx_p->memory_type_selected, file_name);
- return nfo_id;
- }
- }
- else
- {
- if (!strcmp(file_extension_name_ansii, EBR_FILE_TYPE_TXT))
- {
- g_curr_book_cntx_p->g_fmgr_book_type = EBR_FRM_FILE_TYPE_TXT;
- }
- else
- {
- g_curr_book_cntx_p->g_fmgr_book_type = EBR_FRM_FILE_TYPE_PDB;
- }
- return -1;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_check_is_ebook_folder_created
- * DESCRIPTION
- * Is Ebook Folder created
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_check_is_ebook_folder_created(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 tmp_str[MAX_DWNL_EBK_PATH_LEN];
- S8 ebook_folder_path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- sprintf(tmp_str, "%c%s", MMI_CARD_DRV, EBR_DOWNLOADED_EBOOK_PATH);
- AnsiiToUnicodeString((S8*) ebook_folder_path, (S8*) tmp_str);
- FS_CreateDir((PU16) ebook_folder_path);
- sprintf(tmp_str, "%c%s", MMI_PUBLIC_DRV, EBR_DOWNLOADED_EBOOK_PATH);
- AnsiiToUnicodeString((S8*) ebook_folder_path, (S8*) tmp_str);
- FS_CreateDir((PU16) ebook_folder_path);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_init
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_init(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->state_recursive_conversion = EBR_FRM_NO_CONVERSION;
- ebr_frm_check_is_ebook_folder_created();
- ebr_frm_get_memory_type_selected();
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_drive_type
- * DESCRIPTION
- * Get drive type
- * PARAMETERS
- * void
- * RETURNS
- * FILE_HANDLE
- *****************************************************************************/
- ebr_memory_type_enum ebr_frm_get_drive_type(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- ebr_frm_setting_struct g_setting;
- ebr_frm_setting_struct *g_setting_list = &g_setting;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- return g_setting_list->memory_type;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_change_drive_type
- * DESCRIPTION
- * Change the drive type and write in NVRAM
- * PARAMETERS
- * void
- * RETURNS
- * FILE_HANDLE
- *****************************************************************************/
- S16 ebr_frm_change_drive_type(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- ebr_frm_setting_struct g_setting;
- ebr_frm_setting_struct *g_setting_list = &g_setting;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_setting_list->memory_type = (U8) g_curr_book_cntx_p->memory_type_selected;
- WriteRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- return error;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_drive_status
- * DESCRIPTION
- * Get drive status
- * PARAMETERS
- * void
- * RETURNS
- * FILE_HANDLE
- *****************************************************************************/
- int ebr_frm_get_drive_status(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- int drive, status;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- drive = FS_GetDrive(FS_DRIVE_V_REMOVABLE, 1, FS_NO_ALT_DRIVE);
- status = FS_GetDevStatus(drive, FS_MOUNT_STATE_ENUM);
- return status;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_paging_reset_auto_scroll
- * DESCRIPTION
- * Reset auto scroll
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void gui_paging_reset_auto_scroll(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE nfo_hnd;
- U32 size;
- int retval;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nfo_hnd = FS_Open((const WCHAR*)g_curr_book_cntx_p->nfo_path, FS_READ_WRITE);
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_flag = 0;
- FS_Seek(nfo_hnd, 0, FS_FILE_BEGIN);
- retval = FS_Write(nfo_hnd, &g_curr_book_cntx_p->g_nfo_book_struct, sizeof(g_curr_book_cntx_p->g_nfo_book_struct), &size);
- retval = FS_Close(nfo_hnd);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_auto_scroll_status
- * DESCRIPTION
- * Get auto scroll status
- * PARAMETERS
- * void
- * RETURNS
- * FILE_HANDLE
- *****************************************************************************/
- pBOOL ebr_frm_get_auto_scroll_status(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_flag == 1)
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * get_highlight_id_from_nvram
- * DESCRIPTION
- * Get auto scroll status
- * PARAMETERS
- * void
- * RETURNS
- * FILE_HANDLE
- *****************************************************************************/
- S16 get_highlight_id_from_nvram(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 highlight_id = 0;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadValue(NVRAM_EBOOK_LAST_HIGHLIGHT_ID, (void*)&highlight_id, DS_SHORT, &error);
- return highlight_id;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_set_current_highlight_id
- * DESCRIPTION
- * Get highlight id
- * PARAMETERS
- * index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_set_current_highlight_id(S32 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->current_highlight_book_id = index;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_book_size_from_nfo
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- S32 ebr_frm_get_book_size_from_nfo(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_curr_book_cntx_p->g_nfo_book_struct.book_size;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_book_temp_size_from_nfo
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- S32 ebr_frm_get_book_temp_size_from_nfo(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- return g_curr_book_cntx_p->g_nfo_book_struct.temp_book_size;
- }
- else
- {
- return g_curr_book_cntx_p->g_nfo_book_struct.book_size;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_page_size
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- S32 ebr_frm_get_page_size(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->is_book_in_unicode || g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- return EBR_PAGE_SIZE * 2;
- }
- else
- {
- return EBR_PAGE_SIZE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_fmgr_get_nfo_id
- * DESCRIPTION
- * Get nfo id
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- S32 ebr_frm_fmgr_get_nfo_id(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_curr_book_cntx_p->nfo_id;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_fmgr_set_nfo_id
- * DESCRIPTION
- * Set nfo id
- * PARAMETERS
- * local_nfo_id [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_fmgr_set_nfo_id(S32 local_nfo_id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->nfo_id = local_nfo_id;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_get_book_type
- * DESCRIPTION
- * Get book type
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- S16 ebr_fmgr_get_book_type(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_curr_book_cntx_p->ebr_fmgr_book_type;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_fmgr_get_application_type
- * DESCRIPTION
- * Get application type
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- S16 ebr_frm_fmgr_get_application_type(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_curr_book_cntx_p->src_application;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_fmgr_set_application_type
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_fmgr_set_application_type(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->src_application = EBR_FRM_SRC_APP_FMGR;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_set_src_application_type
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_set_src_application_type(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(g_curr_book_cntx_p->nfo_name, 0, sizeof(g_curr_book_cntx_p->nfo_name));
- g_curr_book_cntx_p->src_application = EBR_FRM_SRC_APP_EBOOK;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_check_nfo_file_present
- * DESCRIPTION
- *
- * PARAMETERS
- * nfo_id [IN]
- * RETURNS
- *
- *****************************************************************************/
- S32 ebr_frm_check_nfo_file_present(S32 nfo_id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE nfo_handle;
- U32 size;
- S32 compare_type = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nfo_handle = ebr_frm_get_nfo_handle();
- if (nfo_handle > 0)
- {
- FS_Read(
- nfo_handle,
- &g_curr_book_cntx_p->g_nfo_book_struct,
- sizeof(g_curr_book_cntx_p->g_nfo_book_struct),
- &size);
- FS_Close(nfo_handle);
- compare_type = pfnUnicodeStrcmp(
- (const S8*)g_curr_book_cntx_p->g_nfo_book_struct.e_book_name,
- (const S8*)g_curr_book_cntx_p->nfo_name);
- if (compare_type != 0)
- {
- return 0;
- }
- else
- {
- return nfo_id;
- }
- }
- else
- {
- FS_Close(nfo_handle);
- return 0;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_fmgr_set_file_type
- * DESCRIPTION
- *
- * PARAMETERS
- * file_name [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_fmgr_set_file_type(S8 *file_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 tmp_path_buf[(FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->is_short)
- {
- memset(tmp_path_buf, 0, (FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- mmi_chset_mixed_text_to_ucs2_str(
- (U8*) tmp_path_buf,
- (FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH,
- (U8*) file_name,
- g_chset_text_encoding);
- pfnUnicodeStrcpy((S8*) g_curr_book_cntx_p->nfo_name, (S8*) tmp_path_buf);
- }
- else
- {
- pfnUnicodeStrcpy((S8*) g_curr_book_cntx_p->nfo_name, (S8*) file_name);
- }
- ebr_frm_set_file_type();
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_set_file_name
- * DESCRIPTION
- *
- * PARAMETERS
- * nfo_id [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_set_file_name(S32 nfo_id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE nfo_hnd;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nfo_hnd = ebr_frm_get_nfo_handle();
- pfnUnicodeStrcpy((PS8) g_curr_book_cntx_p->nfo_name, (PS8) g_curr_book_cntx_p->g_nfo_book_struct.e_book_name);
- FS_Close(nfo_hnd);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_fmgr_move_ebook_file
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_fmgr_move_ebook_file(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 create_result;
- FS_HANDLE file_handle;
- U8 name[FMGR_MAX_FILE_LEN*ENCODING_LENGTH];
- U8 tmp_path_buf[(FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcat((S8*) g_curr_book_cntx_p->fmgr_file_path, (S8*) g_curr_book_cntx_p->fmgr_file_name);
- #ifndef __MMI_SHOW_FILE_EXT__
- pfnUnicodeStrcat((PS8) g_curr_book_cntx_p->fmgr_file_path, (PS8) g_curr_book_cntx_p->fmgr_file_extension);
- #endif
- pfnUnicodeStrcpy((PS8) g_curr_book_cntx_p->old_file_path, (PS8) g_curr_book_cntx_p->fmgr_file_path);
- /* short file name src file should be renamed to long file name */
- #ifdef MMI_ON_HARDWARE_P
- if (g_curr_book_cntx_p->is_short == TRUE)
- {
- PS8 temp, temp1;
- temp = mmi_fmgr_extract_file_name((PS8) g_curr_book_cntx_p->fmgr_file_path);
- temp1 = mmi_fmgr_extract_file_name((PS8) g_curr_book_cntx_p->old_file_path);
- mmi_chset_mixed_text_to_ucs2_str(
- (U8*) temp1,
- (MAX_SUBMENU_CHARACTERS - 1) * ENCODING_LENGTH,
- (U8*) temp,
- PhnsetGetDefEncodingType());
- FS_Rename((PU16) g_curr_book_cntx_p->fmgr_file_path, (PU16) g_curr_book_cntx_p->old_file_path);
- }
- #endif /* MMI_ON_HARDWARE_P */
- mmi_fmgr_remove_last_dir((PS8) g_curr_book_cntx_p->fmgr_file_path);
- pfnUnicodeStrcpy((PS8) name, (PS8) FMGR_DEFAULT_FOLDER_EBOOKS);
- mmi_fmgr_append_file_name((PS8) g_curr_book_cntx_p->fmgr_file_path, (PS8) name);
- ebr_fmgr_is_book_shelf_path(g_curr_book_cntx_p->fmgr_file_path);
- mmi_fmgr_remove_last_dir((PS8) g_curr_book_cntx_p->fmgr_file_path);
- ebr_frm_create_new_file_path();
- file_handle = FS_Open((U16*) g_curr_book_cntx_p->fmgr_file_path, FS_OPEN_DIR | FS_READ_ONLY);
- /* path already exist */
- if (file_handle >= 0)
- {
- FS_Close(file_handle);
- create_result = 0;
- }
- else
- {
- create_result = FS_CreateDir((PU16) g_curr_book_cntx_p->fmgr_file_path);
- pfnUnicodeStrcpy((PS8) g_curr_book_cntx_p->gebook_folder_path, (PS8) g_curr_book_cntx_p->fmgr_file_path);
- g_curr_book_cntx_p->g_isEbook_folder_created = TRUE;
- }
- if (mmi_fmgr_append_file_name((PS8) g_curr_book_cntx_p->fmgr_file_path, (PS8) g_curr_book_cntx_p->fmgr_file_name) ==
- TRUE)
- {
- if (g_curr_book_cntx_p->is_short)
- {
- memset(tmp_path_buf, 0, (FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- mmi_chset_mixed_text_to_ucs2_str(
- (U8*) tmp_path_buf,
- (FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH,
- (U8*) g_curr_book_cntx_p->fmgr_file_path,
- g_chset_text_encoding);
- pfnUnicodeStrcpy((S8*) g_curr_book_cntx_p->fmgr_file_path, (S8*) tmp_path_buf);
- }
- ebr_frm_delete_unused_nfo_file();
- mmi_fmgr_send_copy_req(
- FMGR_ACTION_MOVE,
- (PU8) g_curr_book_cntx_p->old_file_path,
- (PU8) g_curr_book_cntx_p->fmgr_file_path,
- (PsFuncPtr) fmgr_ebook_move_rsp);
- ebr_please_wait_actual_screen();
- }
- }
- /*****************************************************************************
- * FUNCTION
- * fmgr_ebook_move_rsp
- * DESCRIPTION
- * Move response handler
- * PARAMETERS
- * info [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void fmgr_ebook_move_rsp(void *info)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_fmt_copy_rsp_strcut *msgPtr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msgPtr = (mmi_fmt_copy_rsp_strcut*) info;
- if (msgPtr->result >= 0)
- {
- ebr_fmgr_set_file_type((S8*) g_curr_book_cntx_p->fmgr_file_name);
- mmi_fmgr_remove_last_dir((PS8) g_curr_book_cntx_p->old_file_path);
- ebr_fmgr_copy_new_file_path_after_move(g_curr_book_cntx_p->old_file_path);
- DeleteScreenIfPresent(SCR_FMGR_FILE_OPTION);
- ebr_app_add_to_book_shelf();
- }
- else
- {
- ebr_display_error_pop_up(msgPtr->result);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_app_change_drive_type
- * DESCRIPTION
- * Change drive type
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_app_change_drive_type(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- error = ebr_frm_change_drive_type();
- ebr_app_get_nfo_id_from_fmgr(
- g_curr_book_cntx_p->fmgr_file_name,
- g_curr_book_cntx_p->fmgr_file_path,
- g_curr_book_cntx_p->fmgr_file_extension,
- g_curr_book_cntx_p->is_short);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_entry_open
- * DESCRIPTION
- * Entry open book
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_fmgr_entry_open(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ebr_app_get_nfo_id_from_fmgr(
- g_curr_book_cntx_p->fmgr_file_name,
- g_curr_book_cntx_p->fmgr_file_path,
- g_curr_book_cntx_p->fmgr_file_extension,
- g_curr_book_cntx_p->is_short);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_move_to_ebook_folder
- * DESCRIPTION
- * Move to ebook folder
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_fmgr_move_to_ebook_folder(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ebr_app_clear_all_key_handlers();
- ebr_frm_fmgr_move_ebook_file();
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_check_file_validity
- * DESCRIPTION
- * Move to ebook folder
- * PARAMETERS
- * file_path [?]
- * file_name [?]
- * RETURNS
- * void
- *****************************************************************************/
- pBOOL ebr_frm_check_file_validity(S8 *file_path, S8 *file_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE file_hnd;
- U32 size;
- ebr_frm_database_hdr_type file_header;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->gbook_type == EBR_FRM_FILE_TYPE_TXT)
- {
- return TRUE;
- }
- pfnUnicodeStrcat((S8*) file_path, (S8*) file_name);
- file_hnd = FS_Open((const WCHAR*)file_path, FS_READ_ONLY);
- if (file_hnd > 0)
- {
- if (FS_Read(file_hnd, &file_header, EBR_FRM_DATABASE_HEADER_SIZE, &size) == FS_NO_ERROR)
- {
- if (memcmp(file_header.type, DOC_TYPE, strlen((PS8) DOC_TYPE)) == 0)
- {
- FS_Close(file_hnd);
- return TRUE;
- }
- else
- {
- FS_Close(file_hnd);
- return FALSE;
- }
- }
- else
- {
- return FALSE;
- }
- }
- else
- {
- return FALSE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_set_file_info_from_fmgr
- * DESCRIPTION
- * Move to ebook folder
- * PARAMETERS
- * file_name [IN]
- * file_path [IN]
- * file_ext [IN]
- * is_short [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_set_file_info_from_fmgr(S8 *file_name, S8 *file_path, S8 *file_ext, BOOL is_short)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((PS8) g_curr_book_cntx_p->fmgr_file_name, (PS8) file_name);
- pfnUnicodeStrcpy((PS8) g_curr_book_cntx_p->fmgr_file_path, (PS8) file_path);
- pfnUnicodeStrcpy((PS8) g_curr_book_cntx_p->fmgr_file_extension, (PS8) file_ext);
- g_curr_book_cntx_p->is_short = is_short;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_delete_all_unused_nfo_file
- * DESCRIPTION
- * Move to ebook folder
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_delete_all_unused_nfo_file(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FS_HANDLE fh_cur;
- FS_DOSDirEntry file_info;
- S8 path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH];
- U8 filename[MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH];
- U32 driveCount = 0;
- S8 driveLatter[FMGR_TOTAL_STORAGE];
- U8 driveNum;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(driveLatter, 0, FMGR_TOTAL_STORAGE);
- mmi_fmgr_get_exist_drive_letter(driveLatter, &driveNum);
- while (driveLatter[driveCount] != 0)
- {
- memset((char*)path, 0, MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH);
- pfnUnicodeStrcpy((S8*) path, (S8*) ebr_frm_get_file_path(driveLatter[driveCount], EBR_FRM_SEARCH_NFO));
- if ((fh_cur = FS_FindFirst(
- (const WCHAR*)path,
- 0,
- 0,
- &file_info,
- (U16*) filename,
- MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH)) >= 0)
- {
- do
- {
- if (!(file_info.Attributes & FS_ATTR_DIR))
- {
- ebr_frm_open_nfo_file_and_delete_all_unused_nfo(driveLatter[driveCount], filename);
- }
- } while ((FS_FindNext(fh_cur, &file_info, (U16*) filename, MAX_EBOOK_NAME_LENGTH * ENCODING_LENGTH) ==
- FS_NO_ERROR));
- FS_FindClose(fh_cur);
- }
- driveCount++;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_open_nfo_file_and_delete_all_unused_nfo
- * DESCRIPTION
- * Move to ebook folder
- * PARAMETERS
- * memory_type [IN]
- * filename [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_open_nfo_file_and_delete_all_unused_nfo(S8 memory_type, U8 *filename)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 nfo_path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH];
- S8 file_path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH];
- FILE_HANDLE nfo_hnd, file_hnd;
- U32 size;
- S32 nfo_id, strlen_file_name;
- ebr_frm_book_struct book_struct;
- ebr_frm_filetype_enum book_type;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((S8*) nfo_path, (S8*) ebr_frm_get_file_path(memory_type, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((S8*) nfo_path, (S8*) filename);
- nfo_hnd = FS_Open((const WCHAR*)nfo_path, FS_READ_ONLY);
- FS_Read(nfo_hnd, &book_struct, sizeof(book_struct), &size);
- FS_Close(nfo_hnd);
- strlen_file_name = pfnUnicodeStrlen((const S8*)book_struct.e_book_name);
- if (book_struct.e_book_name[strlen_file_name * 2 - 6] == 'p')
- {
- book_type = EBR_FRM_FILE_TYPE_PDB;
- }
- else
- {
- book_type = EBR_FRM_FILE_TYPE_TXT;
- }
- pfnUnicodeStrcpy((S8*) file_path, (S8*) ebr_frm_get_file_path(memory_type, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((S8*) file_path, (S8*) book_struct.e_book_name);
- file_hnd = FS_Open((const WCHAR*)file_path, FS_READ_ONLY);
- if (file_hnd <= 0)
- {
- FS_Delete((const WCHAR*)nfo_path);
- }
- else
- {
- FS_Close(file_hnd);
- if (book_type == EBR_FRM_FILE_TYPE_TXT)
- {
- nfo_id = ebr_fmgr_get_nfo_id_for_txt_file(memory_type, (S8*) g_curr_book_cntx_p->g_nfo_book_struct.e_book_name);
- }
- else
- {
- nfo_id = ebr_fmgr_get_nfo_id_for_pdb_file(memory_type, (S8*) g_curr_book_cntx_p->g_nfo_book_struct.e_book_name);
- }
- if (nfo_id <= 0)
- {
- FS_Delete((const WCHAR*)nfo_path);
- }
- }
- }
- #if defined(MMI_ON_HARDWARE_P) && (defined(__MMI_CHSET_BIG5__) || defined(__MMI_CHSET_GB2312__))
- extern const key_index_t *g_chset_encode_to_ucs2_key_LSB_index[NO_OF_TEXT_ENCODING];
- extern const kal_uint8 *g_chset_encode_to_ucs2_key_MSB[NO_OF_TEXT_ENCODING];
- extern const kal_uint16 *g_chset_encode_to_ucs2_table[NO_OF_TEXT_ENCODING];
- extern const kal_uint16 *g_chset_unknown_encode_char;
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_mmi_chset_text_to_ucs2_str
- * DESCRIPTION
- *
- * PARAMETERS
- * file_hnd [IN]
- * dest [IN]
- * dest_size [IN]
- * src [IN]
- * src_size [IN]
- * encoding [IN]
- * over_the_record_border [?]
- * RETURNS
- *
- *****************************************************************************/
- U16 ebr_frm_mmi_chset_text_to_ucs2_str(
- FILE_HANDLE file_hnd,
- U8 *dest,
- S16 dest_size,
- U8 *src,
- S16 src_size,
- TextEncodingEnum encoding,
- U32 *over_the_record_border)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- const key_index_t *key_LSB_index_table = g_chset_encode_to_ucs2_key_LSB_index[encoding];
- const kal_uint8 *key_MSB_table = g_chset_encode_to_ucs2_key_MSB[encoding];
- const kal_uint16 *ucs2_table = g_chset_encode_to_ucs2_table[encoding];
- U8 key_LSB;
- U8 key_MSB;
- S16 start;
- S16 end;
- S16 pos = 0;
- S16 index;
- S16 count = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *over_the_record_border = 0;
- while (*(src) != 0) /* I do not know how we assume that this is end of data.. Currently we are taking only chinese encodings for
- the optimized algo so we can take it as 2 bytes */
- {
- if (*(src) <= 0x7f)
- {
- *(dest + pos) = *src;
- pos++;
- *(dest + pos) = 0;
- pos++;
- src += 1;
- count += 1;
- }
- else
- {
- key_LSB = (U8) (*(src));
- count += 1;
- start = key_LSB_index_table[key_LSB].start;
- if (start < 0)
- {
- dest[pos] = (U8) g_chset_unknown_encode_char[encoding];
- dest[pos + 1] = (U8) (g_chset_unknown_encode_char[encoding] >> 8);
- src += 1;
- }
- else
- {
- if (count >= src_size)
- {
- U32 temp_size;
- FS_Read(file_hnd, &key_MSB, 1, &temp_size);
- if (temp_size != 1)
- {
- key_MSB = 0;
- }
- else
- {
- *over_the_record_border = 1;
- }
- }
- else
- {
- key_MSB = (U8) (*(src + 1));
- }
- count += 1;
- end = key_LSB_index_table[key_LSB].end;
- if ((index = ebr_frm_mmi_chset_binary_search(key_MSB, key_MSB_table, start, end)) < 0) /* key MSB not found */
- {
- dest[pos] = (U8) g_chset_unknown_encode_char[encoding];
- dest[pos + 1] = (U8) (g_chset_unknown_encode_char[encoding] >> 8);
- }
- else
- {
- dest[pos] = (U8) ucs2_table[index];
- dest[pos + 1] = (U8) (ucs2_table[index] >> 8);
- }
- src += 2;
- }
- pos += 2;
- }
- if (pos >= dest_size - 2)
- {
- break;
- }
- }
- dest[pos] = 0;
- dest[pos + 1] = 0;
- return pos + 2;
- }
- /* dest_size must be >= 4 */
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_mmi_chset_binary_search
- * DESCRIPTION
- *
- * PARAMETERS
- * key [IN]
- * lookup_table [IN]
- * start [IN]
- * end [IN]
- * RETURNS
- *
- *****************************************************************************/
- S16 ebr_frm_mmi_chset_binary_search(const kal_uint8 key, const kal_uint8 *lookup_table, kal_int16 start, kal_int16 end)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (start <= end)
- {
- kal_int16 mid = (start + end) / 2;
- if (key > lookup_table[mid])
- {
- start = mid + 1;
- }
- else if (key < lookup_table[mid])
- {
- end = mid - 1;
- }
- else /* key == target */
- {
- return mid;
- }
- }
- return -1;
- }
- #endif /* defined(MMI_ON_HARDWARE_P) && (defined(__MMI_CHSET_BIG5__) || defined(__MMI_CHSET_GB2312__)) */ /* defined(MMI_ON_HARDWARE_P) && defined(__MMI_CHSET_IDEOGRAM_SUPPORT__) */
- #if defined(MMI_ON_HARDWARE_P)
- const kal_uint8 g_ebr_frm_cheset_utf8_bytes_per_char[16] =
- {
- 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 0, 0, 2, 2, 3, 4 /* we don't support UCS4 */
- };
- extern kal_int32 mmi_chset_utf8_to_ucs2(kal_uint8 *dest, kal_uint8 *utf8);
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_mmi_chset_utf8_to_ucs2_string
- * DESCRIPTION
- *
- * PARAMETERS
- * file_hnd [IN]
- * dest [IN]
- * dest_size [IN]
- * src [IN]
- * src_size [IN]
- * over_the_record_border [IN]
- * RETURNS
- *
- *****************************************************************************/
- S32 ebr_frm_mmi_chset_utf8_to_ucs2_string(
- FILE_HANDLE file_hnd,
- U8 *dest,
- S16 dest_size,
- U8 *src,
- S16 src_size,
- U32 *over_the_record_border)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 pos = 0;
- S32 cnt;
- S32 src_count = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *over_the_record_border = 0;
- while (*src && pos < dest_size - 2)
- {
- cnt = g_ebr_frm_cheset_utf8_bytes_per_char[(*src) >> 4];
- if (src_count + cnt > src_size)
- {
- S32 i = 0;
- U8 utf8_char[4];
- U8 bytes_in_buffer;
- U32 size;
- *over_the_record_border = (src_count + cnt) - src_size;
- bytes_in_buffer = cnt - *over_the_record_border;
- for (i = 0; i < bytes_in_buffer; i++)
- {
- utf8_char[i] = *src;
- src += 1;
- }
- FS_Read(file_hnd, &utf8_char[bytes_in_buffer], *over_the_record_border, &size);
- if (size != *over_the_record_border)
- {
- break;
- }
- else
- {
- cnt = mmi_chset_utf8_to_ucs2(dest + pos, utf8_char);
- }
- }
- else
- {
- cnt = mmi_chset_utf8_to_ucs2(dest + pos, src);
- }
- if (cnt == 0) /* abnormal case */
- {
- break;
- }
- else if (cnt == 4)
- {
- src += cnt;
- }
- else /* normal case */
- {
- src += cnt;
- pos += 2;
- }
- src_count += cnt;
- }
- dest[pos] = 0;
- dest[pos + 1] = 0;
- return pos + 2;
- }
- #endif /* defined(MMI_ON_HARDWARE_P) */
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_reset_find_next_data
- * DESCRIPTION
- * Clears flags for find next on shortcut keys
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_reset_find_next_data(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->ebr_last_offset_string = -1;
- g_curr_book_cntx_p->search_found_flag = FALSE;
- g_curr_book_cntx_p->search_string_count = 0;
- g_curr_book_cntx_p->find_next_first_flag = 0;
- g_curr_book_cntx_p->last_record_flag = 0;
- g_curr_book_cntx_p->ebr_last_text_offset = 0;
- g_curr_book_cntx_p->ebr_last_page_id = 0;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_and_set_current_page_values
- * DESCRIPTION
- * Sets current page values in case of Exit category
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_get_and_set_current_page_values(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 page_id;
- S32 text_offset;
- U8 shared_bytes;
- U8 last_showed_percentage;
- S32 last_text_offset_y;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- wgui_paging_multiline_get_current_page(
- &page_id,
- &text_offset,
- &shared_bytes,
- &last_showed_percentage,
- &last_text_offset_y);
- g_curr_book_cntx_p->ebr_last_text_offset = text_offset;
- g_curr_book_cntx_p->ebr_last_page_id = page_id;
- }
- #ifdef __MMI_LANG_HINDI__
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_check_for_full_characters
- * DESCRIPTION
- *
- * PARAMETERS
- * pattern [IN]
- * RETURNS
- *
- *****************************************************************************/
- pBOOL ebr_frm_check_for_full_characters(S16 *pattern)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (pattern[pfnUnicodeStrlen((const S8*)pattern) - 1] == 2381)
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
- #endif /* __MMI_LANG_HINDI__ */
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_check_drive_space
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- pBOOL ebr_frm_check_drive_space(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 file_path_in_ascii[5];
- S8 file_path[10];
- U64 disk_free_space;
- U64 disk_total_space;
- S32 fs_ret;
- FS_DiskInfo disk_info;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- sprintf((char*)file_path_in_ascii, "%c", g_curr_book_cntx_p->memory_type_selected);
- strcat((char*)file_path_in_ascii, ":\");
- AnsiiToUnicodeString((PS8) file_path, file_path_in_ascii);
- fs_ret = FS_GetDiskInfo((PU16) file_path, &disk_info, FS_DI_BASIC_INFO | FS_DI_FREE_SPACE);
- disk_free_space = 0;
- disk_total_space = 0;
- if (fs_ret >= 0)
- {
- disk_free_space = disk_info.FreeClusters * disk_info.SectorsPerCluster * disk_info.BytesPerSector;
- disk_total_space = disk_info.TotalClusters * disk_info.SectorsPerCluster * disk_info.BytesPerSector;
- if (disk_free_space <= g_curr_book_cntx_p->g_nfo_book_struct.book_size)
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_check_nfo_file_size
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- pBOOL ebr_frm_check_nfo_file_size(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 file_path_in_ascii[5];
- S8 file_path[10];
- U64 disk_free_space;
- U64 disk_total_space;
- S32 fs_ret;
- FS_DiskInfo disk_info;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- sprintf((char*)file_path_in_ascii, "%c", g_curr_book_cntx_p->memory_type_selected);
- strcat((char*)file_path_in_ascii, ":\");
- AnsiiToUnicodeString((PS8) file_path, file_path_in_ascii);
- fs_ret = FS_GetDiskInfo((PU16) file_path, &disk_info, FS_DI_BASIC_INFO | FS_DI_FREE_SPACE);
- disk_free_space = 0;
- disk_total_space = 0;
- if (fs_ret >= 0)
- {
- disk_free_space = disk_info.FreeClusters * disk_info.SectorsPerCluster * disk_info.BytesPerSector;
- disk_total_space = disk_info.TotalClusters * disk_info.SectorsPerCluster * disk_info.BytesPerSector;
- if (disk_free_space <= sizeof(g_curr_book_cntx_p->g_nfo_book_struct))
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_kernel_hide_ext_name
- * DESCRIPTION
- *
- * PARAMETERS
- * str_buf_ptr [?]
- * info_ptr [?]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_fmgr_kernel_hide_ext_name(S8 *str_buf_ptr, FMGR_FILE_INFO_STRUCT *info_ptr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 str_len;
- S32 ext_str_len;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- str_len = pfnUnicodeStrlen((PS8) str_buf_ptr);
- ext_str_len = pfnUnicodeStrlen((PS8) info_ptr->file_ext);
- if (ext_str_len > 0)
- {
- ext_str_len += 1;
- }
- if (!(info_ptr->attribute & FS_ATTR_DIR)) /* not folder */
- {
- memset(&str_buf_ptr[(str_len - ext_str_len) * ENCODING_LENGTH], 0, ext_str_len * ENCODING_LENGTH);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_remove_last_directory
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_remove_last_directory(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_fmgr_remove_last_dir((PS8) g_curr_book_cntx_p->book_name_path);
- ebr_fmgr_copy_new_file_path_after_move((S8*) g_curr_book_cntx_p->book_name_path);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_check_is_nfo_file_exist
- * DESCRIPTION
- *
- * PARAMETERS
- * nfo_id [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_check_is_nfo_file_exist(S16 nfo_id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE nfo_hnd;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nfo_hnd = FS_Open((const WCHAR*)ebr_frm_get_nfo_file_name((S32) nfo_id), FS_READ_ONLY);
- if (nfo_hnd <= 0)
- {
- nfo_id = 0;
- WriteValue(NVRAM_EBOOK_NFO_LID, (void*)&nfo_id, DS_SHORT, &error);
- }
- FS_Close(nfo_hnd);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_check_file_exist
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * pBOOL
- *****************************************************************************/
- pBOOL ebr_frm_check_file_exist(void)
- {
- FILE_HANDLE file_hnd;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- file_hnd = FS_Open((const WCHAR*)g_curr_book_cntx_p->temp_book_name_path, FS_READ_ONLY);
- }
- else
- {
- file_hnd = FS_Open((const WCHAR*)g_curr_book_cntx_p->book_name_path, FS_READ_ONLY);
- }
- if(file_hnd<=0)
- return FALSE;
- else
- {
- FS_Close(file_hnd);
- return TRUE;
- }
- }
- MMI_BOOL mmi_ebr_is_memory_type_changed(S8 memoryType)
- {
- if (g_curr_book_cntx_p->g_nfo_book_struct.memory_type == memoryType)
- {
- return MMI_FALSE;
- }
- else
- {
- return MMI_TRUE;
- }
- }
- #endif /* __MMI_EBOOK_READER__ */