EbookFramework.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:303k
源码类别:
MTK
开发平台:
C/C++
- * Get the encoding format
- * PARAMETERS
- * inBuffer [IN]
- * outBuffer [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_get_encoded_data(S8 *inBuffer, S8 *outBuffer)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 mmiEncoding = 0;
- S16 length = pfnUnicodeStrlen((const S8*)outBuffer);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmiEncoding = mmi_ebook_util_get_chset(g_curr_book_cntx_p->g_nfo_book_struct.settings.encoding_format);
- switch (mmiEncoding)
- {
- case MMI_CHSET_UCS2:
- pfnUnicodeStrncpy((PS8) inBuffer, (PS8) outBuffer, (length) * 2);
- break;
- case MMI_CHSET_WESTERN_WIN:
- AnsiiNToUnicodeString((PS8) inBuffer, (PS8) outBuffer, (length) * 2);
- break;
- default:
- mmi_chset_convert(
- (mmi_chset_enum) mmiEncoding,
- MMI_CHSET_UCS2,
- (char*)outBuffer,
- (char*)inBuffer,
- length * 2);
- break;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_record
- * DESCRIPTION
- * Get the record data
- * PARAMETERS
- * end_id [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_get_record(S32 end_id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 record_id_to_be_fetched;
- /* U8 nfo_path[MAX_DWNL_EBK_PATH_LEN*ENCODING_LENGTH]={0}; */
- FILE_HANDLE file_hnd;
- S16 ebr_page_size;
- /*----------------------------------------------------------------*/
- /* 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((PS8)nfo_path, (PS8)g_curr_book_cntx_p->g_nfo_book_struct.e_book_name);
- 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 (g_curr_book_cntx_p->is_book_in_unicode || g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- ebr_page_size = EBR_PAGE_SIZE * 2;
- }
- else
- {
- ebr_page_size = EBR_PAGE_SIZE;
- }
- if (g_curr_book_cntx_p->prev_end_id >= end_id)
- {
- record_id_to_be_fetched = (end_id - 2) / (EBR_RECORD_SIZE_MAX / ebr_page_size) + 1;
- if (record_id_to_be_fetched <= g_curr_book_cntx_p->num_records)
- {
- if ((record_id_to_be_fetched != g_curr_book_cntx_p->gcurrent_record_id) &&
- (record_id_to_be_fetched != g_curr_book_cntx_p->gnext_record_id))
- {
- copy_record_in_buffer(file_hnd, record_id_to_be_fetched, EBR_FRM_COPY_TYPE_PREVIOUS);
- g_curr_book_cntx_p->gcurrent_record_id = record_id_to_be_fetched;
- g_curr_book_cntx_p->gnext_record_id = record_id_to_be_fetched + 1;
- }
- }
- }
- else
- {
- record_id_to_be_fetched = (end_id + 2) / (EBR_RECORD_SIZE_MAX / ebr_page_size) + 1;
- if (record_id_to_be_fetched <= g_curr_book_cntx_p->num_records)
- {
- if ((record_id_to_be_fetched != g_curr_book_cntx_p->gcurrent_record_id) &&
- (record_id_to_be_fetched != g_curr_book_cntx_p->gnext_record_id))
- {
- copy_record_in_buffer(file_hnd, record_id_to_be_fetched, EBR_FRM_COPY_TYPE_NEXT);
- g_curr_book_cntx_p->gcurrent_record_id = record_id_to_be_fetched - 1;
- g_curr_book_cntx_p->gnext_record_id = g_curr_book_cntx_p->gcurrent_record_id + 1;
- }
- }
- }
- g_curr_book_cntx_p->prev_end_id = end_id;
- FS_Close(file_hnd);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_jump_to_record
- * DESCRIPTION
- * Jump to a record
- * PARAMETERS
- * percantage_val [IN]
- * jump_type [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_jump_to_record(U32 percantage_val, ebr_jump_type_enum jump_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 ebr_page_size;
- S32 book_size = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->g_jump_offset = 0;
- // if(g_curr_book_cntx_p->is_book_in_unicode||g_curr_book_cntx_p->book_is_in_other_encoding_format)
- // ebr_page_size = EBR_PAGE_SIZE*2;
- // else
- ebr_page_size = EBR_PAGE_SIZE;
- if (g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- book_size = g_curr_book_cntx_p->g_nfo_book_struct.temp_book_size;
- }
- else
- {
- book_size = g_curr_book_cntx_p->g_nfo_book_struct.book_size;
- }
- if (g_curr_book_cntx_p->is_book_in_unicode || g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- book_size /= 2;
- }
- if (jump_type == EBR_JUMP_MIDDLE && percantage_val == 0)
- {
- percantage_val = 50;
- }
- if (percantage_val == 1)
- {
- jump_type = EBR_JUMP_BEGIN;
- percantage_val = 0;
- }
- if (percantage_val == 100)
- {
- int num_of_pages = 0;
- if (book_size % ebr_page_size == 0)
- {
- num_of_pages = book_size / ebr_page_size - 1;
- }
- else
- {
- num_of_pages = book_size / ebr_page_size;
- }
- if (num_of_pages < 4)
- {
- percantage_val = 0;
- jump_type = EBR_JUMP_END;
- }
- }
- if (percantage_val == 0)
- {
- switch (jump_type)
- {
- case EBR_JUMP_BEGIN:
- g_curr_book_cntx_p->g_start_id = 0;
- g_curr_book_cntx_p->g_end_id = 3;
- g_curr_book_cntx_p->g_jump_offset = 0;
- g_curr_book_cntx_p->gcurrent_record_id = 1;
- g_curr_book_cntx_p->gnext_record_id = 2;
- break;
- case EBR_JUMP_END:
- g_curr_book_cntx_p->ebr_frm_end_book_flag = 0;
- if (book_size % ebr_page_size == 0)
- {
- g_curr_book_cntx_p->g_end_id = book_size / ebr_page_size - 1;
- }
- else
- {
- if (book_size < ebr_page_size * 8)
- {
- if (book_size < ebr_page_size * 4)
- {
- g_curr_book_cntx_p->g_start_id = 0;
- g_curr_book_cntx_p->g_end_id = 3;
- }
- else
- {
- g_curr_book_cntx_p->g_start_id = 0;
- g_curr_book_cntx_p->g_end_id = book_size / ebr_page_size - 1;
- g_curr_book_cntx_p->g_start_id = g_curr_book_cntx_p->g_end_id - 3;
- }
- }
- else
- {
- g_curr_book_cntx_p->g_end_id = book_size / ebr_page_size;
- }
- }
- g_curr_book_cntx_p->g_start_id = g_curr_book_cntx_p->g_end_id - 3;
- break;
- }
- }
- else
- {
- float num;
- int size_offset;
- float actual_size_offset;
- float actual_jump_offset;
- int jump_offset = 0;
- num = percantage_val / (float)100.0;
- actual_size_offset = book_size * num;
- if (percantage_val == 100)
- {
- /* percantage_val--; */
- num = (percantage_val - 1) / (float)100.0;
- num = (float)(num + 0.008);
- size_offset = (int)(book_size * num);
- actual_size_offset = ((float)book_size) * num;
- }
- else
- {
- size_offset = (int)(book_size * num);
- }
- if (actual_size_offset - (float)size_offset > 0)
- {
- size_offset++;
- }
- if ((book_size - size_offset) <= EBR_PAGE_SIZE)
- {
- if (book_size % ebr_page_size == 0)
- {
- g_curr_book_cntx_p->g_end_id = book_size / ebr_page_size - 1;
- g_curr_book_cntx_p->g_start_id = g_curr_book_cntx_p->g_end_id - 3;
- }
- else
- {
- if (book_size < ebr_page_size * 4)
- {
- actual_jump_offset = (float)(book_size) * (float)((float)(percantage_val) / (float)100.0);
- g_curr_book_cntx_p->g_jump_offset = (U16) actual_jump_offset;
- if (actual_jump_offset - (float)g_curr_book_cntx_p->g_jump_offset > 0.5)
- {
- g_curr_book_cntx_p->g_jump_offset++;
- }
- if (g_curr_book_cntx_p->g_jump_offset == book_size)
- {
- g_curr_book_cntx_p->g_jump_offset--;
- }
- g_curr_book_cntx_p->g_start_id = 0;
- g_curr_book_cntx_p->g_end_id = g_curr_book_cntx_p->g_start_id + 3;
- }
- else
- {
- if (book_size < EBR_RECORD_SIZE_MAX)
- {
- actual_jump_offset = (float)(book_size) * (float)((float)(percantage_val) / (float)100.0);
- g_curr_book_cntx_p->g_jump_offset = (U16) actual_jump_offset;
- if (actual_jump_offset - (float)g_curr_book_cntx_p->g_jump_offset > 0.5)
- {
- g_curr_book_cntx_p->g_jump_offset++;
- }
- if (g_curr_book_cntx_p->g_jump_offset == book_size)
- {
- g_curr_book_cntx_p->g_jump_offset--;
- }
- jump_offset = (int)g_curr_book_cntx_p->g_jump_offset;
- /* while(jump_offset>0)
- jump_offset = jump_offset - EBR_PAGE_SIZE; */
- /* g_curr_book_cntx_p->g_jump_offset = jump_offset + EBR_PAGE_SIZE+EBR_PAGE_SIZE; */
- g_curr_book_cntx_p->g_end_id = size_offset / ebr_page_size;
- if (g_curr_book_cntx_p->g_start_id < 0)
- {
- g_curr_book_cntx_p->g_start_id = 0;
- }
- g_curr_book_cntx_p->g_start_id = g_curr_book_cntx_p->g_end_id - 3;
- g_curr_book_cntx_p->g_jump_offset =
- g_curr_book_cntx_p->g_jump_offset - g_curr_book_cntx_p->g_start_id * EBR_PAGE_SIZE;
- }
- else
- {
- g_curr_book_cntx_p->g_jump_offset = size_offset % EBR_PAGE_SIZE + EBR_PAGE_SIZE;
- g_curr_book_cntx_p->g_start_id = (size_offset / ebr_page_size) - 1;
- g_curr_book_cntx_p->g_end_id = g_curr_book_cntx_p->g_start_id + 3;
- }
- }
- }
- }
- else
- {
- if (book_size < EBR_PAGE_SIZE * 4)
- {
- g_curr_book_cntx_p->g_start_id = 0;
- g_curr_book_cntx_p->g_end_id = g_curr_book_cntx_p->g_start_id + 3;
- g_curr_book_cntx_p->g_jump_offset =
- (U32) (((float)book_size) * (float)((float)(percantage_val) / (float)100.0));
- }
- else
- {
- if (book_size < EBR_RECORD_SIZE_MAX)
- {
- actual_jump_offset = (float)(book_size) * (float)((float)(percantage_val) / (float)100.0);
- g_curr_book_cntx_p->g_jump_offset = (U16) actual_jump_offset;
- if (actual_jump_offset - (float)g_curr_book_cntx_p->g_jump_offset > 0.5)
- {
- g_curr_book_cntx_p->g_jump_offset++;
- }
- if (g_curr_book_cntx_p->g_jump_offset == book_size)
- {
- g_curr_book_cntx_p->g_jump_offset--;
- }
- jump_offset = (int)g_curr_book_cntx_p->g_jump_offset;
- while (jump_offset > 0)
- {
- jump_offset = jump_offset - EBR_PAGE_SIZE;
- }
- g_curr_book_cntx_p->g_jump_offset = jump_offset + EBR_PAGE_SIZE;
- g_curr_book_cntx_p->g_start_id = size_offset / ebr_page_size;
- if (g_curr_book_cntx_p->g_start_id < 0)
- {
- g_curr_book_cntx_p->g_start_id = 0;
- }
- g_curr_book_cntx_p->g_end_id = g_curr_book_cntx_p->g_start_id + 3;
- }
- else
- {
- g_curr_book_cntx_p->g_jump_offset = size_offset % EBR_PAGE_SIZE + EBR_PAGE_SIZE;
- if (percantage_val == 100)
- {
- g_curr_book_cntx_p->g_start_id = (size_offset / ebr_page_size);
- }
- else
- {
- g_curr_book_cntx_p->g_start_id = (size_offset / ebr_page_size) - 1;
- }
- g_curr_book_cntx_p->g_end_id = g_curr_book_cntx_p->g_start_id + 3;
- }
- }
- }
- }
- if (percantage_val != g_curr_book_cntx_p->g_nfo_book_struct.last_showed_percentage)
- {
- g_curr_book_cntx_p->g_nfo_book_struct.last_showed_percentage = 0;
- }
- g_curr_book_cntx_p->g_nfo_book_struct.current_page_id = g_curr_book_cntx_p->g_start_id;
- g_curr_book_cntx_p->g_nfo_book_struct.offset = 0;
- g_curr_book_cntx_p->g_nfo_book_struct.jump_offset = g_curr_book_cntx_p->g_jump_offset;
- ebr_frm_save_settings_in_nfo_file();
- g_curr_book_cntx_p->ebr_last_offset_string = -1;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_remove_bookmark
- * DESCRIPTION
- * Create the linked list
- * PARAMETERS
- * bookmark_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_remove_bookmark(U32 bookmark_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 count = 0;
- U32 size;
- S32 retval;
- FILE_HANDLE nfo_hnd;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((PS8) g_curr_book_cntx_p->g_nfo_book_struct.book_marks[bookmark_index].bookmark_name, (PS8) NULL);
- if (g_curr_book_cntx_p->g_nfo_book_struct.book_marks[bookmark_index + 1].bookmark_name[0] != 0)
- {
- count = bookmark_index + 1;
- while (g_curr_book_cntx_p->g_nfo_book_struct.book_marks[count].bookmark_name[0] != 0 && count < EBR_FRM_MAX_NO_OF_BOOKMARKS)
- {
- pfnUnicodeStrcpy(
- (PS8) g_curr_book_cntx_p->g_nfo_book_struct.book_marks[count - 1].bookmark_name,
- (PS8) g_curr_book_cntx_p->g_nfo_book_struct.book_marks[count].bookmark_name);
- count++;
- }
- count--;
- pfnUnicodeStrcpy((PS8) g_curr_book_cntx_p->g_nfo_book_struct.book_marks[count].bookmark_name, (PS8) NULL);
- }
- nfo_hnd = FS_Open((const WCHAR*)g_curr_book_cntx_p->nfo_path, FS_READ_WRITE);
- 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_add_book_mark_pre_entry
- * DESCRIPTION
- * Pre entry Screen for Add book mark
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_add_book_mark_pre_entry()
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i = 0, duplicate = 0;
- U8 bookMarkName[EBR_FRM_MAX_BOOKMARK_NAME_SIZE * ENCODING_LENGTH] = {0};
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((S8*) bookMarkName, (S8*) ebr_get_book_mark_name());
- while (g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].bookmark_name[0] != 0)
- {
- if (!pfnUnicodeStrcmp
- ((const S8*)g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].bookmark_name, (const S8*)bookMarkName))
- {
- duplicate = 1;
- entry_duplicate_book_mark_pop_up();
- }
- i++;
- }
- if (duplicate == 0)
- {
- ebr_frm_add_book_mark();
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_add_book_mark
- * DESCRIPTION
- * Entry function for Add book mark
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_add_book_mark()
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i = 0;
- U8 bookMarkName[EBR_FRM_MAX_BOOKMARK_NAME_SIZE * ENCODING_LENGTH] = {0};
- U32 size;
- S32 retval, count = 0, k = 1, offset, text_offset_local = 0;
- FILE_HANDLE nfo_hnd;
- U32 page_id;
- S32 text_offset;
- U8 shared_bytes;
- U8 last_showed_percentage;
- S32 page_id_local, last_text_offset_y;
- S8 *book_mark_name;
- S16 ebr_page_size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->is_book_in_unicode || g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- ebr_page_size = EBR_PAGE_SIZE * 2;
- }
- else
- {
- ebr_page_size = EBR_PAGE_SIZE;
- }
- wgui_paging_multiline_get_current_page(
- &page_id,
- &text_offset,
- &shared_bytes,
- &last_showed_percentage,
- &last_text_offset_y);
- text_offset_local = text_offset;
- count = 0;
- while ((text_offset) >= 0)
- {
- text_offset = text_offset - ebr_page_size;
- count++;
- }
- text_offset = text_offset + ebr_page_size;
- page_id_local = page_id;
- if (page_id_local > (EBR_RECORD_SIZE_MAX / ebr_page_size) * 2)
- {
- page_id_local =
- page_id_local - (EBR_RECORD_SIZE_MAX / ebr_page_size) * (g_curr_book_cntx_p->gcurrent_record_id - 1);
- }
- while (k != (page_id_local + count))
- {
- k++;
- }
- k = 0;
- offset = text_offset - 2 * (shared_bytes) + (page_id_local + count - 1) * ebr_page_size;
- book_mark_name = ebr_get_book_mark_name();
- pfnUnicodeStrcpy((S8*) bookMarkName, (S8*) book_mark_name);
- if (!book_mark_name[0])
- {
- ebr_app_display_pop_up_book_mark_name_empty();
- return;
- }
- i = 0;
- while (g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].bookmark_name[0] != 0)
- {
- if (!pfnUnicodeStrcmp
- ((const S8*)g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].bookmark_name, (const S8*)bookMarkName))
- {
- break;
- }
- i++;
- }
- if (i == EBR_FRM_MAX_NO_OF_BOOKMARKS)
- {
- /* Display Pop up that no more BookMarks can be added */
- ebr_app_display_pop_up_maximum_book_marks();
- }
- else
- {
- pfnUnicodeStrcpy((PS8) g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].bookmark_name, (PS8) bookMarkName);
- g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].page_id = page_id;
- g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].offset = text_offset_local;
- g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].shared_bytes = shared_bytes;
- g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].percentage_associated_with_book_mark =
- last_showed_percentage;
- nfo_hnd = FS_Open((const WCHAR*)g_curr_book_cntx_p->nfo_path, FS_READ_WRITE);
- 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);
- ebr_app_display_pop_up_book_mark_sucessfully_added();
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_record_for_bookmark
- * DESCRIPTION
- * Get record for BookMArk
- * PARAMETERS
- * selected_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_get_record_for_bookmark(U32 selected_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 filesize;
- S32 page_id = 0, offset = 0, record_id = 0, shared_bytes = 0, book_size;
- S16 ebr_page_size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- book_size = g_curr_book_cntx_p->g_nfo_book_struct.temp_book_size;
- }
- else
- {
- book_size = g_curr_book_cntx_p->g_nfo_book_struct.book_size;
- }
- if (g_curr_book_cntx_p->is_book_in_unicode || g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- ebr_page_size = EBR_PAGE_SIZE * 2;
- }
- else
- {
- ebr_page_size = EBR_PAGE_SIZE;
- }
- filesize = book_size;
- page_id = g_curr_book_cntx_p->g_nfo_book_struct.book_marks[selected_index].page_id;
- offset = g_curr_book_cntx_p->g_nfo_book_struct.book_marks[selected_index].offset;
- shared_bytes = g_curr_book_cntx_p->g_nfo_book_struct.book_marks[selected_index].shared_bytes;
- record_id = (ebr_page_size * page_id) / EBR_RECORD_SIZE_MAX;
- record_id++;
- if ((page_id % (EBR_RECORD_SIZE_MAX / ebr_page_size) > 2) &&
- page_id % (EBR_RECORD_SIZE_MAX / ebr_page_size) <= (EBR_RECORD_SIZE_MAX / ebr_page_size) - 2)
- {
- if (g_curr_book_cntx_p->gbook_type == EBR_FRM_FILE_TYPE_PDB)
- {
- if ((g_curr_book_cntx_p->num_records == record_id - 1) || (g_curr_book_cntx_p->num_records == record_id))
- {
- g_curr_book_cntx_p->gcurrent_record_id = g_curr_book_cntx_p->num_records - 1;
- g_curr_book_cntx_p->gnext_record_id = g_curr_book_cntx_p->gcurrent_record_id + 1;
- }
- else
- {
- g_curr_book_cntx_p->gcurrent_record_id = record_id;
- g_curr_book_cntx_p->gnext_record_id = g_curr_book_cntx_p->gcurrent_record_id + 1;
- }
- }
- else
- {
- g_curr_book_cntx_p->gcurrent_record_id = record_id;
- if (page_id * ebr_page_size + EBR_RECORD_SIZE_MAX > (S32) (book_size))
- {
- g_curr_book_cntx_p->gcurrent_record_id--;
- }
- g_curr_book_cntx_p->gnext_record_id = g_curr_book_cntx_p->gcurrent_record_id + 1;
- }
- }
- else
- {
- }
- if (page_id == 0)
- {
- g_curr_book_cntx_p->gcurrent_record_id = 1;
- g_curr_book_cntx_p->gnext_record_id = 2;
- }
- g_curr_book_cntx_p->g_start_id = page_id;
- g_curr_book_cntx_p->g_end_id = g_curr_book_cntx_p->g_start_id + 3;
- g_curr_book_cntx_p->g_nfo_book_struct.current_page_id = g_curr_book_cntx_p->g_start_id;
- g_curr_book_cntx_p->g_nfo_book_struct.offset = 0;
- g_curr_book_cntx_p->g_nfo_book_struct.jump_offset = g_curr_book_cntx_p->g_nfo_book_struct.book_marks[selected_index].offset;
- g_curr_book_cntx_p->g_nfo_book_struct.last_showed_percentage =
- g_curr_book_cntx_p->g_nfo_book_struct.book_marks[selected_index].percentage_associated_with_book_mark;
- ebr_frm_save_settings_in_nfo_file();
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_convert_page_id_to_record_id
- * DESCRIPTION
- * Get the record number on basis of page id
- * PARAMETERS
- * page_id [IN]
- * text_offset [IN]
- * shared_bytes [IN]
- * record_id [IN]
- * record_offset [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_convert_page_id_to_record_id(
- S32 page_id,
- S32 text_offset,
- S32 shared_bytes,
- S32 *record_id,
- S32 *record_offset)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 ebr_page_size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->is_book_in_unicode || g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- ebr_page_size = EBR_PAGE_SIZE * 2;
- }
- else
- {
- ebr_page_size = EBR_PAGE_SIZE;
- }
- text_offset = text_offset - shared_bytes;
- *record_id = (page_id / (EBR_RECORD_SIZE_MAX / ebr_page_size)) + 1;
- *record_offset =
- ((page_id - ((*record_id - 1) * EBR_RECORD_SIZE_MAX / ebr_page_size)) * EBR_PAGE_SIZE + text_offset) - 1;
- if (*record_offset > EBR_RECORD_SIZE_MAX / 2 && *record_id < g_curr_book_cntx_p->num_records)
- {
- ++(*record_id);
- *record_offset = *record_offset % (EBR_RECORD_SIZE_MAX / 2);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_start_search_timer
- * DESCRIPTION
- * Timer handler to continue searching
- * PARAMETERS
- * search_type [IN]
- * ebr_search_string_input [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_start_search_timer(void)
- {
- MMI_BOOL status;
- StopTimer(EBR_SEARCH_BLOCK_TIMER);
- /* if Ebook application is exited */
- if (!IsScreenPresent(EBOOK_OPEN_SCREENID))
- {
- return;
- }
- status = ebr_frm_search_string_algo(
- (ebr_app_search_type_enum) g_curr_book_cntx_p->ebr_last_search_type,
- (S8*) g_curr_book_cntx_p->ebr_last_search_string_input,
- MMI_TRUE);
- /* search not complete */
- if (status == 0xFF)
- {
- return;
- }
- /* string has been found */
- else if (status == 1)
- {
- if (!ebr_frm_get_auto_scroll_status())
- {
- gui_paging_reset_auto_scroll();
- }
- ebr_app_search_result_successful(g_curr_book_cntx_p->ebr_last_search_type);
- ebr_app_delete_upto_open_book_screen_id();
- GoBackHistory();
- ebr_frm_set_data_for_display();
- }
- /* string has been */
- else
- {
- if(status==2)
- {
- ebr_app_search_result_invalid();
- }
- else
- {
- ebr_app_search_result_unsucessfull();
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_search_string_algo
- * DESCRIPTION
- * String search algo
- * PARAMETERS
- * search_type [IN]
- * ebr_search_string_input [IN]
- * RETURNS
- * void
- *****************************************************************************/
- pBOOL ebr_frm_search_string_algo(ebr_app_search_type_enum search_type, S8 *ebr_search_string_input, MMI_BOOL timeout)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE nfo_hnd_local;
- FILE_HANDLE file_hnd;
- S32 ebr_search_from_offset = -1;
- S32 search_record_id = -1,search_from_record_id;
- U8 mmiEncoding = 0;
- U32 page_id;
- S32 text_offset, last_text_offset_y;
- S8 search_string_input[(EBR_MAX_STR_SEARCH_LENGTH + 1) * ENCODING_LENGTH], string_length = pfnUnicodeStrlen((const S8*)ebr_search_string_input);
- U8 shared_bytes;
- U8 last_showed_percentage;
- pBOOL search_status = 0;
- U32 size, count = 0;
- S16 ebr_page_size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->is_book_in_unicode || g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- ebr_page_size = EBR_PAGE_SIZE * 2;
- }
- else
- {
- ebr_page_size = EBR_PAGE_SIZE;
- }
- /* Need the file handle over here to open the boook and search in it */
- memset((void*)g_curr_book_cntx_p->start, 0, EBR_RECORD_SIZE_MAX * 2);
- pfnUnicodeStrcpy(search_string_input, ebr_search_string_input);
- wgui_paging_multiline_get_current_page(
- &page_id,
- &text_offset,
- &shared_bytes,
- &last_showed_percentage,
- &last_text_offset_y);
- /* continue searching for previous stop */
- if (timeout == MMI_TRUE)
- {
- search_record_id = g_curr_book_cntx_p->ebr_last_search_record_id;
- ebr_search_from_offset = g_curr_book_cntx_p->ebr_last_offset_string;
- }
- else if (g_curr_book_cntx_p->ebr_last_offset_string == -1)
- {
- ebr_frm_convert_page_id_to_record_id(
- page_id,
- text_offset,
- shared_bytes,
- &search_record_id,
- &ebr_search_from_offset);
- }
- else if (pfnUnicodeStrcmp(ebr_search_string_input, g_curr_book_cntx_p->ebr_last_search_string_input) != 0 ||
- g_curr_book_cntx_p->ebr_last_search_type != search_type)
- {
- ebr_frm_convert_page_id_to_record_id(
- page_id,
- text_offset,
- shared_bytes,
- &search_record_id,
- &ebr_search_from_offset);
- g_curr_book_cntx_p->find_next_first_flag = 0;
- g_curr_book_cntx_p->search_found_flag = 0;
- g_curr_book_cntx_p->search_string_count = 0;
- }
- else if (page_id != g_curr_book_cntx_p->ebr_last_page_id || g_curr_book_cntx_p->ebr_last_text_offset != text_offset)
- {
- ebr_frm_convert_page_id_to_record_id(
- page_id,
- text_offset,
- shared_bytes,
- &search_record_id,
- &ebr_search_from_offset);
- }
- else
- {
- search_record_id = g_curr_book_cntx_p->ebr_last_search_record_id;
- ebr_search_from_offset = g_curr_book_cntx_p->ebr_last_offset_string;
- }
- if (g_curr_book_cntx_p->find_next_first_flag == 0)
- {
- g_curr_book_cntx_p->find_next_first_flag = 1;
- g_curr_book_cntx_p->search_record_id_first = search_record_id;
- g_curr_book_cntx_p->ebr_search_from_offset_first = ebr_search_from_offset;
- }
- nfo_hnd_local = ebr_frm_get_nfo_handle();
- 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);
- }
- search_from_record_id = search_record_id;
- while (search_record_id <= g_curr_book_cntx_p->num_records)
- {
- /* Since MMI will be hung on Ebook searching process if the file size is too large, we search for some records and start a timer to continue. */
- count++;
- if (count > EBR_FRM_SEARCH_BLOCK)
- {
- g_curr_book_cntx_p->ebr_last_offset_string = -1;
- g_curr_book_cntx_p->ebr_last_search_record_id = search_record_id;
- g_curr_book_cntx_p->ebr_last_search_type = search_type;
- g_curr_book_cntx_p->ebr_search_from_offset_first = ebr_search_from_offset;
- pfnUnicodeStrcpy(g_curr_book_cntx_p->ebr_last_search_string_input, ebr_search_string_input);
- FS_Close(nfo_hnd_local);
- FS_Close(file_hnd);
- StartTimer(EBR_SEARCH_BLOCK_TIMER, EBR_FRM_SEARCH_BREAK_TIMER, ebr_frm_start_search_timer);
- /* Search not complete */
- return 0xFF;
- }
- if (string_length == 0)
- {
- search_status = 0;
- break;
- }
- memset((void*)g_curr_book_cntx_p->start, 0, EBR_RECORD_SIZE_MAX * 2);
- memset((void*)g_curr_book_cntx_p->buffer, 0, EBR_RECORD_SIZE_MAX);
- copy_record_in_passed_buffer(
- file_hnd,
- search_record_id,
- (U8*) g_curr_book_cntx_p->buffer,
- (U8*) g_curr_book_cntx_p->start,
- &size);
- mmiEncoding = mmi_ebook_util_get_chset(g_curr_book_cntx_p->g_nfo_book_struct.settings.encoding_format);
- switch (mmiEncoding)
- {
- case MMI_CHSET_UCS2:
- pfnUnicodeStrncpy(
- (PS8) g_curr_book_cntx_p->start,
- (PS8) g_curr_book_cntx_p->buffer,
- EBR_RECORD_SIZE_MAX);
- break;
- case MMI_CHSET_WESTERN_WIN:
- AnsiiNToUnicodeString(
- (PS8) g_curr_book_cntx_p->start,
- (PS8) g_curr_book_cntx_p->buffer,
- EBR_RECORD_SIZE_MAX);
- break;
- default:
- pfnUnicodeStrncpy(
- (PS8) g_curr_book_cntx_p->start,
- (PS8) g_curr_book_cntx_p->buffer,
- EBR_RECORD_SIZE_MAX);
- /* mmi_chset_convert ((mmi_chset_enum)mmiEncoding,MMI_CHSET_UCS2, (char*)g_curr_book_cntx_p->start, (char*)g_curr_book_cntx_p->buffer, EBR_RECORD_SIZE_MAX); */
- break;
- }
- if (search_type == EBR_APP_CASE_IN_SENSITIVE)
- {
- ebr_frm_convert_to_upper((S16*) g_curr_book_cntx_p->start);
- ebr_frm_convert_to_upper((S16*) search_string_input);
- }
- // if(ebr_search_from_offset==0)
- // ebr_search_from_offset=-1;
- search_status = ebr_frm_bm_search((S16*) g_curr_book_cntx_p->start, (S16*) search_string_input, &ebr_search_from_offset,size);
- if(search_status==2)
- {
- FS_Close(nfo_hnd_local);
- FS_Close(file_hnd);
- break;
- }
- if (search_status == 0)
- {
- if (g_curr_book_cntx_p->search_record_id_first == search_record_id &&
- g_curr_book_cntx_p->last_record_flag == 1 && g_curr_book_cntx_p->search_found_flag == 0)
- {
- g_curr_book_cntx_p->last_record_flag = 0;
- /* g_curr_book_cntx_p->find_next_first_flag=0; */
- break;
- }
- search_record_id++;
- ebr_search_from_offset = 0;
- /* When the total record of the file is 1, and search offset is not 0, we should still search from beginning of first record. */
- if((search_from_record_id==1) && (search_record_id == g_curr_book_cntx_p->num_records + 1) && (g_curr_book_cntx_p->num_records != 1))
- {
- g_curr_book_cntx_p->last_record_flag = 0;
- break;
- }
- if (search_record_id == g_curr_book_cntx_p->num_records + 1)
- {
- search_record_id = 1;
- search_from_record_id = search_record_id;
- g_curr_book_cntx_p->last_record_flag = 1;
- ebr_search_from_offset = -1;
- }
- }
- else
- {
- g_curr_book_cntx_p->search_found_flag = 1;
- if (g_curr_book_cntx_p->ebr_last_search_record_id == search_record_id &&
- g_curr_book_cntx_p->ebr_last_offset_string == ebr_search_from_offset &&
- g_curr_book_cntx_p->ebr_last_search_type == search_type &&
- string_length == g_curr_book_cntx_p->ebr_search_strlen &&
- page_id == g_curr_book_cntx_p->ebr_last_page_id &&
- g_curr_book_cntx_p->ebr_last_text_offset == text_offset)
- {
- search_status = 0;
- g_curr_book_cntx_p->last_record_flag = 0;
- g_curr_book_cntx_p->search_found_flag = 0;
- g_curr_book_cntx_p->search_string_count = 0;
- }
- else
- {
- g_curr_book_cntx_p->search_string_count++;
- /* if(g_curr_book_cntx_p->search_record_id_first==search_record_id && g_curr_book_cntx_p->last_record_flag==1 && ebr_search_from_offset > g_curr_book_cntx_p->ebr_search_from_offset_first)
- {
- g_curr_book_cntx_p->search_string_count=1;
- g_curr_book_cntx_p->last_record_flag=0;
- } */
- }
- break;
- }
- }
- if (search_status == 1)
- {
- g_curr_book_cntx_p->g_nfo_book_struct.current_page_id =
- (search_record_id - 1) * EBR_RECORD_SIZE_MAX / ebr_page_size + ((ebr_search_from_offset) / EBR_PAGE_SIZE);
- if (g_curr_book_cntx_p->g_nfo_book_struct.current_page_id == 0)
- {
- g_curr_book_cntx_p->g_nfo_book_struct.jump_offset = ebr_search_from_offset;
- }
- else
- {
- g_curr_book_cntx_p->g_nfo_book_struct.current_page_id--;
- g_curr_book_cntx_p->g_nfo_book_struct.jump_offset =
- (ebr_search_from_offset) % EBR_PAGE_SIZE + EBR_PAGE_SIZE;
- }
- g_curr_book_cntx_p->g_nfo_book_struct.offset = 0;
- FS_Seek(nfo_hnd_local, 0, FS_FILE_BEGIN);
- 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);
- g_curr_book_cntx_p->ebr_search_strlen = pfnUnicodeStrlen((const S8*)ebr_search_string_input);
- g_curr_book_cntx_p->highlight_string_flag = 1;
- g_curr_book_cntx_p->ebr_last_search_record_id = search_record_id;
- g_curr_book_cntx_p->ebr_last_search_type = search_type;
- g_curr_book_cntx_p->ebr_last_offset_string = ebr_search_from_offset;
- g_curr_book_cntx_p->ebr_last_page_id = page_id;
- g_curr_book_cntx_p->ebr_last_text_offset = text_offset;
- pfnUnicodeStrcpy(g_curr_book_cntx_p->ebr_last_search_string_input, ebr_search_string_input);
- g_curr_book_cntx_p->search_flag_is_on = 1;
- /* g_curr_book_cntx_p->search_found_flag=0; */
- }
- else
- {
- g_curr_book_cntx_p->ebr_last_offset_string = -1;
- /* g_curr_book_cntx_p->ebr_last_offset_string=ebr_search_from_offset; */
- g_curr_book_cntx_p->ebr_last_page_id = page_id;
- g_curr_book_cntx_p->ebr_last_text_offset = text_offset;
- g_curr_book_cntx_p->ebr_last_search_type = search_type;
- pfnUnicodeStrcpy(g_curr_book_cntx_p->ebr_last_search_string_input, ebr_search_string_input);
- g_curr_book_cntx_p->search_flag_is_on = 0;
- /* g_curr_book_cntx_p->search_found_flag=0; */
- }
- FS_Close(nfo_hnd_local);
- FS_Close(file_hnd);
- return search_status;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_search_string_algo_find_next
- * DESCRIPTION
- * String search algo for find next
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- pBOOL ebr_frm_search_string_algo_find_next(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- pBOOL search_status;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->find_next_flag = TRUE;
- search_status = ebr_frm_search_string_algo(
- (ebr_app_search_type_enum) g_curr_book_cntx_p->ebr_last_search_type,
- (S8*) g_curr_book_cntx_p->ebr_last_search_string_input,
- MMI_FALSE);
- g_curr_book_cntx_p->find_next_flag = FALSE;
- return search_status;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_set_data_for_display
- * DESCRIPTION
- * get the current position from GUI
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_set_data_for_display(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 shared_bytes;
- S32 last_text_offset_y;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- wgui_paging_multiline_get_current_page(
- &g_curr_book_cntx_p->last_displayed_page_id,
- &g_curr_book_cntx_p->last_displayed_offset,
- &shared_bytes,
- &g_curr_book_cntx_p->g_nfo_book_struct.last_showed_percentage,
- &last_text_offset_y);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_reset_for_new_book
- * DESCRIPTION
- * Reset the values for a new file.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- ebr_frm_nfo_create_type_errors_enum ebr_frm_reset_for_new_book(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- ebr_frm_nfo_create_type_errors_enum error_type = EBR_FRM_NFO_CREATE_SUCCESS;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->ebr_frm_end_book_flag = 1;
- g_curr_book_cntx_p->is_book_in_unicode = FALSE;
- g_curr_book_cntx_p->book_is_in_other_encoding_format = FALSE;
- g_curr_book_cntx_p->pdb_converted_to_text = FALSE;
- ebr_frm_reset_find_next_data();
- ebr_frm_set_file_type();
- if (!g_curr_book_cntx_p->src_application)
- {
- if (g_curr_book_cntx_p->gbook_type == EBR_FRM_FILE_TYPE_PDB)
- {
- error_type = ebr_frm_open_book_create_nfo_file_pdb(g_curr_book_cntx_p->nfo_name);
- }
- else
- {
- error_type = ebr_frm_open_book_create_nfo_file_txt(g_curr_book_cntx_p->nfo_name);
- }
- g_curr_book_cntx_p->src_application = EBR_FRM_SRC_APP_EBOOK;
- }
- return error_type;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_set_file_type
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_set_file_type(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 strlen_file_name = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- strlen_file_name = pfnUnicodeStrlen((const S8*)g_curr_book_cntx_p->nfo_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->gbook_type = EBR_FRM_FILE_TYPE_TXT;
- }
- else
- {
- g_curr_book_cntx_p->gbook_type = EBR_FRM_FILE_TYPE_PDB;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_convert_to_upper
- * DESCRIPTION
- * CCase Conversion
- * PARAMETERS
- * decoded_buffer [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_convert_to_upper(S16 *decoded_buffer)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 length, i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- length = pfnUnicodeStrlen((const S8*)decoded_buffer);
- for (i = 0; i < length; i++)
- {
- if ((decoded_buffer[i] >= 97) && (decoded_buffer[i] <= 122))
- {
- decoded_buffer[i] = decoded_buffer[i] - 32;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_bm_search
- * DESCRIPTION
- * Search Algo
- * PARAMETERS
- * text_in_UCS2 [IN]
- * pat [IN]
- * start_pos [IN]
- * RETURNS
- * void
- *****************************************************************************/
- S16 ebr_frm_bm_search(S16 *text_in_UCS2, S16 *pat, S32 *start_pos,U32 size)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 i;
- S32 len = pfnUnicodeStrlen((const S8*)pat);
- S32 temp, temp1, temp2, buffer_length = pfnUnicodeStrlen((const S8*)text_in_UCS2);
- S32 start = len - 1 + (*start_pos + 1);
- S16 pos_array[32] = {0};
- S16 char_position_in_UCS2, char_position_in_ascii;
- S32 clus_len = 1;
- S32 s_size = size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Remove ' ' */
- for(s_size = s_size/2 - 1; s_size >= 0; s_size--)
- {
- if (text_in_UCS2[s_size] != 0)
- {
- break;
- }
- }
- /* Set length of text */
- s_size++;
- if (s_size-6 > 0)
- {
- if(buffer_length < (s_size-6) ) /* txt file with end with "00 00 00 00 00 00 00 00 F2 F2 F2 F2"*/
- {
- return 2;
- }
- }
- for (i = 0; i < len; i++)
- {
- pos_array[i] = len - ((i) + 1);
- }
- temp = len - 1; /* it is taken to remove the need of table */
- temp2 = temp1 = len - 2;
- while (temp >= 0)
- {
- while (temp1 >= 0)
- {
- if (pat[temp] != pat[temp1])
- {
- temp1--;
- }
- else
- {
- pos_array[temp1] = pos_array[temp];
- temp1--;
- }
- }
- temp1 = temp2 - 1;
- temp--;
- }
- while (start < buffer_length)
- {
- S32 count = 0, prev_start = 0;
- while (count < len)
- {
- if (text_in_UCS2[start - count] != pat[(len - 1) - count])
- {
- break;
- }
- else
- {
- count++;
- }
- }
- #ifdef __MMI_LANG_HINDI__
- if (count == len)
- {
- U16 cluster_buffer[EBR_MAX_STR_SEARCH_LENGTH]; /* just to fill the cluster for the purpose of getting its length */
- clus_len = 0;
- init_cluster_start_p((PU8) (text_in_UCS2 + start));
- init_cluster_end_p((PU8) (text_in_UCS2 + (EBR_MAX_STR_SEARCH_LENGTH / 2)));
- clus_len = hf_get_cluster(cluster_buffer);
- }
- #endif /* __MMI_LANG_HINDI__ */
- if (count == len && clus_len == 1)
- {
- *start_pos = (start - count + 1);
- break;
- }
- else
- {
- char_position_in_UCS2 = 0;
- char_position_in_ascii = 0;
- prev_start = start;
- while (char_position_in_ascii < len && text_in_UCS2[start - count] != pat[char_position_in_UCS2])
- {
- char_position_in_UCS2++;
- char_position_in_ascii++;
- }
- if (text_in_UCS2[start - count] == pat[char_position_in_UCS2])
- {
- if (pos_array[char_position_in_ascii] - count < 0)
- {
- start += len;
- }
- else
- {
- start += (pos_array[char_position_in_ascii] - count);
- }
- }
- else
- {
- start += (len - count);
- }
- if (prev_start == start)
- {
- start += len;
- }
- }
- }
- if (start >= buffer_length)
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_paging_multiline_input_box_get_page
- * DESCRIPTION
- * Create the linked list
- * PARAMETERS
- * start_id [IN]
- * end_id [IN]
- * buffer_local [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_paging_multiline_input_box_get_page(U32 start_id, U32 end_id, PU8 buffer_local)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* Code Implementation to get the next page */
- U8 mmiEncoding = 0;
- S32 buffer_length;
- S16 ebr_page_size;
- U8* buffer_start;
- U8 UCS2headerle[] = {0xFF,0xFE};
- U8 UCS2headerbe[] = {0xFE,0xFF};
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->g_start_id = start_id;
- g_curr_book_cntx_p->g_end_id = end_id;
- ebr_frm_get_record(end_id);
- if (g_curr_book_cntx_p->is_book_in_unicode || g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- ebr_page_size = EBR_PAGE_SIZE * 2;
- }
- else
- {
- ebr_page_size = EBR_PAGE_SIZE;
- }
- end_id -= (EBR_RECORD_SIZE_MAX / (ebr_page_size)) * (g_curr_book_cntx_p->gcurrent_record_id - 1);
- memset(g_curr_book_cntx_p->buffer, 0, EBR_RECORD_SIZE_MAX);
- memcpy(g_curr_book_cntx_p->buffer, g_curr_book_cntx_p->start + ebr_page_size * (end_id), ebr_page_size);
- mmiEncoding = mmi_ebook_util_get_chset(g_curr_book_cntx_p->g_nfo_book_struct.settings.encoding_format);
- if ((mmiEncoding == MMI_CHSET_UCS2 || g_curr_book_cntx_p->book_is_in_other_encoding_format) && g_curr_book_cntx_p->g_start_id == 0)
- {
- buffer_start = g_curr_book_cntx_p->buffer;
- while (!pfnUnicodeStrncmp((S8*)buffer_start, (S8*)UCS2headerle,1))
- {
- buffer_start[0] = WHITE_SPACE;
- buffer_start[1] = 0;
- buffer_start += 2;
- }
- while (!pfnUnicodeStrncmp((S8*)buffer_start, (S8*)UCS2headerbe,1))
- {
- buffer_start[0] = WHITE_SPACE;
- buffer_start[1] = 0;
- buffer_start += 2;
- }
- }
- memset(buffer_local, 0, EBR_PAGE_SIZE * 2);
- switch (mmiEncoding)
- {
- case MMI_CHSET_UCS2:
- if (g_curr_book_cntx_p->is_book_in_unicode)
- {
- memcpy(buffer_local, g_curr_book_cntx_p->buffer, ebr_page_size);
- }
- else
- {
- pfnUnicodeStrncpy((PS8) buffer_local, (PS8) g_curr_book_cntx_p->buffer, ebr_page_size);
- }
- break;
- case MMI_CHSET_WESTERN_WIN:
- AnsiiNToUnicodeString((PS8) buffer_local, (PS8) g_curr_book_cntx_p->buffer, ebr_page_size);
- break;
- default:
- if (g_curr_book_cntx_p->is_book_in_unicode)
- {
- /* memset(g_curr_book_cntx_p->page_buffer,0,EBR_PAGE_SIZE*2); */
- buffer_length = mmi_chset_convert(
- (mmi_chset_enum) mmiEncoding,
- MMI_CHSET_UCS2,
- (char*)g_curr_book_cntx_p->buffer,
- (char*)buffer_local,
- ebr_page_size);
- /* memcpy(buffer_local,g_curr_book_cntx_p->page_buffer,buffer_length); */
- }
- else
- //AnsiiNToUnicodeString((PS8)buffer_local,(PS8)g_curr_book_cntx_p->buffer,ebr_page_size);
- //pfnUnicodeStrncpy((PS8)buffer_local,(PS8)g_curr_book_cntx_p->buffer,ebr_page_size);
- {
- memcpy(buffer_local, g_curr_book_cntx_p->buffer, ebr_page_size);
- /* pfnUnicodeStrncpy((PS8) buffer_local, (PS8) g_curr_book_cntx_p->buffer, ebr_page_size); */
- }
- break;
- }
- buffer_length = pfnUnicodeStrlen((const S8*)buffer_local);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_ebook_util_get_chset
- * DESCRIPTION
- * Get the encoding scheme
- * PARAMETERS
- * src_chset [IN]
- * RETURNS
- * U8
- *****************************************************************************/
- U8 mmi_ebook_util_get_chset(U8 src_chset)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (src_chset)
- {
- case EBOOK_UCS:
- return MMI_CHSET_UCS2;
- case EBOOK_UTF8:
- return MMI_CHSET_UTF8;
- #ifdef __MMI_CHSET_BIG5__
- case EBOOK_BIG5:
- return MMI_CHSET_BIG5;
- #endif /* __MMI_CHSET_BIG5__ */
- #ifdef __MMI_CHSET_GB2312__
- case EBOOK_GB2312:
- return MMI_CHSET_GB2312;
- #endif /* __MMI_CHSET_GB2312__ */
- #ifdef __MMI_CHSET_ARABIC_ISO__
- case EBOOK_ARABIC_ISO:
- return MMI_CHSET_ARABIC_ISO;
- #endif /* __MMI_CHSET_ARABIC_ISO__ */
- #ifdef __MMI_CHSET_ARABIC_WIN__
- case EBOOK_ARABIC_WINDOWS:
- return MMI_CHSET_ARABIC_WIN;
- #endif /* __MMI_CHSET_ARABIC_WIN__ */
- #ifdef __MMI_CHSET_BALTIC_ISO__
- case EBOOK_BALTIC_ISO:
- return MMI_CHSET_BALTIC_ISO;
- #endif /* __MMI_CHSET_BALTIC_ISO__ */
- #ifdef __MMI_CHSET_BALTIC_WIN__
- case EBOOK_BALTIC_WINDOWS:
- return MMI_CHSET_BALTIC_WIN;
- #endif /* __MMI_CHSET_BALTIC_WIN__ */
- #ifdef __MMI_CHSET_CEURO_ISO__
- case EBOOK_CENTRAL_EUROPEAN_ISO:
- return MMI_CHSET_CEURO_ISO;
- #endif /* __MMI_CHSET_CEURO_ISO__ */
- #ifdef __MMI_CHSET_CEURO_WIN__
- case EBOOK_CENTRAL_EUROPEAN_WINDOWS:
- return MMI_CHSET_CEURO_WIN;
- #endif /* __MMI_CHSET_CEURO_WIN__ */
- #ifdef __MMI_CHSET_GREEK_ISO__
- case EBOOK_GREEK_ISO:
- return MMI_CHSET_GREEK_ISO;
- #endif /* __MMI_CHSET_GREEK_ISO__ */
- #ifdef __MMI_CHSET_GREEK_WIN__
- case EBOOK_GREEK_WINDOWS:
- return MMI_CHSET_GREEK_WIN;
- #endif /* __MMI_CHSET_GREEK_WIN__ */
- #ifdef __MMI_CHSET_HEBREW_ISO__
- case EBOOK_HEBREW_ISO:
- return MMI_CHSET_HEBREW_ISO;
- #endif /* __MMI_CHSET_HEBREW_ISO__ */
- #ifdef __MMI_CHSET_HEBREW_WIN__
- case EBOOK_HEBREW_WINDOWS:
- return MMI_CHSET_HEBREW_WIN;
- #endif /* __MMI_CHSET_HEBREW_WIN__ */
- #ifdef __MMI_CHSET_LATIN_ISO__
- case EBOOK_LATIN_ISO:
- return MMI_CHSET_LATIN_ISO;
- #endif /* __MMI_CHSET_LATIN_ISO__ */
- #ifdef __MMI_CHSET_NORDIC_ISO__
- case EBOOK_NORDIC_ISO:
- return MMI_CHSET_NORDIC_ISO;
- #endif /* __MMI_CHSET_NORDIC_ISO__ */
- #ifdef __MMI_CHSET_SEURO_ISO__
- case EBOOK_SOURTH_EUROPEAN_ISO:
- return MMI_CHSET_SEURO_ISO;
- #endif /* __MMI_CHSET_SEURO_ISO__ */
- #ifdef __MMI_CHSET_TURKISH_ISO__
- case EBOOK_TURKISH_ISO:
- return MMI_CHSET_TURKISH_ISO;
- #endif /* __MMI_CHSET_TURKISH_ISO__ */
- #ifdef __MMI_CHSET_TURKISH_WIN__
- case EBOOK_TURKISH_WINDOWS:
- return MMI_CHSET_TURKISH_WIN;
- #endif /* __MMI_CHSET_TURKISH_WIN__ */
- #ifdef __MMI_CHSET_WESTERN_ISO__
- case EBOOK_WESTERN_ISO:
- return MMI_CHSET_WESTERN_ISO;
- #endif /* __MMI_CHSET_WESTERN_ISO__ */
- #ifdef __MMI_CHSET_WESTERN_WIN__
- case EBOOK_WESTERN_WINDOWS:
- return MMI_CHSET_WESTERN_WIN;
- #endif /* __MMI_CHSET_WESTERN_WIN__ */
- #ifdef __MMI_CHSET_GB18030__
- case EBOOK_GB:
- return MMI_CHSET_GB18030;
- #endif /* __MMI_CHSET_GB18030__ */
- default:
- return MMI_CHSET_TOTAL; /* unsupported charset */
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_delete_ebook
- * DESCRIPTION
- * Delete the book.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- S32 ebr_frm_delete_ebook()
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 nfo_path[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH] = {0};
- S32 retval_book,retval_nfo = 0;
- S32 local_nfo_id;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Delete PDB/TXT File */
- if (g_curr_book_cntx_p->gbook_type == EBR_FRM_FILE_TYPE_PDB)
- {
- local_nfo_id = ebr_fmgr_get_nfo_id_for_pdb_file(
- g_curr_book_cntx_p->memory_type_selected,
- (PS8) g_curr_book_cntx_p->nfo_name);
- }
- else
- {
- local_nfo_id = ebr_fmgr_get_nfo_id_for_txt_file(
- g_curr_book_cntx_p->memory_type_selected,
- (PS8) g_curr_book_cntx_p->nfo_name);
- }
- if (local_nfo_id > 0)
- {
- pfnUnicodeStrcpy((S8*) nfo_path, (PS8) ebr_frm_get_nfo_file_name(local_nfo_id));
- }
- retval_nfo = FS_Delete((const WCHAR*)nfo_path);
- pfnUnicodeStrcpy(
- (S8*) nfo_path,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((PS8) nfo_path, (PS8) g_curr_book_cntx_p->nfo_name);
- retval_book = FS_Delete((const WCHAR*)nfo_path);
- return retval_book;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_save_settings_in_nfo_file
- * DESCRIPTION
- * Save settings in Nfo file.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_save_settings_in_nfo_file()
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 size;
- S32 retval;
- FILE_HANDLE nfo_hnd;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nfo_hnd = FS_Open((const WCHAR*)g_curr_book_cntx_p->nfo_path, FS_READ_WRITE);
- 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_close_the_ebook
- * DESCRIPTION
- * Variable set before closing the book
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- U8 ebr_frm_close_ebook = 0;
- void ebr_frm_close_the_ebook(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ebr_frm_close_ebook = 1;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_ebook_exit
- * DESCRIPTION
- * Close the book and exit
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- pBOOL ebr_frm_ebook_exit(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 local_nfo_id;
- S16 highlight_id;
- U32 size;
- U32 page_id;
- S32 text_offset;
- U8 shared_bytes;
- U8 last_showed_percentage;
- S32 last_text_offset_y;
- S32 retval;
- FILE_HANDLE nfo_hnd;
- S16 error;
- static pBOOL is_src_app_file_manager = FALSE;
- S16 ebr_page_size, auto_scroll_staus;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- is_src_app_file_manager = FALSE;
- if (g_curr_book_cntx_p->state_recursive_conversion != EBR_FRM_NFO_CONVERSION_COMPLETED)
- {
- auto_scroll_staus = ebr_frm_get_auto_scroll_flag_status();
- if (auto_scroll_staus)
- {
- TurnOffBacklight();
- }
- if (g_curr_book_cntx_p->is_book_in_unicode || g_curr_book_cntx_p->book_is_in_other_encoding_format)
- {
- ebr_page_size = EBR_PAGE_SIZE * 2;
- }
- else
- {
- ebr_page_size = EBR_PAGE_SIZE;
- }
- if (g_curr_book_cntx_p->state_recursive_conversion != EBR_FRM_CONVERSION_UNDERWAY)
- {
- wgui_paging_multiline_get_current_page(
- &page_id,
- &text_offset,
- &shared_bytes,
- &last_showed_percentage,
- &last_text_offset_y);
- g_curr_book_cntx_p->g_nfo_book_struct.offset = text_offset;
- g_curr_book_cntx_p->g_nfo_book_struct.current_page_id = page_id;
- g_curr_book_cntx_p->g_nfo_book_struct.last_showed_percentage = last_showed_percentage;
- g_curr_book_cntx_p->g_nfo_book_struct.jump_offset = 0;
- g_curr_book_cntx_p->g_nfo_book_struct.last_text_offset_y = last_text_offset_y;
- }
- else
- {
- g_curr_book_cntx_p->g_nfo_book_struct.offset = 0;
- g_curr_book_cntx_p->g_nfo_book_struct.current_page_id = 0;
- g_curr_book_cntx_p->g_nfo_book_struct.last_showed_percentage = 0;
- g_curr_book_cntx_p->g_nfo_book_struct.jump_offset = 0;
- g_curr_book_cntx_p->g_nfo_book_struct.last_text_offset_y = 0;
- }
- g_curr_book_cntx_p->src_application = ebr_frm_fmgr_get_application_type();
- if (g_curr_book_cntx_p->src_application != EBR_FRM_SRC_APP_FMGR)
- {
- g_curr_book_cntx_p->g_last_nfo_id_allocated = 0;
- ReadValue(NVRAM_EBOOK_NFO_LID, (void*)&local_nfo_id, DS_SHORT, &error);
- if (local_nfo_id > 0)
- {
- if (ebr_frm_close_ebook)
- {
- local_nfo_id = 0;
- highlight_id = 0;
- WriteValue(NVRAM_EBOOK_NFO_LID, (void*)&local_nfo_id, DS_SHORT, &error);
- WriteValue(
- NVRAM_EBOOK_LAST_HIGHLIGHT_ID,
- (void*)&g_curr_book_cntx_p->current_highlight_book_id,
- DS_SHORT,
- &error);
- ebr_frm_close_ebook = 0;
- }
- else
- {
- WriteValue(
- NVRAM_EBOOK_LAST_HIGHLIGHT_ID,
- (void*)&g_curr_book_cntx_p->current_highlight_book_id,
- DS_SHORT,
- &error);
- }
- }
- else
- {
- local_nfo_id = 0;
- WriteValue(NVRAM_EBOOK_NFO_LID, (void*)&local_nfo_id, DS_SHORT, &error);
- }
- }
- else
- {
- is_src_app_file_manager = TRUE;
- }
- nfo_hnd = FS_Open((const WCHAR*)g_curr_book_cntx_p->nfo_path, FS_READ_WRITE);
- if (nfo_hnd > 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);
- FS_Close(nfo_hnd);
- }
- }
- else
- {
- if (g_curr_book_cntx_p->src_application != EBR_FRM_SRC_APP_FMGR)
- {
- is_src_app_file_manager = FALSE;
- }
- else
- {
- is_src_app_file_manager = TRUE;
- }
- }
- return is_src_app_file_manager;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_set_find_next_flag
- * DESCRIPTION
- * Clears flags for find next on scrolling
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_set_find_next_flag(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->status_for_resetting_find_next_data = TRUE;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_book_type
- * DESCRIPTION
- * Gets the type of the book
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- U8 *ebr_frm_get_book_type(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- static U8 type[EBR_DISPLAY_INFO_DATA * ENCODING_LENGTH];
- S32 strlen_file_name;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- strlen_file_name = pfnUnicodeStrlen((const S8*)g_curr_book_cntx_p->nfo_name);
- if (g_curr_book_cntx_p->nfo_name[strlen_file_name * 2 - 6] == 'p' ||
- g_curr_book_cntx_p->nfo_name[strlen_file_name * 2 - 6] == 'P')
- {
- g_curr_book_cntx_p->gbook_type = EBR_FRM_FILE_TYPE_PDB;
- }
- else
- {
- g_curr_book_cntx_p->gbook_type = EBR_FRM_FILE_TYPE_TXT;
- }
- if (g_curr_book_cntx_p->gbook_type == EBR_FRM_FILE_TYPE_PDB)
- {
- strcpy((char*)type, (const char*)"PDB");
- }
- else
- {
- strcpy((char*)type, (const char*)"TXT");
- }
- return type;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_read_from_nvram
- * DESCRIPTION
- * Get the default value from NVRAM
- * PARAMETERS
- * void
- * RETURNS
- * S32
- *****************************************************************************/
- S32 ebr_frm_read_from_nvram()
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 local_nfo_id;
- S16 error;
- MMI_BOOL status;
- FILE_HANDLE nfo_hnd_local;
- ebr_frm_setting_struct g_setting;
- ebr_frm_setting_struct *g_setting_list = &g_setting;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadValue(NVRAM_EBOOK_NFO_LID, (void*)&local_nfo_id, DS_SHORT, &error);
- ReadRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- status = mmi_fmgr_is_drive_letter_valid(g_setting_list->memory_type);
- if (status && FS_GetDevStatus((UINT)g_setting_list->memory_type, FS_MOUNT_STATE_ENUM) != FS_NO_ERROR)
- {
- status = MMI_FALSE;
- }
- if (status == MMI_TRUE)
- {
- g_curr_book_cntx_p->memory_type_selected = g_setting_list->memory_type;
- }
- else
- {
- g_curr_book_cntx_p->memory_type_selected = (U8)MMI_PUBLIC_DRV;
- }
- pfnUnicodeStrcpy((S8*) g_curr_book_cntx_p->nfo_path, (PS8) ebr_frm_get_nfo_file_name(local_nfo_id));
- nfo_hnd_local = FS_Open((const WCHAR*)g_curr_book_cntx_p->nfo_path, FS_READ_WRITE);
- if (nfo_hnd_local < 0)
- {
- local_nfo_id = 0;
- WriteValue(NVRAM_EBOOK_NFO_LID, (void*)&local_nfo_id, DS_SHORT, &error);
- }
- FS_Close(nfo_hnd_local);
- return local_nfo_id;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_rwrite_into_nvram
- * DESCRIPTION
- * Write Nfo id in NVRAM
- * PARAMETERS
- * local_nfo_id [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_rwrite_into_nvram(S16 local_nfo_id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- WriteValue(NVRAM_EBOOK_NFO_LID, (void*)&local_nfo_id, DS_SHORT, &error);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_write_settings_in_nvram
- * DESCRIPTION
- * Write settings in NVRAM
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_write_settings_in_nvram()
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- ebr_frm_setting_struct g_setting;
- ebr_frm_setting_struct *g_setting_list = &g_setting;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_setting_list->common_settings = g_curr_book_cntx_p->g_nfo_book_struct.settings;
- g_setting_list->memory_type = g_curr_book_cntx_p->g_nfo_book_struct.memory_type;
- WriteRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_default_settings_value
- * DESCRIPTION
- * get the default settings value
- * PARAMETERS
- * g_ebookset_cntx_p [IN]
- * ebr_set_local_setting_flag [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_get_default_settings_value(EBOOKSET_CNTX *g_ebookset_cntx_p, S16 ebr_set_local_setting_flag)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- MMI_BOOL status;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (ebr_set_local_setting_flag == 1)
- {
- g_ebookset_cntx_p->inlineHighligtItemFontStyle = g_curr_book_cntx_p->g_nfo_book_struct.settings.font_style;
- g_ebookset_cntx_p->inlineHighligtItemFontSize = g_curr_book_cntx_p->g_nfo_book_struct.settings.font_size;
- g_ebookset_cntx_p->inlineHighligtItemScrollBy =
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_type;
- g_ebookset_cntx_p->inlineHighligtItemAutoScroll =
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_flag;
- g_ebookset_cntx_p->inlineHighligtItemScrollSpeed =
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_speed;
- g_ebookset_cntx_p->inlineHighligtItemFulScreenMode = g_curr_book_cntx_p->g_nfo_book_struct.settings.screen_mode;
- g_ebookset_cntx_p->inlineHighligtItemEncodingFormat =
- g_curr_book_cntx_p->g_nfo_book_struct.settings.encoding_format;
- }
- else
- {
- ebr_frm_setting_struct g_setting;
- ebr_frm_setting_struct *g_setting_list = &g_setting;
- ReadRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- g_ebookset_cntx_p->inlineHighligtItemEncodingFormat = g_setting_list->common_settings.encoding_format;
- g_ebookset_cntx_p->inlineHighligtItemFontSize = g_setting_list->common_settings.font_size;
- g_ebookset_cntx_p->inlineHighligtItemFontStyle = g_setting_list->common_settings.font_style;
- g_ebookset_cntx_p->inlineHighligtItemFulScreenMode = g_setting_list->common_settings.screen_mode;
- g_ebookset_cntx_p->inlineHighligtItemAutoScroll =
- g_setting_list->common_settings.auto_scroll_settings.scroll_flag;
- g_ebookset_cntx_p->inlineHighligtItemScrollSpeed =
- g_setting_list->common_settings.auto_scroll_settings.scroll_speed;
- g_ebookset_cntx_p->inlineHighligtItemScrollBy =
- g_setting_list->common_settings.auto_scroll_settings.scroll_type;
- /* memory type */
- status = mmi_fmgr_is_drive_letter_valid(g_setting_list->memory_type);
- if (status && FS_GetDevStatus((UINT)g_setting_list->memory_type, FS_MOUNT_STATE_ENUM) != FS_NO_ERROR)
- {
- status = MMI_FALSE;
- }
- if (status == MMI_TRUE)
- {
- g_ebookset_cntx_p->inlineHighligtItemSelectMemory = g_setting_list->memory_type;
- }
- else
- {
- g_ebookset_cntx_p->inlineHighligtItemSelectMemory = (U8)MMI_PUBLIC_DRV;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_save_settings_screen_mode
- * DESCRIPTION
- * save the screen mode in NFO
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- S32 ebr_frm_save_settings_screen_mode(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 size;
- S32 retval;
- FILE_HANDLE nfo_hnd;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->g_nfo_book_struct.settings.screen_mode == 0)
- {
- g_curr_book_cntx_p->g_nfo_book_struct.settings.screen_mode = 1;
- }
- else
- {
- g_curr_book_cntx_p->g_nfo_book_struct.settings.screen_mode = 0;
- }
- nfo_hnd = FS_Open((const WCHAR*)g_curr_book_cntx_p->nfo_path, FS_READ_WRITE);
- 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);
- return g_curr_book_cntx_p->g_nfo_book_struct.settings.screen_mode;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_save_settings_scroll
- * DESCRIPTION
- * save the scroll settings in NFO
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- S32 ebr_frm_save_settings_scroll(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 size;
- S32 retval;
- FILE_HANDLE nfo_hnd;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_flag == 0)
- {
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_flag = 1;
- }
- else
- {
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_flag = 0;
- }
- nfo_hnd = FS_Open((const WCHAR*)g_curr_book_cntx_p->nfo_path, FS_READ_WRITE);
- 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);
- return g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_flag;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_get_nfo_id_for_txt_file
- * DESCRIPTION
- * Ge the nfo id for Text File
- * PARAMETERS
- * drive_type [IN]
- * file_name [IN]
- * RETURNS
- * S32
- *****************************************************************************/
- S32 ebr_fmgr_get_nfo_id_for_txt_file(S8 drive_type, PS8 file_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE file_hnd;
- U32 size;
- U8 ebook_file_name[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH] = {0};
- U8 tmp_str[MAX_EBOOK_NAME_LENGTH] = {0};
- U8 end_footer_buffer[TXT_FOOTER_END_SIZE];
- U8 start_footer_buffer[TXT_FOOTER_START_SIZE];
- S32 local_nfo_id = 0;
- S32 file_size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->memory_type_selected = drive_type;
- pfnUnicodeStrcpy((S8*) ebook_file_name, (S8*) ebr_frm_get_file_path(drive_type, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((PS8) ebook_file_name, (PS8) file_name);
- file_hnd = FS_Open((const WCHAR*)ebook_file_name, FS_READ_ONLY);
- FS_GetFileSize(file_hnd, (U32*) & file_size);
- if (file_hnd > 0)
- {
- if (FS_Seek(file_hnd, -TXT_FOOTER_END_SIZE, FS_FILE_END) != FS_INVALID_FILE_POS)
- {
- FS_Read(file_hnd, end_footer_buffer, TXT_FOOTER_END_SIZE, &size);
- }
- else
- {
- memset(end_footer_buffer, 0, sizeof(end_footer_buffer));
- }
- if (FS_Seek(file_hnd, -TXT_FOOTER_START_SIZE - TXT_FOOTER_END_SIZE - MAX_EBOOK_NAME_LENGTH, FS_FILE_END) !=
- FS_INVALID_FILE_POS)
- {
- FS_Read(file_hnd, start_footer_buffer, TXT_FOOTER_START_SIZE, &size);
- }
- else
- {
- memset(start_footer_buffer, 0, sizeof(start_footer_buffer));
- }
- if (strncmp((PS8) end_footer_buffer, (PS8) EBR_TXT_FOOTER_END, TXT_FOOTER_END_SIZE) == 0 &&
- strncmp((PS8) start_footer_buffer, (PS8) EBR_TXT_FOOTER_START, TXT_FOOTER_START_SIZE) == 0)
- {
- FS_Read(file_hnd, tmp_str, MAX_EBOOK_NAME_LENGTH, &size);
- local_nfo_id = atoi((const char*)tmp_str);
- }
- FS_Close(file_hnd);
- return local_nfo_id;
- }
- return 0;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_get_nfo_id_for_pdb_file
- * DESCRIPTION
- * Ge the nfo id for PDB File
- * PARAMETERS
- * drive_type [IN]
- * file_name [IN]
- * RETURNS
- * S32
- *****************************************************************************/
- S32 ebr_fmgr_get_nfo_id_for_pdb_file(S8 drive_type, PS8 file_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE file_hnd;
- U32 size;
- ebr_frm_database_hdr_type file_header;
- U8 ebook_file_name[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH] = {0};
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->memory_type_selected = drive_type;
- pfnUnicodeStrcpy((S8*) ebook_file_name, (S8*) ebr_frm_get_file_path(drive_type, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((PS8) ebook_file_name, (PS8) file_name);
- file_hnd = FS_Open((const WCHAR*)ebook_file_name, FS_READ_ONLY);
- if (file_hnd > 0)
- {
- if (FS_Read(file_hnd, &file_header, EBR_FRM_DATABASE_HEADER_SIZE, &size) == FS_NO_ERROR)
- {
- FS_Close(file_hnd);
- if (file_header.modification_date > 32768)
- {
- return 0;
- }
- else
- {
- return file_header.modification_date;
- }
- }
- }
- return 0;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_remove_nfo_id_info_from_file
- * DESCRIPTION
- * Remove the nfo id info from the file
- * PARAMETERS
- * drive_type [IN]
- * full_path_with_file_name [IN]
- * book_type [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_remove_nfo_id_info_from_file(S32 drive_type, PS8 full_path_with_file_name, ebr_frm_filetype_enum book_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE file_hnd;
- U32 size;
- ebr_frm_database_hdr_type file_header;
- S32 offset = 0;
- doc_record0 rec0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->memory_type_selected = drive_type;
- // pfnUnicodeStrcpy((S8*)ebook_file_name ,(S8*) ebr_frm_get_file_path(drive_type,EBR_FRM_SEARCH_DEFAULT));
- // pfnUnicodeStrcat((PS8)ebook_file_name, (PS8)file_name);
- file_hnd = FS_Open((const WCHAR*)full_path_with_file_name, FS_READ_WRITE);
- if (file_hnd > 0)
- {
- if (book_type == EBR_FRM_FILE_TYPE_TXT)
- {
- FS_Seek(file_hnd, -TXT_FOOTER_START_SIZE - TXT_FOOTER_END_SIZE - MAX_EBOOK_NAME_LENGTH, FS_FILE_END);
- FS_Truncate(file_hnd);
- }
- else
- {
- if (FS_Read(file_hnd, &file_header, EBR_FRM_DATABASE_HEADER_SIZE, &size) == FS_NO_ERROR)
- {
- SEEK_REC_ENTRY(file_hnd, 0);
- if (FS_Read(file_hnd, &offset, 4, &size) == FS_NO_ERROR)
- {
- offset = ntohl(offset);
- }
- FS_Seek(file_hnd, offset, FS_FILE_BEGIN);
- FS_Read(file_hnd, &rec0, sizeof rec0, &size);
- file_header.modification_date = 32769;
- FS_Seek(file_hnd, 0, FS_FILE_BEGIN);
- FS_Write(file_hnd, &file_header, sizeof(ebr_frm_database_hdr_type), &size);
- }
- }
- FS_Close(file_hnd);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_add_to_book_shelf
- * DESCRIPTION
- * Add file to bookshelf.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- ebr_frm_nfo_create_type_errors_enum ebr_frm_add_to_book_shelf()
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- ebr_frm_nfo_create_type_errors_enum nfo_create_type_error = EBR_FRM_NFO_CREATE_SUCCESS;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->src_application = ebr_frm_fmgr_get_application_type();
- if (g_curr_book_cntx_p->g_fmgr_book_type == EBR_FRM_FILE_TYPE_PDB) /* Means PDB file */
- {
- nfo_create_type_error = ebr_frm_open_book_create_nfo_file_pdb(g_curr_book_cntx_p->nfo_name);
- }
- else
- {
- nfo_create_type_error = ebr_frm_open_book_create_nfo_file_txt(g_curr_book_cntx_p->nfo_name);
- }
- return nfo_create_type_error;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_fmgr_delete_from_ebook
- * DESCRIPTION
- * Delete file from File manager
- * PARAMETERS
- * drive_type [IN]
- * file_name [IN]
- * book_type [IN]
- * RETURNS
- * void
- *****************************************************************************/
- S16 ebr_fmgr_delete_from_ebook(S16 drive_type, S8 *file_name, ebr_frm_filetype_enum book_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 ebook_file_name[MAX_DWNL_EBK_PATH_LEN * ENCODING_LENGTH] = {0};
- S32 retval = -1;
- S16 local_nfo_id;
- ebr_frm_database_hdr_type file_header;
- FILE_HANDLE file_hnd;
- U32 size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Check for the type of file .. delete the cerrseponding NFO file also. */
- pfnUnicodeStrcpy(
- (S8*) ebook_file_name,
- (S8*) ebr_frm_get_file_path(g_curr_book_cntx_p->memory_type_selected, EBR_FRM_SEARCH_DEFAULT));
- pfnUnicodeStrcat((PS8) ebook_file_name, (PS8) file_name);
- file_hnd = FS_Open((const WCHAR*)ebook_file_name, FS_READ_ONLY);
- g_curr_book_cntx_p->g_fmgr_book_type = book_type;
- if (g_curr_book_cntx_p->g_fmgr_book_type == EBR_FRM_FILE_TYPE_PDB) /* Means PDB file */
- {
- if (FS_Read(file_hnd, &file_header, EBR_FRM_DATABASE_HEADER_SIZE, &size) == FS_NO_ERROR)
- {
- if (file_header.modification_date > 32768) /* Means no nfo file has been created. */
- {
- FS_Close(file_hnd);
- retval = FS_Delete((const WCHAR*)ebook_file_name);
- return retval;
- }
- else
- {
- local_nfo_id = (S16) file_header.modification_date;
- FS_Close(file_hnd);
- retval = FS_Delete((const WCHAR*)ebook_file_name);
- FS_Delete((const WCHAR*)ebr_frm_get_nfo_file_name(local_nfo_id));
- return retval;
- }
- }
- }
- else
- { /* this is a text file. Delete the text as well as the cerresponding nfo file if it exists */
- FS_Close(file_hnd);
- local_nfo_id = ebr_fmgr_get_nfo_id_for_txt_file((S8)drive_type, file_name);
- if (local_nfo_id <= 0)
- {
- /* Nfo file doenot exist . delete the file only. */
- retval = FS_Delete((const WCHAR*)ebook_file_name);
- return retval;
- }
- else
- {
- FS_Close(file_hnd);
- retval = FS_Delete((const WCHAR*)ebook_file_name);
- retval = FS_Delete((const WCHAR*)ebr_frm_get_nfo_file_name(local_nfo_id));
- return retval;
- }
- }
- return retval;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_fmgr_set_drive_type
- * DESCRIPTION
- * Get the drive type
- * PARAMETERS
- * drive_type [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_fmgr_set_drive_type(ebr_memory_type_enum drive_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->memory_type_selected = drive_type;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_get_nfo_handle
- * DESCRIPTION
- * Get the NFO handle
- * PARAMETERS
- * void
- * RETURNS
- * FILE_HANDLE
- *****************************************************************************/
- FILE_HANDLE ebr_frm_get_nfo_handle(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- FILE_HANDLE nfo_hnd_local;
- S16 local_nfo_id = 0;
- U32 size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->src_application = ebr_frm_fmgr_get_application_type();
- if (g_curr_book_cntx_p->src_application == EBR_FRM_SRC_APP_FMGR)
- { /* Means it is from file manager */
- local_nfo_id = ebr_frm_fmgr_get_nfo_id();
- }
- else
- {
- /* Write the nfo name in NVRAM */
- ReadValue(NVRAM_EBOOK_NFO_LID, (void*)&local_nfo_id, DS_SHORT, &error);
- if (local_nfo_id == 0)
- {
- if (g_curr_book_cntx_p->gbook_type == EBR_FRM_FILE_TYPE_PDB)
- {
- local_nfo_id = ebr_fmgr_get_nfo_id_for_pdb_file(
- g_curr_book_cntx_p->memory_type_selected,
- (PS8) g_curr_book_cntx_p->nfo_name);
- }
- else
- {
- local_nfo_id = ebr_fmgr_get_nfo_id_for_txt_file(
- g_curr_book_cntx_p->memory_type_selected,
- (PS8) g_curr_book_cntx_p->nfo_name);
- }
- WriteValue(NVRAM_EBOOK_NFO_LID, (void*)&local_nfo_id, DS_SHORT, &error);
- }
- }
- pfnUnicodeStrcpy((S8*) g_curr_book_cntx_p->nfo_path, (PS8) ebr_frm_get_nfo_file_name(local_nfo_id));
- nfo_hnd_local = FS_Open((const WCHAR*)g_curr_book_cntx_p->nfo_path, FS_READ_WRITE);
- if (nfo_hnd_local < 0)
- {
- return nfo_hnd_local;
- }
- FS_Seek(nfo_hnd_local, 0, FS_FILE_BEGIN);
- FS_Read(nfo_hnd_local, &g_curr_book_cntx_p->g_nfo_book_struct, sizeof(ebr_frm_book_struct), &size);
- 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->g_nfo_book_struct.e_book_name);
- return nfo_hnd_local;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_get_drive_type
- * DESCRIPTION
- * Get the drive type selected
- * PARAMETERS
- * void
- * RETURNS
- * S16
- *****************************************************************************/
- S16 ebr_get_drive_type(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_curr_book_cntx_p->memory_type_selected;
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_set_settings_and_save
- * DESCRIPTION
- * Save the settings in nfo file
- * PARAMETERS
- * g_ebookset_cntx_p [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_set_settings_and_save(EBOOKSET_CNTX *g_ebookset_cntx_p)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- ebr_frm_setting_struct g_setting;
- S16 error;
- S16 i;
- ebr_frm_setting_struct *g_setting_list = &g_setting;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->pdb_converted_to_text = FALSE;
- ReadRecord(NVRAM_EF_EBOOK_SETTINGS_LID, 1, (void*)(g_setting_list), NVRAM_EF_EBOOK_SETTING_SIZE, &error);
- if(g_curr_book_cntx_p->g_nfo_book_struct.settings.font_size!=g_ebookset_cntx_p->inlineHighligtItemFontSize)
- {
- g_curr_book_cntx_p->g_nfo_book_struct.jump_offset = g_curr_book_cntx_p->g_nfo_book_struct.offset;
- g_curr_book_cntx_p->g_nfo_book_struct.offset = 0;
- }
- g_curr_book_cntx_p->g_nfo_book_struct.settings.font_size = g_ebookset_cntx_p->inlineHighligtItemFontSize;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.font_style = g_ebookset_cntx_p->inlineHighligtItemFontStyle;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_flag =
- g_ebookset_cntx_p->inlineHighligtItemAutoScroll;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_speed =
- g_ebookset_cntx_p->inlineHighligtItemScrollSpeed;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_type =
- g_ebookset_cntx_p->inlineHighligtItemScrollBy;
- if (g_curr_book_cntx_p->g_nfo_book_struct.settings.encoding_format ==
- g_ebookset_cntx_p->inlineHighligtItemEncodingFormat)
- {
- g_curr_book_cntx_p->g_nfo_book_struct.settings.encoding_format =
- g_ebookset_cntx_p->inlineHighligtItemEncodingFormat;
- }
- else
- {
- g_curr_book_cntx_p->g_nfo_book_struct.temp_encoding_file_format = ' ';
- for (i = 0; i < EBR_FRM_MAX_NO_OF_BOOKMARKS; i++)
- {
- g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].offset = 0;
- g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].page_id = 0;
- pfnUnicodeStrcpy((PS8) g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].bookmark_name, (PS8) NULL);
- g_curr_book_cntx_p->g_nfo_book_struct.book_marks[i].percentage_associated_with_book_mark = 0;
- }
- g_curr_book_cntx_p->g_nfo_book_struct.current_page_id = 0;
- g_curr_book_cntx_p->g_nfo_book_struct.offset = 0;
- g_curr_book_cntx_p->g_nfo_book_struct.jump_offset = 0;
- g_curr_book_cntx_p->g_nfo_book_struct.last_showed_percentage = 0;
- /* g_curr_book_cntx_p->g_nfo_book_struct.settings = g_setting_list->common_settings; */
- g_curr_book_cntx_p->g_nfo_book_struct.settings.encoding_format =
- g_ebookset_cntx_p->inlineHighligtItemEncodingFormat;
- g_curr_book_cntx_p->g_nfo_book_struct.last_text_offset_y = 0;
- }
- g_curr_book_cntx_p->g_nfo_book_struct.settings.screen_mode = g_ebookset_cntx_p->inlineHighligtItemFulScreenMode;
- ebr_frm_save_settings_in_nfo_file();
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_frm_set_settings_and_save_in_nvram
- * DESCRIPTION
- * Save the settings in NVRAM
- * PARAMETERS
- * g_ebookset_cntx_p [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void ebr_frm_set_settings_and_save_in_nvram(EBOOKSET_CNTX *g_ebookset_cntx_p)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_curr_book_cntx_p->g_nfo_book_struct.settings.font_size = g_ebookset_cntx_p->inlineHighligtItemFontSize;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.font_style = g_ebookset_cntx_p->inlineHighligtItemFontStyle;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_flag =
- g_ebookset_cntx_p->inlineHighligtItemAutoScroll;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_speed =
- g_ebookset_cntx_p->inlineHighligtItemScrollSpeed;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.auto_scroll_settings.scroll_type =
- g_ebookset_cntx_p->inlineHighligtItemScrollBy;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.encoding_format =
- g_ebookset_cntx_p->inlineHighligtItemEncodingFormat;
- g_curr_book_cntx_p->g_nfo_book_struct.settings.screen_mode = g_ebookset_cntx_p->inlineHighligtItemFulScreenMode;
- g_curr_book_cntx_p->g_nfo_book_struct.memory_type = g_ebookset_cntx_p->inlineHighligtItemSelectMemory;
- ebr_frm_write_settings_in_nvram();
- }
- /*****************************************************************************
- * FUNCTION
- * ebr_get_book_mark_name_list
- * DESCRIPTION
- * Call back to get the book mark names
- * PARAMETERS
- * item_index [IN]
- * str_buff [IN]