4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #ifndef __TCORE_CORE_OBJECT_H__
22 #define __TCORE_CORE_OBJECT_H__
26 #define CORE_OBJECT_TYPE_DEFAULT 0xB0000000
27 #define CORE_OBJECT_TYPE_MODEM (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_MODEM)
28 #define CORE_OBJECT_TYPE_CALL (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_CALL)
29 #define CORE_OBJECT_TYPE_SS (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SS)
30 #define CORE_OBJECT_TYPE_NETWORK (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_NETWORK)
31 #define CORE_OBJECT_TYPE_PS (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_PS)
32 #define CORE_OBJECT_TYPE_PS_CONTEXT (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_PDP)
33 #define CORE_OBJECT_TYPE_SIM (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SIM)
34 #define CORE_OBJECT_TYPE_SAT (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SAT)
35 #define CORE_OBJECT_TYPE_SAP (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SAP)
36 #define CORE_OBJECT_TYPE_SMS (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SMS)
37 #define CORE_OBJECT_TYPE_PHONEBOOK (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_PHONEBOOK)
38 #define CORE_OBJECT_TYPE_SOUND (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SOUND)
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 typedef struct tcore_object_mapping_tbl object_mapping_table_t;
58 typedef void (*tcore_object_free_hook)(CoreObject *co);
59 typedef void (*tcore_object_clone_hook)(CoreObject *src, CoreObject *dest);
60 typedef gboolean (*tcore_object_callback)(CoreObject *co,
61 const void *event_info, void *user_data);
62 typedef TReturn (*tcore_object_dispatcher)(CoreObject *co, UserRequest *ur);
65 typedef gboolean (*tcore_object_init)(TcorePlugin *plugin, CoreObject *co);
66 typedef void (*tcore_object_deinit)(TcorePlugin *plugin, CoreObject *co);
68 /* Core Object Initializers */
69 struct object_initializer {
70 tcore_object_init modem_init;
71 tcore_object_init sim_init;
72 tcore_object_init sat_init;
73 tcore_object_init sap_init;
74 tcore_object_init network_init;
75 tcore_object_init ps_init;
76 tcore_object_init call_init;
77 tcore_object_init ss_init;
78 tcore_object_init sms_init;
79 tcore_object_init phonebook_init;
80 tcore_object_init gps_init;
81 /* To be updated based on New modules */
84 /* Core Object De-initializers */
85 struct object_deinitializer {
86 tcore_object_deinit modem_deinit;
87 tcore_object_deinit sim_deinit;
88 tcore_object_deinit sat_deinit;
89 tcore_object_deinit sap_deinit;
90 tcore_object_deinit network_deinit;
91 tcore_object_deinit ps_deinit;
92 tcore_object_deinit call_deinit;
93 tcore_object_deinit ss_deinit;
94 tcore_object_deinit sms_deinit;
95 tcore_object_deinit phonebook_deinit;
96 tcore_object_deinit gps_deinit;
97 /* To be updated based on New modules */
100 CoreObject *tcore_object_new(TcorePlugin *plugin, TcoreHal *hal);
101 void tcore_object_free(CoreObject *co);
103 TReturn tcore_object_set_free_hook(CoreObject *co, tcore_object_free_hook free_hook);
104 TReturn tcore_object_set_clone_hook(CoreObject *co, tcore_object_clone_hook clone_hook);
106 CoreObject *tcore_object_clone(CoreObject *src, TcorePlugin *new_parent);
107 CoreObject *tcore_object_clone_template_object(TcorePlugin *p,
108 unsigned int co_type);
110 TReturn tcore_object_set_plugin(CoreObject *co, TcorePlugin *plugin);
111 TcorePlugin *tcore_object_ref_plugin(CoreObject *co);
113 TReturn tcore_object_link_object(CoreObject *co, void *object);
114 void *tcore_object_ref_object(CoreObject *co);
116 TReturn tcore_object_set_type(CoreObject *co, unsigned int type);
117 unsigned int tcore_object_get_type(CoreObject *co);
119 TReturn tcore_object_set_hal(CoreObject *co, TcoreHal *hal);
120 TcoreHal *tcore_object_get_hal(CoreObject *co);
122 TReturn tcore_object_link_user_data(CoreObject *co, void *user_data);
123 void *tcore_object_ref_user_data(CoreObject *co);
125 TReturn tcore_object_set_dispatcher(CoreObject *co, tcore_object_dispatcher func);
126 TReturn tcore_object_dispatch_request(CoreObject *co, UserRequest *ur);
128 TReturn tcore_object_add_callback(CoreObject *co, const char *event, tcore_object_callback callback, void *user_data);
129 TReturn tcore_object_del_callback(CoreObject *co, const char *event, tcore_object_callback callback);
130 TReturn tcore_object_override_callback(CoreObject *co, const char *event, tcore_object_callback callback, void *user_data);
131 TReturn tcore_object_emit_callback(CoreObject *co, const char *event, const void *event_info);
133 void *tcore_object_add_mapping_tbl_entry(void *mapping_tbl,
134 unsigned int object_type, TcoreHal *hal);
135 void tcore_object_remove_mapping_tbl(void *mapping_tbl);
136 void *tcore_object_remove_mapping_tbl_entry(void *mapping_tbl, TcoreHal *hal);
137 void tcore_object_remove_mapping_tbl_entry_by_type(void *mapping_tbl,
138 unsigned int co_type);
140 void tcore_object_print_mapping_tbl(void *mapping_tbl);
142 TReturn tcore_object_init_objects(TcorePlugin *plugin,
143 struct object_initializer *initializer_list);
144 void tcore_object_deinit_objects(TcorePlugin *plugin,
145 struct object_deinitializer *deinitializer_list);