4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hayoon Ko <hayoon.ko@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.
29 #include <core_object.h>
34 #include <user_request.h>
39 #include "atchannel.h"
43 extern struct ATResponse *sp_response;
44 extern char *s_responsePrefix;
45 extern enum ATCommandType s_type;
48 struct CLCC_call_info_t {
50 enum tcore_call_direction direction;
51 enum tcore_call_status status;
52 enum tcore_call_type type;
61 static gboolean _call_request_message( CoreObject *o, UserRequest* ur, char* cmd_string,
62 unsigned int cmd_length, void* on_resp, void* user_data);
64 static void _call_status_idle( TcorePlugin *p, CallObject *co );
65 static void _call_status_active( TcorePlugin *p, CallObject *co );
66 static void _call_status_dialing( TcorePlugin *p, CallObject *co );
67 static void _call_status_alert( TcorePlugin *p, CallObject *co );
68 static void _call_status_incoming( TcorePlugin *p, CallObject *co );
69 static void _call_status_waiting( TcorePlugin *p, CallObject *co );
71 static void _call_branch_by_status( TcorePlugin *p, CallObject *co, unsigned int status );
72 static enum tcore_call_type _call_type( int type );
73 static enum tcore_call_status _call_status(unsigned int status);
74 static gboolean _call_is_in_mpty(int mpty);
76 static TReturn _call_list_get( CoreObject *o, CallObject *co );
78 static void on_confirmation_call_message_send( TcorePending *p, gboolean result, void *user_data ); // from Kernel
80 static void on_response_call_list_get(TcorePending *p, int data_len, const void *data, void *user_data);
81 static gboolean on_notification_call_waiting( CoreObject *o, const void *data, void *user_data );
82 static gboolean on_notification_call_incoming( CoreObject *o, const void *data, void *user_data );
83 static gboolean on_notification_call_status( CoreObject *o, const void *data, void *user_data);
86 static int _callFromCLCCLine(char *line, struct CLCC_call_t *p_call);
89 static enum tcore_call_cli_mode _get_clir_status( char *num )
91 enum tcore_call_cli_mode clir = CALL_CLI_MODE_DEFAULT;
93 if( !strncmp( num, "*31#", 4 ) )
94 return TCORE_CALL_CLI_MODE_RESTRICT;
96 if( !strncmp( num, "#31#", 4 ) )
97 return TCORE_CALL_CLI_MODE_PRESENT;
103 static enum tcore_call_status _call_status(unsigned int status)
108 return TCORE_CALL_STATUS_ACTIVE;
110 return TCORE_CALL_STATUS_HELD;
112 return TCORE_CALL_STATUS_DIALING;
114 return TCORE_CALL_STATUS_ALERT;
116 return TCORE_CALL_STATUS_INCOMING;
118 return TCORE_CALL_STATUS_WAITING;
120 return TCORE_CALL_STATUS_DIALING; //connecting not exist. set to dialing
122 return TCORE_CALL_STATUS_IDLE;
125 return TCORE_CALL_STATUS_IDLE;
129 return TCORE_CALL_STATUS_IDLE;
132 static gboolean _call_is_in_mpty(int mpty)
148 static enum tcore_call_type _call_type(int type )
152 return TCORE_CALL_TYPE_VOICE;
154 return TCORE_CALL_TYPE_VIDEO;
159 return TCORE_CALL_TYPE_VOICE;
162 static gboolean _call_request_message( CoreObject *o,
165 unsigned int cmd_len,
169 TcorePending *pending = NULL;
170 TcorePlugin *p = NULL;
173 unsigned int info_len = 0;
174 info_len = sizeof(struct ATReqMetaInfo);
176 dbg("_call_request_message - cmd : %s, cmdlen :%d (including '\r')",cmd_string, cmd_len);
179 pending = tcore_pending_new(o, ID_RESERVED_AT);
180 tcore_pending_set_request_data(pending, cmd_len, cmd_string);
181 tcore_pending_set_timeout(pending, 0);
182 tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
185 tcore_pending_set_response_callback(pending, on_resp, user_data);
187 tcore_pending_set_send_callback(pending, on_confirmation_call_message_send, NULL);
190 dbg("[ check ] ur is NULL, is this internal request??");
192 tcore_pending_link_user_request(pending, ur);
195 p = tcore_object_ref_plugin(o);
196 h = tcore_object_get_hal(o);
198 tcore_hal_send_request(h, pending);
203 static void _call_status_idle( TcorePlugin *p, CallObject *co )
205 struct tnoti_call_status_idle data;
207 dbg("call id [%d], call status [%d]", tcore_call_object_get_id(co), tcore_call_object_get_status(co));
209 if ( tcore_call_object_get_status( co ) != TCORE_CALL_STATUS_IDLE ) {
214 o = tcore_plugin_ref_core_object(p, "call");
216 data.type = tcore_call_object_get_type( co );
217 dbg("data.type : [%d]", data.type );
219 data.id = tcore_call_object_get_id( co );
220 dbg("data.id : [%d]", data.id );
222 tcore_call_object_set_status( co, TCORE_CALL_STATUS_IDLE );
224 tcore_server_send_notification( tcore_plugin_ref_server(p),
226 TNOTI_CALL_STATUS_IDLE,
227 sizeof(struct tnoti_call_status_idle),
230 tcore_call_object_free( o, co );
233 dbg("[ error ] call object was not free");
237 static void _call_status_dialing( TcorePlugin *p, CallObject *co )
241 struct tnoti_call_status_dialing data;
243 o = tcore_plugin_ref_core_object( p, "call");
245 if ( tcore_call_object_get_status( co ) != TCORE_CALL_STATUS_DIALING ) {
247 data.type = tcore_call_object_get_type( co );
248 dbg("data.type : [%d]", data.type );
250 data.id = tcore_call_object_get_id( co );
251 dbg("data.id : [%d]", data.id );
253 tcore_call_object_set_status( co, TCORE_CALL_STATUS_DIALING );
255 tcore_server_send_notification( tcore_plugin_ref_server(p),
256 tcore_plugin_ref_core_object(p, "call"),
257 TNOTI_CALL_STATUS_DIALING,
258 sizeof(struct tnoti_call_status_dialing),
264 _call_list_get( o, co );
268 static void _call_status_alert( TcorePlugin *p, CallObject *co )
271 struct tnoti_call_status_alert data;
273 o = tcore_plugin_ref_core_object( p, "call");
275 if ( tcore_call_object_get_status( co ) != TCORE_CALL_STATUS_ALERT ) {
277 data.type = tcore_call_object_get_type( co );
278 dbg("data.type : [%d]", data.type );
280 data.id = tcore_call_object_get_id( co );
281 dbg("data.id : [%d]", data.id );
283 tcore_call_object_set_status( co, TCORE_CALL_STATUS_ALERT );
285 tcore_server_send_notification( tcore_plugin_ref_server(p),
286 tcore_plugin_ref_core_object(p, "call"),
287 TNOTI_CALL_STATUS_ALERT,
288 sizeof(struct tnoti_call_status_alert),
294 _call_list_get( o, co );
298 static void _call_status_active( TcorePlugin *p, CallObject *co )
300 struct tnoti_call_status_active data;
302 if ( tcore_call_object_get_status( co ) != TCORE_CALL_STATUS_ACTIVE ) {
304 data.type = tcore_call_object_get_type( co );
305 dbg("data.type : [%d]", data.type );
307 data.id = tcore_call_object_get_id( co );
308 dbg("data.id : [%d]", data.id );
310 tcore_call_object_set_status( co, TCORE_CALL_STATUS_ACTIVE );
312 tcore_server_send_notification( tcore_plugin_ref_server(p),
313 tcore_plugin_ref_core_object(p, "call"),
314 TNOTI_CALL_STATUS_ACTIVE,
315 sizeof(struct tnoti_call_status_active),
321 static void _call_status_held( TcorePlugin *p, CallObject *co )
323 struct tnoti_call_status_held data;
325 if ( tcore_call_object_get_status( co ) != TCORE_CALL_STATUS_HELD ) {
327 data.type = tcore_call_object_get_type( co );
328 dbg("data.type : [%d]", data.type );
330 data.id = tcore_call_object_get_id( co );
331 dbg("data.id : [%d]", data.id );
333 tcore_call_object_set_status( co, TCORE_CALL_STATUS_HELD );
335 tcore_server_send_notification( tcore_plugin_ref_server(p),
336 tcore_plugin_ref_core_object(p, "call"),
337 TNOTI_CALL_STATUS_HELD,
338 sizeof(struct tnoti_call_status_held),
344 static void _call_status_incoming( TcorePlugin *p, CallObject *co )
346 struct tnoti_call_status_incoming data;
348 o = tcore_plugin_ref_core_object( p, "call");
350 if ( tcore_call_object_get_status( co ) != TCORE_CALL_STATUS_INCOMING ) {
352 tcore_call_object_set_status( co, TCORE_CALL_STATUS_INCOMING );
354 data.type = tcore_call_object_get_type( co );
355 dbg("data.type : [%d]", data.type );
357 data.id = tcore_call_object_get_id( co );
358 dbg("data.id : [%d]", data.id );
360 data.cli.mode = tcore_call_object_get_cli_mode( co );
361 dbg("data.cli.mode : [%d]", data.cli.mode );
363 tcore_call_object_get_number( co, data.cli.number );
364 dbg("data.cli.number : [%s]", data.cli.number );
366 data.cna.mode = tcore_call_object_get_cna_mode( co );
367 dbg("data.cna.mode : [%d]", data.cna.mode );
369 tcore_call_object_get_name( co, data.cna.name );
370 dbg("data.cna.name : [%s]", data.cna.name );
372 data.forward = FALSE; // this is tmp code
373 data.active_line = tcore_call_object_get_active_line( co );
374 dbg("data.active_line : [%d]", data.active_line );
376 tcore_server_send_notification( tcore_plugin_ref_server(p),
377 tcore_plugin_ref_core_object(p, "call"),
378 TNOTI_CALL_STATUS_INCOMING,
379 sizeof(struct tnoti_call_status_incoming),
384 _call_list_get( o, co );
389 static void _call_status_waiting( TcorePlugin *p, CallObject *co )
391 _call_status_incoming( p, co );
394 static void _call_branch_by_status( TcorePlugin *p, CallObject *co, unsigned int status )
397 case TCORE_CALL_STATUS_IDLE:
398 _call_status_idle( p, co );
401 case TCORE_CALL_STATUS_ACTIVE:
402 _call_status_active( p, co );
405 case TCORE_CALL_STATUS_HELD:
406 _call_status_held( p, co );
409 case TCORE_CALL_STATUS_DIALING:
410 _call_status_dialing( p, co );
413 case TCORE_CALL_STATUS_ALERT:
414 _call_status_alert( p, co );
417 case TCORE_CALL_STATUS_INCOMING:
418 _call_status_incoming( p, co );
421 case TCORE_CALL_STATUS_WAITING:
422 _call_status_waiting( p, co );
428 static TReturn _call_list_get( CoreObject *o, CallObject *co )
430 gboolean ret = FALSE;
431 UserRequest* ur = NULL;
433 char* cmd_str = NULL;
434 struct ATReqMetaInfo metainfo;
438 return TCORE_RETURN_FAILURE;
440 ur = tcore_user_request_new(NULL, NULL);
442 memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
444 metainfo.type = MULTILINE;
445 memcpy(metainfo.responsePrefix,"+CLCC:",strlen("+CLCC:"));
446 info_len = sizeof(struct ATReqMetaInfo);
447 tcore_user_request_set_metainfo(ur, info_len, &metainfo);
449 cmd_str = g_strdup("AT+CLCC\r");
451 ret = _call_request_message ( o, ur, cmd_str, strlen(cmd_str), on_response_call_list_get, NULL);
454 return TCORE_RETURN_FAILURE;
456 return TCORE_RETURN_SUCCESS;
464 static void on_confirmation_call_message_send( TcorePending *p, gboolean result, void *user_data )
466 UserRequest* ur = NULL;
467 struct ATReqMetaInfo* metainfo = NULL;
468 unsigned int info_len =0;
469 dbg("on_confirmation_call_message_send - msg out from queue. alloc ATRsp buffer & write rspPrefix if needed\n");
471 ReleaseResponse(); //release leftover
472 //alloc new sp_response
474 sp_response = at_response_new();
476 ur = tcore_pending_ref_user_request(p);
477 metainfo = (struct ATReqMetaInfo*)tcore_user_request_ref_metainfo(ur,&info_len);
479 if((metainfo->type == SINGLELINE)||
480 (metainfo->type == MULTILINE))
483 s_responsePrefix = strdup(metainfo->responsePrefix);
484 dbg("duplicating responsePrefix : %s\n", s_responsePrefix);
488 s_responsePrefix = NULL;
491 //set atcmd type into s_type
492 s_type = metainfo->type;
494 if (result == FALSE) {
503 static void on_confirmation_call_outgoing( TcorePending *p, int data_len, const void *data, void *user_data )
508 struct tresp_call_dial resp;
510 o = tcore_pending_ref_core_object(p);
511 ur = tcore_pending_ref_user_request(p);
513 if(sp_response->success >0)
514 resp.err = TCORE_RETURN_SUCCESS;
516 resp.err = TCORE_RETURN_FAILURE;
521 tcore_user_request_send_response(ur, TRESP_CALL_DIAL, sizeof(struct tresp_call_dial), &resp);
524 dbg("[ error ] ur is NULL");
529 static void on_confirmation_call_accept( TcorePending *p, int data_len, const void *data, void *user_data )
534 struct tresp_call_answer resp;
536 o = tcore_pending_ref_core_object(p);
537 ur = tcore_pending_ref_user_request(p);
539 if(sp_response->success >0)
540 resp.err = TCORE_RETURN_SUCCESS;
542 resp.err = TCORE_RETURN_FAILURE;
546 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
549 tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp);
552 dbg("[ error ] ur is NULL");
558 static void on_confirmation_call_reject( TcorePending *p, int data_len, const void *data, void *user_data )
563 struct tresp_call_answer resp;
565 o = tcore_pending_ref_core_object(p);
566 ur = tcore_pending_ref_user_request(p);
568 if(sp_response->success >0)
569 resp.err = TCORE_RETURN_SUCCESS;
571 resp.err = TCORE_RETURN_FAILURE;
575 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
578 tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp);
581 dbg("[ error ] ur is NULL");
586 static void on_confirmation_call_replace( TcorePending *p, int data_len, const void *data, void *user_data )
591 struct tresp_call_answer resp;
593 o = tcore_pending_ref_core_object(p);
594 ur = tcore_pending_ref_user_request(p);
596 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
598 if(sp_response->success >0)
599 resp.err = TCORE_RETURN_SUCCESS;
601 resp.err = TCORE_RETURN_FAILURE;
607 tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp);
610 dbg("[ error ] ur is NULL");
615 static void on_confirmation_call_hold_and_accept( TcorePending *p, int data_len, const void *data, void *user_data )
620 struct tresp_call_answer resp;
622 dbg("ok, function entrance");
624 o = tcore_pending_ref_core_object(p);
625 ur = tcore_pending_ref_user_request(p);
627 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
629 if(sp_response->success >0)
630 resp.err = TCORE_RETURN_SUCCESS;
632 resp.err = TCORE_RETURN_FAILURE;
638 tcore_user_request_send_response(ur, TRESP_CALL_ANSWER, sizeof(struct tresp_call_answer), &resp);
641 dbg("[ error ] ur is NULL");
650 l = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_ACTIVE );
652 dbg("[ error ] can't find active call");
656 co = (CallObject*)l->data;
658 dbg("[ error ] can't get active call object");
662 tcore_call_object_set_status( co, TCORE_CALL_STATUS_HELD );
666 static void on_confirmation_call_release_all( TcorePending *p, int data_len, const void *data, void *user_data )
671 struct tresp_call_end resp;
673 o = tcore_pending_ref_core_object(p);
674 ur = tcore_pending_ref_user_request(p);
677 resp.type = CALL_END_TYPE_ALL;
678 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
680 if(sp_response->success >0)
681 resp.err = TCORE_RETURN_SUCCESS;
683 resp.err = TCORE_RETURN_FAILURE;
688 tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp);
691 dbg("[ error ] ur is NULL");
698 static void on_confirmation_call_release_specific( TcorePending *p, int data_len, const void *data, void *user_data )
703 struct tresp_call_end resp;
705 o = tcore_pending_ref_core_object(p);
706 ur = tcore_pending_ref_user_request(p);
708 resp.type = CALL_END_TYPE_DEFAULT;
709 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
711 if(sp_response->success >0)
712 resp.err = TCORE_RETURN_SUCCESS;
714 resp.err = TCORE_RETURN_FAILURE;
719 tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp);
722 dbg("[ error ] ur is NULL");
727 static void on_confirmation_call_release_all_active( TcorePending *p, int data_len, const void *data, void *user_data )
732 struct tresp_call_end resp;
734 o = tcore_pending_ref_core_object(p);
735 ur = tcore_pending_ref_user_request(p);
737 resp.type = CALL_END_TYPE_ACTIVE_ALL;
738 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
740 if(sp_response->success >0)
741 resp.err = TCORE_RETURN_SUCCESS;
743 resp.err = TCORE_RETURN_FAILURE;
748 tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp);
751 dbg("[ error ] ur is NULL");
756 static void on_confirmation_call_release_all_held( TcorePending *p, int data_len, const void *data, void *user_data )
761 struct tresp_call_end resp;
763 o = tcore_pending_ref_core_object(p);
764 ur = tcore_pending_ref_user_request(p);
766 resp.type = CALL_END_TYPE_HOLD_ALL;
767 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
769 if(sp_response->success >0)
770 resp.err = TCORE_RETURN_SUCCESS;
772 resp.err = TCORE_RETURN_FAILURE;
777 tcore_user_request_send_response(ur, TRESP_CALL_END, sizeof(struct tresp_call_end), &resp);
780 dbg("[ error ] ur is NULL");
785 static void on_confirmation_call_hold( TcorePending *p, int data_len, const void *data, void *user_data )
790 struct tresp_call_hold resp;
792 dbg("ok, function entrance");
794 o = tcore_pending_ref_core_object(p);
795 ur = tcore_pending_ref_user_request(p);
797 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
799 if(sp_response->success >0)
800 resp.err = TCORE_RETURN_SUCCESS;
802 resp.err = TCORE_RETURN_FAILURE;
807 tcore_user_request_send_response(ur, TRESP_CALL_HOLD, sizeof(struct tresp_call_hold), &resp);
810 dbg("[ error ] ur is NULL");
819 active = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_ACTIVE );
821 dbg("[ error ] can't find active call");
825 co = (CallObject*)active->data;
827 dbg("[ error ] can't get active call object");
831 tcore_call_object_set_status( co, TCORE_CALL_STATUS_HELD );
836 static void on_confirmation_call_active( TcorePending *p, int data_len, const void *data, void *user_data )
841 struct tresp_call_active resp;
843 o = tcore_pending_ref_core_object(p);
844 ur = tcore_pending_ref_user_request(p);
846 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
848 if(sp_response->success >0)
849 resp.err = TCORE_RETURN_SUCCESS;
851 resp.err = TCORE_RETURN_FAILURE;
856 tcore_user_request_send_response(ur, TRESP_CALL_ACTIVE, sizeof(struct tresp_call_active), &resp);
859 dbg("[ error ] ur is NULL");
865 static void on_confirmation_call_swap( TcorePending *p, int data_len, const void *data, void *user_data )
870 struct tresp_call_swap resp;
872 dbg("ok, function entrance");
874 o = tcore_pending_ref_core_object(p);
875 ur = tcore_pending_ref_user_request(p);
877 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
879 if(sp_response->success >0)
880 resp.err = TCORE_RETURN_SUCCESS;
882 resp.err = TCORE_RETURN_FAILURE;
887 tcore_user_request_send_response(ur, TRESP_CALL_SWAP, sizeof(struct tresp_call_swap), &resp);
890 dbg("[ error ] ur is NULL");
896 GSList *active = 0, *held = 0;
899 held = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_HELD );
901 dbg("[ error ] can't find held call");
905 active = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_ACTIVE );
907 dbg("[ error ] can't find active call");
911 co = (CallObject*)held->data;
913 dbg("[ error ] can't get held call object");
917 resp.id = tcore_call_object_get_id( co );
918 tcore_call_object_set_status( co, TCORE_CALL_STATUS_ACTIVE );
920 tcore_user_request_send_response(ur, TRESP_CALL_ACTIVE, sizeof(struct tresp_call_active), &resp);
922 co = (CallObject*)active->data;
924 dbg("[ error ] can't get active call object");
928 resp.id = tcore_call_object_get_id( co );
929 tcore_call_object_set_status( co, TCORE_CALL_STATUS_HELD );
931 tcore_user_request_send_response(ur, TRESP_CALL_HOLD, sizeof(struct tresp_call_hold), &resp);
935 static void on_confirmation_call_join( TcorePending *p, int data_len, const void *data, void *user_data )
940 struct tresp_call_join resp;
942 o = tcore_pending_ref_core_object(p);
943 ur = tcore_pending_ref_user_request(p);
945 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
947 if(sp_response->success >0)
948 resp.err = TCORE_RETURN_SUCCESS;
950 resp.err = TCORE_RETURN_FAILURE;
955 tcore_user_request_send_response(ur, TRESP_CALL_JOIN, sizeof(struct tresp_call_join), &resp);
958 dbg("[ error ] ur is NULL");
963 static void on_confirmation_call_split( TcorePending *p, int data_len, const void *data, void *user_data )
969 struct tresp_call_split resp;
971 dbg("ok, function entrance");
973 o = tcore_pending_ref_core_object(p);
974 ur = tcore_pending_ref_user_request(p);
976 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
978 if(sp_response->success >0)
979 resp.err = TCORE_RETURN_SUCCESS;
981 resp.err = TCORE_RETURN_FAILURE;
986 tcore_user_request_send_response(ur, TRESP_CALL_SPLIT, sizeof(struct tresp_call_split), &resp);
989 dbg("[ error ] ur is NULL");
998 active = tcore_call_object_find_by_status( o, TCORE_CALL_STATUS_ACTIVE );
1000 dbg("[ error ] can't find active call");
1004 co = (CallObject*)active->data;
1006 dbg("[ error ] can't get active call object");
1010 tcore_call_object_set_status( co, TCORE_CALL_STATUS_HELD );
1011 tcore_call_object_set_status( (CallObject*)user_data, TCORE_CALL_STATUS_ACTIVE );
1015 static void on_confirmation_call_deflect( TcorePending *p, int data_len, const void *data, void *user_data )
1018 UserRequest *ur = 0;
1020 struct tresp_call_deflect resp;
1022 o = tcore_pending_ref_core_object(p);
1023 ur = tcore_pending_ref_user_request(p);
1025 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
1027 if(sp_response->success >0)
1028 resp.err = TCORE_RETURN_SUCCESS;
1030 resp.err = TCORE_RETURN_FAILURE;
1035 tcore_user_request_send_response(ur, TRESP_CALL_DEFLECT, sizeof(struct tresp_call_deflect), &resp);
1038 dbg("[ error ] ur is NULL");
1043 static void on_confirmation_call_transfer( TcorePending *p, int data_len, const void *data, void *user_data )
1046 UserRequest *ur = 0;
1048 struct tresp_call_transfer resp;
1050 o = tcore_pending_ref_core_object(p);
1051 ur = tcore_pending_ref_user_request(p);
1053 resp.id = tcore_call_object_get_id( (CallObject*)user_data );
1055 if(sp_response->success >0)
1056 resp.err = TCORE_RETURN_SUCCESS;
1058 resp.err = TCORE_RETURN_FAILURE;
1063 tcore_user_request_send_response(ur, TRESP_CALL_TRANSFER, sizeof(struct tresp_call_transfer), &resp);
1066 dbg("[ error ] ur is NULL");
1072 static void on_confirmation_call_endall( TcorePending *p, int data_len, const void *data, void *user_data )
1075 UserRequest* ur = 0;
1077 dbg("on_confirmation_call_endall - 1st result. wait for final result");
1080 o = tcore_pending_ref_core_object(p);
1081 ur = tcore_pending_ref_user_request(p);
1083 //skip response handling - actual result will be handled in on_confirmation_call_request
1089 static void on_response_call_list_get(TcorePending *p, int data_len, const void *data, void *user_data)
1091 TcorePlugin* plugin = 0;
1094 struct ATLine *p_cur;
1097 struct CLCC_call_t* call_list = 0;
1099 int i = 0, countCalls =0, countValidCalls =0, err =0;
1102 plugin = tcore_pending_ref_plugin( p );
1103 o = tcore_pending_ref_core_object( p );
1108 if(sp_response->success > 0)
1111 /* count the calls */
1112 for (countCalls = 0, p_cur = sp_response->p_intermediates
1114 ; p_cur = p_cur->p_next
1118 dbg("total calls : %d",countCalls);
1123 call_list = g_new0( struct CLCC_call_t, countCalls);
1126 for (countValidCalls = 0, p_cur = sp_response->p_intermediates
1128 ; p_cur = p_cur->p_next)
1131 err = _callFromCLCCLine( p_cur->line, call_list + countValidCalls );
1137 co = tcore_call_object_find_by_id( o, call_list[i].info.id );
1139 co = tcore_call_object_new( o, call_list[i].info.id );
1141 dbg("error : tcore_call_object_new [ id : %d ]", call_list[i].info.id);
1146 tcore_call_object_set_type( co, _call_type( call_list[i].info.type ) );
1147 tcore_call_object_set_direction( co, call_list[i].info.direction );
1148 tcore_call_object_set_multiparty_state( co, _call_is_in_mpty(call_list[i].info.mpty) );
1149 tcore_call_object_set_cli_info( co, CALL_CLI_MODE_DEFAULT, call_list[i].number );
1151 _call_branch_by_status( plugin, co, call_list[i].info.status );
1159 static int _callFromCLCCLine(char *line, struct CLCC_call_t*p_call)
1161 //+CLCC: 1,0,2,0,0,\"+18005551212\",145
1162 // index,isMT,state,mode,isMpty(,number,TOA)?
1170 err = at_tok_start(&line);
1171 if (err < 0) goto error;
1174 err = at_tok_nextint(&line, &(p_call->info.id));
1175 if (err < 0) goto error;
1176 dbg("id : [%d]\n", p_call->info.id );
1178 err = at_tok_nextint(&line, &isMT);
1179 if (err < 0) goto error;
1182 p_call->info.direction = TCORE_CALL_DIRECTION_OUTGOING;
1184 p_call->info.direction = TCORE_CALL_DIRECTION_INCOMING;
1186 dbg("direction : [ %d ]\n", p_call->info.direction);
1189 err = at_tok_nextint(&line, &state);
1190 if (err < 0) goto error;
1194 p_call->info.status = TCORE_CALL_STATUS_ACTIVE;
1197 p_call->info.status = TCORE_CALL_STATUS_HELD;
1200 p_call->info.status = TCORE_CALL_STATUS_DIALING;
1203 p_call->info.status = TCORE_CALL_STATUS_ALERT;
1206 p_call->info.status = TCORE_CALL_STATUS_INCOMING;
1209 p_call->info.status = TCORE_CALL_STATUS_WAITING;
1212 dbg("status : [%d]\n", p_call->info.status );
1215 err = at_tok_nextint(&line, &mode);
1216 if (err < 0) goto error;
1221 p_call->info.type = TCORE_CALL_TYPE_VOICE;
1225 p_call->info.type = TCORE_CALL_TYPE_VIDEO;
1228 default: // only Voice/VT call is supported in CS. treat other unknown calls as error
1229 dbg("invalid type : [%d]\n", mode );
1233 dbg("type : [%d]\n", p_call->info.type );
1236 err = at_tok_nextint(&line, &(p_call->info.mpty));
1237 if (err < 0) goto error;
1238 dbg("mpty : [%d]\n", p_call->info.mpty );
1240 if (at_tok_hasmore(&line)) {
1241 err = at_tok_nextstr(&line, &num);
1243 /* tolerate null here */
1244 if (err < 0) return 0;
1246 memcpy(p_call->number, num, strlen(num));
1247 dbg("number : [ %s ]\n", p_call->number );
1249 p_call->info.num_len = strlen(num);
1250 dbg("num_len : [0x%x]\n", p_call->info.num_len );
1252 err = at_tok_nextint(&line, &(p_call->info.num_type));
1253 if (err < 0) goto error;
1254 dbg("num_type : [0x%x]\n", p_call->info.num_type );
1261 err("invalid CLCC line\n");
1267 static gboolean on_notification_call_waiting( CoreObject *o, const void *data, void *user_data )
1269 TcorePlugin* plugin = NULL;
1270 char* cmd = NULL, *num = NULL;
1271 CallObject *co, *dupco = 0;
1272 int id, status, err, type, mpty,direction;
1273 GSList* pList = NULL;
1274 #define LINE_DEFAULT 0
1276 dbg("call waiting noti : %s", cmd);
1277 plugin = tcore_object_ref_plugin(o);
1283 err = at_tok_nextint(&cmd,&id);
1284 err = at_tok_nextint(&cmd,&direction);
1285 err = at_tok_nextint(&cmd,&status);
1286 err = at_tok_nextint(&cmd,&type);
1287 err = at_tok_nextint(&cmd,&mpty);
1289 if(at_tok_hasmore(&cmd)){
1290 err = at_tok_nextstr(&cmd,&num);
1291 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : %s", id,direction,status, type, mpty, num);
1294 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty);
1296 // check call with incoming status already exist
1297 pList = tcore_call_object_find_by_status(o, TCORE_CALL_STATUS_WAITING);
1299 dbg("waiting call already exist. skip");
1303 pList = tcore_call_object_find_by_status(o, TCORE_CALL_STATUS_INCOMING);
1305 dbg("incoming call already exist. skip");
1309 dupco = tcore_call_object_find_by_id(o, id);
1311 dbg("co with same id already exist. skip");
1315 // make new co, add to list
1316 co = tcore_call_object_new( o, id);
1318 dbg("[ error ] co is NULL");
1322 tcore_call_object_set_type(co, _call_type(type));
1323 tcore_call_object_set_multiparty_state(co,_call_is_in_mpty(mpty));
1324 tcore_call_object_set_direction(co, TCORE_CALL_DIRECTION_INCOMING);
1325 tcore_call_object_set_cli_info(co, TCORE_CALL_CLI_MODE_DEFAULT, num);
1326 tcore_call_object_set_active_line(co, LINE_DEFAULT);
1328 _call_list_get( o, co );
1333 static gboolean on_notification_call_incoming( CoreObject *o, const void *data, void *user_data )
1335 TcorePlugin* plugin = NULL;
1336 char* cmd = NULL, *num = NULL;
1337 CallObject *co, *dupco = 0;
1338 int id, status, err, type, mpty,direction;
1339 GSList* pList = NULL;
1340 #define LINE_DEFAULT 0
1342 dbg("call incoming noti : %s", cmd);
1343 plugin = tcore_object_ref_plugin(o);
1349 err = at_tok_nextint(&cmd,&id);
1350 err = at_tok_nextint(&cmd,&direction);
1351 err = at_tok_nextint(&cmd,&status);
1352 err = at_tok_nextint(&cmd,&type);
1353 err = at_tok_nextint(&cmd,&mpty);
1355 if(at_tok_hasmore(&cmd)) {
1356 err = at_tok_nextstr(&cmd,&num);
1357 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : %s", id,direction,status, type, mpty, num);
1360 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty);
1362 // check call with incoming status already exist
1363 pList = tcore_call_object_find_by_status(o, TCORE_CALL_STATUS_INCOMING);
1365 dbg("incoming call already exist. skip");
1369 dupco = tcore_call_object_find_by_id(o, id);
1371 dbg("co with same id already exist. skip");
1375 // make new co, add to list
1376 co = tcore_call_object_new( o, id);
1378 dbg("[ error ] co is NULL");
1382 tcore_call_object_set_type(co, _call_type(type));
1383 tcore_call_object_set_multiparty_state(co,_call_is_in_mpty(mpty));
1384 tcore_call_object_set_direction(co, TCORE_CALL_DIRECTION_INCOMING);
1385 tcore_call_object_set_cli_info(co, TCORE_CALL_CLI_MODE_DEFAULT, num);
1386 tcore_call_object_set_active_line(co, LINE_DEFAULT);
1388 _call_list_get( o, co );
1393 static gboolean on_notification_call_status( CoreObject *o, const void *data, void *user_data)
1395 char* cmd = NULL, *num = NULL;
1398 int id, status, type, mpty,direction;
1401 enum tcore_call_status co_status;
1403 p = tcore_object_ref_plugin( o );
1408 err = at_tok_nextint(&cmd,&id);
1409 err = at_tok_nextint(&cmd,&direction);
1410 err = at_tok_nextint(&cmd,&status);
1411 err = at_tok_nextint(&cmd,&type);
1412 err = at_tok_nextint(&cmd,&mpty);
1414 if (at_tok_hasmore(&cmd)) {
1415 err = at_tok_nextstr(&cmd,&num);
1416 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : %s", id,direction,status, type, mpty, num);
1419 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty);
1422 co_status = _call_status(status);
1424 switch (co_status) {
1425 case CALL_STATUS_ACTIVE:{
1427 dbg("call(%d) status : [ ACTIVE ]", id);
1428 co = tcore_call_object_find_by_id(o,id);
1433 _call_status_active( p, co );
1436 case CALL_STATUS_HELD:
1438 case CALL_STATUS_DIALING:
1440 dbg("call(%d) status : [ dialing ]", id);
1441 co = tcore_call_object_find_by_id(o,id);
1443 co = tcore_call_object_new( o, id );
1445 dbg("error : tcore_call_object_new [ id : %d ]", id);
1450 tcore_call_object_set_type( co, _call_type(type) );
1451 tcore_call_object_set_direction( co, TCORE_CALL_DIRECTION_OUTGOING );
1453 _call_status_dialing( p, co );
1456 case CALL_STATUS_ALERT:
1459 dbg("call(%d) status : [ alert ]", id);
1460 co = tcore_call_object_find_by_id(o, id);
1466 _call_list_get( o, co );
1469 case CALL_STATUS_INCOMING:
1470 case CALL_STATUS_WAITING:
1472 case CALL_STATUS_IDLE: {
1474 dbg("call(%d) status : [ release ]", id);
1476 co = tcore_call_object_find_by_id( o, id );
1480 p = tcore_object_ref_plugin( o );
1482 dbg("plugin is NULL");
1484 _call_status_idle( p, co );
1495 static TReturn s_call_outgoing( CoreObject *o, UserRequest *ur )
1497 TcorePlugin* p = NULL;
1499 struct treq_call_dial* data = 0;
1500 char* raw_str= NULL;
1501 char* cmd_str = NULL;
1503 struct ATReqMetaInfo metainfo;
1505 enum tcore_call_cli_mode clir = CALL_CLI_MODE_DEFAULT;
1507 gboolean ret = FALSE;
1509 data = (struct treq_call_dial*)tcore_user_request_ref_data( ur, 0 );
1510 p = tcore_object_ref_plugin( o );
1512 clir = _get_clir_status( data->number );
1514 //Compose ATCmd string
1517 case TCORE_CALL_CLI_MODE_PRESENT:
1519 break; /*invocation*/
1520 case TCORE_CALL_CLI_MODE_RESTRICT:
1522 break; /*suppression*/
1523 case TCORE_CALL_CLI_MODE_DEFAULT:
1526 break; /*subscription default*/
1529 raw_str = g_strdup_printf("ATD%s%s;", data->number, cclir);
1530 cmd_str = g_strdup_printf("%s%s",raw_str,"\r");
1532 memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1535 metainfo.type = NO_RESULT;
1536 metainfo.responsePrefix[0] ='\0';
1537 info_len = sizeof(struct ATReqMetaInfo);
1539 tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1541 ret = _call_request_message ( o, ur, cmd_str, strlen(cmd_str), on_confirmation_call_outgoing, co);
1547 tcore_call_object_free( o, co );
1548 return TCORE_RETURN_FAILURE;
1551 return TCORE_RETURN_SUCCESS;
1554 static TReturn s_call_answer( CoreObject *o, UserRequest *ur )
1557 struct treq_call_answer* data = 0;
1558 gboolean ret = FALSE;
1559 char* cmd_str = NULL;
1560 struct ATReqMetaInfo metainfo ;
1561 unsigned int info_len =0;
1563 data = (struct treq_call_answer*)tcore_user_request_ref_data( ur, 0 );
1565 co = tcore_call_object_find_by_id( o, data->id );
1567 memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1570 metainfo.type = NO_RESULT;
1571 metainfo.responsePrefix[0] = '\0';
1572 info_len = sizeof(struct ATReqMetaInfo);
1574 tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1576 if ( data->type == CALL_ANSWER_TYPE_ACCEPT ) {
1578 cmd_str = g_strdup_printf("%s%s","ATA","\r");
1579 ret = _call_request_message ( o, ur, (void*)cmd_str, strlen(cmd_str), on_confirmation_call_accept, co);
1582 return TCORE_RETURN_FAILURE;
1586 switch ( data->type ) {
1587 case CALL_ANSWER_TYPE_REJECT: {
1588 dbg("call answer reject");
1589 tcore_call_control_answer_reject( o, ur, on_confirmation_call_reject, co );
1592 case CALL_ANSWER_TYPE_REPLACE: {
1593 dbg("call answer replace");
1594 tcore_call_control_answer_replace( o, ur, on_confirmation_call_replace, co );
1597 case CALL_ANSWER_TYPE_HOLD_ACCEPT: {
1598 dbg("call answer hold and accept");
1599 tcore_call_control_answer_hold_and_accept( o, ur, on_confirmation_call_hold_and_accept, co );
1603 dbg("[ error ] wrong answer type [ %d ]", data->type);
1604 return TCORE_RETURN_FAILURE;
1608 return TCORE_RETURN_SUCCESS;
1611 static TReturn s_call_release( CoreObject *o, UserRequest *ur )
1615 struct treq_call_end* data = 0;
1616 gboolean ret = FALSE;
1617 UserRequest* ur_dup = 0;
1619 char* chld0_cmd = NULL;
1620 char* chld1_cmd = NULL;
1621 struct ATReqMetaInfo metainfo1 ;
1622 struct ATReqMetaInfo metainfo2 ;
1623 unsigned int info_len1, info_len2 =0;
1625 data = (struct treq_call_end*)tcore_user_request_ref_data( ur, 0 );
1627 co = tcore_call_object_find_by_id( o, data->id );
1629 if ( data->type == CALL_END_TYPE_ALL ) {
1631 //releaseAll do not exist on legacy request. send CHLD=0, CHLD=1 in sequence
1632 chld0_cmd = g_strdup("AT+CHLD=0\r");
1633 chld1_cmd = g_strdup("AT+CHLD=1\r");
1635 memset(&metainfo1, 0, sizeof(struct ATReqMetaInfo));
1636 memset(&metainfo2, 0, sizeof(struct ATReqMetaInfo));
1640 metainfo1.type = NO_RESULT;
1641 metainfo1.responsePrefix[0] = '\0';
1642 info_len1 = sizeof(struct ATReqMetaInfo);
1645 metainfo2.type = NO_RESULT;
1646 metainfo2.responsePrefix[0] = '\0';
1647 info_len2 = sizeof(struct ATReqMetaInfo);
1649 ur_dup = tcore_user_request_new(NULL, NULL);
1651 tcore_user_request_set_metainfo(ur_dup, info_len1, &metainfo1);
1652 tcore_user_request_set_metainfo(ur, info_len2, &metainfo2);
1654 ret = _call_request_message(o, ur_dup, chld0_cmd, strlen(chld0_cmd), on_confirmation_call_endall, NULL);
1657 return TCORE_RETURN_FAILURE;
1659 ret = _call_request_message(o, ur, chld1_cmd, strlen(chld1_cmd), on_confirmation_call_release_all, co);
1662 return TCORE_RETURN_FAILURE;
1666 switch ( data->type ) {
1667 case CALL_END_TYPE_DEFAULT: {
1669 id = tcore_call_object_get_id( co );
1671 dbg("call end call id [%d]", id);
1672 tcore_call_control_end_specific( o, ur, id, on_confirmation_call_release_specific, co );
1675 case CALL_END_TYPE_ACTIVE_ALL: {
1677 dbg("call end all active");
1678 tcore_call_control_end_all_active( o, ur, on_confirmation_call_release_all_active, co );
1681 case TCORE_CALL_END_ALL_HELD: {
1683 dbg("call end all held");
1684 tcore_call_control_end_all_held( o, ur, on_confirmation_call_release_all_held, co );
1688 dbg("[ error ] wrong end type [ %d ]", data->type);
1689 return TCORE_RETURN_FAILURE;
1694 return TCORE_RETURN_SUCCESS;
1697 static TReturn s_call_hold( CoreObject *o, UserRequest *ur )
1699 struct treq_call_hold *hold = 0;
1702 hold = (struct treq_call_hold*)tcore_user_request_ref_data( ur, 0 );
1704 dbg("call id : [ %d ]", hold->id);
1706 co = tcore_call_object_find_by_id( o, hold->id );
1708 tcore_call_control_hold( o, ur, on_confirmation_call_hold, co );
1710 return TCORE_RETURN_SUCCESS;
1713 static TReturn s_call_active( CoreObject *o, UserRequest *ur )
1715 struct treq_call_active *active = 0;
1718 active = (struct treq_call_active*)tcore_user_request_ref_data( ur, 0 );
1720 dbg("call id : [ %d ]", active->id);
1722 co = tcore_call_object_find_by_id( o, active->id );
1724 tcore_call_control_active( o, ur, on_confirmation_call_active, co );
1726 return TCORE_RETURN_SUCCESS;
1729 static TReturn s_call_swap( CoreObject *o, UserRequest *ur )
1731 struct treq_call_swap *swap = 0;
1733 swap = (struct treq_call_swap*)tcore_user_request_ref_data( ur, 0 );
1735 dbg("call id : [ %d ]", swap->id);
1737 co = tcore_call_object_find_by_id( o, swap->id );
1739 tcore_call_control_swap( o, ur, on_confirmation_call_swap, co );
1741 return TCORE_RETURN_SUCCESS;
1744 static TReturn s_call_join( CoreObject *o, UserRequest *ur )
1746 struct treq_call_join *join = 0;
1749 join = (struct treq_call_join*)tcore_user_request_ref_data( ur, 0 );
1751 dbg("call id : [ %d ]", join->id);
1753 co = tcore_call_object_find_by_id( o, join->id );
1755 tcore_call_control_join( o, ur, on_confirmation_call_join, co );
1757 return TCORE_RETURN_SUCCESS;
1760 static TReturn s_call_split( CoreObject *o, UserRequest *ur )
1762 struct treq_call_split *split = 0;
1765 split = (struct treq_call_split*)tcore_user_request_ref_data( ur, 0 );
1767 co = tcore_call_object_find_by_id ( o, split->id );
1769 tcore_call_control_split( o, ur, split->id, on_confirmation_call_split, co );
1771 return TCORE_RETURN_SUCCESS;
1774 static TReturn s_call_deflect( CoreObject *o, UserRequest *ur )
1776 struct treq_call_deflect *deflect = 0;
1779 deflect = (struct treq_call_deflect*)tcore_user_request_ref_data( ur, 0 );
1781 co = tcore_call_object_find_by_number( o, deflect->number );
1783 tcore_call_control_deflect( o, ur, deflect->number, on_confirmation_call_deflect, co );
1785 return TCORE_RETURN_SUCCESS;
1788 static TReturn s_call_transfer( CoreObject *o, UserRequest *ur )
1790 struct treq_call_transfer *transfer = 0;
1793 transfer = (struct treq_call_transfer*)tcore_user_request_ref_data( ur, 0 );
1795 dbg("call id : [ %d ]", transfer->id);
1797 co = tcore_call_object_find_by_id( o, transfer->id );
1799 tcore_call_control_transfer( o, ur, on_confirmation_call_transfer, co );
1801 return TCORE_RETURN_SUCCESS;
1804 static TReturn s_call_send_dtmf( CoreObject *o, UserRequest *ur )
1806 return TCORE_RETURN_SUCCESS;
1809 static TReturn s_call_set_sound_path( CoreObject *o, UserRequest *ur )
1812 return TCORE_RETURN_SUCCESS;
1815 static TReturn s_call_set_sound_volume_level( CoreObject *o, UserRequest *ur )
1818 return TCORE_RETURN_SUCCESS;
1821 static TReturn s_call_get_sound_volume_level( CoreObject *o, UserRequest *ur )
1824 return TCORE_RETURN_SUCCESS;
1827 static TReturn s_call_mute( CoreObject *o, UserRequest *ur )
1830 return TCORE_RETURN_SUCCESS;
1833 static TReturn s_call_unmute( CoreObject *o, UserRequest *ur )
1836 return TCORE_RETURN_SUCCESS;
1839 static TReturn s_call_get_mute_status( CoreObject *o, UserRequest *ur )
1842 return TCORE_RETURN_SUCCESS;
1845 static struct tcore_call_operations call_ops = {
1846 .dial = s_call_outgoing,
1847 .answer = s_call_answer,
1848 .end = s_call_release,
1849 .hold = s_call_hold,
1850 .active = s_call_active,
1851 .swap = s_call_swap,
1852 .join = s_call_join,
1853 .split = s_call_split,
1854 .deflect = s_call_deflect,
1855 .transfer = s_call_transfer,
1856 .send_dtmf = s_call_send_dtmf,
1857 .set_sound_path = s_call_set_sound_path,
1858 .set_sound_volume_level = s_call_set_sound_volume_level,
1859 .get_sound_volume_level = s_call_get_sound_volume_level,
1860 .mute = s_call_mute,
1861 .unmute = s_call_unmute,
1862 .get_mute_status = s_call_get_mute_status,
1866 static void s_call_info_mo_waiting( CoreObject *o )
1872 p = tcore_object_ref_plugin(o);
1874 co = tcore_call_object_current_on_mo_processing( o );
1876 dbg("[ error ] can't find call object!");
1880 id = tcore_call_object_get_id( co );
1882 tcore_server_send_notification( tcore_plugin_ref_server(p),
1883 tcore_plugin_ref_core_object(p, "call"),
1884 TNOTI_CALL_INFO_WAITING,
1885 sizeof(unsigned int),
1889 static void s_call_info_mo_forwarded( CoreObject *o )
1895 p = tcore_object_ref_plugin(o);
1897 co = tcore_call_object_current_on_mo_processing( o );
1899 dbg("[ error ] can't find call object!");
1902 id = tcore_call_object_get_id( co );
1904 tcore_server_send_notification( tcore_plugin_ref_server(p),
1905 tcore_plugin_ref_core_object(p, "call"),
1906 TNOTI_CALL_INFO_FORWARDED,
1907 sizeof(unsigned int),
1911 static void s_call_info_mo_barred_incoming( CoreObject *o )
1917 p = tcore_object_ref_plugin(o);
1919 co = tcore_call_object_current_on_mo_processing( o );
1921 dbg("[ error ] can't find call object!");
1924 id = tcore_call_object_get_id( co );
1926 tcore_server_send_notification( tcore_plugin_ref_server(p),
1927 tcore_plugin_ref_core_object(p, "call"),
1928 TNOTI_CALL_INFO_BARRED_INCOMING,
1929 sizeof(unsigned int),
1933 static void s_call_info_mo_barred_outgoing( CoreObject *o )
1939 p = tcore_object_ref_plugin(o);
1941 co = tcore_call_object_current_on_mo_processing( o );
1943 dbg("[ error ] can't find call object!");
1946 id = tcore_call_object_get_id( co );
1948 tcore_server_send_notification( tcore_plugin_ref_server(p),
1949 tcore_plugin_ref_core_object(p, "call"),
1950 TNOTI_CALL_INFO_BARRED_OUTGOING,
1951 sizeof(unsigned int),
1955 static void s_call_info_mo_deflected( CoreObject *o )
1961 p = tcore_object_ref_plugin(o);
1963 co = tcore_call_object_current_on_mo_processing( o );
1965 dbg("[ error ] can't find call object!");
1968 id = tcore_call_object_get_id( co );
1970 tcore_server_send_notification( tcore_plugin_ref_server(p),
1971 tcore_plugin_ref_core_object(p, "call"),
1972 TNOTI_CALL_INFO_DEFLECTED,
1973 sizeof(unsigned int),
1977 static void s_call_info_mo_clir_suppression_reject( CoreObject *o )
1983 p = tcore_object_ref_plugin(o);
1985 co = tcore_call_object_current_on_mo_processing( o );
1987 dbg("[ error ] can't find call object!");
1990 id = tcore_call_object_get_id( co );
1992 tcore_server_send_notification( tcore_plugin_ref_server(p),
1993 tcore_plugin_ref_core_object(p, "call"),
1994 TNOTI_CALL_INFO_CLIR_SUPPRESSION_REJECT,
1995 sizeof(unsigned int),
1999 static void s_call_info_mo_cfu( CoreObject *o )
2005 p = tcore_object_ref_plugin(o);
2007 co = tcore_call_object_current_on_mo_processing( o );
2009 dbg("[ error ] can't find call object!");
2012 id = tcore_call_object_get_id( co );
2014 tcore_server_send_notification( tcore_plugin_ref_server(p),
2015 tcore_plugin_ref_core_object(p, "call"),
2016 TNOTI_CALL_INFO_FORWARD_UNCONDITIONAL,
2017 sizeof(unsigned int),
2021 static void s_call_info_mo_cfc( CoreObject *o )
2027 p = tcore_object_ref_plugin(o);
2029 co = tcore_call_object_current_on_mo_processing( o );
2031 dbg("[ error ] can't find call object!");
2034 id = tcore_call_object_get_id( co );
2036 tcore_server_send_notification( tcore_plugin_ref_server(p),
2037 tcore_plugin_ref_core_object(p, "call"),
2038 TNOTI_CALL_INFO_FORWARD_CONDITIONAL,
2039 sizeof(unsigned int),
2043 static void s_call_info_mt_cli( CoreObject *o, enum tcore_call_cli_mode mode, char* number )
2047 co = tcore_call_object_current_on_mt_processing( o );
2049 dbg("[ error ] can't find call object!");
2052 tcore_call_object_set_cli_info( co, mode, number );
2055 static void s_call_info_mt_cna( CoreObject *o, enum tcore_call_cna_mode mode, char* name, int dcs )
2059 co = tcore_call_object_current_on_mt_processing( o );
2061 dbg("[ error ] can't find call object!");
2064 tcore_call_object_set_cna_info( co, mode, name, dcs );
2067 static void s_call_info_mt_forwarded_call( CoreObject *o, char* number )
2073 p = tcore_object_ref_plugin(o);
2075 co = tcore_call_object_current_on_mt_processing( o );
2077 dbg("[ error ] can't find call object!");
2081 id = tcore_call_object_get_id( co );
2083 tcore_server_send_notification( tcore_plugin_ref_server(p),
2084 tcore_plugin_ref_core_object(p, "call"),
2085 TNOTI_CALL_INFO_FORWARDED_CALL,
2086 sizeof(unsigned int),
2090 static void s_call_info_mt_deflected_call( CoreObject *o, char* number )
2096 p = tcore_object_ref_plugin(o);
2098 co = tcore_call_object_current_on_mt_processing( o );
2100 dbg("[ error ] can't find call object!");
2104 id = tcore_call_object_get_id( co );
2106 tcore_server_send_notification( tcore_plugin_ref_server(p),
2107 tcore_plugin_ref_core_object(p, "call"),
2108 TNOTI_CALL_INFO_DEFLECTED_CALL,
2109 sizeof(unsigned int),
2113 static void s_call_info_mt_transfered( CoreObject *o, char* number )
2119 p = tcore_object_ref_plugin(o);
2121 co = tcore_call_object_current_on_mt_processing( o );
2123 dbg("[ error ] can't find call object!");
2127 id = tcore_call_object_get_id( co );
2129 tcore_server_send_notification( tcore_plugin_ref_server(p),
2130 tcore_plugin_ref_core_object(p, "call"),
2131 TNOTI_CALL_INFO_TRANSFERED_CALL,
2132 sizeof(unsigned int),
2136 static void s_call_info_held( CoreObject *o, char* number )
2142 p = tcore_object_ref_plugin(o);
2144 co = tcore_call_object_find_by_number( o, number );
2146 dbg("[ error ] can't find call object!");
2150 id = tcore_call_object_get_id( co );
2152 tcore_server_send_notification( tcore_plugin_ref_server(p),
2153 tcore_plugin_ref_core_object(p, "call"),
2154 TNOTI_CALL_INFO_HELD,
2155 sizeof(unsigned int),
2159 static void s_call_info_active( CoreObject *o, char* number )
2165 p = tcore_object_ref_plugin(o);
2167 co = tcore_call_object_find_by_number( o, number );
2169 dbg("[ error ] can't find call object!");
2173 id = tcore_call_object_get_id( co );
2175 tcore_server_send_notification( tcore_plugin_ref_server(p),
2176 tcore_plugin_ref_core_object(p, "call"),
2177 TNOTI_CALL_INFO_ACTIVE,
2178 sizeof(unsigned int),
2182 static void s_call_info_joined( CoreObject *o, char* number )
2188 p = tcore_object_ref_plugin(o);
2190 co = tcore_call_object_find_by_number( o, number );
2192 dbg("[ error ] can't find call object!");
2196 id = tcore_call_object_get_id( co );
2198 tcore_server_send_notification( tcore_plugin_ref_server(p),
2199 tcore_plugin_ref_core_object(p, "call"),
2200 TNOTI_CALL_INFO_JOINED,
2201 sizeof(unsigned int),
2205 static void s_call_info_released_on_hold( CoreObject *o, char* number )
2211 p = tcore_object_ref_plugin(o);
2213 co = tcore_call_object_find_by_number( o, number );
2215 dbg("[ error ] can't find call object!");
2219 id = tcore_call_object_get_id( co );
2221 tcore_server_send_notification( tcore_plugin_ref_server(p),
2222 tcore_plugin_ref_core_object(p, "call"),
2223 TNOTI_CALL_INFO_RELEASED_ON_HOLD,
2224 sizeof(unsigned int),
2228 static void s_call_info_transfer_alert( CoreObject *o, char* number )
2234 p = tcore_object_ref_plugin(o);
2236 co = tcore_call_object_find_by_number( o, number );
2238 dbg("[ error ] can't find call object!");
2242 id = tcore_call_object_get_id( co );
2244 tcore_server_send_notification( tcore_plugin_ref_server(p),
2245 tcore_plugin_ref_core_object(p, "call"),
2246 TNOTI_CALL_INFO_TRANSFER_ALERT,
2247 sizeof(unsigned int),
2251 static void s_call_info_transfered( CoreObject *o, char* number )
2257 p = tcore_object_ref_plugin(o);
2259 co = tcore_call_object_find_by_number( o, number );
2261 dbg("[ error ] can't find call object!");
2265 id = tcore_call_object_get_id( co );
2267 tcore_server_send_notification( tcore_plugin_ref_server(p),
2268 tcore_plugin_ref_core_object(p, "call"),
2269 TNOTI_CALL_INFO_TRANSFERED,
2270 sizeof(unsigned int),
2274 static void s_call_info_cf_check_message( CoreObject *o, char* number )
2280 p = tcore_object_ref_plugin(o);
2282 co = tcore_call_object_find_by_number( o, number );
2284 dbg("[ error ] can't find call object!");
2288 id = tcore_call_object_get_id( co );
2290 tcore_server_send_notification( tcore_plugin_ref_server(p),
2291 tcore_plugin_ref_core_object(p, "call"),
2292 TNOTI_CALL_INFO_CF_CHECK_MESSAGE,
2293 sizeof(unsigned int),
2298 static struct tcore_call_information_operations call_information_ops = {
2300 .mo_call_waiting = s_call_info_mo_waiting,
2302 .mo_call_forwarded = s_call_info_mo_forwarded,
2303 .mo_call_barred_incoming = s_call_info_mo_barred_incoming,
2304 .mo_call_barred_outgoing = s_call_info_mo_barred_outgoing,
2305 .mo_call_deflected = s_call_info_mo_deflected,
2306 .mo_call_clir_suppression_reject = s_call_info_mo_clir_suppression_reject,
2307 .mo_call_cfu = s_call_info_mo_cfu,
2308 .mo_call_cfc = s_call_info_mo_cfc,
2309 .mt_call_cli = s_call_info_mt_cli,
2310 .mt_call_cna = s_call_info_mt_cna,
2311 .mt_call_forwarded_call = s_call_info_mt_forwarded_call,
2312 .mt_call_cug_call = 0,
2313 .mt_call_deflected_call = s_call_info_mt_deflected_call,
2314 .mt_call_transfered = s_call_info_mt_transfered,
2315 .call_held = s_call_info_held,
2316 .call_active = s_call_info_active,
2317 .call_joined = s_call_info_joined,
2318 .call_released_on_hold = s_call_info_released_on_hold,
2319 .call_transfer_alert = s_call_info_transfer_alert,
2320 .call_transfered = s_call_info_transfered,
2321 .call_cf_check_message = s_call_info_cf_check_message,
2324 gboolean s_call_init(TcorePlugin *p, TcoreHal *h)
2326 CoreObject *o = NULL;
2327 // TcoreHal *h = NULL;
2328 struct property_call_info *data = NULL;
2330 o = tcore_call_new(p, "call", &call_ops, h);
2334 tcore_call_information_set_operations( o, &call_information_ops );
2336 tcore_object_add_callback( o, EVENT_CALL_STATUS, on_notification_call_status, NULL );
2337 tcore_object_add_callback( o, EVENT_CALL_INCOMING, on_notification_call_incoming, NULL );
2338 tcore_object_add_callback( o, EVENT_CALL_WAITING, on_notification_call_waiting, NULL );
2340 data = calloc( sizeof(struct property_call_info *), 1);
2341 tcore_plugin_link_property(p, "CALL", data);
2346 void s_call_exit( TcorePlugin *p )
2350 struct property_network_info *data;
2352 o = tcore_plugin_ref_core_object(p, "call");
2354 data = tcore_plugin_ref_property(p, "CALL");