4 * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
5 * Copyright (c) 2013 Intel Corporation. All rights reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #ifndef __CORE_OBJECT_H__
21 #define __CORE_OBJECT_H__
27 #define CORE_OBJECT_TYPE_DEFAULT 0xB0000000
28 #define CORE_OBJECT_TYPE_MODEM (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_MODEM)
29 #define CORE_OBJECT_TYPE_CALL (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_CALL)
30 #define CORE_OBJECT_TYPE_SS (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SS)
31 #define CORE_OBJECT_TYPE_NETWORK (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_NETWORK)
32 #define CORE_OBJECT_TYPE_PS (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_PS)
33 #define CORE_OBJECT_TYPE_PS_CONTEXT (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_PDP)
34 #define CORE_OBJECT_TYPE_SIM (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SIM)
35 #define CORE_OBJECT_TYPE_SAT (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SAT)
36 #define CORE_OBJECT_TYPE_SAP (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SAP)
37 #define CORE_OBJECT_TYPE_SMS (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SMS)
38 #define CORE_OBJECT_TYPE_PHONEBOOK (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_PHONEBOOK)
39 #define CORE_OBJECT_TYPE_CUSTOM (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_CUSTOM)
40 #define CORE_OBJECT_TYPE_GPS (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_GPS)
42 #define CORE_OBJECT_CHECK(co,t) \
43 if (co == NULL) { warn("core_object is NULL"); return; } \
44 if (tcore_object_get_type(co) != t) { \
45 warn("type(0x%x != 0x%x) mismatch", tcore_object_get_type(co), t); \
49 #define CORE_OBJECT_CHECK_RETURN(co,t,r) \
50 if (co == NULL) { warn("core_object is NULL"); return r; } \
51 if (tcore_object_get_type(co) != t) { \
52 warn("type(0x%x != 0x%x) mismatch", tcore_object_get_type(co), t); \
56 #define GET_OBJECT_TYPE(command) ((command & 0x0FF00000) | CORE_OBJECT_TYPE_DEFAULT)
58 typedef struct tcore_object_mapping_tbl TcoreObjectMappingTable;
60 typedef void (*TcoreObjectFreeHook)(CoreObject *co);
61 typedef void (*TcoreObjectCloneHook)(CoreObject *src, CoreObject *dest);
62 typedef gboolean (*TcoreObjectCallback)(CoreObject *co,
63 const void *event_info, void *user_data);
65 typedef gboolean (*TcoreObjectInit)(TcorePlugin *plugin, CoreObject *co);
66 typedef void (*TcoreObjectDeinit)(TcorePlugin *plugin, CoreObject *co);
68 /* Core Object Initializers */
70 TcoreObjectInit modem_init;
71 TcoreObjectInit sim_init;
72 TcoreObjectInit sat_init;
73 TcoreObjectInit sap_init;
74 TcoreObjectInit network_init;
75 TcoreObjectInit ps_init;
76 TcoreObjectInit call_init;
77 TcoreObjectInit ss_init;
78 TcoreObjectInit sms_init;
79 TcoreObjectInit phonebook_init;
80 TcoreObjectInit gps_init;
81 /* To be updated based on New modules */
82 } TcoreObjectInitializer;
84 /* Core Object De-initializers */
86 TcoreObjectDeinit modem_deinit;
87 TcoreObjectDeinit sim_deinit;
88 TcoreObjectDeinit sat_deinit;
89 TcoreObjectDeinit sap_deinit;
90 TcoreObjectDeinit network_deinit;
91 TcoreObjectDeinit ps_deinit;
92 TcoreObjectDeinit call_deinit;
93 TcoreObjectDeinit ss_deinit;
94 TcoreObjectDeinit sms_deinit;
95 TcoreObjectDeinit phonebook_deinit;
96 TcoreObjectDeinit gps_deinit;
97 /* To be updated based on New modules */
98 } TcoreObjectDeinitializer;
100 CoreObject *tcore_object_new(TcorePlugin *plugin, TcoreHal *hal);
101 void tcore_object_free(CoreObject *co);
103 TelReturn tcore_object_set_free_hook(CoreObject *co,
104 TcoreObjectFreeHook free_hook);
105 TelReturn tcore_object_set_clone_hook(CoreObject *co,
106 TcoreObjectCloneHook clone_hook);
108 CoreObject *tcore_object_clone(CoreObject *src, TcorePlugin *new_parent);
109 CoreObject *tcore_object_clone_template_object(TcorePlugin *p,
112 TelReturn tcore_object_set_plugin(CoreObject *co, TcorePlugin *plugin);
113 TcorePlugin *tcore_object_ref_plugin(CoreObject *co);
115 TelReturn tcore_object_link_object(CoreObject *co, void *object);
116 void *tcore_object_ref_object(CoreObject *co);
118 TelReturn tcore_object_set_type(CoreObject *co, guint type);
119 guint tcore_object_get_type(CoreObject *co);
121 TelReturn tcore_object_set_hal(CoreObject *co, TcoreHal *hal);
122 TcoreHal *tcore_object_get_hal(CoreObject *co);
124 TelReturn tcore_object_link_user_data(CoreObject *co, void *user_data);
125 void *tcore_object_ref_user_data(CoreObject *co);
127 TelReturn tcore_object_set_dispatcher(CoreObject *co, TcoreObjectDispatcher func);
128 TelReturn tcore_object_dispatch_request(CoreObject *co,
129 gboolean exec_hooks, TcoreCommand command,
130 const void *request, guint request_len,
131 TcorePluginResponseCallback cb, const void *user_data);
133 TelReturn tcore_object_add_callback(CoreObject *co, const gchar *event,
134 TcoreObjectCallback callback, void *user_data);
135 TelReturn tcore_object_del_callback(CoreObject *co, const gchar *event,
136 TcoreObjectCallback callback);
137 TelReturn tcore_object_override_callback(CoreObject *co, const gchar *event,
138 TcoreObjectCallback callback, void *user_data);
139 TelReturn tcore_object_emit_callback(CoreObject *co, const gchar *event,
140 const void *event_info);
142 TelReturn tcore_object_add_request_hook(CoreObject *co,
143 TcoreCommand command, TcoreRequestHook func, void *user_data);
144 void tcore_object_remove_request_hook(CoreObject *co,
145 TcoreCommand command, TcoreRequestHook func);
147 TelReturn tcore_object_add_response_hook(CoreObject *co,
148 TcoreCommand command, const void *request,
149 TcoreResponseHook func, void *user_data);
150 void tcore_object_remove_response_hook(CoreObject *co,
151 TcoreCommand command, TcoreResponseHook func);
153 TelReturn tcore_object_add_notification_hook(CoreObject *co,
154 TcoreNotification command, TcoreNotificationHook func, void *user_data);
155 void tcore_object_remove_notification_hook(CoreObject *co,
156 TcoreNotification command, TcoreNotificationHook func);
157 TelReturn tcore_object_send_notification(CoreObject *co,
158 TcoreNotification command, guint data_len, void *data);
160 void *tcore_object_add_mapping_tbl_entry(void *mapping_tbl,
161 guint object_type, TcoreHal *hal);
162 void tcore_object_remove_mapping_tbl(void *mapping_tbl);
163 void *tcore_object_remove_mapping_tbl_entry(void *mapping_tbl, TcoreHal *hal);
164 void tcore_object_remove_mapping_tbl_entry_by_type(void *mapping_tbl,
167 void tcore_object_print_mapping_tbl(void *mapping_tbl);
169 TelReturn tcore_object_init_objects(TcorePlugin *plugin,
170 TcoreObjectInitializer *initializer_list);
171 void tcore_object_deinit_objects(TcorePlugin *plugin,
172 TcoreObjectDeinitializer *deinitializer_list);
178 #endif /* __CORE_OBJECT_H__ */