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