5a54a54aa1b2debc304d16a1a9d538450aaa513c
[framework/telephony/libtcore.git] / include / hal.h
1 /*
2  * libtcore
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #ifndef __TCORE_HAL_H__
22 #define __TCORE_HAL_H__
23
24 __BEGIN_DECLS
25
26 typedef void (*TcoreHalReceiveCallback)(TcoreHal *hal, unsigned int data_len, const void *data, void *user_data);
27 typedef enum tcore_hook_return (*TcoreHalSendHook)(TcoreHal *hal, unsigned int data_len, void *data, void *user_data);
28
29 enum tcore_hal_recv_data_type {
30         TCORE_HAL_RECV_INDICATION,
31         TCORE_HAL_RECV_RESPONSE,
32         TCORE_HAL_RECV_NOTIFICATION,
33         TCORE_HAL_RECV_UNKNOWN
34 };
35
36 enum tcore_hal_mode {
37         TCORE_HAL_MODE_UNKNOWN,
38         TCORE_HAL_MODE_AT,
39         TCORE_HAL_MODE_CUSTOM,
40     TCORE_HAL_MODE_TRANSPARENT
41 };
42
43 struct tcore_hal_operations {
44         TReturn (*power)(TcoreHal *hal, gboolean flag);
45         TReturn (*send)(TcoreHal *hal, unsigned int data_len, void *data);
46 };
47
48 TcoreHal*    tcore_hal_new(TcorePlugin *plugin, const char *name,
49                  struct tcore_hal_operations *hops,
50                  enum tcore_hal_mode mode);
51 void         tcore_hal_free(TcoreHal *hal);
52
53 TReturn      tcore_hal_set_name(TcoreHal *hal, const char *name);
54 char*        tcore_hal_get_name(TcoreHal *hal);
55
56 TcoreAT*     tcore_hal_get_at(TcoreHal *hal);
57 enum tcore_hal_mode tcore_hal_get_mode(TcoreHal *hal);
58 TReturn         tcore_hal_set_mode(TcoreHal *hal, enum tcore_hal_mode mode);
59
60 TReturn      tcore_hal_set_power(TcoreHal *hal, gboolean flag);
61
62 TReturn      tcore_hal_link_user_data(TcoreHal *hal, void *user_data);
63 void*        tcore_hal_ref_user_data(TcoreHal *hal);
64
65 TReturn      tcore_hal_send_data(TcoreHal *hal, unsigned int data_len, void *data);
66 TReturn      tcore_hal_send_request(TcoreHal *hal, TcorePending *pending);
67 TReturn      tcore_hal_send_force(TcoreHal *hal);
68
69 TReturn      tcore_hal_dispatch_response_data(TcoreHal *hal, int id,
70                  unsigned int data_len, const void *data);
71
72 TReturn      tcore_hal_add_recv_callback(TcoreHal *hal,
73                  TcoreHalReceiveCallback func, void *user_data);
74 TReturn      tcore_hal_remove_recv_callback(TcoreHal *hal,
75                  TcoreHalReceiveCallback func);
76 TReturn      tcore_hal_emit_recv_callback(TcoreHal *hal,
77                  unsigned int data_len, const void *data);
78
79 TReturn      tcore_hal_add_send_hook(TcoreHal *hal, TcoreHalSendHook func,
80                  void *user_data);
81 TReturn      tcore_hal_remove_send_hook(TcoreHal *hal, TcoreHalSendHook func);
82
83 TReturn      tcore_hal_set_power_state(TcoreHal *hal, gboolean flag);
84 gboolean     tcore_hal_get_power_state(TcoreHal *hal);
85
86 TcoreQueue*  tcore_hal_ref_queue(TcoreHal *hal);
87 TcorePlugin* tcore_hal_ref_plugin(TcoreHal *hal);
88
89 __END_DECLS
90
91 #endif