tizen 2.3 release
[framework/telephony/libslp-tapi.git] / test_src / call.c
1 /*
2  * libslp-tapi
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  */
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <sys/time.h>
25 #include <unistd.h>
26 #include <glib.h>
27
28 #include <tapi_common.h>
29 #include <TelCall.h>
30 #include <ITapiCall.h>
31 #include <TapiUtility.h>
32
33 #include "menu.h"
34 #include "call.h"
35
36 static char data_call_id[MENU_DATA_SIZE + 1] = "1";
37 static char data_call_id2[MENU_DATA_SIZE + 1] = "2";
38 static char data_call_type[MENU_DATA_SIZE + 1] = "0";
39 static char data_dtmf_digit[MENU_DATA_SIZE + 1] = "1";
40 static char data_dtmf_string[MENU_DATA_SIZE + 1] = "12345";
41 static char data_dtmf_pulse_width[MENU_DATA_SIZE + 1] = "1";
42 static char data_dtmf_inter_digit_interval[MENU_DATA_SIZE + 1] = "1";
43 static char data_call_number[MENU_DATA_SIZE + 1] = "+821099777347";
44 static char data_answer_type[MENU_DATA_SIZE + 1] = "1";
45 static char data_end_type[MENU_DATA_SIZE + 1] = "1";
46 static char data_mute_path[MENU_DATA_SIZE + 1] = "0";
47 static char data_mute_status[MENU_DATA_SIZE + 1] = "0";
48 static char data_vol_device[MENU_DATA_SIZE + 1] = "0";
49 static char data_vol_type[MENU_DATA_SIZE + 1] = "1";
50 static char data_vol_level[MENU_DATA_SIZE + 1] = "1";
51 static char data_sound_path[MENU_DATA_SIZE + 1] = "1";
52 static char data_extra_volume_status[MENU_DATA_SIZE + 1] = "0";
53 static char data_preferred_voice_subscription[MENU_DATA_SIZE + 1] = "0";
54
55 static void on_noti_call_status_idle(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
56 {
57         TelCallStatusIdleNoti_t *noti_data = (TelCallStatusIdleNoti_t*)data;
58
59         msg("");
60         msgb("event(%s) receive !!", TAPI_NOTI_VOICE_CALL_STATUS_IDLE);
61
62         if (!noti_data)
63                 return;
64
65         msg(" - id = %d", noti_data->id);
66         msg(" - cause = 0x%x", noti_data->cause);
67 }
68
69 static void on_noti_call_status_active(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
70 {
71         TelCallStatusActiveNoti_t *noti_data = (TelCallStatusActiveNoti_t*)data;
72
73         msg("");
74         msgb("event(%s) receive !!", TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE);
75
76         if (!noti_data)
77                 return;
78
79         msg(" - id = %d", noti_data->id);
80 }
81
82 static void on_noti_call_status_held(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
83 {
84         TelCallStatusHeldNoti_t *noti_data = (TelCallStatusHeldNoti_t*)data;
85
86         msg("");
87         msgb("event(%s) receive !!", TAPI_NOTI_VOICE_CALL_STATUS_HELD);
88
89         if (!noti_data)
90                 return;
91
92         msg(" - id = %d", noti_data->id);
93 }
94
95 static void on_noti_call_status_dialing(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
96 {
97         TelCallStatusDialingNoti_t *noti_data = (TelCallStatusDialingNoti_t*)data;
98
99         msg("");
100         msgb("event(%s) receive !!", TAPI_NOTI_VOICE_CALL_STATUS_DIALING);
101
102         if (!noti_data)
103                 return;
104
105         msg(" - id = %d", noti_data->id);
106 }
107
108 static void on_noti_call_status_alert(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
109 {
110         TelCallStatusAlertNoti_t *noti_data = (TelCallStatusAlertNoti_t*)data;
111
112         msg("");
113         msgb("event(%s) receive !!", TAPI_NOTI_VOICE_CALL_STATUS_ALERT);
114
115         if (!noti_data)
116                 return;
117
118         msg(" - id = %d", noti_data->id);
119 }
120
121 static void on_noti_call_status_incoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
122 {
123         TelCallStatusIncomingNoti_t *noti_data = (TelCallStatusIncomingNoti_t*)data;
124
125         msg("");
126         msgb("event(%s) receive !!", TAPI_NOTI_VOICE_CALL_STATUS_INCOMING);
127
128         if (!noti_data)
129                 return;
130
131         msg(" - id = %d", noti_data->id);
132 }
133
134 static void on_noti_call_sound_ringback_tone(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
135 {
136         TelCallSoundRingbackToneNoti_t *noti_data = (TelCallSoundRingbackToneNoti_t*)data;
137
138         msg("");
139         msgb("event(%s) receive !!", TAPI_NOTI_CALL_SOUND_RINGBACK_TONE);
140
141         if (!noti_data)
142                 return;
143
144         msg(" - Ringback tone status = 0x%x", *noti_data);
145 }
146
147 static void on_noti_call_sound_wbamr(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
148 {
149         gboolean *noti_data = (gboolean*)data;
150
151         msg("");
152         msgb("event(%s) receive !!", TAPI_NOTI_CALL_SOUND_WBAMR);
153
154         if (!noti_data)
155                 return;
156
157         msg(" - status = 0x%x", *noti_data);
158 }
159
160 static void on_noti_call_preferred_voice_subscription(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
161 {
162         TelCallPreferredVoiceSubsNoti_t *noti_data = (TelCallPreferredVoiceSubsNoti_t *)data;
163
164         msg("");
165         msgb("event(%s) receive !!", TAPI_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION);
166
167         if (!noti_data)
168                 return;
169
170         msg(" - preferred_subscription = 0x%x", noti_data->preferred_subs);
171 }
172
173 static void on_noti_call_sound_path(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
174 {
175         TelSoundPath_t *noti_data = (TelSoundPath_t *)data;
176
177         msg("");
178         msgb("event(%s) receive !!", TAPI_NOTI_CALL_SOUND_PATH);
179
180         if (!noti_data)
181                 return;
182
183         msg(" - Sound path = 0x%x", *noti_data);
184 }
185
186 static void on_noti_call_on_hold(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
187 {
188         unsigned int *noti_data = (unsigned int*)data;
189
190         msg("");
191         msgb("event(%s) receive !!", TAPI_NOTI_CALL_INFO_HELD);
192
193         if (!noti_data)
194                 return;
195
196         msg(" - ID = %d", *noti_data);
197 }
198
199 static void on_noti_call_active(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
200 {
201         unsigned int *noti_data = (unsigned int*)data;
202
203         msg("");
204         msgb("event(%s) receive !!", TAPI_NOTI_CALL_INFO_ACTIVE);
205
206         if (!noti_data)
207                 return;
208
209         msg(" - ID = %d", *noti_data);
210 }
211
212 static void on_noti_call_joined(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
213 {
214         unsigned int *noti_data = (unsigned int*)data;
215
216         msg("");
217         msgb("event(%s) receive !!", TAPI_NOTI_CALL_INFO_JOINED);
218
219         if (!noti_data)
220                 return;
221
222         msg(" - ID = %d", *noti_data);
223 }
224
225
226 static void on_dial_call(TapiHandle *handle, int result, void *data, void *user_data)
227 {
228         msg("on_dial_call() - result : 0x%x", result);
229 }
230
231 static void on_answer_call(TapiHandle *handle, int result, void *data, void *user_data)
232 {
233         TelCallAnswerCnf_t *cnf_data = (TelCallAnswerCnf_t*)data;
234
235         msg("on_answer_call() - cnf_data->id : %d", cnf_data->id);
236 }
237
238 static void on_end_call(TapiHandle *handle, int result, void *data, void *user_data)
239 {
240         TelCallEndCnf_t *cnf_data = (TelCallEndCnf_t*)data;
241
242         msg("on_end_call() - cnf_data->id : %d result : 0x%x", cnf_data->id, result);
243 }
244
245 static void on_hold_call(TapiHandle *handle, int result, void *data, void *user_data)
246 {
247         TelCallHoldCnf_t *cnf_data = (TelCallHoldCnf_t*)data;
248
249         msg("on_hold_call() - cnf_data->id : %d result : 0x%x", cnf_data->id, result);
250 }
251
252 static void on_active_call(TapiHandle *handle, int result, void *data, void *user_data)
253 {
254         TelCallActiveCnf_t *cnf_data = (TelCallActiveCnf_t*)data;
255
256         msg("on_active_call() - cnf_data->id : %d result : 0x%x", cnf_data->id, result);
257 }
258
259 static void on_swap_call(TapiHandle *handle, int result, void *data, void *user_data)
260 {
261         TelCallSwapCnf_t *cnf_data = (TelCallSwapCnf_t*)data;
262
263         msg("on_swap_call() - cnf_data->id : %d result : 0x%x", cnf_data->id, result);
264 }
265
266 static void on_join_call(TapiHandle *handle, int result, void *data, void *user_data)
267 {
268         TelCallJoinCnf_t *cnf_data = (TelCallJoinCnf_t*)data;
269
270         msg("on_join_call() - cnf_data->id : %d result : 0x%x", cnf_data->id, result);
271 }
272
273 static void on_split_call(TapiHandle *handle, int result, void *data, void *user_data)
274 {
275         TelCallSplitCnf_t *cnf_data = (TelCallSplitCnf_t*)data;
276
277         msg("on_split_call() - cnf_data->id : %d result : 0x%x", cnf_data->id, result);
278 }
279
280 static void on_transfer_call(TapiHandle *handle, int result, void *data, void *user_data)
281 {
282         TelCallTransferCnf_t *cnf_data = (TelCallTransferCnf_t*)data;
283
284         msg("on_transfer_call() - cnf_data->id : %d result : 0x%x", cnf_data->id, result);
285 }
286
287 static void on_start_cont_dtmf_call(TapiHandle *handle, int result, void *data, void *user_data)
288 {
289         msg("on_start_cont_dtmf_call() result : 0x%x", result);
290 }
291
292 static void on_stop_cont_dtmf_call(TapiHandle *handle, int result, void *data, void *user_data)
293 {
294         msg("on_stop_cont_dtmf_call() result : 0x%x", result);
295 }
296
297 static void on_send_burst_dtmf_call(TapiHandle *handle, int result, void *data, void *user_data)
298 {
299         msg("on_send_burst_dtmf_call() result : 0x%x", result);
300 }
301
302 static void on_call_set_mute_status(TapiHandle *handle, int result, void *data, void *user_data)
303 {
304         msg("on_call_set_mute_status() - result : 0x%x", result);
305 }
306
307 static void on_call_get_mute_status(TapiHandle *handle, int result, void *data, void *user_data)
308 {
309         TelCallGetMuteStatusResp_t *resp = (TelCallGetMuteStatusResp_t *)data;
310
311         msg("on_call_get_mute_status() - result : 0x%x", result);
312         msg("on_call_get_mute_status() - path : 0x%x", resp->path);
313         msg("on_call_get_mute_status() - status : 0x%x", resp->status);
314 }
315
316 static void on_call_set_volume_info(TapiHandle *handle, int result, void *data, void *user_data)
317 {
318         msg("on_call_set_volume_info() - result : 0x%x", result);
319 }
320
321 static void on_call_get_volume_info(TapiHandle *handle, int result, void *data, void *user_data)
322 {
323         unsigned int i = 0;
324         TelCallGetVolumeInfoResp_t *resp = (TelCallGetVolumeInfoResp_t *)data;
325
326         msg("on_call_get_volume_info() - result : 0x%x", result);
327         msg("on_call_get_volume_info() - record_num : 0x%x", resp->record_num);
328
329         for ( i=0; i<resp->record_num; i++ ) {
330                 msg("on_call_get_volume_info() - record[%d].device : 0x%x", (i+1), resp->record[i].device);
331                 msg("on_call_get_volume_info() - record[%d].type : 0x%x", (i+1), resp->record[i].device);
332                 msg("on_call_get_volume_info() - record[%d].volume : 0x%x", (i+1), resp->record[i].volume);
333
334         }
335 }
336
337 static void on_call_set_sound_path(TapiHandle *handle, int result, void *data, void *user_data)
338 {
339         msg("on_call_set_sound_path() - result : 0x%x", result);
340 }
341
342 static void on_call_set_preferred_voice_subscription(TapiHandle *handle, int result, void *data, void *user_data)
343 {
344         msg("on_call_set_preferred_voice_subscription() - result : 0x%x", result);
345 }
346
347 static int run_call_dial(MManager *mm, struct menu_data *menu)
348 {
349         TapiHandle *handle = menu_manager_ref_user_data(mm);
350         TelCallDial_t data;
351         int result;
352         int len;
353
354         memset(&data, 0, sizeof(TelCallDial_t));
355
356         data.CallType = atoi(data_call_type);
357         len = strlen(data_call_number);
358         if (len > TAPI_CALL_DIALDIGIT_LEN_MAX) {
359                 msg("number too long");
360                 return 0;
361         }
362
363         memcpy(data.szNumber, data_call_number, len);
364
365         msg("call tel_dail_call()");
366
367         result = tel_dial_call(handle, &data, on_dial_call, NULL);
368         if (result != TAPI_API_SUCCESS) {
369                 msg("failed. (result = %d)", result);
370         }
371
372         return result;
373 }
374
375 static int run_call_answer(MManager *mm, struct menu_data *menu)
376 {
377         TapiHandle *handle = menu_manager_ref_user_data(mm);
378         int result;
379         unsigned int call_id;
380         TelCallAnswerType_t answer_type;
381
382
383         msg("call tel_answer_call()");
384
385         call_id = atoi(data_call_id);
386         answer_type = atoi(data_answer_type);
387
388         result = tel_answer_call(handle, call_id, answer_type, on_answer_call, NULL);
389         if (result != TAPI_API_SUCCESS) {
390                 msg("failed. (result = %d)", result);
391         }
392
393         return result;
394 }
395
396 static int run_call_end(MManager *mm, struct menu_data *menu)
397 {
398         TapiHandle *handle = menu_manager_ref_user_data(mm);
399         int result;
400         unsigned int call_id;
401         TelCallEndType_t end_type;
402
403         msg("call tel_end_call()");
404
405         call_id = atoi(data_call_id);
406         end_type = atoi(data_end_type);
407
408         result = tel_end_call(handle, call_id, end_type, on_end_call, NULL);
409         if (result != TAPI_API_SUCCESS) {
410                 msg("failed. (result = %d)", result);
411         }
412
413         return result;
414 }
415
416 static int run_call_hold(MManager *mm, struct menu_data *menu)
417 {
418         TapiHandle *handle = menu_manager_ref_user_data(mm);
419         int result;
420         unsigned int call_id;
421
422         msg("call tel_hold_call()");
423
424         call_id = atoi(data_call_id);
425         result = tel_hold_call(handle, call_id, on_hold_call, NULL);
426
427         if (result != TAPI_API_SUCCESS) {
428                 msg("failed. (result = %d)", result);
429         }
430
431         return result;
432 }
433
434 static int run_call_join(MManager *mm, struct menu_data *menu)
435 {
436         TapiHandle *handle = menu_manager_ref_user_data(mm);
437         int result;
438         unsigned int call_id;
439
440         msg("call tel_join_call()");
441
442         call_id = atoi(data_call_id);
443
444         result = tel_join_call(handle, call_id, 0, on_join_call, NULL);
445         if (result != TAPI_API_SUCCESS) {
446                 msg("failed. (result = %d)", result);
447         }
448
449         return result;
450 }
451
452 static int run_call_active(MManager *mm, struct menu_data *menu)
453 {
454         TapiHandle *handle = menu_manager_ref_user_data(mm);
455         int result;
456         unsigned int call_id;
457
458         msg("call tel_active_call()");
459
460         call_id = atoi(data_call_id);
461         result = tel_active_call(handle, call_id, on_active_call, NULL);
462         if (result != TAPI_API_SUCCESS) {
463                 msg("failed. (result = %d)", result);
464         }
465
466         return result;
467 }
468
469
470 static int run_call_split(MManager *mm, struct menu_data *menu)
471 {
472         TapiHandle *handle = menu_manager_ref_user_data(mm);
473         int result;
474         unsigned int call_id;
475
476         msg("call tel_split_call()");
477
478         call_id = atoi(data_call_id);
479
480         result = tel_split_call(handle, call_id, on_split_call, NULL);
481         if (result != TAPI_API_SUCCESS) {
482                 msg("failed. (result = %d)", result);
483         }
484
485         return result;
486 }
487
488 static int run_call_swap(MManager *mm, struct menu_data *menu)
489 {
490         TapiHandle *handle = menu_manager_ref_user_data(mm);
491         int result;
492         unsigned int call_id;
493         unsigned int call_id2;
494
495         msg("call tel_swap_call()");
496
497         call_id = atoi(data_call_id);
498         call_id2 = atoi(data_call_id2);
499         result = tel_swap_call(handle, call_id, call_id2, on_swap_call, NULL);
500
501         if (result != TAPI_API_SUCCESS) {
502                 msg("failed. (result = %d)", result);
503         }
504
505         return result;
506 }
507
508
509 static int run_call_transfer(MManager *mm, struct menu_data *menu)
510 {
511         TapiHandle *handle = menu_manager_ref_user_data(mm);
512         int result;
513         unsigned int call_id;
514
515
516         msg("call tel_transfer_call()");
517
518         call_id = atoi(data_call_id);
519
520         result = tel_transfer_call(handle, call_id, on_transfer_call, NULL);
521         if (result != TAPI_API_SUCCESS) {
522                 msg("failed. (result = %d)", result);
523         }
524
525         return result;
526 }
527
528 static int run_call_start_cont_dtmf(MManager *mm, struct menu_data *menu)
529 {
530         TapiHandle *handle = menu_manager_ref_user_data(mm);
531         int result;
532
533         msg("call tel_start_call_cont_dtmf()");
534
535         result = tel_start_call_cont_dtmf(handle, data_dtmf_digit[0], on_start_cont_dtmf_call, NULL);
536         if (result != TAPI_API_SUCCESS) {
537                 msg("failed. (result = %d)", result);
538         }
539
540         return result;
541 }
542
543 static int run_call_stop_cont_dtmf(MManager *mm, struct menu_data *menu)
544 {
545         TapiHandle *handle = menu_manager_ref_user_data(mm);
546         int result;
547
548         msg("call tel_stop_call_cont_dtmf()");
549
550         result = tel_stop_call_cont_dtmf(handle, on_stop_cont_dtmf_call, NULL);
551         if (result != TAPI_API_SUCCESS) {
552                 msg("failed. (result = %d)", result);
553         }
554
555         return result;
556 }
557
558 static int run_call_send_burst_dtmf(MManager *mm, struct menu_data *menu)
559 {
560         TapiHandle *handle = menu_manager_ref_user_data(mm);
561         int result;
562         TelCallBurstDtmf_t info;
563         memset(&info, 0x0, sizeof(info));
564         g_strlcpy(info.dtmf_string, data_dtmf_string, TAPI_CALL_BURST_DTMF_STRING_MAX + 1);
565         info.pulse_width = data_dtmf_pulse_width[0];
566         info.inter_digit_interval = data_dtmf_inter_digit_interval[0];
567
568         msg("call tel_send_call_burst_dtmf()");
569
570         result = tel_send_call_burst_dtmf(handle, &info,on_send_burst_dtmf_call, NULL);
571         if (result != TAPI_API_SUCCESS) {
572                 msg("failed. (result = %d)", result);
573         }
574
575         return result;
576 }
577
578
579 static void call_status_callback( TelCallStatus_t *status, void *user_data )
580 {
581
582         msg(" - id = %d", status->CallHandle);
583         msg(" - direction = %d", status->bMoCall);
584         msg(" - number = %s", status->pNumber);
585         msg(" - type = %d", status->CallType);
586         msg(" - state = %d", status->CallState);
587         msg(" - multiparty = %d", status->bConferenceState);
588
589 }
590
591 static int run_call_get_status(MManager *mm, struct menu_data *menu)
592 {
593         TapiHandle *handle = menu_manager_ref_user_data(mm);
594         int result;
595         unsigned int call_id = 0;
596         TelCallStatus_t info;
597
598         msg("call tel_get_call_status()");
599
600         call_id = atoi(data_call_id);
601
602         result = tel_get_call_status(handle, call_id, &info);
603         if (result != TAPI_API_SUCCESS) {
604                 msg("failed. (result = %d)", result);
605                 return result ;
606         }
607
608         msg(" - id = %d", info.CallHandle);
609         msg(" - direction = %d", info.bMoCall);
610         msg(" - number = %s", info.pNumber);
611         msg(" - type = %d", info.CallType);
612         msg(" - state = %d", info.CallState);
613         msg(" - multiparty = %d", info.bConferenceState);
614
615         return result;
616 }
617
618 static int run_call_get_status_all(MManager *mm, struct menu_data *menu)
619 {
620         TapiHandle *handle = menu_manager_ref_user_data(mm);
621         int result = 0;
622
623         msg("call tel_get_call_status_all()");
624
625         result = tel_get_call_status_all(handle, call_status_callback, NULL);
626         if (result != TAPI_API_SUCCESS) {
627                 msg("failed. (result = %d)", result);
628         }
629
630         return result;
631 }
632
633 static int run_call_set_mute_status(MManager *mm, struct menu_data *menu)
634 {
635         TapiHandle *handle = menu_manager_ref_user_data(mm);
636         int result = 0;
637         TelSoundMutePath_t path = 0;
638         TelSoundMuteStatus_t status = 0;
639
640         msg("call tel_set_call_mute_status()");
641
642         path = (TelSoundMutePath_t)atoi(data_mute_path);
643         status = (TelSoundMuteStatus_t)atoi(data_mute_status);
644
645         msg("path : (%d)", path);
646         msg("status : (%d)", status);
647
648         result = tel_set_call_mute_status(handle, status, path, on_call_set_mute_status, NULL);
649         if (result != TAPI_API_SUCCESS) {
650                 msg("failed. (result = %d)", result);
651         }
652
653         return result;
654 }
655
656 static int run_call_get_mute_status(MManager *mm, struct menu_data *menu)
657 {
658         TapiHandle *handle = menu_manager_ref_user_data(mm);
659         int result = 0;
660
661         msg("call tel_get_call_mute_status()");
662
663         result = tel_get_call_mute_status(handle, on_call_get_mute_status, NULL);
664         if (result != TAPI_API_SUCCESS) {
665                 msg("failed. (result = %d)", result);
666         }
667
668         return result;
669 }
670
671 static int run_call_set_volume_info(MManager *mm, struct menu_data *menu)
672 {
673         TapiHandle *handle = menu_manager_ref_user_data(mm);
674         int result = 0;
675         TelCallVolumeInfo_t data;
676
677         msg("call tel_set_call_volume_info()");
678
679         data.device = (TelSoundDevice_t)atoi(data_vol_device);
680         data.type = (TelSoundType_t)atoi(data_vol_type);
681         data.volume = (TelSoundVolume_t)atoi(data_vol_level);
682
683         msg("device : (%d)", data.device);
684         msg("type : (%d)", data.type);
685         msg("volume : (%d)", data.volume);
686
687         result = tel_set_call_volume_info(handle, &data, on_call_set_volume_info, NULL);
688         if (result != TAPI_API_SUCCESS) {
689                 msg("failed. (result = %d)", result);
690         }
691
692         return result;
693 }
694
695 static int run_call_get_volume_info(MManager *mm, struct menu_data *menu)
696 {
697         TapiHandle *handle = menu_manager_ref_user_data(mm);
698         int result = 0;
699         TelSoundDevice_t device;
700         TelSoundType_t type;
701
702         msg("call tel_get_call_volume_info()");
703
704         device = (TelSoundDevice_t)atoi(data_vol_device);
705         type = (TelSoundType_t)atoi(data_vol_type);
706
707         msg("device : (%d)", device);
708         msg("type : (%d)", type);
709
710         result = tel_get_call_volume_info(handle, device, type, on_call_get_volume_info, NULL);
711         if (result != TAPI_API_SUCCESS) {
712                 msg("failed. (result = %d)", result);
713         }
714
715         return result;
716 }
717
718 static int run_call_set_sound_path(MManager *mm, struct menu_data *menu)
719 {
720         TapiHandle *handle = menu_manager_ref_user_data(mm);
721         int result = 0;
722         TelCallSoundPathInfo_t sound_path ;
723
724         msg("call tel_set_sound_path()");
725
726         sound_path.path = (TelSoundPath_t)atoi(data_sound_path);
727         sound_path.ex_volume = atoi(data_extra_volume_status);
728
729         msg("sound_path.path : (0x%x)", sound_path.path);
730         msg("sound_path.ex_volume : (0x%x)", sound_path.ex_volume);
731
732         result = tel_set_call_sound_path(handle, &sound_path, on_call_set_sound_path, NULL);
733         if (result != TAPI_API_SUCCESS) {
734                 msg("failed. (result = %d)", result);
735         }
736
737         return result;
738 }
739
740 static int run_call_set_preferred_voice_subscription(MManager *mm, struct menu_data *menu)
741 {
742         TapiHandle *handle = menu_manager_ref_user_data(mm);
743         int result = 0;
744         TelCallPreferredVoiceSubs_t preferred_subscription;
745
746         msg("call run_call_set_preferred_voice_subscription()");
747
748         preferred_subscription = (TelCallPreferredVoiceSubs_t)atoi(data_preferred_voice_subscription);
749
750         msg("preferred_subscription : (%d)", preferred_subscription);
751
752         result = tel_set_call_preferred_voice_subscription(handle, preferred_subscription, on_call_set_preferred_voice_subscription, NULL);
753         if (result != TAPI_API_SUCCESS) {
754                 msg("failed. (result = %d)", result);
755         }
756
757         return result;
758 }
759
760 static int run_call_get_preferred_voice_subscription(MManager *mm, struct menu_data *menu)
761 {
762         TapiHandle *handle = menu_manager_ref_user_data(mm);
763         int result = 0;
764         TelCallPreferredVoiceSubs_t preferred_subscription = TAPI_CALL_PREFERRED_VOICE_SUBS_UNKNOWN;
765
766         msg("call tel_get_call_preferred_voice_subscription()");
767
768         result = tel_get_call_preferred_voice_subscription(handle, &preferred_subscription);
769         if (result != TAPI_API_SUCCESS) {
770                 msg("failed. (result = %d)", result);
771         }
772         else {
773                 msg("'preferred' Voice call subscription = (%d)", preferred_subscription);
774         }
775
776         return result;
777 }
778
779 static struct menu_data menu_call_dial[] = {
780         { "1", "type (0=VOICE, 1=VIDEO, 2=Emergency)", 0, 0, data_call_type},
781         { "2", "number", 0, 0, data_call_number},
782         { "3", "run", 0, run_call_dial, 0},
783         { 0, 0, },
784 };
785
786 static struct menu_data menu_call_answer[] = {
787         { "1", "id", 0, 0, data_call_id},
788         { "2", "type (0=ACCEPT, 1=REJECT, 2=REPLACE, 3=HOLD&ACCEPT)", 0, 0, data_answer_type},
789         { "3", "run", 0, run_call_answer, 0},
790         { 0, 0, },
791 };
792
793 static struct menu_data menu_call_end[] = {
794         { "1", "id", 0, 0, data_call_id},
795         { "2", "type (0=END, 1=END ALL, 2=END ACTIVE ALL, 3=END HOLD ALL)", 0, 0, data_end_type},
796         { "3", "run", 0, run_call_end, 0},
797         { 0, 0, },
798 };
799
800 static struct menu_data menu_call_hold[] = {
801         { "1", "id", 0, 0, data_call_id},
802         { "2", "run", 0, run_call_hold, 0},
803         { 0, 0, },
804 };
805
806 static struct menu_data menu_call_active[] = {
807         { "1", "id", 0, 0, data_call_id},
808         { "2", "run", 0, run_call_active, 0},
809         { 0, 0, },
810 };
811
812 static struct menu_data menu_call_swap[] = {
813         { "1", "id", 0, 0, data_call_id},
814         { "2", "id2", 0, 0, data_call_id2},
815         { "3", "run", 0, run_call_swap, 0},
816 };
817
818 static struct menu_data menu_call_join[] = {
819         { "1", "id", 0, 0, data_call_id},
820         { "2", "run", 0, run_call_join, 0},
821         { 0, 0, },
822 };
823
824 static struct menu_data menu_call_split[] = {
825         { "1", "id", 0, 0, data_call_id},
826         { "2", "run", 0, run_call_split, 0},
827         { 0, 0, },
828 };
829
830 static struct menu_data menu_call_transfer[] = {
831         { "1", "id", 0, 0, data_call_id},
832         { "2", "run", 0, run_call_transfer, 0},
833         { 0, 0, },
834 };
835
836 static struct menu_data menu_call_start_cont_dtmf[] = {
837         { "1", "Dtmf Charater(0-9, A-D, ' * ' and ' # ') one character at a time ", NULL, NULL, data_dtmf_digit},
838         { "2", "run", NULL, run_call_start_cont_dtmf, NULL},
839         { NULL, NULL, },
840 };
841
842 static struct menu_data menu_call_stop_cont_dtmf[] = {
843         { "1", "run", NULL, run_call_stop_cont_dtmf, NULL},
844         { NULL, NULL, },
845 };
846
847 static struct menu_data menu_call_send_burst_dtmf[] = {
848         { "1", "Dtmf String(0-9, A-D, ' * ' and ' # ') one character or a string of characters ", NULL, NULL, data_dtmf_string},
849         { "2", "DTMF pulse width (ONLENGTH_95MS=0x0, ONLENGTH_150MS=0x1, ONLENGTH_200MS=0x2, ONLENGTH_250MS=0x3, ONLENGTH_300MS=0x4, ONLENGTH_350MS=0x5, ONLENGTH_SMS=0x6)", NULL, NULL, data_dtmf_pulse_width},
850         { "3", "DTMF inter digit interval (OFFLENGTH_60MS=0x0, OFFLENGTH_100MS=0x1, OFFLENGTH_150MS=0x2, OFFLENGTH_200MS=0x3)", NULL, NULL, data_dtmf_inter_digit_interval},
851         { "4", "run", NULL, run_call_send_burst_dtmf, NULL},
852         { NULL, NULL, },
853 };
854
855
856 static struct menu_data menu_call_get_status[] = {
857         { "1", "id", 0, 0, data_call_id},
858         { "2", "run", 0, run_call_get_status, 0},
859         { 0, 0, },
860 };
861
862 static struct menu_data menu_call_get_status_all[] = {
863         { "1", "id", 0, 0, data_call_id},
864         { "2", "run", 0, run_call_get_status_all, 0},
865         { 0, 0, },
866 };
867
868 static struct menu_data menu_call_set_mute_status[] = {
869         { "1", "status", 0, 0, data_mute_status},
870         { "2", "path", 0, 0, data_mute_path},
871         { "3", "run", 0, run_call_set_mute_status, 0},
872         { 0, 0, },
873 };
874
875 static struct menu_data menu_call_get_mute_status[] = {
876         { "1", "run", 0, run_call_get_mute_status, 0},
877         { 0, 0, },
878 };
879
880 static struct menu_data menu_call_set_volume_info[] = {
881         { "1", "device", 0, 0, data_vol_device},
882         { "2", "type", 0, 0, data_vol_type},
883         { "3", "volume", 0, 0, data_vol_level},
884         { "4", "run", 0, run_call_set_volume_info, 0},
885         { 0, 0, },
886 };
887
888 static struct menu_data menu_call_get_volume_info[] = {
889         { "1", "device", 0, 0, data_vol_device},
890         { "2", "type", 0, 0, data_vol_type},
891         { "3", "run", 0, run_call_get_volume_info, 0},
892         { 0, 0, },
893 };
894
895 static struct menu_data menu_call_set_sound_path[] = {
896         { "1", "Sound path(1= HANDSET, 2= HEADSET, 3= HANDSFREE, 4=BUETOOTH, 5=STEREO_BLUETOOTH, 6=SPK_PHONE, 7=HEADSET_5_PI, 8=BT_NSCE_OFF, 9=MIC1, 10=MIC2, 11=HEADSET_HAC)", 0, 0, data_sound_path},
897         { "2", "Extra Volume Status( 0=OFF, 1=ON)", 0, 0, data_extra_volume_status},
898         { "3", "run", 0, run_call_set_sound_path, 0},
899         { 0, 0, },
900 };
901
902 static struct menu_data menu_call_set_preferred_voice_subscription[] = {
903         { "1", "Preferred Voice call Subcription (0=Current network, 1=ASK Always, 2=SIM 1, 3=SIM 2)", 0, 0, data_preferred_voice_subscription},
904         { "2", "run", 0, run_call_set_preferred_voice_subscription, 0},
905         { 0, 0, },
906 };
907
908 static struct menu_data menu_call_get_preferred_voice_subscription[] = {
909         { "1", "run", 0, run_call_get_preferred_voice_subscription, 0},
910         { 0, 0, },
911 };
912
913 struct menu_data menu_call[] = {
914         { "1", "tel_dial_call", menu_call_dial, 0, 0},
915         { "2", "tel_answer_call", menu_call_answer, 0, 0},
916         { "3", "tel_end_call", menu_call_end, 0, 0},
917         { "4", "tel_hold_call", menu_call_hold, 0, 0},
918         { "5", "tel_active_call", menu_call_active, 0, 0},
919         { "6", "tel_swap_call", menu_call_swap, 0, 0},
920         { "7", "tel_join_call", menu_call_join, 0, 0},
921         { "8", "tel_split_call", menu_call_split, 0, 0},
922         { "9", "tel_transfer_call", menu_call_transfer, 0, 0},
923         { "10", "tel_start_call_cont_dtmf_call", menu_call_start_cont_dtmf, NULL, NULL},
924         { "11", "tel_stop_call_cont_dtmf_call", menu_call_stop_cont_dtmf, NULL, NULL},
925         { "12", "tel_send_call_burst_dtmf", menu_call_send_burst_dtmf, NULL, NULL},
926         { "13", "tel_get_call_status", menu_call_get_status, NULL, NULL},
927         { "14", "tel_get_call_status_all", menu_call_get_status_all, NULL, NULL},
928         { "15", "tel_set_call_mute_status", menu_call_set_mute_status, NULL, NULL},
929         { "16", "tel_get_call_mute_status", menu_call_get_mute_status, NULL, NULL},
930         { "17", "tel_set_call_volume_info", menu_call_set_volume_info, NULL, NULL},
931         { "18", "tel_get_call_volume_info", menu_call_get_volume_info, NULL, NULL},
932         { "19", "tel_set_call_sound_path", menu_call_set_sound_path, NULL, NULL},
933        { "20", "tel_set_call_preferred_voice_subscription", menu_call_set_preferred_voice_subscription, 0, 0},
934        { "21", "tel_get_call_preferred_voice_subscription", menu_call_get_preferred_voice_subscription, 0, 0},
935         { 0, 0, },
936 };
937
938 void register_call_event(TapiHandle *handle)
939 {
940         int ret;
941
942         ret = tel_register_noti_event(handle, TAPI_NOTI_VOICE_CALL_STATUS_IDLE, on_noti_call_status_idle, 0);
943         if (ret != TAPI_API_SUCCESS) {
944                 msg("event register failed(%d)", ret);
945         }
946
947         ret = tel_register_noti_event(handle, TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE, on_noti_call_status_active, 0);
948         if (ret != TAPI_API_SUCCESS) {
949                 msg("event register failed(%d)", ret);
950         }
951
952         ret = tel_register_noti_event(handle, TAPI_NOTI_VOICE_CALL_STATUS_HELD, on_noti_call_status_held, 0);
953         if (ret != TAPI_API_SUCCESS) {
954                 msg("event register failed(%d)", ret);
955         }
956
957         ret = tel_register_noti_event(handle, TAPI_NOTI_VOICE_CALL_STATUS_DIALING, on_noti_call_status_dialing, 0);
958         if (ret != TAPI_API_SUCCESS) {
959                 msg("event register failed(%d)", ret);
960         }
961
962         ret = tel_register_noti_event(handle, TAPI_NOTI_VOICE_CALL_STATUS_ALERT, on_noti_call_status_alert, 0);
963         if (ret != TAPI_API_SUCCESS) {
964                 msg("event register failed(%d)", ret);
965         }
966
967         ret = tel_register_noti_event(handle, TAPI_NOTI_VOICE_CALL_STATUS_INCOMING, on_noti_call_status_incoming, 0);
968         if (ret != TAPI_API_SUCCESS) {
969                 msg("event register failed(%d)", ret);
970         }
971
972         ret = tel_register_noti_event(handle, TAPI_NOTI_CALL_INFO_HELD, on_noti_call_on_hold, 0);
973         if (ret != TAPI_API_SUCCESS) {
974                 msg("event register failed(%d)", ret);
975         }
976
977         ret = tel_register_noti_event(handle, TAPI_NOTI_CALL_INFO_ACTIVE, on_noti_call_active, 0);
978         if (ret != TAPI_API_SUCCESS) {
979                 msg("event register failed(%d)", ret);
980         }
981
982         ret = tel_register_noti_event(handle, TAPI_NOTI_CALL_INFO_JOINED, on_noti_call_joined, 0);
983         if (ret != TAPI_API_SUCCESS) {
984                 msg("event register failed(%d)", ret);
985         }
986
987         ret = tel_register_noti_event(handle, TAPI_NOTI_CALL_SOUND_RINGBACK_TONE, on_noti_call_sound_ringback_tone, 0);
988         if (ret != TAPI_API_SUCCESS) {
989                 msg("event register failed(%d)", ret);
990         }
991
992         ret = tel_register_noti_event(handle, TAPI_NOTI_CALL_SOUND_WBAMR, on_noti_call_sound_wbamr, 0);
993         if (ret != TAPI_API_SUCCESS) {
994                 msg("event register failed(%d)", ret);
995         }
996
997         ret = tel_register_noti_event(handle, TAPI_NOTI_CALL_SOUND_PATH, on_noti_call_sound_path, 0);
998         if (ret != TAPI_API_SUCCESS) {
999                 msg("event register failed(%d)", ret);
1000         }
1001
1002         ret = tel_register_noti_event(handle, TAPI_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION, on_noti_call_preferred_voice_subscription, 0);
1003         if (ret != TAPI_API_SUCCESS) {
1004                 msg("event register failed(%d)", ret);
1005         }
1006 }
1007