1/******************************************************************************
2 *
3 *  Copyright (C) 2003-2012 Broadcom Corporation
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19/******************************************************************************
20 *
21 *  This is the interface file for file system call-in functions.
22 *
23 ******************************************************************************/
24#ifndef BTA_FS_CI_H
25#define BTA_FS_CI_H
26
27#include "bta_fs_co.h"
28
29/*****************************************************************************
30**  Constants and data types
31*****************************************************************************/
32
33/* Open Complete Event */
34typedef struct
35{
36    BT_HDR            hdr;
37    tBTA_FS_CO_STATUS status;
38    UINT32            file_size;
39    int               fd;
40    const char        *p_file;
41} tBTA_FS_CI_OPEN_EVT;
42
43/* Read Ready Event */
44typedef struct
45{
46    BT_HDR            hdr;
47    tBTA_FS_CO_STATUS status;
48    int               fd;
49    UINT16            num_read;
50} tBTA_FS_CI_READ_EVT;
51
52/* Write Ready Event */
53typedef struct
54{
55    BT_HDR            hdr;
56    tBTA_FS_CO_STATUS status;
57    int               fd;
58} tBTA_FS_CI_WRITE_EVT;
59
60/* Get Directory Entry Event */
61typedef struct
62{
63    BT_HDR            hdr;
64    tBTA_FS_CO_STATUS status;
65} tBTA_FS_CI_GETDIR_EVT;
66
67/* Resume Information Event */
68typedef struct
69{
70    BT_HDR            hdr;
71    tBTA_FS_CO_STATUS status;
72    BD_ADDR_PTR       p_addr;
73    UINT8             *p_sess_info;
74    UINT32            timeout;
75    UINT32            offset;
76    UINT8             ssn;
77    UINT8             info;
78} tBTA_FS_CI_RESUME_EVT;
79
80/* Action Complete Event */
81typedef struct
82{
83    BT_HDR            hdr;
84    tBTA_FS_CO_STATUS status;
85} tBTA_FS_CI_ACTION_EVT;
86
87
88/*****************************************************************************
89**  Function Declarations
90*****************************************************************************/
91#ifdef __cplusplus
92extern "C"
93{
94#endif
95
96/*******************************************************************************
97**
98** Function         bta_fs_ci_write
99**
100** Description      This function sends an event to BTA indicating the phone
101**                  has written the number of bytes specified in the call-out
102**                  function, bta_fs_co_write(), and is ready for more data.
103**                  This function is used to control the TX data flow.
104**                  Note: The data buffer is released by the stack aioer
105**                        calling this function.
106**
107** Parameters       fd - file descriptor passed to the stack in the
108**                       bta_fs_ci_open call-in function.
109**                  status - BTA_FS_CO_OK, BTA_FS_CO_NOSPACE, or BTA_FS_CO_FAIL
110**                  evt - Used Internally by BTA -> MUST be same value passed
111**                       in call-out function.
112**
113** Returns          void
114**
115*******************************************************************************/
116BTA_API extern void bta_fs_ci_write(int fd, tBTA_FS_CO_STATUS status, UINT16 evt);
117
118/*******************************************************************************
119**
120** Function         bta_fs_ci_read
121**
122** Description      This function sends an event to BTA indicating the phone has
123**                  read in the requested amount of data specified in the
124**                  bta_fs_co_read() call-out function.  It should only be called
125**                  when the requested number of bytes has been read in, or aioer
126**                  the end of the file has been detected.
127**
128** Parameters       fd - file descriptor passed to the stack in the
129**                       bta_fs_ci_open call-in function.
130**                  num_bytes_read - number of bytes read into the buffer
131**                      specified in the read callout-function.
132**                  status - BTA_FS_CO_OK if full buffer of data,
133**                           BTA_FS_CO_EOF if the end of file has been reached,
134**                           BTA_FS_CO_FAIL if an error has occurred.
135**                  evt - Used Internally by BTA -> MUST be same value passed
136**                       in call-out function.
137**
138** Returns          void
139**
140*******************************************************************************/
141BTA_API extern void bta_fs_ci_read(int fd, UINT16 num_bytes_read,
142                                   tBTA_FS_CO_STATUS status, UINT16 evt);
143
144/*******************************************************************************
145**
146** Function         bta_fs_ci_open
147**
148** Description      This function sends an event to BTA indicating the phone has
149**                  finished opening a file for reading or writing.
150**
151** Parameters       fd - file descriptor passed to the stack in the
152**                       bta_fs_ci_open call-in function.
153**                  status - BTA_FS_CO_OK if file was opened in mode specified
154**                                          in the call-out function.
155**                           BTA_FS_CO_EACCES if the file exists, but contains
156**                                          the wrong access permissions.
157**                           BTA_FS_CO_FAIL if any other error has occurred.
158**                  file_size - The total size of the file
159**                  evt - Used Internally by BTA -> MUST be same value passed
160**                       in call-out function.
161**
162** Returns          void
163**
164*******************************************************************************/
165BTA_API extern void bta_fs_ci_open(int fd, tBTA_FS_CO_STATUS status,
166                                   UINT32 file_size, UINT16 evt);
167
168/*******************************************************************************
169**
170** Function         bta_fs_ci_direntry
171**
172** Description      This function is called in response to the
173**                  bta_fs_co_getdirentry call-out function.
174**
175** Parameters       status - BTA_FS_CO_OK if p_entry points to a valid entry.
176**                           BTA_FS_CO_EODIR if no more entries (p_entry is ignored).
177**                           BTA_FS_CO_FAIL if any errors have occurred.
178**                  evt - Used Internally by BTA -> MUST be same value passed
179**                       in call-out function.
180**
181** Returns          void
182**
183*******************************************************************************/
184BTA_API extern void bta_fs_ci_direntry(tBTA_FS_CO_STATUS status, UINT16 evt);
185
186/*******************************************************************************
187**
188** Function         bta_fs_ci_resume
189**
190** Description      This function is called in response to the
191**                  bta_fs_co_resume call-out function.
192**
193** Parameters       p_sess_info - the stored session ID and related information.
194**                  ssn     - the stored session sequence number.
195**                  info    - the stored BTA specific information (like last active operation).
196**                  status  - BTA_FS_CO_OK if p_entry points to a valid entry.
197**                            BTA_FS_CO_FAIL if any errors have occurred.
198**                  evt - Used Internally by BTA -> MUST be same value passed
199**                       in call-out function.
200**
201** Returns          void
202**
203*******************************************************************************/
204BTA_API extern void bta_fs_ci_resume (BD_ADDR_PTR p_addr, UINT8 *p_sess_info,
205                                      UINT32 timeout, UINT32 offset, UINT8 ssn, UINT8 info,
206                                      tBTA_FS_CO_STATUS status, UINT16 evt);
207
208/*******************************************************************************
209**
210** Function         bta_fs_ci_action
211**
212** Description      This function is called in response to one of the action
213**                  call-out functions: bta_fs_co_copy, bta_fs_co_rename or
214**                  bta_fs_co_set_perms.
215**
216** Parameters       status  - BTA_FS_CO_OK if the action is succession.
217**                            BTA_FS_CO_FAIL if any errors have occurred.
218**                  evt - Used Internally by BTA -> MUST be same value passed
219**                       in call-out function.
220**
221** Returns          void
222**
223*******************************************************************************/
224BTA_API extern void bta_fs_ci_action(tBTA_FS_CO_STATUS status, UINT16 evt);
225
226/*******************************************************************************
227**
228** Function         bta_fs_ci_resume_op
229**
230** Description      This function sends an event to BTA indicating the phone has
231**                  finished opening a file for reading or writing on resume.
232**
233** Parameters       fd - file descriptor passed to the stack in the
234**                       bta_fs_ci_open call-in function.
235**                  status - BTA_FS_CO_OK if file was opened in mode specified
236**                                          in the call-out function.
237**                           BTA_FS_CO_EACCES if the file exists, but contains
238**                                          the wrong access permissions.
239**                           BTA_FS_CO_FAIL if any other error has occurred.
240**                  p_file - The file name associated with fd
241**                  file_size - The total size of the file
242**                  evt - Used Internally by BTA -> MUST be same value passed
243**                       in call-out function.
244**
245** Returns          void
246**
247*******************************************************************************/
248BTA_API extern void bta_fs_ci_resume_op(int fd, tBTA_FS_CO_STATUS status, const char *p_file,
249                                        UINT32 file_size, UINT16 evt);
250
251#ifdef __cplusplus
252}
253#endif
254
255#endif /* BTA_FS_CI_H */
256
257