blob: 45e2301838052ed0e3fb39f6b5d315ba62b014ff [file] [log] [blame]
codeworkxf1587a32012-08-03 23:32:29 +02001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __SECRIL_CLIENT_H__
18#define __SECRIL_CLIENT_H__
19
20#include <sys/types.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26struct RilClient {
27 void *prv;
28};
29
30typedef struct RilClient * HRilClient;
31
32
33//---------------------------------------------------------------------------
34// Defines
35//---------------------------------------------------------------------------
36#define RIL_CLIENT_ERR_SUCCESS 0
37#define RIL_CLIENT_ERR_AGAIN 1
38#define RIL_CLIENT_ERR_INIT 2 // Client is not initialized
39#define RIL_CLIENT_ERR_INVAL 3 // Invalid value
40#define RIL_CLIENT_ERR_CONNECT 4 // Connection error
41#define RIL_CLIENT_ERR_IO 5 // IO error
42#define RIL_CLIENT_ERR_RESOURCE 6 // Resource not available
43#define RIL_CLIENT_ERR_UNKNOWN 7
44
45
46//---------------------------------------------------------------------------
47// Type definitions
48//---------------------------------------------------------------------------
49
50typedef int (*RilOnComplete)(HRilClient handle, const void *data, size_t datalen);
51
52typedef int (*RilOnUnsolicited)(HRilClient handle, const void *data, size_t datalen);
53
54typedef int (*RilOnError)(void *data, int error);
55
56
57//---------------------------------------------------------------------------
58// Client APIs
59//---------------------------------------------------------------------------
60
61/**
62 * Open RILD multi-client.
63 * Return is client handle, NULL on error.
64 */
65HRilClient OpenClient_RILD(void);
66
67/**
68 * Stop RILD multi-client. If client socket was connected,
69 * it will be disconnected.
70 */
71int CloseClient_RILD(HRilClient client);
72
73/**
74 * Connect to RIL deamon. One client task starts.
75 * Return is 0 or error code.
76 */
77int Connect_RILD(HRilClient client);
78
79/**
80 * check whether RILD is connected
81 * Returns 0 or 1
82 */
83int isConnected_RILD(HRilClient client);
84
85/**
86 * Disconnect connection to RIL deamon(socket close).
87 * Return is 0 or error code.
88 */
89int Disconnect_RILD(HRilClient client);
90
91/**
92 * Register unsolicited response handler. If handler is NULL,
93 * the handler for the request ID is unregistered.
94 * The response handler is invoked in the client task context.
95 * Return is 0 or error code.
96 */
97int RegisterUnsolicitedHandler(HRilClient client, uint32_t id, RilOnUnsolicited handler);
98
99/**
100 * Register solicited response handler. If handler is NULL,
101 * the handler for the ID is unregistered.
102 * The response handler is invoked in the client task context.
103 * Return is 0 or error code.
104 */
105int RegisterRequestCompleteHandler(HRilClient client, uint32_t id, RilOnComplete handler);
106
107/**
108 * Register error callback. If handler is NULL,
109 * the callback is unregistered.
110 * The response handler is invoked in the client task context.
111 * Return is 0 or error code.
112 */
113int RegisterErrorCallback(HRilClient client, RilOnError cb, void *data);
114
115/**
116 * Invoke OEM request. Request ID is RIL_REQUEST_OEM_HOOK_RAW.
117 * Return is 0 or error code. For RIL_CLIENT_ERR_AGAIN caller should retry.
118 */
119int InvokeOemRequestHookRaw(HRilClient client, char *data, size_t len);
120
121#ifdef __cplusplus
122};
123#endif
124
125#endif // __SECRIL_CLIENT_H__
126
127// end of file
128