summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrikanth Uppala <suppala@broadcom.com>2012-06-17 21:44:48 -0700
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:23 -0700
commit1144d2b375fc67c9b48298e0ffd774d969cfd2cc (patch)
tree4d36d4f8be4942d769300c242caeb9b9096c6a35
parentfed66f7b66d29da466e2e67befe3238e7ed8fc6a (diff)
downloadexternal_bluetooth_bluedroid-1144d2b375fc67c9b48298e0ffd774d969cfd2cc.zip
external_bluetooth_bluedroid-1144d2b375fc67c9b48298e0ffd774d969cfd2cc.tar.gz
external_bluetooth_bluedroid-1144d2b375fc67c9b48298e0ffd774d969cfd2cc.tar.bz2
resubmit code-cleanup changes lost in gerrit merge
Change-Id: Iebc520d9b10ef220a83a16ff55efa46b4c5a0d27
-rw-r--r--bta/Android.mk46
-rw-r--r--bta/av/bta_av_act.c109
-rw-r--r--bta/av/bta_av_cfg.c39
-rw-r--r--bta/dg/bta_dg_act.c900
-rw-r--r--bta/dg/bta_dg_api.c218
-rw-r--r--bta/dg/bta_dg_cfg.c54
-rw-r--r--bta/dg/bta_dg_ci.c159
-rw-r--r--bta/dg/bta_dg_int.h220
-rw-r--r--bta/dg/bta_dg_main.c597
-rw-r--r--bta/ft/bta_ft_cfg.c86
-rw-r--r--bta/ft/bta_ftc_act.c2062
-rw-r--r--bta/ft/bta_ftc_api.c796
-rw-r--r--bta/ft/bta_ftc_int.h504
-rw-r--r--bta/ft/bta_ftc_main.c689
-rw-r--r--bta/ft/bta_ftc_utils.c608
-rw-r--r--bta/ft/bta_fts_act.c1523
-rw-r--r--bta/ft/bta_fts_api.c230
-rw-r--r--bta/ft/bta_fts_int.h287
-rw-r--r--bta/ft/bta_fts_main.c603
-rw-r--r--bta/ft/bta_fts_sdp.c66
-rw-r--r--bta/ft/bta_fts_utils.c972
-rw-r--r--bta/hd/bta_hd_act.c646
-rw-r--r--bta/hd/bta_hd_api.c236
-rw-r--r--bta/hd/bta_hd_cfg.c151
-rw-r--r--bta/hd/bta_hd_int.h166
-rw-r--r--bta/hd/bta_hd_main.c242
-rw-r--r--bta/include/bta_dg_api.h198
-rw-r--r--bta/include/bta_dg_ci.h107
-rw-r--r--bta/include/bta_dg_co.h198
-rw-r--r--bta/include/bta_ft_api.h724
-rw-r--r--bta/include/bta_hd_api.h289
-rw-r--r--bta/include/bta_ma_api.h691
-rw-r--r--bta/include/bta_ma_co.h91
-rw-r--r--bta/include/bta_ma_def.h479
-rw-r--r--bta/include/bta_mse_api.h470
-rw-r--r--bta/include/bta_mse_ci.h146
-rw-r--r--bta/include/bta_mse_co.h330
-rw-r--r--bta/include/bta_op_api.h567
-rw-r--r--bta/include/bta_pbs_api.h262
-rw-r--r--bta/include/bta_pbs_ci.h93
-rw-r--r--bta/include/bta_pbs_co.h160
-rw-r--r--bta/include/bta_prm_api.h57
-rw-r--r--bta/include/bta_sc_api.h193
-rw-r--r--bta/include/bta_sc_ci.h111
-rw-r--r--bta/include/bta_sc_co.h153
-rw-r--r--bta/ma/bta_ma_api.c1203
-rw-r--r--bta/ma/bta_ma_util.c1750
-rw-r--r--bta/ma/bta_ma_util.h93
-rw-r--r--bta/ma/bta_mse_act.c2763
-rw-r--r--bta/ma/bta_mse_api.c437
-rw-r--r--bta/ma/bta_mse_cfg.c31
-rw-r--r--bta/ma/bta_mse_ci.c251
-rw-r--r--bta/ma/bta_mse_int.h835
-rw-r--r--bta/ma/bta_mse_main.c1367
-rw-r--r--bta/ma/bta_mse_sdp.c63
-rw-r--r--bta/ma/bta_mse_utils.c3867
-rw-r--r--bta/op/bta_op_fmt.c804
-rw-r--r--bta/op/bta_op_fmt.h92
-rw-r--r--bta/op/bta_op_vcal.c158
-rw-r--r--bta/op/bta_op_vcard.c310
-rw-r--r--bta/op/bta_op_vnote.c99
-rw-r--r--bta/op/bta_opc_act.c1017
-rw-r--r--bta/op/bta_opc_api.c214
-rw-r--r--bta/op/bta_opc_int.h257
-rw-r--r--bta/op/bta_opc_main.c425
-rw-r--r--bta/op/bta_opc_utils.c322
-rw-r--r--bta/op/bta_ops_act.c793
-rw-r--r--bta/op/bta_ops_api.c153
-rw-r--r--bta/op/bta_ops_int.h198
-rw-r--r--bta/op/bta_ops_main.c412
-rw-r--r--bta/op/bta_ops_utils.c487
-rw-r--r--bta/pb/bta_pbs_act.c1134
-rw-r--r--bta/pb/bta_pbs_api.c222
-rw-r--r--bta/pb/bta_pbs_ci.c119
-rw-r--r--bta/pb/bta_pbs_int.h262
-rw-r--r--bta/pb/bta_pbs_main.c515
-rw-r--r--bta/pb/bta_pbs_sdp.c113
-rw-r--r--bta/pb/bta_pbs_utils.c734
-rw-r--r--btif/co/bta_fs_co.c2
-rw-r--r--btif/include/btif_av_api.h3
-rwxr-xr-xbtif/src/btif_av.c6
-rwxr-xr-xbtif/src/btif_rc.c4
-rw-r--r--btif/src/btif_sock_sdp.c145
-rwxr-xr-xinclude/bdroid_crespo.txt29
-rwxr-xr-xinclude/bdroid_crespo4g.txt29
-rwxr-xr-xinclude/bdroid_maguro.txt29
-rwxr-xr-xinclude/bdroid_toro.txt29
-rwxr-xr-xinclude/bdroid_wingray.txt29
-rwxr-xr-xinclude/bt_target.h20
-rw-r--r--stack/Android.mk55
-rw-r--r--stack/a2dp/a2d_m12.c141
-rw-r--r--stack/a2dp/a2d_m24.c149
-rw-r--r--stack/avct/avct_bcb_act.c749
-rw-r--r--stack/avct/avct_l2c_br.c397
-rw-r--r--stack/avrc/avrc_api.c557
-rw-r--r--stack/avrc/avrc_bld_ct.c1102
-rw-r--r--stack/avrc/avrc_bld_tg.c1547
-rw-r--r--stack/avrc/avrc_int.h21
-rw-r--r--stack/avrc/avrc_opt.c5
-rw-r--r--stack/avrc/avrc_pars_ct.c663
-rw-r--r--stack/avrc/avrc_pars_tg.c452
-rw-r--r--stack/avrc/avrc_sdp.c34
-rw-r--r--stack/avrc/avrc_utils.c254
-rw-r--r--stack/dun/dun_api.c592
-rw-r--r--stack/dun/dun_int.h63
-rw-r--r--stack/goep/goep_fs.c149
-rw-r--r--stack/goep/goep_int.h55
-rw-r--r--stack/goep/goep_trace.c35
-rw-r--r--stack/goep/goep_util.c504
-rw-r--r--stack/hid/hidd_api.c536
-rw-r--r--stack/hid/hidd_conn.c970
-rw-r--r--stack/hid/hidd_int.h136
-rw-r--r--stack/hid/hidd_mgmt.c287
-rw-r--r--stack/hid/hidd_pm.c288
-rw-r--r--stack/include/a2d_m12.h145
-rw-r--r--stack/include/a2d_m24.h122
-rw-r--r--stack/include/avrc_defs.h5
-rw-r--r--stack/include/dun_api.h201
-rw-r--r--stack/include/goep_util.h265
-rw-r--r--stack/include/hidd_api.h241
-rw-r--r--stack/include/xml_bld_api.h113
-rw-r--r--stack/include/xml_erp_api.h145
-rw-r--r--stack/include/xml_flp_api.h162
-rw-r--r--stack/include/xml_mlp_api.h169
-rw-r--r--stack/include/xml_pars_api.h358
-rw-r--r--stack/include/xml_vlist_api.h136
-rw-r--r--stack/obx/hdrs/obx_dauth.c149
-rw-r--r--stack/obx/hdrs/obx_dbtp.c189
-rw-r--r--stack/obx/hdrs/obx_dopt.c52
-rw-r--r--stack/obx/hdrs/obx_dunic.c64
-rw-r--r--stack/obx/hdrs/obx_dutf.c91
-rw-r--r--stack/obx/hdrs/obx_dwchar.c91
-rw-r--r--stack/obx/hdrs/obx_ebtp.c177
-rw-r--r--stack/obx/hdrs/obx_eopt.c51
-rw-r--r--stack/obx/hdrs/obx_eunic.c64
-rw-r--r--stack/obx/hdrs/obx_eutf.c111
-rw-r--r--stack/obx/hdrs/obx_ewchar.c100
-rw-r--r--stack/obx/hdrs/obx_gen.c896
-rw-r--r--stack/obx/hdrs/obx_wchar.c84
-rw-r--r--stack/obx/hdrs/utfc.c245
-rw-r--r--stack/obx/obx_cact.c1103
-rw-r--r--stack/obx/obx_capi.c855
-rw-r--r--stack/obx/obx_csm.c365
-rw-r--r--stack/obx/obx_int.h602
-rw-r--r--stack/obx/obx_l2c.c1031
-rw-r--r--stack/obx/obx_main.c946
-rw-r--r--stack/obx/obx_md5.c1050
-rw-r--r--stack/obx/obx_rfc.c613
-rw-r--r--stack/obx/obx_sact.c1519
-rw-r--r--stack/obx/obx_sapi.c591
-rw-r--r--stack/obx/obx_ssm.c365
-rw-r--r--stack/obx/obx_utils.c979
-rw-r--r--stack/xml/xml_bld.c192
-rw-r--r--stack/xml/xml_erp.c907
-rw-r--r--stack/xml/xml_flp.c971
-rw-r--r--stack/xml/xml_mlp.c1060
-rw-r--r--stack/xml/xml_parse.c1502
-rw-r--r--stack/xml/xml_vlist.c873
158 files changed, 11 insertions, 69033 deletions
diff --git a/bta/Android.mk b/bta/Android.mk
index f5ab5e1..22665a3 100644
--- a/bta/Android.mk
+++ b/bta/Android.mk
@@ -19,27 +19,6 @@ LOCAL_SRC_FILES:= \
./dm/bta_dm_cfg.c \
./dm/bta_dm_api.c \
./dm/bta_dm_sco.c \
- ./op/bta_op_vcal.c \
- ./op/bta_opc_utils.c \
- ./op/bta_opc_main.c \
- ./op/bta_opc_api.c \
- ./op/bta_opc_act.c \
- ./op/bta_ops_utils.c \
- ./op/bta_op_vcard.c \
- ./op/bta_ops_main.c \
- ./op/bta_op_vnote.c \
- ./op/bta_op_fmt.c \
- ./op/bta_ops_act.c \
- ./op/bta_ops_api.c \
- ./ma/bta_mse_ci.c \
- ./ma/bta_mse_api.c \
- ./ma/bta_mse_act.c \
- ./ma/bta_mse_sdp.c \
- ./ma/bta_ma_util.c \
- ./ma/bta_ma_api.c \
- ./ma/bta_mse_utils.c \
- ./ma/bta_mse_main.c \
- ./ma/bta_mse_cfg.c \
./gatt/bta_gattc_api.c \
./gatt/bta_gatts_act.c \
./gatt/bta_gatts_main.c \
@@ -50,10 +29,6 @@ LOCAL_SRC_FILES:= \
./gatt/bta_gattc_act.c \
./gatt/bta_gattc_cache.c \
./gatt/bta_gatts_utils.c \
- ./hd/bta_hd_cfg.c \
- ./hd/bta_hd_api.c \
- ./hd/bta_hd_main.c \
- ./hd/bta_hd_act.c \
./ag/bta_ag_sdp.c \
./ag/bta_ag_sco.c \
./ag/bta_ag_cfg.c \
@@ -69,27 +44,6 @@ LOCAL_SRC_FILES:= \
./hh/bta_hh_api.c \
./hh/bta_hh_utils.c \
./hh/bta_hh_main.c \
- ./dg/bta_dg_act.c \
- ./dg/bta_dg_main.c \
- ./dg/bta_dg_api.c \
- ./dg/bta_dg_cfg.c \
- ./dg/bta_dg_ci.c \
- ./ft/bta_ft_cfg.c \
- ./ft/bta_ftc_main.c \
- ./ft/bta_fts_utils.c \
- ./ft/bta_fts_sdp.c \
- ./ft/bta_ftc_api.c \
- ./ft/bta_ftc_act.c \
- ./ft/bta_fts_act.c \
- ./ft/bta_fts_api.c \
- ./ft/bta_fts_main.c \
- ./ft/bta_ftc_utils.c \
- ./pb/bta_pbs_act.c \
- ./pb/bta_pbs_api.c \
- ./pb/bta_pbs_sdp.c \
- ./pb/bta_pbs_utils.c \
- ./pb/bta_pbs_ci.c \
- ./pb/bta_pbs_main.c \
./pb/bta_pbs_cfg.c \
./fs/bta_fs_ci.c \
./fs/bta_fs_cfg.c \
diff --git a/bta/av/bta_av_act.c b/bta/av/bta_av_act.c
index 9fafd76..8181e57 100644
--- a/bta/av/bta_av_act.c
+++ b/bta/av/bta_av_act.c
@@ -267,15 +267,6 @@ static void bta_av_rc_msg_cback(UINT8 handle, UINT8 label, UINT8 opcode, tAVRC_M
memcpy((UINT8 *)(p_buf + 1), p_data, data_len);
*p_p_data = (UINT8 *)(p_buf + 1);
}
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- if (opcode == AVRC_OP_BROWSE)
- {
- /* set p_pkt to NULL, so avrc would not free the GKI buffer */
- p_msg->browse.p_browse_pkt = NULL;
- }
-#endif
-#endif
bta_sys_sendmsg(p_buf);
}
}
@@ -489,12 +480,6 @@ void bta_av_rc_opened(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
return;
}
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE && AVCT_BROWSE_INCLUDED == TRUE)
- /* listen to browsing channel when the connection is open,
- - if peer initiated AVRCP connection and local device supports browsing channel */
- if ((p_cb->features & BTA_AV_FEAT_BROWSE) && (p_cb->rcb[i].peer_features == 0))
- AVRC_OpenBrowse (p_data->rc_conn_chg.handle, AVCT_ACP);
-#endif
if (p_cb->rcb[i].lidx == (BTA_AV_NUM_LINKS + 1) && shdl != 0)
{
@@ -552,15 +537,6 @@ void bta_av_rc_opened(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
}
(*p_cb->p_cback)(BTA_AV_RC_OPEN_EVT, (tBTA_AV *) &rc_open);
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE && AVCT_BROWSE_INCLUDED == TRUE)
- /* if local initiated AVRCP connection and both peer and locals device support
- * browsing channel, open the browsing channel now */
- if ((p_cb->features & BTA_AV_FEAT_BROWSE) && (rc_open.peer_features & BTA_AV_FEAT_BROWSE) &&
- ((p_cb->rcb[i].status & BTA_AV_RC_ROLE_MASK) == BTA_AV_RC_ROLE_INT))
- {
- AVRC_OpenBrowse (p_data->rc_conn_chg.handle, AVCT_INT);
- }
-#endif
}
@@ -691,14 +667,6 @@ void bta_av_rc_free_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
*******************************************************************************/
void bta_av_rc_free_msg (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
{
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- if (p_data->rc_msg.opcode == AVRC_OP_BROWSE)
- {
- utl_freebuf ((void **)&p_data->rc_msg.msg.browse.p_browse_pkt);
- }
-#endif
-#endif
}
@@ -772,15 +740,6 @@ tBTA_AV_EVT bta_av_proc_meta_cmd(tAVRC_RESPONSE *p_rc_rsp, tBTA_AV_RC_MSG *p_ms
p_vendor->hdr.ctype = BTA_AV_RSP_NOT_IMPL;
AVRC_VendorRsp(p_msg->handle, p_msg->label, &p_msg->msg.vendor);
}
-#if (AVRC_METADATA_INCLUDED == TRUE)
- else if (!AVRC_IsValidAvcType(pdu, p_vendor->hdr.ctype) )
- {
- APPL_TRACE_DEBUG2("Invalid pdu/ctype: 0x%x, %d", pdu, p_vendor->hdr.ctype);
- /* reject invalid message without reporting to app */
- evt = 0;
- p_rc_rsp->rsp.status = AVRC_STS_BAD_CMD;
- }
-#endif
else
{
switch (pdu)
@@ -852,13 +811,6 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
tBTA_AV av;
BT_HDR *p_pkt = NULL;
tAVRC_MSG_VENDOR *p_vendor = &p_data->rc_msg.msg.vendor;
-#if (AVRC_METADATA_INCLUDED == TRUE)
- tAVRC_STS res;
- UINT8 ctype;
- tAVRC_RESPONSE rc_rsp;
-
- rc_rsp.rsp.status = BTA_AV_STS_NO_RSP;
-#endif
if (p_data->rc_msg.opcode == AVRC_OP_PASS_THRU)
{
@@ -869,12 +821,6 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
if (p_data->rc_msg.msg.pass.op_id == AVRC_ID_VENDOR)
{
p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_NOT_IMPL;
-#if (AVRC_METADATA_INCLUDED == TRUE)
- if (p_cb->features & BTA_AV_FEAT_METADATA)
- p_data->rc_msg.msg.hdr.ctype =
- bta_av_group_navi_supported(p_data->rc_msg.msg.pass.pass_len,
- p_data->rc_msg.msg.pass.p_pass_data);
-#endif
}
else
{
@@ -928,30 +874,12 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
if ((p_cb->features & BTA_AV_FEAT_VENDOR) &&
p_data->rc_msg.msg.hdr.ctype <= AVRC_CMD_GEN_INQ)
{
-#if (AVRC_METADATA_INCLUDED == TRUE)
- if ((p_cb->features & BTA_AV_FEAT_METADATA) &&
- (p_vendor->company_id == AVRC_CO_METADATA))
- {
- av.meta_msg.p_msg = &p_data->rc_msg.msg;
- evt = bta_av_proc_meta_cmd (&rc_rsp, &p_data->rc_msg, &ctype);
- }
- else
-#endif
evt = BTA_AV_VENDOR_CMD_EVT;
}
/* else if configured to support vendor specific and it's a response */
else if ((p_cb->features & BTA_AV_FEAT_VENDOR) &&
p_data->rc_msg.msg.hdr.ctype >= AVRC_RSP_ACCEPT)
{
-#if (AVRC_METADATA_INCLUDED == TRUE)
- if ((p_cb->features & BTA_AV_FEAT_METADATA) &&
- (p_vendor->company_id == AVRC_CO_METADATA))
- {
- av.meta_msg.p_msg = &p_data->rc_msg.msg;
- evt = BTA_AV_META_MSG_EVT;
- }
- else
-#endif
evt = BTA_AV_VENDOR_RSP_EVT;
}
@@ -964,49 +892,12 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
AVRC_VendorRsp(p_data->rc_msg.handle, p_data->rc_msg.label, &p_data->rc_msg.msg.vendor);
}
}
-#if (AVRC_METADATA_INCLUDED == TRUE)
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- else if (p_data->rc_msg.opcode == AVRC_OP_BROWSE)
- {
- /* set up for callback */
- av.meta_msg.code = p_data->rc_msg.msg.hdr.ctype;
- av.meta_msg.company_id = p_vendor->company_id;
- av.meta_msg.label = p_data->rc_msg.label;
- av.meta_msg.p_data = p_data->rc_msg.msg.browse.p_browse_data;
- av.meta_msg.len = p_data->rc_msg.msg.browse.browse_len;
- av.meta_msg.p_msg = &p_data->rc_msg.msg;
- evt = BTA_AV_META_MSG_EVT;
- }
-#endif
-#endif
-
- if (evt == 0 && rc_rsp.rsp.status != BTA_AV_STS_NO_RSP)
- {
- if (!p_pkt)
- {
- rc_rsp.rsp.opcode = p_data->rc_msg.opcode;
- res = AVRC_BldResponse (0, &rc_rsp, &p_pkt);
- }
- if (p_pkt)
- AVRC_MsgReq (p_data->rc_msg.handle, p_data->rc_msg.label, ctype, p_pkt);
- }
-#endif
/* call callback */
if (evt != 0)
{
av.remote_cmd.rc_handle = p_data->rc_msg.handle;
(*p_cb->p_cback)(evt, &av);
-#if (AVRC_METADATA_INCLUDED == TRUE)
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- /* If the application does not free the buffer or claim the ownership, free the buffer now */
- if (p_data->rc_msg.opcode == AVRC_OP_BROWSE)
- utl_freebuf((void **)&p_data->rc_msg.msg.browse.p_browse_pkt);
-#endif
-#endif
-#endif
}
}
diff --git a/bta/av/bta_av_cfg.c b/bta/av/bta_av_cfg.c
index 1c6d335..ebd8bd1 100644
--- a/bta/av/bta_av_cfg.c
+++ b/bta/av/bta_av_cfg.c
@@ -49,15 +49,7 @@ const UINT16 bta_av_audio_flush_to[] = {
}; /* AVDTP audio transport channel flush timeout */
/* Note: Android doesnt support AVRC_SUPF_TG_GROUP_NAVI */
-#if AVRC_ADV_CTRL_INCLUDED == TRUE
-#define BTA_AV_RC_SUPF_TG (AVRC_SUPF_TG_CAT1|AVRC_SUPF_TG_APP_SETTINGS|AVRC_SUPF_TG_BROWSE|AVRC_SUPF_TG_MULTI_PLAYER)
-#else
-#if AVRC_METADATA_INCLUDED == TRUE
-#define BTA_AV_RC_SUPF_TG (AVRC_SUPF_TG_CAT1|AVRC_SUPF_TG_APP_SETTINGS)
-#else
#define BTA_AV_RC_SUPF_TG (AVRC_SUPF_TG_CAT1)
-#endif
-#endif
/*
@@ -68,13 +60,6 @@ const UINT8 bta_av_meta_caps_evt_ids[] = {
AVRC_EVT_TRACK_CHANGE,
AVRC_EVT_PLAY_POS_CHANGED,
AVRC_EVT_APP_SETTING_CHANGE,
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
- AVRC_EVT_NOW_PLAYING_CHANGE,
- AVRC_EVT_AVAL_PLAYERS_CHANGE,
- AVRC_EVT_ADDR_PLAYER_CHANGE,
-// AVRC_EVT_UIDS_CHANGE,
- AVRC_EVT_VOLUME_CHANGE
-#endif
};
#ifndef BTA_AV_NUM_RC_EVT_IDS
#define BTA_AV_NUM_RC_EVT_IDS (sizeof(bta_av_meta_caps_evt_ids) / sizeof(bta_av_meta_caps_evt_ids[0]))
@@ -84,15 +69,7 @@ const UINT8 bta_av_meta_caps_evt_ids[] = {
#else /* !ANDROID_APP_INCLUDED */
/* Note: if AVRC_SUPF_TG_GROUP_NAVI is set, bta_av_cfg.avrc_group should be TRUE */
-#if AVRC_ADV_CTRL_INCLUDED == TRUE
-#define BTA_AV_RC_SUPF_TG (AVRC_SUPF_TG_CAT1|AVRC_SUPF_TG_APP_SETTINGS|AVRC_SUPF_TG_GROUP_NAVI|AVRC_SUPF_TG_BROWSE|AVRC_SUPF_TG_MULTI_PLAYER)
-#else
-#if AVRC_METADATA_INCLUDED == TRUE
-#define BTA_AV_RC_SUPF_TG (AVRC_SUPF_TG_CAT1|AVRC_SUPF_TG_APP_SETTINGS|AVRC_SUPF_TG_GROUP_NAVI)
-#else
#define BTA_AV_RC_SUPF_TG (AVRC_SUPF_TG_CAT1)
-#endif
-#endif
const UINT16 bta_av_audio_flush_to[] = {
120, /* 1 stream */
@@ -115,22 +92,11 @@ const UINT8 bta_av_meta_caps_evt_ids[] = {
AVRC_EVT_BATTERY_STATUS_CHANGE,
AVRC_EVT_SYSTEM_STATUS_CHANGE,
AVRC_EVT_APP_SETTING_CHANGE,
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
- AVRC_EVT_NOW_PLAYING_CHANGE,
- AVRC_EVT_AVAL_PLAYERS_CHANGE,
- AVRC_EVT_ADDR_PLAYER_CHANGE,
- AVRC_EVT_UIDS_CHANGE,
- AVRC_EVT_VOLUME_CHANGE
-#endif
};
#ifndef BTA_AV_NUM_RC_EVT_IDS
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
-#define BTA_AV_NUM_RC_EVT_IDS 13
-#else
#define BTA_AV_NUM_RC_EVT_IDS 8
#endif
-#endif
#endif /* ANDROID_APP_INCLUDED */
@@ -142,13 +108,8 @@ const UINT8 bta_av_meta_caps_evt_ids[] = {
const tBTA_AV_CFG bta_av_cfg =
{
AVRC_CO_BROADCOM, /* AVRCP Company ID */
-#if AVRC_METADATA_INCLUDED == TRUE
- 512, /* AVRCP MTU at L2CAP for control channel */
- BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */
-#else
48, /* AVRCP MTU at L2CAP for control channel */
BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */
-#endif
BTA_AV_RC_SUPF_CT, /* AVRCP controller categories */
BTA_AV_RC_SUPF_TG, /* AVRCP target categories */
672, /* AVDTP signaling channel MTU at L2CAP */
diff --git a/bta/dg/bta_dg_act.c b/bta/dg/bta_dg_act.c
deleted file mode 100644
index f01d606..0000000
--- a/bta/dg/bta_dg_act.c
+++ /dev/null
@@ -1,900 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_dg_act.c
-**
-** Description: This file contains the data gateway action functions
-** for the state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_DG_INCLUDED) && (BTA_DG_INCLUDED == TRUE)
-
-#include <string.h>
-#include "bta_api.h"
-#include "bta_sys.h"
-#include "bta_dg_api.h"
-#include "bta_dg_int.h"
-#include "bta_dg_co.h"
-#include "btm_api.h"
-#include "sdp_api.h"
-#include "dun_api.h"
-#include "gki.h"
-#include "bd.h"
-
-/* Event mask for RfCOMM port callback */
-#define BTA_DG_PORT_EV_MASK (PORT_EV_FC | PORT_EV_FCS | PORT_EV_RXCHAR | \
- PORT_EV_TXEMPTY | PORT_EV_CTS | PORT_EV_DSR | \
- PORT_EV_RING | PORT_EV_CTSS | PORT_EV_DSRS)
-
-/* RX and TX data flow mask */
-#define BTA_DG_RX_MASK 0x0F
-#define BTA_DG_TX_MASK 0xF0
-
-/* size of database for service discovery */
-#define BTA_DG_DISC_BUF_SIZE 450
-
-/* size of discovery db taking into account tBTA_DG_SDP_DB */
-#define BTA_DG_SDP_DB_SIZE (BTA_DG_DISC_BUF_SIZE - (UINT32) &((tBTA_DG_SDP_DB *) 0)->db)
-
-/* UUID lookup table */
-const UINT16 bta_dg_uuid[] =
-{
- UUID_SERVCLASS_SERIAL_PORT, /* BTA_SPP_SERVICE_ID */
- UUID_SERVCLASS_DIALUP_NETWORKING, /* BTA_DUN_SERVICE_ID */
- UUID_SERVCLASS_FAX, /* BTA_FAX_SERVICE_ID */
- UUID_SERVCLASS_LAN_ACCESS_USING_PPP /* BTA_LAP_SERVICE_ID */
-};
-
-/* BTM service ID lookup table */
-const UINT8 bta_dg_sec_id[] =
-{
- BTM_SEC_SERVICE_SERIAL_PORT, /* BTA_SPP_SERVICE_ID */
- BTM_SEC_SERVICE_DUN, /* BTA_DUN_SERVICE_ID */
- BTM_SEC_SERVICE_FAX, /* BTA_FAX_SERVICE_ID */
- BTM_SEC_SERVICE_SERIAL_PORT /* BTA_LAP_SERVICE_ID */
-};
-
-/* RS-232 signal lookup table */
-const UINT8 bta_dg_sig[2][4] =
-{
- {PORT_CLR_DTRDSR, PORT_CLR_CTSRTS, PORT_CLR_RI, PORT_CLR_DCD},
- {PORT_SET_DTRDSR, PORT_SET_CTSRTS, PORT_SET_RI, PORT_SET_DCD}
-};
-
-/* declare sdp callback functions */
-void bta_dg_sdp_cback_1(UINT16 status);
-void bta_dg_sdp_cback_2(UINT16 status);
-void bta_dg_sdp_cback_3(UINT16 status);
-void bta_dg_sdp_cback_4(UINT16 status);
-void bta_dg_sdp_cback_5(UINT16 status);
-void bta_dg_sdp_cback_6(UINT16 status);
-void bta_dg_sdp_cback_7(UINT16 status);
-void bta_dg_sdp_cback_8(UINT16 status);
-
-/* SDP callback function table */
-typedef tSDP_DISC_CMPL_CB *tBTA_DG_SDP_CBACK;
-const tBTA_DG_SDP_CBACK bta_dg_sdp_cback_tbl[] =
-{
- bta_dg_sdp_cback_1,
- bta_dg_sdp_cback_2,
- bta_dg_sdp_cback_3,
- bta_dg_sdp_cback_4,
- bta_dg_sdp_cback_5,
- bta_dg_sdp_cback_6,
- bta_dg_sdp_cback_7,
- bta_dg_sdp_cback_8
-};
-
-/*******************************************************************************
-**
-** Function bta_dg_sdp_cback
-**
-** Description SDP callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_dg_sdp_cback(UINT16 status, UINT8 idx)
-{
- tBTA_DG_DISC_RESULT *p_buf;
-
- APPL_TRACE_DEBUG1("bta_dg_sdp_cback status:0x%x", status);
-
- if ((p_buf = (tBTA_DG_DISC_RESULT *) GKI_getbuf(sizeof(tBTA_DG_DISC_RESULT))) != NULL)
- {
- p_buf->hdr.event = BTA_DG_DISC_RESULT_EVT;
- p_buf->hdr.layer_specific = idx;
- p_buf->status = status;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_sdp_cback_1 to 8
-**
-** Description SDP callback functions. Since there is no way to
-** distinguish scb from the callback we need separate
-** callbacks for each scb.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_sdp_cback_1(UINT16 status) {bta_dg_sdp_cback(status, 1);}
-void bta_dg_sdp_cback_2(UINT16 status) {bta_dg_sdp_cback(status, 2);}
-void bta_dg_sdp_cback_3(UINT16 status) {bta_dg_sdp_cback(status, 3);}
-void bta_dg_sdp_cback_4(UINT16 status) {bta_dg_sdp_cback(status, 4);}
-void bta_dg_sdp_cback_5(UINT16 status) {bta_dg_sdp_cback(status, 5);}
-void bta_dg_sdp_cback_6(UINT16 status) {bta_dg_sdp_cback(status, 6);}
-void bta_dg_sdp_cback_7(UINT16 status) {bta_dg_sdp_cback(status, 7);}
-void bta_dg_sdp_cback_8(UINT16 status) {bta_dg_sdp_cback(status, 8);}
-
-/*******************************************************************************
-**
-** Function bta_dg_port_cback
-**
-** Description RFCOMM Port callback
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_dg_port_cback(UINT32 code, UINT16 port_handle)
-{
- tBTA_DG_RFC_PORT *p_buf;
- tBTA_DG_SCB *p_scb;
-
- /* set flow control state directly */
- if (code & PORT_EV_FC)
- {
- if ((p_scb = bta_dg_scb_by_handle(port_handle)) != NULL)
- {
- p_scb->rfc_enable = ((code & PORT_EV_FCS) == PORT_EV_FCS);
-
- if ((p_scb->flow_mask & BTA_DG_RX_MASK) == BTA_DG_RX_PUSH_BUF)
- {
- bta_dg_co_rx_flow(port_handle, p_scb->app_id, p_scb->rfc_enable);
- }
- }
- }
-
- if ((p_buf = (tBTA_DG_RFC_PORT *) GKI_getbuf(sizeof(tBTA_DG_RFC_PORT))) != NULL)
- {
- p_buf->hdr.event = BTA_DG_RFC_PORT_EVT;
- p_buf->hdr.layer_specific = port_handle;
- p_buf->code = code;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_mgmt_cback
-**
-** Description RFCOMM management callback
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_dg_mgmt_cback(UINT32 code, UINT16 port_handle)
-{
- BT_HDR *p_buf;
- tBTA_DG_SCB *p_scb;
-
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->layer_specific = port_handle;
-
- if (code == PORT_SUCCESS)
- {
- p_buf->event = BTA_DG_RFC_OPEN_EVT;
- bta_sys_sendmsg(p_buf);
- }
- else
- {
- if ((p_scb = bta_dg_scb_by_handle(port_handle)) != NULL)
- {
-/* APPL_TRACE_EVENT6("DG Port Close: handle %d, scb %d, app_id %d, in_use %d, scn %d, state %d",
- port_handle, bta_dg_scb_to_idx(p_scb), p_scb->app_id, p_scb->in_use, p_scb->scn, p_scb->state);
-*/
- p_buf->event = BTA_DG_RFC_CLOSE_EVT;
-
- /* Execute close event before exiting RFC callback to avoid a race
- condition where RFC could reallocate port_handle before DG can
- process the event queue
- */
- bta_dg_sm_execute(p_scb, p_buf->event, (tBTA_DG_DATA *) p_buf);
- }
- else
- {
- APPL_TRACE_WARNING1("DG received RFC Close for unknown handle (%d)",
- port_handle);
- }
-
- GKI_freebuf(p_buf);
- }
- }
- else
- {
- APPL_TRACE_ERROR0("DG RFC callback: No Resources!");
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_data_cback
-**
-** Description RFCOMM data callback. This callback is used when a server
-** TX data path is configured for BTA_DG_TX_PUSH to transfer
-** data directly from RFCOMM to the phone.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static int bta_dg_data_cback(UINT16 port_handle, void *p_data, UINT16 len)
-{
- tBTA_DG_SCB *p_scb;
-
- if ((p_scb = bta_dg_scb_by_handle(port_handle)) != NULL)
- {
- bta_dg_co_tx_write(port_handle, p_scb->app_id, (UINT8 *) p_data, len);
- }
- return 0;
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_setup_port
-**
-** Description Setup RFCOMM port for use by DG.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_dg_setup_port(tBTA_DG_SCB *p_scb)
-{
- /* store scb in handle lookup table */
- bta_dg_cb.hdl_to_scb[p_scb->port_handle - 1] = bta_dg_scb_to_idx(p_scb);
-
- /* call application init call-out */
- p_scb->flow_mask = bta_dg_co_init(p_scb->port_handle, p_scb->app_id);
-
- /* set up port and data callbacks */
- if ((p_scb->flow_mask & BTA_DG_TX_MASK) == BTA_DG_TX_PUSH)
- {
- PORT_SetDataCallback(p_scb->port_handle, bta_dg_data_cback);
- }
- PORT_SetEventMask(p_scb->port_handle, BTA_DG_PORT_EV_MASK);
- PORT_SetEventCallback(p_scb->port_handle, bta_dg_port_cback);
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_setup_server
-**
-** Description This function initializes values of the DG scb and sets up
-** the SDP record for the server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_setup_server(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- tBTA_DG_LISTEN listen;
- tBTA_DG_SCB *p_match;
-
- /* initialize control block */
- p_scb->service_id = p_data->api_listen.service;
- p_scb->sec_mask = p_data->api_listen.sec_mask;
- p_scb->app_id = p_data->api_listen.app_id;
- p_scb->is_server = TRUE;
- BCM_STRNCPY_S(p_scb->name, BTA_SERVICE_NAME_LEN+1, p_data->api_listen.name, BTA_SERVICE_NAME_LEN);
- p_scb->name[BTA_SERVICE_NAME_LEN] = '\0';
-
- /* if existing matching server */
- if ((p_match = bta_dg_server_match(p_scb)) != NULL)
- {
- /* set SCN same as existing matching server */
- p_scb->scn = p_match->scn;
-
- /* copy sdp handle in order to unregister it from any server instance (being last) */
- p_scb->sdp_handle = p_match->sdp_handle;
- }
- else
- {
- /* allocate SDP record and SCN */
- p_scb->sdp_handle = SDP_CreateRecord();
- p_scb->scn = BTM_AllocateSCN();
- APPL_TRACE_DEBUG2( "bta_dg_setup_server: x%x, scn:%d", p_scb->sdp_handle, p_scb->scn);
-
- /* set up sdp record */
- DUN_AddRecord(bta_dg_uuid[p_scb->service_id - BTA_SPP_SERVICE_ID],
- p_data->api_listen.name, p_scb->scn, 0, p_scb->sdp_handle);
-
- bta_sys_add_uuid(bta_dg_uuid[p_scb->service_id - BTA_SPP_SERVICE_ID]);
- }
-
- /* Listen on RFCOMM port */
- bta_dg_listen(p_scb, p_data);
-
- /* call app callback with listen event */
- listen.handle = bta_dg_scb_to_idx(p_scb);
- listen.app_id = p_scb->app_id;
- (*bta_dg_cb.p_cback)(BTA_DG_LISTEN_EVT, (tBTA_DG *) &listen);
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_listen
-**
-** Description Call DUN_Listen to set up a server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_listen(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- UINT8 lkup_id = p_scb->service_id - BTA_SPP_SERVICE_ID;
-
- /* Listen on RFCOMM port */
- if (DUN_Listen(bta_dg_uuid[lkup_id], p_scb->name, p_scb->scn, p_bta_dg_cfg->mtu[lkup_id],
- p_scb->sec_mask, &p_scb->port_handle, bta_dg_mgmt_cback)
- == DUN_SUCCESS)
- {
- bta_dg_setup_port(p_scb);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_del_record
-**
-** Description Delete SDP record.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_del_record(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- /* if no existing matching server */
- if (bta_dg_server_match(p_scb) == NULL)
- {
- APPL_TRACE_DEBUG1( "bta_dg_del_record: x%x", p_scb->sdp_handle);
- if(p_scb->sdp_handle)
- SDP_DeleteRecord(p_scb->sdp_handle);
- bta_sys_remove_uuid( bta_dg_uuid[p_scb->service_id - BTA_SPP_SERVICE_ID] );
- BTM_FreeSCN(p_scb->scn);
- BTM_SecClrService(bta_dg_sec_id[p_scb->service_id - BTA_SPP_SERVICE_ID]);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_shutdown
-**
-** Description Shut down a server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_shutdown(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- UINT8 status;
-
- APPL_TRACE_DEBUG1( "bta_dg_shutdown: x%x", p_scb->sdp_handle);
-
- status = DUN_Shutdown(p_scb->port_handle);
-
- APPL_TRACE_DEBUG1("DUN shutdown status %d", status);
-
- bta_dg_del_record(p_scb, p_data);
-
- /* set shutdown flag */
- p_scb->dealloc = TRUE;
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_close
-**
-** Description Close RFCOMM connection.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_close(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- if (p_scb->port_handle)
- {
- DUN_Close(p_scb->port_handle);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_set_dealloc
-**
-** Description Set the dealloc flag.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_set_dealloc(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- p_scb->dealloc = TRUE;
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_rx_path
-**
-** Description Handle data on the RX path (data sent from the phone to
-** BTA).
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_rx_path(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- /* if data path configured for rx pull */
- if ((p_scb->flow_mask & BTA_DG_RX_MASK) == BTA_DG_RX_PULL)
- {
- /* if RFCOMM can accept data */
- if (p_scb->rfc_enable == TRUE)
- {
- /* call application callout function for rx path */
- bta_dg_co_rx_path(p_scb->port_handle, p_scb->app_id, p_scb->mtu);
- }
- }
- /* else data path configured for rx push */
- else
- {
-
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_tx_path
-**
-** Description Handle the TX data path (data sent from BTA to the phone).
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_tx_path(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- BT_HDR *p_buf;
- UINT16 port_errors;
- tPORT_STATUS port_status;
- int status;
-
- /* if data path configured for tx pull */
- if ((p_scb->flow_mask & BTA_DG_TX_MASK) == BTA_DG_TX_PULL)
- {
- /* call application callout function for tx path */
- bta_dg_co_tx_path(p_scb->port_handle, p_scb->app_id);
- }
- /* if configured for zero copy push */
- else if ((p_scb->flow_mask & BTA_DG_TX_MASK) == BTA_DG_TX_PUSH_BUF)
- {
- /* if app can accept data */
- while (p_scb->app_enable == TRUE)
- {
- /* read data from RFCOMM */
- if ((status = PORT_Read(p_scb->port_handle, &p_buf)) == PORT_SUCCESS)
- {
- if(p_buf == NULL)
- {
- return;
- }
- /* send data to application */
- bta_dg_co_tx_writebuf(p_scb->port_handle, p_scb->app_id, p_buf);
- }
- else if (status == PORT_LINE_ERR)
- {
- PORT_ClearError(p_scb->port_handle, &port_errors, &port_status);
- return;
- }
- else
- {
- return;
- }
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_fc_state
-**
-** Description Set the application flow control state.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_fc_state(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- p_scb->app_enable = p_data->ci_tx_flow.enable;
- PORT_FlowControl(p_scb->port_handle, p_scb->app_enable);
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_writebuf
-**
-** Description Handle a bta_dg_ci_rx_writebuf() and send data to RFCOMM.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_writebuf(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- if ((p_scb->flow_mask & BTA_DG_RX_MASK) == BTA_DG_RX_PUSH_BUF)
- {
- PORT_Write(p_scb->port_handle, (BT_HDR *) p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_control
-**
-** Description Pass RS-232 control signals from phone to RFCOMM.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_control(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- {
- if (p_data->ci_control.signals & 1)
- {
- PORT_Control(p_scb->port_handle, bta_dg_sig[(p_data->ci_control.values & 1)][i]);
- }
- p_data->ci_control.signals >>= 1;
- p_data->ci_control.values >>= 1;
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_rfc_control
-**
-** Description Handle a change in RS-232 signals from RFCOMM
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_rfc_control(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- UINT8 signals = 0;
- UINT8 values = 0;
- UINT8 port_values = 0;
-
- PORT_GetModemStatus(p_scb->port_handle, &port_values);
-
- if (p_data->rfc_port.code & PORT_EV_CTS)
- {
- values |= (p_data->rfc_port.code & PORT_EV_CTSS) ? BTA_DG_RTSCTS_ON : BTA_DG_RTSCTS_OFF;
- signals |= BTA_DG_RTSCTS;
- }
- if (p_data->rfc_port.code & PORT_EV_DSR)
- {
- values |= (p_data->rfc_port.code & PORT_EV_DSRS) ? BTA_DG_DTRDSR_ON : BTA_DG_DTRDSR_OFF;
- signals |= BTA_DG_DTRDSR;
- }
- if (p_data->rfc_port.code & PORT_EV_RING)
- {
- values |= (port_values & PORT_RING_ON);
- signals |= BTA_DG_RI;
- }
-
- bta_dg_co_control(p_scb->port_handle, p_scb->app_id, signals, values);
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_rfc_open
-**
-** Description Handle RFCOMM channel opening.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_rfc_open(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- tPORT_STATUS status;
- UINT16 lcid;
- tBTA_DG_OPEN open;
-
- /* reset flow control state */
- p_scb->rfc_enable = TRUE;
- p_scb->app_enable = TRUE;
-
- /* get mtu of connection */
- PORT_GetQueueStatus(p_scb->port_handle, &status);
- p_scb->mtu = status.mtu_size;
-
- /* call app call-out */
- bta_dg_co_open(p_scb->port_handle, p_scb->app_id, p_scb->service_id, p_scb->mtu);
-
- /* get bd addr of peer */
- PORT_CheckConnection(p_scb->port_handle, open.bd_addr, &lcid);
-
- /* call app callback with open event */
- open.handle = bta_dg_scb_to_idx(p_scb);
- open.service = p_scb->service_id;
- open.app_id = p_scb->app_id;
-
- bdcpy(p_scb->peer_addr, open.bd_addr);
-
- /* inform role manager */
- bta_sys_conn_open( BTA_ID_DG ,p_scb->app_id, open.bd_addr);
-
- (*bta_dg_cb.p_cback)(BTA_DG_OPEN_EVT, (tBTA_DG *) &open);
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_rfc_close
-**
-** Description
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_rfc_close(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- tBTA_DG_CLOSE close;
-
- /* call app call-out */
- if (p_scb->port_handle != 0)
- {
- bta_dg_co_close(p_scb->port_handle, p_scb->app_id);
- }
-
- /* call app callback */
- close.handle = bta_dg_scb_to_idx(p_scb);
- close.app_id = p_scb->app_id;
-
- /* inform role manager */
- bta_sys_conn_close( BTA_ID_DG ,p_scb->app_id, p_scb->peer_addr);
-
- (*bta_dg_cb.p_cback)(BTA_DG_CLOSE_EVT, (tBTA_DG *) &close);
-
- /* if not shutting down, initialize the server */
- if (p_scb->dealloc == FALSE)
- {
- bta_dg_setup_port(p_scb);
- }
- /* else dealloc control block */
- else
- {
- bta_dg_scb_dealloc(p_scb);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_dealloc
-**
-** Description
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_dealloc(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- APPL_TRACE_DEBUG1( "bta_dg_dealloc: x%x", p_scb->sdp_handle);
- bta_dg_scb_dealloc(p_scb);
-}
-/*******************************************************************************
-**
-** Function bta_dg_disc_result
-**
-** Description Process a discovery result.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_disc_result(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- tSDP_DISC_REC *p_rec = NULL;
- tSDP_DISC_ATTR *p_attr;
- tSDP_PROTOCOL_ELEM pe;
- UINT16 name_len;
- char *p_name;
- UINT16 evt = BTA_DG_DISC_FAIL_EVT;
-
-
- if (p_data->disc_result.status == SDP_SUCCESS || p_data->disc_result.status == SDP_DB_FULL)
- {
- /* loop through all records we found */
- while (TRUE)
- {
- /* get next record; if none found, we're done */
- if ((p_rec = SDP_FindServiceInDb(&p_scb->p_disc->db,
- bta_dg_uuid[p_scb->service_id - BTA_SPP_SERVICE_ID], p_rec)) == NULL)
- {
- break;
- }
-
- /* get scn from proto desc list; if not found, go to next record */
- if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
- {
- p_scb->scn = (UINT8) pe.params[0];
- }
- else
- {
- continue;
- }
-
- /* if service name provided for match */
- if (p_scb->p_disc->name[0] != 0)
- {
- /* get service name */
- if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL)
- {
- /* check if name matches */
- p_name = (char *) p_attr->attr_value.v.array;
- name_len = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
- if (strncmp(p_scb->p_disc->name, p_name, name_len) == 0)
- {
- /* name matches; we found it */
- evt = BTA_DG_DISC_OK_EVT;
- break;
- }
- else
- {
- /* name does not match; continue */
- continue;
- }
- }
- }
- /* else name match not required; we're done */
- else
- {
- evt = BTA_DG_DISC_OK_EVT;
- break;
- }
- }
- }
-
- /* send ourselves event to process disc ok or fail */
- bta_dg_sm_execute(p_scb, evt, NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_do_disc
-**
-** Description Do service discovery.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_do_disc(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- tBTA_DG_OPENING opening;
- tSDP_UUID uuid_list;
- UINT16 attr_list[] = {ATTR_ID_SERVICE_CLASS_ID_LIST,
- ATTR_ID_PROTOCOL_DESC_LIST,
- ATTR_ID_SERVICE_NAME};
-
- /* allocate buffer for sdp database */
- if ((p_scb->p_disc = (tBTA_DG_SDP_DB *) GKI_getbuf(BTA_DG_DISC_BUF_SIZE)) != NULL)
- {
- /* store parameters */
- BCM_STRCPY_S(p_scb->p_disc->name, sizeof(p_scb->p_disc->name), p_data->api_open.name);
- bdcpy(p_scb->peer_addr, p_data->api_open.bd_addr);
- p_scb->sec_mask = p_data->api_open.sec_mask;
- p_scb->service_id = p_data->api_open.service;
- p_scb->app_id = p_data->api_open.app_id;
-
- /* initialize some scb parameters */
- p_scb->dealloc = TRUE;
- p_scb->port_handle = 0;
-
-
- bta_sys_app_open(BTA_ID_DG, p_scb->app_id, p_scb->peer_addr);
-
- /* set up service discovery database */
- uuid_list.len = LEN_UUID_16;
- uuid_list.uu.uuid16 = bta_dg_uuid[p_scb->service_id - BTA_SPP_SERVICE_ID];
-
- /* coverity[OVERRUN_STATIC] False-positive: All pointers are ok. len parameter size (in bytes) of the memory must be larger than sizeof(tSDP_DISCOVERY_DB) */
- SDP_InitDiscoveryDb(&p_scb->p_disc->db, BTA_DG_SDP_DB_SIZE, 1, &uuid_list, 3, attr_list);
-
- /* initiate service discovery */
- if (SDP_ServiceSearchAttributeRequest(p_scb->peer_addr, &p_scb->p_disc->db,
- bta_dg_sdp_cback_tbl[bta_dg_scb_to_idx(p_scb) - 1]))
- {
- /* call callback with opening event */
- opening.handle = bta_dg_scb_to_idx(p_scb);
- opening.app_id = p_scb->app_id;
- (*bta_dg_cb.p_cback)(BTA_DG_OPENING_EVT, (tBTA_DG *) &opening);
- }
- else
- {
- bta_dg_sdp_cback(SDP_NO_RESOURCES, bta_dg_scb_to_idx(p_scb));
- }
- }
- else
- {
- APPL_TRACE_ERROR0("DG DISC: No Resources!");
- }
-
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_open
-**
-** Description Open a client connection.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_open(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- UINT8 lkup_id = p_scb->service_id - BTA_SPP_SERVICE_ID;
-
- if (DUN_Connect(bta_dg_uuid[lkup_id], p_scb->peer_addr, p_scb->scn, p_bta_dg_cfg->mtu[lkup_id],
- p_scb->sec_mask, &p_scb->port_handle, bta_dg_mgmt_cback) == DUN_SUCCESS)
- {
- bta_dg_setup_port(p_scb);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_free_db
-**
-** Description Free discovery database.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_free_db(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data)
-{
- if (p_scb->p_disc != NULL)
- {
- GKI_freebuf(p_scb->p_disc);
- p_scb->p_disc = NULL;
- }
-}
-
-#endif /* BTA_DG_INCLUDED */
diff --git a/bta/dg/bta_dg_api.c b/bta/dg/bta_dg_api.c
deleted file mode 100644
index ab4b737..0000000
--- a/bta/dg/bta_dg_api.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_dg_api.c
-**
-** Description: This is the implementation of the API for the data gateway
-** (DG) subsystem of BTA, Widcomm's Bluetooth application
-** layer for mobile phones.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_DG_INCLUDED) && (BTA_DG_INCLUDED == TRUE)
-
-#include <string.h>
-#include "bta_api.h"
-#include "bta_sys.h"
-#include "bta_dg_api.h"
-#include "bta_dg_int.h"
-#include "gki.h"
-#include "bd.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-static const tBTA_SYS_REG bta_dg_reg =
-{
- bta_dg_hdl_event,
- BTA_DgDisable
-};
-
-/*******************************************************************************
-**
-** Function BTA_DgEnable
-**
-** Description Enable the data gateway service. This function must be
-** called before any other functions in the DG API are called.
-** When the enable operation is complete the callback function
-** will be called with a BTA_DG_ENABLE_EVT. After the DG
-** service is enabled a server can be started by calling
-** BTA_DgListen().
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_DgEnable(tBTA_DG_CBACK *p_cback)
-{
- tBTA_DG_API_ENABLE *p_buf;
-
- /* register with BTA system manager */
- GKI_sched_lock();
- bta_sys_register(BTA_ID_DG, &bta_dg_reg);
- GKI_sched_unlock();
-
- APPL_TRACE_API0( "BTA_DgEnable");
- if ((p_buf = (tBTA_DG_API_ENABLE *) GKI_getbuf(sizeof(tBTA_DG_API_ENABLE))) != NULL)
- {
- p_buf->hdr.event = BTA_DG_API_ENABLE_EVT;
- p_buf->p_cback = p_cback;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_DgDisable
-**
-** Description Disable the data gateway service. Before calling this
-** function all DG servers must be shut down by calling
-** BTA_DgShutdown().
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_DgDisable(void)
-{
- BT_HDR *p_buf;
-
- APPL_TRACE_API0( "BTA_DgDisable");
- bta_sys_deregister(BTA_ID_DG);
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_DG_API_DISABLE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_DgListen
-**
-** Description Create a DG server for DUN, FAX or SPP. After creating a
-** server peer devices can open an RFCOMM connection to the
-** server. When the listen operation has started the callback
-** function will be called with a BTA_DG_LISTEN_EVT providing
-** the handle associated with this server. The handle
-** identifies server when calling other DG functions such as
-** BTA_DgClose() or BTA_DgShutdown().
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_DgListen(tBTA_SERVICE_ID service, tBTA_SEC sec_mask,
- char *p_service_name, UINT8 app_id)
-{
- tBTA_DG_API_LISTEN *p_buf;
-
- APPL_TRACE_API1( "BTA_DgListen %d", service);
- if ((p_buf = (tBTA_DG_API_LISTEN *) GKI_getbuf(sizeof(tBTA_DG_API_LISTEN))) != NULL)
- {
- p_buf->hdr.event = BTA_DG_API_LISTEN_EVT;
- BCM_STRNCPY_S(p_buf->name, sizeof(p_buf->name), p_service_name, BTA_SERVICE_NAME_LEN);
- p_buf->sec_mask = sec_mask;
- p_buf->service = service;
- p_buf->app_id = app_id;
- bta_sys_sendmsg(p_buf);
- }
-}
-/*******************************************************************************
-**
-** Function BTA_DgOpen
-**
-** Description Open a DG client connection to a peer device. BTA first
-** searches for the requested service on the peer device. If
-** the service name is specified it will also match the
-** service name. Then BTA initiates an RFCOMM connection to
-** the peer device. The handle associated with the connection
-** is returned with the BTA_DG_OPEN_EVT. If the connection
-** fails or closes at any time the callback function will be
-** called with a BTA_DG_CLOSE_EVT.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_DgOpen(BD_ADDR bd_addr, tBTA_SERVICE_ID service, tBTA_SEC sec_mask,
- char *p_service_name, UINT8 app_id)
-{
- tBTA_DG_API_OPEN *p_buf;
-
- APPL_TRACE_API0( "BTA_DgOpen");
- if ((p_buf = (tBTA_DG_API_OPEN *) GKI_getbuf(sizeof(tBTA_DG_API_OPEN))) != NULL)
- {
- p_buf->hdr.event = BTA_DG_API_OPEN_EVT;
- bdcpy(p_buf->bd_addr, bd_addr);
- if (p_service_name != NULL)
- {
- BCM_STRNCPY_S(p_buf->name, sizeof(p_buf->name), p_service_name, BTA_SERVICE_NAME_LEN);
- }
- else
- {
- p_buf->name[0] = '\0';
- }
- p_buf->sec_mask = sec_mask;
- p_buf->service = service;
- p_buf->app_id = app_id;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_DgClose
-**
-** Description Close a DG server connection to a peer device. BTA will
-** close the RFCOMM connection to the peer device. The server
-** will still be listening for subsequent connections.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_DgClose(UINT16 handle)
-{
- BT_HDR *p_buf;
-
- APPL_TRACE_API0( "BTA_DgClose");
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_DG_API_CLOSE_EVT;
- p_buf->layer_specific = handle;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_DgShutdown
-**
-** Description Shutdown a DG server previously started by calling
-** BTA_DgListen(). The server will no longer be available
-** to peer devices. If there is currently a connection open
-** to the server it will be closed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_DgShutdown(UINT16 handle)
-{
- BT_HDR *p_buf;
-
- APPL_TRACE_API0( "BTA_DgShutdown");
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_DG_API_SHUTDOWN_EVT;
- p_buf->layer_specific = handle;
- bta_sys_sendmsg(p_buf);
- }
-}
-#endif /* BTA_DG_INCLUDED */
diff --git a/bta/dg/bta_dg_cfg.c b/bta/dg/bta_dg_cfg.c
deleted file mode 100644
index 6822c8d..0000000
--- a/bta/dg/bta_dg_cfg.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_dg_cfg.c
-**
-** Description: This file contains compile-time configurable constants
-** for the BTA data gateway.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_DG_INCLUDED) && (BTA_DG_INCLUDED == TRUE)
-
-// btla-specific ++
-#include "l2c_api.h"
-#include "rfcdefs.h"
-// btla-specific --
-#include "bta_dg_api.h"
-#include "rfcdefs.h"
-#include "l2c_api.h"
-
-/* RFCOMM MTU for SPP */
-#ifndef BTA_SPP_MTU
-#define BTA_SPP_MTU 330
-#endif
-
-/* RFCOMM MTU for DUN */
-#ifndef BTA_DUN_MTU
-// btla-specific ++
-#define BTA_DUN_MTU (330*3)
-// btla-specific --
-#endif
-
-/* RFCOMM MTU for FAX */
-#ifndef BTA_FAX_MTU
-#define BTA_FAX_MTU 112
-#endif
-
-/* RFCOMM MTU for LAP */
-#ifndef BTA_LAP_MTU
-#define BTA_LAP_MTU 330
-#endif
-
-const tBTA_DG_CFG bta_dg_cfg =
-{
- {BTA_SPP_MTU, BTA_DUN_MTU, BTA_FAX_MTU, BTA_LAP_MTU},
-
-};
-
-tBTA_DG_CFG *p_bta_dg_cfg = (tBTA_DG_CFG *)&bta_dg_cfg;
-#endif /* BTA_DG_INCLUDED */
diff --git a/bta/dg/bta_dg_ci.c b/bta/dg/bta_dg_ci.c
deleted file mode 100644
index 258eafe..0000000
--- a/bta/dg/bta_dg_ci.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_dg_ci.c
-**
-** Description: This is the implementation file for data gateway call-in
-** functions.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bta_api.h"
-#include "bta_dg_api.h"
-#include "bta_dg_ci.h"
-#include "bta_dg_int.h"
-#include "gki.h"
-
-/*******************************************************************************
-**
-** Function bta_dg_ci_tx_ready
-**
-** Description This function sends an event to DG indicating the phone is
-** ready for more data and DG should call bta_dg_co_tx_path().
-** This function is used when the TX data path is configured
-** to use a pull interface.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_ci_tx_ready(UINT16 handle)
-{
- BT_HDR *p_buf;
-
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_DG_CI_TX_READY_EVT;
- p_buf->layer_specific = handle;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_ci_rx_ready
-**
-** Description This function sends an event to DG indicating the phone
-** has data available to send to DG and DG should call
-** bta_dg_co_rx_path(). This function is used when the RX
-** data path is configured to use a pull interface.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_ci_rx_ready(UINT16 handle)
-{
- BT_HDR *p_buf;
-
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_DG_CI_RX_READY_EVT;
- p_buf->layer_specific = handle;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_ci_tx_flow
-**
-** Description This function is called to enable or disable data flow on
-** the TX path. The phone should call this function to
-** disable data flow when it is congested and cannot handle
-** any more data sent by bta_dg_co_tx_write() or
-** bta_dg_co_tx_writebuf(). This function is used when the
-** TX data path is configured to use a push interface.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_ci_tx_flow(UINT16 handle, BOOLEAN enable)
-{
- tBTA_DG_CI_TX_FLOW *p_buf;
-
- if ((p_buf = (tBTA_DG_CI_TX_FLOW *) GKI_getbuf(sizeof(tBTA_DG_CI_TX_FLOW))) != NULL)
- {
- p_buf->hdr.event = BTA_DG_CI_TX_FLOW_EVT;
- p_buf->hdr.layer_specific = handle;
- p_buf->enable = enable;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_ci_rx_write
-**
-** Description This function is called to send data to DG when the RX path
-** is configured to use a push interface. The function copies
-** data to an event buffer and sends it to DG.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_ci_rx_write(UINT16 handle, UINT8 *p_data, UINT16 len)
-{
-
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_ci_rx_writebuf
-**
-** Description This function is called to send data to the phone when
-** the RX path is configured to use a push interface with
-** zero copy. The function sends an event to DG containing
-** the data buffer. The buffer must be allocated using
-** functions GKI_getbuf() or GKI_getpoolbuf(). The buffer
-** will be freed by BTA; the phone must not free the buffer.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_ci_rx_writebuf(UINT16 handle, BT_HDR *p_buf)
-{
- p_buf->event = BTA_DG_CI_RX_WRITEBUF_EVT;
- p_buf->layer_specific = handle;
- bta_sys_sendmsg(p_buf);
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_ci_control
-**
-** Description This function is called to send RS-232 signal information
-** to DG to be propagated over RFCOMM.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_ci_control(UINT16 handle, UINT8 signals, UINT8 values)
-{
- tBTA_DG_CI_CONTROL *p_buf;
-
- if ((p_buf = (tBTA_DG_CI_CONTROL *) GKI_getbuf(sizeof(tBTA_DG_CI_CONTROL))) != NULL)
- {
- p_buf->hdr.event = BTA_DG_CI_CONTROL_EVT;
- p_buf->hdr.layer_specific = handle;
- p_buf->signals = signals;
- p_buf->values = values;
- bta_sys_sendmsg(p_buf);
- }
-}
diff --git a/bta/dg/bta_dg_int.h b/bta/dg/bta_dg_int.h
deleted file mode 100644
index 0f652e4..0000000
--- a/bta/dg/bta_dg_int.h
+++ /dev/null
@@ -1,220 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_dg_int.h
-**
-** Description: This is the private interface file for the BTA data
-** gateway.
-**
-** Copyright (c) 2003-2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_DG_INT_H
-#define BTA_DG_INT_H
-
-#include "bta_sys.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-
-/* DG events */
-enum
-{
- /* these events are handled by the state machine */
- BTA_DG_API_CLOSE_EVT = BTA_SYS_EVT_START(BTA_ID_DG),
- BTA_DG_API_SHUTDOWN_EVT,
- BTA_DG_API_LISTEN_EVT,
- BTA_DG_API_OPEN_EVT,
- BTA_DG_CI_TX_READY_EVT,
- BTA_DG_CI_RX_READY_EVT,
- BTA_DG_CI_TX_FLOW_EVT,
- BTA_DG_CI_RX_WRITEBUF_EVT,
- BTA_DG_CI_CONTROL_EVT,
- BTA_DG_RFC_OPEN_EVT,
- BTA_DG_RFC_CLOSE_EVT,
- BTA_DG_RFC_TX_READY_EVT,
- BTA_DG_RFC_RX_READY_EVT,
- BTA_DG_RFC_FC_EVT,
- BTA_DG_RFC_CONTROL_EVT,
- BTA_DG_DISC_RESULT_EVT,
- BTA_DG_DISC_OK_EVT,
- BTA_DG_DISC_FAIL_EVT,
-
- /* these events are handled outside of the state machine */
- BTA_DG_API_DISABLE_EVT,
- BTA_DG_API_ENABLE_EVT,
- BTA_DG_RFC_PORT_EVT
-};
-
-/*****************************************************************************
-** Data types
-*****************************************************************************/
-
-/* data type for BTA_DG_API_ENABLE_EVT */
-typedef struct
-{
- BT_HDR hdr; /* Event header */
- tBTA_DG_CBACK *p_cback; /* DG callback function */
-} tBTA_DG_API_ENABLE;
-
-/* data type for BTA_DG_API_LISTEN_EVT */
-typedef struct
-{
- BT_HDR hdr; /* Event header */
- char name[BTA_SERVICE_NAME_LEN+1]; /* Service name */
- tBTA_SEC sec_mask; /* Security mask */
- tBTA_SERVICE_ID service; /* Service ID */
- UINT8 app_id; /* Application ID */
-} tBTA_DG_API_LISTEN;
-
-/* data type for BTA_DG_API_OPEN_EVT */
-typedef struct
-{
- BT_HDR hdr; /* Event header */
- char name[BTA_SERVICE_NAME_LEN+1]; /* Service name */
- BD_ADDR bd_addr; /* Peer address */
- tBTA_SEC sec_mask; /* Security mask */
- tBTA_SERVICE_ID service; /* Service ID */
- UINT8 app_id; /* Application ID */
-} tBTA_DG_API_OPEN;
-
-/* data type for BTA_DG_CI_TX_FLOW_EVT */
-typedef struct
-{
- BT_HDR hdr; /* Event header */
- BOOLEAN enable; /* Flow control setting */
-} tBTA_DG_CI_TX_FLOW;
-
-/* data type for BTA_DG_CI_CONTROL_EVT */
-typedef struct
-{
- BT_HDR hdr; /* Event header */
- UINT8 signals; /* RS-232 signals */
- UINT8 values; /* RS-232 signal values */
-} tBTA_DG_CI_CONTROL;
-
-/* data type for BTA_DG_RFC_FC_EVT */
-typedef struct
-{
- BT_HDR hdr; /* Event header */
- BOOLEAN enable; /* TRUE if data flow enabled */
-} tBTA_DG_RFC_FC;
-
-/* data type for BTA_DG_RFC_PORT_EVT */
-typedef struct
-{
- BT_HDR hdr; /* Event header */
- UINT32 code; /* RFCOMM port callback event code mask */
-} tBTA_DG_RFC_PORT;
-
-/* data type for BTA_DG_DISC_RESULT_EVT */
-typedef struct
-{
- BT_HDR hdr; /* Event header */
- UINT16 status; /* SDP status */
-} tBTA_DG_DISC_RESULT;
-
-/* union of all data types */
-typedef union
-{
- BT_HDR hdr;
- tBTA_DG_API_ENABLE api_enable;
- tBTA_DG_API_LISTEN api_listen;
- tBTA_DG_API_OPEN api_open;
- tBTA_DG_CI_TX_FLOW ci_tx_flow;
- tBTA_DG_CI_CONTROL ci_control;
- tBTA_DG_RFC_FC rfc_fc;
- tBTA_DG_RFC_PORT rfc_port;
- tBTA_DG_DISC_RESULT disc_result;
-} tBTA_DG_DATA;
-
-/* type used to store temporary sdp data */
-typedef struct
-{
- char name[BTA_SERVICE_NAME_LEN+1]; /* Service name */
- tSDP_DISCOVERY_DB db; /* Discovery database */
-} tBTA_DG_SDP_DB;
-
-/* state machine control block */
-typedef struct
-{
- char name[BTA_SERVICE_NAME_LEN+1]; /* Service name */
- BD_ADDR peer_addr; /* BD address of peer device */
- tBTA_DG_SDP_DB *p_disc; /* pointer to sdp discovery db */
- UINT32 sdp_handle; /* SDP record handle */
- UINT16 port_handle; /* RFCOMM port handle */
- UINT16 mtu; /* RFCOMM MTU */
- tBTA_SERVICE_ID service_id; /* Profile service ID */
- tBTA_SEC sec_mask; /* Security mask */
- BOOLEAN rfc_enable; /* RFCOMM flow control state */
- BOOLEAN app_enable; /* Application flow control state */
- BOOLEAN in_use; /* TRUE if SCB in use */
- BOOLEAN dealloc; /* TRUE if service shutting down */
- BOOLEAN is_server; /* TRUE if scb is for server */
- UINT8 state; /* State machine state */
- UINT8 app_id; /* Application ID */
- UINT8 scn; /* Server channel number */
- UINT8 flow_mask; /* Data flow mask */
-} tBTA_DG_SCB;
-
-/* main control block */
-typedef struct
-{
- tBTA_DG_SCB scb[BTA_DG_NUM_CONN]; /* state machine control blocks */
- UINT8 hdl_to_scb[MAX_RFC_PORTS+1];/* port to state machine lookup table */
- tBTA_DG_CBACK *p_cback; /* DG callback function */
-} tBTA_DG_CB;
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* DG control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-extern tBTA_DG_CB bta_dg_cb;
-#else
-extern tBTA_DG_CB *bta_dg_cb_ptr;
-#define bta_dg_cb (*bta_dg_cb_ptr)
-#endif
-
-/* DG configuration constants */
-extern tBTA_DG_CFG * p_bta_dg_cfg;
-
-/*****************************************************************************
-** Function prototypes
-*****************************************************************************/
-
-extern void bta_dg_scb_dealloc(tBTA_DG_SCB *p_scb);
-extern UINT8 bta_dg_scb_to_idx(tBTA_DG_SCB *p_scb);
-extern tBTA_DG_SCB *bta_dg_scb_by_idx(UINT16 idx);
-extern tBTA_DG_SCB *bta_dg_scb_by_handle(UINT16 handle);
-extern tBTA_DG_SCB *bta_dg_server_match(tBTA_DG_SCB *p_srv);
-extern BOOLEAN bta_dg_hdl_event(BT_HDR *p_msg);
-extern void bta_dg_sm_execute(tBTA_DG_SCB *p_scb, UINT16 event, tBTA_DG_DATA *p_data);
-
-/* action functions */
-extern void bta_dg_setup(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_listen(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_del_record(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_shutdown(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_close(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_set_dealloc(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_rx_path(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_tx_path(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_fc_state(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_writebuf(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_control(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_rfc_control(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_rfc_open(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_rfc_close(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_dealloc(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_disc_result(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_do_disc(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_open(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_free_db(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-extern void bta_dg_setup_server(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-
-
-#endif /* BTA_DG_INT_H */
diff --git a/bta/dg/bta_dg_main.c b/bta/dg/bta_dg_main.c
deleted file mode 100644
index 63e6db5..0000000
--- a/bta/dg/bta_dg_main.c
+++ /dev/null
@@ -1,597 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_dg_main.c
-**
-** Description: This file contains the data gateway main functions and
-** state machine.
-**
-** Copyright (c) 2003-2006, Broadcom Corp., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_DG_INCLUDED) && (BTA_DG_INCLUDED == TRUE)
-
-#include <string.h>
-#include "bta_api.h"
-#include "bta_sys.h"
-#include "bta_dg_api.h"
-#include "bta_dg_int.h"
-#include "port_api.h"
-
-/*****************************************************************************
-** Constants and types
-*****************************************************************************/
-
-/* state machine states */
-enum
-{
- BTA_DG_INIT_ST,
- BTA_DG_OPENING_ST,
- BTA_DG_OPEN_ST,
- BTA_DG_CLOSING_ST
-};
-
-/* state machine action enumeration list */
-enum
-{
- BTA_DG_DEL_RECORD,
- BTA_DG_SHUTDOWN,
- BTA_DG_CLOSE,
- BTA_DG_SET_DEALLOC,
- BTA_DG_RX_PATH,
- BTA_DG_TX_PATH,
- BTA_DG_FC_STATE,
- BTA_DG_WRITEBUF,
- BTA_DG_CONTROL,
- BTA_DG_RFC_CONTROL,
- BTA_DG_RFC_OPEN,
- BTA_DG_RFC_CLOSE,
- BTA_DG_DEALLOC,
- BTA_DG_DISC_RESULT,
- BTA_DG_DO_DISC,
- BTA_DG_OPEN,
- BTA_DG_FREE_DB,
- BTA_DG_SETUP_SERVER,
- BTA_DG_IGNORE
-};
-
-/* type for action functions */
-typedef void (*tBTA_DG_ACTION)(tBTA_DG_SCB *p_scb, tBTA_DG_DATA *p_data);
-
-/* action function list */
-const tBTA_DG_ACTION bta_dg_action[] =
-{
- bta_dg_del_record,
- bta_dg_shutdown,
- bta_dg_close,
- bta_dg_set_dealloc,
- bta_dg_rx_path,
- bta_dg_tx_path,
- bta_dg_fc_state,
- bta_dg_writebuf,
- bta_dg_control,
- bta_dg_rfc_control,
- bta_dg_rfc_open,
- bta_dg_rfc_close,
- bta_dg_dealloc,
- bta_dg_disc_result,
- bta_dg_do_disc,
- bta_dg_open,
- bta_dg_free_db,
- bta_dg_setup_server
-};
-
-/* state table information */
-#define BTA_DG_ACTIONS 2 /* number of actions */
-#define BTA_DG_NEXT_STATE 2 /* position of next state */
-#define BTA_DG_NUM_COLS 3 /* number of columns in state tables */
-
-/* state table for init state */
-const UINT8 bta_dg_st_init[][BTA_DG_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* API_CLOSE_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* API_SHUTDOWN_EVT */ {BTA_DG_SHUTDOWN, BTA_DG_DEALLOC, BTA_DG_INIT_ST},
-/* API_LISTEN_EVT */ {BTA_DG_SETUP_SERVER, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* API_OPEN_EVT */ {BTA_DG_DO_DISC, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* CI_TX_READY_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* CI_RX_READY_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* CI_TX_FLOW_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* CI_RX_WRITEBUF_EVT */ {BTA_DG_WRITEBUF, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* CI_CONTROL_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* RFC_OPEN_EVT */ {BTA_DG_RFC_OPEN, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* RFC_CLOSE_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* RFC_TX_READY_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* RFC_RX_READY_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* RFC_FC_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* RFC_CONTROL_EVT */ {BTA_DG_RFC_CONTROL, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* DISC_RESULT_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* DISC_OK_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* DISC_FAIL_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_INIT_ST}
-};
-
-/* state table for opening state */
-const UINT8 bta_dg_st_opening[][BTA_DG_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* API_CLOSE_EVT */ {BTA_DG_CLOSE, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* API_SHUTDOWN_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* API_LISTEN_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* API_OPEN_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* CI_TX_READY_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* CI_RX_READY_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* CI_TX_FLOW_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* CI_RX_WRITEBUF_EVT */ {BTA_DG_WRITEBUF, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* CI_CONTROL_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* RFC_OPEN_EVT */ {BTA_DG_RFC_OPEN, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* RFC_CLOSE_EVT */ {BTA_DG_RFC_CLOSE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* RFC_TX_READY_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* RFC_RX_READY_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* RFC_FC_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* RFC_CONTROL_EVT */ {BTA_DG_RFC_CONTROL, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* DISC_RESULT_EVT */ {BTA_DG_DISC_RESULT, BTA_DG_IGNORE, BTA_DG_OPENING_ST},
-/* DISC_OK_EVT */ {BTA_DG_FREE_DB, BTA_DG_OPEN, BTA_DG_OPENING_ST},
-/* DISC_FAIL_EVT */ {BTA_DG_FREE_DB, BTA_DG_RFC_CLOSE, BTA_DG_INIT_ST}
-};
-
-/* state table for open state */
-const UINT8 bta_dg_st_open[][BTA_DG_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* API_CLOSE_EVT */ {BTA_DG_CLOSE, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* API_SHUTDOWN_EVT */ {BTA_DG_SHUTDOWN, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* API_LISTEN_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* API_OPEN_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* CI_TX_READY_EVT */ {BTA_DG_TX_PATH, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* CI_RX_READY_EVT */ {BTA_DG_RX_PATH, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* CI_TX_FLOW_EVT */ {BTA_DG_FC_STATE, BTA_DG_TX_PATH, BTA_DG_OPEN_ST},
-/* CI_RX_WRITEBUF_EVT */ {BTA_DG_WRITEBUF, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* CI_CONTROL_EVT */ {BTA_DG_CONTROL, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* RFC_OPEN_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* RFC_CLOSE_EVT */ {BTA_DG_RFC_CLOSE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* RFC_TX_READY_EVT */ {BTA_DG_RX_PATH, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* RFC_RX_READY_EVT */ {BTA_DG_TX_PATH, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* RFC_FC_EVT */ {BTA_DG_RX_PATH, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* RFC_CONTROL_EVT */ {BTA_DG_RFC_CONTROL, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* DISC_RESULT_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* DISC_OK_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPEN_ST},
-/* DISC_FAIL_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_OPEN_ST}
-};
-
-/* state table for closing state */
-const UINT8 bta_dg_st_closing[][BTA_DG_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* API_CLOSE_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* API_SHUTDOWN_EVT */ {BTA_DG_DEL_RECORD, BTA_DG_SET_DEALLOC, BTA_DG_CLOSING_ST},
-/* API_LISTEN_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* API_OPEN_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* CI_TX_READY_EVT */ {BTA_DG_TX_PATH, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* CI_RX_READY_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* CI_TX_FLOW_EVT */ {BTA_DG_FC_STATE, BTA_DG_TX_PATH, BTA_DG_CLOSING_ST},
-/* CI_RX_WRITEBUF_EVT */ {BTA_DG_WRITEBUF, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* CI_CONTROL_EVT */ {BTA_DG_CONTROL, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* RFC_OPEN_EVT */ {BTA_DG_CLOSE, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* RFC_CLOSE_EVT */ {BTA_DG_RFC_CLOSE, BTA_DG_IGNORE, BTA_DG_INIT_ST},
-/* RFC_TX_READY_EVT */ {BTA_DG_RX_PATH, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* RFC_RX_READY_EVT */ {BTA_DG_TX_PATH, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* RFC_FC_EVT */ {BTA_DG_RX_PATH, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* RFC_CONTROL_EVT */ {BTA_DG_RFC_CONTROL, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* DISC_RESULT_EVT */ {BTA_DG_FREE_DB, BTA_DG_RFC_CLOSE, BTA_DG_INIT_ST},
-/* DISC_OK_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_CLOSING_ST},
-/* DISC_FAIL_EVT */ {BTA_DG_IGNORE, BTA_DG_IGNORE, BTA_DG_CLOSING_ST}
-};
-
-/* type for state table */
-typedef const UINT8 (*tBTA_DG_ST_TBL)[BTA_DG_NUM_COLS];
-
-/* state table */
-const tBTA_DG_ST_TBL bta_dg_st_tbl[] = {
- bta_dg_st_init,
- bta_dg_st_opening,
- bta_dg_st_open,
- bta_dg_st_closing
-};
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* DG control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-tBTA_DG_CB bta_dg_cb;
-#endif
-
-/*******************************************************************************
-**
-** Function bta_dg_scb_alloc
-**
-** Description Allocate a DG server control block.
-**
-**
-** Returns pointer to the scb, or NULL if none could be allocated.
-**
-*******************************************************************************/
-static tBTA_DG_SCB *bta_dg_scb_alloc(void)
-{
- tBTA_DG_SCB *p_scb = &bta_dg_cb.scb[0];
- int i;
-
- for (i = 0; i < BTA_DG_NUM_CONN; i++, p_scb++)
- {
- if (!p_scb->in_use)
- {
- p_scb->in_use = TRUE;
- APPL_TRACE_DEBUG1("bta_dg_scb_alloc %d", bta_dg_scb_to_idx(p_scb));
- break;
- }
- }
-
- if (i == BTA_DG_NUM_CONN)
- {
- /* out of lcbs */
- p_scb = NULL;
- APPL_TRACE_WARNING0("Out of scbs");
- }
- return p_scb;
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_sm_execute
-**
-** Description State machine event handling function for DG
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_sm_execute(tBTA_DG_SCB *p_scb, UINT16 event, tBTA_DG_DATA *p_data)
-{
- tBTA_DG_ST_TBL state_table;
- UINT8 action;
- int i;
-
- switch( event )
- {
- case BTA_DG_CI_TX_READY_EVT:
- case BTA_DG_CI_RX_READY_EVT:
- case BTA_DG_RFC_TX_READY_EVT:
- case BTA_DG_RFC_RX_READY_EVT:
- break;
- default:
- APPL_TRACE_EVENT3("DG scb=%d event=0x%x state=%d", bta_dg_scb_to_idx(p_scb), event, p_scb->state);
- break;
- }
-
- /* look up the state table for the current state */
- state_table = bta_dg_st_tbl[p_scb->state];
-
- event &= 0x00FF;
-
- /* set next state */
- p_scb->state = state_table[event][BTA_DG_NEXT_STATE];
-
- /* execute action functions */
- for (i = 0; i < BTA_DG_ACTIONS; i++)
- {
- if ((action = state_table[event][i]) != BTA_DG_IGNORE)
- {
- (*bta_dg_action[action])(p_scb, p_data);
- }
- else
- {
- break;
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_api_enable
-**
-** Description Handle an API enable event.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_dg_api_enable(tBTA_DG_DATA *p_data)
-{
- /* initialize control block */
- memset(&bta_dg_cb, 0, sizeof(bta_dg_cb));
-
- /* store callback function */
- bta_dg_cb.p_cback = p_data->api_enable.p_cback;
-
- /* call callback with enable event */
- (*bta_dg_cb.p_cback)(BTA_DG_ENABLE_EVT, NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_api_disable
-**
-** Description Handle an API disable event.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_dg_api_disable(tBTA_DG_DATA *p_data)
-{
- /* close/shutdown all scbs in use */
- tBTA_DG_SCB *p_scb = &bta_dg_cb.scb[0];
- int i;
- UINT16 event;
-
- for (i = 0; i < BTA_DG_NUM_CONN; i++, p_scb++)
- {
- if (p_scb->in_use)
- {
- event = (p_scb->is_server) ? BTA_DG_API_SHUTDOWN_EVT : BTA_DG_API_CLOSE_EVT;
- bta_dg_sm_execute(p_scb, event, p_data);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_new_conn
-**
-** Description Handle an API event that creates a new connection.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_dg_new_conn(tBTA_DG_DATA *p_data)
-{
- tBTA_DG_SCB *p_scb;
-
- /* allocate an scb */
- if ((p_scb = bta_dg_scb_alloc()) != NULL)
- {
- bta_dg_sm_execute(p_scb, p_data->hdr.event, p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_rfc_port
-**
-** Description Handle a port event from RFCOMM. This function decodes
-** the port event mask into multiple state machine events.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_dg_rfc_port(tBTA_DG_DATA *p_data)
-{
- tBTA_DG_SCB *p_scb;
-
- if ((p_scb = bta_dg_scb_by_handle(p_data->hdr.layer_specific)) != NULL)
- {
- if (p_data->rfc_port.code & PORT_EV_FC)
- {
- bta_dg_sm_execute(p_scb, BTA_DG_RFC_FC_EVT, p_data);
- }
-
- if (p_data->rfc_port.code & PORT_EV_TXEMPTY)
- {
- bta_dg_sm_execute(p_scb, BTA_DG_RFC_TX_READY_EVT, p_data);
- }
-
- if (p_data->rfc_port.code & PORT_EV_RXCHAR)
- {
- bta_dg_sm_execute(p_scb, BTA_DG_RFC_RX_READY_EVT, p_data);
- }
-
- if (p_data->rfc_port.code & (PORT_EV_CTS | PORT_EV_DSR | PORT_EV_RING))
- {
- bta_dg_sm_execute(p_scb, BTA_DG_RFC_CONTROL_EVT, p_data);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_scb_dealloc
-**
-** Description Deallocate a link control block.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_dg_scb_dealloc(tBTA_DG_SCB *p_scb)
-{
- APPL_TRACE_DEBUG1("bta_dg_scb_dealloc %d", bta_dg_scb_to_idx(p_scb));
- if (p_scb->port_handle != 0)
- {
- bta_dg_cb.hdl_to_scb[p_scb->port_handle - 1] = 0;
- }
- memset(p_scb, 0, sizeof(tBTA_DG_SCB));
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_scb_to_idx
-**
-** Description Given a pointer to an scb, return its index.
-**
-**
-** Returns Index of scb.
-**
-*******************************************************************************/
-UINT8 bta_dg_scb_to_idx(tBTA_DG_SCB *p_scb)
-{
- /* use array arithmetic to determine index */
- return ((UINT8) (p_scb - bta_dg_cb.scb)) + 1;
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_scb_by_idx
-**
-** Description Given an scb index return pointer to scb.
-**
-**
-** Returns Pointer to scb or NULL if not allocated.
-**
-*******************************************************************************/
-tBTA_DG_SCB *bta_dg_scb_by_idx(UINT16 idx)
-{
- tBTA_DG_SCB *p_scb;
-
- /* verify index */
- if (idx > 0 && idx <= BTA_DG_NUM_CONN)
- {
- p_scb = &bta_dg_cb.scb[idx - 1];
- if (!p_scb->in_use)
- {
- p_scb = NULL;
- APPL_TRACE_WARNING1("scb idx %d not allocated", idx);
- }
- }
- else
- {
- p_scb = NULL;
- APPL_TRACE_WARNING1("scb idx %d out of range", idx);
- }
- return p_scb;
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_scb_by_handle
-**
-** Description Find scb associated with handle.
-**
-**
-** Returns Pointer to scb or NULL if not found.
-**
-*******************************************************************************/
-tBTA_DG_SCB *bta_dg_scb_by_handle(UINT16 handle)
-{
- tBTA_DG_SCB *p_scb = NULL;
-
- if (bta_dg_cb.hdl_to_scb[handle - 1] != 0)
- {
- p_scb = &bta_dg_cb.scb[bta_dg_cb.hdl_to_scb[handle - 1] - 1];
- if (!p_scb->in_use)
- {
- p_scb = NULL;
- }
- }
-
- if (p_scb == NULL)
- {
- APPL_TRACE_WARNING1("No scb for port handle %d", handle);
- }
-
- return p_scb;
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_server_match
-**
-** Description Check if any servers exist with the same service name
-** and service id.
-**
-**
-** Returns Pointer to scb or NULL if not found.
-**
-*******************************************************************************/
-tBTA_DG_SCB *bta_dg_server_match(tBTA_DG_SCB *p_srv)
-{
- tBTA_DG_SCB *p_scb = &bta_dg_cb.scb[0];
- int i;
-
- for (i = 0; i < BTA_DG_NUM_CONN; i++, p_scb++)
- {
- if (p_scb == p_srv)
- {
- continue;
- }
-
- if (p_scb->in_use && p_scb->is_server &&
- (p_scb->service_id == p_srv->service_id) &&
- (strcmp(p_srv->name, p_scb->name) == 0))
- {
- APPL_TRACE_DEBUG1("dg server match:%d", i);
- return p_scb;
- }
- }
- return NULL;
-}
-
-/*******************************************************************************
-**
-** Function bta_dg_hdl_event
-**
-** Description Data gateway main event handling function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BOOLEAN bta_dg_hdl_event(BT_HDR *p_msg)
-{
- tBTA_DG_SCB *p_scb;
- BOOLEAN freebuf = TRUE;
-
- switch (p_msg->event)
- {
- /* handle enable event */
- case BTA_DG_API_ENABLE_EVT:
- bta_dg_api_enable((tBTA_DG_DATA *) p_msg);
- break;
-
- /* handle disable event */
- case BTA_DG_API_DISABLE_EVT:
- bta_dg_api_disable((tBTA_DG_DATA *) p_msg);
- break;
-
- /* handle listen and open events */
- case BTA_DG_API_LISTEN_EVT:
- case BTA_DG_API_OPEN_EVT:
- bta_dg_new_conn((tBTA_DG_DATA *) p_msg);
- break;
-
- /* handle RFCOMM port callback event mask */
- case BTA_DG_RFC_PORT_EVT:
- bta_dg_rfc_port((tBTA_DG_DATA *) p_msg);
- break;
-
- /* events that reference scb by index rather than port handle */
- case BTA_DG_API_CLOSE_EVT:
- case BTA_DG_API_SHUTDOWN_EVT:
- case BTA_DG_DISC_RESULT_EVT:
- if ((p_scb = bta_dg_scb_by_idx(p_msg->layer_specific)) != NULL)
- {
- bta_dg_sm_execute(p_scb, p_msg->event, (tBTA_DG_DATA *) p_msg);
- }
- break;
-
- /* events that require buffer not be released */
- case BTA_DG_CI_RX_WRITEBUF_EVT:
- freebuf = FALSE;
- /* fall through */
-
- /* all others reference scb by port handle */
- default:
- if ((p_scb = bta_dg_scb_by_handle(p_msg->layer_specific)) != NULL)
- {
- bta_dg_sm_execute(p_scb, p_msg->event, (tBTA_DG_DATA *) p_msg);
- }
- break;
- }
- return freebuf;
-}
-#endif /* BTA_DG_INCLUDED */
diff --git a/bta/ft/bta_ft_cfg.c b/bta/ft/bta_ft_cfg.c
deleted file mode 100644
index 89171e0..0000000
--- a/bta/ft/bta_ft_cfg.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ft_cfg.c
-**
-** Description: This file contains compile-time configurable constants
-** for the BTA File Transfer Client and Server.
-**
-** Copyright (c) 2003-2010, Broadcom Inc., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-#include "bta_ftc_int.h"
-
-/* Realm Character Set */
-#ifndef BTA_FTS_REALM_CHARSET
-#define BTA_FTS_REALM_CHARSET 0 /* ASCII */
-#endif
-
-/* Specifies whether or not client's user id is required during obex authentication */
-#ifndef BTA_FTS_USERID_REQ
-#define BTA_FTS_USERID_REQ FALSE
-#endif
-
-#ifndef BTA_FTC_AUTO_FILE_LIST
-#define BTA_FTC_AUTO_FILE_LIST TRUE
-#endif
-
-#ifndef BTA_FTC_ABORT_TIMEOUT
-#define BTA_FTC_ABORT_TIMEOUT 7000 /* 7 Secs for the low baud rates and SRM mode */
-#endif
-
-#ifndef BTA_FTC_STOP_TIMEOUT
-#define BTA_FTC_STOP_TIMEOUT 2000
-#endif
-
-#ifndef BTA_FTC_SUSPEND_TIMEOUT
-#define BTA_FTC_SUSPEND_TIMEOUT 10000
-#endif
-
-#ifndef BTA_FTC_PCE_SUPPORTED_FEAT /* mask: 1/download, 2/browsing */
-#define BTA_FTC_PCE_SUPPORTED_FEAT 0 /* 3/both, 0/PBAP PCE not supported */
-#endif
-
-#ifndef BTA_FTC_PCE_SERVICE_NAME
-#define BTA_FTC_PCE_SERVICE_NAME "PBAP PCE"
-#endif
-
-#ifndef BTA_FTC_2X_SUPPORTED
-#define BTA_FTC_2X_SUPPORTED TRUE
-#endif
-
-const tBTA_FT_CFG bta_ft_cfg =
-{
-#if (defined BIP_INCLUDED && BIP_INCLUDED == TRUE && defined BTA_BI_INCLUDED && BTA_BI_INCLUDED == TRUE)
- bta_ftc_bi_action, /* Client only */
-#else
- NULL, /* Client only */
-#endif
-
- BTA_FTS_REALM_CHARSET, /* Server only */
- BTA_FTS_USERID_REQ, /* Server only */
- BTA_FTC_AUTO_FILE_LIST, /* Client only */
- BTA_FTC_PCE_SUPPORTED_FEAT, /* Client only */
- BTA_FTC_PCE_SERVICE_NAME, /* Client only */
- BTA_FTC_ABORT_TIMEOUT, /* Client only */
- BTA_FTC_STOP_TIMEOUT , /* Client only */
- BTA_FTC_SUSPEND_TIMEOUT /* Client only - used for 2X only */
-#if BTA_FTC_2X_SUPPORTED == TRUE
-// btla-specific ++
- , 0 // [no reliable sess] /* non-0 to allow reliable session (Server Only) */
- , 0 // [no reliable sess] /* the maximum number of suspended session (Server Only) */
-// btla-specific --
- , TRUE /* TRUE to use Obex Over L2CAP (Server Only) */
- , TRUE /* TRUE to engage Single Response Mode (Server Only) */
-#else
- , 0 /* non-0 to allow reliable session (Server Only) */
- , 0 /* the maximum number of suspended session (Server Only) */
- , FALSE /* TRUE to use Obex Over L2CAP (Server Only) */
- , FALSE /* TRUE to engage Single Response Mode (Server Only) */
-#endif
-};
-
-tBTA_FT_CFG *p_bta_ft_cfg = (tBTA_FT_CFG *)&bta_ft_cfg;
-
diff --git a/bta/ft/bta_ftc_act.c b/bta/ft/bta_ftc_act.c
deleted file mode 100644
index bdec2d3..0000000
--- a/bta/ft/bta_ftc_act.c
+++ /dev/null
@@ -1,2062 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ftc_act.c
-**
-** Description: This file contains the file transfer action
-** functions for the state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_FT_INCLUDED) && (BTA_FT_INCLUDED == TRUE)
-
-#include <string.h>
-#include "gki.h"
-#include "bta_sys.h"
-#include "bd.h"
-#include "port_api.h"
-#include "obx_api.h"
-#include "goep_util.h"
-#include "sdp_api.h"
-#include "bta_fs_api.h"
-#include "bta_ft_api.h"
-#include "bta_ftc_int.h"
-#include "bta_fs_co.h"
-#include "bta_fs_ci.h"
-#include "btm_api.h"
-#include "rfcdefs.h"
-#include "utl.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-/* sdp discovery database size */
-#define BTA_FTC_DISC_SIZE 400
-
-
-/*****************************************************************************
-** Local Function prototypes
-*****************************************************************************/
-#if BTA_FTC_DEBUG == TRUE
-static char *ftc_obx_evt_code(tOBX_EVENT evt_code);
-#endif
-
-static void ftc_reset_cb (tBTA_FTC_CB *p_cb);
-static void bta_ftc_sdp_cback(UINT16 status);
-
-/*****************************************************************************
-** Action Functions
-*****************************************************************************/
-
-/*******************************************************************************
-**
-** Function bta_ftc_init_open
-**
-** Description Initiate a connection with a peer device's service.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_init_open(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- p_cb->obx_oper = FTC_OP_NONE;
- p_cb->sec_mask = p_data->api_open.sec_mask;
- p_cb->services = p_data->api_open.services;
- p_cb->srm = p_data->api_open.srm;
- p_cb->nonce = p_data->api_open.nonce;
- bdcpy(p_cb->bd_addr, p_data->api_open.bd_addr);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_abort
-**
-** Description Abort an active Get or Put operation
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_abort(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- /* Abort an active request */
- if (p_cb->obx_oper != FTC_OP_NONE)
- {
- p_cb->aborting = FTC_ABORT_REQ_NOT_SENT;
-
- /* Issue the abort request only if no request pending.
- * some devices do not like out of sequence aborts even though
- * the spec allows it */
- if ( !p_cb->req_pending || p_cb->first_req_pkt ) /* allow request for the first packet */
- {
-
- p_cb->aborting = FTC_ABORT_REQ_SENT; /* protection agains sending AbortReq twice in
- certain conditions */
- OBX_AbortReq(p_cb->obx_handle, (BT_HDR *)NULL);
- /* Start abort response timer */
- p_cb->timer_oper = FTC_TIMER_OP_ABORT;
- bta_sys_start_timer(&p_cb->rsp_timer, BTA_FTC_RSP_TOUT_EVT,
- p_bta_ft_cfg->abort_tout);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_api_action
-**
-** Description Send an Action command to the connected server
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_api_action(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FTC_STATUS status = BTA_FTC_FAIL;
- tBTA_FTC_EVT event = BTA_FTC_COPY_EVT + p_data->api_action.action;
-
- if (p_cb->obx_oper == FTC_OP_NONE)
- {
- /* TODO: we need to check the connected profile here */
- p_obx->p_pkt = OBX_HdrInit(p_cb->obx_handle, OBX_CMD_POOL_SIZE);
- OBX_AddUtf8NameHdr(p_obx->p_pkt, (UINT8 *)p_data->api_action.p_src);
- if (p_data->api_action.action == BTA_FT_ACT_PERMISSION)
- {
- OBX_AddPermissionHdr(p_obx->p_pkt, p_data->api_action.permission[0],
- p_data->api_action.permission[1], p_data->api_action.permission[2]);
- }
- else
- {
- OBX_AddUtf8DestNameHdr(p_obx->p_pkt, (UINT8 *)p_data->api_action.p_dest);
- }
-
- if (OBX_ActionReq(p_cb->obx_handle, p_data->api_action.action, p_obx->p_pkt) == OBX_SUCCESS)
- {
- status = BTA_FTC_OK;
- p_cb->req_pending = TRUE;
- p_cb->obx_oper = FTC_OP_COPY + p_data->api_action.action;
- p_obx->p_pkt = NULL; /* OBX will free the packet */
- }
- }
-
- if (status != BTA_FTC_OK) /* Send an error response to the application */
- {
- utl_freebuf((void**)&p_obx->p_pkt);
- p_cb->p_cback(event, (tBTA_FTC *)&status);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_obx_action_rsp
-**
-** Description Process the response to an action command
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_obx_action_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_FTC_STATUS status = BTA_FTC_FAIL;
- tBTA_FTC_EVT event = BTA_FTC_COPY_EVT + p_cb->obx_oper - FTC_OP_COPY;
-
- p_cb->req_pending = FALSE;
-
- if (p_evt->rsp_code == OBX_RSP_OK)
- status = BTA_FTC_OK;
-
- APPL_TRACE_DEBUG2("bta_ftc_obx_action_rsp rsp_code:0x%x, status:%d", p_evt->rsp_code, status);
- p_cb->obx_oper = FTC_OP_NONE;
-
- utl_freebuf((void**)&p_evt->p_pkt); /* Done with Obex packet */
- p_cb->p_cback(event, (tBTA_FTC *)&status);
-
- /* If successful, initiate a directory listing */
- if (event != BTA_FTC_PERMISSION_EVT &&
- p_evt->rsp_code == OBX_RSP_OK && p_bta_ft_cfg->auto_file_list &&
- (p_cb->sdp_service == UUID_SERVCLASS_OBEX_FILE_TRANSFER) )
- {
- bta_ftc_get_listing(p_cb, ".", NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_obx_get_srm_rsp
-**
-** Description Process the response to an get command after suspend is sent
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_obx_get_srm_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_ACTION p_act;
- /* TODO remove
- if (FTC_SUSPEND_REQ_NOT_SENT == p_cb->aborting)
- {
- p_cb->aborting = 0;
- OBX_SessionReq (p_cb->obx_handle, OBX_SESS_OP_SUSPEND, 0);
- p_cb->timer_oper = FTC_TIMER_OP_SUSPEND;
- bta_sys_start_timer(&p_cb->rsp_timer, BTA_FTC_RSP_TOUT_EVT, p_bta_ft_cfg->suspend_tout );
- }
- */
-
- if (p_cb->timer_oper == FTC_TIMER_OP_SUSPEND)
- {
- p_act = bta_ftc_obx_get_rsp;
- }
- else
- p_act = bta_ftc_ignore_obx;
- (p_act)(p_cb, p_data);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_ci_write_srm
-**
-** Description Continue with the current write operation after suspend is sent
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_ci_write_srm(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- if (p_cb->timer_oper == FTC_TIMER_OP_SUSPEND)
- {
- bta_ftc_ci_write(p_cb, p_data);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function bta_ftc_init_putfile
-**
-** Description Push a file to the OPP or FTP server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_init_putfile(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FS_CO_STATUS status;
- tBTA_FTC data;
- BOOLEAN is_dir;
- UINT8 rsp_code = OBX_RSP_FAILED;
-
- data.status = BTA_FTC_FAIL;
- if (p_cb->obx_oper == FTC_OP_NONE)
- {
- if (p_cb->sdp_service != UUID_SERVCLASS_PBAP_PSE)
- {
- p_cb->obx_oper = FTC_OP_PUT_FILE;
-
- status = bta_fs_co_access(p_data->api_put.p_name, BTA_FS_ACC_READ,
- &is_dir, p_cb->app_id);
- /* Verify that the file exists, and get (optional) file length */
- if (is_dir || status != BTA_FS_CO_OK)
- {
- /* Local file is not accessible or does not exist */
- if (is_dir || status == BTA_FS_CO_EACCES)
- rsp_code = OBX_RSP_UNAUTHORIZED;
- else
- rsp_code = OBX_RSP_NOT_FOUND;
- }
- else
- {
- if ((p_cb->p_name = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- BCM_STRNCPY_S(p_cb->p_name, p_bta_fs_cfg->max_path_len+1, p_data->api_put.p_name, p_bta_fs_cfg->max_path_len);
- p_cb->cout_active = TRUE;
- bta_fs_co_open(p_cb->p_name, BTA_FS_O_RDONLY, 0, BTA_FTC_CI_OPEN_EVT,
- p_cb->app_id);
- rsp_code = OBX_RSP_OK;
- }
- }
- if (rsp_code != OBX_RSP_OK)
- {
- p_data->obx_evt.rsp_code = rsp_code;
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CMPL_EVT, p_data);
- }
- return;
- }
- else
- {
- /* PBAP does not allow PUT */
- data.status = BTA_FTC_NO_PERMISSION;
- }
- }
-
- p_cb->p_cback(BTA_FTC_PUTFILE_EVT, &data);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_init_getfile
-**
-** Description Pull a file off the server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_init_getfile(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_API_GET *p_get = &p_data->api_get;
- tBTA_FTC_GET_PARAM *p_param = p_get->p_param;
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FTC_STATUS status = BTA_FTC_FAIL;
- tBTA_FTC data;
- UINT16 buflen;
- UINT16 rem_name_len;
- BOOLEAN is_ok;
- UINT8 *p = (UINT8 *)BTA_FTC_PULL_VCARD_ENTRY_TYPE;
- UINT8 *p_start;
- UINT16 len = 0;
-
- /* Available for FTP only */
- if (p_cb->obx_oper == FTC_OP_NONE &&
- (p_cb->sdp_service == UUID_SERVCLASS_OBEX_FILE_TRANSFER ||
- p_cb->sdp_service == UUID_SERVCLASS_PBAP_PSE) )
- {
- p_cb->first_req_pkt = TRUE;
- p_obx->offset = 0;
- if ((p_obx->p_pkt = OBX_HdrInit(p_cb->obx_handle, OBX_CMD_POOL_SIZE/*p_cb->peer_mtu*/)) != NULL)
- {
- /* Add the Name Header to the request */
- is_ok = OBX_AddUtf8NameHdr(p_obx->p_pkt, (UINT8 *)p_get->p_rem_name);
-
- if (p_cb->sdp_service == UUID_SERVCLASS_PBAP_PSE && is_ok)
- {
- /* add type header */
- if (p_get->obj_type == BTA_FTC_GET_PB)
- p = (UINT8 *)BTA_FTC_PULL_PB_TYPE;
- is_ok = OBX_AddTypeHdr(p_obx->p_pkt, (char *)p);
-
- /* add app params for PCE */
- p_start = OBX_AddByteStrStart(p_obx->p_pkt, &len);
- p = p_start;
- if (p_get->obj_type != BTA_FTC_GET_PB || p_param->max_list_count != 0)
- {
- if (p_param->filter)
- {
- *p++ = BTA_FTC_APH_FILTER;
- *p++ = 8;
- /* set proprietary filter to 0 */
- UINT32_TO_BE_STREAM(p, 0);
- UINT32_TO_BE_STREAM(p, p_param->filter);
- }
- if (p_param->format < BTA_FTC_FORMAT_MAX)
- {
- *p++ = BTA_FTC_APH_FORMAT;
- *p++ = 1;
- *p++ = p_param->format;
- }
- }
-
- if (p_get->obj_type == BTA_FTC_GET_PB)
- {
- /* this is mandatory */
- *p++ = BTA_FTC_APH_MAX_LIST_COUNT;
- *p++ = 2;
- UINT16_TO_BE_STREAM(p, p_param->max_list_count);
-
- if (p_param->list_start_offset)
- {
- *p++ = BTA_FTC_APH_LIST_STOFF;
- *p++ = 2;
- UINT16_TO_BE_STREAM(p, p_param->list_start_offset);
- }
- }
-
- /* If any of the app param header is added */
- if (p != p_start)
- {
- OBX_AddByteStrHdr(p_obx->p_pkt, OBX_HI_APP_PARMS, NULL, (UINT16)(p - p_start));
- }
- }
- }
-
- rem_name_len = (UINT16)(strlen(p_get->p_rem_name) + 1);
- /* Need a buffer that can hold the local path and UTF-8 filename */
- buflen = p_bta_fs_cfg->max_path_len + 2 + rem_name_len;
-
- /* Save the UNICODE name of the remote file, and local filename and path */
- if ((p_cb->p_name = (char *)GKI_getbuf(buflen)) != NULL)
- {
- memset(p_cb->p_name, 0, buflen);
- BCM_STRNCPY_S(p_cb->p_name, p_bta_fs_cfg->max_path_len, p_get->p_name, p_bta_fs_cfg->max_path_len-1);
-
- p_cb->obj_type = p_get->obj_type;
- p_cb->obx_oper = FTC_OP_GET_FILE;
- if (p_cb->obj_type == BTA_FTC_GET_PB && p_param->max_list_count == 0)
- {
- /* getting the phone book size only. do not need to open a file */
- bta_ftc_send_get_req(p_cb);
- }
- else
- {
- p_cb->cout_active = TRUE;
- bta_fs_co_open(p_cb->p_name,
- (BTA_FS_O_RDWR | BTA_FS_O_CREAT | BTA_FS_O_TRUNC),
- 0, BTA_FTC_CI_OPEN_EVT, p_cb->app_id);
- }
- status = BTA_FTC_OK;
- }
- }
-
- if (status != BTA_FTC_OK)
- {
- data.status = status;
- p_cb->p_cback(BTA_FTC_GETFILE_EVT, &data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_chdir
-**
-** Description Change Directory and get a listing of it.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_chdir(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_API_CHDIR *p_chdir = &p_data->api_chdir;
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
- tOBX_SETPATH_FLAG obx_flags = OBX_SPF_NO_CREATE;
- tBTA_FTC_STATUS status = BTA_FTC_FAIL;
- UINT16 len = OBX_CMD_POOL_SIZE; /* Don't need special OBX buffer pool */
-
- /* Only process if no other OBX operation is active and connected to FTP */
- if (p_cb->obx_oper == FTC_OP_NONE)
- {
- if (p_cb->sdp_service == UUID_SERVCLASS_OBEX_FILE_TRANSFER ||
- p_cb->sdp_service == UUID_SERVCLASS_PBAP_PSE )
- {
- /* Allocate an OBX packet */
- if ((p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle, len)) != NULL)
- {
- status = BTA_FTC_OK;
-
- /* Add the name header if not backing up */
- if (p_chdir->flag != BTA_FTC_FLAG_BACKUP)
- {
- if (!OBX_AddUtf8NameHdr(p_obx->p_pkt, (UINT8 *)p_chdir->p_dir))
- status = BTA_FTC_FAIL;
- }
- else
- obx_flags |= OBX_SPF_BACKUP;
- }
- }
- }
-
- if (status == BTA_FTC_OK)
- {
- if (OBX_SetPathReq(p_cb->obx_handle, obx_flags, p_obx->p_pkt))
- {
- status = BTA_FTC_FAIL;
- }
- else
- {
- p_cb->req_pending = TRUE;
- p_cb->obx_oper = FTC_OP_CHDIR;
- p_obx->p_pkt = NULL; /* OBX will free the packet */
- }
-
- }
-
- if (status != BTA_FTC_OK) /* Send an error response to the application */
- {
- utl_freebuf((void**)&p_obx->p_pkt);
- p_cb->p_cback(BTA_FTC_CHDIR_EVT, (tBTA_FTC *)&status);
- }
-}
-
-/*******************************************************************************
-**
-** Function ftp_clnt_listdir
-**
-** Description List the specified directory contents.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_listdir(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- /* Only process if no other OBX operation is active and connected to FTP */
- if (p_cb->obx_oper == FTC_OP_NONE)
- bta_ftc_get_listing(p_cb, p_data->api_list.p_dir, p_data->api_list.p_param);
- else
- bta_ftc_listing_err(&p_cb->obx.p_pkt, BTA_FTC_FAIL);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_remove
-** Description Remove the specified directory or a file.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_remove(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FTC_STATUS status = BTA_FTC_OK;
-
- APPL_TRACE_DEBUG1("bta_ftc_remove status:%d", p_cb->obx_oper);
-
- if (p_data->api_mkdir.p_dir[0] != '\0')
- {
-
- /* Only process if no other OBX operation is active and connected to FTP */
- if (p_cb->obx_oper == FTC_OP_NONE)
- {
- if ((p_obx->p_pkt = OBX_HdrInit(p_cb->obx_handle, OBX_CMD_POOL_SIZE)) != NULL)
- {
- /* Add the Name Header to the request */
- status = BTA_FTC_OK;
- OBX_AddUtf8NameHdr(p_obx->p_pkt, (UINT8 *)p_data->api_remove.p_name);
- }
- else
- status = BTA_FTC_FAIL;
- }
- else
- status = BTA_FTC_BUSY;
- }
- else
- status = BTA_FTC_NOT_FOUND;
-
- if (status == BTA_FTC_OK)
- {
- if ((OBX_PutReq(p_cb->obx_handle, TRUE, p_obx->p_pkt)) == OBX_SUCCESS)
- {
- p_cb->req_pending = TRUE;
- p_cb->obx_oper = FTC_OP_DELETE;
- p_obx->p_pkt = NULL; /* OBX will free the packet */
- }
- else
- status = BTA_FTC_FAIL;
- }
-
- if (status != BTA_FTC_OK) /* Send an error response to the application */
- {
- utl_freebuf((void**)&p_obx->p_pkt);
- p_cb->p_cback(BTA_FTC_REMOVE_EVT, (tBTA_FTC *)&status);
- }
-}
-/*******************************************************************************
-**
-** Function bta_ftc_mkdir
-**
-** Description Create the specified directory.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_mkdir(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FTC_STATUS status = BTA_FTC_OK;
-
- if (p_data->api_mkdir.p_dir[0] != '\0')
- {
- /* Only process if no other OBX operation is active and connected to FTP */
- if (p_cb->obx_oper == FTC_OP_NONE)
- {
- if ((p_obx->p_pkt = OBX_HdrInit(p_cb->obx_handle, OBX_CMD_POOL_SIZE)) != NULL)
- {
- /* Add the Name Header to the request */
- status = BTA_FTC_OK;
- OBX_AddUtf8NameHdr(p_obx->p_pkt, (UINT8 *)p_data->api_mkdir.p_dir);
- }
- }
- else
- status = BTA_FTC_BUSY;
- }
- else
- status = BTA_FTC_NOT_FOUND;
-
- if (status == BTA_FTC_OK )
- {
- if ((OBX_SetPathReq(p_cb->obx_handle, 0, p_obx->p_pkt)) == OBX_SUCCESS)
- {
- p_cb->req_pending = TRUE;
- p_cb->obx_oper = FTC_OP_MKDIR;
- p_obx->p_pkt = NULL; /* OBX will free the packet */
- }
- else
- status = BTA_FTC_FAIL;
- }
-
- if (status != BTA_FTC_OK) /* Send an error response to the application */
- {
- utl_freebuf((void**)&p_obx->p_pkt);
- p_cb->p_cback(BTA_FTC_MKDIR_EVT, (tBTA_FTC *)&status);
- }
-}
-
-
-
-/*******************************************************************************
-**
-** Function bta_ftc_send_authrsp
-**
-** Description Pass the response to an authentication request back to the
-** client.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_send_authrsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- UINT8 *p_pwd = NULL;
- UINT8 *p_userid = NULL;
-
- if (p_bta_ft_cfg->p_bi_action != NULL &&
- p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_AUTHRSP_IDX] &&
- p_cb->sdp_service == UUID_SERVCLASS_IMAGING_RESPONDER)
- {
- (p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_AUTHRSP_IDX])(p_cb, p_data);
- return;
- }
- else
- {
- if (p_data->auth_rsp.key_len > 0)
- p_pwd = (UINT8 *)p_data->auth_rsp.key;
- if (p_data->auth_rsp.userid_len > 0)
- p_userid = (UINT8 *)p_data->auth_rsp.userid;
-
- OBX_AuthResponse(p_cb->obx_handle, p_pwd, p_data->auth_rsp.key_len,
- p_userid, p_data->auth_rsp.userid_len, FALSE);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_trans_cmpl
-**
-** Description push/pull complete
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_trans_cmpl(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC param;
-
- /* Close the opened file */
- if (p_cb->fd >= 0)
- {
- bta_fs_co_close(p_cb->fd, p_cb->app_id);
- p_cb->fd = BTA_FS_INVALID_FD;
- }
-
- param.status = bta_ftc_convert_obx_to_ftc_status(p_data->obx_evt.rsp_code);
-
- if (p_cb->obx_oper == FTC_OP_PUT_FILE)
- p_cb->p_cback(BTA_FTC_PUTFILE_EVT, &param);
- else if (p_cb->obx_oper == FTC_OP_GET_FILE)
- {
- if (param.status != BTA_FTC_OK)
- {
- bta_fs_co_unlink(p_cb->p_name, p_cb->app_id);
- APPL_TRACE_WARNING2("FTC: Get File Operation Aborted or Error [%s], status 0x%02x",
- p_cb->p_name, param.status);
- }
-
- p_cb->p_cback(BTA_FTC_GETFILE_EVT, &param);
- }
-
- /* Clean up control block */
- ftc_reset_cb(p_cb);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_ci_write
-**
-** Description Continue with the current write operation
-** (Get File processing)
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_ci_write(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FTC param;
- UINT8 rsp_code = OBX_RSP_FAILED;
-
- p_cb->cout_active = FALSE;
-
- /* Process write call-in event if operation is still active */
- if (p_cb->obx_oper != FTC_OP_GET_FILE)
- return;
-
- /* Free current packet */
- utl_freebuf((void**)&p_obx->p_pkt);
-
- /* Process any pending abort */
- if (p_cb->aborting)
- {
- p_cb->aborting |= FTC_ABORT_COUT_DONE;
-
- /* If already have response to abort then notify appl and cleanup */
- if (FTC_ABORT_COMPLETED == p_cb->aborting)
- {
- /* APPL_TRACE_DEBUG0("Received WRITE CALL-IN function; continuing abort..."); */
-
- /* OBX_RSP_GONE indicates aborted; used internally when called from API */
- p_data->obx_evt.rsp_code = (!p_cb->int_abort) ? OBX_RSP_GONE : OBX_RSP_INTRNL_SRVR_ERR;
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CMPL_EVT, p_data);
- return;
- }
- }
-
- if (p_data->write_evt.status == BTA_FS_CO_OK)
- {
- param.prog.bytes = p_obx->offset;
- param.prog.file_size = p_cb->file_size;
- p_cb->p_cback(BTA_FTC_PROGRESS_EVT, &param);
-
- /* Send another Get request if not finished */
- if (!p_obx->final_pkt)
- {
- /* send a new request */
- bta_ftc_send_get_req(p_cb);
- rsp_code = OBX_RSP_CONTINUE;
- }
- else
- rsp_code = OBX_RSP_OK;
- }
-
- if (rsp_code != OBX_RSP_CONTINUE)
- {
- p_data->obx_evt.rsp_code = rsp_code;
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CMPL_EVT, p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_ci_read
-**
-** Description Handles the response to a read call-out request.
-** This is called within the OBX get file request. The
-** operation has completed, send the OBX packet out.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_ci_read(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FS_CI_READ_EVT *p_revt = &p_data->read_evt;
- tBTA_FTC param;
- BOOLEAN is_final;
-
- p_cb->cout_active = FALSE;
-
- /* Process read call-in event if operation is still active */
- if (p_cb->obx_oper == FTC_OP_PUT_FILE)
- {
- if (!p_cb->aborting)
- {
- if (p_revt->status != BTA_FS_CO_OK && p_revt->status != BTA_FS_CO_EOF)
- {
- p_cb->int_abort = TRUE;
- bta_ftc_sm_execute(p_cb, BTA_FTC_API_ABORT_EVT, p_data);
- }
- else
- {
- is_final = (p_revt->status == BTA_FS_CO_EOF) ? TRUE: FALSE;
-
- /* Add the body header to the packet */
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_revt->num_read, is_final);
-
- p_cb->obx.bytes_left -= p_revt->num_read;
- p_cb->obx.offset += p_revt->num_read;
-
- /* Send out the data */
- OBX_PutReq(p_cb->obx_handle, is_final, p_obx->p_pkt);
- p_obx->p_pkt = NULL;
- p_cb->req_pending = TRUE;
-
- /* Give application the status */
- param.prog.bytes = p_revt->num_read;
- param.prog.file_size = p_cb->file_size;
- p_cb->p_cback(BTA_FTC_PROGRESS_EVT, &param);
- }
- }
- else
- {
- /* Process any pending abort */
- p_cb->aborting |= FTC_ABORT_COUT_DONE;
-
- /* If already have response to abort then notify appl and cleanup */
- if (FTC_ABORT_COMPLETED == p_cb->aborting)
- {
- /* APPL_TRACE_DEBUG0("Received READ CALL-IN function; continuing abort..."); */
-
- /* OBX_RSP_GONE indicates aborted; used internally when called from API */
- p_data->obx_evt.rsp_code = (!p_cb->int_abort) ? OBX_RSP_GONE : OBX_RSP_INTRNL_SRVR_ERR;
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CMPL_EVT, p_data);
- return;
- }
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_ci_open
-**
-** Description Continue with the current file open operation
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_ci_open(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FS_CI_OPEN_EVT *p_open = &p_data->open_evt;
- UINT8 rsp_code = OBX_RSP_FAILED;
-
- p_cb->cout_active = FALSE;
- APPL_TRACE_DEBUG2("bta_ftc_ci_open status:%d, aborting:%d", p_open->status, p_cb->aborting);
-
- /* Process any pending abort */
- if (p_cb->aborting)
- {
- p_cb->aborting |= FTC_ABORT_COUT_DONE;
-
- /* If already have response to abort then notify appl and cleanup */
- if (FTC_ABORT_COMPLETED == p_cb->aborting)
- {
- /* APPL_TRACE_DEBUG0("Received OPEN CALL-IN function; continuing abort..."); */
-
- /* OBX_RSP_GONE indicates aborted; used internally when called from API */
- p_data->obx_evt.rsp_code = (!p_cb->int_abort) ? OBX_RSP_GONE : OBX_RSP_INTRNL_SRVR_ERR;
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CMPL_EVT, p_data);
- return;
- }
- }
-
- /* if file is accessible read/write the first buffer of data */
- if (p_open->status == BTA_FS_CO_OK)
- {
- p_cb->fd = p_open->fd;
-
- /* If using OBEX 1.5 */
- if (p_open->p_file)
- {
- if ((p_cb->p_name != NULL) ||
- (p_cb->p_name = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- /* save the image file name */
- BCM_STRNCPY_S(p_cb->p_name, p_bta_fs_cfg->max_path_len+1, p_open->p_file, p_bta_fs_cfg->max_path_len);
- p_cb->p_name[p_bta_fs_cfg->max_path_len] = '\0';
- p_cb->first_req_pkt = FALSE;
- }
- }
- else
- p_cb->first_req_pkt = TRUE;
-
- APPL_TRACE_DEBUG2("first_req_pkt:%d obx_oper:%d", p_cb->first_req_pkt, p_cb->obx_oper);
-
- if (p_cb->obx_oper == FTC_OP_PUT_FILE)
- {
- p_cb->file_size = p_open->file_size;
- rsp_code = bta_ftc_cont_put_file(p_cb, p_cb->first_req_pkt);
- }
- else if (p_cb->obx_oper == FTC_OP_GET_FILE)
- {
- /* Initiate the first OBX GET request */
- rsp_code = bta_ftc_send_get_req(p_cb);
- }
- }
- else
- {
- /* If using OBEX 1.5 */
- if (p_open->status == BTA_FS_CO_NONE)
- {
- rsp_code = OBX_RSP_OK;
- if (p_cb->obx_oper == FTC_OP_GET_LIST)
- {
- bta_ftc_abort(p_cb, NULL);
- }
- }
- else
- {
- if (p_open->status == BTA_FS_CO_EACCES)
- rsp_code = OBX_RSP_UNAUTHORIZED;
- else /* File could not be found */
- rsp_code = OBX_RSP_NOT_FOUND;
- }
- }
-
- if (rsp_code != OBX_RSP_OK)
- {
- p_data->obx_evt.rsp_code = rsp_code;
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CMPL_EVT, p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_ci_resume
-**
-** Description Continue with the resume session
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_ci_resume(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FS_CI_RESUME_EVT *p_resume = &p_data->resume_evt;
-
- APPL_TRACE_DEBUG3("bta_ftc_ci_resume status:%d, ssn:%d, info:%d",
- p_resume->status, p_resume->ssn, p_resume->info);
-
- if (p_resume->status == BTA_FS_CO_OK &&
- OBX_AllocSession (p_resume->p_sess_info, 0, &p_cb->psm,
- bta_ftc_obx_cback, &p_cb->obx_handle) == OBX_SUCCESS)
- {
- BTM_SetSecurityLevel (TRUE, "BTA_FTC", BTM_SEC_SERVICE_OBEX_FTP,
- p_cb->sec_mask, p_cb->psm,
- 0, 0);
- OBX_ResumeSession (p_cb->bd_addr, p_resume->ssn, p_resume->offset, p_cb->obx_handle);
- }
- else
- {
- p_cb->status = BTA_FTC_OBX_ERR;
- p_data->obx_evt.rsp_code = OBX_RSP_FAILED;
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CLOSE_EVT, p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_obx_conn_rsp
-**
-** Description Process the OBX connect event.
-** If FTP service, get directory listing.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_obx_conn_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_FTC param;
- tOBX_SESS_EVT *p_sess;
- UINT8 obx_oper, *p_obx_oper = &p_cb->obx_oper;
-
- APPL_TRACE_DEBUG1("bta_ftc_obx_conn_rsp obx_event=%d", p_evt->obx_event);
-
- /* If using OBEX 1.5 */
- if (p_evt->obx_event == OBX_SESSION_RSP_EVT)
- {
- p_sess = &p_evt->param.sess;
- APPL_TRACE_DEBUG2("bta_ftc_obx_conn_rsp sess_id:0x%x/0x%x", p_cb->p_sess_info, p_sess->p_sess_info);
- p_cb->p_sess_info = p_sess->p_sess_info;
- APPL_TRACE_DEBUG2("client cb p_sess_info:0x%x obj_offset:x%x", p_cb->p_sess_info, p_sess->obj_offset);
- if (p_cb->nonce != BTA_FTC_RESUME_NONCE)
- {
- p_obx_oper = &obx_oper;
- p_cb->obx_oper = FTC_OP_NONE;
- }
- bta_fs_co_session_info(p_cb->bd_addr, p_cb->p_sess_info, p_sess->ssn, BTA_FS_CO_SESS_ST_ACTIVE, NULL, p_obx_oper, p_cb->app_id);
- if ((p_sess->sess_op == OBX_SESS_OP_CREATE) || (p_sess->sess_op == OBX_SESS_OP_RESUME))
- {
- p_cb->state = BTA_FTC_W4_CONN_ST;
- }
- if (p_cb->obx_oper)
- bta_fs_co_resume_op(p_sess->obj_offset, BTA_FTC_CI_OPEN_EVT, p_cb->app_id);
- return;
- }
-
- p_cb->peer_mtu = p_data->obx_evt.param.conn.mtu;
-
- APPL_TRACE_DEBUG2("bta_ftc_obx_conn_rsp peer_mtu=%d obx_oper:0x%x", p_cb->peer_mtu, p_cb->obx_oper);
-
- /* OPP is connected and ready */
- if (p_cb->sdp_service == UUID_SERVCLASS_OBEX_OBJECT_PUSH)
- {
- param.open.service = BTA_OPP_SERVICE_ID;
- APPL_TRACE_EVENT0("[BTA FTC]OPP Service Id ");
- }
- /* PBAP is connected and ready */
- else if (p_cb->sdp_service == UUID_SERVCLASS_PBAP_PSE)
- {
- param.open.service = BTA_PBAP_SERVICE_ID;
- APPL_TRACE_EVENT0("[BTA FTC]PBAP Service Id ");
- }
- else /* Initiate directory listing if FTP service */
- {
- APPL_TRACE_EVENT0("[BTA FTC]FTP Service Id ");
- param.open.service = BTA_FTP_SERVICE_ID;
- if (p_bta_ft_cfg->auto_file_list && !p_cb->obx_oper)
- {
- bta_ftc_get_listing(p_cb, ".", NULL);
- }
- }
-
- if (p_cb->p_sess_info == NULL)
- {
- bta_fs_co_session_info(p_cb->bd_addr, p_cb->p_sess_info, 0, BTA_FS_CO_SESS_ST_NONE, NULL, NULL, p_cb->app_id);
- }
- p_cb->suspending = FALSE;
-
- /* inform role manager */
- bta_sys_conn_open( BTA_ID_FTC ,p_cb->app_id, p_cb->bd_addr);
-
- param.open.version = p_cb->version;
- p_cb->p_cback(BTA_FTC_OPEN_EVT, &param);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_obx_sess_rsp
-**
-** Description Process the OBX session event.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_obx_sess_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_EVT *p_evt = &p_data->obx_evt;
- tOBX_SESS_EVT *p_sess = &p_data->obx_evt.param.sess;
-
- APPL_TRACE_DEBUG3("bta_ftc_obx_sess_rsp obx_event=%d sess_op:%d, ssn:%d",
- p_evt->obx_event, p_sess->sess_op, p_sess->ssn);
- if (p_evt->obx_event == OBX_SESSION_RSP_EVT && p_sess->sess_op == OBX_SESS_OP_SUSPEND)
- {
- p_cb->p_sess_info = p_sess->p_sess_info;
- APPL_TRACE_DEBUG1("client cb p_sess_info:0x%x", p_cb->p_sess_info);
- bta_fs_co_suspend(p_cb->bd_addr, p_cb->p_sess_info, p_sess->ssn, &p_sess->timeout, NULL, p_cb->obx_oper, p_cb->app_id);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_suspended
-**
-** Description Process transport down suspend.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_suspended(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_EVT *p_evt = &p_data->obx_evt;
- tOBX_SESS_EVT *p_sess = &p_data->obx_evt.param.sess;
- UINT32 offset = 0;
-
- APPL_TRACE_DEBUG4("bta_ftc_suspended obx_event=%d sess_op:%d, ssn:%d, obx_oper:%d",
- p_evt->obx_event, p_sess->sess_op, p_sess->ssn, p_cb->obx_oper);
- if (p_evt->obx_event == OBX_SESSION_INFO_EVT)
- {
- if ((p_cb->obx_oper != FTC_OP_GET_FILE) && (p_cb->obx_oper != FTC_OP_PUT_FILE) && (p_cb->obx_oper != FTC_OP_GET_LIST))
- {
- /* the other obx ops are single transaction.
- * If the link is dropped before the transaction ends, re-transmit the request when the session resumes */
- p_sess->ssn--;
- p_cb->obx_oper = FTC_OP_NONE;
- }
- p_cb->suspending = TRUE;
- bta_fs_co_suspend(p_cb->bd_addr, p_sess->p_sess_info, p_sess->ssn,
- &p_sess->timeout, &offset, p_cb->obx_oper, p_cb->app_id);
- /* do not need to worry about active call-out here.
- * this is a result of OBX_SESSION_INFO_EVT
- * OBX would report OBX_CLOSE_IND_EVT, which will eventually call bta_ftc_close_complete */
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_obx_abort_rsp
-**
-** Description Process the OBX abort event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_obx_abort_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- bta_sys_stop_timer(&p_cb->rsp_timer);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_data->obx_evt.p_pkt);
-
- if (p_cb->obx_oper != FTC_OP_NONE)
- {
- if (!p_cb->cout_active)
- {
- /* OBX_RSP_GONE indicates aborted; used internally when called from API */
- p_data->obx_evt.rsp_code = (!p_cb->int_abort) ? OBX_RSP_GONE : OBX_RSP_INTRNL_SRVR_ERR;
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CMPL_EVT, p_data);
- }
- else /* must wait for cout function to complete before finishing the abort */
- {
- /* Mark the fact we have already received the response from the peer */
- p_cb->aborting |= FTC_ABORT_RSP_RCVD;
- /* APPL_TRACE_DEBUG1("ftc_obx_abort_rsp()->Rcvd abort_rsp; waiting for callin...",
- p_cb->aborting); */
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_obx_password
-**
-** Description Process the OBX password request
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_obx_password(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_FTC_AUTH parms;
- tOBX_AUTH_OPT options;
-
- memset(&parms, 0, sizeof(tBTA_FTC_AUTH));
-
- /* Extract user id from packet (if available) */
- if (OBX_ReadChallenge(p_evt->p_pkt, &parms.realm_charset,
- &parms.p_realm,
- &parms.realm_len, &options))
- {
- if (options & OBX_AO_USR_ID)
- parms.userid_required = TRUE;
- }
-
- /* Don't need OBX packet any longer */
- utl_freebuf((void**)&p_evt->p_pkt);
-
- /* Notify application */
- p_cb->p_cback(BTA_FTC_AUTH_EVT, (tBTA_FTC *)&parms);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_obx_timeout
-**
-** Description Process the OBX timeout event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_obx_timeout(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- utl_freebuf((void**)&p_data->obx_evt.p_pkt);
-
- /* If currently processing OBX request, peer is unresponsive so we're done */
- if (p_cb->aborting || p_cb->obx_oper != FTC_OP_NONE)
- {
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
- if (p_cb->bic_handle != BTA_BIC_INVALID_HANDLE)
- {
- BTA_BicDeRegister(p_cb->bic_handle);
- p_cb->bic_handle = BTA_BIC_INVALID_HANDLE;
- }
- else
-#endif
- {
- p_data->obx_evt.rsp_code = OBX_RSP_GONE;
- p_cb->status = BTA_FTC_OBX_TOUT;
-
- /* Start stop response timer */
- p_cb->timer_oper = FTC_TIMER_OP_STOP;
- bta_sys_start_timer(&p_cb->rsp_timer, BTA_FTC_RSP_TOUT_EVT,
- p_bta_ft_cfg->stop_tout);
-
- OBX_DisconnectReq(p_cb->obx_handle, NULL);
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CLOSE_EVT, p_data);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_obx_put_rsp
-**
-** Description Process the OBX file put and delete file/folder events
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_obx_put_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_FTC_STATUS status;
-
- p_cb->req_pending = FALSE;
- p_cb->first_req_pkt = FALSE;
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-
- if (p_cb->obx_oper == FTC_OP_PUT_FILE)
- {
- /* If not finished with Put, start another read */
- if (p_evt->rsp_code == OBX_RSP_CONTINUE)
- bta_ftc_cont_put_file(p_cb, FALSE);
- else
- {
- p_data->obx_evt.rsp_code = p_evt->rsp_code;
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CMPL_EVT, p_data);
- }
- }
-
- else if (p_cb->obx_oper == FTC_OP_DELETE)
- {
- status = bta_ftc_convert_obx_to_ftc_status(p_data->obx_evt.rsp_code);
- p_cb->obx_oper = FTC_OP_NONE;
- p_cb->p_cback(BTA_FTC_REMOVE_EVT, (tBTA_FTC *)&status);
- }
-
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_obx_get_rsp
-**
-** Description Process the OBX file get and folder listing events
-** If the type header is not folder listing, then pulling a file.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_obx_get_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_EVT *p_evt = &p_data->obx_evt;
-
- APPL_TRACE_DEBUG2("bta_ftc_obx_get_rsp req_pending=%d obx_oper:%d", p_cb->req_pending, p_cb->obx_oper);
- p_cb->req_pending = FALSE;
-
- if (p_cb->obx_oper == FTC_OP_GET_FILE)
- bta_ftc_proc_get_rsp(p_cb, p_data);
- else if (p_cb->obx_oper == FTC_OP_GET_LIST)
- bta_ftc_proc_list_data(p_cb, p_evt);
- else /* Release the unexpected OBX response packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_obx_setpath_rsp
-**
-** Description Process the response to a change or make directory requests
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_obx_setpath_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_FTC_STATUS status = BTA_FTC_FAIL;
- tBTA_FTC_EVT event = BTA_FTC_CHDIR_EVT;
-
- p_cb->req_pending = FALSE;
-
- if (p_cb->obx_oper == FTC_OP_MKDIR)
- event = BTA_FTC_MKDIR_EVT;
-
- if (p_evt->rsp_code == OBX_RSP_OK)
- status = BTA_FTC_OK;
-
- p_cb->obx_oper = FTC_OP_NONE;
-
- utl_freebuf((void**)&p_evt->p_pkt); /* Done with Obex packet */
- p_cb->p_cback(event, (tBTA_FTC *)&status);
-
- /* If successful, initiate a directory listing */
- if (p_evt->rsp_code == OBX_RSP_OK && p_bta_ft_cfg->auto_file_list &&
- (p_cb->sdp_service == UUID_SERVCLASS_OBEX_FILE_TRANSFER))
- {
- bta_ftc_get_listing(p_cb, ".", NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_rsp_timeout
-**
-** Description Process the OBX response timeout event
-** stop and abort
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_rsp_timeout(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- p_cb->timer_oper = FTC_TIMER_OP_STOP;
- if (p_cb->timer_oper == FTC_TIMER_OP_ABORT)
- {
- /* Start stop response timer */
- p_cb->status = BTA_FTC_ABORTED;
- bta_sys_start_timer(&p_cb->rsp_timer, BTA_FTC_RSP_TOUT_EVT,
- p_bta_ft_cfg->stop_tout);
-
- OBX_DisconnectReq(p_cb->obx_handle, NULL);
- }
- else /* Timeout waiting for disconnect response */
- {
- p_cb->cout_active = FALSE;
- bta_ftc_initialize(p_cb, p_data);
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
- BTA_BicFreeXmlData(BTA_BIC_CAPABILITIES_EVT, (tBTA_BI_XML **)&p_cb->p_caps);
-#endif
- /* force OBX to close port */
- OBX_DisconnectReq(p_cb->obx_handle, NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_initialize
-**
-** Description Initialize the control block.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_initialize(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FS_CO_STATUS status;
-
- bta_sys_stop_timer(&p_cb->rsp_timer);
-
- /* Close any open files */
- if (p_cb->fd >= 0)
- {
- bta_fs_co_close(p_cb->fd, p_cb->app_id);
- p_cb->fd = BTA_FS_INVALID_FD;
-
- /* Delete an aborted unfinished get file operation */
- if (p_cb->obx_oper == FTC_OP_GET_FILE && p_cb->suspending == FALSE)
- {
- status = bta_fs_co_unlink(p_cb->p_name, p_cb->app_id);
- APPL_TRACE_WARNING2("FTC: Remove ABORTED Get File Operation [%s], status 0x%02x",
- p_cb->p_name, status);
- }
- }
-
- /* Clean up control block */
- ftc_reset_cb(p_cb);
- p_cb->sdp_service = 0;
- p_cb->sdp_pending = FALSE;
- p_cb->suspending = FALSE;
- p_cb->p_sess_info = NULL;
-
- if (p_cb->disabling)
- {
- if (p_cb->sdp_handle)
- {
- SDP_DeleteRecord(p_cb->sdp_handle);
- p_cb->sdp_handle = 0;
- bta_sys_remove_uuid( UUID_SERVCLASS_PBAP_PCE );
- }
- p_cb->is_enabled = FALSE;
- p_cb->disabling = FALSE;
- bta_ftc_sm_execute(p_cb, BTA_FTC_DISABLE_CMPL_EVT, NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_stop_client
-**
-** Description Stop OBX client.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_stop_client(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- INT32 timeout;
-
- APPL_TRACE_DEBUG1("bta_ftc_stop_client suspend:%d", p_data->api_close.suspend);
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
- if (p_bta_ft_cfg->p_bi_action &&
- p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_DEREGISTER_IDX] &&
- p_cb->bic_handle != BTA_BIC_INVALID_HANDLE)
- {
- (p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_DEREGISTER_IDX])(p_cb, p_data);
- }
- else if (!p_cb->sdp_pending)
-#else
- if (!p_cb->sdp_pending)
-#endif
- {
- if (p_data->api_close.suspend)
- {
- timeout = p_bta_ft_cfg->suspend_tout;
- p_cb->timer_oper = FTC_TIMER_OP_SUSPEND;
- p_cb->suspending = TRUE;
- OBX_SessionReq (p_cb->obx_handle, OBX_SESS_OP_SUSPEND, 0);
- p_cb->state = BTA_FTC_SUSPENDING_ST;
-
- }
- else
- {
- bta_fs_co_session_info(p_cb->bd_addr, p_cb->p_sess_info, 0, BTA_FS_CO_SESS_ST_NONE, NULL, NULL, p_cb->app_id);
-
- timeout = p_bta_ft_cfg->stop_tout;
- p_cb->timer_oper = FTC_TIMER_OP_STOP;
- OBX_DisconnectReq(p_cb->obx_handle, NULL);
- }
- /* Start stop response timer */
- bta_sys_start_timer(&p_cb->rsp_timer, BTA_FTC_RSP_TOUT_EVT, timeout );
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_close
-**
-** Description If not waiting for a call-in function, complete the closing
-** of the channel.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_close(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- /* finished if not waiting on a call-in function */
- if (!p_cb->sdp_pending && !p_cb->cout_active)
- bta_ftc_sm_execute(p_cb, BTA_FTC_CLOSE_CMPL_EVT, p_data);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_close
-**
-** Description If not waiting for a call-in function, complete the closing
-** of the channel.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_open_fail(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- bta_ftc_close(p_cb, p_data);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_start_client
-**
-** Description Start an FTP or OPP client.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_start_client(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tOBX_STATUS status;
- UINT16 mtu = OBX_MAX_MTU;
- BOOLEAN srm = p_cb->srm;
- UINT32 nonce = p_cb->nonce;
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
-
- p_cb->status = BTA_FTC_OK;
- p_cb->p_sess_info = NULL;
-
- if ( p_bta_ft_cfg->p_bi_action &&
- p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_REGISTER_IDX] &&
- p_cb->sdp_service == UUID_SERVCLASS_IMAGING_RESPONDER)
- {
- (p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_REGISTER_IDX])(p_cb, p_data);
- return;
- }
-
- /* If using OBEX 1.5 */
- if (p_cb->nonce == BTA_FTC_RESUME_NONCE)
- {
- APPL_TRACE_DEBUG1("bta_ftc_start_client psm:0x%x", p_data->sdp_ok.psm);
- p_cb->psm = p_data->sdp_ok.psm;
- bta_fs_co_resume (BTA_FTC_CI_SESSION_EVT, p_cb->app_id);
- }
- /* Allocate an OBX packet */
- else
- {
- if ((p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(OBX_HANDLE_NULL, OBX_CMD_POOL_SIZE)) != NULL)
- {
- p_cb->version = p_data->sdp_ok.version;
-
- /* Add the target header if connecting to FTP service */
- if (p_cb->sdp_service == UUID_SERVCLASS_OBEX_FILE_TRANSFER)
- {
- OBX_AddTargetHdr(p_obx->p_pkt, (UINT8 *)BTA_FTC_FOLDER_BROWSING_TARGET_UUID,
- BTA_FTC_UUID_LENGTH);
- }
- /* Add the target header if connecting to PBAP service */
- else if (p_cb->sdp_service == UUID_SERVCLASS_PBAP_PSE)
- {
- OBX_AddTargetHdr(p_obx->p_pkt, (UINT8 *)BTA_FTC_PB_ACCESS_TARGET_UUID,
- BTA_FTC_UUID_LENGTH);
- }
-
- status = OBX_AllocSession (NULL, p_data->sdp_ok.scn, &p_data->sdp_ok.psm,
- bta_ftc_obx_cback, &p_cb->obx_handle);
-
- /* set security level */
- if (p_data->sdp_ok.scn)
- {
- BTM_SetSecurityLevel (TRUE, "BTA_FTC", BTM_SEC_SERVICE_OBEX_FTP,
- p_cb->sec_mask, BT_PSM_RFCOMM,
- BTM_SEC_PROTO_RFCOMM, p_data->sdp_ok.scn);
- srm = 0;
- nonce = 0;
- }
- else
- {
- BTM_SetSecurityLevel (TRUE, "BTA_FTC", BTM_SEC_SERVICE_OBEX_FTP,
- p_cb->sec_mask, p_data->sdp_ok.psm, 0, 0);
- }
-
- if (status == OBX_SUCCESS)
- {
- OBX_CreateSession (p_cb->bd_addr, mtu, srm, nonce,
- p_cb->obx_handle, p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* OBX will free the memory */
- return;
- }
- /* else stay in this function to report failure */
- return;
- }
- else
- {
- p_cb->status = BTA_FTC_OBX_ERR;
- p_data->obx_evt.rsp_code = OBX_RSP_FAILED;
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CLOSE_EVT, p_data);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_free_db
-**
-** Description Free buffer used for service discovery database.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_free_db(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- utl_freebuf((void**)&p_cb->p_db);
- p_cb->sdp_pending = FALSE;
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_ignore_obx
-**
-** Description Free OBX packet for ignored OBX events.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_ignore_obx(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- utl_freebuf((void**)&p_data->obx_evt.p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_find_service
-**
-** Description Perform service discovery to find OPP and/or FTP services on
-** peer device. If the service ID is both FTP and OPP then FTP
-** is tried first.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_find_service(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tSDP_UUID uuid_list;
- UINT16 attr_list[5];
- UINT16 num_attrs = 4;
- tBTA_SERVICE_MASK ftc_services = (BTA_FTP_SERVICE_MASK | BTA_OPP_SERVICE_MASK
- | BTA_BIP_SERVICE_MASK | BTA_PBAP_SERVICE_MASK);
-
- APPL_TRACE_DEBUG1("bta_ftc_find_service event:0x%x", BTA_FTC_API_OPEN_EVT);
-
- /* Make sure at least one service was specified */
- if (p_cb->services & ftc_services)
- {
- if ((p_cb->p_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_FTC_DISC_SIZE)) != NULL)
- {
- p_cb->status = BTA_FTC_OK;
-
- attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
- attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
- attr_list[2] = ATTR_ID_BT_PROFILE_DESC_LIST;
- attr_list[3] = ATTR_ID_OBX_OVR_L2CAP_PSM;
-
- uuid_list.len = LEN_UUID_16;
-
- /* Try FTP if its service is desired */
- if (p_cb->services & BTA_FTP_SERVICE_MASK)
- {
- p_cb->services &= ~BTA_FTP_SERVICE_MASK;
- p_cb->sdp_service = UUID_SERVCLASS_OBEX_FILE_TRANSFER;
- uuid_list.uu.uuid16 = UUID_SERVCLASS_OBEX_FILE_TRANSFER;
- }
- else if (p_cb->services & BTA_PBAP_SERVICE_MASK)
- {
- p_cb->services &= ~BTA_PBAP_SERVICE_MASK;
- p_cb->sdp_service = UUID_SERVCLASS_PBAP_PSE;
- uuid_list.uu.uuid16 = UUID_SERVCLASS_PBAP_PSE;
- }
- else if (p_cb->services & BTA_OPP_SERVICE_MASK)
- {
- p_cb->services &= ~BTA_OPP_SERVICE_MASK;
- p_cb->sdp_service = UUID_SERVCLASS_OBEX_OBJECT_PUSH;
- uuid_list.uu.uuid16 = UUID_SERVCLASS_OBEX_OBJECT_PUSH;
- }
- else if (p_bta_ft_cfg->p_bi_action)
- {
- /* Try the basic imaging service */
- p_cb->services &= ~BTA_BIP_SERVICE_MASK;
- p_cb->sdp_service = UUID_SERVCLASS_IMAGING_RESPONDER;
- uuid_list.uu.uuid16 = UUID_SERVCLASS_IMAGING_RESPONDER;
- attr_list[num_attrs++] = ATTR_ID_SUPPORTED_FEATURES;
- }
-
- SDP_InitDiscoveryDb(p_cb->p_db, BTA_FTC_DISC_SIZE, 1, &uuid_list, num_attrs, attr_list);
- if (!SDP_ServiceSearchAttributeRequest(p_cb->bd_addr, p_cb->p_db, bta_ftc_sdp_cback))
- {
- p_cb->status = BTA_FTC_SDP_ERR;
- bta_ftc_sm_execute(p_cb, BTA_FTC_SDP_FAIL_EVT, p_data);
-
- }
-
- p_cb->sdp_pending = TRUE;
- }
- }
- else /* No services available */
- {
- p_cb->status = BTA_FTC_SERVICE_UNAVL;
- bta_ftc_sm_execute(p_cb, BTA_FTC_SDP_FAIL_EVT, p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_close_complete
-**
-** Description Finishes the memory cleanup after a channel is closed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_close_complete(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC param;
-
- param.status = p_cb->status;
- p_cb->cout_active = FALSE;
- bta_ftc_initialize(p_cb, p_data);
-
- if (p_bta_ft_cfg->p_bi_action && p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_FREEXML_IDX])
- (p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_FREEXML_IDX])(p_cb, p_data);
-
- /* inform role manager */
- bta_sys_conn_close( BTA_ID_FTC ,p_cb->app_id, p_cb->bd_addr);
- bta_fs_co_session_info(p_cb->bd_addr, p_cb->p_sess_info, 0, BTA_FS_CO_SESS_ST_NONE, NULL, NULL, p_cb->app_id);
-
- p_cb->p_cback(BTA_FTC_CLOSE_EVT, &param);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_set_disable
-**
-** Description Finishes the memory cleanup after a channel is closed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_set_disable(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- p_cb->disabling = TRUE;
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_bic_put
-**
-** Description Initiate a connection with a peer device's service.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_bic_put(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- if (p_bta_ft_cfg->p_bi_action &&
- p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_PUT_IDX])
- {
- p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_PUT_IDX](p_cb, p_data);
- }
- return;
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_bic_abort
-**
-** Description Initiate a connection with a peer device's service.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_bic_abort(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- if (p_bta_ft_cfg->p_bi_action &&
- p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_ABORT_IDX])
- {
- p_bta_ft_cfg->p_bi_action[BTA_FTC_BI_ABORT_IDX](p_cb, p_data);
- }
- return;
-}
-
-/*****************************************************************************
-** Callback Functions
-*****************************************************************************/
-/*******************************************************************************
-**
-** Function bta_ftc_obx_cback
-**
-** Description OBX callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_obx_cback (tOBX_HANDLE handle, tOBX_EVENT obx_event, UINT8 rsp_code,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt)
-{
- tBTA_FTC_OBX_EVT *p_obx_msg;
- UINT16 event = 0;
- UINT16 size = sizeof(tBTA_FTC_OBX_EVT);
-
-#if BTA_FTC_DEBUG == TRUE
- APPL_TRACE_DEBUG2("OBX Event Callback: obx_event [%s] 0x%x", ftc_obx_evt_code(obx_event), p_pkt);
-#endif
-
- switch (obx_event)
- {
- case OBX_SESSION_INFO_EVT:
- size += OBX_SESSION_INFO_SIZE;
- /* Falls through */
-
- case OBX_SESSION_RSP_EVT:
- case OBX_CONNECT_RSP_EVT:
- if (rsp_code == OBX_RSP_OK)
- {
- event = BTA_FTC_OBX_CONN_RSP_EVT;
- }
- else /* Obex will disconnect underneath BTA */
- {
- APPL_TRACE_WARNING1("FTC_CBACK: Bad connect response 0x%02x", rsp_code);
- if (p_pkt)
- GKI_freebuf(p_pkt);
- return;
- }
- break;
-
- case OBX_ACTION_RSP_EVT:
- event = BTA_FTC_OBX_ACTION_RSP_EVT;
- break;
-
- case OBX_PUT_RSP_EVT:
- event = BTA_FTC_OBX_PUT_RSP_EVT;
- break;
- case OBX_GET_RSP_EVT:
- event = BTA_FTC_OBX_GET_RSP_EVT;
- break;
- case OBX_SETPATH_RSP_EVT:
- event = BTA_FTC_OBX_SETPATH_RSP_EVT;
- break;
- case OBX_ABORT_RSP_EVT:
- event = BTA_FTC_OBX_ABORT_RSP_EVT;
- break;
- case OBX_CLOSE_IND_EVT:
- event = BTA_FTC_OBX_CLOSE_EVT;
- break;
- case OBX_TIMEOUT_EVT:
- event = BTA_FTC_OBX_TOUT_EVT;
- break;
- case OBX_PASSWORD_EVT:
- event = BTA_FTC_OBX_PASSWORD_EVT;
- break;
-
- default:
- /* case OBX_DISCONNECT_RSP_EVT: Handled when OBX_CLOSE_IND_EVT arrives */
- if (p_pkt)
- GKI_freebuf(p_pkt);
- return;
-
- }
-
- /* send event to BTA, if any */
- if ((p_obx_msg = (tBTA_FTC_OBX_EVT *) GKI_getbuf(size)) != NULL)
- {
- APPL_TRACE_DEBUG2("obx_event [%d] event:0x%x", obx_event, event);
- p_obx_msg->hdr.event = event;
- p_obx_msg->obx_event = obx_event;
- p_obx_msg->handle = handle;
- p_obx_msg->rsp_code = rsp_code;
- p_obx_msg->param = param;
- p_obx_msg->p_pkt = p_pkt;
-
- if (obx_event == OBX_SESSION_INFO_EVT)
- {
- p_obx_msg->param.sess.p_sess_info = (UINT8 *)(p_obx_msg + 1);
- memcpy (p_obx_msg->param.sess.p_sess_info, param.sess.p_sess_info, OBX_SESSION_INFO_SIZE);
- }
-
- bta_sys_sendmsg(p_obx_msg);
- }
-}
-
-
-/******************************************************************************
-**
-** Function bta_ftc_sdp_cback
-**
-** Description This is the SDP callback function used by FTC.
-** This function will be executed by SDP when the service
-** search is completed. If the search is successful, it
-** finds the first record in the database that matches the
-** UUID of the search. Then retrieves the scn from the
-** record.
-**
-** Returns Nothing.
-**
-******************************************************************************/
-static void bta_ftc_sdp_cback(UINT16 status)
-{
- tBTA_FTC_CB *p_cb = &bta_ftc_cb;
- tBTA_FTC_SDP_OK_EVT *p_buf;
- tSDP_DISC_REC *p_rec = NULL;
- tSDP_PROTOCOL_ELEM pe;
- UINT8 scn = 0;
- UINT16 psm = 0;
- UINT16 version = GOEP_LEGACY_VERSION;
- BOOLEAN found = FALSE;
- tSDP_DISC_ATTR *p_attr;
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
- tBIP_FEATURE_FLAGS features = 0;
-#endif
-
- APPL_TRACE_DEBUG1("bta_ftc_sdp_cback status:%d", status);
-
- if ( (status == SDP_SUCCESS) || (status == SDP_DB_FULL) )
- {
- status = SDP_SUCCESS;
- /* loop through all records we found */
- do
- {
- /* get next record; if none found, we're done */
- if ((p_rec = SDP_FindServiceInDb(p_cb->p_db, p_cb->sdp_service,
- p_rec)) == NULL)
- break;
-
- /* this is an optional attribute */
- SDP_FindProfileVersionInRec (p_rec, p_cb->sdp_service, &version);
-
- /* get psm from proto desc list alternative; if not found, go to next record */
- if ((p_attr = SDP_FindAttributeInRec(p_rec,
- ATTR_ID_OBX_OVR_L2CAP_PSM)) != NULL)
- {
- psm = p_attr->attr_value.v.u16;
- APPL_TRACE_DEBUG1("attr_len_type: x%x", p_attr->attr_len_type);
- if ((SDP_DISC_ATTR_LEN(p_attr->attr_len_type) == 2) && L2C_IS_VALID_PSM(psm))
- {
- found = TRUE;
- if (version == GOEP_LEGACY_VERSION)
- {
- APPL_TRACE_ERROR0("Lacking mandatory attribute/version");
- version = BTA_FT_ENHANCED_VERSION;
- }
- break;
- }
- }
-
- if (!found)
- {
- /* get scn from proto desc list; if not found, go to next record */
- if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
- {
- if ( p_bta_ft_cfg->p_bi_action && p_cb->sdp_service == UUID_SERVCLASS_IMAGING_RESPONDER)
- {
- /* Check if the Push feature is supported */
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
- if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_FEATURES)) != NULL)
- {
- features = p_attr->attr_value.v.u16;
- APPL_TRACE_DEBUG1("supported BIP features: x%x", features);
- if (features & BIP_FT_IMG_PUSH_FLAGS)
- {
- found = TRUE;
- }
- }
-#endif
- }
- else
- {
- found = TRUE;
- }
- scn = (UINT8) pe.params[0];
-
- /* we've got everything, we're done */
- break;
- }
- else
- {
- continue;
- }
- }
- } while (TRUE);
- }
-
- APPL_TRACE_DEBUG4("found: %d scn:%d, psm:0x%x version:0x%x",found , scn, psm, version);
-
- /* send result in event back to BTA */
- if ((p_buf = (tBTA_FTC_SDP_OK_EVT *) GKI_getbuf(sizeof(tBTA_FTC_SDP_OK_EVT))) != NULL)
- {
- p_buf->hdr.event = BTA_FTC_SDP_FAIL_EVT;
- p_cb->status = BTA_FTC_SERVICE_UNAVL;
-
- if (status == SDP_SUCCESS)
- {
- if (found == TRUE)
- {
- p_buf->hdr.event = BTA_FTC_SDP_OK_EVT;
- p_buf->scn = scn;
- p_buf->psm = psm;
- p_buf->version = version;
- }
- /* See if OPP service needs to be searched for */
- else if (p_cb->services & (BTA_OPP_SERVICE_MASK|BTA_BIP_SERVICE_MASK))
- {
- p_buf->hdr.event = BTA_FTC_SDP_NEXT_EVT;
- }
- }
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*****************************************************************************
-** Local FTP Event Processing Functions
-*****************************************************************************/
-static void ftc_reset_cb (tBTA_FTC_CB *p_cb)
-{
- /* Clean up control block */
- utl_freebuf((void**)&p_cb->obx.p_pkt);
- utl_freebuf((void**)(BT_HDR **)&p_cb->p_name);
- p_cb->obx_oper = FTC_OP_NONE;
- p_cb->aborting = 0;
- p_cb->int_abort = FALSE;
- p_cb->req_pending = FALSE;
-}
-
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if BTA_FTC_DEBUG == TRUE
-
-/*******************************************************************************
-**
-** Function ftc_obx_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *ftc_obx_evt_code(tOBX_EVENT evt_code)
-{
- switch (evt_code)
- {
- case OBX_CONNECT_RSP_EVT:
- return "OBX_CONNECT_RSP_EVT";
- case OBX_DISCONNECT_RSP_EVT:
- return "OBX_DISCONNECT_RSP_EVT";
- case OBX_PUT_RSP_EVT:
- return "OBX_PUT_RSP_EVT";
- case OBX_GET_RSP_EVT:
- return "OBX_GET_RSP_EVT";
- case OBX_SETPATH_RSP_EVT:
- return "OBX_SETPATH_RSP_EVT";
- case OBX_ABORT_RSP_EVT:
- return "OBX_ABORT_RSP_EVT";
- case OBX_CLOSE_IND_EVT:
- return "OBX_CLOSE_IND_EVT";
- case OBX_TIMEOUT_EVT:
- return "OBX_TIMEOUT_EVT";
- case OBX_PASSWORD_EVT:
- return "OBX_PASSWORD_EVT";
- case OBX_SESSION_RSP_EVT:
- return "OBX_SESSION_RSP_EVT";
- case OBX_ACTION_RSP_EVT:
- return "OBX_ACTION_RSP_EVT";
- case OBX_SESSION_INFO_EVT:
- return "OBX_SESSION_INFO_EVT";
- default:
- return "unknown OBX event code";
- }
-}
-#endif /* Debug Functions */
-#endif /* BTA_FT_INCLUDED */
diff --git a/bta/ft/bta_ftc_api.c b/bta/ft/bta_ftc_api.c
deleted file mode 100644
index 31722cf..0000000
--- a/bta/ft/bta_ftc_api.c
+++ /dev/null
@@ -1,796 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ftc_api.c
-**
-** Description: This is the implementation of the API for the file
-** transfer server subsystem of BTA, Widcomm's Bluetooth
-** application layer for mobile phones.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include "bt_target.h"
-
-#if defined(BTA_FT_INCLUDED) && (BTA_FT_INCLUDED == TRUE)
-
-#include <string.h>
-#include "gki.h"
-#include "bta_fs_api.h"
-#include "bta_ftc_int.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-static const tBTA_SYS_REG bta_ftc_reg =
-{
- bta_ftc_hdl_event,
- BTA_FtcDisable
-};
-
-/*******************************************************************************
-**
-** Function BTA_FtcEnable
-**
-** Description Enable the file transfer client. This function must be
-** called before any other functions in the FTC API are called.
-** When the enable operation is complete the callback function
-** will be called with an BTA_FTC_ENABLE_EVT event.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcEnable(tBTA_FTC_CBACK *p_cback, UINT8 app_id)
-{
- tBTA_FTC_API_ENABLE *p_buf;
-
- /* register with BTA system manager */
- GKI_sched_lock();
- bta_sys_register(BTA_ID_FTC, &bta_ftc_reg);
- GKI_sched_unlock();
-
- if ((p_buf = (tBTA_FTC_API_ENABLE *)GKI_getbuf(sizeof(tBTA_FTC_API_ENABLE))) != NULL)
- {
- memset(p_buf, 0, sizeof(tBTA_FTC_API_ENABLE));
-
- p_buf->hdr.event = BTA_FTC_API_ENABLE_EVT;
- p_buf->p_cback = p_cback;
- p_buf->app_id = app_id;
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcDisable
-**
-** Description Disable the file transfer client. If the client is currently
-** connected to a peer device the connection will be closed.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcDisable(void)
-{
- BT_HDR *p_buf;
-
- bta_sys_deregister(BTA_ID_FTC);
- if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_FTC_API_DISABLE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcOpen
-**
-** Description Open a connection to an FTP, PBAP, OPP or BIP server.
-** If parameter services is set to use both all services,
-** the client will attempt to connect to the device using
-** FTP first and then PBAP, OPP, BIP.
-** When the connection is open the callback function
-** will be called with a BTA_FTC_OPEN_EVT. If the connection
-** fails or otherwise is closed the callback function will be
-** called with a BTA_FTC_CLOSE_EVT.
-**
-** If the connection is opened with FTP profile and
-** bta_ft_cfg.auto_file_list is TRUE , the callback
-** function will be called with one or more BTA_FTC_LIST_EVT
-** containing directory list information formatted in XML as
-** described in the IrOBEX Spec, Version 1.2, section 9.1.2.3.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcOpen(BD_ADDR bd_addr, tBTA_SEC sec_mask, tBTA_SERVICE_MASK services,
- BOOLEAN srm, UINT32 nonce)
-{
- tBTA_FTC_API_OPEN *p_buf;
-
- if ((p_buf = (tBTA_FTC_API_OPEN *)GKI_getbuf(sizeof(tBTA_FTC_API_OPEN))) != NULL)
- {
- memset(p_buf, 0, sizeof(tBTA_FTC_API_OPEN));
-
- p_buf->hdr.event = BTA_FTC_API_OPEN_EVT;
- p_buf->services = services;
- p_buf->sec_mask = sec_mask;
- p_buf->srm = srm;
- p_buf->nonce = nonce;
- memcpy(p_buf->bd_addr, bd_addr, BD_ADDR_LEN);
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcSuspend
-**
-** Description Suspend the current connection to the server.
-** This is allowed only for the sessions created by
-** BTA_FtcConnect with nonce!=0
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcSuspend(void)
-{
- tBTA_FTC_API_CLOSE *p_buf;
-
- APPL_TRACE_DEBUG0("BTA_FtcSuspend");
- if ((p_buf = (tBTA_FTC_API_CLOSE *)GKI_getbuf(sizeof(tBTA_FTC_API_CLOSE))) != NULL)
- {
- p_buf->hdr.event = BTA_FTC_API_CLOSE_EVT;
- p_buf->suspend = TRUE;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcClose
-**
-** Description Close the current connection to the server.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcClose(void)
-{
- tBTA_FTC_API_CLOSE *p_buf;
-
- if ((p_buf = (tBTA_FTC_API_CLOSE *)GKI_getbuf(sizeof(tBTA_FTC_API_CLOSE))) != NULL)
- {
- p_buf->hdr.event = BTA_FTC_API_CLOSE_EVT;
- p_buf->suspend = FALSE;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcCopyFile
-**
-** Description Invoke a Copy action on the server.
-** Create a copy of p_src and name it as p_dest
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcCopyFile(const char *p_src, const char *p_dest)
-{
- tBTA_FTC_API_ACTION *p_buf;
- UINT16 src_len = (p_src) ? strlen(p_src) : 0;
- UINT16 dest_len = (p_dest) ? strlen(p_dest) : 0;
- UINT16 total_len = sizeof(tBTA_FTC_API_ACTION) + src_len + dest_len + 2;
-
- APPL_TRACE_DEBUG2("BTA_FtcCopyFile src:%s, dest:%s", p_src, p_dest);
-
- if ((p_buf = (tBTA_FTC_API_ACTION *)GKI_getbuf( total_len)) != NULL)
- {
- p_buf->hdr.event = BTA_FTC_API_ACTION_EVT;
- p_buf->action = BTA_FT_ACT_COPY;
- p_buf->p_src = (char *)(p_buf + 1);
- p_buf->p_dest = (char *)(p_buf->p_src + src_len + 1);
- /* copy the src name */
- if (p_src)
- {
- BCM_STRNCPY_S(p_buf->p_src, src_len+1, p_src, src_len);
- p_buf->p_src[src_len] = '\0';
- }
- else
- p_buf->p_src[0] = '\0';
-
- /* copy the dest name */
- if (p_dest)
- {
- BCM_STRNCPY_S(p_buf->p_dest, dest_len+1, p_dest, dest_len);
- p_buf->p_dest[dest_len] = '\0';
- }
- else
- p_buf->p_dest[0] = '\0';
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcMoveFile
-**
-** Description Invoke a Move action on the server.
-** Move/rename p_src to p_dest
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcMoveFile(const char *p_src, const char *p_dest)
-{
- tBTA_FTC_API_ACTION *p_buf;
- UINT16 src_len = (p_src) ? strlen(p_src) : 0;
- UINT16 dest_len = (p_dest) ? strlen(p_dest) : 0;
- UINT16 total_len = sizeof(tBTA_FTC_API_ACTION) + src_len + dest_len + 2;
-
- APPL_TRACE_DEBUG2("BTA_FtcMoveFile src:%s, dest:%s", p_src, p_dest);
-
- if ((p_buf = (tBTA_FTC_API_ACTION *)GKI_getbuf(total_len)) != NULL)
- {
- p_buf->hdr.event = BTA_FTC_API_ACTION_EVT;
- p_buf->action = BTA_FT_ACT_MOVE;
- p_buf->p_src = (char *)(p_buf + 1);
- p_buf->p_dest = (char *)(p_buf->p_src + src_len + 1);
-
- /* copy the src name */
- if (p_src)
- {
- BCM_STRNCPY_S(p_buf->p_src, src_len+1, p_src, src_len);
- p_buf->p_src[src_len] = '\0';
- }
- else
- p_buf->p_src[0] = '\0';
-
- /* copy the dest name */
- if (p_dest)
- {
- BCM_STRNCPY_S(p_buf->p_dest, dest_len+1, p_dest, dest_len);
- p_buf->p_dest[dest_len] = '\0';
- }
- else
- p_buf->p_dest[0] = '\0';
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcSetPermission
-**
-** Description Invoke a SetPermission action on the server.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcSetPermission(const char *p_src, UINT8 user, UINT8 group, UINT8 other)
-{
- tBTA_FTC_API_ACTION *p_buf;
- UINT16 src_len = (p_src) ? strlen(p_src) : 0;
- UINT16 total_len = sizeof(tBTA_FTC_API_ACTION) + src_len + 1;
-
- APPL_TRACE_DEBUG4("BTA_FtcSetPermission src:%s, user:0x%x, group:0x%x, other:0x%x",
- p_src, user, group, other);
-
- if ((p_buf = (tBTA_FTC_API_ACTION *)GKI_getbuf(total_len)) != NULL)
- {
- p_buf->hdr.event = BTA_FTC_API_ACTION_EVT;
- p_buf->action = BTA_FT_ACT_PERMISSION;
- p_buf->p_src = (char *)(p_buf + 1);
-
- /* copy the src name */
- if (p_src)
- {
- BCM_STRNCPY_S(p_buf->p_src, src_len+1, p_src, src_len);
- p_buf->p_src[src_len] = '\0';
- }
- else
- p_buf->p_src[0] = '\0';
-
- p_buf->permission[0] = user;
- p_buf->permission[1] = group;
- p_buf->permission[2] = other;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcPutFile
-**
-** Description Send a file to the connected server.
-** This function can only be used when the client is connected
-** in FTP, OPP and BIP mode.
-**
-** Note: File name is specified with a fully qualified path.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcPutFile(const char *p_name, tBTA_FTC_PARAM *p_param)
-{
- tBTA_FTC_DATA *p_msg;
- INT32 name_len = (INT32)((p_bta_fs_cfg->max_path_len + 1 + 3)/4)*4;
-
- if ((p_msg = (tBTA_FTC_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_FTC_DATA) +
- sizeof(tBTA_FTC_PARAM) + name_len))) != NULL)
- {
- p_msg->api_put.p_name = (char *)(p_msg + 1);
-
- if (p_name != NULL)
- BCM_STRNCPY_S(p_msg->api_put.p_name, name_len, p_name, p_bta_fs_cfg->max_path_len);
- else
- p_msg->api_put.p_name[0] = 0;
-
- if(p_param)
- {
- p_msg->api_put.p_param = (tBTA_FTC_PARAM *)(p_msg->api_put.p_name + name_len);
- memcpy(p_msg->api_put.p_param, p_param, sizeof(tBTA_FTC_PARAM));
- }
- else
- p_msg->api_put.p_param = NULL;
-
- p_msg->api_put.hdr.event = BTA_FTC_API_PUTFILE_EVT;
- bta_sys_sendmsg(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcGetPhoneBook
-**
-** Description Retrieve a PhoneBook from the peer device and copy it to the
-** local file system.
-**
-** This function can only be used when the client is connected
-** in PBAP mode.
-**
-** Note: local file name is specified with a fully qualified path.
-** Remote file name is absolute path in UTF-8 format.
-** (telecom/pb.vcf or SIM1/telecom/pb.vcf).
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcGetPhoneBook(char *p_local_name, char *p_remote_name,
- tBTA_FTC_FILTER_MASK filter, tBTA_FTC_FORMAT format,
- UINT16 max_list_count, UINT16 list_start_offset)
-{
- tBTA_FTC_DATA *p_msg;
- tBTA_FTC_API_GET *p_get;
- tBTA_FTC_GET_PARAM *p_getp;
- UINT16 remote_name_length = (p_remote_name) ? strlen(p_remote_name) : 0;
-
- if ((p_msg = (tBTA_FTC_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_FTC_DATA) +
- (p_bta_fs_cfg->max_path_len + 1) + remote_name_length + 1))) != NULL)
- {
- p_get = &p_msg->api_get;
- p_get->p_param = (tBTA_FTC_GET_PARAM *)(p_msg + 1);
- p_getp = p_get->p_param;
- p_get->p_rem_name = (char *)(p_getp + 1);
- p_get->p_name = (char *)(p_get->p_rem_name + remote_name_length + 1);
- p_get->obj_type = BTA_FTC_GET_PB;
-
- /* copy the local name */
- if (p_local_name)
- BCM_STRNCPY_S(p_get->p_name, p_bta_fs_cfg->max_path_len + 1, p_local_name, p_bta_fs_cfg->max_path_len);
- else
- p_get->p_name[0] = '\0';
-
- /* copy remote name */
- if( p_remote_name)
- BCM_STRNCPY_S(p_get->p_rem_name, remote_name_length + 1, p_remote_name, remote_name_length);
- p_get->p_rem_name[remote_name_length] = '\0';
-
- p_getp->filter = filter;
- p_getp->format = format;
- p_getp->list_start_offset = list_start_offset;
- p_getp->max_list_count = max_list_count;
-
- p_get->hdr.event = BTA_FTC_API_GETFILE_EVT;
- bta_sys_sendmsg(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcGetCard
-**
-** Description Retrieve a vCard from the peer device and copy it to the
-** local file system.
-**
-** This function can only be used when the client is connected
-** in PBAP mode.
-**
-** Note: local file name is specified with a fully qualified path.
-** Remote file name is relative path in UTF-8 format.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcGetCard(char *p_local_name, char *p_remote_name,
- tBTA_FTC_FILTER_MASK filter, tBTA_FTC_FORMAT format)
-{
- tBTA_FTC_DATA *p_msg;
- tBTA_FTC_API_GET *p_get;
- tBTA_FTC_GET_PARAM *p_getp;
- UINT16 remote_name_length = (p_remote_name) ? strlen(p_remote_name) : 0;
-
- if ((p_msg = (tBTA_FTC_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_FTC_DATA) +
- (p_bta_fs_cfg->max_path_len + 1) + remote_name_length + 1))) != NULL)
- {
- p_get = &p_msg->api_get;
- p_get->p_param = (tBTA_FTC_GET_PARAM *)(p_msg + 1);
- p_getp = p_get->p_param;
- p_get->p_rem_name = (char *)(p_getp + 1);
- p_get->p_name = (char *)(p_get->p_rem_name + remote_name_length + 1);
- p_get->obj_type = BTA_FTC_GET_CARD;
-
- /* copy the local name */
- if (p_local_name)
- {
- BCM_STRNCPY_S(p_get->p_name, p_bta_fs_cfg->max_path_len + 1, p_local_name, p_bta_fs_cfg->max_path_len);
- p_get->p_name[p_bta_fs_cfg->max_path_len] = '\0';
- }
- else
- p_get->p_name[0] = '\0';
-
- /* copy remote name */
- if( p_remote_name)
- BCM_STRNCPY_S(p_get->p_rem_name, remote_name_length+1, p_remote_name, remote_name_length);
- p_get->p_rem_name[remote_name_length] = '\0';
-
- p_getp->filter = filter;
- p_getp->format = format;
-
- p_get->hdr.event = BTA_FTC_API_GETFILE_EVT;
- bta_sys_sendmsg(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcGetFile
-**
-** Description Retrieve a file from the peer device and copy it to the
-** local file system.
-**
-** This function can only be used when the client is connected
-** in FTP mode.
-**
-** Note: local file name is specified with a fully qualified path.
-** Remote file name is specified in UTF-8 format.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcGetFile(char *p_local_name, char *p_remote_name)
-{
- tBTA_FTC_DATA *p_msg;
- tBTA_FTC_API_GET *p_get;
- UINT16 remote_name_length = (p_remote_name) ? strlen(p_remote_name) : 0;
-
- if ((p_msg = (tBTA_FTC_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_FTC_DATA) +
- (p_bta_fs_cfg->max_path_len + 1) + remote_name_length + 1))) != NULL)
- {
- p_get = &p_msg->api_get;
- p_get->obj_type = BTA_FTC_GET_FILE;
- p_get->p_param = NULL;
- p_get->p_rem_name = (char *)(p_msg + 1);
- p_get->p_name = (char *)(p_msg->api_get.p_rem_name + remote_name_length + 1);
-
- /* copy the local name */
- if (p_local_name)
- {
- BCM_STRNCPY_S(p_get->p_name, p_bta_fs_cfg->max_path_len + 1, p_local_name, p_bta_fs_cfg->max_path_len);
- p_get->p_name[p_bta_fs_cfg->max_path_len] = '\0';
- }
- else
- p_get->p_name[0] = '\0';
-
- /* copy remote name */
- if( p_remote_name)
- BCM_STRNCPY_S(p_get->p_rem_name, remote_name_length+1, p_remote_name, remote_name_length);
- p_get->p_rem_name[remote_name_length] = '\0';
-
-
- p_get->hdr.event = BTA_FTC_API_GETFILE_EVT;
- bta_sys_sendmsg(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcChDir
-**
-** Description Change directory on the peer device.
-**
-** This function can only be used when the client is connected
-** in FTP and PBAP mode.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcChDir(char *p_dir, tBTA_FTC_FLAG flag)
-{
- tBTA_FTC_DATA *p_msg;
- tBTA_FTC_API_CHDIR *p_chdir;
- UINT16 dir_len;
-
- /* If directory is specified set the length */
- dir_len = (p_dir && *p_dir != '\0') ? (UINT16)(strlen(p_dir) + 1): 0;
-
- if ((p_msg = (tBTA_FTC_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_FTC_DATA) +
- dir_len))) != NULL)
- {
- p_chdir = &p_msg->api_chdir;
- p_chdir->flag = flag;
- if (dir_len)
- {
- p_chdir->p_dir = (char *)(p_msg + 1);
- BCM_STRNCPY_S(p_chdir->p_dir, dir_len, p_dir, dir_len);
- }
- else /* Setting to root directory OR backing up a directory */
- p_chdir->p_dir = NULL;
-
- p_chdir->hdr.event = BTA_FTC_API_CHDIR_EVT;
- bta_sys_sendmsg(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcAuthRsp
-**
-** Description Sends a response to an OBEX authentication challenge to the
-** connected OBEX server. Called in response to an BTA_FTC_AUTH_EVT
-** event.
-**
-** Note: If the "userid_required" is TRUE in the BTA_FTC_AUTH_EVT event,
-** then p_userid is required, otherwise it is optional.
-**
-** p_password must be less than BTA_FTC_MAX_AUTH_KEY_SIZE (16 bytes)
-** p_userid must be less than OBX_MAX_REALM_LEN (defined in target.h)
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcAuthRsp (char *p_password, char *p_userid)
-{
- tBTA_FTC_API_AUTHRSP *p_auth_rsp;
-
- if ((p_auth_rsp = (tBTA_FTC_API_AUTHRSP *)GKI_getbuf(sizeof(tBTA_FTC_API_AUTHRSP))) != NULL)
- {
- memset(p_auth_rsp, 0, sizeof(tBTA_FTC_API_AUTHRSP));
-
- p_auth_rsp->hdr.event = BTA_FTC_API_AUTHRSP_EVT;
-
- if (p_password)
- {
- p_auth_rsp->key_len = strlen(p_password);
- if (p_auth_rsp->key_len > BTA_FTC_MAX_AUTH_KEY_SIZE)
- p_auth_rsp->key_len = BTA_FTC_MAX_AUTH_KEY_SIZE;
- memcpy(p_auth_rsp->key, p_password, p_auth_rsp->key_len);
- }
-
- if (p_userid)
- {
- p_auth_rsp->userid_len = strlen(p_userid);
- if (p_auth_rsp->userid_len > OBX_MAX_REALM_LEN)
- p_auth_rsp->userid_len = OBX_MAX_REALM_LEN;
- memcpy(p_auth_rsp->userid, p_userid, p_auth_rsp->userid_len);
- }
-
- bta_sys_sendmsg(p_auth_rsp);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcListCards
-**
-** Description Retrieve a directory listing from the peer device.
-** When the operation is complete the callback function will
-** be called with one or more BTA_FTC_LIST_EVT events
-** containing directory list information formatted as described
-** in the PBAP Spec, Version 0.9, section 3.1.6.
-** This function can only be used when the client is connected
-** to a peer device.
-**
-** This function can only be used when the client is connected
-** in PBAP mode.
-**
-** Parameters p_dir - Name of directory to retrieve listing of.
-**
-** Returns void
-**
-*******************************************************************************/
-
-void BTA_FtcListCards(char *p_dir, tBTA_FTC_ORDER order, char *p_value,
- tBTA_FTC_ATTR attribute, UINT16 max_list_count,
- UINT16 list_start_offset)
-{
- tBTA_FTC_DATA *p_msg;
- tBTA_FTC_API_LIST *p_list;
- tBTA_FTC_LST_PARAM *p_param;
- UINT16 dir_len = (p_dir == NULL) ? 0 : strlen(p_dir) ;
- UINT16 value_len = (p_value == NULL) ? 0 : strlen(p_value) ;
-
- if ((p_msg = (tBTA_FTC_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_FTC_DATA) +
- sizeof(tBTA_FTC_LST_PARAM) +
- dir_len + value_len + 2))) != NULL)
- {
- p_list = &p_msg->api_list;
- p_list->p_param = (tBTA_FTC_LST_PARAM *)(p_msg + 1);
- p_param = p_list->p_param;
- p_list->p_dir = (char *)(p_param + 1);
- p_param->order = order;
- p_param->attribute = attribute;
- p_param->max_list_count = max_list_count;
- p_param->list_start_offset = list_start_offset;
-
- if (dir_len)
- BCM_STRNCPY_S(p_list->p_dir, dir_len+1, p_dir, dir_len);
- p_list->p_dir[dir_len] = 0;
-
- if (value_len)
- {
- p_param->p_value = (char *)(p_list->p_dir + dir_len + 1);
- BCM_STRNCPY_S(p_param->p_value, value_len+1, p_value, value_len);
- p_param->p_value[value_len] = 0;
- }
- else
- p_param->p_value = NULL;
-
- p_list->hdr.event = BTA_FTC_API_LISTDIR_EVT;
- bta_sys_sendmsg(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcListDir
-**
-** Description Retrieve a directory listing from the peer device.
-** When the operation is complete the callback function will
-** be called with one or more BTA_FTC_LIST_EVT events
-** containing directory list information formatted as described
-** in the IrOBEX Spec, Version 1.2, section 9.1.2.3.
-**
-** This function can only be used when the client is connected
-** in FTP mode.
-**
-** Parameters p_dir - Name of directory to retrieve listing of. If NULL,
-** the current working directory is retrieved.
-**
-** Returns void
-**
-*******************************************************************************/
-
-void BTA_FtcListDir(char *p_dir)
-{
- tBTA_FTC_DATA *p_msg;
- tBTA_FTC_API_LIST *p_list;
- UINT16 dir_len = (p_dir == NULL) ? 0 : strlen(p_dir) ;
-
- if ((p_msg = (tBTA_FTC_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_FTC_DATA) +
- dir_len + 1))) != NULL)
- {
- p_list = &p_msg->api_list;
- p_list->p_dir = (char *)(p_msg + 1);
- p_list->p_param = NULL;
-
- if (dir_len)
- BCM_STRNCPY_S(p_list->p_dir, dir_len+1, p_dir, dir_len);
-
- p_list->p_dir[dir_len] = 0;
-
- p_list->hdr.event = BTA_FTC_API_LISTDIR_EVT;
- bta_sys_sendmsg(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcMkDir
-**
-** Description Create a directory on the peer device. When the operation is
-** complete the status is returned with the BTA_FTC_MKDIR_EVT
-** event.
-**
-** This function can only be used when the client is connected
-** in FTP mode.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcMkDir(char *p_dir)
-{
- tBTA_FTC_API_MKDIR *p_mkdir;
- UINT16 len = (p_dir == NULL) ? 0: strlen(p_dir);
-
- if ((p_mkdir = (tBTA_FTC_API_MKDIR *)GKI_getbuf((UINT16)(sizeof(tBTA_FTC_API_MKDIR) +
- len + 1))) != NULL)
- {
- p_mkdir->p_dir = (char *)(p_mkdir + 1);
-
- if (len > 0)
- BCM_STRNCPY_S(p_mkdir->p_dir, len+1, p_dir, len);
-
- p_mkdir->p_dir[len] = 0;
-
- p_mkdir->hdr.event = BTA_FTC_API_MKDIR_EVT;
- bta_sys_sendmsg(p_mkdir);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtcRemove
-**
-** Description Remove a file or directory on the peer device. When the
-** operation is complete the status is returned with the
-** BTA_FTC_REMOVE_EVT event.
-**
-** This function can only be used when the client is connected
-** in FTP mode.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcRemove(char *p_name)
-
-{
- tBTA_FTC_DATA *p_msg;
- tBTA_FTC_API_REMOVE *p_remove;
- UINT16 len = (p_name == NULL) ? 0 :strlen(p_name);
-
- if ((p_msg = (tBTA_FTC_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_FTC_DATA) +
- len + 1))) != NULL)
- {
- p_remove = &p_msg->api_remove;
- p_remove->p_name = (char *)(p_msg +1);
- if(len)
- BCM_STRNCPY_S(p_remove->p_name, len+1, p_name, len);
-
- p_remove->p_name[len] = 0;
-
- p_remove->hdr.event = BTA_FTC_API_REMOVE_EVT;
- bta_sys_sendmsg(p_msg);
- }
-}
-
-
-
-
-/*******************************************************************************
-**
-** Function BTA_FtcAbort
-**
-** Description Aborts any active Put or Get file operation.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtcAbort(void)
-{
- BT_HDR *p_buf;
-
- if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_FTC_API_ABORT_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-#endif /* BTA_FT_INCLUDED */
diff --git a/bta/ft/bta_ftc_int.h b/bta/ft/bta_ftc_int.h
deleted file mode 100644
index 4279aa6..0000000
--- a/bta/ft/bta_ftc_int.h
+++ /dev/null
@@ -1,504 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ftc_int.h
-**
-** Description: This is the private file for the file transfer
-** client (FTC).
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_FTC_INT_H
-#define BTA_FTC_INT_H
-
-#include "bt_target.h"
-#include "bta_sys.h"
-#include "obx_api.h"
-#include "bta_ft_api.h"
-#include "bta_fs_co.h"
-#include "bta_fs_ci.h"
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
-#include "bta_bi_api.h"
-#endif
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-#define BTA_FTC_PB_ACCESS_TARGET_UUID "\x79\x61\x35\xF0\xF0\xC5\x11\xD8\x09\x66\x08\x00\x20\x0C\x9A\x66"
-#define BTA_FTC_FOLDER_BROWSING_TARGET_UUID "\xF9\xEC\x7B\xC4\x95\x3C\x11\xD2\x98\x4E\x52\x54\x00\xDC\x9E\x09"
-#define BTA_FTC_UUID_LENGTH 16
-#define BTA_FTC_MAX_AUTH_KEY_SIZE 16 /* Must not be greater than OBX_MAX_AUTH_KEY_SIZE */
-#define BTA_FTC_DEFAULT_VERSION 0x0100 /* for PBAP PCE */
-
-#define BTA_FTC_FOLDER_LISTING_TYPE "x-obex/folder-listing"
-
-#define BTA_FTC_PULL_PB_TYPE "x-bt/phonebook"
-#define BTA_FTC_PULL_VCARD_LISTING_TYPE "x-bt/vcard-listing"
-#define BTA_FTC_PULL_VCARD_ENTRY_TYPE "x-bt/vcard"
-
-/* FTC Active ftp obex operation (Valid in connected state) */
-#define FTC_OP_NONE 0
-#define FTC_OP_GET_FILE 1
-#define FTC_OP_PUT_FILE 2
-#define FTC_OP_DELETE 3 /* Folder or File */
-#define FTC_OP_GET_LIST 4
-#define FTC_OP_MKDIR 5
-#define FTC_OP_CHDIR 6
-/* note: the following 3 OPs need to be continuous and the order can not change */
-#define FTC_OP_COPY 7 /* Copy object */
-#define FTC_OP_MOVE 8 /* Move/rename object */
-#define FTC_OP_PERMISSION 9 /* Set object permission */
-#define FTC_OP_RESUME 0x80 /* to mark the operation to resume */
-
-enum
-{
- BTA_FTC_GET_FILE, /* get file */
- BTA_FTC_GET_CARD, /* PBAP PullvCardEntry */
- BTA_FTC_GET_PB /* PBAP PullPhoneBook */
-};
-typedef UINT8 tBTA_FTC_TYPE;
-
-/* Response Timer Operations */
-#define FTC_TIMER_OP_STOP 0
-#define FTC_TIMER_OP_ABORT 1
-#define FTC_TIMER_OP_SUSPEND 2
-
-/* File abort mask states */
-/* Abort must receive cout and response before abort completed */
-#define FTC_ABORT_REQ_NOT_SENT 0x1
-#define FTC_ABORT_REQ_SENT 0x2
-#define FTC_ABORT_RSP_RCVD 0x4
-#define FTC_ABORT_COUT_DONE 0x8
-
-#define FTC_ABORT_COMPLETED (FTC_ABORT_REQ_SENT | FTC_ABORT_RSP_RCVD | FTC_ABORT_COUT_DONE)
-
-/* TODO remove: Reliable session suspend mask states */
-/* suspend must receive cout and response before suspend completed
-#define FTC_SUSPEND_REQ_NOT_SENT 0x10 */
-
-/* state machine events */
-enum
-{
- /* these events are handled by the state machine */
- BTA_FTC_API_DISABLE_EVT = BTA_SYS_EVT_START(BTA_ID_FTC),
-
- BTA_FTC_API_OPEN_EVT, /* Open a connection request */
- BTA_FTC_API_CLOSE_EVT, /* Close an open connection request */
- BTA_FTC_API_PUTFILE_EVT, /* Put File request */
- BTA_FTC_API_GETFILE_EVT, /* Get File request */
- BTA_FTC_API_LISTDIR_EVT, /* List Directory request */
- BTA_FTC_API_CHDIR_EVT, /* Change Directory request */
- BTA_FTC_API_MKDIR_EVT, /* make Directory request */
- BTA_FTC_API_REMOVE_EVT, /* Remove Directory request */
- BTA_FTC_API_AUTHRSP_EVT, /* Response to password request */
- BTA_FTC_API_ABORT_EVT, /* Abort request */
- BTA_FTC_API_ACTION_EVT, /* Action request */
- BTA_FTC_OBX_ACTION_RSP_EVT, /* Copy/Move File or Set Permission */
- BTA_FTC_CI_SESSION_EVT, /* Call-in response to session requests */
- BTA_FTC_SDP_OK_EVT, /* Service search was successful */
- BTA_FTC_SDP_FAIL_EVT, /* Service search failed */
- BTA_FTC_SDP_NEXT_EVT, /* Try another service search (OPP) */
- BTA_FTC_CI_WRITE_EVT, /* Call-in response to Write request */
- BTA_FTC_CI_READ_EVT, /* Call-in response to Read request */
- BTA_FTC_CI_OPEN_EVT, /* Call-in response to File Open request */
- BTA_FTC_OBX_CONN_RSP_EVT, /* OBX Channel Connect Request */
- BTA_FTC_OBX_ABORT_RSP_EVT, /* OBX_operation aborted */
- BTA_FTC_OBX_TOUT_EVT, /* OBX Operation Timeout */
- BTA_FTC_OBX_PASSWORD_EVT, /* OBX password requested */
- BTA_FTC_OBX_CLOSE_EVT, /* OBX Channel Disconnected (Link Lost) */
- BTA_FTC_OBX_PUT_RSP_EVT, /* Write file data or delete */
- BTA_FTC_OBX_GET_RSP_EVT, /* Read file data or folder listing */
- BTA_FTC_OBX_SETPATH_RSP_EVT, /* Make or Change Directory */
- BTA_FTC_OBX_CMPL_EVT, /* operation has completed */
- BTA_FTC_CLOSE_CMPL_EVT, /* Finish the closing of the channel */
- BTA_FTC_DISABLE_CMPL_EVT, /* Finished disabling system */
- BTA_FTC_RSP_TOUT_EVT, /* Timeout waiting for response from server */
-
- /* these events are handled outside the state machine */
- BTA_FTC_API_ENABLE_EVT
-};
-
-
-/* state machine states */
-enum
-{
- BTA_FTC_IDLE_ST = 0, /* Idle */
- BTA_FTC_W4_CONN_ST, /* Waiting for an Obex connect response */
- BTA_FTC_CONN_ST, /* Connected - FTP Session is active */
- BTA_FTC_SUSPENDING_ST, /* suspend is in progress */
- BTA_FTC_CLOSING_ST /* Closing is in progress */
-};
-typedef UINT16 tBTA_FTC_INT_EVT;
-
-typedef UINT8 tBTA_FTC_STATE;
-
-/* Application Parameters Header
-Tag IDs used in the Application Parameters header:
-*/
- /* Tag ID Length Possible Values */
-#define BTA_FTC_APH_ORDER 0x01 /* Order 1 bytes 0x0 to 0x2 */
-#define BTA_FTC_APH_SEARCH_VALUE 0x02 /* SearchValue variable text */
-#define BTA_FTC_APH_SEARCH_ATTR 0x03 /* SearchAttribute 1 byte 0x0 to 0x2 */
-#define BTA_FTC_APH_MAX_LIST_COUNT 0x04 /* MaxListCount 2 bytes 0x0000 to 0xFFFF */
-#define BTA_FTC_APH_LIST_STOFF 0x05 /* ListStartOffset 2 bytes 0x0000 to 0xFFFF */
-#define BTA_FTC_APH_FILTER 0x06 /* Filter 4 bytes 0x00000000 to 0xFFFFFFFF */
-#define BTA_FTC_APH_FORMAT 0x07 /* Format 1 byte 0x00(2.1), 0x01(3.0) */
-#define BTA_FTC_APH_PB_SIZE 0x08 /* PhoneBookSize 2 byte 0x0000 to 0xFFFF */
-#define BTA_FTC_APH_NEW_MISSED_CALL 0x09 /* NewMissedCall 1 bytes 0x00 to 0xFF */
-#define BTA_FTC_APH_MAX_TAG BTA_FTC_APH_NEW_MISSED_CALL
-
-/* data type for BTA_FTC_API_ENABLE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_FTC_CBACK *p_cback;
- UINT8 app_id;
-} tBTA_FTC_API_ENABLE;
-
-/* data type for BTA_FTC_API_OPEN_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_SERVICE_MASK services; /* FTP and/or OPP */
- BD_ADDR bd_addr;
- UINT8 sec_mask;
- BOOLEAN srm;
- UINT32 nonce;
-} tBTA_FTC_API_OPEN;
-
-/* data type for BTA_FTC_API_CLOSE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- BOOLEAN suspend;
-} tBTA_FTC_API_CLOSE;
-
-/* data type for BTA_FTC_API_ACTION_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_FTC_ACT action;
- char *p_src; /* UTF-8 name from listing */
- char *p_dest; /* UTF-8 name */
- UINT8 permission[3];
-} tBTA_FTC_API_ACTION;
-
-/* data type for BTA_FTC_API_PUTFILE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- char *p_name;
- tBTA_FTC_PARAM *p_param;
-} tBTA_FTC_API_PUT;
-
-typedef struct
-{
- tBTA_FTC_FILTER_MASK filter;
- UINT16 max_list_count;
- UINT16 list_start_offset;
- tBTA_FTC_FORMAT format;
-} tBTA_FTC_GET_PARAM;
-
-/* data type for BTA_FTC_API_GETFILE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- char *p_rem_name; /* UTF-8 name from listing */
- char *p_name;
- tBTA_FTC_GET_PARAM *p_param;
- UINT8 obj_type;
-} tBTA_FTC_API_GET;
-
-/* data type for BTA_FTC_API_CHDIR_EVT */
-typedef struct
-{
- BT_HDR hdr;
- char *p_dir; /* UTF-8 name from listing */
- tBTA_FTC_FLAG flag;
-} tBTA_FTC_API_CHDIR;
-
-typedef struct
-{
- char *p_value;
- UINT16 max_list_count;
- UINT16 list_start_offset;
- tBTA_FTC_ORDER order;
- tBTA_FTC_ATTR attribute;
-} tBTA_FTC_LST_PARAM;
-
-/* data type for BTA_FTC_API_LISTDIR_EVT */
-typedef struct
-{
- BT_HDR hdr;
- char *p_dir; /* UTF-8 name from listing */
- tBTA_FTC_LST_PARAM *p_param;
-} tBTA_FTC_API_LIST;
-
-/* data type for BTA_FTC_API_MKDIR_EVT */
-typedef struct
-{
- BT_HDR hdr;
- char *p_dir; /* UTF-8 name directory */
-} tBTA_FTC_API_MKDIR;
-
-/* data type for BTA_FTC_API_REMOVE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- char *p_name; /* UTF-8 name of file or directory */
-} tBTA_FTC_API_REMOVE;
-
-
-/* data type for BTA_FTC_API_AUTHRSP_EVT */
-typedef struct
-{
- BT_HDR hdr;
- UINT8 key [BTA_FTC_MAX_AUTH_KEY_SIZE]; /* The authentication key.*/
- UINT8 key_len;
- UINT8 userid [OBX_MAX_REALM_LEN]; /* The authentication user id.*/
- UINT8 userid_len;
-} tBTA_FTC_API_AUTHRSP;
-
-/* data type for BTA_FTC_SDP_OK_EVT */
-typedef struct
-{
- BT_HDR hdr;
- UINT8 scn;
- UINT16 psm;
- UINT16 version;
-} tBTA_FTC_SDP_OK_EVT;
-
-/* data type for all obex events
- hdr.event contains the FTC event
-*/
-typedef struct
-{
- BT_HDR hdr;
- tOBX_HANDLE handle;
- tOBX_EVT_PARAM param;
- BT_HDR *p_pkt;
- tOBX_EVENT obx_event;
- UINT8 rsp_code;
-} tBTA_FTC_OBX_EVT;
-
-/* union of all event data types */
-typedef union
-{
- BT_HDR hdr;
- tBTA_FTC_API_ENABLE api_enable;
- tBTA_FTC_API_OPEN api_open;
- tBTA_FTC_API_CLOSE api_close;
- tBTA_FTC_API_PUT api_put;
- tBTA_FTC_API_GET api_get;
- tBTA_FTC_API_CHDIR api_chdir;
- tBTA_FTC_API_MKDIR api_mkdir;
- tBTA_FTC_API_REMOVE api_remove;
- tBTA_FTC_API_AUTHRSP auth_rsp;
- tBTA_FTC_API_LIST api_list;
- tBTA_FTC_API_ACTION api_action;
- tBTA_FTC_SDP_OK_EVT sdp_ok;
- tBTA_FTC_OBX_EVT obx_evt;
- tBTA_FS_CI_OPEN_EVT open_evt;
- tBTA_FS_CI_RESUME_EVT resume_evt;
- tBTA_FS_CI_READ_EVT read_evt;
- tBTA_FS_CI_WRITE_EVT write_evt;
-} tBTA_FTC_DATA;
-
-
-/* OBX Response Packet Structure - Holds current command/response packet info */
-typedef struct
-{
- BT_HDR *p_pkt; /* (Get/Put) Holds the current OBX header for Put or Get */
- UINT8 *p_start; /* (Get/Put) Start of the Body of the packet */
- UINT16 offset; /* (Get/Put) Contains the current offset into the Body (p_start) */
- UINT16 bytes_left; /* (Get/Put) Holds bytes available left in Obx packet */
- BOOLEAN final_pkt; /* (Get) Holds the final bit of the Put packet */
-} tBTA_FTC_OBX_PKT;
-
-/* Power management state for FTC */
-#define BTA_FTC_PM_BUSY 0
-#define BTA_FTC_PM_IDLE 1
-
-
-/* FTC control block */
-typedef struct
-{
- tBTA_FTC_CBACK *p_cback; /* pointer to application callback function */
- char *p_name; /* Holds the local file name */
- tSDP_DISCOVERY_DB *p_db; /* pointer to discovery database */
- UINT32 sdp_handle; /* SDP record handle for PCE */
- tBTA_FTC_OBX_PKT obx; /* Holds the current OBX packet information */
- TIMER_LIST_ENT rsp_timer; /* response timer */
- tBTA_SERVICE_MASK services; /* FTP and/or OPP and/or BIP */
- int fd; /* File Descriptor of opened file */
- UINT32 file_size; /* (Put/Get) length of file */
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
- tBIP_IMAGING_CAPS *p_caps; /* BIP imaging capabilities */
- tBIP_IMG_HDL_STR img_hdl; /* The image’s handle for when responder requests thumbnail */
-#endif
- UINT8 *p_sess_info;
- UINT16 peer_mtu;
- UINT16 sdp_service;
- BD_ADDR bd_addr;
- tOBX_HANDLE obx_handle;
- UINT8 sec_mask;
- tBTA_FTC_STATE state; /* state machine state */
- UINT8 obx_oper; /* current active OBX operation PUT FILE or GET FILE */
- UINT8 timer_oper; /* current active response timer action (abort or close) */
- UINT8 app_id;
- tBTA_FTC_TYPE obj_type; /* type of get op */
- BOOLEAN first_req_pkt; /* TRUE if retrieving the first packet of GET/PUT file */
- BOOLEAN cout_active; /* TRUE if call-out is currently active */
- BOOLEAN disabling; /* TRUE if client is in process of disabling */
- UINT8 aborting; /* Non-zero if client is in process of aborting */
- BOOLEAN int_abort; /* TRUE if internal abort issued (Not API inititated) */
- BOOLEAN is_enabled; /* TRUE if client is enabled */
- BOOLEAN req_pending; /* TRUE when waiting for an obex response */
- BOOLEAN sdp_pending; /* TRUE when waiting for SDP to complete */
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
- UINT8 bic_handle;
-#endif
- UINT8 scn;
- UINT16 version;
-
- /* OBEX 1.5 */
- UINT16 psm;
- UINT32 nonce;
- BOOLEAN srm;
- BOOLEAN suspending; /* TRUE when suspending session */
-
- tBTA_FTC_STATUS status;
- UINT8 pm_state;
-} tBTA_FTC_CB;
-
-/* type for action functions */
-typedef void (*tBTA_FTC_ACTION)(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-
-/******************************************************************************
-** Configuration Definitions
-*******************************************************************************/
-typedef const tBTA_FTC_ACTION (*tBTA_FTC_BI_TBL);
-
-/* Configuration structure */
-typedef struct
-{
- tBTA_FTC_BI_TBL p_bi_action; /* BI related action func used in FTC */
- UINT8 realm_charset; /* Server only */
- BOOLEAN userid_req; /* TRUE if user id is required during obex authentication (Server only) */
- BOOLEAN auto_file_list; /* TRUE if automatic get the file listing from sever on OBEX connect response */
- UINT8 pce_features; /* PBAP PCE supported features. If 0, PCE is not supported */
- char *pce_name; /* service name for PBAP PCE SDP record */
- INT32 abort_tout; /* Timeout in milliseconds to wait for abort OBEX response (client only) */
- INT32 stop_tout; /* Timeout in milliseconds to wait for close OBEX response (client only) */
- INT32 suspend_tout; /* Timeout in milliseconds to wait for suspend OBEX response (client only) */
- UINT32 nonce; /* non-0 to allow reliable session (Server Only) */
- UINT8 max_suspend; /* the maximum number of suspended session (Server Only) */
- BOOLEAN over_l2cap; /* TRUE to use Obex Over L2CAP (Server Only) */
- BOOLEAN srm; /* TRUE to engage Single Response Mode (Server Only) */
-
-} tBTA_FT_CFG;
-
-enum
-{
- BTA_FTC_BI_REGISTER_IDX = 0,
- BTA_FTC_BI_DEREGISTER_IDX,
- BTA_FTC_BI_AUTHRSP_IDX,
- BTA_FTC_BI_FREEXML_IDX,
- BTA_FTC_BI_PUT_IDX,
- BTA_FTC_BI_ABORT_IDX
-};
-
-extern const tBTA_FTC_ACTION bta_ftc_bi_action[];
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* FTC control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-extern tBTA_FTC_CB bta_ftc_cb;
-#else
-extern tBTA_FTC_CB *bta_ftc_cb_ptr;
-#define bta_ftc_cb (*bta_ftc_cb_ptr)
-#endif
-
-/* FT configuration constants */
-extern tBTA_FT_CFG *p_bta_ft_cfg;
-
-/*****************************************************************************
-** Function prototypes
-*****************************************************************************/
-
-extern BOOLEAN bta_ftc_hdl_event(BT_HDR *p_msg);
-extern void bta_ftc_sm_execute(tBTA_FTC_CB *p_cb, UINT16 event,
- tBTA_FTC_DATA *p_data);
-extern void bta_ftc_obx_cback (tOBX_HANDLE handle, tOBX_EVENT event,
- UINT8 rsp_code, tOBX_EVT_PARAM param,
- BT_HDR *p_pkt);
-
-extern void bta_ftc_init_open(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_init_close(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_init_putfile(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_init_getfile(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_chdir(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_send_authrsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_abort(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_api_action(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_obx_action_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_obx_get_srm_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_ci_write_srm(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_ci_write(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_ci_read(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_ci_open(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_ci_resume(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_obx_conn_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_obx_sess_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_suspended(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_obx_abort_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_obx_password(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_obx_timeout(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_obx_put_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_obx_get_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_obx_setpath_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_initialize(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_trans_cmpl(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_stop_client(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_start_client(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_free_db(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_ignore_obx(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_find_service(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_close(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_open_fail(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_close_complete(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_set_disable(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_rsp_timeout(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_bic_put(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_bic_abort(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-
-/* BI related action function used in FTC */
-extern void bta_ftc_bic_register(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_bic_deregister(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_bic_authrsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_bic_freexml(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_bic_putact(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_bic_abortact(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-
-
-extern void bta_ftc_listdir(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_remove(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern void bta_ftc_mkdir(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-
-/* miscellaneous functions */
-extern UINT8 bta_ftc_send_get_req(tBTA_FTC_CB *p_cb);
-extern void bta_ftc_proc_get_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data);
-extern UINT8 bta_ftc_cont_put_file(tBTA_FTC_CB *p_cb, BOOLEAN first_pkt);
-extern void bta_ftc_proc_list_data(tBTA_FTC_CB *p_cb, tBTA_FTC_OBX_EVT *p_evt);
-extern void bta_ftc_get_listing(tBTA_FTC_CB *p_cb, char *p_name, tBTA_FTC_LST_PARAM *p_param);
-extern void bta_ftc_listing_err(BT_HDR **p_pkt, tBTA_FTC_STATUS status);
-
-
-extern tBTA_FTC_STATUS bta_ftc_convert_obx_to_ftc_status(tOBX_STATUS obx_status);
-
-#endif /* BTA_FTC_INT_H */
diff --git a/bta/ft/bta_ftc_main.c b/bta/ft/bta_ftc_main.c
deleted file mode 100644
index 8148703..0000000
--- a/bta/ft/bta_ftc_main.c
+++ /dev/null
@@ -1,689 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ftc_main.c
-**
-** Description: This file contains the file transfer client main functions
-** and state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "bt_target.h"
-
-#if defined(BTA_FT_INCLUDED) && (BTA_FT_INCLUDED == TRUE)
-
-#include "bta_ftc_int.h"
-#include "gki.h"
-#include "obx_api.h"
-
-
-/*****************************************************************************
-** Constants and types
-*****************************************************************************/
-
-
-/* state machine action enumeration list */
-enum
-{
- BTA_FTC_INIT_OPEN,
- BTA_FTC_START_CLIENT,
- BTA_FTC_STOP_CLIENT,
- BTA_FTC_INIT_GETFILE,
- BTA_FTC_INIT_PUTFILE,
- BTA_FTC_LISTDIR,
- BTA_FTC_CHDIR,
- BTA_FTC_MKDIR,
- BTA_FTC_REMOVE,
- BTA_FTC_SEND_AUTHRSP,
- BTA_FTC_CI_WRITE,
- BTA_FTC_CI_READ,
- BTA_FTC_CI_OPEN,
- BTA_FTC_CI_RESUME,
- BTA_FTC_OBX_SESS_RSP,
- BTA_FTC_OBX_GET_SRM_RSP,
- BTA_FTC_CI_WRITE_SRM,
- BTA_FTC_SUSPENDED,
- BTA_FTC_OBX_CONN_RSP,
- BTA_FTC_CLOSE,
- BTA_FTC_OPEN_FAIL,
- BTA_FTC_OBX_ABORT_RSP,
- BTA_FTC_OBX_PASSWORD,
- BTA_FTC_OBX_TIMEOUT,
- BTA_FTC_OBX_PUT_RSP,
- BTA_FTC_OBX_GET_RSP,
- BTA_FTC_OBX_SETPATH_RSP,
- BTA_FTC_TRANS_CMPL,
- BTA_FTC_FREE_DB,
- BTA_FTC_IGNORE_OBX,
- BTA_FTC_FIND_SERVICE,
- BTA_FTC_INITIALIZE,
- BTA_FTC_CLOSE_COMPLETE,
- BTA_FTC_BIC_PUT,
- BTA_FTC_BIC_ABORT,
- BTA_FTC_SET_DISABLE,
- BTA_FTC_ABORT,
- BTA_FTC_API_ACTION,
- BTA_FTC_OBX_ACTION_RSP,
- BTA_FTC_RSP_TIMEOUT,
- BTA_FTC_IGNORE
-};
-
-/* action function list */
-const tBTA_FTC_ACTION bta_ftc_action[] =
-{
- bta_ftc_init_open,
- bta_ftc_start_client,
- bta_ftc_stop_client,
- bta_ftc_init_getfile,
- bta_ftc_init_putfile,
- bta_ftc_listdir,
- bta_ftc_chdir,
- bta_ftc_mkdir,
- bta_ftc_remove,
- bta_ftc_send_authrsp,
- bta_ftc_ci_write,
- bta_ftc_ci_read,
- bta_ftc_ci_open,
- bta_ftc_ci_resume,
- bta_ftc_obx_sess_rsp,
- bta_ftc_obx_get_srm_rsp,
- bta_ftc_ci_write_srm,
- bta_ftc_suspended,
- bta_ftc_obx_conn_rsp,
- bta_ftc_close,
- bta_ftc_open_fail,
- bta_ftc_obx_abort_rsp,
- bta_ftc_obx_password,
- bta_ftc_obx_timeout,
- bta_ftc_obx_put_rsp,
- bta_ftc_obx_get_rsp,
- bta_ftc_obx_setpath_rsp,
- bta_ftc_trans_cmpl,
- bta_ftc_free_db,
- bta_ftc_ignore_obx,
- bta_ftc_find_service,
- bta_ftc_initialize,
- bta_ftc_close_complete,
- bta_ftc_bic_put,
- bta_ftc_bic_abort,
- bta_ftc_set_disable,
- bta_ftc_abort,
- bta_ftc_api_action,
- bta_ftc_obx_action_rsp,
- bta_ftc_rsp_timeout
-};
-
-
-/* state table information */
-#define BTA_FTC_ACTIONS 2 /* number of actions */
-#define BTA_FTC_NEXT_STATE 2 /* position of next state */
-#define BTA_FTC_NUM_COLS 3 /* number of columns in state tables */
-
-/* state table for idle state */
-static const UINT8 bta_ftc_st_idle[][BTA_FTC_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* BTA_FTC_API_DISABLE_EVT */ {BTA_FTC_SET_DISABLE, BTA_FTC_INITIALIZE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_API_OPEN_EVT */ {BTA_FTC_INIT_OPEN, BTA_FTC_FIND_SERVICE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_API_CLOSE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_API_PUTFILE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_API_GETFILE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_API_LISTDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_API_CHDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_API_MKDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_API_REMOVE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_API_AUTHRSP_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_API_ABORT_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_API_ACTION_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_OBX_ACTION_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_CI_SESSION_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_SDP_OK_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_SDP_FAIL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_SDP_NEXT_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_CI_WRITE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_CI_READ_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_CI_OPEN_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_OBX_CONN_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_OBX_ABORT_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_OBX_TOUT_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_OBX_PASSWORD_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_OBX_CLOSE_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_OBX_PUT_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_OBX_GET_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_OBX_SETPATH_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_OBX_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_CLOSE_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_DISABLE_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_RSP_TOUT_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST}
-};
-
-/* state table for wait for authentication response state */
-static const UINT8 bta_ftc_st_w4_conn[][BTA_FTC_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* BTA_FTC_API_DISABLE_EVT */ {BTA_FTC_SET_DISABLE, BTA_FTC_STOP_CLIENT, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_OPEN_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_API_CLOSE_EVT */ {BTA_FTC_STOP_CLIENT, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_PUTFILE_EVT */ {BTA_FTC_BIC_PUT, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_API_GETFILE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_API_LISTDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_API_CHDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_API_MKDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_API_REMOVE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_API_AUTHRSP_EVT */ {BTA_FTC_SEND_AUTHRSP, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_API_ABORT_EVT */ {BTA_FTC_BIC_ABORT, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_API_ACTION_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_OBX_ACTION_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_CI_SESSION_EVT */ {BTA_FTC_CI_RESUME, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_SDP_OK_EVT */ {BTA_FTC_FREE_DB, BTA_FTC_START_CLIENT, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_SDP_FAIL_EVT */ {BTA_FTC_FREE_DB, BTA_FTC_CLOSE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_SDP_NEXT_EVT */ {BTA_FTC_FREE_DB, BTA_FTC_FIND_SERVICE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_CI_WRITE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_CI_READ_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_CI_OPEN_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_OBX_CONN_RSP_EVT */ {BTA_FTC_OBX_CONN_RSP, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_OBX_ABORT_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_OBX_TOUT_EVT */ {BTA_FTC_OBX_TIMEOUT, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_OBX_PASSWORD_EVT */ {BTA_FTC_OBX_PASSWORD, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_OBX_CLOSE_EVT */ {BTA_FTC_OPEN_FAIL, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_PUT_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_OBX_GET_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_OBX_SETPATH_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_OBX_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_W4_CONN_ST},
-/* BTA_FTC_CLOSE_CMPL_EVT */ {BTA_FTC_CLOSE_COMPLETE,BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_DISABLE_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_RSP_TOUT_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST}
-
-};
-
-/* state table for connected state */
-static const UINT8 bta_ftc_st_connected[][BTA_FTC_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* BTA_FTC_API_DISABLE_EVT */ {BTA_FTC_SET_DISABLE, BTA_FTC_STOP_CLIENT, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_OPEN_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_API_CLOSE_EVT */ {BTA_FTC_STOP_CLIENT, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_PUTFILE_EVT */ {BTA_FTC_INIT_PUTFILE, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_API_GETFILE_EVT */ {BTA_FTC_INIT_GETFILE, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_API_LISTDIR_EVT */ {BTA_FTC_LISTDIR , BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_API_CHDIR_EVT */ {BTA_FTC_CHDIR, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_API_MKDIR_EVT */ {BTA_FTC_MKDIR, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_API_REMOVE_EVT */ {BTA_FTC_REMOVE, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_API_AUTHRSP_EVT */ {BTA_FTC_SEND_AUTHRSP, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_API_ABORT_EVT */ {BTA_FTC_ABORT, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_API_ACTION_EVT */ {BTA_FTC_API_ACTION, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_OBX_ACTION_RSP_EVT */ {BTA_FTC_OBX_ACTION_RSP, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_CI_SESSION_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_SDP_OK_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_SDP_FAIL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_SDP_NEXT_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_CI_WRITE_EVT */ {BTA_FTC_CI_WRITE, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_CI_READ_EVT */ {BTA_FTC_CI_READ, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_CI_OPEN_EVT */ {BTA_FTC_CI_OPEN, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_OBX_CONN_RSP_EVT */ {BTA_FTC_SUSPENDED, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_OBX_ABORT_RSP_EVT */ {BTA_FTC_OBX_ABORT_RSP, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_OBX_TOUT_EVT */ {BTA_FTC_OBX_TIMEOUT, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_OBX_PASSWORD_EVT */ {BTA_FTC_OBX_PASSWORD, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_OBX_CLOSE_EVT */ {BTA_FTC_CLOSE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_PUT_RSP_EVT */ {BTA_FTC_OBX_PUT_RSP, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_OBX_GET_RSP_EVT */ {BTA_FTC_OBX_GET_RSP, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_OBX_SETPATH_RSP_EVT */ {BTA_FTC_OBX_SETPATH_RSP, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_OBX_CMPL_EVT */ {BTA_FTC_TRANS_CMPL, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_CLOSE_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CONN_ST},
-/* BTA_FTC_DISABLE_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_RSP_TOUT_EVT */ {BTA_FTC_RSP_TIMEOUT, BTA_FTC_IGNORE, BTA_FTC_CONN_ST}
-};
-
-/* state table for suspending state */
-static const UINT8 bta_ftc_st_suspending[][BTA_FTC_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* BTA_FTC_API_DISABLE_EVT */ {BTA_FTC_SET_DISABLE, BTA_FTC_STOP_CLIENT, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_OPEN_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_API_CLOSE_EVT */ {BTA_FTC_STOP_CLIENT, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_PUTFILE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_API_GETFILE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_API_LISTDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_API_CHDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_API_MKDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_API_REMOVE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_API_AUTHRSP_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_API_ABORT_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_API_ACTION_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_OBX_ACTION_RSP_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_CI_SESSION_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_SDP_OK_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_SDP_FAIL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_SDP_NEXT_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_CI_WRITE_EVT */ {BTA_FTC_CI_WRITE_SRM, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_CI_READ_EVT */ {BTA_FTC_CI_READ, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_CI_OPEN_EVT */ {BTA_FTC_CI_OPEN, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_OBX_CONN_RSP_EVT */ {BTA_FTC_OBX_SESS_RSP, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_ABORT_RSP_EVT */ {BTA_FTC_OBX_ABORT_RSP, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_OBX_TOUT_EVT */ {BTA_FTC_OBX_TIMEOUT, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_OBX_PASSWORD_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_OBX_CLOSE_EVT */ {BTA_FTC_CLOSE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_PUT_RSP_EVT */ {BTA_FTC_OBX_PUT_RSP, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_OBX_GET_RSP_EVT */ {BTA_FTC_OBX_GET_SRM_RSP, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_OBX_SETPATH_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_OBX_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_CLOSE_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_SUSPENDING_ST},
-/* BTA_FTC_DISABLE_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_RSP_TOUT_EVT */ {BTA_FTC_RSP_TIMEOUT, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST}
-};
-
-/* state table for closing state */
-static const UINT8 bta_ftc_st_closing[][BTA_FTC_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* BTA_FTC_API_DISABLE_EVT */ {BTA_FTC_SET_DISABLE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_OPEN_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_CLOSE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_PUTFILE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_GETFILE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_LISTDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_CHDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_MKDIR_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_REMOVE_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_AUTHRSP_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_ABORT_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_API_ACTION_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_ACTION_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_CI_SESSION_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_SDP_OK_EVT */ {BTA_FTC_FREE_DB, BTA_FTC_CLOSE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_SDP_FAIL_EVT */ {BTA_FTC_FREE_DB, BTA_FTC_CLOSE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_SDP_NEXT_EVT */ {BTA_FTC_FREE_DB, BTA_FTC_CLOSE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_CI_WRITE_EVT */ {BTA_FTC_CLOSE_COMPLETE,BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_CI_READ_EVT */ {BTA_FTC_CLOSE_COMPLETE,BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_CI_OPEN_EVT */ {BTA_FTC_CLOSE_COMPLETE,BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_OBX_CONN_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_ABORT_RSP_EVT */ {BTA_FTC_OBX_ABORT_RSP, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_TOUT_EVT */ {BTA_FTC_OBX_TIMEOUT, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_PASSWORD_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_CLOSE_EVT */ {BTA_FTC_CLOSE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_PUT_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_GET_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_SETPATH_RSP_EVT */ {BTA_FTC_IGNORE_OBX, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_OBX_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_CLOSING_ST},
-/* BTA_FTC_CLOSE_CMPL_EVT */ {BTA_FTC_CLOSE_COMPLETE,BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_DISABLE_CMPL_EVT */ {BTA_FTC_IGNORE, BTA_FTC_IGNORE, BTA_FTC_IDLE_ST},
-/* BTA_FTC_RSP_TOUT_EVT */ {BTA_FTC_RSP_TIMEOUT, BTA_FTC_CLOSE_COMPLETE, BTA_FTC_IDLE_ST}
-};
-
-/* type for state table */
-typedef const UINT8 (*tBTA_FTC_ST_TBL)[BTA_FTC_NUM_COLS];
-
-/* state table */
-const tBTA_FTC_ST_TBL bta_ftc_st_tbl[] =
-{
- bta_ftc_st_idle,
- bta_ftc_st_w4_conn,
- bta_ftc_st_connected,
- bta_ftc_st_suspending,
- bta_ftc_st_closing
-};
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* FTC control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-tBTA_FTC_CB bta_ftc_cb;
-#endif
-
-#if BTA_FTC_DEBUG == TRUE
-static char *ftc_evt_code(tBTA_FTC_INT_EVT evt_code);
-static char *ftc_state_code(tBTA_FTC_STATE state_code);
-#endif
-
-/*******************************************************************************
-**
-** Function bta_ftc_sm_execute
-**
-** Description State machine event handling function for FTC
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_sm_execute(tBTA_FTC_CB *p_cb, UINT16 event, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_ST_TBL state_table;
- UINT8 action;
- int i;
-#if BTA_FTC_DEBUG == TRUE
- tBTA_FTC_STATE in_state = p_cb->state;
- UINT16 in_event = event;
- APPL_TRACE_DEBUG4("bta_ftc_sm_execute: State 0x%02x [%s], Event 0x%x[%s]", in_state,
- ftc_state_code(in_state),
- in_event,
- ftc_evt_code(in_event));
-#endif
-
- /* look up the state table for the current state */
- state_table = bta_ftc_st_tbl[p_cb->state];
-
- event &= 0x00FF;
-
- /* set next state */
- p_cb->state = state_table[event][BTA_FTC_NEXT_STATE];
-
- /* execute action functions */
- for (i = 0; i < BTA_FTC_ACTIONS; i++)
- {
- if ((action = state_table[event][i]) != BTA_FTC_IGNORE)
- {
- (*bta_ftc_action[action])(p_cb, p_data);
- }
- else
- {
- break;
- }
- }
-
-#if BTA_FTC_DEBUG == TRUE
- if (in_state != p_cb->state)
- {
- APPL_TRACE_DEBUG3("FTC State Change: [%s] -> [%s] after Event [%s]",
- ftc_state_code(in_state),
- ftc_state_code(p_cb->state),
- ftc_evt_code(in_event));
- }
-#endif
-}
-
-/*****************************************************************************
-**
-** Function: bta_ftc_sdp_register()
-**
-** Purpose: Registers the File Transfer service with SDP
-**
-** Parameters:
-**
-**
-** Returns: void
-**
-*****************************************************************************/
-static void bta_ftc_sdp_register (tBTA_FTC_CB *p_cb)
-{
- UINT16 pbap_service = UUID_SERVCLASS_PBAP_PCE;
- UINT16 browse = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
- BOOLEAN status = FALSE;
-
- if ((p_cb->sdp_handle = SDP_CreateRecord()) == 0)
- {
- APPL_TRACE_WARNING0("FTC SDP: Unable to register PBAP PCE Service");
- return;
- }
-
- /* add service class */
- if (SDP_AddServiceClassIdList(p_cb->sdp_handle, 1, &pbap_service))
- {
- status = TRUE; /* All mandatory fields were successful */
-
- /* optional: if name is not "", add a name entry */
- if (p_bta_ft_cfg->pce_name && p_bta_ft_cfg->pce_name[0] != '\0')
- SDP_AddAttribute(p_cb->sdp_handle,
- (UINT16)ATTR_ID_SERVICE_NAME,
- (UINT8)TEXT_STR_DESC_TYPE,
- (UINT32)(strlen(p_bta_ft_cfg->pce_name) + 1),
- (UINT8 *)p_bta_ft_cfg->pce_name);
-
- /* Add in the Bluetooth Profile Descriptor List */
- SDP_AddProfileDescriptorList(p_cb->sdp_handle,
- UUID_SERVCLASS_PBAP_PCE,
- BTA_FTC_DEFAULT_VERSION);
- } /* end of setting mandatory service class */
-
- /* Make the service browseable */
- SDP_AddUuidSequence (p_cb->sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse);
-
- if (!status)
- {
- SDP_DeleteRecord(p_cb->sdp_handle);
- APPL_TRACE_ERROR0("bta_ftc_sdp_register FAILED");
- p_cb->sdp_handle = 0;
- }
- else
- {
- bta_sys_add_uuid( pbap_service ); /* UUID_SERVCLASS_PBAP_PCE */
- APPL_TRACE_DEBUG1("FTC: SDP Registered (handle 0x%08x)", p_cb->sdp_handle);
- }
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_api_enable
-**
-** Description Handle an api enable event. This function enables the FT
-** Client by opening an Obex/Rfcomm channel with a peer device.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_ftc_api_enable(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- if (!p_cb->is_enabled)
- {
- /* initialize control block */
- memset(p_cb, 0, sizeof(tBTA_FTC_CB));
-
- /* store parameters */
- p_cb->p_cback = p_data->api_enable.p_cback;
- p_cb->app_id = p_data->api_enable.app_id;
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
- p_cb->bic_handle = BTA_BIC_INVALID_HANDLE;
-#endif
- p_cb->fd = BTA_FS_INVALID_FD;
- p_cb->is_enabled = TRUE;
-
- /* create SDP record for PCE */
- if(p_bta_ft_cfg->pce_features)
- bta_ftc_sdp_register(p_cb);
- }
-
- /* callback with enable event */
- (*p_cb->p_cback)(BTA_FTC_ENABLE_EVT, 0);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_hdl_event
-**
-** Description File transfer server main event handling function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BOOLEAN bta_ftc_hdl_event(BT_HDR *p_msg)
-{
- tBTA_FTC_CB *p_cb = &bta_ftc_cb;
-#if BTA_FTC_DEBUG == TRUE
- tBTA_FTC_STATE in_state = p_cb->state;
-#endif
-
- switch (p_msg->event)
- {
- case BTA_FTC_API_ENABLE_EVT:
-#if BTA_FTC_DEBUG == TRUE
- APPL_TRACE_DEBUG3("FTC Event Handler: State 0x%02x [%s], Event [%s]", in_state,
- ftc_state_code(in_state),
- ftc_evt_code(p_msg->event));
-#endif
- bta_ftc_api_enable(p_cb, (tBTA_FTC_DATA *) p_msg);
-#if BTA_FTC_DEBUG == TRUE
- if (in_state != p_cb->state)
- {
- APPL_TRACE_DEBUG3("FTC State Change: [%s] -> [%s] after Event [%s]",
- ftc_state_code(in_state),
- ftc_state_code(p_cb->state),
- ftc_evt_code(p_msg->event));
- }
-#endif
- break;
-
- default:
- if (p_cb->is_enabled)
- {
- bta_ftc_sm_execute(p_cb, p_msg->event, (tBTA_FTC_DATA *) p_msg);
-
- if ( p_cb->state == BTA_FTC_CONN_ST )
- {
- if (( p_cb->pm_state == BTA_FTC_PM_IDLE )
- &&( p_cb->obx_oper != FTC_OP_NONE ))
- {
- /* inform power manager */
- APPL_TRACE_DEBUG0("BTA FTC informs DM/PM busy state");
- bta_sys_busy( BTA_ID_FTC, p_cb->app_id, p_cb->bd_addr );
- p_cb->pm_state = BTA_FTC_PM_BUSY;
- }
- else if (( p_cb->pm_state == BTA_FTC_PM_BUSY )
- &&( p_cb->obx_oper == FTC_OP_NONE ))
- {
- /* inform power manager */
- APPL_TRACE_DEBUG0("BTA FTC informs DM/PM idle state");
- bta_sys_idle( BTA_ID_FTC ,p_cb->app_id, p_cb->bd_addr);
- p_cb->pm_state = BTA_FTC_PM_IDLE;
- }
- }
- else if ( p_cb->state == BTA_FTC_IDLE_ST )
- {
- /* initialize power management state */
- p_cb->pm_state = BTA_FTC_PM_BUSY;
- }
- }
- break;
- }
-
-
- return (TRUE);
-}
-
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if BTA_FTC_DEBUG == TRUE
-
-/*******************************************************************************
-**
-** Function ftc_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *ftc_evt_code(tBTA_FTC_INT_EVT evt_code)
-{
- switch(evt_code)
- {
- case BTA_FTC_API_DISABLE_EVT:
- return "BTA_FTC_API_DISABLE_EVT";
- case BTA_FTC_API_OPEN_EVT:
- return "BTA_FTC_API_OPEN_EVT";
- case BTA_FTC_API_CLOSE_EVT:
- return "BTA_FTC_API_CLOSE_EVT";
- case BTA_FTC_API_PUTFILE_EVT:
- return "BTA_FTC_API_PUTFILE_EVT";
- case BTA_FTC_API_GETFILE_EVT:
- return "BTA_FTC_API_GETFILE_EVT";
- case BTA_FTC_API_LISTDIR_EVT:
- return "BTA_FTC_API_LISTDIR_EVT";
- case BTA_FTC_API_CHDIR_EVT:
- return "BTA_FTC_API_CHDIR_EVT";
- case BTA_FTC_API_MKDIR_EVT:
- return "BTA_FTC_API_MKDIR_EVT";
- case BTA_FTC_API_REMOVE_EVT:
- return "BTA_FTC_API_REMOVE_EVT";
- case BTA_FTC_API_AUTHRSP_EVT:
- return "BTA_FTC_API_AUTHRSP_EVT";
- case BTA_FTC_API_ABORT_EVT:
- return "BTA_FTC_API_ABORT_EVT";
- case BTA_FTC_API_ACTION_EVT:
- return "BTA_FTC_API_ACTION_EVT";
- case BTA_FTC_OBX_ACTION_RSP_EVT:
- return "BTA_FTC_OBX_ACTION_RSP_EVT";
- case BTA_FTC_CI_SESSION_EVT:
- return "BTA_FTC_CI_SESSION_EVT";
- case BTA_FTC_SDP_OK_EVT:
- return "BTA_FTC_SDP_OK_EVT";
- case BTA_FTC_SDP_FAIL_EVT:
- return "BTA_FTC_SDP_FAIL_EVT";
- case BTA_FTC_SDP_NEXT_EVT:
- return "BTA_FTC_SDP_NEXT_EVT";
- case BTA_FTC_CI_WRITE_EVT:
- return "BTA_FTC_CI_WRITE_EVT";
- case BTA_FTC_CI_READ_EVT:
- return "BTA_FTC_CI_READ_EVT";
- case BTA_FTC_CI_OPEN_EVT:
- return "BTA_FTC_CI_OPEN_EVT";
- case BTA_FTC_OBX_CONN_RSP_EVT:
- return "BTA_FTC_OBX_CONN_RSP_EVT";
- case BTA_FTC_OBX_ABORT_RSP_EVT:
- return "BTA_FTC_OBX_ABORT_RSP_EVT";
- case BTA_FTC_OBX_TOUT_EVT:
- return "BTA_FTC_OBX_TOUT_EVT";
- case BTA_FTC_OBX_PASSWORD_EVT:
- return "BTA_FTC_OBX_PASSWORD_EVT";
- case BTA_FTC_OBX_CLOSE_EVT:
- return "BTA_FTC_OBX_CLOSE_EVT";
- case BTA_FTC_OBX_PUT_RSP_EVT:
- return "BTA_FTC_OBX_PUT_RSP_EVT";
- case BTA_FTC_CLOSE_CMPL_EVT:
- return "BTA_FTC_CLOSE_CMPL_EVT";
- case BTA_FTC_OBX_GET_RSP_EVT:
- return "BTA_FTC_OBX_GET_RSP_EVT";
- case BTA_FTC_OBX_SETPATH_RSP_EVT:
- return "BTA_FTC_OBX_SETPATH_RSP_EVT";
- case BTA_FTC_OBX_CMPL_EVT:
- return "BTA_FTC_OBX_CMPL_EVT";
- case BTA_FTC_DISABLE_CMPL_EVT:
- return "BTA_FTC_DISABLE_CMPL_EVT";
- case BTA_FTC_RSP_TOUT_EVT:
- return "BTA_FTC_RSP_TOUT_EVT";
- case BTA_FTC_API_ENABLE_EVT:
- return "BTA_FTC_API_ENABLE_EVT";
- default:
- return "unknown FTC event code";
- }
-}
-
-/*******************************************************************************
-**
-** Function ftc_state_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *ftc_state_code(tBTA_FTC_STATE state_code)
-{
- switch(state_code)
- {
- case BTA_FTC_IDLE_ST:
- return "BTA_FTC_IDLE_ST";
- case BTA_FTC_W4_CONN_ST:
- return "BTA_FTC_W4_CONN_ST";
- case BTA_FTC_CONN_ST:
- return "BTA_FTC_CONN_ST";
- case BTA_FTC_SUSPENDING_ST:
- return "BTA_FTC_SUSPENDING_ST";
- case BTA_FTC_CLOSING_ST:
- return "BTA_FTC_CLOSING_ST";
- default:
- return "unknown FTC state code";
- }
-}
-
-#endif /* Debug Functions */
-#endif /* BTA_FT_INCLUDED */
diff --git a/bta/ft/bta_ftc_utils.c b/bta/ft/bta_ftc_utils.c
deleted file mode 100644
index 8468d5f..0000000
--- a/bta/ft/bta_ftc_utils.c
+++ /dev/null
@@ -1,608 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ftc_utils.c
-**
-** Description: This file implements object store functions for the
-** file transfer server.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-
-#if defined(BTA_FT_INCLUDED) && (BTA_FT_INCLUDED == TRUE)
-
-#include <stdio.h>
-#include <string.h>
-#include "bta_ftc_int.h"
-#include "bta_fs_api.h"
-#include "bta_fs_co.h"
-#include "gki.h"
-#include "utl.h"
-
-/*******************************************************************************
-** Constants
-*******************************************************************************/
-
-/*******************************************************************************
-** Local Function Prototypes
-*******************************************************************************/
-
-/*******************************************************************************
-* Macros for FTC
-*******************************************************************************/
-#define BTA_FTC_XML_EOL "\n"
-#define BTA_FTC_FOLDER_LISTING_START ( "<?xml version=\"1.0\"?>\n" \
- "<!DOCTYPE folder-listing SYSTEM \"obex-folder-listing.dtd\">\n" \
- "<folder-listing version=\"1.0\">\n" )
-
-#define BTA_FTC_FOLDER_LISTING_END ( "</folder-listing>" )
-
-#define BTA_FTC_FILE_ELEM "file"
-#define BTA_FTC_FOLDER_ELEM "folder"
-#define BTA_FTC_PARENT_FOLDER_ELEM "parent-folder"
-#define BTA_FTC_NAME_ATTR "name"
-#define BTA_FTC_SIZE_ATTR "size"
-#define BTA_FTC_TYPE_ATTR "type"
-#define BTA_FTC_MODIFIED_ATTR "modified"
-#define BTA_FTC_CREATED_ATTR "created"
-#define BTA_FTC_ACCESSED_ATTR "accessed"
-#define BTA_FTC_USER_PERM_ATTR "user-perm"
-#define BTA_FTC_GROUP_PERM_ATTR "group-perm"
-#define BTA_FTC_OTHER_PERM_ATTR "other-perm"
-#define BTA_FTC_GROUP_ATTR "group"
-#define BTA_FTC_OWNER_ATTR "owner"
-#define BTA_FTC_LANG_ATTR "xml:lang"
-
-/*******************************************************************************
-** Local Function
-*******************************************************************************/
-/*******************************************************************************
-**
-** Function bta_ftc_send_abort_req
-**
-** Description Send an abort request.
-**
-** Parameters p_cb - Pointer to the FTC control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_send_abort_req(tBTA_FTC_CB *p_cb)
-{
- if (FTC_ABORT_REQ_NOT_SENT == p_cb->aborting)
- {
- p_cb->aborting = FTC_ABORT_REQ_SENT;
- OBX_AbortReq(p_cb->obx_handle, (BT_HDR *)NULL);
-
- /* Start abort response timer */
- p_cb->timer_oper = FTC_TIMER_OP_ABORT;
- bta_sys_start_timer(&p_cb->rsp_timer, BTA_FTC_RSP_TOUT_EVT,
- p_bta_ft_cfg->abort_tout);
- }
-}
-/*******************************************************************************
-**
-** Function bta_ftc_proc_pbap_param
-**
-** Description read PBAP app parameter header.
-**
-** Parameters
-**
-** Returns
-**
-*******************************************************************************/
-tBTA_FTC_PB_PARAM * bta_ftc_proc_pbap_param(tBTA_FTC_PB_PARAM *p_param, BT_HDR *p_pkt)
-{
- UINT8 *p_data = NULL, aph;
- UINT16 data_len = 0;
- int left, len;
- if(OBX_ReadByteStrHdr(p_pkt, OBX_HI_APP_PARMS, &p_data, &data_len, 0))
- {
- memset(p_param, 0, sizeof(tBTA_FTC_PB_PARAM));
- left = data_len;
- while(left > 0)
- {
- aph = *p_data++;
- len = *p_data++;
- left -= len;
- left -= 2;
- switch(aph)
- {
- case BTA_FTC_APH_PB_SIZE:
- BE_STREAM_TO_UINT16(p_param->phone_book_size, p_data);
- p_param->pbs_exist = TRUE;
- break;
- case BTA_FTC_APH_NEW_MISSED_CALL:
- p_param->new_missed_calls = *p_data++;
- p_param->nmc_exist = TRUE;
- break;
- default:
- p_data += len;
- }
- }
- }
- else
- p_param = NULL;
- return p_param;
-}
-
-/*******************************************************************************
-* Exported Functions
-*******************************************************************************/
-/*******************************************************************************
-**
-** Function bta_ftc_send_get_req
-**
-** Description Processes a Get File Operation.
-**
-** Parameters p_cb - Pointer to the FTC control block
-**
-** Returns (UINT8) OBX response code
-**
-*******************************************************************************/
-UINT8 bta_ftc_send_get_req(tBTA_FTC_CB *p_cb)
-{
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
- UINT8 rsp_code = OBX_RSP_FAILED;
-
- /* Do not start another request if currently aborting */
- if (!p_cb->aborting)
- {
- /* OBX header are added in bta_ftc_init_getfile */
- if ((OBX_GetReq(p_cb->obx_handle, TRUE, p_obx->p_pkt)) == OBX_SUCCESS)
- {
- p_cb->req_pending = TRUE;
- rsp_code = OBX_RSP_OK;
- p_obx->p_pkt = NULL;
- }
- }
- else
- {
- bta_ftc_send_abort_req(p_cb);
- }
-
- return (rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_proc_get_rsp
-**
-** Description Processes a Get File response packet.
-** Initiates a file write if no errors.
-**
-** Parameters
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_proc_get_rsp(tBTA_FTC_CB *p_cb, tBTA_FTC_DATA *p_data)
-{
- tBTA_FTC_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
- UINT16 body_size;
- BOOLEAN final;
- BOOLEAN done = TRUE;
- BOOLEAN send_request = TRUE;
- UINT8 num_hdrs;
- tBTA_FTC data;
-
- do
- {
- if (p_evt->rsp_code == OBX_RSP_OK || p_evt->rsp_code == OBX_RSP_CONTINUE)
- {
- /* Only continue if not aborting */
- if (p_cb->aborting)
- {
- /* Aborting: done with current packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-
- /* If aborting, and this response is not last packet send abort */
- if(p_evt->rsp_code == OBX_RSP_CONTINUE)
- {
- bta_ftc_send_abort_req(p_cb);
- return;
- }
- else /* Last packet - abort and remove file (p_evt->rsp_code == OBX_RSP_OK) */
- {
- p_evt->rsp_code = (!p_cb->int_abort) ? OBX_RSP_GONE : OBX_RSP_INTRNL_SRVR_ERR;
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CMPL_EVT, p_data);
- return;
- }
- }
-
- p_obx->final_pkt = (p_evt->rsp_code == OBX_RSP_OK) ? TRUE : FALSE;
-
- /* If length header exists, save the file length */
- if (p_cb->first_req_pkt == TRUE)
- {
- p_cb->first_req_pkt = FALSE;
-
- /* if the obj_type is */
- if(p_cb->obj_type == BTA_FTC_GET_PB)
- {
- bta_ftc_proc_pbap_param(&data.pb, p_obx->p_pkt);
- bta_ftc_cb.p_cback(BTA_FTC_PHONEBOOK_EVT, &data);
- if (p_cb->fd == BTA_FS_INVALID_FD)
- {
- /* if the obj_type is get pb && the file id not open,
- * must be getting the phonebook size only
- * - end of transaction */
- break;
- }
- }
- if (!OBX_ReadLengthHdr(p_evt->p_pkt, &p_cb->file_size))
- p_cb->file_size = BTA_FS_LEN_UNKNOWN;
- }
-
- /* Read the body header from the obx packet */
- num_hdrs = OBX_ReadBodyHdr(p_evt->p_pkt, &p_obx->p_start, &body_size,
- &final);
- /* process body header */
- if (num_hdrs == 1)
- {
- if (body_size)
- {
- /* Data to be written */
- p_obx->p_pkt = p_evt->p_pkt;
- p_obx->offset = body_size; /* Save write size for comparison */
- p_cb->cout_active = TRUE;
- bta_fs_co_write(p_cb->fd, p_obx->p_start, body_size,
- BTA_FTC_CI_WRITE_EVT, 0, p_cb->app_id);
- done = FALSE;
- send_request = FALSE;
- }
- /* If body header is zero in length but not final, request next packet */
- else if (!final)
- {
- done = FALSE;
- }
- }
- else if (num_hdrs > 1) /* Cannot handle more than a single body header */
- {
- p_evt->rsp_code = OBX_RSP_BAD_REQUEST;
- }
- /* Empty Body; send next request or finished */
- else if (!p_obx->final_pkt)
- done = FALSE;
- }
- } while (0);
-
- if (done)
- {
- bta_ftc_sm_execute(p_cb, BTA_FTC_OBX_CMPL_EVT, p_data);
- utl_freebuf((void**)&p_evt->p_pkt);
- }
- else if (send_request)
- {
- /* Free current packet and send a new request */
- utl_freebuf((void**)&p_evt->p_pkt);
- bta_ftc_send_get_req(p_cb);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_cont_put_file
-**
-** Description Continues a Put File Operation.
-** Builds a new OBX packet, and initiates a read operation.
-**
-** Parameters p_cb - pointer to the client's control block.
-** first_pkt - TRUE if initial PUT request to server.
-**
-**
-** Returns UINT8 OBX response code
-**
-*******************************************************************************/
-UINT8 bta_ftc_cont_put_file(tBTA_FTC_CB *p_cb, BOOLEAN first_pkt)
-{
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
- UINT8 rsp_code;
- char *p_ch;
-
- /* Do not start another request if currently aborting */
- if (p_cb->aborting)
- {
- bta_ftc_send_abort_req(p_cb);
- return (OBX_RSP_OK);
- }
-
- rsp_code = OBX_RSP_FAILED;
-
- if ((p_obx->p_pkt = OBX_HdrInit(p_cb->obx_handle, p_cb->peer_mtu)) != NULL)
- {
- p_obx->offset = 0;
-
- /* Add length header if it exists; No body in first packet */
- if (first_pkt)
- {
- /* Add the Name Header to the request */
- /* Find the beginning of the name (excluding the path) */
- p_ch = strrchr(p_cb->p_name, (int) p_bta_fs_cfg->path_separator);
- if (p_ch && p_ch[1] != '\0')
- {
- OBX_AddUtf8NameHdr(p_obx->p_pkt, (UINT8 *)&p_ch[1]);
-
- /* Add the length header if known */
- if (p_cb->file_size != BTA_FS_LEN_UNKNOWN)
- {
- OBX_AddLengthHdr(p_obx->p_pkt, p_cb->file_size);
-
- }
-
- OBX_PutReq(p_cb->obx_handle, FALSE, p_obx->p_pkt);
- p_cb->req_pending = TRUE;
- p_obx->p_pkt = NULL;
- rsp_code = OBX_RSP_OK;
- }
- }
- else /* A continuation packet so read file data */
- {
- /* Add the start of the Body Header */
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
-
- /* Read in the first packet's worth of data */
- p_cb->cout_active = TRUE;
- bta_fs_co_read(p_cb->fd, &p_obx->p_start[p_obx->offset],
- p_obx->bytes_left, BTA_FTC_CI_READ_EVT, 0, p_cb->app_id);
- rsp_code = OBX_RSP_OK;
- }
- }
-
- return (rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_proc_list_data
-**
-** Description Processes responses to directory listing requests
-** Loops through returned data generating application
-** listing data events. If needed, issues a new request
-** to the server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_proc_list_data(tBTA_FTC_CB *p_cb, tBTA_FTC_OBX_EVT *p_evt)
-{
- tBTA_FTC app_evt;
- tBTA_FTC_PB_PARAM param;
- BOOLEAN is_ok = FALSE;
- BOOLEAN first_req_pkt = p_cb->first_req_pkt;
-
- app_evt.list.status = bta_ftc_convert_obx_to_ftc_status(p_evt->rsp_code);
-
- if (p_evt->rsp_code == OBX_RSP_OK || p_evt->rsp_code == OBX_RSP_CONTINUE)
- {
- app_evt.list.p_param = NULL;
- if (p_cb->first_req_pkt == TRUE)
- {
- p_cb->first_req_pkt = FALSE;
- if(p_cb->sdp_service == UUID_SERVCLASS_PBAP_PSE)
- app_evt.list.p_param = bta_ftc_proc_pbap_param(&param, p_evt->p_pkt);
- }
- APPL_TRACE_EVENT1("first_req_pkt: %d ", first_req_pkt);
-
- if (OBX_ReadBodyHdr(p_evt->p_pkt, &app_evt.list.data, &app_evt.list.len,
- &app_evt.list.final))
- {
- /* len > 0 or is final packet */
- if(app_evt.list.len || app_evt.list.final)
-
- {
- bta_ftc_cb.p_cback(BTA_FTC_LIST_EVT, &app_evt);
- }
- is_ok = TRUE;
- }
- else if(first_req_pkt && p_evt->rsp_code == OBX_RSP_CONTINUE)
- {
- /* no body header is OK, if this is the first packet and is continue response */
- is_ok = TRUE;
- }
-
- if(is_ok)
- {
- utl_freebuf((void**)&p_evt->p_pkt);
- /* Initiate another request if not finished */
- if (p_evt->rsp_code == OBX_RSP_CONTINUE)
- {
- if (p_cb->aborting)
- bta_ftc_send_abort_req(p_cb);
- else
- bta_ftc_get_listing(p_cb, NULL, NULL);
- }
- else
- p_cb->obx_oper = FTC_OP_NONE; /* Finished with directory listing */
- }
- else
- {
- /* Missing body header & not the first packet */
- bta_ftc_listing_err(&p_evt->p_pkt, OBX_RSP_NO_CONTENT);
- }
- }
- else /* Issue an error list entry */
- bta_ftc_listing_err(&p_evt->p_pkt, app_evt.list.status);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_get_listing
-**
-** Description Initiates or Continues a GET Listing operation
-** on the server's current directory.
-**
-** Parameters p_cb - pointer to the client's control block.
-** first_pkt - TRUE if initial GET request to server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_get_listing(tBTA_FTC_CB *p_cb, char *p_name, tBTA_FTC_LST_PARAM *p_param)
-{
- tBTA_FTC_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FTC_STATUS status = BTA_FTC_FAIL;
- BOOLEAN is_ok = TRUE;
- UINT8 *p, *p2, *p_start;
- UINT16 len = 0;
-
- if ((p_obx->p_pkt = OBX_HdrInit(p_cb->obx_handle, OBX_CMD_POOL_SIZE)) != NULL)
- {
- if (p_name)
- {
- /* first packet */
- p_cb->first_req_pkt = TRUE;
- /* Add the Type Header */
- p = (UINT8 *) BTA_FTC_FOLDER_LISTING_TYPE;
- if(p_cb->sdp_service == UUID_SERVCLASS_PBAP_PSE)
- p = (UINT8 *) BTA_FTC_PULL_VCARD_LISTING_TYPE;
-
- is_ok = OBX_AddTypeHdr(p_obx->p_pkt, (char *)p);
-
- if(strcmp(p_name, ".") == 0 || p_name[0] == 0)
- {
- p_name = NULL;
- }
-
- if (p_name)
- {
- is_ok = OBX_AddUtf8NameHdr(p_obx->p_pkt, (unsigned char *) p_name);
- }
-
- if(p_param && p_cb->sdp_service == UUID_SERVCLASS_PBAP_PSE)
- {
- /* add app params for PCE */
- p_start = OBX_AddByteStrStart(p_obx->p_pkt, &len);
- p = p_start;
- if(p_param->order < BTA_FTC_ORDER_MAX)
- {
- *p++ = BTA_FTC_APH_ORDER;
- *p++ = 1;
- *p++ = p_param->order;
- }
- if(p_param->p_value)
- {
- *p++ = BTA_FTC_APH_SEARCH_VALUE;
- *p = strlen(p_param->p_value);
- BCM_STRNCPY_S((char *) (p+1), strlen(p_param->p_value), p_param->p_value, *p);
- p2 = p + 1 + *p;
- p = p2;
- }
- if(p_param->attribute < BTA_FTC_ATTR_MAX)
- {
- *p++ = BTA_FTC_APH_SEARCH_ATTR;
- *p++ = 1;
- *p++ = p_param->attribute;
- }
- if(p_param->max_list_count != 0xFFFF)
- {
- *p++ = BTA_FTC_APH_MAX_LIST_COUNT;
- *p++ = 2;
- UINT16_TO_BE_STREAM(p, p_param->max_list_count);
- }
- if(p_param->list_start_offset)
- {
- *p++ = BTA_FTC_APH_LIST_STOFF;
- *p++ = 2;
- UINT16_TO_BE_STREAM(p, p_param->list_start_offset);
- }
-
- /* If any of the app param header is added */
- if(p != p_start)
- {
- OBX_AddByteStrHdr(p_obx->p_pkt, OBX_HI_APP_PARMS, NULL, (UINT16)(p - p_start));
- }
- } /* if p_param: PBAP PCE need to keep AppParam in the first Get response */
- }
-
- if (is_ok)
- {
- if ((OBX_GetReq(p_cb->obx_handle, TRUE, p_obx->p_pkt)) == OBX_SUCCESS)
- {
- p_cb->req_pending = TRUE;
- p_obx->p_pkt = NULL; /* OBX will free the memory */
- p_cb->obx_oper = FTC_OP_GET_LIST;
- status = BTA_FTC_OK;
- }
- }
- }
-
- if (status != BTA_FTC_OK) /* Send an error response to the application */
- bta_ftc_listing_err(&p_obx->p_pkt, status);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_listing_err
-**
-** Description Send a directory listing error event to the application
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ftc_listing_err(BT_HDR **p_pkt, tBTA_FTC_STATUS status)
-{
- tBTA_FTC err_rsp;
-
- if (bta_ftc_cb.obx_oper == FTC_OP_GET_LIST)
- bta_ftc_cb.obx_oper = FTC_OP_NONE;
- utl_freebuf((void**)p_pkt);
-
- err_rsp.list.len = 0;
- err_rsp.list.status = status;
- err_rsp.list.final = TRUE;
- err_rsp.list.data = NULL;
- bta_ftc_cb.p_cback(BTA_FTC_LIST_EVT, &err_rsp);
-}
-
-/*******************************************************************************
-**
-** Function bta_ftc_convert_obx_to_ftc_status
-**
-** Description Convert OBX response code into BTA FTC status code.
-**
-** Returns void
-**
-*******************************************************************************/
-tBTA_FTC_STATUS bta_ftc_convert_obx_to_ftc_status(tOBX_STATUS obx_status)
-{
- tBTA_FTC_STATUS status;
-
- switch (obx_status)
- {
- case OBX_RSP_OK:
- case OBX_RSP_CONTINUE:
- status = BTA_FTC_OK;
- break;
- case OBX_RSP_UNAUTHORIZED:
- status = BTA_FTC_NO_PERMISSION;
- break;
- case OBX_RSP_NOT_FOUND:
- status = BTA_FTC_NOT_FOUND;
- break;
- case OBX_RSP_REQ_ENT_2_LARGE:
- case OBX_RSP_DATABASE_FULL:
- status = BTA_FTC_FULL;
- break;
- case OBX_RSP_GONE:
- status = BTA_FTC_ABORTED;
- break;
- case OBX_RSP_SERVICE_UNAVL:
- status = BTA_FTC_SERVICE_UNAVL;
- break;
- default:
- status = BTA_FTC_FAIL;
- }
-
- return (status);
-}
-#endif /* BTA_FT_INCLUDED */
diff --git a/bta/ft/bta_fts_act.c b/bta/ft/bta_fts_act.c
deleted file mode 100644
index 52ba9e4..0000000
--- a/bta/ft/bta_fts_act.c
+++ /dev/null
@@ -1,1523 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_fts_act.c
-**
-** Description: This file contains the file transfer action
-** functions for the state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_FT_INCLUDED) && (BTA_FT_INCLUDED == TRUE)
-
-#include <stdio.h>
-#include <string.h>
-#include "gki.h"
-#include "bta_sys.h"
-#include "obx_api.h"
-#include "bta_ft_api.h"
-#include "bta_fts_int.h"
-#include "bta_fs_api.h"
-#include "bta_fs_co.h"
-#include "bta_fs_ci.h"
-#include "btm_api.h"
-#include "utl.h"
-#include "bd.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-#define FLAGS_ARE_MASK (OBX_SPF_BACKUP | OBX_SPF_NO_CREATE)
-#define FLAGS_ARE_ILLEGAL 0x1 /* 'Backup and Create flag combo is BAD */
-
-/*****************************************************************************
-** Local Function prototypes
-*****************************************************************************/
-#if BTA_FTS_DEBUG == TRUE
-static char *fts_obx_evt_code(tOBX_EVENT evt_code);
-#endif
-
-/*****************************************************************************
-** Action Functions
-*****************************************************************************/
-/*******************************************************************************
-**
-** Function bta_fts_api_disable
-**
-** Description Stop FTP server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_api_disable(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
-
- /* If callout is active, wait till finished before shutting down */
- if (p_cb->cout_active)
- p_cb->disabling = TRUE;
- else
- bta_fts_sm_execute(p_cb, BTA_FTS_DISABLE_CMPL_EVT, p_data);
-
- bta_sys_remove_uuid(UUID_SERVCLASS_OBEX_FILE_TRANSFER);
- BTM_SecClrService(BTM_SEC_SERVICE_OBEX_FTP);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_api_authrsp
-**
-** Description Pass the response to an authentication request back to the
-** client.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_api_authrsp(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- UINT8 *p_pwd = NULL;
- UINT8 *p_userid = NULL;
-
- if (p_data->auth_rsp.key_len > 0)
- p_pwd = (UINT8 *)p_data->auth_rsp.key;
- if (p_data->auth_rsp.userid_len > 0)
- p_userid = (UINT8 *)p_data->auth_rsp.userid;
-
- OBX_Password(p_cb->obx_handle, p_pwd, p_data->auth_rsp.key_len,
- p_userid, p_data->auth_rsp.userid_len);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_api_accessrsp
-**
-** Description Process the access API event.
-** If permission had been granted, continue the PUT operation,
-** otherwise stop the operation.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_api_accessrsp(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- UINT8 rsp_code = OBX_RSP_OK;
- tBTA_FS_CO_STATUS status = BTA_FS_CO_EACCES;
- tBTA_FT_ACCESS access = p_data->access_rsp.flag;
- tBTA_FT_OPER old_acc_active = p_cb->acc_active;
- tBTA_FTS_OBX_RSP *p_rsp = NULL;
- tBTA_FTS_OBJECT objevt;
-
- APPL_TRACE_DEBUG3("bta_fts_api_accessrsp op:%d/%d access:%d", old_acc_active, p_data->access_rsp.oper, access);
- if(p_cb->acc_active != p_data->access_rsp.oper )
- {
- APPL_TRACE_WARNING2("FTS ACCRSP: not match active:%d, rsp:%d",
- p_cb->acc_active, p_data->access_rsp.oper);
- return;
- }
-
- p_cb->acc_active = 0;
- /* Process the currently active access response */
- switch (old_acc_active)
- {
- case BTA_FT_OPER_PUT:
- if (access == BTA_FT_ACCESS_ALLOW)
- {
- /* Save the file name with path prepended */
- BCM_STRNCPY_S(p_cb->p_path, p_bta_fs_cfg->max_file_len+1, p_data->access_rsp.p_name, p_bta_fs_cfg->max_file_len);
- p_cb->p_path[p_bta_fs_cfg->max_file_len] = '\0';
-
- p_cb->cout_active = TRUE;
- bta_fs_co_open (p_cb->p_path,
- (BTA_FS_O_CREAT | BTA_FS_O_TRUNC | BTA_FS_O_RDWR),
- p_cb->file_length, BTA_FTS_CI_OPEN_EVT,
- p_cb->app_id);
- }
- else /* Access denied */
- {
- bta_fts_clean_getput(p_cb, TRUE);
- OBX_PutRsp(p_cb->obx_handle, OBX_RSP_UNAUTHORIZED, (BT_HDR *)NULL);
- }
- break;
-
- case BTA_FT_OPER_GET:
- if (access == BTA_FT_ACCESS_ALLOW)
- {
- p_cb->cout_active = TRUE;
- bta_fs_co_open (p_cb->p_path, BTA_FS_O_RDONLY, 0,
- BTA_FTS_CI_OPEN_EVT, p_cb->app_id);
- }
- else /* Denied */
- bta_fts_get_file_rsp(OBX_RSP_UNAUTHORIZED, 0);
- break;
-
- case BTA_FT_OPER_DEL_FILE: /* Request is a DELETE file */
- p_rsp = OBX_PutRsp;
- if (access == BTA_FT_ACCESS_ALLOW)
- {
- objevt.p_name = p_cb->p_path;
- objevt.status = BTA_FTS_OK;
- if ((status = bta_fs_co_unlink(p_cb->p_path, p_cb->app_id)) != BTA_FS_CO_OK)
- {
- objevt.status = BTA_FTS_FAIL;
- }
-
- /* Notify application of delete attempt */
- p_cb->p_cback(BTA_FTS_DEL_CMPL_EVT, (tBTA_FTS *)&objevt);
- }
- break;
-
- case BTA_FT_OPER_DEL_DIR: /* Request is a DELETE folder */
- p_rsp = OBX_PutRsp;
- if (access == BTA_FT_ACCESS_ALLOW)
- {
- objevt.p_name = p_cb->p_path;
- objevt.status = BTA_FTS_OK;
- if ((status = bta_fs_co_rmdir(p_cb->p_path, p_cb->app_id)) != BTA_FS_CO_OK)
- {
- objevt.status = BTA_FTS_FAIL;
- }
-
- /* Notify application of delete attempt */
- p_cb->p_cback(BTA_FTS_DEL_CMPL_EVT, (tBTA_FTS *)&objevt);
- }
- break;
-
- case BTA_FT_OPER_CHG_DIR: /* Request is a Change Folder */
- p_rsp = OBX_SetPathRsp;
- if (access == BTA_FT_ACCESS_ALLOW)
- {
- status = BTA_FS_CO_OK;
- BCM_STRNCPY_S(p_cb->p_workdir, p_bta_fs_cfg->max_path_len+1, p_cb->p_path, p_bta_fs_cfg->max_path_len);
- p_cb->p_workdir[p_bta_fs_cfg->max_path_len] = '\0';
- APPL_TRACE_DEBUG1("FTS: SET NEW PATH [%s]", p_cb->p_workdir);
- bta_fs_co_setdir(p_cb->p_workdir, p_cb->app_id);
- }
- break;
-
- case BTA_FT_OPER_MK_DIR: /* Request is a Make Folder */
- p_rsp = OBX_SetPathRsp;
- if (access == BTA_FT_ACCESS_ALLOW)
- {
- if ((status = bta_fs_co_mkdir(p_cb->p_path, p_cb->app_id)) == BTA_FS_CO_OK)
- {
- BCM_STRNCPY_S(p_cb->p_workdir, p_bta_fs_cfg->max_path_len+1, p_cb->p_path, p_bta_fs_cfg->max_path_len);
- p_cb->p_workdir[p_bta_fs_cfg->max_path_len] = '\0';
- APPL_TRACE_DEBUG1("FTS: SET NEW PATH [%s]", p_cb->p_workdir);
- bta_fs_co_setdir(p_cb->p_workdir, p_cb->app_id);
- }
- }
- break;
-
- case BTA_FT_OPER_COPY_ACT:
- if (access == BTA_FT_ACCESS_ALLOW)
- {
- p_cb->cout_active = TRUE;
- bta_fs_co_copy(p_cb->p_path, p_cb->p_dest, p_cb->perms, BTA_FTS_CI_OPEN_EVT, p_cb->app_id);
- }
- else
- p_rsp = OBX_ActionRsp;
- break;
-
- case BTA_FT_OPER_MOVE_ACT:
- if (access == BTA_FT_ACCESS_ALLOW)
- {
- p_cb->cout_active = TRUE;
- bta_fs_co_rename(p_cb->p_path, p_cb->p_dest, p_cb->perms, BTA_FTS_CI_OPEN_EVT, p_cb->app_id);
- }
- else
- p_rsp = OBX_ActionRsp;
- break;
-
- case BTA_FT_OPER_SET_PERM:
- if (access == BTA_FT_ACCESS_ALLOW)
- {
- p_cb->cout_active = TRUE;
- bta_fs_co_set_perms(p_cb->p_path, p_cb->perms, BTA_FTS_CI_OPEN_EVT, p_cb->app_id);
- }
- else
- p_rsp = OBX_ActionRsp;
- break;
-
- default:
- p_cb->acc_active = old_acc_active;
- APPL_TRACE_WARNING1("FTS ACCRSP: Unknown tBTA_FT_OPER value (%d)",
- p_cb->acc_active);
- }
- if(p_rsp)
- {
- switch (status)
- {
- case BTA_FS_CO_OK:
- rsp_code = OBX_RSP_OK;
- break;
- case BTA_FS_CO_ENOTEMPTY:
- rsp_code = OBX_RSP_PRECONDTN_FAILED;
- break;
- case BTA_FS_CO_EACCES:
- rsp_code = OBX_RSP_UNAUTHORIZED;
- break;
- default:
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- utl_freebuf((void**)&p_cb->p_name);
- utl_freebuf((void**)&p_cb->p_path);
- utl_freebuf((void**)&p_cb->p_dest);
-
- p_cb->obx_oper = FTS_OP_NONE;
- (*p_rsp)(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_api_close
-**
-** Description Handle an api close event.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_api_close(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- BD_ADDR bd_addr;
- if (OBX_GetPeerAddr(p_cb->obx_handle, bd_addr) != 0)
- {
- /* resources will be freed at BTA_PBS_OBX_CLOSE_EVT */
- OBX_DisconnectRsp(p_cb->obx_handle, OBX_RSP_SERVICE_UNAVL, NULL);
- }
- else
- {
- p_cb->p_cback(BTA_FTS_CLOSE_EVT, 0);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_ci_write
-**
-** Description Continue with the current write operation
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_ci_write(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- UINT8 rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->disabling)
- {
- bta_fts_sm_execute(p_cb,BTA_FTS_DISABLE_CMPL_EVT, p_data);
- }
-
- /* Process write call-in event if operation is still active */
- if (p_cb->obx_oper == FTS_OP_PUT_FILE)
- {
- if (p_data->write_evt.status == BTA_FS_CO_OK)
- rsp_code = OBX_RSP_OK;
- else
- {
- if (p_data->write_evt.status == BTA_FS_CO_ENOSPACE)
- rsp_code = OBX_RSP_DATABASE_FULL;
- bta_fts_clean_getput(p_cb, TRUE);
- }
-
- /* Process response to OBX client */
- bta_fts_put_file_rsp(rsp_code);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_ci_read
-**
-** Description Handles the response to a read call-out request.
-** This is called within the OBX get file request. If the
-** operation has completed, the OBX response is sent out;
-** otherwise a read for additional data is made.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_ci_read(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FS_CI_READ_EVT *p_revt = &p_data->read_evt;
- UINT8 rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->disabling)
- {
- bta_fts_sm_execute(p_cb,BTA_FTS_DISABLE_CMPL_EVT, p_data);
- }
-
- /* Process read call-in event if operation is still active */
- if (p_cb->obx_oper == FTS_OP_GET_FILE && p_revt->fd == p_cb->fd)
- {
- /* Read was successful, not finished yet */
- if (p_revt->status == BTA_FS_CO_OK)
- rsp_code = OBX_RSP_CONTINUE;
-
- /* Read was successful, end of file has been detected */
- else if (p_revt->status == BTA_FS_CO_EOF)
- rsp_code = OBX_RSP_OK;
-
- /* Process response to OBX client */
- bta_fts_get_file_rsp(rsp_code, p_revt->num_read);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_ci_resume
-**
-** Description Continue with the current file open operation
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_ci_resume(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_UTL_COD cod;
-
- p_cb->state = BTA_FTS_LISTEN_ST;
- APPL_TRACE_EVENT1("bta_fts_ci_resume status:%d", p_data->resume_evt.status);
- /* Set the File Transfer service class bit */
- cod.service = BTM_COD_SERVICE_OBJ_TRANSFER;
- utl_set_device_class(&cod, BTA_UTL_SET_COD_SERVICE_CLASS);
- if (p_data->resume_evt.status == BTA_FS_CO_OK)
- {
- OBX_AddSuspendedSession (p_cb->obx_handle, p_data->resume_evt.p_addr,
- p_data->resume_evt.p_sess_info, p_data->resume_evt.timeout,
- p_data->resume_evt.ssn, p_data->resume_evt.offset);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_ci_open
-**
-** Description Continue with the current file open operation
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_ci_open(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FS_CI_OPEN_EVT *p_open = &p_data->open_evt;
- UINT8 rsp_code = OBX_RSP_OK;
- tBTA_FTS_OBX_PKT *p_obx = &p_cb->obx;
- UINT8 num_hdrs;
- BOOLEAN endpkt;
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->disabling)
- {
- bta_fts_sm_execute(p_cb,BTA_FTS_DISABLE_CMPL_EVT, p_data);
- }
-
- /* If using OBEX 1.5 */
- if ( p_cb->obx_oper & FTS_OP_RESUME)
- {
- /* clear the FTS_OP_RESUME when the first request is received.
- * We may need to adjust ssn/offset */
- if ((p_open->fd >= 0) && (p_cb->obx_oper == FTS_OP_RESUME))
- {
- /* file is open successfully when the resumed obex op is FTS_OP_NONE
- * close this file */
- bta_fs_co_close(p_open->fd, p_cb->app_id);
- p_open->fd = BTA_FS_INVALID_FD;
- }
- p_cb->fd = p_open->fd;
- return;
- }
-
- /* Only process file get or put operations */
- if (p_cb->obx_oper == FTS_OP_GET_FILE)
- {
- /* if file is accessible read/write the first buffer of data */
- if (p_open->status == BTA_FS_CO_OK)
- {
- p_cb->file_length = p_open->file_size;
- p_cb->fd = p_open->fd;
-
- /* Add the length header if available */
- if (p_cb->file_length != BTA_FS_LEN_UNKNOWN)
- {
- OBX_AddLengthHdr(p_obx->p_pkt, p_cb->file_length);
- if (p_cb->file_length > 0)
- rsp_code = OBX_RSP_CONTINUE;
- else
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, TRUE);
- }
-
- /* Send continuation response with the length of the file and no body */
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* Do not deallocate buffer; OBX will */
-
- if (p_cb->file_length == 0)
- bta_fts_clean_getput(p_cb, FALSE);
- }
- else
- {
- if (p_open->status == BTA_FS_CO_EACCES)
- rsp_code = OBX_RSP_UNAUTHORIZED;
- else /* File could not be found */
- rsp_code = OBX_RSP_NOT_FOUND;
-
- /* Send OBX response if an error occurred */
- bta_fts_get_file_rsp(rsp_code, 0);
- }
- }
- else if (p_cb->obx_oper == FTS_OP_PUT_FILE)
- {
- /* if file is accessible read/write the first buffer of data */
- if (p_open->status == BTA_FS_CO_OK)
- {
- p_cb->fd = p_open->fd;
-
- /* Read in start of body if there is a body header */
- num_hdrs = OBX_ReadBodyHdr(p_obx->p_pkt, &p_obx->p_start,
- &p_obx->bytes_left, &endpkt);
- if (num_hdrs == 1)
- {
- rsp_code = OBX_RSP_PART_CONTENT; /* Do not send OBX response yet */
- /* Initiate the writing out of the data */
- p_cb->cout_active = TRUE;
- bta_fs_co_write(p_cb->fd, &p_obx->p_start[p_obx->offset],
- p_obx->bytes_left, BTA_FTS_CI_WRITE_EVT, 0,
- p_cb->app_id);
- }
- else if (num_hdrs > 1) /* Cannot handle multiple body headers */
- {
- rsp_code = OBX_RSP_BAD_REQUEST;
- bta_fts_clean_getput(p_cb, TRUE);
- }
- else /* No body: respond with an OK so client can start sending the data */
- p_obx->bytes_left = 0;
-
- if (rsp_code != OBX_RSP_PART_CONTENT)
- {
- bta_fts_put_file_rsp(rsp_code);
- }
- }
- else
- {
- if (p_open->status == BTA_FS_CO_EACCES)
- rsp_code = OBX_RSP_UNAUTHORIZED;
- else if (p_open->status == BTA_FS_CO_ENOSPACE)
- rsp_code = OBX_RSP_DATABASE_FULL;
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
-
- /* Send OBX response now if an error occurred */
- bta_fts_put_file_rsp(rsp_code);
- }
- }
- /* If using OBEX 1.5 */
- else
- {
- /* must be action commands BTA_FT_OPER_COPY_ACT - BTA_FT_OPER_SET_PERM*/
- switch (p_open->status)
- {
- case BTA_FS_CO_OK:
- rsp_code = OBX_RSP_OK;
- break;
- case BTA_FS_CO_EACCES:
- rsp_code = OBX_RSP_UNAUTHORIZED;
- break;
- case BTA_FS_CO_EIS_DIR:
- rsp_code = OBX_RSP_FORBIDDEN;
- default:
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- utl_freebuf((void**)&p_cb->p_name);
- utl_freebuf((void**)&p_cb->p_path);
- utl_freebuf((void**)&p_cb->p_dest);
- p_cb->obx_oper = FTS_OP_NONE;
- OBX_ActionRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_ci_direntry
-**
-** Description Continue getting the current directory entry operation
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_ci_direntry(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- UINT8 rsp_code;
- BOOLEAN free_pkt = TRUE;
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->disabling)
- {
- bta_fts_sm_execute(p_cb,BTA_FTS_DISABLE_CMPL_EVT, p_data);
- }
-
- /* Process dirent listing call-in event if operation is still active */
- if (p_cb->obx_oper == FTS_OP_LISTING)
- {
- switch (p_data->getdir_evt.status)
- {
- case BTA_FS_CO_OK: /* Valid new entry */
- free_pkt = FALSE;
- if ((rsp_code = bta_fts_add_list_entry()) != OBX_RSP_PART_CONTENT)
- bta_fts_end_of_list(rsp_code);
- break;
-
- case BTA_FS_CO_EODIR: /* End of list (entry not valid) */
- free_pkt = FALSE;
- bta_fts_end_of_list(OBX_RSP_OK);
- break;
-
- case BTA_FS_CO_FAIL: /* Error occurred */
- bta_fts_end_of_list(OBX_RSP_NOT_FOUND);
- break;
- }
- }
-
- if (free_pkt)
- utl_freebuf((void **)&p_cb->obx.p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_obx_connect
-**
-** Description Process the OBX connect event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_obx_connect(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FTS_OBX_EVENT *p_evt = &p_data->obx_evt;
- tOBX_SESS_EVT *p_sess = &p_data->obx_evt.param.sess;
-
- APPL_TRACE_DEBUG1("bta_fts_obx_connect obx_event=%d", p_evt->obx_event);
- if (p_evt->obx_event == OBX_SESSION_REQ_EVT)
- {
- APPL_TRACE_EVENT3("sess_op:%d obj_offset:x%x ssn:%d", p_sess->sess_op, p_sess->obj_offset, p_sess->ssn);
-
- BCM_STRNCPY_S(p_cb->p_workdir, p_bta_fs_cfg->max_path_len+1, p_cb->p_rootpath, p_bta_fs_cfg->max_path_len);
- p_cb->p_workdir[p_bta_fs_cfg->max_path_len] = '\0';
-
- bta_fs_co_session_info(p_cb->bd_addr, p_sess->p_sess_info, p_sess->ssn,
- BTA_FS_CO_SESS_ST_ACTIVE, p_cb->p_workdir, &p_cb->obx_oper, p_cb->app_id);
- APPL_TRACE_DEBUG1("obx_oper:%d", p_cb->obx_oper);
- if (p_sess->sess_op == OBX_SESS_OP_CREATE)
- {
- p_cb->state = BTA_FTS_LISTEN_ST;
- p_cb->obx_oper = FTS_OP_NONE;
- }
- else if (p_sess->sess_op == OBX_SESS_OP_RESUME)
- {
- p_cb->state = BTA_FTS_LISTEN_ST;
- p_cb->resume_ssn = p_sess->ssn;
- APPL_TRACE_EVENT1("resume ssn:%d", p_sess->ssn);
- if (p_cb->obx_oper)
- {
- bta_fs_co_resume_op(p_sess->obj_offset, BTA_FTS_CI_OPEN_EVT, p_cb->app_id);
- p_cb->obx_oper |= FTS_OP_RESUME;
- }
- }
- return;
- }
-
- p_cb->peer_mtu = p_evt->param.conn.mtu;
- memcpy(p_cb->bd_addr, p_evt->param.conn.peer_addr, BD_ADDR_LEN);
- APPL_TRACE_EVENT2("FTS Connect: peer mtu 0x%04x handle:0x%x", p_cb->peer_mtu, p_evt->handle);
-
- if (!p_evt->param.conn.no_rsp)
- {
- OBX_ConnectRsp(p_evt->handle, OBX_RSP_OK, (BT_HDR *)NULL);
-
- /* Reset to the root directory */
- BCM_STRNCPY_S(p_cb->p_workdir, p_bta_fs_cfg->max_path_len+1, p_cb->p_rootpath, p_bta_fs_cfg->max_path_len);
- p_cb->p_workdir[p_bta_fs_cfg->max_path_len] = '\0';
-
- bta_fs_co_setdir(p_cb->p_workdir, p_cb->app_id);
- }
-
- /* inform role manager */
- bta_sys_conn_open( BTA_ID_FTS, p_cb->app_id, p_cb->bd_addr);
-
- /* Notify the MMI that a connection has been opened */
- p_cb->p_cback(BTA_FTS_OPEN_EVT, (tBTA_FTS*)p_cb->bd_addr);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_obx_disc
-**
-** Description Process the OBX disconnect event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_obx_disc(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FTS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code;
-
- rsp_code = (p_evt->obx_event == OBX_DISCONNECT_REQ_EVT) ? OBX_RSP_OK
- : OBX_RSP_BAD_REQUEST;
- OBX_DisconnectRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_obx_close
-**
-** Description Process the OBX link lost event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_obx_close(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- /* finished if not waiting on a call-in function */
- if (!p_cb->cout_active)
- bta_fts_sm_execute(p_cb, BTA_FTS_CLOSE_CMPL_EVT, p_data);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_obx_abort
-**
-** Description Process the OBX abort event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_obx_abort(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FTS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code = OBX_RSP_OK;
-
- utl_freebuf((void**)&p_evt->p_pkt);
-
- switch (p_cb->obx_oper)
- {
- case FTS_OP_LISTING:
- utl_freebuf((void**)&p_cb->obx.p_pkt);
- bta_fts_clean_list(p_cb);
- break;
-
- case FTS_OP_GET_FILE:
- case FTS_OP_PUT_FILE:
- bta_fts_clean_getput(p_cb, TRUE);
- break;
-
- default: /* Reply OK to the client */
- rsp_code = OBX_RSP_BAD_REQUEST;
- }
-
- OBX_AbortRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_obx_password
-**
-** Description Process the OBX password request
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_obx_password(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FTS_OBX_EVENT *p_evt = &p_data->obx_evt;
- tBTA_FTS_AUTH *p_auth;
- BOOLEAN is_challenged;
- tOBX_AUTH_OPT options;
-
- if ((p_auth = (tBTA_FTS_AUTH *)GKI_getbuf(sizeof(tBTA_FTS_AUTH))) != NULL)
- {
- memset(p_auth, 0, sizeof(tBTA_FTS_AUTH));
-
- /* Extract user id from packet (if available) */
- if (OBX_ReadAuthParams(p_data->obx_evt.p_pkt, &p_auth->p_userid,
- &p_auth->userid_len,
- &is_challenged, &options))
- {
- if (options & OBX_AO_USR_ID)
- p_auth->userid_required = TRUE;
- }
-
- /* Don't need OBX packet any longer */
- utl_freebuf((void**)&p_evt->p_pkt);
-
- /* Notify application */
- p_cb->p_cback(BTA_FTS_AUTH_EVT, (tBTA_FTS *)p_auth);
-
- GKI_freebuf(p_auth);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_obx_put
-**
-** Description Process the OBX file put and delete file/folder events
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_obx_put(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FTS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code = OBX_RSP_OK;
- BOOLEAN rsp_now = TRUE;
- BOOLEAN free_in_pkt = TRUE;
- UINT8 obx_oper = bta_fts_cb.obx_oper;
- tBTA_FTS_OBX_PKT *p_obx = &p_cb->obx;
- UINT8 num_hdrs;
- BOOLEAN endpkt;
-
- APPL_TRACE_EVENT1("bta_fts_obx_put oper=x%x", p_cb->obx_oper);
-
- /* If using OBEX 1.5 */
- if ( p_cb->obx_oper & FTS_OP_RESUME)
- {
- APPL_TRACE_EVENT2("bta_fts_obx_put ssn:%d resume ssn:%d", p_evt->param.get.ssn, p_cb->resume_ssn);
- p_cb->obx_oper &= ~FTS_OP_RESUME;
- num_hdrs = OBX_ReadBodyHdr(p_obx->p_pkt, &p_obx->p_start,
- &p_obx->bytes_left, &endpkt);
- if ((p_evt->param.get.ssn != p_cb->resume_ssn) && (p_cb->fd >= 0))
- {
- if ((p_cb->obx_oper == FTS_OP_PUT_FILE) && (num_hdrs == 0) && ((p_evt->param.get.ssn + 1) == p_cb->resume_ssn))
- {
- APPL_TRACE_EVENT0("client did not get the last PUT response. Just want another response pkt");
- }
- else
- bta_fs_co_sess_ssn(p_cb->fd, p_evt->param.put.ssn, p_cb->app_id);
- }
- }
-
- /* If currently processing a PUT, use the current name */
- if (bta_fts_cb.obx_oper == FTS_OP_PUT_FILE)
- {
- free_in_pkt = FALSE; /* Hang on to Obx packet until done */
- bta_fts_proc_put_file(p_evt->p_pkt, p_cb->p_name, p_evt->param.put.final, obx_oper);
- rsp_now = FALSE; /* Response sent after processing the request */
- }
- else /* This is a new request */
- {
- /* Pull out the name header if it exists */
- if ((p_cb->p_name = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_file_len + 1))) != NULL)
- {
- if (OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *) p_cb->p_name, p_bta_fs_cfg->max_file_len))
- {
- /* Is Put operation Delete, Create, or Put */
- if (p_evt->param.put.type == OBX_PT_DELETE)
- {
- APPL_TRACE_EVENT1("FTS File/Folder Delete: Name [%s]", p_cb->p_name);
- bta_fts_delete(p_evt, p_cb->p_name);
- utl_freebuf((void**)&p_cb->p_name);
- }
- else /* File Put or File Create */
- {
- free_in_pkt = FALSE; /* Hang on to Obx packet until done */
- APPL_TRACE_EVENT1("FTS File Put: Name [%s]", p_cb->p_name);
- bta_fts_proc_put_file(p_evt->p_pkt, p_cb->p_name, p_evt->param.put.final, obx_oper);
- }
-
- rsp_now = FALSE; /* Response sent after processing the request */
- }
- else /* Must have a name header */
- {
- utl_freebuf((void**)&p_cb->p_name);
- rsp_code = OBX_RSP_BAD_REQUEST;
- }
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
-
- /* Respond right away if an error has been detected processing request */
- if (rsp_now)
- OBX_PutRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
-
- /* Done with Obex packet */
- if (free_in_pkt)
- utl_freebuf((void**)&p_evt->p_pkt);
-
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_obx_get
-**
-** Description Process the OBX file get and folder listing events
-** If the type header is not folder listing, then pulling a file.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_obx_get(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FTS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT16 len;
- BOOLEAN is_file_get = TRUE; /* Set to false if folder listing */
- UINT8 *p_type;
-
- APPL_TRACE_EVENT1("bta_fts_obx_get:%d", bta_fts_cb.obx_oper);
-
- /* If using OBEX 1.5 */
- if ( p_cb->obx_oper & FTS_OP_RESUME)
- {
- p_cb->obx_oper &= ~FTS_OP_RESUME;
- APPL_TRACE_DEBUG3("ssn:%d resume ssn:%d, op:%d", p_evt->param.get.ssn, p_cb->resume_ssn, bta_fts_cb.obx_oper );
- if (bta_fts_cb.obx_oper == FTS_OP_LISTING)
- {
- /* abort the listing */
- bta_fts_end_of_list(OBX_RSP_INTRNL_SRVR_ERR);
- return;
- }
- else if ((p_evt->param.get.ssn != p_cb->resume_ssn) && (p_cb->fd >= 0))
- {
- APPL_TRACE_EVENT2("ssn:%d resume ssn:%d", p_evt->param.get.ssn, p_cb->resume_ssn);
- bta_fs_co_sess_ssn(p_cb->fd, p_evt->param.get.ssn, p_cb->app_id);
- }
- }
-
- /* If currently processing a GET, use the current name */
- if (bta_fts_cb.obx_oper == FTS_OP_LISTING)
- bta_fts_getdirlist(p_cb->p_name);
- else if (bta_fts_cb.obx_oper == FTS_OP_GET_FILE)
- bta_fts_proc_get_file(p_cb->p_name);
-
- else /* This is a new request */
- {
- /* Pull out the name header if it exists */
- if ((p_cb->p_name = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_file_len + 1))) != NULL)
- {
- if (!OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *)p_cb->p_name, p_bta_fs_cfg->max_file_len))
- {
- GKI_freebuf(p_cb->p_name);
- p_cb->p_name = NULL;
- }
- }
-
- /* See if getting a folder listing */
- if (OBX_ReadTypeHdr(p_evt->p_pkt, &p_type, &len))
- {
- if (!memcmp(p_type, BTA_FTS_FOLDER_LISTING_TYPE, len))
- {
- is_file_get = FALSE;
- bta_fts_getdirlist(p_cb->p_name);
- }
- }
-
- /* Initiate the Get File request if not folder listing */
- if (is_file_get)
- {
- if (p_cb->p_name)
- {
- APPL_TRACE_EVENT1("FTS File Get: Name [%s]", p_cb->p_name);
- }
- bta_fts_proc_get_file(p_cb->p_name);
- }
- }
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_obx_setpath
-**
-** Description Process the FTP change or make directory requests
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_obx_setpath(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FTS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code = OBX_RSP_BAD_REQUEST;
- tOBX_SETPATH_FLAG *p_flag = &p_evt->param.sp.flag;
- tBTA_FT_OPER ft_op = 0;
-
- /* Verify flags and handle before accepting */
- if (p_evt->handle == p_cb->obx_handle &&
- (((*p_flag) & FLAGS_ARE_MASK) != FLAGS_ARE_ILLEGAL))
- {
- p_cb->p_name = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_file_len + 1));
- p_cb->p_path = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len +
- p_bta_fs_cfg->max_file_len + 2));
- if (p_cb->p_name != NULL && p_cb->p_path != NULL)
- {
- if (!OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *)p_cb->p_name, p_bta_fs_cfg->max_file_len))
- {
- utl_freebuf((void **)&p_cb->p_name); /* no name header */
- }
- else if (!p_cb->p_name)
- {
- /* empty name header set to null terminated string */
- p_cb->p_name[0] = '\0';
- }
-
-
- /* Determine if operation is mkdir */
- if (!((*p_flag) & OBX_SPF_NO_CREATE))
- {
- rsp_code = bta_fts_mkdir(p_evt->p_pkt, &ft_op);
-
- /* If the directory already exists, silently perform change directory */
- if(rsp_code == OBX_RSP_CONTINUE)
- {
- /* Note BACKUP flag must be FALSE for mkdir operation */
- rsp_code = bta_fts_chdir(p_evt->p_pkt, FALSE, &ft_op);
- }
- }
- else /* Operation is chdir */
- rsp_code = bta_fts_chdir(p_evt->p_pkt, (BOOLEAN)((*p_flag) & OBX_SPF_BACKUP), &ft_op);
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
-
- if (ft_op)
- {
- bta_fts_req_app_access(ft_op, p_cb);
- }
- else
- {
- OBX_SetPathRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- utl_freebuf((void**)&p_cb->p_name);
- utl_freebuf((void**)&p_cb->p_path);
- }
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/* Using OBEX 1.5 */
-/*******************************************************************************
-**
-** Function bta_fts_obx_action
-**
-** Description Process the FTP action requests
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_obx_action(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FTS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code = OBX_RSP_BAD_REQUEST;
- tBTA_FT_OPER ft_op = 0;
- UINT8 action;
- BOOLEAN is_dir;
- BOOLEAN has_perms = FALSE;
- char *p_dest_name = NULL;
- char *p_newpath = NULL;
-
- /* Verify flags and handle before accepting */
- if (p_evt->handle == p_cb->obx_handle )
- {
- if (OBX_ReadActionIdHdr(p_evt->p_pkt, &action))
- {
- p_cb->p_name = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_file_len + 1));
- p_cb->p_path = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len +
- p_bta_fs_cfg->max_file_len + 2));
- p_newpath = p_cb->p_path;
- if ((p_cb->p_name != NULL) && (p_cb->p_path != NULL) &&
- ((strlen(p_cb->p_name) + strlen(p_cb->p_workdir) + 1) <= p_bta_fs_cfg->max_path_len))
-
- {
- if (OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *)p_cb->p_name, p_bta_fs_cfg->max_file_len) &&
- p_cb->p_name[0])
- {
- /* the packet has non-empty name header */
- sprintf(p_newpath, "%s%c%s", p_cb->p_workdir,
- p_bta_fs_cfg->path_separator, p_cb->p_name);
- if (((bta_fs_co_access(p_newpath, BTA_FS_ACC_EXIST,
- &is_dir, p_cb->app_id)) == BTA_FS_CO_OK))
- {
- /* the src object exists */
- ft_op = BTA_FT_OPER_COPY_ACT + action;
- }
- else
- rsp_code = OBX_RSP_NOT_FOUND;
- }
-
- if (ft_op)
- {
- memset (p_cb->perms, 0, BTA_FS_PERM_SIZE);
- /* it's SetPermission -> need Permission Header */
- if (OBX_ReadPermissionHdr(p_evt->p_pkt, &p_cb->perms[BTA_FS_PERM_USER],
- &p_cb->perms[BTA_FS_PERM_GROUP], &p_cb->perms[BTA_FS_PERM_OTHER]))
- {
- has_perms = TRUE;
- }
- if (action != BTA_FT_ACT_PERMISSION)
- {
- /* it's Move or Copy -> need DestName Header */
- p_dest_name = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_file_len + 1));
- p_cb->p_dest = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len +
- p_bta_fs_cfg->max_file_len + 2));
- p_newpath = p_cb->p_dest;
- if (p_dest_name && p_cb->p_dest)
- {
- if (OBX_ReadUtf8DestNameHdr(p_evt->p_pkt, (UINT8 *)p_dest_name, p_bta_fs_cfg->max_file_len) &&
- p_dest_name[0])
- {
- if (p_dest_name[0] == '/' || p_dest_name[0] == '\\')
- {
- /* the packet has non-empty DestName header */
- sprintf(p_newpath, "%s%c%s", p_cb->p_rootpath,
- p_bta_fs_cfg->path_separator, p_dest_name);
- }
- else
- {
- /* the packet has non-empty DestName header */
- sprintf(p_newpath, "%s%c%s", p_cb->p_workdir,
- p_bta_fs_cfg->path_separator, p_dest_name);
- }
- if (((bta_fs_co_access(p_newpath, BTA_FS_ACC_EXIST,
- &is_dir, p_cb->app_id)) == BTA_FS_CO_FAIL))
- {
- /* the dest object does not exist */
- rsp_code = OBX_RSP_OK;
- }
- }
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- else if (has_perms)
- {
- /* the SetPermission action must have the permission header */
- rsp_code = OBX_RSP_OK;
- }
- }
-
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- }
-
- if(rsp_code == OBX_RSP_OK)
- {
- bta_fts_req_app_access(ft_op, p_cb);
- }
- else
- {
- OBX_ActionRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- utl_freebuf((void**)&p_cb->p_name);
- utl_freebuf((void**)&p_cb->p_path);
- utl_freebuf((void**)&p_dest_name);
- utl_freebuf((void**)&p_cb->p_dest);
- }
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-/* end of using OBEX 1.5 */
-
-/*******************************************************************************
-**
-** Function bta_fts_appl_tout
-**
-** Description Process the FTS application timeout event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_appl_tout(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_conn_err_rsp
-**
-** Description Process the OBX error response
-** Connect request received in wrong state, or bad request
-** from client
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_conn_err_rsp(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- OBX_ConnectRsp(p_data->obx_evt.handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
-}
-
-/* Using OBEX 1.5 */
-/*******************************************************************************
-**
-** Function bta_fts_session_req
-**
-** Description Process the OBX session req in connected state
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_session_req(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FTS_OBX_EVENT *p_evt = &p_data->obx_evt;
- tOBX_SESS_EVT *p_sess = &p_data->obx_evt.param.sess;
- UINT8 rsp_code = OBX_RSP_OK;
- UINT32 offset = 0;
-
- if (p_evt->obx_event == OBX_SESSION_REQ_EVT)
- {
- APPL_TRACE_EVENT2("sess_op:%d ssn:%d", p_sess->sess_op, p_sess->ssn);
- switch (p_sess->sess_op)
- {
- case OBX_SESS_OP_SUSPEND:
- bta_fs_co_suspend(p_cb->bd_addr, p_sess->p_sess_info, p_sess->ssn, &p_sess->timeout, &offset, p_cb->obx_oper, p_cb->app_id);
- p_cb->state = BTA_FTS_CLOSING_ST;
- p_cb->suspending = TRUE;
- break;
-
- case OBX_SESS_OP_CLOSE:
- bta_fs_co_session_info(p_cb->bd_addr, p_sess->p_sess_info, 0, BTA_FS_CO_SESS_ST_NONE, NULL, NULL, p_cb->app_id);
- p_cb->state = BTA_FTS_CLOSING_ST;
- break;
-
- case OBX_SESS_OP_CREATE:
- case OBX_SESS_OP_RESUME:
- p_cb->state = BTA_FTS_CONN_ST;
- rsp_code = OBX_RSP_FORBIDDEN;
- break;
- }
- OBX_SessionRsp (p_evt->handle, rsp_code, p_sess->ssn, offset, NULL);
- return;
- }
- else if (p_evt->obx_event == OBX_SESSION_INFO_EVT)
- {
- if ((p_cb->obx_oper != FTS_OP_GET_FILE) && (p_cb->obx_oper != FTS_OP_PUT_FILE) && (p_cb->obx_oper != FTS_OP_LISTING))
- {
- /* the other obx ops are single transaction.
- * If the link is dropped before the transaction ends, let the client re-transmit the request */
- p_sess->ssn--;
- p_cb->obx_oper = FTS_OP_NONE;
- }
- bta_fs_co_suspend(p_cb->bd_addr, p_sess->p_sess_info, p_sess->ssn,
- &p_sess->timeout, &offset, p_cb->obx_oper, p_cb->app_id);
- OBX_AddSuspendedSession (p_cb->obx_handle, p_cb->bd_addr,
- p_sess->p_sess_info, p_sess->timeout,
- p_sess->ssn, offset);
- p_cb->suspending = TRUE;
- }
- else
- {
- p_cb->state = BTA_FTS_CONN_ST;
- bta_fts_conn_err_rsp (p_cb, p_data);
- }
-}
-/* End of using OBEX 1.5 */
-
-/*******************************************************************************
-**
-** Function bta_fts_disc_err_rsp
-**
-** Description Process the OBX error response
-** Disconnect request received in wrong state, or bad request
-** from client
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_disc_err_rsp(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- OBX_DisconnectRsp(p_data->obx_evt.handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_gasp_err_rsp
-**
-** Description Process the OBX error response for Get, Abort, Setpath, and Put.
-**
-** The rsp_code field of tBTA_FTS_DATA (obx_evt) contains the
-** response code to be sent to OBEX, and the obx_event field
-** contains the current OBEX event.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_gasp_err_rsp(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tBTA_FTS_OBX_EVENT *p_evt = &p_data->obx_evt;
- tBTA_FTS_OBX_RSP *p_rsp = NULL;
-
- switch (p_evt->obx_event)
- {
- case OBX_PUT_REQ_EVT:
- p_rsp = OBX_PutRsp;
- break;
- case OBX_GET_REQ_EVT:
- p_rsp = OBX_GetRsp;
- break;
- case OBX_SETPATH_REQ_EVT:
- p_rsp = OBX_SetPathRsp;
- break;
- case OBX_ABORT_REQ_EVT:
- p_rsp = OBX_AbortRsp;
- break;
- case OBX_ACTION_REQ_EVT:
- p_rsp = OBX_ActionRsp;
- break;
- }
- if(p_rsp)
- (*p_rsp)(p_evt->handle, p_evt->rsp_code, (BT_HDR *)NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_close_complete
-**
-** Description Finishes the memory cleanup after a channel is closed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_close_complete(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- p_cb->cout_active = FALSE;
- bta_fts_clean_getput(p_cb, TRUE);
- bta_fts_clean_list(p_cb);
-
- /* inform role manager */
- bta_sys_conn_close( BTA_ID_FTS ,p_cb->app_id, p_cb->bd_addr);
-
-
-
-
- /* Notify the MMI that a connection has been closed */
- p_cb->p_cback(BTA_FTS_CLOSE_EVT, (tBTA_FTS*)p_cb->bd_addr);
- memset(p_cb->bd_addr, 0, BD_ADDR_LEN);
-
- if (p_data->obx_evt.p_pkt)
- APPL_TRACE_WARNING0("FTS: OBX CLOSE CALLED WITH non-NULL Packet!!!");
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_disable_cmpl
-**
-** Description Finishes the memory cleanup before shutting down server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_disable_cmpl(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- bta_fts_disable_cleanup(p_cb);
-}
-
-/*****************************************************************************
-** Callback Functions
-*****************************************************************************/
-/*******************************************************************************
-**
-** Function bta_fts_obx_cback
-**
-** Description OBX callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_obx_cback (tOBX_HANDLE handle, tOBX_EVENT obx_event,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt)
-{
- tBTA_FTS_OBX_EVENT *p_obx_msg;
- UINT16 event = 0;
- UINT16 size = sizeof(tBTA_FTS_OBX_EVENT);
-
-#if BTA_FTS_DEBUG == TRUE
- APPL_TRACE_DEBUG2("OBX Event Callback: obx_event [%s] %d", fts_obx_evt_code(obx_event), obx_event);
-#endif
-
- switch(obx_event)
- {
- case OBX_SESSION_INFO_EVT: /* the session information event to resume the session. */
- size += OBX_SESSION_INFO_SIZE;
- /* Falls through */
-
- case OBX_SESSION_REQ_EVT:
- case OBX_CONNECT_REQ_EVT:
- event = BTA_FTS_OBX_CONN_EVT;
- break;
- case OBX_ACTION_REQ_EVT:
- event = BTA_FTS_OBX_ACTION_EVT;
- break;
- case OBX_DISCONNECT_REQ_EVT:
- event = BTA_FTS_OBX_DISC_EVT;
- break;
- case OBX_PUT_REQ_EVT:
- event = BTA_FTS_OBX_PUT_EVT;
- break;
- case OBX_GET_REQ_EVT:
- event = BTA_FTS_OBX_GET_EVT;
- break;
- case OBX_SETPATH_REQ_EVT:
- event = BTA_FTS_OBX_SETPATH_EVT;
- break;
- case OBX_ABORT_REQ_EVT:
- event = BTA_FTS_OBX_ABORT_EVT;
- break;
- case OBX_CLOSE_IND_EVT:
- event = BTA_FTS_OBX_CLOSE_EVT;
- break;
- case OBX_TIMEOUT_EVT:
- break;
- case OBX_PASSWORD_EVT:
- event = BTA_FTS_OBX_PASSWORD_EVT;
- break;
- default:
- /* Unrecognized packet; disconnect the session */
- if (p_pkt)
- event = BTA_FTS_OBX_DISC_EVT;
- }
-
- /* send event to BTA, if any */
- if (event && (p_obx_msg =
- (tBTA_FTS_OBX_EVENT *) GKI_getbuf(size)) != NULL)
- {
- p_obx_msg->hdr.event = event;
- p_obx_msg->obx_event = obx_event;
- p_obx_msg->handle = handle;
- p_obx_msg->param = param;
- p_obx_msg->p_pkt = p_pkt;
-
- if (obx_event == OBX_SESSION_INFO_EVT)
- {
- p_obx_msg->param.sess.p_sess_info = (UINT8 *)(p_obx_msg + 1);
- memcpy (p_obx_msg->param.sess.p_sess_info, param.sess.p_sess_info, OBX_SESSION_INFO_SIZE);
- }
-
- bta_sys_sendmsg(p_obx_msg);
- }
-}
-
-/*****************************************************************************
-** Local FTP Event Processing Functions
-*****************************************************************************/
-/*******************************************************************************
-**
-** Function bta_fts_req_app_access
-**
-** Description Sends an access request event to the application.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_req_app_access (tBTA_FT_OPER oper, tBTA_FTS_CB *p_cb)
-{
- tBTA_FTS_ACCESS *p_acc_evt;
- char *p_devname;
-
- /* Notify the application that a put or get file has been requested */
- if ((p_acc_evt = (tBTA_FTS_ACCESS *)GKI_getbuf(sizeof(tBTA_FTS_ACCESS))) != NULL)
- {
- memset(p_acc_evt, 0, sizeof(tBTA_FTS_ACCESS));
-
- APPL_TRACE_API1("ACCESS REQ: [%s]", p_cb->p_path);
-
- p_acc_evt->p_name = p_cb->p_path;
- p_acc_evt->p_dest_name = p_cb->p_dest;
- memcpy(p_acc_evt->perms, p_cb->perms, BTA_FS_PERM_SIZE);
-
- p_acc_evt->size = p_cb->file_length;
- p_acc_evt->oper = p_cb->acc_active = oper;
- bdcpy(p_acc_evt->bd_addr, p_cb->bd_addr);
- if ((p_devname = BTM_SecReadDevName(p_cb->bd_addr)) != NULL)
- BCM_STRNCPY_S((char *)p_acc_evt->dev_name, sizeof(p_acc_evt->dev_name), p_devname, BTM_MAX_REM_BD_NAME_LEN);
-
- p_cb->p_cback(BTA_FTS_ACCESS_EVT, (tBTA_FTS *)p_acc_evt);
- GKI_freebuf(p_acc_evt);
- }
-}
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if BTA_FTS_DEBUG == TRUE
-
-/*******************************************************************************
-**
-** Function fts_obx_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *fts_obx_evt_code(tOBX_EVENT evt_code)
-{
- switch(evt_code)
- {
- case OBX_CONNECT_REQ_EVT:
- return "OBX_CONNECT_REQ_EVT";
- case OBX_DISCONNECT_REQ_EVT:
- return "OBX_DISCONNECT_REQ_EVT";
- case OBX_PUT_REQ_EVT:
- return "OBX_PUT_REQ_EVT";
- case OBX_GET_REQ_EVT:
- return "OBX_GET_REQ_EVT";
- case OBX_SETPATH_REQ_EVT:
- return "OBX_SETPATH_REQ_EVT";
- case OBX_ABORT_REQ_EVT:
- return "OBX_ABORT_REQ_EVT";
- case OBX_CLOSE_IND_EVT:
- return "OBX_CLOSE_IND_EVT";
- case OBX_TIMEOUT_EVT:
- return "OBX_TIMEOUT_EVT";
- case OBX_PASSWORD_EVT:
- return "OBX_PASSWORD_EVT";
- case OBX_SESSION_REQ_EVT:
- return "OBX_SESSION_REQ_EVT";
- case OBX_ACTION_REQ_EVT:
- return "OBX_ACTION_REQ_EVT";
- case OBX_SESSION_INFO_EVT:
- return "OBX_SESSION_INFO_EVT";
-
- default:
- return "unknown OBX event code";
- }
-}
-#endif /* Debug Functions */
-#endif /* BTA_FT_INCLUDED */
diff --git a/bta/ft/bta_fts_api.c b/bta/ft/bta_fts_api.c
deleted file mode 100644
index be359e0..0000000
--- a/bta/ft/bta_fts_api.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_fts_api.c
-**
-** Description: This is the implementation of the API for the file
-** transfer server subsystem of BTA, Widcomm's Bluetooth
-** application layer for mobile phones.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_FT_INCLUDED) && (BTA_FT_INCLUDED == TRUE)
-
-#include <string.h>
-#include "gki.h"
-#include "bta_fs_api.h"
-#include "bta_fts_int.h"
-
-// btla-specific ++
-//todo sdh
-
-/* Maximum path length supported by MMI */
-#ifndef BTA_FS_PATH_LEN
-#define BTA_FS_PATH_LEN 294
-#endif
-// btla-specific --
-
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-static const tBTA_SYS_REG bta_fts_reg =
-{
- bta_fts_hdl_event,
- BTA_FtsDisable
-};
-
-/*******************************************************************************
-**
-** Function BTA_FtsEnable
-**
-** Description Enable the file transfer server. This function must be
-** called before any other functions in the FTS API are called.
-** When the enable operation is complete the callback function
-** will be called with an BTA_FTS_ENABLE_EVT event.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtsEnable(tBTA_SEC sec_mask, const char *p_service_name,
- const char *p_root_path, BOOLEAN enable_authen,
- UINT8 realm_len, UINT8 *p_realm,
- tBTA_FTS_CBACK *p_cback, UINT8 app_id)
-{
- tBTA_FTS_API_ENABLE *p_buf;
-
- /* register with BTA system manager */
- GKI_sched_lock();
- bta_sys_register(BTA_ID_FTS, &bta_fts_reg);
- GKI_sched_unlock();
-
- if ((p_buf = (tBTA_FTS_API_ENABLE *)GKI_getbuf((UINT16)(sizeof(tBTA_FTS_API_ENABLE) +
- p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- memset(p_buf, 0, sizeof(tBTA_FTS_API_ENABLE));
-
- p_buf->p_root_path = (char *)(p_buf + 1);
- p_buf->p_root_path[p_bta_fs_cfg->max_path_len] = '\0';
-
- p_buf->hdr.event = BTA_FTS_API_ENABLE_EVT;
- p_buf->p_cback = p_cback;
- p_buf->sec_mask = sec_mask;
- p_buf->app_id = app_id;
- p_buf->auth_enabled = enable_authen;
-
- p_buf->realm_len = (realm_len < OBX_MAX_REALM_LEN) ? realm_len :
- OBX_MAX_REALM_LEN;
- if (p_realm)
- memcpy(p_buf->realm, p_realm, p_buf->realm_len);
-
- if (p_service_name)
- BCM_STRNCPY_S(p_buf->servicename, sizeof(p_buf->servicename), p_service_name, BTA_SERVICE_NAME_LEN);
-
- if (p_root_path)
- {
- BCM_STRNCPY_S(p_buf->p_root_path, p_bta_fs_cfg->max_path_len+1, p_root_path,
- p_bta_fs_cfg->max_path_len);
- p_buf->p_root_path[p_bta_fs_cfg->max_path_len] = '\0';
- }
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtsDisable
-**
-** Description Disable the file transfer server. If the server is currently
-** connected to a peer device the connection will be closed.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtsDisable(void)
-{
- BT_HDR *p_buf;
-
- bta_sys_deregister(BTA_ID_FTS);
- if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_FTS_API_DISABLE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtsClose
-**
-** Description Close the current connection. This function is called if
-** the phone wishes to close the connection before the FT
-** client disconnects.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtsClose(void)
-{
- BT_HDR *p_buf;
-
- if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_FTS_API_CLOSE_EVT;
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtsUnauthRsp
-**
-** Description Sends an OBEX authentication challenge to the connected
-** OBEX client. Called in response to an BTA_FTS_AUTH_EVT event.
-** Used when "enable_authen" is set to TRUE in BTA_FtsEnable().
-**
-** Note: If the "userid_required" is TRUE in the BTA_FTS_AUTH_EVT
-** event, then p_userid is required, otherwise it is optional.
-**
-** p_password must be less than BTA_FTS_MAX_AUTH_KEY_SIZE
-** p_userid must be less than OBX_MAX_REALM_LEN
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtsAuthRsp (char *p_password, char *p_userid)
-{
- tBTA_FTS_API_AUTHRSP *p_auth_rsp;
-
- if ((p_auth_rsp = (tBTA_FTS_API_AUTHRSP *)GKI_getbuf(sizeof(tBTA_FTS_API_AUTHRSP))) != NULL)
- {
- memset(p_auth_rsp, 0, sizeof(tBTA_FTS_API_AUTHRSP));
-
- p_auth_rsp->hdr.event = BTA_FTS_API_AUTHRSP_EVT;
-
- if (p_password)
- {
- p_auth_rsp->key_len = strlen(p_password);
- if (p_auth_rsp->key_len > BTA_FTS_MAX_AUTH_KEY_SIZE)
- p_auth_rsp->key_len = BTA_FTS_MAX_AUTH_KEY_SIZE;
- memcpy(p_auth_rsp->key, p_password, p_auth_rsp->key_len);
- }
-
- if (p_userid)
- {
- p_auth_rsp->userid_len = strlen(p_userid);
- if (p_auth_rsp->userid_len > OBX_MAX_REALM_LEN)
- p_auth_rsp->userid_len = OBX_MAX_REALM_LEN;
- memcpy(p_auth_rsp->userid, p_userid, p_auth_rsp->userid_len);
- }
-
- bta_sys_sendmsg(p_auth_rsp);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_FtsAccessRsp
-**
-** Description Sends a reply to an access request event (BTA_FTS_ACCESS_EVT).
-** This call MUST be made whenever the event occurs.
-**
-** Parameters oper - operation being accessed.
-** access - BTA_FT_ACCESS_ALLOW or BTA_FT_ACCESS_FORBID
-** p_name - Full path of file to pulled or pushed.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_FtsAccessRsp(tBTA_FT_OPER oper, tBTA_FT_ACCESS access, char *p_name)
-{
- tBTA_FTS_API_ACCESSRSP *p_acc_rsp;
-
- if ((p_acc_rsp = (tBTA_FTS_API_ACCESSRSP *)GKI_getbuf((UINT16)(sizeof(tBTA_FTS_API_ACCESSRSP)
- + p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- p_acc_rsp->flag = access;
- p_acc_rsp->oper = oper;
- p_acc_rsp->p_name = (char *)(p_acc_rsp + 1);
- if (p_name)
- {
- BCM_STRNCPY_S(p_acc_rsp->p_name, BTA_FS_PATH_LEN, p_name, p_bta_fs_cfg->max_path_len-1);
- p_acc_rsp->p_name[p_bta_fs_cfg->max_path_len-1] = '\0';
- }
- else
- *p_acc_rsp->p_name = '\0';
-
- p_acc_rsp->hdr.event = BTA_FTS_API_ACCESSRSP_EVT;
- bta_sys_sendmsg(p_acc_rsp);
- }
-}
-#endif /* BTA_FT_INCLUDED */
diff --git a/bta/ft/bta_fts_int.h b/bta/ft/bta_fts_int.h
deleted file mode 100644
index b77c96f..0000000
--- a/bta/ft/bta_fts_int.h
+++ /dev/null
@@ -1,287 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_fts_int.h
-**
-** Description: This is the private file for the file transfer
-** server (FTS).
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_FTS_INT_H
-#define BTA_FTS_INT_H
-
-#include "bt_target.h"
-#include "bta_sys.h"
-#include "obx_api.h"
-#include "bta_ft_api.h"
-#include "bta_fs_co.h"
-#include "bta_fs_ci.h"
-#include "bta_ftc_int.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-
-
-#define BTA_FTS_FOLDER_BROWSING_TARGET_UUID "\xF9\xEC\x7B\xC4\x95\x3C\x11\xD2\x98\x4E\x52\x54\x00\xDC\x9E\x09"
-#define BTA_FTS_UUID_LENGTH 16
-#define BTA_FTS_MAX_AUTH_KEY_SIZE 16 /* Must not be greater than OBX_MAX_AUTH_KEY_SIZE */
-
-#define BTA_FTS_DEFAULT_VERSION 0x0100
-#define BTA_FTS_FOLDER_LISTING_TYPE "x-obex/folder-listing"
-
-typedef tOBX_STATUS (tBTA_FTS_OBX_RSP) (tOBX_HANDLE handle, UINT8 rsp_code, BT_HDR *p_pkt);
-
-/* FTS Active ftp obex operation (Valid in connected state) */
-#define FTS_OP_NONE 0
-#define FTS_OP_LISTING 1
-#define FTS_OP_GET_FILE 2
-#define FTS_OP_PUT_FILE 3
-#define FTS_OP_DELETE 4 /* Folder or File */
-#define FTS_OP_CHDIR 5
-#define FTS_OP_MKDIR 6
-#define FTS_OP_RESUME 0x10
-
-/* state machine states */
-enum
-{
- BTA_FTS_IDLE_ST = 0, /* Idle */
- BTA_FTS_LISTEN_ST, /* Listen - waiting for OBX/RFC connection */
- BTA_FTS_W4_AUTH_ST, /* Wait for Authentication - (optional) */
- BTA_FTS_CONN_ST, /* Connected - FTP Session is active */
- BTA_FTS_CLOSING_ST /* Closing is in progress */
-};
-
-/* state machine events */
-enum
-{
- /* these events are handled by the state machine */
- BTA_FTS_API_DISABLE_EVT = BTA_SYS_EVT_START(BTA_ID_FTS),
-
- BTA_FTS_API_AUTHRSP_EVT, /* Response to password request */
- BTA_FTS_API_ACCESSRSP_EVT, /* Response to an access request */
- BTA_FTS_API_CLOSE_EVT, /* Disconnect the OBEX channel */
- BTA_FTS_CI_WRITE_EVT, /* Response to Write request */
- BTA_FTS_CI_READ_EVT, /* Response to Read request */
- BTA_FTS_CI_OPEN_EVT, /* Response to File Open request */
- BTA_FTS_CI_DIRENTRY_EVT, /* Response to a directory entry request */
- BTA_FTS_OBX_CONN_EVT, /* OBX Channel Connect Request */
- BTA_FTS_OBX_DISC_EVT, /* OBX Channel Disconnect */
- BTA_FTS_OBX_ABORT_EVT, /* OBX_operation aborted */
- BTA_FTS_OBX_PASSWORD_EVT, /* OBX password requested */
- BTA_FTS_OBX_CLOSE_EVT, /* OBX Channel Disconnected (Link Lost) */
- BTA_FTS_OBX_PUT_EVT, /* Write file data or delete */
- BTA_FTS_OBX_GET_EVT, /* Read file data or folder listing */
- BTA_FTS_OBX_SETPATH_EVT, /* Make or Change Directory */
- BTA_FTS_CI_SESSION_EVT, /* Call-in response to session requests */
- BTA_FTS_OBX_ACTION_EVT, /* Action command */
- BTA_FTS_APPL_TOUT_EVT, /* Timeout waiting for application */
- BTA_FTS_DISC_ERR_EVT, /* Sends OBX_DisconnectRsp with error code */
- BTA_FTS_GASP_ERR_EVT, /* Sends Err Resp to Get, Abort, Setpath, and Put */
- BTA_FTS_CLOSE_CMPL_EVT, /* Finished closing channel */
- BTA_FTS_DISABLE_CMPL_EVT, /* Finished disabling server */
-
- /* these events are handled outside the state machine */
- BTA_FTS_API_ENABLE_EVT
-};
-
-typedef UINT16 tBTA_FTS_INT_EVT;
-
-typedef UINT8 tBTA_FTS_STATE;
-
-/* data type for BTA_FTS_API_ENABLE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_FTS_CBACK *p_cback;
- char servicename[BTA_SERVICE_NAME_LEN + 1];
- char *p_root_path;
- UINT8 realm [OBX_MAX_REALM_LEN]; /* The realm is intended to be
- displayed to users so they know
- which userid and password to use.
- The first byte of the string is
- the character set of the string.
- */
- UINT8 realm_len;
- UINT8 sec_mask;
- UINT8 app_id;
- BOOLEAN auth_enabled;
-} tBTA_FTS_API_ENABLE;
-
-/* data type for BTA_FTS_API_AUTHRSP_EVT */
-typedef struct
-{
- BT_HDR hdr;
- UINT8 key [BTA_FTS_MAX_AUTH_KEY_SIZE]; /* The authentication key.*/
- UINT8 key_len;
- UINT8 userid [OBX_MAX_REALM_LEN]; /* The authentication user id.*/
- UINT8 userid_len;
-} tBTA_FTS_API_AUTHRSP;
-
-/* data type for BTA_FTS_API_ACCESSRSP_EVT */
-typedef struct
-{
- BT_HDR hdr;
- char *p_name;
- tBTA_FT_OPER oper;
- tBTA_FT_ACCESS flag;
-} tBTA_FTS_API_ACCESSRSP;
-
-/* data type for all obex events
- hdr.event contains the FTS event
-*/
-typedef struct
-{
- BT_HDR hdr;
- tOBX_HANDLE handle;
- tOBX_EVT_PARAM param;
- BT_HDR *p_pkt;
- tOBX_EVENT obx_event;
- UINT8 rsp_code;
-} tBTA_FTS_OBX_EVENT;
-
-/* union of all event data types */
-typedef union
-{
- BT_HDR hdr;
- tBTA_FTS_API_ENABLE api_enable;
- tBTA_FTS_API_AUTHRSP auth_rsp;
- tBTA_FTS_API_ACCESSRSP access_rsp;
- tBTA_FTS_OBX_EVENT obx_evt;
- tBTA_FS_CI_GETDIR_EVT getdir_evt;
- tBTA_FS_CI_OPEN_EVT open_evt;
- tBTA_FS_CI_RESUME_EVT resume_evt;
- tBTA_FS_CI_READ_EVT read_evt;
- tBTA_FS_CI_WRITE_EVT write_evt;
-} tBTA_FTS_DATA;
-
-
-/* OBX Response Packet Structure - Holds current response packet info */
-typedef struct
-{
- BT_HDR *p_pkt; /* (Get/Put) Holds the current OBX header for Put or Get */
- UINT8 *p_start; /* (Get/Put) Start of the Body of the packet */
- UINT16 offset; /* (Get/Put) Contains the current offset into the Body (p_start) */
- UINT16 bytes_left; /* (Get/Put) Holds bytes available left in Obx packet */
- BOOLEAN final_pkt; /* (Put) Holds the final bit of the Put packet */
-} tBTA_FTS_OBX_PKT;
-
-/* Directory Listing Information */
-typedef struct
-{
- tBTA_FS_DIRENTRY *p_entry; /* Holds current directory entry */
- BOOLEAN is_root; /* TRUE if path is root directory */
-} tBTA_FTS_DIRLIST;
-
-/* Power management state for FTS */
-#define BTA_FTS_PM_BUSY 0
-#define BTA_FTS_PM_IDLE 1
-
-/* FTS control block */
-typedef struct
-{
- tBTA_FTS_CBACK *p_cback; /* pointer to application callback function */
- char *p_name; /* Holds name of current operation */
- char *p_dest; /* Holds p_dest_name of current operation */
- char *p_path; /* Holds path of current operation */
- char *p_rootpath;
- char *p_workdir; /* Current working directory */
- tBTA_FTS_OBX_PKT obx; /* Holds the current OBX packet information */
- tBTA_FTS_DIRLIST dir; /* Holds current directory list information */
- UINT32 sdp_handle; /* SDP record handle */
- UINT32 file_length; /* length of file being PUT/GET */
- UINT8 sess_id[OBX_SESSION_ID_SIZE]; /* session id */
- int fd; /* File Descriptor of opened file */
- BD_ADDR bd_addr; /* Device currently connected to */
- tOBX_HANDLE obx_handle;
- UINT16 peer_mtu;
- UINT16 psm; /* PSM for Obex Over L2CAP */
- UINT8 perms[BTA_FS_PERM_SIZE]; /* the permission */
- UINT8 scn; /* SCN of the FTP server */
- tBTA_FTS_STATE state; /* state machine state */
- UINT8 obx_oper; /* current active OBX operation PUT FILE, GET FILE, LISTING, etc */
- UINT8 app_id;
- BOOLEAN auth_enabled; /* Is OBEX authentication enabled */
- BOOLEAN cout_active; /* TRUE when waiting for a call-in function */
- tBTA_FT_OPER acc_active; /* op code when waiting for an access rsp (API) (0 not active) */
- BOOLEAN suspending; /* TRUE when suspending session */
- UINT8 resume_ssn; /* the ssn for resume session */
- BOOLEAN disabling; /* TRUE when disabling server */
- UINT8 pm_state; /* power management state */
-} tBTA_FTS_CB;
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* FTS control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-extern tBTA_FTS_CB bta_fts_cb;
-#else
-extern tBTA_FTS_CB *bta_fts_cb_ptr;
-#define bta_fts_cb (*bta_fts_cb_ptr)
-#endif
-
-/* FT configuration constants */
-extern tBTA_FT_CFG * p_bta_ft_cfg;
-
-/*****************************************************************************
-** Function prototypes
-*****************************************************************************/
-
-extern BOOLEAN bta_fts_hdl_event(BT_HDR *p_msg);
-extern void bta_fts_sm_execute(tBTA_FTS_CB *p_cb, UINT16 event, tBTA_FTS_DATA *p_data);
-extern void bta_fts_sdp_register (tBTA_FTS_CB *p_cb, char *p_service_name);
-extern void bta_fts_obx_cback (tOBX_HANDLE handle, tOBX_EVENT event,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt);
-
-/* action functions */
-extern void bta_fts_api_disable(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_api_authrsp(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_api_accessrsp(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_api_close(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_ci_write(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_ci_read(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_ci_open(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_ci_resume(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_ci_direntry(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_obx_connect(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_obx_disc(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_obx_close(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_obx_abort(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_obx_password(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_obx_put(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_obx_get(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_obx_setpath(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_obx_action(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_appl_tout(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_conn_err_rsp(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_disc_err_rsp(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_gasp_err_rsp(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_close_complete(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_disable_cmpl(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-extern void bta_fts_session_req(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-
-/* object store */
-extern UINT8 bta_fts_mkdir(BT_HDR *p_pkt, tBTA_FT_OPER *p_op);
-extern UINT8 bta_fts_chdir(BT_HDR *p_pkt, BOOLEAN backup_flag, tBTA_FT_OPER *p_op);
-extern void bta_fts_getdirlist(char *p_name);
-extern void bta_fts_proc_get_file(char *p_name);
-extern void bta_fts_proc_put_file(BT_HDR *p_pkt, char *p_name, BOOLEAN final_pkt, UINT8 oper);
-extern void bta_fts_delete(tBTA_FTS_OBX_EVENT *p_evt, const char *p);
-extern void bta_fts_req_app_access (tBTA_FT_OPER oper, tBTA_FTS_CB *p_cb);
-
-/* miscellaneous functions */
-extern void bta_fts_get_file_rsp(UINT8 rsp_code, UINT16 num_read);
-extern void bta_fts_put_file_rsp(UINT8 rsp_code);
-extern void bta_fts_end_of_list(UINT8 rsp_code);
-extern UINT8 bta_fts_add_list_entry(void);
-extern void bta_fts_clean_list(tBTA_FTS_CB *p_cb);
-extern void bta_fts_clean_getput(tBTA_FTS_CB *p_cb, BOOLEAN is_aborted);
-extern void bta_fts_disable_cleanup(tBTA_FTS_CB *p_cb);
-extern void bta_fts_discard_data(UINT16 event, tBTA_FTS_DATA *p_data);
-
-#endif /* BTA_FTS_INT_H */
diff --git a/bta/ft/bta_fts_main.c b/bta/ft/bta_fts_main.c
deleted file mode 100644
index 67be954..0000000
--- a/bta/ft/bta_fts_main.c
+++ /dev/null
@@ -1,603 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_fts_main.c
-**
-** Description: This file contains the file transfer server main functions
-** and state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "bt_target.h"
-#if defined(BTA_FT_INCLUDED) && (BTA_FT_INCLUDED == TRUE)
-
-#include "bta_fs_api.h"
-#include "bta_fts_int.h"
-#include "gki.h"
-#include "utl.h"
-#include "obx_api.h"
-#include "rfcdefs.h" /* BT_PSM_RFCOMM */
-
-/*****************************************************************************
-** Constants and types
-*****************************************************************************/
-
-
-/* state machine action enumeration list */
-enum
-{
- BTA_FTS_API_DISABLE,
- BTA_FTS_API_AUTHRSP,
- BTA_FTS_API_ACCESSRSP,
- BTA_FTS_API_CLOSE,
- BTA_FTS_CI_WRITE,
- BTA_FTS_CI_READ,
- BTA_FTS_CI_OPEN,
- BTA_FTS_CI_DIRENTRY,
- BTA_FTS_OBX_CONNECT,
- BTA_FTS_OBX_DISC,
- BTA_FTS_OBX_CLOSE,
- BTA_FTS_OBX_ABORT,
- BTA_FTS_OBX_PASSWORD,
- BTA_FTS_OBX_PUT,
- BTA_FTS_OBX_GET,
- BTA_FTS_OBX_SETPATH,
- BTA_FTS_CI_RESUME,
- BTA_FTS_OBX_ACTION,
- BTA_FTS_SESSION_REQ,
- BTA_FTS_APPL_TOUT,
- BTA_FTS_CONN_ERR_RSP,
- BTA_FTS_DISC_ERR_RSP,
- BTA_FTS_GASP_ERR_RSP,
- BTA_FTS_CLOSE_COMPLETE,
- BTA_FTS_DISABLE_CMPL,
- BTA_FTS_IGNORE
-};
-
-/* type for action functions */
-typedef void (*tBTA_FTS_ACTION)(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data);
-
-/* action function list */
-const tBTA_FTS_ACTION bta_fts_action[] =
-{
- bta_fts_api_disable,
- bta_fts_api_authrsp,
- bta_fts_api_accessrsp,
- bta_fts_api_close,
- bta_fts_ci_write,
- bta_fts_ci_read,
- bta_fts_ci_open,
- bta_fts_ci_direntry,
- bta_fts_obx_connect,
- bta_fts_obx_disc,
- bta_fts_obx_close,
- bta_fts_obx_abort,
- bta_fts_obx_password,
- bta_fts_obx_put,
- bta_fts_obx_get,
- bta_fts_obx_setpath,
- bta_fts_ci_resume,
- bta_fts_obx_action,
- bta_fts_session_req,
- bta_fts_appl_tout,
- bta_fts_conn_err_rsp,
- bta_fts_disc_err_rsp,
- bta_fts_gasp_err_rsp,
- bta_fts_close_complete,
- bta_fts_disable_cmpl
-};
-
-
-/* state table information */
-#define BTA_FTS_ACTIONS 1 /* number of actions */
-#define BTA_FTS_NEXT_STATE 1 /* position of next state */
-#define BTA_FTS_NUM_COLS 2 /* number of columns in state tables */
-
-/* state table for idle state */
-static const UINT8 bta_fts_st_idle[][BTA_FTS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_FTS_API_ENABLE_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_API_AUTHRSP_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_API_ACCESSRSP_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_API_CLOSE_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_CI_WRITE_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_CI_READ_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_CI_OPEN_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_CI_DIRENTRY_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_OBX_CONN_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_OBX_DISC_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_OBX_ABORT_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_OBX_PASSWORD_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_OBX_CLOSE_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_OBX_PUT_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_OBX_GET_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_OBX_SETPATH_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_CI_SESSION_EVT */ {BTA_FTS_CI_RESUME, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_OBX_ACTION_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_APPL_TOUT_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_DISC_ERR_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_GASP_ERR_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_CLOSE_CMPL_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST},
-/* BTA_FTS_DISABLE_CMPL_EVT */ {BTA_FTS_IGNORE, BTA_FTS_IDLE_ST}
-};
-
-/* state table for obex/rfcomm connection state */
-static const UINT8 bta_fts_st_listen[][BTA_FTS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_FTS_API_DISABLE_EVT */ {BTA_FTS_API_DISABLE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_API_AUTHRSP_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_API_ACCESSRSP_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_API_CLOSE_EVT */ {BTA_FTS_API_CLOSE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_CI_WRITE_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_CI_READ_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_CI_OPEN_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_CI_DIRENTRY_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_OBX_CONN_EVT */ {BTA_FTS_OBX_CONNECT, BTA_FTS_CONN_ST},
-/* BTA_FTS_OBX_DISC_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_OBX_ABORT_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_OBX_PASSWORD_EVT */ {BTA_FTS_OBX_PASSWORD, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_OBX_CLOSE_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_OBX_PUT_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_OBX_GET_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_OBX_SETPATH_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_CI_SESSION_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_OBX_ACTION_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_APPL_TOUT_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_DISC_ERR_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_GASP_ERR_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_CLOSE_CMPL_EVT */ {BTA_FTS_IGNORE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_DISABLE_CMPL_EVT */ {BTA_FTS_DISABLE_CMPL, BTA_FTS_IDLE_ST}
-};
-
-/* state table for wait for authentication response state */
-static const UINT8 bta_fts_st_w4_auth[][BTA_FTS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_FTS_API_DISABLE_EVT */ {BTA_FTS_API_DISABLE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_API_AUTHRSP_EVT */ {BTA_FTS_API_AUTHRSP, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_API_ACCESSRSP_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_API_CLOSE_EVT */ {BTA_FTS_API_CLOSE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_CI_WRITE_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_CI_READ_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_CI_OPEN_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_CI_DIRENTRY_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_OBX_CONN_EVT */ {BTA_FTS_CONN_ERR_RSP, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_OBX_DISC_EVT */ {BTA_FTS_OBX_DISC, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_OBX_ABORT_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_OBX_PASSWORD_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_OBX_CLOSE_EVT */ {BTA_FTS_OBX_CLOSE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_OBX_PUT_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_OBX_GET_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_OBX_SETPATH_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_CI_SESSION_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_OBX_ACTION_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_APPL_TOUT_EVT */ {BTA_FTS_APPL_TOUT, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_DISC_ERR_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_GASP_ERR_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_CLOSE_CMPL_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_DISABLE_CMPL_EVT */ {BTA_FTS_DISABLE_CMPL, BTA_FTS_IDLE_ST}
-};
-
-/* state table for open state */
-static const UINT8 bta_fts_st_connected[][BTA_FTS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_FTS_API_DISABLE_EVT */ {BTA_FTS_API_DISABLE, BTA_FTS_CONN_ST},
-/* BTA_FTS_API_AUTHRSP_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CONN_ST},
-/* BTA_FTS_API_ACCESSRSP_EVT */ {BTA_FTS_API_ACCESSRSP, BTA_FTS_CONN_ST},
-/* BTA_FTS_API_CLOSE_EVT */ {BTA_FTS_API_CLOSE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_CI_WRITE_EVT */ {BTA_FTS_CI_WRITE, BTA_FTS_CONN_ST},
-/* BTA_FTS_CI_READ_EVT */ {BTA_FTS_CI_READ, BTA_FTS_CONN_ST},
-/* BTA_FTS_CI_OPEN_EVT */ {BTA_FTS_CI_OPEN, BTA_FTS_CONN_ST},
-/* BTA_FTS_CI_DIRENTRY_EVT */ {BTA_FTS_CI_DIRENTRY, BTA_FTS_CONN_ST},
-/* BTA_FTS_OBX_CONN_EVT */ {BTA_FTS_SESSION_REQ, BTA_FTS_CONN_ST},
-/* BTA_FTS_OBX_DISC_EVT */ {BTA_FTS_OBX_DISC, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_OBX_ABORT_EVT */ {BTA_FTS_OBX_ABORT, BTA_FTS_CONN_ST},
-/* BTA_FTS_OBX_PASSWORD_EVT */ {BTA_FTS_IGNORE, BTA_FTS_W4_AUTH_ST},
-/* BTA_FTS_OBX_CLOSE_EVT */ {BTA_FTS_OBX_CLOSE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_OBX_PUT_EVT */ {BTA_FTS_OBX_PUT, BTA_FTS_CONN_ST},
-/* BTA_FTS_OBX_GET_EVT */ {BTA_FTS_OBX_GET, BTA_FTS_CONN_ST},
-/* BTA_FTS_OBX_SETPATH_EVT */ {BTA_FTS_OBX_SETPATH, BTA_FTS_CONN_ST},
-/* BTA_FTS_CI_SESSION_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CONN_ST},
-/* BTA_FTS_OBX_ACTION_EVT */ {BTA_FTS_OBX_ACTION, BTA_FTS_CONN_ST},
-/* BTA_FTS_APPL_TOUT_EVT */ {BTA_FTS_APPL_TOUT, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_DISC_ERR_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CONN_ST},
-/* BTA_FTS_GASP_ERR_EVT */ {BTA_FTS_GASP_ERR_RSP, BTA_FTS_CONN_ST},
-/* BTA_FTS_CLOSE_CMPL_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CONN_ST},
-/* BTA_FTS_DISABLE_CMPL_EVT */ {BTA_FTS_DISABLE_CMPL, BTA_FTS_IDLE_ST}
-};
-
-/* state table for closing state */
-static const UINT8 bta_fts_st_closing[][BTA_FTS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_FTS_API_DISABLE_EVT */ {BTA_FTS_API_DISABLE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_API_AUTHRSP_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_API_ACCESSRSP_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_API_CLOSE_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_CI_WRITE_EVT */ {BTA_FTS_CLOSE_COMPLETE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_CI_READ_EVT */ {BTA_FTS_CLOSE_COMPLETE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_CI_OPEN_EVT */ {BTA_FTS_CLOSE_COMPLETE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_CI_DIRENTRY_EVT */ {BTA_FTS_CLOSE_COMPLETE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_OBX_CONN_EVT */ {BTA_FTS_SESSION_REQ, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_OBX_DISC_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_OBX_ABORT_EVT */ {BTA_FTS_OBX_ABORT, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_OBX_PASSWORD_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_OBX_CLOSE_EVT */ {BTA_FTS_OBX_CLOSE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_OBX_PUT_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_OBX_GET_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_OBX_SETPATH_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_CI_SESSION_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_OBX_ACTION_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_APPL_TOUT_EVT */ {BTA_FTS_IGNORE, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_DISC_ERR_EVT */ {BTA_FTS_DISC_ERR_RSP, BTA_FTS_CONN_ST},
-/* BTA_FTS_GASP_ERR_EVT */ {BTA_FTS_GASP_ERR_RSP, BTA_FTS_CLOSING_ST},
-/* BTA_FTS_CLOSE_CMPL_EVT */ {BTA_FTS_CLOSE_COMPLETE, BTA_FTS_LISTEN_ST},
-/* BTA_FTS_DISABLE_CMPL_EVT */ {BTA_FTS_DISABLE_CMPL, BTA_FTS_IDLE_ST}
-};
-
-/* type for state table */
-typedef const UINT8 (*tBTA_FTS_ST_TBL)[BTA_FTS_NUM_COLS];
-
-/* state table */
-const tBTA_FTS_ST_TBL bta_fts_st_tbl[] =
-{
- bta_fts_st_idle,
- bta_fts_st_listen,
- bta_fts_st_w4_auth,
- bta_fts_st_connected,
- bta_fts_st_closing
-};
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* FTS control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-tBTA_FTS_CB bta_fts_cb;
-#endif
-
-#if BTA_FTS_DEBUG == TRUE
-static char *fts_evt_code(tBTA_FTS_INT_EVT evt_code);
-static char *fts_state_code(tBTA_FTS_STATE state_code);
-#endif
-
-/*******************************************************************************
-**
-** Function bta_fts_sm_execute
-**
-** Description State machine event handling function for FTS
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_sm_execute(tBTA_FTS_CB *p_cb, UINT16 event, tBTA_FTS_DATA *p_data)
-{
- tBTA_FTS_ST_TBL state_table;
- UINT8 action;
- int i;
-#if BTA_FTS_DEBUG == TRUE
- tBTA_FTS_STATE in_state = bta_fts_cb.state;
- UINT16 in_event = event;
- APPL_TRACE_EVENT3("FTS Event : State 0x%02x [%s], Event [%s]", in_state,
- fts_state_code(in_state),
- fts_evt_code(event));
-#endif
-
- /* look up the state table for the current state */
- state_table = bta_fts_st_tbl[p_cb->state];
-
- event &= 0x00FF;
-
- /* set next state */
- p_cb->state = state_table[event][BTA_FTS_NEXT_STATE];
-
- /* execute action functions */
- for (i = 0; i < BTA_FTS_ACTIONS; i++)
- {
- if ((action = state_table[event][i]) != BTA_FTS_IGNORE)
- {
- (*bta_fts_action[action])(p_cb, p_data);
- }
- else
- {
- /* discard fts data */
- bta_fts_discard_data(p_data->hdr.event, p_data);
- break;
- }
- }
-
-#if BTA_FTS_DEBUG == TRUE
- if (in_state != bta_fts_cb.state)
- {
- APPL_TRACE_DEBUG3("FTS State Change: [%s] -> [%s] after Event [%s]",
- fts_state_code(in_state),
- fts_state_code(bta_fts_cb.state),
- fts_evt_code(in_event));
- }
-#endif
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_api_enable
-**
-** Description Handle an api enable event. This function enables the FT
-** Server by opening an Obex/Rfcomm channel and placing it into
-** listen mode.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_fts_api_enable(tBTA_FTS_CB *p_cb, tBTA_FTS_DATA *p_data)
-{
- tOBX_StartParams start_msg;
- tBTA_FTS_API_ENABLE *p_api = &p_data->api_enable;
- tOBX_TARGET target;
- UINT16 len;
- tOBX_STATUS status;
- UINT16 mtu = OBX_MAX_MTU;
-
- /* initialize control block */
- memset(p_cb, 0, sizeof(tBTA_FTS_CB));
-
- /* Allocate an aligned memory buffer to hold the root path and working directory */
- /* Add 1 byte for '\0' */
- len = p_bta_fs_cfg->max_path_len + 1;
- if ((p_cb->p_rootpath = (char *)GKI_getbuf((UINT16)(len * 2))) != NULL)
- {
- p_cb->p_workdir = p_cb->p_rootpath + len;
- memcpy(target.target, BTA_FTS_FOLDER_BROWSING_TARGET_UUID, BTA_FTS_UUID_LENGTH);
- target.len = BTA_FTS_UUID_LENGTH;
-
- /* store parameters */
- p_cb->app_id = p_api->app_id;
- p_cb->p_cback = p_api->p_cback;
- p_cb->scn = BTM_AllocateSCN();
-
- if (p_bta_ft_cfg->over_l2cap)
- {
- p_cb->psm = L2CA_AllocatePSM();
- BTM_SetSecurityLevel (FALSE, p_api->servicename, BTM_SEC_SERVICE_OBEX_FTP,
- p_api->sec_mask, p_cb->psm,
- 0, 0);
- }
-
- p_cb->auth_enabled = p_api->auth_enabled;
-
- p_cb->fd = BTA_FS_INVALID_FD;
- /* Initialize the current working directory to be the root directory */
- BCM_STRNCPY_S(p_cb->p_rootpath, len, p_api->p_root_path, len-1);
- BCM_STRNCPY_S(p_cb->p_workdir, len, p_api->p_root_path, len-1);
-
- /* Register FTP security requirements with BTM */
- BTM_SetSecurityLevel(FALSE, p_api->servicename, BTM_SEC_SERVICE_OBEX_FTP,
- p_api->sec_mask, BT_PSM_RFCOMM,
- BTM_SEC_PROTO_RFCOMM, (UINT32)p_cb->scn);
-
- /* Start up the FTP service */
- memset (&start_msg, 0, sizeof(tOBX_StartParams));
- start_msg.p_target = &target;
-
- /* Make the MTU fit into one RFC frame */
- start_msg.mtu = mtu;
- start_msg.scn = p_cb->scn;
- start_msg.psm = p_cb->psm;
- start_msg.srm = p_bta_ft_cfg->srm;
- start_msg.nonce = p_bta_ft_cfg->nonce;
- start_msg.max_suspend = p_bta_ft_cfg->max_suspend;
- start_msg.authenticate = p_cb->auth_enabled;
-
- start_msg.auth_option = (p_bta_ft_cfg->userid_req) ? OBX_AO_USR_ID : OBX_AO_NONE;
- start_msg.p_cback = bta_fts_obx_cback;
-
- start_msg.realm_len = p_api->realm_len;
- start_msg.p_realm = p_api->realm;
- start_msg.realm_charset = (tOBX_CHARSET) p_bta_ft_cfg->realm_charset;
-
- if ((status = OBX_StartServer (&start_msg, &p_cb->obx_handle)) == OBX_SUCCESS)
- {
- /* Set up the SDP record for file transfer service */
- bta_fts_sdp_register(p_cb, p_api->servicename);
-
- if (start_msg.nonce)
- {
- bta_fs_co_resume (BTA_FTS_CI_SESSION_EVT, p_cb->app_id);
- }
- else
- {
- p_data->resume_evt.status = BTA_FS_CO_FAIL;
- bta_fts_ci_resume(p_cb, p_data);
- }
- }
- else
- APPL_TRACE_ERROR1("OBX_StartServer returns error (%d)", status);
- }
- else /* Cannot allocate resources to run Server */
- APPL_TRACE_ERROR0("Not enough Resources to run FTP Server");
-
- p_cb->p_cback(BTA_FTS_ENABLE_EVT, 0);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_hdl_event
-**
-** Description File transfer server main event handling function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BOOLEAN bta_fts_hdl_event(BT_HDR *p_msg)
-{
-#if BTA_FTS_DEBUG == TRUE
- tBTA_FTS_STATE in_state = bta_fts_cb.state;
-#endif
-
- switch (p_msg->event)
- {
- case BTA_FTS_API_ENABLE_EVT:
-#if BTA_FTS_DEBUG == TRUE
- APPL_TRACE_EVENT3("FTS Event Handler: State 0x%02x [%s], Event [%s]", in_state,
- fts_state_code(in_state),
- fts_evt_code(p_msg->event));
-#endif
- bta_fts_api_enable(&bta_fts_cb, (tBTA_FTS_DATA *) p_msg);
-
-#if BTA_FTS_DEBUG == TRUE
- if (in_state != bta_fts_cb.state)
- {
- APPL_TRACE_DEBUG3("FTS State Change: [%s] -> [%s] after Event [%s]",
- fts_state_code(in_state),
- fts_state_code(bta_fts_cb.state),
- fts_evt_code(p_msg->event));
- }
-#endif
- break;
-
- default:
-
- bta_fts_sm_execute(&bta_fts_cb, p_msg->event, (tBTA_FTS_DATA *) p_msg);
-
- if ( bta_fts_cb.state == BTA_FTS_CONN_ST )
- {
- if (( bta_fts_cb.pm_state == BTA_FTS_PM_IDLE )
- &&( bta_fts_cb.obx_oper != FTS_OP_NONE ))
- {
- /* inform power manager */
- APPL_TRACE_DEBUG0("BTA FTS informs DM/PM busy state");
- bta_sys_busy( BTA_ID_FTS ,bta_fts_cb.app_id, bta_fts_cb.bd_addr);
- bta_fts_cb.pm_state = BTA_FTS_PM_BUSY;
- }
- else if (( bta_fts_cb.pm_state == BTA_FTS_PM_BUSY )
- &&( bta_fts_cb.obx_oper == FTS_OP_NONE ))
- {
- /* inform power manager */
- APPL_TRACE_DEBUG0("BTA FTS informs DM/PM idle state");
- bta_sys_idle( BTA_ID_FTS ,bta_fts_cb.app_id, bta_fts_cb.bd_addr);
- bta_fts_cb.pm_state = BTA_FTS_PM_IDLE;
- }
- }
- else if ( bta_fts_cb.state == BTA_FTS_LISTEN_ST )
- {
- /* initialize power management state */
- bta_fts_cb.pm_state = BTA_FTS_PM_BUSY;
- }
-
- break;
- }
-
- return (TRUE);
-}
-
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if BTA_FTS_DEBUG == TRUE
-
-/*******************************************************************************
-**
-** Function fts_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *fts_evt_code(tBTA_FTS_INT_EVT evt_code)
-{
- switch(evt_code)
- {
- case BTA_FTS_API_DISABLE_EVT:
- return "BTA_FTS_API_DISABLE_EVT";
- case BTA_FTS_API_AUTHRSP_EVT:
- return "BTA_FTS_API_AUTHRSP_EVT";
- case BTA_FTS_API_ACCESSRSP_EVT:
- return "BTA_FTS_API_ACCESSRSP_EVT";
- case BTA_FTS_API_CLOSE_EVT:
- return "BTA_FTS_API_CLOSE_EVT";
- case BTA_FTS_CI_WRITE_EVT:
- return "BTA_FTS_CI_WRITE_EVT";
- case BTA_FTS_CI_READ_EVT:
- return "BTA_FTS_CI_READ_EVT";
- case BTA_FTS_CI_OPEN_EVT:
- return "BTA_FTS_CI_OPEN_EVT";
- case BTA_FTS_CI_DIRENTRY_EVT:
- return "BTA_FTS_CI_DIRENTRY_EVT";
- case BTA_FTS_OBX_CONN_EVT:
- return "BTA_FTS_OBX_CONN_EVT";
- case BTA_FTS_OBX_DISC_EVT:
- return "BTA_FTS_OBX_DISC_EVT";
- case BTA_FTS_OBX_ABORT_EVT:
- return "BTA_FTS_OBX_ABORT_EVT";
- case BTA_FTS_OBX_PASSWORD_EVT:
- return "BTA_FTS_OBX_PASSWORD_EVT";
- case BTA_FTS_OBX_CLOSE_EVT:
- return "BTA_FTS_OBX_CLOSE_EVT";
- case BTA_FTS_OBX_PUT_EVT:
- return "BTA_FTS_OBX_PUT_EVT";
- case BTA_FTS_OBX_GET_EVT:
- return "BTA_FTS_OBX_GET_EVT";
- case BTA_FTS_OBX_SETPATH_EVT:
- return "BTA_FTS_OBX_SETPATH_EVT";
- case BTA_FTS_OBX_ACTION_EVT:
- return "BTA_FTS_OBX_ACTION_EVT";
- case BTA_FTS_CI_SESSION_EVT:
- return "BTA_FTS_CI_SESSION_EVT";
- case BTA_FTS_APPL_TOUT_EVT:
- return "BTA_FTS_APPL_TOUT_EVT";
- case BTA_FTS_DISC_ERR_EVT:
- return "BTA_FTS_DISC_ERR_EVT";
- case BTA_FTS_GASP_ERR_EVT:
- return "BTA_FTS_GASP_ERR_EVT";
- case BTA_FTS_API_ENABLE_EVT:
- return "BTA_FTS_API_ENABLE_EVT";
- case BTA_FTS_CLOSE_CMPL_EVT:
- return "BTA_FTS_CLOSE_CMPL_EVT";
- case BTA_FTS_DISABLE_CMPL_EVT:
- return "BTA_FTS_DISABLE_CMPL_EVT";
- default:
- return "unknown FTS event code";
- }
-}
-
-/*******************************************************************************
-**
-** Function fts_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *fts_state_code(tBTA_FTS_STATE state_code)
-{
- switch(state_code)
- {
- case BTA_FTS_IDLE_ST:
- return "BTA_FTS_IDLE_ST";
- case BTA_FTS_LISTEN_ST:
- return "BTA_FTS_LISTEN_ST";
- case BTA_FTS_W4_AUTH_ST:
- return "BTA_FTS_W4_AUTH_ST";
- case BTA_FTS_CONN_ST:
- return "BTA_FTS_CONN_ST";
- case BTA_FTS_CLOSING_ST:
- return "BTA_FTS_CLOSING_ST";
- default:
- return "unknown FTS state code";
- }
-}
-
-#endif /* Debug Functions */
-#endif /* BTA_FT_INCLUDED */
diff --git a/bta/ft/bta_fts_sdp.c b/bta/ft/bta_fts_sdp.c
deleted file mode 100644
index 2613942..0000000
--- a/bta/ft/bta_fts_sdp.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_fts_sdp.c
-**
-** File: Implements the SDP functions used by File Transfer Server
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <string.h>
-
-#include "sdp_api.h"
-#include "bta_fts_int.h"
-#include "goep_util.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-
-/*****************************************************************************
-**
-** Function: bta_fts_sdp_register()
-**
-** Purpose: Registers the File Transfer service with SDP
-**
-** Parameters:
-**
-**
-** Returns: void
-**
-*****************************************************************************/
-void bta_fts_sdp_register (tBTA_FTS_CB *p_cb, char *p_service_name)
-{
- UINT16 ftp_service = UUID_SERVCLASS_OBEX_FILE_TRANSFER;
- tGOEP_ERRORS status = GOEP_ERROR;
- UINT16 version = BTA_FTS_DEFAULT_VERSION;
- UINT8 temp[4], *p;
-
- if (p_bta_ft_cfg->over_l2cap)
- {
- version = BTA_FT_ENHANCED_VERSION;
- }
- status = GOEP_Register (p_service_name, &p_cb->sdp_handle, p_cb->scn, 1, &ftp_service,
- ftp_service, version);
-
- if (status == GOEP_SUCCESS)
- {
- if (p_bta_ft_cfg->over_l2cap)
- {
- /* add the psm */
- p = temp;
- UINT16_TO_BE_STREAM(p, p_cb->psm);
- SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_OBX_OVR_L2CAP_PSM, UINT_DESC_TYPE,
- (UINT32)2, (UINT8*)temp);
- }
-
-
- bta_sys_add_uuid(ftp_service); /* UUID_SERVCLASS_OBEX_FILE_TRANSFER */
- APPL_TRACE_DEBUG1("FTS: SDP Registered (handle 0x%08x)", p_cb->sdp_handle);
- }
-
- return;
-}
diff --git a/bta/ft/bta_fts_utils.c b/bta/ft/bta_fts_utils.c
deleted file mode 100644
index f689752..0000000
--- a/bta/ft/bta_fts_utils.c
+++ /dev/null
@@ -1,972 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_fts_utils.c
-**
-** Description: This file implements object store functions for the
-** file transfer server.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_FT_INCLUDED) && (BTA_FT_INCLUDED == TRUE)
-
-#include <stdio.h>
-#include <string.h>
-#include "bta_fs_api.h"
-#include "bta_fts_int.h"
-#include "bta_fs_co.h"
-#include "gki.h"
-#include "utl.h"
-
-/*******************************************************************************
-** Constants
-*******************************************************************************/
-
-/*******************************************************************************
-** Local Function Prototypes
-*******************************************************************************/
-
-/*******************************************************************************
-* Macros for FTS
-*******************************************************************************/
-#define BTA_FTS_XML_EOL "\n"
-#define BTA_FTS_FOLDER_LISTING_START ( "<?xml version=\"1.0\"?>\n" \
- "<!DOCTYPE folder-listing SYSTEM \"obex-folder-listing.dtd\">\n" \
- "<folder-listing version=\"1.0\">\n" )
-
-#define BTA_FTS_FOLDER_LISTING_END ( "</folder-listing>" )
-#define BTA_FTS_PARENT_FOLDER (" <parent-folder/>\n")
-
-#define BTA_FTS_FILE_ELEM "file"
-#define BTA_FTS_FOLDER_ELEM "folder"
-#define BTA_FTS_NAME_ATTR "name"
-#define BTA_FTS_SIZE_ATTR "size"
-#define BTA_FTS_TYPE_ATTR "type"
-#define BTA_FTS_MODIFIED_ATTR "modified"
-#define BTA_FTS_CREATED_ATTR "created"
-#define BTA_FTS_ACCESSED_ATTR "accessed"
-#define BTA_FTS_USER_PERM_ATTR "user-perm"
-
-/*******************************************************************************
-* Exported Functions
-*******************************************************************************/
-/*******************************************************************************
-**
-** Function bta_fts_getdirlist
-**
-** Description Processes the retrieval of a directory listing.
-**
-** Parameters p_pkt - Pointer to the OBX Get request
-** name directory to list.
-**
-**
-** Returns UINT8 - OBX response code. OBX_RSP_OK if initiated.
-**
-*******************************************************************************/
-void bta_fts_getdirlist(char *p_name)
-{
- tBTA_FTS_CB *p_cb = &bta_fts_cb;
- tBTA_FTS_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FTS_DIRLIST *p_dir = &p_cb->dir;
- UINT16 temp_len;
- BOOLEAN is_dir;
- UINT8 rsp_code = OBX_RSP_OK;
-
- if (!p_cb->p_path)
- p_cb->p_path = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1));
- if (p_cb->p_path)
- {
- /* If not specified, use the current work directory */
- if (!p_name || p_name[0] == '\0')
- {
- p_cb->p_path[p_bta_fs_cfg->max_path_len] = 0;
- BCM_STRNCPY_S(p_cb->p_path, (p_bta_fs_cfg->max_path_len + 1), p_cb->p_workdir, p_bta_fs_cfg->max_path_len);
- }
- else
- {
- if ((strlen(p_cb->p_workdir) + strlen(p_name) + 2) <= p_bta_fs_cfg->max_path_len)
- {
- sprintf(p_cb->p_path, "%s%c%s", p_cb->p_workdir,
- p_bta_fs_cfg->path_separator, p_name);
-
- /* Make sure the Name is a directory and accessible */
- if (((bta_fs_co_access(p_cb->p_path, BTA_FS_ACC_EXIST,
- &is_dir, p_cb->app_id))!= BTA_FS_CO_OK)
- || !is_dir)
- rsp_code = OBX_RSP_NOT_FOUND;
- }
- else
- rsp_code = OBX_RSP_BAD_REQUEST;
- }
-
- /* Build the listing */
- if (rsp_code == OBX_RSP_OK)
- {
- if (!(strcmp(p_cb->p_path, p_cb->p_rootpath)))
- p_dir->is_root = TRUE;
- else
- p_dir->is_root = FALSE;
-
- p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle, p_cb->peer_mtu);
-
- if (!p_dir->p_entry)
- {
- /* Allocate enough space for the structure and the file name */
- if ((p_dir->p_entry = (tBTA_FS_DIRENTRY *)
- GKI_getbuf((UINT16)(sizeof(tBTA_FS_DIRENTRY) +
- p_bta_fs_cfg->max_file_len + 1))) != NULL)
- p_dir->p_entry->p_name = (char *)(p_dir->p_entry + 1);
- }
-
- if (p_dir->p_entry && p_obx->p_pkt)
- {
- /* Add the start of the Body Header */
- p_obx->offset = 0;
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
-
- /* Is this a new request or continuation? */
- if ((p_cb->obx_oper == FTS_OP_NONE))
- {
- p_cb->obx_oper = FTS_OP_LISTING;
- APPL_TRACE_EVENT1("FTS List Directory: Name [%s]", p_cb->p_path);
-
- temp_len = strlen(BTA_FTS_FOLDER_LISTING_START);
-
- /* Add the beginning label of http */
- memcpy(p_obx->p_start, BTA_FTS_FOLDER_LISTING_START, temp_len);
- p_obx->bytes_left -= (UINT16)(temp_len + strlen(BTA_FTS_FOLDER_LISTING_END));
- p_obx->offset += temp_len;
-
- /* Add the parent directory if not the root */
- if (strcmp(p_cb->p_path, p_cb->p_rootpath))
- {
- temp_len = strlen(BTA_FTS_PARENT_FOLDER);
- memcpy(p_obx->p_start + p_obx->offset,
- BTA_FTS_PARENT_FOLDER, temp_len);
- p_obx->bytes_left -= temp_len;
- p_obx->offset += temp_len;
- }
-
- p_cb->cout_active = TRUE;
- bta_fs_co_getdirentry (p_cb->p_path, TRUE, p_dir->p_entry,
- BTA_FTS_CI_DIRENTRY_EVT, p_cb->app_id);
-
- /* List is not complete, so don't send the response yet */
- rsp_code = OBX_RSP_PART_CONTENT;
- }
- else /* Add the entry previously retrieved */
- rsp_code = bta_fts_add_list_entry();
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- }
- else /* Error occurred */
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
-
- /* Response goes out if complete or error occurred */
- if (rsp_code != OBX_RSP_PART_CONTENT)
- bta_fts_end_of_list(rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_proc_get_file
-**
-** Description Processes a Get File Operation.
-** If first OBX request, the file is opened, otherwise if it is
-** a continuation the next read is initiated.
-**
-** Parameters p_pkt - Pointer to the OBX Get request
-** name of file to read.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_proc_get_file(char *p_name)
-{
- tBTA_FTS_CB *p_cb = &bta_fts_cb;
- tBTA_FTS_OBX_PKT *p_obx = &p_cb->obx;
- UINT8 rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
-
- p_obx->offset = 0;
-
- /* Allocate an OBX packet */
- if ((p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle,
- p_cb->peer_mtu)) != NULL)
- {
- /* Is this a new request or continuation? */
- if ((p_cb->obx_oper == FTS_OP_NONE))
- {
- /* Validate the name */
- if (p_name)
- {
- if ((p_cb->p_path =
- (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- /* Build a fully qualified path */
- if ((strlen(p_cb->p_workdir) + strlen(p_name) + 2)
- <= p_bta_fs_cfg->max_path_len)
- {
- rsp_code = OBX_RSP_OK;
- sprintf(p_cb->p_path, "%s%c%s", p_cb->p_workdir,
- p_bta_fs_cfg->path_separator, p_name);
-
- APPL_TRACE_EVENT1("FTS GET FILE: Name [%s]", p_cb->p_path);
-
- p_cb->obx_oper = FTS_OP_GET_FILE;
-
- /* Notify the application that a get file has been requested */
- bta_fts_req_app_access (BTA_FT_OPER_GET, p_cb);
- }
- }
- }
- }
- else /* Continue reading from the file */
- {
- /* Add the start of the Body Header */
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
-
- rsp_code = OBX_RSP_OK;
- p_cb->cout_active = TRUE;
- bta_fs_co_read(p_cb->fd, &p_obx->p_start[p_obx->offset],
- p_obx->bytes_left, BTA_FTS_CI_READ_EVT, 0, p_cb->app_id);
- }
- }
- if (rsp_code != OBX_RSP_OK)
- bta_fts_get_file_rsp(rsp_code, 0);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_proc_put_file
-**
-** Description Processes a Put File Operation.
-** Initiates the opening of a file for writing, or continues
-** with a new Obx packet of data (continuation).
-**
-** Parameters p_pkt - Pointer to the OBX Put request
-** name of file to write out.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_proc_put_file(BT_HDR *p_pkt, char *p_name, BOOLEAN final_pkt, UINT8 oper)
-{
- tBTA_FTS_CB *p_cb = &bta_fts_cb;
- tBTA_FTS_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FS_CO_STATUS status;
- UINT8 rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- UINT8 num_hdrs;
- BOOLEAN is_dir;
- BOOLEAN endpkt;
-
- p_obx->final_pkt = final_pkt;
- p_obx->p_pkt = p_pkt;
- p_obx->offset = 0; /* Initial offset into OBX data */
- APPL_TRACE_DEBUG2("bta_fts_proc_put_file len:%d p_pkt->offset:%d", p_pkt->len, p_pkt->offset);
-
- /* Is this a new request or continuation? */
- if ((p_cb->obx_oper == FTS_OP_NONE))
- {
- /* See if the folder permissions are writable in the current folder */
- if (((status = bta_fs_co_access(p_cb->p_workdir, BTA_FS_ACC_RDWR,
- &is_dir, p_cb->app_id)) == BTA_FS_CO_OK) && is_dir)
- {
- /* Initialize the start of data and length */
- if ((p_cb->p_path =
- (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- /* Build a fully qualified path */
- if ((strlen(p_cb->p_workdir) + strlen(p_name) + 2)
- <= p_bta_fs_cfg->max_path_len)
- {
- /* Read the file length if header exists */
- if (!OBX_ReadLengthHdr(p_pkt, &p_cb->file_length))
- p_cb->file_length = BTA_FS_LEN_UNKNOWN;
-
- rsp_code = OBX_RSP_PART_CONTENT; /* Do not send OBX response yet */
- sprintf(p_cb->p_path, "%s%c%s", p_cb->p_workdir,
- p_bta_fs_cfg->path_separator, p_name);
-
- APPL_TRACE_DEBUG2("FTS PUT FILE: Name [%s], Length = 0x%0x (0 = n/a)",
- p_cb->p_path, p_cb->file_length);
-
- p_cb->obx_oper = FTS_OP_PUT_FILE;
-
- /* Get permission before proceeding */
- bta_fts_req_app_access(BTA_FT_OPER_PUT, p_cb);
- }
- }
- }
- else
- rsp_code = OBX_RSP_UNAUTHORIZED;
- }
- else /* Continue writing to the open file */
- {
- /* Read in start of body if there is a body header */
- num_hdrs = OBX_ReadBodyHdr(p_obx->p_pkt, &p_obx->p_start,
- &p_obx->bytes_left, &endpkt);
- if (num_hdrs == 1)
- {
- if (p_obx->bytes_left)
- {
- rsp_code = OBX_RSP_PART_CONTENT; /* Do not send OBX response yet */
- p_cb->cout_active = TRUE;
- bta_fs_co_write(p_cb->fd, &p_obx->p_start[p_obx->offset],
- p_obx->bytes_left, BTA_FTS_CI_WRITE_EVT, 0, p_cb->app_id);
- }
- else
- {
- rsp_code = OBX_RSP_OK;
- }
-
- }
- else if (oper & FTS_OP_RESUME)
- {
- rsp_code = OBX_RSP_OK;
- }
- else
- {
- bta_fts_clean_getput(p_cb, TRUE);
- rsp_code = OBX_RSP_BAD_REQUEST;
- }
- }
-
- if (rsp_code != OBX_RSP_PART_CONTENT)
- bta_fts_put_file_rsp(rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_mkdir
-**
-** Description make a new directory and sets the new path to this directory
-** if successful.
-**
-** Parameters p_pkt - Pointer to the OBX packet
-**
-** Returns UINT8 - OBX response code
-**
-*******************************************************************************/
-UINT8 bta_fts_mkdir(BT_HDR *p_pkt, tBTA_FT_OPER *p_op)
-{
- tBTA_FTS_CB *p_cb = &bta_fts_cb;
- tBTA_FS_CO_STATUS status = BTA_FS_CO_FAIL;
- UINT8 rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- char *p_newpath;
- char *p_name;
- BOOLEAN is_dir;
-
- p_newpath = p_cb->p_path;
- p_name = p_cb->p_name;
-
- /* the name of the directory being created */
- if (p_cb->p_name && p_cb->p_name[0])
- {
- /* Make sure the new path is not too big */
- if ((strlen(p_name) + strlen(p_cb->p_workdir) + 1) <= p_bta_fs_cfg->max_path_len)
- {
- /* create a temporary path for creation attempt */
- sprintf(p_newpath, "%s%c%s", p_cb->p_workdir,
- p_bta_fs_cfg->path_separator, p_name);
-
- /* If the directory already exists, we're done */
- if (((status = bta_fs_co_access(p_newpath, BTA_FS_ACC_EXIST,
- &is_dir, p_cb->app_id)) == BTA_FS_CO_OK) && is_dir)
- {
- /* If directory exists, skip mkdir and just issue chdir- Note OBX_RSP_CONTINUE used internally by callee */
- rsp_code = OBX_RSP_CONTINUE;
- }
-
- /* See if the folder permissions are writable in the current folder */
- else if (((status = bta_fs_co_access(p_cb->p_workdir, BTA_FS_ACC_RDWR,
- &is_dir, p_cb->app_id)) == BTA_FS_CO_OK))
- {
- *p_op = BTA_FT_OPER_MK_DIR;
- }
- else if (status == BTA_FS_CO_EACCES)
- rsp_code = OBX_RSP_UNAUTHORIZED; /* Read only folder, cannot create a new one */
- }
- else
- APPL_TRACE_WARNING0 ("bta_fts_mkdir: path too long!!!");
- }
- else
- rsp_code = OBX_RSP_BAD_REQUEST;
-
-
- APPL_TRACE_DEBUG2("bta_fts_mkdir: co_status [%d], obx_rsp_code [0x%02x]",
- status, rsp_code);
-
- return (rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_chdir
-**
-** Description Changes the current path to the specified directory.
-**
-** Parameters p_pkt - Pointer to the OBX packet
-** backup_flag - if TRUE, path adjusted up one level.
-**
-** Returns UINT8 - OBX response code
-**
-*******************************************************************************/
-UINT8 bta_fts_chdir(BT_HDR *p_pkt, BOOLEAN backup_flag, tBTA_FT_OPER *p_op)
-{
- tBTA_FTS_CB *p_cb = &bta_fts_cb;
- char *p_path = p_cb->p_path;
- char *p_name = p_cb->p_name;
- char *p_workdir = p_cb->p_workdir;
- UINT8 rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- BOOLEAN is_dir;
-
- if (!backup_flag)
- {
-
- /* If No Name header, or empty name header, set to root path */
- if (p_name == NULL || (p_name && p_name[0] == '\0'))
- {
- BCM_STRNCPY_S(p_workdir, p_bta_fs_cfg->max_path_len+1, p_cb->p_rootpath, p_bta_fs_cfg->max_path_len);
- p_workdir[p_bta_fs_cfg->max_path_len] = '\0';
-
- rsp_code = OBX_RSP_OK;
- APPL_TRACE_DEBUG0("FTS: Setting current path to ROOT");
- }
-// btla-specific ++
- #if defined (FTS_REJECT_INVALID_OBEX_SET_PATH_REQ) && (FTS_REJECT_INVALID_OBEX_SET_PATH_REQ == TRUE)
- /* Reject invalid OBEX set path reqeust - DOS or unix/linux like change directory*/
- else if(strncmp("/", p_name, 1) == 0 || strncmp("..", p_name, 2) == 0)
- {
- APPL_TRACE_ERROR0("FTS: Rejecting invalid chdir request start with / or ..");
- rsp_code = OBX_RSP_NOT_FOUND;
- }
- #endif
-// btla-specific --
- /* Make sure the new path is not too big */
- else if ((strlen(p_name) + strlen(p_workdir) + 2)
- <= p_bta_fs_cfg->max_path_len)
- {
- /* create a temporary path for creation attempt */
- sprintf(p_path, "%s%c%s", p_workdir,
- p_bta_fs_cfg->path_separator, p_name);
-
- if (((bta_fs_co_access(p_path, BTA_FS_ACC_EXIST,
- &is_dir, p_cb->app_id)) == BTA_FS_CO_OK) && is_dir)
- {
- *p_op = BTA_FT_OPER_CHG_DIR;
- }
- else
- rsp_code = OBX_RSP_NOT_FOUND;
- }
- }
- else /* Backing up a directory */
- {
- /* Backup unless already at root */
- if (strcmp(p_workdir, p_cb->p_rootpath))
- {
- /* if an empty name header exist(although illegal), goes to root */
- if (p_name && p_name[0] == '\0')
- {
- BCM_STRNCPY_S(p_workdir, p_bta_fs_cfg->max_path_len+1, p_cb->p_rootpath, p_bta_fs_cfg->max_path_len);
- p_workdir[p_bta_fs_cfg->max_path_len] = '\0';
-
- APPL_TRACE_DEBUG0("FTS: Setting current path to ROOT");
- }
- /* otherwise back up one level */
- /* Find the last occurrence of separator and replace with '\0' */
- else if((p_path = strrchr(p_workdir, (int)p_bta_fs_cfg->path_separator)) != NULL)
- *p_path = '\0';
- APPL_TRACE_DEBUG1("FTS: SET NEW PATH [%s]", p_cb->p_workdir);
-
- rsp_code = OBX_RSP_OK;
- }
- else
- rsp_code = OBX_RSP_NOT_FOUND;
- }
-
- if (rsp_code == OBX_RSP_OK)
- bta_fs_co_setdir(p_workdir, p_cb->app_id);
-
- return (rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_delete
-**
-** Description remove a file or directory
-**
-** Parameters
-** p - Pointer to the name of the object store. It is
-** converted into a fully qualified path before call-out
-** function is called (if not a RAM object).
-**
-** Returns void
-**
-** Obex packet is responded to with:
-** OBX_RSP_OK if successful,
-** OBX_RSP_PRECONDTN_FAILED if a directory and not empty,
-** OBX_RSP_UNAUTHORIZED if read only (access problem),
-** OBX_RSP_INTRNL_SRVR_ERR otherwise.
-**
-*******************************************************************************/
-void bta_fts_delete(tBTA_FTS_OBX_EVENT *p_evt, const char *p_name)
-{
- tBTA_FTS_CB *p_cb = &bta_fts_cb;
- char *p_path;
- tBTA_FS_CO_STATUS status;
- UINT8 rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- BOOLEAN is_dir;
- tBTA_FT_OPER ft_op = BTA_FT_OPER_DEL_FILE;
- BOOLEAN rsp_now = TRUE;
-
- if ((p_cb->p_path = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 2))) != NULL)
- {
- p_path = p_cb->p_path;
- sprintf(p_path, "%s%c%s", p_cb->p_workdir, p_bta_fs_cfg->path_separator,
- p_name);
-
- /* Access the object to see if it exists */
- status = bta_fs_co_access(p_path, BTA_FS_ACC_RDWR, &is_dir, p_cb->app_id);
- if (status == BTA_FS_CO_OK)
- {
- if (is_dir)
- ft_op = BTA_FT_OPER_DEL_DIR;
- rsp_now = FALSE;
- bta_fts_req_app_access(ft_op, p_cb);
- }
- else if (status == BTA_FS_CO_EACCES)
- rsp_code = OBX_RSP_UNAUTHORIZED;
- else
- rsp_code = OBX_RSP_NOT_FOUND;
-
- }
- if(rsp_now)
- {
- utl_freebuf((void**)&p_cb->p_path);
- OBX_PutRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_end_of_list
-**
-** Description Finishes up the end body of the listing, and sends out the
-** OBX response
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_end_of_list(UINT8 rsp_code)
-{
- tBTA_FTS_CB *p_cb = &bta_fts_cb;
- tBTA_FTS_OBX_PKT *p_obx = &p_cb->obx;
- UINT16 temp_len;
-
- /* Add the end of folder listing string if successful operation */
- if (rsp_code == OBX_RSP_OK || rsp_code == OBX_RSP_CONTINUE)
- {
- /* If listing has completed, add on end string (http) */
- if (rsp_code == OBX_RSP_OK)
- {
- temp_len = strlen(BTA_FTS_FOLDER_LISTING_END);
- memcpy(&p_obx->p_start[p_obx->offset], BTA_FTS_FOLDER_LISTING_END, temp_len);
- p_obx->offset += temp_len;
-
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, TRUE);
-
- /* Clean up control block */
- bta_fts_clean_list(p_cb);
- }
- else /* More listing data to be sent */
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, FALSE);
-
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* Do not deallocate buffer; OBX will */
- }
- else /* An error occurred */
- {
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- bta_fts_clean_list(p_cb);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_get_file_rsp
-**
-** Description Finishes up the end body of the file get, and sends out the
-** OBX response
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_get_file_rsp(UINT8 rsp_code, UINT16 num_read)
-{
- tBTA_FTS_CB *p_cb = &bta_fts_cb;
- tBTA_FTS_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FTS param;
- BOOLEAN done = TRUE;
-
- /* Send the response packet if successful operation */
- if (rsp_code == OBX_RSP_OK || rsp_code == OBX_RSP_CONTINUE)
- {
- p_obx->offset += num_read;
-
- /* More to be sent */
- if (rsp_code == OBX_RSP_CONTINUE)
- {
- if (p_obx->bytes_left != num_read)
- APPL_TRACE_WARNING2("FTS Read: Requested (0x%04x), Read In (0x%04x)",
- p_obx->bytes_left, num_read);
- done = FALSE;
- }
-
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, done);
-
- /* Notify application with progress */
- if (num_read)
- {
- param.prog.bytes = num_read;
- param.prog.file_size = p_cb->file_length;
- p_cb->p_cback(BTA_FTS_PROGRESS_EVT, &param);
- }
- }
- else
- p_cb->obx_oper = FTS_OP_NONE;
-
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* Do not deallocate buffer; OBX will */
-
- /* Final response packet sent out */
- if (done)
- bta_fts_clean_getput(p_cb, FALSE);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_put_file_rsp
-**
-** Description Responds to a put request, and closes the file if finished
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_put_file_rsp(UINT8 rsp_code)
-{
- tBTA_FTS_CB *p_cb = &bta_fts_cb;
- tBTA_FTS_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FTS param;
-
- /* Finished with input packet */
- utl_freebuf((void**)&p_obx->p_pkt);
-
- if (rsp_code == OBX_RSP_OK)
- {
- /* Update application if file data was transferred */
- if (p_obx->bytes_left)
- {
- param.prog.bytes = p_obx->bytes_left;
- param.prog.file_size = p_cb->file_length;
- p_cb->p_cback(BTA_FTS_PROGRESS_EVT, &param);
- }
-
- /* If not end of file put, set the continue response */
- if (!p_obx->final_pkt)
- rsp_code = OBX_RSP_CONTINUE;
- else /* Done - free the allocated memory */
- bta_fts_clean_getput(p_cb, FALSE);
- }
- else
- p_cb->obx_oper = FTS_OP_NONE;
-
- OBX_PutRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_add_list_entry
-**
-** Description used by bta_fts_getdirlist to write a list entry to an
-** obex packet (byte array).
-**
-** Returns UINT8 - OBX response code
-** OBX_RSP_PART_CONTENT if not finished yet.
-** OBX_RSP_CONTINUE [packet done]
-** Others send error response out
-**
-*******************************************************************************/
-UINT8 bta_fts_add_list_entry(void)
-{
- tBTA_FTS_CB *p_cb = &bta_fts_cb;
- tBTA_FTS_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FTS_DIRLIST *p_dir = &p_cb->dir;
- tBTA_FS_DIRENTRY *p_file = p_dir->p_entry;
- char *p_buf;
- UINT16 size;
- UINT8 rsp_code = OBX_RSP_PART_CONTENT;
-
- if ((p_buf = (char *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL)
- {
- p_buf[0] = '\0';
-
- APPL_TRACE_DEBUG2("bta_fts_add_list_entry: attr:0x%02x, name:%s",
- p_file->mode, p_file->p_name);
-
- if(p_file->mode & BTA_FS_A_DIR) /* Subdirectory */
- {
- /* ignore "." and ".." */
- if (strcmp(p_file->p_name, ".") && strcmp(p_file->p_name, ".."))
- {
- sprintf(p_buf, " <" BTA_FTS_FOLDER_ELEM " "
- BTA_FTS_NAME_ATTR "=\"%s\"/>" BTA_FTS_XML_EOL,
- p_file->p_name);
- }
- }
- else /* treat anything else as file */
- {
- /* Add the creation time if valid */
- if (p_file->crtime[0] != '\0')
- {
- sprintf(p_buf, " <" BTA_FTS_FILE_ELEM " "
- BTA_FTS_NAME_ATTR "=\"%s\" "
- BTA_FTS_SIZE_ATTR "=\"%lu\" "
- BTA_FTS_USER_PERM_ATTR "=\"R%s\" "
- BTA_FTS_CREATED_ATTR "=\"%s\"/>" BTA_FTS_XML_EOL,
- p_file->p_name,
- p_file->filesize,
- p_file->mode & BTA_FS_A_RDONLY ? "" : "WD",
- p_file->crtime);
- }
- else
- {
- sprintf(p_buf, " <" BTA_FTS_FILE_ELEM " "
- BTA_FTS_NAME_ATTR "=\"%s\" "
- BTA_FTS_SIZE_ATTR "=\"%lu\" "
- BTA_FTS_USER_PERM_ATTR "=\"R%s\"/>" BTA_FTS_XML_EOL,
- p_file->p_name,
- p_file->filesize,
- p_file->mode & BTA_FS_A_RDONLY ? "" : "WD");
- }
- }
-
- /* Make sure the entry fits into the current obx packet */
- size = strlen(p_buf);
- if (size <= p_obx->bytes_left)
- {
- if (size > 0)
- {
- memcpy (&p_obx->p_start[p_obx->offset], p_buf, size);
- p_obx->offset += size;
- p_obx->bytes_left -= size;
- }
- /* Get the next directory entry */
- p_cb->cout_active = TRUE;
- bta_fs_co_getdirentry (p_cb->p_path, FALSE, p_dir->p_entry,
- BTA_FTS_CI_DIRENTRY_EVT, p_cb->app_id);
- }
- else /* entry did not fit in current obx packet; try to add entry in next obx req */
- rsp_code = OBX_RSP_CONTINUE;
-
- /* Done with temporary buffer */
- GKI_freebuf(p_buf);
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- return (rsp_code);
-}
-
-
-/*******************************************************************************
-* Static Functions
-*******************************************************************************/
-
-/*******************************************************************************
-**
-** Function bta_fts_clean_list
-**
-** Description Cleans up the get directory list memory and control block
-**
-** Returns void
-**
-*******************************************
-************************************/
-void bta_fts_clean_list(tBTA_FTS_CB *p_cb)
-{
- tBTA_FTS_DIRLIST *p_dir = &p_cb->dir;
- /* Clean up control block */
- p_cb->obx_oper = FTS_OP_NONE;
- utl_freebuf((void**)&p_cb->p_name);
- utl_freebuf((void**)&p_dir->p_entry);
- utl_freebuf((void**)&p_cb->p_path);
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_clean_getput
-**
-** Description Cleans up the get/put resources and control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_clean_getput(tBTA_FTS_CB *p_cb, BOOLEAN is_aborted)
-{
- tBTA_FS_CO_STATUS status;
- tBTA_FTS_OBJECT objdata;
- tBTA_FTS_EVT evt = 0;
-
- /* Clean up control block */
- utl_freebuf((void**)&p_cb->obx.p_pkt);
-
- /* Close any open files */
- if (p_cb->fd >= 0)
- {
- bta_fs_co_close(p_cb->fd, p_cb->app_id);
- p_cb->fd = BTA_FS_INVALID_FD;
-
- /* Notify the application */
- objdata.p_name = p_cb->p_path;
-
- if (is_aborted)
- objdata.status = BTA_FTS_FAIL;
- else
- objdata.status = BTA_FTS_OK;
-
- if (p_cb->obx_oper == FTS_OP_PUT_FILE)
- {
- /* Delete an aborted unfinished push file operation */
- if (is_aborted && p_cb->suspending == FALSE)
- {
- status = bta_fs_co_unlink(p_cb->p_path, p_cb->app_id);
- APPL_TRACE_WARNING2("FTS: Remove ABORTED Push File Operation [%s], status 0x%02x",
- p_cb->p_path, status);
- }
-
- evt = BTA_FTS_PUT_CMPL_EVT;
- }
- else if (p_cb->obx_oper == FTS_OP_GET_FILE)
- {
- evt = BTA_FTS_GET_CMPL_EVT;
- }
-
- if (evt)
- {
- /* Notify application of operation complete */
- p_cb->p_cback(evt, (tBTA_FTS *)&objdata);
- }
- }
-
- p_cb->suspending = FALSE;
-
- utl_freebuf((void**)&p_cb->p_name);
- utl_freebuf((void**)&p_cb->p_path);
-
- p_cb->obx_oper = FTS_OP_NONE;
- p_cb->obx.bytes_left = 0;
- p_cb->file_length = BTA_FS_LEN_UNKNOWN;
- p_cb->acc_active = 0;
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_disable_cleanup
-**
-** Description Cleans up the resources and control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_disable_cleanup(tBTA_FTS_CB *p_cb)
-{
- tBTA_FS_CO_STATUS status;
-
- /* Stop the OBEX server */
- OBX_StopServer(p_cb->obx_handle);
-
- /* Clean up control block */
- utl_freebuf((void **)&p_cb->obx.p_pkt);
-
- /* Close any open files */
- if (p_cb->fd >= 0)
- {
- bta_fs_co_close(p_cb->fd, p_cb->app_id);
- p_cb->fd = BTA_FS_INVALID_FD;
-
- /* Delete an aborted unfinished push file operation */
- if (p_cb->obx_oper == FTS_OP_PUT_FILE)
- {
- status = bta_fs_co_unlink(p_cb->p_path, p_cb->app_id);
- APPL_TRACE_WARNING2("FTS: bta_fts_disable_cleanup() ->Remove ABORTED Push File Operation [%s], status 0x%02x",
- p_cb->p_path, status);
- }
- }
-
- /* Free any used memory buffers */
- utl_freebuf((void **)&p_cb->dir.p_entry);
- utl_freebuf((void **)&p_cb->p_name);
- utl_freebuf((void **)&p_cb->p_path);
-
- /* Remove the FTP service from the SDP database */
- SDP_DeleteRecord(p_cb->sdp_handle);
-
- /* Free the allocated server channel number */
- BTM_FreeSCN(p_cb->scn);
-
- GKI_freebuf(p_cb->p_rootpath); /* Free buffer containing root and working paths */
-
- p_cb->obx_oper = FTS_OP_NONE;
- p_cb->obx.bytes_left = 0;
- p_cb->file_length = BTA_FS_LEN_UNKNOWN;
- p_cb->acc_active = 0;
-
- if (p_cb->p_cback)
- {
- /* Notify the application */
- p_cb->p_cback(BTA_FTS_DISABLE_EVT, 0);
- p_cb->p_cback = NULL;
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_fts_discard_data
-**
-** Description frees the data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_fts_discard_data(UINT16 event, tBTA_FTS_DATA *p_data)
-{
- switch(event)
- {
- case BTA_FTS_OBX_CONN_EVT:
- case BTA_FTS_OBX_DISC_EVT:
- case BTA_FTS_OBX_ABORT_EVT:
- case BTA_FTS_OBX_PASSWORD_EVT:
- case BTA_FTS_OBX_CLOSE_EVT:
- case BTA_FTS_OBX_PUT_EVT:
- case BTA_FTS_OBX_GET_EVT:
- case BTA_FTS_OBX_SETPATH_EVT:
- utl_freebuf((void**)&p_data->obx_evt.p_pkt);
- break;
-
- default:
- /*Nothing to free*/
- break;
- }
-}
-
-#endif /* BTA_FT_INCLUDED */
diff --git a/bta/hd/bta_hd_act.c b/bta/hd/bta_hd_act.c
deleted file mode 100644
index 0e6393b..0000000
--- a/bta/hd/bta_hd_act.c
+++ /dev/null
@@ -1,646 +0,0 @@
-/******************************************************************************
-**
-** File Name: bta_hd_act.c
-**
-** Description: This module contains state machine action functions for
-** the HID Device service.
-**
-** Copyright (c) 2002-2009, Broadcom Corp., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-******************************************************************************/
-
-#include <string.h>
-#include "data_types.h"
-#include "bt_types.h"
-#include "bt_target.h"
-#include "hidd_api.h"
-#include "bta_hd_int.h"
-#include "bta_hd_api.h"
-#include "l2c_api.h"
-#include "btm_api.h"
-#include "bd.h"
-
-
-
-const UINT8 bta_hd_buf_len[] =
-{
- BTA_HD_KBD_REPT_SIZE, /* BTA_HD_REPT_ID_SPEC 0: other */
- BTA_HD_KBD_REPT_SIZE, /* BTA_HD_REPT_ID_KBD 1: regular keyboard */
- BTA_HD_MOUSE_REPT_SIZE /* BTA_HD_REPT_ID_MOUSE 2: mouse */
-};
-
-typedef struct
-{
- UINT8 modifier;
- UINT8 reserved;
- UINT8 keycode_1;
- UINT8 keycode_2;
- UINT8 keycode_3;
- UINT8 keycode_4;
- UINT8 keycode_5;
- UINT8 keycode_6;
-} tBTA_HD_KEY_REPORT;
-
-
-#if (BT_USE_TRACES == TRUE)
-const char * bta_hd_ctrl_str [] =
-{
- "NOP",
- "HARD_RESET",
- "SOFT_RESET",
- "SUSPEND",
- "EXIT_SUSPEND",
- "VCAB_UNPLUG"
-};
-
-const char * bta_hd_rept_id_str [] =
-{
- "MASK",
- "OTHER",
- "INPUT",
- "OUTPUT",
- "FEATURE"
-};
-
-const char * bta_hd_evt_str [] =
-{
- "OPEN",
- "CLOSE",
- "RETRYING",
- "MODE_CHG",
- "PM_FAILED",
- "CONTROL",
- "GET_REPORT",
- "SET_REPORT",
- "GET_PROTO",
- "SET_PROTO",
- "GET_IDLE",
- "SET_IDLE",
- "DATA",
- "DATC",
- "L2C_CONG",
-};
-#endif
-
-/*******************************************************************************
-**
-** Function bta_hd_kick_timer
-**
-** Description kick the timer in DM for power management
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_hd_kick_timer(tBTA_HD_CB *p_cb)
-{
- APPL_TRACE_DEBUG0("bta_hd_kick_timer");
-#if (BTM_SSR_INCLUDED == TRUE)
- if(!p_cb->use_ssr)
-#endif
- {
- bta_sys_busy(BTA_ID_HD, p_cb->app_id, p_cb->peer_addr);
- bta_sys_idle(BTA_ID_HD, p_cb->app_id, p_cb->peer_addr);
- }
-}
-/*******************************************************************************
-**
-** Function bta_hd_ssr_timer_cback
-**
-** Description Sends disable event to application
-**
-**
-** Returns void
-**
-*******************************************************************************/
-#if (BTM_SSR_INCLUDED == TRUE)
-static void bta_hd_ssr_timer_cback (TIMER_LIST_ENT *p_tle)
-{
- tBTA_HD_CB *p_cb = (tBTA_HD_CB *)p_tle->param;
- p_cb->use_ssr = BTA_DmUseSsr(p_cb->peer_addr);
- APPL_TRACE_DEBUG1("bta_hd_ssr_timer_cback use_ssr:%d", p_cb->use_ssr);
- bta_sys_idle(BTA_ID_HD, p_cb->app_id, p_cb->peer_addr);
-}
-#endif
-
-/*******************************************************************************
-**
-** Function bta_hd_send_data
-**
-** Description Send data to the connected host
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_hd_send_data(tBTA_HD_CB *p_cb, UINT8 rep_type, UINT16 len, UINT8 *p_data)
-{
- BT_HDR *p_buf;
- UINT8 *p;
-
- p_buf = (BT_HDR *) GKI_getbuf( (UINT16)(L2CAP_MIN_OFFSET+len + 1) );
- if(p_buf)
- {
- p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET+1;
- memcpy( p, p_data, len);
- p_buf->len = len;
- p_buf->offset = L2CAP_MIN_OFFSET+1;
- HID_DevSendData ( TRUE, rep_type, p_buf );
- if(p_cb)
- {
- bta_hd_kick_timer(p_cb);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_flush_data
-**
-** Description Send the queued data to the connected host
-**
-**
-** Returns BOOLEAN
-**
-*******************************************************************************/
-static BOOLEAN bta_hd_flush_data(tBTA_HD_CB *p_cb)
-{
- BT_HDR *p_buf;
- BOOLEAN set_busy = FALSE;
-
- while((p_buf = (BT_HDR*)GKI_dequeue (&p_cb->out_q)) != NULL)
- {
- if(HID_DevSendData ( FALSE, HID_PAR_REP_TYPE_INPUT, p_buf ) == HID_ERR_CONGESTED)
- {
- /* can not send it now. put it back to the queue */
- GKI_enqueue_head(&p_cb->out_q, p_buf);
- break;
- }
-
- /* sent one packet */
- set_busy = TRUE;
- }
-
- if(set_busy)
- {
- bta_hd_kick_timer(p_cb);
- }
- return GKI_queue_is_empty(&p_cb->out_q);
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_init_con_act
-**
-** Description Initialize the connection to the known host.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hd_init_con_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data)
-{
- APPL_TRACE_DEBUG0("bta_hd_init_con_act");
- if( HID_DevConnect() != HID_SUCCESS )
- {
- bta_hd_sm_execute(p_cb, BTA_HD_DISCONNECTED_EVT, NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_close_act
-**
-** Description process close API function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hd_close_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data)
-{
- APPL_TRACE_DEBUG0("bta_hd_close_act");
- HID_DevDisconnect();
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_disable_act
-**
-** Description process disable API function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hd_disable_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data)
-{
- APPL_TRACE_DEBUG0("bta_hd_disable_act");
- BTM_SecClrService(BTM_SEC_SERVICE_HID_SEC_CTRL);
- BTM_SecClrService(BTM_SEC_SERVICE_HID_INTR);
- if(bta_hd_cb.sdp_handle)
- {
- SDP_DeleteRecord(bta_hd_cb.sdp_handle);
- bta_hd_cb.sdp_handle = 0;
-#if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&(BTA_EIR_CANNED_UUID_LIST != TRUE)
- bta_sys_remove_uuid(UUID_SERVCLASS_HUMAN_INTERFACE);
-#endif
- }
- HID_DevDeregister();
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_open_act
-**
-** Description received connected event from HIDD. report to user
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hd_open_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data)
-{
- BD_ADDR_PTR p_addr = p_data->cback_data.pdata->host_bdaddr;
-#if (BTM_SSR_INCLUDED == TRUE)
- UINT8 *p;
-#endif
-
- p_cb->proto = HID_PAR_PROTOCOL_REPORT; /* the default is report mode */
- bdcpy(p_cb->peer_addr, p_addr);
- /* inform role manager */
- bta_sys_conn_open( BTA_ID_HD ,p_cb->app_id, p_addr);
-#if (BTM_SSR_INCLUDED == TRUE)
- p_cb->timer.param = (UINT32)p_cb;
- p_cb->timer.p_cback = (TIMER_CBACK*)&bta_hd_ssr_timer_cback;
- bta_sys_start_timer(&p_cb->timer, 0, 6000);
- p_cb->use_ssr = FALSE;
- if( ((NULL != (p = BTM_ReadLocalFeatures ())) && HCI_SNIFF_SUB_RATE_SUPPORTED(p)) &&
- ((NULL != (p = BTM_ReadRemoteFeatures (p_addr))) && HCI_SNIFF_SUB_RATE_SUPPORTED(p)) )
- {
- /* both local and remote devices support SSR */
- p_cb->use_ssr = TRUE;
- }
-#endif
- p_cb->p_cback(BTA_HD_OPEN_EVT, (tBTA_HD *)p_addr);
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_opn_cb_act
-**
-** Description process events from HIDD in open state.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hd_opn_cb_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data)
-{
- UINT8 res_code;
- BOOLEAN *p_cong;
- tHID_DEV_DSCP_INFO *p_info;
- tBTA_HD_CBACK_DATA *p_evt = (tBTA_HD_CBACK_DATA *)p_data;
- BOOLEAN set_busy = TRUE;
- tBTA_HD_REPORT rpt;
- UINT8 evt;
- BT_HDR *p_buf;
-
- switch(p_evt->event)
- {
- case HID_DEV_EVT_CONTROL: /* Host sent HID_CONTROL Data=Control Operation */
- if(p_evt->data == HID_PAR_CONTROL_VIRTUAL_CABLE_UNPLUG)
- {
- p_cb->p_cback(BTA_HD_UNPLUG_EVT, NULL);
- set_busy = FALSE;
- }
- else if(p_evt->data == HID_PAR_CONTROL_SUSPEND)
- {
- bta_sys_idle(BTA_ID_HD, p_cb->app_id, p_cb->peer_addr);
- set_busy = FALSE;
- }
- break;
-
- case HID_DEV_EVT_GET_REPORT:/*Host sent GET_REPORT Data=Length pdata=structure
- having details of get-report.*/
- /* bta_hd_hidd_cback sends SM event only when
- ((tHID_DEV_GET_REP_DATA *)p_data))->rep_type == HID_PAR_REP_TYPE_FEATURE */
- p_info = &p_bta_hd_cfg->sdp_info.dscp_info;
- bta_hd_send_data(p_cb, HID_PAR_REP_TYPE_FEATURE, p_info->dl_len, p_info->dsc_list);
- break;
-
- case HID_DEV_EVT_GET_PROTO:/*Host sent GET_PROTOCOL Data=NA*/
- res_code = p_cb->proto; /* the protocol (Report or Boot) mode from control block */
- bta_hd_send_data(p_cb, HID_PAR_REP_TYPE_OTHER, 1, &res_code);
- break;
-
- case HID_DEV_EVT_SET_PROTO:/*Host sent SET_PROTOCOL Data=1 for Report, 0 for Boot*/
- if((p_evt->data == HID_PAR_PROTOCOL_REPORT) || (p_evt->data == HID_PAR_PROTOCOL_BOOT_MODE))
- {
- p_cb->proto = p_evt->data;
- res_code = HID_PAR_HANDSHAKE_RSP_SUCCESS;
- }
- else
- res_code = HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ;
- HID_DevHandShake(res_code);
- break;
-
- case HID_DEV_EVT_L2CAP_CONGEST:
- p_cong = (BOOLEAN *)p_evt->pdata;
- if(*p_cong == FALSE)
- {
- /* L2CAP is uncongested, send out the queued buffers */
- bta_hd_flush_data(p_cb);
- set_busy = FALSE;
- }
- break;
-
- case HID_DEV_EVT_DATA:
- case HID_DEV_EVT_DATC:
- evt = (p_evt->event == HID_DEV_EVT_DATA) ? BTA_HD_DATA_EVT: BTA_HD_DATC_EVT;
- if(p_evt->pdata)
- {
- if(p_evt->data == HID_PAR_REP_TYPE_OUTPUT)
- {
- p_buf = p_evt->pdata->buffer;
-
- rpt.p_data = (UINT8 *)(p_buf + 1) + p_buf->offset + 1;
- rpt.len = p_buf->len - 1;
-
- p_cb->p_cback(evt, (tBTA_HD *)&rpt);
- }
-
- GKI_freebuf (p_evt->pdata->buffer);
- }
- break;
- }
-
- if(set_busy)
- {
- bta_hd_kick_timer(p_cb);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_input_act
-**
-** Description received input event from user. send to peer
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hd_input_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data)
-{
- tBTA_HD_API_INPUT_SPEC *p_spec = (tBTA_HD_API_INPUT_SPEC *)p_data;
- tBTA_HD_API_INPUT *p_input = (tBTA_HD_API_INPUT *)p_data;
- tBTA_HD_KEY_REPORT key_buf = {0};
- UINT16 len = bta_hd_buf_len[p_input->rid];
- UINT16 size;
- BT_HDR *p_buf;
- UINT8 *p;
- int temp;
- BOOLEAN release = FALSE;
-
- if(p_input->rid == BTA_HD_REPT_ID_SPEC)
- len = BTA_HD_KBD_REPT_SIZE;
- size = L2CAP_MIN_OFFSET + sizeof(BT_HDR) + len;
-
- if ( (p_buf = (BT_HDR *)GKI_getbuf(size)) == NULL )
- return;
-
- p_buf->offset = L2CAP_MIN_OFFSET+1;
- p = (UINT8 *) ((UINT8 *) (p_buf+1))+L2CAP_MIN_OFFSET+1;
- *p++ = p_input->rid;
- switch(p_input->rid)
- {
- case BTA_HD_REPT_ID_SPEC:
- p--;
- memcpy(p, p_spec->seq, p_spec->len);
- /* use the proper report ID type for the key release */
- p_input->rid = *p;
- temp = BTA_HD_KBD_REPT_SIZE - p_spec->len;
- if(temp > 0)
- memset(p + p_spec->len, 0, temp);
- release = p_spec->release;
- break;
-
- case BTA_HD_REPT_ID_KBD: /* 1: regular keyboard */
- key_buf.keycode_1 = p_input->keyCode;
- key_buf.modifier = p_input->buttons;
- memcpy(p, (void *)&key_buf, len-1);
- release = p_input->release;
- break;
-
- case BTA_HD_REPT_ID_MOUSE: /* 2: mouse */
- *p++ = p_input->buttons;
- *p++ = p_input->keyCode; /* x */
- *p++ = p_input->keyCode2; /* y */
- *p++ = p_input->wheel;
- break;
-
- default:
- GKI_freebuf(p_buf);
- return;
- }
- p_buf->len = len;
-
- GKI_enqueue(&p_cb->out_q, p_buf);
-
- if(release)
- {
- /* key release event */
- if ( (p_buf = (BT_HDR *)GKI_getbuf(size)) == NULL )
- return;
-
- p_buf->offset = L2CAP_MIN_OFFSET+1;
- p_buf->len = len;
- p = (UINT8 *) ((UINT8 *) (p_buf+1))+L2CAP_MIN_OFFSET+1;
- *p++ = p_input->rid;
- memset(p, 0, p_buf->len-1);
- GKI_enqueue(&p_cb->out_q, p_buf);
- }
- bta_hd_flush_data(p_cb);
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_discntd_act
-**
-** Description received disconnected event from HIDD. report to user
-** The connection was not open yet at this action
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hd_discntd_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data)
-{
-#if (BTM_SSR_INCLUDED == TRUE)
- bta_sys_stop_timer(&p_cb->timer);
-#endif
-
- /* inform role manager */
- bta_sys_conn_close( BTA_ID_HD ,p_cb->app_id, p_cb->peer_addr);
- p_cb->p_cback(BTA_HD_CLOSE_EVT, (tBTA_HD *)p_cb->peer_addr);
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_discnt_act
-**
-** Description received disconnected event from HIDD. report to user
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hd_discnt_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data)
-{
- BT_HDR *p_buf;
-
-#if (BTM_SSR_INCLUDED == TRUE)
- bta_sys_stop_timer(&p_cb->timer);
-#endif
-
- /* clean out queue */
- while((p_buf = (BT_HDR*)GKI_dequeue (&p_cb->out_q)) != NULL)
- GKI_freebuf(p_buf);
-
- /* inform role manager */
- bta_sys_conn_close( BTA_ID_HD ,p_cb->app_id, p_cb->peer_addr);
- p_cb->p_cback(BTA_HD_CLOSE_EVT, (tBTA_HD *)p_cb->peer_addr);
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_hidd_cback
-**
-** Description This is the HIDD callback function to process events from HIDD.
-** just post a message to BTA_HD
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hd_hidd_cback(UINT8 event, UINT32 data, tHID_DEV_CBACK_DATA *pdata)
-{
- tBTA_HD_CBACK_DATA *p_buf;
- tHID_DEV_GET_REP_DATA *pget_rep;
- UINT16 sm_evt = BTA_HD_INVALID_EVT;
- UINT8 res_code;
-
-#if (BT_USE_TRACES == TRUE)
- APPL_TRACE_EVENT3("HID event=0x%x(%s), data: %d", event, bta_hd_evt_str[event], data);
-#endif
-
- switch( event )
- {
- case HID_DEV_EVT_OPEN: /*Connected to host Data = 1 if Virtual Cable
- with Interrupt and Control
- Channels in OPEN state. pdata = Host BD-Addr.*/
- sm_evt = BTA_HD_CONNECTED_EVT;
- break;
-
- case HID_DEV_EVT_CLOSE: /*Connection with host is closed. Data=Reason Code. */
- sm_evt = BTA_HD_DISCONNECTED_EVT;
- break;
-
- /*case HID_DEV_EVT_RETRYING: Data=Retrial number
- Lost connection is being re-connected.
- MSKB_TRACE_0("HID_DEV_EVT_RETRYING");
- break; */
-
- /*case HID_DEV_EVT_MODE_CHG: Device changed power mode. Data=new power mode
- APPL_TRACE_DEBUG1("Mode change - %d", data);
- break; */
-
- /*case HID_DEV_EVT_PM_FAILED: Host sent SET_IDLE Data=Idle Rate
- MSKB_TRACE_0("PM - Failed");
- break; */
-
- case HID_DEV_EVT_CONTROL: /* Host sent HID_CONTROL Data=Control Operation */
-#if (BT_USE_TRACES == TRUE)
- APPL_TRACE_DEBUG2("EVT_CONTROL:%d(%s)",data, bta_hd_ctrl_str[data]);
-#endif
- switch(data)
- {
- case HID_PAR_CONTROL_VIRTUAL_CABLE_UNPLUG:
- case HID_PAR_CONTROL_SUSPEND:
- case HID_PAR_CONTROL_EXIT_SUSPEND:
- sm_evt = BTA_HD_CBACK_EVT ;
- HID_DevHandShake(HID_PAR_HANDSHAKE_RSP_SUCCESS);
- break;
- default:
- HID_DevHandShake(HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ);
- }
- break;
-
- case HID_DEV_EVT_GET_REPORT:/*Host sent GET_REPORT Data=Length pdata=structure
- having details of get-report.*/
- pget_rep = (tHID_DEV_GET_REP_DATA *) pdata;
- APPL_TRACE_DEBUG3("RepType:%d(%s), id:%d",pget_rep->rep_type,
- bta_hd_rept_id_str[pget_rep->rep_type], pget_rep->rep_id);
-
- if(pget_rep->rep_type == HID_PAR_REP_TYPE_FEATURE)
- {
- sm_evt = BTA_HD_CBACK_EVT ;
- }
- else
- {
- HID_DevHandShake(HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ);
- }
- break;
- case HID_DEV_EVT_SET_REPORT:/*Host sent SET_REPORT Data=Length pdata=details.*/
- HID_DevHandShake(HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ);
- APPL_TRACE_EVENT0("HID_DEV_EVT_SET_REPORT");
- GKI_freebuf (pdata->buffer);
- break;
- case HID_DEV_EVT_GET_PROTO:/*Host sent GET_PROTOCOL Data=NA*/
- sm_evt = BTA_HD_CBACK_EVT ;
- break;
- case HID_DEV_EVT_SET_PROTO:/*Host sent SET_PROTOCOL Data=1 for Report, 0 for Boot*/
- sm_evt = BTA_HD_CBACK_EVT ;
- break;
- case HID_DEV_EVT_GET_IDLE:/* Host sent GET_IDLE Data=NA */
- /* only support infinite idle rate (= 0) */
- res_code = 0;
- bta_hd_send_data(NULL, HID_PAR_REP_TYPE_OTHER, 1, &res_code);
- break;
- case HID_DEV_EVT_SET_IDLE: /* Host sent SET_IDLE Data=Idle Rate */
- res_code = HID_PAR_HANDSHAKE_RSP_ERR_INVALID_PARAM;
- if( data == 0 ) /* only support infinite idle rate (= 0) */
- res_code = HID_PAR_HANDSHAKE_RSP_SUCCESS;
- HID_DevHandShake(res_code);
- break;
- case HID_DEV_EVT_L2CAP_CONGEST:
- sm_evt = BTA_HD_CBACK_EVT ;
- break;
- case HID_DEV_EVT_DATA:
- case HID_DEV_EVT_DATC:
- APPL_TRACE_EVENT1("HID_DEV_EVT_DATC/DATC event = %s", bta_hd_evt_str[event]);
- sm_evt = BTA_HD_CBACK_EVT ;
- break;
- }
-
- if ((sm_evt != BTA_HD_INVALID_EVT) &&
- (p_buf = (tBTA_HD_CBACK_DATA *) GKI_getbuf(
- (UINT16)(sizeof(tBTA_HD_CBACK_DATA)+sizeof(tHID_DEV_CBACK_DATA)))) != NULL)
- {
- p_buf->hdr.event = sm_evt;
- p_buf->event = event;
- p_buf->data = data;
- if(pdata)
- {
- p_buf->pdata = (tHID_DEV_CBACK_DATA *)(p_buf + 1);
- memcpy(p_buf->pdata, pdata, sizeof(tHID_DEV_CBACK_DATA));
- }
- else
- {
- p_buf->pdata = NULL;
- }
- bta_sys_sendmsg(p_buf);
- }
-
-
-}
-
diff --git a/bta/hd/bta_hd_api.c b/bta/hd/bta_hd_api.c
deleted file mode 100644
index 6709c1d..0000000
--- a/bta/hd/bta_hd_api.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/******************************************************************************
-**
-** File Name: bta_hd_api.c
-**
-** Description: This is the API functions for the HID Device
-** service.
-**
-** Copyright (c) 2002-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-******************************************************************************/
-
-#include "bta_api.h"
-#include "bd.h"
-#include "bta_sys.h"
-#include "bta_hd_api.h"
-#include "bta_hd_int.h"
-#include "gki.h"
-#include <string.h>
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-static const tBTA_SYS_REG bta_hd_reg =
-{
- bta_hd_hdl_event,
- BTA_HdDisable
-};
-
-/*******************************************************************************
-**
-** Function BTA_HdEnable
-**
-** Description Enable the HID Device service. When the enable
-** operation is complete the callback function will be
-** called with a BTA_HD_ENABLE_EVT. This function must
-** be called before other function in the HD API are
-** called.
-**
-** If all bytes of the specified bd_addr are 0xff, the
-** peer address is considered as unknown. The HID device listens
-** for incoming connection request.
-** Otherwise, The HID device initiates a connection toward the
-** specified bd_addr when BTA_HdOpen() is called.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_HdEnable(BD_ADDR bd_addr, tBTA_SEC sec_mask, const char *p_service_name,
- tBTA_HD_CBACK *p_cback, UINT8 app_id)
-{
- tBTA_HD_API_ENABLE *p_buf;
-
-
- /* register with BTA system manager */
- GKI_sched_lock();
- bta_sys_register(BTA_ID_HD, &bta_hd_reg);
- GKI_sched_unlock();
-
- if ((p_buf = (tBTA_HD_API_ENABLE *) GKI_getbuf(sizeof(tBTA_HD_API_ENABLE))) != NULL)
- {
- p_buf->hdr.event = BTA_HD_API_ENABLE_EVT;
- p_buf->app_id = app_id;
- if(p_service_name)
- {
- BCM_STRNCPY_S(p_buf->service_name, sizeof(p_buf->service_name), p_service_name, BTA_SERVICE_NAME_LEN);
- p_buf->service_name[BTA_SERVICE_NAME_LEN] = 0;
- }
- else
- {
- p_buf->service_name[0] = 0;
- }
- p_buf->p_cback = p_cback;
- bdcpy(p_buf->bd_addr, bd_addr);
- p_buf->sec_mask = sec_mask;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_HdDisable
-**
-** Description Disable the HID Device service.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_HdDisable(void)
-{
- BT_HDR *p_buf;
-
- bta_sys_deregister(BTA_ID_HD);
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_HD_API_DISABLE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_HdOpen
-**
-** Description Opens an HID Device connection to a peer device.
-** When connection is open, callback function is called
-** with a BTA_HD_OPEN_EVT.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_HdOpen(tBTA_SEC sec_mask)
-{
- tBTA_HD_API_OPEN *p_buf;
-
- if ((p_buf = (tBTA_HD_API_OPEN *) GKI_getbuf(sizeof(tBTA_HD_API_OPEN))) != NULL)
- {
- p_buf->hdr.event = BTA_HD_API_OPEN_EVT;
- p_buf->sec_mask = sec_mask;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_HdClose
-**
-** Description Close the current connection a peer device.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_HdClose(void)
-{
- BT_HDR *p_buf;
-
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_HD_API_CLOSE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function BTA_HdSendRegularKey
-**
-** Description Send a key report to the connected host.
-** If auto_release is TRUE, assume the keyboard report must be
-** a key press. An associated key release report is also sent.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_HdSendRegularKey (UINT8 modifier, UINT8 key_code, BOOLEAN auto_release)
-{
- tBTA_HD_API_INPUT *p_buf;
-
- if ((p_buf = (tBTA_HD_API_INPUT *) GKI_getbuf(sizeof(tBTA_HD_API_INPUT))) != NULL)
- {
- p_buf->hdr.event = BTA_HD_API_INPUT_EVT;
- p_buf->rid = BTA_HD_REPT_ID_KBD;
- p_buf->keyCode = key_code;
- p_buf->buttons = modifier;
- p_buf->release = auto_release;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_HdSendSpecialKey
-**
-** Description Send a special key report to the connected host.
-** The report is sent as a keyboard report.
-** If auto_release is TRUE, assume the keyboard report must be
-** a key press. An associated key release report is also sent.
-** If key_len is less than BTA_HD_KBD_REPT_SIZE, the key_seq
-** is padded with 0 until BTA_HD_KBD_REPT_SIZE.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_HdSendSpecialKey (UINT8 key_len, UINT8 * key_seq, BOOLEAN auto_release)
-{
- tBTA_HD_API_INPUT_SPEC *p_buf;
-
- if ((p_buf = (tBTA_HD_API_INPUT_SPEC *) GKI_getbuf(
- (UINT16)(sizeof(tBTA_HD_API_INPUT_SPEC)+key_len))) != NULL)
- {
- p_buf->hdr.event = BTA_HD_API_INPUT_EVT;
- p_buf->rid = BTA_HD_REPT_ID_SPEC;
- p_buf->len = key_len;
- p_buf->seq = (UINT8 *)(p_buf+1);
- p_buf->release = auto_release;
- memcpy(p_buf->seq, key_seq, key_len);
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_HdSendMouseReport
-**
-** Description Send a mouse report to the connected host
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_HdSendMouseReport (UINT8 is_left, UINT8 is_right, UINT8 is_middle,
- INT8 delta_x, INT8 delta_y, INT8 delta_wheel)
-{
- tBTA_HD_API_INPUT *p_buf;
-
- if ((p_buf = (tBTA_HD_API_INPUT *) GKI_getbuf(sizeof(tBTA_HD_API_INPUT))) != NULL)
- {
- p_buf->hdr.event = BTA_HD_API_INPUT_EVT;
- p_buf->rid = BTA_HD_REPT_ID_MOUSE;
- p_buf->keyCode = (UINT8)delta_x;
- p_buf->keyCode2 = (UINT8)delta_y;
- p_buf->buttons = (is_left ? 0x01 : 0x00) |
- (is_right ? 0x02 : 0x00) |
- (is_middle ? 0x04 : 0x00);
- p_buf->wheel = (UINT8)delta_wheel;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-
-
diff --git a/bta/hd/bta_hd_cfg.c b/bta/hd/bta_hd_cfg.c
deleted file mode 100644
index 4256ba2..0000000
--- a/bta/hd/bta_hd_cfg.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_hd_cfg.c
-**
-** Description: This file contains compile-time configurable constants
-** for HID Device
-**
-** Copyright (c) 2004, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "gki.h"
-#include "bta_api.h"
-#include "bd.h"
-#include "bta_hd_api.h"
-
-const UINT8 bta_hd_cfg_report[] =
-{
- 0x05, 0x01, /* Usage page Desktop 01 */
- 0x09, 0x06, /* Usage Keyboard 06 */
- 0xa1, 0x01, /* Collection appliction */
- 0x05, 0x07, /* Usage page Keyboard */
- 0x85, BTA_HD_REPT_ID_KBD, /* Report ID 1 */
- 0x19, 0xe0, /* Usage minimum e0 (leftControl) */
- 0x29, 0xe7, /* Usage maximum e7 (right gui) */
- 0x15, 0x00, /* Logical mimumum 0 */
- 0x25, 0x01, /* Logical Maximum 1 */
- 0x75, 0x01, /* Report size 1 */
- 0x95, 0x08, /* Report count 8 */
- 0x81, 0x02, /* Input Variable Abs */
- 0x95, 0x01, /* Report count 1 */
- 0x75, 0x08, /* Report size 8 */
- 0x81, 0x01, /* Iput constant variable */
- 0x95, 0x05, /* report count 5 */
- 0x75, 0x01, /* Report size 1 */
- 0x05, 0x08, /* LED page */
- 0x19, 0x01, /* Usage minimum 1 Num lock */
- 0x29, 0x05, /* Usage maximum 5 Kana */
- 0x91, 0x02, /* Output Data, Variable, Absolute */
- 0x95, 0x01, /* Report Count 1 */
- 0x75, 0x03, /* Report Size 3 */
- 0x91, 0x01, /* Output constant, Absolute */
- 0x95, 0x06, /* Report Count 6 */
- 0x75, 0x08, /* Report size 8 */
- 0x15, 0x00, /* Logical mimumum 0 */
- 0x26, 0xa4, 0x00, /* Logical Maximum 00a4 */
- 0x05, 0x07, /* Usage page Keyboard */
- 0x19, 0x00, /* Usage minimum 0 */
- 0x29, 0xa4, /* Usage maximum a4 */
- 0x81, 0x00, /* Input data array absolute */
- 0xc0,
-
- 0x05, 0x01, /* Usage page Desktop 01 */
- 0x09, 0x02, /* Usage 2 Mouse */
- 0xa1, 0x01, /* Collection appliction */
- 0x09, 0x01, /* Usage 1 pointer */
- 0xa1, 0x00, /* Collection physical */
- 0x85, BTA_HD_REPT_ID_MOUSE, /* report id 2 */
- 0x05, 0x09, /* Usage page button */
- 0x19, 0x01, /* Usage minimum 1 */
- 0x29, 0x03, /* Usage maximum 3 */
- 0x15, 0x00, /* Logical mimumum 0 */
- 0x25, 0x01, /* Logical Maximum 1 */
- 0x95, 0x03, /* Report Count 3 */
- 0x75, 0x01, /* Report size 1 */
- 0x81, 0x02, /* Input Variable Abs */
- 0x95, 0x01, /* Report Count 1 */
- 0x75, 0x05, /* Report size 5 */
- 0x81, 0x03, /* Input const var Abs */
-
- 0x05, 0x01, /* Usage page Desktop 01 */
- 0x09, 0x30, /* Usage X */
- 0x09, 0x31, /* Usage Y */
- 0x09, 0x38, /* Usage Wheel */
- 0x15, 0x81, /* Logical mimumum -127 */
- 0x25, 0x7f, /* Logical Maximum 127 */
- 0x75, 0x08, /* Report size 8 */
- 0x95, 0x03, /* Report Count 3 */
- 0x81, 0x06, /* Input Variable relative */
- 0xc0,
- 0xc0,
-
- 0x05, 0x0c, /* Usage page (consumer page) */
- 0x09, 0x01, /* Usage Consumer control */
- 0xa1, 0x01, /* Collection appliction */
- 0x85, BTA_HD_REPT_ID_CONSUMER, /* Report ID 3 */
- 0x75, 0x10, /* report size 16 */
- 0x95, 0x02, /* report count 2 */
- 0x15, 0x01, /* Logical mimumum 1 */
- 0x26, 0x8c, 0x02, /* Logical Maximum 028c */
- 0x19, 0x01, /* Usage minimum 1 */
- 0x2a, 0x8c, 0x02, /* Usage maximum 028c */
- 0x81, 0x60, /* Input Data array absolute No preferred, Null state */
- 0xc0,
-};
-
-
-const tBTA_HD_CFG bta_hd_cfg =
-{
- {
- {
- 0, /* qos_flags */
- 1, /* service type */
- 800, /* token rate (bytes/second) */
- 8, /* token_bucket_size (bytes) */
- 0, /* peak_bandwidth (bytes/second) */
- 0xffffffff, /* latency(microseconds) */
- 0xffffffff /* delay_variation(microseconds) */
- }, /* ctrl_ch */
- {
- 0, /* qos_flags */
- 1, /* service type */
- 300, /* token rate (bytes/second) */
- 4, /* token_bucket_size (bytes) */
- 300, /* peak_bandwidth (bytes/second) */
- 10000, /* latency(microseconds) */
- 10000 /* delay_variation(microseconds) */
- }, /* int_ch */
- {
- 0, /* qos_flags */
- 2, /* service type */
- 400, /* token rate (bytes/second) */
- 8, /* token_bucket_size (bytes) */
- 800, /* peak_bandwidth (bytes/second) */
- 10000, /* latency(microseconds) */
- 10000 /* delay_variation(microseconds) */
- } /* hci */
- }, /* qos */
- {
- "BTA HID Device", /* Service name */
- "Remote Control", /* Service Description */
- "Broadcom Corp", /* Provider Name.*/
- 0x0100, /* HID device release number */
- 0x0111, /* HID Parser Version.*/
- HID_SSR_PARAM_INVALID, /* SSR max latency */
- HID_SSR_PARAM_INVALID, /* SSR min timeout */
- BTM_COD_MINOR_COMBO,/*Device Subclass.*/
- 0, /* Country Code. (0 for not localized) */
- 0, /* Supervisory Timeout */
- {
- sizeof(bta_hd_cfg_report), /* size of report descriptor */
- (UINT8 *)bta_hd_cfg_report,/* config report descriptor */
- }, /* dscp_info */
- 0 /* p_sdp_layer_rec */
- }, /* sdp info */
- 1 /* use QoS */
-};
-
-tBTA_HD_CFG *p_bta_hd_cfg = (tBTA_HD_CFG *) &bta_hd_cfg;
-
diff --git a/bta/hd/bta_hd_int.h b/bta/hd/bta_hd_int.h
deleted file mode 100644
index 4ea5365..0000000
--- a/bta/hd/bta_hd_int.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/******************************************************************************
-**
-** File Name: bta_hd_int.h
-**
-** Description: This is the internal header file for the HID Device service.
-**
-** Copyright (c) 2002-2009, Broadcom Corp., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-******************************************************************************/
-
-#ifndef BTA_HD_INT_H
-#define BTA_HD_INT_H
-
-#include "bt_types.h"
-#include "gki.h"
-#include "bta_sys.h"
-#include "bta_hd_api.h"
-
-
-/*****************************************************************************/
-/* C O N S T A N T S */
-/*****************************************************************************/
-
-#define BTA_HD_KEYBOARD_REPORT_SIZE 0x3F
-#define BTA_HD_MOUSE_REPORT_SIZE 0x32
-
-/* BTA_HD State machine events */
-enum
-{
- /* these events are handled by the state machine */
- BTA_HD_API_OPEN_EVT = BTA_SYS_EVT_START(BTA_ID_HD),
- BTA_HD_API_CLOSE_EVT,
- BTA_HD_API_DISABLE_EVT,
- BTA_HD_API_INPUT_EVT,
- BTA_HD_CBACK_EVT,
- BTA_HD_CONNECTED_EVT,
- BTA_HD_DISCONNECTED_EVT,
-
- /* these events are handled outside of the state machine */
- BTA_HD_API_ENABLE_EVT
-};
-#define BTA_HD_INVALID_EVT (BTA_HD_API_ENABLE_EVT + 1)
-
-/*****************************************************************************
-** Data types
-*****************************************************************************/
-
-/* data type for BTA_HD_API_ENABLE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- char service_name[BTA_SERVICE_NAME_LEN+1];
- tBTA_HD_CBACK *p_cback;
- BD_ADDR bd_addr;
- tBTA_SEC sec_mask;
- UINT8 app_id;
-} tBTA_HD_API_ENABLE;
-
-/* data type for BTA_HD_API_OPEN_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_SEC sec_mask;
-} tBTA_HD_API_OPEN;
-
-
-/* data type for BTA_HD_API_INPUT_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_HD_REPT_ID rid;
- UINT8 keyCode; /* if BTA_HD_REPT_ID_MOUSE, X */
- UINT8 keyCode2; /* if BTA_HD_REPT_ID_MOUSE, Y */
- UINT8 wheel; /* BTA_HD_REPT_ID_MOUSE only */
- UINT8 buttons; /* BTA_HD_REPT_ID_MOUSE & BTA_HD_REPT_ID_KBD (modifier) only */
- BOOLEAN release; /* If TRUE, HD sends release key. not used by mouse report */
-} tBTA_HD_API_INPUT;
-
-typedef struct
-{
- BT_HDR hdr;
- tBTA_HD_REPT_ID rid;
- UINT8 len;
- UINT8 *seq;
- BOOLEAN release; /* If TRUE, HD sends release key. */
-} tBTA_HD_API_INPUT_SPEC;
-
-/* data type for BTA_HD_CBACK_EVT */
-typedef struct
-{
- BT_HDR hdr;
- UINT8 event;
- UINT32 data;
- tHID_DEV_CBACK_DATA *pdata;
-} tBTA_HD_CBACK_DATA;
-
-/* union of all event datatypes */
-typedef union
-{
- tBTA_HD_API_ENABLE api_enable;
- tBTA_HD_API_OPEN api_open;
- tBTA_HD_API_INPUT api_input;
- tBTA_HD_API_INPUT_SPEC api_spec;
- tBTA_HD_CBACK_DATA cback_data;
-} tBTA_HD_DATA;
-
-
-/* type for HD control block */
-typedef struct
-{
- BD_ADDR peer_addr; /* peer BD address */
- UINT32 sdp_handle; /* SDP record handle */
- tBTA_HD_CBACK *p_cback; /* application callback function */
- BUFFER_Q out_q; /* Queue for reports */
- tBTA_SEC sec_mask; /* security mask */
- UINT8 state; /* state machine state */
- UINT8 proto; /* protocol (boot or report) */
- UINT8 app_id;
-#if (BTM_SSR_INCLUDED == TRUE)
- BOOLEAN use_ssr; /* TRUE, if SSR is supported on this link */
- TIMER_LIST_ENT timer; /* delay timer to check for SSR */
-#endif
-} tBTA_HD_CB;
-
-/*****************************************************************************/
-/* P U B L I C D A T A */
-/*****************************************************************************/
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* control block declaration */
-#if BTA_DYNAMIC_MEMORY == FALSE
-extern tBTA_HD_CB bta_hd_cb;
-#else
-extern tBTA_HD_CB *bta_hd_cb_ptr;
-#define bta_hd_cb (*bta_hd_cb_ptr)
-#endif
-
-/* config struct */
-extern tBTA_HD_CFG *p_bta_hd_cfg;
-
-/* rc id config struct */
-extern UINT16 *p_bta_hd_rc_id;
-
-/*****************************************************************************/
-/* F U N C T I O N P R O T O T Y P E S */
-/*****************************************************************************/
-
-/* from bta_hd_main.c */
-extern BOOLEAN bta_hd_hdl_event(BT_HDR *p_msg);
-extern void bta_hd_sm_execute(tBTA_HD_CB *p_cb, UINT16 event, tBTA_HD_DATA *p_data);
-/* from bta_hd_act.c */
-extern void bta_hd_init_con_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data);
-extern void bta_hd_close_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data);
-extern void bta_hd_disable_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data);
-extern void bta_hd_open_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data);
-extern void bta_hd_opn_cb_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data);
-extern void bta_hd_input_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data);
-extern void bta_hd_discntd_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data);
-extern void bta_hd_discnt_act(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data);
-extern void bta_hd_hidd_cback(UINT8 event, UINT32 data, tHID_DEV_CBACK_DATA *pdata);
-#endif /* BTA_HD_INT_H */
-
diff --git a/bta/hd/bta_hd_main.c b/bta/hd/bta_hd_main.c
deleted file mode 100644
index ee3efae..0000000
--- a/bta/hd/bta_hd_main.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/******************************************************************************
-**
-** File Name: bta_hd_main.c
-**
-** Description: This is the state machine definition for the HID Device
-** service.
-**
-** Copyright (c) 2002-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-******************************************************************************/
-
-#include <string.h>
-#include "bt_target.h"
-#include "data_types.h"
-#include "bt_types.h"
-#include "hidd_api.h"
-#include "bta_hd_api.h"
-#include "bta_hd_int.h"
-#include "bd.h"
-
-/*****************************************************************************
-** Constants and types
-*****************************************************************************/
-
-
-/* state machine states */
-enum
-{
- BTA_HD_IDLE_ST,
- BTA_HD_LISTEN_ST,
- BTA_HD_OPEN_ST
-};
-
-/* state machine action enumeration list */
-enum
-{
- BTA_HD_INIT_CON_ACT,
- BTA_HD_CLOSE_ACT,
- BTA_HD_DISABLE_ACT,
- BTA_HD_OPEN_ACT,
- BTA_HD_OPN_CB_ACT,
- BTA_HD_INPUT_ACT,
- BTA_HD_DISCNTD_ACT,
- BTA_HD_DISCNT_ACT,
- BTA_HD_NUM_ACTIONS
-};
-
-#define BTA_HD_IGNORE BTA_HD_NUM_ACTIONS
-
-/* type for action functions */
-typedef void (*tBTA_HD_ACTION)(tBTA_HD_CB *p_cb, tBTA_HD_DATA *p_data);
-
-/* action functions */
-const tBTA_HD_ACTION bta_hd_action[] =
-{
- bta_hd_init_con_act,
- bta_hd_close_act,
- bta_hd_disable_act,
- bta_hd_open_act,
- bta_hd_opn_cb_act,
- bta_hd_input_act,
- bta_hd_discntd_act,
- bta_hd_discnt_act
-};
-
-/* state table information */
-#define BTA_HD_NUM_ACTS 1 /* number of actions */
-#define BTA_HD_ACTION 0 /* position of action */
-#define BTA_HD_NEXT_STATE 1 /* position of next state */
-#define BTA_HD_NUM_COLS 2 /* number of columns in state tables */
-
-/* state table for listen state */
-const UINT8 bta_hd_st_listen[][BTA_HD_NUM_COLS] =
-{
-/* API_OPEN */ {BTA_HD_INIT_CON_ACT, BTA_HD_LISTEN_ST},
-/* API_CLOSE */ {BTA_HD_CLOSE_ACT, BTA_HD_LISTEN_ST},
-/* API_DISABLE */ {BTA_HD_DISABLE_ACT, BTA_HD_IDLE_ST},
-/* API_INPUT */ {BTA_HD_IGNORE, BTA_HD_LISTEN_ST},
-/* CBACK */ {BTA_HD_IGNORE, BTA_HD_LISTEN_ST},
-/* CONNECTED */ {BTA_HD_OPEN_ACT, BTA_HD_OPEN_ST},
-/* DISCONNECT */ {BTA_HD_DISCNTD_ACT, BTA_HD_LISTEN_ST}
-};
-
-/* state table for open state */
-const UINT8 bta_hd_st_open[][BTA_HD_NUM_COLS] =
-{
-/* API_OPEN */ {BTA_HD_IGNORE, BTA_HD_OPEN_ST},
-/* API_CLOSE */ {BTA_HD_CLOSE_ACT, BTA_HD_OPEN_ST},
-/* API_DISABLE */ {BTA_HD_DISABLE_ACT, BTA_HD_IDLE_ST},
-/* API_INPUT */ {BTA_HD_INPUT_ACT, BTA_HD_OPEN_ST},
-/* CBACK */ {BTA_HD_OPN_CB_ACT, BTA_HD_OPEN_ST},
-/* CONNECTED */ {BTA_HD_IGNORE, BTA_HD_OPEN_ST},
-/* DISCONNECT */ {BTA_HD_DISCNT_ACT, BTA_HD_LISTEN_ST}
-};
-
-/* type for state table */
-typedef const UINT8 (*tBTA_HD_ST_TBL)[BTA_HD_NUM_COLS];
-
-/* state table */
-const tBTA_HD_ST_TBL bta_hd_st_tbl[] =
-{
- bta_hd_st_listen,
- bta_hd_st_open
-};
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* HD control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-tBTA_HD_CB bta_hd_cb;
-#endif
-
-
-/*******************************************************************************
-**
-** Function bta_hd_api_enable
-**
-** Description Handle an API enable event.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_hd_api_enable(tBTA_HD_DATA *p_data)
-{
- tHID_DEV_SDP_INFO sdp_info;
- tHID_DEV_REG_INFO reg_info;
- tBTA_SEC sec_mask = p_data->api_enable.sec_mask;
- tBTA_HD_STATUS status = BTA_HD_FAIL;
-
- /* initialize control block */
- memset(&bta_hd_cb, 0, sizeof(tBTA_HD_CB));
- GKI_init_q (&bta_hd_cb.out_q);
-
- /* store parameters */
- bta_hd_cb.p_cback = p_data->api_enable.p_cback;
-
- /* register HID Device to HIDD */
- reg_info.app_cback = bta_hd_hidd_cback;
- bdcpy(reg_info.host_addr, p_data->api_enable.bd_addr);
- if(p_bta_hd_cfg->use_qos)
- reg_info.qos_info = &p_bta_hd_cfg->qos;
- else
- reg_info.qos_info = NULL;
-
-
- if(HID_DevRegister(&reg_info) == HID_SUCCESS)
- {
- HID_DevSetSecurityLevel("BT HID Combo Mouse/Keyboard", sec_mask);
-
- /* register HID Device to SDP */
- memcpy(&sdp_info, &p_bta_hd_cfg->sdp_info, sizeof(tHID_DEV_SDP_INFO));
- if(p_data->api_enable.service_name[0])
- {
- BCM_STRNCPY_S(sdp_info.svc_name, sizeof(sdp_info.svc_name), p_data->api_enable.service_name,
-// btla-specific ++
- sizeof(sdp_info.svc_name));
-// btla-specific --
- }
- bta_hd_cb.sdp_handle = HID_DevSetSDPRecord(&sdp_info);
- }
-
- if(bta_hd_cb.sdp_handle>0)
- {
- status = BTA_HD_SUCCESS;
- bta_hd_cb.state = BTA_HD_LISTEN_ST;
- bta_sys_add_uuid(UUID_SERVCLASS_HUMAN_INTERFACE);
- }
-
- /* call callback with enable event */
- (*bta_hd_cb.p_cback)(BTA_HD_ENABLE_EVT, (tBTA_HD *)&status);
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_sm_execute
-**
-** Description State machine event handling function for HD
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hd_sm_execute(tBTA_HD_CB *p_cb, UINT16 event, tBTA_HD_DATA *p_data)
-{
- tBTA_HD_ST_TBL state_table;
- UINT8 action;
-
- if(p_cb->state == BTA_HD_IDLE_ST)
- {
- APPL_TRACE_EVENT1("HD event=0x%x received in IDLE", event);
- return;
- }
-
- /* look up the state table for the current state */
- state_table = bta_hd_st_tbl[p_cb->state-1];
-
- event &= 0x00FF;
-
- APPL_TRACE_EVENT3("HD event=0x%x state=%d, next: %d",
- event, p_cb->state, state_table[event][BTA_HD_NEXT_STATE]);
- /* set next state */
- p_cb->state = state_table[event][BTA_HD_NEXT_STATE];
- action = state_table[event][BTA_HD_ACTION];
-
- /* execute action functions */
- if (action != BTA_HD_IGNORE)
- {
- (*bta_hd_action[action])(p_cb, p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_hd_hdl_event
-**
-** Description HID Device main event handling function.
-**
-**
-** Returns BOOLEAN
-**
-*******************************************************************************/
-BOOLEAN bta_hd_hdl_event(BT_HDR *p_msg)
-{
- switch (p_msg->event)
- {
- /* handle enable event */
- case BTA_HD_API_ENABLE_EVT:
- bta_hd_api_enable((tBTA_HD_DATA *) p_msg);
- break;
-
- /* all others run through state machine */
- default:
- bta_hd_sm_execute(&bta_hd_cb, p_msg->event, (tBTA_HD_DATA *) p_msg);
- break;
- }
- return TRUE;
-}
-
diff --git a/bta/include/bta_dg_api.h b/bta/include/bta_dg_api.h
deleted file mode 100644
index 3e8b2db..0000000
--- a/bta/include/bta_dg_api.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_dg_api.h
-**
-** Description: This is the public interface file for the data gateway
-** (DG) subsystem of BTA, Widcomm's Bluetooth application
-** layer for mobile phones.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_DG_API_H
-#define BTA_DG_API_H
-
-#include "bta_api.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-/* DG Callback events */
-#define BTA_DG_ENABLE_EVT 0 /* DG service is enabled. */
-#define BTA_DG_LISTEN_EVT 1 /* Server listen is started. */
-#define BTA_DG_OPENING_EVT 2 /* Client connection opening. */
-#define BTA_DG_OPEN_EVT 3 /* Connection has been opened. */
-#define BTA_DG_CLOSE_EVT 4 /* Connection has been closed. */
-
-typedef UINT8 tBTA_DG_EVT;
-
-/* Event associated with BTA_DG_LISTEN_EVT */
-typedef struct
-{
- UINT16 handle; /* Handle associated with this server. */
- UINT8 app_id; /* ID associated with call to BTA_DgListen(). */
-} tBTA_DG_LISTEN;
-
-/* Event associated with BTA_DG_OPENING_EVT */
-typedef struct
-{
- UINT16 handle; /* Handle associated with this server. */
- UINT8 app_id; /* ID associated with call to BTA_DgListen(). */
-} tBTA_DG_OPENING;
-
-
-/* Event associated with BTA_DG_OPEN_EVT */
-typedef struct
-{
- BD_ADDR bd_addr; /* BD address of peer device. */
- UINT16 handle; /* Handle associated with this server. */
- tBTA_SERVICE_ID service; /* Service ID of opened service. */
- UINT8 app_id; /* ID associated with call to BTA_DgListen(). */
-} tBTA_DG_OPEN;
-
-/* Event associated with BTA_DG_CLOSE_EVT */
-typedef struct
-{
- UINT16 handle; /* Handle associated with this server. */
- UINT8 app_id; /* ID associated with call to BTA_DgListen(). */
-} tBTA_DG_CLOSE;
-
-/* Union of all DG callback structures */
-typedef union
-{
- tBTA_DG_LISTEN listen; /* Server listen is started. */
- tBTA_DG_OPENING opening; /* Client connection opening. */
- tBTA_DG_OPEN open; /* Connection has been opened. */
- tBTA_DG_CLOSE close; /* Connection has been closed. */
-} tBTA_DG;
-
-/* DG callback */
-typedef void (tBTA_DG_CBACK)(tBTA_DG_EVT event, tBTA_DG *p_data);
-
-/* configuration structure */
-typedef struct
-{
- UINT16 mtu[4]; /* MTU for SPP, DUN, FAX, LAP */
-
-} tBTA_DG_CFG;
-
-/* Number of DG servers */
-#ifndef BTA_DG_NUM_CONN
-#define BTA_DG_NUM_CONN 5
-#endif
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*******************************************************************************
-**
-** Function BTA_DgEnable
-**
-** Description Enable the data gateway service. This function must be
-** called before any other functions in the DG API are called.
-** When the enable operation is complete the callback function
-** will be called with a BTA_DG_ENABLE_EVT. After the DG
-** service is enabled a server can be started by calling
-** BTA_DgListen().
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_DgEnable(tBTA_DG_CBACK *p_cback);
-
-/*******************************************************************************
-**
-** Function BTA_DgDisable
-**
-** Description Disable the data gateway service. Before calling this
-** function all DG servers must be shut down by calling
-** BTA_DgShutdown().
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_DgDisable(void);
-
-/*******************************************************************************
-**
-** Function BTA_DgListen
-**
-** Description Create a DG server for DUN, FAX or SPP. After creating a
-** server peer devices can open an RFCOMM connection to the
-** server. When the listen operation has started the callback
-** function will be called with a BTA_DG_LISTEN_EVT providing
-** the handle associated with this server. The handle
-** identifies server when calling other DG functions such as
-** BTA_DgClose() or BTA_DgShutdown().
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_DgListen(tBTA_SERVICE_ID service, tBTA_SEC sec_mask,
- char *p_service_name, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function BTA_DgOpen
-**
-** Description Open a DG client connection to a peer device. BTA first
-** searches for the requested service on the peer device. If
-** the service name is specified it will also match the
-** service name. Then BTA initiates an RFCOMM connection to
-** the peer device. The handle associated with the connection
-** is returned with the BTA_DG_OPEN_EVT. If the connection
-** fails or closes at any time the callback function will be
-** called with a BTA_DG_CLOSE_EVT.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_DgOpen(BD_ADDR bd_addr, tBTA_SERVICE_ID service,
- tBTA_SEC sec_mask, char *p_service_name, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function BTA_DgClose
-**
-** Description Close a DG connection to a peer device. BTA will
-** close the RFCOMM connection to the peer device. Servers
-** will still be listening for subsequent connections.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_DgClose(UINT16 handle);
-
-/*******************************************************************************
-**
-** Function BTA_DgShutdown
-**
-** Description Shutdown a DG server previously started by calling
-** BTA_DgListen(). The server will no longer be available
-** to peer devices. If there is currently a connection open
-** to the server it will be closed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_DgShutdown(UINT16 handle);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BTA_DG_API_H */
-
diff --git a/bta/include/bta_dg_ci.h b/bta/include/bta_dg_ci.h
deleted file mode 100644
index 1f52ab2..0000000
--- a/bta/include/bta_dg_ci.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_dg_ci.h
-**
-** Description: This is the interface file for data gateway call-in
-** functions.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_DG_CI_H
-#define BTA_DG_CI_H
-
-#include "bta_dg_api.h"
-
-/*****************************************************************************
-** Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*******************************************************************************
-**
-** Function bta_dg_ci_tx_ready
-**
-** Description This function sends an event to DG indicating the phone is
-** ready for more data and DG should call bta_dg_co_tx_path().
-** This function is used when the TX data path is configured
-** to use a pull interface.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_ci_tx_ready(UINT16 handle);
-
-/*******************************************************************************
-**
-** Function bta_dg_ci_rx_ready
-**
-** Description This function sends an event to DG indicating the phone
-** has data available to send to DG and DG should call
-** bta_dg_co_rx_path(). This function is used when the RX
-** data path is configured to use a pull interface.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_ci_rx_ready(UINT16 handle);
-
-/*******************************************************************************
-**
-** Function bta_dg_ci_tx_flow
-**
-** Description This function is called to enable or disable data flow on
-** the TX path. The phone should call this function to
-** disable data flow when it is congested and cannot handle
-** any more data sent by bta_dg_co_tx_write() or
-** bta_dg_co_tx_writebuf(). This function is used when the
-** TX data path is configured to use a push interface.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_ci_tx_flow(UINT16 handle, BOOLEAN enable);
-
-/*******************************************************************************
-**
-** Function bta_dg_ci_rx_writebuf
-**
-** Description This function is called to send data to the phone when
-** the RX path is configured to use a push interface with
-** zero copy. The function sends an event to DG containing
-** the data buffer. The buffer must be allocated using
-** functions GKI_getbuf() or GKI_getpoolbuf(). The buffer
-** will be freed by BTA; the phone must not free the buffer.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_ci_rx_writebuf(UINT16 handle, BT_HDR *p_buf);
-
-/*******************************************************************************
-**
-** Function bta_dg_ci_control
-**
-** Description This function is called to send RS-232 signal information
-** to DG to be propagated over RFCOMM.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_ci_control(UINT16 handle, UINT8 signals, UINT8 values);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BTA_DG_CI_H */
-
diff --git a/bta/include/bta_dg_co.h b/bta/include/bta_dg_co.h
deleted file mode 100644
index 667a01c..0000000
--- a/bta/include/bta_dg_co.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_dg_co.h
-**
-** Description: This is the interface file for data gateway call-out
-** functions.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_DG_CO_H
-#define BTA_DG_CO_H
-
-#include "bta_dg_api.h"
-#include "l2c_api.h"
-#include "rfcdefs.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-/* RS-232 Signal Mask */
-#define BTA_DG_DTRDSR 0x01 /* DTR/DSR signal. */
-#define BTA_DG_RTSCTS 0x02 /* RTS/CTS signal. */
-#define BTA_DG_RI 0x04 /* Ring indicator signal. */
-#define BTA_DG_CD 0x08 /* Carrier detect signal. */
-
-/* RS-232 Signal Values */
-#define BTA_DG_DTRDSR_ON 0x01 /* DTR/DSR signal on. */
-#define BTA_DG_DTRDSR_OFF 0x00 /* DTR/DSR signal off. */
-#define BTA_DG_RTSCTS_ON 0x02 /* RTS/CTS signal on. */
-#define BTA_DG_RTSCTS_OFF 0x00 /* RTS/CTS signal off. */
-#define BTA_DG_RI_ON 0x04 /* Ring indicator signal on. */
-#define BTA_DG_RI_OFF 0x00 /* Ring indicator signal off. */
-#define BTA_DG_CD_ON 0x08 /* Carrier detect signal on. */
-#define BTA_DG_CD_OFF 0x00 /* Carrier detect signal off. */
-
-/* Data Flow Mask */
-#define BTA_DG_RX_PUSH_BUF 0x01 /* RX push with zero copy. */
-#define BTA_DG_RX_PULL 0x02 /* RX pull. */
-#define BTA_DG_TX_PUSH 0x00 /* TX push. */
-#define BTA_DG_TX_PUSH_BUF 0x10 /* TX push with zero copy. */
-#define BTA_DG_TX_PULL 0x20 /* TX pull. */
-
-/* BT_HDR buffer offset */
-#define BTA_DG_MIN_OFFSET (L2CAP_MIN_OFFSET + RFCOMM_MIN_OFFSET)
-
-/*****************************************************************************
-** Function Declarations
-*****************************************************************************/
-
-/*******************************************************************************
-**
-** Function bta_dg_co_init
-**
-** Description This callout function is executed by DG when a server is
-** started by calling BTA_DgListen(). This function can be
-** used by the phone to initialize data paths or for other
-** initialization purposes. The function must return the
-** data flow mask as described below.
-**
-**
-** Returns Data flow mask.
-**
-*******************************************************************************/
-BTA_API extern UINT8 bta_dg_co_init(UINT16 handle, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function bta_dg_co_open
-**
-** Description This function is executed by DG when a connection to a
-** server is opened. The phone can use this function to set
-** up data paths or perform any required initialization or
-** set up particular to the connected service.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_co_open(UINT16 handle, UINT8 app_id, tBTA_SERVICE_ID service, UINT16 mtu);
-
-/*******************************************************************************
-**
-** Function bta_dg_co_close
-**
-** Description This function is called by DG when a connection to a
-** server is closed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_co_close(UINT16 handle, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function bta_dg_co_tx_path
-**
-** Description This function is called by DG to transfer data on the
-** TX path; that is, data being sent from BTA to the phone.
-** This function is used when the TX data path is configured
-** to use the pull interface. The implementation of this
-** function will typically call Bluetooth stack functions
-** PORT_Read() or PORT_ReadData() to read data from RFCOMM
-** and then a platform-specific function to send data that
-** data to the phone.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_co_tx_path(UINT16 handle, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function bta_dg_co_rx_path
-**
-** Description This function is called by DG to transfer data on the
-** RX path; that is, data being sent from the phone to BTA.
-** This function is used when the RX data path is configured
-** to use the pull interface. The implementation of this
-** function will typically call a platform-specific function
-** to read data from the phone and then call Bluetooth stack
-** functions PORT_Write() or PORT_WriteData() to send data
-** to RFCOMM.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_co_rx_path(UINT16 handle, UINT8 app_id, UINT16 mtu);
-
-/*******************************************************************************
-**
-** Function bta_dg_co_tx_write
-**
-** Description This function is called by DG to send data to the phone
-** when the TX path is configured to use a push interface.
-** The implementation of this function must copy the data to
-** the phone's memory.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_co_tx_write(UINT16 handle, UINT8 app_id, UINT8 *p_data, UINT16 len);
-
-/*******************************************************************************
-**
-** Function bta_dg_co_tx_writebuf
-**
-** Description This function is called by DG to send data to the phone
-** when the TX path is configured to use a push interface with
-** zero copy. The phone must free the buffer using function
-** GKI_freebuf() when it is through processing the buffer.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_co_tx_writebuf(UINT16 handle, UINT8 app_id, BT_HDR *p_buf);
-
-/*******************************************************************************
-**
-** Function bta_dg_co_rx_flow
-**
-** Description This function is called by DG to enable or disable
-** data flow on the RX path when it is configured to use
-** a push interface. If data flow is disabled the phone must
-** not call bta_dg_ci_rx_write() or bta_dg_ci_rx_writebuf()
-** until data flow is enabled again.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_co_rx_flow(UINT16 handle, UINT8 app_id, BOOLEAN enable);
-
-/*******************************************************************************
-**
-** Function bta_dg_co_control
-**
-** Description This function is called by DG to send RS-232 signal
-** information to the phone. This function allows these
-** signals to be propagated from the RFCOMM channel to the
-** phone. If the phone does not use these signals the
-** implementation of this function can do nothing.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_dg_co_control(UINT16 handle, UINT8 app_id, UINT8 signals, UINT8 values);
-
-#endif /* BTA_DG_CO_H */
-
diff --git a/bta/include/bta_ft_api.h b/bta/include/bta_ft_api.h
deleted file mode 100644
index 96ed66f..0000000
--- a/bta/include/bta_ft_api.h
+++ /dev/null
@@ -1,724 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ft_api.h
-**
-** Description: This is the public interface file for the file transfer
-** (FT) server subsystem of BTA, Widcomm's
-** Bluetooth application layer for mobile phones.
-**
-** Copyright (c) 2003-2009, Broadcom Corp., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_FT_API_H
-#define BTA_FT_API_H
-
-#include "bta_api.h"
-#include "btm_api.h"
-#if( defined BIP_INCLUDED) && (BIP_INCLUDED == TRUE)
-#include "bip_api.h"
-#endif
-#include "bta_sys.h"
-#include "bta_fs_co.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-#define BTA_FT_ENHANCED_VERSION 0x0102
-
-/**************************
-** Common Definitions
-***************************/
-/* Access response types */
-#define BTA_FT_ACCESS_ALLOW 0 /* Allow the requested operation */
-#define BTA_FT_ACCESS_FORBID 1 /* Disallow the requested operation */
-
-typedef UINT8 tBTA_FT_ACCESS;
-
-/* Access event operation types */
-#define BTA_FT_OPER_DEFAULT 0 /* Default mode */
-#define BTA_FT_OPER_PUT 1 /* Request is a PUT file */
-#define BTA_FT_OPER_GET 2 /* Request is a GET file */
-#define BTA_FT_OPER_DEL_FILE 3 /* Request is a DELETE file */
-#define BTA_FT_OPER_DEL_DIR 4 /* Request is a DELETE folder */
-#define BTA_FT_OPER_CHG_DIR 5 /* Request is a Change Folder */
-#define BTA_FT_OPER_MK_DIR 6 /* Request is a Make Folder */
-#define BTA_FT_OPER_COPY_ACT 7 /* Request is a Copy Action command */
-#define BTA_FT_OPER_MOVE_ACT 8 /* Request is a Move Action command */
-#define BTA_FT_OPER_SET_PERM 9 /* Request is a SetPermission Action command */
-
-typedef UINT8 tBTA_FT_OPER;
-
-#define BTA_FT_ACT_COPY OBX_ACT_COPY /* 0x00 Copy object */
-#define BTA_FT_ACT_MOVE OBX_ACT_MOVE /* 0x01 Move/rename object */
-#define BTA_FT_ACT_PERMISSION OBX_ACT_PERMISSION /* 0x02 Set object permission */
-typedef tOBX_ACTION tBTA_FTC_ACT;
-
-#define BTA_FTC_RESUME_NONCE 0xFFFFFFFF
-
-/* permission flags */
-#define BTA_FT_PERMISSION_READ OBX_PERMISSION_READ /* 0x01 */
-#define BTA_FT_PERMISSION_WRITE OBX_PERMISSION_WRITE /* 0x02 */
-#define BTA_FT_PERMISSION_DELETE OBX_PERMISSION_DELETE /* 0x04 */
-#define BTA_FT_PERMISSION_MODIFY OBX_PERMISSION_MODIFY /* 0x80 */
-
-/**************************
-** Server Definitions
-***************************/
-/* Extra Debug Code */
-#ifndef BTA_FTS_DEBUG
-#define BTA_FTS_DEBUG FALSE
-#endif
-
-#define BTA_FTS_OK 0
-#define BTA_FTS_FAIL 1
-typedef UINT8 tBTA_FTS_STATUS;
-
-/* Server callback function events */
-#define BTA_FTS_ENABLE_EVT 0 /* File transfer server is enabled. */
-#define BTA_FTS_OPEN_EVT 1 /* Connection to peer is open. */
-#define BTA_FTS_CLOSE_EVT 2 /* Connection to peer closed. */
-#define BTA_FTS_AUTH_EVT 3 /* Request for Authentication key and realm */
-#define BTA_FTS_ACCESS_EVT 4 /* Request for access to put a file */
-#define BTA_FTS_PROGRESS_EVT 5 /* Number of bytes read or written so far */
-#define BTA_FTS_PUT_CMPL_EVT 6 /* File Put complete */
-#define BTA_FTS_GET_CMPL_EVT 7 /* File Get complete */
-#define BTA_FTS_DEL_CMPL_EVT 8 /* Remove File or Folder complete */
-#define BTA_FTS_DISABLE_EVT 9 /* Reply to a disable api request */
-
-typedef UINT8 tBTA_FTS_EVT;
-
-/* Structure associated with BTA_FTS_xxx_CMPL_EVT */
-typedef struct
-{
- char *p_name; /* file or folder name. */
- tBTA_FTS_STATUS status;
-} tBTA_FTS_OBJECT;
-
-typedef struct
-{
- UINT32 file_size; /* Total size of file (BTA_FS_LEN_UNKNOWN if unknown) */
- UINT16 bytes; /* Number of bytes read or written since last progress event */
-} tBTA_FTS_PROGRESS;
-
-typedef struct
-{
-
- UINT8 *p_userid;
- UINT8 userid_len;
- BOOLEAN userid_required; /* TRUE if user ID is required in response (rechallanged) */
-} tBTA_FTS_AUTH;
-
-typedef struct
-{
- char *p_name; /* file name with fully qualified path */
- UINT32 size; /* file size */
- tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
- tBTA_FT_OPER oper; /* operation (put) */
- BD_ADDR bd_addr; /* Address of device */
- char *p_dest_name; /* destination file name with fully qualified path (BTA_FT_OPER_COPY_ACT & BTA_FT_OPER_MOVE_ACT) */
- UINT8 perms[BTA_FS_PERM_SIZE]; /* user/group/other permission (BTA_FT_OPER_SET_PERM) */
-} tBTA_FTS_ACCESS;
-
-typedef union
-{
- tBTA_FTS_STATUS status;
- tBTA_FTS_PROGRESS prog;
- tBTA_FTS_AUTH auth;
- tBTA_FTS_ACCESS access;
- tBTA_FTS_OBJECT obj;
- BD_ADDR bd_addr;
-} tBTA_FTS;
-
-/* Server callback function */
-typedef void tBTA_FTS_CBACK(tBTA_FTS_EVT event, tBTA_FTS *p_data);
-
-
-/**************************
-** Client Definitions
-***************************/
-/* Extra Debug Code */
-#ifndef BTA_FTC_DEBUG
-#define BTA_FTC_DEBUG FALSE
-#endif
-
-/* Additional paramters for BTA_FtcPutFile using BIP service */
-typedef union
-{
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
- tBIP_IMAGE_DESC desc; /* when connectied with BIP service */
-#else
- void* desc;
-#endif
-} tBTA_FTC_PARAM;
-
-/* Client callback function events */
-#define BTA_FTC_ENABLE_EVT 0 /* File transfer client is enabled. */
-#define BTA_FTC_OPEN_EVT 1 /* Connection to peer is open. */
-#define BTA_FTC_CLOSE_EVT 2 /* Connection to peer closed. */
-#define BTA_FTC_AUTH_EVT 3 /* Request for Authentication key and user id */
-#define BTA_FTC_LIST_EVT 4 /* Event contains a directory entry (tBTA_FTC_LIST) */
-#define BTA_FTC_PROGRESS_EVT 5 /* Number of bytes read or written so far */
-#define BTA_FTC_PUTFILE_EVT 6 /* File Put complete */
-#define BTA_FTC_GETFILE_EVT 7 /* File Get complete */
-#define BTA_FTC_BI_CAPS_EVT 8 /* BIP imaging capabilities */
-#define BTA_FTC_THUMBNAIL_EVT 9 /* BIP responder requests for the thumbnail version */
-#define BTA_FTC_CHDIR_EVT 10 /* Change Directory complete */
-#define BTA_FTC_MKDIR_EVT 11 /* Make Directory complete */
-#define BTA_FTC_REMOVE_EVT 12 /* Remove File/Directory complete */
-#define BTA_FTC_PHONEBOOK_EVT 13 /* Report the Application Parameters for BTA_FtcGetPhoneBook response */
-#define BTA_FTC_COPY_EVT 14 /* Copy File complete */
-#define BTA_FTC_MOVE_EVT 15 /* Move File complete */
-#define BTA_FTC_PERMISSION_EVT 16 /* Set File permission complete */
-
-
-typedef UINT8 tBTA_FTC_EVT;
-
-
-#define BTA_FTC_OK 0
-#define BTA_FTC_FAIL 1
-#define BTA_FTC_NO_PERMISSION 2
-#define BTA_FTC_NOT_FOUND 3
-#define BTA_FTC_FULL 4
-#define BTA_FTC_BUSY 5
-#define BTA_FTC_ABORTED 6
-#define BTA_FTC_SERVICE_UNAVL 7
-#define BTA_FTC_SDP_ERR 8
-#define BTA_FTC_OBX_ERR 9
-#define BTA_FTC_OBX_TOUT 10
-
-typedef UINT8 tBTA_FTC_STATUS;
-
-#define BTA_FTC_FLAG_NONE 0
-#define BTA_FTC_FLAG_BACKUP 1
-
-typedef UINT8 tBTA_FTC_FLAG;
-
-typedef struct
-{
- tBTA_SERVICE_ID service; /* Connection is open with OPP, BIP, PBAP or FTP service */
- UINT16 version;
-} tBTA_FTC_OPEN;
-
-#define BTA_FTC_FILTER_VERSION (1<<0) /* Version */
-#define BTA_FTC_FILTER_FN (1<<1) /* Formatted Name */
-#define BTA_FTC_FILTER_N (1<<2) /* Structured Presentation of Name */
-#define BTA_FTC_FILTER_PHOTO (1<<3) /* Associated Image or Photo */
-#define BTA_FTC_FILTER_BDAY (1<<4) /* Birthday */
-#define BTA_FTC_FILTER_ADR (1<<5) /* Delivery Address */
-#define BTA_FTC_FILTER_LABEL (1<<6) /* Delivery */
-#define BTA_FTC_FILTER_TEL (1<<7) /* Telephone Number */
-#define BTA_FTC_FILTER_EMAIL (1<<8) /* Electronic Mail Address */
-#define BTA_FTC_FILTER_MAILER (1<<9) /* Electronic Mail */
-#define BTA_FTC_FILTER_TZ (1<<10) /* Time Zone */
-#define BTA_FTC_FILTER_GEO (1<<11) /* Geographic Position */
-#define BTA_FTC_FILTER_TITLE (1<<12) /* Job */
-#define BTA_FTC_FILTER_ROLE (1<<13) /* Role within the Organization */
-#define BTA_FTC_FILTER_LOGO (1<<14) /* Organization Logo */
-#define BTA_FTC_FILTER_AGENT (1<<15) /* vCard of Person Representing */
-#define BTA_FTC_FILTER_ORG (1<<16) /* Name of Organization */
-#define BTA_FTC_FILTER_NOTE (1<<17) /* Comments */
-#define BTA_FTC_FILTER_REV (1<<18) /* Revision */
-#define BTA_FTC_FILTER_SOUND (1<<19) /* Pronunciation of Name */
-#define BTA_FTC_FILTER_URL (1<<20) /* Uniform Resource Locator */
-#define BTA_FTC_FILTER_UID (1<<21) /* Unique ID */
-#define BTA_FTC_FILTER_KEY (1<<22) /* Public Encryption Key */
-#define BTA_FTC_FILTER_ALL (0)
-typedef UINT32 tBTA_FTC_FILTER_MASK;
-
-enum
-{
- BTA_FTC_FORMAT_CARD_21, /* vCard format 2.1 */
- BTA_FTC_FORMAT_CARD_30, /* vCard format 3.0 */
- BTA_FTC_FORMAT_MAX
-};
-typedef UINT8 tBTA_FTC_FORMAT;
-
-typedef struct
-{
- UINT16 phone_book_size;
- BOOLEAN pbs_exist; /* phone_book_size is present in the response */
- UINT8 new_missed_calls;
- BOOLEAN nmc_exist; /* new_missed_calls is present in the response */
-} tBTA_FTC_PB_PARAM;
-
-typedef struct
-{
- tBTA_FTC_PB_PARAM *p_param;
- UINT8 *data;
- UINT16 len;
- BOOLEAN final; /* If TRUE, entry is last of the series */
- tBTA_FTC_STATUS status; /* Fields are valid when status is BTA_FTC_OK */
-} tBTA_FTC_LIST;
-
-enum
-{
- BTA_FTC_ORDER_INDEXED = 0, /* indexed */
- BTA_FTC_ORDER_ALPHANUM, /* alphanumeric */
- BTA_FTC_ORDER_PHONETIC, /* phonetic */
- BTA_FTC_ORDER_MAX
-};
-typedef UINT8 tBTA_FTC_ORDER;
-enum
-{
- BTA_FTC_ATTR_NAME = 0, /* name */
- BTA_FTC_ATTR_NUMBER, /* number */
- BTA_FTC_ATTR_SOUND, /* sound */
- BTA_FTC_ATTR_MAX
-};
-typedef UINT8 tBTA_FTC_ATTR;
-
-typedef struct
-{
- UINT32 file_size; /* Total size of file (BTA_FS_LEN_UNKNOWN if unknown) */
- UINT16 bytes; /* Number of bytes read or written since last progress event */
-} tBTA_FTC_PROGRESS;
-
-typedef struct
-{
- UINT8 *p_realm;
- UINT8 realm_len;
- UINT8 realm_charset;
- BOOLEAN userid_required; /* If TRUE, a user ID must be sent */
-} tBTA_FTC_AUTH;
-
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
-typedef struct
-{
- tBIP_IMAGING_CAPS *p_bi_caps; /* BIP imaging capabilities */
-} tBTA_FTC_CAPS;
-
-typedef struct
-{
- UINT8 *p_name; /* the image file name */
- tBIP_IMG_HDL_STR handle; /* The image’s handle assigned by BIP responder. */
-} tBTA_FTC_THUMB;
-#endif
-
-typedef union
-{
- tBTA_FTC_STATUS status;
- tBTA_FTC_OPEN open;
- tBTA_FTC_LIST list;
- tBTA_FTC_PROGRESS prog;
- tBTA_FTC_AUTH auth;
-#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
- tBTA_FTC_CAPS bi_caps;
- tBTA_FTC_THUMB thumb;
-#endif
- tBTA_FTC_PB_PARAM pb;
-} tBTA_FTC;
-
-/* Client callback function */
-typedef void tBTA_FTC_CBACK(tBTA_FTC_EVT event, tBTA_FTC *p_data);
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/**************************
-** Server Functions
-***************************/
-
-/*******************************************************************************
-**
-** Function BTA_FtsEnable
-**
-** Description Enable the file transfer server. This function must be
-** called before any other functions in the FTS API are called.
-** When the enable operation is complete the callback function
-** will be called with an BTA_FTS_ENABLE_EVT event.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtsEnable(tBTA_SEC sec_mask, const char *p_service_name,
- const char *p_root_path, BOOLEAN enable_authen,
- UINT8 realm_len, UINT8 *p_realm,
- tBTA_FTS_CBACK *p_cback, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function BTA_FtsDisable
-**
-** Description Disable the file transfer server. If the server is currently
-** connected to a peer device the connection will be closed.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtsDisable(void);
-
-/*******************************************************************************
-**
-** Function BTA_FtsClose
-**
-** Description Close the current connection. This function is called if
-** the phone wishes to close the connection before the FT
-** client disconnects.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtsClose(void);
-
-/*******************************************************************************
-**
-** Function BTA_FtsUnauthRsp
-**
-** Description Sends an OBEX authentication challenge to the connected
-** OBEX client. Called in response to an BTA_FTS_AUTH_EVT event.
-** Used when "enable_authen" is set to TRUE in BTA_FtsEnable().
-**
-** Note: If the "userid_required" is TRUE in the BTA_FTS_AUTH_EVT
-** event, then p_userid is required, otherwise it is optional.
-**
-** p_password must be less than BTA_FTS_MAX_AUTH_KEY_SIZE (16 bytes)
-** p_userid must be less than OBX_MAX_REALM_LEN (defined in target.h)
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtsAuthRsp (char *p_password, char *p_userid);
-
-/*******************************************************************************
-**
-** Function BTA_FtsAccessRsp
-**
-** Description Sends a reply to an access request event (BTA_FTS_ACCESS_EVT).
-** This call MUST be made whenever the event occurs.
-**
-** Parameters oper - operation being accessed.
-** access - BTA_FT_ACCESS_ALLOW or BTA_FT_ACCESS_FORBID
-** p_name - Full path of file to pulled or pushed.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtsAccessRsp(tBTA_FT_OPER oper, tBTA_FT_ACCESS access,
- char *p_name);
-
-
-/**************************
-** Client Functions
-***************************/
-
-/*******************************************************************************
-**
-** Function BTA_FtcEnable
-**
-** Description Enable the file transfer client. This function must be
-** called before any other functions in the FTC API are called.
-** When the enable operation is complete the callback function
-** will be called with an BTA_FTC_ENABLE_EVT event.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcEnable(tBTA_FTC_CBACK *p_cback, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function BTA_FtcDisable
-**
-** Description Disable the file transfer client. If the client is currently
-** connected to a peer device the connection will be closed.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcDisable(void);
-
-/*******************************************************************************
-**
-** Function BTA_FtcOpen
-**
-** Description Open a connection to an FTP, PBAP, OPP or BIP server.
-** If parameter services is set to use both all services,
-** the client will attempt to connect to the device using
-** FTP first and then PBAP, OPP, BIP.
-** When the connection is open the callback function
-** will be called with a BTA_FTC_OPEN_EVT. If the connection
-** fails or otherwise is closed the callback function will be
-** called with a BTA_FTC_CLOSE_EVT.
-**
-** If the connection is opened with FTP profile and
-** bta_ft_cfg.auto_file_list is TRUE , the callback
-** function will be called with one or more BTA_FTC_LIST_EVT
-** containing directory list information formatted in XML as
-** described in the IrOBEX Spec, Version 1.2, section 9.1.2.3.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcOpen(BD_ADDR bd_addr, tBTA_SEC sec_mask,
- tBTA_SERVICE_MASK services, BOOLEAN srm, UINT32 nonce);
-
-/*******************************************************************************
-**
-** Function BTA_FtcSuspend
-**
-** Description Suspend the current connection to the server.
-** This is allowed only for the sessions created by
-** BTA_FtcConnect with nonce!=0
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcSuspend(void);
-
-/*******************************************************************************
-**
-** Function BTA_FtcClose
-**
-** Description Close the current connection to the server. Aborts any
-** active file transfer.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcClose(void);
-
-/*******************************************************************************
-**
-** Function BTA_FtcCopyFile
-**
-** Description Invoke a Copy action on the server.
-** Create a copy of p_src and name it as p_dest
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcCopyFile(const char *p_src, const char *p_dest);
-
-/*******************************************************************************
-**
-** Function BTA_FtcMoveFile
-**
-** Description Invoke a Move action on the server.
-** Move/rename p_src to p_dest
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcMoveFile(const char *p_src, const char *p_dest);
-
-/*******************************************************************************
-**
-** Function BTA_FtcSetPermission
-**
-** Description Invoke a SetPermission action on the server.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcSetPermission(const char *p_src, UINT8 user, UINT8 group, UINT8 other);
-
-/*******************************************************************************
-**
-** Function BTA_FtcPutFile
-**
-** Description Send a file to the connected server.
-**
-** This function can only be used when the client is connected
-** in FTP, OPP and BIP mode.
-**
-** Note: File name is specified with a fully qualified path.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcPutFile(const char *p_name, tBTA_FTC_PARAM *p_param);
-
-/*******************************************************************************
-**
-** Function BTA_FtcGetPhoneBook
-**
-** Description Retrieve a PhoneBook from the peer device and copy it to the
-** local file system.
-**
-** This function can only be used when the client is connected
-** in PBAP mode.
-**
-** Note: local file name is specified with a fully qualified path.
-** Remote file name is absolute path in UTF-8 format
-** (telecom/pb.vcf or SIM1/telecom/pb.vcf).
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcGetPhoneBook(char *p_local_name, char *p_remote_name,
- tBTA_FTC_FILTER_MASK filter, tBTA_FTC_FORMAT format,
- UINT16 max_list_count, UINT16 list_start_offset);
-
-/*******************************************************************************
-**
-** Function BTA_FtcGetCard
-**
-** Description Retrieve a vCard from the peer device and copy it to the
-** local file system.
-**
-** This function can only be used when the client is connected
-** in PBAP mode.
-**
-** Note: local file name is specified with a fully qualified path.
-** Remote file name is relative path in UTF-8 format.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcGetCard(char *p_local_name, char *p_remote_name,
- tBTA_FTC_FILTER_MASK filter, tBTA_FTC_FORMAT format);
-
-/*******************************************************************************
-**
-** Function BTA_FtcGetFile
-**
-** Description Retrieve a file from the peer device and copy it to the
-** local file system.
-**
-** This function can only be used when the client is connected
-** in FTP mode.
-**
-** Note: local file name is specified with a fully qualified path.
-** Remote file name is specified in UTF-8 format.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcGetFile(char *p_local_name, char *p_remote_name);
-
-/*******************************************************************************
-**
-** Function BTA_FtcChDir
-**
-** Description Change directory on the peer device.
-**
-** This function can only be used when the client is connected
-** in FTP and PBAP mode.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcChDir(char *p_dir, tBTA_FTC_FLAG flag);
-
-/*******************************************************************************
-**
-** Function BTA_FtcAuthRsp
-**
-** Description Sends a response to an OBEX authentication challenge to the
-** connected OBEX server. Called in response to an BTA_FTC_AUTH_EVT
-** event.
-**
-** Note: If the "userid_required" is TRUE in the BTA_FTC_AUTH_EVT event,
-** then p_userid is required, otherwise it is optional.
-**
-** p_password must be less than BTA_FTC_MAX_AUTH_KEY_SIZE (16 bytes)
-** p_userid must be less than OBX_MAX_REALM_LEN (defined in target.h)
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcAuthRsp (char *p_password, char *p_userid);
-
-/*******************************************************************************
-**
-** Function BTA_FtcListCards
-**
-** Description Retrieve a directory listing from the peer device.
-** When the operation is complete the callback function will
-** be called with one or more BTA_FTC_LIST_EVT events
-** containing directory list information formatted as described
-** in the PBAP Spec, Version 0.9, section 3.1.6.
-** This function can only be used when the client is connected
-** to a peer device.
-**
-** This function can only be used when the client is connected
-** in PBAP mode.
-**
-** Parameters p_dir - Name of directory to retrieve listing of.
-**
-** Returns void
-**
-*******************************************************************************/
-
-BTA_API extern void BTA_FtcListCards(char *p_dir, tBTA_FTC_ORDER order, char *p_value,
- tBTA_FTC_ATTR attribute, UINT16 max_list_count,
- UINT16 list_start_offset);
-
-/*******************************************************************************
-**
-** Function BTA_FtcListDir
-**
-** Description Retrieve a directory listing from the peer device.
-** When the operation is complete the callback function will
-** be called with one or more BTA_FTC_LIST_EVT events
-** containing directory list information formatted as described
-** in the IrOBEX Spec, Version 1.2, section 9.1.2.3.
-**
-** This function can only be used when the client is connected
-** in FTP mode.
-**
-** Parameters p_dir - Name of directory to retrieve listing of. If NULL,
-** the current working directory is retrieved.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcListDir(char *p_dir);
-
-/*******************************************************************************
-**
-** Function BTA_FtcAbort
-**
-** Description Aborts any active Put or Get file operation.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcAbort(void);
-
-/*******************************************************************************
-**
-** Function BTA_FtcRemove
-**
-** Description Remove a file or directory on the peer device. When the
-** operation is complete the status is returned with the
-** BTA_FTC_REMOVE_EVT event.
-**
-** This function can only be used when the client is connected
-** in FTP mode.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcRemove(char *p_name);
-
-/*******************************************************************************
-**
-** Function BTA_FtcMkDir
-**
-** Description Create a directory on the peer device. When the operation is
-** complete the status is returned with the BTA_FTC_MKDIR_EVT
-** event.
-**
-** This function can only be used when the client is connected
-** in FTP mode.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_FtcMkDir(char *p_dir);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BTA_FT_API_H */
diff --git a/bta/include/bta_hd_api.h b/bta/include/bta_hd_api.h
deleted file mode 100644
index 5fd7443..0000000
--- a/bta/include/bta_hd_api.h
+++ /dev/null
@@ -1,289 +0,0 @@
-/******************************************************************************
-**
-** File Name: bta_hd_api.h
-**
-** Description: This is the interface header file for the HID Device service.
-**
-** Copyright (c) 2002-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-******************************************************************************/
-
-#ifndef BTA_HD_API_H
-#define BTA_HD_API_H
-
-#include "bt_types.h"
-#include "bta_api.h"
-#include "hidd_api.h"
-
-/*****************************************************************************/
-/* C O N S T A N T S */
-/*****************************************************************************/
-/* status values */
-#define BTA_HD_SUCCESS 0 /* operation successful */
-#define BTA_HD_FAIL 1 /* generic failure */
-#define BTA_HD_FAIL_SDP 2 /* service not found */
-
-typedef UINT8 tBTA_HD_STATUS;
-
-/* HD callback events */
-#define BTA_HD_ENABLE_EVT 0 /* HD enabled */
-#define BTA_HD_OPEN_EVT 1 /* connection opened */
-#define BTA_HD_CLOSE_EVT 2 /* connection closed */
-#define BTA_HD_UNPLUG_EVT 3 /* unplug */
-#define BTA_HD_DATA_EVT 4 /* Data received */
-#define BTA_HD_DATC_EVT 5 /* Data continueation received */
-
-typedef UINT8 tBTA_HD_EVT;
-
-enum
-{
- BTA_HD_REPT_ID_SPEC, /* 0 */
- BTA_HD_REPT_ID_KBD, /* 1: regular keyboard */
- BTA_HD_REPT_ID_MOUSE, /* 2: mouse */
- BTA_HD_REPT_ID_CONSUMER
-};
-typedef UINT8 tBTA_HD_REPT_ID;
-#define BTA_HD_REPT_ID_MAX BTA_HD_REPT_ID_CONSUMER
-
-
-#define BTA_HD_KBD_REPT_SIZE 9
-#define BTA_HD_MOUSE_REPT_SIZE 5
-
-
-/* Modifier Keys definition */
-#define BTA_HD_MDF_LCTRL 0x01 /* Left CTRL */
-#define BTA_HD_MDF_LSHIFT 0x02 /* Left SHIFT */
-#define BTA_HD_MDF_LALT 0x04 /* Left ALT */
-#define BTA_HD_MDF_LGUI 0x08 /* Left GUI */
-#define BTA_HD_MDF_RCTRL 0x10 /* Right CTRL */
-#define BTA_HD_MDF_RSHIFT 0x20 /* Right SHIFT */
-#define BTA_HD_MDF_RALT 0x40 /* Right ALT */
-#define BTA_HD_MDF_RGUI 0x80 /* Right GUI */
-
-/* keycode definition -
- * See USB HID Usage Tables section 10: Keyboard/Keypad Page (0x07) */
-#define BTA_HD_KEYCODE_A 0x04 /* a A */
-#define BTA_HD_KEYCODE_B 0x05 /* b B */
-#define BTA_HD_KEYCODE_C 0x06 /* c C */
-#define BTA_HD_KEYCODE_D 0x07 /* d D */
-#define BTA_HD_KEYCODE_E 0x08 /* e E */
-#define BTA_HD_KEYCODE_F 0x09 /* f F */
-#define BTA_HD_KEYCODE_G 0x0A /* g G */
-#define BTA_HD_KEYCODE_H 0x0B /* h H */
-#define BTA_HD_KEYCODE_I 0x0C /* i I */
-#define BTA_HD_KEYCODE_J 0x0D /* j J */
-#define BTA_HD_KEYCODE_K 0x0E /* k K */
-#define BTA_HD_KEYCODE_L 0x0F /* l L */
-#define BTA_HD_KEYCODE_M 0x10 /* m M */
-#define BTA_HD_KEYCODE_N 0x11 /* n N */
-#define BTA_HD_KEYCODE_O 0x12 /* o O */
-#define BTA_HD_KEYCODE_P 0x13 /* p P */
-#define BTA_HD_KEYCODE_Q 0x14 /* q Q */
-#define BTA_HD_KEYCODE_R 0x15 /* r R */
-#define BTA_HD_KEYCODE_S 0x16 /* s S */
-#define BTA_HD_KEYCODE_T 0x17 /* t T */
-#define BTA_HD_KEYCODE_U 0x18 /* u U */
-#define BTA_HD_KEYCODE_V 0x19 /* v V */
-#define BTA_HD_KEYCODE_W 0x1A /* w W */
-#define BTA_HD_KEYCODE_X 0x1B /* x X */
-#define BTA_HD_KEYCODE_Y 0x1C /* y Y */
-#define BTA_HD_KEYCODE_Z 0x1D /* z Z */
-#define BTA_HD_KEYCODE_1 0x1E /* 1 ! */
-#define BTA_HD_KEYCODE_2 0x1F /* 2 @ */
-#define BTA_HD_KEYCODE_3 0x20 /* 3 # */
-#define BTA_HD_KEYCODE_4 0x21 /* 4 $ */
-#define BTA_HD_KEYCODE_5 0x22 /* 5 % */
-#define BTA_HD_KEYCODE_6 0x23 /* 6 ^ */
-#define BTA_HD_KEYCODE_7 0x24 /* 7 & */
-#define BTA_HD_KEYCODE_8 0x25 /* 8 * */
-#define BTA_HD_KEYCODE_9 0x26 /* 9 ( */
-#define BTA_HD_KEYCODE_0 0x27 /* 0 ) */
-#define BTA_HD_KEYCODE_ENTER 0x28 /* ENTER */
-#define BTA_HD_KEYCODE_ESC 0x29 /* ESC */
-#define BTA_HD_KEYCODE_BACKSPACE 0x2A /* BACKSPACE */
-#define BTA_HD_KEYCODE_TAB 0x2B /* TAB */
-#define BTA_HD_KEYCODE_SPACE 0x2C /* SPACE */
-#define BTA_HD_KEYCODE_MINUS 0x2D /* - _ */
-#define BTA_HD_KEYCODE_EQUAL 0x2E /* = + */
-#define BTA_HD_KEYCODE_LBRACKET 0x2F /* [ { */
-#define BTA_HD_KEYCODE_RBRACKET 0x30 /* ] } */
-#define BTA_HD_KEYCODE_BACKSLASH 0x31 /* \ | */
-#define BTA_HD_KEYCODE_SEMICOLUMN 0x33 /* ; : */
-#define BTA_HD_KEYCODE_QUOTE 0x34 /* ' " */
-#define BTA_HD_KEYCODE_TILT 0x35 /* ` ~ */
-#define BTA_HD_KEYCODE_COMMA 0x36 /* , < */
-#define BTA_HD_KEYCODE_DIR 0x37 /* . > */
-#define BTA_HD_KEYCODE_SLASH 0x38 /* / ? */
-#define BTA_HD_KEYCODE_F1 0x3A /* F1 */
-#define BTA_HD_KEYCODE_F2 0x3B /* F2 */
-#define BTA_HD_KEYCODE_F3 0x3C /* F3 */
-#define BTA_HD_KEYCODE_F4 0x3D /* F4 */
-#define BTA_HD_KEYCODE_F5 0x3E /* F5 */
-#define BTA_HD_KEYCODE_F6 0x3F /* F6 */
-#define BTA_HD_KEYCODE_F7 0x40 /* F7 */
-#define BTA_HD_KEYCODE_F8 0x41 /* F8 */
-#define BTA_HD_KEYCODE_F9 0x42 /* F9 */
-#define BTA_HD_KEYCODE_F10 0x43 /* F10 */
-#define BTA_HD_KEYCODE_F11 0x44 /* F11 */
-#define BTA_HD_KEYCODE_F12 0x45 /* F12 */
-#define BTA_HD_KEYCODE_HOME 0x4A /* HOME */
-#define BTA_HD_KEYCODE_PAGEUP 0x4B /* PAGE UP */
-#define BTA_HD_KEYCODE_END 0x4D /* END */
-#define BTA_HD_KEYCODE_PAGEDOWN 0x4E /* PAGE DOWN */
-#define BTA_HD_KEYCODE_RIGHTARROW 0x4F /* RIGHT ARROW */
-#define BTA_HD_KEYCODE_LEFTARROW 0x50 /* LEFT ARROW */
-#define BTA_HD_KEYCODE_DOWNARROW 0x51 /* DOWN ARROW */
-#define BTA_HD_KEYCODE_UPARROW 0x52 /* UP ARROW */
-#define BTA_HD_KEYCODE_POPUP 0x65 /* POPUP Menu */
-
-/* data associated with BTA_HD_OPEN_EVT */
-typedef struct
-{
- BD_ADDR bd_addr;
-} tBTA_HD_OPEN;
-
-/* data associated with BTA_HD_ENABLE_EVT */
-typedef struct
-{
- tBTA_HD_STATUS status;
-} tBTA_HD_ENABLE;
-
-/* data associated with BTA_HD_CLOSE_EVT */
-typedef struct
-{
- BD_ADDR bd_addr;
-} tBTA_HD_CLOSE;
-
-/* data associated with BTA_HD_REPORT_EVT */
-typedef struct
-{
- UINT8 *p_data;
- UINT16 len;
-} tBTA_HD_REPORT;
-/*****************************************************************************/
-/* F U N C T I O N P R O T O T Y P E S */
-/*****************************************************************************/
-/* union of data associated with HD callback */
-typedef union
-{
- tBTA_HD_ENABLE enable;
- tBTA_HD_OPEN open;
- tBTA_HD_CLOSE close;
- tBTA_HD_REPORT data;
-} tBTA_HD;
-
-/* HD callback */
-typedef void (tBTA_HD_CBACK)(tBTA_HD_EVT event, tBTA_HD *p_data);
-
-/* HD configuration structure */
-typedef struct
-{
- tHID_DEV_QOS_INFO qos;
- tHID_DEV_SDP_INFO sdp_info;
- BOOLEAN use_qos; /* use QoS */
-} tBTA_HD_CFG;
-
-/*******************************************************************************
-**
-** Function BTA_HdEnable
-**
-** Description Enable the HID Device service. When the enable
-** operation is complete the callback function will be
-** called with a BTA_HD_ENABLE_EVT. This function must
-** be called before other function in the HD API are
-** called.
-**
-** If all bytes of the specified bd_addr are 0xff, the
-** peer address is considered as unknown. The HID device listens
-** for incoming connection request.
-** Otherwise, The HID device initiates a connection toward the
-** specified bd_addr when BTA_HdOpen() is called.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API void BTA_HdEnable(BD_ADDR bd_addr, tBTA_SEC sec_mask, const char *p_service_name,
- tBTA_HD_CBACK *p_cback, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function BTA_HdDisable
-**
-** Description Disable the HID Device service.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API void BTA_HdDisable(void);
-
-/*******************************************************************************
-**
-** Function BTA_HdOpen
-**
-** Description Opens an HID Device connection to a peer device.
-** When connection is open, callback function is called
-** with a BTA_HD_OPEN_EVT.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API void BTA_HdOpen(tBTA_SEC sec_mask);
-
-/*******************************************************************************
-**
-** Function BTA_HdClose
-**
-** Description Close the current connection a peer device.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API void BTA_HdClose(void);
-
-/*******************************************************************************
-**
-** Function BTA_HdSendRegularKey
-**
-** Description Send a key report to the connected host.
-** If auto_release is TRUE, assume the keyboard report must be
-** a key press. An associated key release report is also sent.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API void BTA_HdSendRegularKey (UINT8 modifier, UINT8 key_code, BOOLEAN auto_release);
-
-/*******************************************************************************
-**
-** Function BTA_HdSendSpecialKey
-**
-** Description Send a special key report to the connected host.
-** The report is sent as a keyboard report.
-** If auto_release is TRUE, assume the keyboard report must be
-** a key press. An associated key release report is also sent.
-** If key_len is less than BTA_HD_KBD_REPT_SIZE, the key_seq
-** is padded with 0 until BTA_HD_KBD_REPT_SIZE.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API void BTA_HdSendSpecialKey (UINT8 key_len, UINT8 * key_seq, BOOLEAN auto_release);
-
-/*******************************************************************************
-**
-** Function BTA_HdSendMouseReport
-**
-** Description Send a mouse report to the connected host
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API void BTA_HdSendMouseReport (UINT8 is_left, UINT8 is_right, UINT8 is_middle,
- INT8 delta_x, INT8 delta_y, INT8 delta_wheel);
-
-
-#endif /* BTA_HD_API_H */
diff --git a/bta/include/bta_ma_api.h b/bta/include/bta_ma_api.h
deleted file mode 100644
index e0b413e..0000000
--- a/bta/include/bta_ma_api.h
+++ /dev/null
@@ -1,691 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ma_api.h
-**
-** Description: This file contains the common API functions used
-** for the Message Access Profiles (MAP).
-**
-** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_MA_API_H
-#define BTA_MA_API_H
-
-#include "bta_mse_api.h" /* For tBTA_MA_MSG_TYPE */
-#include <stdio.h>
-
-typedef struct
-{
- UINT16 size; /* Size of the buffer */
- UINT8 * p_buffer; /* Pointer to buffer */
- UINT8 * p_next; /* Pointer to next byte to use in buffer */
-
-}tBTA_MA_MEM_STREAM;
-
-typedef struct
-{
- int fd;
-
-}tBTA_MA_FILE_STREAM;
-
-/* Structure used for streaming data */
-typedef struct
-{
-#define STRM_TYPE_MEMORY 0
-#define STRM_TYPE_FILE 1
-
- UINT8 type;
-
-#define STRM_SUCCESS 0
-#define STRM_ERROR_OVERFLOW 1
-#define STRM_ERROR_FILE 2
-
- UINT8 status;
-
- union
- {
- tBTA_MA_MEM_STREAM mem;
- tBTA_MA_FILE_STREAM file;
- } u;
-
-} tBTA_MA_STREAM;
-
-/*******************************************************************************
-**
-** bMessage functions
-**
-** Description The following API functions are generic in a sense that
-** they do not imply how the data is stored (to memory or
-** to file, etc.).
-**
-** They operate on a generic set of structure types. Though
-** the internal structure of those types are implementation
-** specific.
-**
-*******************************************************************************/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgCreate
-**
-** Description Create and initialize an instance of a tBTA_MA_BMSG structure.
-**
-** Parameters None
-**
-** Returns Pointer to a bMessage object, or NULL if this fails.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG * BTA_MaBmsgCreate(void);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgFree
-**
-** Description Destroy (free) the contents of a tBTA_MA_BMSG structure.
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns None
-**
-*******************************************************************************/
-BTA_API extern void BTA_MaBmsgFree(tBTA_MA_BMSG * p_msg);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetReadSts
-**
-** Description Set the bmessage-readstatus-property value for the bMessage
-** object. If the 'read_sts' is TRUE then value will be "READ",
-** otherwise it is "UNREAD".
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-** read_sts - Read status TRUE- read FALSE - unread
-**
-** Returns None
-**
-*******************************************************************************/
-BTA_API extern void BTA_MaBmsgSetReadSts(tBTA_MA_BMSG * p_msg, BOOLEAN read_sts);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetReadSts
-**
-** Description Get the bmessage-readstatus-property value for the bMessage
-** object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Read status (TRUE/FALSE) for the specified bMessage.
-**
-*******************************************************************************/
-BTA_API extern BOOLEAN BTA_MaBmsgGetReadSts(tBTA_MA_BMSG * p_msg);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetMsgType
-**
-** Description Set the bmessage-type-property value for the bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-** msg_type - Message type
-**
-** Returns None
-**
-*******************************************************************************/
-BTA_API extern void BTA_MaBmsgSetMsgType(tBTA_MA_BMSG * p_msg, tBTA_MA_MSG_TYPE msg_type);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetMsgType
-**
-** Description Get the bmessage-type-property value for the specified
-** bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Message type
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_MSG_TYPE BTA_MaBmsgGetMsgType(tBTA_MA_BMSG * p_msg);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetFolder
-**
-** Description Set the bmessage-folder-property value for the bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-** p_folder - Pointer to a folder path
-**
-** Returns None
-**
-*******************************************************************************/
-BTA_API extern void BTA_MaBmsgSetFolder(tBTA_MA_BMSG * p_msg, char * p_folder);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetFolder
-**
-** Description Get the bmessage-folder-property value for the specified
-** bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Pointer to folder path string, or NULL if it has not been set.
-**
-*******************************************************************************/
-BTA_API extern char * BTA_MaBmsgGetFolder(tBTA_MA_BMSG * p_msg);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddOrigToBmsg
-**
-** Description Add an originator to the bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Pointer to a new vCard structure, or NULL if this function
-** fails.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_VCARD * BTA_MaBmsgAddOrigToBmsg(tBTA_MA_BMSG * p_msg);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetOrigFromBmsg
-**
-** Description Get the first originator vCard information from the specified
-** bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Pointer to first 'originator vCard, or NULL not used.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_VCARD * BTA_MaBmsgGetOrigFromBmsg(tBTA_MA_BMSG * p_msg);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddEnvToBmsg
-**
-** Description Add a new envelope to the bMessage object. This is the first
-** (top) level envelope. bMessage allows up to 3 levels of envelopes.
-** application should call BTA_MaBmsgAddEnvToEnv to add the 2nd
-** 3rd level enevelope.
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Pointer to a new envelope structure, or NULL if this
-** function fails.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgAddEnvToBmsg(tBTA_MA_BMSG * p_msg);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddEnvToEnv
-**
-** Description Add a child envelope to an existing envelope.
-**
-** Parameters p_envelope - Pointer to a parent envelope
-**
-** Returns Pointer to an envelope structure, or NULL if this
-** function fails.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgAddEnvToEnv(tBTA_MA_BMSG_ENVELOPE * p_envelope);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetEnv
-**
-** Description Get the pointer of the first level envelope.
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Pointer to the first level envelope structure, or NULL if it
-** does not exist
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgGetEnv(tBTA_MA_BMSG * p_msg);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetNextEnv
-**
-** Description Get the child envelope of the specified parent envelope.
-**
-** Parameters p_env - Pointer to a parent envelope
-**
-** Returns Pointer to a child enevelope. NULL if the
-** envelope does not have a 'child' envelope.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgGetNextEnv(tBTA_MA_BMSG_ENVELOPE * p_env);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddRecipToEnv
-**
-** Description Add recipient to the specified envelope.
-**
-** Parameters p_env - Pointer to a envelope
-**
-** Returns Pointer to a vCard structure. NULL if it
-** fails to allocate a vCard structure.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_VCARD * BTA_MaBmsgAddRecipToEnv(tBTA_MA_BMSG_ENVELOPE * p_env);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetRecipFromEnv
-**
-** Description Get the first recipient's vCard from the specified envelope.
-**
-** Parameters p_env - Pointer to a envelope
-**
-** Returns Pointer to the first recipient's vCard structure. NULL if it
-** has not be set.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_VCARD * BTA_MaBmsgGetRecipFromEnv(tBTA_MA_BMSG_ENVELOPE * p_env);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddBodyToEnv
-**
-** Description Add a message body to the specified envelope.
-**
-** Parameters p_env - Pointer to a envelope
-**
-** Returns Pointer to a message body structure.
-** NULL if it fails to allocate a message body structure.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_BODY * BTA_MaBmsgAddBodyToEnv(tBTA_MA_BMSG_ENVELOPE * p_env);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetBodyFromEnv
-**
-** Description Get the message body pointer from the specified envelope.
-**
-** Parameters p_env - Pointer to a envelope
-**
-** Returns Pointer to a message body structure.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_BODY * BTA_MaBmsgGetBodyFromEnv(tBTA_MA_BMSG_ENVELOPE * p_env);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetBodyEncoding
-**
-** Description Set the bmessage-body-encoding-property value for the bMessage
-** body.
-**
-** Parameters p_body - Pointer to a bMessage body
-** encoding - encoding scheme
-**
-** Returns None
-**
-*******************************************************************************/
-BTA_API extern void BTA_MaBmsgSetBodyEncoding(tBTA_MA_BMSG_BODY * p_body, tBTA_MA_BMSG_ENCODING encoding);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetBodyEncoding
-**
-** Description Get the bmessage-body-encoding-property value for the specified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns Message encoding scheme
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_ENCODING BTA_MaBmsgGetBodyEncoding(tBTA_MA_BMSG_BODY * p_body);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetBodyPartid
-**
-** Description Set the bmessage-body-part-ID value for the speicified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-** part_id - Part ID (range: from 0 to 65535)
-**
-** Returns None
-**
-*******************************************************************************/
-BTA_API extern void BTA_MaBmsgSetBodyPartid(tBTA_MA_BMSG_BODY * p_body, UINT16 part_id);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetBodyPartid
-**
-** Description Get the bmessage-body-part-ID value for the specified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns The value of the Part ID
-**
-*******************************************************************************/
-BTA_API extern UINT16 BTA_MaBmsgGetBodyPartid(tBTA_MA_BMSG_BODY * p_body);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgIsBodyMultiPart
-**
-** Description Is this a multi-part body
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns TURE - if this is a multi-part body
-**
-*******************************************************************************/
-BTA_API extern BOOLEAN BTA_MaBmsgIsBodyMultiPart(tBTA_MA_BMSG_BODY * p_body);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetBodyCharset
-**
-** Description Get the bmessage-body-charset-property value for the speicified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns Charset
-**
-*******************************************************************************/
-BTA_API extern void BTA_MaBmsgSetBodyCharset(tBTA_MA_BMSG_BODY * p_body, tBTA_MA_CHARSET charset);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetBodyCharset
-**
-** Description Get the bmessage-body-charset-property value for the speicified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns Charset
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_CHARSET BTA_MaBmsgGetBodyCharset(tBTA_MA_BMSG_BODY * p_body);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetBodyLanguage
-**
-** Description Set the bmessage-body-language-property value for the speicified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-** Language - the language of the message
-**
-** Returns None
-**
-*******************************************************************************/
-BTA_API extern void BTA_MaBmsgSetBodyLanguage(tBTA_MA_BMSG_BODY * p_body, tBTA_MA_BMSG_LANGUAGE language);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetBodyLanguage
-**
-** Description Get the bmessage-body-language-property value for the speicified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns the language of the message
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_LANGUAGE BTA_MaBmsgGetBodyLanguage(tBTA_MA_BMSG_BODY * p_body);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddContentToBody
-**
-** Description Add a message content to the speicified bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns Pointer to a message content.
-** NULL if it fails to allocate a message content buffer
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_CONTENT * BTA_MaBmsgAddContentToBody(tBTA_MA_BMSG_BODY * p_body);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetContentFromBody
-**
-** Description Get a message content from the speicified bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns Pointer to a message content.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_CONTENT * BTA_MaBmsgGetContentFromBody(tBTA_MA_BMSG_BODY * p_body);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetNextContent
-**
-** Description Get the next message content from the speicified message content.
-**
-** Parameters p_content - Pointer to a message content
-**
-** Returns Pointer to a message content.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_CONTENT * BTA_MaBmsgGetNextContent(tBTA_MA_BMSG_CONTENT * p_content);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddMsgContent
-**
-** Description Add a text string to the speicified message content.
-**
-** Parameters p_content - Pointer to a message content
-** p_text - Pointer to a text string
-**
-** Returns None
-**
-*******************************************************************************/
-BTA_API extern void BTA_MaBmsgAddMsgContent(tBTA_MA_BMSG_CONTENT * p_content, char * p_text);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetMsgContent
-**
-** Description Get the next text string from the speicified message content.
-**
-** Parameters p_content - Pointer to a message content
-**
-** Returns Pointer to the next text string.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-BTA_API extern char * BTA_MaBmsgGetMsgContent(tBTA_MA_BMSG_CONTENT * p_content);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetNextVcard
-**
-** Description Get the next vCard from the speicified vCard.
-**
-** Parameters p_vcard - Pointer to a vCard
-**
-** Returns Pointer to the next vCard.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-BTA_API extern char * BTA_MaBmsgGetNextMsgContent(tBTA_MA_BMSG_CONTENT * p_content);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetNextVcard
-**
-** Description Get the next vCard from the speicified vCard.
-**
-** Parameters p_vcard - Pointer to a vCard
-**
-** Returns Pointer to the next vCard.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_BMSG_VCARD * BTA_MaBmsgGetNextVcard(tBTA_MA_BMSG_VCARD * p_vcard);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetVcardVersion
-**
-** Description Set the vCard version for the speicified vCard.
-**
-** Parameters p_vcard - Pointer to a vCard
-** version - vcard version
-**
-** Returns None
-**
-*******************************************************************************/
-BTA_API extern void BTA_MaBmsgSetVcardVersion(tBTA_MA_BMSG_VCARD * p_vcard, tBTA_MA_VCARD_VERSION version);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetVcardVersion
-**
-** Description Get the vCard version from the speicified vCard.
-**
-** Parameters p_vcard - Pointer to a vCard
-**
-** Returns vCard version number
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_VCARD_VERSION BTA_MaBmsgGetVcardVersion(tBTA_MA_BMSG_VCARD * p_vcard);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetVcardProp
-**
-** Description Get the vCard property from the speicified vCard peoperty enum.
-**
-** Parameters p_vcard - Pointer to a vCard
-** prop - Indicate which vCard peoperty
-**
-** Returns Pointer to the vCard peoperty.
-** NULL if the vCard peoperty does not exist
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_VCARD_PROPERTY * BTA_MaBmsgAddVcardProp(tBTA_MA_BMSG_VCARD * p_vcard, tBTA_MA_VCARD_PROP prop, char * p_value, char * p_param);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetVcardProp
-**
-** Description Get the next vCard property from the speicified vCard peoperty.
-**
-** Parameters p_prop - Pointer to a vCard property
-**
-** Returns Pointer to the next vCard peoperty.
-** NULL if the next vCard peoperty does not exist
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_VCARD_PROPERTY * BTA_MaBmsgGetVcardProp(tBTA_MA_BMSG_VCARD * p_vcard, tBTA_MA_VCARD_PROP prop);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetNextVcardProp
-**
-** Description Get the next vCard property from the speicified vCard peoperty.
-**
-** Parameters p_prop - Pointer to a vCard property
-**
-** Returns Pointer to the next vCard peoperty.
-** NULL if the next vCard peoperty does not exist
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_VCARD_PROPERTY * BTA_MaBmsgGetNextVcardProp(tBTA_MA_VCARD_PROPERTY * p_prop);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetVcardPropValue
-**
-** Description Get the vCard property value from the speicified vCard peoperty.
-**
-** Parameters p_prop - Pointer to a vCard property
-**
-** Returns Pointer to the vCard peoperty value.
-** NULL if the vCard peoperty value has not been set.
-**
-*******************************************************************************/
-BTA_API extern char * BTA_MaBmsgGetVcardPropValue(tBTA_MA_VCARD_PROPERTY * p_prop);
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetVcardPropParam
-**
-** Description Get the vCard property parameter from the speicified vCard peoperty.
-**
-** Parameters p_prop - Pointer to a vCard property
-**
-** Returns Poiter to the vCard peoperty parameter.
-** NULL if the vCard peoperty parameter has not been set.
-**
-*******************************************************************************/
-BTA_API extern char * BTA_MaBmsgGetVcardPropParam(tBTA_MA_VCARD_PROPERTY * p_prop);
-/*******************************************************************************
-**
-** Function BTA_MaBuildMapBmsgObj
-**
-** Description Builds a specification compliant bMessage object given a
-** generic bMessage internal structure.
-**
-** Parameters p_msg - pointer to bMessage object structure (input).
-** p_stream - Output stream.
-**
-** Returns BTA_MA_STATUS_OK if successful. BTA_MA_STATUS_FAIL if not.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_STATUS BTA_MaBuildMapBmsgObj(tBTA_MA_BMSG * p_msg, tBTA_MA_STREAM * p_stream);
-/*******************************************************************************
-**
-** Function bta_ma_parse_map_bmsg_obj
-**
-** Description Parses a bMessage object from a stream into a generic
-** bMessage internal structure.
-**
-** Parameters p_msg - pointer to bMessage object structure (output).
-** p_stream - Input stream.
-**
-** Returns BTA_MA_STATUS_OK if successful. BTA_MA_STATUS_FAIL if not.
-**
-*******************************************************************************/
-BTA_API extern tBTA_MA_STATUS BTA_MaParseMapBmsgObj(tBTA_MA_BMSG * p_msg, tBTA_MA_STREAM * p_stream);
-
-/*******************************************************************************
-**
-** Function BTA_MaInitMemStream
-**
-** Description Initializes a memory based stream
-**
-** Parameters p_stream - pointer to stream information.
-** p_buffer - pointer to buffer to be manipulated.
-** size - size of buffer pointed to by 'p_buffer'.
-**
-** Returns TRUE if stream is successfully initialized
-**
-*******************************************************************************/
-BTA_API extern BOOLEAN BTA_MaInitMemStream(tBTA_MA_STREAM * p_stream,
- UINT8 * p_buffer,
- UINT16 size);
-/*******************************************************************************
-**
-** Function BTA_MaInitFileStream
-**
-** Description Initializes a file stream
-**
-** Parameters p_stream - pointer to stream information.
-** p_filename - Full pathname to file to use.
-** oflags - permissions and mode (see constants above)
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern BOOLEAN BTA_MaInitFileStream(tBTA_MA_STREAM * p_stream,
- const char *p_path,
- int oflags);
-/*******************************************************************************
-**
-** Function BTA_MaCloseStream
-**
-** Description Close a stream (do any necessary clean-up.
-**
-** Parameters p_stream - pointer to stream information.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_MaCloseStream(tBTA_MA_STREAM * p_stream);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BTA_BMSG_API_H */
diff --git a/bta/include/bta_ma_co.h b/bta/include/bta_ma_co.h
deleted file mode 100644
index 442d106..0000000
--- a/bta/include/bta_ma_co.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ma_co.h
-**
-** Description: This is the interface file for the Message Access Profile
-** common call-out functions.
-**
-** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_MA_CO_H
-#define BTA_MA_CO_H
-
-#include <stdio.h>
-
-/*****************************************************************************
-**
-** Utility functions for converting types to strings.
-**
-*****************************************************************************/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*******************************************************************************
-**
-** Function bta_ma_co_open
-**
-** Description Open a file.
-**
-** Parameters p_path - Full path of file to open.
-** oflags - file open flags.
-**
-** Returns file descriptor. BTA_FS_INVALID_FD if open fails.
-**
-*******************************************************************************/
- BTA_API extern int bta_ma_co_open(const char *p_path, int oflags);
-
-/*******************************************************************************
-**
-** Function bta_ma_co_write
-**
-** Description Write data to file.
-**
-** Parameters fd - file descriptor.
-** buffer - data to write.
-** size - size of data to write (in bytes).
-**
-** Returns Number of bytes written.
-**
-*******************************************************************************/
- BTA_API extern int bta_ma_co_write(int fd, const void *buffer, int size);
-
-/*******************************************************************************
-**
-** Function bta_ma_co_read
-**
-** Description Read data from file.
-**
-** Parameters fd - file descriptor.
-** buffer - to receive data.
-** size - amount of data to read (in bytes).
-**
-** Returns Number of bytes read.
-**
-*******************************************************************************/
- BTA_API extern int bta_ma_co_read(int fd, void *buffer, int size);
-
-/*******************************************************************************
-**
-** Function bta_ma_co_close
-**
-** Description Close the file.
-**
-** Parameters fd - file descriptor.
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void bta_ma_co_close(int fd);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BTA_MA_FILE_H */
-
-
diff --git a/bta/include/bta_ma_def.h b/bta/include/bta_ma_def.h
deleted file mode 100644
index 7202385..0000000
--- a/bta/include/bta_ma_def.h
+++ /dev/null
@@ -1,479 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ma_def.h
-**
-** Description: This file contains the common definitions for the Message Access
-** profile (MA) related SW modules
-**
-** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_MA_DEF_H
-#define BTA_MA_DEF_H
-
-#include "obx_api.h"
-#include "bta_api.h"
-#include "btm_api.h"
-#include "bta_sys.h"
-#include "bta_fs_co.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-
-#define BTA_MA_HANDLE_SIZE 8
-
-typedef UINT8 tBTA_MA_MSG_HANDLE[BTA_MA_HANDLE_SIZE];
-
-typedef tOBX_HANDLE tBTA_MA_SESS_HANDLE;
-
-typedef UINT8 tBTA_MA_INST_ID;
-
-#define BTA_MA_STATUS_OK 0
-#define BTA_MA_STATUS_FAIL 1 /* Used to pass all other errors */
-#define BTA_MA_STATUS_ABORTED 2
-#define BTA_MA_STATUS_NO_RESOURCE 3
-#define BTA_MA_STATUS_EACCES 4
-#define BTA_MA_STATUS_ENOTEMPTY 5
-#define BTA_MA_STATUS_EOF 6
-#define BTA_MA_STATUS_EODIR 7
-#define BTA_MA_STATUS_ENOSPACE 8 /* Returned in bta_fs_ci_open if no room */
-#define BTA_MA_STATUS_DUPLICATE_ID 9
-#define BTA_MA_STATUS_ID_NOT_FOUND 10
-#define BTA_MA_STATUS_FULL 11 /* reach the max packet size */
-
-typedef UINT8 tBTA_MA_STATUS;
-
-#define BTA_MA_OPER_NONE 0
-#define BTA_MA_OPER_GET_MSG 1
-#define BTA_MA_OPER_PUSH_MSG 2
-
-typedef UINT8 tBTA_MA_OPER;
-
-/* mode field in tBTA_MSE_CO_FOLDER_ENTRY (OR'd together) */
-#define BTA_MA_A_RDONLY 1
-#define BTA_MA_A_DIR 2 /* Entry is a sub directory */
-
-
-/* message status inficator */
-#define BTA_MA_STS_INDTR_READ 0
-#define BTA_MA_STS_INDTR_DELETE 1
-typedef UINT8 tBTA_MA_STS_INDCTR;
-
-/* message status value */
-#define BTA_MA_STS_VALUE_NO 0
-#define BTA_MA_STS_VALUE_YES 1
-typedef UINT8 tBTA_MA_STS_VALUE;
-
-/* notification status */
-enum
-{
- BTA_MA_NOTIF_OFF = 0,
- BTA_MA_NOTIF_ON,
- BTA_MA_NOTIF_MAX
-
-};
-typedef UINT8 tBTA_MA_NOTIF_STATUS;
-
-
-/* Access response types */
-enum
-{
- BTA_MA_ACCESS_TYPE_ALLOW = 0, /* Allow the requested operation */
- BTA_MA_ACCESS_TYPE_FORBID /* Disallow the requested operation */
-};
-
-typedef UINT8 tBTA_MA_ACCESS_TYPE;
-
-/* Structure for in progress related event*/
-typedef struct
-{
- UINT32 obj_size; /* Total size of object 0 if unknow*/
- tBTA_MA_SESS_HANDLE mas_session_id;
- UINT16 bytes; /* Number of bytes read or written since last progress event */
-} tBTA_MA_IN_PROG;
-
-
-/* Message type see SDP supported message type */
-#define BTA_MA_MSG_TYPE_EMAIL (1<<0)
-#define BTA_MA_MSG_TYPE_SMS_GSM (1<<1)
-#define BTA_MA_MSG_TYPE_SMS_CDMA (1<<2)
-#define BTA_MA_MSG_TYPE_MMS (1<<3)
-typedef UINT8 tBTA_MA_MSG_TYPE;
-
-#define BTA_MA_MAX_FILTER_TEXT_SIZE 255
-
-/* Message type mask for FilterMessageType in Application parameter */
-#define BTA_MA_MSG_TYPE_MASK_SMS_GSM (1<<0)
-#define BTA_MA_MSG_TYPE_MASK_SMS_CDMA (1<<1)
-#define BTA_MA_MSG_TYPE_MASK_EMAIL (1<<2)
-#define BTA_MA_MSG_TYPE_MASK_MMS (1<<3)
-
-
-typedef UINT8 tBTA_MA_MSG_TYPE_MASK;
-
-
-
-/* Parameter Mask for Messages-Listing */
-#define BTA_MA_ML_MASK_SUBJECT (1<<0)
-#define BTA_MA_ML_MASK_DATETIME (1<<1)
-#define BTA_MA_ML_MASK_SENDER_NAME (1<<2)
-#define BTA_MA_ML_MASK_SENDER_ADDRESSING (1<<3)
-#define BTA_MA_ML_MASK_RECIPIENT_NAME (1<<4)
-#define BTA_MA_ML_MASK_RECIPIENT_ADDRESSING (1<<5)
-#define BTA_MA_ML_MASK_TYPE (1<<6)
-#define BTA_MA_ML_MASK_SIZE (1<<7)
-#define BTA_MA_ML_MASK_RECEPTION_STATUS (1<<8)
-#define BTA_MA_ML_MASK_TEXT (1<<9)
-#define BTA_MA_ML_MASK_ATTACHMENT_SIZE (1<<10)
-#define BTA_MA_ML_MASK_PRIORITY (1<<11)
-#define BTA_MA_ML_MASK_READ (1<<12)
-#define BTA_MA_ML_MASK_SENT (1<<13)
-#define BTA_MA_ML_MASK_PROTECTED (1<<14)
-#define BTA_MA_ML_MASK_REPLYTO_ADDRESSING (1<<15)
-
-typedef UINT32 tBTA_MA_ML_MASK;
-
-/* Read status used for message list */
-enum
-{
- BTA_MA_READ_STATUS_NO_FILTERING = 0,
- BTA_MA_READ_STATUS_UNREAD = 1,
- BTA_MA_READ_STATUS_READ = 2
-};
-typedef UINT8 tBTA_MA_READ_STATUS;
-
-/* Priority status used for filtering message list */
-enum
-{
- BTA_MA_PRI_STATUS_NO_FILTERING = 0,
- BTA_MA_PRI_STATUS_HIGH = 1,
- BTA_MA_PRI_STATUS_NON_HIGH = 2
-};
-typedef UINT8 tBTA_MA_PRI_STATUS;
-
-#define BTA_MA_LTIME_LEN 15
-typedef struct
-{
- tBTA_MA_ML_MASK parameter_mask;
- UINT16 max_list_cnt;
- UINT16 list_start_offset;
- UINT8 subject_length; /* valid range 1...255 */
- tBTA_MA_MSG_TYPE_MASK msg_mask;
- char period_begin[BTA_MA_LTIME_LEN+1]; /* "yyyymmddTHHMMSS", or "" if none */
- char period_end[BTA_MA_LTIME_LEN+1]; /* "yyyymmddTHHMMSS", or "" if none */
- tBTA_MA_READ_STATUS read_status;
- char recipient[BTA_MA_MAX_FILTER_TEXT_SIZE+1]; /* "" if none */
- char originator[BTA_MA_MAX_FILTER_TEXT_SIZE+1];/* "" if none */
- tBTA_MA_PRI_STATUS pri_status;
-} tBTA_MA_MSG_LIST_FILTER_PARAM;
-
-/* enum for charset used in GetMEssage */
-enum
-{
- BTA_MA_CHARSET_NATIVE = 0,
- BTA_MA_CHARSET_UTF_8 = 1,
- BTA_MA_CHARSET_UNKNOWN,
- BTA_MA_CHARSET_MAX
-};
-typedef UINT8 tBTA_MA_CHARSET;
-
-/* enum for fraction request used in GetMEssage */
-enum
-{
- BTA_MA_FRAC_REQ_FIRST = 0,
- BTA_MA_FRAC_REQ_NEXT = 1,
- BTA_MA_FRAC_REQ_NO, /* this is not a fraction request */
- BTA_MA_FRAC_REQ_MAX
-};
-typedef UINT8 tBTA_MA_FRAC_REQ;
-
-/* enum for fraction delivery used in GetMEssage */
-enum
-{
- BTA_MA_FRAC_DELIVER_MORE = 0,
- BTA_MA_FRAC_DELIVER_LAST = 1,
- BTA_MA_FRAC_DELIVER_NO, /* this is not a fraction deliver*/
- BTA_MA_FRAC_DELIVER_MAX
-};
-typedef UINT8 tBTA_MA_FRAC_DELIVER;
-
-
-typedef struct
-{
- BOOLEAN attachment;
- tBTA_MA_MSG_HANDLE handle;
- tBTA_MA_CHARSET charset;
- tBTA_MA_FRAC_REQ fraction_request;
-} tBTA_MA_GET_MSG_PARAM;
-
-#define BTA_MA_RETRY_OFF 0
-#define BTA_MA_RETRY_ON 1
-#define BTA_MA_RETRY_UNKNOWN 0xff
-typedef UINT8 tBTA_MA_RETRY_TYPE;
-
-
-#define BTA_MA_TRANSP_OFF 0
-#define BTA_MA_TRANSP_ON 1
-#define BTA_MA_TRANSP_UNKNOWN 0xff
-typedef UINT8 tBTA_MA_TRANSP_TYPE;
-
-typedef struct
-{
- char *p_folder; /* current or child folder
- for current folder set
- *p_folder = ""
- */
- char *p_msg_name; /* for MCE use only*/
- tBTA_MA_TRANSP_TYPE transparent;
- tBTA_MA_RETRY_TYPE retry;
- tBTA_MA_CHARSET charset;
-
-} tBTA_MA_PUSH_MSG_PARAM;
-
-/* get or push message multi-packet status */
-enum
-{
- BTA_MA_MPKT_STATUS_MORE = 0,
- BTA_MA_MPKT_STATUS_LAST,
- BTA_MA_MPKT_MAX
-};
-
-typedef UINT8 tBTA_MA_MPKT_STATUS;
-
-/* definitions for directory navigation */
-#define BTA_MA_DIR_NAV_ROOT_OR_DOWN_ONE_LVL 2
-#define BTA_MA_DIR_NAV_UP_ONE_LVL 3
-
-typedef UINT8 tBTA_MA_DIR_NAV;
-
-enum
-{
- BTA_MA_ATTACH_OFF = 0,
- BTA_MA_ATTACH_ON
-};
-typedef UINT8 tBTA_MA_ATTACH_TYPE;
-
-/* MAS tag ID in application parameters header definition */
-#define BTA_MA_APH_MAX_LIST_COUNT 0x01 /* MaxListCount 2 bytes 0x0000 to 0xFFFF */
-#define BTA_MA_APH_START_STOFF 0x02 /* StartOffset 2 bytes 0x0000 to 0xFFFF */
-#define BTA_MA_APH_FILTER_MSG_TYPE 0x03 /* SearchAttribute 1 byte 1,2,4 */
-#define BTA_MA_APH_FILTER_PRD_BEGIN 0x04 /* Filter Period Begin variable */
-#define BTA_MA_APH_FILTER_PRD_END 0x05 /* Filter Period End variable */
-#define BTA_MA_APH_FILTER_READ_STS 0x06 /* Filter read status 1 byte 0, 1, 2 */
-#define BTA_MA_APH_FILTER_RECEIP 0x07 /* FilterRecipient variable */
-#define BTA_MA_APH_FILTER_ORIGIN 0x08 /* FilterOriginator variable */
-#define BTA_MA_APH_FILTER_PRIORITY 0x09 /* FilterPriority 1 byte */
-#define BTA_MA_APH_ATTACH 0x0a /* Attachment 1 byte */
-#define BTA_MA_APH_TRANSPARENT 0x0b /* transparent 1 byte */
-#define BTA_MA_APH_RETRY 0x0c /* retry 1 byte */
-#define BTA_MA_APH_NEW_MSG 0x0d /* NewMessage 1 byte */
-#define BTA_MA_APH_NOTIF_STATUS 0x0e /* Notification Status 1 byte */
-#define BTA_MA_APH_MAS_INST_ID 0x0f /* MAS instance ID 1 byte 0 ... 255 */
-#define BTA_MA_APH_PARAM_MASK 0x10 /* Parameter mask 2 bytes */
-#define BTA_MA_APH_FOLDER_LST_SIZE 0x11 /* Folder Listing Size 2 bytes */
-#define BTA_MA_APH_MSG_LST_SIZE 0x12 /* Message Listing Size 2 bytes */
-#define BTA_MA_APH_SUBJ_LEN 0x13 /* Subject Length 1 byte */
-#define BTA_MA_APH_CHARSET 0x14 /* Character Set 1 byte :0, 1 */
-#define BTA_MA_APH_FRAC_REQ 0x15 /* Fraction request 1 byte :0, 1 */
-#define BTA_MA_APH_FRAC_DELVR 0x16 /* Fraction delivery 1 byte :0, 1 */
-#define BTA_MA_APH_STS_INDCTR 0x17 /* Status Indicator 1 byte */
-#define BTA_MA_APH_STS_VALUE 0x18 /* Status Value 1 byte: 0, 1 */
-#define BTA_MA_APH_MSE_TIME 0x19 /* MSETime variable */
-
-#define BTA_MA_BODY_FILLER_BYTE 0x30
-
-/* MAS type header */
-#define BTA_MA_HDR_TYPE_NOTIF_REG "x-bt/MAP-NotificationRegistration"
-#define BTA_MA_HDR_TYPE_MSG_UPDATE "x-bt/MAP-messageUpdate"
-#define BTA_MA_HDR_TYPE_EVENT_RPT "x-bt/MAP-event-report"
-#define BTA_MA_HDR_TYPE_MSG_LIST "x-bt/MAP-msg-listing"
-#define BTA_MA_HDR_TYPE_MSG "x-bt/message"
-#define BTA_MA_HDR_TYPE_MSG_STATUS "x-bt/messageStatus"
-#define BTA_MA_HDR_TYPE_FOLDER_LIST "x-obex/folder-listing"
-
-#define BTA_MAS_MESSAGE_ACCESS_TARGET_UUID "\xBB\x58\x2B\x40\x42\x0C\x11\xDB\xB0\xDE\x08\x00\x20\x0C\x9A\x66"
-#define BTA_MAS_MESSAGE_NOTIFICATION_TARGET_UUID "\xBB\x58\x2B\x41\x42\x0C\x11\xDB\xB0\xDE\x08\x00\x20\x0C\x9A\x66"
-#define BTA_MAS_UUID_LENGTH 16
-#define BTA_MAS_DEFAULT_VERSION 0x0100
-
-#define BTA_MA_NOTIF_STS_TAG_ID 0x0E
-#define BTA_MA_NOTIF_STS_LEN 0x01
-#define BTA_MA_NOTIF_STS_ON 0x01
-#define BTA_MA_NOTIF_STS_OFF 0x00
-
-#define BTA_MA_NAS_INST_ID_TAG_ID 0x0F
-#define BTA_MA_NAS_INST_ID_LEN 0x01
-
-#define BTA_MA_DEFAULT_MAX_LIST_CNT 1024
-
-
-#define BTA_MA_64BIT_HEX_STR_SIZE (16+1)
-#define BTA_MA_32BIT_HEX_STR_SIZE (8+1)
-
-
-
-/*******************************************************************************
-**
-** bMessage types
-**
-** Description The following types are designed to hold data in memory.
-** The internal structure of these types are implementation
-** specific.
-**
-*******************************************************************************/
-
-enum
-{
- BTA_MA_BMSG_ENC_8BIT = 0, /* Used for Email/MMS */
-
- BTA_MA_BMSG_ENC_G7BIT, /* Used for GSM-SMS */
- BTA_MA_BMSG_ENC_G7BITEXT,
- BTA_MA_BMSG_ENC_GUCS2,
- BTA_MA_BMSG_ENC_G8BIT,
-
- BTA_MA_BMSG_ENC_C8BIT, /* Used for CDMA-SMS */
- BTA_MA_BMSG_ENC_CEPM,
- BTA_MA_BMSG_ENC_C7ASCII,
- BTA_MA_BMSG_ENC_CIA5,
- BTA_MA_BMSG_ENC_CUNICODE,
- BTA_MA_BMSG_ENC_CSJIS,
- BTA_MA_BMSG_ENC_CKOREAN,
- BTA_MA_BMSG_ENC_CLATINHEB,
- BTA_MA_BMSG_ENC_CLATIN,
-
- BTA_MA_BMSG_ENC_UNKNOWN
-};
-typedef UINT8 tBTA_MA_BMSG_ENCODING;
-
-enum
-{
- BTA_MA_BMSG_LANG_UNSPECIFIED = 0,
-
- BTA_MA_BMSG_LANG_UNKNOWN,
- BTA_MA_BMSG_LANG_SPANISH, /* GSM-SMS or CDMA-SMS */
-
- BTA_MA_BMSG_LANG_TURKISH, /* GSM-SMS only */
- BTA_MA_BMSG_LANG_PORTUGUESE,
-
- BTA_MA_BMSG_LANG_ENGLISH, /* CDMA-SMS only */
- BTA_MA_BMSG_LANG_FRENCH,
- BTA_MA_BMSG_LANG_JAPANESE,
- BTA_MA_BMSG_LANG_KOREAN,
- BTA_MA_BMSG_LANG_CHINESE,
- BTA_MA_BMSG_LANG_HEBREW
-};
-typedef UINT8 tBTA_MA_BMSG_LANGUAGE;
-
-
-enum
-{
- BTA_MA_VCARD_VERSION_21=0,
- BTA_MA_VCARD_VERSION_30
-};
-typedef UINT8 tBTA_MA_VCARD_VERSION;
-
-enum
-{
- BTA_MA_VCARD_PROP_N,
- BTA_MA_VCARD_PROP_FN,
- BTA_MA_VCARD_PROP_TEL,
- BTA_MA_VCARD_PROP_EMAIL,
-
- BTA_MA_VCARD_PROP_MAX
-};
-typedef UINT8 tBTA_MA_VCARD_PROP;
-
-typedef struct
-{
- char * p_param;
- char * p_value;
-
- /* link to the next property (if any) */
- void * p_next;
-
-} tBTA_MA_VCARD_PROPERTY;
-
-typedef struct
-{
- tBTA_MA_VCARD_VERSION version;
-
- tBTA_MA_VCARD_PROPERTY * p_prop[BTA_MA_VCARD_PROP_MAX];
-
- /* link to the next vCard (if any) */
- void * p_next;
-
-} tBTA_MA_BMSG_VCARD;
-
-typedef struct BMSG_MESSAGE_struct
-{
- char * p_text;
-
- /* link to the next chunk of message text (if any) */
- void * p_next;
-
-} tBTA_MA_BMSG_MESSAGE;
-
-typedef struct BMSG_CONTENT_struct
-{
- /* this is the first bit of message text */
- tBTA_MA_BMSG_MESSAGE * p_message;
-
- /* this points to the last entered text -or-
- ** it is the last that we returned back to
- **
- */
- tBTA_MA_BMSG_MESSAGE * p_last;
-
- /* link to the next chunk of content (if any) */
- void * p_next;
-
-} tBTA_MA_BMSG_CONTENT;
-
-
-typedef struct
-{
- /* Part ID */
- UINT16 part_id;
- BOOLEAN is_multipart;
-
- /* Properties */
- tBTA_MA_BMSG_ENCODING encoding;
- tBTA_MA_BMSG_LANGUAGE language; /* optional */
- tBTA_MA_CHARSET charset;
- /* One or more body content */
- tBTA_MA_BMSG_CONTENT * p_content;
-
-} tBTA_MA_BMSG_BODY;
-
-typedef struct BMSG_ENVELOPE_struct
-{
- /* One or more Recipient (vCards) */
- tBTA_MA_BMSG_VCARD * p_recip;
-
- /* There will be either another envelope or the body */
- void * p_next;
- tBTA_MA_BMSG_BODY * p_body;
-
-} tBTA_MA_BMSG_ENVELOPE;
-
-typedef struct
-{
- /* Property values */
- BOOLEAN read_sts;
- tBTA_MA_MSG_TYPE msg_type;
- char * p_folder;
-
- /* One or more Originator (vCards) */
- tBTA_MA_BMSG_VCARD * p_orig;
-
- /* Envelope */
- tBTA_MA_BMSG_ENVELOPE * p_envelope;
-
-} tBTA_MA_BMSG;
-
-
-#endif
-
diff --git a/bta/include/bta_mse_api.h b/bta/include/bta_mse_api.h
deleted file mode 100644
index 742ea7a..0000000
--- a/bta/include/bta_mse_api.h
+++ /dev/null
@@ -1,470 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_mse_api.h
-**
-** Description: This is the public interface file for the Message Server Equipment
-** (MSE) subsystem of BTA, Broadcom's
-** Bluetooth application layer for mobile phones.
-**
-** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_MSE_API_H
-#define BTA_MSE_API_H
-
-#include "bta_api.h"
-#include "bta_ma_def.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-/* Extra Debug Code */
-#ifndef BTA_MSE_DEBUG
- #define BTA_MSE_DEBUG TRUE
-#endif
-
-/**************************
-** Common Definitions
-***************************/
-
-/* MSE callback function events */
-enum
-{
- BTA_MSE_ENABLE_EVT = 0, /* MAS server is enabled. */
- BTA_MSE_DISABLE_EVT,
- BTA_MSE_ACCESS_EVT,
- BTA_MSE_OPER_CMPL_EVT, /* MSE operation complete */
- BTA_MSE_MA_OPEN_EVT,
- BTA_MSE_MA_CLOSE_EVT,
- BTA_MSE_SET_NOTIF_REG_EVT,
- BTA_MSE_NOTIF_REG_EVT,
- BTA_MSE_UPDATE_INBOX_EVT,
- BTA_MSE_GET_MSG_IN_PROG_EVT,
- BTA_MSE_PUSH_MSG_IN_PROG_EVT,
- BTA_MSE_SEND_NOTIF_EVT,
- BTA_MSE_MN_OPEN_EVT,
- BTA_MSE_MN_CLOSE_EVT,
- BTA_MSE_START_EVT,
- BTA_MSE_STOP_EVT
-};
-typedef UINT8 tBTA_MSE_EVT;
-
-
-/* Structure associated with BTA_MSE_ENABLE_EVT
- BTA_MSE_DISABLE_EVT
-*/
-typedef struct
-{
- tBTA_MA_STATUS status;
- UINT8 app_id;
-} tBTA_MSE_ENABLE_DISABLE;
-
-
-/*******************************************
-** Message Access Server Definitions
-********************************************/
-/* Access event operation types */
-#define BTA_MSE_OPER_NONE 0
-#define BTA_MSE_OPER_SETPATH 1
-#define BTA_MSE_OPER_GET_FOLDER_LIST 2
-#define BTA_MSE_OPER_GET_MSG_LIST 3
-#define BTA_MSE_OPER_GET_MSG 4
-#define BTA_MSE_OPER_SET_MSG_STATUS 5
-#define BTA_MSE_OPER_DEL_MSG 6
-#define BTA_MSE_OPER_PUSH_MSG 7
-#define BTA_MSE_OPER_NOTIF_REG 8
-#define BTA_MSE_OPER_UPDATE_INBOX 9
-
-typedef UINT8 tBTA_MSE_OPER;
-
-/* Structure associated with BTA_MSE_ACCESS_EVT */
-typedef struct
-{
- tBTA_MA_SESS_HANDLE mas_session_id; /* MAS Session ID */
- tBTA_MSE_OPER oper; /* operation */
- char *p_path; /* full path name */
- tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
- BD_ADDR bd_addr; /* Address of device */
- tBTA_MA_MSG_HANDLE handle;
- BOOLEAN delete_sts;
-} tBTA_MSE_ACCESS;
-
-/* Structure associated with BTA_MSE_OPER_CMPL_EVT */
-typedef struct
-{
- UINT32 obj_size; /* Total size of object 0 if unknow*/
- tBTA_MA_SESS_HANDLE mas_session_id; /* MAS Session ID */
- tBTA_MSE_OPER operation;
- tBTA_MA_STATUS status;
-} tBTA_MSE_OPER_CMPL;
-
-
-/* Structure associated with BTA_MSE_MA_OPEN_EVT */
-typedef struct
-{
- tBTA_MA_INST_ID mas_instance_id; /* MAS instance ID: one MAS
- instance can support multiple
- sessions */
- tBTA_MA_SESS_HANDLE mas_session_id; /* MAS Session ID, all session based
- operation will need to use this ID */
- tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
- BD_ADDR bd_addr; /* Address of device */
-
-} tBTA_MSE_MA_OPEN;
-
-/* Structure associated with BTA_MSE_MA_CLOSE_EVT */
-typedef struct
-{
- tBTA_MA_STATUS status;
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MA_INST_ID mas_instance_id;
-} tBTA_MSE_MA_CLOSE;
-
-/* Structure associated with BTA_MSE_MN_OPEN_EVT or
- BTA_MSE_MN_CLOSE_EVT
-*/
-typedef struct
-{
- tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
- BD_ADDR bd_addr; /* Address of device */
- tBTA_MA_INST_ID first_mas_instance_id; /* MN connection can be used for more
- than one MasInstanceIDs.
- first_mas_instance_id is the MasInstanceId of a
- MAS service MCE first registers to receive the
- message notification */
-} tBTA_MSE_MN_OPEN;
-
-typedef struct
-{
- tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
- BD_ADDR bd_addr; /* Address of device */
-} tBTA_MSE_MN_CLOSE;
-
-/* Update Inbox response types */
-enum
-{
- BTA_MSE_UPDATE_INBOX_ALLOW = 0, /* Allow the update inbox */
- BTA_MSE_UPDATE_INBOX_FORBID /* Disallow the update inbox */
-};
-typedef UINT8 tBTA_MSE_UPDATE_INBOX_TYPE;
-
-
-/* Set Notification Registration response types */
-enum
-{
- BTA_MSE_SET_NOTIF_REG_ALLOW = 0, /* Allow the notification registration request*/
- BTA_MSE_SET_NOTIF_REG_FORBID /* Disallow the notification registration request */
-};
-typedef UINT8 tBTA_MSE_SET_NOTIF_REG_TYPE;
-
-/* Structure associated with BTA_MSE_SEND_NOTIF_EVT */
-typedef struct
-{
- tBTA_MA_STATUS status;
- tBTA_MA_INST_ID mas_instance_id;
- BD_ADDR bd_addr; /* remote MCE's BD address*/
-} tBTA_MSE_SEND_NOTIF;
-
-
-/* Structure associated with BTA_MSE_START_EVT or
- BTA_MSE_STOP_EVT */
-typedef struct
-{
- tBTA_MA_STATUS status;
- UINT8 mas_instance_id;
-} tBTA_MSE_START_STOP;
-
-typedef struct
-{
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MA_INST_ID mas_instance_id;
- tBTA_MA_NOTIF_STATUS notif_status;
- BD_ADDR bd_addr; /* remote MCE's BD address*/
-}tBTA_MSE_SET_NOTIF_REG;
-
-typedef struct
-{
- tBTA_MA_STATUS status;
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MA_INST_ID mas_instance_id;
- tBTA_MA_NOTIF_STATUS notif_status;
- BD_ADDR bd_addr; /* remote MCE's BD address*/
-}tBTA_MSE_NOTIF_REG;
-
-
-/* Data associated with call back events */
-typedef union
-{
- tBTA_MA_SESS_HANDLE mas_session_id; /* BTA_MSE_UPDATE_INBOX_EVT*/
- tBTA_MSE_ENABLE_DISABLE enable;
- tBTA_MSE_ENABLE_DISABLE disable;
- tBTA_MSE_ACCESS access;
- tBTA_MSE_SET_NOTIF_REG set_notif_reg;
- tBTA_MSE_NOTIF_REG notif_reg;
- tBTA_MSE_MN_OPEN mn_open;
- tBTA_MSE_MN_CLOSE mn_close;
- tBTA_MSE_MA_OPEN ma_open;
- tBTA_MSE_MA_CLOSE ma_close;
- tBTA_MSE_SEND_NOTIF send_notif;
- tBTA_MA_IN_PROG get_msg_in_prog;
- tBTA_MA_IN_PROG push_msg_in_prog;
- tBTA_MSE_OPER_CMPL oper_cmpl;
- tBTA_MSE_START_STOP start;
- tBTA_MSE_START_STOP stop;
-} tBTA_MSE;
-
-/* MSE callback function */
-typedef void tBTA_MSE_CBACK(tBTA_MSE_EVT event, tBTA_MSE *p_data);
-
-
-/********************************************
-** Message Notification Client Definitions
-*********************************************/
-
-/* Send Notification function arguments definition */
-enum
-{
- BTA_MSE_NOTIF_TYPE_NEW_MSG = 0,
- BTA_MSE_NOTIF_TYPE_DELIVERY_SUCCESS,
- BTA_MSE_NOTIF_TYPE_SENDING_SUCCESS,
- BTA_MSE_NOTIF_TYPE_DELIVERY_FAILURE,
- BTA_MSE_NOTIF_TYPE_SENDING_FAILURE,
- BTA_MSE_NOTIF_TYPE_MEMORY_FULL,
- BTA_MSE_NOTIF_TYPE_MEMORY_AVAILABLE,
- BTA_MSE_NOTIF_TYPE_MESSAGE_DELETED,
- BTA_MSE_NOTIF_TYPE_MESSAGE_SHIFT,
- BTA_MSE_NOTIF_TYPE_MAX
-};
-
-typedef UINT8 tBTA_MSE_NOTIF_TYPE;
-
-/* configuration related constant */
-
-
-
-/* MSE configuration data */
-#define BTA_MSE_NUM_INST 4
-#define BTA_MSE_NUM_SESS 4
-#define BTA_MSE_NUM_MN 7 /* i.e. up to 7 MCEs can be connected to the MSE */
-
-typedef struct
-{
- INT32 obx_rsp_tout; /* maximum amount of time to wait for obx rsp */
- UINT16 max_name_len; /* maximum folder name length */
-
-} tBTA_MSE_CFG;
-
-extern tBTA_MSE_CFG * p_bta_mse_cfg;
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/**************************
-** API Functions
-***************************/
-
-/*******************************************************************************
-**
-** Function BTA_MseEnable
-**
-** Description Enable the MSE subsystems. This function must be
-** called before any other functions in the MSE API are called.
-** When the enable operation is completed the callback function
-** will be called with an BTA_MSE_ENABLE_EVT event.
-**
-** Parameters p_cback - MSE event call back function
-** app_id - Application ID
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseEnable(tBTA_MSE_CBACK *p_cback, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function BTA_MseDisable
-**
-** Description Disable the MSE subsystem.
-**
-** Parameters
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseDisable(void);
-/*******************************************************************************
-**
-** Function BTA_MseStart
-**
-** Description Start a MA server on the MSE
-**
-**
-** Parameters mas_inst_id - MAS instance ID
-** sec_mask - Security Setting Mask
-** MSE always enables
-** (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)
-** p_service_name - Pointer to service name
-** p_root_path - Pointer to root path
-** (one level above telecom)
-** sup_msg_type - supported message type(s)
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseStart( tBTA_MA_INST_ID mas_inst_id,
- tBTA_SEC sec_mask, const char *p_service_name,
- const char *p_root_path,
- tBTA_MA_MSG_TYPE sup_msg_type);
-/*******************************************************************************
-**
-** Function BTA_MseStop
-**
-** Description Stop a MAS service on the MSE
-**
-** Parameters mas_instance_id - MAS Instance ID
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseStop (tBTA_MA_INST_ID mas_instance_id);
-
-/*******************************************************************************
-**
-** Function BTA_MseClose
-**
-** Description Close all MAS sessions on the specified MAS Instance ID
-**
-** Parameters mas_instance_id - MAS Inatance ID
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseClose(tBTA_MA_INST_ID mas_instance_id);
-
-/*******************************************************************************
-**
-** Function BTA_MseMaClose
-**
-** Description Close a MAS sessions on the specified BD address
-**
-** Parameters bd_addr - remote BD's address
-** mas_instance_id - MAS Inatance ID
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseMaClose(BD_ADDR bd_addr, tBTA_MA_INST_ID mas_instance_id);
-
-/*******************************************************************************
-**
-** Function BTA_MseMnClose
-**
-** Description Close a MN session
-**
-** Parameters bd_addr - remote BT's address
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseMnClose(BD_ADDR bd_addr);
-
-/*******************************************************************************
-**
-** Function BTA_MseAccessRsp
-**
-** Description Send a response for the access request
-**
-** Parameters mas_session_id - MAS session ID
-** oper - MAS operation type
-** access - Access is allowed or not
-** p_path - pointer to a path if if the operation
-** involves accessing a folder
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseAccessRsp(tBTA_MA_SESS_HANDLE mas_session_id, tBTA_MSE_OPER oper,
- tBTA_MA_ACCESS_TYPE access, char *p_name);
-
-/*******************************************************************************
-**
-** Function BTA_MseUpdateInboxRsp
-**
-** Description Send a response for the update inbox request
-**
-**
-** Parameters mas_session_id - MAS session ID
-** update_rsp - update inbox is allowed or not
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseUpdateInboxRsp(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MSE_UPDATE_INBOX_TYPE update_rsp);
-
-/*******************************************************************************
-**
-** Function BTA_MseSetNotifRegRsp
-**
-** Description Send a response for the set notification registration
-**
-**
-** Parameters mas_session_id - MAS session ID
-** set_notif_reg_rsp - indicate whether the set notification
-** registration is allowed or not
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseSetNotifRegRsp(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MSE_SET_NOTIF_REG_TYPE set_notif_reg_rsp);
-
-/*******************************************************************************
-**
-** Function BTA_MseSendNotif
-**
-** Description Send a Message notification report to all MCEs registered with
-** the specified MAS instance ID
-**
-** Parameters mas_instance_id - MAS Instance ID
-** notif_type - message notification type
-** handle - message handle
-** p_folder - pointer to current folder
-** p_old_folder - pointer to older folder
-** msg_type - message type (E_MAIL, SMS_GSM, SMS_CDMA, MMS)
-** except_bd_addr - except to the MCE on this BD Address.
-** (Note: notification will be not sent to
-** this BD Addreess)
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseSendNotif(tBTA_MA_INST_ID mas_instance_id,
- tBTA_MSE_NOTIF_TYPE notif_type,
- tBTA_MA_MSG_HANDLE handle,
- char * p_folder, char *p_old_folder,
- tBTA_MA_MSG_TYPE msg_type,
- BD_ADDR except_bd_addr);
-
-/*******************************************************************************
-**
-** Function BTA_MseMnAbort
-**
-** Description Abort the current OBEX multi-packt operation
-**
-** Parameters mas_instance_id - MAS Instance ID
-**
-** Returns void
-**
-*******************************************************************************/
- BTA_API extern void BTA_MseMnAbort(tBTA_MA_INST_ID mas_instance_id);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BTA_MSE_API_H */
diff --git a/bta/include/bta_mse_ci.h b/bta/include/bta_mse_ci.h
deleted file mode 100644
index f366f16..0000000
--- a/bta/include/bta_mse_ci.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_mse_ci.h
-**
-** Description: This is the interface file for the Message Server Equipment
-** (MSE) subsystem call-out functions.
-**
-** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_MSE_CI_H
-#define BTA_MSE_CI_H
-
-#include "bta_api.h"
-#include "bta_ma_def.h"
-#include "bta_mse_api.h"
-#include "bta_mse_co.h"
-
-/*******************************************************************************
-**
-** Function bta_mse_ci_get_folder_entry
-**
-** Description This function is called in response to the
-** bta_mse_co_get_folder_entry call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK if p_entry points to a valid entry.
-** BTA_MA_STATUS_EODIR if no more entries (p_entry is ignored).
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** evt - evt from the call-out function
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_get_folder_entry(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- UINT16 evt);
-/*******************************************************************************
-**
-** Function bta_mse_ci_get_msg_list_info
-**
-** Description This function is called in response to the
-** bta_mse_co_get_msg_list_info call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK operation is successful.
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** evt - evt from the call-out function
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_get_msg_list_info(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- UINT16 evt);
-/*******************************************************************************
-**
-** Function bta_mse_ci_get_msg_list_entry
-**
-** Description This function is called in response to the
-** bta_mse_co_get_msg_list_entry call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK if p_entry points to a valid entry.
-** BTA_MA_STATUS_EODIR if no more entries (p_entry is ignored).
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** evt - evt from the call-out function
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_get_msg_list_entry(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- UINT16 evt);
-/*******************************************************************************
-**
-** Function bta_mse_ci_get_msg
-**
-** Description This function is called in response to the
-** bta_mse_co_get_msg call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK if p_msg points to a valid bmessage.
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** filled_buff_size - size of the filled buffer
-** multi_pkt_status - BTA_MA_MPKT_STATUS_MORE - need to get more packets
-** BTA_MA_MPKT_STATUS_LAST - last packet of the bMessage
-** frac_deliver_status - BTA_MA_FRAC_DELIVER_MORE - other fractions following
-** this bMessage
-** BTA_MA_FRAC_DELIVER_LAST - Last fraction
-** evt - evt from the call-out function
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_get_msg(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- UINT16 filled_buff_size,
- tBTA_MA_MPKT_STATUS multi_pkt_status,
- tBTA_MA_FRAC_DELIVER frac_deliver_status,
- UINT16 evt);
-/*******************************************************************************
-**
-** Function bta_mse_ci_set_msg_delete_status
-**
-** Description This function is called in response to the
-** bta_mse_co_set_msg_delete_status call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK if operation is successful.
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** evt - evt from the call-out function
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_set_msg_delete_status(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- UINT16 evt);
-/*******************************************************************************
-**
-** Function bta_mse_ci_push_msg
-**
-** Description This function is called in response to the
-** bta_mse_co_push_msg call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK if the message upload is successful.
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** last_packet - last packet of a multi-packet message
-** handle - message handle for the uploaded message if
-** status is BTA_MA_OK and last_packet is TRUE
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_push_msg(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- BOOLEAN last_packet,
- tBTA_MA_MSG_HANDLE handle,
- UINT16 evt);
-#endif /* BTA_MSE_CI_H */
-
-
-
-
diff --git a/bta/include/bta_mse_co.h b/bta/include/bta_mse_co.h
deleted file mode 100644
index adc551f..0000000
--- a/bta/include/bta_mse_co.h
+++ /dev/null
@@ -1,330 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_mse_co.h
-**
-** Description: This is the interface file for the Message Server Equipment
-** (MSE) subsystem call-out functions.
-**
-** Copyright (c) 2009-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_MSE_CO_H
-#define BTA_MSE_CO_H
-
-#include "bta_api.h"
-#include "bta_ma_def.h"
-#include "bta_mse_api.h"
-
-/*****************************************************************************
-** Constants and Data Types
-*****************************************************************************/
-/**************************
-** Common Definitions
-***************************/
-
-
-/* Return structure type for a folder entry i.e. only folder level
- information under the specified path and no file name */
-typedef struct
-{
- UINT32 refdata; /* holder for OS specific data used to get next entry */
- UINT32 filesize;
- char *p_name; /* Contains the addr of memory to copy name into */
- char crtime[BTA_FS_CTIME_LEN]; /* "yyyymmddTHHMMSSZ", or "" if none */
- UINT8 mode; /* BTA_MSE_A_RDONLY and/or BTA_MSE_A_DIR */
-} tBTA_MSE_CO_FOLDER_ENTRY;
-
-
-#define BTA_MSE_CO_MAX_ADDR_LEN 256 /* See MAP spec 3.1.6 */
-#define BTA_MSE_CO_MAX_DATE_TIME 21 /* "YYYYMMDDTHHMMSS+hhmm" or "YYYYMMDDTHHMMSS" */
-
-enum
-{
- BTA_MSE_CO_RCV_STATUS_COMPLETE = 0,
- BTA_MSE_CO_RCV_STATUS_FRACTIONED,
- BTA_MSE_CO_RCV_STATUS_NOTIFICATION,
- BTA_MSE_CO_RCV_STATUS_MAX
-};
-
-typedef UINT8 tBTA_MSE_CO_RCV_STATUS;
-
-typedef struct
-{
- UINT16 msg_list_size;
- UINT8 mse_time_len;
- char mse_time[BTA_FS_CTIME_LEN];
- BOOLEAN new_msg;
-} tBTA_MSE_CO_MSG_LIST_INFO;
-
-typedef struct
-{
- UINT32 refdata; /* holder for OS specific data used to get next msg entry */
- tBTA_MA_ML_MASK parameter_mask;
- UINT32 org_msg_size;
- UINT32 attachment_size;
- BOOLEAN text;
- BOOLEAN high_priority;
- BOOLEAN read;
- BOOLEAN sent;
- BOOLEAN is_protected;
- tBTA_MA_MSG_HANDLE msg_handle;
- tBTA_MA_MSG_TYPE type;
- tBTA_MSE_CO_RCV_STATUS reception_status;
- char subject[BTA_MSE_CO_MAX_ADDR_LEN];
- char date_time[BTA_MSE_CO_MAX_DATE_TIME]; /* "YYYYMMDDTHHMMSS+hhmm", "YYYYMMDDTHHMMSS", or "" if none */
- char sender_name[BTA_MSE_CO_MAX_ADDR_LEN];
- char sender_addressing[BTA_MSE_CO_MAX_ADDR_LEN];
- char recipient_name[BTA_MSE_CO_MAX_ADDR_LEN];
- char recipient_addressing[BTA_MSE_CO_MAX_ADDR_LEN];
- char replyto_addressing[BTA_MSE_CO_MAX_ADDR_LEN];
-} tBTA_MSE_CO_MSG_LIST_ENTRY;
-
-/*******************************************************************************
-**
-** Function bta_mse_co_update_inbox
-**
-** Description Update the inbox
-**
-** Parameters mas_session_id - MAS session ID
-** app_id - application ID specified in the enable functions.
-** It can be used to identify which application
-** is the caller of the call-out function.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_co_update_inbox(tBTA_MA_SESS_HANDLE mas_session_id, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function bta_mse_co_set_folder
-**
-** Description Set the current foldeer to the specified path
-**
-** Parameters mas_session_id - MAS session ID
-** p_path - points to the current folder path
-** app_id - application ID specified in the enable functions.
-** It can be used to identify which application
-** is the caller of the call-out function.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_co_set_folder(tBTA_MA_SESS_HANDLE mas_session_id,
- const char *p_path,
- UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function bta_mse_co_get_folder_entry
-**
-** Description This function is called to get a folder entry for the
-** specified path. The folder name should be filled
-** into the location specified by p_entry.
-**
-** Parameters mas_session_id - MAS session ID
-** p_path - points to the folder path to get the subfolder entry
-** (fully qualified path)
-** first_item - TRUE if first search, FALSE if next search
-** p_entry (input/output) - Points to the current entry data
-** evt - event that must be passed into the call-in function.
-** app_id - application ID specified in the enable functions.
-** It can be used to identify which application
-** is the caller of the call-out function.
-**
-** Returns void
-**
-** Note: Upon completion of the request, the status is passed
-** in the bta_mse_ci_get_folder_entry() call-in function.
-** BTA_MA_STATUS_OK is returned when p_entry is valid,
-** BTA_MA_STATUS_EODIR is returned when no more entries [finished]
-** BTA_MA_STATUS_FAIL is returned if an error occurred
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_co_get_folder_entry(tBTA_MA_SESS_HANDLE mas_session_id, const char *p_path,
- BOOLEAN first_item, tBTA_MSE_CO_FOLDER_ENTRY *p_entry,
- UINT16 evt, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function bta_mse_co_get_msg_list_info
-**
-** Description This function is called to get a message list information for
-** the specified folder
-**
-** Parameters mas_session_id - MAS session ID
-** p_name - points to the current or child folder for getting the
-** message list information
-** (if *p_name == "" it means current folder)
-** filter_para - filter parameters for getting the message
-** list information
-** p_info(input/output) - Points to the message listing information
-** evt - event that be passed into the call-in function.
-** app_id - application ID specified in the enable functions.
-** It can be used to identify which application
-** is the caller of the call-out function.
-**
-** Returns void
-**
-** Note: Upon completion of the request, the status is passed
-** in the bta_mse_ci_get_msg_list_info() call-in function.
-** BTA_MA_STATUS_OK is returned when p_entry is valid
-** BTA_MA_STATUS_FAIL is returned if an error occurred
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_co_get_msg_list_info(tBTA_MA_SESS_HANDLE mas_session_id, const char *p_name,
- tBTA_MA_MSG_LIST_FILTER_PARAM * p_filter_param,
- tBTA_MSE_CO_MSG_LIST_INFO * p_info,
- UINT16 evt, UINT8 app_id);
-/*******************************************************************************
-**
-** Function bta_mse_co_get_msg_list_entry
-**
-** Description This function is called to retrieve a message list entry for
-** the specified folder. The msg information should be filled by
-** application into the location specified by p_entry.
-**
-** Parameters mas_session_id - MAS session ID
-** p_name - points to the current or child folder for getting the
-** message list entry
-** (if *p_name == "" it means current folder)
-** filter_para - filter parameters for getting message list
-** first_item - TRUE if first get, FALSE if next msg
-** p_entry(input/output) - Points to current entry data
-** evt - event that must be passed into the call-in function.
-** app_id - application ID specified in the enable functions.
-** It can be used to identify which application
-** is the caller of the call-out function.
-**
-** Returns void
-**
-** Note: Upon completion of the request, the status is passed
-** in the bta_mse_ci_get_msg_list_entry() call-in function.
-** BTA_MA_STATUS_OK is returned when p_entry is valid,
-** BTA_MA_STATUS_EODIR is returned when no more entries [finished]
-** BTA_MA_STATUS_FAIL is returned if an error occurred
-*******************************************************************************/
-BTA_API extern void bta_mse_co_get_msg_list_entry(tBTA_MA_SESS_HANDLE mas_session_id, const char *p_name,
- tBTA_MA_MSG_LIST_FILTER_PARAM *p_filter_param,
- BOOLEAN first_item, tBTA_MSE_CO_MSG_LIST_ENTRY *p_entry,
- UINT16 evt, UINT8 app_id);
-/*******************************************************************************
-**
-** Function bta_mse_co_get_msg
-**
-** Description This function is called to retrieve a msessage for the
-** specified message handle. The message will be filled by
-** application in bMessage format into the location
-** specified by p_buffer. The status and size of the filled
-** buffer are returned by bta_mse_ci_get_msg() call-in function
-**
-**
-** Parameters mas_session_id - MAS session ID
-** p_param - points to the parameters for the get message operation
-** first_get - TRUE first get FALSE subsequent get
-** buffer_size - size of the buffer pointed by p_buffer
-** p_buffer - points to the bMessage object storage location
-** evt - event that be passed into the call-in function.
-** app_id - application ID specified in the enable functions.
-** It can be used to identify which application
-** is the caller of the call-out function.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_co_get_msg(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_GET_MSG_PARAM *p_param,
- BOOLEAN first_get,
- UINT16 buffer_size,
- UINT8 *p_buffer,
- UINT16 evt,
- UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function bta_mse_co_set_msg_delete_status
-**
-** Description This function is called to set a message delete status
-**
-** Parameters mas_session_id - MAS session ID
-** handle - message handle
-** status value - 1- yes, 0 = No
-** evt_id - event that be passed into the call-in function.
-** app_id - application ID specified in the enable functions.
-** It can be used to identify which application
-** is the caller of the call-out function.
-**
-** Returns void
-**
-** Note: Upon completion of the request, the status is passed
-** in the bta_mse_ci_set_msg_delete_status() call-in function.
-** BTA_MA_STATUS_OK is returned when the delete operation is successful
-** BTA_MA_STATUS_FAIL is returned if an error occurred
-*******************************************************************************/
-BTA_API extern void bta_mse_co_set_msg_delete_status(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_MSG_HANDLE handle,
- UINT8 status_value,
- UINT16 evt_id,
- UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function bta_mse_co_set_msg_read_status
-**
-** Description This function is called to set a message read status
-**
-** Parameters mas_session_id - MAS session ID
-** handle - message handle
-** status value - 1- yes, 0 = No
-** app_id - application ID specified in the enable functions.
-** It can be used to identify which application
-** is the caller of the call-out function.
-**
-** Returns BTA_MA_STATUS_OK - read status change is successful
-** BTA_MA_STATUS_FAIL
-*******************************************************************************/
-BTA_API extern tBTA_MA_STATUS bta_mse_co_set_msg_read_status(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_MSG_HANDLE handle,
- UINT8 status_value,
- UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function bta_mse_co_push_msg
-**
-** Description This function is called to upload a message to the
-** specified folder
-**
-** Parameters mas_session_id - MAS session ID
-** p_param - points to parameters for message upload
-** msg_len - length of the message to be uploaded
-** p_msg - points to the message to be uploaded
-** first_pkt - TRUE first push message packet
-** multi_pkt_status -
-** BTA_MA_MPKT_STATUS_MORE - need to get more packets
-** BTA_MA_MPKT_STATUS_LAST - last packet of
-** the bMessage to be uploaded
-** evt - event that be passed into the call-in function.
-** app_id - application ID specified in the enable functions.
-** It can be used to identify which application
-** is the caller of the call-out function.
-**
-** Returns void
-**
-** Note1: Upon completion of the request, the status is passed
-** in the bta_mse_ci_push_msg() call-in function.
-** BTA_MA_STATUS_OK is returned if the request is successful,
-** BTA_MA_STATUS_FAIL is returned if an error occurred
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_co_push_msg(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_PUSH_MSG_PARAM *p_param,
- UINT16 msg_len,
- UINT8 *p_msg,
- BOOLEAN first_pkt,
- tBTA_MA_MPKT_STATUS mpkt_status,
- UINT16 evt,
- UINT8 app_id);
-
-#endif /* BTA_MSE_CO_H */
diff --git a/bta/include/bta_op_api.h b/bta/include/bta_op_api.h
index b2a624c..b333622 100644
--- a/bta/include/bta_op_api.h
+++ b/bta/include/bta_op_api.h
@@ -50,572 +50,5 @@ typedef UINT8 tBTA_OP_FMT;
typedef UINT8 tBTA_OP_FMT_MASK;
-/* Status */
-#define BTA_OP_OK 0 /* Operation successful. */
-#define BTA_OP_FAIL 1 /* Operation failed. */
-#define BTA_OP_MEM 2 /* Not enough memory to complete operation. */
-
-typedef UINT8 tBTA_OP_STATUS;
-
-/* vCal Object Type */
-#define BTA_OP_VCAL_EVENT 0 /* Object is an "Event" object. */
-#define BTA_OP_VCAL_TODO 1 /* Object is a "ToDo" object. */
-
-typedef UINT8 tBTA_OP_VCAL;
-
-/* vCard Property Names */
-#define BTA_OP_VCARD_ADR 1 /* Address. */
-#define BTA_OP_VCARD_EMAIL 2 /* Email address. */
-#define BTA_OP_VCARD_FN 3 /* Formatted name. */
-#define BTA_OP_VCARD_NOTE 4 /* Note. */
-#define BTA_OP_VCARD_NICKNAME 5 /* Nickname. */
-#define BTA_OP_VCARD_N 6 /* Name. */
-#define BTA_OP_VCARD_ORG 7 /* Organization. */
-#define BTA_OP_VCARD_TEL 8 /* Telephone number. */
-#define BTA_OP_VCARD_TITLE 9 /* Title. */
-#define BTA_OP_VCARD_URL 10 /* URL. */
-#define BTA_OP_VCARD_LUID 11 /* Locally Unique Identifier. */
-#define BTA_OP_VCARD_BDAY 12 /* Birthday. */
-#define BTA_OP_VCARD_PHOTO 13 /* Photo. */
-#define BTA_OP_VCARD_SOUND 14 /* Sound. */
-#define BTA_OP_VCARD_CALL 15 /* Call date-time */
-
-/* vCal Property Names */
-#define BTA_OP_VCAL_CATEGORIES 1 /* Categories of event. */
-#define BTA_OP_VCAL_COMPLETED 2 /* Time event is completed. */
-#define BTA_OP_VCAL_DESCRIPTION 3 /* Description of event. */
-#define BTA_OP_VCAL_DTEND 4 /* End date and time of event. */
-#define BTA_OP_VCAL_DTSTART 5 /* Start date and time of event. */
-#define BTA_OP_VCAL_DUE 6 /* Due date and time of event. */
-#define BTA_OP_VCAL_LOCATION 7 /* Location of event. */
-#define BTA_OP_VCAL_PRIORITY 8 /* Priority of event. */
-#define BTA_OP_VCAL_STATUS 9 /* Status of event. */
-#define BTA_OP_VCAL_SUMMARY 10 /* Summary of event. */
-#define BTA_OP_VCAL_LUID 11 /* Locally Unique Identifier. */
-
-/* vNote Property Names */
-#define BTA_OP_VNOTE_BODY 1 /* Message body text. */
-#define BTA_OP_VNOTE_LUID 2 /* Locally Unique Identifier. */
-
-/* Structure of the 32-bit parameters mask:
-**
-** + property-specific
-** +reserved | + character set
-** | | | + encoding
-** | | | |
-** 0000000000000000 00000000 00000 000
-*/
-
-/* Encoding Parameter */
-#define BTA_OP_ENC_QUOTED_PRINTABLE (1<<0) /* Quoted-Printable encoding. */
-#define BTA_OP_ENC_8BIT (2<<0) /* 8-bit encoding */
-#define BTA_OP_ENC_BINARY (3<<0) /* Binary encoding */
-// btla-specific ++
-#define BTA_OP_ENC_BASE64 (4<<0) /* base64 encoding */
-// btla-specific --
-
-/* Character Set Parameter */
-#define BTA_OP_CHAR_BIG5 (1<<3) /* Big5 character set. */
-#define BTA_OP_CHAR_EUC_JP (2<<3) /* EUC-JP character set. */
-#define BTA_OP_CHAR_EUC_KR (3<<3) /* EUC-KR character set. */
-#define BTA_OP_CHAR_GB2312 (4<<3) /* GB2312 character set. */
-#define BTA_OP_CHAR_ISO_2022_JP (5<<3) /* ISO-2022-JP character set. */
-#define BTA_OP_CHAR_ISO_8859_1 (6<<3) /* ISO-8859-1 character set. */
-#define BTA_OP_CHAR_ISO_8859_2 (7<<3) /* ISO-8859-2 character set. */
-#define BTA_OP_CHAR_ISO_8859_3 (8<<3) /* ISO-8859-3 character set. */
-#define BTA_OP_CHAR_ISO_8859_4 (9<<3) /* ISO-8859-4 character set. */
-#define BTA_OP_CHAR_ISO_8859_5 (10<<3) /* ISO-8859-5 character set. */
-#define BTA_OP_CHAR_ISO_8859_6 (11<<3) /* ISO-8859-6 character set. */
-#define BTA_OP_CHAR_ISO_8859_7 (12<<3) /* ISO-8859-7 character set. */
-#define BTA_OP_CHAR_ISO_8859_8 (13<<3) /* ISO-8859-8 character set. */
-#define BTA_OP_CHAR_KOI8_R (14<<3) /* KOI8-R character set. */
-#define BTA_OP_CHAR_SHIFT_JIS (15<<3) /* Shift_JIS character set. */
-#define BTA_OP_CHAR_UTF_8 (16<<3) /* UTF-8 character set. */
-
-/* Address Type Parameter */
-#define BTA_OP_ADR_DOM (1<<8) /* Domestic address. */
-#define BTA_OP_ADR_INTL (1<<9) /* International address. */
-#define BTA_OP_ADR_POSTAL (1<<10) /* Postal address. */
-#define BTA_OP_ADR_PARCEL (1<<11) /* Parcel post address. */
-#define BTA_OP_ADR_HOME (1<<12) /* Home address. */
-#define BTA_OP_ADR_WORK (1<<13) /* Work address. */
-
-/* EMAIL Type Parameter */
-#define BTA_OP_EMAIL_PREF (1<<8) /* Preferred email. */
-#define BTA_OP_EMAIL_INTERNET (1<<9) /* Internet email. */
-#define BTA_OP_EMAIL_X400 (1<<10) /* x400 emaill */
-
-/* Telephone Number Type Parameter */
-#define BTA_OP_TEL_PREF (1<<8) /* Preferred number. */
-#define BTA_OP_TEL_WORK (1<<9) /* Work number. */
-#define BTA_OP_TEL_HOME (1<<10) /* Home number. */
-#define BTA_OP_TEL_VOICE (1<<11) /* Voice number. */
-#define BTA_OP_TEL_FAX (1<<12) /* Fax number. */
-#define BTA_OP_TEL_MSG (1<<13) /* Message number. */
-#define BTA_OP_TEL_CELL (1<<14) /* Cell phone number. */
-#define BTA_OP_TEL_PAGER (1<<15) /* Pager number. */
-
-/* Photo Parameter */
-#define BTA_OP_PHOTO_VALUE_URI (1<<8) /* URI value */
-#define BTA_OP_PHOTO_VALUE_URL (1<<9) /* URL value */
-#define BTA_OP_PHOTO_TYPE_JPEG (1<<10) /* JPEG photo */
-#define BTA_OP_PHOTO_TYPE_GIF (1<<11) /* GIF photo */
-
-/* Sound Parameter */
-#define BTA_OP_SOUND_VALUE_URI (1<<8) /* URI value */
-#define BTA_OP_SOUND_VALUE_URL (1<<9) /* URL value */
-#define BTA_OP_SOUND_TYPE_BASIC (1<<10) /* BASIC sound */
-#define BTA_OP_SOUND_TYPE_WAVE (1<<11) /* WAVE sound */
-
-/* vCard filter mask */
-#define BTA_OP_FILTER_VERSION (1<<0) /* vCard Version */
-#define BTA_OP_FILTER_FN (1<<1) /* Formatted Name */
-#define BTA_OP_FILTER_N (1<<2) /* Structured Presentation of Name */
-#define BTA_OP_FILTER_PHOTO (1<<3) /* Associated Image or Photo */
-#define BTA_OP_FILTER_BDAY (1<<4) /* Birthday */
-#define BTA_OP_FILTER_ADR (1<<5) /* Delivery Address */
-#define BTA_OP_FILTER_LABEL (1<<6) /* Delivery */
-#define BTA_OP_FILTER_TEL (1<<7) /* Telephone Number */
-#define BTA_OP_FILTER_EMAIL (1<<8) /* Electronic Mail Address */
-#define BTA_OP_FILTER_MAILER (1<<9) /* Electronic Mail */
-#define BTA_OP_FILTER_TZ (1<<10) /* Time Zone */
-#define BTA_OP_FILTER_GEO (1<<11) /* Geographic Position */
-#define BTA_OP_FILTER_TITLE (1<<12) /* Job */
-#define BTA_OP_FILTER_ROLE (1<<13) /* Role within the Organization */
-#define BTA_OP_FILTER_LOGO (1<<14) /* Organization Logo */
-#define BTA_OP_FILTER_AGENT (1<<15) /* vCard of Person Representing */
-#define BTA_OP_FILTER_ORG (1<<16) /* Name of Organization */
-#define BTA_OP_FILTER_NOTE (1<<17) /* Comments */
-#define BTA_OP_FILTER_REV (1<<18) /* Revision */
-#define BTA_OP_FILTER_SOUND (1<<19) /* Pronunciation of Name */
-#define BTA_OP_FILTER_URL (1<<20) /* Uniform Resource Locator */
-#define BTA_OP_FILTER_UID (1<<21) /* Unique ID */
-#define BTA_OP_FILTER_KEY (1<<22) /* Public Encryption Key */
-#define BTA_OP_FILTER_NICKNAME (1<<23) /* Nickname */
-#define BTA_OP_FILTER_CATEGORIES (1<<24) /* Categories */
-#define BTA_OP_FILTER_PROID (1<<25) /* Product ID */
-#define BTA_OP_FILTER_CLASS (1<<26) /* Class Information */
-#define BTA_OP_FILTER_SORT_STRING (1<<27) /* String used for sorting operations */
-#define BTA_OP_FILTER_TIME_STAMP (1<<28) /* Time Stamp */
-#define BTA_OP_FILTER_ALL (0)
-
-/* This structure describes an object property, or individual item, inside an object. */
-typedef struct
-{
- UINT8 *p_data; /* Pointer to property data. */
- UINT32 parameters; /* Property parameters. */
- UINT16 name; /* Property name. */
- UINT16 len; /* Length of data. */
- UINT8 *p_param; /* Pointer to the Parameters */
- UINT16 param_len; /* Param Len */
-} tBTA_OP_PROP;
-
-
-/* Access response types */
-#define BTA_OP_ACCESS_ALLOW 0 /* Allow the requested operation */
-#define BTA_OP_ACCESS_FORBID 1 /* Disallow the requested operation */
-#define BTA_OP_ACCESS_NONSUP 2 /* Requested operation is not supported */
-
-typedef UINT8 tBTA_OP_ACCESS;
-
-/* Access event operation types */
-#define BTA_OP_OPER_PUSH 1
-#define BTA_OP_OPER_PULL 2
-
-typedef UINT8 tBTA_OP_OPER;
-
-
-/* Client callback function event */
-#define BTA_OPC_ENABLE_EVT 0 /* Object push client is enabled. */
-#define BTA_OPC_OPEN_EVT 1 /* Connection to peer is open. */
-#define BTA_OPC_PROGRESS_EVT 2 /* push/pull in progres */
-#define BTA_OPC_OBJECT_EVT 3 /* Object Pulled */
-#define BTA_OPC_OBJECT_PSHD_EVT 4 /* Object pushed */
-#define BTA_OPC_CLOSE_EVT 5 /* Connection to peer closed. */
-
-typedef UINT8 tBTA_OPC_EVT;
-
-/* Client callback function result */
-#define BTA_OPC_OK 0 /* Object push succeeded. */
-#define BTA_OPC_FAIL 1 /* Object push failed. */
-#define BTA_OPC_NOT_FOUND 2 /* Object not found. */
-#define BTA_OPC_NO_PERMISSION 3 /* Operation not authorized. */
-#define BTA_OPC_SRV_UNAVAIL 4 /* Service unavaliable */
-#define BTA_OPC_ON_BT 5 /* only used for BTA_OPC_MOVE_CH_EVT */
-#define BTA_OPC_RSP_FORBIDDEN 6 /* Operation forbidden */
-#define BTA_OPC_RSP_NOT_ACCEPTABLE 7 /* Operation not acceptable */
-
-typedef UINT8 tBTA_OPC_STATUS;
-
-/* Structure associated with BTA_OPC_OBJECT_EVT */
-typedef struct
-{
- char *p_name; /* Object name. */
- tBTA_OPC_STATUS status;
-} tBTA_OPC_OBJECT;
-
-typedef struct
-{
- UINT32 obj_size; /* Total size of object (BTA_FS_LEN_UNKNOWN if unknown) */
- UINT16 bytes; /* Number of bytes read or written since last progress event */
- tBTA_OP_OPER operation; /* Is progress for Push or Pull */
-} tBTA_OPC_PROGRESS;
-
-/* Union of all client callback structures */
-typedef union
-{
- tBTA_OPC_OBJECT object;
- tBTA_OPC_PROGRESS prog;
- tBTA_OPC_STATUS status;
-} tBTA_OPC;
-
-/* Client callback function */
-typedef void (tBTA_OPC_CBACK)(tBTA_OPC_EVT event, tBTA_OPC *p_data);
-
-/* Server callback function event */
-#define BTA_OPS_ENABLE_EVT 0 /* Object push server is enabled. */
-#define BTA_OPS_OPEN_EVT 1 /* Connection to peer is open. */
-#define BTA_OPS_PROGRESS_EVT 2 /* Object being sent or received. */
-#define BTA_OPS_OBJECT_EVT 3 /* Object has been received. */
-#define BTA_OPS_CLOSE_EVT 4 /* Connection to peer closed. */
-#define BTA_OPS_ACCESS_EVT 5 /* Request for access to push or pull object */
-
-typedef UINT8 tBTA_OPS_EVT;
-
-typedef UINT8 tBTA_OPS_STATUS;
-
-/* Structure associated with BTA_OPS_OBJECT_EVT */
-typedef struct
-{
- char *p_name; /* Object name. */
- tBTA_OP_FMT format; /* Object format. */
-} tBTA_OPS_OBJECT;
-
-typedef struct
-{
- UINT32 obj_size; /* Total size of object (BTA_FS_LEN_UNKNOWN if unknown) */
- UINT16 bytes; /* Number of bytes read or written since last progress event */
- tBTA_OP_OPER operation; /* Is progress for Push or Pull */
-} tBTA_OPS_PROGRESS;
-
-typedef struct
-{
- char *p_name; /* Object name */
- char *p_type; /* Object type (NULL if not specified) */
- UINT32 size; /* Object size */
- tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
- BD_ADDR bd_addr; /* Address of device */
- tBTA_OP_OPER oper; /* Operation (push or pull) */
- tBTA_OP_FMT format; /* Object format */
-} tBTA_OPS_ACCESS;
-
-/* Union of all server callback structures */
-typedef union
-{
- tBTA_OPS_STATUS status;
- tBTA_OPS_OBJECT object;
- tBTA_OPS_PROGRESS prog;
- tBTA_OPS_ACCESS access;
- BD_ADDR bd_addr;
-} tBTA_OPS;
-
-/* Server callback function */
-typedef void (tBTA_OPS_CBACK)(tBTA_OPS_EVT event, tBTA_OPS *p_data);
-
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*******************************************************************************
-**
-** Function BTA_OpcEnable
-**
-** Description Enable the object push client. This function must be
-** called before any other functions in the OP API are called.
-** When the enable operation is complete the callback function
-** will be called with a BTA_OPC_ENABLE_EVT.
-**
-** If single_op is FALSE, the connection stays open after
-** the operation finishes (until BTA_OpcClose is called).
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_OpcEnable(tBTA_SEC sec_mask, tBTA_OPC_CBACK *p_cback,
- BOOLEAN single_op, BOOLEAN srm, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function BTA_OpcDisable
-**
-** Description Disable the object push client. If the client is currently
-** connected to a peer device the connection will be closed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_OpcDisable(void);
-
-/*******************************************************************************
-**
-** Function BTA_OpcPush
-**
-** Description Push an object to a peer device. p_name must point to
-** a fully qualified path and file name.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_OpcPush(BD_ADDR bd_addr, tBTA_OP_FMT format, char *p_name);
-
-/*******************************************************************************
-**
-** Function BTA_OpcPullCard
-**
-** Description Pull default card from peer. p_path must point to a fully
-** qualified path specifying where to store the pulled card.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_OpcPullCard(BD_ADDR bd_addr, char *p_path);
-
-
-/*******************************************************************************
-**
-** Function BTA_OpcExchCard
-**
-** Description Exchange business cards with a peer device. p_send points to
-** a fully qualified path and file name of vcard to push.
-** p_recv_path points to a fully qualified path specifying
-** where to store the pulled card.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_OpcExchCard(BD_ADDR bd_addr, char *p_send,
- char *p_recv_path);
-
-
-/*******************************************************************************
-**
-** Function BTA_OpcClose
-**
-** Description Close the current connection. This function is called if
-** the phone wishes to close the connection before the object
-** push is completed. In a typical connection this function
-** does not need to be called; the connection will be closed
-** automatically when the object push is complete.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_OpcClose(void);
-
-/*******************************************************************************
-**
-** Function BTA_OpsEnable
-**
-** Description Enable the object push server. This function must be
-** called before any other functions in the OPS API are called.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_OpsEnable(tBTA_SEC sec_mask, tBTA_OP_FMT_MASK formats,
- char *p_service_name, tBTA_OPS_CBACK *p_cback,
- BOOLEAN srm, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function BTA_OpsDisable
-**
-** Description Disable the object push server. If the server is currently
-** connected to a peer device the connection will be closed.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_OpsDisable(void);
-
-/*******************************************************************************
-**
-** Function BTA_OpsClose
-**
-** Description Close the current connection. This function is called if
-** the phone wishes to close the connection before the object
-** push is completed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_OpsClose(void);
-
-/*******************************************************************************
-**
-** Function BTA_OpsAccessRsp
-**
-** Description Sends a reply to an access request event (BTA_OPS_ACCESS_EVT).
-** This call MUST be made whenever the event occurs.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_OpsAccessRsp(tBTA_OP_OPER oper, tBTA_OP_ACCESS access,
- char *p_name);
-
-/*******************************************************************************
-**
-** Function BTA_OpBuildCard
-**
-** Description Build a vCard object. The input to this function is
-** requested format(2.1/3.0), an array of vCard properties
-** and a pointer to memory to store the card.
-** The output is a formatted vCard.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete build.
-**
-*******************************************************************************/
-BTA_API extern tBTA_OP_STATUS BTA_OpBuildCard(UINT8 *p_card, UINT16 *p_len,
- tBTA_OP_FMT fmt,
- tBTA_OP_PROP *p_prop,
- UINT8 num_prop);
-
-/*******************************************************************************
-**
-** Function BTA_OpBuildNote
-**
-** Description Build a vNote object. The input to this function is an
-** array of vNote properties and a pointer to memory to store
-** the card. The output is a formatted vNote.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete build.
-**
-*******************************************************************************/
-BTA_API extern tBTA_OP_STATUS BTA_OpBuildNote(UINT8 *p_note, UINT16 *p_len,
- tBTA_OP_PROP *p_prop,
- UINT8 num_prop);
-
-/*******************************************************************************
-**
-** Function BTA_OpBuildCal
-**
-** Description Build a vCal 1.0 object. The input to this function is an
-** array of vCaalproperties and a pointer to memory to store
-** the card. The output is a formatted vCal.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete build.
-**
-*******************************************************************************/
-BTA_API extern tBTA_OP_STATUS BTA_OpBuildCal(UINT8 *p_cal, UINT16 *p_len,
- tBTA_OP_PROP *p_prop,
- UINT8 num_prop,
- tBTA_OP_VCAL vcal_type);
-
-/*******************************************************************************
-**
-** Function BTA_OpParseCard
-**
-** Description Parse a vCard 2.1 object. The input to this function is
-** a pointer to vCard data. The output is an array of parsed
-** vCard properties.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete parsing.
-**
-*******************************************************************************/
-BTA_API extern tBTA_OP_STATUS BTA_OpParseCard(tBTA_OP_PROP *p_prop,
- UINT8 *p_num_prop, UINT8 *p_card,
- UINT16 len);
-
-/*******************************************************************************
-**
-** Function BTA_OpGetCardProperty
-**
-** Description Get Card property value by name. The input to this function is
-** property name. The output is property value and len
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-**
-*******************************************************************************/
-BTA_API extern tBTA_OP_STATUS BTA_OpGetCardProperty(UINT8 *p_value, UINT16 *p_len, tBTA_OP_PROP *p_prop,
- UINT8 num_prop, UINT8 *p_name);
-
-/*******************************************************************************
-**
-** Function BTA_OpParseNote
-**
-** Description Parse a vNote object. The input to this function is a
-** pointer to vNote data. The output is an array of parsed
-** vNote properties.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete parsing.
-**
-*******************************************************************************/
-BTA_API extern tBTA_OP_STATUS BTA_OpParseNote(tBTA_OP_PROP *p_prop,
- UINT8 *p_num_prop,
- UINT8 *p_note, UINT16 len);
-
-/*******************************************************************************
-**
-** Function BTA_OpParseCal
-**
-** Description Parse a vCal object. The input to this function is a
-** pointer to vCal data. The output is an array of parsed
-** vCal properties.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete parsing.
-**
-*******************************************************************************/
-BTA_API extern tBTA_OP_STATUS BTA_OpParseCal(tBTA_OP_PROP *p_prop,
- UINT8 *p_num_prop, UINT8 *p_cal,
- UINT16 len, tBTA_OP_VCAL *p_vcal_type);
-
-/*******************************************************************************
-**
-** Function BTA_OpSetCardPropFilterMask
-**
-** Description Set Property Filter Mask
-**
-**
-** Returns
-**
-*******************************************************************************/
-BTA_API extern void BTA_OpSetCardPropFilterMask(UINT32 mask);
-
-#ifdef __cplusplus
-}
-#endif
-
#endif /* BTA_OP_API_H */
diff --git a/bta/include/bta_pbs_api.h b/bta/include/bta_pbs_api.h
index 41198ff..7d887ed 100644
--- a/bta/include/bta_pbs_api.h
+++ b/bta/include/bta_pbs_api.h
@@ -33,266 +33,4 @@
#define BTA_PBS_REPOSIT_LOCAL 0x01 /* Local PhoneBook */
#define BTA_PBS_REPOSIT_SIM 0x02 /* SIM card PhoneBook */
-enum
-{
- BTA_PBS_VCF_FMT_21 = 0, /* vcard format 2.1 */
- BTA_PBS_VCF_FMT_30 /* vcard format 3.0 */
-};
-typedef UINT8 tBTA_PBS_VCF_FMT;
-
-enum
-{
- BTA_PBS_ORDER_INDEX = 0, /* Default. vCard handle */
- BTA_PBS_ORDER_ALPHA_NUM, /* UTF8 name attribute, LastName then FirstName then MiddleName */
- BTA_PBS_ORDER_PHONETIC /* UTF8 representation of the sound attribute */
-};
-typedef UINT8 tBTA_PBS_ORDER;
-
-enum
-{
- BTA_PBS_ATTR_NAME = 0, /* name */
- BTA_PBS_ATTR_NUMBER, /* number */
- BTA_PBS_ATTR_SOUND, /* sound */
- BTA_PBS_ATTR_MAX
-};
-typedef UINT8 tBTA_PBS_ATTR;
-
-#define BTA_PBS_FILTER_VERSION (1<<0) /* vCard Version */
-#define BTA_PBS_FILTER_FN (1<<1) /* Formatted Name */
-#define BTA_PBS_FILTER_N (1<<2) /* Structured Presentation of Name */
-#define BTA_PBS_FILTER_PHOTO (1<<3) /* Associated Image or Photo */
-#define BTA_PBS_FILTER_BDAY (1<<4) /* Birthday */
-#define BTA_PBS_FILTER_ADR (1<<5) /* Delivery Address */
-#define BTA_PBS_FILTER_LABEL (1<<6) /* Delivery */
-#define BTA_PBS_FILTER_TEL (1<<7) /* Telephone Number */
-#define BTA_PBS_FILTER_EMAIL (1<<8) /* Electronic Mail Address */
-#define BTA_PBS_FILTER_MAILER (1<<9) /* Electronic Mail */
-#define BTA_PBS_FILTER_TZ (1<<10) /* Time Zone */
-#define BTA_PBS_FILTER_GEO (1<<11) /* Geographic Position */
-#define BTA_PBS_FILTER_TITLE (1<<12) /* Job */
-#define BTA_PBS_FILTER_ROLE (1<<13) /* Role within the Organization */
-#define BTA_PBS_FILTER_LOGO (1<<14) /* Organization Logo */
-#define BTA_PBS_FILTER_AGENT (1<<15) /* vCard of Person Representing */
-#define BTA_PBS_FILTER_ORG (1<<16) /* Name of Organization */
-#define BTA_PBS_FILTER_NOTE (1<<17) /* Comments */
-#define BTA_PBS_FILTER_REV (1<<18) /* Revision */
-#define BTA_PBS_FILTER_SOUND (1<<19) /* Pronunciation of Name */
-#define BTA_PBS_FILTER_URL (1<<20) /* Uniform Resource Locator */
-#define BTA_PBS_FILTER_UID (1<<21) /* Unique ID */
-#define BTA_PBS_FILTER_KEY (1<<22) /* Public Encryption Key */
-#define BTA_PBS_FILTER_NICKNAME (1<<23) /* Nickname */
-#define BTA_PBS_FILTER_CATEGORIES (1<<24) /* Categories */
-#define BTA_PBS_FILTER_PROID (1<<25) /* Product ID */
-#define BTA_PBS_FILTER_CLASS (1<<26) /* Class Information */
-#define BTA_PBS_FILTER_SORT_STRING (1<<27) /* String used for sorting operations */
-#define BTA_PBS_FILTER_TIME_STAMP (1<<28) /* Time Stamp */
-#define BTA_PBS_FILTER_PROPRIETARY (1<<39) /* Indicates the usage of a proprietary filter */
-#define BTA_PBS_FILTER_ALL (0)
-
-typedef UINT32 tBTA_PBS_FILTER_MASK;
-
-/* Access response types */
-enum
-{
- BTA_PBS_ACCESS_TYPE_ALLOW = 0, /* Allow the requested operation */
- BTA_PBS_ACCESS_TYPE_FORBID, /* Disallow the requested operation */
- BTA_PBS_ACCESS_TYPE_PRECONDITION /* Get vCard Entry operation only (object handle invalid) */
-};
-
-typedef UINT8 tBTA_PBS_ACCESS_TYPE;
-
-#define BTA_PBS_MAX_FILE_LEN 64
-#define BTA_PBS_MAX_CONTACT_NAME_LEN 128
-
-/* Obex application params passed to open callout */
-typedef struct
-{
- tBTA_PBS_FILTER_MASK filter;
- tBTA_PBS_VCF_FMT format;
- UINT16 max_count;
- UINT16 start_offset;
-} tBTA_PBS_PULLPB_APP_PARAMS;
-
-/* Obex application params passed to getvlist callout */
-typedef struct
-{
- tBTA_PBS_ORDER order;
- tBTA_PBS_ATTR attribute;
- UINT8 p_value[64];
- UINT16 value_len;
- UINT16 max_count;
- UINT16 start_offset;
-} tBTA_PBS_VCARDLIST_APP_PARAMS;
-
-/* VCard Listing structuture Returned by application*/
-typedef struct
-{
- char handle[BTA_PBS_MAX_FILE_LEN]; /* Contains the vcf name */
- char name[BTA_PBS_MAX_CONTACT_NAME_LEN]; /* Contains the contacted name of the vlist */
-} tBTA_PBS_VCARDLIST;
-
-/* Access event operation types */
-#define BTA_PBS_OPER_NONE 0
-#define BTA_PBS_OPER_PULL_PB 1
-#define BTA_PBS_OPER_SET_PB 2
-#define BTA_PBS_OPER_PULL_VCARD_LIST 3
-#define BTA_PBS_OPER_PULL_VCARD_ENTRY 4
-
-typedef UINT8 tBTA_PBS_OPER;
-
-/* Object type */
-#define BTA_PBS_NONE_OBJ 0
-#define BTA_PBS_PB_OBJ 1
-#define BTA_PBS_ICH_OBJ 2
-#define BTA_PBS_OCH_OBJ 3
-#define BTA_PBS_MCH_OBJ 4
-#define BTA_PBS_CCH_OBJ 5
-
-typedef UINT8 tBTA_PBS_OBJ_TYPE;
-
-
-/**************************
-** Server Definitions
-***************************/
-/* Extra Debug Code */
-#ifndef BTA_PBS_DEBUG
-#define BTA_PBS_DEBUG FALSE
-#endif
-
-#define BTA_PBS_OK 0
-#define BTA_PBS_FAIL 1
-typedef UINT8 tBTA_PBS_STATUS;
-
-/* Server callback function events */
-#define BTA_PBS_ENABLE_EVT 0 /* PB transfer server is enabled. */
-#define BTA_PBS_OPEN_EVT 1 /* Connection to peer is open. */
-#define BTA_PBS_CLOSE_EVT 2 /* Connection to peer closed. */
-#define BTA_PBS_AUTH_EVT 3 /* Request for Authentication key and realm */
-#define BTA_PBS_ACCESS_EVT 4 /* Request for access to put a file */
-#define BTA_PBS_OPER_CMPL_EVT 5 /* PB operation complete */
-
-typedef UINT8 tBTA_PBS_EVT;
-
-/* Structure associated with BTA_PBS_OPER_CMPL_EVT */
-typedef struct
-{
- char *p_name; /* file or folder name. */
- tBTA_PBS_OPER operation;
- tBTA_PBS_STATUS status;
-} tBTA_PBS_OBJECT;
-
-typedef struct
-{
- UINT8 *p_userid;
- UINT8 userid_len;
- BOOLEAN userid_required; /* TRUE if user ID is required in response (rechallanged) */
-} tBTA_PBS_AUTH;
-
-typedef struct
-{
- char *p_name; /* file or directory name with fully qualified path */
- tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
- tBTA_PBS_OPER oper; /* operation */
- BD_ADDR bd_addr; /* Address of device */
-} tBTA_PBS_ACCESS;
-
-typedef struct
-{
- tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
- BD_ADDR bd_addr; /* Address of device */
-} tBTA_PBS_OPEN;
-
-typedef union
-{
- tBTA_PBS_AUTH auth;
- tBTA_PBS_ACCESS access;
- tBTA_PBS_OBJECT obj;
- tBTA_PBS_OPEN open;
-} tBTA_PBS;
-
-/* Server callback function */
-typedef void tBTA_PBS_CBACK(tBTA_PBS_EVT event, tBTA_PBS *p_data);
-
-/**************************
-** Server Functions
-***************************/
-
-/*******************************************************************************
-**
-** Function BTA_PbsEnable
-**
-** Description Enable the phone book access server. This function must be
-** called before any other functions in the PB Server API are called.
-** When the enable operation is complete the callback function
-** will be called with an BTA_PBS_ENABLE_EVT event.
-** Note: Pbs always enable (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_PbsEnable(tBTA_SEC sec_mask, const char *p_service_name,
- const char *p_root_path, BOOLEAN enable_authen,
- UINT8 realm_len, UINT8 *p_realm,
- tBTA_PBS_CBACK *p_cback, UINT8 app_id);
-
-/*******************************************************************************
-**
-** Function BTA_PbsDisable
-**
-** Description Disable the Phone book access server. If the server is currently
-** connected to a peer device the connection will be closed.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_PbsDisable(void);
-
-/*******************************************************************************
-**
-** Function BTA_PbsAuthRsp
-**
-** Description Respond to obex client authenticate repond by sending back password to
-** BTA. Called in response to an BTA_PBS_AUTH_EVT event.
-** Used when "enable_authen" is set to TRUE in BTA_PbapsEnable().
-**
-** Note: If the "userid_required" is TRUE in the BTA_PBS_AUTH_EVT
-** event, then p_userid is required, otherwise it is optional.
-**
-** p_password must be less than BTA_PBS_MAX_AUTH_KEY_SIZE (16 bytes)
-** p_userid must be less than OBX_MAX_REALM_LEN (defined in target.h)
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_PbsAuthRsp (char *p_password, char *p_userid);
-
-/*******************************************************************************
-**
-** Function BTA_PbsAccessRsp
-**
-** Description Sends a reply to an access request event (BTA_PBS_ACCESS_EVT).
-** This call MUST be made whenever the event occurs.
-**
-** Parameters oper - operation being accessed.
-** access - BTA_PBS_ACCESS_ALLOW or BTA_PBS_ACCESS_FORBID
-** p_name - path of file or directory to be accessed.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_PbsAccessRsp(tBTA_PBS_OPER oper, tBTA_PBS_ACCESS_TYPE access,
- char *p_name);
-
-/*******************************************************************************
-**
-** Function BTA_PbsClose
-**
-** Description Close the current connection.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_PbsClose(void);
#endif
diff --git a/bta/include/bta_pbs_ci.h b/bta/include/bta_pbs_ci.h
deleted file mode 100644
index e44f960..0000000
--- a/bta/include/bta_pbs_ci.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_pbs_ci.h
-**
-** Description: This is the interface file for phone book access server
-** call-in functions.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_PBS_CI_H
-#define BTA_PBS_CI_H
-
-#include "bta_pbs_co.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-
-/*****************************************************************************
-** Function Declarations
-*****************************************************************************/
-
-
-/*******************************************************************************
-**
-** Function bta_pbs_ci_read
-**
-** Description This function sends an event to BTA indicating the phone has
-** read in the requested amount of data specified in the
-** bta_pbs_co_read() call-out function.
-**
-** Parameters fd - file descriptor passed to the stack in the
-** bta_pbs_ci_open call-in function.
-** num_bytes_read - number of bytes read into the buffer
-** specified in the read callout-function.
-** status - BTA_PBS_CO_OK if get buffer of data,
-** BTA_PBS_CO_FAIL if an error has occurred.
-** final - indicate whether it is the final data
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_pbs_ci_read(int fd, UINT16 num_bytes_read,
- tBTA_PBS_CO_STATUS status, BOOLEAN final);
-
-/*******************************************************************************
-**
-** Function bta_pbs_ci_open
-**
-** Description This function sends an event to BTA indicating the phone has
-** finished opening a pb for reading.
-**
-** Parameters fd - file descriptor passed to the stack in the
-** bta_pbs_ci_open call-in function.
-** status - BTA_PBS_CO_OK if file was opened in mode specified
-** in the call-out function.
-** BTA_PBS_CO_EACCES if the file exists, but contains
-** the wrong access permissions.
-** BTA_PBS_CO_FAIL if any other error has occurred.
-** file_size - The total size of the file
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_pbs_ci_open(int fd, tBTA_PBS_CO_STATUS status,
- UINT32 file_size);
-
-/*******************************************************************************
-**
-** Function bta_pbs_ci_getvlist
-**
-** Description This function sends an event to BTA indicating the phone has
-** finished reading a VCard list entry.
-**
-** Parameters
-** status - BTA_PBS_CO_OK if reading Vcard list entry
-** BTA_PBS_CO_FAIL if any other error has occurred.
-** final - whether it is the last entry
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_pbs_ci_getvlist(tBTA_PBS_CO_STATUS status, BOOLEAN final);
-
-
-#endif
-
diff --git a/bta/include/bta_pbs_co.h b/bta/include/bta_pbs_co.h
deleted file mode 100644
index 76ec75a..0000000
--- a/bta/include/bta_pbs_co.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_pbs_co.h
-**
-** Description: This is the interface file for the phone book access server
-** call-out functions.
-**
-** Copyright (c) 2003-2004, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_PBS_CO_H
-#define BTA_PBS_CO_H
-
-#include "bta_api.h"
-#include "goep_fs.h"
-#include "bta_pbs_api.h"
-
-
-/*****************************************************************************
-** Constants and Data Types
-*****************************************************************************/
-/**************************
-** Common Definitions
-***************************/
-
-/* Status codes returned by call-out functions, or in call-in functions as status */
-#define BTA_PBS_CO_OK GOEP_OK
-#define BTA_PBS_CO_FAIL GOEP_FAIL /* Used to pass all other errors */
-#define BTA_PBS_CO_EACCES GOEP_EACCES
-#define BTA_PBS_CO_EOF GOEP_EOF
-#define BTA_PBS_CO_EODIR GOEP_EODIR
-
-typedef UINT16 tBTA_PBS_CO_STATUS;
-
-#define BTA_PBS_LEN_UNKNOWN GOEP_LEN_UNKNOWN
-#define BTA_PBS_INVALID_FD GOEP_INVALID_FD
-#define BTA_PBS_INVALID_APP_ID (0xFF) /* this app_id is reserved */
-
-
-/*****************************************************************************
-** Function Declarations
-*****************************************************************************/
-/**************************
-** Common Functions
-***************************/
-/*******************************************************************************
-**
-** Function bta_pbs_co_open
-**
-** Description This function is executed by BTA when a pb file is requested to be opened.
-** The phone book access profile server uses this function to open
-** a file for reading on two phone book access operations
-** (pull pb or pull pb entry)
-**
-** Parameters p_path - path and file name.
-** operation - BTA_PB_OPER_PULL_PB or BTA_PB_OPER_PULL_VCARD_ENTRY
-** p_app_params - obex application params
-**
-**
-** Returns void
-**
-** Note: Upon completion of the request
-** if successful, and an error code (tBTA_PBS_CO_STATUS)
-** are returned in the call-in function, bta_pbs_ci_open().
-**
-*******************************************************************************/
-BTA_API extern void bta_pbs_co_open(const char *p_path, tBTA_PBS_OPER operation, tBTA_PBS_PULLPB_APP_PARAMS *p_app_params);
-
-/*******************************************************************************
-**
-** Function bta_pbs_co_close
-**
-** Description This function is called by BTA when a connection to a
-** client is closed.
-**
-** Parameters fd - file descriptor of file to close.
-**
-**
-** Returns (tBTA_PBS_CO_STATUS) status of the call.
-** [BTA_PBS_CO_OK if successful],
-** [BTA_PBS_CO_FAIL if failed ]
-**
-*******************************************************************************/
-BTA_API extern tBTA_PBS_CO_STATUS bta_pbs_co_close(int fd);
-
-/*******************************************************************************
-**
-** Function bta_pbs_co_get_pbinfo
-**
-** Description This function is called by BTA to inquire about pb size and new missed calls.
-**
-** Parameters p_name: which type of phone book object Eg. telecom/pb.vcf, telecom/ich.vcf
-** operation: phone book operation type Eg. BTA_PBS_OPER_PULL_PB
-** obj_type: phone book repository type Eg. BTA_PBS_MCH_OBJ
-**
-** Returns pb_size - phone book size
-** new_missed_call - new missed calls
-* (tBTA_PBS_CO_STATUS) status of the call.
-** [BTA_PBS_CO_OK if successful],
-** [BTA_PBS_CO_FAIL if failed ]
-**
-*******************************************************************************/
-BTA_API extern tBTA_PBS_CO_STATUS bta_pbs_co_getpbinfo(tBTA_PBS_OPER operation, tBTA_PBS_OBJ_TYPE obj_type, UINT16 *pb_size, UINT16 *new_missed_call);
-
-/*******************************************************************************
-**
-** Function bta_pbs_co_read
-**
-** Description This function is called by BTA to read in data from the
-** previously opened pb file on the phone.
-** the application callin should fill in the PB object needed to be
-** send to the client
-**
-** Parameters fd - file descriptor of file to read from.
-** operation - BTA_PBS_OPER_PULL_PB or BTA_PBS_OPER_PULL_VCARD_ENTRY
-** p_buf - buffer to read the data into.
-** nbytes - number of bytes to read into the buffer.
-**
-**
-** Returns void
-**
-** Note: Upon completion of the request, bta_pbs_ci_read() is
-** called with the buffer of data, along with the number
-** of bytes read into the buffer, and a status.
-**
-*******************************************************************************/
-BTA_API extern void bta_pbs_co_read(int fd, tBTA_PBS_OPER operation, UINT8 *p_buf, UINT16 nbytes);
-
-
-/*******************************************************************************
-**
-** Function bta_pbs_co_getvlist
-**
-** Description This function is called to retrieve a vcard list entry for the
-** specified path.
-** The first/next directory should be filled by application
-** into the location specified by p_entry.
-**
-** Parameters p_path - directory to search
-** p_app_params - Obex application params, NULL if first_item is FALSE
-** first_item - TRUE if first get, FALSE if next getvlist
-** (p_entry contains previous)
-** p_entry(input/output) - Points to prev entry data, the callout application need
-** to fill in with the next entry
-**
-**
-** Returns void
-**
-** Note: Upon completion of the request, bta_pbs_ci_getvlist() is
-** called with the a status and final flag.
-**
-**
-**
-*******************************************************************************/
-BTA_API extern void bta_pbs_co_getvlist(const char *p_path, tBTA_PBS_VCARDLIST_APP_PARAMS *p_app_params,
- BOOLEAN first_item, tBTA_PBS_VCARDLIST *p_entry);
-
-
-#endif /* BTA_PBS_CO_H */
diff --git a/bta/include/bta_prm_api.h b/bta/include/bta_prm_api.h
deleted file mode 100644
index 434888f..0000000
--- a/bta/include/bta_prm_api.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_prm_api.h
-**
-** Description: This is the public interface file for the patch ram
-** subsystem of BTA, Widcomm's
-** Bluetooth application layer for mobile phones.
-**
-** Copyright (c) 2003-2005, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_PRM_API_H
-#define BTA_PRM_API_H
-
-#include "bta_api.h"
-#include "bta_sys.h"
-
-/* callback function */
-typedef void (tBTA_PRM_CBACK) (tBTA_STATUS status);
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*******************************************************************************
-**
-** Function BTA_PatchRam
-**
-** Description Patch Ram function
-**
-** Parameters p_cback - callback to indicate status of download operation.
-** p_name - path and file name of the patch file.
-** - if p_name is NULL, try to use patch data built into code.
-** fs_app_id - app_id used by bta file system callout functions
-** - to distinguish between applications which uses FS.
-** address - address of patch ram
-**
-**
-** Returns void
-**
-**
-*******************************************************************************/
-BTA_API extern void BTA_PatchRam(tBTA_PRM_CBACK *p_cback, const char *p_name,
- UINT8 fs_app_id, UINT32 address);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
diff --git a/bta/include/bta_sc_api.h b/bta/include/bta_sc_api.h
deleted file mode 100644
index 90e673f..0000000
--- a/bta/include/bta_sc_api.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_sc_api.c
-**
-** Description: This is the implementation of the API for the SIM
-** Card (SC) server subsystem of BTA, Widcomm's Bluetooth
-** application layer for mobile phones.
-**
-** Copyright (c) 2004, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_SC_API_H
-#define BTA_SC_API_H
-
-#include "bta_api.h"
-#include "sap_api.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-/* Status of SIM card (for BTA_ScCardStatus) */
-#define BTA_SC_CARD_UNKNOWN_ERROR SAP_CARD_UNKNOWN_ERROR /* Unknown problem with SIM card. */
-#define BTA_SC_CARD_RESET SAP_CARD_RESET /* SIM inserted and powered on prior to SIM Access Profile connection. */
-#define BTA_SC_CARD_NOT_ACCESSIBLE SAP_CARD_NOT_ACCESSIBLE /* SIM inserted, but not accessible. */
-#define BTA_SC_CARD_REMOVED SAP_CARD_REMOVED /* SIM not inserted, or has been removed. */
-#define BTA_SC_CARD_INSERTED SAP_CARD_INSERTED /* SIM inserted, but not powered on. Client needs to power on the SIM before using it. */
-#define BTA_SC_CARD_RECOVERED SAP_CARD_RECOVERED /* Previously not accessible card has been made accessible again, and is powered on by server. */
-typedef UINT8 tBTA_SC_CARD_STATUS;
-
-/* Flags describing Card Reader options (for reader_flags parameter of BTA_ScEnable) */
-#define BTA_SC_READER_FL_REMOVABLE 0x0001
-typedef UINT16 tBTA_SC_READER_FLAGS;
-
-/* Status of card reader (for BTA_ScReaderStatus) */
-#define BTA_SC_READER_STATUS_ATTACHED 0
-#define BTA_SC_READER_STATUS_REMOVED 1
-typedef UINT8 tBTA_SC_READER_STATUS;
-
-
-/* Disconnection type (for BTA_Disconnect) */
-#define BTA_SC_DISC_GRACEFUL SAP_DISCONNECT_GRACEFUL
-#define BTA_SC_DISC_IMMEDIATE SAP_DISCONNECT_IMMEDIATE
-typedef UINT8 tBTA_SC_DISCONNECT_TYPE;
-
-/* Server callback function events */
-#define BTA_SC_ENABLE_EVT 0 /* SIM Access server is enabled. */
-#define BTA_SC_OPEN_EVT 1 /* Connection to peer is open. */
-#define BTA_SC_CLOSE_EVT 2 /* Connection to peer closed. */
-// btla-specific ++
-#define BTA_SC_DISABLE_EVT 3 /* SIM Access server is disabled. */
-// btla-specific --
-typedef UINT8 tBTA_SC_EVT;
-
-
-/* Results codes for use with call-in functions */
-#define BTA_SC_RESULT_OK SAP_RESULT_OK /* Request processed correctly. */
-#define BTA_SC_RESULT_ERROR SAP_RESULT_ERROR /* Error - no reason specified. */
-#define BTA_SC_RESULT_CARD_NOT_ACCESSIBLE SAP_RESULT_CARD_NOT_ACCESSIBLE /* Error - card inserted but not accessible. */
-#define BTA_SC_RESULT_CARD_POWERED_OFF SAP_RESULT_CARD_POWERED_OFF /* Error - card is powered off. */
-#define BTA_SC_RESULT_CARD_REMOVED SAP_RESULT_CARD_REMOVED /* Error - card is not inserted. */
-#define BTA_SC_RESULT_CARD_ALREADY_ON SAP_RESULT_CARD_ALREADY_ON /* Error - card already turned on. */
-#define BTA_SC_RESULT_DATA_NOT_AVAILABLE SAP_RESULT_DATA_NOT_AVAILABLE /* Error - data not available. */
-/* Request codes for use with call-in functions */
-#define BTA_SC_REQUEST_APDU (BTA_SC_RESULT_OK + 10)
-typedef UINT8 tBTA_SC_RESULT;
-
-
-/* Results codes for sim reset */
-#define BTA_SC_RESET_RESULT_OK 0 /* Reset successful */
-#define BTA_SC_RESET_RESULT_ERROR 1 /* Reset failed */
-#define BTA_SC_RESET_RESULT_OK_ONGOING_CALL 2 /* Ongoing call (will reset after call is released) */
-typedef UINT8 tBTA_SC_RESET_RESULT;
-
-/**************************
-** Structure definitions
-***************************/
-/* Event data for BTA_SC_OPEN_EVT */
-typedef struct
-{
- BD_ADDR bd_addr; /* Client bd address */
-} tBTA_SC_OPEN;
-
-
-/* Union of data types for BTA_SC callback function */
-typedef union
-{
- tBTA_SC_OPEN open;
-} tBTA_SC;
-
-/* Server callback function */
-typedef void tBTA_SC_CBACK (tBTA_SC_EVT event, tBTA_SC *p_data);
-
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-/*******************************************************************************
-**
-** Function BTA_ScEnable
-**
-** Description Enable the SIM Card server. This function must be
-** called before any other functions in the SC API are called.
-** When the enable operation is complete the callback function
-** will be called with a BTA_SC_ENABLE_EVT.
-**
-** Parameters
-** sec_mask Security options
-** p_service_name Service name for SDP record
-** reader_id SIM Card Reader ID (for TRANSFER_CARD_READER_STATUS requests)
-** reader_flags Flags describing card reader
-** msg_size_min Min message size for SIM APDU commands
-** msg_size_max Max message size for SIM APDU commands
-** p_cback Callback for BTA_SC event notification
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_ScEnable(tBTA_SEC sec_mask, const char *p_service_name,
- UINT8 reader_id, tBTA_SC_READER_FLAGS reader_flags,
- UINT16 msg_size_min, UINT16 msg_size_max,
- tBTA_SC_CBACK *p_cback);
-
-/*******************************************************************************
-**
-** Function BTA_ScDisable
-**
-** Description Disable the SIM Card server.
-**
-** Parameters none
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_ScDisable(void);
-
-/*******************************************************************************
-**
-** Function BTA_ScClose
-**
-** Description Close client connection.
-**
-** Parameters
-** type Type of disconnection desired (BTA_SC_DISC_GRACEFUL or
-** BTA_SC_DISC_IMMEDIATE)
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_ScClose(tBTA_SC_DISCONNECT_TYPE type);
-
-
-/*******************************************************************************
-**
-** Function BTA_ScCardStatus
-**
-** Description Notify client of change in SIM card status
-**
-** Parameters
-** status New status
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_ScCardStatus(tBTA_SC_CARD_STATUS status);
-
-
-/*******************************************************************************
-**
-** Function BTA_ScReaderStatus
-**
-** Description Notify client of change in SIM card reader status
-**
-** Parameters
-** status New status
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void BTA_ScReaderStatus(tBTA_SC_READER_STATUS status);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BTA_SC_API_H */
diff --git a/bta/include/bta_sc_ci.h b/bta/include/bta_sc_ci.h
deleted file mode 100644
index 10b11e6..0000000
--- a/bta/include/bta_sc_ci.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_sc_ci.h
-**
-** Description: This is the interface file for SIM Access server
-** call-in functions.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_SC_CI_H
-#define BTA_SC_CI_H
-
-#include "bta_sc_api.h"
-
-/*****************************************************************************
-** Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*******************************************************************************
-**
-** Function bta_sc_ci_apdu
-**
-** Description This function sends an event to SC to indicate the APDU request
-** has been completed or requested
-**
-** Parameters
-** result result of operation or request of operation
-** p_apdu response buffer for APDU command (if result=BTA_SC_RESULT_OK)
-** or request buffer for APDU command (if result=BTA_SC_REQUEST_APDU)
-** apdulen length of response or request buffer
-** is_apdu_7816 TRUE if format of apdu data is APDU7816
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_ci_apdu(tBTA_SC_RESULT result, UINT8 *p_apdu, UINT16 apdulen, BOOLEAN is_apdu_7816);
-
-/*******************************************************************************
-**
-** Function bta_sc_ci_atr
-**
-** Description This function sends an event to SC to indicate the ATR request
-** has been completed
-**
-** Parameters
-** result result of operation
-** p_atr response buffer for ATR request (if result=BTA_SC_RESULT_OK)
-** atrlen length of response buffer
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_ci_atr(tBTA_SC_RESULT result, UINT8 *p_atr, UINT16 atrlen);
-
-/*******************************************************************************
-**
-** Function bta_sc_ci_sim_on
-**
-** Description This function sends an event to SC to indicate the SIM_ON request
-** has been completed
-**
-** Parameters
-** result result of operation
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_ci_sim_on(tBTA_SC_RESULT result);
-
-/*******************************************************************************
-**
-** Function bta_sc_ci_sim_off
-**
-** Description This function sends an event to SC to indicate the SIM_OFF request
-** has been completed
-**
-** Parameters
-** result result of operation
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_ci_sim_off(tBTA_SC_RESULT result);
-
-/*******************************************************************************
-**
-** Function bta_sc_ci_sim_reset
-**
-** Description This function sends an event to SC to indicate the SIM_RESET request
-** has been completed
-**
-** Parameters
-** result result of operation
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_ci_sim_reset(tBTA_SC_RESET_RESULT result);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BTA_SC_CI_H */
-
diff --git a/bta/include/bta_sc_co.h b/bta/include/bta_sc_co.h
deleted file mode 100644
index a088823..0000000
--- a/bta/include/bta_sc_co.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_sc_co.h
-**
-** Description: This is the interface file for the SIM access
-** server call-out functions.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_SC_CO_H
-#define BTA_SC_CO_H
-
-#include "bta_sc_api.h"
-
-/*****************************************************************************
-** Constants and Data Types
-*****************************************************************************/
-
-/*****************************************************************************
-** Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*******************************************************************************
-**
-** Function bta_sc_co_sim_opem
-**
-** Description Called when client connection is opened, in case any special
-** handling or intialization of the SIM is required.
-**
-** Parameters
-** None.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_co_sim_open(void);
-
-/*******************************************************************************
-**
-** Function bta_sc_co_sim_close
-**
-** Description Called when client connection is closed.
-**
-** Parameters
-** None.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_co_sim_close(void);
-
-/*******************************************************************************
-**
-** Function bta_sc_co_sim_reset
-**
-** Description This function is called by BTA to reset the SIM card
-**
-** Once SIM has been turned reset, call bta_sc_ci_sim_reset().
-**
-** Parameters
-** None.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_co_sim_reset(void);
-
-/*******************************************************************************
-**
-** Function bta_sc_co_sim_off
-**
-** Description This function is called by BTA to turn the SIM card off
-**
-** Once SIM has been turned on, call bta_sc_ci_sim_on().
-**
-** Parameters
-** None.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_co_sim_off(void);
-
-/*******************************************************************************
-**
-** Function bta_sc_co_sim_on
-**
-** Description This function is called by BTA to turn the SIM card on
-**
-** Once SIM has been turned on, call bta_sc_ci_sim_on().
-**
-** Parameters
-** None.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_co_sim_on(void);
-
-/*******************************************************************************
-**
-** Function bta_sc_co_atr
-**
-** Description This function is called by BTA to retrieve ATR information
-** (operational requirements of the SIM, as described in
-** section 5.8 of GSM 11.11)
-**
-** Once the ATR information is retrieved, call bta_sc_ci_atr().
-**
-** Parameters
-** None.
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_co_atr(void);
-
-/*******************************************************************************
-**
-** Function bta_sc_co_apdu
-**
-** Description This function is called by BTA to to transfer APDU command
-** messages to the SIM. Generally used for selecting, storing
-** and retrieving data from the SIM.
-**
-** Once the command has been completed, call bta_sc_ci_apdu()
-** with the result.
-**
-** Parameters
-** p_apdu_req Pointer to the APDU message from the client. Format
-** is described in section 9 of GSM 11.11
-**
-** req_len Length of APDU message.
-**
-** rsp_maxlen Maximum length of response message allowed by client
-** (negotiated during CONNECT_REQ)
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_sc_co_apdu(UINT8 *p_apdu_req, UINT16 req_len, UINT16 rsp_maxlen, BOOLEAN is_apdu_7816);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BTA_SC_CO_H */
diff --git a/bta/ma/bta_ma_api.c b/bta/ma/bta_ma_api.c
deleted file mode 100644
index 2157447..0000000
--- a/bta/ma/bta_ma_api.c
+++ /dev/null
@@ -1,1203 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_mse_api.c
-**
-** Description: This is the implementation of the common API for the Message
-** Acess Profile of BTA, Broadcom Corp's Bluetooth
-** application layer for mobile phones.
-**
-** Copyright (c) 2009-2011 Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_MSE_INCLUDED) && (BTA_MSE_INCLUDED == TRUE)
-
-
-#include <string.h>
-#include "bta_ma_api.h"
-#include "bta_ma_util.h"
-#include "bta_ma_co.h"
-/*******************************************************************************
-**
-** Function BTA_MaBmsgCreate
-**
-** Description Create and initialize an instance of a tBTA_MA_BMSG structure.
-**
-** Parameters None
-**
-** Returns Pointer to a bMessage object, or NULL if this fails.
-**
-*******************************************************************************/
-tBTA_MA_BMSG * BTA_MaBmsgCreate(void)
-{
- tBTA_MA_BMSG *p_msg = (tBTA_MA_BMSG *) bta_ma_bmsg_alloc(sizeof(tBTA_MA_BMSG));
-
- if ( p_msg )
- {
- memset(p_msg, 0, sizeof(tBTA_MA_BMSG));
- }
- else
- {
- APPL_TRACE_ERROR0("BTA_MaBmsgCreate failed");
- }
-
- return(p_msg);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgFree
-**
-** Description Destroy (free) the contents of a tBTA_MA_BMSG structure.
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns None
-**
-*******************************************************************************/
-void BTA_MaBmsgFree(tBTA_MA_BMSG * p_msg)
-{
- if ( p_msg )
- {
- /* free folder string */
- bta_ma_bmsg_free(p_msg->p_folder);
-
- /* free all the vCards */
- bta_ma_bmsg_free_vcards(p_msg->p_orig);
-
- /* free the envelopes */
- bta_ma_bmsg_free_envelope(p_msg->p_envelope);
-
- /* free b-message structure itself */
- bta_ma_bmsg_free(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetReadSts
-**
-** Description Set the bmessage-readstatus-property value for the bMessage
-** object. If the 'read_sts' is TRUE then value will be "READ",
-** otherwise it is "UNREAD".
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-** read_sts - Read status TRUE- read FALSE - unread
-**
-** Returns None
-**
-*******************************************************************************/
-void BTA_MaBmsgSetReadSts(tBTA_MA_BMSG * p_msg, BOOLEAN read_sts)
-{
- if ( p_msg )
- p_msg->read_sts = read_sts;
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetReadSts
-**
-** Description Get the bmessage-readstatus-property value for the bMessage
-** object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Read status (TRUE/FALSE) for the specified bMessage.
-**
-*******************************************************************************/
-BOOLEAN BTA_MaBmsgGetReadSts(tBTA_MA_BMSG * p_msg)
-{
- return( p_msg ? p_msg->read_sts : FALSE);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetMsgType
-**
-** Description Set the bmessage-type-property value for the bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-** msg_type - Message type
-**
-** Returns None
-**
-*******************************************************************************/
-void BTA_MaBmsgSetMsgType(tBTA_MA_BMSG * p_msg, tBTA_MA_MSG_TYPE msg_type)
-{
- if ( p_msg )
- p_msg->msg_type = msg_type;
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetMsgType
-**
-** Description Get the bmessage-type-property value for the specified
-** bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Message type
-**
-*******************************************************************************/
-tBTA_MA_MSG_TYPE BTA_MaBmsgGetMsgType(tBTA_MA_BMSG * p_msg)
-{
- /* return 0 (for lack of a better value) */
- return( p_msg ? p_msg->msg_type : 0);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetFolder
-**
-** Description Set the bmessage-folder-property value for the bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-** p_folder - Pointer to a folder path
-**
-** Returns None
-**
-*******************************************************************************/
-void BTA_MaBmsgSetFolder(tBTA_MA_BMSG *p_msg, char *p_folder)
-{
- if ( p_msg && p_folder )
- {
- /* free any existing string */
- if ( p_msg->p_folder )
- bta_ma_bmsg_free(p_msg->p_folder);
-
- /* allocate a new one */
- p_msg->p_folder = (char *) bta_ma_bmsg_alloc(strlen(p_folder)+1);
- if ( p_msg->p_folder )
- BCM_STRNCPY_S(p_msg->p_folder, strlen(p_folder)+1, p_folder, strlen(p_folder)+1);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetFolder
-**
-** Description Get the bmessage-folder-property value for the specified
-** bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Pointer to folder path string, or NULL if it has not been set.
-**
-*******************************************************************************/
-char * BTA_MaBmsgGetFolder(tBTA_MA_BMSG * p_msg)
-{
- return(p_msg ? (char *) p_msg->p_folder : NULL);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddOrigToBmsg
-**
-** Description Add an originator to the bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Pointer to a new vCard structure, or NULL if this function
-** fails.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_VCARD * BTA_MaBmsgAddOrigToBmsg(tBTA_MA_BMSG * p_msg)
-{
- tBTA_MA_BMSG_VCARD * p_vcard = NULL;
- tBTA_MA_BMSG_VCARD * p_last_vcard = NULL;
-
- if ( p_msg )
- {
- p_vcard = (tBTA_MA_BMSG_VCARD *)bta_ma_bmsg_alloc(sizeof(tBTA_MA_BMSG_VCARD));
- if ( p_vcard )
- {
- memset(p_vcard, 0, sizeof(tBTA_MA_BMSG_VCARD));
- p_vcard->version = BTA_MA_VCARD_VERSION_21; /* default to 2.1 */
-
- if ( p_msg->p_orig )
- {
- /* set pointer to the last entry in the list */
- p_last_vcard = p_msg->p_orig;
- while ( p_last_vcard->p_next )
- p_last_vcard = (tBTA_MA_BMSG_VCARD *) p_last_vcard->p_next;
-
- p_last_vcard->p_next = p_vcard;
- }
- else
- p_msg->p_orig = p_vcard;
- }
- }
-
- return(p_vcard);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetOrigFromBmsg
-**
-** Description Get the first originator vCard information from the specified
-** bMessage object
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Pointer to first 'originator vCard, or NULL not used.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_VCARD * BTA_MaBmsgGetOrigFromBmsg(tBTA_MA_BMSG * p_msg)
-{
- return(p_msg ? (tBTA_MA_BMSG_VCARD *) p_msg->p_orig : NULL);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddEnvToBmsg
-**
-** Description Add a new envelope to the bMessage object. This is the first
-** (top) level envelope. bMessage allows up to 3 levels of envelopes.
-** application should call BTA_MaBmsgAddEnvToEnv to add the 2nd
-** 3rd level enevelope.
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Pointer to a new envelope structure, or NULL if this
-** function fails.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgAddEnvToBmsg(tBTA_MA_BMSG * p_msg)
-{
- tBTA_MA_BMSG_ENVELOPE * p_envelope = NULL;
-
- if ( p_msg )
- {
- p_envelope = (tBTA_MA_BMSG_ENVELOPE *)bta_ma_bmsg_alloc(sizeof(tBTA_MA_BMSG_ENVELOPE));
- if ( p_envelope )
- {
- memset(p_envelope, 0, sizeof(tBTA_MA_BMSG_ENVELOPE));
- p_msg->p_envelope = p_envelope;
- }
- }
-
- return( p_envelope );
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddEnvToEnv
-**
-** Description Add a child envelope to an existing envelope.
-**
-** Parameters p_envelope - Pointer to a parent envelope
-**
-** Returns Pointer to an envelope structure, or NULL if this
-** function fails.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgAddEnvToEnv(tBTA_MA_BMSG_ENVELOPE * p_envelope)
-{
- tBTA_MA_BMSG_ENVELOPE * p_new_envelope = NULL;
-
- if ( p_envelope )
- {
- p_new_envelope = (tBTA_MA_BMSG_ENVELOPE *)bta_ma_bmsg_alloc(sizeof(tBTA_MA_BMSG_ENVELOPE));
- if ( p_new_envelope )
- {
- memset(p_new_envelope, 0, sizeof(tBTA_MA_BMSG_ENVELOPE));
- p_envelope->p_next = p_new_envelope;
- }
- }
-
- return( p_new_envelope );
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetEnv
-**
-** Description Get the pointer of the first level envelope.
-**
-** Parameters p_bmsg - Pointer to a bMessage object
-**
-** Returns Pointer to the first level envelope structure, or NULL if it
-** does not exist
-**
-*******************************************************************************/
-tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgGetEnv(tBTA_MA_BMSG * p_msg)
-{
- return(p_msg ? (tBTA_MA_BMSG_ENVELOPE *) p_msg->p_envelope : NULL);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetNextEnv
-**
-** Description Get the child envelope of the specified parent envelope.
-**
-** Parameters p_env - Pointer to a parent envelope
-**
-** Returns Pointer to a child enevelope. NULL if the
-** envelope does not have a 'child' envelope.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgGetNextEnv(tBTA_MA_BMSG_ENVELOPE * p_env)
-{
- return(p_env ? (tBTA_MA_BMSG_ENVELOPE *)p_env->p_next : NULL);
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddRecipToEnv
-**
-** Description Add recipient to the specified envelope.
-**
-** Parameters p_env - Pointer to a envelope
-**
-** Returns Pointer to a vCard structure. NULL if it
-** fails to allocate a vCard structure.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_VCARD * BTA_MaBmsgAddRecipToEnv(tBTA_MA_BMSG_ENVELOPE * p_env)
-{
- tBTA_MA_BMSG_VCARD * p_vcard = NULL;
- tBTA_MA_BMSG_VCARD * p_last_vcard = NULL;
-
- if ( p_env )
- {
- p_vcard = (tBTA_MA_BMSG_VCARD *)bta_ma_bmsg_alloc(sizeof(tBTA_MA_BMSG_VCARD));
- if ( p_vcard )
- {
- memset(p_vcard, 0, sizeof(tBTA_MA_BMSG_VCARD));
- p_vcard->version = BTA_MA_VCARD_VERSION_21; /* default to 2.1 */
-
- if ( p_env->p_recip )
- {
- /* set pointer to the last entry in the list */
- p_last_vcard = p_env->p_recip;
- while ( p_last_vcard->p_next )
- p_last_vcard = (tBTA_MA_BMSG_VCARD *) p_last_vcard->p_next;
-
- p_last_vcard->p_next = p_vcard;
- }
- else
- p_env->p_recip = p_vcard;
- }
- }
-
- return(p_vcard);
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetRecipFromEnv
-**
-** Description Get the first recipient's vCard from the specified envelope.
-**
-** Parameters p_env - Pointer to a envelope
-**
-** Returns Pointer to the first recipient's vCard structure. NULL if it
-** has not be set.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_VCARD * BTA_MaBmsgGetRecipFromEnv(tBTA_MA_BMSG_ENVELOPE * p_env)
-{
- return(p_env ? p_env->p_recip : NULL);
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddBodyToEnv
-**
-** Description Add a message body to the specified envelope.
-**
-** Parameters p_env - Pointer to a envelope
-**
-** Returns Pointer to a message body structure.
-** NULL if it fails to allocate a message body structure.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_BODY * BTA_MaBmsgAddBodyToEnv(tBTA_MA_BMSG_ENVELOPE * p_env)
-{
- tBTA_MA_BMSG_BODY * p_body = NULL;
-
- if ( p_env )
- {
- /* free any existing body */
- if ( p_env->p_body )
- bta_ma_bmsg_free_body(p_env->p_body);
-
- /* allocate a new one */
- p_body = (tBTA_MA_BMSG_BODY *)bta_ma_bmsg_alloc(sizeof(tBTA_MA_BMSG_BODY));
- if ( p_body )
- {
- memset(p_body, 0, sizeof(tBTA_MA_BMSG_BODY));
- p_body->encoding = BTA_MA_BMSG_ENC_8BIT; /* default */
- }
-
- p_env->p_body = p_body;
- }
-
- return(p_body);
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetBodyFromEnv
-**
-** Description Get the message body pointer from the specified envelope.
-**
-** Parameters p_env - Pointer to a envelope
-**
-** Returns Pointer to a message body structure.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_BODY * BTA_MaBmsgGetBodyFromEnv(tBTA_MA_BMSG_ENVELOPE * p_env)
-{
- return( p_env ? p_env->p_body : NULL);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetBodyEncoding
-**
-** Description Set the bmessage-body-encoding-property value for the bMessage
-** body.
-**
-** Parameters p_body - Pointer to a bMessage body
-** encoding - encoding scheme
-**
-** Returns None
-**
-*******************************************************************************/
-void BTA_MaBmsgSetBodyEncoding(tBTA_MA_BMSG_BODY * p_body, tBTA_MA_BMSG_ENCODING encoding)
-{
- if ( p_body )
- p_body->encoding = encoding;
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetBodyEncoding
-**
-** Description Get the bmessage-body-encoding-property value for the specified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns Message encoding scheme
-**
-*******************************************************************************/
-tBTA_MA_BMSG_ENCODING BTA_MaBmsgGetBodyEncoding(tBTA_MA_BMSG_BODY * p_body)
-{
- return( p_body ? p_body->encoding : BTA_MA_BMSG_ENC_8BIT );
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetBodyPartid
-**
-** Description Set the bmessage-body-part-ID value for the speicified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-** part_id - Part ID (range: from 0 to 65535)
-**
-** Returns None
-**
-*******************************************************************************/
-void BTA_MaBmsgSetBodyPartid(tBTA_MA_BMSG_BODY * p_body, UINT16 part_id)
-{
- if ( p_body )
- {
- p_body->part_id = part_id;
- p_body->is_multipart = TRUE;
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetBodyPartid
-**
-** Description Get the bmessage-body-part-ID value for the specified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns The value of the Part ID
-**
-*******************************************************************************/
-UINT16 BTA_MaBmsgGetBodyPartid(tBTA_MA_BMSG_BODY * p_body)
-{
- return( p_body ? p_body->part_id : 0 );
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgIsBodyMultiPart
-**
-** Description Is this a multi-part body
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns TURE - if this is a multi-part body
-**
-*******************************************************************************/
-BOOLEAN BTA_MaBmsgIsBodyMultiPart(tBTA_MA_BMSG_BODY * p_body)
-{
- return( p_body ? p_body->is_multipart : FALSE );
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetBodyCharset
-**
-** Description Set the bmessage-body-charset-property value for the speicified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-** charset - Charset
-**
-** Returns None
-**
-*******************************************************************************/
-void BTA_MaBmsgSetBodyCharset(tBTA_MA_BMSG_BODY * p_body, tBTA_MA_CHARSET charset)
-{
- if ( p_body )
- p_body->charset = charset;
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetBodyCharset
-**
-** Description Get the bmessage-body-charset-property value for the speicified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns Charset
-**
-*******************************************************************************/
-tBTA_MA_CHARSET BTA_MaBmsgGetBodyCharset(tBTA_MA_BMSG_BODY * p_body)
-{
- return( p_body ? p_body->charset : BTA_MA_CHARSET_UNKNOWN );
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetBodyLanguage
-**
-** Description Set the bmessage-body-language-property value for the speicified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-** Language - the language of the message
-**
-** Returns None
-**
-*******************************************************************************/
-void BTA_MaBmsgSetBodyLanguage(tBTA_MA_BMSG_BODY * p_body, tBTA_MA_BMSG_LANGUAGE language)
-{
- if ( p_body )
- p_body->language = language;
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetBodyLanguage
-**
-** Description Get the bmessage-body-language-property value for the speicified
-** bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns the language of the message
-**
-*******************************************************************************/
-tBTA_MA_BMSG_LANGUAGE BTA_MaBmsgGetBodyLanguage(tBTA_MA_BMSG_BODY * p_body)
-{
- return( p_body ? p_body->language : BTA_MA_BMSG_LANG_UNSPECIFIED );
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddContentToBody
-**
-** Description Add a message content to the speicified bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns Pointer to a message content.
-** NULL if it fails to allocate a message content buffer
-**
-*******************************************************************************/
-tBTA_MA_BMSG_CONTENT * BTA_MaBmsgAddContentToBody(tBTA_MA_BMSG_BODY * p_body)
-{
- tBTA_MA_BMSG_CONTENT * p_content = NULL;
- tBTA_MA_BMSG_CONTENT * p_last_content = NULL;
-
- if ( p_body )
- {
- p_content = (tBTA_MA_BMSG_CONTENT *)bta_ma_bmsg_alloc(sizeof(tBTA_MA_BMSG_CONTENT));
- if ( p_content )
- {
- memset(p_content, 0, sizeof(tBTA_MA_BMSG_CONTENT));
-
- if ( p_body->p_content )
- {
- /* set pointer to the last entry in the list */
- p_last_content = p_body->p_content;
- while ( p_last_content->p_next )
- p_last_content = (tBTA_MA_BMSG_CONTENT *)p_last_content->p_next;
-
- p_last_content->p_next = p_content;
- }
- else
- p_body->p_content = p_content;
- }
- }
-
- return(p_content);
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetContentFromBody
-**
-** Description Get a message content from the speicified bMessage body.
-**
-** Parameters p_body - Pointer to a bMessage body
-**
-** Returns Pointer to a message content.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_CONTENT * BTA_MaBmsgGetContentFromBody(tBTA_MA_BMSG_BODY * p_body)
-{
- return(p_body ? p_body->p_content : NULL);
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetNextContent
-**
-** Description Get the next message content from the speicified message content.
-**
-** Parameters p_content - Pointer to a message content
-**
-** Returns Pointer to a message content.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_CONTENT * BTA_MaBmsgGetNextContent(tBTA_MA_BMSG_CONTENT * p_content)
-{
- return(p_content ? (tBTA_MA_BMSG_CONTENT *)p_content->p_next : NULL);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddMsgContent
-**
-** Description Add a text string to the speicified message content.
-**
-** Parameters p_content - Pointer to a message content
-** p_text - Pointer to a text string
-**
-** Returns None
-**
-*******************************************************************************/
-void BTA_MaBmsgAddMsgContent(tBTA_MA_BMSG_CONTENT * p_content, char * p_text)
-{
- tBTA_MA_BMSG_MESSAGE * p_message;
-
- if ( p_content )
- {
- p_message = (tBTA_MA_BMSG_MESSAGE *)bta_ma_bmsg_alloc(sizeof(tBTA_MA_BMSG_MESSAGE));
- if ( p_message )
- {
- memset(p_message, 0, sizeof(tBTA_MA_BMSG_MESSAGE));
-
- p_message->p_text = (char *)bta_ma_bmsg_alloc(strlen(p_text)+1);
-
- if ( p_message->p_text )
- {
- BCM_STRNCPY_S(p_message->p_text, strlen(p_text)+1, p_text, strlen(p_text)+1);
-
- /* if the content already points to a message,
- ** then we tack it on the end of the message list.
- */
- if ( p_content->p_message && p_content->p_last )
- p_content->p_last->p_next = p_message;
- else
- p_content->p_message = p_message;
-
- /* keep track of the last message text we added */
- p_content->p_last = p_message;
- }
- else
- bta_ma_bmsg_free(p_message);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetMsgContent
-**
-** Description Get the first text string from the speicified message content.
-**
-** Parameters p_content - Pointer to a message content
-**
-** Returns Pointer to the first text string.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-char * BTA_MaBmsgGetMsgContent(tBTA_MA_BMSG_CONTENT * p_content)
-{
- char * p_text = NULL;
- if ( p_content && p_content->p_message )
- {
- /* reset 'last' pointer for when 'get_next' is called. */
- p_content->p_last = p_content->p_message;
-
- p_text = p_content->p_message->p_text;
- }
-
- return( p_text );
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetMsgContent
-**
-** Description Get the next text string from the speicified message content.
-**
-** Parameters p_content - Pointer to a message content
-**
-** Returns Pointer to the next text string.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-char * BTA_MaBmsgGetNextMsgContent(tBTA_MA_BMSG_CONTENT * p_content)
-{
- char * p_text = NULL;
-
- if ( p_content && p_content->p_last )
- {
- /* advance pointer */
- p_content->p_last = ( tBTA_MA_BMSG_MESSAGE *)p_content->p_last->p_next;
-
- if ( p_content->p_last )
- p_text = p_content->p_last->p_text;
- }
-
- return( p_text );
-}
-
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetNextVcard
-**
-** Description Get the next vCard from the speicified vCard.
-**
-** Parameters p_vcard - Pointer to a vCard
-**
-** Returns Pointer to the next vCard.
-** NULL if it has not been set.
-**
-*******************************************************************************/
-tBTA_MA_BMSG_VCARD * BTA_MaBmsgGetNextVcard(tBTA_MA_BMSG_VCARD * p_vcard)
-{
- return(p_vcard ? (tBTA_MA_BMSG_VCARD *)p_vcard->p_next : NULL);
-}
-
-
-/*******************************************************************************
-**
-** Function BTA_MaBmsgSetVcardVersion
-**
-** Description Set the vCard version for the speicified vCard.
-**
-** Parameters p_vcard - Pointer to a vCard
-** version - vcard version
-**
-** Returns None
-**
-*******************************************************************************/
-void BTA_MaBmsgSetVcardVersion(tBTA_MA_BMSG_VCARD * p_vcard, tBTA_MA_VCARD_VERSION version)
-{
- if ( p_vcard )
- p_vcard->version = version;
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetVcardVersion
-**
-** Description Get the vCard version from the speicified vCard.
-**
-** Parameters p_vcard - Pointer to a vCard
-**
-** Returns vCard version number
-**
-*******************************************************************************/
-tBTA_MA_VCARD_VERSION BTA_MaBmsgGetVcardVersion(tBTA_MA_BMSG_VCARD * p_vcard)
-{
- return(p_vcard ? p_vcard->version : 0);
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgAddVcardProp
-**
-** Description Add a property to the speicified vCard.
-**
-** Parameters p_vcard - Pointer to a vCard
-** prop - Indicate which vCard peoperty
-** p_value - Pointer to the vCard property value
-** p_param - Pointer to the vCard property parameter
-**
-** Returns Pointer to the vCard peoperty
-**
-*******************************************************************************/
-tBTA_MA_VCARD_PROPERTY * BTA_MaBmsgAddVcardProp(tBTA_MA_BMSG_VCARD *p_vcard, tBTA_MA_VCARD_PROP prop, char *p_value, char *p_param)
-{
- tBTA_MA_VCARD_PROPERTY * p_prop = NULL;
- tBTA_MA_VCARD_PROPERTY * p_last_prop = NULL;
-
- if ( p_vcard && prop < BTA_MA_VCARD_PROP_MAX )
- {
- p_prop = (tBTA_MA_VCARD_PROPERTY *) bta_ma_bmsg_alloc(sizeof(tBTA_MA_VCARD_PROPERTY));
- if ( p_prop )
- {
- memset(p_prop, 0, sizeof(tBTA_MA_VCARD_PROPERTY));
-
- /* Set the value (if given) */
- if ( p_value )
- {
- p_prop->p_value = (char *)bta_ma_bmsg_alloc(strlen(p_value)+1);
- if ( p_prop->p_value )
- BCM_STRNCPY_S(p_prop->p_value, strlen(p_value)+1, p_value, strlen(p_value)+1);
- }
-
- /* Set the parameter (if given) */
- if ( p_param )
- {
- p_prop->p_param = (char *)bta_ma_bmsg_alloc(strlen(p_param)+1);
- if ( p_prop->p_param )
- BCM_STRNCPY_S(p_prop->p_param, strlen(p_param)+1, p_param, strlen(p_param)+1);
- }
-
- /* There can be more than one of a property. So add this property to the end of the list. */
- if ( p_vcard->p_prop[prop] == NULL )
- p_vcard->p_prop[prop] = p_prop;
- else
- {
- p_last_prop = p_vcard->p_prop[prop];
- while ( p_last_prop->p_next )
- p_last_prop = (tBTA_MA_VCARD_PROPERTY *)p_last_prop->p_next;
-
- p_last_prop->p_next = p_prop;
- }
- }
- }
-
- return(p_prop);
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetVcardProp
-**
-** Description Get the vCard property from the speicified vCard peoperty enum.
-**
-** Parameters p_vcard - Pointer to a vCard
-** prop - Indicate which vCard peoperty
-**
-** Returns Pointer to the vCard peoperty.
-** NULL if the vCard peoperty does not exist
-**
-*******************************************************************************/
-tBTA_MA_VCARD_PROPERTY * BTA_MaBmsgGetVcardProp(tBTA_MA_BMSG_VCARD * p_vcard, tBTA_MA_VCARD_PROP prop)
-{
- return( p_vcard && prop < BTA_MA_VCARD_PROP_MAX ? p_vcard->p_prop[prop] : NULL);
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetNextVcardProp
-**
-** Description Get the next vCard property from the speicified vCard peoperty.
-**
-** Parameters p_prop - Pointer to a vCard property
-**
-** Returns Pointer to the next vCard peoperty.
-** NULL if the next vCard peoperty does not exist
-**
-*******************************************************************************/
-tBTA_MA_VCARD_PROPERTY * BTA_MaBmsgGetNextVcardProp(tBTA_MA_VCARD_PROPERTY * p_prop)
-{
- return(p_prop ? (tBTA_MA_VCARD_PROPERTY *)p_prop->p_next : NULL);
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetVcardPropValue
-**
-** Description Get the vCard property value from the speicified vCard peoperty.
-**
-** Parameters p_prop - Pointer to a vCard property
-**
-** Returns Pointer to the vCard peoperty value.
-** NULL if the vCard peoperty value has not been set.
-**
-*******************************************************************************/
-char * BTA_MaBmsgGetVcardPropValue(tBTA_MA_VCARD_PROPERTY * p_prop)
-{
- return(p_prop ? p_prop->p_value : NULL);
-}
-/*******************************************************************************
-**
-** Function BTA_MaBmsgGetVcardPropParam
-**
-** Description Get the vCard property parameter from the speicified vCard peoperty.
-**
-** Parameters p_prop - Pointer to a vCard property
-**
-** Returns Poiter to the vCard peoperty parameter.
-** NULL if the vCard peoperty parameter has not been set.
-**
-*******************************************************************************/
-char * BTA_MaBmsgGetVcardPropParam(tBTA_MA_VCARD_PROPERTY * p_prop)
-{
- return(p_prop ? p_prop->p_param : NULL);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaBuildMapBmsgObj
-**
-** Description Builds a specification compliant bMessage object given a
-** generic bMessage internal structure.
-**
-** Parameters p_msg - pointer to bMessage object structure (input).
-** p_stream - Output stream.
-**
-** Returns BTA_MA_STATUS_OK if successful. BTA_MA_STATUS_FAIL if not.
-**
-*******************************************************************************/
-tBTA_MA_STATUS BTA_MaBuildMapBmsgObj(tBTA_MA_BMSG * p_msg,
- tBTA_MA_STREAM * p_stream)
-{
- tBTA_MA_STATUS status = BTA_MA_STATUS_FAIL;
-
-
- if ( p_msg && p_stream )
- {
- bta_ma_stream_str(p_stream, "BEGIN:BMSG");
- bta_ma_stream_str(p_stream, "\r\nVERSION:1.0");
-
- /* Read Status */
- bta_ma_stream_str(p_stream, "\r\nSTATUS:");
- bta_ma_stream_str(p_stream, (BTA_MaBmsgGetReadSts(p_msg) ? "READ" : "UNREAD"));
-
- /* Type */
- bta_ma_stream_str(p_stream, "\r\nTYPE:");
- bta_ma_stream_str(p_stream, bta_ma_msg_typ_to_string(BTA_MaBmsgGetMsgType(p_msg)));
-
- /* Folder */
- bta_ma_stream_str(p_stream, "\r\nFOLDER:");
- bta_ma_stream_str(p_stream, BTA_MaBmsgGetFolder(p_msg));
-
- /* Originator(s) */
- bta_ma_stream_vcards(p_stream, BTA_MaBmsgGetOrigFromBmsg(p_msg));
-
- /* Envelopes (nested) */
- bta_ma_stream_envelopes(p_stream, BTA_MaBmsgGetEnv(p_msg));
-
- bta_ma_stream_str(p_stream, "\r\nEND:BMSG\r\n");
-
- /* if buffer overflowed then return failure */
- status = bta_ma_stream_ok(p_stream)
- ? BTA_MA_STATUS_OK
- : BTA_MA_STATUS_FAIL;
- }
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("BTA_MA_STATUS =%d (0-OK) BTA_MaBuildMapBmsgObj", status);
-#endif
- return( status );
-}
-/*******************************************************************************
-**
-** Function bta_ma_parse_map_bmsg_obj
-**
-** Description Parses a bMessage object from a stream into a generic
-** bMessage internal structure.
-**
-** Parameters p_msg - pointer to bMessage object structure (output).
-** p_stream - Input stream.
-**
-** Returns BTA_MA_STATUS_OK if successful. BTA_MA_STATUS_FAIL if not.
-**
-*******************************************************************************/
-tBTA_MA_STATUS BTA_MaParseMapBmsgObj(tBTA_MA_BMSG * p_msg,
- tBTA_MA_STREAM * p_stream)
-{
- char sz[BTA_MA_MAX_SIZE];
- UINT32 prop_mask = 0;
- tBTA_MA_STATUS status = BTA_MA_STATUS_FAIL;
- tBTA_MA_BMSG_VCARD * p_vcard = NULL;
- tBTA_MA_BMSG_ENVELOPE * p_envelope = NULL;
- tBTA_MA_MSG_TYPE msg_type = 0;
-
- APPL_TRACE_EVENT0("BTA_MaParseMapBmsgObj");
- if ( p_msg && p_stream )
- {
- /* Must start with BEGIN:MSG */
- if ( bta_ma_get_tag(p_stream, sz, BTA_MA_MAX_SIZE)
- && (strcmp(sz, "BEGIN") == 0)
- && bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE)
- && (strcmp(sz, "BMSG") == 0) )
- {
- while ( bta_ma_get_tag(p_stream, sz, BTA_MA_MAX_SIZE) )
- {
- /* VERSION */
- if ( strcmp(sz, "VERSION") == 0 )
- {
- if ( bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE)
- && (strcmp(sz, "1.0") == 0) )
- {
- prop_mask |= BTA_MA_PROP_VERSION;
- }
- else
- break; /* incorrect VERSION */
- }
- else if ( strcmp(sz, "STATUS") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- BTA_MaBmsgSetReadSts(p_msg, (BOOLEAN) (strcmp(sz, "READ") == 0));
- }
- else if ( strcmp(sz, "TYPE") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- if ( bta_ma_str_to_msg_typ(sz, &msg_type) )
- BTA_MaBmsgSetMsgType(p_msg, msg_type);
-
- }
- else if ( strcmp(sz, "FOLDER") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- BTA_MaBmsgSetFolder(p_msg, sz);
- }
- else if ( strcmp(sz, "BEGIN") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
-
- if ( strcmp(sz, "VCARD") == 0 )
- {
- p_vcard = BTA_MaBmsgAddOrigToBmsg(p_msg);
- bta_ma_parse_vcard(p_vcard, p_stream);
- }
- else if ( strcmp(sz, "BENV") == 0 )
- {
- p_envelope = BTA_MaBmsgAddEnvToBmsg(p_msg);
- bta_ma_parse_envelope(p_envelope, p_stream);
- }
- else
- {
- APPL_TRACE_ERROR1("bta_ma_parse_map_bmsg_obj - Invalid BEGIN: '%s'", sz);
- }
- }
- else if ( strcmp(sz, "END") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- status = BTA_MA_STATUS_OK;
- break;
- }
- else
- {
- APPL_TRACE_ERROR1("bta_ma_parse_map_bmsg_obj - Invalid tag: '%s'", sz);
- }
- }
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("BTA_MaParseMapBmsgObj status=%d(0-OK)", status);
-#endif
- return( status );
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaInitMemStream
-**
-** Description Initializes a memory based stream
-**
-** Parameters p_stream - pointer to stream information.
-** p_buffer - pointer to buffer to be manipulated.
-** size - size of buffer pointed to by 'p_buffer'.
-**
-** Returns TRUE if stream is opened.
-**
-*******************************************************************************/
-BOOLEAN BTA_MaInitMemStream(tBTA_MA_STREAM * p_stream,
- UINT8 * p_buffer,
- UINT16 size)
-{
- if ( !p_stream )
- return(FALSE);
-
- memset(p_stream, 0, sizeof(tBTA_MA_STREAM));
-
- p_stream->type = STRM_TYPE_MEMORY;
- p_stream->u.mem.p_buffer = p_stream->u.mem.p_next = p_buffer;
- p_stream->u.mem.size = size;
-
- return(TRUE);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaInitFileStream
-**
-** Description Initializes a file stream
-**
-** Parameters p_stream - pointer to stream information.
-** p_path - Full pathname to file to use.
-** oflags - permissions and mode
-**
-** Returns TRUE if file stream is opened.
-**
-*******************************************************************************/
-BOOLEAN BTA_MaInitFileStream(tBTA_MA_STREAM * p_stream,
- const char *p_path,
- int oflags)
-{
- if ( !p_stream )
- {
- APPL_TRACE_ERROR0("Invalid stream pointer");
- return(FALSE);
- }
-
- memset(p_stream, 0, sizeof(tBTA_MA_STREAM));
-
- p_stream->type = STRM_TYPE_FILE;
-
- p_stream->u.file.fd = bta_ma_co_open(p_path, oflags);
-
- if ( p_stream->u.file.fd == -1 )
- {
- APPL_TRACE_ERROR0("Unable to open file ");
- p_stream->status = STRM_ERROR_FILE;
- }
-
- /* return TRUE if stream is OK */
- return(p_stream->status == STRM_SUCCESS);
-}
-
-/*******************************************************************************
-**
-** Function BTA_MaCloseStream
-**
-** Description Close a stream (do any necessary clean-up).
-**
-** Parameters p_stream - pointer to stream information.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MaCloseStream(tBTA_MA_STREAM * p_stream)
-{
- if ( p_stream->type == STRM_TYPE_FILE )
- {
- bta_ma_co_close(p_stream->u.file.fd);
- p_stream->u.file.fd = BTA_FS_INVALID_FD;
- }
-}
-#endif /* BTA_MSE_INCLUDED */
diff --git a/bta/ma/bta_ma_util.c b/bta/ma/bta_ma_util.c
deleted file mode 100644
index 6544e6a..0000000
--- a/bta/ma/bta_ma_util.c
+++ /dev/null
@@ -1,1750 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ma_util.c
-**
-** Description: This is the implementation file for the Message Access
-** Profile (MAP) utility functions.
-**
-** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_MSE_INCLUDED) && (BTA_MSE_INCLUDED)
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "bta_ma_api.h"
-#include "bta_ma_util.h"
-
-/*
-** Static constant data declarations
-*/
-/* Charset */static const char * bmsg_body_charset[] =
-{
- "native", /* BMSG_CHARSET_NATIVE (native) */
- "UTF-8" /* BMSG_CHARSET_UTF-8 (UTF-8) */
-};
-
-static const int num_bmsg_body_charset = sizeof(bmsg_body_charset) / sizeof(char*);
-
-
-/* vCard property names (the order is dicated by the tBTA_MA_BMSG_VCARD_PROP enumeration in bmsg_cnt.h) */
-static const char * vcard_prop_name[] =
-{
- "N", /* VCARD_PROP_N */
- "FN", /* VCARD_PROP_FN */
- "TEL", /* VCARD_PROP_TEL */
- "EMAIL" /* VCARD_PROP_EMAIL */
-};
-
-/* bMessage encoding names (the order is dictated by the tBTA_MA_BMSG_ENCODING enumeration in bmsg_cnt.h) */
-static const char * bmsg_body_encoding[] =
-{
- "8BIT", /* BMSG_ENC_8BIT (8-Bit-Clean encoding) */
- "G-7BIT", /* BMSG_ENC_G7BIT (GSM 7 bit Default Alphabet) */
- "G-7BITEXT", /* BMSG_ENC_G7BITEXT (GSM 7 bit Alphabet with national language extension) */
- "G-UCS2" , /* BMSG_ENC_GUCS2 */
- "G-8BIT", /* BMSG_ENC_G8BIT */
- "C-8BIT", /* BMSG_ENC_C8BIT (Octet, unspecified) */
- "C-EPM", /* BMSG_ENC_CEPM (Extended Protocol Message) */
- "C-7ASCII", /* BMSG_ENC_C7ASCII (7-bit ASCII) */
- "C-IA5", /* BMSG_ENC_CIA5 (IA5) */
- "C-UNICODE", /* BMSG_ENC_CUNICODE (UNICODE) */
- "C-SJIS", /* BMSG_ENC_CSJIS (Shift-JIS) */
- "C-KOREAN", /* BMSG_ENC_CKOREAN (Korean) */
- "C-LATINHEB", /* BMSG_ENC_CLATINHEB (Latin/Hebrew) */
- "C-LATIN" /* BMSG_ENC_CLATIN (Latin) */
-};
-
-static const int num_bmsg_body_encoding = sizeof(bmsg_body_encoding) / sizeof(char*);
-
-static const char * bmsg_body_language[] =
-{
- "", /* BMSG_LANG_UNSPECIFIED (not provided in bBody */
- "UNKNOWN", /* BMSG_LANG_UNKNOWN */
- "SPANISH", /* BMSG_LANG_SPANISH */
- "TURKISH", /* BMSG_LANG_TURKISH */
- "PORTUGUESE", /* BMSG_LANG_PORTUGUESE */
- "ENGLISH", /* BMSG_LANG_ENGLISH */
- "FRENCH", /* BMSG_LANG_FRENCH */
- "JAPANESE", /* BMSG_LANG_JAPANESE */
- "KOREAN", /* BMSG_LANG_KOREAN */
- "CHINESE", /* BMSG_LANG_CHINESE */
- "HEBREW" /* BMSG_LANG_HEBREW */
-};
-
-static const int num_bmsg_body_language = sizeof(bmsg_body_language) / sizeof(char*);
-
-#include "bta_ma_co.h"
-
-#define BTA_MSE_NOTIF_TYPE_NEW_MSG_STR "NewMessage"
-#define BTA_MSE_NOTIF_TYPE_DELIVERY_SUCCESS_STR "DeliverySuccess"
-#define BTA_MSE_NOTIF_TYPE_SENDING_SUCCESS_STR "SendingSuccess"
-#define BTA_MSE_NOTIF_TYPE_DELIVERY_FAILURE_STR "DeliveryFailure"
-#define BTA_MSE_NOTIF_TYPE_SENDING_FAILURE_STR "SendingFailure"
-#define BTA_MSE_NOTIF_TYPE_MEMORY_FULL_STR "MemoryFull"
-#define BTA_MSE_NOTIF_TYPE_MEMORY_AVAILABLE_STR "MemoryAvailable"
-#define BTA_MSE_NOTIF_TYPE_MESSAGE_DELETED_STR "MessageDeleted"
-#define BTA_MSE_NOTIF_TYPE_MESSAGE_SHIFT_STR "MessageShift"
-
-#define BTA_MSE_MSG_TYPE_EMAIL "EMAIL"
-#define BTA_MSE_MSG_TYPE_SMS_GSM "SMS_GSM"
-#define BTA_MSE_MSG_TYPE_SMS_CDMA "SMS_CDMA"
-#define BTA_MSE_MSG_TYPE_MMS "MMS"
-
-#define BTA_MSE_RCV_STATUS_COMPLETE "complete"
-#define BTA_MSE_RCV_STATUS_FRACTIONED "fractioned"
-#define BTA_MSE_RCV_STATUS_NOTIFICATION "notification"
-
-#define BTA_MSE_BOOLEAN_YES "yes"
-#define BTA_MSE_BOOLEAN_NO "no"
-
-/*******************************************************************************
-**
-** Function bta_ma_evt_typ_to_string
-**
-** Description Utility function to return a pointer to a string holding
-** the notifiction "type" for the MAP-Event-Report object.
-**
-** Parameters notif_type - Notification type
-**
-** Returns Pointer to static string representing notification type.
-**
-*******************************************************************************/
-
-const char * bta_ma_evt_typ_to_string(tBTA_MSE_NOTIF_TYPE notif_type)
-{
- switch (notif_type)
- {
- case BTA_MSE_NOTIF_TYPE_NEW_MSG:
- return(BTA_MSE_NOTIF_TYPE_NEW_MSG_STR);
- case BTA_MSE_NOTIF_TYPE_DELIVERY_SUCCESS:
- return(BTA_MSE_NOTIF_TYPE_DELIVERY_SUCCESS_STR);
- case BTA_MSE_NOTIF_TYPE_SENDING_SUCCESS:
- return(BTA_MSE_NOTIF_TYPE_SENDING_SUCCESS_STR);
- case BTA_MSE_NOTIF_TYPE_DELIVERY_FAILURE:
- return(BTA_MSE_NOTIF_TYPE_DELIVERY_FAILURE_STR);
- case BTA_MSE_NOTIF_TYPE_SENDING_FAILURE:
- return(BTA_MSE_NOTIF_TYPE_SENDING_FAILURE_STR);
- case BTA_MSE_NOTIF_TYPE_MEMORY_FULL:
- return(BTA_MSE_NOTIF_TYPE_MEMORY_FULL_STR);
- case BTA_MSE_NOTIF_TYPE_MEMORY_AVAILABLE:
- return(BTA_MSE_NOTIF_TYPE_MEMORY_AVAILABLE_STR);
- case BTA_MSE_NOTIF_TYPE_MESSAGE_DELETED:
- return(BTA_MSE_NOTIF_TYPE_MESSAGE_DELETED_STR);
- case BTA_MSE_NOTIF_TYPE_MESSAGE_SHIFT:
- return(BTA_MSE_NOTIF_TYPE_MESSAGE_SHIFT_STR);
- }
-
- return NULL;
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_msg_typ_to_string
-**
-** Description Utility function to return a pointer to a string holding
-** the "msg_type" for the MAP-Event-Report object or or the
-** the type for the MAP-msg-listing object
-**
-** Parameters msg_typ - Message type
-**
-** Returns Pointer to static string representing message type.
-**
-*******************************************************************************/
-
-const char * bta_ma_msg_typ_to_string(tBTA_MA_MSG_TYPE msg_typ)
-{
- switch (msg_typ)
- {
- case BTA_MA_MSG_TYPE_EMAIL: return(BTA_MSE_MSG_TYPE_EMAIL);
- case BTA_MA_MSG_TYPE_SMS_GSM: return(BTA_MSE_MSG_TYPE_SMS_GSM);
- case BTA_MA_MSG_TYPE_SMS_CDMA: return(BTA_MSE_MSG_TYPE_SMS_CDMA);
- case BTA_MA_MSG_TYPE_MMS: return(BTA_MSE_MSG_TYPE_MMS);
- }
-
- return NULL;
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_rcv_status_to_string
-**
-** Description Utility function to return a pointer to a string holding
-** the "reception_status" for the MAP-msg-listing object
-**
-** Parameters rcv_status - Reception status
-**
-** Returns Pointer to static string representing message type.
-**
-*******************************************************************************/
-const char * bta_ma_rcv_status_to_string(tBTA_MSE_CO_RCV_STATUS rcv_status)
-{
- switch (rcv_status)
- {
- case BTA_MSE_CO_RCV_STATUS_COMPLETE:
- return(BTA_MSE_RCV_STATUS_COMPLETE);
- case BTA_MSE_CO_RCV_STATUS_FRACTIONED:
- return(BTA_MSE_RCV_STATUS_FRACTIONED);
- case BTA_MSE_CO_RCV_STATUS_NOTIFICATION:
- return(BTA_MSE_RCV_STATUS_NOTIFICATION);
- }
-
- return NULL;
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_str
-**
-** Description Input a string into the stream.
-**
-** Parameters p_stream - pointer to stream information.
-** p_str - pointer to string to be put in the buffer. Only the
-** string characters, and not the NULL, are put into the
-** buffer.
-**
-** Returns TRUE if the string was successfully added into the stream.
-**
-*******************************************************************************/
-BOOLEAN bta_ma_stream_str(tBTA_MA_STREAM * p_stream, const char * p_str)
-{
- UINT16 buf_size;
- UINT16 str_size;
- UINT16 size = 0;
-
- /* ensure stream and string are not NULL */
- if ( !p_str || !p_stream )
- return(FALSE);
-
- /* get length of string */
- str_size = strlen(p_str);
-
- switch ( p_stream->type )
- {
- case STRM_TYPE_MEMORY:
- /* ensure buffer is not full */
- if ( p_stream->status == STRM_SUCCESS )
- {
- /* get amount of size left in buffer */
- buf_size = p_stream->u.mem.size - bta_ma_stream_used_size(p_stream);
-
- /* calculate the size to copy (the minimum of string and buffer size */
- if ( str_size > buf_size )
- {
- size = buf_size;
- p_stream->status = STRM_ERROR_OVERFLOW;
- }
- else
- size = str_size;
-
- /* copy the data and move the pointer */
- memcpy(p_stream->u.mem.p_next, p_str, size);
- p_stream->u.mem.p_next += size;
- }
- break;
-
- case STRM_TYPE_FILE:
- /* write string */
- bta_ma_co_write(p_stream->u.file.fd, p_str, str_size);
- break;
- }
-
- /* return TRUE if stream is OK */
- return(p_stream->status == STRM_SUCCESS);
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_buf
-**
-** Description Stream a buffer into the buffer.
-**
-** Parameters p_stream - pointer to stream information.
-** len - length of buffer
-** p_buf - pointer to buffer to stream.
-**
-** Returns TRUE if the buffer was large enough to hold the data.
-**
-*******************************************************************************/
-extern BOOLEAN bta_ma_stream_buf(tBTA_MA_STREAM * p_stream,
- UINT16 len,
- UINT8 * p_buf)
-{
- UINT16 buf_size;
- UINT16 size = 0;
-
- /* ensure stream and buffer pointer are not NULL */
- if ( !p_buf || !p_stream )
- return(FALSE);
-
- switch ( p_stream->type )
- {
- case STRM_TYPE_MEMORY:
- /* ensure buffer is not full */
- if ( p_stream->status == STRM_SUCCESS )
- {
- /* get amount of size left in buffer */
- buf_size = p_stream->u.mem.size - bta_ma_stream_used_size(p_stream);
-
- /* calculate the size to copy (the minimum of string and buffer size */
- if ( len > buf_size )
- {
- size = buf_size;
- p_stream->status = STRM_ERROR_OVERFLOW;
- }
- else
- size = len;
-
- /* copy the data and move the pointer */
- memcpy(p_stream->u.mem.p_next, p_buf, len);
- p_stream->u.mem.p_next += size;
- }
- break;
- case STRM_TYPE_FILE:
- /* write string */
- bta_ma_co_write(p_stream->u.file.fd, p_buf, len);
- break;
- }
-
- /* return TRUE if stream is OK */
- return(p_stream->status == STRM_SUCCESS);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_boolean_yes_no
-**
-** Description Stream a yes/no string into the buffer.
-**
-** Parameters p_stream - pointer to stream information.
-** val - a boolean value to indicate yes or no
-**
-** Returns TRUE if the yes/no string was successfully added into
-** the stream.
-**
-*******************************************************************************/
-BOOLEAN bta_ma_stream_boolean_yes_no(tBTA_MA_STREAM * p_stream, BOOLEAN val)
-{
- return bta_ma_stream_str(p_stream,
- val == FALSE ? BTA_MSE_BOOLEAN_NO : BTA_MSE_BOOLEAN_YES);
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_value
-**
-** Description Stream an UINT32 value string into the buffer.
-**
-** Parameters p_stream - pointer to stream information.
-** val - a UINT32 value
-**
-** Returns TRUE if the buffer was large enough to hold the data.
-**
-*******************************************************************************/
-BOOLEAN bta_ma_stream_value(tBTA_MA_STREAM * p_stream, UINT32 val)
-{
- char temp[50];
-
- sprintf(temp, "%lu", val);
- return bta_ma_stream_str(p_stream, temp);
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_handle
-**
-** Description Stream a message handle into the buffer.
-**
-** Parameters p_stream - pointer to stream information.
-** handle - handle to be put in the buffer.
-**
-** Returns TRUE if the buffer was large enough to hold the data.
-**
-*******************************************************************************/
-
-BOOLEAN bta_ma_stream_handle(tBTA_MA_STREAM * p_stream, tBTA_MA_MSG_HANDLE handle)
-{
- char temp[5];
- int x;
- BOOLEAN value_yet = FALSE;
-
- /* ensure buffer is not full */
- if ( p_stream->status == STRM_SUCCESS )
- {
- for ( x=0; x < BTA_MA_HANDLE_SIZE; x++ )
- {
- /* Skip any leading 0's */
- if ( (! value_yet) && (handle[x] == 0) )
- continue;
-
- value_yet = TRUE;
-
- sprintf(temp, "%02x", handle[x]);
-
- if ( bta_ma_stream_str(p_stream, temp) == FALSE )
- return(FALSE);
- }
- }
-
- /* return TRUE if stream is OK */
- return(p_stream->status == STRM_SUCCESS);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_used_size
-**
-** Description Returns the used byte count.
-**
-** Parameters p_stream - pointer to stream information.
-**
-** Returns Number of bytes used in the buffer.
-**
-*******************************************************************************/
-
-UINT16 bta_ma_stream_used_size(tBTA_MA_STREAM * p_stream)
-{
- return(p_stream->u.mem.p_next - p_stream->u.mem.p_buffer);
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_ok
-**
-** Description Determines if the stream is ok.
-**
-** Parameters p_stream - pointer to stream information.
-**
-** Returns TRUE if stream status is OK.
-**
-*******************************************************************************/
-
-BOOLEAN bta_ma_stream_ok(tBTA_MA_STREAM * p_stream)
-{
- return(p_stream && p_stream->status == STRM_SUCCESS);
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_convert_hex_str_to_64bit_handle
-**
-** Description Convert a hex string to a 64 bit message handle in Big Endian
-** format
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ma_convert_hex_str_to_64bit_handle(char *p_hex_str, tBTA_MA_MSG_HANDLE handle)
-{
- UINT32 ul1, ul2;
- UINT8 *p;
- char tmp[BTA_MA_32BIT_HEX_STR_SIZE];
- UINT8 str_len;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_convert_hex_str_to_64bit_handle");
-#endif
-
- str_len = strlen(p_hex_str);
- memset(handle,0,sizeof(tBTA_MA_MSG_HANDLE));
-
- if (str_len >= 8)
- {
- /* most significant 4 bytes */
- memcpy(tmp,p_hex_str,(str_len-8));
- tmp[str_len-8]='\0';
- ul1 = strtoul(tmp,0,16);
- p=handle;
- UINT32_TO_BE_STREAM(p, ul1);
-
- /* least significant 4 bytes */
- memcpy(tmp,&(p_hex_str[str_len-8]),8);
- tmp[8]='\0';
- ul2 = strtoul(tmp,0,16);
- p=&handle[4];
- UINT32_TO_BE_STREAM(p, ul2);
- }
- else
- {
- /* least significant 4 bytes */
- ul1 = strtoul(p_hex_str,0,16);
- p=&handle[4];
- UINT32_TO_BE_STREAM(p, ul1);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_get_char
-**
-** Description Gets one character from the stream.
-**
-** Parameters p_stream - pointer to stream information.
-** p_char - pointer to where to receive the character.
-**
-** Returns TRUE if character was read OK.
-**
-*******************************************************************************/
-BOOLEAN bta_ma_get_char(tBTA_MA_STREAM * p_stream, char * p_char)
-{
- BOOLEAN bStatus = FALSE;
-
- if ( p_char )
- {
- *p_char = 0;
-
- if ( p_stream )
- {
- switch ( p_stream->type )
- {
- case STRM_TYPE_MEMORY:
- if ( (p_stream->u.mem.p_next-p_stream->u.mem.p_buffer) < p_stream->u.mem.size )
- {
- *p_char = *p_stream->u.mem.p_next;
- p_stream->u.mem.p_next++;
-
- bStatus = TRUE;
- }
- break;
- case STRM_TYPE_FILE:
- /* read character */
- bStatus = bta_ma_co_read(p_stream->u.file.fd, (void *) p_char, 1) == 1;
- break;
- }
- }
- }
-
- return( bStatus );
-}
-
-
-/*******************************************************************************
-**
-** Function bta_ma_get_tag
-**
-** Description Parses a tag from the stream. Basically this returns any text
-** before a ':' character, ignoring leading whitespace.
-**
-** Parameters p_stream - Input stream.
-** psz - buffer to receive the tag
-** max_size - size of the receiving buffer (including space
-** for the NULL character.
-**
-** Returns Size of tag, or 0 if there was an error.
-**
-*******************************************************************************/
-UINT16 bta_ma_get_tag(tBTA_MA_STREAM * p_stream, char * psz, UINT16 max_size)
-{
- char c;
- UINT16 count = 0;
-
- /* handle bad arguments */
- if ( p_stream && psz && (max_size > 0) )
- {
- /* reserve last byte for NULL terminator */
- max_size--;
-
- while ( bta_ma_get_char(p_stream, &c)
- && (c != ':')
- && (count < max_size) )
- {
- /* ignore leading whitespace */
- if ( !count && ((c == ' ') || (c == '\t')) )
- continue;
-
- /* if we hit a CR, return 0 to indicate an error */
- if ( c == '\r' )
- return( 0 );
-
- psz[count++] = c;
- }
-
- /* Either we hit a problem reading from the stream
- ** or the buffer was not large enough
- */
- if ( c != ':' )
- return( 0 );
-
- /* terminate string */
- psz[count] = '\0';
- }
-
- return( count );
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_get_value
-**
-** Description Parses a value from the stream. Basically this any text
-** up to (but not including) the CR LF sequence.
-**
-** Parameters p_stream - Input stream.
-** psz - buffer to receive the value
-** max_size - size of the receiving buffer (including space
-** for the NULL character.
-**
-** Returns Size of value, or 0 if there was an error.
-**
-*******************************************************************************/
-UINT16 bta_ma_get_value(tBTA_MA_STREAM * p_stream, char * psz, UINT16 max_size)
-{
- char c;
- UINT16 count = 0;
-
- /* handle bad arguments */
- if ( p_stream && psz && (max_size > 0) )
- {
- /* reserve last byte for NULL terminator */
- max_size--;
-
- while ( bta_ma_get_char(p_stream, &c)
- && (c != '\r')
- && (count < max_size) )
- {
- psz[count++] = c;
- }
-
- /* Either we hit a problem reading from the stream
- ** or the buffer was not large enough
- */
- if ( c != '\r' )
- return( 0 );
-
- /* burn the next character which must be LF */
- if ( ! bta_ma_get_char(p_stream, &c) )
- return( 0 );
-
- /* terminate string */
- psz[count] = '\0';
- }
-
- return( count );
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_get_param
-**
-** Description Parses the parameter from the source string.
-**
-** Parameters p_src - source paramter string.
-** psz - buffer to receive the value
-**
-** Returns Size of param, or 0 if there was an error.
-**
-*******************************************************************************/
-UINT16 bta_ma_get_param(char *p_src, char *psz )
-{
- char c;
- UINT16 count = 0;
- BOOLEAN first_semicolon_found=FALSE;
-
- /* handle bad arguments */
- if ( p_src && psz )
- {
- while ( (c = *p_src++) )
- {
-
- /* throw away the first ';' */
- if ( !count && (c==';') )
- {
- first_semicolon_found = TRUE;
- continue;
- }
-
- /* first char should be ';' otherwise return 0 */
- if(!count && !first_semicolon_found && (c!=';'))
- return (0);
-
- /* if we hit a CR, return 0 to indicate an error */
- if ( c == '\r' )
- return( 0 );
-
- psz[count++] = c;
- }
-
- if ( !count )
- return( 0 );
-
- /* terminate string */
- psz[count] = '\0';
- }
-
- return( count );
-}
-
-
-
-
-/*******************************************************************************
-**
-** Function bta_ma_parse_vcard
-**
-** Description Parses a vCard from the stream into a generic tBTA_MA_BMSG_VCARD
-** structure.
-**
-** Parameters p_vcard - pointer to generic vCard structure.
-** p_stream - Input stream.
-**
-** Returns BTA_MA_STATUS_OK if successful. BTA_MA_STATUS_FAIL if not.
-**
-*******************************************************************************/
-tBTA_MA_STATUS bta_ma_parse_vcard(tBTA_MA_BMSG_VCARD * p_vcard,
- tBTA_MA_STREAM * p_stream)
-{
- char sz[BTA_MA_MAX_SIZE];
- tBTA_MA_STATUS status = BTA_MA_STATUS_FAIL;
- tBTA_MA_VCARD_VERSION version;
- char * psztoken_tel = "TEL";
-// btla-specific ++
- char * psztoken_name = "N;";
-// btla-specific --
- char param[BTA_MA_MAX_SIZE];
- char *p_src;
- UINT16 len;
-
-
- while ( bta_ma_get_tag(p_stream, sz, BTA_MA_MAX_SIZE) )
- {
- if ( strcmp(sz, "VERSION") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- if ( strcmp(sz, "3.0") == 0 )
- version = BTA_MA_VCARD_VERSION_30;
- else if ( strcmp(sz, "2.1") == 0 )
- version = BTA_MA_VCARD_VERSION_21;
- else
- {
- APPL_TRACE_ERROR1("bta_ma_parse_vcard - Invalid vcard version: '%s'", sz);
- break;
- }
-
- BTA_MaBmsgSetVcardVersion(p_vcard, version);
- }
- else if ( strcmp(sz, "N") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- BTA_MaBmsgAddVcardProp(p_vcard, BTA_MA_VCARD_PROP_N, sz, NULL);
-// btla-specific ++
- }
- else if ( strstr(sz, psztoken_name) == sz )
- {
- p_src = sz + strlen(psztoken_name) - 1; // move to (first) semicolon, not past it
- len = strlen(p_src);
- if ( (len < BTA_MA_MAX_SIZE) && bta_ma_get_param(p_src, param))
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- BTA_MaBmsgAddVcardProp(p_vcard, BTA_MA_VCARD_PROP_N, sz, param);
- }
-// btla-specific --
- }
- else if ( strcmp(sz, "FN") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- BTA_MaBmsgAddVcardProp(p_vcard, BTA_MA_VCARD_PROP_FN, sz, NULL);
- }
- else if ( strcmp(sz, psztoken_tel ) == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- BTA_MaBmsgAddVcardProp(p_vcard, BTA_MA_VCARD_PROP_TEL, sz, NULL);
- }
- else if ( strstr(sz, psztoken_tel) == sz )
- {
- p_src = sz + strlen(psztoken_tel);
- len = strlen(p_src);
- if ( (len < BTA_MA_MAX_SIZE) && bta_ma_get_param(p_src, param))
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- BTA_MaBmsgAddVcardProp(p_vcard, BTA_MA_VCARD_PROP_TEL, sz, param);
- }
- }
- else if ( strcmp(sz, "EMAIL") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- BTA_MaBmsgAddVcardProp(p_vcard, BTA_MA_VCARD_PROP_EMAIL, sz, NULL);
- }
- else if ( strcmp(sz, "END") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- status = BTA_MA_STATUS_OK;
- break;
- }
- else
- {
- APPL_TRACE_ERROR1("bta_ma_parse_vcard - Invalid tag: '%s'", sz);
- }
- }
-
- return( status );
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_parse_content
-**
-** Description Parses a <bmessage-body-content> from the stream into a
-** generic tBTA_MA_BMSG_CONTENT structure. This will parse text until
-** we see "END:MSG" at the start of a line.
-**
-** Parameters p_content - pointer to generic content structure.
-** p_stream - Input stream.
-**
-** Returns BTA_MA_STATUS_OK if successful. BTA_MA_STATUS_FAIL if not.
-**
-*******************************************************************************/
-tBTA_MA_STATUS bta_ma_parse_content(tBTA_MA_BMSG_CONTENT * p_content,
- tBTA_MA_STREAM * p_stream)
-{
-/* This constant defines the size of the work buffer used for parsing.
-** It MUST be larger than the 'END:MSG<CRLF>" string size. The larger
-** the buffer the more efficient this parser will be.
-*/
-#define BTA_MA_PARSE_BUF_SIZE BTA_MA_MAX_SIZE
-
-/* These constants define the four states the parser can be in.
-*/
-#define STATE_WS (0) /* checking for leading whitespace */
-#define STATE_END (1) /* checking for END:MSG */
-#define STATE_CR (2) /* checking for CRLF */
-#define STATE_TEXT (3) /* copying text */
-
- static const char * END_MSG = "END:MSG\r\n";
-
- char sz[BTA_MA_PARSE_BUF_SIZE+1];
- char c;
- int state = STATE_WS; /* start in the 'whitespace' state */
- int idx_commit = 0;
- int idx_trial = 0;
- int idx_end = 0;
- int x;
-
- /* NOTES - There are 3 primary indices used during parsing:
- **
- ** 'idx_commit' these are characters that are commited to being
- ** in the message text. We need to be able to save characters
- ** (such as <CR><LF>, "END..", etc.) but not actually 'commit' them.
- **
- ** 'idx_trial' these are characters that we are saving on a trial
- ** basis until we know what to do with them. For example, if
- ** we get a sequence "<CR>+<LF>+E+N", we don't want to commit
- ** them until we know it is not "END:MSG<CR><LF>".
- **
- ** 'idx_end' is used to index through the "END:MSG<CR><LF> string.
- */
-
- /* Handle bad arguments */
- if ( p_stream && p_content )
- {
- /* Get one character from the stream */
- while ( bta_ma_get_char(p_stream, &c) )
- {
- switch (state)
- {
- case STATE_WS:
- /* totally ignore leading whitespace */
- if ( (c == ' ') || (c == '\t') )
- continue;
-
- /* Otherwise intentionaly fall through after resetting the
- ** 'end' index so we start comparing from the beginning.
- */
- idx_end = 0;
-
- case STATE_END:
- /* Is the character in the "END:MSG<CR><LF> sequence? */
- if ( c == END_MSG[idx_end] )
- {
- /* Yes. Did we get to the end of "END:MSG<cr><lf>"? */
- if ( ! END_MSG[++idx_end] )
- {
- /* Yes. Commit any characters and get out. */
- if ( idx_commit )
- {
- sz[idx_commit] = '\0';
- BTA_MaBmsgAddMsgContent(p_content, sz);
- }
-
- return( BTA_MA_STATUS_OK );
- }
-
- state = STATE_END;
- break;
- }
- /* If we fell through from the whitespace state
- ** then we should commit all chars at this point.
- ** It handles the case where we get consecutive CRLF.
- */
- if ( state == STATE_WS )
- idx_commit = idx_trial;
-
- /* And intentionally fall through */
-
- case STATE_CR:
- /* We got <CR>, is this <LF>? */
- if ( c == '\n' )
- {
- /* Now look for any whitespace */
- state = STATE_WS;
- break;
- }
-
- /* otherwise intentionally fall through */
-
- case STATE_TEXT:
- /* is a CR? */
- if ( c == '\r' )
- state = STATE_CR; /* Look for <LF> */
- else
- state = STATE_TEXT; /* Copy the text */
- break;
- }
-
- /* All (non-whitespace) characters are copied to
- ** the buffer as 'trial' characters possibly
- ** committed later.
- */
- sz[idx_trial++] = c;
-
- /* If we are in the text copy state, then
- ** commit all characters to this point.
- */
- if ( state == STATE_TEXT )
- idx_commit = idx_trial;
-
- /* The buffer is full. Commit the good characters
- ** to the message content, and rearrange the rest
- ** of the text to make room for more.
- */
- if ( idx_trial == BTA_MA_PARSE_BUF_SIZE )
- {
- /* Do we have characters to commit?
- ** If we don't we are in trouble.
- */
- if ( idx_commit )
- {
- /* Save the last character so we can put a NULL there. */
- c = sz[idx_commit];
- sz[idx_commit] = '\0';
- BTA_MaBmsgAddMsgContent(p_content, sz);
-
- /* Do we need to rearrange uncommited text? */
- if ( idx_commit != idx_trial )
- {
- /* Restore character */
- sz[idx_commit] = c;
-
- /* Copy the 'trial' characters to the beginning of buffer */
- idx_trial -= idx_commit;
- for ( x=0; x < idx_trial; x++)
- sz[x] = sz[x+idx_commit];
- idx_commit = 0;
- }
- else
- {
- idx_trial = idx_commit = 0;
- }
- }
- else
- {
- /* ERROR - no space to shuffle things around */
- APPL_TRACE_ERROR0("bta_ma_parse_content - work buffer too small");
- break;
- }
- }
- }
- }
-
- return( BTA_MA_STATUS_FAIL );
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_parse_body
-**
-** Description Parses a <bmessage-content> (BBODY) from the stream into a
-** generic tBTA_MA_BMSG_BODY structure. This will parse text until
-** we see "END:BODY" at the start of a line.
-**
-** Parameters p_body - pointer to generic content body structure.
-** p_stream - Input stream.
-**
-** Returns BTA_MA_STATUS_OK if successful. BTA_MA_STATUS_FAIL if not.
-**
-*******************************************************************************/
-tBTA_MA_STATUS bta_ma_parse_body(tBTA_MA_BMSG_BODY * p_body,
- tBTA_MA_STREAM * p_stream)
-{
- char sz[BTA_MA_MAX_SIZE];
- tBTA_MA_STATUS status = BTA_MA_STATUS_FAIL;
- tBTA_MA_BMSG_CONTENT *p_content = NULL;
- tBTA_MA_BMSG_ENCODING encoding;
- tBTA_MA_BMSG_LANGUAGE language;
- tBTA_MA_CHARSET charset;
-
- while ( bta_ma_get_tag(p_stream, sz, BTA_MA_MAX_SIZE) )
- {
- if ( strcmp(sz, "PARTID") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- BTA_MaBmsgSetBodyPartid(p_body, (UINT16) atoi(sz));
- }
- else if ( strcmp(sz, "ENCODING") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- if ( bta_ma_str_to_encoding(sz, &encoding) )
- BTA_MaBmsgSetBodyEncoding(p_body, encoding);
- else
- APPL_TRACE_ERROR1("bta_ma_parse_body - Invalid ENCODING: '%s'", sz);
- }
- else if ( strcmp(sz, "CHARSET") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- if ( bta_ma_str_to_charset(sz, &charset))
- BTA_MaBmsgSetBodyCharset(p_body, charset);
- else
- APPL_TRACE_ERROR1("bta_ma_parse_body - invalid CHARSET: '%s'", sz);
- }
- else if ( strcmp(sz, "LANGUAGE") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- if ( bta_ma_str_to_language(sz, &language) )
- BTA_MaBmsgSetBodyLanguage(p_body, language);
- else
- APPL_TRACE_ERROR1("bta_ma_parse_body - Invalid LANGUAGE: '%s'", sz);
- }
- else if ( strcmp(sz, "LENGTH") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- /* we don't really care about the length */
- }
- else if ( strcmp(sz, "BEGIN") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
-
- if ( strcmp(sz, "MSG") == 0 )
- {
- p_content = BTA_MaBmsgAddContentToBody(p_body);
- bta_ma_parse_content(p_content, p_stream);
- }
- else
- {
- APPL_TRACE_ERROR1("bta_ma_parse_body - Invalid BEGIN: '%s'", sz);
- }
- }
- else if ( strcmp(sz, "END") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- status = BTA_MA_STATUS_OK;
- break;
- }
- else
- {
- APPL_TRACE_ERROR1("bta_ma_parse_body - Invalid tag: '%s'", sz);
- }
- }
-
- return( status );
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_parse_envelope
-**
-** Description Parses a <bmessage-envelope> from the stream into a
-** generic tBTA_MA_BMSG_ENVELOPE structure. This will parse text
-** until we see "END:BENV" at the start of a line.
-**
-** Parameters p_envelope - pointer to generic envelope structure.
-** p_stream - Input stream.
-**
-** Returns BTA_MA_STATUS_OK if successful. BTA_MA_STATUS_FAIL if not.
-**
-*******************************************************************************/
-tBTA_MA_STATUS bta_ma_parse_envelope(tBTA_MA_BMSG_ENVELOPE * p_envelope,
- tBTA_MA_STREAM * p_stream)
-{
- char sz[BTA_MA_MAX_SIZE];
- tBTA_MA_STATUS status = BTA_MA_STATUS_FAIL;
- tBTA_MA_BMSG_VCARD * p_vcard = NULL;
- tBTA_MA_BMSG_ENVELOPE * p_new_envelope = NULL;
- tBTA_MA_BMSG_BODY * p_body = NULL;
-
- while ( bta_ma_get_tag(p_stream, sz, BTA_MA_MAX_SIZE) )
- {
- if ( strcmp(sz, "BEGIN") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
-
- if ( strcmp(sz, "VCARD") == 0 )
- {
- p_vcard = BTA_MaBmsgAddRecipToEnv(p_envelope);
- bta_ma_parse_vcard(p_vcard, p_stream);
- }
- else if ( strcmp(sz, "BENV") == 0 )
- {
- p_new_envelope = BTA_MaBmsgAddEnvToEnv(p_envelope);
- bta_ma_parse_envelope(p_new_envelope, p_stream);
- }
- else if ( strcmp(sz, "BBODY") == 0 )
- {
- p_body = BTA_MaBmsgAddBodyToEnv(p_envelope);
- bta_ma_parse_body(p_body, p_stream);
- }
- else
- {
- APPL_TRACE_ERROR1("bta_ma_parse_envelope - Invalid BEGIN: '%s'", sz);
- }
-
- }
- else if ( strcmp(sz, "END") == 0 )
- {
- bta_ma_get_value(p_stream, sz, BTA_MA_MAX_SIZE);
- status = BTA_MA_STATUS_OK;
- break;
- }
- else
- {
- APPL_TRACE_ERROR1("bta_ma_parse_envelope - Invalid tag: '%s'", sz);
- }
- }
-
- return( status );
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_vcards
-**
-** Description Builds vCards into a stream.
-**
-** Parameters p_stream - Output stream.
-** p_vcard - pointer to single vCard that may be linked to
-** additional vCards.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ma_stream_vcards(tBTA_MA_STREAM * p_stream,
- tBTA_MA_BMSG_VCARD * p_vcard)
-{
- int x;
-
- /* vCards are formatted one after another */
- while ( p_stream && p_vcard )
- {
- bta_ma_stream_str(p_stream, "\r\nBEGIN:VCARD");
-
- /* version */
- bta_ma_stream_str(p_stream, "\r\nVERSION:");
- bta_ma_stream_str(p_stream,
- p_vcard->version == BTA_MA_VCARD_VERSION_21 ? "2.1" : "3.0");
-
- /* vcard properties */
- for (x=0; x < BTA_MA_VCARD_PROP_MAX; x++)
- bta_ma_stream_vcard_prop(p_stream, p_vcard,(tBTA_MA_VCARD_PROP) x);
-
- bta_ma_stream_str(p_stream, "\r\nEND:VCARD");
-
- /* Get the next vCard and repeat */
- p_vcard = BTA_MaBmsgGetNextVcard(p_vcard);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_vcard_prop
-**
-** Description Builds a property and values into a stream. This will
-** build all of the property/values for one property (i.e.
-** can be multiple EMAIL propeties set). It will only
-** format the property if it has a value (except the N/name
-** if a 2.1 vCard and FN/fullname property of a 3.0 vCard
-** will always be output).
-**
-** Parameters p_stream - Output stream.
-** p_vcard - pointer to vCard.
-** prop - property.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ma_stream_vcard_prop(tBTA_MA_STREAM * p_stream,
- tBTA_MA_BMSG_VCARD * p_vcard,
- tBTA_MA_VCARD_PROP prop)
-{
- tBTA_MA_VCARD_PROPERTY * p_prop;
- tBTA_MA_VCARD_VERSION version;
- char * p_param;
- char * p_value;
-
- if ( p_vcard && prop < BTA_MA_VCARD_PROP_MAX )
- {
- p_prop = BTA_MaBmsgGetVcardProp(p_vcard, prop);
-
- do
- {
- p_param = BTA_MaBmsgGetVcardPropParam(p_prop);
- p_value = BTA_MaBmsgGetVcardPropValue(p_prop);
- version = BTA_MaBmsgGetVcardVersion(p_vcard);
-
- if ( (p_value && strlen(p_value))
- || ((version == BTA_MA_VCARD_VERSION_21) && (prop == BTA_MA_VCARD_PROP_N))
- || ((version == BTA_MA_VCARD_VERSION_30) && (prop <= BTA_MA_VCARD_PROP_FN)) )
- {
- /* property name */
- bta_ma_stream_str(p_stream, "\r\n");
- bta_ma_stream_str(p_stream, vcard_prop_name[prop]);
-
-
- /* property parameter */
- if ( p_param )
- {
- bta_ma_stream_str(p_stream, ";");
- bta_ma_stream_str(p_stream, p_param);
- }
-
- /* property value */
- bta_ma_stream_str(p_stream, ":");
- bta_ma_stream_str(p_stream, p_value);
- }
-
- /* There may be multiple instances of a property (e.g. 2 TEL numbers */
- p_prop = BTA_MaBmsgGetNextVcardProp(p_prop);
-
- } while ( p_prop );
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_envelopes
-**
-** Description Builds a envelope <bmessage-envelope> (or series of
-** envelopes) into a stream.
-**
-** Parameters p_stream - Output stream.
-** p_envelope - pointer to envelope structure.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ma_stream_envelopes(tBTA_MA_STREAM * p_stream,
- tBTA_MA_BMSG_ENVELOPE * p_envelope)
-{
- tBTA_MA_BMSG_BODY * p_body;
-
- if ( p_stream && p_envelope )
- {
- bta_ma_stream_str(p_stream, "\r\nBEGIN:BENV");
-
- /* Recipients */
- bta_ma_stream_vcards(p_stream, BTA_MaBmsgGetRecipFromEnv(p_envelope));
-
- /* It will either be another (nested) envelope or the body */
- p_body = BTA_MaBmsgGetBodyFromEnv(p_envelope);
-
- if ( p_body )
- bta_ma_stream_body(p_stream, p_body);
- else
- bta_ma_stream_envelopes(p_stream, BTA_MaBmsgGetNextEnv(p_envelope));
-
- bta_ma_stream_str(p_stream, "\r\nEND:BENV");
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_body
-**
-** Description Builds a bMessage content <bmessage-content> into a stream.
-**
-** Parameters p_stream - Output stream.
-** p_body - pointer to bBody structure.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ma_stream_body(tBTA_MA_STREAM * p_stream, tBTA_MA_BMSG_BODY * p_body)
-{
- UINT16 part_id = 0;
- tBTA_MA_BMSG_LANGUAGE language;
- tBTA_MA_CHARSET charset;
-
- if ( p_stream && p_body )
- {
- bta_ma_stream_str(p_stream, "\r\nBEGIN:BBODY");
-
- /* Part ID (optional) */
- part_id = BTA_MaBmsgGetBodyPartid(p_body);
- if ( part_id != 0 )
- {
- bta_ma_stream_str(p_stream, "\r\nPARTID:");
- bta_ma_stream_value(p_stream, part_id);
- }
-
- /* Character set */
- charset = BTA_MaBmsgGetBodyCharset(p_body);
- switch ( charset)
- {
- case BTA_MA_CHARSET_UTF_8:
- bta_ma_stream_str(p_stream, "\r\nCHARSET:UTF-8");
- break;
- case BTA_MA_CHARSET_NATIVE:
- bta_ma_stream_str(p_stream, "\r\nCHARSET:NATIVE");
- /* Encoding */
- bta_ma_stream_str(p_stream, "\r\nENCODING:");
- bta_ma_stream_str(p_stream, bmsg_body_encoding[BTA_MaBmsgGetBodyEncoding(p_body)]);
- break;
- default:
- break;
- }
-
- /* Language */
- language = BTA_MaBmsgGetBodyLanguage(p_body);
- if ( language != BTA_MA_BMSG_LANG_UNSPECIFIED )
- {
- bta_ma_stream_str(p_stream, "\r\nLANGUAGE:");
- bta_ma_stream_str(p_stream, bmsg_body_language[language]);
- }
-
- /* Body content length */
- bta_ma_stream_str(p_stream, "\r\nLENGTH:");
- bta_ma_stream_value(p_stream, bta_ma_get_body_length(p_body));
-
- /* Content */
- bta_ma_stream_body_content(p_stream, BTA_MaBmsgGetContentFromBody(p_body));
-
- bta_ma_stream_str(p_stream, "\r\nEND:BBODY");
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_stream_body_content
-**
-** Description Builds a body content <bmessage-body-content> into a stream.
-**
-** Parameters p_stream - Output stream.
-** p_content - pointer to content structure.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ma_stream_body_content(tBTA_MA_STREAM * p_stream,
- tBTA_MA_BMSG_CONTENT * p_content)
-{
- char * p_text;
-
- APPL_TRACE_EVENT0("bta_ma_stream_body_content");
- while ( p_stream && p_content )
- {
- bta_ma_stream_str(p_stream, "\r\nBEGIN:MSG");
-
- p_text = BTA_MaBmsgGetMsgContent(p_content);
- if ( p_text )
- {
- bta_ma_stream_str(p_stream, "\r\n");
-
- while ( p_text )
- {
- bta_ma_stream_str(p_stream, p_text);
- p_text = BTA_MaBmsgGetNextMsgContent(p_content);
- }
- }
-
- bta_ma_stream_str(p_stream, "\r\nEND:MSG");
-
- p_content = BTA_MaBmsgGetNextContent(p_content);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_str_to_charset
-**
-** Description Returns the charset enumeration (tBTA_MA_CHARSET) that
-** corresponds to the provided string.
-**
-** Parameters psz - Input string.
-** p_charset - pointer to the charset value to be received.
-**
-** Returns TRUE if there is a match, otherwise FALSE.
-**
-*******************************************************************************/
-BOOLEAN bta_ma_str_to_charset(char * psz, tBTA_MA_CHARSET * p_charset)
-{
-
- tBTA_MA_CHARSET e;
-
- if ( psz && p_charset )
- {
- for (e= BTA_MA_CHARSET_NATIVE; e < num_bmsg_body_charset; e++)
- {
- if ( strcmp(psz, bmsg_body_charset[e]) == 0 )
- {
- *p_charset = e;
- return( TRUE );
- }
- }
- }
-
- return( FALSE );
-}
-
-
-/*******************************************************************************
-**
-** Function bta_ma_str_to_encoding
-**
-** Description Returns the encoding enumeration (tBTA_MA_BMSG_ENCODING) that
-** corresponds to the provided string.
-**
-** Parameters psz - Input string.
-** p_encoding - pointer to the encoding value to be received.
-**
-** Returns TRUE if there is a match, otherwise FALSE.
-**
-*******************************************************************************/
-BOOLEAN bta_ma_str_to_encoding(char * psz, tBTA_MA_BMSG_ENCODING * p_encoding)
-{
- tBTA_MA_BMSG_ENCODING e;
-
- if ( psz && p_encoding )
- {
- for (e= BTA_MA_BMSG_ENC_8BIT; e < num_bmsg_body_encoding; e++)
- {
- if ( strcmp(psz, bmsg_body_encoding[e]) == 0 )
- {
- *p_encoding = e;
- return( TRUE );
- }
- }
- }
-
- return( FALSE );
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_str_to_language
-**
-** Description Returns the language enumeration (tBTA_MA_BMSG_LANGUAGE) that
-** corresponds to the provided string.
-**
-** Parameters psz - Input string.
-** p_language - pointer to the language value to be received.
-**
-** Returns TRUE if there is a match, otherwise FALSE.
-**
-*******************************************************************************/
-BOOLEAN bta_ma_str_to_language(char * psz, tBTA_MA_BMSG_LANGUAGE * p_language)
-{
- tBTA_MA_BMSG_LANGUAGE l;
-
- if ( psz && p_language )
- {
- for (l=BTA_MA_BMSG_LANG_UNSPECIFIED; l < num_bmsg_body_language; l++)
- {
- if ( strcmp(psz, bmsg_body_language[l]) == 0 )
- {
- *p_language = l;
- return( TRUE );
- }
- }
- }
-
- return( FALSE );
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_str_to_msg_typ
-**
-** Description Returns the message type enumeration (tBTA_MA_MSG_TYPE)
-** that corresponds to the provided string.
-**
-** Parameters psz - Input string.
-** p_msg_type - pointer to the message type value to be
-** received.
-**
-** Returns TRUE if there is a match, otherwise FALSE.
-**
-*******************************************************************************/
-BOOLEAN bta_ma_str_to_msg_typ(char * psz, tBTA_MA_MSG_TYPE * p_msg_type)
-{
- if ( psz && p_msg_type )
- {
- if ( strcmp(psz, "EMAIL") == 0 )
- *p_msg_type = BTA_MA_MSG_TYPE_EMAIL;
- else if ( strcmp(psz, "SMS_GSM") == 0 )
- *p_msg_type = BTA_MA_MSG_TYPE_SMS_GSM;
- else if ( strcmp(psz, "SMS_CDMA") == 0 )
- *p_msg_type = BTA_MA_MSG_TYPE_SMS_CDMA;
- else if ( strcmp(psz, "MMS") == 0 )
- *p_msg_type = BTA_MA_MSG_TYPE_MMS;
- else
- return FALSE;
- }
-
- return( TRUE );
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_get_body_length
-**
-** Description Returns the combined length in characters of the message
-** content.
-**
-** Parameters p_body - pointer to bBody structure.
-**
-** Returns Length of the body message text.
-**
-*******************************************************************************/
-UINT32 bta_ma_get_body_length(tBTA_MA_BMSG_BODY * p_body)
-{
- UINT32 length = 0, len=0;
- tBTA_MA_BMSG_CONTENT * p_content;
- char * p_text;
-
- APPL_TRACE_EVENT0("bta_ma_get_body_length");
-
- p_content = BTA_MaBmsgGetContentFromBody(p_body);
-
- while ( p_content )
- {
- p_text= BTA_MaBmsgGetMsgContent(p_content);
-
- while ( p_text )
- {
- len = strlen(p_text);
- length += (len + BTA_MA_BMSG_BODY_TAG_CTL_LENGTH);
-
- APPL_TRACE_EVENT3("total=%d len=%d text=%s",length, len, p_text);
-
- p_text = BTA_MaBmsgGetNextMsgContent(p_content);
- }
-
- p_content = BTA_MaBmsgGetNextContent(p_content);
- }
-
- APPL_TRACE_EVENT1("bta_ma_get_body_length len=%d", length);
- return( length );
-
-
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_bmsg_free_vcards
-**
-** Description Free buffers used by vVards
-**
-** Parameters p_vcard - Pointer to the first vCard in the linked vCards
-**
-** Returns None
-**
-*******************************************************************************/
-
-void bta_ma_bmsg_free_vcards(tBTA_MA_BMSG_VCARD * p_vcard)
-{
- int x;
-
- if ( p_vcard )
- {
- /* recursively free any linked vCards */
- bta_ma_bmsg_free_vcards((tBTA_MA_BMSG_VCARD *)p_vcard->p_next);
-
- /* Free properties */
- for (x=0; x < BTA_MA_VCARD_PROP_MAX; x++)
- bta_ma_bmsg_free_vcard_prop(p_vcard->p_prop[x]);
-
- /* free vcard structure itself */
- bta_ma_bmsg_free(p_vcard);
- }
-}
-/*******************************************************************************
-**
-** Function bta_ma_bmsg_free_envelope
-**
-** Description Free buffers used by envelopes
-**
-** Parameters p_envelope - Pointer to the first envelope in the linked envelopes
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_ma_bmsg_free_envelope(tBTA_MA_BMSG_ENVELOPE * p_envelope)
-{
- if ( p_envelope )
- {
- /* recursively free any linked envelopes */
- bta_ma_bmsg_free_envelope((tBTA_MA_BMSG_ENVELOPE *)p_envelope->p_next);
-
- /* free the body */
- bta_ma_bmsg_free_body(p_envelope->p_body);
-
- /* free recipients */
- bta_ma_bmsg_free_vcards(p_envelope->p_recip);
-
- /* free envelope structure itself */
- bta_ma_bmsg_free(p_envelope);
- }
-}
-/*******************************************************************************
-**
-** Function bta_ma_bmsg_free_body
-**
-** Description Free buffers used by a message body
-**
-** Parameters p_body - Pointer to a message body
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_ma_bmsg_free_body(tBTA_MA_BMSG_BODY * p_body)
-{
- if ( p_body )
- {
- bta_ma_bmsg_free_content(p_body->p_content);
-
- /* free body structure itself */
- bta_ma_bmsg_free(p_body);
- }
-}
-/*******************************************************************************
-**
-** Function bta_ma_bmsg_free_content
-**
-** Description Free buffers used by message contents
-**
-** Parameters p_envelope - Pointer to the first message content in the
-** linked message contents
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_ma_bmsg_free_content(tBTA_MA_BMSG_CONTENT * p_content)
-{
- if ( p_content )
- {
- /* recursively free any linked content */
- bta_ma_bmsg_free_content((tBTA_MA_BMSG_CONTENT *)p_content->p_next);
-
- /* free all of the message text */
- bta_ma_bmsg_free_message_text(p_content->p_message);
-
- /* free content structure itself */
- bta_ma_bmsg_free(p_content);
- }
-}
-/*******************************************************************************
-**
-** Function bta_ma_bmsg_free_message_text
-**
-** Description Free text string buffers used by a message
-**
-** Parameters p_envelope - Pointer to a message
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_ma_bmsg_free_message_text(tBTA_MA_BMSG_MESSAGE * p_message)
-{
- tBTA_MA_BMSG_MESSAGE * p_temp;
-
- while ( p_message )
- {
- p_temp = (tBTA_MA_BMSG_MESSAGE *)p_message->p_next;
-
- /* free message string */
- bta_ma_bmsg_free(p_message->p_text);
-
- /* free message text structure */
- bta_ma_bmsg_free(p_message);
-
- /* now point to the next one */
- p_message = p_temp;
- }
-}
-/*******************************************************************************
-**
-** Function bta_ma_bmsg_free_vcard_prop
-**
-** Description Free buffers used by a vCard property
-**
-** Parameters p_envelope - Pointer to a vCard property
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_ma_bmsg_free_vcard_prop(tBTA_MA_VCARD_PROPERTY * p_prop)
-{
- if ( p_prop )
- {
- /* free the value and the parameter */
- if ( p_prop->p_value )
- bta_ma_bmsg_free(p_prop->p_value);
-
- if ( p_prop->p_param )
- bta_ma_bmsg_free(p_prop->p_param);
-
- /* recursively free any linked content */
- if ( p_prop->p_next )
- bta_ma_bmsg_free_vcard_prop((tBTA_MA_VCARD_PROPERTY *)p_prop->p_next);
-
- /* free property structure itself */
- bta_ma_bmsg_free(p_prop);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ma_bmsg_alloc
-**
-** Description Allocate buffer for the specified size
-**
-** Parameters cb - request buffer size
-**
-** Returns None
-**
-*******************************************************************************/
-
-void * bta_ma_bmsg_alloc(size_t cb)
-{
- void * p_buf;
-
- if ((p_buf = GKI_getbuf((UINT16) cb)) == NULL )
- {
- APPL_TRACE_ERROR1("Unable to allocate buffer for size=%", (UINT16) cb);
- }
- return(p_buf);
-}
-/*******************************************************************************
-**
-** Function bta_ma_bmsg_free
-**
-** Description Free buffer
-**
-** Parameters p - pointer to a buffer
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_ma_bmsg_free(void * p)
-{
- if ( p )
- GKI_freebuf(p);
-}
-
-
-#endif /* BTA_MSE_INCLUDED */
diff --git a/bta/ma/bta_ma_util.h b/bta/ma/bta_ma_util.h
deleted file mode 100644
index 9040201..0000000
--- a/bta/ma/bta_ma_util.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ma_util.h
-**
-** Description: This is the interface file for the Message Access Profile
-** (MAP) utility functions.
-**
-** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_MA_UTIL_H
-#define BTA_MA_UTIL_H
-
-#include "bta_ma_def.h"
-#include "bta_mse_api.h"
-#include "bta_mse_co.h"
-#include "bta_ma_api.h"
-
-
-#define BTA_MA_MAX_SIZE (100)
-
-/* Here are a set of property flags used to keep track
-** of properties that are successfully parsed. We use
-** this information to determine if all the *required*
-** properties have been provided in the parsed object.
-*/
-#define BTA_MA_PROP_VERSION 0x00000001
-#define BTA_MA_BMSG_BODY_TAG_CTL_LENGTH 22 /* see MAP Spec. Errata 3603 */
- /* BEGIN:MSG<CRTL>+<CRTL>+END:MSG<CRTL> */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- extern const char * bta_ma_evt_typ_to_string(tBTA_MSE_NOTIF_TYPE notif_type);
- extern const char * bta_ma_msg_typ_to_string(tBTA_MA_MSG_TYPE msg_typ);
- extern const char * bta_ma_rcv_status_to_string(tBTA_MSE_CO_RCV_STATUS rcv_status);
-
- extern BOOLEAN bta_ma_stream_str(tBTA_MA_STREAM * p_stream,
- const char * p_str);
-
- extern BOOLEAN bta_ma_stream_buf(tBTA_MA_STREAM * p_stream,
- UINT16 len,
- UINT8 * p_buf);
-
- extern BOOLEAN bta_ma_stream_boolean_yes_no(tBTA_MA_STREAM * p_stream, BOOLEAN val);
-
- extern BOOLEAN bta_ma_stream_value(tBTA_MA_STREAM * p_stream, UINT32 val);
-
- extern BOOLEAN bta_ma_stream_handle(tBTA_MA_STREAM * p_stream,
- tBTA_MA_MSG_HANDLE handle);
-
- extern UINT16 bta_ma_stream_used_size(tBTA_MA_STREAM * p_stream);
-
- extern BOOLEAN bta_ma_stream_ok(tBTA_MA_STREAM * p_stream);
-
- extern void bta_ma_convert_hex_str_to_64bit_handle(char *p_hex_str, tBTA_MA_MSG_HANDLE handle);
-
- extern BOOLEAN bta_ma_get_char(tBTA_MA_STREAM * p_stream, char * p_char);
- extern BOOLEAN bta_ma_str_to_charset(char * psz, tBTA_MA_CHARSET * p_charset);
- extern BOOLEAN bta_ma_str_to_encoding(char * psz, tBTA_MA_BMSG_ENCODING * p_encoding);
- extern BOOLEAN bta_ma_str_to_language(char * psz, tBTA_MA_BMSG_LANGUAGE * p_language);
- extern BOOLEAN bta_ma_str_to_msg_typ(char * psz, tBTA_MA_MSG_TYPE * p_msg_type);
-
- extern void bta_ma_stream_vcards(tBTA_MA_STREAM *, tBTA_MA_BMSG_VCARD *);
- extern void bta_ma_stream_envelopes(tBTA_MA_STREAM * p_stream, tBTA_MA_BMSG_ENVELOPE * p_envelope);
- extern void bta_ma_stream_body(tBTA_MA_STREAM * p_stream, tBTA_MA_BMSG_BODY * p_body);
- extern void bta_ma_stream_body_content(tBTA_MA_STREAM * p_stream, tBTA_MA_BMSG_CONTENT * p_content);
- extern void bta_ma_stream_vcard_prop(tBTA_MA_STREAM * p_stream, tBTA_MA_BMSG_VCARD * p_vcard, tBTA_MA_VCARD_PROP prop);
-
- extern UINT32 bta_ma_get_body_length(tBTA_MA_BMSG_BODY * p_body);
-
- extern UINT16 bta_ma_get_tag(tBTA_MA_STREAM * p_stream, char * psz, UINT16 max_size);
- extern UINT16 bta_ma_get_value(tBTA_MA_STREAM * p_stream, char * psz, UINT16 max_size);
-
- extern tBTA_MA_STATUS bta_ma_parse_vcard(tBTA_MA_BMSG_VCARD * p_vcard, tBTA_MA_STREAM * p_stream);
- extern tBTA_MA_STATUS bta_ma_parse_envelope(tBTA_MA_BMSG_ENVELOPE * p_envelope, tBTA_MA_STREAM * p_stream);
-
- extern void * bta_ma_bmsg_alloc(size_t cb);
- extern void bta_ma_bmsg_free(void * p);
- extern void bta_ma_bmsg_free_vcards(tBTA_MA_BMSG_VCARD * p_vcard);
- extern void bta_ma_bmsg_free_envelope(tBTA_MA_BMSG_ENVELOPE * p_envelope);
- extern void bta_ma_bmsg_free_body(tBTA_MA_BMSG_BODY * p_body);
- extern void bta_ma_bmsg_free_content(tBTA_MA_BMSG_CONTENT * p_content);
- extern void bta_ma_bmsg_free_message_text(tBTA_MA_BMSG_MESSAGE * p_message);
- extern void bta_ma_bmsg_free_vcard_prop(tBTA_MA_VCARD_PROPERTY * p_prop);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BTA_MA_UTIL_H */
diff --git a/bta/ma/bta_mse_act.c b/bta/ma/bta_mse_act.c
deleted file mode 100644
index c8ec487..0000000
--- a/bta/ma/bta_mse_act.c
+++ /dev/null
@@ -1,2763 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_mse_act.c
-**
-** Description: This file contains the message access server action
-** functions for the state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_MSE_INCLUDED) && (BTA_MSE_INCLUDED == TRUE)
-
-#include <string.h>
-#include "gki.h"
-#include "sdp_api.h"
-#include "bta_sys.h"
-#include "port_api.h"
-#include "obx_api.h"
-#include "sdp_api.h"
-#include "bta_fs_api.h"
-#include "bta_mse_api.h"
-#include "bta_mse_int.h"
-#include "bta_fs_co.h"
-#include "utl.h"
-#include "bd.h"
-#include "bta_ma_def.h"
-
-
-/*****************************************************************************
-** Local Function prototypes
-*****************************************************************************/
-void bta_mse_req_app_access(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
-static void bta_mse_mn_sdp_cback0(UINT16 status);
-static void bta_mse_mn_sdp_cback1(UINT16 status);
-static void bta_mse_mn_sdp_cback2(UINT16 status);
-static void bta_mse_mn_sdp_cback3(UINT16 status);
-static void bta_mse_mn_sdp_cback4(UINT16 status);
-static void bta_mse_mn_sdp_cback5(UINT16 status);
-static void bta_mse_mn_sdp_cback6(UINT16 status);
-
-static tSDP_DISC_CMPL_CB * const bta_mse_mn_sdp_cback_arr[] = {
- bta_mse_mn_sdp_cback0,
- bta_mse_mn_sdp_cback1,
- bta_mse_mn_sdp_cback2,
- bta_mse_mn_sdp_cback3,
- bta_mse_mn_sdp_cback4,
- bta_mse_mn_sdp_cback5,
- bta_mse_mn_sdp_cback6
-};
-
-#if (BTA_MSE_DEBUG == TRUE) && (BT_USE_TRACES == TRUE)
-static char *bta_mse_obx_evt_code(UINT16 evt_code);
-#endif
-
-
-/*******************************************************************************
-** Message Access Server (MAS) Action functions
-**
-*******************************************************************************/
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_int_close
-**
-** Description Porcesses the Internal MAS session close event
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_int_close(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- BD_ADDR bd_addr;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_int_close inst idx=%d sess idx=%d",inst_idx, sess_idx);
-#endif
-
- if (OBX_GetPeerAddr(p_cb->obx_handle, bd_addr) != 0)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("Send Obx Discon rsp obx session id=%d",
- p_cb->obx_handle);
-#endif
- /* resources will be freed at BTA_MSE_MA_OBX_CLOSE_EVT */
- OBX_DisconnectRsp(p_cb->obx_handle, OBX_RSP_SERVICE_UNAVL, NULL);
- }
- else
- {
- /* OBX close already */
- bta_mse_ma_sm_execute(inst_idx, sess_idx, BTA_MSE_MA_OBX_CLOSE_EVT, p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_api_upd_ibx_rsp
-**
-** Description Processes the API update inbox response event.
-** If permission had been granted, continue the operation,
-** otherwise stop the operation.
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_api_upd_ibx_rsp(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- UINT8 rsp_code = OBX_RSP_UNAUTHORIZED;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_api_upd_ibx_rsp inst idx=%d sess idx=%d",inst_idx, sess_idx);
-#endif
-
- /* Process the currently active access response */
- if (p_cb->oper == BTA_MSE_OPER_UPDATE_INBOX)
- {
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_NONE);
- if (p_data->api_upd_ibx_rsp.rsp == BTA_MSE_UPDATE_INBOX_ALLOW)
- {
- bta_mse_co_update_inbox(p_cb->obx_handle, bta_mse_cb.app_id);
- rsp_code = OBX_RSP_OK;
- }
- OBX_PutRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- }
- else
- {
- APPL_TRACE_WARNING1("MSE UPDIBXRSP: Unknown tBTA_MSE_OPER value (%d)",
- p_cb->oper);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_api_set_notif_reg_rsp
-**
-** Description Processes the API set notification registration response event.
-** If permission had been granted, continue the operation,
-** otherwise stop the operation.
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_api_set_notif_reg_rsp(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- UINT8 rsp_code = OBX_RSP_SERVICE_UNAVL;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_api_set_notif_reg_rsp inst idx=%d sess idx=%d",inst_idx, sess_idx);
-#endif
-
- /* Process the currently active access response */
- if ( p_cb->oper == BTA_MSE_OPER_NOTIF_REG)
- {
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_NONE);
- if (p_data->api_set_notif_reg_rsp.rsp == BTA_MSE_SET_NOTIF_REG_ALLOW)
- {
- bta_mse_proc_notif_reg_status(p_cb->notif_reg_req.notif_status,
- inst_idx, sess_idx);
- }
- else
- {
- OBX_PutRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- }
- }
- else
- {
- APPL_TRACE_WARNING1("MSE SETNOTIFREGRSP: Unknown tBTA_MSE_OPER value (%d)",
- p_cb->oper);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_api_accessrsp
-**
-** Description Processes the API access response event.
-** If permission had been granted, continue the operation,
-** otherwise stop the operation.
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-
-void bta_mse_ma_api_accessrsp(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- UINT8 rsp_code = OBX_RSP_OK;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT3("bta_mse_ma_api_accessrsp inst idx=%d sess idx=%d access_rsp=%d",
- inst_idx, sess_idx,
- p_data->api_access_rsp.rsp);
-#endif
-
- if (p_cb->oper != p_data->api_access_rsp.oper )
- {
- APPL_TRACE_WARNING2("MSE MA ACCRSP: not match active:%d, rsp:%d",
- p_cb->oper, p_data->api_access_rsp.oper);
- return;
- }
-
- /* Process the currently active access response */
- switch (p_cb->oper)
- {
- case BTA_MSE_OPER_SETPATH:
-
- if (p_data->api_access_rsp.rsp == BTA_MA_ACCESS_TYPE_ALLOW)
- {
- bta_mse_co_set_folder( p_cb->obx_handle, p_cb->sp.p_path, bta_mse_cb.app_id);
- /* updat the working dir */
- BCM_STRNCPY_S(p_cb->p_workdir, p_bta_fs_cfg->max_path_len+1, p_cb->sp.p_path, p_bta_fs_cfg->max_path_len);
- }
- else
- {
- rsp_code = OBX_RSP_UNAUTHORIZED;
- }
-
- utl_freebuf((void**)&(p_cb->sp.p_path));
- utl_freebuf((void**)&(p_cb->sp.p_name));
- OBX_SetPathRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_NONE);
- break;
-
- case BTA_MSE_OPER_GET_MSG_LIST:
-
- if (p_data->api_access_rsp.rsp == BTA_MA_ACCESS_TYPE_ALLOW)
- {
- bta_mse_getmsglist(inst_idx,sess_idx, TRUE);
- }
- else
- {
- OBX_GetRsp(p_cb->obx_handle, OBX_RSP_UNAUTHORIZED, (BT_HDR *)NULL);
- bta_mse_clean_msg_list(inst_idx,sess_idx);
- }
- break;
-
- case BTA_MSE_OPER_GET_MSG:
-
- if (p_data->api_access_rsp.rsp == BTA_MA_ACCESS_TYPE_ALLOW)
- {
- bta_mse_getmsg(inst_idx,sess_idx, TRUE);
- }
- else
- {
- OBX_GetRsp(p_cb->obx_handle, OBX_RSP_UNAUTHORIZED, (BT_HDR *)NULL);
- bta_mse_clean_msg(inst_idx,sess_idx);
- }
- break;
-
- case BTA_MSE_OPER_PUSH_MSG:
-
- if (p_data->api_access_rsp.rsp == BTA_MA_ACCESS_TYPE_ALLOW)
- {
- bta_mse_pushmsg(inst_idx, sess_idx, TRUE);
- }
- else
- {
- OBX_PutRsp(p_cb->obx_handle, OBX_RSP_UNAUTHORIZED, (BT_HDR *)NULL);
- bta_mse_clean_push_msg(inst_idx,sess_idx);
- }
- break;
-
- case BTA_MSE_OPER_DEL_MSG:
-
- if (p_data->api_access_rsp.rsp == BTA_MA_ACCESS_TYPE_ALLOW)
- {
- p_cb->cout_active = TRUE;
- bta_mse_co_set_msg_delete_status((tBTA_MA_SESS_HANDLE) p_cb->obx_handle,
- p_cb->set_msg_sts.handle,
- p_cb->set_msg_sts.sts_val,
- BTA_MSE_CI_DEL_MSG_EVT,
- bta_mse_cb.app_id);
- }
- else
- {
- OBX_PutRsp(p_cb->obx_handle, OBX_RSP_UNAUTHORIZED, (BT_HDR *)NULL);
- bta_mse_clean_set_msg_sts(inst_idx,sess_idx);
- }
- break;
-
- default:
- APPL_TRACE_WARNING1("MSE ACCRSP: Unknown tBTA_MSE_OPER value (%d)",
- p_cb->oper);
- break;
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_ci_get_folder_entry
-**
-** Description Proceses the get folder entry call-in event
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_ci_get_folder_entry(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- UINT8 rsp_code = OBX_RSP_PART_CONTENT;
- BOOLEAN free_pkt = TRUE;
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_ci_get_folder_entry inst idx=%d sess idx=%d",
- inst_idx, sess_idx);
-#endif
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->aborting)
- {
- bta_mse_clean_getput(inst_idx,sess_idx, BTA_MA_STATUS_ABORTED);
- return;
- }
-
- /* Process dirent listing call-in event if operation is still active */
- if (p_cb->oper == BTA_MSE_OPER_GET_FOLDER_LIST)
- {
- switch (p_data->ci_get_fentry.status)
- {
- case BTA_MA_STATUS_OK: /* Valid new entry */
- free_pkt = FALSE;
- rsp_code = bta_mse_add_list_entry(inst_idx, sess_idx);
- break;
-
- case BTA_MA_STATUS_EODIR: /* End of list (entry not valid) */
- free_pkt = FALSE;
- rsp_code = OBX_RSP_OK;
- break;
-
- case BTA_MA_STATUS_FAIL: /* Error occurred */
- rsp_code = OBX_RSP_NOT_FOUND;
- break;
-
- default:
- APPL_TRACE_ERROR1("bta_mse_ma_ci_get_folder_entry Unknown status=%d ",
- p_data->ci_get_fentry.status );
- rsp_code = OBX_RSP_NOT_FOUND;
- break;
- }
- }
-
- if (rsp_code != OBX_RSP_PART_CONTENT)
- bta_mse_end_of_list(inst_idx, sess_idx,rsp_code);
-
- if (free_pkt)
- utl_freebuf((void **)&p_cb->obx.p_pkt);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_ci_get_ml_info
-**
-** Description Proceses the get message list info call-in event
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_ci_get_ml_info(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- UINT8 rsp_code = OBX_RSP_PART_CONTENT;
- BOOLEAN free_pkt = TRUE;
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_ci_get_ml_info inst idx=%d sess idx=%d",
- inst_idx, sess_idx);
-#endif
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->aborting)
- {
- bta_mse_clean_getput(inst_idx,sess_idx, BTA_MA_STATUS_ABORTED);
- return;
- }
-
- /* Process dirent listing call-in event if operation is still active */
- if (p_cb->oper == BTA_MSE_OPER_GET_MSG_LIST)
- {
- switch (p_data->ci_get_ml_info.status)
- {
- case BTA_MA_STATUS_OK: /* Valid new entry */
- free_pkt = FALSE;
- rsp_code = bta_mse_add_msg_list_info(inst_idx, sess_idx);
- break;
-
- case BTA_MA_STATUS_EODIR: /* End of list (entry not valid) */
- free_pkt = FALSE;
- rsp_code = OBX_RSP_OK;
- break;
-
- case BTA_MA_STATUS_FAIL: /* Error occurred */
- rsp_code = OBX_RSP_NOT_FOUND;
- break;
-
- default:
- APPL_TRACE_ERROR1("bta_mse_ma_ci_get_ml_info Unknown status=%d ",
- p_data->ci_get_ml_info.status );
- rsp_code = OBX_RSP_NOT_FOUND;
- break;
- }
- }
-
- if (rsp_code != OBX_RSP_PART_CONTENT)
- bta_mse_end_of_msg_list(inst_idx, sess_idx,rsp_code);
-
- if (free_pkt)
- utl_freebuf((void **)&p_cb->obx.p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_ci_get_msg_entry
-**
-** Description Proceses the get message entry call-in event
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_ci_get_ml_entry(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- UINT8 rsp_code = OBX_RSP_PART_CONTENT;
- BOOLEAN free_pkt = TRUE;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_ci_get_msg_entry inst idx=%d sess idx=%d",inst_idx, sess_idx);
- APPL_TRACE_EVENT1(" status=%d",p_data->ci_get_ml_entry.status);
-#endif
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->aborting)
- {
- bta_mse_clean_getput(inst_idx,sess_idx, BTA_MA_STATUS_ABORTED);
- return;
- }
-
- /* Process dirent listing call-in event if operation is still active */
- if (p_cb->oper == BTA_MSE_OPER_GET_MSG_LIST)
- {
- switch (p_data->ci_get_ml_entry.status)
- {
- case BTA_MA_STATUS_OK: /* Valid new entry */
- free_pkt = FALSE;
- rsp_code = bta_mse_add_msg_list_entry(inst_idx, sess_idx);
- break;
-
- case BTA_MA_STATUS_EODIR: /* End of list (entry not valid) */
- free_pkt = FALSE;
- rsp_code = OBX_RSP_OK;
- break;
-
- case BTA_MA_STATUS_FAIL: /* Error occurred */
- rsp_code = OBX_RSP_NOT_FOUND;
- break;
-
- default:
- APPL_TRACE_ERROR1("bta_mse_ma_ci_get_ml_entry Unknown status=%d ",
- p_data->ci_get_ml_entry.status);
- rsp_code = OBX_RSP_NOT_FOUND;
- break;
- }
- }
-
- if (rsp_code != OBX_RSP_PART_CONTENT)
- bta_mse_end_of_msg_list(inst_idx, sess_idx,rsp_code);
-
- if (free_pkt)
- utl_freebuf((void **)&p_cb->obx.p_pkt);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_ci_get_msg
-**
-** Description Proceses the get message call-in event
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_ci_get_msg(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OPER_MSG_PARAM *p_param = &p_cb->msg_param;
- tBTA_MSE_CI_GET_MSG *p_ci_get_msg = &p_data->ci_get_msg;
- UINT8 rsp_code = OBX_RSP_NOT_FOUND;
- BOOLEAN free_pkt = TRUE, end_of_msg= TRUE;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_ci_get_msg inst idx=%d sess idx=%d",
- inst_idx, sess_idx);
- APPL_TRACE_EVENT1("status=%d",p_data->ci_get_ml_entry.status);
-#endif
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->aborting)
- {
- bta_mse_clean_getput(inst_idx,sess_idx, BTA_MA_STATUS_ABORTED);
- return;
- }
-
- /* Process get msg call-in event if operation is still active */
- if (p_cb->oper == BTA_MSE_OPER_GET_MSG)
- {
- switch (p_data->ci_get_msg.status)
- {
- case BTA_MA_STATUS_OK: /* Valid new entry */
- free_pkt = FALSE;
- p_param->frac_deliver_status = p_ci_get_msg->frac_deliver_status;
- p_param->filled_buff_size = p_ci_get_msg->filled_buff_size;
-
- if ( p_ci_get_msg->multi_pkt_status == BTA_MA_MPKT_STATUS_MORE)
- {
- p_param->byte_get_cnt += p_param->filled_buff_size;
- rsp_code = OBX_RSP_CONTINUE;
- }
- else
- rsp_code = OBX_RSP_OK;
-
- break;
-
- case BTA_MA_STATUS_FAIL: /* Error occurred */
- break;
-
- default:
- end_of_msg = FALSE;
- break;
- }
- }
-
- if (end_of_msg)
- bta_mse_end_of_msg(inst_idx, sess_idx,rsp_code);
-
- if (free_pkt)
- utl_freebuf((void **)&p_cb->obx.p_pkt);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_ci_push_msg
-**
-** Description Proceses the push message call-in event
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_ci_push_msg(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- UINT8 rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- BOOLEAN free_pkt = TRUE;
- char handle_buf[BTA_MSE_64BIT_HEX_STR_SIZE];
- tBTA_MA_STREAM strm;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_ci_push_msg inst idx=%d sess idx=%d",
- inst_idx, sess_idx);
- APPL_TRACE_EVENT4(" status=%d ci_last_pkt=%d obx_final=%d oper=%d",
- p_data->ci_push_msg.status,
- p_data->ci_push_msg.last_packet,
- p_obx->final_pkt,
- p_cb->oper);
-#endif
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->aborting)
- {
- bta_mse_clean_getput(inst_idx,sess_idx, BTA_MA_STATUS_ABORTED);
- return;
- }
-
- /* Process get msg call-in event if operation is still active */
- if (p_cb->oper == BTA_MSE_OPER_PUSH_MSG)
- {
- switch (p_data->ci_push_msg.status)
- {
- case BTA_MA_STATUS_OK: /* Valid new entry */
- if (p_obx->final_pkt)
- {
- APPL_TRACE_EVENT2("final pkt: status=%d oper=%d",
- p_data->ci_push_msg.status, p_cb->oper);
-
- utl_freebuf((void**)&p_obx->p_pkt);
-
- rsp_code = OBX_RSP_OK;
-
- p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle,
- /* p_cb->peer_mtu */ HCI_CMD_POOL_BUF_SIZE);
- if (p_obx->p_pkt)
- {
- memset(handle_buf, 0,BTA_MSE_64BIT_HEX_STR_SIZE);
- BTA_MaInitMemStream(&strm,(UINT8 *) handle_buf, BTA_MSE_64BIT_HEX_STR_SIZE);
- bta_ma_stream_handle(&strm, p_data->ci_push_msg.handle);
- if (OBX_AddUtf8NameHdr(p_obx->p_pkt, (UINT8 *)handle_buf))
- {
- rsp_code = OBX_RSP_OK;
- free_pkt = FALSE;
- }
- else
- {
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- }
- else
- {
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- }
- else
- rsp_code = OBX_RSP_CONTINUE;
- break;
-
- case BTA_MA_STATUS_FAIL: /* Error occurred */
- rsp_code = OBX_RSP_UNAUTHORIZED;
- break;
- default:
- break;
- }
- }
-
- if (rsp_code==OBX_RSP_OK)
- {
- OBX_PutRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* Do not deallocate buffer; OBX will */
- }
- else
- {
- OBX_PutRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- }
-
-
- if (rsp_code == OBX_RSP_CONTINUE)
- {
- bta_mse_send_push_msg_in_prog_evt(inst_idx,sess_idx);
- }
- else
- {
- if ((rsp_code != OBX_RSP_OK) ||
- ((p_obx->final_pkt) &&(rsp_code == OBX_RSP_OK)))
- {
- bta_mse_send_oper_cmpl_evt(inst_idx,sess_idx, p_data->ci_push_msg.status);
- bta_mse_clean_push_msg(inst_idx,sess_idx);
- }
- }
-
- if (free_pkt) utl_freebuf((void**)&p_obx->p_pkt);
-
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_ci_del_msg
-**
-** Description Proceses the delete message call-in event
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_ci_del_msg(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- UINT8 rsp_code = OBX_RSP_OK;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_ci_del_msg inst idx=%d sess idx=%d",
- inst_idx, sess_idx);
- APPL_TRACE_EVENT2(" status=%d oper=%d",p_data->ci_del_msg.status, p_cb->oper);
-#endif
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->aborting)
- {
- /* too late to abort now*/
- bta_mse_abort_too_late(inst_idx,sess_idx);
- }
-
- /* Process get msg call-in event if operation is still active */
- if (p_cb->oper == BTA_MSE_OPER_DEL_MSG)
- {
- switch (p_data->ci_del_msg.status)
- {
- case BTA_MA_STATUS_OK:
- rsp_code = OBX_RSP_OK;
- break;
-
- case BTA_MA_STATUS_FAIL: /* Error occurred */
- rsp_code = OBX_RSP_FORBIDDEN;
- break;
- default:
- break;
- }
- }
-
- OBX_PutRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- bta_mse_clean_set_msg_sts(inst_idx,sess_idx);
-
-}
-/*******************************************************************************
-**
-** Function bta_mse_ma_obx_connect
-**
-** Description Proceses the obx connect request to open a MAS session
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_obx_connect(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_CB *p_scb = BTA_MSE_GET_INST_CB_PTR(inst_idx);
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_MSE cback_evt_data;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_obx_connect inst idx=%d sess idx=%d",
- inst_idx, sess_idx);
-#endif
-
- p_cb->peer_mtu = p_evt->param.conn.mtu;
- p_cb->obx_handle = p_evt->handle;
- memcpy(p_cb->bd_addr, p_evt->param.conn.peer_addr, BD_ADDR_LEN);
-
- OBX_ConnectRsp(p_evt->handle, OBX_RSP_OK, (BT_HDR *)NULL);
-
- /* Reset to the root directory */
- BCM_STRNCPY_S(p_cb->p_workdir, p_bta_fs_cfg->max_path_len+1, p_scb->p_rootpath, p_bta_fs_cfg->max_path_len);
-
- /* inform role manager */
- bta_mse_pm_conn_open(p_cb->bd_addr);
-
- bdcpy(cback_evt_data.ma_open.bd_addr, p_cb->bd_addr);
- BCM_STRNCPY_S((char *)cback_evt_data.ma_open.dev_name, sizeof(cback_evt_data.ma_open.dev_name),
- "", BTM_MAX_REM_BD_NAME_LEN);
- cback_evt_data.ma_open.mas_instance_id = p_scb->mas_inst_id;
- cback_evt_data.ma_open.mas_session_id = p_cb->obx_handle;
-
- bta_mse_cb.p_cback(BTA_MSE_MA_OPEN_EVT, (tBTA_MSE *) &cback_evt_data);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-
-}
-/*******************************************************************************
-**
-** Function bta_mse_ma_obx_disc
-**
-** Description Proceses the obx disconnect request to close a MAS session
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_obx_disc(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_OBX_EVT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_obx_disc inst idx=%d sess idx=%d",
- inst_idx, sess_idx);
-#endif
- rsp_code = (p_evt->obx_event == OBX_DISCONNECT_REQ_EVT) ? OBX_RSP_OK
- : OBX_RSP_BAD_REQUEST;
- OBX_DisconnectRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-/*******************************************************************************
-**
-** Function bta_mse_ma_obx_close
-**
-** Description Proceses the obx close indication to close a MAS connection
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_obx_close(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_obx_close inst idx=%d sess idx=%d",
- inst_idx, sess_idx);
-#endif
- /* finished if not waiting on a call-in function */
- if (!p_cb->cout_active)
- bta_mse_ma_sm_execute(inst_idx, sess_idx, BTA_MSE_CLOSE_CMPL_EVT, p_data);
-
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_obx_abort
-**
-** Description Proceses the obx abort request
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_obx_abort(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_EVT *p_evt = &p_data->obx_evt;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT3("bta_mse_ma_obx_abort inst idx=%d sess idx=%d oper=%d",
- inst_idx, sess_idx, p_cb->oper);
-#endif
-
- utl_freebuf((void**)&p_evt->p_pkt);
-
- switch (p_cb->oper)
- {
- case BTA_MSE_OPER_SETPATH:
- case BTA_MSE_OPER_NONE:
- OBX_AbortRsp(p_evt->handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
- return;
- default:
- break;
-
- }
-
- if (!p_cb->cout_active)
- {
- bta_mse_clean_getput(inst_idx,sess_idx, BTA_MA_STATUS_ABORTED);
- }
- else /* Delay the response if a call-out function is active */
- p_cb->aborting = TRUE;
-
-}
-/*******************************************************************************
-**
-** Function bta_mse_ma_obx_put
-**
-** Description Proceses the obx put request
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_obx_put(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_MSE_OPER_PUSH_MSG *p_push_msg = &p_cb->push_msg;
- tBTA_MSE_OPER_SET_MSG_STS *p_set_msg_sts = &p_cb->set_msg_sts;
- tBTA_MA_SESS_HANDLE mas_session_id;
- UINT16 len;
- UINT8 *p_type;
- UINT8 *p_param;
- UINT8 rsp_code = OBX_RSP_OK;
- UINT8 num_hdrs;
- BOOLEAN free_pkt = TRUE;
- BOOLEAN send_rsp = TRUE;
- BOOLEAN send_ok_rsp = FALSE;
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_obx_put inst idx=%d sess idx=%d",
- inst_idx, sess_idx);
-#endif
-
- if (OBX_ReadTypeHdr(p_evt->p_pkt, &p_type, &len))
- {
- if (!memcmp(p_type, BTA_MA_HDR_TYPE_NOTIF_REG, len))
- {
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_NOTIF_REG);
- }
- else if (!memcmp(p_type, BTA_MA_HDR_TYPE_MSG, len))
- {
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_PUSH_MSG);
- bta_mse_init_push_msg(inst_idx, sess_idx, &rsp_code);
- if (rsp_code != OBX_RSP_OK)
- {
- OBX_PutRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- bta_mse_clean_push_msg(inst_idx, sess_idx);
- return;
- }
- }
- else if (!memcmp(p_type, BTA_MA_HDR_TYPE_MSG_UPDATE, len))
- {
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_UPDATE_INBOX);
- }
- else if (!memcmp(p_type, BTA_MA_HDR_TYPE_MSG_STATUS, len))
- {
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_SET_MSG_STATUS);
- bta_mse_init_set_msg_sts(inst_idx, sess_idx, &rsp_code);
- if (rsp_code != OBX_RSP_OK)
- {
- OBX_PutRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- bta_mse_clean_set_msg_sts(inst_idx, sess_idx);
- return;
- }
- }
- }
-
- switch ( p_cb->oper)
- {
- case BTA_MSE_OPER_NOTIF_REG:
-
- p_param = bta_mse_read_app_params(p_evt->p_pkt, BTA_MA_APH_NOTIF_STATUS, &len);
- if (p_param)
- {
- p_cb->notif_reg_req.notif_status_rcv = TRUE;
- BE_STREAM_TO_UINT8(p_cb->notif_reg_req.notif_status, p_param);
- }
-
- if (p_evt->param.put.final)
- {
- /* check end of body is included or not */
-
- if ((num_hdrs = OBX_ReadBodyHdr(p_evt->p_pkt, &p_obx->p_start, &p_obx->offset, &p_obx->final_pkt)) &&
- p_obx->final_pkt)
- {
- if (p_cb->notif_reg_req.notif_status_rcv)
- {
- if (!bta_mse_send_set_notif_reg(p_cb->notif_reg_req.notif_status,
- inst_idx, sess_idx))
- {
- OBX_PutRsp(p_evt->handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
- }
- else
- {
- /* wait for the set notif reg response from the application*/
- break;
- }
- }
- else
- {
- OBX_PutRsp(p_evt->handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
- }
- }
- else
- {
- OBX_PutRsp(p_evt->handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
- }
- /* if reach here this is a bad request case so clean up*/
- bta_mse_clean_set_notif_reg(inst_idx,sess_idx);
- }
- else
- {
- OBX_PutRsp(p_evt->handle, OBX_RSP_CONTINUE, (BT_HDR *)NULL);
- }
-
- break;
- case BTA_MSE_OPER_PUSH_MSG:
-
- if ((!p_push_msg->rcv_folder_name) &&
- (OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *)p_push_msg->param.p_folder,
- p_bta_mse_cfg->max_name_len)))
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("Rcv folder len=%d, name=%s ",
- strlen( p_push_msg->param.p_folder),
- p_push_msg->param.p_folder);
-#endif
- p_push_msg->rcv_folder_name = TRUE;
- }
-
- if (!p_push_msg->rcv_charset)
- {
- p_param = bta_mse_read_app_params(p_evt->p_pkt, BTA_MA_APH_CHARSET, &len);
- if (p_param)
- {
-
- p_push_msg->rcv_charset = TRUE;
- BE_STREAM_TO_UINT8(p_push_msg->param.charset, p_param);
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("Rcv Charset=%d(0-native 1-UTF8)",p_push_msg->param.charset);
-#endif
- }
- }
-
- if (!p_push_msg->rcv_transparent)
- {
- p_param = bta_mse_read_app_params(p_evt->p_pkt, BTA_MA_APH_TRANSPARENT, &len);
- if (p_param)
- {
- p_push_msg->rcv_transparent = TRUE;
- BE_STREAM_TO_UINT8(p_push_msg->param.transparent, p_param);
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("Rcv Transparent=%d",p_push_msg->param.transparent);
-#endif
- }
- }
-
- if (!p_push_msg->rcv_retry)
- {
- p_param = bta_mse_read_app_params(p_evt->p_pkt, BTA_MA_APH_RETRY, &len);
- if (p_param)
- {
- p_push_msg->rcv_retry = TRUE;
- BE_STREAM_TO_UINT8(p_push_msg->param.retry, p_param);
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("Rcv Retry=%d",p_push_msg->param.retry);
-#endif
- }
- }
-
- /* Read the body header from the obx packet */
- num_hdrs = OBX_ReadBodyHdr(p_evt->p_pkt, &p_obx->p_start, &p_obx->offset,
- &p_obx->final_pkt);
- /* process body or end of body header */
- if (num_hdrs >= 1 )
- {
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT3("Rcv Body or EndOfBody body_hdr=%d len=%d final=%d",
- num_hdrs,
- p_obx->offset,
- p_obx->final_pkt);
-#endif
-
- if (p_push_msg->rcv_charset && p_push_msg->rcv_folder_name)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("Rcv all Required params");
-#endif
-
- free_pkt = FALSE;
- p_obx->p_pkt = p_evt->p_pkt;
- if (p_push_msg->first_req_pkt)
- {
- p_push_msg->first_req_pkt = FALSE;
- bta_mse_req_app_access( inst_idx, sess_idx, p_data);
- }
- else
- {
- bta_mse_pushmsg(inst_idx, sess_idx, FALSE);
- }
- send_rsp = FALSE;
- }
- else
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_ERROR0("Not all Mandatory params are rcv before body/EndofBody: bad request");
-#endif
- rsp_code = OBX_RSP_BAD_REQUEST;
- }
- }
- else
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("No Body or End of Body in this push msg pkt");
-#endif
- }
-
- if (!p_obx->final_pkt)
- {
- if (rsp_code != OBX_RSP_BAD_REQUEST)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("Not a final pkt and no error set rsp_code=Continue");
-#endif
- rsp_code = OBX_RSP_CONTINUE;
- }
- }
-
- if (send_rsp) OBX_PutRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- if (rsp_code == OBX_RSP_BAD_REQUEST )
- {
- if (!p_push_msg->first_req_pkt)
- bta_mse_send_oper_cmpl_evt(inst_idx,sess_idx, BTA_MA_STATUS_FAIL);
- bta_mse_clean_push_msg(inst_idx,sess_idx);
- }
- break;
- case BTA_MSE_OPER_UPDATE_INBOX:
-
- if (p_evt->param.put.final)
- {
- /* check enod of body is included or not */
-
- if ((num_hdrs = OBX_ReadBodyHdr(p_evt->p_pkt, &p_obx->p_start, &p_obx->offset, &p_obx->final_pkt)) &&
- p_obx->final_pkt)
- {
-
- mas_session_id = (tBTA_MA_SESS_HANDLE) p_cb->obx_handle;
- bta_mse_cb.p_cback(BTA_MSE_UPDATE_INBOX_EVT, (tBTA_MSE *)&mas_session_id);
- }
- else
- {
- OBX_PutRsp(p_evt->handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
- }
- }
- else
- {
- OBX_PutRsp(p_evt->handle, OBX_RSP_CONTINUE, (BT_HDR *)NULL);
- }
-
-
- break;
- case BTA_MSE_OPER_SET_MSG_STATUS:
-
-
- if ((!p_set_msg_sts->rcv_msg_handle) &&
- (OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *)p_set_msg_sts->p_msg_handle,
- BTA_MSE_64BIT_HEX_STR_SIZE)))
- {
- bta_ma_convert_hex_str_to_64bit_handle(p_set_msg_sts->p_msg_handle,
- p_set_msg_sts->handle);
- p_set_msg_sts->rcv_msg_handle = TRUE;
- }
-
- if (!p_set_msg_sts->rcv_sts_ind)
- {
- p_param = bta_mse_read_app_params(p_evt->p_pkt, BTA_MA_APH_STS_INDCTR, &len);
- if (p_param)
- {
- p_set_msg_sts->rcv_sts_ind = TRUE;
- BE_STREAM_TO_UINT8(p_set_msg_sts->sts_ind, p_param);
- }
- }
-
- if (!p_set_msg_sts->rcv_sts_val)
- {
- p_param = bta_mse_read_app_params(p_evt->p_pkt, BTA_MA_APH_STS_VALUE, &len);
- if (p_param)
- {
- p_set_msg_sts->rcv_sts_val = TRUE;
- BE_STREAM_TO_UINT8(p_set_msg_sts->sts_val, p_param);
- }
- }
-
- /* Read the body header from the obx packet */
- num_hdrs = OBX_ReadBodyHdr(p_evt->p_pkt, &p_obx->p_start, &p_obx->offset,
- &p_obx->final_pkt);
- /* process body or end of body header */
- if ((num_hdrs >= 1 && p_obx->final_pkt ) )
- {
- if (p_set_msg_sts->rcv_msg_handle && p_set_msg_sts->rcv_sts_ind &&
- p_set_msg_sts->rcv_sts_val)
- {
- if (p_set_msg_sts->sts_ind == BTA_MA_STS_INDTR_DELETE)
- {
- p_cb->oper = BTA_MSE_OPER_DEL_MSG;
- bta_mse_req_app_access( inst_idx, sess_idx, p_data);
- }
- else
- {
- if (bta_mse_co_set_msg_read_status((tBTA_MA_SESS_HANDLE) p_cb->obx_handle,
- p_set_msg_sts->handle,
- p_set_msg_sts->sts_val,
- bta_mse_cb.app_id) != BTA_MA_STATUS_OK)
- {
- rsp_code = OBX_RSP_FORBIDDEN;
- }
- send_ok_rsp = TRUE;
- }
- }
- else
- {
- rsp_code = OBX_RSP_BAD_REQUEST;
- }
- }
-
- if (!p_obx->final_pkt)
- {
- if (rsp_code != OBX_RSP_BAD_REQUEST)
- {
- rsp_code = OBX_RSP_CONTINUE;
- }
- }
-
- if (rsp_code != OBX_RSP_OK)
- {
- OBX_PutRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- if (rsp_code == OBX_RSP_BAD_REQUEST )
- {
- bta_mse_clean_set_msg_sts(inst_idx,sess_idx);
- }
- }
- else
- {
- if (send_ok_rsp)
- {
- OBX_PutRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- bta_mse_clean_set_msg_sts(inst_idx,sess_idx);
- }
- }
- break;
- default:
- OBX_PutRsp(p_evt->handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
- break;
- }
-
- /* Done with Obex packet */
- if (free_pkt) utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_obx_get
-**
-** Description Proceses the obx get request
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_obx_get(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_EVT *p_evt = &p_data->obx_evt;
- UINT16 len;
- UINT8 *p_type;
- tBTA_MSE_MA_GET_ACT get_act = BTA_MSE_MA_GET_ACT_NONE;
- tBTA_MSE_MA_GET_TYPE get_type = BTA_MSE_MA_GET_TYPE_NONE;
- UINT8 rsp_code = OBX_RSP_BAD_REQUEST;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_obx_get inst idx=%d sess idx=%d",inst_idx, sess_idx);
- APPL_TRACE_EVENT1(" oper=%d",p_cb->oper );
-#endif
- switch (p_cb->oper)
- {
- case BTA_MSE_OPER_GET_FOLDER_LIST:
- get_type = BTA_MSE_MA_GET_TYPE_CON_FOLDER_LIST;
- break;
- case BTA_MSE_OPER_GET_MSG_LIST:
- get_type = BTA_MSE_MA_GET_TYPE_CON_MSG_LIST;
- break;
- case BTA_MSE_OPER_GET_MSG:
- get_type = BTA_MSE_MA_GET_TYPE_CON_MSG;
- break;
- case BTA_MSE_OPER_NONE:
- if (OBX_ReadTypeHdr(p_evt->p_pkt, &p_type, &len))
- {
- if (!memcmp(p_type, BTA_MA_HDR_TYPE_FOLDER_LIST, len))
- {
- get_type = BTA_MSE_MA_GET_TYPE_FOLDER_LIST;
- }
- else if (!memcmp(p_type, BTA_MA_HDR_TYPE_MSG_LIST, len) )
- {
- get_type = BTA_MSE_MA_GET_TYPE_MSG_LIST;
- }
- else if (!memcmp(p_type, BTA_MA_HDR_TYPE_MSG, len) )
- {
-
- get_type = BTA_MSE_MA_GET_TYPE_MSG;
- }
- }
- break;
- default:
- break;
- }
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_ma_obx_get get_type=%d",get_type);
-#endif
- switch (get_type)
- {
- case BTA_MSE_MA_GET_TYPE_FOLDER_LIST:
- bta_mse_ma_fl_read_app_params(inst_idx, sess_idx, p_evt->p_pkt);
- get_act = BTA_MSE_MA_GET_ACT_NEW_FOLDER_LIST;
- break;
-
- case BTA_MSE_MA_GET_TYPE_MSG_LIST:
- if (!p_cb->ml_param.p_name)
- {
- p_cb->ml_param.p_name = (char *)GKI_getbuf((UINT16)(p_bta_mse_cfg->max_name_len + 1));
- }
-
- if (!p_cb->ml_param.p_path)
- {
- p_cb->ml_param.p_path = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1));
- }
-
- if ((p_cb->ml_param.p_name != NULL) && (p_cb->ml_param.p_path != NULL))
- {
- if (!OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *)p_cb->ml_param.p_name,
- p_bta_mse_cfg->max_name_len))
- {
- rsp_code = OBX_RSP_BAD_REQUEST;
- break;
- }
- else
- {
- if (!bta_mse_get_msglist_path(inst_idx, sess_idx))
- {
- rsp_code = OBX_RSP_NOT_FOUND;
- break;
- }
- }
- }
- else
- {
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- break;
- }
-
- bta_mse_ma_ml_read_app_params(inst_idx, sess_idx,p_evt->p_pkt);
- get_act = BTA_MSE_MA_GET_ACT_NEW_MSG_LIST;
- break;
-
- case BTA_MSE_MA_GET_TYPE_MSG:
-
- if (!p_cb->msg_param.p_msg_handle)
- {
- if ((p_cb->msg_param.p_msg_handle = (char *)GKI_getbuf((UINT16)(BTA_MSE_64BIT_HEX_STR_SIZE))) == NULL )
- {
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- get_act = BTA_MSE_MA_GET_ACT_ERR;
- break;
- }
- }
-
- if (OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *)p_cb->msg_param.p_msg_handle,
- BTA_MSE_64BIT_HEX_STR_SIZE))
- {
- bta_ma_convert_hex_str_to_64bit_handle(p_cb->msg_param.p_msg_handle,
- p_cb->msg_param.data.handle);
- }
- else
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("Unable to decode or find Name Header for Message Handle");
-#endif
-
- get_act = BTA_MSE_MA_GET_ACT_ERR;
- break;
- }
-
- if (!bta_mse_ma_msg_read_app_params(inst_idx, sess_idx, p_evt->p_pkt))
- {
- get_act = BTA_MSE_MA_GET_ACT_ERR;
- break;
- }
- get_act = BTA_MSE_MA_GET_ACT_NEW_MSG;
- break;
-
- case BTA_MSE_MA_GET_TYPE_CON_FOLDER_LIST:
- get_act = BTA_MSE_MA_GET_ACT_CON_FOLDER_LIST;
- break;
-
- case BTA_MSE_MA_GET_TYPE_CON_MSG_LIST:
- get_act = BTA_MSE_MA_GET_ACT_CON_MSG_LIST;
- break;
-
- case BTA_MSE_MA_GET_TYPE_CON_MSG:
- get_act = BTA_MSE_MA_GET_ACT_CON_MSG;
- break;
- default:
- break;
- }
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1(" get_act=%d",get_act);
-#endif
- switch (get_act)
- {
- case BTA_MSE_MA_GET_ACT_NEW_FOLDER_LIST:
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_GET_FOLDER_LIST);
- bta_mse_getfolderlist(inst_idx,sess_idx, TRUE);
- break;
- case BTA_MSE_MA_GET_ACT_CON_FOLDER_LIST:
- bta_mse_getfolderlist(inst_idx,sess_idx, FALSE);
- break;
-
- case BTA_MSE_MA_GET_ACT_NEW_MSG_LIST:
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_GET_MSG_LIST);
- bta_mse_req_app_access( inst_idx, sess_idx, p_data);
- break;
- case BTA_MSE_MA_GET_ACT_CON_MSG_LIST:
- bta_mse_getmsglist(inst_idx,sess_idx, FALSE);
- break;
-
- case BTA_MSE_MA_GET_ACT_NEW_MSG:
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_GET_MSG);
- if (p_cb->msg_param.data.fraction_request == BTA_MA_FRAC_REQ_FIRST ||
- p_cb->msg_param.data.fraction_request == BTA_MA_FRAC_REQ_NEXT)
- {
- p_cb->msg_param.add_frac_del_hdr = TRUE;
- }
- p_cb->msg_param.byte_get_cnt = 0;
- bta_mse_req_app_access( inst_idx, sess_idx, p_data);
- break;
- case BTA_MSE_MA_GET_ACT_CON_MSG:
- bta_mse_getmsg(inst_idx,sess_idx, FALSE);
- break;
-
- case BTA_MSE_MA_GET_ACT_ERR:
- default:
- OBX_GetRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- utl_freebuf((void**)&p_cb->ml_param.p_name);
- utl_freebuf((void**)&p_cb->ml_param.p_path);
- break;
- }
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-/*******************************************************************************
-**
-** Function bta_mse_ma_obx_setpath
-**
-** Description Proceses the obx setpath request
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_obx_setpath(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
-
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_MA_DIR_NAV flags = (tBTA_MA_DIR_NAV)p_evt->param.sp.flag;
- UINT8 rsp_code = OBX_RSP_BAD_REQUEST;
- tBTA_MSE_OPER mse_oper = BTA_MSE_OPER_NONE;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_obx_setpath inst idx=%d sess idx=%d",
- inst_idx, sess_idx);
- APPL_TRACE_EVENT1(" flags=%d ", flags);
-#endif
-
- /* Verify flags and handle before accepting */
- if ((flags == BTA_MA_DIR_NAV_ROOT_OR_DOWN_ONE_LVL) ||
- (flags == BTA_MA_DIR_NAV_UP_ONE_LVL))
- {
-
- p_cb->sp.p_path = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1));
- p_cb->sp.p_name = (char *)GKI_getbuf((UINT16)(p_bta_mse_cfg->max_name_len + 1));
- if (p_cb->sp.p_name != NULL )
- {
- p_cb->sp.flags = flags;
-
- if (!OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *)p_cb->sp.p_name,
- p_bta_fs_cfg->max_path_len))
- {
- p_cb->sp.p_name[0] = '\0';
- }
-
- rsp_code = bta_mse_chdir( inst_idx, sess_idx, &mse_oper);
-
- }
- else
- {
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- }
-
- bta_mse_set_ma_oper(inst_idx, sess_idx, mse_oper);
- if (mse_oper != BTA_MSE_OPER_NONE)
- {
- bta_mse_req_app_access( inst_idx, sess_idx, p_data);
- }
- else
- {
- OBX_SetPathRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- utl_freebuf((void**)&p_cb->sp.p_name);
- }
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-/*******************************************************************************
-**
-** Function bta_mse_ma_conn_err_rsp
-**
-** Description Proceses the inavlid obx connection request
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_conn_err_rsp(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_conn_err_rsp inst idx=%d sess idx=%d",inst_idx, sess_idx);
-#endif
-
- OBX_ConnectRsp(p_data->obx_evt.handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
- /* Done with Obex packet */
- utl_freebuf((void**)&(p_data->obx_evt.p_pkt));
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_close_complete
-**
-** Description Proceses the connection close complete event.
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_close_complete(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_CB *p_scb = BTA_MSE_GET_INST_CB_PTR(inst_idx);
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE cback_evt_data;
- tBTA_MSE *p_cevt = &cback_evt_data;
- UINT8 num_act_mas=0, num_act_sess=0, i;
- tBTA_MA_STATUS clean_getput_status = BTA_MA_STATUS_OK;
- UINT8 ccb_idx;
- BD_ADDR bd_addr;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ma_close_complete inst idx=%d sess idx=%d",inst_idx, sess_idx);
-#endif
-
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->aborting) clean_getput_status = BTA_MA_STATUS_ABORTED;
- bta_mse_clean_getput(inst_idx, sess_idx, clean_getput_status);
- utl_freebuf((void**)&p_cb->p_workdir);
-
- /* inform role manager */
-
- bta_mse_pm_conn_close(p_cb->bd_addr);
- bdcpy(bd_addr, p_cb->bd_addr);
- memset(p_cb->bd_addr, 0, BD_ADDR_LEN);
- p_cb->peer_mtu = 0;
-
- /* We now done with the close this seesion so issue a BTA_MSE_MA_CLOSE_EVT*/
- p_cevt->ma_close.mas_session_id = p_cb->obx_handle;
- p_cevt->ma_close.mas_instance_id = p_scb->mas_inst_id;
- p_cevt->ma_close.status = BTA_MA_STATUS_OK ;
- bta_mse_cb.p_cback(BTA_MSE_MA_CLOSE_EVT, (tBTA_MSE *) p_cevt);
-
-
- /* turn off the registration status for the associated MAs instance
- and also check whether MN connection needs to be closed or not */
- if (bta_mse_find_bd_addr_match_mn_cb_index(bd_addr, &ccb_idx) &&
- bta_mse_mn_is_inst_id_exist(ccb_idx, p_scb->mas_inst_id))
- {
- bta_mse_mn_remove_inst_id(ccb_idx, p_scb->mas_inst_id);
- if (!bta_mse_mn_find_num_of_act_inst_id(ccb_idx))
- {
- bta_mse_mn_sm_execute(ccb_idx,BTA_MSE_MN_INT_CLOSE_EVT, NULL);
- }
- }
-
- /* Check Any MAS instance need to be stopped */
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("stopping=%d MAS in use=%d", p_scb->stopping,p_scb->in_use);
-#endif
- if (p_scb->stopping && p_scb->in_use)
- {
- num_act_sess = 0;
- for (i=0; i < BTA_MSE_NUM_SESS; i ++)
- {
- p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, i);
- if (p_cb->state != BTA_MSE_MA_LISTEN_ST)
- num_act_sess++;
- }
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("num_act_sess=%d ", num_act_sess);
-#endif
- if (!num_act_sess)
- {
- p_cevt->stop.status = BTA_MA_STATUS_OK;
- p_cevt->stop.mas_instance_id = p_scb->mas_inst_id;
- bta_mse_cb.p_cback(BTA_MSE_STOP_EVT, (tBTA_MSE *) p_cevt);
- bta_mse_clean_mas_service(inst_idx);
- }
- }
-
- if (bta_mse_cb.disabling && bta_mse_cb.enable)
- {
- num_act_mas=0;
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- p_scb = BTA_MSE_GET_INST_CB_PTR(i);
- if (p_scb->in_use )
- num_act_mas++;
- }
-
- if (!num_act_mas)
- {
- bta_mse_cb.enable = FALSE;
- p_cevt->disable.status = BTA_MA_STATUS_OK;
- p_cevt->disable.app_id = bta_mse_cb.app_id;
- bta_mse_cb.p_cback(BTA_MSE_DISABLE_EVT, (tBTA_MSE *) p_cevt);
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("MSE Disabled location-2");
-#endif
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ignore_obx
-**
-** Description Ignores the obx event
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ignore_obx(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ignore_obx inst idx=%d sess idx=%d",inst_idx, sess_idx);
-#endif
-
- utl_freebuf((void**)&p_data->obx_evt.p_pkt);
-}
-/*******************************************************************************
-**
-** Function bta_mse_ma_obx_cback
-**
-** Description OBX callback function for MA.
-**
-** Parameters handle - Handle for Obex session
-** obx_event - Obex event
-** param - event parameters
-** p_pkt - pointer to Obex packet
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_obx_cback (tOBX_HANDLE handle, tOBX_EVENT obx_event,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt)
-{
- tBTA_MSE_OBX_EVT *p_obx_msg;
- UINT16 event = 0;
-
- switch (obx_event)
- {
- case OBX_CONNECT_REQ_EVT:
- event = BTA_MSE_MA_OBX_CONN_EVT;
- break;
- case OBX_DISCONNECT_REQ_EVT:
- event = BTA_MSE_MA_OBX_DISC_EVT;
- break;
- case OBX_PUT_REQ_EVT:
- event = BTA_MSE_MA_OBX_PUT_EVT;
- break;
- case OBX_GET_REQ_EVT:
- event = BTA_MSE_MA_OBX_GET_EVT;
- break;
- case OBX_SETPATH_REQ_EVT:
- event = BTA_MSE_MA_OBX_SETPATH_EVT;
- break;
- case OBX_ABORT_REQ_EVT:
- event = BTA_MSE_MA_OBX_ABORT_EVT;
- break;
- case OBX_CLOSE_IND_EVT:
- event = BTA_MSE_MA_OBX_CLOSE_EVT;
- break;
- case OBX_TIMEOUT_EVT:
- break;
- case OBX_PASSWORD_EVT:
- break;
- default:
- /* Unrecognized packet; disconnect the session */
- if (p_pkt)
- event = BTA_MSE_MA_OBX_DISC_EVT;
- }
-
- /* send event to BTA, if any */
- if (event && (p_obx_msg =
- (tBTA_MSE_OBX_EVT *) GKI_getbuf(sizeof(tBTA_MSE_OBX_EVT))) != NULL)
- {
-#if (BTA_MSE_DEBUG == TRUE) && (BT_USE_TRACES == TRUE)
- APPL_TRACE_DEBUG1("MA OBX Event Callback: mse_obx_event [%s]", bta_mse_obx_evt_code(event));
-#endif
- p_obx_msg->hdr.event = event;
- p_obx_msg->obx_event = obx_event;
- p_obx_msg->handle = handle;
- p_obx_msg->param = param;
- p_obx_msg->p_pkt = p_pkt;
- p_obx_msg->hdr.layer_specific = 0xFFFF;
-
- bta_sys_sendmsg(p_obx_msg);
- }
-}
-/*******************************************************************************
-** Message Notification Client (MNC) Action functions
-**
-*******************************************************************************/
-/******************************************************************************
-**
-** Function bta_mse_mn_sdp_cback
-**
-** Description This is the SDP callback function used by MSE.
-** This function will be executed by SDP when the service
-** search is completed. If the search is successful, it
-** finds the first record in the database that matches the
-** UUID of the search. Then retrieves the scn from the
-** record.
-**
-** Parameters ccb_idx - Index to the MN control block
-** status - status of the SDP callabck
-**
-** Returns void.
-**
-******************************************************************************/
-static void bta_mse_mn_sdp_cback(UINT8 ccb_idx, UINT16 status)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
- tBTA_MSE_MN_SDP_OK *p_buf;
- tSDP_DISC_REC *p_rec = NULL;
- tSDP_PROTOCOL_ELEM pe;
- UINT8 scn = 0;
- BOOLEAN found = FALSE;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_sdp_cback status:%d", status);
-#endif
- if (status == SDP_SUCCESS || status == SDP_DB_FULL)
- {
- /* loop through all records we found */
- do
- {
- /* get next record; if none found, we're done */
- if ((p_rec = SDP_FindServiceInDb(p_cb->p_db, p_cb->sdp_service,
- p_rec)) == NULL)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("SDP Not Found");
-#endif
- break;
- }
-
- /* get scn from proto desc list; if not found, go to next record */
- if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
- {
- found = TRUE;
- scn = (UINT8) pe.params[0];
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("SDP found scn=%d", scn);
-#endif
- /* we've got everything, we're done */
- break;
- }
- else
- continue;
- } while (TRUE);
- }
-
- /* send result in event back to BTA */
- if ((p_buf = (tBTA_MSE_MN_SDP_OK *) GKI_getbuf(sizeof(tBTA_MSE_MN_SDP_OK))) != NULL)
- {
- p_buf->hdr.event = BTA_MSE_MN_SDP_FAIL_EVT;
- p_buf->ccb_idx = ccb_idx;
- if (status == SDP_SUCCESS || status == SDP_DB_FULL)
- {
- if (found == TRUE)
- {
- p_buf->hdr.event = BTA_MSE_MN_SDP_OK_EVT;
- p_buf->scn = scn;
- }
- else
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("SDP 1 BTA_MSE_MN_SDP_FAIL_EVT");
-#endif
- }
- }
- else
- {
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("SDP 2 BTA_MSE_MN_SDP_FAIL_EVT");
-#endif
- }
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/******************************************************************************
-**
-** Function bta_mse_mn_sdp_cback0
-**
-** Description This is the SDP callback function used by MN indx = 0
-**
-** Parameters status - status of the SDP callabck
-**
-** Returns void.
-**
-******************************************************************************/
-static void bta_mse_mn_sdp_cback0(UINT16 status)
-{
- bta_mse_mn_sdp_cback(0, status);
-}
-
-/******************************************************************************
-**
-** Function bta_mse_mn_sdp_cback1
-**
-** Description This is the SDP callback function used by MN indx = 1
-**
-** Parameters status - status of the SDP callabck
-**
-** Returns void.
-**
-******************************************************************************/
-static void bta_mse_mn_sdp_cback1(UINT16 status)
-{
- bta_mse_mn_sdp_cback(1, status);
-}
-
-/******************************************************************************
-**
-** Function bta_mse_mn_sdp_cback2
-**
-** Description This is the SDP callback function used by MN indx = 2
-**
-** Parameters status - status of the SDP callabck
-**
-** Returns void.
-**
-******************************************************************************/
-static void bta_mse_mn_sdp_cback2(UINT16 status)
-{
- bta_mse_mn_sdp_cback(2, status);
-}
-
-/******************************************************************************
-**
-** Function bta_mse_mn_sdp_cback3
-**
-** Description This is the SDP callback function used by MN indx = 3
-**
-** Parameters status - status of the SDP callabck
-**
-** Returns void.
-**
-******************************************************************************/
-static void bta_mse_mn_sdp_cback3(UINT16 status)
-{
- bta_mse_mn_sdp_cback(3, status);
-}
-
-/******************************************************************************
-**
-** Function bta_mse_mn_sdp_cback4
-**
-** Description This is the SDP callback function used by MN indx = 4
-**
-** Parameters status - status of the SDP callabck
-**
-** Returns void.
-**
-******************************************************************************/
-static void bta_mse_mn_sdp_cback4(UINT16 status)
-{
- bta_mse_mn_sdp_cback(4, status);
-}
-
-/******************************************************************************
-**
-** Function bta_mse_mn_sdp_cback5
-**
-** Description This is the SDP callback function used by MN indx = 5
-**
-** Parameters status - status of the SDP callabck
-**
-** Returns void.
-**
-******************************************************************************/
-static void bta_mse_mn_sdp_cback5(UINT16 status)
-{
- bta_mse_mn_sdp_cback(5, status);
-}
-
-/******************************************************************************
-**
-** Function bta_mse_mn_sdp_cback6
-**
-** Description This is the SDP callback function used by MN indx = 6
-**
-** Parameters status - status of the SDP callabck
-**
-** Returns void.
-**
-******************************************************************************/
-static void bta_mse_mn_sdp_cback6(UINT16 status)
-{
- bta_mse_mn_sdp_cback(6, status);
-}
-/*******************************************************************************
-**
-** Function bta_mse_mn_init_sdp
-**
-** Description Initialize SDP on message notification server device.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_init_sdp(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = &(bta_mse_cb.ccb[ccb_idx]);
- tBTA_MSE_MN_INT_OPEN *p_evt = &p_data->mn_int_open;
-
- tSDP_UUID uuid_list;
- UINT16 attr_list[3];
- UINT16 num_attrs = 2;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_mn_init_sdp");
-#endif
-
- p_cb->in_use = TRUE;
- p_cb->sec_mask = p_evt->sec_mask;
- bdcpy(p_cb->bd_addr,p_evt->bd_addr);
- p_cb->sdp_pending = TRUE;
- p_cb->sdp_cback = bta_mse_mn_sdp_cback_arr[ccb_idx];
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT6("SDP INIT BD_ADDR= %x:%x:%x:%x:%x:%x",
- p_cb->bd_addr[0],
- p_cb->bd_addr[1],
- p_cb->bd_addr[2],
- p_cb->bd_addr[3],
- p_cb->bd_addr[4],
- p_cb->bd_addr[5]);
-#endif
-
- if ((p_cb->p_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_MSE_MN_DISC_SIZE)) != NULL)
- {
- attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
- attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
-
- uuid_list.len = LEN_UUID_16;
-
- p_cb->sdp_service = UUID_SERVCLASS_MESSAGE_NOTIFICATION;
- uuid_list.uu.uuid16 = UUID_SERVCLASS_MESSAGE_NOTIFICATION;
-
- SDP_InitDiscoveryDb(p_cb->p_db, BTA_MSE_MN_DISC_SIZE, 1, &uuid_list, num_attrs, attr_list);
- if (!SDP_ServiceSearchAttributeRequest(p_cb->bd_addr, p_cb->p_db, p_cb->sdp_cback))
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("SDP Init failed ");
-#endif
- bta_mse_mn_sm_execute(ccb_idx, BTA_MSE_MN_SDP_FAIL_EVT, p_data);
- }
- else
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("SDP Init Success ");
-#endif
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_start_client
-**
-** Description Starts the OBEX client for Message Notification service.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_start_client(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
-
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- BOOLEAN connect_fail = TRUE;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_start_client ccb idx=%d ",ccb_idx);
-#endif
-
- /* free discovery data base */
- utl_freebuf((void**)&p_cb->p_db);
- p_cb->sdp_pending = FALSE;
- /* Allocate an OBX packet */
- if ((p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(OBX_HANDLE_NULL, OBX_CMD_POOL_SIZE)) != NULL)
- {
- /* set security level */
- BTM_SetSecurityLevel (TRUE, "BTA_MNC", BTM_SEC_SERVICE_MAP,
- p_cb->sec_mask, BT_PSM_RFCOMM,
- BTM_SEC_PROTO_RFCOMM, p_data->mn_sdp_ok.scn);
-
- if (p_cb->sdp_service == UUID_SERVCLASS_MESSAGE_NOTIFICATION)
- {
- OBX_AddTargetHdr(p_obx->p_pkt, (UINT8 *)BTA_MAS_MESSAGE_NOTIFICATION_TARGET_UUID,
- BTA_MAS_UUID_LENGTH);
- }
- if (OBX_ConnectReq(p_cb->bd_addr, p_data->mn_sdp_ok.scn, OBX_MAX_MTU,
- bta_mse_mn_obx_cback, &p_cb->obx_handle, p_obx->p_pkt) == OBX_SUCCESS)
- {
- p_obx->p_pkt = NULL; /* OBX will free the memory */
- connect_fail = FALSE;
- }
- else
- {
- utl_freebuf((void**)&p_obx->p_pkt);
- }
- }
-
- if (connect_fail)
- {
- bta_mse_mn_sm_execute(ccb_idx, BTA_MSE_MN_OBX_CLOSE_EVT, p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_rsp_timeout
-**
-** Description Process the OBX response timeout event
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_rsp_timeout(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-
- if (p_cb->timer_oper == BTA_MSE_TIMER_OP_ABORT)
- {
- /* Start stop response timer */
- bta_mse_mn_start_timer(ccb_idx, BTA_MSE_TIMER_OP_STOP);
-
- OBX_DisconnectReq(p_cb->obx_handle, NULL);
- }
- else /* Timeout waiting for disconnect response */
- {
- bta_mse_mn_sm_execute(ccb_idx, BTA_MSE_MN_OBX_CLOSE_EVT, p_data);
-
- }
-}
-/*******************************************************************************
-**
-** Function bta_mse_mn_stop_client
-**
-** Description Stop the OBX client for Message Notification service.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_stop_client(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_stop_client ccb idx=%d ",ccb_idx);
-#endif
-
- if (!p_cb->sdp_pending)
- {
- /* Start stop response timer */
- bta_mse_mn_start_timer(ccb_idx, BTA_MSE_TIMER_OP_STOP);
- OBX_DisconnectReq(p_cb->obx_handle, NULL);
- }
- else
- {
- APPL_TRACE_WARNING0("bta_mase_mn_stop_client: Waiting for SDP to complete");
- }
-}
-/*******************************************************************************
-**
-** Function bta_mse_mn_obx_conn_rsp
-**
-** Description Process OBX connection response.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_obx_conn_rsp(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
- tBTA_MSE_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_MSE param;
- UINT8 mas_insatnce_id;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_obx_conn_rsp ccb idx=%d ",ccb_idx);
-#endif
-
- p_cb->peer_mtu = p_data->obx_evt.param.conn.mtu;
- p_cb->obx_handle = p_evt->handle;
-
- if (p_cb->sdp_service == UUID_SERVCLASS_MESSAGE_NOTIFICATION)
- {
- bdcpy(param.mn_open.bd_addr ,p_cb->bd_addr);
- BCM_STRNCPY_S((char *)param.mn_open.dev_name, sizeof(param.mn_open.dev_name), "",
- BTM_MAX_REM_BD_NAME_LEN);
- if (bta_mse_mn_get_first_inst_id(ccb_idx, &mas_insatnce_id))
- {
- param.mn_open.first_mas_instance_id = mas_insatnce_id;
- }
- else
- {
- APPL_TRACE_ERROR0("Unable to find the first instance ID");
- }
- }
-
- /* inform role manager */
- bta_mse_pm_conn_open(p_cb->bd_addr);
-
- bta_mse_cb.p_cback(BTA_MSE_MN_OPEN_EVT, &param);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-/*******************************************************************************
-**
-** Function bta_mse_mn_close
-**
-** Description Process the connection close event.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_close(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_close ccb idx=%d ",ccb_idx);
-#endif
-
- bta_mse_mn_remove_all_inst_ids(ccb_idx);
-
- /* finished if not waiting on a call-in function */
- if (!p_cb->sdp_pending && !p_cb->cout_active)
- bta_mse_mn_sm_execute(ccb_idx, BTA_MSE_MN_CLOSE_CMPL_EVT, p_data);
-}
-/*******************************************************************************
-**
-** Function bta_mse_mn_send_notif
-**
-** Description Process send notification request
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_send_notif(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
- tBTA_MSE_MN_API_SEND_NOTIF *p_evt = &p_data->mn_send_notif;
- UINT8 *p_buffer;
- UINT16 buffer_len;
- tBTA_MA_STATUS status = BTA_MA_STATUS_FAIL;
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_send_notif ccb_idx=%d ",ccb_idx);
-#endif
-
- if ( (p_cb->req_pending == TRUE) &&
- (p_cb->obx_oper == BTA_MSE_MN_OP_PUT_EVT_RPT))
- {
- /* only one pending request per Obex connection is allowed */
- bta_mse_mn_send_notif_evt(p_evt->mas_instance_id,
- BTA_MA_STATUS_NO_RESOURCE,
- p_cb->bd_addr);
- return;
- }
-
- memset(&(p_cb->msg_notif), 0, sizeof(tBTA_MSE_MN_MSG_NOTIF));
-
- if ((p_buffer = (UINT8 *)GKI_getbuf(BTA_MSE_MN_MAX_MSG_EVT_OBECT_SIZE)) != NULL)
- {
- /* Build the Message Event Object */
- buffer_len = BTA_MSE_MN_MAX_MSG_EVT_OBECT_SIZE;
- status = bta_mse_build_map_event_rpt_obj( p_evt->notif_type,
- p_evt->handle,
- p_evt->p_folder,
- p_evt->p_old_folder,
- p_evt->msg_type,
- &buffer_len,
- p_buffer);
- if (status == BTA_MA_STATUS_OK)
- {
- p_cb->msg_notif.p_buffer = p_buffer;
- p_cb->msg_notif.buffer_len = buffer_len;
- p_cb->msg_notif.bytes_sent = 0;
- p_cb->msg_notif.mas_instance_id = p_evt->mas_instance_id;
- status = bta_mse_mn_cont_send_notif(ccb_idx, TRUE);
- }
- }
-
- if ( status != BTA_MA_STATUS_OK)
- {
- bta_mse_mn_send_notif_evt(p_evt->mas_instance_id,
- BTA_MA_STATUS_NO_RESOURCE,
- p_cb->bd_addr);
- bta_mse_mn_clean_send_notif(ccb_idx);
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("status=%d ",status );
-#endif
-}
-/*******************************************************************************
-**
-** Function bta_mse_mn_put_rsp
-**
-** Description Process the obx PUT response.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_put_rsp(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
- tBTA_MSE_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_MSE_MN_MSG_NOTIF *p_msg_notif = &p_cb->msg_notif;
- tBTA_MA_STATUS status = BTA_MA_STATUS_FAIL;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_mn_put_rsp ccb idx=%d rsp_code=%d",
- ccb_idx, p_evt->rsp_code);
-#endif
-
- p_cb->req_pending = FALSE;
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-
- if (p_cb->obx_oper == BTA_MSE_MN_OP_PUT_EVT_RPT)
- {
- /* If not finished with Put, start another read */
- if (p_evt->rsp_code == OBX_RSP_CONTINUE)
- bta_mse_mn_cont_send_notif(ccb_idx, FALSE);
- else
- {
- /* done with obex operation */
- if ( p_evt->rsp_code == OBX_RSP_OK ) status = BTA_MA_STATUS_OK;
- bta_mse_mn_send_notif_evt(p_msg_notif->mas_instance_id, status,
- p_cb->bd_addr);
- bta_mse_mn_clean_send_notif(ccb_idx);
- }
- }
-}
-/*******************************************************************************
-**
-** Function bta_mse_mn_close_compl
-**
-** Description Process the close complete event.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_close_compl(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
- tBTA_MSE param;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_close_compl ccb idx=%d ",ccb_idx);
-#endif
-
- /* free discovery data base */
- utl_freebuf((void**)&p_cb->p_db);
- p_cb->sdp_pending = FALSE;
-
- p_cb->cout_active = FALSE;
- bta_mse_mn_stop_timer(ccb_idx, BTA_MSE_TIMER_OP_ALL);
- bta_mse_mn_clean_send_notif(ccb_idx);
- /* inform role manager */
- bta_mse_pm_conn_close(p_cb->bd_addr);
- bdcpy(param.mn_close.bd_addr ,p_cb->bd_addr);
- bta_mse_cb.p_cback(BTA_MSE_MN_CLOSE_EVT, &param);
- memset(p_cb, 0 , sizeof(tBTA_MSE_MN_CB));
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_abort
-**
-** Description Process the abort event.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_abort(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_abort ccb idx=%d ",ccb_idx);
-#endif
- /* Abort an active request */
- if (p_cb->obx_oper != BTA_MSE_MN_OP_NONE)
- {
- p_cb->aborting = BTA_MSE_MN_ABORT_REQ_NOT_SENT;
-
- /* Issue the abort request only if no request pending.
- * some devices do not like out of sequence aborts even though
- * the spec allows it */
- if (!p_cb->req_pending)
- {
- /* Start abort response timer */
- bta_mse_mn_start_timer(ccb_idx, BTA_MSE_TIMER_OP_ABORT);
- OBX_AbortReq(p_cb->obx_handle, (BT_HDR *)NULL);
- p_cb->aborting = BTA_MSE_MN_ABORT_REQ_SENT;
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_abort_rsp
-**
-** Description Process the abort response event.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_abort_rsp(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
- tBTA_MSE_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_MSE_MN_MSG_NOTIF *p_msg_notif = &p_cb->msg_notif;
- tBTA_MA_STATUS status = BTA_MA_STATUS_FAIL;
-
-
- bta_mse_mn_stop_timer(ccb_idx,BTA_MSE_TIMER_OP_ABORT);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-
- if (p_cb->obx_oper != BTA_MSE_MN_OP_NONE)
- {
- if (p_cb->obx_oper == BTA_MSE_MN_OP_PUT_EVT_RPT )
- {
- bta_mse_mn_send_notif_evt(p_msg_notif->mas_instance_id, status,
- p_cb->bd_addr);
- bta_mse_mn_clean_send_notif(ccb_idx);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_sdp_fail
-**
-** Description Process the SDP fail event.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_sdp_fail(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_sdp_fail ccb idx=%d ",ccb_idx);
-#endif
- /* free discovery data base */
- utl_freebuf((void**)&p_cb->p_db);
- p_cb->sdp_pending = FALSE;
- bta_mse_mn_sm_execute(ccb_idx, BTA_MSE_MN_OBX_CLOSE_EVT, p_data);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_obx_tout
-**
-** Description Process the obx timeout event.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_obx_tout(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_obx_tout ccb idx=%d ",ccb_idx);
-#endif
-
- if (p_cb->req_pending)
- {
- if (p_cb->obx_oper == BTA_MSE_MN_OP_PUT_EVT_RPT)
- {
- bta_mse_mn_send_notif_evt( p_cb->msg_notif.mas_instance_id,
- BTA_MA_STATUS_FAIL,
- p_cb->bd_addr);
- bta_mse_mn_clean_send_notif(ccb_idx);
- }
- }
-}
-/*******************************************************************************
-**
-** Function bta_mse_mn_ignore_obx
-**
-** Description Ignore OBX event.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_ignore_obx(UINT8 ccb_idx, tBTA_MSE_DATA *p_data)
-{
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_ignore_obx ccb idx=%d ",ccb_idx);
-#endif
-
- utl_freebuf((void **) &p_data->obx_evt.p_pkt);
-}
-
-
-
-/*****************************************************************************
-** MNC Callback Functions
-*****************************************************************************/
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_obx_cback
-**
-** Description OBX callback function.
-**
-** Parameters handle - Handle for Obex session
-** obx_event - Obex event
-** rsp_code - Obex response code
-** param - event parameters
-** p_pkt - pointer to Obex packet
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_obx_cback (tOBX_HANDLE handle, tOBX_EVENT obx_event, UINT8 rsp_code,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt)
-{
- tBTA_MSE_OBX_EVT *p_obx_msg;
- UINT16 event = 0;
-
-
-
- switch (obx_event)
- {
- case OBX_CONNECT_RSP_EVT:
- if (rsp_code == OBX_RSP_OK)
- {
- event = BTA_MSE_MN_OBX_CONN_RSP_EVT;
- }
- else /* Obex will disconnect underneath BTA */
- {
- APPL_TRACE_WARNING1("MN_OBX_CBACK: Bad connect response 0x%02x", rsp_code);
- if (p_pkt)
- GKI_freebuf(p_pkt);
- return;
- }
- break;
- case OBX_PUT_RSP_EVT:
- event = BTA_MSE_MN_OBX_PUT_RSP_EVT;
- break;
- case OBX_CLOSE_IND_EVT:
- event = BTA_MSE_MN_OBX_CLOSE_EVT;
- break;
- case OBX_TIMEOUT_EVT:
- event = BTA_MSE_MN_OBX_TOUT_EVT;
- break;
- case OBX_ABORT_RSP_EVT:
- event = BTA_MSE_MN_OBX_ABORT_RSP_EVT;
- break;
- case OBX_PASSWORD_EVT:
- case OBX_GET_RSP_EVT:
- case OBX_SETPATH_RSP_EVT:
- default:
- /* case OBX_DISCONNECT_RSP_EVT: Handled when OBX_CLOSE_IND_EVT arrives */
- if (p_pkt)
- GKI_freebuf(p_pkt);
- return;
- }
-
-
-
- if (event && (p_obx_msg =
- (tBTA_MSE_OBX_EVT *) GKI_getbuf(sizeof(tBTA_MSE_OBX_EVT))) != NULL)
- {
-#if (BTA_MSE_DEBUG == TRUE) && (BT_USE_TRACES == TRUE)
- APPL_TRACE_DEBUG1("MN OBX Event Callback: mn_obx_event [%s]",
- bta_mse_obx_evt_code(event));
-#endif
- /* send event to BTA, if any */
- p_obx_msg->hdr.event = event;
- p_obx_msg->hdr.layer_specific = 0xFFFF; /* not used */
- p_obx_msg->obx_event = obx_event;
- p_obx_msg->handle = handle;
- p_obx_msg->rsp_code = rsp_code;
- p_obx_msg->param = param;
- p_obx_msg->p_pkt = p_pkt;
-
- bta_sys_sendmsg(p_obx_msg);
- }
-}
-
-
-/*****************************************************************************
-** Local MSE Event Processing Functions
-*****************************************************************************/
-
-/*******************************************************************************
-**
-** Function bta_mse_req_app_access
-**
-** Description Sends an access request event to the application.
-**
-** Parameters ccb_idx - Index to the MN control block
-** p_data - Pointer to the MN event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_req_app_access (UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_ACCESS *p_acc_evt;
- char *p_devname;
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_req_app_access inst idx=%d sess idx=%d",
- inst_idx, sess_idx);
-#endif
-
- /* Ask application for the operation's access permission */
- if ((p_acc_evt = (tBTA_MSE_ACCESS *)GKI_getbuf((UINT16) (sizeof(tBTA_MSE_ACCESS)+
- (p_bta_fs_cfg->max_path_len + 1)))) != NULL)
- {
- memset(p_acc_evt, 0, sizeof(tBTA_MSE_ACCESS));
- p_acc_evt->p_path = (char *) (p_acc_evt+1);
- p_acc_evt->p_path[0]='\0';
-
- APPL_TRACE_API1("MSE ACCESS REQ: Oper=%d", p_cb->oper);
- switch (p_cb->oper)
- {
- case BTA_MSE_OPER_SETPATH:
- BCM_STRNCPY_S(p_acc_evt->p_path, p_bta_fs_cfg->max_path_len+1,
- p_cb->sp.p_path, p_bta_fs_cfg->max_path_len);
- break;
-
- case BTA_MSE_OPER_GET_MSG_LIST:
- BCM_STRNCPY_S(p_acc_evt->p_path, p_bta_fs_cfg->max_path_len+1,
- p_cb->ml_param.p_path, p_bta_fs_cfg->max_path_len);
- break;
-
- case BTA_MSE_OPER_GET_MSG:
- memcpy(p_acc_evt->handle, p_cb->msg_param.data.handle,
- sizeof(tBTA_MA_MSG_HANDLE));
- break;
- case BTA_MSE_OPER_PUSH_MSG:
- memset(p_acc_evt->handle, 0, sizeof(tBTA_MA_MSG_HANDLE));
- BCM_STRNCPY_S(p_acc_evt->p_path, p_bta_fs_cfg->max_path_len+1,
- p_cb->push_msg.param.p_folder, p_bta_fs_cfg->max_path_len);
- break;
- case BTA_MSE_OPER_DEL_MSG:
- memcpy(p_acc_evt->handle, p_cb->set_msg_sts.handle,
- sizeof(tBTA_MA_MSG_HANDLE));
- p_acc_evt->delete_sts = p_cb->set_msg_sts.sts_val;
- break;
- default:
- break;
- }
-
- p_acc_evt->oper = p_cb->oper;
- p_acc_evt->mas_session_id = (tBTA_MA_SESS_HANDLE) p_cb->obx_handle;
- bdcpy(p_acc_evt->bd_addr, p_cb->bd_addr);
- if ((p_devname = BTM_SecReadDevName(p_cb->bd_addr)) != NULL)
- BCM_STRNCPY_S((char *)p_acc_evt->dev_name, sizeof(p_acc_evt->dev_name), p_devname, BTM_MAX_REM_BD_NAME_LEN);
-
- bta_mse_cb.p_cback(BTA_MSE_ACCESS_EVT, (tBTA_MSE *)p_acc_evt);
- GKI_freebuf(p_acc_evt);
- }
-}
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if (BTA_MSE_DEBUG == TRUE) && (BT_USE_TRACES == TRUE)
-
-/*******************************************************************************
-**
-** Function bta_mse_obx_evt_code
-**
-** Description get the obx event string pointer
-**
-** Parameters evt_code - obex event code
-**
-** Returns char * - event string pointer
-**
-*******************************************************************************/
-static char *bta_mse_obx_evt_code(UINT16 evt_code)
-{
- switch (evt_code)
- {
- case BTA_MSE_MA_OBX_CONN_EVT:
- return "BTA_MSE_MA_OBX_CONN_EVT";
- case BTA_MSE_MA_OBX_DISC_EVT:
- return "BTA_MSE_MA_OBX_DISC_EVT";
- case BTA_MSE_MA_OBX_PUT_EVT:
- return "BTA_MSE_MA_OBX_PUT_EVT";
- case BTA_MSE_MA_OBX_GET_EVT:
- return "BTA_MSE_MA_OBX_GET_EVT";
- case BTA_MSE_MA_OBX_SETPATH_EVT:
- return "BTA_MSE_MA_OBX_SETPATH_EVT";
- case BTA_MSE_MA_OBX_ABORT_EVT:
- return "BTA_MSE_MA_OBX_ABORT_EVT";
- case BTA_MSE_MA_OBX_CLOSE_EVT:
- return "BTA_MSE_MA_OBX_CLOSE_EVT";
- case BTA_MSE_MN_OBX_TOUT_EVT:
- return "BTA_MSE_MN_OBX_TOUT_EVT";
- case BTA_MSE_MN_OBX_CONN_RSP_EVT:
- return "BTA_MSE_MN_OBX_CONN_RSP_EVT";
- case BTA_MSE_MN_OBX_PUT_RSP_EVT:
- return "BTA_MSE_MN_OBX_PUT_RSP_EVT";
- case BTA_MSE_MN_OBX_CLOSE_EVT:
- return "BTA_MSE_MN_OBX_CLOSE_EVT";
- case BTA_MSE_MN_OBX_ABORT_RSP_EVT:
- return"BTA_MSE_MN_OBX_ABORT_RSP_EVT";
- default:
- return "unknown MSE OBX event code";
- }
-}
-#endif /* Debug Functions */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#endif /* BTA_MSE_INCLUDED */
diff --git a/bta/ma/bta_mse_api.c b/bta/ma/bta_mse_api.c
deleted file mode 100644
index 5a2fd29..0000000
--- a/bta/ma/bta_mse_api.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_mse_api.c
-**
-** Description: This is the implementation of the API for the Message
-** Acess Server subsystem of BTA, Broadcom Corp's Bluetooth
-** application layer for mobile phones.
-**
-** Copyright (c) 2009-2011 Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_MSE_INCLUDED) && (BTA_MSE_INCLUDED == TRUE)
-
-#include <string.h>
-#include "gki.h"
-#include "bd.h"
-#include "bta_ma_def.h"
-#include "bta_mse_api.h"
-#include "bta_fs_api.h"
-#include "bta_mse_int.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-static const tBTA_SYS_REG bta_mse_reg =
-{
- bta_mse_hdl_event,
- BTA_MseDisable
-};
-
-/*******************************************************************************
-**
-** Function BTA_MseEnable
-**
-** Description Enable the MSE subsystems. This function must be
-** called before any other functions in the MSE API are called.
-** When the enable operation is completed the callback function
-** will be called with an BTA_MSE_ENABLE_EVT event.
-**
-** Parameters p_cback - MSE event call back function
-** app_id - Application ID
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseEnable(tBTA_MSE_CBACK *p_cback, UINT8 app_id)
-{
- tBTA_MSE_API_ENABLE *p_buf;
-
- /* register with BTA system manager */
- GKI_sched_lock();
- bta_sys_register(BTA_ID_MSE, &bta_mse_reg);
- GKI_sched_unlock();
-
- if ((p_buf = (tBTA_MSE_API_ENABLE *)GKI_getbuf(sizeof(tBTA_MSE_API_ENABLE))) != NULL)
- {
- p_buf->hdr.event = BTA_MSE_API_ENABLE_EVT;
- p_buf->p_cback = p_cback;
- p_buf->app_id = app_id;
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_MseDisable
-**
-** Description Disable the MSE subsystem.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseDisable(void)
-{
- BT_HDR *p_buf;
-
- bta_sys_deregister(BTA_ID_MSE);
- if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_MSE_API_DISABLE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_MseStart
-**
-** Description Start a MA server on the MSE
-**
-**
-** Parameters mas_inst_id - MAS instance ID
-** sec_mask - Security Setting Mask
-** MSE always enables
-** (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)
-** p_service_name - Pointer to service name
-** p_root_path - Pointer to root path
-** (one level above telecom)
-** sup_msg_type - supported message type(s)
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseStart( tBTA_MA_INST_ID mas_inst_id,
- tBTA_SEC sec_mask, const char *p_service_name,
- const char *p_root_path,
- tBTA_MA_MSG_TYPE sup_msg_type)
-{
- tBTA_MSE_API_START *p_buf;
-
- if ((p_buf = (tBTA_MSE_API_START *)GKI_getbuf((UINT16)(sizeof(tBTA_MSE_API_START) +
- p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- p_buf->p_root_path = (char *)(p_buf + 1);
- p_buf->hdr.event = BTA_MSE_API_START_EVT;
- p_buf->mas_inst_id = mas_inst_id;
- p_buf->sec_mask = (sec_mask | BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT);
- p_buf->sup_msg_type = sup_msg_type;
-
-
- if (p_service_name)
- {
- BCM_STRNCPY_S(p_buf->servicename, sizeof(p_buf->servicename), p_service_name, BTA_SERVICE_NAME_LEN);
- p_buf->servicename[BTA_SERVICE_NAME_LEN] = '\0';
- }
- else
- p_buf->servicename[0]= '\0';
-
- if (p_root_path)
- {
- BCM_STRNCPY_S(p_buf->p_root_path, p_bta_fs_cfg->max_path_len+1, p_root_path, p_bta_fs_cfg->max_path_len);
- p_buf->p_root_path[p_bta_fs_cfg->max_path_len] = '\0';
- }
- else
- p_buf->p_root_path[0] = '\0';
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_MseStop
-**
-** Description Stop a MA server on the MSE
-**
-** Parameters mas_instance_id - MAS Instance ID
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseStop (tBTA_MA_INST_ID mas_instance_id)
-{
- tBTA_MSE_API_STOP *p_buf;
-
- if ((p_buf = (tBTA_MSE_API_STOP *)GKI_getbuf((UINT16)(sizeof(tBTA_MSE_API_STOP)))) != NULL)
- {
- p_buf->hdr.event = BTA_MSE_API_STOP_EVT;
- p_buf->mas_inst_id = mas_instance_id;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_MseClose
-**
-** Description Close all MAS sessions on the specified MAS Instance ID
-**
-** Parameters mas_instance_id - MAS Inatance ID
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseClose(tBTA_MA_INST_ID mas_instance_id)
-{
-
- tBTA_MSE_API_CLOSE *p_buf;
-
- if ((p_buf = (tBTA_MSE_API_CLOSE *)GKI_getbuf((UINT16)(sizeof(tBTA_MSE_API_CLOSE)))) != NULL)
- {
- p_buf->hdr.event = BTA_MSE_API_CLOSE_EVT;
- p_buf->mas_instance_id = mas_instance_id;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_MseMaClose
-**
-** Description Close a MAS sessions on the specified BD address
-**
-** Parameters bd_addr - remote BD's address
-** mas_instance_id - MAS Inatance ID
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseMaClose(BD_ADDR bd_addr, tBTA_MA_INST_ID mas_instance_id)
-{
- tBTA_MSE_API_MA_CLOSE *p_buf;
-
- if ((p_buf = (tBTA_MSE_API_MA_CLOSE *)GKI_getbuf((UINT16)(sizeof(tBTA_MSE_API_MA_CLOSE)))) != NULL)
- {
- memset(p_buf, 0, sizeof(tBTA_MSE_API_MA_CLOSE));
-
- p_buf->hdr.event = BTA_MSE_API_MA_CLOSE_EVT;
- bdcpy(p_buf->bd_addr, bd_addr);
- p_buf->mas_instance_id = mas_instance_id;
- bta_sys_sendmsg(p_buf);
- }
-}
-/*******************************************************************************
-**
-** Function BTA_MseMnClose
-**
-** Description Close a MN session
-**
-** Parameters bd_addr - remote BD's address
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseMnClose(BD_ADDR bd_addr)
-{
- tBTA_MSE_API_MN_CLOSE *p_buf;
-
- if ((p_buf = (tBTA_MSE_API_MN_CLOSE *)GKI_getbuf((UINT16)(sizeof(tBTA_MSE_API_MN_CLOSE)))) != NULL)
- {
- p_buf->hdr.event = BTA_MSE_API_MN_CLOSE_EVT;
- bdcpy(p_buf->bd_addr, bd_addr);
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_MseAccessRsp
-**
-** Description Send a response for the access request
-**
-** Parameters mas_session_id - MAS session ID
-** oper - MAS operation type
-** access - Access is allowed or not
-** p_path - pointer to a path if if the operation
-** involves accessing a folder
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseAccessRsp(tBTA_MA_SESS_HANDLE mas_session_id, tBTA_MSE_OPER oper,
- tBTA_MA_ACCESS_TYPE access, char *p_path)
-{
- tBTA_MSE_API_ACCESSRSP *p_acc_rsp;
- UINT16 path_len;
-
- /* If directory is specified set the length */
- path_len = (p_path && *p_path != '\0') ? (UINT16)(strlen(p_path) + 1): 1;
-
- if ((p_acc_rsp = (tBTA_MSE_API_ACCESSRSP *)GKI_getbuf((UINT16)(sizeof(tBTA_MSE_API_ACCESSRSP)
- + path_len))) != NULL)
- {
- p_acc_rsp->mas_session_id = mas_session_id;
- p_acc_rsp->rsp = access;
- p_acc_rsp->oper = oper;
- p_acc_rsp->p_path = (char *)(p_acc_rsp + 1);
- if (p_path)
- {
- BCM_STRNCPY_S(p_acc_rsp->p_path, path_len, p_path, path_len-1);
- p_acc_rsp->p_path[path_len-1] = '\0';
- }
- else
- p_acc_rsp->p_path[0] = '\0';
-
- p_acc_rsp->hdr.event = BTA_MSE_API_ACCESSRSP_EVT;
- bta_sys_sendmsg(p_acc_rsp);
- }
-}
-/*******************************************************************************
-**
-** Function BTA_MseUpdateInboxRsp
-**
-** Description Send a response for the update inbox request
-**
-**
-** Parameters mas_session_id - MAS session ID
-** update_rsp - update inbox is allowed or not
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseUpdateInboxRsp(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MSE_UPDATE_INBOX_TYPE update_rsp)
-{
- tBTA_MSE_API_UPDINBRSP *p_buf;
-
- if ((p_buf = (tBTA_MSE_API_UPDINBRSP *)GKI_getbuf((UINT16)(sizeof(tBTA_MSE_API_UPDINBRSP)))) != NULL)
- {
- p_buf->hdr.event = BTA_MSE_API_UPD_IBX_RSP_EVT;
- p_buf->mas_session_id = mas_session_id;
- p_buf->rsp = update_rsp;
- bta_sys_sendmsg(p_buf);
- }
-}
-/*******************************************************************************
-**
-** Function BTA_MseSetNotifRegRsp
-**
-** Description Send a response for the set notification registration
-**
-**
-** Parameters mas_session_id - MAS session ID
-** set_notif_reg_rsp - indicate whether the set notification
-** registration is allowed or not
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseSetNotifRegRsp(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MSE_SET_NOTIF_REG_TYPE set_notif_reg_rsp)
-{
- tBTA_MSE_API_SETNOTIFREGRSP *p_buf;
-
- if ((p_buf = (tBTA_MSE_API_SETNOTIFREGRSP *)GKI_getbuf((UINT16)(sizeof(tBTA_MSE_API_UPDINBRSP)))) != NULL)
- {
- p_buf->hdr.event = BTA_MSE_API_SET_NOTIF_REG_RSP_EVT;
- p_buf->mas_session_id = mas_session_id;
- p_buf->rsp = set_notif_reg_rsp;
- bta_sys_sendmsg(p_buf);
- }
-}
-/*******************************************************************************
-**
-** Function BTA_MseSendNotif
-**
-** Description Send a Message notification report to all MCEs registered with
-** the specified MAS instance ID
-**
-** Parameters mas_instance_id - MAS Instance ID
-** notif_type - message notification type
-** handle - message handle
-** p_folder - pointer to current folder
-** p_old_folder - pointer to older folder
-** msg_type - message type (E_MAIL, SMS_GSM, SMS_CDMA, MMS)
-** except_bd_addr - except to the MCE on this BD Address.
-** (Note: notification will be not sent to
-** this BD Addreess)
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseSendNotif(tBTA_MA_INST_ID mas_instance_id,
- tBTA_MSE_NOTIF_TYPE notif_type,
- tBTA_MA_MSG_HANDLE handle,
- char * p_folder, char *p_old_folder,
- tBTA_MA_MSG_TYPE msg_type,
- BD_ADDR except_bd_addr)
-{
- tBTA_MSE_MN_API_SEND_NOTIF *p_buf;
- UINT16 folder_len, old_folder_len;
-
- /* If directory is specified set the length */
- folder_len = (p_folder && *p_folder != '\0') ? (UINT16)(strlen(p_folder) + 1): 0;
- old_folder_len = (p_old_folder && *p_old_folder != '\0') ? (UINT16)(strlen(p_old_folder) + 1): 0;
-
- if ((p_buf = (tBTA_MSE_MN_API_SEND_NOTIF *)GKI_getbuf((UINT16) ((UINT16)sizeof(tBTA_MSE_MN_API_SEND_NOTIF) +
- folder_len +
- old_folder_len))) != NULL)
- {
- p_buf->hdr.event = BTA_MSE_API_SEND_NOTIF_EVT;
- p_buf->mas_instance_id = mas_instance_id;
- p_buf->notif_type = notif_type;
- memcpy(p_buf->handle, handle, sizeof(tBTA_MA_MSG_HANDLE));
-
- if (folder_len)
- {
- p_buf->p_folder = (char *)(p_buf + 1);
- BCM_STRNCPY_S(p_buf->p_folder, folder_len+1, p_folder, folder_len);
- }
- else
- p_buf->p_folder = NULL;
-
- if (old_folder_len)
- {
- if (folder_len)
- p_buf->p_old_folder = p_buf->p_folder + folder_len;
- else
- p_buf->p_old_folder = (char *)(p_buf + 1);
-
- BCM_STRNCPY_S(p_buf->p_old_folder, old_folder_len+1, p_old_folder, old_folder_len);
- }
- else
- p_buf->p_old_folder = NULL;
-
- p_buf->msg_type = msg_type;
- if (except_bd_addr != NULL)
- {
- bdcpy(p_buf->except_bd_addr, except_bd_addr);
- }
- else
- {
- memset(p_buf->except_bd_addr, 0, sizeof(BD_ADDR));
- }
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_MseMnAbort
-**
-** Description Abort the current OBEX multi-packt operation in MN
-**
-** Parameters mas_instance_id - MAS Instance ID
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_MseMnAbort(tBTA_MA_INST_ID mas_instance_id)
-{
- tBTA_MSE_MN_API_ABORT *p_buf;
-
- if ((p_buf = (tBTA_MSE_MN_API_ABORT *)GKI_getbuf((UINT16)(sizeof(tBTA_MSE_MN_API_ABORT)))) != NULL)
- {
- p_buf->hdr.event = BTA_MSE_API_MN_ABORT_EVT;
- p_buf->mas_instance_id = mas_instance_id;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-
-#endif /* BTA_MSE_INCLUDED */
diff --git a/bta/ma/bta_mse_cfg.c b/bta/ma/bta_mse_cfg.c
deleted file mode 100644
index 69953d0..0000000
--- a/bta/ma/bta_mse_cfg.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_mse_cfg.c
-**
-** Description: This file contains compile-time configurable constants
-** for the MSE subsystem.
-**
-** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bta_mse_api.h"
-
-#ifndef BTA_MSE_MAX_NAME_LEN
- #define BTA_MSE_MAX_NAME_LEN 256
-#endif
-
-#ifndef BTA_MSE_OBX_RSP_TOUT
- #define BTA_MSE_OBX_RSP_TOUT 2000
-#endif
-
-
-const tBTA_MSE_CFG bta_mse_cfg =
-{
- BTA_MSE_OBX_RSP_TOUT,
- BTA_MSE_MAX_NAME_LEN
-};
-
-tBTA_MSE_CFG *p_bta_mse_cfg = (tBTA_MSE_CFG *)&bta_mse_cfg;
-
diff --git a/bta/ma/bta_mse_ci.c b/bta/ma/bta_mse_ci.c
deleted file mode 100644
index dfaeb7e..0000000
--- a/bta/ma/bta_mse_ci.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_mse_ci.c
-**
-** Description: This is the implementaion for the Message Server Equipment
-** (MSE) subsystem call-in functions.
-**
-** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
-#include "bta_api.h"
-#include "bta_ma_def.h"
-#include "bta_mse_api.h"
-#include "bta_mse_co.h"
-#include "bta_mse_int.h"
-#include "bta_mse_ci.h"
-
-/*******************************************************************************
-**
-** Function bta_mse_ci_get_folder_entry
-**
-** Description This function is called in response to the
-** bta_mse_co_get_folder_entry call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK if p_entry points to a valid entry.
-** BTA_MA_STATUS_EODIR if no more entries (p_entry is ignored).
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** evt - evt from the call-out function
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_get_folder_entry(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- UINT16 evt)
-{
- tBTA_MSE_CI_GET_FENTRY *p_evt;
-
- if ((p_evt = (tBTA_MSE_CI_GET_FENTRY *)GKI_getbuf(sizeof(tBTA_MSE_CI_GET_FENTRY))) != NULL)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ci_get_folder_entry sess_id=%d, status=%d \n",
- mas_session_id, status);
-#endif
- p_evt->hdr.event = evt;
- p_evt->mas_session_id = mas_session_id;
- p_evt->status = status;
- bta_sys_sendmsg(p_evt);
- }
-}
-/*******************************************************************************
-**
-** Function bta_mse_ci_get_msg_list_info
-**
-** Description This function is called in response to the
-** bta_mse_co_get_msg_list_info call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK operation is successful.
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** evt - evt from the call-out function
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_get_msg_list_info(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- UINT16 evt)
-{
- tBTA_MSE_CI_GET_ML_INFO *p_evt;
-
- if ((p_evt = (tBTA_MSE_CI_GET_ML_INFO *)GKI_getbuf(sizeof(tBTA_MSE_CI_GET_ML_INFO))) != NULL)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ci_get_msg_list_info sess_id=%d, status=%d \n",
- mas_session_id, status);
-#endif
- p_evt->hdr.event = evt;
- p_evt->mas_session_id = mas_session_id;
- p_evt->status = status;
- bta_sys_sendmsg(p_evt);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ci_get_msg_list_entry
-**
-** Description This function is called in response to the
-** bta_mse_co_get_msg_list_entry call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK if p_entry points to a valid entry.
-** BTA_MA_STATUS_EODIR if no more entries (p_entry is ignored).
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** evt - evt from the call-out function
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_get_msg_list_entry(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- UINT16 evt)
-{
- tBTA_MSE_CI_GET_ML_ENTRY *p_evt;
-
- if ((p_evt = (tBTA_MSE_CI_GET_ML_ENTRY *)GKI_getbuf(sizeof(tBTA_MSE_CI_GET_ML_ENTRY))) != NULL)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_ci_get_msg_list_entry sess_id=%d, status=%d \n",
- mas_session_id, status);
-#endif
- p_evt->hdr.event = evt;
- p_evt->mas_session_id = mas_session_id;
- p_evt->status = status;
- bta_sys_sendmsg(p_evt);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ci_get_msg
-**
-** Description This function is called in response to the
-** bta_mse_co_get_msg call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK if p_msg points to a valid bmessage.
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** filled_buff_size - size of the filled buffer
-** multi_pkt_status - BTA_MA_MPKT_STATUS_MORE - need to get more packets
-** BTA_MA_MPKT_STATUS_LAST - last packet of the bMessage
-** frac_deliver_status - BTA_MA_FRAC_DELIVER_MORE - other fractions following
-** this bMessage
-** BTA_MA_FRAC_DELIVER_LAST - Last fraction
-** evt - evt from the call-out function
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_get_msg(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- UINT16 filled_buff_size,
- tBTA_MA_MPKT_STATUS multi_pkt_status,
- tBTA_MA_FRAC_DELIVER frac_deliver_status,
- UINT16 evt)
-{
- tBTA_MSE_CI_GET_MSG *p_evt;
-
- if ((p_evt = (tBTA_MSE_CI_GET_MSG *)GKI_getbuf(sizeof(tBTA_MSE_CI_GET_MSG))) != NULL)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT4("bta_mse_ci_get_msg sess_id=%d, status=%d, multi-pkt status=%d frac=%d\n",
- mas_session_id,
- status,
- multi_pkt_status,
- frac_deliver_status);
-#endif
- p_evt->hdr.event = evt;
- p_evt->mas_session_id = mas_session_id;
- p_evt->status = status;
- p_evt->filled_buff_size = filled_buff_size;
- p_evt->multi_pkt_status = multi_pkt_status;
- p_evt->frac_deliver_status = frac_deliver_status;
- bta_sys_sendmsg(p_evt);
- }
-}
-/*******************************************************************************
-**
-** Function bta_mse_ci_set_msg_delete_status
-**
-** Description This function is called in response to the
-** bta_mse_co_set_msg_delete_status call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK if operation is successful.
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** evt - evt from the call-out function
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_set_msg_delete_status(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- UINT16 evt)
-{
- tBTA_MSE_CI_DEL_MSG *p_evt;
-
- if ((p_evt = (tBTA_MSE_CI_DEL_MSG *)GKI_getbuf(sizeof(tBTA_MSE_CI_DEL_MSG))) != NULL)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT3("bta_mse_ci_del_msg sess_id=%d, status=%d evt=%d\n",
- mas_session_id, status, evt);
-#endif
- p_evt->hdr.event = evt;
- p_evt->mas_session_id = mas_session_id;
- p_evt->status = status;
- bta_sys_sendmsg(p_evt);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ci_push_msg
-**
-** Description This function is called in response to the
-** bta_mse_co_push_msg call-out function.
-**
-** Parameters mas_session_id - MAS session ID
-** status - BTA_MA_STATUS_OK if the message upload is successful.
-** BTA_MA_STATUS_FAIL if any errors have occurred.
-** last_packet - last packet of a multi-packet message
-** handle - message handle for the uploaded message if
-** status is BTA_MA_OK and last_packet is TRUE
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_mse_ci_push_msg(tBTA_MA_SESS_HANDLE mas_session_id,
- tBTA_MA_STATUS status,
- BOOLEAN last_packet,
- tBTA_MA_MSG_HANDLE handle,
- UINT16 evt)
-{
- tBTA_MSE_CI_PUSH_MSG *p_evt;
-
- if ((p_evt = (tBTA_MSE_CI_PUSH_MSG *)GKI_getbuf(sizeof(tBTA_MSE_CI_PUSH_MSG))) != NULL)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT4("bta_mse_ci_push_msg sess_id=%d, status=%d, last_pkt=%d evt=%d\n",
- mas_session_id,
- status,
- last_packet,
- evt);
-#endif
-
- p_evt->hdr.event = evt;
- p_evt->mas_session_id = mas_session_id;
- p_evt->status = status;
- memcpy(p_evt->handle,
- handle,
- sizeof(tBTA_MA_MSG_HANDLE));
- p_evt->last_packet = last_packet;
- bta_sys_sendmsg(p_evt);
- }
-}
-
-
diff --git a/bta/ma/bta_mse_int.h b/bta/ma/bta_mse_int.h
deleted file mode 100644
index d519b71..0000000
--- a/bta/ma/bta_mse_int.h
+++ /dev/null
@@ -1,835 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_mse_int.h
-**
-** Description: This is the private file for the message access
-** equipment (MSE) subsystem.
-**
-** Copyright (c) 1998-2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_MSE_INT_H
-#define BTA_MSE_INT_H
-
-#include "bt_target.h"
-#include "bta_sys.h"
-#include "obx_api.h"
-#include "bta_ma_def.h"
-#include "bta_mse_api.h"
-#include "bta_mse_co.h"
-#include "bta_mse_ci.h"
-#include "bta_ma_util.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-typedef tOBX_STATUS (tBTA_MA_OBX_RSP) (tOBX_HANDLE handle, UINT8 rsp_code, BT_HDR *p_pkt);
-
-#ifndef BTA_MSE_MN_DISC_SIZE
- #define BTA_MSE_MN_DISC_SIZE 500
-#endif
-
-#define BTA_MSE_64BIT_HEX_STR_SIZE (16+1)
-#define BTA_MSE_32BIT_HEX_STR_SIZE (8+1)
-
-#define BTA_MSE_MN_MAX_MSG_EVT_OBECT_SIZE 1536 /* 1.5 k */
-/* mode field in tBTA_MSE_CO_FOLDER_ENTRY (OR'd together) */
-#define BTA_MSE_A_RDONLY GOEP_A_RDONLY
-#define BTA_MSE_A_DIR GOEP_A_DIR /* Entry is a sub directory */
-
-enum
-{
- BTA_MSE_MA_GET_ACT_NEW_FOLDER_LIST = 0,
- BTA_MSE_MA_GET_ACT_CON_FOLDER_LIST,
- BTA_MSE_MA_GET_ACT_ERR_FOLDER_LIST,
- BTA_MSE_MA_GET_ACT_NEW_MSG_LIST,
- BTA_MSE_MA_GET_ACT_CON_MSG_LIST,
- BTA_MSE_MA_GET_ACT_ERR_MSG_LIST,
- BTA_MSE_MA_GET_ACT_NEW_MSG,
- BTA_MSE_MA_GET_ACT_CON_MSG,
- BTA_MSE_MA_GET_ACT_ERR_MSG,
- BTA_MSE_MA_GET_ACT_ERR,
- BTA_MSE_MA_GET_ACT_NONE,
- BTA_MSE_MA_GET_ACT_MAX
-};
-typedef UINT8 tBTA_MSE_MA_GET_ACT;
-
-enum
-{
- BTA_MSE_MA_GET_TYPE_FOLDER_LIST = 0,
- BTA_MSE_MA_GET_TYPE_MSG_LIST,
- BTA_MSE_MA_GET_TYPE_MSG,
- BTA_MSE_MA_GET_TYPE_CON_FOLDER_LIST,
- BTA_MSE_MA_GET_TYPE_CON_MSG_LIST,
- BTA_MSE_MA_GET_TYPE_CON_MSG,
- BTA_MSE_MA_GET_TYPE_NONE,
- BTA_MSE_MA_GET_TYPE_MAX
-};
-typedef UINT8 tBTA_MSE_MA_GET_TYPE;
-
-enum
-{
- BTA_MSE_MA_PUT_TYPE_NOTIF_REG = 0,
- BTA_MSE_MA_PUT_TYPE_EVT_RPT,
- BTA_MSE_MA_PUT_TYPE_NONE,
- BTA_MSE_MA_PUT_TYPE_MAX
-};
-typedef UINT8 tBTA_MSE_MA_PUT_TYPE;
-
-enum
-{
- BTA_MSE_MN_NOTIF_REG_STS_OFF = 0,
- BTA_MSE_MN_NOTIF_REG_STS_ON,
- BTA_MSE_MN_NOTIF_REG_STS_NONE,
- BTA_MSE_MN_NOTIF_REG_STS_MAX
-};
-typedef UINT8 tBTA_MSE_MN_NOTIF_REG_STS;
-
-enum
-{
- BTA_MSE_MN_ACT_TYPE_OPEN_CONN = 0,
- BTA_MSE_MN_ACT_TYPE_OPEN_CONN_NONE,
- BTA_MSE_MN_ACT_TYPE_OPEN_CONN_ERR,
- BTA_MSE_MN_ACT_TYPE_CLOSE_CONN,
- BTA_MSE_MN_ACT_TYPE_CLOSE_CONN_NONE,
- BTA_MSE_MN_ACT_TYPE_CLOSE_CONN_ERR,
- BTA_MSE_MN_ACT_TYPE_NONE,
- BTA_MSE_MN_ACT_TYPE_MAX
-};
-typedef UINT8 tBTA_MSE_MN_ACT_TYPE;
-
-typedef tOBX_STATUS (tBTA_MSE_OBX_RSP) (tOBX_HANDLE handle, UINT8 rsp_code, BT_HDR *p_pkt);
-
-/* MSE Active MA obex operation (Valid in connected state) */
-#define BTA_MSE_MA_OP_NONE 0
-#define BTA_MSE_MA_OP_SETPATH 1
-#define BTA_MSE_MA_OP_GET_FOLDER_LIST 2
-#define BTA_MSE_MA_OP_GET_MSG_LIST 3
-#define BTA_MSE_MA_OP_GET_MSG 4
-#define BTA_MSE_MA_OP_SET_STATUS 5
-#define BTA_MSE_MA_OP_PUSH_MSG 6
-
-/* MAS Active MN obex operation (Valid in connected state) */
-#define BTA_MSE_MN_OP_NONE 0
-#define BTA_MSE_MN_OP_PUT_EVT_RPT 1
-
-
-/* MN Abort state */
-#define BTA_MSE_MN_ABORT_NONE 0x0
-#define BTA_MSE_MN_ABORT_REQ_NOT_SENT 0x1
-#define BTA_MSE_MN_ABORT_REQ_SENT 0x2
-#define BTA_MSE_MN_ABORT_RSP_RCVD 0x4
-
-
-/* Response Timer Operations */
-#define BTA_MSE_TIMER_OP_NONE 0
-#define BTA_MSE_TIMER_OP_STOP 1
-#define BTA_MSE_TIMER_OP_ABORT 2
-#define BTA_MSE_TIMER_OP_ALL 0xFF /* use to stop all timers */
-
-/* State Machine Events */
-enum
-{
- /* these events are handled by the state machine */
- BTA_MSE_INT_CLOSE_EVT = BTA_SYS_EVT_START(BTA_ID_MSE),
- BTA_MSE_API_ACCESSRSP_EVT,
- BTA_MSE_API_UPD_IBX_RSP_EVT,
- BTA_MSE_API_SET_NOTIF_REG_RSP_EVT,
- BTA_MSE_INT_START_EVT,
- BTA_MSE_CI_GET_FENTRY_EVT,
- BTA_MSE_CI_GET_ML_INFO_EVT,
- BTA_MSE_CI_GET_ML_ENTRY_EVT,
- BTA_MSE_CI_GET_MSG_EVT,
- BTA_MSE_CI_PUSH_MSG_EVT,
- BTA_MSE_CI_DEL_MSG_EVT,
- BTA_MSE_MA_OBX_CONN_EVT, /* OBX Channel Connect Request */
- BTA_MSE_MA_OBX_DISC_EVT, /* OBX Channel Disconnect */
- BTA_MSE_MA_OBX_ABORT_EVT, /* OBX_operation aborted */
- BTA_MSE_MA_OBX_CLOSE_EVT, /* OBX Channel Disconnected (Link Lost) */
- BTA_MSE_MA_OBX_PUT_EVT, /* Write file data or delete */
- BTA_MSE_MA_OBX_GET_EVT, /* Read file data or folder listing */
- BTA_MSE_MA_OBX_SETPATH_EVT, /* Make or Change Directory */
- BTA_MSE_CLOSE_CMPL_EVT, /* Finished closing channel */
-
- /* Message Notification Client events */
- BTA_MSE_MN_INT_OPEN_EVT,
- BTA_MSE_MN_INT_CLOSE_EVT,
- BTA_MSE_MN_SDP_OK_EVT,
- BTA_MSE_MN_SDP_FAIL_EVT,
- BTA_MSE_MN_OBX_CONN_RSP_EVT,
- BTA_MSE_MN_OBX_PUT_RSP_EVT,
- BTA_MSE_MN_OBX_CLOSE_EVT,
- BTA_MSE_MN_OBX_TOUT_EVT,
- BTA_MSE_MN_CLOSE_CMPL_EVT,
- BTA_MSE_API_SEND_NOTIF_EVT,
- BTA_MSE_API_MN_ABORT_EVT,
- BTA_MSE_MN_OBX_ABORT_RSP_EVT,
- BTA_MSE_MN_RSP_TOUT_EVT,
-
- /* these events are handled outside the state machine */
- BTA_MSE_MN_RSP0_TOUT_EVT, /* timeout event for MN control block index 0*/
- BTA_MSE_MN_RSP1_TOUT_EVT,
- BTA_MSE_MN_RSP2_TOUT_EVT,
- BTA_MSE_MN_RSP3_TOUT_EVT,
- BTA_MSE_MN_RSP4_TOUT_EVT,
- BTA_MSE_MN_RSP5_TOUT_EVT,
- BTA_MSE_MN_RSP6_TOUT_EVT, /* Bluetooth limit for upto 7 devices*/
- BTA_MSE_API_ENABLE_EVT,
- BTA_MSE_API_DISABLE_EVT,
- BTA_MSE_API_START_EVT,
- BTA_MSE_API_STOP_EVT,
- BTA_MSE_API_CLOSE_EVT,
- BTA_MSE_API_MA_CLOSE_EVT,
- BTA_MSE_API_MN_CLOSE_EVT
-
-};
-typedef UINT16 tBTA_MSE_INT_EVT;
-
-#define BTA_MSE_MN_EVT_MIN BTA_MSE_MN_INT_OPEN_EVT
-#define BTA_MSE_MN_EVT_MAX BTA_MSE_MN_RSP_TOUT_EVT
-
-
-/* state machine states */
-enum
-{
- BTA_MSE_MA_IDLE_ST = 0, /* Idle */
- BTA_MSE_MA_LISTEN_ST, /* Listen - waiting for OBX/RFC connection */
- BTA_MSE_MA_CONN_ST, /* Connected - MA Session is active */
- BTA_MSE_MA_CLOSING_ST /* Closing is in progress */
-};
-typedef UINT8 tBTA_MSE_MA_STATE;
-
-/* data type for BTA_MSE_MA_CI_GET_FENTRY_EVT note:sdh */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MA_STATUS status;
-} tBTA_MSE_CI_GET_FENTRY;
-
-/* data type for BTA_MSE_MA_CI_GET_FENTRY_EVT note:sdh */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MA_STATUS status;
-} tBTA_MSE_CI_GET_ML_INFO;
-
-
-
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MA_STATUS status;
-} tBTA_MSE_CI_GET_ML_ENTRY;
-
-
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MA_STATUS status;
- BOOLEAN last_packet;
- tBTA_MA_MSG_HANDLE handle;
-} tBTA_MSE_CI_PUSH_MSG;
-
-
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MA_STATUS status;
- UINT16 filled_buff_size;
- tBTA_MA_MPKT_STATUS multi_pkt_status;
- tBTA_MA_FRAC_DELIVER frac_deliver_status;
-} tBTA_MSE_CI_GET_MSG;
-
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MA_STATUS status;
-} tBTA_MSE_CI_DEL_MSG;
-
-
-
-/* data type for BTA_MSE_API_ENABLE_EVT note:sdh */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MSE_CBACK *p_cback; /* pointer to application callback function */
- UINT8 app_id;
-} tBTA_MSE_API_ENABLE;
-
-
-/* data type for BTA_MSE_API_DISABLE_EVT note:sdh */
-typedef struct
-{
- BT_HDR hdr;
- UINT8 app_id;
-} tBTA_MSE_API_DISABLE;
-
-/* data type for BTA_MSE_API_START_EVT note:sdh */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_INST_ID mas_inst_id;
- char servicename[BTA_SERVICE_NAME_LEN + 1];
- char *p_root_path;
- tBTA_SEC sec_mask;
- tBTA_MA_MSG_TYPE sup_msg_type;
-} tBTA_MSE_API_START;
-
-/* data type for BTA_MSE_API_STOP_EVT note:sdh */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_INST_ID mas_inst_id;
-
-} tBTA_MSE_API_STOP;
-
-/* data type for BTA_MSE_API_CLOSE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_INST_ID mas_instance_id;
-
-} tBTA_MSE_API_CLOSE;
-
-/* data type for BTA_MSE_API_MA_CLOSE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- BD_ADDR bd_addr;
- tBTA_MA_INST_ID mas_instance_id;
-
-} tBTA_MSE_API_MA_CLOSE;
-
-/* data type for BTA_MSE_INT_CLOSE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_SESS_HANDLE mas_session_id;
-
-} tBTA_MSE_INT_CLOSE;
-
-
-/* data type for BTA_MSE_API_MN_CLOSE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- BD_ADDR bd_addr;
-} tBTA_MSE_API_MN_CLOSE;
-
-
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MSE_OPER oper;
- tBTA_MA_ACCESS_TYPE rsp;
- char *p_path;
-} tBTA_MSE_API_ACCESSRSP;
-
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MSE_UPDATE_INBOX_TYPE rsp;
- char *p_path;
-} tBTA_MSE_API_UPDINBRSP;
-
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_SESS_HANDLE mas_session_id;
- tBTA_MSE_SET_NOTIF_REG_TYPE rsp;
-} tBTA_MSE_API_SETNOTIFREGRSP;
-
-/* data type for all obex events
- hdr.event contains the MAS event
-*/
-typedef struct
-{
- BT_HDR hdr;
- tOBX_HANDLE handle;
- tOBX_EVT_PARAM param;
- BT_HDR *p_pkt;
- tOBX_EVENT obx_event;
- UINT8 rsp_code;
-} tBTA_MSE_OBX_EVT;
-
-/* OBX Response Packet Structure - Holds current response packet info */
-typedef struct
-{
- BT_HDR *p_pkt; /* (Get/Put) Holds the current OBX header for Put or Get */
- UINT8 *p_start; /* (Get/Put) Start of the Body of the packet */
- UINT16 offset; /* (Get/Put) Contains the current offset into the Body (p_start) */
- UINT16 bytes_left; /* (Get/Put) Holds bytes available left in Obx packet */
- BOOLEAN final_pkt; /* (Put) Holds the final bit of the Put packet */
-} tBTA_MSE_OBX_PKT;
-
-/* data type for BTA_MSE_MN_INT_OPEN_EVT */
-typedef struct
-{
- BT_HDR hdr;
- UINT8 ccb_idx;
- BD_ADDR bd_addr;
- tBTA_SEC sec_mask;
-}tBTA_MSE_MN_INT_OPEN;
-
-/* data type for BTA_MSE_MN_INT_OPEN_EVT */
-typedef struct
-{
- BT_HDR hdr;
- UINT8 ccb_idx;
-}tBTA_MSE_MN_INT_CLOSE;
-
-/* data type for BTA_MSE_MN_SDP_OK_EVT */
-typedef struct
-{
- BT_HDR hdr;
- UINT8 ccb_idx;
- UINT8 scn;
-}tBTA_MSE_MN_SDP_OK;
-
-
-/* data type for BTA_MSE_MN_SDP_FAIL_EVT */
-typedef struct
-{
- BT_HDR hdr;
- UINT8 ccb_idx;
-}tBTA_MSE_MN_SDP_FAIL;
-
-
-/* data type for BTA_MSE_MN_API_SEND_NOTIF_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_INST_ID mas_instance_id;
- tBTA_MSE_NOTIF_TYPE notif_type;
- tBTA_MA_MSG_HANDLE handle;
- char *p_folder;
- char *p_old_folder;
- tBTA_MA_MSG_TYPE msg_type;
- BD_ADDR except_bd_addr;
-} tBTA_MSE_MN_API_SEND_NOTIF;
-
-/* data type for BTA_MSE_API_MN_ABORT_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_MA_INST_ID mas_instance_id;
-}tBTA_MSE_MN_API_ABORT;
-
-
-/* union of all state machine event data types */
-typedef union
-{
- BT_HDR hdr;
- tBTA_MSE_API_ENABLE api_enable; /* data for BTA_MSE_API_ENABLE_EVT */
- tBTA_MSE_API_DISABLE api_disable;
- tBTA_MSE_API_START api_start;
- tBTA_MSE_API_STOP api_stop;
- tBTA_MSE_API_CLOSE api_close;
- tBTA_MSE_INT_CLOSE int_close;
- tBTA_MSE_API_MA_CLOSE api_ma_close;
- tBTA_MSE_API_MN_CLOSE api_mn_close;
- tBTA_MSE_API_ACCESSRSP api_access_rsp;
- tBTA_MSE_API_UPDINBRSP api_upd_ibx_rsp;
- tBTA_MSE_API_SETNOTIFREGRSP api_set_notif_reg_rsp;
- tBTA_MSE_OBX_EVT obx_evt;
- tBTA_MSE_CI_GET_FENTRY ci_get_fentry;
- tBTA_MSE_CI_GET_ML_INFO ci_get_ml_info;
- tBTA_MSE_CI_GET_ML_ENTRY ci_get_ml_entry;
- tBTA_MSE_CI_GET_MSG ci_get_msg;
- tBTA_MSE_CI_PUSH_MSG ci_push_msg;
- tBTA_MSE_CI_DEL_MSG ci_del_msg;
- tBTA_MSE_MN_INT_OPEN mn_int_open;
- tBTA_MSE_MN_INT_CLOSE mn_int_close;
- tBTA_MSE_MN_SDP_OK mn_sdp_ok;
- tBTA_MSE_MN_SDP_FAIL mn_sdp_fail;
- tBTA_MSE_MN_API_SEND_NOTIF mn_send_notif;
- tBTA_MSE_MN_API_ABORT mn_abort;
-
-} tBTA_MSE_DATA;
-
-typedef struct
-{
- char *p_path;
- char *p_name;
- tBTA_MA_DIR_NAV flags;
-} tBTA_MSE_OPER_SETPATH;
-
-/* Directory Listing bufer pointer */
-typedef struct
-{
- tBTA_MSE_CO_FOLDER_ENTRY *p_entry; /* Holds current directory entry */
- BOOLEAN is_root; /* TRUE if path is root directory */
-} tBTA_MSE_DIRLIST;
-
-typedef struct
-{
- UINT16 max_list_cnt;
- UINT16 start_offset;
- UINT16 list_cnt;
-} tBTA_MSE_OPER_FLIST_PARAM;
-
-/* Message Listing buffer pointers */
-typedef struct
-{
- tBTA_MSE_CO_MSG_LIST_ENTRY *p_entry;
- tBTA_MSE_CO_MSG_LIST_INFO *p_info;
- BOOLEAN pending_ml_frag;
- char *p_xml_buf;
- UINT16 offset;
- UINT16 remaing_size;
-} tBTA_MSE_MSGLIST;
-
-typedef struct
-{
- tBTA_MA_MSG_LIST_FILTER_PARAM filter;
- char *p_name;
- char *p_path;
- BOOLEAN w4info;
-} tBTA_MSE_OPER_MLIST_PARAM;
-
-
-typedef struct
-{
- BOOLEAN notif_status_rcv;
- tBTA_MA_NOTIF_STATUS notif_status;
-} tBTA_NOTIF_REG;
-
-typedef struct
-{
- tBTA_MA_GET_MSG_PARAM data;
- char *p_msg_handle;
- UINT8 *p_frac_delivery;
- UINT16 byte_get_cnt;
- UINT16 filled_buff_size;
- BOOLEAN add_frac_del_hdr;
- tBTA_MA_FRAC_DELIVER frac_deliver_status;
-} tBTA_MSE_OPER_MSG_PARAM;
-
-typedef struct
-{
- tBTA_MA_PUSH_MSG_PARAM param;
- UINT16 push_byte_cnt;
- BOOLEAN rcv_folder_name;
- BOOLEAN rcv_charset;
- BOOLEAN rcv_transparent;
- BOOLEAN rcv_retry;
- BOOLEAN first_req_pkt;
-} tBTA_MSE_OPER_PUSH_MSG;
-
-typedef struct
-{
- char *p_msg_handle;
- BOOLEAN rcv_msg_handle;
- BOOLEAN rcv_sts_ind;
- BOOLEAN rcv_sts_val;
- tBTA_MA_MSG_HANDLE handle;
- tBTA_MA_STS_INDCTR sts_ind;
- tBTA_MA_STS_VALUE sts_val;
-} tBTA_MSE_OPER_SET_MSG_STS;
-
-
-/* MAS control block */
-typedef struct
-{
- tBTA_NOTIF_REG notif_reg_req;
- tBTA_MSE_OPER_PUSH_MSG push_msg;
- tBTA_MSE_OPER_SET_MSG_STS set_msg_sts;
- tBTA_MSE_OPER_SETPATH sp;
- tBTA_MSE_OPER_FLIST_PARAM fl_param;
- tBTA_MSE_DIRLIST dir;
- tBTA_MSE_OPER_MLIST_PARAM ml_param;
- tBTA_MSE_MSGLIST ml; /* point to the Message-Listing object buffer */
- tBTA_MSE_OPER_MSG_PARAM msg_param;
- tBTA_MSE_OBX_PKT obx;
- char *p_workdir; /* Current working folder */
- tOBX_HANDLE obx_handle; /* OBEX handle,used as MAS session ID as well */
- UINT16 peer_mtu;
- BOOLEAN cout_active; /* TRUE when waiting for a call-in function */
- BOOLEAN aborting;
- BD_ADDR bd_addr; /* Device currently connected to */
- tBTA_MSE_OPER oper;
- tBTA_MSE_MA_STATE state; /* state machine state */
-
-} tBTA_MSE_MA_SESS_CB;
-
-typedef struct
-{
- tBTA_MSE_MA_SESS_CB sess_cb[BTA_MSE_NUM_SESS];
- UINT32 sdp_handle; /* SDP record handle */
- char *p_rootpath;
- tOBX_HANDLE obx_handle; /* OBEX handle ID */
- BOOLEAN stopping;
- BOOLEAN in_use;
- tBTA_SEC sec_mask;
- tBTA_MA_MSG_TYPE sup_msg_type;
- char servicename[BTA_SERVICE_NAME_LEN + 1];
- UINT8 scn; /* SCN of the MA server */
- tBTA_MA_INST_ID mas_inst_id; /* MAS instance id */
-}tBTA_MSE_MA_CB;
-
-/* state machine states */
-enum
-{
- BTA_MSE_MN_IDLE_ST = 0, /* Idle */
- BTA_MSE_MN_W4_CONN_ST, /* wait for connection state */
- BTA_MSE_MN_CONN_ST, /* Connected - MAS Session is active */
- BTA_MSE_MN_CLOSING_ST /* Closing is in progress */
-};
-typedef UINT8 tBTA_MSE_MN_STATE;
-
-/* notification registration status */
-typedef struct
-{
- BOOLEAN status;
- tBTA_MA_INST_ID mas_inst_id; /* only valid when status == TRUE*/
-} tBTA_MSE_MN_REG_STATUS;
-
-/* Message notification report */
-typedef struct
-{
- UINT16 buffer_len;
- UINT16 bytes_sent;
- BOOLEAN final_pkt;
- UINT8 pkt_cnt;
- tBTA_MA_INST_ID mas_instance_id;
- UINT8 *p_buffer;
-}tBTA_MSE_MN_MSG_NOTIF;
-
-typedef struct
-{
- tBTA_MSE_MN_REG_STATUS notif_reg[BTA_MSE_NUM_INST];
- tBTA_MSE_OBX_PKT obx; /* Holds the current OBX packet information */
- tBTA_MSE_MN_MSG_NOTIF msg_notif;
- TIMER_LIST_ENT rsp_timer; /* response timer */
- tSDP_DISCOVERY_DB *p_db; /* pointer to discovery database */
- tSDP_DISC_CMPL_CB *sdp_cback;
- tOBX_HANDLE obx_handle;
- UINT16 sdp_service;
- UINT16 peer_mtu;
- BOOLEAN in_use;
- BOOLEAN req_pending; /* TRUE when waiting for an obex response */
- BOOLEAN cout_active; /* TRUE if call-out is currently active */
- BOOLEAN sdp_pending;
- BD_ADDR bd_addr; /* Peer device MNS server address */
- tBTA_MSE_MN_STATE state; /* state machine state */
- tBTA_SEC sec_mask;
- UINT8 timer_oper; /* current active response timer action (abort or close) */
- UINT8 obx_oper; /* current active OBX operation PUT or GET operations */
- UINT8 aborting;
-}tBTA_MSE_MN_CB;
-
-typedef struct
-{
- BOOLEAN in_use;
- BD_ADDR bd_addr;
- BOOLEAN opened;
- BOOLEAN busy;
-}tBTA_MSE_PM_CB;
-
-
-typedef struct
-{
- tBTA_MSE_MA_CB scb[BTA_MSE_NUM_INST]; /* MA Server Control Blocks */
- tBTA_MSE_MN_CB ccb[BTA_MSE_NUM_MN]; /* MN Client Control Blocks */
- tBTA_MSE_PM_CB pcb[BTA_MSE_NUM_MN];
- tBTA_MSE_CBACK *p_cback; /* pointer to application event callback function */
- BOOLEAN enable;
- BOOLEAN disabling;
- UINT8 app_id;
-}tBTA_MSE_CB;
-
-/******************************************************************************
-** Configuration Definitions
-*******************************************************************************/
-/* Configuration structure */
-typedef struct
-{
- INT32 abort_tout; /* Timeout in milliseconds to wait for abort OBEX response (client only) */
- INT32 stop_tout; /* Timeout in milliseconds to wait for close OBEX response (client only) */
-
-} tBTA_MSE_MA_CFG;
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* MAS control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-extern tBTA_MSE_CB bta_mse_cb;
-#else
-extern tBTA_MSE_CB *bta_mse_cb_ptr;
- #define bta_mse_cb (*bta_mse_cb_ptr)
-#endif
-
-#define BTA_MSE_GET_INST_CB_PTR(inst_idx) &(bta_mse_cb.scb[(inst_idx)])
-#define BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx ) &(bta_mse_cb.scb[(inst_idx)].sess_cb[(sess_idx)])
-#define BTA_MSE_GET_MN_CB_PTR(ccb_idx) &(bta_mse_cb.ccb[(ccb_idx)])
-#define BTA_MSE_GET_PM_CB_PTR(pcb_idx) &(bta_mse_cb.pcb[(pcb_idx)])
-/* MAS configuration constants */
-extern tBTA_MSE_MA_CFG * p_bta_ms_cfg;
-
-/*****************************************************************************
-** Function prototypes
-*****************************************************************************/
-/* MSE event handler for MA and MN */
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- extern BOOLEAN bta_mse_hdl_event(BT_HDR *p_msg);
-
-/* State machine drivers */
- extern void bta_mse_ma_sm_execute(UINT8 inst_idx, UINT8 sess_idx, UINT16 event, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_sm_execute(UINT8 ccb_idx, UINT16 event, tBTA_MSE_DATA *p_data);
-
- extern void bta_mse_ma_sdp_register (tBTA_MSE_MA_CB *p_scb, char *p_service_name, tBTA_MA_INST_ID inst_id, tBTA_MA_MSG_TYPE msg_type);
-
-/* Obx callback functions */
- extern void bta_mse_ma_obx_cback (tOBX_HANDLE handle, tOBX_EVENT event,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt);
-
- extern void bta_mse_mn_obx_cback (tOBX_HANDLE handle, tOBX_EVENT obx_event, UINT8 rsp_code,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt);
-
-/* action functions for MA */
- extern void bta_mse_ma_int_close(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_api_accessrsp(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_api_upd_ibx_rsp(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_api_set_notif_reg_rsp(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
-
- extern void bta_mse_ma_ci_get_folder_entry(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_ci_get_ml_info(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_ci_get_ml_entry(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_ci_get_msg(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_ci_push_msg(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_ci_del_msg(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
-
- extern void bta_mse_ma_obx_disc(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_obx_connect(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_obx_close(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_obx_abort(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_obx_put(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_obx_get(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_obx_setpath(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_conn_err_rsp(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_ma_close_complete(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
-
-/* action function for MN */
- extern void bta_mse_mn_init_sdp(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_start_client(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_stop_client(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_obx_conn_rsp(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_close(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_send_notif(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_rsp_timeout(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_put_rsp(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_obx_tout(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_close_compl(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_ignore_obx(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_sdp_fail(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_abort(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
- extern void bta_mse_mn_abort_rsp(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
-
-
-/* miscellaneous functions */
- extern void bta_mse_discard_data(UINT16 event, tBTA_MSE_DATA *p_data);
-
-/* utility functions */
-
- extern void bta_mse_send_push_msg_in_prog_evt(UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_send_get_msg_in_prog_evt(UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_send_oper_cmpl_evt(UINT8 inst_idx, UINT8 sess_idx, tBTA_MA_STATUS status);
- extern void bta_mse_pushmsg(UINT8 inst_idx, UINT8 sess_idx, BOOLEAN first_pkt);
- extern void bta_mse_clean_set_msg_sts(UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_clean_set_notif_reg(UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_clean_push_msg(UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_init_set_msg_sts(UINT8 inst_idx, UINT8 sess_idx, UINT8 *p_rsp_code);
- extern void bta_mse_init_push_msg(UINT8 inst_idx, UINT8 sess_idx, UINT8 *p_rsp_code);
- extern void bta_mse_remove_uuid(void);
- extern void bta_mse_clean_mas_service(UINT8 inst_idx);
- extern void bta_mse_abort_too_late(UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_clean_getput(UINT8 inst_idx, UINT8 sess_idx, tBTA_MA_STATUS status);
- extern void bta_mse_clean_msg(UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_end_of_msg(UINT8 inst_idx, UINT8 sess_idx, UINT8 rsp_code);
- extern void bta_mse_getmsg(UINT8 inst_idx, UINT8 sess_idx, BOOLEAN new_req);
- extern tBTA_MA_STATUS bta_mse_build_msg_listing_obj(tBTA_MSE_CO_MSG_LIST_ENTRY *p_entry,
- UINT16 *p_size, char *p_buf );
- extern void bta_mse_clean_msg_list(UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_end_of_msg_list(UINT8 inst_idx, UINT8 sess_idx, UINT8 rsp_code);
- extern UINT8 bta_mse_add_msg_list_info(UINT8 inst_idx, UINT8 sess_idx);
- extern UINT8 bta_mse_add_msg_list_entry(UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_getmsglist(UINT8 inst_idx, UINT8 sess_idx,BOOLEAN new_req);
- extern UINT8 * bta_mse_read_app_params(BT_HDR *p_pkt, UINT8 tag, UINT16 *param_len);
- extern void bta_mse_clean_list(UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_end_of_list(UINT8 inst_idx, UINT8 sess_idx, UINT8 rsp_code);
- extern UINT8 bta_mse_add_list_entry(UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_getfolderlist(UINT8 inst_idx, UINT8 sess_idx, BOOLEAN new_req);
- extern UINT8 bta_mse_chdir(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_OPER *p_oper);
- extern BOOLEAN bta_mse_send_set_notif_reg(UINT8 status,
- UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_proc_notif_reg_status(UINT8 status,
- UINT8 inst_idx, UINT8 sess_idx);
- extern void bta_mse_discard_data(UINT16 event, tBTA_MSE_DATA *p_data);
- extern BOOLEAN bta_mse_find_bd_addr_match_sess_cb_idx(BD_ADDR bd_addr, UINT8 inst_idx, UINT8 *p_idx);
- extern BOOLEAN bta_mse_find_mas_inst_id_match_cb_idx(tBTA_MA_INST_ID mas_inst_id, UINT8 *p_idx);
- extern BOOLEAN bta_mse_find_handle_match_mas_inst_cb_idx(tOBX_HANDLE obx_handle, UINT8 *p_idx);
- extern BOOLEAN bta_mse_find_mas_sess_cb_idx(tOBX_HANDLE obx_handle, UINT8 *p_mas_inst_idx, UINT8 *p_mas_sess_idx);
- extern BOOLEAN bta_mse_find_ma_cb_indexes(tBTA_MSE_DATA *p_msg, UINT8 *p_inst_idx, UINT8 *p_sess_idx);
- extern void bta_mse_ma_cleanup(tBTA_MSE_DATA *p_msg);
- extern BOOLEAN bta_mse_is_a_duplicate_id(tBTA_MA_INST_ID mas_inst_id);
- extern BOOLEAN bta_mse_find_avail_mas_inst_cb_idx(UINT8 *p_idx);
- extern BOOLEAN bta_mse_find_avail_mas_sess_cb_idx(tBTA_MSE_MA_CB *p_scb, UINT8 *p_idx);
- extern BOOLEAN bta_mse_find_sess_id_match_ma_cb_indexes(tBTA_MA_SESS_HANDLE mas_session_id,
- UINT8 *p_inst_idx, UINT8 *p_sess_idx);
- extern BOOLEAN bta_mse_find_avail_mn_cb_idx(UINT8 *p_idx);
- extern BOOLEAN bta_mse_find_bd_addr_match_mn_cb_index(BD_ADDR p_bd_addr, UINT8 *p_idx);
- extern BOOLEAN bta_mse_find_sess_id_match_mn_cb_index(tBTA_MA_SESS_HANDLE mas_session_id,
- UINT8 *p_idx);
- extern BOOLEAN bta_mse_find_mn_cb_index(tBTA_MSE_DATA *p_msg, UINT8 *p_ccb_idx);
- extern void bta_mse_mn_cleanup(tBTA_MSE_DATA *p_msg);
- extern tBTA_MA_STATUS bta_mse_build_map_event_rpt_obj(tBTA_MSE_NOTIF_TYPE notif_type,
- tBTA_MA_MSG_HANDLE handle,
- char * p_folder,
- char * p_old_folder,
- tBTA_MA_MSG_TYPE msg_typ,
- UINT16 * p_len,
- UINT8 * p_buffer);
- extern void bta_mse_mn_start_timer(UINT8 ccb_idx, UINT8 timer_id);
- extern void bta_mse_mn_stop_timer(UINT8 ccb_idx, UINT8 timer_id);
- extern BOOLEAN bta_mse_mn_add_inst_id(UINT8 ccb_idx, tBTA_MA_INST_ID mas_inst_id);
- extern BOOLEAN bta_mse_mn_remove_inst_id(UINT8 ccb_idx, tBTA_MA_INST_ID mas_inst_id);
- extern void bta_mse_mn_remove_all_inst_ids(UINT8 ccb_idx);
- extern UINT8 bta_mse_mn_find_num_of_act_inst_id(UINT8 ccb_idx);
- extern BOOLEAN bta_mse_mn_is_inst_id_exist(UINT8 ccb_idx, tBTA_MA_INST_ID mas_inst_id );
- extern BOOLEAN bta_mse_mn_is_ok_to_close_mn(BD_ADDR bd_addr, tBTA_MA_INST_ID mas_inst_id );
- extern BOOLEAN bta_mse_mn_get_first_inst_id(UINT8 ccb_idx, tBTA_MA_INST_ID *p_mas_inst_id);
- extern tBTA_MA_STATUS bta_mse_mn_cont_send_notif(UINT8 ccb_idx, BOOLEAN first_pkt);
- extern void bta_mse_mn_send_notif_evt(tBTA_MA_INST_ID mas_instance_id, tBTA_MA_STATUS status,
- BD_ADDR bd_addr );
- extern void bta_mse_mn_clean_send_notif(UINT8 ccb_idx);
- extern void bta_mse_ma_fl_read_app_params(UINT8 inst_idx, UINT8 sess_idx, BT_HDR *p_pkt);
- extern void bta_mse_ma_ml_read_app_params(UINT8 inst_idx, UINT8 sess_idx, BT_HDR *p_pkt);
- extern BOOLEAN bta_mse_ma_msg_read_app_params(UINT8 inst_idx, UINT8 sess_idx, BT_HDR *p_pkt);
- extern BOOLEAN bta_mse_get_msglist_path(UINT8 inst_idx, UINT8 sess_idx);
-
- extern BOOLEAN bta_mse_find_pm_cb_index(BD_ADDR p_bd_addr, UINT8 *p_idx);
- extern BOOLEAN bta_mse_find_avail_pm_cb_idx(UINT8 *p_idx);
- extern void bta_mse_pm_conn_open(BD_ADDR bd_addr);
- extern void bta_mse_pm_conn_close(BD_ADDR bd_addr);
- extern void bta_mse_set_ma_oper(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_OPER oper);
- extern void bta_mse_set_mn_oper(UINT8 ccb_idx, UINT8 oper);
-#ifdef __cplusplus
-}
-#endif
-#endif /* BTA_MSE_INT_H */
diff --git a/bta/ma/bta_mse_main.c b/bta/ma/bta_mse_main.c
deleted file mode 100644
index feddd09..0000000
--- a/bta/ma/bta_mse_main.c
+++ /dev/null
@@ -1,1367 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_mse_main.c
-**
-** Description: This file contains the Message Access Server main functions
-** and state machine.
-**
-** Copyright (c) 1998-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_MSE_INCLUDED) && (BTA_MSE_INCLUDED == TRUE)
-
-#include <string.h>
-
-#include "bta_fs_api.h"
-#include "bta_mse_int.h"
-#include "gki.h"
-#include "utl.h"
-#include "obx_api.h"
-
-/*****************************************************************************
-** Message Access Server State Table
-*****************************************************************************/
-/*****************************************************************************
-** Constants and types
-*****************************************************************************/
-/* state machine action enumeration list for MAS */
-enum
-{
- BTA_MSE_MA_INT_CLOSE,
- BTA_MSE_MA_API_ACCESSRSP,
- BTA_MSE_MA_API_UPD_IBX_RSP,
- BTA_MSE_MA_API_SET_NOTIF_REG_RSP,
- BTA_MSE_MA_CI_GET_FENTRY,
- BTA_MSE_MA_CI_GET_ML_INFO,
- BTA_MSE_MA_CI_GET_ML_ENTRY,
- BTA_MSE_MA_CI_GET_MSG,
- BTA_MSE_MA_CI_PUSH_MSG,
- BTA_MSE_MA_CI_DEL_MSG,
- BTA_MSE_MA_OBX_CONNECT,
- BTA_MSE_MA_OBX_DISC,
- BTA_MSE_MA_OBX_CLOSE,
- BTA_MSE_MA_OBX_ABORT,
- BTA_MSE_MA_OBX_PUT,
- BTA_MSE_MA_OBX_GET,
- BTA_MSE_MA_OBX_SETPATH,
- BTA_MSE_MA_CONN_ERR_RSP,
- BTA_MSE_MA_CLOSE_COMPLETE,
- BTA_MSE_MA_IGNORE
-};
-
-/* type for action functions */
-typedef void (*tBTA_MSE_MA_ACTION)(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_DATA *p_data);
-
-/* action function list for MAS */
-const tBTA_MSE_MA_ACTION bta_mse_ma_action[] =
-{
- bta_mse_ma_int_close,
- bta_mse_ma_api_accessrsp,
- bta_mse_ma_api_upd_ibx_rsp,
- bta_mse_ma_api_set_notif_reg_rsp,
- bta_mse_ma_ci_get_folder_entry,
- bta_mse_ma_ci_get_ml_info,
- bta_mse_ma_ci_get_ml_entry,
- bta_mse_ma_ci_get_msg,
- bta_mse_ma_ci_push_msg,
- bta_mse_ma_ci_del_msg,
- bta_mse_ma_obx_connect,
- bta_mse_ma_obx_disc,
- bta_mse_ma_obx_close,
- bta_mse_ma_obx_abort,
- bta_mse_ma_obx_put,
- bta_mse_ma_obx_get,
- bta_mse_ma_obx_setpath,
- bta_mse_ma_conn_err_rsp,
- bta_mse_ma_close_complete,
-};
-
-
-/* state table information */
-#define BTA_MSE_MA_ACTIONS 1 /* number of actions */
-#define BTA_MSE_MA_NEXT_STATE 1 /* position of next state */
-#define BTA_MSE_MA_NUM_COLS 2 /* number of columns in state tables */
-
-
-/* state table for MAS idle state */
-static const UINT8 bta_mse_ma_st_idle[][BTA_MSE_MA_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_MSE_INT_CLOSE_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_API_ACCESSRSP_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_API_UPD_IBX_RSP_EVT*/ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_API_SET_NOTIF_REG_RSP_EVT*/ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_INT_START_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-
-/* BTA_MSE_CI_GET_FENTRY_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_CI_GET_ML_INFO_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_CI_GET_ML_ENTRY_EVT*/ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_CI_GET_MSG_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_CI_PUSH_MSG_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_CI_DEL_MSG_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-
-/* BTA_MSE_MA_OBX_CONN_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_MA_OBX_DISC_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_MA_OBX_ABORT_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_MA_OBX_CLOSE_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_MA_OBX_PUT_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_MA_OBX_GET_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_MA_OBX_SETPATH_EVT*/ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-/* BTA_MSE_CLOSE_CMPL_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_IDLE_ST},
-};
-
-/* state table for obex/rfcomm connection state */
-static const UINT8 bta_mse_ma_st_listen[][BTA_MSE_MA_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_MSE_INT_CLOSE_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_API_ACCESSRSP_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_API_UPD_IBX_RSP_EVT*/ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_API_SET_NOTIF_REG_RSP_EVT*/{BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_MA_INT_START_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_CI_GET_FENTRY_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_CI_GET_ML_INFO_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_CI_GET_ML_ENTRY_EVT*/ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_CI_GET_MSG_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_CI_PUSH_MSG_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_CI_DEL_MSG_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_MA_OBX_CONN_EVT */ {BTA_MSE_MA_OBX_CONNECT, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_MA_OBX_DISC_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_MA_OBX_ABORT_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_MA_OBX_CLOSE_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_MA_OBX_PUT_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_MA_OBX_GET_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_MA_OBX_SETPATH_EVT*/ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-/* BTA_MSE_CLOSE_CMPL_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_LISTEN_ST},
-};
-
-/* state table for open state */
-static const UINT8 bta_mse_ma_st_connected[][BTA_MSE_MA_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_MSE_INT_CLOSE_EVT */ {BTA_MSE_MA_INT_CLOSE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_API_ACCESSRSP_EVT */ {BTA_MSE_MA_API_ACCESSRSP, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_API_UPD_IBX_RSP_EVT*/ {BTA_MSE_MA_API_UPD_IBX_RSP, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_API_SET_NOTIF_REG_RSP_EVT*/{BTA_MSE_MA_API_SET_NOTIF_REG_RSP,BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_MA_INT_START_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_CI_GET_FENTRY_EVT */ {BTA_MSE_MA_CI_GET_FENTRY, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_CI_GET_ML_INFO_EVT */ {BTA_MSE_MA_CI_GET_ML_INFO, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_CI_GET_ML_ENTRY_EVT*/ {BTA_MSE_MA_CI_GET_ML_ENTRY, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_CI_GET_MSG_EVT */ {BTA_MSE_MA_CI_GET_MSG, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_CI_PUSH_MSG_EVT */ {BTA_MSE_MA_CI_PUSH_MSG, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_CI_DEL_MSG_EVT */ {BTA_MSE_MA_CI_DEL_MSG, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_MA_OBX_CONN_EVT */ {BTA_MSE_MA_CONN_ERR_RSP, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_MA_OBX_DISC_EVT */ {BTA_MSE_MA_OBX_DISC, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_MA_OBX_ABORT_EVT */ {BTA_MSE_MA_OBX_ABORT, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_MA_OBX_CLOSE_EVT */ {BTA_MSE_MA_OBX_CLOSE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_MA_OBX_PUT_EVT */ {BTA_MSE_MA_OBX_PUT, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_MA_OBX_GET_EVT */ {BTA_MSE_MA_OBX_GET, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_MA_OBX_SETPATH_EVT*/ {BTA_MSE_MA_OBX_SETPATH, BTA_MSE_MA_CONN_ST},
-/* BTA_MSE_CLOSE_CMPL_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_CONN_ST},
-};
-
-/* state table for closing state */
-static const UINT8 bta_mse_ma_st_closing[][BTA_MSE_MA_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_MSE_INT_CLOSE_EVT */ {BTA_MSE_MA_INT_CLOSE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_API_ACCESSRSP_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_API_UPD_IBX_RSP_EVT*/ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_API_SET_NOTIF_REG_RSP_EVT*/{BTA_MSE_MA_IGNORE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_MA_INT_START_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_CI_GET_FENTRY_EVT */ {BTA_MSE_MA_CLOSE_COMPLETE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_CI_GET_ML_INFO_EVT*/ {BTA_MSE_MA_CLOSE_COMPLETE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_CI_GET_ML_ENTRY_EVT*/ {BTA_MSE_MA_CLOSE_COMPLETE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_CI_GET_MSG_EVT */ {BTA_MSE_MA_CLOSE_COMPLETE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_CI_PUSH_MSG_EVT */ {BTA_MSE_MA_CLOSE_COMPLETE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_CI_DEL_MSG_EVT */ {BTA_MSE_MA_CLOSE_COMPLETE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_MA_OBX_CONN_EVT */ {BTA_MSE_MA_CONN_ERR_RSP, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_MA_OBX_DISC_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_MA_OBX_ABORT_EVT */ {BTA_MSE_MA_OBX_ABORT, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_MA_OBX_CLOSE_EVT */ {BTA_MSE_MA_OBX_CLOSE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_MA_OBX_PUT_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_MA_OBX_GET_EVT */ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_MA_OBX_SETPATH_EVT*/ {BTA_MSE_MA_IGNORE, BTA_MSE_MA_CLOSING_ST},
-/* BTA_MSE_CLOSE_CMPL_EVT */ {BTA_MSE_MA_CLOSE_COMPLETE, BTA_MSE_MA_LISTEN_ST},
-};
-
-/* type for state table MAS */
-typedef const UINT8 (*tBTA_MSE_MA_ST_TBL)[BTA_MSE_MA_NUM_COLS];
-
-/* MAS state table */
-const tBTA_MSE_MA_ST_TBL bta_mse_ma_st_tbl[] =
-{
- bta_mse_ma_st_idle,
- bta_mse_ma_st_listen,
- bta_mse_ma_st_connected,
- bta_mse_ma_st_closing
-};
-
-/*****************************************************************************
-** Message Notification Client State Table
-*****************************************************************************/
-/*****************************************************************************
-** Constants and types
-*****************************************************************************/
-/* state machine action enumeration list for MNC */
-/* The order of this enumeration must be the same as bta_mse_mn_act_tbl[] */
-enum
-{
- BTA_MSE_MN_INIT_SDP,
- BTA_MSE_MN_START_CLIENT,
- BTA_MSE_MN_STOP_CLIENT,
- BTA_MSE_MN_OBX_CONN_RSP,
- BTA_MSE_MN_CLOSE,
- BTA_MSE_MN_SEND_NOTIF,
- BTA_MSE_MN_RSP_TIMEOUT,
- BTA_MSE_MN_PUT_RSP,
- BTA_MSE_MN_OBX_TOUT,
- BTA_MSE_MN_CLOSE_COMPL,
- BTA_MSE_MN_ABORT,
- BTA_MSE_MN_ABORT_RSP,
- BTA_MSE_MN_SDP_FAIL,
- BTA_MSE_MN_IGNORE_OBX,
- BTA_MSE_MN_IGNORE
-};
-
-typedef void (*tBTA_MSE_MN_ACTION)(UINT8 ccb_idx, tBTA_MSE_DATA *p_data);
-
-static const tBTA_MSE_MN_ACTION bta_mse_mn_action[] =
-{
- bta_mse_mn_init_sdp,
- bta_mse_mn_start_client,
- bta_mse_mn_stop_client,
- bta_mse_mn_obx_conn_rsp,
- bta_mse_mn_close,
- bta_mse_mn_send_notif,
- bta_mse_mn_rsp_timeout,
- bta_mse_mn_put_rsp,
- bta_mse_mn_obx_tout,
- bta_mse_mn_close_compl,
- bta_mse_mn_abort,
- bta_mse_mn_abort_rsp,
- bta_mse_mn_sdp_fail,
- bta_mse_mn_ignore_obx
-};
-
-
-/* state table information */
-#define BTA_MSE_MN_ACTIONS 1 /* number of actions */
-#define BTA_MSE_MN_ACTION_COL 0 /* position of action */
-#define BTA_MSE_MN_NEXT_STATE 1 /* position of next state */
-#define BTA_MSE_MN_NUM_COLS 2 /* number of columns in state tables */
-
-/* state table for idle state */
-static const UINT8 bta_mse_mn_st_idle[][BTA_MSE_MN_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_MSE_MN_INT_OPEN_EVT */ {BTA_MSE_MN_INIT_SDP, BTA_MSE_MN_W4_CONN_ST},
-/* BTA_MSE_MN_INT_CLOSE_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_MN_SDP_OK_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_MN_SDP_FAIL_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_MN_OBX_CONN_RSP_EVT */ {BTA_MSE_MN_IGNORE_OBX, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_MN_OBX_PUT_RSP_EVT */ {BTA_MSE_MN_IGNORE_OBX, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_MN_OBX_CLOSE_EVT */ {BTA_MSE_MN_IGNORE_OBX, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_MN_OBX_TOUT_EVT */ {BTA_MSE_MN_IGNORE_OBX, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_MN_CLOSE_CMPL_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_API_SEND_NOTIF_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_API_MN_ABORT_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_MN_OBX_ABORT_RSP_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_MN_RSP_TOUT_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_IDLE_ST}
-};
-
-
-/* state table for wait for authentication state */
-static const UINT8 bta_mse_mn_st_w4_conn[][BTA_MSE_MN_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_MSE_MN_INT_OPEN_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_W4_CONN_ST},
-/* BTA_MSE_MN_INT_CLOSE_EVT */ {BTA_MSE_MN_STOP_CLIENT, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_SDP_OK_EVT */ {BTA_MSE_MN_START_CLIENT, BTA_MSE_MN_W4_CONN_ST},
-/* BTA_MSE_MN_SDP_FAIL_EVT */ {BTA_MSE_MN_SDP_FAIL, BTA_MSE_MN_W4_CONN_ST},
-/* BTA_MSE_MN_OBX_CONN_RSP_EVT */ {BTA_MSE_MN_OBX_CONN_RSP, BTA_MSE_MN_CONN_ST},
-/* BTA_MSE_MN_OBX_PUT_RSP_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_W4_CONN_ST},
-/* BTA_MSE_MN_OBX_CLOSE_EVT */ {BTA_MSE_MN_CLOSE, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_OBX_TOUT_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_W4_CONN_ST},
-/* BTA_MSE_MN_CLOSE_CMPL_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_W4_CONN_ST},
-/* BTA_MSE_API_SEND_NOTIF_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_W4_CONN_ST},
-/* BTA_MSE_API_MN_ABORT_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_W4_CONN_ST},
-/* BTA_MSE_MN_OBX_ABORT_RSP_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_W4_CONN_ST},
-/* BTA_MSE_MN_RSP_TOUT_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_W4_CONN_ST}
-};
-
-/* state table for connected state */
-static const UINT8 bta_mse_mn_st_connected[][BTA_MSE_MN_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_MSE_MN_INT_OPEN_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CONN_ST},
-/* BTA_MSE_MN_INT_CLOSE_EVT */ {BTA_MSE_MN_STOP_CLIENT, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_SDP_OK_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CONN_ST},
-/* BTA_MSE_MN_SDP_FAIL_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CONN_ST},
-/* BTA_MSE_MN_OBX_CONN_RSP_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CONN_ST},
-/* BTA_MSE_MN_OBX_PUT_RSP_EVT */ {BTA_MSE_MN_PUT_RSP, BTA_MSE_MN_CONN_ST},
-/* BTA_MSE_MN_OBX_CLOSE_EVT */ {BTA_MSE_MN_CLOSE, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_OBX_TOUT_EVT */ {BTA_MSE_MN_OBX_TOUT, BTA_MSE_MN_CONN_ST},
-/* BTA_MSE_MN_CLOSE_CMPL_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CONN_ST},
-/* BTA_MSE_API_SEND_NOTIF_EVT */ {BTA_MSE_MN_SEND_NOTIF, BTA_MSE_MN_CONN_ST},
-/* BTA_MSE_API_MN_ABORT_EVT */ {BTA_MSE_MN_ABORT, BTA_MSE_MN_CONN_ST},
-/* BTA_MSE_MN_OBX_ABORT_RSP_EVT */ {BTA_MSE_MN_ABORT_RSP, BTA_MSE_MN_CONN_ST},
-/* BTA_MSE_MN_RSP_TOUT_EVT */ {BTA_MSE_MN_RSP_TIMEOUT, BTA_MSE_MN_CLOSING_ST}
-};
-
-/* state table for closing state */
-static const UINT8 bta_mse_mn_st_closing[][BTA_MSE_MN_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_MSE_MN_INT_OPEN_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_INT_CLOSE_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_SDP_OK_EVT */ {BTA_MSE_MN_CLOSE_COMPL, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_MN_SDP_FAIL_EVT */ {BTA_MSE_MN_CLOSE_COMPL, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_MN_OBX_CONN_RSP_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_OBX_PUT_RSP_EVT */ {BTA_MSE_MN_IGNORE_OBX, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_OBX_CLOSE_EVT */ {BTA_MSE_MN_CLOSE, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_OBX_TOUT_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_CLOSE_CMPL_EVT */ {BTA_MSE_MN_CLOSE_COMPL, BTA_MSE_MN_IDLE_ST},
-/* BTA_MSE_API_SEND_NOTIF_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_API_MN_ABORT_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_OBX_ABORT_RSP_EVT */ {BTA_MSE_MN_IGNORE, BTA_MSE_MN_CLOSING_ST},
-/* BTA_MSE_MN_RSP_TOUT_EVT */ {BTA_MSE_MN_RSP_TIMEOUT, BTA_MSE_MN_CLOSING_ST}
-};
-
-/* type for state table */
-typedef const UINT8 (*tBTA_MSE_MN_ST_TBL)[BTA_MSE_MN_NUM_COLS];
-
-/* state table */
-const tBTA_MSE_MN_ST_TBL bta_mse_mn_st_tbl[] =
-{
- bta_mse_mn_st_idle,
- bta_mse_mn_st_w4_conn,
- bta_mse_mn_st_connected,
- bta_mse_mn_st_closing
-};
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* MSE control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-tBTA_MSE_CB bta_mse_cb;
-#endif
-
-#if (BTA_MSE_DEBUG == TRUE) && (BT_USE_TRACES == TRUE)
-
-static char *bta_mse_evt_code(tBTA_MSE_INT_EVT evt_code);
-static char *bta_mse_ma_state_code(tBTA_MSE_MA_STATE state_code);
-static char *bta_mse_mn_state_code(tBTA_MSE_MN_STATE state_code);
-#endif
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_sm_execute
-**
-** Description State machine event handling function for MA
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** event - MA event
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_sm_execute(UINT8 inst_idx, UINT8 sess_idx, UINT16 event, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MA_ST_TBL state_table;
- UINT8 action;
- int i;
- tBTA_MSE_MA_SESS_CB *p_cb = &(bta_mse_cb.scb[inst_idx].sess_cb[sess_idx]);
-
-#if (BTA_MSE_DEBUG == TRUE) && (BT_USE_TRACES == TRUE)
- tBTA_MSE_MA_STATE in_state = p_cb->state;
- UINT16 cur_evt = event;
- APPL_TRACE_EVENT3("MSE MA Event Handler: State 0x%02x [%s], Event [%s]", in_state,
- bta_mse_ma_state_code(in_state),
- bta_mse_evt_code(cur_evt));
-#endif
-
- /* look up the state table for the current state */
- state_table = bta_mse_ma_st_tbl[p_cb->state];
-
- event &= 0x00FF;
-
- /* set next state */
- p_cb->state = state_table[event][BTA_MSE_MA_NEXT_STATE];
-
- /* execute action functions */
- for (i = 0; i < BTA_MSE_MA_ACTIONS; i++)
- {
- if ((action = state_table[event][i]) != BTA_MSE_MA_IGNORE)
- {
- (*bta_mse_ma_action[action])(inst_idx, sess_idx, p_data);
- }
- else
- {
- /* discard mas data */
- bta_mse_discard_data(p_data->hdr.event, p_data);
- break;
- }
- }
-#if (BTA_MSE_DEBUG == TRUE) && (BT_USE_TRACES == TRUE)
- if (in_state != p_cb->state)
- {
- APPL_TRACE_EVENT3("MSE MA State Change: [%s] -> [%s] after Event [%s]",
- bta_mse_ma_state_code(in_state),
- bta_mse_ma_state_code(p_cb->state),
- bta_mse_evt_code(cur_evt));
- }
-#endif
-
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_sm_execute
-**
-** Description State machine event handling function for MNC
-**
-** Parameters mn_cb_idx - Index to the MN control block
-** event - MN event
-** p_data - Pointer to the event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_sm_execute(UINT8 mn_cb_idx, UINT16 event, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_CB *p_cb = &(bta_mse_cb.ccb[mn_cb_idx]);
- tBTA_MSE_MN_ST_TBL state_table;
- UINT8 action;
- int i;
-
-
-
-#if (BTA_MSE_DEBUG == TRUE) && (BT_USE_TRACES == TRUE)
- tBTA_MSE_MN_STATE in_state = p_cb->state;
- UINT16 cur_evt = event;
- APPL_TRACE_EVENT3("MSE MN Event Handler: State 0x%02x [%s], Event [%s]", in_state,
- bta_mse_mn_state_code(in_state),
- bta_mse_evt_code(cur_evt));
-#endif
-
- /* look up the state table for the current state */
- state_table = bta_mse_mn_st_tbl[p_cb->state];
- event -= BTA_MSE_MN_EVT_MIN;
-
- /* set next state */
- p_cb->state = state_table[event][BTA_MSE_MN_NEXT_STATE];
-
- /* execute action functions */
- for (i = 0; i < BTA_MSE_MN_ACTIONS; i++)
- {
- if ((action = state_table[event][i]) != BTA_MSE_MN_IGNORE)
- {
- (*bta_mse_mn_action[action])(mn_cb_idx, p_data);
- }
- else
- {
- /* discard mas data */
- bta_mse_discard_data(p_data->hdr.event, p_data);
- break;
- }
- }
-
-
-#if (BTA_MSE_DEBUG == TRUE) && (BT_USE_TRACES == TRUE)
- if (in_state != p_cb->state)
- {
- APPL_TRACE_EVENT3("MSE MN State Change: [%s] -> [%s] after Event [%s]",
- bta_mse_mn_state_code(in_state),
- bta_mse_mn_state_code(p_cb->state),
- bta_mse_evt_code(cur_evt));
- }
-#endif
-}
-/*******************************************************************************
-**
-** Function bta_mse_ma_api_enable
-**
-** Description Process API enable request to enable MCE subsystem
-**
-** Parameters p_cb - Pointer to MSE control block
-** p_data - Pointer to MSE event data
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_mse_ma_api_enable(tBTA_MSE_CB *p_cb, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE evt_data;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_ma_api_enable" );
-#endif
- /* If already enabled then reject this request */
- if (p_cb->enable)
- {
- APPL_TRACE_ERROR0("MSE is already enabled");
- evt_data.enable.app_id = p_data->api_enable.app_id;
- evt_data.enable.status = BTA_MA_STATUS_FAIL;
- p_data->api_enable.p_cback(BTA_MSE_ENABLE_EVT, (tBTA_MSE *) &evt_data);
- return;
- }
-
- /* Done with checking. now perform the enable oepration*/
- /* initialize control block */
- memset(p_cb, 0, sizeof(tBTA_MSE_CB));
-
- p_cb->p_cback = p_data->api_enable.p_cback;
- p_cb->app_id = p_data->api_enable.app_id;
- p_cb->enable = TRUE;
-
- evt_data.enable.app_id = p_cb->app_id;
- evt_data.enable.status = BTA_MA_STATUS_OK;
- p_cb->p_cback(BTA_MSE_ENABLE_EVT, (tBTA_MSE *) &evt_data);
-}
-/*******************************************************************************
-**
-** Function bta_mse_ma_api_disable
-**
-** Description Process API disable request
-**
-** Parameters p_cb - Pointer to MSE control block
-** p_data - Pointer to MSE event data
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_mse_ma_api_disable(tBTA_MSE_CB *p_cb, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE evt_data;
- tBTA_MA_STATUS status = BTA_MA_STATUS_OK;
- UINT8 app_id = p_data->api_disable.app_id;
- UINT8 i,j, num_act_mas=0, num_act_sess=0;
- tBTA_MSE_MA_CB *p_scb;
- tBTA_MSE_MA_SESS_CB *p_sess_cb;
- BOOLEAN send_disable_evt =FALSE;
- tBTA_MSE_MN_CB *p_ccb;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_ma_api_disable" );
-#endif
-
- if (p_cb->enable)
- {
- /* close all MN connections */
- for (i=0; i < BTA_MSE_NUM_MN; i ++)
- {
- p_ccb = BTA_MSE_GET_MN_CB_PTR(i);
- if (p_ccb->in_use &&
- (p_ccb->state != BTA_MSE_MN_IDLE_ST))
- {
- bta_mse_mn_remove_all_inst_ids(i);
- bta_mse_mn_sm_execute(i,BTA_MSE_MN_INT_CLOSE_EVT, NULL);
- }
- }
-
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- p_scb = BTA_MSE_GET_INST_CB_PTR(i);
- if (p_scb->in_use )
- {
- num_act_mas++;
- p_cb->disabling = TRUE;
- p_scb->stopping = TRUE;
- num_act_sess =0;
- for (j=0; j<BTA_MSE_NUM_SESS; j++ )
- {
- p_sess_cb = BTA_MSE_GET_SESS_CB_PTR(i, j);
- if (p_sess_cb->state != BTA_MSE_MA_LISTEN_ST)
- {
- bta_mse_ma_sm_execute(i, j, BTA_MSE_INT_CLOSE_EVT, p_data);
- num_act_sess++;
- }
- }
-
- if (!num_act_sess)
- {
- evt_data.stop.status = BTA_MA_STATUS_OK;
- evt_data.stop.mas_instance_id = p_scb->mas_inst_id;
- p_cb->p_cback(BTA_MSE_STOP_EVT, (tBTA_MSE *) &evt_data);
- bta_mse_clean_mas_service(i);
- num_act_mas--;
- }
- }
- }
-
- if (!num_act_mas)
- {
- send_disable_evt = TRUE;
- p_cb->enable = FALSE;
- }
- }
- else
- {
- send_disable_evt = TRUE;
- status = BTA_MA_STATUS_FAIL;
- }
-
-
- if (send_disable_evt)
- {
- evt_data.enable.app_id = app_id;
- evt_data.enable.status = status;
- p_cb->p_cback(BTA_MSE_DISABLE_EVT, (tBTA_MSE *) &evt_data);
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("MSE Disabled location-1");
-#endif
- }
-
-}
-/*******************************************************************************
-**
-** Function bta_mse_ma_api_start
-**
-** Description Process API MA server start request
-**
-** Parameters p_cb - Pointer to MSE control block
-** p_data - Pointer to MSE event data
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_mse_ma_api_start(tBTA_MSE_CB *p_cb, tBTA_MSE_DATA *p_data)
-{
- UINT8 i = 0;
- tBTA_MSE evt_data; /* event call back */
- tBTA_MSE_MA_CB *p_scb = NULL; /* MA instance control block*/
- tOBX_StartParams start_msg;
- tBTA_MSE_API_START *p_api = &p_data->api_start;
- tOBX_TARGET target;
- tOBX_STATUS status;
- tBTA_UTL_COD cod;
- UINT8 mas_instance_idx;
- UINT16 root_folder_len;
- tBTA_MA_STATUS ma_status = BTA_MA_STATUS_OK;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_ma_api_start" );
-#endif
- if (!p_cb->enable || ((p_cb->enable) && bta_mse_is_a_duplicate_id(p_api->mas_inst_id)) )
- {
- ma_status = BTA_MA_STATUS_DUPLICATE_ID;
- }
-
- if ((ma_status == BTA_MA_STATUS_OK) && bta_mse_find_avail_mas_inst_cb_idx(&mas_instance_idx))
- {
- APPL_TRACE_EVENT1("bta_mse_ma_api_start inst_idx=%d",mas_instance_idx );
-
- /* initialize the MA Instance control block */
- p_scb = &(p_cb->scb[mas_instance_idx]);
- memset(p_scb, 0, sizeof(tBTA_MSE_MA_CB));
-
- p_scb->in_use = TRUE;
- BCM_STRNCPY_S(p_scb->servicename, sizeof(p_scb->servicename), p_api->servicename, BTA_SERVICE_NAME_LEN);
- p_scb->mas_inst_id = p_api->mas_inst_id;
- p_scb->sec_mask = p_api->sec_mask;
- p_scb->sup_msg_type = p_api->sup_msg_type;
-
- /* If directory is specified set the length */
- root_folder_len = p_bta_fs_cfg->max_path_len + 1;
-
- /* Allocate an aligned memory buffer to hold the root path in the */
- /* MAS instance cb as well as the session cbs */
- /* Add 1 byte for '\0' */
- if ((p_scb->p_rootpath = (char *)GKI_getbuf((UINT16)(root_folder_len+1))) != NULL)
- {
- memcpy(target.target, BTA_MAS_MESSAGE_ACCESS_TARGET_UUID, BTA_MAS_UUID_LENGTH);
- target.len = BTA_MAS_UUID_LENGTH;
- p_scb->scn = BTM_AllocateSCN();
- BCM_STRNCPY_S(p_scb->p_rootpath, root_folder_len+1, p_api->p_root_path, root_folder_len);
- p_scb->p_rootpath[root_folder_len] = '\0';
-
- /* Register MAP security requirements with BTM */
- BTM_SetSecurityLevel(FALSE, p_api->servicename, BTM_SEC_SERVICE_MAP,
- p_api->sec_mask, BT_PSM_RFCOMM,
- BTM_SEC_PROTO_RFCOMM, (UINT32)p_scb->scn);
-
- /* Start up the MSE service */
- memset(&start_msg, 0, sizeof(tOBX_StartParams));
- start_msg.p_target = &target;
- /* Make the MTU fit into one RFC frame */
- start_msg.mtu = OBX_MAX_MTU;
- start_msg.scn = p_scb->scn;
- start_msg.authenticate = FALSE; /* OBX authentication is disabled */
- start_msg.auth_option = (UINT8) NULL;
- start_msg.p_cback = bta_mse_ma_obx_cback;
- start_msg.realm_len =(UINT8) NULL;
- start_msg.p_realm = (UINT8) NULL;
- start_msg.realm_charset = (tOBX_CHARSET) NULL;
- start_msg.max_sessions = BTA_MSE_NUM_SESS;
-
- if ((status = OBX_StartServer (&start_msg, &p_scb->obx_handle)) == OBX_SUCCESS)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("Obx start for MAS server: obx_hdl=%d", p_scb->obx_handle);
-#endif
- /* initialze all session states */
- for (i=0; i<BTA_MSE_NUM_SESS; i++ )
- {
- p_scb->sess_cb[i].state = BTA_MSE_MA_LISTEN_ST;
- }
-
- if (ma_status == BTA_MA_STATUS_OK)
- {
- /* Set the File Transfer service class bit */
- cod.service = BTM_COD_SERVICE_OBJ_TRANSFER;
- utl_set_device_class(&cod, BTA_UTL_SET_COD_SERVICE_CLASS);
-
- /* Set up the SDP record for pbs service */
- bta_mse_ma_sdp_register(p_scb, p_api->servicename, p_scb->mas_inst_id, p_scb->sup_msg_type );
- }
- else
- {
- /* release resources */
- OBX_StopServer(p_scb->obx_handle);
- for (i=0; i < BTA_MSE_NUM_SESS; i++ )
- {
- utl_freebuf((void**)&p_scb->sess_cb[i].p_workdir );
- }
- }
- }
- else
- {
- /* release resources */
- utl_freebuf((void**)&p_scb->p_rootpath);
- APPL_TRACE_ERROR1("OBX_StartServer returns error (%d)", status);
- ma_status = BTA_MA_STATUS_NO_RESOURCE;
- }
- }
- else /* Cannot allocate resources to run Server */
- {
- APPL_TRACE_ERROR0("Not enough Resources to run MSE Server");
- ma_status = BTA_MA_STATUS_NO_RESOURCE;
- }
-
- if (ma_status != BTA_MA_STATUS_OK)
- {
- /* clearn up the contrl block*/
- memset(p_scb, 0, sizeof(tBTA_MSE_MA_CB));
- }
- }
-
- evt_data.start.mas_instance_id = p_api->mas_inst_id;
- evt_data.start.status = ma_status;
- p_cb->p_cback(BTA_MSE_START_EVT, (tBTA_MSE *) &evt_data);
-
-}
-/*******************************************************************************
-**
-** Function bta_mse_ma_api_stop
-**
-** Description Process API MA server stop request
-**
-** Parameters p_cb - Pointer to MSE control block
-** p_data - Pointer to MSE event data
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_mse_ma_api_stop(tBTA_MSE_CB *p_cb, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_API_STOP *p_stop = &p_data->api_stop;
- BOOLEAN send_stop_evt = FALSE;
- tBTA_MA_STATUS status = BTA_MA_STATUS_OK;
- tBTA_MSE_MA_CB *p_scb;
- tBTA_MSE_MA_SESS_CB *p_sess_cb;
- tBTA_MSE_MN_CB *p_ccb;
- UINT8 i, inst_idx;
- UINT8 num_act_sess=0;
- tBTA_MSE evt_data;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_ma_api_stop" );
-#endif
-
-
- if (bta_mse_find_mas_inst_id_match_cb_idx(p_stop->mas_inst_id, &inst_idx))
- {
- p_scb = BTA_MSE_GET_INST_CB_PTR(inst_idx);
- p_scb->stopping = TRUE;
-
- for (i=0; i < BTA_MSE_NUM_MN; i ++)
- {
- p_ccb = BTA_MSE_GET_MN_CB_PTR(i);
- if (p_ccb->in_use &&
- (p_ccb->state != BTA_MSE_MN_IDLE_ST) &&
- bta_mse_mn_is_ok_to_close_mn(p_ccb->bd_addr,p_scb->mas_inst_id))
- {
- /* close the MN connection if mas_inst_id is the last active inst_id */
- bta_mse_mn_remove_inst_id(i, p_scb->mas_inst_id);
- bta_mse_mn_sm_execute(i,BTA_MSE_MN_INT_CLOSE_EVT, NULL);
- }
- }
- /* close all active session */
- for (i=0; i < BTA_MSE_NUM_SESS; i ++)
- {
- p_sess_cb = &(p_scb->sess_cb[i]);
- if (p_sess_cb->state != BTA_MSE_MA_LISTEN_ST)
- {
- APPL_TRACE_EVENT2("Send API CLOSE to SM for STOP sess ind=%d state=%d",i,p_sess_cb->state);
- bta_mse_ma_sm_execute(inst_idx, i, BTA_MSE_INT_CLOSE_EVT, p_data);
- num_act_sess++;
- }
- }
-
- if (!num_act_sess)
- {
- bta_mse_clean_mas_service(inst_idx);
- send_stop_evt = TRUE;
- }
- }
- else
- {
- send_stop_evt = TRUE;
- status = BTA_MA_STATUS_FAIL;
- }
-
- if (send_stop_evt)
- {
- evt_data.stop.status = status;
- evt_data.stop.mas_instance_id = p_stop->mas_inst_id;
- p_cb->p_cback(BTA_MSE_STOP_EVT, (tBTA_MSE *) &evt_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_api_close
-**
-** Description Process API close request. It will close all MA
-** sesions on the specified MAS instance ID
-**
-** Parameters p_cb - Pointer to MSE control block
-** p_data - Pointer to MSE event data
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_mse_ma_api_close(tBTA_MSE_CB *p_cb, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_API_CLOSE *p_close = &p_data->api_close;
- BOOLEAN send_close_evt = FALSE;
- tBTA_MA_STATUS status = BTA_MA_STATUS_OK;
- tBTA_MSE_MA_CB *p_scb;
- tBTA_MSE_MA_SESS_CB *p_sess_cb;
- UINT8 i, inst_idx;
- UINT8 num_act_sess=0;
- tBTA_MSE evt_data;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_ma_api_close" );
-#endif
- if (bta_mse_find_mas_inst_id_match_cb_idx(p_close->mas_instance_id, &inst_idx))
- {
- p_scb = BTA_MSE_GET_INST_CB_PTR(inst_idx);
- /* close all active sessions for the specified MA Server */
- for (i=0; i < BTA_MSE_NUM_SESS; i ++)
- {
- p_sess_cb = &(p_scb->sess_cb[i]);
- if (p_sess_cb->state != BTA_MSE_MA_LISTEN_ST)
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT4("Disconnect inst_id=%d, sess_id=%d, inst_idx=%d, sess_idx=%d",
- p_close->mas_instance_id,
- p_sess_cb->obx_handle,
- inst_idx,
- i);
-#endif
-
- bta_mse_ma_sm_execute(inst_idx, i, BTA_MSE_INT_CLOSE_EVT, p_data);
- num_act_sess++;
- }
- }
-
- if (!num_act_sess)
- {
- send_close_evt = TRUE;
- }
- }
- else
- {
- send_close_evt = TRUE;
- status = BTA_MA_STATUS_FAIL;
- }
-
- if (send_close_evt)
- {
- evt_data.ma_close.status = status;
- evt_data.ma_close.mas_session_id = 0;
- evt_data.ma_close.mas_instance_id = p_close->mas_instance_id ;
- p_cb->p_cback(BTA_MSE_MA_CLOSE_EVT, (tBTA_MSE *) &evt_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_api_ma_close
-**
-** Description Process API MA close request. It will close the
-** specified MA session.
-**
-** Parameters p_cb - Pointer to MSE control block
-** p_data - Pointer to MSE event data
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_mse_ma_api_ma_close(tBTA_MSE_CB *p_cb, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_API_MA_CLOSE *p_ma_close = &p_data->api_ma_close;
- UINT8 inst_idx, sess_idx;
- tBTA_MSE evt_data;
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_ma_api_ma_close" );
-#endif
-
- if (bta_mse_find_mas_inst_id_match_cb_idx (p_ma_close->mas_instance_id, &inst_idx)&&
- bta_mse_find_bd_addr_match_sess_cb_idx(p_ma_close->bd_addr,inst_idx,&sess_idx))
- {
- bta_mse_ma_sm_execute(inst_idx, sess_idx, BTA_MSE_INT_CLOSE_EVT, p_data);
- }
- else
- {
- evt_data.ma_close.mas_session_id = 0xFF;
- evt_data.ma_close.mas_instance_id = p_ma_close->mas_instance_id;
- evt_data.ma_close.status = BTA_MA_STATUS_FAIL ;
- p_cb->p_cback(BTA_MSE_MA_CLOSE_EVT, (tBTA_MSE *) &evt_data);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_api_close
-**
-** Description Process API MN close request.
-**
-** Parameters p_cb - Pointer to MSE control block
-** p_data - Pointer to MSE event data
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_mse_mn_api_close(tBTA_MSE_CB *p_cb, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_API_MN_CLOSE *p_mn_close = &p_data->api_mn_close;
- UINT8 ccb_idx;
- tBTA_MSE evt_data;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_mn_api_close" );
-#endif
-
- if (bta_mse_find_bd_addr_match_mn_cb_index(p_mn_close->bd_addr, &ccb_idx))
- {
- bta_mse_mn_sm_execute(ccb_idx, BTA_MSE_MN_INT_CLOSE_EVT, p_data);
- }
- else
- {
- evt_data.mn_close.bd_addr[0] = '\0';
- evt_data.mn_close.dev_name[0] = '\0';
- p_cb->p_cback(BTA_MSE_MN_CLOSE_EVT, (tBTA_MSE *) &evt_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_api_send_notif
-**
-** Description Process API send message notification report to all MCEs
-** registered with the specified MAS instance ID
-**
-** Parameters p_cb - Pointer to MSE control block
-** p_data - Pointer to MSE event data
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_mse_mn_api_send_notif(tBTA_MSE_CB *p_cb, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_API_SEND_NOTIF *p_mn_send_notif = &p_data->mn_send_notif;
- UINT8 i;
- tBTA_MSE evt_data;
- tBTA_MSE_MN_CB *p_ccb;
- UINT8 active_sess_cnt;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_mn_api_send_notif" );
-#endif
-
- active_sess_cnt =0 ;
- for (i=0; i < BTA_MSE_NUM_MN; i ++)
- {
- p_ccb = BTA_MSE_GET_MN_CB_PTR(i);
-
- if (p_ccb->in_use &&
- (p_ccb->state == BTA_MSE_MN_CONN_ST) &&
- (memcmp(p_ccb->bd_addr, p_mn_send_notif->except_bd_addr, BD_ADDR_LEN) != 0 ) &&
- bta_mse_mn_is_inst_id_exist(i,p_mn_send_notif->mas_instance_id))
- {
- bta_mse_mn_sm_execute(i, BTA_MSE_API_SEND_NOTIF_EVT, p_data);
- active_sess_cnt++;
- }
- }
-
- if (!active_sess_cnt)
- {
- evt_data.send_notif.mas_instance_id = p_mn_send_notif->mas_instance_id;
- evt_data.send_notif.status = BTA_MA_STATUS_FAIL;
- memset(evt_data.send_notif.bd_addr,0, sizeof(evt_data.send_notif.bd_addr));
- p_cb->p_cback(BTA_MSE_SEND_NOTIF_EVT, (tBTA_MSE *) &evt_data);
- }
-
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_api_abort
-**
-** Description Abort the current OBEX multi-packet oepration
-**
-** Parameters p_cb - Pointer to MSE control block
-** p_data - Pointer to MSE event data
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_mse_mn_api_abort(tBTA_MSE_CB *p_cb, tBTA_MSE_DATA *p_data)
-{
- tBTA_MSE_MN_API_ABORT *p_mn_abort = &p_data->mn_abort;
- UINT8 i;
- tBTA_MSE_MN_CB *p_ccb;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_mn_api_abort" );
-#endif
-
- for (i=0; i < BTA_MSE_NUM_MN; i ++)
- {
- p_ccb = BTA_MSE_GET_MN_CB_PTR(i);
- if (p_ccb->in_use &&
- (p_ccb->state == BTA_MSE_MN_CONN_ST) &&
- bta_mse_mn_is_inst_id_exist(i,p_mn_abort->mas_instance_id))
- {
- bta_mse_mn_sm_execute(i, BTA_MSE_API_MN_ABORT_EVT, p_data);
- }
- }
-
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_rsp_tout
-**
-** Description Process MN response timer timeout event
-**
-** Parameters p_cb - Pointer to MSE control block
-** p_data - Pointer to MSE event data
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_mse_mn_rsp_tout(tBTA_MSE_CB *p_cb, tBTA_MSE_DATA *p_data)
-{
- UINT8 ccb_idx;
-
- ccb_idx = (UINT8)(p_data->hdr.event - BTA_MSE_MN_RSP0_TOUT_EVT);
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_rsp_tout ccd_idx=%d",ccb_idx);
-#endif
- bta_mse_mn_sm_execute(ccb_idx, BTA_MSE_MN_RSP_TOUT_EVT, p_data);
-}
-/*******************************************************************************
-**
-** Function bta_mse_hdl_event
-**
-** Description MSE main event handling function.
-**
-** Parameters p_msg - Pointer to MSE event data
-**
-** Returns void
-**
-*******************************************************************************/
-BOOLEAN bta_mse_hdl_event(BT_HDR *p_msg){
- UINT8 inst_idx, sess_idx, ccb_idx;
- BOOLEAN success = TRUE;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("MSE Event Handler: Event [%s]",
- bta_mse_evt_code(p_msg->event));
-#endif
-
- switch (p_msg->event)
- {
- case BTA_MSE_API_ENABLE_EVT:
- bta_mse_ma_api_enable(&bta_mse_cb, (tBTA_MSE_DATA *) p_msg);
- break;
-
- case BTA_MSE_API_START_EVT:
- bta_mse_ma_api_start(&bta_mse_cb, (tBTA_MSE_DATA *) p_msg);
- break;
-
- case BTA_MSE_API_STOP_EVT:
- bta_mse_ma_api_stop(&bta_mse_cb, (tBTA_MSE_DATA *) p_msg);
- break;
-
- case BTA_MSE_API_DISABLE_EVT:
- bta_mse_ma_api_disable(&bta_mse_cb, (tBTA_MSE_DATA *) p_msg);
- break;
-
- case BTA_MSE_API_CLOSE_EVT:
- bta_mse_ma_api_close(&bta_mse_cb, (tBTA_MSE_DATA *) p_msg);
- break;
-
- case BTA_MSE_API_MA_CLOSE_EVT:
- bta_mse_ma_api_ma_close(&bta_mse_cb, (tBTA_MSE_DATA *) p_msg);
- break;
-
- case BTA_MSE_API_MN_CLOSE_EVT:
- bta_mse_mn_api_close(&bta_mse_cb, (tBTA_MSE_DATA *) p_msg);
- break;
-
- case BTA_MSE_API_SEND_NOTIF_EVT:
- bta_mse_mn_api_send_notif(&bta_mse_cb, (tBTA_MSE_DATA *) p_msg);
- break;
-
- case BTA_MSE_API_MN_ABORT_EVT:
- bta_mse_mn_api_abort(&bta_mse_cb, (tBTA_MSE_DATA *) p_msg);
- break;
-
- case BTA_MSE_MN_RSP0_TOUT_EVT:
- case BTA_MSE_MN_RSP1_TOUT_EVT:
- case BTA_MSE_MN_RSP2_TOUT_EVT:
- case BTA_MSE_MN_RSP3_TOUT_EVT:
- case BTA_MSE_MN_RSP4_TOUT_EVT:
- case BTA_MSE_MN_RSP5_TOUT_EVT:
- case BTA_MSE_MN_RSP6_TOUT_EVT:
- bta_mse_mn_rsp_tout(&bta_mse_cb, (tBTA_MSE_DATA *) p_msg);
- break;
-
- default:
-
- if (p_msg->event < BTA_MSE_MN_EVT_MIN)
- {
- if (bta_mse_find_ma_cb_indexes((tBTA_MSE_DATA *) p_msg, &inst_idx, &sess_idx))
- {
- bta_mse_ma_sm_execute( inst_idx ,
- sess_idx ,
- p_msg->event, (tBTA_MSE_DATA *) p_msg);
- }
- else
- {
- APPL_TRACE_ERROR1("unable to find inst_idx and sess_idx: event=%s",
- bta_mse_evt_code(p_msg->event));
- success = FALSE;
- bta_mse_ma_cleanup ((tBTA_MSE_DATA *) p_msg);
- }
- }
- else
- {
- if (bta_mse_find_mn_cb_index((tBTA_MSE_DATA *) p_msg, &ccb_idx))
- {
- bta_mse_mn_sm_execute( ccb_idx,
- p_msg->event ,
- (tBTA_MSE_DATA *) p_msg);
- }
- else
- {
- APPL_TRACE_ERROR1("unable to find ccb_idx: event=%s",
- bta_mse_evt_code(p_msg->event));
- success = FALSE;
- bta_mse_mn_cleanup ((tBTA_MSE_DATA *) p_msg);
- }
- }
- break;
- }
-
- return(success);
-}
-
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if (BTA_MSE_DEBUG == TRUE) && (BT_USE_TRACES == TRUE)
-/*******************************************************************************
-**
-** Function bta_mse_ma_evt_code
-**
-** Description Maps MA event code to the corresponding event string
-**
-** Parameters evt_code - MA event code
-**
-** Returns string pointer for the associated event name
-**
-*******************************************************************************/
-static char *bta_mse_evt_code(tBTA_MSE_INT_EVT evt_code){
- switch (evt_code)
- {
- case BTA_MSE_API_CLOSE_EVT:
- return "BTA_MSE_API_CLOSE_EVT";
- case BTA_MSE_API_MA_CLOSE_EVT:
- return "BTA_MSE_API_MA_CLOSE_EVT";
- case BTA_MSE_API_MN_CLOSE_EVT:
- return "BTA_MSE_API_MN_CLOSE_EVT";
- case BTA_MSE_INT_CLOSE_EVT:
- return "BTA_MSE_INT_CLOSE_EVT";
- case BTA_MSE_API_ACCESSRSP_EVT:
- return "BTA_MSE_API_ACCESSRSP_EVT";
- case BTA_MSE_API_UPD_IBX_RSP_EVT:
- return "BTA_MSE_API_UPD_IBX_RSP_EVT";
- case BTA_MSE_API_SET_NOTIF_REG_RSP_EVT:
- return "BTA_MSE_API_SET_NOTIF_REG_RSP_EVT";
- case BTA_MSE_INT_START_EVT:
- return "BTA_MSE_INT_START_EVT";
- case BTA_MSE_CI_GET_FENTRY_EVT:
- return "BTA_MSE_CI_GET_FENTRY_EVT";
- case BTA_MSE_CI_GET_ML_INFO_EVT:
- return "BTA_MSE_CI_GET_ML_INFO_EVT";
- case BTA_MSE_CI_GET_ML_ENTRY_EVT:
- return "BTA_MSE_CI_GET_ML_ENTRY_EVT";
- case BTA_MSE_CI_GET_MSG_EVT:
- return "BTA_MSE_CI_GET_MSG_EVT";
- case BTA_MSE_CI_PUSH_MSG_EVT:
- return "BTA_MSE_CI_PUSH_MSG_EVT";
- case BTA_MSE_CI_DEL_MSG_EVT:
- return "BTA_MSE_CI_DEL_MSG_EVT";
- case BTA_MSE_MA_OBX_CONN_EVT:
- return "BTA_MSE_MA_OBX_CONN_EVT";
- case BTA_MSE_MA_OBX_DISC_EVT:
- return "BTA_MSE_MA_OBX_DISC_EVT";
- case BTA_MSE_MA_OBX_ABORT_EVT:
- return "BTA_MSE_MA_OBX_ABORT_EVT";
- case BTA_MSE_MA_OBX_CLOSE_EVT:
- return "BTA_MSE_MA_OBX_CLOSE_EVT";
- case BTA_MSE_MA_OBX_PUT_EVT:
- return "BTA_MSE_MA_OBX_PUT_EVT";
- case BTA_MSE_MA_OBX_GET_EVT:
- return "BTA_MSE_MA_OBX_GET_EVT";
- case BTA_MSE_MA_OBX_SETPATH_EVT:
- return "BTA_MSE_MA_OBX_SETPATH_EVT";
- case BTA_MSE_CLOSE_CMPL_EVT:
- return "BTA_MSE_CLOSE_CMPL_EVT";
- case BTA_MSE_MN_INT_OPEN_EVT:
- return "BTA_MSE_MN_INT_OPEN_EVT";
- case BTA_MSE_MN_INT_CLOSE_EVT:
- return "BTA_MSE_MN_INT_CLOSE_EVT";
- case BTA_MSE_MN_SDP_OK_EVT:
- return "BTA_MSE_MN_SDP_OK_EVT";
- case BTA_MSE_MN_SDP_FAIL_EVT:
- return "BTA_MSE_MN_SDP_FAIL_EVT";
- case BTA_MSE_MN_OBX_CONN_RSP_EVT:
- return "BTA_MSE_MN_OBX_CONN_RSP_EVT";
- case BTA_MSE_MN_OBX_PUT_RSP_EVT:
- return "BTA_MSE_MN_OBX_PUT_RSP_EVT";
- case BTA_MSE_MN_OBX_CLOSE_EVT:
- return "BTA_MSE_MN_OBX_CLOSE_EVT";
- case BTA_MSE_MN_OBX_TOUT_EVT:
- return "BTA_MSE_MN_OBX_TOUT_EVT";
- case BTA_MSE_MN_CLOSE_CMPL_EVT:
- return "BTA_MSE_MN_CLOSE_CMPL_EVT";
- case BTA_MSE_API_SEND_NOTIF_EVT:
- return "BTA_MSE_API_SEND_NOTIF_EVT";
- case BTA_MSE_API_MN_ABORT_EVT:
- return "BTA_MSE_API_MN_ABORT_EVT";
- case BTA_MSE_MN_OBX_ABORT_RSP_EVT:
- return "BTA_MSE_MN_OBX_ABORT_RSP_EVT";
- case BTA_MSE_API_ENABLE_EVT:
- return "BTA_MSE_API_ENABLE_EVT";
- case BTA_MSE_API_START_EVT:
- return "BTA_MSE_API_START_EVT";
- case BTA_MSE_API_STOP_EVT:
- return "BTA_MSE_API_STOP_EVT";
- default:
- return "Unknown MSE event code";
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_state_code
-**
-** Description Maps MA state code to the corresponding state string
-**
-** Parameters state_code - MA state code
-**
-** Returns string pointer for the associated state name
-**
-*******************************************************************************/
-static char *bta_mse_ma_state_code(tBTA_MSE_MA_STATE state_code){
- switch (state_code)
- {
- case BTA_MSE_MA_IDLE_ST:
- return "BTA_MSE_MA_IDLE_ST";
- case BTA_MSE_MA_LISTEN_ST:
- return "BTA_MSE_MA_LISTEN_ST";
- case BTA_MSE_MA_CONN_ST:
- return "BTA_MSE_MA_CONN_ST";
- case BTA_MSE_MA_CLOSING_ST:
- return "BTA_MSE_MA_CLOSING_ST";
- default:
- return "Unknown MA state code";
- }
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_state_code
-**
-** Description Maps MN state code to the corresponding state string
-**
-** Parameters state_code - MN state code
-**
-** Returns string pointer for the associated state name
-**
-*******************************************************************************/
-static char *bta_mse_mn_state_code(tBTA_MSE_MN_STATE state_code){
- switch (state_code)
- {
- case BTA_MSE_MN_IDLE_ST:
- return "BTA_MSE_MN_IDLE_ST";
- case BTA_MSE_MN_W4_CONN_ST:
- return "BTA_MSE_MN_W4_CONN_ST";
- case BTA_MSE_MN_CONN_ST:
- return "BTA_MSE_MN_CONN_ST";
- case BTA_MSE_MN_CLOSING_ST:
- return "BTA_MSE_MN_CLOSING_ST";
- default:
- return "Unknown MN state code";
- }
-}
-
-#endif /* Debug Functions */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#endif /* BTA_MSE_INCLUDED */
diff --git a/bta/ma/bta_mse_sdp.c b/bta/ma/bta_mse_sdp.c
deleted file mode 100644
index a56e07f..0000000
--- a/bta/ma/bta_mse_sdp.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_mse_sdp.c
-**
-** File: Implements the SDP functions used by Message Access Server
-**
-** Copyright (c) 1998-2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <string.h>
-
-#include "sdp_api.h"
-#include "bta_mse_int.h"
-#include "goep_util.h"
-
-/*****************************************************************************
-**
-** Function: bta_mas_sdp_register
-**
-** Purpose: Register the Message Access service with SDP
-**
-** Parameters: p_cb - Pointer to MA instance control block
-** p_service_name - MA server name
-** inst_id - MAS instance ID
-** msg_type - Supported message type(s)
-**
-**
-** Returns: void
-**
-*****************************************************************************/
-void bta_mse_ma_sdp_register (tBTA_MSE_MA_CB *p_cb, char *p_service_name,
- tBTA_MA_INST_ID inst_id,
- tBTA_MA_MSG_TYPE msg_type)
-{
- UINT16 mas_service = UUID_SERVCLASS_MESSAGE_ACCESS;
- tGOEP_ERRORS goep_status;
-
- goep_status = GOEP_Register(p_service_name, &p_cb->sdp_handle, p_cb->scn,
- 1, &mas_service, UUID_SERVCLASS_MAP_PROFILE,
- BTA_MAS_DEFAULT_VERSION);
- if (goep_status == GOEP_SUCCESS)
- {
- /* add instance ID */
- SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_MAS_INSTANCE_ID, UINT_DESC_TYPE,
- (UINT32)1, (UINT8*)&inst_id);
-
- /* add supported message type */
- SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_SUPPORTED_MSG_TYPE, UINT_DESC_TYPE,
- (UINT32)1, (UINT8*)&msg_type);
-
- bta_sys_add_uuid(mas_service); /* UUID_SERVCLASS_MESSAGE_ACCESS */
- APPL_TRACE_DEBUG1("MAS: SDP Registered (handle 0x%08x)", p_cb->sdp_handle);
- }
- else
- {
- if (p_cb->sdp_handle) SDP_DeleteRecord(p_cb->sdp_handle);
- APPL_TRACE_ERROR0("bta_mse_ma_sdp_register FAILED");
- }
-
- return;
-}
diff --git a/bta/ma/bta_mse_utils.c b/bta/ma/bta_mse_utils.c
deleted file mode 100644
index 2b14b7a..0000000
--- a/bta/ma/bta_mse_utils.c
+++ /dev/null
@@ -1,3867 +0,0 @@
-/*********************************************a********************************
-**
-** Name: bta_mse_utils.c
-**
-** Description: This file implements utility functions for the
-** file transfer server.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_MSE_INCLUDED) && (BTA_MSE_INCLUDED == TRUE)
-
-#include <stdio.h>
-#include <string.h>
-#include "gki.h"
-#include "utl.h"
-#include "bd.h"
-#include "bta_fs_api.h"
-#include "bta_mse_int.h"
-#include "bta_fs_co.h"
-#include "bta_mse_co.h"
-
-#include "bta_ma_util.h"
-
-
-/*******************************************************************************
-* Macros for MSE
-*******************************************************************************/
-#define BTA_MSE_XML_EOL "\n"
-#define BTA_MSE_FOLDER_LISTING_START ( "<?xml version=\"1.0\"?>\n" \
- "<!DOCTYPE folder-listing SYSTEM \"obex-folder-listing.dtd\">\n" \
- "<folder-listing version=\"1.0\">\n" )
-
-#define BTA_MSE_FOLDER_LISTING_END ( "</folder-listing>" )
-#define BTA_MSE_PARENT_FOLDER (" <parent-folder/>\n")
-
-#define BTA_MSE_FILE_ELEM "file"
-#define BTA_MSE_FOLDER_ELEM "folder"
-#define BTA_MSE_NAME_ATTR "name"
-#define BTA_MSE_SIZE_ATTR "size"
-#define BTA_MSE_TYPE_ATTR "type"
-#define BTA_MSE_MODIFIED_ATTR "modified"
-#define BTA_MSE_CREATED_ATTR "created"
-#define BTA_MSE_ACCESSED_ATTR "accessed"
-#define BTA_MSE_USER_PERM_ATTR "user-perm"
-
-#define BTA_MSE_MSG_LISTING_START ( "<MAP-msg-listing version=\"1.0\">\n" )
-#define BTA_MSE_MSG_LISTING_END ( "</MAP-msg-listing>" )
-
-
-// btla-specific ++
-#define BTA_MSE_ENABLE_FS_CO FALSE
-// btla-specific --
-
-/*******************************************************************************
-**
-** Function bta_mse_send_push_msg_in_prog_evt
-**
-** Description send the push message in progress event
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns void
-**
-*******************************************************************************/
-
-void bta_mse_send_push_msg_in_prog_evt(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OPER_PUSH_MSG *p_push_msg = &p_cb->push_msg;
- tBTA_MSE cback_evt_data;
- tBTA_MSE *p_data = &cback_evt_data;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_send_push_msg_in_prog_evt inst_idx=%d sess_idx=%d",
- inst_idx,sess_idx);
-#endif
-
- p_data->push_msg_in_prog.mas_session_id = p_cb->obx_handle;
- p_data->push_msg_in_prog.bytes = p_cb->obx.offset;
- p_data->push_msg_in_prog.obj_size = p_push_msg->push_byte_cnt;
- bta_mse_cb.p_cback(BTA_MSE_PUSH_MSG_IN_PROG_EVT, (tBTA_MSE *) p_data);
-}
-/*******************************************************************************
-**
-** Function bta_mse_send_get_msg_in_prog_evt
-**
-** Description Sends the get message in progress event
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_send_get_msg_in_prog_evt(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OPER_MSG_PARAM *p_param = &p_cb->msg_param;
- tBTA_MSE cback_evt_data;
- tBTA_MSE *p_data = &cback_evt_data;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_send_get_msg_in_prog_evt inst_idx=%d sess_idx=%d",
- inst_idx,sess_idx);
-#endif
-
- p_data->get_msg_in_prog.mas_session_id = (tBTA_MA_SESS_HANDLE) p_cb->obx_handle;
- p_data->get_msg_in_prog.bytes = p_param->filled_buff_size;
- p_data->get_msg_in_prog.obj_size = p_param->byte_get_cnt;
- bta_mse_cb.p_cback(BTA_MSE_GET_MSG_IN_PROG_EVT, (tBTA_MSE *) p_data);
-}
-/*******************************************************************************
-**
-** Function bta_mse_send_oper_cmpl_evt
-**
-** Description Sends the operartion complete event based on the specified status
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** status - MA status code
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_send_oper_cmpl_evt(UINT8 inst_idx, UINT8 sess_idx, tBTA_MA_STATUS status)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OPER_MSG_PARAM *p_param = &p_cb->msg_param;
- tBTA_MSE_OPER_PUSH_MSG *p_push_msg = &p_cb->push_msg;
- tBTA_MSE cback_evt_data;
- tBTA_MSE *p_data = &cback_evt_data;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT3("bta_mse_send_oper_cmpl_evt inst_idx=%d sess_idx=%d status=%d",
- inst_idx, sess_idx, status);
-#endif
-
- p_data->oper_cmpl.mas_session_id = p_cb->obx_handle;
- p_data->oper_cmpl.operation = p_cb->oper;
- p_data->oper_cmpl.status = status;
- switch (p_cb->oper)
- {
- case BTA_MSE_OPER_GET_MSG:
- p_data->oper_cmpl.obj_size = p_param->byte_get_cnt;
- break;
- case BTA_MSE_OPER_PUSH_MSG:
- p_data->oper_cmpl.obj_size = p_push_msg->push_byte_cnt;
- break;
- default:
- p_data->oper_cmpl.obj_size = 0;
- break;
- }
- bta_mse_cb.p_cback(BTA_MSE_OPER_CMPL_EVT, (tBTA_MSE *) p_data);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_pushmsg
-**
-** Description Process the push message request
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** first_pkt - first packet of the push message request
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_pushmsg(UINT8 inst_idx, UINT8 sess_idx, BOOLEAN first_pkt)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OPER_PUSH_MSG *p_push_msg = &p_cb->push_msg;
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_MA_MPKT_STATUS mpkt_status;
-
- p_push_msg->push_byte_cnt += p_obx->offset;
- p_cb->cout_active = TRUE;
- mpkt_status = BTA_MA_MPKT_STATUS_LAST;
- if (!p_obx->final_pkt) mpkt_status = BTA_MA_MPKT_STATUS_MORE;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT5("bta_mse_pushmsg i_idx=%d s_idx=%d first=%d final=%d cnt=%d",
- inst_idx, sess_idx, first_pkt, p_obx->final_pkt,
- p_push_msg->push_byte_cnt);
-#endif
-
-
- bta_mse_co_push_msg((tBTA_MA_SESS_HANDLE) p_cb->obx_handle, &p_push_msg->param,
- p_obx->offset, p_obx->p_start, first_pkt,
- mpkt_status, BTA_MSE_CI_PUSH_MSG_EVT, bta_mse_cb.app_id);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_clean_set_msg_sts
-**
-** Description Cleans up the set message status resources and cotrol block
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_clean_set_msg_sts(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OPER_SET_MSG_STS *p_set_msg_sts = &p_cb->set_msg_sts;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_clean_set_msg_sts");
-#endif
-
- utl_freebuf((void**)&(p_set_msg_sts->p_msg_handle));
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_NONE);
-
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_clean_set_notif_reg
-**
-** Description Cleans up the set notification registration resources and cotrol block
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_clean_set_notif_reg(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_clean_set_notif_reg");
-#endif
-
- p_cb->notif_reg_req.notif_status_rcv = FALSE;
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_NONE);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_clean_push_msg
-**
-** Description Cleans up the push message resources and cotrol block
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_clean_push_msg(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OPER_PUSH_MSG *p_push_msg = &p_cb->push_msg;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_clean_push_msg");
-#endif
-
- utl_freebuf((void**)&(p_push_msg->param.p_folder));
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_NONE);
-
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_init_set_msg_sts
-**
-** Description Initializes the set message status resources and cotrol block
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_rsp_code - (output) pointer to the obex response code
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_init_set_msg_sts(UINT8 inst_idx, UINT8 sess_idx, UINT8 *p_rsp_code)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OPER_SET_MSG_STS *p_set_msg_sts = &p_cb->set_msg_sts;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_init_set_msg_sts");
-#endif
- *p_rsp_code = OBX_RSP_OK;
-
-
-
- p_set_msg_sts->rcv_msg_handle = FALSE;
- p_set_msg_sts->rcv_sts_ind = FALSE;
- p_set_msg_sts->rcv_sts_val = FALSE;
-
- if (!p_set_msg_sts->p_msg_handle)
- {
- if ((p_set_msg_sts->p_msg_handle = (char *)GKI_getbuf((UINT16)(BTA_MSE_64BIT_HEX_STR_SIZE))) == NULL )
- {
- *p_rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_init_push_msg
-**
-** Description initializes the push message resources and control block
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_rsp_code - (output) pointer to the obex response code
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_init_push_msg(UINT8 inst_idx, UINT8 sess_idx, UINT8 *p_rsp_code)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OPER_PUSH_MSG *p_push_msg = &p_cb->push_msg;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_init_push_msg");
-#endif
- *p_rsp_code = OBX_RSP_OK;
-
-
- p_push_msg->push_byte_cnt = 0;
- p_push_msg->first_req_pkt = TRUE;
- p_push_msg->rcv_charset = FALSE;
- p_push_msg->rcv_folder_name = FALSE;
- p_push_msg->rcv_retry = FALSE;
- p_push_msg->rcv_transparent = FALSE;
- p_push_msg->param.transparent = BTA_MA_TRANSP_OFF;
- p_push_msg->param.retry = BTA_MA_RETRY_OFF;
-
- if (!p_push_msg->param.p_folder)
- {
- if ((p_push_msg->param.p_folder = (char *)GKI_getbuf((UINT16)(p_bta_mse_cfg->max_name_len + 1))) == NULL )
- {
- *p_rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- }
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_remove_uuid
-**
-** Description Remove UUID and clear service
-**
-** Parameters none
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_remove_uuid(void)
-{
- bta_sys_remove_uuid(UUID_SERVCLASS_MESSAGE_ACCESS);
- BTM_SecClrService(BTM_SEC_SERVICE_MAP);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_clean_mas_service
-**
-** Description Cleans up the MAS service resources and control block
-**
-** Parameters inst_idx - Index to the MA instance control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_clean_mas_service(UINT8 inst_idx)
-{
- tBTA_MSE_MA_CB *p_scb = BTA_MSE_GET_INST_CB_PTR(inst_idx);
- tBTA_MSE_MA_SESS_CB *p_cb;
- int i, num_act_mas =0;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_clean_mas_service");
-#endif
- OBX_StopServer(p_scb->obx_handle);
- BTM_FreeSCN(p_scb->scn);
- if (p_scb->sdp_handle) SDP_DeleteRecord(p_scb->sdp_handle);
-
- utl_freebuf((void**)&p_scb->p_rootpath);
- for (i=0; i < BTA_MSE_NUM_SESS; i++ )
- {
- p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, i);
- utl_freebuf((void**)&p_cb->p_workdir);
- }
- p_scb->in_use = FALSE;
-
- /* check all other MAS instances */
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- p_scb = BTA_MSE_GET_INST_CB_PTR(i);
- if (p_scb->in_use) num_act_mas++;
- }
-
- if (!num_act_mas) bta_mse_remove_uuid();
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_abort_too_late
-**
-** Description It is too late to abort the operation
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_abort_too_late(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_abort_too_late oper=%d ",p_cb->oper );
-#endif
- OBX_AbortRsp(p_cb->obx_handle, OBX_RSP_FORBIDDEN, (BT_HDR *)NULL);
- p_cb->aborting = FALSE;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_clean_getput
-**
-** Description Cleans up get and put resources and control blocks
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** status - operation status
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_clean_getput(UINT8 inst_idx, UINT8 sess_idx, tBTA_MA_STATUS status)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_clean_getput oper=%d status=%d",p_cb->oper, status );
-#endif
- if (status == BTA_MA_STATUS_ABORTED)
- {
- OBX_AbortRsp(p_cb->obx_handle, OBX_RSP_OK, (BT_HDR *)NULL);
- p_cb->aborting = FALSE;
- }
- switch (p_cb->oper)
- {
- case BTA_MSE_OPER_UPDATE_INBOX:
- bta_mse_set_ma_oper(inst_idx,sess_idx, BTA_MSE_OPER_NONE);
- break;
- case BTA_MSE_OPER_GET_FOLDER_LIST:
- bta_mse_clean_list(inst_idx,sess_idx);
- break;
- case BTA_MSE_OPER_GET_MSG_LIST:
- bta_mse_clean_msg_list(inst_idx,sess_idx);
- break;
- case BTA_MSE_OPER_GET_MSG:
- bta_mse_send_oper_cmpl_evt(inst_idx,sess_idx, status);
- bta_mse_clean_msg(inst_idx,sess_idx);
- break;
- case BTA_MSE_OPER_PUSH_MSG:
- bta_mse_send_oper_cmpl_evt(inst_idx,sess_idx, status);
- bta_mse_clean_push_msg(inst_idx,sess_idx);
- break;
- case BTA_MSE_OPER_DEL_MSG:
- case BTA_MSE_OPER_SET_MSG_STATUS:
- bta_mse_clean_set_msg_sts(inst_idx,sess_idx);
- break;
-
- default:
- break;
- }
-
- utl_freebuf((void**)&p_cb->obx.p_pkt);
- p_cb->obx.bytes_left = 0;
-
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_clean_msg
-**
-** Description Cleans up the get message resources and control block
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_clean_msg(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- /* Clean up control block */
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_clean_msg");
-#endif
- utl_freebuf((void **)&p_cb->msg_param.p_msg_handle);
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_NONE);
-
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_end_of_msg
-**
-** Description Complete the end body of the get message response, and
-** sends out the OBX get response
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** rsp_code - Obex response code
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_end_of_msg(UINT8 inst_idx, UINT8 sess_idx, UINT8 rsp_code)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_MSE_OPER_MSG_PARAM *p_param = &p_cb->msg_param;
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_end_of_msg");
-#endif
- /* Add the end of folder listing string if successful operation */
- if (rsp_code == OBX_RSP_OK || rsp_code == OBX_RSP_CONTINUE)
- {
- /* If get message has completed, update the fraction delivery status */
-
- if (p_param->add_frac_del_hdr)
- {
- *(p_param->p_frac_delivery) = p_param->frac_deliver_status;
- p_param->add_frac_del_hdr = FALSE;
- }
-
- p_obx->offset += p_param->filled_buff_size;
-
- if (rsp_code == OBX_RSP_OK)
- {
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, TRUE);
- }
- else /* More data to be sent */
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, FALSE);
-
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* Do not deallocate buffer; OBX will */
-
- if (rsp_code == OBX_RSP_CONTINUE)
- {
- bta_mse_send_get_msg_in_prog_evt(inst_idx, sess_idx);
- }
- else
- {
- bta_mse_clean_getput(inst_idx, sess_idx, BTA_MA_STATUS_OK);
- }
- }
- else /* An error occurred */
- {
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- bta_mse_clean_getput(inst_idx, sess_idx, BTA_MA_STATUS_FAIL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_getmsg
-**
-** Description Processes the get message request
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_getmsg(UINT8 inst_idx, UINT8 sess_idx, BOOLEAN new_req)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_MSE_OPER_MSG_PARAM *p_param = &p_cb->msg_param;
- UINT8 rsp_code = OBX_RSP_OK;
- UINT8 *p, *p_start;
- UINT16 len = 0;
- BOOLEAN first_get=FALSE;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_getmsg");
-#endif
-
- p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle,
- /* p_cb->peer_mtu */ OBX_LRG_DATA_POOL_SIZE);
- if (p_obx->p_pkt)
- {
- /* Is this a new request or continuation? */
- if (new_req)
- {
- first_get = TRUE;
- if (p_param->add_frac_del_hdr)
- {
- /* Add Fraction Deliver Header */
- p_start = OBX_AddByteStrStart(p_obx->p_pkt, &len);
- p = p_start;
- *p++ = BTA_MA_APH_FRAC_DELVR;
- *p++ = 1;
- p_param->p_frac_delivery = p;
- /* use Last as default and it can be changed to More if application indicates more */
- UINT8_TO_BE_STREAM(p, BTA_MA_FRAC_DELIVER_LAST);
- OBX_AddByteStrHdr(p_obx->p_pkt, OBX_HI_APP_PARMS, NULL, (UINT16)(p - p_start));
- }
- }
-
- /* Add the start of the Body Header */
- p_obx->offset = 0;
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
- p_cb->cout_active = TRUE;
- bta_mse_co_get_msg((tBTA_MA_SESS_HANDLE) p_cb->obx_handle,
- &p_param->data,
- first_get,
- p_obx->bytes_left,
- p_obx->p_start,
- BTA_MSE_CI_GET_MSG_EVT,
- bta_mse_cb.app_id);
-
- /* List is not complete, so don't send the response yet */
- rsp_code = OBX_RSP_PART_CONTENT;
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
-
- /* Response goes out if complete or error occurred */
- if (rsp_code != OBX_RSP_PART_CONTENT)
- bta_mse_end_of_msg(inst_idx, sess_idx,rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_clean_msg_list
-**
-** Description Cleans up the get message list resources and control block
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_clean_msg_list(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_MSGLIST *p_ml = &p_cb->ml;
- /* Clean up control block */
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_clean_msg_list");
-#endif
- bta_mse_set_ma_oper(inst_idx, sess_idx, BTA_MSE_OPER_NONE);
- p_ml->remaing_size =0;
- p_ml->offset =0;
- p_ml->pending_ml_frag = FALSE;
-
- utl_freebuf((void**)&p_ml->p_entry);
- utl_freebuf((void**)&p_ml->p_info);
- utl_freebuf((void**)&p_ml->p_xml_buf);
- utl_freebuf((void**)&p_cb->ml_param.p_name);
- utl_freebuf((void**)&p_cb->ml_param.p_path);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_end_of_msg_list
-**
-** Description Complete the end body of the get message listing response, and
-** sends out the OBX get response
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** rsp_code - Obex response code
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_end_of_msg_list(UINT8 inst_idx, UINT8 sess_idx, UINT8 rsp_code)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_MSE_OPER_MLIST_PARAM *p_ml_param = &p_cb->ml_param;
- UINT16 len;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_end_of_msg_list");
-#endif
- /* Add the end of folder listing string if successful operation */
- if (rsp_code == OBX_RSP_OK || rsp_code == OBX_RSP_CONTINUE)
- {
- /* If listing has completed, check the max list count */
- if (rsp_code == OBX_RSP_OK)
- {
- if (p_ml_param->filter.max_list_cnt)
- {
- len = strlen(BTA_MSE_MSG_LISTING_END);
- memcpy(&p_obx->p_start[p_obx->offset], BTA_MSE_MSG_LISTING_END, len);
- p_obx->offset += len;
-
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, TRUE);
- }
-
- /* Clean up control block */
- bta_mse_clean_msg_list(inst_idx, sess_idx);
- }
- else /* More listing data to be sent */
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, FALSE);
-
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* Do not deallocate buffer; OBX will */
- }
- else /* An error occurred */
- {
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- bta_mse_clean_msg_list(inst_idx, sess_idx);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_add_msg_list_info
-**
-** Description Adds applications paramter headers for new message and
-** message list size
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns UINT8 - OBX response code
-** OBX_RSP_PART_CONTENT if not finished yet.
-**
-*******************************************************************************/
-UINT8 bta_mse_add_msg_list_info(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_MSE_MSGLIST *p_ml = &p_cb->ml;
- tBTA_MSE_CO_MSG_LIST_INFO *p_info = p_ml->p_info;
- tBTA_MSE_CO_MSG_LIST_ENTRY *p_entry = p_ml->p_entry;
- tBTA_MA_MSG_LIST_FILTER_PARAM *p_filter = &p_cb->ml_param.filter;
- UINT8 rsp_code = OBX_RSP_PART_CONTENT;
- UINT8 *p, *p_start;
- UINT16 len = 0;
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_add_msg_list_info: new msg=%d, list size=%d",
- p_info->new_msg, p_info->msg_list_size );
-#endif
-
- /* add app params for GetMessageListing */
- p_start = OBX_AddByteStrStart(p_obx->p_pkt, &len);
- p = p_start;
-
- *p++ = BTA_MA_APH_NEW_MSG;
- *p++ = 1;
- UINT8_TO_BE_STREAM(p, p_info->new_msg);
-
- *p++ = BTA_MA_APH_MSG_LST_SIZE;
- *p++ = 2;
- UINT16_TO_BE_STREAM(p, p_info->msg_list_size);
-
- *p++ = BTA_MA_APH_MSE_TIME;
- *p++ = p_info->mse_time_len;
- memcpy(p, p_info->mse_time, p_info->mse_time_len);
- p += p_info->mse_time_len;
-
- if (p != p_start)
- {
- OBX_AddByteStrHdr(p_obx->p_pkt, OBX_HI_APP_PARMS, NULL, (UINT16)(p - p_start));
- }
-
- if (p_filter->max_list_cnt)
- {
- /* Add the start of the Body Header */
- p_obx->offset = 0;
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
-
- len = strlen(BTA_MSE_MSG_LISTING_START);
- memcpy(&p_obx->p_start[p_obx->offset], BTA_MSE_MSG_LISTING_START, len);
- p_obx->bytes_left -= (UINT16)(len + strlen(BTA_MSE_MSG_LISTING_END));
- p_obx->offset += len;
- p_cb->cout_active = TRUE;
- bta_mse_co_get_msg_list_entry((tBTA_MA_SESS_HANDLE) p_cb->obx_handle,
- p_cb->ml_param.p_name,
- p_filter, TRUE,
- p_entry,
- BTA_MSE_CI_GET_ML_ENTRY_EVT,
- bta_mse_cb.app_id);
- }
- else
- {
- /* done with get msg list request */
- rsp_code = OBX_RSP_OK;
- }
- return(rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_add_msg_list_entry
-**
-** Description Adds one entry of the message list to the message list object
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns UINT8 - OBX response code
-** OBX_RSP_PART_CONTENT if not finished yet.
-** OBX_RSP_CONTINUE [packet done]
-** Others send error response out
-**
-*******************************************************************************/
-UINT8 bta_mse_add_msg_list_entry(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_MSE_MSGLIST *p_ml = &p_cb->ml;
- tBTA_MSE_CO_MSG_LIST_ENTRY *p_entry = p_ml->p_entry;
- tBTA_MA_MSG_LIST_FILTER_PARAM *p_filter = &p_cb->ml_param.filter;
- char *p_buf;
- UINT16 size;
- UINT8 rsp_code = OBX_RSP_PART_CONTENT;
- tBTA_MA_STATUS status;
- BOOLEAN release_xml_buf = TRUE;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_add_msg_list_entry");
-#endif
-
- if (p_ml->pending_ml_frag)
- {
- if (p_ml->remaing_size <= p_obx->bytes_left)
- {
- size = p_ml->remaing_size;
- p_ml->pending_ml_frag = FALSE;
- }
- else
- {
- rsp_code = OBX_RSP_CONTINUE;
- size = p_obx->bytes_left;
- }
-
- p_buf = p_ml->p_xml_buf + p_ml->offset;
- memcpy (&p_obx->p_start[p_obx->offset], p_buf, size);
- p_obx->offset += size;
- p_obx->bytes_left -= size;
- p_ml->remaing_size -= size;
- p_ml->offset += size;
-
- if ( !p_ml->pending_ml_frag )
- {
- utl_freebuf((void **) &p_ml->p_xml_buf);
- }
-
-
- if (rsp_code == OBX_RSP_PART_CONTENT)
- {
- /* Get the next msg list entry */
- p_cb->cout_active = TRUE;
- bta_mse_co_get_msg_list_entry((tBTA_MA_SESS_HANDLE) p_cb->obx_handle,
- p_cb->ml_param.p_name,
- p_filter, FALSE,
- p_entry,
- BTA_MSE_CI_GET_ML_ENTRY_EVT,
- bta_mse_cb.app_id);
- }
- return rsp_code;
- }
-
- if ((p_buf = (char *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL)
- {
- p_buf[0] = '\0';
- size = GKI_MAX_BUF_SIZE;
- status = bta_mse_build_msg_listing_obj( p_entry, &size, p_buf );
-
- if (status == BTA_MA_STATUS_OK)
- {
- size = strlen(p_buf);
-
- if (size <= p_obx->bytes_left)
- {
- if ( size > 0)
- {
- memcpy (&p_obx->p_start[p_obx->offset], p_buf, size);
- p_obx->offset += size;
- p_obx->bytes_left -= size;
- }
-
- /* Get the next msg list entry */
- p_cb->cout_active = TRUE;
- bta_mse_co_get_msg_list_entry((tBTA_MA_SESS_HANDLE) p_cb->obx_handle,
- p_cb->ml_param.p_name,
- p_filter, FALSE,
- p_entry,
- BTA_MSE_CI_GET_ML_ENTRY_EVT,
- bta_mse_cb.app_id);
- }
- else /* entry did not fit in current obx packet; try to add entry in next obx req */
- {
- p_ml->pending_ml_frag = TRUE;
- p_ml->p_xml_buf= p_buf;
- p_ml->offset =0;
- p_ml->remaing_size = size - p_obx->bytes_left;
- p_ml->offset += p_obx->bytes_left;
- release_xml_buf = FALSE;
- memcpy (&p_obx->p_start[p_obx->offset], p_buf, p_obx->bytes_left);
- p_obx->offset += p_obx->bytes_left;
- p_obx->bytes_left = 0;
-
- APPL_TRACE_EVENT2("1st msg list fragment peer_mtu=%d msg_list_size=%d",
- p_cb->peer_mtu, size);
- APPL_TRACE_EVENT3("pending_flag=%d offset=%d remaining_size=%d",
- p_ml->pending_ml_frag, p_ml->offset, p_ml->remaing_size);
- APPL_TRACE_EVENT2("obx offset=%d byte_left=%d",
- p_obx->offset, p_obx->bytes_left );
-
- rsp_code = OBX_RSP_CONTINUE;
-
- }
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- /* Done with temporary buffer */
- if (release_xml_buf) utl_freebuf((void **) &p_buf);
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
-
- return(rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_getmsglist
-**
-** Description Process the retrieval of a msg listing.
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_mse_getmsglist(UINT8 inst_idx, UINT8 sess_idx, BOOLEAN new_req)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_MSE_MSGLIST *p_ml = &p_cb->ml;
- UINT8 rsp_code = OBX_RSP_OK;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_getmsglist ");
-#endif
-
- p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle,
- /* p_cb->peer_mtu */ OBX_LRG_DATA_POOL_SIZE);
- if (!p_ml->p_entry)
- {
- /* Allocate enough space for the structure */
- p_ml->p_entry = (tBTA_MSE_CO_MSG_LIST_ENTRY *)
- GKI_getbuf((UINT16)(sizeof(tBTA_MSE_CO_MSG_LIST_ENTRY)));
- }
-
- if (p_ml->p_entry && p_obx->p_pkt)
- {
- /* Is this a new request or continuation? */
- if (new_req)
- {
- if (!p_ml->p_info)
- {
- /* Allocate enough space for the structure */
- p_ml->p_info = (tBTA_MSE_CO_MSG_LIST_INFO *)
- GKI_getbuf((UINT16)(sizeof(tBTA_MSE_CO_MSG_LIST_INFO)));
- }
-
- if (p_ml->p_info)
- {
- p_cb->ml_param.w4info =TRUE;
-
- p_cb->cout_active = TRUE;
- bta_mse_co_get_msg_list_info((tBTA_MA_SESS_HANDLE) p_cb->obx_handle,
- p_cb->ml_param.p_name,
- &(p_cb->ml_param.filter),
- p_ml->p_info,
- BTA_MSE_CI_GET_ML_INFO_EVT,
- bta_mse_cb.app_id);
-
- /* List is not complete, so don't send the response yet */
- rsp_code = OBX_RSP_PART_CONTENT;
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- else /* Add the entry previously retrieved */
- {
- /* Add the start of the Body Header */
- p_obx->offset = 0;
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
- rsp_code = bta_mse_add_msg_list_entry(inst_idx, sess_idx);
- }
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
-
- /* Response goes out if complete or error occurred */
- if (rsp_code != OBX_RSP_PART_CONTENT)
- bta_mse_end_of_msg_list(inst_idx, sess_idx,rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_read_app_params
-**
-** Description Read the specified application parameter from the given OBX packet
-**
-** Parameters p_pkt - obex packet pointer
-** tag - application parameter tag
-** param_len - (output) pointer to the length of application paramter
-**
-** Returns pointer to the application parameter found
-** NULL - not found
-**
-*******************************************************************************/
-
-UINT8 * bta_mse_read_app_params(BT_HDR *p_pkt, UINT8 tag, UINT16 *param_len)
-{
- UINT8 *p_data = NULL, *p = NULL;
- UINT16 data_len = 0;
- int left, len;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_read_app_params");
-#endif
-
- if (OBX_ReadByteStrHdr(p_pkt, OBX_HI_APP_PARMS, &p_data, &data_len, 0))
- {
- left = data_len;
- while (left > 0)
- {
- len = *(p_data + 1);
- if (*p_data == tag)
- {
- p_data += 2;
- p = p_data;
- *param_len = (UINT16) len;
- break;
- }
- p_data += (len+2);
- left -= (len+2);
- }
- }
- return p;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_clean_list
-**
-** Description Cleans up the get folder list resources and control block
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_clean_list(UINT8 inst_idx, UINT8 sess_idx)
-{
-
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_DIRLIST *p_dir = &p_cb->dir;
- /*tBTA_MSE_CO_FOLDER_ENTRY *p_entry = p_dir->p_entry; */
- /* Clean up control block */
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_clean_list");
-#endif
- bta_mse_set_ma_oper(inst_idx,sess_idx, BTA_MSE_OPER_NONE);
- utl_freebuf((void**)&(p_dir->p_entry));
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_end_of_list
-**
-** Description Finishes up the end body of the get folder listing, and sends out the
-** OBX response
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** rsp_code - obex response code
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_end_of_list(UINT8 inst_idx, UINT8 sess_idx, UINT8 rsp_code)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- UINT16 len = 0;
- UINT8 *p, *p_start;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_end_of_list");
-#endif
- /* Add the end of folder listing string if successful operation */
- if (rsp_code == OBX_RSP_OK || rsp_code == OBX_RSP_CONTINUE)
- {
- /* If listing has completed, add on end string (http) */
- if (rsp_code == OBX_RSP_OK)
- {
- if (p_cb->fl_param.max_list_cnt)
- {
- len = strlen(BTA_MSE_FOLDER_LISTING_END);
- memcpy(&p_obx->p_start[p_obx->offset], BTA_MSE_FOLDER_LISTING_END, len);
- p_obx->offset += len;
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, TRUE);
- }
- else
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("list_cnt=%d",p_cb->fl_param.list_cnt);
-#endif
-
- /* send the folder list size header only*/
- p_start = OBX_AddByteStrStart(p_obx->p_pkt, &len);
- p = p_start;
-
- *p++ = BTA_MA_APH_FOLDER_LST_SIZE;
- *p++ = 2;
- UINT16_TO_BE_STREAM(p, p_cb->fl_param.list_cnt);
- if (p != p_start)
- {
- OBX_AddByteStrHdr(p_obx->p_pkt, OBX_HI_APP_PARMS, NULL, (UINT16)(p - p_start));
- }
- }
- /* Clean up control block */
- bta_mse_clean_list(inst_idx, sess_idx);
- }
- else /* More listing data to be sent */
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, FALSE);
-
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* Do not deallocate buffer; OBX will */
- }
- else /* An error occurred */
- {
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- bta_mse_clean_list(inst_idx, sess_idx);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_add_list_entry
-**
-** Description Adds an subfolder entry to the folder list object
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns UINT8 - OBX response code
-** OBX_RSP_PART_CONTENT if not finished yet.
-** OBX_RSP_CONTINUE [packet done]
-** Others send error response out
-**
-*******************************************************************************/
-UINT8 bta_mse_add_list_entry(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_MSE_DIRLIST *p_dir = &p_cb->dir;
- tBTA_MSE_CO_FOLDER_ENTRY *p_entry = p_dir->p_entry;
- char *p_buf;
- UINT16 size;
- UINT8 rsp_code = OBX_RSP_PART_CONTENT;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_add_list_entry");
-#endif
- if ((p_buf = (char *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL)
- {
- p_buf[0] = '\0';
-
- APPL_TRACE_DEBUG2("bta_mse_add_list_entry: attr:0x%02x, name:%s",
- p_entry->mode, p_entry->p_name);
-
- if (p_entry->mode & BTA_MA_A_DIR) /* only process Subdirectory ignore files */
- {
- /* ignore "." and ".." */
- if (strcmp(p_entry->p_name, ".") && strcmp(p_entry->p_name, ".."))
- {
- p_cb->fl_param.list_cnt++;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("list_cnt=%d",p_cb->fl_param.list_cnt);
-#endif
- if (p_cb->fl_param.max_list_cnt)
- {
- if (p_cb->fl_param.list_cnt <= p_cb->fl_param.max_list_cnt)
- {
- if (p_cb->fl_param.list_cnt > p_cb->fl_param.start_offset )
- {
- sprintf(p_buf, " <" BTA_MSE_FOLDER_ELEM " "
- BTA_MSE_NAME_ATTR "=\"%s\"/>" BTA_MSE_XML_EOL,
- p_entry->p_name);
- }
- }
- } /* if max_list_cnt==0 only count the list size - but no body should be included*/
- }
- }/* ignore files i.e. non-folder items */
-
- size = strlen(p_buf);
- if (size <= p_obx->bytes_left)
- {
- if ( size > 0)
- {
- memcpy (&p_obx->p_start[p_obx->offset], p_buf, size);
- p_obx->offset += size;
- p_obx->bytes_left -= size;
- }
-
- if ((p_cb->fl_param.list_cnt < p_cb->fl_param.max_list_cnt) ||
- (p_cb->fl_param.max_list_cnt == 0) )
- {
- /* Get the next directory entry */
- p_cb->cout_active = TRUE;
- bta_mse_co_get_folder_entry((tBTA_MA_SESS_HANDLE) p_cb->obx_handle,
- p_cb->p_workdir, FALSE, p_dir->p_entry,
- BTA_MSE_CI_GET_FENTRY_EVT,
- bta_mse_cb.app_id);
- }
- else
- {
- /* reach the max allowed */
- rsp_code = OBX_RSP_OK;
- }
- }
- else /* entry did not fit in current obx packet; try to add entry in next obx req */
- {
- p_cb->fl_param.list_cnt--;
- rsp_code = OBX_RSP_CONTINUE;
- }
-
- /* Done with temporary buffer */
- GKI_freebuf(p_buf);
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- return(rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_getfolderlist
-**
-** Description Processes the retrieval of a folder listing.
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_getfolderlist(UINT8 inst_idx, UINT8 sess_idx, BOOLEAN new_req)
-{
- tBTA_MSE_MA_CB *p_scb = BTA_MSE_GET_INST_CB_PTR(inst_idx);
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_MSE_DIRLIST *p_dir = &p_cb->dir;
- UINT16 temp_len;
- UINT8 rsp_code = OBX_RSP_OK;
-
-#if BTA_MSE_ENABLE_FS_CO == TRUE
- BOOLEAN is_dir;
-#endif
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_getfolderlist");
-#endif
-
-#if BTA_MSE_ENABLE_FS_CO == TRUE
- /* Make sure the Name is a directory and accessible */
- if (((bta_fs_co_access(p_cb->p_workdir, BTA_FS_ACC_EXIST,
- &is_dir, bta_mse_cb.app_id))!= BTA_FS_CO_OK)
- || !is_dir)
- rsp_code = OBX_RSP_NOT_FOUND;
-#endif
- /* Build the listing */
- if (rsp_code == OBX_RSP_OK)
- {
- p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle,
- /* p_cb->peer_mtu */ OBX_LRG_DATA_POOL_SIZE);
- if (!(strcmp(p_cb->p_workdir, p_scb->p_rootpath)))
- p_dir->is_root = TRUE;
- else
- p_dir->is_root = FALSE;
-
- if (!p_dir->p_entry)
- {
- /* Allocate enough space for the structure and the folder name */
- if ((p_dir->p_entry = (tBTA_MSE_CO_FOLDER_ENTRY *)
- GKI_getbuf((UINT16)(sizeof(tBTA_MSE_CO_FOLDER_ENTRY) +
- p_bta_mse_cfg->max_name_len + 1))) != NULL)
- p_dir->p_entry->p_name = (char *)(p_dir->p_entry + 1);
- }
-
- if (p_dir->p_entry && p_obx->p_pkt)
- {
- if (p_cb->fl_param.max_list_cnt)
- {
- /* Add the start of the Body Header */
- p_obx->offset = 0;
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
- }
-
- /* Is this a new request or continuation? */
- if (new_req)
- {
- APPL_TRACE_EVENT1("Folder List Directory: [%s]", p_cb->p_workdir);
- p_cb->fl_param.list_cnt =0;
-
- /* add body header if max_list_cnt is not 0
- if max_list_cnt =0 then only report the actual number
- accessible folders. Use FolderListingSize header only
- */
-
- if (p_cb->fl_param.max_list_cnt)
- {
- temp_len = strlen(BTA_MSE_FOLDER_LISTING_START);
-
- /* Add the beginning label of http */
- memcpy(p_obx->p_start, BTA_MSE_FOLDER_LISTING_START, temp_len);
- p_obx->bytes_left -= (UINT16)(temp_len + strlen(BTA_MSE_FOLDER_LISTING_END));
- p_obx->offset += temp_len;
-
- /* Add the parent directory if not the root */
- if (strcmp(p_cb->p_workdir, p_scb->p_rootpath))
- {
- APPL_TRACE_EVENT0("Add parent folder");
-
- temp_len = strlen(BTA_MSE_PARENT_FOLDER);
- memcpy(p_obx->p_start + p_obx->offset,
- BTA_MSE_PARENT_FOLDER, temp_len);
- p_obx->bytes_left -= temp_len;
- p_obx->offset += temp_len;
- }
- }
- p_cb->cout_active = TRUE;
- bta_mse_co_get_folder_entry((tBTA_MA_SESS_HANDLE) p_cb->obx_handle,
- p_cb->p_workdir, TRUE, p_dir->p_entry,
- BTA_MSE_CI_GET_FENTRY_EVT,
- bta_mse_cb.app_id);
-
- /* List is not complete, so don't send the response yet */
- rsp_code = OBX_RSP_PART_CONTENT;
- }
- else /* Add the entry previously retrieved */
- rsp_code = bta_mse_add_list_entry(inst_idx, sess_idx);
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
-
- /* Response goes out if complete or error occurred */
- if (rsp_code != OBX_RSP_PART_CONTENT)
- bta_mse_end_of_list(inst_idx, sess_idx,rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_chdir
-**
-** Description Changes the current path based on received setpath paramters
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_oper - (output) pointer to the MSE operation code
-**
-** Returns UINT8 - OBX response code
-** output *p_oper set to BTA_MSE_OPER_SETPATH if the
-** the resulting path is a valid path
-*******************************************************************************/
-UINT8 bta_mse_chdir(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_OPER *p_oper)
-{
- tBTA_MSE_MA_CB *p_scb = BTA_MSE_GET_INST_CB_PTR(inst_idx);
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- char *p_path = p_cb->sp.p_path;
- char *p_name = p_cb->sp.p_name;
- char *p_tmp;
-
- char *p_workdir = p_cb->p_workdir;
- UINT8 rsp_code = OBX_RSP_OK;
-
-#if BTA_MSE_ENABLE_FS_CO == TRUE
- BOOLEAN is_dir;
-#endif
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_chdir flag=%d name=%s",p_cb->sp.flags,p_cb->sp.p_name );
-#endif
- *p_oper = BTA_MSE_OPER_NONE;
- switch (p_cb->sp.flags)
- {
- case BTA_MA_DIR_NAV_ROOT_OR_DOWN_ONE_LVL:
- p_path = p_cb->sp.p_path;
- p_name = p_cb->sp.p_name;
- rsp_code = OBX_RSP_OK;
- if (*p_name == '\0')
- {
- /* backup to root */
- if (strcmp(p_workdir, p_scb->p_rootpath))
- {
- BCM_STRNCPY_S(p_path, p_bta_fs_cfg->max_path_len+1, p_scb->p_rootpath, p_bta_fs_cfg->max_path_len);
- /* go back up to the root folder*/
- *p_oper = BTA_MSE_OPER_SETPATH;
- }
- }
- /* Make sure the new path is not too big */
- /* +1 is for the separator */
- else if ((strlen(p_workdir)+1+strlen(p_name)) <= p_bta_fs_cfg->max_path_len)
- {
- /* create a temporary path for creation attempt */
- sprintf(p_path, "%s%c%s", p_workdir,
- p_bta_fs_cfg->path_separator, p_name);
-#if BTA_MSE_ENABLE_FS_CO == TRUE
- if (((bta_fs_co_access(p_path, BTA_FS_ACC_EXIST,
- &is_dir, bta_mse_cb.app_id)) == BTA_FS_CO_OK) && is_dir)
- {
- /* go back down one level to the name folder*/
- *p_oper = BTA_MSE_OPER_SETPATH;
- }
- else
- rsp_code = OBX_RSP_NOT_FOUND;
-#else
- *p_oper = BTA_MSE_OPER_SETPATH;
-#endif
- }
- else
- {
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- break;
- case BTA_MA_DIR_NAV_UP_ONE_LVL:
-
- if (strcmp(p_workdir, p_scb->p_rootpath))
- {
- /* Find the last occurrence of separator and replace with '\0' */
- BCM_STRNCPY_S(p_path, p_bta_fs_cfg->max_path_len+1, p_workdir, p_bta_fs_cfg->max_path_len);
- if ((p_tmp = strrchr(p_path, (int)p_bta_fs_cfg->path_separator)) != NULL)
- {
- *p_tmp = '\0';
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("path=[%s]",p_path );
- APPL_TRACE_EVENT1("name=[%s]", p_name );
-#endif
- /* now check we need to go down one level if name is not empty*/
- if (*p_name !='\0')
- {
- if ((strlen(p_workdir)+1+strlen(p_name)) <= p_bta_fs_cfg->max_path_len)
- {
- sprintf(p_path, "%s%c%s", p_path,
- p_bta_fs_cfg->path_separator, p_name);
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("Up one level and then down one" );
- APPL_TRACE_EVENT1("path=[%s]",p_path );
-#endif
-#if BTA_MSE_ENABLE_FS_CO == TRUE
- if (((bta_fs_co_access(p_path, BTA_FS_ACC_EXIST,
- &is_dir, bta_mse_cb.app_id)) == BTA_FS_CO_OK) && is_dir)
- {
- /* go up one level and then go down one level to the name folder */
- *p_oper = BTA_MSE_OPER_SETPATH;
- }
- else
- {
- rsp_code = OBX_RSP_NOT_FOUND;
- }
-#else
- *p_oper = BTA_MSE_OPER_SETPATH;
-#endif
- }
- else
- {
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- }
- else
- {
- /* just go up one level to the parent directory */
- *p_oper = BTA_MSE_OPER_SETPATH;
- }
- }
- else
- {
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- }
- else
- {
- rsp_code = OBX_RSP_NOT_FOUND;
- }
- break;
- default:
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- break;
- }
-
- return(rsp_code);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_send_set_notif_reg
-**
-** Description Send a set notification registration event to application
-** so application can decide whether the request is allowed or not
-**
-** Parameters status - (output) pointer to the MSE operation code
-** inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns TRUE - request is sent FALSE - requestr is not sent due to
-** error in the request
-*******************************************************************************/
-BOOLEAN bta_mse_send_set_notif_reg(UINT8 status,
- UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_MA_CB *p_scb = BTA_MSE_GET_INST_CB_PTR(inst_idx);
- tBTA_MSE cback_evt_data;
- tBTA_MA_NOTIF_STATUS notif_sts = BTA_MA_NOTIF_OFF;
- BOOLEAN send_status = TRUE;
- UINT8 ccb_idx;
-
- if (status & BTA_MA_NOTIF_STS_ON) notif_sts = BTA_MA_NOTIF_ON;
-
- if (notif_sts == BTA_MA_NOTIF_OFF)
- {
- if (!bta_mse_find_bd_addr_match_mn_cb_index(p_cb->bd_addr, &ccb_idx))
- {
- send_status = FALSE;
- }
- }
-
- if (send_status)
- {
- cback_evt_data.set_notif_reg.mas_session_id = p_cb->obx_handle;
- cback_evt_data.set_notif_reg.mas_instance_id = p_scb->mas_inst_id;
- cback_evt_data.set_notif_reg.notif_status = notif_sts;
- bdcpy(cback_evt_data.set_notif_reg.bd_addr, p_cb->bd_addr);
- bta_mse_cb.p_cback(BTA_MSE_SET_NOTIF_REG_EVT, (tBTA_MSE *) &cback_evt_data);
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_send_set_notif_reg send_status=%d",send_status );
-#endif
-
-
- return send_status;
-
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_proc_notif_reg_status
-**
-** Description Process the notification registration status to determine
-** whether a MN conenction should be opened or closed
-**
-** Parameters status - (output) pointer to the MSE operation code
-** inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_mse_proc_notif_reg_status(UINT8 status,
- UINT8 inst_idx, UINT8 sess_idx )
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_MA_CB *p_scb = BTA_MSE_GET_INST_CB_PTR(inst_idx);
- tBTA_MA_NOTIF_STATUS notif_sts = BTA_MA_NOTIF_OFF;
- tBTA_MSE_MN_CB *p_ccb;
- UINT8 ccb_idx;
- tBTA_MSE_MN_ACT_TYPE mn_act_type = BTA_MSE_MN_ACT_TYPE_NONE;
- tOBX_RSP_CODE rsp_code = OBX_RSP_OK;
-
- tBTA_MSE cback_evt_data;
- tBTA_MSE_MN_INT_OPEN *p_open_evt;
- tBTA_MSE_MN_INT_CLOSE *p_close_evt;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_proc_notif_reg_status");
-#endif
-
- if (status & BTA_MA_NOTIF_STS_ON) notif_sts = BTA_MA_NOTIF_ON;
-
- switch (notif_sts)
- {
- case BTA_MA_NOTIF_ON:
-
- if (!bta_mse_find_bd_addr_match_mn_cb_index(p_cb->bd_addr, &ccb_idx))
- {
- if (bta_mse_find_avail_mn_cb_idx(&ccb_idx))
- mn_act_type = BTA_MSE_MN_ACT_TYPE_OPEN_CONN;
- else
- mn_act_type = BTA_MSE_MN_ACT_TYPE_OPEN_CONN_ERR;
- }
- else
- {
- /* it is connected already */
- mn_act_type = BTA_MSE_MN_ACT_TYPE_OPEN_CONN_NONE;
- }
- break;
-
- case BTA_MA_NOTIF_OFF:
-
- if (!bta_mse_find_bd_addr_match_mn_cb_index(p_cb->bd_addr, &ccb_idx))
- {
- mn_act_type = BTA_MSE_MN_ACT_TYPE_CLOSE_CONN_ERR;
- break;
- }
-
- p_ccb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-
- if ((p_ccb->state !=BTA_MSE_MN_W4_CONN_ST) &&
- (p_ccb->state !=BTA_MSE_MN_CONN_ST))
- {
- /* MN is either idle or to be closed shortly so do nothing*/
- mn_act_type = BTA_MSE_MN_ACT_TYPE_CLOSE_CONN_NONE;
- }
- else
- {
- if (bta_mse_mn_is_ok_to_close_mn(p_cb->bd_addr, p_scb->mas_inst_id))
- {
- /* This is the last active MN session using this conncection*/
- mn_act_type = BTA_MSE_MN_ACT_TYPE_CLOSE_CONN;
- }
- else
- {
- mn_act_type = BTA_MSE_MN_ACT_TYPE_CLOSE_CONN_NONE;
- }
- }
- break;
- }
-
- switch (mn_act_type)
- {
- case BTA_MSE_MN_ACT_TYPE_OPEN_CONN:
-
- if ((p_open_evt = (tBTA_MSE_MN_INT_OPEN *) GKI_getbuf(sizeof(tBTA_MSE_MN_INT_OPEN))) != NULL)
- {
- bta_mse_mn_add_inst_id(ccb_idx, p_scb->mas_inst_id);
- p_open_evt->hdr.event = BTA_MSE_MN_INT_OPEN_EVT;
- p_open_evt->ccb_idx = ccb_idx;
- p_open_evt->sec_mask = (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT);
- memcpy(p_open_evt->bd_addr, p_cb->bd_addr, sizeof(BD_ADDR));
- bta_sys_sendmsg(p_open_evt);
- }
- else
- {
- rsp_code = OBX_RSP_FAILED;
- }
-
- break;
-
- case BTA_MSE_MN_ACT_TYPE_CLOSE_CONN:
-
- if ((p_close_evt = (tBTA_MSE_MN_INT_CLOSE *) GKI_getbuf(sizeof(tBTA_MSE_MN_INT_CLOSE))) != NULL)
- {
- bta_mse_mn_remove_inst_id(ccb_idx, p_scb->mas_inst_id);
- p_close_evt->hdr.event = BTA_MSE_MN_INT_CLOSE_EVT;
- p_close_evt->ccb_idx = ccb_idx;
- bta_sys_sendmsg(p_close_evt);
- }
- else
- {
- rsp_code = OBX_RSP_FAILED;
- }
- break;
-
- case BTA_MSE_MN_ACT_TYPE_OPEN_CONN_ERR:
- rsp_code = OBX_RSP_FAILED;
- break;
-
- case BTA_MSE_MN_ACT_TYPE_OPEN_CONN_NONE:
- bta_mse_mn_add_inst_id(ccb_idx, p_scb->mas_inst_id);
- break;
- case BTA_MSE_MN_ACT_TYPE_CLOSE_CONN_NONE:
- bta_mse_mn_remove_inst_id(ccb_idx, p_scb->mas_inst_id);
- break;
- default:
- break;
- }
-
- OBX_PutRsp(p_cb->obx_handle , rsp_code, NULL);
- if (rsp_code == OBX_RSP_OK)
- cback_evt_data.notif_reg.status = BTA_MA_STATUS_OK;
- else
- cback_evt_data.notif_reg.status = BTA_MA_STATUS_FAIL;
- cback_evt_data.notif_reg.mas_session_id = p_cb->obx_handle;
- cback_evt_data.notif_reg.mas_instance_id = p_scb->mas_inst_id;
- cback_evt_data.notif_reg.notif_status = notif_sts;
- bdcpy(cback_evt_data.notif_reg.bd_addr, p_cb->bd_addr);
- bta_mse_clean_set_notif_reg(inst_idx,sess_idx);
-
- bta_mse_cb.p_cback(BTA_MSE_NOTIF_REG_EVT, (tBTA_MSE *) &cback_evt_data);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_discard_data
-**
-** Description frees the data
-**
-** Parameters event - MSE event
-** p_data - Pointer to the MSE event data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_discard_data(UINT16 event, tBTA_MSE_DATA *p_data)
-{
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_discard_data");
-#endif
-
- switch (event)
- {
- case BTA_MSE_MA_OBX_CONN_EVT:
- case BTA_MSE_MA_OBX_DISC_EVT:
- case BTA_MSE_MA_OBX_ABORT_EVT:
- case BTA_MSE_MA_OBX_CLOSE_EVT:
- case BTA_MSE_MA_OBX_PUT_EVT:
- case BTA_MSE_MA_OBX_GET_EVT:
- case BTA_MSE_MA_OBX_SETPATH_EVT:
- utl_freebuf((void**)&p_data->obx_evt.p_pkt);
- break;
-
- default:
- /*Nothing to free*/
- break;
- }
-}
-
-
-
-/*******************************************************************************
-**
-** Function bta_mse_find_mas_inst_id_match_cb_idx
-**
-** Description Finds the MAS instance control block index based on the specified
-** MAS instance ID
-**
-** Parameters mas_inst_id - MAS instance ID
-** p_idx - (output) pointer to the MA control block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-*******************************************************************************/
-BOOLEAN bta_mse_find_mas_inst_id_match_cb_idx(tBTA_MA_INST_ID mas_inst_id, UINT8 *p_idx)
-{
- BOOLEAN found=FALSE;
- UINT8 i;
-
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if (bta_mse_cb.scb[i].in_use)
- {
- if (bta_mse_cb.scb[i].mas_inst_id == mas_inst_id)
- {
- found = TRUE;
- *p_idx = i;
- break;
- }
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT3("bta_mse_find_mas_inst_id_match_cb_idx found=%d, inst_id=%d inst_idx=%d",
- found, mas_inst_id, i);
-#endif
- return found;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_find_bd_addr_match_sess_cb_idx
-**
-** Description Finds the Session control block index based on the specified
-** MAS instance control block index and BD address
-**
-** Parameters bd_addr - BD address
-** inst_idx - MA control block index
-** p_idx - (output) pointer to the MA server control block
-** index
-**
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-*******************************************************************************/
-BOOLEAN bta_mse_find_bd_addr_match_sess_cb_idx(BD_ADDR bd_addr, UINT8 inst_idx,
- UINT8 *p_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb;
- BOOLEAN found=FALSE;
- UINT8 i;
-
- for (i=0; i < BTA_MSE_NUM_SESS ; i ++)
- {
- p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, i);
- if ((p_cb->state == BTA_MSE_MA_CONN_ST) &&
- !memcmp (p_cb->bd_addr, bd_addr, BD_ADDR_LEN))
- {
- found = TRUE;
- *p_idx = i;
- break;
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT3("bta_mse_find_bd_addr_match_sess_cb_idx found=%d, inst_idx=%d p_idx=%d",
- found, inst_idx, i);
-#endif
- return found;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_find_handle_match_mas_inst_cb_idx
-**
-** Description Finds the MAS instance control block index based on the specified Obx handle
-**
-** Parameters obx_handle - Obex session handle
-** p_idx - (output) pointer to the MA server control block index
-**
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-BOOLEAN bta_mse_find_handle_match_mas_inst_cb_idx(tOBX_HANDLE obx_handle, UINT8 *p_idx)
-{
- BOOLEAN found=FALSE;
- UINT8 i;
-
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if (bta_mse_cb.scb[i].in_use)
- {
- if (bta_mse_cb.scb[i].obx_handle == obx_handle)
- {
- found = TRUE;
- *p_idx = i;
- break;
- }
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_find_handle_match_mas_inst_cb_idx found=%d idx=%d",found, i);
-#endif
- return found;
-}
-/*******************************************************************************
-**
-** Function bta_mse_find_mas_sess_cb_idx
-**
-** Description Finds the MAS instance and session control block indexes
-** based on Obx handle
-**
-** Parameters obx_handle - Obex session handle
-** p_mas_inst_idx - (output) pointer to the MA server control
-** block index
-** p_mas_sess_idx - (output) pointer to the MA session control
-** block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-BOOLEAN bta_mse_find_mas_sess_cb_idx(tOBX_HANDLE obx_handle,
- UINT8 *p_mas_inst_idx, UINT8 *p_mas_sess_idx)
-{
- BOOLEAN found=FALSE;
- UINT8 i, j;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_find_mas_sess_cb_idx");
-#endif
- for (i=0; i< BTA_MSE_NUM_INST; i++)
- {
- if (bta_mse_cb.scb[i].in_use)
- {
- for (j=0; j < BTA_MSE_NUM_SESS; j++ )
- {
- if ( (bta_mse_cb.scb[i].sess_cb[j].state != BTA_MSE_MA_LISTEN_ST) &&
- (bta_mse_cb.scb[i].sess_cb[j].obx_handle == obx_handle) )
- {
- found = TRUE;
- *p_mas_inst_idx = i;
- *p_mas_sess_idx = j;
- return found;
- }
- }
- }
- }
-
- return found;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_find_ma_cb_indexes
-**
-** Description Finds the MAS instance and session control block indexes
-** based on the received internal event
-**
-** Parameters p_msg - Pointer to MSE msg data
-** p_mas_inst_idx - (output) pointer to the MA server control
-** block index
-** p_mas_sess_idx - (output) pointer to the MA session control
-** block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-BOOLEAN bta_mse_find_ma_cb_indexes(tBTA_MSE_DATA *p_msg,
- UINT8 *p_inst_idx, UINT8 *p_sess_idx)
-{
- BOOLEAN found = FALSE;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_find_ma_cb_indexes");
-#endif
- switch (p_msg->hdr.event)
- {
- case BTA_MSE_MA_OBX_CONN_EVT:
-
- if (bta_mse_find_handle_match_mas_inst_cb_idx( p_msg->obx_evt.param.conn.handle, p_inst_idx))
- {
- if (bta_mse_find_avail_mas_sess_cb_idx(&(bta_mse_cb.scb[*p_inst_idx]), p_sess_idx))
- found = TRUE;
- }
- break;
-
- case BTA_MSE_API_ACCESSRSP_EVT:
-
- if (bta_mse_find_sess_id_match_ma_cb_indexes(p_msg->api_access_rsp.mas_session_id,
- p_inst_idx,p_sess_idx))
- found = TRUE;
-
- break;
-
- case BTA_MSE_API_UPD_IBX_RSP_EVT:
-
- if (bta_mse_find_sess_id_match_ma_cb_indexes(p_msg->api_upd_ibx_rsp.mas_session_id,
- p_inst_idx,p_sess_idx))
- found = TRUE;
-
- break;
-
- case BTA_MSE_API_SET_NOTIF_REG_RSP_EVT:
-
- if (bta_mse_find_sess_id_match_ma_cb_indexes(p_msg->api_set_notif_reg_rsp.mas_session_id,
- p_inst_idx,p_sess_idx))
- found = TRUE;
-
- break;
-
- case BTA_MSE_INT_CLOSE_EVT:
-
- if (bta_mse_find_sess_id_match_ma_cb_indexes(p_msg->int_close.mas_session_id,
- p_inst_idx,p_sess_idx))
- found = TRUE;
-
- break;
-
- case BTA_MSE_CI_GET_FENTRY_EVT:
-
- if (bta_mse_find_sess_id_match_ma_cb_indexes(p_msg->ci_get_fentry.mas_session_id,
- p_inst_idx,p_sess_idx))
- found = TRUE;
-
- break;
- case BTA_MSE_CI_GET_ML_INFO_EVT:
-
- if (bta_mse_find_sess_id_match_ma_cb_indexes(p_msg->ci_get_ml_info.mas_session_id,
- p_inst_idx,p_sess_idx))
- found = TRUE;
-
- break;
- case BTA_MSE_CI_GET_ML_ENTRY_EVT:
-
- if (bta_mse_find_sess_id_match_ma_cb_indexes(p_msg->ci_get_ml_entry.mas_session_id,
- p_inst_idx,p_sess_idx))
- found = TRUE;
-
- break;
- case BTA_MSE_CI_GET_MSG_EVT:
-
- if (bta_mse_find_sess_id_match_ma_cb_indexes(p_msg->ci_get_msg.mas_session_id,
- p_inst_idx,p_sess_idx))
- found = TRUE;
-
- break;
-
- case BTA_MSE_CI_PUSH_MSG_EVT:
-
- if (bta_mse_find_sess_id_match_ma_cb_indexes(p_msg->ci_push_msg.mas_session_id,
- p_inst_idx,p_sess_idx))
- found = TRUE;
-
- break;
-
- case BTA_MSE_CI_DEL_MSG_EVT:
-
- if (bta_mse_find_sess_id_match_ma_cb_indexes(p_msg->ci_del_msg.mas_session_id,
- p_inst_idx,p_sess_idx))
- found = TRUE;
-
- break;
-
- case BTA_MSE_MA_OBX_DISC_EVT:
- case BTA_MSE_MA_OBX_ABORT_EVT:
- case BTA_MSE_MA_OBX_CLOSE_EVT:
- case BTA_MSE_MA_OBX_PUT_EVT:
- case BTA_MSE_MA_OBX_GET_EVT:
- case BTA_MSE_MA_OBX_SETPATH_EVT:
-
- if (bta_mse_find_mas_sess_cb_idx( p_msg->obx_evt.handle, p_inst_idx, p_sess_idx))
- found = TRUE;
- break;
- default:
- break;
-
- }
-
- return found;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_cleanup
-**
-** Description Free resources if unable to find MA control block indexes
-**
-** Parameters p_msg - Pointer to MSE msg data
-**
-** Returns none
-**
-*******************************************************************************/
-void bta_mse_ma_cleanup(tBTA_MSE_DATA *p_msg)
-{
- tBTA_MSE_OBX_EVT *p_evt = &p_msg->obx_evt;
- tBTA_MA_OBX_RSP *p_rsp = NULL;
- UINT8 rsp_code = OBX_RSP_BAD_REQUEST;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_ma_cleanup");
-#endif
- switch (p_msg->hdr.event)
- {
- case BTA_MSE_MA_OBX_CONN_EVT:
- p_rsp = OBX_ConnectRsp;
- rsp_code = OBX_RSP_SERVICE_UNAVL;
- break;
- case BTA_MSE_MA_OBX_DISC_EVT:
- p_rsp = OBX_DisconnectRsp;
- break;
- case BTA_MSE_MA_OBX_ABORT_EVT:
- p_rsp = OBX_AbortRsp;
- break;
- case BTA_MSE_MA_OBX_PUT_EVT:
- p_rsp = OBX_PutRsp;
- break;
- case BTA_MSE_MA_OBX_GET_EVT:
- p_rsp = OBX_GetRsp;
- break;
- case BTA_MSE_MA_OBX_SETPATH_EVT:
- p_rsp = OBX_SetPathRsp;
- break;
- default:
- break;
- }
-
- if (p_rsp)
- {
- (*p_rsp)(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
- }
-}
-
-
-
-/*******************************************************************************
-**
-** Function bta_mse_is_a_duplicate_id
-**
-** Description Determine the MAS instance ID has been used or not by other MAS instance
-**
-** Parameters mas_inst_id - MAS instance ID
-**
-** Returns BOOLEAN - TRUE the MAS isntance is a duplicate ID
-** FALSE not a duplicate ID
-*******************************************************************************/
-BOOLEAN bta_mse_is_a_duplicate_id(tBTA_MA_INST_ID mas_inst_id)
-{
- BOOLEAN is_duplicate=FALSE;
- UINT8 i;
-
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if (bta_mse_cb.scb[i].in_use &&
- (bta_mse_cb.scb[i].mas_inst_id == mas_inst_id))
- {
- is_duplicate = TRUE;
-
- break;
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_is_a_duplicate_id inst_id=%d status=%d",
- mas_inst_id, is_duplicate);
-#endif
-
- return is_duplicate;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_find_avail_mas_inst_cb_idx
-**
-** Description Finds a not in used MAS instance control block index
-**
-** Parameters p_idx - (output) pointer to the MA server control
-** block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-BOOLEAN bta_mse_find_avail_mas_inst_cb_idx(UINT8 *p_idx)
-{
- BOOLEAN found=FALSE;
- UINT8 i;
-
-
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if (!bta_mse_cb.scb[i].in_use)
- {
- found = TRUE;
- *p_idx = i;
- break;
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_find_avail_mas_inst_cb_idx found=%d inst_idx=%d",
- found, i);
-#endif
- return found;
-}
-/*******************************************************************************
-**
-** Function bta_mse_find_avail_mas_sess_cb_idx
-**
-** Description Finds a not in used MAS session control block index
-**
-** Parameters p_scb - Pointer to the MA control block
-** p_idx - (output) pointer to the MA session control
-** block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-*******************************************************************************/
-BOOLEAN bta_mse_find_avail_mas_sess_cb_idx(tBTA_MSE_MA_CB *p_scb, UINT8 *p_idx)
-{
- BOOLEAN found=FALSE;
- UINT8 i;
-
- for (i=0; i < BTA_MSE_NUM_SESS ; i ++)
- {
- if (p_scb->sess_cb[i].state == BTA_MSE_MA_LISTEN_ST)
- {
- if ((p_scb->sess_cb[i].p_workdir = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- found = TRUE;
- *p_idx = i;
- }
- break;
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_find_avail_mas_sess_cb_idx found=%d idx=%d", found, i);
-#endif
- return found;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_find_avail_mn_cb_idx
-**
-** Description Finds a not in use MN control block index
-**
-** Parameters p_idx - (output) pointer to the MN control block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-BOOLEAN bta_mse_find_avail_mn_cb_idx(UINT8 *p_idx)
-{
- BOOLEAN found=FALSE;
- UINT8 i;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_find_avail_mn_cb_idx");
-#endif
- for (i=0; i < BTA_MSE_NUM_MN ; i ++)
- {
- if (!bta_mse_cb.ccb[i].in_use)
- {
- found = TRUE;
- *p_idx = i;
- break;
- }
- }
- return found;
-}
-
-
-
-/*******************************************************************************
-**
-** Function bta_mse_find_bd_addr_match_mn_cb_index
-**
-** Description Find the MN control block index based on the specified BD address
-**
-** Parameters p_bd_addr - Pointer to the BD address
-** p_idx - (output) pointer to the MN control block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-
-BOOLEAN bta_mse_find_bd_addr_match_mn_cb_index(BD_ADDR p_bd_addr, UINT8 *p_idx)
-{
- BOOLEAN found=FALSE;
- UINT8 i;
-
- for (i=0; i < BTA_MSE_NUM_MN ; i ++)
- {
- if ((bta_mse_cb.ccb[i].in_use) &&
- (!memcmp (bta_mse_cb.ccb[i].bd_addr, p_bd_addr, BD_ADDR_LEN)))
- {
- found = TRUE;
- *p_idx = i;
- break;
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_find_bd_addr_match_mn_cb_index found=%d index=%d", found, i);
-#endif
- return found;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_find_bd_addr_match_mn_cb_index
-**
-** Description Find the MN control block index based on the specified obx handle
-**
-** Parameters obx_hdl - Obex session handle
-** p_idx - (output) pointer to the MN control block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-
-BOOLEAN bta_mse_find_obx_hdl_match_mn_cb_index(tOBX_HANDLE obx_hdl, UINT8 *p_idx)
-{
- BOOLEAN found=FALSE;
- UINT8 i;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_find_obx_hdl_match_mn_cb_index");
-#endif
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if ((bta_mse_cb.ccb[i].in_use) &&
- (bta_mse_cb.ccb[i].obx_handle == obx_hdl))
- {
- found = TRUE;
- *p_idx = i;
- break;
- }
- }
-
- return found;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_find_sess_id_match_ma_cb_indexes
-**
-** Description Finds the MAS instance and session control block indexes
-** based on the specified MAS session ID
-**
-** Parameters mas_session_id - MAS instance ID
-** p_inst_idx - (output) pointer to the MA server control
-** block index
-** p_sess_idx - (output) pointer to the MA session control
-** block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-BOOLEAN bta_mse_find_sess_id_match_ma_cb_indexes(tBTA_MA_SESS_HANDLE mas_session_id,
- UINT8 *p_inst_idx, UINT8 *p_sess_idx)
-{
- BOOLEAN found=FALSE;
- UINT8 i,j;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_find_sess_id_match_ma_cb_indexes");
-#endif
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- for (j=0; j<BTA_MSE_NUM_SESS; j++ )
- {
- if ((bta_mse_cb.scb[i].in_use) &&
- (bta_mse_cb.scb[i].sess_cb[j].obx_handle == (tOBX_HANDLE) mas_session_id ))
- {
- found = TRUE;
- *p_inst_idx = i;
- *p_sess_idx = j;
- return found;
- }
- }
- }
-
- return found;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_find_sess_id_match_mn_cb_index
-**
-** Description Finds the MN control block index
-** based on the specified MAS session ID
-**
-** Parameters mas_session_id - MAS instance ID
-** p_idx - (output) pointer to the MN control
-** block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-BOOLEAN bta_mse_find_sess_id_match_mn_cb_index(tBTA_MA_SESS_HANDLE mas_session_id,
- UINT8 *p_idx)
-{
- BOOLEAN found=FALSE;
-
- UINT8 i,j;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_find_sess_id_match_mn_cb_index");
-#endif
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- for (j=0; j<BTA_MSE_NUM_SESS; j++ )
- {
- if ((bta_mse_cb.scb[i].in_use) &&
- (bta_mse_cb.scb[i].sess_cb[j].obx_handle == (tOBX_HANDLE) mas_session_id ))
- {
- found = TRUE;
- break;
- }
- }
- if (found) break;
- }
-
- /* found session index now need to match BD address*/
- if (found)
- {
- found = FALSE;
- if ( bta_mse_find_bd_addr_match_mn_cb_index(bta_mse_cb.scb[i].sess_cb[j].bd_addr, p_idx))
- {
- found = TRUE;
- }
- }
- return found;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_find_mn_cb_index
-**
-** Description Finds the MN control block index
-** based on the specified event
-**
-** Parameters p_msg - Pointer to MSE msg data
-** p_ccb_idx - (output) pointer to the MN control block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-BOOLEAN bta_mse_find_mn_cb_index(tBTA_MSE_DATA *p_msg, UINT8 *p_ccb_idx)
-{
- BOOLEAN found = TRUE;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_find_mn_cb_index");
-#endif
- switch (p_msg->hdr.event)
- {
- case BTA_MSE_MN_INT_OPEN_EVT:
- *p_ccb_idx= p_msg->mn_int_open.ccb_idx;
- break;
-
- case BTA_MSE_MN_INT_CLOSE_EVT:
- *p_ccb_idx= p_msg->mn_int_close.ccb_idx;
- break;
-
- case BTA_MSE_MN_OBX_CONN_RSP_EVT:
-
- if (!bta_mse_find_bd_addr_match_mn_cb_index(
- p_msg->obx_evt.param.conn.peer_addr,
- p_ccb_idx))
- {
- found = FALSE;
- }
- break;
-
- case BTA_MSE_MN_OBX_TOUT_EVT:
- case BTA_MSE_MN_OBX_CLOSE_EVT:
- case BTA_MSE_MN_OBX_PUT_RSP_EVT:
- if (!bta_mse_find_obx_hdl_match_mn_cb_index(
- p_msg->obx_evt.handle,
- p_ccb_idx))
- {
- found = FALSE;
- }
-
- break;
-
- case BTA_MSE_MN_SDP_OK_EVT:
-
- *p_ccb_idx = p_msg->mn_sdp_ok.ccb_idx;
- break;
-
- case BTA_MSE_MN_SDP_FAIL_EVT:
-
- *p_ccb_idx = p_msg->mn_sdp_fail.ccb_idx;
- break;
-
- default:
- found = FALSE;
- break;
- }
-
- return found;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_cleanup
-**
-** Description Free resources if unable to find MN control block index
-**
-** Parameters p_msg - Pointer to MSE msg data
-**
-** Returns none
-**
-*******************************************************************************/
-void bta_mse_mn_cleanup(tBTA_MSE_DATA *p_msg)
-{
- tBTA_MSE_OBX_EVT *p_evt = &p_msg->obx_evt;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_mn_cleanup");
-#endif
- switch (p_msg->hdr.event)
- {
- case BTA_MSE_MN_OBX_CONN_RSP_EVT:
- case BTA_MSE_MN_OBX_PUT_RSP_EVT:
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
- break;
-
- default:
- break;
- }
-}
-/*******************************************************************************
-**
-** Function bta_mse_build_map_event_rpt_obj
-**
-** Description Create a MAP-Event-Report object in the
-** specified buffer.
-**
-** Parameters notif_type - Notification type
-** handle (input only) - handle of the message that the "type"
-** indication refers to. Ignored when the event "type" is
-** "MemoryFull" or "MemoryAvailable".
-** p_folder - name of the folder in which the corresponding
-** message has been filed by the MSE. NULL when the event
-** "type" is "MemoryFull" or "MemoryAvailable".
-** p_old_folder - Used only in case of a message shift to
-** indicate the folder on the MSE from which the message
-** has been shifted out.
-** msg_typ - Gives the type of the message. Ignored when the
-** event "type" is "MemoryFull" or "MemoryAvailable".
-** p_len - Pointer to value containing the size of
-** the buffer (p_buffer). Receives the output size of
-** filled XML object.
-** p_buffer - Pointer to buffer to receive the XML object.
-**
-** Returns BTA_MA_STATUS_FAIL if buffer was not large enough, otherwise
-** returns BTA_MA_STATUS_OK.
-**
-*******************************************************************************/
-tBTA_MA_STATUS bta_mse_build_map_event_rpt_obj(tBTA_MSE_NOTIF_TYPE notif_type,
- tBTA_MA_MSG_HANDLE handle,
- char * p_folder,
- char * p_old_folder,
- tBTA_MA_MSG_TYPE msg_typ,
- UINT16 * p_len,
- UINT8 * p_buffer)
-{
- tBTA_MA_STREAM strm;
-
- memset(p_buffer, 0, *p_len);
- BTA_MaInitMemStream(&strm, p_buffer, *p_len);
-
- /* stream event attribute and event type */
- bta_ma_stream_str(&strm, "<MAP-event-report version=\"1.0\">\n"
- "<event type = \"");
- bta_ma_stream_str(&strm, bta_ma_evt_typ_to_string(notif_type));
-
- /* Some things are not used for "MemoryFull" and "MemoryAvailable" */
- if ( (BTA_MSE_NOTIF_TYPE_MEMORY_FULL != notif_type)
- && (BTA_MSE_NOTIF_TYPE_MEMORY_AVAILABLE != notif_type) )
- {
- /* stream handle label and value */
- bta_ma_stream_str(&strm, "\" handle = \"");
- bta_ma_stream_handle(&strm, handle);
-
- if (p_folder && (*p_folder !='\0'))
- {
- /* stream folder */
- bta_ma_stream_str(&strm, "\" folder = \"");
- bta_ma_stream_str(&strm, p_folder);
- }
-
- /* stream old_folder if it is a "MessageShift" */
- if ( (BTA_MSE_NOTIF_TYPE_MESSAGE_SHIFT == notif_type) &&
- p_old_folder && (*p_old_folder !='\0'))
- {
- /* stream folder */
- bta_ma_stream_str(&strm, "\" old_folder = \"");
- bta_ma_stream_str(&strm, p_old_folder);
- }
-
- /* stream message type */
- bta_ma_stream_str(&strm, "\" msg_type = \"");
- bta_ma_stream_str(&strm, bta_ma_msg_typ_to_string(msg_typ));
- }
-
- /* we are done with this evnet */
- bta_ma_stream_str(&strm, "\" />\n</MAP-event-report>");
-
- /* set the output length (i.e. amount of buffer that got used) */
- *p_len = bta_ma_stream_used_size(&strm);
-
- /* return status based on the stream status */
- return(bta_ma_stream_ok(&strm)
- ? BTA_MA_STATUS_OK
- : BTA_MA_STATUS_FAIL);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_build_msg_listing_obj
-**
-** Description Build the message listing object in the specified buffer
-**
-** Parameters p_entry - Pointer to the message listing entry
-** p_size - input: pointer to the available buffer size
-** output: pointer to the filled buffer size
-** p_buf - pointer to the buffer for building the msg listing
-** object
-**
-** Returns status - BTA_MA_STATUS_OK - build the object successfully
-** BTA_MA_STATUS_FAIL - failed to build the object
-**
-*******************************************************************************/
-tBTA_MA_STATUS bta_mse_build_msg_listing_obj(tBTA_MSE_CO_MSG_LIST_ENTRY *p_entry,
- UINT16 *p_size, char *p_buf )
-{
- tBTA_MA_STREAM strm;
-
- memset(p_buf, 0, *p_size);
- BTA_MaInitMemStream(&strm, (UINT8 *)p_buf, *p_size);
-
- /* stream msg element */
- bta_ma_stream_str(&strm, "<msg ");
- /* stream msg attributes */
- bta_ma_stream_str(&strm, "handle = \"");
- bta_ma_stream_handle(&strm, p_entry->msg_handle);
-
- if (p_entry->parameter_mask &BTA_MA_ML_MASK_SUBJECT)
- {
- bta_ma_stream_str(&strm, "\" subject = \"");
- bta_ma_stream_str(&strm, p_entry->subject);
- }
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_DATETIME)
- {
- bta_ma_stream_str(&strm, "\" datetime = \"");
- bta_ma_stream_str(&strm, p_entry->date_time);
- }
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_SENDER_NAME)
- {
- bta_ma_stream_str(&strm, "\" sender_name = \"");
- bta_ma_stream_str(&strm, p_entry->sender_name);
- }
-
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_SENDER_ADDRESSING)
- {
- bta_ma_stream_str(&strm, "\" sender_addressing = \"");
- bta_ma_stream_str(&strm, p_entry->sender_addressing);
- }
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_REPLYTO_ADDRESSING)
- {
- bta_ma_stream_str(&strm, "\" replyto_addressing = \"");
- bta_ma_stream_str(&strm, p_entry->replyto_addressing);
- }
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_RECIPIENT_NAME)
- {
- bta_ma_stream_str(&strm, "\" recipient_name = \"");
- bta_ma_stream_str(&strm, p_entry->recipient_name);
- }
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_RECIPIENT_ADDRESSING)
- {
- bta_ma_stream_str(&strm, "\" recipient_addressing = \"");
- bta_ma_stream_str(&strm, p_entry->recipient_addressing);
- }
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_TYPE)
- {
- bta_ma_stream_str(&strm, "\" type = \"");
- if (!bta_ma_stream_str(&strm, bta_ma_msg_typ_to_string(p_entry->type)))
- {
- return BTA_MA_STATUS_FAIL;
- }
- }
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_SIZE)
- {
- bta_ma_stream_str(&strm, "\" size = \"");
- bta_ma_stream_value(&strm, p_entry->org_msg_size);
- }
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_TEXT)
- {
- bta_ma_stream_str(&strm, "\" text = \"");
- bta_ma_stream_boolean_yes_no(&strm, p_entry->text);
- }
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_RECEPTION_STATUS)
- {
- bta_ma_stream_str(&strm, "\" reception_status = \"");
- if (!bta_ma_stream_str(&strm,
- bta_ma_rcv_status_to_string(p_entry->reception_status)))
- {
- return BTA_MA_STATUS_FAIL;
- }
- }
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_ATTACHMENT_SIZE)
- {
- bta_ma_stream_str(&strm, "\" attachment_size = \"");
- bta_ma_stream_value(&strm, p_entry->attachment_size);
- }
-
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_PRIORITY)
- {
- bta_ma_stream_str(&strm, "\" priority = \"");
- bta_ma_stream_boolean_yes_no(&strm, p_entry->high_priority);
- }
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_READ)
- {
- bta_ma_stream_str(&strm, "\" read = \"");
- bta_ma_stream_boolean_yes_no(&strm, p_entry->read);
- }
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_SENT)
- {
- bta_ma_stream_str(&strm, "\" sent = \"");
- bta_ma_stream_boolean_yes_no(&strm, p_entry->sent);
- }
- if (p_entry->parameter_mask & BTA_MA_ML_MASK_PROTECTED)
- {
- bta_ma_stream_str(&strm, "\" protected = \"");
- bta_ma_stream_boolean_yes_no(&strm, p_entry->is_protected);
- }
-
- /* stream msg element end tag*/
- bta_ma_stream_str(&strm, "\"/> ");
-
- /* set the output length (i.e. amount of buffer that got used) */
- *p_size = bta_ma_stream_used_size(&strm);
-
- /* return status based on the stream status */
- return(bta_ma_stream_ok(&strm)
- ? BTA_MA_STATUS_OK
- : BTA_MA_STATUS_FAIL);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_start_timer
-**
-** Description Start a wait for obx response timer
-**
-** Parameters ccb_inx - MN control block index
-** timer_id - indicating this timer is for which operation
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_mse_mn_start_timer(UINT8 ccb_idx, UINT8 timer_id)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
- UINT16 event_id;
- p_cb->rsp_timer.param = (UINT32) (ccb_idx+1);
- event_id = (UINT16) BTA_MSE_MN_RSP0_TOUT_EVT + ccb_idx;
- bta_sys_start_timer(&p_cb->rsp_timer, event_id,
- p_bta_mse_cfg->obx_rsp_tout);
-
- p_cb->timer_oper = timer_id;
-}
-/*******************************************************************************
-**
-** Function bta_mse_mn_start_stop_timer
-**
-** Description Stop a wait for obx response timer
-**
-** Parameters ccb_inx - MN control block index
-** timer_id - indicating this timer is for which operation
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_mse_mn_stop_timer(UINT8 ccb_idx, UINT8 timer_id)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-
- if ((p_cb->timer_oper == timer_id) || (timer_id == BTA_MSE_TIMER_OP_ALL))
- {
- p_cb->rsp_timer.param = 0;
- bta_sys_stop_timer(&p_cb->rsp_timer );
- p_cb->timer_oper = BTA_MSE_TIMER_OP_NONE;
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_add_inst_id
-**
-** Description Add mas_inst_id to the MN notif_reg data base
-**
-** Parameters ccb_inx - MN control block index
-** mas_inst_id - MAS instance ID
-**
-** Returns BOOLEAN - TRUE OK
-** FALSE not OK
-**
-*******************************************************************************/
-BOOLEAN bta_mse_mn_add_inst_id(UINT8 ccb_idx, tBTA_MA_INST_ID mas_inst_id)
-{
- BOOLEAN found=FALSE;
- BOOLEAN add_status=FALSE;
- UINT8 i;
- tBTA_MSE_MN_CB *p_ccb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_mn_add_inst_id ccb_idx=%d mas_inst_id=%d",
- ccb_idx, mas_inst_id);
-#endif
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if (p_ccb->notif_reg[i].status &&
- (p_ccb->notif_reg[i].mas_inst_id == mas_inst_id))
- {
- found = TRUE;
- add_status = TRUE;
- break;
- }
- }
-
- if (!found)
- {
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if (!p_ccb->notif_reg[i].status)
- {
- /* find an available entry to add */
- p_ccb->notif_reg[i].mas_inst_id = mas_inst_id;
- p_ccb->notif_reg[i].status = TRUE;
- add_status = TRUE;
- break;
- }
- }
- }
-
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("add_status=%d", add_status);
-#endif
-
- return add_status;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_remove_inst_id
-**
-** Description Remove mas_inst_id from the MN notif_reg data base
-**
-** Parameters ccb_inx - MN control block index
-** mas_inst_id - MAS instance ID
-**
-** Returns BOOLEAN - TRUE OK
-** FALSE not OK
-**
-*******************************************************************************/
-BOOLEAN bta_mse_mn_remove_inst_id(UINT8 ccb_idx, tBTA_MA_INST_ID mas_inst_id)
-{
- BOOLEAN remove_status=FALSE;
- UINT8 i;
- tBTA_MSE_MN_CB *p_ccb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_mn_remove_inst_id ccb_idx=%d mas_inst_id=%d",
- ccb_idx, mas_inst_id);
-#endif
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if (p_ccb->notif_reg[i].status &&
- (p_ccb->notif_reg[i].mas_inst_id == mas_inst_id))
- {
- p_ccb->notif_reg[i].status = FALSE;
- p_ccb->notif_reg[i].mas_inst_id =(tBTA_MA_INST_ID )0;
-
- remove_status = TRUE;
- break;
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("remove_status=%d", remove_status);
-#endif
-
- return remove_status;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_remove_all_inst_ids
-**
-** Description Remove all mas_inst_ids from the MN notif_reg data base
-**
-** Parameters ccb_inx - MN control block index
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_mse_mn_remove_all_inst_ids(UINT8 ccb_idx)
-{
- UINT8 i;
- tBTA_MSE_MN_CB *p_ccb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT1("bta_mse_mn_remove_all_inst_ids ccb_idx=%d ",
- ccb_idx);
-#endif
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if (p_ccb->notif_reg[i].status)
- {
- p_ccb->notif_reg[i].status = FALSE;
- p_ccb->notif_reg[i].mas_inst_id =(tBTA_MA_INST_ID) 0;
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_find_num_of_act_inst_id
-**
-** Description fin the number of Mas Instance IDs with registration status on
-**
-** Parameters ccb_inx - MN control block index
-**
-** Returns UINT8 - Number of active Mas Instance ID
-**
-*******************************************************************************/
-UINT8 bta_mse_mn_find_num_of_act_inst_id(UINT8 ccb_idx)
-{
- UINT8 i,cnt;
- tBTA_MSE_MN_CB *p_ccb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);;
-
- cnt =0;
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if (p_ccb->notif_reg[i].status) cnt++;
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_mn_find_num_of_act_inst_id ccb_idx=%d cnt=%d",
- ccb_idx, cnt);
-#endif
-
- return cnt;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_is_inst_id_exist
-**
-** Description Check whether the specified mas_inst_id is in the
-** MN notif_reg data base
-**
-** Parameters ccb_inx - MN control block index
-** mas_inst_id - MAS instance ID
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-**
-*******************************************************************************/
-BOOLEAN bta_mse_mn_is_inst_id_exist(UINT8 ccb_idx, tBTA_MA_INST_ID mas_inst_id )
-{
- BOOLEAN found = FALSE;
- UINT8 i;
- tBTA_MSE_MN_CB *p_ccb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);;
-
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if (p_ccb->notif_reg[i].status &&
- (p_ccb->notif_reg[i].mas_inst_id == mas_inst_id))
- {
- found = TRUE;
- break;
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT3("bta_mse_mn_is_inst_id_exist ccb_idx=%d mas_inst_id=%d found=%d",
- ccb_idx, mas_inst_id, found);
-#endif
-
- return found;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_is_ok_to_close_mn
-**
-** Description Determine is ok to close MN connection
-**
-** Parameters bd_addr - BD address
-** mas_inst_id - MAS instance ID
-**
-** Returns BOOLEAN - TRUE OK
-** FALSE not OK
-**
-*******************************************************************************/
-BOOLEAN bta_mse_mn_is_ok_to_close_mn(BD_ADDR bd_addr, tBTA_MA_INST_ID mas_inst_id )
-{
- UINT8 ccb_idx;
- BOOLEAN ok_status= FALSE;
-
-
- if (bta_mse_find_bd_addr_match_mn_cb_index(bd_addr, &ccb_idx) &&
- (bta_mse_mn_find_num_of_act_inst_id(ccb_idx) == 1) &&
- (bta_mse_mn_is_inst_id_exist(ccb_idx, mas_inst_id)))
- {
- ok_status = TRUE;
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_mn_is_ok_to_close_mn mas_inst_id=%d ok_status=%d",
- mas_inst_id, ok_status);
-#endif
-
- return ok_status;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_get_first_inst_id
-**
-** Description Get the first active mas_inst_id from the MN notif_reg data base
-**
-** Parameters ccb_inx - MN control block index
-** mas_inst_id - MAS instance ID
-**
-** Returns BOOLEAN - TRUE OK
-** FALSE not OK
-**
-*******************************************************************************/
-BOOLEAN bta_mse_mn_get_first_inst_id(UINT8 ccb_idx, tBTA_MA_INST_ID *p_mas_inst_id)
-{
- BOOLEAN found=FALSE;
- UINT8 i;
- tBTA_MSE_MN_CB *p_ccb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-
-
- for (i=0; i < BTA_MSE_NUM_INST ; i ++)
- {
- if (p_ccb->notif_reg[i].status )
- {
- *p_mas_inst_id = p_ccb->notif_reg[i].mas_inst_id;
-
- found = TRUE;
- break;
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT3("bta_mse_mn_get_inst_id ccb_idx=%d found status =%d mas_inst_id=%d",
- ccb_idx, found, *p_mas_inst_id);
-#endif
-
- return found;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_send_abort_req
-**
-** Description Send an abort request.
-**
-** Parameters ccb_inx - MN control block index
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_send_abort_req(UINT8 ccb_idx)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-
- if (BTA_MSE_MN_ABORT_REQ_NOT_SENT == p_cb->aborting)
- {
- bta_mse_mn_start_timer(ccb_idx, BTA_MSE_TIMER_OP_ABORT);
- OBX_AbortReq(p_cb->obx_handle, (BT_HDR *)NULL);
- p_cb->aborting = BTA_MSE_MN_ABORT_REQ_SENT;
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_cont_send_notif
-**
-** Description Continues the send notification operation. Builds a new OBX packet
-**
-** Parameters ccb_idx - MN control block index
-** first_pkt - first obex packet indicator
-**
-** Returns tBTA_MA_STATUS : BTA_MA_STATUS_OK if msg notification sent is ok
-** otherwise BTA_MA_STATUS_FAIL
-*******************************************************************************/
-tBTA_MA_STATUS bta_mse_mn_cont_send_notif(UINT8 ccb_idx, BOOLEAN first_pkt)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
- tBTA_MSE_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_MSE_MN_MSG_NOTIF *p_msg_notif = &p_cb->msg_notif;
- tOBX_TRIPLET app_param[1];
- UINT16 body_len;
- BOOLEAN final_pkt = FALSE;
- tBTA_MA_STATUS status = BTA_MA_STATUS_OK;
-
- /* Do not start another request if currently aborting */
- if (p_cb->aborting)
- {
- bta_mse_mn_send_abort_req(ccb_idx);
- return status;
- }
-
- if ((p_obx->p_pkt = OBX_HdrInit(p_cb->obx_handle, p_cb->peer_mtu)) != NULL)
- {
- if (first_pkt)
- {
- OBX_AddTypeHdr(p_obx->p_pkt, BTA_MA_HDR_TYPE_EVENT_RPT);
-
- app_param[0].tag = BTA_MA_NAS_INST_ID_TAG_ID;
- app_param[0].len = BTA_MA_NAS_INST_ID_LEN;
- app_param[0].p_array = &(p_msg_notif->mas_instance_id);
- OBX_AddAppParamHdr(p_obx->p_pkt, app_param, 1);
- }
- else
- {
- p_obx->offset =
- p_obx->bytes_left = 0; /* 0 -length available */
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
-
- body_len = p_obx->bytes_left;
- final_pkt = ( (p_msg_notif->buffer_len - p_msg_notif->bytes_sent) < body_len) ?
- TRUE : FALSE ;
- if (final_pkt) body_len = (p_msg_notif->buffer_len - p_msg_notif->bytes_sent);
-
- memcpy(&p_obx->p_start[p_obx->offset],
- &(p_msg_notif->p_buffer[p_msg_notif->bytes_sent]), body_len);
- p_msg_notif->bytes_sent += body_len;
- p_obx->offset += body_len;
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, TRUE);
- }
-
- OBX_PutReq(p_cb->obx_handle, final_pkt , p_obx->p_pkt);
- p_obx->p_pkt = NULL;
- p_cb->req_pending = TRUE;
- bta_mse_set_mn_oper(ccb_idx, BTA_MSE_MN_OP_PUT_EVT_RPT);
- p_msg_notif->final_pkt = final_pkt;
- p_msg_notif->pkt_cnt++;
- }
- else
- {
- status = BTA_MA_STATUS_FAIL;
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT4("bta_mse_mn_cont_send_notif ccb_idx=%d first_pkt=%d send_status=%d final=%d",
- ccb_idx, first_pkt, status, final_pkt);
-#endif
-
- return status;
-}
-/*******************************************************************************
-**
-** Function bta_mse_mn_send_notif_evt
-**
-** Description Issue a send notification event
-**
-** Parameters mas_instance_id - MAS instance ID
-** status - MS sttaus
-** bd_addr - BD address
-**
-**
-** Returns UINT8 OBX response code
-**
-*******************************************************************************/
-void bta_mse_mn_send_notif_evt(tBTA_MA_INST_ID mas_instance_id, tBTA_MA_STATUS status,
- BD_ADDR bd_addr )
-{
- tBTA_MSE param;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_mn_send_notif_evt mas_instance_id=%d status=%d",
- mas_instance_id,
- status);
-#endif
-
- param.send_notif.mas_instance_id = mas_instance_id;
- param.send_notif.status = status;
- bdcpy(param.send_notif.bd_addr, bd_addr);
- bta_mse_cb.p_cback(BTA_MSE_SEND_NOTIF_EVT, &param);
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_mn_clean_send_notif
-**
-** Description Clean up send notif resources and cotrol block
-**
-** Parameters ccb_idx - MN control block index
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_mn_clean_send_notif(UINT8 ccb_idx)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("bta_mse_mn_clean_send_notif");
-#endif
-
- utl_freebuf((void**)&(p_cb->msg_notif.p_buffer));
- bta_mse_set_mn_oper(ccb_idx, BTA_MSE_MN_OP_NONE);
- p_cb->req_pending = FALSE;
- p_cb->aborting = BTA_MSE_MN_ABORT_NONE;
- memset(&(p_cb->msg_notif), 0, sizeof(tBTA_MSE_MN_MSG_NOTIF));
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_fl_read_app_params
-**
-** Description Read application parameters for the get folder list requst
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_pkt - Pointer to the obex packet
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_mse_ma_fl_read_app_params(UINT8 inst_idx, UINT8 sess_idx, BT_HDR *p_pkt)
-
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- UINT8 *p_param;
- UINT16 len;
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_MAX_LIST_COUNT, &len);
-
- if (p_param)
- {
- BE_STREAM_TO_UINT16(p_cb->fl_param.max_list_cnt, p_param);
- }
- else
- p_cb->fl_param.max_list_cnt = BTA_MA_DEFAULT_MAX_LIST_CNT;
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_START_STOFF, &len);
-
- if (p_param)
- {
- BE_STREAM_TO_UINT16(p_cb->fl_param.start_offset, p_param);
- }
- else
- p_cb->fl_param.start_offset = 0;
-
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_ml_read_app_params
-**
-** Description Read application parameters for the get message list requst
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_pkt - Pointer to the obex packet
-**
-** Returns void
-**
-*******************************************************************************/
-
-void bta_mse_ma_ml_read_app_params(UINT8 inst_idx, UINT8 sess_idx, BT_HDR *p_pkt)
-
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- UINT8 *p_param;
- UINT16 len;
-
- memset(&(p_cb->ml_param.filter), 0x00, sizeof(tBTA_MA_MSG_LIST_FILTER_PARAM));
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_MAX_LIST_COUNT, &len);
- if (p_param)
- {
- BE_STREAM_TO_UINT16(p_cb->ml_param.filter.max_list_cnt, p_param);
- }
- else
- {
- p_cb->ml_param.filter.max_list_cnt = BTA_MA_DEFAULT_MAX_LIST_CNT;
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_START_STOFF, &len);
- if (p_param)
- {
- BE_STREAM_TO_UINT16(p_cb->ml_param.filter.list_start_offset, p_param);
- }
- else
- {
- p_cb->ml_param.filter.list_start_offset = 0;
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_SUBJ_LEN, &len);
- if (p_param)
- {
- BE_STREAM_TO_UINT8(p_cb->ml_param.filter.subject_length, p_param);
- }
- else
- {
- p_cb->ml_param.filter.subject_length = 0xff;
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_PARAM_MASK, &len);
- if (p_param)
- {
- BE_STREAM_TO_UINT32(p_cb->ml_param.filter.parameter_mask, p_param);
- }
- else
- {
- p_cb->ml_param.filter.parameter_mask = 0;
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_FILTER_MSG_TYPE, &len);
- if (p_param)
- {
- BE_STREAM_TO_UINT8(p_cb->ml_param.filter.msg_mask, p_param);
- }
- else
- {
- p_cb->ml_param.filter.msg_mask = 0;
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_FILTER_PRD_BEGIN, &len);
-
- if (p_param)
- {
- p_cb->ml_param.filter.period_begin[BTA_MA_LTIME_LEN]='\0';
- if (len < BTA_MA_LTIME_LEN)
- {
- p_cb->ml_param.filter.period_begin[0] = '\0';
- }
- else
- {
- BCM_STRNCPY_S((char *)p_cb->ml_param.filter.period_begin, sizeof(p_cb->ml_param.filter.period_begin),
- (const char *)p_param, BTA_MA_LTIME_LEN);
- }
- }
- else
- {
- p_cb->ml_param.filter.period_begin[0] = '\0';
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_FILTER_PRD_END, &len);
- if (p_param)
- {
- p_cb->ml_param.filter.period_end[BTA_MA_LTIME_LEN] = '\0';
- if (len < BTA_MA_LTIME_LEN)
- {
- p_cb->ml_param.filter.period_end[0] = '\0';
- }
- else
- {
- BCM_STRNCPY_S((char *)p_cb->ml_param.filter.period_end, sizeof(p_cb->ml_param.filter.period_end),
- (const char *)p_param, BTA_MA_LTIME_LEN);
- }
- }
- else
- {
- p_cb->ml_param.filter.period_end[0] = '\0';
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_FILTER_READ_STS, &len);
- if (p_param)
- {
- BE_STREAM_TO_UINT8(p_cb->ml_param.filter.read_status, p_param);
- }
- else
- {
- p_cb->ml_param.filter.read_status = 0;
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_FILTER_RECEIP, &len);
- p_cb->ml_param.filter.recipient[0] = '\0';
- if (p_param && len)
- {
- if (len >= BTA_MA_MAX_FILTER_TEXT_SIZE)
- {
- p_cb->ml_param.filter.recipient[BTA_MA_MAX_FILTER_TEXT_SIZE] = '\0';
- len = BTA_MA_MAX_FILTER_TEXT_SIZE;
- }
- BCM_STRNCPY_S((char *)p_cb->ml_param.filter.recipient, sizeof(p_cb->ml_param.filter.recipient),
- (const char *)p_param, len);
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_FILTER_ORIGIN, &len);
- p_cb->ml_param.filter.originator[0] = '\0';
- if (p_param && len)
- {
- if (len >= BTA_MA_MAX_FILTER_TEXT_SIZE)
- {
- p_cb->ml_param.filter.originator[BTA_MA_MAX_FILTER_TEXT_SIZE] = '\0';
- len = BTA_MA_MAX_FILTER_TEXT_SIZE;
- }
- BCM_STRNCPY_S((char *)p_cb->ml_param.filter.originator, sizeof(p_cb->ml_param.filter.originator),
- (const char *)p_param, len);
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_FILTER_PRIORITY, &len);
- if (p_param)
- {
- BE_STREAM_TO_UINT8(p_cb->ml_param.filter.pri_status, p_param);
- }
- else
- {
- p_cb->ml_param.filter.pri_status = 0;
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_ma_msg_read_app_params
-**
-** Description Read application parameters for the get message list requst
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_pkt - Pointer to the obex packet
-**
-** Returns BOOLEAN TRUE - operation is successful
-**
-*******************************************************************************/
-
-BOOLEAN bta_mse_ma_msg_read_app_params(UINT8 inst_idx, UINT8 sess_idx, BT_HDR *p_pkt)
-
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- UINT8 *p_param;
- UINT16 len;
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_CHARSET, &len);
- if (p_param)
- {
- BE_STREAM_TO_UINT8(p_cb->msg_param.data.charset, p_param);
- }
- else
- {
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT0("Unable to decode or find charset in application parameter ");
-#endif
- return FALSE;
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_ATTACH, &len);
- if (p_param)
- {
- BE_STREAM_TO_UINT8(p_cb->msg_param.data.attachment, p_param);
- }
- else
- {
- p_cb->msg_param.data.attachment = FALSE;
- }
-
- p_param = bta_mse_read_app_params(p_pkt, BTA_MA_APH_FRAC_REQ, &len);
- if (p_param)
- {
- BE_STREAM_TO_UINT8(p_cb->msg_param.data.fraction_request, p_param);
- }
- else
- {
- p_cb->msg_param.data.fraction_request = BTA_MA_FRAC_REQ_NO;
- }
-
-
- return TRUE;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_get_msglist_path
-**
-** Description Get the path based on received folder name for the get
-** message list
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** p_path - (output) pointer to the folder path
-**
-** Returns BOOLEAN TRUE-get path is successful
-*******************************************************************************/
-BOOLEAN bta_mse_get_msglist_path(UINT8 inst_idx, UINT8 sess_idx)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- char *p_name = p_cb->ml_param.p_name;
- char *p_path = p_cb->ml_param.p_path;
- char *p_workdir = p_cb->p_workdir;
- BOOLEAN status = TRUE;
-#if BTA_MSE_ENABLE_FS_CO == TRUE
- BOOLEAN is_dir;
-#endif
-
-
- if (*p_name == '\0')
- {
- BCM_STRNCPY_S(p_path, p_bta_fs_cfg->max_path_len+1, p_workdir, p_bta_fs_cfg->max_path_len);
- }
- /* Make sure the new path is not too big */
- /* +1 is for the separator */
- else if ((strlen(p_workdir)+1+strlen(p_name)) <= p_bta_fs_cfg->max_path_len)
- {
- /* create a temporary path for creation attempt */
- sprintf(p_path, "%s%c%s", p_workdir,
- p_bta_fs_cfg->path_separator, p_name);
-#if BTA_MSE_ENABLE_FS_CO == TRUE
- if (((bta_fs_co_access(p_path, BTA_FS_ACC_EXIST,
- &is_dir, bta_mse_cb.app_id)) != BTA_FS_CO_OK) || !is_dir)
- {
- status = FALSE;
- }
-#endif
- }
- else
- {
- status = FALSE;
- }
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_EVENT2("bta_mse_get_msglist_path status=%d pth=%s",status, p_path );
-#endif
-
- return status;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_find_bd_addr_match_pm_cb_index
-**
-** Description Finds the PM control block index
-** based on the specified BD address
-**
-** Parameters app_id - app_id
-** p_bd_addr - BD address
-** p_idx - (output) pointer to the MN control
-** block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-BOOLEAN bta_mse_find_pm_cb_index(BD_ADDR p_bd_addr, UINT8 *p_idx)
-{
- BOOLEAN found=FALSE;
- UINT8 i;
-
- for (i=0; i < BTA_MSE_NUM_MN ; i ++)
- {
- if ((bta_mse_cb.pcb[i].in_use) &&
- (!memcmp (bta_mse_cb.pcb[i].bd_addr, p_bd_addr, BD_ADDR_LEN)))
- {
- found = TRUE;
- *p_idx = i;
- break;
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- if (!found) APPL_TRACE_DEBUG2("dbg bta_mse_find_pm_cb_index found=%d index=%d", found, i);
-#endif
- return found;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_find_avail_pm_cb_idx
-**
-** Description Finds a not in use PM control block index
-**
-** Parameters p_idx - (output) pointer to the PM control block index
-**
-** Returns BOOLEAN - TRUE found
-** FALSE not found
-**
-*******************************************************************************/
-BOOLEAN bta_mse_find_avail_pm_cb_idx(UINT8 *p_idx)
-{
- BOOLEAN found=FALSE;
- UINT8 i;
-
- for (i=0; i < BTA_MSE_NUM_MN ; i ++)
- {
- if (!bta_mse_cb.pcb[i].in_use)
- {
- found = TRUE;
- *p_idx = i;
- break;
- }
- }
-
-#if BTA_MSE_DEBUG == TRUE
- if (!found) APPL_TRACE_DEBUG2("bta_mse_find_avail_pm_cb_idx found=%d i=%d", found, i);
-#endif
-
- return found;
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_pm_conn_open
-**
-** Description Determine whether or not bta_sys_conn_open should be called
-**
-** Parameters bd_addr - peer BD address
-**
-** Returns None
-**
-*******************************************************************************/
-void bta_mse_pm_conn_open(BD_ADDR bd_addr)
-{
- tBTA_MSE_PM_CB *p_pcb;
- UINT8 idx;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_DEBUG0("bta_mse_pm_conn_open");
-#endif
- if (!bta_mse_find_pm_cb_index(bd_addr, &idx))
- {
- if (bta_mse_find_avail_pm_cb_idx(&idx))
- {
- p_pcb = BTA_MSE_GET_PM_CB_PTR(idx);
-
- p_pcb->in_use = TRUE;
- p_pcb->opened = TRUE;
- bdcpy(p_pcb->bd_addr, bd_addr);
- bta_sys_conn_open(BTA_ID_MSE , bta_mse_cb.app_id, bd_addr);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_pm_conn_close
-**
-** Description Determine whether or not bta_sys_conn_close should be called
-**
-** Parameters bd_addr - peer BD address
-**
-** Returns None
-*******************************************************************************/
-void bta_mse_pm_conn_close(BD_ADDR bd_addr)
-{
- tBTA_MSE_PM_CB *p_pcb;
- UINT8 i, pm_idx, sess_idx, mn_idx;
- BOOLEAN found_bd_addr=FALSE;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_DEBUG0("bta_mse_pm_conn_close");
-#endif
- if (bta_mse_find_pm_cb_index(bd_addr, &pm_idx))
- {
- p_pcb = BTA_MSE_GET_PM_CB_PTR(pm_idx);
- if (p_pcb->opened)
- {
- for (i=0; i<BTA_MSE_NUM_INST; i++)
- {
- if (bta_mse_find_bd_addr_match_sess_cb_idx(bd_addr, i, &sess_idx))
- {
- found_bd_addr = TRUE;
- break;
- }
- }
-
- if (!found_bd_addr)
- {
- if ( bta_mse_find_bd_addr_match_mn_cb_index(bd_addr, &mn_idx))
- {
- found_bd_addr = TRUE;
-
- }
- }
-
- if (!found_bd_addr)
- {
- memset(p_pcb, 0, sizeof(tBTA_MSE_PM_CB));
- bta_sys_conn_close(BTA_ID_MSE , bta_mse_cb.app_id, bd_addr);
- }
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_mse_set_ma_oper
-**
-** Description Set MA operation and power management's busy/idle status based on
-** MA operation
-**
-** Parameters inst_idx - Index to the MA instance control block
-** sess_idx - Index to the MA session control block
-** oper - MA operation
-**
-** Returns None
-*******************************************************************************/
-void bta_mse_set_ma_oper(UINT8 inst_idx, UINT8 sess_idx, tBTA_MSE_OPER oper)
-{
- tBTA_MSE_MA_SESS_CB *p_cb = BTA_MSE_GET_SESS_CB_PTR(inst_idx, sess_idx);
- tBTA_MSE_MA_SESS_CB *p_scb;
- tBTA_MSE_MN_CB *p_mcb;
- tBTA_MSE_PM_CB *p_pcb;
- UINT8 i, j, pm_idx, mn_idx;
- BOOLEAN still_busy = FALSE;
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_DEBUG2("bta_mse_set_ma_oper old=%d new=%d", p_cb->oper, oper);
-#endif
-
- if (p_cb->oper != oper)
- {
- p_cb->oper = oper;
- if (bta_mse_find_pm_cb_index(p_cb->bd_addr, &pm_idx))
- {
- p_pcb = BTA_MSE_GET_PM_CB_PTR(pm_idx);
-
- if (oper != BTA_MSE_OPER_NONE )
- {
- if (!p_pcb->busy)
- {
- p_pcb->busy = TRUE;
- bta_sys_busy(BTA_ID_MSE, bta_mse_cb.app_id, p_cb->bd_addr);
- }
- }
- else
- {
- if (p_pcb->busy)
- {
- for (i=0; i<BTA_MSE_NUM_INST; i++)
- {
- if (bta_mse_find_bd_addr_match_sess_cb_idx( p_cb->bd_addr, i, &j) &&
- (i != inst_idx) && (j != sess_idx))
- {
- p_scb = BTA_MSE_GET_SESS_CB_PTR(i, j);
- if (p_scb->oper != BTA_MSE_OPER_NONE )
- {
- still_busy = TRUE;
- break;
- }
- }
- }
-
- if ((!still_busy) &&
- bta_mse_find_bd_addr_match_mn_cb_index( p_cb->bd_addr, &mn_idx))
- {
- p_mcb = BTA_MSE_GET_MN_CB_PTR(mn_idx);
- if (p_mcb->obx_oper != BTA_MSE_MN_OP_NONE )
- {
- still_busy = TRUE;
- }
- }
-
- if (!still_busy)
- {
- p_pcb->busy = FALSE;
- bta_sys_idle(BTA_ID_MSE, bta_mse_cb.app_id, p_cb->bd_addr);
- }
- }
- }
- }
- }
-}
-
-
-/*******************************************************************************
-**
-** Function bta_mse_set_mn_oper
-**
-** Description Set MN operation and power management's busy/idle status based on
-** MN operation
-**
-** Parameters ccb_idx - MN control block index
-** oper - MN operation
-**
-** Returns None
-*******************************************************************************/
-void bta_mse_set_mn_oper(UINT8 ccb_idx, UINT8 oper)
-{
- tBTA_MSE_MN_CB *p_cb = BTA_MSE_GET_MN_CB_PTR(ccb_idx);
- tBTA_MSE_MA_SESS_CB *p_scb;
- tBTA_MSE_MN_CB *p_mcb;
- tBTA_MSE_PM_CB *p_pcb;
- UINT8 i, j, pm_idx, mn_idx;
- BOOLEAN still_busy = FALSE;
-
-#if BTA_MSE_DEBUG == TRUE
- APPL_TRACE_DEBUG2("dbg bta_mse_set_mn_oper old=%d new=%d", p_cb->obx_oper, oper);
-#endif
- if (p_cb->obx_oper != oper)
- {
- p_cb->obx_oper = oper;
- if (bta_mse_find_pm_cb_index(p_cb->bd_addr, &pm_idx))
- {
- p_pcb = BTA_MSE_GET_PM_CB_PTR(pm_idx);
-
- if (oper != BTA_MSE_MN_OP_NONE )
- {
- if (!p_pcb->busy)
- {
- p_pcb->busy = TRUE;
- bta_sys_busy(BTA_ID_MSE, bta_mse_cb.app_id, p_cb->bd_addr);
- }
- }
- else
- {
- if (p_pcb->busy)
- {
- for (i=0; i<BTA_MSE_NUM_INST; i++)
- {
- if (bta_mse_find_bd_addr_match_sess_cb_idx( p_cb->bd_addr, i, &j))
- {
- p_scb = BTA_MSE_GET_SESS_CB_PTR(i, j);
- if (p_scb->oper != BTA_MSE_OPER_NONE )
- {
- still_busy = TRUE;
- break;
- }
- }
- }
-
- if ((!still_busy) &&
- bta_mse_find_bd_addr_match_mn_cb_index(p_cb->bd_addr, &mn_idx) &&
- (mn_idx != ccb_idx))
- {
- p_mcb = BTA_MSE_GET_MN_CB_PTR(mn_idx);
- if (p_mcb->obx_oper != BTA_MSE_MN_OP_NONE )
- {
- still_busy = TRUE;
- }
- }
-
- if (!still_busy)
- {
- p_pcb->busy = FALSE;
- bta_sys_idle(BTA_ID_MSE, bta_mse_cb.app_id, p_cb->bd_addr);
- }
- }
- }
- }
- }
-
-}
-
-#endif /* BTA_MSE_INCLUDED */
diff --git a/bta/op/bta_op_fmt.c b/bta/op/bta_op_fmt.c
deleted file mode 100644
index 000370a..0000000
--- a/bta/op/bta_op_fmt.c
+++ /dev/null
@@ -1,804 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_op_fmt.c
-**
-** Description: This file contains common functions and data structures
-** used by the OPP object formatting functions.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <string.h>
-#include <ctype.h>
-#include "bta_op_api.h"
-#include "bta_op_fmt.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-#define BTA_OP_ENCODING_LEN 9
-#define BTA_OP_CHARSET_LEN 8
-#define BTA_OP_PARAM_TYPE_HDR_LEN 5
-#define BTA_OP_NUM_NONINLINE_MEDIA 2
-
-const char bta_op_encoding[] = "ENCODING=";
-
-const tBTA_OP_PARAM bta_op_encodings[] =
-{/* the len is (BTA_OP_ENCODING_LEN + 1 + strlen(p_name)) */
- {NULL, 0},
- {"QUOTED-PRINTABLE", 26}, /* BTA_OP_ENC_QUOTED_PRINTABLE */
- {"8BIT", 14}, /* BTA_OP_ENC_8BIT */
- {"b", 11}, /* BTA_OP_ENC_BINARY */
-// btla-specific ++
- {"BASE64", 16} /* BTA_OP_ENC_BASE64 */
-// btla-specific --
-};
-
-#define BTA_OP_NUM_ENCODINGS 3
-#define BTA_OP_QP_IDX 1 /* array index for quoted printable in bta_op_encodings */
-
-const char bta_op_charset[] = "CHARSET=";
-
-const char bta_op_param_type_hdr[] = "TYPE=";
-
-const tBTA_OP_PARAM bta_op_charsets[] =
-{/* the len is (BTA_OP_CHARSET_LEN + 1 + strlen(p_name)) */
- {NULL, 0},
- {"BIG5", 13}, /* BTA_OP_CHAR_BIG5 */
- {"EUC-JP", 15}, /* BTA_OP_CHAR_EUC_JP */
- {"EUC-KR", 15}, /* BTA_OP_CHAR_EUC_KR */
- {"GB2312", 15}, /* BTA_OP_CHAR_GB2312 */
- {"ISO-2022-JP", 20}, /* BTA_OP_CHAR_ISO_2022_JP */
- {"ISO-8859-1", 19}, /* BTA_OP_CHAR_ISO_8859_1 */
- {"ISO-8859-2", 19}, /* BTA_OP_CHAR_ISO_8859_2 */
- {"ISO-8859-3", 19}, /* BTA_OP_CHAR_ISO_8859_3 */
- {"ISO-8859-4", 19}, /* BTA_OP_CHAR_ISO_8859_4 */
- {"ISO-8859-5", 19}, /* BTA_OP_CHAR_ISO_8859_5 */
- {"ISO-8859-6", 19}, /* BTA_OP_CHAR_ISO_8859_6 */
- {"ISO-8859-7", 19}, /* BTA_OP_CHAR_ISO_8859_7 */
- {"ISO-8859-8", 19}, /* BTA_OP_CHAR_ISO_8859_8 */
- {"KOI8-R", 15}, /* BTA_OP_CHAR_KOI8_R */
- {"SHIFT_JIS", 18}, /* BTA_OP_CHAR_SHIFT_JIS */
- {"UTF-8", 14} /* BTA_OP_CHAR_UTF_8 */
-};
-
-#define BTA_OP_NUM_CHARSETS 16
-
-/* Structure of the 32-bit parameters mask:
-** (same comment is in bta_op_api.h)
-** + property-specific
-** +reserved | + character set
-** | | | + encoding
-** | | | |
-** 0000000000000000 00000000 00000 000
-*/
-#define BTA_OP_GET_PARAM(param, encod, charset, specific) \
- encod = (UINT8) (param) & 0x00000007; \
- charset = (UINT8) ((param) >> 3) & 0x0000001F; \
- specific = (UINT8) ((param) >> 8) & 0x000000FF;
-
-/* mask for properties default 0, filter all */
-static UINT32 bta_op_prop_filter_mask = 0;
-
-const tBTA_OP_PROP_MEDIA bta_op_media[] =
-{
- {NULL, 2},
- {"PHOTO", 5},
- {"SOUND", 5}
-};
-
-/* Place holder constant for safe string functions since there's no way to know how
-** memory is remaining for input parameter to build property.
-** Note: The BCM_STRCPY_S functions should be changed to know how much memory
-** is remaining. When completed this constant can be removed. Also, if safe
-** string functions are not used then this parameter is ignored anyway!
-*/
-#ifndef BTA_OP_REM_MEMORY
-#define BTA_OP_REM_MEMORY 8228
-#endif
-
-/*******************************************************************************
-**
-** Function bta_op_strnicmp
-**
-** Description Case insensitive strncmp.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-INT16 bta_op_strnicmp(const char *pStr1, const char *pStr2, size_t Count)
-{
- char c1, c2;
- INT16 v;
-
- if (Count == 0)
- return 0;
-
- do {
- c1 = *pStr1++;
- c2 = *pStr2++;
- /* the casts are necessary when pStr1 is shorter & char is signed */
- v = (UINT16) tolower(c1) - (UINT16) tolower(c2);
- } while ((v == 0) && (c1 != '\0') && (--Count > 0));
-
- return v;
-}
-
-/*******************************************************************************
-**
-** Function bta_op_set_prop_mask
-**
-** Description Set property mask
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_op_set_prop_filter_mask(UINT32 mask)
-{
- bta_op_prop_filter_mask = mask;
- return;
-}
-
-/*******************************************************************************
-**
-** Function bta_op_prop_len
-**
-** Description Calculate the length of a property string through lookup
-** tables.
-**
-**
-** Returns Length of string in bytes.
-**
-*******************************************************************************/
-UINT16 bta_op_prop_len(const tBTA_OP_PROP_TBL *p_tbl, tBTA_OP_PROP *p_prop)
-{
- UINT8 i_e, i_c, i_s;
- UINT8 len_s = 0;
- int i;
-
- /* parse parameters mask */
- BTA_OP_GET_PARAM(p_prop->parameters, i_e, i_c, i_s);
-
- /* calculate length of property-specific parameters, if any */
- if (p_tbl[p_prop->name].p_param_tbl != NULL)
- {
- for (i = 1; (i_s != 0) && (i <= p_tbl[p_prop->name].p_param_tbl[0].len); i++)
- {
- if (i_s & 1)
- {
- len_s += p_tbl[p_prop->name].p_param_tbl[i].len;
- }
- i_s >>= 1;
- }
- }
-
- return (p_tbl[p_prop->name].len + len_s + bta_op_charsets[i_c].len +
- bta_op_encodings[i_e].len + p_prop->len);
-}
-
-/*******************************************************************************
-**
-** Function bta_op_param_conflict
-**
-** Description Check if the parameters of the property for the format
-** conflict/not allowed.
-**
-**
-** Returns TRUE if not allowed, else FALSE
-**
-*******************************************************************************/
-BOOLEAN bta_op_param_conflict(tBTA_OP_SUP_FMT fmt, tBTA_OP_PROP *p_prop)
-{
- UINT8 i_e, i_c, i_s;
- BOOLEAN conflict = FALSE;
-
- if (p_prop->parameters != 0)
- {
- BTA_OP_GET_PARAM(p_prop->parameters, i_e, i_c, i_s);
-
- if (fmt == BTA_OP_FMT_VCARD30)
- {
- /* VCard 3.0 does not support CHARSET. If it is present, we
- should ignore the whole property in the vCard build process */
- if (bta_op_charsets[i_c].p_name != NULL)
- conflict = TRUE;
-
- /* VCard 3.0 only supports 'b' encoding. If any other encoding
- ex. quoted-printable, is present, then whole property is ignored */
- if ((bta_op_encodings[i_e].p_name != NULL) && strcmp(bta_op_encodings[i_e].p_name, "b"))
- conflict = TRUE;
- }
- }
-
- return conflict;
-}
-/*******************************************************************************
-**
-** Function bta_op_add_param
-**
-** Description Add parameter strings to a property string.
-**
-**
-** Returns Pointer to the next byte after the end of the string.
-**
-*******************************************************************************/
-UINT8 *bta_op_add_param(tBTA_OP_SUP_FMT fmt, const tBTA_OP_PROP_TBL *p_tbl, UINT8 *p, tBTA_OP_PROP *p_prop)
-{
- UINT8 i_e, i_c, i_s;
- int i;
- UINT8 bta_op_param_type_delimit = 0;
-
- if (p_prop->parameters != 0)
- {
- BTA_OP_GET_PARAM(p_prop->parameters, i_e, i_c, i_s);
-
- /* add encoding parameter */
- if (bta_op_encodings[i_e].p_name != NULL)
- {
- *p++ = ';';
- BCM_STRCPY_S((char *) p, BTA_OP_REM_MEMORY, bta_op_encoding);
- p += BTA_OP_ENCODING_LEN;
- BCM_STRCPY_S((char *) p, BTA_OP_REM_MEMORY, bta_op_encodings[i_e].p_name);
- p += bta_op_encodings[i_e].len - BTA_OP_ENCODING_LEN - 1;
- }
-
- /* add character set parameter */
- if (bta_op_charsets[i_c].p_name != NULL)
- {
- *p++ = ';';
- BCM_STRCPY_S((char *) p, BTA_OP_REM_MEMORY, bta_op_charset);
- p += BTA_OP_CHARSET_LEN;
- BCM_STRCPY_S((char *) p, BTA_OP_REM_MEMORY, bta_op_charsets[i_c].p_name);
- p += bta_op_charsets[i_c].len - BTA_OP_CHARSET_LEN - 1;
- }
-
- /* add any property-specific parameters */
- if (p_tbl[p_prop->name].p_param_tbl != NULL)
- {
- for (i = 1; (i_s != 0) && (i <= p_tbl[p_prop->name].p_param_tbl[0].len); i++)
- {
- if (i_s & 1)
- {
- if (bta_op_param_type_delimit)
- {
- *p++ = ',';
- }
- else
- {
- *p++ = ';';
-
- if (fmt == BTA_OP_FMT_VCARD30)
- {
- BCM_STRNCPY_S((char *) p, BTA_OP_PARAM_TYPE_HDR_LEN+1, bta_op_param_type_hdr, BTA_OP_PARAM_TYPE_HDR_LEN);
- p += BTA_OP_PARAM_TYPE_HDR_LEN;
- bta_op_param_type_delimit++;
- }
- }
- BCM_STRCPY_S((char *) p, BTA_OP_REM_MEMORY, p_tbl[p_prop->name].p_param_tbl[i].p_name);
- p += p_tbl[p_prop->name].p_param_tbl[i].len - 1;
- }
- i_s >>= 1;
- }
- }
- }
- else if (p_prop->p_param)
- {
- *p++ = ';';
- memcpy((char *) p, p_prop->p_param, p_prop->param_len);
- p += p_prop->param_len;
- }
-
- return p;
-}
-
-/*******************************************************************************
-**
-** Function bta_op_add_media_param
-**
-** Description Add parameter strings to a media property string.
-**
-**
-** Returns Pointer to the next byte after the end of the string.
-**
-*******************************************************************************/
-UINT8 *bta_op_add_media_param(const tBTA_OP_PROP_TBL *p_tbl, UINT8 *p, tBTA_OP_PROP *p_prop)
-{
- UINT8 i_e, i_c, i_s;
- int i;
-
- if (p_prop->parameters != 0)
- {
- BTA_OP_GET_PARAM(p_prop->parameters, i_e, i_c, i_s);
-
- /* add encoding parameter */
- if (bta_op_encodings[i_e].p_name != NULL)
- {
- *p++ = ';';
- BCM_STRCPY_S((char *) p, BTA_OP_REM_MEMORY, bta_op_encoding);
- p += BTA_OP_ENCODING_LEN;
- BCM_STRCPY_S((char *) p, BTA_OP_REM_MEMORY, bta_op_encodings[i_e].p_name);
- p += bta_op_encodings[i_e].len - BTA_OP_ENCODING_LEN - 1;
- }
-
- /* add any property-specific parameters */
- if (p_tbl[p_prop->name].p_param_tbl != NULL)
- {
- for (i = 1; (i_s != 0) && (i <= p_tbl[p_prop->name].p_param_tbl[0].len); i++)
- {
- if (i_s & 1)
- {
- *p++ = ';';
-
- /* Add "TYPE=" to non-referenced (inline) media */
- if (i > BTA_OP_NUM_NONINLINE_MEDIA)
- {
- BCM_STRNCPY_S((char *) p, BTA_OP_PARAM_TYPE_HDR_LEN+1, bta_op_param_type_hdr, BTA_OP_PARAM_TYPE_HDR_LEN);
- p += BTA_OP_PARAM_TYPE_HDR_LEN;
- }
-
- BCM_STRCPY_S((char *) p, BTA_OP_REM_MEMORY, p_tbl[p_prop->name].p_param_tbl[i].p_name);
- p += p_tbl[p_prop->name].p_param_tbl[i].len - 1;
- break;
- }
- i_s >>= 1;
- }
- }
- }
- else if (p_prop->p_param)
- {
- *p++ = ';';
- memcpy((char *) p, p_prop->p_param, p_prop->param_len);
- p += p_prop->param_len;
- }
-
- return p;
-}
-
-/*******************************************************************************
-**
-** Function bta_op_get_property_by_name
-**
-** Description Get the property user data by name.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if there is no property user data.
-**
-*******************************************************************************/
-tBTA_OP_STATUS bta_op_get_property_by_name(const tBTA_OP_PROP_TBL *p_tbl, UINT8 *p_name,
- tBTA_OP_PROP *p_prop, UINT8 num_prop, UINT8 *p_data,
- UINT16 *p_len)
-{
- int i, j;
- tBTA_OP_STATUS result = BTA_OP_FAIL;
-
- /* for each property */
- for(i = 0; num_prop != 0; num_prop--, i++)
- {
- /* verify property is valid */
- if ((p_prop[i].name == 0) || (p_prop[i].name > p_tbl[0].len))
- {
- result = BTA_OP_FAIL;
- break;
- }
-
- j = p_prop[i].name;
-
- if (bta_op_strnicmp(p_tbl[j].p_name, (char *) p_name,
- (p_tbl[j].len - BTA_OP_PROP_OVHD)) == 0)
- {
- memcpy(p_data, p_prop[i].p_data, p_prop[i].len);
- *p_len = p_prop[i].len;
- result = BTA_OP_OK;
- break;
- }
- }
- return result;
-}
-
-/*******************************************************************************
-**
-** Function bta_op_build_obj
-**
-** Description Build an object from property data supplied by the user.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete build.
-**
-*******************************************************************************/
-tBTA_OP_STATUS bta_op_build_obj(const tBTA_OP_OBJ_TBL *p_bld, UINT8 *p_data,
- UINT16 *p_len, tBTA_OP_PROP *p_prop, UINT8 num_prop)
-{
- int i,j;
- tBTA_OP_STATUS result = BTA_OP_OK;
- UINT8 *p = p_data;
-
- /* sanity check length */
- if (*p_len < p_bld->min_len)
- {
- result = BTA_OP_MEM;
- }
- else
- {
- /* adjust p_len to amount of free space minus start and end */
- *p_len -= p_bld->min_len;
-
- /* add begin, version */
- BCM_STRCPY_S((char *) p, BTA_OP_REM_MEMORY, p_bld->p_begin_str);
- p += p_bld->begin_len;
-
- /* for each property */
- for(i = 0; num_prop != 0; num_prop--, i++)
- {
- /* verify property is valid */
- if ((p_prop[i].name == 0) || (p_prop[i].name > p_bld->p_tbl[0].len))
- {
- result = BTA_OP_FAIL;
- break;
- }
-
- /* verify property will fit */
- if (bta_op_prop_len(p_bld->p_tbl, &p_prop[i]) > (p_data + p_bld->begin_len + *p_len - p))
- {
- result = BTA_OP_MEM;
- break;
- }
-
- /* check for filter */
- if (bta_op_prop_filter_mask !=0 && p_bld->p_prop_filter_mask_tbl != NULL &&
- p_prop[i].name <= p_bld->p_prop_filter_mask_tbl->len)
- {
- if (!(bta_op_prop_filter_mask & p_bld->p_prop_filter_mask_tbl->p_prop_filter_mask[p_prop[i].name]))
- continue;
- }
-
- /* Check if the combination of parameters are allowed for
- the format we are building */
- if (bta_op_param_conflict(p_bld->fmt, &p_prop[i]))
- continue;
-
- /* add property string */
- BCM_STRCPY_S((char *) p, BTA_OP_REM_MEMORY, p_bld->p_tbl[p_prop[i].name].p_name);
- p += p_bld->p_tbl[p_prop[i].name].len - BTA_OP_PROP_OVHD;
-
- for (j= bta_op_media[0].len; j > 0; j--)
- {
- if (!bta_op_strnicmp(bta_op_media[j].media_name, p_bld->p_tbl[p_prop[i].name].p_name, bta_op_media[j].len))
- {
- p = bta_op_add_media_param(p_bld->p_tbl, p, &p_prop[i]);
- break;
- }
- }
-
- if (!j)
- {
- /* add property parameters */
- p = bta_op_add_param(p_bld->fmt, p_bld->p_tbl, p, &p_prop[i]);
- }
-
- /* add user data */
-// btla-specific ++
- if(p_prop[i].name != BTA_OP_VCARD_CALL) // If the data is call date-time, use ';' instead of ':'
- {
- *p++ = ':';
- }
- else
- {
- *p++ = ';';
- }
-// btla-specific --
-
- memcpy(p, p_prop[i].p_data, p_prop[i].len);
- p += p_prop[i].len;
- *p++ = '\r';
- *p++ = '\n';
- }
-
- /* add in end */
- memcpy(p, p_bld->p_end_str, p_bld->end_len);
- p += p_bld->end_len;
- }
-
- *p_len = (UINT16) (p - p_data);
- return result;
-}
-
-/*******************************************************************************
-**
-** Function bta_op_nextline
-**
-** Description Scan to beginning of next property text line.
-**
-**
-** Returns Pointer to beginning of property or NULL if end of
-** data reached.
-**
-*******************************************************************************/
-static UINT8 *bta_op_nextline(UINT8 *p, UINT8 *p_end, BOOLEAN qp)
-{
-// btla-specific ++
- if (*p == '\r')
- {
- p--;
- }
-// btla-specific --
-
- if ((p_end - p) > 3)
- {
- p_end -= 3;
- while (p < p_end)
- {
- if (*(++p) == '\r')
- {
- if (*(p + 1) == '\n')
- {
- if (qp)
- {
- if (*(p - 1) == '=')
- {
- /* this is a soft break for quoted-printable*/
- continue;
- }
- }
-
- if ((*(p + 2) != ' ') && (*(p + 2) != '\t'))
- {
- return(p + 2);
- }
- }
- }
- }
- }
- return NULL;
-}
-
-/*******************************************************************************
-**
-** Function bta_op_scantok
-**
-** Description Scan a line for one or more tokens.
-**
-**
-** Returns Pointer to token or NULL if end of data reached.
-**
-*******************************************************************************/
-static UINT8 *bta_op_scantok(UINT8 *p, UINT8 *p_end, const char *p_tok)
-{
- int i;
- UINT8 num_tok = strlen(p_tok);
-
- for (; p < p_end; p++)
- {
- for (i = 0; i < num_tok; i++)
- {
- if (*p == p_tok[i])
- {
- return p;
- }
- }
- }
- return NULL;
-}
-
-/*******************************************************************************
-**
-** Function bta_op_scanstr
-**
-** Description Scan for a matching string.
-**
-**
-** Returns Pointer to end of match or NULL if end of data reached.
-**
-*******************************************************************************/
-UINT8 *bta_op_scanstr(UINT8 *p, UINT8 *p_end, const char *p_str)
-{
- int len = strlen(p_str);
-
- for (;;)
- {
- /* check for match */
- if (strncmp((char *) p, p_str, len) == 0)
- {
- p += len;
- break;
- }
- /* no match; skip to next line, checking for end */
- else if ((p = bta_op_nextline(p, p_end, FALSE)) == NULL)
- {
- break;
- }
- }
- return p;
-}
-
-/*******************************************************************************
-**
-** Function bta_op_parse_obj
-**
-** Description Parse an object.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid data.
-** BTA_OP_MEM if not enough memory to complete build.
-**
-*******************************************************************************/
-tBTA_OP_STATUS bta_op_parse_obj(const tBTA_OP_OBJ_TBL *p_prs, tBTA_OP_PROP *p_prop,
- UINT8 *p_num_prop, UINT8 *p_data, UINT16 len)
-{
- UINT32 j;
- UINT8 *p_s, *p_e;
- tBTA_OP_STATUS result = BTA_OP_OK;
- UINT8 max_prop = *p_num_prop;
- UINT8 *p_end = p_data + len;
- UINT8 prop_name = 0;
- BOOLEAN qp=FALSE;
-
- *p_num_prop = 0;
-
- /* sanity check length */
- if (len < p_prs->min_len)
- {
- return BTA_OP_FAIL;
- }
-
- /* find beginning */
- if ((p_s = bta_op_scanstr(p_data, p_end, p_prs->p_begin_str)) == NULL)
- {
- return BTA_OP_FAIL;
- }
-
- while (*p_num_prop < max_prop)
- {
- /* scan for next delimiter */
- if ((p_e = bta_op_scantok(p_s, p_end, ".;:")) == NULL)
- {
- break;
- }
-
- /* deal with grouping delimiter */
- if (*p_e == '.')
- {
- p_s = p_e + 1;
- if ((p_e = bta_op_scantok(p_s, p_end, ";:")) == NULL)
- {
- break;
- }
- }
-
- /* we found a property; see if it matches anything in our list */
- for (j = 1; j <= p_prs->p_tbl[0].len; j++)
- {
- if (bta_op_strnicmp(p_prs->p_tbl[j].p_name, (char *) p_s,
- (p_prs->p_tbl[j].len - BTA_OP_PROP_OVHD)) == 0)
- {
- p_prop[*p_num_prop].name = prop_name = j;
- p_prop[*p_num_prop].parameters = 0;
- break;
- }
- }
-
- /* if not in our list we can't parse it; continue */
- if (j > p_prs->p_tbl[0].len)
- {
- if ((p_s = bta_op_nextline(p_e, p_end, FALSE)) == NULL)
- {
- break;
- }
- continue;
- }
-
- /* now parse out all the parameters */
- if (*p_e == ';')
- {
- while ((*p_e == ';') || (*p_e == ','))
- {
- p_s = p_e + 1;
-
- if ((p_e = bta_op_scantok(p_s, p_end, ",;:")) == NULL)
- {
- break;
- }
-
- /* we found a parameter; see if it matches anything */
-
- /* check for encoding */
- qp = FALSE;
- if (bta_op_strnicmp(bta_op_encoding, (char *) p_s, BTA_OP_ENCODING_LEN) == 0)
- {
- p_s += BTA_OP_ENCODING_LEN;
- for (j = 1; j <= BTA_OP_NUM_ENCODINGS; j++)
- {
- if (bta_op_strnicmp(bta_op_encodings[j].p_name, (char *) p_s,
- (bta_op_encodings[j].len - BTA_OP_ENCODING_LEN - 1)) == 0)
- {
- if (j == BTA_OP_QP_IDX)
- {
- /* encoding = quoted-printable*/
- qp= TRUE;
- }
- p_prop[*p_num_prop].parameters |= j;
- break;
- }
- }
- }
- /* check for charset */
- else if (bta_op_strnicmp(bta_op_charset, (char *) p_s, BTA_OP_CHARSET_LEN) == 0)
- {
- p_s += BTA_OP_CHARSET_LEN;
- for (j = 1; j <= BTA_OP_NUM_CHARSETS; j++)
- {
- if (bta_op_strnicmp(bta_op_charsets[j].p_name, (char *) p_s,
- (bta_op_charsets[j].len - BTA_OP_CHARSET_LEN - 1)) == 0)
- {
- p_prop[*p_num_prop].parameters |= j << 3;
- break;
- }
- }
- }
- /* check for property-specific parameters */
- else if (p_prs->p_tbl[prop_name].p_param_tbl != NULL)
- {
-
- /* Check for "TYPE=" */
- if (!bta_op_strnicmp((char *)p_s, bta_op_param_type_hdr, BTA_OP_PARAM_TYPE_HDR_LEN))
- {
- p_s += BTA_OP_PARAM_TYPE_HDR_LEN;
- }
-
- for (j = p_prs->p_tbl[prop_name].p_param_tbl[0].len; j > 0; j--)
- {
- if (bta_op_strnicmp(p_prs->p_tbl[prop_name].p_param_tbl[j].p_name,
- (char *) p_s, (p_prs->p_tbl[prop_name].p_param_tbl[j].len - 1)) == 0)
- {
- p_prop[*p_num_prop].parameters |= ((UINT32) 1) << (j + 7);
- break;
- }
- }
- }
- else
- {
- /* if this the start of the param */
- if (!p_prop[*p_num_prop].p_param)
- p_prop[*p_num_prop].p_param = p_s;
- if (*p_e == ':')
- p_prop[*p_num_prop].param_len += (p_e - p_s);
- else
- p_prop[*p_num_prop].param_len += (p_e - p_s + 1);
- }
- }
- }
-
- if (p_e == NULL)
- {
- break;
- }
-
- /* go to start of next property */
- p_s = p_e + 1;
- if ((p_e = bta_op_nextline(p_s, p_end, qp)) == NULL)
- {
- break;
- }
-
- /* save property info */
- p_prop[*p_num_prop].p_data = p_s;
- p_prop[*p_num_prop].len = (UINT16) (p_e - p_s - 2);
-// btla-specific ++
- if (p_prop[*p_num_prop].len)
- {
- (*p_num_prop)++;
- }
-// btla-specific --
- p_s = p_e;
- }
- return result;
-}
-
diff --git a/bta/op/bta_op_fmt.h b/bta/op/bta_op_fmt.h
deleted file mode 100644
index 29bb40c..0000000
--- a/bta/op/bta_op_fmt.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_op_fmt.h
-**
-** Description: This is the interface file for common functions and data
-** types used by the OPP object formatting functions.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_OP_FMT_H
-#define BTA_OP_FMT_H
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-#define BTA_OP_PROP_OVHD 3
-
-/*****************************************************************************
-** Data types
-*****************************************************************************/
-
-enum {
- BTA_OP_FMT_NONE=0,
- BTA_OP_FMT_VCARD21,
- BTA_OP_FMT_VCARD30,
- BTA_OP_FMT_VCAL10,
- BTA_OP_FMT_VNOTE11
-};
-
-/*Supported formats */
-typedef UINT8 tBTA_OP_SUP_FMT;
-
-typedef struct
-{
- const char *p_name;
- UINT8 len;
-} tBTA_OP_PARAM;
-
-typedef struct
-{
- const char *p_name;
- const tBTA_OP_PARAM *p_param_tbl;
- UINT8 len;
-} tBTA_OP_PROP_TBL;
-
-
-typedef struct
-{
- const UINT32 *p_prop_filter_mask;
- UINT8 len;
-} tBTA_OP_PROP_FILTER_MASK_TBL;
-
-typedef struct
-{
- const tBTA_OP_PROP_TBL *p_tbl;
- tBTA_OP_SUP_FMT fmt;
- const char *p_begin_str;
- const char *p_end_str;
- UINT8 begin_len;
- UINT8 end_len;
- UINT8 min_len;
- const tBTA_OP_PROP_FILTER_MASK_TBL *p_prop_filter_mask_tbl;
-} tBTA_OP_OBJ_TBL;
-
-typedef struct
-{
- const char *media_name;
- UINT8 len;
-} tBTA_OP_PROP_MEDIA;
-
-/*****************************************************************************
-** Function prototypes
-*****************************************************************************/
-
-extern tBTA_OP_STATUS bta_op_build_obj(const tBTA_OP_OBJ_TBL *p_bld,
- UINT8 *p_data, UINT16 *p_len,
- tBTA_OP_PROP *p_prop, UINT8 num_prop);
-
-extern tBTA_OP_STATUS bta_op_parse_obj(const tBTA_OP_OBJ_TBL *p_prs,
- tBTA_OP_PROP *p_prop, UINT8 *p_num_prop,
- UINT8 *p_data, UINT16 len);
-extern tBTA_OP_STATUS bta_op_get_property_by_name(const tBTA_OP_PROP_TBL *p_tbl, UINT8 *p_name,
- tBTA_OP_PROP *p_prop, UINT8 num_prop, UINT8 *p_data,
- UINT16 *p_len);
-extern UINT8 *bta_op_scanstr(UINT8 *p, UINT8 *p_end, const char *p_str);
-extern void bta_op_set_prop_filter_mask(UINT32 mask);
-
-#endif /* BTA_OP_FMT_H */
-
diff --git a/bta/op/bta_op_vcal.c b/bta/op/bta_op_vcal.c
deleted file mode 100644
index 79aef02..0000000
--- a/bta/op/bta_op_vcal.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_op_vcal.c
-**
-** Description: This file contains functions for parsing and building
-** vCal objects.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bta_op_api.h"
-#include "bta_op_fmt.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-#define BTA_OP_TODO_BEGIN_LEN 43
-#define BTA_OP_TODO_END_LEN 26
-
-#define BTA_OP_TODO_MIN_LEN (BTA_OP_TODO_BEGIN_LEN + BTA_OP_TODO_END_LEN)
-
-#define BTA_OP_EVENT_BEGIN_LEN 44
-#define BTA_OP_EVENT_END_LEN 27
-
-#define BTA_OP_EVENT_MIN_LEN (BTA_OP_EVENT_BEGIN_LEN + BTA_OP_EVENT_END_LEN)
-
-#define BTA_OP_VCAL_BEGIN_LEN 17
-#define BTA_OP_VCAL_END_LEN 15
-#define BTA_OP_VCAL_MIN_LEN (BTA_OP_VCAL_BEGIN_LEN + BTA_OP_VCAL_END_LEN)
-#define BTA_OP_BEGIN_OFFSET 30
-
-const char bta_op_vcal_begin[] = "BEGIN:VCALENDAR\r\n";
-
-const char bta_op_todo_begin[] = "BEGIN:VCALENDAR\r\nVERSION:1.0\r\nBEGIN:VTODO\r\n";
-
-const char bta_op_todo_end[] = "END:VTODO\r\nEND:VCALENDAR\r\n";
-
-const char bta_op_event_begin[] = "BEGIN:VCALENDAR\r\nVERSION:1.0\r\nBEGIN:VEVENT\r\n";
-
-const char bta_op_event_end[] = "END:VEVENT\r\nEND:VCALENDAR\r\n";
-
-const tBTA_OP_PROP_TBL bta_op_vcal_tbl[] =
-{
- {NULL, NULL, 11}, /* Number of elements in array */
- {"CATEGORIES", NULL, 13}, /* BTA_OP_VCAL_CATEGORIES */
- {"COMPLETED", NULL, 12}, /* BTA_OP_VCAL_COMPLETED */
- {"DESCRIPTION", NULL, 14}, /* BTA_OP_VCAL_DESCRIPTION */
- {"DTEND", NULL, 8}, /* BTA_OP_VCAL_DTEND */
- {"DTSTART", NULL, 10}, /* BTA_OP_VCAL_DTSTART */
- {"DUE", NULL, 6}, /* BTA_OP_VCAL_DUE */
- {"LOCATION", NULL, 11}, /* BTA_OP_VCAL_LOCATION */
- {"PRIORITY", NULL, 11}, /* BTA_OP_VCAL_PRIORITY */
- {"STATUS", NULL, 9}, /* BTA_OP_VCAL_STATUS */
- {"SUMMARY", NULL, 10}, /* BTA_OP_VCAL_SUMMARY */
- {"X-IRMC-LUID", NULL, 14} /* BTA_OP_VCAL_LUID */
-};
-
-const tBTA_OP_OBJ_TBL bta_op_todo_bld =
-{
- bta_op_vcal_tbl,
- BTA_OP_FMT_VCAL10,
- bta_op_todo_begin,
- bta_op_todo_end,
- BTA_OP_TODO_BEGIN_LEN,
- BTA_OP_TODO_END_LEN,
- BTA_OP_TODO_MIN_LEN
-};
-
-const tBTA_OP_OBJ_TBL bta_op_event_bld =
-{
- bta_op_vcal_tbl,
- BTA_OP_FMT_VCAL10,
- bta_op_event_begin,
- bta_op_event_end,
- BTA_OP_EVENT_BEGIN_LEN,
- BTA_OP_EVENT_END_LEN,
- BTA_OP_EVENT_MIN_LEN
-};
-
-const tBTA_OP_OBJ_TBL bta_op_vcal_prs =
-{
- bta_op_vcal_tbl,
- BTA_OP_FMT_VCAL10,
- bta_op_vcal_begin,
- NULL,
- BTA_OP_VCAL_BEGIN_LEN,
- BTA_OP_VCAL_END_LEN,
- BTA_OP_VCAL_MIN_LEN
-};
-
-/*******************************************************************************
-**
-** Function BTA_OpBuildCal
-**
-** Description Build a vCal 1.0 object. The input to this function is an
-** array of vCaalproperties and a pointer to memory to store
-** the card. The output is a formatted vCal.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete build.
-**
-*******************************************************************************/
-tBTA_OP_STATUS BTA_OpBuildCal(UINT8 *p_cal, UINT16 *p_len, tBTA_OP_PROP *p_prop,
- UINT8 num_prop, tBTA_OP_VCAL vcal_type)
-{
- tBTA_OP_OBJ_TBL *p_bld;
-
- if (vcal_type == BTA_OP_VCAL_EVENT)
- {
- p_bld = (tBTA_OP_OBJ_TBL *) &bta_op_event_bld;
- }
- else
- {
- p_bld = ( tBTA_OP_OBJ_TBL *) &bta_op_todo_bld;
- }
-
- return bta_op_build_obj(p_bld, p_cal, p_len, p_prop, num_prop);
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpParseCal
-**
-** Description Parse a vCal object. The input to this function is a
-** pointer to vCal data. The output is an array of parsed
-** vCal properties.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete parsing.
-**
-*******************************************************************************/
-tBTA_OP_STATUS BTA_OpParseCal(tBTA_OP_PROP *p_prop, UINT8 *p_num_prop, UINT8 *p_cal,
- UINT16 len, tBTA_OP_VCAL *p_vcal_type)
-{
- if (bta_op_scanstr(p_cal, (p_cal + len), &bta_op_todo_begin[BTA_OP_BEGIN_OFFSET]) != NULL)
- {
- *p_vcal_type = BTA_OP_VCAL_TODO;
- }
- else if (bta_op_scanstr(p_cal, (p_cal + len), &bta_op_event_begin[BTA_OP_BEGIN_OFFSET]) != NULL)
- {
- *p_vcal_type = BTA_OP_VCAL_EVENT;
- }
- else
- {
- *p_num_prop = 0;
- return BTA_OP_FAIL;
- }
-
- return bta_op_parse_obj(&bta_op_vcal_prs, p_prop, p_num_prop, p_cal, len);
-}
-
diff --git a/bta/op/bta_op_vcard.c b/bta/op/bta_op_vcard.c
deleted file mode 100644
index 6a278ba..0000000
--- a/bta/op/bta_op_vcard.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_op_vcard.c
-**
-** Description: This file contains functions for parsing and building
-** vCard objects.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bta_op_api.h"
-#include "bta_op_fmt.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-#define BTA_OP_VCARD_BEGIN_LEN 26
-#define BTA_OP_VCARD_END_LEN 11
-
-#define BTA_OP_VCARD_MIN_LEN (BTA_OP_VCARD_BEGIN_LEN + BTA_OP_VCARD_END_LEN)
-
-const char bta_op_vcard_prs_begin[] = "BEGIN:VCARD\r\n";
-
-const char bta_op_vcard_21_begin[] = "BEGIN:VCARD\r\nVERSION:2.1\r\n";
-
-const char bta_op_vcard_30_begin[] = "BEGIN:VCARD\r\nVERSION:3.0\r\n";
-
-const char bta_op_vcard_end[] = "END:VCARD\r\n";
-
-const tBTA_OP_PARAM bta_op_vcard_adr[] =
-{
- {NULL, 6}, /* Number of elements in array */
- {"DOM", 4}, /* BTA_OP_ADR_DOM */
- {"INTL", 5}, /* BTA_OP_ADR_INTL */
- {"POSTAL", 7}, /* BTA_OP_ADR_POSTAL */
- {"PARCEL", 7}, /* BTA_OP_ADR_PARCEL */
- {"HOME", 5}, /* BTA_OP_ADR_HOME */
- {"WORK", 5} /* BTA_OP_ADR_WORK */
-};
-
-const tBTA_OP_PARAM bta_op_vcard_email[] =
-{
- {NULL, 3}, /* Number of elements in array */
- {"PREF", 5}, /* BTA_OP_EMAIL_PREF */
- {"INTERNET", 9}, /* BTA_OP_EMAIL_INTERNET */
- {"X400", 5} /* BTA_OP_EMAIL_X400 */
-};
-
-const tBTA_OP_PARAM bta_op_vcard_tel[] =
-{
- {NULL, 8}, /* Number of elements in array */
- {"PREF", 5}, /* BTA_OP_TEL_PREF */
- {"WORK", 5}, /* BTA_OP_TEL_WORK */
- {"HOME", 5}, /* BTA_OP_TEL_HOME */
- {"VOICE", 6}, /* BTA_OP_TEL_VOICE */
- {"FAX", 4}, /* BTA_OP_TEL_FAX */
- {"MSG", 4}, /* BTA_OP_TEL_MSG */
- {"CELL", 5}, /* BTA_OP_TEL_CELL */
- {"PAGER", 6} /* BTA_OP_TEL_PAGER */
-};
-
-const tBTA_OP_PARAM bta_op_vcard_photo[] =
-{
- {NULL, 4}, /* Number of elements in array */
- {"VALUE=URI", 10}, /* BTA_OP_PHOTO_VALUE_URI */
- {"VALUE=URL", 10}, /* BTA_OP_PHOTO_VALUE_URL */
- {"JPEG", 5}, /* BTA_OP_PHOTO_TYPE_JPEG */
- {"GIF", 4} /* BTA_OP_PHOTO_TYPE_GIF */
-};
-
-const tBTA_OP_PARAM bta_op_vcard_sound[] =
-{
- {NULL, 4}, /* Number of elements in array */
- {"VALUE=URI", 10}, /* BTA_OP_SOUND_VALUE_URI */
- {"VALUE=URL", 10}, /* BTA_OP_SOUND_VALUE_URL */
- {"BASIC", 6}, /* BTA_OP_SOUND_TYPE_BASIC */
- {"WAVE", 5} /* BTA_OP_SOUND_TYPE_WAVE */
-};
-
-const tBTA_OP_PROP_TBL bta_op_vcard_tbl[] =
-{
- {NULL, NULL, 15}, /* Number of elements in array */
- {"ADR", bta_op_vcard_adr, 6}, /* BTA_OP_VCARD_ADR */
- {"EMAIL", bta_op_vcard_email, 8}, /* BTA_OP_VCARD_EMAIL */
- {"FN", NULL, 5}, /* BTA_OP_VCARD_FN */
- {"NOTE", NULL, 7}, /* BTA_OP_VCARD_NOTE */
- {"NICKNAME", NULL, 11}, /* BTA_OP_VACRD_NICKNAME */
- {"N", NULL, 4}, /* BTA_OP_VCARD_N */
- {"ORG", NULL, 6}, /* BTA_OP_VCARD_ORG */
- {"TEL", bta_op_vcard_tel, 6}, /* BTA_OP_VCARD_TEL */
- {"TITLE", NULL, 8}, /* BTA_OP_VCARD_TITLE */
- {"URL", NULL, 6}, /* BTA_OP_VCARD_URL */
- {"X-IRMC-LUID", NULL, 14}, /* BTA_OP_VNOTE_LUID */
- {"BDAY", NULL, 7}, /* BTA_OP_VCARD_BDAY */
- {"PHOTO", bta_op_vcard_photo, 8}, /* BTA_OP_VCARD_PHOTO */
- {"SOUND", bta_op_vcard_sound, 8}, /* BTA_OP_VCARD_SOUND */
- {"X-IRMC-CALL-DATETIME", NULL, 23} /* BTA_OP_VCARD_CALL */
-};
-
-const UINT32 bta_op_vcard_prop_filter_mask[] =
-{
-/* table index should be the same as the prop table above */
- BTA_OP_FILTER_ALL,
- BTA_OP_FILTER_ADR,
- BTA_OP_FILTER_EMAIL,
- BTA_OP_FILTER_FN,
- BTA_OP_FILTER_NOTE,
- BTA_OP_FILTER_NICKNAME,
- BTA_OP_FILTER_N,
- BTA_OP_FILTER_ORG,
- BTA_OP_FILTER_TEL,
- BTA_OP_FILTER_TITLE,
- BTA_OP_FILTER_URL,
- BTA_OP_FILTER_UID,
- BTA_OP_FILTER_BDAY,
- BTA_OP_FILTER_PHOTO,
- BTA_OP_FILTER_SOUND,
- BTA_OP_FILTER_TIME_STAMP
-};
-
-const tBTA_OP_PROP_FILTER_MASK_TBL bta_op_vcard_prop_filter_mask_tbl =
-{
- bta_op_vcard_prop_filter_mask,
- 15
-};
-
-const tBTA_OP_OBJ_TBL bta_op_vcard_21_bld =
-{
- bta_op_vcard_tbl,
- BTA_OP_FMT_VCARD21,
- bta_op_vcard_21_begin,
- bta_op_vcard_end,
- BTA_OP_VCARD_BEGIN_LEN,
- BTA_OP_VCARD_END_LEN,
- BTA_OP_VCARD_MIN_LEN,
- &bta_op_vcard_prop_filter_mask_tbl
-};
-
-const tBTA_OP_OBJ_TBL bta_op_vcard_30_bld =
-{
- bta_op_vcard_tbl,
- BTA_OP_FMT_VCARD30,
- bta_op_vcard_30_begin,
- bta_op_vcard_end,
- BTA_OP_VCARD_BEGIN_LEN,
- BTA_OP_VCARD_END_LEN,
- BTA_OP_VCARD_MIN_LEN,
- &bta_op_vcard_prop_filter_mask_tbl
-};
-
-const tBTA_OP_OBJ_TBL bta_op_vcard_21_prs =
-{
- bta_op_vcard_tbl,
- BTA_OP_FMT_VCARD21,
- bta_op_vcard_prs_begin,
- bta_op_vcard_end,
- BTA_OP_VCARD_BEGIN_LEN,
- BTA_OP_VCARD_END_LEN,
- BTA_OP_VCARD_MIN_LEN,
- NULL
-};
-
-const tBTA_OP_OBJ_TBL bta_op_vcard_30_prs =
-{
- bta_op_vcard_tbl,
- BTA_OP_FMT_VCARD30,
- bta_op_vcard_prs_begin,
- bta_op_vcard_end,
- BTA_OP_VCARD_BEGIN_LEN,
- BTA_OP_VCARD_END_LEN,
- BTA_OP_VCARD_MIN_LEN,
- NULL
-};
-
-
-/*******************************************************************************
-**
-** Function bta_op_get_card_fmt
-**
-** Description Finds the vCard format contained in buffer pointed by p_card
-**
-**
-** Returns Vcard Format BTA_OP_VCARD21_FMT/BTA_OP_VCARD30_FMT else
-** BTA_OP_OTHER_FMT
-**
-*******************************************************************************/
-static tBTA_OP_SUP_FMT bta_op_get_card_fmt(UINT8 *p_data, UINT16 len)
-{
- UINT8 *p_end = p_data + len;
-
- if (bta_op_scanstr(p_data, p_end, bta_op_vcard_21_begin) != NULL)
- {
- return BTA_OP_FMT_VCARD21;
- }
- else if (bta_op_scanstr(p_data, p_end, bta_op_vcard_30_begin) != NULL)
- {
- return BTA_OP_FMT_VCARD30;
- }
- else
- {
- return BTA_OP_FMT_NONE;
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpBuildCard
-**
-** Description Build a vCard object. The input to this function is
-** requested format(2.1/3.0), an array of vCard properties
-** and a pointer to memory to store the card.
-** The output is a formatted vCard.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete build.
-**
-*******************************************************************************/
-tBTA_OP_STATUS BTA_OpBuildCard(UINT8 *p_card, UINT16 *p_len, tBTA_OP_FMT fmt,
- tBTA_OP_PROP *p_prop, UINT8 num_prop)
-{
- if(fmt == BTA_OP_VCARD21_FMT)
- {
- return bta_op_build_obj(&bta_op_vcard_21_bld, p_card, p_len, p_prop, num_prop);
- }
- else if(fmt == BTA_OP_VCARD30_FMT)
- {
- return bta_op_build_obj(&bta_op_vcard_30_bld, p_card, p_len, p_prop, num_prop);
- }
- else
- {
- *p_len = 0;
- return BTA_OP_FAIL;
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpSetCardPropFilterMask
-**
-** Description Set Property Filter Mask
-**
-**
-** Returns
-**
-*******************************************************************************/
-void BTA_OpSetCardPropFilterMask(UINT32 mask)
-{
- bta_op_set_prop_filter_mask(mask);
- return;
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpParseCard
-**
-** Description Parse a vCard 2.1 object. The input to this function is
-** a pointer to vCard data. The output is an array of parsed
-** vCard properties.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete parsing.
-**
-*******************************************************************************/
-tBTA_OP_STATUS BTA_OpParseCard(tBTA_OP_PROP *p_prop, UINT8 *p_num_prop,
- UINT8 *p_card, UINT16 len)
-{
- tBTA_OP_SUP_FMT fmt = bta_op_get_card_fmt(p_card, len);
-
- if (fmt == BTA_OP_FMT_VCARD21)
- {
- return bta_op_parse_obj(&bta_op_vcard_21_prs, p_prop, p_num_prop, p_card, len);
- }
- else if(fmt == BTA_OP_FMT_VCARD30)
- {
- return bta_op_parse_obj(&bta_op_vcard_30_prs, p_prop, p_num_prop, p_card, len);
- }
- else
- {
- *p_num_prop = 0;
- return BTA_OP_FAIL;
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpGetCardProperty
-**
-** Description Get Card property value by name. The input to this function is
-** property name. The output is property value and len
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-**
-*******************************************************************************/
-tBTA_OP_STATUS BTA_OpGetCardProperty(UINT8 *p_value, UINT16 *p_len, tBTA_OP_PROP *p_prop,
- UINT8 num_prop, UINT8 *p_name)
-{
- return bta_op_get_property_by_name(bta_op_vcard_tbl, p_name,
- p_prop, num_prop, p_value, p_len);
-}
-
-
diff --git a/bta/op/bta_op_vnote.c b/bta/op/bta_op_vnote.c
deleted file mode 100644
index ff1c015..0000000
--- a/bta/op/bta_op_vnote.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_op_vnote.c
-**
-** Description: This file contains functions for parsing and building
-** vNote objects.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bta_op_api.h"
-#include "bta_op_fmt.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-#define BTA_OP_VNOTE_BEGIN_LEN 26
-#define BTA_OP_VNOTE_END_LEN 11
-
-#define BTA_OP_VNOTE_MIN_LEN (BTA_OP_VNOTE_BEGIN_LEN + BTA_OP_VNOTE_END_LEN)
-
-const char bta_op_vnote_prs_begin[] = "BEGIN:VNOTE\r\n";
-
-const char bta_op_vnote_begin[] = "BEGIN:VNOTE\r\nVERSION:1.1\r\n";
-
-const char bta_op_vnote_end[] = "END:VNOTE\r\n";
-
-const tBTA_OP_PROP_TBL bta_op_vnote_tbl[] =
-{
- {NULL, NULL, 2}, /* Number of elements in array */
- {"BODY", NULL, 7}, /* BTA_OP_VNOTE_BODY */
- {"X-IRMC-LUID", NULL, 14} /* BTA_OP_VNOTE_LUID */
-};
-
-const tBTA_OP_OBJ_TBL bta_op_vnote_bld =
-{
- bta_op_vnote_tbl,
- BTA_OP_FMT_VNOTE11,
- bta_op_vnote_begin,
- bta_op_vnote_end,
- BTA_OP_VNOTE_BEGIN_LEN,
- BTA_OP_VNOTE_END_LEN,
- BTA_OP_VNOTE_MIN_LEN
-};
-
-const tBTA_OP_OBJ_TBL bta_op_vnote_prs =
-{
- bta_op_vnote_tbl,
- BTA_OP_FMT_VNOTE11,
- bta_op_vnote_prs_begin,
- bta_op_vnote_end,
- BTA_OP_VNOTE_BEGIN_LEN,
- BTA_OP_VNOTE_END_LEN,
- BTA_OP_VNOTE_MIN_LEN
-};
-
-/*******************************************************************************
-**
-** Function BTA_OpBuildNote
-**
-** Description Build a vNote object. The input to this function is an
-** array of vNote properties and a pointer to memory to store
-** the card. The output is a formatted vNote.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete build.
-**
-*******************************************************************************/
-tBTA_OP_STATUS BTA_OpBuildNote(UINT8 *p_note, UINT16 *p_len, tBTA_OP_PROP *p_prop,
- UINT8 num_prop)
-{
- return bta_op_build_obj(&bta_op_vnote_bld, p_note, p_len, p_prop, num_prop);
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpParseNote
-**
-** Description Parse a vNote object. The input to this function is a
-** pointer to vNote data. The output is an array of parsed
-** vNote properties.
-**
-**
-** Returns BTA_OP_OK if operation successful.
-** BTA_OP_FAIL if invalid property data.
-** BTA_OP_MEM if not enough memory to complete parsing.
-**
-*******************************************************************************/
-tBTA_OP_STATUS BTA_OpParseNote(tBTA_OP_PROP *p_prop, UINT8 *p_num_prop, UINT8 *p_note,
- UINT16 len)
-{
- return bta_op_parse_obj(&bta_op_vnote_prs, p_prop, p_num_prop, p_note, len);
-}
-
diff --git a/bta/op/bta_opc_act.c b/bta/op/bta_opc_act.c
deleted file mode 100644
index cf4780d..0000000
--- a/bta/op/bta_opc_act.c
+++ /dev/null
@@ -1,1017 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_opc_act.c
-**
-** Description: This file contains the file transfer action
-** functions for the state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <string.h>
-#include "gki.h"
-#include "bta_sys.h"
-#include "bd.h"
-#include "port_api.h"
-#include "obx_api.h"
-#include "goep_util.h"
-#include "sdp_api.h"
-#include "bta_fs_api.h"
-#include "bta_op_api.h"
-#include "bta_opc_int.h"
-#include "bta_fs_co.h"
-#include "bta_fs_ci.h"
-#include "btm_api.h"
-#include "rfcdefs.h"
-#include "utl.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-/* sdp discovery database size */
-#define BTA_OPC_DISC_SIZE 450
-
-
-/*****************************************************************************
-** Local Function prototypes
-*****************************************************************************/
-#if BTA_OPC_DEBUG == TRUE
-static char *opc_obx_evt_code(tOBX_EVENT evt_code);
-#endif
-
-static void bta_opc_sdp_cback(UINT16 status);
-
-
-/*****************************************************************************
-** Action Functions
-*****************************************************************************/
-
-/*******************************************************************************
-**
-** Function bta_opc_enable
-**
-** Description Handle an api enable event. This function enables the OP
-** Client by opening an Obex/Rfcomm channel with a peer device.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_enable(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
-
- /* store parameters */
- p_cb->p_cback = p_data->api_enable.p_cback;
- p_cb->sec_mask = p_data->api_enable.sec_mask;
- p_cb->app_id = p_data->api_enable.app_id;
- p_cb->srm = p_data->api_enable.srm;
- p_cb->single_op = p_data->api_enable.single_op;
- p_cb->fd = BTA_FS_INVALID_FD;
-
- /* callback with enable event */
- (*p_cb->p_cback)(BTA_OPC_ENABLE_EVT, NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_init_push
-**
-** Description Push an object to the OPP server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_init_push(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- p_cb->status = BTA_OPC_FAIL;
- p_cb->exch_status = BTA_OPC_OK;
-
- if ((p_cb->p_name = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- p_cb->to_do = BTA_OPC_PUSH_MASK;
- p_cb->format = p_data->api_push.format;
- BCM_STRNCPY_S(p_cb->p_name, p_bta_fs_cfg->max_path_len+1, p_data->api_push.p_name, p_bta_fs_cfg->max_path_len);
- p_cb->p_name[p_bta_fs_cfg->max_path_len] = '\0';
- }
- else
- bta_opc_sm_execute(p_cb, BTA_OPC_OBX_CMPL_EVT, (tBTA_OPC_DATA *)NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_init_pull
-**
-** Description Pull an object off the server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_init_pull(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- p_cb->status = BTA_OPC_FAIL;
- p_cb->exch_status = BTA_OPC_OK;
-
- if ((p_cb->p_name = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_file_len +
- p_bta_fs_cfg->max_path_len + 2))) != NULL)
- {
- p_cb->p_rcv_path = p_cb->p_name + p_bta_fs_cfg->max_file_len + 1;
- p_cb->to_do = BTA_OPC_PULL_MASK;
- p_cb->first_get_pkt = TRUE;
- BCM_STRNCPY_S(p_cb->p_rcv_path, p_bta_fs_cfg->max_path_len+1, p_data->api_pull.p_path, p_bta_fs_cfg->max_path_len);
- p_cb->p_rcv_path[p_bta_fs_cfg->max_path_len] = '\0';
- }
- else
- bta_opc_sm_execute(p_cb, BTA_OPC_OBX_CMPL_EVT, (tBTA_OPC_DATA *)NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_init_exch
-**
-** Description Exchange business cards with a server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_init_exch(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- p_cb->status = BTA_OPC_FAIL;
- p_cb->exch_status = BTA_OPC_OK;
-
- /* Need room to hold the receive path, along with path and file name to push */
- if ((p_cb->p_name =
- (char *)GKI_getbuf((UINT16)((p_bta_fs_cfg->max_path_len + 1) * 2))) != NULL)
- {
- p_cb->p_rcv_path = p_cb->p_name + p_bta_fs_cfg->max_path_len + 1;
- p_cb->to_do = BTA_OPC_PULL_MASK | BTA_OPC_PUSH_MASK;
- p_cb->first_get_pkt = TRUE;
- BCM_STRNCPY_S(p_cb->p_name, p_bta_fs_cfg->max_path_len+1, p_data->api_exch.p_send, p_bta_fs_cfg->max_path_len);
- p_cb->p_name[p_bta_fs_cfg->max_path_len] = '\0';
- BCM_STRNCPY_S(p_cb->p_rcv_path, p_bta_fs_cfg->max_path_len+1, p_data->api_exch.p_rcv_path, p_bta_fs_cfg->max_path_len);
- p_cb->p_rcv_path[p_bta_fs_cfg->max_path_len] = '\0';
- }
- else
- bta_opc_sm_execute(p_cb, BTA_OPC_OBX_CMPL_EVT, (tBTA_OPC_DATA *)NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_trans_cmpl
-**
-** Description push/pull complete
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_trans_cmpl(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- tBTA_OPC_OBJECT param;
- tBTA_OPC_EVT evt = BTA_OPC_OBJECT_EVT;
- tBTA_FS_CO_STATUS status;
-
- if (p_data)
- {
- p_cb->status = bta_opc_convert_obx_to_opc_status(p_data->obx_evt.rsp_code);
- }
- else
- {
- /* some action functions send the event to SM with NULL p_data */
- p_cb->status = BTA_OPC_FAIL;
- }
-
- if (p_cb->obx_oper == OPC_OP_PUSH_OBJ)
- evt = BTA_OPC_OBJECT_PSHD_EVT;
-
- /* rearrange the code a little bit to make sure p_cb->status is for the current op
- * (previously, we might use the ststus from the PUSH op, if this is an exchange card) */
- param.status = p_cb->status;
-
- /* If exchange, and push received an error use this error */
- if (p_cb->exch_status != BTA_OPC_OK)
- param.status = p_cb->exch_status;
-
- /* Notify appl the result of the pull or push */
- param.p_name = p_cb->p_name;
- p_cb->p_cback(evt, (tBTA_OPC *)&param);
-
- /* Close any open files */
- if (p_cb->fd >= 0)
- {
- bta_fs_co_close(p_cb->fd, p_cb->app_id);
- p_cb->fd = BTA_FS_INVALID_FD;
-
- /* Delete an aborted unfinished get vCard operation */
- if (p_cb->obx_oper == OPC_OP_PULL_OBJ && p_cb->status != BTA_OPC_OK)
- {
- status = bta_fs_co_unlink(p_cb->p_name, p_cb->app_id);
- APPL_TRACE_WARNING2("OPC: Remove ABORTED Get File Operation [%s], status 0x%02x",
- p_cb->p_name, status);
- }
- }
-
- utl_freebuf((void**)&p_cb->p_name);
-
- p_cb->obx_oper = OPC_OP_NONE;
-
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_ci_write
-**
-** Description Continue with the current write operation
-** (Get File processing)
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_ci_write(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- tBTA_OPC_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_OPC_PROGRESS param;
- UINT8 rsp_code = OBX_RSP_FAILED;
-
- p_cb->cout_active = FALSE;
-
- /* Process write call-in event if operation is still active */
- if (p_cb->obx_oper == OPC_OP_PULL_OBJ)
- {
- if (p_data->write_evt.status == BTA_FS_CO_OK)
- {
- param.bytes = p_obx->offset;
- param.obj_size = p_cb->obj_size;
- param.operation = BTA_OP_OPER_PULL;
- p_cb->p_cback(BTA_OPC_PROGRESS_EVT, (tBTA_OPC *)&param);
-
- /* Send another Get request if not finished */
- if (!p_obx->final_pkt)
- {
- /* Free current packet and send a new request */
- bta_opc_send_get_req(p_cb);
- rsp_code = OBX_RSP_CONTINUE;
- }
- else
- rsp_code = OBX_RSP_OK;
- }
-
- if (rsp_code != OBX_RSP_CONTINUE)
- {
- p_data->obx_evt.rsp_code = rsp_code;
- bta_opc_sm_execute(p_cb, BTA_OPC_OBX_CMPL_EVT, p_data);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_ci_read
-**
-** Description Handles the response to a read call-out request.
-** This is called within the OBX get object request. The
-** operation has completed, send the OBX packet out.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_ci_read(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- tBTA_OPC_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FS_CI_READ_EVT *p_revt = &p_data->read_evt;
- tBTA_OPC_PROGRESS param;
- BOOLEAN is_final;
-
- p_cb->cout_active = FALSE;
-
- /* Process read call-in event if operation is still active */
- if (p_cb->obx_oper == OPC_OP_PUSH_OBJ)
- {
- if (p_revt->status != BTA_FS_CO_OK && p_revt->status != BTA_FS_CO_EOF)
- {
- p_data->obx_evt.rsp_code = OBX_RSP_FAILED;
-/* if abort added to OPC use -> bta_opc_sm_execute(p_cb, BTA_OPC_OBX_CMPL_EVT, p_data); */
- bta_opc_sm_execute(p_cb, BTA_OPC_API_CLOSE_EVT, p_data);
- }
- else
- {
- is_final = (p_revt->status == BTA_FS_CO_EOF) ? TRUE: FALSE;
-
- /* Add the body header to the packet */
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_revt->num_read, is_final);
-
- p_cb->obx.bytes_left -= p_revt->num_read;
- p_cb->obx.offset += p_revt->num_read;
-
- /* Send out the data */
- OBX_PutReq(p_cb->obx_handle, is_final, p_obx->p_pkt);
- p_obx->p_pkt = NULL;
- p_cb->req_pending = TRUE;
-
- /* Give application the status */
- param.bytes = p_revt->num_read;
- param.obj_size = p_cb->obj_size;
- param.operation = BTA_OP_OPER_PUSH;
- p_cb->p_cback(BTA_OPC_PROGRESS_EVT, (tBTA_OPC *)&param);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_ci_open
-**
-** Description Continue with the current file open operation
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_ci_open(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- tBTA_OPC_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FS_CI_OPEN_EVT *p_open = &p_data->open_evt;
- UINT8 rsp_code = OBX_RSP_FAILED;
-
- p_cb->cout_active = FALSE;
-
- /* if file is accessible read/write the first buffer of data */
- if (p_open->status == BTA_FS_CO_OK)
- {
- p_cb->fd = p_open->fd;
-
- if (p_cb->obx_oper == OPC_OP_PUSH_OBJ)
- {
- p_cb->obj_size = p_open->file_size;
-
- rsp_code = bta_opc_send_put_req(p_cb, TRUE);
- }
- else if (p_cb->obx_oper == OPC_OP_PULL_OBJ)
- {
- rsp_code = OBX_RSP_OK;
-
- /* Initiate the first OBX GET request */
- p_obx->offset = 0;
-
- /* Continue processing GET rsp */
- bta_opc_cont_get_rsp(p_cb);
- }
- }
- else
- {
- if (p_open->status == BTA_FS_CO_EACCES)
- rsp_code = OBX_RSP_UNAUTHORIZED;
- else /* File could not be found */
- rsp_code = OBX_RSP_NOT_FOUND;
- }
-
- if (rsp_code != OBX_RSP_OK)
- {
- p_data->obx_evt.rsp_code = rsp_code;
- bta_opc_sm_execute(p_cb, BTA_OPC_API_CLOSE_EVT, p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_obx_conn_rsp
-**
-** Description Process the OBX connect event.
-** If OPP service, get directory listing.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_obx_conn_rsp(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- tBTA_OPC_OBX_EVT *p_evt = &p_data->obx_evt;
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-
- p_cb->peer_mtu = p_data->obx_evt.param.conn.mtu;
-
- /* inform role manager */
- bta_sys_conn_open( BTA_ID_OPC ,p_cb->app_id, bta_opc_cb.bd_addr);
-
- p_cb->p_cback(BTA_OPC_OPEN_EVT, NULL);
-
- /* start the first operation. For card exchange PUSH is done first */
- if(p_cb->to_do & BTA_OPC_PUSH_MASK)
- bta_opc_start_push(p_cb);
- else
- bta_opc_send_get_req(p_cb);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_obx_put_rsp
-**
-** Description Process the OBX file put and delete file/folder events
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_obx_put_rsp(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- tBTA_OPC_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_OPC_OBJECT param;
-
- p_cb->req_pending = FALSE;
- APPL_TRACE_DEBUG1("bta_opc_obx_put_rsp to_do 0x%02x",p_cb->to_do);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-
- if (p_cb->obx_oper == OPC_OP_PUSH_OBJ)
- {
- /* If not finished with Put, start another read */
- if (p_evt->rsp_code == OBX_RSP_CONTINUE)
- bta_opc_send_put_req(p_cb, FALSE);
-
- /* Start the Pull if this is card exchange */
- else if (p_cb->to_do & BTA_OPC_PULL_MASK)
- {
- /* Close the current file and initiate a pull vcard */
- bta_fs_co_close(p_cb->fd, p_cb->app_id);
- p_cb->fd = BTA_FS_INVALID_FD;
-
- /* If error occurred during push save it */
- if (p_evt->rsp_code != OBX_RSP_OK)
- p_cb->exch_status = BTA_OPC_FAIL;
-
- /* Notify application with status of push operation */
- param.status = p_cb->exch_status;
- param.p_name = p_cb->p_name;
- p_cb->p_cback(BTA_OPC_OBJECT_PSHD_EVT, (tBTA_OPC *)&param);
-
- /* Initiate the Pull operation */
- bta_opc_send_get_req(p_cb);
- }
- else /* Finished or an error occurred */
- {
- p_data->obx_evt.rsp_code = p_evt->rsp_code;
- bta_opc_sm_execute(p_cb, BTA_OPC_OBX_CMPL_EVT, p_data);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_obx_get_rsp
-**
-** Description Process the OBX file get and folder listing events
-** If the type header is not folder listing, then pulling a file.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_obx_get_rsp(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- tBTA_OPC_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_OPC_OBX_PKT *p_obx = &p_cb->obx;
- BOOLEAN free_pkt = FALSE;
-
- p_obx->final_pkt = (p_evt->rsp_code == OBX_RSP_OK) ? TRUE : FALSE;
- p_obx->p_pkt = p_evt->p_pkt;
- p_obx->rsp_code = p_evt->rsp_code;
- p_cb->req_pending = FALSE;
-
- if (p_cb->obx_oper == OPC_OP_PULL_OBJ)
- {
- /* Open file for writing */
- if (p_cb->first_get_pkt == TRUE)
- {
- p_cb->first_get_pkt = FALSE;
- free_pkt = bta_opc_proc_get_rsp(p_cb, p_data);
- }
- else /* Continuation of the object transfer */
- bta_opc_cont_get_rsp(p_cb);
- }
- else
- free_pkt = TRUE;
-
- if (free_pkt) /* Release the OBX response packet */
- utl_freebuf((void**)&p_obx->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_initialize
-**
-** Description Initialize the control block.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_initialize(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- tBTA_FS_CO_STATUS status;
-
- utl_freebuf((void**)&p_cb->obx.p_pkt);
-
- /* Close any open files */
- if (p_cb->fd >= 0)
- {
- bta_fs_co_close(p_cb->fd, p_cb->app_id);
- p_cb->fd = BTA_FS_INVALID_FD;
-
- /* Delete an aborted unfinished get vCard operation */
- if (p_cb->obx_oper == OPC_OP_PULL_OBJ && p_cb->status != BTA_OPC_OK)
- {
- status = bta_fs_co_unlink(p_cb->p_name, p_cb->app_id);
- APPL_TRACE_WARNING2("OPC: Remove ABORTED Get File Operation [%s], status 0x%02x",
- p_cb->p_name, status);
- }
- }
-
- utl_freebuf((void**)&p_cb->p_name);
-
- /* Clean up control block */
- p_cb->obx_oper = OPC_OP_NONE;
- p_cb->req_pending = FALSE;
- p_cb->sdp_pending = FALSE;
- p_cb->to_do = 0;
- p_cb->p_rcv_path = NULL;
- p_cb->first_get_pkt = FALSE;
-
- if (p_cb->disabling)
- {
- p_cb->disabling = FALSE;
- bta_opc_sm_execute(p_cb, BTA_OPC_DISABLE_CMPL_EVT, NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_stop_client
-**
-** Description Stop OBX client.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_stop_client(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- if (!p_cb->sdp_pending)
- {
-// btla-specific ++
-#if defined (BTA_OPC_SENDING_ABORT) && (BTA_OPC_SENDING_ABORT == TRUE)
- APPL_TRACE_WARNING3("bta_opc_stop_client p_cb->req_pending = %d, p_cb->sdp_pending = %d,handle = %d",
- p_cb->req_pending, p_cb->sdp_pending,p_cb->obx_handle);
- /* Abort an active request */
- if (p_cb->req_pending)
- OBX_AbortReq(p_cb->obx_handle, (BT_HDR *)NULL);
-#endif
-// btla-specific --
- /* do not free p_cb->obx.p_pkt here, just in case cout_active.
- * bta_opc_close_complete would handle it */
- OBX_DisconnectReq(p_cb->obx_handle, NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_close
-**
-** Description If not waiting for a call-in function, complete the closing
-** of the channel.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_close(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- /* finished if not waiting on a call-in function */
- if (!p_cb->cout_active)
- bta_opc_sm_execute(p_cb, BTA_OPC_CLOSE_CMPL_EVT, p_data);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_start_client
-**
-** Description Start an OPP operation.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_start_client(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- tBTA_OPC_OBX_PKT *p_obx = &p_cb->obx;
- tOBX_STATUS status;
- BOOLEAN srm = p_cb->srm;
-
- /* Allocate an OBX packet */
- if ((p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(OBX_HANDLE_NULL, OBX_MAX_MTU)) != NULL)
- {
- status = OBX_AllocSession (NULL, p_data->sdp_ok.scn, &p_data->sdp_ok.psm,
- bta_opc_obx_cback, &p_cb->obx_handle);
-
- /* set security level */
- if (p_data->sdp_ok.scn)
- {
- BTM_SetSecurityLevel (TRUE, "BTA_OPC", BTM_SEC_SERVICE_OBEX,
- p_cb->sec_mask, BT_PSM_RFCOMM,
- BTM_SEC_PROTO_RFCOMM, p_data->sdp_ok.scn);
- srm = 0;
- }
- else
- {
- BTM_SetSecurityLevel (TRUE, "BTA_OPC", BTM_SEC_SERVICE_OBEX,
- p_cb->sec_mask, p_data->sdp_ok.psm, 0, 0);
- }
-
- if (status == OBX_SUCCESS)
- {
- OBX_CreateSession (p_cb->bd_addr, OBX_MAX_MTU, srm, 0,
- p_cb->obx_handle, p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* OBX will free the memory */
- return;
- }
- }
- else
- {
- p_data->obx_evt.rsp_code = OBX_RSP_FAILED;
- bta_opc_sm_execute(p_cb, BTA_OPC_CLOSE_CMPL_EVT, p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_free_db
-**
-** Description Free buffer used for service discovery database.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_free_db(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- utl_freebuf((void**)&p_cb->p_db);
- p_cb->sdp_pending = FALSE;
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_ignore_obx
-**
-** Description Free OBX packet for ignored OBX events.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_ignore_obx(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- utl_freebuf((void**)&p_data->obx_evt.p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_find_service
-**
-** Description Perform service discovery to find the OPP service on the
-** peer device.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_find_service(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- tSDP_UUID uuid_list;
- UINT16 attr_list[3];
-
- if (!p_cb->to_do)
- return;
-
- bdcpy(p_cb->bd_addr, p_data->api_push.bd_addr);
- if ((p_cb->p_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_OPC_DISC_SIZE)) != NULL)
- {
- attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
- attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
- attr_list[2] = ATTR_ID_OBX_OVR_L2CAP_PSM;
-
- uuid_list.len = LEN_UUID_16;
- uuid_list.uu.uuid16 = UUID_SERVCLASS_OBEX_OBJECT_PUSH;
- p_cb->sdp_pending = TRUE;
- SDP_InitDiscoveryDb(p_cb->p_db, BTA_OPC_DISC_SIZE, 1, &uuid_list, 3, attr_list);
- if(!SDP_ServiceSearchAttributeRequest(p_cb->bd_addr, p_cb->p_db, bta_opc_sdp_cback))
- {
- bta_opc_sm_execute(p_cb, BTA_OPC_SDP_FAIL_EVT, (tBTA_OPC_DATA *)NULL);
- }
- }
- else
- bta_opc_sm_execute(p_cb, BTA_OPC_OBX_CMPL_EVT, (tBTA_OPC_DATA *)NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_close_complete
-**
-** Description Finishes the memory cleanup after a channel is closed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_close_complete(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- p_cb->cout_active = FALSE;
- bta_opc_initialize(p_cb, p_data);
-
- /* inform role manager */
- bta_sys_conn_close( BTA_ID_OPC ,p_cb->app_id, bta_opc_cb.bd_addr);
-
- p_cb->p_cback(BTA_OPC_CLOSE_EVT, (tBTA_OPC *)&p_cb->status);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_set_disable
-**
-** Description Sets flag to disable.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_set_disable(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- p_cb->disabling = TRUE;
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_chk_close
-**
-** Description Check if we need to stop the client now.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_chk_close(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- if (p_cb->single_op)
- {
- bta_opc_sm_execute(p_cb, BTA_OPC_API_CLOSE_EVT, (tBTA_OPC_DATA *)NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_do_pull
-**
-** Description
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_do_pull(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- APPL_TRACE_DEBUG1("bta_opc_do_pull to_do 0x%02x",p_cb->to_do);
- bta_opc_send_get_req(p_cb);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_do_push
-**
-** Description
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_do_push(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- APPL_TRACE_DEBUG1("bta_opc_do_push to_do 0x%02x",p_cb->to_do);
- bta_opc_start_push(p_cb);
-}
-
-/*****************************************************************************
-** Callback Functions
-*****************************************************************************/
-/*******************************************************************************
-**
-** Function bta_opc_obx_cback
-**
-** Description OBX callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_obx_cback (tOBX_HANDLE handle, tOBX_EVENT obx_event, UINT8 rsp_code,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt)
-{
- tBTA_OPC_OBX_EVT *p_obx_msg;
- UINT16 event = 0;
-
-#if BTA_OPC_DEBUG == TRUE
- APPL_TRACE_DEBUG1("OBX Event Callback: obx_event [%s]", opc_obx_evt_code(obx_event));
-#endif
-
- switch(obx_event)
- {
- case OBX_CONNECT_RSP_EVT:
- if (rsp_code == OBX_RSP_OK)
- {
- event = BTA_OPC_OBX_CONN_RSP_EVT;
- }
- else /* Obex will disconnect underneath BTA */
- {
- APPL_TRACE_WARNING1("OPC_CBACK: Bad connect response 0x%02x", rsp_code);
- if (p_pkt)
- GKI_freebuf(p_pkt);
- return;
- }
- break;
- case OBX_PUT_RSP_EVT:
- event = BTA_OPC_OBX_PUT_RSP_EVT;
- break;
- case OBX_GET_RSP_EVT:
- event = BTA_OPC_OBX_GET_RSP_EVT;
- break;
- case OBX_CLOSE_IND_EVT:
- event = BTA_OPC_OBX_CLOSE_EVT;
- break;
- case OBX_PASSWORD_EVT:
- event = BTA_OPC_OBX_PASSWORD_EVT;
- break;
-
- default:
-/* case OBX_ABORT_RSP_EVT: */
-/* case OBX_DISCONNECT_RSP_EVT: Handled when OBX_CLOSE_IND_EVT arrives */
- if (p_pkt)
- GKI_freebuf(p_pkt);
- return;
- }
-
- /* send event to BTA, if any */
- if ((p_obx_msg = (tBTA_OPC_OBX_EVT *) GKI_getbuf(sizeof(tBTA_OPC_OBX_EVT))) != NULL)
- {
- p_obx_msg->hdr.event = event;
- p_obx_msg->obx_event = obx_event;
- p_obx_msg->handle = handle;
- p_obx_msg->rsp_code = rsp_code;
- p_obx_msg->param = param;
- p_obx_msg->p_pkt = p_pkt;
-
- bta_sys_sendmsg(p_obx_msg);
- }
-}
-
-/******************************************************************************
-**
-** Function bta_opc_sdp_cback
-**
-** Description This is the SDP callback function used by OPC.
-** This function will be executed by SDP when the service
-** search is completed. If the search is successful, it
-** finds the first record in the database that matches the
-** UUID of the search. Then retrieves the scn from the
-** record.
-**
-** Returns Nothing.
-**
-******************************************************************************/
-static void bta_opc_sdp_cback(UINT16 status)
-{
- tBTA_OPC_SDP_OK_EVT *p_buf;
- tSDP_DISC_REC *p_rec = NULL;
- tSDP_PROTOCOL_ELEM pe;
- UINT8 scn = 0;
- BOOLEAN found = FALSE;
- UINT16 version = GOEP_LEGACY_VERSION;
- UINT16 psm = 0;
- tSDP_DISC_ATTR *p_attr;
-
- APPL_TRACE_DEBUG1("bta_opc_sdp_cback status:%d", status);
-
- if ( (status == SDP_SUCCESS) || (status == SDP_DB_FULL) )
- {
- status = SDP_SUCCESS;
- /* loop through all records we found */
- do
- {
- /* get next record; if none found, we're done */
- if ((p_rec = SDP_FindServiceInDb(bta_opc_cb.p_db,
- UUID_SERVCLASS_OBEX_OBJECT_PUSH, p_rec)) == NULL)
- break;
-
- /* this is an optional attribute */
- SDP_FindProfileVersionInRec (p_rec, UUID_SERVCLASS_OBEX_OBJECT_PUSH, &version);
-
- /* get psm from proto desc list alternative; if not found, go to next record */
- if ((p_attr = SDP_FindAttributeInRec(p_rec,
- ATTR_ID_OBX_OVR_L2CAP_PSM)) != NULL)
- {
- psm = p_attr->attr_value.v.u16;
- if ((SDP_DISC_ATTR_LEN(p_attr->attr_len_type) == 2) && L2C_IS_VALID_PSM(psm))
- {
- found = TRUE;
- if (version == GOEP_LEGACY_VERSION)
- {
- APPL_TRACE_ERROR0("Lacking mandatory attribute/version");
- version = GOEP_ENHANCED_VERSION;
- }
- break;
- }
- }
-
- /* If no OBEX over L2CAP look for RFCOMM SCN */
- if (!found)
- {
- /* get scn from proto desc list; if not found, go to next record */
- if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
- {
- scn = (UINT8) pe.params[0];
-
- /* we've got everything, we're done */
- found = TRUE;
- break;
- }
- else
- {
- continue;
- }
- }
- } while (TRUE);
- }
-
- /* send result in event back to BTA */
- if ((p_buf = (tBTA_OPC_SDP_OK_EVT *) GKI_getbuf(sizeof(tBTA_OPC_SDP_OK_EVT))) != NULL)
- {
- if ((status == SDP_SUCCESS) && (found == TRUE))
- {
- p_buf->hdr.event = BTA_OPC_SDP_OK_EVT;
- p_buf->scn = scn;
- p_buf->psm = psm;
- p_buf->version = version;
- }
- else
- p_buf->hdr.event = BTA_OPC_SDP_FAIL_EVT;
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*****************************************************************************
-** Local OPP Event Processing Functions
-*****************************************************************************/
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if BTA_OPC_DEBUG == TRUE
-
-/*******************************************************************************
-**
-** Function opc_obx_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *opc_obx_evt_code(tOBX_EVENT evt_code)
-{
- switch(evt_code)
- {
- case OBX_CONNECT_RSP_EVT:
- return "OBX_CONNECT_RSP_EVT";
- case OBX_DISCONNECT_RSP_EVT:
- return "OBX_DISCONNECT_RSP_EVT";
- case OBX_PUT_RSP_EVT:
- return "OBX_PUT_RSP_EVT";
- case OBX_GET_RSP_EVT:
- return "OBX_GET_RSP_EVT";
- case OBX_SETPATH_RSP_EVT:
- return "OBX_SETPATH_RSP_EVT";
- case OBX_ABORT_RSP_EVT:
- return "OBX_ABORT_RSP_EVT";
- case OBX_CLOSE_IND_EVT:
- return "OBX_CLOSE_IND_EVT";
- case OBX_TIMEOUT_EVT:
- return "OBX_TIMEOUT_EVT";
- case OBX_PASSWORD_EVT:
- return "OBX_PASSWORD_EVT";
- default:
- return "unknown OBX event code";
- }
-}
-#endif /* Debug Functions */
diff --git a/bta/op/bta_opc_api.c b/bta/op/bta_opc_api.c
deleted file mode 100644
index 4440b1c..0000000
--- a/bta/op/bta_opc_api.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_opc_api.c
-**
-** Description: This is the implementation of the API for the object
-** push client subsystem of BTA, Widcomm's Bluetooth
-** application layer for mobile phones.
-**
-** Copyright (c) 2003 - 2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <string.h>
-#include "gki.h"
-#include "bta_sys.h"
-#include "bta_fs_api.h"
-#include "bta_op_api.h"
-#include "bta_opc_int.h"
-#include "bd.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-static const tBTA_SYS_REG bta_opc_reg =
-{
- bta_opc_hdl_event,
- BTA_OpcDisable
-};
-
-/*******************************************************************************
-**
-** Function BTA_OpcEnable
-**
-** Description Enable the object push client. This function must be
-** called before any other functions in the DG API are called.
-** When the enable operation is complete the callback function
-** will be called with a BTA_OPC_ENABLE_EVT.
-**
-** If single_op is FALSE, the connection stays open after
-** the operation finishes (until BTA_OpcClose is called).
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_OpcEnable(tBTA_SEC sec_mask, tBTA_OPC_CBACK *p_cback,
- BOOLEAN single_op, BOOLEAN srm, UINT8 app_id)
-{
- tBTA_OPC_API_ENABLE *p_buf;
-
- /* register with BTA system manager */
- GKI_sched_lock();
- bta_sys_register(BTA_ID_OPC, &bta_opc_reg);
- GKI_sched_unlock();
-
- /* initialize control block */
- memset(&bta_opc_cb, 0, sizeof(tBTA_OPC_CB));
-
- if ((p_buf = (tBTA_OPC_API_ENABLE *) GKI_getbuf(sizeof(tBTA_OPC_API_ENABLE))) != NULL)
- {
- p_buf->hdr.event = BTA_OPC_API_ENABLE_EVT;
- p_buf->p_cback = p_cback;
- p_buf->sec_mask = sec_mask;
- p_buf->single_op = single_op;
- p_buf->srm = srm;
- p_buf->app_id = app_id;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpcDisable
-**
-** Description Disable the object push client. If the client is currently
-** connected to a peer device the connection will be closed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_OpcDisable(void)
-{
- BT_HDR *p_buf;
-
- bta_sys_deregister(BTA_ID_OPC);
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_OPC_API_DISABLE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpcPush
-**
-** Description Push an object to a peer device. p_name must point to
-** a fully qualified path and file name.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_OpcPush(BD_ADDR bd_addr, tBTA_OP_FMT format, char *p_name)
-{
- tBTA_OPC_DATA *p_msg;
-
- if ((p_msg = (tBTA_OPC_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_OPC_DATA) +
- p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- p_msg->api_push.p_name = (char *)(p_msg + 1);
- BCM_STRNCPY_S(p_msg->api_push.p_name, p_bta_fs_cfg->max_path_len+1, p_name, p_bta_fs_cfg->max_path_len);
- p_msg->api_push.p_name[p_bta_fs_cfg->max_path_len] = '\0';
- p_msg->hdr.event = BTA_OPC_API_PUSH_EVT;
- bdcpy(p_msg->api_push.bd_addr, bd_addr);
- p_msg->api_push.format = format;
- bta_sys_sendmsg(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpcPullCard
-**
-** Description Pull default card from peer. p_path must point to a fully
-** qualified path specifying where to store the pulled card.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_OpcPullCard(BD_ADDR bd_addr, char *p_path)
-{
- tBTA_OPC_DATA *p_msg;
- tBTA_OPC_API_PULL *p_pull;
-
- if ((p_msg = (tBTA_OPC_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_OPC_DATA) +
- (p_bta_fs_cfg->max_path_len + 1)))) != NULL)
- {
- p_pull = &p_msg->api_pull;
- p_pull->p_path = (char *)(p_msg + 1);
- BCM_STRNCPY_S(p_pull->p_path, p_bta_fs_cfg->max_path_len+1, p_path, p_bta_fs_cfg->max_path_len);
- p_pull->p_path[p_bta_fs_cfg->max_path_len] = '\0';
- bdcpy(p_pull->bd_addr, bd_addr);
- p_pull->hdr.event = BTA_OPC_API_PULL_EVT;
- bta_sys_sendmsg(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpcExchCard
-**
-** Description Exchange business cards with a peer device. p_send points to
-** a fully qualified path and file name of vcard to push.
-** p_recv_path points to a fully qualified path specifying
-** where to store the pulled card.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_OpcExchCard(BD_ADDR bd_addr, char *p_send, char *p_recv_path)
-{
- tBTA_OPC_DATA *p_msg;
- tBTA_OPC_API_EXCH *p_exch;
-
- if(!p_send || !p_recv_path)
- return;
-
- if ((p_msg = (tBTA_OPC_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_OPC_DATA) +
- (p_bta_fs_cfg->max_path_len + 1) * 2))) != NULL)
- {
- p_exch = &p_msg->api_exch;
- p_exch->p_send = (char *)(p_msg + 1);
- p_exch->p_rcv_path = (char *)(p_exch->p_send + p_bta_fs_cfg->max_path_len + 1);
- BCM_STRNCPY_S(p_exch->p_send, p_bta_fs_cfg->max_path_len+1, p_send, p_bta_fs_cfg->max_path_len);
- p_exch->p_send[p_bta_fs_cfg->max_path_len] = '\0';
- BCM_STRNCPY_S(p_exch->p_rcv_path, p_bta_fs_cfg->max_path_len+1, p_recv_path, p_bta_fs_cfg->max_path_len);
- p_exch->p_rcv_path[p_bta_fs_cfg->max_path_len] = '\0';
- bdcpy(p_exch->bd_addr, bd_addr);
- p_exch->hdr.event = BTA_OPC_API_EXCH_EVT;
- bta_sys_sendmsg(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpcClose
-**
-** Description Close the current connection. This function is called if
-** the phone wishes to close the connection before the object
-** push is completed. In a typical connection this function
-** does not need to be called; the connection will be closed
-** automatically when the object push is complete.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_OpcClose(void)
-{
- BT_HDR *p_buf;
-
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_OPC_API_CLOSE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-
diff --git a/bta/op/bta_opc_int.h b/bta/op/bta_opc_int.h
deleted file mode 100644
index e26d2b5..0000000
--- a/bta/op/bta_opc_int.h
+++ /dev/null
@@ -1,257 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_opc_int.h
-**
-** Description: This is the private header file for the Object Push
-** Client (OPC).
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_OPC_INT_H
-#define BTA_OPC_INT_H
-
-#include "bt_target.h"
-#include "bta_sys.h"
-#include "obx_api.h"
-#include "bta_op_api.h"
-#include "bta_fs_co.h"
-#include "bta_fs_ci.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-
-#define OPC_DEF_NAME "default_opc.vcf"
-
-/* if the pulled vCard does not have a Name Header associated with it,
- * this is the default name used to received the file.
- * Please make sure that this is of different file name than the local
- * default vCard file name */
-#ifndef OPC_DEF_RCV_NAME
-#define OPC_DEF_RCV_NAME "opc_def_rcv.vcf"
-#endif
-
-/* OPC Active opp obex operation (Valid in connected state) */
-#define OPC_OP_NONE 0
-#define OPC_OP_PULL_OBJ 1
-#define OPC_OP_PUSH_OBJ 2
-
-/* Constants used for "to_do" list */
-#define BTA_OPC_PUSH_MASK 0x01
-#define BTA_OPC_PULL_MASK 0x02
-
-/* state machine events */
-enum
-{
- /* these events are handled by the state machine */
- BTA_OPC_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_OPC),
- BTA_OPC_API_DISABLE_EVT,
- BTA_OPC_API_CLOSE_EVT, /* Close connection event */
- BTA_OPC_API_PUSH_EVT, /* Push Object request */
- BTA_OPC_API_PULL_EVT, /* Pull Object request */
- BTA_OPC_API_EXCH_EVT, /* Exchange business Cards */
- BTA_OPC_SDP_OK_EVT, /* Service search was successful */
- BTA_OPC_SDP_FAIL_EVT, /* Service search failed */
- BTA_OPC_CI_WRITE_EVT, /* Call-in response to Write request */
- BTA_OPC_CI_READ_EVT, /* Call-in response to Read request */
- BTA_OPC_CI_OPEN_EVT, /* Call-in response to File Open request */
- BTA_OPC_OBX_CONN_RSP_EVT, /* OBX Channel Connect Request */
- BTA_OPC_OBX_PASSWORD_EVT, /* OBX password requested */
- BTA_OPC_OBX_CLOSE_EVT, /* OBX Channel Disconnected (Link Lost) */
- BTA_OPC_OBX_PUT_RSP_EVT, /* Write file data or delete */
- BTA_OPC_OBX_GET_RSP_EVT, /* Read file data or folder listing */
- BTA_OPC_OBX_CMPL_EVT, /* operation has completed */
- BTA_OPC_CLOSE_CMPL_EVT, /* Finish the closing of the channel */
- BTA_OPC_DISABLE_CMPL_EVT /* Transition to disabled state */
-};
-
-typedef UINT16 tBTA_OPC_INT_EVT;
-
-typedef UINT8 tBTA_OPC_STATE;
-
-/* data type for BTA_OPC_API_ENABLE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_OPC_CBACK *p_cback;
- UINT8 sec_mask;
- BOOLEAN single_op;
- BOOLEAN srm;
- UINT8 app_id;
-} tBTA_OPC_API_ENABLE;
-
-/* data type for BTA_OPC_API_PUSH_EVT */
-typedef struct
-{
- BT_HDR hdr;
- BD_ADDR bd_addr;
- char *p_name;
- tBTA_OP_FMT format;
-} tBTA_OPC_API_PUSH;
-
-/* data type for BTA_OPC_API_PULL_EVT */
-typedef struct
-{
- BT_HDR hdr;
- BD_ADDR bd_addr;
- char *p_path;
-} tBTA_OPC_API_PULL;
-
-/* data type for BTA_OPC_API_EXCH_EVT */
-typedef struct
-{
- BT_HDR hdr;
- BD_ADDR bd_addr;
- char *p_send;
- char *p_rcv_path;
-} tBTA_OPC_API_EXCH;
-
-/* data type for BTA_OPC_SDP_OK_EVT */
-typedef struct
-{
- BT_HDR hdr;
- UINT8 scn;
- UINT16 psm;
- UINT16 version;
-} tBTA_OPC_SDP_OK_EVT;
-
-/* data type for all obex events
- hdr.event contains the OPC event
-*/
-typedef struct
-{
- BT_HDR hdr;
- tOBX_HANDLE handle;
- tOBX_EVT_PARAM param;
- BT_HDR *p_pkt;
- tOBX_EVENT obx_event;
- UINT8 rsp_code;
-} tBTA_OPC_OBX_EVT;
-
-/* union of all event data types */
-typedef union
-{
- BT_HDR hdr;
- tBTA_OPC_API_ENABLE api_enable;
- tBTA_OPC_API_PUSH api_push;
- tBTA_OPC_API_PULL api_pull;
- tBTA_OPC_API_EXCH api_exch;
- tBTA_OPC_SDP_OK_EVT sdp_ok;
- tBTA_OPC_OBX_EVT obx_evt;
- tBTA_FS_CI_OPEN_EVT open_evt;
- tBTA_FS_CI_READ_EVT read_evt;
- tBTA_FS_CI_WRITE_EVT write_evt;
-} tBTA_OPC_DATA;
-
-
-/* OBX Response Packet Structure - Holds current command/response packet info */
-typedef struct
-{
- BT_HDR *p_pkt; /* (Get/Put) Holds the current OBX header for Put or Get */
- UINT8 *p_start; /* (Get/Put) Start of the Body of the packet */
- UINT16 offset; /* (Get/Put) Contains the current offset into the Body (p_start) */
- UINT16 bytes_left; /* (Get/Put) Holds bytes available leop in Obx packet */
- BOOLEAN final_pkt; /* (Get) Holds the final bit of the Put packet */
- UINT8 rsp_code;
-} tBTA_OPC_OBX_PKT;
-
-/* Power management state for OPC */
-#define BTA_OPC_PM_BUSY 0
-#define BTA_OPC_PM_IDLE 1
-
-/* OPC control block */
-typedef struct
-{
- tBTA_OPC_CBACK *p_cback; /* pointer to application callback function */
- char *p_name; /* Holds the local path and file name of pushed item */
- char *p_rcv_path; /* Holds the local path and file name of received item (card exch only) */
- tSDP_DISCOVERY_DB *p_db; /* pointer to discovery database */
- tBTA_OPC_OBX_PKT obx; /* Holds the current OBX packet information */
- int fd; /* File Descriptor of opened file */
- UINT32 obj_size; /* (Push/Pull) file length */
- tOBX_HANDLE obx_handle;
- UINT16 peer_mtu;
- BD_ADDR bd_addr;
- BOOLEAN single_op; /* if TRUE, close OBX connection when OP finishes */
- UINT8 sec_mask;
- tBTA_OPC_STATE state; /* state machine state */
- tBTA_OP_FMT format;
- UINT8 obx_oper; /* current active OBX operation PUT FILE or GET FILE */
- UINT8 to_do; /* actions to be done (push,pull) */
- UINT8 app_id;
- tBTA_OPC_STATUS status;
- tBTA_OPC_STATUS exch_status;
- BOOLEAN first_get_pkt; /* TRUE if retrieving the first packet of GET object */
- BOOLEAN cout_active; /* TRUE if call-out is currently active */
- BOOLEAN req_pending; /* TRUE if an obx request to peer is in progress */
- BOOLEAN disabling; /* TRUE if an disabling client */
- BOOLEAN sdp_pending; /* TRUE when waiting for SDP to complete */
- BOOLEAN srm; /* TRUE, to use SIngle Response Mode */
- UINT8 pm_state;
-} tBTA_OPC_CB;
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* OPC control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-extern tBTA_OPC_CB bta_opc_cb;
-#else
-extern tBTA_OPC_CB *bta_opc_cb_ptr;
-#define bta_opc_cb (*bta_opc_cb_ptr)
-#endif
-
-
-/*****************************************************************************
-** Function prototypes
-*****************************************************************************/
-
-extern BOOLEAN bta_opc_hdl_event(BT_HDR *p_msg);
-extern void bta_opc_sm_execute(tBTA_OPC_CB *p_cb, UINT16 event,
- tBTA_OPC_DATA *p_data);
-extern void bta_opc_obx_cback (tOBX_HANDLE handle, tOBX_EVENT event,
- UINT8 rsp_code, tOBX_EVT_PARAM param,
- BT_HDR *p_pkt);
-
-/* action functions */
-extern void bta_opc_init_close(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_init_push(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_init_pull(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_init_exch(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_send_authrsp(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_ci_write(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_ci_read(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_ci_open(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_obx_conn_rsp(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_obx_put_rsp(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_obx_get_rsp(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_initialize(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_trans_cmpl(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_stop_client(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_start_client(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_free_db(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_ignore_obx(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_find_service(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_close(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_close_complete(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_set_disable(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_chk_close(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_do_pull(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_do_push(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_enable(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-
-/* miscellaneous functions */
-extern UINT8 bta_opc_send_get_req(tBTA_OPC_CB *p_cb);
-extern BOOLEAN bta_opc_proc_get_rsp(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-extern void bta_opc_cont_get_rsp(tBTA_OPC_CB *p_cb);
-extern UINT8 bta_opc_send_put_req(tBTA_OPC_CB *p_cb, BOOLEAN first_pkt);
-extern void bta_opc_start_push(tBTA_OPC_CB *p_cb);
-extern void bta_opc_listing_err(BT_HDR **p_pkt, tBTA_OPC_STATUS status);
-
-extern tBTA_OPC_STATUS bta_opc_convert_obx_to_opc_status(tOBX_STATUS obx_status);
-
-#endif /* BTA_OPC_INT_H */
diff --git a/bta/op/bta_opc_main.c b/bta/op/bta_opc_main.c
deleted file mode 100644
index cf76143..0000000
--- a/bta/op/bta_opc_main.c
+++ /dev/null
@@ -1,425 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_opc_main.c
-**
-** Description: This file contains the file transfer client main functions
-** and state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "bta_opc_int.h"
-
-/*****************************************************************************
-** Constants and types
-*****************************************************************************/
-
-/* state machine states */
-enum
-{
- BTA_OPC_DISABLED_ST = 0, /* Disabled */
- BTA_OPC_IDLE_ST, /* Idle */
- BTA_OPC_W4_CONN_ST, /* Waiting for an Obex connect response */
- BTA_OPC_CONN_ST, /* Connected - OPP Session is active */
- BTA_OPC_CLOSING_ST /* Closing is in progress */
-};
-
-/* state machine action enumeration list */
-enum
-{
- BTA_OPC_START_CLIENT,
- BTA_OPC_STOP_CLIENT,
- BTA_OPC_INIT_PULL,
- BTA_OPC_INIT_PUSH,
- BTA_OPC_INIT_EXCH,
- BTA_OPC_CI_WRITE,
- BTA_OPC_CI_READ,
- BTA_OPC_CI_OPEN,
- BTA_OPC_OBX_CONN_RSP,
- BTA_OPC_CLOSE,
- BTA_OPC_OBX_PUT_RSP,
- BTA_OPC_OBX_GET_RSP,
- BTA_OPC_TRANS_CMPL,
- BTA_OPC_FREE_DB,
- BTA_OPC_IGNORE_OBX,
- BTA_OPC_FIND_SERVICE,
- BTA_OPC_INITIALIZE,
- BTA_OPC_CLOSE_COMPLETE,
- BTA_OPC_SET_DISABLE,
- BTA_OPC_CHK_CLOSE,
- BTA_OPC_DO_PUSH,
- BTA_OPC_DO_PULL,
- BTA_OPC_ENABLE,
- BTA_OPC_IGNORE
-};
-
-/* type for action functions */
-typedef void (*tBTA_OPC_ACTION)(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data);
-
-/* action function list */
-const tBTA_OPC_ACTION bta_opc_action[] =
-{
- bta_opc_start_client,
- bta_opc_stop_client,
- bta_opc_init_pull,
- bta_opc_init_push,
- bta_opc_init_exch,
- bta_opc_ci_write,
- bta_opc_ci_read,
- bta_opc_ci_open,
- bta_opc_obx_conn_rsp,
- bta_opc_close,
- bta_opc_obx_put_rsp,
- bta_opc_obx_get_rsp,
- bta_opc_trans_cmpl,
- bta_opc_free_db,
- bta_opc_ignore_obx,
- bta_opc_find_service,
- bta_opc_initialize,
- bta_opc_close_complete,
- bta_opc_set_disable,
- bta_opc_chk_close,
- bta_opc_do_push,
- bta_opc_do_pull,
- bta_opc_enable
-};
-
-
-/* state table information */
-#define BTA_OPC_ACTIONS 2 /* number of actions */
-#define BTA_OPC_NEXT_STATE 2 /* position of next state */
-#define BTA_OPC_NUM_COLS 3 /* number of columns in state tables */
-
-/* state table for disabled state (enable is handled*/
-static const UINT8 bta_opc_st_disabled[][BTA_OPC_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* BTA_OPC_API_ENABLE_EVT */ {BTA_OPC_ENABLE, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_API_DISABLE_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_DISABLED_ST},
-/* BTA_OPC_API_DISABLE_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_DISABLED_ST},
-/* BTA_OPC_API_CLOSE_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_DISABLED_ST},
-/* BTA_OPC_API_PUSH_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_DISABLED_ST},
-/* BTA_OPC_API_PULL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_DISABLED_ST},
-/* BTA_OPC_API_EXCH_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_DISABLED_ST}
-};
-
-/* state table for idle state */
-static const UINT8 bta_opc_st_idle[][BTA_OPC_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* BTA_OPC_API_ENABLE_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_API_DISABLE_EVT */ {BTA_OPC_INITIALIZE, BTA_OPC_IGNORE, BTA_OPC_DISABLED_ST},
-/* BTA_OPC_API_CLOSE_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_API_PUSH_EVT */ {BTA_OPC_INIT_PUSH, BTA_OPC_FIND_SERVICE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_API_PULL_EVT */ {BTA_OPC_INIT_PULL, BTA_OPC_FIND_SERVICE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_API_EXCH_EVT */ {BTA_OPC_INIT_EXCH, BTA_OPC_FIND_SERVICE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_SDP_OK_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_SDP_FAIL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_CI_WRITE_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_CI_READ_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_CI_OPEN_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_OBX_CONN_RSP_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_OBX_PASSWORD_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_OBX_CLOSE_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_OBX_PUT_RSP_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_OBX_GET_RSP_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_OBX_CMPL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_CLOSE_CMPL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_DISABLE_CMPL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_DISABLED_ST}
-};
-
-/* state table for wait for authentication response state */
-static const UINT8 bta_opc_st_w4_conn[][BTA_OPC_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* BTA_OPC_API_ENABLE_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_API_DISABLE_EVT */ {BTA_OPC_SET_DISABLE, BTA_OPC_STOP_CLIENT, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_API_CLOSE_EVT */ {BTA_OPC_STOP_CLIENT, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_API_PUSH_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_API_PULL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_API_EXCH_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_SDP_OK_EVT */ {BTA_OPC_FREE_DB, BTA_OPC_START_CLIENT, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_SDP_FAIL_EVT */ {BTA_OPC_FREE_DB, BTA_OPC_CLOSE_COMPLETE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_CI_WRITE_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_CI_READ_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_CI_OPEN_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_OBX_CONN_RSP_EVT */ {BTA_OPC_OBX_CONN_RSP, BTA_OPC_IGNORE, BTA_OPC_CONN_ST},
-/* BTA_OPC_OBX_PASSWORD_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_STOP_CLIENT, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_OBX_CLOSE_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_CLOSE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_OBX_PUT_RSP_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_IGNORE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_OBX_GET_RSP_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_IGNORE, BTA_OPC_W4_CONN_ST},
-/* BTA_OPC_OBX_CMPL_EVT */ {BTA_OPC_TRANS_CMPL, BTA_OPC_STOP_CLIENT, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_CLOSE_CMPL_EVT */ {BTA_OPC_CLOSE_COMPLETE,BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_DISABLE_CMPL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_DISABLED_ST}
-};
-
-/* state table for open state */
-static const UINT8 bta_opc_st_connected[][BTA_OPC_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* BTA_OPC_API_ENABLE_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_CONN_ST},
-/* BTA_OPC_API_DISABLE_EVT */ {BTA_OPC_SET_DISABLE, BTA_OPC_STOP_CLIENT, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_API_CLOSE_EVT */ {BTA_OPC_STOP_CLIENT, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_API_PUSH_EVT */ {BTA_OPC_INIT_PUSH, BTA_OPC_DO_PUSH, BTA_OPC_CONN_ST},
-/* BTA_OPC_API_PULL_EVT */ {BTA_OPC_INIT_PULL, BTA_OPC_DO_PULL, BTA_OPC_CONN_ST},
-/* BTA_OPC_API_EXCH_EVT */ {BTA_OPC_INIT_EXCH, BTA_OPC_DO_PUSH, BTA_OPC_CONN_ST},
-/* BTA_OPC_SDP_OK_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_CONN_ST},
-/* BTA_OPC_SDP_FAIL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_CONN_ST},
-/* BTA_OPC_CI_WRITE_EVT */ {BTA_OPC_CI_WRITE, BTA_OPC_IGNORE, BTA_OPC_CONN_ST},
-/* BTA_OPC_CI_READ_EVT */ {BTA_OPC_CI_READ, BTA_OPC_IGNORE, BTA_OPC_CONN_ST},
-/* BTA_OPC_CI_OPEN_EVT */ {BTA_OPC_CI_OPEN, BTA_OPC_IGNORE, BTA_OPC_CONN_ST},
-/* BTA_OPC_OBX_CONN_RSP_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_IGNORE, BTA_OPC_CONN_ST},
-/* BTA_OPC_OBX_PASSWORD_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_STOP_CLIENT, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_OBX_CLOSE_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_CLOSE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_OBX_PUT_RSP_EVT */ {BTA_OPC_OBX_PUT_RSP, BTA_OPC_IGNORE, BTA_OPC_CONN_ST},
-/* BTA_OPC_OBX_GET_RSP_EVT */ {BTA_OPC_OBX_GET_RSP, BTA_OPC_IGNORE, BTA_OPC_CONN_ST},
-/* BTA_OPC_OBX_CMPL_EVT */ {BTA_OPC_TRANS_CMPL, BTA_OPC_CHK_CLOSE, BTA_OPC_CONN_ST},
-/* BTA_OPC_CLOSE_CMPL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_CONN_ST},
-/* BTA_OPC_DISABLE_CMPL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_DISABLED_ST}
-};
-
-/* state table for closing state */
-static const UINT8 bta_opc_st_closing[][BTA_OPC_NUM_COLS] =
-{
-/* Event Action 1 Action 2 Next state */
-/* BTA_OPC_API_ENABLE_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_API_DISABLE_EVT */ {BTA_OPC_SET_DISABLE, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_API_CLOSE_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_API_PUSH_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_API_PULL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_API_EXCH_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_SDP_OK_EVT */ {BTA_OPC_FREE_DB, BTA_OPC_CLOSE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_SDP_FAIL_EVT */ {BTA_OPC_FREE_DB, BTA_OPC_CLOSE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_CI_WRITE_EVT */ {BTA_OPC_CLOSE_COMPLETE,BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_CI_READ_EVT */ {BTA_OPC_CLOSE_COMPLETE,BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_CI_OPEN_EVT */ {BTA_OPC_CLOSE_COMPLETE,BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_OBX_CONN_RSP_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_STOP_CLIENT, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_OBX_PASSWORD_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_OBX_CLOSE_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_CLOSE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_OBX_PUT_RSP_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_OBX_GET_RSP_EVT */ {BTA_OPC_IGNORE_OBX, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_OBX_CMPL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_CLOSING_ST},
-/* BTA_OPC_CLOSE_CMPL_EVT */ {BTA_OPC_CLOSE_COMPLETE,BTA_OPC_IGNORE, BTA_OPC_IDLE_ST},
-/* BTA_OPC_DISABLE_CMPL_EVT */ {BTA_OPC_IGNORE, BTA_OPC_IGNORE, BTA_OPC_DISABLED_ST}
-};
-
-/* type for state table */
-typedef const UINT8 (*tBTA_OPC_ST_TBL)[BTA_OPC_NUM_COLS];
-
-/* state table */
-const tBTA_OPC_ST_TBL bta_opc_st_tbl[] =
-{
- bta_opc_st_disabled,
- bta_opc_st_idle,
- bta_opc_st_w4_conn,
- bta_opc_st_connected,
- bta_opc_st_closing
-};
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* OPC control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-tBTA_OPC_CB bta_opc_cb;
-#endif
-
-#if BTA_OPC_DEBUG == TRUE
-static char *opc_evt_code(tBTA_OPC_INT_EVT evt_code);
-static char *opc_state_code(tBTA_OPC_STATE state_code);
-#endif
-
-/*******************************************************************************
-**
-** Function bta_opc_sm_execute
-**
-** Description State machine event handling function for OPC
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_sm_execute(tBTA_OPC_CB *p_cb, UINT16 event, tBTA_OPC_DATA *p_data)
-{
- tBTA_OPC_ST_TBL state_table;
- UINT8 action;
- int i;
-
- /* look up the state table for the current state */
- state_table = bta_opc_st_tbl[p_cb->state];
-
- event &= 0x00FF;
-
- /* set next state */
- p_cb->state = state_table[event][BTA_OPC_NEXT_STATE];
-
- /* execute action functions */
- for (i = 0; i < BTA_OPC_ACTIONS; i++)
- {
- if ((action = state_table[event][i]) != BTA_OPC_IGNORE)
- {
- (*bta_opc_action[action])(p_cb, p_data);
- }
- else
- {
- break;
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_hdl_event
-**
-** Description File transfer server main event handling function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BOOLEAN bta_opc_hdl_event(BT_HDR *p_msg)
-{
- tBTA_OPC_CB *p_cb = &bta_opc_cb;
-
-#if BTA_OPC_DEBUG == TRUE
- tBTA_OPC_STATE in_state = p_cb->state;
- APPL_TRACE_DEBUG3("OPC Event Handler: State 0x%02x [%s], Event [%s]", in_state,
- opc_state_code(in_state),
- opc_evt_code(p_msg->event));
-#endif
-
- bta_opc_sm_execute(p_cb, p_msg->event, (tBTA_OPC_DATA *) p_msg);
-
- if ( p_cb->state == BTA_OPC_CONN_ST )
- {
- if (( p_cb->pm_state == BTA_OPC_PM_IDLE )
- &&( p_cb->obx_oper != OPC_OP_NONE ))
- {
- /* inform power manager */
- APPL_TRACE_DEBUG0("BTA OPC informs DM/PM busy state");
- bta_sys_busy( BTA_ID_OPC, p_cb->app_id, p_cb->bd_addr );
- p_cb->pm_state = BTA_OPC_PM_BUSY;
- }
- else if (( p_cb->pm_state == BTA_OPC_PM_BUSY )
- &&( p_cb->obx_oper == OPC_OP_NONE ))
- {
- /* inform power manager */
- APPL_TRACE_DEBUG0("BTA OPC informs DM/PM idle state");
- bta_sys_idle( BTA_ID_OPC ,p_cb->app_id, p_cb->bd_addr);
- p_cb->pm_state = BTA_OPC_PM_IDLE;
- }
- }
- else if ( p_cb->state == BTA_OPC_IDLE_ST )
- {
- /* initialize power management state */
- p_cb->pm_state = BTA_OPC_PM_BUSY;
- }
-
-#if BTA_OPC_DEBUG == TRUE
- if (in_state != p_cb->state)
- {
- APPL_TRACE_DEBUG3("OPC State Change: [%s] -> [%s] after Event [%s]",
- opc_state_code(in_state),
- opc_state_code(p_cb->state),
- opc_evt_code(p_msg->event));
- }
-#endif
-
- return (TRUE);
-}
-
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if BTA_OPC_DEBUG == TRUE
-
-/*******************************************************************************
-**
-** Function opc_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *opc_evt_code(tBTA_OPC_INT_EVT evt_code)
-{
- switch(evt_code)
- {
- case BTA_OPC_API_ENABLE_EVT:
- return "BTA_OPC_API_ENABLE_EVT";
- case BTA_OPC_API_DISABLE_EVT:
- return "BTA_OPC_API_DISABLE_EVT";
- case BTA_OPC_API_CLOSE_EVT:
- return "BTA_OPC_API_CLOSE_EVT";
- case BTA_OPC_API_PUSH_EVT:
- return "BTA_OPC_API_PUSH_EVT";
- case BTA_OPC_API_PULL_EVT:
- return "BTA_OPC_API_PULL_EVT";
- case BTA_OPC_API_EXCH_EVT:
- return "BTA_OPC_API_EXCH_EVT";
- case BTA_OPC_SDP_OK_EVT:
- return "BTA_OPC_SDP_OK_EVT";
- case BTA_OPC_SDP_FAIL_EVT:
- return "BTA_OPC_SDP_FAIL_EVT";
- case BTA_OPC_CI_WRITE_EVT:
- return "BTA_OPC_CI_WRITE_EVT";
- case BTA_OPC_CI_READ_EVT:
- return "BTA_OPC_CI_READ_EVT";
- case BTA_OPC_CI_OPEN_EVT:
- return "BTA_OPC_CI_OPEN_EVT";
- case BTA_OPC_OBX_CONN_RSP_EVT:
- return "BTA_OPC_OBX_CONN_RSP_EVT";
- case BTA_OPC_OBX_PASSWORD_EVT:
- return "BTA_OPC_OBX_PASSWORD_EVT";
- case BTA_OPC_OBX_CLOSE_EVT:
- return "BTA_OPC_OBX_CLOSE_EVT";
- case BTA_OPC_OBX_PUT_RSP_EVT:
- return "BTA_OPC_OBX_PUT_RSP_EVT";
- case BTA_OPC_OBX_GET_RSP_EVT:
- return "BTA_OPC_OBX_GET_RSP_EVT";
- case BTA_OPC_OBX_CMPL_EVT:
- return "BTA_OPC_OBX_CMPL_EVT";
- case BTA_OPC_CLOSE_CMPL_EVT:
- return "BTA_OPC_CLOSE_CMPL_EVT";
- case BTA_OPC_DISABLE_CMPL_EVT:
- return "BTA_OPC_DISABLE_CMPL_EVT";
- default:
- return "unknown OPC event code";
- }
-}
-
-/*******************************************************************************
-**
-** Function opc_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *opc_state_code(tBTA_OPC_STATE state_code)
-{
- switch(state_code)
- {
- case BTA_OPC_DISABLED_ST:
- return "BTA_OPC_DISABLED_ST";
- case BTA_OPC_IDLE_ST:
- return "BTA_OPC_IDLE_ST";
- case BTA_OPC_W4_CONN_ST:
- return "BTA_OPC_W4_CONN_ST";
- case BTA_OPC_CONN_ST:
- return "BTA_OPC_CONN_ST";
- case BTA_OPC_CLOSING_ST:
- return "BTA_OPC_CLOSING_ST";
- default:
- return "unknown OPC state code";
- }
-}
-
-#endif /* Debug Functions */
diff --git a/bta/op/bta_opc_utils.c b/bta/op/bta_opc_utils.c
deleted file mode 100644
index 82e626c..0000000
--- a/bta/op/bta_opc_utils.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_opc_utils.c
-**
-** Description: This file implements object store functions for the
-** file transfer server.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#include "bta_opc_int.h"
-#include "bta_fs_api.h"
-#include "bta_fs_co.h"
-#include "gki.h"
-#include "utl.h"
-
-/*******************************************************************************
-** Constants
-*******************************************************************************/
-
-/*******************************************************************************
-** Local Function Prototypes
-*******************************************************************************/
-
-/*******************************************************************************
-* Macros for OPC
-*******************************************************************************/
-
-/*******************************************************************************
-* Exported Functions
-*******************************************************************************/
-/*******************************************************************************
-**
-** Function bta_opc_send_get_req
-**
-** Description Processes a Get File Operation.
-**
-** Parameters p_cb - Pointer to the OPC control block
-**
-** Returns (UINT8) OBX response code
-**
-*******************************************************************************/
-UINT8 bta_opc_send_get_req(tBTA_OPC_CB *p_cb)
-{
- tBTA_OPC_OBX_PKT *p_obx = &p_cb->obx;
- UINT8 rsp_code = OBX_RSP_FAILED;
-
- utl_freebuf((void**)&p_obx->p_pkt);
- if ((p_obx->p_pkt = OBX_HdrInit(p_cb->obx_handle, p_cb->peer_mtu)) != NULL)
- {
- /* If first request add the Type Header to the request */
- if (p_cb->first_get_pkt == TRUE)
- {
- p_cb->obx_oper = OPC_OP_PULL_OBJ;
- p_cb->to_do &= ~BTA_OPC_PULL_MASK;
- OBX_AddTypeHdr(p_obx->p_pkt, "text/x-vcard");
- }
-
- if ((OBX_GetReq(p_cb->obx_handle, TRUE, p_obx->p_pkt)) == OBX_SUCCESS)
- {
- rsp_code = OBX_RSP_OK;
- p_obx->p_pkt = NULL;
- p_cb->req_pending = TRUE;
- }
- }
-
- return (rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_cont_get_rsp
-**
-** Description Continues an obex get response packet.
-** This function is called upon completion of a file open or
-** a file write event.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_cont_get_rsp(tBTA_OPC_CB *p_cb)
-{
- tBTA_OPC_OBX_EVT obx_evt;
- tBTA_OPC_OBX_PKT *p_obx = &p_cb->obx;
- UINT16 body_size;
- BOOLEAN end;
-
- /* Read the body header from the obx packet if it exists */
- if (OBX_ReadBodyHdr(p_obx->p_pkt, &p_obx->p_start, &body_size, &end))
- {
- p_obx->final_pkt = end;
- if (body_size)
- {
- /* Data to be written */
- p_obx->offset = body_size; /* Save write size for comparison */
- p_cb->cout_active = TRUE;
- bta_fs_co_write(p_cb->fd, p_obx->p_start, body_size,
- BTA_OPC_CI_WRITE_EVT, 0, p_cb->app_id);
- return;
- }
- }
-
- /* Empty Body; send next request or finished */
- if (!p_obx->final_pkt)
- {
- bta_opc_send_get_req(p_cb);
- }
- else /* Done getting object */
- {
- memset(&obx_evt, 0, sizeof(tBTA_OPC_OBX_EVT));
- obx_evt.rsp_code = OBX_RSP_OK;
- bta_opc_sm_execute(p_cb, BTA_OPC_OBX_CMPL_EVT, (tBTA_OPC_DATA *) &obx_evt);
- utl_freebuf((void**)&p_obx->p_pkt);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_proc_get_rsp
-**
-** Description Processes an obex get response packet.
-** Initiates a file open if no errors.
-**
-**
-** Returns BOOLEAN - TRUE if obex packet is to be freed
-**
-*******************************************************************************/
-BOOLEAN bta_opc_proc_get_rsp(tBTA_OPC_CB *p_cb, tBTA_OPC_DATA *p_data)
-{
- tBTA_OPC_OBX_EVT *p_evt = &p_data->obx_evt;
- tBTA_OPC_OBX_PKT *p_obx = &p_cb->obx;
- char *p_filename;
-
- if (p_evt->rsp_code == OBX_RSP_OK || p_evt->rsp_code == OBX_RSP_CONTINUE)
- {
- /* The get the file name */
- if (!OBX_ReadUtf8NameHdr(p_obx->p_pkt, (UINT8 *) p_cb->p_name,
- p_bta_fs_cfg->max_file_len))
- BCM_STRNCPY_S(p_cb->p_name, p_bta_fs_cfg->max_path_len+1, OPC_DEF_RCV_NAME, sizeof(OPC_DEF_RCV_NAME)+1);
-
- /* If length header exists, save the file length */
- if (!OBX_ReadLengthHdr(p_obx->p_pkt, &p_cb->obj_size))
- p_cb->obj_size = BTA_FS_LEN_UNKNOWN;
-
- /* Build the file name with a fully qualified path */
- if ((p_filename = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- sprintf(p_filename, "%s%c%s", p_cb->p_rcv_path,
- p_bta_fs_cfg->path_separator,
- p_cb->p_name);
-
- p_cb->cout_active = TRUE;
- bta_fs_co_open(p_filename,
- (BTA_FS_O_RDWR | BTA_FS_O_CREAT | BTA_FS_O_TRUNC),
- p_cb->obj_size, BTA_OPC_CI_OPEN_EVT, p_cb->app_id);
-
- GKI_freebuf(p_filename);
- return FALSE; /* Do not free the obex packet until data is written */
- }
- else
- p_evt->rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
-
- /* Server returned an error or out of memory to process request */
- bta_opc_sm_execute(p_cb, BTA_OPC_OBX_CMPL_EVT, p_data);
-
- return TRUE;
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_send_put_req
-**
-** Description Initiates/Continues a Put Object Operation.
-** Builds a new OBX packet, and initiates a read operation.
-**
-** Parameters p_cb - pointer to the client's control block.
-** first_pkt - TRUE if initial PUT request to server.
-**
-**
-** Returns UINT8 OBX response code
-**
-*******************************************************************************/
-UINT8 bta_opc_send_put_req(tBTA_OPC_CB *p_cb, BOOLEAN first_pkt)
-{
- tBTA_OPC_OBX_PKT *p_obx = &p_cb->obx;
- UINT8 rsp_code = OBX_RSP_FAILED;
- char *p_ch;
-
- utl_freebuf((void**)&p_obx->p_pkt);
- if ((p_obx->p_pkt = OBX_HdrInit(p_cb->obx_handle, OBX_LRG_DATA_POOL_SIZE)) != NULL)
- {
- /* Add length header if it exists; No body in first packet */
- if (first_pkt)
- {
- /* Add the Name Header to the request */
- /* Find the beginning of the name (excluding the path) */
- p_ch = strrchr(p_cb->p_name, (int) p_bta_fs_cfg->path_separator);
- if (p_ch == NULL)
- p_ch = p_cb->p_name;
-
- if (p_ch && p_ch[1] != '\0')
- {
- OBX_AddUtf8NameHdr(p_obx->p_pkt, (UINT8 *) (&p_ch[1]));
-
- /* Add the length header if known */
- if (p_cb->obj_size != BTA_FS_LEN_UNKNOWN)
- {
- OBX_AddLengthHdr(p_obx->p_pkt, p_cb->obj_size);
- }
-
- /* Add the type header if known */
- switch (p_cb->format)
- {
- case BTA_OP_VCARD30_FMT:
- case BTA_OP_VCARD21_FMT:
- OBX_AddTypeHdr(p_obx->p_pkt, "text/x-vcard");
- break;
- case BTA_OP_VCAL_FMT:
- case BTA_OP_ICAL_FMT:
- OBX_AddTypeHdr(p_obx->p_pkt, "text/x-vcalendar");
- break;
- case BTA_OP_VNOTE_FMT:
- OBX_AddTypeHdr(p_obx->p_pkt, "text/x-vnote");
- break;
- case BTA_OP_VMSG_FMT:
- OBX_AddTypeHdr(p_obx->p_pkt, "text/x-vmessage");
- break;
- }
-
- OBX_PutReq(p_cb->obx_handle, FALSE, p_obx->p_pkt);
- p_obx->p_pkt = NULL;
- p_cb->req_pending = TRUE;
- rsp_code = OBX_RSP_OK;
- }
- else
- APPL_TRACE_ERROR1("Invalid file name [%s] feed, PutReq NOT sent.", p_cb->p_name);
-
- }
- else /* A continuation packet so read object data */
- {
- /* Add the start of the Body Header */
- p_obx->offset = 0;
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
-
- /* Read in the first packet's worth of data */
- p_cb->cout_active = TRUE;
- bta_fs_co_read(p_cb->fd, &p_obx->p_start[p_obx->offset],
- p_obx->bytes_left, BTA_OPC_CI_READ_EVT, 0, p_cb->app_id);
- rsp_code = OBX_RSP_OK;
- }
- }
-
- return (rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_start_push
-**
-** Description Push an object to connected server.
-** Opens the object to be transferred to the server.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_opc_start_push(tBTA_OPC_CB *p_cb)
-{
- p_cb->to_do &= ~BTA_OPC_PUSH_MASK;
- p_cb->obx_oper = OPC_OP_PUSH_OBJ;
- p_cb->cout_active = TRUE;
-
- bta_fs_co_open(p_cb->p_name, BTA_FS_O_RDONLY, 0, BTA_OPC_CI_OPEN_EVT,
- p_cb->app_id);
-}
-
-/*******************************************************************************
-**
-** Function bta_opc_convert_obx_to_opc_status
-**
-** Description Convert OBX response code into BTA OPC status code.
-**
-** Returns void
-**
-*******************************************************************************/
-tBTA_OPC_STATUS bta_opc_convert_obx_to_opc_status(tOBX_STATUS obx_status)
-{
- tBTA_OPC_STATUS status;
-
- switch (obx_status)
- {
- case OBX_RSP_OK:
- case OBX_RSP_CONTINUE:
- status = BTA_OPC_OK;
- break;
- case OBX_RSP_UNAUTHORIZED:
- status = BTA_OPC_NO_PERMISSION;
- break;
- case OBX_RSP_NOT_FOUND:
- status = BTA_OPC_NOT_FOUND;
- break;
- case OBX_RSP_SERVICE_UNAVL:
- status = BTA_OPC_SRV_UNAVAIL;
- break;
- case OBX_RSP_FORBIDDEN:
- status = BTA_OPC_RSP_FORBIDDEN;
- break;
- case OBX_RSP_NOT_ACCEPTABLE:
- status = BTA_OPC_RSP_NOT_ACCEPTABLE;
- break;
- default:
- status = BTA_OPC_FAIL;
- }
-
- return (status);
-}
diff --git a/bta/op/bta_ops_act.c b/bta/op/bta_ops_act.c
deleted file mode 100644
index 5409cf1..0000000
--- a/bta/op/bta_ops_act.c
+++ /dev/null
@@ -1,793 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ops_act.c
-**
-** Description: This file contains the object transfer action
-** functions for the state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_OP_INCLUDED) && (BTA_OP_INCLUDED)
-
-#include <string.h>
-#include "gki.h"
-#include "bta_sys.h"
-#include "obx_api.h"
-#include "bta_op_api.h"
-#include "bta_ops_int.h"
-#include "bta_fs_api.h"
-#include "bta_fs_co.h"
-#include "bta_fs_ci.h"
-#include "rfcdefs.h" /* BT_PSM_RFCOMM */
-#include "btm_api.h"
-#include "utl.h"
-#include "goep_util.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-#define BTA_OPS_NUM_FMTS 7
-#define BTA_OPS_PROTOCOL_COUNT 3
-
-/* object format lookup table */
-const tBTA_OP_FMT bta_ops_obj_fmt[] =
-{
- BTA_OP_VCARD21_FMT,
- BTA_OP_VCARD30_FMT,
- BTA_OP_VCAL_FMT,
- BTA_OP_ICAL_FMT,
- BTA_OP_VNOTE_FMT,
- BTA_OP_VMSG_FMT,
- BTA_OP_OTHER_FMT
-};
-
-/*****************************************************************************
-** Local Function prototypes
-*****************************************************************************/
-#if BTA_OPS_DEBUG == TRUE
-static char *ops_obx_evt_code(tOBX_EVENT evt_code);
-#endif
-
-/*****************************************************************************
-** Action Functions
-*****************************************************************************/
-/*******************************************************************************
-**
-** Function bta_ops_enable
-**
-** Description Perform necessary operations to enable object push.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_enable(tBTA_OPS_CB *p_cb, tBTA_OPS_API_ENABLE *p_data)
-{
- tOBX_StartParams start_params;
- UINT16 servclass = UUID_SERVCLASS_OBEX_OBJECT_PUSH;
- int i, j;
- tBTA_UTL_COD cod;
- tOBX_STATUS status;
- UINT8 desc_type[BTA_OPS_NUM_FMTS];
- UINT8 type_len[BTA_OPS_NUM_FMTS];
- UINT8 *type_value[BTA_OPS_NUM_FMTS];
- UINT16 mtu = OBX_MAX_MTU;
- UINT8 temp[4], *p;
- UINT16 version = GOEP_ENHANCED_VERSION;
-
- /* allocate scn for opp */
- p_cb->scn = BTM_AllocateSCN();
- p_cb->app_id = p_data->app_id;
-
- /* set security level */
- BTM_SetSecurityLevel (FALSE, (char *) "", BTM_SEC_SERVICE_OBEX,
- p_data->sec_mask, BT_PSM_RFCOMM,
- BTM_SEC_PROTO_RFCOMM, p_cb->scn);
-
- p_cb->psm = L2CA_AllocatePSM();
- BTM_SetSecurityLevel (FALSE, (char *) "", BTM_SEC_SERVICE_OBEX,
- p_data->sec_mask, p_cb->psm, 0, 0);
-
- memset (&start_params, 0, sizeof(tOBX_StartParams));
- start_params.p_target = NULL;
- start_params.p_cback = &bta_ops_obx_cback;
- start_params.mtu = mtu;
- start_params.scn = p_cb->scn;
- start_params.psm = p_cb->psm;
- start_params.srm = p_cb->srm;
- start_params.nonce = 0;
- start_params.authenticate = FALSE;
- start_params.auth_option = OBX_AO_NONE;
- start_params.realm_charset = OBX_RCS_ASCII;
- start_params.p_realm = NULL;
- start_params.realm_len = 0;
-
- if ((status = OBX_StartServer (&start_params, &p_cb->obx_handle)) == OBX_SUCCESS)
- {
- status = GOEP_Register (p_data->name, &p_cb->sdp_handle, p_cb->scn, 1, &servclass,
- servclass, version);
-
- /* add the psm */
- p = temp;
- UINT16_TO_BE_STREAM(p, p_cb->psm);
- SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_OBX_OVR_L2CAP_PSM, UINT_DESC_TYPE,
- (UINT32)2, (UINT8*)temp);
-
- /* add sequence for supported types */
- for (i = 0, j = 0; i < BTA_OPS_NUM_FMTS; i++)
- {
- if ((p_data->formats >> i) & 1)
- {
- type_value[j] = (UINT8 *) &bta_ops_obj_fmt[i];
- desc_type[j] = UINT_DESC_TYPE;
- type_len[j++] = 1;
- }
- }
-
- SDP_AddSequence(p_cb->sdp_handle, (UINT16) ATTR_ID_SUPPORTED_FORMATS_LIST,
- (UINT8) j, desc_type, type_len, type_value);
-
- /* set class of device */
- cod.service = BTM_COD_SERVICE_OBJ_TRANSFER;
- utl_set_device_class(&cod, BTA_UTL_SET_COD_SERVICE_CLASS);
-
- /* store formats value */
- p_cb->formats = p_data->formats;
- }
- bta_sys_add_uuid(servclass); /* UUID_SERVCLASS_OBEX_OBJECT_PUSH */
-
- p_cb->p_cback(BTA_OPS_ENABLE_EVT, NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_api_disable
-**
-** Description Perform necessary operations to disable object push.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_api_disable(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- /* Free any outstanding headers and control block memory */
- bta_ops_clean_getput(p_cb, TRUE);
-
- /* Stop the OBEX server */
- OBX_StopServer(p_cb->obx_handle);
-
- /* Remove the OPP service from the SDP database */
- SDP_DeleteRecord(p_cb->sdp_handle);
- bta_sys_remove_uuid(UUID_SERVCLASS_OBEX_OBJECT_PUSH);
-
- /* Free the allocated server channel number */
- BTM_FreeSCN(p_cb->scn);
- BTM_SecClrService(BTM_SEC_SERVICE_OBEX);
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_api_accessrsp
-**
-** Description Process the access API event.
-** If permission had been granted, continue the push or pull
-** operation.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_api_accessrsp(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- UINT8 rsp_code;
-
- /* Process the currently active access response */
- switch (p_cb->acc_active)
- {
- case BTA_OP_OPER_PUSH:
- if (p_data->api_access.oper == BTA_OP_OPER_PUSH)
- {
- if (p_data->api_access.flag == BTA_OP_ACCESS_ALLOW)
- {
- /* Save the file name with path prepended */
- BCM_STRCPY_S(p_cb->p_path, p_bta_fs_cfg->max_path_len+1, p_data->api_access.p_name);
-
- APPL_TRACE_DEBUG2("OPS PUSH OBJ: Name [%s], Length = 0x%0x (0 = n/a)",
- p_cb->p_path, p_cb->file_length);
-
- p_cb->cout_active = TRUE;
- bta_fs_co_open (p_cb->p_path,
- (BTA_FS_O_CREAT | BTA_FS_O_TRUNC | BTA_FS_O_RDWR),
- p_cb->file_length, BTA_OPS_CI_OPEN_EVT,
- p_cb->app_id);
- }
- else /* Access denied or Unsupported */
- {
- rsp_code = (p_data->api_access.flag == BTA_OP_ACCESS_NONSUP)
- ? OBX_RSP_UNSUPTD_TYPE : OBX_RSP_UNAUTHORIZED;
- bta_ops_clean_getput(p_cb, TRUE);
- OBX_PutRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- }
- p_cb->acc_active = 0;
- }
-
- break;
-
- case BTA_OP_OPER_PULL:
- if (p_data->api_access.oper == BTA_OP_OPER_PULL)
- {
- if (p_data->api_access.flag == BTA_OP_ACCESS_ALLOW)
- {
- /* Save the file name with path prepended */
- BCM_STRCPY_S(p_cb->p_path, p_bta_fs_cfg->max_path_len+1, p_data->api_access.p_name);
-
- APPL_TRACE_DEBUG1("OPS PULL VCARD: Name [%s]", p_cb->p_path);
-
- p_cb->cout_active = TRUE;
- bta_fs_co_open (p_cb->p_path, BTA_FS_O_RDONLY, 0,
- BTA_OPS_CI_OPEN_EVT, p_cb->app_id);
- }
- else /* Denied */
- bta_ops_get_obj_rsp(OBX_RSP_UNAUTHORIZED, 0);
-
- p_cb->acc_active = 0;
- }
- break;
-
- default:
- APPL_TRACE_WARNING1("OPS ACCRSP: Unknown tBTA_OP_OPER value (%d)",
- p_cb->acc_active);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_api_close
-**
-** Description Handle an api close event.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_api_close(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- /* resources will be freed at BTA_OPS_OBX_CLOSE_EVT */
- OBX_DisconnectRsp(p_cb->obx_handle, OBX_RSP_SERVICE_UNAVL, NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_ci_write
-**
-** Description Continue with the current write operation
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_ci_write(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- UINT8 rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
-
- p_cb->cout_active = FALSE;
-
- if (!p_cb->aborting)
- {
- /* Process write call-in event if operation is still active */
- if (p_cb->obx_oper == OPS_OP_PUSH_OBJ)
- {
- if (p_data->write_evt.status == BTA_FS_CO_OK)
- rsp_code = OBX_RSP_OK;
- else
- {
- if (p_data->write_evt.status == BTA_FS_CO_ENOSPACE)
- rsp_code = OBX_RSP_DATABASE_FULL;
- bta_ops_clean_getput(p_cb, TRUE);
- }
-
- /* Process response to OBX client */
- bta_ops_put_obj_rsp(rsp_code);
- }
- }
- else /* Finish aborting */
- {
- bta_ops_clean_getput(p_cb, TRUE);
- OBX_AbortRsp(p_cb->obx_handle, OBX_RSP_OK, (BT_HDR *)NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_ci_read
-**
-** Description Handles the response to a read call-out request.
-** This is called within the OBX get file request. If the
-** operation has completed, the OBX response is sent out;
-** otherwise a read for additional data is made.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_ci_read(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- tBTA_FS_CI_READ_EVT *p_revt = &p_data->read_evt;
- UINT8 rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
-
- p_cb->cout_active = FALSE;
-
- if (!p_cb->aborting)
- {
- /* Process read call-in event if operation is still active */
- if (p_cb->obx_oper == OPS_OP_PULL_OBJ && p_revt->fd == p_cb->fd)
- {
- /* Read was successful, not finished yet */
- if (p_revt->status == BTA_FS_CO_OK)
- rsp_code = OBX_RSP_CONTINUE;
-
- /* Read was successful, end of file has been detected */
- else if (p_revt->status == BTA_FS_CO_EOF)
- rsp_code = OBX_RSP_OK;
-
- /* Process response to OBX client */
- bta_ops_get_obj_rsp(rsp_code, p_revt->num_read);
- }
- }
- else /* Finish aborting */
- {
- bta_ops_clean_getput(p_cb, TRUE);
- OBX_AbortRsp(p_cb->obx_handle, OBX_RSP_OK, (BT_HDR *)NULL);
- APPL_TRACE_ERROR0("OPS PUSH OBJ: Finished ABORTING!!!");
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_ci_open
-**
-** Description Continue with the current file open operation
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_ci_open(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- tBTA_OPS_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_FS_CI_OPEN_EVT *p_open = &p_data->open_evt;
- UINT8 rsp_code = OBX_RSP_OK;
- UINT8 num_hdrs;
- BOOLEAN endpkt;
- char *p_name;
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->aborting)
- {
- bta_ops_clean_getput(p_cb, TRUE);
- OBX_AbortRsp(p_cb->obx_handle, OBX_RSP_OK, (BT_HDR *)NULL);
- return;
- }
-
- /* Only process file get or put operations */
- if (p_cb->obx_oper == OPS_OP_PULL_OBJ)
- {
- /* if file is accessible read/write the first buffer of data */
- if (p_open->status == BTA_FS_CO_OK)
- {
- p_cb->fd = p_open->fd;
- p_cb->file_length = p_open->file_size;
-
- /* Add the name and length headers */
- p_name = strrchr(p_cb->p_path, (int)p_bta_fs_cfg->path_separator);
- if (p_name == NULL)
- p_name = p_cb->p_path;
- else
- p_name++; /* increment past the file separator */
-
- OBX_AddUtf8NameHdr(p_obx->p_pkt, (UINT8 *)p_name);
-
- if (p_cb->file_length != BTA_FS_LEN_UNKNOWN)
- {
- OBX_AddLengthHdr(p_obx->p_pkt, p_cb->file_length);
- if (p_cb->file_length > 0)
- {
- rsp_code = OBX_RSP_CONTINUE;
- }
- }
-
- /* Send continuation response with the length of the file and no body */
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* Do not deallocate buffer; OBX will */
- }
- else
- {
- if (p_open->status == BTA_FS_CO_EACCES)
- rsp_code = OBX_RSP_UNAUTHORIZED;
- else /* File could not be found */
- rsp_code = OBX_RSP_NOT_FOUND;
-
- /* Send OBX response if an error occurred */
- bta_ops_get_obj_rsp(rsp_code, 0);
- }
- }
- else if (p_cb->obx_oper == OPS_OP_PUSH_OBJ)
- {
- /* if file is accessible read/write the first buffer of data */
- if (p_open->status == BTA_FS_CO_OK)
- {
- p_cb->fd = p_open->fd;
-
- /* Read in start of body if there is a body header */
- num_hdrs = OBX_ReadBodyHdr(p_obx->p_pkt, &p_obx->p_start,
- &p_obx->bytes_left, &endpkt);
- if (num_hdrs == 1)
- {
- rsp_code = OBX_RSP_PART_CONTENT; /* Do not send OBX response yet */
-
- /* Initiate the writing out of the data */
- p_cb->cout_active = TRUE;
- bta_fs_co_write(p_cb->fd, &p_obx->p_start[p_obx->offset],
- p_obx->bytes_left, BTA_OPS_CI_WRITE_EVT,
- 0, p_cb->app_id);
- }
- else if (num_hdrs > 1) /* Too many body headers to handle */
- {
- rsp_code = OBX_RSP_BAD_REQUEST;
- bta_ops_clean_getput(p_cb, TRUE);
- }
- else /* No body: respond with an OK so client can start sending the data */
- p_obx->bytes_left = 0;
- }
- else
- {
- if (p_open->status == BTA_FS_CO_EACCES)
- rsp_code = OBX_RSP_UNAUTHORIZED;
- else if (p_open->status == BTA_FS_CO_ENOSPACE)
- rsp_code = OBX_RSP_DATABASE_FULL;
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
-
- /* Send OBX response now if an error occurred or no body */
- if (rsp_code != OBX_RSP_PART_CONTENT)
- bta_ops_put_obj_rsp(rsp_code);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_obx_connect
-**
-** Description Process the OBX connect event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_obx_connect(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- tBTA_OPS_OBX_EVENT *p_evt = &p_data->obx_evt;
-
- p_cb->peer_mtu = p_evt->param.conn.mtu;
- memcpy(p_cb->bd_addr, p_evt->param.conn.peer_addr, BD_ADDR_LEN);
- APPL_TRACE_EVENT1("OPS Connect: peer mtu 0x%04x", p_cb->peer_mtu);
-
- /* done with obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-
- OBX_ConnectRsp(p_evt->handle, OBX_RSP_OK, (BT_HDR *)NULL);
-
- /* inform role manager */
- bta_sys_conn_open( BTA_ID_OPS ,p_cb->app_id, bta_ops_cb.bd_addr);
-
- /* Notify the MMI that a connection has been opened */
- p_cb->p_cback(BTA_OPS_OPEN_EVT, (tBTA_OPS*)bta_ops_cb.bd_addr);
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_obx_disc
-**
-** Description Process the OBX disconnect event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_obx_disc(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- tBTA_OPS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code;
-
- rsp_code = (p_evt->obx_event == OBX_DISCONNECT_REQ_EVT) ? OBX_RSP_OK
- : OBX_RSP_BAD_REQUEST;
-
- /* Action operation is not supported in OPP, send reject rsp and free data */
- if(p_evt->obx_event == OBX_ACTION_REQ_EVT)
- {
- OBX_ActionRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- }
-
- OBX_DisconnectRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_obx_close
-**
-** Description Process the OBX link lost event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_obx_close(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- /* finished if not waiting on a call-in function */
- if (!p_cb->cout_active)
- bta_ops_sm_execute(p_cb, BTA_OPS_CLOSE_CMPL_EVT, p_data);
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_obx_abort
-**
-** Description Process the OBX abort event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_obx_abort(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- tBTA_OPS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code = OBX_RSP_OK;
-
- utl_freebuf((void**)&p_evt->p_pkt);
-
- if (!p_cb->cout_active)
- {
- bta_ops_clean_getput(p_cb, TRUE);
- OBX_AbortRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- }
- else /* Delay the response if a call-out function is active */
- p_cb->aborting = TRUE;
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_obx_put
-**
-** Description Process the OBX push object put event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_obx_put(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- tBTA_OPS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code = OBX_RSP_CONTINUE;
-
- p_cb->obx.final_pkt = p_evt->param.put.final;
-
- /* If currently processing a push, use the current name */
- if (bta_ops_cb.obx_oper == OPS_OP_PUSH_OBJ)
- {
- bta_ops_proc_put_obj(p_evt->p_pkt);
- }
-
- /* This is a new request; allocate enough memory to hold the path (including file name) */
- else if ((p_cb->p_path = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len
- + p_bta_fs_cfg->max_file_len + 2))) != NULL)
- {
- p_cb->p_name = (p_cb->p_path + p_bta_fs_cfg->max_path_len + 1);
- p_cb->p_name[p_bta_fs_cfg->max_file_len] = '\0';
- p_cb->p_path[p_bta_fs_cfg->max_path_len] = '\0';
-
- /* read the name header if it exists */
- if (OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *)p_cb->p_name, p_bta_fs_cfg->max_file_len))
- {
- /* get file type from file name; check if supported */
- if ((p_cb->obj_fmt = bta_ops_fmt_supported(p_cb->p_name,
- p_cb->formats)) != 0)
- {
- if(!(OBX_ReadLengthHdr(p_evt->p_pkt, &p_cb->file_length)))
- p_cb->file_length = BTA_FS_LEN_UNKNOWN;
-
- p_cb->obx.p_pkt = p_evt->p_pkt; /* save the packet for later use */
- p_cb->obx.offset = 0; /* Initial offset into OBX data */
- p_cb->obx_oper = OPS_OP_PUSH_OBJ;
-
- /* request access from the app */
- bta_ops_req_app_access (BTA_OP_OPER_PUSH, p_cb);
- }
- else
- rsp_code = OBX_RSP_UNSUPTD_TYPE;
- }
- else
- rsp_code = OBX_RSP_BAD_REQUEST;
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
-
- /* Error has been detected; respond with error code */
- if (rsp_code != OBX_RSP_CONTINUE)
- {
- utl_freebuf((void**)&p_evt->p_pkt); /* done with obex packet */
- utl_freebuf((void**)&p_cb->p_path);
- p_cb->p_name = NULL;
- OBX_PutRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_obx_get
-**
-** Description Process the OBX pull vCard object.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_obx_get(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- /* this is a new request; validate it */
- if (bta_ops_cb.obx_oper != OPS_OP_PULL_OBJ)
- bta_ops_init_get_obj(p_cb, p_data);
- else /* this is a continuation request */
- bta_ops_proc_get_obj(p_cb);
-
- /* done with Obex packet */
- utl_freebuf((void**)&p_data->obx_evt.p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_close_complete
-**
-** Description Finishes the memory cleanup after a channel is closed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_close_complete(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
-
- /* inform role manager */
- bta_sys_conn_close( BTA_ID_OPS ,p_cb->app_id, bta_ops_cb.bd_addr);
-
- p_cb->cout_active = FALSE;
-
- bta_ops_clean_getput(p_cb, TRUE);
-
- /* Notify the MMI that a connection has been closed */
- p_cb->p_cback(BTA_OPS_CLOSE_EVT, (tBTA_OPS*)p_cb->bd_addr);
- memset(p_cb->bd_addr, 0, BD_ADDR_LEN);
-
- if (p_data->obx_evt.p_pkt)
- APPL_TRACE_WARNING0("OPS: OBX CLOSE CALLED WITH non-NULL Packet!!!");
-}
-
-/*****************************************************************************
-** Callback Functions
-*****************************************************************************/
-/*******************************************************************************
-**
-** Function bta_ops_obx_cback
-**
-** Description OBX callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_obx_cback (tOBX_HANDLE handle, tOBX_EVENT obx_event,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt)
-{
- tBTA_OPS_OBX_EVENT *p_obx_msg;
- UINT16 event = 0;
-
-#if BTA_OPS_DEBUG == TRUE
- APPL_TRACE_DEBUG1("OBX Event Callback: ops_obx_event[%s]", ops_obx_evt_code(obx_event));
-#endif
-
- switch(obx_event)
- {
- case OBX_CONNECT_REQ_EVT:
- event = BTA_OPS_OBX_CONN_EVT;
- break;
- case OBX_DISCONNECT_REQ_EVT:
- event = BTA_OPS_OBX_DISC_EVT;
- break;
- case OBX_PUT_REQ_EVT:
- event = BTA_OPS_OBX_PUT_EVT;
- break;
- case OBX_GET_REQ_EVT:
- event = BTA_OPS_OBX_GET_EVT;
- break;
- case OBX_ABORT_REQ_EVT:
- event = BTA_OPS_OBX_ABORT_EVT;
- break;
- case OBX_CLOSE_IND_EVT:
- event = BTA_OPS_OBX_CLOSE_EVT;
- break;
- case OBX_TIMEOUT_EVT:
- break;
- default:
- /* Unrecognized packet; disconnect the session */
- if (p_pkt)
- event = BTA_OPS_OBX_DISC_EVT;
- }
-
- /* send event to BTA, if any */
- if (event && (p_obx_msg =
- (tBTA_OPS_OBX_EVENT *) GKI_getbuf(sizeof(tBTA_OPS_OBX_EVENT))) != NULL)
- {
- p_obx_msg->hdr.event = event;
- p_obx_msg->obx_event = obx_event;
- p_obx_msg->handle = handle;
- p_obx_msg->param = param;
- p_obx_msg->p_pkt = p_pkt;
-
- bta_sys_sendmsg(p_obx_msg);
- }
-}
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if BTA_OPS_DEBUG == TRUE
-
-/*******************************************************************************
-**
-** Function ops_obx_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *ops_obx_evt_code(tOBX_EVENT evt_code)
-{
- switch(evt_code)
- {
- case OBX_CONNECT_REQ_EVT:
- return "OBX_CONNECT_REQ_EVT";
- case OBX_DISCONNECT_REQ_EVT:
- return "OBX_DISCONNECT_REQ_EVT";
- case OBX_PUT_REQ_EVT:
- return "OBX_PUT_REQ_EVT";
- case OBX_GET_REQ_EVT:
- return "OBX_GET_REQ_EVT";
- case OBX_SETPATH_REQ_EVT:
- return "OBX_SETPATH_REQ_EVT";
- case OBX_ABORT_REQ_EVT:
- return "OBX_ABORT_REQ_EVT";
- case OBX_CLOSE_IND_EVT:
- return "OBX_CLOSE_IND_EVT";
- case OBX_TIMEOUT_EVT:
- return "OBX_TIMEOUT_EVT";
- case OBX_PASSWORD_EVT:
- return "OBX_PASSWORD_EVT";
- case OBX_SESSION_REQ_EVT:
- return "OBX_SESSION_REQ_EVT";
- case OBX_ACTION_REQ_EVT:
- return "OBX_ACTION_REQ_EVT";
- default:
- return "unknown OBX event code";
- }
-}
-#endif /* Debug Functions */
-#endif /* BTA_OP_INCLUDED */
diff --git a/bta/op/bta_ops_api.c b/bta/op/bta_ops_api.c
deleted file mode 100644
index 1c09094..0000000
--- a/bta/op/bta_ops_api.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ops_api.c
-**
-** Description: This is the implementation of the API for the object
-** push server subsystem of BTA, Widcomm's Bluetooth
-** application layer for mobile phones.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_OP_INCLUDED) && (BTA_OP_INCLUDED)
-
-#include <string.h>
-#include "gki.h"
-#include "bta_sys.h"
-#include "bta_fs_api.h"
-#include "bta_op_api.h"
-#include "bta_ops_int.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-static const tBTA_SYS_REG bta_ops_reg =
-{
- bta_ops_hdl_event,
- BTA_OpsDisable
-};
-
-/*******************************************************************************
-**
-** Function BTA_OpsEnable
-**
-** Description Enable the object push server. This function must be
-** called before any other functions in the OPS API are called.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_OpsEnable(tBTA_SEC sec_mask, tBTA_OP_FMT_MASK formats,
- char *p_service_name, tBTA_OPS_CBACK *p_cback, BOOLEAN srm, UINT8 app_id)
-{
- tBTA_OPS_API_ENABLE *p_buf;
-
- GKI_sched_lock();
- /* register with BTA system manager */
- bta_sys_register(BTA_ID_OPS, &bta_ops_reg);
- GKI_sched_unlock();
-
- if ((p_buf = (tBTA_OPS_API_ENABLE *) GKI_getbuf(sizeof(tBTA_OPS_API_ENABLE))) != NULL)
- {
- p_buf->hdr.event = BTA_OPS_API_ENABLE_EVT;
- BCM_STRNCPY_S(p_buf->name, sizeof(p_buf->name), p_service_name, BTA_SERVICE_NAME_LEN);
- p_buf->name[BTA_SERVICE_NAME_LEN] = '\0';
- p_buf->p_cback = p_cback;
- p_buf->app_id = app_id;
- p_buf->formats = formats;
- p_buf->sec_mask = sec_mask;
- p_buf->srm = srm;
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpsDisable
-**
-** Description Disable the object push server. If the server is currently
-** connected to a peer device the connection will be closed.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_OpsDisable(void)
-{
- BT_HDR *p_buf;
-
- bta_sys_deregister(BTA_ID_OPS);
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_OPS_API_DISABLE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpsClose
-**
-** Description Close the current connection. This function is called if
-** the phone wishes to close the connection before the object
-** push is completed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_OpsClose(void)
-{
- BT_HDR *p_buf;
-
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_OPS_API_CLOSE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_OpsAccessRsp
-**
-** Description Sends a reply to an access request event (BTA_OPS_ACCESS_EVT).
-** This call MUST be made whenever the event occurs.
-**
-** Parameters oper - operation being accessed.
-** access - BTA_OP_ACCESS_ALLOW, BTA_OP_ACCESS_FORBID, or
-** BTA_OP_ACCESS_NONSUP.
-** p_name - Full path of file to read from (pull) or write to
-** (push).
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_OpsAccessRsp(tBTA_OP_OPER oper, tBTA_OP_ACCESS access, char *p_name)
-{
- tBTA_OPS_API_ACCESSRSP *p_buf;
-
- if ((p_buf = (tBTA_OPS_API_ACCESSRSP *)GKI_getbuf((UINT16)(sizeof(tBTA_OPS_API_ACCESSRSP)
- + p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- p_buf->flag = access;
- p_buf->oper = oper;
- p_buf->p_name = (char *)(p_buf + 1);
- if (p_name)
- {
- BCM_STRNCPY_S(p_buf->p_name, p_bta_fs_cfg->max_path_len+1, p_name, p_bta_fs_cfg->max_path_len);
- p_buf->p_name[p_bta_fs_cfg->max_path_len] = '\0';
- }
- else
- *p_buf->p_name = '\0';
-
- p_buf->hdr.event = BTA_OPS_API_ACCESSRSP_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-#endif /* BTA_OP_INCLUDED */
diff --git a/bta/op/bta_ops_int.h b/bta/op/bta_ops_int.h
deleted file mode 100644
index 733b9ae..0000000
--- a/bta/op/bta_ops_int.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ops_int.h
-**
-** Description: This is the private file for the object transfer
-** server (OPS).
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef BTA_OPS_INT_H
-#define BTA_OPS_INT_H
-
-#include "bt_target.h"
-#include "bta_sys.h"
-#include "obx_api.h"
-#include "bta_op_api.h"
-#include "bta_fs_co.h"
-#include "bta_fs_ci.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-
-/* OPS active obex operation (Valid in connected state) */
-#define OPS_OP_NONE 0
-#define OPS_OP_PULL_OBJ 1
-#define OPS_OP_PUSH_OBJ 2
-
-/* state machine events */
-enum
-{
- /* these events are handled by the state machine */
- BTA_OPS_API_DISABLE_EVT = BTA_SYS_EVT_START(BTA_ID_OPS),
-
- BTA_OPS_API_ACCESSRSP_EVT, /* Response to an access request */
- BTA_OPS_API_CLOSE_EVT, /* Close API */
- BTA_OPS_CI_OPEN_EVT, /* Response to File Open request */
- BTA_OPS_CI_WRITE_EVT, /* Response to Write request */
- BTA_OPS_CI_READ_EVT, /* Response to Read request */
- BTA_OPS_OBX_CONN_EVT, /* OBX Channel Connect Request */
- BTA_OPS_OBX_DISC_EVT, /* OBX Channel Disconnect */
- BTA_OPS_OBX_ABORT_EVT, /* OBX_operation aborted */
- BTA_OPS_OBX_CLOSE_EVT, /* OBX Channel Disconnected (Link Lost) */
- BTA_OPS_OBX_PUT_EVT, /* Write file data or delete */
- BTA_OPS_OBX_GET_EVT, /* Read file data or folder listing */
- BTA_OPS_CLOSE_CMPL_EVT, /* Finished closing channel */
-
- /* these events are handled outside the state machine */
- BTA_OPS_API_ENABLE_EVT
-};
-
-typedef UINT16 tBTA_OPS_INT_EVT;
-
-typedef UINT8 tBTA_OPS_STATE;
-
-/* data type for BTA_OPS_API_ENABLE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- char name[BTA_SERVICE_NAME_LEN + 1];
- tBTA_OPS_CBACK *p_cback;
- tBTA_OP_FMT_MASK formats;
- UINT8 sec_mask;
- BOOLEAN srm;
- UINT8 app_id;
-} tBTA_OPS_API_ENABLE;
-
-/* data type for BTA_OPS_API_ACCESSRSP_EVT */
-typedef struct
-{
- BT_HDR hdr;
- char *p_name;
- tBTA_OP_OPER oper;
- tBTA_OP_ACCESS flag;
-} tBTA_OPS_API_ACCESSRSP;
-
-/* data type for all obex events
- hdr.event contains the OPS event
-*/
-typedef struct
-{
- BT_HDR hdr;
- tOBX_HANDLE handle;
- tOBX_EVT_PARAM param;
- BT_HDR *p_pkt;
- tOBX_EVENT obx_event;
- UINT8 rsp_code;
-} tBTA_OPS_OBX_EVENT;
-
-/* union of all event data types */
-typedef union
-{
- BT_HDR hdr;
- tBTA_OPS_API_ENABLE api_enable;
- tBTA_OPS_API_ACCESSRSP api_access;
- tBTA_OPS_OBX_EVENT obx_evt;
- tBTA_FS_CI_OPEN_EVT open_evt;
- tBTA_FS_CI_READ_EVT read_evt;
- tBTA_FS_CI_WRITE_EVT write_evt;
-} tBTA_OPS_DATA;
-
-/* OBX Response Packet Structure - Holds current response packet info */
-typedef struct
-{
- BT_HDR *p_pkt; /* (Pull/Push) Holds the current OBX hdr for Push or Pull */
- UINT8 *p_start; /* (Pull/Push) Start of the Body of the packet */
- UINT16 offset; /* (Pull/Push) Contains the current offset into the Body (p_start) */
- UINT16 bytes_left; /* (Pull/Push) Holds bytes available left in Obx packet */
- BOOLEAN final_pkt; /* (Push) Holds the final bit of the Push packet */
-} tBTA_OPS_OBX_PKT;
-
-/* Power management state for OPS */
-#define BTA_OPS_PM_BUSY 0
-#define BTA_OPS_PM_IDLE 1
-
-/* OPS control block */
-typedef struct
-{
- tBTA_OPS_CBACK *p_cback; /* pointer to application callback function */
- char *p_name; /* Holds name of current operation */
- char *p_path; /* Holds path of current operation */
- tBTA_OPS_OBX_PKT obx; /* Holds the current OBX packet information */
- UINT32 sdp_handle; /* SDP record handle */
- UINT32 file_length; /* length of file being Push/Pull */
- int fd; /* File Descriptor of opened file */
- BD_ADDR bd_addr; /* Device currently connected to */
- tOBX_HANDLE obx_handle;
- UINT16 peer_mtu;
- UINT16 psm; /* PSM for Obex Over L2CAP */
- BOOLEAN srm; /* TRUE, to use SIngle Response Mode */
- UINT8 scn; /* SCN of the OPP server */
- tBTA_OP_FMT_MASK formats; /* supported object formats */
- tBTA_OPS_STATE state; /* state machine state */
- tBTA_OP_FMT obj_fmt; /* file format of received object */
- UINT8 obx_oper; /* current active OBX operation PUSH OBJ, or PULL OBJ */
- UINT8 app_id;
- tBTA_OP_OPER acc_active; /* op code when waiting for an access rsp (API) (0 not active) */
- BOOLEAN cout_active; /* TRUE when waiting for a call-in function */
- BOOLEAN aborting; /* TRUE when waiting for a call-in function */
- UINT8 pm_state;
-} tBTA_OPS_CB;
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* OPS control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-extern tBTA_OPS_CB bta_ops_cb;
-#else
-extern tBTA_OPS_CB *bta_ops_cb_ptr;
-#define bta_ops_cb (*bta_ops_cb_ptr)
-#endif
-
-
-/*****************************************************************************
-** Function prototypes
-*****************************************************************************/
-
-extern BOOLEAN bta_ops_hdl_event(BT_HDR *p_msg);
-extern void bta_ops_sm_execute(tBTA_OPS_CB *p_cb, UINT16 event, tBTA_OPS_DATA *p_data);
-extern void bta_ops_obx_cback (tOBX_HANDLE handle, tOBX_EVENT event,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt);
-
-/* action functions */
-extern void bta_ops_api_disable(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_api_accessrsp(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_api_close(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_ci_write(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_ci_read(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_ci_open(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_obx_connect(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_obx_disc(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_obx_close(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_obx_abort(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_obx_put(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_obx_get(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_gasp_err_rsp(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_close_complete(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-
-/* object store */
-extern void bta_ops_init_get_obj(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-extern void bta_ops_proc_get_obj(tBTA_OPS_CB *p_cb);
-extern void bta_ops_proc_put_obj(BT_HDR *p_pkt);
-
-/* miscellaneous functions */
-extern void bta_ops_enable(tBTA_OPS_CB *p_cb, tBTA_OPS_API_ENABLE *p_data);
-extern void bta_ops_get_obj_rsp(UINT8 rsp_code, UINT16 num_read);
-extern void bta_ops_put_obj_rsp(UINT8 rsp_code);
-extern void bta_ops_clean_getput(tBTA_OPS_CB *p_cb, BOOLEAN is_aborted);
-extern void bta_ops_discard_data(UINT16 event, tBTA_OPS_DATA *p_data);
-extern void bta_ops_req_app_access (tBTA_OP_OPER oper, tBTA_OPS_CB *p_cb);
-extern tBTA_OP_FMT bta_ops_fmt_supported(char *p, tBTA_OP_FMT_MASK fmt_mask);
-
-#endif /* BTA_OPS_INT_H */
diff --git a/bta/op/bta_ops_main.c b/bta/op/bta_ops_main.c
deleted file mode 100644
index f98b43b..0000000
--- a/bta/op/bta_ops_main.c
+++ /dev/null
@@ -1,412 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ops_main.c
-**
-** Description: This file contains the file transfer server main functions
-** and state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_OP_INCLUDED) && (BTA_OP_INCLUDED)
-
-#include <string.h>
-
-#include "bta_fs_api.h"
-#include "bta_ops_int.h"
-#include "gki.h"
-#include "obx_api.h"
-
-/*****************************************************************************
-** Constants and types
-*****************************************************************************/
-
-/* state machine states */
-enum
-{
- BTA_OPS_IDLE_ST = 0, /* Idle */
- BTA_OPS_LISTEN_ST, /* Listen - waiting for OBX/RFC connection */
- BTA_OPS_CONN_ST, /* Connected - OPP Session is active */
- BTA_OPS_CLOSING_ST /* Closing is in progress */
-};
-
-/* state machine action enumeration list */
-enum
-{
- BTA_OPS_API_DISABLE,
- BTA_OPS_API_ACCESSRSP,
- BTA_OPS_API_CLOSE,
- BTA_OPS_CI_WRITE,
- BTA_OPS_CI_READ,
- BTA_OPS_CI_OPEN,
- BTA_OPS_OBX_CONNECT,
- BTA_OPS_OBX_DISC,
- BTA_OPS_OBX_CLOSE,
- BTA_OPS_OBX_ABORT,
- BTA_OPS_OBX_PUT,
- BTA_OPS_OBX_GET,
- BTA_OPS_CLOSE_COMPLETE,
- BTA_OPS_IGNORE
-};
-
-/* type for action functions */
-typedef void (*tBTA_OPS_ACTION)(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data);
-
-/* action function list */
-const tBTA_OPS_ACTION bta_ops_action[] =
-{
- bta_ops_api_disable,
- bta_ops_api_accessrsp,
- bta_ops_api_close,
- bta_ops_ci_write,
- bta_ops_ci_read,
- bta_ops_ci_open,
- bta_ops_obx_connect,
- bta_ops_obx_disc,
- bta_ops_obx_close,
- bta_ops_obx_abort,
- bta_ops_obx_put,
- bta_ops_obx_get,
- bta_ops_close_complete
-};
-
-
-/* state table information */
-#define BTA_OPS_ACTIONS 1 /* number of actions */
-#define BTA_OPS_NEXT_STATE 1 /* position of next state */
-#define BTA_OPS_NUM_COLS 2 /* number of columns in state tables */
-
-/* state table for idle state */
-static const UINT8 bta_ops_st_idle[][BTA_OPS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_OPS_API_DISABLE_EVT */ {BTA_OPS_IGNORE, BTA_OPS_IDLE_ST},
-/* BTA_OPS_API_ACCESSRSP_EVT */ {BTA_OPS_IGNORE, BTA_OPS_IDLE_ST},
-/* BTA_OPS_API_CLOSE_EVT */ {BTA_OPS_IGNORE, BTA_OPS_IDLE_ST},
-};
-
-/* state table for obex/rfcomm connection state */
-static const UINT8 bta_ops_st_listen[][BTA_OPS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_OPS_API_DISABLE_EVT */ {BTA_OPS_API_DISABLE, BTA_OPS_IDLE_ST},
-/* BTA_OPS_API_ACCESSRSP_EVT */ {BTA_OPS_IGNORE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_API_CLOSE_EVT */ {BTA_OPS_IGNORE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_CI_OPEN_EVT */ {BTA_OPS_IGNORE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_CI_WRITE_EVT */ {BTA_OPS_IGNORE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_CI_READ_EVT */ {BTA_OPS_IGNORE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_OBX_CONN_EVT */ {BTA_OPS_OBX_CONNECT, BTA_OPS_CONN_ST},
-/* BTA_OPS_OBX_DISC_EVT */ {BTA_OPS_IGNORE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_OBX_ABORT_EVT */ {BTA_OPS_IGNORE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_OBX_CLOSE_EVT */ {BTA_OPS_IGNORE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_OBX_PUT_EVT */ {BTA_OPS_IGNORE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_OBX_GET_EVT */ {BTA_OPS_IGNORE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_CLOSE_CMPL_EVT */ {BTA_OPS_IGNORE, BTA_OPS_LISTEN_ST}
-};
-
-/* state table for open state */
-static const UINT8 bta_ops_st_connected[][BTA_OPS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_OPS_API_DISABLE_EVT */ {BTA_OPS_API_DISABLE, BTA_OPS_IDLE_ST},
-/* BTA_OPS_API_ACCESSRSP_EVT */ {BTA_OPS_API_ACCESSRSP, BTA_OPS_CONN_ST},
-/* BTA_OPS_API_CLOSE_EVT */ {BTA_OPS_API_CLOSE, BTA_OPS_CLOSING_ST},
-/* BTA_OPS_CI_OPEN_EVT */ {BTA_OPS_CI_OPEN, BTA_OPS_CONN_ST},
-/* BTA_OPS_CI_WRITE_EVT */ {BTA_OPS_CI_WRITE, BTA_OPS_CONN_ST},
-/* BTA_OPS_CI_READ_EVT */ {BTA_OPS_CI_READ, BTA_OPS_CONN_ST},
-/* BTA_OPS_OBX_CONN_EVT */ {BTA_OPS_IGNORE, BTA_OPS_CONN_ST},
-/* BTA_OPS_OBX_DISC_EVT */ {BTA_OPS_OBX_DISC, BTA_OPS_CLOSING_ST},
-/* BTA_OPS_OBX_ABORT_EVT */ {BTA_OPS_OBX_ABORT, BTA_OPS_CONN_ST},
-/* BTA_OPS_OBX_CLOSE_EVT */ {BTA_OPS_OBX_CLOSE, BTA_OPS_CLOSING_ST},
-/* BTA_OPS_OBX_PUT_EVT */ {BTA_OPS_OBX_PUT, BTA_OPS_CONN_ST},
-/* BTA_OPS_OBX_GET_EVT */ {BTA_OPS_OBX_GET, BTA_OPS_CONN_ST},
-/* BTA_OPS_CLOSE_CMPL_EVT */ {BTA_OPS_IGNORE, BTA_OPS_CONN_ST}
-};
-
-/* state table for closing state */
-static const UINT8 bta_ops_st_closing[][BTA_OPS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_OPS_API_DISABLE_EVT */ {BTA_OPS_API_DISABLE, BTA_OPS_IDLE_ST},
-/* BTA_OPS_API_ACCESSRSP_EVT */ {BTA_OPS_IGNORE, BTA_OPS_CLOSING_ST},
-/* BTA_OPS_API_CLOSE_EVT */ {BTA_OPS_IGNORE, BTA_OPS_CLOSING_ST},
-/* BTA_OPS_CI_OPEN_EVT */ {BTA_OPS_CLOSE_COMPLETE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_CI_WRITE_EVT */ {BTA_OPS_CLOSE_COMPLETE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_CI_READ_EVT */ {BTA_OPS_CLOSE_COMPLETE, BTA_OPS_LISTEN_ST},
-/* BTA_OPS_OBX_CONN_EVT */ {BTA_OPS_IGNORE, BTA_OPS_CLOSING_ST},
-/* BTA_OPS_OBX_DISC_EVT */ {BTA_OPS_IGNORE, BTA_OPS_CLOSING_ST},
-/* BTA_OPS_OBX_ABORT_EVT */ {BTA_OPS_OBX_ABORT, BTA_OPS_CLOSING_ST},
-/* BTA_OPS_OBX_CLOSE_EVT */ {BTA_OPS_OBX_CLOSE, BTA_OPS_CLOSING_ST},
-/* BTA_OPS_OBX_PUT_EVT */ {BTA_OPS_IGNORE, BTA_OPS_CLOSING_ST},
-/* BTA_OPS_OBX_GET_EVT */ {BTA_OPS_IGNORE, BTA_OPS_CLOSING_ST},
-/* BTA_OPS_CLOSE_CMPL_EVT */ {BTA_OPS_CLOSE_COMPLETE, BTA_OPS_LISTEN_ST}
-};
-
-/* type for state table */
-typedef const UINT8 (*tBTA_OPS_ST_TBL)[BTA_OPS_NUM_COLS];
-
-/* state table */
-const tBTA_OPS_ST_TBL bta_ops_st_tbl[] =
-{
- bta_ops_st_idle,
- bta_ops_st_listen,
- bta_ops_st_connected,
- bta_ops_st_closing
-};
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* OPS control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-tBTA_OPS_CB bta_ops_cb;
-#endif
-
-#if BTA_OPS_DEBUG == TRUE
-static char *ops_evt_code(tBTA_OPS_INT_EVT evt_code);
-static char *ops_state_code(tBTA_OPS_STATE state_code);
-#endif
-
-/*******************************************************************************
-**
-** Function bta_ops_sm_execute
-**
-** Description State machine event handling function for OPS
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_sm_execute(tBTA_OPS_CB *p_cb, UINT16 event, tBTA_OPS_DATA *p_data)
-{
- tBTA_OPS_ST_TBL state_table;
- UINT8 action;
- int i;
-#if BTA_OPS_DEBUG == TRUE
- tBTA_OPS_STATE in_state = bta_ops_cb.state;
- UINT16 in_event = event;
- APPL_TRACE_EVENT3("OPS Event Handler: State 0x%02x [%s], Event [%s]", in_state,
- ops_state_code(in_state),
- ops_evt_code(event));
-#endif
-
- /* look up the state table for the current state */
- state_table = bta_ops_st_tbl[p_cb->state];
-
- event &= 0x00FF;
-
- /* set next state */
- p_cb->state = state_table[event][BTA_OPS_NEXT_STATE];
-
- /* execute action functions */
- for (i = 0; i < BTA_OPS_ACTIONS; i++)
- {
- if ((action = state_table[event][i]) != BTA_OPS_IGNORE)
- {
- (*bta_ops_action[action])(p_cb, p_data);
- }
- else
- {
- /* discard ops data */
- bta_ops_discard_data(p_data->hdr.event, p_data);
- break;
- }
- }
-
-#if BTA_OPS_DEBUG == TRUE
- if (in_state != bta_ops_cb.state)
- {
- APPL_TRACE_DEBUG3("OPS State Change: [%s] -> [%s] after Event [%s]",
- ops_state_code(in_state),
- ops_state_code(bta_ops_cb.state),
- ops_evt_code(in_event));
- }
-#endif
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_api_enable
-**
-** Description Handle an api enable event. This function enables the OP
-** Server by opening an Obex/Rfcomm channel and placing it into
-** listen mode.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_ops_api_enable(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- tBTA_OPS_API_ENABLE *p_enable = &p_data->api_enable;
-
- /* initialize control block */
- memset(p_cb, 0, sizeof(tBTA_OPS_CB));
- p_cb->p_cback = p_enable->p_cback;
- p_cb->app_id = p_enable->app_id;
- p_cb->srm = p_enable->srm;
- p_cb->fd = BTA_FS_INVALID_FD;
-
- bta_ops_cb.state = BTA_OPS_LISTEN_ST;
-
- /* call enable action function */
- bta_ops_enable(p_cb, p_enable);
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_hdl_event
-**
-** Description File transfer server main event handling function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BOOLEAN bta_ops_hdl_event(BT_HDR *p_msg)
-{
-#if BTA_OPS_DEBUG == TRUE
- tBTA_OPS_STATE in_state = bta_ops_cb.state;
-#endif
-
- switch (p_msg->event)
- {
- case BTA_OPS_API_ENABLE_EVT:
-#if BTA_OPS_DEBUG == TRUE
- APPL_TRACE_EVENT3("OPS Event Handler: State 0x%02x [%s], Event [%s]", in_state,
- ops_state_code(in_state),
- ops_evt_code(p_msg->event));
-#endif
- bta_ops_api_enable(&bta_ops_cb, (tBTA_OPS_DATA *) p_msg);
-
-#if BTA_OPS_DEBUG == TRUE
- if (in_state != bta_ops_cb.state)
- {
- APPL_TRACE_DEBUG3("OPS State Change: [%s] -> [%s] after Event [%s]",
- ops_state_code(in_state),
- ops_state_code(bta_ops_cb.state),
- ops_evt_code(p_msg->event));
- }
-#endif
- break;
-
- default:
-
- bta_ops_sm_execute(&bta_ops_cb, p_msg->event, (tBTA_OPS_DATA *) p_msg);
-
- if ( bta_ops_cb.state == BTA_OPS_CONN_ST )
- {
- if (( bta_ops_cb.pm_state == BTA_OPS_PM_IDLE )
- &&( bta_ops_cb.obx_oper != OPS_OP_NONE ))
- {
- /* inform power manager */
- APPL_TRACE_DEBUG0("BTA OPS informs DM/PM busy state");
- bta_sys_busy( BTA_ID_OPS ,bta_ops_cb.app_id, bta_ops_cb.bd_addr);
- bta_ops_cb.pm_state = BTA_OPS_PM_BUSY;
- }
- else if (( bta_ops_cb.pm_state == BTA_OPS_PM_BUSY )
- &&( bta_ops_cb.obx_oper == OPS_OP_NONE ))
- {
- /* inform power manager */
- APPL_TRACE_DEBUG0("BTA OPS informs DM/PM idle state");
- bta_sys_idle( BTA_ID_OPS ,bta_ops_cb.app_id, bta_ops_cb.bd_addr);
- bta_ops_cb.pm_state = BTA_OPS_PM_IDLE;
- }
- }
- else if ( bta_ops_cb.state == BTA_OPS_LISTEN_ST )
- {
- /* initialize power management state */
- bta_ops_cb.pm_state = BTA_OPS_PM_BUSY;
- }
-
- break;
- }
-
- return (TRUE);
-}
-
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if BTA_OPS_DEBUG == TRUE
-
-/*******************************************************************************
-**
-** Function ops_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *ops_evt_code(tBTA_OPS_INT_EVT evt_code)
-{
- switch(evt_code)
- {
- case BTA_OPS_API_DISABLE_EVT:
- return "BTA_OPS_API_DISABLE_EVT";
- case BTA_OPS_API_ACCESSRSP_EVT:
- return "BTA_OPS_API_ACCESSRSP_EVT";
- case BTA_OPS_API_CLOSE_EVT:
- return "BTA_OPS_API_CLOSE_EVT";
- case BTA_OPS_CI_OPEN_EVT:
- return "BTA_OPS_CI_OPEN_EVT";
- case BTA_OPS_CI_WRITE_EVT:
- return "BTA_OPS_CI_WRITE_EVT";
- case BTA_OPS_CI_READ_EVT:
- return "BTA_OPS_CI_READ_EVT";
- case BTA_OPS_OBX_CONN_EVT:
- return "BTA_OPS_OBX_CONN_EVT";
- case BTA_OPS_OBX_DISC_EVT:
- return "BTA_OPS_OBX_DISC_EVT";
- case BTA_OPS_OBX_ABORT_EVT:
- return "BTA_OPS_OBX_ABORT_EVT";
- case BTA_OPS_OBX_CLOSE_EVT:
- return "BTA_OPS_OBX_CLOSE_EVT";
- case BTA_OPS_OBX_PUT_EVT:
- return "BTA_OPS_OBX_PUT_EVT";
- case BTA_OPS_OBX_GET_EVT:
- return "BTA_OPS_OBX_GET_EVT";
- case BTA_OPS_CLOSE_CMPL_EVT:
- return "BTA_OPS_CLOSE_CMPL_EVT";
- case BTA_OPS_API_ENABLE_EVT:
- return "BTA_OPS_API_ENABLE_EVT";
- default:
- return "unknown OPS event code";
- }
-}
-
-/*******************************************************************************
-**
-** Function ops_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *ops_state_code(tBTA_OPS_STATE state_code)
-{
- switch(state_code)
- {
- case BTA_OPS_IDLE_ST:
- return "BTA_OPS_IDLE_ST";
- case BTA_OPS_LISTEN_ST:
- return "BTA_OPS_LISTEN_ST";
- case BTA_OPS_CONN_ST:
- return "BTA_OPS_CONN_ST";
- case BTA_OPS_CLOSING_ST:
- return "BTA_OPS_CLOSING_ST";
- default:
- return "unknown OPS state code";
- }
-}
-
-#endif /* Debug Functions */
-#endif /* BTA_OP_INCLUDED */
diff --git a/bta/op/bta_ops_utils.c b/bta/op/bta_ops_utils.c
deleted file mode 100644
index eccc1e7..0000000
--- a/bta/op/bta_ops_utils.c
+++ /dev/null
@@ -1,487 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_ops_utils.c
-**
-** Description: This file implements object store functions for the
-** object transfer server.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_OP_INCLUDED) && (BTA_OP_INCLUDED)
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include "bta_fs_api.h"
-#include "bta_ops_int.h"
-#include "bta_fs_co.h"
-#include "gki.h"
-#include "utl.h"
-#include "bd.h"
-
-/*******************************************************************************
-** Constants
-*******************************************************************************/
-
-/*******************************************************************************
-** Local Function Prototypes
-*******************************************************************************/
-static int bta_ops_stricmp (const char *p_str1, const char *p_str2);
-
-/*******************************************************************************
-* Exported Functions
-*******************************************************************************/
-/*******************************************************************************
-**
-** Function bta_ops_init_get_obj
-**
-** Description Processes a begin object pull request.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_init_get_obj(tBTA_OPS_CB *p_cb, tBTA_OPS_DATA *p_data)
-{
- tBTA_OPS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code = OBX_RSP_FORBIDDEN;
- UINT16 len;
- UINT8 *p_type;
- UINT16 name_len;
-
- /* Type Hdr must be present */
- if (OBX_ReadTypeHdr(p_evt->p_pkt, &p_type, &len))
- {
- /* Type Hdr must be correct */
- if (!bta_ops_stricmp((const char *)p_type, "text/x-vcard"))
- {
- /* Erratum 385 - original OPP spec says "Name Header must not be used."
- * errara says "Name Header must be empty"
- * Be a forgiving OPP server, allow either way */
- name_len = OBX_ReadHdrLen(p_evt->p_pkt, OBX_HI_NAME);
- if((name_len == OBX_INVALID_HDR_LEN) ||/* no name header */
- (name_len == 3) /* name header is empty */ )
- {
- p_cb->obx.p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle,
- /*p_cb->peer_mtu*/OBX_CMD_POOL_SIZE);
- p_cb->p_path = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1));
-
- if (p_cb->p_path && p_cb->obx.p_pkt)
- {
- p_cb->p_path[0] = '\0';
- p_cb->p_name = p_cb->p_path;
- p_cb->obx_oper = OPS_OP_PULL_OBJ;
- p_cb->obj_fmt = BTA_OP_VCARD21_FMT;
- p_cb->file_length = BTA_FS_LEN_UNKNOWN;
-
- /* Notify the appl that a pull default card has been requested */
- bta_ops_req_app_access (BTA_OP_OPER_PULL, p_cb);
- rsp_code = OBX_RSP_CONTINUE;
- }
- else
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- }
- }
-
- /* Error has been detected; respond with error code */
- if (rsp_code != OBX_RSP_CONTINUE)
- {
- utl_freebuf((void**)&p_cb->obx.p_pkt);
- utl_freebuf((void**)&p_cb->p_path);
- p_cb->p_name = NULL;
- OBX_GetRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_proc_get_obj
-**
-** Description Processes a continuation packet for pulling a vcard.
-** Builds a response packet and initiates a read into it.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_proc_get_obj(tBTA_OPS_CB *p_cb)
-{
- tBTA_OPS_OBX_PKT *p_obx = &p_cb->obx;
-
- /* Allocate a new OBX packet */
- if ((p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle,
- /*p_cb->peer_mtu*/OBX_LRG_DATA_POOL_SIZE)) != NULL)
- {
- /* Add the start of the Body Header */
- p_obx->offset = 0;
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
-
- p_cb->cout_active = TRUE;
- bta_fs_co_read(p_cb->fd, &p_obx->p_start[p_obx->offset],
- p_obx->bytes_left, BTA_OPS_CI_READ_EVT, 0, p_cb->app_id);
- }
- else
- bta_ops_get_obj_rsp(OBX_RSP_INTRNL_SRVR_ERR, 0);
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_proc_put_obj
-**
-** Description Processes a Push Object Operation.
-** Initiates the opening of an object for writing, or continues
-** with a new Obx packet of data (continuation).
-**
-** Parameters p_pkt - Pointer to the OBX Put request
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_proc_put_obj(BT_HDR *p_pkt)
-{
- tBTA_OPS_CB *p_cb = &bta_ops_cb;
- tBTA_OPS_OBX_PKT *p_obx = &p_cb->obx;
- UINT8 num_hdrs;
- BOOLEAN endpkt;
-
- p_obx->p_pkt = p_pkt;
-
- p_obx->offset = 0; /* Initial offset into OBX data */
- /* Read in start of body if there is a body header */
- num_hdrs = OBX_ReadBodyHdr(p_obx->p_pkt, &p_obx->p_start, &p_obx->bytes_left,
- &endpkt);
- if (num_hdrs == 1)
- {
- p_cb->cout_active = TRUE;
- bta_fs_co_write(p_cb->fd, &p_obx->p_start[p_obx->offset],
- p_obx->bytes_left, BTA_OPS_CI_WRITE_EVT, 0, p_cb->app_id);
- }
- else
- {
- bta_ops_clean_getput(p_cb, TRUE);
- bta_ops_put_obj_rsp(OBX_RSP_BAD_REQUEST);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_get_obj_rsp
-**
-** Description Finishes up the end body of the object get, and sends out the
-** OBX response
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_get_obj_rsp(UINT8 rsp_code, UINT16 num_read)
-{
- tBTA_OPS_CB *p_cb = &bta_ops_cb;
- tBTA_OPS_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_OPS_PROGRESS param;
- BOOLEAN done = TRUE;
-
- /* Send the response packet if successful operation */
- if (rsp_code == OBX_RSP_OK || rsp_code == OBX_RSP_CONTINUE)
- {
- p_obx->offset += num_read;
-
- /* More to be sent */
- if (rsp_code == OBX_RSP_CONTINUE)
- {
- if (p_obx->bytes_left != num_read)
- APPL_TRACE_WARNING2("OPS Read: Requested (0x%04x), Read In (0x%04x)",
- p_obx->bytes_left, num_read);
- done = FALSE;
- }
-
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, done);
-
- /* Notify application with progress */
- if (num_read)
- {
- param.bytes = num_read;
- param.obj_size = p_cb->file_length;
- param.operation = BTA_OP_OPER_PULL;
- p_cb->p_cback(BTA_OPS_PROGRESS_EVT, (tBTA_OPS *)&param);
- }
- }
- else
- p_cb->obx_oper = OPS_OP_NONE;
-
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* Do not deallocate buffer; OBX will */
-
- /* Final response packet sent out */
- if (done)
- bta_ops_clean_getput(p_cb, FALSE);
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_put_obj_rsp
-**
-** Description Responds to a put request, and closes the object if finished
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_put_obj_rsp(UINT8 rsp_code)
-{
- tBTA_OPS_CB *p_cb = &bta_ops_cb;
- tBTA_OPS_OBX_PKT *p_obx = &p_cb->obx;
- tBTA_OPS_PROGRESS param;
- tBTA_OPS_OBJECT object;
-
- /* Finished with input packet */
- utl_freebuf((void**)&p_obx->p_pkt);
-
- if (rsp_code == OBX_RSP_OK)
- {
- /* Update application if object data was transferred */
- if (p_obx->bytes_left)
- {
- param.bytes = p_obx->bytes_left;
- param.obj_size = p_cb->file_length;
- param.operation = BTA_OP_OPER_PUSH;
- p_cb->p_cback(BTA_OPS_PROGRESS_EVT, (tBTA_OPS *)&param);
- }
-
- /* If not end of object put, set the continue response */
- if (!p_obx->final_pkt)
- rsp_code = OBX_RSP_CONTINUE;
- else /* Done - free the allocated memory */
- {
- /* callback to app with object */
- object.format = p_cb->obj_fmt;
- object.p_name = p_cb->p_name;
-
- bta_ops_clean_getput(p_cb, FALSE);
- p_cb->p_cback(BTA_OPS_OBJECT_EVT, (tBTA_OPS *) &object);
-
- }
- }
- else
- p_cb->obx_oper = OPS_OP_NONE;
-
- OBX_PutRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_req_app_access
-**
-** Description Sends an access request event to the application.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_req_app_access (tBTA_OP_OPER oper, tBTA_OPS_CB *p_cb)
-{
- tBTA_OPS_ACCESS *p_acc_evt;
- char *p_devname;
- UINT16 len;
-
- /* Notify the application that a put or get file has been requested */
- if ((p_acc_evt = (tBTA_OPS_ACCESS *)GKI_getbuf(sizeof(tBTA_OPS_ACCESS))) != NULL)
- {
- memset(p_acc_evt, 0, sizeof(tBTA_OPS_ACCESS));
- p_acc_evt->p_name = p_cb->p_name;
- p_acc_evt->size = p_cb->file_length;
- p_acc_evt->oper = p_cb->acc_active = oper;
- p_acc_evt->format = p_cb->obj_fmt;
- bdcpy(p_acc_evt->bd_addr, p_cb->bd_addr);
-
- if ((p_devname = BTM_SecReadDevName(p_cb->bd_addr)) != NULL)
- BCM_STRNCPY_S((char *)p_acc_evt->dev_name, sizeof(tBTM_BD_NAME), p_devname, BTM_MAX_REM_BD_NAME_LEN);
-
- /* Only pass the object type if Push operation */
- if (oper == BTA_OP_OPER_PUSH)
- {
- if (!OBX_ReadTypeHdr(p_cb->obx.p_pkt, (UINT8 **)&p_acc_evt->p_type, &len))
- p_acc_evt->p_type = NULL;
- }
-
- if (p_acc_evt->p_type)
- {
- APPL_TRACE_EVENT3("OPS Access Request...Name [%s], Oper [%d], Type [%s]",
- p_cb->p_name, oper, p_acc_evt->p_type);
- }
- else
- {
- APPL_TRACE_EVENT2("OPS Access Request...Name [%s], Oper [%d]",
- p_cb->p_name, oper);
- }
-
- p_cb->p_cback(BTA_OPS_ACCESS_EVT, (tBTA_OPS *)p_acc_evt);
- GKI_freebuf(p_acc_evt);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_clean_getput
-**
-** Description Cleans up the get/put resources and control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_clean_getput(tBTA_OPS_CB *p_cb, BOOLEAN is_aborted)
-{
- tBTA_FS_CO_STATUS status;
-
- /* Clean up control block */
- utl_freebuf((void**)&p_cb->obx.p_pkt);
-
- /* Close any open files */
- if (p_cb->fd >= 0)
- {
- bta_fs_co_close(p_cb->fd, p_cb->app_id);
- p_cb->fd = BTA_FS_INVALID_FD;
-
- /* Delete an aborted unfinished push file operation */
- if (is_aborted && p_cb->obx_oper == OPS_OP_PUSH_OBJ)
- {
- status = bta_fs_co_unlink(p_cb->p_path, p_cb->app_id);
- APPL_TRACE_WARNING2("OPS: Remove ABORTED Push File Operation [%s], status 0x%02x", p_cb->p_path, status);
- }
- }
-
- utl_freebuf((void**)&p_cb->p_path);
- p_cb->p_name = NULL;
-
- p_cb->obx_oper = OPS_OP_NONE;
- p_cb->obx.bytes_left = 0;
- p_cb->file_length = BTA_FS_LEN_UNKNOWN;
- p_cb->acc_active = 0;
- p_cb->aborting = FALSE;
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_fmt_supported
-**
-** Description This function determines the file type from a file name
-** and checks if the file type is supported.
-**
-**
-** Returns Format type value or zero if format unsupported.
-**
-*******************************************************************************/
-tBTA_OP_FMT bta_ops_fmt_supported(char *p, tBTA_OP_FMT_MASK fmt_mask)
-{
- char *p_suffix;
- tBTA_OP_FMT fmt = BTA_OP_OTHER_FMT;
-
- /* scan to find file suffix */
- if ((p_suffix = strrchr(p, '.')) != NULL)
- {
- p_suffix++;
- if (bta_ops_stricmp (p_suffix, "vcf") == 0)
- {
- fmt = BTA_OP_VCARD21_FMT;
- }
- else if (bta_ops_stricmp (p_suffix, "vcd") == 0)
- {
- fmt = BTA_OP_VCARD30_FMT;
- }
- else if (bta_ops_stricmp (p_suffix, "vcs") == 0)
- {
- fmt = BTA_OP_VCAL_FMT;
- }
- else if (bta_ops_stricmp (p_suffix, "ics") == 0)
- {
- fmt = BTA_OP_ICAL_FMT;
- }
- else if (bta_ops_stricmp (p_suffix, "vmg") == 0)
- {
- fmt = BTA_OP_VMSG_FMT;
- }
- else if (bta_ops_stricmp (p_suffix, "vnt") == 0)
- {
- fmt = BTA_OP_VNOTE_FMT;
- }
- }
-
- /* see if supported */
- if (fmt == BTA_OP_OTHER_FMT)
- {
- if (!(fmt_mask & BTA_OP_ANY_MASK))
- fmt = 0; /* Other types not supported */
- }
- else
- {
- if (!((1 << (fmt - 1)) & fmt_mask))
- fmt = 0;
- }
-
- return fmt;
-}
-
-/*******************************************************************************
-**
-** Function bta_ops_discard_data
-**
-** Description frees the data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_ops_discard_data(UINT16 event, tBTA_OPS_DATA *p_data)
-{
- switch(event)
- {
- case BTA_OPS_OBX_CONN_EVT:
- case BTA_OPS_OBX_DISC_EVT:
- case BTA_OPS_OBX_ABORT_EVT:
- case BTA_OPS_OBX_CLOSE_EVT:
- case BTA_OPS_OBX_PUT_EVT:
- case BTA_OPS_OBX_GET_EVT:
- utl_freebuf((void**)&p_data->obx_evt.p_pkt);
- break;
-
- default:
- /*Nothing to free*/
- break;
- }
-}
-
-/*******************************************************************************
-* Static Functions
-*******************************************************************************/
-/*******************************************************************************
-**
-** Function bta_ops_stricmp
-**
-** Description Used to compare type header
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static int bta_ops_stricmp (const char *p_str1, const char *p_str2)
-{
- UINT16 i;
- UINT16 cmplen;
-
- if (!p_str1 || !p_str2)
- return (1);
-
- cmplen = strlen(p_str1);
- if (cmplen != strlen(p_str2))
- return (1);
-
- for (i = 0; i < cmplen; i++)
- {
- if (toupper(p_str1[i]) != toupper(p_str2[i]))
- return (i+1);
- }
-
- return 0;
-}
-#endif /* BTA_OP_INCLUDED */
diff --git a/bta/pb/bta_pbs_act.c b/bta/pb/bta_pbs_act.c
deleted file mode 100644
index 98f6463..0000000
--- a/bta/pb/bta_pbs_act.c
+++ /dev/null
@@ -1,1134 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_pbs_act.c
-**
-** Description: This file contains the phone book access server
-** functions for the state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_PBS_INCLUDED) && (BTA_PBS_INCLUDED == TRUE)
-
-#include <string.h>
-#include "gki.h"
-#include "bta_sys.h"
-#include "obx_api.h"
-#include "bta_fs_api.h"
-#include "bta_pbs_api.h"
-#include "bta_pbs_int.h"
-#include "btm_api.h"
-#include "utl.h"
-#include "bd.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-#define FLAGS_ARE_MASK (OBX_SPF_BACKUP | OBX_SPF_NO_CREATE)
-#define FLAGS_ARE_ILLEGAL 0x1 /* 'Backup and Create flag combo is BAD */
-/*****************************************************************************
-** Local Function prototypes
-*****************************************************************************/
-#if BTA_PBS_DEBUG == TRUE
-static char *pbs_obx_evt_code(tOBX_EVENT evt_code);
-#endif
-
-/*****************************************************************************
-** Action Functions
-*****************************************************************************/
-/*******************************************************************************
-**
-** Function bta_pbs_api_disable
-**
-** Description Stop PBS server.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_api_disable(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- /* Free any outstanding headers and control block memory */
- bta_pbs_clean_getput(p_cb, TRUE);
-
- /* Stop the OBEX server */
- OBX_StopServer(p_cb->obx_handle);
-
- /* Remove the PBS service from the SDP database */
- SDP_DeleteRecord(p_cb->sdp_handle);
- bta_sys_remove_uuid(UUID_SERVCLASS_PBAP_PSE);
- /* Free the allocated server channel number */
- BTM_FreeSCN(p_cb->scn);
- BTM_SecClrService(BTM_SEC_SERVICE_PBAP);
-
- utl_freebuf((void**)&p_cb->p_rootpath); /* Free buffer containing root and working paths */
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_api_authrsp
-**
-** Description Pass the response to an authentication request back to the
-** client.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_api_authrsp(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- UINT8 *p_pwd = NULL;
- UINT8 *p_userid = NULL;
-
- if (p_data->auth_rsp.key_len > 0)
- p_pwd = (UINT8 *)p_data->auth_rsp.key;
- if (p_data->auth_rsp.userid_len > 0)
- p_userid = (UINT8 *)p_data->auth_rsp.userid;
-
- OBX_Password(p_cb->obx_handle, p_pwd, p_data->auth_rsp.key_len,
- p_userid, p_data->auth_rsp.userid_len);
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_api_close
-**
-** Description Handle an api close event.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_api_close(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- BD_ADDR bd_addr;
- if (OBX_GetPeerAddr(p_cb->obx_handle, bd_addr) != 0)
- {
- /* resources will be freed at BTA_PBS_OBX_CLOSE_EVT */
- OBX_DisconnectRsp(p_cb->obx_handle, OBX_RSP_SERVICE_UNAVL, NULL);
- }
- else
- {
- p_cb->p_cback(BTA_PBS_CLOSE_EVT, 0);
-}
-}
-
-
-/*******************************************************************************
-**
-** Function bta_pbs_api_accessrsp
-**
-** Description Process the access API event.
-** If permission had been granted, continue the operation,
-** otherwise stop the operation.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_api_accessrsp(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- UINT8 rsp_code = OBX_RSP_OK;
- tBTA_PBS_CO_STATUS status = BTA_PBS_CO_EACCES;
- tBTA_PBS_ACCESS_TYPE access = p_data->access_rsp.flag;
- tBTA_PBS_OPER old_acc_active = p_cb->acc_active;
- tBTA_PBS_OBX_RSP *p_rsp = NULL;
- tBTA_PBS_OBJECT objevt;
-
- if(p_cb->acc_active != p_data->access_rsp.oper )
- {
- APPL_TRACE_WARNING2("PBS ACCRSP: not match active:%d, rsp:%d",
- p_cb->acc_active, p_data->access_rsp.oper);
- return;
- }
-
- p_cb->acc_active = 0;
- /* Process the currently active access response */
- switch (old_acc_active)
- {
- case BTA_PBS_OPER_PULL_PB:
- case BTA_PBS_OPER_PULL_VCARD_ENTRY:
- if (access == BTA_PBS_ACCESS_TYPE_ALLOW)
- {
- p_cb->cout_active = TRUE;
- bta_pbs_co_open(p_cb->p_path, p_cb->obx_oper, &p_cb->pullpb_app_params);
- }
-
- /* Case where application determined requested vCard handle has been modified: Requests a new listing to clear */
- else if (access == BTA_PBS_ACCESS_TYPE_PRECONDITION && old_acc_active == BTA_PBS_OPER_PULL_VCARD_ENTRY)
- bta_pbs_get_file_rsp(OBX_RSP_PRECONDTN_FAILED, 0);
- else /* Denied */
- bta_pbs_get_file_rsp(OBX_RSP_UNAUTHORIZED, 0);
- break;
- case BTA_PBS_OPER_PULL_VCARD_LIST:
- if (access == BTA_PBS_ACCESS_TYPE_ALLOW)
- {
- /* continue with get vlist */
- bta_pbs_getvlist(p_cb->p_name);
- }
- else
- bta_pbs_get_file_rsp(OBX_RSP_UNAUTHORIZED, 0);
- break;
-
- case BTA_PBS_OPER_SET_PB: /* Request is a Change Folder */
- p_rsp = OBX_SetPathRsp;
- if (access == BTA_PBS_ACCESS_TYPE_ALLOW)
- {
- status = BTA_PBS_CO_OK;
- /* set obj type based on path */
- if (!memcmp(p_cb->p_name, BTA_PBS_PBFOLDER_NAME, sizeof(BTA_PBS_PBFOLDER_NAME)))
- p_cb->obj_type = BTA_PBS_PB_OBJ;
- if (!memcmp(p_cb->p_name, BTA_PBS_ICHFOLDER_NAME, sizeof(BTA_PBS_ICHFOLDER_NAME)))
- p_cb->obj_type = BTA_PBS_ICH_OBJ;
- if (!memcmp(p_cb->p_name, BTA_PBS_OCHFOLDER_NAME, sizeof(BTA_PBS_OCHFOLDER_NAME)))
- p_cb->obj_type = BTA_PBS_OCH_OBJ;
- if (!memcmp(p_cb->p_name, BTA_PBS_MCHFOLDER_NAME, sizeof(BTA_PBS_MCHFOLDER_NAME)))
- p_cb->obj_type = BTA_PBS_MCH_OBJ;
- if (!memcmp(p_cb->p_name, BTA_PBS_CCHFOLDER_NAME, sizeof(BTA_PBS_CCHFOLDER_NAME)))
- p_cb->obj_type = BTA_PBS_CCH_OBJ;
- BCM_STRNCPY_S(p_cb->p_workdir, p_bta_fs_cfg->max_path_len+1, p_cb->p_path, p_bta_fs_cfg->max_path_len);
- p_cb->p_workdir[p_bta_fs_cfg->max_path_len] = '\0';
- APPL_TRACE_DEBUG1("PBS: SET NEW PATH [%s]", p_cb->p_workdir);
- }
- break;
-
- default:
- p_cb->acc_active = old_acc_active;
- APPL_TRACE_WARNING1("PBS ACCRSP: Unknown tBTA_PBS_OPER value (%d)",
- p_cb->acc_active);
- break;
- }
-
- /* Set Path Done */
- if(p_rsp && old_acc_active == BTA_PBS_OPER_SET_PB)
- {
- switch (status)
- {
- case BTA_PBS_CO_OK:
- rsp_code = OBX_RSP_OK;
- break;
- case BTA_PBS_CO_EACCES:
- rsp_code = OBX_RSP_UNAUTHORIZED;
- break;
- default:
- rsp_code = OBX_RSP_SERVICE_UNAVL;
- break;
- }
- if (p_cb->p_cback)
- {
- objevt.operation = p_cb->obx_oper;
- objevt.p_name = p_cb->p_path;
- objevt.status = (status == BTA_PBS_CO_OK ? BTA_PBS_OK: BTA_PBS_FAIL);
- (p_cb->p_cback) (BTA_PBS_OPER_CMPL_EVT, (tBTA_PBS *) &objevt);
- }
- utl_freebuf((void**)&p_cb->p_name);
- utl_freebuf((void**)&p_cb->p_path);
- p_cb->obx_oper = BTA_PBS_OPER_NONE;
- (*p_rsp)(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function bta_pbs_ci_vlist_act
-**
-** Description Continue getting the current vlist entry operation
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_ci_vlist_act(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- UINT8 rsp_code;
- tBTA_PBS_CI_VLIST_EVT *p_revt = &p_data->vlist_evt;
-
- p_cb->cout_active = FALSE;
-
- /* Process vcard listing call-in event if operation is still active */
- if (p_cb->obx_oper == BTA_PBS_OPER_PULL_VCARD_LIST)
- {
- switch (p_revt->status)
- {
- case BTA_PBS_CO_OK:
- p_cb->num_vlist_idxs++;
-
- /* Valid new entry */
- if (!strcmp(p_cb->vlist.handle, ".") || !strcmp(p_cb->vlist.handle, "..")
- || p_cb->vlist.handle[0] == '\0') {
- /* don't count this entry */
- p_cb->num_vlist_idxs--;
-
- /* continue get */
- if (p_revt->final) {
- /* if it is final */
- bta_pbs_end_of_list(OBX_RSP_OK);
- } else {
- p_cb->cout_active = TRUE;
- bta_pbs_co_getvlist(p_cb->p_path, &p_cb->getvlist_app_params,
- FALSE, &p_cb->vlist);
- }
- } else if ((rsp_code = bta_pbs_add_list_entry()) == OBX_RSP_OK) {
- /* if we can add the entry */
- if (p_revt->final) {
- /* if it is final */
- bta_pbs_end_of_list(rsp_code);
- } else {
- /* continue get */
- p_cb->cout_active = TRUE;
- bta_pbs_co_getvlist(p_cb->p_path, &p_cb->getvlist_app_params,
- FALSE, &p_cb->vlist);
- }
- } else if (rsp_code == OBX_RSP_CONTINUE) {
- /* do not have enough data buffer, send obex continue to client */
- if (p_revt->final) {
- /* if this is the last VCard list entry */
- p_cb->obx.final_pkt = TRUE;
- }
- bta_pbs_end_of_list(rsp_code);
- } else {
- bta_pbs_end_of_list(rsp_code);
- }
- break;
-
- case BTA_PBS_CO_FAIL: /* Error occurred */
- bta_pbs_end_of_list(OBX_RSP_SERVICE_UNAVL);
- break;
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_ci_read
-**
-** Description Handles the response to a read call-out request.
-** This is called within the OBX get file request. If the
-** operation has completed, the OBX response is sent out;
-** otherwise a read for additional data is made.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_ci_read_act(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- tBTA_PBS_CI_READ_EVT *p_revt = &p_data->read_evt;
- UINT8 rsp_code = OBX_RSP_SERVICE_UNAVL;
-
- p_cb->cout_active = FALSE;
- if (p_cb->aborting)
- {
- bta_pbs_clean_getput(p_cb, TRUE);
- OBX_AbortRsp(p_cb->obx_handle, OBX_RSP_OK, (BT_HDR *)NULL);
- return;
- }
-
- /* Process read call-in event if operation is still active */
- if ((p_cb->obx_oper == BTA_PBS_OPER_PULL_PB || p_cb->obx_oper == BTA_PBS_OPER_PULL_VCARD_ENTRY)
- && p_revt->fd == p_cb->fd)
- {
- /* Read was successful, not finished yet */
- if (p_revt->status == BTA_PBS_CO_OK && !p_revt->final)
- rsp_code = OBX_RSP_CONTINUE;
- if (p_revt->status == BTA_PBS_CO_OK && p_revt->final)
- rsp_code = OBX_RSP_OK;
-
- /* Process response to OBX client */
- bta_pbs_get_file_rsp(rsp_code, p_revt->num_read);
- }
- else
- {
- bta_pbs_get_file_rsp(rsp_code, 0);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_ci_open
-**
-** Description Continue with the current file open operation
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_ci_open_act(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- tBTA_PBS_CI_OPEN_EVT *p_open = &p_data->open_evt;
- UINT8 rsp_code = OBX_RSP_OK;
- tBTA_PBS_OBX_PKT *p_obx = &p_cb->obx;
- UINT16 pb_size = 0, new_missed_call = 0, len=0;
- UINT8 *p, *p_start;
-
- p_cb->cout_active = FALSE;
-
- if (p_cb->aborting)
- {
- bta_pbs_clean_getput(p_cb, TRUE);
- OBX_AbortRsp(p_cb->obx_handle, OBX_RSP_OK, (BT_HDR *)NULL);
- return;
- }
-
- /* Only process file get operations */
- if (p_cb->obx_oper == BTA_PBS_OPER_PULL_PB || p_cb->obx_oper == BTA_PBS_OPER_PULL_VCARD_ENTRY)
- {
- if (p_open->status == BTA_PBS_CO_OK)
- {
- p_cb->file_length = p_open->file_size;
- p_cb->fd = p_open->fd;
-
- /* add other application header */
- if (p_cb->obx_oper == BTA_PBS_OPER_PULL_PB)
- {
- if (p_cb->pullpb_app_params.max_count == 0 ||
- p_cb->obj_type == BTA_PBS_MCH_OBJ)
- {
- p_start = OBX_AddByteStrStart(p_obx->p_pkt, &len);
- bta_pbs_co_getpbinfo(p_cb->obx_oper, p_cb->obj_type, &pb_size, &new_missed_call);
- p = p_start;
- if (p_cb->pullpb_app_params.max_count == 0)
- {
- *p++ = BTA_PBS_TAG_PB_SIZE;
- *p++ = 2;
- UINT16_TO_BE_STREAM(p, pb_size);
- /* if max count = 0, client want to know the pb size */
- p_cb->file_length = 0;
- }
- if (p_cb->obj_type == BTA_PBS_MCH_OBJ)
- {
- *p++ = BTA_PBS_TAG_NEW_MISSED_CALLS;
- *p++ = 1;
- *p++ = (UINT8) new_missed_call;
- }
- OBX_AddByteStrHdr(p_obx->p_pkt, OBX_HI_APP_PARMS, NULL, (UINT16)(p - p_start));
- }
- }
-
- if (p_cb->file_length > 0)
- {
- /* contiune to get file */
- bta_pbs_proc_get_file(p_cb->p_name, p_cb->obx_oper);
- }
- else
- {
- /* If file length is zero, add end body header */
- if (((p_cb->obx_oper == BTA_PBS_OPER_PULL_PB) && p_cb->pullpb_app_params.max_count) || p_cb->obx_oper == BTA_PBS_OPER_PULL_VCARD_ENTRY)
- {
- p_obx->offset = 0;
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, 0, TRUE);
- }
- bta_pbs_get_file_rsp(rsp_code, 0);
- }
- }
- else
- {
- if (p_open->status == BTA_PBS_CO_EACCES)
- rsp_code = OBX_RSP_UNAUTHORIZED;
- else /* File could not be found */
- rsp_code = OBX_RSP_NOT_FOUND;
-
- /* Send OBX response if an error occurred */
- bta_pbs_get_file_rsp(rsp_code, 0);
- }
- }
-
- return;
-
-}
-
-
-/*******************************************************************************
-**
-** Function bta_pbs_obx_connect
-**
-** Description Process the OBX connect event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_obx_connect(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- tBTA_PBS_OBX_EVENT *p_evt = &p_data->obx_evt;
- tBTA_PBS_OPEN open_evt;
- char *p_devname;
-
- p_cb->peer_mtu = p_evt->param.conn.mtu;
- memcpy(p_cb->bd_addr, p_evt->param.conn.peer_addr, BD_ADDR_LEN);
- APPL_TRACE_EVENT1("PBS Connect: peer mtu 0x%04x", p_cb->peer_mtu);
-
- OBX_ConnectRsp(p_evt->handle, OBX_RSP_OK, (BT_HDR *)NULL);
-
- /* Reset to the root directory */
- BCM_STRNCPY_S(p_cb->p_workdir, p_bta_fs_cfg->max_path_len+1, p_cb->p_rootpath, p_bta_fs_cfg->max_path_len);
- p_cb->p_workdir[p_bta_fs_cfg->max_path_len] = '\0';
-
- /* inform role manager */
- bta_sys_conn_open(BTA_ID_PBS ,p_cb->app_id, p_cb->bd_addr);
-
- /* Notify the MMI that a connection has been opened */
- memcpy(open_evt.bd_addr, p_evt->param.conn.peer_addr, BD_ADDR_LEN);
- if ((p_devname = BTM_SecReadDevName(p_cb->bd_addr)) != NULL)
- BCM_STRNCPY_S((char *)open_evt.dev_name, sizeof(tBTM_BD_NAME), p_devname, BTM_MAX_REM_BD_NAME_LEN);
-
- p_cb->p_cback(BTA_PBS_OPEN_EVT, (tBTA_PBS *) &open_evt);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_obx_disc
-**
-** Description Process the OBX disconnect event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_obx_disc(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- tBTA_PBS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code;
-
- rsp_code = (p_evt->obx_event == OBX_DISCONNECT_REQ_EVT) ? OBX_RSP_OK
- : OBX_RSP_BAD_REQUEST;
- OBX_DisconnectRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_obx_close
-**
-** Description Process the OBX link lost event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_obx_close(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- /* finished if not waiting on a call-in function */
- if (!p_cb->cout_active)
- bta_pbs_sm_execute(p_cb, BTA_PBS_CLOSE_CMPL_EVT, p_data);
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_obx_abort
-**
-** Description Process the OBX abort event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_obx_abort(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- tBTA_PBS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code = OBX_RSP_OK;
-
- utl_freebuf((void**)&p_evt->p_pkt);
-
- if (!p_cb->cout_active)
- {
- bta_pbs_clean_getput(p_cb, TRUE);
- OBX_AbortRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- }
- else /* Delay the response if a call-out function is active */
- p_cb->aborting = TRUE;
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_obx_password
-**
-** Description Process the OBX password request
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_obx_password(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- tBTA_PBS_OBX_EVENT *p_evt = &p_data->obx_evt;
- tBTA_PBS_AUTH *p_auth;
- BOOLEAN is_challenged;
- tOBX_AUTH_OPT options;
-
- if ((p_auth = (tBTA_PBS_AUTH *)GKI_getbuf(sizeof(tBTA_PBS_AUTH))) != NULL)
- {
- memset(p_auth, 0, sizeof(tBTA_PBS_AUTH));
-
- /* Extract user id from packet (if available) */
- if (OBX_ReadAuthParams(p_data->obx_evt.p_pkt, &p_auth->p_userid,
- &p_auth->userid_len,
- &is_challenged, &options))
- {
- if (options & OBX_AO_USR_ID)
- p_auth->userid_required = TRUE;
- }
-
-
- /* Notify application */
- p_cb->p_cback(BTA_PBS_AUTH_EVT, (tBTA_PBS *)p_auth);
-
- GKI_freebuf(p_auth);
- }
- /* Don't need OBX packet any longer */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_pbs_obx_get
-**
-** Description Process the OBX file get and folder listing events
-** If the type header is not folder listing, then pulling a file.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_obx_get(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- tBTA_PBS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT16 len;
- UINT8 *p_type;
- UINT8 *p_param;
- UINT16 param_len;
- tBTA_PBS_OPER operation = 0;
-
- /* If currently processing a GET, use the current name */
- if (bta_pbs_cb.obx_oper == BTA_PBS_OPER_PULL_VCARD_LIST)
- bta_pbs_getvlist(p_cb->p_name);
- else if (bta_pbs_cb.obx_oper == BTA_PBS_OPER_PULL_PB ||
- bta_pbs_cb.obx_oper == BTA_PBS_OPER_PULL_VCARD_ENTRY)
- bta_pbs_proc_get_file(p_cb->p_name, bta_pbs_cb.obx_oper);
- else /* This is a new request */
- {
- /* Pull out the name header if it exists */
- if ((p_cb->p_name = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_file_len + 1))) != NULL)
- {
- if (!OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *)p_cb->p_name, p_bta_fs_cfg->max_file_len))
- {
-
- GKI_freebuf(p_cb->p_name);
- p_cb->p_name = NULL;
-
-#if 0 /* Peer spec violation, but some platforms do this wrong, so relaxing requirement.
- enable this if strict error checking needed */
- utl_freebuf((void**)&p_evt->p_pkt);
- OBX_GetRsp(p_cb->obx_handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
- return;
-#endif
- }
- } else {
- OBX_GetRsp(p_cb->obx_handle, OBX_RSP_SERVICE_UNAVL, (BT_HDR *)NULL);
- utl_freebuf((void**)&p_evt->p_pkt);
- return;
- }
-
- /* See what type of operations */
- if (OBX_ReadTypeHdr(p_evt->p_pkt, &p_type, &len))
- {
- if (!memcmp(p_type, BTA_PBS_GETVCARD_LISTING_TYPE, len))
- {
-
- if ((p_cb->p_name) && strlen(p_cb->p_name))
- {
- APPL_TRACE_EVENT1("PBS VList Get: Name [%s]", p_cb->p_name);
- }
- else /* This is a peer spec violation, but allowing for better IOP */
- {
- APPL_TRACE_WARNING0("PBS OBX GET: Missing Name Header...Assuming current directory");
-
- /* Errata 1824: It is illegal to issue a PullvCardListing request with an empty
- name header from the "telecom" folder */
- if (p_cb->p_workdir && !strcmp(&(p_cb->p_workdir[strlen(p_cb->p_workdir) - 7]), "telecom"))
- {
- utl_freebuf((void**)&p_evt->p_pkt);
- OBX_GetRsp(p_cb->obx_handle, OBX_RSP_NOT_FOUND, (BT_HDR *)NULL);
- return;
- }
- }
-
- /* read application params */
- p_param = bta_pbs_read_app_params(p_evt->p_pkt, BTA_PBS_TAG_MAX_LIST_COUNT, &param_len);
- if (p_param)
- {
- BE_STREAM_TO_UINT16(p_cb->getvlist_app_params.max_count, p_param);
- }
- else
- {
- p_cb->getvlist_app_params.max_count = BTA_PBS_MAX_LIST_COUNT;
- }
-
- p_param = bta_pbs_read_app_params(p_evt->p_pkt, BTA_PBS_TAG_LIST_START_OFFSET, &param_len);
- if (p_param)
- {
- BE_STREAM_TO_UINT16(p_cb->getvlist_app_params.start_offset, p_param);
- }
- else
- {
- p_cb->getvlist_app_params.start_offset = 0;
- }
-
- p_param = bta_pbs_read_app_params(p_evt->p_pkt, BTA_PBS_TAG_ORDER, &param_len);
- if (p_param)
- {
- p_cb->getvlist_app_params.order = *p_param;
- }
- else
- {
- p_cb->getvlist_app_params.order = BTA_PBS_ORDER_INDEX;
- }
-
- p_param = bta_pbs_read_app_params(p_evt->p_pkt, BTA_PBS_TAG_SEARCH_ATTRIBUTE, &param_len);
- if (p_param)
- {
- p_cb->getvlist_app_params.attribute = *p_param;
- }
- else
- {
- p_cb->getvlist_app_params.attribute = 0;
- }
-
- p_param = bta_pbs_read_app_params(p_evt->p_pkt, BTA_PBS_TAG_SEARCH_VALUE, &param_len);
- if (p_param)
- {
- memcpy(p_cb->getvlist_app_params.p_value, p_param, param_len);
- p_cb->getvlist_app_params.value_len = param_len;
- }
- else
- {
- p_cb->getvlist_app_params.value_len = 0;
- }
-
- /* Assume downloading vCard Listing if no name */
- p_cb->obj_type = BTA_PBS_PB_OBJ;
-
- if (p_cb->p_name)
- {
-/* if (!memcmp(p_cb->p_name, BTA_PBS_PBFOLDER_NAME, sizeof(BTA_PBS_PBFOLDER_NAME)))
- p_cb->obj_type = BTA_PBS_PB_OBJ; <-- default type */
- if (!memcmp(p_cb->p_name, BTA_PBS_ICHFOLDER_NAME, sizeof(BTA_PBS_ICHFOLDER_NAME)))
- p_cb->obj_type = BTA_PBS_ICH_OBJ;
- else if (!memcmp(p_cb->p_name, BTA_PBS_OCHFOLDER_NAME, sizeof(BTA_PBS_OCHFOLDER_NAME)))
- p_cb->obj_type = BTA_PBS_OCH_OBJ;
- else if (!memcmp(p_cb->p_name, BTA_PBS_MCHFOLDER_NAME, sizeof(BTA_PBS_MCHFOLDER_NAME)))
- p_cb->obj_type = BTA_PBS_MCH_OBJ;
- else if (!memcmp(p_cb->p_name, BTA_PBS_CCHFOLDER_NAME, sizeof(BTA_PBS_CCHFOLDER_NAME)))
- p_cb->obj_type = BTA_PBS_CCH_OBJ;
- }
- bta_pbs_getvlist(p_cb->p_name);
- }
- else if (!memcmp(p_type, BTA_PBS_GETFILE_TYPE, len) ||
- !memcmp(p_type, BTA_PBS_GETVARD_ENTRY_TYPE, len))
- {
- if (!memcmp(p_type, BTA_PBS_GETFILE_TYPE, len))
- operation = BTA_PBS_OPER_PULL_PB;
- else
- operation = BTA_PBS_OPER_PULL_VCARD_ENTRY;
- /* read application params */
- if (p_cb->p_name)
- {
- APPL_TRACE_EVENT2("PBS File Get: Name [%s], operation %d", p_cb->p_name, operation);
- }
-
- p_param = bta_pbs_read_app_params(p_evt->p_pkt, BTA_PBS_TAG_FILTER, &param_len);
- if (p_param)
- {
- if (param_len == 8)
- p_param += 4; /* skip the first 4 bytes, we do not handle proprietary AttributesMask */
- BE_STREAM_TO_UINT32(p_cb->pullpb_app_params.filter, p_param);
- }
- else
- {
- p_cb->pullpb_app_params.filter = BTA_PBS_FILTER_ALL;
- }
-
- p_param = bta_pbs_read_app_params(p_evt->p_pkt, BTA_PBS_TAG_FORMAT, &param_len);
- if (p_param)
- {
- p_cb->pullpb_app_params.format = *p_param;
- }
- else
- {
- p_cb->pullpb_app_params.format = BTA_PBS_VCF_FMT_21;
- }
-
- /* set the object type for pull pb */
- if (operation == BTA_PBS_OPER_PULL_PB)
- {
- if (p_cb->p_name == NULL)
- OBX_GetRsp(p_cb->obx_handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
- else
- {
- if (!memcmp(p_cb->p_name, BTA_PBS_PULLPB_NAME, sizeof(BTA_PBS_PULLPB_NAME)))
- p_cb->obj_type = BTA_PBS_PB_OBJ;
- if (!memcmp(p_cb->p_name, BTA_PBS_PULLICH_NAME, sizeof(BTA_PBS_PULLICH_NAME)))
- p_cb->obj_type = BTA_PBS_ICH_OBJ;
- if (!memcmp(p_cb->p_name, BTA_PBS_PULLOCH_NAME, sizeof(BTA_PBS_PULLOCH_NAME)))
- p_cb->obj_type = BTA_PBS_OCH_OBJ;
- if (!memcmp(p_cb->p_name, BTA_PBS_PULLMCH_NAME, sizeof(BTA_PBS_PULLMCH_NAME)))
- p_cb->obj_type = BTA_PBS_MCH_OBJ;
- if (!memcmp(p_cb->p_name, BTA_PBS_PULLCCH_NAME, sizeof(BTA_PBS_PULLCCH_NAME)))
- p_cb->obj_type = BTA_PBS_CCH_OBJ;
- }
- }
- /* for pull pb, read app params for max list count and start offset */
- if (operation == BTA_PBS_OPER_PULL_PB)
- {
- p_param = bta_pbs_read_app_params(p_evt->p_pkt, BTA_PBS_TAG_MAX_LIST_COUNT, &param_len);
- if (p_param)
- BE_STREAM_TO_UINT16(p_cb->pullpb_app_params.max_count, p_param);
- p_param = bta_pbs_read_app_params(p_evt->p_pkt, BTA_PBS_TAG_LIST_START_OFFSET, &param_len);
- if (p_param)
- {
- BE_STREAM_TO_UINT16(p_cb->pullpb_app_params.start_offset, p_param);
- }
- else
- {
- p_cb->pullpb_app_params.start_offset = 0;
- }
- }
- bta_pbs_proc_get_file(p_cb->p_name, operation);
- }
- else {
- OBX_GetRsp(p_cb->obx_handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
- }
- }
- }
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_obx_setpath
-**
-** Description Process the PBS change directory requests
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_obx_setpath(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- tBTA_PBS_OBX_EVENT *p_evt = &p_data->obx_evt;
- UINT8 rsp_code = OBX_RSP_BAD_REQUEST;
- tOBX_SETPATH_FLAG *p_flag = &p_evt->param.sp.flag;
- tBTA_PBS_OPER pbs_op = 0;
- tBTA_PBS_OBJECT objevt;
-
- /* Verify flags and handle before accepting */
- if (p_evt->handle == p_cb->obx_handle &&
- (((*p_flag) & FLAGS_ARE_MASK) != FLAGS_ARE_ILLEGAL))
- {
- p_cb->obx_oper = BTA_PBS_OPER_SET_PB;
- p_cb->p_name = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_file_len + 1));
- p_cb->p_path = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len +
- p_bta_fs_cfg->max_file_len + 2));
- if (p_cb->p_name != NULL && p_cb->p_path != NULL)
- {
- if (!OBX_ReadUtf8NameHdr(p_evt->p_pkt, (UINT8 *)p_cb->p_name, p_bta_fs_cfg->max_file_len))
- {
- p_cb->p_name[0] = 0;
- }
-
- rsp_code = bta_pbs_chdir(p_evt->p_pkt, (BOOLEAN)((*p_flag) & OBX_SPF_BACKUP), &pbs_op);
- }
- else
- rsp_code = OBX_RSP_SERVICE_UNAVL;
- }
-
- if(pbs_op)
- {
- bta_pbs_req_app_access(pbs_op, p_cb);
- }
- else
- {
- if (p_cb->p_cback)
- {
- objevt.operation = BTA_PBS_OPER_SET_PB;
- objevt.p_name = p_cb->p_path;
- objevt.status = (rsp_code == OBX_RSP_OK ? BTA_PBS_OK: BTA_PBS_FAIL);
- (p_cb->p_cback) (BTA_PBS_OPER_CMPL_EVT, (tBTA_PBS *) &objevt);
- }
- p_cb->obx_oper = BTA_PBS_OPER_NONE;
- OBX_SetPathRsp(p_evt->handle, rsp_code, (BT_HDR *)NULL);
- utl_freebuf((void**)&p_cb->p_name);
- utl_freebuf((void**)&p_cb->p_path);
- }
-
- /* Done with Obex packet */
- utl_freebuf((void**)&p_evt->p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_appl_tout
-**
-** Description Process the PBS application timeout event
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_appl_tout(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_conn_err_rsp
-**
-** Description Process the OBX error response
-** Connect request received in wrong state, or bad request
-** from client
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_conn_err_rsp(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- OBX_ConnectRsp(p_data->obx_evt.handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_disc_err_rsp
-**
-** Description Process the OBX error response
-** Disconnect request received in wrong state, or bad request
-** from client
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_disc_err_rsp(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- OBX_DisconnectRsp(p_data->obx_evt.handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_gasp_err_rsp
-**
-** Description Process the OBX error response for Get, Abort, Setpath.
-**
-** The rsp_code field of tBTA_PBS_DATA (obx_evt) contains the
-** response code to be sent to OBEX, and the obx_event field
-** contains the current OBEX event.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_gasp_err_rsp(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- tBTA_PBS_OBX_EVENT *p_evt = &p_data->obx_evt;
-
- switch (p_evt->obx_event)
- {
- case OBX_GET_REQ_EVT:
- OBX_GetRsp(p_evt->handle, p_evt->rsp_code, (BT_HDR *)NULL);
- break;
- case OBX_SETPATH_REQ_EVT:
- OBX_SetPathRsp(p_evt->handle, p_evt->rsp_code, (BT_HDR *)NULL);
- break;
- case OBX_ABORT_REQ_EVT:
- OBX_AbortRsp(p_evt->handle, p_evt->rsp_code, (BT_HDR *)NULL);
- break;
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_close_complete
-**
-** Description Finishes the memory cleanup after a channel is closed.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_close_complete(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- p_cb->cout_active = FALSE;
- bta_pbs_clean_getput(p_cb, TRUE);
-
- /* inform role manager */
- bta_sys_conn_close( BTA_ID_PBS ,p_cb->app_id, p_cb->bd_addr);
-
- memset(p_cb->bd_addr, 0, BD_ADDR_LEN);
-
- /* Notify the MMI that a connection has been closed */
- p_cb->p_cback(BTA_PBS_CLOSE_EVT, 0);
-
- if (p_data->obx_evt.p_pkt)
- APPL_TRACE_WARNING0("PBS: OBX CLOSE CALLED WITH non-NULL Packet!!!");
-}
-
-/*****************************************************************************
-** Callback Functions
-*****************************************************************************/
-/*******************************************************************************
-**
-** Function bta_pbs_obx_cback
-**
-** Description OBX callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_obx_cback (tOBX_HANDLE handle, tOBX_EVENT obx_event,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt)
-{
- tBTA_PBS_OBX_EVENT *p_obx_msg;
- UINT16 event = 0;
-
-#if BTA_PBS_DEBUG == TRUE
- APPL_TRACE_DEBUG1("OBX Event Callback: obx_event [%s]", pbs_obx_evt_code(obx_event));
-#endif
-
- switch(obx_event)
- {
- case OBX_CONNECT_REQ_EVT:
- event = BTA_PBS_OBX_CONN_EVT;
- break;
- case OBX_DISCONNECT_REQ_EVT:
- event = BTA_PBS_OBX_DISC_EVT;
- break;
- case OBX_GET_REQ_EVT:
- event = BTA_PBS_OBX_GET_EVT;
- break;
- case OBX_SETPATH_REQ_EVT:
- event = BTA_PBS_OBX_SETPATH_EVT;
- break;
- case OBX_ABORT_REQ_EVT:
- event = BTA_PBS_OBX_ABORT_EVT;
- break;
- case OBX_CLOSE_IND_EVT:
- event = BTA_PBS_OBX_CLOSE_EVT;
- break;
- case OBX_TIMEOUT_EVT:
- break;
- case OBX_PASSWORD_EVT:
- event = BTA_PBS_OBX_PASSWORD_EVT;
- break;
- /* send Bad Request for Obex put request */
- case OBX_PUT_REQ_EVT:
- OBX_PutRsp(handle, OBX_RSP_BAD_REQUEST, (BT_HDR *)NULL);
- if (p_pkt)
- utl_freebuf((void**)&p_pkt);
- return;
- break;
- default:
- /* Unrecognized packet; disconnect the session */
- if (p_pkt)
- {
- event = BTA_PBS_OBX_DISC_EVT;
- utl_freebuf((void**)&p_pkt);
- }
- break;
- }
-
- /* send event to BTA, if any */
- if (event && (p_obx_msg =
- (tBTA_PBS_OBX_EVENT *) GKI_getbuf(sizeof(tBTA_PBS_OBX_EVENT))) != NULL)
- {
- p_obx_msg->hdr.event = event;
- p_obx_msg->obx_event = obx_event;
- p_obx_msg->handle = handle;
- p_obx_msg->param = param;
- p_obx_msg->p_pkt = p_pkt;
-
- bta_sys_sendmsg(p_obx_msg);
- }
-}
-
-/*****************************************************************************
-** Local PBS Event Processing Functions
-*****************************************************************************/
-/*******************************************************************************
-**
-** Function bta_pbs_req_app_access
-**
-** Description Sends an access request event to the application.
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_req_app_access (tBTA_PBS_OPER oper, tBTA_PBS_CB *p_cb)
-{
- tBTA_PBS_ACCESS *p_acc_evt;
- char *p_devname;
-
- /* Notify the application that a get file has been requested */
- if ((p_acc_evt = (tBTA_PBS_ACCESS *)GKI_getbuf(sizeof(tBTA_PBS_ACCESS))) != NULL)
- {
- memset(p_acc_evt, 0, sizeof(tBTA_PBS_ACCESS));
-
- APPL_TRACE_API1("ACCESS REQ: [%s]", p_cb->p_path);
- p_acc_evt->p_name = p_cb->p_path;
- p_acc_evt->oper = p_cb->acc_active = oper;
- bdcpy(p_acc_evt->bd_addr, p_cb->bd_addr);
- if ((p_devname = BTM_SecReadDevName(p_cb->bd_addr)) != NULL)
- BCM_STRNCPY_S((char *)p_acc_evt->dev_name, sizeof(tBTM_BD_NAME), p_devname, BTM_MAX_REM_BD_NAME_LEN);
-
- p_cb->p_cback(BTA_PBS_ACCESS_EVT, (tBTA_PBS *)p_acc_evt);
- GKI_freebuf(p_acc_evt);
- }
-}
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if BTA_PBS_DEBUG == TRUE
-
-/*******************************************************************************
-**
-** Function pbs_obx_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *pbs_obx_evt_code(tOBX_EVENT evt_code)
-{
- switch(evt_code)
- {
- case OBX_CONNECT_REQ_EVT:
- return "OBX_CONNECT_REQ_EVT";
- case OBX_DISCONNECT_REQ_EVT:
- return "OBX_DISCONNECT_REQ_EVT";
- case OBX_GET_REQ_EVT:
- return "OBX_GET_REQ_EVT";
- case OBX_SETPATH_REQ_EVT:
- return "OBX_SETPATH_REQ_EVT";
- case OBX_ABORT_REQ_EVT:
- return "OBX_ABORT_REQ_EVT";
- case OBX_CLOSE_IND_EVT:
- return "OBX_CLOSE_IND_EVT";
- case OBX_TIMEOUT_EVT:
- return "OBX_TIMEOUT_EVT";
- case OBX_PASSWORD_EVT:
- return "OBX_PASSWORD_EVT";
- default:
- return "unknown OBX event code";
- }
-}
-#endif /* Debug Functions */
-#endif /* BTA_PBS_INCLUDED */
diff --git a/bta/pb/bta_pbs_api.c b/bta/pb/bta_pbs_api.c
deleted file mode 100644
index c8466f6..0000000
--- a/bta/pb/bta_pbs_api.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_pbs_api.c
-**
-** Description: This is the implementation of the API for the phone book
-** access server subsystem of BTA, Widcomm's Bluetooth
-** application layer for mobile phones.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_PBS_INCLUDED) && (BTA_PBS_INCLUDED == TRUE)
-
-#include <string.h>
-#include "gki.h"
-#include "bta_fs_api.h"
-#include "bta_pbs_api.h"
-#include "bta_pbs_int.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-static const tBTA_SYS_REG bta_pbs_reg =
-{
- bta_pbs_hdl_event,
- BTA_PbsDisable
-};
-
-/*******************************************************************************
-**
-** Function BTA_PbsEnable
-**
-** Description Enable the phone book access server. This function must be
-** called before any other functions in the PB Server API are called.
-** When the enable operation is complete the callback function
-** will be called with an BTA_PBS_ENABLE_EVT event.
-** Note: Pbs always enable (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_PbsEnable(tBTA_SEC sec_mask, const char *p_service_name,
- const char *p_root_path, BOOLEAN enable_authen,
- UINT8 realm_len, UINT8 *p_realm,
- tBTA_PBS_CBACK *p_cback, UINT8 app_id)
-{
- tBTA_PBS_API_ENABLE *p_buf;
-
- /* register with BTA system manager */
- GKI_sched_lock();
- bta_sys_register(BTA_ID_PBS, &bta_pbs_reg);
- GKI_sched_unlock();
-
- if ((p_buf = (tBTA_PBS_API_ENABLE *)GKI_getbuf((UINT16)(sizeof(tBTA_PBS_API_ENABLE) +
- p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- memset(p_buf, 0, sizeof(tBTA_PBS_API_ENABLE));
-
- p_buf->p_root_path = (char *)(p_buf + 1);
- p_buf->p_root_path[0] = '\0';
-
- p_buf->hdr.event = BTA_PBS_API_ENABLE_EVT;
- p_buf->p_cback = p_cback;
- p_buf->sec_mask = (sec_mask | BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT);
- p_buf->app_id = app_id;
- p_buf->auth_enabled = enable_authen;
-
- p_buf->realm_len = (realm_len < OBX_MAX_REALM_LEN) ? realm_len :
- OBX_MAX_REALM_LEN;
- if (p_realm)
- memcpy(p_buf->realm, p_realm, p_buf->realm_len);
-
- if (p_service_name)
- {
- BCM_STRNCPY_S(p_buf->servicename, sizeof(p_buf->servicename), p_service_name, BTA_SERVICE_NAME_LEN);
- p_buf->servicename[BTA_SERVICE_NAME_LEN] = '\0';
- }
-
- if (p_root_path)
- {
- BCM_STRNCPY_S(p_buf->p_root_path, p_bta_fs_cfg->max_path_len+1, p_root_path, p_bta_fs_cfg->max_path_len);
- p_buf->p_root_path[p_bta_fs_cfg->max_path_len] = '\0';
- }
-
- bta_sys_sendmsg(p_buf);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_PbsDisable
-**
-** Description Disable the Phone book access server. If the server is currently
-** connected to a peer device the connection will be closed.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_PbsDisable(void)
-{
- BT_HDR *p_buf;
-
- bta_sys_deregister(BTA_ID_PBS);
- if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_PBS_API_DISABLE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-/*******************************************************************************
-**
-** Function BTA_PbsAuthRsp
-**
-** Description Respond to obex client authenticate repond by sending back password to
-** BTA. Called in response to an BTA_PBS_AUTH_EVT event.
-** Used when "enable_authen" is set to TRUE in BTA_PbapsEnable().
-**
-** Note: If the "userid_required" is TRUE in the BTA_PBS_AUTH_EVT
-** event, then p_userid is required, otherwise it is optional.
-**
-** p_password must be less than BTA_PBS_MAX_AUTH_KEY_SIZE (16 bytes)
-** p_userid must be less than OBX_MAX_REALM_LEN (defined in target.h)
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_PbsAuthRsp (char *p_password, char *p_userid)
-{
- tBTA_PBS_API_AUTHRSP *p_auth_rsp;
-
- if ((p_auth_rsp = (tBTA_PBS_API_AUTHRSP *)GKI_getbuf(sizeof(tBTA_PBS_API_AUTHRSP))) != NULL)
- {
- memset(p_auth_rsp, 0, sizeof(tBTA_PBS_API_AUTHRSP));
-
- p_auth_rsp->hdr.event = BTA_PBS_API_AUTHRSP_EVT;
-
- if (p_password)
- {
- p_auth_rsp->key_len = strlen(p_password);
- if (p_auth_rsp->key_len > BTA_PBS_MAX_AUTH_KEY_SIZE)
- p_auth_rsp->key_len = BTA_PBS_MAX_AUTH_KEY_SIZE;
- memcpy(p_auth_rsp->key, p_password, p_auth_rsp->key_len);
- }
-
- if (p_userid)
- {
- p_auth_rsp->userid_len = strlen(p_userid);
- if (p_auth_rsp->userid_len > OBX_MAX_REALM_LEN)
- p_auth_rsp->userid_len = OBX_MAX_REALM_LEN;
- memcpy(p_auth_rsp->userid, p_userid, p_auth_rsp->userid_len);
- }
-
- bta_sys_sendmsg(p_auth_rsp);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_PbsAccessRsp
-**
-** Description Sends a reply to an access request event (BTA_PBS_ACCESS_EVT).
-** This call MUST be made whenever the event occurs.
-**
-** Parameters oper - operation being accessed.
-** access - BTA_PBS_ACCESS_ALLOW or BTA_PBS_ACCESS_FORBID
-** p_name - path of file or directory to be accessed.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_PbsAccessRsp(tBTA_PBS_OPER oper, tBTA_PBS_ACCESS_TYPE access, char *p_name)
-{
- tBTA_PBS_API_ACCESSRSP *p_acc_rsp;
- UINT16 max_full_name = p_bta_fs_cfg->max_path_len + p_bta_fs_cfg->max_file_len + 1;
-
- if ((p_acc_rsp = (tBTA_PBS_API_ACCESSRSP *)GKI_getbuf((UINT16)(sizeof(tBTA_PBS_API_ACCESSRSP)
- + max_full_name + 1))) != NULL)
- {
- p_acc_rsp->flag = access;
- p_acc_rsp->oper = oper;
- p_acc_rsp->p_name = (char *)(p_acc_rsp + 1);
- if (p_name)
- {
- BCM_STRNCPY_S(p_acc_rsp->p_name, max_full_name+1, p_name, max_full_name);
- p_acc_rsp->p_name[max_full_name] = '\0';
- }
- else
- p_acc_rsp->p_name[0] = '\0';
-
- p_acc_rsp->hdr.event = BTA_PBS_API_ACCESSRSP_EVT;
- bta_sys_sendmsg(p_acc_rsp);
- }
-}
-
-/*******************************************************************************
-**
-** Function BTA_PbsClose
-**
-** Description Close the current connection.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void BTA_PbsClose(void)
-{
- BT_HDR *p_buf;
-
- if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
- {
- p_buf->event = BTA_PBS_API_CLOSE_EVT;
- bta_sys_sendmsg(p_buf);
- }
-}
-
-#endif /* BTA_PBS_INCLUDED */
diff --git a/bta/pb/bta_pbs_ci.c b/bta/pb/bta_pbs_ci.c
deleted file mode 100644
index fa2644b..0000000
--- a/bta/pb/bta_pbs_ci.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_pbs_ci.c
-**
-** Description: This is the implementation file for the phone book access server
-** call-in functions.
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bta_api.h"
-#include "bta_sys.h"
-#include "bta_pbs_ci.h"
-#include "bta_pbs_int.h"
-#include "gki.h"
-
-/*******************************************************************************
-**
-** Function bta_pbs_ci_read
-**
-** Description This function sends an event to BTA indicating the phone has
-** read in the requested amount of data specified in the
-** bta_pbs_co_read() call-out function.
-**
-** Parameters fd - file descriptor passed to the stack in the
-** bta_pbs_ci_open call-in function.
-** num_bytes_read - number of bytes read into the buffer
-** specified in the read callout-function.
-** status - BTA_PBS_CO_OK if get buffer of data,
-** BTA_PBS_CO_FAIL if an error has occurred.
-** final - indicate whether it is the final data
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_ci_read(int fd, UINT16 num_bytes_read,
- tBTA_PBS_CO_STATUS status, BOOLEAN final)
-{
- tBTA_PBS_CI_READ_EVT *p_evt;
-
- if ((p_evt = (tBTA_PBS_CI_READ_EVT *) GKI_getbuf(sizeof(tBTA_PBS_CI_READ_EVT))) != NULL)
- {
- p_evt->hdr.event = BTA_PBS_CI_READ_EVT;
- p_evt->fd = fd;
- p_evt->status = status;
- p_evt->num_read = num_bytes_read;
- p_evt->final = final;
-
- bta_sys_sendmsg(p_evt);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_ci_open
-**
-** Description This function sends an event to BTA indicating the phone has
-** finished opening a pb for reading.
-**
-** Parameters fd - file descriptor passed to the stack in the
-** bta_pbs_ci_open call-in function.
-** status - BTA_PBS_CO_OK if file was opened in mode specified
-** in the call-out function.
-** BTA_PBS_CO_EACCES if the file exists, but contains
-** the wrong access permissions.
-** BTA_PBS_CO_FAIL if any other error has occurred.
-** file_size - The total size of the file
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_ci_open(int fd, tBTA_PBS_CO_STATUS status, UINT32 file_size)
-{
- tBTA_PBS_CI_OPEN_EVT *p_evt;
-
- if ((p_evt = (tBTA_PBS_CI_OPEN_EVT *) GKI_getbuf(sizeof(tBTA_PBS_CI_OPEN_EVT))) != NULL)
- {
- p_evt->hdr.event = BTA_PBS_CI_OPEN_EVT;
- p_evt->fd = fd;
- p_evt->status = status;
- p_evt->file_size = file_size;
-
- bta_sys_sendmsg(p_evt);
- }
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_ci_getvlist
-**
-** Description This function sends an event to BTA indicating the phone has
-** finished reading a VCard list entry.
-**
-** Parameters
-** status - BTA_PBS_CO_OK if reading Vcard list entry
-** BTA_PBS_CO_FAIL if any other error has occurred.
-** final - whether it is the last entry
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BTA_API extern void bta_pbs_ci_getvlist(tBTA_PBS_CO_STATUS status, BOOLEAN final)
-{
- tBTA_PBS_CI_VLIST_EVT *p_evt;
-
- if ((p_evt = (tBTA_PBS_CI_VLIST_EVT *) GKI_getbuf(sizeof(tBTA_PBS_CI_VLIST_EVT))) != NULL)
- {
- p_evt->hdr.event = BTA_PBS_CI_VLIST_EVT;
- p_evt->status = status;
- p_evt->final = final;
-
- bta_sys_sendmsg(p_evt);
- }
-}
diff --git a/bta/pb/bta_pbs_int.h b/bta/pb/bta_pbs_int.h
index 19045fd..b7ab929 100644
--- a/bta/pb/bta_pbs_int.h
+++ b/bta/pb/bta_pbs_int.h
@@ -13,11 +13,7 @@
#define BTA_PBS_INT_H
#include "bt_target.h"
-#include "bta_sys.h"
-#include "obx_api.h"
#include "bta_pbs_api.h"
-#include "bta_pbs_co.h"
-#include "bta_pbs_ci.h"
/*****************************************************************************
** Constants and data types
@@ -29,211 +25,6 @@
#define BTA_PBS_DEFAULT_VERSION 0x0101 /* for PBAP PSE version 1.1 */
-#define BTA_PBS_GETVCARD_LISTING_TYPE "x-bt/vcard-listing"
-#define BTA_PBS_GETFILE_TYPE "x-bt/phonebook"
-#define BTA_PBS_GETVARD_ENTRY_TYPE "x-bt/vcard"
-#define BTA_PBS_PULLPB_NAME "telecom/pb.vcf"
-#define BTA_PBS_PULLICH_NAME "telecom/ich.vcf"
-#define BTA_PBS_PULLOCH_NAME "telecom/och.vcf"
-#define BTA_PBS_PULLMCH_NAME "telecom/mch.vcf"
-#define BTA_PBS_PULLCCH_NAME "telecom/cch.vcf"
-#define BTA_PBS_PBFOLDER_NAME "pb"
-#define BTA_PBS_ICHFOLDER_NAME "ich"
-#define BTA_PBS_OCHFOLDER_NAME "och"
-#define BTA_PBS_MCHFOLDER_NAME "mch"
-#define BTA_PBS_CCHFOLDER_NAME "cch"
-
-/* Tags for application parameter obex headers */
-/* application parameter len: number of bytes + 2 (tag&len) */
-#define BTA_PBS_TAG_ORDER 1 /* UINT8 */
-#define BTA_PBS_TAG_SEARCH_VALUE 2 /* string */
-#define BTA_PBS_TAG_SEARCH_ATTRIBUTE 3 /* UINT8 */
-#define BTA_PBS_TAG_MAX_LIST_COUNT 4 /* UINT16 */
-#define BTA_PBS_TAG_LIST_START_OFFSET 5 /* UINT16 */
-#define BTA_PBS_TAG_FILTER 6 /* UINT32 */
-#define BTA_PBS_TAG_FORMAT 7 /* UINT8 */
-#define BTA_PBS_TAG_PB_SIZE 8 /* UINT16 */
-#define BTA_PBS_TAG_NEW_MISSED_CALLS 9 /* UINT8 */
-
-#define BTA_PBS_MAX_LIST_COUNT 65535
-
-typedef tOBX_STATUS (tBTA_PBS_OBX_RSP) (tOBX_HANDLE handle, UINT8 rsp_code, BT_HDR *p_pkt);
-
-/* state machine events */
-enum
-{
- /* these events are handled by the state machine */
- BTA_PBS_API_DISABLE_EVT = BTA_SYS_EVT_START(BTA_ID_PBS),
-
- BTA_PBS_API_AUTHRSP_EVT, /* Response to password request */
- BTA_PBS_API_ACCESSRSP_EVT, /* Response to an access request */
- BTA_PBS_API_CLOSE_EVT, /* Response to a close request */
- BTA_PBS_CI_READ_EVT, /* Response to Read request */
- BTA_PBS_CI_OPEN_EVT, /* Response to File Open request */
- BTA_PBS_CI_VLIST_EVT, /* Response to Get Vcard Entry request */
- BTA_PBS_OBX_CONN_EVT, /* OBX Channel Connect Request */
- BTA_PBS_OBX_DISC_EVT, /* OBX Channel Disconnect */
- BTA_PBS_OBX_ABORT_EVT, /* OBX_operation aborted */
- BTA_PBS_OBX_PASSWORD_EVT, /* OBX password requested */
- BTA_PBS_OBX_CLOSE_EVT, /* OBX Channel Disconnected (Link Lost) */
- BTA_PBS_OBX_GET_EVT, /* Read file data or folder listing */
- BTA_PBS_OBX_SETPATH_EVT, /* Make or Change Directory */
- BTA_PBS_APPL_TOUT_EVT, /* Timeout waiting for application */
- BTA_PBS_DISC_ERR_EVT, /* Sends OBX_DisconnectRsp with error code */
- BTA_PBS_GASP_ERR_EVT, /* Sends Err Resp to Get, Abort, Setpath */
- BTA_PBS_CLOSE_CMPL_EVT, /* Finished closing channel */
-
- /* these events are handled outside the state machine */
- BTA_PBS_API_ENABLE_EVT
-};
-
-typedef UINT16 tBTA_PBS_INT_EVT;
-
-typedef UINT8 tBTA_PBS_STATE;
-
-/* data type for BTA_PBS_API_ENABLE_EVT */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_PBS_CBACK *p_cback;
- char servicename[BTA_SERVICE_NAME_LEN + 1];
- char *p_root_path;
- UINT8 realm [OBX_MAX_REALM_LEN]; /* The realm is intended to be
- displayed to users so they know
- which userid and password to use.
- The first byte of the string is
- the character set of the string.
- */
- UINT8 realm_len;
- UINT8 sec_mask;
- UINT8 app_id;
- BOOLEAN auth_enabled;
-} tBTA_PBS_API_ENABLE;
-
-/* data type for BTA_PBS_API_AUTHRSP_EVT */
-typedef struct
-{
- BT_HDR hdr;
- UINT8 key [BTA_PBS_MAX_AUTH_KEY_SIZE]; /* The authentication key.*/
- UINT8 key_len;
- UINT8 userid [OBX_MAX_REALM_LEN]; /* The authentication user id.*/
- UINT8 userid_len;
-} tBTA_PBS_API_AUTHRSP;
-
-/* data type for BTA_PBS_API_ACCESSRSP_EVT */
-typedef struct
-{
- BT_HDR hdr;
- char *p_name;
- tBTA_PBS_OPER oper;
- tBTA_PBS_ACCESS_TYPE flag;
-} tBTA_PBS_API_ACCESSRSP;
-
-typedef struct
-{
- BT_HDR hdr;
- UINT32 file_size;
- int fd;
- tBTA_PBS_CO_STATUS status;
-} tBTA_PBS_CI_OPEN_EVT;
-
-/* Read Ready Event */
-typedef struct
-{
- BT_HDR hdr;
- int fd;
- UINT16 num_read;
- tBTA_PBS_CO_STATUS status;
- BOOLEAN final;
-} tBTA_PBS_CI_READ_EVT;
-
-/* Get Vlist Entry Ready Event */
-typedef struct
-{
- BT_HDR hdr;
- tBTA_PBS_CO_STATUS status;
- BOOLEAN final;
-} tBTA_PBS_CI_VLIST_EVT;
-
-
-/* data type for all obex events
- hdr.event contains the PBS event
-*/
-typedef struct
-{
- BT_HDR hdr;
- tOBX_HANDLE handle;
- tOBX_EVT_PARAM param;
- BT_HDR *p_pkt;
- tOBX_EVENT obx_event;
- UINT8 rsp_code;
-} tBTA_PBS_OBX_EVENT;
-
-/* union of all event data types */
-typedef union
-{
- BT_HDR hdr;
- tBTA_PBS_API_ENABLE api_enable;
- tBTA_PBS_API_AUTHRSP auth_rsp;
- tBTA_PBS_API_ACCESSRSP access_rsp;
- tBTA_PBS_OBX_EVENT obx_evt;
- tBTA_PBS_CI_OPEN_EVT open_evt;
- tBTA_PBS_CI_READ_EVT read_evt;
- tBTA_PBS_CI_VLIST_EVT vlist_evt;
-} tBTA_PBS_DATA;
-
-
-/* OBX Response Packet Structure - Holds current response packet info */
-typedef struct
-{
- BT_HDR *p_pkt; /* (Get/Put) Holds the current OBX header for Put or Get */
- UINT8 *p_start; /* (Get/Put) Start of the Body of the packet */
- UINT16 offset; /* (Get/Put) Contains the current offset into the Body (p_start) */
- UINT16 bytes_left; /* (Get/Put) Holds bytes available left in Obx packet */
- BOOLEAN final_pkt; /* (Put) Holds the final bit of the Put packet */
-} tBTA_PBS_OBX_PKT;
-
-
-/* PBS control block */
-typedef struct
-{
- tBTA_PBS_CBACK *p_cback; /* pointer to application callback function */
- char *p_name; /* Holds name of current operation */
- char *p_path; /* Holds path of current operation */
- char *p_rootpath;
- char *p_workdir; /* Current working directory */
- UINT8 *p_stream_indexes; /* Contains pointer to beginning of phonebook size area in ob hdr */
- tBTA_PBS_OBX_PKT obx; /* Holds the current OBX packet information */
- tBTA_PBS_PULLPB_APP_PARAMS pullpb_app_params; /* PULLPB Application params */
- tBTA_PBS_VCARDLIST_APP_PARAMS getvlist_app_params; /* Get VLIST Application params */
- tBTA_PBS_VCARDLIST vlist; /* Holds current directory list information */
- UINT32 sdp_handle; /* SDP record handle */
- UINT32 file_length; /* length of file being PUT/GET */
- int fd; /* File Descriptor of opened file */
- BD_ADDR bd_addr; /* Device currently connected to */
- tOBX_HANDLE obx_handle;
- UINT16 peer_mtu;
- UINT16 num_vlist_idxs; /* keeps track of number of indexes in vCard listing */
- UINT8 scn; /* SCN of the FTP server */
- tBTA_PBS_STATE state; /* state machine state */
- UINT8 obx_oper; /* current active OBX operation GET FILE, LISTING, etc */
- UINT8 app_id;
- BOOLEAN auth_enabled; /* Is OBEX authentication enabled */
- BOOLEAN cout_active; /* TRUE when waiting for a call-in function */
- BOOLEAN aborting;
- BOOLEAN get_only_indexes; /* True if PCE only wants num indexes for vListing response */
- tBTA_PBS_OPER acc_active; /* op code when waiting for an access rsp (API) (0 not active) */
- tBTA_PBS_OBJ_TYPE obj_type;
- UINT8 realm [OBX_MAX_REALM_LEN]; /* The realm is intended to be
- displayed to users so they know
- which userid and password to use.
- The first byte of the string is
- the character set of the string.
- */
- UINT8 realm_len;
-} tBTA_PBS_CB;
-
-
/* Configuration structure */
typedef struct
@@ -245,61 +36,10 @@ typedef struct
} tBTA_PBS_CFG;
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* PBS control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-extern tBTA_PBS_CB bta_pbs_cb;
-#else
-extern tBTA_PBS_CB *bta_pbs_cb_ptr;
-#define bta_pbs_cb (*bta_pbs_cb_ptr)
-#endif
-
-/* PBS configuration constants */
-extern tBTA_PBS_CFG * p_bta_pbs_cfg;
/*****************************************************************************
-** Function prototypes
+** Global data
*****************************************************************************/
-extern BOOLEAN bta_pbs_hdl_event(BT_HDR *p_msg);
-extern void bta_pbs_sm_execute(tBTA_PBS_CB *p_cb, UINT16 event, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_sdp_register (tBTA_PBS_CB *p_cb, char *p_service_name);
-extern void bta_pbs_obx_cback (tOBX_HANDLE handle, tOBX_EVENT event,
- tOBX_EVT_PARAM param, BT_HDR *p_pkt);
-
-/* action functions */
-extern void bta_pbs_api_disable(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_api_authrsp(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_api_accessrsp(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_api_close(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_obx_connect(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_obx_disc(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_obx_close(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_obx_abort(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_obx_password(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_obx_get(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_obx_setpath(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_appl_tout(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_conn_err_rsp(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_disc_err_rsp(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_gasp_err_rsp(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_close_complete(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_ci_open_act(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_ci_read_act(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-extern void bta_pbs_ci_vlist_act(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-/* object store */
-extern void bta_pbs_proc_get_file(char *p_name, tBTA_PBS_OPER operation);
-extern void bta_pbs_req_app_access (tBTA_PBS_OPER oper, tBTA_PBS_CB *p_cb);
-extern void bta_pbs_getvlist(char *p_name);
-/* miscellaneous functions */
-extern void bta_pbs_get_file_rsp(UINT8 rsp_code, UINT16 num_read);
-extern void bta_pbs_clean_getput(tBTA_PBS_CB *p_cb, BOOLEAN is_aborted);
-extern void bta_pbs_end_of_list(UINT8 rsp_code);
-extern UINT8 bta_pbs_add_list_entry(void);
-extern UINT8 bta_pbs_chdir(BT_HDR *p_pkt, BOOLEAN backup_flag, tBTA_PBS_OPER *p_op);
-extern UINT8 * bta_pbs_read_app_params(BT_HDR *p_pkt, UINT8 tag, UINT16 *param_len);
#endif /* BTA_PBS_INT_H */
diff --git a/bta/pb/bta_pbs_main.c b/bta/pb/bta_pbs_main.c
deleted file mode 100644
index 1ed892d..0000000
--- a/bta/pb/bta_pbs_main.c
+++ /dev/null
@@ -1,515 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_pbs_main.c
-**
-** Description: This file contains the phone book access server main functions
-** and state machine.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_PBS_INCLUDED) && (BTA_PBS_INCLUDED == TRUE)
-
-#include <string.h>
-#include "bta_fs_api.h"
-#include "bta_pbs_api.h"
-#include "bta_pbs_int.h"
-#include "gki.h"
-#include "utl.h"
-#include "obx_api.h"
-#include "rfcdefs.h" /* BT_PSM_RFCOMM */
-#include "bta_fs_co.h"
-
-/*****************************************************************************
-** Constants and types
-*****************************************************************************/
-
-/* state machine states */
-enum
-{
- BTA_PBS_IDLE_ST = 0, /* Idle */
- BTA_PBS_LISTEN_ST, /* Listen - waiting for OBX/RFC connection */
- BTA_PBS_W4_AUTH_ST, /* Wait for Authentication - (optional) */
- BTA_PBS_CONN_ST, /* Connected - PBS Session is active */
- BTA_PBS_CLOSING_ST /* Closing is in progress */
-};
-
-/* state machine action enumeration list */
-enum
-{
- BTA_PBS_API_DISABLE,
- BTA_PBS_API_AUTHRSP,
- BTA_PBS_API_ACCESSRSP,
- BTA_PBS_API_CLOSE,
- BTA_PBS_CI_READ,
- BTA_PBS_CI_OPEN,
- BTA_PBS_CI_VLIST,
- BTA_PBS_OBX_CONNECT,
- BTA_PBS_OBX_DISC,
- BTA_PBS_OBX_CLOSE,
- BTA_PBS_OBX_ABORT,
- BTA_PBS_OBX_PASSWORD,
- BTA_PBS_OBX_GET,
- BTA_PBS_OBX_SETPATH,
- BTA_PBS_APPL_TOUT,
- BTA_PBS_CONN_ERR_RSP,
- BTA_PBS_DISC_ERR_RSP,
- BTA_PBS_GASP_ERR_RSP,
- BTA_PBS_CLOSE_COMPLETE,
- BTA_PBS_IGNORE
-};
-
-/* type for action functions */
-typedef void (*tBTA_PBS_ACTION)(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data);
-
-/* action function list */
-const tBTA_PBS_ACTION bta_pbs_action[] =
-{
- bta_pbs_api_disable,
- bta_pbs_api_authrsp,
- bta_pbs_api_accessrsp,
- bta_pbs_api_close,
- bta_pbs_ci_read_act,
- bta_pbs_ci_open_act,
- bta_pbs_ci_vlist_act,
- bta_pbs_obx_connect,
- bta_pbs_obx_disc,
- bta_pbs_obx_close,
- bta_pbs_obx_abort,
- bta_pbs_obx_password,
- bta_pbs_obx_get,
- bta_pbs_obx_setpath,
- bta_pbs_appl_tout,
- bta_pbs_conn_err_rsp,
- bta_pbs_disc_err_rsp,
- bta_pbs_gasp_err_rsp,
- bta_pbs_close_complete
-};
-
-
-/* state table information */
-#define BTA_PBS_ACTIONS 1 /* number of actions */
-#define BTA_PBS_NEXT_STATE 1 /* position of next state */
-#define BTA_PBS_NUM_COLS 2 /* number of columns in state tables */
-
-/* state table for idle state */
-static const UINT8 bta_pbs_st_idle[][BTA_PBS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_PBS_API_ENABLE_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST}
-};
-
-/* state table for obex/rfcomm connection state */
-static const UINT8 bta_pbs_st_listen[][BTA_PBS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_PBS_API_DISABLE_EVT */ {BTA_PBS_API_DISABLE, BTA_PBS_IDLE_ST},
-/* BTA_PBS_API_AUTHRSP_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_API_ACCESSRSP_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_API_CLOSE_EVT */ {BTA_PBS_API_CLOSE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_CI_READ_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_CI_OPEN_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_CI_VLIST_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_OBX_CONN_EVT */ {BTA_PBS_OBX_CONNECT, BTA_PBS_CONN_ST},
-/* BTA_PBS_OBX_DISC_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_OBX_ABORT_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_OBX_PASSWORD_EVT */ {BTA_PBS_OBX_PASSWORD, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_OBX_CLOSE_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_OBX_GET_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_OBX_SETPATH_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_APPL_TOUT_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_DISC_ERR_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_GASP_ERR_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_CLOSE_CMPL_EVT */ {BTA_PBS_IGNORE, BTA_PBS_LISTEN_ST}
-};
-
-/* state table for wait for authentication response state */
-static const UINT8 bta_pbs_st_w4_auth[][BTA_PBS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_PBS_API_DISABLE_EVT */ {BTA_PBS_API_DISABLE, BTA_PBS_IDLE_ST},
-/* BTA_PBS_API_AUTHRSP_EVT */ {BTA_PBS_API_AUTHRSP, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_API_ACCESSRSP_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_API_CLOSE_EVT */ {BTA_PBS_API_CLOSE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_CI_READ_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_CI_OPEN_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_CI_VLIST_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_OBX_CONN_EVT */ {BTA_PBS_CONN_ERR_RSP, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_OBX_DISC_EVT */ {BTA_PBS_OBX_DISC, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_OBX_ABORT_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_OBX_PASSWORD_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_OBX_CLOSE_EVT */ {BTA_PBS_OBX_CLOSE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_OBX_GET_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_OBX_SETPATH_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_APPL_TOUT_EVT */ {BTA_PBS_APPL_TOUT, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_DISC_ERR_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_GASP_ERR_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_CLOSE_CMPL_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST}
-};
-
-/* state table for open state */
-static const UINT8 bta_pbs_st_connected[][BTA_PBS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_PBS_API_DISABLE_EVT */ {BTA_PBS_API_DISABLE, BTA_PBS_IDLE_ST},
-/* BTA_PBS_API_AUTHRSP_EVT */ {BTA_PBS_IGNORE, BTA_PBS_CONN_ST},
-/* BTA_PBS_API_ACCESSRSP_EVT */ {BTA_PBS_API_ACCESSRSP, BTA_PBS_CONN_ST},
-/* BTA_PBS_API_CLOSE_EVT */ {BTA_PBS_API_CLOSE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_CI_READ_EVT */ {BTA_PBS_CI_READ, BTA_PBS_CONN_ST},
-/* BTA_PBS_CI_OPEN_EVT */ {BTA_PBS_CI_OPEN, BTA_PBS_CONN_ST},
-/* BTA_PBS_CI_VLIST_EVT */ {BTA_PBS_CI_VLIST, BTA_PBS_CONN_ST},
-/* BTA_PBS_OBX_CONN_EVT */ {BTA_PBS_CONN_ERR_RSP, BTA_PBS_CONN_ST},
-/* BTA_PBS_OBX_DISC_EVT */ {BTA_PBS_OBX_DISC, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_OBX_ABORT_EVT */ {BTA_PBS_OBX_ABORT, BTA_PBS_CONN_ST},
-/* BTA_PBS_OBX_PASSWORD_EVT */ {BTA_PBS_IGNORE, BTA_PBS_W4_AUTH_ST},
-/* BTA_PBS_OBX_CLOSE_EVT */ {BTA_PBS_OBX_CLOSE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_OBX_GET_EVT */ {BTA_PBS_OBX_GET, BTA_PBS_CONN_ST},
-/* BTA_PBS_OBX_SETPATH_EVT */ {BTA_PBS_OBX_SETPATH, BTA_PBS_CONN_ST},
-/* BTA_PBS_APPL_TOUT_EVT */ {BTA_PBS_APPL_TOUT, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_DISC_ERR_EVT */ {BTA_PBS_IGNORE, BTA_PBS_CONN_ST},
-/* BTA_PBS_GASP_ERR_EVT */ {BTA_PBS_GASP_ERR_RSP, BTA_PBS_CONN_ST},
-/* BTA_PBS_CLOSE_CMPL_EVT */ {BTA_PBS_IGNORE, BTA_PBS_CONN_ST}
-};
-
-/* state table for closing state */
-static const UINT8 bta_pbs_st_closing[][BTA_PBS_NUM_COLS] =
-{
-/* Event Action 1 Next state */
-/* BTA_PBS_API_DISABLE_EVT */ {BTA_PBS_API_DISABLE, BTA_PBS_IDLE_ST},
-/* BTA_PBS_API_AUTHRSP_EVT */ {BTA_PBS_IGNORE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_API_ACCESSRSP_EVT */ {BTA_PBS_IGNORE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_API_CLOSE_EVT */ {BTA_PBS_IGNORE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_CI_READ_EVT */ {BTA_PBS_CLOSE_COMPLETE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_CI_OPEN_EVT */ {BTA_PBS_CLOSE_COMPLETE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_CI_VLIST_EVT */ {BTA_PBS_CLOSE_COMPLETE, BTA_PBS_LISTEN_ST},
-/* BTA_PBS_OBX_CONN_EVT */ {BTA_PBS_CONN_ERR_RSP, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_OBX_DISC_EVT */ {BTA_PBS_IGNORE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_OBX_ABORT_EVT */ {BTA_PBS_OBX_ABORT, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_OBX_PASSWORD_EVT */ {BTA_PBS_IGNORE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_OBX_CLOSE_EVT */ {BTA_PBS_OBX_CLOSE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_OBX_GET_EVT */ {BTA_PBS_IGNORE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_OBX_SETPATH_EVT */ {BTA_PBS_IGNORE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_APPL_TOUT_EVT */ {BTA_PBS_IGNORE, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_DISC_ERR_EVT */ {BTA_PBS_DISC_ERR_RSP, BTA_PBS_CONN_ST},
-/* BTA_PBS_GASP_ERR_EVT */ {BTA_PBS_GASP_ERR_RSP, BTA_PBS_CLOSING_ST},
-/* BTA_PBS_CLOSE_CMPL_EVT */ {BTA_PBS_CLOSE_COMPLETE, BTA_PBS_LISTEN_ST}
-};
-
-/* type for state table */
-typedef const UINT8 (*tBTA_PBS_ST_TBL)[BTA_PBS_NUM_COLS];
-
-/* state table */
-const tBTA_PBS_ST_TBL bta_pbs_st_tbl[] =
-{
- bta_pbs_st_idle,
- bta_pbs_st_listen,
- bta_pbs_st_w4_auth,
- bta_pbs_st_connected,
- bta_pbs_st_closing
-};
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/* PBS control block */
-#if BTA_DYNAMIC_MEMORY == FALSE
-tBTA_PBS_CB bta_pbs_cb;
-#endif
-
-#if BTA_PBS_DEBUG == TRUE
-static char *pbs_evt_code(tBTA_PBS_INT_EVT evt_code);
-static char *pbs_state_code(tBTA_PBS_STATE state_code);
-#endif
-
-/*******************************************************************************
-**
-** Function bta_pbs_sm_execute
-**
-** Description State machine event handling function for PBS
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_sm_execute(tBTA_PBS_CB *p_cb, UINT16 event, tBTA_PBS_DATA *p_data)
-{
- tBTA_PBS_ST_TBL state_table;
- UINT8 action;
- int i;
- tBTA_PBS_OBX_EVENT *p_obex_event;
-#if BTA_PBS_DEBUG == TRUE
- tBTA_PBS_STATE in_state = bta_pbs_cb.state;
- UINT16 in_event = event;
- APPL_TRACE_EVENT3("PBS Event : State 0x%02x [%s], Event [%s]", in_state,
- pbs_state_code(in_state),
- pbs_evt_code(event));
-#endif
-
- /* look up the state table for the current state */
- state_table = bta_pbs_st_tbl[p_cb->state];
-
- event &= 0x00FF;
-
- /* set next state */
- p_cb->state = state_table[event][BTA_PBS_NEXT_STATE];
-
- /* execute action functions */
- for (i = 0; i < BTA_PBS_ACTIONS; i++)
- {
- if ((action = state_table[event][i]) != BTA_PBS_IGNORE)
- {
- (*bta_pbs_action[action])(p_cb, p_data);
- }
- else
- {
- if (event >= BTA_PBS_OBX_CONN_EVT && event <= BTA_PBS_OBX_SETPATH_EVT) {
- p_obex_event = (tBTA_PBS_OBX_EVENT *) p_data;
- utl_freebuf((void**)&(p_obex_event->p_pkt));
- }
- break;
- }
- }
-
-#if BTA_PBS_DEBUG == TRUE
- if (in_state != bta_pbs_cb.state)
- {
- APPL_TRACE_DEBUG3("PBS State Change: [%s] -> [%s] after Event [%s]",
- pbs_state_code(in_state),
- pbs_state_code(bta_pbs_cb.state),
- pbs_evt_code(in_event));
- }
-#endif
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_api_enable
-**
-** Description Handle an api enable event. This function enables the PBS
-** Server by opening an Obex/Rfcomm channel and placing it into
-** listen mode.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-static void bta_pbs_api_enable(tBTA_PBS_CB *p_cb, tBTA_PBS_DATA *p_data)
-{
- tOBX_StartParams start_msg;
- tBTA_PBS_API_ENABLE *p_api = &p_data->api_enable;
- tOBX_TARGET target;
- UINT16 len;
- tOBX_STATUS status;
- tBTA_UTL_COD cod;
-
- /* initialize control block */
- memset(p_cb, 0, sizeof(tBTA_PBS_CB));
-
- /* Allocate an aligned memory buffer to hold the root path and working directory */
- /* Add 1 byte for '\0' */
- len = p_bta_fs_cfg->max_path_len + 1;
- if ((p_cb->p_rootpath = (char *)GKI_getbuf((UINT16)(len * 2))) != NULL)
- {
- p_cb->p_workdir = p_cb->p_rootpath + len;
- memcpy(target.target, BTA_PBS_TARGET_UUID, BTA_PBS_UUID_LENGTH);
- target.len = BTA_PBS_UUID_LENGTH;
-
- /* store parameters */
- p_cb->app_id = p_api->app_id;
- p_cb->p_cback = p_api->p_cback;
- p_cb->scn = BTM_AllocateSCN();
- p_cb->auth_enabled = p_api->auth_enabled;
- p_cb->fd = BTA_FS_INVALID_FD;
- p_cb->realm_len = p_api->realm_len;
- memcpy(p_cb->realm, p_api->realm, p_api->realm_len);
-
- /* Initialize the current working directory to be the root directory */
- BCM_STRNCPY_S(p_cb->p_rootpath, len, p_api->p_root_path, p_bta_fs_cfg->max_path_len);
- p_cb->p_rootpath[len-1] = '\0';
- BCM_STRNCPY_S(p_cb->p_workdir, len, p_api->p_root_path, p_bta_fs_cfg->max_path_len);
- p_cb->p_workdir[len-1] = '\0';
-
- /* Register PBS security requirements with BTM */
- BTM_SetSecurityLevel(FALSE, p_api->servicename, BTM_SEC_SERVICE_PBAP,
- p_api->sec_mask, BT_PSM_RFCOMM,
- BTM_SEC_PROTO_RFCOMM, (UINT32)p_cb->scn);
-
- /* Start up the PBS service */
- memset (&start_msg, 0, sizeof(tOBX_StartParams));
- start_msg.p_target = &target;
-
- /* Make the MTU fit into one RFC frame */
- start_msg.mtu = OBX_MAX_MTU;
- start_msg.scn = p_cb->scn;
- start_msg.authenticate = p_cb->auth_enabled;
-
- start_msg.auth_option = (p_bta_pbs_cfg->userid_req) ? OBX_AO_USR_ID : OBX_AO_NONE;
- start_msg.p_cback = bta_pbs_obx_cback;
-
- start_msg.realm_len = p_api->realm_len;
- start_msg.p_realm = p_api->realm;
- start_msg.realm_charset = (tOBX_CHARSET) p_bta_pbs_cfg->realm_charset;
-
- if ((status = OBX_StartServer (&start_msg, &p_cb->obx_handle)) == OBX_SUCCESS)
- {
- p_cb->state = BTA_PBS_LISTEN_ST;
-
- /* Set the File Transfer service class bit */
- cod.service = BTM_COD_SERVICE_OBJ_TRANSFER;
- utl_set_device_class(&cod, BTA_UTL_SET_COD_SERVICE_CLASS);
-
- /* Set up the SDP record for pbs service */
- bta_pbs_sdp_register(p_cb, p_api->servicename);
- }
- else
- APPL_TRACE_ERROR1("OBX_StartServer returns error (%d)", status);
- }
- else /* Cannot allocate resources to run Server */
- APPL_TRACE_ERROR0("Not enough Resources to run PBS Server");
-
- p_cb->p_cback(BTA_PBS_ENABLE_EVT, 0);
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_hdl_event
-**
-** Description File transfer server main event handling function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-BOOLEAN bta_pbs_hdl_event(BT_HDR *p_msg)
-{
-#if BTA_PBS_DEBUG == TRUE
- tBTA_PBS_STATE in_state = bta_pbs_cb.state;
-#endif
-
- switch (p_msg->event)
- {
- case BTA_PBS_API_ENABLE_EVT:
-#if BTA_PBS_DEBUG == TRUE
- APPL_TRACE_EVENT3("PBS Event Handler: State 0x%02x [%s], Event [%s]", in_state,
- pbs_state_code(in_state),
- pbs_evt_code(p_msg->event));
-#endif
- bta_pbs_api_enable(&bta_pbs_cb, (tBTA_PBS_DATA *) p_msg);
-
-#if BTA_PBS_DEBUG == TRUE
- if (in_state != bta_pbs_cb.state)
- {
- APPL_TRACE_DEBUG3("PBS State Change: [%s] -> [%s] after Event [%s]",
- pbs_state_code(in_state),
- pbs_state_code(bta_pbs_cb.state),
- pbs_evt_code(p_msg->event));
- }
-#endif
- break;
-
- default:
- bta_pbs_sm_execute(&bta_pbs_cb, p_msg->event, (tBTA_PBS_DATA *) p_msg);
- break;
- }
-
- return (TRUE);
-}
-
-
-/*****************************************************************************
-** Debug Functions
-*****************************************************************************/
-#if BTA_PBS_DEBUG == TRUE
-
-/*******************************************************************************
-**
-** Function pbs_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *pbs_evt_code(tBTA_PBS_INT_EVT evt_code)
-{
- switch(evt_code)
- {
- case BTA_PBS_API_DISABLE_EVT:
- return "BTA_PBS_API_DISABLE_EVT";
- case BTA_PBS_API_AUTHRSP_EVT:
- return "BTA_PBS_API_AUTHRSP_EVT";
- case BTA_PBS_API_ACCESSRSP_EVT:
- return "BTA_PBS_API_ACCESSRSP_EVT";
- case BTA_PBS_API_CLOSE_EVT:
- return "BTA_PBS_API_CLOSE_EVT";
- case BTA_PBS_CI_READ_EVT:
- return "BTA_PBS_CI_READ_EVT";
- case BTA_PBS_CI_OPEN_EVT:
- return "BTA_PBS_CI_OPEN_EVT";
- case BTA_PBS_CI_VLIST_EVT:
- return "BTA_PBS_CI_VLIST_EVT";
- case BTA_PBS_OBX_CONN_EVT:
- return "BTA_PBS_OBX_CONN_EVT";
- case BTA_PBS_OBX_DISC_EVT:
- return "BTA_PBS_OBX_DISC_EVT";
- case BTA_PBS_OBX_ABORT_EVT:
- return "BTA_PBS_OBX_ABORT_EVT";
- case BTA_PBS_OBX_PASSWORD_EVT:
- return "BTA_PBS_OBX_PASSWORD_EVT";
- case BTA_PBS_OBX_CLOSE_EVT:
- return "BTA_PBS_OBX_CLOSE_EVT";
- case BTA_PBS_OBX_GET_EVT:
- return "BTA_PBS_OBX_GET_EVT";
- case BTA_PBS_OBX_SETPATH_EVT:
- return "BTA_PBS_OBX_SETPATH_EVT";
- case BTA_PBS_APPL_TOUT_EVT:
- return "BTA_PBS_APPL_TOUT_EVT";
- case BTA_PBS_DISC_ERR_EVT:
- return "BTA_PBS_DISC_ERR_EVT";
- case BTA_PBS_GASP_ERR_EVT:
- return "BTA_PBS_GASP_ERR_EVT";
- case BTA_PBS_API_ENABLE_EVT:
- return "BTA_PBS_API_ENABLE_EVT";
- case BTA_PBS_CLOSE_CMPL_EVT:
- return "BTA_PBS_CLOSE_CMPL_EVT";
- default:
- APPL_TRACE_EVENT1("unknown PBS Event: %d", evt_code)
- return "unknown PBS event code";
- }
-}
-
-/*******************************************************************************
-**
-** Function pbs_evt_code
-**
-** Description
-**
-** Returns void
-**
-*******************************************************************************/
-static char *pbs_state_code(tBTA_PBS_STATE state_code)
-{
- switch(state_code)
- {
- case BTA_PBS_IDLE_ST:
- return "BTA_PBS_IDLE_ST";
- case BTA_PBS_LISTEN_ST:
- return "BTA_PBS_LISTEN_ST";
- case BTA_PBS_W4_AUTH_ST:
- return "BTA_PBS_W4_AUTH_ST";
- case BTA_PBS_CONN_ST:
- return "BTA_PBS_CONN_ST";
- case BTA_PBS_CLOSING_ST:
- return "BTA_PBS_CLOSING_ST";
- default:
- return "unknown PBS state code";
- }
-}
-
-#endif /* Debug Functions */
-#endif /* BTA_PBS_INCLUDED */
diff --git a/bta/pb/bta_pbs_sdp.c b/bta/pb/bta_pbs_sdp.c
deleted file mode 100644
index eeec573..0000000
--- a/bta/pb/bta_pbs_sdp.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_pbs_sdp.c
-**
-** File: Implements the SDP functions used by Phone Book Access Server
-**
-** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
-** Widcomm Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_PBS_INCLUDED) && (BTA_PBS_INCLUDED == TRUE)
-
-#include <string.h>
-
-#include "sdp_api.h"
-#include "bta_pbs_int.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-
-/*****************************************************************************
-**
-** Function: bta_pbs_sdp_register()
-**
-** Purpose: Registers the PBS service with SDP
-**
-** Parameters:
-**
-**
-** Returns: void
-**
-*****************************************************************************/
-void bta_pbs_sdp_register (tBTA_PBS_CB *p_cb, char *p_service_name)
-{
- tSDP_PROTOCOL_ELEM protoList [3];
- UINT16 pbs_service = UUID_SERVCLASS_PBAP_PSE;
-// btla-specific ++
- UINT16 browse = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
-// btla-specific --
- BOOLEAN status = FALSE;
-
- if ((p_cb->sdp_handle = SDP_CreateRecord()) == 0)
- {
- APPL_TRACE_WARNING0("PBS SDP: Unable to register PBS Service");
- return;
- }
-
- /* add service class */
- if (SDP_AddServiceClassIdList(p_cb->sdp_handle, 1, &pbs_service))
- {
- memset( protoList, 0 , 3*sizeof(tSDP_PROTOCOL_ELEM) );
- /* add protocol list, including RFCOMM scn */
- protoList[0].protocol_uuid = UUID_PROTOCOL_L2CAP;
- protoList[0].num_params = 0;
- protoList[1].protocol_uuid = UUID_PROTOCOL_RFCOMM;
- protoList[1].num_params = 1;
- protoList[1].params[0] = p_cb->scn;
- protoList[2].protocol_uuid = UUID_PROTOCOL_OBEX;
- protoList[2].num_params = 0;
-
- if (SDP_AddProtocolList(p_cb->sdp_handle, 3, protoList))
- {
- status = TRUE; /* All mandatory fields were successful */
-
- /* optional: if name is not "", add a name entry */
- if (*p_service_name != '\0')
- SDP_AddAttribute(p_cb->sdp_handle,
- (UINT16)ATTR_ID_SERVICE_NAME,
- (UINT8)TEXT_STR_DESC_TYPE,
- (UINT32)(strlen(p_service_name) + 1),
- (UINT8 *)p_service_name);
-
- /* Add in the Bluetooth Profile Descriptor List */
- SDP_AddProfileDescriptorList(p_cb->sdp_handle,
- UUID_SERVCLASS_PHONE_ACCESS,
- BTA_PBS_DEFAULT_VERSION);
-
- } /* end of setting mandatory protocol list */
- } /* end of setting mandatory service class */
-
- /* add supported feature and repositories */
- if (status)
- {
-// btla-specific ++
- // SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE,
- // (UINT32)1, (UINT8*)&p_bta_pbs_cfg->supported_features);
- SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_SUPPORTED_REPOSITORIES, UINT_DESC_TYPE,
- (UINT32)1, (UINT8*)&p_bta_pbs_cfg->supported_repositories);
-
- /* Make the service browseable */
- SDP_AddUuidSequence (p_cb->sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse);
-// btla-specific --
- }
-
- if (!status)
- {
- SDP_DeleteRecord(p_cb->sdp_handle);
- APPL_TRACE_ERROR0("bta_pbs_sdp_register FAILED");
- }
- else
- {
- bta_sys_add_uuid(pbs_service); /* UUID_SERVCLASS_PBAP_PSE */
- APPL_TRACE_DEBUG1("PBS: SDP Registered (handle 0x%08x)", p_cb->sdp_handle);
- }
-
- return;
-}
-#endif /* BTA_PBS_INCLUDED */
diff --git a/bta/pb/bta_pbs_utils.c b/bta/pb/bta_pbs_utils.c
deleted file mode 100644
index 61d7401..0000000
--- a/bta/pb/bta_pbs_utils.c
+++ /dev/null
@@ -1,734 +0,0 @@
-/*****************************************************************************
-**
-** Name: bta_pbs_utils.c
-**
-** Description: This file implements utils functions for phone book access
-** server.
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if defined(BTA_PBS_INCLUDED) && (BTA_PBS_INCLUDED == TRUE)
-
-#include <stdio.h>
-#include <string.h>
-#include "bta_fs_api.h"
-#include "bta_pbs_int.h"
-#include "bta_fs_co.h"
-#include "gki.h"
-#include "utl.h"
-
-/*******************************************************************************
-** Constants
-*******************************************************************************/
-
-/*******************************************************************************
-** Local Function Prototypes
-*******************************************************************************/
-static void bta_pbs_translate_special_character(char *buffer, const char *str);
-/*******************************************************************************
-* Macros for PBS
-*******************************************************************************/
-#define BTA_PBS_XML_EOL "\n"
-#define BTA_PBS_FOLDER_LISTING_START ( "<?xml version=\"1.0\"?>\n" \
- "<!DOCTYPE vcard-listing SYSTEM \"vcard-listing.dtd\">\n" \
- "<vCard-listing version=\"1.0\">\n" )
-
-#define BTA_PBS_FOLDER_LISTING_END ( "</vCard-listing>" )
-#define BTA_PBS_PARENT_FOLDER (" <parent-folder/>\n")
-
-#define BTA_PBS_CARD_ELEM "card handle"
-#define BTA_PBS_NAME_ATTR "name"
-
-/*******************************************************************************
-* Exported Functions
-*******************************************************************************/
-/*******************************************************************************
-**
-** Function bta_pbs_getdirlist
-**
-** Description Processes the retrieval of a directory listing.
-**
-** Parameters p_pkt - Pointer to the OBX Get request
-** name directory to list.
-**
-**
-** Returns UINT8 - OBX response code. OBX_RSP_OK if initiated.
-**
-*******************************************************************************/
-void bta_pbs_getvlist(char *p_name)
-{
- tBTA_PBS_CB *p_cb = &bta_pbs_cb;
- tBTA_PBS_OBX_PKT *p_obx = &p_cb->obx;
- UINT16 temp_len;
- UINT8 rsp_code = OBX_RSP_OK;
- UINT16 pb_size, new_missed_call, len=0;
- UINT8 *p, *p_start;
- char *p_sep = NULL;
-
-
- /* if this the first time asking for access */
- if (!p_cb->p_path)
- {
- p_cb->p_path = (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1));
- /* If not specified, use the current work directory */
- if (!p_name || p_name[0] == '\0')
- {
- BCM_STRNCPY_S(p_cb->p_path, p_bta_fs_cfg->max_path_len+1, p_cb->p_workdir, p_bta_fs_cfg->max_path_len);
- p_sep = strchr((char *)p_cb->p_path, '/');
- if (p_sep)
- *p_sep = p_bta_fs_cfg->path_separator;
- }
- else
- {
- if ((strlen(p_cb->p_workdir) + strlen(p_name) + 2) <= p_bta_fs_cfg->max_path_len)
- {
- sprintf(p_cb->p_path, "%s%c%s", p_cb->p_workdir,
- p_bta_fs_cfg->path_separator, p_name);
- if (p_bta_fs_cfg->path_separator == 0x5c)
- {
- while ((p_sep = strchr((char *)p_cb->p_path, '/')) != NULL)
- {
- if (p_sep)
- *p_sep = p_bta_fs_cfg->path_separator;
- }
- }
- }
- else
- rsp_code = OBX_RSP_BAD_REQUEST;
- }
- if (rsp_code == OBX_RSP_OK)
- {
- p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle,
- /* p_cb->peer_mtu */ OBX_LRG_DATA_POOL_SIZE);
- if (p_obx->p_pkt)
- {
- /* Notify the application that a get file has been requested */
- bta_pbs_req_app_access (BTA_PBS_OPER_PULL_VCARD_LIST, p_cb);
- return;
- }
- else
- rsp_code = OBX_RSP_BAD_REQUEST;
- }
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- bta_pbs_clean_getput(p_cb, TRUE);
- }
- else if (p_cb->p_path)
- {
- /* Build the listing */
- if (rsp_code == OBX_RSP_OK)
- {
- if (!p_obx->p_pkt)
- p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle,
- /* p_cb->peer_mtu */ OBX_LRG_DATA_POOL_SIZE);
- if (p_obx->p_pkt)
- {
- /* Is this a new request or continuation? */
- if ((p_cb->obx_oper == BTA_PBS_OPER_NONE))
- {
- p_cb->get_only_indexes = FALSE;
-
- if (p_cb->getvlist_app_params.max_count == 0 ||
- p_cb->obj_type == BTA_PBS_MCH_OBJ)
- {
- p_start = OBX_AddByteStrStart(p_obx->p_pkt, &len);
- bta_pbs_co_getpbinfo(p_cb->obx_oper, p_cb->obj_type, &pb_size, &new_missed_call);
- p = p_start;
- /* Just looking for number of indexes only ? */
- if (p_cb->getvlist_app_params.max_count == 0)
- {
- *p++ = BTA_PBS_TAG_PB_SIZE;
- *p++ = 2;
- p_cb->p_stream_indexes = p; /* save location to store entries later */
- UINT16_TO_BE_STREAM(p, p_cb->getvlist_app_params.max_count);
-
- /* overwrite appl params max count so entries will be retrieved */
- p_cb->getvlist_app_params.max_count = BTA_PBS_MAX_LIST_COUNT;
- /* ignore the list start offset */
- p_cb->getvlist_app_params.start_offset = 0;
- p_cb->get_only_indexes = TRUE;
- p_cb->num_vlist_idxs = 0;
- APPL_TRACE_EVENT1("PBS Get Vcard List: Name [p_stream = 0x%07x] (Indexes Only)", /*p_cb->p_path*/(UINT32)p_cb->p_stream_indexes);
- }
-
- if (p_cb->obj_type == BTA_PBS_MCH_OBJ)
- {
- *p++ = BTA_PBS_TAG_NEW_MISSED_CALLS;
- *p++ = 1;
- *p++ = (UINT8) new_missed_call;
- }
- OBX_AddByteStrHdr(p_obx->p_pkt, OBX_HI_APP_PARMS, NULL, (UINT16)(p - p_start));
- }
-
- /* By pass Body Header if only requesting number of entries */
- if (!p_cb->get_only_indexes)
- {
- /* Add the start of the Body Header */
- p_obx->offset = 0;
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
-
- temp_len = strlen(BTA_PBS_FOLDER_LISTING_START);
-
- /* Add the beginning label of vard list */
- memcpy(p_obx->p_start, BTA_PBS_FOLDER_LISTING_START, temp_len);
- p_obx->bytes_left -= (UINT16)(temp_len + strlen(BTA_PBS_FOLDER_LISTING_END));
- p_obx->offset += temp_len;
-
- APPL_TRACE_EVENT1("PBS Get Vcard List: Name [%s]", p_cb->p_path);
- }
-
- p_cb->obx_oper = BTA_PBS_OPER_PULL_VCARD_LIST;
- p_cb->cout_active = TRUE;
-
- bta_pbs_co_getvlist(p_cb->p_path, &p_cb->getvlist_app_params,
- TRUE, &p_cb->vlist);
-
- /* List is not complete, so don't send the response yet */
- rsp_code = OBX_RSP_PART_CONTENT;
- }
- else /* continue case */
- {
- /* By pass Body Header if only requesting number of entries */
- if (!p_cb->get_only_indexes)
- {
- /* Add the start of the Body Header */
- p_obx->offset = 0;
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
- APPL_TRACE_EVENT1("PBS Get Vcard List: Name [%s] continue", p_cb->p_path);
- }
-
- /* Add the entry previously retrieved */
- rsp_code = bta_pbs_add_list_entry();
-
- if (!p_obx->final_pkt) {
- p_cb->cout_active = TRUE;
-
- bta_pbs_co_getvlist(p_cb->p_path, &p_cb->getvlist_app_params,
- FALSE, &p_cb->vlist);
- /* List is not complete, so don't send the response yet */
- rsp_code = OBX_RSP_PART_CONTENT;
- } else
- p_obx->final_pkt = FALSE;
- }
- }
- else
- rsp_code = OBX_RSP_SERVICE_UNAVL;
- }
- }
- else /* Error occurred */
- rsp_code = OBX_RSP_SERVICE_UNAVL;
-
- /* Response goes out if complete or error occurred */
- if (rsp_code != OBX_RSP_PART_CONTENT)
- bta_pbs_end_of_list(rsp_code);
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_proc_get_file
-**
-** Description Processes a Get File Operation.
-** If first OBX request, the file is opened, otherwise if it is
-** a continuation the next read is initiated.
-**
-** Parameters p_pkt - Pointer to the OBX Get request
-** name of file to read.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_proc_get_file(char *p_name, tBTA_PBS_OPER operation)
-{
- tBTA_PBS_CB *p_cb = &bta_pbs_cb;
- tBTA_PBS_OBX_PKT *p_obx = &p_cb->obx;
- UINT8 rsp_code = OBX_RSP_SERVICE_UNAVL;
- char *p_sep;
-
- if (operation != BTA_PBS_OPER_PULL_PB && operation != BTA_PBS_OPER_PULL_VCARD_ENTRY)
- return;
- /* Allocate an OBX packet */
- if (p_obx->p_pkt != NULL || (p_obx->p_pkt = (BT_HDR *)OBX_HdrInit(p_cb->obx_handle,
- /*p_cb->peer_mtu*/OBX_LRG_DATA_POOL_SIZE)) != NULL)
- {
- /* Is this a new request or continuation? */
- if ((p_cb->obx_oper == BTA_PBS_OPER_NONE))
- {
- /* Validate the name */
- if (p_name)
- {
- if ((p_cb->p_path =
- (char *)GKI_getbuf((UINT16)(p_bta_fs_cfg->max_path_len + 1))) != NULL)
- {
- /* Build a fully qualified path for Pull Vcard entry */
- if (operation == BTA_PBS_OPER_PULL_VCARD_ENTRY)
- {
- if ((strlen(p_cb->p_workdir) + strlen(p_name) + 2)
- <= p_bta_fs_cfg->max_path_len)
- {
- rsp_code = OBX_RSP_OK;
- sprintf(p_cb->p_path, "%s%c%s", p_cb->p_workdir,
- p_bta_fs_cfg->path_separator, p_name);
- if (p_bta_fs_cfg->path_separator == 0x5c) {
- while ((p_sep = strchr((char *)p_cb->p_path, '/')) != NULL)
- {
- if (p_sep)
- *p_sep = p_bta_fs_cfg->path_separator;
- }
- }
-
- APPL_TRACE_EVENT1("PBS PULL VCARD ENTRY: Name [%s]", p_cb->p_path);
-
- p_cb->obx_oper = BTA_PBS_OPER_PULL_VCARD_ENTRY;
-
- /* Notify the application that a get file has been requested */
- bta_pbs_req_app_access (BTA_PBS_OPER_PULL_VCARD_ENTRY, p_cb);
- }
- }
-
- /* Build a fully qualified path for Pull PBentry */
- if (operation == BTA_PBS_OPER_PULL_PB)
- {
- if ((strlen(p_cb->p_rootpath) + strlen(p_name) + 2)
- <= p_bta_fs_cfg->max_path_len)
- {
- rsp_code = OBX_RSP_OK;
- sprintf(p_cb->p_path, "%s%c%s", p_cb->p_rootpath,
- p_bta_fs_cfg->path_separator, p_name);
- if (p_bta_fs_cfg->path_separator == 0x5c) {
- while ((p_sep = strchr((char *)p_cb->p_path, '/')) != NULL)
- {
- if (p_sep)
- *p_sep = p_bta_fs_cfg->path_separator;
- }
- }
-
- APPL_TRACE_EVENT1("PBS PULL PB : Name [%s]", p_cb->p_path);
-
- p_cb->obx_oper = BTA_PBS_OPER_PULL_PB;
-
- /* Notify the application that a get file has been requested */
- bta_pbs_req_app_access (BTA_PBS_OPER_PULL_PB, p_cb);
- }
- }
-
- }
- }
- }
- else /* Continue reading from the file */
- {
- /* Add the start of the Body Header */
- p_obx->offset = 0;
- p_obx->bytes_left = 0;
- p_obx->p_start = OBX_AddBodyStart(p_obx->p_pkt, &p_obx->bytes_left);
-
- rsp_code = OBX_RSP_OK;
- p_cb->cout_active = TRUE;
- bta_pbs_co_read(p_cb->fd, p_cb->obx_oper, &p_obx->p_start[p_obx->offset],
- p_obx->bytes_left);
- }
- }
- if (rsp_code != OBX_RSP_OK)
- bta_pbs_get_file_rsp(rsp_code, 0);
-}
-
-
-
-
-/*******************************************************************************
-**
-** Function bta_pbs_chdir
-**
-** Description Changes the current path to the specified directory.
-**
-** Parameters p_pkt - Pointer to the OBX packet
-** backup_flag - if TRUE, path adjusted up one level.
-**
-** Returns UINT8 - OBX response code
-**
-*******************************************************************************/
-UINT8 bta_pbs_chdir(BT_HDR *p_pkt, BOOLEAN backup_flag, tBTA_PBS_OPER *p_op)
-{
- tBTA_PBS_CB *p_cb = &bta_pbs_cb;
- char *p_path;
- char *p_name;
- char *p_workdir = p_cb->p_workdir;
- UINT8 rsp_code = OBX_RSP_SERVICE_UNAVL;
- BOOLEAN is_dir;
-
- if (!backup_flag)
- {
- p_path = p_cb->p_path;
- p_name = p_cb->p_name;
-
- /* If No Name header, or if it is NULL, set to root path */
- if (*p_name == '\0')
- {
- BCM_STRNCPY_S(p_workdir, p_bta_fs_cfg->max_path_len+1, p_cb->p_rootpath, p_bta_fs_cfg->max_path_len);
- p_workdir[p_bta_fs_cfg->max_path_len] = '\0';
- p_cb->obj_type = BTA_PBS_NONE_OBJ;
- rsp_code = OBX_RSP_OK;
- APPL_TRACE_DEBUG0("PBS: Setting current path to ROOT");
- }
- /* Make sure the new path is not too big */
- else if ((strlen(p_name) + strlen(p_workdir) + 2)
- <= p_bta_fs_cfg->max_path_len)
- {
- if (!strcmp(p_name, "pb") || !strcmp(p_name, "telecom") ||
- !strcmp(p_name, "ich") || !strcmp(p_name, "och") ||
- !strcmp(p_name, "mch") || !strcmp(p_name, "cch") ||
- !strcmp(p_name, "SIM1"))
- {
-
- /* create a temporary path for creation attempt */
- sprintf(p_path, "%s%c%s", p_workdir,
- p_bta_fs_cfg->path_separator, p_name);
-
- if (((bta_fs_co_access(p_path, BTA_FS_ACC_EXIST,
- &is_dir, p_cb->app_id)) == BTA_FS_CO_OK) && is_dir)
- {
- *p_op = BTA_PBS_OPER_SET_PB;
- }
- else
- rsp_code = OBX_RSP_NOT_FOUND;
- }
- else
- rsp_code = OBX_RSP_BAD_REQUEST;
- }
- }
- else /* Backing up a directory */
- {
- /* Backup a level unless already at root */
- if (strcmp(p_workdir, p_cb->p_rootpath))
- {
- /* Find the last occurrence of separator and replace with '\0' */
- if ((p_path = strrchr(p_workdir, (int)p_bta_fs_cfg->path_separator)) != NULL)
- *p_path = '\0';
- p_cb->obj_type = BTA_PBS_NONE_OBJ;
- APPL_TRACE_DEBUG1("PBS: SET NEW PATH [%s]", p_cb->p_workdir);
-
- rsp_code = OBX_RSP_OK;
- }
- else
- rsp_code = OBX_RSP_NOT_FOUND;
- }
-
- return (rsp_code);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_pbs_end_of_list
-**
-** Description Finishes up the end body of the listing, and sends out the
-** OBX response
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_end_of_list(UINT8 rsp_code)
-{
- tBTA_PBS_CB *p_cb = &bta_pbs_cb;
- tBTA_PBS_OBX_PKT *p_obx = &p_cb->obx;
- UINT16 temp_len;
-
- /* Add the end of folder listing string if successful operation */
- if (rsp_code == OBX_RSP_OK || rsp_code == OBX_RSP_CONTINUE)
- {
- /* If only getting entries add the number to the response */
- if (p_cb->get_only_indexes)
- {
- if (rsp_code != OBX_RSP_OK)
- {
- rsp_code = OBX_RSP_OK;
- APPL_TRACE_WARNING0("bta_pbs_end_of_list: index ONLY, but received OBX_RSP_CONTINUE??");
- }
- APPL_TRACE_DEBUG2("bta_pbs_end_of_list: indexes = %d, p_stream_indexes = 0x%07x",
- p_cb->num_vlist_idxs, p_cb->p_stream_indexes);
- UINT16_TO_BE_STREAM(p_cb->p_stream_indexes, p_cb->num_vlist_idxs);
- }
- else
- {
- /* If listing has completed, add on end string (http) */
- if (rsp_code == OBX_RSP_OK)
- {
- temp_len = strlen(BTA_PBS_FOLDER_LISTING_END);
- memcpy(&p_obx->p_start[p_obx->offset], BTA_PBS_FOLDER_LISTING_END, temp_len);
- p_obx->offset += temp_len;
-
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, TRUE);
- }
- else /* More listing data to be sent */
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, FALSE);
- }
-
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* Do not deallocate buffer; OBX will */
- if (rsp_code == OBX_RSP_OK)
- bta_pbs_clean_getput(p_cb, FALSE);
- }
- else /* An error occurred */
- {
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)NULL);
- bta_pbs_clean_getput(p_cb, TRUE);
- }
-
-}
-
-/*******************************************************************************
-**
-** Function bta_pbs_get_file_rsp
-**
-** Description Finishes up the end body of the file get, and sends out the
-** OBX response
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_get_file_rsp(UINT8 rsp_code, UINT16 num_read)
-{
- tBTA_PBS_CB *p_cb = &bta_pbs_cb;
- tBTA_PBS_OBX_PKT *p_obx = &p_cb->obx;
- BOOLEAN done = TRUE;
-
- /* Send the response packet if successful operation */
- if (rsp_code == OBX_RSP_OK || rsp_code == OBX_RSP_CONTINUE)
- {
- p_obx->offset += num_read;
-
- /* More to be sent */
- if (rsp_code == OBX_RSP_CONTINUE)
- {
- if (p_obx->bytes_left != num_read)
- APPL_TRACE_WARNING2("PBS Read: Requested (0x%04x), Read In (0x%04x)",
- p_obx->bytes_left, num_read);
- done = FALSE;
- }
-
- if (num_read)
- OBX_AddBodyEnd(p_obx->p_pkt, p_obx->p_start, p_obx->offset, done);
- }
- else
- p_cb->obx_oper = BTA_PBS_OPER_NONE;
-
- OBX_GetRsp(p_cb->obx_handle, rsp_code, (BT_HDR *)p_obx->p_pkt);
- p_obx->p_pkt = NULL; /* Do not deallocate buffer; OBX will */
-
- /* Final response packet sent out */
- if (done && rsp_code == OBX_RSP_OK)
- bta_pbs_clean_getput(p_cb, FALSE);
- /* If there is error */
- if (rsp_code != OBX_RSP_OK && rsp_code != OBX_RSP_CONTINUE)
- bta_pbs_clean_getput(p_cb, TRUE);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_pbs_add_list_entry
-**
-** Description used by bta_pbs_getdirlist to write a list entry to an
-** obex packet (byte array).
-**
-** Returns UINT8 - OBX response code
-** OBX_RSP_OK
-** OBX_RSP_CONTINUE
-** Others send error response out
-**
-*******************************************************************************/
-UINT8 bta_pbs_add_list_entry(void)
-{
- tBTA_PBS_CB *p_cb = &bta_pbs_cb;
- tBTA_PBS_OBX_PKT *p_obx = &p_cb->obx;
- char *p_buf;
- UINT16 size;
- UINT8 rsp_code = OBX_RSP_SERVICE_UNAVL;
-
- /* Skip filling in entry; just counting */
- if (p_cb->get_only_indexes)
- {
- return (OBX_RSP_OK);
- }
-
- if ((p_buf = (char *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL)
- {
- p_buf[0] = '\0';
-
- APPL_TRACE_DEBUG2("bta_pbs_add_list_entry: handle:%s, name:%s",
- p_cb->vlist.handle, p_cb->vlist.name);
-
- sprintf(p_buf, " <" BTA_PBS_CARD_ELEM " = \"%s\" " BTA_PBS_NAME_ATTR " = \"",p_cb->vlist.handle);
- /* Need to translate special characters to XML format */
- bta_pbs_translate_special_character(strlen(p_buf) + p_buf, p_cb->vlist.name);
- sprintf(strlen(p_buf)+p_buf, "\"/>" BTA_PBS_XML_EOL);
- /* Make sure the entry fits into the current obx packet */
- size = strlen(p_buf);
- if (size <= p_obx->bytes_left)
- {
- if (size > 0)
- {
- memcpy (&p_obx->p_start[p_obx->offset], p_buf, size);
- p_obx->offset += size;
- p_obx->bytes_left -= size;
- }
- rsp_code = OBX_RSP_OK;
- }
- else /* entry did not fit in current obx packet; try to add entry in next obx req */
- rsp_code = OBX_RSP_CONTINUE;
-
- /* Done with temporary buffer */
- GKI_freebuf(p_buf);
- }
- else
- rsp_code = OBX_RSP_SERVICE_UNAVL;
-
- return (rsp_code);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_pbs_clean_getput
-**
-** Description Cleans up the get resources and control block
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_pbs_clean_getput(tBTA_PBS_CB *p_cb, BOOLEAN is_aborted)
-{
- tBTA_PBS_OBJECT objdata;
-
- /* Clean up control block */
- utl_freebuf((void**)&p_cb->obx.p_pkt);
-
- /* Close any open files */
- if (p_cb->fd >= 0)
- {
- bta_pbs_co_close(p_cb->fd);
- p_cb->fd = BTA_FS_INVALID_FD;
- }
-
- /* Notify the application */
- objdata.p_name = p_cb->p_path;
-
- if (is_aborted)
- objdata.status = BTA_PBS_FAIL;
- else
- objdata.status = BTA_PBS_OK;
-
- if (p_cb->p_cback && p_cb->obx_oper != 0)
- {
- objdata.operation = p_cb->obx_oper;
- /* Notify application of operation complete */
- p_cb->p_cback(BTA_PBS_OPER_CMPL_EVT, (tBTA_PBS *)&objdata);
- }
-
- utl_freebuf((void**)&p_cb->p_name);
- utl_freebuf((void**)&p_cb->p_path);
-
- p_cb->obx_oper = BTA_PBS_OPER_NONE;
- p_cb->obj_type = BTA_PBS_NONE_OBJ;
- p_cb->obx.bytes_left = 0;
- p_cb->file_length = BTA_FS_LEN_UNKNOWN;
- p_cb->acc_active = 0;
-// btla-specific ++
- p_cb->aborting = FALSE;
-// btla-specific --
- memset(&p_cb->getvlist_app_params, 0, sizeof(p_cb->getvlist_app_params));
- memset(&p_cb->pullpb_app_params, 0, sizeof(p_cb->pullpb_app_params));
- memset(&p_cb->vlist, 0, sizeof(p_cb->vlist));
-}
-
-/*****************************************************************************
-* Function: bta_pbs_read_app_params
-* Purpose: Read the application parameters from the given OBX packet
-*****************************************************************************/
-UINT8 * bta_pbs_read_app_params(BT_HDR *p_pkt, UINT8 tag, UINT16 *param_len)
-{
- UINT8 *p_data = NULL, *p = NULL;
- UINT16 data_len = 0;
- int left, len;
-
- if(OBX_ReadByteStrHdr(p_pkt, OBX_HI_APP_PARMS, &p_data, &data_len, 0))
- {
- left = data_len;
- while(left > 0)
- {
- len = *(p_data + 1);
- if(*p_data == tag)
- {
- p_data += 2;
- p = p_data;
- *param_len = (UINT16) len;
- break;
- }
- p_data += (len+2);
- left -= (len+2);
- }
- }
- return p;
-}
-
-
-
-/*******************************************************************************
-**
-** Function bta_pbs_handle_special_character
-**
-** Description Translate special characters to XML format
-**
-**
-** Returns Void
-**
-*******************************************************************************/
-static void bta_pbs_translate_special_character(char *buffer, const char *str)
-{
- char *buf=buffer;
- int slen = strlen(str);
- int i;
- for (i=0; i < slen;i++)
- {
-
- char c = str[i];
- switch (c)
- {
- case '<':
- BCM_STRCPY_S(buf,4,"&lt;");
- buf+=4;
- break;
- case '>':
- BCM_STRCPY_S(buf,4,"&gt;");
- buf+=4;
- break;
- case '\"':
- BCM_STRCPY_S(buf,6,"&quot;");
- buf+=6;
- break;
- case '\'':
- BCM_STRCPY_S(buf,6,"&apos;");
- buf+=6;
- break;
- case '&':
- BCM_STRCPY_S(buf,5,"&amp;");
- buf+=5;
- break;
- default:
- buf[0]=c;
- buf++;
- }
- }
- buf[0]='\0';
-
-}
-
-
-
-#endif /* BTA_PBS_INCLUDED */
diff --git a/btif/co/bta_fs_co.c b/btif/co/bta_fs_co.c
index 0ba35bd..8834555 100644
--- a/btif/co/bta_fs_co.c
+++ b/btif/co/bta_fs_co.c
@@ -58,8 +58,6 @@
#include "gki.h"
#include "bta_fs_co.h"
#include "bta_fs_ci.h"
-//#include "btui.h"
-//#include "btui_int.h"
#include <inttypes.h>
#ifndef AID_SYSTEM
diff --git a/btif/include/btif_av_api.h b/btif/include/btif_av_api.h
index 9f9beeb..4cee7b5 100644
--- a/btif/include/btif_av_api.h
+++ b/btif/include/btif_av_api.h
@@ -64,8 +64,7 @@
#include "btif_media.h"
#include "a2d_api.h"
#include "a2d_sbc.h"
-#include "a2d_m12.h"
-#include "a2d_m24.h"
+
/*****************************************************************************
** Constants and data types
diff --git a/btif/src/btif_av.c b/btif/src/btif_av.c
index 3096629..512ae61 100755
--- a/btif/src/btif_av.c
+++ b/btif/src/btif_av.c
@@ -938,11 +938,6 @@ bt_status_t btif_av_execute_service(BOOLEAN b_enable)
{
if (b_enable)
{
-#if (AVRC_METADATA_INCLUDED == TRUE)
- BTA_AvEnable(BTA_SEC_AUTHENTICATE|BTA_SEC_AUTHORIZE,
- BTA_AV_FEAT_RCTG|BTA_AV_FEAT_METADATA|BTA_AV_FEAT_VENDOR,
- bte_av_callback);
-#else
/* TODO: Removed BTA_SEC_AUTHORIZE since the Java/App does not
* handle this request in order to allow incoming connections to succeed.
* We need to put this back once support for this is added */
@@ -952,7 +947,6 @@ bt_status_t btif_av_execute_service(BOOLEAN b_enable)
* be initiated by the app/audioflinger layers */
BTA_AvEnable(BTA_SEC_AUTHENTICATE, (BTA_AV_FEAT_RCTG | BTA_AV_FEAT_NO_SCO_SSPD),
bte_av_callback);
-#endif
BTA_AvRegister(BTA_AV_CHNL_AUDIO, BTIF_AV_SERVICE_NAME, 0);
}
else {
diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c
index 9a0d0ee..a3f631a 100755
--- a/btif/src/btif_rc.c
+++ b/btif/src/btif_rc.c
@@ -67,12 +67,8 @@
/*****************************************************************************
** Constants & Macros
******************************************************************************/
-#if (!defined(AVRC_METADATA_INCLUDED) || (AVRC_METADATA_INCLUDED == FALSE))
#define BTIF_RC_USE_UINPUT TRUE
#include "uinput.h"
-#else
-#error "AVRCP 1.3 is not supported on Bluedroid yet."
-#endif
/* cod value for Headsets */
#define COD_AV_HEADSETS 0x0404
diff --git a/btif/src/btif_sock_sdp.c b/btif/src/btif_sock_sdp.c
index c441df0..b2553e0 100644
--- a/btif/src/btif_sock_sdp.c
+++ b/btif/src/btif_sock_sdp.c
@@ -78,9 +78,8 @@
#include "btm_int.h"
#include "btif_sock_sdp.h"
#include "utl.h"
-#include "../bta/ft/bta_fts_int.h"
#include "../bta/pb/bta_pbs_int.h"
-#include "../bta/op/bta_ops_int.h"
+#include "../include/bta_op_api.h"
#include <cutils/log.h>
#define info(fmt, ...) LOGI ("%s: " fmt,__FUNCTION__, ## __VA_ARGS__)
#define debug(fmt, ...) LOGD ("%s: " fmt,__FUNCTION__, ## __VA_ARGS__)
@@ -100,140 +99,11 @@ static const UINT8 UUID_OBEX_OBJECT_PUSH[] = {0x00, 0x00, 0x11, 0x05, 0x00, 0x0
static const UINT8 UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
-static const UINT8 UUID_OBEX_FILE_TRANSFER[] = {0x00, 0x00, 0x11, 0x06, 0x00, 0x00, 0x10, 0x00,
- 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
-#define IS_UUID(u1,u2) !memcmp(u1,u2,UUID_MAX_LENGTH)
-
-static int add_ftp_sdp(const char *p_service_name, int scn)
-{
- tSDP_PROTOCOL_ELEM protoList [3];
- UINT16 ftp_service = UUID_SERVCLASS_OBEX_FILE_TRANSFER;
- UINT16 browse = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
- BOOLEAN status = FALSE;
- int sdp_handle;
-
- info("scn: %d, service name: %s", scn, p_service_name);
- tBTA_UTL_COD cod;
-
-
- /* also set cod service bit for now */
- cod.service = BTM_COD_SERVICE_OBJ_TRANSFER;
- utl_set_device_class(&cod, BTA_UTL_SET_COD_SERVICE_CLASS);
-
- if ((sdp_handle = SDP_CreateRecord()) == 0)
- {
- error("FTS SDP: Unable to register FTP Service");
- return sdp_handle;
- }
-
- /* add service class */
- if (SDP_AddServiceClassIdList(sdp_handle, 1, &ftp_service))
- {
- /* add protocol list, including RFCOMM scn */
- protoList[0].protocol_uuid = UUID_PROTOCOL_L2CAP;
- protoList[0].num_params = 0;
- protoList[1].protocol_uuid = UUID_PROTOCOL_RFCOMM;
- protoList[1].num_params = 1;
- protoList[1].params[0] = scn;
- protoList[2].protocol_uuid = UUID_PROTOCOL_OBEX;
- protoList[2].num_params = 0;
-
- if (SDP_AddProtocolList(sdp_handle, 3, protoList))
- {
- status = TRUE; /* All mandatory fields were successful */
-
- /* optional: if name is not "", add a name entry */
- if (*p_service_name != '\0')
- SDP_AddAttribute(sdp_handle,
- (UINT16)ATTR_ID_SERVICE_NAME,
- (UINT8)TEXT_STR_DESC_TYPE,
- (UINT32)(strlen(p_service_name) + 1),
- (UINT8 *)p_service_name);
-
- /* Add in the Bluetooth Profile Descriptor List */
- SDP_AddProfileDescriptorList(sdp_handle,
- UUID_SERVCLASS_OBEX_FILE_TRANSFER,
- BTA_FTS_DEFAULT_VERSION);
-
- } /* end of setting mandatory protocol list */
- } /* end of setting mandatory service class */
-
- /* Make the service browseable */
- SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse);
-
- if (!status)
- {
- SDP_DeleteRecord(sdp_handle);
- sdp_handle = 0;
- error("bta_fts_sdp_register FAILED");
- }
- else
- {
- bta_sys_add_uuid(ftp_service); /* UUID_SERVCLASS_OBEX_FILE_TRANSFER */
- error("FTS: SDP Registered (handle 0x%08x)", sdp_handle);
- }
-
- return sdp_handle;
-}
-
-
-static int add_spp_sdp(const char *service_name, int scn)
-{
-#if 0
- tSPP_STATUS status = SPP_SUCCESS;
- UINT16 serviceclassid = UUID_SERVCLASS_SERIAL_PORT;
- tSDP_PROTOCOL_ELEM proto_elem_list[SPP_NUM_PROTO_ELEMS];
- int sdp_handle;
-
- info("scn %d, service name %s", scn, service_name);
- /* register the service */
- if ((sdp_handle = SDP_CreateRecord()) != FALSE)
- {
- /*** Fill out the protocol element sequence for SDP ***/
- proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP;
- proto_elem_list[0].num_params = 0;
- proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_RFCOMM;
- proto_elem_list[1].num_params = 1;
-
- proto_elem_list[1].params[0] = scn;
-
- if (SDP_AddProtocolList(sdp_handle, SPP_NUM_PROTO_ELEMS,
- proto_elem_list))
- {
- if (SDP_AddServiceClassIdList(sdp_handle, 1, &serviceclassid))
- {
- if ((SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME,
- TEXT_STR_DESC_TYPE, (UINT32)(strlen(service_name)+1),
- (UINT8 *)service_name)) == FALSE)
-
- status = SPP_ERR_SDP_ATTR;
- else
- {
- UINT16 list[1];
+#define IS_UUID(u1,u2) !memcmp(u1,u2,UUID_MAX_LENGTH)
- /* Make the service browseable */
- list[0] = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
- if ((SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST,
- 1, list)) == FALSE)
- status = SPP_ERR_SDP_CLASSID;
- }
- }
- else
- status = SPP_ERR_SDP_CLASSID;
- }
- else
- status = SPP_ERR_SDP_PROTO;
- }
- else
- status = SPP_ERR_SDP_REG;
-
- return spb_handle;
-#endif
- return 0;
-}
#define BTM_NUM_PROTO_ELEMS 2
static int add_sdp_by_uuid(const char *name, const uint8_t *service_uuid, UINT16 channel)
{
@@ -410,11 +280,9 @@ static int add_ops_sdp(const char *p_service_name,int scn)
tSDP_PROTOCOL_ELEM protoList [BTA_OPS_PROTOCOL_COUNT];
- tOBX_StartParams start_params;
UINT16 servclass = UUID_SERVCLASS_OBEX_OBJECT_PUSH;
int i, j;
tBTA_UTL_COD cod;
- tOBX_STATUS status;
UINT8 desc_type[BTA_OPS_NUM_FMTS];
UINT8 type_len[BTA_OPS_NUM_FMTS];
UINT8 *type_value[BTA_OPS_NUM_FMTS];
@@ -512,12 +380,6 @@ static int add_rfc_sdp_by_uuid(const char* name, const uint8_t* uuid, int scn)
{
handle = add_pbap_sdp(name, final_scn); //PBAP Server is always 19
}
- else if (IS_UUID(UUID_OBEX_FILE_TRANSFER,uuid))
- {
- APPL_TRACE_EVENT0("Stopping btld ftp serivce when 3-party registering ftp service");
- //BTA_FtsDisable();
- handle = add_sdp_by_uuid(name, uuid, final_scn);
- }
else
{
handle = add_sdp_by_uuid(name, uuid, final_scn);
@@ -563,8 +425,7 @@ int add_rfc_sdp_rec(const char* name, const uint8_t* uuid, int scn)
case RESERVED_SCN_OPS:
add_ops_sdp(name,scn);
break;
- default://serial port profile
- sdp_handle = add_spp_sdp(name, scn);
+ default:
break;
}
}
diff --git a/include/bdroid_crespo.txt b/include/bdroid_crespo.txt
index 573216a..2c58193 100755
--- a/include/bdroid_crespo.txt
+++ b/include/bdroid_crespo.txt
@@ -1,28 +1,9 @@
AVCT_INCLUDED = TRUE
AVRC_INCLUDED = TRUE
-AVRC_METADATA_INCLUDED = FALSE
-AVRC_ADV_CTRL_INCLUDED = FALSE
AVDT_INCLUDED = TRUE
UNV_INCLUDED = FALSE
A2D_INCLUDED = TRUE
A2D_SBC_INCLUDED = TRUE
-A2D_M12_INCLUDED = FALSE
-A2D_M24_INCLUDED = FALSE
-VDP_INCLUDED = FALSE
-VDP_H263_INCLUDED = FALSE
-VDP_MPEG_INCLUDED = FALSE
-VDP_VEND_INCLUDED = FALSE
-BIP_INCLUDED = FALSE
-BIP_INITR_INCLUDED = FALSE
-BIP_RSPDR_INCLUDED = FALSE
-BIP_PUSH_INCLUDED = FALSE
-BIP_PULL_INCLUDED = FALSE
-BIP_PRINTING_INCLUDED = FALSE
-BIP_ARCHIVE_INCLUDED = FALSE
-BIP_CAMERA_INCLUDED = FALSE
-BIP_DISPLAY_INCLUDED = FALSE
-BPP_INCLUDED = FALSE
-BPP_SND_INCLUDED = FALSE
DUN_INCLUDED = FALSE
GAP_INCLUDED = FALSE
GOEP_INCLUDED = FALSE
@@ -33,14 +14,7 @@ L2CAP_INCLUDED = TRUE
L2CAP_LINK_INACTIVITY_TOUT = 4
L2CAP_FCR_INCLUDED = TRUE
L2CAP_EXTFEA_SUPPORTED_MASK = (L2CAP_EXTFEA_ENH_RETRANS | L2CAP_EXTFEA_STREAM_MODE | L2CAP_EXTFEA_NO_CRC | L2CAP_EXTFEA_FIXED_CHNLS)
-OBX_INCLUDED = TRUE
-OBX_SERVER_INCLUDED = TRUE
-OBX_CLIENT_INCLUDED = TRUE
-OBX_MD5_INCLUDED = FALSE
-OBX_MD5_TEST_INCLUDED = FALSE
-OBX_14_INCLUDED = FALSE
BTUI_OPS_FORMATS = (BTA_OP_VCARD21_MASK | BTA_OP_VCAL_MASK | BTA_OP_VNOTE_MASK | BTA_OP_ANY_MASK)
-BTA_OPC_SENDING_ABORT = TRUE
RFCOMM_INCLUDED = TRUE
MAX_RFC_PORTS = 30
MAX_BD_CONNECTIONS = 7
@@ -68,7 +42,6 @@ SDP_MAX_ATTR_LEN = 400
SDP_MAX_PAD_LEN = 600
BNEP_INCLUDED = TRUE
PAN_INCLUDED = TRUE
-SAP_SERVER_INCLUDED = FALSE
HID_DEV_INCLUDED = FALSE
HID_HOST_INCLUDED = TRUE
BLE_INCLUDED = FALSE
@@ -190,7 +163,7 @@ BTAPP_DM_SUPPORTED_SERVICES = (BTA_HSP_SERVICE_MASK | BTA_HFP_SERVICE_MASK | BTA
PBAP_ZERO_VCARD_IN_DB = FALSE
BTA_DM_SDP_DB_SIZE = 8000
MAX_L2CAP_CLIENTS = 15
-FTS_REJECT_INVALID_OBEX_SET_PATH_REQ = TRUE
+FTS_REJECT_INVALID_OBEX_SET_PATH_REQ = FALSE
HID_HOST_MAX_CONN_RETRY = (3)
BTM_DISC_DURING_RS = TRUE
BTM_WBS_INCLUDED = FALSE
diff --git a/include/bdroid_crespo4g.txt b/include/bdroid_crespo4g.txt
index 573216a..2c58193 100755
--- a/include/bdroid_crespo4g.txt
+++ b/include/bdroid_crespo4g.txt
@@ -1,28 +1,9 @@
AVCT_INCLUDED = TRUE
AVRC_INCLUDED = TRUE
-AVRC_METADATA_INCLUDED = FALSE
-AVRC_ADV_CTRL_INCLUDED = FALSE
AVDT_INCLUDED = TRUE
UNV_INCLUDED = FALSE
A2D_INCLUDED = TRUE
A2D_SBC_INCLUDED = TRUE
-A2D_M12_INCLUDED = FALSE
-A2D_M24_INCLUDED = FALSE
-VDP_INCLUDED = FALSE
-VDP_H263_INCLUDED = FALSE
-VDP_MPEG_INCLUDED = FALSE
-VDP_VEND_INCLUDED = FALSE
-BIP_INCLUDED = FALSE
-BIP_INITR_INCLUDED = FALSE
-BIP_RSPDR_INCLUDED = FALSE
-BIP_PUSH_INCLUDED = FALSE
-BIP_PULL_INCLUDED = FALSE
-BIP_PRINTING_INCLUDED = FALSE
-BIP_ARCHIVE_INCLUDED = FALSE
-BIP_CAMERA_INCLUDED = FALSE
-BIP_DISPLAY_INCLUDED = FALSE
-BPP_INCLUDED = FALSE
-BPP_SND_INCLUDED = FALSE
DUN_INCLUDED = FALSE
GAP_INCLUDED = FALSE
GOEP_INCLUDED = FALSE
@@ -33,14 +14,7 @@ L2CAP_INCLUDED = TRUE
L2CAP_LINK_INACTIVITY_TOUT = 4
L2CAP_FCR_INCLUDED = TRUE
L2CAP_EXTFEA_SUPPORTED_MASK = (L2CAP_EXTFEA_ENH_RETRANS | L2CAP_EXTFEA_STREAM_MODE | L2CAP_EXTFEA_NO_CRC | L2CAP_EXTFEA_FIXED_CHNLS)
-OBX_INCLUDED = TRUE
-OBX_SERVER_INCLUDED = TRUE
-OBX_CLIENT_INCLUDED = TRUE
-OBX_MD5_INCLUDED = FALSE
-OBX_MD5_TEST_INCLUDED = FALSE
-OBX_14_INCLUDED = FALSE
BTUI_OPS_FORMATS = (BTA_OP_VCARD21_MASK | BTA_OP_VCAL_MASK | BTA_OP_VNOTE_MASK | BTA_OP_ANY_MASK)
-BTA_OPC_SENDING_ABORT = TRUE
RFCOMM_INCLUDED = TRUE
MAX_RFC_PORTS = 30
MAX_BD_CONNECTIONS = 7
@@ -68,7 +42,6 @@ SDP_MAX_ATTR_LEN = 400
SDP_MAX_PAD_LEN = 600
BNEP_INCLUDED = TRUE
PAN_INCLUDED = TRUE
-SAP_SERVER_INCLUDED = FALSE
HID_DEV_INCLUDED = FALSE
HID_HOST_INCLUDED = TRUE
BLE_INCLUDED = FALSE
@@ -190,7 +163,7 @@ BTAPP_DM_SUPPORTED_SERVICES = (BTA_HSP_SERVICE_MASK | BTA_HFP_SERVICE_MASK | BTA
PBAP_ZERO_VCARD_IN_DB = FALSE
BTA_DM_SDP_DB_SIZE = 8000
MAX_L2CAP_CLIENTS = 15
-FTS_REJECT_INVALID_OBEX_SET_PATH_REQ = TRUE
+FTS_REJECT_INVALID_OBEX_SET_PATH_REQ = FALSE
HID_HOST_MAX_CONN_RETRY = (3)
BTM_DISC_DURING_RS = TRUE
BTM_WBS_INCLUDED = FALSE
diff --git a/include/bdroid_maguro.txt b/include/bdroid_maguro.txt
index 917d8ef..9fe40d7 100755
--- a/include/bdroid_maguro.txt
+++ b/include/bdroid_maguro.txt
@@ -1,28 +1,9 @@
AVCT_INCLUDED = TRUE
AVRC_INCLUDED = TRUE
-AVRC_METADATA_INCLUDED = FALSE
-AVRC_ADV_CTRL_INCLUDED = FALSE
AVDT_INCLUDED = TRUE
UNV_INCLUDED = FALSE
A2D_INCLUDED = TRUE
A2D_SBC_INCLUDED = TRUE
-A2D_M12_INCLUDED = FALSE
-A2D_M24_INCLUDED = FALSE
-VDP_INCLUDED = FALSE
-VDP_H263_INCLUDED = FALSE
-VDP_MPEG_INCLUDED = FALSE
-VDP_VEND_INCLUDED = FALSE
-BIP_INCLUDED = FALSE
-BIP_INITR_INCLUDED = FALSE
-BIP_RSPDR_INCLUDED = FALSE
-BIP_PUSH_INCLUDED = FALSE
-BIP_PULL_INCLUDED = FALSE
-BIP_PRINTING_INCLUDED = FALSE
-BIP_ARCHIVE_INCLUDED = FALSE
-BIP_CAMERA_INCLUDED = FALSE
-BIP_DISPLAY_INCLUDED = FALSE
-BPP_INCLUDED = FALSE
-BPP_SND_INCLUDED = FALSE
DUN_INCLUDED = FALSE
GAP_INCLUDED = FALSE
GOEP_INCLUDED = FALSE
@@ -33,14 +14,7 @@ L2CAP_INCLUDED = TRUE
L2CAP_LINK_INACTIVITY_TOUT = 4
L2CAP_FCR_INCLUDED = TRUE
L2CAP_EXTFEA_SUPPORTED_MASK = (L2CAP_EXTFEA_ENH_RETRANS | L2CAP_EXTFEA_STREAM_MODE | L2CAP_EXTFEA_NO_CRC | L2CAP_EXTFEA_FIXED_CHNLS)
-OBX_INCLUDED = TRUE
-OBX_SERVER_INCLUDED = TRUE
-OBX_CLIENT_INCLUDED = TRUE
-OBX_MD5_INCLUDED = FALSE
-OBX_MD5_TEST_INCLUDED = FALSE
-OBX_14_INCLUDED = FALSE
BTUI_OPS_FORMATS = (BTA_OP_VCARD21_MASK | BTA_OP_VCAL_MASK | BTA_OP_VNOTE_MASK | BTA_OP_ANY_MASK)
-BTA_OPC_SENDING_ABORT = TRUE
RFCOMM_INCLUDED = TRUE
MAX_RFC_PORTS = 30
MAX_BD_CONNECTIONS = 7
@@ -68,7 +42,6 @@ SDP_MAX_ATTR_LEN = 400
SDP_MAX_PAD_LEN = 600
BNEP_INCLUDED = TRUE
PAN_INCLUDED = TRUE
-SAP_SERVER_INCLUDED = FALSE
HID_DEV_INCLUDED = FALSE
HID_HOST_INCLUDED = TRUE
BLE_INCLUDED = FALSE
@@ -188,7 +161,7 @@ BTAPP_DM_SUPPORTED_SERVICES = (BTA_HSP_SERVICE_MASK | BTA_HFP_SERVICE_MASK | BTA
PBAP_ZERO_VCARD_IN_DB = FALSE
BTA_DM_SDP_DB_SIZE = 8000
MAX_L2CAP_CLIENTS = 15
-FTS_REJECT_INVALID_OBEX_SET_PATH_REQ = TRUE
+FTS_REJECT_INVALID_OBEX_SET_PATH_REQ = FALSE
HID_HOST_MAX_CONN_RETRY = (3)
BTM_DISC_DURING_RS = TRUE
BTM_WBS_INCLUDED = FALSE
diff --git a/include/bdroid_toro.txt b/include/bdroid_toro.txt
index a8742ce..3e5a4ea 100755
--- a/include/bdroid_toro.txt
+++ b/include/bdroid_toro.txt
@@ -1,28 +1,9 @@
AVCT_INCLUDED = TRUE
AVRC_INCLUDED = TRUE
-AVRC_METADATA_INCLUDED = FALSE
-AVRC_ADV_CTRL_INCLUDED = FALSE
AVDT_INCLUDED = TRUE
UNV_INCLUDED = FALSE
A2D_INCLUDED = TRUE
A2D_SBC_INCLUDED = TRUE
-A2D_M12_INCLUDED = FALSE
-A2D_M24_INCLUDED = FALSE
-VDP_INCLUDED = FALSE
-VDP_H263_INCLUDED = FALSE
-VDP_MPEG_INCLUDED = FALSE
-VDP_VEND_INCLUDED = FALSE
-BIP_INCLUDED = FALSE
-BIP_INITR_INCLUDED = FALSE
-BIP_RSPDR_INCLUDED = FALSE
-BIP_PUSH_INCLUDED = FALSE
-BIP_PULL_INCLUDED = FALSE
-BIP_PRINTING_INCLUDED = FALSE
-BIP_ARCHIVE_INCLUDED = FALSE
-BIP_CAMERA_INCLUDED = FALSE
-BIP_DISPLAY_INCLUDED = FALSE
-BPP_INCLUDED = FALSE
-BPP_SND_INCLUDED = FALSE
DUN_INCLUDED = FALSE
GAP_INCLUDED = FALSE
GOEP_INCLUDED = FALSE
@@ -33,14 +14,7 @@ L2CAP_INCLUDED = TRUE
L2CAP_LINK_INACTIVITY_TOUT = 4
L2CAP_FCR_INCLUDED = TRUE
L2CAP_EXTFEA_SUPPORTED_MASK = (L2CAP_EXTFEA_ENH_RETRANS | L2CAP_EXTFEA_STREAM_MODE | L2CAP_EXTFEA_NO_CRC | L2CAP_EXTFEA_FIXED_CHNLS)
-OBX_INCLUDED = TRUE
-OBX_SERVER_INCLUDED = TRUE
-OBX_CLIENT_INCLUDED = TRUE
-OBX_MD5_INCLUDED = FALSE
-OBX_MD5_TEST_INCLUDED = FALSE
-OBX_14_INCLUDED = FALSE
BTUI_OPS_FORMATS = (BTA_OP_VCARD21_MASK | BTA_OP_VCAL_MASK | BTA_OP_VNOTE_MASK | BTA_OP_ANY_MASK)
-BTA_OPC_SENDING_ABORT = TRUE
RFCOMM_INCLUDED = TRUE
MAX_RFC_PORTS = 30
MAX_BD_CONNECTIONS = 7
@@ -68,7 +42,6 @@ SDP_MAX_ATTR_LEN = 400
SDP_MAX_PAD_LEN = 600
BNEP_INCLUDED = TRUE
PAN_INCLUDED = TRUE
-SAP_SERVER_INCLUDED = FALSE
HID_DEV_INCLUDED = FALSE
HID_HOST_INCLUDED = TRUE
BLE_INCLUDED = FALSE
@@ -188,7 +161,7 @@ BTAPP_DM_SUPPORTED_SERVICES = (BTA_HSP_SERVICE_MASK | BTA_HFP_SERVICE_MASK | BTA
PBAP_ZERO_VCARD_IN_DB = FALSE
BTA_DM_SDP_DB_SIZE = 8000
MAX_L2CAP_CLIENTS = 15
-FTS_REJECT_INVALID_OBEX_SET_PATH_REQ = TRUE
+FTS_REJECT_INVALID_OBEX_SET_PATH_REQ = FALSE
HID_HOST_MAX_CONN_RETRY = (3)
BTM_DISC_DURING_RS = TRUE
BTM_WBS_INCLUDED = FALSE
diff --git a/include/bdroid_wingray.txt b/include/bdroid_wingray.txt
index a63f095..3636ba7 100755
--- a/include/bdroid_wingray.txt
+++ b/include/bdroid_wingray.txt
@@ -1,28 +1,9 @@
AVCT_INCLUDED = TRUE
AVRC_INCLUDED = TRUE
-AVRC_METADATA_INCLUDED = FALSE
-AVRC_ADV_CTRL_INCLUDED = FALSE
AVDT_INCLUDED = TRUE
UNV_INCLUDED = FALSE
A2D_INCLUDED = TRUE
A2D_SBC_INCLUDED = TRUE
-A2D_M12_INCLUDED = FALSE
-A2D_M24_INCLUDED = FALSE
-VDP_INCLUDED = FALSE
-VDP_H263_INCLUDED = FALSE
-VDP_MPEG_INCLUDED = FALSE
-VDP_VEND_INCLUDED = FALSE
-BIP_INCLUDED = FALSE
-BIP_INITR_INCLUDED = FALSE
-BIP_RSPDR_INCLUDED = FALSE
-BIP_PUSH_INCLUDED = FALSE
-BIP_PULL_INCLUDED = FALSE
-BIP_PRINTING_INCLUDED = FALSE
-BIP_ARCHIVE_INCLUDED = FALSE
-BIP_CAMERA_INCLUDED = FALSE
-BIP_DISPLAY_INCLUDED = FALSE
-BPP_INCLUDED = FALSE
-BPP_SND_INCLUDED = FALSE
DUN_INCLUDED = FALSE
GAP_INCLUDED = FALSE
GOEP_INCLUDED = FALSE
@@ -33,14 +14,7 @@ L2CAP_INCLUDED = TRUE
L2CAP_LINK_INACTIVITY_TOUT = 4
L2CAP_FCR_INCLUDED = TRUE
L2CAP_EXTFEA_SUPPORTED_MASK = (L2CAP_EXTFEA_ENH_RETRANS | L2CAP_EXTFEA_STREAM_MODE | L2CAP_EXTFEA_NO_CRC | L2CAP_EXTFEA_FIXED_CHNLS)
-OBX_INCLUDED = TRUE
-OBX_SERVER_INCLUDED = TRUE
-OBX_CLIENT_INCLUDED = TRUE
-OBX_MD5_INCLUDED = FALSE
-OBX_MD5_TEST_INCLUDED = FALSE
-OBX_14_INCLUDED = FALSE
BTUI_OPS_FORMATS = (BTA_OP_VCARD21_MASK | BTA_OP_VCAL_MASK | BTA_OP_VNOTE_MASK | BTA_OP_ANY_MASK)
-BTA_OPC_SENDING_ABORT = TRUE
RFCOMM_INCLUDED = TRUE
MAX_RFC_PORTS = 30
MAX_BD_CONNECTIONS = 7
@@ -68,7 +42,6 @@ SDP_MAX_ATTR_LEN = 400
SDP_MAX_PAD_LEN = 600
BNEP_INCLUDED = TRUE
PAN_INCLUDED = TRUE
-SAP_SERVER_INCLUDED = FALSE
HID_DEV_INCLUDED = FALSE
HID_HOST_INCLUDED = FALSE
BLE_INCLUDED = FALSE
@@ -189,7 +162,7 @@ BTAPP_DM_SUPPORTED_SERVICES = (BTA_HSP_SERVICE_MASK | BTA_HFP_SERVICE_MASK | BTA
PBAP_ZERO_VCARD_IN_DB = FALSE
BTA_DM_SDP_DB_SIZE = 8000
MAX_L2CAP_CLIENTS = 15
-FTS_REJECT_INVALID_OBEX_SET_PATH_REQ = TRUE
+FTS_REJECT_INVALID_OBEX_SET_PATH_REQ = FALSE
HID_HOST_MAX_CONN_RETRY = (3)
BTM_DISC_DURING_RS = TRUE
BTM_WBS_INCLUDED = FALSE
diff --git a/include/bt_target.h b/include/bt_target.h
index b5ac06c..7e29052 100755
--- a/include/bt_target.h
+++ b/include/bt_target.h
@@ -3022,16 +3022,6 @@ Range: Minimum 12000 (12 secs) on BR/EDR when supporting PBF.
#define AVCT_NUM_CONN 3
#endif
-/* TRUE to support the browsing channel. */
-#ifndef AVCT_BROWSE_INCLUDED
-#define AVCT_BROWSE_INCLUDED TRUE
-#endif
-
-#if ((L2CAP_FCR_INCLUDED == FALSE) && (AVCT_BROWSE_INCLUDED == TRUE))
-#undef AVCT_BROWSE_INCLUDED
-#define AVCT_BROWSE_INCLUDED FALSE
-#endif
-
/* Pool ID where to reassemble the SDU.
This Pool allows buffers to be used that are larger than
the L2CAP_MAX_MTU. */
@@ -3113,16 +3103,6 @@ Range: Minimum 12000 (12 secs) when supporting PBF.
#define AVRC_INCLUDED FALSE
#endif
-/* TRUE to support AVRCP 1.3 - Metadata. */
-#ifndef AVRC_METADATA_INCLUDED
-#define AVRC_METADATA_INCLUDED TRUE
-#endif
-
-/* TRUE to support AVRCP 1.4 - Advanced Control. */
-#ifndef AVRC_ADV_CTRL_INCLUDED
-#define AVRC_ADV_CTRL_INCLUDED TRUE
-#endif
-
/******************************************************************************
**
** MCAP
diff --git a/stack/Android.mk b/stack/Android.mk
index 0d7a17e..d2ccaff 100644
--- a/stack/Android.mk
+++ b/stack/Android.mk
@@ -13,16 +13,11 @@ LOCAL_C_INCLUDES:= . \
$(LOCAL_PATH)/avdt \
$(LOCAL_PATH)/gatt \
$(LOCAL_PATH)/gap \
- $(LOCAL_PATH)/bip \
$(LOCAL_PATH)/pan \
- $(LOCAL_PATH)/bpp \
$(LOCAL_PATH)/bnep \
$(LOCAL_PATH)/hid \
- $(LOCAL_PATH)/obx \
$(LOCAL_PATH)/sdp \
$(LOCAL_PATH)/smp \
- $(LOCAL_PATH)/amp \
- $(LOCAL_PATH)/amp/security \
$(LOCAL_PATH)/../include \
$(LOCAL_PATH)/../gki/common \
$(LOCAL_PATH)/../gki/ulinux \
@@ -41,25 +36,13 @@ endif
LOCAL_PRELINK_MODULE:=false
LOCAL_SRC_FILES:= \
- ./dun/dun_api.c \
./a2dp/a2d_api.c \
- ./a2dp/a2d_m24.c \
- ./a2dp/a2d_m12.c \
./a2dp/a2d_sbc.c \
- ./avrc/avrc_bld_tg.c \
./avrc/avrc_api.c \
- ./avrc/avrc_utils.c \
- ./avrc/avrc_pars_ct.c \
./avrc/avrc_sdp.c \
- ./avrc/avrc_pars_tg.c \
- ./avrc/avrc_bld_ct.c \
./avrc/avrc_opt.c \
- ./hid/hidd_conn.c \
- ./hid/hidd_mgmt.c \
./hid/hidh_api.c \
- ./hid/hidd_pm.c \
./hid/hidh_conn.c \
- ./hid/hidd_api.c \
./bnep/bnep_main.c \
./bnep/bnep_utils.c \
./bnep/bnep_api.c \
@@ -102,33 +85,6 @@ LOCAL_SRC_FILES:= \
./gatt/att_protocol.c \
./gatt/gatt_attr.c \
./gatt/gatt_db.c \
- ./obx/hdrs/obx_dutf.c \
- ./obx/hdrs/obx_dwchar.c \
- ./obx/hdrs/obx_gen.c \
- ./obx/hdrs/obx_dunic.c \
- ./obx/hdrs/utfc.c \
- ./obx/hdrs/obx_dbtp.c \
- ./obx/hdrs/obx_dauth.c \
- ./obx/hdrs/obx_ebtp.c \
- ./obx/hdrs/obx_wchar.c \
- ./obx/hdrs/obx_eunic.c \
- ./obx/hdrs/obx_eopt.c \
- ./obx/hdrs/obx_dopt.c \
- ./obx/hdrs/obx_ewchar.c \
- ./obx/hdrs/obx_eutf.c \
- ./obx/obx_csm.c \
- ./obx/obx_ssm.c \
- ./obx/obx_cact.c \
- ./obx/obx_md5.c \
- ./obx/obx_rfc.c \
- ./obx/obx_main.c \
- ./obx/obx_sapi.c \
- ./obx/obx_l2c.c \
- ./obx/obx_sact.c \
- ./obx/obx_utils.c \
- ./obx/obx_capi.c \
- ./avct/avct_bcb_act.c \
- ./avct/avct_l2c_br.c \
./avct/avct_api.c \
./avct/avct_l2c.c \
./avct/avct_lcb.c \
@@ -156,12 +112,6 @@ LOCAL_SRC_FILES:= \
./sdp/sdp_utils.c \
./sdp/sdp_api.c \
./sdp/sdp_discovery.c \
- ./xml/xml_parse.c \
- ./xml/xml_vlist.c \
- ./xml/xml_erp.c \
- ./xml/xml_flp.c \
- ./xml/xml_mlp.c \
- ./xml/xml_bld.c \
./pan/pan_main.c \
./pan/pan_api.c \
./pan/pan_utils.c \
@@ -175,10 +125,7 @@ LOCAL_SRC_FILES:= \
./l2cap/l2c_utils.c \
./l2cap/l2c_csm.c \
./l2cap/l2c_link.c \
- ./l2cap/l2c_ble.c \
- ./goep/goep_fs.c \
- ./goep/goep_trace.c \
- ./goep/goep_util.c
+ ./l2cap/l2c_ble.c
LOCAL_MODULE := libbt-brcm_stack
LOCAL_MODULE_TAGS := optional
diff --git a/stack/a2dp/a2d_m12.c b/stack/a2dp/a2d_m12.c
deleted file mode 100644
index 3c9fb98..0000000
--- a/stack/a2dp/a2d_m12.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*****************************************************************************
-**
-** Name: a2d_m12.c
-**
-** Description:utility functions to help build and parse MPEG-1, 2 Audio
-** Codec Information Element and Media Payload.
-** Copyright (c) 2002-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include "bt_target.h"
-
-#if (A2D_M12_INCLUDED == TRUE)
-#include "a2d_api.h"
-#include "a2d_int.h"
-#include "a2d_m12.h"
-
-
-/******************************************************************************
-**
-** Function A2D_BldM12Info
-**
-** Description This function is called by an application to build
-** the MPEG-1, 2 Audio Media Codec Capabilities byte sequence
-** beginning from the LOSC octet.
-** media_type: Indicates Audio, or Multimedia.
-**
-** p_ie: The MPEG-1, 2 Audio Codec Information Element information.
-**
-** Output Parameters:
-** p_result: the resulting codec info byte sequence.
-**
-** Returns A2D_SUCCESS if function execution succeeded.
-** Error status code, otherwise.
-******************************************************************************/
-tA2D_STATUS A2D_BldM12Info(UINT8 media_type, tA2D_M12_CIE *p_ie, UINT8 *p_result)
-{
- tA2D_STATUS status;
- UINT8 *p_vbr;
-
- if( p_ie == NULL || p_result == NULL ||
- (p_ie->layer & ~A2D_M12_IE_LAYER_MSK) ||
- (p_ie->ch_mode & ~A2D_M12_IE_CH_MD_MSK) ||
- (p_ie->samp_freq & ~A2D_M12_IE_SAMP_FREQ_MSK) ||
- (p_ie->bitrate & ~A2D_M12_IE_BITRATE_MSK))
- {
- /* if any unused bit is set */
- status = A2D_INVALID_PARAMS;
- }
- else
- {
- status = A2D_SUCCESS;
- *p_result++ = A2D_M12_INFO_LEN;
- *p_result++ = media_type;
- *p_result++ = A2D_MEDIA_CT_M12;
-
- /* Media Codec Specific Information Element */
- *p_result = p_ie->layer | p_ie->ch_mode;
- if(p_ie->crc)
- *p_result |= A2D_M12_IE_CRC_MSK;
- p_result++;
-
- *p_result = p_ie->samp_freq;
- if(p_ie->mpf)
- *p_result |= A2D_M12_IE_MPF_MSK;
- p_result++;
-
- p_vbr = p_result;
- UINT16_TO_BE_STREAM(p_result, p_ie->bitrate);
- if(p_ie->vbr)
- *p_vbr |= A2D_M12_IE_VBR_MSK;
- }
- return status;
-}
-
-/******************************************************************************
-**
-** Function A2D_ParsM12Info
-**
-** Description This function is called by an application to parse
-** the MPEG-1, 2 Audio Media Codec Capabilities byte sequence
-** beginning from the LOSC octet.
-** Input Parameters:
-** p_info: the byte sequence to parse.
-**
-** for_caps: TRUE, if the byte sequence is for get capabilities response.
-**
-** Output Parameters:
-** p_ie: The MPEG-1, 2 Audio Codec Information Element information.
-**
-** Returns A2D_SUCCESS if function execution succeeded.
-** Error status code, otherwise.
-******************************************************************************/
-tA2D_STATUS A2D_ParsM12Info(tA2D_M12_CIE *p_ie, UINT8 *p_info, BOOLEAN for_caps)
-{
- tA2D_STATUS status;
- UINT8 losc;
- UINT8 mt;
-
- if( p_ie == NULL || p_info == NULL)
- status = A2D_INVALID_PARAMS;
- else
- {
- losc = *p_info++;
- mt = *p_info++;
- /* If the function is called for the wrong Media Type or Media Codec Type */
- if(losc != A2D_M12_INFO_LEN || *p_info != A2D_MEDIA_CT_M12)
- status = A2D_WRONG_CODEC;
- else
- {
- p_info++;
- p_ie->layer = *p_info & A2D_M12_IE_LAYER_MSK;
- p_ie->crc = (*p_info & A2D_M12_IE_CRC_MSK) >> 4;
- p_ie->ch_mode = *p_info & A2D_M12_IE_CH_MD_MSK;
- p_info++;
- p_ie->mpf = (*p_info & A2D_M12_IE_MPF_MSK) >> 6;
- p_ie->samp_freq = *p_info & A2D_M12_IE_SAMP_FREQ_MSK;
- p_info++;
- p_ie->vbr = (*p_info & A2D_M12_IE_VBR_MSK) >> 7;
- BE_STREAM_TO_UINT16(p_ie->bitrate, p_info);
- p_ie->bitrate &= A2D_M12_IE_BITRATE_MSK;
-
- status = A2D_SUCCESS;
- if(for_caps == FALSE)
- {
- if(A2D_BitsSet(p_ie->layer) != A2D_SET_ONE_BIT)
- status = A2D_BAD_LAYER;
- if(A2D_BitsSet(p_ie->ch_mode) != A2D_SET_ONE_BIT)
- status = A2D_BAD_CH_MODE;
- if(A2D_BitsSet(p_ie->samp_freq) != A2D_SET_ONE_BIT)
- status = A2D_BAD_SAMP_FREQ;
- if((A2D_BitsSet((UINT8)(p_ie->bitrate&0xFF)) +
- A2D_BitsSet((UINT8)((p_ie->bitrate&0xFF00)>>8)))!= A2D_SET_ONE_BIT)
- status = A2D_BAD_BIT_RATE;
- }
- }
- }
- return status;
-}
-
-#endif /* A2D_M12_INCLUDED == TRUE */
diff --git a/stack/a2dp/a2d_m24.c b/stack/a2dp/a2d_m24.c
deleted file mode 100644
index d8df766..0000000
--- a/stack/a2dp/a2d_m24.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*****************************************************************************
-**
-** Name: a2d_m24.c
-**
-** Description:utility functions to help build and parse MPEG-2, 4 AAC
-** Codec Information Element and Media Payload.
-** Copyright (c) 2002-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include "bt_target.h"
-
-#if (A2D_M24_INCLUDED == TRUE)
-#include "a2d_api.h"
-#include "a2d_int.h"
-#include "a2d_m24.h"
-
-
-/******************************************************************************
-**
-** Function A2D_BldM24Info
-**
-** Description This function is called by an application to build
-** the MPEG-2, 4 AAC Media Codec Capabilities byte sequence
-** beginning from the LOSC octet.
-** Input Parameters:
-** media_type: Indicates Audio, or Multimedia.
-**
-** p_ie: MPEG-2, 4 AAC Codec Information Element information.
-**
-** Output Parameters:
-** p_result: the resulting codec info byte sequence.
-**
-** Returns A2D_SUCCESS if function execution succeeded.
-** Error status code, otherwise.
-******************************************************************************/
-tA2D_STATUS A2D_BldM24Info(UINT8 media_type, tA2D_M24_CIE *p_ie, UINT8 *p_result)
-{
- tA2D_STATUS status;
- UINT16 bitrate45;
-
- if( p_ie == NULL || p_result == NULL ||
- (p_ie->obj_type & ~A2D_M24_IE_OBJ_MSK) ||
- (p_ie->samp_freq & ~A2D_M24_IE_SAMP_FREQ_MSK) ||
- (p_ie->chnl & ~A2D_M24_IE_CHNL_MSK) ||
- (p_ie->bitrate & ~A2D_M24_IE_BITRATE_MSK))
- {
- /* if any unused bit is set */
- status = A2D_INVALID_PARAMS;
- }
- else
- {
- status = A2D_SUCCESS;
- *p_result++ = A2D_M24_INFO_LEN;
- *p_result++ = media_type;
- *p_result++ = A2D_MEDIA_CT_M24;
-
- /* Media Codec Specific Information Element */
- *p_result++ = p_ie->obj_type;
-
- UINT16_TO_BE_STREAM(p_result, p_ie->samp_freq);
- p_result--;
- *p_result++ |= p_ie->chnl;
-
- *p_result = (p_ie->bitrate & A2D_M24_IE_BITRATE3_MSK) >> 16;
- if(p_ie->vbr)
- *p_result |= A2D_M24_IE_VBR_MSK;
- p_result++;
- bitrate45 = (UINT16)(p_ie->bitrate & A2D_M24_IE_BITRATE45_MSK);
- UINT16_TO_BE_STREAM(p_result, bitrate45);
- }
- return status;
-}
-
-/******************************************************************************
-**
-** Function A2D_ParsM24Info
-**
-** Description This function is called by an application to parse
-** the MPEG-2, 4 AAC Media Codec Capabilities byte sequence
-** beginning from the LOSC octet.
-** Input Parameters:
-** p_info: the byte sequence to parse.
-**
-** for_caps: TRUE, if the byte sequence is for get capabilities response.
-**
-** Output Parameters:
-** p_ie: MPEG-2, 4 AAC Codec Information Element information.
-**
-** Returns A2D_SUCCESS if function execution succeeded.
-** Error status code, otherwise.
-******************************************************************************/
-tA2D_STATUS A2D_ParsM24Info(tA2D_M24_CIE *p_ie, UINT8 *p_info, BOOLEAN for_caps)
-{
- tA2D_STATUS status;
- UINT8 vbr;
- UINT16 u16;
- UINT8 losc;
- UINT8 mt;
-
- if( p_ie == NULL || p_info == NULL)
- status = A2D_INVALID_PARAMS;
- else
- {
- losc = *p_info++;
- mt = *p_info++;
- /* If the function is called for the wrong Media Type or Media Codec Type */
- if(losc != A2D_M24_INFO_LEN || *p_info != A2D_MEDIA_CT_M24)
- status = A2D_WRONG_CODEC;
- else
- {
- p_info++;
- p_ie->obj_type = *p_info++;
- BE_STREAM_TO_UINT16(p_ie->samp_freq, p_info);
- p_ie->chnl = p_ie->samp_freq & A2D_M24_IE_CHNL_MSK;
- p_ie->samp_freq &= A2D_M24_IE_SAMP_FREQ_MSK;
- vbr = *p_info++;
- BE_STREAM_TO_UINT16(u16, p_info); /* u16 contains the octect4, 5 of bterate */
-
- p_ie->vbr = (vbr & A2D_M24_IE_VBR_MSK) >> 7;
- vbr &= ~A2D_M24_IE_VBR_MSK; /* vbr has become the octect3 of bitrate */
- p_ie->bitrate = vbr;
- p_ie->bitrate <<= 16;
- p_ie->bitrate += u16;
-
- status = A2D_SUCCESS;
- if(for_caps == FALSE)
- {
- if(A2D_BitsSet(p_ie->obj_type) != A2D_SET_ONE_BIT)
- status = A2D_BAD_OBJ_TYPE;
-
- if((A2D_BitsSet((UINT8)(p_ie->samp_freq&0xFF)) +
- A2D_BitsSet((UINT8)((p_ie->samp_freq&0xFF00)>>8)))!= A2D_SET_ONE_BIT)
- status = A2D_BAD_SAMP_FREQ;
-
- if(A2D_BitsSet(p_ie->chnl) != A2D_SET_ONE_BIT)
- status = A2D_BAD_CHANNEL;
-
- /* BitRate must be greater than zero when specifying AAC configuration */
- if (p_ie->bitrate == 0)
- status = A2D_BAD_BIT_RATE;
- }
- }
- }
- return status;
-}
-#endif /* (A2D_M24_INCLUDED == TRUE) */
-
diff --git a/stack/avct/avct_bcb_act.c b/stack/avct/avct_bcb_act.c
deleted file mode 100644
index ad6d651..0000000
--- a/stack/avct/avct_bcb_act.c
+++ /dev/null
@@ -1,749 +0,0 @@
-/*****************************************************************************
-**
-** Name: avct_bcb_act.c
-**
-** Description: This module contains action functions of the browsing control
-** state machine.
-**
-** Copyright (c) 2003-2008, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <string.h>
-#include "data_types.h"
-#include "bt_target.h"
-#include "avct_api.h"
-#include "avct_int.h"
-#include "gki.h"
-
-
-#include "btm_api.h"
-
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-/* action function list */
-const tAVCT_BCB_ACTION avct_bcb_action[] = {
- avct_bcb_chnl_open, /* AVCT_LCB_CHNL_OPEN */
- avct_bcb_chnl_disc, /* AVCT_LCB_CHNL_DISC */
- avct_bcb_send_msg, /* AVCT_LCB_SEND_MSG */
- avct_bcb_open_ind, /* AVCT_LCB_OPEN_IND */
- avct_bcb_open_fail, /* AVCT_LCB_OPEN_FAIL */
- avct_bcb_close_ind, /* AVCT_LCB_CLOSE_IND */
- avct_bcb_close_cfm, /* AVCT_LCB_CLOSE_CFM */
- avct_bcb_msg_ind, /* AVCT_LCB_MSG_IND */
- avct_bcb_cong_ind, /* AVCT_LCB_CONG_IND */
- avct_bcb_bind_conn, /* AVCT_LCB_BIND_CONN */
- avct_bcb_bind_fail, /* AVCT_LCB_BIND_FAIL */
- avct_bcb_unbind_disc, /* AVCT_LCB_UNBIND_DISC */
- avct_bcb_chk_disc, /* AVCT_LCB_CHK_DISC */
- avct_bcb_discard_msg, /* AVCT_LCB_DISCARD_MSG */
- avct_bcb_dealloc, /* AVCT_LCB_DEALLOC */
- avct_bcb_free_msg_ind /* AVCT_LCB_FREE_MSG_IND */
-};
-
-
-/*******************************************************************************
-**
-** Function avct_bcb_msg_asmbl
-**
-** Description Reassemble incoming message.
-**
-**
-** Returns Pointer to reassembled message; NULL if no message
-** available.
-**
-*******************************************************************************/
-static BT_HDR *avct_bcb_msg_asmbl(tAVCT_BCB *p_bcb, BT_HDR *p_buf)
-{
- UINT8 *p;
- UINT8 pkt_type;
- BT_HDR *p_ret = NULL;
-
- /* parse the message header */
- p = (UINT8 *)(p_buf + 1) + p_buf->offset;
- AVCT_PRS_PKT_TYPE(p, pkt_type);
-
- /* must be single packet - can not fragment */
- if (pkt_type == AVCT_PKT_TYPE_SINGLE)
- {
- p_ret = p_buf;
- }
- else
- {
- GKI_freebuf(p_buf);
- AVCT_TRACE_WARNING1("Pkt type=%d - fragmentation not allowed. drop it", pkt_type);
- }
- return p_ret;
-}
-
-
-/*******************************************************************************
-**
-** Function avct_bcb_chnl_open
-**
-** Description Open L2CAP channel to peer
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_chnl_open(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- UINT16 result = AVCT_RESULT_FAIL;
- tAVCT_LCB *p_lcb = avct_lcb_by_bcb(p_bcb);
- tL2CAP_ERTM_INFO ertm_info;
-
- BTM_SetOutService(p_lcb->peer_addr, BTM_SEC_SERVICE_AVCTP_BROWSE, 0);
-
- /* Set the FCR options: Browsing channel mandates ERTM */
- ertm_info.preferred_mode = avct_l2c_br_fcr_opts_def.mode;
- ertm_info.allowed_modes = L2CAP_FCR_CHAN_OPT_ERTM;
- ertm_info.user_rx_pool_id = AVCT_BR_USER_RX_POOL_ID;
- ertm_info.user_tx_pool_id = AVCT_BR_USER_TX_POOL_ID;
- ertm_info.fcr_rx_pool_id = AVCT_BR_FCR_RX_POOL_ID;
- ertm_info.fcr_tx_pool_id = AVCT_BR_FCR_TX_POOL_ID;
-
- /* call l2cap connect req */
- p_bcb->ch_state = AVCT_CH_CONN;
- if ((p_bcb->ch_lcid = L2CA_ErtmConnectReq(AVCT_BR_PSM, p_lcb->peer_addr, &ertm_info)) == 0)
- {
- /* if connect req failed, send ourselves close event */
- avct_bcb_event(p_bcb, AVCT_LCB_LL_CLOSE_EVT, (tAVCT_LCB_EVT *) &result);
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_unbind_disc
-**
-** Description call callback with disconnect event.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_unbind_disc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- p_data->p_ccb->p_bcb = NULL;
- (*p_data->p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_data->p_ccb), AVCT_BROWSE_DISCONN_CFM_EVT, 0, NULL);
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_open_ind
-**
-** Description Handle an LL_OPEN event. For each allocated ccb already
-** bound to this lcb, send a connect event. For each
-** unbound ccb with a new PID, bind that ccb to this lcb and
-** send a connect event.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_open_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
- tAVCT_CCB *p_ccb_bind = NULL;
- int i;
- BOOLEAN bind = FALSE;
- tAVCT_UL_MSG ul_msg;
-
- for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++)
- {
- /* if ccb allocated and */
- if (p_ccb->allocated)
- {
- /* if bound to this lcb send connect confirm event */
- if (p_ccb->p_bcb == p_bcb)
- {
- bind = TRUE;
- p_ccb_bind = p_ccb;
- p_ccb->cc.p_ctrl_cback(avct_ccb_to_idx(p_ccb), AVCT_BROWSE_CONN_CFM_EVT,
- 0, p_ccb->p_lcb->peer_addr);
- }
- /* if unbound acceptor and lcb e */
- else if ((p_ccb->p_bcb == NULL) && (p_ccb->cc.role == AVCT_ACP) &&
- (p_ccb->p_lcb != NULL))
- {
- /* bind ccb to lcb and send connect ind event */
- bind = TRUE;
- p_ccb_bind = p_ccb;
- p_ccb->p_bcb = p_bcb;
- p_ccb->cc.p_ctrl_cback(avct_ccb_to_idx(p_ccb), AVCT_BROWSE_CONN_IND_EVT,
- 0, p_ccb->p_lcb->peer_addr);
- }
- }
- }
-
- /* if no ccbs bound to this lcb, disconnect */
- if (bind == FALSE)
- {
- avct_bcb_event(p_bcb, AVCT_LCB_INT_CLOSE_EVT, p_data);
- }
- else if (p_bcb->p_tx_msg)
- {
- if (p_ccb_bind)
- {
- ul_msg.p_buf = p_bcb->p_tx_msg;
- ul_msg.p_ccb = p_ccb_bind;
- ul_msg.label = (UINT8)(p_bcb->p_tx_msg->layer_specific & 0xFF);
- ul_msg.cr = (UINT8)((p_bcb->p_tx_msg->layer_specific & 0xFF00) >> 8);
- p_bcb->p_tx_msg->layer_specific = AVCT_DATA_BROWSE;
- p_bcb->p_tx_msg = NULL;
-
- /* send msg event to bcb */
- avct_bcb_event(p_bcb, AVCT_LCB_UL_MSG_EVT, (tAVCT_LCB_EVT *) &ul_msg);
- }
- else
- {
- GKI_freebuf (p_bcb->p_tx_msg);
- p_bcb->p_tx_msg = NULL;
- }
-
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_open_fail
-**
-** Description L2CAP channel open attempt failed. Mark the ccbs
-** as NULL bcb.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_open_fail(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
- int i;
-
- for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++)
- {
- if (p_ccb->allocated && (p_ccb->p_bcb == p_bcb))
- {
- p_ccb->p_bcb = NULL;
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_close_ind
-**
-** Description L2CAP channel closed by peer. Deallocate any initiator
-** ccbs on this lcb and send disconnect ind event.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_close_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
- tAVCT_LCB *p_lcb = avct_lcb_by_bcb(p_bcb);
- int i;
-
- for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++)
- {
- if (p_ccb->allocated && (p_ccb->p_bcb == p_bcb))
- {
- if (p_ccb->cc.role == AVCT_INT)
- {
- (*p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_ccb), AVCT_BROWSE_DISCONN_CFM_EVT, 0, p_lcb->peer_addr);
- }
- else
- {
- (*p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_ccb), AVCT_BROWSE_DISCONN_IND_EVT, 0, NULL);
- }
- p_ccb->p_bcb = NULL;
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_close_cfm
-**
-** Description L2CAP channel closed by us. Deallocate any initiator
-** ccbs on this lcb and send disconnect ind or cfm event.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_close_cfm(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
- int i;
- UINT8 event = 0;
- BOOLEAN ch_close = p_bcb->ch_close; /* Whether BCB initiated channel close */
- tAVCT_CTRL_CBACK *p_cback;
-
- p_bcb->ch_close = FALSE;
- p_bcb->allocated = 0;
- for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++)
- {
- if (p_ccb->allocated && (p_ccb->p_bcb == p_bcb))
- {
- /* if this ccb initiated close send disconnect cfm otherwise ind */
- if (ch_close)
- {
- event = AVCT_BROWSE_DISCONN_CFM_EVT;
- }
- else
- {
- event = AVCT_BROWSE_DISCONN_IND_EVT;
- }
-
- p_cback = p_ccb->cc.p_ctrl_cback;
- p_ccb->p_bcb = NULL;
- if (p_ccb->p_lcb == NULL)
- avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL);
- (*p_cback)(avct_ccb_to_idx(p_ccb), event,
- p_data->result, NULL);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_bind_conn
-**
-** Description Bind ccb to lcb and send connect cfm event.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_bind_conn(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- tAVCT_LCB *p_lcb = avct_lcb_by_bcb(p_bcb);
- p_data->p_ccb->p_bcb = p_bcb;
- (*p_data->p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_data->p_ccb),
- AVCT_BROWSE_CONN_CFM_EVT, 0, p_lcb->peer_addr);
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_chk_disc
-**
-** Description A ccb wants to close; if it is the last ccb on this lcb,
-** close channel. Otherwise just deallocate and call
-** callback.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_chk_disc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- AVCT_TRACE_WARNING0("avct_bcb_chk_disc");
- p_bcb->ch_close = avct_bcb_last_ccb(p_bcb, p_data->p_ccb);
- if (p_bcb->ch_close)
- {
- AVCT_TRACE_WARNING0("b closing");
- avct_bcb_event(p_bcb, AVCT_LCB_INT_CLOSE_EVT, p_data);
- }
- else
- {
- AVCT_TRACE_WARNING0("b unbind_disc");
- avct_bcb_unbind_disc(p_bcb, p_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_chnl_disc
-**
-** Description Disconnect L2CAP channel.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_chnl_disc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- L2CA_DisconnectReq(p_bcb->ch_lcid);
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_bind_fail
-**
-** Description Deallocate ccb and call callback with connect event
-** with failure result.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_bind_fail(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- p_data->p_ccb->p_bcb = NULL;
- (*p_data->p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_data->p_ccb), AVCT_BROWSE_CONN_CFM_EVT, AVCT_RESULT_FAIL, NULL);
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_cong_ind
-**
-** Description Handle congestion indication from L2CAP.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_cong_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
- int i;
- UINT8 event;
- tAVCT_LCB *p_lcb = avct_lcb_by_bcb(p_bcb);
-
- /* set event */
- event = (p_data->cong) ? AVCT_BROWSE_CONG_IND_EVT : AVCT_BROWSE_UNCONG_IND_EVT;
-
- /* send event to all ccbs on this lcb */
- for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++)
- {
- if (p_ccb->allocated && (p_ccb->p_bcb == p_bcb))
- {
- (*p_ccb->cc.p_ctrl_cback)(avct_ccb_to_idx(p_ccb), event, 0, p_lcb->peer_addr);
- }
- }
-
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_discard_msg
-**
-** Description Discard a message sent in from the API.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_discard_msg(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- AVCT_TRACE_WARNING0("save msg in control block");
-
- if (p_bcb->p_tx_msg)
- {
- GKI_freebuf(p_bcb->p_tx_msg);
- p_bcb->p_tx_msg = NULL;
- }
-
- /* if control channel is up, save the message and open the browsing channel */
- if (p_data->ul_msg.p_ccb->p_lcb)
- {
- p_bcb->p_tx_msg = p_data->ul_msg.p_buf;
-
- if (p_bcb->p_tx_msg)
- {
- p_bcb->p_tx_msg->layer_specific = (p_data->ul_msg.cr << 8) + p_data->ul_msg.label;
-
- /* the channel is closed, opening or closing - open it again */
- AVCT_TRACE_DEBUG2("ch_state: %d, allocated:%d", p_bcb->ch_state, p_bcb->allocated);
- p_bcb->allocated = p_data->ul_msg.p_ccb->p_lcb->allocated;
- AVCT_TRACE_DEBUG2("ch_state: %d, allocated:%d", p_bcb->ch_state, p_bcb->allocated);
- avct_bcb_event(p_bcb, AVCT_LCB_UL_BIND_EVT, (tAVCT_LCB_EVT *) p_data->ul_msg.p_ccb);
- }
- }
- else
- GKI_freebuf(p_data->ul_msg.p_buf);
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_send_msg
-**
-** Description Build and send an AVCTP message.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_send_msg(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- UINT16 curr_msg_len;
- UINT8 pkt_type = AVCT_PKT_TYPE_SINGLE;
- UINT8 hdr_len;
- BT_HDR *p_buf;
- UINT8 *p;
-
- /* store msg len */
- curr_msg_len = p_data->ul_msg.p_buf->len;
-
- /* initialize packet type and other stuff */
- if (curr_msg_len > (p_bcb->peer_mtu - AVCT_HDR_LEN_SINGLE))
- {
- AVCT_TRACE_ERROR3 ("avct_bcb_send_msg msg len (%d) exceeds peer mtu(%d-%d)!!", curr_msg_len, p_bcb->peer_mtu, AVCT_HDR_LEN_SINGLE);
- GKI_freebuf(p_data->ul_msg.p_buf);
- return;
- }
-
- /* set header len */
- hdr_len = avct_lcb_pkt_type_len[pkt_type];
- p_buf = p_data->ul_msg.p_buf;
-
- /* set up to build header */
- p_buf->len += hdr_len;
- p_buf->offset -= hdr_len;
- p = (UINT8 *)(p_buf + 1) + p_buf->offset;
-
- /* build header */
- AVCT_BLD_HDR(p, p_data->ul_msg.label, pkt_type, p_data->ul_msg.cr);
- UINT16_TO_BE_STREAM(p, p_data->ul_msg.p_ccb->cc.pid);
-
- /* send message to L2CAP */
- L2CA_DataWrite(p_bcb->ch_lcid, p_buf);
- return;
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_free_msg_ind
-**
-** Description Discard an incoming AVCTP message.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_free_msg_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- if (p_data)
- GKI_freebuf(p_data->p_buf);
- return;
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_msg_ind
-**
-** Description Handle an incoming AVCTP message.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_bcb_msg_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- UINT8 *p;
- UINT8 label, type, cr_ipid;
- UINT16 pid;
- tAVCT_CCB *p_ccb;
- BT_HDR *p_buf;
- tAVCT_LCB *p_lcb = avct_lcb_by_bcb(p_bcb);
-
- /* this p_buf is to be reported through p_msg_cback. The layer_specific
- * needs to be set properly to indicate that it is received through
- * broasing channel */
- p_data->p_buf->layer_specific = AVCT_DATA_BROWSE;
-
- /* reassemble message; if no message available (we received a fragment) return */
- if ((p_data->p_buf = avct_bcb_msg_asmbl(p_bcb, p_data->p_buf)) == NULL)
- {
- return;
- }
-
- p = (UINT8 *)(p_data->p_buf + 1) + p_data->p_buf->offset;
-
- /* parse header byte */
- AVCT_PRS_HDR(p, label, type, cr_ipid);
-
- /* check for invalid cr_ipid */
- if (cr_ipid == AVCT_CR_IPID_INVALID)
- {
- AVCT_TRACE_WARNING1("Invalid cr_ipid", cr_ipid);
- GKI_freebuf(p_data->p_buf);
- return;
- }
-
- /* parse and lookup PID */
- BE_STREAM_TO_UINT16(pid, p);
- if ((p_ccb = avct_lcb_has_pid(p_lcb, pid)) != NULL)
- {
- /* PID found; send msg up, adjust bt hdr and call msg callback */
- p_data->p_buf->offset += AVCT_HDR_LEN_SINGLE;
- p_data->p_buf->len -= AVCT_HDR_LEN_SINGLE;
- (*p_ccb->cc.p_msg_cback)(avct_ccb_to_idx(p_ccb), label, cr_ipid, p_data->p_buf);
- }
- else
- {
- /* PID not found; drop message */
- AVCT_TRACE_WARNING1("No ccb for PID=%x", pid);
- GKI_freebuf(p_data->p_buf);
-
- /* if command send reject */
- if (cr_ipid == AVCT_CMD)
- {
- if ((p_buf = (BT_HDR *) GKI_getpoolbuf(AVCT_CMD_POOL_ID)) != NULL)
- {
- p_buf->len = AVCT_HDR_LEN_SINGLE;
- p_buf->offset = AVCT_MSG_OFFSET - AVCT_HDR_LEN_SINGLE;
- p = (UINT8 *)(p_buf + 1) + p_buf->offset;
- AVCT_BLD_HDR(p, label, AVCT_PKT_TYPE_SINGLE, AVCT_REJ);
- UINT16_TO_BE_STREAM(p, pid);
- L2CA_DataWrite(p_bcb->ch_lcid, p_buf);
- }
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_dealloc
-**
-** Description Deallocate a link control block.
-**
-**
-** Returns void.
-**
-*******************************************************************************/
-void avct_bcb_dealloc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data)
-{
- tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
- tAVCT_CCB *p_ccb_found = NULL;
- BOOLEAN found = FALSE;
- int i;
-
- AVCT_TRACE_DEBUG1("avct_bcb_dealloc %d", p_bcb->allocated);
-
- for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++)
- {
- /* if ccb allocated and */
- if (p_ccb->allocated)
- {
- if (p_ccb->p_bcb == p_bcb)
- {
- p_ccb_found = p_ccb;
- p_ccb->p_bcb = NULL;
- AVCT_TRACE_DEBUG1("avct_bcb_dealloc used by ccb: %d", i);
- found = TRUE;
- break;
- }
- }
- }
-
- /* the browsing channel is down. Check if we have pending messages */
- if (p_bcb->p_tx_msg != NULL)
- {
- GKI_freebuf(p_bcb->p_tx_msg);
- }
- memset(p_bcb, 0, sizeof(tAVCT_BCB));
-}
-
-/*******************************************************************************
-**
-** Function avct_close_bcb
-**
-** Description this function is called right before LCB disconnects.
-**
-**
-** Returns Nothing.
-**
-*******************************************************************************/
-void avct_close_bcb(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
-{
- tAVCT_BCB *p_bcb = avct_bcb_by_lcb(p_lcb);
- if (p_bcb->allocated)
- {
- avct_bcb_event(p_bcb, AVCT_LCB_UL_UNBIND_EVT, p_data);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function avct_lcb_by_bcb
-**
-** Description This lookup function finds the lcb for a bcb.
-**
-** Returns pointer to the lcb.
-**
-*******************************************************************************/
-tAVCT_LCB *avct_lcb_by_bcb(tAVCT_BCB *p_bcb)
-{
- return &avct_cb.lcb[p_bcb->allocated - 1];
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_by_lcb
-**
-** Description This lookup function finds the bcb for a lcb.
-**
-** Returns pointer to the lcb.
-**
-*******************************************************************************/
-tAVCT_BCB *avct_bcb_by_lcb(tAVCT_LCB *p_lcb)
-{
- return &avct_cb.bcb[p_lcb->allocated - 1];
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_last_ccb
-**
-** Description See if given ccb is only one on the bcb.
-**
-**
-** Returns 0, if ccb is last, (ccb index + 1) otherwise.
-**
-*******************************************************************************/
-UINT8 avct_bcb_last_ccb(tAVCT_BCB *p_bcb, tAVCT_CCB *p_ccb_last)
-{
- tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
- int i;
- UINT8 idx = 0;
-
- for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++)
- {
- if (p_ccb->allocated && (p_ccb->p_bcb == p_bcb))
- {
- if (p_ccb != p_ccb_last)
- return 0;
- idx = (UINT8)(i + 1);
- }
- }
- return idx;
-}
-
-/*******************************************************************************
-**
-** Function avct_bcb_by_lcid
-**
-** Description Find the BCB associated with the L2CAP LCID
-**
-**
-** Returns pointer to the lcb, or NULL if none found.
-**
-*******************************************************************************/
-tAVCT_BCB *avct_bcb_by_lcid(UINT16 lcid)
-{
- tAVCT_BCB *p_bcb = &avct_cb.bcb[0];
- int i;
-
- for (i = 0; i < AVCT_NUM_LINKS; i++, p_bcb++)
- {
- if (p_bcb->allocated && (p_bcb->ch_lcid == lcid))
- {
- break;
- }
- }
-
- if (i == AVCT_NUM_LINKS)
- {
- p_bcb = NULL;
- /* out of lcbs */
- AVCT_TRACE_WARNING1("No bcb for lcid %x", lcid);
- }
-
- return p_bcb;
-}
-#endif /* (AVCT_BROWSE_INCLUDED == TRUE) */
diff --git a/stack/avct/avct_l2c_br.c b/stack/avct/avct_l2c_br.c
deleted file mode 100644
index e333edf..0000000
--- a/stack/avct/avct_l2c_br.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/*****************************************************************************
-**
-** Name: avct_l2c_br.c
-**
-** Description: This AVCTP module interfaces to L2CAP
-**
-** Copyright (c) 2008, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <string.h>
-#include "data_types.h"
-#include "bt_target.h"
-#include "avct_api.h"
-#include "avct_int.h"
-#include "l2c_api.h"
-#include "l2cdefs.h"
-
-/* Configuration flags. */
-#define AVCT_L2C_CFG_IND_DONE (1<<0)
-#define AVCT_L2C_CFG_CFM_DONE (1<<1)
-
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-/* callback function declarations */
-void avct_l2c_br_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id);
-void avct_l2c_br_connect_cfm_cback(UINT16 lcid, UINT16 result);
-void avct_l2c_br_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg);
-void avct_l2c_br_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg);
-void avct_l2c_br_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed);
-void avct_l2c_br_disconnect_cfm_cback(UINT16 lcid, UINT16 result);
-void avct_l2c_br_congestion_ind_cback(UINT16 lcid, BOOLEAN is_congested);
-void avct_l2c_br_data_ind_cback(UINT16 lcid, BT_HDR *p_buf);
-
-/* L2CAP callback function structure */
-const tL2CAP_APPL_INFO avct_l2c_br_appl = {
- avct_l2c_br_connect_ind_cback,
- avct_l2c_br_connect_cfm_cback,
- NULL,
- avct_l2c_br_config_ind_cback,
- avct_l2c_br_config_cfm_cback,
- avct_l2c_br_disconnect_ind_cback,
- avct_l2c_br_disconnect_cfm_cback,
- NULL,
- avct_l2c_br_data_ind_cback,
- avct_l2c_br_congestion_ind_cback,
- NULL /* tL2CA_TX_COMPLETE_CB */
-};
-
-/* Browsing channel eL2CAP default options */
-const tL2CAP_FCR_OPTS avct_l2c_br_fcr_opts_def = {
- L2CAP_FCR_ERTM_MODE, /* Mandatory for Browsing channel */
- AVCT_BR_FCR_OPT_TX_WINDOW_SIZE, /* Tx window size */
- AVCT_BR_FCR_OPT_MAX_TX_B4_DISCNT, /* Maximum transmissions before disconnecting */
- AVCT_BR_FCR_OPT_RETX_TOUT, /* Retransmission timeout (2 secs) */
- AVCT_BR_FCR_OPT_MONITOR_TOUT, /* Monitor timeout (12 secs) */
- L2CAP_DEFAULT_ERM_MPS /* MPS segment size */
-};
-
-/*******************************************************************************
-**
-** Function avct_l2c_br_connect_ind_cback
-**
-** Description This is the L2CAP connect indication callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void avct_l2c_br_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id)
-{
- tAVCT_LCB *p_lcb;
- UINT16 result = L2CAP_CONN_NO_RESOURCES;
- tL2CAP_CFG_INFO cfg;
- tAVCT_BCB *p_bcb;
- tL2CAP_ERTM_INFO ertm_info;
-
- memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
- cfg.mtu_present = TRUE;
-
- if ((p_lcb = avct_lcb_by_bd(bd_addr)) != NULL)
- {
- /* control channel exists */
- p_bcb = avct_bcb_by_lcb(p_lcb);
-
- if (!p_bcb->allocated)
- {
- /* browsing channel does not exist yet and the browsing channel is registered
- * - accept connection */
- p_bcb->allocated = p_lcb->allocated; /* copy the index from lcb */
-
- result = L2CAP_CONN_OK;
- cfg.mtu = avct_cb.mtu_br;
-
- cfg.fcr_present = TRUE;
- cfg.fcr = avct_l2c_br_fcr_opts_def;
- }
- }
- /* else no control channel yet, reject */
-
- /* Set the FCR options: Browsing channel mandates ERTM */
- ertm_info.preferred_mode = cfg.fcr.mode;
- ertm_info.allowed_modes = L2CAP_FCR_CHAN_OPT_ERTM;
- ertm_info.user_rx_pool_id = AVCT_BR_USER_RX_POOL_ID;
- ertm_info.user_tx_pool_id = AVCT_BR_USER_TX_POOL_ID;
- ertm_info.fcr_rx_pool_id = AVCT_BR_FCR_RX_POOL_ID;
- ertm_info.fcr_tx_pool_id = AVCT_BR_FCR_TX_POOL_ID;
-
- /* Send L2CAP connect rsp */
- L2CA_ErtmConnectRsp(bd_addr, id, lcid, result, 0, &ertm_info);
-
- /* if result ok, proceed with connection */
- if (result == L2CAP_CONN_OK)
- {
- /* store LCID */
- p_bcb->ch_lcid = lcid;
-
- /* transition to configuration state */
- p_bcb->ch_state = AVCT_CH_CFG;
-
- /* Send L2CAP config req */
- L2CA_ConfigReq(lcid, &cfg);
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_l2c_br_connect_cfm_cback
-**
-** Description This is the L2CAP connect confirm callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void avct_l2c_br_connect_cfm_cback(UINT16 lcid, UINT16 result)
-{
- tAVCT_BCB *p_lcb;
- tL2CAP_CFG_INFO cfg;
-
- /* look up lcb for this channel */
- if ((p_lcb = avct_bcb_by_lcid(lcid)) != NULL)
- {
- /* if in correct state */
- if (p_lcb->ch_state == AVCT_CH_CONN)
- {
- /* if result successful */
- if (result == L2CAP_CONN_OK)
- {
- /* set channel state */
- p_lcb->ch_state = AVCT_CH_CFG;
-
- /* Send L2CAP config req */
- memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
-
- cfg.mtu_present = TRUE;
- cfg.mtu = avct_cb.mtu_br;
-
- cfg.fcr_present = TRUE;
- cfg.fcr = avct_l2c_br_fcr_opts_def;
-
- L2CA_ConfigReq(lcid, &cfg);
- }
- /* else failure */
- else
- {
- avct_bcb_event(p_lcb, AVCT_LCB_LL_CLOSE_EVT, (tAVCT_LCB_EVT *) &result);
- }
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_l2c_br_config_cfm_cback
-**
-** Description This is the L2CAP config confirm callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void avct_l2c_br_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
-{
- tAVCT_BCB *p_lcb;
-
- /* look up lcb for this channel */
- if ((p_lcb = avct_bcb_by_lcid(lcid)) != NULL)
- {
- /* if in correct state */
- if (p_lcb->ch_state == AVCT_CH_CFG)
- {
- /* if result successful */
- if (p_cfg->result == L2CAP_CFG_OK)
- {
- /* update flags */
- p_lcb->ch_flags |= AVCT_L2C_CFG_CFM_DONE;
-
- /* if configuration complete */
- if (p_lcb->ch_flags & AVCT_L2C_CFG_IND_DONE)
- {
- p_lcb->ch_state = AVCT_CH_OPEN;
- avct_bcb_event(p_lcb, AVCT_LCB_LL_OPEN_EVT, NULL);
- }
- }
- /* else failure */
- else
- {
- /* store result value */
- p_lcb->ch_result = p_cfg->result;
-
- /* Send L2CAP disconnect req */
- L2CA_DisconnectReq(lcid);
- }
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_l2c_br_config_ind_cback
-**
-** Description This is the L2CAP config indication callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void avct_l2c_br_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
-{
- tAVCT_BCB *p_lcb;
- UINT16 max_mtu = GKI_MAX_BUF_SIZE - L2CAP_MIN_OFFSET - BT_HDR_SIZE;
-
- /* Don't include QoS nor flush timeout in the response since we
- currently always accept these values. Note: fcr_present is left
- untouched since l2cap negotiates this internally
- */
- p_cfg->flush_to_present = FALSE;
- p_cfg->qos_present = FALSE;
-
- /* look up lcb for this channel */
- if ((p_lcb = avct_bcb_by_lcid(lcid)) != NULL)
- {
- /* store the mtu in tbl */
- if (p_cfg->mtu_present)
- {
- p_lcb->peer_mtu = p_cfg->mtu;
- }
- else
- {
- p_lcb->peer_mtu = L2CAP_DEFAULT_MTU;
- }
-
- if (p_lcb->peer_mtu > max_mtu)
- {
- p_lcb->peer_mtu = p_cfg->mtu = max_mtu;
-
- /* Must tell the peer what the adjusted value is */
- p_cfg->mtu_present = TRUE;
- }
- else /* Don't include in the response */
- p_cfg->mtu_present = FALSE;
- AVCT_TRACE_DEBUG2 ("avct_l2c_br_config_ind_cback peer_mtu:%d use:%d", p_lcb->peer_mtu, max_mtu);
-
- if (p_lcb->peer_mtu >= AVCT_MIN_BROWSE_MTU)
- p_cfg->result = L2CAP_CFG_OK;
- else
- {
- p_cfg->result = L2CAP_CFG_UNACCEPTABLE_PARAMS;
- p_cfg->mtu_present = TRUE;
- p_cfg->mtu = AVCT_MIN_BROWSE_MTU;
- }
-
- /* send L2CAP configure response */
- L2CA_ConfigRsp(lcid, p_cfg);
-
- if (p_cfg->result != L2CAP_CFG_OK)
- {
- return;
- }
-
- /* if first config ind */
- if ((p_lcb->ch_flags & AVCT_L2C_CFG_IND_DONE) == 0)
- {
- /* update flags */
- p_lcb->ch_flags |= AVCT_L2C_CFG_IND_DONE;
-
- /* if configuration complete */
- if (p_lcb->ch_flags & AVCT_L2C_CFG_CFM_DONE)
- {
- p_lcb->ch_state = AVCT_CH_OPEN;
- avct_bcb_event(p_lcb, AVCT_LCB_LL_OPEN_EVT, NULL);
- }
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_l2c_br_disconnect_ind_cback
-**
-** Description This is the L2CAP disconnect indication callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void avct_l2c_br_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
-{
- tAVCT_BCB *p_lcb;
- UINT16 result = AVCT_RESULT_FAIL;
-
- /* look up lcb for this channel */
- if ((p_lcb = avct_bcb_by_lcid(lcid)) != NULL)
- {
- if (ack_needed)
- {
- /* send L2CAP disconnect response */
- L2CA_DisconnectRsp(lcid);
- }
-
- avct_bcb_event(p_lcb, AVCT_LCB_LL_CLOSE_EVT, (tAVCT_LCB_EVT *) &result);
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_l2c_br_disconnect_cfm_cback
-**
-** Description This is the L2CAP disconnect confirm callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void avct_l2c_br_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
-{
- tAVCT_BCB *p_lcb;
- UINT16 res;
-
- /* look up lcb for this channel */
- if ((p_lcb = avct_bcb_by_lcid(lcid)) != NULL)
- {
- /* result value may be previously stored */
- res = (p_lcb->ch_result != 0) ? p_lcb->ch_result : result;
- p_lcb->ch_result = 0;
-
- avct_bcb_event(p_lcb, AVCT_LCB_LL_CLOSE_EVT, (tAVCT_LCB_EVT *) &res);
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_l2c_br_congestion_ind_cback
-**
-** Description This is the L2CAP congestion indication callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void avct_l2c_br_congestion_ind_cback(UINT16 lcid, BOOLEAN is_congested)
-{
- tAVCT_BCB *p_lcb;
-
- /* look up lcb for this channel */
- if ((p_lcb = avct_bcb_by_lcid(lcid)) != NULL)
- {
- avct_bcb_event(p_lcb, AVCT_LCB_LL_CONG_EVT, (tAVCT_LCB_EVT *) &is_congested);
- }
-}
-
-/*******************************************************************************
-**
-** Function avct_l2c_br_data_ind_cback
-**
-** Description This is the L2CAP data indication callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void avct_l2c_br_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
-{
- tAVCT_BCB *p_lcb;
-
- /* look up lcb for this channel */
- if ((p_lcb = avct_bcb_by_lcid(lcid)) != NULL)
- {
- avct_bcb_event(p_lcb, AVCT_LCB_LL_MSG_EVT, (tAVCT_LCB_EVT *) &p_buf);
- }
- else /* prevent buffer leak */
- GKI_freebuf(p_buf);
-}
-#endif /* (AVCT_BROWSE_INCLUDED == TRUE) */
-
-
diff --git a/stack/avrc/avrc_api.c b/stack/avrc/avrc_api.c
index dd7e752..94425af 100644
--- a/stack/avrc/avrc_api.c
+++ b/stack/avrc/avrc_api.c
@@ -98,354 +98,6 @@ static UINT8 * avrc_get_data_ptr(BT_HDR *p_pkt)
return p_data;
}
-#if (AVRC_METADATA_INCLUDED == TRUE)
-/******************************************************************************
-**
-** Function avrc_prep_end_frag
-**
-** Description This function prepares an end response fragment
-**
-**
-** Returns Nothing.
-**
-******************************************************************************/
-static void avrc_prep_end_frag(UINT8 handle)
-{
- tAVRC_FRAG_CB *p_fcb;
- BT_HDR *p_pkt_new;
- UINT8 *p_data;
-
- AVRC_TRACE_DEBUG0 ("avrc_prep_end_frag" );
- p_fcb = &avrc_cb.fcb[handle];
- p_pkt_new = p_fcb->p_fmsg;
- p_pkt_new->len -= (AVRC_MAX_CTRL_DATA_LEN - AVRC_VENDOR_HDR_SIZE - AVRC_MIN_META_HDR_SIZE);
- p_pkt_new->offset += (AVRC_MAX_CTRL_DATA_LEN - AVRC_VENDOR_HDR_SIZE - AVRC_MIN_META_HDR_SIZE);
- p_data = (UINT8 *)(p_pkt_new+1) + p_pkt_new->offset;
- *p_data++ = (AVRC_RSP_ACCEPT & AVRC_CTYPE_MASK);
- *p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT);
- *p_data++ = AVRC_OP_VENDOR;
- AVRC_CO_ID_TO_BE_STREAM(p_data, AVRC_CO_METADATA);
- *p_data++ = p_fcb->frag_pdu;
- *p_data++ = AVRC_PKT_END;
- UINT16_TO_BE_STREAM(p_data, (p_pkt_new->len - AVRC_VENDOR_HDR_SIZE - AVRC_MIN_META_HDR_SIZE)); /* 4=pdu, pkt_type & len */
-}
-
-/******************************************************************************
-**
-** Function avrc_send_continue_frag
-**
-** Description This function sends a continue response fragment
-**
-**
-** Returns Nothing.
-**
-******************************************************************************/
-static void avrc_send_continue_frag(UINT8 handle, UINT8 label)
-{
- tAVRC_FRAG_CB *p_fcb;
- BT_HDR *p_pkt_old, *p_pkt;
- UINT8 *p_old, *p_data;
- UINT8 cr = AVCT_RSP;
- tAVRC_RSP rej_rsp;
-
- p_fcb = &avrc_cb.fcb[handle];
- p_pkt = p_fcb->p_fmsg;
-
- AVRC_TRACE_DEBUG1 ("avrc_send_continue_frag len(%d) / AVRC_MAX_CTRL_DATA_LEN", p_pkt->len );
- if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN)
- {
- p_pkt_old = p_fcb->p_fmsg;
- p_pkt = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + AVCT_MSG_OFFSET + BT_HDR_SIZE));
- if (p_pkt)
- {
- p_pkt->len = AVRC_MAX_CTRL_DATA_LEN;
- p_pkt->offset = AVCT_MSG_OFFSET;
- p_pkt->layer_specific = p_pkt_old->layer_specific;
- p_pkt->event = p_pkt_old->event;
- p_old = (UINT8 *)(p_pkt_old+1) + p_pkt_old->offset;
- p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
- memcpy (p_data, p_old, AVRC_MAX_CTRL_DATA_LEN);
- /* use AVRC continue packet type */
- p_data += AVRC_VENDOR_HDR_SIZE;
- p_data++; /* pdu */
- *p_data++ = AVRC_PKT_CONTINUE;
- UINT16_TO_BE_STREAM(p_data, (AVRC_MAX_CTRL_DATA_LEN - AVRC_VENDOR_HDR_SIZE - 4)); /* 4=pdu, pkt_type & len */
-
- /* prepare the left over for as an end fragment */
- avrc_prep_end_frag (handle);
- }
- else
- {
- /* use the current GKI buffer to send Internal error status */
- p_pkt = p_fcb->p_fmsg;
- p_fcb->p_fmsg = NULL;
- p_fcb->frag_enabled = FALSE;
- AVRC_TRACE_ERROR0 ("AVRC_MsgReq no buffers for fragmentation - send internal error" );
- p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
- *p_data++ = AVRC_PDU_REQUEST_CONTINUATION_RSP;
- *p_data++ = 0;
- UINT16_TO_BE_STREAM(p_data, 0);
- p_pkt->len = 4;
- rej_rsp.pdu = AVRC_PDU_REQUEST_CONTINUATION_RSP;
- rej_rsp.status = AVRC_STS_INTERNAL_ERR;
- AVRC_BldResponse( handle, (tAVRC_RESPONSE *)&rej_rsp, &p_pkt);
- cr = AVCT_RSP;
- }
- }
- else
- {
- /* end fragment. clean the control block */
- p_fcb->frag_enabled = FALSE;
- p_fcb->p_fmsg = NULL;
- }
- AVCT_MsgReq( handle, label, cr, p_pkt);
-}
-
-/******************************************************************************
-**
-** Function avrc_proc_vendor_command
-**
-** Description This function processes received vendor command.
-**
-**
-** Returns if not NULL, the response to send right away.
-**
-******************************************************************************/
-static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label,
- BT_HDR *p_pkt, tAVRC_MSG_VENDOR *p_msg)
-{
- BT_HDR *p_rsp = NULL;
- UINT8 *p_data;
- UINT8 *p_begin;
- UINT8 pkt_type;
- BOOLEAN abort_frag = FALSE;
- tAVRC_STS status = AVRC_STS_NO_ERROR;
- tAVRC_FRAG_CB *p_fcb;
-
- p_begin = (UINT8 *)(p_pkt+1) + p_pkt->offset;
- p_data = p_begin + AVRC_VENDOR_HDR_SIZE;
- pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK;
-
- if (pkt_type != AVRC_PKT_SINGLE)
- {
- /* reject - commands can only be in single packets at AVRCP level */
- AVRC_TRACE_ERROR1 ("commands must be in single packet pdu:0x%x", *p_data );
- /* use the current GKI buffer to send the reject */
- status = AVRC_STS_BAD_CMD;
- }
- /* check if there are fragments waiting to be sent */
- else if (avrc_cb.fcb[handle].frag_enabled)
- {
- p_fcb = &avrc_cb.fcb[handle];
- if (p_msg->company_id == AVRC_CO_METADATA)
- {
- switch (*p_data)
- {
- case AVRC_PDU_ABORT_CONTINUATION_RSP:
- /* aborted by CT - send accept response */
- abort_frag = TRUE;
- p_begin = (UINT8 *)(p_pkt+1) + p_pkt->offset;
- *p_begin = (AVRC_RSP_ACCEPT & AVRC_CTYPE_MASK);
- if (*(p_data + 4) != p_fcb->frag_pdu)
- {
- *p_begin = (AVRC_RSP_REJ & AVRC_CTYPE_MASK);
- *(p_data + 4) = AVRC_STS_BAD_PARAM;
- }
- else
- {
- p_data = (p_begin + AVRC_VENDOR_HDR_SIZE + 2);
- UINT16_TO_BE_STREAM(p_data, 0);
- p_pkt->len = (p_data - p_begin);
- }
- AVCT_MsgReq( handle, label, AVCT_RSP, p_pkt);
- p_msg->hdr.opcode = AVRC_OP_DROP; /* used the p_pkt to send response */
- break;
-
- case AVRC_PDU_REQUEST_CONTINUATION_RSP:
- if (*(p_data + 4) == p_fcb->frag_pdu)
- {
- avrc_send_continue_frag(handle, label);
- p_msg->hdr.opcode = AVRC_OP_DROP_N_FREE;
- }
- else
- {
- /* the pdu id does not match - reject the command using the current GKI buffer */
- AVRC_TRACE_ERROR2("avrc_proc_vendor_command continue pdu: 0x%x does not match current re-assembly pdu: 0x%x",
- *(p_data + 4), p_fcb->frag_pdu);
- status = AVRC_STS_BAD_PARAM;
- abort_frag = TRUE;
- }
- break;
-
- default:
- /* implicit abort */
- abort_frag = TRUE;
- }
- }
- else
- {
- abort_frag = TRUE;
- /* implicit abort */
- }
-
- if (abort_frag)
- {
- if (p_fcb->p_fmsg)
- GKI_freebuf(p_fcb->p_fmsg);
- p_fcb->p_fmsg = NULL;
- p_fcb->frag_enabled = FALSE;
- }
- }
-
- if (status != AVRC_STS_NO_ERROR)
- {
- /* use the current GKI buffer to build/send the reject message */
- p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
- *p_data++ = AVRC_RSP_REJ;
- p_data += AVRC_VENDOR_HDR_SIZE; /* pdu */
- *p_data++ = 0; /* pkt_type */
- UINT16_TO_BE_STREAM(p_data, 1); /* len */
- *p_data++ = status; /* error code */
- p_pkt->len = AVRC_VENDOR_HDR_SIZE + 5;
- p_rsp = p_pkt;
- }
-
- return p_rsp;
-}
-
-/******************************************************************************
-**
-** Function avrc_proc_far_msg
-**
-** Description This function processes vendor command/response fragmetation
-** and reassembly
-**
-** Returns 0, to report the message with msg_cback .
-**
-******************************************************************************/
-static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_pkt, tAVRC_MSG_VENDOR *p_msg)
-{
- BT_HDR *p_pkt = *pp_pkt;
- UINT8 *p_data;
- BOOLEAN drop = FALSE;
- BT_HDR *p_rsp = NULL;
- BT_HDR *p_cmd = NULL;
- BOOLEAN req_continue = FALSE;
- BT_HDR *p_pkt_new = NULL;
- UINT8 pkt_type;
- UINT16 buf_len;
- tAVRC_RASM_CB *p_rcb;
- tAVRC_NEXT_CMD avrc_cmd;
-
- p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
- pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK;
- AVRC_TRACE_DEBUG1 ("pkt_type %d", pkt_type );
- p_rcb = &avrc_cb.rcb[handle];
- if (p_msg->company_id == AVRC_CO_METADATA)
- {
- /* check if the message needs to be re-assembled */
- if (pkt_type == AVRC_PKT_SINGLE || pkt_type == AVRC_PKT_START)
- {
- /* previous fragments need to be dropped, when received another new message */
- p_rcb->rasm_offset = 0;
- if (p_rcb->p_rmsg)
- {
- GKI_freebuf(p_rcb->p_rmsg);
- p_rcb->p_rmsg = NULL;
- }
- }
-
- if (pkt_type != AVRC_PKT_SINGLE && cr == AVCT_RSP)
- {
- /* not a single response packet - need to re-assemble metadata messages */
- if (pkt_type == AVRC_PKT_START)
- {
- p_rcb->rasm_offset = p_pkt->offset;
- p_rcb->p_rmsg = p_pkt;
- /* set offset to point to where to copy next - use the same re-asm logic as AVCT */
- p_rcb->p_rmsg->offset += p_rcb->p_rmsg->len;
- p_rcb->rasm_pdu = *p_data;
- req_continue = TRUE;
- }
- else
- {
- /* get size of buffer holding assembled message */
- buf_len = GKI_get_buf_size (p_rcb->p_rmsg) - sizeof(BT_HDR);
- /* adjust offset and len of fragment for header byte */
- p_pkt->offset += (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);
- p_pkt->len -= (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);
- /* verify length */
- if ((p_rcb->p_rmsg->offset + p_pkt->len) > buf_len)
- {
- AVRC_TRACE_WARNING0("Fragmented message too big! - report the partial message");
- p_pkt->len = buf_len - p_rcb->p_rmsg->offset;
- pkt_type = AVRC_PKT_END;
- }
-
- /* copy contents of p_pkt to p_rx_msg */
- memcpy((UINT8 *)(p_rcb->p_rmsg + 1) + p_rcb->p_rmsg->offset,
- (UINT8 *)(p_pkt + 1) + p_pkt->offset, p_pkt->len);
-
- if (pkt_type == AVRC_PKT_END)
- {
- p_rcb->p_rmsg->offset = p_rcb->rasm_offset;
- p_rcb->p_rmsg->len += p_pkt->len;
- p_pkt_new = p_rcb->p_rmsg;
- p_rcb->rasm_offset = 0;
- p_rcb->p_rmsg = NULL;
- p_msg->p_vendor_data = (UINT8 *)(p_pkt_new+1) + p_pkt_new->offset;
- p_msg->hdr.ctype = p_msg->p_vendor_data[0] & AVRC_CTYPE_MASK;
- p_msg->p_vendor_data += AVRC_VENDOR_HDR_SIZE; /* 6 = ctype, subunit*, opcode & CO_ID */
- p_msg->vendor_len = p_pkt_new->len - AVRC_VENDOR_HDR_SIZE;
- p_data = p_msg->p_vendor_data + 1; /* skip pdu */
- *p_data++ = AVRC_PKT_SINGLE;
- UINT16_TO_BE_STREAM(p_data, (p_msg->vendor_len - AVRC_MIN_META_HDR_SIZE));
- AVRC_TRACE_DEBUG3("end frag:%d, total len:%d, offset:%d", p_pkt->len, p_pkt_new->len, p_pkt_new->offset);
- }
- else
- {
- p_rcb->p_rmsg->offset += p_pkt->len;
- p_rcb->p_rmsg->len += p_pkt->len;
- p_pkt_new = NULL;
- req_continue = TRUE;
- }
- GKI_freebuf(p_pkt);
- *pp_pkt = p_pkt_new;
- }
- }
-
- if (cr == AVCT_CMD)
- {
- p_rsp = avrc_proc_vendor_command(handle, label, *pp_pkt, p_msg);
- if (p_rsp)
- {
- AVCT_MsgReq( handle, label, AVCT_RSP, p_rsp);
- drop = 3;
- }
- else if (p_msg->hdr.opcode == AVRC_OP_DROP)
- {
- drop = 1;
- }
- else if (p_msg->hdr.opcode == AVRC_OP_DROP_N_FREE)
- drop = 4;
-
- }
- else if (cr == AVCT_RSP && req_continue == TRUE)
- {
- avrc_cmd.pdu = AVRC_PDU_REQUEST_CONTINUATION_RSP;
- avrc_cmd.status = AVRC_STS_NO_ERROR;
- avrc_cmd.target_pdu = p_rcb->rasm_pdu;
- if (AVRC_BldCommand ((tAVRC_COMMAND *)&avrc_cmd, &p_cmd) == AVRC_STS_NO_ERROR)
- {
- cr = AVCT_CMD;
- drop = 2;
- AVRC_MsgReq (handle, (UINT8)(label+1), cr, p_cmd);
- }
- }
- }
- return drop;
-}
-#endif /* (AVRC_METADATA_INCLUDED == TRUE) */
/******************************************************************************
**
@@ -497,17 +149,6 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
memset(&msg, 0, sizeof(tAVRC_MSG) );
-#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE))
- if (p_pkt->layer_specific == AVCT_DATA_BROWSE)
- {
- opcode = AVRC_OP_BROWSE;
- msg.browse.hdr.ctype= cr;
- msg.browse.p_browse_data = p_data;
- msg.browse.browse_len = p_pkt->len;
- msg.browse.p_browse_pkt = p_pkt;
- }
- else
-#endif
{
msg.hdr.ctype = p_data[0] & AVRC_CTYPE_MASK;
AVRC_TRACE_DEBUG4("avrc_msg_cback handle:%d, ctype:%d, offset:%d, len: %d",
@@ -602,34 +243,6 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
p_msg->p_vendor_data = p_data;
p_msg->vendor_len = p_pkt->len - (p_data - p_begin);
-#if (AVRC_METADATA_INCLUDED == TRUE)
- drop = avrc_proc_far_msg(handle, label, cr, &p_pkt, p_msg);
- if (drop)
- {
- free = FALSE;
- if (drop == 4)
- free = TRUE;
-#if (BT_USE_TRACES == TRUE)
- switch (drop)
- {
- case 1:
- p_drop_msg = "sent_frag";
- break;
- case 2:
- p_drop_msg = "req_cont";
- break;
- case 3:
- p_drop_msg = "sent_frag3";
- break;
- case 4:
- p_drop_msg = "sent_frag_free";
- break;
- default:
- p_drop_msg = "sent_fragd";
- }
-#endif
- }
-#endif /* (AVRC_METADATA_INCLUDED == TRUE) */
break;
case AVRC_OP_PASS_THRU:
@@ -657,12 +270,6 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
msg.pass.p_pass_data = NULL;
break;
-#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE))
- case AVRC_OP_BROWSE:
- /* the event data is handled already.
- * this empty "case" is to keep the message from being rejected by the default case. */
- break;
-#endif
default:
if ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD))
@@ -676,9 +283,6 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
}
else /* drop the event */
{
-#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE))
- if (opcode != AVRC_OP_BROWSE)
-#endif
drop = TRUE;
}
@@ -717,12 +321,6 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
}
#endif
-#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE))
- if (opcode == AVRC_OP_BROWSE && msg.browse.p_browse_pkt == NULL)
- {
- free = FALSE;
- }
-#endif
if (free)
GKI_freebuf(p_pkt);
@@ -847,10 +445,6 @@ UINT16 AVRC_Open(UINT8 *p_handle, tAVRC_CONN_CB *p_ccb, BD_ADDR_PTR peer_addr)
if (status == AVCT_SUCCESS)
{
memcpy(&avrc_cb.ccb[*p_handle], p_ccb, sizeof(tAVRC_CONN_CB));
-#if (AVRC_METADATA_INCLUDED == TRUE)
- memset(&avrc_cb.fcb[*p_handle], 0, sizeof(tAVRC_FRAG_CB));
- memset(&avrc_cb.rcb[*p_handle], 0, sizeof(tAVRC_RASM_CB));
-#endif
}
AVRC_TRACE_DEBUG4("AVRC_Open role: %d, control:%d status:%d, handle:%d", cc.role, cc.control, status, *p_handle);
@@ -881,43 +475,6 @@ UINT16 AVRC_Close(UINT8 handle)
return AVCT_RemoveConn(handle);
}
-#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE))
-/******************************************************************************
-**
-** Function AVRC_OpenBrowse
-**
-** Description This function is called to open a browsing connection to AVCTP.
-** The connection can be either an initiator or acceptor, as
-** determined by the p_conn_role.
-** The handle is returned by a previous call to AVRC_Open.
-**
-** Returns AVRC_SUCCESS if successful.
-** AVRC_NO_RESOURCES if there are not enough resources to open
-** the connection.
-**
-******************************************************************************/
-UINT16 AVRC_OpenBrowse(UINT8 handle, UINT8 conn_role)
-{
- return AVCT_CreateBrowse(handle, conn_role);
-}
-
-/******************************************************************************
-**
-** Function AVRC_CloseBrowse
-**
-** Description Close a connection opened with AVRC_OpenBrowse().
-** This function is called when the
-** application is no longer using a connection.
-**
-** Returns AVRC_SUCCESS if successful.
-** AVRC_BAD_HANDLE if handle is invalid.
-**
-******************************************************************************/
-UINT16 AVRC_CloseBrowse(UINT8 handle)
-{
- return AVCT_RemoveBrowse(handle);
-}
-#endif
/******************************************************************************
**
@@ -937,121 +494,7 @@ UINT16 AVRC_CloseBrowse(UINT8 handle)
******************************************************************************/
UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
{
-#if (AVRC_METADATA_INCLUDED == TRUE)
- UINT8 *p_data;
- UINT8 cr = AVCT_CMD;
- BOOLEAN chk_frag = TRUE;
- UINT8 *p_start = NULL;
- tAVRC_FRAG_CB *p_fcb;
- UINT16 len;
- BT_HDR *p_pkt_new;
-#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE))
- UINT16 peer_mtu;
-#endif
-
- if (!p_pkt)
- return AVRC_BAD_PARAM;
-
- if (ctype >= AVRC_RSP_NOT_IMPL)
- cr = AVCT_RSP;
-
- if (p_pkt->event == AVRC_OP_VENDOR)
- {
- /* add AVRCP Vendor Dependent headers */
- p_start = ((UINT8 *)(p_pkt + 1) + p_pkt->offset);
- p_pkt->offset -= AVRC_VENDOR_HDR_SIZE;
- p_pkt->len += AVRC_VENDOR_HDR_SIZE;
- p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- *p_data++ = (ctype & AVRC_CTYPE_MASK);
- *p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT);
- *p_data++ = AVRC_OP_VENDOR;
- AVRC_CO_ID_TO_BE_STREAM(p_data, AVRC_CO_METADATA);
- }
- else if (p_pkt->event == AVRC_OP_PASS_THRU)
- {
- /* add AVRCP Pass Through headers */
- p_start = ((UINT8 *)(p_pkt + 1) + p_pkt->offset);
- p_pkt->offset -= AVRC_PASS_THRU_SIZE;
- p_pkt->len += AVRC_PASS_THRU_SIZE;
- p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- *p_data++ = (ctype & AVRC_CTYPE_MASK);
- *p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT);
- *p_data++ = AVRC_OP_PASS_THRU;/* opcode */
- *p_data++ = AVRC_ID_VENDOR; /* operation id */
- *p_data++ = 5; /* operation data len */
- AVRC_CO_ID_TO_BE_STREAM(p_data, AVRC_CO_METADATA);
- }
-#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE))
- else
- {
- chk_frag = FALSE;
- peer_mtu = AVCT_GetBrowseMtu (handle);
- if (p_pkt->len > (peer_mtu-AVCT_HDR_LEN_SINGLE))
- {
- AVRC_TRACE_ERROR3 ("p_pkt->len(%d) > peer_mtu(%d-%d)", p_pkt->len, peer_mtu, AVCT_HDR_LEN_SINGLE );
- GKI_freebuf(p_pkt);
- return AVRC_MSG_TOO_BIG;
- }
- }
-#endif
-
- /* abandon previous fragments */
- p_fcb = &avrc_cb.fcb[handle];
- if (p_fcb->frag_enabled)
- p_fcb->frag_enabled = FALSE;
-
- if (p_fcb->p_fmsg)
- {
- GKI_freebuf(p_fcb->p_fmsg);
- p_fcb->p_fmsg = NULL;
- }
-
- /* AVRCP spec has not defined any control channel commands that needs fragmentation at this level
- * check for fragmentation only on the response */
- if ((cr == AVCT_RSP) && (chk_frag == TRUE))
- {
- if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN)
- {
- AVRC_TRACE_DEBUG1 ("p_pkt->len(%d) > AVRC_MAX_CTRL_DATA_LEN", p_pkt->len );
- p_pkt_new = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + AVCT_MSG_OFFSET + BT_HDR_SIZE));
- if (p_pkt_new)
- {
- p_fcb->frag_enabled = TRUE;
- p_fcb->p_fmsg = p_pkt;
- p_fcb->frag_pdu = *p_start;
- p_pkt = p_pkt_new;
- p_pkt_new = p_fcb->p_fmsg;
- p_pkt->len = AVRC_MAX_CTRL_DATA_LEN;
- p_pkt->offset = p_pkt_new->offset;
- p_pkt->layer_specific = p_pkt_new->layer_specific;
- p_pkt->event = p_pkt_new->event;
- p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
- p_start -= AVRC_VENDOR_HDR_SIZE;
- memcpy (p_data, p_start, AVRC_MAX_CTRL_DATA_LEN);
- /* use AVRC start packet type */
- p_data += AVRC_VENDOR_HDR_SIZE;
- p_data++; /* pdu */
- *p_data++ = AVRC_PKT_START;
- len = (AVRC_MAX_CTRL_DATA_LEN - AVRC_VENDOR_HDR_SIZE - AVRC_MIN_META_HDR_SIZE); /* 4 pdu, pkt_type & len */
- UINT16_TO_BE_STREAM(p_data, len);
-
- /* prepare the left over for as an end fragment */
- avrc_prep_end_frag (handle);
- AVRC_TRACE_DEBUG3 ("p_pkt len:%d/%d, next len:%d", p_pkt->len, len, p_fcb->p_fmsg->len );
- }
- else
- {
- AVRC_TRACE_ERROR0 ("AVRC_MsgReq no buffers for fragmentation" );
- GKI_freebuf(p_pkt);
- return AVRC_NO_RESOURCES;
- }
- }
- }
-
- return AVCT_MsgReq( handle, label, cr, p_pkt);
-#else
return AVRC_NO_RESOURCES;
-#endif
}
diff --git a/stack/avrc/avrc_bld_ct.c b/stack/avrc/avrc_bld_ct.c
deleted file mode 100644
index a1d5fa1..0000000
--- a/stack/avrc/avrc_bld_ct.c
+++ /dev/null
@@ -1,1102 +0,0 @@
-/*****************************************************************************
-**
-** Name: avrc_bld_ct.c
-**
-** Description:Interface to AVRCP build message functions for the Control Role
-**
-** Copyright (c) 2008-2008, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "gki.h"
-#include "avrc_api.h"
-#include "avrc_defs.h"
-#include "avrc_int.h"
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-
-#if (AVRC_METADATA_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function avrc_bld_get_capability_cmd
-**
-** Description This function builds the Get Capability command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_capability_cmd (tAVRC_GET_CAPS_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- if (!AVRC_IS_VALID_CAP_ID(p_cmd->capability_id))
- {
- AVRC_TRACE_ERROR1("avrc_bld_get_capability_cmd bad capability_id:0x%x", p_cmd->capability_id);
- return AVRC_STS_BAD_PARAM;
- }
-
- AVRC_TRACE_API0("avrc_bld_get_capability_cmd");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 2; /* pdu + rsvd */
-
- /* add fixed lenth - capability_id(1) */
- UINT16_TO_BE_STREAM(p_data, 1);
- /* add the capability_id */
- UINT8_TO_BE_STREAM(p_data, p_cmd->capability_id);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_list_app_settings_attr_cmd
-**
-** Description This function builds the List Application Settings Attribute
-** command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_list_app_settings_attr_cmd (tAVRC_CMD *p_cmd, BT_HDR *p_pkt)
-{
- AVRC_TRACE_API0("avrc_bld_list_app_settings_attr_cmd");
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_list_app_settings_values_cmd
-**
-** Description This function builds the List Application Setting Values
-** command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_list_app_settings_values_cmd (tAVRC_LIST_APP_VALUES_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- if (!AVRC_IsValidPlayerAttr(p_cmd->attr_id))
- {
- AVRC_TRACE_ERROR1("avrc_bld_list_app_settings_values_cmd bad attr:0x%x", p_cmd->attr_id);
- return AVRC_STS_BAD_PARAM;
- }
-
- AVRC_TRACE_API0("avrc_bld_list_app_settings_values_cmd");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 2; /* pdu + rsvd */
-
- /* add fixed lenth - attr_id(1) */
- UINT16_TO_BE_STREAM(p_data, 1);
- /* add the attr_id */
- UINT8_TO_BE_STREAM(p_data, p_cmd->attr_id);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_cur_app_setting_value_cmd
-**
-** Description This function builds the Get Current Application Setting Value
-** or the Get Application Setting Attribute Text command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_cur_app_setting_value_cmd (tAVRC_GET_CUR_APP_VALUE_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT8 *p_len;
- UINT16 len = 0;
- UINT8 xx;
- UINT8 *p_count;
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_len = p_data = p_start + 2; /* pdu + rsvd */
-
- BE_STREAM_TO_UINT16(len, p_data);
- p_count = p_data;
- if (len == 0)
- {
- /* first time initialize the attribute count */
- *p_count = 0;
- p_data++;
- len = 1;
- }
- else
- {
- p_data = p_start + p_pkt->len;
- }
-
- for (xx=0; xx<p_cmd->num_attr; xx++)
- {
- if (AVRC_IsValidPlayerAttr(p_cmd->attrs[xx]))
- {
- (*p_count)++;
- UINT8_TO_BE_STREAM(p_data, p_cmd->attrs[xx]);
- len++;
- }
- }
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_set_app_setting_value_cmd
-**
-** Description This function builds the Set Application Setting Value
-** command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_set_app_setting_value_cmd (tAVRC_SET_APP_VALUE_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT8 *p_len;
- UINT16 len;
- UINT8 xx;
- UINT8 *p_count;
-
- if (!p_cmd->p_vals)
- {
- AVRC_TRACE_ERROR0("avrc_bld_set_app_setting_value_cmd NULL parameter");
- return AVRC_STS_BAD_PARAM;
- }
-
- AVRC_TRACE_API1("avrc_bld_set_app_setting_value_cmd num_val:%d", p_cmd->num_val);
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 2; /* pdu + rsvd */
-
- BE_STREAM_TO_UINT16(len, p_data);
- p_count = p_data;
- if (len == 0)
- {
- /* first time initialize the attribute count */
- *p_count = 0;
- p_data++;
- len = 1;
- }
- else
- {
- p_data = p_start + p_pkt->len;
- }
-
-
- for (xx=0; xx<p_cmd->num_val; xx++)
- {
- AVRC_TRACE_DEBUG3("[%d] id/val = 0x%x/0x%x", xx, p_cmd->p_vals[xx].attr_id, p_cmd->p_vals[xx].attr_val);
- if (avrc_is_valid_player_attrib_value(p_cmd->p_vals[xx].attr_id, p_cmd->p_vals[xx].attr_val))
- {
- (*p_count)++;
- UINT8_TO_BE_STREAM(p_data, p_cmd->p_vals[xx].attr_id);
- UINT8_TO_BE_STREAM(p_data, p_cmd->p_vals[xx].attr_val);
- len += 2;
- }
- }
-
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_app_setting_attr_text_cmd
-**
-** Description This function builds the Get Application Setting Attribute Text
-** command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_app_setting_attr_text_cmd (tAVRC_GET_APP_ATTR_TXT_CMD *p_cmd, BT_HDR *p_pkt)
-{
- AVRC_TRACE_API0("avrc_bld_get_app_setting_attr_text_cmd");
- return avrc_bld_get_cur_app_setting_value_cmd((tAVRC_GET_CUR_APP_VALUE_CMD *)p_cmd, p_pkt);
-
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_app_setting_value_text_cmd
-**
-** Description This function builds the Get Application Setting Value Text
-** command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_app_setting_value_text_cmd (tAVRC_GET_APP_VAL_TXT_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT8 *p_len;
- UINT16 len = 0;
- UINT8 xx;
- UINT8 *p_count;
-
- AVRC_TRACE_API0("avrc_bld_get_app_setting_value_text_cmd");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 2; /* pdu + rsvd */
-
- BE_STREAM_TO_UINT16(len, p_data);
- p_count = p_data + 1;
- if (len == 0)
- {
- /* first time initialize the attribute count */
- UINT8_TO_BE_STREAM(p_data, p_cmd->attr_id);
- *p_count = 0;
- p_data++;
- len = 2;
- }
- else
- {
- p_data = p_start + p_pkt->len;
- }
-
- for (xx=0; xx<p_cmd->num_val; xx++)
- {
- (*p_count)++;
- UINT8_TO_BE_STREAM(p_data, p_cmd->vals[xx]);
- len++;
- }
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_inform_charset_cmd
-**
-** Description This function builds the Inform Displayable Character Set
-** command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_inform_charset_cmd (tAVRC_INFORM_CHARSET_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT16 len = 0;
- UINT8 xx;
-
- AVRC_TRACE_API0("avrc_bld_inform_charset_cmd");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 2; /* pdu + rsvd */
-
- len = 1 + (p_cmd->num_id << 1);
- UINT16_TO_BE_STREAM(p_data, len);
-
- UINT8_TO_BE_STREAM(p_data, p_cmd->num_id);
- for (xx=0; xx<p_cmd->num_id; xx++)
- {
- UINT16_TO_BE_STREAM(p_data, p_cmd->charsets[xx]);
- }
-
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_inform_battery_status_cmd
-**
-** Description This function builds the Inform Battery Status
-** command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_inform_battery_status_cmd (tAVRC_BATTERY_STATUS_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- if (!AVRC_IS_VALID_BATTERY_STATUS(p_cmd->battery_status))
- {
- AVRC_TRACE_ERROR1("avrc_bld_inform_battery_status_cmd bad battery_status:0x%x", p_cmd->battery_status);
- return AVRC_STS_BAD_PARAM;
- }
-
- AVRC_TRACE_API0("avrc_bld_inform_battery_status_cmd");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 2; /* pdu + rsvd */
- /* add fixed lenth - battery_status(1) */
- UINT16_TO_BE_STREAM(p_data, 1);
- /* add the battery_status */
- UINT8_TO_BE_STREAM(p_data, p_cmd->battery_status);
-
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_elem_attrs_cmd
-**
-** Description This function builds the Get Element Attributes
-** command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_elem_attrs_cmd (tAVRC_GET_ELEM_ATTRS_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT8 *p_len;
- UINT16 len = 0;
- UINT8 xx;
- UINT8 *p_count;
-
- AVRC_TRACE_API0("avrc_bld_get_elem_attrs_cmd");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_len = p_start + 2; /* pdu + rsvd */
- p_data = p_len + 2;
-
- /* 8 byte identifier 0 - PLAYING - the only valid one */
- UINT32_TO_BE_STREAM(p_data, 0);
- UINT32_TO_BE_STREAM(p_data, 0);
-
- p_count = p_data;
- p_data++;
- *p_count = 0;
- len = 9;
- for (xx=0; xx<p_cmd->num_attr; xx++)
- {
- if (AVRC_IS_VALID_MEDIA_ATTRIBUTE(p_cmd->attrs[xx]))
- {
- (*p_count)++;
- UINT32_TO_BE_STREAM(p_data, p_cmd->attrs[xx]);
- len += 4;
- }
- }
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_play_status_cmd
-**
-** Description This function builds the Get Play Status
-** command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_play_status_cmd (tAVRC_CMD *p_cmd, BT_HDR *p_pkt)
-{
- AVRC_TRACE_API0("avrc_bld_get_play_status_cmd");
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_notify_cmd
-**
-** Description This function builds the Register Notification command.
-**
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_notify_cmd (tAVRC_REG_NOTIF_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- AVRC_TRACE_API0("avrc_bld_notify_cmd");
- if (!AVRC_IS_VALID_EVENT_ID(p_cmd->event_id))
- {
- AVRC_TRACE_ERROR1("avrc_bld_notify_cmd bad event_id:0x%x", p_cmd->event_id);
- return AVRC_STS_BAD_PARAM;
- }
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 2; /* pdu + rsvd */
-
- /* add fixed lenth 5 - event_id (1) + interval(4) */
- UINT16_TO_BE_STREAM(p_data, 5);
- UINT8_TO_BE_STREAM(p_data, p_cmd->event_id);
- UINT32_TO_BE_STREAM(p_data, p_cmd->param);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_next_cmd
-**
-** Description This function builds the Request Continue or Abort command.
-**
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_next_cmd (tAVRC_NEXT_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- AVRC_TRACE_API0("avrc_bld_next_cmd");
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 2; /* pdu + rsvd */
-
- /* add fixed lenth 1 - pdu_id (1) */
- UINT16_TO_BE_STREAM(p_data, 1);
- UINT8_TO_BE_STREAM(p_data, p_cmd->target_pdu);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_group_navigation_cmd
-**
-** Description This function builds the Group Navigation
-** command.
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-tAVRC_STS avrc_bld_group_navigation_cmd (UINT16 navi_id, BT_HDR *p_pkt)
-{
- UINT8 *p_data;
-
- if (!AVRC_IS_VALID_GROUP(navi_id))
- {
- AVRC_TRACE_ERROR1("avrc_bld_group_navigation_cmd bad navigation op id: %d", navi_id);
- return AVRC_STS_BAD_PARAM;
- }
-
- AVRC_TRACE_API0("avrc_bld_group_navigation_cmd");
- p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
- UINT16_TO_BE_STREAM(p_data, navi_id);
- p_pkt->len = 2;
- return AVRC_STS_NO_ERROR;
-}
-
-/*****************************************************************************
-** the following commands are introduced in AVRCP 1.4
-*****************************************************************************/
-
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function avrc_bld_set_addr_player_cmd
-**
-** Description This function builds the Set Addresses Player command.
-**
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_set_addr_player_cmd (tAVRC_SET_ADDR_PLAYER_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- AVRC_TRACE_API0("avrc_bld_set_addr_player_cmd");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 2; /* pdu + rsvd */
- /* add fixed lenth - player_id(2) */
- UINT16_TO_BE_STREAM(p_data, 2);
- UINT16_TO_BE_STREAM(p_data, p_cmd->player_id);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_set_abs_volume_cmd
-**
-** Description This function builds the Set Absolute Volume command.
-**
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_set_abs_volume_cmd (tAVRC_SET_VOLUME_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- AVRC_TRACE_API0("avrc_bld_set_abs_volume_cmd");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 2; /* pdu + rsvd */
- /* add fixed lenth 1 - volume (1) */
- UINT16_TO_BE_STREAM(p_data, 1);
- UINT8_TO_BE_STREAM(p_data, (AVRC_MAX_VOLUME & p_cmd->volume));
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_set_browsed_player_cmd
-**
-** Description This function builds the Set Browsed Player command.
-**
-** This message goes through the Browsing channel and is
-** valid only when AVCT_BROWSE_INCLUDED compile option is TRUE
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-static tAVRC_STS avrc_bld_set_browsed_player_cmd (tAVRC_SET_BR_PLAYER_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- AVRC_TRACE_API0("avrc_bld_set_browsed_player_cmd");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 1; /* pdu */
- /* add fixed lenth - player_id(2) */
- UINT16_TO_BE_STREAM(p_data, 2);
- UINT16_TO_BE_STREAM(p_data, p_cmd->player_id);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-#endif
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_folder_items_cmd
-**
-** Description This function builds the Get Folder Items command.
-**
-** This message goes through the Browsing channel and is
-** valid only when AVCT_BROWSE_INCLUDED compile option is TRUE
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-static tAVRC_STS avrc_bld_get_folder_items_cmd (tAVRC_GET_ITEMS_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT8 *p_len, xx;
- UINT16 len = 0;
-
- AVRC_TRACE_API0("avrc_bld_get_folder_items_cmd");
- if (p_cmd->scope > AVRC_SCOPE_NOW_PLAYING || p_cmd->start_item > p_cmd->end_item)
- {
- AVRC_TRACE_ERROR3("bad scope:0x%x or range (%d-%d)", p_cmd->scope, p_cmd->start_item, p_cmd->end_item);
- return AVRC_STS_BAD_PARAM;
- }
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_len = p_start + 1; /* pdu */
- p_data = p_len + 2;
-
- UINT8_TO_BE_STREAM(p_data, p_cmd->scope);
- UINT32_TO_BE_STREAM(p_data, p_cmd->start_item);
- UINT32_TO_BE_STREAM(p_data, p_cmd->end_item);
- /* do not allow us to send the command with attribute list when scope is player list */
- if (p_cmd->scope == AVRC_SCOPE_PLAYER_LIST)
- p_cmd->attr_count = 0;
-
- UINT8_TO_BE_STREAM(p_data, p_cmd->attr_count);
- len = 10;
- if ((p_cmd->attr_count != AVRC_FOLDER_ITEM_COUNT_NONE) &&
- (p_cmd->attr_count > 0))
- {
- if (p_cmd->p_attr_list)
- {
- for (xx=0; xx<p_cmd->attr_count; xx++)
- {
- UINT32_TO_BE_STREAM(p_data, p_cmd->p_attr_list[xx]);
- len += 4;
- }
- }
- else
- {
- AVRC_TRACE_ERROR1("attr_count:%d but NULL p_attr_list", p_cmd->attr_count);
- return AVRC_STS_BAD_PARAM;
- }
- }
-
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-#endif
-
-/*******************************************************************************
-**
-** Function avrc_bld_change_path_cmd
-**
-** Description This function builds the Change Path command.
-**
-** This message goes through the Browsing channel and is
-** valid only when AVCT_BROWSE_INCLUDED compile option is TRUE
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-static tAVRC_STS avrc_bld_change_path_cmd (tAVRC_CHG_PATH_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- AVRC_TRACE_API0("avrc_bld_change_path_cmd");
- if (p_cmd->direction != AVRC_DIR_UP && p_cmd->direction != AVRC_DIR_DOWN)
- {
- AVRC_TRACE_ERROR1("AVRC_BldChangePathCmd bad direction:%d", p_cmd->direction);
- return AVRC_STS_BAD_PARAM;
- }
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 1; /* pdu */
- /* add fixed lenth - uid_counter(2) + direction(1) + uid(8) */
- UINT16_TO_BE_STREAM(p_data, 11);
- UINT16_TO_BE_STREAM(p_data, p_cmd->uid_counter);
- *p_data++ = p_cmd->direction;
- ARRAY_TO_BE_STREAM(p_data, p_cmd->folder_uid, AVRC_UID_SIZE);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-#endif
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_item_attrs_cmd
-**
-** Description This function builds the Get Item Attributes command.
-**
-** This message goes through the Browsing channel and is
-** valid only when AVCT_BROWSE_INCLUDED compile option is TRUE
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-static tAVRC_STS avrc_bld_get_item_attrs_cmd (tAVRC_GET_ATTRS_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT8 *p_len, xx;
- UINT16 len;
- UINT8 *p_count;
-
- AVRC_TRACE_API0("avrc_bld_get_item_attrs_cmd");
- if (p_cmd->scope > AVRC_SCOPE_NOW_PLAYING)
- {
- AVRC_TRACE_ERROR1("bad scope:%d", p_cmd->scope);
- return AVRC_STS_BAD_PARAM;
- }
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_len = p_start + 1; /* pdu */
- p_data = p_len + 2;
-
- UINT8_TO_BE_STREAM(p_data, p_cmd->scope);
- ARRAY_TO_BE_STREAM(p_data, p_cmd->uid, AVRC_UID_SIZE);
- UINT16_TO_BE_STREAM(p_data, p_cmd->uid_counter);
- //UINT8_TO_BE_STREAM(p_data, p_cmd->attr_count);
- p_count = p_data++;
- len = AVRC_UID_SIZE + 4;
- *p_count = 0;
-
- if (p_cmd->attr_count>0)
- {
- if (p_cmd->p_attr_list)
- {
- for (xx=0; xx<p_cmd->attr_count; xx++)
- {
- if (AVRC_IS_VALID_MEDIA_ATTRIBUTE(p_cmd->p_attr_list[xx]))
- {
- (*p_count)++;
- UINT32_TO_BE_STREAM(p_data, p_cmd->p_attr_list[xx]);
- len += 4;
- }
-#if (BT_USE_TRACES == TRUE)
- else
- {
- AVRC_TRACE_ERROR1("invalid attr id:%d", p_cmd->p_attr_list[xx]);
- }
-#endif
- }
- }
-#if (BT_USE_TRACES == TRUE)
- else
- {
- AVRC_TRACE_ERROR1("attr_count:%d, NULL p_attr_list", p_cmd->attr_count);
- }
-#endif
- }
- UINT16_TO_BE_STREAM(p_len, len);
-
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-#endif
-
-/*******************************************************************************
-**
-** Function avrc_bld_search_cmd
-**
-** Description This function builds the Search command.
-**
-** This message goes through the Browsing channel and is
-** valid only when AVCT_BROWSE_INCLUDED compile option is TRUE
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-static tAVRC_STS avrc_bld_search_cmd (tAVRC_SEARCH_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT16 len;
-
- AVRC_TRACE_API0("avrc_bld_search_cmd");
- if (!p_cmd->string.p_str)
- {
- AVRC_TRACE_ERROR0("null string");
- return AVRC_STS_BAD_PARAM;
- }
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 1; /* pdu */
- /* variable lenth */
- len = p_cmd->string.str_len + 4;
- UINT16_TO_BE_STREAM(p_data, len);
-
- UINT16_TO_BE_STREAM(p_data, p_cmd->string.charset_id);
- UINT16_TO_BE_STREAM(p_data, p_cmd->string.str_len);
- ARRAY_TO_BE_STREAM(p_data, p_cmd->string.p_str, p_cmd->string.str_len);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-#endif
-
-/*******************************************************************************
-**
-** Function avrc_bld_play_item_cmd
-**
-** Description This function builds the Play Item command.
-**
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_play_item_cmd (tAVRC_PLAY_ITEM_CMD *p_cmd, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- AVRC_TRACE_API0("avrc_bld_play_item_cmd");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 2; /* pdu + rsvd */
-
- /* fixed lenth - scope(1) + uid(8) + uid_counter(2) */
- UINT16_TO_BE_STREAM(p_data, 11);
-
- UINT8_TO_BE_STREAM(p_data, p_cmd->scope);
- ARRAY_TO_BE_STREAM(p_data, p_cmd->uid, AVRC_UID_SIZE);
- UINT16_TO_BE_STREAM(p_data, p_cmd->uid_counter);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_add_to_now_playing_cmd
-**
-** Description This function builds the Add to Now Playing command.
-**
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_add_to_now_playing_cmd (tAVRC_ADD_TO_PLAY_CMD *p_cmd, BT_HDR *p_pkt)
-{
- AVRC_TRACE_API0("avrc_bld_add_to_now_playing_cmd");
- return avrc_bld_play_item_cmd((tAVRC_PLAY_ITEM_CMD *)p_cmd, p_pkt);
-}
-
-#endif /* AVRC_ADV_CTRL_INCLUDED=TRUE */
-
-/*******************************************************************************
-**
-** Function avrc_bld_init_cmd_buffer
-**
-** Description This function initializes the command buffer based on PDU
-**
-** Returns NULL, if no GKI buffer or failure to build the message.
-** Otherwise, the GKI buffer that contains the initialized message.
-**
-*******************************************************************************/
-static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
-{
- UINT16 offset, chnl = AVCT_DATA_CTRL, len=AVRC_META_CMD_POOL_SIZE;
- BT_HDR *p_pkt=NULL;
- UINT8 opcode;
-
- opcode = avrc_opcode_from_pdu(p_cmd->pdu);
- AVRC_TRACE_API2("avrc_bld_init_cmd_buffer: pdu=%x, opcode=%x", p_cmd->pdu, opcode);
-
- switch (opcode)
- {
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- case AVRC_OP_BROWSE:
- chnl = AVCT_DATA_BROWSE;
- offset = AVCT_BROWSE_OFFSET;
- len = AVRC_BROWSE_POOL_SIZE;
- break;
-#endif /* AVCT_BROWSE_INCLUDED */
-
- case AVRC_OP_PASS_THRU:
- offset = AVRC_MSG_PASS_THRU_OFFSET;
- break;
-
- case AVRC_OP_VENDOR:
- offset = AVRC_MSG_VENDOR_OFFSET;
- break;
- }
-
- /* allocate and initialize the buffer */
- p_pkt = (BT_HDR *)GKI_getbuf(len);
- if (p_pkt)
- {
- UINT8 *p_data, *p_start;
-
- p_pkt->layer_specific = chnl;
- p_pkt->event = opcode;
- p_pkt->offset = offset;
- p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_start = p_data;
-
- /* pass thru - group navigation - has a two byte op_id, so dont do it here */
- if (opcode != AVRC_OP_PASS_THRU)
- *p_data++ = p_cmd->pdu;
-
- switch (opcode)
- {
- case AVRC_OP_VENDOR:
- /* reserved 0, packet_type 0 */
- UINT8_TO_BE_STREAM(p_data, 0);
- /* continue to the next "case to add length */
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- case AVRC_OP_BROWSE:
-#endif
- /* add fixed lenth - 0 */
- UINT16_TO_BE_STREAM(p_data, 0);
- break;
- }
-
- p_pkt->len = (p_data - p_start);
- }
- p_cmd->cmd.opcode = opcode;
- return p_pkt;
-}
-
-/*******************************************************************************
-**
-** Function AVRC_BldCommand
-**
-** Description This function builds the given AVRCP command to the given
-** GKI buffer
-**
-** Returns AVRC_STS_NO_ERROR, if the command is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt)
-{
- tAVRC_STS status = AVRC_STS_BAD_PARAM;
- BT_HDR *p_pkt;
- BOOLEAN alloc = FALSE;
-
- AVRC_TRACE_API2("AVRC_BldCommand: pdu=%x status=%x", p_cmd->cmd.pdu, p_cmd->cmd.status);
- if (!p_cmd || !pp_pkt)
- {
- AVRC_TRACE_API2("AVRC_BldCommand. Invalid parameters passed. p_cmd=%p, pp_pkt=%p", p_cmd, pp_pkt);
- return AVRC_STS_BAD_PARAM;
- }
-
- if (*pp_pkt == NULL)
- {
- if ((*pp_pkt = avrc_bld_init_cmd_buffer(p_cmd)) == NULL)
- {
- AVRC_TRACE_API0("AVRC_BldCommand: Failed to initialize command buffer");
- return AVRC_STS_INTERNAL_ERR;
- }
- alloc = TRUE;
- }
- status = AVRC_STS_NO_ERROR;
- p_pkt = *pp_pkt;
-
- switch (p_cmd->pdu)
- {
- case AVRC_PDU_NEXT_GROUP: /* 0x00 */
- case AVRC_PDU_PREV_GROUP: /* 0x01 */
- status = avrc_bld_group_navigation_cmd (p_cmd->pdu, p_pkt);
- break;
-
- case AVRC_PDU_GET_CAPABILITIES:
- status = avrc_bld_get_capability_cmd(&p_cmd->get_caps, p_pkt);
- break;
-
- case AVRC_PDU_LIST_PLAYER_APP_ATTR:
- status = avrc_bld_list_app_settings_attr_cmd(&p_cmd->list_app_attr, p_pkt);
- break;
-
- case AVRC_PDU_LIST_PLAYER_APP_VALUES:
- status = avrc_bld_list_app_settings_values_cmd(&p_cmd->list_app_values, p_pkt);
- break;
-
- case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE:
- status = avrc_bld_get_cur_app_setting_value_cmd(&p_cmd->get_cur_app_val, p_pkt);
- break;
-
- case AVRC_PDU_SET_PLAYER_APP_VALUE:
- status = avrc_bld_set_app_setting_value_cmd(&p_cmd->set_app_val, p_pkt);
- break;
-
- case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT:
- status = avrc_bld_get_app_setting_attr_text_cmd(&p_cmd->get_app_attr_txt, p_pkt);
- break;
-
- case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT:
- status = avrc_bld_get_app_setting_value_text_cmd(&p_cmd->get_app_val_txt, p_pkt);
- break;
-
- case AVRC_PDU_INFORM_DISPLAY_CHARSET:
- status = avrc_bld_inform_charset_cmd(&p_cmd->inform_charset, p_pkt);
- break;
-
- case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT:
- status = avrc_bld_inform_battery_status_cmd(&p_cmd->inform_battery_status, p_pkt);
- break;
-
- case AVRC_PDU_GET_ELEMENT_ATTR:
- status = avrc_bld_get_elem_attrs_cmd(&p_cmd->get_elem_attrs, p_pkt);
- break;
-
- case AVRC_PDU_GET_PLAY_STATUS:
- status = avrc_bld_get_play_status_cmd(&p_cmd->get_play_status, p_pkt);
- break;
-
- case AVRC_PDU_REGISTER_NOTIFICATION:
- status = avrc_bld_notify_cmd(&p_cmd->reg_notif, p_pkt);
- break;
-
- case AVRC_PDU_REQUEST_CONTINUATION_RSP: /* 0x40 */
- status = avrc_bld_next_cmd(&p_cmd->continu, p_pkt);
- break;
-
- case AVRC_PDU_ABORT_CONTINUATION_RSP: /* 0x41 */
- status = avrc_bld_next_cmd(&p_cmd->abort, p_pkt);
- break;
-
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
- case AVRC_PDU_SET_ABSOLUTE_VOLUME: /* 0x50 */
- status = avrc_bld_set_abs_volume_cmd(&p_cmd->volume, p_pkt);
- break;
-
- case AVRC_PDU_SET_ADDRESSED_PLAYER: /* 0x60 */
- status = avrc_bld_set_addr_player_cmd(&p_cmd->addr_player, p_pkt);
- break;
-
- case AVRC_PDU_PLAY_ITEM: /* 0x74 */
- status = avrc_bld_play_item_cmd(&p_cmd->play_item, p_pkt);
- break;
-
- case AVRC_PDU_ADD_TO_NOW_PLAYING: /* 0x90 */
- status = avrc_bld_add_to_now_playing_cmd(&p_cmd->add_to_play, p_pkt);
- break;
-
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- case AVRC_PDU_SET_BROWSED_PLAYER: /* 0x70 */
- status = avrc_bld_set_browsed_player_cmd(&p_cmd->br_player, p_pkt);
- break;
-
- case AVRC_PDU_GET_FOLDER_ITEMS: /* 0x71 */
- status = avrc_bld_get_folder_items_cmd(&p_cmd->get_items, p_pkt);
- break;
-
- case AVRC_PDU_CHANGE_PATH: /* 0x72 */
- status = avrc_bld_change_path_cmd(&p_cmd->chg_path, p_pkt);
- break;
-
- case AVRC_PDU_GET_ITEM_ATTRIBUTES: /* 0x73 */
- status = avrc_bld_get_item_attrs_cmd(&p_cmd->get_attrs, p_pkt);
- break;
-
- case AVRC_PDU_SEARCH: /* 0x80 */
- status = avrc_bld_search_cmd(&p_cmd->search, p_pkt);
- break;
-#endif
-#endif
-
- }
-
- if (alloc && (status != AVRC_STS_NO_ERROR) )
- {
- GKI_freebuf(p_pkt);
- *pp_pkt = NULL;
- }
- AVRC_TRACE_API1("AVRC_BldCommand: returning %d", status);
- return status;
-}
-#endif /* (AVRC_METADATA_INCLUDED == TRUE) */
-
diff --git a/stack/avrc/avrc_bld_tg.c b/stack/avrc/avrc_bld_tg.c
deleted file mode 100644
index 667499e..0000000
--- a/stack/avrc/avrc_bld_tg.c
+++ /dev/null
@@ -1,1547 +0,0 @@
-/*****************************************************************************
-**
-** Name: avrc_bld_tg.c
-**
-** Description:Interface to AVRCP build message functions for the Target Role
-**
-** Copyright (c) 2008-2008, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "gki.h"
-#include "avrc_api.h"
-#include "avrc_defs.h"
-#include "avrc_int.h"
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-#if (AVRC_METADATA_INCLUDED == TRUE)
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_capability_rsp
-**
-** Description This function builds the Get Capability response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_capability_rsp (tAVRC_GET_CAPS_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start, *p_len, *p_count;
- UINT16 len = 0;
- UINT8 xx;
- UINT32 *p_company_id;
- UINT8 *p_event_id;
- tAVRC_STS status = AVRC_STS_NO_ERROR;
-
- if (!(AVRC_IS_VALID_CAP_ID(p_rsp->capability_id)))
- {
- AVRC_TRACE_ERROR1("avrc_bld_get_capability_rsp bad parameter. p_rsp: %x", p_rsp);
- status = AVRC_STS_BAD_PARAM;
- return status;
- }
-
- AVRC_TRACE_API0("avrc_bld_get_capability_rsp");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 2; /* pdu + rsvd */
-
- BE_STREAM_TO_UINT16(len, p_data);
- UINT8_TO_BE_STREAM(p_data, p_rsp->capability_id);
- p_count = p_data;
-
- if (len == 0)
- {
- *p_count = p_rsp->count;
- p_data++;
- len = 2; /* move past the capability_id and count */
- }
- else
- {
- p_data = p_start + p_pkt->len;
- *p_count += p_rsp->count;
- }
-
- if (p_rsp->capability_id == AVRC_CAP_COMPANY_ID)
- {
- p_company_id = p_rsp->param.company_id;
- for (xx=0; xx< p_rsp->count; xx++)
- {
- UINT24_TO_BE_STREAM(p_data, p_company_id[xx]);
- }
- len += p_rsp->count * 3;
- }
- else
- {
- p_event_id = p_rsp->param.event_id;
- *p_count = 0;
- for (xx=0; xx< p_rsp->count; xx++)
- {
- if (AVRC_IS_VALID_EVENT_ID(p_event_id[xx]))
- {
- (*p_count)++;
- UINT8_TO_BE_STREAM(p_data, p_event_id[xx]);
- }
- }
- len += (*p_count);
- }
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
- status = AVRC_STS_NO_ERROR;
-
- return status;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_list_app_settings_attr_rsp
-**
-** Description This function builds the List Application Settings Attribute
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_list_app_settings_attr_rsp (tAVRC_LIST_APP_ATTR_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start, *p_len, *p_num;
- UINT16 len = 0;
- UINT8 xx;
-
- AVRC_TRACE_API0("avrc_bld_list_app_settings_attr_rsp");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 2; /* pdu + rsvd */
-
- BE_STREAM_TO_UINT16(len, p_data);
- p_num = p_data;
- if (len == 0)
- {
- /* first time initialize the attribute count */
- *p_num = 0;
- p_data++;
- }
- else
- {
- p_data = p_start + p_pkt->len;
- }
-
- for (xx=0; xx<p_rsp->num_attr; xx++)
- {
- if(AVRC_IsValidPlayerAttr(p_rsp->attrs[xx]))
- {
- (*p_num)++;
- UINT8_TO_BE_STREAM(p_data, p_rsp->attrs[xx]);
- }
- }
-
- len = *p_num + 1;
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_list_app_settings_values_rsp
-**
-** Description This function builds the List Application Setting Values
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_list_app_settings_values_rsp (tAVRC_LIST_APP_VALUES_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start, *p_len, *p_num;
- UINT8 xx;
- UINT16 len;
-
- AVRC_TRACE_API0("avrc_bld_list_app_settings_values_rsp");
-
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 2; /* pdu + rsvd */
-
- /* get the existing length, if any, and also the num attributes */
- BE_STREAM_TO_UINT16(len, p_data);
- p_num = p_data;
- /* first time initialize the attribute count */
- if (len == 0)
- {
- *p_num = p_rsp->num_val;
- p_data++;
- }
- else
- {
- p_data = p_start + p_pkt->len;
- *p_num += p_rsp->num_val;
- }
-
-
- for (xx=0; xx<p_rsp->num_val; xx++)
- {
- UINT8_TO_BE_STREAM(p_data, p_rsp->vals[xx]);
- }
-
- len = *p_num + 1;
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_cur_app_setting_value_rsp
-**
-** Description This function builds the Get Current Application Setting Value
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_cur_app_setting_value_rsp (tAVRC_GET_CUR_APP_VALUE_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start, *p_len, *p_count;
- UINT16 len;
- UINT8 xx;
-
- if (!p_rsp->p_vals)
- {
- AVRC_TRACE_ERROR0("avrc_bld_get_cur_app_setting_value_rsp NULL parameter");
- return AVRC_STS_BAD_PARAM;
- }
-
- AVRC_TRACE_API0("avrc_bld_get_cur_app_setting_value_rsp");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 2; /* pdu + rsvd */
-
- BE_STREAM_TO_UINT16(len, p_data);
- p_count = p_data;
- if (len == 0)
- {
- /* first time initialize the attribute count */
- *p_count = 0;
- p_data++;
- }
- else
- {
- p_data = p_start + p_pkt->len;
- }
-
- for (xx=0; xx<p_rsp->num_val; xx++)
- {
- if (avrc_is_valid_player_attrib_value(p_rsp->p_vals[xx].attr_id, p_rsp->p_vals[xx].attr_val))
- {
- (*p_count)++;
- UINT8_TO_BE_STREAM(p_data, p_rsp->p_vals[xx].attr_id);
- UINT8_TO_BE_STREAM(p_data, p_rsp->p_vals[xx].attr_val);
- }
- }
- len = ((*p_count) << 1) + 1;
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_set_app_setting_value_rsp
-**
-** Description This function builds the Set Application Setting Value
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_set_app_setting_value_rsp (tAVRC_RSP *p_rsp, BT_HDR *p_pkt)
-{
- /* nothing to be added. */
- AVRC_TRACE_API0("avrc_bld_set_app_setting_value_rsp");
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_app_setting_text_rsp
-**
-** Description This function builds the Get Application Settings Attribute Text
-** or Get Application Settings Value Text response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_app_setting_text_rsp (tAVRC_GET_APP_ATTR_TXT_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start, *p_len, *p_count;
- UINT16 len, len_left;
- UINT8 xx;
- tAVRC_STS sts = AVRC_STS_NO_ERROR;
- UINT8 num_added = 0;
-
- if (!p_rsp->p_attrs)
- {
- AVRC_TRACE_ERROR0("avrc_bld_app_setting_text_rsp NULL parameter");
- return AVRC_STS_BAD_PARAM;
- }
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 2; /* pdu + rsvd */
- len_left = GKI_get_buf_size(p_pkt) - BT_HDR_SIZE - p_pkt->offset - p_pkt->len;
-
- BE_STREAM_TO_UINT16(len, p_data);
- p_count = p_data;
-
- if (len == 0)
- {
- *p_count = 0;
- p_data++;
- }
- else
- {
- p_data = p_start + p_pkt->len;
- }
-
- for (xx=0; xx<p_rsp->num_attr; xx++)
- {
- if (len_left < (p_rsp->p_attrs[xx].str_len + 4))
- {
- AVRC_TRACE_ERROR3("avrc_bld_app_setting_text_rsp out of room (str_len:%d, left:%d)",
- xx, p_rsp->p_attrs[xx].str_len, len_left);
- p_rsp->num_attr = num_added;
- sts = AVRC_STS_INTERNAL_ERR;
- break;
- }
- if ( !p_rsp->p_attrs[xx].str_len || !p_rsp->p_attrs[xx].p_str )
- {
- AVRC_TRACE_ERROR1("avrc_bld_app_setting_text_rsp NULL attr text[%d]", xx);
- continue;
- }
- UINT8_TO_BE_STREAM(p_data, p_rsp->p_attrs[xx].attr_id);
- UINT16_TO_BE_STREAM(p_data, p_rsp->p_attrs[xx].charset_id);
- UINT8_TO_BE_STREAM(p_data, p_rsp->p_attrs[xx].str_len);
- ARRAY_TO_BE_STREAM(p_data, p_rsp->p_attrs[xx].p_str, p_rsp->p_attrs[xx].str_len);
- (*p_count)++;
- num_added++;
- }
- len = p_data - p_count;
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
-
- return sts;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_app_setting_attr_text_rsp
-**
-** Description This function builds the Get Application Setting Attribute Text
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_app_setting_attr_text_rsp (tAVRC_GET_APP_ATTR_TXT_RSP *p_rsp, BT_HDR *p_pkt)
-{
- AVRC_TRACE_API0("avrc_bld_get_app_setting_attr_text_rsp");
- return avrc_bld_app_setting_text_rsp(p_rsp, p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_app_setting_value_text_rsp
-**
-** Description This function builds the Get Application Setting Value Text
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_app_setting_value_text_rsp (tAVRC_GET_APP_ATTR_TXT_RSP *p_rsp, BT_HDR *p_pkt)
-{
- AVRC_TRACE_API0("avrc_bld_get_app_setting_value_text_rsp");
- return avrc_bld_app_setting_text_rsp(p_rsp, p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_inform_charset_rsp
-**
-** Description This function builds the Inform Displayable Character Set
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_inform_charset_rsp (tAVRC_RSP *p_rsp, BT_HDR *p_pkt)
-{
- /* nothing to be added. */
- AVRC_TRACE_API0("avrc_bld_inform_charset_rsp");
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_inform_battery_status_rsp
-**
-** Description This function builds the Inform Battery Status
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_inform_battery_status_rsp (tAVRC_RSP *p_rsp, BT_HDR *p_pkt)
-{
- /* nothing to be added. */
- AVRC_TRACE_API0("avrc_bld_inform_battery_status_rsp");
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_elem_attrs_rsp
-**
-** Description This function builds the Get Element Attributes
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_elem_attrs_rsp (tAVRC_GET_ELEM_ATTRS_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start, *p_len, *p_count;
- UINT16 len;
- UINT8 xx;
-
- AVRC_TRACE_API0("avrc_bld_get_elem_attrs_rsp");
- if (!p_rsp->p_attrs)
- {
- AVRC_TRACE_ERROR0("avrc_bld_get_elem_attrs_rsp NULL parameter");
- return AVRC_STS_BAD_PARAM;
- }
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 2; /* pdu + rsvd */
-
- BE_STREAM_TO_UINT16(len, p_data);
- p_count = p_data;
-
- if (len == 0)
- {
- *p_count = 0;
- p_data++;
- }
- else
- {
- p_data = p_start + p_pkt->len;
- }
-
- for (xx=0; xx<p_rsp->num_attr; xx++)
- {
- if (!AVRC_IS_VALID_MEDIA_ATTRIBUTE(p_rsp->p_attrs[xx].attr_id))
- {
- AVRC_TRACE_ERROR2("avrc_bld_get_elem_attrs_rsp invalid attr id[%d]: %d", xx, p_rsp->p_attrs[xx].attr_id);
- continue;
- }
- if ( !p_rsp->p_attrs[xx].name.p_str )
- {
- p_rsp->p_attrs[xx].name.str_len = 0;
- }
- UINT32_TO_BE_STREAM(p_data, p_rsp->p_attrs[xx].attr_id);
- UINT16_TO_BE_STREAM(p_data, p_rsp->p_attrs[xx].name.charset_id);
- UINT16_TO_BE_STREAM(p_data, p_rsp->p_attrs[xx].name.str_len);
- ARRAY_TO_BE_STREAM(p_data, p_rsp->p_attrs[xx].name.p_str, p_rsp->p_attrs[xx].name.str_len);
- (*p_count)++;
- }
- len = p_data - p_count;
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_play_status_rsp
-**
-** Description This function builds the Get Play Status
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_get_play_status_rsp (tAVRC_GET_PLAY_STATUS_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- AVRC_TRACE_API0("avrc_bld_get_play_status_rsp");
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 2;
-
- /* add fixed lenth - song len(4) + song position(4) + status(1) */
- UINT16_TO_BE_STREAM(p_data, 9);
- UINT32_TO_BE_STREAM(p_data, p_rsp->song_len);
- UINT32_TO_BE_STREAM(p_data, p_rsp->song_pos);
- UINT8_TO_BE_STREAM(p_data, p_rsp->play_status);
- p_pkt->len = (p_data - p_start);
-
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_notify_rsp
-**
-** Description This function builds the Notification response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_notify_rsp (tAVRC_REG_NOTIF_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT8 *p_len;
- UINT16 len = 0;
- UINT8 xx;
- tAVRC_STS status = AVRC_STS_NO_ERROR;
-
- AVRC_TRACE_API0("avrc_bld_notify_rsp");
-
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 2; /* pdu + rsvd */
- p_data += 2;
-
- UINT8_TO_BE_STREAM(p_data, p_rsp->event_id);
- switch (p_rsp->event_id)
- {
- case AVRC_EVT_PLAY_STATUS_CHANGE: /* 0x01 */
- /* p_rsp->param.play_status >= AVRC_PLAYSTATE_STOPPED is always TRUE */
- if ((p_rsp->param.play_status <= AVRC_PLAYSTATE_REV_SEEK) ||
- (p_rsp->param.play_status == AVRC_PLAYSTATE_ERROR) )
- {
- UINT8_TO_BE_STREAM(p_data, p_rsp->param.play_status);
- len = 2;
- }
- else
- {
- AVRC_TRACE_ERROR0("bad play state");
- status = AVRC_STS_BAD_PARAM;
- }
- break;
-
- case AVRC_EVT_TRACK_CHANGE: /* 0x02 */
- ARRAY_TO_BE_STREAM(p_data, p_rsp->param.track, AVRC_UID_SIZE);
- len = (UINT8)(AVRC_UID_SIZE + 1);
- break;
-
- case AVRC_EVT_TRACK_REACHED_END: /* 0x03 */
- case AVRC_EVT_TRACK_REACHED_START: /* 0x04 */
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
- case AVRC_EVT_NOW_PLAYING_CHANGE: /* 0x09 */
- case AVRC_EVT_AVAL_PLAYERS_CHANGE: /* 0x0a */
-#endif
- len = 1;
- break;
-
- case AVRC_EVT_PLAY_POS_CHANGED: /* 0x05 */
- UINT32_TO_BE_STREAM(p_data, p_rsp->param.play_pos);
- len = 5;
- break;
-
- case AVRC_EVT_BATTERY_STATUS_CHANGE: /* 0x06 */
- if (AVRC_IS_VALID_BATTERY_STATUS(p_rsp->param.battery_status))
- {
- UINT8_TO_BE_STREAM(p_data, p_rsp->param.battery_status);
- len = 2;
- }
- else
- {
- AVRC_TRACE_ERROR0("bad battery status");
- status = AVRC_STS_BAD_PARAM;
- }
- break;
-
- case AVRC_EVT_SYSTEM_STATUS_CHANGE: /* 0x07 */
- if (AVRC_IS_VALID_SYSTEM_STATUS(p_rsp->param.system_status))
- {
- UINT8_TO_BE_STREAM(p_data, p_rsp->param.system_status);
- len = 2;
- }
- else
- {
- AVRC_TRACE_ERROR0("bad system status");
- status = AVRC_STS_BAD_PARAM;
- }
- break;
-
- case AVRC_EVT_APP_SETTING_CHANGE: /* 0x08 */
- if (p_rsp->param.player_setting.num_attr > AVRC_MAX_APP_SETTINGS)
- p_rsp->param.player_setting.num_attr = AVRC_MAX_APP_SETTINGS;
-
- if (p_rsp->param.player_setting.num_attr > 0)
- {
- UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.num_attr);
- len = 2;
- for (xx=0; xx<p_rsp->param.player_setting.num_attr; xx++)
- {
- if (avrc_is_valid_player_attrib_value(p_rsp->param.player_setting.attr_id[xx], p_rsp->param.player_setting.attr_value[xx]))
- {
- UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.attr_id[xx]);
- UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.attr_value[xx]);
- }
- else
- {
- AVRC_TRACE_ERROR0("bad player app seeting attribute or value");
- status = AVRC_STS_BAD_PARAM;
- break;
- }
- len += 2;
- }
- }
- else
- status = AVRC_STS_BAD_PARAM;
- break;
-
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
- case AVRC_EVT_ADDR_PLAYER_CHANGE: /* 0x0b */
- UINT16_TO_BE_STREAM(p_data, p_rsp->param.addr_player.player_id); /* player_id */
- UINT16_TO_BE_STREAM(p_data, p_rsp->param.addr_player.uid_counter); /* uid counter */
- len = 5;
- break;
-
- case AVRC_EVT_UIDS_CHANGE: /* 0x0c */
- UINT16_TO_BE_STREAM(p_data, p_rsp->param.uid_counter); /* uid counter */
- len = 3;
- break;
-
- case AVRC_EVT_VOLUME_CHANGE: /* 0x0d */
- UINT8_TO_BE_STREAM(p_data, (UINT8)(p_rsp->param.volume&AVRC_MAX_VOLUME));
- len = 2;
- break;
-#endif
-
- default:
- status = AVRC_STS_BAD_PARAM;
- AVRC_TRACE_ERROR0("unknown event_id");
- }
-
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
-
- return status;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_next_rsp
-**
-** Description This function builds the Request Continue or Abort
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_next_rsp (tAVRC_RSP *p_rsp, BT_HDR *p_pkt)
-{
- /* nothing to be added. */
- AVRC_TRACE_API0("avrc_bld_next_rsp");
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_group_navigation_rsp
-**
-** Description This function builds the Group Navigation
-** response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-tAVRC_STS avrc_bld_group_navigation_rsp (UINT16 navi_id, BT_HDR *p_pkt)
-{
- UINT8 *p_data;
-
- if (!AVRC_IS_VALID_GROUP(navi_id))
- {
- AVRC_TRACE_ERROR1("avrc_bld_group_navigation_rsp bad navigation op id: %d", navi_id);
- return AVRC_STS_BAD_PARAM;
- }
-
- AVRC_TRACE_API0("avrc_bld_group_navigation_rsp");
- p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
- UINT16_TO_BE_STREAM(p_data, navi_id);
- p_pkt->len = 2;
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_rejected_rsp
-**
-** Description This function builds the General Response response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_rejected_rsp( tAVRC_RSP *p_rsp, BT_HDR *p_pkt )
-{
- UINT8 *p_data, *p_start;
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- UINT8 opcode = avrc_opcode_from_pdu(p_rsp->pdu);
-#endif
-
- AVRC_TRACE_API2("avrc_bld_rejected_rsp: status=%d, pdu:x%x", p_rsp->status, p_rsp->pdu);
-
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- if (opcode == AVRC_OP_BROWSE)
- {
- p_data = p_start + 1;
- if (avrc_opcode_from_pdu(*p_start) != AVRC_OP_BROWSE)
- {
- /* if the given opcode is not recognized as a browsing command opcode, use general reject command */
- *p_start = AVRC_PDU_GENERAL_REJECT;
- }
- }
- else
-#endif
- {
- p_data = p_start + 2;
- }
- AVRC_TRACE_DEBUG1("pdu:x%x", *p_start);
-
- UINT16_TO_BE_STREAM(p_data, 1);
- UINT8_TO_BE_STREAM(p_data, p_rsp->status);
- p_pkt->len = p_data - p_start;
-
- return AVRC_STS_NO_ERROR;
-}
-
-
-/*****************************************************************************
-** the following commands are introduced in AVRCP 1.4
-*****************************************************************************/
-
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function avrc_bld_ctrl_status_rsp
-**
-** Description This function builds the responses with a UINT8 parameter.
-**
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_ctrl_status_rsp (tAVRC_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 2; /* pdu + rsvd */
-
- /* add fixed lenth - status(1) */
- UINT16_TO_BE_STREAM(p_data, 1);
- UINT8_TO_BE_STREAM(p_data, p_rsp->status);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_set_addr_player_rsp
-**
-** Description This function builds the Set Addresses Player response.
-**
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_set_addr_player_rsp (tAVRC_RSP *p_rsp, BT_HDR *p_pkt)
-{
- AVRC_TRACE_API0("avrc_bld_set_addr_player_rsp");
- return avrc_bld_ctrl_status_rsp(p_rsp, p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function avrc_bld_set_abs_volume_rsp
-**
-** Description This function builds the Set Absolute Volume response.
-**
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_set_abs_volume_rsp (tAVRC_SET_VOLUME_RSP *p_rsp, BT_HDR *p_pkt)
-{
- p_rsp->status = (p_rsp->volume & AVRC_MAX_VOLUME);
- AVRC_TRACE_API2("avrc_bld_set_abs_volume_rsp volume:%d, sts:%d", p_rsp->volume, p_rsp->status);
- return avrc_bld_ctrl_status_rsp((tAVRC_RSP *)p_rsp, p_pkt);
-}
-
-
-/*******************************************************************************
-**
-** Function avrc_bld_set_browsed_player_rsp
-**
-** Description This function builds the Set Browsed Player response.
-**
-** This message goes through the Browsing channel and is
-** valid only when AVCT_BROWSE_INCLUDED compile option is TRUE
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-static tAVRC_STS avrc_bld_set_browsed_player_rsp (tAVRC_SET_BR_PLAYER_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT8 *p_len, xx;
- UINT16 len;
- tAVRC_NAME *p_folders = p_rsp->p_folders;
- UINT16 len_left;
- UINT8 *p_num;
- UINT16 mtu;
-
- AVRC_TRACE_API0("avrc_bld_set_browsed_player_rsp");
- /* make sure the given GKI buffer can accomodate this response */
- len_left = GKI_get_buf_size(p_pkt) - BT_HDR_SIZE;
- p_data = (UINT8 *)(p_pkt + 1);
- BE_STREAM_TO_UINT16 (mtu, p_data);
- if (len_left > mtu)
- {
- len_left = mtu;
- }
- len_left = len_left - p_pkt->offset - p_pkt->len;
- AVRC_TRACE_DEBUG2("len_left:%d, mtu:%d ", len_left, mtu);
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 1; /* pdu */
-
- /* the existing len */
- BE_STREAM_TO_UINT16(len, p_data);
- p_num = p_data + 9;
- if (len == 0)
- {
- /* first time initialize the attribute count */
- UINT8_TO_BE_STREAM(p_data, p_rsp->status);
- UINT16_TO_BE_STREAM(p_data, p_rsp->uid_counter);
- UINT32_TO_BE_STREAM(p_data, p_rsp->num_items);
- UINT16_TO_BE_STREAM(p_data, p_rsp->charset_id);
- *p_num = 0;
- p_data++;
- len = 10;
- len_left -= 12; /* assuming that we would never use a GKI buffer that is too small for headers */
- }
- else
- {
- p_data = p_start + p_pkt->len;
- }
-
- for (xx=0; (xx<p_rsp->folder_depth) && (len_left>(p_folders[xx].str_len + 2)); xx++)
- {
- (*p_num)++;
- UINT16_TO_BE_STREAM(p_data, p_folders[xx].str_len);
- ARRAY_TO_BE_STREAM(p_data, p_folders[xx].p_str, p_folders[xx].str_len);
- len += (p_folders[xx].str_len + 2);
- }
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-#endif
-
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_folder_items_rsp
-**
-** Description This function builds the Get Folder Items response.
-** The error code is returned in *p_status.
-** AVRC_STS_INTERNAL_ERR means no GKI buffers.
-** Try again later or with smaller item_count
-**
-** This message goes through the Browsing channel and is
-** valid only when AVCT_BROWSE_INCLUDED compile option is TRUE
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** AVRC_STS_INTERNAL_ERR, if the given GKI buffer does not have enough room
-** Otherwise, the error code.
-**
-*******************************************************************************/
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-static tAVRC_STS avrc_bld_get_folder_items_rsp (tAVRC_GET_ITEMS_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT8 *p_len, xx;
- UINT16 len;
- UINT16 item_len;
- UINT8 *p_item_len, yy;
- tAVRC_ITEM_PLAYER *p_player;
- tAVRC_ITEM_FOLDER *p_folder;
- tAVRC_ITEM_MEDIA *p_media;
- tAVRC_ATTR_ENTRY *p_attr;
- tAVRC_ITEM *p_item_list = p_rsp->p_item_list;
- tAVRC_STS status = AVRC_STS_NO_ERROR;
- UINT16 len_left;
- UINT8 *p_num, *p;
- UINT8 *p_item_start, *p_attr_count;
- UINT16 item_count;
- UINT16 mtu;
-
- AVRC_TRACE_API0("avrc_bld_get_folder_items_rsp");
- /* make sure the given GKI buffer can accomodate this response */
- len_left = GKI_get_buf_size(p_pkt) - BT_HDR_SIZE;
- p = (UINT8 *)(p_pkt + 1);
- BE_STREAM_TO_UINT16 (mtu, p);
- if (len_left > mtu)
- len_left = mtu;
- len_left = len_left - p_pkt->offset - p_pkt->len;
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 1; /* pdu */
-
- /* the existing len */
- BE_STREAM_TO_UINT16(len, p_data);
- p_num = p_data + 3;
- if (len == 0)
- {
- /* first time initialize the attribute count */
- UINT8_TO_BE_STREAM(p_data, p_rsp->status);
- UINT16_TO_BE_STREAM(p_data, p_rsp->uid_counter);
- item_count = 0;
- p_data+= 2;
- len = 5;
- len_left -= 5;
- }
- else
- {
- p_data = p_start + p_pkt->len;
- p = p_num;
- BE_STREAM_TO_UINT16 (item_count, p);
- }
- AVRC_TRACE_DEBUG3("len:%d, len_left:%d, num:%d", len, len_left, item_count);
-
- /* min len required = item_type(1) + item len(2) + min item (14) = 17 */
- for (xx=0; xx<p_rsp->item_count && len_left > 17; xx++)
- {
- p_item_start = p_data;
- UINT8_TO_BE_STREAM(p_data, p_item_list[xx].item_type);
- /* variable item lenth - save the location to add length */
- p_item_len = p_data;
- p_data += 2;
- item_len = 0;
- len_left -= 3; /* item_type(1) + item len(2) */
- switch (p_item_list[xx].item_type)
- {
- case AVRC_ITEM_PLAYER:
- /* min len required: 2 + 1 + 4 + 1 + 16 + 2 + 2 = 30 + str_len */
- p_player = &p_item_list[xx].u.player;
- item_len = AVRC_FEATURE_MASK_SIZE + p_player->name.str_len + 12;
- if ((len_left > item_len) &&
- p_player->name.p_str &&
- (p_player->major_type & AVRC_MJ_TYPE_INVALID) == 0 &&
- (p_player->sub_type & AVRC_SUB_TYPE_INVALID) == 0 &&
- (p_player->play_status <= AVRC_PLAYSTATE_REV_SEEK || p_player->play_status == AVRC_PLAYSTATE_ERROR) )
- {
- UINT16_TO_BE_STREAM(p_data, p_player->player_id);
- UINT8_TO_BE_STREAM(p_data, p_player->major_type);
- UINT32_TO_BE_STREAM(p_data, p_player->sub_type);
- UINT8_TO_BE_STREAM(p_data, p_player->play_status);
- ARRAY_TO_BE_STREAM(p_data, p_player->features, AVRC_FEATURE_MASK_SIZE);
- UINT16_TO_BE_STREAM(p_data, p_player->name.charset_id);
- UINT16_TO_BE_STREAM(p_data, p_player->name.str_len);
- ARRAY_TO_BE_STREAM(p_data, p_player->name.p_str, p_player->name.str_len);
- }
- else
- {
- p_data = p_item_start;
- }
- break;
-
- case AVRC_ITEM_FOLDER:
- /* min len required: 8 + 1 + 1 + 2 + 2 = 14 + str_len */
- p_folder = &p_item_list[xx].u.folder;
- item_len = AVRC_UID_SIZE + p_folder->name.str_len + 6;
- if ((len_left > item_len) &&
- p_folder->name.p_str &&
- p_folder->type <= AVRC_FOLDER_TYPE_YEARS &&
- p_folder->playable <= TRUE)
- {
- ARRAY_TO_BE_STREAM(p_data, p_folder->uid, AVRC_UID_SIZE);
- UINT8_TO_BE_STREAM(p_data, p_folder->type);
- UINT8_TO_BE_STREAM(p_data, p_folder->playable);
- UINT16_TO_BE_STREAM(p_data, p_folder->name.charset_id);
- UINT16_TO_BE_STREAM(p_data, p_folder->name.str_len);
- ARRAY_TO_BE_STREAM(p_data, p_folder->name.p_str, p_folder->name.str_len);
- }
- else
- {
- p_data = p_item_start;
- }
- break;
-
- case AVRC_ITEM_MEDIA:
- /* min len required: 8 + 1 + 2 + 2 + 1 = 14 + str_len */
- p_media = &p_item_list[xx].u.media;
- item_len = AVRC_UID_SIZE + p_media->name.str_len + 6;
- if ((len_left > item_len) &&
- p_media->name.p_str &&
- p_media->type <= AVRC_MEDIA_TYPE_VIDEO)
- {
- ARRAY_TO_BE_STREAM(p_data, p_media->uid, AVRC_UID_SIZE);
- UINT8_TO_BE_STREAM(p_data, p_media->type);
- UINT16_TO_BE_STREAM(p_data, p_media->name.charset_id);
- UINT16_TO_BE_STREAM(p_data, p_media->name.str_len);
- ARRAY_TO_BE_STREAM(p_data, p_media->name.p_str, p_media->name.str_len);
- p_attr_count = p_data++;
- *p_attr_count = 0;
- len_left -= item_len;
- if (p_media->attr_count>0)
- {
- p_attr = p_media->p_attr_list;
- for (yy=0; yy<p_media->attr_count && len_left > 8; yy++)
- {
- if (p_attr[yy].name.p_str &&
- AVRC_IS_VALID_MEDIA_ATTRIBUTE(p_attr[yy].attr_id) &&
- (len_left >= (p_attr[yy].name.str_len + 8)) )
- {
- (*p_attr_count) ++;
- UINT32_TO_BE_STREAM(p_data, p_attr[yy].attr_id);
- UINT16_TO_BE_STREAM(p_data, p_attr[yy].name.charset_id);
- UINT16_TO_BE_STREAM(p_data, p_attr[yy].name.str_len);
- ARRAY_TO_BE_STREAM(p_data, p_attr[yy].name.p_str, p_attr[yy].name.str_len);
- item_len += (p_attr[yy].name.str_len + 8);
- len_left -= (p_attr[yy].name.str_len + 8);
- }
- }
- }
- }
- else
- {
- p_data = p_item_start;
- }
- break;
- } /* switch item_type */
-
- if (p_item_start != p_data)
- {
- /* successfully added the item */
- item_count++;
- /* fill in variable item lenth */
- UINT16_TO_BE_STREAM(p_item_len, item_len);
- }
- else
- {
- /* some item is not added properly - set an error status */
- if (len_left > item_len)
- status = AVRC_STS_INTERNAL_ERR;
- else
- status = AVRC_STS_BAD_PARAM;
- }
-
- len += item_len;
- len += 3; /* the item_type(1) and item_len(2) */
- AVRC_TRACE_DEBUG4("len:%d, len_left:%d, num:%d, item_len:%d", len, len_left, item_count, item_len);
- } /* for item_count */
-
- UINT16_TO_BE_STREAM(p_num, item_count);
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
-
- if (p_rsp->item_count != xx)
- {
- p_rsp->item_count = xx;
- if (status == AVRC_STS_NO_ERROR)
- status = AVRC_STS_INTERNAL_ERR;
- }
-
- return status;
-}
-#endif
-
-
-/*******************************************************************************
-**
-** Function avrc_bld_change_path_rsp
-**
-** Description This function builds the Change Path response.
-**
-** This message goes through the Browsing channel and is
-** valid only when AVCT_BROWSE_INCLUDED compile option is TRUE
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-static tAVRC_STS avrc_bld_change_path_rsp (tAVRC_CHG_PATH_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_start + 1; /* pdu */
- /* add fixed lenth - status(1) + num_items(4) */
- UINT16_TO_BE_STREAM(p_data, 5);
- UINT8_TO_BE_STREAM(p_data, p_rsp->status);
- UINT32_TO_BE_STREAM(p_data, p_rsp->num_items);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-#endif
-
-
-/*******************************************************************************
-**
-** Function avrc_bld_get_item_attrs_rsp
-**
-** Description This function builds the Get Item Attributes response.
-**
-** This message goes through the Browsing channel and is
-** valid only when AVCT_BROWSE_INCLUDED compile option is TRUE
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** AVRC_STS_INTERNAL_ERR, if the given GKI buffer does not have enough room
-** Otherwise, the error code.
-**
-*******************************************************************************/
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-static tAVRC_STS avrc_bld_get_item_attrs_rsp (tAVRC_GET_ATTRS_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start;
- UINT8 *p_len, xx;
- UINT16 len, len_left;
- UINT8 *p_num;
- UINT16 mtu;
-
- AVRC_TRACE_API0("avrc_bld_get_item_attrs_rsp");
- /* calculate the GKI buffer size needed and validate the parameters */
- if (!p_rsp->p_attr_list)
- {
- AVRC_TRACE_ERROR0("NULL p_attr_list");
- return AVRC_STS_BAD_PARAM;
- }
-
- /* check the length before adding the attr to the message */
- len = 2;
- for (xx=0; xx<p_rsp->attr_count; xx++)
- {
- if(p_rsp->p_attr_list[xx].name.p_str == 0 ||
- !AVRC_IS_VALID_MEDIA_ATTRIBUTE(p_rsp->p_attr_list[xx].attr_id))
- {
- AVRC_TRACE_ERROR2("[%d] NULL p_attr_list str or bad attr_id:%d", xx, p_rsp->p_attr_list[xx].attr_id);
- return AVRC_STS_BAD_PARAM;
- }
- len += (p_rsp->p_attr_list[xx].name.str_len + 8);
- }
- len_left = GKI_get_buf_size(p_pkt) - BT_HDR_SIZE;
- p_data = (UINT8 *)(p_pkt + 1);
- BE_STREAM_TO_UINT16 (mtu, p_data);
- if (len_left > mtu)
- {
- len_left = mtu;
- }
- len_left = len_left - p_pkt->offset - p_pkt->len;
-
- AVRC_TRACE_DEBUG3("len_left:%d, mtu:%d len needed:%d", len_left, mtu, len);
- if (len_left < 11) /* 11 is 4/attr_id + 2/charset_id + 2/str_len + 3/first timer/attr count & len */
- {
- return AVRC_STS_INTERNAL_ERR;
- }
- if (len > len_left)
- {
- AVRC_TRACE_ERROR0("The GKI buffer does not have enough room to hold the given data.");
- }
-
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 1; /* pdu */
-
- /* the existing len */
- BE_STREAM_TO_UINT16(len, p_data);
- p_num = p_data + 1;
- if (len == 0)
- {
- /* first time initialize the attribute count */
- UINT8_TO_BE_STREAM(p_data, p_rsp->status);
- *p_num = 0;
- p_data++;
- len = 2;
- len_left -= 3;
- }
- else
- {
- p_data = p_start + p_pkt->len;
- }
-
-
- for (xx=0; (xx<p_rsp->attr_count) && (len_left>9); xx++)
- {
- (*p_num)++;
- UINT32_TO_BE_STREAM(p_data, p_rsp->p_attr_list[xx].attr_id);
- UINT16_TO_BE_STREAM(p_data, p_rsp->p_attr_list[xx].name.charset_id);
- UINT16_TO_BE_STREAM(p_data, p_rsp->p_attr_list[xx].name.str_len);
- len_left -= 8;
- if (p_rsp->p_attr_list[xx].name.str_len > len_left)
- p_rsp->p_attr_list[xx].name.str_len = len_left;
- ARRAY_TO_BE_STREAM(p_data, p_rsp->p_attr_list[xx].name.p_str, p_rsp->p_attr_list[xx].name.str_len);
- len_left -= p_rsp->p_attr_list[xx].name.str_len;
- len += (p_rsp->p_attr_list[xx].name.str_len + 8);
- }
-
- UINT16_TO_BE_STREAM(p_len, len);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-#endif
-
-
-/*******************************************************************************
-**
-** Function avrc_bld_search_rsp
-**
-** Description This function builds the Search response.
-**
-** This message goes through the Browsing channel and is
-** valid only when AVCT_BROWSE_INCLUDED compile option is TRUE
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-static tAVRC_STS avrc_bld_search_rsp (tAVRC_SEARCH_RSP *p_rsp, BT_HDR *p_pkt)
-{
- UINT8 *p_data, *p_start, *p_len;
-
- AVRC_TRACE_API0("avrc_bld_search_rsp");
- /* get the existing length, if any, and also the num attributes */
- p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_data = p_len = p_start + 1; /* pdu */
-
- /* add fixed lenth - status(1) + uid_counter(2) + num_items(4) */
- UINT16_TO_BE_STREAM(p_data, 7);
- UINT8_TO_BE_STREAM(p_data, p_rsp->status);
- UINT16_TO_BE_STREAM(p_data, p_rsp->uid_counter);
- UINT32_TO_BE_STREAM(p_data, p_rsp->num_items);
- p_pkt->len = (p_data - p_start);
- return AVRC_STS_NO_ERROR;
-}
-#endif
-
-
-/*******************************************************************************
-**
-** Function avrc_bld_play_item_rsp
-**
-** Description This function builds the Play Item response.
-**
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_play_item_rsp (tAVRC_RSP *p_rsp, BT_HDR *p_pkt)
-{
- AVRC_TRACE_API0("avrc_bld_play_item_rsp");
- return avrc_bld_ctrl_status_rsp(p_rsp, p_pkt);
-}
-
-
-/*******************************************************************************
-**
-** Function avrc_bld_add_to_now_playing_rsp
-**
-** Description This function builds the Add to Now Playing response.
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-static tAVRC_STS avrc_bld_add_to_now_playing_rsp (tAVRC_RSP *p_rsp, BT_HDR *p_pkt)
-{
- AVRC_TRACE_API0("avrc_bld_add_to_now_playing_rsp");
- return avrc_bld_ctrl_status_rsp(p_rsp, p_pkt);
-}
-
-#endif /* AVRC_ADV_CTRL_INCLUDED=TRUE */
-
-/*******************************************************************************
-**
-** Function avrc_bld_init_rsp_buffer
-**
-** Description This function initializes the response buffer based on PDU
-**
-** Returns NULL, if no GKI buffer or failure to build the message.
-** Otherwise, the GKI buffer that contains the initialized message.
-**
-*******************************************************************************/
-static BT_HDR *avrc_bld_init_rsp_buffer(tAVRC_RESPONSE *p_rsp)
-{
- UINT16 offset, chnl = AVCT_DATA_CTRL, len=AVRC_META_CMD_POOL_SIZE;
- BT_HDR *p_pkt=NULL;
- UINT8 opcode = avrc_opcode_from_pdu(p_rsp->pdu);
-
- AVRC_TRACE_API3("avrc_bld_init_rsp_buffer: pdu=%x, opcode=%x/%x", p_rsp->pdu, opcode, p_rsp->rsp.opcode);
- if (opcode != p_rsp->rsp.opcode && p_rsp->rsp.status != AVRC_STS_NO_ERROR && avrc_is_valid_opcode(p_rsp->rsp.opcode))
- {
- opcode = p_rsp->rsp.opcode;
- AVRC_TRACE_API1("opcode=%x", opcode);
- }
-
- switch (opcode)
- {
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- case AVRC_OP_BROWSE:
- chnl = AVCT_DATA_BROWSE;
- offset = AVCT_BROWSE_OFFSET;
- len = AVRC_BROWSE_POOL_SIZE;
- break;
-#endif /* AVCT_BROWSE_INCLUDED */
-
- case AVRC_OP_PASS_THRU:
- offset = AVRC_MSG_PASS_THRU_OFFSET;
- break;
-
- case AVRC_OP_VENDOR:
- offset = AVRC_MSG_VENDOR_OFFSET;
- if (p_rsp->pdu == AVRC_PDU_GET_ELEMENT_ATTR)
- len = AVRC_BROWSE_POOL_SIZE;
- break;
- }
-
- /* allocate and initialize the buffer */
- p_pkt = (BT_HDR *)GKI_getbuf(len);
- if (p_pkt)
- {
- UINT8 *p_data, *p_start;
-
- p_pkt->layer_specific = chnl;
- p_pkt->event = opcode;
- p_pkt->offset = offset;
- p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- p_start = p_data;
-
- /* pass thru - group navigation - has a two byte op_id, so dont do it here */
- if (opcode != AVRC_OP_PASS_THRU)
- *p_data++ = p_rsp->pdu;
-
- switch (opcode)
- {
- case AVRC_OP_VENDOR:
- /* reserved 0, packet_type 0 */
- UINT8_TO_BE_STREAM(p_data, 0);
- /* continue to the next "case to add length */
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- case AVRC_OP_BROWSE:
-#endif
- /* add fixed lenth - 0 */
- UINT16_TO_BE_STREAM(p_data, 0);
- break;
- }
-
- p_pkt->len = (p_data - p_start);
- }
- p_rsp->rsp.opcode = opcode;
- return p_pkt;
-}
-
-/*******************************************************************************
-**
-** Function AVRC_BldResponse
-**
-** Description This function builds the given AVRCP response to the given
-** GKI buffer
-**
-** Returns AVRC_STS_NO_ERROR, if the response is built successfully
-** Otherwise, the error code.
-**
-*******************************************************************************/
-tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt)
-{
- tAVRC_STS status = AVRC_STS_BAD_PARAM;
- BT_HDR *p_pkt;
- BOOLEAN alloc = FALSE;
-#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE))
- UINT8 *p;
- UINT16 peer_mtu;
-#endif
-
- if (!p_rsp || !pp_pkt)
- {
- AVRC_TRACE_API2("AVRC_BldResponse. Invalid parameters passed. p_rsp=%p, pp_pkt=%p", p_rsp, pp_pkt);
- return AVRC_STS_BAD_PARAM;
- }
-
- if (*pp_pkt == NULL)
- {
- if ((*pp_pkt = avrc_bld_init_rsp_buffer(p_rsp)) == NULL)
- {
- AVRC_TRACE_API0("AVRC_BldResponse: Failed to initialize response buffer");
- return AVRC_STS_INTERNAL_ERR;
- }
-#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE))
- if ((*pp_pkt)->layer_specific == AVCT_DATA_BROWSE)
- {
- p = (UINT8 *)((*pp_pkt) + 1);
- peer_mtu = AVCT_GetBrowseMtu(handle) - AVCT_HDR_LEN_SINGLE;
- UINT16_TO_BE_STREAM(p, peer_mtu);
- }
-#endif
- alloc = TRUE;
- }
- status = AVRC_STS_NO_ERROR;
- p_pkt = *pp_pkt;
-
- AVRC_TRACE_API2("AVRC_BldResponse: pdu=%x status=%x", p_rsp->rsp.pdu, p_rsp->rsp.status);
- if (p_rsp->rsp.status != AVRC_STS_NO_ERROR)
- {
- return( avrc_bld_rejected_rsp(&p_rsp->rsp, p_pkt) );
- }
-
- switch (p_rsp->pdu)
- {
- case AVRC_PDU_NEXT_GROUP:
- case AVRC_PDU_PREV_GROUP:
- status = avrc_bld_group_navigation_rsp(p_rsp->pdu, p_pkt);
- break;
-
- case AVRC_PDU_GET_CAPABILITIES:
- status = avrc_bld_get_capability_rsp(&p_rsp->get_caps, p_pkt);
- break;
-
- case AVRC_PDU_LIST_PLAYER_APP_ATTR:
- status = avrc_bld_list_app_settings_attr_rsp(&p_rsp->list_app_attr, p_pkt);
- break;
-
- case AVRC_PDU_LIST_PLAYER_APP_VALUES:
- status = avrc_bld_list_app_settings_values_rsp(&p_rsp->list_app_values, p_pkt);
- break;
-
- case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE:
- status = avrc_bld_get_cur_app_setting_value_rsp(&p_rsp->get_cur_app_val, p_pkt);
- break;
-
- case AVRC_PDU_SET_PLAYER_APP_VALUE:
- status = avrc_bld_set_app_setting_value_rsp(&p_rsp->set_app_val, p_pkt);
- break;
-
- case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT:
- status = avrc_bld_get_app_setting_attr_text_rsp(&p_rsp->get_app_attr_txt, p_pkt);
- break;
-
- case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT:
- status = avrc_bld_get_app_setting_value_text_rsp(&p_rsp->get_app_val_txt, p_pkt);
- break;
-
- case AVRC_PDU_INFORM_DISPLAY_CHARSET:
- status = avrc_bld_inform_charset_rsp(&p_rsp->inform_charset, p_pkt);
- break;
-
- case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT:
- status = avrc_bld_inform_battery_status_rsp(&p_rsp->inform_battery_status, p_pkt);
- break;
-
- case AVRC_PDU_GET_ELEMENT_ATTR:
- status = avrc_bld_get_elem_attrs_rsp(&p_rsp->get_elem_attrs, p_pkt);
- break;
-
- case AVRC_PDU_GET_PLAY_STATUS:
- status = avrc_bld_get_play_status_rsp(&p_rsp->get_play_status, p_pkt);
- break;
-
- case AVRC_PDU_REGISTER_NOTIFICATION:
- status = avrc_bld_notify_rsp(&p_rsp->reg_notif, p_pkt);
- break;
-
- case AVRC_PDU_REQUEST_CONTINUATION_RSP: /* 0x40 */
- status = avrc_bld_next_rsp(&p_rsp->continu, p_pkt);
- break;
-
- case AVRC_PDU_ABORT_CONTINUATION_RSP: /* 0x41 */
- status = avrc_bld_next_rsp(&p_rsp->abort, p_pkt);
- break;
-
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
- case AVRC_PDU_SET_ABSOLUTE_VOLUME: /* 0x50 */
- status = avrc_bld_set_abs_volume_rsp(&p_rsp->volume, p_pkt);
- break;
-
- case AVRC_PDU_SET_ADDRESSED_PLAYER: /* 0x60 */
- status = avrc_bld_set_addr_player_rsp(&p_rsp->addr_player, p_pkt);
- break;
-
- case AVRC_PDU_PLAY_ITEM: /* 0x74 */
- status = avrc_bld_play_item_rsp(&p_rsp->play_item, p_pkt);
- break;
-
- case AVRC_PDU_ADD_TO_NOW_PLAYING: /* 0x90 */
- status = avrc_bld_add_to_now_playing_rsp(&p_rsp->add_to_play, p_pkt);
- break;
-
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- case AVRC_PDU_SET_BROWSED_PLAYER: /* 0x70 */
- status = avrc_bld_set_browsed_player_rsp(&p_rsp->br_player, p_pkt);
- break;
-
- case AVRC_PDU_GET_FOLDER_ITEMS: /* 0x71 */
- status = avrc_bld_get_folder_items_rsp(&p_rsp->get_items, p_pkt);
- break;
-
- case AVRC_PDU_CHANGE_PATH: /* 0x72 */
- status = avrc_bld_change_path_rsp(&p_rsp->chg_path, p_pkt);
- break;
-
- case AVRC_PDU_GET_ITEM_ATTRIBUTES: /* 0x73 */
- status = avrc_bld_get_item_attrs_rsp(&p_rsp->get_attrs, p_pkt);
- break;
-
- case AVRC_PDU_SEARCH: /* 0x80 */
- status = avrc_bld_search_rsp(&p_rsp->search, p_pkt);
- break;
-#endif
-#endif
- }
-
- if (alloc && (status != AVRC_STS_NO_ERROR) )
- {
- GKI_freebuf(p_pkt);
- *pp_pkt = NULL;
- }
- AVRC_TRACE_API1("AVRC_BldResponse: returning %d", status);
- return status;
-}
-
-#endif /* (AVRC_METADATA_INCLUDED == TRUE)*/
-
diff --git a/stack/avrc/avrc_int.h b/stack/avrc/avrc_int.h
index 33e561c..a2a4073 100644
--- a/stack/avrc/avrc_int.h
+++ b/stack/avrc/avrc_int.h
@@ -83,31 +83,10 @@
** Type definitions
*****************************************************************************/
-#if (AVRC_METADATA_INCLUDED == TRUE)
-/* type for Metadata fragmentation control block */
-typedef struct
-{
- BT_HDR *p_fmsg; /* the fragmented message */
- UINT8 frag_pdu; /* the PDU ID for fragmentation */
- BOOLEAN frag_enabled; /* fragmentation flag */
-} tAVRC_FRAG_CB;
-
-/* type for Metadata re-assembly control block */
-typedef struct
-{
- BT_HDR *p_rmsg; /* the received message */
- UINT16 rasm_offset; /* re-assembly flag, the offset of the start fragment */
- UINT8 rasm_pdu; /* the PDU ID for re-assembly */
-} tAVRC_RASM_CB;
-#endif
typedef struct
{
tAVRC_CONN_CB ccb[AVCT_NUM_CONN];
-#if (AVRC_METADATA_INCLUDED == TRUE)
- tAVRC_FRAG_CB fcb[AVCT_NUM_CONN];
- tAVRC_RASM_CB rcb[AVCT_NUM_CONN];
-#endif
tAVRC_FIND_CBACK *p_cback; /* pointer to application callback */
tSDP_DISCOVERY_DB *p_db; /* pointer to discovery database */
UINT16 service_uuid; /* service UUID to search */
diff --git a/stack/avrc/avrc_opt.c b/stack/avrc/avrc_opt.c
index 7711655..8902ac9 100644
--- a/stack/avrc/avrc_opt.c
+++ b/stack/avrc/avrc_opt.c
@@ -40,13 +40,8 @@ static BT_HDR * avrc_vendor_msg(tAVRC_MSG_VENDOR *p_msg)
WC_ASSERT(p_msg != NULL);
-#if AVRC_METADATA_INCLUDED == TRUE
- WC_ASSERT(AVRC_META_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->vendor_len));
- if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_META_CMD_POOL_ID)) != NULL)
-#else
WC_ASSERT(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->vendor_len));
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL)
-#endif
{
p_cmd->offset = AVCT_MSG_OFFSET;
p_data = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
diff --git a/stack/avrc/avrc_pars_ct.c b/stack/avrc/avrc_pars_ct.c
deleted file mode 100644
index 4feb256..0000000
--- a/stack/avrc/avrc_pars_ct.c
+++ /dev/null
@@ -1,663 +0,0 @@
-/*****************************************************************************
-**
-** Name: avrc_pars_ct.c
-**
-** Description:Interface to AVRCP parse message functions for the Control Role
-**
-** Copyright (c) 2008-2008, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "gki.h"
-#include "avrc_api.h"
-#include "avrc_defs.h"
-#include "avrc_int.h"
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-#if (AVRC_METADATA_INCLUDED == TRUE)
-
-/*******************************************************************************
-**
-** Function avrc_pars_vendor_rsp
-**
-** Description This function parses the vendor specific commands defined by
-** Bluetooth SIG
-**
-** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
-** Otherwise, the error code defined by AVRCP 1.4
-**
-*******************************************************************************/
-static tAVRC_STS avrc_pars_vendor_rsp(tAVRC_MSG_VENDOR *p_msg, tAVRC_RESPONSE *p_result, UINT8 *p_buf, UINT16 buf_len)
-{
- tAVRC_STS status = AVRC_STS_NO_ERROR;
- UINT8 *p = p_msg->p_vendor_data;
- UINT16 len;
- UINT8 xx, yy;
- tAVRC_NOTIF_RSP_PARAM *p_param;
- tAVRC_APP_SETTING *p_app_set;
- tAVRC_APP_SETTING_TEXT *p_app_txt;
- tAVRC_ATTR_ENTRY *p_entry;
- UINT32 *p_u32;
- UINT8 *p_u8;
- UINT16 size_needed;
-
- BE_STREAM_TO_UINT8 (p_result->pdu, p);
- p++; /* skip the reserved/packe_type byte */
- BE_STREAM_TO_UINT16 (len, p);
- AVRC_TRACE_DEBUG4("avrc_pars_vendor_rsp() ctype:0x%x pdu:0x%x, len:%d/0x%x", p_msg->hdr.ctype, p_result->pdu, len, len);
- if (p_msg->hdr.ctype == AVRC_RSP_REJ)
- {
- p_result->rsp.status = *p;
- return p_result->rsp.status;
- }
-
- switch (p_result->pdu)
- {
- case AVRC_PDU_GET_CAPABILITIES: /* 0x10 */
- p_result->get_caps.capability_id = *p++;
- if (AVRC_IS_VALID_CAP_ID(p_result->get_caps.capability_id))
- {
- p_result->get_caps.count = *p++;
- if (p_result->get_caps.capability_id == AVRC_CAP_COMPANY_ID)
- {
- p_u32 = p_result->get_caps.param.company_id;
- for (xx=0; xx<p_result->get_caps.count; xx++)
- {
- AVRC_BE_STREAM_TO_CO_ID (p_u32[xx], p);
- }
- }
- else
- {
- p_u8 = p_result->get_caps.param.event_id;
- for (xx=0; xx<p_result->get_caps.count; xx++)
- {
- BE_STREAM_TO_UINT8 (p_u8[xx], p);
- }
- }
- }
- else
- status = AVRC_STS_BAD_PARAM;
- break;
-
- case AVRC_PDU_LIST_PLAYER_APP_ATTR: /* 0x11 */
- BE_STREAM_TO_UINT8 (p_result->list_app_attr.num_attr, p);
- p_u8 = p_result->list_app_attr.attrs;
- for(xx=0, yy=0; xx< p_result->list_app_attr.num_attr; xx++)
- {
- /* only report the valid player app attributes */
- if (AVRC_IsValidPlayerAttr(*p))
- p_u8[yy++] = *p;
- p++;
- }
- p_result->list_app_attr.num_attr = yy;
- break;
-
- case AVRC_PDU_LIST_PLAYER_APP_VALUES: /* 0x12 */
- BE_STREAM_TO_UINT8 (p_result->list_app_values.num_val, p);
- p_u8 = p_result->list_app_values.vals;
- for(xx=0; xx< p_result->list_app_values.num_val; xx++)
- {
- p_u8[xx] = *p++;
- }
- break;
-
- case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE: /* 0x13 */
- BE_STREAM_TO_UINT8 (p_result->get_cur_app_val.num_val, p);
- size_needed = sizeof(tAVRC_APP_SETTING);
- if (p_buf)
- {
- p_result->get_cur_app_val.p_vals = (tAVRC_APP_SETTING *)p_buf;
- p_app_set = p_result->get_cur_app_val.p_vals;
- for(xx=0; ((xx< p_result->get_cur_app_val.num_val) && (buf_len > size_needed)); xx++)
- {
- buf_len -= size_needed;
- BE_STREAM_TO_UINT8 (p_app_set[xx].attr_id, p);
- BE_STREAM_TO_UINT8 (p_app_set[xx].attr_val, p);
- }
- if (xx != p_result->get_cur_app_val.num_val)
- {
- AVRC_TRACE_ERROR2("GET_CUR_PLAYER_APP_VALUE not enough room:%d orig num_val:%d",
- xx, p_result->get_cur_app_val.num_val);
- p_result->get_cur_app_val.num_val = xx;
- }
- }
- else
- {
- AVRC_TRACE_ERROR2("GET_CUR_PLAYER_APP_VALUE not enough room:len: %d needed for struct: %d", buf_len, size_needed);
- status = AVRC_STS_INTERNAL_ERR;
- }
- break;
-
- case AVRC_PDU_SET_PLAYER_APP_VALUE: /* 0x14 */
- case AVRC_PDU_INFORM_DISPLAY_CHARSET: /* 0x17 */
- case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT:/* 0x18 */
- /* no additional parameters */
- if (len != 0)
- status = AVRC_STS_INTERNAL_ERR;
- break;
-
- case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT: /* 0x15 */
- case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT:/* 0x16 */
- BE_STREAM_TO_UINT8 (p_result->get_app_attr_txt.num_attr, p);
- size_needed = sizeof(tAVRC_APP_SETTING_TEXT) * p_result->get_app_attr_txt.num_attr;
- if (p_buf && (buf_len > size_needed))
- {
- p_result->get_app_attr_txt.p_attrs = (tAVRC_APP_SETTING_TEXT *)p_buf;
- p_app_txt = p_result->get_app_attr_txt.p_attrs;
- p_u8 = p_buf + size_needed;
- buf_len -= size_needed;
- for(xx=0; xx< p_result->get_app_attr_txt.num_attr; xx++)
- {
- BE_STREAM_TO_UINT8 (p_app_txt[xx].attr_id, p);
- BE_STREAM_TO_UINT16 (p_app_txt[xx].charset_id, p);
- BE_STREAM_TO_UINT8 (p_app_txt[xx].str_len, p);
- p_app_txt[xx].p_str = p_u8;
- if (buf_len > p_app_txt[xx].str_len)
- {
- BE_STREAM_TO_ARRAY(p, p_u8, p_app_txt[xx].str_len);
- p_u8 += p_app_txt[xx].str_len;
- buf_len -= p_app_txt[xx].str_len;
- }
- else
- {
- AVRC_TRACE_ERROR4("GET_CUR_PLAYER_APP_VALUE not enough room:[%d] len orig/left: %d/%d, orig num_attr:%d",
- xx, p_app_txt[xx].str_len, buf_len, p_result->get_app_attr_txt.num_attr);
- p_app_txt[xx].str_len = (UINT8)buf_len;
- BE_STREAM_TO_ARRAY(p, p_u8, p_app_txt[xx].str_len);
- p_result->get_app_attr_txt.num_attr = xx+1;
- status = AVRC_STS_INTERNAL_ERR;
- break;
- }
- }
- }
- else
- {
- AVRC_TRACE_ERROR2("GET_CUR_PLAYER_APP_VALUE not enough room:len: %d needed for struct: %d", buf_len, size_needed);
- status = AVRC_STS_INTERNAL_ERR;
- }
- break;
-
- case AVRC_PDU_GET_ELEMENT_ATTR: /* 0x20 */
- BE_STREAM_TO_UINT8 (p_result->get_elem_attrs.num_attr, p);
- size_needed = sizeof(tAVRC_ATTR_ENTRY) * p_result->get_elem_attrs.num_attr;
- if (p_buf && (buf_len > size_needed))
- {
- p_result->get_elem_attrs.p_attrs = (tAVRC_ATTR_ENTRY *)p_buf;
- p_entry = p_result->get_elem_attrs.p_attrs;
- p_u8 = p_buf + size_needed;
- buf_len -= size_needed;
- for(xx=0; xx< p_result->get_elem_attrs.num_attr; xx++)
- {
- BE_STREAM_TO_UINT32 (p_entry[xx].attr_id, p);
- BE_STREAM_TO_UINT16 (p_entry[xx].name.charset_id, p);
- BE_STREAM_TO_UINT16 (p_entry[xx].name.str_len, p);
- p_entry[xx].name.p_str = p_u8;
- if (buf_len > p_entry[xx].name.str_len)
- {
- BE_STREAM_TO_ARRAY(p, p_u8, p_entry[xx].name.str_len);
- p_u8 += p_entry[xx].name.str_len;
- buf_len -= p_entry[xx].name.str_len;
- }
- else
- {
- AVRC_TRACE_ERROR4("GET_ELEMENT_ATTR not enough room:[%d] len orig/left: %d/%d, orig num_attr:%d",
- xx, p_entry[xx].name.str_len, buf_len, p_result->get_elem_attrs.num_attr);
- p_entry[xx].name.str_len = buf_len;
- BE_STREAM_TO_ARRAY(p, p_u8, p_entry[xx].name.str_len);
- p_result->get_elem_attrs.num_attr = xx + 1;
- status = AVRC_STS_INTERNAL_ERR;
- break;
- }
- }
- }
- else
- {
- AVRC_TRACE_ERROR2("GET_ELEMENT_ATTR not enough room:len: %d needed for struct: %d", buf_len, size_needed);
- status = AVRC_STS_INTERNAL_ERR;
- }
- break;
-
- case AVRC_PDU_GET_PLAY_STATUS: /* 0x30 */
- BE_STREAM_TO_UINT32 (p_result->get_play_status.song_len, p);
- BE_STREAM_TO_UINT32 (p_result->get_play_status.song_pos, p);
- BE_STREAM_TO_UINT8 (p_result->get_play_status.play_status, p);
- if (len != 9)
- status = AVRC_STS_INTERNAL_ERR;
- break;
-
- case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
- BE_STREAM_TO_UINT8 (p_result->reg_notif.event_id, p);
- p_param = &p_result->reg_notif.param;
- switch (p_result->reg_notif.event_id)
- {
- case AVRC_EVT_PLAY_STATUS_CHANGE: /* 0x01 */
- BE_STREAM_TO_UINT8 (p_param->play_status, p);
- if ((p_param->play_status > AVRC_PLAYSTATE_REV_SEEK) &&
- (p_param->play_status != AVRC_PLAYSTATE_ERROR) )
- {
- status = AVRC_STS_BAD_PARAM;
- }
- break;
-
- case AVRC_EVT_TRACK_CHANGE: /* 0x02 */
- BE_STREAM_TO_ARRAY (p, p_param->track, AVRC_UID_SIZE);
- break;
-
- case AVRC_EVT_TRACK_REACHED_END: /* 0x03 */
- case AVRC_EVT_TRACK_REACHED_START: /* 0x04 */
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
- case AVRC_EVT_NOW_PLAYING_CHANGE: /* 0x09 */
- case AVRC_EVT_AVAL_PLAYERS_CHANGE: /* 0x0a */
-#endif /* (AVRC_ADV_CTRL_INCLUDED == TRUE) */
- /* these events do not have additional parameters */
- break;
-
- case AVRC_EVT_PLAY_POS_CHANGED: /* 0x05 */
- BE_STREAM_TO_UINT32 (p_param->play_pos, p);
- break;
-
- case AVRC_EVT_BATTERY_STATUS_CHANGE:/* 0x06 */
- BE_STREAM_TO_UINT8 (p_param->battery_status, p);
- if (!AVRC_IS_VALID_BATTERY_STATUS(p_param->battery_status))
- {
- status = AVRC_STS_BAD_PARAM;
- }
- break;
-
- case AVRC_EVT_SYSTEM_STATUS_CHANGE: /* 0x07 */
- BE_STREAM_TO_UINT8 (p_param->system_status, p);
- if (!AVRC_IS_VALID_SYSTEM_STATUS(p_param->system_status))
- {
- status = AVRC_STS_BAD_PARAM;
- }
- break;
-
- case AVRC_EVT_APP_SETTING_CHANGE: /* 0x08 */
- BE_STREAM_TO_UINT8 (p_param->player_setting.num_attr, p);
- if (p_param->player_setting.num_attr > AVRC_MAX_APP_SETTINGS)
- p_param->player_setting.num_attr = AVRC_MAX_APP_SETTINGS;
- for (xx=0; xx<p_param->player_setting.num_attr; xx++)
- {
- BE_STREAM_TO_UINT8 (p_param->player_setting.attr_id[xx], p);
- BE_STREAM_TO_UINT8 (p_param->player_setting.attr_value[xx], p);
- if (!avrc_is_valid_player_attrib_value(p_param->player_setting.attr_id[xx], p_param->player_setting.attr_value[xx]))
- {
- status = AVRC_STS_BAD_PARAM;
- break;
- }
- }
- break;
-
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
- case AVRC_EVT_ADDR_PLAYER_CHANGE: /* 0x0b */
- BE_STREAM_TO_UINT16 (p_param->addr_player.player_id, p);
- BE_STREAM_TO_UINT16 (p_param->addr_player.uid_counter, p);
- break;
-
- case AVRC_EVT_UIDS_CHANGE: /* 0x0c */
- BE_STREAM_TO_UINT16 (p_param->uid_counter, p);
- break;
-
- case AVRC_EVT_VOLUME_CHANGE: /* 0x0d */
- BE_STREAM_TO_UINT8 (p_param->volume, p);
- break;
-#endif /* (AVRC_ADV_CTRL_INCLUDED == TRUE) */
-
- default:
- status = AVRC_STS_BAD_PARAM;
- break;
- }
- break;
-
- /* case AVRC_PDU_REQUEST_CONTINUATION_RSP: 0x40 */
- /* case AVRC_PDU_ABORT_CONTINUATION_RSP: 0x41 */
-
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
- case AVRC_PDU_SET_ABSOLUTE_VOLUME: /* 0x50 */
- case AVRC_PDU_SET_ADDRESSED_PLAYER: /* 0x60 */
- case AVRC_PDU_PLAY_ITEM: /* 0x74 */
- case AVRC_PDU_ADD_TO_NOW_PLAYING: /* 0x90 */
- BE_STREAM_TO_UINT8 (p_result->volume.volume, p);
- if (len != 1)
- status = AVRC_STS_INTERNAL_ERR;
- break;
-#endif /* (AVRC_ADV_CTRL_INCLUDED == TRUE) */
-
- default:
- status = AVRC_STS_BAD_CMD;
- break;
- }
-
- return status;
-}
-
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function avrc_pars_browsing_rsp
-**
-** Description This function parses the commands that go through the
-** browsing channel
-**
-** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
-** Otherwise, the error code defined by AVRCP 1.4
-**
-*******************************************************************************/
-static tAVRC_STS avrc_pars_browsing_rsp(tAVRC_MSG_BROWSE *p_msg, tAVRC_RESPONSE *p_result, UINT8 *p_buf, UINT16 buf_len)
-{
- tAVRC_STS status = AVRC_STS_NO_ERROR;
- UINT8 *p = p_msg->p_browse_data;
- UINT16 len;
- int i, count;
- UINT8 *p_left = p_buf;
- tAVRC_ITEM *p_item;
- tAVRC_ITEM_PLAYER *p_player;
- tAVRC_ITEM_FOLDER *p_folder;
- tAVRC_ITEM_MEDIA *p_media;
- tAVRC_ATTR_ENTRY *p_attrs;
- UINT16 item_len;
- UINT8 xx;
- UINT16 size_needed;
-
- p_result->pdu = *p++;
- BE_STREAM_TO_UINT16 (len, p);
- BE_STREAM_TO_UINT8 (status, p);
- AVRC_TRACE_DEBUG4("avrc_pars_browsing_rsp() pdu:0x%x, len:%d/0x%x, status:0x%x", p_result->pdu, len, len, status);
- if (status != AVRC_STS_NO_ERROR)
- return status;
-
- switch (p_result->pdu)
- {
- case AVRC_PDU_SET_BROWSED_PLAYER: /* 0x70 */
- BE_STREAM_TO_UINT16 (p_result->br_player.uid_counter, p);
- BE_STREAM_TO_UINT32 (p_result->br_player.num_items, p);
- BE_STREAM_TO_UINT16 (p_result->br_player.charset_id, p);
- BE_STREAM_TO_UINT8 (p_result->br_player.folder_depth, p);
- p_result->br_player.p_folders = NULL;
- if (p_result->br_player.folder_depth == 0)
- return status;
-
- size_needed = sizeof(tAVRC_NAME) * p_result->br_player.folder_depth;
- if (p_buf && (buf_len > size_needed))
- {
- p_result->br_player.p_folders = (tAVRC_NAME *)p_buf;
- p_left = p_buf + size_needed;
- count = p_result->br_player.folder_depth;
- buf_len -= size_needed;
- for (i=0; i<count; i++)
- {
- p_result->br_player.p_folders[i].p_str = p_left;
- BE_STREAM_TO_UINT16 (p_result->br_player.p_folders[i].str_len, p);
- if (buf_len > p_result->br_player.p_folders[i].str_len)
- {
- BE_STREAM_TO_ARRAY (p, p_result->br_player.p_folders[i].p_str, p_result->br_player.p_folders[i].str_len);
- p_left += p_result->br_player.p_folders[i].str_len;
- buf_len -= p_result->br_player.p_folders[i].str_len;
- }
- else
- {
- AVRC_TRACE_ERROR4("SET_BROWSED_PLAYER not enough room:[%d] len orig/left: %d/%d, orig depth:%d",
- i, p_result->br_player.p_folders[i].str_len, buf_len, p_result->br_player.folder_depth);
- p_result->br_player.p_folders[i].str_len = buf_len;
- BE_STREAM_TO_ARRAY (p, p_result->br_player.p_folders[i].p_str, p_result->br_player.p_folders[i].str_len);
- p_result->br_player.folder_depth = i+1;
- status = AVRC_STS_INTERNAL_ERR;
- break;
- }
- }
- }
- else
- {
- AVRC_TRACE_ERROR2("SET_BROWSED_PLAYER not enough room:len: %d needed for struct: %d", buf_len, size_needed);
- status = AVRC_STS_INTERNAL_ERR;
- }
- break;
-
- case AVRC_PDU_GET_FOLDER_ITEMS: /* 0x71 */
- BE_STREAM_TO_UINT16 (p_result->get_items.uid_counter, p);
- BE_STREAM_TO_UINT16 (p_result->get_items.item_count, p);
- p_result->get_items.p_item_list = NULL;
- if (p_result->get_items.item_count == 0)
- return status;
- size_needed = sizeof(tAVRC_ITEM) * p_result->get_items.item_count;
- if (p_buf && (buf_len > size_needed))
- {
- p_result->get_items.p_item_list = p_item = (tAVRC_ITEM *)p_buf;
- p_left = p_buf + size_needed;
- count = p_result->get_items.item_count;
- buf_len -= size_needed;
- for (i=0; i<count; i++)
- {
- BE_STREAM_TO_UINT8 (p_item[i].item_type, p);
- BE_STREAM_TO_UINT16 (item_len, p);
- AVRC_TRACE_DEBUG3("[%d] type:%d len left:%d", i, p_item[i].item_type, buf_len);
- switch(p_item[i].item_type)
- {
- case AVRC_ITEM_PLAYER:
- p_player = &p_item[i].u.player;
- BE_STREAM_TO_UINT16 (p_player->player_id, p);
- BE_STREAM_TO_UINT8 (p_player->major_type, p);
- BE_STREAM_TO_UINT32 (p_player->sub_type, p);
- BE_STREAM_TO_UINT8 (p_player->play_status, p);
- BE_STREAM_TO_ARRAY (p, p_player->features, AVRC_FEATURE_MASK_SIZE);
- BE_STREAM_TO_UINT16 (p_player->name.charset_id, p);
- BE_STREAM_TO_UINT16 (p_player->name.str_len, p);
- p_player->name.p_str = p_left;
- if (buf_len > p_player->name.str_len)
- {
- p_left += p_player->name.str_len;
- BE_STREAM_TO_ARRAY (p, p_player->name.p_str, p_player->name.str_len);
- buf_len -= p_player->name.str_len;
- }
- else
- {
- AVRC_TRACE_ERROR4("GET_FOLDER_ITEMS player not enough room:[%d] len orig/left: %d/%d, orig item count:%d",
- i, p_player->name.str_len, buf_len, p_result->get_items.item_count);
- p_player->name.str_len = buf_len;
- BE_STREAM_TO_ARRAY (p, p_player->name.p_str, p_player->name.str_len);
- p_result->get_items.item_count = i+1;
- return AVRC_STS_INTERNAL_ERR;
- }
- break;
-
- case AVRC_ITEM_FOLDER:
- p_folder = &p_item[i].u.folder;
- BE_STREAM_TO_ARRAY (p, p_folder->uid, AVRC_UID_SIZE);
- BE_STREAM_TO_UINT8 (p_folder->type, p);
- BE_STREAM_TO_UINT8 (p_folder->playable, p);
- BE_STREAM_TO_UINT16 (p_folder->name.charset_id, p);
- BE_STREAM_TO_UINT16 (p_folder->name.str_len, p);
- p_folder->name.p_str = p_left;
- if (buf_len > p_folder->name.str_len)
- {
- p_left += p_folder->name.str_len;
- BE_STREAM_TO_ARRAY (p, p_folder->name.p_str, p_folder->name.str_len);
- buf_len -= p_folder->name.str_len;
- }
- else
- {
- AVRC_TRACE_ERROR4("GET_FOLDER_ITEMS folder not enough room:[%d] len orig/left: %d/%d, orig item count:%d",
- i, p_folder->name.str_len, buf_len, p_result->get_items.item_count);
- p_folder->name.str_len = buf_len;
- BE_STREAM_TO_ARRAY (p, p_folder->name.p_str, p_folder->name.str_len);
- p_result->get_items.item_count = i+1;
- return AVRC_STS_INTERNAL_ERR;
- }
- break;
-
- case AVRC_ITEM_MEDIA:
- p_media = &p_item[i].u.media;
- BE_STREAM_TO_ARRAY (p, p_media->uid, AVRC_UID_SIZE);
- BE_STREAM_TO_UINT8 (p_media->type, p);
- BE_STREAM_TO_UINT16 (p_media->name.charset_id, p);
- BE_STREAM_TO_UINT16 (p_media->name.str_len, p);
- p_media->name.p_str = p_left;
- if (buf_len < p_media->name.str_len)
- {
- AVRC_TRACE_ERROR4("GET_FOLDER_ITEMS media not enough room:[%d] len orig/left: %d/%d, orig item count:%d",
- i, p_media->name.str_len, buf_len, p_result->get_items.item_count);
- p_media->name.str_len = buf_len;
- BE_STREAM_TO_ARRAY (p, p_media->name.p_str, p_media->name.str_len);
- p_media->attr_count = 0;
- p_media->p_attr_list = NULL;
- p_result->get_items.item_count = i+1;
- return AVRC_STS_INTERNAL_ERR;
- }
- p_left += p_media->name.str_len;
- buf_len -= p_media->name.str_len;
- BE_STREAM_TO_ARRAY (p, p_media->name.p_str, p_media->name.str_len);
- BE_STREAM_TO_UINT8 (p_media->attr_count, p);
- size_needed = sizeof(tAVRC_ATTR_ENTRY) * p_media->attr_count;
- if (buf_len < size_needed)
- {
- AVRC_TRACE_ERROR4("GET_FOLDER_ITEMS media not enough room:[%d] attr_count orig/left: %d/%d, orig item count:%d",
- i, p_media->attr_count, buf_len, p_result->get_items.item_count);
- p_media->name.str_len = buf_len;
- BE_STREAM_TO_ARRAY (p, p_media->name.p_str, p_media->name.str_len);
- p_media->attr_count = 0;
- p_media->p_attr_list = NULL;
- p_result->get_items.item_count = i+1;
- return AVRC_STS_INTERNAL_ERR;
- }
- p_media->p_attr_list = p_attrs = (tAVRC_ATTR_ENTRY *)p_left;
- p_left += size_needed;
- buf_len -= size_needed;
- for (xx= 0; xx<p_media->attr_count; xx++)
- {
- BE_STREAM_TO_UINT32 (p_attrs[xx].attr_id, p);
- BE_STREAM_TO_UINT16 (p_attrs[xx].name.charset_id, p);
- BE_STREAM_TO_UINT16 (p_attrs[xx].name.str_len, p);
- p_attrs[xx].name.p_str = p_left;
- if (buf_len > p_attrs[xx].name.str_len)
- {
- p_left += p_attrs[xx].name.str_len;
- BE_STREAM_TO_ARRAY (p, p_attrs[xx].name.p_str, p_attrs[xx].name.str_len);
- buf_len -= p_attrs[xx].name.str_len;
- }
- else
- {
- AVRC_TRACE_ERROR4("GET_FOLDER_ITEMS media not enough room:[%d] attr name len orig/left: %d/%d, orig item count:%d",
- i, p_attrs[xx].name.str_len, buf_len, p_result->get_items.item_count);
- p_attrs[xx].name.str_len = buf_len;
- BE_STREAM_TO_ARRAY (p, p_attrs[xx].name.p_str, p_attrs[xx].name.str_len);
- p_media->attr_count = xx+1;
- p_result->get_items.item_count = i+1;
- return AVRC_STS_INTERNAL_ERR;
- }
- }
- break;
- }
- }
- }
- break;
-
- case AVRC_PDU_CHANGE_PATH: /* 0x72 */
- BE_STREAM_TO_UINT32 (p_result->chg_path.num_items, p);
- break;
-
- case AVRC_PDU_GET_ITEM_ATTRIBUTES: /* 0x73 */
- BE_STREAM_TO_UINT8 (p_result->get_attrs.attr_count, p);
- p_result->get_attrs.p_attr_list = p_attrs = NULL;
- if (p_result->get_attrs.attr_count == 0)
- return status;
-
- size_needed = sizeof(tAVRC_ATTR_ENTRY) * p_result->get_attrs.attr_count;
- if (p_buf && (buf_len > size_needed))
- {
- p_result->get_attrs.p_attr_list = p_attrs = (tAVRC_ATTR_ENTRY *)p_left;
- p_left += size_needed;
- buf_len -= size_needed;
- for (xx= 0; xx<p_result->get_attrs.attr_count; xx++)
- {
- BE_STREAM_TO_UINT32 (p_attrs[xx].attr_id, p);
- BE_STREAM_TO_UINT16 (p_attrs[xx].name.charset_id, p);
- BE_STREAM_TO_UINT16 (p_attrs[xx].name.str_len, p);
- p_attrs[xx].name.p_str = p_left;
- if (buf_len > p_attrs[xx].name.str_len)
- {
- p_left += p_attrs[xx].name.str_len;
- BE_STREAM_TO_ARRAY (p, p_attrs[xx].name.p_str, p_attrs[xx].name.str_len);
- buf_len -= p_attrs[xx].name.str_len;
- }
- else
- {
- AVRC_TRACE_ERROR4("GET_ITEM_ATTRIBUTES not enough room:[%d] len orig/left: %d/%d, orig attr_count:%d",
- xx, p_attrs[xx].name.str_len, buf_len, p_result->get_attrs.attr_count);
- p_attrs[xx].name.str_len = buf_len;
- BE_STREAM_TO_ARRAY (p, p_attrs[xx].name.p_str, p_attrs[xx].name.str_len);
- p_result->get_attrs.attr_count = xx+1;
- status = AVRC_STS_INTERNAL_ERR;
- break;
- }
- }
- }
- break;
-
- case AVRC_PDU_SEARCH: /* 0x80 */
- BE_STREAM_TO_UINT16 (p_result->search.uid_counter, p);
- BE_STREAM_TO_UINT32 (p_result->search.num_items, p);
- break;
-
- default:
- status = AVRC_STS_BAD_CMD;
- break;
- }
-
- return status;
-}
-#endif /* (AVCT_BROWSE_INCLUDED == TRUE)*/
-
-/*******************************************************************************
-**
-** Function AVRC_ParsResponse
-**
-** Description This function is a superset of AVRC_ParsMetadata to parse the response.
-**
-** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
-** Otherwise, the error code defined by AVRCP 1.4
-**
-*******************************************************************************/
-tAVRC_STS AVRC_ParsResponse (tAVRC_MSG *p_msg, tAVRC_RESPONSE *p_result, UINT8 *p_buf, UINT16 buf_len)
-{
- tAVRC_STS status = AVRC_STS_INTERNAL_ERR;
- UINT16 id;
-
- if (p_msg && p_result)
- {
- switch (p_msg->hdr.opcode)
- {
- case AVRC_OP_VENDOR: /* 0x00 Vendor-dependent commands */
- status = avrc_pars_vendor_rsp(&p_msg->vendor, p_result, p_buf, buf_len);
- break;
-
- case AVRC_OP_PASS_THRU: /* 0x7C panel subunit opcode */
- status = avrc_pars_pass_thru(&p_msg->pass, &id);
- if (status == AVRC_STS_NO_ERROR)
- {
- p_result->pdu = (UINT8)id;
- }
- break;
-
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- case AVRC_OP_BROWSE:
- status = avrc_pars_browsing_rsp(&p_msg->browse, p_result, p_buf, buf_len);
- break;
-#endif /* (AVCT_BROWSE_INCLUDED == TRUE) */
-
- default:
- AVRC_TRACE_ERROR1("AVRC_ParsCommand() unknown opcode:0x%x", p_msg->hdr.opcode);
- break;
- }
- p_result->rsp.opcode = p_msg->hdr.opcode;
- p_result->rsp.status = status;
- }
- return status;
-}
-
-
-#endif /* (AVRC_METADATA_INCLUDED == TRUE) */
diff --git a/stack/avrc/avrc_pars_tg.c b/stack/avrc/avrc_pars_tg.c
deleted file mode 100644
index 8237655..0000000
--- a/stack/avrc/avrc_pars_tg.c
+++ /dev/null
@@ -1,452 +0,0 @@
-/*****************************************************************************
-**
-** Name: avrc_pars_tg.c
-**
-** Description:Interface to AVRCP parse message functions for the Target Role
-**
-** Copyright (c) 2008-2008, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "gki.h"
-#include "avrc_api.h"
-#include "avrc_defs.h"
-#include "avrc_int.h"
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-#if (AVRC_METADATA_INCLUDED == TRUE)
-
-/*******************************************************************************
-**
-** Function avrc_pars_vendor_cmd
-**
-** Description This function parses the vendor specific commands defined by
-** Bluetooth SIG
-**
-** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
-** Otherwise, the error code defined by AVRCP 1.4
-**
-*******************************************************************************/
-static tAVRC_STS avrc_pars_vendor_cmd(tAVRC_MSG_VENDOR *p_msg, tAVRC_COMMAND *p_result, UINT8 *p_buf, UINT16 buf_len)
-{
- tAVRC_STS status = AVRC_STS_NO_ERROR;
- UINT8 *p = p_msg->p_vendor_data;
- UINT16 len;
- UINT8 xx, yy;
- UINT8 *p_u8;
- UINT16 *p_u16;
- UINT32 u32, u32_2, *p_u32;
- tAVRC_APP_SETTING *p_app_set;
- UINT16 size_needed;
-
- p_result->pdu = *p++;
- AVRC_TRACE_DEBUG1("avrc_pars_vendor_cmd() pdu:0x%x", p_result->pdu);
- if (!AVRC_IsValidAvcType (p_result->pdu, p_msg->hdr.ctype))
- {
- AVRC_TRACE_DEBUG0("avrc_pars_vendor_cmd() detects wrong AV/C type!");
- status = AVRC_STS_BAD_CMD;
- }
-
- p++; /* skip the reserved byte */
- BE_STREAM_TO_UINT16 (len, p);
- if ((len+4) != (p_msg->vendor_len))
- {
- status = AVRC_STS_INTERNAL_ERR;
- }
-
- if (status != AVRC_STS_NO_ERROR)
- return status;
-
- switch (p_result->pdu)
- {
- case AVRC_PDU_GET_CAPABILITIES: /* 0x10 */
- p_result->get_caps.capability_id = *p++;
- if (!AVRC_IS_VALID_CAP_ID(p_result->get_caps.capability_id))
- status = AVRC_STS_BAD_PARAM;
- else if (len != 1)
- status = AVRC_STS_INTERNAL_ERR;
- break;
-
- case AVRC_PDU_LIST_PLAYER_APP_ATTR: /* 0x11 */
- /* no additional parameters */
- if (len != 0)
- status = AVRC_STS_INTERNAL_ERR;
- break;
-
- case AVRC_PDU_LIST_PLAYER_APP_VALUES: /* 0x12 */
- p_result->list_app_values.attr_id = *p++;
- if (!AVRC_IS_VALID_ATTRIBUTE(p_result->list_app_values.attr_id))
- status = AVRC_STS_BAD_PARAM;
- else if (len != 1)
- status = AVRC_STS_INTERNAL_ERR;
- break;
-
- case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE: /* 0x13 */
- case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT: /* 0x15 */
- BE_STREAM_TO_UINT8 (p_result->get_cur_app_val.num_attr, p);
- if (len != (p_result->get_cur_app_val.num_attr+1))
- {
- status = AVRC_STS_INTERNAL_ERR;
- break;
- }
- p_u8 = p_result->get_cur_app_val.attrs;
- for (xx=0, yy=0; xx< p_result->get_cur_app_val.num_attr; xx++)
- {
- /* only report the valid player app attributes */
- if (AVRC_IsValidPlayerAttr(*p))
- p_u8[yy++] = *p;
- p++;
- }
- p_result->get_cur_app_val.num_attr = yy;
- if (yy == 0)
- {
- status = AVRC_STS_BAD_PARAM;
- }
- break;
-
- case AVRC_PDU_SET_PLAYER_APP_VALUE: /* 0x14 */
- BE_STREAM_TO_UINT8 (p_result->set_app_val.num_val, p);
- size_needed = sizeof(tAVRC_APP_SETTING);
- if (p_buf && (len == ((p_result->set_app_val.num_val<<1) + 1)))
- {
- p_result->set_app_val.p_vals = (tAVRC_APP_SETTING *)p_buf;
- p_app_set = p_result->set_app_val.p_vals;
- for (xx=0; ((xx< p_result->set_app_val.num_val) && (buf_len > size_needed)); xx++)
- {
- p_app_set[xx].attr_id = *p++;
- p_app_set[xx].attr_val = *p++;
- if (!avrc_is_valid_player_attrib_value(p_app_set[xx].attr_id, p_app_set[xx].attr_val))
- status = AVRC_STS_BAD_PARAM;
- }
- if (xx != p_result->set_app_val.num_val)
- {
- AVRC_TRACE_ERROR2("AVRC_PDU_SET_PLAYER_APP_VALUE not enough room:%d orig num_val:%d",
- xx, p_result->set_app_val.num_val);
- p_result->set_app_val.num_val = xx;
- }
- }
- else
- {
- AVRC_TRACE_ERROR0("AVRC_PDU_SET_PLAYER_APP_VALUE NULL decode buffer or bad len");
- status = AVRC_STS_INTERNAL_ERR;
- }
- break;
-
- case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT:/* 0x16 */
- if (len < 3)
- status = AVRC_STS_INTERNAL_ERR;
- else
- {
- BE_STREAM_TO_UINT8 (p_result->get_app_val_txt.attr_id, p);
- if (!AVRC_IS_VALID_ATTRIBUTE(p_result->get_app_val_txt.attr_id))
- status = AVRC_STS_BAD_PARAM;
- else
- {
- BE_STREAM_TO_UINT8 (p_result->get_app_val_txt.num_val, p);
- if ( (len - 2/* attr_id & num_val */) != p_result->get_app_val_txt.num_val)
- status = AVRC_STS_INTERNAL_ERR;
- else
- {
- p_u8 = p_result->get_app_val_txt.vals;
- for (xx=0; xx< p_result->get_app_val_txt.num_val; xx++)
- {
- p_u8[xx] = *p++;
- if (!avrc_is_valid_player_attrib_value(p_result->get_app_val_txt.attr_id, p_u8[xx]))
- {
- status = AVRC_STS_BAD_PARAM;
- break;
- }
- }
- }
- }
- }
- break;
-
- case AVRC_PDU_INFORM_DISPLAY_CHARSET: /* 0x17 */
- if (len < 3)
- status = AVRC_STS_INTERNAL_ERR;
- else
- {
- BE_STREAM_TO_UINT8 (p_result->inform_charset.num_id, p);
- if ( (len - 1/* num_id */) != p_result->inform_charset.num_id * 2)
- status = AVRC_STS_INTERNAL_ERR;
- else
- {
- p_u16 = p_result->inform_charset.charsets;
- if (p_result->inform_charset.num_id > AVRC_MAX_CHARSET_SIZE)
- p_result->inform_charset.num_id = AVRC_MAX_CHARSET_SIZE;
- for (xx=0; xx< p_result->inform_charset.num_id; xx++)
- {
- BE_STREAM_TO_UINT16 (p_u16[xx], p);
- }
- }
- }
- break;
-
- case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT:/* 0x18 */
- if (len != 1)
- status = AVRC_STS_INTERNAL_ERR;
- else
- {
- p_result->inform_battery_status.battery_status = *p++;
- if (!AVRC_IS_VALID_BATTERY_STATUS(p_result->inform_battery_status.battery_status))
- status = AVRC_STS_BAD_PARAM;
- }
- break;
-
- case AVRC_PDU_GET_ELEMENT_ATTR: /* 0x20 */
- if (len < 9) /* UID/8 and num_attr/1 */
- status = AVRC_STS_INTERNAL_ERR;
- else
- {
- BE_STREAM_TO_UINT32 (u32, p);
- BE_STREAM_TO_UINT32 (u32_2, p);
- if (u32== 0 && u32_2 == 0)
- {
- BE_STREAM_TO_UINT8 (p_result->get_elem_attrs.num_attr, p);
- if ( (len - 9/* UID/8 and num_attr/1 */) != (p_result->get_elem_attrs.num_attr * 4))
- status = AVRC_STS_INTERNAL_ERR;
- else
- {
- p_u32 = p_result->get_elem_attrs.attrs;
- if (p_result->get_elem_attrs.num_attr > AVRC_MAX_ELEM_ATTR_SIZE)
- p_result->get_elem_attrs.num_attr = AVRC_MAX_ELEM_ATTR_SIZE;
- for (xx=0; xx< p_result->get_elem_attrs.num_attr; xx++)
- {
- BE_STREAM_TO_UINT32 (p_u32[xx], p);
- }
- }
- }
- else
- status = AVRC_STS_NOT_FOUND;
- }
- break;
-
- case AVRC_PDU_GET_PLAY_STATUS: /* 0x30 */
- /* no additional parameters */
- if (len != 0)
- status = AVRC_STS_INTERNAL_ERR;
- break;
-
- case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
- if (len != 5)
- status = AVRC_STS_INTERNAL_ERR;
- BE_STREAM_TO_UINT8 (p_result->reg_notif.event_id, p);
- BE_STREAM_TO_UINT32 (p_result->reg_notif.param, p);
- break;
-
- /* case AVRC_PDU_REQUEST_CONTINUATION_RSP: 0x40 */
- /* case AVRC_PDU_ABORT_CONTINUATION_RSP: 0x41 */
-
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
- case AVRC_PDU_SET_ABSOLUTE_VOLUME: /* 0x50 */
- if (len != 1)
- status = AVRC_STS_INTERNAL_ERR;
- p_result->volume.volume = *p++;
- break;
-
- case AVRC_PDU_SET_ADDRESSED_PLAYER: /* 0x60 */
- if (len != 2)
- status = AVRC_STS_INTERNAL_ERR;
- BE_STREAM_TO_UINT16 (p_result->addr_player.player_id, p);
- break;
-
- case AVRC_PDU_PLAY_ITEM: /* 0x74 */
- case AVRC_PDU_ADD_TO_NOW_PLAYING: /* 0x90 */
- if (len != (AVRC_UID_SIZE + 3))
- status = AVRC_STS_INTERNAL_ERR;
- BE_STREAM_TO_UINT8 (p_result->play_item.scope, p);
- if (p_result->play_item.scope > AVRC_SCOPE_NOW_PLAYING)
- {
- status = AVRC_STS_BAD_SCOPE;
- }
- BE_STREAM_TO_ARRAY (p, p_result->play_item.uid, AVRC_UID_SIZE);
- BE_STREAM_TO_UINT16 (p_result->play_item.uid_counter, p);
- break;
-#endif /* (AVRC_ADV_CTRL_INCLUDED == TRUE) */
-
- default:
- status = AVRC_STS_BAD_CMD;
- break;
- }
-
- return status;
-}
-
-#if (AVCT_BROWSE_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function avrc_pars_browsing
-**
-** Description This function parses the commands that go through the
-** browsing channel
-**
-** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
-** Otherwise, the error code defined by AVRCP+1
-**
-*******************************************************************************/
-static tAVRC_STS avrc_pars_browsing_cmd(tAVRC_MSG_BROWSE *p_msg, tAVRC_COMMAND *p_result, UINT8 *p_buf, UINT16 buf_len)
-{
- tAVRC_STS status = AVRC_STS_NO_ERROR;
- UINT8 *p = p_msg->p_browse_data;
- UINT16 len;
- int i, count;
-
- p_result->pdu = *p++;
- AVRC_TRACE_DEBUG1("avrc_pars_browsing_cmd() pdu:0x%x", p_result->pdu);
- BE_STREAM_TO_UINT16 (len, p);
- switch (p_result->pdu)
- {
- case AVRC_PDU_SET_BROWSED_PLAYER: /* 0x70 */
- BE_STREAM_TO_UINT16 (p_result->br_player.player_id, p);
- break;
-
- case AVRC_PDU_GET_FOLDER_ITEMS: /* 0x71 */
- BE_STREAM_TO_UINT8 (p_result->get_items.scope, p);
- if (p_result->get_items.scope > AVRC_SCOPE_NOW_PLAYING)
- {
- status = AVRC_STS_BAD_SCOPE;
- }
- BE_STREAM_TO_UINT32 (p_result->get_items.start_item, p);
- BE_STREAM_TO_UINT32 (p_result->get_items.end_item, p);
- if (p_result->get_items.start_item > p_result->get_items.end_item)
- {
- status = AVRC_STS_BAD_RANGE;
- }
- BE_STREAM_TO_UINT8 (p_result->get_items.attr_count, p);
- p_result->get_items.p_attr_list = NULL;
- if (p_result->get_items.attr_count && p_buf &&
- (p_result->get_items.attr_count != AVRC_FOLDER_ITEM_COUNT_NONE))
- {
- p_result->get_items.p_attr_list = (UINT32 *)p_buf;
- count = p_result->get_items.attr_count;
- if (buf_len < (count<<2))
- p_result->get_items.attr_count = count = (buf_len >> 2);
- for (i=0; i<count; i++)
- {
- BE_STREAM_TO_UINT32 (p_result->get_items.p_attr_list[i], p);
- }
- }
- break;
-
- case AVRC_PDU_CHANGE_PATH: /* 0x72 */
- BE_STREAM_TO_UINT16 (p_result->chg_path.uid_counter, p);
- BE_STREAM_TO_UINT8 (p_result->chg_path.direction, p);
- if (p_result->chg_path.direction != AVRC_DIR_UP && p_result->chg_path.direction != AVRC_DIR_DOWN)
- {
- status = AVRC_STS_BAD_DIR;
- }
- BE_STREAM_TO_ARRAY (p, p_result->chg_path.folder_uid, AVRC_UID_SIZE);
- break;
-
- case AVRC_PDU_GET_ITEM_ATTRIBUTES: /* 0x73 */
- BE_STREAM_TO_UINT8 (p_result->get_attrs.scope, p);
- if (p_result->get_attrs.scope > AVRC_SCOPE_NOW_PLAYING)
- {
- status = AVRC_STS_BAD_SCOPE;
- break;
- }
- BE_STREAM_TO_ARRAY (p, p_result->get_attrs.uid, AVRC_UID_SIZE);
- BE_STREAM_TO_UINT16 (p_result->get_attrs.uid_counter, p);
- BE_STREAM_TO_UINT8 (p_result->get_attrs.attr_count, p);
- p_result->get_attrs.p_attr_list = NULL;
- if (p_result->get_attrs.attr_count && p_buf)
- {
- p_result->get_attrs.p_attr_list = (UINT32 *)p_buf;
- count = p_result->get_attrs.attr_count;
- if (buf_len < (count<<2))
- p_result->get_attrs.attr_count = count = (buf_len >> 2);
- for (i=0, count=0; i<p_result->get_attrs.attr_count; i++)
- {
- BE_STREAM_TO_UINT32 (p_result->get_attrs.p_attr_list[count], p);
- if (AVRC_IS_VALID_MEDIA_ATTRIBUTE(p_result->get_attrs.p_attr_list[count]))
- {
- count++;
- }
- }
-
- if (p_result->get_attrs.attr_count != count && count == 0)
- status = AVRC_STS_BAD_PARAM;
- else
- p_result->get_attrs.attr_count = count;
- }
- break;
-
- case AVRC_PDU_SEARCH: /* 0x80 */
- BE_STREAM_TO_UINT16 (p_result->search.string.charset_id, p);
- BE_STREAM_TO_UINT16 (p_result->search.string.str_len, p);
- p_result->search.string.p_str = p_buf;
- if (p_buf)
- {
- if (buf_len > p_result->search.string.str_len)
- buf_len = p_result->search.string.str_len;
- BE_STREAM_TO_ARRAY (p, p_buf, p_result->search.string.str_len);
- }
- else
- {
- status = AVRC_STS_INTERNAL_ERR;
- }
- break;
-
- default:
- status = AVRC_STS_BAD_CMD;
- break;
- }
- return status;
-}
-#endif /* AVCT_BROWSE_INCLUDED == TRUE*/
-
-/*******************************************************************************
-**
-** Function AVRC_ParsCommand
-**
-** Description This function is a superset of AVRC_ParsMetadata to parse the command.
-**
-** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
-** Otherwise, the error code defined by AVRCP 1.4
-**
-*******************************************************************************/
-tAVRC_STS AVRC_ParsCommand (tAVRC_MSG *p_msg, tAVRC_COMMAND *p_result, UINT8 *p_buf, UINT16 buf_len)
-{
- tAVRC_STS status = AVRC_STS_INTERNAL_ERR;
- UINT16 id;
-
- if (p_msg && p_result)
- {
- switch (p_msg->hdr.opcode)
- {
- case AVRC_OP_VENDOR: /* 0x00 Vendor-dependent commands */
- status = avrc_pars_vendor_cmd(&p_msg->vendor, p_result, p_buf, buf_len);
- break;
-
- case AVRC_OP_PASS_THRU: /* 0x7C panel subunit opcode */
- status = avrc_pars_pass_thru(&p_msg->pass, &id);
- if (status == AVRC_STS_NO_ERROR)
- {
- p_result->pdu = (UINT8)id;
- }
- break;
-
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- case AVRC_OP_BROWSE:
- status = avrc_pars_browsing_cmd(&p_msg->browse, p_result, p_buf, buf_len);
- break;
-#endif /*(AVCT_BROWSE_INCLUDED == TRUE)*/
-
- default:
- AVRC_TRACE_ERROR1("AVRC_ParsCommand() unknown opcode:0x%x", p_msg->hdr.opcode);
- break;
- }
- p_result->cmd.opcode = p_msg->hdr.opcode;
- p_result->cmd.status = status;
- }
- AVRC_TRACE_DEBUG1("AVRC_ParsCommand() return status:0x%x", status);
- return status;
-}
-
-#endif /* (AVRC_METADATA_INCLUDED == TRUE) */
-
diff --git a/stack/avrc/avrc_sdp.c b/stack/avrc/avrc_sdp.c
index ad2024e..c9ad935 100644
--- a/stack/avrc/avrc_sdp.c
+++ b/stack/avrc/avrc_sdp.c
@@ -25,26 +25,9 @@ tAVRC_CB avrc_cb;
const tSDP_PROTOCOL_ELEM avrc_proto_list [] =
{
{UUID_PROTOCOL_L2CAP, 1, {AVCT_PSM, 0} },
-#if AVRC_ADV_CTRL_INCLUDED == TRUE
- {UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_3, 0} }
-#else
-#if AVRC_METADATA_INCLUDED == TRUE
- {UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_2, 0} }
-#else
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_0, 0} }
-#endif
-#endif
};
-#if AVRC_ADV_CTRL_INCLUDED == TRUE
-const tSDP_PROTO_LIST_ELEM avrc_add_proto_list [] =
-{
- {AVRC_NUM_PROTO_ELEMS,
- {
- {UUID_PROTOCOL_L2CAP, 1, {AVCT_BR_PSM, 0} },
- {UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_3, 0} }}}
-};
-#endif
/******************************************************************************
@@ -210,30 +193,13 @@ UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
/* add service class id list */
class_list[0] = service_uuid;
-#if AVRC_ADV_CTRL_INCLUDED == TRUE
- if( service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL )
- {
- class_list[1] = UUID_SERVCLASS_AV_REM_CTRL_CONTROL;
- count = 2;
- }
-#endif
result &= SDP_AddServiceClassIdList(sdp_handle, count, class_list);
/* add protocol descriptor list */
result &= SDP_AddProtocolList(sdp_handle, AVRC_NUM_PROTO_ELEMS, (tSDP_PROTOCOL_ELEM *)avrc_proto_list);
/* add profile descriptor list */
-#if AVRC_ADV_CTRL_INCLUDED == TRUE
- result &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_AV_REMOTE_CONTROL, AVRC_REV_1_4);
- /* additional protocol list to include browsing channel */
- result &= SDP_AddAdditionProtoLists( sdp_handle, 1, (tSDP_PROTO_LIST_ELEM *)avrc_add_proto_list);
-#else
-#if AVRC_METADATA_INCLUDED == TRUE
- result &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_AV_REMOTE_CONTROL, AVRC_REV_1_3);
-#else
result &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_AV_REMOTE_CONTROL, AVRC_REV_1_0);
-#endif
-#endif
/* add supported categories */
p = temp;
diff --git a/stack/avrc/avrc_utils.c b/stack/avrc/avrc_utils.c
deleted file mode 100644
index b9eef9b..0000000
--- a/stack/avrc/avrc_utils.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*****************************************************************************
-**
-** Name: avrc_utils.c
-**
-** Description: Utility functions to validate AVRC command/response paramaters
-**
-** Copyright (c) 2003-2008, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "gki.h"
-#include "avrc_api.h"
-#include "avrc_int.h"
-
-
-#if (AVRC_METADATA_INCLUDED == TRUE)
-
-/**************************************************************************
-**
-** Function AVRC_IsValidAvcType
-**
-** Description Check if correct AVC type is specified
-**
-** Returns returns TRUE if it is valid
-**
-**
-*******************************************************************************/
-BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type)
-{
- BOOLEAN result=FALSE;
-
- if (avc_type < AVRC_RSP_NOT_IMPL) /* command msg */
- {
- switch (pdu_id)
- {
- case AVRC_PDU_GET_CAPABILITIES: /* 0x10 */
- case AVRC_PDU_LIST_PLAYER_APP_ATTR: /* 0x11 */
- case AVRC_PDU_LIST_PLAYER_APP_VALUES: /* 0x12 */
- case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE: /* 0x13 */
- case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT: /* 0x15 */
- case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT: /* 0x16 */
- case AVRC_PDU_GET_ELEMENT_ATTR: /* 0x20 */
- case AVRC_PDU_GET_PLAY_STATUS: /* 0x30 */
- if (avc_type == AVRC_CMD_STATUS)
- result=TRUE;
- break;
-
- case AVRC_PDU_SET_PLAYER_APP_VALUE: /* 0x14 */
- case AVRC_PDU_INFORM_DISPLAY_CHARSET: /* 0x17 */
- case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT: /* 0x18 */
- case AVRC_PDU_REQUEST_CONTINUATION_RSP: /* 0x40 */
- case AVRC_PDU_ABORT_CONTINUATION_RSP: /* 0x41 */
- if (avc_type == AVRC_CMD_CTRL)
- result=TRUE;
- break;
-
- case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
- if (avc_type == AVRC_CMD_NOTIF)
- result=TRUE;
- break;
-
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
- case AVRC_PDU_SET_ABSOLUTE_VOLUME: /* 0x50 */
- case AVRC_PDU_SET_ADDRESSED_PLAYER: /* 0x60 */
- case AVRC_PDU_PLAY_ITEM: /* 0x74 */
- case AVRC_PDU_ADD_TO_NOW_PLAYING: /* 0x90 */
- if (avc_type == AVRC_CMD_CTRL)
- result=TRUE;
- break;
-#endif
- }
- }
- else /* response msg */
- {
- if (avc_type >= AVRC_RSP_NOT_IMPL &&
- avc_type <= AVRC_RSP_INTERIM )
- result=TRUE;
- }
-
- return result;
-}
-
-/*******************************************************************************
-**
-** Function avrc_is_valid_player_attrib_value
-**
-** Description Check if the given attrib value is valid for its attribute
-**
-**
-** Returns returns TRUE if it is valid
-**
-*******************************************************************************/
-BOOLEAN avrc_is_valid_player_attrib_value(UINT8 attrib, UINT8 value)
-{
- BOOLEAN result=FALSE;
-
- switch(attrib)
- {
- case AVRC_PLAYER_SETTING_EQUALIZER:
- if ((value > 0) &&
- (value <= AVRC_PLAYER_VAL_ON))
- result=TRUE;
- break;
-
- case AVRC_PLAYER_SETTING_REPEAT:
- if ((value > 0) &&
- (value <= AVRC_PLAYER_VAL_GROUP_REPEAT))
- result=TRUE;
- break;
-
- case AVRC_PLAYER_SETTING_SHUFFLE:
- case AVRC_PLAYER_SETTING_SCAN:
- if ((value > 0) &&
- (value <= AVRC_PLAYER_VAL_GROUP_SHUFFLE))
- result=TRUE;
- break;
- }
-
- if (attrib >= AVRC_PLAYER_SETTING_LOW_MENU_EXT &&
- attrib <= AVRC_PLAYER_SETTING_HIGH_MENU_EXT)
- result = TRUE;
-
- if (!result)
- AVRC_TRACE_ERROR2("avrc_is_valid_player_attrib_value() found not matching attrib(x%x)-value(x%x) pair!", attrib, value);
-
- return result;
-}
-
-/*******************************************************************************
-**
-** Function AVRC_IsValidPlayerAttr
-**
-** Description Check if the given attrib value is a valid one
-**
-**
-** Returns returns TRUE if it is valid
-**
-*******************************************************************************/
-BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr)
-{
- BOOLEAN result=FALSE;
-
- if ( (attr >= AVRC_PLAYER_SETTING_EQUALIZER && attr <= AVRC_PLAYER_SETTING_SCAN) ||
- (attr >= AVRC_PLAYER_SETTING_LOW_MENU_EXT && attr <= AVRC_PLAYER_SETTING_HIGH_MENU_EXT) )
- {
- result = TRUE;
- }
-
- return result;
-}
-
-
-
-/*******************************************************************************
-**
-** Function avrc_pars_pass_thru
-**
-** Description This function parses the pass thru commands defined by
-** Bluetooth SIG
-**
-** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
-** Otherwise, the error code defined by AVRCP 1.4
-**
-*******************************************************************************/
-tAVRC_STS avrc_pars_pass_thru(tAVRC_MSG_PASS *p_msg, UINT16 *p_vendor_unique_id)
-{
- UINT8 *p_data;
- UINT32 co_id;
- UINT16 id;
- tAVRC_STS status = AVRC_STS_BAD_CMD;
-
- if (p_msg->op_id == AVRC_ID_VENDOR && p_msg->pass_len == AVRC_PASS_THRU_GROUP_LEN)
- {
- p_data = p_msg->p_pass_data;
- AVRC_BE_STREAM_TO_CO_ID (co_id, p_data);
- if (co_id == AVRC_CO_METADATA)
- {
- BE_STREAM_TO_UINT16 (id, p_data);
- if (AVRC_IS_VALID_GROUP(id))
- {
- *p_vendor_unique_id = id;
- status = AVRC_STS_NO_ERROR;
- }
- }
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function avrc_opcode_from_pdu
-**
-** Description This function returns the opcode of the given pdu
-**
-** Returns AVRC_OP_VENDOR, AVRC_OP_PASS_THRU or AVRC_OP_BROWSE
-**
-*******************************************************************************/
-UINT8 avrc_opcode_from_pdu(UINT8 pdu)
-{
- UINT8 opcode = 0;
-
- switch (pdu)
- {
-#if (AVCT_BROWSE_INCLUDED == TRUE)
- case AVRC_PDU_SET_BROWSED_PLAYER:
- case AVRC_PDU_GET_FOLDER_ITEMS:
- case AVRC_PDU_CHANGE_PATH:
- case AVRC_PDU_GET_ITEM_ATTRIBUTES:
- case AVRC_PDU_SEARCH:
- case AVRC_PDU_GENERAL_REJECT:
- opcode = AVRC_OP_BROWSE;
- break;
-#endif /* AVCT_BROWSE_INCLUDED */
-
- case AVRC_PDU_NEXT_GROUP:
- case AVRC_PDU_PREV_GROUP: /* pass thru */
- opcode = AVRC_OP_PASS_THRU;
- break;
-
- default: /* vendor */
- opcode = AVRC_OP_VENDOR;
- break;
- }
-
- return opcode;
-}
-
-/*******************************************************************************
-**
-** Function avrc_is_valid_opcode
-**
-** Description This function returns the opcode of the given pdu
-**
-** Returns AVRC_OP_VENDOR, AVRC_OP_PASS_THRU or AVRC_OP_BROWSE
-**
-*******************************************************************************/
-BOOLEAN avrc_is_valid_opcode(UINT8 opcode)
-{
- BOOLEAN is_valid = FALSE;
- switch (opcode)
- {
- case AVRC_OP_BROWSE:
- case AVRC_OP_PASS_THRU:
- case AVRC_OP_VENDOR:
- is_valid = TRUE;
- break;
- }
- return is_valid;
-}
-
-#endif /* (AVRC_METADATA_INCLUDED == TRUE) */
-
diff --git a/stack/dun/dun_api.c b/stack/dun/dun_api.c
deleted file mode 100644
index ce7380e..0000000
--- a/stack/dun/dun_api.c
+++ /dev/null
@@ -1,592 +0,0 @@
-/*****************************************************************************/
-/* */
-/* Name: dun_api.c */
-/* */
-/* Description: This file contains the DUN API routines */
-/* */
-/* */
-/* Copyright (c) 1999-2009, Broadcom Corp., All Rights Reserved. */
-/* Broadcom Bluetooth Core. Proprietary and confidential. */
-/*****************************************************************************/
-
-#include <string.h>
-#include "bt_target.h"
-#include "btm_api.h"
-#include "port_api.h"
-#include "dun_api.h"
-#include "dun_int.h"
-#include "rfcdefs.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-/* Number of attributes in DUN and Fax SDP records. */
-#define DUN_NUM_ATTR_DUN 4
-#define DUN_NUM_ATTR_FAX 7
-
-/* Number of protocol elements in protocol element list. */
-#define DUN_NUM_PROTO_ELEMS 2
-
-
-/* Global DUN/FAX control block structure
-*/
-#if DUN_DYNAMIC_MEMORY == FALSE
-tDUN_CB dun_cb;
-#endif
-
-/******************************************************************************
-**
-** Function dun_sdp_cback
-**
-** Description This is the SDP callback function used by DUN_FindService.
-** This function will be executed by SDP when the service
-** search is completed. If the search is successful, it
-** finds the first record in the database that matches the
-** UUID of the search. Then retrieves various parameters
-** from the record. When it is finished it calls the
-** application callback function.
-**
-** Returns Nothing.
-**
-******************************************************************************/
-static void dun_sdp_cback(UINT16 status)
-{
- tSDP_DISC_REC *p_rec = NULL;
- tSDP_DISC_ATTR *p_attr;
- tSDP_PROTOCOL_ELEM pe;
- UINT8 scn = 0;
- UINT16 name_len = 0;
- char *p_name = "";
- UINT16 options = 0;
- BOOLEAN found = FALSE;
-
- DUN_TRACE_API1("dun_sdp_cback status: %d", status);
-
- if (status == SDP_SUCCESS)
- {
- /* loop through all records we found */
- do
- {
- /* get next record; if none found, we're done */
- if ((p_rec = SDP_FindServiceInDb(dun_cb.find_cb.p_db,
- dun_cb.find_cb.service_uuid, p_rec)) == NULL)
- {
- break;
- }
-
- /* get scn from proto desc list; if not found, go to next record */
- if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
- {
- scn = (UINT8) pe.params[0];
- }
- else
- {
- continue;
- }
-
- /* get service name */
- if ((p_attr = SDP_FindAttributeInRec(p_rec,
- ATTR_ID_SERVICE_NAME)) != NULL)
- {
- p_name = (char *) p_attr->attr_value.v.array;
- name_len = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
- }
-
- /* get audio support */
- if ((p_attr = SDP_FindAttributeInRec(p_rec,
- ATTR_ID_AUDIO_FEEDBACK_SUPPORT)) != NULL)
- {
- options |= (p_attr->attr_value.v.u8) ? DUN_OPTIONS_AUDIO : 0;
- }
-
- /* get fax options */
- if(dun_cb.find_cb.service_uuid == UUID_SERVCLASS_FAX)
- {
- if ((p_attr = SDP_FindAttributeInRec(p_rec,
- ATTR_ID_FAX_CLASS_1_SUPPORT)) != NULL)
- {
- options |= (p_attr->attr_value.v.u8) ? DUN_OPTIONS_CLASS1 : 0;
- }
-
- if ((p_attr = SDP_FindAttributeInRec(p_rec,
- ATTR_ID_FAX_CLASS_2_0_SUPPORT)) != NULL)
- {
- options |= (p_attr->attr_value.v.u8) ? DUN_OPTIONS_CLASS20 : 0;
- }
-
- if ((p_attr = SDP_FindAttributeInRec(p_rec,
- ATTR_ID_FAX_CLASS_2_SUPPORT)) != NULL)
- {
- options |= (p_attr->attr_value.v.u8) ? DUN_OPTIONS_CLASS2 : 0;
- }
- }
-
- /* we've got everything, we're done */
- found = TRUE;
- break;
-
- } while (TRUE);
- }
-
- /* return info from sdp record in app callback function */
- if (dun_cb.find_cb.p_cback != NULL)
- {
- (*dun_cb.find_cb.p_cback)(found, scn, p_name, name_len, options);
- }
-
- return;
-}
-
-/******************************************************************************
-**
-** Function DUN_Listen
-**
-** Description This function opens a DUN or Fax connection in server mode.
-** It configures the security settings for the connection and
-** opens an RFCOMM connection in server mode. It returns
-** the handle for the RFCOMM connection.
-**
-** Input Parameters:
-** service_uuid: Indicates DUN or Fax.
-**
-** p_service_name: A null-terminated character string
-** containing the service name. This is used for security.
-**
-** scn: The server channel number for the RFCOMM
-** connection.
-**
-** mtu: The MTU, or maximum data frame size, for the
-** RFCOMM connection.
-**
-** security_mask: Security configuration. See the BTM API.
-**
-** p_cback: RFCOMM port callback function. See the
-** RFCOMM API.
-**
-** Output Parameters:
-** p_handle: The handle for the RFCOMM connection.
-** This value is used in subsequent calls to the RFCOMM API.
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-UINT8 DUN_Listen(UINT16 service_uuid, char *p_service_name, UINT8 scn, UINT16 mtu,
- UINT8 security_mask, UINT16 *p_handle, tPORT_CALLBACK *p_cback)
-{
- BD_ADDR bd_addr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
- UINT8 status = DUN_SUCCESS;
- UINT8 service_id;
-
- DUN_TRACE_API1("DUN_Listen uuid: %x", service_uuid);
-
- switch (service_uuid)
- {
- case UUID_SERVCLASS_DIALUP_NETWORKING:
- service_id = BTM_SEC_SERVICE_DUN;
- break;
-
- case UUID_SERVCLASS_FAX:
- service_id = BTM_SEC_SERVICE_FAX;
- break;
-
- case UUID_SERVCLASS_SERIAL_PORT:
- default:
- service_id = BTM_SEC_SERVICE_SERIAL_PORT;
- break;
- }
-
- /* set up security */
- if (BTM_SetSecurityLevel(FALSE, (char *) p_service_name, service_id,
- security_mask, BT_PSM_RFCOMM, BTM_SEC_PROTO_RFCOMM, scn) == FALSE)
- {
- status = DUN_FAIL;
- }
-
- /* open rfcomm server connection */
- if (status == DUN_SUCCESS)
- {
- if (RFCOMM_CreateConnection(service_uuid, scn, TRUE, mtu, bd_addr,
- p_handle, p_cback) != PORT_SUCCESS)
- {
- status = DUN_FAIL;
- }
- }
-
- return status;
-}
-
-/******************************************************************************
-**
-** Function DUN_Connect
-**
-** Description This function opens a DUN or Fax client connection.
-** It configures the security settings for the connection
-** and opens an RFCOMM connection in server mode.
-** It returns the handle for the RFCOMM connection.
-**
-** Input Parameters:
-** service_uuid: Indicates DUN or Fax.
-**
-** bd_addr: BD address of the peer device.
-**
-** scn: The server channel number for the RFCOMM
-** connection.
-**
-** mtu: The MTU, or maximum data frame size, for the
-** RFCOMM connection.
-**
-** security_mask: Security configuration. See the BTM API.
-**
-** p_cback: RFCOMM port callback function. See the
-** RFCOMM API.
-**
-** Output Parameters:
-** p_handle: The handle for the RFCOMM connection.
-** This value is used in subsequent calls to the RFCOMM API.
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-UINT8 DUN_Connect(UINT16 service_uuid, BD_ADDR bd_addr, UINT8 scn, UINT16 mtu,
- UINT8 security_mask, UINT16 *p_handle, tPORT_CALLBACK *p_cback)
-{
- char name[] = ""; /* don't bother using a name for security */
- UINT8 status = DUN_SUCCESS;
- UINT8 service_id;
-
- DUN_TRACE_API1("DUN_Connect uuid: %x", service_uuid);
-
- switch (service_uuid)
- {
- case UUID_SERVCLASS_DIALUP_NETWORKING:
- service_id = BTM_SEC_SERVICE_DUN;
- break;
-
- case UUID_SERVCLASS_FAX:
- service_id = BTM_SEC_SERVICE_FAX;
- break;
-
- case UUID_SERVCLASS_SERIAL_PORT:
- default:
- service_id = BTM_SEC_SERVICE_SERIAL_PORT;
- break;
- }
-
- /* set up security */
- if(BTM_SetSecurityLevel(TRUE, name, service_id, security_mask,
- BT_PSM_RFCOMM, BTM_SEC_PROTO_RFCOMM, scn) == FALSE)
- {
- status = DUN_FAIL;
- }
-
- /* open rfcomm client connection */
- if (status == DUN_SUCCESS)
- {
- if (RFCOMM_CreateConnection(service_uuid, scn, FALSE, mtu, bd_addr,
- p_handle, p_cback) != PORT_SUCCESS)
- {
- status = DUN_FAIL;
- }
- }
-
- return status;
-}
-
-
-/******************************************************************************
-**
-** Function DUN_Close
-**
-** Description This function closes a DUN or Fax client connection
-** previously opened with DUN_Connect().
-**
-** Input Parameters:
-** handle: The handle for the RFCOMM connection
-** previously returned by DUN_Connect().
-**
-** Output Parameters:
-** None.
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-UINT8 DUN_Close(UINT16 handle)
-{
- UINT8 status = DUN_SUCCESS;
-
- DUN_TRACE_API0("DUN_close");
-
- if (RFCOMM_RemoveConnection(handle) != PORT_SUCCESS)
- {
- status = DUN_FAIL;
- }
-
- return status;
-}
-
-
-/******************************************************************************
-**
-** Function DUN_Shutdown
-**
-** Description This function closes a DUN or Fax server connection
-** previously opened with DUN_Listen(). It is called if
-** the application wishes to close the DUN or Fax server
-** connection at any time.
-**
-** Input Parameters:
-** service_uuid: Indicates DUN or Fax.
-**
-** handle: The handle for the RFCOMM connection
-** previously returned by DUN_Connect().
-**
-** Output Parameters:
-** None.
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-UINT8 DUN_Shutdown(UINT16 handle)
-{
- UINT8 status = DUN_SUCCESS;
-
- DUN_TRACE_API0("DUN_Shutdown");
-
- /* close rfcomm connection */
- if (RFCOMM_RemoveServer(handle) != PORT_SUCCESS)
- {
- status = DUN_FAIL;
- }
-
- return status;
-}
-
-/******************************************************************************
-**
-** Function DUN_AddRecord
-**
-** Description This function is called by a server application to add
-** DUN or Fax information to an SDP record. Prior to
-** calling this function the application must call
-** SDP_CreateRecord() to create an SDP record.
-**
-** Input Parameters:
-** service_uuid: Indicates DUN or Fax.
-**
-** p_service_name: Pointer to a null-terminated character
-** string containing the service name.
-**
-** scn: The server channel number of the RFCOMM
-** connection.
-**
-** options: Profile support options.
-**
-** sdp_handle: SDP handle returned by SDP_CreateRecord().
-**
-** Output Parameters:
-** None.
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-UINT8 DUN_AddRecord(UINT16 service_uuid, char *p_service_name, UINT8 scn,
- UINT16 options, UINT32 sdp_handle)
-{
- tSDP_PROTOCOL_ELEM proto_elem_list[DUN_NUM_PROTO_ELEMS];
- UINT8 audio;
- UINT8 class1;
- UINT8 class20;
- UINT8 class2;
- UINT16 browse_list[1];
- BOOLEAN result = TRUE;
-
- DUN_TRACE_API1("DUN_AddRecord uuid: %x", service_uuid);
-
- memset((void*) proto_elem_list, 0 , DUN_NUM_PROTO_ELEMS*sizeof(tSDP_PROTOCOL_ELEM));
-
- /* add the protocol element sequence */
- proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP;
- proto_elem_list[0].num_params = 0;
- proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_RFCOMM;
- proto_elem_list[1].num_params = 1;
- proto_elem_list[1].params[0] = scn;
- result &= SDP_AddProtocolList(sdp_handle, DUN_NUM_PROTO_ELEMS, proto_elem_list);
-
- /* add service class id list */
- result &= SDP_AddServiceClassIdList(sdp_handle, 1, &service_uuid);
-
- /* add service name */
- if (p_service_name != NULL)
- {
- result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
- (UINT32)(strlen(p_service_name)+1), (UINT8 *) p_service_name);
- }
-
- /* add audio feedback support */
- if((service_uuid == UUID_SERVCLASS_FAX) ||
- (service_uuid == UUID_SERVCLASS_DIALUP_NETWORKING))
- {
- audio = (options & DUN_OPTIONS_AUDIO) ? TRUE : FALSE;
- result &= SDP_AddAttribute(sdp_handle, ATTR_ID_AUDIO_FEEDBACK_SUPPORT,
- BOOLEAN_DESC_TYPE, 1, &audio);
- }
-
- /* add fax service class support */
- if(service_uuid == UUID_SERVCLASS_FAX)
- {
- class1 = (options & DUN_OPTIONS_CLASS1) ? TRUE : FALSE;
- result &= SDP_AddAttribute(sdp_handle, ATTR_ID_FAX_CLASS_1_SUPPORT,
- BOOLEAN_DESC_TYPE, 1, &class1);
-
- class20 = (options & DUN_OPTIONS_CLASS20) ? TRUE : FALSE;
- result &= SDP_AddAttribute(sdp_handle, ATTR_ID_FAX_CLASS_2_0_SUPPORT,
- BOOLEAN_DESC_TYPE, 1, &class20);
-
- class2 = (options & DUN_OPTIONS_CLASS2) ? TRUE : FALSE;
- result &= SDP_AddAttribute(sdp_handle, ATTR_ID_FAX_CLASS_2_SUPPORT,
- BOOLEAN_DESC_TYPE, 1, &class2);
- }
-
- /* add browse group list */
- browse_list[0] = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
- result &= SDP_AddUuidSequence(sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, browse_list);
-
- /* add profile descriptor list */
- if (service_uuid != UUID_SERVCLASS_SERIAL_PORT) /* BQB fix: BTA DG uses this for SPP */
- result &= SDP_AddProfileDescriptorList(sdp_handle, service_uuid, 0x0100);
-
- return (result ? DUN_SUCCESS : DUN_FAIL);
-}
-
-/******************************************************************************
-**
-** Function DUN_FindService
-**
-** Description This function is called by a client application to
-** perform service discovery and retrieve DUN or Fax SDP
-** record information from a server. Information is
-** returned for the first service record found on the
-** server that matches the service UUID. The callback
-** function will be executed when service discovery is
-** complete. There can only be one outstanding call to
-** DUN_FindService() at a time; the application must wait
-** for the callback before it makes another call to
-** the function.
-**
-** Input Parameters:
-** service_uuid: Indicates DUN or Fax.
-**
-** bd_addr: BD address of the peer device.
-**
-** p_db: Pointer to the discovery database.
-**
-** db_len: Length, in bytes, of the discovery database.
-**
-** p_cback: Pointer to the DUN_FindService()
-** callback function.
-**
-** Output Parameters:
-** None.
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-UINT8 DUN_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
- tSDP_DISCOVERY_DB *p_db, UINT32 db_len, tDUN_FIND_CBACK *p_cback)
-{
- tSDP_UUID uuid_list;
- UINT16 num_attr;
- BOOLEAN result = TRUE;
- UINT16 dun_attr_list[] = {ATTR_ID_SERVICE_CLASS_ID_LIST,
- ATTR_ID_PROTOCOL_DESC_LIST,
- ATTR_ID_SERVICE_NAME,
- ATTR_ID_AUDIO_FEEDBACK_SUPPORT,
- ATTR_ID_FAX_CLASS_1_SUPPORT,
- ATTR_ID_FAX_CLASS_2_0_SUPPORT,
- ATTR_ID_FAX_CLASS_2_SUPPORT};
-
- DUN_TRACE_API1("DUN_FindService uuid: %x", service_uuid);
-
- /* set up discovery database */
- uuid_list.len = LEN_UUID_16;
- uuid_list.uu.uuid16 = service_uuid;
-
- num_attr = (service_uuid == UUID_SERVCLASS_FAX) ?
- DUN_NUM_ATTR_FAX : DUN_NUM_ATTR_DUN;
-
- result = SDP_InitDiscoveryDb(p_db, db_len, 1, &uuid_list, num_attr,
- (UINT16 *) dun_attr_list);
-
- if (result == TRUE)
- {
- /* store service_uuid and discovery db pointer */
- dun_cb.find_cb.p_db = p_db;
- dun_cb.find_cb.service_uuid = service_uuid;
- dun_cb.find_cb.p_cback = p_cback;
-
- /* perform service search */
- result = SDP_ServiceSearchAttributeRequest(bd_addr, p_db, dun_sdp_cback);
- }
-
- return (result ? DUN_SUCCESS : DUN_FAIL);
-}
-
-/*******************************************************************************
-**
-** Function DUN_Init
-**
-** Description This function is called to initialize the control block
-** for this layer. It must be called before accessing any
-** other API functions for this layer. It is typically called
-** once during the start up of the stack.
-**
-** Returns void
-**
-*******************************************************************************/
-void DUN_Init (void)
-{
- /* All fields are cleared; nonzero fields are reinitialized in appropriate function */
- memset(&dun_cb, 0, sizeof(tDUN_CB));
-
-#if defined(DUN_INITIAL_TRACE_LEVEL)
- dun_cb.trace_level = DUN_INITIAL_TRACE_LEVEL;
-#else
- dun_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
-#endif
-}
-
-/******************************************************************************
-**
-** Function DUN_SetTraceLevel
-**
-** Description Sets the trace level for DUN. If 0xff is passed, the
-** current trace level is returned.
-**
-** Input Parameters:
-** new_level: The level to set the DUN tracing to:
-** 0xff-returns the current setting.
-** 0-turns off tracing.
-** >= 1-Errors.
-** >= 2-Warnings.
-** >= 3-APIs.
-** >= 4-Events.
-** >= 5-Debug.
-**
-** Returns The new trace level or current trace level if
-** the input parameter is 0xff.
-**
-******************************************************************************/
-UINT8 DUN_SetTraceLevel (UINT8 new_level)
-{
- if (new_level != 0xFF)
- dun_cb.trace_level = new_level;
-
- return (dun_cb.trace_level);
-}
diff --git a/stack/dun/dun_int.h b/stack/dun/dun_int.h
deleted file mode 100644
index 1e23bdc..0000000
--- a/stack/dun/dun_int.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*****************************************************************************
-**
-** Name: dun_int.h
-**
-** File: dun/fax type definitions
-**
-** Copyright (c) 2002-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef DUN_INT_H
-#define DUN_INT_H
-
-#include "dun_api.h"
-#include "sdp_api.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-/*****************************************************************************
-** DUN Control Blocks
-******************************************************************************/
-/*****************************************************************************
-** Type definitions
-*****************************************************************************/
-/* Control block used by DUN_FindService(). */
-typedef struct
-{
- tDUN_FIND_CBACK *p_cback; /* pointer to application callback */
- tSDP_DISCOVERY_DB *p_db; /* pointer to discovery database */
- UINT16 service_uuid; /* service UUID of search */
-} tDUN_FIND_CB;
-
-typedef struct
-{
- tDUN_FIND_CB find_cb;
- UINT8 trace_level;
-} tDUN_CB;
-
-/*****************************************************************************
-** External Definitions
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/*
-** Define prototypes for global data
-*/
-#if DUN_DYNAMIC_MEMORY == FALSE
-DUN_API extern tDUN_CB dun_cb;
-#else
-DUN_API extern tDUN_CB *dun_cb_ptr;
-#define dun_cb (*dun_cb_ptr)
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DUN_INT_H */
-
diff --git a/stack/goep/goep_fs.c b/stack/goep/goep_fs.c
deleted file mode 100644
index 4373341..0000000
--- a/stack/goep/goep_fs.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*****************************************************************************
-**
-** Name: goep_fs.c
-**
-** File: Implements the Object Interface for GOEP Profiles
-**
-** Copyright (c) 2000-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <string.h>
-#include <ctype.h>
-#include <stdio.h>
-
-#include "gki.h"
-#include "btu.h"
-#include "goep_fs.h"
-
-/*****************************************************************************
-**
-** Function: GOEP_OpenRsp
-**
-** Purpose: Report the status of tGOEP_OPEN_CBACK callback function.
-**
-** Parameters: fd - File handle.
-** status - Status of the operation.
-** file_size - total number of bytes in this file.
-** event_id - event id as given in the tGOEP_OPEN_CBACK function.
-**
-** Returns: void
-**
-*****************************************************************************/
-void GOEP_OpenRsp (tGOEP_FD fd, tGOEP_STATUS status, UINT32 file_size,
- UINT16 event_id)
-{
- tGOEP_OPEN_RSP *p_evt_msg;
- UINT16 size = sizeof(tGOEP_OPEN_RSP);
-
- /* get an GKI buffer and send the event along with the event data to BTU task */
- p_evt_msg = (tGOEP_OPEN_RSP *)GKI_getbuf(size);
- if (p_evt_msg != NULL)
- {
- memset(&p_evt_msg->hdr, 0, sizeof(BT_HDR));
- p_evt_msg->hdr.event = event_id;
- p_evt_msg->fd = fd;
- p_evt_msg->status = status;
- p_evt_msg->file_size = file_size;
-
- GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_evt_msg);
- }
-}
-
-/*****************************************************************************
-**
-** Function: GOEP_ReadRsp
-**
-** Purpose: Report the status of tGOEP_READ_CBACK callback function.
-**
-** Parameters: fd - File handle.
-** status - Status of the operation.
-** bytes_read - total number of bytes read from the file.
-** event_id - event id as given in the tGOEP_READ_CBACK function.
-**
-** Returns: void
-**
-*****************************************************************************/
-void GOEP_ReadRsp (tGOEP_FD fd, tGOEP_STATUS status, UINT16 bytes_read,
- UINT16 event_id)
-{
- tGOEP_READ_RSP *p_evt_msg;
- UINT16 size = sizeof(tGOEP_READ_RSP);
-
- /* get an GKI buffer and send the event along with the event data to BTU task */
- p_evt_msg = (tGOEP_READ_RSP *)GKI_getbuf(size);
- if (p_evt_msg != NULL)
- {
- memset(&p_evt_msg->hdr, 0, sizeof(BT_HDR));
- p_evt_msg->hdr.event = event_id;
- p_evt_msg->fd = fd;
- p_evt_msg->status = status;
- p_evt_msg->bytes_read = bytes_read;
-
- GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_evt_msg);
- }
-}
-
-/*****************************************************************************
-**
-** Function: GOEP_WriteRsp
-**
-** Purpose: Report the status of tGOEP_WRITE_CBACK callback function.
-**
-** Parameters: fd - File handle.
-** status - Status of the operation.
-** event_id - event id as given in the tGOEP_WRITE_CBACK function.
-**
-** Returns: void
-**
-*****************************************************************************/
-void GOEP_WriteRsp (tGOEP_FD fd, tGOEP_STATUS status, UINT16 event_id)
-{
- tGOEP_WRITE_RSP *p_evt_msg;
- UINT16 size = sizeof(tGOEP_WRITE_RSP);
-
- /* get an GKI buffer and send the event along with the event data to BTU task */
- p_evt_msg = (tGOEP_WRITE_RSP *)GKI_getbuf(size);
- if (p_evt_msg != NULL)
- {
- memset(&p_evt_msg->hdr, 0, sizeof(BT_HDR));
- p_evt_msg->hdr.event = event_id;
- p_evt_msg->fd = fd;
- p_evt_msg->status = status;
-
- GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_evt_msg);
- }
-}
-
-/*****************************************************************************
-**
-** Function: GOEP_DirentryRsp
-**
-** Purpose: Report the status of tGOEP_DIRENTRY_CBACK callback function.
-**
-** Parameters: status - GOEP_OK if p_entry points to a valid entry.
-** GOEP_EODIR if no more entries (p_entry is ignored).
-** GOEP_FAIL if any errors have occurred.
-** event_id - event id as given in the tGOEP_DIRENTRY_CBACK function.
-**
-** Returns: void
-**
-*****************************************************************************/
-void GOEP_DirentryRsp (tGOEP_STATUS status, UINT16 event_id)
-{
- tGOEP_DIRENTRY_RSP *p_evt_msg;
- UINT16 size = sizeof(tGOEP_DIRENTRY_RSP);
-
- /* get an GKI buffer and send the event along with the event data to BTU task */
- p_evt_msg = (tGOEP_DIRENTRY_RSP *)GKI_getbuf(size);
- if (p_evt_msg != NULL)
- {
- memset(&p_evt_msg->hdr, 0, sizeof(BT_HDR));
- p_evt_msg->hdr.event = event_id;
- p_evt_msg->status = status;
-
- GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_evt_msg);
- }
-}
-
diff --git a/stack/goep/goep_int.h b/stack/goep/goep_int.h
deleted file mode 100644
index 476d55a..0000000
--- a/stack/goep/goep_int.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*****************************************************************************
-**
-** Name: goep_int.h
-**
-** File: Generic Object Exchange Profile Internal Definitions
-**
-** Copyright (c) 2000-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef GOEP_INT_H
-#define GOEP_INT_H
-
-#include "bt_target.h"
-#include "goep_util.h"
-
-
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-#define GOEP_PROTOCOL_COUNT 3
-
-
-
-/*****************************************************************************
-** Main Control Block Structure
-*****************************************************************************/
-
-typedef struct
-{
- UINT8 trace_level;
-} tGOEP_CB;
-
-/*****************************************************************************
-** Function Prototypes
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if GOEP_DYNAMIC_MEMORY == FALSE
-GOEP_API extern tGOEP_CB goep_cb;
-#else
-GOEP_API extern tGOEP_CB *goep_cb_ptr;
-#define goep_cb (*goep_cb_ptr)
-#endif
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GOEP_INT_H */
diff --git a/stack/goep/goep_trace.c b/stack/goep/goep_trace.c
deleted file mode 100644
index 137f2cd..0000000
--- a/stack/goep/goep_trace.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/******************************************************************************
-**
-** Name: goep_trace.c
-**
-** Description: This file contains the debug display prototypes
-**
-** Copyright (c) 2000-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-******************************************************************************/
-#include "bt_target.h"
-
-#if (defined(GOEP_INCLUDED) && GOEP_INCLUDED == TRUE)
-
-#include "goep_int.h"
-
-#if (defined (BT_USE_TRACES) && BT_USE_TRACES == TRUE)
-
-
-char *GOEP_ErrorName (tGOEP_ERRORS error)
-{
- switch (error)
- {
- case GOEP_SUCCESS: return "GOEP_SUCCESS (0x00)";
- case GOEP_ERROR: return "GOEP_ERROR (0x01)";
- case GOEP_RESOURCES: return "GOEP_RESOURCES (0x02)";
- case GOEP_INVALID_PARAM: return "GOEP_INVALID_PARAM (0x03)";
- default: return "UNKNOWN GOEP ERROR";
- }
-}
-
-/* end if BT_TRACE_VERBOSE */
-#endif
-
-#endif /* GOEP_INCLUDED */
diff --git a/stack/goep/goep_util.c b/stack/goep/goep_util.c
deleted file mode 100644
index 099177a..0000000
--- a/stack/goep/goep_util.c
+++ /dev/null
@@ -1,504 +0,0 @@
-/*****************************************************************************
-**
-** Name: goep_util.c
-**
-** File: Implements the Utility API of the GOEP Profile
-**
-** Copyright (c) 2000-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <string.h>
-
-#include "btm_api.h"
-#include "btu.h" /* BTU_HCI_RCV_MBOX */
-#include "goep_util.h"
-#include "goep_fs.h"
-#include "goep_int.h"
-#include "rfcdefs.h" /* BT_PSM_RFCOMM */
-#include "wcassert.h" /* WC_ASSERT() */
-#include "l2c_api.h" /* WC_ASSERT() */
-
-#if GOEP_DYNAMIC_MEMORY == FALSE
-tGOEP_CB goep_cb;
-#endif
-
-/*******************************************************************************
-**
-** Function GOEP_Init
-**
-** Description GOEP initialization
-**
-** Returns nothing
-**
-*******************************************************************************/
-void GOEP_Init(void)
-{
- memset(&goep_cb, 0, sizeof(tGOEP_CB));
-
-#if defined(GOEP_INITIAL_TRACE_LEVEL)
- goep_cb.trace_level = GOEP_INITIAL_TRACE_LEVEL;
-#else
- goep_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
-#endif
-
-}
-
-
-
-/*****************************************************************************
-**
-** Function: GOEP_SetSecurityLevel()
-**
-** Purpose: Register security & encryption level for GOEP server.
-** This is not to be used for the GOEP command server.
-**
-**
-** Parameters:
-** char *pName service name; Typically GOEP_DEFAULT_SERVICE_NAME
-** Not used if BTM_SEC_SERVICE_NAME_LEN is 0.
-** UINT8 level Security level; The mandatory GOEP security level
-** GOEP_DEFAULT_SECURITY, is or'd in.
-**
-**
-** Returns: (BOOLEAN) TRUE if OK
-** FALSE if a bad parameter
-**
-*****************************************************************************/
-BOOLEAN GOEP_SetSecurityLevel (BOOLEAN bOrig, char *pName, UINT32 service,
- UINT8 level, UINT8 scn)
-{
-#if BTM_SEC_SERVICE_NAME_LEN > 0
- char sec_name[BTM_SEC_SERVICE_NAME_LEN+1];
-#endif
-
- /* Guarantee that there is a name */
- if (!pName)
- {
- pName = "";
- }
-
-#if BTM_SEC_SERVICE_NAME_LEN > 0
- GOEP_TRACE_EVENT4("GOEP: Set Security Mode; name '%s'; service %d; level 0x%02x; scn %d",
- pName, service, level, scn);
-
- /* Guarantee that name is not too long */
- if (strlen (pName) >= BTM_SEC_SERVICE_NAME_LEN)
- {
- BCM_STRNCPY_S(sec_name, sizeof(sec_name), pName, BTM_SEC_SERVICE_NAME_LEN);
- sec_name[BTM_SEC_SERVICE_NAME_LEN] = '\0';
- pName = sec_name;
- }
-#else
- GOEP_TRACE_EVENT3("GOEP: Set Security Mode: service id %d; level 0x%02x; scn %d",
- service, level, scn);
-#endif
-
- /* Register with Security Manager for the specific security level */
- if (!BTM_SetSecurityLevel (bOrig, pName, (UINT8)service, level, BT_PSM_RFCOMM,
- BTM_SEC_PROTO_RFCOMM, scn))
- {
- GOEP_TRACE_WARNING1("GOEP: Security Registration failed for %s", pName);
- return (FALSE);
- }
-
- return (TRUE);
-}
-
-/*****************************************************************************
-**
-** Function: GOEP_SetTraceLevel
-**
-** Purpose: This function changes the trace level
-**
-** Returns: Nothing
-*****************************************************************************/
-void GOEP_SetTraceLevel(UINT8 level)
-{
- goep_cb.trace_level = level;
-}
-
-/*******************************************************************************
-**
-** Function GOEP_FreeBuf
-**
-** Description free memory for specified packet
-**
-** Returns void
-**
-*******************************************************************************/
-void GOEP_FreeBuf (void **p_buf)
-{
- if (p_buf && *p_buf)
- {
- GKI_freebuf(*p_buf);
- *p_buf = NULL;
- }
-}
-
-/*******************************************************************************
-**
-** Function GOEP_SendMsg
-**
-** Description send a message to BTU task
-**
-** Returns void
-**
-*******************************************************************************/
-void GOEP_SendMsg (void *p_msg)
-
-{
- if(p_msg)
- {
- GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_msg);
- }
-}
-
-/*****************************************************************************
-**
-** Function: GOEP_Register()
-**
-** Purpose: Register an OBEX profile with SDP
-**
-** Parameters:
-**
-** char *p_name service name; optional (may be NULL)
-** UINT32 *phSDP handle to the created record; cannot be NULL
-** UINT8 scn scn desired for the service; must be > 0
-** UINT16 version version of the service; optional (may be 0)
-**
-** Returns: (tGOEP_ERRORS) GOEP_SUCCESS if ok; GOEP_ERROR on error
-**
-** Notes:
-**
-**
-** Preconditions:
-** - phSDP must be set (to return the SDP record handle)
-** - scn must be set
-**
-** Postconditions:
-** -
-**
-*****************************************************************************/
-tGOEP_ERRORS GOEP_Register (char *p_name,
- UINT32 *phSDP,
- UINT8 scn,
- UINT8 num_srv_class,
- UINT16 *p_service_class,
- UINT16 profile_id,
- UINT16 version)
-{
- tGOEP_ERRORS status = GOEP_ERROR;
- tSDP_PROTOCOL_ELEM protoList [GOEP_PROTOCOL_COUNT];
- UINT16 browse;
-
- /* GOEP_TRACE_EVENT4("GOEP: Register with SDP: name %s, scn %d, class %#x, version %d)",
- p_name ? p_name : "NULL",
- (UINT16)scn,
- (UINT16)p_service_class[0],
- version); */
-
- /* parameter checking */
- WC_ASSERT(phSDP);
- WC_ASSERT(scn);
-
- /* parameter checking */
- if (!(phSDP && scn))
- {
- return (GOEP_INVALID_PARAM);
- }
-
- *phSDP = SDP_CreateRecord();
- WC_ASSERT(*phSDP);
- GOEP_TRACE_API2("GOEP: Register with SDP: scn %d, record:0x%08x", scn, *phSDP);
-
- /* could a SDP handle be allocated? */
- if (*phSDP == 0)
- {
- return (GOEP_RESOURCES);
- }
-
- /* add service class */
- if (SDP_AddServiceClassIdList(*phSDP, num_srv_class, p_service_class))
- {
- /* add protocol list, including RFCOMM scn */
- protoList[0].protocol_uuid = UUID_PROTOCOL_L2CAP;
- protoList[0].num_params = 0;
- protoList[1].protocol_uuid = UUID_PROTOCOL_RFCOMM;
- protoList[1].num_params = 1;
- protoList[1].params[0] = scn;
- protoList[2].protocol_uuid = UUID_PROTOCOL_OBEX;
- protoList[2].num_params = 0;
-
-/* coverity[uninit_use_in_call]
-FALSE-POSITIVE: coverity says
-Event uninit_use_in_call: Using uninitialized element of array "(protoList)->params" in call to function "SDP_AddProtocolList"
-Event uninit_use_in_call: Using uninitialized value "(protoList)->num_params" in call to function "SDP_AddProtocolList"
-Event uninit_use_in_call: Using uninitialized value "(protoList)->protocol_uuid" in call to function "SDP_AddProtocolList"
-SDP_AddProtocolList() uses (protoList)->params only when (protoList)->num_params is non-0
-*/
- if (SDP_AddProtocolList(*phSDP, GOEP_PROTOCOL_COUNT, protoList))
- {
- /* optional: if name is not NULL, add a name entry */
- if (p_name && p_name[0] )
- {
- SDP_AddAttribute(*phSDP,
- (UINT16)ATTR_ID_SERVICE_NAME,
- (UINT8)TEXT_STR_DESC_TYPE,
- (UINT32)(strlen(p_name) + 1),
- (UINT8 *)p_name);
- } /* end of setting optional name */
- /* Add in the Bluetooth Profile Descriptor List for IrMCSync [Sync s7.1.2] */
- if (version)
- {
- SDP_AddProfileDescriptorList(*phSDP, profile_id, version);
- } /* end of setting optional profile version */
- status = GOEP_SUCCESS;
- } /* end of setting mandatory protocol list */
- } /* end of setting mandatory service class */
-
- /* Make the service browseable */
- browse = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
- if (status == GOEP_SUCCESS && SDP_AddUuidSequence (*phSDP,
- ATTR_ID_BROWSE_GROUP_LIST,
- 1,
- &browse) == FALSE)
- {
- status = GOEP_ERROR;
- }
-
- if (status != GOEP_SUCCESS)
- {
- SDP_DeleteRecord(*phSDP);
- GOEP_TRACE_DEBUG1("GOEP_Register status: %d", status);
- }
- else
- {
- GOEP_TRACE_EVENT1("GOEP: Register with SDP returns handle 0x%08x", *phSDP);
- }
-
- return (status);
-}
-
-/*****************************************************************************
-**
-** Function: GOEP_Register2()
-**
-** Purpose: Register an OBEX 1.4 profile with SDP
-**
-** Parameters:
-**
-** char *p_name service name; optional (may be NULL)
-** UINT32 *phSDP handle to the created record; cannot be NULL
-** UINT8 scn scn desired for the service; must be > 0
-** UINT16 psm psm desired for the service; must be an legal L2CAP dynamic PSM
-** UINT16 version version of the service; optional (may be 0)
-**
-** Returns: (tGOEP_ERRORS) GOEP_SUCCESS if ok; GOEP_ERROR on error
-**
-** Notes:
-**
-**
-** Preconditions:
-** - phSDP must be set (to return the SDP record handle)
-** - psm must be set
-**
-** Postconditions:
-** -
-**
-*****************************************************************************/
-tGOEP_ERRORS GOEP_Register2 (char *p_name,
- UINT32 *phSDP,
- UINT16 psm,
- UINT8 num_srv_class,
- UINT16 *p_service_class,
- UINT16 profile_id,
- UINT16 version)
-{
- tGOEP_ERRORS status = GOEP_ERROR;
- tSDP_PROTOCOL_ELEM protoList [GOEP_PROTOCOL_COUNT];
- UINT16 browse;
- UINT16 num_elem;
- UINT8 *p, array[3];
-
- /* GOEP_TRACE_EVENT4("GOEP: Register2 with SDP: name %s, psm 0x%x, class %#x, version %d)",
- p_name ? p_name : "NULL",
- (UINT16)psm,
- (UINT16)p_service_class[0],
- version); */
-
- /* parameter checking */
- WC_ASSERT(phSDP);
-
- /* parameter checking */
- if (!(phSDP && L2C_IS_VALID_PSM(psm)))
- {
- return (GOEP_INVALID_PARAM);
- }
-
- *phSDP = SDP_CreateRecord();
- WC_ASSERT(*phSDP);
- GOEP_TRACE_API2("GOEP: Register with SDP(2): psm 0x%x, record:0x%08x", psm, *phSDP);
-
- /* could a SDP handle be allocated? */
- if (*phSDP == 0)
- {
- return (GOEP_RESOURCES);
- }
-
- /* add service class */
- if (SDP_AddServiceClassIdList(*phSDP, num_srv_class, p_service_class))
- {
- /* add protocol list, including RFCOMM scn */
- num_elem=0;
- protoList[num_elem].protocol_uuid = UUID_PROTOCOL_L2CAP;
- protoList[num_elem].num_params = 0;
- num_elem++;
- protoList[num_elem].protocol_uuid = UUID_PROTOCOL_OBEX;
- protoList[num_elem].num_params = 0;
- num_elem++;
-/* coverity[uninit_use_in_call]
-FALSE-POSITIVE: coverity says
-Event uninit_use_in_call: Using uninitialized element of array "(protoList)->params" in call to function "SDP_AddProtocolList"
-Event uninit_use_in_call: Using uninitialized value "(protoList)->num_params" in call to function "SDP_AddProtocolList"
-Event uninit_use_in_call: Using uninitialized value "(protoList)->protocol_uuid" in call to function "SDP_AddProtocolList"
-SDP_AddProtocolList() uses (protoList)->params only when (protoList)->num_params is non-0
-*/
- if (SDP_AddProtocolList(*phSDP, num_elem, protoList))
- {
- p = array;
- UINT16_TO_BE_STREAM (p, psm);
- SDP_AddAttribute (*phSDP, ATTR_ID_OBX_OVR_L2CAP_PSM, UINT_DESC_TYPE, 2, array);
-
- /* optional: if name is not NULL, add a name entry */
- if (p_name && p_name[0] )
- {
- SDP_AddAttribute(*phSDP,
- (UINT16)ATTR_ID_SERVICE_NAME,
- (UINT8)TEXT_STR_DESC_TYPE,
- (UINT32)(strlen(p_name) + 1),
- (UINT8 *)p_name);
- } /* end of setting optional name */
- /* Add in the Bluetooth Profile Descriptor List for IrMCSync [Sync s7.1.2] */
- if (version)
- {
- SDP_AddProfileDescriptorList(*phSDP, profile_id, version);
- } /* end of setting optional profile version */
- status = GOEP_SUCCESS;
- } /* end of setting mandatory protocol list */
- } /* end of setting mandatory service class */
-
- /* Make the service browseable */
- browse = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
- if (status == GOEP_SUCCESS && SDP_AddUuidSequence (*phSDP,
- ATTR_ID_BROWSE_GROUP_LIST,
- 1,
- &browse) == FALSE)
- {
- status = GOEP_ERROR;
- }
-
- if (status != GOEP_SUCCESS)
- {
- SDP_DeleteRecord(*phSDP);
- GOEP_TRACE_DEBUG1("GOEP_Register status: %d", status);
- }
- else
- {
- GOEP_TRACE_EVENT1("GOEP: Register with SDP returns handle 0x%08x", *phSDP);
- }
-
-
- return (status);
-}
-
-/*****************************************************************************
-**
-** Function: GOEP_AddProtoLists()
-**
-** Purpose: Add the AdditionalProtocolDescriptorLists attribute
-** to a SDP record
-**
-** Parameters:
-**
-** UINT32 sdp_hdl the SDP record handle
-** UINT8 scn scn desired for the service; must be > 0
-**
-** Returns: (tGOEP_ERRORS) GOEP_SUCCESS if ok; GOEP_ERROR on error
-**
-** Notes:
-**
-**
-** Preconditions:
-** - sdp_hdl must be set (to the SDP record handle from GOEP_Register())
-** - scn must be set
-**
-** Postconditions:
-** -
-**
-*****************************************************************************/
-#if (BPP_INCLUDED == TRUE)
-tGOEP_ERRORS GOEP_AddProtoLists ( UINT32 sdp_hdl, UINT8 scn)
-{
- tGOEP_ERRORS status = GOEP_ERROR;
- tSDP_PROTO_LIST_ELEM proto_list_elem;
- tSDP_PROTOCOL_ELEM *p_proto_list;
-
- /*
- GOEP_TRACE_EVENT4("GOEP: Register with SDP: name %s, scn %d, class %#x, version %d)",
- p_name ? p_name : "NULL",
- (UINT16)scn,
- (UINT16)p_service_class[0],
- version);
- */
-
- /* parameter checking */
- WC_ASSERT(sdp_hdl);
- WC_ASSERT(scn);
-
- /* parameter checking */
- if (!(sdp_hdl && scn))
- {
- return (GOEP_INVALID_PARAM);
- }
-
- proto_list_elem.num_elems = 0;
- p_proto_list = &proto_list_elem.list_elem[proto_list_elem.num_elems++];
- p_proto_list->num_params = 0;
- p_proto_list->protocol_uuid = UUID_PROTOCOL_L2CAP;
- p_proto_list = &proto_list_elem.list_elem[proto_list_elem.num_elems++];
- p_proto_list->num_params = 1;
- p_proto_list->params[0] = scn;
- p_proto_list->protocol_uuid = UUID_PROTOCOL_RFCOMM;
- p_proto_list = &proto_list_elem.list_elem[proto_list_elem.num_elems++];
- p_proto_list->num_params = 0;
- p_proto_list->protocol_uuid = UUID_PROTOCOL_OBEX;
-
- /* add protocol list, including RFCOMM scn */
- if(SDP_AddAdditionProtoLists( sdp_hdl, 1, &proto_list_elem))
- status = GOEP_SUCCESS;
-
- GOEP_TRACE_DEBUG1("GOEP_AddProtoLists status: %s", GOEP_ErrorName(status));
-
- return (status);
-}
-#endif
-
-/*****************************************************************************
-**
-** Function: goep_dummy
-**
-** Purpose: This is to work around a GCC build linking problem
-**
-** Returns: none
-**
-*****************************************************************************/
-#if (RPC_INCLUDED == TRUE && RPC_TRACE_ONLY == TRUE && GOEP_FS_INCLUDED == TRUE)
-static void goep_dummy(void)
-{
- GOEP_OpenRsp(0, 0, 0, 0);
-}
-#endif /* RPC stuff */
-
-
diff --git a/stack/hid/hidd_api.c b/stack/hid/hidd_api.c
deleted file mode 100644
index 7ee41ea..0000000
--- a/stack/hid/hidd_api.c
+++ /dev/null
@@ -1,536 +0,0 @@
-/*****************************************************************************/
-/* */
-/* Name: hidd_api.c */
-/* */
-/* Description: this file contains the Device HID API entry points */
-/* */
-/* */
-/* Copyright (c) 2002-2004, WIDCOMM Inc., All Rights Reserved. */
-/* WIDCOMM Bluetooth Core. Proprietary and confidential. */
-/*****************************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include "wcassert.h"
-
-#include "gki.h"
-#include "bt_types.h"
-#include "hiddefs.h"
-#include "hidd_api.h"
-#include "hidd_int.h"
-#include "btm_api.h"
-
-#include "hcimsgs.h"
-#include "btu.h"
-#include "sdpdefs.h"
-#include "sdp_api.h"
-
-static const UINT8 HidDevLangList[] = HID_DEV_LANGUAGELIST;
-
-#ifndef HID_DEV_BOOT_DEVICE
-#define HID_DEV_BOOT_DEVICE TRUE
-#endif
-
-
-/*******************************************************************************
-**
-** Function HID_DevSetSDPRecord
-**
-** Description This function should be called at startup to create the
-** device SDP record
-**
-** Returns 0 if error else sdp handle for the record.
-**
-*******************************************************************************/
-UINT32 HID_DevSetSDPRecord (tHID_DEV_SDP_INFO *p_sdp_info)
-{
- UINT32 sdp_handle;
- tSDP_PROTOCOL_ELEM protocol_list[2];
- tSDP_PROTO_LIST_ELEM additional_list;
- UINT16 u16;
- UINT8 u8;
- UINT8 *pRepDescriptor, *pd;
- char buf[2];
-
- if( p_sdp_info == NULL )
- return (0);
-
- /* Create an SDP record for the ctrl/data or notification channel */
- if ((sdp_handle = SDP_CreateRecord()) == FALSE)
- {
- HIDD_TRACE_ERROR0 ("Could not create service record");
- return (0);
- }
-
- /* Add the UUID to the Service Class ID List */
- u16 = UUID_SERVCLASS_HUMAN_INTERFACE;
- SDP_AddServiceClassIdList(sdp_handle, 1, &u16);
-
- /* Build the protocol descriptor list */
- protocol_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP;
- protocol_list[0].num_params = 1;
- protocol_list[0].params[0] = HID_PSM_CONTROL;
-
- protocol_list[1].num_params = 0;
- protocol_list[1].protocol_uuid = UUID_PROTOCOL_HIDP;
-
- SDP_AddProtocolList(sdp_handle, 2, protocol_list);
-
- /* Language base */
- SDP_AddLanguageBaseAttrIDList (sdp_handle, LANG_ID_CODE_ENGLISH, LANG_ID_CHAR_ENCODE_UTF8,
- LANGUAGE_BASE_ID);
-
- /* Add the Bluetooth Profile Descriptor List (profile version number) */
- SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_HUMAN_INTERFACE, 0x0100);
-
- /* Add the PSM of the interrupt channel to the Additional Protocol Descriptor List */
- additional_list.num_elems = 2;
- additional_list.list_elem[0].protocol_uuid = UUID_PROTOCOL_L2CAP;
- additional_list.list_elem[0].num_params = 1;
- additional_list.list_elem[0].params[0] = HID_PSM_INTERRUPT;
- additional_list.list_elem[1].protocol_uuid = UUID_PROTOCOL_HIDP;
- additional_list.list_elem[1].num_params = 0;
-
- SDP_AddAdditionProtoLists (sdp_handle, 1, &additional_list);
-
- if( p_sdp_info->svc_name[0] != '\0' )
- SDP_AddAttribute (sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
- (UINT8)(strlen(p_sdp_info->svc_name)+1), (UINT8 *)p_sdp_info->svc_name);
-
- if( p_sdp_info->svc_descr[0] != '\0' )
- SDP_AddAttribute (sdp_handle, ATTR_ID_SERVICE_DESCRIPTION, TEXT_STR_DESC_TYPE,
- (UINT8)(strlen(p_sdp_info->svc_descr)+1), (UINT8 *)p_sdp_info->svc_descr);
-
- if( p_sdp_info->prov_name[0] != '\0' )
- SDP_AddAttribute (sdp_handle, ATTR_ID_PROVIDER_NAME, TEXT_STR_DESC_TYPE,
- (UINT8)(strlen(p_sdp_info->prov_name)+1), (UINT8 *)p_sdp_info->prov_name);
-
- /* HID parser version */
- UINT16_TO_BE_FIELD(buf,p_sdp_info->hpars_ver) ;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_PARSER_VERSION, UINT_DESC_TYPE, 2, (UINT8 *)buf);
-
- /* HID subclass */
- u8 = p_sdp_info->sub_class;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_DEVICE_SUBCLASS, UINT_DESC_TYPE, 1, &u8);
-
- /* HID country code */
- u8 = p_sdp_info->ctry_code;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_COUNTRY_CODE, UINT_DESC_TYPE, 1, &u8);
-
- /* HID Virtual Cable */
- u8 = HID_DEV_VIRTUAL_CABLE;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_VIRTUAL_CABLE, BOOLEAN_DESC_TYPE, 1, &u8);
-
- /* HID reconnect initiate */
- u8 = HID_DEV_RECONN_INITIATE;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_RECONNECT_INITIATE, BOOLEAN_DESC_TYPE, 1, &u8);
-
- /* HID report descriptor */
- if ( NULL != (pRepDescriptor = (UINT8 *)GKI_getbuf((UINT16)(p_sdp_info->dscp_info.dl_len + 8 ))) )
- {
- pd = pRepDescriptor;
- *pd++ = (UINT8)((DATA_ELE_SEQ_DESC_TYPE << 3) | SIZE_IN_NEXT_BYTE);
- *pd++ = (UINT8)(p_sdp_info->dscp_info.dl_len + 4);
- *pd++ = (UINT8)((UINT_DESC_TYPE << 3) | SIZE_ONE_BYTE);
- *pd++ = (UINT8)(HID_SDP_DESCRIPTOR_REPORT);
- *pd++ = (UINT8)((TEXT_STR_DESC_TYPE << 3) | SIZE_IN_NEXT_BYTE);
- *pd++ = (UINT8)(p_sdp_info->dscp_info.dl_len);
- memcpy (pd, p_sdp_info->dscp_info.dsc_list, p_sdp_info->dscp_info.dl_len);
- pd += p_sdp_info->dscp_info.dl_len;
-
- SDP_AddAttribute (sdp_handle, ATTR_ID_HID_DESCRIPTOR_LIST, DATA_ELE_SEQ_DESC_TYPE,
- (UINT32)(pd - pRepDescriptor), pRepDescriptor);
- GKI_freebuf( pRepDescriptor );
- }
- else
- {
- SDP_DeleteRecord( sdp_handle ); /* delete freshly allocated record */
- HIDD_TRACE_ERROR1( "HID_DevSetSDPRecord(): SDP creation failed: no memory for rep dscr len: %d",
- p_sdp_info->dscp_info.dl_len );
- return 0;
- }
- /* HID language base list */
- SDP_AddAttribute (sdp_handle, ATTR_ID_HID_LANGUAGE_ID_BASE, DATA_ELE_SEQ_DESC_TYPE,
- sizeof (HidDevLangList), (UINT8 *)HidDevLangList);
-
- /* HID SDP disable (i.e. SDP while Control and Interrupt are up) */
-#if (MAX_L2CAP_CHANNELS > 2)
- u8 = 0;
-#else
- u8 = 1;
-#endif
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_SDP_DISABLE, BOOLEAN_DESC_TYPE, 1, &u8);
-
-#if defined(HID_DEV_BATTERY_POW)
- /* HID battery power */
- u8 = HID_DEV_BATTERY_POW;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_BATTERY_POWER, BOOLEAN_DESC_TYPE, 1, &u8);
-#endif
-
-#if defined(HID_DEV_REMOTE_WAKE)
- /* HID remote wakeup capable */
- u8 = HID_DEV_REMOTE_WAKE;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_REMOTE_WAKE, BOOLEAN_DESC_TYPE, 1, &u8);
-#endif
-
- /* Link supervision timeout */
- UINT16_TO_BE_FIELD(buf,HID_DEV_LINK_SUPERVISION_TO) ;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_LINK_SUPERVISION_TO, UINT_DESC_TYPE, 2, (UINT8 *)buf);
-
- /* HID remote wakeup capable */
- u8 = HID_DEV_NORMALLY_CONN;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_NORMALLY_CONNECTABLE, BOOLEAN_DESC_TYPE, 1, &u8);
-
- /* HID BOOT Device */
- u8 = HID_DEV_BOOT_DEVICE;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_BOOT_DEVICE, BOOLEAN_DESC_TYPE, 1, &u8);
-
- u16 = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
- SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &u16);
-
- /* SSR host max latency */
- if (p_sdp_info->ssr_max_latency != HID_SSR_PARAM_INVALID)
- {
- UINT16_TO_BE_FIELD(buf,HID_DEV_LINK_SUPERVISION_TO) ;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_SSR_HOST_MAX_LAT, UINT_DESC_TYPE, 2, (UINT8 *)buf);
- }
-
- /* SSR host min timeout */
- if (p_sdp_info->ssr_max_latency != HID_SSR_PARAM_INVALID)
- {
- UINT16_TO_BE_FIELD(buf,HID_DEV_LINK_SUPERVISION_TO) ;
- SDP_AddAttribute(sdp_handle, ATTR_ID_HID_SSR_HOST_MIN_TOUT, UINT_DESC_TYPE, 2, (UINT8 *)buf);
- }
- return (sdp_handle);
-}
-
-/*******************************************************************************
-**
-** Function HID_DevInit
-**
-** Description This function initializes the control block and trace variable
-**
-** Returns void
-**
-*******************************************************************************/
-void HID_DevInit (void)
-{
- memset(&hd_cb, 0, sizeof(tHIDDEV_CB));
-
- /* Initialize control channel L2CAP configuration */
- hd_cb.l2cap_ctrl_cfg.mtu_present = TRUE;
- hd_cb.l2cap_ctrl_cfg.mtu = HID_DEV_MTU_SIZE;
-
- /* Initialize interrupt channel L2CAP configuration */
- hd_cb.l2cap_int_cfg.mtu_present = TRUE;
- hd_cb.l2cap_int_cfg.mtu = HID_DEV_MTU_SIZE;
-
- hd_cb.conn.timer_entry.param = (UINT32) hidd_proc_repage_timeout;
-#if defined(HID_INITIAL_TRACE_LEVEL)
- hd_cb.trace_level = HID_INITIAL_TRACE_LEVEL;
-#else
- hd_cb.trace_level = BT_TRACE_LEVEL_NONE;
-#endif
-}
-
-/*******************************************************************************
-**
-** Function HID_DevRegister
-**
-** Description This function must be called at startup so the device receive
-** HID related events and call other HID API Calls.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS HID_DevRegister( tHID_DEV_REG_INFO *p_reg_info )
-{
- tHID_STATUS st;
- BD_ADDR bt_bd_any = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
- UINT16 conn_able;
-
- if( p_reg_info == NULL ||
- p_reg_info->app_cback == NULL )
- return HID_ERR_INVALID_PARAM;
-
- if( hd_cb.reg_flag )
- return HID_ERR_ALREADY_REGISTERED;
-
- /* Check if the host address is provided */
- if( memcmp( p_reg_info->host_addr, bt_bd_any, BD_ADDR_LEN ) )
- {
- hd_cb.host_known = TRUE;
- memcpy( hd_cb.host_addr, p_reg_info->host_addr, BD_ADDR_LEN );
- hd_cb.dev_state = HID_DEV_ST_NO_CONN ;
-
- /* When host address is provided, connectibility is determined by the
- SDP attribute, otherwise device has to be connectable for initial
- pairing process with the host */
- conn_able = (UINT16) HID_DEV_NORMALLY_CONN;
- }
- else
- {
- hd_cb.host_known = FALSE;
- conn_able = BTM_CONNECTABLE;
- }
-
- hd_cb.virtual_cable = HID_DEV_VIRTUAL_CABLE;
-
- /* Copy QoS parameters if provided */
- if( p_reg_info->qos_info )
- {
- memcpy( &(hd_cb.qos_info), p_reg_info->qos_info, sizeof( tHID_DEV_QOS_INFO ) );
- hd_cb.use_qos_flg = TRUE;
- }
- else
- {
- hd_cb.use_qos_flg = FALSE;
- }
-
- hd_cb.callback = p_reg_info->app_cback ;
-
- /* Register with L2CAP */
- if( (st = hidd_conn_reg()) != HID_SUCCESS )
- {
- return st;
- }
-
-#if (!defined(HID_DEV_SET_CONN_MODE) || HID_DEV_SET_CONN_MODE == TRUE)
- if( BTM_SetConnectability (conn_able, HID_DEV_PAGE_SCAN_WIN, HID_DEV_PAGE_SCAN_INT) != BTM_SUCCESS )
- return HID_ERR_SET_CONNABLE_FAIL ;
-#endif
-
- hd_cb.reg_flag = TRUE;
- hd_cb.unplug_on = FALSE;
-
- HIDD_TRACE_DEBUG0 ("HID_DevRegister successful");
- return HID_SUCCESS;
-}
-
-/*******************************************************************************
-**
-** Function HID_DevDeregister
-**
-** Description This function may be used to remove HID service records and
-** deregister from L2CAP.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS HID_DevDeregister( void )
-{
- if( !hd_cb.reg_flag )
- return HID_ERR_NOT_REGISTERED;
-
- hidd_mgmt_process_evt( HID_API_DISCONNECT, NULL ) ; /* Disconnect first */
- /* Deregister with L2CAP */
- hidd_conn_dereg() ;
- hd_cb.reg_flag = FALSE;
- return HID_SUCCESS;
-}
-
-/*******************************************************************************
-**
-** Function HID_DevConnect
-**
-** Description This function may be used to initiate a connection to the host..
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS HID_DevConnect( void )
-{
- if( hd_cb.reg_flag == FALSE )
- return HID_ERR_NOT_REGISTERED;
-
- return hidd_mgmt_process_evt( HID_API_CONNECT, NULL ) ; /* This will initiate connection */
-}
-
-/*******************************************************************************
-**
-** Function HID_DevDisconnect
-**
-** Description This function may be used to disconnect from the host
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS HID_DevDisconnect( void )
-{
- if( hd_cb.reg_flag == FALSE )
- return HID_ERR_NOT_REGISTERED;
-
- return hidd_mgmt_process_evt( HID_API_DISCONNECT, NULL ) ; /* This will initiate disconnection */
-}
-
-/*******************************************************************************
-**
-** Function HID_DevHandShake
-**
-** Description This function may be used to send HAND-SHAKE to host
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS HID_DevHandShake( UINT8 res_code )
-{
- tHID_SND_DATA_PARAMS hsk_data;
-
- if( hd_cb.reg_flag == FALSE )
- return HID_ERR_NOT_REGISTERED;
-
- hsk_data.trans_type = HID_TRANS_HANDSHAKE ;
- hsk_data.ctrl_ch = TRUE ;
- hsk_data.param = res_code;
- hsk_data.buf = NULL;
-
- return hidd_mgmt_process_evt( HID_API_SEND_DATA, &hsk_data ) ;
-}
-
-/*******************************************************************************
-**
-** Function HID_DevVirtualUnplug
-**
-** Description This function may be used to send VIRTUAL-UNPLUG to host
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS HID_DevVirtualUnplug ( void )
-{
- tHID_STATUS st;
-
- tHID_SND_DATA_PARAMS vup_data;
-
- if( hd_cb.reg_flag == FALSE )
- return HID_ERR_NOT_REGISTERED;
-
- vup_data.trans_type = HID_TRANS_CONTROL ;
- vup_data.ctrl_ch = TRUE ;
- vup_data.param = HID_PAR_CONTROL_VIRTUAL_CABLE_UNPLUG;
- vup_data.buf = NULL;
-
- if( (st = hidd_mgmt_process_evt(HID_API_SEND_DATA, &vup_data)) == HID_SUCCESS )
- {
- hd_cb.unplug_on = TRUE;
- }
-
- return st;
-}
-
-/*******************************************************************************
-**
-** Function HID_DevSendData
-**
-** Description This function may be used to send input reports to host
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS HID_DevSendData ( BOOLEAN control_ch, UINT8 rep_type, BT_HDR *data_buf )
-{
- tHID_SND_DATA_PARAMS snd_data;
-
- WC_ASSERT(control_ch != TRUE && control_ch != FALSE);
-
- if( hd_cb.reg_flag == FALSE )
- return HID_ERR_NOT_REGISTERED;
-
- snd_data.trans_type = HID_TRANS_DATA ;
- snd_data.ctrl_ch = control_ch ;
- snd_data.param = rep_type;
- snd_data.buf = data_buf;
-
- return hidd_mgmt_process_evt( HID_API_SEND_DATA, &snd_data ) ;
-}
-
-/*******************************************************************************
-**
-** Function HID_DevSetSecurityLevel
-**
-** Description This function set security level for the Hid Device service.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS HID_DevSetSecurityLevel( char serv_name[], UINT8 sec_lvl )
-{
- hd_cb.sec_mask = sec_lvl;
-
- if (sec_lvl == 0)
- {
- if (!BTM_SetSecurityLevel (FALSE, serv_name, BTM_SEC_SERVICE_HID_NOSEC_CTRL,
- BTM_SEC_NONE, HID_PSM_CONTROL, BTM_SEC_PROTO_HID , HIDD_NOSEC_CHN))
- {
- HIDD_TRACE_ERROR0 ("Security Registration 1 failed");
- return (HID_ERR_NO_RESOURCES);
- }
- if (!BTM_SetSecurityLevel (TRUE, serv_name, BTM_SEC_SERVICE_HID_NOSEC_CTRL,
- BTM_SEC_NONE, HID_PSM_CONTROL, BTM_SEC_PROTO_HID, HIDD_NOSEC_CHN))
- {
- HIDD_TRACE_ERROR0 ("Security Registration 2 failed");
- return (HID_ERR_NO_RESOURCES);
- }
- }
- else
- {
- /* Register with Security Manager for the specific security level */
- if (!BTM_SetSecurityLevel (FALSE, serv_name, BTM_SEC_SERVICE_HID_SEC_CTRL,
- sec_lvl, HID_PSM_CONTROL, BTM_SEC_PROTO_HID, HIDD_SEC_CHN))
- {
- HIDD_TRACE_ERROR0 ("Security Registration 3 failed");
- return (HID_ERR_NO_RESOURCES);
- }
- if (!BTM_SetSecurityLevel (TRUE, serv_name, BTM_SEC_SERVICE_HID_SEC_CTRL,
- sec_lvl, HID_PSM_CONTROL, BTM_SEC_PROTO_HID, HIDD_SEC_CHN))
- {
- HIDD_TRACE_ERROR0 ("Security Registration 4 failed");
- return (HID_ERR_NO_RESOURCES);
- }
- }
-
- /* Register with Security Manager for the specific security level for interupt channel*/
- if (!BTM_SetSecurityLevel (TRUE, serv_name, BTM_SEC_SERVICE_HID_INTR,
- BTM_SEC_NONE, HID_PSM_INTERRUPT, BTM_SEC_PROTO_HID, 0))
- {
- HIDD_TRACE_ERROR0 ("Security Registration 5 failed");
- return (HID_ERR_NO_RESOURCES);
- }
-
- if (!BTM_SetSecurityLevel (FALSE, serv_name, BTM_SEC_SERVICE_HID_INTR,
- BTM_SEC_NONE, HID_PSM_INTERRUPT, BTM_SEC_PROTO_HID, 0))
- {
- HIDD_TRACE_ERROR0 ("Security Registration 6 failed");
- return (HID_ERR_NO_RESOURCES);
- }
-
- return HID_SUCCESS;
-}
-
-#if HID_DEV_PM_INCLUDED == TRUE
-/*******************************************************************************
-**
-** Function HID_DevSetPowerMgmtParams
-**
-** Description This function may be used to change power mgmt parameters.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS HID_DevSetPowerMgmtParams( UINT8 conn_substate, tHID_DEV_PM_PWR_MD pm_params )
-{
- if( conn_substate > HID_DEV_SUSP_CONN_ST )
- return (HID_ERR_INVALID_PARAM);
-
- memcpy( &hd_cb.pm_params[conn_substate], &pm_params, sizeof( tHID_DEV_PM_PWR_MD ) ) ;
-
- /* Set the power mode to new parameters if currently in that state */
- if( conn_substate == hd_cb.conn_substate )
- hidd_pm_set_power_mode ( &(hd_cb.pm_params[conn_substate]) );
-
- return (HID_SUCCESS);
-}
-
-#endif
-
diff --git a/stack/hid/hidd_conn.c b/stack/hid/hidd_conn.c
deleted file mode 100644
index 111dcb7..0000000
--- a/stack/hid/hidd_conn.c
+++ /dev/null
@@ -1,970 +0,0 @@
-/*****************************************************************************/
-/* */
-/* Name: hidd_conn.c */
-/* */
-/* Description: this file contains the connection interface functions */
-/* for device role */
-/* Copyright (c) 2002-2011, Broadcom Corp., All Rights Reserved. */
-/* Broadcom Bluetooth Core. Proprietary and confidential. */
-/* */
-/*****************************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-
-#include "gki.h"
-#include "bt_types.h"
-
-#include "l2cdefs.h"
-#include "l2c_api.h"
-
-#include "btu.h"
-#include "btm_api.h"
-#include "btm_int.h"
-
-#include "hiddefs.h"
-
-#include "hidd_api.h"
-#include "hidd_int.h"
-
-/********************************************************************************/
-/* L O C A L F U N C T I O N P R O T O T Y P E S */
-/********************************************************************************/
-static void hidd_l2cif_connect_ind (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm,
- UINT8 l2cap_id);
-static void hidd_l2cif_connect_cfm (UINT16 l2cap_cid, UINT16 result);
-static void hidd_l2cif_config_ind (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg);
-static void hidd_l2cif_config_cfm (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg);
-static void hidd_l2cif_disconnect_ind (UINT16 l2cap_cid, BOOLEAN ack_needed);
-static void hidd_l2cif_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg);
-static void hidd_l2cif_disconnect_cfm (UINT16 l2cap_cid, UINT16 result);
-static void hidd_l2cif_cong_ind (UINT16 l2cap_cid, BOOLEAN congested);
-
-static const tL2CAP_APPL_INFO reg_info =
-{
- hidd_l2cif_connect_ind,
- hidd_l2cif_connect_cfm,
- NULL,
- hidd_l2cif_config_ind,
- hidd_l2cif_config_cfm,
- hidd_l2cif_disconnect_ind,
- hidd_l2cif_disconnect_cfm,
- NULL,
- hidd_l2cif_data_ind,
- hidd_l2cif_cong_ind,
- NULL /* tL2CA_TX_COMPLETE_CB */
-} ;
-
-
-/*******************************************************************************
-**
-** Function hidd_conn_reg
-**
-** Description This function registers with L2CAP.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS hidd_conn_reg (void)
-{
- /* Now, register with L2CAP for control and interrupt PSMs*/
- if (!L2CA_Register (HID_PSM_CONTROL, (tL2CAP_APPL_INFO *) &reg_info))
- {
- HIDD_TRACE_ERROR0 ("HID Control Registration failed");
- return( HID_ERR_L2CAP_FAILED );
- }
-
- if (!L2CA_Register (HID_PSM_INTERRUPT, (tL2CAP_APPL_INFO *) &reg_info))
- {
- L2CA_Deregister( HID_PSM_CONTROL ) ;
- HIDD_TRACE_ERROR0 ("HID Interrupt Registration failed");
- return( HID_ERR_L2CAP_FAILED );
- }
-
- /* Set up / initialize the l2cap configuration data */
- hd_cb.l2cap_ctrl_cfg.flush_to_present = TRUE;
- hd_cb.l2cap_ctrl_cfg.flush_to = HID_DEV_FLUSH_TO;
- hd_cb.l2cap_int_cfg.flush_to_present = TRUE;
- hd_cb.l2cap_int_cfg.flush_to = HID_DEV_FLUSH_TO;
-
- if( hd_cb.use_qos_flg == TRUE )
- {
- memcpy( &(hd_cb.l2cap_ctrl_cfg.qos), &(hd_cb.qos_info.ctrl_ch), sizeof( FLOW_SPEC ) ) ;
- hd_cb.l2cap_ctrl_cfg.qos_present = TRUE ;
-
- memcpy( &(hd_cb.l2cap_int_cfg.qos), &(hd_cb.qos_info.int_ch), sizeof( FLOW_SPEC ) ) ;
- hd_cb.l2cap_int_cfg.qos_present = TRUE ;
- }
- else
- {
- hd_cb.l2cap_ctrl_cfg.qos_present = FALSE ;
- hd_cb.l2cap_int_cfg.qos_present = FALSE ;
- }
-
- hd_cb.conn.conn_state = HID_CONN_STATE_UNUSED ;
-
- return( HID_SUCCESS );
-}
-
-/*******************************************************************************
-**
-** Function hidd_conn_dereg
-**
-** Description This function deregisters with L2CAP.
-**
-** Returns void
-**
-*******************************************************************************/
-void hidd_conn_dereg( void )
-{
- L2CA_Deregister (HID_PSM_CONTROL);
- L2CA_Deregister (HID_PSM_INTERRUPT);
-}
-
-/*******************************************************************************
-**
-** Function hid_conn_disconnect
-**
-** Description This function disconnects a connection.
-**
-** Returns TRUE if disconnect started, FALSE if already disconnected
-**
-*******************************************************************************/
-void hidd_conn_disconnect ()
-{
- tHID_CONN *p_hcon = &hd_cb.conn;
-#if HID_DEV_PM_INCLUDED == TRUE
- tHID_DEV_PM_PWR_MD act_pm = { 0, 0, 0, 0, HCI_MODE_ACTIVE } ;
-#endif
-
- HIDD_TRACE_EVENT0 ("HID - disconnect");
-
-#if HID_DEV_PM_INCLUDED == TRUE
- hidd_pm_stop(); /* This will stop the idle timer if running */
-
- /* Need to go to to active mode to be able to send disconnect */
- hidd_pm_set_power_mode( &act_pm );
-#endif
-
- if ((p_hcon->ctrl_cid != 0) || (p_hcon->intr_cid != 0))
- {
- p_hcon->conn_state = HID_CONN_STATE_DISCONNECTING;
- /* Disconnect both control and interrupt channels */
- if (p_hcon->intr_cid)
- L2CA_DisconnectReq (p_hcon->intr_cid);
-
- if (p_hcon->ctrl_cid)
- L2CA_DisconnectReq (p_hcon->ctrl_cid);
- }
- else
- {
- p_hcon->conn_state = HID_CONN_STATE_UNUSED;
- }
-}
-
-/*******************************************************************************
-**
-** Function hidd_conn_initiate
-**
-** Description This function is called by the management to create a connection.
-**
-** Returns void
-**
-*******************************************************************************/
-tHID_STATUS hidd_conn_initiate (void)
-{
- tHID_CONN *p_hcon = &hd_cb.conn;
- UINT8 service_id = BTM_SEC_SERVICE_HID_NOSEC_CTRL;
- UINT32 mx_chan_id = HIDD_NOSEC_CHN;
-
-#if HID_DEV_NORMALLY_CONN == TRUE
- if( p_hcon->conn_state != HID_CONN_STATE_UNUSED )
- return HID_ERR_CONN_IN_PROCESS ;
-#endif
-
- HIDD_TRACE_EVENT0 ("HID - Originate started");
-
- p_hcon->ctrl_cid = 0;
- p_hcon->intr_cid = 0;
-
- /* We are the originator of this connection */
- p_hcon->conn_flags = HID_CONN_FLAGS_IS_ORIG;
- if(hd_cb.sec_mask)
- {
- service_id = BTM_SEC_SERVICE_HID_SEC_CTRL;
- mx_chan_id = HIDD_SEC_CHN;
- }
- BTM_SetOutService (hd_cb.host_addr, service_id, mx_chan_id);
-
- /* Check if L2CAP started the connection process */
- if ((p_hcon->ctrl_cid = L2CA_ConnectReq (HID_PSM_CONTROL, hd_cb.host_addr)) == 0)
- {
- HIDD_TRACE_WARNING0 ("HID - Originate failed");
- return (HID_ERR_L2CAP_FAILED);
- }
- else
- {
- /* Transition to the next appropriate state, waiting for connection confirm on control channel. */
- p_hcon->conn_state = HID_CONN_STATE_CONNECTING_CTRL;
-
- return (HID_SUCCESS);
- }
-}
-
-/*******************************************************************************
-**
-** Function hidd_sec_check_complete_term
-**
-** Description HID device security check complete callback function.
-**
-** Returns When security check succeed, send L2Cap connect response with
-** OK code and send L2C configuration requret; otherwise send
-** L2C connection response with security block code.
-**
-**
-*******************************************************************************/
-void hidd_sec_check_complete_term (BD_ADDR bd_addr, void *p_ref_data, UINT8 res)
-{
- tHID_CONN *p_hcon = &hd_cb.conn;
-
- if( res == BTM_SUCCESS && p_hcon->conn_state == HID_CONN_STATE_SECURITY )
- {
- p_hcon->conn_state = HID_CONN_STATE_CONNECTING_INTR;
-
- /* Send response to the L2CAP layer. */
- L2CA_ConnectRsp (bd_addr, p_hcon->ctrl_id, p_hcon->ctrl_cid, L2CAP_CONN_OK, L2CAP_CONN_OK);
-
- /* Send a Configuration Request. */
- L2CA_ConfigReq (p_hcon->ctrl_cid, &hd_cb.l2cap_ctrl_cfg);
-
- }
- /* security check fail */
- else if (res != BTM_SUCCESS)
- {
- L2CA_ConnectRsp (bd_addr, p_hcon->ctrl_id, p_hcon->ctrl_cid, L2CAP_CONN_SECURITY_BLOCK, L2CAP_CONN_OK);
- p_hcon->conn_state = HID_CONN_STATE_UNUSED;
- }
-}
-
-/*******************************************************************************
-**
-** Function hidd_l2cif_connect_ind
-**
-** Description This function handles an inbound connection indication
-** from L2CAP. This is the case where we are acting as a
-** server.
-**
-** Returns void
-**
-*******************************************************************************/
-static void hidd_l2cif_connect_ind (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UINT8 l2cap_id)
-{
- tHID_CONN *p_hcon = &hd_cb.conn;
- BOOLEAN bAccept = TRUE;
- tL2CAP_CFG_INFO *p_l2cfg = NULL;
-
- HIDD_TRACE_EVENT2 ("HID - Rcvd L2CAP conn ind, PSM: 0x%04x CID 0x%x", psm, l2cap_cid);
-
- /* If host address provided during registration does not match, reject connection */
- if( hd_cb.virtual_cable && hd_cb.host_known &&
- memcmp( hd_cb.host_addr, bd_addr, BD_ADDR_LEN) )
- bAccept = FALSE;
- else
- {
- /* Check we are in the correct state for this */
- if (psm == HID_PSM_INTERRUPT)
- {
- if (p_hcon->ctrl_cid == 0)
- {
- HIDD_TRACE_WARNING0 ("HID - Rcvd INTR L2CAP conn ind, but no CTL channel");
- bAccept = FALSE;
- }
- if (p_hcon->conn_state != HID_CONN_STATE_CONNECTING_INTR)
- {
- HIDD_TRACE_WARNING1 ("HID - Rcvd INTR L2CAP conn ind, wrong state: %d", p_hcon->conn_state);
- bAccept = FALSE;
- }
- p_l2cfg = &hd_cb.l2cap_int_cfg;
- }
- else
- {
- if (p_hcon->conn_state != HID_CONN_STATE_UNUSED)
- {
- HIDD_TRACE_WARNING1 ("HID - Rcvd CTL L2CAP conn ind, wrong state: %d", p_hcon->conn_state);
- bAccept = FALSE;
- }
- p_l2cfg = &hd_cb.l2cap_ctrl_cfg;
- }
- }
-
- if (!bAccept)
- {
- L2CA_ConnectRsp (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_NO_RESOURCES, 0);
- return;
- }
-
- if (psm == HID_PSM_CONTROL)
- {
- p_hcon->conn_flags = 0;
- p_hcon->ctrl_cid = l2cap_cid;
- p_hcon->ctrl_id = l2cap_id;
-
- p_hcon->conn_state = HID_CONN_STATE_SECURITY;
-
- if(btm_sec_mx_access_request (bd_addr, HID_PSM_CONTROL,
- FALSE, BTM_SEC_PROTO_HID,
- (hd_cb.sec_mask == 0) ? HIDD_NOSEC_CHN : HIDD_SEC_CHN,
- &hidd_sec_check_complete_term, NULL) == BTM_CMD_STARTED)
- {
- L2CA_ConnectRsp (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_PENDING, L2CAP_CONN_OK);
- }
- return;
- }
- else
- {
- /* Transition to the next appropriate state, configuration */
- p_hcon->conn_state = HID_CONN_STATE_CONFIG;
- p_hcon->intr_cid = l2cap_cid;
- }
-
- /* Send response to the L2CAP layer. */
- L2CA_ConnectRsp (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_OK, L2CAP_CONN_OK);
-
- /* Send a Configuration Request. */
- L2CA_ConfigReq (l2cap_cid, p_l2cfg);
-
- memcpy( hd_cb.host_addr, bd_addr, BD_ADDR_LEN ) ;
-
- HIDD_TRACE_EVENT2 ("HID - Rcvd L2CAP conn ind, sent config req, PSM: 0x%04x CID 0x%x", psm, l2cap_cid);
-}
-
-/*******************************************************************************
-**
-** Function hidd_sec_check_complete_orig
-**
-** Description This function checks to see if security procedures are being
-** carried out or not..
-**
-** Returns void
-**
-*******************************************************************************/
-void hidd_sec_check_complete_orig (BD_ADDR bd_addr, void *p_ref_data, UINT8 res)
-{
- UINT32 reason;
- tHID_CONN *p_hcon = &hd_cb.conn;
-
- if( res == BTM_SUCCESS && p_hcon->conn_state == HID_CONN_STATE_SECURITY )
- {
- HIDD_TRACE_EVENT0 ("HID Device - Originator security pass.");
-
- /* Send connect request for interrupt channel */
- if ((p_hcon->intr_cid = L2CA_ConnectReq (HID_PSM_INTERRUPT, hd_cb.host_addr)) == 0)
- {
- HIDD_TRACE_WARNING0 ("HID - INTR Originate failed");
- hidd_conn_disconnect();/* Disconnects the ctrl channel if setting of int chnl failed */
- reason = HID_L2CAP_REQ_FAIL ;
- hd_cb.conn_tries = HID_DEV_MAX_CONN_RETRY+1;
- hidd_mgmt_process_evt( HOST_CONN_FAIL, &reason ) ;
- return;
- }
- else
- {
- /* Transition to the next appropriate state, waiting for connection confirm on control channel. */
- p_hcon->conn_state = HID_CONN_STATE_CONNECTING_INTR;
- }
- }
-
- if( res != BTM_SUCCESS && p_hcon->conn_state == HID_CONN_STATE_SECURITY )
- {
- hidd_conn_disconnect();
- }
-
-}
-
-/*******************************************************************************
-**
-** Function hid_l2cif_connect_cfm
-**
-** Description This function handles the connect confirm events
-** from L2CAP. This is the case when we are acting as a
-** client and have sent a connect request.
-**
-** Returns void
-**
-*******************************************************************************/
-static void hidd_l2cif_connect_cfm (UINT16 l2cap_cid, UINT16 result)
-{
- UINT32 reason;
- tHID_CONN *p_hcon = &hd_cb.conn;
- tL2CAP_CFG_INFO *p_l2cfg;
-
- /* Verify we are in a state to accept this message */
- if (((p_hcon->ctrl_cid != l2cap_cid) && (p_hcon->intr_cid != l2cap_cid))
- || (!(p_hcon->conn_flags & HID_CONN_FLAGS_IS_ORIG))
- || ((l2cap_cid == p_hcon->ctrl_cid) && (p_hcon->conn_state != HID_CONN_STATE_CONNECTING_CTRL))
- || ((l2cap_cid == p_hcon->intr_cid) && (p_hcon->conn_state != HID_CONN_STATE_CONNECTING_INTR)))
- {
- HIDD_TRACE_WARNING1 ("HID - Rcvd unexpected conn cnf, CID 0x%x ", l2cap_cid);
- return;
- }
-
- if (result != L2CAP_CONN_OK)
- {
- if (l2cap_cid == p_hcon->ctrl_cid)
- p_hcon->ctrl_cid = 0;
- else
- p_hcon->intr_cid = 0;
-
- reason = HID_L2CAP_CONN_FAIL | ((UINT32) result) ;
- hidd_conn_disconnect(); /* Disconnects the ctrl channel if setting of int chnl failed */
-
- /* If connection failed due to bad air link, retry... */
- if (result != HCI_ERR_CONNECTION_TOUT && result != HCI_ERR_UNSPECIFIED
- && result != HCI_ERR_PAGE_TIMEOUT)
- hd_cb.conn_tries = HID_DEV_MAX_CONN_RETRY+1;
- hidd_mgmt_process_evt( HOST_CONN_FAIL, &reason ) ;
- return;
- }
-
- if (l2cap_cid == p_hcon->ctrl_cid)
- {
- /* let HID Device handle security itself */
- p_hcon->conn_state = HID_CONN_STATE_SECURITY;
-
- btm_sec_mx_access_request (hd_cb.host_addr, HID_PSM_CONTROL,
- TRUE, BTM_SEC_PROTO_HID,
- (hd_cb.sec_mask == 0) ? HIDD_NOSEC_CHN : HIDD_SEC_CHN,
- &hidd_sec_check_complete_orig, NULL);
-
- p_l2cfg = &hd_cb.l2cap_int_cfg;
-
- }
- else
- {
- p_hcon->conn_state = HID_CONN_STATE_CONFIG;
- p_l2cfg = &hd_cb.l2cap_ctrl_cfg;
- }
-
- /* Send a Configuration Request. */
- L2CA_ConfigReq (l2cap_cid, p_l2cfg);
-
- HIDD_TRACE_EVENT1 ("HID - got CTRL conn cnf, sent cfg req, CID: 0x%x", l2cap_cid);
- return;
-}
-
-/*******************************************************************************
-**
-** Function hidd_l2c_connected
-**
-** Description This function is called when both control and interrupt channels
-** have been created.
-**
-** Returns void
-**
-*******************************************************************************/
-void hidd_l2c_connected( tHID_CONN *p_hcon )
-{
- p_hcon->conn_state = HID_CONN_STATE_CONNECTED;
-
- /* Set HCI QoS */
- if( hd_cb.use_qos_flg )
- BTM_SetQoS( hd_cb.host_addr, &(hd_cb.qos_info.hci), NULL ) ;
-
- hidd_mgmt_process_evt( HOST_CONN_OPEN, hd_cb.host_addr) ;
-#if HID_DEV_PM_INCLUDED == TRUE
- hidd_pm_init();
- hidd_pm_start(); /* This kicks in the idle timer */
-#endif
-}
-
-/*******************************************************************************
-**
-** Function hidd_l2cif_config_ind
-**
-** Description This function processes the L2CAP configuration indication
-** event.
-**
-** Returns void
-**
-*******************************************************************************/
-static void hidd_l2cif_config_ind (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg)
-{
- tHID_CONN *p_hcon = &hd_cb.conn;
-
- /* Find CCB based on CID */
- if ((p_hcon->ctrl_cid != l2cap_cid) && (p_hcon->intr_cid != l2cap_cid))
- {
- HIDD_TRACE_WARNING1 ("HID - Rcvd L2CAP cfg ind, unknown CID: 0x%x", l2cap_cid);
- return;
- }
-
- HIDD_TRACE_EVENT1 ("HID - Rcvd cfg ind, sent cfg cfm, CID: 0x%x", l2cap_cid);
-
- /* Remember the remote MTU size */
- if ((!p_cfg->mtu_present) || (p_cfg->mtu > HID_DEV_MTU_SIZE))
- p_hcon->rem_mtu_size = HID_DEV_MTU_SIZE;
- else
- p_hcon->rem_mtu_size = p_cfg->mtu;
-
- /* For now, always accept configuration from the other side */
- p_cfg->flush_to_present = FALSE;
- p_cfg->mtu_present = FALSE;
- p_cfg->result = L2CAP_CFG_OK;
-
- L2CA_ConfigRsp (l2cap_cid, p_cfg);
-
- if (l2cap_cid == p_hcon->ctrl_cid)
- p_hcon->conn_flags |= HID_CONN_FLAGS_HIS_CTRL_CFG_DONE;
- else
- p_hcon->conn_flags |= HID_CONN_FLAGS_HIS_INTR_CFG_DONE;
-
- /* If all configuration is complete, change state and tell management we are up */
- if (((p_hcon->conn_flags & HID_CONN_FLAGS_ALL_CONFIGURED) == HID_CONN_FLAGS_ALL_CONFIGURED)
- && (p_hcon->conn_state == HID_CONN_STATE_CONFIG))
- {
- hidd_l2c_connected( p_hcon );
- }
-}
-
-
-/*******************************************************************************
-**
-** Function hid_l2cif_config_cfm
-**
-** Description This function processes the L2CAP configuration confirmation
-** event.
-**
-** Returns void
-**
-*******************************************************************************/
-static void hidd_l2cif_config_cfm (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg)
-{
- UINT32 reason;
- tHID_CONN *p_hcon = &hd_cb.conn;
- tL2CAP_CFG_INFO * p_l2cfg = NULL;
-
- HIDD_TRACE_EVENT2 ("HID - Rcvd cfg cfm, CID: 0x%x Result: %d", l2cap_cid, p_cfg->result);
-
- /* Find CCB based on CID */
- if ((p_hcon->ctrl_cid != l2cap_cid) && (p_hcon->intr_cid != l2cap_cid))
- {
- HIDD_TRACE_WARNING1 ("HID - Rcvd L2CAP cfg ind, unknown CID: 0x%x", l2cap_cid);
- return;
- }
-
- /* config fail for unaccepted param, send reconfiguration */
- if (p_cfg->result == L2CAP_CFG_UNACCEPTABLE_PARAMS)
- {
- /* remember the host prefered config param in control block */
- p_l2cfg = (l2cap_cid == p_hcon->ctrl_cid)? &hd_cb.l2cap_ctrl_cfg : &hd_cb.l2cap_int_cfg ;
- memcpy(p_l2cfg, p_cfg, sizeof(tL2CAP_CFG_INFO));
-
- /* Send a second time configuration request. */
- L2CA_ConfigReq (l2cap_cid, p_l2cfg);
- return;
- }
- /* If configuration failed for other reason, disconnect the channel(s) */
- else if (p_cfg->result != L2CAP_CFG_OK)
- {
- reason = HID_L2CAP_CFG_FAIL | ((UINT32) p_cfg->result) ;
- hidd_conn_disconnect();
- hd_cb.conn_tries = HID_DEV_MAX_CONN_RETRY+1;
- hidd_mgmt_process_evt( HOST_CONN_FAIL, &reason ) ;
- return;
- }
-
- if (l2cap_cid == p_hcon->ctrl_cid)
- p_hcon->conn_flags |= HID_CONN_FLAGS_MY_CTRL_CFG_DONE;
- else
- p_hcon->conn_flags |= HID_CONN_FLAGS_MY_INTR_CFG_DONE;
-
- /* If all configuration is complete, change state and tell management we are up */
- if (((p_hcon->conn_flags & HID_CONN_FLAGS_ALL_CONFIGURED) == HID_CONN_FLAGS_ALL_CONFIGURED)
- && (p_hcon->conn_state == HID_CONN_STATE_CONFIG))
- {
- hidd_l2c_connected( p_hcon );
- }
-}
-
-
-/*******************************************************************************
-**
-** Function hidd_l2cif_disconnect_ind
-**
-** Description This function handles a disconnect event from L2CAP. If
-** requested to, we ack the disconnect before dropping the CCB
-**
-** Returns void
-**
-*******************************************************************************/
-static void hidd_l2cif_disconnect_ind (UINT16 l2cap_cid, BOOLEAN ack_needed)
-{
- tHID_CONN *p_hcon = &hd_cb.conn;
- UINT16 disc_res = HCI_PENDING ;
- UINT8 evt = HOST_CONN_CLOSE;
-
- /* Find CCB based on CID */
- if ((p_hcon->ctrl_cid != l2cap_cid) && (p_hcon->intr_cid != l2cap_cid))
- {
- HIDD_TRACE_WARNING1 ("HID - Rcvd L2CAP disc, unknown CID: 0x%x", l2cap_cid);
- return;
- }
-
- if (ack_needed)
- L2CA_DisconnectRsp (l2cap_cid);
-
- HIDD_TRACE_EVENT1 ("HID - Rcvd L2CAP disc, CID: 0x%x", l2cap_cid);
-
- p_hcon->conn_state = HID_CONN_STATE_DISCONNECTING;
-
- if (l2cap_cid == p_hcon->ctrl_cid)
- p_hcon->ctrl_cid = 0;
- else
- p_hcon->intr_cid = 0;
-
- if ((p_hcon->ctrl_cid == 0) && (p_hcon->intr_cid == 0))
- {
- if (!ack_needed)
- disc_res = btm_get_acl_disc_reason_code();
- HIDD_TRACE_EVENT1 ("disc_res: 0x%x", disc_res);
-
- if( disc_res == HCI_ERR_CONNECTION_TOUT || disc_res == HCI_ERR_UNSPECIFIED )
- evt = HOST_CONN_LOST;
-
- p_hcon->conn_state = HID_CONN_STATE_UNUSED;
- hidd_mgmt_process_evt( evt, &disc_res ) ;
-#if HID_DEV_PM_INCLUDED == TRUE
- hidd_pm_stop();
-#endif
- }
-}
-
-
-/*******************************************************************************
-**
-** Function hid_l2cif_disconnect_cfm
-**
-** Description This function handles a disconnect confirm event from L2CAP.
-**
-** Returns void
-**
-*******************************************************************************/
-static void hidd_l2cif_disconnect_cfm (UINT16 l2cap_cid, UINT16 result)
-{
- UINT16 disc_res = HCI_SUCCESS;
- tHID_CONN *p_hcon = &hd_cb.conn;
-
- /* Find CCB based on CID */
- if ((p_hcon->ctrl_cid != l2cap_cid) && (p_hcon->intr_cid != l2cap_cid))
- {
- HIDD_TRACE_WARNING1 ("HID - Rcvd L2CAP disc cfm, unknown CID: 0x%x", l2cap_cid);
- return;
- }
-
- HIDD_TRACE_EVENT1 ("HID - Rcvd L2CAP disc cfm, CID: 0x%x", l2cap_cid);
-
- if (l2cap_cid == p_hcon->ctrl_cid)
- p_hcon->ctrl_cid = 0;
- else
- p_hcon->intr_cid = 0;
-
- if ((p_hcon->ctrl_cid == 0) && (p_hcon->intr_cid == 0))
- {
- p_hcon->conn_state = HID_CONN_STATE_UNUSED;
- hidd_mgmt_process_evt( HOST_CONN_CLOSE, &disc_res ) ;
-#if HID_DEV_PM_INCLUDED == TRUE
- hidd_pm_stop();
-#endif
- }
-}
-
-
-/*******************************************************************************
-**
-** Function hidd_l2cif_cong_ind
-**
-** Description This function handles a congestion status event from L2CAP.
-**
-** Returns void
-**
-*******************************************************************************/
-static void hidd_l2cif_cong_ind (UINT16 l2cap_cid, BOOLEAN congested)
-{
- tHID_CONN *p_hcon = &hd_cb.conn;
-
- /* Find CCB based on CID */
- if ((p_hcon->ctrl_cid != l2cap_cid) && (p_hcon->intr_cid != l2cap_cid))
- {
- HIDD_TRACE_WARNING1 ("HID - Rcvd L2CAP congestion status, unknown CID: 0x%x", l2cap_cid);
- return;
- }
-
- HIDD_TRACE_EVENT2 ("HID - Rcvd L2CAP congestion status, CID: 0x%x Cong: %d", l2cap_cid, congested);
-
- if (congested)
- p_hcon->conn_flags |= HID_CONN_FLAGS_CONGESTED;
- else
- {
- p_hcon->conn_flags &= ~HID_CONN_FLAGS_CONGESTED;
- }
-
- hd_cb.callback( HID_DEV_EVT_L2CAP_CONGEST, (p_hcon->ctrl_cid == l2cap_cid), (tHID_DEV_CBACK_DATA*) &congested ) ;
-}
-
-
-/*******************************************************************************
-**
-** Function hid_l2cif_data_ind
-**
-** Description This function is called when data is received from L2CAP.
-** if we are the originator of the connection, we are the SDP
-** client, and the received message is queued up for the client.
-**
-** If we are the destination of the connection, we are the SDP
-** server, so the message is passed to the server processing
-** function.
-**
-** Returns void
-**
-*******************************************************************************/
-static void hidd_l2cif_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg)
-{
- tHID_CONN *p_hcon = &hd_cb.conn;
- UINT8 *p_data = (UINT8 *)(p_msg + 1) + p_msg->offset;
- UINT8 ttype, param, rep_type, idle_rate;
- tHID_DEV_GET_REP_DATA get_rep;
- BOOLEAN suspend = FALSE;
-
- /* Find CCB based on CID */
- if ((p_hcon->ctrl_cid != l2cap_cid) && (p_hcon->intr_cid != l2cap_cid))
- {
- HIDD_TRACE_WARNING1 ("HID - Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
- GKI_freebuf (p_msg);
- return;
- }
-
- ttype = HID_GET_TRANS_FROM_HDR(*p_data);
- param = HID_GET_PARAM_FROM_HDR(*p_data);
- rep_type = param & HID_PAR_REP_TYPE_MASK;
- p_data++;
-
- switch (ttype)
- {
- case HID_TRANS_CONTROL:
- switch (param)
- {
- case HID_PAR_CONTROL_NOP:
- case HID_PAR_CONTROL_HARD_RESET:
- case HID_PAR_CONTROL_SOFT_RESET:
- case HID_PAR_CONTROL_EXIT_SUSPEND:
- break;
-
- case HID_PAR_CONTROL_SUSPEND:
- suspend = TRUE;
-#if HID_DEV_PM_INCLUDED == TRUE
- hidd_pm_suspend_evt() ;
-#endif
- break;
-
- case HID_PAR_CONTROL_VIRTUAL_CABLE_UNPLUG:
- hidd_mgmt_process_evt( HID_API_DISCONNECT, NULL ) ;
- hd_cb.unplug_on = TRUE;
- break;
-
- default:
- GKI_freebuf (p_msg);
- HID_DevHandShake( HID_PAR_HANDSHAKE_RSP_ERR_INVALID_PARAM ) ;
- return;
- }
- hd_cb.callback( HID_DEV_EVT_CONTROL, param, NULL ) ;
- break;
-
- case HID_TRANS_GET_REPORT:
- if (param & HID_PAR_GET_REP_BUFSIZE_FOLLOWS)
- {
- STREAM_TO_UINT8 (get_rep.rep_id, p_data);
- STREAM_TO_UINT16 (hd_cb.get_rep_buf_sz, p_data);
- }
- else
- hd_cb.get_rep_buf_sz = 0;
-
- get_rep.rep_type = param & HID_PAR_REP_TYPE_MASK;
-
- hd_cb.callback( HID_DEV_EVT_GET_REPORT, param,
- (tHID_DEV_CBACK_DATA*) &get_rep ) ;
- break;
-
- case HID_TRANS_SET_REPORT:
- hd_cb.callback( HID_DEV_EVT_SET_REPORT, rep_type, (tHID_DEV_CBACK_DATA*) &p_msg ) ;
- break;
-
- case HID_TRANS_DATA:
- hd_cb.callback( HID_DEV_EVT_DATA, rep_type, (tHID_DEV_CBACK_DATA*) &p_msg ) ;
- break;
-
- case HID_TRANS_DATAC:
- hd_cb.callback( HID_DEV_EVT_DATC, rep_type, (tHID_DEV_CBACK_DATA*) &p_msg ) ;
- break;
-
- case HID_TRANS_GET_PROTOCOL:
- /* Get current protocol */
- hd_cb.callback( HID_DEV_EVT_GET_PROTO, 0, NULL ) ;
- break;
-
- case HID_TRANS_SET_PROTOCOL:
- hd_cb.callback( HID_DEV_EVT_SET_PROTO, (UINT32) (param & HID_PAR_PROTOCOL_MASK), NULL ) ;
- break;
-
- /* for HID 1.0 device only */
- case HID_TRANS_GET_IDLE:
- hd_cb.callback( HID_DEV_EVT_GET_IDLE, 0, NULL ) ;
- break;
-
- /* for HID 1.0 device only */
- case HID_TRANS_SET_IDLE:
- STREAM_TO_UINT8 (idle_rate, p_data);
- hd_cb.callback( HID_DEV_EVT_SET_IDLE, idle_rate, NULL ) ;
- break;
-
- default:
- GKI_freebuf (p_msg);
- HID_DevHandShake( HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ ) ;
- return;
- }
-
-#if HID_DEV_PM_INCLUDED == TRUE
- if( !suspend )
- hidd_pm_start();
-#endif
-
- if( (ttype != HID_TRANS_SET_REPORT) && (ttype != HID_TRANS_DATA) && (ttype != HID_TRANS_DATAC) )
- GKI_freebuf (p_msg);
- /* Else application frees the buffer */
-}
-
-/*******************************************************************************
-**
-** Function hidd_conn_snd_data
-**
-** Description This function is called to send HID data.
-**
-** Returns void
-**
-*******************************************************************************/
-tHID_STATUS hidd_conn_snd_data (tHID_SND_DATA_PARAMS *p_data)
-{
- tHID_CONN *p_hcon = &hd_cb.conn;
- BT_HDR *p_buf;
- UINT8 *p_out;
- UINT16 bytes_copied;
- BOOLEAN seg_req = FALSE;
- UINT16 data_size;
- UINT16 cid;
- UINT8 pool_id;
- UINT16 rem_mtu;
-
-#if HID_DEV_PM_INCLUDED == TRUE
- hidd_pm_start();
-#endif
-
- /* Safety check */
- if (p_data)
- {
- pool_id = (p_data->ctrl_ch) ? HID_CONTROL_POOL_ID : HID_INTERRUPT_POOL_ID;
- }
- else
- {
- HIDD_TRACE_ERROR0 ("HID_ERR_INVALID_PARAM");
- return HID_ERR_INVALID_PARAM;
- }
-
- if (p_hcon->conn_flags & HID_CONN_FLAGS_CONGESTED)
- {
- return( HID_ERR_CONGESTED );
- }
-
- if( (p_data->trans_type == HID_TRANS_DATA) && p_data->ctrl_ch && hd_cb.get_rep_buf_sz )
- {
- rem_mtu = hd_cb.get_rep_buf_sz;
- hd_cb.get_rep_buf_sz = 0;
- }
- else
- {
- rem_mtu = p_hcon->rem_mtu_size;
- }
-
- do
- {
- /* If buf is null form the HID message with ttype and params alone */
- if ( p_data->buf == NULL )
- {
- if((p_buf = (BT_HDR *)GKI_getpoolbuf (pool_id)) == NULL)
- return (HID_ERR_NO_RESOURCES);
-
- p_buf->offset = L2CAP_MIN_OFFSET;
- seg_req = FALSE;
- data_size = 0;
- bytes_copied = 0;
- }
- /* Segmentation case */
- else if ( (p_data->buf->len > (rem_mtu - 1)))
- {
- if((p_buf = (BT_HDR *)GKI_getpoolbuf (pool_id)) == NULL)
- return (HID_ERR_NO_RESOURCES);
-
- p_buf->offset = L2CAP_MIN_OFFSET;
- seg_req = TRUE;
- data_size = p_data->buf->len;
- bytes_copied = rem_mtu - 1;
- }
- else /* NOTE: The initial buffer gets used last */
- {
- p_buf = p_data->buf ;
- p_buf->offset -= 1;
- seg_req = FALSE;
- data_size = p_data->buf->len;
- bytes_copied = p_data->buf->len;
- }
-
- p_out = (UINT8 *)(p_buf + 1) + p_buf->offset;
- *p_out++ = HID_BUILD_HDR(p_data->trans_type, p_data->param);
-
- if (seg_req)
- {
- memcpy (p_out, (((UINT8 *)(p_data->buf+1)) + p_data->buf->offset), bytes_copied);
- p_data->buf->offset += bytes_copied;
- p_data->buf->len -= bytes_copied;
- }
-
- p_buf->len = bytes_copied + 1;
- data_size -= bytes_copied;
-
- cid = (p_data->ctrl_ch ? p_hcon->ctrl_cid : p_hcon->intr_cid);
- /* Send the buffer through L2CAP */
- if ((p_hcon->conn_flags & HID_CONN_FLAGS_CONGESTED) || (!L2CA_DataWrite (cid, p_buf)))
- {
- return (HID_ERR_CONGESTED);
- }
-
- if (data_size)
- p_data->trans_type = HID_TRANS_DATAC;
-
- } while (data_size != 0);
-
- if( bytes_copied == (rem_mtu - 1) )
- {
- tHID_SND_DATA_PARAMS datc;
-
- datc.buf = NULL;
- datc.ctrl_ch = p_data->ctrl_ch;
- datc.param = p_data->param ;
- datc.trans_type = HID_TRANS_DATAC ;
-
- hidd_conn_snd_data( &datc ) ;
- }
-
- return (HID_SUCCESS);
-}
-
diff --git a/stack/hid/hidd_int.h b/stack/hid/hidd_int.h
deleted file mode 100644
index 58d7a83..0000000
--- a/stack/hid/hidd_int.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************/
-/* */
-/* Name: hidd_int.h */
-/* */
-/* Function: this file contains HID DEVICE internal definitions */
-/* */
-/* */
-/* Copyright (c) 2002-2004, WIDCOMM Inc., All Rights Reserved. */
-/* WIDCOMM Bluetooth Core. Proprietary and confidential. */
-/* */
-/****************************************************************************/
-
-#ifndef HIDD_INT_H
-#define HIDD_INT_H
-#include "hidd_api.h"
-#include "hid_conn.h"
-#include "l2c_api.h"
-
-/* Define the possible events of the HID Device state machine.
-*/
-enum
-{
- HOST_CONN_OPEN,
- HOST_CONN_CLOSE,
- HOST_CONN_LOST,
- HOST_CONN_FAIL,
- HID_API_CONNECT,
- HID_API_DISCONNECT,
- HID_API_SEND_DATA
-};
-
-/* Define the possible states of the HID Device.
-*/
-enum
-{
- HID_DEV_ST_NO_CONN,
- HID_DEV_ST_CONNECTING,
- HID_DEV_ST_CONNECTED,
- HID_DEV_ST_DISC_ING
-};
-
-/* To remember the power mode and setting */
-typedef struct curr_pm_setting
-{
- UINT8 mode;
- UINT16 interval;
-} tHID_DEV_PM_CURR;
-
-/* Define the HID management control block.
-*/
-typedef struct hid_control_block
-{
- BD_ADDR host_addr; /* BD-Addr of the host device */
- BOOLEAN host_known; /* Mode */
- BOOLEAN virtual_cable;/* If the device is to behave as virtual cable */
- UINT8 dev_state; /* Device state if in HOST-KNOWN mode */
- UINT8 conn_tries; /* Remembers to the number of connection attempts while CONNECTING */
- UINT8 sec_mask;
- UINT16 get_rep_buf_sz;
- tHID_CONN conn; /* L2CAP channel info */
-
-#if HID_DEV_PM_INCLUDED == TRUE
- TIMER_LIST_ENT idle_tle; /* Timer used for inactivity timing */
- tHID_DEV_PM_PWR_MD pm_params[3]; /* Power management parameters for the three possible states */
- tHID_DEV_PM_CURR curr_pm; /* Current power mode */
- BOOLEAN pm_ctrl_busy;/* A power mode transition is going on */
- UINT8 conn_substate;
- tHID_DEV_PM_PWR_MD final_pm;/* To remember the power mode while a power mode change is ongoing */
-#endif
-
- BOOLEAN use_qos_flg; /* Qos information provided by application or not */
- BOOLEAN unplug_on; /* Virtual unplug has been sent or received */
- tHID_DEV_QOS_INFO qos_info; /* Storage for QoS provided by application */
-
- tHID_DEV_CALLBACK *callback; /* Application callbacks */
- tL2CAP_CFG_INFO l2cap_ctrl_cfg; /* Configuration data for control channel */
- tL2CAP_CFG_INFO l2cap_int_cfg; /* Configuration data for interrupt channel */
- BOOLEAN reg_flag;
- UINT8 trace_level;
-} tHIDDEV_CB;
-
-typedef struct snd_data_params
-{
- BOOLEAN ctrl_ch; /* TRUE if control channel, FALSE if interrupt */
- UINT8 trans_type; /* Transaction type */
- UINT8 param; /* Second byte after trans type */
- BT_HDR *buf ; /* Data that comes after param */
-} tHID_SND_DATA_PARAMS; /* Is defined for hidd_conn_snd_data */
-
-/* HID management function prototype
-*/
-typedef tHID_STATUS (tHIDD_MGMT_EVT_HDLR) (UINT8, void *);
-
-/* HID Globals
-*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/******************************************************************************
-** Main Control Block
-*******************************************************************************/
-#if HID_DYNAMIC_MEMORY == FALSE
-HID_API extern tHIDDEV_CB hd_cb;
-#else
-HID_API extern tHIDDEV_CB *hidd_cb_ptr;
-#define hd_cb (*hidd_cb_ptr)
-#endif
-
-extern tHID_STATUS hidd_conn_reg (void);
-extern void hidd_conn_dereg( void );
-extern tHID_STATUS hidd_conn_initiate (void);
-extern void hidd_conn_disconnect (void);
-extern tHID_STATUS hidd_conn_snd_data (tHID_SND_DATA_PARAMS *p_data);
-
-extern tHID_STATUS hidd_mgmt_process_evt( UINT8 event, void *data );
-extern void hidd_proc_repage_timeout (TIMER_LIST_ENT *p_tle);
-
-#if HID_DEV_PM_INCLUDED == TRUE
-extern tHID_STATUS hidd_pm_start( void ) ;
-extern tHID_STATUS hidd_pm_stop( void );
-extern tHID_STATUS hidd_pm_activity_evt( void );
-extern tHID_STATUS hidd_pm_suspend_evt( void );
-extern tHID_STATUS hidd_pm_unsuspend_evt( void );
-extern void hidd_pm_init( void );
-extern BOOLEAN hidd_pm_set_power_mode( tHID_DEV_PM_PWR_MD *pm) ;
-
-extern void hidd_pm_proc_mode_change( UINT8 hci_status, UINT8 mode, UINT16 interval );
-#endif /* HID_DEV_PM_INCLUDED == TRUE */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/stack/hid/hidd_mgmt.c b/stack/hid/hidd_mgmt.c
deleted file mode 100644
index 819dd11..0000000
--- a/stack/hid/hidd_mgmt.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/*****************************************************************************/
-/* */
-/* Name: hidd_mgmt.c */
-/* */
-/* Description: this file contains the HID Device Management logic */
-/* */
-/* NOTE: In the interest of keeping code small, there is an */
-/* inherent assumption that L2CAP always runs a timer, */
-/* and so the HID management never needs a timer on L2CAP */
-/* actions like connect and disconnect. */
-/* */
-/* */
-/* Copyright (c) 2002-2004, WIDCOMM Inc., All Rights Reserved. */
-/* WIDCOMM Bluetooth Core. Proprietary and confidential. */
-/*****************************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "gki.h"
-#include "bt_types.h"
-#include "hidd_api.h"
-#include "hiddefs.h"
-#include "hidd_int.h"
-#include "btu.h"
-#include "btm_api.h"
-
-
-/********************************************************************************/
-/* L O C A L F U N C T I O N P R O T O T Y P E S */
-/********************************************************************************/
-static tHID_STATUS hidd_no_conn_proc_evt( UINT8 event, void *p_data );
-static tHID_STATUS hidd_connecting_proc_evt( UINT8 event, void *p_data );
-static tHID_STATUS hidd_connected_proc_evt( UINT8 event, void *p_data );
-static tHID_STATUS hidd_disc_ing_proc_evt( UINT8 event, void *p_data );
-
-
-/* State machine jump table.
-*/
-tHIDD_MGMT_EVT_HDLR * const hidd_sm_proc_evt[] =
-{
- hidd_no_conn_proc_evt,
- hidd_connecting_proc_evt,
- hidd_connected_proc_evt,
- hidd_disc_ing_proc_evt
-};
-
-/* Main HID control block */
-#if HID_DYNAMIC_MEMORY == FALSE
-tHIDDEV_CB hd_cb;
-#endif
-
-/*******************************************************************************
-**
-** Function hidd_mgmt_process_evt
-**
-** Description This function is called by other modules to report an event
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS hidd_mgmt_process_evt( UINT8 event, void *p_data )
-{
- HIDD_TRACE_DEBUG3("hidd_mgmt_process_evt known: %d, s:%d, e:%d",
- hd_cb.host_known, hd_cb.dev_state, event);
- if( hd_cb.host_known )
- {
- return ((hidd_sm_proc_evt[hd_cb.dev_state]) (event, p_data)); /* Event is passed to main State Machine */
- }
-
- if( event == HOST_CONN_OPEN )
- {
- hd_cb.host_known = TRUE;
- memcpy( hd_cb.host_addr, (BD_ADDR *) p_data, BD_ADDR_LEN ) ;
- hd_cb.dev_state = HID_DEV_ST_CONNECTED ;
- /* Call-Back the Application with this information */
- hd_cb.callback(HID_DEV_EVT_OPEN, 0, (tHID_DEV_CBACK_DATA *) hd_cb.host_addr ) ;
- return( HID_SUCCESS );
- }
-
- return( HID_ERR_HOST_UNKNOWN );
-}
-
-/*******************************************************************************
-**
-** Function hidd_no_conn_proc_evt
-**
-** Description NO-CONN state event handler.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-static tHID_STATUS hidd_no_conn_proc_evt( UINT8 event, void *p_data )
-{
- tHID_STATUS st = HID_SUCCESS;
-
- switch( event )
- {
- case HOST_CONN_OPEN:
- hd_cb.dev_state = HID_DEV_ST_CONNECTED ;
- hd_cb.callback(HID_DEV_EVT_OPEN, 0, (tHID_DEV_CBACK_DATA *) hd_cb.host_addr ) ;
- break;
- case HID_API_CONNECT:
- hd_cb.conn_tries = 1;
- hd_cb.dev_state = HID_DEV_ST_CONNECTING ;
- if( (st = hidd_conn_initiate()) != HID_SUCCESS )
- {
-#if HID_DEV_MAX_CONN_RETRY > 0
- btu_start_timer (&(hd_cb.conn.timer_entry), BTU_TTYPE_USER_FUNC, HID_DEV_REPAGE_WIN);
- return HID_SUCCESS;
-#else
- hd_cb.dev_state = HID_DEV_ST_NO_CONN ;
-#endif
- }
- break;
- default:
- st = HID_ERR_NO_CONNECTION;
- }
-
- return st;
-}
-
-/*******************************************************************************
-**
-** Function hidd_proc_repage_timeout
-**
-** Description function to handle timeout.
-**
-** Returns void
-**
-*******************************************************************************/
-void hidd_proc_repage_timeout (TIMER_LIST_ENT *p_tle)
-{
- HIDD_TRACE_DEBUG0 ("hidd_proc_repage_timeout");
- hd_cb.conn_tries++;
- if( hidd_conn_initiate() != HID_SUCCESS )
- {
- if( hd_cb.conn_tries > HID_DEV_MAX_CONN_RETRY )
- {
- hd_cb.dev_state = HID_DEV_ST_NO_CONN ;
- hd_cb.callback(HID_DEV_EVT_CLOSE, 0, NULL );
- }
- else
- btu_start_timer (&(hd_cb.conn.timer_entry), BTU_TTYPE_USER_FUNC, HID_DEV_REPAGE_WIN);
- }
- else
- hd_cb.callback( HID_DEV_EVT_RETRYING, hd_cb.conn_tries, NULL );
-}
-
-/*******************************************************************************
-**
-** Function hidd_connecting_proc_evt
-**
-** Description CONNECTING state event handler
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-static tHID_STATUS hidd_connecting_proc_evt( UINT8 event, void *p_data )
-{
- switch( event )
- {
- case HOST_CONN_OPEN:
- hd_cb.dev_state = HID_DEV_ST_CONNECTED ;
- hd_cb.callback(HID_DEV_EVT_OPEN, 0, (tHID_DEV_CBACK_DATA *) hd_cb.host_addr ) ;
- break;
-
- case HOST_CONN_FAIL:
- if( hd_cb.conn_tries > HID_DEV_MAX_CONN_RETRY )
- {
- UINT16 reason = *( (UINT16 *) p_data);
-
- hd_cb.dev_state = HID_DEV_ST_NO_CONN;
- hd_cb.callback(HID_DEV_EVT_CLOSE, reason, NULL );
- }
-#if HID_DEV_MAX_CONN_RETRY > 0
- else
- {
- btu_start_timer (&(hd_cb.conn.timer_entry), BTU_TTYPE_USER_FUNC, HID_DEV_REPAGE_WIN);
- }
-#endif
- break;
-
- case HOST_CONN_CLOSE:
- case HOST_CONN_LOST:
- hd_cb.dev_state = HID_DEV_ST_NO_CONN;
- hd_cb.callback(HID_DEV_EVT_CLOSE, *((UINT16 *) p_data), NULL );
- break;
-
- case HID_API_DISCONNECT:
- hd_cb.dev_state = HID_DEV_ST_NO_CONN ;
- btu_stop_timer (&(hd_cb.conn.timer_entry));
- hidd_conn_disconnect();
- break;
-
- default:
- return( HID_ERR_CONN_IN_PROCESS ) ;
- }
-
- return (HID_SUCCESS);
-}
-
-/*******************************************************************************
-**
-** Function hidd_mgmt_conn_closed
-**
-** Description Called when l2cap channels have been released
-**
-** Returns void
-**
-*******************************************************************************/
-void hidd_mgmt_conn_closed( UINT16 reason )
-{
- if( hd_cb.unplug_on )
- {
- hd_cb.host_known = FALSE; /* This allows the device to accept connection from other hosts */
- }
-
- hd_cb.dev_state = HID_DEV_ST_NO_CONN;
- hd_cb.callback(HID_DEV_EVT_CLOSE, reason, NULL );
-}
-
-/*******************************************************************************
-**
-** Function hidd_connected_proc_evt
-**
-** Description CONNECTED state event handler
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-static tHID_STATUS hidd_connected_proc_evt( UINT8 event, void *p_data )
-{
- switch( event )
- {
- case HOST_CONN_LOST:
-#if HID_DEV_RECONN_INITIATE == TRUE
- hd_cb.dev_state = HID_DEV_ST_CONNECTING ;
- hd_cb.conn_tries = 0;
- btu_start_timer (&(hd_cb.conn.timer_entry), BTU_TTYPE_USER_FUNC, HID_DEV_REPAGE_WIN);
-#else
- hidd_mgmt_conn_closed( *((UINT16 *) p_data) ) ;
-#endif
- break;
- case HOST_CONN_CLOSE:
- hidd_mgmt_conn_closed( *((UINT16 *) p_data) ) ;
- break;
- case HID_API_DISCONNECT:
- hd_cb.dev_state = HID_DEV_ST_DISC_ING ;
- hidd_conn_disconnect();
- break;
- case HID_API_SEND_DATA: /*Send Input reports, handshake or virtual-unplug */
- return hidd_conn_snd_data( (tHID_SND_DATA_PARAMS *) p_data );
- default:
- return( HID_ERR_ALREADY_CONN ) ;
- }
-
- return( HID_SUCCESS );
-}
-
-/*******************************************************************************
-**
-** Function hidd_disc_ing_proc_evt
-**
-** Description DISCONNECTING state event handler
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-static tHID_STATUS hidd_disc_ing_proc_evt( UINT8 event, void *p_data )
-{
- switch( event )
- {
- case HOST_CONN_LOST:
- case HOST_CONN_FAIL:
- case HOST_CONN_CLOSE:
- hidd_mgmt_conn_closed( *((UINT16 *) p_data) ) ;
- break;
- default:
- return( HID_ERR_DISCONNECTING ) ;
- }
-
- return( HID_SUCCESS );
-}
-
-
diff --git a/stack/hid/hidd_pm.c b/stack/hid/hidd_pm.c
deleted file mode 100644
index ff3cc22..0000000
--- a/stack/hid/hidd_pm.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*****************************************************************************/
-/* */
-/* Name: hidd_pm.c */
-/* */
-/* Description: this file contains the HID Device Power Management logic */
-/* */
-/* */
-/* Copyright (c) 2002-2004, WIDCOMM Inc., All Rights Reserved. */
-/* WIDCOMM Bluetooth Core. Proprietary and confidential. */
-/*****************************************************************************/
-
-
-#include "gki.h"
-#include "bt_types.h"
-#include "hiddefs.h"
-#include "btm_api.h"
-#include "string.h"
-
-#include "hiddefs.h"
-
-#include "hidd_api.h"
-#include "hidd_int.h"
-#include "btu.h"
-
-#if HID_DEV_PM_INCLUDED == TRUE
-
-/*******************************************************************************
-**
-** Function hidd_pm_init
-**
-** Description This function is called when connection is established. It
-** initializes the control block for power management.
-**
-** Returns void
-**
-*******************************************************************************/
-
-static const tHID_DEV_PM_PWR_MD pwr_modes[] =
-{
- HID_DEV_BUSY_MODE_PARAMS,
- HID_DEV_IDLE_MODE_PARAMS,
- HID_DEV_SUSP_MODE_PARAMS
-};
-
-void hidd_pm_init( void )
-{
- int i;
-
- hd_cb.curr_pm.mode = HCI_MODE_ACTIVE ;
- hd_cb.final_pm.mode = 0xff;
-
- for( i=0; i<3; i++ )
- memcpy( &hd_cb.pm_params[i], &pwr_modes[i], sizeof( tHID_DEV_PM_PWR_MD ) ) ;
-
- hd_cb.pm_ctrl_busy = FALSE;
-}
-
-/*******************************************************************************
-**
-** Function hidd_pm_set_now
-**
-** Description This drives the BTM for power management settings.
-**
-** Returns TRUE if Success, FALSE otherwise
-**
-*******************************************************************************/
-BOOLEAN hidd_pm_set_now( tHID_DEV_PM_PWR_MD *p_req_mode)
-{
- tHID_DEV_PM_PWR_MD act_pm = { 0, 0, 0, 0, HCI_MODE_ACTIVE } ;
- UINT8 st = BTM_SUCCESS;
-
- /* Do nothing if already in required state or already performing a pm function */
- if( (hd_cb.pm_ctrl_busy) ||
- ((p_req_mode->mode == hd_cb.curr_pm.mode) && ( (p_req_mode->mode == HCI_MODE_ACTIVE) ||
- ((hd_cb.curr_pm.interval >= p_req_mode->min) && (hd_cb.curr_pm.interval <= p_req_mode->max)) )) )
- {
- hd_cb.final_pm.mode = 0xff;
- return TRUE;
- }
-
- switch( p_req_mode->mode )
- {
- case HCI_MODE_ACTIVE:
- if( hd_cb.curr_pm.mode == HCI_MODE_SNIFF )
- {
-#if BTM_PWR_MGR_INCLUDED == TRUE
- st = BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, hd_cb.host_addr, (tBTM_PM_PWR_MD *) &act_pm);
-#else
- st = BTM_CancelSniffMode (hd_cb.host_addr);
-#endif
- hd_cb.pm_ctrl_busy = TRUE;
- }
- else if( hd_cb.curr_pm.mode == HCI_MODE_PARK )
- {
-#if BTM_PWR_MGR_INCLUDED == TRUE
- st = BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, hd_cb.host_addr, (tBTM_PM_PWR_MD *) &act_pm);
-#else
- st = BTM_CancelParkMode (hd_cb.host_addr);
-#endif
- hd_cb.pm_ctrl_busy = TRUE;
- }
- break;
-
- case HCI_MODE_SNIFF:
- if( hd_cb.curr_pm.mode != HCI_MODE_ACTIVE ) /* Transition through active state required */
- hidd_pm_set_now (&act_pm);
- else
- {
-#if BTM_PWR_MGR_INCLUDED == TRUE
- st = BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, hd_cb.host_addr, (tBTM_PM_PWR_MD *) p_req_mode);
-#else
- st = BTM_SetSniffMode (hd_cb.host_addr, p_req_mode->min, p_req_mode->max, p_req_mode->attempt, p_req_mode->timeout);
-#endif
- hd_cb.pm_ctrl_busy = TRUE;
- }
- break;
-
- case HCI_MODE_PARK:
- if( hd_cb.curr_pm.mode != HCI_MODE_ACTIVE ) /* Transition through active state required */
- hidd_pm_set_now (&act_pm);
- else
- {
-#if BTM_PWR_MGR_INCLUDED == TRUE
- st = BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, hd_cb.host_addr, (tBTM_PM_PWR_MD *) p_req_mode);
-#else
- st = BTM_SetParkMode (hd_cb.host_addr, p_req_mode->min, p_req_mode->max);
-#endif
- hd_cb.pm_ctrl_busy = TRUE;
- }
- break;
-
- default:
- break;
- }
-
- if( st == BTM_SUCCESS || st == BTM_CMD_STARTED )
- return TRUE;
- else
- {
- st += HCI_ERR_MAX_ERR ;
- if( hd_cb.callback )
- hd_cb.callback( HID_DEV_EVT_PM_FAILED, hd_cb.conn_substate, (tHID_DEV_CBACK_DATA *) &st ) ;
- return FALSE;
- }
-}
-
-/*******************************************************************************
-**
-** Function hidd_pm_set_power_mode
-**
-** Description This stores the power management setting and calls fn to set
-** the power.
-**
-** Returns TRUE if Success, FALSE otherwise
-**
-*******************************************************************************/
-BOOLEAN hidd_pm_set_power_mode( tHID_DEV_PM_PWR_MD *p_req_mode)
-{
- memcpy( &hd_cb.final_pm, p_req_mode, sizeof( tHID_DEV_PM_PWR_MD ) ) ;
- return hidd_pm_set_now( p_req_mode ) ;
-}
-
-
-/*******************************************************************************
-**
-** Function hidd_pm_proc_mode_change
-**
-** Description This is the callback function, when power mode changes.
-**
-** Returns void
-**
-*******************************************************************************/
-void hidd_pm_proc_mode_change( UINT8 hci_status, UINT8 mode, UINT16 interval )
-{
- if (!hd_cb.reg_flag )
- return;
-
- hd_cb.pm_ctrl_busy = FALSE;
-
- if( hci_status != HCI_SUCCESS )
- {
- if( hd_cb.callback )
- hd_cb.callback( HID_DEV_EVT_PM_FAILED, hd_cb.conn_substate, (tHID_DEV_CBACK_DATA *) &hci_status ) ;
- }
- else
- {
- hd_cb.curr_pm.mode = mode;
- hd_cb.curr_pm.interval = interval;
-
- if( hd_cb.final_pm.mode != 0xff )
- {
- /* If we haven't reached the final power mode, set it now */
- if( (hd_cb.final_pm.mode != hd_cb.curr_pm.mode) ||
- ( (hd_cb.final_pm.mode != HCI_MODE_ACTIVE) &&
- ((hd_cb.curr_pm.interval < hd_cb.final_pm.min) || (hd_cb.curr_pm.interval > hd_cb.final_pm.max))
- ) )
- {
- hidd_pm_set_now( &(hd_cb.final_pm) ) ;
- }
- else
- hd_cb.final_pm.mode = 0xff;
- }
- else
- {
- if( hd_cb.curr_pm.mode == HCI_MODE_ACTIVE )
- hidd_pm_start();
- }
-
- if( hd_cb.callback )
- hd_cb.callback( HID_DEV_EVT_MODE_CHG, mode, (tHID_DEV_CBACK_DATA *) &interval) ;
- }
-}
-
-
-/*******************************************************************************
-**
-** Function hidd_pm_inact_timeout
-**
-** Description Called when idle timer expires.
-**
-** Returns void
-**
-*******************************************************************************/
-void hidd_pm_inact_timeout (TIMER_LIST_ENT *p_tle)
-{
- hidd_pm_set_power_mode ( &(hd_cb.pm_params[HID_DEV_IDLE_CONN_ST]));
- hd_cb.conn_substate = HID_DEV_IDLE_CONN_ST;
-}
-
-/*******************************************************************************
-**
-** Function hidd_pm_start
-**
-** Description Starts the power management function in a given state.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS hidd_pm_start( void )
-{
- hidd_pm_set_power_mode ( &(hd_cb.pm_params[HID_DEV_BUSY_CONN_ST]) );
-
- hd_cb.conn_substate = HID_DEV_BUSY_CONN_ST;
-
- hd_cb.idle_tle.param = (UINT32) hidd_pm_inact_timeout;
- btu_start_timer (&hd_cb.idle_tle, BTU_TTYPE_USER_FUNC, HID_DEV_INACT_TIMEOUT);
-
- return( HID_SUCCESS );
-}
-
-/*******************************************************************************
-**
-** Function hidd_pm_stop
-**
-** Description Stops the idle timer.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS hidd_pm_stop( void )
-{
- tHID_DEV_PM_PWR_MD p_md = { 0, 0, 0, 0, HCI_MODE_ACTIVE };
-
- hidd_pm_set_power_mode( &p_md );
- btu_stop_timer( &hd_cb.idle_tle ) ;
- return( HID_SUCCESS );
-}
-
-
-/*******************************************************************************
-**
-** Function hidd_pm_suspend_evt
-**
-** Description Called when host suspends the device.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-tHID_STATUS hidd_pm_suspend_evt( void )
-{
- if( hd_cb.conn_substate == HID_DEV_BUSY_CONN_ST )
- btu_stop_timer( &hd_cb.idle_tle ) ;
-
- hidd_pm_set_power_mode ( &(hd_cb.pm_params[HID_DEV_SUSP_CONN_ST]) );
- hd_cb.conn_substate = HID_DEV_SUSP_CONN_ST;
- return( HID_SUCCESS );
-}
-#endif /* HID_DEV_PM_INCLUDED == TRUE */
diff --git a/stack/include/a2d_m12.h b/stack/include/a2d_m12.h
deleted file mode 100644
index 2cc5ef9..0000000
--- a/stack/include/a2d_m12.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*****************************************************************************
-**
-** Name: a2d_m12.h
-**
-** Description:Interface to MPEG-1, 2 Audio
-**
-** Copyright (c) 2000-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef A2D_M12_H
-#define A2D_M12_H
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-/* the length of the MPEG_1, 2 Audio Media Payload header. */
-#define A2D_M12_MPL_HDR_LEN 4
-
-/* the LOSC of MPEG_1, 2 Audio media codec capabilitiy */
-#define A2D_M12_INFO_LEN 6
-
-/* for Codec Specific Information Element */
-#define A2D_M12_IE_LAYER_MSK 0xE0 /* b7-b5 layer */
-#define A2D_M12_IE_LAYER1 0x80 /* b7: layer1 (mp1) */
-#define A2D_M12_IE_LAYER2 0x40 /* b6: layer2 (mp2) */
-#define A2D_M12_IE_LAYER3 0x20 /* b5: layer3 (mp3) */
-
-#define A2D_M12_IE_CRC_MSK 0x10 /* b4: CRC */
-
-#define A2D_M12_IE_CH_MD_MSK 0x0F /* b3-b0 channel mode */
-#define A2D_M12_IE_CH_MD_MONO 0x08 /* b3: mono */
-#define A2D_M12_IE_CH_MD_DUAL 0x04 /* b2: dual */
-#define A2D_M12_IE_CH_MD_STEREO 0x02 /* b1: stereo */
-#define A2D_M12_IE_CH_MD_JOINT 0x01 /* b0: joint stereo */
-
-#define A2D_M12_IE_MPF_MSK 0x40 /* b6: MPF */
-
-#define A2D_M12_IE_SAMP_FREQ_MSK 0x3F /* b5-b0 sampling frequency */
-#define A2D_M12_IE_SAMP_FREQ_16 0x20 /* b5:16 kHz */
-#define A2D_M12_IE_SAMP_FREQ_22 0x10 /* b4:22.05kHz */
-#define A2D_M12_IE_SAMP_FREQ_24 0x08 /* b3:24 kHz */
-#define A2D_M12_IE_SAMP_FREQ_32 0x04 /* b2:32 kHz */
-#define A2D_M12_IE_SAMP_FREQ_44 0x02 /* b1:44.1kHz */
-#define A2D_M12_IE_SAMP_FREQ_48 0x01 /* b0:48 kHz */
-
-#define A2D_M12_IE_VBR_MSK 0x80 /* b7: VBR */
-
-#define A2D_M12_IE_BITRATE_MSK 0x7FFF /* b6-b0 of octect 2, all of octect3*/
-#define A2D_M12_IE_BITRATE_0 0x0001 /* 0000 */
-#define A2D_M12_IE_BITRATE_1 0x0002 /* 0001 */
-#define A2D_M12_IE_BITRATE_2 0x0004 /* 0010 */
-#define A2D_M12_IE_BITRATE_3 0x0008 /* 0011 */
-#define A2D_M12_IE_BITRATE_4 0x0010 /* 0100 */
-#define A2D_M12_IE_BITRATE_5 0x0020 /* 0101 */
-#define A2D_M12_IE_BITRATE_6 0x0040 /* 0110 */
-#define A2D_M12_IE_BITRATE_7 0x0080 /* 0111 */
-#define A2D_M12_IE_BITRATE_8 0x0100 /* 1000 */
-#define A2D_M12_IE_BITRATE_9 0x0200 /* 1001 */
-#define A2D_M12_IE_BITRATE_10 0x0400 /* 1010 */
-#define A2D_M12_IE_BITRATE_11 0x0800 /* 1011 */
-#define A2D_M12_IE_BITRATE_12 0x1000 /* 1100 */
-#define A2D_M12_IE_BITRATE_13 0x2000 /* 1101 */
-#define A2D_M12_IE_BITRATE_14 0x4000 /* 1110 */
-
-#define A2D_BLD_M12_PML_HDR(p_dst,frag_offset) {UINT16_TO_BE_STREAM(p_dst, 0); \
- UINT16_TO_BE_STREAM(p_dst, frag_offset); }
-
-#define A2D_PARS_M12_PML_HDR(p_src,frag_offset) {BE_STREAM_TO_UINT16(frag_offset, p_src); \
- BE_STREAM_TO_UINT16(frag_offset, p_src); }
-
-
-/*****************************************************************************
-** Type Definitions
-*****************************************************************************/
-
-/* data type for the MPEG-1, 2 Audio Codec Information Element*/
-typedef struct
-{
- UINT8 layer; /* layers */
- BOOLEAN crc; /* Support of CRC protection or not */
- UINT8 ch_mode; /* Channel mode */
- UINT8 mpf; /* 1, if MPF-2 is supported. 0, otherwise */
- UINT8 samp_freq; /* Sampling frequency */
- BOOLEAN vbr; /* Variable Bit Rate */
- UINT16 bitrate; /* Bit rate index */
-} tA2D_M12_CIE;
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/******************************************************************************
-**
-** Function A2D_BldM12Info
-**
-** Description This function is called by an application to build
-** the MPEG-1, 2 Audio Media Codec Capabilities byte sequence
-** beginning from the LOSC octet.
-** Input Parameters:
-** media_type: Indicates Audio, or Multimedia.
-**
-** p_ie: The MPEG-1, 2 Audio Codec Information Element
-** information.
-**
-** Output Parameters:
-** p_result: the resulting codec info byte sequence.
-**
-** Returns A2D_SUCCESS if function execution succeeded.
-** Error status code, otherwise.
-******************************************************************************/
-A2D_API extern tA2D_STATUS A2D_BldM12Info(UINT8 media_type, tA2D_M12_CIE *p_ie,
- UINT8 *p_result);
-
-/******************************************************************************
-**
-** Function A2D_ParsM12Info
-**
-** Description This function is called by an application to parse
-** the MPEG-1, 2 Audio Media Codec Capabilities byte sequence
-** beginning from the LOSC octet.
-** Input Parameters:
-** p_info: the byte sequence to parse.
-**
-** for_caps: TRUE, if the byte sequence is for get capabilities
-** response.
-**
-** Output Parameters:
-** p_ie: The MPEG-1, 2 Audio Codec Information Element
-** information.
-**
-** Returns A2D_SUCCESS if function execution succeeded.
-** Error status code, otherwise.
-******************************************************************************/
-A2D_API extern tA2D_STATUS A2D_ParsM12Info(tA2D_M12_CIE *p_ie, UINT8 *p_info,
- BOOLEAN for_caps);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* A2D_M12_H */
diff --git a/stack/include/a2d_m24.h b/stack/include/a2d_m24.h
deleted file mode 100644
index 0417a57..0000000
--- a/stack/include/a2d_m24.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*****************************************************************************
-**
-** Name: a2d_m24.h
-**
-** Description:Interface to MPEG-2, 4 Aac
-**
-** Copyright (c) 2000-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef A2D_M24_H
-#define A2D_M24_H
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-/* the LOSC of MPEG_2, 4 AAC media codec capabilitiy */
-#define A2D_M24_INFO_LEN 8
-
-/* for Codec Specific Information Element */
-#define A2D_M24_IE_OBJ_MSK 0xF0 /* b7-b4 object type. b3-b0 is RFA,not used */
-#define A2D_M24_IE_OBJ_2LC 0x80 /* b7: MPEG-2 AAC LC */
-#define A2D_M24_IE_OBJ_4LC 0x40 /* b6: MPEG-4 AAC LC */
-#define A2D_M24_IE_OBJ_4LTP 0x20 /* b5: MPEG-4 AAC LTP */
-#define A2D_M24_IE_OBJ_4S 0x10 /* b4: MPEG-4 AAC scalable */
-
-#define A2D_M24_IE_SAMP_FREQ_MSK 0xFFF0 /* sampling frequency */
-#define A2D_M24_IE_SAMP_FREQ_8 0x8000 /* b7:8 kHz */
-#define A2D_M24_IE_SAMP_FREQ_11 0x4000 /* b6:11 kHz */
-#define A2D_M24_IE_SAMP_FREQ_12 0x2000 /* b5:12 kHz */
-#define A2D_M24_IE_SAMP_FREQ_16 0x1000 /* b4:16 kHz */
-#define A2D_M24_IE_SAMP_FREQ_22 0x0800 /* b3:22.05kHz */
-#define A2D_M24_IE_SAMP_FREQ_24 0x0400 /* b2:24 kHz */
-#define A2D_M24_IE_SAMP_FREQ_32 0x0200 /* b1:32 kHz */
-#define A2D_M24_IE_SAMP_FREQ_44 0x0100 /* b0:44.1kHz */
-#define A2D_M24_IE_SAMP_FREQ_48 0x0080 /* b7:48 kHz */
-#define A2D_M24_IE_SAMP_FREQ_64 0x0040 /* b6:64 kHz */
-#define A2D_M24_IE_SAMP_FREQ_88 0x0020 /* b5:88 kHz */
-#define A2D_M24_IE_SAMP_FREQ_96 0x0010 /* b4:96 kHz */
-
-#define A2D_M24_IE_CHNL_MSK 0x0C /* b3-b2 channels */
-#define A2D_M24_IE_CHNL_1 0x08 /* b3: 1 channel */
-#define A2D_M24_IE_CHNL_2 0x04 /* b2: 2 channels */
-
-#define A2D_M24_IE_VBR_MSK 0x80 /* b7: VBR */
-
-#define A2D_M24_IE_BITRATE3_MSK 0x7F0000 /* octect3*/
-#define A2D_M24_IE_BITRATE45_MSK 0x00FFFF /* octect4, 5*/
-#define A2D_M24_IE_BITRATE_MSK 0x7FFFFF /* b7-b0 of octect 3, all of octect4, 5*/
-
-
-/*****************************************************************************
-** Type Definitions
-*****************************************************************************/
-
-/* data type for the MPEG-2, 4 AAC Codec Information Element*/
-typedef struct
-{
- UINT8 obj_type; /* Object type */
- UINT16 samp_freq; /* Sampling frequency */
- UINT8 chnl; /* Channel mode */
- BOOLEAN vbr; /* Variable Bit Rate */
- UINT32 bitrate; /* Bit rate index */
-} tA2D_M24_CIE;
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/******************************************************************************
-**
-** Function A2D_BldM24Info
-**
-** Description This function is called by an application to build
-** the MPEG-2, 4 AAC Media Codec Capabilities byte sequence
-** beginning from the LOSC octet.
-** Input Parameters:
-** media_type: Indicates Audio, or Multimedia.
-**
-** p_ie: MPEG-2, 4 AAC Codec Information Element information.
-**
-** Output Parameters:
-** p_result: the resulting codec info byte sequence.
-**
-** Returns A2D_SUCCESS if function execution succeeded.
-** Error status code, otherwise.
-******************************************************************************/
-A2D_API extern tA2D_STATUS A2D_BldM24Info(UINT8 media_type, tA2D_M24_CIE *p_ie,
- UINT8 *p_result);
-
-/******************************************************************************
-**
-** Function A2D_ParsM24Info
-**
-** Description This function is called by an application to parse
-** the MPEG-2, 4 AAC Media Codec Capabilities byte sequence
-** beginning from the LOSC octet.
-** Input Parameters:
-** p_info: the byte sequence to parse.
-**
-** for_caps: TRUE, if the byte sequence is for get
-** capabilities response.
-**
-** Output Parameters:
-** p_ie: MPEG-2, 4 AAC Codec Information Element information.
-**
-** Returns A2D_SUCCESS if function execution succeeded.
-** Error status code, otherwise.
-******************************************************************************/
-A2D_API extern tA2D_STATUS A2D_ParsM24Info(tA2D_M24_CIE *p_ie, UINT8 *p_info,
- BOOLEAN for_caps);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* A2D_M24_H */
-
diff --git a/stack/include/avrc_defs.h b/stack/include/avrc_defs.h
index 188f5a4..b902bff 100644
--- a/stack/include/avrc_defs.h
+++ b/stack/include/avrc_defs.h
@@ -825,13 +825,8 @@ typedef union
/* macros */
#define AVRC_IS_VALID_CAP_ID(a) (((a == AVRC_CAP_COMPANY_ID) || (a == AVRC_CAP_EVENTS_SUPPORTED)) ? TRUE : FALSE)
-#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
-#define AVRC_IS_VALID_EVENT_ID(a) (((a >= AVRC_EVT_PLAY_STATUS_CHANGE) && \
- (a <= AVRC_EVT_VOLUME_CHANGE)) ? TRUE : FALSE)
-#else /* AVRCP 1.3 */
#define AVRC_IS_VALID_EVENT_ID(a) (((a >= AVRC_EVT_PLAY_STATUS_CHANGE) && \
(a <= AVRC_EVT_APP_SETTING_CHANGE)) ? TRUE : FALSE)
-#endif
#define AVRC_IS_VALID_ATTRIBUTE(a) (((((a > 0) && a <= AVRC_PLAYER_SETTING_SCAN)) || \
((a >= AVRC_PLAYER_SETTING_LOW_MENU_EXT) && \
diff --git a/stack/include/dun_api.h b/stack/include/dun_api.h
deleted file mode 100644
index 2b3679f..0000000
--- a/stack/include/dun_api.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/************************************************************************************
-**
-** Name: dun_api.h
-**
-** Description: this file contains the DUN API declaration
-**
-**
-** Copyright (c) 1999-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-*************************************************************************************/
-#ifndef DUN_API_H
-#define DUN_API_H
-
-#include "bt_target.h"
-#include "btm_api.h"
-#include "sdp_api.h"
-#include "port_api.h"
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-/* API function return values */
-#define DUN_SUCCESS 0
-#define DUN_FAIL 1
-
-/* Values for the options parameter. It is an integer bit mask that
-** contains information used in the DUN or Fax SDP record. These values
-** can be or'ed together to indicate more than one option. Fax class options
-** are not allowed for the DUN profile.
-*/
-#define DUN_OPTIONS_AUDIO (1<<0) /* Audio feedback supported */
-#define DUN_OPTIONS_CLASS1 (1<<1) /* Fax class 1 supported */
-#define DUN_OPTIONS_CLASS20 (1<<2) /* Fax class 2.0 supported */
-#define DUN_OPTIONS_CLASS2 (1<<3) /* Fax class 2 supported */
-
-/*****************************************************************************
-** Type definitions
-*****************************************************************************/
-
-/* This callback function returns service discovery information to the
-** application after the DUN_FindService() API function is called. The
-** implementation of this callback function must copy the p_name parameter
-** passed to it as it is not guaranteed to remain after the callback
-** function exits.
-*/
-typedef void (tDUN_FIND_CBACK)(BOOLEAN found, UINT8 scn, char* p_name,
- UINT16 name_len, UINT16 options);
-
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/******************************************************************************
-**
-** Function DUN_Listen
-**
-** Description This function opens a DUN or Fax connection in server mode.
-** It configures the security settings for the connection,
-** opens an RFCOMM connection in server mode, and sets the
-** class of device as required by the profile. It returns
-** the handle for the RFCOMM connection.
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-DUN_API extern UINT8 DUN_Listen(UINT16 service_uuid, char *p_service_name,
- UINT8 scn, UINT16 mtu, UINT8 security_mask,
- UINT16 *p_handle, tPORT_CALLBACK *p_cback);
-
-/******************************************************************************
-**
-** Function DUN_Connect
-**
-** Description This function opens a DUN or Fax client connection.
-** It configures the security settings for the connection
-** and opens an RFCOMM connection in server mode.
-** It returns the handle for the RFCOMM connection.
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-DUN_API extern UINT8 DUN_Connect(UINT16 service_uuid, BD_ADDR bd_addr, UINT8 scn,
- UINT16 mtu, UINT8 security_mask, UINT16 *p_handle,
- tPORT_CALLBACK *p_cback);
-
-/******************************************************************************
-**
-** Function DUN_Close
-**
-** Description This function closes a DUN or Fax client connection
-** previously opened with DUN_Connect().
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-DUN_API extern UINT8 DUN_Close(UINT16 handle);
-
-/******************************************************************************
-**
-** Function DUN_Shutdown
-**
-** Description This function closes a DUN or Fax server connection
-** previously opened with DUN_Listen(). It is called if
-** the application wishes to close the DUN or Fax server
-** connection at any time.
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-DUN_API extern UINT8 DUN_Shutdown(UINT16 handle);
-
-/******************************************************************************
-**
-** Function DUN_AddRecord
-**
-** Description This function is called by a server application to add
-** DUN or Fax information to an SDP record. Prior to
-** calling this function the application must call
-** SDP_CreateRecord() to create an SDP record.
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-DUN_API extern UINT8 DUN_AddRecord(UINT16 service_uuid, char *p_service_name,
- UINT8 scn, UINT16 options, UINT32 sdp_handle);
-
-/******************************************************************************
-**
-** Function DUN_FindService
-**
-** Description This function is called by a client application to
-** perform service discovery and retrieve DUN or Fax SDP
-** record information from a server. Information is
-** returned for the first service record found on the
-** server that matches the service UUID. The callback
-** function will be executed when service discovery is
-** complete. There can only be one outstanding call to
-** DUN_FindService() at a time; the application must wait
-** for the callback before it makes another call to
-** the function.
-**
-** Returns DUN_SUCCESS if function execution succeeded,
-** DUN_FAIL if function execution failed.
-**
-******************************************************************************/
-DUN_API extern UINT8 DUN_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
- tSDP_DISCOVERY_DB *p_db, UINT32 db_len,
- tDUN_FIND_CBACK *p_cback);
-
-/******************************************************************************
-**
-** Function DUN_SetTraceLevel
-**
-** Description Sets the trace level for DUN. If 0xff is passed, the
-** current trace level is returned.
-**
-** Input Parameters:
-** new_level: The level to set the DUN tracing to:
-** 0xff-returns the current setting.
-** 0-turns off tracing.
-** >= 1-Errors.
-** >= 2-Warnings.
-** >= 3-APIs.
-** >= 4-Events.
-** >= 5-Debug.
-**
-** Returns The new trace level or current trace level if
-** the input parameter is 0xff.
-**
-******************************************************************************/
-DUN_API extern UINT8 DUN_SetTraceLevel (UINT8 new_level);
-
-/*******************************************************************************
-**
-** Function DUN_Init
-**
-** Description This function is called before accessing the DUN APIs in order
-** to initialize the control block.
-**
-** Returns void
-**
-*******************************************************************************/
-DUN_API extern void DUN_Init(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DUN_API_H */
-
diff --git a/stack/include/goep_util.h b/stack/include/goep_util.h
deleted file mode 100644
index 600c6d0..0000000
--- a/stack/include/goep_util.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/*****************************************************************************
-**
-** Name: goep_util.h
-**
-** File: Generic Object Exchange Profile utility API
-**
-** Copyright (c) 2000-2008, Broadcom Corp., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef GOEP_UTIL_H
-#define GOEP_UTIL_H
-
-#include "bt_target.h"
-#include "sdp_api.h" /* for tSDP_DISC_REC */
-
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-#define GOEP_ENHANCED_VERSION 0x0102
-#define GOEP_LEGACY_VERSION 0x0100
-
-
-/*****************************************************************************
-** Type Definitions
-*****************************************************************************/
-
-/*** Define goep error codes ***/
-enum
-{
- GOEP_SUCCESS = 0, /* success */
- GOEP_ERROR, /* general failure */
- GOEP_RESOURCES, /* resources not available */
- GOEP_INVALID_PARAM /* bad parameter(s) */
-} ;
-typedef UINT8 tGOEP_ERRORS;
-
-
-
-
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*** GOEP utility functions ***/
-/*****************************************************************************
-**
-** Function GOEP_SetSecurityLevel()
-**
-** Description Register security & encryption level for GOEP server.
-** This is not to be used for the GOEP command server.
-**
-** Returns TRUE if OK, FALSE if a bad parameter
-**
-*****************************************************************************/
-GOEP_API extern BOOLEAN GOEP_SetSecurityLevel (BOOLEAN b_orig,
- char *p_sz_name,
- UINT32 service,
- UINT8 sec,
- UINT8 scn);
-
-/*****************************************************************************
-**
-** Function GOEP_SetTraceLevel
-**
-** Description This function changes the trace level (debugging levels)
-**
-** Returns void
-**
-*****************************************************************************/
-GOEP_API extern void GOEP_SetTraceLevel(UINT8 level);
-
-/*******************************************************************************
-**
-** Function GOEP_FreeBuf
-**
-** Description free memory for specified packet
-**
-** Returns void
-**
-*******************************************************************************/
-GOEP_API extern void GOEP_FreeBuf (void **p_buf);
-
-/*******************************************************************************
-**
-** Function GOEP_SendMsg
-**
-** Description send a message to BTU task
-**
-** Returns void
-**
-*******************************************************************************/
-GOEP_API extern void GOEP_SendMsg (void *p_msg);
-
-/*******************************************************************************
-**
-** Function GOEP_Init
-**
-** Description This function is called once at stack startup to allocate
-** (if using dynamic memory) and initialize the
-** control block, and initializes the
-** debug tracing level.
-**
-** Returns void
-**
-*******************************************************************************/
-GOEP_API extern void GOEP_Init(void);
-
-
-
-/*** GOEP Service functions ***/
-
-
-/*****************************************************************************
-**
-** Function: GOEP_Register()
-**
-** Purpose: Register an OBEX profile with SDP
-**
-** Parameters:
-**
-** char *p_name service name; optional (may be NULL)
-** UINT32 *phSDP handle to the created record; cannot be NULL
-** UINT8 scn scn desired for the service; must be > 0
-** UINT16 version version of the service; optional (may be 0)
-**
-** Returns: (tGOEP_ERRORS) GOEP_SUCCESS if ok; GOEP_ERROR on error
-**
-** Notes:
-**
-**
-** Preconditions:
-** - phSDP must be set (to return the SDP record handle)
-** - scn must be set
-**
-** Postconditions:
-** -
-**
-*****************************************************************************/
-GOEP_API extern tGOEP_ERRORS GOEP_Register (char *p_name,
- UINT32 *p_sdp_handle,
- UINT8 scn,
- UINT8 num_srv_class,
- UINT16 *p_service_class,
- UINT16 profile_id,
- UINT16 version);
-/*****************************************************************************
-**
-** Function: GOEP_Register2()
-**
-** Purpose: Register an OBEX 1.5 profile with SDP
-**
-** Parameters:
-**
-** char *p_name service name; optional (may be NULL)
-** UINT32 *phSDP handle to the created record; cannot be NULL
-** UINT16 psm psm desired for the service; must be an legal L2CAP dynamic PSM
-** UINT16 version version of the service; optional (may be 0)
-**
-** Returns: (tGOEP_ERRORS) GOEP_SUCCESS if ok; GOEP_ERROR on error
-**
-** Notes:
-**
-**
-** Preconditions:
-** - phSDP must be set (to return the SDP record handle)
-** - psm must be set
-**
-** Postconditions:
-** -
-**
-*****************************************************************************/
-GOEP_API extern tGOEP_ERRORS GOEP_Register2 (char *p_name,
- UINT32 *phSDP,
- UINT16 psm,
- UINT8 num_srv_class,
- UINT16 *p_service_class,
- UINT16 profile_id,
- UINT16 version);
-
-/*****************************************************************************
-**
-** Function: GOEP_AddProtoLists()
-**
-** Purpose: Add the AdditionalProtocolDescriptorLists attribute
-** to a SDP record
-**
-** Parameters:
-**
-** UINT32 sdp_hdl the SDP record handle
-** UINT8 scn scn desired for the service; must be > 0
-**
-** Returns: (tGOEP_ERRORS) GOEP_SUCCESS if ok; GOEP_ERROR on error
-**
-** Notes:
-**
-**
-** Preconditions:
-** - sdp_hdl must be set (to the SDP record handle from GOEP_Register())
-** - scn must be set
-**
-** Postconditions:
-** -
-**
-*****************************************************************************/
-GOEP_API extern tGOEP_ERRORS GOEP_AddProtoLists ( UINT32 sdp_hdl, UINT8 scn);
-
-
-
-/*** Debug Tracing support ***/
-#if BT_USE_TRACES == TRUE
-
-GOEP_API extern char *GOEP_ErrorName (tGOEP_ERRORS error);
-GOEP_API extern void GOEP_TraceSupportedDataTypes(UINT8 data_types, UINT8 *p_data_types);
-#else
-#ifndef BTE_SIM_APP
-/* define these trace functions out */
-#define GOEP_CodeName(_x) ""
-#define GOEP_ErrorName(_x) ""
-#endif
-#define GOEP_TraceSupportedDataTypes(x, y)
-#endif
-
-
-/*****************************************************************************
-**
-** Design notes:
-**
-** The responsibilities handle by this module include:
-**
-** a) Function signatures which assure the proper header fields are
-** set for the GOEP connection establishment, GOEP put, and GOEP get.
-** Required fields / headers are filled in through the API function
-** parameters. Extensions beyond the required fields / headers
-** must be set through the tOBEX_HEADERS *p_headers parameter.
-**
-** b) Debug error checking for required fields and prohibited fields
-** for the GOEP connection establishment, GOEP put, and GOEP get.
-** With debugging on, non-optional headers set in the p_headers
-** parameter will generate a Widcomm assertion error.
-**
-** c) Does NOT include checks of any kind on the contents of the
-** authentication or authentication response headers. In fact,
-** the logic for encoding, decoding, validating, and calculating
-** authentication data is outside the scope of GOEP and OBEX.
-** Refer to IrOBEX v1.2 sections 2.2.13, 2.2.14, and 3.5.
-**
-** d) Does NOT include checks of any kind on the contents of the
-** data (body headers) sent or received.
-**
-**
-*****************************************************************************/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GOEP_UTIL_H */
diff --git a/stack/include/hidd_api.h b/stack/include/hidd_api.h
deleted file mode 100644
index 180dc3e..0000000
--- a/stack/include/hidd_api.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/****************************************************************************
-**
-** Name: hidd_api.h
-**
-** Function: this file contains HID DEVICE side API definitions
-**
-**
-** Copyright (c) 2002-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef HIDD_API_H
-#define HIDD_API_H
-
-#include "hiddefs.h"
-
-
-/*****************************************************************************
-** Type Definitions
-*****************************************************************************/
-
-/* Define the structures that the HID Device function should use to register
-** callbacks with HID.
-*/
-
-typedef struct
-{
- FLOW_SPEC ctrl_ch;
- FLOW_SPEC int_ch;
- FLOW_SPEC hci;
-} tHID_DEV_QOS_INFO;
-
-typedef struct rep_data
-{
- UINT8 rep_type;
- UINT8 rep_id;
-} tHID_DEV_GET_REP_DATA;
-
-/* HID-Device Callback Events
-*/
-enum
-{
- HID_DEV_EVT_OPEN, /*Connected to host with Interrupt and Control Data = 1 if Virtual Cable
- Channels in OPEN state. pdata = Host BD-Addr.*/
-
- HID_DEV_EVT_CLOSE, /*Connection with host is closed. Data=Reason Code. */
- HID_DEV_EVT_RETRYING, /*Lost connection is being re-connected. Data=Retrial number */
- HID_DEV_EVT_MODE_CHG, /*Device changed power mode. Data=new power mode */
- HID_DEV_EVT_PM_FAILED,
- HID_DEV_EVT_CONTROL, /*Host sent HID_CONTROL Data=Control Operation */
- HID_DEV_EVT_GET_REPORT,/*Host sent GET_REPORT Data=Length pdata=structure
- having details of get-report.*/
- HID_DEV_EVT_SET_REPORT,/*Host sent SET_REPORT Data=Length pdata=details.*/
- HID_DEV_EVT_GET_PROTO, /*Host sent GET_PROTOCOL Data=NA*/
- HID_DEV_EVT_SET_PROTO, /*Host sent SET_PROTOCOL Data=1 for Report, 0 for Boot*/
- HID_DEV_EVT_GET_IDLE, /*Host sent GET_IDLE Data=NA */
- HID_DEV_EVT_SET_IDLE, /*Host sent SET_IDLE Data=Idle Rate */
- HID_DEV_EVT_DATA,
- HID_DEV_EVT_DATC,
-
- HID_DEV_EVT_L2CAP_CONGEST /* L2CAP channel congested */
-};
-
-/* Define the possible states of the HID Device power manager.
-*/
-enum
-{
- HID_DEV_BUSY_CONN_ST,
- HID_DEV_IDLE_CONN_ST,
- HID_DEV_SUSP_CONN_ST
-};
-
-typedef union {
- BD_ADDR host_bdaddr;
- BT_HDR *buffer;
- tHID_DEV_GET_REP_DATA get_rep;
- UINT8 pm_err_code;
- UINT16 pm_interval;
-} tHID_DEV_CBACK_DATA;
-
-typedef void (tHID_DEV_CALLBACK) (UINT8 event, /* Event from HID-DEVICE. */
- UINT32 data, /* Integer data corresponding to the event. */
- tHID_DEV_CBACK_DATA *pdata ); /* Pointer data corresponding to the event.*/
-
-typedef struct
-{
- BD_ADDR host_addr;/* Host BD-ADDR */
- tHID_DEV_QOS_INFO *qos_info; /* This info is used only if HID_DEV_USE_GLB_QOS is set to FALSE.*/
- tHID_DEV_CALLBACK *app_cback;
-} tHID_DEV_REG_INFO;
-
-typedef struct pwr_md
-{
- UINT16 max;
- UINT16 min;
- UINT16 attempt;
- UINT16 timeout;
- UINT8 mode;
-} tHID_DEV_PM_PWR_MD;
-
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*******************************************************************************
-**
-** Function HID_DevSetSDPRecord
-**
-** Description This function should be called at startup to create the
-** device SDP record
-**
-** Returns 0 if error else sdp handle for the record.
-**
-*******************************************************************************/
-HID_API extern UINT32 HID_DevSetSDPRecord (tHID_DEV_SDP_INFO *p_sdp_info);
-
-/*******************************************************************************
-**
-** Function HID_DevRegister
-**
-** Description This function must be called at startup so the device receive
-** HID related events and call other HID API Calls.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-HID_API extern tHID_STATUS HID_DevRegister(tHID_DEV_REG_INFO *pHID_DEVRegInfo );
-
-/*******************************************************************************
-**
-** Function HID_DevDeregister
-**
-** Description This function may be used to remove HID service records and
-** deregister from L2CAP.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-HID_API extern tHID_STATUS HID_DevDeregister(void);
-
-/*******************************************************************************
-**
-** Function HID_DevConnect
-**
-** Description This function may be used to initiate a connection to the host..
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-HID_API extern tHID_STATUS HID_DevConnect(void);
-
-/*******************************************************************************
-**
-** Function HID_DevDisconnect
-**
-** Description This function may be used to disconnect from the host.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-HID_API extern tHID_STATUS HID_DevDisconnect(void);
-
-/*******************************************************************************
-**
-** Function HID_DevHandShake
-**
-** Description This function may be used to send HAND-SHAKE to host.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-HID_API extern tHID_STATUS HID_DevHandShake(UINT8 res_code );
-
-/*******************************************************************************
-**
-** Function HID_DevVirtualUnplug
-**
-** Description This function may be used to send VIRTUAL-UNPLUG to host.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-HID_API extern tHID_STATUS HID_DevVirtualUnplug (void);
-
-/*******************************************************************************
-**
-** Function HID_DevSendData
-**
-** Description This function may be used to send input reports to host.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-HID_API extern tHID_STATUS HID_DevSendData (BOOLEAN control_ch, UINT8 rep_type,
- BT_HDR *data_buf );
-
-/*******************************************************************************
-**
-** Function HID_DevSetPowerMgmtParams
-**
-** Description This function may be used to change power mgmt parameters.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-HID_API extern tHID_STATUS HID_DevSetPowerMgmtParams(UINT8 conn_substate,
- tHID_DEV_PM_PWR_MD pm_params );
-
-/*******************************************************************************
-**
-** Function HID_DevInit
-**
-** Description This function initializes the control block and trace variable
-**
-** Returns void
-**
-*******************************************************************************/
-HID_API extern void HID_DevInit(void);
-
-/*******************************************************************************
-**
-** Function HID_DevSetSecurityLevel
-**
-** Description This function set security level for the Hid Device service.
-**
-** Returns tHID_STATUS
-**
-*******************************************************************************/
-HID_API extern tHID_STATUS HID_DevSetSecurityLevel( char serv_name[], UINT8 sec_lvl );
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* HIDD_API_H */
diff --git a/stack/include/xml_bld_api.h b/stack/include/xml_bld_api.h
deleted file mode 100644
index 2d788e0..0000000
--- a/stack/include/xml_bld_api.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*****************************************************************************
-**
-** Name: xml_bld_api.h
-**
-** File: XML Builder API
-**
-**
-** Copyright (c) 2000-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef XML_BLD_API_H
-#define XML_BLD_API_H
-
-#include "data_types.h"
-
-
-/*****************************************************************************
-** Type Definitions
-*****************************************************************************/
-
-enum
-{
- XML_BLD_SUCCESS,
- XML_BLD_ERROR
-};
-typedef UINT16 tXML_BLD_RESULT;
-
-
-enum
-{
- XML_ATTR_CONT = FALSE, /* not the end of attribute list. add quote(') */
- XML_ATTR_LAST = TRUE, /* the last one of the attribute list. add quote('), greater_than(>), and line_feed(\n) */
- XML_ATTR_ETAG = 2 /* the end of the element. add quote('), end_mark(/), greater_than(>), and line_feed(\n) */
-};
-typedef UINT8 tXML_ATTR_END;
-
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-
-/*****************************************************************************
-**
-** Function: XML_BufAddTag
-**
-** Purpose: Write a start or end tag and optional prefix.
-**
-** Parameters:
-** UINT8 **pp_buf reference to the storage to hold the XML object
-** GOEP_WriteStore.
-** const UINT8* prefix tag prefix (namespace)
-** const UINT8* tag tag name
-** BOOLEAN start_tag TRUE = start tag, FALSE = end tag
-** BOOLEAN has_attr TRUE if the tag contains attributes
-**
-** Returns: XML_BLD_SUCCESS if success
-**
-*****************************************************************************/
-tXML_BLD_RESULT XML_BufAddTag (UINT8 **pp_buf,
- const UINT8 *prefix,
- const UINT8 *tag,
- BOOLEAN start_tag,
- BOOLEAN has_attr);
-
-
-/*****************************************************************************
-**
-** Function: XML_BufAddAttribute
-**
-** Purpose: Write an attribute and optional prefix.
-**
-** Parameters:
-** UINT8 **pp_buf reference to the storage to hold the XML object
-** const UINT8* prefix attribute prefix (namespace)
-** const UINT8* attr_name attribute name
-** const UINT8* attr_value attribute value
-**
-** Returns: XML_BLD_SUCCESS if success
-**
-*****************************************************************************/
-tXML_BLD_RESULT XML_BufAddAttribute (UINT8 **pp_buf,
- const UINT8 *prefix,
- const UINT8 *attr_name,
- const UINT8 *attr_value,
- tXML_ATTR_END last_attr);
-
-/*****************************************************************************
-**
-** Function: XML_BufAddCharData
-**
-** Purpose: Write the element content.
-**
-** Parameters:
-** UINT8 **pp_buf reference to the storage to hold the XML object
-** const UINT8* content element content
-**
-** Returns: XML_BLD_SUCCESS if success
-**
-*****************************************************************************/
-tXML_BLD_RESULT XML_BufAddCharData (UINT8 **pp_buf, const UINT8 *charData);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ifndef XML_BLD_API_H */
diff --git a/stack/include/xml_erp_api.h b/stack/include/xml_erp_api.h
deleted file mode 100644
index fa2b33a..0000000
--- a/stack/include/xml_erp_api.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/******************************************************************************
- **
- ** Name: xml_erp_api.h
- ** $Id:
- **
- ** Description: This module contains xml parser of MAP event report
- **
- ** Copyright (c) 2004-2005, Broadcom Corporation, All Rights Reserved.
- ** WIDCOMM Bluetooth Core. Proprietary and confidential.
- ******************************************************************************/
-
-#ifndef XML_ERP_API_H
-#define XML_ERP_API_H
-
-#include "bt_target.h"
-#include "gki.h"
-#include "xml_pars_api.h"
-
-
-#ifndef XML_EVT_RPT_CARRY_OVER_LEN
-#define XML_EVT_RPT_CARRY_OVER_LEN 512 /* number of bytes we can store in case we did not yet find the > */
-#endif
-
-/**********************************************************************************/
-
-typedef struct
-{
- UINT16 type_len;
- UINT16 handle_len;
- UINT16 folder_len;
- UINT16 old_folder_len;
- UINT16 msg_type_len;
- UINT8 *type;
- UINT8 *handle;
- UINT8 *folder;
- UINT8 *old_folder;
- UINT8 *msg_type;
-} tXML_EVT_RPT_ENTRY;
-
-/**********************************************************************************/
-
-enum
-{
- XML_EVT_RPT_OK, /* parsing is ok, operation is ok */
- XML_EVT_RPT_PENDING, /* parsing is ok but not enough data */
- XML_EVT_RPT_END_LIST, /* found </MAP-event-report> */
- XML_EVT_RPT_OUT_FULL, /* output buffer full /MAP-event-report not reached! data is dumped */
- XML_EVT_RPT_ERROR, /* some parsing error occured */
- XML_EVT_RPT_NO_RES, /* ran out of resources (memory) */
- XML_EVT_RPT_DST_NO_RES /* ran out of destination data buffer */
-} ;
-typedef UINT8 tXML_EVT_RPT_RES;
-
-
-typedef struct
-{
- tXML_EVT_RPT_ENTRY *p_entry; /* point to parser_cb->ilist.evt_rpt */
- tXML_PROP *p_prop; /* GKI_BUF3_SIZE */
-
- tXML_PROP *offset_prop; /* current filling property */
- UINT16 prop_num; /* number of properties left to be filled in */
-
- INT16 current_entry;
- INT16 max_name_len; /* maximum length of name length of entry
- XML parser limits to 196 bytes i think. */
- UINT16 max_entry;
- BOOLEAN ended;
- UINT16 prop_index;
- UINT16 max_num_prop;
- UINT8 obj; /* the XML object - (tFTC_XML_OBJ + 1)*/
-} tXML_EVT_RPT_STATE;
-
-typedef struct
-{
- tXML_MUL_STATE xml;
- tXML_EVT_RPT_STATE xml_user_data;
-} tXML_EVT_RPT_PARSER;
-
-/* only this value is of significance, if not ok frame is dropped by parser */
-#define XML_EVT_RPT_ENTRY_OK 0
-
-typedef UINT8 tXML_EVT_RPT_STATUS;
-
-
-typedef struct
-{
- UINT8 *data;
- UINT16 len;
- BOOLEAN final; /* If TRUE, entry is last of the series */
- tXML_EVT_RPT_STATUS status; /* Fields are valid when status is BTA_FTC_OK */
-} tXML_EVT_RPT_LIST; /* clone of tBTA_FTC_LIST */
-
-
-/**************************************************************************************
-** Function XML_EvtRptInit
-**
-** Description Initialize xml parser state machine.
-**
-** Parameters p_xml_state: address of parser structure, allocate an additional space
-** of size XML_EVT_RPT_CARRY_OVER_LEN right after p_xml_state
-** to hold carry over data.
-** p_entry : points start of output directory entry. caller needs do free this memory
-** max_entry : max is 16 bit integer value which is the maximum number of folder entries.
-
-**
-** Returns void
-**************************************************************************************/
-MCE_API void XML_EvtRptInit( tXML_EVT_RPT_PARSER *p_xml_state,
- tXML_EVT_RPT_ENTRY *p_entry,
- const UINT16 max_entry );
-
-
-/**************************************************************************************
-** Function XML_EvtRptParse
-**
-** Description This function is called to parse the xml data received from OBEX
-** into folder entries associated with properties value. It can also be
-** used as clean up function to delete left over data from previous parse.
-** This clean up function is typically used when application runs out of
-** resource and decides to discard extra xml data received.
-**
-** Parameters p_xml_state: pointer to a xml parser initialized by XML_FolderInit().
-** xml_data: valid pointer to OBEX list data in xml format.
-** xml_len: length of the package, must be non-zero value.
-** dst_data: valid pointer to the buffer for holding converted folder entry name.
-** When dst_data is NULL, clean up all remaining data in the parser.
-** dst_len: length of the dst_data buffer, its carry out value is the number
-** of bytes of available buffer remains.
-** num_entries: current number of entries, in the end it is the total number of entries
-**
-** Returns tXML_EVT_RPT_RES (see xml_flp.h)
-** XML_PENDING: parsing not completed
-** XML_END_LIST: found /folder-listing but no final flag detected
-** XML_EVT_RPT_OUT_FULL: reached max_entry -> do not call parser anymore!!! dump data
-** XML_EVT_RPT_DST_NO_RES : run out of dst buffer resource while
-** some xml data still remains.
-
-**************************************************************************************/
-MCE_API extern tXML_EVT_RPT_RES XML_EvtRptParse( tXML_EVT_RPT_PARSER *p_xml_state,
- UINT8 *xml_data, UINT16 xml_len,
- UINT8 *dst_data, UINT16 *dst_len,
- UINT16 *num_entries );
-
-
-#endif
diff --git a/stack/include/xml_flp_api.h b/stack/include/xml_flp_api.h
deleted file mode 100644
index fddb839..0000000
--- a/stack/include/xml_flp_api.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/******************************************************************************
- **
- ** Name: xml_flp.h
- ** $Id: xml_flp.h,v 1.2 2004/11/15 14:07:47 rlenden Exp
- **
- ** Description: This module contains xml parser of obex folder listing
- **
- ** Copyright (c) 2004-2005, Broadcom Corporation, All Rights Reserved.
- ** WIDCOMM Bluetooth Core. Proprietary and confidential.
- ******************************************************************************/
-
-#ifndef XML_FLP_H
-#define XML_FLP_H
-
-#include "bt_target.h"
-#include "gki.h"
-#include "xml_pars_api.h"
-
-/**********************************************************************************/
-#ifndef XML_OBX_FOLDER
-#define XML_OBX_FOLDER 0
-#endif
-#ifndef XML_OBX_FILE
-#define XML_OBX_FILE 1
-#endif
-
-#define XML_PERM_READ_B 0x01
-#define XML_PERM_WRITE_B 0x02
-#define XML_PERM_DELETE_B 0x04
-
-typedef UINT8 XML_PERM_MASK ;
-
-#ifndef XML_OBX_FILE_MAX
-#define XML_OBX_FILE_MAX 100
-#endif
-
-#ifndef XML_FOLDER_CARRY_OVER_LEN
-#define XML_FOLDER_CARRY_OVER_LEN 512 /* number of bytes we can store in case we did not yet find the > */
-#endif
-
-
-#ifndef XML_PARENT_FOLDER
-#define XML_PARENT_FOLDER ".." /* <parent-folder/> is represented as .. */
-#endif
-
-
-typedef struct
-{
-
- UINT8 *data;
- UINT32 size; /* size of file or folder in bytes */
- UINT16 len;
- UINT8 type;
- XML_PERM_MASK user_perm;
-} tXML_FOLDER_ENTRY;
-
-/**********************************************************************************/
-
-typedef enum
-{
- XML_FOLDER_OK, /* parsing is ok, operation is ok */
- XML_FOLDER_PENDING, /* parsing is ok but not enough data */
- XML_FOLDER_END_LIST, /* found </folder-listing> */
- XML_FOLDER_OUT_FULL, /* output buffer full /folder-listing not reached! data is dumped */
- XML_FOLDER_ERROR, /* some parsing error occured */
- XML_FOLDER_NO_RES, /* ran out of resources (memory) */
- XML_FOLDER_DST_NO_RES /* ran out of destination data buffer */
-} txml_folder_res;
-typedef UINT8 tXML_FOLDER_RES;
-
-
-typedef struct
-{
- tXML_FOLDER_ENTRY *p_entry;
- tXML_PROP *p_prop;
-
- tXML_PROP *offset_prop; /* current filling property */
- UINT16 prop_num; /* number of properties left to be filled in */
-
- INT16 current_entry;
- INT16 max_name_len; /* maximum length of name length of entry
- XML parser limits to 196 bytes i think. */
- UINT16 max_entry;
- BOOLEAN ended;
- UINT16 prop_index;
- UINT16 max_num_prop;
- UINT8 obj; /* the XML object - (tFTC_XML_OBJ + 1)*/
-} tXML_FOLDER_STATE;
-
-typedef struct
-{
- tXML_MUL_STATE xml;
- tXML_FOLDER_STATE xml_user_data;
-} tXML_FOLDER_PARSER;
-
-/* only this value is of significance, if not ok frame is dropped by parser */
-#define XML_FOLDER_ENTRY_OK 0
-
-typedef UINT8 tXML_FOLDER_STATUS;
-
-
-typedef struct
-{
- UINT8 *data;
- UINT16 len;
- BOOLEAN final; /* If TRUE, entry is last of the series */
- tXML_FOLDER_STATUS status; /* Fields are valid when status is BTA_FTC_OK */
-} tXML_FOLDER_LIST; /* clone of tBTA_FTC_LIST */
-
-
-/**************************************************************************************
-** Function XML_FolderInit
-**
-** Description Initialize xml parser state machine.
-**
-** Parameters p_xml_state: address of parser structure, allocate an additional space
-** of size XML_FOLDER_CARRY_OVER_LEN right after p_xml_state
-** to hold carry over data.
-** p_entry : points start of output directory entry. caller needs do free this memory
-** max_entry : max is 16 bit integer value which is the maximum number of folder entries.
-
-**
-** Returns void
-**************************************************************************************/
-FTP_API void XML_FolderInit( tXML_FOLDER_PARSER *p_xml_state,
- tXML_FOLDER_ENTRY *p_entry,
- const UINT16 max_entry );
-
-
-/**************************************************************************************
-** Function XML_FolderParse
-**
-** Description This function is called to parse the xml data received from OBEX
-** into folder entries associated with properties value. It can also be
-** used as clean up function to delete left over data from previous parse.
-** This clean up function is typically used when application runs out of
-** resource and decides to discard extra xml data received.
-**
-** Parameters p_xml_state: pointer to a xml parser initialized by XML_FolderInit().
-** xml_data: valid pointer to OBEX list data in xml format.
-** xml_len: length of the package, must be non-zero value.
-** dst_data: valid pointer to the buffer for holding converted folder entry name.
-** When dst_data is NULL, clean up all remaining data in the parser.
-** dst_len: length of the dst_data buffer, its carry out value is the number
-** of bytes of available buffer remains.
-** num_entries: current number of entries, in the end it is the total number of entries
-**
-** Returns tXML_FOLDER_RES (see xml_flp.h)
-** XML_PENDING: parsing not completed
-** XML_END_LIST: found /folder-listing but no final flag detected
-** XML_FOLDER_OUT_FULL: reached max_entry -> do not call parser anymore!!! dump data
-** XML_FOLDER_DST_NO_RES : run out of dst buffer resource while
-** some xml data still remains.
-
-**************************************************************************************/
-FTP_API extern tXML_FOLDER_RES XML_FolderParse( tXML_FOLDER_PARSER *p_xml_state,
- UINT8 *xml_data, UINT16 xml_len,
- UINT8 *dst_data, UINT16 *dst_len,
- UINT16 *num_entries );
-
-
-#endif
diff --git a/stack/include/xml_mlp_api.h b/stack/include/xml_mlp_api.h
deleted file mode 100644
index eabbfbd..0000000
--- a/stack/include/xml_mlp_api.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/******************************************************************************
- **
- ** Name: xml_mlp_api.h
- ** $Id:
- **
- ** Description: This module contains xml parser of MAP message list object
- **
- ** Copyright (c) 2004-2005, Broadcom Corporation, All Rights Reserved.
- ** WIDCOMM Bluetooth Core. Proprietary and confidential.
- ******************************************************************************/
-
-#ifndef XML_MLP_API_H
-#define XML_MLP_API_H
-
-#include "bt_target.h"
-#include "gki.h"
-#include "xml_pars_api.h"
-
-
-#ifndef XML_ML_CARRY_OVER_LEN
-#define XML_ML_CARRY_OVER_LEN 512 /* number of bytes we can store in case we did not yet find the > */
-#endif
-
-/**********************************************************************************/
-
-typedef struct
-{
- UINT16 msg_handle_len;
- UINT16 subject_len;
- UINT16 datetime_len;
- UINT16 sender_name_len;
- UINT16 sender_addressing_len;
- UINT16 replyto_addressing_len;
- UINT16 recipient_name_len;
- UINT16 recipient_addressing_len;
- UINT16 type_len;
- UINT16 org_msg_size_len;
- UINT16 text_len;
- UINT16 reception_status_len;
- UINT16 attachment_size_len;
- UINT16 priority_status_len;
- UINT16 read_len;
- UINT16 sent_len;
- UINT16 is_protected_len;
- UINT8 *msg_handle;
- UINT8 *subject;
- UINT8 *datetime;
- UINT8 *sender_name;
- UINT8 *sender_addressing;
- UINT8 *replyto_addressing;
- UINT8 *recipient_name;
- UINT8 *recipient_addressing;
- UINT8 *type;
- UINT8 *org_msg_size;
- UINT8 *text;
- UINT8 *reception_status;
- UINT8 *attachment_size;
- UINT8 *priority_status;
- UINT8 *read;
- UINT8 *sent;
- UINT8 *is_protected;
-} tXML_ML_ENTRY;
-
-/**********************************************************************************/
-
-enum
-{
- XML_ML_OK, /* parsing is ok, operation is ok */
- XML_ML_PENDING, /* parsing is ok but not enough data */
- XML_ML_END_LIST, /* found </MAP-msg-listing> */
- XML_ML_OUT_FULL, /* output buffer full /MAP-msg-listing not reached! data is dumped */
- XML_ML_ERROR, /* some parsing error occured */
- XML_ML_NO_RES, /* ran out of resources (memory) */
- XML_ML_DST_NO_RES /* ran out of destination data buffer */
-};
-typedef UINT8 tXML_ML_RES;
-
-
-typedef struct
-{
- tXML_ML_ENTRY *p_entry; /* point to parser_cb->mlist.evt_rpt */
- tXML_PROP *p_prop; /* GKI_BUF3_SIZE */
-
- tXML_PROP *offset_prop; /* current filling property */
- UINT16 prop_num; /* number of properties left to be filled in */
-
- INT16 current_entry;
- INT16 max_name_len; /* maximum length of name length of entry
- XML parser limits to 196 bytes i think. */
- UINT16 max_entry;
- BOOLEAN ended;
- UINT16 prop_index;
- UINT16 max_num_prop;
- UINT8 obj; /* the XML object - (tFTC_XML_OBJ + 1)*/
-} tXML_ML_STATE;
-
-typedef struct
-{
- tXML_MUL_STATE xml;
- tXML_ML_STATE xml_user_data;
-} tXML_ML_PARSER;
-
-/* only this value is of significance, if not ok frame is dropped by parser */
-#define XML_ML_ENTRY_OK 0
-
-typedef UINT8 tXML_ML_STATUS;
-
-
-typedef struct
-{
- UINT8 *data;
- UINT16 len;
- BOOLEAN final; /* If TRUE, entry is last of the series */
- tXML_ML_STATUS status; /* Fields are valid when status is BTA_FTC_OK */
-} tXML_ML_LIST; /* clone of tBTA_FTC_LIST */
-
-
-/**************************************************************************************
-** Function XML_MlInit
-**
-** Description Initialize xml parser state machine.
-**
-** Parameters p_xml_state: address of parser structure, allocate an additional space
-** of size XML_ML_CARRY_OVER_LEN right after p_xml_state
-** to hold carry over data.
-** p_entry : points start of output directory entry. caller needs do free this memory
-** max_entry : max is 16 bit integer value which is the maximum number of folder entries.
-
-**
-** Returns void
-**************************************************************************************/
-MCE_API void XML_MlInit( tXML_ML_PARSER *p_xml_state,
- tXML_ML_ENTRY *p_entry,
- const UINT16 max_entry );
-
-
-/**************************************************************************************
-** Function XML_MLParse
-**
-** Description This function is called to parse the xml data received from OBEX
-** into folder entries associated with properties value. It can also be
-** used as clean up function to delete left over data from previous parse.
-** This clean up function is typically used when application runs out of
-** resource and decides to discard extra xml data received.
-**
-** Parameters p_xml_state: pointer to a xml parser initialized by XML_FolderInit().
-** xml_data: valid pointer to OBEX list data in xml format.
-** xml_len: length of the package, must be non-zero value.
-** dst_data: valid pointer to the buffer for holding converted folder entry name.
-** When dst_data is NULL, clean up all remaining data in the parser.
-** dst_len: length of the dst_data buffer, its carry out value is the number
-** of bytes of available buffer remains.
-** num_entries: current number of entries, in the end it is the total number of entries
-**
-** Returns tXML_ML_RES (see xml_flp.h)
-** XML_PENDING: parsing not completed
-** XML_END_LIST: found /folder-listing but no final flag detected
-** XML_ML_OUT_FULL: reached max_entry -> do not call parser anymore!!! dump data
-** XML_ML_DST_NO_RES : run out of dst buffer resource while
-** some xml data still remains.
-
-**************************************************************************************/
-MCE_API extern tXML_ML_RES XML_MlParse( tXML_ML_PARSER *p_xml_state,
- UINT8 *xml_data, UINT16 xml_len,
- UINT8 *dst_data, UINT16 *dst_len,
- UINT16 *num_entries );
-
-
-#endif
diff --git a/stack/include/xml_pars_api.h b/stack/include/xml_pars_api.h
deleted file mode 100644
index d29645a..0000000
--- a/stack/include/xml_pars_api.h
+++ /dev/null
@@ -1,358 +0,0 @@
-/*****************************************************************************
-**
-** Name: xml_pars_api.h
-**
-** File: XML Parser
-**
-** Copyright (c) 2000-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef XML_PARS_API_H
-#define XML_PARS_API_H
-
-#include "data_types.h"
-
-#define XML_STACK_SIZE 7
-
-#ifndef XML_UI_ENTRY_MAX_NAME_LEN
-#define XML_UI_ENTRY_MAX_NAME_LEN 256
-#endif
-
-/*****************************************************************************
-** Type Definitions
-*****************************************************************************/
-
-/* Definition of XML events */
-enum
-{
- XML_XMLDECL,
- XML_TAG, /* 1 For STag (Start Tag) and EmptyElemTag */
- XML_TAG_END, /* 2 When STag or EmptyElemTag ends */
- XML_ATTRIBUTE, /* 3 */
- XML_CHARDATA, /* 4 */
- XML_ETAG, /* 5 For End Tag */
- XML_PARTIAL, /* 6 notify XML user that the parse does not end properly */
- XML_COPY, /* 7 notify XML user to copy till end of a token */
- XML_QUERY, /* 8 query if the XML object has ended */
- XML_TOP /* 9 */
-};
-typedef UINT16 tXML_EVENT;
-#define XML_LAST_XE XML_ETAG
-
-enum
-{
- XML_SUCCESS,
- XML_WARNING,
- XML_OBJ_ST_EMPTY,
- XML_NO_MEM, /* no p_last_bfr, and the tXML_MUL_STATE is not in init */
- XML_NO_PROP, /* run out of tXML_PROP */
- XML_ERR, /* generic error */
- XML_NO_END /* to be continued */
-};
-typedef UINT16 tXML_RESULT;
-
-/* Definitions of different event data */
-typedef struct
-{
- UINT8 *p_version;
- UINT8 *p_enc_name;
- BOOLEAN *p_standalone; /* NULL if no standalone decl was found */
-} tXML_DECL;
-
-
-
-/* for parser that expand multi-sessions */
-/* tag stack */
-typedef struct
-{
- UINT8 stack[XML_STACK_SIZE];
- UINT8 top;
- tXML_EVENT event; /* last XML event */
-} tXML_STACK;
-
-typedef struct
-{
- UINT8 *p;
- UINT16 len;
-} tXML_STR;
-
-typedef struct
-{
- tXML_STACK stack;
- tXML_STR prefix;
- tXML_STR name;
- UINT8 *p_last_stm;
-} tXML_MTAG;
-
-typedef struct
-{
- tXML_STACK stack;
- BOOLEAN end; /* true if end of EmptyElemTag */
- /* false if end of STag */
-} tXML_MTAG_END;
-
-
-
-typedef struct
-{
- tXML_STACK stack;
- tXML_STR prefix;
- tXML_STR name;
- tXML_STR value;
-} tXML_MATTR;
-
-
-/* There may be several XML_CHARDATA events dispatched for one CHARDATA
-** string in the XML document. In each XML_CHARDATA only a segment of the
-** total string is provided. For the last segement the field last is true.
-*/
-typedef struct
-{
- tXML_STACK stack;
- tXML_STR value;
- BOOLEAN last;
-} tXML_MCH_DATA;
-
-
-typedef struct
-{
- tXML_STACK stack;
- tXML_STR prefix;
- tXML_STR name;
-} tXML_METAG;
-
-typedef struct
-{
- tXML_STACK stack;
- UINT8 *p_begin;
- tXML_STR last;
-} tXML_MCOPY;
-
-typedef struct
-{
- tXML_STACK stack;
- tXML_RESULT parse;
- UINT8 *p_keep;
-} tXML_MPART;
-
-typedef union
-{
- tXML_STACK stack;
- tXML_DECL decl;
- tXML_MTAG tag;
- tXML_MTAG_END empty_elem;
- tXML_MATTR attr;
- tXML_MCH_DATA ch_data;
- tXML_METAG etag;
- tXML_MCOPY copy;
- tXML_MPART part;
-} tXML_MEVT_DATA;
-
-typedef struct
-{
- UINT8 *p_data; /* Pointer to property data. */
- UINT16 len; /* Length of data. */
- UINT8 prefix; /* Property prefix. */
- UINT8 name; /* Property name. */
- UINT8 level; /* 0 as top level */
-} tXML_PROP;
-
-/* Definitions of different error actions.
-** At present there is only one.
-*/
-enum
-{
- XML_NEXT_TAG /* tries to find beginning of next tag */
-};
-typedef UINT16 tXML_ERR_ACTION;
-
-
-
-enum
-{
- XML_STS_INIT,
- XML_STS_1STM, /* got the first < */
- XML_STS_1TAG, /* got the first tag element */
- XML_STS_DONE
-};
-typedef UINT8 tXML_STATUS;
-
-typedef struct
-{
- UINT8 *p_hdr; /* the beginning of GKI buffer */
- UINT8 *p_begin;/* the beginning of XML data */
- UINT8 *p_end; /* the end of XML data */
-} tXML_OS;
-
-
-/*****************************************************************************
-**
-** Callback tXML_CBACK
-**
-** Description
-** Called repeatedly from the XML parser for each XML construct parsed.
-** The parsed XML construct is reported as an XML event in the event
-** in-parameter. The parser provides event data specific for each event
-** in the callback through the p_event_data param which should be casted
-** to the proper type by the user implemented tXML_CBACK function.
-** The p_event_data should be casted to a pointer of a type with the same
-** name as the event but prefixed with t. For example when the event is
-** XML_TAG, p_event_data should be casted to tXML_TAG*. Alternatively,
-** p_event_data can be casted to a tEVENT_DATA* (pointer to union) type
-** for all events. The memory behind the p_event_data is provided by the
-** parser and is only valid during the callback, i.e. the memory is not
-** valid after the callback. No pointer inside the event structures may
-** be NULL unless explicitly stated so above for some specific event.
-** The p_usr_data parameter is the same p_usr_data pointer the
-** API user passed in the XML_Parse. It is only declared as a mean for
-** the API user to pass any user data to its callback function.
-**
-**
-** Parameters
-** event (in) : the XML event or XML contruct just parsed,
-** p_event_data (in) : data, i.e. names values etc, found in the XML
-** construct. The data is specific for the XML
-** construct and should be casted to the
-** proper type as descibed above. May not be NULL.
-** p_usr_data (in) : Same p_usr_data as passed in XML_Parse.
-**
-** Returns
-** TRUE : if parsing should continue
-** FALSE : if parsing should stop
-**
-*****************************************************************************/
-
-typedef BOOLEAN (*tXML_CBACK)(tXML_EVENT event, void *p_event_data,
- void *p_usr_data);
-
-typedef struct
-{
-
- UINT8 p[512];
- UINT16 len;
-} tXML_STR_PARTIAL;
-
-typedef struct
-{
- tXML_STR_PARTIAL last_bfr;
- UINT16 used_last_bfr;
- tXML_MEVT_DATA event_data;
-}
-tXML_PARTIAL;
-
-/* tXML_STATE stores state during the XML_Parse call not between
-** XML_Parse calls. It is used in most static functions in this file
-** and passed in as first parameter to these.
-*/
-typedef struct
-{
- /* input from XML_Parse caller */
- tXML_OS xml_os;
- UINT8 *p_cur;
- tXML_CBACK cback;
- void *p_usr_data;
- tXML_MEVT_DATA event_data;
-
- /* handling of data buffers for prefix, name and value */
- UINT8 *p_data_bfr;
- UINT8 *p_last_stm; /* last '<' */
- UINT8 *p_copy;
- tXML_STR last_bfr;
- tXML_STR value;
- tXML_STR prefix;
- tXML_STR name;
-
- /* token and result handling */
- INT16 curr_res;
- tXML_RESULT pars_res;
- UINT8 next_token;
- BOOLEAN skip_next_nl;
-
- UINT16 used_last_bfr; /* the actual data size in p_last_bfr */
- tXML_STATUS status;
-
- /* structure used to store partial data */
- tXML_PARTIAL partial_st;
-} tXML_MUL_STATE;
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*****************************************************************************
-**
-** Function XML_Parse
-**
-** Description
-** Parses an XML message/document in utf8. The message is read from
-** an object store which must have been initialised and an object
-** (file) must have been opened so the parser can start directly with
-** reading the first byte using the GOEP_Read function and passing
-** the h_obj_store in-param.
-** The parser will call the xml_cback callback for each basic
-** XML-construct parsed. If the parser encounters an error it will
-** try to act according to the err_action in-param and report any
-** errors through the err_handle. The parser is non-validating.
-**
-** Parameters
-** h_obj_store (in) : a handle to an opened object (file) in
-** the Object Store. The object must be
-** ready for reading.
-** xml_cback (in) : the user provided function to call back
-** for each XML-construct (XML event) parsed.
-** err_action (in) : the action the parser will try if it finds
-** an error.
-** err_handle (in) : a handle to some error recording object to
-** which the parser may report errors. This is
-** a place holder to connect any type of error
-** recording object.
-** p_usr_data (in) : any user data that will be passed on
-** unchanged to the callback function.
-**
-** Returns
-** 0 if the parsing was successfull without errors
-** non-zero error or warning code otherwise
-**
-*****************************************************************************/
-
-tXML_RESULT XML_Parse(tXML_OS *p_os, tXML_CBACK xml_cback,
- tXML_ERR_ACTION err_action, UINT32 err_handle,
- void *p_usr_data);
-
-/*****************************************************************************
-**
-** Function XML_MulParse
-**
-** Description Initialize XML parser state machine.
-**
-** Parameters
-** p_st (in) : xml state machine.
-** p_os (in) : xml data storage
-**
-*****************************************************************************/
-tXML_RESULT XML_MulParse(tXML_MUL_STATE *p_st, tXML_OS *p_os);
-
-/*****************************************************************************
-**
-** Function XML_InitPars
-**
-** Description Initialize XML parser state machine.
-**
-** Parameters
-** p_st (in) : xml state machine.
-** xml_cback (in) : the user provided function to call back
-** p_usr_data : user defined data.
-**
-*****************************************************************************/
-void XML_InitPars(tXML_MUL_STATE *p_st, tXML_CBACK xml_cback, void *p_usr_data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ifndef XML_PARS_API_H */
diff --git a/stack/include/xml_vlist_api.h b/stack/include/xml_vlist_api.h
deleted file mode 100644
index 362432a..0000000
--- a/stack/include/xml_vlist_api.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/******************************************************************************
- **
- ** Name: xml_vlist_api.h
- **
- ** Description: This module contains xml parser of obex vcard listing
- **
- ** Copyright (c) 2004-2005, Broadcom Corporation, All Rights Reserved.
- ** WIDCOMM Bluetooth Core. Proprietary and confidential.
- ******************************************************************************/
-
-#ifndef XML_VLIST_API_H
-#define XML_VLIST_API_H
-
-#include "bt_target.h"
-#include "gki.h"
-#include "xml_pars_api.h"
-
-/**********************************************************************************/
-#ifndef XML_VLIST_CARRY_OVER_LEN
-#define XML_VLIST_CARRY_OVER_LEN 512 /* number of bytes we can store in case we did not yet find the > */
-#endif
-
-typedef struct
-{
- UINT16 handle_len;
- UINT8 *handle;
- UINT16 name_len;
- UINT8 *name;
-} tXML_VLIST_ENTRY;
-
-/**********************************************************************************/
-
-typedef enum
-{
- XML_VLIST_OK, /* parsing is ok, operation is ok */
- XML_VLIST_PENDING, /* parsing is ok but not enough data */
- XML_VLIST_END_LIST, /* found </vCard-listing> */
- XML_VLIST_OUT_FULL, /* output buffer full /vCard-listing not reached! data is dumped */
- XML_VLIST_ERROR, /* some parsing error occured */
- XML_VLIST_NO_RES, /* ran out of resources (memory) */
- XML_VLIST_DST_NO_RES /* ran out of destination data buffer */
-} txml_vlist_res;
-typedef UINT8 tXML_VLIST_RES;
-
-
-typedef struct
-{
- tXML_VLIST_ENTRY *p_entry;
- tXML_PROP *p_prop;
-
- tXML_PROP *offset_prop; /* current filling property */
- UINT16 prop_num; /* number of properties left to be filled in */
-
- INT16 current_entry;
- INT16 max_name_len; /* maximum length of name length of entry
- XML parser limits to 64 bytes i think. */
- UINT16 max_entry;
- BOOLEAN ended;
- UINT16 prop_index;
- UINT16 max_num_prop;
- UINT8 obj; /* the XML object */
-} tXML_VLIST_STATE;
-
-typedef struct
-{
- tXML_MUL_STATE xml;
- tXML_VLIST_STATE xml_user_data;
-} tXML_VLIST_PARSER;
-
-/* only this value is of significance, if not ok frame is dropped by parser */
-#define XML_VLIST_ENTRY_OK 0
-
-typedef UINT8 tXML_VLIST_STATUS;
-
-
-typedef struct
-{
- UINT8 *data;
- UINT16 len;
- BOOLEAN final; /* If TRUE, entry is last of the series */
- tXML_VLIST_STATUS status; /* Fields are valid when status is BTA_FTC_OK */
-} tXML_VLIST_LIST; /* clone of tBTA_FTC_LIST */
-
-
-/**************************************************************************************
-** Function XML_VlistInit
-**
-** Description Initialize xml parser state machine.
-**
-** Parameters p_xml_state: address of parser structure, allocate an additional space
-** of size XML_VLIST_CARRY_OVER_LEN right after p_xml_state
-** to hold carry over data.
-** p_entry : points start of output vlist entry. caller needs do free this memory
-** max_entry : max is 16 bit integer value which is the maximum number of vlist entries.
-
-**
-** Returns void
-**************************************************************************************/
-BT_API void XML_VlistInit(tXML_VLIST_PARSER *p_xml_state,
- tXML_VLIST_ENTRY *p_entry,
- const UINT16 max_entry );
-
-
-/**************************************************************************************
-** Function XML_VlistParse
-**
-** Description This function is called to parse the xml data received from OBEX
-** into vlist entries associated with properties value. It can also be
-** used as clean up function to delete left over data from previous parse.
-** This clean up function is typically used when application runs out of
-** resource and decides to discard extra xml data received.
-**
-** Parameters p_xml_state: pointer to a xml parser initialized by XML_VlistInit().
-** xml_data: valid pointer to OBEX list data in xml format.
-** xml_len: length of the package, must be non-zero value.
-** dst_data: valid pointer to the buffer for holding converted vlist entry name and handle.
-** When dst_data is NULL, clean up all remaining data in the parser.
-** dst_len: length of the dst_data buffer, its carry out value is the number
-** of bytes of available buffer remains.
-** num_entries: current number of entries, in the end it is the total number of entries
-**
-** Returns tXML_VLIST_RES (see xml_vlist_api.h)
-** XML_PENDING: parsing not completed
-** XML_END_LIST: found /vCard-listing but no final flag detected
-** XML_VLIST_OUT_FULL: reached max_entry -> do not call parser anymore!!! dump data
-** XML_VLIST_DST_NO_RES : run out of dst buffer resource while
-** some xml data still remains.
-
-**************************************************************************************/
-BT_API extern tXML_VLIST_RES XML_VlistParse( tXML_VLIST_PARSER *p_xml_state,
- UINT8 *xml_data, UINT16 xml_len,
- UINT8 *dst_data, UINT16 *dst_len,
- UINT16 *num_entries );
-
-
-#endif
diff --git a/stack/obx/hdrs/obx_dauth.c b/stack/obx/hdrs/obx_dauth.c
deleted file mode 100644
index 91d4bd7..0000000
--- a/stack/obx/hdrs/obx_dauth.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_dauth.c
-**
-** File: OBEX Authentication related functions
-**
-** Copyright (c) 2003-2008, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-#include "bt_target.h"
-#include "obx_api.h"
-
-
-
-
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
-
-/*******************************************************************************
-**
-** Function OBX_ReadChallenge
-**
-** Description This function is called by the client to read the Realm and
-** options of the Authentication Challenge Header in the
-** given OBEX packet ( from an OBX_PASSWORD_EVT event).
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadChallenge(BT_HDR *p_pkt, tOBX_CHARSET *p_charset,
- UINT8 **p_realm, UINT8 *p_len,
- tOBX_AUTH_OPT *p_option)
-{
- BOOLEAN status;
- tOBX_TRIPLET triplet[OBX_MAX_NUM_AUTH_TRIPLET];
- UINT8 num_trip = OBX_MAX_NUM_AUTH_TRIPLET;
- UINT8 xx;
-
- /* The coverity complaints on this function is not correct.
- * The value in triplet[] is set/initialized by OBX_ReadTriplet if it returns TRUE.
- * leave this unnecessary memset here */
- memset( triplet, 0, sizeof(triplet ));
-
- *p_len = 0;
- *p_option = OBX_AO_NONE;
- *p_realm = NULL;
- *p_charset = OBX_RCS_ASCII; /* 0 */
- status = OBX_ReadTriplet(p_pkt, OBX_HI_CHALLENGE, triplet, &num_trip);
- if(status)
- {
- for(xx=0; xx<num_trip; xx++)
- {
- switch(triplet[xx].tag)
- {
- case OBX_OPTIONS_CHLNG_TAG:
- *p_option = triplet[xx].p_array[0];
- break;
- case OBX_REALM_CHLNG_TAG:
- *p_charset = triplet[xx].p_array[0];
- *p_len = triplet[xx].len - 1;
- *p_realm = &(triplet[xx].p_array[1]);
- break;
- /* The user does not need to know the nonce value
- case OBX_NONCE_CHLNG_TAG:
- break;
- */
- }
- }
- }
-
- return status;
-}
-#endif
-
-
-
-#if (OBX_SERVER_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function OBX_ReadAuthParams
-**
-** Description This function is called by the server to read the User ID of
-** the Authentication Response Header in the given OBEX packet
-** ( from an OBX_PASSWORD_EVT event).
-** This function also
-** checks if the authentication challenge header exists and
-** checks the authentication challenge options.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadAuthParams(BT_HDR *p_pkt, UINT8 **p_userid, UINT8 *p_len,
- BOOLEAN *is_challenged, tOBX_AUTH_OPT *p_option)
-{
- BOOLEAN status;
- tOBX_TRIPLET triplet[OBX_MAX_NUM_AUTH_TRIPLET];
- UINT8 num_trip = OBX_MAX_NUM_AUTH_TRIPLET;
- UINT8 xx;
-
- /* The coverity complaints on this function is not correct.
- * The value in triplet[] is set/initialized by OBX_ReadTriplet if it returns TRUE.
- * leave this unnecessary memset here */
- memset( triplet, 0, sizeof(triplet ));
-
- *p_userid = NULL;
- *p_len = 0;
- *is_challenged = FALSE;
- *p_option = OBX_AO_NONE;
- status = OBX_ReadTriplet(p_pkt, OBX_HI_AUTH_RSP, triplet, &num_trip);
- if(status)
- {
- /* found authentication response, but we do not know if it has user id.
- * assume no user id */
- *p_len = 0;
- for(xx=0; xx<num_trip; xx++)
- {
- if(triplet[xx].tag == OBX_USERID_RSP_TAG)
- {
- *p_len = triplet[xx].len;
- *p_userid = triplet[xx].p_array;
- break;
- }
- }
-
- /* read the authentication challenge header,
- * only if the authentication response header exists */
- if( OBX_ReadTriplet(p_pkt, OBX_HI_CHALLENGE, triplet, &num_trip) == TRUE)
- {
- *is_challenged = TRUE;
- for(xx=0; xx<num_trip; xx++)
- {
- if(triplet[xx].tag == OBX_OPTIONS_CHLNG_TAG)
- {
- *p_option = triplet[xx].p_array[0];
- break;
- }
- }
- }
- }
- return status;
-}
-#endif
-
-
-
diff --git a/stack/obx/hdrs/obx_dbtp.c b/stack/obx/hdrs/obx_dbtp.c
deleted file mode 100644
index fbf473d..0000000
--- a/stack/obx/hdrs/obx_dbtp.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_dbtp.c
-**
-** File: OBEX Headers Decode Utility functions
-** - for current Bluetooth profiles
-**
-** Copyright (c) 2003-2008, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-#include "bt_target.h"
-#include "obx_api.h"
-#include "obx_int.h"
-
-
-
-
-/*******************************************************************************
-**
-** Function OBX_ReadTypeHdr
-**
-** Description This function is called to get the Type Header in the given
-** OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadTypeHdr(BT_HDR *p_pkt, UINT8 **p_type, UINT16 *p_len)
-{
- return OBX_ReadByteStrHdr(p_pkt, OBX_HI_TYPE, p_type, p_len, 0);
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadLengthHdr
-**
-** Description This function is called to get the Length Header in the given
-** OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadLengthHdr(BT_HDR *p_pkt, UINT32 *p_len)
-{
- return OBX_Read4ByteHdr(p_pkt, OBX_HI_LENGTH, p_len);
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadTargetHdr
-**
-** Description This function is called to get the Target Header in the
-** given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadTargetHdr(BT_HDR *p_pkt, UINT8 **p_target, UINT16 *p_len, UINT8 next)
-{
- return OBX_ReadByteStrHdr(p_pkt, OBX_HI_TARGET, p_target, p_len, next);
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadBodyHdr
-**
-** Description This function is called to get the Body Header in the
-** given OBEX packet.
-**
-** Returns 1, if a single header is in the OBEX packet.
-** 2, if a end of body header is in the OBEX packet.
-** 0, (FALSE) otherwise.
-**
-*******************************************************************************/
-UINT8 OBX_ReadBodyHdr(BT_HDR *p_pkt, UINT8 **p_body, UINT16 *p_len, BOOLEAN *p_end)
-{
- BOOLEAN status;
- UINT8 *p_body2;
- UINT16 len2;
- UINT8 num;
-
- *p_end = FALSE;
- num = OBX_ReadByteStrHdr(p_pkt, OBX_HI_BODY, p_body, p_len, 0);
- status = OBX_ReadByteStrHdr(p_pkt, OBX_HI_BODY_END, &p_body2, &len2, 0);
- if(num == FALSE && status == TRUE)
- {
- *p_body = p_body2;
- *p_len = len2;
- *p_end = TRUE;
- }
- num += status;
-
- return num;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadWhoHdr
-**
-** Description This function is called to get the Who Header in the
-** given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadWhoHdr(BT_HDR *p_pkt, UINT8 **p_who, UINT16 *p_len)
-{
- return OBX_ReadByteStrHdr(p_pkt, OBX_HI_WHO, p_who, p_len, 0);
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadAppParamHdr
-**
-** Description This function is called to get the Application Parameter Header
-** in the given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadAppParamHdr(BT_HDR *p_pkt, UINT8 *p_tag, UINT8 **p_app_param, UINT8 *p_len, UINT8 next)
-{
- BOOLEAN status;
- tOBX_TRIPLET triplet[OBX_MAX_TRIPLET];
- UINT8 num = OBX_MAX_TRIPLET;
-
- /* The coverity complaints on this function is not correct.
- * The value in triplet[] is set/initialized by OBX_ReadTriplet if it returns TRUE.
- * leave this unnecessary memset here */
- memset( triplet, 0, sizeof(triplet ));
-
- status = OBX_ReadTriplet(p_pkt, OBX_HI_APP_PARMS, triplet, &num);
- if(status == TRUE)
- {
- if(next >= num)
- {
- status = FALSE;
- }
- else
- {
- *p_tag = triplet[next].tag;
- *p_app_param = triplet[next].p_array;
- *p_len = triplet[next].len;
- OBX_TRACE_DEBUG3( "OBX_ReadAppParamHdr: next: %d, tag: %x, len: %d",
- next, *p_tag, *p_len);
- }
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadPermissionHdr
-**
-** Description This function is called to get the Application Parameter Header
-** in the given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadPermissionHdr(BT_HDR *p_pkt, UINT8 *p_user, UINT8 *p_group, UINT8 *p_other)
-{
- UINT32 permission;
- BOOLEAN status = FALSE;
-
- if (OBX_Read4ByteHdr(p_pkt, OBX_HI_PERMISSION, &permission))
- {
- *p_other = (permission & 0xFF);
- permission >>= 8;
- *p_group = (permission & 0xFF);
- permission >>= 8;
- *p_user = (permission & 0xFF);
- status = TRUE;
- }
-
- return status;
-}
-
-
-
-
diff --git a/stack/obx/hdrs/obx_dopt.c b/stack/obx/hdrs/obx_dopt.c
deleted file mode 100644
index e3d0d27..0000000
--- a/stack/obx/hdrs/obx_dopt.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_dopt.c
-**
-** File: OBEX Headers Decode Utility functions
-** - optional functions
-**
-** Copyright (c) 2003-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include "bt_target.h"
-#include "obx_api.h"
-
-
-
-
-
-
-/*******************************************************************************
-**
-** Function OBX_ReadTimeHdr
-**
-** Description This function is called to get the Time Header in the given
-** OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadTimeHdr(BT_HDR *p_pkt, UINT8 **p_time, UINT16 *p_len)
-{
- return OBX_ReadByteStrHdr(p_pkt, OBX_HI_TIME, p_time, p_len, 0);
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_ReadHttpHdr
-**
-** Description This function is called to get the HTTP Header in the
-** given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadHttpHdr(BT_HDR *p_pkt, UINT8 **p_http, UINT16 *p_len, UINT8 next)
-{
- return OBX_ReadByteStrHdr(p_pkt, OBX_HI_HTTP, p_http, p_len, next);
-}
-
diff --git a/stack/obx/hdrs/obx_dunic.c b/stack/obx/hdrs/obx_dunic.c
deleted file mode 100644
index c8f6b12..0000000
--- a/stack/obx/hdrs/obx_dunic.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_dunic.c
-**
-** File: OBEX Headers Decode Utility functions
-** - Unicode functions
-**
-** Copyright (c) 2003-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include "bt_target.h"
-#include "obx_api.h"
-
-
-
-
-/*******************************************************************************
-**
-** Function OBX_ReadNameHdr
-**
-** Description This function is called to get the Name Header in the given
-** OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadNameHdr(BT_HDR *p_pkt, UINT16 *p_name, UINT16 *p_len)
-{
- return OBX_ReadUnicodeHdr(p_pkt, OBX_HI_NAME, p_name, p_len);
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadDescrHdr
-**
-** Description This function is called to get the Description Header in the
-** given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadDescrHdr(BT_HDR *p_pkt, UINT16 *p_descr, UINT16 *p_len)
-{
- return OBX_ReadUnicodeHdr(p_pkt, OBX_HI_DESCRIPTION, p_descr, p_len);
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadDestNameHdr
-**
-** Description This function is called to get the DestName Header in the
-** given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadDestNameHdr(BT_HDR *p_pkt, UINT16 *p_dest, UINT16 *p_len)
-{
- return OBX_ReadUnicodeHdr(p_pkt, OBX_HI_DEST_NAME, p_dest, p_len);
-}
diff --git a/stack/obx/hdrs/obx_dutf.c b/stack/obx/hdrs/obx_dutf.c
deleted file mode 100644
index a800428..0000000
--- a/stack/obx/hdrs/obx_dutf.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_dutf.c
-**
-** File: OBEX Headers Decode Utility functions
-** - Unicode conversion functions
-**
-** Copyright (c) 2003-2009, Broadcom Corp., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include "bt_target.h"
-#include "gki.h"
-#include "obx_api.h"
-
-
-/*******************************************************************************
-**
-** Function OBX_ReadUtf8NameHdr
-**
-** Description This function is called to get the Name Header in the given
-** OBEX packet. If Name header exists in the given OBEX packet,
-** it is converted to UTF8 format and copied into p_name.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadUtf8NameHdr(BT_HDR *p_pkt, UINT8 *p_name, UINT16 max_len)
-{
- BOOLEAN status;
- UINT16 *p_unicode = (UINT16 *)GKI_getbuf((UINT16)((max_len + 1) * 2));
- UINT16 len = max_len;
-
- status = OBX_ReadUnicodeHdr(p_pkt, OBX_HI_NAME, p_unicode, &len);
- utfc_16_to_8(p_name, max_len, p_unicode, len);
- GKI_freebuf(p_unicode);
- return status;
-}
-
-
-
-/*******************************************************************************
-**
-** Function OBX_ReadUtf8DescrHdr
-**
-** Description This function is called to get the Description Header in the
-** given OBEX packet. If Description header exists in the given
-** OBEX packet, it is converted to UTF8 format and copied into
-** p_descr.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadUtf8DescrHdr(BT_HDR *p_pkt, UINT8 *p_descr, UINT16 max_len)
-{
- BOOLEAN status;
- UINT16 *p_unicode = (UINT16 *)GKI_getbuf((UINT16)((max_len + 1) * 2));
- UINT16 len = max_len;
-
- status = OBX_ReadUnicodeHdr(p_pkt, OBX_HI_DESCRIPTION, p_unicode, &len);
- utfc_16_to_8(p_descr, max_len, p_unicode, len);
- GKI_freebuf(p_unicode);
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadUtf8DestNameHdr
-**
-** Description This function is called to get the DestName Header in the
-** given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadUtf8DestNameHdr(BT_HDR *p_pkt, UINT8 *p_dest, UINT16 max_len)
-{
- BOOLEAN status;
- UINT16 *p_unicode = (UINT16 *)GKI_getbuf((UINT16)((max_len + 1) * 2));
- UINT16 len = max_len;
-
- status = OBX_ReadUnicodeHdr(p_pkt, OBX_HI_DEST_NAME, p_unicode, &len);
- utfc_16_to_8(p_dest, max_len, p_unicode, len);
- GKI_freebuf(p_unicode);
- return status;
-}
-
-
diff --git a/stack/obx/hdrs/obx_dwchar.c b/stack/obx/hdrs/obx_dwchar.c
deleted file mode 100644
index 2aa5ebd..0000000
--- a/stack/obx/hdrs/obx_dwchar.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_dwchar.c
-**
-** File: OBEX Headers Decode Utility functions
-** - Unicode conversion functions
-**
-** Copyright (c) 2003-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include "bt_target.h"
-#include "gki.h"
-#include "obx_api.h"
-
-
-/*******************************************************************************
-**
-** Function OBX_ReadAsciiNameHdr
-**
-** Description This function is called to get the Name Header in the given
-** OBEX packet. If Name header exists in the given OBEX packet,
-** it is converted to ASCII format and copied into p_name.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadAsciiNameHdr(BT_HDR *p_pkt, char *p_name, UINT16 max_len)
-{
- BOOLEAN status;
- UINT16 *p_unicode = (UINT16 *)GKI_getbuf((UINT16)((max_len + 1) * 2));
- UINT16 len = max_len;
-
- status = OBX_ReadUnicodeHdr(p_pkt, OBX_HI_NAME, p_unicode, &len);
- OBX_WcharToChar(p_name, p_unicode, max_len);
- GKI_freebuf(p_unicode);
- return status;
-}
-
-
-
-/*******************************************************************************
-**
-** Function OBX_ReadAsciiDescrHdr
-**
-** Description This function is called to get the Description Header in the
-** given OBEX packet. If Description header exists in the given
-** OBEX packet, it is converted to ASCII format and copied into
-** p_descr.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadAsciiDescrHdr(BT_HDR *p_pkt, char *p_descr, UINT16 max_len)
-{
- BOOLEAN status;
- UINT16 *p_unicode = (UINT16 *)GKI_getbuf((UINT16)((max_len + 1) * 2));
- UINT16 len = max_len;
-
- status = OBX_ReadUnicodeHdr(p_pkt, OBX_HI_DESCRIPTION, p_unicode, &len);
- OBX_WcharToChar(p_descr, p_unicode, max_len);
- GKI_freebuf(p_unicode);
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadAsciiDestNameHdr
-**
-** Description This function is called to get the DestName Header in the
-** given OBEX packet. If DestName header exists in the given
-** OBEX packet, it is converted to ASCII format and copied into
-** p_descr.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadAsciiDestNameHdr(BT_HDR *p_pkt, char *p_dest, UINT16 max_len)
-{
- BOOLEAN status;
- UINT16 *p_unicode = (UINT16 *)GKI_getbuf((UINT16)((max_len + 1) * 2));
- UINT16 len = max_len;
-
- status = OBX_ReadUnicodeHdr(p_pkt, OBX_HI_DEST_NAME, p_unicode, &len);
- OBX_WcharToChar(p_dest, p_unicode, max_len);
- GKI_freebuf(p_unicode);
- return status;
-}
diff --git a/stack/obx/hdrs/obx_ebtp.c b/stack/obx/hdrs/obx_ebtp.c
deleted file mode 100644
index 93dd988..0000000
--- a/stack/obx/hdrs/obx_ebtp.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_ebtp.c
-**
-** File: OBEX Headers Encode Utility functions
-** - for current Bluetooth profiles
-**
-** Copyright (c) 2003-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "bt_target.h"
-#include "obx_api.h"
-
-
-
-/*******************************************************************************
-**
-** Function OBX_AddTypeHdr
-**
-** Description This function is called to add an OBEX Type header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddTypeHdr(BT_HDR *p_pkt, char *p_type)
-{
- return OBX_AddByteStrHdr(p_pkt, OBX_HI_TYPE, (UINT8*)p_type, (UINT16)(strlen(p_type)+1));
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddLengthHdr
-**
-** Description This function is called to add an OBEX Length header to an OBEX
-** packet. The Length header describes the total length in bytes of
-** the object.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddLengthHdr(BT_HDR *p_pkt, UINT32 len)
-{
- return OBX_Add4ByteHdr(p_pkt, OBX_HI_LENGTH, len);
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddTargetHdr
-**
-** Description This function is called to add an OBEX Target header to an OBEX
-** packet. This header is most commonly used in Connect packets.
-**
-** NOTE: The target header must be the first header in an OBEX message.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddTargetHdr(BT_HDR *p_pkt, UINT8 *p_target, UINT16 len)
-{
- BOOLEAN add = FALSE;
- UINT8 *p;
-
- if (p_pkt->len == 0)
- {
- add = TRUE;
- }
- else if (p_pkt->len == 2)
- {
- p = (UINT8 *)(p_pkt+1)+p_pkt->offset;
- if ((*p) == OBX_HI_SESSION_SN)
- add = TRUE;
-
- }
- /* allow SSN to preceed target header */
- if (add)
- return OBX_AddByteStrHdr(p_pkt, OBX_HI_TARGET, p_target, len);
- else
- {
- BT_ERROR_TRACE_1(TRACE_LAYER_OBEX, "Target header must be the first:%d", p_pkt->len) ;
- return FALSE;
- }
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddBodyHdr
-**
-** Description This function is called to add an OBEX body header
-** to an OBEX packet.
-**
-** NOTE: The body header must be the last header in an OBEX message.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddBodyHdr(BT_HDR *p_pkt, UINT8 *p_body, UINT16 len, BOOLEAN end)
-{
- UINT8 id = (end)?OBX_HI_BODY_END:OBX_HI_BODY;
- return OBX_AddByteStrHdr(p_pkt, id, p_body, len);
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_AddWhoHdr
-**
-** Description This function is called to add an OBEX Who header to an OBEX
-** packet.
-**
-** Note: Who header is typically used in an OBEX CONNECT response packet
-** to indicate the UUID of the service that has accepted the
-** directed connection. If the server calls OBX_StartServer() with
-** specified target header, this OBEX implementation automatically
-** adds this WHO header to the CONNECT response packet. If
-** OBX_StartServer() is called with target header length as 0, the
-** OBEX API user is responsible to add the WHO header.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddWhoHdr(BT_HDR *p_pkt, UINT8 *p_who, UINT16 len)
-{
- return OBX_AddByteStrHdr(p_pkt, OBX_HI_WHO, p_who, len);
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddAppParamHdr
-**
-** Description This function is called to add an OBEX Application Parameter
-** header to an OBEX packet. This header is used by the application
-** layer above OBEX to convey application specific information.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddAppParamHdr(BT_HDR *p_pkt, tOBX_TRIPLET *p_triplet, UINT8 num)
-{
- return OBX_AddTriplet(p_pkt, OBX_HI_APP_PARMS, p_triplet, num);
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddPermissionHdr
-**
-** Description This function is called to add an OBEX Permission header to an OBEX
-** packet.
-** bit 0 is set for read permission
-** bit 1 is set for write permission
-** bit 2 is set for delete permission
-** bit 7 is set for modify permission
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddPermissionHdr(BT_HDR *p_pkt, UINT8 user, UINT8 group, UINT8 other)
-{
- UINT32 permission = user;
- permission <<= 8;
- permission |= group;
- permission <<= 8;
- permission |= other;
- return OBX_Add4ByteHdr(p_pkt, OBX_HI_PERMISSION, permission);
-}
-
-
diff --git a/stack/obx/hdrs/obx_eopt.c b/stack/obx/hdrs/obx_eopt.c
deleted file mode 100644
index e0b0487..0000000
--- a/stack/obx/hdrs/obx_eopt.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_eopt.c
-**
-** File: OBEX Headers Encode Utility functions
-** - optional functions
-**
-** Copyright (c) 2003-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-#include "bt_target.h"
-#include "obx_api.h"
-
-
-
-/*******************************************************************************
-**
-** Function OBX_AddTimeHdr
-**
-** Description This function is called to add an OBEX Time header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddTimeHdr(BT_HDR *p_pkt, char *p_time)
-{
- return OBX_AddByteStrHdr(p_pkt, OBX_HI_TIME, (UINT8 *)p_time, (UINT16)strlen(p_time));
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_AddHttpHdr
-**
-** Description This function is called to add an OBEX HTTP header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddHttpHdr(BT_HDR *p_pkt, UINT8 *p_http, UINT16 len)
-{
- return OBX_AddByteStrHdr(p_pkt, OBX_HI_HTTP, p_http, len);
-}
-
-
diff --git a/stack/obx/hdrs/obx_eunic.c b/stack/obx/hdrs/obx_eunic.c
deleted file mode 100644
index 6b5cb29..0000000
--- a/stack/obx/hdrs/obx_eunic.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_eunic.c
-**
-** File: OBEX Headers Encode Utility functions
-** - Unicode functions
-**
-** Copyright (c) 2003-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include "bt_target.h"
-#include "obx_api.h"
-
-
-/*******************************************************************************
-**
-** Function OBX_AddNameHdr
-**
-** Description This function is called to add an OBEX Name header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddNameHdr(BT_HDR *p_pkt, UINT16 *p_name, UINT16 len)
-{
- return OBX_AddUnicodeHdr(p_pkt, OBX_HI_NAME, p_name, len);
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddDescrHdr
-**
-** Description This function is called to add an OBEX Description header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddDescrHdr(BT_HDR *p_pkt, UINT16 *p_descr, UINT16 len)
-{
- return OBX_AddUnicodeHdr(p_pkt, OBX_HI_DESCRIPTION, p_descr, len);
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddDestNameHdr
-**
-** Description This function is called to add an OBEX DestName header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddDestNameHdr(BT_HDR *p_pkt, UINT16 *p_dest, UINT16 len)
-{
- return OBX_AddUnicodeHdr(p_pkt, OBX_HI_DEST_NAME, p_dest, len);
-}
-
-
diff --git a/stack/obx/hdrs/obx_eutf.c b/stack/obx/hdrs/obx_eutf.c
deleted file mode 100644
index b298500..0000000
--- a/stack/obx/hdrs/obx_eutf.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_eutf.c
-**
-** File: OBEX Headers Encode Utility functions
-** - Unicode conversion functions
-**
-** Copyright (c) 2003-2005, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-#include "bt_target.h"
-#include "gki.h"
-#include "obx_api.h"
-
-
-/*******************************************************************************
-**
-** Function OBX_AddUtf8NameHdr
-**
-** Description This function is called to add an OBEX Name header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddUtf8NameHdr(BT_HDR *p_pkt, UINT8 *p_name)
-{
- BOOLEAN status = FALSE;
- UINT16 utf16_len = 0;
- UINT16 *p_utf16 = NULL;
-
- if (p_name)
- {
- utf16_len = strlen((char *)p_name) * 2 + 2;
- p_utf16 = (UINT16 *)GKI_getbuf(utf16_len);
- }
-
- if (p_utf16)
- utf16_len = utfc_8_to_16(p_utf16, utf16_len, p_name);
- else
- utf16_len = 0;
-
- status = OBX_AddUnicodeHdr(p_pkt, OBX_HI_NAME, p_utf16, utf16_len);
-
- if (p_utf16)
- GKI_freebuf(p_utf16);
-
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddUtf8DescrHdr
-**
-** Description This function is called to add an OBEX Description header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddUtf8DescrHdr(BT_HDR *p_pkt, UINT8 *p_descr)
-{
- BOOLEAN status = FALSE;
- UINT16 utf16_len;
- UINT16 *p_utf16;
-
- utf16_len = strlen((char *)p_descr) * 2 + 2;
- p_utf16 = (UINT16 *)GKI_getbuf(utf16_len);
- if(p_utf16)
- {
- utf16_len = utfc_8_to_16(p_utf16, utf16_len, p_descr);
- status = OBX_AddUnicodeHdr(p_pkt, OBX_HI_DESCRIPTION, p_utf16, utf16_len);
- GKI_freebuf(p_utf16);
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddUtf8DestNameHdr
-**
-** Description This function is called to add an OBEX DestName header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddUtf8DestNameHdr(BT_HDR *p_pkt, UINT8 *p_dest)
-{
- BOOLEAN status = FALSE;
- UINT16 utf16_len;
- UINT16 *p_utf16;
-
- utf16_len = strlen((char *)p_dest) * 2 + 2;
- p_utf16 = (UINT16 *)GKI_getbuf(utf16_len);
- if(p_utf16)
- {
- utf16_len = utfc_8_to_16(p_utf16, utf16_len, p_dest);
- status = OBX_AddUnicodeHdr(p_pkt, OBX_HI_DEST_NAME, p_utf16, utf16_len);
- GKI_freebuf(p_utf16);
- }
- return status;
-}
-
-
-
diff --git a/stack/obx/hdrs/obx_ewchar.c b/stack/obx/hdrs/obx_ewchar.c
deleted file mode 100644
index 2025baa..0000000
--- a/stack/obx/hdrs/obx_ewchar.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_ewchar.c
-**
-** File: OBEX Headers Encode Utility functions
-** - Unicode conversion functions
-**
-** Copyright (c) 2003-2005, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-#include "bt_target.h"
-#include "gki.h"
-#include "obx_api.h"
-
-/*******************************************************************************
-**
-** Function OBX_AddAsciiNameHdr
-**
-** Description This function is called to add an OBEX Name header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddAsciiNameHdr(BT_HDR *p_pkt, char *p_name)
-{
- BOOLEAN status;
- UINT16 len = 0;
- UINT16 *p_unicode = NULL;
-
- if(p_name)
- {
- len = strlen(p_name) + 1;
- p_unicode = (UINT16 *)GKI_getbuf((UINT16)(len*2));
- }
-
- if(p_unicode)
- len = OBX_CharToWchar(p_unicode, p_name, len);
- else
- len = 0;
-
- status = OBX_AddUnicodeHdr(p_pkt, OBX_HI_NAME, p_unicode, len);
-
- if(p_unicode)
- GKI_freebuf(p_unicode);
- return status;
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_AddAsciiDescrHdr
-**
-** Description This function is called to add an OBEX Description header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddAsciiDescrHdr(BT_HDR *p_pkt, char *p_descr)
-{
- BOOLEAN status;
- UINT16 len = strlen(p_descr) + 1;
- UINT16 *p_unicode = (UINT16 *)GKI_getbuf((UINT16)(len*2));
-
- len = OBX_CharToWchar(p_unicode, p_descr, len);
- status = OBX_AddUnicodeHdr(p_pkt, OBX_HI_DESCRIPTION, p_unicode, len);
- GKI_freebuf(p_unicode);
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddAsciiDestNameHdr
-**
-** Description This function is called to add an OBEX DestName header
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddAsciiDestNameHdr(BT_HDR *p_pkt, char *p_dest)
-{
- BOOLEAN status;
- UINT16 len = strlen(p_dest) + 1;
- UINT16 *p_unicode = (UINT16 *)GKI_getbuf((UINT16)(len*2));
-
- len = OBX_CharToWchar(p_unicode, p_dest, len);
- status = OBX_AddUnicodeHdr(p_pkt, OBX_HI_DEST_NAME, p_unicode, len);
- GKI_freebuf(p_unicode);
- return status;
-}
-
-
-
diff --git a/stack/obx/hdrs/obx_gen.c b/stack/obx/hdrs/obx_gen.c
deleted file mode 100644
index 9b25e04..0000000
--- a/stack/obx/hdrs/obx_gen.c
+++ /dev/null
@@ -1,896 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_gen.c
-**
-** File: OBEX Headers Utility functions
-** - common/generic functions
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "bt_target.h"
-#include "wcassert.h"
-#include "obx_api.h"
-#include "gki.h"
-#include "obx_int.h"
-
-const UINT8 obx_hdr_start_offset[] =
-{
- OBX_CONN_HDRS_OFFSET, /* OBX_CONNECT_REQ_EVT */
- OBX_SESS_HDRS_OFFSET, /* OBX_SESSION_REQ_EVT */
- OBX_DISCON_HDRS_OFFSET, /* OBX_DISCONNECT_REQ_EVT */
- OBX_PUT_HDRS_OFFSET, /* OBX_PUT_REQ_EVT */
- OBX_GET_HDRS_OFFSET, /* OBX_GET_REQ_EVT */
- OBX_SETPATH_REQ_HDRS_OFFSET,/* OBX_SETPATH_REQ_EVT */
- OBX_ABORT_HDRS_OFFSET, /* OBX_ABORT_REQ_EVT */
- OBX_ACTION_HDRS_OFFSET, /* OBX_ACTION_REQ_EVT */
- OBX_CONN_HDRS_OFFSET, /* OBX_CONNECT_RSP_EVT */
- OBX_RESPONSE_HDRS_OFFSET, /* OBX_SESSION_RSP_EVT */
- OBX_RESPONSE_HDRS_OFFSET, /* OBX_DISCONNECT_RSP_EVT */
- OBX_RESPONSE_HDRS_OFFSET, /* OBX_PUT_RSP_EVT */
- OBX_RESPONSE_HDRS_OFFSET, /* OBX_GET_RSP_EVT */
- OBX_RESPONSE_HDRS_OFFSET, /* OBX_SETPATH_RSP_EVT */
- OBX_RESPONSE_HDRS_OFFSET, /* OBX_ABORT_RSP_EVT */
- OBX_RESPONSE_HDRS_OFFSET /* OBX_ACTION_RSP_EVT */
-};
-
-/*******************************************************************************
-**
-** Function obx_access_rsp_code
-**
-** Description This function is used to read/change response code
-**
-** Returns void.
-**
-*******************************************************************************/
-void obx_access_rsp_code(BT_HDR *p_pkt, UINT8 *p_rsp_code)
-{
- UINT8 *p = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- if(*p_rsp_code == OBX_RSP_DEFAULT)
- *p_rsp_code = *p;
- else
- *p = *p_rsp_code;
-}
-
-/*******************************************************************************
-**
-** Function obx_adjust_packet_len
-**
-** Description Adjust the packet length in the OBEX packet
-**
-** Returns void.
-**
-*******************************************************************************/
-void obx_adjust_packet_len(BT_HDR *p_pkt)
-{
- UINT8 *p = (UINT8 *)(p_pkt + 1) + p_pkt->offset + 1;
- UINT16_TO_BE_STREAM(p, p_pkt->len);
-}
-
-/*******************************************************************************
-**
-** Function obx_read_header_len
-**
-** Description ph is the beginning of an OBEX header
-**
-** Returns total length of the header
-**
-*******************************************************************************/
-UINT16 obx_read_header_len(UINT8 *ph)
-{
- UINT16 len = 0;
-
- /*
- OBX_TRACE_DEBUG1( "obx_read_header_len: 0x%x", *ph);
- */
- switch(*ph&OBX_HI_TYPE_MASK)
- {
- case OBX_HI_TYPE_BYTE:
- len = 2;
- break;
- case OBX_HI_TYPE_INT:
- len = 5;
- break;
- case OBX_HI_TYPE_ARRAY:
- case OBX_HI_TYPE_UNIC:
- ph++;
- BE_STREAM_TO_UINT16(len, ph);
- break;
- }
- /*
- OBX_TRACE_DEBUG1( "len:%d", len);
- */
- return len;
-}
-
-/*******************************************************************************
-**
-** Function obx_dup_pkt
-**
-** Description This function duplicate the OBEX message
-**
-** Returns BT_HDR *.
-**
-*******************************************************************************/
-BT_HDR * obx_dup_pkt(BT_HDR *p_pkt)
-{
- BT_HDR *p_new;
- UINT16 size = p_pkt->len + p_pkt->offset + BT_HDR_SIZE;
-
- if (size < GKI_MAX_BUF_SIZE)
- {
- /* Use the largest general pool to allow challenge tags appendage */
- p_new = (BT_HDR *)GKI_getbuf(GKI_MAX_BUF_SIZE);
- }
- else
- {
- p_new = (BT_HDR *) GKI_getpoolbuf(OBX_LRG_DATA_POOL_ID);
- }
-
- if (p_new)
- memcpy(p_new, p_pkt, size );
-
- return p_new;
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_HdrInit
-**
-** Description This function is called to initialize an OBEX packet. This
-** function takes a GKI buffer and sets the offset in BT_HDR as
-** OBX_HDR_OFFSET, the len as 0. The layer_specific is set to the
-** length still available. This function compares the given
-** (pkt_size - BT_HDR_SIZE) with the peer MTU to get the lesser
-** of the two and set the layer_specific to
-** (lesser_size - OBX_HDR_OFFSET).
-** If composing a header for the CONNECT request (there is no
-** client handle yet), use OBX_HANDLE_NULL as the handle.
-**
-** If the pkt_size is larger than the largest public pool size,
-** GKI_MAX_BUF_SIZE, then an attempt to grab a buffer from the reserved OBX
-** data pool will be made.
-** Returns BT_HDR *.
-**
-*******************************************************************************/
-BT_HDR *OBX_HdrInit(tOBX_HANDLE handle, UINT16 pkt_size)
-{
- UINT16 mtu = OBX_HandleToMtu(handle);
- BT_HDR *p_pkt = NULL;
- UINT16 buf_size;
-#if (BT_USE_TRACES == TRUE)
- UINT16 req_size = pkt_size;
-#endif
-
- WC_ASSERT(pkt_size > (BT_HDR_SIZE + OBX_HDR_OFFSET));
-
- pkt_size -= BT_HDR_SIZE;
- if(pkt_size > mtu )
- pkt_size = mtu;
- pkt_size += (BT_HDR_SIZE + OBX_HDR_OFFSET);
-
- OBX_TRACE_DEBUG4( "OBX_HdrInit: checking req_size %d, pkt_size:%d, max:%d, offset:%d",
- req_size, pkt_size, GKI_MAX_BUF_SIZE, OBX_HDR_OFFSET);
- /* See if packet will fit in regular public pool */
- if ((pkt_size) < GKI_MAX_BUF_SIZE)
- {
- p_pkt = (BT_HDR *) GKI_getbuf(pkt_size);
- }
- else /* Must use the reserved OBX buffer pool */
- {
- p_pkt = (BT_HDR *) GKI_getpoolbuf(OBX_LRG_DATA_POOL_ID);
- if (!p_pkt)
- {
- OBX_TRACE_DEBUG1( "Out of Large buffers. Trying pkt_size:%d", GKI_MAX_BUF_SIZE);
- p_pkt = (BT_HDR *) GKI_getbuf(GKI_MAX_BUF_SIZE);
- }
- }
-
- if(p_pkt)
- {
- buf_size = GKI_get_buf_size(p_pkt);
- buf_size -= BT_HDR_SIZE;
- if(buf_size > mtu)
- buf_size = mtu;
-
- OBX_TRACE_DEBUG4( "OBX_HdrInit: req_size %d, pkt_size = %d, gki_size %d, buf_size %d",
- req_size, pkt_size, GKI_get_buf_size(p_pkt), buf_size);
-
- p_pkt->offset = OBX_HDR_OFFSET;
- p_pkt->len = 0;
- p_pkt->event = 0;
-
- /* layer specific contains remaining space in packet */
- p_pkt->layer_specific = buf_size - OBX_HDR_OFFSET ;
- p_pkt->layer_specific -= 2;
-
- OBX_TRACE_DEBUG2( "buf size: %d, ls:%d", buf_size, p_pkt->layer_specific);
- }
- else
- {
- OBX_TRACE_ERROR1("OBX_HdrInit: No buffers for size (%d)", pkt_size);
- }
-
- return p_pkt;
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_Add1ByteHdr
-**
-** Description This function is called to add a header with type as UINT8
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_Add1ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT8 data)
-{
- UINT8 *p;
- BOOLEAN status = FALSE;
- UINT16 size = 2; /* total length added by this header - 1/hi & 1/hv */
-
- if(p_pkt)
- {
- p = (UINT8 *)(p_pkt+1)+p_pkt->offset+p_pkt->len;
- /* verify that the HI is of correct type and the remaining length in the packet is good */
- if( ((id & OBX_HI_TYPE_MASK) == OBX_HI_TYPE_BYTE) && (p_pkt->layer_specific >= size) )
- {
- *p++ = id;
- *p++ = data;
-
- p_pkt->len += size;
- p_pkt->layer_specific -= size;
- status = TRUE;
- }
- }
-
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_Add4ByteHdr
-**
-** Description This function is called to add a header with type as UINT32
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_Add4ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT32 data)
-{
- UINT8 *p;
- BOOLEAN status = FALSE;
- UINT16 size = 5; /* total length added by this header - 1/hi & 4/hv */
-
- if(p_pkt)
- {
- p = (UINT8 *)(p_pkt+1)+p_pkt->offset+p_pkt->len;
- /* verify that the HI is of correct type and the remaining length in the packet is good */
- if( ((id & OBX_HI_TYPE_MASK) == OBX_HI_TYPE_INT) && (p_pkt->layer_specific >= size) )
- {
- *p++ = id;
- UINT32_TO_BE_STREAM(p, data);
-
- p_pkt->len += size;
- p_pkt->layer_specific -= size;
- status = TRUE;
- }
- }
-
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddByteStrStart
-**
-** Description This function is called to get the address to the beginning of
-** the byte sequence for an OBEX header in an OBEX packet.
-**
-** Returns The address to add the byte sequence.
-**
-*******************************************************************************/
-UINT8 *OBX_AddByteStrStart(BT_HDR *p_pkt, UINT16 *p_len)
-{
- UINT8 *p = (UINT8 *)(p_pkt + 1) + p_pkt->offset + p_pkt->len + 3;
-
- WC_ASSERT(p_len);
-
- if(*p_len > (p_pkt->layer_specific - 3) || *p_len == 0)
- *p_len = p_pkt->layer_specific - 3;
- return p;
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddByteStrHdr
-**
-** Description This function is called to add a header with type as byte sequence
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddByteStrHdr(BT_HDR *p_pkt, UINT8 id, UINT8 *p_data, UINT16 len)
-{
- UINT8 *p;
- BOOLEAN status = FALSE;
- UINT16 size = (len+3); /* total length added by this header - 1/hi & len+2/hv */
-
- if(p_pkt)
- {
- p = (UINT8 *)(p_pkt+1)+p_pkt->offset+p_pkt->len;
- /* verify that the HI is of correct type and the remaining length in the packet is good */
- if( ((id & OBX_HI_TYPE_MASK) == OBX_HI_TYPE_ARRAY) && (p_pkt->layer_specific >= size) )
- {
- *p++ = id;
- UINT16_TO_BE_STREAM(p, size);
- if(p_data)
- memcpy(p, p_data, len);
-
- p_pkt->len += size;
- p_pkt->layer_specific -= size;
- status = TRUE;
- }
- }
-
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddUnicodeHdr
-**
-** Description This function is called to add a header with type as Unicode string
-** to an OBEX packet.
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddUnicodeHdr(BT_HDR *p_pkt, UINT8 id, UINT16 *p_data, UINT16 len)
-{
- UINT8 *p;
- BOOLEAN status = FALSE;
- UINT16 size, xx;
-
- if(p_pkt)
- {
- p = (UINT8 *)(p_pkt+1)+p_pkt->offset+p_pkt->len;
- size = (len*OBX_UNICODE_SIZE + 3); /* total length added by this header - 1/hi & len*OBX_UNICODE_SIZE+2/hv */
- OBX_TRACE_DEBUG4( "OBX_AddUnicodeHdr len: %d, size: %d, left: %d, id: 0x%x",
- len, size, p_pkt->layer_specific, id );
-
- /* verify that the HI is of correct type and the remaining length in the packet is good */
- if( ((id & OBX_HI_TYPE_MASK) == OBX_HI_TYPE_UNIC) && (p_pkt->layer_specific >= size) )
- {
- *p++ = id;
- UINT16_TO_BE_STREAM(p, size);
- for(xx=0; xx<len; xx++)
- {
- UINT16_TO_BE_STREAM(p, *p_data);
- p_data++;
- }
-
- p_pkt->len += size;
- p_pkt->layer_specific -= size;
- status = TRUE;
- }
- }
-
- return status;
-}
-
-/* Alternate Body header functions: for non-blocking scenario */
-/*******************************************************************************
-**
-** Function OBX_AddBodyStart
-**
-** Description This function is called to get the address to the beginning of
-** the byte sequence for an OBEX body header in an OBEX packet.
-**
-** Returns The address to add body content.
-**
-*******************************************************************************/
-UINT8 *OBX_AddBodyStart(BT_HDR *p_pkt, UINT16 *p_len)
-{
- UINT8 *p = (UINT8 *)(p_pkt + 1) + p_pkt->offset + p_pkt->len + 3;
-
- WC_ASSERT(p_len);
-
- if(*p_len > (p_pkt->layer_specific - 3) || *p_len == 0)
- *p_len = p_pkt->layer_specific - 3;
- return p;
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddBodyEnd
-**
-** Description This function is called to add the HI and the length of HV of an
-** OBEX body header to an OBEX packet. If end is TRUE, HI is
-** OBX_HI_BODY_END. If FALSE, HI is OBX_HI_BODY. It is assumed that
-** the actual value of the body has been copied into the OBEX packet.
-**
-** Returns void
-**
-*******************************************************************************/
-void OBX_AddBodyEnd(BT_HDR *p_pkt, UINT8 *p, UINT16 len, BOOLEAN end)
-{
- UINT8 id = (end)?OBX_HI_BODY_END:OBX_HI_BODY;
- UINT8 *pb = (UINT8 *)(p_pkt + 1) + p_pkt->offset + p_pkt->len;
- *pb++ = id;
- len += 3; /* 1/hi, 2/hv_len */
- UINT16_TO_BE_STREAM(pb, len);
- p_pkt->layer_specific -= len;
- p_pkt->len += len;
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddTriplet
-**
-** Description This function is called to add a header with type as byte sequence
-** to an OBEX packet.
-**
-** Note: The byte sequence uses a Tag-Length-Value encoding scheme
-** These headers include: Application Parameters header
-** Authenticate Challenge header
-** Authenticate Response header
-**
-** Returns TRUE, if the header is added successfully.
-** FALSE, if the operation failed. p_pkt is not altered.
-**
-*******************************************************************************/
-BOOLEAN OBX_AddTriplet(BT_HDR *p_pkt, UINT8 id, tOBX_TRIPLET *p_triplet, UINT8 num)
-{
- UINT8 *p = (UINT8 *)(p_pkt+1)+p_pkt->offset+p_pkt->len;
- BOOLEAN status = FALSE;
- UINT16 size = 3;/* 1/hi & len+2/hv */
- UINT8 xx;
-
- /* calculate the total length added by this header */
- for(xx=0; xx< num; xx++)
- size += (p_triplet[xx].len + 2);
-
- /* verify that the HI is of correct type and the remaining length in the packet is good */
- if( ((id & OBX_HI_TYPE_MASK) == OBX_HI_TYPE_ARRAY) && (p_pkt->layer_specific >= size) )
- {
- *p++ = id;
- UINT16_TO_BE_STREAM(p, size);
- for(xx=0; xx< num; xx++)
- {
- *p++ = p_triplet[xx].tag;
- *p++ = p_triplet[xx].len;
- memcpy(p, p_triplet[xx].p_array, p_triplet[xx].len);
- p += p_triplet[xx].len;
- }
- p_pkt->len += size;
- p_pkt->layer_specific -= size;
- status = TRUE;
- }
-
- return status;
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_CheckNext
-**
-** Description This function is called to check if the given OBEX packet
-** contains the specified header.
-**
-** Returns NULL, if the header is not in the OBEX packet.
-** The pointer to the specified header beginning from HI.
-**
-*******************************************************************************/
-UINT8 * OBX_CheckNext(BT_HDR *p_pkt, UINT8 *p_start, UINT8 id)
-{
- UINT8 *p;
- UINT8 *p_res = NULL;
- UINT16 len, start, skip;
- int remain;
-
- if(p_pkt != NULL && p_start != NULL)
- {
- p = (UINT8 *)(p_pkt+1)+p_pkt->offset;
- if(p_pkt->event <= OBX_MAX_OFFSET_IND)
- {
- start = obx_hdr_start_offset[p_pkt->event-1];
- p++;
- BE_STREAM_TO_UINT16(len, p);
- remain = len - start;
- p = p - 3 + start;
-
- while(remain >0)
- {
- if(*p != id || p < p_start)
- {
- skip = obx_read_header_len(p);
- p += skip;
- /* Just in case this is a bad packet, make sure that remain is >= 0 */
- if(skip && (remain > skip))
- remain -= skip;
- else
- remain = 0;
- }
- else
- {
- p_res = p;
- break;
- }
- }
- }
- }
-
- if (p_pkt)
- {
- OBX_TRACE_DEBUG2( "OBX_CheckNext: remain: %d len:%d", remain, p_pkt->len);
- }
-
- return p_res;
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_CheckHdr
-**
-** Description This function is called to check if the given OBEX packet
-** contains the specified header.
-**
-** Returns NULL, if the header is not in the OBEX packet.
-** The pointer to the specified header beginning from HI.
-**
-*******************************************************************************/
-UINT8 * OBX_CheckHdr(BT_HDR *p_pkt, UINT8 id)
-{
- UINT8 *p;
- UINT8 *p_res = NULL;
- UINT16 len, start, skip;
- int remain;
-
- if(p_pkt != NULL)
- {
- p = (UINT8 *)(p_pkt+1)+p_pkt->offset;
- if(p_pkt->event <= OBX_MAX_OFFSET_IND)
- {
- start = obx_hdr_start_offset[p_pkt->event-1];
- p++;
- BE_STREAM_TO_UINT16(len, p);
- remain = len - start;
- p = p - 3 + start;
-
- while(remain >0)
- {
- if(*p != id)
- {
- skip = obx_read_header_len(p);
- p += skip;
- /* Just in case this is a bad packet, make sure that remain is >= 0 */
- if(skip && (remain > skip))
- remain -= skip;
- else
- remain = 0;
- }
- else
- {
- p_res = p;
- break;
- }
- }
- }
- }
-
- return p_res;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadNumHdrs
-**
-** Description This function is called to check the number of headers in the
-** given OBEX packet
-**
-** Returns number of headers.
-**
-*******************************************************************************/
-UINT8 OBX_ReadNumHdrs(BT_HDR *p_pkt, UINT8 *p_num_body)
-{
- UINT8 num_hdrs = 0, num_body = 0;
- UINT8 *p;
- UINT16 len, start, skip;
- int remain = 0;
-
- if(p_pkt != NULL)
- {
- p = (UINT8 *)(p_pkt+1)+p_pkt->offset;
- if(p_pkt->event == 0)
- {
- /* GKI buffer just went through OBX_HdrInit; not processed by the state machine yet */
- remain = len = p_pkt->len;
- }
- else if(p_pkt->event <= OBX_MAX_OFFSET_IND)
- {
- start = obx_hdr_start_offset[p_pkt->event-1];
- p++;
- BE_STREAM_TO_UINT16(len, p);
- remain = len - start;
- p = p - 3 + start;
- }
-
- while(remain >0)
- {
- num_hdrs++;
- if(*p == OBX_HI_BODY || *p == OBX_HI_BODY_END)
- num_body++;
-
- skip = obx_read_header_len(p);
- p += skip;
- /* Just in case this is a bad packet, make sure that remain is >= 0 */
- if(skip && (remain > skip))
- remain -= skip;
- else
- remain = 0;
-
- }
- }
- if (p_num_body)
- *p_num_body = num_body;
- return num_hdrs;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadHdrLen
-**
-** Description This function is called to check the length of the specified
-** header in the given OBEX packet.
-**
-** Returns OBX_INVALID_HDR_LEN, if the header is not in the OBEX packet.
-** Otherwise the actual length of the header.
-**
-*******************************************************************************/
-UINT16 OBX_ReadHdrLen(BT_HDR *p_pkt, UINT8 id)
-{
- UINT8 *p;
- UINT16 len = OBX_INVALID_HDR_LEN;
-
- if( (p = OBX_CheckHdr(p_pkt, id)) != NULL)
- len = obx_read_header_len(p);
-
- return len;
-}
-
-/*******************************************************************************
-**
-** Function OBX_Read1ByteHdr
-**
-** Description This function is called to get the UINT8 HV of the given HI
-** in the given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_Read1ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT8 *p_data)
-{
- BOOLEAN status = FALSE;
- UINT8 *p_start = OBX_CheckHdr(p_pkt, id);
-
- if(p_start)
- {
- *p_data = *(++p_start);
- status = TRUE;
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_Read4ByteHdr
-**
-** Description This function is called to get the UINT32 HV of the given HI
-** in the given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_Read4ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT32 *p_data)
-{
- BOOLEAN status = FALSE;
- UINT8 *p_start = OBX_CheckHdr(p_pkt, id);
-
- if(p_start)
- {
- p_start++;
- BE_STREAM_TO_UINT32(*p_data, p_start);
- status = TRUE;
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadByteStrHdr
-**
-** Description This function is called to get the byte sequence HV of the given
-** HI in the given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadByteStrHdr(BT_HDR *p_pkt, UINT8 id, UINT8 **p_data, UINT16 *p_len, UINT8 next)
-{
- BOOLEAN status = FALSE;
- UINT8 *p_start = OBX_CheckHdr(p_pkt, id);
-
- if(p_start)
- {
- next += 1;
- while(next && (id == *p_start++))
- {
- next--;
- BE_STREAM_TO_UINT16(*p_len, p_start);
- if(next == 0)
- {
- status = TRUE;
- *p_len -= 3; /* get rid of hi and hv_len */
- *p_data = p_start;
- }
- else
- p_start = p_start + *p_len - 3;
- }
- }
- else
- {
- *p_len = 0;
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadUnicodeHdr
-**
-** Description This function is called to get the Unicode HV of the given
-** HI in the given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadUnicodeHdr(BT_HDR *p_pkt, UINT8 id, UINT16 *p_data, UINT16 *p_len)
-{
- BOOLEAN status = FALSE;
- UINT16 len, xx, max_len;
- UINT8 *p_start = OBX_CheckHdr(p_pkt, id);
-
- if(p_start)
- {
- max_len = *p_len;
- p_start++; /* 1/hi*/
- BE_STREAM_TO_UINT16(len, p_start);
- len -= 3; /* 1/hi, 2/hv_len */
- len /= OBX_UNICODE_SIZE; /* size in UINT16 */
- /* only conver the provided size */
- if( len > max_len)
- len = max_len;
- for(xx=0; xx<len; xx++)
- {
- BE_STREAM_TO_UINT16(*p_data, p_start);
- p_data++;
- }
- *p_len = len;
- status = TRUE;
- max_len -= len;
- while ( (p_start = OBX_CheckNext(p_pkt, p_start, id)) != NULL && (max_len > 0))
- {
- p_start++; /* 1/hi*/
- BE_STREAM_TO_UINT16(len, p_start);
- len -= 3; /* 1/hi, 2/hv_len */
- len /= OBX_UNICODE_SIZE; /* size in UINT16 */
- /* only conver the provided size */
- if( len > max_len)
- len = max_len;
- for(xx=0; xx<len; xx++)
- {
- BE_STREAM_TO_UINT16(*p_data, p_start);
- p_data++;
- }
- *p_len += len;
- max_len -= len;
- }
- }
- else
- {
- *p_len = 0;
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadTriplet
-**
-** Description This function is called to get the Triplet HV of the given
-** HI in the given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadTriplet(BT_HDR *p_pkt, UINT8 id, tOBX_TRIPLET *p_triplet, UINT8 *p_num)
-{
- BOOLEAN status = FALSE;
- UINT8 *p_start = OBX_CheckHdr(p_pkt, id);
- UINT16 len;
- UINT8 count = 0;
-
- if(p_start)
- {
- p_start++; /* 1/hi*/
- BE_STREAM_TO_UINT16(len, p_start);
- len -= 3; /* 1/hi, 2/hv_len */
- while(len && *p_num > count)
- {
- p_triplet[count].tag = *p_start++;
- p_triplet[count].len = *p_start++;
- OBX_TRACE_DEBUG3( "OBX_ReadTriplet: count: %d, tag: %x, len: %d",
- count, p_triplet[count].tag, p_triplet[count].len);
- p_triplet[count].p_array = p_start;
- p_start += p_triplet[count].len;
- if(len > (p_triplet[count].len + 2) )
- len -= (p_triplet[count].len + 2);
- else
- len = 0;
- count++;
- }
- status = TRUE;
- }
- *p_num = count;
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ReadActionIdHdr
-**
-** Description This function is called to get the HV of the Action ID header
-** in the given OBEX packet.
-**
-** Returns TRUE, if the header is in the OBEX packet.
-** FALSE, otherwise.
-**
-*******************************************************************************/
-BOOLEAN OBX_ReadActionIdHdr(BT_HDR *p_pkt, UINT8 *p_data)
-{
- BOOLEAN status = FALSE;
- UINT8 *p_start = OBX_CheckHdr(p_pkt, OBX_HI_ACTION_ID);
-
- if(p_start)
- {
- p_start++;
- /* check for valid values: 0-2 */
- /* do not allow 0x80 - 0xFF (vendor extention) for now. */
- if (*p_start <= OBX_ACT_PERMISSION)
- {
- *p_data = *(p_start);
- status = TRUE;
- }
- }
- return status;
-}
diff --git a/stack/obx/hdrs/obx_wchar.c b/stack/obx/hdrs/obx_wchar.c
deleted file mode 100644
index 5364210..0000000
--- a/stack/obx/hdrs/obx_wchar.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_wchar.c
-**
-** File: OBEX Headers Encode conversion Utility functions
-**
-** Copyright (c) 2003-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include "bt_target.h"
-#include "gki.h"
-#include "obx_api.h"
-
-/*******************************************************************************
-**
-** Function OBX_CharToWchar
-**
-** Description This function is called to convert ASCII to Unicode (UINT16).
-**
-** Returns the length.
-**
-*******************************************************************************/
-UINT16 OBX_CharToWchar (UINT16 *w_str, char* a_str, UINT16 w_size)
-{
- UINT16 result = 0;
- int size = w_size;
-
- if (a_str == NULL || w_str == NULL)
- return 0;
-
- while (size > 0 && *a_str != '\0')
- {
- w_str[result++] = (UINT16) *a_str;
- a_str++;
- size--;
- }
-
- if (size > 0)
- {
- w_str[result] = 0;
- }
-
- return (result+1);
-}
-
-/*******************************************************************************
-**
-** Function OBX_WcharToChar
-**
-** Description This function is called to convert Unicode (UINT16) to ASCII.
-**
-** Returns void.
-**
-*******************************************************************************/
-void OBX_WcharToChar (char *a_str, UINT16* w_str, UINT16 a_size)
-{
- UINT16 result = 0;
- int size = a_size;
-
- if (w_str == NULL || a_str == NULL)
- return;
-
- while (size > 0 && *w_str != 0)
- {
- if ((*w_str & ~0xff) != 0)
- {
- result = 0;
- break;
- }
-
- a_str[result++] = (char) *w_str;
- ++(w_str);
- --size;
- }
-
- if(size)
- a_str[result] = 0;
-
- return;
-
-
-}
-
diff --git a/stack/obx/hdrs/utfc.c b/stack/obx/hdrs/utfc.c
deleted file mode 100644
index d59733d..0000000
--- a/stack/obx/hdrs/utfc.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/*****************************************************************************
-**
-** Name: utfc.c
-**
-** Description: UTF conversion utilities.
-**
-** Copyright (c) 2003-2004, WIDCOMM Inc., All Rights Reserved.
-**
-*****************************************************************************/
-
-#include <string.h>
-#include "bt_target.h"
-#include "utfc.h"
-
-/* Based on code from Unicode, Inc:
- *
- * Copyright 2001-2003 Unicode, Inc.
- *
- * Limitations on Rights to Redistribute This Code
- *
- * Unicode, Inc. hereby grants the right to freely use the information
- * supplied in this file in the creation of products supporting the
- * Unicode Standard, and to make copies of this file in any form
- * for internal or external distribution as long as this notice
- * remains attached.
- */
-
-/*******************************************************************************
-** Constants
-*******************************************************************************/
-
-#define UTFC_8_MASK 0xBF
-#define UTFC_8_MARK 0x80
-
-#define UTFC_SUR_HIGH_START 0xD800
-#define UTFC_SUR_HIGH_END 0xDBFF
-#define UTFC_SUR_LOW_START 0xDC00
-#define UTFC_SUR_LOW_END 0xDFFF
-
-/* Lookup table for length of UTF-8 byte sequence based on upper four bits
-** of first byte. Illegal values give length zero.
-*/
-static const UINT8 utfc_8_seq_len[] = {1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 0, 0, 2, 2, 3, 4};
-
-/* Magic values subtracted from a buffer value during UTF-8 conversion.
-** This table contains as many values as there might be trailing bytes
-** in a UTF-8 sequence.
-**/
-static const UINT32 utfc_8_offset[] = {0x00000000, 0x00003080,
- 0x000E2080, 0x03C82080};
-
-static const UINT8 utfc_8_first_byte[] = {0x00, 0x00, 0xC0, 0xE0, 0xF0};
-
-/*******************************************************************************
-**
-** Function utfc_16_to_8
-**
-** Description Convert a UTF-16 array to a null-terminated UTF-8 string.
-** Illegal characters are skipped.
-**
-** Returns Length of UTF-8 string in bytes.
-**
-*******************************************************************************/
-UINT16 utfc_16_to_8(UINT8 *p_utf8, UINT16 utf8_len, UINT16 *p_utf16, UINT16 utf16_len)
-{
- UINT32 ch, ch2;
- UINT16 len = 0;
- UINT8 seq_len;
-
- /* sanity check destination buffer len */
- if (utf8_len == 0)
- {
- /* set null */
- *p_utf8 = 0;
- return len;
- }
-
- /* save space for null */
- utf8_len--;
-
- while (utf16_len-- > 0)
- {
- ch = (UINT32) *p_utf16++;
-
- /* if we have a surrogate pair, convert to UTF-32 first */
- if (ch >= UTFC_SUR_HIGH_START && ch <= UTFC_SUR_HIGH_END)
- {
- /* if not enough characters we're done */
- if (utf16_len == 0)
- {
- break;
- }
-
- /* get next character */
- ch2 = *p_utf16++;
- utf16_len--;
-
- /* if it's a low surrogate, convert to UTF-32 */
- if (ch2 >= UTFC_SUR_LOW_START && ch2 <= UTFC_SUR_LOW_END)
- {
- ch = ((ch - UTFC_SUR_HIGH_START) << 10) +
- (ch2 - UTFC_SUR_LOW_START) + 0x00010000;
- }
- else
- {
- /* illegal UTF-16 sequence, skip it */
- continue;
- }
- }
-
- /* Figure out how many bytes the result will require */
- if (ch < 0x00000080)
- seq_len = 1;
- else if (ch < 0x00000800)
- seq_len = 2;
- else if (ch < 0x00010000)
- seq_len = 3;
- else
- seq_len = 4;
-
- /* if sequence doesn't fit we're done */
- if (utf8_len < len + seq_len)
- {
- break;
- }
-
- /* build UTF-8 sequence */
- switch (seq_len)
- { /* note: everything falls through. */
- case 4: p_utf8[3] = (UINT8) ((ch | UTFC_8_MARK) & UTFC_8_MASK); ch >>= 6;
- case 3: p_utf8[2] = (UINT8) ((ch | UTFC_8_MARK) & UTFC_8_MASK); ch >>= 6;
- case 2: p_utf8[1] = (UINT8) ((ch | UTFC_8_MARK) & UTFC_8_MASK); ch >>= 6;
- case 1: p_utf8[0] = (UINT8) (ch | utfc_8_first_byte[seq_len]);
- }
-
- /* converted value is a null we're done */
- if (*p_utf8 == 0)
- {
- break;
- }
-
- p_utf8 += seq_len;
- len += seq_len;
- }
-
- /* set null */
- *p_utf8 = 0;
-
- return len;
-}
-
-/*******************************************************************************
-**
-** Function utfc_8_to_16
-**
-** Description Convert a null-terminated UTF-8 string to a UTF-16 array.
-** Illegal characters are skipped. The UTF-16 array is
-** appended with a zero (null) character.
-**
-** Returns Length of UTF-16 array including null character.
-**
-*******************************************************************************/
-UINT16 utfc_8_to_16(UINT16 *p_utf16, UINT16 utf16_len, UINT8 *p_utf8)
-{
- UINT32 ch;
- UINT8 *p_end;
- UINT16 *p;
- UINT8 seq_len;
-
- /* sanity check destination buffer len */
- if (utf16_len == 0)
- {
- *p_utf16 = 0;
- return 0;
- }
-
- /* save space for null */
- utf16_len--;
-
- p = p_utf16;
- p_end = (UINT8 *) p_utf8 + strlen((char *) p_utf8);
-
- while (*p_utf8)
- {
- /* get sequence length; skip if illegal */
- if ((seq_len = utfc_8_seq_len[*p_utf8 >> 4]) == 0)
- {
- p_utf8++;
- continue;
- }
-
- /* make sure sequence doesn't extend past end of UTF-8 buffer */
- if (p_utf8 + seq_len > p_end)
- {
- break;
- }
-
- /* construct UTF-32 character from sequence */
- ch = 0;
- switch (seq_len)
- { /* note: everything falls through. */
- case 4: ch += *p_utf8++; ch <<= 6;
- case 3: ch += *p_utf8++; ch <<= 6;
- case 2: ch += *p_utf8++; ch <<= 6;
- case 1: ch += *p_utf8++;
- }
- ch -= utfc_8_offset[seq_len - 1];
-
- if (ch <= 0x0000FFFF)
- {
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UTFC_SUR_HIGH_START && ch <= UTFC_SUR_LOW_END)
- {
- continue;
- }
-
- /* make sure fits */
- if (p - p_utf16 == utf16_len)
- {
- break;
- }
-
- *p++ = (UINT16) ch;
- }
- else if (ch < 0x0010FFFF)
- {
- /* make sure fits */
- if ((p - p_utf16) == (utf16_len - 1))
- {
- break;
- }
-
- ch -= 0x00010000;
- *p++ = (UINT16) ((ch >> 10) + UTFC_SUR_HIGH_START);
- *p++ = (UINT16) ((ch & 0x000003FF) + UTFC_SUR_LOW_START);
- }
- }
-
- /* set null */
- *p++ = 0;
-
- return (UINT16) (p - p_utf16);
-}
-
diff --git a/stack/obx/obx_cact.c b/stack/obx/obx_cact.c
deleted file mode 100644
index 62998bd..0000000
--- a/stack/obx/obx_cact.c
+++ /dev/null
@@ -1,1103 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_cact.c
-**
-** File: OBEX Client State Machine Action Functions
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-#include "bt_target.h"
-#include "obx_int.h"
-#include "btm_api.h"
-
-const tOBX_EVENT obx_cl_state_2_event_map[] =
-{
- OBX_DISCONNECT_RSP_EVT, /* OBX_CS_NOT_CONNECTED */
- OBX_SESSION_RSP_EVT, /* OBX_CS_SESSION_REQ_SENT */
- OBX_CONNECT_RSP_EVT, /* OBX_CS_CONNECT_REQ_SENT */
- OBX_NULL_EVT, /* OBX_CS_UNAUTH */
- OBX_ABORT_RSP_EVT, /* OBX_CS_CONNECTED */
- OBX_DISCONNECT_RSP_EVT, /* OBX_CS_DISCNT_REQ_SENT */
- OBX_NULL_EVT, /* OBX_CS_OP_UNAUTH */
- OBX_SETPATH_RSP_EVT, /* OBX_CS_SETPATH_REQ_SENT */
- OBX_ACTION_RSP_EVT, /* OBX_CS_ACTION_REQ_SENT */
- OBX_ABORT_RSP_EVT, /* OBX_CS_ABORT_REQ_SENT */
- OBX_PUT_RSP_EVT, /* OBX_CS_PUT_REQ_SENT */
- OBX_GET_RSP_EVT, /* OBX_CS_GET_REQ_SENT */
- OBX_PUT_RSP_EVT, /* OBX_CS_PUT_TRANSACTION */
- OBX_GET_RSP_EVT, /* OBX_CS_GET_TRANSACTION */
- OBX_PUT_RSP_EVT, /* OBX_CS_PUT_SRM */
- OBX_GET_RSP_EVT /* OBX_CS_GET_SRM */
-};
-
-/*******************************************************************************
-** Function obx_ca_close_sess_req
-** Description send close session request
-*******************************************************************************/
-BT_HDR * obx_ca_close_sess_req(tOBX_CL_CB *p_cb)
-{
- BT_HDR *p_req;
- UINT8 *p;
- UINT8 num_trip = 0;
- tOBX_TRIPLET triplet[4];
- UINT8 data[2];
-
- p_req = OBX_HdrInit(OBX_HANDLE_NULL, OBX_MIN_MTU);
- p = (UINT8 *) (p_req + 1) + p_req->offset;
- /* Session request packet always has the final bit set */
- *p++ = (OBX_REQ_SESSION | OBX_FINAL);
- p_req->len = 3;
- p = data;
-
- /* add session opcode */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_SESS_OP;
- triplet[num_trip].len = OBX_LEN_SESS_PARAM_SESS_OP;
- triplet[num_trip].p_array = p;
- *p = OBX_SESS_OP_CLOSE;
- p += OBX_LEN_SESS_PARAM_SESS_OP;
- num_trip++;
-
- /* add session id */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_SESS_ID;
- triplet[num_trip].len = OBX_SESSION_ID_SIZE;
- triplet[num_trip].p_array = p_cb->sess_info;
- num_trip++;
-
- OBX_AddTriplet(p_req, OBX_HI_SESSION_PARAM, triplet, num_trip);
- /* adjust the packet len */
- p = (UINT8 *) (p_req + 1) + p_req->offset + 1;
- UINT16_TO_BE_STREAM(p, p_req->len);
- p_req->event = OBX_SESSION_REQ_EVT;
- p_cb->sess_st = OBX_SESS_CLOSE;
- OBX_TRACE_DEBUG2("obx_ca_close_sess_req shandle:0x%x, sess_st:%d", p_cb->ll_cb.comm.handle, p_cb->sess_st);
- return p_req;
-}
-
-/*******************************************************************************
-** Function obx_ca_connect_req
-** Description send connect request
-*******************************************************************************/
-void obx_ca_connect_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- UINT8 msg[OBX_HDR_OFFSET + OBX_MAX_CONN_HDR_EXTRA];
- UINT8 *p = msg;
-
- /* Connect request packet always has the final bit set */
- *p++ = (OBX_REQ_CONNECT | OBX_FINAL);
- p += OBX_PKT_LEN_SIZE;
-
- *p++ = OBX_VERSION;
- *p++ = OBX_CONN_FLAGS;
- UINT16_TO_BE_STREAM(p, p_cb->ll_cb.port.rx_mtu);
-
- /* add session sequence number, if session is active */
- if (p_cb->sess_st == OBX_SESS_ACTIVE)
- {
- *p++ = OBX_HI_SESSION_SN;
- *p++ = p_cb->ssn;
- }
- if (p_cb->srm)
- {
- p_cb->srm = OBX_SRM_ENABLE;
- }
-
- /* IrOBEX spec forbids connection ID in Connect Request */
- p_pkt = obx_cl_prepend_msg(p_cb, p_pkt, msg, (UINT16)(p - msg) );
-
- p_pkt->event = OBX_CONNECT_REQ_EVT;
- obx_csm_event(p_cb, OBX_CONNECT_REQ_CEVT, p_pkt);
-}
-
-/*******************************************************************************
-** Function obx_ca_state
-** Description change state
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_state(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- /* p_pkt should be NULL here */
- return p_cb->next_state;
-}
-
-/*******************************************************************************
-** Function obx_ca_start_timer
-** Description start timer
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_start_timer(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- if (p_pkt)
- GKI_freebuf(p_pkt);
- obx_start_timer(&p_cb->ll_cb.comm);
- return OBX_CS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_ca_connect_ok
-** Description process the connect OK response from server
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_connect_ok(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- UINT8 *p;
- tOBX_EVT_PARAM param; /* The event parameter. */
-
- if (p_cb->sess_st == OBX_SESS_ACTIVE)
- {
- /* reliable session was established - need to report the session event first */
- p = &p_cb->sess_info[OBX_SESSION_INFO_ID_IDX];
- UINT32_TO_BE_STREAM(p, p_cb->conn_id);
- param.sess.p_sess_info= p_cb->sess_info;
- param.sess.sess_st = p_cb->sess_st;
- param.sess.nssn = p_cb->ssn;
- param.sess.obj_offset = 0;
- p = &p_cb->sess_info[OBX_SESSION_INFO_MTU_IDX];
- UINT16_TO_BE_STREAM(p, p_cb->param.conn.mtu);
- param.sess.sess_op = OBX_SESS_OP_CREATE;
- (*p_cb->p_cback)(p_cb->ll_cb.comm.handle, OBX_SESSION_RSP_EVT, p_cb->rsp_code, param, NULL);
- }
- return obx_ca_notify(p_cb, p_pkt);
-}
-
-/*******************************************************************************
-** Function obx_ca_session_ok
-** Description process the session OK response from server
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_session_ok(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_TRIPLET triplet[OBX_MAX_SESS_PARAM_TRIP];
- UINT8 num = OBX_MAX_SESS_PARAM_TRIP;
- UINT8 *p_nonce = NULL, *p_addr = NULL, *p_sess_id = NULL;
- UINT8 *p, *p_cl_nonce;
- UINT8 ind, nonce_len = 0;
- UINT8 ind_sess_id;
- BD_ADDR cl_addr;
- tOBX_STATUS status = OBX_SUCCESS;
- UINT8 nssn;
-#if (BT_USE_TRACES == TRUE)
- tOBX_SESS_ST old_sess_st = p_cb->sess_st;
-#endif
- tOBX_SESS_OP sess_op = OBX_SESS_OP_SET_TIME;
- tOBX_CL_STATE new_state = OBX_CS_NULL;
- tOBX_CL_EVENT sm_evt = OBX_BAD_SM_EVT;
- UINT32 obj_offset = p_cb->param.sess.obj_offset;
- UINT32 timeout = p_cb->param.sess.timeout;
- tOBX_EVT_PARAM param; /* The event parameter. */
- UINT8 dropped = 0;
-
- OBX_TRACE_DEBUG4("obx_ca_session_ok sess_st: %d ssn:%d obj_offset:%d prev_state:%d", p_cb->sess_st, p_cb->ssn, obj_offset, p_cb->prev_state);
- OBX_ReadTriplet(p_pkt, OBX_HI_SESSION_PARAM, triplet, &num);
- obx_read_timeout (triplet, num, &timeout, &p_cb->sess_info[OBX_SESSION_INFO_TO_IDX]);
- p_cb->param.sess.timeout = timeout;
- if (p_cb->sess_st == OBX_SESS_SUSPEND)
- {
- p_cb->sess_st = OBX_SESS_SUSPENDED;
- sess_op = OBX_SESS_OP_SUSPEND;
- p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX] = p_cb->srm;
- nssn = p_cb->ssn;
- /* send a tx_empty event to close port */
- sm_evt = OBX_TX_EMPTY_CEVT;
- OBX_TRACE_DEBUG2("suspend saved st:%d, srm:0x%x", p_cb->sess_info[OBX_SESSION_INFO_ST_IDX], p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX]);
- }
- else if (p_cb->sess_st == OBX_SESS_CLOSE)
- {
- sess_op = OBX_SESS_OP_CLOSE;
- p_cb->sess_st = OBX_SESS_NONE;
- /* send a tx_empty event to close port */
- sm_evt = OBX_TX_EMPTY_CEVT;
- }
- else if (num)
- {
- ind_sess_id = obx_read_triplet(triplet, num, OBX_TAG_SESS_PARAM_SESS_ID);
- if ((ind_sess_id != num) && (triplet[ind_sess_id].len == OBX_SESSION_ID_SIZE))
- {
- p_sess_id = triplet[ind_sess_id].p_array;
- }
- switch (p_cb->sess_st)
- {
- case OBX_SESS_CREATE:
- sess_op = OBX_SESS_OP_CREATE;
- status = OBX_BAD_PARAMS;
- ind = obx_read_triplet(triplet, num, OBX_TAG_SESS_PARAM_ADDR);
- if ((ind != num) && (triplet[ind].len == BD_ADDR_LEN))
- {
- p_addr = triplet[ind].p_array;
- }
- ind = obx_read_triplet(triplet, num, OBX_TAG_SESS_PARAM_NONCE);
- if ((ind != num) && (triplet[ind].len >= OBX_MIN_NONCE_SIZE) && (triplet[ind].len <= OBX_NONCE_SIZE))
- {
- p_nonce = triplet[ind].p_array;
- nonce_len = triplet[ind].len;
- }
-
- if (p_nonce && p_addr && p_sess_id)
- {
- OBX_TRACE_DEBUG0("verify session id");
- BTM_GetLocalDeviceAddr (cl_addr);
- p_cl_nonce = &p_cb->sess_info[OBX_SESSION_ID_SIZE];
- p = p_cl_nonce;
- UINT32_TO_BE_STREAM(p, p_cb->nonce);
- /* calculate client copy of session id */
- obx_session_id (p_cb->sess_info, cl_addr, p_cl_nonce, OBX_LOCAL_NONCE_SIZE, p_addr, p_nonce, nonce_len);
- obxu_dump_hex (p_cb->sess_info, "cl sess id", OBX_SESSION_ID_SIZE);
- obxu_dump_hex (p_sess_id, "sr sess id", OBX_SESSION_ID_SIZE);
- /* verify that the server copy is the same */
- if (memcmp (p_sess_id, p_cb->sess_info, OBX_SESSION_ID_SIZE) == 0)
- {
- p_cb->sess_st = OBX_SESS_ACTIVE;
- p_cb->ssn = 0;
- /* do we want a timer here */
- status = OBX_SUCCESS;
- OBX_TRACE_DEBUG0("freeing received packet");
- GKI_freebuf (p_pkt) ;
- p_pkt = p_cb->p_next_req;
- p_cb->p_next_req = NULL;
- obx_ca_connect_req (p_cb, p_pkt);
- /*
- p_cb->param.sess.p_sess_info= p_cb->sess_info;
- p_cb->param.sess.sess_st = p_cb->sess_st;
- p_cb->param.sess.nssn = p_cb->ssn;
- p_cb->param.sess.sess_op = sess_op;
- (*p_cb->p_cback)(p_cb->ll_cb.comm.handle, OBX_SESSION_RSP_EVT, p_cb->rsp_code, p_cb->param, NULL);
- */
- return new_state;
- }
- }
- break;
-
- case OBX_SESS_RESUME:
- status = OBX_BAD_PARAMS;
- dropped = p_cb->sess_info[OBX_SESSION_INFO_ST_IDX] & OBX_CL_STATE_DROP;
- ind = obx_read_triplet(triplet, num, OBX_TAG_SESS_PARAM_NSEQNUM);
- if ((ind == num) || (triplet[ind].len != 1))
- {
- OBX_TRACE_ERROR0("RESUME:do not have valid NSSN tag");
- break;
- }
-
- nssn = *(triplet[ind].p_array);
- /* if SRM is enaged; make sure object offset TAG exists */
- if ((p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX] & OBX_SRM_ENGAGE) != 0)
- {
- obj_offset = obx_read_obj_offset(triplet, num);
- OBX_TRACE_DEBUG2("RESUME:SRM is engaged and object offset:0x%x (0x%x)",
- obj_offset, p_cb->param.sess.obj_offset);
-
- /* client always takes the offset and ssn from the response since adjustment was done at server side */
- p_cb->param.sess.obj_offset = obj_offset;
- p_cb->ssn = nssn;
- status = OBX_SUCCESS;
- }
- /* otherwise make sure NSSN from server is OK */
- else if (nssn == p_cb->ssn)
- {
- OBX_TRACE_DEBUG0("RESUME:nssn matches expected ssn");
- status = OBX_SUCCESS;
- }
- else if (dropped != 0)
- {
- OBX_TRACE_DEBUG2("RESUME:link drop suspend nssn:%d cb ssn:%d", nssn, p_cb->ssn);
- if ((UINT8)(nssn+1) == p_cb->ssn)
- {
- OBX_TRACE_DEBUG0("RESUME:nssn matches expected(ssn-1)");
- p_cb->ssn -= 1;
- status = OBX_SUCCESS;
- }
- else if (nssn == (UINT8)(p_cb->ssn+1))
- {
- OBX_TRACE_DEBUG0("RESUME:nssn matches expected(ssn+1)");
- nssn -= 1;
- status = OBX_SUCCESS;
- }
- }
- else
- {
- OBX_TRACE_ERROR2("RESUME:bad NSSN:%d (%d)", nssn, p_cb->ssn);
- break;
- }
- p_cb->sess_st = OBX_SESS_ACTIVE;
- sess_op = OBX_SESS_OP_RESUME;
- OBX_TRACE_DEBUG2("RESUME:info new_state:0x%x, srm:0x%x", p_cb->sess_info[OBX_SESSION_INFO_ST_IDX], p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX]);
- p_cb->srm = p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX];
- p_cb->sess_info[OBX_SESSION_INFO_ST_IDX] &= ~OBX_CL_STATE_DROP;
- if (p_cb->srm & OBX_SRM_ENGAGE)
- {
- new_state = p_cb->sess_info[OBX_SESSION_INFO_ST_IDX];
- if (new_state == OBX_CS_GET_SRM)
- {
- p_cb->srm |= OBX_SRM_WAIT_UL;
- /* Adjust snn in the control block since it is off by one with nssn in resume request */
- p_cb->ssn--;
- }
- }
- else
- {
- new_state = OBX_CS_CONNECTED;
- p_cb->srmp |= OBX_SRMP_SESS_FST;
- }
- OBX_TRACE_DEBUG2("RESUME:new_state:%d, srm:0x%x", new_state, p_cb->srm);
- break;
-
- default:
- status = OBX_BAD_PARAMS;
- }
- }
- else
- {
- status = OBX_BAD_PARAMS;
- }
- OBX_TRACE_DEBUG5("obx_ca_session_ok prev:%d, sess_st:%d->%d obj_offset:%d status:%d", p_cb->prev_state, old_sess_st, p_cb->sess_st, obj_offset, status);
-
- if (sess_op == OBX_SESS_OP_SET_TIME)
- new_state = p_cb->prev_state;
-
- if (status != OBX_SUCCESS)
- {
- if (p_cb->sess_st == OBX_SESS_CLOSE)
- p_cb->sess_st = OBX_SESS_NONE;
- obx_csm_event(p_cb, OBX_TIMEOUT_CEVT, NULL);
- return OBX_CS_NULL;
- }
- p_cb->param.sess.p_sess_info= p_cb->sess_info;
- p_cb->param.sess.sess_st = p_cb->sess_st;
- p_cb->param.sess.nssn = nssn;
- p_cb->param.sess.ssn = nssn;
- p_cb->param.sess.sess_op = sess_op;
- p_cb->param.sess.obj_offset = obj_offset;
- p_cb->param.sess.timeout = timeout;
- (*p_cb->p_cback)(p_cb->ll_cb.comm.handle, OBX_SESSION_RSP_EVT, p_cb->rsp_code, p_cb->param, NULL);
-
- if ((sess_op == OBX_SESS_OP_RESUME) && (p_cb->sess_st == OBX_SESS_ACTIVE))
- {
- param.conn.ssn = p_cb->ssn;
- memcpy (param.conn.peer_addr, p_cb->peer_addr, BD_ADDR_LEN);
- p = &p_cb->sess_info[OBX_SESSION_INFO_MTU_IDX];
- BE_STREAM_TO_UINT16(param.conn.mtu, p);
- p_cb->ll_cb.comm.tx_mtu = param.conn.mtu;
- param.conn.handle = p_cb->ll_cb.comm.handle;
- OBX_TRACE_DEBUG1("RESUME: tx_mtu: %d", p_cb->ll_cb.comm.tx_mtu);
- /* report OBX_CONNECT_RSP_EVT to let the client know the MTU */
- (*p_cb->p_cback)(p_cb->ll_cb.comm.handle, OBX_CONNECT_RSP_EVT, OBX_RSP_OK, param, NULL);
- sm_evt = OBX_STATE_CEVT;
- p_cb->next_state = OBX_CS_CONNECTED;
- }
-
- if (sm_evt != OBX_BAD_SM_EVT)
- {
- /* send an event to csm */
- obx_csm_event(p_cb, sm_evt, NULL);
- }
- return new_state;
-}
-
-/*******************************************************************************
-** Function obx_ca_session_cont
-** Description process the continue response from server for SRM after
-** a suspend session request is sent
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_session_cont(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- BOOLEAN free = TRUE;
-
- OBX_TRACE_DEBUG3("obx_ca_session_cont sess_st:%d prev_state:%d, srm:0x%x", p_cb->sess_st, p_cb->prev_state, p_cb->srm);
- if (p_cb->sess_st == OBX_SESS_SUSPEND)
- {
- if (p_cb->prev_state == OBX_CS_GET_SRM)
- {
- if ((p_cb->srm & OBX_SRM_WAIT_UL) == 0)
- {
- p_cb->srm |= OBX_SRM_WAIT_UL;
- p_cb->api_evt = OBX_GET_RSP_EVT;
- }
- else
- {
- GKI_enqueue_head (&p_cb->ll_cb.comm.rx_q, p_pkt);
- OBX_TRACE_DEBUG1("obx_ca_session_cont rx_q.count:%d", p_cb->ll_cb.comm.rx_q.count);
- }
- free = FALSE;
- }
- else if (p_cb->prev_state == OBX_CS_GET_REQ_SENT)
- {
- p_cb->api_evt = OBX_GET_RSP_EVT;
- free = FALSE;
- }
-
- }
- if (free && p_pkt)
- GKI_freebuf(p_pkt);
- OBX_TRACE_DEBUG1("obx_ca_session_cont srm: 0x%x(e)", p_cb->srm );
- return OBX_CS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_ca_session_get
-** Description process the get req api for SRM after
-** a suspend session request is sent (to clean out the received buffers)
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_session_get(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- OBX_TRACE_DEBUG3("obx_ca_session_get sess_st:%d prev_state: %d, srm:0x%x", p_cb->sess_st, p_cb->prev_state, p_cb->srm );
- if (p_cb->sess_st == OBX_SESS_SUSPEND && p_cb->prev_state == OBX_CS_GET_SRM)
- return obx_ca_srm_get_req(p_cb, p_pkt);
- return OBX_CS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_ca_session_fail
-** Description process the session failed response from server
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_session_fail(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SESS_ST old_sess_st = p_cb->sess_st;
-
- p_cb->sess_st = OBX_SESS_NONE;
- OBX_TRACE_DEBUG2("obx_ca_session_fail, sess_st:%d->%d", old_sess_st, p_cb->sess_st);
- if (old_sess_st == OBX_SESS_CREATE && p_cb->rsp_code != OBX_RSP_OK)
- {
- /* peer device does not support session. Continue with regular session */
- /* report session failure */
- (*p_cb->p_cback)(p_cb->ll_cb.comm.handle, OBX_SESSION_RSP_EVT, p_cb->rsp_code, p_cb->param, NULL);
- OBX_TRACE_DEBUG0("freeing received packet");
- if (p_pkt)
- GKI_freebuf (p_pkt) ;
- p_pkt = p_cb->p_next_req;
- p_cb->p_next_req = NULL;
- obx_ca_connect_req (p_cb, p_pkt);
- }
- else
- {
- (*p_cb->p_cback)(p_cb->ll_cb.comm.handle, OBX_SESSION_RSP_EVT, OBX_RSP_FAILED, p_cb->param, NULL);
- obx_ca_close_port (p_cb, p_pkt);
- }
- return OBX_CS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_ca_abort
-** Description process the abort request in connected state
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_abort(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- OBX_TRACE_DEBUG2("obx_ca_abort srm:0x%x srmp:0x%x", p_cb->srm, p_cb->srmp);
- if ( p_cb->srmp & OBX_SRMP_SESS_FST)
- {
- /* the first request after a session is resume.
- * We may need to abort the previous request */
- if (p_cb->sess_info[OBX_SESSION_INFO_ST_IDX] != OBX_CS_CONNECTED)
- {
- /* set the state here, just in case the result of obx_ca_snd_req is partial_sent */
- p_cb->state = OBX_CS_ABORT_REQ_SENT;
- obx_ca_snd_req(p_cb, p_pkt);
- return OBX_CS_NULL;
- }
- p_cb->srmp &= ~OBX_SRMP_SESS_FST;
- }
- obx_ca_notify (p_cb, p_pkt);
- return OBX_CS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_ca_snd_put_req
-** Description send put request in connected state
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_snd_put_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_CS_NULL;
-
- OBX_TRACE_DEBUG1("obx_ca_snd_put_req, srm:0x%x", p_cb->srm);
- state = obx_ca_snd_req (p_cb, p_pkt);
- if (p_cb->srm & OBX_SRM_ENGAGE)
- {
- if (state == OBX_CS_PARTIAL_SENT)
- {
- p_cb->next_state = OBX_CS_PUT_SRM;
- }
- else
- {
- p_cb->state = OBX_CS_PUT_SRM;
- if ((p_cb->srm & OBX_SRM_WAIT) == 0)
- {
- p_cb->rsp_code = OBX_RSP_CONTINUE;
- p_cb->param.put.final = FALSE;
- p_cb->param.put.type = OBX_PT_PUT;
- p_cb->param.put.ssn = 0;
- state = obx_ca_notify (p_cb, NULL);
- }
- }
- }
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_snd_get_req
-** Description send get request in connected state
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_snd_get_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state;
-
- OBX_TRACE_DEBUG1("obx_ca_snd_get_req srm:0x%x", p_cb->srm );
- state = obx_ca_snd_req (p_cb, p_pkt);
- OBX_TRACE_DEBUG1("srm:0x%x", p_cb->srm );
- if (p_cb->srm & OBX_SRM_ENABLE)
- {
- if (state == OBX_CS_PARTIAL_SENT)
- {
- p_cb->next_state = OBX_CS_GET_SRM;
- }
- else
- state = OBX_CS_GET_SRM;
- p_cb->srm &= ~OBX_SRM_WAIT_UL;
- }
- OBX_TRACE_DEBUG1("srm:0x%x", p_cb->srm );
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_srm_snd_req
-** Description send Abort or Disconnect request
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_srm_snd_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state;
- tOBX_COMM_CB *p_comm = &p_cb->ll_cb.comm;
-
- OBX_TRACE_DEBUG2("obx_ca_srm_snd_req rx_q.count: %d, srm:0x%x", p_comm->rx_q.count, p_cb->srm );
- p_cb->srm &= ~OBX_SRM_WAIT_UL;
- state = obx_ca_snd_req (p_cb, p_pkt);
- if ((p_pkt = (BT_HDR *)GKI_dequeue (&p_comm->rx_q)) != NULL)
- {
- GKI_freebuf(p_pkt);
- }
- OBX_TRACE_DEBUG2(" rx_q.count: %d, srm:0x%x", p_comm->rx_q.count, p_cb->srm );
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_srm_put_req
-** Description send a PUT request when SRM is engaged
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_srm_put_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state;
-
- OBX_TRACE_DEBUG1("obx_ca_srm_put_req srm:0x%x", p_cb->srm );
- state = obx_ca_snd_req (p_cb, p_pkt);
- OBX_TRACE_DEBUG4("obx_ca_srm_put_req state:%d srm:0x%x, final:%d rsp_code:0x%x", state, p_cb->srm, p_cb->final, p_cb->rsp_code );
- if (state != OBX_CS_PARTIAL_SENT && p_cb->final != TRUE && (p_cb->srm & OBX_SRM_WAIT) == 0)
- {
- p_cb->rsp_code = OBX_RSP_CONTINUE;
- state = obx_ca_notify (p_cb, NULL);
- }
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_srm_get_req
-** Description send a GET request when SRM is engaged
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_srm_get_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_CS_NULL;
- tOBX_COMM_CB *p_comm = &p_cb->ll_cb.comm;
-
- OBX_TRACE_DEBUG3("obx_ca_srm_get_req rx_q.count: %d, srm:0x%x", p_cb->sess_st, p_comm->rx_q.count, p_cb->srm );
-
- obx_start_timer(&p_cb->ll_cb.comm);
- p_cb->srm &= ~OBX_SRM_WAIT_UL;
- if (p_cb->sess_st == OBX_SESS_ACTIVE)
- {
- p_cb->ssn++;
- }
- if (p_pkt)
- GKI_freebuf(p_pkt);
-
- if ((p_pkt = (BT_HDR *)GKI_dequeue (&p_comm->rx_q)) != NULL)
- {
- if (state != OBX_CS_NULL)
- {
- p_cb->prev_state = p_cb->state;
- p_cb->state = state;
- state = OBX_CS_NULL;
- }
- obx_cl_proc_pkt (p_cb, p_pkt);
- obx_flow_control(p_comm);
- OBX_TRACE_DEBUG1("obx_ca_srm_get_req rx_q.count: %d", p_cb->ll_cb.comm.rx_q.count );
- }
- OBX_TRACE_DEBUG1("obx_ca_srm_get_req srm:0x%x", p_cb->srm );
-
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_srm_put_notify
-** Description Notify the OBX user OBX_PUT_RSP_EVT (OBX is ready for next req)
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_srm_put_notify(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state;
-
- OBX_TRACE_DEBUG2("obx_ca_srm_put_notify srm: 0x%x, srmp: 0x%x", p_cb->srm, p_cb->srmp );
-
- state = obx_ca_notify (p_cb, p_pkt);
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_srm_get_notify
-** Description Notify the OBX user OBX_GET_RSP_EVT (OBX is ready for next req)
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_srm_get_notify(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_CS_NULL;
-
- OBX_TRACE_DEBUG1("obx_ca_srm_get_notify srm: 0x%x", p_cb->srm );
- /* do not allow SRMP for now */
- p_cb->srm &= ~OBX_SRM_WAIT;
-
- if (p_cb->srm & OBX_SRM_ENGAGE)
- {
- if ((p_cb->srm & OBX_SRM_WAIT_UL) == 0)
- {
- p_cb->srm |= OBX_SRM_WAIT_UL;
- state = obx_ca_notify (p_cb, p_pkt);
- }
- else
- {
- GKI_enqueue_head (&p_cb->ll_cb.comm.rx_q, p_pkt);
- OBX_TRACE_DEBUG1("obx_ca_srm_get_notify rx_q.count:%d", p_cb->ll_cb.comm.rx_q.count);
- }
- }
- else
- {
- state = obx_ca_notify (p_cb, p_pkt);
- if (state == OBX_CS_GET_SRM || state == OBX_CS_NULL)
- state = OBX_CS_GET_TRANSACTION;
- }
- OBX_TRACE_DEBUG2("obx_ca_srm_get_notify srm: 0x%x(e) state:%s", p_cb->srm, obx_sr_get_state_name(state) );
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_save_rsp
-** Description save response in control block
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_save_rsp(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- GKI_enqueue (&p_cb->ll_cb.comm.rx_q, p_pkt);
- return OBX_CS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_ca_save_req
-** Description save request in control block
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_save_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- if (p_cb->p_next_req)
- {
- /* this probably would not happen */
- /* this action only occurs when we are flow controlled by the peer
- * and the client wants to abort the operation */
- /* Just in case that the user keeps calling abort request.... */
- OBX_TRACE_WARNING1("free next req: 0x%x", p_cb->p_next_req );
- GKI_freebuf(p_cb->p_next_req);
- }
-
- p_cb->p_next_req = p_pkt;
-
- return OBX_CS_NULL;
-}
-
-
-/*******************************************************************************
-** Function obx_ca_snd_req
-** Description If (p_pkt), call p_send_fn() to send the message to the peer.
-** Start timer. Return NULL state.If data is partially sent, return
-** PART state.
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_snd_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_CS_NULL;
- UINT8 rsp_code = OBX_RSP_DEFAULT;
-
- obx_access_rsp_code(p_pkt, &rsp_code);
- p_cb->final = (rsp_code&OBX_FINAL) ? TRUE : FALSE;
- OBX_TRACE_DEBUG2("obx_ca_snd_req rsp_code: 0x%x final:%d", rsp_code, p_cb->final );
-
- /* save a copy of the request sent to the server */
- /* In case that we are challenged by the server,
- * we can send the same request with authentication response again */
- if (p_cb->p_saved_req)
- GKI_freebuf(p_cb->p_saved_req);
-
- p_cb->p_saved_req = obx_dup_pkt(p_pkt);
-
- OBX_TRACE_DEBUG3( "event p_saved_req:%d, pkt:%d, final: %d", p_cb->p_saved_req->event, p_pkt->event,p_cb->final);
-
- p_cb->ll_cb.comm.p_txmsg = p_pkt;
- /* debug: obxu_dump_hex ((UINT8 *)(p_pkt + 1) + p_pkt->offset, "conn req", p_pkt->len); */
-
- p_cb->srmp &= ~OBX_SRMP_SESS_FST;
- if (p_cb->sess_st == OBX_SESS_ACTIVE)
- {
- p_cb->ssn++;
- }
-
- if (p_cb->ll_cb.comm.p_send_fn(&p_cb->ll_cb) == FALSE)
- {
- p_cb->next_state = p_cb->state;
- state = OBX_CS_PARTIAL_SENT;
- }
-
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_close_port
-** Description Close the transport. Return NULL state.
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_close_port(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- if (p_pkt)
- GKI_freebuf(p_pkt);
- p_cb->ll_cb.comm.p_close_fn(p_cb->ll_cb.comm.id);
- return OBX_CS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_ca_snd_part
-** Description Call p_send_fn() to send the left-over OBEX message to the peer.
-** Start timer. If all the data is sent, call obx_csm_event() with
-** STATE event to next_state in the port control block.
-** If (p_next_req), call obx_csm_event() to process the saved request.
-** Return NULL state.
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_snd_part(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_CL_STATE state = OBX_CS_NULL;
-
- OBX_TRACE_DEBUG1("obx_ca_snd_part sess_st:%d", p_cb->sess_st);
-
- /* p_pkt should be NULL here */
- if (p_cb->ll_cb.comm.p_send_fn(&p_cb->ll_cb) == TRUE)
- {
- /* data is all sent. change state to the appropriate state */
- obx_csm_event(p_cb, OBX_STATE_CEVT, NULL);
- if (p_cb->p_next_req && (p_cb->sess_st != OBX_SESS_CREATE))
- {
- /* abort request was issued - send it now */
- p_pkt = p_cb->p_next_req;
- p_cb->p_next_req = NULL;
- obx_csm_event(p_cb, (tOBX_CL_EVENT)(p_pkt->event-1), p_pkt);
- }
-
- OBX_TRACE_DEBUG2("obx_ca_snd_part state:%d, srm:0x%x", p_cb->state, p_cb->srm);
- if ((p_pkt = (BT_HDR *)GKI_dequeue (&p_cb->ll_cb.comm.rx_q)) != NULL)
- {
- obx_cl_proc_pkt (p_cb, p_pkt);
- }
- else if (p_cb->state == OBX_CS_PUT_SRM)
- {
- if (((p_cb->srm & OBX_SRM_WAIT) == 0) && (p_cb->final != TRUE))
- {
- state = obx_ca_notify (p_cb, NULL);
- }
- }
- }
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_connect_error
-** Description Call callback function with OBX_CLOSE_IND_EVT. Free the client
-** control block. Return NULL state.
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_connect_error(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_CL_CBACK *p_cback = p_cb->p_cback;
- tOBX_HANDLE handle = p_cb->ll_cb.comm.handle;
- tOBX_EVT_PARAM param = p_cb->param;
- tOBX_SR_STATE save_state;
-
- if (p_cb->sess_st == OBX_SESS_ACTIVE)
- {
- /* The transport is interrupted while a reliable session is active:
- * report a suspend event fot application to save the information in NV.
- * The only time this is called is for port close evt /w next state as not_connected
- * we need to use prev_state as the potential state to resume session
- */
- save_state = p_cb->prev_state;
- if (save_state == OBX_CS_PARTIAL_SENT)
- save_state = p_cb->next_state;
- /* marks link drop suspend only when SRM is not engaged */
- if ((p_cb->srm & OBX_SRM_ENGAGE) == 0)
- save_state |= OBX_CL_STATE_DROP;
- else if (save_state == OBX_CS_GET_SRM)
- p_cb->srm &= ~OBX_SRM_WAIT_UL;
- p_cb->sess_info[OBX_SESSION_INFO_ST_IDX] = save_state;
- OBX_TRACE_DEBUG2("obx_ca_connect_error saved state:0x%x, srm:0x%x", save_state, p_cb->srm);
- p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX] = p_cb->srm;
- param.sess.p_sess_info = p_cb->sess_info;
- param.sess.sess_op = OBX_SESS_OP_TRANSPORT;
- param.sess.sess_st = p_cb->sess_st;
- param.sess.nssn = p_cb->ssn;
- param.sess.ssn = p_cb->ssn;
- param.sess.obj_offset = 0;
- param.sess.timeout = OBX_SESS_TIMEOUT_VALUE;
- memcpy(param.sess.peer_addr, p_cb->peer_addr, BD_ADDR_LEN);
- p_cb->sess_st = OBX_SESS_NONE;
- (*p_cback)(handle, OBX_SESSION_INFO_EVT, OBX_RSP_OK, param, NULL);
- }
-
- obx_cl_free_cb(p_cb);
- (*p_cback)(handle, OBX_CLOSE_IND_EVT, OBX_RSP_DEFAULT, param, p_pkt);
- return OBX_CS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_ca_connect_fail
-** Description If the response code is OBX_RSP_UNAUTHORIZED, save the OBEX
-** message in the client control block and call callback function
-** with OBX_PASSWORD_EVT. Return NULL state.Otherwise, call
-** obx_csm_event() with OBX_DISCNT_REQ_CEVT. (We do not need to
-** send disconnect request to the server, since we are not
-** connected yet). Return NULL state.
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_connect_fail(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_CS_NULL;
-
- if ( p_cb->rsp_code == OBX_RSP_UNAUTHORIZED &&
- OBX_CheckHdr(p_pkt, OBX_HI_CHALLENGE) != NULL)
- {
- p_cb->api_evt = OBX_PASSWORD_EVT;
- p_cb->p_auth = obx_dup_pkt(p_pkt);
- }
- else
- {
- /* Connect Request is rejected for reasons other than authentication
- * or if the client challenges the server, but the server does nt return good digest
- * - notify the user of the failure and .. */
- (*p_cb->p_cback)(p_cb->ll_cb.comm.handle, OBX_CONNECT_RSP_EVT, p_cb->rsp_code, p_cb->param, p_pkt);
- p_cb->api_evt = OBX_NULL_EVT;
- /* and close the RFCOMM port */
- obx_csm_event(p_cb, OBX_DISCNT_REQ_CEVT, NULL);
- }
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_discnt_req
-** Description OBX_DISCNT_REQ_CEVT event is received in OBX_CS_CONNECT_REQ_SENT
-** state. In case that the server fails the authentication, client
-** needs to send Disconnect Req. Otherwise, just close port.
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_discnt_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_CL_STATE state = OBX_CS_NOT_CONNECTED;
- UINT8 msg[OBX_HDR_OFFSET];
- UINT8 *p = msg;
-
- if (p_cb->wait_auth == OBX_WAIT_AUTH_FAIL)
- {
- /* server thinks the connection is up.
- * client needs to send disconnect req */
- state = OBX_CS_DISCNT_REQ_SENT;
- /* Disconnect request always has the final bit set */
- *p++ = (OBX_REQ_DISCONNECT|OBX_FINAL);
- p += OBX_PKT_LEN_SIZE;
-
- /* add session sequence number, if session is active */
- if (p_cb->sess_st == OBX_SESS_ACTIVE)
- {
- *p++ = OBX_HI_SESSION_SN;
- *p++ = p_cb->ssn;
- }
-
- /* add connection ID, if needed */
- if (p_cb->conn_id != OBX_INVALID_CONN_ID)
- {
- *p++ = OBX_HI_CONN_ID;
- UINT32_TO_BE_STREAM(p, p_cb->conn_id);
- }
-
- p_pkt = obx_cl_prepend_msg(p_cb, NULL, msg, (UINT16)(p - msg) );
- obx_ca_snd_req(p_cb, p_pkt);
- }
- else
- {
- /* connection is not officially up yet.
- * just close the port */
- obx_ca_close_port(p_cb, p_pkt);
- }
- p_cb->wait_auth = FALSE;
-
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_notify
-** Description Use api_evt or look up the event according to the state. Fill
-** the event parameter. Call callback function with the event.
-** Return NULL state.
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_notify(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_CS_CONNECTED;
- tOBX_EVENT event = obx_cl_state_2_event_map[p_cb->state - 1];
- BOOLEAN notify = FALSE;
- tOBX_CL_EVENT sm_evt = OBX_BAD_SM_EVT;
- BT_HDR *p_req = NULL;
-
- OBX_TRACE_DEBUG6( "obx_ca_notify state: %s, prev_state: %s, rsp:0x%x, sess_st:%d, event:%d srm:0x%x",
- obx_cl_get_state_name( p_cb->state ), obx_cl_get_state_name(p_cb->prev_state), p_cb->rsp_code, p_cb->sess_st, event, p_cb->srm);
- OBX_TRACE_DEBUG2( "ssn:0x%x/0x%x", p_cb->ssn, p_cb->param.ssn);
-
- if ( (p_cb->final == TRUE && p_cb->rsp_code == OBX_RSP_CONTINUE && p_cb->state == OBX_CS_PUT_TRANSACTION) ||
- (p_cb->final == FALSE && p_cb->rsp_code != OBX_RSP_CONTINUE) )
- {
- /* final bit on the request mismatch the responde code --- Error!! */
- OBX_TRACE_ERROR2( "final:%d on the request mismatch the responde code:0x%x",
- p_cb->final, p_cb->rsp_code) ;
- /* change the state to not connected state */
- p_cb->next_state = OBX_CS_NOT_CONNECTED;
- obx_csm_event(p_cb, OBX_STATE_CEVT, NULL);
- notify = TRUE;
- /* send a tx_empty event to close port */
- sm_evt = OBX_TX_EMPTY_CEVT;
- }
-
- else if (event != OBX_NULL_EVT)
- {
- switch (p_cb->state)
- {
- case OBX_CS_PUT_TRANSACTION:
- case OBX_CS_GET_TRANSACTION:
- case OBX_CS_PUT_REQ_SENT:
- case OBX_CS_GET_REQ_SENT:
- case OBX_CS_PUT_SRM:
- case OBX_CS_GET_SRM:
- if (p_cb->rsp_code == OBX_RSP_CONTINUE )
- {
- /* notify the event in this function. the new state stays the same */
- notify = TRUE;
-
- if (p_cb->srm & OBX_SRM_ENGAGE)
- {
- if (p_cb->state == OBX_CS_PUT_TRANSACTION)
- {
- p_cb->state = OBX_CS_PUT_SRM;
- }
- else if (p_cb->state == OBX_CS_GET_TRANSACTION)
- {
- p_cb->state = OBX_CS_GET_SRM;
- }
- else if (p_cb->state == OBX_CS_PUT_SRM && p_pkt && (p_cb->srm & OBX_SRM_WAIT) == 0)
- {
- OBX_TRACE_ERROR0 ("unexpected PUT response. disconnect now!!");
- notify = FALSE;
- event = OBX_NULL_EVT;
- obx_ca_close_port(p_cb, p_pkt);
- }
- /* clear the wait bit here to avoid the link being disconnected by accident */
- p_cb->srm &= ~OBX_SRM_WAIT;
- if (p_cb->srmp)
- {
- p_cb->srmp = 0;
- p_cb->srm |= OBX_SRM_WAIT;
- }
- }
- }
- /* else let obx_csm_event notify the event. the new state is OBX_CS_CONNECTED */
- else
- {
- /* dis-engage SRM */
- p_cb->srm &= OBX_SRM_ENABLE;
- OBX_TRACE_DEBUG1( "disengage srm:0x%x", p_cb->srm);
- }
- break;
-
- case OBX_CS_NOT_CONNECTED:
- if (p_cb->sess_st == OBX_SESS_ACTIVE && p_cb->prev_state == OBX_CS_DISCNT_REQ_SENT)
- {
- p_req = obx_ca_close_sess_req (p_cb);
- sm_evt = OBX_SESSION_REQ_CEVT;
- state = OBX_CS_NULL;
- }
- else
- {
- notify = TRUE;
- /* send a tx_empty event to close port */
- sm_evt = OBX_TX_EMPTY_CEVT;
- }
- break;
-
- case OBX_CS_CONNECT_REQ_SENT:
- if (p_cb->rsp_code == OBX_RSP_FAILED)
- {
- /* client challenged the server and the server does not return a good digest */
- notify = TRUE;
- /* send a disconnect req event to close port */
- sm_evt = OBX_DISCNT_REQ_CEVT;
- }
- break;
-
- case OBX_CS_ABORT_REQ_SENT:
- p_cb->srm &= OBX_SRM_ENABLE;
- OBX_TRACE_DEBUG1( "(ab) disengage srm:0x%x", p_cb->srm);
- break;
- }
- }
-
- if (notify == TRUE )
- {
- (*p_cb->p_cback)(p_cb->ll_cb.comm.handle, event, p_cb->rsp_code, p_cb->param, p_pkt);
- event = OBX_NULL_EVT;
- }
-
- if (sm_evt != OBX_BAD_SM_EVT)
- {
- /* send an event to csm */
- obx_csm_event(p_cb, sm_evt, p_req);
- }
-
- p_cb->api_evt = event;
- if (event == OBX_NULL_EVT)
- {
- state = OBX_CS_NULL;
- }
- else
- {
- p_cb->ssn = p_cb->param.ssn;
- OBX_TRACE_DEBUG1( "ssn:0x%x", p_cb->ssn);
- }
-
- return state;
-}
-
-/*******************************************************************************
-** Function obx_ca_fail_rsp
-** Description Save the OBEX message in control block.If the response code is
-** OBX_RSP_UNAUTHORIZED, set api_evt to OBX_PASSWORD_EVT. Return
-** OP_UNAUTH state.Otherwise, set api_evt according to the
-** event/state table. Return CONN state.
-*******************************************************************************/
-tOBX_CL_STATE obx_ca_fail_rsp(tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_CS_CONNECTED;
-
- p_cb->srm &= OBX_SRM_ENABLE;
-
- if ( p_cb->rsp_code == OBX_RSP_UNAUTHORIZED &&
- OBX_CheckHdr(p_pkt, OBX_HI_CHALLENGE) != NULL)
- {
- state = OBX_CS_OP_UNAUTH;
- p_cb->api_evt = OBX_PASSWORD_EVT;
- p_cb->p_auth = obx_dup_pkt(p_pkt);
- }
- else
- p_cb->api_evt = obx_cl_state_2_event_map[p_cb->state - 1];
-
- return state;
-}
diff --git a/stack/obx/obx_capi.c b/stack/obx/obx_capi.c
deleted file mode 100644
index ea34aa1..0000000
--- a/stack/obx/obx_capi.c
+++ /dev/null
@@ -1,855 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_capi.c
-**
-** File: OBEX Client Application Programming Interface functions
-**
-** Copyright (c) 2003-2010, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include "bt_target.h"
-#include "wcassert.h"
-#include "obx_int.h"
-#include "port_api.h"
-#include "l2c_api.h"
-#include "btm_api.h"
-
-/*******************************************************************************
-**
-** Function OBX_ConnectReq
-**
-** Description This function registers a client entity to OBEX and sends a
-** CONNECT request to the server specified by the API parameters.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_NO_RESOURCES, if OBX does not resources
-**
-*******************************************************************************/
-tOBX_STATUS OBX_ConnectReq(BD_ADDR bd_addr, UINT8 scn, UINT16 mtu,
- tOBX_CL_CBACK *p_cback, tOBX_HANDLE *p_handle, BT_HDR *p_pkt)
-{
- tOBX_STATUS status = OBX_NO_RESOURCES;
- UINT8 msg[OBX_HDR_OFFSET + OBX_MAX_CONN_HDR_EXTRA];
- UINT8 *p = msg;
- tOBX_CL_CB *p_cb;
-
- WC_ASSERT(p_handle);
-
- p_cb = obx_cl_get_cb(*p_handle);
- if (p_cb == NULL)
- p_cb = obx_cl_alloc_cb();
-
- if (p_cb)
- {
- if (p_cb->ll_cb.port.port_handle == 0)
- {
- WC_ASSERT(p_cback);
- /* port is not open yet- open one
- * this is the first CONNECT request */
- p_cb->ll_cb.comm.rx_mtu = mtu;
- p_cb->p_cback = p_cback;
- p_cb->state = OBX_CS_NOT_CONNECTED;
- status = obx_open_port(&p_cb->ll_cb.port, bd_addr, scn);
- *p_handle = p_cb->ll_cb.port.handle;
- }
- else
- {
- /* when called by other OBX functions */
- status = OBX_SUCCESS;
- }
-
- if (status == OBX_SUCCESS)
- {
- /* Connect request packet always has the final bit set */
- *p++ = (OBX_REQ_CONNECT | OBX_FINAL);
- p += OBX_PKT_LEN_SIZE;
-
- *p++ = OBX_VERSION;
- *p++ = OBX_CONN_FLAGS;
- UINT16_TO_BE_STREAM(p, p_cb->ll_cb.port.rx_mtu);
- /* IrOBEX spec forbids connection ID in Connect Request */
- p_pkt = obx_cl_prepend_msg(p_cb, p_pkt, msg, (UINT16)(p - msg) );
-
- p_pkt->event = OBX_CONNECT_REQ_EVT;
- obx_csm_event(p_cb, OBX_CONNECT_REQ_CEVT, p_pkt);
- }
- else
- {
- OBX_TRACE_ERROR1("Error opening port for scn: %d", scn);
- obx_cl_free_cb(p_cb);
- }
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_AllocSession
-**
-** Description This function registers a client entity to OBEX.
-** If p_session_info is not NULL, it tries to find an suspended session
-** with matching session_info.
-** If scn is not 0, it allocates a control block for this new session.
-** Otherwise, it allocates a control block for the given PSM.
-** The associated virtual PSM assigned by L2CAP is returned in p_psm
-** The allocated OBEX handle is returned in p_handle.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_NO_RESOURCES, if OBX does not resources
-**
-*******************************************************************************/
-tOBX_STATUS OBX_AllocSession (UINT8 *p_session_info, UINT8 scn, UINT16 *p_psm,
- tOBX_CL_CBACK *p_cback, tOBX_HANDLE *p_handle)
-{
- tOBX_STATUS status = OBX_NO_RESOURCES;
- tOBX_CL_CB *p_cb;
-
- WC_ASSERT(p_handle);
- WC_ASSERT(p_cback);
-
- OBX_TRACE_API2("OBX_AllocSession scn: %d, psm:0x%x", scn, *p_psm);
-
- if (p_session_info)
- {
- p_cb = obx_cl_get_suspended_cb(p_handle, p_session_info);
- if (p_cb)
- {
- p_cb->srm = p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX];
- status = OBX_SUCCESS;
- }
- }
- else
- {
- p_cb = obx_cl_get_cb(*p_handle);
- if (p_cb == NULL)
- p_cb = obx_cl_alloc_cb();
-
-
- }
-
- if (p_cb)
- {
- p_cb->rsp_code = 0;
- p_cb->psm = 0;
-
- if (p_cb->sess_st != OBX_SESS_SUSPENDED)
- p_cb->sess_st = OBX_SESS_NONE;
-
- if (p_psm && L2C_IS_VALID_PSM(*p_psm))
- {
- obx_register_l2c(p_cb, *p_psm);
- /* obx_register_l2c puts the virtual psm in p_cb->psm */
- if (p_cb->psm)
- {
- *p_psm = p_cb->psm;
- status = OBX_SUCCESS;
- }
- }
-
- /* check SCN only when a virtual PSM is not allocated */
- if (!p_cb->psm)
- {
- if (scn)
- {
- /* borrow this data member temporarily */
- p_cb->rsp_code = scn;
- status = OBX_SUCCESS;
- }
- }
- }
-
- if (status != OBX_SUCCESS)
- {
- obx_cl_free_cb(p_cb);
- p_cb = NULL;
- }
-
- if (p_cb)
- {
- *p_handle = p_cb->ll_cb.comm.handle;
- p_cb->p_cback = p_cback;
- p_cb->state = OBX_CS_NOT_CONNECTED;
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_CreateSession
-**
-** Description This function registers a client entity to OBEX.
-** It may send a CreateSession request and wait for CreateSession response.
-** It sends a CONNECT request to the server specified by the API parameters.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_NO_RESOURCES, if OBX does not resources
-**
-*******************************************************************************/
-tOBX_STATUS OBX_CreateSession (BD_ADDR bd_addr, UINT16 mtu, BOOLEAN srm, UINT32 nonce,
- tOBX_HANDLE handle, BT_HDR *p_pkt)
-{
- tOBX_STATUS status = OBX_NO_RESOURCES;
- tOBX_CL_CB *p_cb;
- UINT8 *p;
- UINT8 *pn;
- BT_HDR *p_req;
- UINT8 data[20];
- tOBX_TRIPLET triplet[4];
- UINT8 num_trip = 0;
-
- OBX_TRACE_API1("OBX_CreateSession handle: 0x%x", handle);
- p_cb = obx_cl_get_cb(handle);
-
- if (p_cb)
- {
- if (p_cb->state != OBX_CS_NOT_CONNECTED || p_cb->sess_st != OBX_SESS_NONE)
- {
- OBX_TRACE_ERROR2("bad state: %d, or sess_st:%d", p_cb->state, p_cb->sess_st);
- return status;
- }
-
- if (p_cb->ll_cb.comm.id == 0)
- {
- p_cb->ll_cb.comm.rx_mtu = mtu;
-
- OBX_TRACE_DEBUG2("scn: %d, psm:0x%x", p_cb->rsp_code, p_cb->psm);
-
- if (p_cb->psm)
- {
- /* L2CAP channel is not open yet- open one
- * this is the first CONNECT request */
- status = obx_open_l2c(p_cb, bd_addr);
- }
- else if (p_cb->rsp_code) /* p_cb->rsp_code is used as the scn */
- {
- /* port is not open yet- open one
- * this is the first CONNECT request */
- status = obx_open_port(&p_cb->ll_cb.port, bd_addr, p_cb->rsp_code);
- }
- }
- else
- {
- /* when called by other OBX functions */
- status = OBX_SUCCESS;
- }
-
- if (status == OBX_SUCCESS)
- {
- /* OBEX 1.5 */
- p_cb->srm = OBX_SRM_NO;
- if (srm)
- p_cb->srm = OBX_SRM_ENABLE;
- p_cb->nonce = nonce;
- p_cb->sess_st = OBX_SESS_NONE;
- if (nonce)
- {
- if ( (p_req = OBX_HdrInit(handle, OBX_MIN_MTU)) != NULL)
- {
- p = (UINT8 *) (p_req + 1) + p_req->offset;
- /* Session request packet always has the final bit set */
- *p++ = (OBX_REQ_SESSION | OBX_FINAL);
- p_req->len = 3;
- p = data;
- /* add session opcode */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_SESS_OP;
- triplet[num_trip].len = OBX_LEN_SESS_PARAM_SESS_OP;
- triplet[num_trip].p_array = p;
- *p = OBX_SESS_OP_CREATE;
- p += OBX_LEN_SESS_PARAM_SESS_OP;
- num_trip++;
-
- /* add device addr */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_ADDR;
- triplet[num_trip].len = BD_ADDR_LEN;
- triplet[num_trip].p_array = p;
- BTM_GetLocalDeviceAddr (p);
- p += BD_ADDR_LEN;
- num_trip++;
-
- /* add nonce 4 - 16 bytes */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_NONCE;
- triplet[num_trip].len = OBX_LOCAL_NONCE_SIZE;
- pn = &p_cb->sess_info[OBX_SESSION_ID_SIZE];
- triplet[num_trip].p_array = pn;
- UINT32_TO_BE_STREAM(pn, nonce);
- num_trip++;
-
- /* add timeout */
- triplet[num_trip].p_array = p;
- if (obx_add_timeout (&triplet[num_trip], obx_cb.sess_tout_val, &p_cb->param.sess))
- {
- num_trip ++;
- p = &p_cb->sess_info[OBX_SESSION_INFO_TO_IDX];
- UINT32_TO_BE_STREAM(p, obx_cb.sess_tout_val);
- p_cb->param.sess.timeout = obx_cb.sess_tout_val;
- }
-
- OBX_AddTriplet(p_req, OBX_HI_SESSION_PARAM, triplet, num_trip);
- if (p_pkt)
- {
- /* assume that these headers are to be added to the connect req */
- p_cb->p_next_req = p_pkt;
- }
- /* adjust the packet len */
- p = (UINT8 *) (p_req + 1) + p_req->offset + 1;
- UINT16_TO_BE_STREAM(p, p_req->len);
- p_req->event = OBX_SESSION_REQ_EVT;
- p_cb->sess_st = OBX_SESS_CREATE;
- obx_csm_event(p_cb, OBX_SESSION_REQ_CEVT, p_req);
- }
- else
- status = OBX_NO_RESOURCES;
- }
- else /* legacy */
- {
- obx_ca_connect_req (p_cb, p_pkt);
- }
- }
- if (status != OBX_SUCCESS)
- {
- obx_cl_free_cb(p_cb);
- }
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ResumeSession
-**
-** Description This function registers a client entity to OBEX and resumes
-** a previously interrupted reliable session.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_NO_RESOURCES, if OBX does not resources
-**
-*******************************************************************************/
-tOBX_STATUS OBX_ResumeSession (BD_ADDR bd_addr, UINT8 ssn, UINT32 offset, tOBX_HANDLE handle)
-{
- tOBX_STATUS status = OBX_NO_RESOURCES;
- UINT8 *p;
- tOBX_CL_CB *p_cb;
- BT_HDR *p_req;
- tOBX_TRIPLET triplet[6];
- UINT8 data[13];
- UINT8 num_trip = 0;
- UINT8 *pn;
-
- OBX_TRACE_API3("OBX_ResumeSession handle: 0x%x ssn:%d offset:%d", handle, ssn, offset);
- p_cb = obx_cl_get_cb(handle);
-
- if (p_cb)
- {
- OBX_TRACE_DEBUG3("OBX_ResumeSession, sess_st:%d srm:0x%x, saved state:0x%x", p_cb->sess_st,
- p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX], p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX]);
- if (p_cb->sess_st == OBX_SESS_SUSPENDED)
- {
- if ((p_req = OBX_HdrInit(OBX_HANDLE_NULL, OBX_MIN_MTU)) != NULL)
- {
- p = (UINT8 *) (p_req + 1) + p_req->offset;
- /* Session request packet always has the final bit set */
- *p++ = (OBX_REQ_SESSION | OBX_FINAL);
- p_req->len = 3;
-
- /* add session opcode */
- p = data;
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_SESS_OP;
- triplet[num_trip].len = OBX_LEN_SESS_PARAM_SESS_OP;
- triplet[num_trip].p_array = p;
- *p = OBX_SESS_OP_RESUME;
- p += OBX_LEN_SESS_PARAM_SESS_OP;
- num_trip++;
-
- /* add device addr */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_ADDR;
- triplet[num_trip].len = BD_ADDR_LEN;
- triplet[num_trip].p_array = p;
- BTM_GetLocalDeviceAddr (p);
- p += BD_ADDR_LEN;
- num_trip++;
-
- /* add nonce 4 - 16 bytes */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_NONCE;
- triplet[num_trip].len = OBX_LOCAL_NONCE_SIZE;
- pn = &p_cb->sess_info[OBX_SESSION_ID_SIZE];
- triplet[num_trip].p_array = pn;
- num_trip++;
-
- /* add session id */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_SESS_ID;
- triplet[num_trip].len = OBX_SESSION_ID_SIZE;
- triplet[num_trip].p_array = p_cb->sess_info;
- num_trip++;
-
- if (p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX] & OBX_SRM_ENGAGE)
- {
- /* add ssn */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_NSEQNUM;
- triplet[num_trip].len = 1;
- triplet[num_trip].p_array = p;
- *p++ = ssn;
- num_trip++;
-
- if (offset)
- {
- /* add object offset */
- p_cb->param.sess.obj_offset = offset;
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_OBJ_OFF;
- triplet[num_trip].len = OBX_LEN_SESS_PARAM_OBJ_OFF;
- triplet[num_trip].p_array = p;
- UINT32_TO_BE_STREAM(p, offset);
- num_trip++;
- }
- }
-
- p_cb->sess_st = OBX_SESS_RESUME;
- OBX_AddTriplet(p_req, OBX_HI_SESSION_PARAM, triplet, num_trip);
- /* adjust the packet len */
- p = (UINT8 *) (p_req + 1) + p_req->offset + 1;
- UINT16_TO_BE_STREAM(p, p_req->len);
- p_req->event = OBX_SESSION_REQ_EVT;
- status = OBX_SUCCESS;
-
- if (p_cb->ll_cb.comm.id == 0 || p_cb->ll_cb.comm.p_send_fn == 0)
- {
- /* the transport is closed. open it again */
- OBX_TRACE_DEBUG2("scn: %d, psm:0x%x", p_cb->rsp_code, p_cb->psm);
- p_cb->ll_cb.comm.rx_mtu = OBX_MAX_MTU;
-
- if (p_cb->psm)
- {
- /* L2CAP channel is not open yet- open one
- * this is the first CONNECT request */
- status = obx_open_l2c(p_cb, bd_addr);
- }
- else if (p_cb->rsp_code) /* p_cb->rsp_code is used as the scn */
- {
- /* port is not open yet- open one
- * this is the first CONNECT request */
- status = obx_open_port(&p_cb->ll_cb.port, bd_addr, p_cb->rsp_code);
- }
- }
-
- if (status == OBX_SUCCESS)
- {
- pn = &p_cb->sess_info[OBX_SESSION_INFO_ID_IDX];
- BE_STREAM_TO_UINT32(p_cb->conn_id, pn);
- p_cb->ssn = ssn;
- p_cb->param.sess.ssn = ssn;
- obx_csm_event(p_cb, OBX_SESSION_REQ_CEVT, p_req);
- }
- }
- }
- else
- {
- OBX_TRACE_ERROR1("Handle is not in a right state: %d for RESUME", p_cb->sess_st);
- status = OBX_BAD_HANDLE;
- }
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_SessionReq
-**
-** Description This function is used to Suspend/Close a session or update the
-** timeout value of the session.
-** If timeout is 0, OBX_SESS_TIMEOUT_VALUE is the value used
-** THe timeout value is not added for the CloseSession request
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_NO_RESOURCES, if OBX does not resources
-**
-*******************************************************************************/
-tOBX_STATUS OBX_SessionReq (tOBX_HANDLE handle, tOBX_SESS_OP opcode, UINT32 timeout)
-{
- tOBX_STATUS status = OBX_NO_RESOURCES;
- UINT8 *p;
- tOBX_CL_CB *p_cb;
- BT_HDR *p_req;
- tOBX_TRIPLET triplet[3];
- UINT8 data[12];
- UINT8 num_trip = 0;
- tOBX_SESS_ST old_sess_st;
-
- p_cb = obx_cl_get_cb(handle);
-
- if (p_cb)
- {
- OBX_TRACE_API2("OBX_SessionReq st:%d opcode:%d", p_cb->sess_st, opcode);
- old_sess_st = p_cb->sess_st;
- if ((p_req = OBX_HdrInit(OBX_HANDLE_NULL, OBX_MIN_MTU)) != NULL)
- {
- status = OBX_SUCCESS;
- p = (UINT8 *) (p_req + 1) + p_req->offset;
- /* Session request packet always has the final bit set */
- *p++ = (OBX_REQ_SESSION | OBX_FINAL);
- p_req->len = 3;
-
- /* add session opcode */
- p = data;
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_SESS_OP;
- triplet[num_trip].len = OBX_LEN_SESS_PARAM_SESS_OP;
- triplet[num_trip].p_array = p;
- *p = opcode;
- p += OBX_LEN_SESS_PARAM_SESS_OP;
- num_trip++;
- if (timeout == 0)
- {
- timeout = obx_cb.sess_tout_val;
- if (p_cb->srm & OBX_SRM_ENABLE)
- timeout += obx_cb.sess_tout_val;
- }
- triplet[num_trip].p_array = p;
- switch (opcode)
- {
- case OBX_SESS_OP_CLOSE:
- /* do not need any other session parameters */
- if (p_cb->sess_st != OBX_SESS_NONE)
- p_cb->sess_st = OBX_SESS_CLOSE;
- else
- {
- OBX_TRACE_ERROR1("Handle is not in a right state: %d for CLOSE", p_cb->sess_st);
- status = OBX_BAD_HANDLE;
- }
- break;
-
- case OBX_SESS_OP_SUSPEND:
- /* do not need any other session parameters */
- if (p_cb->sess_st == OBX_SESS_ACTIVE)
- {
- /* add timeout value */
- num_trip += obx_add_timeout (&triplet[num_trip], timeout, &p_cb->param.sess);
- p_cb->sess_st = OBX_SESS_SUSPEND;
- }
- else
- {
- OBX_TRACE_ERROR1("Handle is not in a right state: %d for SUSPEND", p_cb->sess_st);
- status = OBX_BAD_HANDLE;
- }
- break;
-
- case OBX_SESS_OP_SET_TIME:
- if (p_cb->sess_st == OBX_SESS_ACTIVE)
- {
- /* add timeout value */
- num_trip += obx_add_timeout (&triplet[num_trip], timeout, &p_cb->param.sess);
- p_cb->sess_st = OBX_SESS_TIMEOUT;
- }
- else
- {
- OBX_TRACE_ERROR1("Handle is not in a right state: %d for SET_TIME", p_cb->sess_st);
- status = OBX_BAD_HANDLE;
- }
- break;
- default:
- OBX_TRACE_ERROR1("bad session opcode :%d", opcode);
- status = OBX_BAD_PARAMS;
- }
-
- OBX_TRACE_DEBUG4("OBX_SessionReq, sess_st:%d->%d opcode:%d status:%d", old_sess_st, p_cb->sess_st, opcode, status);
- if (status != OBX_SUCCESS)
- GKI_freebuf (p_req);
- else
- {
- OBX_AddTriplet(p_req, OBX_HI_SESSION_PARAM, triplet, num_trip);
- if (p_cb->sess_st == OBX_SESS_SUSPEND)
- {
- p_cb->sess_info[OBX_SESSION_INFO_ST_IDX] = p_cb->state;
- if (p_cb->state == OBX_CS_PARTIAL_SENT)
- p_cb->sess_info[OBX_SESSION_INFO_ST_IDX] = p_cb->prev_state;
- p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX] = p_cb->srm;
- OBX_TRACE_DEBUG2("suspend saved st:%d, srm:0x%x", p_cb->sess_info[OBX_SESSION_INFO_ST_IDX], p_cb->sess_info[OBX_SESSION_INFO_SRM_IDX]);
- }
- /* adjust the packet len */
- p = (UINT8 *) (p_req + 1) + p_req->offset + 1;
- UINT16_TO_BE_STREAM(p, p_req->len);
- p_req->event = OBX_SESSION_REQ_EVT;
- obx_csm_event(p_cb, OBX_SESSION_REQ_CEVT, p_req);
- }
- }
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_GetPortHandle
-**
-** Description This function is called to get RFCOMM port handle for the obex connection.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_NO_RESOURCES, if no existing connection.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_GetPortHandle(tOBX_HANDLE handle, UINT16 *port_handle)
-{
- BD_ADDR bd_addr;
- UINT16 lcid;
- tOBX_STATUS status = OBX_SUCCESS;
- tOBX_CL_CB *p_cb = obx_cl_get_cb(handle);
-
- if (p_cb)
- {
- if (PORT_CheckConnection(p_cb->ll_cb.port.port_handle, bd_addr, &lcid) != PORT_SUCCESS)
- {
- status = OBX_NO_RESOURCES;
- }
- else
- {
- *port_handle = p_cb->ll_cb.port.port_handle;
- }
- }
- else
- status = OBX_BAD_HANDLE;
-
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_SetPathReq
-**
-** Description This function sends a Set Path request to the connected server.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_SetPathReq(tOBX_HANDLE handle, UINT8 flags, BT_HDR *p_pkt)
-{
- tOBX_CL_CB *p_cb = obx_cl_get_cb(handle);
- tOBX_STATUS status = OBX_BAD_HANDLE;
- UINT8 msg[OBX_HDR_OFFSET];
- UINT8 *p = msg;
- UINT8 good_flags = (OBX_SPF_BACKUP | OBX_SPF_NO_CREATE);
-
- if (p_cb)
- {
- /* SetPath request packet always has the final bit set */
- *p++ = (OBX_REQ_SETPATH | OBX_FINAL);
- p += OBX_PKT_LEN_SIZE;
- *p++ = (flags & good_flags); /* send only good flags */
- *p++ = OBX_SETPATH_CONST;
-
- /* add session sequence number, if session is active */
- if (p_cb->sess_st == OBX_SESS_ACTIVE)
- {
- *p++ = OBX_HI_SESSION_SN;
- *p++ = p_cb->ssn;
- }
-
- /* add connection ID, if needed */
- if (p_cb->conn_id != OBX_INVALID_CONN_ID)
- {
- *p++ = OBX_HI_CONN_ID;
- UINT32_TO_BE_STREAM(p, p_cb->conn_id);
- }
- p_pkt = obx_cl_prepend_msg(p_cb, p_pkt, msg, (UINT16)(p - msg) );
- p_pkt->event = OBX_SETPATH_REQ_EVT;
- obx_csm_event(p_cb, OBX_SETPATH_REQ_CEVT, p_pkt);
- status = OBX_SUCCESS;
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function obx_prepend_req_msg
-**
-** Description This function is called to add request code and connection ID
-** to the given OBEX message
-** Returns void
-**
-*******************************************************************************/
-tOBX_STATUS obx_prepend_req_msg(tOBX_HANDLE handle, tOBX_CL_EVENT event, UINT8 req_code, BT_HDR *p_pkt)
-{
- tOBX_STATUS status = OBX_SUCCESS;
- tOBX_CL_CB *p_cb = obx_cl_get_cb(handle);
- UINT8 msg[OBX_HDR_OFFSET];
- UINT8 *p = msg;
- UINT8 srm = 0;
- UINT8 num_hdrs, num_body;
-
- if (p_cb)
- {
- *p++ = req_code;
- p += OBX_PKT_LEN_SIZE;
-
- /* add session sequence number, if session is active */
- if (p_cb->sess_st == OBX_SESS_ACTIVE)
- {
- *p++ = OBX_HI_SESSION_SN;
- *p++ = p_cb->ssn;
- }
-
- req_code &= ~OBX_FINAL;
-
- /* add connection ID, if needed */
- if ((p_cb->conn_id != OBX_INVALID_CONN_ID) &&
- /* always use connection ID in CONNECTED state or being challenged on operation */
- ((p_cb->state == OBX_CS_CONNECTED) || (p_cb->state == OBX_CS_OP_UNAUTH) ||
- /* always use connection ID for abort and disconnect. they may be out of sequence */
- (req_code == OBX_REQ_ABORT) || (req_code == OBX_REQ_DISCONNECT)))
- {
- *p++ = OBX_HI_CONN_ID;
- UINT32_TO_BE_STREAM(p, p_cb->conn_id);
- }
-
- /* add SRM header, if SRM is enabled */
- if (p_cb->srm & OBX_SRM_ENABLE)
- {
- if (p_cb->state == OBX_CS_CONNECTED)
- {
- if(event == OBX_PUT_REQ_CEVT)
- {
- num_hdrs = OBX_ReadNumHdrs(p_pkt, &num_body);
- OBX_TRACE_DEBUG2("num_hdrs:%d num_body:%d", num_hdrs, num_body);
- if (num_hdrs == num_body)
- {
- OBX_TRACE_DEBUG0("it is left-over, drop it");
- if (p_pkt)
- GKI_freebuf (p_pkt);
- return OBX_BAD_PARAMS;
- }
- srm = OBX_SRM_REQING | OBX_SRM_WAIT;
- }
- else if (event == OBX_GET_REQ_CEVT)
- {
- srm = OBX_SRM_REQING;
- }
-
- OBX_TRACE_DEBUG2("cb srm: 0x%x/0x%x", p_cb->srm, srm );
- if (srm)
- {
- p_cb->srm |= srm;
- *p++ = OBX_HI_SRM;
- *p++ = OBX_HV_SRM_ENABLE;
- }
- }
- }
-
- p_pkt = obx_cl_prepend_msg(p_cb, p_pkt, msg, (UINT16)(p - msg) );
- p_pkt->event = obx_sm_evt_to_api_evt[event];
- obx_csm_event(p_cb, event, p_pkt);
- }
- else
- status = OBX_BAD_HANDLE;
-
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_PutReq
-**
-** Description This function sends a Put request to the connected server.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_PutReq(tOBX_HANDLE handle, BOOLEAN final, BT_HDR *p_pkt)
-{
- UINT8 req_code = OBX_REQ_PUT;
- if (final)
- req_code |= OBX_FINAL;
- return obx_prepend_req_msg(handle, OBX_PUT_REQ_CEVT, req_code, p_pkt);
-
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_GetReq
-**
-** Description This function sends a Get request to the connected server.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_GetReq(tOBX_HANDLE handle, BOOLEAN final, BT_HDR *p_pkt)
-{
- UINT8 req_code = OBX_REQ_GET;
- OBX_TRACE_API1("OBX_GetReq final: 0x%x", final );
- if (final)
- req_code |= OBX_FINAL;
- return obx_prepend_req_msg(handle, OBX_GET_REQ_CEVT, req_code, p_pkt);
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_AbortReq
-**
-** Description This function sends an Abort request to the connected server.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_AbortReq(tOBX_HANDLE handle, BT_HDR *p_pkt)
-{
- /* Disconnect request always has the final bit set */
- UINT8 req_code = (OBX_REQ_ABORT|OBX_FINAL);
- return obx_prepend_req_msg(handle, OBX_ABORT_REQ_CEVT, req_code, p_pkt);
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_DisconnectReq
-**
-** Description This function sends a Disconnect request to the connected server.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_DisconnectReq(tOBX_HANDLE handle, BT_HDR *p_pkt)
-{
- /* Disconnect request always has the final bit set */
- UINT8 req_code = (OBX_REQ_DISCONNECT|OBX_FINAL);
- return obx_prepend_req_msg(handle, OBX_DISCNT_REQ_CEVT, req_code, p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function OBX_ActionReq
-**
-** Description This function sends a Action request to the connected server.
-** The Name Header and DestName Header must be in p_pkt for
-** the Copy and Move Object action.
-** The Name header and Permission Header must be in p_pkt for
-** the Set Object Permission action.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_ActionReq(tOBX_HANDLE handle, tOBX_ACTION action_id, BT_HDR *p_pkt)
-{
- /* Disconnect request always has the final bit set */
- UINT8 req_code = (OBX_REQ_ACTION|OBX_FINAL);
- UINT8 *p;
-
- if (p_pkt == NULL)
- {
- OBX_TRACE_ERROR0("OBX_ActionReq must include Name & DestName Header for Copy/Move action" );
- OBX_TRACE_ERROR0("OBX_ActionReq must include Name & Permission Header for Set Object Permission action" );
- return OBX_BAD_PARAMS;
- }
-
- /* add the Action ID header before the other headers */
- p_pkt->offset -= 2;
- p_pkt->len += 2;
- p = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- *p++ = OBX_HI_ACTION_ID;
- *p++ = action_id;
-
- return obx_prepend_req_msg(handle, OBX_ACTION_REQ_CEVT, req_code, p_pkt);
-}
diff --git a/stack/obx/obx_csm.c b/stack/obx/obx_csm.c
deleted file mode 100644
index 25447df..0000000
--- a/stack/obx/obx_csm.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_csm.c
-**
-** File: OBEX Client State Machine and Control Block Access Functions
-**
-** Copyright (c) 2003-2009, Broadcom Corp., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-#include "bt_target.h"
-#include "btu.h" /* for timer */
-#include "obx_int.h"
-
-/* OBEX Client Action Functions Enums (must match obx_cl_action [below] */
-enum
-{
- OBX_CA_SND_REQ,
- OBX_CA_NOTIFY,
- OBX_CA_CONNECT_ERROR,
- OBX_CA_STATE,
- OBX_CA_CLOSE_PORT,
- OBX_CA_CONNECT_FAIL,
- OBX_CA_DISCNT_REQ,
- OBX_CA_START_TIMER,
- OBX_CA_FAIL_RSP,
- OBX_CA_SND_PART,
- OBX_CA_CONNECT_OK,
- OBX_CA_SESSION_OK,
- OBX_CA_SESSION_CONT,
- OBX_CA_SESSION_GET,
- OBX_CA_SESSION_FAIL,
- OBX_CA_ABORT,
- OBX_CA_SND_PUT_REQ,
- OBX_CA_SND_GET_REQ,
- OBX_CA_SRM_SND_REQ,
- OBX_CA_SRM_PUT_REQ,
- OBX_CA_SRM_GET_REQ,
- OBX_CA_SRM_PUT_NOTIFY,
- OBX_CA_SRM_GET_NOTIFY,
- OBX_CA_SAVE_RSP,
- OBX_CA_SAVE_REQ
-};
-
-/* OBEX Client Action Functions */
-static const tOBX_CL_ACT obx_cl_action[] =
-{
- obx_ca_snd_req,
- obx_ca_notify,
- obx_ca_connect_error,
- obx_ca_state,
- obx_ca_close_port,
- obx_ca_connect_fail,
- obx_ca_discnt_req,
- obx_ca_start_timer,
- obx_ca_fail_rsp,
- obx_ca_snd_part,
- obx_ca_connect_ok,
- obx_ca_session_ok,
- obx_ca_session_cont,
- obx_ca_session_get,
- obx_ca_session_fail,
- obx_ca_abort,
- obx_ca_snd_put_req,
- obx_ca_snd_get_req,
- obx_ca_srm_snd_req,
- obx_ca_srm_put_req,
- obx_ca_srm_get_req,
- obx_ca_srm_put_notify,
- obx_ca_srm_get_notify,
- obx_ca_save_rsp,
- obx_ca_save_req
-};
-
-/************ OBX Client FSM State/Event Indirection Table **************/
-/* obx_csm_event() first looks at obx_csm_entry_map[][] to get an entry of the event of a particular state
- * 0 means the event in the current state is ignored.
- * a number with 0x80 bit set, use obx_cl_all_table[][] as the "state table".
- * other numbers, look up obx_cl_main_state_table[] for the state table of current state.
- *
- * once the state table is determined,
- * look up the "action" column to find the associated action function
- * and the "next state" column to find the "next state" candidate.
- *
- * The actual next state could be either the state in the "next state" column
- * or the state returned from the action function.
- */
-static const UINT8 obx_csm_entry_map[][OBX_CS_MAX-1] =
-{
-/* state name: NtCon SesRs ConRs UnAut Conn DscRs OpUna StpRs ActRs AbtRs PutRs GetRs Put Get PutS GetS Part */
-/* CONN_R */{ 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
-/* SESS_R */{ 2, 0, 0, 0, 5, 0, 0, 0, 0, 0, 2, 2, 2, 2, 5, 5, 1 },
-/* DISCNT_R */{ 0, 0x87, 2, 0x87, 0x81, 0x87, 0x87, 0x81, 0x81, 0x81, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87 },
-/* PUT_R */{ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0 },
-/* GET_R */{ 0, 3, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0 },
-/* SETPATH_R*/{ 0, 0, 0, 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
-/* ACT_R */{ 0, 0, 0, 0, 6, 0, 5, 0, 0, 0, 0x82, 0x82, 0x82, 0x82, 3, 3, 1 },
-/* ABORT_R */{ 0, 0, 0, 0, 4, 0, 4, 0, 0, 0, 0x82, 0x82, 0x82, 0x82, 3, 3, 1 },
-/* OK_C */{ 0, 1, 3, 0, 0, 1, 0, 0x83, 0x83, 0x83, 0x83, 0x83, 0, 0, 0x83, 0x83, 3 },
-/* CONT_C */{ 0, 2, 0, 0, 0, 2, 0, 0, 0, 1, 1, 1, 0, 0, 4, 4, 3 },
-/* FAIL_C */{ 0, 4, 1, 0, 0, 0x87, 0, 0x86, 0x86, 2, 0x86, 0x86, 0, 0, 0x86, 0x86, 3 },
-/* PORT_CLS */{ 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84 },
-/* TX_EMPTY */{ 0x87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
-/* FCS_SET */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 },
-/* STATE */{ 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85 },
-/* TIMEOUT */{ 3, 2, 0x87, 0, 0, 0x87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
-};
-
-static const UINT8 obx_cl_all_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* DISCNT_R */{OBX_CA_SND_REQ, OBX_CS_DISCNT_REQ_SENT },
-/* ABORT_R */{OBX_CA_SND_REQ, OBX_CS_ABORT_REQ_SENT },
-/* OK_C */{OBX_CA_NOTIFY, OBX_CS_NULL },
-/* PORT_CLS */{OBX_CA_CONNECT_ERROR, OBX_CS_NOT_CONNECTED },
-/* STATE */{OBX_CA_STATE, OBX_CS_NULL },
-/* FAIL_C */{OBX_CA_FAIL_RSP, OBX_CS_NULL },
-/* end */{OBX_CA_CLOSE_PORT, OBX_CS_NOT_CONNECTED }
-};
-
-static const UINT8 obx_cl_not_conn_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* CONN_R */{OBX_CA_SND_REQ, OBX_CS_CONNECT_REQ_SENT },
-/* SESS_R */{OBX_CA_SND_REQ, OBX_CS_SESSION_REQ_SENT },
-/* TIMEOUT */{OBX_CA_SESSION_FAIL, OBX_CS_NOT_CONNECTED }
-};
-
-static const UINT8 obx_cl_sess_rs_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* OK_C */{OBX_CA_SESSION_OK, OBX_CS_NOT_CONNECTED },
-/* CONT_C */{OBX_CA_SESSION_CONT, OBX_CS_SESSION_REQ_SENT },
-/* GET_R */{OBX_CA_SESSION_GET, OBX_CS_SESSION_REQ_SENT },
-/* FAIL_C */{OBX_CA_SESSION_FAIL, OBX_CS_NOT_CONNECTED }
-};
-
-static const UINT8 obx_cl_conn_rs_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* FAIL_C */{OBX_CA_CONNECT_FAIL, OBX_CS_UNAUTH },
-/* DISCNT_R */{OBX_CA_DISCNT_REQ, OBX_CS_NULL },
-/* OK_C */{OBX_CA_CONNECT_OK, OBX_CS_NULL }
-};
-
-static const UINT8 obx_cl_unauth_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* CONN_R */{OBX_CA_SND_REQ, OBX_CS_CONNECT_REQ_SENT }
-};
-
-static const UINT8 obx_cl_conn_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* PUT_R */{OBX_CA_SND_PUT_REQ, OBX_CS_PUT_REQ_SENT },
-/* GET_R */{OBX_CA_SND_GET_REQ, OBX_CS_GET_REQ_SENT },
-/* SETPATH_R*/{OBX_CA_SND_REQ, OBX_CS_SETPATH_REQ_SENT },
-/* ABORT_R */{OBX_CA_ABORT, OBX_CS_CONNECTED },
-/* SESS_R */{OBX_CA_SND_REQ, OBX_CS_SESSION_REQ_SENT },
-/* ACT_R */{OBX_CA_SND_REQ, OBX_CS_ACTION_REQ_SENT }
-};
-
-static const UINT8 obx_cl_discnt_rs_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* OK_C */{OBX_CA_NOTIFY, OBX_CS_NOT_CONNECTED }, /* and close port */
-/* CONT_C */{OBX_CA_START_TIMER, OBX_CS_DISCNT_REQ_SENT }
-};
-
-static const UINT8 obx_cl_op_unauth_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* PUT_R */{OBX_CA_SND_REQ, OBX_CS_PUT_REQ_SENT },
-/* GET_R */{OBX_CA_SND_REQ, OBX_CS_GET_REQ_SENT },
-/* SETPATH_R*/{OBX_CA_SND_REQ, OBX_CS_SETPATH_REQ_SENT },
-/* ABORT_R */{OBX_SM_NO_ACTION, OBX_CS_CONNECTED },
-/* ACT_R */{OBX_CA_SND_REQ, OBX_CS_ACTION_REQ_SENT }
-};
-
-/* static const UINT8 obx_cl_setpath_rs_table[][OBX_SM_NUM_COLS] = { */
-/* Event Action Next State */
-/* DISCNT_R {OBX_CA_SND_REQ, OBX_CS_DISCNT_REQ_SENT },*/
-/* OK_C {OBX_CA_NOTIFY, OBX_CS_NULL },*/
-/* FAIL_C {OBX_CA_FAIL_RSP, OBX_CS_NULL },*/
-/* PORT_CLS {OBX_CA_CONNECT_ERROR, OBX_CS_NOT_CONNECTED },*/
-/* STATE {OBX_CA_STATE, OBX_CS_NULL },*/
-/* }; */
-
-static const UINT8 obx_cl_abort_rs_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* CONT_C */{OBX_CA_START_TIMER, OBX_CS_ABORT_REQ_SENT },
-/* FAIL_C */{OBX_CA_NOTIFY, OBX_CS_CONNECTED }
-};
-
-static const UINT8 obx_cl_put_rs_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* CONT_C */{OBX_CA_NOTIFY, OBX_CS_PUT_TRANSACTION },
-/* SESS_R */{OBX_CA_SND_REQ, OBX_CS_SESSION_REQ_SENT }
-};
-
-static const UINT8 obx_cl_get_rs_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* CONT_C */{OBX_CA_NOTIFY, OBX_CS_GET_TRANSACTION },
-/* SESS_R */{OBX_CA_SND_REQ, OBX_CS_SESSION_REQ_SENT }
-};
-
-static const UINT8 obx_cl_put_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* PUT_R */{OBX_CA_SND_REQ, OBX_CS_PUT_REQ_SENT },
-/* SESS_R */{OBX_CA_SND_REQ, OBX_CS_SESSION_REQ_SENT }
-};
-
-static const UINT8 obx_cl_get_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* GET_R */{OBX_CA_SND_REQ, OBX_CS_GET_REQ_SENT },
-/* SESS_R */{OBX_CA_SND_REQ, OBX_CS_SESSION_REQ_SENT }
-};
-
-static const UINT8 obx_cl_put_s_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* DISCNT_R */{OBX_CA_SRM_SND_REQ, OBX_CS_DISCNT_REQ_SENT },
-/* PUT_R */{OBX_CA_SRM_PUT_REQ, OBX_CS_PUT_SRM },
-/* ABORT_R */{OBX_CA_SRM_SND_REQ, OBX_CS_ABORT_REQ_SENT },
-/* CONT_C */{OBX_CA_SRM_PUT_NOTIFY, OBX_CS_PUT_SRM },
-/* SESS_R */{OBX_CA_SND_REQ, OBX_CS_SESSION_REQ_SENT }
-};
-
-static const UINT8 obx_cl_get_s_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* DISCNT_R */{OBX_CA_SRM_SND_REQ, OBX_CS_DISCNT_REQ_SENT },
-/* GET_R */{OBX_CA_SRM_GET_REQ, OBX_CS_GET_SRM },
-/* ABORT_R */{OBX_CA_SRM_SND_REQ, OBX_CS_ABORT_REQ_SENT },
-/* CONT_C */{OBX_CA_SRM_GET_NOTIFY, OBX_CS_GET_SRM },
-/* SESS_R */{OBX_CA_SND_REQ, OBX_CS_SESSION_REQ_SENT }
-};
-
-static const UINT8 obx_cl_part_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* ABORT_R */{OBX_CA_SAVE_REQ, OBX_CS_PARTIAL_SENT },
-/* FCS_SET */{OBX_CA_SND_PART, OBX_CS_NULL },
-/* FAIL_C */{OBX_CA_SAVE_RSP, OBX_CS_NULL }
-};
-
-static const tOBX_SM_TBL obx_cl_main_state_table[] = {
- obx_cl_not_conn_table,
- obx_cl_sess_rs_table,
- obx_cl_conn_rs_table,
- obx_cl_unauth_table,
- obx_cl_conn_table,
- obx_cl_discnt_rs_table,
- obx_cl_op_unauth_table,
- NULL, /* obx_cl_setpath_rs_table */
- NULL, /* obx_cl_action_rs_table */
- obx_cl_abort_rs_table,
- obx_cl_put_rs_table,
- obx_cl_get_rs_table,
- obx_cl_put_table,
- obx_cl_get_table,
- obx_cl_put_s_table,
- obx_cl_get_s_table,
- obx_cl_part_table
-};
-
-/*******************************************************************************
-**
-** Function obx_csm_event
-**
-** Description Handle events to the client state machine. It looks up the entry
-** in the obx_csm_entry_map array. If it is a valid entry, it gets
-** the state table. Set the next state, if not NULL state.Execute
-** the action function according to the state table. If the state
-** returned by action function is not NULL state, adjust the new
-** state to the returned state.If (api_evt != MAX), call callback
-** function.
-**
-** Returns void.
-**
-*******************************************************************************/
-void obx_csm_event(tOBX_CL_CB *p_cb, tOBX_CL_EVENT event, BT_HDR *p_msg)
-{
- UINT8 curr_state = p_cb->state;
- tOBX_SM_TBL state_table = NULL;
- UINT8 action, entry;
- tOBX_CL_STATE act_state = OBX_CS_NULL;
- UINT8 prev_state = OBX_CS_NULL;
-
- if( curr_state == OBX_CS_NULL || curr_state >= OBX_CS_MAX)
- {
- OBX_TRACE_WARNING1( "Invalid state: %d", curr_state) ;
- if(p_msg)
- GKI_freebuf(p_msg);
- return;
- }
- OBX_TRACE_DEBUG4( "Client Handle 0x%x, State: %s, event: %s srm:0x%x",
- p_cb->ll_cb.comm.handle, obx_cl_get_state_name( p_cb->state ), obx_cl_get_event_name(event), p_cb->srm ) ;
- OBX_TRACE_DEBUG1("obx_csm_event csm offset:%d", p_cb->param.sess.obj_offset);
-
- /* look up the state table for the current state */
- /* lookup entry /w event & curr_state */
- /* If entry is ignore, return.
- * Otherwise, get state table (according to curr_state or all_state) */
- if( (entry = obx_csm_entry_map[event][curr_state-1]) != OBX_SM_IGNORE )
- {
- if(entry&OBX_SM_ALL)
- {
- entry &= OBX_SM_ENTRY_MASK;
- state_table = obx_cl_all_table;
- }
- else
- state_table = obx_cl_main_state_table[curr_state-1];
- }
-
- if( entry == OBX_SM_IGNORE || state_table == NULL)
- {
- OBX_TRACE_WARNING4( "Ignore event %s(%d) in state %s(%d)",
- obx_cl_get_event_name(event), event, obx_cl_get_state_name(curr_state), curr_state );
- if(p_msg)
- GKI_freebuf(p_msg);
- return;
- }
-
- /* Get possible next state from state table. */
- if( state_table[entry-1][OBX_SME_NEXT_STATE] != OBX_CS_NULL )
- {
- prev_state = p_cb->state;
- p_cb->state = state_table[entry-1][OBX_SME_NEXT_STATE];
- if (prev_state != p_cb->state)
- {
- p_cb->prev_state = prev_state;
- OBX_TRACE_DEBUG1( "saved state1:%s", obx_cl_get_state_name(p_cb->prev_state));
- }
- }
- OBX_TRACE_DEBUG1( "possible new state = %s", obx_cl_get_state_name( p_cb->state ) ) ;
-
- /* If action is not ignore, clear param, exec action and get next state.
- * The action function may set the Param for cback.
- * Depending on param, call cback or free buffer. */
- /* execute action */
- action = state_table[entry-1][OBX_SME_ACTION];
- if (action != OBX_SM_NO_ACTION)
- {
- act_state = (*obx_cl_action[action])(p_cb, p_msg);
- }
-
- /* adjust next state, if it needs to use the new state returned from action function */
- if( act_state != OBX_CS_NULL)
- {
- prev_state = p_cb->state;
- p_cb->state = act_state;
- OBX_TRACE_DEBUG1( "new state = %s (action)", obx_cl_get_state_name( p_cb->state )) ;
- if (prev_state != p_cb->state)
- {
- p_cb->prev_state = prev_state;
- OBX_TRACE_DEBUG1( "saved state2:%s", obx_cl_get_state_name(p_cb->prev_state));
- }
- }
-
- if(p_cb->api_evt)
- {
- (p_cb->p_cback) (p_cb->ll_cb.comm.handle, p_cb->api_evt, p_cb->rsp_code, p_cb->param, p_msg);
- p_cb->api_evt = OBX_NULL_EVT;
- p_cb->rsp_code = 0;
- memset(&p_cb->param, 0, sizeof (p_cb->param) );
- }
- else if(action == OBX_SM_NO_ACTION && p_msg)
- GKI_freebuf(p_msg);
- OBX_TRACE_DEBUG1("after csm offset:%d", p_cb->param.sess.obj_offset);
-
- OBX_TRACE_DEBUG2( "result state = %s/%d", obx_cl_get_state_name( p_cb->state ), p_cb->state ) ;
-}
-
-
diff --git a/stack/obx/obx_int.h b/stack/obx/obx_int.h
deleted file mode 100644
index 8d4a7f6..0000000
--- a/stack/obx/obx_int.h
+++ /dev/null
@@ -1,602 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_int.h
-**
-** File: OBEX Internal header file
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#ifndef OBX_INT_H
-#define OBX_INT_H
-
-#include "bt_target.h"
-#include "obx_api.h"
-#include "gki.h"
-
-#define OBX_DEFAULT_TARGET_LEN 0xFF
-#define OBX_INITIAL_CONN_ID 0x1
-
-/* the rules for OBX handles: (some of the definitions are in obx_api.h)
- *
- * tOBX_HANDLE is UINT16
- * It was UINT8, the support for multiple clients on the same SCN for MAP is required
- *
- * LSB (0x00FF) is the same as the old definition.
- * The 0x80 bit (OBX_CL_HANDLE_MASK) is set for client connections.
- * The 0x40 bit (OBX_HANDLE_RX_MTU_MASK) is used internally for RFCOMM to allocate a buffer to receive data
- *
- * The MSB (0xFF00) is used for enhancements add for BTE release 3.15
- * This byte is the session index; used for server only.
- */
-
-#define OBX_CL_HANDLE_MASK 0x80
-#define OBX_CL_CB_IND_MASK 0x007F
-#define OBX_HANDLE_RX_MTU_MASK 0x40
-#define OBX_LOCAL_NONCE_SIZE OBX_MIN_NONCE_SIZE /* 4 - 16 per IrOBEX spec. local nonce is always 4 */
-
-#define OBX_MAX_EVT_MAP_NUM (OBX_ABORT_REQ_SEVT+1)
-
-#define OBX_PORT_EVENT_MASK (PORT_EV_RXCHAR | PORT_EV_TXEMPTY | \
- PORT_EV_FC | PORT_EV_FCS)
-
-#define OBX_BAD_SM_EVT 0xFF
-
-/* for wait_auth flag */
-#define OBX_WAIT_AUTH_FAIL 2
-
-enum
-{
- OBX_CS_NULL, /* 0 0 */
- OBX_CS_NOT_CONNECTED, /* 1 1 */
- OBX_CS_SESSION_REQ_SENT, /* 2 */
- OBX_CS_CONNECT_REQ_SENT, /* 3 2 */
- OBX_CS_UNAUTH, /* 4 3 */
- OBX_CS_CONNECTED, /* 5 4 */
- OBX_CS_DISCNT_REQ_SENT, /* 6 5 */
- OBX_CS_OP_UNAUTH, /* 7 6 */
- OBX_CS_SETPATH_REQ_SENT, /* 8 7 */
- OBX_CS_ACTION_REQ_SENT, /* 9 */
- OBX_CS_ABORT_REQ_SENT, /*10 8 */
- OBX_CS_PUT_REQ_SENT, /*11 9 */
- OBX_CS_GET_REQ_SENT, /*12 10 */
- OBX_CS_PUT_TRANSACTION, /*13 11 */
- OBX_CS_GET_TRANSACTION, /*14 12 */
- OBX_CS_PUT_SRM, /*15 */
- OBX_CS_GET_SRM, /*16 */
- OBX_CS_PARTIAL_SENT, /*17 13 */
- OBX_CS_MAX
-};
-
-typedef UINT8 tOBX_CL_STATE;
-#define OBX_CL_STATE_DROP 0x80 /* this is used only in session_info[] to mark link drop suspend*/
-
-enum
-{
- OBX_CONNECT_REQ_CEVT, /* API call to send a CONNECT request. */
- OBX_SESSION_REQ_CEVT, /* API call to send a SESSION request. */
- OBX_DISCNT_REQ_CEVT, /* API call to send a DISCONNECT request. */
- OBX_PUT_REQ_CEVT, /* API call to send a PUT request. */
- OBX_GET_REQ_CEVT, /* API call to send a GET request.*/
- OBX_SETPATH_REQ_CEVT, /* API call to send a SETPATH request. */
- OBX_ACTION_REQ_CEVT, /* API call to send an ACTION request. */
- OBX_ABORT_REQ_CEVT, /* API call to send an ABORT request. */
- OBX_OK_CFM_CEVT, /* Received success response from server. */
- OBX_CONT_CFM_CEVT, /* Received continue response from server. */
- OBX_FAIL_CFM_CEVT, /* Received failure response from server. */
- OBX_PORT_CLOSE_CEVT, /* Transport is closed. */
- OBX_TX_EMPTY_CEVT, /* Transmit Queue Empty */
- OBX_FCS_SET_CEVT, /* Data flow enable */
- OBX_STATE_CEVT, /* Change state. */
- OBX_TIMEOUT_CEVT, /* Timeout occurred. */
- OBX_MAX_CEVT
-};
-typedef UINT8 tOBX_CL_EVENT;
-
-#define OBX_MAX_API_CEVT OBX_ABORT_REQ_CEVT
-
-enum
-{
- OBX_CONNECT_REQ_SEVT, /* 1 1 Received CONNECT request from client. */
- OBX_SESSION_REQ_SEVT, /* 2 Received SESSION request from client. */
- OBX_DISCNT_REQ_SEVT, /* 3 2 Received DISCONNECT request from client. */
- OBX_PUT_REQ_SEVT, /* 4 3 Received PUT request from client. */
- OBX_GET_REQ_SEVT, /* 5 4 Received GET request from client. */
- OBX_SETPATH_REQ_SEVT, /* 6 5 Received SETPATH request from client. */
- OBX_ACTION_REQ_SEVT, /* 7 Received ACTION request from client. */
- OBX_ABORT_REQ_SEVT, /* 8 6 Received ABORT request from client. */
- OBX_CONNECT_CFM_SEVT, /* 9 7 API call to send a CONNECT response. */
- OBX_SESSION_CFM_SEVT, /*10 API call to send a SESSION response. */
- OBX_DISCNT_CFM_SEVT, /*11 8 API call to send a DISCONNECT response or close the connection to the client. */
- OBX_PUT_CFM_SEVT, /*12 9 API call to send a PUT response. */
- OBX_GET_CFM_SEVT, /*13 10 API call to send a GET response. */
- OBX_SETPATH_CFM_SEVT, /*14 11 API call to send a SETPATH response. */
- OBX_ACTION_CFM_SEVT, /*15 API call to send an ACTION response. */
- OBX_ABORT_CFM_SEVT, /*16 12 API call to send an ABORT response. */
- OBX_PORT_CLOSE_SEVT, /*17 13 Transport is closed. */
- OBX_FCS_SET_SEVT, /*18 14 Data flow enable */
- OBX_STATE_SEVT, /*19 15 Change state. */
- OBX_TIMEOUT_SEVT, /*20 16 Timeout has occurred. */
- OBX_BAD_REQ_SEVT, /*21 17 Received a bad request from client. */
- OBX_TX_EMPTY_SEVT, /*22 18 Transmit Queue Empty */
- OBX_MAX_SEVT
-};
-typedef UINT8 tOBX_SR_EVENT;
-
-#define OBX_SEVT_DIFF_REQ_CFM (OBX_CONNECT_CFM_SEVT - OBX_CONNECT_REQ_SEVT) /* the index difference between *REQ_SEVT and *CFM_SEVT */
-#define OBX_SEVT_MAX_REQ OBX_ACTION_REQ_SEVT /* last *REQ_SEVT */
-
-enum
-{
- OBX_SS_NULL, /* 0 0 */
- OBX_SS_NOT_CONNECTED, /* 1 1 */
- OBX_SS_SESS_INDICATED, /* 2 */
- OBX_SS_CONN_INDICATED, /* 3 2 */
- OBX_SS_WAIT_AUTH, /* 4 3 */
- OBX_SS_AUTH_INDICATED, /* 5 4 */
- OBX_SS_CONNECTED, /* 6 5 */
- OBX_SS_DISCNT_INDICATED, /* 7 6 */
- OBX_SS_SETPATH_INDICATED, /* 8 7 */
- OBX_SS_ACTION_INDICATED, /* 9 */
- OBX_SS_ABORT_INDICATED, /*10 8 */
- OBX_SS_PUT_INDICATED, /*11 9 */
- OBX_SS_GET_INDICATED, /*12 10 */
- OBX_SS_PUT_TRANSACTION, /*13 11 */
- OBX_SS_GET_TRANSACTION, /*14 12 */
- OBX_SS_PUT_SRM, /*15 */
- OBX_SS_GET_SRM, /*16 */
- OBX_SS_PARTIAL_SENT, /*17 13 */
- OBX_SS_WAIT_CLOSE, /*18 14 */
- OBX_SS_MAX
-};
-typedef UINT8 tOBX_SR_STATE;
-
-typedef UINT8 tOBX_STATE; /* this must be the same type as tOBX_SR_STATE and tOBX_CL_STATE */
-
-typedef struct
-{
- UINT16 pkt_len;/* the packet length */
- UINT8 code; /* the response/request code with the final bit */
- UINT8 sm_evt; /* The state machine event*/
-} tOBX_RX_HDR;
-
-typedef void (tOBX_CLOSE_FN) (UINT16);
-typedef BOOLEAN (tOBX_SEND_FN) (void *p_cb);
-typedef UINT8 (*tOBX_VERIFY_OPCODE)(UINT8 opcode, tOBX_RX_HDR *p_rxh);
-
-#define OBX_SRM_NO 0x00 /* SRM is not enabled and not engaged */
-#define OBX_SRM_ENABLE 0x01 /* SRM is enabled. */
-#define OBX_SRM_PARAM_AL 0x02 /* SRMP is allowed only in the beginning of a transaction */
-#define OBX_SRM_REQING 0x04 /* requesting/requested to enable SRM. */
-#define OBX_SRM_ABORT 0x08 /* (server) abort/reject at SRM GET/PUT rsp API*/
-#define OBX_SRM_ENGAGE 0x10 /* SRM is engaged. */
-#define OBX_SRM_NEXT 0x20 /* peer is ready for next packet. */
-#define OBX_SRM_WAIT 0x40 /* wait for peer. */
-#define OBX_SRM_WAIT_UL 0x80 /* wait for upper layer. */
-typedef UINT8 tOBX_SRM;
-
-#define OBX_SRMP_WAIT 0x40 /* wait for peer */
-#define OBX_SRMP_NONF 0x80 /* handle GET non-final (used by server only) */
-#define OBX_SRMP_NONF_EVT 0x20 /* report GET non-final req event (used by server only) */
-#define OBX_SRMP_SESS_FST 0x01 /* mark the session resume. The SSN on first req might not match */
-typedef UINT8 tOBX_SRMP;
-
-/* continue to define tOBX_SESS_ST for internal use */
-enum
-{
- OBX_SESS_TIMEOUT = OBX_SESS_EXT_MAX, /* 0x03 session is requested/set timeout. */
- OBX_SESS_CREATE, /* 0x04 session is requested/create. */
- OBX_SESS_SUSPEND, /* 0x05 session is requested/suspend. */
- OBX_SESS_RESUME, /* 0x06 session is requested/resume. */
- OBX_SESS_CLOSE, /* 0x07 session is requested/close. */
- OBX_SESS_SUSPENDING /* 0x08 session is requested/suspend: server has not reported the suspend event */
-};
-#define OBX_SESS_DROP (0x80|OBX_SESS_SUSPENDED) /* the session as suspended by link drop */
-
-/* port control block */
-typedef struct
-{
- tOBX_HANDLE handle; /* The handle of the client or session handle for server */
- UINT16 port_handle; /* Port handle of connection */
- UINT16 tx_mtu; /* The MTU of the connected peer */
- UINT16 rx_mtu; /* The MTU of this instance */
- TIMER_LIST_ENT tle; /* This session's Timer List Entry */
- tOBX_CLOSE_FN *p_close_fn; /* the close connection function */
- tOBX_SEND_FN *p_send_fn; /* the send message function */
- BT_HDR *p_txmsg; /* The message to send to peer */
- BUFFER_Q rx_q; /* received data buffer queue */
- BOOLEAN stopped; /* TRUE, if flow control the peer (stop peer from sending more data). */
- BT_HDR *p_rxmsg; /* The message received from peer */
-} tOBX_PORT_CB;
-
-typedef struct
-{
- tOBX_PORT_CB *p_pcb; /* the port control block */
- UINT32 code; /* the event code from RFCOMM */
-} tOBX_PORT_EVT;
-
-/* l2cap control block */
-typedef struct
-{
- tOBX_HANDLE handle; /* The handle of the client or session handle for server */
- UINT16 lcid; /* l2cap lcid of connection */
- UINT16 tx_mtu; /* The MTU of the connected peer */
- UINT16 rx_mtu; /* The MTU of this instance */
- TIMER_LIST_ENT tle; /* This session's Timer List Entry */
- tOBX_CLOSE_FN *p_close_fn; /* the close connection function */
- tOBX_SEND_FN *p_send_fn; /* the send message function */
- BT_HDR *p_txmsg; /* The message to send to peer */
- BUFFER_Q rx_q; /* received data buffer queue */
- BOOLEAN stopped; /* TRUE, if flow control the peer (stop peer from sending more data). */
- UINT8 ch_state; /* L2CAP channel state */
- UINT8 ch_flags; /* L2CAP configuration flags */
- BOOLEAN cong; /* TRUE, if L2CAP is congested. */
-} tOBX_L2C_CB;
-
-enum
-{
- OBX_L2C_EVT_CONG,
- OBX_L2C_EVT_CLOSE,
- OBX_L2C_EVT_CONN_IND,
- OBX_L2C_EVT_DATA_IND,
- OBX_L2C_EVT_RESUME
-};
-typedef UINT8 tOBX_L2C_EVT;
-
-typedef struct
-{
- BD_ADDR bd_addr;
- UINT16 lcid;
- UINT16 psm;
- UINT8 id;
-} tOBX_L2C_IND;
-
-typedef union
-{
- tOBX_L2C_IND conn_ind;
- BOOLEAN is_cong;
- BT_HDR *p_pkt;
- UINT8 any;
- BD_ADDR remote_addr;
-} tOBX_L2C_EVT_PARAM;
-
-typedef struct
-{
- tOBX_L2C_CB *p_l2cb; /* the L2CAP control block */
- tOBX_L2C_EVT_PARAM param;
- tOBX_L2C_EVT l2c_evt; /* the event code from L2CAP */
-} tOBX_L2C_EVT_MSG;
-
-/* common of port & l2cap control block */
-typedef struct
-{
- tOBX_HANDLE handle; /* The handle of the client or session handle for server */
- UINT16 id; /* l2cap lcid or port handle */
- UINT16 tx_mtu; /* The MTU of the connected peer */
- UINT16 rx_mtu; /* The MTU of this instance */
- TIMER_LIST_ENT tle; /* This session's Timer List Entry */
- tOBX_CLOSE_FN *p_close_fn; /* the close connection function */
- tOBX_SEND_FN *p_send_fn; /* the send message function */
- BT_HDR *p_txmsg; /* The message to send to peer */
- BUFFER_Q rx_q; /* received data buffer queue */
- BOOLEAN stopped; /* TRUE, if flow control the peer (stop peer from sending more data). */
-} tOBX_COMM_CB;
-
-/* lower layer control block */
-typedef union
-{
- tOBX_PORT_CB port;
- tOBX_L2C_CB l2c;
- tOBX_COMM_CB comm;
-} tOBX_LL_CB;
-
-/* client control block */
-typedef struct
-{
- tOBX_CL_CBACK *p_cback; /* Application callback function to receive events */
- BT_HDR *p_next_req; /* This is used when the session is flow controlled by peer
- * and a DISCONNECT or ABORT request is sent.*/
- BT_HDR *p_saved_req; /* Client saves a copy of the request sent to the server
- * Just in case the operation is challenged by the server */
- BT_HDR *p_auth; /* The request-digest string, if challenging the server.
- * The received OBEX packet, if waiting for password */
- tOBX_LL_CB ll_cb; /* lower layer control block for this client */
- UINT32 conn_id; /* Connection ID for this connection */
- UINT32 nonce; /* This is converted to UINT8[16] internally before adding to the OBEX header. This value is copied to the server control block and is increased after each use. 0, if only legacy OBEX (unreliable) session is desired. */
- BD_ADDR peer_addr; /* peer address */
- tOBX_EVT_PARAM param; /* The event parameter. */
- UINT8 sess_info[OBX_SESSION_INFO_SIZE]; /* session id + local nonce */
- tOBX_EVENT api_evt; /* Set the API event, if need to notify user outside of action function. */
- tOBX_CL_STATE state; /* The current state */
- tOBX_STATE next_state; /* Use by PART state to return to regular states */
- tOBX_CL_STATE prev_state; /* The previous state */
- UINT16 psm; /* L2CAP virtual psm */
- tOBX_SRM srm; /* Single Response Mode */
- tOBX_SRMP srmp; /* Single Response Mode Parameter */
- UINT8 ssn; /* Session Sequence number */
- tOBX_SESS_ST sess_st; /* Session state */
- UINT8 rsp_code; /* The response code of the response packet */
- BOOLEAN final; /* The final bit status of last request */
- BOOLEAN wait_auth; /* TRUE, if challenges the server and is waiting for the response */
-} tOBX_CL_CB;
-
-/* Authentication Control block */
-typedef struct
-{
- UINT32 nonce; /* Timestamp used as nonce */
- tOBX_AUTH_OPT auth_option; /* Authentication option */
- UINT8 realm_len; /* The length of p_realm */
- UINT8 realm[1]; /* The realm of this server. Charset is the first byte */
-} tOBX_AUTH_PARAMS;
-
-/* suspend control block */
-typedef struct
-{
- TIMER_LIST_ENT stle; /* The timer for suspended session timeout */
- BD_ADDR peer_addr; /* peer address */
- UINT8 sess_info[OBX_SESSION_INFO_SIZE]; /* session id + local nonce + conn id + state + srm */
- UINT32 offset; /* the file offset */
- tOBX_SR_STATE state; /* The current state */
- UINT8 ssn; /* the last ssn */
-} tOBX_SPND_CB;
-
-/* server control block */
-typedef struct
-{
- tOBX_SR_CBACK *p_cback; /* Application callback function to receive events */
- tOBX_TARGET target; /* target header of this server */
- tOBX_AUTH_PARAMS *p_auth; /* A GKI buffer that holds the authentication related parameters */
- UINT8 sess[OBX_MAX_SR_SESSION]; /* index + 1 of sr_sess[]. 0, if not used. */
- tOBX_SPND_CB *p_suspend; /* the information for suspended sessions (GKI buffer) */
- UINT32 nonce; /* This is converted to UINT8[16] internally before adding to the OBEX header. This value is copied to the server control block and is increased after each use. 0, if only legacy OBEX (unreliable) session is desired. */
- UINT16 psm; /* PSM for this server */
- UINT8 max_suspend; /* the max number of tOBX_SPD_CB[] in p_suspend. must be less than OBX_MAX_SUSPEND_SESSIONS */
- UINT8 scn; /* SCN for this server */
- UINT8 num_sess; /* Max number of session control blocks used by this server*/
-} tOBX_SR_CB;
-
-/* server session control block */
-typedef struct
-{
- BT_HDR *p_saved_msg; /* This is a message saved for authentication or GetReq-non-final */
- BT_HDR *p_next_req; /* This is a message saved for flow control reasons */
- tOBX_LL_CB ll_cb; /* lower layer control block for this session */
- UINT32 conn_id; /* Connection ID for this connection */
- BD_ADDR peer_addr; /* peer address */
- UINT8 sess_info[OBX_SESSION_INFO_SIZE]; /* session id + local nonce */
- tOBX_SR_STATE state; /* The current state */
- tOBX_SR_STATE prev_state; /* The previous state */
- tOBX_STATE next_state; /* Use by PART state to return to regular states */
- tOBX_HANDLE handle; /* The obx handle for server */
- tOBX_EVENT api_evt; /* The event to notify the API user. */
- tOBX_EVT_PARAM param; /* The event parameter. */
- tOBX_SRMP srmp; /* Single Response Mode Parameter */
- tOBX_SRM srm; /* Single Response Mode */
- tOBX_SESS_ST sess_st; /* Session state */
- UINT8 ssn; /* Next Session Sequence number */
- UINT8 cur_op; /* The op code for the current transaction (keep this for Abort reasons) */
- /* set to the current OP (non-abort) in rfc.c, set it to abort when a response is sent */
-} tOBX_SR_SESS_CB;
-
-typedef struct
-{
-#if (OBX_SERVER_INCLUDED == TRUE)
- tOBX_SR_CB server[OBX_NUM_SERVERS];/* The server control blocks */
- UINT32 next_cid; /* Next OBEX connection ID for server */
- tOBX_SR_SESS_CB sr_sess[OBX_NUM_SR_SESSIONS];
- tOBX_L2C_CB sr_l2cb; /* for obx_l2c_connect_ind_cback */
-#endif
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
- tOBX_CL_CB client[OBX_NUM_CLIENTS];/* The client control blocks */
- tOBX_PORT_CB *p_temp_pcb; /* Valid only during client RFCOMM_CreateConnection call */
- UINT8 next_ind; /* The index to the next client control block */
-#endif
-
- tOBX_HANDLE hdl_map[MAX_RFC_PORTS]; /* index of this array is the port_handle,
- * the value is the OBX handle */
- UINT16 l2c_map[MAX_L2CAP_CHANNELS]; /* index of this array is (lcid - L2CAP_BASE_APPL_CID) */
- UINT32 timeout_val; /* The timeout value to wait for activity from peer */
- UINT32 sess_tout_val; /* The timeout value for reliable sessions to remain in suspend */
- UINT8 trace_level; /* The default trace level */
- UINT8 num_client; /* Number of client control blocks */
- UINT8 num_server; /* Number of server control blocks */
- UINT8 num_sr_sess; /* Number of server session control blocks */
- UINT8 max_rx_qcount; /* Max Number of rx_q count */
-} tOBX_CB;
-
-/*****************************************************************************
-** Definition for State Machine
-*****************************************************************************/
-
-/* Client Action functions are of this type */
-typedef tOBX_CL_STATE (*tOBX_CL_ACT)(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-
-/* Server Action functions are of this type */
-typedef tOBX_SR_STATE (*tOBX_SR_ACT)(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-
-#define OBX_SM_IGNORE 0
-#define OBX_SM_NO_ACTION 0xFF
-#define OBX_SM_ALL 0x80 /* for events like close confirm, abort request, close request where event handling is the same for most of the states */
-#define OBX_SM_ENTRY_MASK 0x7F /* state machine entry mask */
-
-#define OBX_SME_ACTION 0
-#define OBX_SME_NEXT_STATE 1
-#define OBX_SM_NUM_COLS 2
-
-typedef const UINT8 (*tOBX_SM_TBL)[OBX_SM_NUM_COLS];
-
-/*****************************************************************************
-** External global data
-*****************************************************************************/
-#if OBX_DYNAMIC_MEMORY == FALSE
-OBX_API extern tOBX_CB obx_cb;
-#else
-OBX_API extern tOBX_CB *obx_cb_ptr;
-#define obx_cb (*obx_cb_ptr)
-#endif
-extern const tOBX_EVENT obx_sm_evt_to_api_evt[];
-extern const UINT8 obx_hdr_start_offset[];
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-/* from obx_main.c */
-
-#if (defined (BT_USE_TRACES) && BT_USE_TRACES == TRUE && OBX_CLIENT_INCLUDED == TRUE)
-extern const char * obx_cl_get_state_name(tOBX_CL_STATE state);
-extern const char * obx_cl_get_event_name(tOBX_CL_EVENT event);
-#else
-#define obx_cl_get_state_name(state_num) ""
-#define obx_cl_get_event_name(event_num) ""
-#endif
-
-#if (defined (BT_USE_TRACES) && BT_USE_TRACES == TRUE && OBX_SERVER_INCLUDED == TRUE)
-extern const char * obx_sr_get_state_name(tOBX_SR_STATE state);
-extern const char * obx_sr_get_event_name(tOBX_SR_EVENT event);
-#else
-#define obx_sr_get_state_name(state_num) ""
-#define obx_sr_get_event_name(event_num) ""
-#endif
-/* client functions in obx_main.c */
-extern void obx_cl_timeout(TIMER_LIST_ENT *p_tle);
-extern tOBX_CL_CB * obx_cl_alloc_cb(void);
-extern tOBX_CL_CB * obx_cl_get_cb(tOBX_HANDLE handle);
-extern tOBX_CL_CB * obx_cl_get_suspended_cb(tOBX_HANDLE *p_handle, UINT8 *p_session_info);
-extern void obx_cl_free_cb(tOBX_CL_CB * p_cb);
-
-/* server functions in obx_main.c */
-extern tOBX_SPND_CB * obx_find_suspended_session (tOBX_SR_SESS_CB *p_scb, tOBX_TRIPLET *p_triplet, UINT8 num);
-extern void obx_l2c_snd_evt (tOBX_L2C_CB *p_l2cb, tOBX_L2C_EVT_PARAM param, tOBX_L2C_EVT l2c_evt);
-extern void obx_sr_timeout(TIMER_LIST_ENT *p_tle);
-extern void obx_sr_sess_timeout(TIMER_LIST_ENT *p_tle);
-extern tOBX_HANDLE obx_sr_alloc_cb(tOBX_StartParams *p_params);
-extern tOBX_SR_CB * obx_sr_get_cb(tOBX_HANDLE handle);
-extern tOBX_SR_SESS_CB * obx_sr_get_scb(tOBX_HANDLE handle);
-extern void obx_sr_free_cb(tOBX_HANDLE handle);
-extern void obx_sr_free_scb(tOBX_SR_SESS_CB *p_scb);
-extern UINT32 obx_sr_get_next_conn_id(void);
-/* common functions in obx_main.c */
-extern tOBX_PORT_CB * obx_port_handle_2cb(UINT16 port_handle);
-extern void obx_start_timer(tOBX_COMM_CB *p_pcb);
-extern void obx_stop_timer(TIMER_LIST_ENT *p_tle);
-
-/* from obx_rfc.c */
-extern void obx_cl_proc_evt(tOBX_PORT_EVT *p_evt);
-extern BT_HDR * obx_build_dummy_rsp(tOBX_SR_SESS_CB *p_scb, UINT8 rsp_code);
-extern void obx_sr_proc_evt(tOBX_PORT_EVT *p_evt);
-extern BOOLEAN obx_rfc_snd_msg(tOBX_PORT_CB *p_pcb);
-extern tOBX_STATUS obx_open_port(tOBX_PORT_CB *p_pcb, const BD_ADDR bd_addr, UINT8 scn);
-extern void obx_add_port(tOBX_HANDLE obx_handle);
-extern void obx_close_port(UINT16 port_handle);
-
-/* from obx_capi.c */
-extern tOBX_STATUS obx_prepend_req_msg(tOBX_HANDLE handle, tOBX_CL_EVENT event, UINT8 req_code, BT_HDR *p_pkt);
-
-/* from obx_csm.c */
-extern void obx_csm_event(tOBX_CL_CB *p_cb, tOBX_EVENT event, BT_HDR *p_msg);
-
-/* from obx_cact.c */
-extern void obx_ca_connect_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_snd_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_close_port(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_snd_part(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_connect_error(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_connect_fail(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_discnt_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_notify(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_fail_rsp(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_state(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_start_timer(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_connect_ok(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_session_ok(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_session_cont(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_session_get(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_session_fail(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_abort(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_snd_put_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_snd_get_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_srm_snd_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_srm_put_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_srm_get_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_srm_put_notify(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_srm_get_notify(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_save_rsp(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern tOBX_CL_STATE obx_ca_save_req(tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-
-/* from obx_ssm.c */
-extern void obx_ssm_event(tOBX_SR_SESS_CB *p_scb, tOBX_SR_EVENT event, BT_HDR *p_msg);
-
-/* from obx_sapi.c */
-extern tOBX_STATUS obx_prepend_rsp_msg(tOBX_HANDLE shandle, tOBX_SR_EVENT event, UINT8 rsp_code, BT_HDR *p_pkt);
-
-/* from obx_sact.c */
-extern tOBX_SR_STATE obx_sa_snd_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_snd_part(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_abort_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_op_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern BT_HDR * obx_conn_rsp(tOBX_SR_CB *p_cb, tOBX_SR_SESS_CB *p_scb, UINT8 rsp_code, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_connect_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_wc_conn_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_auth_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_connect_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_connection_error(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_close_port(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_clean_port(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_state(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_nc_to(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_save_req(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_rej_req(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_session_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_sess_conn_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_wc_sess_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_session_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_put_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_get_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_get_req(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_srm_put_req(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_srm_put_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_srm_get_fcs(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_srm_get_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern tOBX_SR_STATE obx_sa_srm_get_req(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-
-/* from obx_gen.c */
-extern void obx_access_rsp_code(BT_HDR *p_pkt, UINT8 *p_rsp_code);
-extern void obx_adjust_packet_len(BT_HDR *p_pkt);
-extern UINT16 obx_read_header_len(UINT8 *ph);
-extern BT_HDR * obx_dup_pkt(BT_HDR *p_pkt);
-
-/* from obx_md5 */
-extern BT_HDR * obx_unauthorize_rsp(tOBX_SR_CB *p_cb, tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern void obx_session_id(UINT8 *p_sess_id, UINT8 *p_cl_addr, UINT8 * p_cl_nonce, int cl_nonce_len,
- UINT8 *p_sr_addr, UINT8 * p_sr_nonce, int sr_nonce_len);
-
-/* from obx_l2c.c */
-extern void obx_register_l2c(tOBX_CL_CB *p_cl_cb, UINT16 psm);
-extern tOBX_STATUS obx_open_l2c(tOBX_CL_CB *p_cl_cb, const BD_ADDR bd_addr);
-extern tOBX_STATUS obx_l2c_sr_register (tOBX_SR_CB *p_cb);
-extern void obx_close_l2c(UINT16 lcid);
-extern BOOLEAN obx_l2c_snd_msg(tOBX_L2C_CB *p_l2cb);
-extern void obx_sr_proc_l2c_evt (tOBX_L2C_EVT_MSG *p_msg);
-extern void obx_cl_proc_l2c_evt (tOBX_L2C_EVT_MSG *p_msg);
-
-/* from obx_utils.c */
-extern UINT8 obx_verify_response(UINT8 opcode, tOBX_RX_HDR *p_rxh);
-extern UINT8 obx_verify_request(UINT8 opcode, tOBX_RX_HDR *p_rxh);
-extern BOOLEAN obx_sr_proc_pkt (tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt);
-extern void obx_cl_proc_pkt (tOBX_CL_CB *p_cb, BT_HDR *p_pkt);
-extern void obx_free_buf(tOBX_LL_CB *p_ll_cb);
-extern UINT8 obx_add_timeout (tOBX_TRIPLET *p_trip, UINT32 timeout, tOBX_SESS_EVT *p_param);
-extern void obx_read_timeout (tOBX_TRIPLET *p_trip, UINT8 num, UINT32 *p_timeout, UINT8 *p_toa);
-#if (BT_USE_TRACES == TRUE)
-extern void obxu_dump_hex (UINT8 *p, char *p_title, UINT16 len);
-#else
-#define obxu_dump_hex(p, p_title, len)
-#endif
-extern BT_HDR * obx_sr_prepend_msg(BT_HDR *p_pkt, UINT8 * p_data, UINT16 data_len);
-extern BT_HDR * obx_cl_prepend_msg(tOBX_CL_CB *p_cb, BT_HDR *p_pkt, UINT8 * p_data, UINT16 data_len);
-extern void obx_flow_control(tOBX_COMM_CB *p_comm);
-extern UINT8 obx_read_triplet(tOBX_TRIPLET *p_trip, UINT8 num_trip, UINT8 tag);
-extern UINT32 obx_read_obj_offset(tOBX_TRIPLET *p_trip, UINT8 num_trip);
-
-#endif /* OBX_INT_H */
diff --git a/stack/obx/obx_l2c.c b/stack/obx/obx_l2c.c
deleted file mode 100644
index 51226d9..0000000
--- a/stack/obx/obx_l2c.c
+++ /dev/null
@@ -1,1031 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_l2c.c
-**
-** Description: This OBX module interfaces to L2CAP
-**
-** Copyright (c) 2008-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <string.h>
-#include "wcassert.h"
-#include "data_types.h"
-#include "bt_target.h"
-#include "obx_api.h"
-#include "obx_int.h"
-#include "l2c_api.h"
-#include "l2cdefs.h"
-#include "port_api.h"
-#include "btu.h"
-#include "btm_int.h"
-
-/* Configuration flags. */
-#define OBX_L2C_CFG_IND_DONE 0x01
-#define OBX_L2C_CFG_CFM_DONE 0x02
-#define OBX_L2C_SECURITY_DONE 0x04
-#define OBX_L2C_CONN_RQS_DONE 0x07
-
-/* "states" used for L2CAP channel */
-#define OBX_CH_IDLE 0 /* No connection */
-#define OBX_CH_CONN 1 /* Waiting for connection confirm */
-#define OBX_CH_CFG 2 /* Waiting for configuration complete */
-#define OBX_CH_OPEN 3 /* Channel opened */
-
-/* callback function declarations */
-void obx_l2c_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id);
-void obx_l2c_connect_cfm_cback(UINT16 lcid, UINT16 result);
-void obx_l2c_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg);
-void obx_l2c_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg);
-void obx_l2c_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed);
-void obx_l2c_disconnect_cfm_cback(UINT16 lcid, UINT16 result);
-void obx_l2c_data_ind_cback(UINT16 lcid, BT_HDR *p_buf);
-void obx_l2c_congestion_ind_cback(UINT16 lcid, BOOLEAN is_congested);
-tOBX_SR_SESS_CB * obx_lcb_2_sr_sess_cb(tOBX_L2C_CB *p_lcb);
-
-#if (OBX_SERVER_INCLUDED == TRUE)
-/* L2CAP callback function structure for server */
-const tL2CAP_APPL_INFO obx_l2c_sr_appl = {
- obx_l2c_connect_ind_cback, /* tL2CA_CONNECT_IND_CB */
- NULL, /* tL2CA_CONNECT_CFM_CB */
- NULL, /* tL2CA_CONNECT_PND_CB */
- obx_l2c_config_ind_cback, /* tL2CA_CONFIG_IND_CB */
- obx_l2c_config_cfm_cback, /* tL2CA_CONFIG_CFM_CB */
- obx_l2c_disconnect_ind_cback, /* tL2CA_DISCONNECT_IND_CB */
- obx_l2c_disconnect_cfm_cback, /* tL2CA_DISCONNECT_CFM_CB */
- NULL, /* tL2CA_QOS_VIOLATION_IND_CB */
- obx_l2c_data_ind_cback, /* tL2CA_DATA_IND_CB */
- obx_l2c_congestion_ind_cback, /* tL2CA_CONGESTION_STATUS_CB */
- NULL /* tL2CA_TX_COMPLETE_CB */
-};
-#endif
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
-/* L2CAP callback function structure for client */
-const tL2CAP_APPL_INFO obx_l2c_cl_appl = {
- NULL, /* tL2CA_CONNECT_IND_CB */
- obx_l2c_connect_cfm_cback, /* tL2CA_CONNECT_CFM_CB */
- NULL, /* tL2CA_CONNECT_PND_CB */
- obx_l2c_config_ind_cback, /* tL2CA_CONFIG_IND_CB */
- obx_l2c_config_cfm_cback, /* tL2CA_CONFIG_CFM_CB */
- obx_l2c_disconnect_ind_cback, /* tL2CA_DISCONNECT_IND_CB */
- obx_l2c_disconnect_cfm_cback, /* tL2CA_DISCONNECT_CFM_CB */
- NULL, /* tL2CA_QOS_VIOLATION_IND_CB */
- obx_l2c_data_ind_cback, /* tL2CA_DATA_IND_CB */
- obx_l2c_congestion_ind_cback, /* tL2CA_CONGESTION_STATUS_CB */
- NULL /* tL2CA_TX_COMPLETE_CB */
-};
-#endif
-
-/* OBX eL2CAP default options */
-const tL2CAP_FCR_OPTS obx_l2c_fcr_opts_def = {
- L2CAP_FCR_ERTM_MODE, /* Mandatory for Obex over L2CAP */
- OBX_FCR_OPT_TX_WINDOW_SIZE_BR_EDR, /* Tx window size over Bluetooth */
- OBX_FCR_OPT_MAX_TX_B4_DISCNT, /* Maximum transmissions before disconnecting */
- OBX_FCR_OPT_RETX_TOUT, /* Retransmission timeout (2 secs) */
- OBX_FCR_OPT_MONITOR_TOUT, /* Monitor timeout (12 secs) */
- L2CAP_DEFAULT_ERM_MPS /* MPS segment size */
-};
-
-/*******************************************************************************
-** Function obx_l2c_snd_evt
-** Description Sends an L2CAP event to OBX through the BTU task.
-*******************************************************************************/
-void obx_l2c_snd_evt (tOBX_L2C_CB *p_l2cb, tOBX_L2C_EVT_PARAM param, tOBX_L2C_EVT l2c_evt)
-{
- BT_HDR *p_msg;
- tOBX_L2C_EVT_MSG *p_evt;
- UINT16 event;
-
- if (!p_l2cb)
- return;
-
- p_msg = (BT_HDR*)GKI_getbuf(BT_HDR_SIZE + sizeof(tOBX_PORT_EVT));
- WC_ASSERT(p_msg);
-
- if (p_l2cb->handle & OBX_CL_HANDLE_MASK)
- event = BT_EVT_TO_OBX_CL_L2C_MSG;
- else
- event = BT_EVT_TO_OBX_SR_L2C_MSG;
-
- p_msg->event = event;
- p_msg->len = sizeof(tOBX_L2C_EVT_MSG);
- p_msg->offset = 0;
- p_evt = (tOBX_L2C_EVT_MSG *)(p_msg + 1);
- p_evt->l2c_evt = l2c_evt;
- p_evt->p_l2cb = p_l2cb;
- p_evt->param = param;
-
- GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_msg);
-}
-
-#if (OBX_SERVER_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function obx_sr_scb_by_psm
-**
-** Description Find the server session control block for L2CAP.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-tOBX_SR_SESS_CB * obx_sr_scb_by_psm (UINT16 psm)
-{
- UINT32 xx, yy;
- tOBX_SR_CB *p_cb;
- tOBX_SR_SESS_CB *p_scb = NULL, *p_scbt;
- UINT16 port_handle;
-
- for (xx=0; xx<obx_cb.num_server; xx++)
- {
- if (obx_cb.server[xx].psm == psm)
- {
- p_cb = &obx_cb.server[xx];
- /* find one that has not allocated a RFCOMM port */
- for (yy=0; yy<p_cb->num_sess; yy++)
- {
- p_scbt = &obx_cb.sr_sess[p_cb->sess[yy]-1];
- if (p_scbt->ll_cb.comm.id == 0)
- {
- p_scb = p_scbt;
- p_scb->ll_cb.l2c.p_close_fn = obx_close_l2c;
- p_scb->ll_cb.l2c.p_send_fn = (tOBX_SEND_FN *)obx_l2c_snd_msg;
- break;
- }
- }
-
- if (p_scb == NULL)
- {
- /* check if an RFCOMM port can be freed */
- for (yy=0; yy<p_cb->num_sess; yy++)
- {
- p_scbt = &obx_cb.sr_sess[p_cb->sess[yy]-1];
- if (p_scbt->ll_cb.comm.p_send_fn == (tOBX_SEND_FN *)obx_rfc_snd_msg && p_scbt->state == OBX_SS_NOT_CONNECTED)
- {
- port_handle = p_scbt->ll_cb.port.port_handle;
- p_scbt->ll_cb.port.port_handle = 0;
- p_scb = p_scbt;
- p_scb->ll_cb.l2c.p_close_fn = obx_close_l2c;
- p_scb->ll_cb.l2c.p_send_fn = (tOBX_SEND_FN *)obx_l2c_snd_msg;
- obx_close_port(port_handle);
- RFCOMM_RemoveServer(port_handle);
- obx_sr_free_scb(p_scbt);
- break;
- }
- }
- }
- break;
- }
- }
-
- return p_scb;
-}
-
-/*******************************************************************************
-**
-** Function obx_sr_proc_l2c_evt
-**
-** Description This is called to process BT_EVT_TO_OBX_SR_L2C_MSG
-** Process server events from L2CAP. Get the associated server control
-** block. If this is a request packet, stop timer. Find the
-** associated API event and save it in server control block
-** (api_evt). Fill the event parameter (param).
-** Call obx_ssm_event() with the associated events.If the associated
-** control block is not found (maybe the target header does not
-** match) or busy, compose a service unavailable response and call
-** obx_l2c_snd_msg().
-** Returns void
-**
-*******************************************************************************/
-void obx_sr_proc_l2c_evt (tOBX_L2C_EVT_MSG *p_msg)
-{
- tOBX_SR_SESS_CB *p_scb = NULL;
- tOBX_L2C_CB *p_lcb;
- BT_HDR *p_pkt=NULL;
- tOBX_RX_HDR *p_rxh;
- UINT8 opcode;
- tOBX_L2C_IND *p_ind;
- tL2CAP_CFG_INFO cfg;
- UINT16 result = L2CAP_CONN_NO_RESOURCES;
-#if (BT_USE_TRACES == TRUE)
- UINT16 len;
-#endif
- tL2CAP_ERTM_INFO ertm_info;
- tBT_UUID bt_uuid = {2, {UUID_PROTOCOL_OBEX}};
- tOBX_EVT_PARAM param;
- tOBX_SR_CB *p_cb;
-
- if (p_msg == NULL || p_msg->p_l2cb == NULL)
- return;
-
- if (p_msg->l2c_evt == OBX_L2C_EVT_CONN_IND)
- {
- memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
- cfg.mtu_present = TRUE;
-
- p_ind = &p_msg->param.conn_ind;
- if ((p_scb = obx_sr_scb_by_psm(p_ind->psm)) != NULL)
- {
- memcpy(p_scb->param.conn.peer_addr, p_ind->bd_addr, BD_ADDR_LEN);
- memcpy(p_scb->peer_addr, p_ind->bd_addr, BD_ADDR_LEN);
- result = L2CAP_CONN_OK;
- p_lcb = &p_scb->ll_cb.l2c;
- cfg.mtu = p_lcb->rx_mtu;
-
- cfg.fcr_present = TRUE;
- cfg.fcr = obx_l2c_fcr_opts_def;
- }
- /* else no control channel yet, reject */
-
- /* Set the FCR options: */
- ertm_info.preferred_mode = obx_l2c_fcr_opts_def.mode;
- ertm_info.allowed_modes = L2CAP_FCR_CHAN_OPT_ERTM;
- ertm_info.user_rx_pool_id = OBX_USER_RX_POOL_ID;
- ertm_info.user_tx_pool_id = OBX_USER_TX_POOL_ID;
- ertm_info.fcr_rx_pool_id = OBX_FCR_RX_POOL_ID;
- ertm_info.fcr_tx_pool_id = OBX_FCR_TX_POOL_ID;
-
- /* Send L2CAP connect rsp */
- L2CA_CONNECT_RSP(p_ind->bd_addr, p_ind->id, p_ind->lcid, result, 0, &ertm_info, &bt_uuid);
-
- /* if result ok, proceed with connection */
- if (result == L2CAP_CONN_OK)
- {
- /* store LCID */
- p_lcb->lcid = p_ind->lcid;
- obx_cb.l2c_map[p_ind->lcid - L2CAP_BASE_APPL_CID] = p_lcb->handle;
- OBX_TRACE_DEBUG2("l2c_map[%d]=0x%x",p_ind->lcid - L2CAP_BASE_APPL_CID, p_lcb->handle );
-
- /* transition to configuration state */
- p_lcb->ch_state = OBX_CH_CFG;
- p_lcb->ch_flags = OBX_L2C_SECURITY_DONE;
-
- /* Send L2CAP config req */
- L2CA_CONFIG_REQ(p_ind->lcid, &cfg);
- }
- return;
- }
-
- p_lcb = p_msg->p_l2cb;
- p_scb = obx_lcb_2_sr_sess_cb(p_lcb);
- if (p_scb == NULL)
- return;
-
- switch (p_msg->l2c_evt)
- {
- case OBX_L2C_EVT_RESUME:
- p_cb = &obx_cb.server[p_scb->handle - 1];
- param.ssn = p_scb->ssn;
- (p_cb->p_cback) (p_scb->ll_cb.comm.handle, OBX_GET_REQ_EVT, param, p_pkt);
- break;
-
- case OBX_L2C_EVT_CONG:
- p_lcb->cong = p_msg->param.is_cong;
- obx_ssm_event (p_scb, OBX_FCS_SET_SEVT, NULL);
- break;
-
- case OBX_L2C_EVT_CLOSE:
- obx_ssm_event (p_scb, OBX_PORT_CLOSE_SEVT, NULL);
- break;
-
- case OBX_L2C_EVT_DATA_IND:
- p_pkt = p_msg->param.p_pkt;
- OBX_TRACE_DEBUG2("obx_sr_proc_l2c_evt len:%d, offset:%d", p_pkt->len, p_pkt->offset );
-#if (BT_USE_TRACES == TRUE)
- len = p_pkt->len;
- if (len > 0x20)
- len = 0x20;
- obxu_dump_hex ((UINT8 *)(p_pkt + 1) + p_pkt->offset, "rsp evt", len);
-#endif
- p_rxh = (tOBX_RX_HDR *)(p_pkt + 1);
- opcode = *((UINT8 *)(p_pkt + 1) + p_pkt->offset);
- memset(p_rxh, 0, sizeof(tOBX_RX_HDR));
- if (obx_verify_request (opcode, p_rxh) == OBX_BAD_SM_EVT)
- {
- OBX_TRACE_ERROR1("bad opcode:0x%x disconnect now", opcode );
- GKI_freebuf(p_pkt);
- /* coverity [overrun-call] */
- obx_ssm_event(p_scb, OBX_TX_EMPTY_SEVT, NULL);
- return;
- }
- p_pkt->event = obx_sm_evt_to_api_evt[p_rxh->sm_evt];
- p_pkt->layer_specific = GKI_get_buf_size(p_pkt) - BT_HDR_SIZE - p_pkt->offset - p_pkt->len;
- OBX_TRACE_DEBUG3("opcode:0x%x event:%d sm_evt:%d", opcode, p_pkt->event, p_rxh->sm_evt );
- if (p_pkt->event != OBX_BAD_SM_EVT)
- {
- if (GKI_queue_is_empty(&p_lcb->rx_q) && (p_scb->srm & OBX_SRM_WAIT_UL) == 0)
- {
- obx_sr_proc_pkt (p_scb, p_pkt);
- }
- else
- {
- GKI_enqueue (&p_lcb->rx_q, p_pkt);
- if (p_lcb->rx_q.count > obx_cb.max_rx_qcount)
- {
- p_lcb->stopped = TRUE;
- L2CA_FlowControl(p_lcb->lcid, FALSE);
- }
- OBX_TRACE_DEBUG4 ("obx_sr_proc_l2c_evt stopped:%d state:%d rx_q.count:%d, srm:0x%x",
- p_lcb->stopped, p_scb->state, p_lcb->rx_q.count, p_scb->srm );
- }
- }
- else
- {
- OBX_TRACE_ERROR0("bad SM event" );
- }
- break;
- }
-}
-
-/*******************************************************************************
-**
-** Function obx_l2c_sr_register
-**
-** Description register the PSM to L2CAP.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-tOBX_STATUS obx_l2c_sr_register (tOBX_SR_CB *p_cb)
-{
- tOBX_STATUS status = OBX_NO_RESOURCES;
-
- if (L2CA_REGISTER (p_cb->psm, &obx_l2c_sr_appl, AMP_AUTOSWITCH_ALLOWED|AMP_USE_AMP_IF_POSSIBLE))
- {
- status = OBX_SUCCESS;
- }
- return status;
-}
-#endif
-
-#if (OBX_SERVER_INCLUDED == TRUE)
-
-/*******************************************************************************
-**
-** Function obx_lcb_2_sr_sess_cb
-**
-** Description Find the client control block for the given l2cap session.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-tOBX_SR_SESS_CB * obx_lcb_2_sr_sess_cb(tOBX_L2C_CB *p_lcb)
-{
- UINT32 xx, yy;
- tOBX_SR_CB *p_cb;
- tOBX_SR_SESS_CB *p_scb = NULL;
-
- for (xx=0; xx<obx_cb.num_server; xx++)
- {
- if (obx_cb.server[xx].num_sess)
- {
- p_cb = &obx_cb.server[xx];
- for (yy=0; yy<p_cb->num_sess; yy++)
- {
- if (&(obx_cb.sr_sess[p_cb->sess[yy]-1].ll_cb.l2c) == p_lcb)
- {
- p_scb = &(obx_cb.sr_sess[p_cb->sess[yy]-1]);
- break;
- }
- }
-
- if (p_scb)
- break;
- }
- }
- return p_scb;
-}
-#endif
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function obx_lcb_2_clcb
-**
-** Description Find the client control block for the given l2cap session.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-tOBX_CL_CB * obx_lcb_2_clcb(tOBX_L2C_CB *p_lcb)
-{
- UINT32 xx;
- tOBX_CL_CB *p_cl_cb = NULL;
-
- for (xx=0; xx<obx_cb.num_client; xx++)
- {
- if (&obx_cb.client[xx].ll_cb.l2c == p_lcb)
- {
- p_cl_cb = &obx_cb.client[xx];
- break;
- }
- }
- return p_cl_cb;
-}
-#endif
-
-/*******************************************************************************
-**
-** Function obx_lcid_2lcb
-**
-** Description Given a lcid, return the associated client or server
-** control block.
-**
-** Returns
-**
-*******************************************************************************/
-tOBX_L2C_CB * obx_lcid_2lcb(UINT16 lcid)
-{
- tOBX_L2C_CB *p_lcb = NULL;
- tOBX_HANDLE obx_handle = 0;
-#if (OBX_SERVER_INCLUDED == TRUE)
- tOBX_SR_CB *p_cb;
-#endif
- tOBX_HANDLE obx_mskd_handle;
-
- /* this function is called by obx_rfc_cback() only.
- * assume that port_handle is within range */
- obx_handle = obx_cb.l2c_map[lcid-L2CAP_BASE_APPL_CID];
- obx_mskd_handle = obx_handle&OBX_HANDLE_MASK;
- OBX_TRACE_DEBUG3("obx_lcid_2lcb lcid:0x%x obx_handle:0x%x obx_mskd_handle:0x%x",
- lcid, obx_handle, obx_mskd_handle);
-
- if (obx_handle > 0)
- {
- if (obx_mskd_handle & OBX_CL_HANDLE_MASK)
- {
-#if (OBX_CLIENT_INCLUDED == TRUE)
- obx_mskd_handle &= ~OBX_CL_HANDLE_MASK;
- p_lcb = &obx_cb.client[obx_mskd_handle - 1].ll_cb.l2c;
-#endif /* OBX_CLIENT_INCLUDED */
- }
- else if (obx_mskd_handle < OBX_NUM_SERVERS)
- {
-#if (OBX_SERVER_INCLUDED == TRUE)
- p_cb = &obx_cb.server[obx_mskd_handle - 1];
- p_lcb = &obx_cb.sr_sess[p_cb->sess[OBX_DEC_SESS_IND(obx_handle)]-1].ll_cb.l2c;
- OBX_TRACE_DEBUG3("p_lcb lcid:0x%x sess_ind:%d, sr_sess[%d]",
- p_lcb->lcid, OBX_DEC_SESS_IND(obx_handle), p_cb->sess[OBX_DEC_SESS_IND(obx_handle)]-1);
-#endif /* OBX_SERVER_INCLUDED */
- }
- }
-
- return p_lcb;
-}
-
-/*******************************************************************************
-**
-** Function obx_l2c_checks_ch_flags
-**
-** Description This function processes the L2CAP configuration indication
-** event.
-**
-** Returns void
-**
-*******************************************************************************/
-static void obx_l2c_checks_ch_flags (tOBX_L2C_CB *p_lcb)
-{
- tOBX_L2C_EVT_PARAM evt_param;
-
- OBX_TRACE_DEBUG1 ("obx_l2c_checks_ch_flags ch_flags:0x%x ", p_lcb->ch_flags);
- /* if all the required ch_flags are set, report the OPEN event now */
- if ((p_lcb->ch_flags & OBX_L2C_CONN_RQS_DONE) == OBX_L2C_CONN_RQS_DONE)
- {
- p_lcb->ch_state = OBX_CH_OPEN;
- obx_start_timer((tOBX_COMM_CB *)p_lcb);
- evt_param.is_cong = FALSE;
- obx_l2c_snd_evt (p_lcb, evt_param, OBX_L2C_EVT_CONG);
- }
-}
-
-/*******************************************************************************
-**
-** Function obx_l2c_connect_ind_cback
-**
-** Description This is the L2CAP connect indication callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-#if (OBX_SERVER_INCLUDED == TRUE)
-void obx_l2c_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id)
-{
- tOBX_L2C_EVT_PARAM evt_param;
-
- obx_cb.sr_l2cb.handle = 0; /* to mark as server event */
- memcpy( evt_param.conn_ind.bd_addr, bd_addr, BD_ADDR_LEN);
- evt_param.conn_ind.lcid = lcid;
- evt_param.conn_ind.psm = psm;
- evt_param.conn_ind.id = id;
- obx_l2c_snd_evt (&obx_cb.sr_l2cb, evt_param, OBX_L2C_EVT_CONN_IND);
-}
-#endif /* OBX_SERVER_INCLUDED */
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function obx_cl_proc_l2c_evt
-**
-** Description This is called to process BT_EVT_TO_OBX_CL_L2C_MSG
-** Process client events from L2CAP. Get the associated client control
-** block. If this is a response packet, stop timer. Call
-** obx_csm_event() with event OK_CFM, FAIL_CFM or CONT_CFM.
-** Returns void
-**
-*******************************************************************************/
-void obx_cl_proc_l2c_evt (tOBX_L2C_EVT_MSG *p_msg)
-{
- tOBX_CL_CB *p_cl_cb = NULL;
- tOBX_L2C_CB *p_l2cb;
- BT_HDR *p_pkt;
- tOBX_RX_HDR *p_rxh;
- UINT8 opcode;
-
- if (p_msg == NULL || p_msg->p_l2cb == NULL)
- return;
-
- p_l2cb = p_msg->p_l2cb;
- p_cl_cb = obx_lcb_2_clcb(p_l2cb);
- if (p_cl_cb == NULL)
- return;
-
- switch (p_msg->l2c_evt)
- {
- case OBX_L2C_EVT_CONG:
- p_msg->p_l2cb->cong = p_msg->param.is_cong;
- obx_csm_event (p_cl_cb, OBX_FCS_SET_CEVT, NULL);
- break;
-
- case OBX_L2C_EVT_CLOSE:
- obx_csm_event (p_cl_cb, OBX_PORT_CLOSE_CEVT, NULL);
- break;
-
- case OBX_L2C_EVT_DATA_IND:
- p_pkt = p_msg->param.p_pkt;
- p_rxh = (tOBX_RX_HDR *)(p_pkt + 1);
- opcode = *((UINT8 *)(p_pkt + 1) + p_pkt->offset);
- memset(p_rxh, 0, sizeof(tOBX_RX_HDR));
- obx_verify_response (opcode, p_rxh);
-
- OBX_TRACE_DEBUG4 ("obx_cl_proc_l2c_evt event:0x%x/0x%x state:%d srm:0x%x", p_pkt->event, p_rxh->sm_evt, p_cl_cb->state, p_cl_cb->srm );
- if (p_rxh->sm_evt != OBX_BAD_SM_EVT)
- {
- if (GKI_queue_is_empty(&p_l2cb->rx_q) && (p_cl_cb->srm & OBX_SRM_WAIT_UL) == 0)
- {
- obx_cl_proc_pkt (p_cl_cb, p_pkt);
- }
- else
- {
- GKI_enqueue (&p_l2cb->rx_q, p_pkt);
- if (p_l2cb->rx_q.count > obx_cb.max_rx_qcount)
- {
- p_l2cb->stopped = TRUE;
- L2CA_FlowControl(p_l2cb->lcid, FALSE);
- }
- OBX_TRACE_DEBUG3 ("obx_cl_proc_l2c_evt rx_q.count:%d, stopped:%d state:%d", p_l2cb->rx_q.count, p_l2cb->stopped, p_cl_cb->state );
- }
- }
- else
- {
- OBX_TRACE_ERROR0("bad SM event" );
- }
- break;
-
- }
-}
-
-/*******************************************************************************
-**
-** Function obx_l2c_sec_check_complete
-**
-** Description The function called when Security Manager finishes
-** verification of the service side connection
-**
-** Returns void
-**
-*******************************************************************************/
-static void obx_l2c_sec_check_complete (BD_ADDR bd_addr, void *p_ref_data, UINT8 res)
-{
- tOBX_L2C_CB *p_lcb = (tOBX_L2C_CB *)p_ref_data;
-
- OBX_TRACE_DEBUG3 ("obx_l2c_sec_check_complete ch_state:%d, ch_flags:0x%x, status:%d",
- p_lcb->ch_state, p_lcb->ch_flags, res);
- if (p_lcb->ch_state == OBX_CH_IDLE)
- return;
-
- if (res == BTM_SUCCESS)
- {
- p_lcb->ch_flags |= OBX_L2C_SECURITY_DONE;
- obx_l2c_checks_ch_flags (p_lcb);
- }
- else
- {
- /* security failed - disconnect the channel */
- L2CA_DISCONNECT_REQ (p_lcb->lcid);
- }
-}
-
-/*******************************************************************************
-**
-** Function obx_l2c_connect_cfm_cback
-**
-** Description This is the L2CAP connect confirm callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_l2c_connect_cfm_cback(UINT16 lcid, UINT16 result)
-{
- tOBX_L2C_CB *p_lcb;
- tL2CAP_CFG_INFO cfg;
- tOBX_L2C_EVT_PARAM evt_param;
- tOBX_CL_CB *p_cl_cb = NULL;
-
- /* look up lcb for this channel */
- if ((p_lcb = obx_lcid_2lcb(lcid)) != NULL)
- {
- OBX_TRACE_DEBUG1("obx_l2c_connect_cfm_cback ch_state:%d", p_lcb->ch_state);
- /* if in correct state */
- if (p_lcb->ch_state == OBX_CH_CONN)
- {
- /* if result successful */
- if (result == L2CAP_CONN_OK)
- {
- /* set channel state */
- p_lcb->ch_state = OBX_CH_CFG;
-
- p_cl_cb = obx_lcb_2_clcb(p_lcb);
- btm_sec_mx_access_request (p_cl_cb->peer_addr, p_cl_cb->psm, TRUE,
- 0, 0, &obx_l2c_sec_check_complete, p_lcb);
-
- /* Send L2CAP config req */
- memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
-
- cfg.mtu_present = TRUE;
- cfg.mtu = p_lcb->rx_mtu;
-
- cfg.fcr_present = TRUE;
- cfg.fcr = obx_l2c_fcr_opts_def;
-
- L2CA_CONFIG_REQ(lcid, &cfg);
- }
- /* else failure */
- else
- {
- evt_param.any = 0;
- obx_l2c_snd_evt (p_lcb, evt_param, OBX_L2C_EVT_CLOSE);
- }
- }
- }
-}
-#endif /* OBX_CLIENT_INCLUDED */
-
-
-/*******************************************************************************
-**
-** Function obx_l2c_config_cfm_cback
-**
-** Description This is the L2CAP config confirm callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_l2c_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
-{
- tOBX_L2C_CB *p_lcb;
-
- /* look up lcb for this channel */
- if ((p_lcb = obx_lcid_2lcb(lcid)) != NULL)
- {
- /* if in correct state */
- if (p_lcb->ch_state == OBX_CH_CFG)
- {
- /* if result successful */
- if (p_cfg->result == L2CAP_CFG_OK)
- {
- /* update flags */
- p_lcb->ch_flags |= OBX_L2C_CFG_CFM_DONE;
-
- /* if configuration complete */
- obx_l2c_checks_ch_flags(p_lcb);
- }
- /* else failure */
- else
- {
- /* store result value
- p_lcb->ch_result = p_cfg->result; */
-
- /* Send L2CAP disconnect req */
- L2CA_DISCONNECT_REQ(lcid);
- }
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function obx_l2c_config_ind_cback
-**
-** Description This is the L2CAP config indication callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_l2c_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
-{
- tOBX_L2C_CB *p_lcb;
- UINT16 max_mtu = OBX_MAX_MTU;
-
- /* Don't include QoS nor flush timeout in the response since we
- currently always accept these values. Note: fcr_present is left
- untouched since l2cap negotiates this internally
- */
- p_cfg->flush_to_present = FALSE;
- p_cfg->qos_present = FALSE;
-
- /* look up lcb for this channel */
- if ((p_lcb = obx_lcid_2lcb(lcid)) != NULL)
- {
- /* store the mtu in tbl */
- if (p_cfg->mtu_present)
- {
- p_lcb->tx_mtu = p_cfg->mtu;
- }
- else
- {
- p_lcb->tx_mtu = L2CAP_DEFAULT_MTU;
- }
-
- if (p_lcb->tx_mtu > max_mtu)
- {
- p_lcb->tx_mtu = p_cfg->mtu = max_mtu;
-
- /* Must tell the peer what the adjusted value is */
- p_cfg->mtu_present = TRUE;
- }
- else /* Don't include in the response */
- p_cfg->mtu_present = FALSE;
- OBX_TRACE_DEBUG2 ("obx_l2c_config_ind_cback tx_mtu:%d use:%d", p_lcb->tx_mtu, max_mtu);
-
- p_cfg->result = L2CAP_CFG_OK;
-
- /* send L2CAP configure response */
- L2CA_CONFIG_RSP(lcid, p_cfg);
-
- if (p_cfg->result != L2CAP_CFG_OK)
- {
- return;
- }
-
- /* if first config ind */
- if ((p_lcb->ch_flags & OBX_L2C_CFG_IND_DONE) == 0)
- {
- /* update flags */
- p_lcb->ch_flags |= OBX_L2C_CFG_IND_DONE;
-
- /* if configuration complete */
- obx_l2c_checks_ch_flags(p_lcb);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function obx_l2c_disconnect_ind_cback
-**
-** Description This is the L2CAP disconnect indication callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_l2c_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
-{
- tOBX_L2C_CB *p_lcb;
- tOBX_L2C_EVT_PARAM evt_param;
-
- /* look up lcb for this channel */
- if ((p_lcb = obx_lcid_2lcb(lcid)) != NULL)
- {
- if (ack_needed)
- {
- /* send L2CAP disconnect response */
- L2CA_DISCONNECT_RSP(lcid);
- }
-
- evt_param.any = 0;
- obx_l2c_snd_evt (p_lcb, evt_param, OBX_L2C_EVT_CLOSE);
- }
-}
-
-/*******************************************************************************
-**
-** Function obx_l2c_disconnect_cfm_cback
-**
-** Description This is the L2CAP disconnect confirm callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_l2c_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
-{
- tOBX_L2C_CB *p_lcb;
- tOBX_L2C_EVT_PARAM evt_param;
-
- /* look up lcb for this channel */
- if ((p_lcb = obx_lcid_2lcb(lcid)) != NULL)
- {
- evt_param.any = 0;
- obx_l2c_snd_evt (p_lcb, evt_param, OBX_L2C_EVT_CLOSE);
- }
-}
-
-/*******************************************************************************
-**
-** Function obx_l2c_data_ind_cback
-**
-** Description This is the L2CAP data indication callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_l2c_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
-{
- tOBX_L2C_CB *p_lcb;
- tOBX_L2C_EVT_PARAM evt_param;
-#if (BT_USE_TRACES == TRUE)
- UINT16 len;
-#endif
-
- /* look up lcb for this channel */
- if ((p_lcb = obx_lcid_2lcb(lcid)) != NULL)
- {
- evt_param.p_pkt = p_buf;
- OBX_TRACE_DEBUG3("obx_l2c_data_ind_cback 0x%x, len:%d, offset:%d", p_buf, p_buf->len, p_buf->offset );
-#if (BT_USE_TRACES == TRUE)
- len = p_buf->len;
- if (len > 0x20)
- len = 0x20;
- obxu_dump_hex ((UINT8 *)(p_buf + 1) + p_buf->offset, "rsp cback", len);
-#endif
- obx_l2c_snd_evt (p_lcb, evt_param, OBX_L2C_EVT_DATA_IND);
- }
- else /* prevent buffer leak */
- GKI_freebuf(p_buf);
-}
-
-
-/*******************************************************************************
-**
-** Function obx_l2c_congestion_ind_cback
-**
-** Description This is the L2CAP congestion indication callback function.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_l2c_congestion_ind_cback(UINT16 lcid, BOOLEAN is_congested)
-{
- tOBX_L2C_CB *p_lcb;
- tOBX_L2C_EVT_PARAM evt_param;
-
- OBX_TRACE_DEBUG2("obx_l2c_congestion_ind_cback lcid:%d, is_congested:%d",lcid, is_congested );
- /* look up lcb for this channel */
- if ((p_lcb = obx_lcid_2lcb(lcid)) != NULL)
- {
- evt_param.is_cong = is_congested;
- obx_l2c_snd_evt (p_lcb, evt_param, OBX_L2C_EVT_CONG);
- }
-}
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
-/*******************************************************************************
-** Function obx_register_l2c
-** Description Call L2CA_Register() to get virtual psm.
-** Returns
-*******************************************************************************/
-void obx_register_l2c(tOBX_CL_CB *p_cl_cb, UINT16 psm)
-{
- p_cl_cb->psm = L2CA_REGISTER (psm, &obx_l2c_cl_appl, AMP_AUTOSWITCH_ALLOWED|AMP_USE_AMP_IF_POSSIBLE);
-}
-
-/*******************************************************************************
-** Function obx_open_l2c
-** Description Call L2CA_Register() & L2CA_ConnectReq() to get lcid.
-** Returns port handle
-*******************************************************************************/
-tOBX_STATUS obx_open_l2c(tOBX_CL_CB *p_cl_cb, const BD_ADDR bd_addr)
-{
- tOBX_L2C_CB *p_l2cb = &p_cl_cb->ll_cb.l2c;
- tOBX_STATUS status = OBX_NO_RESOURCES; /* successful */
- UINT16 max_mtu = OBX_MAX_MTU;
- tL2CAP_CFG_INFO cfg;
- tL2CAP_ERTM_INFO ertm_info;
- tBT_UUID bt_uuid = {2, {UUID_PROTOCOL_OBEX}};
-
- OBX_TRACE_DEBUG2("obx_open_l2c rxmtu:%d, cbmtu:%d", p_l2cb->rx_mtu, max_mtu );
-
- /* clear buffers from previous connection */
- obx_free_buf(&p_cl_cb->ll_cb);
-
- /* make sure the MTU is in registered range */
- if (p_l2cb->rx_mtu > max_mtu)
- p_l2cb->rx_mtu = max_mtu;
- if (p_l2cb->rx_mtu < OBX_MIN_MTU)
- p_l2cb->rx_mtu = OBX_MIN_MTU;
-
- if (p_cl_cb->psm)
- {
- memcpy (p_cl_cb->peer_addr, bd_addr, BD_ADDR_LEN);
-
- /* Set the FCR options: */
- ertm_info.preferred_mode = obx_l2c_fcr_opts_def.mode;
- ertm_info.allowed_modes = L2CAP_FCR_CHAN_OPT_ERTM;
- ertm_info.user_rx_pool_id = OBX_USER_RX_POOL_ID;
- ertm_info.user_tx_pool_id = OBX_USER_TX_POOL_ID;
- ertm_info.fcr_rx_pool_id = OBX_FCR_RX_POOL_ID;
- ertm_info.fcr_tx_pool_id = OBX_FCR_TX_POOL_ID;
-
- p_l2cb->lcid = L2CA_CONNECT_REQ (p_cl_cb->psm, (BD_ADDR_PTR)bd_addr, &ertm_info, &bt_uuid);
- if (p_l2cb->lcid)
- {
- p_l2cb->ch_state = OBX_CH_CONN;
- p_l2cb->ch_flags = 0;
- p_l2cb->cong = TRUE;
- memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
- cfg.fcr_present = TRUE;
- cfg.fcr = obx_l2c_fcr_opts_def;
- status = OBX_SUCCESS;
- }
- }
-
- OBX_TRACE_DEBUG3("obx_open_l2c rxmtu:%d, lcid:%d, l2c.handle:0x%x",
- p_l2cb->rx_mtu, p_l2cb->lcid, p_l2cb->handle );
-
- if (status == OBX_SUCCESS)
- {
- obx_cb.l2c_map[p_l2cb->lcid - L2CAP_BASE_APPL_CID] = p_l2cb->handle;
- p_l2cb->p_send_fn = (tOBX_SEND_FN *)obx_l2c_snd_msg;
- p_l2cb->p_close_fn = obx_close_l2c;
- }
- else
- {
- status = OBX_NO_RESOURCES;
- }
-
- return status;
-}
-#endif
-
-/*******************************************************************************
-**
-** Function obx_close_l2c
-** Description Clear the port event mask and callback. Close the port.
-** Returns void
-*******************************************************************************/
-void obx_close_l2c(UINT16 lcid)
-{
- L2CA_DISCONNECT_REQ (lcid);
-}
-
-/*******************************************************************************
-** Function obx_l2c_snd_msg
-** Description Call PORT_WriteData() to send an OBEX message to peer. If
-** all data is sent, free the GKI buffer that holds
-** the OBEX message. If only portion of data is
-** sent, adjust the BT_HDR for PART state.
-** Returns TRUE if all data is sent
-*******************************************************************************/
-BOOLEAN obx_l2c_snd_msg(tOBX_L2C_CB *p_l2cb)
-{
- BOOLEAN sent = FALSE;
-
- if (!p_l2cb->cong)
- {
- OBX_TRACE_DEBUG2("obx_l2c_snd_msg len:%d, offset:0x%x", p_l2cb->p_txmsg->len, p_l2cb->p_txmsg->offset);
-
- obx_stop_timer(&p_l2cb->tle);
- if (L2CA_DATA_WRITE (p_l2cb->lcid, p_l2cb->p_txmsg) == L2CAP_DW_CONGESTED)
- {
- OBX_TRACE_DEBUG0("obx_l2c_snd_msg congested");
- p_l2cb->cong = TRUE;
- }
- obx_start_timer ((tOBX_COMM_CB *)p_l2cb);
- p_l2cb->p_txmsg = NULL;
- sent = TRUE;
- }
-
- return sent;
-}
diff --git a/stack/obx/obx_main.c b/stack/obx/obx_main.c
deleted file mode 100644
index 7dc7c97..0000000
--- a/stack/obx/obx_main.c
+++ /dev/null
@@ -1,946 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_main.c
-**
-** File: OBEX common API and interface to other Bluetooth modules
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "bt_target.h"
-#include "obx_int.h"
-#include "btu.h" /* for timer */
-#include "l2c_api.h"
-#include "l2cdefs.h"
-
-#if (defined (BT_USE_TRACES) && BT_USE_TRACES == TRUE)
-const char * const obx_cl_state_name [] =
-{
- "NULL",
- "NOT_CONN",
- "SESS_RS",
- "CONN_RS",
- "UNAUTH",
- "CONN",
- "DISCNT_RS",
- "OP_UNAUTH",
- "SETPATH_RS",
- "ACT_RS",
- "ABORT_RS",
- "PUT_RS",
- "GET_RS",
- "PUT",
- "GET",
- "PUT_S",
- "GET_S",
- "PART",
- "Unknown"
-};
-
-const char * const obx_cl_event_name [] =
-{
- "CONN_R",
- "SESS_R",
- "DISCNT_R",
- "PUT_R",
- "GET_R",
- "SETPATH_R",
- "ACT_R",
- "ABORT_R",
- "OK_C",
- "CONT_C",
- "FAIL_C",
- "PORT_CLS",
- "TX_EMPTY",
- "FCS_SET",
- "STATE",
- "TIMEOUT",
- "Unknown"
-};
-
-const char * const obx_sr_state_name [] =
-{
- "NULL",
- "NOT_CONN",
- "SESS_I",
- "CONN_I",
- "WAIT_AUTH",
- "AUTH_I",
- "CONN",
- "DISCNT_I",
- "SETPATH_I",
- "ACT_I",
- "ABORT_I",
- "PUT_I",
- "GET_I",
- "PUT",
- "GET",
- "PUT_S",
- "GET_S",
- "PART",
- "WAIT_CLS",
- "Unknown"
-};
-
-const char * const obx_sr_event_name [] =
-{
- "CONN_R",
- "SESS_R",
- "DISCNT_R",
- "PUT_R",
- "GET_R",
- "SETPATH_R",
- "ACT_R",
- "ABORT_R",
- "CONN_C",
- "SESS_C",
- "DISCNT_C",
- "PUT_C",
- "GET_C",
- "SETPATH_C",
- "ACT_C",
- "ABORT_C",
- "PORT_CLS",
- "FCS_SET",
- "STATE",
- "TIMEOUT",
- "BAD_REQ",
- "TX_EMPTY",
- "Unknown"
-};
-#endif
-
-#if OBX_DYNAMIC_MEMORY == FALSE
-OBX_API tOBX_CB obx_cb;
-#endif
-
-
-#if (defined (BT_USE_TRACES) && BT_USE_TRACES == TRUE)
-#if (OBX_CLIENT_INCLUDED == TRUE)
-/*******************************************************************************
-** Function obx_cl_get_state_name
-** Returns The client state name.
-*******************************************************************************/
-const char *obx_cl_get_state_name(tOBX_CL_STATE state)
-{
- const char * p_str = obx_cl_state_name[OBX_CS_MAX];
- if (state < OBX_CS_MAX)
- {
- p_str = obx_cl_state_name[state];
- }
- return p_str;
-}
-
-/*******************************************************************************
-** Function obx_cl_get_event_name
-** Returns The client event name.
-*******************************************************************************/
-const char *obx_cl_get_event_name(tOBX_CL_EVENT event)
-{
- const char * p_str = obx_cl_event_name[OBX_MAX_CEVT];
- if (event < OBX_MAX_CEVT)
- {
- p_str = obx_cl_event_name[event];
- }
- return p_str;
-}
-#endif
-
-#if (OBX_SERVER_INCLUDED == TRUE)
-/*******************************************************************************
-** Function obx_sr_get_state_name
-** Returns The server state name.
-*******************************************************************************/
-const char *obx_sr_get_state_name(tOBX_SR_STATE state)
-{
- const char * p_str = obx_sr_state_name[OBX_SS_MAX];
- if (state < OBX_SS_MAX)
- {
- p_str = obx_sr_state_name[state];
- }
- return p_str;
-}
-
-/*******************************************************************************
-** Function obx_sr_get_event_name
-** Returns The server event name.
-*******************************************************************************/
-const char *obx_sr_get_event_name(tOBX_SR_EVENT event)
-{
- const char * p_str = obx_sr_event_name[OBX_MAX_SEVT];
- if (event < OBX_MAX_SEVT)
- {
- p_str = obx_sr_event_name[event];
- }
- return p_str;
-}
-#endif
-#endif
-
-/*******************************************************************************
-** Function obx_start_timer
-** Description start BTU timer.
-*******************************************************************************/
-void obx_start_timer(tOBX_COMM_CB *p_pcb)
-{
- UINT16 type = 0;
- UINT32 timeout = obx_cb.timeout_val;
-
- if (timeout)
- {
- if (p_pcb->handle & OBX_CL_HANDLE_MASK)
- {
- if (p_pcb->p_txmsg && p_pcb->p_txmsg->event == OBX_DISCONNECT_REQ_EVT)
- {
- timeout = OBX_DISC_TOUT_VALUE;
- }
- type = BTU_TTYPE_OBX_CLIENT_TO;
- }
- else
- {
- if (p_pcb->p_txmsg && p_pcb->p_txmsg->event == (OBX_DISCNT_CFM_SEVT + 1))
- {
- timeout = OBX_DISC_TOUT_VALUE;
- }
- type = BTU_TTYPE_OBX_SERVER_TO;
- }
- btu_start_timer(&p_pcb->tle, type, timeout);
- }
- OBX_TRACE_DEBUG3("obx_start_timer type: %d, val:%d, p_tle:0x%x", type, timeout, &p_pcb->tle);
-}
-
-/*******************************************************************************
-** Function obx_stop_timer
-** Description Stop BTU timer
-*******************************************************************************/
-void obx_stop_timer(TIMER_LIST_ENT *p_tle)
-{
- btu_stop_timer(p_tle);
- OBX_TRACE_DEBUG1("obx_stop_timer p_tle:0x%x", p_tle);
-}
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
-/*******************************************************************************
-** Function obx_cl_timeout
-** Description Get client control block from timer param. Start BTU timer again.
-** Call application callback routine with OBX_TIMEOUT_EVT event.
-*******************************************************************************/
-void obx_cl_timeout(TIMER_LIST_ENT *p_tle)
-{
- tOBX_CL_CB *p_cb = (tOBX_CL_CB *) p_tle->param;
- tOBX_EVT_PARAM evtp;
- tOBX_HANDLE handle = p_cb->ll_cb.comm.handle;
- tOBX_CL_CBACK *p_cback = p_cb->p_cback;
-
- memset(&evtp, 0, sizeof(tOBX_EVT_PARAM));
- if (obx_cb.timeout_val)
- btu_start_timer(p_tle, BTU_TTYPE_OBX_CLIENT_TO, obx_cb.timeout_val);
- obx_csm_event(p_cb, OBX_TIMEOUT_CEVT, NULL);
- (*p_cback) (handle, OBX_TIMEOUT_EVT, OBX_RSP_DEFAULT, evtp, NULL);
-}
-
-/*******************************************************************************
-**
-** Function obx_cl_alloc_cb
-**
-** Description allocate a client control block.
-**
-*******************************************************************************/
-tOBX_CL_CB *obx_cl_alloc_cb(void)
-{
- int xx, yy;
- tOBX_CL_CB *p_cb = NULL;
-
- /* allocate a client control block */
- for (xx=0, yy=obx_cb.next_ind; xx<obx_cb.num_client; xx++, yy++)
- {
- if (yy >= obx_cb.num_client)
- yy = 0;
- p_cb = &obx_cb.client[yy];
-
- if (p_cb->ll_cb.comm.handle == OBX_HANDLE_NULL)
- {
- p_cb->ll_cb.comm.handle = OBX_CL_HANDLE_MASK | (yy + 1);
- obx_cb.next_ind = yy+1; /* it will be adjusted, so we do not need to check the range now */
- OBX_TRACE_DEBUG3("obx_cl_alloc_cb obx handle:0x%x, yy:%d, next: %d",
- p_cb->ll_cb.comm.handle, yy, obx_cb.next_ind);
- p_cb->ll_cb.comm.tx_mtu = 0;
- p_cb->conn_id = OBX_INVALID_CONN_ID;
-
- p_cb->ll_cb.comm.tle.param = (UINT32)p_cb;
- p_cb->psm = 0;
- p_cb->srm = 0;
- break;
- }
- }
-
- if (xx == obx_cb.num_client)
- p_cb = NULL;
- return p_cb;
-}
-
-/*******************************************************************************
-**
-** Function obx_cl_get_cb
-**
-** Description Returns the pointer to the client control block with given handle.
-**
-*******************************************************************************/
-tOBX_CL_CB *obx_cl_get_cb(tOBX_HANDLE handle)
-{
- tOBX_CL_CB *p_cb = NULL;
- UINT8 ind = (handle & OBX_CL_CB_IND_MASK);
-
- if (handle & OBX_CL_HANDLE_MASK)
- {
- if (ind <= obx_cb.num_client && ind > 0)
- {
- if (obx_cb.client[--ind].ll_cb.comm.handle == handle)
- p_cb = &obx_cb.client[ind];
- }
- }
-
- return p_cb;
-}
-
-/*******************************************************************************
-**
-** Function obx_cl_get_suspended_cb
-**
-** Description Returns the pointer to the client control block with given handle.
-**
-*******************************************************************************/
-tOBX_CL_CB *obx_cl_get_suspended_cb(tOBX_HANDLE *p_handle, UINT8 *p_session_info)
-{
- tOBX_HANDLE handle = *p_handle;
- tOBX_CL_CB *p_cb = NULL;
- tOBX_CL_CB *p_ccb = NULL;
- UINT8 ind = (handle & OBX_CL_CB_IND_MASK);
-
- OBX_TRACE_DEBUG1("obx_cl_get_suspended_cb handle: 0x%x", handle);
- if (handle & OBX_CL_HANDLE_MASK)
- {
- if (ind <= obx_cb.num_client && ind > 0)
- {
- if (obx_cb.client[--ind].ll_cb.comm.handle == handle)
- {
- p_ccb = &obx_cb.client[ind];
- if (p_ccb->sess_st == OBX_SESS_SUSPENDED &&
- ((p_session_info == p_ccb->sess_info) || (memcmp(p_session_info, p_ccb->sess_info, OBX_SESSION_INFO_SIZE) == 0)))
- {
- OBX_TRACE_DEBUG0("found a suspended session");
- p_cb = p_ccb;
- }
- }
- }
- }
- if (p_cb == NULL) /* if the handle is NULL, assume the system was power cycled. attempt to allocate a control block */
- {
- p_cb = obx_cl_alloc_cb();
- if (p_cb)
- {
- *p_handle = p_cb->ll_cb.comm.handle;
- p_cb->sess_st = OBX_SESS_SUSPENDED;
- memcpy(p_cb->sess_info, p_session_info, OBX_SESSION_INFO_SIZE);
- OBX_TRACE_DEBUG1("allocated a suspended session handle: 0x%x", *p_handle);
- }
- }
-
- return p_cb;
-}
-
-/*******************************************************************************
-**
-** Function obx_cl_free_cb
-**
-** Description Free the given client control block.
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_cl_free_cb(tOBX_CL_CB * p_cb)
-{
- if (p_cb)
- {
- OBX_TRACE_DEBUG2("obx_cl_free_cb id: %d, sess_st:%d", p_cb->ll_cb.comm.id, p_cb->sess_st);
-
- if (p_cb->ll_cb.comm.id>0)
- {
- if (p_cb->ll_cb.comm.p_send_fn == (tOBX_SEND_FN *)obx_rfc_snd_msg)
- obx_cb.hdl_map[p_cb->ll_cb.port.port_handle - 1] = 0;
- else
- obx_cb.l2c_map[p_cb->ll_cb.l2c.lcid - L2CAP_BASE_APPL_CID] = 0;
- }
-
- /* make sure the GKI buffers are freed */
- if (p_cb->p_next_req)
- GKI_freebuf(p_cb->p_next_req);
-
- if (p_cb->p_saved_req)
- GKI_freebuf(p_cb->p_saved_req);
-
- if (p_cb->p_auth)
- GKI_freebuf(p_cb->p_auth);
-
- obx_free_buf (&p_cb->ll_cb);
-
- if (p_cb->psm)
- L2CA_DEREGISTER (p_cb->psm);
-
- /* make sure the timer is stopped */
- btu_stop_timer(&p_cb->ll_cb.comm.tle);
-
- memset(p_cb, 0, sizeof(tOBX_CL_CB) );
- }
-}
-#endif /* OBX_CLIENT_INCLUDED */
-
-#if (OBX_SERVER_INCLUDED == TRUE)
-/*******************************************************************************
-** Function obx_find_suspended_session
-** Description if p_triplet is NULL,
-** check if there's still room for a reliable session
-** else check if the given session is still in the suspended list
-*******************************************************************************/
-tOBX_SPND_CB *obx_find_suspended_session (tOBX_SR_SESS_CB *p_scb, tOBX_TRIPLET *p_triplet, UINT8 num)
-{
- UINT8 ind;
- BOOLEAN found = FALSE;
- BOOLEAN infinite = FALSE;
- UINT8 *p, xx;
- tOBX_SR_CB *p_cb = obx_sr_get_cb(p_scb->handle);
- tOBX_SPND_CB *p_spndcb, *p_ret = NULL;
-
- OBX_TRACE_DEBUG0("obx_find_suspended_session ");
- if (p_triplet == NULL)
- {
- if (p_cb->p_suspend)
- {
- for (xx=0, p_spndcb=p_cb->p_suspend; xx<p_cb->max_suspend; xx++, p_spndcb++)
- {
- if ((p_spndcb->state == OBX_SS_NULL) || (memcmp(p_spndcb->peer_addr, p_scb->peer_addr, BD_ADDR_LEN)==0))
- {
- OBX_TRACE_DEBUG3("[%d] state: %d, BDA: %08x", xx, p_spndcb->state,
- (p_spndcb->peer_addr[2]<<24)+(p_spndcb->peer_addr[3]<<16)+(p_spndcb->peer_addr[4]<<8)+p_spndcb->peer_addr[5]);
- /* this entry is not used yet or overwriting the entry with the same address */
- found = TRUE;
- break;
- }
- else if (p_spndcb->stle.param == 0)
- {
- infinite = TRUE;
- }
- }
- OBX_TRACE_DEBUG2("found: %d infinite:%d", found, infinite);
- if (found == FALSE)
- found = infinite;
- }
- else if (p_cb->max_suspend > 0)
- {
- found = TRUE;
- }
- p_ret = (tOBX_SPND_CB *)p_scb;
- }
- else if (p_cb->p_suspend)
- {
- ind = obx_read_triplet(p_triplet, num, OBX_TAG_SESS_PARAM_SESS_ID);
- if (ind < num && p_triplet[ind].len == OBX_SESSION_ID_SIZE)
- {
- p = p_triplet[ind].p_array;
- for (xx=0, p_spndcb=p_cb->p_suspend; xx<p_cb->max_suspend; xx++, p_spndcb++)
- {
- OBX_TRACE_DEBUG5("[%d] state: %d/%d, ssn:%d offset:x%x", xx, p_spndcb->state,
- p_spndcb->sess_info[OBX_SESSION_INFO_ST_IDX], p_spndcb->ssn, p_spndcb->offset);
- if ((p_spndcb->state != OBX_SS_NULL) &&
- (memcmp (p, p_spndcb->sess_info, OBX_SESSION_ID_SIZE) == 0))
- {
- obxu_dump_hex (p_spndcb->sess_info, "sess info", OBX_SESSION_INFO_SIZE);
- /* prepare p_scb to the proper state for resume */
- p_ret = p_spndcb;
- break;
- }
- }
- }
- }
- return p_ret;
-}
-
-/*******************************************************************************
-** Function obx_sr_sess_timeout
-** Description Get suspended session control block from timer param.
-** mark the suspended session as NULL
-*******************************************************************************/
-void obx_sr_sess_timeout(TIMER_LIST_ENT *p_tle)
-{
- tOBX_SPND_CB *p_spndcb = (tOBX_SPND_CB *) p_tle->param;
-
- OBX_TRACE_DEBUG0("obx_sr_sess_timeout");
- p_spndcb->state = OBX_SS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_sr_timeout
-** Description Get server control block from timer param. Start BTU timer again.
-** Call application callback routine with OBX_TIMEOUT_EVT event.
-*******************************************************************************/
-void obx_sr_timeout(TIMER_LIST_ENT *p_tle)
-{
- tOBX_SR_SESS_CB *p_scb = (tOBX_SR_SESS_CB *) p_tle->param;
- tOBX_EVT_PARAM evtp;
- tOBX_HANDLE handle = p_scb->ll_cb.comm.handle;
- tOBX_SR_CBACK *p_cback;
- tOBX_SR_CB *p_cb;
-
- memset(&evtp, 0, sizeof(tOBX_EVT_PARAM));
- if (obx_cb.timeout_val)
- btu_start_timer(p_tle, BTU_TTYPE_OBX_SERVER_TO, obx_cb.timeout_val);
- p_cb = &obx_cb.server[p_scb->handle - 1];
- p_cback = p_cb->p_cback;
- obx_ssm_event(p_scb, OBX_TIMEOUT_SEVT, NULL);
- (*p_cback) (handle, OBX_TIMEOUT_EVT, evtp, NULL);
-}
-
-/*******************************************************************************
-**
-** Function obx_sr_alloc_cb
-**
-** Description allocate a server control block.
-**
-*******************************************************************************/
-tOBX_HANDLE obx_sr_alloc_cb(tOBX_StartParams *p_params)
-{
- int xx, yy, zz;
- tOBX_SR_CB *p_cb = &obx_cb.server[0];
- tOBX_SR_SESS_CB *p_scb = &obx_cb.sr_sess[0];
- tOBX_HANDLE obx_handle = OBX_HANDLE_NULL;
-
- OBX_TRACE_DEBUG1("obx_sr_alloc_cb num sess: %d", p_params->max_sessions);
- /* allocate a server control block */
- for (xx=0; xx<obx_cb.num_server; xx++, p_cb++)
- {
- if (p_cb->scn == 0 && p_cb->psm == 0)
- {
- obx_handle = xx + 1;
- p_cb->scn = p_params->scn;
- p_cb->psm = p_params->psm;
- break;
- }
- }
-
- if (xx != obx_cb.num_server)
- {
- /* allocate session control blocks */
- zz = 0;
- for (yy=0; yy<obx_cb.num_sr_sess && zz < p_params->max_sessions; yy++, p_scb++)
- {
- if (p_scb->ll_cb.comm.handle == OBX_HANDLE_NULL)
- {
- p_scb->handle = obx_handle;
- if (p_params->get_nonf)
- p_scb->srmp = OBX_SRMP_NONF_EVT;
- p_cb->sess[zz] = yy + 1;
- p_scb->srm = p_params->srm;
- p_scb->ll_cb.comm.handle = OBX_ENC_SESS_HANDLE((obx_handle), zz);
- p_scb->ll_cb.comm.tx_mtu = 0;
- p_scb->ll_cb.comm.tle.param = (UINT32)p_scb;
- OBX_TRACE_DEBUG2("[%d]: 0x%x", zz, p_scb->ll_cb.comm.handle);
- zz++;
- }
- }
-
- if (zz == p_params->max_sessions && L2C_IS_VALID_PSM(p_params->psm))
- {
- if (obx_l2c_sr_register(p_cb) != OBX_SUCCESS)
- {
- OBX_TRACE_ERROR0("Cannot register to L2CAP");
- zz = 0; /* let it fail */
- }
- }
-
- if (zz != p_params->max_sessions)
- {
- OBX_TRACE_ERROR0("not enough resources: release the allocated ones");
- p_cb->scn = 0;
- p_cb->psm = 0;
- obx_handle = OBX_HANDLE_NULL;
- p_scb = &obx_cb.sr_sess[0];
- for (yy=0; yy<obx_cb.num_sr_sess; yy++, p_scb++)
- {
- if (p_scb->handle == obx_handle)
- {
- p_scb->ll_cb.comm.handle = OBX_HANDLE_NULL;
- }
- }
- }
- else
- {
- p_cb->num_sess = p_params->max_sessions;
- p_cb->nonce = p_params->nonce;
- p_cb->max_suspend = p_params->max_suspend;
- if (p_cb->nonce && (p_cb->max_suspend == 0))
- p_cb->max_suspend = 1;
- if (p_cb->max_suspend > OBX_MAX_SUSPEND_SESSIONS)
- p_cb->max_suspend = OBX_MAX_SUSPEND_SESSIONS;
- if ((p_cb->max_suspend * sizeof (tOBX_SPND_CB)) > GKI_MAX_BUF_SIZE)
- {
- OBX_TRACE_ERROR1("OBX_MAX_SUSPEND_SESSIONS:%d is too big", OBX_MAX_SUSPEND_SESSIONS);
- }
- }
- }
- return obx_handle;
-}
-
-/*******************************************************************************
-**
-** Function obx_sr_get_cb
-**
-** Description Returns the pointer to the server control block with given handle.
-**
-*******************************************************************************/
-tOBX_SR_CB * obx_sr_get_cb(tOBX_HANDLE handle)
-{
- tOBX_SR_CB *p_cb = NULL;
- tOBX_HANDLE obx_handle = OBX_DEC_HANDLE(handle);
-
- /* check range */
- if (obx_handle <= obx_cb.num_server && obx_handle > 0 && obx_cb.server[obx_handle-1].p_cback)
- {
- p_cb = &obx_cb.server[obx_handle-1];
- }
-
- return p_cb;
-}
-
-/*******************************************************************************
-**
-** Function obx_sr_get_scb
-**
-** Description Returns the pointer to the server control block with given handle.
-**
-*******************************************************************************/
-tOBX_SR_SESS_CB * obx_sr_get_scb(tOBX_HANDLE handle)
-{
- tOBX_SR_CB *p_cb;
- tOBX_SR_SESS_CB *p_scb = NULL;
- tOBX_HANDLE obx_handle;
- UINT16 sess_ind;
-
- /* check range */
- obx_handle = OBX_DEC_HANDLE(handle) - 1;
- if (obx_handle < obx_cb.num_server)
- {
- /* make sure the handle is a valid one */
- p_cb = &obx_cb.server[obx_handle];
- sess_ind = OBX_DEC_SESS_IND(handle);
- if ((sess_ind < p_cb->num_sess))
- {
- if ((obx_cb.sr_sess[p_cb->sess[sess_ind]-1].ll_cb.comm.handle) == handle)
- p_scb = &obx_cb.sr_sess[p_cb->sess[sess_ind]-1];
- }
- }
-
- return p_scb;
-}
-
-/*******************************************************************************
-**
-** Function obx_sr_free_cb
-**
-** Description Free the given server control block.
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_sr_free_cb(tOBX_HANDLE handle)
-{
- tOBX_SR_CB * p_cb = obx_sr_get_cb(handle);
- tOBX_SR_SESS_CB *p_scb;
- int yy;
-
- OBX_TRACE_DEBUG1("obx_sr_free_cb handle:0x%x", handle);
- /* check range */
- if (p_cb)
- {
- p_scb = &obx_cb.sr_sess[0];
- for (yy=0; yy<obx_cb.num_sr_sess; yy++, p_scb++)
- {
- if (OBX_DEC_HANDLE(p_scb->handle) == OBX_DEC_HANDLE(handle))
- {
- obx_sr_free_scb(p_scb);
- if (p_scb->ll_cb.comm.id>0)
- {
- if (p_scb->ll_cb.comm.p_send_fn == (tOBX_SEND_FN *)obx_rfc_snd_msg)
- obx_cb.hdl_map[p_scb->ll_cb.port.port_handle - 1] = 0;
- else
- obx_cb.l2c_map[p_scb->ll_cb.l2c.lcid - L2CAP_BASE_APPL_CID] = 0;
- }
- memset(p_scb, 0, sizeof(tOBX_SR_SESS_CB) );
- }
- }
-
- if (p_cb->p_auth)
- {
- GKI_freebuf(p_cb->p_auth);
- p_cb->p_auth = 0;
- }
-
- memset(p_cb, 0, sizeof(tOBX_SR_CB) );
- }
-}
-
-/*******************************************************************************
-**
-** Function obx_sr_free_scb
-**
-** Description Free the given server session control block.
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_sr_free_scb(tOBX_SR_SESS_CB *p_scb)
-{
- OBX_TRACE_DEBUG2("obx_sr_free_scb shandle:0x%x, sess_st:%d", p_scb->ll_cb.comm.handle, p_scb->sess_st);
-
- /* make sure the GKI buffers are freed */
- if (p_scb->p_saved_msg)
- {
- GKI_freebuf(p_scb->p_saved_msg);
- p_scb->p_saved_msg = 0;
- }
-
- if (p_scb->p_next_req)
- {
- GKI_freebuf(p_scb->p_next_req);
- p_scb->p_next_req = 0;
- }
- obx_free_buf (&p_scb->ll_cb);
-
- /* make sure the timer is stopped */
- btu_stop_timer(&p_scb->ll_cb.comm.tle);
-}
-
-/*******************************************************************************
-**
-** Function obx_sr_get_next_conn_id
-**
-** Description assigns the next available connection id. It will avoid using
-** active conn id instances as well so that we can work with the
-** IVT stack bugs.
-**
-*******************************************************************************/
-UINT32 obx_sr_get_next_conn_id(void)
-{
-#if (OBX_CLIENT_INCLUDED == TRUE)
- tOBX_CL_CB *p_ccb;
- int xx;
- BOOLEAN done;
-
- /* Make sure no client instances are using the value */
- do
- {
- obx_cb.next_cid++;
-
- /* Increment the value and make sure it is legal */
- if (obx_cb.next_cid == OBX_INVALID_CONN_ID)
- obx_cb.next_cid = OBX_INITIAL_CONN_ID;
-
- done = TRUE;
- for (xx=0, p_ccb = &obx_cb.client[0]; xx < obx_cb.num_client; xx++, p_ccb++)
- {
- /* If the handle is in use and same as proposed conn_id, increment and restart */
- if (p_ccb->ll_cb.comm.handle != OBX_HANDLE_NULL && p_ccb->conn_id == obx_cb.next_cid)
- {
- OBX_TRACE_WARNING1(" **** OBX CONN_ID Collision (0x%08x) trying another...", obx_cb.next_cid);
- done = FALSE;
- break;
- }
- }
- } while (!done);
-
-#else /* Client code is not compiled in */
-
- obx_cb.next_cid++;
-
- /* Increment the value and make sure it is legal */
- if (obx_cb.next_cid == OBX_INVALID_CONN_ID)
- obx_cb.next_cid = OBX_INITIAL_CONN_ID;
-#endif
-
- return obx_cb.next_cid;
-}
-
-#endif /* OBX_SERVER_INCLUDED */
-
-/*******************************************************************************
-**
-** Function obx_port_handle_2cb
-**
-** Description Given a port handle, return the associated client or server
-** control block.
-**
-** Returns
-**
-*******************************************************************************/
-tOBX_PORT_CB * obx_port_handle_2cb(UINT16 port_handle)
-{
- tOBX_PORT_CB *p_pcb = NULL;
- tOBX_HANDLE obx_handle = 0;
-#if (OBX_SERVER_INCLUDED == TRUE)
- tOBX_SR_CB *p_cb;
-#endif
-
- /* this function is called by obx_rfc_cback() only.
- * assume that port_handle is within range */
- obx_handle = obx_cb.hdl_map[port_handle-1];
- OBX_TRACE_DEBUG2("obx_port_handle_2cb port_handle:%d obx_handle:0x%x", port_handle, obx_handle);
-
- if (obx_handle > 0)
- {
- if (obx_handle & OBX_CL_HANDLE_MASK)
- {
-#if (OBX_CLIENT_INCLUDED == TRUE)
- obx_handle &= OBX_CL_CB_IND_MASK;
- p_pcb = &obx_cb.client[obx_handle - 1].ll_cb.port;
-#endif /* OBX_CLIENT_INCLUDED */
- }
- else
- {
-#if (OBX_SERVER_INCLUDED == TRUE)
- p_cb = &obx_cb.server[OBX_DEC_HANDLE(obx_handle) - 1];
- p_pcb = &obx_cb.sr_sess[p_cb->sess[OBX_DEC_SESS_IND(obx_handle)]-1].ll_cb.port;
- OBX_TRACE_DEBUG1("p_pcb port_handle:%d", p_pcb->port_handle);
-#endif /* OBX_SERVER_INCLUDED */
- }
- }
-
- return p_pcb;
-}
-
-
-
-/*******************************************************************************
-**
-** Function OBX_Init
-**
-** Description This function is called to initialize the control block for this
-** layer. It must be called before accessing any other of its API
-** functions. It is typically called once during the start up of
-** the stack.
-**
-** Returns void.
-**
-*******************************************************************************/
-void OBX_Init(void)
-{
- memset(&obx_cb, 0, sizeof(tOBX_CB));
-
-#if defined(OBX_INITIAL_TRACE_LEVEL)
- obx_cb.trace_level = OBX_INITIAL_TRACE_LEVEL;
-#else
- obx_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
-#endif
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
- obx_cb.next_ind = 0;
- obx_cb.num_client = OBX_NUM_CLIENTS;
-#endif
-
-#if (OBX_SERVER_INCLUDED == TRUE)
- obx_cb.num_server = OBX_NUM_SERVERS;
- obx_cb.num_sr_sess = OBX_NUM_SR_SESSIONS;
- obx_cb.next_cid = OBX_INITIAL_CONN_ID;
-#endif
- obx_cb.timeout_val = OBX_TIMEOUT_VALUE;
- obx_cb.sess_tout_val= OBX_SESS_TIMEOUT_VALUE;
- obx_cb.max_rx_qcount= OBX_MAX_RX_QUEUE_COUNT;
-}
-
-/*******************************************************************************
-**
-** Function OBX_SetTraceLevel
-**
-** Description This function sets the debug trace level for OBX.
-** If 0xff is passed, the current trace level is returned.
-**
-** Input Parameters:
-** level: The level to set the OBX tracing to:
-** 0xff-returns the current setting.
-** 0-turns off tracing.
-** >= 1-Errors.
-** >= 2-Warnings.
-** >= 3-APIs.
-** >= 4-Events.
-** >= 5-Debug.
-**
-** Returns The new trace level or current trace level if
-** the input parameter is 0xff.
-**
-*******************************************************************************/
-UINT8 OBX_SetTraceLevel (UINT8 level)
-{
- if (level != 0xFF)
- obx_cb.trace_level = level;
-
- return (obx_cb.trace_level);
-}
-
-/*******************************************************************************
-** Function OBX_HandleToMtu
-**
-** Description Given an OBEX handle, return the associated peer MTU.
-**
-** Returns MTU.
-**
-*******************************************************************************/
-UINT16 OBX_HandleToMtu(tOBX_HANDLE handle)
-{
- UINT16 mtu = OBX_MIN_MTU;
- BOOLEAN rx = (handle & OBX_HANDLE_RX_MTU_MASK);
-#if (OBX_CLIENT_INCLUDED == TRUE)
- int xx;
-#endif
-#if (OBX_SERVER_INCLUDED == TRUE)
- tOBX_SR_SESS_CB *p_scb;
-#endif
-
- handle &= ~OBX_HANDLE_RX_MTU_MASK;
-
- if (handle != OBX_HANDLE_NULL)
- {
- if (handle & OBX_CL_HANDLE_MASK)
- {
-#if (OBX_CLIENT_INCLUDED == TRUE)
- /* a client handle */
- for (xx=0; xx<obx_cb.num_client; xx++)
- {
- if (handle == obx_cb.client[xx].ll_cb.comm.handle)
- {
- mtu = (rx) ? obx_cb.client[xx].ll_cb.comm.rx_mtu : obx_cb.client[xx].ll_cb.comm.tx_mtu;
- break;
- }
- }
-#endif
- }
- else
- {
-#if (OBX_SERVER_INCLUDED == TRUE)
- /* a server handle */
- p_scb = obx_sr_get_scb(handle);
- /* make sure the handle is a valid one */
- if (p_scb && p_scb->ll_cb.comm.handle != OBX_HANDLE_NULL)
- {
- mtu = (rx) ? p_scb->ll_cb.comm.rx_mtu : p_scb->ll_cb.comm.tx_mtu;
- }
-#endif
- }
- }
-
- if (mtu < OBX_MIN_MTU)
- mtu = OBX_MIN_MTU;
- OBX_TRACE_DEBUG3("OBX_HandleToMtu handle: 0x%x, rx:%x, mtu:%d", handle, rx, mtu);
- return mtu;
-}
-
diff --git a/stack/obx/obx_md5.c b/stack/obx/obx_md5.c
deleted file mode 100644
index 6e0d6ea..0000000
--- a/stack/obx/obx_md5.c
+++ /dev/null
@@ -1,1050 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_md5.c
-**
-** File: OBEX Authentication related functions
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
-
-#include "bt_target.h"
-#include "btu.h"
-#include "obx_int.h"
-#include "wcassert.h"
-
-
-
-/*
-* This code implements the MD5 message-digest algorithm.
-* The algorithm is due to Ron Rivest. This code was
-* written by Colin Plumb in 1993, no copyright is claimed.
-* This code is in the public domain; do with it what you wish.
-*
-* Equivalent code is available from RSA Data Security, Inc.
-* This code has been tested against that, and is equivalent,
-* except that you don't need to include two pages of legalese
-* with every copy.
-*
-* To compute the message digest of a chunk of bytes, declare an
-* MD5Context structure, pass it to MD5Init, call MD5Update as
-* needed on buffers full of bytes, and then call MD5Final, which
-* will fill a supplied 16-byte array with the digest.
-*/
-typedef UINT32 word32;
-typedef UINT8 byte;
-struct xMD5Context {
- word32 buf[4];
- word32 bytes[2];
- word32 in[16];
-};
-
-static void obx_md5_transform(word32 buf[4], word32 const in[16]);
-
-/*
-* Shuffle the bytes into little-endian order within words, as per the
-* MD5 spec. Note: this code works regardless of the byte order.
-*/
-static void obx_byte_swap(word32 *buf, unsigned words)
-{
- byte *p = (byte *)buf;
- do {
- *buf++ = (word32)((unsigned)p[3] << 8 | p[2]) << 16
- | (word32)((unsigned)p[1] << 8 | p[0]);
- p += 4;
- } while (--words);
-}
-
-/*
-* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
-* initialization constants.
-*/
-static void obx_md5_init(struct xMD5Context *ctx)
-{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
- ctx->bytes[0] = 0;
- ctx->bytes[1] = 0;
-}
-
-/*
-* Update context to reflect the concatenation of another buffer full
-* of bytes.
-*/
-static void obx_md5_update(struct xMD5Context *ctx, byte const *buf, int len)
-{
- word32 t;
- /* Update byte count */
- t = ctx->bytes[0];
- if ((ctx->bytes[0] = t + len) < t)
- ctx->bytes[1]++; /* Carry from low to high */
- t = 64 - (t & 0x3f); /* Space avail in ctx->in (at least 1) */
- if ((unsigned)t > (unsigned)len)
- {
- memcpy ((byte *)ctx->in + 64 - (unsigned)t, buf, len);
- return;
- }
- /* First chunk is an odd size */
- memcpy (ctx->in + (64 - (unsigned)t), buf, (unsigned)t);
- obx_byte_swap(ctx->in, 16);
- obx_md5_transform(ctx->buf, ctx->in);
- buf += (unsigned)t;
- len -= (unsigned)t;
- /* Process data in 64-byte chunks */
- while (len >= 64)
- {
- /* coverity[access_dbuff_const] */
- memcpy (ctx->in, buf, 64);
- obx_byte_swap(ctx->in, 16);
- obx_md5_transform(ctx->buf, ctx->in);
- buf += 64;
- len -= 64;
- }
- /* Handle any remaining bytes of data. */
- memcpy (ctx->in, buf, len);
-}
-
-/*
-* Final wrapup - pad to 64-byte boundary with the bit pattern
-* 1 0* (64-bit count of bits processed, MSB-first)
-*/
-static void obx_md5_final(byte digest[16], struct xMD5Context *ctx)
-{
- int count = (int)(ctx->bytes[0] & 0x3f); /* Bytes in ctx->in */
- byte *p = (byte *)ctx->in + count; /* First unused byte */
- /* Set the first char of padding to 0x80. There is always room.*/
- *p++ = 0x80;
- /* Bytes of padding needed to make 56 bytes (-8..55) */
- count = 56 - 1 - count;
- if (count < 0) /* Padding forces an extra block */
- {
- memset (p, 0, count+8);
- obx_byte_swap(ctx->in, 16);
- obx_md5_transform(ctx->buf, ctx->in);
- p = (byte *)ctx->in;
- count = 56;
- }
- memset (p, 0, count+8);
- obx_byte_swap(ctx->in, 14);
- /* Append length in bits and transform */
- ctx->in[14] = ctx->bytes[0] << 3;
- ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
- obx_md5_transform(ctx->buf, ctx->in);
- obx_byte_swap(ctx->buf, 4);
- memcpy (digest, ctx->buf, 16);
- memset (ctx, 0, sizeof(ctx));
-}
-
-/* The four core functions - F1 is optimized somewhat */
-/* #define F1(x, y, z) (x & y | ~x & z) */
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
-#define F2(x, y, z) F1(z, x, y)
-#define F3(x, y, z) (x ^ y ^ z)
-#define F4(x, y, z) (y ^ (x | ~z))
-
-/* This is the central step in the MD5 algorithm. */
-#define MD5STEP(f,w,x,y,z,in,s) \
-(w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
-
-/*
-* The core of the MD5 algorithm, this alters an existing MD5 hash to
-* reflect the addition of 16 longwords of new data. MD5Update blocks
-* the data and converts bytes into longwords for this routine.
-*/
-static const word32 obx_md5_f1 [] =
-{
- 0xd76aa478,
- 0xe8c7b756,
- 0x242070db,
- 0xc1bdceee,
-
- 0xf57c0faf,
- 0x4787c62a,
- 0xa8304613,
- 0xfd469501,
-
- 0x698098d8,
- 0x8b44f7af,
- 0xffff5bb1,
- 0x895cd7be,
-
- 0x6b901122,
- 0xfd987193,
- 0xa679438e,
- 0x49b40821
-};
-
-static const word32 obx_md5_f2 [] =
-{
- 0xf61e2562,
- 0xc040b340,
- 0x265e5a51,
- 0xe9b6c7aa,
-
- 0xd62f105d,
- 0x02441453,
- 0xd8a1e681,
- 0xe7d3fbc8,
-
- 0x21e1cde6,
- 0xc33707d6,
- 0xf4d50d87,
- 0x455a14ed,
-
- 0xa9e3e905,
- 0xfcefa3f8,
- 0x676f02d9,
- 0x8d2a4c8a
-};
-
-static const word32 obx_md5_f3 [] =
-{
- 0xfffa3942,
- 0x8771f681,
- 0x6d9d6122,
- 0xfde5380c,
-
- 0xa4beea44,
- 0x4bdecfa9,
- 0xf6bb4b60,
- 0xbebfbc70,
-
- 0x289b7ec6,
- 0xeaa127fa,
- 0xd4ef3085,
- 0x04881d05,
-
- 0xd9d4d039,
- 0xe6db99e5,
- 0x1fa27cf8,
- 0xc4ac5665
-};
-
-static const word32 obx_md5_f4 [] =
-{
- 0xf4292244,
- 0x432aff97,
- 0xab9423a7,
- 0xfc93a039,
-
- 0x655b59c3,
- 0x8f0ccc92,
- 0xffeff47d,
- 0x85845dd1,
-
- 0x6fa87e4f,
- 0xfe2ce6e0,
- 0xa3014314,
- 0x4e0811a1,
-
- 0xf7537e82,
- 0xbd3af235,
- 0x2ad7d2bb,
- 0xeb86d391
-};
-
-static const UINT8 obx_md5_a [] =
-{
- 1,
- 2,
- 3,
- 0,
- 1,
- 2,
- 3
-};
-
-static const word32 obx_md5_var1 [] =
-{
- 7,
- 12,
- 17,
- 22
-};
-
-static const word32 obx_md5_var2 [] =
-{
- 5,
- 9,
- 14,
- 20
-};
-
-static const word32 obx_md5_var3 [] =
-{
- 4,
- 11,
- 16,
- 23
-};
-
-static const word32 obx_md5_var4 [] =
-{
- 6,
- 10,
- 15,
- 21
-};
-
-static void obx_md5_transform(word32 buf[4], word32 const in[16])
-{
- int xx, yy, zz, i, j, k;
- word32 a[4];
-
- a[0] = buf[0];
- a[1] = buf[1];
- a[2] = buf[2];
- a[3] = buf[3];
-
- yy = 0;
- for(xx=0; xx<4; xx++)
- {
- j = 3;
- for(i=0; i < 4; i++)
- {
- k = j--;
- /*
- OBX_TRACE_DEBUG4( "f1 a: %d, yy: %d, inc: 0x%x, var: %d",
- obx_md5_a[k], yy, obx_md5_f1[yy], obx_md5_var1[i]);
- */
- MD5STEP(F1, a[obx_md5_a[k]], a[obx_md5_a[k+1]], a[obx_md5_a[k+2]], a[obx_md5_a[k+3]],
- in[yy] + obx_md5_f1[yy], obx_md5_var1[i]);
- yy++;
- }
- }
-
- yy = 1;
- zz = 0;
- for(xx=0; xx<4; xx++)
- {
- j = 3;
- for(i=0; i < 4; i++)
- {
- k = j--;
- /*
- OBX_TRACE_DEBUG4( "f2 a: %d, yy: %d, inc: 0x%x, var: %d",
- obx_md5_a[k], yy, obx_md5_f2[zz], obx_md5_var2[i]);
- */
- MD5STEP(F2, a[obx_md5_a[k]], a[obx_md5_a[k+1]], a[obx_md5_a[k+2]], a[obx_md5_a[k+3]],
- in[yy] + obx_md5_f2[zz++], obx_md5_var2[i]);
- yy += 5;
- yy %= 16;
- }
- }
-
- yy = 5;
- zz = 0;
- for(xx=0; xx<4; xx++)
- {
- j = 3;
- for(i=0; i < 4; i++)
- {
- k = j--;
- /*
- OBX_TRACE_DEBUG4( "f3 a: %d, yy: %d, inc: 0x%x, var: %d",
- obx_md5_a[k], yy, obx_md5_f3[zz], obx_md5_var3[i]);
- */
- MD5STEP(F3, a[obx_md5_a[k]], a[obx_md5_a[k+1]], a[obx_md5_a[k+2]], a[obx_md5_a[k+3]],
- in[yy] + obx_md5_f3[zz++], obx_md5_var3[i]);
- yy += 3;
- yy %= 16;
- }
- }
-
-
- yy = 0;
- zz = 0;
- for(xx=0; xx<4; xx++)
- {
- j = 3;
- for(i=0; i < 4; i++)
- {
- k = j--;
- /*
- OBX_TRACE_DEBUG4( "f4 a: %d, yy: %d, inc: 0x%x, var: %d",
- obx_md5_a[k], yy, obx_md5_f4[zz], obx_md5_var4[i]);
- */
- MD5STEP(F4, a[obx_md5_a[k]], a[obx_md5_a[k+1]], a[obx_md5_a[k+2]], a[obx_md5_a[k+3]],
- in[yy] + obx_md5_f4[zz++], obx_md5_var4[i]);
- yy += 7;
- yy %= 16;
- }
- }
-
- buf[0] += a[0];
- buf[1] += a[1];
- buf[2] += a[2];
- buf[3] += a[3];
-}
-
-/*******************************************************************************
-**
-** Function OBX_MD5
-**
-** Description This function is called to run the MD5 algorithm.
-**
-** Returns void
-**
-*******************************************************************************/
-static void OBX_MD5(void *digest, UINT8 *nonce, UINT8 * password, int password_len)
-{
- struct xMD5Context context;
- UINT8 before[OBX_NONCE_SIZE + OBX_MAX_AUTH_KEY_SIZE + 4];
-
- memcpy(before, nonce, OBX_NONCE_SIZE);
- before[OBX_NONCE_SIZE] = ':';
- memcpy(before + OBX_NONCE_SIZE + 1, password, password_len);
- /*
- scru_dump_hex (before, "before", OBX_NONCE_SIZE + 1 + password_len, TRACE_LAYER_OBEX, TRACE_TYPE_GENERIC);
- */
-
- obx_md5_init(&context);
-/* coverity[overrun-buffer-val] */
-/*
-FALSE-POSITIVE: coverity says "Overrun of static array "before" of size 36 bytes by passing it as an argument to a function which indexes it at byte position 63"
-obx_md5_update() only goes into that condition when (len >= 64). In this case, len is (OBX_NONCE_SIZE + 1 + password_len) which is less than or equal to 33.
-password_len is less than or equal to OBX_MAX_AUTH_KEY_SIZE. The size of before[] is more than enough */
- obx_md5_update(&context, (byte const *)before, OBX_NONCE_SIZE + 1 + password_len);
- obx_md5_final((byte *)digest, &context);
- /*
- scru_dump_hex (digest, "after", 16, TRACE_LAYER_OBEX, TRACE_TYPE_GENERIC);
- */
-}
-
-/*******************************************************************************
-**
-** Function obx_session_id
-**
-** Description This function is called to run the MD5 algorithm to create a
-** session id.
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_session_id(UINT8 *p_sess_id, UINT8 *p_cl_addr, UINT8 * p_cl_nonce, int cl_nonce_len,
- UINT8 *p_sr_addr, UINT8 * p_sr_nonce, int sr_nonce_len)
-{
- struct xMD5Context context;
- UINT8 before[(OBX_NONCE_SIZE + BD_ADDR_LEN) * 2 + 4];
- UINT8 *p = before;
- UINT8 len;
-
- memcpy(p, p_cl_addr, BD_ADDR_LEN);
- p += BD_ADDR_LEN;
- memcpy(p, p_cl_nonce, cl_nonce_len);
- p += cl_nonce_len;
- memcpy(p, p_sr_addr, BD_ADDR_LEN);
- p += BD_ADDR_LEN;
- memcpy(p, p_sr_nonce, sr_nonce_len);
- p += sr_nonce_len;
- /*
- scru_dump_hex (before, "before", OBX_NONCE_SIZE + 1 + password_len, TRACE_LAYER_OBEX, TRACE_TYPE_GENERIC);
- */
-
- len = BD_ADDR_LEN + cl_nonce_len + BD_ADDR_LEN + sr_nonce_len;
- obx_md5_init(&context);
-/* coverity [overrun-buffer-val] */
-/* Overrun of static array "before" of size 48 bytes by passing it as an argument to a function which indexes it at byte position 63*/
-/* FALSE-POSITIVE: obx_md5_update() only goes into that condition when (len >= 64). In this case, len is (OBX_NONCE_SIZE + 1 + password_len) which is less than or equal to 33.
-password_len is less than or equal to OBX_MAX_AUTH_KEY_SIZE. The size of before[] is more than enough */
- obx_md5_update(&context, (byte const *)before, len);
- obx_md5_final((byte *)p_sess_id, &context);
- /*
- scru_dump_hex (p_sess_id, "after", 16, TRACE_LAYER_OBEX, TRACE_TYPE_GENERIC);
- */
-}
-
-#if (OBX_SERVER_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function obx_copy_and_rm_auth_hdrs
-**
-** Description This function is used to copy the given OBEX packet to a new packet
-** with the authentication headers removed.
-**
-** Returns tOBX_STATUS
-**
-*******************************************************************************/
-tOBX_STATUS obx_copy_and_rm_auth_hdrs(BT_HDR *p_pkt, BT_HDR *p_new, UINT8 * p_hi)
-{
- tOBX_STATUS status = OBX_SUCCESS;
- UINT8 *pn, *po, *p_nlen = NULL;
- int hsize, nsize;
- UINT16 nlen, olen;
- UINT8 size;
- int xx;
-
- WC_ASSERT(p_new);
-
-
- po = (UINT8 *)(p_pkt + 1) + p_pkt->offset + 1;
- BE_STREAM_TO_UINT16(olen, po);
- OBX_TRACE_DEBUG3( "obx_copy_and_rm_auth_hdrs event: %d, new len:%d, olen:%d",
- p_pkt->event, p_new->len, olen);
-
- po = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- if(p_new->len == 0)
- {
- p_new->offset = p_pkt->offset;
- p_nlen = (UINT8 *)(p_new + 1) + p_new->offset + 1;
- }
- pn = (UINT8 *)(p_new + 1) + p_new->offset;
-
- /* Get the number of bytes before headers start */
- size = obx_hdr_start_offset[p_pkt->event - 1];
- if(p_new->len)
- {
- /* for OBX_AuthResponse
- * - do not need to copy the stuff before headers
- * there's already some header, skip them */
- pn += p_new->len;
- nlen = p_new->len;
- }
- else
- {
- /* for obx_unauthorize_rsp
- * - needs to copy the stuff before headers */
- memcpy(pn, po, size);
- pn += size;
- nlen = size;
- }
- po += size;
-
- olen -= size;
- while(olen)
- {
- OBX_TRACE_DEBUG1( "olen:%d", olen);
- hsize = (int)obx_read_header_len(po);
- if(olen > hsize)
- olen -= hsize;
- else
- olen = 0;
-
- xx = 0;
- nsize = hsize;
- while(p_hi[xx] != OBX_HI_NULL)
- {
- /*
- OBX_TRACE_DEBUG2( "po:0x%x, hix:0x%x", *po, p_hi[xx]);
- */
- if(*po == p_hi[xx++])
- {
- nsize = 0;
- break;
- }
- }
- OBX_TRACE_DEBUG2( "hsize:%d, nsize:%d", hsize, nsize);
- if(nsize)
- {
- /* skip auth challenge and auth response */
- if((nlen+hsize) < p_pkt->layer_specific)
- {
- /* copy other headers */
- memcpy(pn, po, hsize);
- pn += hsize;
- nlen += hsize;
- }
- else
- {
- OBX_TRACE_WARNING1( "obx_copy_and_rm_auth_hdrs Not enough room: %d", olen);
- /* no more room in the new packet */
- status = OBX_NO_RESOURCES;
- break;
- }
- }
- po += hsize;
- }
-
- if(status == OBX_SUCCESS)
- {
- if(p_nlen)
- {
- UINT16_TO_BE_STREAM(p_nlen, nlen);
- }
- p_new->len = nlen;
- p_new->layer_specific = GKI_get_buf_size(p_new) - BT_HDR_SIZE - p_new->offset;
- p_new->event = p_pkt->event;
- }
-
- return status;
-}
-
-/*******************************************************************************
-**
-** Function obx_unauthorize_rsp
-**
-** Description This function is used to add authentication challenge triplet
-**
-** Returns void.
-** Note: this function assumes that all data can fit in the MTU
-*******************************************************************************/
-BT_HDR * obx_unauthorize_rsp(tOBX_SR_CB *p_cb, tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- UINT8 *p;
- UINT8 nonce[OBX_NONCE_SIZE+2];
- UINT8 option[2];
- UINT8 *p_target = NULL;
- tOBX_TRIPLET triplet[OBX_MAX_NUM_AUTH_TRIPLET];
- UINT8 num_trip = 0;
- BT_HDR *p_old;
- UINT8 hi[] = {OBX_HI_CHALLENGE, OBX_HI_AUTH_RSP, OBX_HI_NULL};
-
- OBX_TRACE_DEBUG1( "obx_unauthorize_rsp: %d", p_cb->target.len);
- if(OBX_CheckHdr(p_pkt, OBX_HI_CHALLENGE) || OBX_CheckHdr(p_pkt, OBX_HI_AUTH_RSP))
- {
- p_old = p_pkt;
- p_pkt = OBX_HdrInit(p_scb->ll_cb.comm.handle, (UINT16)(p_old->len + BT_HDR_SIZE + p_old->offset));
- obx_copy_and_rm_auth_hdrs(p_old, p_pkt, hi);
- GKI_freebuf(p_old);
- }
-
- if(p_cb->target.len)
- {
- /* There must be the target header, change it to be WHO header */
- if( (p_target = OBX_CheckHdr(p_pkt, OBX_HI_TARGET)) != NULL)
- {
- *p_target = OBX_HI_WHO;
- }
- }
- OBX_TRACE_DEBUG1( "p_target: %x", p_target);
-
- if(p_cb->p_auth)
- {
- /* server registers for authentication */
- /* prepare the triplet byte sequence */
- /* add nonce: tag, length, value */
- p_cb->p_auth->nonce = GKI_get_tick_count();
- sprintf ((char *)nonce, "%016lu", p_cb->p_auth->nonce);
-
- num_trip = 0;
- triplet[num_trip].tag = OBX_NONCE_CHLNG_TAG;
- triplet[num_trip].len = OBX_NONCE_SIZE;
- triplet[num_trip].p_array = nonce;
- num_trip++;
-
- if(p_cb->p_auth->auth_option)
- {
- /* add option */
- triplet[num_trip].tag = OBX_OPTIONS_CHLNG_TAG;
- triplet[num_trip].len = 1;
- option[0] = p_cb->p_auth->auth_option;
- triplet[num_trip].p_array = option;
- num_trip++;
- }
- if(p_cb->p_auth->realm_len)
- {
- /* add realm */
- triplet[num_trip].tag = OBX_REALM_CHLNG_TAG;
- triplet[num_trip].len = p_cb->p_auth->realm_len+1;
- triplet[num_trip].p_array = p_cb->p_auth->realm;
- num_trip++;
- }
-
- /* add the sequence to header */
- OBX_AddTriplet(p_pkt, OBX_HI_CHALLENGE, triplet, num_trip);
- }
-
- p = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
- /* change the opcode to unauthorized response */
- *p++ = OBX_RSP_UNAUTHORIZED | OBX_FINAL;
- /* adjust the packet len */
- UINT16_TO_BE_STREAM(p, p_pkt->len);
-
- /* add session sequence number, if session is active */
- if ((p_scb->sess_st == OBX_SESS_ACTIVE) && ((p_target = OBX_CheckHdr(p_pkt, OBX_HI_SESSION_SN)) != NULL))
- {
- p_target++;
- (*p_target)++;
- }
-
- p_pkt->event = OBX_CONNECT_RSP_EVT;
-
- return p_pkt;
-}
-
-/*******************************************************************************
-**
-** Function OBX_Password
-**
-** Description This function is called by the server to respond to an
-** OBX_PASSWORD_EVT event.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_NO_RESOURCES, if OBX does not resources
-**
-*******************************************************************************/
-tOBX_STATUS OBX_Password(tOBX_HANDLE shandle, UINT8 *p_password, UINT8 password_len,
- UINT8 *p_userid, UINT8 userid_len)
-{
- tOBX_STATUS status = OBX_SUCCESS;
- BT_HDR *p_pkt;
- BT_HDR *p_rsp;
- UINT8 temp_digest[OBX_DIGEST_SIZE];
- UINT8 nonce[OBX_NONCE_SIZE + 1];
- BOOLEAN pass = FALSE;
- BOOLEAN digest_done = FALSE;
- BOOLEAN option_userid = FALSE;
- tOBX_TRIPLET triplet[OBX_MAX_NUM_AUTH_TRIPLET];
- UINT8 num_trip = OBX_MAX_NUM_AUTH_TRIPLET;
- UINT8 xx;
- UINT8 *p_target;
- UINT16 tlen;
- tOBX_SR_SESS_CB *p_scb = obx_sr_get_scb(shandle);
- tOBX_SR_CB *p_cb = obx_sr_get_cb(shandle);
- UINT8 *p;
- tOBX_EVT_PARAM param; /* The event parameter. */
-
- WC_ASSERT(password_len < OBX_MAX_AUTH_KEY_SIZE);
-
- if(p_scb == NULL || p_scb->p_saved_msg == NULL)
- return OBX_NO_RESOURCES;
-
- /* The coverity complaints on this function is not correct.
- * The value in triplet[] is set/initialized by OBX_ReadTriplet if num_trip returns TRUE.
- * leave this unnecessary memset here */
- memset(triplet,0,sizeof(triplet));
-
- p_pkt = p_scb->p_saved_msg;
-
- if(p_cb->p_auth == NULL)
- {
- pass = TRUE;
- }
- else if(OBX_ReadTriplet(p_pkt, OBX_HI_AUTH_RSP, triplet, &num_trip) == TRUE)
- {
- if(p_password && password_len )
- {
- /* if given password, verify it */
- for(xx=0; xx<num_trip; xx++)
- {
- if(triplet[xx].tag == OBX_DIGEST_RSP_TAG)
- {
- sprintf((char *)nonce, "%016lu", p_cb->p_auth->nonce);
- OBX_MD5 (temp_digest, nonce, p_password, password_len);
- if (memcmp (temp_digest, triplet[xx].p_array, OBX_DIGEST_SIZE) == 0)
- pass = TRUE;
- break;
- }
- }
- }
- }
-
- /* check if challenged by client */
- num_trip = OBX_MAX_NUM_AUTH_TRIPLET;
- if(pass == TRUE && OBX_ReadTriplet(p_pkt, OBX_HI_CHALLENGE, triplet, &num_trip) == TRUE)
- {
- /* Make sure password was passed in and not empty */
- if (p_password && password_len )
- {
- for(xx=0; xx<num_trip; xx++)
- {
- if(triplet[xx].tag == OBX_NONCE_CHLNG_TAG)
- {
- /* nonce tag is mandatory */
- OBX_MD5 (temp_digest, triplet[xx].p_array, p_password, password_len);
- digest_done = TRUE;
- }
- else if(triplet[xx].tag == OBX_OPTIONS_CHLNG_TAG)
- {
- /* user ID bit is set */
- if(OBX_AO_USR_ID & triplet[xx].p_array[0])
- option_userid = TRUE;
- }
- }
-
- if (option_userid && (userid_len == 0 || p_userid == NULL) )
- {
- status = OBX_BAD_PARAMS;
- }
- }
- }
-
- if(status == OBX_SUCCESS)
- {
- p_scb->p_saved_msg = NULL;
- if(pass == TRUE)
- {
- p_rsp = OBX_HdrInit(shandle, OBX_MIN_MTU);
-
- /* add the authentication response if been challenged */
- if(digest_done)
- {
- num_trip = 1;
- triplet[0].tag = OBX_DIGEST_RSP_TAG;
- triplet[0].len = OBX_DIGEST_SIZE;
- triplet[0].p_array = temp_digest;
- if(option_userid)
- {
- num_trip++;
- triplet[1].tag = OBX_USERID_RSP_TAG;
- triplet[1].len = userid_len;
- triplet[1].p_array = p_userid;
- }
- OBX_AddTriplet(p_rsp, OBX_HI_AUTH_RSP, triplet, num_trip);
- }
-
- if( p_cb->target.len == OBX_DEFAULT_TARGET_LEN &&
- OBX_ReadTargetHdr(p_pkt, &p_target, &tlen, 0) == TRUE)
- {
- /* API user is supposed to handle WHO header
- * for this special case, we add it for the API user */
- OBX_AddWhoHdr(p_rsp, p_target, tlen);
- }
-
- /* use OBX_ConnectRsp to fill the common data */
- status = OBX_ConnectRsp(shandle, OBX_RSP_OK, p_rsp);
- if(status == OBX_SUCCESS)
- {
- /* If authentication is successful, need to update session info */
- p = &p_scb->sess_info[OBX_SESSION_INFO_ID_IDX];
- UINT32_TO_BE_STREAM(p, p_scb->conn_id);
- param.sess.p_sess_info = p_scb->sess_info;
- param.sess.sess_op = OBX_SESS_OP_CREATE;
- param.sess.sess_st = p_scb->sess_st;
- param.sess.nssn = p_scb->param.ssn;
- param.sess.ssn = p_scb->param.ssn;
- param.sess.obj_offset = 0;
- p = &p_scb->sess_info[OBX_SESSION_INFO_MTU_IDX];
- UINT16_TO_BE_STREAM(p, p_scb->param.conn.mtu);
- memcpy(param.sess.peer_addr, p_scb->peer_addr, BD_ADDR_LEN);
- (*p_cb->p_cback)(p_scb->ll_cb.comm.handle, OBX_SESSION_REQ_EVT, param, p_pkt);
- (*p_cb->p_cback)(p_scb->ll_cb.comm.handle, OBX_CONNECT_REQ_EVT, p_scb->param, p_pkt);
- }
- else
- GKI_freebuf(p_pkt);
- }
- else
- {
- /* server can not find the password, send unauthorized response */
- p_pkt = obx_unauthorize_rsp(p_cb, p_scb, p_pkt);
- obx_ssm_event(p_scb, OBX_CONNECT_CFM_SEVT, p_pkt);
- }
- }
- /*
- else p_scb->p_saved_msg is still valid.
- */
-
- return status;
-}
-#endif
-
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function OBX_AuthResponse
-**
-** Description This function is called by the client to respond to an
-** OBX_PASSWORD_EVT event.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_NO_RESOURCES, if OBX does not resources
-**
-*******************************************************************************/
-tOBX_STATUS OBX_AuthResponse(tOBX_HANDLE handle,
- UINT8 *p_password, UINT8 password_len,
- UINT8 *p_userid, UINT8 userid_len,
- BOOLEAN authenticate)
-{
- tOBX_CL_CB *p_cb = obx_cl_get_cb(handle);
- tOBX_STATUS status = OBX_NO_RESOURCES;
- BT_HDR *p_pkt;
- BT_HDR *p_saved_req;
- UINT8 num_trip, flags = 0;
- UINT16 nlen, xx;
- UINT8 temp_digest[OBX_DIGEST_SIZE];
- UINT8 nonce[OBX_NONCE_SIZE + 1];
- BOOLEAN digest_done = FALSE;
- BOOLEAN option_userid = FALSE;
- UINT8 rsp_code;
- BOOLEAN final;
- UINT8 *p_target;
- tOBX_TRIPLET triplet[OBX_MAX_NUM_AUTH_TRIPLET];
- UINT8 hi[] = {OBX_HI_CONN_ID, OBX_HI_TARGET, OBX_HI_CHALLENGE, OBX_HI_AUTH_RSP,
- OBX_HI_SESSION_SN, /* prevent SSN from being copied */
- OBX_HI_NULL};
- WC_ASSERT(password_len < OBX_MAX_AUTH_KEY_SIZE);
- WC_ASSERT(p_password);
-
- if(p_cb == NULL || p_cb->p_auth == NULL || p_cb->p_saved_req == NULL)
- return OBX_NO_RESOURCES;
-
- p_saved_req = p_cb->p_saved_req;
- p_pkt = OBX_HdrInit(handle, GKI_MAX_BUF_SIZE); /* make sure added length will fit */
- WC_ASSERT(p_pkt);
- OBX_TRACE_DEBUG2("OBX_AuthResponse p_saved_req:%d, p_saved_req->len %d ",
- p_saved_req->event, p_saved_req->len);
-
- /* if the save_req contains SSN, add it now */
- if ((p_target = OBX_CheckHdr(p_saved_req, OBX_HI_SESSION_SN)) != NULL)
- {
- p_target++;
- OBX_Add1ByteHdr(p_pkt, OBX_HI_SESSION_SN, (UINT8)((*p_target) + 1));
- }
-
- /* The coverity complaints on this function is not correct.
- * The value in triplet[] is set/initialized by OBX_ReadTriplet if num_trip returns TRUE.
- * leave this unnecessary memset here */
- memset(triplet,0,sizeof(triplet));
-
- /* if target header exists in the original request
- * and the Connection ID has not been assigned yet,
- * copy the target header over */
- if(OBX_ReadTargetHdr(p_saved_req, &p_target, &nlen, 0) == TRUE)
- {
- OBX_AddTargetHdr(p_pkt, p_target, nlen);
- }
-
- /* read the challenge from received packet */
- num_trip = OBX_MAX_NUM_AUTH_TRIPLET;
- if(OBX_ReadTriplet(p_cb->p_auth, OBX_HI_CHALLENGE, triplet, &num_trip) == TRUE)
- {
- status = OBX_SUCCESS;
- for(xx=0; xx<num_trip; xx++)
- {
- if(triplet[xx].tag == OBX_NONCE_CHLNG_TAG)
- {
- /* nonce tag is mandatory */
- OBX_MD5 (temp_digest, triplet[xx].p_array, p_password, password_len);
- digest_done = TRUE;
- }
- else if(triplet[xx].tag == OBX_OPTIONS_CHLNG_TAG)
- {
- /* user ID bit is set */
- if(OBX_AO_USR_ID & triplet[xx].p_array[0])
- option_userid = TRUE;
- }
- }
-
- if(option_userid && (userid_len == 0 || p_userid == NULL) )
- {
- status = OBX_BAD_PARAMS;
- }
- OBX_TRACE_DEBUG2( "num_trip:%d, option_userid:%d", num_trip, option_userid);
-
- if(digest_done && status == OBX_SUCCESS)
- {
- /* Compose and add the authentication Response header */
- num_trip = 1;
- triplet[0].tag = OBX_DIGEST_RSP_TAG;
- triplet[0].len = OBX_DIGEST_SIZE;
- triplet[0].p_array = temp_digest;
- if(option_userid)
- {
- /* add user id */
- num_trip++;
- triplet[1].tag = OBX_USERID_RSP_TAG;
- triplet[1].len = userid_len;
- triplet[1].p_array = p_userid;
- }
- OBX_AddTriplet(p_pkt, OBX_HI_AUTH_RSP, triplet, num_trip);
-
- /* if we want to authenticate the server, add the challenge header here */
- /* Note: we only do it for the CONNECT request */
- if(authenticate && p_saved_req->event == OBX_CONNECT_REQ_EVT)
- {
- /* Indicate in the control block to verify the response */
- p_cb->wait_auth = TRUE;
-
- /* add the challenge nonce */
- num_trip = 1;
- triplet[0].tag = OBX_NONCE_CHLNG_TAG;
- triplet[0].len = OBX_NONCE_SIZE;
- triplet[0].p_array = nonce;
- sprintf ((char *)nonce, "%016lu", GKI_get_tick_count());
- OBX_AddTriplet(p_pkt, OBX_HI_CHALLENGE, triplet, num_trip);
- OBX_MD5 ((UINT8 *)(p_cb->p_auth), nonce, p_password, password_len);
- }
-
- /* copy non-(target, conn_id, authentication) headers from p_saved_req. */
- status = obx_copy_and_rm_auth_hdrs(p_saved_req, p_pkt, hi);
- OBX_TRACE_DEBUG4( "status:%d, save:%d, pkt:%d, off:%d",
- status, p_saved_req->event, p_pkt->event, p_pkt->offset);
-
- if(status == OBX_SUCCESS)
- {
- /* get the final from the saved request */
- rsp_code = OBX_RSP_DEFAULT;
- obx_access_rsp_code(p_saved_req, &rsp_code);
- final = (rsp_code & OBX_FINAL) ? TRUE : FALSE;
- OBX_TRACE_DEBUG1( "saved final:%d", final);
-
- /* call the associated API function to send the request again */
- switch(p_pkt->event)
- {
- case OBX_CONNECT_REQ_EVT:
- status = OBX_ConnectReq((BD_ADDR_PTR)BT_BD_ANY, 0, 0, NULL, &p_cb->ll_cb.comm.handle, p_pkt);
- break;
- case OBX_PUT_REQ_EVT:
- status = OBX_PutReq(handle, final, p_pkt);
- break;
- case OBX_GET_REQ_EVT:
- status = OBX_GetReq(handle, final, p_pkt);
- break;
- case OBX_SETPATH_REQ_EVT:
- /* get the flags from old request - if SetPath */
- flags = *((UINT8 *)(p_saved_req + 1) + p_saved_req->offset + 3);
- status = OBX_SetPathReq(handle, flags, p_pkt);
- break;
- default:
- /* it does not make sense to authenticate on Abort and Disconnect */
- OBX_TRACE_WARNING1( "Authenticate on bad request: %d", p_pkt->event);
- status = OBX_NO_RESOURCES;
- } /* switch (event) */
- }
- } /* digest done */
- } /* challenge heaer exists */
-
- if(status != OBX_SUCCESS)
- {
- GKI_freebuf(p_pkt);
- }
-
- if(p_cb->wait_auth == FALSE)
- {
- GKI_freebuf(p_cb->p_auth);
- p_cb->p_auth = NULL;
- }
- return status;
-}
-
-#if (OBX_MD5_TEST_INCLUDED == TRUE)
-/*******************************************************************************
-**
-** Function OBX_VerifyResponse
-**
-** Description This function is called by the client to verify the challenge
-** response.
-**
-** Returns TRUE, if successful.
-** FALSE, if authentication failed
-**
-*******************************************************************************/
-BOOLEAN OBX_VerifyResponse(UINT32 nonce_u32, UINT8 *p_password, UINT8 password_len, UINT8 *p_response)
-{
- BOOLEAN status = FALSE;
- UINT8 nonce[OBX_NONCE_SIZE + 1];
- UINT8 temp_digest[OBX_DIGEST_SIZE];
-
- OBX_TRACE_API0( "OBX_VerifyResponse");
- if (p_password && password_len)
- {
- sprintf((char *)nonce, "%016lu", nonce_u32);
- OBX_MD5 (temp_digest, nonce, p_password, password_len);
- if (memcmp (temp_digest, p_response, OBX_DIGEST_SIZE) == 0)
- status = TRUE;
- }
- return status;
-}
-#endif /* OBX_MD5_TEST_INCLUDED */
-
-
-#endif
-
-
-
diff --git a/stack/obx/obx_rfc.c b/stack/obx/obx_rfc.c
deleted file mode 100644
index b02fbef..0000000
--- a/stack/obx/obx_rfc.c
+++ /dev/null
@@ -1,613 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_rfc.c
-**
-** File: OBEX interface to the RFCOMM module
-**
-** Copyright (c) 2003-2008, Broadcom Corp., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-#include "wcassert.h"
-
-#include "bt_target.h"
-#include "obx_int.h"
-
-#include "port_api.h"
-#include "sdpdefs.h"
-#include "btu.h"
-
-/*******************************************************************************
-** Function obx_rfc_snd_evt
-** Description Sends an rfcomm event to OBX through the BTU task.
-*******************************************************************************/
-static void obx_rfc_snd_evt (tOBX_PORT_CB *p_pcb, UINT32 code)
-{
- BT_HDR *p_msg;
- tOBX_PORT_EVT *p_evt;
- UINT16 event;
-
- if (!p_pcb)
- return;
-
- p_msg = (BT_HDR*)GKI_getbuf(BT_HDR_SIZE + sizeof(tOBX_PORT_EVT));
- WC_ASSERT(p_msg);
-
- if (p_pcb->handle & OBX_CL_HANDLE_MASK)
- event = BT_EVT_TO_OBX_CL_MSG;
- else
- event = BT_EVT_TO_OBX_SR_MSG;
-
- p_msg->event = event;
- p_msg->len = sizeof(tOBX_PORT_EVT);
- p_msg->offset = 0;
- p_evt = (tOBX_PORT_EVT *)(p_msg + 1);
- p_evt->code = code;
- p_evt->p_pcb = p_pcb;
-
- GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_msg);
-}
-
-/*******************************************************************************
-** Function obx_rfc_cback
-** Description find the port control block and post an event to BTU task.
-** NOTE: This callback does not handle connect up/down events.
-** obx_rfc_mgmt_cback is used for these events.
-*******************************************************************************/
-static void obx_rfc_cback (UINT32 code, UINT16 port_handle)
-{
- tOBX_PORT_CB *p_pcb = obx_port_handle_2cb(port_handle);
-
- if (p_pcb)
- {
- obx_rfc_snd_evt (p_pcb, code);
- }
- else
- {
- OBX_TRACE_WARNING0("Can not find control block");
- }
-}
-
-/*******************************************************************************
-** Function obx_rfc_mgmt_cback
-** Callback registered with the PORT entity's Management Callback so that OBX
-** can be notified when the connection has come up or gone down.
-********************************************************************************/
-void obx_rfc_mgmt_cback(UINT32 port_status, UINT16 port_handle)
-{
- tOBX_PORT_CB *p_pcb = obx_port_handle_2cb(port_handle);
- UINT32 code;
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
- if (!p_pcb && port_status != PORT_SUCCESS)
- {
- /* See if error called within RFCOMM_CreateConnection */
- if (obx_cb.p_temp_pcb)
- {
- p_pcb = obx_cb.p_temp_pcb;
- obx_cb.p_temp_pcb = NULL;
- }
- }
-#endif
-
- if (p_pcb)
- {
- code = (port_status == PORT_SUCCESS) ? PORT_EV_CONNECTED : PORT_EV_CONNECT_ERR;
- obx_rfc_snd_evt (p_pcb, code);
- }
- else
- {
- OBX_TRACE_WARNING0("mgmt cback: Can not find control block");
- }
-}
-
-
-/*******************************************************************************
-** Function obx_read_data
-** Description This functions reads data from FRCOMM. Return a message if the
-** whole packet is read.
-** The following defines how BT_HDR is used in this function
-** event: response or request event code
-** len: the length read so far.
-** offset: offset to the beginning of the actual data.
-** layer_specific: left
-*******************************************************************************/
-static BT_HDR * obx_read_data (tOBX_PORT_CB *p_pcb, tOBX_VERIFY_OPCODE p_verify_opcode)
-{
- BT_HDR *p_ret = NULL;
- UINT8 *p;
- UINT16 ask_len;
- UINT16 got_len;
- int rc;
- tOBX_RX_HDR *p_rxh;
- tOBX_SR_SESS_CB *p_scb;
- UINT8 opcode;
- UINT16 pkt_len;
- BOOLEAN failed = FALSE;
-
- OBX_TRACE_DEBUG1("obx_read_data port_handle:%d", p_pcb->port_handle );
- for (;;)
- {
- if (p_pcb->p_rxmsg == NULL)
- {
- p_pcb->p_rxmsg = OBX_HdrInit((tOBX_HANDLE)(p_pcb->handle|OBX_HANDLE_RX_MTU_MASK),
- OBX_LRG_DATA_POOL_SIZE);
- memset((p_pcb->p_rxmsg + 1), 0, sizeof(tOBX_RX_HDR));
- }
- /* we use this header to keep the status of this packet (instead of in control block) */
- p_rxh = (tOBX_RX_HDR *)(p_pcb->p_rxmsg + 1);
-
- ask_len = 0;
- if (p_rxh->code == 0)
- {
- if (p_pcb->p_rxmsg->len == 0) /* we need this if statement in case of "throw away" */
- ask_len = 1;
- }
- else if (p_pcb->p_rxmsg->len < (OBX_PKT_LEN_SIZE + 1) )
- {
- /* if we do not know the packet len yet, read from port */
- ask_len = OBX_PKT_LEN_SIZE + 1 - p_pcb->p_rxmsg->len;
- }
- else
- {
- /* we already know the packet len.
- * determine how many more bytes we need for this packet */
- ask_len = p_rxh->pkt_len - p_pcb->p_rxmsg->len;
- }
-
- /* the position of next byte to read */
- p = (UINT8 *)(p_pcb->p_rxmsg + 1) + p_pcb->p_rxmsg->offset + p_pcb->p_rxmsg->len;
-
- if (ask_len)
- {
- rc = PORT_ReadData( p_pcb->port_handle, (char*)p, ask_len, &got_len);
- if (rc != PORT_SUCCESS)
- {
- OBX_TRACE_WARNING2("Error %d returned from PORT_Read_Data, len:%d", rc, got_len);
- }
-
- OBX_TRACE_DEBUG2("ask_len: %d, got_len:%d", ask_len, got_len );
- if (got_len == 0)
- {
- /* If we tried to read but did not get anything, */
- /* there is nothing more to read at this time */
- break;
- }
- p_pcb->p_rxmsg->len += got_len;
- p_pcb->p_rxmsg->layer_specific -= got_len;
- }
-
- /* process the response/opcode, if not yet */
- if (p_rxh->code == 0 && p_pcb->p_rxmsg->len)
- {
- opcode = *((UINT8 *)(p_pcb->p_rxmsg + 1) + p_pcb->p_rxmsg->offset);
- if ( (p_verify_opcode)(opcode, p_rxh) == OBX_BAD_SM_EVT)
- {
- OBX_TRACE_WARNING1("bad opcode:0x%x - Disconnecting", opcode );
- /* received data with bad length. */
-
- /*bad length disconnect */
- failed = TRUE;
- break;
- }
- continue;
- }
-
- /* process the packet len */
- if (p_rxh->pkt_len == 0 && p_pcb->p_rxmsg->len >= (OBX_PKT_LEN_SIZE + 1) )
- {
- p = (UINT8 *)(p_pcb->p_rxmsg + 1) + p_pcb->p_rxmsg->offset + 1;
- BE_STREAM_TO_UINT16(pkt_len, p);
-
- if ( (pkt_len > p_pcb->rx_mtu) ||
- (pkt_len < 3) ||
- (pkt_len == 4) )
- {
- /* received data with bad length. */
- OBX_TRACE_WARNING2("Received bad packet len -Disconnecting: %d RX MTU: %x",
- pkt_len, p_pcb->rx_mtu);
- /*bad length disconnect */
- failed = TRUE;
- break;
- }
- else
- {
- /* keep the packet len in the header */
- p_rxh->pkt_len = pkt_len;
- }
- continue;
- }
-
- if (p_pcb->p_rxmsg->len == p_rxh->pkt_len)
- {
- /* received a whole packet */
- OBX_TRACE_DEBUG1("got a packet. opcode:0x%x", p_rxh->code );
- p_ret = p_pcb->p_rxmsg;
- p_pcb->p_rxmsg = NULL;
- break;
- }
-
- }
-
- if (failed)
- {
- if (p_pcb->handle & OBX_CL_HANDLE_MASK)
- {
- obx_close_port(p_pcb->port_handle);
- }
- else
- {
- if ((p_scb = obx_sr_get_scb(p_pcb->handle)) != NULL)
- obx_ssm_event(p_scb, OBX_PORT_CLOSE_SEVT, NULL);
-
- }
- p_ret = NULL;
- }
-
- return p_ret;
-}
-
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
-/*******************************************************************************
-** Function obx_cl_proc_evt
-** Description This is called to process BT_EVT_TO_OBX_CL_MSG
-** Process events from RFCOMM. Get the associated client control
-** block. If this is a response packet, stop timer. Call
-** obx_csm_event() with event OK_CFM, FAIL_CFM or CONT_CFM.
-*******************************************************************************/
-void obx_cl_proc_evt(tOBX_PORT_EVT *p_evt)
-{
- tOBX_PORT_CB *p_pcb = p_evt->p_pcb;
- tOBX_CL_CB *p_cb = obx_cl_get_cb(p_pcb->handle);
- BT_HDR *p_pkt;
-
- if (p_cb == NULL)
- {
- /* probably already close the port and deregistered from OBX */
- OBX_TRACE_ERROR1("Could not find control block for handle: 0x%x", p_pcb->handle);
- return;
- }
-
- if (p_evt->code & PORT_EV_CONNECT_ERR)
- {
- obx_csm_event(p_cb, OBX_PORT_CLOSE_CEVT, NULL);
- return;
- } /* PORT_EV_CONNECT_ERR */
-
- if (p_evt->code & PORT_EV_TXEMPTY)
- {
- obx_csm_event(p_cb, OBX_TX_EMPTY_CEVT, NULL);
- } /* PORT_EV_TXEMPTY */
-
- if (p_evt->code & PORT_EV_RXCHAR)
- {
- while( (p_pkt = obx_read_data(p_pcb, obx_verify_response)) != NULL )
- {
- if (GKI_queue_is_empty(&p_pcb->rx_q))
- {
- if (p_pkt->event != OBX_BAD_SM_EVT)
- {
- obx_cl_proc_pkt (p_cb, p_pkt);
- }
- else
- {
- OBX_TRACE_ERROR0("bad SM event" );
- }
- }
- else if (p_pkt->event != OBX_BAD_SM_EVT)
- {
- GKI_enqueue (&p_pcb->rx_q, p_pkt);
- if (p_pcb->rx_q.count > obx_cb.max_rx_qcount)
- {
- p_pcb->stopped = TRUE;
- PORT_FlowControl(p_pcb->port_handle, FALSE);
- }
- }
- } /* while received a packet */
- } /* PORT_EV_RXCHAR */
-
- if (p_evt->code & PORT_EV_FC)
- {
- if (p_evt->code & PORT_EV_FCS)
- {
- OBX_TRACE_EVENT0("cl flow control event - FCS SET ----" );
- obx_csm_event(p_cb, OBX_FCS_SET_CEVT, NULL);
- }
- } /* PORT_EV_FC */
-}
-#endif
-
-#if (OBX_SERVER_INCLUDED == TRUE)
-/*******************************************************************************
-** Function obx_build_dummy_rsp
-** Description make up a dummy response if the app does not call response API
-** yet and AbortRsp is called
-*******************************************************************************/
-BT_HDR * obx_build_dummy_rsp(tOBX_SR_SESS_CB *p_scb, UINT8 rsp_code)
-{
- BT_HDR *p_pkt;
- UINT8 *p;
- UINT16 size = 3;
-
- p_pkt = OBX_HdrInit(p_scb->ll_cb.comm.handle, OBX_CMD_POOL_SIZE);
- p = (UINT8 *)(p_pkt+1)+p_pkt->offset+p_pkt->len;
- *p++ = (rsp_code|OBX_FINAL);
- if (p_scb->conn_id)
- {
- size += 5;
- UINT16_TO_BE_STREAM(p, size);
- *p++ = OBX_HI_CONN_ID;
- UINT32_TO_BE_STREAM(p, p_scb->conn_id);
- }
- else
- {
- UINT16_TO_BE_STREAM(p, size);
- }
- p_pkt->len = size;
- p_pkt->event = OBX_PUT_RSP_EVT; /* or OBX_GET_RSP_EVT: for tracing purposes */
- return p_pkt;
-}
-
-/*******************************************************************************
-** Function obx_add_port
-** Description check if this server has aother un-used port to open
-**
-**
-** Returns void
-*******************************************************************************/
-void obx_add_port(tOBX_HANDLE obx_handle)
-{
- tOBX_SR_CB * p_cb = obx_sr_get_cb(obx_handle);
- tOBX_SR_SESS_CB *p_scb, *p_scb0;
- int xx;
- tOBX_STATUS status = OBX_NO_RESOURCES;
- BOOLEAN found;
-
- OBX_TRACE_DEBUG1("obx_add_port handle:0x%x", obx_handle );
- if (p_cb && p_cb->scn)
- {
- OBX_TRACE_DEBUG2("num_sess:%d scn:%d", p_cb->num_sess, p_cb->scn );
- p_scb0 = &obx_cb.sr_sess[p_cb->sess[0]-1];
- found = FALSE;
- /* find an RFCOMM port that is not connected yet */
- for (xx=0; xx < p_cb->num_sess && p_cb->sess[xx]; xx++)
- {
- p_scb = &obx_cb.sr_sess[p_cb->sess[xx]-1];
- OBX_TRACE_DEBUG3("[%d] id:0x%x, state:%d", xx, p_scb->ll_cb.comm.id, p_scb->state );
-
- if (p_scb->ll_cb.comm.p_send_fn == (tOBX_SEND_FN *)obx_rfc_snd_msg
- && p_scb->state == OBX_SS_NOT_CONNECTED)
- {
- found = TRUE;
- break;
- }
- }
-
- if (!found)
- {
- for (xx=0; xx < p_cb->num_sess && p_cb->sess[xx]; xx++)
- {
- p_scb = &obx_cb.sr_sess[p_cb->sess[xx]-1];
- OBX_TRACE_DEBUG2("[%d] port_handle:%d", xx, p_scb->ll_cb.port.port_handle );
- if (!p_scb->ll_cb.comm.id)
- {
- status = obx_open_port(&p_scb->ll_cb.port, BT_BD_ANY, p_cb->scn);
- if (status == OBX_SUCCESS)
- {
- p_scb->ll_cb.port.rx_mtu= p_scb0->ll_cb.port.rx_mtu;
- p_scb->state = OBX_SS_NOT_CONNECTED;
- }
- break;
- }
- }
- }
- }
-}
-
-/*******************************************************************************
-** Function obx_sr_proc_evt
-** Description This is called to process BT_EVT_TO_OBX_SR_MSG
-** Process events from RFCOMM. Get the associated server control
-** block. If this is a request packet, stop timer. Find the
-** associated API event and save it in server control block
-** (api_evt). Fill the event parameter (param).
-** Call obx_ssm_event() with the associated events.If the associated
-** control block is not found (maybe the target header does not
-** match) or busy, compose a service unavailable response and call
-** obx_rfc_snd_msg().
-*******************************************************************************/
-void obx_sr_proc_evt(tOBX_PORT_EVT *p_evt)
-{
- tOBX_SR_SESS_CB *p_scb;
- BT_HDR *p_pkt;
- tOBX_RX_HDR *p_rxh;
- tOBX_PORT_CB *p_pcb = p_evt->p_pcb;
-
-
- OBX_TRACE_DEBUG2("obx_sr_proc_evt handle: 0x%x, port_handle:%d", p_evt->p_pcb->handle, p_evt->p_pcb->port_handle);
- if (p_pcb->handle == 0 || p_pcb->p_send_fn != (tOBX_SEND_FN*)obx_rfc_snd_msg)
- return;
-
- if ((p_scb = obx_sr_get_scb(p_pcb->handle)) == NULL)
- {
- /* probably already close the port and deregistered from OBX */
- OBX_TRACE_ERROR1("Could not find control block for handle: 0x%x", p_pcb->handle);
- return;
- }
-
- if (p_evt->code & PORT_EV_CONNECTED)
- {
- p_scb->ll_cb.port.tx_mtu = OBX_MIN_MTU;
- obx_start_timer(&p_scb->ll_cb.comm);
- /* Get the Bd_Addr */
- PORT_CheckConnection (p_scb->ll_cb.port.port_handle,
- p_scb->param.conn.peer_addr,
- NULL);
- memcpy(p_scb->peer_addr, p_scb->param.conn.peer_addr, BD_ADDR_LEN);
- }
-
- if (p_evt->code & PORT_EV_CONNECT_ERR)
- {
- obx_ssm_event(p_scb, OBX_PORT_CLOSE_SEVT, NULL);
- return;
- } /* PORT_EV_CONNECT_ERR */
-
- if (p_evt->code & PORT_EV_RXCHAR)
- {
- while( (p_pkt = obx_read_data(p_pcb, obx_verify_request)) != NULL)
- {
- p_rxh = (tOBX_RX_HDR *)(p_pkt + 1);
- p_pkt->event = obx_sm_evt_to_api_evt[p_rxh->sm_evt];
- if (GKI_queue_is_empty(&p_pcb->rx_q))
- {
- if (p_pkt->event != OBX_BAD_SM_EVT)
- {
- obx_sr_proc_pkt (p_scb, p_pkt);
- }
- else
- {
- OBX_TRACE_ERROR0("bad SM event" );
- }
- }
- else
- {
- GKI_enqueue (&p_pcb->rx_q, p_pkt);
- if (p_pcb->rx_q.count > obx_cb.max_rx_qcount)
- {
- p_pcb->stopped = TRUE;
- PORT_FlowControl(p_pcb->port_handle, FALSE);
- }
- }
- } /* while a packet */
- } /* PORT_EV_RXCHAR */
-
- /* The server does not need to handle this event
- */
- if (p_evt->code & PORT_EV_TXEMPTY)
- {
- obx_ssm_event(p_scb, OBX_TX_EMPTY_SEVT, NULL);
- }
-
- if (p_evt->code & PORT_EV_FC)
- {
- if (p_evt->code & PORT_EV_FCS)
- {
- OBX_TRACE_EVENT0("sr flow control event - FCS SET ----" );
- obx_ssm_event(p_scb, OBX_FCS_SET_SEVT, NULL);
- }
- } /* PORT_EV_FC */
-}
-#endif /* OBX_SERVER_INCLUDED */
-
-/*******************************************************************************
-** Function obx_open_port
-** Description Call RFCOMM_CreateConnection() to get port_handle.
-** Call PORT_SetEventCallback() with given callback.
-** Call PORT_SetEventMask() with given event mask. Return port handle.
-** Returns port handle
-*******************************************************************************/
-tOBX_STATUS obx_open_port(tOBX_PORT_CB *p_pcb, const BD_ADDR bd_addr, UINT8 scn)
-{
- tOBX_STATUS status = OBX_SUCCESS; /* successful */
- UINT16 port_rc;
- BOOLEAN is_server = (p_pcb->handle & OBX_CL_HANDLE_MASK)?FALSE:TRUE;
- UINT16 max_mtu = OBX_MAX_MTU;
-
- OBX_TRACE_DEBUG2("obx_open_port rxmtu:%d, cbmtu:%d", p_pcb->rx_mtu, max_mtu );
-
- /* clear buffers from previous connection */
- obx_free_buf ((tOBX_LL_CB*)p_pcb);
-
- /* make sure the MTU is in registered range */
- if (p_pcb->rx_mtu > max_mtu)
- p_pcb->rx_mtu = max_mtu;
- if (p_pcb->rx_mtu < OBX_MIN_MTU)
- p_pcb->rx_mtu = OBX_MIN_MTU;
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
- /* There's a remote chance that an error can occur in L2CAP before the handle
- * before the handle can be assigned (server side only). We will save the
- * client control block while the handle is not known */
- if (!is_server)
- {
- obx_cb.p_temp_pcb = p_pcb;
- }
-#endif
-
- port_rc = RFCOMM_CreateConnection ( UUID_PROTOCOL_OBEX, scn,
- is_server, (UINT16)(p_pcb->rx_mtu+1), (BD_ADDR_PTR)bd_addr,
- &p_pcb->port_handle, obx_rfc_mgmt_cback);
-
- OBX_TRACE_DEBUG3("obx_open_port rxmtu:%d, port_handle:%d, port.handle:0x%x",
- p_pcb->rx_mtu, p_pcb->port_handle, p_pcb->handle );
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
- if (!is_server)
- {
- obx_cb.p_temp_pcb = NULL;
- }
-#endif
-
- if (port_rc == PORT_SUCCESS)
- {
- obx_cb.hdl_map[p_pcb->port_handle - 1] = p_pcb->handle;
- PORT_SetEventCallback (p_pcb->port_handle, obx_rfc_cback);
- PORT_SetEventMask (p_pcb->port_handle, OBX_PORT_EVENT_MASK);
- p_pcb->p_send_fn = (tOBX_SEND_FN *)obx_rfc_snd_msg;
- p_pcb->p_close_fn = obx_close_port;
- }
- else
- {
- status = OBX_NO_RESOURCES;
- }
-
- return status;
-}
-
-
-/*******************************************************************************
-** Function obx_close_port
-** Description Clear the port event mask and callback. Close the port.
-** Returns void
-*******************************************************************************/
-void obx_close_port(UINT16 port_handle)
-{
- RFCOMM_RemoveConnection(port_handle);
-}
-
-/*******************************************************************************
-** Function obx_rfc_snd_msg
-** Description Call PORT_WriteData() to send an OBEX message to peer. If
-** all data is sent, free the GKI buffer that holds
-** the OBEX message. If only portion of data is
-** sent, adjust the BT_HDR for PART state.
-** Returns TRUE if all data is sent
-*******************************************************************************/
-BOOLEAN obx_rfc_snd_msg(tOBX_PORT_CB *p_pcb)
-{
- BOOLEAN status = FALSE;
- UINT16 bytes_written = 0;
-
- obx_stop_timer(&p_pcb->tle);
- PORT_WriteData(p_pcb->port_handle, ((char*)(p_pcb->p_txmsg + 1)) + p_pcb->p_txmsg->offset,
- p_pcb->p_txmsg->len, &bytes_written);
-
- obx_start_timer ((tOBX_COMM_CB *)p_pcb);
-
- if (bytes_written == p_pcb->p_txmsg->len)
- {
- GKI_freebuf(p_pcb->p_txmsg);
- p_pcb->p_txmsg = NULL;
- status = TRUE;
- }
- else
- {
- /* packet not completely written to RFCOMM */
- p_pcb->p_txmsg->offset += bytes_written;
- p_pcb->p_txmsg->len -= bytes_written;
- }
-
- return status;
-}
diff --git a/stack/obx/obx_sact.c b/stack/obx/obx_sact.c
deleted file mode 100644
index 1602752..0000000
--- a/stack/obx/obx_sact.c
+++ /dev/null
@@ -1,1519 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_sact.c
-**
-** File: OBEX Server State Machine Action Functions
-**
-** Copyright (c) 2003-2012, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-#include <bt_target.h>
-
-#include "btu.h"
-#include "obx_int.h"
-#include "btm_api.h"
-
-/*******************************************************************************
-** Function obx_sa_snd_rsp
-** Description Call p_send_fn() to send the OBEX message to the peer.
-** Start timer. Return NULL state.If data is partially sent, set
-** next_state in port control block. Return PART state.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_snd_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = p_scb->state;
- UINT8 rsp_code = OBX_RSP_DEFAULT;
- tOBX_SR_CB *p_cb;
- BOOLEAN not_cong = TRUE;
-
- obx_access_rsp_code(p_pkt, &rsp_code);
- p_scb->cur_op = OBX_REQ_ABORT;
-
-
- p_scb->ll_cb.comm.p_txmsg = p_pkt;
- rsp_code &= ~OBX_FINAL;
- /* Get and Put operation may need to adjust the state*/
- if (rsp_code != OBX_RSP_CONTINUE )
- {
- if (p_scb->state == OBX_SS_GET_TRANSACTION ||
- p_scb->state == OBX_SS_PUT_SRM ||
- p_scb->state == OBX_SS_GET_SRM ||
- p_scb->state == OBX_SS_PUT_TRANSACTION)
- {
- state = OBX_SS_CONNECTED;
- /* the SRM bits can not be cleared here, if aborting */
- if ((p_scb->srm &OBX_SRM_ABORT) == 0)
- p_scb->srm &= OBX_SRM_ENABLE;
- }
- }
-
- OBX_TRACE_DEBUG2("obx_sa_snd_rsp sess_st:%d, event:%d", p_scb->sess_st, p_pkt->event);
- if ((p_scb->sess_st == OBX_SESS_ACTIVE) && (p_pkt->event != (OBX_SESSION_CFM_SEVT + 1)))
- {
- p_scb->ssn++;
- }
-
- if (p_scb->ll_cb.comm.p_send_fn(&p_scb->ll_cb) == FALSE)
- {
- p_scb->next_state = state;
- state = OBX_SS_PARTIAL_SENT;
- }
- else if (p_scb->state == OBX_SS_GET_SRM)
- {
- if (((p_scb->srmp & OBX_SRMP_WAIT) == 0) && (rsp_code == OBX_RSP_CONTINUE))
- {
- if (p_scb->ll_cb.comm.p_send_fn == (tOBX_SEND_FN *)obx_l2c_snd_msg)
- {
- OBX_TRACE_DEBUG1("obx_sa_snd_rsp cong:%d", p_scb->ll_cb.l2c.cong);
- if (p_scb->ll_cb.l2c.cong)
- {
- not_cong = FALSE;
- }
- }
-
- /* do not need to wait
- - fake a get request event, so the profile would issue another GET response */
- if (not_cong)
- {
- p_cb = obx_sr_get_cb(p_scb->handle);
- (p_cb->p_cback) (p_scb->ll_cb.comm.handle, OBX_GET_REQ_EVT, p_scb->param, NULL);
- }
- }
- p_scb->srmp &= ~OBX_SRMP_WAIT;
- }
- else if (p_scb->sess_st == OBX_SESS_SUSPENDING)
- {
- p_scb->ssn++;
- p_scb->param.sess.ssn = p_scb->ssn;
- p_scb->param.sess.nssn = p_scb->ssn;
- p_scb->sess_st = OBX_SESS_SUSPEND;
- p_scb->sess_info[OBX_SESSION_INFO_ST_IDX] = p_scb->state;
- state = OBX_SS_SESS_INDICATED;
- p_scb->api_evt = OBX_SESSION_REQ_EVT;
- }
-
- return state;
-}
-
-/*******************************************************************************
-** Function obx_sa_snd_part
-** Description Call p_send_fn() to send the left-over OBEX message to the
-** peer. Start timer. If all the data is sent, call obx_ssm_event()
-** with STATE event to next_state in the port control block.
-** If (p_saved), call obx_ssm_event() to process the saved request.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_snd_part(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_SS_NULL;
- UINT8 rsp_code = OBX_RSP_DEFAULT;
- tOBX_SR_CB *p_cb;
-
- obx_access_rsp_code(p_scb->ll_cb.comm.p_txmsg , &rsp_code);
- if (p_scb->ll_cb.comm.p_send_fn(&p_scb->ll_cb) == TRUE)
- {
- obx_ssm_event(p_scb, OBX_STATE_SEVT, NULL);
- if (p_scb->p_next_req)
- {
- p_pkt = p_scb->p_next_req;
- obx_access_rsp_code(p_pkt , &rsp_code);
- p_scb->p_next_req = NULL;
- p_scb->api_evt = (tOBX_EVENT)p_pkt->event;
- obx_ssm_event(p_scb, (tOBX_SR_EVENT)(p_pkt->event-1), p_pkt);
- }
-
- OBX_TRACE_DEBUG3("obx_sa_snd_part state:%d, srm:0x%x, rsp_code:0x%x", p_scb->state, p_scb->srm, rsp_code);
- if (p_scb->state == OBX_SS_GET_SRM)
- {
- rsp_code &= ~OBX_FINAL;
- if (((p_scb->srm & OBX_SRM_WAIT) == 0) && (rsp_code == OBX_RSP_CONTINUE))
- {
- /* do not need to wait
- - fake a get request event, so the profile would issue another GET response */
- p_cb = obx_sr_get_cb(p_scb->handle);
- (p_cb->p_cback) (p_scb->ll_cb.comm.handle, OBX_GET_REQ_EVT, p_scb->param, NULL);
- }
- }
- }
- return state;
-}
-
-/*******************************************************************************
-** Function obx_sa_abort_rsp
-** Description Send an abort response.
-** If Put/Get response has not been sent yet,
-** send it before the abort response.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_abort_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_SS_NULL;
- BT_HDR *p_dummy;
- UINT8 rsp_code = OBX_RSP_CONTINUE;
-
- if (p_scb->cur_op != OBX_REQ_ABORT && ((p_scb->srm & OBX_SRM_ENGAGE) == 0))
- {
- /* if we have not respond to an op yet, send a dummy response */
- if (p_scb->cur_op == (rsp_code|OBX_REQ_PUT) )
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- p_dummy = obx_build_dummy_rsp(p_scb, rsp_code);
- obx_sa_snd_rsp(p_scb, p_dummy);
- }
-
- /* clear the SRM bits; leave only the enabled bit */
- p_scb->srm &= OBX_SRM_ENABLE;
- state = obx_sa_snd_rsp(p_scb, p_pkt);
- return state;
-}
-
-/*******************************************************************************
-** Function obx_sa_op_rsp
-** Description Send response for Put/Get when Abort request is already received
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_op_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_SS_NULL;
- if (p_scb->cur_op != OBX_REQ_ABORT)
- state = obx_sa_snd_rsp(p_scb, p_pkt);
-#if (BT_USE_TRACES == TRUE)
- else
- OBX_TRACE_WARNING0("OBX is not waiting for a rsp API!!");
-#endif
- return state;
-}
-
-/*******************************************************************************
-** Function obx_verify_target
-** Description Verify that target header or connection ID is correct.
-** Make sure that they do not both exist
-*******************************************************************************/
-static UINT8 obx_verify_target(tOBX_SR_CB *p_cb, tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- UINT16 len = 0;
- UINT8 rsp_code = OBX_RSP_SERVICE_UNAVL;
- UINT32 conn_id = 0;
- UINT8 *p_target = NULL;
-
- OBX_Read4ByteHdr(p_pkt, OBX_HI_CONN_ID, &conn_id);
-/* Coverity:
-Event unchecked_value: Return value of "OBX_ReadTargetHdr" is not checked
-Coverity: FALSE-POSITIVE error from Coverity tool. Please do NOT remove following comment. */
-/* coverity[unchecked_value] False-positive: If target headser does not exist,
- p_target would remain the default value/NULL and len would be set to 0.
- There's no need to check the return value of OBX_ReadTargetHdr
-*/
- OBX_ReadTargetHdr(p_pkt, &p_target, &len, 0);
-
- if (p_cb->target.len)
- {
- /* directed connection: make sure the connection ID matches */
- if ( conn_id && conn_id == p_scb->conn_id )
- rsp_code = OBX_RSP_OK;
-
- if (p_cb->target.len == OBX_DEFAULT_TARGET_LEN)
- {
- /* the user verify target (cases like BIP that has multiple targets) */
- rsp_code = OBX_RSP_OK;
- }
- else if ( len == p_cb->target.len && p_target &&
- memcmp(p_cb->target.target, p_target, p_cb->target.len) == 0)
- {
- rsp_code = OBX_RSP_OK;
- }
- }
- else
- {
- /* no target - request to inbox, like OPP */
- if (conn_id == 0 && len == 0)
- {
- if (p_scb->ll_cb.comm.tx_mtu < OBX_MIN_MTU)
- rsp_code = OBX_RSP_FORBIDDEN;
- else
- rsp_code = OBX_RSP_OK;
- }
- }
-
- /* target header and connection ID are not supposed to exist in the same packet*/
- if (conn_id != 0 && p_target != NULL)
- rsp_code = OBX_RSP_BAD_REQUEST;
-
- OBX_TRACE_DEBUG3("obx_verify_target rsp: %x, id:%x, code:%x",
- rsp_code, conn_id, ((tOBX_RX_HDR *)(p_pkt + 1))->code);
- if (rsp_code != OBX_RSP_OK)
- p_pkt->event = OBX_CONNECT_RSP_EVT;
- return rsp_code;
-}
-
-/*******************************************************************************
-** Function obx_conn_rsp
-** Description Called by OBX_ConnectRsp() and obx_sa_connect_ind() to compose
-** a connect response packet.
-*******************************************************************************/
-BT_HDR * obx_conn_rsp(tOBX_SR_CB *p_cb, tOBX_SR_SESS_CB *p_scb, UINT8 rsp_code, BT_HDR *p_pkt)
-{
- UINT8 msg[OBX_HDR_OFFSET + OBX_MAX_CONN_HDR_EXTRA];
- UINT8 *p = msg;
-
- /* response packets always have the final bit set */
- *p++ = (rsp_code | OBX_FINAL);
- p += OBX_PKT_LEN_SIZE;
-
- *p++ = OBX_VERSION;
- *p++ = OBX_CONN_FLAGS;
- UINT16_TO_BE_STREAM(p, p_scb->ll_cb.comm.rx_mtu);
-
- /* add session sequence number, if session is active */
- if (p_scb->sess_st == OBX_SESS_ACTIVE)
- {
- *p++ = OBX_HI_SESSION_SN;
- *p++ = (p_scb->ssn+1);
- }
-
- if (p_scb->conn_id && rsp_code == OBX_RSP_OK)
- {
- *p++ = OBX_HI_CONN_ID;
- UINT32_TO_BE_STREAM(p, p_scb->conn_id);
- }
-
- p_pkt = obx_sr_prepend_msg(p_pkt, msg, (UINT16)(p - msg) );
-
- /* If the target is registered to server and the WHO headers not in the packet
- * add WHO header here */
- p_pkt->event = OBX_CONNECT_RSP_EVT;
- if (p_cb->target.len && p_cb->target.len != OBX_DEFAULT_TARGET_LEN &&
- OBX_CheckHdr(p_pkt, OBX_HI_WHO) == NULL)
- {
- OBX_AddByteStrHdr(p_pkt, OBX_HI_WHO, p_cb->target.target, p_cb->target.len);
- /* adjust the packet len */
- obx_adjust_packet_len(p_pkt);
- }
- return p_pkt;
-}
-
-/*******************************************************************************
-** Function obx_sa_wc_conn_ind
-** Description Connect Req is received when waiting for the port to close
-** Call callback with OBX_CLOSE_IND_EVT to clean up the profiles
-** then call obx_sa_connect_ind to process the connect req.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_wc_conn_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_EVT_PARAM param;
- tOBX_SR_CB *p_cb = obx_sr_get_cb(p_scb->handle);
-
- obx_stop_timer(&p_scb->ll_cb.comm.tle);
- memset(&param, 0, sizeof(tOBX_EVT_PARAM));
- if (p_cb && p_cb->p_cback)
- (*p_cb->p_cback)(p_scb->ll_cb.comm.handle, OBX_CLOSE_IND_EVT, param, NULL);
- obx_sa_connect_ind(p_scb, p_pkt);
- return OBX_SS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_sa_connect_ind
-** Description Save peer MTU in the server control block.If the server does not
-** register authentication, call callback with OBX_CONNECT_REQ_EVT
-** and the MTU from the request message. Return NULL state.
-** If authenticate, compose an unauthorized response, and call
-** obx_sa_snd_rsp() to send it to the client. Return WAIT_AUTH state.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_connect_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_SS_NULL;
- UINT8 rsp_code = OBX_RSP_SERVICE_UNAVL;
- tOBX_SR_CB *p_cb = obx_sr_get_cb(p_scb->handle);
- UINT8 *p;
- tOBX_EVT_PARAM param; /* The event parameter. */
-
- /* clear the SRM bits; leave only the enabled bit */
- p_scb->srm &= OBX_SRM_ENABLE;
-
- OBX_TRACE_DEBUG0("obx_sa_connect_ind");
- p_scb->api_evt = OBX_NULL_EVT;
-
- /* verify that the connect request is OK */
- rsp_code = obx_verify_target(p_cb, p_scb, p_pkt);
- if (rsp_code == OBX_RSP_OK)
- {
- if (p_cb->target.len && p_scb->conn_id == 0)
- {
- /* if Connection ID is used for this connection and none assigned yet,
- * - assign one */
- p_scb->conn_id = obx_sr_get_next_conn_id();
- OBX_TRACE_DEBUG1(" **** obx_sr_get_next_conn_id (0x%08x)", p_scb->conn_id);
- }
-
- /* tx_mtu is processed in obx_sr_proc_evt() */
- if (p_cb->p_auth)
- {
- /* If client challenge us first, and the server registers for authentication:
- * remove the authentication headers and challenge it back */
- /* send unauthorize response */
- p_pkt = obx_unauthorize_rsp(p_cb, p_scb, p_pkt);
- state = OBX_SS_WAIT_AUTH;
- }
- else
- {
- if (OBX_CheckHdr(p_pkt, OBX_HI_CHALLENGE) != NULL)
- {
- /* If client challenge us first, and the server does not register for authentication:
- * report the challenge */
- p_scb->p_saved_msg = obx_dup_pkt(p_pkt);
- state = OBX_SS_AUTH_INDICATED;
- p_scb->api_evt = OBX_PASSWORD_EVT;
- }
- else
- {
- if (p_scb->sess_st == OBX_SESS_ACTIVE)
- {
- p = &p_scb->sess_info[OBX_SESSION_INFO_ID_IDX];
- UINT32_TO_BE_STREAM(p, p_scb->conn_id);
- param.sess.p_sess_info = p_scb->sess_info;
- param.sess.sess_op = OBX_SESS_OP_CREATE;
- param.sess.sess_st = p_scb->sess_st;
- param.sess.nssn = p_scb->param.ssn;
- param.sess.ssn = p_scb->param.ssn;
- param.sess.obj_offset = 0;
- p = &p_scb->sess_info[OBX_SESSION_INFO_MTU_IDX];
- UINT16_TO_BE_STREAM(p, p_scb->param.conn.mtu);
- memcpy(param.sess.peer_addr, p_scb->peer_addr, BD_ADDR_LEN);
- (*p_cb->p_cback)(p_scb->ll_cb.comm.handle, OBX_SESSION_REQ_EVT, param, NULL);
- }
- (*p_cb->p_cback)(p_scb->ll_cb.comm.handle, OBX_CONNECT_REQ_EVT, p_scb->param, p_pkt);
- }
- }
- }
- else
- {
- /* bad target or connection ID - reject the request */
- rsp_code |= OBX_FINAL;
- obx_access_rsp_code(p_pkt, &rsp_code);
- state = OBX_SS_NOT_CONNECTED;
- }
-
- if (state != OBX_SS_NULL && state != OBX_SS_AUTH_INDICATED)
- {
- /* each port has its own credit.
- * It's very unlikely that we can be flow controlled here */
- obx_sa_snd_rsp(p_scb, p_pkt);
- }
-
- return state;
-}
-
-/*******************************************************************************
-** Function obx_sa_auth_ind
-** Description Save peer MTU and the OBEX message in the server control block.
-** Call callback function with OBX_PASSWORD_EVT.
-** Note: This action function is only valid when MD5 is included
-** Leave this as a stub function to avoid altering the state machine
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_auth_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_SS_NULL;
- UINT8 rsp_code;
- tOBX_SR_CB *p_cb = obx_sr_get_cb(p_scb->handle);
-
- p_scb->api_evt = OBX_NULL_EVT;
- rsp_code = obx_verify_target(p_cb, p_scb, p_pkt);
-
- if (rsp_code == OBX_RSP_OK)
- {
- /* tx_mtu is processed in obx_sr_proc_evt() */
- if (OBX_CheckHdr(p_pkt, OBX_HI_AUTH_RSP) == NULL)
- {
- /* we are expecting authentication response in this state.
- * if none is received, reject the request */
- p_pkt = obx_unauthorize_rsp(p_cb, p_scb, p_pkt);
- state = OBX_SS_NOT_CONNECTED;
- }
- else
- {
- /* the client sends authentication response.
- * save a copy in the control block. Verify it when OBX_Password() is issued */
- p_scb->p_saved_msg = obx_dup_pkt(p_pkt);
- (*p_cb->p_cback)(p_scb->ll_cb.comm.handle, OBX_PASSWORD_EVT, p_scb->param, p_pkt);
- }
- }
- else
- {
- /* bad target or connection ID - reject the request */
- rsp_code |= OBX_FINAL;
- obx_access_rsp_code(p_pkt, &rsp_code);
- state = OBX_SS_NOT_CONNECTED;
- }
-
- if (state != OBX_SS_NULL)
- {
- /* each port has its own credit.
- * It's very unlikely that we can be flow controlled here */
- obx_sa_snd_rsp(p_scb, p_pkt);
- }
-
- return state;
-}
-
-/*******************************************************************************
-** Function obx_sa_connect_rsp
-** Description obx_sa_snd_rsp().If(p_saved), free the OBEX message.If OK
-** response, return NULL state.If unauthorized response, return
-** WAIT_AUTH state.If other fail response, return NOT_CONN state.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_connect_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- UINT8 rsp_code = OBX_RSP_DEFAULT;
- tOBX_SR_STATE state = p_scb->state;
-
- obx_access_rsp_code(p_pkt, &rsp_code);
-
- if (p_scb->p_saved_msg)
- {
- GKI_freebuf(p_scb->p_saved_msg);
- p_scb->p_saved_msg = NULL;
- }
-
- if ( rsp_code == (OBX_RSP_UNAUTHORIZED | OBX_FINAL) &&
- OBX_CheckHdr(p_pkt, OBX_HI_CHALLENGE) != NULL)
- {
- state = OBX_SS_WAIT_AUTH;
- }
- else if (rsp_code != (OBX_RSP_OK | OBX_FINAL) )
- state = OBX_SS_NOT_CONNECTED;
-
- /* each port has its own credit.
- * It's very unlikely that we can be flow controlled here */
- obx_sa_snd_rsp(p_scb, p_pkt);
-
- return state;
-}
-
-/*******************************************************************************
-** Function obx_sa_connection_error
-** Description Stop timer. Reopen transport. Call callback function with
-** OBX_CLOSE_IND_EVT.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_connection_error(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_EVT_PARAM param;
- tOBX_SR_CB *p_cb = obx_sr_get_cb(p_scb->handle);
- tOBX_SR_CBACK *p_cback = NULL;
- tOBX_SR_STATE save_state;
-
- OBX_TRACE_DEBUG4("obx_sa_connection_error tx_mtu: %d, sess_st:%d state:%d, prev_state:%d",
- p_scb->ll_cb.comm.tx_mtu, p_scb->sess_st, p_scb->state, p_scb->prev_state);
-
- if (p_cb)
- {
- p_cback = p_cb->p_cback;
- memset(&param, 0, sizeof(tOBX_EVT_PARAM));
- }
-
- /* clear buffers from previous connection */
- obx_free_buf (&p_scb->ll_cb);
-
- if (p_scb->sess_st == OBX_SESS_ACTIVE)
- {
- /* The transport is interrupted while a reliable session is active:
- * report a suspend event fot application to save the information in NV */
- save_state = p_scb->prev_state;
- p_scb->sess_info[OBX_SESSION_INFO_SRM_IDX] = p_scb->srm;
- param.sess.p_sess_info = p_scb->sess_info;
- param.sess.sess_op = OBX_SESS_OP_TRANSPORT;
- param.sess.sess_st = p_scb->sess_st;
- param.sess.nssn = p_scb->ssn;
- param.sess.ssn = p_scb->ssn;
- param.sess.obj_offset = 0;
- param.sess.timeout = OBX_SESS_TIMEOUT_VALUE;
- if (save_state == OBX_SS_PARTIAL_SENT)
- save_state = p_scb->next_state;
-
- if ((p_scb->srm & OBX_SRM_ENGAGE) == 0)
- {
- /* SRM is not engaged.
- * When the session is resume, client needs to send the request first,
- * the save ssm state may need to be adjusted */
- if (save_state == OBX_SS_PUT_INDICATED)
- {
- save_state = OBX_SS_PUT_TRANSACTION;
- }
- else if (save_state == OBX_SS_GET_INDICATED)
- {
- save_state = OBX_SS_GET_TRANSACTION;
- }
- }
- p_scb->sess_info[OBX_SESSION_INFO_ST_IDX] = save_state;
- OBX_TRACE_DEBUG2("saved state:0x%x, srm:0x%x", save_state, p_scb->sess_info[OBX_SESSION_INFO_SRM_IDX]);
- memcpy(param.sess.peer_addr, p_scb->peer_addr, BD_ADDR_LEN);
- p_scb->sess_st = OBX_SESS_NONE;
- if (p_cback)
- (*p_cback)(p_scb->ll_cb.comm.handle, OBX_SESSION_INFO_EVT, param, NULL);
- }
- else if (p_scb->sess_st == OBX_SESS_CLOSE || p_scb->state == OBX_SS_NOT_CONNECTED)
- p_scb->sess_st = OBX_SESS_NONE;
-
- if (p_scb->ll_cb.comm.tx_mtu != 0)
- {
- p_scb->ll_cb.comm.tx_mtu = 0;
- obx_stop_timer(&p_scb->ll_cb.comm.tle);
- p_scb->conn_id = 0;
- if (p_cback)
- (*p_cback)(p_scb->ll_cb.comm.handle, OBX_CLOSE_IND_EVT, param, p_pkt);
- }
-
- if (p_scb->ll_cb.comm.p_send_fn == (tOBX_SEND_FN *)obx_l2c_snd_msg)
- {
- p_scb->ll_cb.comm.id = 0; /* mark this port unused. */
- p_scb->srm &= OBX_SRM_ENABLE;
- obx_add_port (p_scb->handle);
- }
-
- return OBX_SS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_sa_close_port
-** Description Close transport. Start timer.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_close_port(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- if (p_pkt)
- GKI_freebuf(p_pkt);
- p_scb->ll_cb.comm.p_close_fn(p_scb->ll_cb.comm.id);
- obx_sr_free_scb(p_scb);
- obx_start_timer(&p_scb->ll_cb.comm);
- return OBX_SS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_sa_clean_port
-** Description Close transport and clean up api_evt if illegal obex message is
-** received.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_clean_port(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- p_scb->api_evt = OBX_NULL_EVT;
- return obx_sa_close_port(p_scb, p_pkt);
-}
-/*******************************************************************************
-** Function obx_sa_state
-** Description change state
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_state(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- return p_scb->next_state;
-}
-
-/*******************************************************************************
-** Function obx_sa_nc_to
-** Description Timer expires in not_conn state
-** if there is existing connections -> disconnect
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_nc_to(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- BD_ADDR bd_addr;
-
- obx_stop_timer(&p_scb->ll_cb.comm.tle);
- /* if there is existing connections -> disconnect */
- if (OBX_GetPeerAddr(p_scb->ll_cb.comm.handle, bd_addr) != 0)
- {
- p_scb->ll_cb.comm.p_close_fn(p_scb->ll_cb.comm.id);
- p_scb->conn_id = 0;
- /* wait for the conn err event to re-open the port */
- }
- return OBX_SS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_sa_save_req
-** Description When a request received from peer in PART state,
-** save the request for later processing
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_save_req(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- if (p_scb->p_next_req)
- {
- GKI_freebuf(p_scb->p_next_req);
- }
- p_scb->p_next_req = p_pkt;
- p_scb->api_evt = OBX_NULL_EVT;
- return OBX_SS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_sa_rej_req
-** Description Send bad request response when request comes in bad state
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_rej_req(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- UINT8 msg[OBX_HDR_OFFSET];
- UINT8 *p = msg;
-
- OBX_TRACE_DEBUG0( "obx_sa_rej_req" ) ;
- if (p_pkt)
- GKI_freebuf(p_pkt);
-
- /* response packets always have the final bit set */
- *p++ = (OBX_RSP_SERVICE_UNAVL | OBX_FINAL);
- p += OBX_PKT_LEN_SIZE;
-
- /* add session sequence number, if session is active */
- if (p_scb->sess_st == OBX_SESS_ACTIVE)
- {
- *p++ = OBX_HI_SESSION_SN;
- *p++ = (p_scb->ssn+1);
- }
-
- /* add connection ID, if needed */
- if (p_scb->conn_id)
- {
- *p++ = OBX_HI_CONN_ID;
- UINT32_TO_BE_STREAM(p, p_scb->conn_id);
- }
-
- p_pkt = obx_sr_prepend_msg(NULL, msg, (UINT16)(p - msg) );
- p_pkt->event = OBX_PUT_RSP_EVT; /* any response */
- p_scb->api_evt = OBX_NULL_EVT;
-
- return obx_sa_snd_rsp(p_scb, p_pkt);
-}
-
-/*******************************************************************************
-** Function obx_sa_get_ind
-** Description received a GET request from the client. Check if SRM is engaged.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_get_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_SS_NULL;
-
- if ((p_scb->srm & OBX_SRM_REQING) && (p_scb->srm & OBX_SRM_ENABLE))
- {
- state = OBX_CS_GET_SRM;
- }
-
- /* the GET request does not set the final bit.
- * Save this request, send response automatically and do not report the event */
- if ((!p_scb->param.get.final) && ((p_scb->srmp & OBX_SRMP_NONF_EVT) == 0))
- {
- p_scb->srmp |= OBX_SRMP_NONF;
- if (p_scb->p_saved_msg)
- GKI_freebuf(p_scb->p_saved_msg);
- p_scb->p_saved_msg = p_pkt;
- p_scb->api_evt = OBX_NULL_EVT;
- OBX_GetRsp(p_scb->ll_cb.comm.handle, OBX_RSP_CONTINUE, NULL);
- }
- return state;
-}
-
-/*******************************************************************************
-** Function obx_merge_get_req
-** Description merge the given 2 GET request packets and return the merged result
-*******************************************************************************/
-BT_HDR * obx_merge_get_req(BT_HDR *p_pkt1, BT_HDR *p_pkt2)
-{
- BT_HDR *p_ret = p_pkt1;
- UINT16 size, need;
- UINT8 *p1, *p2;
- UINT8 *p, pre_size = OBX_GET_HDRS_OFFSET;
-
- /* skip the connection ID header */
- p = (UINT8 *)(p_pkt2 + 1) + p_pkt2->offset;
- if (*p == OBX_HI_CONN_ID)
- pre_size += 5;
-
- need = p_pkt1->len + p_pkt2->len;
- if ((p_pkt2->len == pre_size) || (need >= OBX_LRG_DATA_POOL_SIZE))
- {
- GKI_freebuf (p_pkt2);
- return p_pkt1;
- }
-
- /* get rid of the GET request header - opcode(1) + packet len(2) (and maybe connection ID) before merging */
- p_pkt2->len -= pre_size;
- p_pkt2->offset += pre_size;
- size = GKI_get_buf_size(p_pkt1);
-
- if (size < need)
- {
- /* the original p_pkt1 is too small.
- * Allocate a bigger GKI buffer, p_ret, and copy p_pkt1 into p_ret */
- if (need < GKI_MAX_BUF_SIZE)
- {
- /* Use the largest general pool to allow challenge tags appendage */
- p_ret = (BT_HDR *)GKI_getbuf(GKI_MAX_BUF_SIZE);
- }
- else
- {
- p_ret = (BT_HDR *) GKI_getpoolbuf(OBX_LRG_DATA_POOL_ID);
- }
- memcpy (p_ret, p_pkt1, sizeof (BT_HDR));
- p_ret->offset = 0;
- p1 = (UINT8 *)(p_ret + 1);
- p2 = (UINT8 *)(p_pkt1 + 1) + p_pkt1->offset;
- memcpy (p1, p2, p_pkt1->len);
- GKI_freebuf (p_pkt1);
- }
-
- /* adjust the actualy packet length to reflect the combined packet and copy p_pkt2 into p_ret */
- p1 = (UINT8 *)(p_ret + 1) + p_ret->offset + 1;
- size = p_ret->len + p_pkt2->len;
- UINT16_TO_BE_STREAM(p1, size);
- p1 = (UINT8 *)(p_ret + 1) + p_ret->offset + p_ret->len;
- p2 = (UINT8 *)(p_pkt2 + 1) + p_pkt2->offset;
- p_ret->len = size;
- memcpy (p1, p2, p_pkt2->len);
- GKI_freebuf (p_pkt2);
-
- return p_ret;
-}
-
-/*******************************************************************************
-** Function obx_sa_get_req
-** Description
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_get_req(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_SS_NULL;
- tOBX_SR_CB *p_cb;
-
- OBX_TRACE_DEBUG2("obx_sa_get_req srmp:0x%x final:%d", p_scb->srmp, p_scb->param.get.final);
- if (p_scb->srmp & OBX_SRMP_NONF)
- {
- /* the GET request does not set the final bit yet.
- * merge this request, send response automatically and do not report the event */
- if (!p_scb->param.get.final)
- {
- p_scb->p_saved_msg = obx_merge_get_req(p_scb->p_saved_msg, p_pkt);
- p_scb->api_evt = OBX_NULL_EVT;
- OBX_GetRsp(p_scb->ll_cb.comm.handle, OBX_RSP_CONTINUE, NULL);
- }
- else
- {
- p_scb->srmp &= ~OBX_SRMP_NONF;
- p_pkt = obx_merge_get_req(p_scb->p_saved_msg, p_pkt);
- p_scb->p_saved_msg = NULL;
- p_scb->api_evt = OBX_NULL_EVT;
- p_cb = &obx_cb.server[p_scb->handle - 1];
- (p_cb->p_cback) (p_scb->ll_cb.comm.handle, OBX_GET_REQ_EVT, p_scb->param, p_pkt);
- memset(&p_scb->param, 0, sizeof (p_scb->param) );
- }
- }
-
- return state;
-}
-
-/*******************************************************************************
-** Function obx_sa_make_sess_id
-** Description compute the session id
-*******************************************************************************/
-static tOBX_STATUS obx_sa_make_sess_id (tOBX_SR_SESS_CB *p_scb, UINT8 *p_sess_info,
- tOBX_TRIPLET *p_triplet, UINT8 num_triplet)
-{
- UINT8 data[10];
- UINT8 ind;
- UINT8 *p;
-
- /* check the device address session parameter */
- ind = obx_read_triplet(p_triplet, num_triplet, OBX_TAG_SESS_PARAM_ADDR);
- OBX_TRACE_DEBUG2("addr ind:%d, num:%d", ind, num_triplet);
- if (ind == num_triplet || p_triplet[ind].len != BD_ADDR_LEN)
- {
- OBX_TRACE_ERROR0("No Device Addr parameter");
- return OBX_BAD_PARAMS;
- }
-
- if (memcmp (p_scb->peer_addr, p_triplet[ind].p_array, BD_ADDR_LEN) != 0)
- {
- OBX_TRACE_ERROR0("Bad Device Addr parameter");
- return OBX_BAD_PARAMS;
- }
-
- /* check the nonce session parameter */
- ind = obx_read_triplet(p_triplet, num_triplet, OBX_TAG_SESS_PARAM_NONCE);
- OBX_TRACE_DEBUG2("nonce ind:%d, num:%d", ind, num_triplet);
- if (ind == num_triplet || (p_triplet[ind].len < OBX_MIN_NONCE_SIZE) || (p_triplet[ind].len > OBX_NONCE_SIZE))
- {
- OBX_TRACE_ERROR0("No Nonce parameter");
- return OBX_BAD_PARAMS;
- }
- p = data;
- BTM_GetLocalDeviceAddr (p);
-
- /* compute the session ID */
- obx_session_id (p_sess_info, p_scb->peer_addr, p_triplet[ind].p_array, p_triplet[ind].len,
- data, &p_scb->sess_info[OBX_SESSION_ID_SIZE], OBX_LOCAL_NONCE_SIZE);
-
- return OBX_SUCCESS;
-}
-
-/*******************************************************************************
-** Function obx_sa_session_ind
-** Description process session request from client
-** when the session request is received is not OBX_SS_NOT_CONNECTED
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_session_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_TRIPLET triplet[OBX_MAX_SESS_PARAM_TRIP];
- UINT8 num = OBX_MAX_SESS_PARAM_TRIP, ind;
- UINT8 *p;
- tOBX_SR_CB *p_cb = obx_sr_get_cb(p_scb->handle);
- UINT8 rsp_code = OBX_RSP_FORBIDDEN;
- BOOLEAN now = FALSE;
-#if (BT_USE_TRACES == TRUE)
- tOBX_SESS_ST old_sess_st = p_scb->sess_st;
-#endif
- tOBX_EVENT old_api_evt;
- UINT32 obj_offset = 0;
- UINT8 ind_to;
- UINT32 timeout = OBX_INFINITE_TIMEOUT;
- tOBX_SR_STATE state = OBX_SS_NULL;
-
- OBX_TRACE_DEBUG0("obx_sa_session_ind");
- OBX_ReadTriplet(p_pkt, OBX_HI_SESSION_PARAM, triplet, &num);
- if (p_cb->nonce == 0)
- {
- OBX_TRACE_ERROR0("reliable session is not supported by this server");
- /* do not report the session_req_evt */
- p_scb->api_evt = OBX_NULL_EVT;
- obx_prepend_rsp_msg(p_scb->handle, OBX_SESSION_CFM_SEVT, OBX_RSP_NOT_IMPLEMENTED, NULL);
- return OBX_SS_NULL;
- }
- else if (num)
- {
- ind = obx_read_triplet(triplet, num, OBX_TAG_SESS_PARAM_SESS_OP);
- OBX_TRACE_DEBUG2("sess_op ind:%d, num:%d", ind, num);
- if ((ind != num) && (triplet[ind].len == OBX_LEN_SESS_PARAM_SESS_OP))
- {
- p = triplet[ind].p_array;
- p_scb->param.sess.sess_op = *p;
- OBX_TRACE_DEBUG1("sess_op :%d", *p);
- switch (*p)
- {
- case OBX_SESS_OP_CREATE:
- /* do not report the API event */
- p_scb->api_evt = OBX_NULL_EVT;
- /* the session is already active; reject with Service Unavailable */
- rsp_code = OBX_RSP_SERVICE_UNAVL;
- break;
-
- case OBX_SESS_OP_CLOSE:
- /* verify that the session ID matches an existing one. Otherwise, FORBIDDEN */
- if (p_scb->sess_st != OBX_SESS_NONE)
- {
- ind = obx_read_triplet(triplet, num, OBX_TAG_SESS_PARAM_SESS_ID);
- if (ind == num || triplet[ind].len != OBX_SESSION_ID_SIZE)
- break;
- if (memcmp (p_scb->sess_info, triplet[ind].p_array, OBX_SESSION_ID_SIZE) != 0)
- {
- /* bad session id */
- break;
- }
- /* must be closing a good session 0 send the response now */
- now = TRUE;
- rsp_code = OBX_RSP_OK;
- p_scb->sess_st = OBX_SESS_CLOSE;
- }
- break;
-
- case OBX_SESS_OP_SUSPEND:
- /* verify that a session is active. Otherwise, FORBIDDEN */
- if (p_scb->sess_st == OBX_SESS_ACTIVE)
- {
- rsp_code = OBX_RSP_OK;
- p_scb->sess_st = OBX_SESS_SUSPEND;
- p_scb->sess_info[OBX_SESSION_INFO_ST_IDX] = p_scb->prev_state;
- p_scb->sess_info[OBX_SESSION_INFO_SRM_IDX] = p_scb->srm;
- /* save the session state in a GKI buffer on OBX_SessionRsp */
- if (p_scb->prev_state == OBX_SS_PUT_INDICATED || p_scb->prev_state == OBX_SS_GET_INDICATED)
- {
- /* out of sequence suspend:
- * report the suspend event when the PutRsp or GetRsp is called
- * this would allow server to resume the session in the right state */
- p_scb->api_evt = OBX_NULL_EVT;
- p_scb->sess_st = OBX_SESS_SUSPENDING;
- state = p_scb->prev_state;
- }
- }
- break;
-
- case OBX_SESS_OP_RESUME:
- rsp_code = OBX_RSP_SERVICE_UNAVL;
- /* do not report the API event */
- p_scb->api_evt = OBX_NULL_EVT;
- break;
-
- case OBX_SESS_OP_SET_TIME:
- /* respond SET_TIME right away */
- now = TRUE;
-
- if (p_scb->sess_st == OBX_SESS_NONE)
- {
- rsp_code = OBX_RSP_FORBIDDEN;
- }
- break;
- }
- }
- }
- OBX_TRACE_DEBUG6("obx_sa_session_ind tx_mtu: %d, sess_st:%d->%d, rsp_code:0x%x, now:%d pstate:%d",
- p_scb->ll_cb.comm.tx_mtu, old_sess_st, p_scb->sess_st, rsp_code, now, p_scb->prev_state);
-
- if (rsp_code == OBX_RSP_OK)
- {
- obx_read_timeout (triplet, num, &timeout, &p_scb->sess_info[OBX_SESSION_INFO_TO_IDX]);
- }
-
- if ((rsp_code != OBX_RSP_OK) || now)
- {
- /* hold the original api_evt temporarily, so it's not reported at this obx_ssm_event */
- old_api_evt = p_scb->api_evt;
- p_scb->api_evt = OBX_NULL_EVT;
- /* send the response now */
- obx_prepend_rsp_msg(p_scb->handle, OBX_SESSION_CFM_SEVT, rsp_code, NULL);
- /* restore the api event */
- p_scb->api_evt = old_api_evt;
- }
- else
- {
- ind_to = obx_read_triplet(triplet, num, OBX_TAG_SESS_PARAM_SESS_OP);
- if ((ind_to != num) && (triplet[ind_to].len == OBX_TIMEOUT_SIZE))
- {
- p = triplet[ind_to].p_array;
- BE_STREAM_TO_UINT32(timeout, p);
- }
- p_scb->param.sess.p_sess_info = p_scb->sess_info;
- p_scb->param.sess.sess_st = p_scb->sess_st;
- p_scb->param.sess.ssn = p_scb->ssn;
- p_scb->param.sess.obj_offset = obj_offset;
- p_scb->param.sess.timeout = timeout;
- memcpy(p_scb->param.sess.peer_addr , p_scb->peer_addr, BD_ADDR_LEN);
-
- }
- return state;
-}
-
-/*******************************************************************************
-** Function obx_sa_sess_conn_ind
-** Description process session request from client
-** when the session request is received in OBX_SS_NOT_CONNECTED
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_sess_conn_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- UINT8 sess_info[OBX_SESSION_INFO_SIZE]; /* session id + local nonce */
- tOBX_TRIPLET triplet[OBX_MAX_SESS_PARAM_TRIP];
- UINT8 num = OBX_MAX_SESS_PARAM_TRIP, ind;
- UINT8 *p;
- tOBX_SR_CB *p_cb = obx_sr_get_cb(p_scb->handle);
- UINT8 rsp_code = OBX_RSP_FORBIDDEN;
- BOOLEAN now = FALSE;
-#if (BT_USE_TRACES == TRUE)
- tOBX_SESS_ST old_sess_st = p_scb->sess_st;
-#endif
- tOBX_SESS_OP sess_op = OBX_SESS_OP_CREATE;
- tOBX_EVENT old_api_evt;
- UINT32 obj_offset = 0;/* to report in evt param */
- UINT8 op_ssn;
- UINT8 num_trip = 0;
- BT_HDR *p_rsp = NULL;
- UINT8 data[12];
- UINT8 ind_to;
- UINT32 timeout = OBX_INFINITE_TIMEOUT;
- UINT32 offset = 0; /* if non-0, add to triplet on resume */
- tOBX_SPND_CB *p_spndcb;
- tOBX_EVT_PARAM param; /* The event parameter. */
-
- OBX_TRACE_DEBUG0("obx_sa_sess_conn_ind");
- OBX_ReadTriplet(p_pkt, OBX_HI_SESSION_PARAM, triplet, &num);
- if (p_cb->nonce == 0)
- {
- OBX_TRACE_ERROR0("reliable session is not supported by this server");
- /* do not report the session_req_evt */
- p_scb->api_evt = OBX_NULL_EVT;
- obx_prepend_rsp_msg(p_scb->handle, OBX_SESSION_CFM_SEVT, OBX_RSP_NOT_IMPLEMENTED, NULL);
- return OBX_SS_NULL;
- }
- else if (num)
- {
- ind = obx_read_triplet(triplet, num, OBX_TAG_SESS_PARAM_SESS_OP);
- OBX_TRACE_DEBUG2("sess_op ind:%d, num:%d", ind, num);
- if ((ind != num) && (triplet[ind].len == OBX_LEN_SESS_PARAM_SESS_OP))
- {
- p = triplet[ind].p_array;
- p_scb->param.sess.sess_op = sess_op = *p;
- OBX_TRACE_DEBUG1("sess_op :%d", *p);
- switch (*p)
- {
- case OBX_SESS_OP_CREATE:
- /* do not report the API event */
- p_scb->api_evt = OBX_NULL_EVT;
-
- if (p_scb->sess_st == OBX_SESS_ACTIVE)
- {
- /* the session is already active; reject with OBX_RSP_FORBIDDEN */
- break;
- }
-
- /* check if we still have room for one more session */
- if (obx_find_suspended_session (p_scb, NULL, 0) == NULL)
- {
- rsp_code = OBX_RSP_DATABASE_FULL;
- break;
- }
-
- p = &p_scb->sess_info[OBX_SESSION_INFO_NONCE_IDX];
- UINT32_TO_BE_STREAM(p, p_cb->nonce);
- p_cb->nonce++;
- /* make sure it's not 0 (which means reliable session is disabled) */
- if (!p_cb->nonce)
- p_cb->nonce++;
-
- if (obx_sa_make_sess_id (p_scb, p_scb->sess_info, triplet, num) == OBX_SUCCESS)
- {
- rsp_code = OBX_RSP_OK;
- p_scb->ssn = 0;
- p_scb->sess_st = OBX_SESS_CREATE;
- }
- break;
-
- case OBX_SESS_OP_RESUME:
- /* verify that a previously interrupted session exists with the same session parameters.
- Otherwise, OBX_RSP_SERVICE_UNAVL.
- */
- p_spndcb = obx_find_suspended_session (p_scb, triplet, num);
- if (p_spndcb)
- {
- op_ssn = p_spndcb->ssn;
- memcpy (p_scb->sess_info, p_spndcb->sess_info, OBX_SESSION_INFO_SIZE);
- if (obx_sa_make_sess_id (p_scb, sess_info, triplet, num) == OBX_SUCCESS &&
- memcmp (sess_info, p_scb->sess_info, OBX_SESSION_ID_SIZE) == 0)
- {
- /* clear the suspend cb info */
- p_spndcb->state = OBX_SS_NULL;
- if (p_spndcb->stle.param)
- {
- btu_stop_timer (&p_spndcb->stle);
- p_spndcb->stle.param = 0;
- }
- rsp_code = OBX_RSP_OK;
- p_scb->sess_st = OBX_SESS_RESUME;
- p_scb->srmp |= OBX_SRMP_SESS_FST;
- ind = obx_read_triplet(triplet, num, OBX_TAG_SESS_PARAM_NSEQNUM);
- if (ind != num)
- {
- /* ssn exists - must be immediate suspend */
- p = triplet[ind].p_array;
- op_ssn = *p;
- obj_offset = obx_read_obj_offset(triplet, num);
- }
- }
- obxu_dump_hex (p_scb->sess_info, "sess info", OBX_SESSION_INFO_SIZE);
- OBX_TRACE_DEBUG4("p_spndcb->offset: 0x%x srm:x%x op_ssn %d ssn %d", p_spndcb->offset, p_scb->sess_info[OBX_SESSION_INFO_SRM_IDX],op_ssn,p_scb->ssn);
-
- if (p_scb->sess_info[OBX_SESSION_INFO_SRM_IDX] & OBX_SRM_ENGAGE)
- {
- /*
- If offset in the request is smaller which only happens when it is a get operation, then client's offset and ssn matters.
- So server's offset and ssn should be set to the client's ones.
- If offset in the request is greater which only happens when it is a put operation, then server's offset and ssn matters.
- So server keeps its offset(do nothing) and ssn and send it back to client in the resume reponse.
- If offset are equal, either side's offset & ssn is fine, we choose to use the one in the reqeust
- */
-
- offset = p_spndcb->offset;
- if (obj_offset && (obj_offset <= offset))
- {
- offset = obj_offset;
- p_scb->ssn = op_ssn;
- /* Adjust ssn in the next continue to be the same as nssn in the resume request */
- if (p_scb->sess_info[OBX_SESSION_INFO_ST_IDX] ==OBX_CS_GET_SRM)
- p_scb->ssn--;
-
-
- }
-
- }
- /* SRM is not enabled */
- else
- {
- p_scb->ssn = op_ssn;
- }
-
- OBX_TRACE_DEBUG4("offset: 0x%x ssn:%d obj_offset:0x%x srm:0x%x", offset, p_scb->ssn, obj_offset, p_scb->sess_info[OBX_SESSION_INFO_SRM_IDX]);
- }
-
-
- if (rsp_code != OBX_RSP_OK)
- {
- rsp_code = OBX_RSP_SERVICE_UNAVL;
- }
- /* do not report the API event for RESUME.
- * if OBX_RSP_OK, the event is reported in this function.
- * p_rsp is used to call obx_ssm_event, and can not be reported to cback */
- p_scb->api_evt = OBX_NULL_EVT;
- break;
- }
- }
- }
- else
- {
- /* do not have session parameters - bad req do not report the API event */
- p_scb->api_evt = OBX_NULL_EVT;
- rsp_code = OBX_RSP_BAD_REQUEST;
- }
- OBX_TRACE_DEBUG5("obx_sa_sess_conn_ind tx_mtu: %d, sess_st:%d->%d, rsp_code:0x%x, now:%d",
- p_scb->ll_cb.comm.tx_mtu, old_sess_st, p_scb->sess_st, rsp_code, now);
-
- if (rsp_code == OBX_RSP_OK)
- {
- /* send the session response now.
- * do not report OBX_SESSION_REQ_EVT until connect indication,
- * so connection id can be reported at the same time in sess_info */
- if ( (p_rsp = OBX_HdrInit(p_scb->handle, OBX_MIN_MTU))== NULL)
- {
- rsp_code = OBX_RSP_INTRNL_SRVR_ERR;
- }
- else
- {
- obx_read_timeout (triplet, num, &timeout, &p_scb->sess_info[OBX_SESSION_INFO_TO_IDX]);
-
- p = (UINT8 *) (p_rsp + 1) + p_rsp->offset;
- /* response packet always has the final bit set */
- *p++ = (OBX_RSP_OK | OBX_FINAL);
- p_rsp->len = 3;
- p = data;
-
- /* add address */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_ADDR;
- triplet[num_trip].len = BD_ADDR_LEN;
- triplet[num_trip].p_array = p;
- BTM_GetLocalDeviceAddr (p);
- p += BD_ADDR_LEN;
- num_trip++;
-
- /* add nonce 4 - 16 bytes */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_NONCE;
- triplet[num_trip].len = OBX_LOCAL_NONCE_SIZE;
- triplet[num_trip].p_array = &p_scb->sess_info[OBX_SESSION_INFO_NONCE_IDX];
- num_trip++;
-
- /* add session id */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_SESS_ID;
- triplet[num_trip].len = OBX_SESSION_ID_SIZE;
- triplet[num_trip].p_array = p_scb->sess_info;
- num_trip++;
-
- if (sess_op == OBX_SESS_OP_RESUME)
- {
- /* add session id */
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_NSEQNUM;
- triplet[num_trip].len = 1;
- triplet[num_trip].p_array = p;
- /* Adjust ssn in the resume response to be the same as nssn in the resume request */
- if (p_scb->sess_info[OBX_SESSION_INFO_ST_IDX] == OBX_CS_GET_SRM)
- *p++ = p_scb->ssn+1;
- else
- *p++ = p_scb->ssn;
- num_trip++;
- if (offset)
- {
- triplet[num_trip].tag = OBX_TAG_SESS_PARAM_OBJ_OFF;
- triplet[num_trip].len = OBX_LEN_SESS_PARAM_OBJ_OFF;
- triplet[num_trip].p_array = p;
- UINT32_TO_BE_STREAM(p, offset);
- num_trip++;
- obj_offset = offset;
- }
- }
-
- /* add timeout */
- if (timeout != OBX_INFINITE_TIMEOUT && obx_cb.sess_tout_val != OBX_INFINITE_TIMEOUT && (obx_cb.sess_tout_val > timeout))
- {
- timeout = obx_cb.sess_tout_val;
- triplet[num_trip].p_array = p;
- num_trip += obx_add_timeout (&triplet[num_trip], obx_cb.sess_tout_val, &p_scb->param.sess);
- p = &p_scb->sess_info[OBX_SESSION_INFO_TO_IDX];
- UINT32_TO_BE_STREAM(p, timeout);
- }
- OBX_AddTriplet(p_rsp, OBX_HI_SESSION_PARAM, triplet, num_trip);
-
- /* adjust the packet len */
- p = (UINT8 *) (p_rsp + 1) + p_rsp->offset + 1;
- UINT16_TO_BE_STREAM(p, p_rsp->len);
- p_rsp->event = OBX_SESSION_CFM_SEVT + 1;
- p_scb->sess_st = OBX_SESS_ACTIVE;
- p_scb->param.sess.p_sess_info = p_scb->sess_info;
- p_scb->param.sess.sess_st = p_scb->sess_st;
- p_scb->param.sess.ssn = p_scb->ssn;
- p_scb->param.sess.nssn = p_scb->ssn;
- p_scb->param.sess.obj_offset = obj_offset;
- p_scb->param.sess.timeout = timeout;
- memcpy(p_scb->param.sess.peer_addr , p_scb->peer_addr, BD_ADDR_LEN);
- obx_ssm_event(p_scb, OBX_SESSION_CFM_SEVT, p_rsp);
-
- if (sess_op == OBX_SESS_OP_RESUME)
- {
- (*p_cb->p_cback)(p_scb->ll_cb.comm.handle, OBX_SESSION_REQ_EVT, p_scb->param, NULL);
- memset(&p_scb->param, 0, sizeof (p_scb->param) );
- param.conn.ssn = p_scb->ssn;
- memcpy (param.conn.peer_addr, p_scb->peer_addr, BD_ADDR_LEN);
- p = &p_scb->sess_info[OBX_SESSION_INFO_MTU_IDX];
- BE_STREAM_TO_UINT16(param.conn.mtu, p);
- p_scb->ll_cb.comm.tx_mtu = param.conn.mtu;
- param.conn.handle = p_scb->ll_cb.comm.handle;
- OBX_TRACE_DEBUG1("RESUME tx_mtu: %d", p_scb->ll_cb.comm.tx_mtu);
- /* report OBX_CONNECT_REQ_EVT to let the client know the MTU */
- (*p_cb->p_cback)(p_scb->ll_cb.comm.handle, OBX_CONNECT_REQ_EVT, param, NULL);
- }
- }
- }
-
- if ((rsp_code != OBX_RSP_OK) || now)
- {
- /* hold the original api_evt temporarily, so it's not reported at this obx_ssm_event */
- old_api_evt = p_scb->api_evt;
- p_scb->api_evt = OBX_NULL_EVT;
- /* send the response now */
- obx_prepend_rsp_msg(p_scb->handle, OBX_DISCNT_CFM_SEVT, rsp_code, NULL);
- /* restore the api event */
- p_scb->api_evt = old_api_evt;
- }
- else
- {
- ind_to = obx_read_triplet(triplet, num, OBX_TAG_SESS_PARAM_SESS_OP);
- if ((ind_to != num) && (triplet[ind_to].len == OBX_TIMEOUT_SIZE))
- {
- p = triplet[ind_to].p_array;
- BE_STREAM_TO_UINT32(timeout, p);
- }
- p_scb->param.sess.p_sess_info = p_scb->sess_info;
- p_scb->param.sess.sess_st = p_scb->sess_st;
- p_scb->param.sess.ssn = p_scb->ssn;
- p_scb->param.sess.nssn = p_scb->ssn;
- p_scb->param.sess.obj_offset = obj_offset;
- p_scb->param.sess.timeout = timeout;
- memcpy(p_scb->param.sess.peer_addr , p_scb->peer_addr, BD_ADDR_LEN);
-
- }
- return OBX_SS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_sa_wc_sess_ind
-** Description process session request from client
-** when the session request is received in OBX_SS_WAIT_CLOSE
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_wc_sess_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_EVT_PARAM param;
- tOBX_SR_CB *p_cb = obx_sr_get_cb(p_scb->handle);
-
- OBX_TRACE_DEBUG1("obx_sa_wc_sess_ind sess_st:%d", p_scb->sess_st);
- if (p_scb->sess_st == OBX_SESS_ACTIVE)
- {
- /* processing CloseSession */
- obx_sa_session_ind(p_scb, p_pkt);
- }
- else
- {
- /* probably CreateSession */
- obx_sa_sess_conn_ind(p_scb, p_pkt);
- OBX_TRACE_DEBUG1("obx_sa_wc_sess_ind (after obx_sa_sess_conn_ind) sess_st:%d", p_scb->sess_st);
- if (p_scb->sess_st == OBX_SESS_ACTIVE)
- {
- /* after session command and still is Active
- * a session must have been created during Wait_close state.
- * need to report a OBX_CLOSE_IND_EVT to clean up the profiles */
- memset(&param, 0, sizeof(tOBX_EVT_PARAM));
- if (p_cb && p_cb->p_cback)
- (*p_cb->p_cback)(p_scb->ll_cb.comm.handle, OBX_CLOSE_IND_EVT, param, NULL);
- }
- }
- return OBX_SS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_sa_session_rsp
-** Description process Session response API.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_session_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE new_state = OBX_SS_NULL;
- UINT8 *p;
- tOBX_L2C_CB *p_lcb;
- tOBX_L2C_EVT_PARAM evt_param;
-
- OBX_TRACE_DEBUG1("obx_sa_session_rsp pstate:%d", p_scb->prev_state);
- new_state = obx_sa_snd_rsp(p_scb, p_pkt);
- OBX_TRACE_DEBUG2("sess_st: %d op:%d", p_scb->sess_st, p_scb->param.sess.sess_op);
- if (p_scb->sess_st == OBX_SESS_ACTIVE && p_scb->param.sess.sess_op == OBX_SESS_OP_RESUME)
- {
- p_scb->srm = p_scb->sess_info[OBX_SESSION_INFO_SRM_IDX];
- new_state = p_scb->sess_info[OBX_SESSION_INFO_ST_IDX];
- p = &p_scb->sess_info[OBX_SESSION_INFO_ID_IDX];
- BE_STREAM_TO_UINT32(p_scb->conn_id, p);
- OBX_TRACE_DEBUG3("new_state; %d Connection ID: 0x%x, srm:0x%x", new_state, p_scb->conn_id, p_scb->srm);
- if ((p_scb->srm & OBX_SRM_ENGAGE) && (new_state == OBX_SS_GET_SRM))
- {
- p_lcb = &p_scb->ll_cb.l2c;
- evt_param.any = 0;
- obx_l2c_snd_evt (p_lcb, evt_param, OBX_L2C_EVT_RESUME);
- }
- /* report OBX_CONNECT_REQ_EVT in obx_sa_sess_conn_ind()
- if (new_state == OBX_SS_CONNECTED)
- {
- } */
- }
- else if (p_scb->sess_st == OBX_SESS_CLOSE)
- {
- new_state = OBX_SS_WAIT_CLOSE;
- }
-
- return new_state;
-}
-
-/*******************************************************************************
-** Function obx_sa_put_ind
-** Description received a PUT request from the client. Check if SRM is engaged.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_put_ind(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_SS_NULL;
- if ((p_scb->srm & OBX_SRM_REQING) && (p_scb->srm & OBX_SRM_ENABLE))
- {
- state = OBX_CS_PUT_SRM;
- }
- return state;
-}
-
-/*******************************************************************************
-** Function obx_sa_srm_put_req
-** Description received a PUT request from the client when SRM is engaged.
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_srm_put_req(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- if (!p_scb->param.put.final)
- p_scb->srm |= OBX_SRM_WAIT_UL;
- return OBX_SS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_sa_srm_put_rsp
-** Description process PUT response API function.
-** report PUT request event, if any is queued
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_srm_put_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_SS_NULL;
- tOBX_COMM_CB *p_comm = &p_scb->ll_cb.comm;
- UINT8 rsp_code = OBX_RSP_DEFAULT;
- BOOLEAN ret = TRUE;
-
- obx_access_rsp_code(p_pkt, &rsp_code);
- rsp_code &= ~OBX_FINAL;
- if (rsp_code != OBX_RSP_CONTINUE )
- {
- p_scb->srm |= OBX_SRM_NEXT;
- if (rsp_code != OBX_RSP_OK)
- p_scb->srm |= OBX_SRM_ABORT;
- }
-
- p_scb->srm &= ~OBX_SRM_WAIT_UL;
- OBX_TRACE_DEBUG2("obx_sa_srm_put_rsp srm:0x%x rsp_code:0x%x", p_scb->srm, rsp_code);
- if (p_scb->srm & OBX_SRM_NEXT)
- {
- p_scb->srm &= ~OBX_SRM_NEXT;
- state = obx_sa_snd_rsp (p_scb, p_pkt);
- }
- else
- {
- if (p_scb->sess_st == OBX_SESS_ACTIVE)
- {
- p_scb->ssn++;
- }
- obx_start_timer(&p_scb->ll_cb.comm);
- if (p_pkt)
- GKI_freebuf(p_pkt);
- }
- OBX_TRACE_DEBUG1("obx_sa_srm_put_rsp srm:0x%x", p_scb->srm);
-
- while (ret && (p_pkt = (BT_HDR *)GKI_dequeue (&p_comm->rx_q)) != NULL)
- {
- if (state != OBX_SS_NULL)
- {
- p_scb->state = state;
- state = OBX_SS_NULL;
- }
- ret = obx_sr_proc_pkt (p_scb, p_pkt);
- if ((p_scb->srm & OBX_SRM_ABORT) == 0)
- ret = FALSE;
- obx_flow_control(p_comm);
- OBX_TRACE_DEBUG3("obx_sa_srm_put_rsp rx_q.count: %d srm:0x%x, ret:%d", p_comm->rx_q.count, p_scb->srm, ret );
- }
-
- return state;
-}
-
-/*******************************************************************************
-** Function obx_sa_srm_get_fcs
-** Description Process L2CAP congestion event
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_srm_get_fcs(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- BOOLEAN not_cong = TRUE;
- if (p_scb->ll_cb.comm.p_send_fn == (tOBX_SEND_FN *)obx_l2c_snd_msg)
- {
- OBX_TRACE_DEBUG1("obx_sa_srm_get_fcs cong:%d", p_scb->ll_cb.l2c.cong);
- if (p_scb->ll_cb.l2c.cong)
- not_cong = FALSE;
- }
- if (not_cong)
- p_scb->api_evt = OBX_GET_REQ_EVT;
- return OBX_SS_NULL;
-}
-
-/*******************************************************************************
-** Function obx_sa_srm_get_rsp
-** Description send GET response to client
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_srm_get_rsp(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state;
- OBX_TRACE_DEBUG1("obx_sa_srm_get_rsp srm:0x%x", p_scb->srm);
- state = obx_sa_snd_rsp(p_scb, p_pkt);
- return state;
-}
-
-
-
-/*******************************************************************************
-** Function obx_sa_srm_get_req
-** Description process GET request from client
-*******************************************************************************/
-tOBX_SR_STATE obx_sa_srm_get_req(tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_SR_STATE state = OBX_SS_NULL;
- tOBX_SR_CB *p_cb;
-
- OBX_TRACE_DEBUG3("obx_sa_srm_get_req srm:0x%x srmp:0x%x final:%d", p_scb->srm, p_scb->srmp, p_scb->param.get.final);
- if (p_scb->srmp & OBX_SRMP_NONF)
- {
- /* the GET request does not set the final bit yet.
- * merge this request, send response automatically and do not report the event */
- if (!p_scb->param.get.final)
- {
- p_scb->p_saved_msg = obx_merge_get_req(p_scb->p_saved_msg, p_pkt);
- p_scb->api_evt = OBX_NULL_EVT;
- }
- else
- {
- p_scb->srmp &= ~OBX_SRMP_NONF;
- p_pkt = obx_merge_get_req(p_scb->p_saved_msg, p_pkt);
- p_scb->p_saved_msg = NULL;
- p_scb->api_evt = OBX_NULL_EVT;
- p_cb = &obx_cb.server[p_scb->handle - 1];
- (p_cb->p_cback) (p_scb->ll_cb.comm.handle, OBX_GET_REQ_EVT, p_scb->param, p_pkt);
- memset(&p_scb->param, 0, sizeof (p_scb->param) );
- }
- }
-
- return state;
-}
-
diff --git a/stack/obx/obx_sapi.c b/stack/obx/obx_sapi.c
deleted file mode 100644
index 7815947..0000000
--- a/stack/obx/obx_sapi.c
+++ /dev/null
@@ -1,591 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_sapi.c
-**
-** File: OBEX Server Application Programming Interface functions
-**
-** Copyright (c) 2003-2009, Broadcom Corp., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "bt_target.h"
-
-#if defined(OBX_INCLUDED) && (OBX_INCLUDED == TRUE)
-
-#include "wcassert.h"
-#include "btu.h"
-#include "port_api.h"
-#include "obx_int.h"
-#include "l2c_api.h"
-#include "btm_api.h"
-
-/*******************************************************************************
-**
-** Function OBX_StartServer
-**
-** Description This function is to register a server entity to OBEX.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_NO_RESOURCES, if OBX does not have resources.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_StartServer(tOBX_StartParams *p_params, tOBX_HANDLE *p_handle)
-{
- tOBX_SR_CB *p_cb = NULL;
- tOBX_STATUS status = OBX_NO_RESOURCES;
-// btla-specific ++
- tOBX_SR_SESS_CB *p_scb = NULL;
-// btla-specific --
- tOBX_HANDLE obx_handle;
- UINT8 size;
-
- WC_ASSERT(p_params);
- WC_ASSERT(p_params->p_cback);
- WC_ASSERT(p_handle);
-
- if (p_params->max_sessions > OBX_MAX_SR_SESSION)
- {
- OBX_TRACE_ERROR2("OBX_StartServer bad max_sessions:%d (1-%d)",
- p_params->max_sessions, OBX_MAX_SR_SESSION);
- return OBX_BAD_PARAMS;
- }
-
- if (p_params->scn == 0 && L2C_INVALID_PSM(p_params->psm))
- {
- OBX_TRACE_ERROR2("OBX_StartServer bad scn:%d and psm:0x%x", p_params->scn, p_params->psm);
- return OBX_BAD_PARAMS;
- }
-
- if (p_params->max_sessions == 0)
- p_params->max_sessions = 1;
-
- /* allocate a server control block */
- obx_handle = obx_sr_alloc_cb(p_params);
- if (obx_handle)
- p_cb = &obx_cb.server[obx_handle-1];
-
- if (p_cb != NULL)
- {
- p_scb = &obx_cb.sr_sess[p_cb->sess[0]-1];
- p_scb->ll_cb.port.rx_mtu = p_params->mtu;
- if (p_cb->scn)
- {
- /* open an RFCOMM port to listen for incoming messages */
- /* allocate the port for the first session now. The others will be allocated when needed */
- status = obx_open_port(&p_scb->ll_cb.port, BT_BD_ANY, p_cb->scn);
- }
- else
- {
- status = OBX_SUCCESS;
- }
-
- if (status == OBX_SUCCESS)
- {
- /* If authentication is needed for this server, save the parameters in control block */
- if (p_params->authenticate)
- {
- p_cb->p_auth = (tOBX_AUTH_PARAMS *)GKI_getbuf(sizeof(tOBX_AUTH_PARAMS)+OBX_MAX_REALM_LEN+1);
- if (p_cb->p_auth)
- {
- p_cb->p_auth->auth_option = p_params->auth_option;
- /* adjust realm len, if the given realm is too big */
- size = (p_params->realm_len>OBX_MAX_REALM_LEN) ? OBX_MAX_REALM_LEN : p_params->realm_len;
- p_cb->p_auth->realm_len = size;
- p_cb->p_auth->realm[0] = p_params->realm_charset;
- if (p_params->realm_len && p_params->p_realm)
- memcpy(&p_cb->p_auth->realm[1], p_params->p_realm, size);
- }
- else
- status = OBX_NO_RESOURCES;
- }
- }
-
- if (status == OBX_SUCCESS)
- {
- /* if everything is OK, save the other parameters for this server */
- memset(p_cb->target.target, 0, OBX_MAX_TARGET_LEN);
- if (p_params->p_target)
- {
- if (p_params->p_target->len)
- {
- /* OBX handles who, connection ID headers */
- p_cb->target.len = p_params->p_target->len;
- memcpy(p_cb->target.target, p_params->p_target->target, p_params->p_target->len);
- }
- else
- {
- /* the regular default server */
- /* the user handles target, who headers.
- * OBX handles connection ID header */
- p_cb->target.len = OBX_DEFAULT_TARGET_LEN;
- }
- }
- else
- {
- /* the one and only default server */
- /* no target, who, connection id headers for this case */
- p_cb->target.len = 0;
- }
-
-// btla-specific ++
- if (p_scb)
- {
- OBX_TRACE_DEBUG3("OBX_StartServer target len:%d, authenticate:%d handle:0x%x",
- p_cb->target.len, p_params->authenticate, p_scb->ll_cb.port.handle);
- p_cb->p_cback = p_params->p_cback;
- p_scb->state = OBX_SS_NOT_CONNECTED;
-
- /* give the handle to application */
- *p_handle = p_scb->ll_cb.port.handle;
- }
-// btla-specific --
- }
- else
- {
- /* otherwise, free the control block */
- obx_sr_free_cb(obx_handle);
- }
- }
-
- return status;
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_StopServer
-**
-** Description This function is to stop this OBEX server from receiving any
-** more incoming requests.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_StopServer(tOBX_HANDLE handle)
-{
- tOBX_STATUS status = OBX_SUCCESS;
- tOBX_SR_CB *p_cb = obx_sr_get_cb(handle);
- tOBX_SR_SESS_CB *p_scb;
- int xx;
- tOBX_SPND_CB *p_spndcb;
-
- if (p_cb)
- {
- /* Process suspended session if necessary */
- if (p_cb->p_suspend)
- {
- for (xx=0, p_spndcb=p_cb->p_suspend; xx<p_cb->max_suspend; xx++, p_spndcb++)
- {
- if (p_spndcb->state)
- {
- btu_stop_timer (&p_spndcb->stle);
- }
- }
- GKI_freebuf (p_cb->p_suspend);
- }
-
- for (xx=0; xx < p_cb->num_sess && p_cb->sess[xx]; xx ++)
- {
- p_scb = &obx_cb.sr_sess[p_cb->sess[xx]-1];
- if (p_scb->ll_cb.comm.id)
- {
- OBX_DisconnectRsp(handle, OBX_RSP_SERVICE_UNAVL, NULL);
- if (p_scb->ll_cb.comm.p_send_fn == (tOBX_SEND_FN *)obx_rfc_snd_msg)
- RFCOMM_RemoveServer(p_scb->ll_cb.port.port_handle);
- }
- }
-
- if (p_cb->psm)
- L2CA_DEREGISTER (p_cb->psm);
-
- obx_sr_free_cb (handle);
- }
- else
- status = OBX_BAD_HANDLE;
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_AddSuspendedSession
-**
-** Description This function is to add the session information for a previously
-** suspended reliable session to the server control block
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_AddSuspendedSession(tOBX_HANDLE shandle, BD_ADDR peer_addr, UINT8 *p_sess_info,
- UINT32 timeout, UINT8 ssn, UINT32 offset)
-{
- tOBX_STATUS status = OBX_SUCCESS;
- tOBX_SR_CB *p_cb = obx_sr_get_cb(shandle);
- UINT16 size;
- UINT8 xx;
- tOBX_SPND_CB *p_spndcb;
- INT32 ticks = 0x7FFFFFFF, remain_ticks;
- BOOLEAN added = FALSE;
- UINT8 saved_xx = 0;
-
- OBX_TRACE_DEBUG2("OBX_AddSuspendedSession BDA: %06x%06x",
- (peer_addr[0]<<16)+(peer_addr[1]<<8)+peer_addr[2],
- (peer_addr[3]<<16)+(peer_addr[4]<<8)+peer_addr[5]);
- if (p_cb && p_sess_info && p_cb->max_suspend)
- {
- if (p_cb->p_suspend == NULL)
- {
- size = p_cb->max_suspend * sizeof (tOBX_SPND_CB);
- p_cb->p_suspend = (tOBX_SPND_CB *)GKI_getbuf( size);
- memset (p_cb->p_suspend, 0, size);
- }
-
- if (p_cb->p_suspend)
- {
- for (xx=0, p_spndcb=p_cb->p_suspend; xx<p_cb->max_suspend; xx++, p_spndcb++)
- {
- OBX_TRACE_DEBUG4("[%d] state: %d, ssn:%d BDA: %08x", xx, p_spndcb->state, p_spndcb->ssn,
- (p_spndcb->peer_addr[2]<<24)+(p_spndcb->peer_addr[3]<<16)+(p_spndcb->peer_addr[4]<<8)+p_spndcb->peer_addr[5]);
- if (p_spndcb->state == OBX_SS_NULL || memcmp(p_spndcb->peer_addr, peer_addr, BD_ADDR_LEN) == 0)
- {
- added = TRUE;
- break;
- }
- else if (p_spndcb->state != OBX_SS_NULL && ticks)
- {
- if (p_spndcb->stle.param == 0)
- {
- /* this entry has infinite timeout; just use it */
- ticks = 0;
- saved_xx = xx;
- OBX_TRACE_DEBUG1("[%d] infinite timeout", xx );
- }
- /* find the entry the expires in the shortest time */
- else
- {
- remain_ticks = btu_remaining_time(&p_spndcb->stle);
- OBX_TRACE_DEBUG2("[%d] remain_ticks: %d", xx, remain_ticks );
- if (remain_ticks < ticks)
- {
- ticks = remain_ticks;
- saved_xx = xx;
- }
- }
- }
- }
-
- if (!added)
- {
- /* if cannot use an empty/or reuse an existing entry, use the one expires soon */
- added = TRUE;
- xx = saved_xx; /* this is for debug trace; don't optimize */
- p_spndcb = &p_cb->p_suspend[xx];
- OBX_TRACE_DEBUG1("reuse entry [%d]", xx );
- }
-
- if (added)
- {
- memcpy (p_spndcb->sess_info, p_sess_info, OBX_SESSION_INFO_SIZE);
- p_spndcb->state = p_sess_info[OBX_SESSION_INFO_ST_IDX];
- p_spndcb->ssn = ssn;
- p_spndcb->offset = offset;
- OBX_TRACE_DEBUG6("[%d] timeout: %d state:%d ssn:%d offset:%d, BDA: %08x",
- xx, timeout, p_spndcb->state, ssn, offset,
- (peer_addr[2]<<24)+(peer_addr[3]<<16)+(peer_addr[4]<<8)+peer_addr[5]);
- memcpy(p_spndcb->peer_addr, peer_addr, BD_ADDR_LEN);
- if (timeout != OBX_INFINITE_TIMEOUT)
- {
- p_spndcb->stle.param = (UINT32)p_spndcb;
- btu_start_timer(&p_spndcb->stle, BTU_TTYPE_OBX_SVR_SESS_TO, timeout);
- OBX_TRACE_DEBUG2("timeout: %d ticks:%d", timeout, p_spndcb->stle.ticks);
- }
- else
- p_spndcb->stle.param = 0;
- }
- }
- }
- else
- status = OBX_BAD_HANDLE;
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_ConnectRsp
-**
-** Description This function is called to send the response to a Connect
-** Request from an OBEX client.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_ConnectRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt)
-{
- tOBX_STATUS status = OBX_SUCCESS;
- tOBX_SR_SESS_CB *p_scb = obx_sr_get_scb(shandle);
- tOBX_SR_CB *p_cb = obx_sr_get_cb(shandle);
-
- if (p_scb)
- {
- p_pkt = obx_conn_rsp(p_cb, p_scb, rsp_code, p_pkt);
-
- obx_ssm_event(p_scb, OBX_CONNECT_CFM_SEVT, p_pkt);
- }
- else
- {
- OBX_TRACE_DEBUG1("OBX_ConnectRsp Bad Handle: 0x%x", shandle);
- status = OBX_BAD_HANDLE;
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_SessionRsp
-**
-** Description This function is called to respond to a request to create a reliable session.
-**
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_SessionRsp(tOBX_HANDLE shandle, UINT8 rsp_code, UINT8 ssn, UINT32 offset, BT_HDR *p_pkt)
-{
- tOBX_STATUS status = OBX_SUCCESS;
- tOBX_SR_SESS_CB *p_scb = obx_sr_get_scb(shandle);
- UINT8 *p;
- BT_HDR *p_rsp = NULL;
- tOBX_TRIPLET triplet[5];
- UINT8 data[12];
- UINT8 num_trip = 0;
- UINT32 timeout;
- tOBX_SESS_ST old_sess_st;
-
- OBX_TRACE_API0("OBX_SessionRsp");
- if (p_scb)
- {
- old_sess_st = p_scb->sess_st;
- p_rsp = OBX_HdrInit(p_scb->handle, OBX_MIN_MTU);
- if (p_rsp)
- {
- p = (UINT8 *) (p_rsp + 1) + p_rsp->offset;
- /* response packet always has the final bit set */
- *p++ = (rsp_code | OBX_FINAL);
- p_rsp->len = 3;
- p = data;
- if (rsp_code == OBX_RSP_OK)
- {
- switch (p_scb->sess_st)
- {
- case OBX_SESS_CREATE:
- case OBX_SESS_RESUME:
- GKI_freebuf (p_rsp);
- if (p_pkt)
- GKI_freebuf (p_pkt);
- OBX_TRACE_DEBUG0("OBX_SessionRsp do not need to be called for CREATE and RESUME");
- return OBX_SUCCESS;
- case OBX_SESS_SUSPEND:
- p_scb->sess_st = OBX_SESS_SUSPENDED;
- p = &p_scb->sess_info[OBX_SESSION_INFO_TO_IDX];
- BE_STREAM_TO_UINT32(timeout, p);
- OBX_AddSuspendedSession(p_scb->handle, p_scb->peer_addr, p_scb->sess_info, timeout, ssn, offset);
- break;
- case OBX_SESS_CLOSE:
- p_scb->sess_st = OBX_SESS_NONE;
- break;
- }
-
- if (num_trip)
- OBX_AddTriplet(p_rsp, OBX_HI_SESSION_PARAM, triplet, num_trip);
- if (p_pkt)
- {
- p = (UINT8 *) (p_rsp + 1) + p_rsp->offset + p_rsp->len;
- memcpy (p, ((UINT8 *) (p_pkt + 1) + p_pkt->offset), p_pkt->len);
- p_rsp->len += p_pkt->len;
- }
- }
- p = (UINT8 *) (p_rsp + 1) + p_rsp->offset + 1;
- UINT16_TO_BE_STREAM(p, p_rsp->len);
-
- p_rsp->event = OBX_SESSION_CFM_SEVT + 1;
- }
- OBX_TRACE_DEBUG3("Rsp sess_st:%d->%d status:%d", old_sess_st, p_scb->sess_st, status);
-
- obx_ssm_event(p_scb, OBX_SESSION_CFM_SEVT, p_rsp);
- /* clear the "previous" session state as required by earlier comment */
- p_scb->param.sess.sess_st = 0;
- }
- else
- status = OBX_BAD_HANDLE;
-
- if (p_pkt)
- {
- GKI_freebuf (p_pkt);
- }
- return status;
-}
-
-/*******************************************************************************
-**
-** Function obx_prepend_rsp_msg
-**
-** Description This function is called to add response code and connection ID
-** to the given OBEX message
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS obx_prepend_rsp_msg(tOBX_HANDLE shandle, tOBX_SR_EVENT event, UINT8 rsp_code, BT_HDR *p_pkt)
-{
- tOBX_STATUS status = OBX_SUCCESS;
- tOBX_SR_SESS_CB *p_scb = obx_sr_get_scb(shandle);
- UINT8 msg[OBX_HDR_OFFSET];
- UINT8 *p = msg;
-
- if (p_scb)
- {
- /* response packets always have the final bit set */
- *p++ = (rsp_code | OBX_FINAL);
- p += OBX_PKT_LEN_SIZE;
-
- /* add session sequence number, if session is active */
- if (p_scb->sess_st == OBX_SESS_ACTIVE || p_scb->sess_st == OBX_SESS_SUSPENDING)
- {
- *p++ = OBX_HI_SESSION_SN;
- *p++ = (p_scb->ssn+1);
- }
-
- if (event == OBX_DISCNT_CFM_SEVT)
- p_scb->conn_id = 0;
-
- if (p_scb->srm & OBX_SRM_REQING)
- {
- p_scb->srm &= ~OBX_SRM_REQING;
- if (rsp_code == OBX_RSP_CONTINUE)
- {
- p_scb->srm |= OBX_SRM_ENGAGE;
- *p++ = OBX_HI_SRM;
- *p++ = OBX_HV_SRM_ENABLE;
-
- if (event == OBX_PUT_CFM_SEVT)
- p_scb->srm |= OBX_SRM_NEXT;
- }
- }
-
- p_pkt = obx_sr_prepend_msg(p_pkt, msg, (UINT16)(p - msg) );
- /* this event code needs to be set up properly for flow control reasons */
- p_pkt->event = event+1;
- obx_ssm_event(p_scb, event, p_pkt);
- }
- else
- status = OBX_BAD_HANDLE;
-
- return status;
-}
-
-/*******************************************************************************
-**
-** Function OBX_SetPathRsp
-**
-** Description This function is called to send the response to a Set Path
-** Request from an OBEX client.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_SetPathRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt)
-{
- return obx_prepend_rsp_msg(shandle, OBX_SETPATH_CFM_SEVT, rsp_code, p_pkt);
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_PutRsp
-**
-** Description This function is called to send the response to a Put
-** Request from an OBEX client.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_PutRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt)
-{
- return obx_prepend_rsp_msg(shandle, OBX_PUT_CFM_SEVT, rsp_code, p_pkt);
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_GetRsp
-**
-** Description This function is called to send the response to a Get
-** Request from an OBEX client.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_GetRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt)
-{
- return obx_prepend_rsp_msg(shandle, OBX_GET_CFM_SEVT, rsp_code, p_pkt);
-}
-
-
-/*******************************************************************************
-**
-** Function OBX_AbortRsp
-**
-** Description This function is called to send the response to an Abort
-** Request from an OBEX client.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_AbortRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt)
-{
- return obx_prepend_rsp_msg(shandle, OBX_ABORT_CFM_SEVT, rsp_code, p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function OBX_ActionRsp
-**
-** Description This function is called to respond to an Action command Request
-** from an OBEX client.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_ActionRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt)
-{
- return obx_prepend_rsp_msg(shandle, OBX_ACTION_CFM_SEVT, rsp_code, p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function OBX_DisconnectRsp
-**
-** Description This function is called to send the response to a Disconnect
-** Request from an OBEX client.
-** This function can also be used to force close the transport
-** to a connected client.
-**
-** Returns OBX_SUCCESS, if successful.
-** OBX_BAD_HANDLE, if the handle is not valid.
-**
-*******************************************************************************/
-tOBX_STATUS OBX_DisconnectRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt)
-{
- return obx_prepend_rsp_msg(shandle, OBX_DISCNT_CFM_SEVT, rsp_code, p_pkt);
-}
-#endif
diff --git a/stack/obx/obx_ssm.c b/stack/obx/obx_ssm.c
deleted file mode 100644
index 2e06404..0000000
--- a/stack/obx/obx_ssm.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_ssm.c
-**
-** File: OBEX Server State Machine and Control Block Access Functions
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-
-#include "btu.h" /* for timer */
-#include "obx_int.h"
-
-/* OBEX Server Action Functions Enums (must match obx_sr_action [below] */
-enum
-{
- OBX_SA_CLOSE_PORT,
- OBX_SA_CONNECTION_ERROR,
- OBX_SA_STATE,
- OBX_SA_CONNECT_IND,
- OBX_SA_WC_CONN_IND,
- OBX_SA_NC_TO,
- OBX_SA_CONNECT_RSP,
- OBX_SA_AUTH_IND,
- OBX_SA_SND_RSP,
- OBX_SA_SAVE_REQ,
- OBX_SA_SND_PART,
- OBX_SA_REJ_REQ,
- OBX_SA_ABORT_RSP,
- OBX_SA_OP_RSP,
- OBX_SA_GET_IND,
- OBX_SA_GET_REQ,
- OBX_SA_SESSION_IND,
- OBX_SA_SESS_CONN_IND,
- OBX_SA_WC_SESS_IND,
- OBX_SA_SESSION_RSP,
- OBX_SA_PUT_IND,
- OBX_SA_SRM_PUT_REQ,
- OBX_SA_SRM_PUT_RSP,
- OBX_SA_SRM_GET_FCS,
- OBX_SA_SRM_GET_RSP,
- OBX_SA_SRM_GET_REQ,
- OBX_SA_CLEAN_PORT
-};
-
-/* OBEX Server Action Functions */
-static const tOBX_SR_ACT obx_sr_action[] =
-{
- obx_sa_close_port,
- obx_sa_connection_error,
- obx_sa_state,
- obx_sa_connect_ind,
- obx_sa_wc_conn_ind,
- obx_sa_nc_to,
- obx_sa_connect_rsp,
- obx_sa_auth_ind,
- obx_sa_snd_rsp,
- obx_sa_save_req,
- obx_sa_snd_part,
- obx_sa_rej_req,
- obx_sa_abort_rsp,
- obx_sa_op_rsp,
- obx_sa_get_ind,
- obx_sa_get_req,
- obx_sa_session_ind,
- obx_sa_sess_conn_ind,
- obx_sa_wc_sess_ind,
- obx_sa_session_rsp,
- obx_sa_put_ind,
- obx_sa_srm_put_req,
- obx_sa_srm_put_rsp,
- obx_sa_srm_get_fcs,
- obx_sa_srm_get_rsp,
- obx_sa_srm_get_req,
- obx_sa_clean_port
-};
-
-/************ OBX Server FSM State/Event Indirection Table **************/
-/* obx_ssm_event() first looks at obx_ssm_entry_map[][] to get an entry of the event of a particular state
- * 0 means the event in the current state is ignored.
- * a number with 0x80 bit set, use obx_sr_all_table[][] as the "state table".
- * other numbers, look up obx_sr_main_state_table[] for the state table of current state.
- *
- * once the state table is determined,
- * look up the "action" column to find the associated action function
- * and the "next state" column to find the "next state" candidate.
- *
- * The actual next state could be either the state in the "next state" column
- * or the state returned from the action function.
- */
-static const UINT8 obx_ssm_entry_map[][OBX_SS_MAX-1] =
-{
-/* state name: NtCon SesIn CntIn WtAut AutIn Conn DscIn StpIn ActIn AbtIn PutIn GetIn Put Get PutS GetS Part WtCls */
-/* CONN_R */{ 1, 0x82, 0x82, 1, 0x82, 0x86, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82 ,1 },
-/* SESS_R */{ 3, 0x82, 0x82, 0x82, 0x82, 0x88, 3, 0x85, 0x85, 0x85, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 1 ,3 },
-/* DISCNT_R */{ 0x86, 0x82, 0x82, 0x82, 0x82, 0x85, 0x82, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 1 ,0x86 },
-/* PUT_R */{ 0x86, 0x82, 0x82, 0x82, 0x82, 1, 0x87, 0x87, 0x87, 0x82, 0x87, 0x87, 1, 0x82, 1, 0x82, 0x82 ,0x86 },
-/* GET_R */{ 0x86, 0x82, 0x82, 0x82, 0x82, 2, 0x87, 0x87, 0x87, 0x82, 0x87, 0x87, 0x82, 1, 0x82, 1, 0x82 ,0x86 },
-/* SETPATH_R*/{ 0x86, 0x82, 0x82, 0x82, 0x82, 3, 0x87, 0x87, 0x87, 0x82, 0x87, 0x87, 0x82, 0x82, 0x82, 0x82, 0x82 ,0x86 },
-/* ACTION_R */{ 0x86, 0x82, 0x82, 0x82, 0x82, 4, 0x87, 0x87, 0x87, 0x82, 0x87, 0x87, 0x82, 0x82, 0x82, 0x82, 0x82 ,0x86 },
-/* ABORT_R */{ 0x86, 0x82, 0x82, 0x82, 0x82, 0x86, 0x82, 0x82, 0x82, 0x82, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 1 ,0x86 },
-/* CONN_C */{ 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 },
-/* SESS_C */{ 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 },
-/* DISCNT_C */{ 0, 0x82, 0x82, 0x82, 0x82, 0x82, 1, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82 ,0 },
-/* PUT_C */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 2, 0, 0 ,0 },
-/* GET_C */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 2, 0 ,0 },
-/* SETPATH_C*/{ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 },
-/* ACTION_C */{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ,0 },
-/* ABORT_C */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0 ,0 },
-/* PORT_CLS */{ 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83 ,0x83 },
-/* FCS_SET */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2 ,0 },
-/* STATE */{ 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84 ,0x84 },
-/* TIMEOUT */{ 2, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,2 },
-/* BAD_REQ */{ 0x86, 0x82, 0x82, 0x82, 0x82, 0x86, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82 ,0x86 },
-/* TX_EMPTY */{ 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 }
-};
-
-static const UINT8 obx_sr_all_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* ABORT_R */{OBX_SM_NO_ACTION, OBX_SS_ABORT_INDICATED },
-/* misc */{OBX_SA_CLOSE_PORT, OBX_SS_NOT_CONNECTED },
-/* PORT_CLS */{OBX_SA_CONNECTION_ERROR, OBX_SS_NOT_CONNECTED },
-/* STATE */{OBX_SA_STATE, OBX_SS_NULL },
-/* DISCNT_R */{OBX_SM_NO_ACTION, OBX_SS_DISCNT_INDICATED },
-/* misc */{OBX_SA_REJ_REQ, OBX_SS_NULL },
-/* illegalop*/{OBX_SA_CLEAN_PORT, OBX_SS_NOT_CONNECTED },
-/* SESS_R */{OBX_SA_SESSION_IND, OBX_SS_SESS_INDICATED }
-};
-
-static const UINT8 obx_sr_not_conn_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* CONN_R */{OBX_SA_CONNECT_IND, OBX_SS_CONN_INDICATED },
-/* TIMEOUT */{OBX_SA_NC_TO, OBX_SS_NOT_CONNECTED},
-/* SESS_R */{OBX_SA_SESS_CONN_IND, OBX_SS_SESS_INDICATED }
-};
-
-static const UINT8 obx_sr_connect_ind_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* CONN_C */{OBX_SA_CONNECT_RSP, OBX_SS_CONNECTED }
-};
-
-static const UINT8 obx_sr_session_ind_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* SESS_R */{OBX_SA_SESSION_RSP, OBX_SS_NOT_CONNECTED }
-};
-
-static const UINT8 obx_sr_wait_auth_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* CONN_R */{OBX_SA_AUTH_IND, OBX_SS_AUTH_INDICATED },
-/* TIMEOUT */{OBX_SA_CLOSE_PORT, OBX_SS_NOT_CONNECTED}
-};
-
-static const UINT8 obx_sr_conn_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* PUT_R */{OBX_SA_PUT_IND, OBX_SS_PUT_INDICATED },
-/* GET_R */{OBX_SA_GET_IND, OBX_SS_GET_INDICATED },
-/* SETPATH_R*/{OBX_SM_NO_ACTION, OBX_SS_SETPATH_INDICATED },
-/* ACTION_R */{OBX_SM_NO_ACTION, OBX_SS_ACTION_INDICATED }
-};
-
-static const UINT8 obx_sr_disconnect_ind_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* DISCNT_C */{OBX_SA_SND_RSP, OBX_SS_WAIT_CLOSE },
-/* TIMEOUT */{OBX_SA_CLOSE_PORT, OBX_SS_NOT_CONNECTED},
-/* SESS_R */{OBX_SA_SESSION_IND, OBX_SS_DISCNT_INDICATED}
-};
-
-static const UINT8 obx_sr_setpath_ind_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* SETPATH_C*/{OBX_SA_SND_RSP, OBX_SS_CONNECTED }
-};
-
-static const UINT8 obx_sr_abort_ind_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* GET/PUT_C*/{OBX_SA_OP_RSP, OBX_SS_ABORT_INDICATED },
-/* ABORT_C */{OBX_SA_ABORT_RSP, OBX_SS_CONNECTED }
-};
-
-static const UINT8 obx_sr_put_ind_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* PUT_C */{OBX_SA_SND_RSP, OBX_SS_PUT_TRANSACTION }
-};
-
-static const UINT8 obx_sr_get_ind_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* GET_C */{OBX_SA_SND_RSP, OBX_SS_GET_TRANSACTION }
-};
-
-static const UINT8 obx_sr_put_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* PUT_R */{OBX_SM_NO_ACTION, OBX_SS_PUT_INDICATED }
-};
-
-static const UINT8 obx_sr_get_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* GET_R */{OBX_SA_GET_REQ, OBX_SS_GET_INDICATED }
-};
-
-static const UINT8 obx_sr_put_s_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* PUT_R */{OBX_SA_SRM_PUT_REQ, OBX_SS_PUT_SRM },
-/* PUT_C */{OBX_SA_SRM_PUT_RSP, OBX_SS_PUT_SRM }
-};
-
-static const UINT8 obx_sr_get_s_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* GET_R */{OBX_SA_SRM_GET_REQ, OBX_SS_GET_SRM },
-/* GET_C */{OBX_SA_SRM_GET_RSP, OBX_SS_GET_SRM },
-/* FCS_SET */{OBX_SA_SRM_GET_FCS, OBX_SS_GET_SRM }
-};
-
-static const UINT8 obx_sr_part_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* ABORT_R */{OBX_SA_SAVE_REQ, OBX_SS_NULL },/* and DISCNT_R */
-/* FCS_SET */{OBX_SA_SND_PART, OBX_SS_NULL }
-};
-
-static const UINT8 obx_sr_wait_close_table[][OBX_SM_NUM_COLS] = {
-/* Event Action Next State */
-/* CONN_R */{OBX_SA_WC_CONN_IND, OBX_SS_CONN_INDICATED },
-/* TIMEOUT */{OBX_SA_NC_TO, OBX_SS_NOT_CONNECTED},
-/* SESS_R */{OBX_SA_WC_SESS_IND, OBX_SS_SESS_INDICATED }
-};
-
-static const tOBX_SM_TBL obx_sr_main_state_table[] = {
- obx_sr_not_conn_table,
- obx_sr_session_ind_table,
- obx_sr_connect_ind_table,
- obx_sr_wait_auth_table,
- obx_sr_connect_ind_table, /* same table for auth ind */
- obx_sr_conn_table,
- obx_sr_disconnect_ind_table,
- obx_sr_setpath_ind_table,
- obx_sr_setpath_ind_table, /* same action table for action_ind */
- obx_sr_abort_ind_table,
- obx_sr_put_ind_table,
- obx_sr_get_ind_table,
- obx_sr_put_table,
- obx_sr_get_table,
- obx_sr_put_s_table,
- obx_sr_get_s_table,
- obx_sr_part_table,
- obx_sr_wait_close_table
-};
-
-/*******************************************************************************
-**
-** Function obx_ssm_event
-**
-** Description Handle events to the server state machine. It looks up the entry
-** in the obx_ssm_entry_map array. If it is a valid entry, it gets
-** the state table.Set the next state, if not NULL state.Execute
-** the action function according to the state table. If the state
-** returned by action function is not NULL state, adjust the new
-** state to the returned state.If (api_evt != MAX), call callback
-** function.
-**
-** Returns void.
-**
-*******************************************************************************/
-void obx_ssm_event(tOBX_SR_SESS_CB *p_scb, tOBX_SR_EVENT event, BT_HDR *p_msg)
-{
- UINT8 curr_state = p_scb->state;
- tOBX_SM_TBL state_table;
- UINT8 action, entry;
- tOBX_SR_STATE act_state = OBX_SS_NULL;
- UINT8 *p_data;
- UINT16 len;
- BT_HDR *p_dummy;
- tOBX_EVENT api_evt;
- tOBX_SR_CB *p_cb;
-#if 0
- UINT8 srm;
-#endif
-
- if( curr_state == OBX_SS_NULL || curr_state >= OBX_SS_MAX)
- {
- OBX_TRACE_WARNING1( "Invalid state: %d", curr_state) ;
- if(p_msg)
- GKI_freebuf(p_msg);
- return;
- }
-
- OBX_TRACE_DEBUG6( "For Server SHandle 0x%x, State: %s, Event: %s/%d srm:0x%x ssn:%d",
- p_scb->ll_cb.comm.handle, obx_sr_get_state_name( p_scb->state ),
- obx_sr_get_event_name(event), event, p_scb->srm, p_scb->ssn ) ;
-
- /* look up the state table for the current state */
- /* lookup entry /w event & curr_state */
- /* If entry is ignore, return.
- * Otherwise, get state table (according to curr_state or all_state) */
- /* coverity [index_parm] */
- if( (entry = obx_ssm_entry_map[event][curr_state-1]) != OBX_SM_IGNORE )
- {
- if(entry&OBX_SM_ALL)
- {
- entry &= OBX_SM_ENTRY_MASK;
- state_table = obx_sr_all_table;
- }
- else
- state_table = obx_sr_main_state_table[curr_state-1];
- }
- else
- {
- OBX_TRACE_WARNING2( "Ignore event %d in state %d", event, curr_state );
- if(p_msg)
- GKI_freebuf(p_msg);
- return;
- }
-
- /* Get possible next state from state table. */
- if( state_table[entry-1][OBX_SME_NEXT_STATE] != OBX_CS_NULL )
- p_scb->state = state_table[entry-1][OBX_SME_NEXT_STATE];
- p_scb->prev_state = curr_state;
- OBX_TRACE_DEBUG3( "possible new state = %s/%s/%d",
- obx_sr_get_state_name(p_scb->state), obx_sr_get_state_name( p_scb->prev_state ), p_scb->prev_state) ;
-
- /* If action is not ignore, clear param, exec action and get next state.
- * The action function may set the Param for cback.
- * Depending on param, call cback or free buffer. */
- /* execute action */
- action = state_table[entry-1][OBX_SME_ACTION];
- if (action != OBX_SM_NO_ACTION)
- {
- act_state = (*obx_sr_action[action])(p_scb, p_msg);
- }
-
- /* adjust next state, if it needs to use the new state returned from action function */
- if( act_state != OBX_CS_NULL)
- {
- p_scb->state = act_state;
- OBX_TRACE_DEBUG1( "new state = %s (action)", obx_sr_get_state_name( p_scb->state ) ) ;
- }
-
- if(p_scb->api_evt)
- {
- api_evt = p_scb->api_evt;
- p_scb->api_evt = OBX_NULL_EVT;
- /* we do not want the operation to be challenged by the client */
- if( event <= OBX_SEVT_MAX_REQ && event != OBX_CONNECT_REQ_SEVT &&
- OBX_ReadByteStrHdr(p_msg, OBX_HI_CHALLENGE, &p_data, &len, 0) == TRUE)
- {
- /* send bad request response */
- p_dummy = obx_build_dummy_rsp(p_scb, OBX_RSP_BAD_REQUEST);
- event += OBX_SEVT_DIFF_REQ_CFM;
- obx_ssm_event(p_scb, event, p_dummy);
- GKI_freebuf(p_msg);
- }
- else
- {
- p_cb = &obx_cb.server[p_scb->handle - 1];
- (p_cb->p_cback) (p_scb->ll_cb.comm.handle, api_evt, p_scb->param, p_msg);
- }
- memset(&p_scb->param, 0, sizeof (p_scb->param) );
- }
- else if(action == OBX_SM_NO_ACTION && p_msg)
- GKI_freebuf(p_msg);
-
-
- OBX_TRACE_DEBUG2( "result state = %s ssn:%d", obx_sr_get_state_name( p_scb->state ), p_scb->ssn ) ;
-}
-
-
diff --git a/stack/obx/obx_utils.c b/stack/obx/obx_utils.c
deleted file mode 100644
index 785df18..0000000
--- a/stack/obx/obx_utils.c
+++ /dev/null
@@ -1,979 +0,0 @@
-/*****************************************************************************
-**
-** Name: obx_utils.c
-**
-** File: OBEX common utility functions
-**
-** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include <string.h>
-#include <stdio.h>
-#include "wcassert.h"
-
-
-#include "bt_target.h"
-#include "obx_int.h"
-#include "port_api.h"
-#include "sdpdefs.h"
-#include "l2c_api.h"
-
-const tOBX_EVENT obx_sm_evt_to_api_evt[OBX_MAX_EVT_MAP_NUM] =
-{
- OBX_CONNECT_REQ_EVT,
- OBX_SESSION_REQ_EVT, /* A Crease Session or Resume Session request is received by the server. Call OBX_SessionRsp(). */
- OBX_DISCONNECT_REQ_EVT,
- OBX_PUT_REQ_EVT,
- OBX_GET_REQ_EVT,
- OBX_SETPATH_REQ_EVT,
- OBX_ACTION_REQ_EVT, /* An Action request is received by the server. Call OBX_ActionRsp(). */
- OBX_ABORT_REQ_EVT
-};
-
-
-const UINT8 obx_rsp_code[] =
-{
- OBX_RSP_CONTINUE, /* 0x10 Continue */
- OBX_RSP_OK, /* 0x20 OK, Success */
- OBX_RSP_CREATED, /* 0x21 Created */
- OBX_RSP_ACCEPTED, /* 0x22 Accepted */
- OBX_RSP_NON_AUTH_INFO, /* 0x23 Non-Authoritative Information */
- OBX_RSP_NO_CONTENT, /* 0x24 No Content */
- OBX_RSP_RESET_CONTENT, /* 0x25 Reset Content */
- OBX_RSP_PART_CONTENT, /* 0x26 Partial Content */
- OBX_RSP_MULTI_CHOICES, /* 0x30 Multiple Choices */
- OBX_RSP_MVD_PERM, /* 0x31 Moved Permanently */
- OBX_RSP_MVD_TEMP, /* 0x32 Moved temporarily */
- OBX_RSP_SEE_OTHER, /* 0x33 See Other */
- OBX_RSP_NOT_MODIFIED, /* 0x34 Not modified */
- OBX_RSP_USE_PROXY, /* 0x35 Use Proxy */
- OBX_RSP_BAD_REQUEST, /* 0x40 Bad Request - server couldn't understand request */
- OBX_RSP_UNAUTHORIZED, /* 0x41 Unauthorized */
- OBX_RSP_PAYMENT_REQD, /* 0x42 Payment required */
- OBX_RSP_FORBIDDEN, /* 0x43 Forbidden - operation is understood but refused */
- OBX_RSP_NOT_FOUND, /* 0x44 Not Found */
- OBX_RSP_NOT_ALLOWED, /* 0x45 Method not allowed */
- OBX_RSP_NOT_ACCEPTABLE, /* 0x46 Not Acceptable */
- OBX_RSP_PROXY_AUTH_REQD, /* 0x47 Proxy Authentication required */
- OBX_RSP_REQUEST_TIMEOUT, /* 0x48 Request Time Out */
- OBX_RSP_CONFLICT, /* 0x49 Conflict */
- OBX_RSP_GONE, /* 0x4A Gone */
- OBX_RSP_LENGTH_REQD, /* 0x4B Length Required */
- OBX_RSP_PRECONDTN_FAILED, /* 0x4C Precondition failed */
- OBX_RSP_REQ_ENT_2_LARGE, /* 0x4D Requested entity too large */
- OBX_RSP_REQ_URL_2_LARGE, /* 0x4E Request URL too large */
- OBX_RSP_UNSUPTD_TYPE, /* 0x4F Unsupported media type */
- OBX_RSP_INTRNL_SRVR_ERR, /* 0x50 Internal Server Error */
- OBX_RSP_NOT_IMPLEMENTED, /* 0x51 Not Implemented */
- OBX_RSP_BAD_GATEWAY, /* 0x52 Bad Gateway */
- OBX_RSP_SERVICE_UNAVL, /* 0x53 Service Unavailable */
- OBX_RSP_GATEWAY_TIMEOUT, /* 0x54 Gateway Timeout */
- OBX_RSP_HTTP_VER_NOT_SUPTD, /* 0x55 HTTP version not supported */
- OBX_RSP_DATABASE_FULL, /* 0x60 Database Full */
- OBX_RSP_DATABASE_LOCKED, /* 0x61 Database Locked */
- OBX_RSP_DEFAULT
-};
-
-static void obx_read_mtu(BT_HDR *p_pkt, tOBX_HANDLE handle, tOBX_CONN_EVT *p_evt);
-
-/*******************************************************************************
-** Function obx_read_srm
-** Description read the SRM and SRM_PARAM headers from the packet received from
-** peer and set the control block data member accordingly
-** Return UINT8
-*******************************************************************************/
-UINT8 obx_read_srm (tOBX_SRM *p_srm, BOOLEAN is_client, BT_HDR *p_pkt)
-{
- UINT8 srm, srmp = 0, ret_srmp=0;
- UINT8 old_srm = *p_srm;
- BOOLEAN allowed = FALSE, clear = TRUE;
-
- OBX_TRACE_DEBUG1("obx_read_srm srm:0x%x", *p_srm );
- if (*p_srm)
- {
- /* if the SRM enable request is not granted in the next packet, the request is not valid any more
- * clear the requesting flag */
- *p_srm &= ~OBX_SRM_REQING;
-
- if (OBX_Read1ByteHdr(p_pkt, OBX_HI_SRM, &srm))
- {
- if (srm == OBX_HV_SRM_ENABLE)
- {
- if (is_client)
- {
- if (old_srm & OBX_SRM_REQING)
- {
- *p_srm |= OBX_SRM_ENGAGE;
- allowed = TRUE;
- }
- }
- else /* is server */
- {
- *p_srm |= OBX_SRM_REQING;
- allowed = TRUE;
- }
- }
- OBX_TRACE_DEBUG3("SRM :0x%x srm:0x%x old_srm:0x%x", srm, *p_srm, old_srm );
- }
-
- if (!allowed)
- allowed = old_srm & OBX_SRM_PARAM_AL;
-
- if (OBX_Read1ByteHdr(p_pkt, OBX_HI_SRM_PARAM, &srmp))
- {
- if ((srmp == OBX_HV_SRM_PARAM_WAIT) && allowed)
- {
- ret_srmp = OBX_SRMP_WAIT;
- *p_srm |= OBX_SRM_PARAM_AL;
- clear = FALSE;
- }
- }
- OBX_TRACE_DEBUG4("SRM_PARAM :0x%x srm:0x%x allowed:%d clear:%d", srmp, *p_srm, allowed, clear );
-
- /* once the SRMP header is not used, it should be ignored for the rest of the transaction */
- if (clear)
- *p_srm &= ~OBX_SRM_PARAM_AL;
- }
-
- return ret_srmp;
-}
-
-/*******************************************************************************
-** Function obx_add_timeout
-** Description add the timeout triplet
-**
-** Return UINT8
-*******************************************************************************/
-UINT8 obx_add_timeout (tOBX_TRIPLET *p_trip, UINT32 timeout, tOBX_SESS_EVT *p_param)
-{
- UINT8 *p;
- UINT8 ret = 0;
-
- if (timeout != OBX_INFINITE_TIMEOUT)
- {
- p_trip->tag = OBX_TAG_SESS_PARAM_TOUT;
- p_trip->len = OBX_TIMEOUT_SIZE;
- p = p_trip->p_array;
- UINT32_TO_BE_STREAM(p, timeout);
- ret = 1;
- }
- p_param->timeout = timeout;
- return ret;
-}
-
-/*******************************************************************************
-** Function obx_read_timeout
-** Description add the timeout triplet
-**
-** Return void
-*******************************************************************************/
-void obx_read_timeout (tOBX_TRIPLET *p_trip, UINT8 num, UINT32 *p_timeout, UINT8 *p_toa)
-{
- UINT8 ind;
- UINT8 *p;
- UINT32 tmp;
-
- p = p_toa;
- BE_STREAM_TO_UINT32(tmp, p);
- OBX_TRACE_DEBUG2("obx_read_timeout %d/%d", *p_timeout, tmp);
- if (*p_timeout == 0)
- *p_timeout = tmp;
- ind = obx_read_triplet(p_trip, num, OBX_TAG_SESS_PARAM_TOUT);
- if ((ind != num) && (p_trip[ind].len == OBX_TIMEOUT_SIZE))
- {
- p = p_trip[ind].p_array;
- BE_STREAM_TO_UINT32(tmp, p);
- if (tmp < (*p_timeout))
- {
- (*p_timeout) = tmp;
- OBX_TRACE_DEBUG1("new timeout %d", tmp);
- }
- }
- UINT32_TO_BE_STREAM(p_toa, (*p_timeout));
-}
-
-#if (OBX_CLIENT_INCLUDED == TRUE)
-/*******************************************************************************
-** Function obx_verify_response
-** Description
-** Return OBX_BAD_SM_EVT, if bad.
-*******************************************************************************/
-UINT8 obx_verify_response(UINT8 opcode, tOBX_RX_HDR *p_rxh)
-{
- UINT8 final = (opcode & OBX_FINAL) ? TRUE : FALSE;
- int xx = 0;
- UINT8 res_code = opcode & ~OBX_FINAL;
-
- p_rxh->sm_evt = OBX_BAD_SM_EVT;
-
- /* response packet must have the final bit set */
- if (final == TRUE)
- {
- if (res_code == OBX_RSP_CONTINUE)
- {
- p_rxh->sm_evt = OBX_CONT_CFM_CEVT;
- }
- else
- {
- /* figure out the kind of response, Continue, OK, or Error */
- while(obx_rsp_code[xx] != OBX_RSP_DEFAULT)
- {
- if (obx_rsp_code[xx] == res_code)
- break;
- xx++;
- }
-
- if (obx_rsp_code[xx] != OBX_RSP_DEFAULT)
- {
- if (obx_rsp_code[xx] <= OBX_MAX_OK_RSP)
- p_rxh->sm_evt = OBX_OK_CFM_CEVT;
- else
- p_rxh->sm_evt = OBX_FAIL_CFM_CEVT;
- }
- /* else bad response code */
- }
- if (p_rxh->sm_evt != OBX_BAD_SM_EVT)
- {
- p_rxh->code = opcode;
- }
- }
- /*
- else final bit not set in response packet -> bad response code
- */
-
- return p_rxh->sm_evt;
-}
-
-/*******************************************************************************
-**
-** Function obx_cl_proc_pkt
-**
-** Description process a packet received from the connected server
-** verify that the response is valid
-** fill in event parameters
-** call csm to process the event
-**
-** Returns void
-**
-*******************************************************************************/
-void obx_cl_proc_pkt (tOBX_CL_CB *p_cb, BT_HDR *p_pkt)
-{
- tOBX_RX_HDR *p_rxh;
- UINT32 conn_id;
- BOOLEAN pass = FALSE;
- UINT8 xx;
- tOBX_TRIPLET triplet[OBX_MAX_NUM_AUTH_TRIPLET];
- UINT8 num_trip = OBX_MAX_NUM_AUTH_TRIPLET;
- tOBX_CL_EVENT sm_evt;
- UINT8 ssn;
-
- OBX_TRACE_DEBUG3("obx_cl_proc_pkt 0x%x srm:0x%x, sess_st:%d", p_pkt, p_cb->srm, p_cb->sess_st);
- OBX_TRACE_DEBUG1("csm offset:%d", p_cb->param.sess.obj_offset);
-
- p_rxh = (tOBX_RX_HDR *)(p_pkt + 1);
- p_cb->rsp_code = p_rxh->code & ~OBX_FINAL;
-
- p_pkt->event = OBX_PUT_RSP_EVT; /* any response */
- /* setup callback event param
- memset(&p_cb->param, 0, sizeof(tOBX_EVT_PARAM)); */
-
- if (p_cb->state == OBX_CS_CONNECT_REQ_SENT )
- {
- /* when a response packet is received in conn_rs state,
- * it must be a connect response packet */
- p_pkt->event = OBX_CONNECT_RSP_EVT;
- p_cb->param.conn.handle = p_cb->ll_cb.port.handle;
- obx_read_mtu(p_pkt, p_cb->ll_cb.port.handle, &(p_cb->param.conn));
- p_cb->ll_cb.port.tx_mtu = p_cb->param.conn.mtu;
-
- /* save Connection ID */
- if (OBX_Read4ByteHdr(p_pkt, OBX_HI_CONN_ID, &conn_id) == TRUE)
- p_cb->conn_id = conn_id;
- OBX_TRACE_DEBUG1("Connection ID: 0x%x", p_cb->conn_id );
- }
-
- if (p_cb->sess_st == OBX_SESS_ACTIVE)
- {
- /* verify the session sequence number */
- if (OBX_Read1ByteHdr (p_pkt, OBX_HI_SESSION_SN, &ssn))
- {
- OBX_TRACE_DEBUG1("ssn:%d", ssn);
- p_cb->param.ssn = ssn;
- }
- }
-
- sm_evt = p_rxh->sm_evt;
-
- if (p_cb->wait_auth == TRUE)
- {
- /* this can only happen for CONNECT */
- if (p_cb->rsp_code == OBX_RSP_OK)
- {
- /* successful according to server */
- /* verify the digest */
- p_cb->wait_auth = FALSE;
- /* The coverity complaints on this function is not correct.
- * The value in triplet[] is set/initialized by OBX_ReadTriplet if num_trip returns TRUE.
- * leave this unnecessary memset here */
- memset(triplet,0,sizeof(triplet));
- if (OBX_ReadTriplet(p_pkt, OBX_HI_AUTH_RSP, triplet, &num_trip))
- {
- for (xx=0; xx<num_trip; xx++)
- {
- if (triplet[xx].tag == OBX_DIGEST_RSP_TAG)
- {
- if (memcmp (p_cb->p_auth, triplet[xx].p_array, OBX_DIGEST_SIZE) == 0)
- pass = TRUE;
- break;
- }
- }
- }
- if (pass == FALSE)
- {
- OBX_TRACE_ERROR0("Failed - server does not provide good digest" );
- p_cb->wait_auth = OBX_WAIT_AUTH_FAIL;
- p_cb->rsp_code = OBX_RSP_FAILED;
- }
- }
- }
- if (p_cb->p_auth)
- GKI_freebuf(p_cb->p_auth);
- p_cb->p_auth = NULL;
-
- p_cb->srmp = obx_read_srm (&p_cb->srm, TRUE, p_pkt);
- obx_csm_event(p_cb, sm_evt, p_pkt);
-}
-
-/*******************************************************************************
-**
-** Function obx_cl_prepend_msg
-**
-** Description This function is used by API functions to add the data in the
-** reserved space in the OBEX packet
-**
-** Returns void.
-**
-*******************************************************************************/
-BT_HDR * obx_cl_prepend_msg(tOBX_CL_CB *p_cb, BT_HDR *p_pkt, UINT8 * p_data, UINT16 data_len)
-{
- UINT8 *p;
- UINT16 len;
-
- if (p_pkt == NULL)
- {
- p_pkt = OBX_HdrInit(OBX_HANDLE_NULL, OBX_MIN_MTU);
- len = data_len;
- }
- else
- {
- len = p_pkt->len + data_len;
- }
-
- WC_ASSERT(p_pkt->offset >= data_len);
- p = (UINT8 *)(p_pkt + 1) + p_pkt->offset - data_len;
- memcpy(p, p_data, data_len);
- p++;
- /* adjust the packet len */
- UINT16_TO_BE_STREAM(p, len);
- p_pkt->len += data_len;
- p_pkt->offset -= data_len;
- p_pkt->layer_specific -= data_len;
-
- return p_pkt;
-}
-#endif /* OBX_CLIENT_INCLUDED */
-
-#if (OBX_SERVER_INCLUDED == TRUE)
-/*******************************************************************************
-** Function obx_verify_request
-** Description
-** Return OBX_BAD_SM_EVT, if bad.
-*******************************************************************************/
-UINT8 obx_verify_request(UINT8 opcode, tOBX_RX_HDR *p_rxh)
-{
- UINT8 final = (opcode & OBX_FINAL) ? TRUE : FALSE;
- UINT8 req_code = opcode & ~OBX_FINAL;
- p_rxh->sm_evt = OBX_BAD_SM_EVT;
-
- OBX_TRACE_DEBUG2("obx_verify_request opcode 0x%x: final:%d", opcode, final);
- switch (req_code)
- {
- case OBX_REQ_CONNECT:
- /* this request must have the final bit set */
- if (final == TRUE)
- p_rxh->sm_evt = OBX_CONNECT_REQ_SEVT;
- break;
-
- case OBX_REQ_SESSION:
- /* this request must have the final bit set */
- if (final == TRUE)
- p_rxh->sm_evt = OBX_SESSION_REQ_SEVT;
- break;
-
- case OBX_REQ_ACTION:
- /* this request must have the final bit set */
- if (final == TRUE)
- p_rxh->sm_evt = OBX_ACTION_REQ_SEVT;
- break;
-
- case OBX_REQ_DISCONNECT:
- /* this request must have the final bit set */
- if (final == TRUE)
- p_rxh->sm_evt = OBX_DISCNT_REQ_SEVT;
- break;
-
- case OBX_REQ_PUT:
- p_rxh->sm_evt = OBX_PUT_REQ_SEVT;
- break;
-
- case OBX_REQ_GET:
- p_rxh->sm_evt = OBX_GET_REQ_SEVT;
- break;
-
- case OBX_REQ_SETPATH:
- /* this request must have the final bit set */
- if (final == TRUE)
- p_rxh->sm_evt = OBX_SETPATH_REQ_SEVT;
- break;
-
- case OBX_REQ_ABORT:
- /* this request must have the final bit set */
- if (final == TRUE)
- p_rxh->sm_evt = OBX_ABORT_REQ_SEVT;
- break;
- }
-
- if (p_rxh->sm_evt != OBX_BAD_SM_EVT)
- {
- p_rxh->code = opcode;
- }
- return p_rxh->sm_evt;
-}
-
-/*******************************************************************************
-**
-** Function obx_is_get_or_put_cont
-**
-** Returns TRUE, if it's a GET/PUT continuing continuing
-** TRUE, if it's an ABORT
-**
-*******************************************************************************/
-BOOLEAN obx_is_get_or_put_cont (tOBX_SR_SESS_CB *p_scb, UINT8 req_code)
-{
- BOOLEAN is_cont = FALSE;
-
- if (req_code == OBX_REQ_ABORT)
- {
- is_cont = TRUE;
- }
- else if (req_code == OBX_REQ_PUT)
- {
- if (p_scb->state == OBX_SS_PUT_TRANSACTION || p_scb->state == OBX_SS_PUT_SRM)
- {
- is_cont = TRUE;
- }
- }
- else if (req_code == OBX_REQ_GET)
- {
- if (p_scb->state == OBX_SS_GET_TRANSACTION || p_scb->state == OBX_SS_GET_SRM)
- {
- is_cont = TRUE;
- }
- }
-
- return is_cont;
-}
-
-/*******************************************************************************
-**
-** Function obx_sr_proc_pkt
-**
-** Description process a packet received from the connected client
-** verify that the request is valid
-** fill in event parameters
-** call ssm to process the event
-**
-** Returns TRUE, if abort
-**
-*******************************************************************************/
-BOOLEAN obx_sr_proc_pkt (tOBX_SR_SESS_CB *p_scb, BT_HDR *p_pkt)
-{
- tOBX_RX_HDR *p_rxh;
- UINT8 *p_body;
- UINT16 len;
- BOOLEAN end;
- UINT32 conn_id = 0;
- UINT8 req_code;
- BOOLEAN final;
- UINT8 ssn, tmp_ssn;
- UINT8 num_hdrs, num_body, num_ssn;
- UINT8 rsp_code = OBX_RSP_OK;
- UINT8 num_id;
- BOOLEAN chk_add = FALSE;
-
- p_rxh = (tOBX_RX_HDR *)(p_pkt + 1);
- final = (p_rxh->code & OBX_FINAL) ? TRUE : FALSE;
- req_code = p_rxh->code & ~OBX_FINAL;
- p_scb->api_evt = (UINT8)p_pkt->event;
- memset(&p_scb->param, 0, sizeof(tOBX_EVT_PARAM));
- p_scb->param.get.final = final;
-
- num_id = OBX_Read4ByteHdr (p_pkt, OBX_HI_CONN_ID, &conn_id);
-
- OBX_TRACE_DEBUG6("obx_sr_proc_pkt 0x%x srm:0x%x sess_st:%d req_code:0x%x, sm_evt:%d ssn:%d",
- p_pkt, p_scb->srm, p_scb->sess_st, req_code, p_rxh->sm_evt, p_scb->ssn);
-
- num_ssn = OBX_Read1ByteHdr (p_pkt, OBX_HI_SESSION_SN, &ssn);
- if (p_scb->srm & OBX_SRM_ABORT)
- {
- /* OBX_SRM_ABORT bit is set by server only when PUT req /w SRM is rejected before transaction actually ends
- * this means we need to ignore follow packets until the next transaction starts */
- if (req_code == OBX_REQ_PUT)
- {
- /* check if this is the put for the previous transaction */
- num_hdrs = OBX_ReadNumHdrs(p_pkt, &num_body);
- OBX_TRACE_DEBUG4("num_hdrs:%d num_body:%d num_id:%d num_ssn:%d", num_hdrs, num_body, num_id, num_ssn);
- num_body += num_ssn;
- num_body += num_id;
- if (num_hdrs <= num_body)
- {
- p_scb->ssn = ssn+1;
- /* it is left-over, drop it. */
- if (p_pkt)
- GKI_freebuf (p_pkt);
- p_scb->api_evt = OBX_NULL_EVT;
- return TRUE;
- }
- }
- /* clear the SRM bits; leave only the enabled bit */
- p_scb->srm &= OBX_SRM_ENABLE;
- }
-
- if ((p_scb->sess_st == OBX_SESS_ACTIVE) && (req_code != OBX_REQ_SESSION) && (req_code != OBX_REQ_ABORT))
- {
- rsp_code = OBX_RSP_BAD_REQUEST;
- /* verify the session sequence number */
- if (num_ssn)
- {
- OBX_TRACE_DEBUG2("ssn pkt/cb=%d/%d", ssn, p_scb->ssn);
- if (ssn == p_scb->ssn)
- {
- p_scb->param.ssn = p_scb->ssn;
- rsp_code = OBX_RSP_OK;
- }
- else if (p_scb->srmp & OBX_SRMP_SESS_FST)
- {
- tmp_ssn = ssn+1;
- if (tmp_ssn == p_scb->ssn)
- {
- p_scb->param.ssn = ssn;
- p_scb->ssn = ssn;
- rsp_code = OBX_RSP_OK;
- }
- }
- }
- p_scb->srmp &= ~OBX_SRMP_SESS_FST;
- }
-
- /* fill event parameter */
- if (req_code == OBX_REQ_CONNECT)
- {
- p_scb->param.conn.handle = p_scb->handle;
- obx_read_mtu(p_pkt, p_scb->ll_cb.comm.handle, &(p_scb->param.conn));
-
- p_scb->ll_cb.port.tx_mtu = p_scb->param.conn.mtu;
- /* verify the target header and connection ID
- * in obx_sa_connect_ind() for OBX_SS_NOT_CONNECTED */
- /* verify the connection ID in obx_sa_auth_ind() for OBX_SS_WAIT_AUTH */
- chk_add = TRUE;
- }
- else if (req_code == OBX_REQ_SESSION)
- {
- /* do nothing */
- if (conn_id != 0)
- {
- OBX_TRACE_ERROR1("Session command should not use Connection ID: 0x%x", conn_id);
- p_rxh->sm_evt = OBX_BAD_REQ_SEVT;
- }
- }
- else
- {
- OBX_TRACE_DEBUG3("Connection ID: 0x%x/0x%x state:%d", p_scb->conn_id, conn_id, p_scb->state );
- /* verify the connection ID */
- if ( (conn_id == p_scb->conn_id) ||
- (conn_id == 0 && p_scb->conn_id != 0 && obx_is_get_or_put_cont(p_scb, req_code)))
- {
- /* match: both non-exist or both exist and equal */
- /* connection ID header does not exist, but control block uses connection ID,
- * if this is continuation packets for PUT and GET, it's OK */
- if (req_code == OBX_REQ_PUT)
- {
- p_scb->param.put.final = final;
-
- /* determine the PUT type */
- p_scb->param.put.type = OBX_PT_PUT;
- if (p_scb->state == OBX_SS_CONNECTED && final == TRUE)
- {
- if (OBX_ReadBodyHdr(p_pkt, &p_body, &len, &end) == FALSE)
- {
- /* final is set, no BODY or End-of-Body
- * -> Delete request */
- p_scb->param.put.type = OBX_PT_DELETE;
- }
- else if (end == TRUE && len == 0)
- {
- /* an empty End-of-Body header
- * -> Create-Empty request */
- p_scb->param.put.type = OBX_PT_CREATE;
- }
- }
- OBX_TRACE_EVENT1("Put request type: %d", p_scb->param.put.type);
- }
- else if (req_code == OBX_REQ_SETPATH)
- {
- p_scb->param.sp.flag = *((UINT8 *)(p_pkt + 1) + p_pkt->offset + OBX_SETPATH_FLAG_OFFSET);
- }
- }
- else
- {
- /* does not have good connection ID */
- p_rxh->sm_evt = OBX_BAD_REQ_SEVT;
- p_scb->api_evt = OBX_NULL_EVT;
- }
- }
-
- /* process the SRM header */
- p_scb->srmp |= obx_read_srm (&p_scb->srm, FALSE, p_pkt);
-
- if (p_rxh->sm_evt != OBX_BAD_REQ_SEVT && req_code != OBX_REQ_ABORT)
- {
- p_scb->cur_op = req_code;
- if (final)
- p_scb->cur_op |= OBX_FINAL;
- }
-
- if (rsp_code != OBX_RSP_OK)
- {
- p_rxh->sm_evt = OBX_BAD_REQ_SEVT;
- }
-
- OBX_TRACE_DEBUG2("rsp_code:0x%x, sm_evt:%d", rsp_code, p_rxh->sm_evt);
-
- obx_ssm_event(p_scb, p_rxh->sm_evt, p_pkt);
- if (chk_add)
- {
- if (p_scb->ll_cb.comm.p_send_fn == (tOBX_SEND_FN *)obx_rfc_snd_msg)
- obx_add_port(p_scb->handle);
- }
- return FALSE;
-}
-
-/*******************************************************************************
-**
-** Function obx_sr_prepend_msg
-**
-** Description This function is used by API functions to add the data in the
-** reserved space in the OBEX packet
-**
-** Returns void.
-**
-*******************************************************************************/
-BT_HDR * obx_sr_prepend_msg(BT_HDR *p_pkt, UINT8 * p_data, UINT16 data_len)
-{
- UINT8 *p;
- UINT16 len;
-
- if (p_pkt == NULL)
- {
- p_pkt = OBX_HdrInit(OBX_HANDLE_NULL, OBX_MIN_MTU);
- len = data_len;
- }
- else
- {
- len = p_pkt->len + data_len;
- }
-
- WC_ASSERT(p_pkt->offset >= data_len);
- p = (UINT8 *)(p_pkt + 1) + p_pkt->offset - data_len;
- memcpy(p, p_data, data_len);
- p++;
- /* adjust the packet len */
- UINT16_TO_BE_STREAM(p, len);
- p_pkt->len += data_len;
- p_pkt->offset -= data_len;
- p_pkt->layer_specific -= data_len;
-
- return p_pkt;
-}
-#endif /* OBX_SERVER_INCLUDED */
-
-/*******************************************************************************
-**
-** Function obx_read_mtu
-**
-** Description This function is used to access the MTU in CONNECT packets
-**
-** Returns void.
-**
-*******************************************************************************/
-void obx_read_mtu(BT_HDR *p_pkt, tOBX_HANDLE handle, tOBX_CONN_EVT *p_evt)
-{
- UINT8 *p = (UINT8 *)(p_pkt + 1) + p_pkt->offset + OBX_CONNECT_MTU_OFFSET;
-
- BE_STREAM_TO_UINT16(p_evt->mtu, p);
- if (p_evt->mtu > OBX_MAX_MTU)
- p_evt->mtu = OBX_MAX_MTU;
- if (p_evt->mtu == 0)
- p_evt->mtu = OBX_MIN_MTU;
-
- /* Get the Bd_Addr */
- OBX_GetPeerAddr (handle, p_evt->peer_addr);
-}
-
-/*******************************************************************************
-**
-** Function obx_free_buf
-**
-** Description This function is used to free the GKI buffers of the given
-** lower layer control block
-**
-** Returns void.
-**
-*******************************************************************************/
-void obx_free_buf(tOBX_LL_CB *p_ll_cb)
-{
- void *p_pkt;
-
-
- if (p_ll_cb->comm.p_send_fn == (tOBX_SEND_FN *)obx_rfc_snd_msg)
- {
- if (p_ll_cb->port.p_rxmsg)
- {
- OBX_TRACE_WARNING0("obx_free_buf release p_rxmsg");
- GKI_freebuf(p_ll_cb->port.p_rxmsg);
- p_ll_cb->port.p_rxmsg = 0;
- }
- }
-
- if (!GKI_queue_is_empty(&p_ll_cb->comm.rx_q))
- {
- while((p_pkt = GKI_dequeue (&p_ll_cb->comm.rx_q)) != NULL)
- {
- OBX_TRACE_WARNING0("obx_free_buf release rx_q");
- GKI_freebuf(p_pkt);
- }
- }
-
- if (p_ll_cb->comm.p_txmsg)
- {
- OBX_TRACE_WARNING0("obx_free_buf release p_txmsg");
- GKI_freebuf(p_ll_cb->comm.p_txmsg);
- p_ll_cb->comm.p_txmsg = 0;
- }
-}
-
-/*******************************************************************************
-**
-** Function obx_flow_control
-**
-** Description If we had flowed control the peer, enable the data path now
-**
-** Returns void.
-**
-*******************************************************************************/
-void obx_flow_control(tOBX_COMM_CB *p_comm)
-{
- OBX_TRACE_DEBUG1 ("obx_flow_control stopped:%d", p_comm->stopped );
- if (p_comm->stopped)
- {
- if (p_comm->p_send_fn == (tOBX_SEND_FN *)obx_rfc_snd_msg)
- {
- PORT_FlowControl(p_comm->id, TRUE);
- }
- else
- {
- L2CA_FlowControl(p_comm->id, TRUE);
- }
- p_comm->stopped = FALSE;
- }
-}
-
-/*****************************************************************************
-* Function: obx_read_triplet
-* Purpose: Read the application parameters with the given tag
-*****************************************************************************/
-UINT8 obx_read_triplet(tOBX_TRIPLET *p_trip, UINT8 num_trip, UINT8 tag)
-{
- UINT8 xx = 0;
-
- for (xx=0; xx<num_trip; xx++, p_trip++)
- {
- if (p_trip->tag == tag)
- {
- break;
- }
- }
-
- return xx;
-}
-/*****************************************************************************
-* Function: obx_read_obj_offset
-* Purpose: Read the application parameters with the object offset tag
-*****************************************************************************/
-UINT32 obx_read_obj_offset(tOBX_TRIPLET *p_trip, UINT8 num_trip)
-{
- UINT32 obj_offset = 0;
- UINT8 ind;
- UINT8 *p = NULL, *pe;
- UINT8 extra = 0, xx;
-
- ind = obx_read_triplet(p_trip, num_trip, OBX_TAG_SESS_PARAM_OBJ_OFF);
- if (ind != num_trip)
- {
- if (p_trip[ind].len == 4)
- {
- p = p_trip[ind].p_array;
- }
- else if (p_trip[ind].len > 4)
- {
- extra = p_trip[ind].len - 4;
- }
-
- if (extra)
- {
- /* the TLV is bigger than 4 bytes
- * if the MSBs are all 0, we can still handle it with UINT32 */
- pe = p_trip[ind].p_array;
- for (xx=0; xx<extra; xx++)
- {
- if (*pe == 0)
- pe++;
- else
- break;
- }
- if (xx == extra)
- p = pe;
- }
-
- if (p)
- BE_STREAM_TO_UINT32(obj_offset, p);
- }
-
- return obj_offset;
-}
-
-/*******************************************************************************
-**
-** Function obxu_dump_hex
-**
-** Description This function dumps hex data
-**
-*/
-#if (BT_USE_TRACES == TRUE)
-void obxu_dump_hex (UINT8 *p, char *p_title, UINT16 len)
-{
- UINT16 xx, yy;
- char buff1[100], buff2[20];
-
- if (p_title)
- OBX_TRACE_DEBUG1 ("%s:", p_title);
-
- memset (buff2, ' ', 16);
- buff2[16] = 0;
-
- yy = sprintf (buff1, "%04x: ", 0);
- for (xx = 0; xx < len; xx++)
- {
- if ( (xx) && ((xx & 15) == 0) )
- {
- OBX_TRACE_DEBUG2 (" %s %s", buff1, buff2);
- yy = sprintf(buff1, "%04x: ", xx);
- memset (buff2, ' ', 16);
- }
- yy += sprintf (&buff1[yy], "%02x ", *p);
-
- if ((*p >= ' ') && (*p <= 'z'))
- buff2[xx & 15] = *p;
- else
- buff2[xx & 15] = '.';
-
- p++;
- }
-
- /* Pad out the remainder */
- for ( ; ; xx++)
- {
- if ((xx & 15) == 0)
- {
- OBX_TRACE_DEBUG2 (" %s %s", buff1, buff2);
- break;
- }
- yy += sprintf (&buff1[yy], " ");
- }
-
-}
-#endif
-
-/*******************************************************************************
-**
-** Function OBX_GetPeerAddr
-**
-** Description This function is called to learn the Bluetooth address of the
-** connected device.
-**
-** Returns L2CAP channel ID.
-**
-*******************************************************************************/
-UINT16 OBX_GetPeerAddr(tOBX_HANDLE shandle, BD_ADDR bd_addr)
-{
- UINT16 lcid = 0;
-#if (OBX_SERVER_INCLUDED == TRUE)
- tOBX_SR_SESS_CB *p_scb;
-#endif
-#if (OBX_CLIENT_INCLUDED == TRUE)
- tOBX_CL_CB *p_cb;
-
- if (shandle & OBX_CL_HANDLE_MASK)
- {
- p_cb = obx_cl_get_cb(shandle);
- if (p_cb)
- {
- if (p_cb->ll_cb.comm.p_send_fn == (tOBX_SEND_FN *)obx_rfc_snd_msg)
- {
- PORT_CheckConnection(p_cb->ll_cb.port.port_handle, p_cb->peer_addr, &lcid);
- memcpy (bd_addr, p_cb->peer_addr, BD_ADDR_LEN);
- lcid = p_cb->ll_cb.comm.id;
- }
- else if (p_cb->ll_cb.comm.id)
- {
- /* GetPeerAddr for l2c */
- memcpy (bd_addr, p_cb->peer_addr, BD_ADDR_LEN);
- lcid = p_cb->ll_cb.comm.id;
- }
- }
- }
-#endif
-
-#if (OBX_SERVER_INCLUDED == TRUE)
- if ((shandle & OBX_CL_HANDLE_MASK) == 0)
- {
- p_scb = obx_sr_get_scb(shandle);
- if (p_scb)
- {
- if (p_scb->ll_cb.comm.p_send_fn == (tOBX_SEND_FN *)obx_rfc_snd_msg)
- {
- PORT_CheckConnection(p_scb->ll_cb.port.port_handle, bd_addr, &lcid);
- }
- else if (p_scb->ll_cb.comm.id)
- {
- /* GetPeerAddr for l2c */
- memcpy (bd_addr, p_scb->peer_addr, BD_ADDR_LEN);
- lcid = p_scb->ll_cb.comm.id;
- }
- }
- }
-#endif
-
- return lcid;
-}
diff --git a/stack/xml/xml_bld.c b/stack/xml/xml_bld.c
deleted file mode 100644
index 57a7347..0000000
--- a/stack/xml/xml_bld.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*****************************************************************************
-**
-** Name: xml_bld_api.c
-**
-** File: Implements the XML Builder
-**
-**
-** Copyright (c) 2000-2004, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <string.h>
-#include <stdio.h>
-
-#include "bt_target.h"
-#include "xml_bld_api.h"
-
-/* The XML Builder is dependent on the Object Store. At present
-** the object store resides in GOEP and hence the builder is
-** dependent on GOEP. The builder only uses the Object Store
-** in GOEP, so if the Object Store is separated from GOEP in the
-** future, the builder will not be dependent on GOEP.
-*/
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-#define XML_ST "<"
-#define XML_EM "/"
-#define XML_SP " "
-#define XML_CO ":"
-#define XML_EQ "="
-#define XML_GT ">"
-#define XML_QT "\""
-
-#define XML_LF "\n" /* Line feed */
-
-/*****************************************************************************
-** Interface functions
-*****************************************************************************/
-
-
-/*****************************************************************************
-**
-** Function: XML_BufAddTag
-**
-** Purpose: Write a start or end tag and optional prefix.
-**
-** Parameters:
-** UINT8 **pp_buf reference to the storage to hold the XML object
-** GOEP_WriteStore.
-** const UINT8* prefix tag prefix (namespace)
-** const UINT8* tag tag name
-** BOOLEAN start_tag TRUE = start tag, FALSE = end tag
-** BOOLEAN has_attr TRUE if the tag contains attributes
-**
-** Returns: XML_BLD_SUCCESS if success
-**
-*****************************************************************************/
-tXML_BLD_RESULT XML_BufAddTag (UINT8 **pp_buf,
- const UINT8 *prefix,
- const UINT8 *tag,
- BOOLEAN start_tag,
- BOOLEAN has_attr)
-{
- UINT16 status = XML_BLD_ERROR;
- int n;
-
- if (tag != NULL)
- {
- if(start_tag)
- n = sprintf((char *)*pp_buf, XML_ST);
- else
- n = sprintf((char *)*pp_buf, XML_ST XML_EM);
- *pp_buf += n;
-
- if (prefix != NULL)
- {
- n = sprintf((char *)*pp_buf, "%s" XML_CO, prefix );
- *pp_buf += n;
- }
- n = sprintf((char *)*pp_buf, "%s" , tag );
- *pp_buf += n;
- if(!has_attr)
- {
- n = sprintf((char *)*pp_buf, XML_GT);
- *pp_buf += n;
- if (!start_tag)
- {
- n = sprintf((char *)*pp_buf, XML_LF);
- *pp_buf += n;
- }
- }
-
- status = XML_BLD_SUCCESS;
- }
- return status;
-}
-
-
-
-/*****************************************************************************
-**
-** Function: XML_BufAddAttribute
-**
-** Purpose: Write an attribute and optional prefix.
-**
-** Parameters:
-** UINT8 **pp_buf reference to the storage to hold the XML object
-** const UINT8* prefix attribute prefix (namespace)
-** const UINT8* attr_name attribute name
-** const UINT8* attr_value attribute value
-**
-** Returns: XML_BLD_SUCCESS if success
-**
-*****************************************************************************/
-tXML_BLD_RESULT XML_BufAddAttribute (UINT8 **pp_buf,
- const UINT8 *prefix,
- const UINT8 *attr_name,
- const UINT8 *attr_value,
- tXML_ATTR_END last_attr)
-{
- UINT16 status = XML_BLD_ERROR;
- int n;
-
- if (attr_name != NULL && attr_value != NULL)
- {
- n = sprintf((char *)*pp_buf, XML_SP);
- *pp_buf += n;
- if (prefix != NULL)
- {
- n = sprintf((char *)*pp_buf, "%s" XML_CO, prefix );
- *pp_buf += n;
- }
- n = sprintf((char *)*pp_buf, "%s" XML_EQ XML_QT "%s", attr_name, attr_value );
- *pp_buf += n;
- switch(last_attr)
- {
- case XML_ATTR_CONT:
- n = sprintf((char *)*pp_buf, XML_QT );
- break;
- case XML_ATTR_LAST:
- n = sprintf((char *)*pp_buf, XML_QT XML_GT XML_LF );
- break;
- case XML_ATTR_ETAG:
- n = sprintf((char *)*pp_buf, XML_QT XML_EM XML_GT XML_LF );
- break;
- default:
- n = 0;
- break;
- }
- *pp_buf += n;
- status = XML_BLD_SUCCESS;
- }
- else if(last_attr == XML_ATTR_ETAG)
- {
- /* allow the call to only add the closing attribute */
- n = sprintf((char *)*pp_buf, XML_EM XML_GT XML_LF );
- *pp_buf += n ;
- status = XML_BLD_SUCCESS;
- }
- return status;
-}
-
-/*****************************************************************************
-**
-** Function: XML_BufAddCharData
-**
-** Purpose: Write the element content.
-**
-** Parameters:
-** UINT8 **pp_buf reference to the storage to hold the XML object
-** const UINT8* content element content
-**
-** Returns: XML_BLD_SUCCESS if success
-**
-*****************************************************************************/
-tXML_BLD_RESULT XML_BufAddCharData (UINT8 **pp_buf, const UINT8 *charData)
-{
- UINT16 status = XML_BLD_ERROR;
- int n;
-
- if (charData != NULL)
- {
- n = sprintf((char *)*pp_buf, "%s", charData);
- *pp_buf += n;
- status = XML_BLD_SUCCESS;
- }
- return status;
-}
-
diff --git a/stack/xml/xml_erp.c b/stack/xml/xml_erp.c
deleted file mode 100644
index 90711e2..0000000
--- a/stack/xml/xml_erp.c
+++ /dev/null
@@ -1,907 +0,0 @@
-/******************************************************************************
- **
- ** Name: xml_erp.c
- **
- ** Description: This module contains xml parser of MAP event report object
- **
- ** Copyright (c) 2004-2011, Broadcom Corporation, All Rights Reserved.
- ** Broadcom Bluetooth Core. Proprietary and confidential.
- ******************************************************************************/
-
-#include "bt_target.h"
-#include "gki.h"
-#include "xml_erp_api.h"
-
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef EVT_RPT_DEBUG_XML
-#define EVT_RPT_DEBUG_XML TRUE
-#endif
-#define EVT_RPT_DEBUG_LEN 50
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
-#define XML_TRACE_DEBUG0(m) {BT_TRACE_0(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m);}
-#define XML_TRACE_DEBUG1(m,p1) {BT_TRACE_1(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1);}
-#define XML_TRACE_DEBUG2(m,p1,p2) {BT_TRACE_2(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define XML_TRACE_DEBUG3(m,p1,p2,p3) {BT_TRACE_3(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define XML_TRACE_DEBUG4(m,p1,p2,p3,p4) {BT_TRACE_4(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define XML_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {BT_TRACE_5(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define XML_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {BT_TRACE_6(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#else
-#define XML_TRACE_DEBUG0(m)
-#define XML_TRACE_DEBUG1(m,p1)
-#define XML_TRACE_DEBUG2(m,p1,p2)
-#define XML_TRACE_DEBUG3(m,p1,p2,p3)
-#define XML_TRACE_DEBUG4(m,p1,p2,p3,p4)
-#define XML_TRACE_DEBUG5(m,p1,p2,p3,p4,p5)
-#define XML_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6)
-#endif
-
-#define XML_PERM_LEN_MAX 4
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-const UINT8 xml_evt_rpt_elem[] = "MAP-event-report";
-const UINT8 xml_evt_rpt_event_elem[] = "event";
-const UINT8 xml_evt_rpt_type_attr[] = "type";
-const UINT8 xml_evt_rpt_handle_attr[] = "handle";
-const UINT8 xml_evt_rpt_folder_attr[] = "folder";
-const UINT8 xml_evt_rpt_old_folder_attr[] = "old_folder";
-const UINT8 xml_evt_rpt_msg_type_attr[] = "msg_type";
-const UINT8 xml_evt_rpt_version_attr[] = "version";
-const UINT8 xml_evt_rpt_unknown[] = "unknown";
-
-#define XML_EVT_RPT_ELEM_ID 0x01
-#define XML_EVT_RPT_EVT_ELEM_ID 0x02
-#define XML_EVT_RPT_MAX_OBJ_TAG_ID XML_EVT_RPT_ELEM_ID
-#define XML_EVT_RPT_TYPE_ATTR_ID 0x03
-#define XML_EVT_RPT_HANDLE_ATTR_ID 0x04
-#define XML_EVT_RPT_FOLDER_ATTR_ID 0x05
-#define XML_EVT_RPT_OLD_FOLDER_ATTR_ID 0x06
-#define XML_EVT_RPT_MSG_TYPE_ATTR_ID 0x07
-#define XML_EVT_RPT_VERSION_ATTR_ID 0x08
-#define XML_EVT_RPT_UNKNOWN_ID 0x09
-#define XML_EVT_RPT_MAX_ID 0x0a /* keep in sync with above */
-#define XML_EVT_RPT_TAG_END_ID 0x0b /* closing tag found end=true */
-#define XML_EVT_RPT_PAUSE_ID 0x0c /* closing tag found end=false */
-
-
-#define XML_EVT_RPT_TTBL_SIZE (XML_EVT_RPT_MAX_ID+1)
-
-/*****************************************************************************
-** Type Definitions
-*****************************************************************************/
-
-typedef struct
-{
- const UINT8 *p_name;
- UINT8 len;
-} tXML_EVT_RPT_TTBL_ELEM;
-
-typedef tXML_EVT_RPT_TTBL_ELEM tXML_EVT_RPT_TTBL[]; /* Tag Table */
-
-
-static const tXML_EVT_RPT_TTBL_ELEM xml_erp_ttbl[XML_EVT_RPT_TTBL_SIZE] =
-{ /* index (EVT_RPT_XP_*_ID) & name */
- {(UINT8*) "", XML_EVT_RPT_MAX_ID-1}, /* \x00 Number of elements in array */
- /* XML EVT_RPT element (TAG) name */
- {xml_evt_rpt_elem, 16}, /* x01 MAP-event-report */
- {xml_evt_rpt_event_elem, 5}, /* 0x02 event */
- {xml_evt_rpt_type_attr, 4}, /* x03 type */
- {xml_evt_rpt_handle_attr, 6}, /* x04 handle */
- {xml_evt_rpt_folder_attr, 6}, /* x05 folder */
- {xml_evt_rpt_old_folder_attr, 10}, /* x06 old_folder */
- {xml_evt_rpt_msg_type_attr, 8}, /* x07 msg_type */
- {xml_evt_rpt_version_attr, 7}, /* x08 version */
- {xml_evt_rpt_unknown, 7} /* x09 unknown */
-};
-
-#define XML_MAP_EVT_RPT_PTBL_SIZE 0x03
-typedef UINT8 * tXML_MAP_EVT_RPT_PTBL_ELEM;
-
-static const tXML_MAP_EVT_RPT_PTBL_ELEM xml_erp_ptbl[XML_MAP_EVT_RPT_PTBL_SIZE] =
-{
- (UINT8 *) "\x01", /* index x00, all valide attributes in above list */
- (UINT8 *) "\x08\x02", /* x01 attributes and sub-tags supported */
- (UINT8 *) "\x03\x04\x05\x06\x07" /* x02: event report attributes */
-};
-
-
-#if (EVT_RPT_DEBUG_XML == TRUE)
-void xml_erp_debug_str(tXML_STR *p_str, UINT8 *p_buf)
-{
- int dbg_len;
- if ( (p_str == NULL) || (NULL==p_str->p))
- BCM_STRNCPY_S( (char *)p_buf, EVT_RPT_DEBUG_LEN, "(NULL)", EVT_RPT_DEBUG_LEN-1 );
- else
- {
- dbg_len = p_str->len;
- if ( dbg_len >= EVT_RPT_DEBUG_LEN)
- dbg_len = EVT_RPT_DEBUG_LEN - 1;
- BCM_STRNCPY_S( (char *)p_buf, EVT_RPT_DEBUG_LEN, (char *)p_str->p, dbg_len);
- p_buf[dbg_len] = 0;
- }
-}
-
-#else
-#define xml_erp_debug_str(p_str, p_buf)
-#endif
-
-/*****************************************************************************
- ** Function xml_erp_proc_tag
- ** Description
- ** Parameters -
- ** Returns
- *****************************************************************************/
-static UINT8 xml_erp_proc_tag( tXML_EVT_RPT_STATE *p_st, tXML_STR *p_name, tXML_STACK *p_stk)
-{
- const UINT8 *p_stag; /* sub tag pointer */
- UINT8 curr = p_stk->stack[p_stk->top];
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- UINT8 dbg_name[EVT_RPT_DEBUG_LEN];
-#endif
-
-
- if (curr < XML_MAP_EVT_RPT_PTBL_SIZE)
- {
- /* Iterate over allowed sub-tags for the current tag. */
- for (p_stag = xml_erp_ptbl[curr]; p_stag && *p_stag ; p_stag++)
- {
- if (*p_stag >= XML_EVT_RPT_TTBL_SIZE)
- continue;
- if (p_name->len == xml_erp_ttbl[*p_stag].len &&
- strncmp((char *)p_name->p, (char *)xml_erp_ttbl[*p_stag].p_name, p_name->len) == 0)
- {
- p_stk->top++;
- p_stk->stack[p_stk->top] = *p_stag;
-
- return *p_stag;
- }
- }
- }
-
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- xml_erp_debug_str(p_name, dbg_name);
- XML_TRACE_DEBUG1("xml_erp_proc_tag: bad name:%s", dbg_name );
-#endif
-
- return XML_EVT_RPT_UNKNOWN_ID;
-}
-
-
-/*****************************************************************************
- ** Function xml_erp_proc_attr
- ** Description
- ** Parameters -
- ** Returns
- *****************************************************************************/
-static UINT8 xml_erp_proc_attr(tXML_EVT_RPT_STATE *p_st, tXML_STR *p_name, tXML_STACK *p_stk)
-{
- const UINT8 *p_stag; /* sub tag pointer */
- UINT8 curr = p_stk->stack[p_stk->top];
-#if (EVT_RPT_DEBUG_XML == TRUE)
- UINT8 dbg_name[EVT_RPT_DEBUG_LEN];
-#endif
- if (curr < XML_MAP_EVT_RPT_PTBL_SIZE)
- {
- /* Iterate over allowed sub-tags for the current tag. */
- for (p_stag = xml_erp_ptbl[curr]; p_stag && *p_stag; p_stag++)
- {
- if (*p_stag >= XML_EVT_RPT_TTBL_SIZE)
- continue;
- if (p_name->len == xml_erp_ttbl[*p_stag].len &&
- strncmp((char *)p_name->p, (char *)xml_erp_ttbl[*p_stag].p_name, p_name->len) == 0)
- {
- p_stk->top++;
- p_stk->stack[p_stk->top] = *p_stag;
-
- return *p_stag;
- }
- }
- }
-
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- xml_erp_debug_str(p_name, dbg_name);
- XML_TRACE_DEBUG1("xml_erp_proc_attr: bad name:%s", dbg_name);
-#endif
- return XML_EVT_RPT_UNKNOWN_ID;
-}
-
-/*****************************************************************************
- ** Function xml_erp_find_ch_n_copy
- ** Description copy any chacter till one char in p_str. Any char in p_str
- ** will stop copy pointed by p_begin
- ** Parameters
- ** Returns
- *****************************************************************************/
-static void xml_erp_find_ch_n_copy( tXML_MCOPY *p_copy )
-{
- const UINT8 *p_tmp;
- const UINT8 *p_str = (UINT8 *)">"; /* was: ":=/> \t\n\r". i think we should copy till
- closing flag */
- unsigned int last = XML_EVT_RPT_CARRY_OVER_LEN; /* maximum carry over len we can support */
- UINT8 *p_last = p_copy->last.p + p_copy->last.len - 1; /* point to the last char of carry
- over buffer */
- BOOLEAN found = FALSE;
- /* check if the last char in p_last is in p_str */
- for (p_tmp = p_str; *p_tmp; p_tmp++)
- {
- if (*p_last == *p_tmp)
- {
- found = TRUE;
- break;
- }
- } /* for */
-
- if (found == FALSE)
- {
- /* if not in p_str, move chars from p_begin to p_last
- * until reached last_len or any char in p_str */
- p_last++;
- last -= p_copy->last.len; /* calculate the maximum number of chars we can copy */
- while (*(p_copy->p_begin) && last) /* rl: not sure that this buffer is termninated by a 0 */
- {
- /* copy from source (new buffer) to carry over. adjust only carry over ptr. */
- *p_last++ = *p_copy->p_begin;
- last--;
- for (p_tmp = p_str; *p_tmp; p_tmp++)
- {
- if (*p_copy->p_begin == *p_tmp)
- {
- p_copy->p_begin++; /* adjust pointer to point to next char to read */
- /* calculate new length of carry over buffer contents */
- p_copy->last.len = XML_EVT_RPT_CARRY_OVER_LEN-last;
- *p_last = 0; /* NULL terminate p_last. rl: not really neccessary. */
- return;
- }
- } /* for */
- p_copy->p_begin++; /* update now to next char. this way abort char is also copied */
- } /* while */
- } /* !found */
-}
-
-/*****************************************************************************
-** Function xml_evt_rpt_cback
-** Description
-**
-** Parameters
-** Returns
-*****************************************************************************/
-static BOOLEAN xml_evt_rpt_cback( tXML_EVENT event, void *p_event_data, void *p_usr_data)
-{
- tXML_MEVT_DATA *p_ed = (tXML_MEVT_DATA*) p_event_data;
- tXML_EVT_RPT_STATE *p_st = (tXML_EVT_RPT_STATE *) p_usr_data;
- tXML_PROP *p_cp = &p_st->p_prop[p_st->prop_index];
- BOOLEAN ret = TRUE;
- UINT8 next; /* next element */
- UINT8 curr = p_ed->stack.stack[p_ed->stack.top]; /* current element */
-#if (EVT_RPT_DEBUG_XML == TRUE)
- UINT8 dbg_name[EVT_RPT_DEBUG_LEN];
- UINT8 dbg_prefix[EVT_RPT_DEBUG_LEN];
- UINT8 dbg_value[EVT_RPT_DEBUG_LEN];
-#endif
-
-#if (EVT_RPT_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG1("xml_evt_rpt_cback:%d", event);
-#endif
-
- switch (event)
- {
- case XML_TAG : /* <tag-name */
- next = xml_erp_proc_tag(p_st, &p_ed->tag.name, &p_ed->stack);
-#if (EVT_RPT_DEBUG_XML == TRUE)
- xml_erp_debug_str(&p_ed->tag.name, dbg_name);
- xml_erp_debug_str(&p_ed->tag.prefix, dbg_prefix);
- XML_TRACE_DEBUG2("XML_TAG: p:%s, name:%s", dbg_prefix, dbg_name);
- XML_TRACE_DEBUG2("top:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
-
-#endif
- if (next != 0)
- {
- if (next <= XML_EVT_RPT_MAX_OBJ_TAG_ID)
- p_st->obj = next;
-
- if (p_st->prop_index <p_st->max_num_prop)
- {
- /* we do not use prefix in FTC */
- p_cp->name = next;
- p_cp->p_data = NULL;
- p_cp->len = 0;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- }
- else
- ret = FALSE;
- }
- break;
-
- case XML_ATTRIBUTE : /* attr-name="attr-value" */
- curr = xml_erp_proc_attr(p_st, &p_ed->attr.name, &p_ed->stack);
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- xml_erp_debug_str(&p_ed->attr.name, dbg_name);
- xml_erp_debug_str(&p_ed->attr.prefix, dbg_prefix);
- xml_erp_debug_str(&p_ed->attr.value, dbg_value);
- XML_TRACE_DEBUG4("[xml evt_rpt] XML_ATTRIBUTE: p:%s, name:%s, v:%s, curr:%x",
- dbg_prefix, dbg_name, dbg_value, curr );
- XML_TRACE_DEBUG2("top 1:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
-#endif
- if ((curr != 0) && (curr != XML_EVT_RPT_UNKNOWN_ID))
- {
- if (p_st->prop_index <p_st->max_num_prop)
- {
- p_cp->name = curr;
- p_cp->p_data = p_ed->attr.value.p;
- p_cp->len = p_ed->attr.value.len;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- }
- else
- ret = FALSE;
- p_ed->stack.top--;
- XML_TRACE_DEBUG2("top 2:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
- }
- break;
-
- case XML_CHARDATA :
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- xml_erp_debug_str(&p_ed->ch_data.value, dbg_value);
- XML_TRACE_DEBUG2("XML_CHARDATA: v:%s, last:%d", dbg_value, p_ed->ch_data.last);
-#endif
- break;
-
- case XML_ETAG : /* </tag-name> */
- if (p_ed->stack.top > 0)
- {
- p_ed->stack.stack[p_ed->stack.top] = 0;
- p_ed->stack.top--;
- p_st->ended = (BOOLEAN) (p_ed->stack.top == 0);
- }
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- xml_erp_debug_str(&p_ed->etag.name, dbg_name);
- xml_erp_debug_str(&p_ed->etag.prefix, dbg_prefix);
- XML_TRACE_DEBUG2("[xml evt_rpt] XML_ETAG: p:%s, name:%s", dbg_prefix, dbg_name);
- XML_TRACE_DEBUG2("[xml evt_rpt] top:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
-#endif
- break;
-
- case XML_TAG_END: /* /> */
- curr = p_ed->stack.stack[p_ed->stack.top];
-
- if (p_st->prop_index <p_st->max_num_prop)
- {
- if (p_ed->empty_elem.end)
- p_cp->name = XML_EVT_RPT_TAG_END_ID;
- else
- p_cp->name = XML_EVT_RPT_PAUSE_ID;
- p_cp->p_data = NULL;
- p_cp->len = 0;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- if (p_ed->empty_elem.end && p_ed->stack.top > 0)
- {
- p_ed->stack.top--;
- }
- }
- else
- ret = FALSE;
-
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG4("[xml evt_rpt] XML_TAG_END: %d, top:x%x, stk:x%x, curr:x%x",
- p_ed->empty_elem.end, p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top], curr);
-#endif
- break;
-
- case XML_PARTIAL:
- if (p_st->p_prop[p_st->prop_index-1].name != XML_EVT_RPT_TAG_END_ID)
- {
- p_ed->stack.top--;
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0("[xml evt_rpt] adjust due to XML_PARTIAL");
-#endif
- }
- break;
-
- case XML_COPY:
- xml_erp_find_ch_n_copy( &p_ed->copy );
- XML_TRACE_DEBUG1("[xml evt_rpt] XML_COPY: %s", p_ed->copy.last.p);
- break;
-
- default :
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG1("[xml evt_rpt] default: XML event: %d", event);
-#endif
- break;
- }
-
- return ret;
-}
-
-
-
-
-/**********************************************************************************
-** Function xml_erp_int_fill_file_folder
-** Description fill in file/folder structure.
-**
-** Parameters
-** Returns xx: > 0 : number of properties scanned, folder entry is added
-** = 0 : no end tag found, carry over to next parse
-** = -1: no dst_resource avaibale, all prop left to next parse
-** = -2: exceed max entry, no folder entry added
-**********************************************************************************/
-static INT16 xml_erp_int_fill_evt_rpt( tXML_EVT_RPT_STATE * p_xud,
- tXML_PROP *p_prop,
- UINT16 *num_prop,
- UINT8 **p_dst_data,
- UINT16 *dst_len)
-{
- INT16 xx;
- UINT16 len;
- BOOLEAN end = FALSE;
- tXML_PROP *cur_prop = p_prop;
- UINT8 *p_cur_offset = *p_dst_data;
- BOOLEAN copy_attr_info;
- BOOLEAN no_buf_left;
- UINT8 **p_attr_data = NULL;
- UINT16 *p_attr_len = NULL;
-
- if ( p_xud->current_entry >= p_xud->max_entry )
- return -2;
-
- for (xx=0; (xx < *num_prop) && !end; xx++, cur_prop++)
- {
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- /* XML_TRACE_DEBUG5( "[xml evt_rpt] fill: num_prop:%d, name id: x%x, p_prop: x%x, len: %d p_data:%s",
- (*num_prop-xx) , cur_prop->name, cur_prop, cur_prop->len, cur_prop->p_data, ); */
-#endif
- copy_attr_info = TRUE;
- no_buf_left = FALSE;
- len = cur_prop->len;
-
- switch (cur_prop->name)
- {
- case XML_EVT_RPT_TYPE_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].type) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].type_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
-
- case XML_EVT_RPT_HANDLE_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].handle) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].handle_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_EVT_RPT_FOLDER_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].folder) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].folder_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_EVT_RPT_OLD_FOLDER_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].old_folder) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].old_folder_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_EVT_RPT_MSG_TYPE_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].msg_type) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].msg_type_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_EVT_RPT_TAG_END_ID:
- /* -------------------- CUSTOMER SPECIFIC ---------------------- */
- p_xud->current_entry++; /* increment only when end tag (/>) found */
- copy_attr_info = FALSE;
- XML_TRACE_DEBUG1("[xml ml]: current_entry=%d",p_xud->current_entry);
- break;
- /* case XML_VERSION_ATTR_ID: */
- default:
- copy_attr_info = FALSE;
- XML_TRACE_DEBUG1("[xml evt_rpt] unknown attrib: %d", cur_prop->name );
- break;
- }
-
- if (copy_attr_info && p_attr_data && p_attr_len)
- {
- *p_attr_data = p_cur_offset;
- *p_attr_len = len;
-
- memcpy( (void *)*p_attr_data,
- (const void *)cur_prop->p_data,
- len );
- (*p_attr_data)[len] = 0; /* null terminate string */
- p_cur_offset += (len + 1);
- *dst_len = *dst_len - (len + 1) ;
-
- #if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
-
- XML_TRACE_DEBUG5("[xml evt_rpt]: Attr ID=%d val=[%s] len=%d level=%d dst_len lef=%d",
- cur_prop->name,
- *p_attr_data,
- *p_attr_len,
- cur_prop->level,
- *dst_len);
- #endif
- }
-
- if (no_buf_left)
- {
- return -1;
- }
-
- }
-#if (EVT_RPT_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG2("[xml evt_rpt] fill_evt_rpt: end:%d, xx:%d", end, xx);
-#endif
-#if 0
- /* if end tag not found -> split over two buffers. but parser will still show rest of
- found properties. so return still found properties. */
- if (end == FALSE)
- xx = 0;
-#endif
-
- /* keep track of current data buffer offset */
- *p_dst_data = p_cur_offset;
- return xx;
-} /* xml_erp_int_fill_file_evt_rpt() */
-
-
-/**********************************************************************************
-** Function xml_erp_int_fill_evt_data
-**
-** Description fill in MAP event report structure.
-**
-** Parameters
-** Returns
-**********************************************************************************/
-static tXML_EVT_RPT_RES xml_erp_int_fill_evt_data( UINT8 op,
- void *p_evt_data,
- tXML_PROP **p_prop,
- UINT16 *num_prop,
- UINT8 **p_dst_data,
- UINT16 *dst_len)
-{
- tXML_EVT_RPT_STATE *p_xud = (tXML_EVT_RPT_STATE *)p_evt_data;
- INT16 inc_prop;
- UINT8 prop_name; /* Property name. */
- tXML_PROP *cur_prop = *p_prop;
- UINT8 *p_cur_offset = *p_dst_data;
-
- tXML_EVT_RPT_RES x_res = XML_EVT_RPT_OK;
- BOOLEAN x_no_res = FALSE; /* guard dest buffer resource */
-
- if ( op == 0 || op > XML_EVT_RPT_MAX_OBJ_TAG_ID || *num_prop == 0)
- return XML_EVT_RPT_ERROR;
-
-#if EVT_RPT_DEBUG_XML
- XML_TRACE_DEBUG2( "[xml evt_rpt] xml_erp_int_fill_evt_data op:%d, num_prop:%d",
- op, *num_prop);
-#endif
-
-
-
- while ( *num_prop > 0 && !x_no_res )
- {
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG2("end_prop:%d, name id: x%x", *num_prop, cur_prop->name);
-#endif
- prop_name = cur_prop->name;
- cur_prop++;
- *num_prop -= 1;
-
-
- switch ( prop_name )
- {
- case XML_EVT_RPT_ELEM_ID:
- XML_TRACE_DEBUG0("[xml evt_rpt] xml_etag_elem");
- /* skip over version attribute which should always be 1.0. this is the top level */
- break;
-
- case XML_EVT_RPT_EVT_ELEM_ID:
- XML_TRACE_DEBUG0("[xml evt_rpt] xml_etag_elem");
- inc_prop = xml_erp_int_fill_evt_rpt( p_xud,
- cur_prop,
- num_prop,
- &p_cur_offset,
- dst_len);
- if (inc_prop == -1) /* no dst_buf available */
- {
- /* backup one more prop to obtain the skipped evt_rpt/file entry header */
- cur_prop --;
- *num_prop += 1;
-
- x_res = XML_EVT_RPT_DST_NO_RES;
- x_no_res = TRUE;
- }
- else if (inc_prop == -2) /* exceed max entry */
- {
- x_no_res = TRUE;
- x_res = XML_EVT_RPT_OUT_FULL;
- }
- else /* found evt_rpt entry */
- {
- cur_prop += inc_prop;
- *num_prop -= inc_prop;
- }
- break;
-
- case XML_EVT_RPT_PAUSE_ID:
- XML_TRACE_DEBUG0("[xml evt_rpt] xml_etag_elem");
-
-#if (EVT_RPT_DEBUG_XML==TRUE)
- XML_TRACE_DEBUG0( "[xml evt_rpt] xml_erp_int_fill_evt_data(): XML_EVT_RPT_PAUSE_ID" );
-#endif
- break;
-
- case XML_EVT_RPT_TAG_END_ID:
- XML_TRACE_DEBUG0("[xml evt_rpt] xml_etag_elem");
-#if (EVT_RPT_DEBUG_XML==TRUE)
- XML_TRACE_DEBUG0( "[xml evt_rpt] xml_erp_int_fill_evt_data(): XML_EVT_RPT_TAG_END_ID" );
-#endif
- break;
-
- default:
- XML_TRACE_DEBUG1( "[xml evt_rpt] xml_erp_int_fill_evt_data():unknown element: %d", prop_name );
- break;
- }
- }
-
- /* keep track of current filling position, and current available dst buffer */
- *p_prop = cur_prop;
- *p_dst_data = p_cur_offset;
-
- return x_res;
-} /* xml_erp_int_fill_evt_data() */
-
-
-/**************************************************************************************
-** Function XML_EvtRptInit
-**
-** Description Initialize xml parser state machine.
-**
-** Parameters p_xml_state: address of an xml parser state machine to be initialized,
-** allocate an additional space of size XML_EVT_RPT_CARRY_OVER_LEN
-** right after *p_xml_state to hold carry over data.
-** p_entry : points start of output directory entry. caller needs do
-** free this memory
-** max_entry : max is 16 bit integer value which is the maximum number
-** of evt_rpt entries.
-
-**
-** Returns void
-**************************************************************************************/
-
-void XML_EvtRptInit( tXML_EVT_RPT_PARSER *p_xml_state,
- tXML_EVT_RPT_ENTRY *p_entry,
- const UINT16 max_entry )
-{
- XML_TRACE_DEBUG0("[xml evt_rpt] XML_EvtRptInit");
- /* Initialize the generic xml parser state machine.*/
- XML_InitPars( &p_xml_state->xml, xml_evt_rpt_cback, &p_xml_state->xml_user_data );
-
- /* User need to allocate an additional space of size XML_EVT_RPT_CARRY_OVER_LEN */
- /* right after *p_xml_state to hold carry over data. */
- /* point to the end of the allocated buffer for p_xml_state, which is the */
- /* beginning of buffer(XML_EVT_RPT_CARRY_OVER_LEN) */
- p_xml_state->xml.last_bfr.p = (UINT8 *)(p_xml_state + 1);
- p_xml_state->xml.last_bfr.len = XML_EVT_RPT_CARRY_OVER_LEN;
-
- /* Initialize user data */
- p_xml_state->xml_user_data.p_entry = p_entry;
- p_xml_state->xml_user_data.current_entry = 0;
- p_xml_state->xml_user_data.max_name_len = XML_UI_ENTRY_MAX_NAME_LEN + 1;
- p_xml_state->xml_user_data.max_entry = (UINT16)max_entry;
- p_xml_state->xml_user_data.prop_num = 0;
-}
-
-
-/**************************************************************************************
-** Function XML_EvtRptParse
-**
-** Description This function is called to parse the xml data received from OBEX
-** into folder entries associated with properties value. It can also be
-** used as clean up function to delete left over data from previous parse.
-** This clean up function is typically used when application runs out of
-** resource and decides to discard extra xml data received.
-**
-** Parameters p_xml_state: pointer to a xml parser initialized by XML_EvtRptInit().
-** xml_data: valid pointer to OBEX list data in xml format.
-** xml_len: length of the package, must be non-zero value.
-** dst_data: valid pointer to the buffer for holding converted folder entry name.
- When dst_data is NULL, clean up all remaining data in the parser.
-** dst_len: pointer to the length of dst_data buffer, its carry out value
-** is the number of bytes remaining buffer.When dst_len is NULL,
-** it will cause to flush the internal data in the parser.
-** num_entries: current number of entries, in the end it is the total number of entries
-**
-** Returns tXML_EVT_RPT_RES (see xml_erp.h)
-** XML_PENDING: parsing not completed
-** XML_END_LIST: found /folder-listing but no final flag detected
-** XML_EVT_RPT_OUT_FULL: reached max_entry -> do not call parser anymore!!! dump data
-** XML_EVT_RPT_DST_NO_RES : run out of dst buffer resource while
-** some xml data still remains.
-
-**************************************************************************************/
-tXML_EVT_RPT_RES XML_EvtRptParse( tXML_EVT_RPT_PARSER *p_xml_state,
- UINT8 *xml_data, UINT16 xml_len,
- UINT8 *dst_data, UINT16 *dst_len,
- UINT16 *num_entries )
-{
- tXML_OS xos;
- BOOLEAN is_remain = TRUE;
- tXML_MUL_STATE *p_xml = &p_xml_state->xml;
- tXML_EVT_RPT_STATE *p_st = &p_xml_state->xml_user_data;
- tXML_EVT_RPT_RES x_res = XML_EVT_RPT_OK;
- tXML_RESULT res = XML_NO_PROP;
- UINT16 max_num_prop = GKI_BUF3_SIZE/sizeof(tXML_PROP); /* i hope this is sufficient for 1 */
-
-
-#if (defined(EVT_RPT_DEBUG_XML) && EVT_RPT_DEBUG_XML == TRUE)
- int xx;
- UINT8 dbg_buf[EVT_RPT_DEBUG_LEN];
- tXML_STR str;
-#endif
-
- XML_TRACE_DEBUG0("[xml evt_rpt] XML_EvtRptParse");
- /* if dst_data is NULL, clean up remaining data */
- if (!dst_data || !dst_len)
- {
- /* clean out remained xml data left over from last parse */
- if (p_xml_state->xml_user_data.p_prop )
- {
- GKI_freebuf( p_st->p_prop );
- p_st->p_prop = p_st->offset_prop = NULL;
- p_st->prop_num = 0;
- }
-#if (EVT_RPT_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0( "[xml evt_rpt] XML_EvtRptParse() Clean up left over!");
-#endif
- return x_res;
- }
-
- /* if illegal OBEX data or dst buffer pointer received, return ERROR */
- if (xml_len == 0 || !xml_data)
- {
- return XML_EVT_RPT_ERROR;
- }
-
- /* XML_EvtRptParse receive new xml data, allocate buffer to hold parsed prop */
- if (p_st->offset_prop == NULL)
- {
-
-#if (EVT_RPT_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0( "[xml evt_rpt] XML_EvtRptParse() Receive New Data!");
- XML_TRACE_DEBUG2( "[xml evt_rpt] XML_data start[%x] end [%x]",xml_data, xml_data+xml_len);
-#endif
- is_remain = FALSE;
- if ( NULL!= (p_st->p_prop = (tXML_PROP *)GKI_getbuf( GKI_BUF3_SIZE ) ) )
- {
- /* pointing next prop to be converted into file entry */
- p_st->prop_num = 0;
- }
- else
- {
- GKI_freebuf( p_xml_state );
- x_res = XML_EVT_RPT_NO_RES;
- return x_res;
- }
- }
-#if (EVT_RPT_DEBUG_XML == TRUE)
- else
- {
- XML_TRACE_DEBUG0( "[xml evt_rpt] XML_EvtRptParse(): Keep cleaning up old xml data !");
- }
-#endif
- /* update the data address */
- xos.p_begin = xml_data;
- xos.p_end = xml_data + xml_len;
-
- while ( res == XML_NO_PROP )
- {
- /* if no remaining data in p_st->p_prop, parse new xml data */
- if (!is_remain)
- {
- p_st->max_num_prop = max_num_prop;
- p_st->prop_index = 0;
- res = XML_MulParse( p_xml, &xos );
-
-
-#if (EVT_RPT_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG4( "xml_evt_rpt_parse obj: %x, max: %d, num: %d, res: %d",
- p_st->obj, max_num_prop, p_st->prop_index, res);
-
- if (res != 0)
- {
- XML_TRACE_DEBUG1( "XML_MulParse Parsing: %d !!!", res);
- }
-
- for (xx=0; xx<p_st->prop_index; xx++)
- {
- if ( p_st->p_prop[xx].name < XML_EVT_RPT_MAX_ID )
- {
- str.p = p_st->p_prop[xx].p_data;
- str.len = p_st->p_prop[xx].len;
- xml_erp_debug_str(&str, dbg_buf);
- XML_TRACE_DEBUG5( "[xml evt_rpt] parsed: index[%d]:%d:%s: %s(%d)", p_st->prop_index-xx, p_st->p_prop[xx].level,
- xml_erp_ttbl[p_st->p_prop[xx].name].p_name, dbg_buf, p_st->p_prop[xx].len);
- }
- else
- {
- XML_TRACE_DEBUG3( "[xml evt_rpt] internal prop: %d:%d:%d", xx, p_st->p_prop[xx].level,
- p_st->p_prop[xx].name );
- }
- }
-#endif
- p_st->prop_num = p_st->prop_index ;
- p_st->offset_prop = p_st->p_prop;
- }
- else
- {
- /* This is left over data, pick up the result from the previous parse */
- res = p_xml->pars_res;
- }
-
- if ( res != XML_OBJ_ST_EMPTY )
- {
- x_res = xml_erp_int_fill_evt_data( p_st->obj, p_st, &p_st->offset_prop, &p_st->prop_num, &dst_data, dst_len );
-
- if ( (XML_EVT_RPT_OK == x_res) && (XML_NO_END == res) )
- {
- /* XML_NO_END means that the xml is not completly finished and fill returns
- ok when when partial filling has been ok */
- x_res = XML_EVT_RPT_PENDING;
- }
-
- /* all parsed xml data has been converted into file entry */
- /* or exceed max entry number , break the parsing loop */
- if (XML_EVT_RPT_OUT_FULL != x_res && XML_EVT_RPT_DST_NO_RES != x_res)
- {
- is_remain = FALSE;
- }
- else
- break;
- }
- } /* while */
-
- /* free property table. at next call a new one is allocated */
- if ((x_res != XML_EVT_RPT_DST_NO_RES && p_st->p_prop) ||
- XML_EVT_RPT_OUT_FULL == x_res)
- {
- GKI_freebuf( p_st->p_prop );
- p_st->p_prop = NULL;
- p_st->offset_prop = NULL;
- }
-
- if ( x_res != XML_EVT_RPT_DST_NO_RES && p_st->ended)
- {
- /* this should happen on the same time as final flag in fact */
- x_res = XML_EVT_RPT_END_LIST; /* found closing /evt_rpt-listing */
- }
-
-
- *num_entries = p_st->current_entry; /* report number of entries found. only when ended is true
- application really should be interested! */
- return x_res;
-}
-
diff --git a/stack/xml/xml_flp.c b/stack/xml/xml_flp.c
deleted file mode 100644
index 688f1b5..0000000
--- a/stack/xml/xml_flp.c
+++ /dev/null
@@ -1,971 +0,0 @@
-/******************************************************************************
- **
- ** Name: xml_flp.c
- **
- ** Description: This module contains xml parser of obex folder listing
- **
- ** Copyright (c) 2004-2011, Broadcom Corporation, All Rights Reserved.
- ** Broadcom Bluetooth Core. Proprietary and confidential.
- ******************************************************************************/
-
-#include "bt_target.h"
-#include "gki.h"
-#include "xml_flp_api.h"
-
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef FOLDER_DEBUG_XML
-#define FOLDER_DEBUG_XML FALSE
-#endif
-#define FOLDER_DEBUG_LEN 50
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
-#define XML_TRACE_DEBUG0(m) {BT_TRACE_0(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m);}
-#define XML_TRACE_DEBUG1(m,p1) {BT_TRACE_1(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1);}
-#define XML_TRACE_DEBUG2(m,p1,p2) {BT_TRACE_2(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define XML_TRACE_DEBUG3(m,p1,p2,p3) {BT_TRACE_3(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define XML_TRACE_DEBUG4(m,p1,p2,p3,p4) {BT_TRACE_4(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define XML_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {BT_TRACE_5(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define XML_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {BT_TRACE_6(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#else
-#define XML_TRACE_DEBUG0(m)
-#define XML_TRACE_DEBUG1(m,p1)
-#define XML_TRACE_DEBUG2(m,p1,p2)
-#define XML_TRACE_DEBUG3(m,p1,p2,p3)
-#define XML_TRACE_DEBUG4(m,p1,p2,p3,p4)
-#define XML_TRACE_DEBUG5(m,p1,p2,p3,p4,p5)
-#define XML_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6)
-#endif
-
-#define XML_PERM_LEN_MAX 4
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-const UINT8 xml_folder_listing_elem[] = "folder-listing";
-const UINT8 xml_file_elem[] = "file";
-const UINT8 xml_folder_elem[] = "folder";
-const UINT8 xml_parent_folder_elem[] = "parent-folder";
-const UINT8 xml_name_attr[] = "name";
-const UINT8 xml_size_attr[] = "size";
-const UINT8 xml_type_attr[] = "type";
-const UINT8 xml_modified_attr[] = "modified";
-const UINT8 xml_created_attr[] = "created";
-const UINT8 xml_accessed_attr[] = "accessed";
-const UINT8 xml_user_perm_attr[] = "user-perm";
-const UINT8 xml_group_perm_attr[] = "group-perm";
-const UINT8 xml_other_perm_attr[] = "other-perm";
-const UINT8 xml_group_attr[] = "group";
-const UINT8 xml_owner_attr[] = "owner";
-const UINT8 xml_version_attr[] = "version";
-const UINT8 xml_lang_attr[] = "xml:lang";
-const UINT8 xml_unknown[] = "unknown";
-
-#define XML_FOLDER_LISTING_ELEM_ID 0x01
-#define XML_FILE_ELEM_ID 0x02
-#define XML_FOLDER_ELEM_ID 0x03
-#define XML_PARENT_FOLDER_ELEM_ID 0x04
-#define XML_MAX_OBJ_TAG_ID XML_FOLDER_LISTING_ELEM_ID
-#define XML_NAME_ATTR_ID 0x05
-#define XML_SIZE_ATTR_ID 0x06
-#define XML_TYPE_ATTR_ID 0x07
-#define XML_MODIFIED_ATTR_ID 0x08
-#define XML_CREATED_ATTR_ID 0x09
-#define XML_ACCESSED_ATTR_ID 0x0a
-#define XML_USER_PERM_ATTR_ID 0x0b
-#define XML_GROUP_PERM_ATTR_ID 0x0c
-#define XML_OTHER_PERM_ATTR_ID 0x0d
-#define XML_GROUP_ATTR_ID 0x0e
-#define XML_OWNER_ATTR_ID 0x0f
-#define XML_VERSION_ATTR_ID 0x10
-#define XML_LANG_ATTR_ID 0x11
-#define XML_XP_UNKNOWN_ID 0x12
-#define XML_FOLDER_MAX_ID 0x13 /* keep in sync with above */
-#define XML_FOLDER_TAG_END_ID 0x13 /* closing tag found end=true */
-#define XML_FOLDER_PAUSE_ID 0x14 /* closing tag found end=false */
-
-
-#define XML_FOLDER_TTBL_SIZE (XML_FOLDER_MAX_ID+1)
-
-/*****************************************************************************
-** Type Definitions
-*****************************************************************************/
-
-typedef struct
-{
- const UINT8 *p_name;
- UINT8 len;
-} tXML_FOLDER_TTBL_ELEM;
-
-typedef tXML_FOLDER_TTBL_ELEM tXML_FOLDER_TTBL[]; /* Tag Table */
-
-
-static const tXML_FOLDER_TTBL_ELEM xml_flp_ttbl[XML_FOLDER_TTBL_SIZE] =
-{ /* index (FOLDER_XP_*_ID) & name */
- {(UINT8*) "", XML_FOLDER_MAX_ID-1}, /* \x00 Number of elements in array */
- /* XML FOLDER element (TAG) name */
- {xml_folder_listing_elem, 14}, /* x01 folder-listing */
- {xml_file_elem, 4}, /* 0x02 file */
- {xml_folder_elem, 6}, /* x03 folder */
- {xml_parent_folder_elem, 13}, /* x04 parent-folder */
- {xml_name_attr, 4}, /* x05 name */
- {xml_size_attr, 4}, /* x06 size */
- {xml_type_attr, 4}, /* x07 type */
- {xml_modified_attr, 8}, /* x08 modified */
- {xml_created_attr, 7}, /* x09 created */
- {xml_accessed_attr, 8}, /* x0a accessed */
- {xml_user_perm_attr, 9}, /* x0b user-perm */
- {xml_group_perm_attr, 10}, /* x0c group-perm */
- {xml_other_perm_attr, 10}, /* x0d other-perm */
- {xml_group_attr, 5}, /* x0e group */
- {xml_owner_attr, 5}, /* x0f owner */
- {xml_version_attr, 7}, /* x10 version */
- {xml_lang_attr, 8}, /* x11 xml:lang */
- {xml_unknown, 7 } /* x12 unknown */
-};
-
-#define XML_FOLDER_PTBL_SIZE 0x10
-typedef UINT8 * tXML_FOLDER_PTBL_ELEM;
-
-static const tXML_FOLDER_PTBL_ELEM xml_flp_ptbl[XML_FOLDER_PTBL_SIZE] =
-{
- (UINT8 *) "\x01\x02\x03\x04", /* index x00, all valide attributes in above list */
- (UINT8 *) "\x10\x02\x03\x04", /* x01 attributes and sub-tags supported */
- (UINT8 *) "\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x11", /* x02: file attributes */
- (UINT8 *) "\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x11", /* x03: folder attributes */
- (UINT8 *) "" /* x04 parent folder has no attributes */
-};
-
-
-#if (FOLDER_DEBUG_XML == TRUE)
-void xml_flp_debug_str(tXML_STR *p_str, UINT8 *p_buf)
-{
- int dbg_len;
- if ( (p_str == NULL) || (NULL==p_str->p))
- BCM_STRCPY_S( (char *)p_buf, FOLDER_DEBUG_LEN, "(NULL)" );
- else
- {
- dbg_len = p_str->len;
- if ( dbg_len >= FOLDER_DEBUG_LEN)
- dbg_len = FOLDER_DEBUG_LEN - 1;
- BCM_STRNCPY_S( (char *)p_buf, FOLDER_DEBUG_LEN, (char *)p_str->p, dbg_len);
- p_buf[dbg_len] = 0;
- }
-}
-
-#else
-#define xml_flp_debug_str(p_str, p_buf)
-#endif
-
-/*****************************************************************************
- ** Function xml_flp_proc_tag
- ** Description
- ** Parameters -
- ** Returns
- *****************************************************************************/
-static UINT8 xml_flp_proc_tag( tXML_FOLDER_STATE *p_st, tXML_STR *p_name, tXML_STACK *p_stk)
-{
- const UINT8 *p_stag; /* sub tag pointer */
- UINT8 curr = p_stk->stack[p_stk->top];
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- UINT8 dbg_name[FOLDER_DEBUG_LEN];
-#endif
-
- if (curr < XML_FOLDER_PTBL_SIZE)
- {
- /* Iterate over allowed sub-tags for the current tag. */
- for (p_stag = xml_flp_ptbl[curr]; p_stag && *p_stag ; p_stag++)
- {
- if (*p_stag >= XML_FOLDER_TTBL_SIZE)
- continue;
- if(p_name->len == xml_flp_ttbl[*p_stag].len &&
- strncmp((char *)p_name->p, (char *)xml_flp_ttbl[*p_stag].p_name, p_name->len) == 0)
- {
- p_stk->top++;
- p_stk->stack[p_stk->top] = *p_stag;
-
- return *p_stag;
- }
- }
- }
-
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- xml_flp_debug_str(p_name, dbg_name);
- XML_TRACE_DEBUG1("xml_flp_proc_tag: bad name:%s", dbg_name );
-#endif
-
- p_stk->top++;
- p_stk->stack[p_stk->top] = XML_XP_UNKNOWN_ID;
- return XML_XP_UNKNOWN_ID;
-}
-
-
-/*****************************************************************************
- ** Function xml_flp_proc_attr
- ** Description
- ** Parameters -
- ** Returns
- *****************************************************************************/
-static UINT8 xml_flp_proc_attr(tXML_FOLDER_STATE *p_st, tXML_STR *p_name, tXML_STACK *p_stk)
-{
- const UINT8 *p_stag; /* sub tag pointer */
- UINT8 curr = p_stk->stack[p_stk->top];
-#if (FOLDER_DEBUG_XML == TRUE)
- UINT8 dbg_name[FOLDER_DEBUG_LEN];
-#endif
-
- if (curr < XML_FOLDER_PTBL_SIZE)
- {
- /* Iterate over allowed sub-tags for the current tag. */
- for (p_stag = xml_flp_ptbl[curr]; p_stag && *p_stag; p_stag++)
- {
- if (*p_stag >= XML_FOLDER_TTBL_SIZE)
- continue;
- if(p_name->len == xml_flp_ttbl[*p_stag].len &&
- strncmp((char *)p_name->p, (char *)xml_flp_ttbl[*p_stag].p_name, p_name->len) == 0)
- {
- p_stk->top++;
- p_stk->stack[p_stk->top] = *p_stag;
-
- return *p_stag;
- }
- }
- }
-
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- xml_flp_debug_str(p_name, dbg_name);
- XML_TRACE_DEBUG1("xml_flp_proc_attr: bad name:%s", dbg_name);
-#endif
- return XML_XP_UNKNOWN_ID;
-}
-/*****************************************************************************
- ** Function xml_flp_get_perm
- ** Description Translate permission character into XML_PERM_MASK
- ** Returns XML_PERM_MASK: permission mask
- *****************************************************************************/
-static XML_PERM_MASK xml_flp_get_perm(char *right, UINT16 len )
-{
- XML_PERM_MASK mask = 0;
- UINT8 perm_str[XML_PERM_LEN_MAX] = {0};
-
- memcpy(perm_str, right, XML_PERM_LEN_MAX);
- perm_str[len] = '\0';
-
- if (strchr((char *)perm_str, 'R'))
- mask |= XML_PERM_READ_B;
- if (strchr((char *)perm_str, 'W'))
- mask |= XML_PERM_WRITE_B;
- if (strchr((char *)perm_str, 'D'))
- mask |= XML_PERM_DELETE_B;
-
-#if (FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG2("xml_flp_get_perm [%s] -> %d",perm_str, mask);
-#endif
- return mask;
-}
-
-/*****************************************************************************
- ** Function xml_flp_find_ch_n_copy
- ** Description copy any chacter till one char in p_str. Any char in p_str
- ** will stop copy pointed by p_begin
- ** Parameters
- ** Returns
- *****************************************************************************/
-static void xml_flp_find_ch_n_copy( tXML_MCOPY *p_copy )
-{
- const UINT8 *p_tmp;
- const UINT8 *p_str = (UINT8 *)">"; /* was: ":=/> \t\n\r". i think we should copy till
- closing flag */
- unsigned int last = XML_FOLDER_CARRY_OVER_LEN; /* maximum carry over len we can support */
- UINT8 *p_last = p_copy->last.p + p_copy->last.len - 1; /* point to the last char of carry
- over buffer */
- BOOLEAN found = FALSE;
-
- /* check if the last char in p_last is in p_str */
- for (p_tmp = p_str; *p_tmp; p_tmp++)
- {
- if (*p_last == *p_tmp)
- {
- found = TRUE;
- break;
- }
- } /* for */
-
- if (found == FALSE)
- {
- /* if not in p_str, move chars from p_begin to p_last
- * until reached last_len or any char in p_str */
- p_last++;
- last -= p_copy->last.len; /* calculate the maximum number of chars we can copy */
- while (*(p_copy->p_begin) && last) /* rl: not sure that this buffer is termninated by a 0 */
- {
- /* copy from source (new buffer) to carry over. adjust only carry over ptr. */
- *p_last++ = *p_copy->p_begin;
- last--;
- for (p_tmp = p_str; *p_tmp; p_tmp++)
- {
- if (*p_copy->p_begin == *p_tmp)
- {
- p_copy->p_begin++; /* adjust pointer to point to next char to read */
- /* calculate new length of carry over buffer contents */
- p_copy->last.len = XML_FOLDER_CARRY_OVER_LEN-last;
- *p_last = 0; /* NULL terminate p_last. rl: not really neccessary. */
- return;
- }
- } /* for */
- p_copy->p_begin++; /* update now to next char. this way abort char is also copied */
- } /* while */
- } /* !found */
-}
-
-/*****************************************************************************
-** Function xml_folder_cback
-** Description
-**
-** Parameters
-** Returns
-*****************************************************************************/
-static BOOLEAN xml_folder_cback( tXML_EVENT event, void *p_event_data, void *p_usr_data)
-{
- tXML_MEVT_DATA *p_ed = (tXML_MEVT_DATA*) p_event_data;
- tXML_FOLDER_STATE *p_st = (tXML_FOLDER_STATE *) p_usr_data;
- tXML_PROP *p_cp = &p_st->p_prop[p_st->prop_index];
- BOOLEAN ret = TRUE;
- UINT8 next; /* next element */
- UINT8 curr = p_ed->stack.stack[p_ed->stack.top]; /* current element */
-#if (FOLDER_DEBUG_XML == TRUE)
- UINT8 dbg_name[FOLDER_DEBUG_LEN];
- UINT8 dbg_prefix[FOLDER_DEBUG_LEN];
- UINT8 dbg_value[FOLDER_DEBUG_LEN];
-#endif
-
-#if (FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG1("xml_folder_cback:%d", event);
-#endif
-
- switch (event)
- {
- case XML_TAG : /* <tag-name */
- next = xml_flp_proc_tag(p_st, &p_ed->tag.name, &p_ed->stack);
-#if (FOLDER_DEBUG_XML == TRUE)
- xml_flp_debug_str(&p_ed->tag.name, dbg_name);
- xml_flp_debug_str(&p_ed->tag.prefix, dbg_prefix);
- XML_TRACE_DEBUG2("XML_TAG: p:%s, name:%s", dbg_prefix, dbg_name);
- XML_TRACE_DEBUG2("top:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
-
-#endif
- if (next != 0)
- {
- if (next <= XML_MAX_OBJ_TAG_ID)
- p_st->obj = next;
-
- if(p_st->prop_index <p_st->max_num_prop)
- {
- /* we do not use prefix in FTC */
- p_cp->name = next;
- p_cp->p_data = NULL;
- p_cp->len = 0;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- }
- else
- ret = FALSE;
- }
- break;
-
- case XML_ATTRIBUTE : /* attr-name="attr-value" */
- curr = xml_flp_proc_attr(p_st, &p_ed->attr.name, &p_ed->stack);
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- xml_flp_debug_str(&p_ed->attr.name, dbg_name);
- xml_flp_debug_str(&p_ed->attr.prefix, dbg_prefix);
- xml_flp_debug_str(&p_ed->attr.value, dbg_value);
- XML_TRACE_DEBUG4("[xml folder] XML_ATTRIBUTE: p:%s, name:%s, v:%s, curr:%x",
- dbg_prefix, dbg_name, dbg_value, curr);
-#endif
- if ((curr != 0) && (curr != XML_XP_UNKNOWN_ID))
- {
- if(p_st->prop_index <p_st->max_num_prop)
- {
- p_cp->name = curr;
- p_cp->p_data = p_ed->attr.value.p;
- p_cp->len = p_ed->attr.value.len;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- }
- else
- ret = FALSE;
- p_ed->stack.top--;
- }
- break;
-
- case XML_CHARDATA :
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- xml_flp_debug_str(&p_ed->ch_data.value, dbg_value);
- XML_TRACE_DEBUG2("XML_CHARDATA: v:%s, last:%d", dbg_value, p_ed->ch_data.last);
-#endif
- break;
-
- case XML_ETAG : /* </tag-name> */
- if(p_ed->stack.top > 0)
- {
- p_ed->stack.stack[p_ed->stack.top] = 0;
- p_ed->stack.top--;
- p_st->ended = (BOOLEAN) (p_ed->stack.top == 0);
- }
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- xml_flp_debug_str(&p_ed->etag.name, dbg_name);
- xml_flp_debug_str(&p_ed->etag.prefix, dbg_prefix);
- XML_TRACE_DEBUG2("[xml folder] XML_ETAG: p:%s, name:%s", dbg_prefix, dbg_name);
- XML_TRACE_DEBUG2("[xml folder] top:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
-#endif
- break;
-
- case XML_TAG_END: /* /> */
- curr = p_ed->stack.stack[p_ed->stack.top];
-
- if(p_st->prop_index <p_st->max_num_prop)
- {
- if(p_ed->empty_elem.end)
- p_cp->name = XML_FOLDER_TAG_END_ID;
- else
- p_cp->name = XML_FOLDER_PAUSE_ID;
- p_cp->p_data = NULL;
- p_cp->len = 0;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- if(p_ed->empty_elem.end && p_ed->stack.top > 0)
- {
- p_ed->stack.top--;
- }
- }
- else
- ret = FALSE;
-
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG4("[xml folder] XML_TAG_END: %d, top:x%x, stk:x%x, curr:x%x",
- p_ed->empty_elem.end, p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top], curr);
-#endif
- break;
-
- case XML_PARTIAL:
- if(p_st->p_prop[p_st->prop_index-1].name != XML_FOLDER_TAG_END_ID)
- {
- p_ed->stack.top--;
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0("[xml folder] adjust due to XML_PARTIAL");
-#endif
- }
- break;
-
- case XML_COPY:
- xml_flp_find_ch_n_copy( &p_ed->copy );
- XML_TRACE_DEBUG1("[xml folder] XML_COPY: %s", p_ed->copy.last.p);
- break;
-
- default :
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG1("[xml folder] XML event: %d", event);
-#endif
- break;
- }
-
- return ret;
-}
-
-/**********************************************************************************
-** Function xml_flp_int_fill_file_folder
-** Description fill in file/folder structure.
-**
-** Parameters
-** Returns xx: > 0 : number of properties scanned, folder entry is added
-** = 0 : no end tag found, carry over to next parse
-** = -1: no dst_resource avaibale, all prop left to next parse
-** = -2: exceed max entry, no folder entry added
-**********************************************************************************/
-static INT16 xml_flp_int_fill_file_folder( const UINT8 type,
- tXML_FOLDER_STATE * p_xud,
- tXML_PROP *p_prop,
- UINT16 *num_prop,
- UINT8 **p_dst_data,
- UINT16 *dst_len)
-{
- INT16 xx;
- UINT16 len;
- BOOLEAN end = FALSE;
- tXML_PROP *cur_prop = p_prop;
- UINT8 *p_cur_offset = *p_dst_data;
-
- for(xx=0; (xx < *num_prop) && !end; xx++, cur_prop++)
- {
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG5( "[xml folder] fill: num_prop:%d, name id: x%x, p_prop: x%x, p_data:%s, len: %d",
- (*num_prop-xx) , cur_prop->name, cur_prop, cur_prop->p_data, cur_prop->len);
-#endif
- switch (cur_prop->name)
- {
- case XML_NAME_ATTR_ID:
- if ( p_xud->current_entry < p_xud->max_entry )
- {
- /* as long as we do not exceed the number of entries in the ouput array copy name */
- p_xud->p_entry[p_xud->current_entry].type = type;
- /* calculate the max length to copy */
- len = (cur_prop->len<=p_xud->max_name_len) ? cur_prop->len:p_xud->max_name_len;
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_xud->p_entry[p_xud->current_entry].data = p_cur_offset;
- p_xud->p_entry[p_xud->current_entry].len = len;
-
- memcpy( (void *)p_xud->p_entry[p_xud->current_entry].data,
- (const void *)cur_prop->p_data,
- len );
- p_xud->p_entry[p_xud->current_entry].data[len] = 0; /* null terminate string */
- p_cur_offset += (len + 1);
- *dst_len = *dst_len - (len + 1) ;
-
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG3("[xml folder]: catch filename [%s] len [%d] dst_len left:[%d]",
- p_xud->p_entry[p_xud->current_entry].data,
- len,
- *dst_len);
-#endif
- }
- else /* run out of dst buffer resource */
- {
- xx = -1;
- return xx;
- }
- }
- else /* exceed max entry */
- return -2;
-
- break;
-
- case XML_SIZE_ATTR_ID:
- if ( p_xud->current_entry < p_xud->max_entry )
- {
- p_xud->p_entry[p_xud->current_entry].size = atol( (const char *)cur_prop->p_data );
- }
- break;
-
- case XML_USER_PERM_ATTR_ID:
- if ( p_xud->current_entry < p_xud->max_entry )
- {
- p_xud->p_entry[p_xud->current_entry].user_perm = xml_flp_get_perm( (char *)cur_prop->p_data, cur_prop->len);
- }
- break;
- case XML_TYPE_ATTR_ID:
- case XML_MODIFIED_ATTR_ID:
- case XML_CREATED_ATTR_ID:
- case XML_ACCESSED_ATTR_ID:
- case XML_GROUP_PERM_ATTR_ID:
- case XML_OTHER_PERM_ATTR_ID:
- case XML_GROUP_ATTR_ID:
- case XML_OWNER_ATTR_ID:
- case XML_LANG_ATTR_ID:
-
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG1( "[xml folder] ignored attr: 0x%x", cur_prop->name );
-#endif
- break;
-
- case XML_FOLDER_TAG_END_ID:
- /* -------------------- CUSTOMER SPECIFIC ---------------------- */
- p_xud->current_entry++; /* increment only when end tag (/>) found */
-
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG1( "[xml folder] FOUND END TAG: 0x%x", cur_prop->name );
-#endif
-
- end = TRUE;
- break;
-
- default:
- XML_TRACE_DEBUG1("[xml folder] unknown attrib: %d", cur_prop->name );
- break;
- }
- }
-#if (FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG2("[xml folder] fill_file_folder: end:%d, xx:%d", end, xx);
-#endif
-#if 0
- /* if end tag not found -> split over two buffers. but parser will still show rest of
- found properties. so return still found properties. */
- if(end == FALSE)
- xx = 0;
-#endif
-
- /* keep track of current data buffer offset */
- *p_dst_data = p_cur_offset;
- return xx;
-} /* xml_flp_int_fill_file_folder() */
-
-
-/**********************************************************************************
-** Function xml_flp_int_fill_evt_data
-**
-** Description fill in file/folder structure.
-**
-** Parameters
-** Returns
-**********************************************************************************/
-static tXML_FOLDER_RES xml_flp_int_fill_evt_data( UINT8 op,
- void *p_evt_data,
- tXML_PROP **p_prop,
- UINT16 *num_prop,
- UINT8 **p_dst_data,
- UINT16 *dst_len)
-{
- tXML_FOLDER_STATE *p_xud = (tXML_FOLDER_STATE *)p_evt_data;
- INT16 inc_prop;
- UINT8 prop_name; /* Property name. */
- UINT8 entry_type;
- tXML_PROP *cur_prop = *p_prop;
- UINT8 *p_cur_offset = *p_dst_data;
-
- tXML_FOLDER_RES x_res = XML_FOLDER_OK;
- BOOLEAN x_no_res = FALSE; /* guard dest buffer resource */
-
-
- if ( op == 0 || op > XML_MAX_OBJ_TAG_ID || *num_prop == 0)
- return XML_FOLDER_ERROR;
-
-#if FOLDER_DEBUG_XML
- XML_TRACE_DEBUG2( "[xml folder] xml_flp_int_fill_evt_data op:%d, num_prop:%d",
- op, *num_prop);
-#endif
-
-
-
- while ( *num_prop > 0 && !x_no_res )
- {
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG2("end_prop:%d, name id: x%x", *num_prop, cur_prop->name);
-#endif
- prop_name = cur_prop->name;
- cur_prop++;
- *num_prop -= 1;
-
-
- switch( prop_name )
- {
- case XML_FOLDER_LISTING_ELEM_ID:
- /* skip over version attribute which should always be 1.0. this is the top level */
- break;
-
- case XML_FILE_ELEM_ID:
- case XML_FOLDER_ELEM_ID:
- /* folder or file: only type is the difference */
- entry_type = (XML_FILE_ELEM_ID==prop_name)?XML_OBX_FILE:XML_OBX_FOLDER;
- inc_prop = xml_flp_int_fill_file_folder( entry_type,
- p_xud,
- cur_prop,
- num_prop,
- &p_cur_offset,
- dst_len);
- if (inc_prop == -1) /* no dst_buf available */
- {
- /* backup one more prop to obtain the skipped folder/file entry header */
- cur_prop --;
- *num_prop += 1;
-
- x_res = XML_FOLDER_DST_NO_RES;
- x_no_res = TRUE;
- }
- else if (inc_prop == -2) /* exceed max entry */
- {
- x_no_res = TRUE;
- x_res = XML_FOLDER_OUT_FULL;
- }
- else /* found folder entry */
- {
- cur_prop += inc_prop;
- *num_prop -= inc_prop;
- }
- break;
-
- case XML_PARENT_FOLDER_ELEM_ID:
- if ( p_xud->current_entry < p_xud->max_entry )
- {
- /* set type of entry (file, folder) */
- p_xud->p_entry[p_xud->current_entry].type = XML_OBX_FOLDER;
- /* copy folder name if dst buffer is big enough, parent folder as ".." */
- if ((*dst_len - strlen(XML_PARENT_FOLDER)) > 0)
- {
- p_xud->p_entry[p_xud->current_entry].data = p_cur_offset;
- p_xud->p_entry[p_xud->current_entry].len = 2;
- memcpy( (void *)p_xud->p_entry[p_xud->current_entry].data,
- (const void *)XML_PARENT_FOLDER, 2);
- p_xud->p_entry[p_xud->current_entry].data[2] = '\0'; /* null terminate */
- p_xud->current_entry ++;
- p_cur_offset += 3 ;
- *dst_len -= 3;
- }
- else
- {
- x_no_res = TRUE;
- x_res = XML_FOLDER_DST_NO_RES;
- }
- }
- else
- {
- x_no_res = TRUE;
- x_res = XML_FOLDER_OUT_FULL;
- }
- break;
-
- case XML_FOLDER_PAUSE_ID:
-
-#if (FOLDER_DEBUG_XML==TRUE)
- XML_TRACE_DEBUG0( "[xml folder] xml_flp_int_fill_evt_data(): XML_FOLDER_PAUSE_ID" );
-#endif
- break;
-
- case XML_FOLDER_TAG_END_ID:
-#if (FOLDER_DEBUG_XML==TRUE)
- XML_TRACE_DEBUG0( "[xml folder] xml_flp_int_fill_evt_data(): XML_FOLDER_TAG_END_ID" );
-#endif
- break;
-
- default:
- XML_TRACE_DEBUG1( "[xml folder] xml_flp_int_fill_evt_data():unknown element: %d", prop_name );
- break;
- }
- }
-
- /* keep track of current filling position, and current available dst buffer */
- *p_prop = cur_prop;
- *p_dst_data = p_cur_offset;
-
- return x_res;
-} /* xml_flp_int_fill_evt_data() */
-
-
-/**************************************************************************************
-** Function XML_FolderInit
-**
-** Description Initialize xml parser state machine.
-**
-** Parameters p_xml_state: address of an xml parser state machine to be initialized,
-** allocate an additional space of size XML_FOLDER_CARRY_OVER_LEN
-** right after *p_xml_state to hold carry over data.
-** p_entry : points start of output directory entry. caller needs do
-** free this memory
-** max_entry : max is 16 bit integer value which is the maximum number
-** of folder entries.
-
-**
-** Returns void
-**************************************************************************************/
-
-void XML_FolderInit( tXML_FOLDER_PARSER *p_xml_state,
- tXML_FOLDER_ENTRY *p_entry,
- const UINT16 max_entry )
-{
- /* Initialize the generic xml parser state machine.*/
- XML_InitPars( &p_xml_state->xml, xml_folder_cback, &p_xml_state->xml_user_data );
-
- /* User need to allocate an additional space of size XML_FOLDER_CARRY_OVER_LEN */
- /* right after *p_xml_state to hold carry over data. */
- /* point to the end of the allocated buffer for p_xml_state, which is the */
- /* beginning of buffer(XML_FOLDER_CARRY_OVER_LEN) */
- p_xml_state->xml.last_bfr.p = (UINT8 *)(p_xml_state + 1);
- p_xml_state->xml.last_bfr.len = XML_FOLDER_CARRY_OVER_LEN;
-
- /* Initialize user data */
- p_xml_state->xml_user_data.p_entry = p_entry;
- p_xml_state->xml_user_data.current_entry = 0;
- p_xml_state->xml_user_data.max_name_len = XML_UI_ENTRY_MAX_NAME_LEN + 1;
- p_xml_state->xml_user_data.max_entry = (UINT16)max_entry;
- p_xml_state->xml_user_data.prop_num = 0;
-}
-
-
-/**************************************************************************************
-** Function XML_FolderParse
-**
-** Description This function is called to parse the xml data received from OBEX
-** into folder entries associated with properties value. It can also be
-** used as clean up function to delete left over data from previous parse.
-** This clean up function is typically used when application runs out of
-** resource and decides to discard extra xml data received.
-**
-** Parameters p_xml_state: pointer to a xml parser initialized by XML_FolderInit().
-** xml_data: valid pointer to OBEX list data in xml format.
-** xml_len: length of the package, must be non-zero value.
-** dst_data: valid pointer to the buffer for holding converted folder entry name.
- When dst_data is NULL, clean up all remaining data in the parser.
-** dst_len: pointer to the length of dst_data buffer, its carry out value
-** is the number of bytes remaining buffer.When dst_len is NULL,
-** it will cause to flush the internal data in the parser.
-** num_entries: current number of entries, in the end it is the total number of entries
-**
-** Returns tXML_FOLDER_RES (see xml_flp.h)
-** XML_PENDING: parsing not completed
-** XML_END_LIST: found /folder-listing but no final flag detected
-** XML_FOLDER_OUT_FULL: reached max_entry -> do not call parser anymore!!! dump data
-** XML_FOLDER_DST_NO_RES : run out of dst buffer resource while
-** some xml data still remains.
-
-**************************************************************************************/
-tXML_FOLDER_RES XML_FolderParse( tXML_FOLDER_PARSER *p_xml_state,
- UINT8 *xml_data, UINT16 xml_len,
- UINT8 *dst_data, UINT16 *dst_len,
- UINT16 *num_entries )
-{
- tXML_OS xos;
- BOOLEAN is_remain = TRUE;
- tXML_MUL_STATE *p_xml = &p_xml_state->xml;
- tXML_FOLDER_STATE *p_st = &p_xml_state->xml_user_data;
- tXML_FOLDER_RES x_res = XML_FOLDER_OK;
- tXML_RESULT res = XML_NO_PROP;
- UINT16 max_num_prop = OBX_LRG_DATA_POOL_SIZE/sizeof(tXML_PROP); /* Changed to use the reserved buffer pool */
-
-
-#if (defined(FOLDER_DEBUG_XML) && FOLDER_DEBUG_XML == TRUE)
- int xx;
- UINT8 dbg_buf[FOLDER_DEBUG_LEN];
- tXML_STR str;
-#endif
-
- /* if dst_data is NULL, clean up remaining data */
- if (!dst_data || !dst_len)
- {
- /* clean out remained xml data left over from last parse */
- if (p_xml_state->xml_user_data.p_prop )
- {
- GKI_freebuf( p_st->p_prop );
- p_st->p_prop = p_st->offset_prop = NULL;
- p_st->prop_num = 0;
- }
-#if (FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0( "[xml folder] XML_FolderParse() Clean up left over!");
-#endif
- return x_res;
- }
-
- /* if illegal OBEX data or dst buffer pointer received, return ERROR */
- if (xml_len == 0 || !xml_data)
- {
- return XML_FOLDER_ERROR;
- }
-
- /* XML_FolderParse receive new xml data, allocate buffer to hold parsed prop */
- if (p_st->offset_prop == NULL)
- {
-
-#if (FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0( "[xml folder] XML_FolderParse() Receive New Data!");
- XML_TRACE_DEBUG2( "[xml folder] XML_data start[%x] end [%x]",xml_data, xml_data+xml_len);
-#endif
- is_remain = FALSE;
- if ( NULL!= (p_st->p_prop = (tXML_PROP *)GKI_getpoolbuf( OBX_LRG_DATA_POOL_ID ) ) )
- {
- /* pointing next prop to be converted into file entry */
- p_st->prop_num = 0;
- }
- else
- {
- GKI_freebuf( p_xml_state );
- x_res = XML_FOLDER_NO_RES;
- return x_res;
- }
- }
-#if (FOLDER_DEBUG_XML == TRUE)
- else
- {
- XML_TRACE_DEBUG0( "[xml folder] XML_FolderParse(): Keep cleaning up old xml data !");
- }
-#endif
- /* update the data address */
- xos.p_begin = xml_data;
- xos.p_end = xml_data + xml_len;
-
- while( res == XML_NO_PROP )
- {
- /* if no remaining data in p_st->p_prop, parse new xml data */
- if (!is_remain)
- {
- p_st->max_num_prop = max_num_prop;
- p_st->prop_index = 0;
- res = XML_MulParse( p_xml, &xos );
-
-
-#if (FOLDER_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG4( "xml_folder_parse obj: %x, max: %d, num: %d, res: %d",
- p_st->obj, max_num_prop, p_st->prop_index, res);
-
- if (res != 0)
- {
- XML_TRACE_DEBUG1( "XML_MulParse Parsing: %d !!!", res);
- }
-
- for(xx=0; xx<p_st->prop_index; xx++)
- {
- if ( p_st->p_prop[xx].name < XML_FOLDER_MAX_ID )
- {
- str.p = p_st->p_prop[xx].p_data;
- str.len = p_st->p_prop[xx].len;
- xml_flp_debug_str(&str, dbg_buf);
- XML_TRACE_DEBUG5( "[xml folder] parsed: index[%d]:%d:%s: %s(%d)", p_st->prop_index-xx, p_st->p_prop[xx].level,
- xml_flp_ttbl[p_st->p_prop[xx].name].p_name, dbg_buf, p_st->p_prop[xx].len);
- }
- else
- {
- XML_TRACE_DEBUG3( "[xml folder] internal prop: %d:%d:%d", xx, p_st->p_prop[xx].level,
- p_st->p_prop[xx].name );
- }
- }
-#endif
- p_st->prop_num = p_st->prop_index ;
- p_st->offset_prop = p_st->p_prop;
- }
- else
- {
- /* This is left over data, pick up the result from the previous parse */
- res = p_xml->pars_res;
- }
-
- if ( res != XML_OBJ_ST_EMPTY )
- {
- x_res = xml_flp_int_fill_evt_data( p_st->obj, p_st, &p_st->offset_prop, &p_st->prop_num, &dst_data, dst_len );
-
- if ( (XML_FOLDER_OK == x_res) && (XML_NO_END == res) )
- {
- /* XML_NO_END means that the xml is not completly finished and fill returns
- ok when when partial filling has been ok */
- x_res = XML_FOLDER_PENDING;
- }
-
- /* all parsed xml data has been converted into file entry */
- /* or exceed max entry number , break the parsing loop */
- if (XML_FOLDER_OUT_FULL != x_res && XML_FOLDER_DST_NO_RES != x_res)
- {
- is_remain = FALSE;
- }
- else
- break;
- }
- } /* while */
-
- /* free property table. at next call a new one is allocated */
- if ((x_res != XML_FOLDER_DST_NO_RES && p_st->p_prop) ||
- XML_FOLDER_OUT_FULL == x_res)
- {
- GKI_freebuf( p_st->p_prop );
- p_st->p_prop = NULL;
- p_st->offset_prop = NULL;
- }
-
- if ( x_res != XML_FOLDER_DST_NO_RES && p_st->ended)
- {
- /* this should happen on the same time as final flag in fact */
- x_res = XML_FOLDER_END_LIST; /* found closing /folder-listing */
- }
-
-
- *num_entries = p_st->current_entry; /* report number of entries found. only when ended is true
- application really should be interested! */
- return x_res;
-}
-
diff --git a/stack/xml/xml_mlp.c b/stack/xml/xml_mlp.c
deleted file mode 100644
index aca0cb5..0000000
--- a/stack/xml/xml_mlp.c
+++ /dev/null
@@ -1,1060 +0,0 @@
-/******************************************************************************
- **
- ** Name: xml_mlp.c
- **
- ** Description: This module contains xml parser of MAP message list object
- **
- ** Copyright (c) 2004-2011, Broadcom Corporation, All Rights Reserved.
- ** Broadcom Bluetooth Core. Proprietary and confidential.
- ******************************************************************************/
-
-#include "bt_target.h"
-#include "gki.h"
-#include "xml_mlp_api.h"
-
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef ML_DEBUG_XML
-#define ML_DEBUG_XML TRUE
-#endif
-#define ML_DEBUG_LEN 50
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
-#define XML_TRACE_DEBUG0(m) {BT_TRACE_0(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m);}
-#define XML_TRACE_DEBUG1(m,p1) {BT_TRACE_1(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1);}
-#define XML_TRACE_DEBUG2(m,p1,p2) {BT_TRACE_2(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define XML_TRACE_DEBUG3(m,p1,p2,p3) {BT_TRACE_3(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define XML_TRACE_DEBUG4(m,p1,p2,p3,p4) {BT_TRACE_4(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define XML_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {BT_TRACE_5(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define XML_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {BT_TRACE_6(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#else
-#define XML_TRACE_DEBUG0(m)
-#define XML_TRACE_DEBUG1(m,p1)
-#define XML_TRACE_DEBUG2(m,p1,p2)
-#define XML_TRACE_DEBUG3(m,p1,p2,p3)
-#define XML_TRACE_DEBUG4(m,p1,p2,p3,p4)
-#define XML_TRACE_DEBUG5(m,p1,p2,p3,p4,p5)
-#define XML_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6)
-#endif
-
-#define XML_PERM_LEN_MAX 4
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-const UINT8 xml_ml_elem[] = "MAP-msg-listing";
-const UINT8 xml_ml_msg_elem[] = "msg";
-const UINT8 xml_ml_handle_attr[] = "handle";
-const UINT8 xml_ml_subject_attr[] = "subject";
-const UINT8 xml_ml_datetime_attr[] = "datetime";
-const UINT8 xml_ml_sender_name_attr[] = "sender_name";
-const UINT8 xml_ml_sender_addressing_attr[] = "sender_addressing";
-const UINT8 xml_ml_replyto_addressing_attr[] = "replyto_addressing";
-const UINT8 xml_ml_recipient_name_attr[] = "recipient_name";
-const UINT8 xml_ml_recipient_addressing_attr[] = "recipient_addressing";
-const UINT8 xml_ml_type_attr[] = "type";
-const UINT8 xml_ml_size_attr[] = "size";
-const UINT8 xml_ml_text_attr[] = "text";
-const UINT8 xml_ml_reception_status_attr[] = "reception_status";
-const UINT8 xml_ml_attachment_size_attr[] = "attachment_size";
-const UINT8 xml_ml_priority_attr[] = "priority";
-const UINT8 xml_ml_read_attr[] = "read";
-const UINT8 xml_ml_sent_attr[] = "sent";
-const UINT8 xml_ml_protected_attr[] = "protected";
-const UINT8 xml_ml_version_attr[] = "version";
-const UINT8 xml_ml_unknown[] = "unknown";
-
-#define XML_ML_ELEM_ID 0x01
-#define XML_ML_MSG_ELEM_ID 0x02
-#define XML_ML_MAX_OBJ_TAG_ID XML_ML_ELEM_ID
-#define XML_ML_HANDLE_ATTR_ID 0x03
-#define XML_ML_SUBJECT_ATTR_ID 0x04
-#define XML_ML_DATETIME_ATTR_ID 0x05
-#define XML_ML_SENDER_NAME_ATTR_ID 0x06
-#define XML_ML_SENDER_ADDRESSING_ATTR_ID 0x07
-#define XML_ML_REPLYTO_ADDRESSING_ATTR_ID 0x08
-#define XML_ML_RECIPIENT_NAME_ATTR_ID 0x09
-#define XML_ML_RECIPIENT_ADDRESSING_ATTR_ID 0x0a
-#define XML_ML_TYPE_ATTR_ID 0x0b
-#define XML_ML_SIZE_ATTR_ID 0x0c
-#define XML_ML_TEXT_ATTR_ID 0x0d
-#define XML_ML_RECEPTION_STATUS_ATTR_ID 0x0e
-#define XML_ML_ATTACHMENT_SIZE_ATTR_ID 0x0f
-#define XML_ML_PRIORITY_ATTR_ID 0x10
-#define XML_ML_READ_ATTR_ID 0x11
-#define XML_ML_SENT_ATTR_ID 0x12
-#define XML_ML_PROTECTED_ATTR_ID 0x13
-#define XML_ML_VERSION_ATTR_ID 0x14
-#define XML_ML_UNKNOWN_ID 0x15
-#define XML_ML_MAX_ID 0x16 /* keep in sync with above */
-#define XML_ML_TAG_END_ID 0x17 /* closing tag found end=true */
-#define XML_ML_PAUSE_ID 0x18 /* closing tag found end=false */
-
-#define XML_ML_TTBL_SIZE (XML_ML_MAX_ID+1)
-
-/*****************************************************************************
-** Type Definitions
-*****************************************************************************/
-
-typedef struct
-{
- const UINT8 *p_name;
- UINT8 len;
-} tXML_ML_TTBL_ELEM;
-
-typedef tXML_ML_TTBL_ELEM tXML_ML_TTBL[]; /* Tag Table */
-
-
-static const tXML_ML_TTBL_ELEM xml_ml_ttbl[XML_ML_TTBL_SIZE] =
-{ /* index (ML_XP_*_ID) & name */
- {(UINT8*) "", XML_ML_MAX_ID-1}, /* \x00 Number of elements in array */
- /* XML EVT_RPT element (TAG) name */
- {xml_ml_elem, 15}, /* x01 MAP-msg-listing */
- {xml_ml_msg_elem, 3}, /* x02 msg */
- {xml_ml_handle_attr, 6}, /* x03 handle */
- {xml_ml_subject_attr, 7}, /* x04 subject */
- {xml_ml_datetime_attr, 8}, /* x05 datetime */
- {xml_ml_sender_name_attr, 11}, /* x06 sender_name */
- {xml_ml_sender_addressing_attr, 17}, /* x07 sender_addressing */
- {xml_ml_replyto_addressing_attr, 18}, /* x08 replyto_addressing */
- {xml_ml_recipient_name_attr, 14}, /* x09 recipient_name */
- {xml_ml_recipient_addressing_attr, 20}, /* x0a recipient_addressing */
- {xml_ml_type_attr, 4}, /* x0b type */
- {xml_ml_size_attr, 4}, /* x0c size */
- {xml_ml_text_attr, 4}, /* x0d text */
- {xml_ml_reception_status_attr, 16}, /* x0e reception_status */
- {xml_ml_attachment_size_attr, 15}, /* x0f attachment_size */
- {xml_ml_priority_attr, 8}, /* x10 priority */
- {xml_ml_read_attr, 4}, /* x11 read */
- {xml_ml_sent_attr, 4}, /* x12 sent */
- {xml_ml_protected_attr, 9}, /* x13 protected */
- {xml_ml_version_attr, 7}, /* x14 version */
- {xml_ml_unknown, 7} /* x15 unknown */
-};
-
-#define XML_MAP_ML_PTBL_SIZE 0x03
-typedef UINT8 * tXML_MAP_ML_PTBL_ELEM;
-
-static const tXML_MAP_ML_PTBL_ELEM xml_ml_ptbl[XML_MAP_ML_PTBL_SIZE] =
-{
- (UINT8 *) "\x01", /* index x00, all valide attributes in above list */
- (UINT8 *) "\x14\x02", /* x01 attributes and sub-tags supported */
- (UINT8 *) "\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13"
-};
-
-
-#if (ML_DEBUG_XML == TRUE)
-void xml_ml_debug_str(tXML_STR *p_str, UINT8 *p_buf)
-{
- int dbg_len;
- if ( (p_str == NULL) || (NULL==p_str->p))
- BCM_STRNCPY_S( (char *)p_buf, ML_DEBUG_LEN, "(NULL)", ML_DEBUG_LEN-1);
- else
- {
- dbg_len = p_str->len;
- if ( dbg_len >= ML_DEBUG_LEN)
- dbg_len = ML_DEBUG_LEN - 1;
- BCM_STRNCPY_S( (char *)p_buf, ML_DEBUG_LEN, (char *)p_str->p, dbg_len);
- p_buf[dbg_len] = 0;
- }
-}
-
-#else
-#define xml_ml_debug_str(p_str, p_buf)
-#endif
-
-/*****************************************************************************
- ** Function xml_ml_proc_tag
- ** Description
- ** Parameters -
- ** Returns
- *****************************************************************************/
-static UINT8 xml_ml_proc_tag( tXML_ML_STATE *p_st, tXML_STR *p_name, tXML_STACK *p_stk)
-{
- const UINT8 *p_stag; /* sub tag pointer */
- UINT8 curr = p_stk->stack[p_stk->top];
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- UINT8 dbg_name[ML_DEBUG_LEN];
-#endif
-
-
- if (curr < XML_MAP_ML_PTBL_SIZE)
- {
- /* Iterate over allowed sub-tags for the current tag. */
- for (p_stag = xml_ml_ptbl[curr]; p_stag && *p_stag ; p_stag++)
- {
- if (*p_stag >= XML_ML_TTBL_SIZE)
- continue;
- if (p_name->len == xml_ml_ttbl[*p_stag].len &&
- strncmp((char *)p_name->p, (char *)xml_ml_ttbl[*p_stag].p_name, p_name->len) == 0)
- {
- p_stk->top++;
- p_stk->stack[p_stk->top] = *p_stag;
-
- return *p_stag;
- }
- }
- }
-
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- xml_ml_debug_str(p_name, dbg_name);
- XML_TRACE_DEBUG1("xml_ml_proc_tag: bad name:%s", dbg_name );
-#endif
-
- return XML_ML_UNKNOWN_ID;
-}
-
-
-/*****************************************************************************
- ** Function xml_ml_proc_attr
- ** Description
- ** Parameters -
- ** Returns
- *****************************************************************************/
-static UINT8 xml_ml_proc_attr(tXML_ML_STATE *p_st, tXML_STR *p_name, tXML_STACK *p_stk)
-{
- const UINT8 *p_stag; /* sub tag pointer */
- UINT8 curr = p_stk->stack[p_stk->top];
-#if (ML_DEBUG_XML == TRUE)
- UINT8 dbg_name[ML_DEBUG_LEN];
-#endif
- if (curr < XML_MAP_ML_PTBL_SIZE)
- {
- /* Iterate over allowed sub-tags for the current tag. */
- for (p_stag = xml_ml_ptbl[curr]; p_stag && *p_stag; p_stag++)
- {
- if (*p_stag >= XML_ML_TTBL_SIZE)
- continue;
- if (p_name->len == xml_ml_ttbl[*p_stag].len &&
- strncmp((char *)p_name->p, (char *)xml_ml_ttbl[*p_stag].p_name, p_name->len) == 0)
- {
- p_stk->top++;
- p_stk->stack[p_stk->top] = *p_stag;
-
- return *p_stag;
- }
- }
- }
-
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- xml_ml_debug_str(p_name, dbg_name);
- XML_TRACE_DEBUG1("xml_ml_proc_attr: bad name:%s", dbg_name);
-#endif
- return XML_ML_UNKNOWN_ID;
-}
-
-/*****************************************************************************
- ** Function xml_ml_find_ch_n_copy
- ** Description copy any chacter till one char in p_str. Any char in p_str
- ** will stop copy pointed by p_begin
- ** Parameters
- ** Returns
- *****************************************************************************/
-static void xml_ml_find_ch_n_copy( tXML_MCOPY *p_copy )
-{
- const UINT8 *p_tmp;
- const UINT8 *p_str = (UINT8 *)">"; /* was: ":=/> \t\n\r". i think we should copy till
- closing flag */
- unsigned int last = XML_ML_CARRY_OVER_LEN; /* maximum carry over len we can support */
- UINT8 *p_last = p_copy->last.p + p_copy->last.len - 1; /* point to the last char of carry
- over buffer */
- BOOLEAN found = FALSE;
- /* check if the last char in p_last is in p_str */
- for (p_tmp = p_str; *p_tmp; p_tmp++)
- {
- if (*p_last == *p_tmp)
- {
- found = TRUE;
- break;
- }
- } /* for */
-
- if (found == FALSE)
- {
- /* if not in p_str, move chars from p_begin to p_last
- * until reached last_len or any char in p_str */
- p_last++;
- last -= p_copy->last.len; /* calculate the maximum number of chars we can copy */
- while (*(p_copy->p_begin) && last) /* rl: not sure that this buffer is termninated by a 0 */
- {
- /* copy from source (new buffer) to carry over. adjust only carry over ptr. */
- *p_last++ = *p_copy->p_begin;
- last--;
- for (p_tmp = p_str; *p_tmp; p_tmp++)
- {
- if (*p_copy->p_begin == *p_tmp)
- {
- p_copy->p_begin++; /* adjust pointer to point to next char to read */
- /* calculate new length of carry over buffer contents */
- p_copy->last.len = XML_ML_CARRY_OVER_LEN-last;
- *p_last = 0; /* NULL terminate p_last. rl: not really neccessary. */
- return;
- }
- } /* for */
- p_copy->p_begin++; /* update now to next char. this way abort char is also copied */
- } /* while */
- } /* !found */
-}
-
-/*****************************************************************************
-** Function xml_ml_cback
-** Description
-**
-** Parameters
-** Returns
-*****************************************************************************/
-static BOOLEAN xml_ml_cback( tXML_EVENT event, void *p_event_data, void *p_usr_data)
-{
- tXML_MEVT_DATA *p_ed = (tXML_MEVT_DATA*) p_event_data;
- tXML_ML_STATE *p_st = (tXML_ML_STATE *) p_usr_data;
- tXML_PROP *p_cp = &p_st->p_prop[p_st->prop_index];
- BOOLEAN ret = TRUE;
- UINT8 next; /* next element */
- UINT8 curr = p_ed->stack.stack[p_ed->stack.top]; /* current element */
-#if (ML_DEBUG_XML == TRUE)
- UINT8 dbg_name[ML_DEBUG_LEN];
- UINT8 dbg_prefix[ML_DEBUG_LEN];
- UINT8 dbg_value[ML_DEBUG_LEN];
-#endif
-
-#if (ML_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG1("xml_ml_cback:%d", event);
-#endif
-
- switch (event)
- {
- case XML_TAG : /* <tag-name */
- next = xml_ml_proc_tag(p_st, &p_ed->tag.name, &p_ed->stack);
-#if (ML_DEBUG_XML == TRUE)
- xml_ml_debug_str(&p_ed->tag.name, dbg_name);
- xml_ml_debug_str(&p_ed->tag.prefix, dbg_prefix);
- XML_TRACE_DEBUG2("XML_TAG: p:%s, name:%s", dbg_prefix, dbg_name);
- XML_TRACE_DEBUG2("top:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
-
-#endif
- if (next != 0)
- {
- if (next <= XML_ML_MAX_OBJ_TAG_ID)
- p_st->obj = next;
-
- if (p_st->prop_index <p_st->max_num_prop)
- {
- /* we do not use prefix in FTC */
- p_cp->name = next;
- p_cp->p_data = NULL;
- p_cp->len = 0;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- }
- else
- ret = FALSE;
- }
- break;
-
- case XML_ATTRIBUTE : /* attr-name="attr-value" */
- curr = xml_ml_proc_attr(p_st, &p_ed->attr.name, &p_ed->stack);
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- xml_ml_debug_str(&p_ed->attr.name, dbg_name);
- xml_ml_debug_str(&p_ed->attr.prefix, dbg_prefix);
- xml_ml_debug_str(&p_ed->attr.value, dbg_value);
- XML_TRACE_DEBUG4("[xml ml] XML_ATTRIBUTE: p:%s, name:%s, v:%s, curr:%x",
- dbg_prefix, dbg_name, dbg_value, curr );
- XML_TRACE_DEBUG2("top 1:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
-#endif
- if ((curr != 0) && (curr != XML_ML_UNKNOWN_ID))
- {
- if (p_st->prop_index <p_st->max_num_prop)
- {
- p_cp->name = curr;
- p_cp->p_data = p_ed->attr.value.p;
- p_cp->len = p_ed->attr.value.len;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- }
- else
- ret = FALSE;
- p_ed->stack.top--;
- XML_TRACE_DEBUG2("top 2:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
- }
- break;
-
- case XML_CHARDATA :
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- xml_ml_debug_str(&p_ed->ch_data.value, dbg_value);
- XML_TRACE_DEBUG2("XML_CHARDATA: v:%s, last:%d", dbg_value, p_ed->ch_data.last);
-#endif
- break;
-
- case XML_ETAG : /* </tag-name> */
- if (p_ed->stack.top > 0)
- {
- p_ed->stack.stack[p_ed->stack.top] = 0;
- p_ed->stack.top--;
- p_st->ended = (BOOLEAN) (p_ed->stack.top == 0);
- }
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- xml_ml_debug_str(&p_ed->etag.name, dbg_name);
- xml_ml_debug_str(&p_ed->etag.prefix, dbg_prefix);
- XML_TRACE_DEBUG2("[xml ml] XML_ETAG: p:%s, name:%s", dbg_prefix, dbg_name);
- XML_TRACE_DEBUG2("[xml ml] top:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
-#endif
- break;
-
- case XML_TAG_END: /* /> */
- curr = p_ed->stack.stack[p_ed->stack.top];
-
- if (p_st->prop_index <p_st->max_num_prop)
- {
- if (p_ed->empty_elem.end)
- p_cp->name = XML_ML_TAG_END_ID;
- else
- p_cp->name = XML_ML_PAUSE_ID;
- p_cp->p_data = NULL;
- p_cp->len = 0;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- if (p_ed->empty_elem.end && p_ed->stack.top > 0)
- {
- p_ed->stack.top--;
- }
- }
- else
- ret = FALSE;
-
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG4("[xml ml] XML_TAG_END: %d, top:x%x, stk:x%x, curr:x%x",
- p_ed->empty_elem.end, p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top], curr);
-#endif
- break;
-
- case XML_PARTIAL:
- if (p_st->p_prop[p_st->prop_index-1].name != XML_ML_TAG_END_ID)
- {
- p_ed->stack.top--;
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0("[xml ml] adjust due to XML_PARTIAL");
-#endif
- }
- break;
-
- case XML_COPY:
- xml_ml_find_ch_n_copy( &p_ed->copy );
- XML_TRACE_DEBUG1("[xml ml] XML_COPY: %s", p_ed->copy.last.p);
- break;
-
- default :
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG1("[xml ml] default: XML event: %d", event);
-#endif
- break;
- }
-
- return ret;
-}
-
-
-
-
-/**********************************************************************************
-** Function xml_ml_int_fill_msg_list
-** Description fill in file/folder structure.
-**
-** Parameters
-** Returns xx: > 0 : number of properties scanned, folder entry is added
-** = 0 : no end tag found, carry over to next parse
-** = -1: no dst_resource avaibale, all prop left to next parse
-** = -2: exceed max entry, no folder entry added
-**********************************************************************************/
-static INT16 xml_ml_int_fill_msg_list( tXML_ML_STATE * p_xud,
- tXML_PROP *p_prop,
- UINT16 *num_prop,
- UINT8 **p_dst_data,
- UINT16 *dst_len)
-{
- INT16 xx;
- UINT16 len;
- BOOLEAN end = FALSE;
- tXML_PROP *cur_prop = p_prop;
- UINT8 *p_cur_offset = *p_dst_data;
- BOOLEAN copy_attr_info;
- BOOLEAN no_buf_left;
- UINT8 **p_attr_data = NULL;
- UINT16 *p_attr_len = NULL;
-
- if ( p_xud->current_entry >= p_xud->max_entry )
- return -2;
-
- for (xx=0; (xx < *num_prop) && !end; xx++, cur_prop++)
- {
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- /* XML_TRACE_DEBUG5( "[xml ml] fill: num_prop:%d, name id: x%x, p_prop: x%x, len: %d p_data:%s",
- (*num_prop-xx) , cur_prop->name, cur_prop, cur_prop->len, cur_prop->p_data, ); */
-#endif
- copy_attr_info = TRUE;
- no_buf_left = FALSE;
- len = cur_prop->len;
-
- switch (cur_prop->name)
- {
- case XML_ML_HANDLE_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].msg_handle) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].msg_handle_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
-
- case XML_ML_SUBJECT_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].subject) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].subject_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_DATETIME_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].datetime) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].datetime_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_SENDER_NAME_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].sender_name) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].sender_name_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_SENDER_ADDRESSING_ATTR_ID :
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].sender_addressing) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].sender_addressing_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_REPLYTO_ADDRESSING_ATTR_ID :
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].replyto_addressing) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].replyto_addressing_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_RECIPIENT_NAME_ATTR_ID :
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].recipient_name) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].recipient_name_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_RECIPIENT_ADDRESSING_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].recipient_addressing) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].recipient_addressing_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_TYPE_ATTR_ID :
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].type) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].type_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
-
- case XML_ML_SIZE_ATTR_ID :
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].org_msg_size) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].org_msg_size_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_TEXT_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].text) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].text_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_RECEPTION_STATUS_ATTR_ID:
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].reception_status) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].reception_status_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_ATTACHMENT_SIZE_ATTR_ID :
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].attachment_size) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].attachment_size_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_PRIORITY_ATTR_ID :
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].priority_status) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].priority_status_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_READ_ATTR_ID :
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].read) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].read_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_SENT_ATTR_ID :
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
-
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].sent) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].sent_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
- case XML_ML_PROTECTED_ATTR_ID :
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_attr_data = &(p_xud->p_entry[p_xud->current_entry].is_protected) ;
- p_attr_len = &(p_xud->p_entry[p_xud->current_entry].is_protected_len);
- }
- else /* run out of dst buffer resource */
- no_buf_left = TRUE;
- break;
-
- case XML_ML_TAG_END_ID:
- /* -------------------- CUSTOMER SPECIFIC ---------------------- */
- p_xud->current_entry++; /* increment only when end tag (/>) found */
- copy_attr_info = FALSE;
- XML_TRACE_DEBUG1("[xml ml]: current_entry cnt=%d",p_xud->current_entry);
- break;
- /* case XML_VERSION_ATTR_ID: */
- default:
- copy_attr_info = FALSE;
- XML_TRACE_DEBUG1("[xml ml] unknown attrib: %d", cur_prop->name );
- break;
- }
-
- if (copy_attr_info && p_attr_data && p_attr_len)
- {
- *p_attr_data = p_cur_offset;
- *p_attr_len = len;
-
- memcpy( (void *)*p_attr_data,
- (const void *)cur_prop->p_data,
- len );
- (*p_attr_data)[len] = 0; /* null terminate string */
- p_cur_offset += (len + 1);
- *dst_len = *dst_len - (len + 1) ;
-
- #if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
-
- XML_TRACE_DEBUG5("[xml ml]: Attr ID=%d val=[%s] len=%d level=%d dst_len_left=%d",
- cur_prop->name,
- *p_attr_data,
- *p_attr_len,
- cur_prop->level,
- *dst_len);
- #endif
- }
-
- if (no_buf_left)
- {
- #if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0("Error!! No more buffer left to store the parser outputs");
- #endif
- return -1;
- }
-
- }
-#if (ML_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG2("[xml ml] fill_ml: end:%d, xx:%d", end, xx);
-#endif
-#if 0
- /* if end tag not found -> split over two buffers. but parser will still show rest of
- found properties. so return still found properties. */
- if (end == FALSE)
- xx = 0;
-#endif
-
- /* keep track of current data buffer offset */
- *p_dst_data = p_cur_offset;
- return xx;
-} /* xml_ml_int_fill_msg_list() */
-
-
-/**********************************************************************************
-** Function xml_ml_int_fill_evt_data
-**
-** Description fill in MAP event report structure.
-**
-** Parameters
-** Returns
-**********************************************************************************/
-static tXML_ML_RES xml_ml_int_fill_evt_data( UINT8 op,
- void *p_evt_data,
- tXML_PROP **p_prop,
- UINT16 *num_prop,
- UINT8 **p_dst_data,
- UINT16 *dst_len)
-{
- tXML_ML_STATE *p_xud = (tXML_ML_STATE *)p_evt_data;
- INT16 inc_prop;
- UINT8 prop_name; /* Property name. */
- tXML_PROP *cur_prop = *p_prop;
- UINT8 *p_cur_offset = *p_dst_data;
-
- tXML_ML_RES x_res = XML_ML_OK;
- BOOLEAN x_no_res = FALSE; /* guard dest buffer resource */
-
- if ( op == 0 || op > XML_ML_MAX_OBJ_TAG_ID || *num_prop == 0)
- return XML_ML_ERROR;
-
-#if ML_DEBUG_XML
- XML_TRACE_DEBUG2( "[xml ml] xml_ml_int_fill_evt_data op:%d, num_prop:%d",
- op, *num_prop);
-#endif
-
-
-
- while ( *num_prop > 0 && !x_no_res )
- {
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG2("end_prop:%d, name id: x%x", *num_prop, cur_prop->name);
-#endif
- prop_name = cur_prop->name;
- cur_prop++;
- *num_prop -= 1;
-
-
- switch ( prop_name )
- {
- case XML_ML_ELEM_ID:
- XML_TRACE_DEBUG0("[xml ml] xml_etag_elem");
- /* skip over version attribute which should always be 1.0. this is the top level */
- break;
-
- case XML_ML_MSG_ELEM_ID:
- XML_TRACE_DEBUG0("[xml ml] xml_etag_elem");
- inc_prop = xml_ml_int_fill_msg_list( p_xud,
- cur_prop,
- num_prop,
- &p_cur_offset,
- dst_len);
- if (inc_prop == -1) /* no dst_buf available */
- {
- /* backup one more prop to obtain the skipped ml/file entry header */
- cur_prop --;
- *num_prop += 1;
-
- x_res = XML_ML_DST_NO_RES;
- x_no_res = TRUE;
- }
- else if (inc_prop == -2) /* exceed max entry */
- {
- x_no_res = TRUE;
- x_res = XML_ML_OUT_FULL;
- }
- else /* found ml entry */
- {
- cur_prop += inc_prop;
- *num_prop -= inc_prop;
- }
- break;
-
- case XML_ML_PAUSE_ID:
-#if (ML_DEBUG_XML==TRUE)
- XML_TRACE_DEBUG0( "[xml ml] xml_ml_int_fill_evt_data(): XML_ML_PAUSE_ID" );
-#endif
- break;
-
- case XML_ML_TAG_END_ID:
-#if (ML_DEBUG_XML==TRUE)
- XML_TRACE_DEBUG0( "[xml ml] xml_ml_int_fill_evt_data(): XML_ML_TAG_END_ID" );
-#endif
- break;
-
- default:
- XML_TRACE_DEBUG1( "[xml ml] xml_ml_int_fill_evt_data():unknown element: %d", prop_name );
- break;
- }
- }
-
- /* keep track of current filling position, and current available dst buffer */
- *p_prop = cur_prop;
- *p_dst_data = p_cur_offset;
-
- return x_res;
-} /* xml_ml_int_fill_evt_data() */
-
-
-/**************************************************************************************
-** Function XML_MlInit
-**
-** Description Initialize xml parser state machine.
-**
-** Parameters p_xml_state: address of an xml parser state machine to be initialized,
-** allocate an additional space of size XML_ML_CARRY_OVER_LEN
-** right after *p_xml_state to hold carry over data.
-** p_entry : points start of output directory entry. caller needs do
-** free this memory
-** max_entry : max is 16 bit integer value which is the maximum number
-** of ml entries.
-
-**
-** Returns void
-**************************************************************************************/
-
-void XML_MlInit( tXML_ML_PARSER *p_xml_state,
- tXML_ML_ENTRY *p_entry,
- const UINT16 max_entry )
-{
- XML_TRACE_DEBUG0("[xml ml] XML_MlInit");
- /* Initialize the generic xml parser state machine.*/
- XML_InitPars( &p_xml_state->xml, xml_ml_cback, &p_xml_state->xml_user_data );
-
- /* User need to allocate an additional space of size XML_ML_CARRY_OVER_LEN */
- /* right after *p_xml_state to hold carry over data. */
- /* point to the end of the allocated buffer for p_xml_state, which is the */
- /* beginning of buffer(XML_ML_CARRY_OVER_LEN) */
- p_xml_state->xml.last_bfr.p = (UINT8 *)(p_xml_state + 1);
- p_xml_state->xml.last_bfr.len = XML_ML_CARRY_OVER_LEN;
-
- /* Initialize user data */
- p_xml_state->xml_user_data.p_entry = p_entry;
- p_xml_state->xml_user_data.current_entry = 0;
- p_xml_state->xml_user_data.max_name_len = XML_UI_ENTRY_MAX_NAME_LEN + 1;
- p_xml_state->xml_user_data.max_entry = (UINT16)max_entry;
- p_xml_state->xml_user_data.prop_num = 0;
-}
-
-
-/**************************************************************************************
-** Function XML_MlParse
-**
-** Description This function is called to parse the xml data received from OBEX
-** into folder entries associated with properties value. It can also be
-** used as clean up function to delete left over data from previous parse.
-** This clean up function is typically used when application runs out of
-** resource and decides to discard extra xml data received.
-**
-** Parameters p_xml_state: pointer to a xml parser initialized by XML_MlInit().
-** xml_data: valid pointer to OBEX list data in xml format.
-** xml_len: length of the package, must be non-zero value.
-** dst_data: valid pointer to the buffer for holding converted folder entry name.
- When dst_data is NULL, clean up all remaining data in the parser.
-** dst_len: pointer to the length of dst_data buffer, its carry out value
-** is the number of bytes remaining buffer.When dst_len is NULL,
-** it will cause to flush the internal data in the parser.
-** num_entries: current number of entries, in the end it is the total number of entries
-**
-** Returns tXML_ML_RES (see xml_erp.h)
-** XML_PENDING: parsing not completed
-** XML_END_LIST: found /folder-listing but no final flag detected
-** XML_ML_OUT_FULL: reached max_entry -> do not call parser anymore!!! dump data
-** XML_ML_DST_NO_RES : run out of dst buffer resource while
-** some xml data still remains.
-
-**************************************************************************************/
-tXML_ML_RES XML_MlParse( tXML_ML_PARSER *p_xml_state,
- UINT8 *xml_data, UINT16 xml_len,
- UINT8 *dst_data, UINT16 *dst_len,
- UINT16 *num_entries )
-{
- tXML_OS xos;
- BOOLEAN is_remain = TRUE;
- tXML_MUL_STATE *p_xml = &p_xml_state->xml;
- tXML_ML_STATE *p_st = &p_xml_state->xml_user_data;
- tXML_ML_RES x_res = XML_ML_OK;
- tXML_RESULT res = XML_NO_PROP;
- UINT16 max_num_prop = GKI_BUF3_SIZE/sizeof(tXML_PROP); /* i hope this is sufficient for 1 */
-
-
-#if (defined(ML_DEBUG_XML) && ML_DEBUG_XML == TRUE)
- int xx;
- UINT8 dbg_buf[ML_DEBUG_LEN];
- tXML_STR str;
-#endif
-
- XML_TRACE_DEBUG0("[xml ml] XML_MlParse");
- /* if dst_data is NULL, clean up remaining data */
- if (!dst_data || !dst_len)
- {
- /* clean out remained xml data left over from last parse */
- if (p_xml_state->xml_user_data.p_prop )
- {
- GKI_freebuf( p_st->p_prop );
- p_st->p_prop = p_st->offset_prop = NULL;
- p_st->prop_num = 0;
- }
-#if (ML_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0( "[xml ml] XML_MlParse() Clean up left over!");
-#endif
- return x_res;
- }
-
- /* if illegal OBEX data or dst buffer pointer received, return ERROR */
- if (xml_len == 0 || !xml_data)
- {
- return XML_ML_ERROR;
- }
-
- /* XML_MlParse receive new xml data, allocate buffer to hold parsed prop */
- if (p_st->offset_prop == NULL)
- {
-
-#if (ML_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0( "[xml ml] XML_MlParse() Receive New Data!");
- XML_TRACE_DEBUG2( "[xml ml] XML_data start[%x] end [%x]",xml_data, xml_data+xml_len);
-#endif
- is_remain = FALSE;
- if ( NULL!= (p_st->p_prop = (tXML_PROP *)GKI_getbuf( GKI_BUF3_SIZE ) ) )
- {
- /* pointing next prop to be converted into file entry */
- p_st->prop_num = 0;
- }
- else
- {
- GKI_freebuf( p_xml_state );
- x_res = XML_ML_NO_RES;
- return x_res;
- }
- }
-#if (ML_DEBUG_XML == TRUE)
- else
- {
- XML_TRACE_DEBUG0( "[xml ml] XML_MlParse(): Keep cleaning up old xml data !");
- }
-#endif
- /* update the data address */
- xos.p_begin = xml_data;
- xos.p_end = xml_data + xml_len;
-
- while ( res == XML_NO_PROP )
- {
- /* if no remaining data in p_st->p_prop, parse new xml data */
- if (!is_remain)
- {
- p_st->max_num_prop = max_num_prop;
- p_st->prop_index = 0;
- res = XML_MulParse( p_xml, &xos );
-
-
-#if (ML_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG4( "xml_ml_parse obj: %x, max: %d, num: %d, res: %d",
- p_st->obj, max_num_prop, p_st->prop_index, res);
- if (res != 0)
- {
- XML_TRACE_DEBUG1( "XML_MulParse Parsing: %d !!!", res);
- }
-
- for (xx=0; xx<p_st->prop_index; xx++)
- {
- if ( p_st->p_prop[xx].name < XML_ML_MAX_ID )
- {
- str.p = p_st->p_prop[xx].p_data;
- str.len = p_st->p_prop[xx].len;
- xml_ml_debug_str(&str, dbg_buf);
- XML_TRACE_DEBUG5( "[xml ml] parsed: index[%d]:%d:%s: %s(%d)", p_st->prop_index-xx, p_st->p_prop[xx].level,
- xml_ml_ttbl[p_st->p_prop[xx].name].p_name, dbg_buf, p_st->p_prop[xx].len);
- }
- else
- {
- XML_TRACE_DEBUG3( "[xml ml] internal prop: %d:%d:%d", xx, p_st->p_prop[xx].level,
- p_st->p_prop[xx].name );
- }
- }
-#endif
- p_st->prop_num = p_st->prop_index ;
- p_st->offset_prop = p_st->p_prop;
- }
- else
- {
- /* This is left over data, pick up the result from the previous parse */
- res = p_xml->pars_res;
- }
-
- if ( res != XML_OBJ_ST_EMPTY )
- {
- x_res = xml_ml_int_fill_evt_data( p_st->obj, p_st, &p_st->offset_prop, &p_st->prop_num, &dst_data, dst_len );
-
- if ( (XML_ML_OK == x_res) && (XML_NO_END == res) )
- {
- /* XML_NO_END means that the xml is not completly finished and fill returns
- ok when when partial filling has been ok */
- x_res = XML_ML_PENDING;
- }
-
- /* all parsed xml data has been converted into file entry */
- /* or exceed max entry number , break the parsing loop */
- if (XML_ML_OUT_FULL != x_res && XML_ML_DST_NO_RES != x_res)
- {
- is_remain = FALSE;
- }
- else
- break;
- }
- } /* while */
-
- /* free property table. at next call a new one is allocated */
- if ((x_res != XML_ML_DST_NO_RES && p_st->p_prop) ||
- XML_ML_OUT_FULL == x_res)
- {
- GKI_freebuf( p_st->p_prop );
- p_st->p_prop = NULL;
- p_st->offset_prop = NULL;
- }
-
- if ( x_res != XML_ML_DST_NO_RES && p_st->ended)
- {
- /* this should happen on the same time as final flag in fact */
- x_res = XML_ML_END_LIST; /* found closing /ml-listing */
- }
-
- *num_entries = p_st->current_entry; /* report number of entries found. only when ended is true
- application really should be interested! */
- return x_res;
-}
-
diff --git a/stack/xml/xml_parse.c b/stack/xml/xml_parse.c
deleted file mode 100644
index 3f9e2e1..0000000
--- a/stack/xml/xml_parse.c
+++ /dev/null
@@ -1,1502 +0,0 @@
-/*****************************************************************************
-**
-** Name: xml_parse.c
-**
-** File: XML Parser
-**
-** Copyright (c) 2000-2011, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-#include "bt_target.h"
-#include "xml_pars_api.h"
-#include "data_types.h"
-#include "bt_types.h"
-/* The XML Parser is dependent on the Object Store. At present
-** the object store resides in GOEP and hence the parser is
-** dependent on GOEP. The parser only uses the Object Store
-** in GOEP, so if the Object Store is separated from GOEP in the
-** future, the parser will not be dependent on GOEP.
-*/
-
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef BIP_TRACE_XML
-#define BIP_TRACE_XML FALSE
-#endif
-
-#if (defined(BIP_TRACE_XML) && BIP_TRACE_XML == TRUE)
-#define XML_TRACE_DEBUG0(m) {BT_TRACE_0(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m);}
-#define XML_TRACE_DEBUG1(m,p1) {BT_TRACE_1(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1);}
-#define XML_TRACE_DEBUG2(m,p1,p2) {BT_TRACE_2(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define XML_TRACE_DEBUG3(m,p1,p2,p3) {BT_TRACE_3(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define XML_TRACE_DEBUG4(m,p1,p2,p3,p4) {BT_TRACE_4(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define XML_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {BT_TRACE_5(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define XML_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {BT_TRACE_6(TRACE_LAYER_GOEP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#else
-#define XML_TRACE_DEBUG0(m)
-#define XML_TRACE_DEBUG1(m,p1)
-#define XML_TRACE_DEBUG2(m,p1,p2)
-#define XML_TRACE_DEBUG3(m,p1,p2,p3)
-#define XML_TRACE_DEBUG4(m,p1,p2,p3,p4)
-#define XML_TRACE_DEBUG5(m,p1,p2,p3,p4,p5)
-#define XML_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6)
-#endif
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-
-#define XML_ST '<'
-#define XML_GT '>'
-#define XML_QM '?'
-#define XML_EX '!'
-#define XML_EM '/' /* End Mark */
-#define XML_CO ':'
-#define XML_EQ '='
-#define XML_SQ '\''
-#define XML_DQ '"'
-#define XML_AM '&'
-#define XML_SC ';'
-#define XML_PD '#'
-#define XML_HX 'x'
-#define XML_HY '-'
-#define XML_LB '['
-
-#define XML_LT_STR "lt"
-#define XML_GT_STR "gt"
-#define XML_AMP_STR "amp"
-#define XML_APOS_STR "apos"
-#define XML_QUOT_STR "quot"
-
-#define XML_QTAG_END_STR "?>"
-#define XML_COMM_STR "--"
-#define XML_COMM_END_STR "-->"
-#define XML_CDS_STR "[CDATA["
-#define XML_CDS_END_STR "]]>"
-#define XML_DOCT_STR "<'\""
-
-static const UINT8 xml_name_srch[] = ":=/> \t\n\r";
-
-
-/*****************************************************************************
-** Type Definitions
-*****************************************************************************/
-
-enum
-{
- XML_PASS_WS,
- XML_SKIP_WS,
- XML_NORM_WS
-};
-typedef UINT16 tXML_WS_OP;
-
-
-
-/*****************************************************************************
-** Globals
-**
-** The global below is used as the buffer set (tXML_BFR_SET) in a local
-** variable (of type tXML_MUL_STATE) in XML_Parse. The buffer set memory, is
-** separated from the rest of tXML_MUL_STATE to make it easy to change the
-** allocation of its memory if found necessary. See xml_alloc_bfr_set.
-*****************************************************************************/
-
-/*****************************************************************************
-** Macro Functions
-*****************************************************************************/
-
-#define XML_EOS(p_st) ((p_st)->curr_res <= 0) /* End Of Store */
-/* white space: " ", \t, \r, \n */
-#define XML_IS_WS(c) (((c) == 0x20) || ((c) == 0x9) || \
- ((c) == 0xD) || ((c) == 0xA) || \
- ((c) == 0x00) )
-
-
-/*****************************************************************************
-** Function Prototypes
-*****************************************************************************/
-
-static BOOLEAN xml_get_next(tXML_MUL_STATE *, tXML_WS_OP);
-
-static BOOLEAN xml_find_ch(tXML_MUL_STATE *, UINT8, tXML_WS_OP);
-
-static void xml_incr_pars_res(tXML_MUL_STATE *, tXML_RESULT);
-
-static void xml_set_bfr(tXML_MUL_STATE *, UINT8);
-
-/* parsing static functions */
-
-static BOOLEAN xml_elems(tXML_MUL_STATE *, BOOLEAN);
-
-static BOOLEAN xml_qm_elem(tXML_MUL_STATE *);
-
-static BOOLEAN xml_ex_elem(tXML_MUL_STATE *, BOOLEAN);
-
-static BOOLEAN xml_tag_elem(tXML_MUL_STATE *);
-
-static BOOLEAN xml_etag_elem(tXML_MUL_STATE *);
-
-#define XML_SET_CLEAR 0
-#define XML_SET_NAME 1
-#define XML_SET_VALUE 2
-
-
-
-
-/*****************************************************************************
-** API Functions
-*****************************************************************************/
-
-void XML_InitPars(tXML_MUL_STATE *p_st, tXML_CBACK xml_cback, void *p_usr_data)
-{
- memset(p_st, 0, sizeof(tXML_MUL_STATE));
- p_st->cback = xml_cback;
- p_st->p_usr_data = p_usr_data;
-
- /* by memset()
- p_st->p_data_bfr = NULL;
- p_st->next_token = 0;
- p_st->curr_res = 0;
- p_st->pars_res = XML_SUCCESS;
- p_st->skip_next_nl = FALSE;
-
- p_st->prefix.p = NULL;
- p_st->name.p = NULL;
- p_st->value.p = NULL;
- p_st->prefix.len= 0;
- p_st->name.len = 0;
- p_st->value.len = 0;
-
- p_st->status = XML_STS_INIT;
- */
-}
-
-
-
-/*****************************************************************************
-**
-** Function XML_MulParse
-**
-** Description
-** The current implementation of the xml_pars_api supports only those
-** XML-contructs needed in BPP SOAP-messages. The parser must have a
-** small footprint and is therefore small and simple.
-**
-** According to SOAP a message must not contain the doctypedecl construct
-** (production) and it must not contain Processing Instructions (PI
-** production), i.e. these constructs are not supported. In addition,
-** CDATA sections, any external or internal entities and the XML
-** Declaration are not supported (not used in BPP). Should any of these
-** be included in a message being parsed, they will be reported returning
-** a warning code. The parser will then try to find the next tag.
-** When the parser reports an XML-event using the callback it will always
-** continue, even if the callback returns false. All strings in event
-** data passed with the callback are limited to 64 bytes in size, except
-** the prefix string which has 32 as max size. Consequtive XML_CHARDATA
-** events are not supported. Leading and trailing white space is removed
-** from the value string before sending the XML_CHARDATA event.
-**
-** This function and also all other helping static parsing functions use
-** more than one return statement in a function. The reason is that
-** a parse error has been found and to exit as soon as possible.
-** If one had used only one return in each function, the path
-** representing a correct xml syntax had been expressed with very deeply
-** nested if-statements.
-**
-** Parameters
-** see h-file
-** Returns
-** see h-file
-*****************************************************************************/
-
-tXML_RESULT XML_MulParse(tXML_MUL_STATE *p_st, tXML_OS *p_os)
-{
- BOOLEAN found;
- BOOLEAN query, partial = FALSE;
- BOOLEAN parse_ok = TRUE;
- int keep_size;
- tXML_RESULT res = XML_SUCCESS;
- tXML_RESULT old_pars_res;
-
- p_st->curr_res = 1; /* not EOS */
- memcpy(&p_st->xml_os, p_os, sizeof(tXML_OS));
- old_pars_res = p_st->pars_res;
- p_st->pars_res = XML_SUCCESS;
- p_st->prefix.len = 0;
- p_st->name.len = 0;
- p_st->value.len = 0;
- p_st->p_last_stm = 0;
- p_st->p_copy = 0;
-
-#if ((defined (BIP_TRACE_XML) && BIP_TRACE_XML == TRUE) || (defined FOLDER_DEBUG_XML && FOLDER_DEBUG_XML== TRUE))
- XML_TRACE_DEBUG4("XML_MulParse status:%d, pars_res: %d, begin:%x, end:x%x",
- p_st->status, old_pars_res, p_os->p_begin, p_os->p_end);
-#endif
-
- /* this do-while(0) loop is to avoid too many return statements in this routine.
- * it's easier to "cleanup" with only one return statement */
- if(p_st->status == XML_STS_INIT)
- {
-
- p_st->p_cur = p_os->p_begin;
-#if ((defined (BIP_TRACE_XML) && BIP_TRACE_XML == TRUE) || (defined FOLDER_DEBUG_XML && FOLDER_DEBUG_XML== TRUE))
- XML_TRACE_DEBUG1("p_cur:x%x", p_st->p_cur);
-#endif
- do
- {
- if (!xml_get_next(p_st, XML_PASS_WS)) /* obj store empty or err */
- {
- res = XML_OBJ_ST_EMPTY;
- break;
- }
-
- found = FALSE;
- while (!XML_EOS(p_st) && !found)
- { /* skip all but top element */
- if (!xml_find_ch(p_st, XML_ST, XML_PASS_WS) ||
- !xml_get_next(p_st, XML_PASS_WS))
- {
- res = XML_ERR;
- break;
- }
-
- if (p_st->next_token == XML_QM)
- {
- parse_ok = xml_qm_elem(p_st);
- }
- else if (p_st->next_token == XML_EX)
- {
- parse_ok = xml_ex_elem(p_st, TRUE);
- }
- else if (p_st->next_token == XML_EM)
- {
- parse_ok = FALSE;
- if (!xml_get_next(p_st, XML_PASS_WS))
- {
- res = XML_ERR;
- break;
- }
- }
- else
- {
- found = TRUE;
- parse_ok = TRUE;
- }
-
- if (!parse_ok)
- xml_incr_pars_res(p_st, XML_ERR);
- }
- } while (0);
- p_st->status = XML_STS_1STM;
- }
- else if(old_pars_res == XML_NO_PROP)
- {
- }
- else
- {
-#if ((defined (BIP_TRACE_XML) && BIP_TRACE_XML == TRUE) || (defined FOLDER_DEBUG_XML && FOLDER_DEBUG_XML== TRUE))
- XML_TRACE_DEBUG2("p_st->last_bfr.p:x%x, p_st->used_last_bfr:%d",
- p_st->last_bfr.p, p_st->used_last_bfr);
-#endif
-
-/* if there was some data left, read it here. */
- if(p_st->partial_st.last_bfr.p && p_st->partial_st.used_last_bfr )
- {
- memcpy(p_st->last_bfr.p, p_st->partial_st.last_bfr.p, p_st->partial_st.used_last_bfr);
- p_st->used_last_bfr = p_st->partial_st.used_last_bfr;
- p_st->last_bfr.p[p_st->partial_st.used_last_bfr] = 0;
- p_st->event_data.part.parse = p_st->partial_st.event_data.part.parse;
-
- /* set length to 0 */
- p_st->partial_st.used_last_bfr = 0;
- XML_TRACE_DEBUG1("retrieved PARTIAL data = [%s]\n", p_st->last_bfr.p);
-
- p_st->p_cur = p_st->last_bfr.p;
- /* continuation packet */
- /* read a ch, setup xml_set_bfr */
- xml_get_next(p_st, XML_PASS_WS);
- p_st->event_data.copy.p_begin = p_st->xml_os.p_begin;
- p_st->event_data.copy.last.p = p_st->last_bfr.p;
- p_st->event_data.copy.last.len = p_st->used_last_bfr;
- p_st->cback(XML_COPY, &(p_st->event_data), p_st->p_usr_data);
- }
- else
- {
- if(p_st->used_last_bfr == 0)
- {
- p_st->p_cur = p_os->p_begin;
- xml_get_next(p_st, XML_PASS_WS);
- }
- else
- return XML_NO_MEM;
- }
-#if ((defined (BIP_TRACE_XML) && BIP_TRACE_XML == TRUE) || (defined FOLDER_DEBUG_XML && FOLDER_DEBUG_XML== TRUE))
- XML_TRACE_DEBUG1("p_st->p_cur:x%x", p_st->p_cur);
-#endif
- }
-
- XML_TRACE_DEBUG0("XML_MulParse end while");
-
- if(res == XML_SUCCESS)
- {
- /* here we found "<(a-z)" */
- if (!XML_EOS(p_st))
- {
- if(p_st->status == XML_STS_1STM)
- {
- /* remeber the beginning position right after '<' in the first line */
- /* if the first line can't be parsed at first round, save it to the second parse */
- p_st->p_copy = p_st->p_cur - 1;
- parse_ok = xml_tag_elem(p_st);
- }
-
- /* parsed the first line */
- XML_TRACE_DEBUG0("XML_MulParse exit xml_tag_elem");
-
- if (!parse_ok)
- {
- query = p_st->cback(XML_QUERY, &(p_st->event_data), p_st->p_usr_data);
-
- /* if first line parsing is not completed while reach the end of stack, ERROR occurs */
- if (query == TRUE)
- xml_incr_pars_res(p_st, XML_ERR);
- else /* first line parsing to be continued, copy partial data at later point*/
- partial = TRUE;
- }
- else /* first line is parsed ok, change parsing status */
- p_st->status = XML_STS_1TAG;
-
-
-
- if (!XML_EOS(p_st) && parse_ok)
- {
- parse_ok = xml_elems(p_st, parse_ok);
- query = p_st->cback(XML_QUERY, &(p_st->event_data), p_st->p_usr_data);
- if (parse_ok == FALSE || query == FALSE)
- {
- partial = TRUE;
-
- }
- else
- p_st->status = XML_STS_DONE;
- }
-
- /* copy partial data if any */
- if (partial)
- {
- if(p_st->pars_res == XML_NO_PROP)
- {
- p_st->p_cur = p_st->p_copy;
- p_st->event_data.part.parse = p_st->pars_res;
- p_st->event_data.part.p_keep = p_st->p_cur;
- XML_TRACE_DEBUG1("p_st->p_cur:x%x (last_stm)", p_st->p_cur);
- p_st->cback(XML_PARTIAL, &(p_st->event_data), p_st->p_usr_data);
- xml_incr_pars_res(p_st, XML_NO_END);
- }
- else
- {
- if( p_st->last_bfr.p &&
- (p_st->p_copy > p_st->xml_os.p_begin) &&
- (p_st->p_copy < p_st->xml_os.p_end) )
- {
- keep_size = p_st->xml_os.p_end - p_st->p_copy;
- if(keep_size < p_st->last_bfr.len)
- {
- /* store the partial data to a temporary buffer,
- NOT to the queue of buffers as it would overwrite current ones! */
- if(p_st->partial_st.last_bfr.p )
- {
- XML_TRACE_DEBUG0("Store partial data\n");
- BCM_STRNCPY_S((char *)p_st->partial_st.last_bfr.p, 512, (char *)p_st->p_copy, keep_size);
- p_st->partial_st.used_last_bfr= keep_size;
- p_st->partial_st.last_bfr.p[keep_size] = 0;
- p_st->partial_st.event_data.part.parse = p_st->pars_res;
- p_st->partial_st.event_data.part.p_keep= p_st->last_bfr.p;
- }
- else
- XML_TRACE_DEBUG0("ERROR to store partial data");
-
- p_st->cback(XML_PARTIAL, &(p_st->event_data), p_st->p_usr_data);
- xml_incr_pars_res(p_st, XML_NO_END);
- }
- }
- }/* else NO_PROP */
- } /* end of partial */
- } /* end of !XML_EOS(p_st) */
- } /* end of res == XML_SUCCESS */
-
-
- return p_st->pars_res;
-}
-
-
-/*****************************************************************************
-** Static Functions
-*****************************************************************************/
-
-
-
-/*****************************************************************************
-**
-** Function xml_set_bfr
-**
-** Description
-** Sets the buffer that is going to be used when tokens are pushed from
-** p_st->next_token into some buffer in the buffer set.
-**
-** Parameters
-** p_st (in/out) : the parser state
-** p_bfr (in) : the buffer that will get all tokens (characters)
-** NULL is allowed in which case no buffer is used.
-** bfr_max_ind (in) : the max index into the buffer in which a non-null
-** char may be stored
-**
-** Returns
-** -
-*****************************************************************************/
-static void xml_set_bfr(tXML_MUL_STATE *p_st, UINT8 set)
-{
- switch(set)
- {
- case XML_SET_NAME:
- p_st->name.p = p_st->p_cur - 1;
- p_st->p_data_bfr = p_st->name.p;
- p_st->name.len = 0;
- break;
- case XML_SET_VALUE:
- p_st->value.p = p_st->p_cur - 1;
- p_st->p_data_bfr = p_st->value.p;
- p_st->value.len = 0;
- break;
- default:
- p_st->p_data_bfr = NULL;
- }
-}
-
-
-/*****************************************************************************
-**
-** Function xml_write_bfr
-**
-** Description
-** Pushes (copies) the character from p_st->next_token to the buffer, if
-** any, that has been set calling xml_set_bfr.
-**
-** Parameters
-** p_st (in/out) : the parser state
-**
-** Returns
-** -
-*****************************************************************************/
-
-static void xml_write_bfr(tXML_MUL_STATE *p_st)
-{
- if (p_st->p_data_bfr)
- {
- if(p_st->p_data_bfr == p_st->name.p)
- p_st->name.len++;
- else
- p_st->value.len++;
- }
-}
-
-
-/*****************************************************************************
-**
-** Function xml_incr_pars_res
-**
-** Description
-** Sets the final parsing result if the new_res provided has
-** higher rank than the current parsing result.
-**
-** Parameters
-** p_st (in/out) : the parser state
-** new_res (in) : the new parsing result
-**
-** Returns
-** -
-*****************************************************************************/
-
-static void xml_incr_pars_res(tXML_MUL_STATE *p_st, tXML_RESULT new_res)
-{
- if (new_res > p_st->pars_res)
- {
- switch(p_st->pars_res)
- {
- /* preserve these error messages */
- case XML_OBJ_ST_EMPTY:
- case XML_NO_MEM: /* no last_bfr.p, and the tXML_MUL_STATE is not in init */
- case XML_NO_PROP: /* run out of tXML_PROP */
- break;
-
- default:
- /*
- case XML_SUCCESS:
- case XML_WARNING:
- case XML_ERR:
- */
- p_st->pars_res = new_res;
- break;
- }
- }
-}
-
-
-/*****************************************************************************
-**
-** Function xml_read_char
-**
-** Description
-*****************************************************************************/
-static void xml_read_char(tXML_MUL_STATE *p_st)
-{
- BOOLEAN get_new = FALSE;
-
- if (p_st->p_cur && p_st->p_cur >= p_st->last_bfr.p && p_st->p_cur < (p_st->last_bfr.p + p_st->used_last_bfr))
- {
- /* left over from previous parse */
- p_st->next_token = *p_st->p_cur;
- if(p_st->next_token == 0)
- {
- /* leftover is done, use the new one */
- p_st->p_cur = p_st->xml_os.p_begin;
- p_st->last_bfr.p[0] = 0;
- p_st->used_last_bfr = 0;
- get_new = TRUE;
- }
- else
- {
- p_st->p_cur++;
- p_st->curr_res = 1;
- }
- }
- else
- {
- if(p_st->p_cur == (p_st->last_bfr.p + p_st->used_last_bfr))
- {
- p_st->used_last_bfr = 0;
- p_st->p_cur = p_st->xml_os.p_begin;
- }
- get_new = TRUE;
- }
-
- if(get_new)
- {
- if(p_st->p_cur && p_st->p_cur < p_st->xml_os.p_end)
- {
- /* use buffer given to XML_Parse */
- p_st->next_token = *p_st->p_cur;
- p_st->p_cur++;
- p_st->curr_res = 1;
- }
- else
- p_st->curr_res = 0;
- }
-
-
-/*
- XML_TRACE_DEBUG4("xml_read_char p_cur: x%x, curr_res:%d, get_new:%d, token:%c",
- p_st->p_cur, p_st->curr_res, get_new, p_st->next_token);
-*/
-}
-
-/*****************************************************************************
-**
-** Function xml_get_next
-**
-** Description
-** Writes the character in p_st->next_token to the current buffer if set.
-** Then the next character is read from the Object Store into
-** p_st->next_token. The first time get_next is called, the current
-** buffer must be NULL, i.e p_st->data_bfr must be NULL.
-**
-** xml_get_next handles end-of-line as specified in the xml spec. It
-** passes, skips or normalises (p.29 in XML spec) white spaces (ws)
-** as specified in the ws_op param. Note, the ws_op applies when
-** getting one (or many characters) from Object Store into the
-** p_st->next_token. It does not apply when pushing the (initial)
-** p_st->next_token to the current buffer.
-**
-** The characters are read one by one from the Object Store.
-** Presently this is not anticipated to cause any problems
-** regarding reading speed. Should it become a problem in the
-** future, a new buffer could be introduced into which a chunk
-** of characters could be put, using one Object Store read call.
-** The get_next function would then get the next character from
-** the new buffer.
-**
-** Parameters
-** p_st (in/out) : the parser state
-** ws_op (in) : the requested white space handling.
-**
-** Returns
-** True if a character was successfully read into p_st->next_token.
-** False otherwise.
-*****************************************************************************/
-
-static BOOLEAN xml_get_next(tXML_MUL_STATE *p_st, tXML_WS_OP ws_op)
-{
- xml_write_bfr(p_st);
- do
- {
- xml_read_char(p_st);
- } while ((ws_op == XML_SKIP_WS) && XML_IS_WS(p_st->next_token) &&
- !XML_EOS(p_st));
-
-
- /* handle end-of-line if any after the do-while above */
-
- if (!XML_EOS(p_st) && (p_st->next_token == 0xA) && p_st->skip_next_nl)
- { /* we have previously found 0xD (cr) and have set the state var
- ** p_st->skip_next_nl,see below
- */
- xml_read_char(p_st);
- }
- p_st->skip_next_nl = FALSE;
-
- if (XML_EOS(p_st))
- {
- p_st->next_token = 0;
- return FALSE;
- }
-
- if (p_st->next_token == 0xD)
- {
- p_st->next_token = 0xA;
- p_st->skip_next_nl = TRUE;
- }
-
- if ((ws_op == XML_NORM_WS) &&
- ((p_st->next_token == 0xA) || (p_st->next_token == 0x9)))
- {
- p_st->next_token = 0x20;
- }
-
- return TRUE;
-}
-
-
-/*****************************************************************************
-**
-** Function xml_find_ch
-**
-** Description
-** Searches for the character given in ch. It starts searching in
-** p_st->next_token and if not found it gets characters from the Object
-** Store until ch is in p_st->next_token.
-**
-** Parameters
-** p_st (in/out) : the parser state
-** ch (in) : the character to search for
-** ws_op (in) : the requested white space handling when getting chars
-**
-** Returns
-** True if the character was found.
-** False otherwise.
-*****************************************************************************/
-
-static BOOLEAN xml_find_ch(tXML_MUL_STATE *p_st, UINT8 ch, tXML_WS_OP ws_op)
-{
- while (!XML_EOS(p_st) && (p_st->next_token != ch))
- xml_get_next(p_st, ws_op);
- return (BOOLEAN) !XML_EOS(p_st);
-}
-
-
-/*****************************************************************************
-**
-** Function xml_find_ch_n
-**
-** Description
-** Same function as xml_find_ch, except that any character in p_str
-** that is found will stop the search.
-**
-** Parameters
-** p_st (in/out) : the parser state
-** p_str (in) : the string containing the characters searched for.
-** Must not be NULL or an empty string.
-**
-** Returns
-** True if any of the characters in p_str was found.
-** Fase otherwise.
-*****************************************************************************/
-
-static BOOLEAN xml_find_ch_n(tXML_MUL_STATE *p_st, const UINT8 *p_str)
-{
- const UINT8 *p_tmp;
-
- while (!XML_EOS(p_st))
- {
- for (p_tmp = p_str; *p_tmp; p_tmp++)
- {
- if (p_st->next_token == *p_tmp)
- return TRUE;
- }
- xml_get_next(p_st, XML_PASS_WS);
- }
- return FALSE;
-}
-
-
-/*****************************************************************************
-**
-** Function xml_find_str
-**
-** Description
-** Searches for p_str (i.e the exact sequence of characters in p_str) in
-** the input from Object Store. The function ends with the character
-** succeeding p_str in the input, (i.e that char is in p_st->next_token
-** upon return) or with XML_EOS.
-**
-** Parameters
-** p_st (in/out) : the parser state
-** p_str (in) : the string to search for and pass by.
-** Must not be NULL or an empty string.
-**
-** Returns
-** True if the string was found.
-** False otherwise.
-*****************************************************************************/
-
-static BOOLEAN xml_find_str(tXML_MUL_STATE *p_st, const UINT8 *p_str)
-{
- const UINT8 *p_tmp;
-
- p_tmp = p_str;
- while (*p_tmp && !XML_EOS(p_st))
- {
- for (p_tmp = p_str; *p_tmp && !XML_EOS(p_st); p_tmp++)
- {
- if (p_st->next_token != *p_tmp)
- break;
- xml_get_next(p_st, XML_PASS_WS);
- }
-
- if ((p_tmp == p_str) && !XML_EOS(p_st))
- {
- xml_get_next(p_st, XML_PASS_WS);
- }
- }
-
- return (BOOLEAN) (*p_tmp == 0);
-}
-
-
-/*****************************************************************************
-**
-** Function xml_consume_str
-**
-** Description
-** Checks for p_str i.e that the first character from p_str is in
-** p_st->next_token and that the successors immediately follows in the
-** Object Store. The p_str must not be last in the Object Store.
-**
-** Parameters
-** p_st (in/out) : the parser state
-** p_str (in) : the string to check if present next and to pass by
-** Must not be NULL.
-**
-** Returns
-** True if the string was found and was not last in the Object Store.
-** False otherwise.
-*****************************************************************************/
-
-static BOOLEAN xml_consume_str(tXML_MUL_STATE *p_st, const UINT8 *p_str)
-{
- do
- {
- if (p_st->next_token != *p_str)
- return FALSE;
- p_str++;
- if (!xml_get_next(p_st, XML_PASS_WS))
- return FALSE;
- } while (*p_str);
- return TRUE;
-}
-
-
-/*****************************************************************************
-**
-** Function xml_resolve_refs
-**
-** Description
-** Resolves predefined entity references (sect. 4.6 in the XML spec)
-** and character references (sect 4.1) that may be found in
-** AttValue and content. (According to the XML spec it may also
-** be in an EntityValue. However EntityValues are in the
-** doctypedecl part which is not supported).
-**
-** The AttValue and content not beginning with a tag, must be
-** stored in the p_st->p_bfr_set->value buffer.
-**
-** Parameters
-** p_st (in/out) : the parser state
-**
-** Returns
-** -
-*****************************************************************************/
-
-static void xml_resolve_refs(tXML_MUL_STATE *p_st)
-{
- UINT8 *p_srch; /* where next search for & starts */
- UINT8 *p_am; /* points to found & */
- UINT8 *p_sc; /* points to found ; and succeeding chars */
- UINT8 *p_start;
- UINT8 *p_tmp;
- UINT32 ch_code;
- UINT32 tmp_code;
- INT8 i;
- BOOLEAN resolved;
- UINT16 len_left;
-
- p_srch = p_st->value.p;
- len_left = p_st->value.len;
- do
- {
- p_start = p_srch;
- p_am = (UINT8*) strchr((char*) p_srch, XML_AM);
- p_sc = p_am ? (UINT8*) strchr((char*) p_am, XML_SC) : NULL;
- /* make sure the ptr does not exceed the end of the value str */
- if(p_sc > (len_left + p_start))
- p_sc = NULL;
-
- if (p_am && p_sc)
- {
- resolved = FALSE;
- p_tmp = p_am + 1;
- *p_sc = 0; /* terminate the ref by replacing ; with 0 */
- if (*p_tmp == XML_PD) /* character ref */
- {
- if (p_tmp[1] == XML_HX)
- *p_tmp = '0';
- else
- {
- for(p_tmp++; *p_tmp == '0'; p_tmp++)
- {
- ;
- }
- }
-
- ch_code = strtoul((char*) p_tmp, NULL, 0);
- /* skip leading zero bytes */
- for (i = 3; (i >= 0) && !(ch_code >> i * 8); i--)
- {
- ;
- }
- p_tmp = p_am;
- while (i >= 0)
- {
- /* mask out one byte and shift it rightmost */
- /* preceding bytes must be zero so shift left first */
- tmp_code = ch_code << ((3-i) * 8);
- *p_tmp = (UINT8) (tmp_code >> 24);
- p_tmp++;
- i--;
- }
- resolved = TRUE;
- }
- else if (p_tmp < p_sc) /* check if predefined ref */
- {
- resolved = TRUE;
- if (strcmp((char*) p_tmp, XML_LT_STR) == 0)
- {
- *p_am = XML_ST;
- p_st->value.len = p_st->value.len - 3; /* remove the length for lt; */
- p_st->p_cur = p_st->p_cur - 3;
- }
- else if (strcmp((char*) p_tmp, XML_GT_STR) == 0)
- {
- *p_am = XML_GT;
- p_st->value.len = p_st->value.len - 3; /* remove the length for gt; */
- p_st->p_cur = p_st->p_cur - 3;
- }
- else if (strcmp((char*) p_tmp, XML_AMP_STR) == 0)
- {
- *p_am = XML_AM;
- p_st->value.len = p_st->value.len - 4; /* remove the length for amp; */
- p_st->p_cur = p_st->p_cur - 4;
- }
- else if (strcmp((char*) p_tmp, XML_APOS_STR) == 0)
- {
- *p_am = XML_SQ;
- p_st->value.len = p_st->value.len - 5; /* remove the length for apos; */
- p_st->p_cur = p_st->p_cur - 5;
- }
- else if (strcmp((char*) p_tmp, XML_QUOT_STR) == 0)
- {
- *p_am = XML_DQ;
- p_st->value.len = p_st->value.len - 5; /* remove the length for quot; */
- p_st->p_cur = p_st->p_cur - 5;
- }
- else
- resolved = FALSE;
- }
-
- if (resolved)
- {
- p_srch = p_tmp; /* will contain char after ; */
- p_sc++;
- while(*p_sc)
- {
- *p_tmp++ = *p_sc++;
- }
- }
- else
- {
- *p_sc = XML_SC; /* restore the ref end */
- p_srch = p_sc + 1;
- }
-
- } /* end if */
- } while (*p_srch && p_am && p_sc);
-}
-
-
-/*****************************************************************************
-**
-** Function xml_remove_trail_ws
-**
-** Description
-** Removes trailing white space from the p_st->p_data_bfr buffer.
-**
-** Parameters
-** p_st (in/out) : the parser state
-**
-** Returns
-** -
-*****************************************************************************/
-
-static void xml_remove_trail_ws(tXML_MUL_STATE *p_st)
-{
- UINT16 xx;
-
- if(p_st->value.p)
- {
- xx = p_st->value.len;
- while(xx && XML_IS_WS(p_st->value.p[xx-1]))
- xx--;
- p_st->value.len = xx;
- }
-
-}
-
-
-/*****************************************************************************
-** Parsing Static Functions
-*****************************************************************************/
-
-
-/*****************************************************************************
-**
-** Function xml_name
-**
-** Description
-** Parses a name and its prefix if any. The prefix and name buffers
-** are set.
-** The functions ends with either white space,
-** XML_EQ, XML_EM or XML_GT in p_st->next_token or with XML_EOS.
-**
-** Parameters
-** p_st (in/out) : the parser state
-**
-** Returns
-** True if no error was found.
-** False otherwise.
-*****************************************************************************/
-
-static BOOLEAN xml_name(tXML_MUL_STATE *p_st)
-{
- BOOLEAN found = FALSE;
-
- p_st->prefix.p = NULL;
- p_st->prefix.len = 0;
- xml_set_bfr(p_st, XML_SET_NAME);
- xml_find_ch_n(p_st, xml_name_srch);
- if (!XML_EOS(p_st) && (p_st->next_token == XML_CO))
- {
- if (p_st->name.len)
- {
- found = TRUE;
- /* p_st->name.len is string size in name buffer, \0 excl.
- */
- p_st->prefix.p = p_st->name.p;
- p_st->prefix.len = p_st->name.len;
- }
- xml_get_next(p_st, XML_PASS_WS);
- xml_set_bfr(p_st, XML_SET_NAME);
- if (!XML_EOS(p_st))
- {
- xml_find_ch_n(p_st, xml_name_srch + 1);
- }
- }
-
- found = (BOOLEAN) (found || p_st->name.len);
- if(found)
- xml_set_bfr(p_st, XML_SET_CLEAR);
- return found;
-}
-
-
-/*****************************************************************************
-**
-** Function xml_attributes
-**
-** Description
-** Parses an attribute list.
-** The functions ends with the XML_GT or XML_EM char or XML_EOS.
-** Error is reported if the attribute list is last in the Object
-** Store.
-** Sends a XML_ATTRIBUTE event in the user callback for each
-** attribute found.
-**
-** Parameters
-** p_st (in/out) : the parser state
-**
-** Returns
-** True if no error was found.
-** False otherwise.
-*****************************************************************************/
-
-static BOOLEAN xml_attributes(tXML_MUL_STATE *p_st)
-{
- BOOLEAN cb_ret = TRUE;
- UINT8 q_ch;
-
- XML_TRACE_DEBUG1("[xml_parse] xml_attributes: res= %d", p_st->pars_res);
-
- while ( cb_ret)
- {
- /* if this is a white space, then the next character is read from the
- Object Store into p_st->next_token */
- if( XML_IS_WS(p_st->next_token) )
- {
- if (!xml_get_next(p_st, XML_SKIP_WS))
- return FALSE;
- }
-
- if (p_st->next_token == XML_EQ)
- return FALSE;
-
- if ((p_st->next_token == XML_GT) || (p_st->next_token == XML_EM))
- return TRUE;
- if (!xml_name(p_st) || XML_EOS(p_st))
- {
- return FALSE;
- }
- if(XML_IS_WS(p_st->next_token))
- {
- if (!xml_get_next(p_st, XML_SKIP_WS))
- return FALSE;
- }
-
- if (p_st->next_token != XML_EQ)
- return FALSE;
-
- if (!xml_get_next(p_st, XML_SKIP_WS))
- return FALSE;
-
- if ((p_st->next_token != XML_SQ) && (p_st->next_token != XML_DQ))
- return FALSE;
-
- q_ch = p_st->next_token;
- if (!xml_get_next(p_st, XML_PASS_WS))
- return FALSE;
-
-
- xml_set_bfr(p_st, XML_SET_VALUE);
- if (!xml_find_ch(p_st, q_ch, XML_NORM_WS))
- {
- return FALSE;
- }
-
- xml_set_bfr(p_st, XML_SET_CLEAR);
- xml_resolve_refs(p_st);
-
- p_st->event_data.attr.prefix.p = p_st->prefix.p;
- p_st->event_data.attr.prefix.len = p_st->prefix.len;
- p_st->event_data.attr.name.p = p_st->name.p;
- p_st->event_data.attr.name.len = p_st->name.len;
- p_st->event_data.attr.value.p = p_st->value.p;
- p_st->event_data.attr.value.len = p_st->value.len;
- p_st->value.len = 0;
- cb_ret = p_st->cback(XML_ATTRIBUTE, &(p_st->event_data), p_st->p_usr_data);
- /* chk cback return */
- if(cb_ret == FALSE)
- {
- xml_incr_pars_res(p_st, XML_NO_PROP);
- return FALSE;
- }
-
- if (!xml_get_next(p_st, XML_PASS_WS))
- return FALSE;
- }
-
- return (BOOLEAN)
- ((p_st->next_token == XML_GT) || (p_st->next_token == XML_EM));
-}
-
-
-/*****************************************************************************
-**
-** Function xml_elems
-**
-** Description
-** Parses all elements with all their content.This function is not a
-** one-to-one mapped implementation of one production from the XML spec.
-** Instead it uses a simplified iterative (as opposed to recursive)
-** approach when parsing both the element and content productions.
-**
-** When a parsing error is found, this function tries to recover by
-** searching for the next element (tag).
-**
-** When char data is found, the function sends the XML_CHARDATA event in
-** the user callback.
-**
-** Other static functions with production names, start their parsing
-** from the first character in their production. They might check
-** that the first character (token) in the production matches
-** p_st->next_token, alternatively they can just get rid of the first
-** char in the production by calling get_next_ch. The exceptions to this
-** are the xml_qm_elem, xml_ex_elem, xml_etag_elem and the xml_tag_elem
-** functions which starts with the XML_QM, XML_EX, XML_EM and the first
-** char in the tag name, respectively.
-**
-** Parameters
-** p_st (in/out) : the parser state
-** prev_ok (in) : if parsing done before calling this function was
-** ok. If not, the functions starts with recovering.
-**
-** Returns
-** True if parsing was successful possibly with successful recoveries.
-** False if an error was found from which recovery failed (XML_EOS).
-*****************************************************************************/
-
-static BOOLEAN xml_elems(tXML_MUL_STATE *p_st, BOOLEAN prev_ok)
-{
- BOOLEAN tag_found;
- BOOLEAN cb_ret = TRUE;
-
- while (!XML_EOS(p_st) && prev_ok)
- {
- /* remove leading ws even if char data */
- if (XML_IS_WS(p_st->next_token))
- {
- if (!xml_get_next(p_st, XML_SKIP_WS))
- return TRUE;
- }
-
- tag_found = (BOOLEAN) (p_st->next_token == XML_ST);
- if (!tag_found)
- {
- xml_set_bfr(p_st, XML_SET_VALUE);
- tag_found = xml_find_ch(p_st, XML_ST, XML_PASS_WS);
-
- xml_remove_trail_ws(p_st);
- if (p_st->value.len > 0)
- {
- xml_resolve_refs(p_st);
- p_st->event_data.ch_data.value.p = p_st->value.p;
- p_st->event_data.ch_data.value.len = p_st->value.len;
- p_st->event_data.ch_data.last = TRUE;
- p_st->value.len = 0;
- cb_ret = p_st->cback(XML_CHARDATA, &(p_st->event_data), p_st->p_usr_data);
- /* chk cback return */
- if(cb_ret == FALSE)
- {
- xml_incr_pars_res(p_st, XML_NO_PROP);
- return FALSE;
- }
-
- }
- xml_set_bfr(p_st, XML_SET_CLEAR);
-
- if (!tag_found)
- return prev_ok;
- }
- else
- {
- p_st->p_last_stm = p_st->p_cur - 1;
-
- if (p_st->p_cur)
- p_st->p_copy = p_st->p_last_stm;
-
- p_st->cback(XML_TOP, &(p_st->event_data), p_st->p_usr_data);
- }
-
- /* tag was found */
- if (!xml_get_next(p_st, XML_PASS_WS))
- return FALSE;
-
-
- if (p_st->next_token == XML_QM)
- prev_ok = xml_qm_elem(p_st);
- else if (p_st->next_token == XML_EX)
- {
- prev_ok = xml_ex_elem(p_st, FALSE);
- }
- else if (p_st->next_token == XML_EM)
- {
- prev_ok = xml_etag_elem(p_st);
- }
- else
- prev_ok = xml_tag_elem(p_st);
-
-
-
- if (!prev_ok)
- xml_incr_pars_res(p_st, XML_ERR);
- }
-
- XML_TRACE_DEBUG1("xml_elems prev_ok:%d", prev_ok);
- return prev_ok;
-}
-
-
-/*****************************************************************************
-**
-** Function xml_qm_elem
-**
-** Description
-** Recognises all productions starting with "<?". That is PI and XML decl.
-** These productions are skipped and XML_WARNING is set.
-** The function starts with the XML_QM as the first char (is in
-** p_st->next_token).It ends with the XML_GT successor (is in
-** p_st->next_token) or XML_EOS.
-**
-** Parameters
-** p_st (in/out) : the parser state
-**
-** Returns
-** True if no error was found trying to recognise the start and end of
-** the productions. False otherwise.
-*****************************************************************************/
-
-static BOOLEAN xml_qm_elem(tXML_MUL_STATE *p_st)
-{
- if (!xml_get_next(p_st, XML_PASS_WS))
- return FALSE;
- if (!xml_find_str(p_st, (UINT8*) XML_QTAG_END_STR))
- return FALSE;
- xml_incr_pars_res(p_st, XML_WARNING);
- return TRUE;
-}
-
-
-/*****************************************************************************
-**
-** Function xml_ex_elem
-**
-** Description
-** Handles all productions starting with "<!". They are Comments, CDSect
-** doctypedecl and markupdecl. All are skipped. However, the inpar
-** prolog must be set for the function to try to detect the doctypedecl
-** and markupdecl beginning.
-**
-** The function starts with the XML_EX as the first char.
-** The function ends with XML_EOS or the char succeeding XML_GT,
-** except for doctypedecl and marcupdecl which ends with the next XM_TAG.
-**
-** Parameters
-** p_st (in/out) : the parser state
-** prolog (in) : should be set if in prolog in which case the function
-** tries to detect (allows) the beginning of doctypedecl
-** and markupdecl.
-** Returns
-** True if no error was found trying to recognise the start and end of
-** the productions. False otherwise.
-*****************************************************************************/
-
-static BOOLEAN xml_ex_elem(tXML_MUL_STATE *p_st, BOOLEAN prolog)
-{
- UINT8 q_ch;
-
- if (!xml_get_next(p_st, XML_PASS_WS))
- return FALSE;
-
- if (p_st->next_token == XML_HY) /* comment */
- {
- if (!xml_consume_str(p_st, (UINT8*) XML_COMM_STR))
- return FALSE;
-
- if (!xml_find_str(p_st, (UINT8*) XML_COMM_END_STR))
- return FALSE;
- }
- else if (p_st->next_token == XML_LB) /* CDSect */
- {
- if (!xml_consume_str(p_st, (UINT8*) XML_CDS_STR))
- return FALSE;
-
- if (!xml_find_str(p_st, (UINT8*) XML_CDS_END_STR))
- return FALSE;
-
- xml_incr_pars_res(p_st, XML_WARNING);
- }
- else if (prolog) /* doctypedecl or markupdecl */
- {
- do
- {
- if (!xml_find_ch_n(p_st, (UINT8*) XML_DOCT_STR))
- return FALSE;
-
- if ((p_st->next_token == XML_SQ) || (p_st->next_token == XML_DQ))
- {
- q_ch = p_st->next_token;
- if (!xml_get_next(p_st, XML_PASS_WS))
- return FALSE;
-
- if (!xml_find_ch(p_st, q_ch, XML_PASS_WS))
- return FALSE;
-
- xml_get_next(p_st, XML_PASS_WS);
- }
- } while (!XML_EOS(p_st) && (p_st->next_token != XML_ST));
-
- xml_incr_pars_res(p_st, XML_WARNING);
- }
- else /* error */
- {
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*****************************************************************************
-**
-** Function xml_tag_elem
-**
-** Description
-** Parses a tag element. The function starts with the char succeeding the
-** XML_ST char.
-** The functions ends with the char succeeding the XML_GT char or
-** with XML_EOS.
-** Sends the XML_TAG and the XML_TAG_END events in a callback each.
-**
-** Parameters
-** p_st (in/out) : the parser state
-**
-** Returns
-** True if no error was found.
-** False otherwise.
-*****************************************************************************/
-
-static BOOLEAN xml_tag_elem(tXML_MUL_STATE *p_st)
-{
- BOOLEAN cb_ret = TRUE;
-
- if (!xml_name(p_st))
- return FALSE;
-
- p_st->event_data.tag.prefix.p = p_st->prefix.p;
- p_st->event_data.tag.name.p = p_st->name.p;
- p_st->event_data.tag.prefix.len = p_st->prefix.len;
- p_st->event_data.tag.name.len = p_st->name.len;
- p_st->event_data.tag.p_last_stm = p_st->p_last_stm;
- cb_ret = p_st->cback(XML_TAG, &(p_st->event_data), p_st->p_usr_data);
- if(cb_ret == FALSE)
- {
- xml_incr_pars_res(p_st, XML_NO_PROP);
- return FALSE;
- }
-
- /* chk cback return */
-
- if (XML_EOS(p_st))
- return FALSE;
-
- if (XML_IS_WS(p_st->next_token))
- {
- if (!xml_attributes(p_st))
- return FALSE;
- }
-
- p_st->event_data.empty_elem.end = (BOOLEAN) (p_st->next_token == XML_EM);
- if (p_st->event_data.empty_elem.end)
- {
- if (!xml_get_next(p_st, XML_PASS_WS))
- return FALSE;
- }
-
- if (p_st->next_token != XML_GT)
- return FALSE;
-
- xml_get_next(p_st, XML_PASS_WS);
-
- cb_ret = p_st->cback(XML_TAG_END, &(p_st->event_data), p_st->p_usr_data);
-
-
- if(cb_ret == FALSE)
- {
- xml_incr_pars_res(p_st, XML_NO_PROP);
- return FALSE;
- }
-
- p_st->p_copy = p_st->p_cur - 1;
- p_st->cback(XML_TOP, &(p_st->event_data), p_st->p_usr_data);
- /* chk cback return */
-
- return TRUE;
-}
-
-
-/*****************************************************************************
-**
-** Function xml_etag_elem
-**
-** Description
-** Parses an end tag element. The function starts with the XML_EM char.
-** The functions ends with the char succeeding the XML_GT char or
-** with XML_EOS. Sends the XML_ETAG event in the user callback.
-**
-** Parameters
-** p_st (in/out) : the parser state
-**
-** Returns
-** True if no error was found.
-** False otherwise.
-*****************************************************************************/
-
-static BOOLEAN xml_etag_elem(tXML_MUL_STATE *p_st)
-{
- BOOLEAN cb_ret = TRUE;
-
- if (!xml_get_next(p_st, XML_PASS_WS))
- return FALSE;
-
- if (!xml_name(p_st))
- return FALSE;
-
- p_st->event_data.etag.prefix.p = p_st->prefix.p;
- p_st->event_data.etag.name.p = p_st->name.p;
- p_st->event_data.etag.name.len = p_st->name.len;
- p_st->event_data.etag.prefix.len = p_st->prefix.len;
- cb_ret = p_st->cback(XML_ETAG, &(p_st->event_data), p_st->p_usr_data);
- if(cb_ret == FALSE)
- {
- xml_incr_pars_res(p_st, XML_NO_PROP);
- return FALSE;
- }
-
- p_st->p_copy = (p_st->prefix.p) ? p_st->prefix.p - 2: p_st->name.p - 2;
- p_st->cback(XML_TOP, &(p_st->event_data), p_st->p_usr_data);
-
- /* chk cback return */
-
- if (XML_EOS(p_st))
- return FALSE;
-
- if (XML_IS_WS(p_st->next_token))
- if (!xml_get_next(p_st, XML_SKIP_WS))
- return FALSE;
-
- if (p_st->next_token != XML_GT)
- return FALSE;
-
- xml_get_next(p_st, XML_PASS_WS);
-
- return TRUE;
-}
-
diff --git a/stack/xml/xml_vlist.c b/stack/xml/xml_vlist.c
deleted file mode 100644
index 2800c12..0000000
--- a/stack/xml/xml_vlist.c
+++ /dev/null
@@ -1,873 +0,0 @@
-/******************************************************************************
- **
- ** Name: xml_vlist.c
- **
- ** Description: This module contains xml parser of VCard listing
- **
- ** Copyright (c) 2004-2011, Broadcom Corporation, All Rights Reserved.
- ** Broadcom Bluetooth Core. Proprietary and confidential.
- ******************************************************************************/
-
-#include "bt_target.h"
-#include "gki.h"
-#include "xml_vlist_api.h"
-
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef VLIST_DEBUG_XML
-#define VLIST_DEBUG_XML FALSE
-#endif
-#define VLIST_DEBUG_LEN 50
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
-#define XML_TRACE_DEBUG0(m) {BT_TRACE_0(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m);}
-#define XML_TRACE_DEBUG1(m,p1) {BT_TRACE_1(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1);}
-#define XML_TRACE_DEBUG2(m,p1,p2) {BT_TRACE_2(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2);}
-#define XML_TRACE_DEBUG3(m,p1,p2,p3) {BT_TRACE_3(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3);}
-#define XML_TRACE_DEBUG4(m,p1,p2,p3,p4) {BT_TRACE_4(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);}
-#define XML_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {BT_TRACE_5(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);}
-#define XML_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {BT_TRACE_6(TRACE_LAYER_FTP, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);}
-#else
-#define XML_TRACE_DEBUG0(m)
-#define XML_TRACE_DEBUG1(m,p1)
-#define XML_TRACE_DEBUG2(m,p1,p2)
-#define XML_TRACE_DEBUG3(m,p1,p2,p3)
-#define XML_TRACE_DEBUG4(m,p1,p2,p3,p4)
-#define XML_TRACE_DEBUG5(m,p1,p2,p3,p4,p5)
-#define XML_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6)
-#endif
-
-
-/*****************************************************************************
-** Constants
-*****************************************************************************/
-const UINT8 xml_vlist_elem[] = "vCard-listing";/* "vCard-listing" */
-const UINT8 xml_card_elem[] = "card"; /* "card" */
-const UINT8 xml_handle_attr[] = "handle"; /* "handle" */
-const UINT8 xml_vlist_name_attr[] = "name"; /* "name" */
-const UINT8 xml_vlist_version_attr[] = "version"; /* "version" */
-const UINT8 xml_vlist_unknown[] = "unknown"; /* "unknown" */
-
-
-#define XML_VLIST_ELEM_ID 0x01
-#define XML_CARD_ELEM_ID 0x02
-#define XML_MAX_OBJ_TAG_ID XML_VLIST_ELEM_ID
-#define XML_HANDLE_ATTR_ID 0x03
-#define XML_NAME_ATTR_ID 0x04
-#define XML_VERSION_ATTR_ID 0x05
-#define XML_XP_UNKNOWN_ID 0x06
-#define XML_VLIST_MAX_ID 0x07 /* keep in sync with above */
-#define XML_VLIST_TAG_END_ID 0x07 /* closing tag found end=true */
-#define XML_VLIST_PAUSE_ID 0x08 /* closing tag found end=false */
-
-
-#define XML_VLIST_TTBL_SIZE (XML_VLIST_MAX_ID+1)
-
-/*****************************************************************************
-** Type Definitions
-*****************************************************************************/
-
-typedef struct
-{
- const UINT8 *p_name;
- UINT8 len;
-} tXML_VLIST_TTBL_ELEM;
-
-typedef tXML_VLIST_TTBL_ELEM tXML_VLIST_TTBL[]; /* Tag Table */
-
-
-static const tXML_VLIST_TTBL_ELEM xml_vlist_ttbl[XML_VLIST_TTBL_SIZE] =
-{ /* index (VLIST_XP_*_ID) & name */
- {(UINT8*) "", XML_VLIST_MAX_ID-1}, /* \x00 Number of elements in array */
- {xml_vlist_elem, 13}, /* \x01 vcard listing */
- {xml_card_elem, 4}, /* \x02 card */
- {xml_handle_attr, 6}, /* \x03 handle */
- {xml_vlist_name_attr, 4}, /* \x04 name */
- {xml_vlist_version_attr, 7}, /* \x05 version */
- {xml_vlist_unknown, 7}, /* \x06 unknown */
-};
-
-#define XML_VLIST_PTBL_SIZE 0x03
-typedef UINT8 * tXML_VLIST_PTBL_ELEM;
-
-static const tXML_VLIST_PTBL_ELEM xml_vlist_ptbl[XML_VLIST_PTBL_SIZE] =
-{
- (UINT8*) "\x01", /* \x00 */
- (UINT8*) "\x05\x02", /* \x01 Vcard Listing */
- (UINT8*) "\x03\x04" /* \x02 Card */
-};
-
-
-#if (VLIST_DEBUG_XML == TRUE)
-void xml_vlist_debug_str(tXML_STR *p_str, UINT8 *p_buf)
-{
- int dbg_len;
- if ( (p_str == NULL) || (NULL==p_str->p))
- BCM_STRCPY_S( (char *)p_buf, VLIST_DEBUG_LEN, "(NULL)" );
- else
- {
- dbg_len = p_str->len;
- if ( dbg_len >= VLIST_DEBUG_LEN)
- dbg_len = VLIST_DEBUG_LEN - 1;
- BCM_STRNCPY_S( (char *)p_buf, VLIST_DEBUG_LEN, (char *)p_str->p, dbg_len);
- p_buf[dbg_len] = 0;
- }
-}
-
-#else
-#define xml_vlist_debug_str(p_str, p_buf)
-#endif
-
-/*****************************************************************************
- ** Function xml_vlist_proc_tag
- ** Description
- ** Parameters -
- ** Returns
- *****************************************************************************/
-static UINT8 xml_vlist_proc_tag( tXML_VLIST_STATE *p_st, tXML_STR *p_name, tXML_STACK *p_stk)
-{
- const UINT8 *p_stag; /* sub tag pointer */
- UINT8 curr = p_stk->stack[p_stk->top];
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- UINT8 dbg_name[VLIST_DEBUG_LEN];
-#endif
-
- if (curr < XML_VLIST_PTBL_SIZE)
- {
- /* Iterate over allowed sub-tags for the current tag. */
- for (p_stag = xml_vlist_ptbl[curr]; p_stag && *p_stag ; p_stag++)
- {
- if (*p_stag >= XML_VLIST_TTBL_SIZE)
- continue;
- if(p_name->len == xml_vlist_ttbl[*p_stag].len &&
- strncmp((char *)p_name->p, (char *)xml_vlist_ttbl[*p_stag].p_name, p_name->len) == 0)
- {
- p_stk->top++;
- p_stk->stack[p_stk->top] = *p_stag;
-
- return *p_stag;
- }
- }
- }
-
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- xml_vlist_debug_str(p_name, dbg_name);
- XML_TRACE_DEBUG1("xml_vlist_proc_tag: bad name:%s", dbg_name );
-#endif
-
- return XML_XP_UNKNOWN_ID;
-}
-
-
-/*****************************************************************************
- ** Function xml_vlist_proc_attr
- ** Description
- ** Parameters -
- ** Returns
- *****************************************************************************/
-static UINT8 xml_vlist_proc_attr(tXML_VLIST_STATE *p_st, tXML_STR *p_name, tXML_STACK *p_stk)
-{
- const UINT8 *p_stag; /* sub tag pointer */
- UINT8 curr = p_stk->stack[p_stk->top];
-#if (VLIST_DEBUG_XML == TRUE)
- UINT8 dbg_name[VLIST_DEBUG_LEN];
-#endif
-
- if (curr < XML_VLIST_PTBL_SIZE)
- {
- /* Iterate over allowed sub-tags for the current tag. */
- for (p_stag = xml_vlist_ptbl[curr]; p_stag && *p_stag; p_stag++)
- {
- if (*p_stag >= XML_VLIST_TTBL_SIZE)
- continue;
- if(p_name->len == xml_vlist_ttbl[*p_stag].len &&
- strncmp((char *)p_name->p, (char *)xml_vlist_ttbl[*p_stag].p_name, p_name->len) == 0)
- {
- p_stk->top++;
- p_stk->stack[p_stk->top] = *p_stag;
-
- return *p_stag;
- }
- }
- }
-
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- xml_vlist_debug_str(p_name, dbg_name);
- XML_TRACE_DEBUG1("xml_vlist_proc_attr: bad name:%s", dbg_name);
-#endif
- return XML_XP_UNKNOWN_ID;
-}
-
-
-/*****************************************************************************
- ** Function xml_vlist_find_ch_n_copy
- ** Description copy any chacter till one char in p_str. Any char in p_str
- ** will stop copy pointed by p_begin
- ** Parameters
- ** Returns
- *****************************************************************************/
-static void xml_vlist_find_ch_n_copy( tXML_MCOPY *p_copy )
-{
- const UINT8 *p_tmp;
- const UINT8 *p_str = (UINT8 *)">"; /* was: ":=/> \t\n\r". i think we should copy till
- closing flag */
- unsigned int last = XML_VLIST_CARRY_OVER_LEN; /* maximum carry over len we can support */
- UINT8 *p_last = p_copy->last.p + p_copy->last.len - 1; /* point to the last char of carry
- over buffer */
- BOOLEAN found = FALSE;
-
- /* check if the last char in p_last is in p_str */
- for (p_tmp = p_str; *p_tmp; p_tmp++)
- {
- if (*p_last == *p_tmp)
- {
- found = TRUE;
- break;
- }
- } /* for */
-
- if (found == FALSE)
- {
- /* if not in p_str, move chars from p_begin to p_last
- * until reached last_len or any char in p_str */
- p_last++;
- last -= p_copy->last.len; /* calculate the maximum number of chars we can copy */
- while (*(p_copy->p_begin) && last) /* rl: not sure that this buffer is termninated by a 0 */
- {
- /* copy from source (new buffer) to carry over. adjust only carry over ptr. */
- *p_last++ = *p_copy->p_begin;
- last--;
- for (p_tmp = p_str; *p_tmp; p_tmp++)
- {
- if (*p_copy->p_begin == *p_tmp)
- {
- p_copy->p_begin++; /* adjust pointer to point to next char to read */
- /* calculate new length of carry over buffer contents */
- p_copy->last.len = XML_VLIST_CARRY_OVER_LEN-last;
- *p_last = 0; /* NULL terminate p_last. rl: not really neccessary. */
- return;
- }
- } /* for */
- p_copy->p_begin++; /* update now to next char. this way abort char is also copied */
- } /* while */
- } /* !found */
-}
-
-/*****************************************************************************
-** Function xml_vlist_cback
-** Description
-**
-** Parameters
-** Returns
-*****************************************************************************/
-static BOOLEAN xml_vlist_cback( tXML_EVENT event, void *p_event_data, void *p_usr_data)
-{
- tXML_MEVT_DATA *p_ed = (tXML_MEVT_DATA*) p_event_data;
- tXML_VLIST_STATE *p_st = (tXML_VLIST_STATE *) p_usr_data;
- tXML_PROP *p_cp = &p_st->p_prop[p_st->prop_index];
- BOOLEAN ret = TRUE;
- UINT8 next; /* next element */
- UINT8 curr = p_ed->stack.stack[p_ed->stack.top]; /* current element */
-#if (VLIST_DEBUG_XML == TRUE)
- UINT8 dbg_name[VLIST_DEBUG_LEN];
- UINT8 dbg_prefix[VLIST_DEBUG_LEN];
- UINT8 dbg_value[VLIST_DEBUG_LEN];
-#endif
-
-#if (VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG1("xml_vlist_cback:%d", event);
-#endif
-
- switch (event)
- {
- case XML_TAG : /* <tag-name */
- next = xml_vlist_proc_tag(p_st, &p_ed->tag.name, &p_ed->stack);
-#if (VLIST_DEBUG_XML == TRUE)
- xml_vlist_debug_str(&p_ed->tag.name, dbg_name);
- xml_vlist_debug_str(&p_ed->tag.prefix, dbg_prefix);
- XML_TRACE_DEBUG2("XML_TAG: p:%s, name:%s", dbg_prefix, dbg_name);
- XML_TRACE_DEBUG2("top:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
-
-#endif
- if (next != 0)
- {
- if (next <= XML_MAX_OBJ_TAG_ID)
- p_st->obj = next;
-
- if(p_st->prop_index <p_st->max_num_prop)
- {
- p_cp->name = next;
- p_cp->p_data = NULL;
- p_cp->len = 0;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- }
- else
- ret = FALSE;
- }
- break;
-
- case XML_ATTRIBUTE : /* attr-name="attr-value" */
- curr = xml_vlist_proc_attr(p_st, &p_ed->attr.name, &p_ed->stack);
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- xml_vlist_debug_str(&p_ed->attr.name, dbg_name);
- xml_vlist_debug_str(&p_ed->attr.prefix, dbg_prefix);
- xml_vlist_debug_str(&p_ed->attr.value, dbg_value);
- XML_TRACE_DEBUG4("[xml vlist] XML_ATTRIBUTE: p:%s, name:%s, v:%s, curr:%x",
- dbg_prefix, dbg_name, dbg_value, curr);
-#endif
- if (curr != 0)
- {
- if(p_st->prop_index <p_st->max_num_prop)
- {
- p_cp->name = curr;
- p_cp->p_data = p_ed->attr.value.p;
- p_cp->len = p_ed->attr.value.len;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- }
- else
- ret = FALSE;
- p_ed->stack.top--;
- }
- break;
-
- case XML_CHARDATA :
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- xml_vlist_debug_str(&p_ed->ch_data.value, dbg_value);
- XML_TRACE_DEBUG2("XML_CHARDATA: v:%s, last:%d", dbg_value, p_ed->ch_data.last);
-#endif
- break;
-
- case XML_ETAG : /* </tag-name> */
- if(p_ed->stack.top > 0)
- {
- p_ed->stack.stack[p_ed->stack.top] = 0;
- p_ed->stack.top--;
- p_st->ended = (BOOLEAN) (p_ed->stack.top == 0);
- }
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- xml_vlist_debug_str(&p_ed->etag.name, dbg_name);
- xml_vlist_debug_str(&p_ed->etag.prefix, dbg_prefix);
- XML_TRACE_DEBUG2("[xml vlist] XML_ETAG: p:%s, name:%s", dbg_prefix, dbg_name);
- XML_TRACE_DEBUG2("[xml vlist] top:x%x, stk:x%x", p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top]);
-#endif
- break;
-
- case XML_TAG_END: /* /> */
- curr = p_ed->stack.stack[p_ed->stack.top];
-
- if(p_st->prop_index <p_st->max_num_prop)
- {
- if(p_ed->empty_elem.end)
- p_cp->name = XML_VLIST_TAG_END_ID;
- else
- p_cp->name = XML_VLIST_PAUSE_ID;
- p_cp->p_data = NULL;
- p_cp->len = 0;
- p_cp->level = p_ed->stack.top;
- p_st->prop_index++;
- if(p_ed->empty_elem.end && p_ed->stack.top > 0)
- {
- p_ed->stack.top--;
- }
- }
- else
- ret = FALSE;
-
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG4("[xml vlist] XML_TAG_END: %d, top:x%x, stk:x%x, curr:x%x",
- p_ed->empty_elem.end, p_ed->stack.top, p_ed->stack.stack[p_ed->stack.top], curr);
-#endif
- break;
-
- case XML_PARTIAL:
- if(p_st->p_prop[p_st->prop_index-1].name != XML_VLIST_TAG_END_ID)
- {
- p_ed->stack.top--;
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0("[xml vlist] adjust due to XML_PARTIAL");
-#endif
- }
- break;
-
- case XML_COPY:
- xml_vlist_find_ch_n_copy( &p_ed->copy );
- XML_TRACE_DEBUG1("[xml vlist] XML_COPY: %s", p_ed->copy.last.p);
- break;
-
- default :
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG1("[xml vlist] XML event: %d", event);
-#endif
- break;
- }
-
- return ret;
-}
-
-/**********************************************************************************
-** Function xml_vlist_int_fill_attribute
-** Description fill in file/folder structure.
-**
-** Parameters
-** Returns xx: > 0 : number of properties scanned, folder entry is added
-** = 0 : no end tag found, carry over to next parse
-** = -1: no dst_resource avaibale, all prop left to next parse
-** = -2: exceed max entry, no folder entry added
-**********************************************************************************/
-static INT16 xml_vlist_int_fill_attribute(tXML_VLIST_STATE * p_xud,
- tXML_PROP *p_prop,
- UINT16 *num_prop,
- UINT8 **p_dst_data,
- UINT16 *dst_len)
-{
- INT16 xx;
- UINT16 len;
- BOOLEAN end = FALSE;
- tXML_PROP *cur_prop = p_prop;
- UINT8 *p_cur_offset = *p_dst_data;
-
- for(xx=0; (xx < *num_prop) && !end; xx++, cur_prop++)
- {
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG5( "[xml vlist] fill: num_prop:%d, name id: x%x, p_prop: x%x, p_data:%s, len: %d",
- (*num_prop-xx) , cur_prop->name, cur_prop, cur_prop->p_data, cur_prop->len);
-#endif
- switch (cur_prop->name)
- {
- case XML_NAME_ATTR_ID:
- if ( p_xud->current_entry < p_xud->max_entry )
- {
- /* calculate the max length to copy */
- len = (cur_prop->len<=p_xud->max_name_len) ? cur_prop->len:p_xud->max_name_len;
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_xud->p_entry[p_xud->current_entry].name = p_cur_offset;
- p_xud->p_entry[p_xud->current_entry].name_len = len;
-
- memcpy( (void *)p_xud->p_entry[p_xud->current_entry].name,
- (const void *)cur_prop->p_data,
- len );
- p_xud->p_entry[p_xud->current_entry].name[len] = 0; /* null terminate string */
- p_cur_offset += (len + 1);
- *dst_len = *dst_len - (len + 1) ;
-
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG3("[xml vlist]: catch filename [%s] len [%d] dst_len left:[%d]",
- p_xud->p_entry[p_xud->current_entry].name,
- len,
- *dst_len);
-#endif
- }
- else /* run out of dst buffer resource */
- {
- xx = -1;
- return xx;
- }
- }
- else /* exceed max entry */
- return -2;
-
- break;
-
- case XML_HANDLE_ATTR_ID:
- if ( p_xud->current_entry < p_xud->max_entry )
- {
- /* as long as we do not exceed the number of entries in the ouput array copy name */
- /* calculate the max length to copy */
- len = (cur_prop->len<=p_xud->max_name_len) ? cur_prop->len:p_xud->max_name_len;
- if ((*dst_len - len) > 0) /* enough data buffer available? */
- {
- p_xud->p_entry[p_xud->current_entry].handle = p_cur_offset;
- p_xud->p_entry[p_xud->current_entry].handle_len = len;
-
- memcpy( (void *)p_xud->p_entry[p_xud->current_entry].handle,
- (const void *)cur_prop->p_data,
- len );
- p_xud->p_entry[p_xud->current_entry].handle[len] = 0; /* null terminate string */
- p_cur_offset += (len + 1);
- *dst_len = *dst_len - (len + 1) ;
-
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG3("[xml vlist]: catch filename [%s] len [%d] dst_len left:[%d]",
- p_xud->p_entry[p_xud->current_entry].handle,
- len,
- *dst_len);
-#endif
- }
- else /* run out of dst buffer resource */
- {
- xx = -1;
- return xx;
- }
- }
- else /* exceed max entry */
- return -2;
-
- break;
-
- case XML_VLIST_TAG_END_ID:
- /* -------------------- CUSTOMER SPECIFIC ---------------------- */
- p_xud->current_entry++; /* increment only when end tag (/>) found */
-
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG1( "[xml vlist] FOUND END TAG: 0x%x", cur_prop->name );
-#endif
-
- end = TRUE;
- break;
-
- default:
- XML_TRACE_DEBUG1("[xml vlist] unknown attrib: %d", cur_prop->name );
- break;
- }
- }
-#if (VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG2("[xml vlist] fill_attribute: end:%d, xx:%d", end, xx);
-#endif
-#if 0
- /* if end tag not found -> split over two buffers. but parser will still show rest of
- found properties. so return still found properties. */
- if(end == FALSE)
- xx = 0;
-#endif
-
- /* keep track of current data buffer offset */
- *p_dst_data = p_cur_offset;
- return xx;
-}
-
-
-/**********************************************************************************
-** Function xml_vlist_int_fill_evt_data
-**
-** Description fill in file/folder structure.
-**
-** Parameters
-** Returns
-**********************************************************************************/
-static tXML_VLIST_RES xml_vlist_int_fill_evt_data( UINT8 op,
- void *p_evt_data,
- tXML_PROP **p_prop,
- UINT16 *num_prop,
- UINT8 **p_dst_data,
- UINT16 *dst_len)
-{
- tXML_VLIST_STATE *p_xud = (tXML_VLIST_STATE *)p_evt_data;
- INT16 inc_prop;
- UINT8 prop_name; /* Property name. */
- tXML_PROP *cur_prop = *p_prop;
- UINT8 *p_cur_offset = *p_dst_data;
-
- tXML_VLIST_RES x_res = XML_VLIST_OK;
- BOOLEAN x_no_res = FALSE; /* guard dest buffer resource */
-
-
- if ( op == 0 || op > XML_MAX_OBJ_TAG_ID || *num_prop == 0)
- return XML_VLIST_ERROR;
-
-#if VLIST_DEBUG_XML
- XML_TRACE_DEBUG2( "[xml vlist] xml_vlist_int_fill_evt_data op:%d, num_prop:%d",
- op, *num_prop);
-#endif
-
-
-
- while ( *num_prop > 0 && !x_no_res )
- {
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG2("end_prop:%d, name id: x%x", *num_prop, cur_prop->name);
-#endif
- prop_name = cur_prop->name;
- cur_prop++;
- *num_prop -= 1;
-
-
- switch( prop_name )
- {
- case XML_VLIST_ELEM_ID:
- /* skip over version attribute which should always be 1.0. this is the top level */
- break;
-
- case XML_CARD_ELEM_ID:
- inc_prop = xml_vlist_int_fill_attribute(p_xud,
- cur_prop,
- num_prop,
- &p_cur_offset,
- dst_len);
- if (inc_prop == -1) /* no dst_buf available */
- {
- /* backup one more prop to obtain the skipped folder/file entry header */
- cur_prop --;
- *num_prop += 1;
-
- x_res = XML_VLIST_DST_NO_RES;
- x_no_res = TRUE;
- }
- else if (inc_prop == -2) /* exceed max entry */
- {
- x_no_res = TRUE;
- x_res = XML_VLIST_OUT_FULL;
- }
- else /* found folder entry */
- {
- cur_prop += inc_prop;
- *num_prop -= inc_prop;
- }
- break;
-
-
- case XML_VLIST_PAUSE_ID:
-
-#if (VLIST_DEBUG_XML==TRUE)
- XML_TRACE_DEBUG0( "[xml vlist] xml_vlist_int_fill_evt_data(): XML_VLIST_PAUSE_ID" );
-#endif
- break;
-
- case XML_VLIST_TAG_END_ID:
-#if (VLIST_DEBUG_XML==TRUE)
- XML_TRACE_DEBUG0( "[xml vlist] xml_vlist_int_fill_evt_data(): XML_VLIST_TAG_END_ID" );
-#endif
- break;
-
- default:
- XML_TRACE_DEBUG1( "[xml vlist] xml_vlist_int_fill_evt_data():unknown element: %d", prop_name );
- break;
- }
- }
-
- /* keep track of current filling position, and current available dst buffer */
- *p_prop = cur_prop;
- *p_dst_data = p_cur_offset;
-
- return x_res;
-}
-
-
-/**************************************************************************************
-** Function XML_VlistInit
-**
-** Description Initialize xml parser state machine.
-**
-** Parameters p_xml_state: address of an xml parser state machine to be initialized,
-** allocate an additional space of size XML_VLIST_CARRY_OVER_LEN
-** right after *p_xml_state to hold carry over data.
-** p_entry : points start of output vlist entry. caller needs do
-** free this memory
-** max_entry : max is 16 bit integer value which is the maximum number
-** of folder entries.
-
-**
-** Returns void
-**************************************************************************************/
-
-void XML_VlistInit( tXML_VLIST_PARSER *p_xml_state,
- tXML_VLIST_ENTRY *p_entry,
- const UINT16 max_entry )
-{
- /* Initialize the generic xml parser state machine.*/
- XML_InitPars( &p_xml_state->xml, xml_vlist_cback, &p_xml_state->xml_user_data );
-
- /* User need to allocate an additional space of size XML_VLIST_CARRY_OVER_LEN */
- /* right after *p_xml_state to hold carry over data. */
- /* point to the end of the allocated buffer for p_xml_state, which is the */
- /* beginning of buffer(XML_VLIST_CARRY_OVER_LEN) */
- p_xml_state->xml.last_bfr.p = (UINT8 *)(p_xml_state + 1);
- p_xml_state->xml.last_bfr.len = XML_VLIST_CARRY_OVER_LEN;
-
- /* Initialize user data */
- p_xml_state->xml_user_data.p_entry = p_entry;
- p_xml_state->xml_user_data.current_entry = 0;
- p_xml_state->xml_user_data.max_name_len = XML_UI_ENTRY_MAX_NAME_LEN + 1;
- p_xml_state->xml_user_data.max_entry = (UINT16)max_entry;
- p_xml_state->xml_user_data.prop_num = 0;
-}
-
-
-/**************************************************************************************
-** Function XML_VlistParse
-**
-** Description This function is called to parse the xml data received from OBEX
-** into folder entries associated with properties value. It can also be
-** used as clean up function to delete left over data from previous parse.
-** This clean up function is typically used when application runs out of
-** resource and decides to discard extra xml data received.
-**
-** Parameters p_xml_state: pointer to a xml parser initialized by XML_VlistInit().
-** xml_data: valid pointer to OBEX list data in xml format.
-** xml_len: length of the package, must be non-zero value.
-** dst_data: valid pointer to the buffer for holding converted folder entry name.
- When dst_data is NULL, clean up all remaining data in the parser.
-** dst_len: pointer to the length of dst_data buffer, its carry out value
-** is the number of bytes remaining buffer.When dst_len is NULL,
-** it will cause to flush the internal data in the parser.
-** num_entries: current number of entries, in the end it is the total number of entries
-**
-** Returns tXML_VLIST_RES (see xml_vlist_api.h)
-** XML_PENDING: parsing not completed
-** XML_END_LIST: found /VCard-listing but no final flag detected
-** XML_VLIST_OUT_FULL: reached max_entry -> do not call parser anymore!!! dump data
-** XML_VLIST_DST_NO_RES : run out of dst buffer resource while
-** some xml data still remains.
-
-**************************************************************************************/
-tXML_VLIST_RES XML_VlistParse( tXML_VLIST_PARSER *p_xml_state,
- UINT8 *xml_data, UINT16 xml_len,
- UINT8 *dst_data, UINT16 *dst_len,
- UINT16 *num_entries )
-{
- tXML_OS xos;
- BOOLEAN is_remain = TRUE;
- tXML_MUL_STATE *p_xml = &p_xml_state->xml;
- tXML_VLIST_STATE *p_st = &p_xml_state->xml_user_data;
- tXML_VLIST_RES x_res = XML_VLIST_OK;
- tXML_RESULT res = XML_NO_PROP;
- UINT16 max_num_prop = GKI_BUF3_SIZE/sizeof(tXML_PROP); /* i hope this is sufficient for 1 */
-
-#if (defined(VLIST_DEBUG_XML) && VLIST_DEBUG_XML == TRUE)
- int xx;
- UINT8 dbg_buf[VLIST_DEBUG_LEN];
- tXML_STR str;
-#endif
-
- /* if dst_data is NULL, clean up remaining data */
- if (!dst_data || !dst_len)
- {
- /* clean out remained xml data left over from last parse */
- if (p_xml_state->xml_user_data.p_prop )
- {
- GKI_freebuf( p_st->p_prop );
- p_st->p_prop = p_st->offset_prop = NULL;
- p_st->prop_num = 0;
- }
-#if (VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0( "[xml vlist] XML_VlistParse() Clean up left over!");
-#endif
- return x_res;
- }
-
- /* if illegal OBEX data or dst buffer pointer received, return ERROR */
- if (xml_len == 0 || !xml_data)
- {
- return XML_VLIST_ERROR;
- }
-
- /* XML_VlistParse receive new xml data, allocate buffer to hold parsed prop */
- if (p_st->offset_prop == NULL)
- {
-
-#if (VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG0( "[xml vlist] XML_VlistParse() Receive New Data!");
- XML_TRACE_DEBUG2( "[xml vlist] XML_data start[%x] end [%x]",xml_data, xml_data+xml_len);
-#endif
- is_remain = FALSE;
- if ( NULL!= (p_st->p_prop = (tXML_PROP *)GKI_getbuf( GKI_BUF3_SIZE ) ) )
- {
- xos.p_begin = xml_data;
- xos.p_end = xml_data + xml_len;
- /* pointing next prop to be converted into file entry */
- p_st->prop_num = 0;
- }
- else
- {
- GKI_freebuf( p_xml_state );
- x_res = XML_VLIST_NO_RES;
- return x_res;
- }
- }
-#if (VLIST_DEBUG_XML == TRUE)
- else
- {
- XML_TRACE_DEBUG0( "[xml vlist] XML_VlistParse(): Keep cleaning up old xml data !");
- }
-#endif
-
- while( res == XML_NO_PROP )
- {
- /* if no remaining data in p_st->p_prop, parse new xml data */
- if (!is_remain)
- {
- p_st->max_num_prop = max_num_prop;
- p_st->prop_index = 0;
- res = XML_MulParse( p_xml, &xos );
-
-
-#if (VLIST_DEBUG_XML == TRUE)
- XML_TRACE_DEBUG4( "xml_vlist_parse obj: %x, max: %d, num: %d, res: %d",
- p_st->obj, max_num_prop, p_st->prop_index, res);
-
- if (res != 0)
- {
- XML_TRACE_DEBUG1( "XML_MulParse Parsing: %d !!!", res);
- }
-
- for(xx=0; xx<p_st->prop_index; xx++)
- {
- if ( p_st->p_prop[xx].name < XML_VLIST_MAX_ID )
- {
- str.p = p_st->p_prop[xx].p_data;
- str.len = p_st->p_prop[xx].len;
- xml_vlist_debug_str(&str, dbg_buf);
- XML_TRACE_DEBUG5( "[xml vlist] parsed: index[%d]:%d:%s: %s(%d)", p_st->prop_index-xx, p_st->p_prop[xx].level,
- xml_vlist_ttbl[p_st->p_prop[xx].name].p_name, dbg_buf, p_st->p_prop[xx].len);
- }
- else
- {
- XML_TRACE_DEBUG3( "[xml vlist] internal prop: %d:%d:%d", xx, p_st->p_prop[xx].level,
- p_st->p_prop[xx].name );
- }
- }
-#endif
- p_st->prop_num = p_st->prop_index ;
- p_st->offset_prop = p_st->p_prop;
- }
- else
- {
- /* This is left over data, pick up the result from the previous parse */
- res = p_xml->pars_res;
- }
-
- if ( res != XML_OBJ_ST_EMPTY )
- {
- x_res = xml_vlist_int_fill_evt_data( p_st->obj, p_st, &p_st->offset_prop, &p_st->prop_num, &dst_data, dst_len );
-
- if ( (XML_VLIST_OK == x_res) && (XML_NO_END == res) )
- {
- /* XML_NO_END means that the xml is not completly finished and fill returns
- ok when when partial filling has been ok */
- x_res = XML_VLIST_PENDING;
- }
-
- /* all parsed xml data has been converted into file entry */
- /* or exceed max entry number , break the parsing loop */
- if (XML_VLIST_OUT_FULL != x_res && XML_VLIST_DST_NO_RES != x_res)
- {
- is_remain = FALSE;
- }
- else
- break;
- }
- } /* while */
-
- /* free property table. at next call a new one is allocated */
- if ((x_res != XML_VLIST_DST_NO_RES && p_st->p_prop) ||
- XML_VLIST_OUT_FULL == x_res)
- {
- GKI_freebuf( p_st->p_prop );
- p_st->p_prop = NULL;
- p_st->offset_prop = NULL;
- }
-
- if ( x_res != XML_VLIST_DST_NO_RES && p_st->ended)
- {
- /* this should happen on the same time as final flag in fact */
- x_res = XML_VLIST_END_LIST; /* found closing /folder-listing */
- }
-
-
- *num_entries = p_st->current_entry; /* report number of entries found. only when ended is true
- application really should be interested! */
- return x_res;
-}
-