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 = CALL_ERROR_NONE;
516 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
542 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
571 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
601 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
632 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
683 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
714 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
743 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
772 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
802 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
851 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
882 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
950 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
981 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
1030 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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 = CALL_ERROR_NONE;
1058 resp.err = CALL_ERROR_SERVICE_UNAVAIL;
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] );
1133 if ( countCalls > countValidCalls )
1140 co = tcore_call_object_find_by_id( o, call_list[i].info.id );
1142 co = tcore_call_object_new( o, call_list[i].info.id );
1144 dbg("error : tcore_call_object_new [ id : %d ]", call_list[i].info.id);
1149 tcore_call_object_set_type( co, _call_type( call_list[i].info.type ) );
1150 tcore_call_object_set_direction( co, call_list[i].info.direction );
1151 tcore_call_object_set_multiparty_state( co, _call_is_in_mpty(call_list[i].info.mpty) );
1152 tcore_call_object_set_cli_info( co, CALL_CLI_MODE_DEFAULT, call_list[i].number );
1154 _call_branch_by_status( plugin, co, call_list[i].info.status );
1158 if ( i == countCalls )
1166 static int _callFromCLCCLine(char *line, struct CLCC_call_t*p_call)
1168 //+CLCC: 1,0,2,0,0,\"+18005551212\",145
1169 // index,isMT,state,mode,isMpty(,number,TOA)?
1177 err = at_tok_start(&line);
1178 if (err < 0) goto error;
1181 err = at_tok_nextint(&line, &(p_call->info.id));
1182 if (err < 0) goto error;
1183 dbg("id : [%d]\n", p_call->info.id );
1185 err = at_tok_nextint(&line, &isMT);
1186 if (err < 0) goto error;
1189 p_call->info.direction = TCORE_CALL_DIRECTION_OUTGOING;
1191 p_call->info.direction = TCORE_CALL_DIRECTION_INCOMING;
1193 dbg("direction : [ %d ]\n", p_call->info.direction);
1196 err = at_tok_nextint(&line, &state);
1197 if (err < 0) goto error;
1201 p_call->info.status = TCORE_CALL_STATUS_ACTIVE;
1204 p_call->info.status = TCORE_CALL_STATUS_HELD;
1207 p_call->info.status = TCORE_CALL_STATUS_DIALING;
1210 p_call->info.status = TCORE_CALL_STATUS_ALERT;
1213 p_call->info.status = TCORE_CALL_STATUS_INCOMING;
1216 p_call->info.status = TCORE_CALL_STATUS_WAITING;
1219 dbg("status : [%d]\n", p_call->info.status );
1222 err = at_tok_nextint(&line, &mode);
1223 if (err < 0) goto error;
1228 p_call->info.type = TCORE_CALL_TYPE_VOICE;
1232 p_call->info.type = TCORE_CALL_TYPE_VIDEO;
1235 default: // only Voice/VT call is supported in CS. treat other unknown calls as error
1236 dbg("invalid type : [%d]\n", mode );
1240 dbg("type : [%d]\n", p_call->info.type );
1243 err = at_tok_nextint(&line, &(p_call->info.mpty));
1244 if (err < 0) goto error;
1245 dbg("mpty : [%d]\n", p_call->info.mpty );
1247 if (at_tok_hasmore(&line)) {
1248 err = at_tok_nextstr(&line, &num);
1250 /* tolerate null here */
1251 if (err < 0) return 0;
1253 memcpy(p_call->number, num, strlen(num));
1254 dbg("number : [ %s ]\n", p_call->number );
1256 p_call->info.num_len = strlen(num);
1257 dbg("num_len : [0x%x]\n", p_call->info.num_len );
1259 err = at_tok_nextint(&line, &(p_call->info.num_type));
1260 if (err < 0) goto error;
1261 dbg("num_type : [0x%x]\n", p_call->info.num_type );
1268 err("invalid CLCC line\n");
1274 static gboolean on_notification_call_waiting( CoreObject *o, const void *data, void *user_data )
1276 TcorePlugin* plugin = NULL;
1277 char* cmd = NULL, *num = NULL;
1278 CallObject *co, *dupco = 0;
1279 int id, status, err, type, mpty,direction;
1280 GSList* pList = NULL;
1281 #define LINE_DEFAULT 0
1283 dbg("call waiting noti : %s", cmd);
1284 plugin = tcore_object_ref_plugin(o);
1290 err = at_tok_nextint(&cmd,&id);
1291 err = at_tok_nextint(&cmd,&direction);
1292 err = at_tok_nextint(&cmd,&status);
1293 err = at_tok_nextint(&cmd,&type);
1294 err = at_tok_nextint(&cmd,&mpty);
1296 if(at_tok_hasmore(&cmd)){
1297 err = at_tok_nextstr(&cmd,&num);
1298 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : %s", id,direction,status, type, mpty, num);
1301 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty);
1303 // check call with incoming status already exist
1304 pList = tcore_call_object_find_by_status(o, TCORE_CALL_STATUS_WAITING);
1306 dbg("waiting call already exist. skip");
1310 pList = tcore_call_object_find_by_status(o, TCORE_CALL_STATUS_INCOMING);
1312 dbg("incoming call already exist. skip");
1316 dupco = tcore_call_object_find_by_id(o, id);
1318 dbg("co with same id already exist. skip");
1322 // make new co, add to list
1323 co = tcore_call_object_new( o, id);
1325 dbg("[ error ] co is NULL");
1329 tcore_call_object_set_type(co, _call_type(type));
1330 tcore_call_object_set_multiparty_state(co,_call_is_in_mpty(mpty));
1331 tcore_call_object_set_direction(co, TCORE_CALL_DIRECTION_INCOMING);
1332 tcore_call_object_set_cli_info(co, TCORE_CALL_CLI_MODE_DEFAULT, num);
1333 tcore_call_object_set_active_line(co, LINE_DEFAULT);
1335 _call_list_get( o, co );
1340 static gboolean on_notification_call_incoming( CoreObject *o, const void *data, void *user_data )
1342 TcorePlugin* plugin = NULL;
1343 char* cmd = NULL, *num = NULL;
1344 CallObject *co, *dupco = 0;
1345 int id, status, err, type, mpty,direction;
1346 GSList* pList = NULL;
1347 #define LINE_DEFAULT 0
1349 dbg("call incoming noti : %s", cmd);
1350 plugin = tcore_object_ref_plugin(o);
1356 err = at_tok_nextint(&cmd,&id);
1357 err = at_tok_nextint(&cmd,&direction);
1358 err = at_tok_nextint(&cmd,&status);
1359 err = at_tok_nextint(&cmd,&type);
1360 err = at_tok_nextint(&cmd,&mpty);
1362 if(at_tok_hasmore(&cmd)) {
1363 err = at_tok_nextstr(&cmd,&num);
1364 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : %s", id,direction,status, type, mpty, num);
1367 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty);
1369 // check call with incoming status already exist
1370 pList = tcore_call_object_find_by_status(o, TCORE_CALL_STATUS_INCOMING);
1372 dbg("incoming call already exist. skip");
1376 dupco = tcore_call_object_find_by_id(o, id);
1378 dbg("co with same id already exist. skip");
1382 // make new co, add to list
1383 co = tcore_call_object_new( o, id);
1385 dbg("[ error ] co is NULL");
1389 tcore_call_object_set_type(co, _call_type(type));
1390 tcore_call_object_set_multiparty_state(co,_call_is_in_mpty(mpty));
1391 tcore_call_object_set_direction(co, TCORE_CALL_DIRECTION_INCOMING);
1392 tcore_call_object_set_cli_info(co, TCORE_CALL_CLI_MODE_DEFAULT, num);
1393 tcore_call_object_set_active_line(co, LINE_DEFAULT);
1395 _call_list_get( o, co );
1400 static gboolean on_notification_call_status( CoreObject *o, const void *data, void *user_data)
1402 char* cmd = NULL, *num = NULL;
1405 int id, status, type, mpty,direction;
1408 enum tcore_call_status co_status;
1410 p = tcore_object_ref_plugin( o );
1415 err = at_tok_nextint(&cmd,&id);
1416 err = at_tok_nextint(&cmd,&direction);
1417 err = at_tok_nextint(&cmd,&status);
1418 err = at_tok_nextint(&cmd,&type);
1419 err = at_tok_nextint(&cmd,&mpty);
1421 if (at_tok_hasmore(&cmd)) {
1422 err = at_tok_nextstr(&cmd,&num);
1423 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : %s", id,direction,status, type, mpty, num);
1426 dbg("id: %d, direction : %d, status : %d, type :%d, mpty : %d, num : NULL", id,direction,status, type, mpty);
1429 co_status = _call_status(status);
1431 switch (co_status) {
1432 case CALL_STATUS_ACTIVE:{
1434 dbg("call(%d) status : [ ACTIVE ]", id);
1435 co = tcore_call_object_find_by_id(o,id);
1440 _call_status_active( p, co );
1443 case CALL_STATUS_HELD:
1445 case CALL_STATUS_DIALING:
1447 dbg("call(%d) status : [ dialing ]", id);
1448 co = tcore_call_object_find_by_id(o,id);
1450 co = tcore_call_object_new( o, id );
1452 dbg("error : tcore_call_object_new [ id : %d ]", id);
1457 tcore_call_object_set_type( co, _call_type(type) );
1458 tcore_call_object_set_direction( co, TCORE_CALL_DIRECTION_OUTGOING );
1460 _call_status_dialing( p, co );
1463 case CALL_STATUS_ALERT:
1466 dbg("call(%d) status : [ alert ]", id);
1467 co = tcore_call_object_find_by_id(o, id);
1473 _call_list_get( o, co );
1476 case CALL_STATUS_INCOMING:
1477 case CALL_STATUS_WAITING:
1479 case CALL_STATUS_IDLE: {
1481 dbg("call(%d) status : [ release ]", id);
1483 co = tcore_call_object_find_by_id( o, id );
1487 p = tcore_object_ref_plugin( o );
1489 dbg("plugin is NULL");
1491 _call_status_idle( p, co );
1502 static TReturn s_call_outgoing( CoreObject *o, UserRequest *ur )
1504 TcorePlugin* p = NULL;
1506 struct treq_call_dial* data = 0;
1507 char* raw_str= NULL;
1508 char* cmd_str = NULL;
1510 struct ATReqMetaInfo metainfo;
1512 enum tcore_call_cli_mode clir = CALL_CLI_MODE_DEFAULT;
1514 gboolean ret = FALSE;
1516 data = (struct treq_call_dial*)tcore_user_request_ref_data( ur, 0 );
1517 p = tcore_object_ref_plugin( o );
1519 clir = _get_clir_status( data->number );
1521 //Compose ATCmd string
1524 case TCORE_CALL_CLI_MODE_PRESENT:
1526 break; /*invocation*/
1527 case TCORE_CALL_CLI_MODE_RESTRICT:
1529 break; /*suppression*/
1530 case TCORE_CALL_CLI_MODE_DEFAULT:
1533 break; /*subscription default*/
1536 raw_str = g_strdup_printf("ATD%s%s;", data->number, cclir);
1537 cmd_str = g_strdup_printf("%s%s",raw_str,"\r");
1539 memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1542 metainfo.type = NO_RESULT;
1543 metainfo.responsePrefix[0] ='\0';
1544 info_len = sizeof(struct ATReqMetaInfo);
1546 tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1548 ret = _call_request_message ( o, ur, cmd_str, strlen(cmd_str), on_confirmation_call_outgoing, co);
1554 tcore_call_object_free( o, co );
1555 return TCORE_RETURN_FAILURE;
1558 return TCORE_RETURN_SUCCESS;
1561 static TReturn s_call_answer( CoreObject *o, UserRequest *ur )
1564 struct treq_call_answer* data = 0;
1565 gboolean ret = FALSE;
1566 char* cmd_str = NULL;
1567 struct ATReqMetaInfo metainfo ;
1568 unsigned int info_len =0;
1570 data = (struct treq_call_answer*)tcore_user_request_ref_data( ur, 0 );
1572 co = tcore_call_object_find_by_id( o, data->id );
1574 memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1577 metainfo.type = NO_RESULT;
1578 metainfo.responsePrefix[0] = '\0';
1579 info_len = sizeof(struct ATReqMetaInfo);
1581 tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1583 if ( data->type == CALL_ANSWER_TYPE_ACCEPT ) {
1585 cmd_str = g_strdup_printf("%s%s","ATA","\r");
1586 ret = _call_request_message ( o, ur, (void*)cmd_str, strlen(cmd_str), on_confirmation_call_accept, co);
1589 return TCORE_RETURN_FAILURE;
1593 switch ( data->type ) {
1594 case CALL_ANSWER_TYPE_REJECT: {
1595 dbg("call answer reject");
1596 tcore_call_control_answer_reject( o, ur, on_confirmation_call_reject, co );
1599 case CALL_ANSWER_TYPE_REPLACE: {
1600 dbg("call answer replace");
1601 tcore_call_control_answer_replace( o, ur, on_confirmation_call_replace, co );
1604 case CALL_ANSWER_TYPE_HOLD_ACCEPT: {
1605 dbg("call answer hold and accept");
1606 tcore_call_control_answer_hold_and_accept( o, ur, on_confirmation_call_hold_and_accept, co );
1610 dbg("[ error ] wrong answer type [ %d ]", data->type);
1611 return TCORE_RETURN_FAILURE;
1615 return TCORE_RETURN_SUCCESS;
1618 static TReturn s_call_release( CoreObject *o, UserRequest *ur )
1622 struct treq_call_end* data = 0;
1623 gboolean ret = FALSE;
1624 UserRequest* ur_dup = 0;
1626 char* chld0_cmd = NULL;
1627 char* chld1_cmd = NULL;
1628 struct ATReqMetaInfo metainfo1 ;
1629 struct ATReqMetaInfo metainfo2 ;
1630 unsigned int info_len1, info_len2 =0;
1632 data = (struct treq_call_end*)tcore_user_request_ref_data( ur, 0 );
1634 co = tcore_call_object_find_by_id( o, data->id );
1636 if ( data->type == CALL_END_TYPE_ALL ) {
1638 //releaseAll do not exist on legacy request. send CHLD=0, CHLD=1 in sequence
1639 chld0_cmd = g_strdup("AT+CHLD=0\r");
1640 chld1_cmd = g_strdup("AT+CHLD=1\r");
1642 memset(&metainfo1, 0, sizeof(struct ATReqMetaInfo));
1643 memset(&metainfo2, 0, sizeof(struct ATReqMetaInfo));
1647 metainfo1.type = NO_RESULT;
1648 metainfo1.responsePrefix[0] = '\0';
1649 info_len1 = sizeof(struct ATReqMetaInfo);
1652 metainfo2.type = NO_RESULT;
1653 metainfo2.responsePrefix[0] = '\0';
1654 info_len2 = sizeof(struct ATReqMetaInfo);
1656 ur_dup = tcore_user_request_new(NULL, NULL);
1658 tcore_user_request_set_metainfo(ur_dup, info_len1, &metainfo1);
1659 tcore_user_request_set_metainfo(ur, info_len2, &metainfo2);
1661 ret = _call_request_message(o, ur_dup, chld0_cmd, strlen(chld0_cmd), on_confirmation_call_endall, NULL);
1664 return TCORE_RETURN_FAILURE;
1666 ret = _call_request_message(o, ur, chld1_cmd, strlen(chld1_cmd), on_confirmation_call_release_all, co);
1669 return TCORE_RETURN_FAILURE;
1673 switch ( data->type ) {
1674 case CALL_END_TYPE_DEFAULT: {
1676 id = tcore_call_object_get_id( co );
1678 dbg("call end call id [%d]", id);
1679 tcore_call_control_end_specific( o, ur, id, on_confirmation_call_release_specific, co );
1682 case CALL_END_TYPE_ACTIVE_ALL: {
1684 dbg("call end all active");
1685 tcore_call_control_end_all_active( o, ur, on_confirmation_call_release_all_active, co );
1688 case TCORE_CALL_END_ALL_HELD: {
1690 dbg("call end all held");
1691 tcore_call_control_end_all_held( o, ur, on_confirmation_call_release_all_held, co );
1695 dbg("[ error ] wrong end type [ %d ]", data->type);
1696 return TCORE_RETURN_FAILURE;
1701 return TCORE_RETURN_SUCCESS;
1704 static TReturn s_call_hold( CoreObject *o, UserRequest *ur )
1706 struct treq_call_hold *hold = 0;
1709 hold = (struct treq_call_hold*)tcore_user_request_ref_data( ur, 0 );
1711 dbg("call id : [ %d ]", hold->id);
1713 co = tcore_call_object_find_by_id( o, hold->id );
1715 tcore_call_control_hold( o, ur, on_confirmation_call_hold, co );
1717 return TCORE_RETURN_SUCCESS;
1720 static TReturn s_call_active( CoreObject *o, UserRequest *ur )
1722 struct treq_call_active *active = 0;
1725 active = (struct treq_call_active*)tcore_user_request_ref_data( ur, 0 );
1727 dbg("call id : [ %d ]", active->id);
1729 co = tcore_call_object_find_by_id( o, active->id );
1731 tcore_call_control_active( o, ur, on_confirmation_call_active, co );
1733 return TCORE_RETURN_SUCCESS;
1736 static TReturn s_call_swap( CoreObject *o, UserRequest *ur )
1738 struct treq_call_swap *swap = 0;
1740 swap = (struct treq_call_swap*)tcore_user_request_ref_data( ur, 0 );
1742 dbg("call id : [ %d ]", swap->id);
1744 co = tcore_call_object_find_by_id( o, swap->id );
1746 tcore_call_control_swap( o, ur, on_confirmation_call_swap, co );
1748 return TCORE_RETURN_SUCCESS;
1751 static TReturn s_call_join( CoreObject *o, UserRequest *ur )
1753 struct treq_call_join *join = 0;
1756 join = (struct treq_call_join*)tcore_user_request_ref_data( ur, 0 );
1758 dbg("call id : [ %d ]", join->id);
1760 co = tcore_call_object_find_by_id( o, join->id );
1762 tcore_call_control_join( o, ur, on_confirmation_call_join, co );
1764 return TCORE_RETURN_SUCCESS;
1767 static TReturn s_call_split( CoreObject *o, UserRequest *ur )
1769 struct treq_call_split *split = 0;
1772 split = (struct treq_call_split*)tcore_user_request_ref_data( ur, 0 );
1774 co = tcore_call_object_find_by_id ( o, split->id );
1776 tcore_call_control_split( o, ur, split->id, on_confirmation_call_split, co );
1778 return TCORE_RETURN_SUCCESS;
1781 static TReturn s_call_deflect( CoreObject *o, UserRequest *ur )
1783 struct treq_call_deflect *deflect = 0;
1786 deflect = (struct treq_call_deflect*)tcore_user_request_ref_data( ur, 0 );
1788 co = tcore_call_object_find_by_number( o, deflect->number );
1790 tcore_call_control_deflect( o, ur, deflect->number, on_confirmation_call_deflect, co );
1792 return TCORE_RETURN_SUCCESS;
1795 static TReturn s_call_transfer( CoreObject *o, UserRequest *ur )
1797 struct treq_call_transfer *transfer = 0;
1800 transfer = (struct treq_call_transfer*)tcore_user_request_ref_data( ur, 0 );
1802 dbg("call id : [ %d ]", transfer->id);
1804 co = tcore_call_object_find_by_id( o, transfer->id );
1806 tcore_call_control_transfer( o, ur, on_confirmation_call_transfer, co );
1808 return TCORE_RETURN_SUCCESS;
1811 static TReturn s_call_send_dtmf( CoreObject *o, UserRequest *ur )
1813 return TCORE_RETURN_SUCCESS;
1816 static TReturn s_call_set_sound_path( CoreObject *o, UserRequest *ur )
1819 return TCORE_RETURN_SUCCESS;
1822 static TReturn s_call_set_sound_volume_level( CoreObject *o, UserRequest *ur )
1825 return TCORE_RETURN_SUCCESS;
1828 static TReturn s_call_get_sound_volume_level( CoreObject *o, UserRequest *ur )
1831 return TCORE_RETURN_SUCCESS;
1834 static TReturn s_call_mute( CoreObject *o, UserRequest *ur )
1837 return TCORE_RETURN_SUCCESS;
1840 static TReturn s_call_unmute( CoreObject *o, UserRequest *ur )
1843 return TCORE_RETURN_SUCCESS;
1846 static TReturn s_call_get_mute_status( CoreObject *o, UserRequest *ur )
1849 return TCORE_RETURN_SUCCESS;
1852 static struct tcore_call_operations call_ops = {
1853 .dial = s_call_outgoing,
1854 .answer = s_call_answer,
1855 .end = s_call_release,
1856 .hold = s_call_hold,
1857 .active = s_call_active,
1858 .swap = s_call_swap,
1859 .join = s_call_join,
1860 .split = s_call_split,
1861 .deflect = s_call_deflect,
1862 .transfer = s_call_transfer,
1863 .send_dtmf = s_call_send_dtmf,
1864 .set_sound_path = s_call_set_sound_path,
1865 .set_sound_volume_level = s_call_set_sound_volume_level,
1866 .get_sound_volume_level = s_call_get_sound_volume_level,
1867 .mute = s_call_mute,
1868 .unmute = s_call_unmute,
1869 .get_mute_status = s_call_get_mute_status,
1873 static void s_call_info_mo_waiting( CoreObject *o )
1879 p = tcore_object_ref_plugin(o);
1881 co = tcore_call_object_current_on_mo_processing( o );
1883 dbg("[ error ] can't find call object!");
1887 id = tcore_call_object_get_id( co );
1889 tcore_server_send_notification( tcore_plugin_ref_server(p),
1890 tcore_plugin_ref_core_object(p, "call"),
1891 TNOTI_CALL_INFO_WAITING,
1892 sizeof(unsigned int),
1896 static void s_call_info_mo_forwarded( CoreObject *o )
1902 p = tcore_object_ref_plugin(o);
1904 co = tcore_call_object_current_on_mo_processing( o );
1906 dbg("[ error ] can't find call object!");
1909 id = tcore_call_object_get_id( co );
1911 tcore_server_send_notification( tcore_plugin_ref_server(p),
1912 tcore_plugin_ref_core_object(p, "call"),
1913 TNOTI_CALL_INFO_FORWARDED,
1914 sizeof(unsigned int),
1918 static void s_call_info_mo_barred_incoming( CoreObject *o )
1924 p = tcore_object_ref_plugin(o);
1926 co = tcore_call_object_current_on_mo_processing( o );
1928 dbg("[ error ] can't find call object!");
1931 id = tcore_call_object_get_id( co );
1933 tcore_server_send_notification( tcore_plugin_ref_server(p),
1934 tcore_plugin_ref_core_object(p, "call"),
1935 TNOTI_CALL_INFO_BARRED_INCOMING,
1936 sizeof(unsigned int),
1940 static void s_call_info_mo_barred_outgoing( CoreObject *o )
1946 p = tcore_object_ref_plugin(o);
1948 co = tcore_call_object_current_on_mo_processing( o );
1950 dbg("[ error ] can't find call object!");
1953 id = tcore_call_object_get_id( co );
1955 tcore_server_send_notification( tcore_plugin_ref_server(p),
1956 tcore_plugin_ref_core_object(p, "call"),
1957 TNOTI_CALL_INFO_BARRED_OUTGOING,
1958 sizeof(unsigned int),
1962 static void s_call_info_mo_deflected( CoreObject *o )
1968 p = tcore_object_ref_plugin(o);
1970 co = tcore_call_object_current_on_mo_processing( o );
1972 dbg("[ error ] can't find call object!");
1975 id = tcore_call_object_get_id( co );
1977 tcore_server_send_notification( tcore_plugin_ref_server(p),
1978 tcore_plugin_ref_core_object(p, "call"),
1979 TNOTI_CALL_INFO_DEFLECTED,
1980 sizeof(unsigned int),
1984 static void s_call_info_mo_clir_suppression_reject( CoreObject *o )
1990 p = tcore_object_ref_plugin(o);
1992 co = tcore_call_object_current_on_mo_processing( o );
1994 dbg("[ error ] can't find call object!");
1997 id = tcore_call_object_get_id( co );
1999 tcore_server_send_notification( tcore_plugin_ref_server(p),
2000 tcore_plugin_ref_core_object(p, "call"),
2001 TNOTI_CALL_INFO_CLIR_SUPPRESSION_REJECT,
2002 sizeof(unsigned int),
2006 static void s_call_info_mo_cfu( CoreObject *o )
2012 p = tcore_object_ref_plugin(o);
2014 co = tcore_call_object_current_on_mo_processing( o );
2016 dbg("[ error ] can't find call object!");
2019 id = tcore_call_object_get_id( co );
2021 tcore_server_send_notification( tcore_plugin_ref_server(p),
2022 tcore_plugin_ref_core_object(p, "call"),
2023 TNOTI_CALL_INFO_FORWARD_UNCONDITIONAL,
2024 sizeof(unsigned int),
2028 static void s_call_info_mo_cfc( CoreObject *o )
2034 p = tcore_object_ref_plugin(o);
2036 co = tcore_call_object_current_on_mo_processing( o );
2038 dbg("[ error ] can't find call object!");
2041 id = tcore_call_object_get_id( co );
2043 tcore_server_send_notification( tcore_plugin_ref_server(p),
2044 tcore_plugin_ref_core_object(p, "call"),
2045 TNOTI_CALL_INFO_FORWARD_CONDITIONAL,
2046 sizeof(unsigned int),
2050 static void s_call_info_mt_cli( CoreObject *o, enum tcore_call_cli_mode mode, char* number )
2054 co = tcore_call_object_current_on_mt_processing( o );
2056 dbg("[ error ] can't find call object!");
2059 tcore_call_object_set_cli_info( co, mode, number );
2062 static void s_call_info_mt_cna( CoreObject *o, enum tcore_call_cna_mode mode, char* name, int dcs )
2066 co = tcore_call_object_current_on_mt_processing( o );
2068 dbg("[ error ] can't find call object!");
2071 tcore_call_object_set_cna_info( co, mode, name, dcs );
2074 static void s_call_info_mt_forwarded_call( CoreObject *o, char* number )
2080 p = tcore_object_ref_plugin(o);
2082 co = tcore_call_object_current_on_mt_processing( o );
2084 dbg("[ error ] can't find call object!");
2088 id = tcore_call_object_get_id( co );
2090 tcore_server_send_notification( tcore_plugin_ref_server(p),
2091 tcore_plugin_ref_core_object(p, "call"),
2092 TNOTI_CALL_INFO_FORWARDED_CALL,
2093 sizeof(unsigned int),
2097 static void s_call_info_mt_deflected_call( CoreObject *o, char* number )
2103 p = tcore_object_ref_plugin(o);
2105 co = tcore_call_object_current_on_mt_processing( o );
2107 dbg("[ error ] can't find call object!");
2111 id = tcore_call_object_get_id( co );
2113 tcore_server_send_notification( tcore_plugin_ref_server(p),
2114 tcore_plugin_ref_core_object(p, "call"),
2115 TNOTI_CALL_INFO_DEFLECTED_CALL,
2116 sizeof(unsigned int),
2120 static void s_call_info_mt_transfered( CoreObject *o, char* number )
2126 p = tcore_object_ref_plugin(o);
2128 co = tcore_call_object_current_on_mt_processing( o );
2130 dbg("[ error ] can't find call object!");
2134 id = tcore_call_object_get_id( co );
2136 tcore_server_send_notification( tcore_plugin_ref_server(p),
2137 tcore_plugin_ref_core_object(p, "call"),
2138 TNOTI_CALL_INFO_TRANSFERED_CALL,
2139 sizeof(unsigned int),
2143 static void s_call_info_held( CoreObject *o, char* number )
2149 p = tcore_object_ref_plugin(o);
2151 co = tcore_call_object_find_by_number( o, number );
2153 dbg("[ error ] can't find call object!");
2157 id = tcore_call_object_get_id( co );
2159 tcore_server_send_notification( tcore_plugin_ref_server(p),
2160 tcore_plugin_ref_core_object(p, "call"),
2161 TNOTI_CALL_INFO_HELD,
2162 sizeof(unsigned int),
2166 static void s_call_info_active( CoreObject *o, char* number )
2172 p = tcore_object_ref_plugin(o);
2174 co = tcore_call_object_find_by_number( o, number );
2176 dbg("[ error ] can't find call object!");
2180 id = tcore_call_object_get_id( co );
2182 tcore_server_send_notification( tcore_plugin_ref_server(p),
2183 tcore_plugin_ref_core_object(p, "call"),
2184 TNOTI_CALL_INFO_ACTIVE,
2185 sizeof(unsigned int),
2189 static void s_call_info_joined( CoreObject *o, char* number )
2195 p = tcore_object_ref_plugin(o);
2197 co = tcore_call_object_find_by_number( o, number );
2199 dbg("[ error ] can't find call object!");
2203 id = tcore_call_object_get_id( co );
2205 tcore_server_send_notification( tcore_plugin_ref_server(p),
2206 tcore_plugin_ref_core_object(p, "call"),
2207 TNOTI_CALL_INFO_JOINED,
2208 sizeof(unsigned int),
2212 static void s_call_info_released_on_hold( CoreObject *o, char* number )
2218 p = tcore_object_ref_plugin(o);
2220 co = tcore_call_object_find_by_number( o, number );
2222 dbg("[ error ] can't find call object!");
2226 id = tcore_call_object_get_id( co );
2228 tcore_server_send_notification( tcore_plugin_ref_server(p),
2229 tcore_plugin_ref_core_object(p, "call"),
2230 TNOTI_CALL_INFO_RELEASED_ON_HOLD,
2231 sizeof(unsigned int),
2235 static void s_call_info_transfer_alert( CoreObject *o, char* number )
2241 p = tcore_object_ref_plugin(o);
2243 co = tcore_call_object_find_by_number( o, number );
2245 dbg("[ error ] can't find call object!");
2249 id = tcore_call_object_get_id( co );
2251 tcore_server_send_notification( tcore_plugin_ref_server(p),
2252 tcore_plugin_ref_core_object(p, "call"),
2253 TNOTI_CALL_INFO_TRANSFER_ALERT,
2254 sizeof(unsigned int),
2258 static void s_call_info_transfered( CoreObject *o, char* number )
2264 p = tcore_object_ref_plugin(o);
2266 co = tcore_call_object_find_by_number( o, number );
2268 dbg("[ error ] can't find call object!");
2272 id = tcore_call_object_get_id( co );
2274 tcore_server_send_notification( tcore_plugin_ref_server(p),
2275 tcore_plugin_ref_core_object(p, "call"),
2276 TNOTI_CALL_INFO_TRANSFERED,
2277 sizeof(unsigned int),
2281 static void s_call_info_cf_check_message( CoreObject *o, char* number )
2287 p = tcore_object_ref_plugin(o);
2289 co = tcore_call_object_find_by_number( o, number );
2291 dbg("[ error ] can't find call object!");
2295 id = tcore_call_object_get_id( co );
2297 tcore_server_send_notification( tcore_plugin_ref_server(p),
2298 tcore_plugin_ref_core_object(p, "call"),
2299 TNOTI_CALL_INFO_CF_CHECK_MESSAGE,
2300 sizeof(unsigned int),
2305 static struct tcore_call_information_operations call_information_ops = {
2307 .mo_call_waiting = s_call_info_mo_waiting,
2309 .mo_call_forwarded = s_call_info_mo_forwarded,
2310 .mo_call_barred_incoming = s_call_info_mo_barred_incoming,
2311 .mo_call_barred_outgoing = s_call_info_mo_barred_outgoing,
2312 .mo_call_deflected = s_call_info_mo_deflected,
2313 .mo_call_clir_suppression_reject = s_call_info_mo_clir_suppression_reject,
2314 .mo_call_cfu = s_call_info_mo_cfu,
2315 .mo_call_cfc = s_call_info_mo_cfc,
2316 .mt_call_cli = s_call_info_mt_cli,
2317 .mt_call_cna = s_call_info_mt_cna,
2318 .mt_call_forwarded_call = s_call_info_mt_forwarded_call,
2319 .mt_call_cug_call = 0,
2320 .mt_call_deflected_call = s_call_info_mt_deflected_call,
2321 .mt_call_transfered = s_call_info_mt_transfered,
2322 .call_held = s_call_info_held,
2323 .call_active = s_call_info_active,
2324 .call_joined = s_call_info_joined,
2325 .call_released_on_hold = s_call_info_released_on_hold,
2326 .call_transfer_alert = s_call_info_transfer_alert,
2327 .call_transfered = s_call_info_transfered,
2328 .call_cf_check_message = s_call_info_cf_check_message,
2331 gboolean s_call_init(TcorePlugin *p, TcoreHal *h)
2333 CoreObject *o = NULL;
2334 // TcoreHal *h = NULL;
2335 struct property_call_info *data = NULL;
2337 o = tcore_call_new(p, "call", &call_ops, h);
2341 tcore_call_information_set_operations( o, &call_information_ops );
2343 tcore_object_add_callback( o, EVENT_CALL_STATUS, on_notification_call_status, NULL );
2344 tcore_object_add_callback( o, EVENT_CALL_INCOMING, on_notification_call_incoming, NULL );
2345 tcore_object_add_callback( o, EVENT_CALL_WAITING, on_notification_call_waiting, NULL );
2347 data = calloc( sizeof(struct property_call_info *), 1);
2348 tcore_plugin_link_property(p, "CALL", data);
2353 void s_call_exit( TcorePlugin *p )
2357 struct property_network_info *data;
2359 o = tcore_plugin_ref_core_object(p, "call");
2361 data = tcore_plugin_ref_property(p, "CALL");