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

MTK

开发平台:

C/C++

  1. #ifndef _PIXCOM_EBOOKMANAGER_H
  2. #define _PIXCOM_EBOOKMANAGER_H
  3. #include "FileSystemDef.h"
  4. #include "wgui_inputs.h"
  5. #include "PixTelDataTypes.h"
  6. #include "EbookGprot.h"
  7. #include "Conversions.h"
  8. #define     MAX_EBOOK_NAME_LENGTH            60
  9. #define     EBR_DOWNLOADED_EBOOK_PATH           ":\Ebook\"
  10. #define     EBR_EBOOK_SEARCH_PDB_STR            "*.pdb"
  11. #define     EBR_EBOOK_SEARCH_TXT_STR            "*.txt"
  12. #define     EBR_EBOOK_SEARCH_NFO_STR            "*.nfo"
  13. #define     EBR_EBOOK_SEARCH_TXZ_STR            "*.txz"
  14. #define     EBR_EBOOK_SEARCH_PBZ_STR            "*.pbz"
  15. #define     EBR_EBOOK_NFO_FILE_EXT           ".nfo"
  16. #define     EBR_EBOOK_PDB_FILE_EXT           ".pdb"
  17. #define     EBR_EBOOK_TXT_FILE_EXT           ".txt"
  18. #define     EBOOK_SEARCH_TXT_STR          "*.txt"
  19. #define     MAX_DWNL_EBK_PATH_LEN            (60)
  20. #define     EBR_MAX_EBOOK_SEARCH_STR_LEN     (10)
  21. #define     DOC_CREATOR                   "REAd"
  22. #define     DOC_TYPE                   "TEXtREAd"
  23. #define     EBR_FRM_MAX_NO_OF_BOOKMARKS         10
  24. #define     EBR_PAGE_SIZE                 GUI_PAGE_SIZE
  25. #define     EBR_FRM_RECORD_ENTRY_SIZE        8
  26. #define     COMPRESSED                    2
  27. #define     COUNT_BITS                    3
  28. #define     EBOOK_MESSAGE_WAIT_TIMER_DURATION   15000
  29. #define     EBR_MAX_RECORD_SIZE              1200
  30. #define     EBR_TXT_FOOTER_START          "<EBOOK>"       //Old:"<PIXTEL_MMI_EBOOK_2005>"       //KP Jerry modify on 2007-3-22
  31. #define     EBR_TXT_FOOTER_END              "</EBOOK>"     //Old:"</PIXTEL_MMI_EBOOK_2005>"     //KP Jerry modify on 2007-3-22 
  32. #define     TXT_FOOTER_START_SIZE            23
  33. #define     TXT_FOOTER_END_SIZE              24
  34. #define     EBR_FRM_NUMBER_OF_CHARACTERS_TO_COMPARE  4
  35. #define     EBR_FRM_DATABASE_HEADER_SIZE     78
  36. #define     FILE_NAME_LENGTH              32
  37. #define     EBOOK_FOLDER_PATH             "Ebook"
  38. #define     EBR_FILE_TYPE_TXT             "TXT"
  39. #define     EBR_FILE_TYPE_PDB             "PDB"
  40. #define     MMI_EBOOK_LOCATION               "Ebook\"
  41. #define     EBR_EXTENSION_NAME_LENGTH        3
  42. #define     TEMP_STR                   "temp_"
  43. #define     TXT_TEMP_EXT_STR              ".txz"
  44. #define     PDB_TEMP_EXT_STR              ".pbz"
  45. #define     NFO_FILE_NAME_LENGTH       20
  46. #define     NFO_FILE_NAME_VALUE           9
  47. #ifndef MMI_ON_HARDWARE_P
  48. #define     NVRAM_EF_EBOOK_SETTING_SIZE         8
  49. #endif 
  50. #define  SEEK_REC_ENTRY(f,i) 
  51.    FS_Seek( f, EBR_FRM_DATABASE_HEADER_SIZE + EBR_FRM_RECORD_ENTRY_SIZE * (i), FS_FILE_BEGIN )
  52. #define ntohs(A)  ((((A) & 0xff00) >> 8) | ((A) & 0x00ff) << 8)
  53. #define ntohl(A)  ((((A) & 0xff000000) >> 24) | (((A) & 0x00ff0000) >> 8) | 
  54.       (((A) & 0x0000ff00) << 8) | (((A) & 0x000000ff) << 24))
  55. #define EBR_FRM_SEARCH_BLOCK    5
  56. #define EBR_FRM_SEARCH_BREAK_TIMER    10
  57. typedef enum
  58. {
  59.     EBR_FRM_FILE_TYPE_PDB = 1,
  60.     EBR_FRM_FILE_TYPE_TXT
  61. } ebr_frm_filetype_enum;
  62. typedef enum
  63. {
  64.     EBR_FRM_SEARCH_DEFAULT = 0,
  65.     EBR_FRM_SEARCH_NFO,
  66.     EBR_FRM_SEARCH_PDB,
  67.     EBR_FRM_SEARCH_TXT,
  68.     EBR_FRM_SEARCH_TXZ,
  69.     EBR_FRM_SEARCH_PBZ,
  70.     EBR_FRM_SEARCH_MAX
  71. } ebr_frm_search_type_enum;
  72. typedef enum
  73. {
  74.     EBR_FRM_COPY_TYPE_FIRST = 1,
  75.     EBR_FRM_COPY_TYPE_SECOND,
  76.     EBR_FRM_COPY_TYPE_PREVIOUS,
  77.     EBR_FRM_COPY_TYPE_NEXT
  78. } ebr_frm_copy_type_enum;
  79. typedef enum
  80. {
  81.     EBR_FRM_SRC_APP_EBOOK,
  82.     EBR_FRM_SRC_APP_FMGR
  83. } ebr_frm_application_type_enum;
  84. typedef enum
  85. {
  86.     EBR_FRM_NFO_CREATE_SUCCESS = 0,
  87.     EBR_FRM_NFO_CREATE_FAILURE = 1,
  88.     EBR_FRM_NFO_CREATE_FILE_TYPE_NOT_SUPPORTED = 2,
  89.     EBR_FRM_EMPTY_BOOK = 3
  90. } ebr_frm_nfo_create_type_errors_enum;
  91. typedef enum
  92. {
  93.     EBR_FRM_NO_CONVERSION = 0,
  94.     EBR_FRM_CONVERSION_UNDERWAY = 1,
  95.     EBR_FRM_NFO_CONVERSION_COMPLETED = 2
  96. } ebr_frm_recursive_type_errors_enum;
  97. typedef struct
  98. {
  99.     U8 scroll_flag;
  100.     U8 scroll_speed;
  101.     U8 scroll_type;
  102. } ebr_frm_auto_scroll_struct;
  103. typedef struct
  104. {
  105.     U8 bookmark_name[(EBR_FRM_MAX_BOOKMARK_NAME_SIZE + 1) *ENCODING_LENGTH];
  106.     U8 percentage_associated_with_book_mark;
  107.     U32 page_id;
  108.     U32 offset;
  109.     U32 shared_bytes;
  110. } ebr_frm_bookmark_struct;
  111. typedef struct
  112. {
  113.     U8 font_style;
  114.     U8 font_size;
  115.     ebr_frm_auto_scroll_struct auto_scroll_settings;
  116.     U8 encoding_format;
  117.     U8 screen_mode;
  118. } ebr_frm_common_setting_struct;
  119. typedef struct
  120. {
  121.     ebr_frm_common_setting_struct common_settings;
  122.     S8 memory_type;
  123. } ebr_frm_setting_struct;
  124. typedef struct
  125. {
  126.     U8 e_book_name[(MAX_EBOOK_NAME_LENGTH + 1) *ENCODING_LENGTH];
  127.     U8 temp_file_name[MAX_DWNL_EBK_PATH_LEN *ENCODING_LENGTH];
  128.     U8 display_name[(MAX_EBOOK_NAME_LENGTH + 1) *ENCODING_LENGTH];
  129.     U8 last_showed_percentage;
  130.     U8 temp_encoding_file_format;
  131.     U32 current_page_id;
  132.     U32 offset;
  133.     U32 jump_offset;
  134.     ebr_frm_bookmark_struct book_marks[EBR_FRM_MAX_NO_OF_BOOKMARKS];
  135.     ebr_frm_common_setting_struct settings;
  136.     U32 book_size;
  137.     U32 temp_book_size;
  138.     S8 memory_type;
  139.     S32 last_text_offset_y;
  140.     S8 checksum[TXT_FOOTER_START_SIZE];
  141. } ebr_frm_book_struct;
  142. typedef struct  /* 16 bytes total */
  143. {
  144.     pBOOL version;      /* 1 = plain text, 2 = compressed */
  145.     pBOOL reserved1;
  146.     U32 doc_size;       /* in bytes, when uncompressed */
  147.     pBOOL num_records;  /* PDB header numRecords - 1 */
  148.     pBOOL rec_size;     /* usually RECORD_SIZE_MAX */
  149.     U32 reserved2;
  150. } doc_record0;
  151. typedef struct
  152. {
  153.     S32 gcurrent_record_id;
  154.     S32 gnext_record_id;
  155.     S32 g_start_id;
  156.     S32 g_end_id;
  157.     S32 prev_end_id;
  158.     U16 g_offset;
  159.     U16 g_jump_offset;
  160.     S32 num_records;
  161.     S32 g_last_nfo_id_allocated;
  162.     ebr_frm_filetype_enum gbook_type;
  163.     pBOOL ebr_frm_end_book_flag;
  164.     S32 nfo_id;
  165.     S16 g_fmgr_book_type;
  166.     S8 memory_type_selected;
  167.     S16 src_application;
  168.     U8 ebr_search_strlen;
  169.     pBOOL highlight_string_flag;
  170.     S8 ebr_last_search_string_input[(EBR_MAX_STR_SEARCH_LENGTH + 1) *ENCODING_LENGTH];
  171.     S32 ebr_last_search_record_id;
  172.     S32 ebr_last_offset_string;
  173.     U16 ebr_last_text_offset;
  174.     U32 ebr_last_page_id;
  175.     ebr_frm_book_struct g_nfo_book_struct;
  176.     U8 buffer[EBR_RECORD_SIZE_MAX + EBR_MAX_STR_SEARCH_LENGTH];
  177.     U8 for_unicode_buffer[EBR_RECORD_SIZE_MAX];
  178.     U8 start[(EBR_RECORD_SIZE_MAX + EBR_MAX_STR_SEARCH_LENGTH) *2];
  179.     U8 nfo_path[MAX_DWNL_EBK_PATH_LEN *ENCODING_LENGTH];
  180.     U8 nfo_name[(MAX_EBOOK_NAME_LENGTH + 1) *ENCODING_LENGTH];
  181.     U8 book_name_path[MAX_DWNL_EBK_PATH_LEN *ENCODING_LENGTH];
  182.     U8 temp_book_name_path[MAX_DWNL_EBK_PATH_LEN *ENCODING_LENGTH];
  183.     S8 gebook_folder_path[(FMGR_MAX_FILE_LEN + 1) *ENCODING_LENGTH];
  184.     S8 fmgr_file_name[(FMGR_MAX_FILE_LEN + 1) *ENCODING_LENGTH];
  185.     S8 fmgr_file_extension[(FMGR_MAX_EXT_LEN + 1) *ENCODING_LENGTH];
  186.     S8 fmgr_file_path[FMGR_MAX_PATH_LEN *ENCODING_LENGTH + ENCODING_LENGTH];
  187.     S8 old_file_path[FMGR_MAX_PATH_LEN * ENCODING_LENGTH + ENCODING_LENGTH];
  188.     S16 g_isEbook_folder_created;
  189.     S16 ebook_src_application;
  190.     S16 ebr_fmgr_book_type;
  191.     pBOOL ebr_last_search_type;
  192.     U8 temp_encoding_file_format;
  193.     U32 last_displayed_page_id;
  194.     S32 last_displayed_offset;
  195.     S32 last_text_offset_y;
  196.     pBOOL is_book_in_unicode;
  197.     pBOOL book_is_in_other_encoding_format;
  198.     S32 search_record_id_first;
  199.     S16 ebr_search_from_offset_first;
  200.     pBOOL find_next_first_flag;
  201.     pBOOL last_record_flag;
  202.     pBOOL search_found_flag;
  203.     S32 current_highlight_book_id;
  204.     S32 search_string_count;
  205.     pBOOL search_flag_is_on;
  206.     pBOOL find_next_flag;
  207.     pBOOL pdb_converted_to_text;
  208.     BOOL is_short;
  209.     pBOOL status_for_resetting_find_next_data;
  210.     FILE_HANDLE g_file_hnd_offset;
  211.     S32 g_record_id;
  212.     S32 state_recursive_conversion;
  213.     void (*g_recursive_callback_fn) (void);
  214.     pBOOL is_in_valid;
  215. } g_current_book_context;
  216. typedef struct
  217. {
  218.     U32 next_recordlist_id;
  219.     pBOOL num_records;
  220. } ebr_record_list_type;
  221. typedef struct  /* 78 bytes total */
  222. {
  223.     U8 name[FILE_NAME_LENGTH];
  224.     pBOOL attributes;
  225.     pBOOL version;
  226.     U32 creation_date;
  227.     U32 modification_date;
  228.     U32 last_back_up_date;
  229.     U32 modification_number;
  230.     U32 app_info_id;
  231.     U32 sort_info_id;
  232.     U8 type[4];
  233.     U8 creator[4];
  234.     U32 unique_id_seed;
  235.     ebr_record_list_type record_list;
  236. } ebr_frm_database_hdr_type;
  237. extern void ebr_frm_entry_refresh_book_shelf(void);
  238. extern S32 ebr_frm_create_nfo_file(U8 *display_name, U8 *ebook_file_name_with_path, U8 *ebook_file_name);
  239. extern S16 ebr_frm_fill_nfo_file(FILE_HANDLE file_hnd, U8 *display_name, U8 *ebook_file_name);
  240. extern S16 ebr_frm_decode_header(U8 *ebook_file_name);
  241. extern void ebr_frm_decompress_pdb(U8 *b, U32 *size, ebr_frm_copy_type_enum copy_type);
  242. extern void ebr_frm_start_search_timer(void);
  243. extern pBOOL ebr_frm_search_string_algo(ebr_app_search_type_enum search_type, S8 *ebr_search_string_input, MMI_BOOL timeout);
  244. extern S16 ebr_frm_bm_search(S16 *text, S16 *pat, S32 *start_pos,U32 size);
  245. extern void ebr_frm_get_record(S32 end_id);
  246. extern void ebr_frm_get_record_for_bookmark(U32 selected_index);
  247. extern S16 ebr_frm_get_data_to_open_book(gui_page_info_app *, U8 *buffer_data, S8 *book_display_name);
  248. extern void ebr_frm_jump_to_record(U32 percantage_val, ebr_jump_type_enum jump_type);
  249. extern void ebr_frm_convert_to_upper(S16 *decoded_buffer);
  250. extern S16 ebr_frm_pre_create_bookshelf_screen(void);
  251. extern void ebr_frm_remove_bookmark(U32 bookmark_index);
  252. extern void ebr_frm_add_book_mark(void);
  253. extern S32 ebr_frm_delete_ebook(void);
  254. extern void ebr_frm_save_settings_in_nfo_file(void);
  255. extern pBOOL ebr_frm_ebook_exit(void);
  256. extern U8 *ebr_frm_get_book_type(void);
  257. extern S16 ebr_get_drive_type(void);
  258. extern void ebr_frm_add_book_mark_pre_entry(void);
  259. extern S32 ebr_frm_read_from_nvram(void);
  260. extern void ebr_frm_rwrite_into_nvram(S16 nfo_id);
  261. extern S32 ebr_frm_get_total_countof_nfo_file(void);
  262. extern void ebr_frm_write_settings_in_nvram(void);
  263. extern void ebr_frm_get_default_settings_value(EBOOKSET_CNTX *g_ebookset_cntx_p, S16 ebr_set_local_setting_flag);
  264. extern S32 ebr_frm_save_settings_scroll(void);
  265. extern S32 ebr_frm_save_settings_screen_mode(void);
  266. extern S32 ebr_fmgr_get_nfo_id_for_pdb_file(S8 drive_type, PS8 file_name);
  267. extern S32 ebr_fmgr_get_nfo_id_for_txt_file(S8 drive_type, PS8 file_name);
  268. extern S16 ebr_fmgr_delete_from_ebook(S16 drive_type, S8 *file_name, ebr_frm_filetype_enum book_type);
  269. extern FILE_HANDLE ebr_frm_get_nfo_handle(void);
  270. extern void ebr_frm_close_the_ebook(void);
  271. extern S8 *ebr_fmgr_get_file_name(void);
  272. extern S8 *ebr_frm_get_file_path(S8 memory_type_selected, ebr_frm_search_type_enum search_type_path);
  273. extern void ebr_frm_set_settings_and_save(EBOOKSET_CNTX *g_ebookset_cntx_p);
  274. extern void ebr_frm_set_settings_and_save_in_nvram(EBOOKSET_CNTX *g_ebookset_cntx_p);
  275. extern pBOOL ebr_get_book_mark_name_list(S32 item_index, UI_string_type str_buff, PU8 *img_buff_p, U8 str_img_mask);
  276. extern S16 ebr_frm_get_count_of_book_marks(void);
  277. extern S16 ebr_frm_get_full_screen_flag_status(void);
  278. extern S16 ebr_frm_get_auto_scroll_flag_status(void);
  279. extern S32 ebr_fmgr_is_book_shelf_path(PS8 path);
  280. extern U8 *ebr_get_selected_file_name(void);
  281. extern void ebr_set_selected_file_name(FMGR_FILE_INFO_STRUCT *file_info);
  282. extern S8 *ebr_frm_get_book_name(void);
  283. extern S32 ebr_frm_get_book_size(void);
  284. extern S32 ebr_frm_get_record_size_pdb(FILE_HANDLE file_hnd, S32 offset, S32 rec_num);
  285. extern S32 ebr_frm_restore_default_book_shelf_settings(void);
  286. extern void ebr_frm_delete_all_from_book_shelf(void);
  287. extern S32 ebr_frm_restore_default_book_settings(void);
  288. extern ebr_memory_type_enum ebr_frm_get_memory_type_selected(void);
  289. extern FILE_HANDLE ebr_frm_fmgr_get_nfo_handle(S8 *file_name);
  290. extern void ebr_frm_write_default_value_for_nfo_id_in_nvram(void);
  291. extern void ebr_frm_find_next_nfo_id(void);
  292. extern void ebr_fmgr_get_file_name_call_back(S8 *fmgr_file_name, S8 *file_name);
  293. extern S8 *ebr_fmgr_get_file_size_and_name(S8 *fmgr_file_name);
  294. extern U32 ebr_fmgr_get_file_size(S8 *fmgr_file_name);
  295. extern S32 ebr_frm_fmgr_pre_entry_open_book(S8 *file_name, S8 *file_path, S8 *file_ext);
  296. extern void ebr_frm_update_nfo_file(S8 *new_file_name, ebr_frm_filetype_enum book_type);
  297. extern S32 ebr_frm_get_record_size_txt(S32 rec_num);
  298. extern S32 ebr_frm_create_temp_file_txt(S32 rec_num);
  299. extern S8 *ebr_frm_get_path_for_bookshelf(void);
  300. extern void ebr_frm_fmgr_delete_nfo_file(fmgr_tree_action_enum action_type);
  301. extern void ebr_fmgr_get_display_name_call_back(S8 *fmgr_file_name, ebr_frm_filetype_enum book_type, S8 *file_name);
  302. extern ebr_memory_type_enum ebr_frm_get_drive_type(void);
  303. extern S16 ebr_frm_change_drive_type(void);
  304. extern void ebr_fmgr_set_file_type(S8* file_name);
  305. extern void ebr_frm_get_encoded_data(S8 *inBuffer, S8 *outBuffer);
  306. extern void ebr_frm_delete_unused_nfo_file(void);
  307. extern void ebr_frm_open_nfo_file_and_delete_unused_nfo(U8 *filename);
  308. extern U8 *ebr_frm_get_nfo_file_name(S32 local_nfo_id);
  309. extern void ebr_frm_start_decompression(U8 *decompressed_buffer, U8 *compressed_buffer, U32 *size);
  310. extern void copy_record_in_passed_buffer(
  311.                 FS_HANDLE file_hnd,
  312.                 S32 record_id,
  313.                 U8 *output_buffer,
  314.                 U8 *input_buffer,
  315.                 U32 *size);
  316. extern ebr_frm_nfo_create_type_errors_enum ebr_frm_reset_for_new_book(void);
  317. extern void ebr_frm_set_data_for_display(void);
  318. extern pBOOL ebr_frm_search_string_algo_find_next(void);
  319. extern void ebr_frm_convert_page_id_to_record_id(
  320.                 S32 page_id,
  321.                 S32 text_offset,
  322.                 S32 shared_bytes,
  323.                 S32 *record_id,
  324.                 S32 *record_offset);
  325. extern void ebr_fmgr_set_file_name(PS8 fmgr_file_name);
  326. extern void ebr_frm_remove_nfo_id_info_from_file(S32 drive_type, PS8 file_name, ebr_frm_filetype_enum book_type);
  327. extern ebr_frm_nfo_create_type_errors_enum ebr_frm_open_book_create_nfo_file_pdb(U8 *filename);
  328. extern ebr_frm_nfo_create_type_errors_enum ebr_frm_open_book_create_nfo_file_txt(U8 *filename);
  329. extern MMI_BOOL ebr_frm_is_empty_file(FILE_HANDLE file_hnd, ebr_frm_filetype_enum type);
  330. extern ebr_frm_nfo_create_type_errors_enum ebr_frm_add_to_book_shelf(void);
  331. extern U8 mmi_ebook_util_get_chset(U8 src_chset);
  332. extern void ebr_frm_get_book_encoding_type(void);
  333. extern void ebr_frm_open_nfo_file_and_restore_default(
  334.                 S32 memory_type_selected,
  335.                 U8 *filename,
  336.                 ebr_frm_setting_struct *g_setting_list);
  337. extern void ebr_frm_restore_default_settings_for_each_book(ebr_frm_setting_struct *g_setting_list);
  338. extern void ebr_frm_get_encoding_type_from_book(void);
  339. extern void ebr_frm_create_temp_file_path(void);
  340. extern S32 ebr_frm_create_temp_file_in_ucs2(FILE_HANDLE file_hnd);
  341. extern pBOOL ebr_frm_check_if_file_exists_or_not(void);
  342. extern void ebr_frm_set_file_type(void);
  343. extern void ebr_frm_fmgr_set_application_type(void);
  344. extern void ebr_frm_fmgr_set_file_type(S8 *filename);
  345. extern S32 ebr_frm_check_nfo_file_present(S32 nfo_id);
  346. extern void ebr_frm_create_book_path(void);
  347. extern void ebr_frm_delete_all_unused_nfo_file(void);
  348. extern void ebr_frm_open_nfo_file_and_delete_all_unused_nfo(S8 memory_type, U8 *filename);
  349. extern void ebr_frm_create_new_file_path(void);
  350. extern void ebr_frm_delete_temp_file(void);
  351. extern U16 ebr_frm_mmi_chset_text_to_ucs2_str(
  352.             FILE_HANDLE file_hnd,
  353.             U8 *dest,
  354.             S16 dest_size,
  355.             U8 *src,
  356.             S16 src_size,
  357.             TextEncodingEnum encoding,
  358.             U32 *over_the_record_border);
  359. extern S16 ebr_frm_mmi_chset_binary_search(
  360.             const kal_uint8 key,
  361.             const kal_uint8 *lookup_table,
  362.             kal_int16 start,
  363.             kal_int16 end);
  364. extern S32 ebr_frm_mmi_chset_utf8_to_ucs2_string(
  365.             FILE_HANDLE file_hnd,
  366.             U8 *dest,
  367.             S16 dest_size,
  368.             U8 *src,
  369.             S16 src_size,
  370.             U32 *over_the_record_border);
  371. extern void ebr_frm_reset_find_next_data(void);
  372. extern void ebr_frm_restore_default_nvram(void);
  373. extern void ebr_fmgr_copy_new_file_path_after_move(S8* new_file_path);
  374. extern kal_int32 ebr_frm_mmi_chset_utf8_to_ucs2_string(
  375.                     FILE_HANDLE file_hnd,
  376.                     U8 *dest,
  377.                     S16 dest_size,
  378.                     U8 *src,
  379.                     S16 src_size,
  380.                     U32 *over_the_record_border);
  381. #ifdef __MMI_TOUCH_SCREEN__
  382. extern void ebr_frm_get_data_during_scrolling(S32 page_id, PU8 buffer_local);
  383. #endif 
  384. #endif /* _PIXCOM_EBOOKMANAGER_H */