S32 bpp_convert_filecontent_to_utf8(U16* src_file, U16* dst_file) { kal_uint32 uft8_filesize = 0; U8 ret; BTMTK_FS_HANDLE dst_fh; BT_BPP_FUNC_ENTRY(BPP_CONVERT_FILE_TO_UTF8); ret = btmtk_chset_set_file_encoding(src_file, BTMTK_CHSET_NONE, dst_file, BTMTK_CHSET_UTF8); BT_BPP_TRACE_INFO_ARG1(BPP_CONVERT_TO_UTF8_RETURN, ret); /* get UTF8 file size */ if (ret > 0) { dst_fh = btmtk_fs_open_ucs2(dst_file, BTMTK_FS_READ_ONLY); if (dst_fh <= 0) return 0; btmtk_fs_get_filesize_ucs2(dst_fh, &uft8_filesize); btmtk_fs_close_ucs2(dst_fh); } return (S32)uft8_filesize; }
void bpp_adp_init(void) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ BT_BPP_FUNC_ENTRY(BPP_ADP_ENTRY_INIT); /* clear memory */ OS_MemSet((U8*)&g_bpp_adp_cntx, 0 , sizeof(g_bpp_adp_cntx)); g_bpp_adp_cntx.cm_conn_id = (U8)BPP_INVALID_CMID; /* register callback */ bpp_register_callback(bpp_adp_event_callback); }
U32 bpp_compose_vcard_to_xhtml(BTMTK_FS_HANDLE fh, U16* vcard_file) { btmtk_vcard_data_struct *p_vcard = NULL; S32 parse_rst; U8* cdata; int data_len, write_len; S32 ret; U32 total_len = 0; BT_BPP_FUNC_ENTRY(BPP_COMPOSE_VCARD2XHTML); /* Parsing */ p_vcard = get_ctrl_buffer(sizeof(btmtk_vcard_data_struct)); OS_MemSet((U8*)p_vcard, 0, sizeof(btmtk_vcard_data_struct)); parse_rst = btmtk_vcard_parse_file_to_struct(vcard_file, p_vcard); BT_BPP_TRACE_INFO_ARG1(BPP_PARSE_VCARD_FILE2STRUCT_RETURN, parse_rst); if (parse_rst != BTMTK_VCD_ERR_OK) { /* failed */ free_ctrl_buffer(p_vcard); return 0; } /* Composing */ /* 1. prologue */ cdata = bpp_get_xhtml_prologue(); data_len = strlen((char*)cdata); ret = bpp_fs_write(fh, cdata, data_len, &write_len); total_len += write_len; /* 2. head */ cdata = (U8* )vcard_xhtml_head_template; data_len = strlen((char*)cdata); ret = bpp_fs_write(fh, cdata, data_len, &write_len); total_len += write_len; /* 3. body start */ cdata = (U8* )vcard_xhtml_body_start; data_len = strlen((char*)cdata); ret = bpp_fs_write(fh, cdata, data_len, &write_len); total_len += write_len; /* 4. vCard attributes */ write_len = bpp_compose_vcard_attr_to_xhtml(fh, p_vcard); total_len += write_len; /* 5. body end */ cdata = (U8* )vcard_xhtml_body_end; data_len = strlen((char*)cdata); ret = bpp_fs_write(fh, cdata, data_len, &write_len); total_len += write_len; if (p_vcard) free_ctrl_buffer(p_vcard); return total_len; }