VoIPUtil.c
126 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* VoIPUtil.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* Coding Template header file
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifndef __MTK_TARGET__
#include <windows.h>
#endif
#include "MMI_include.h"
#include "MMI_features.h"
#ifdef __MMI_VOIP__
#include "ProtocolEvents.h"
#include "CommonScreens.h"
#include "SettingProfile.h"
#include "custom_nvram_editor_data_item.h"
#include "custom_data_account.h"
#include "Conversions.h"
#include "DateTimeGprot.h"
#include "FileManagerGProt.h"
#include "FileMgrSrvGProt.h"
#include "gpioInc.h"
#include "mdi_datatype.h"
#include "mdi_audio.h"
#include "ProfilesDefs.h"
#include "ProfileGprots.h"
#include "PhoneBookGprot.h"
#include "app2soc_struct.h"
#include "soc_api.h"
#include "med_struct.h"
#include "rtp_api.h"
#include "UcmSrvGProt.h"
#include "..\..\..\Service\UcmSrv\UcmSrvIntProt.h"
#include "mmi_rp_srv_gcall_def.h" /* IMG_ID_GCALL_OUTGOING */
#include "PhoneBookDef.h" /* IMG_PHB_DEFAULT */
#include "VoIPResDef.h"
#include "VoIPGProt.h"
#include "VoIPProt.h"
extern void* g_voip_ucm_user_data;
const U8 sipUri[10] = { 's', '\0', 'i', '\0', 'p', '\0', ':', '\0', '\0', '\0' }; /* sip: */
const U8 telUri[10] = { 't', '\0', 'e', '\0', 'l', '\0', ':', '\0', '\0', '\0' }; /* tel: */
const U8 anonyUri[30] = { 's', '\0', 'i', '\0', 'p', '\0', ':', '\0', 'a', '\0', 'n', '\0', 'o', '\0', 'n', '\0', 'y', '\0', 'm', '\0', 'o', '\0', 'u', '\0', 's', '\0', '@', '\0', '\0', '\0' }; /* sip: anonymous@ */
const U8 sosUri[8] = { 's', '\0', 'o', '\0', 's', '\0', '\0', '\0' }; /* sos */
const U8 sos112[8] = { '1', '\0', '1', '\0', '2', '\0', '\0', '\0' }; /* 112 */
const U8 sos911[8] = { '9', '\0', '1', '\0', '1', '\0', '\0', '\0' }; /* 911 */
const U8 zeroIp[8] = { '0', '\0', '0', '\0', '0', '\0', '\0', '\0' }; /* 000 */
const U16 VoIPDTMFDigits[MMI_VOIP_MAX_NUM_DIGITS] =
{
KEY_1, KEY_2, KEY_3,
KEY_4, KEY_5, KEY_6,
KEY_7, KEY_8, KEY_9,
KEY_STAR, KEY_0, KEY_POUND
};
const mmi_voip_error_string_struct g_voip_error_table[] =
{
{VOIP_UNSPECIFIED_ERROR, STR_ID_VOIP_UNKNOWN_ERROR},
{VOIP_NOT_REGISTERED, STR_ID_VOIP_NOT_REGISTER},
{VOIP_ALREADY_REGISTERED, STR_ID_VOIP_ALREADY_REGISTER},
{VOIP_INVALID_PARAM, STR_ID_VOIP_INVALID_PARAMETER},
{VOIP_CREATE_UAC_ERROR, STR_ID_VOIP_SIP_ERROR},
{VOIP_GET_ADDR_FAILED, STR_ID_VOIP_INVALID_URI},
{VOIP_CALL_ABORT_LOCALLY, STR_ID_VOIP_CALL_END},
{VOIP_RECV_BYE, STR_ID_VOIP_CALL_END},
{VOIP_INCORRECT_CALL_STATE, STR_ID_VOIP_ACTION_INVALID},
{VOIP_BEARER_DISCONNECTED, STR_ID_VOIP_NETWORK_DOWN},
{VOIP_ABORT_FAILED, STR_ID_VOIP_CALL_END},
{VOIP_CALL_NOT_EXIST, STR_ID_VOIP_CALL_NOT_EXIST},
{VOIP_INVALID_URI, STR_ID_VOIP_INVALID_URI},
{VOIP_SWAP_FAILED, STR_ID_VOIP_SWAP_FAIL},
{VOIP_SWAP_PARTIAL_FAILED, STR_ID_VOIP_SWAP_FAIL},
{VOIP_TRANSFER_FAILED, STR_ID_VOIP_TRANSFER_FAIL},
{VOIP_MERGE_FAILED, STR_ID_VOIP_CONFERENCE_FAIL},
{VOIP_MERGE_PARTIAL_FAILED, STR_ID_VOIP_CONFERENCE_FAIL},
{VOIP_NAT_FAILED, STR_ID_VOIP_NAT_ERROR},
{VOIP_TEMPORARY_BUSY, STR_ID_VOIP_ACTION_CONFLICT},
{VOIP_UNSUPPORTED_NAT_TYPE, STR_ID_VOIP_NAT_ERROR},
{VOIP_NETWORK_ERROR, STR_ID_VOIP_NETWORK_ERROR},
{VOIP_BUSY, STR_ID_VOIP_ACTION_CONFLICT},
{VOIP_INVALID_CALL_REQ, STR_ID_VOIP_ACTION_INVALID},
{VOIP_PARTIAL_FAILED, STR_ID_VOIP_UNKNOWN_ERROR},
{VOIP_REREGISTER_FAILED, STR_ID_VOIP_REGISTER_FAIL},
{VOIP_SDP_MISMATCHED, STR_ID_VOIP_SDP_ERROR},
{VOIP_DNS_ERROR, STR_ID_VOIP_DNS_ERROR},
{VOIP_NO_RESOURCE, STR_ID_VOIP_UNKNOWN_ERROR},
{VOIP_SIP_FS_ERROR, STR_ID_VOIP_UNKNOWN_ERROR},
{VOIP_DHCP_ERROR, STR_ID_VOIP_NETWORK_ERROR},
{VOIP_SIP_300_MULTIPLE_CHOICES, STR_ID_VOIP_NETWORK_ERROR},
{VOIP_SIP_301_MOVED_PERMANENTLY, STR_ID_VOIP_NUMBER_MOVE},
{VOIP_SIP_302_MOVED_TEMPORARILY, STR_ID_VOIP_NUMBER_MOVE},
{VOIP_SIP_305_USE_PROXY, STR_ID_VOIP_SIP_ERROR},
{VOIP_SIP_400_BAD_REQUEST, STR_ID_VOIP_ACTION_INVALID},
{VOIP_SIP_401_UNAUTHORIZED, STR_ID_VOIP_AUTHENTICATION_FAIL},
{VOIP_SIP_403_FORBIDDEN, STR_ID_VOIP_ACTION_FORBIDDEN},
{VOIP_SIP_404_NOT_FOUND, STR_ID_VOIP_USER_NOT_FOUND},
{VOIP_SIP_405_METHOD_NOT_ALLOW, STR_ID_VOIP_SIP_ERROR},
{VOIP_SIP_406_NOT_ACCEPTABLE, STR_ID_VOIP_USER_BUSY},
{VOIP_SIP_407_PROXY_AUTH_REQUIRED, STR_ID_VOIP_AUTHENTICATION_FAIL},
{VOIP_SIP_408_REQUEST_TIMEOUT, STR_ID_VOIP_REQUEST_TIMEOUT},
{VOIP_SIP_412_CONDITIONAL_REQ_FAIL, STR_ID_VOIP_SIP_ERROR},
{VOIP_SIP_422_INTERVAL_TOO_BRIEF, STR_ID_VOIP_SIP_ERROR},
{VOIP_SIP_423_INTERVAL_TOO_BRIEF, STR_ID_VOIP_SIP_ERROR},
{VOIP_SIP_478_UNRESOLVEABLE_DEST, STR_ID_VOIP_USER_NOT_FOUND},
{VOIP_SIP_480_TEMP_UNAVAILABLE, STR_ID_VOIP_USER_BUSY},
{VOIP_SIP_481_CALL_TRANS_NOT_EXIST, STR_ID_VOIP_CALL_NOT_EXIST},
{VOIP_SIP_484_ADDRESS_INCOMPLETE, STR_ID_VOIP_USER_NOT_FOUND},
{VOIP_SIP_486_BUSY_HERE, STR_ID_VOIP_USER_BUSY},
{VOIP_SIP_487_REQ_TERMINATED, STR_ID_VOIP_CALL_END},
{VOIP_SIP_488_NOT_ACCEPTABLE_HERE, STR_ID_VOIP_USER_BUSY},
{VOIP_SIP_491_REQUEST_PENDING, STR_ID_VOIP_USER_BUSY},
{VOIP_SIP_499_UNRESOLVEABLE_DEST, STR_ID_VOIP_USER_NOT_FOUND},
{VOIP_SIP_500_SERVER_INT_ERROR, STR_ID_VOIP_NETWORK_ERROR},
{VOIP_SIP_503_SERVICE_UNAVAILABLE, STR_ID_VOIP_NETWORK_ERROR},
{VOIP_SIP_600_BUSY_EVERYWHERE, STR_ID_VOIP_USER_BUSY},
{VOIP_SIP_603_DECLINE, STR_ID_VOIP_USER_BUSY},
{VOIP_SIP_606_NOT_ACCEPTABLE, STR_ID_VOIP_USER_BUSY},
{0, STR_ID_VOIP_UNKNOWN_ERROR}
};
extern MMI_BOOL mmi_voip_get_caller_res_info(void *info);
/*****************************************************************************
* FUNCTION
* mmi_voip_set_processing_parameter
* DESCRIPTION
* Set processing screen parameter.
* PARAMETERS
* titleStr [IN] Title string
* bodyStr [IN] Body string
* animationImg [IN] Animation image
* lskStr [IN] LSK display string
* lskFunc [IN] LSK function pointer
* rskStr [IN] RSK display string
* rskFunc [IN] RSK function pointer
* sendFunc [IN] SEND key function pointer
* endFunc [IN] END key function pointer
* RETURNS
* void
*****************************************************************************/
void mmi_voip_set_processing_parameter(
U16 titleStr,
U16 bodyStr,
U16 animationImg,
U16 lskStr,
FuncPtr lskFunc,
U16 rskStr,
FuncPtr rskFunc,
FuncPtr sendFunc,
FuncPtr endFunc)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
g_voip_cntx_p->proc_scr_info.title_string = titleStr;
g_voip_cntx_p->proc_scr_info.body_string = bodyStr;
g_voip_cntx_p->proc_scr_info.animation_image = animationImg;
g_voip_cntx_p->proc_scr_info.lsk_string = lskStr;
g_voip_cntx_p->proc_scr_info.lsk_funcPtr = lskFunc;
g_voip_cntx_p->proc_scr_info.rsk_string = rskStr;
g_voip_cntx_p->proc_scr_info.rsk_funcPtr = rskFunc;
g_voip_cntx_p->proc_scr_info.send_funcPtr = sendFunc;
g_voip_cntx_p->proc_scr_info.end_funcPtr = endFunc;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_entry_processing_screen
* DESCRIPTION
* General entry function of processing screen.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_voip_entry_processing_screen(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *guiBuffer = NULL;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
EntryNewScreen(SCR_ID_VOIP_PROCESSING, NULL, mmi_voip_entry_processing_screen, NULL);
guiBuffer = GetCurrGuiBuffer(SCR_ID_VOIP_PROCESSING);
ShowCategory66Screen(
g_voip_cntx_p->proc_scr_info.title_string,
GetRootTitleIcon(MENU_ID_VOIP_MAIN),
g_voip_cntx_p->proc_scr_info.lsk_string,
IMG_GLOBAL_OK,
g_voip_cntx_p->proc_scr_info.rsk_string,
IMG_GLOBAL_BACK,
(U8*) GetString(g_voip_cntx_p->proc_scr_info.body_string),
g_voip_cntx_p->proc_scr_info.animation_image,
NULL);
SetLeftSoftkeyFunction(g_voip_cntx_p->proc_scr_info.lsk_funcPtr, KEY_EVENT_UP);
SetRightSoftkeyFunction(g_voip_cntx_p->proc_scr_info.rsk_funcPtr, KEY_EVENT_UP);
SetKeyHandler(g_voip_cntx_p->proc_scr_info.send_funcPtr, KEY_SEND, KEY_EVENT_DOWN);
SetKeyHandler(g_voip_cntx_p->proc_scr_info.end_funcPtr, KEY_END, KEY_EVENT_DOWN);
}
/*****************************************************************************
* FUNCTION
* mmi_voip_validate_port
* DESCRIPTION
* Validate port. 0~65535 is a valid range of port.
* PARAMETERS
* unicodePort [IN] Port string in unicode
* RETURNS
* TRUE means port number is valid; FALSE means port number is invalid.
*****************************************************************************/
MMI_BOOL mmi_voip_validate_port(U8 *unicodePort)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 portNumber = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
portNumber = gui_atoi((UI_string_type) unicodePort);
if ((portNumber >= 0) && (portNumber <= 65535))
{
return TRUE;
}
return FALSE;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_validate_uri
* DESCRIPTION
* Validate uri. Only one @ can appear in the uri.
* The @ cannot in the beginning of the uri,
* and cannot in the end of the uri, either.
* PARAMETERS
* unicodeUri [IN] Uri string in unicode
* RETURNS
* TRUE means uri is valid; FALSE means uri is invalid.
*****************************************************************************/
MMI_BOOL mmi_voip_validate_uri(U8 *unicodeUri)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *lowercaseUri = OslMalloc((VOIP_URI_LEN +1 ) * ENCODING_LENGTH);
S32 count = 0;
S8 foundAt = 0;
U8 charUnit;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
memset(lowercaseUri, 0, ((VOIP_URI_LEN + 1) * ENCODING_LENGTH));
mmi_voip_convert_uri_lower_case(unicodeUri, lowercaseUri, VOIP_URI_LEN * ENCODING_LENGTH);
if ((mmi_ucs2strlen((S8*)lowercaseUri) == 0) ||
(!mmi_ucs2cmp((S8*)lowercaseUri, (S8*)sipUri)) ||
(!mmi_ucs2cmp((S8*)lowercaseUri, (S8*)telUri)))
{
OslMfree(lowercaseUri);
return TRUE;
}
while (unicodeUri[count] != '\0' || unicodeUri[count + 1] != '\0')
{
if (unicodeUri[count] > 0x7e || unicodeUri[count + 1] > 0x7e)
{
OslMfree(lowercaseUri);
return FALSE;
}
charUnit = unicodeUri[count];
switch (charUnit)
{
case '@':
{
foundAt++;
if (count == 0) /* @xxxxx */
{
OslMfree(lowercaseUri);
return FALSE;
}
else if (foundAt > 1)
{
OslMfree(lowercaseUri);
return FALSE;
}
else if (unicodeUri[count + 2] == '\0' && unicodeUri[count + 3] == '\0')
{
OslMfree(lowercaseUri);
return FALSE; /* xxxx@ */
}
else
{
break;
}
}
case ',':
case ';':
case '<':
case '>':
case '[':
case ']':
case '"':
case ')':
case '(':
OslMfree(lowercaseUri);
return FALSE;
default:
break;
}
count += 2;
}
if (foundAt == 1)
{
OslMfree(lowercaseUri);
return TRUE;
}
OslMfree(lowercaseUri);
return FALSE;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_is_validate_uri
* DESCRIPTION
* check if the uri is valid, if having @, then check with mmi_voip_validate_uri
* if not, then return TRUE
* PARAMETERS
* unicodeUri [IN] Uri string in unicode
* RETURNS
* TRUE means uri is valid; FALSE means uri is invalid.
*****************************************************************************/
MMI_BOOL mmi_voip_is_validate_uri(U8 *unicodeUri)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (mmi_ucs2chr((S8*) unicodeUri, '@') != NULL)
{
return mmi_voip_validate_uri(unicodeUri);
}
return MMI_TRUE;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_validate_ip
* DESCRIPTION
* Validate ip. 0.0.0.0 is not a valid ip.
* PARAMETERS
* ip1 [IN] First number in the ip format
* ip2 [IN] Second number in the ip format
* ip3 [IN] Third number in the ip format
* ip4 [IN] Fourth number in the ip format
* RETURNS
* TRUE means ip address is valid; FALSE means ip address is invalid.
*****************************************************************************/
MMI_BOOL mmi_voip_validate_ip(U8 *ip1, U8 *ip2, U8 *ip3, U8 *ip4)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if ((gui_atoi((UI_string_type) ip1) != 0) ||
(gui_atoi((UI_string_type) ip2) != 0) ||
(gui_atoi((UI_string_type) ip3) != 0) ||
(gui_atoi((UI_string_type) ip4) != 0))
{
return TRUE;
}
return FALSE;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_validate_dtmf
* DESCRIPTION
* Validate dtmf key. Valide dtmf key is defined in VoIPDTMFDigits array.
* PARAMETERS
* dtmfKey [IN]
* RETURNS
* TRUE means dtmf key is valid; FALSE means dtmf key is invalid.
*****************************************************************************/
MMI_BOOL mmi_voip_validate_dtmf(U16 dtmfKey)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 i = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0; i < MMI_VOIP_MAX_NUM_DIGITS; i++)
{
if (dtmfKey == VoIPDTMFDigits[i])
{
return MMI_TRUE;
}
}
return MMI_FALSE;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_ucm_utility_cbk
* DESCRIPTION
* Validate dtmf key. Valide dtmf key is defined in VoIPDTMFDigits array.
* PARAMETERS
* dtmfKey [IN]
* RETURNS
* TRUE means dtmf key is valid; FALSE means dtmf key is invalid.
*****************************************************************************/
MMI_BOOL mmi_voip_ucm_utility_cbk(srv_ucm_call_type_enum call_type, srv_ucm_int_query_enum query_type, void *ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
MMI_BOOL result = MMI_FALSE;
U8 *unicodeUri = OslMalloc((VOIP_URI_LEN + 1) * ENCODING_LENGTH);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ASSERT((call_type & SRV_UCM_VOIP_CALL_TYPE) == SRV_UCM_VOIP_CALL_TYPE);
memset((S8*) unicodeUri, 0x00, (VOIP_URI_LEN + 1) * ENCODING_LENGTH);
switch(query_type)
{
case SRV_UCM_INT_NUMBER:
{
srv_ucm_int_query_number_struct* number = (srv_ucm_int_query_number_struct*)ptr;
mmi_asc_n_to_ucs2(
(S8*)unicodeUri,
(S8*)number->num_uri,
VOIP_URI_LEN);
result = mmi_voip_is_validate_uri(unicodeUri);
break;
}
case SRV_UCM_INT_ECC_NUMBER:
{
srv_ucm_int_query_number_struct* number = (srv_ucm_int_query_number_struct*)ptr;
mmi_asc_n_to_ucs2(
(S8*)unicodeUri,
(S8*)number->num_uri,
VOIP_URI_LEN);
result = mmi_voip_is_sos_number(unicodeUri);
break;
}
case SRV_UCM_INT_DTMF_DIGIT:
{
srv_ucm_dtmf_struct* dtmf = (srv_ucm_dtmf_struct*)ptr;
result = mmi_voip_validate_dtmf(dtmf->digit);
break;
}
case SRV_UCM_INT_CALL_SRV_AVAILABLE:
{
result = mmi_voip_is_srv_available();
break;
}
case SRV_UCM_INT_CALL_SRV_TMP_UNAVAILABLE:
{
/* temporarily not available should exclude "always unavailable" */
result = MMI_FALSE;
break;
}
case SRV_UCM_INT_CALLER_RES:
{
result = mmi_voip_get_caller_res_info(ptr);
break;
}
default:
{
ASSERT(0);
break;
}
};
OslMfree(unicodeUri);
return result;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_parse_uri
* DESCRIPTION
* Make sure the uri has sip: and domain name.
* PARAMETERS
* unicodeUri [IN] Uri string in unicode
* RETURNS
* void
*****************************************************************************/
void mmi_voip_parse_uri(U8 *unicodeUri)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *lowercaseUri = OslMalloc((VOIP_URI_LEN + 1)* ENCODING_LENGTH);
S32 sipLen = 0, telLen = 0, count = 0;
S8 foundAt = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
memset(lowercaseUri, 0, ((VOIP_URI_LEN + 1) * ENCODING_LENGTH));
mmi_voip_convert_uri_lower_case(unicodeUri, lowercaseUri, VOIP_URI_LEN * ENCODING_LENGTH);
sipLen = mmi_ucs2strlen((S8*)sipUri); /* number of characters */
telLen = mmi_ucs2strlen((S8*)telUri); /* number of characters */
if ((mmi_ucs2ncmp((S8*)lowercaseUri, (S8*)sipUri, sipLen)) && (mmi_ucs2ncmp((S8*)lowercaseUri, (S8*)telUri, telLen))) /* no prefix sip: and tel: */
{
mmi_voip_append_uri_prefix(unicodeUri);
}
while (unicodeUri[count] != '\0' || unicodeUri[count + 1] != '\0')
{
if (unicodeUri[count] == '@')
{
foundAt = 1;
break;
}
count += 2;
}
if (foundAt == 0)
{
mmi_voip_append_uri_domain(unicodeUri);
}
OslMfree(lowercaseUri);
}
/*****************************************************************************
* FUNCTION
* mmi_voip_convert_uri_star_n_pound
* DESCRIPTION
* Convert uri string %23 as # and %2A as *.
* PARAMETERS
* asciiSrc [IN/OUT] Source uri string in ascii
* RETURNS
* void
*****************************************************************************/
void mmi_voip_convert_uri_star_n_pound(U8 *asciiSrc)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 i = 0, j = 0;
U8 *asciiDest = OslMalloc(VOIP_URI_LEN + 1);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0, j = 0; i < (S32)strlen((S8*)asciiSrc); i++)
{
if ((asciiSrc[i] == '%') && (asciiSrc[i + 1] == '2') && (asciiSrc[i + 2] == '3'))
{
asciiDest[j++] = '#';
i += 2;
}
else if ((asciiSrc[i] == '%') && (asciiSrc[i + 1] == '2') && (asciiSrc[i + 2] == 'A'))
{
asciiDest[j++] = '*';
i += 2;
}
else /* normal case */
{
asciiDest[j++] = asciiSrc[i];
}
}
memset(asciiSrc, 0, VOIP_URI_LEN);
strncpy((S8*)asciiSrc, (S8*)asciiDest, VOIP_URI_LEN);
if(j < VOIP_URI_LEN)
{
asciiSrc[j] = 0;
}
else
{
asciiSrc[VOIP_URI_LEN] = 0;
}
OslMfree(asciiDest);
}
/*****************************************************************************
* FUNCTION
* mmi_voip_convert_uri_lower_case
* DESCRIPTION
* Convert uri string to lower case.
* PARAMETERS
* unicodeSrc [IN] Source uri string in unicode
* unicodeDest [IN/OUT] Destination uri string in unicode
* RETURNS
* void
*****************************************************************************/
void mmi_voip_convert_uri_lower_case(U8 *unicodeSrc, U8 *unicodeDest, U16 len)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 count = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
while ((unicodeSrc[count] != '\0' || unicodeSrc[count + 1] != '\0') && count <= len)
{
if ((unicodeSrc[count] >= 'A') && (unicodeSrc[count] <= 'Z'))
{
unicodeDest[count] = unicodeSrc[count] + ('a' - 'A');
}
else
{
unicodeDest[count] = unicodeSrc[count];
}
count += 2;
}
}
/*****************************************************************************
* FUNCTION
* mmi_voip_append_uri_prefix
* DESCRIPTION
* Append sip: in front of the uri.
* PARAMETERS
* unicodeUri [IN] Uri string in unicode
* RETURNS
* void
*****************************************************************************/
void mmi_voip_append_uri_prefix(U8 *unicodeUri)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 sipLen = 0;
U8 *noprefixUri = OslMalloc(VOIP_URI_LEN * ENCODING_LENGTH);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
memset(noprefixUri, 0, (VOIP_URI_LEN * ENCODING_LENGTH));
mmi_ucs2ncpy((S8*)noprefixUri, (S8*)unicodeUri, VOIP_URI_LEN);
memset(unicodeUri, 0, (VOIP_URI_LEN * ENCODING_LENGTH));
sipLen = mmi_ucs2strlen((S8*)sipUri);
mmi_ucs2ncpy((S8*)unicodeUri, (S8*)sipUri, sipLen);
mmi_ucs2ncpy((S8*)unicodeUri + sipLen * ENCODING_LENGTH, (S8*)noprefixUri, ((VOIP_URI_LEN - 1) - sipLen));
OslMfree(noprefixUri);
}
/*****************************************************************************
* FUNCTION
* mmi_voip_append_uri_domain
* DESCRIPTION
* Append domain name in back of the uri.
* PARAMETERS
* unicodeUri [IN] Uri string in unicode
* RETURNS
* void
*****************************************************************************/
void mmi_voip_append_uri_domain(U8 *unicodeUri)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *unicodeProf = OslMalloc(VOIP_URI_LEN * ENCODING_LENGTH);
S32 profIndex = g_voip_cntx_p->prof_setting_info.actprofIndex;
S8 foundAt = 0;
S32 count = 0, uriLen = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
memset(unicodeProf, 0, (VOIP_URI_LEN * ENCODING_LENGTH));
mmi_asc_n_to_ucs2(
(S8*)unicodeProf,
(S8*)g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].acct_info.username,
VOIP_URI_LEN);
while (unicodeProf[count] != '\0' || unicodeProf[count + 1] != '\0')
{
if (unicodeProf[count] == '@')
{
foundAt = 1;
break;
}
count += 2;
}
if (foundAt == 1)
{
uriLen = mmi_ucs2strlen((S8*)unicodeUri);
if(uriLen + (mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].acct_info.username)<<1)-(count+1) <= VOIP_URI_LEN)
{
mmi_ucs2ncpy(
(S8*)unicodeUri + uriLen * ENCODING_LENGTH,
(S8*)unicodeProf + count,
((VOIP_URI_LEN - 1) - uriLen));
}
}
OslMfree(unicodeProf);
}
/*****************************************************************************
* FUNCTION
* mmi_voip_reset_rtp_proc
* DESCRIPTION
* Reset rtp_proc info.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void mmi_voip_reset_rtp_proc(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_RESET_RTP_PROC);
memset(g_voip_cntx_p->rtp_proc_info.close_rtp_list, -1, MMI_VOIP_MAX_NUM_CALL * VOIP_MAX_NUM_DIALOG);
g_voip_cntx_p->rtp_proc_info.close_rtp_num = 0;
memset(g_voip_cntx_p->rtp_proc_info.remove_mixer_list, -1, MMI_VOIP_MAX_NUM_CALL);
g_voip_cntx_p->rtp_proc_info.remove_mixer_num= 0;
memset(g_voip_cntx_p->rtp_proc_info.rtp_process, 0, MMI_VOIP_MAX_NUM_CALL * VOIP_MAX_NUM_DIALOG);
}
/*****************************************************************************
* FUNCTION
* mmi_voip_reset_call_end_ind_list
* DESCRIPTION
* Reset call_end_ind info.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void mmi_voip_reset_call_end_ind_list(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_RESET_CALL_END_IND_LIST);
memset(g_voip_cntx_p->call_list_info.call_end_ind_list, -1, MMI_VOIP_MAX_NUM_CALL * VOIP_MAX_NUM_DIALOG * sizeof(mmi_voip_ucm_uid_struct));
g_voip_cntx_p->call_list_info.call_end_ind_num = 0;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_add_to_call_list
* DESCRIPTION
* Add specific call to call list.
* PARAMETERS
* fileName [IN] Voip cc call list file, path included
* callId [IN] Call id
* dialogId [IN] Dialog id
* currState [IN] Current state, either MMI_VOIP_OUTGOING_STATE or MMI_VOIP_INCOMING_STATE
* RETURNS
* void
*****************************************************************************/
void mmi_voip_add_to_call_list(U16 *fileName, S32 callId, S32 dialogId, mmi_voip_call_state_enum currState)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
FS_HANDLE fileHandle = 0;
U32 fileLen = 0;
S32 i = 0, result = 0;
voip_call_struct callList;
S32 freeTab = g_voip_cntx_p->call_misc_info.currfreeTab;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_ADD_TO_CALL_LIST, callId, dialogId, currState);
fileHandle = FS_Open(fileName, FS_READ_ONLY);
if (fileHandle < 0)
{
MMI_ASSERT(fileHandle >= 0);
}
for (i = 0; i <= callId; i++)
{
result = FS_Read(fileHandle, &callList, sizeof(voip_call_struct), &fileLen);
if (result != FS_NO_ERROR)
{
MMI_ASSERT(result == FS_NO_ERROR);
}
}
FS_Close(fileHandle);
if (freeTab != -1)
{
g_voip_cntx_p->call_list_info.call_info[freeTab].callId = callId;
g_voip_cntx_p->call_list_info.call_info[freeTab].currState = currState;
if (g_voip_cntx_p->call_list_info.call_info[freeTab].currState == MMI_VOIP_OUTGOING_STATE)
{
g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].callOrigin = MMI_VOIP_MO_ORIGIN;
}
else if (g_voip_cntx_p->call_list_info.call_info[freeTab].currState == MMI_VOIP_INCOMING_STATE)
{
g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].callOrigin = MMI_VOIP_MT_ORIGIN;
}
g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].dialogId = dialogId;
g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].dialogIdx = callList.dialog[0].dialog_idx;
memset(
g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].appName,
0,
(VOIP_DISP_NAME_LEN * sizeof(U16)));
if (g_voip_cntx_p->call_list_info.call_info[freeTab].currState == MMI_VOIP_OUTGOING_STATE)
{
mmi_voip_get_outgoing_disp_name(
MMI_VOIP_PHB|MMI_VOIP_HISTORY|MMI_VOIP_SOS,
g_voip_cntx_p->call_misc_info.dispUri, /* for display emergency number string */
(U8*)g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].appName,
VOIP_DISP_NAME_LEN);
}
memset(
g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].dispName,
0,
(VOIP_DISP_NAME_LEN * sizeof(U16)));
mmi_chset_convert(
MMI_CHSET_UTF8,
MMI_CHSET_UCS2,
(char*)callList.dialog[dialogId].user_addr.disp_name,
(char*)g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].dispName,
(S32)(VOIP_DISP_NAME_LEN * sizeof(U16)));
memset(g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].remoteUri, 0, VOIP_URI_LEN);
memcpy(
g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].remoteUri,
callList.dialog[dialogId].user_addr.uri,
VOIP_URI_LEN);
mmi_voip_convert_uri_star_n_pound(g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].remoteUri);
/* copy sdp info */
g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].rtpHandle = -1; /* rtp is not created yet */
g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].isMixer = FALSE;
memcpy(
&g_voip_cntx_p->call_list_info.call_info[freeTab].dialog_info[0].sdp_info,
&callList.dialog[dialogId].sdp_info,
sizeof(voip_sdp_struct));
g_voip_cntx_p->call_list_info.call_info[freeTab].numDialog++;
g_voip_cntx_p->call_list_info.numTotal++;
g_voip_cntx_p->call_misc_info.currfreeTab++;
if (g_voip_cntx_p->call_misc_info.currfreeTab == MMI_VOIP_MAX_NUM_CALL)
{
g_voip_cntx_p->call_misc_info.currfreeTab = -1; /* call capacity full */
}
}
else
{
MMI_ASSERT(0); /* no available call entry */
}
}
/*****************************************************************************
* FUNCTION
* mmi_voip_del_from_call_list
* DESCRIPTION
* Delete specific call from call list.
* PARAMETERS
* callId [IN] Call id
* dialogId [IN] Dialog id
* RETURNS
* void
*****************************************************************************/
void mmi_voip_del_from_call_list(S32 callId, S32 dialogId)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 callIndex = 0, dialogIndex = 0, i = 0, j = 0;
mmi_voip_rtp_proc_struct *rtp_proc = &(g_voip_cntx_p->rtp_proc_info);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_DEL_FROM_CALL_LIST, callId, dialogId);
callIndex = mmi_voip_get_call_index(callId);
if (callIndex != -1)
{
dialogIndex = mmi_voip_get_dialog_index(callIndex, dialogId);
if (dialogIndex == 0)
{
g_voip_cntx_p->call_list_info.call_info[callIndex].numDialog--;
if (g_voip_cntx_p->call_list_info.call_info[callIndex].numDialog == 0)
{
/* reset call info */
g_voip_cntx_p->call_list_info.numTotal--;
rtp_proc->remove_mixer_list[rtp_proc->remove_mixer_num++] = callIndex;
if (g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[dialogIndex].rtpHandle != -1)
{
rtp_proc->close_rtp_list[rtp_proc->close_rtp_num++] = g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[dialogIndex].rtpHandle;
}
memset(&g_voip_cntx_p->call_list_info.call_info[callIndex], 0, sizeof(mmi_voip_call_struct));
g_voip_cntx_p->call_list_info.call_info[callIndex].callId = -1;
for (i = 0; i < VOIP_MAX_NUM_DIALOG; i++)
{
g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[i].dialogId = -1;
g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[i].rtpHandle = -1;
}
/* if currfreeTab is 0 already, it means the call was not connected but is disconnected now.
therefore, no need to decrease currfreeTab */
if (g_voip_cntx_p->call_misc_info.currfreeTab > 0)
{
g_voip_cntx_p->call_misc_info.currfreeTab--;
}
/* when reaching call capacity, currfreeTab is set to -1 already.
therefore, currfreeTab has to set to 3 when call entry is available */
else if (g_voip_cntx_p->call_misc_info.currfreeTab == -1)
{
g_voip_cntx_p->call_misc_info.currfreeTab = MMI_VOIP_MAX_NUM_CALL - 1;
}
}
else /* g_voip_cntx_p->call_list_info.call_info[callIndex].numDialog == 1 */
{
/* move dialog 1 to dialog 0 */
rtp_proc->remove_mixer_list[rtp_proc->remove_mixer_num++] = callIndex;
if (g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[dialogIndex].rtpHandle != -1)
{
rtp_proc->close_rtp_list[rtp_proc->close_rtp_num++] = g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[dialogIndex].rtpHandle;
}
memcpy(
&g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[0],
&g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[1],
sizeof(mmi_voip_dialog_struct));
memset(
&g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[1],
0,
sizeof(mmi_voip_dialog_struct));
g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[1].dialogId = -1;
g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[1].rtpHandle = -1;
}
}
else if (dialogIndex == 1)
{
g_voip_cntx_p->call_list_info.call_info[callIndex].numDialog--;
if (g_voip_cntx_p->call_list_info.call_info[callIndex].numDialog == 0)
{
/* reset call info */
g_voip_cntx_p->call_list_info.numTotal--;
rtp_proc->remove_mixer_list[rtp_proc->remove_mixer_num++] = callIndex;
if (g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[dialogIndex].rtpHandle != -1)
{
rtp_proc->close_rtp_list[rtp_proc->close_rtp_num++] = g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[dialogIndex].rtpHandle;
}
memset(&g_voip_cntx_p->call_list_info.call_info[callIndex], 0, sizeof(mmi_voip_call_struct));
g_voip_cntx_p->call_list_info.call_info[callIndex].callId = -1;
for (i = 0; i < VOIP_MAX_NUM_DIALOG; i++)
{
g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[i].dialogId = -1;
g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[i].rtpHandle = -1;
}
/* if currfreeTab is 0 already, it means the call was not connected but is disconnected now.
therefore, no need to decrease currfreeTab */
if (g_voip_cntx_p->call_misc_info.currfreeTab > 0)
{
g_voip_cntx_p->call_misc_info.currfreeTab--;
}
/* when reaching call capacity, currfreeTab is set to -1 already.
therefore, currfreeTab has to set to 3 when call entry is available */
else if (g_voip_cntx_p->call_misc_info.currfreeTab == -1)
{
g_voip_cntx_p->call_misc_info.currfreeTab = MMI_VOIP_MAX_NUM_CALL - 1;
}
}
else /* numDialog == 1 */
{
/* reset dialog info */
rtp_proc->remove_mixer_list[rtp_proc->remove_mixer_num++] = callIndex;
if (g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[dialogIndex].rtpHandle != -1)
{
rtp_proc->close_rtp_list[rtp_proc->close_rtp_num++] = g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[dialogIndex].rtpHandle;
}
memset(
&g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[dialogIndex],
0,
sizeof(mmi_voip_dialog_struct));
g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[dialogIndex].dialogId = -1;
g_voip_cntx_p->call_list_info.call_info[callIndex].dialog_info[dialogIndex].rtpHandle = -1;
}
}
/* rearrange call list */
if (g_voip_cntx_p->call_list_info.call_info[callIndex].numDialog == 0)
{
for (i = callIndex; i < (MMI_VOIP_MAX_NUM_CALL - 1); i++)
{
memcpy(
&g_voip_cntx_p->call_list_info.call_info[i],
&g_voip_cntx_p->call_list_info.call_info[i + 1],
sizeof(mmi_voip_call_struct));
memset(&g_voip_cntx_p->call_list_info.call_info[i + 1], 0, sizeof(mmi_voip_call_struct));
g_voip_cntx_p->call_list_info.call_info[i + 1].callId = -1;
for (j = 0; j < VOIP_MAX_NUM_DIALOG; j++)
{
g_voip_cntx_p->call_list_info.call_info[i + 1].dialog_info[j].dialogId = -1;
g_voip_cntx_p->call_list_info.call_info[i + 1].dialog_info[j].rtpHandle = -1;
}
}
}
}
}
/*****************************************************************************
* FUNCTION
* mmi_voip_update_rtp
* DESCRIPTION
* Update rtp handles and speech on/off according to rtp_proc info.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_voip_update_rtp(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 i = 0, j = 0;
mmi_voip_rtp_proc_struct *rtp_proc_info = &(g_voip_cntx_p->rtp_proc_info);
mmi_voip_call_list_struct *call_list_info = &(g_voip_cntx_p->call_list_info);
S32 total_call_num = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_UPDATE_RTP);
/* SPEECH ON */
total_call_num = g_voip_cntx_p->call_list_info.numTotal - g_voip_cntx_p->call_list_info.numHeld;
if(mmi_voip_get_incoming_call_id() != -1)
{
total_call_num --;
}
if(mmi_voip_get_outgoing_call_id() != -1)
{
total_call_num --;
}
if((total_call_num > 0) || (mdi_audio_speech_get_app_id() == MDI_AUDIO_SPEECH_APP_ID_NONE))
{
mmi_voip_ucm_session_ind(MDI_AUDIO_SPEECH_APP_ID_VOIP, MMI_TRUE);
g_voip_cntx_p->call_list_info.inSession = MMI_TRUE;
}
total_call_num = 0;
/* handle rtp */
/* 1. close rtp */
mmi_voip_ucm_speech_ind(0, MMI_FALSE, MMI_FALSE);
for(i = 0; i<rtp_proc_info->remove_mixer_num; i++)
{
if(rtp_proc_info->remove_mixer_list[i] != -1)
{
mmi_voip_remove_mixer_before_close(rtp_proc_info->remove_mixer_list[i]);
}
}
for(i = 0; i < rtp_proc_info->close_rtp_num; i++)
{
if(rtp_proc_info->close_rtp_list[i] != -1)
{
mmi_voip_control_rtp(rtp_proc_info->close_rtp_list[i], VOIP_RTP_DIRECTION_INACTIVE);
mmi_voip_close_rtp(rtp_proc_info->close_rtp_list[i]);
}
}
/* 2. create rtp & update */
for(i = 0; i < MMI_VOIP_MAX_NUM_CALL; i++)
{
for(j = 0; j < VOIP_MAX_NUM_DIALOG; j++)
{
if(rtp_proc_info->rtp_process[i][j] & MMI_VOIP_RTP_PROC_CREATE)
{
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_UPDATE_RTP_CREATE_RTP, i, j, rtp_proc_info->rtp_process[i][j]);
call_list_info->call_info[i].dialog_info[j].rtpHandle = mmi_voip_create_rtp(&(call_list_info->call_info[i].dialog_info[j].sdp_info));
}
if(rtp_proc_info->rtp_process[i][j] & MMI_VOIP_RTP_PROC_UPDATE)
{
mmi_voip_switch_rtp(MMI_FALSE, call_list_info->call_info[i].callId, call_list_info->call_info[i].dialog_info[j].dialogId);
}
}
}
for(i = 0; i < MMI_VOIP_MAX_NUM_CALL; i ++)
{
for(j = 0; j < VOIP_MAX_NUM_DIALOG; j ++)
{
if(g_voip_cntx_p->call_list_info.call_info[i].dialog_info[j].dialogId != -1 &&
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[j].rtpHandle != -1 &&
(g_voip_cntx_p->call_list_info.call_info[i].dialog_info[j].sdp_info.direction == VOIP_RTP_DIRECTION_SENDRECV||
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[j].sdp_info.direction == VOIP_RTP_DIRECTION_RECVONLY))
{
total_call_num ++;
}
}
}
if(total_call_num)
{
mmi_voip_ucm_speech_ind(0, MMI_TRUE, MMI_TRUE);
}
else
{
mmi_voip_ucm_speech_ind(0, MMI_FALSE, MMI_FALSE);
//mmi_voip_ucm_session_ind(MDI_AUDIO_SPEECH_APP_ID_VOIP, MMI_FALSE);
//g_voip_cntx_p->call_list_info.inSession = MMI_FALSE;
}
mmi_voip_reset_rtp_proc();
}
static void mmi_voip_add_send_call_end_ind(S32 callId, S16 dialogIdx)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_ADD_SEND_CALL_END_IND, callId, dialogIdx);
g_voip_cntx_p->call_list_info.call_end_ind_list[g_voip_cntx_p->call_list_info.call_end_ind_num].callId = callId;
g_voip_cntx_p->call_list_info.call_end_ind_list[g_voip_cntx_p->call_list_info.call_end_ind_num++].dialogIdx = dialogIdx;
}
static void mmi_voip_send_call_end_ind(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 i = 0;
mmi_voip_ucm_uid_struct *uid = NULL;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_SEND_CALL_END_IND, g_voip_cntx_p->call_list_info.call_end_ind_num);
while(g_voip_cntx_p->call_list_info.call_end_ind_num > 0)
{
uid = &(g_voip_cntx_p->call_list_info.call_end_ind_list[i++]);
mmi_voip_ucm_release_ind(uid->callId, uid->dialogIdx, (U8*)GetString(STR_ID_VOIP_CALL_END), IMG_ID_VOIP_CALL_ENDED, SUCCESS_TONE_IN_CALL);
g_voip_cntx_p->call_list_info.call_end_ind_num --;
}
mmi_voip_reset_call_end_ind_list();
}
/*****************************************************************************
* FUNCTION
* mmi_voip_update_call_list
* DESCRIPTION
* Update mmi call list.
* PARAMETERS
* fileName [IN] Voip cc call list file, path included
* isConf [IN] Display popup or not
* RETURNS
* void
*****************************************************************************/
void mmi_voip_update_call_list(U16 *fileName, MMI_BOOL isConf)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_UPDATE_CALL_LIST, isConf);
g_voip_cntx_p->call_list_info.numHeld = 0; /* re-calculate number of held call */
mmi_voip_update_to_del_call_list(fileName, isConf);
mmi_voip_update_to_add_call_list(fileName, isConf);
mmi_voip_send_call_end_ind();
if((g_voip_cntx_p->call_list_info.processCId == -1) && (g_voip_cntx_p->call_list_info.processDId == -1))
{
mmi_voip_update_rtp();
}
mmi_voip_switch_session(MMI_VOIP_IDLE_STATE);
FS_Delete(fileName);
}
/*****************************************************************************
* FUNCTION
* mmi_voip_update_to_del_call_list
* DESCRIPTION
* First pass of updating call list from voip cc to mmi.
* Delete mmi call list entry that voip cc call list does not have.
* PARAMETERS
* fileName [IN] Voip cc call list file, path included
* isConf [IN] Display popup or not
* RETURNS
* void
*****************************************************************************/
void mmi_voip_update_to_del_call_list(U16 *fileName, MMI_BOOL isConf)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
FS_HANDLE fileHandle = 0;
U32 fileLen = 0;
S32 result = 0;
voip_call_struct callList;
S32 i = 0, j = 0, m = 0, n = 0, callId = 0, dialogId = 0;
MYTIME currTime, duration;
U8 popupStr[MAX_SUB_MENU_SIZE];
MMI_BOOL send_release_ind = MMI_FALSE;
mmi_voip_rtp_proc_struct *rtp_proc = &(g_voip_cntx_p->rtp_proc_info);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_UPDATE_TO_DEL_CALL_LIST, isConf);
while (i < MMI_VOIP_MAX_NUM_CALL)
{
callId = g_voip_cntx_p->call_list_info.call_info[i].callId;
if (callId != -1)
{
fileHandle = FS_Open(fileName, FS_READ_ONLY);
if (fileHandle < 0)
{
MMI_ASSERT(fileHandle >= 0);
}
for (j = 0; j < g_voip_cntx_p->call_list_info.maxnumCall; j++)
{
result = FS_Read(fileHandle, &callList, sizeof(voip_call_struct), &fileLen);
if (result != FS_NO_ERROR)
{
MMI_ASSERT(result == FS_NO_ERROR);
}
if(callList.call_id == callId && callList.is_bk_call == TRUE)
{
send_release_ind = MMI_TRUE;
}
if ((callList.is_bk_call == FALSE) && (callList.call_state != VOIP_CALL_STATE_TERMINATED) &&
(callList.call_id == callId))
{
while (m < VOIP_MAX_NUM_DIALOG)
{
dialogId = g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].dialogId;
if (dialogId != -1)
{
for (n = 0; n < VOIP_MAX_NUM_DIALOG; n++)
{
if ((callList.dialog[n].in_use == TRUE) && (callList.dialog[n].dialog_id == dialogId))
{
/* update call info */
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].dialogIdx = callList.dialog[n].dialog_idx;
g_voip_cntx_p->call_list_info.call_info[i].currState = mmi_voip_get_call_state_enum(callList.dialog[n].dialog_state);
if(g_voip_cntx_p->call_list_info.call_info[i].currState == MMI_VOIP_ACTIVE_STATE )
{
g_voip_cntx_p->call_misc_info.currhiliteTab = i;
}
if ((g_voip_cntx_p->call_list_info.call_info[i].currState == MMI_VOIP_HOLD_STATE) && (m == 0)) /* only update held call count according to the first dialog */
{
g_voip_cntx_p->call_list_info.numHeld++;
}
else if (g_voip_cntx_p->call_list_info.call_info[i].currState ==
MMI_VOIP_OUTGOING_STATE)
{
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].callOrigin =
MMI_VOIP_MO_ORIGIN;
}
else if (g_voip_cntx_p->call_list_info.call_info[i].currState ==
MMI_VOIP_INCOMING_STATE)
{
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].callOrigin =
MMI_VOIP_MT_ORIGIN;
}
/* outgoing call or incoming call doesn't have the info of sdp yet */
if ((g_voip_cntx_p->call_list_info.call_info[i].currState == MMI_VOIP_ACTIVE_STATE) ||
(g_voip_cntx_p->call_list_info.call_info[i].currState == MMI_VOIP_HOLD_STATE) ||
(g_voip_cntx_p->call_list_info.call_info[i].currState == MMI_VOIP_HOLDING_STATE))
{
if (g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].rtpHandle == -1)
{
rtp_proc->rtp_process[i][m] |= MMI_VOIP_RTP_PROC_CREATE;
}
else if (mmi_voip_is_addr_change
(&g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].sdp_info,
&callList.dialog[n].sdp_info))
{
rtp_proc->remove_mixer_list[rtp_proc->remove_mixer_num++] = i;
rtp_proc->close_rtp_list[rtp_proc->close_rtp_num++] = g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].rtpHandle;
rtp_proc->rtp_process[i][m] |= MMI_VOIP_RTP_PROC_CREATE;
}
memcpy(
&g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].sdp_info,
&callList.dialog[n].sdp_info,
sizeof(voip_sdp_struct));
//mmi_voip_switch_rtp(FALSE, callId, dialogId);
rtp_proc->rtp_process[i][m] |= MMI_VOIP_RTP_PROC_UPDATE;
if (!mmi_dt_is_valid(&g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].startTime))
{
DTGetRTCTime(&currTime);
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].startTime = currTime;
}
}
memset(
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].dispName,
0,
(VOIP_DISP_NAME_LEN * sizeof(U16)));
mmi_chset_convert(
MMI_CHSET_UTF8,
MMI_CHSET_UCS2,
(char*)callList.dialog[n].user_addr.disp_name,
(char*)g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].dispName,
(S32)(VOIP_DISP_NAME_LEN * sizeof(U16)));
/* it could be a transfer case if uri changes, need to update appName */
if (strncmp(
(S8*)g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].remoteUri,
(S8*)callList.dialog[n].user_addr.uri,
VOIP_URI_LEN))
{
memset(
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].appName,
0,
(VOIP_DISP_NAME_LEN * sizeof(U16)));
}
memset(
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].remoteUri,
0,
VOIP_URI_LEN);
memcpy(
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].remoteUri,
callList.dialog[n].user_addr.uri,
VOIP_URI_LEN);
mmi_voip_convert_uri_star_n_pound(g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].remoteUri);
break;
}
}
m++;
if (n == VOIP_MAX_NUM_DIALOG) /* delete dialog entry */
{
if (mmi_dt_is_valid(&g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m - 1].startTime))
{
memset(&duration, 0, sizeof(MYTIME));
mmi_voip_log_call_end_time(callId, dialogId, &duration);
}
if (isConf == TRUE)
{
/* store actual call origin and actual start time for merge call or split call */
g_voip_cntx_p->call_misc_info.actualOrigin =
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m - 1].callOrigin;
g_voip_cntx_p->call_misc_info.actualTime =
g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m - 1].startTime;
}
else /* isConf == FALSE */
{
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_VOIP_TRC_GRP, "\n[mmi_voip_update_to_del_call_list] It is possible\n");
}
mmi_voip_del_from_call_list(callId, dialogId);
m--;
}
}
else /* dialogId == -1, break the loop because mmi call list is sorted */
{
break;
}
}
m = 0; /* reset m to check next call id's dialog */
break;
}
}
i++;
if (j == g_voip_cntx_p->call_list_info.maxnumCall) /* delete call entry */
{
S32 dialogIdx = g_voip_cntx_p->call_list_info.call_info[i - 1].dialog_info[m].dialogIdx;
/* dialogId is invalid at the moment, so get the first dialog id to show call end popup */
dialogId = g_voip_cntx_p->call_list_info.call_info[i - 1].dialog_info[m].dialogId;
if (mmi_dt_is_valid(&g_voip_cntx_p->call_list_info.call_info[i - 1].dialog_info[m].startTime))
{
memset(&duration, 0, sizeof(MYTIME));
mmi_voip_log_call_end_time(callId, dialogId, &duration);
//memset(popupStr, 0, MAX_SUB_MENU_SIZE);
//mmi_voip_get_call_end_string(&duration, popupStr);
}
else /* outgoing call or incoming call */
{
memset(popupStr, 0, MAX_SUB_MENU_SIZE);
mmi_ucs2cpy((S8*)popupStr, GetString(STR_ID_VOIP_CALL_END));
MMI_ASSERT(popupStr[MAX_SUB_MENU_SIZE - 2] == '\0' && popupStr[MAX_SUB_MENU_SIZE - 1] == '\0');
}
if (isConf == TRUE)
{
/* store actual call origin and actual start time for merge call or split call */
g_voip_cntx_p->call_misc_info.actualOrigin =
g_voip_cntx_p->call_list_info.call_info[i - 1].dialog_info[m].callOrigin;
g_voip_cntx_p->call_misc_info.actualTime =
g_voip_cntx_p->call_list_info.call_info[i - 1].dialog_info[m].startTime;
}
else /* isConf == FALSE */
{
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_VOIP_TRC_GRP, "\n[mmi_voip_update_to_del_call_list] It is possible\n");
}
mmi_voip_del_from_call_list(callId, dialogId);
if(send_release_ind)
{
mmi_voip_add_send_call_end_ind(callId, dialogIdx);
}
i--;
}
FS_Close(fileHandle);
}
else /* callId == -1, break the loop because mmi call list is sorted */
{
break;
}
}
i = 0; /* reset i */
}
/*****************************************************************************
* FUNCTION
* mmi_voip_add_dialog
* DESCRIPTION
* Add voip dialog
* PARAMETERS
* callList [IN] call list
* dialogId [IN] Id of the dialog to be added
* call_info [IN] call info
* isConf [IN] is in conference
* RETURNS
* void
*****************************************************************************/
MMI_BOOL mmi_voip_add_dialog(voip_call_struct *callList, S32 callId, S32 dialogId, MMI_BOOL isConf)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
MYTIME currTime;
S32 m = 0;
mmi_voip_rtp_proc_struct *rtp_proc = &(g_voip_cntx_p->rtp_proc_info);
mmi_voip_call_struct *call_info = &(g_voip_cntx_p->call_list_info.call_info[callId]);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_ADD_DIALOG, callId, dialogId, isConf);
for (m = 0; m < VOIP_MAX_NUM_DIALOG; m++)
{
if (call_info->dialog_info[m].dialogId == -1)
{
call_info->numDialog++;
call_info->dialog_info[m].dialogId =
callList->dialog[dialogId].dialog_id;
call_info->dialog_info[m].dialogIdx =
callList->dialog[dialogId].dialog_idx;
if(call_info->currState == MMI_VOIP_ACTIVE_STATE )
{
g_voip_cntx_p->call_misc_info.currhiliteTab = m;
}
if ((call_info->currState == MMI_VOIP_ACTIVE_STATE) ||
(call_info->currState == MMI_VOIP_HOLD_STATE))
{
if (call_info->dialog_info[m].rtpHandle == -1)
{
rtp_proc->rtp_process[callId][m] |= MMI_VOIP_RTP_PROC_CREATE;
}
memcpy(
&call_info->dialog_info[m].sdp_info,
&callList->dialog[dialogId].sdp_info,
sizeof(voip_sdp_struct));
rtp_proc->rtp_process[callId][m] |= MMI_VOIP_RTP_PROC_UPDATE;
if (!mmi_dt_is_valid(&call_info->dialog_info[m].startTime))
{
DTGetRTCTime(&currTime);
call_info->dialog_info[m].startTime = currTime;
}
}
memset(
call_info->dialog_info[m].dispName,
0,
(VOIP_DISP_NAME_LEN * sizeof(U16)));
mmi_chset_convert(
MMI_CHSET_UTF8,
MMI_CHSET_UCS2,
(char*)callList->dialog[dialogId].user_addr.disp_name,
(char*)call_info->dialog_info[m].dispName,
(S32)(VOIP_DISP_NAME_LEN * sizeof(U16)));
/* it could be a transfer case if uri changes, need to update appName */
if (strncmp(
(S8*)call_info->dialog_info[m].remoteUri,
(S8*)callList->dialog[dialogId].user_addr.uri,
VOIP_URI_LEN))
{
memset(
call_info->dialog_info[m].appName,
0,
(VOIP_DISP_NAME_LEN * sizeof(U16)));
}
memset(
call_info->dialog_info[m].remoteUri,
0,
VOIP_URI_LEN);
memcpy(
call_info->dialog_info[m].remoteUri,
callList->dialog[dialogId].user_addr.uri,
VOIP_URI_LEN);
mmi_voip_convert_uri_star_n_pound(call_info->dialog_info[m].remoteUri);
if (isConf == TRUE)
{
/* update mixer's information for the other dialog */
rtp_proc->rtp_process[callId][m] |= MMI_VOIP_RTP_PROC_UPDATE;
call_info->dialog_info[m].callOrigin =
g_voip_cntx_p->call_misc_info.actualOrigin;
g_voip_cntx_p->call_misc_info.actualOrigin = MMI_VOIP_NONE_ORIGIN;
call_info->dialog_info[m].startTime =
g_voip_cntx_p->call_misc_info.actualTime;
memset(&g_voip_cntx_p->call_misc_info.actualTime, 0, sizeof(MYTIME));
}
//break;
return MMI_TRUE;
}
}
return MMI_FALSE;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_update_to_add_call_list
* DESCRIPTION
* Second pass of updating call list from voip cc to mmi.
* Add mmi call list entry that mmi call list does not have.
* PARAMETERS
* fileName [IN] Voip cc call list file, path included
* isConf [IN] Display popup or not
* RETURNS
* void
*****************************************************************************/
void mmi_voip_update_to_add_call_list(U16 *fileName, MMI_BOOL isConf)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
FS_HANDLE fileHandle = 0;
U32 fileLen = 0;
S32 result = 0;
voip_call_struct callList;
S32 i = 0, j = 0, m = 0, n = 0, callId = 0, dialogId = 0, freeTab = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_VOIP_TRC_GRP, TRC_MMI_VOIP_UPDATE_TO_ADD_CALL_LIST, isConf);
fileHandle = FS_Open(fileName, FS_READ_ONLY);
if (fileHandle < 0)
{
MMI_ASSERT(fileHandle >= 0);
}
for (j = 0; j < g_voip_cntx_p->call_list_info.maxnumCall; j++)
{
result = FS_Read(fileHandle, &callList, sizeof(voip_call_struct), &fileLen);
if (result != FS_NO_ERROR)
{
MMI_ASSERT(result == FS_NO_ERROR);
}
if ((callList.is_bk_call == FALSE) &&
(callList.call_state != VOIP_CALL_STATE_TERMINATED) &&
(callList.call_id != g_voip_cntx_p->call_list_info.bkrejCId) ) /* for race condition */
{
for (i = 0; i < MMI_VOIP_MAX_NUM_CALL; i++)
{
callId = g_voip_cntx_p->call_list_info.call_info[i].callId;
if (callList.call_id == callId)
{
for (n = 0; n < VOIP_MAX_NUM_DIALOG; n++)
{
if (callList.dialog[n].in_use == TRUE)
{
for (m = 0; m < VOIP_MAX_NUM_DIALOG; m++)
{
dialogId = g_voip_cntx_p->call_list_info.call_info[i].dialog_info[m].dialogId;
if (callList.dialog[n].dialog_id == dialogId)
{
break;
}
}
if (m == VOIP_MAX_NUM_DIALOG) /* add dialog entry */
{
if(mmi_voip_add_dialog(
&callList,
i,
n,
isConf) == MMI_TRUE)
{
break;
}
else
{
MMI_ASSERT(0); /* no available dialog entry */
}
}
}
}
break;
}
}
if (i == MMI_VOIP_MAX_NUM_CALL) /* add call entry */
{
freeTab = g_voip_cntx_p->call_misc_info.currfreeTab;
if (freeTab != -1)
{
for (n = 0; n < VOIP_MAX_NUM_DIALOG; n++)
{
if (callList.dialog[n].in_use == TRUE)
{
g_voip_cntx_p->call_list_info.call_info[freeTab].callId = callList.call_id;
g_voip_cntx_p->call_list_info.call_info[freeTab].currState = mmi_voip_get_call_state_enum(callList.dialog[n].dialog_state);
if ((g_voip_cntx_p->call_list_info.call_info[freeTab].currState == MMI_VOIP_HOLD_STATE) && (m == 0)) /* only update held call count according to the first dialog */
{
g_voip_cntx_p->call_list_info.numHeld++;
}
g_voip_cntx_p->call_list_info.numTotal++;
if(!mmi_voip_add_dialog(
&callList,
freeTab,
n,
isConf) == MMI_TRUE)
{
MMI_ASSERT(0); /* no available dialog entry */
}
g_voip_cntx_p->call_misc_info.currfreeTab++;
if (g_voip_cntx_p->call_misc_info.currfreeTab == MMI_VOIP_MAX_NUM_CALL)
{
g_voip_cntx_p->call_misc_info.currfreeTab = -1; /* call capacity full */
}
}
}
}
else
{
/* do not assert in case four calls + one will-be-bk-reject call */
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_VOIP_TRC_GRP, "\n[mmi_voip_update_to_add_call_list] No Available Call Entry, Ignore and Wait to Background Reject\n");
}
}
}
}
FS_Close(fileHandle);
}
S16 mmi_voip_get_actual_dialog_id(S16 ucm_call_info_id)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 i = 0, j = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0; i < MMI_VOIP_MAX_NUM_CALL; i ++)
{
for (j = 0; j < VOIP_MAX_NUM_DIALOG; j ++)
{
if(g_voip_cntx_p->call_list_info.call_info[i].dialog_info[j].dialogIdx == ucm_call_info_id)
{
return g_voip_cntx_p->call_list_info.call_info[i].dialog_info[j].dialogId;
}
}
}
return -1;
}
S16 mmi_voip_get_dialog_idx(S32 call_id, S32 dialog_id)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 i = 0, j = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0; i < MMI_VOIP_MAX_NUM_CALL; i ++)
{
if(g_voip_cntx_p->call_list_info.call_info[i].callId == call_id)
{
for (j = 0; j < VOIP_MAX_NUM_DIALOG; j ++)
{
if(g_voip_cntx_p->call_list_info.call_info[i].dialog_info[j].dialogId == dialog_id)
{
return g_voip_cntx_p->call_list_info.call_info[i].dialog_info[j].dialogIdx;
}
}
}
}
return -1;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_summary_string
* DESCRIPTION
* Prepare current status display string.
* PARAMETERS
* unicodeStr [IN/OUT] Current status string in unicode
* RETURNS
* void
*****************************************************************************/
void mmi_voip_get_summary_string(U8 *unicodeStr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 profIndex = 0;
U8 newline[4] = { '\n', '\0', '\0', '\0' }; /* \n */
S8 *colon = (S8*)GetString(STR_ID_VOIP_FULL_SHAPE_COLON);
S8 *slash = (S8*)GetString(STR_ID_VOIP_FULL_SHAPE_SLASH);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* Login/Logout: */
mmi_ucs2cpy((S8*)unicodeStr, GetString(STR_GLOBAL_LOGIN));
mmi_ucs2cat((S8*)unicodeStr, (S8*)slash);
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_GLOBAL_LOGOUT));
mmi_ucs2cat((S8*)unicodeStr, (S8*)colon);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
profIndex = g_voip_cntx_p->prof_setting_info.actprofIndex;
if (profIndex != -1)
{
if (g_voip_cntx_p->reg_state_info == MMI_VOIP_REG_STATE)
{
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_REGISTER));
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
}
else
{
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_NOT_REGISTER));
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
}
mmi_voip_update_prof_common_cache_to_disp(profIndex);
/* Profile Name: */
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_PROF_COMMON_PROFNAME));
mmi_ucs2cat((S8*)unicodeStr, (S8*)colon);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
mmi_ucs2cat((S8*)unicodeStr, (S8*)g_voip_cntx_p->prof_setting_info.disp_prof.profileName);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
mmi_voip_update_prof_acct_cache_to_disp(profIndex);
/* SIP Server/SIP Port: */
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_PROF_ACCOUNT_SIPSERVER));
mmi_ucs2cat((S8*)unicodeStr, (S8*)slash);
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_PROF_ACCOUNT_SIPPORT));
mmi_ucs2cat((S8*)unicodeStr, (S8*)colon);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
mmi_ucs2cat((S8*)unicodeStr, (S8*)g_voip_cntx_p->prof_setting_info.disp_prof.serverName);
mmi_ucs2cat((S8*)unicodeStr, (S8*)colon);
mmi_ucs2cat((S8*)unicodeStr, (S8*)g_voip_cntx_p->prof_setting_info.disp_prof.portNumber);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
/* Username: */
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_GLOBAL_USERNAME));
mmi_ucs2cat((S8*)unicodeStr, (S8*)colon);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
mmi_ucs2cat((S8*)unicodeStr, (S8*)g_voip_cntx_p->prof_setting_info.disp_prof.username);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
/* Display Name: */
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_PROF_ACCOUNT_DISPNAME));
mmi_ucs2cat((S8*)unicodeStr, (S8*)colon);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
mmi_ucs2cat((S8*)unicodeStr, (S8*)g_voip_cntx_p->prof_setting_info.disp_prof.displayName);
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
}
else
{
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_NO_ACTIVATED_PROFILE));
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
}
MMI_ASSERT(unicodeStr[MAX_SUB_MENUS * MAX_SUB_MENU_SIZE - 1] == '\0');
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_call_state_enum
* DESCRIPTION
* Map voip cc dialog state to mmi call state.
* PARAMETERS
* state [IN] Voip cc dialog state
* RETURNS
* MMI call state.
*****************************************************************************/
mmi_voip_call_state_enum mmi_voip_get_call_state_enum(voip_dlg_state_enum state)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (state)
{
case VOIP_DLG_STATE_TERMINATED:
return MMI_VOIP_IDLE_STATE;
case VOIP_DLG_STATE_WAIT_NAT:
case VOIP_DLG_STATE_MO:
return MMI_VOIP_OUTGOING_STATE;
case VOIP_DLG_STATE_MT:
return MMI_VOIP_INCOMING_STATE;
case VOIP_DLG_STATE_WAIT_ACK: /* accept call complete before remote ack */
case VOIP_DLG_STATE_ACTIVE:
return MMI_VOIP_ACTIVE_STATE;
case VOIP_DLG_STATE_HOLD:
return MMI_VOIP_HOLD_STATE;
case VOIP_DLG_STATE_TRANSFERING:
case VOIP_DLG_STATE_TRANSFEREE:
return MMI_VOIP_TRANSFER_STATE;
case VOIP_DLG_STATE_TERMINATING:
return MMI_VOIP_DISCONNECTING_STATE;
case VOIP_DLG_STATE_HOLDING:
return MMI_VOIP_HOLDING_STATE;
case VOIP_DLG_STATE_UNHOLDING:
return MMI_VOIP_HOLD_STATE;
default:
MMI_EXT_ASSERT(0, state, 0, 0);
return MMI_VOIP_CALL_STATE_TOTAL;
}
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_call_end_string
* DESCRIPTION
* Append string "Call End" in front of call duration.
* PARAMETERS
* duration [IN] Duration of the call
* unicodeStr [IN/OUT] Call end string
* RETURNS
* void
*****************************************************************************/
void mmi_voip_get_call_end_string(MYTIME *duration, U8 *unicodeStr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 newline[4] = { '\n', '\0', '\0', '\0' }; /* \n */
U8 *timeStr = OslMalloc(32);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
mmi_ucs2cpy((S8*) unicodeStr, GetString(STR_ID_VOIP_CALL_END));
mmi_ucs2cat((S8*) unicodeStr, (S8*) newline);
duration_string(duration, (UI_string_type) timeStr, DT_ACTIVE_CALL_SCREEN);
mmi_ucs2cat((S8*) unicodeStr, (S8*) timeStr);
OslMfree(timeStr);
MMI_ASSERT(unicodeStr[MAX_SUB_MENU_SIZE - 2] == '\0' && unicodeStr[MAX_SUB_MENU_SIZE - 1] == '\0');
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_dtmf_keycode_enum
* DESCRIPTION
* Map mmi dtmf key to rtp dtmf key.
* PARAMETERS
* keyCode [IN] Mmi dtmf key
* RETURNS
* RTP dtmf key.
*****************************************************************************/
rtp_dtmf_code_enum mmi_voip_get_dtmf_keycode_enum(U16 *keyCode)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (*keyCode)
{
case KEY_0:
return RTP_DTMF_CODE_0;
case KEY_1:
return RTP_DTMF_CODE_1;
case KEY_2:
return RTP_DTMF_CODE_2;
case KEY_3:
return RTP_DTMF_CODE_3;
case KEY_4:
return RTP_DTMF_CODE_4;
case KEY_5:
return RTP_DTMF_CODE_5;
case KEY_6:
return RTP_DTMF_CODE_6;
case KEY_7:
return RTP_DTMF_CODE_7;
case KEY_8:
return RTP_DTMF_CODE_8;
case KEY_9:
return RTP_DTMF_CODE_9;
case KEY_STAR:
return RTP_DTMF_CODE_STAR;
case KEY_POUND:
return RTP_DTMF_CODE_HASH;
default:
return RTP_DTMF_CODE_TOTAL;
}
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_error_cause
* DESCRIPTION
* Map voip cc error cause to mmi error string.
* PARAMETERS
* result [IN] Major result
* cause [IN] Minor cause
* RETURNS
* String id of the error.
*****************************************************************************/
U16 mmi_voip_get_error_cause(U8 result, S32 cause)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (result)
{
case VOIP_ERROR: /* failure happens in VoIP task */
case VOIP_SIP_ERROR: /* failure happens in SIP task */
case VOIP_NAT_ERROR: /* NAT related error */
return mmi_voip_get_error_string(cause);
case VOIP_FS_ERROR: /* file system related error */
return srv_fmgr_fs_error_get_string(cause);
default:
return STR_ID_VOIP_UNKNOWN_ERROR;
}
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_error_string
* DESCRIPTION
* Look up error table to get corresponding error string.
* PARAMETERS
* cause [IN] Error cause
* RETURNS
* String id of the error.
*****************************************************************************/
U16 mmi_voip_get_error_string(S32 cause)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 i = 0, totalEntry = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
totalEntry = sizeof(g_voip_error_table) / sizeof(mmi_voip_error_string_struct);
for (i = 0; i < totalEntry; i++)
{
if (g_voip_error_table[i].errorNo == cause)
{
return g_voip_error_table[i].errorStr;
}
}
return STR_ID_VOIP_UNKNOWN_ERROR;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_set_outgoing_origin_app
* DESCRIPTION
* Put phonebook or call history structure to g_voip_cntx_p->call_originapp_info.
* PARAMETERS
* moOrigin [IN] Outgoing call origin, either MMI_VOIP_PHB or MMI_VOIP_HISTORY
* RETURNS
* TRUE means outgoing call does dial from phonebook or call history;
* FALSE means outgoing call neither dial from phonebook nor call history.
*****************************************************************************/
MMI_BOOL mmi_voip_set_outgoing_origin_app(mmi_voip_mo_origin_enum moOrigin)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
srv_phb_caller_info_struct* pb_data = NULL;
srv_phb_cm_number_struct req_info;
S32 uriLen = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (moOrigin == MMI_VOIP_PHB || moOrigin == MMI_VOIP_HISTORY)
{
srv_phb_caller_info_struct* pb_data = OslMalloc(sizeof(srv_phb_caller_info_struct));
memset((U8*)&req_info, 0x00, sizeof(srv_phb_cm_number_struct));
memset((U8*)pb_data, 0x00, sizeof(srv_phb_caller_info_struct));
req_info.number = (U16*)&(g_voip_cntx_p->call_misc_info.dispUri);
req_info.user_data = g_voip_ucm_user_data;
req_info.is_mo_call = MMI_TRUE; /* make mo call set MMI_TRUE, else set MMI_FALSE */
req_info.is_voip_call = MMI_TRUE; /* make voip call set MMI_TRUE, else set MMI_FALSE */
srv_phb_get_caller_info_by_number(&req_info, pb_data);
//MMI_PRINT(MOD_MMI_COMMON_APP, MMI_VOIP_TRC_GRP,"[VoIP] mmi_voip_set_outgoing_origin_app(), pb_name:%s", pb_data->name);
memset(&g_voip_cntx_p->call_originapp_info, 0, sizeof(mmi_voip_call_originapp_struct));
g_voip_cntx_p->call_originapp_info.moOrgin = moOrigin;
uriLen = (VOIP_DISP_NAME_LEN > mmi_ucs2strlen((S8*)pb_data->name)) ?
(mmi_ucs2strlen((S8*)pb_data->name)) : (VOIP_DISP_NAME_LEN - 1);
mmi_ucs2ncpy((S8*)g_voip_cntx_p->call_originapp_info.dispName, (S8*)pb_data->name, uriLen);
mmi_ucs2ncpy((S8*)g_voip_cntx_p->call_originapp_info.remoteUri, (S8*)g_voip_cntx_p->call_misc_info.dispUri, VOIP_URI_LEN - 1);
OslMfree(pb_data);
return MMI_TRUE;
}
return FALSE;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_outgoing_disp_name
* DESCRIPTION
* Determine to show display name or not for outgoing call.
* PARAMETERS
* moOrigin [IN] Outgoing call origin
* unicodeSrc [IN] Source uri string in unicode
* unicodeDest [IN/OUT] Destination uri string in unicode
* destLen [IN] Destination uri string length
* RETURNS
* TRUE means outgoing call should show display name;
* FALSE means outgoing call should not show display name.
*****************************************************************************/
MMI_BOOL mmi_voip_get_outgoing_disp_name(U8 moOrigin, U8* unicodeSrc, U8* unicodeDest, U8 destLen)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 uriLen = 0;
MMI_BOOL ret = MMI_FALSE;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if ((!mmi_ucs2cmp((S8*)unicodeSrc, (S8*)sos112)) ||
(!mmi_ucs2cmp((S8*)unicodeSrc, (S8*)sos911)) ||
(!mmi_ucs2cmp((S8*)unicodeSrc, (S8*)GetString(STR_ID_VOIP_EMERGENCY_NUM))))
{
uriLen = (destLen > mmi_ucs2strlen((S8*)GetString(STR_ID_VOIP_EMERGENCY_NUM))) ?
(mmi_ucs2strlen((S8*)GetString(STR_ID_VOIP_EMERGENCY_NUM))) : (destLen - 1);
memset(unicodeDest, 0, (destLen * ENCODING_LENGTH));
mmi_ucs2ncpy((S8*)unicodeDest, (S8*)GetString(STR_ID_VOIP_EMERGENCY_NUM), uriLen);
ret = MMI_TRUE;
}
if (ret == MMI_TRUE)
{
return ret;
}
if ((moOrigin & MMI_VOIP_HISTORY) == MMI_VOIP_HISTORY)
{
/* ensure the name from call history is not empty */
if ((g_voip_cntx_p->call_originapp_info.moOrgin == MMI_VOIP_HISTORY) &&
(mmi_ucs2strlen((S8*)g_voip_cntx_p->call_originapp_info.dispName)))
{
uriLen = (destLen >= VOIP_DISP_NAME_LEN) ? (VOIP_DISP_NAME_LEN) : (destLen - 1);
memset(unicodeDest, 0, (destLen * ENCODING_LENGTH));
mmi_ucs2ncpy((S8*)unicodeDest, (S8*)g_voip_cntx_p->call_originapp_info.dispName, uriLen);
ret = MMI_TRUE;
}
}
if ((moOrigin & MMI_VOIP_PHB) == MMI_VOIP_PHB)
{
/* ensure the name from phonebook is not empty */
if ((g_voip_cntx_p->call_originapp_info.moOrgin == MMI_VOIP_PHB) &&
(mmi_ucs2strlen((S8*)g_voip_cntx_p->call_originapp_info.dispName)))
{
uriLen = (destLen >= VOIP_DISP_NAME_LEN) ? (VOIP_DISP_NAME_LEN) : (destLen - 1);
memset(unicodeDest, 0, (destLen * ENCODING_LENGTH));
mmi_ucs2ncpy((S8*)unicodeDest, (S8*)g_voip_cntx_p->call_originapp_info.dispName, uriLen);
ret = MMI_TRUE;
}
}
return ret;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_redial_string
* DESCRIPTION
* Prepare redial display string.
* PARAMETERS
* unicodeStr [IN/OUT] Redial string in unicode
* RETURNS
* void
*****************************************************************************/
void mmi_voip_get_redial_string(U8 *unicodeStr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 newline[4] = { '\n', '\0', '\0', '\0' }; /* \n */
U8 *asciinumStr = OslMalloc(16);
U8 *unicodenumStr = OslMalloc(32);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
memset(asciinumStr, 0, 16);
sprintf((S8*)asciinumStr, "%d / %d", (g_voip_cntx_p->call_redial_info.currAttempt + 1), g_voip_cntx_p->call_redial_info.maxAttempt);
memset(unicodenumStr, 0, 32);
mmi_asc_to_ucs2((S8*)unicodenumStr, (S8*)asciinumStr);
mmi_ucs2cpy((S8*)unicodeStr, (S8*)unicodenumStr);
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_TIME_UNIT));
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
OslMfree(asciinumStr);
OslMfree(unicodenumStr);
MMI_ASSERT(unicodeStr[MMI_VOIP_MAX_STRING_LEN - 1] == '\0');
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_mwi_state_enum
* DESCRIPTION
* Map voip cc message waiting type to mmi message waiting string.
* PARAMETERS
* state [IN] Message waiting type
* RETURNS
* String id of message waiting.
*****************************************************************************/
U16 mmi_voip_get_mwi_state_enum(voip_mwi_type_enum state)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (state)
{
case VOIP_MWI_VOICE:
return STR_ID_VOIP_VOICE_MESSAGE;
case VOIP_MWI_FAX:
return STR_ID_VOIP_FAX_MESSAGE;
case VOIP_MWI_PAGER:
return STR_ID_VOIP_PAGER_MESSAGE;
case VOIP_MWI_MM:
return STR_ID_VOIP_MULTIMEDIA_MESSAGE;
case VOIP_MWI_TEXT:
return STR_ID_VOIP_TEXT_MESSAGE;
default:
return STR_ID_VOIP_UNKNOWN_MESSAGE;
}
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_mwi_string
* DESCRIPTION
* Prepare message waiting display string.
* PARAMETERS
* unicodeStr [IN/OUT] Message waiting string in unicode
* RETURNS
* void
*****************************************************************************/
void mmi_voip_get_mwi_string(U8 *unicodeStr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 newline[4] = { '\n', '\0', '\0', '\0' }; /* \n */
U8 *asciinumStr = OslMalloc(16);
U8 *unicodenumStr = OslMalloc(32);
U32 newMsg = 0, totalMsg = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
mmi_ucs2cpy((S8*)unicodeStr, GetString(STR_ID_VOIP_NEW_MESSAGE));
mmi_ucs2cat((S8*)unicodeStr, (S8*) newline);
newMsg = g_voip_cntx_p->msg_waiting_info.mwiMsg.newmsgs;
totalMsg = g_voip_cntx_p->msg_waiting_info.mwiMsg.newmsgs + g_voip_cntx_p->msg_waiting_info.mwiMsg.oldmsgs;
memset(asciinumStr, 0, 16);
sprintf((S8*)asciinumStr, "%d / %d", newMsg, totalMsg);
memset(unicodenumStr, 0, 32);
mmi_asc_to_ucs2((S8*)unicodenumStr, (S8*)asciinumStr);
mmi_ucs2cat((S8*)unicodeStr, (S8*)unicodenumStr);
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_MSG_UNIT));
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_URGENT_MESSAGE));
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
if (g_voip_cntx_p->msg_waiting_info.mwiMsg.is_urgent_present == TRUE)
{
newMsg = g_voip_cntx_p->msg_waiting_info.mwiMsg.new_urgentmsgs;
totalMsg =
g_voip_cntx_p->msg_waiting_info.mwiMsg.new_urgentmsgs +
g_voip_cntx_p->msg_waiting_info.mwiMsg.old_urgentmsgs;
memset(asciinumStr, 0, 16);
sprintf((S8*)asciinumStr, "%d / %d", newMsg, totalMsg);
memset(unicodenumStr, 0, 32);
mmi_asc_to_ucs2((S8*)unicodenumStr, (S8*)asciinumStr);
mmi_ucs2cat((S8*)unicodeStr, (S8*)unicodenumStr);
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_MSG_UNIT));
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
}
else
{
mmi_ucs2cat((S8*)unicodeStr, GetString(STR_ID_VOIP_NOT_SUPPORT));
mmi_ucs2cat((S8*)unicodeStr, (S8*)newline);
}
OslMfree(asciinumStr);
OslMfree(unicodenumStr);
MMI_ASSERT(unicodeStr[MMI_VOIP_MAX_STRING_LEN - 1] == '\0');
}
/*****************************************************************************
* FUNCTION
* mmi_voip_is_idle_state
* DESCRIPTION
* Check if it is in the idle screen or screen saver.
* PARAMETERS
* void
* RETURNS
* TRUE means it is in idle screen or screen saver;
* FALSE means it is not in idle screen or screen saver.
*****************************************************************************/
MMI_BOOL mmi_voip_is_idle_state(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_idle_context.IsOnIdleScreen || g_idle_context.ScreenSaverRunFlag)
{
return TRUE;
}
else
{
return FALSE;
}
}
/*****************************************************************************
* FUNCTION
* mmi_voip_is_keypad_lock_state
* DESCRIPTION
* Check if keypad is locked.
* PARAMETERS
* void
* RETURNS
* TRUE means it is in keypad lock; FALSE means it is not in keypad lock.
*****************************************************************************/
MMI_BOOL mmi_voip_is_keypad_lock_state(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_keylock_context.gKeyPadLockFlag)
{
return TRUE;
}
else
{
return FALSE;
}
}
/*****************************************************************************
* FUNCTION
* mmi_voip_is_empty_profile
* DESCRIPTION
* Check if the specific profile is empty.
* PARAMETERS
* profIndex [IN] Index of intended to check profile
* RETURNS
* TRUE means the specific profile is empty;
* FALSE means the specific profile is not empty.
*****************************************************************************/
MMI_BOOL mmi_voip_is_empty_profile(S32 profIndex)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
mmi_voip_update_prof_common_cache_to_disp(profIndex);
/* profile name is not default profile name, the profile is not empty */
if (mmi_ucs2cmp(
(S8*)g_voip_cntx_p->prof_setting_info.disp_prof.profileName,
(S8*)GetString(STR_ID_VOIP_PROF_COMMON_PROF1 + profIndex)))
{
return FALSE;
}
/* voice mail server is not empty and is not "sip:", the profile is not empty */
if (mmi_ucs2cmp(
(S8*)g_voip_cntx_p->prof_setting_info.disp_prof.serverName,
(S8*)sipUri))
{
return FALSE;
}
mmi_voip_update_prof_acct_cache_to_disp(profIndex);
if ((mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.disp_prof.serverName)) ||
(mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.disp_prof.displayName)) ||
(mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.disp_prof.password)) ||
(mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.disp_prof.authName)))
{
return FALSE;
}
/* port is not 5060, the profile is not empty */
if (g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].acct_info.sipPort != 5060)
{
return FALSE;
}
/* username is not empty and is not "sip:", the profile is not empty */
if (mmi_ucs2cmp(
(S8*)g_voip_cntx_p->prof_setting_info.disp_prof.username,
(S8*)sipUri))
{
return FALSE;
}
mmi_voip_update_prof_outbound_cache_to_disp(profIndex);
if ((mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.disp_prof.serverName)) ||
(mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.disp_prof.username)) ||
(mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.disp_prof.password)))
{
return FALSE;
}
if (g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].out_server_info.port != 0)
{
return FALSE;
}
mmi_voip_update_prof_register_cache_to_disp(profIndex);
if ((mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.disp_prof.serverName)) ||
(mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.disp_prof.username)) ||
(mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.disp_prof.password)))
{
return FALSE;
}
if (g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].reg_server_info.port != 0)
{
return FALSE;
}
mmi_voip_update_prof_nat_cache_to_disp(profIndex);
if ((mmi_ucs2strlen((S8*)g_voip_cntx_p->prof_setting_info.disp_prof.serverName)))
{
return FALSE;
}
if ((g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].nat_info.natFirewall[0] != 0) ||
(g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].nat_info.natFirewall[1] != 0) ||
(g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].nat_info.natFirewall[2] != 0) ||
(g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].nat_info.natFirewall[3] != 0))
{
return FALSE;
}
if (g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].nat_info.stunPort != 3478)
{
return FALSE;
}
if (g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].nat_info.refInterval != 2)
{
return FALSE;
}
return TRUE;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_is_owner_number
* DESCRIPTION
* Check if two strings are the same, regardless of the difference of capital or lowercase.
* PARAMETERS
* unicodeSrc1 [IN] String 1 in unicode
* unicodeSrc2 [IN] String 2 in unicode
* RETURNS
* TRUE means lowercase of the two strings are the same;
* FALSE means lowercase of the two strings are different.
*****************************************************************************/
MMI_BOOL mmi_voip_is_owner_number(U8 *unicodeSrc1, U8 *unicodeSrc2)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *lowercaseSrc1 = OslMalloc(VOIP_URI_LEN * ENCODING_LENGTH);
U8 *lowercaseSrc2 = OslMalloc(VOIP_URI_LEN * ENCODING_LENGTH);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
memset(lowercaseSrc1, 0, (VOIP_URI_LEN * ENCODING_LENGTH));
mmi_voip_convert_uri_lower_case(unicodeSrc1, lowercaseSrc1, VOIP_URI_LEN * ENCODING_LENGTH);
memset(lowercaseSrc2, 0, (VOIP_URI_LEN * ENCODING_LENGTH));
mmi_voip_convert_uri_lower_case(unicodeSrc2, lowercaseSrc2, VOIP_URI_LEN * ENCODING_LENGTH);
if (!mmi_ucs2cmp((S8*)lowercaseSrc1, (S8*)lowercaseSrc2))
{
OslMfree(lowercaseSrc1);
OslMfree(lowercaseSrc2);
return TRUE;
}
else
{
OslMfree(lowercaseSrc1);
OslMfree(lowercaseSrc2);
return FALSE;
}
}
/*****************************************************************************
* FUNCTION
* mmi_voip_is_sos_number
* DESCRIPTION
* Check if given uri is an emergency number, including 112, 911, sos...etc,
* regardless of the difference of capital or lowercase.
* PARAMETERS
* unicodeUri [IN] Uri string in unicode
* RETURNS
* TRUE means it is an emergency number;
* FALSE means it is not an emergency number.
*****************************************************************************/
MMI_BOOL mmi_voip_is_sos_number(U8 *unicodeUri)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *copyUri = OslMalloc((VOIP_URI_LEN + 1) * ENCODING_LENGTH);
U8 *sipsosStr = OslMalloc(32);
U8 asciiatStr[2], unicodeatStr[4];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
memset(copyUri, 0, ((VOIP_URI_LEN + 1) * ENCODING_LENGTH));
mmi_ucs2ncpy((S8*)copyUri, (S8*)unicodeUri, VOIP_URI_LEN);
mmi_voip_parse_uri(copyUri); /* do not modify unicodeUri directly because unicodeUri could be an empty uri */
mmi_voip_convert_uri_lower_case(copyUri, copyUri, VOIP_URI_LEN * ENCODING_LENGTH);
memset(asciiatStr, 0, 2);
sprintf((S8*)asciiatStr, "@");
memset(unicodeatStr, 0, 4);
mmi_asc_to_ucs2((S8*)unicodeatStr, (S8*)asciiatStr);
memset(sipsosStr, 0, 32);
mmi_ucs2ncpy((S8*)sipsosStr, (S8*)sipUri, mmi_ucs2strlen((S8*)sipUri));
mmi_ucs2ncat((S8*)sipsosStr, (S8*)sos112, mmi_ucs2strlen((S8*)sos112));
mmi_ucs2cat((S8*)sipsosStr, (S8*)unicodeatStr);
if (!mmi_ucs2ncmp((S8*)copyUri, (S8*)sipsosStr, mmi_ucs2strlen((S8*)sipsosStr)))
{
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_VOIP_TRC_GRP, "\n[mmi_voip_is_sos_number] Detect sip:112@ Pattern!\n");
g_voip_cntx_p->call_misc_info.isSOS = TRUE;
}
memset(sipsosStr, 0, 32);
mmi_ucs2ncpy((S8*)sipsosStr, (S8*)sipUri, mmi_ucs2strlen((S8*)sipUri));
mmi_ucs2ncat((S8*)sipsosStr, (S8*)sos911, mmi_ucs2strlen((S8*)sos911));
mmi_ucs2cat((S8*)sipsosStr, (S8*)unicodeatStr);
if (!mmi_ucs2ncmp((S8*)copyUri, (S8*)sipsosStr, mmi_ucs2strlen((S8*)sipsosStr)))
{
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_VOIP_TRC_GRP, "\n[mmi_voip_is_sos_number] Detect sip:911@ Pattern!\n");
g_voip_cntx_p->call_misc_info.isSOS = TRUE;
}
memset(sipsosStr, 0, 32);
mmi_ucs2ncpy((S8*)sipsosStr, (S8*)sipUri, mmi_ucs2strlen((S8*)sipUri));
mmi_ucs2ncat((S8*)sipsosStr, (S8*)sosUri, mmi_ucs2strlen((S8*)sosUri));
mmi_ucs2cat((S8*)sipsosStr, (S8*)unicodeatStr);
if (!mmi_ucs2ncmp((S8*)copyUri, (S8*)sipsosStr, mmi_ucs2strlen((S8*)sipsosStr)))
{
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_VOIP_TRC_GRP, "\n[mmi_voip_is_sos_number] Detect sip:sos@ Pattern!\n");
g_voip_cntx_p->call_misc_info.isSOS = TRUE;
}
OslMfree(copyUri);
OslMfree(sipsosStr);
if (g_voip_cntx_p->call_misc_info.isSOS == TRUE)
{
memset(unicodeUri, 0, (VOIP_URI_LEN * ENCODING_LENGTH));
mmi_ucs2cpy((S8*)unicodeUri, (S8*)sos112);
g_voip_cntx_p->call_misc_info.isSOS = FALSE;
return TRUE;
}
return FALSE;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_is_codec_compatible
* DESCRIPTION
* Check if held call's codec is allowed to merge to active call before merging call.
* PARAMETERS
* codecList [IN] Supported codec list of the held call.
* firstcodecOnly [IN] Only compare to the first codec in codec list.
* RETURNS
* TRUE means the codecs are compatible to merge;
* FALSE means the codecs are not compatible to merge.
*****************************************************************************/
MMI_BOOL mmi_voip_is_codec_compatible(voip_codec_enum *codecList, MMI_BOOL firstcodecOnly)
{
#ifdef __MMI_TARGET__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 codecSupport = 0, localCodec = 0;
med_voip_codec_cap_struct codecDetail;
S32 i = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
voip_get_codec_cap(VOIP_ENCODE_DECODE, &codecSupport, &codecDetail);
if (firstcodecOnly == TRUE)
{
/* current held call in-use codec must in the codec support list
so that two calls can be merged */
if ((codecSupport & codecList[0]) != 0)
{
return TRUE;
}
}
else
{
for (i = 0; i < VOIP_MAX_NUM_CODEC; i++)
{
localCodec |= codecList[i];
}
if ((codecSupport & localCodec) != 0)
{
return TRUE;
}
}
return FALSE;
#else
/* always return true for modis and pc simulator */
return TRUE;
#endif /* __MMI_TARGET__ */
}
/*****************************************************************************
* FUNCTION
* mmi_voip_is_addr_change
* DESCRIPTION
* Check if sdp address or port is changed.
* PARAMETERS
* mmiSdp [IN] Sdp in mmi, which represents last sdp info.
* voipSdp [IN] Sdp in voip cc, which represents current sdp info.
* RETURNS
* TRUE means the sdp addr or port is changed;
* FALSE means the sdp addr and port is not changed.
*****************************************************************************/
MMI_BOOL mmi_voip_is_addr_change(voip_sdp_struct *mmiSdp, voip_sdp_struct *voipSdp)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if ((strncmp((S8*) mmiSdp->local_addr, (S8*) voipSdp->local_addr, VOIP_MAX_IP_SEG_LEN)) ||
(strncmp((S8*) mmiSdp->remote_addr, (S8*) voipSdp->remote_addr, VOIP_MAX_IP_SEG_LEN)) ||
(mmiSdp->local_rtp_port != voipSdp->local_rtp_port) ||
(mmiSdp->remote_rtp_port != voipSdp->remote_rtp_port) ||
(mmiSdp->local_rtcp_port != voipSdp->local_rtcp_port) ||
(mmiSdp->remote_rtcp_port != voipSdp->remote_rtcp_port))
{
return TRUE;
}
return FALSE;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_decoded_dtnct_id
* DESCRIPTION
* get decoded data account id.
* PARAMETERS
* dtnct_id
* RETURNS
* void
*****************************************************************************/
U32 mmi_voip_get_decoded_dtnct_id(U32 dtnct_id)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
cbm_sim_id_enum sim_id;
kal_uint8 app_id;
kal_bool always_ask;
kal_uint32 ori_acc_id;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
cbm_decode_data_account_id(dtnct_id, &sim_id,&app_id, &always_ask, &ori_acc_id);
return ori_acc_id;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_app_total_call
* DESCRIPTION
* Total number of voip calls, including outgoing call, incoming call,
* active call, held call, etc.
* PARAMETERS
* void
* RETURNS
* 0 means voip not in-call, !0 means voip in-call.
*****************************************************************************/
S32 mmi_voip_app_total_call(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return g_voip_cntx_p->call_list_info.numTotal;
}
/*****************************************************************************
* FUNCTION
* mmi_voip_app_total_call
* DESCRIPTION
* Total number of voip calls, including outgoing call, incoming call,
* active call, held call, etc.
* PARAMETERS
* void
* RETURNS
* 0 means voip not in-call, !0 means voip in-call.
*****************************************************************************/
S32 mmi_voip_query_call_count(mmi_voip_call_state_enum state)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 incoming_call_num = 0;
S32 outgoing_call_num = 0;
mmi_voip_call_list_struct *call_list = &g_voip_cntx_p->call_list_info;
U32 i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch(state)
{
case MMI_VOIP_CALL_STATE_ALL:
return g_voip_cntx_p->call_list_info.numTotal;
case MMI_VOIP_HOLD_STATE:
return g_voip_cntx_p->call_list_info.numHeld;
case MMI_VOIP_ACTIVE_STATE:
case MMI_VOIP_INCOMING_STATE:
case MMI_VOIP_OUTGOING_STATE:
{
for (i = 0; i < MMI_VOIP_MAX_NUM_CALL; i++)
{
if (call_list->call_info[i].currState == MMI_VOIP_INCOMING_STATE)
{
incoming_call_num += 1;
}
else if (call_list->call_info[i].currState == MMI_VOIP_OUTGOING_STATE)
{
outgoing_call_num += 1;
}
}
if (state == MMI_VOIP_INCOMING_STATE)
{
return incoming_call_num;
}
else if (state == MMI_VOIP_OUTGOING_STATE)
{
return outgoing_call_num;
}
else
{
return (g_voip_cntx_p->call_list_info.numTotal -
g_voip_cntx_p->call_list_info.numHeld -
incoming_call_num -
outgoing_call_num);
}
}
default:
return 0;
}
}
/*****************************************************************************
* FUNCTION
* mmi_voip_get_call_n_dialog_id
* DESCRIPTION
* Get call id
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_voip_get_call_n_dialog_id(mmi_voip_call_state_enum state, S32* call_id, S32* dialog_id)
{
U32 i = 0;
mmi_voip_call_list_struct *call_list = &g_voip_cntx_p->call_list_info;
MMI_BOOL is_found = MMI_FALSE;
ASSERT((state == MMI_VOIP_OUTGOING_STATE) || (state == MMI_VOIP_INCOMING_STATE) || (state == MMI_VOIP_ACTIVE_STATE));
for (i = 0; i < MMI_VOIP_MAX_NUM_CALL; i++)
{
if (call_list->call_info[i].currState == state)
{
*call_id = call_list->call_info[i].callId;
*dialog_id = call_list->call_info[i].dialog_info[0].dialogId;
is_found = MMI_TRUE;
break;
}
}
ASSERT(is_found == MMI_TRUE);
}
/*****************************************************************************
* FUNCTION
* srv_gcall_get_caller_res_info
* DESCRIPTION
*
* PARAMETERS
* info [IN/OUT] caller resource info
* RETURNS
* MMI_FALSE if fails
*****************************************************************************/
MMI_BOOL mmi_voip_get_caller_res_info(void *info)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
srv_ucm_int_query_caller_res_struct *ucm_res_info = (srv_ucm_int_query_caller_res_struct*)info;
S16 call_id = 0, dialog_id = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (!info)
{
return MMI_FALSE;
}
call_id = ucm_res_info->uid_info.group_id;
dialog_id = mmi_voip_get_actual_dialog_id(ucm_res_info->uid_info.call_id);
/* decide image id */
if (g_voip_cntx_p->call_list_info.call_info[call_id].currState == MMI_VOIP_OUTGOING_STATE)
{
ucm_res_info->pic_id = IMG_ID_GCALL_OUTGOING;
}
else
{
ucm_res_info->pic_id = IMG_PHB_DEFAULT;
}
/* decide tone id */
srv_prof_get_current_profile_value(
SRV_PROF_SETTINGS_MT_CALL_TONE,
&(ucm_res_info->tone_id));
ucm_res_info->tone_path[0] = 0;
ucm_res_info->tone_path[1] = 0;
ucm_res_info->pic_path[0] = 0;
ucm_res_info->pic_path[1] = 0;
//memcpy(ucm_res_info->tone_path, 0, sizeof(ucm_res_info->tone_path));
//memcpy(ucm_res_info->pic_path, 0, sizeof(ucm_res_info->pic_path));
ucm_res_info->is_video_sound = MMI_FALSE;
/* decide res type */
ucm_res_info->res_type = SRV_UCM_RES_TYPE_TONE_ID | SRV_PHB_RES_TYPE_IMAGE_ID;
return MMI_TRUE;
}
#endif /* __MMI_VOIP__ */