Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
BT_BOOL bpp_is_file_utf8_encoding(U16* filename)
{
	BT_BOOL ret = TRUE;
	BTMTK_CHSET_ENUM file_chset;	
	
	file_chset =  btmtk_chset_get_file_encoding(filename);
	BT_BPP_TRACE_INFO_ARG1(BPP_GET_FILE_CHARSET_RETURN, file_chset);

	if (file_chset != BTMTK_CHSET_UTF8)
	{
		ret = FALSE;
	}

	BT_BPP_TRACE_INFO_ARG1(BPP_IS_UTF8_TEXT_RETURN, ret);

	return ret;
}
Exemplo n.º 3
0
/*****************************************************************************
 * FUNCTION
 *  bpp_adp_send_msg2app
 * DESCRIPTION
 *  This function send msg to bpp app(mmi)
 * PARAMETERS
 *  msg_id      [IN]        
 *  wparam      [?]         [?]
 * RETURNS
 *  void
 *****************************************************************************/
static void bpp_adp_send_msg2app(kal_uint16 msg_id, local_para_struct *wparam)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
#ifdef __ON_MAUI__
    
    ilm_struct *ilm_send = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    BT_BPP_TRACE_INFO_ARG1(BPP_ADP_SEND_MSG2APP, msg_id);

    ilm_send = allocate_ilm(MOD_BT);
    ilm_send->src_mod_id = MOD_BT;
    ilm_send->dest_mod_id = MOD_MMI;
    ilm_send->sap_id = BT_BPP_SAP;
    ilm_send->msg_id = (kal_uint16) msg_id;
    ilm_send->local_para_ptr = (local_para_struct*) wparam;
    ilm_send->peer_buff_ptr = NULL;
	
    msg_send_ext_queue(ilm_send);

#else

	U16 msg_len;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    BT_BPP_TRACE_INFO_ARG1(BPP_ADP_SEND_MSG2APP, msg_id);
    
    msg_len = wparam ? ((local_para_struct*)wparam)->msg_len : 0;
	
    BT_SendMessage(msg_id, MOD_MMI, wparam, msg_len);

#endif
}
Exemplo n.º 4
0
/*****************************************************************************
 * FUNCTION
 *  bpp_adp_disconnect_confirm
 * DESCRIPTION
 *  This function is send close confirm msg to bpp app
 * PARAMETERS
 *  printer         [?]         [?]
 *  err_code        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
static void bpp_adp_disconnect_confirm(BPP_ERROR_CODE err_code)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    bt_bpp_disconnect_cnf_struct *close_cnf =
        (bt_bpp_disconnect_cnf_struct*) construct_local_para(sizeof(bt_bpp_disconnect_cnf_struct), TD_CTRL);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    BT_BPP_TRACE_INFO_ARG1(BPP_ADP_DISC_CONFIRM, err_code);

	if (err_code == BPP_SUCCESS)
	{
	    if(g_bpp_adp_cntx.cm_conn_id != BPP_INVALID_CMID)
	    {
			BT_BPP_TRACE_INFO_ARG1(BPP_ADP_RELEASE_CM_CONNID, g_bpp_adp_cntx.cm_conn_id);

			BTBMProfileReleaseConnIndex(g_bpp_adp_cntx.cm_conn_id);

			g_bpp_adp_cntx.cm_conn_id = (U8)BPP_INVALID_CMID;
	    }
	}

    close_cnf->hprinter = g_bpp_adp_cntx.printer_handle;
    close_cnf->cnf_code = err_code;
    		
	if (err_code == BPP_SUCCESS)
	{
		g_bpp_adp_cntx.printer_handle = BPP_INVALID_PRINTER_HANDLE;
		g_bpp_adp_cntx.cur_req = BPP_REQ_NONE;
	}

    bpp_adp_send_msg2app(MSG_ID_BT_BPP_DISCONNECT_CNF, (local_para_struct*) close_cnf);
    
}
Exemplo n.º 5
0
/*****************************************************************************
 * FUNCTION
 *  bpp_adp_open_confirm
 * DESCRIPTION
 *  This function is to send open confirm msg to bpp app(MMI)
 * PARAMETERS
 *  printer         [?]         Address
 *  err_code        [IN]        Error code
 * RETURNS
 *****************************************************************************/
static void bpp_adp_connect_confirm(BPP_ERROR_CODE cnf_code)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    bt_bpp_connect_cnf_struct *open_cnf =
        (bt_bpp_connect_cnf_struct*) construct_local_para(sizeof(bt_bpp_connect_cnf_struct), TD_CTRL);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    BT_BPP_TRACE_INFO_ARG1(BPP_ADP_CONNECT_CONFIRM,cnf_code);

    if (cnf_code == BPP_SUCCESS)
    {
        g_bpp_adp_cntx.cm_conn_id =  BTBMProfileAllocateConnIndex(BT_BASIC_PRINTING, g_bpp_adp_cntx.bt_addr);

        open_cnf->cm_conn_id = g_bpp_adp_cntx.cm_conn_id;

		BT_BPP_TRACE_INFO_ARG1(BPP_ADP_ALLOC_CM_CONNID, g_bpp_adp_cntx.cm_conn_id);
    }

    open_cnf->hprinter = g_bpp_adp_cntx.printer_handle;
    open_cnf->cnf_code = cnf_code;

	if (cnf_code != BPP_SUCCESS)
	{
		g_bpp_adp_cntx.printer_handle = BPP_INVALID_PRINTER_HANDLE;
	}
	
	g_bpp_adp_cntx.cur_req = BPP_REQ_NONE;
	
    bpp_adp_send_msg2app(MSG_ID_BT_BPP_CONNECT_CNF, (local_para_struct*) open_cnf);

}
Exemplo n.º 6
0
static void bpp_adp_disconnect_ind(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    bt_bpp_disconnect_ind_struct *disc_ind;
	
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    BT_BPP_TRACE_INFO(BPP_ADP_DISC_IND);

    if(g_bpp_adp_cntx.cm_conn_id != BPP_INVALID_CMID)
    {
		BT_BPP_TRACE_INFO_ARG1(BPP_ADP_RELEASE_CM_CONNID, g_bpp_adp_cntx.cm_conn_id);

		BTBMProfileReleaseConnIndex(g_bpp_adp_cntx.cm_conn_id);

		g_bpp_adp_cntx.cm_conn_id = (U8)BPP_INVALID_CMID;
    }

	if (g_bpp_adp_cntx.cur_req == BPP_REQ_CANCEL)
	{
		bpp_adp_cancel_confirm(BPP_SUCCESS);
	}
	
	disc_ind =
        (bt_bpp_disconnect_ind_struct*) construct_local_para(sizeof(bt_bpp_disconnect_ind_struct), TD_CTRL);

    disc_ind->hprinter = g_bpp_adp_cntx.printer_handle;
	//disc_ind->cm_conn_id = g_bpp_adp_cntx.cm_conn_id;

	g_bpp_adp_cntx.printer_handle = BPP_INVALID_PRINTER_HANDLE;
	g_bpp_adp_cntx.cur_req = BPP_REQ_NONE;
		
    bpp_adp_send_msg2app(MSG_ID_BT_BPP_DISCONNECT_IND, (local_para_struct*) disc_ind);

}
Exemplo n.º 7
0
/*****************************************************************************
 * FUNCTION
 *  bpp_adp_get_attr_confirm
 * DESCRIPTION
 *  This function send get attr confirm to bpp app (mmi)
 * PARAMETERS
 *  printer         [?]         [?]
 *  err_code        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
static void bpp_adp_get_attr_confirm(BPP_ERROR_CODE err_code, bt_bpp_printer_attributes *attr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    bt_bpp_get_printer_attr_cnf_struct *get_attr_cnf = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    BT_BPP_TRACE_INFO_ARG1(BPP_ADP_GET_ATTR_CONFIRM,err_code);

    get_attr_cnf =
        (bt_bpp_get_printer_attr_cnf_struct*) construct_local_para(sizeof(bt_bpp_get_printer_attr_cnf_struct), TD_CTRL);

    OS_MemSet((U8*)&get_attr_cnf->printer_attributes, 0, sizeof(get_attr_cnf->printer_attributes));
    get_attr_cnf->hprinter = g_bpp_adp_cntx.printer_handle;
    get_attr_cnf->cnf_code = err_code;
	
	if (attr != NULL)
	{
		get_attr_cnf->printer_attributes.printer_state = attr->printer_state;
		get_attr_cnf->printer_attributes.state_reason = attr->state_reason;
	}
	
	if (err_code == BPP_SUCCESS)
	{		
		OS_MemCopy((U8*)&get_attr_cnf->printer_attributes.capability, (U8*)&attr->capability, sizeof(bt_bpp_printer_capability));
	}

	if (g_bpp_adp_cntx.cur_req == BPP_REQ_GETPRINTERATTR)
    {
		g_bpp_adp_cntx.cur_req = BPP_REQ_NONE;
    }

    bpp_adp_send_msg2app(MSG_ID_BT_BPP_GET_PRINTER_ATTR_CNF, (local_para_struct*) get_attr_cnf);
	
}
Exemplo n.º 8
0
/*****************************************************************************
 * FUNCTION
 *  bpp_adp_cancel_confirm
 * DESCRIPTION
 *  This function is send close confirm msg to bpp app
 * PARAMETERS
 *  printer         [?]         [?]
 *  err_code        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
static void bpp_adp_cancel_confirm(BPP_ERROR_CODE err_code)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    bt_bpp_cancel_cnf_struct *cancel_cnf =
        (bt_bpp_cancel_cnf_struct*) construct_local_para(sizeof(bt_bpp_cancel_cnf_struct), TD_CTRL);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    BT_BPP_TRACE_INFO_ARG1(BPP_ADP_CANCEL_CONFIRM, err_code);

    cancel_cnf->hprinter = g_bpp_adp_cntx.printer_handle;
    cancel_cnf->cnf_code = err_code;
    		
	if (err_code == BPP_SUCCESS)
	{
		g_bpp_adp_cntx.cur_req = BPP_REQ_NONE;
	}

    bpp_adp_send_msg2app(MSG_ID_BT_BPP_CANCEL_CNF, (local_para_struct*) cancel_cnf);
    
}
Exemplo n.º 9
0
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;
}