769066cc52052768c99fa4b04e9b47c33825b008
[profile/ivi/tel-plugin-imc.git] / src / s_sat.c
1 /**\r
2  * tel-plugin-samsung\r
3  *\r
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved\r
5  *\r
6  * Contact: chandan swarup patra <chandan.sp@samsung.com>\r
7  *\r
8  * PROPRIETARY/CONFIDENTIAL\r
9  *\r
10  * This software is the confidential and proprietary information of SAMSUNG ELECTRONICS ("Confidential Information").\r
11  * You shall not disclose such Confidential Information and shall\r
12  * use it only in accordance with the terms of the license agreement you entered into with SAMSUNG ELECTRONICS.\r
13  * SAMSUNG make no representations or warranties about the suitability\r
14  * of the software, either express or implied, including but not\r
15  * limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement.\r
16  * SAMSUNG shall not be liable for any damages suffered by licensee as\r
17  * a result of using, modifying or distributing this software or its derivatives.\r
18  */\r
19 \r
20 #include <stdio.h>\r
21 #include <stdlib.h>\r
22 #include <string.h>\r
23 #include <glib.h>\r
24 #include <tcore.h>\r
25 #include <hal.h>\r
26 #include <core_object.h>\r
27 #include <plugin.h>\r
28 #include <queue.h>\r
29 #include <server.h>\r
30 #include <co_sat.h>\r
31 #include <user_request.h>\r
32 #include <at.h>\r
33 \r
34 #include "s_common.h"\r
35 #include "s_sat.h"\r
36 #define ENVELOPE_CMD_LEN        256\r
37 \r
38 static  TReturn s_terminal_response(CoreObject *o, UserRequest *ur);\r
39 static void on_confirmation_sat_message_send(TcorePending *p, gboolean result, void *user_data ); // from Kernel\r
40 \r
41 static void on_confirmation_sat_message_send( TcorePending *p, gboolean result, void *user_data )\r
42 {\r
43         dbg("on_confirmation_modem_message_send - msg out from queue.\n");\r
44 \r
45         if (result == FALSE)\r
46         {\r
47                 /* Fail */\r
48                 dbg("SEND FAIL");\r
49         }\r
50         else \r
51         {\r
52                 dbg("SEND OK");\r
53         }\r
54 }\r
55 \r
56 static gboolean on_response_terminal_response_confirm(CoreObject *o, const void *event_info, void *user_data)\r
57 {\r
58         dbg("Function Entry");\r
59         return TRUE;\r
60         dbg("Function Exit");\r
61 }\r
62 \r
63 static gboolean on_event_sat_proactive_command(CoreObject *o, const void *event_info, void *user_data)\r
64 {\r
65         struct tcore_sat_proactive_command      decoded_data;\r
66         struct tnoti_sat_proactive_ind          proactive_noti;\r
67         int                                     len_proactive_cmd = 0;\r
68         GSList                                  *lines= NULL;\r
69         GSList                                  *tokens= NULL;\r
70         char                                    *line= NULL;\r
71         char                                    *hexData= NULL;\r
72         char                                    *tmp= NULL;\r
73         char                                    *recordData= NULL;\r
74 \r
75         dbg("Function Entry");\r
76 \r
77         memset(&proactive_noti, 0x00, sizeof(struct tnoti_sat_proactive_ind));\r
78         memset(&decoded_data, 0x00, sizeof(struct tcore_sat_proactive_command));\r
79         lines = (GSList*)event_info;\r
80         line = (char*)lines->data;\r
81         tokens = tcore_at_tok_new(line);\r
82         if (g_slist_length(tokens) != 1) \r
83         {\r
84                 dbg("invalid message");\r
85                 tcore_at_tok_free(tokens);\r
86                 return FALSE;\r
87         }\r
88         hexData = (char*)g_slist_nth_data(tokens, 0);\r
89         \r
90         dbg("hexdata %s ", hexData);\r
91         dbg("hexdata length %d", strlen(hexData));\r
92 \r
93         tmp = calloc(1, strlen(hexData)-1);\r
94         if(tmp == NULL)\r
95         {\r
96                 return FALSE;\r
97         }       \r
98         memcpy(tmp, hexData+1, strlen(hexData)-2);\r
99 \r
100         recordData = util_hexStringToBytes(tmp);\r
101         dbg("recordData: %x", recordData);\r
102         free(tmp);\r
103         util_hex_dump("    ", strlen(hexData)/2, recordData);\r
104         len_proactive_cmd = strlen(recordData);\r
105         dbg("len_proactive_cmd = %d", len_proactive_cmd);\r
106         tcore_sat_decode_proactive_command((unsigned char*)recordData, (strlen(hexData)/2) - 1, &decoded_data);\r
107         free(recordData);\r
108 \r
109         proactive_noti.cmd_number = decoded_data.cmd_num;\r
110         proactive_noti.cmd_type = decoded_data.cmd_type;\r
111 \r
112         switch(decoded_data.cmd_type)\r
113         {\r
114                 case SAT_PROATV_CMD_DISPLAY_TEXT:\r
115                         dbg("decoded command is display text!!");\r
116                         memcpy(&proactive_noti.proactive_ind_data.display_text, &decoded_data.data.display_text,        sizeof(struct tel_sat_display_text_tlv));\r
117                         break;\r
118                 case SAT_PROATV_CMD_GET_INKEY:\r
119                         dbg("decoded command is get inkey!!");\r
120                         memcpy(&proactive_noti.proactive_ind_data.get_inkey, &decoded_data.data.get_inkey,      sizeof(struct tel_sat_get_inkey_tlv));\r
121                         break;\r
122                 case SAT_PROATV_CMD_GET_INPUT:\r
123                         dbg("decoded command is get input!!");\r
124                         memcpy(&proactive_noti.proactive_ind_data.get_input, &decoded_data.data.get_input,      sizeof(struct tel_sat_get_input_tlv));\r
125                         break;\r
126                 case SAT_PROATV_CMD_MORE_TIME:\r
127                         dbg("decoded command is more time!!");\r
128                         memcpy(&proactive_noti.proactive_ind_data.more_time, &decoded_data.data.more_time,      sizeof(struct tel_sat_more_time_tlv));\r
129                         break;\r
130                 case SAT_PROATV_CMD_PLAY_TONE:\r
131                         dbg("decoded command is play tone!!");\r
132                         memcpy(&proactive_noti.proactive_ind_data.play_tone, &decoded_data.data.play_tone,      sizeof(struct tel_sat_play_tone_tlv));\r
133                         break;\r
134                 case SAT_PROATV_CMD_SETUP_MENU:\r
135                         dbg("decoded command is SETUP MENU!!");\r
136                         memcpy(&proactive_noti.proactive_ind_data.setup_menu, &decoded_data.data.setup_menu, sizeof(struct tel_sat_setup_menu_tlv));\r
137                         break;\r
138                 case SAT_PROATV_CMD_SELECT_ITEM:\r
139                         dbg("decoded command is select item!!");\r
140                         memcpy(&proactive_noti.proactive_ind_data.select_item, &decoded_data.data.select_item,  sizeof(struct tel_sat_select_item_tlv));\r
141                         break;\r
142                 case SAT_PROATV_CMD_SEND_SMS:\r
143                         dbg("decoded command is send sms!!");\r
144                         memcpy(&proactive_noti.proactive_ind_data.send_sms, &decoded_data.data.send_sms,        sizeof(struct tel_sat_send_sms_tlv));\r
145                         break;\r
146                 case SAT_PROATV_CMD_SEND_SS:\r
147                         dbg("decoded command is send ss!!");\r
148                         memcpy(&proactive_noti.proactive_ind_data.send_ss, &decoded_data.data.send_ss,  sizeof(struct tel_sat_send_ss_tlv));\r
149                         break;\r
150                 case SAT_PROATV_CMD_SEND_USSD:\r
151                         dbg("decoded command is send ussd!!");\r
152                         memcpy(&proactive_noti.proactive_ind_data.send_ussd, &decoded_data.data.send_ussd,      sizeof(struct tel_sat_send_ussd_tlv));\r
153                         break;\r
154                 case SAT_PROATV_CMD_SETUP_CALL:\r
155                         dbg("decoded command is setup call!!");\r
156                         memcpy(&proactive_noti.proactive_ind_data.setup_call, &decoded_data.data.setup_call,    sizeof(struct tel_sat_setup_call_tlv));\r
157                         break;\r
158                 case SAT_PROATV_CMD_REFRESH:\r
159                         dbg("decoded command is refresh");\r
160                         memcpy(&proactive_noti.proactive_ind_data.refresh, &decoded_data.data.refresh, sizeof(struct tel_sat_refresh_tlv));\r
161                         break;  \r
162                 case SAT_PROATV_CMD_PROVIDE_LOCAL_INFO:\r
163                         dbg("decoded command is provide local info");\r
164                         memcpy(&proactive_noti.proactive_ind_data.provide_local_info, &decoded_data.data.provide_local_info, sizeof(struct tel_sat_provide_local_info_tlv));\r
165                         break;\r
166                 case SAT_PROATV_CMD_SETUP_EVENT_LIST:\r
167                         dbg("decoded command is setup event list!!");\r
168                         memcpy(&proactive_noti.proactive_ind_data.setup_event_list, &decoded_data.data.setup_event_list, sizeof(struct tel_sat_setup_event_list_tlv));\r
169                         //setup_event_rsp_get(o, &decoded_data.data.setup_event_list);\r
170                         break;\r
171                 case SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT:\r
172                         dbg("decoded command is setup idle mode text");\r
173                         memcpy(&proactive_noti.proactive_ind_data.setup_idle_mode_text, &decoded_data.data.setup_idle_mode_text,        sizeof(struct tel_sat_setup_idle_mode_text_tlv));\r
174                         break;\r
175                 case SAT_PROATV_CMD_SEND_DTMF:\r
176                         dbg("decoded command is send dtmf");\r
177                         memcpy(&proactive_noti.proactive_ind_data.send_dtmf, &decoded_data.data.send_dtmf,       sizeof(struct tel_sat_send_dtmf_tlv));\r
178                         break;\r
179                 case SAT_PROATV_CMD_LANGUAGE_NOTIFICATION:\r
180                         dbg("decoded command is language notification");\r
181                         memcpy(&proactive_noti.proactive_ind_data.language_notification, &decoded_data.data.language_notification,      sizeof(struct tel_sat_language_notification_tlv));\r
182                         break;\r
183                 case SAT_PROATV_CMD_LAUNCH_BROWSER:\r
184                         dbg("decoded command is launch browser");\r
185                         memcpy(&proactive_noti.proactive_ind_data.launch_browser, &decoded_data.data.launch_browser,    sizeof(struct tel_sat_launch_browser_tlv));\r
186                         break;\r
187                 case SAT_PROATV_CMD_OPEN_CHANNEL:\r
188                         dbg("decoded command is open channel!!");\r
189                         memcpy(&proactive_noti.proactive_ind_data.open_channel, &decoded_data.data.open_channel,        sizeof(struct tel_sat_open_channel_tlv));\r
190                         break;\r
191                 case SAT_PROATV_CMD_CLOSE_CHANNEL:\r
192                         dbg("decoded command is close channel!!");\r
193                         memcpy(&proactive_noti.proactive_ind_data.close_channel, &decoded_data.data.close_channel,      sizeof(struct tel_sat_close_channel_tlv));\r
194                         break;\r
195                 case SAT_PROATV_CMD_RECEIVE_DATA:\r
196                         dbg("decoded command is receive data!!");\r
197                         memcpy(&proactive_noti.proactive_ind_data.receive_data, &decoded_data.data.receive_data,        sizeof(struct tel_sat_receive_channel_tlv));\r
198                         break;\r
199                 case SAT_PROATV_CMD_SEND_DATA:\r
200                         dbg("decoded command is send data!!");\r
201                         memcpy(&proactive_noti.proactive_ind_data.send_data, &decoded_data.data.send_data,      sizeof(struct tel_sat_send_channel_tlv));\r
202                         break;\r
203                 case SAT_PROATV_CMD_GET_CHANNEL_STATUS:\r
204                         dbg("decoded command is get channel status!!");\r
205                         memcpy(&proactive_noti.proactive_ind_data.get_channel_status, &decoded_data.data.get_channel_status,    sizeof(struct tel_sat_get_channel_status_tlv));\r
206                         break;\r
207                 default:\r
208                         dbg("wrong input");\r
209                         break;\r
210         }\r
211         if((decoded_data.cmd_type == SAT_PROATV_CMD_REFRESH) || (decoded_data.cmd_type == SAT_PROATV_CMD_SETUP_EVENT_LIST))\r
212         {\r
213                 /*Not supported*/\r
214                 dbg("Not suported Proactive command");\r
215                 return FALSE;\r
216         }\r
217         tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SAT_PROACTIVE_CMD,\r
218                 sizeof(struct tnoti_sat_proactive_ind), &proactive_noti);\r
219         tcore_at_tok_free(tokens);\r
220         dbg("Function Exit");\r
221         return TRUE;\r
222 }\r
223 \r
224 static void on_response_envelop_cmd(TcorePending *p, int data_len, const void *data, void *user_data)\r
225 {\r
226         const TcoreATResponse           *resp = data;\r
227         UserRequest                             *ur = NULL;\r
228         CoreObject                                      *o = NULL;\r
229         const struct                            treq_sat_envelop_cmd_data       *req_data = NULL;\r
230         GSList                                          *tokens=NULL;\r
231         struct                                          tresp_sat_envelop_data          res;\r
232         const char                                      *line = NULL;\r
233         const char                                      *env_res = NULL;\r
234         int                                                     sw2 = -1;\r
235         \r
236         ur = tcore_pending_ref_user_request(p);\r
237         req_data = tcore_user_request_ref_data(ur, NULL);\r
238         o = tcore_pending_ref_core_object(p);\r
239 \r
240         if(!req_data){\r
241                 dbg("request data is NULL");\r
242                 return;\r
243         }\r
244         memset(&res, 0, sizeof(struct tresp_sat_envelop_data));\r
245 \r
246         res.sub_cmd = req_data->sub_cmd;\r
247 \r
248         if(resp->success > 0)\r
249         {\r
250                 dbg("RESPONSE OK");\r
251                 if(resp->lines) \r
252                 {\r
253                         line = (const char*)resp->lines->data;\r
254                         tokens = tcore_at_tok_new(line);\r
255                         if (g_slist_length(tokens) < 1) \r
256                         {\r
257                                 msg("invalid message");\r
258                                 tcore_at_tok_free(tokens);\r
259                                 return;\r
260                         }\r
261                 }\r
262                 env_res = g_slist_nth_data(tokens, 0);\r
263                 res.result = 0x8000;\r
264                 res.envelop_resp = ENVELOPE_SUCCESS;\r
265                 dbg("RESPONSE OK 3");\r
266                 if(NULL != g_slist_nth_data(tokens, 1))\r
267                 {\r
268                         sw2 = atoi(g_slist_nth_data(tokens, 1));\r
269                         dbg("RESPONSE OK 4");\r
270                         if(sw2 == 0)\r
271                         {\r
272                                 dbg("RESPONSE OK 5");\r
273                                 tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SAT_SESSION_END,    0, NULL);\r
274                         }\r
275                 }\r
276         }\r
277         else\r
278         {\r
279                 dbg("RESPONSE NOK");\r
280                 res.result = -1;\r
281                 res.envelop_resp = ENVELOPE_FAILED;\r
282         }\r
283         \r
284         if (ur) \r
285         {\r
286                         tcore_user_request_send_response(ur, TRESP_SAT_REQ_ENVELOPE, sizeof(struct tresp_sat_envelop_data), &res);\r
287         }\r
288         tcore_at_tok_free(tokens);\r
289         dbg(" Function exit");\r
290 }\r
291 \r
292 static void on_timeout_terminal_response(TcorePending *p, void *user_data)\r
293 {\r
294         UserRequest     *ur = NULL;\r
295         CoreObject      *o = NULL;\r
296         gpointer        tmp = NULL;\r
297 \r
298         dbg("Function Entry");\r
299         dbg("SAT - TIMEOUT !!!!! pending=%p", p);\r
300 \r
301         ur = tcore_pending_ref_user_request(p);\r
302         tmp = (gpointer)tcore_user_request_ref_communicator(ur);\r
303         if(!ur || !tmp )\r
304         {\r
305                 dbg("error - current ur is NULL");\r
306                 return;\r
307         }\r
308 \r
309         o = tcore_pending_ref_core_object(p);\r
310         if(!o)\r
311                 dbg("error - current sat core is NULL");\r
312 \r
313         tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SAT_SESSION_END,    0, NULL);\r
314         dbg("Function Exit");\r
315 }\r
316 \r
317 \r
318 static void on_response_terminal_response(TcorePending *p, int data_len, const void *data, void *user_data)\r
319 {\r
320         UserRequest                     *ur = NULL;\r
321         CoreObject                      *o = NULL;\r
322         const TcoreATResponse           *resp = data;\r
323         gpointer                        tmp = NULL;\r
324 \r
325         dbg("Function Entry");\r
326 \r
327         if(resp->success > 0)\r
328         {\r
329                 dbg("RESPONSE OK");\r
330                 dbg(" resp->success = %d",  resp->success);\r
331                 ur = tcore_pending_ref_user_request(p);\r
332                 tmp = (gpointer)tcore_user_request_ref_communicator(ur);\r
333                 if(!ur || !tmp )\r
334                 {\r
335                         dbg("error - current ur is NULL");\r
336                         return;\r
337                 }\r
338 \r
339                 o = tcore_pending_ref_core_object(p);\r
340                 if(!o)\r
341                         dbg("error - current sat core is NULL");\r
342                 tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SAT_SESSION_END,    0, NULL);\r
343         }\r
344         dbg("Function Exit");\r
345 }\r
346 \r
347 static  TReturn s_envelope(CoreObject *o, UserRequest *ur)\r
348 {\r
349         TcoreHal*                               hal;\r
350         TcoreATRequest                  *req = NULL;\r
351         TcorePending                    *pending = NULL;\r
352         char                                    *cmd_str = NULL;\r
353         const struct                    treq_sat_envelop_cmd_data       *req_data = NULL;\r
354         int                                     envelope_cmd_len = 0;\r
355         char                                    envelope_cmd[ENVELOPE_CMD_LEN];\r
356         int                                     count = 0;\r
357         char                                    envelope_cmdhex[ENVELOPE_CMD_LEN*2];\r
358         char                                    *pbuffer = NULL;\r
359 \r
360         dbg("Function Entry");\r
361         memset(&envelope_cmdhex, 0x00, sizeof(envelope_cmdhex));\r
362         pbuffer = envelope_cmdhex;\r
363 \r
364         hal = tcore_object_get_hal(o);\r
365         pending = tcore_pending_new(o, 0);\r
366         req_data = tcore_user_request_ref_data(ur, NULL);\r
367         dbg("new pending sub cmd(%d)", req_data->sub_cmd);\r
368 \r
369         envelope_cmd_len = tcore_sat_encode_envelop_cmd(req_data, (char *)envelope_cmd);\r
370                 \r
371         dbg("envelope_cmd_len %d", envelope_cmd_len);           \r
372         if(envelope_cmd_len == 0)\r
373         {\r
374                 return TCORE_RETURN_EINVAL;\r
375         }\r
376         for(count = 0; count < envelope_cmd_len ;count++ )\r
377         {\r
378                 dbg("envelope_cmd %02x", envelope_cmd[count]);\r
379                 sprintf(pbuffer, "%02x", envelope_cmd[count]);\r
380                 pbuffer +=2;\r
381         }\r
382         dbg("pbuffer %s", envelope_cmdhex);     \r
383         cmd_str = g_strdup_printf("AT+SATE=\"%s\"%s", envelope_cmdhex,"\r");\r
384         req = tcore_at_request_new(cmd_str, "+SATE:", TCORE_AT_SINGLELINE);\r
385         dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));\r
386 \r
387         tcore_pending_set_request_data(pending, 0, req);\r
388         tcore_pending_set_response_callback(pending, on_response_envelop_cmd, hal);\r
389         tcore_pending_link_user_request(pending, ur);\r
390         tcore_pending_set_send_callback(pending, on_confirmation_sat_message_send, NULL);\r
391         tcore_hal_send_request(hal, pending);\r
392         \r
393         dbg("Function Exit");\r
394         return TCORE_RETURN_SUCCESS;\r
395 }\r
396 \r
397 static  TReturn s_terminal_response(CoreObject *o, UserRequest *ur)\r
398 {\r
399         TcoreHal                                *hal = NULL;\r
400         TcoreATRequest                  *req = NULL;\r
401         TcorePending                    *pending = NULL;\r
402         char                                    *cmd_str = NULL;\r
403         const struct                    treq_sat_terminal_rsp_data *req_data = NULL;\r
404         int                                     proactive_resp_len = 0;\r
405         char                                    proactive_resp[ENVELOPE_CMD_LEN];\r
406         char                                    proactive_resphex[ENVELOPE_CMD_LEN*2];\r
407         char                                    *pbuffer = NULL;\r
408         int                                     i = 0;\r
409         char                                    *hexString = NULL;\r
410 \r
411         dbg("Function Entry");\r
412         memset(&proactive_resphex, 0x00, sizeof(proactive_resphex));\r
413         pbuffer = proactive_resphex;\r
414         hal = tcore_object_get_hal(o);\r
415         pending = tcore_pending_new(o, 0);\r
416         req_data = tcore_user_request_ref_data(ur, NULL);\r
417 \r
418         proactive_resp_len = tcore_sat_encode_terminal_response(req_data, (char *)proactive_resp);\r
419         dbg("proactive_resp %s", proactive_resp);\r
420         dbg("proactive_resp length %d", strlen(proactive_resp));\r
421         if(proactive_resp_len == 0)\r
422         {\r
423                 return TCORE_RETURN_EINVAL;\r
424         }\r
425         hexString = calloc((proactive_resp_len*2)+1, 1);\r
426 \r
427         for(i=0; i<proactive_resp_len*2; i+=2) \r
428         {\r
429                                 char value = 0;\r
430                                 value = (proactive_resp[i/2] & 0xf0) >> 4;\r
431                                 if(value < 0xA)\r
432                                         hexString[i] = ((proactive_resp[i/2] & 0xf0) >> 4) + '0';\r
433                                 else \r
434                                         hexString[i] = ((proactive_resp[i/2] & 0xf0) >> 4) + 'A' -10;\r
435 \r
436                                 value = proactive_resp[i/2] & 0x0f;\r
437                                 if(value < 0xA)\r
438                                         hexString[i+1] = (proactive_resp[i/2] & 0x0f) + '0';\r
439                                 else \r
440                                         hexString[i+1] = (proactive_resp[i/2] & 0x0f) + 'A' -10;\r
441         }\r
442 \r
443         dbg("hexString %s", hexString);\r
444         cmd_str = g_strdup_printf("AT+SATR=\"%s\"%s", hexString,"\r");\r
445 \r
446         req = tcore_at_request_new(cmd_str, NULL , TCORE_AT_NO_RESULT);\r
447         dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));\r
448 \r
449         tcore_pending_set_request_data(pending, 0, req);\r
450         tcore_pending_set_timeout(pending, 10);\r
451         tcore_pending_set_response_callback(pending, on_response_terminal_response, hal);\r
452         tcore_pending_set_timeout_callback(pending, on_timeout_terminal_response, NULL);\r
453         tcore_pending_link_user_request(pending, ur);\r
454         tcore_pending_set_send_callback(pending, on_confirmation_sat_message_send, NULL);\r
455         tcore_hal_send_request(hal, pending);\r
456 \r
457         dbg("Function Exit");\r
458         return TCORE_RETURN_SUCCESS;\r
459 }\r
460 \r
461 static struct tcore_sat_operations sat_ops =\r
462 {\r
463         .envelope = s_envelope,\r
464         .terminal_response = s_terminal_response,\r
465 };\r
466 \r
467 gboolean s_sat_init(TcorePlugin *p, TcoreHal *h)\r
468 {\r
469         CoreObject *o = NULL;\r
470 \r
471         dbg("Entry");\r
472         o = tcore_sat_new(p, "sat", &sat_ops,h);\r
473         if (!o)\r
474         {\r
475                 dbg("CoreObject NULL !!");\r
476                 return FALSE;\r
477         }\r
478         \r
479         tcore_object_add_callback(o, "+SATI", on_event_sat_proactive_command, NULL);\r
480         tcore_object_add_callback(o, "+SATN", on_event_sat_proactive_command, NULL);\r
481         tcore_object_add_callback(o, "+SATF", on_response_terminal_response_confirm, NULL);\r
482 \r
483         dbg("Exit");\r
484         return TRUE;\r
485 }\r
486 \r
487 void s_sat_exit(TcorePlugin *p)\r
488 {\r
489         CoreObject *o = NULL;\r
490         o = tcore_plugin_ref_core_object(p, "sat");\r
491         if (!o)\r
492                 return;\r
493         tcore_sat_free(o);\r
494 }\r