summaryrefslogtreecommitdiffstats
path: root/bta
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 /bta
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
Diffstat (limited to 'bta')
-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
78 files changed, 1 insertions, 39027 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 */