Initial refactoring merge
[platform/core/telephony/libtcore.git] / include / hal.h
1 /*
2  * libtcore
3  *
4  * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
5  * Copyright (c) 2013 Intel Corporation. All rights reserved.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 #ifndef __HAL_H__
21 #define __HAL_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 typedef void (*TcoreHalReceiveCallback)(TcoreHal *hal,
28         guint data_len, const void *data, void *user_data);
29
30 typedef TcoreHookReturn (*TcoreHalSendHook)(TcoreHal *hal,
31         guint data_len, void *data, void *user_data);
32
33 typedef void (*TcoreHalSetupNetifCallback)(CoreObject *co,
34         gint result, const gchar* devname, void *user_data);
35
36 typedef enum {
37         TCORE_HAL_RECV_INDICATION,
38         TCORE_HAL_RECV_RESPONSE,
39         TCORE_HAL_RECV_NOTIFICATION,
40         TCORE_HAL_RECV_UNKNOWN
41 } TcoreHalRecvDataType;
42
43 typedef enum {
44         TCORE_HAL_MODE_UNKNOWN,
45         TCORE_HAL_MODE_AT,
46         TCORE_HAL_MODE_CUSTOM,
47         TCORE_HAL_MODE_TRANSPARENT
48 } TcoreHalMode;
49
50 typedef struct {
51         TelReturn (*power)(TcoreHal *hal, gboolean flag);
52         TelReturn (*send)(TcoreHal *hal, guint data_len, void *data);
53         TelReturn (*setup_netif)(CoreObject *co,
54                 TcoreHalSetupNetifCallback func, void *user_data,
55                 guint cid, gboolean enable);
56 } TcoreHalOperations;
57
58 TcoreHal *tcore_hal_new(TcorePlugin *plugin, const gchar *name,
59                 TcoreHalOperations *hops, TcoreHalMode mode);
60 void tcore_hal_free(TcoreHal *hal);
61
62 TelReturn tcore_hal_set_name(TcoreHal *hal, const gchar *name);
63 gchar *tcore_hal_get_name(TcoreHal *hal);
64
65 TcoreAT *tcore_hal_get_at(TcoreHal *hal);
66 TcoreHalMode tcore_hal_get_mode(TcoreHal *hal);
67 TelReturn tcore_hal_set_mode(TcoreHal *hal, TcoreHalMode mode);
68
69 TelReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag);
70
71 TelReturn tcore_hal_link_user_data(TcoreHal *hal, void *user_data);
72 void *tcore_hal_ref_user_data(TcoreHal *hal);
73
74 TelReturn tcore_hal_send_data(TcoreHal *hal, guint data_len, void *data);
75 TelReturn tcore_hal_send_request(TcoreHal *hal, TcorePending *pending);
76 TelReturn tcore_hal_send_force(TcoreHal *hal);
77
78 TelReturn tcore_hal_dispatch_response_data(TcoreHal *hal, guint id,
79                 guint data_len, const void *data);
80
81 TelReturn tcore_hal_add_recv_callback(TcoreHal *hal,
82         TcoreHalReceiveCallback func, void *user_data);
83 TelReturn tcore_hal_remove_recv_callback(TcoreHal *hal,
84         TcoreHalReceiveCallback func);
85 TelReturn tcore_hal_emit_recv_callback(TcoreHal *hal,
86         guint data_len, const void *data);
87 TelReturn tcore_hal_add_send_hook(TcoreHal *hal,
88         TcoreHalSendHook func, void *user_data);
89 TelReturn tcore_hal_remove_send_hook(TcoreHal *hal,
90         TcoreHalSendHook func);
91
92 TelReturn tcore_hal_set_power_state(TcoreHal *hal, gboolean flag);
93 gboolean tcore_hal_get_power_state(TcoreHal *hal);
94
95 TcoreQueue *tcore_hal_ref_queue(TcoreHal *hal);
96 TcorePlugin *tcore_hal_ref_plugin(TcoreHal *hal);
97
98 TelReturn tcore_hal_setup_netif(TcoreHal *hal, CoreObject *co,
99         TcoreHalSetupNetifCallback func, void *user_data,
100         guint cid, gboolean enable);
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif  /* __HAL_H__ */