summaryrefslogtreecommitdiffstats
path: root/bta/pb/bta_pbs_ci.c
blob: fa2644b5d52ec6c395ea8b748412b3fcefada0dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*****************************************************************************
**
**  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);
    }
}